import { OptionalParamSlugs, OptionalParamSlugsWithoutDefaults, Param, ParamType, PromptParam, PromptParamType } from "./params"; import { OutputParamValueByType } from "./params_output"; import { SerializedParamValueByType } from "./params_serialized"; import { ConfigVar } from "../api/types"; import { AirplaneFile } from "../file"; import { AirplaneFileObject } from "../file/file_object"; import { IfEmptyUndefined, Optional } from "../type_helpers"; export type InputParamValueByType = Omit & { upload: string | AirplaneFileObject | AirplaneFile; date: string | Date; datetime: string | Date; configvar: string | ConfigVar; }; export type InputParamType = keyof InputParamValueByType; export type InputParamValue = InputParamValueByType[keyof InputParamValueByType] | undefined; export type InputParamValues = TParams extends Record ? Record | undefined : IfEmptyUndefined["multi"] extends true ? InputParamValueByType[NormalizeAsObject["type"]][] : InputParamValueByType[NormalizeAsObject["type"]]; }, OptionalParamSlugs>>>; /** * InputParam accepts a shorthand of a param type or a fully-specified parameter object. * * A shorthand of `"TYPE"` is equivalent to `{ type: "TYPE" }`. */ export type InputParam = ParamType | Param; /** * InputParams are a set of parameters keyed by parameter slug. * * The order of parameters within the object is retained for ordering parameters in form UIs. */ export type InputParams = Record; /** * PromptInputParams are the subset of InputParams that are available to prompts. * * Currently config variables and files are not supported by prompts. Once those are supported, * we can remove this in favor of using InputParams directly. */ export type PromptInputParams = Record; type NormalizeAsObjects = { [TSlug in keyof TInputParams]: NormalizeAsObject; }; type NormalizeAsObject = TInputParam extends ParamType ? { type: TInputParam; required: true; multi: false; } : TInputParam extends Param ? TInputParam : Param; export type InputToSerializedParamValues = TParams extends Record ? Record : Optional<{ [TSlug in keyof TParams]: NormalizeAsObject["multi"] extends true ? SerializedParamValueByType[NormalizeAsObject["type"]][] : SerializedParamValueByType[NormalizeAsObject["type"]]; }, OptionalParamSlugsWithoutDefaults>>; export type InputToOutputParamValues = TParams extends Record ? Record : Optional<{ [TSlug in keyof TParams]: NormalizeAsObject["multi"] extends true ? OutputParamValueByType[NormalizeAsObject["type"]][] : OutputParamValueByType[NormalizeAsObject["type"]]; }, OptionalParamSlugsWithoutDefaults>>; export {};