UNPKG

@prismatic-io/spectral

Version:

Utility library for building Prismatic connectors and code-native integrations

12 lines (11 loc) 1.03 kB
import type { ConditionalExpression } from "./conditional-logic"; import type { Connection, InputCleanFunction, InputFieldCollection, Inputs, KeyValuePair } from "./Inputs"; /** * Collection of input parameters. * Inputs can be static values, references to config variables, or * references to previous steps' outputs. */ export type ActionInputParameters<TInputs extends Inputs> = { [Property in keyof TInputs]: TInputs[Property]["clean"] extends InputCleanFunction<any> ? ReturnType<TInputs[Property]["clean"]> : TInputs[Property]["type"] extends "connection" ? ExtractValue<Connection, TInputs[Property]["collection"]> : TInputs[Property]["type"] extends "conditional" ? ExtractValue<ConditionalExpression, TInputs[Property]["collection"]> : ExtractValue<TInputs[Property]["default"], TInputs[Property]["collection"]>; }; export type ExtractValue<TType, TCollection extends InputFieldCollection | undefined> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] : TCollection extends "valuelist" ? TType[] : TType;