import { ChoiceCore, ChoiceValue } from "./choice-type"; import { ArrayTypeBaseCore, ObjectTypeBaseCore } from "./container-types"; import { DynamicCore, GraphQLCore, GraphQLValue } from "./misc-types"; import { DateRangeStringsCore, DateStringCore, NumberTypeBaseCore, RichBooleanCore } from "./primitive-types"; import { QueryBuilderCore } from "./query-builder-types"; import { CommonTypeBase, ContextDependentConfig, Defaultable, GenericContext } from "./shared-controls"; import { Nullish } from "./type-utils"; /** * `[string, number]` -> `[string | undefined, number | undefined]` */ export type PartialParams
= { [K in keyof P]: P[K] | undefined; }; export type FunctionControlContext
= GenericContext = ContextDependentConfig = string> extends TypeBaseDefault = "string" | PlainStringType | ChoiceType | DateStringType | DateRangeStringsType | AnyType ;
export interface PlainNumberType = number> extends TypeBaseDefault = PlainNumberType | (TypeBaseDefault | AnyType ;
export interface PlainBooleanType = boolean> extends TypeBaseDefault = PlainBooleanType | (TypeBaseDefault | AnyType ;
export type GraphQLType = TypeBaseDefault extends TypeBaseDefault = PlainNullType | AnyType ;
export interface PlainUndefinedType extends TypeBaseDefault = PlainUndefinedType | AnyType ;
export type ExtractObjectKeys = Record , ExtractObjectKeys = TypeBaseDefault >;
export type QueryBuilderType = TypeBaseDefault extends TypeBaseDefault = PlainAnyType ;
export interface PlainVoidType extends CommonTypeBase {
type: "void";
}
export type VoidType = PlainVoidType | AnyType ;
type IsAny = T extends GraphQLValue ? GraphQLType : T extends null ? NullType : T extends undefined ? UndefinedType : T extends Array : T extends object ? ObjectType : AnyType ;
type AnyTyping = T extends string ? StringType : T extends number ? NumberType : T extends boolean ? BooleanType : CommonType ;
export type ChoiceTypeBase = TypeBaseDefault extends ChoiceTypeBase {
multiSelect?: false;
}
export interface MultiChoiceType extends ChoiceTypeBase {
multiSelect: true;
}
export interface CustomChoiceType extends ChoiceTypeBase {
multiSelect: FunctionContextConfig ;
}
export type ChoiceType = SingleChoiceType | MultiChoiceType | CustomChoiceType ;
export type DateStringType = TypeBaseDefault = TypeBaseDefault extends CommonTypeBase, DynamicCore > {
}
export type RestrictedType = IsAny : [
T
] extends [string] ? StringType : [T] extends [number] ? NumberType : [T] extends [boolean] ? BooleanType : T extends string | null | undefined ? Exclude : CommonType : T extends number | null | undefined ? Exclude : CommonType : T extends boolean | null | undefined ? Exclude : CommonType : CommonType ;
export type GenericType = RestrictedType | DynamicType | QueryBuilderType ;
export interface ParamTypeBase {
name: string;
}
export type ParamType = ParamTypeBase & GenericType ;
export type RequiredParam = ParamTypeBase & ParamType & {
isOptional?: false;
isRestParameter?: false;
};
export type OptionalParam = ParamTypeBase & ParamType & {
isRestParameter?: false;
};
export type RestParam = ParamTypeBase & ParamType & {
isOptional?: false;
isRestParameter: true;
};
type RequiredParams = R extends [
infer H,
...infer T
] ? [string | RequiredParam , ...HandleRequiredParams ] : [];
type HandleOptionalParams = R extends [
infer H,
...infer T
] ? [] | [
string | OptionalParam ,
...HandleOptionalParams
] : R extends [] ? [] : R extends Array ] : [];
export type HandleParams = [
...HandleRequiredParams >,
...HandleOptionalParams >>
];
export type HandleReturnType = VoidType | ParamType ;
export {};