/** numeric strings */ declare type NumberType = "float32" | "float64" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32"; /** string strings */ declare type StringType = "string" | "timestamp"; /** Generic JTD Schema without inference of the represented type */ export declare type SomeJTDSchemaType = (// ref { ref: string; } | { type: NumberType | StringType | "boolean"; } | { enum: string[]; } | { elements: SomeJTDSchemaType; } | { values: SomeJTDSchemaType; } | { properties: Record; optionalProperties?: Record; additionalProperties?: boolean; } | { properties?: Record; optionalProperties: Record; additionalProperties?: boolean; } | { discriminator: string; mapping: Record; } | {}) & { nullable?: boolean; metadata?: Record; definitions?: Record; }; /** required keys of an object, not undefined */ declare type RequiredKeys = { [K in keyof T]-?: undefined extends T[K] ? never : K; }[keyof T]; /** optional or undifined-able keys of an object */ declare type OptionalKeys = { [K in keyof T]-?: undefined extends T[K] ? K : never; }[keyof T]; /** type is true if T is a union type */ declare type IsUnion_ = false extends (T extends unknown ? ([U] extends [T] ? false : true) : never) ? false : true; declare type IsUnion = IsUnion_; /** type is true if T is identically E */ declare type TypeEquality = [T] extends [E] ? ([E] extends [T] ? true : false) : false; /** type is true if T or null is identically E or null*/ declare type NullTypeEquality = TypeEquality; /** gets only the string literals of a type or null if a type isn't a string literal */ declare type EnumString = [T] extends [never] ? null : T extends string ? string extends T ? null : T : null; /** true if type is a union of string literals */ declare type IsEnum = null extends EnumString> ? false : true; /** true only if all types are array types (not tuples) */ declare type IsElements = false extends IsUnion ? [T] extends [readonly unknown[]] ? undefined extends T[0.5] ? false : true : false : false; /** true if the the type is a values type */ declare type IsValues = false extends IsUnion> ? TypeEquality, string> : false; /** true if type is a proeprties type and Union is false, or type is a discriminator type and Union is true */ declare type IsRecord = Union extends IsUnion> ? null extends EnumString> ? false : true : false; /** actual schema */ export declare type JTDSchemaType = Record> = (// refs - where null wasn't specified, must match exactly (null extends EnumString ? never : ({ [K in keyof D]: [T] extends [D[K]] ? { ref: K; } : never; }[keyof D] & { nullable?: false; }) | (null extends T ? { [K in keyof D]: [Exclude] extends [Exclude] ? { ref: K; } : never; }[keyof D] & { nullable: true; } : never)) | (unknown extends T ? { nullable?: boolean; } : never) | ((true extends NullTypeEquality ? { type: NumberType; } : true extends NullTypeEquality ? { type: "boolean"; } : true extends NullTypeEquality ? { type: StringType; } : true extends NullTypeEquality ? { type: "timestamp"; } : true extends IsEnum ? { enum: EnumString>[]; } : true extends IsElements> ? T extends readonly (infer E)[] ? { elements: JTDSchemaType; } : never : true extends IsValues ? T extends Record ? { values: JTDSchemaType; } : never : true extends IsRecord ? ([RequiredKeys>] extends [never] ? { properties?: Record; } : { properties: { [K in RequiredKeys]: JTDSchemaType; }; }) & ([OptionalKeys>] extends [never] ? { optionalProperties?: Record; } : { optionalProperties: { [K in OptionalKeys]: JTDSchemaType, D>; }; }) & { additionalProperties?: boolean; } : true extends IsRecord ? { [K in keyof Exclude]-?: Exclude[K] extends string ? { discriminator: K; mapping: { [M in Exclude[K]]: JTDSchemaType, D>; }; } : never; }[keyof Exclude] : never) & (null extends T ? { nullable: true; } : { nullable?: false; }))) & { metadata?: Record; definitions?: { [K in keyof D]: JTDSchemaType; }; }; declare type JTDDataDef> = // ref (S extends { ref: string; } ? D extends { [K in S["ref"]]: infer V; } ? JTDDataDef : never : S extends { type: NumberType; } ? number : S extends { type: "boolean"; } ? boolean : S extends { type: "string"; } ? string : S extends { type: "timestamp"; } ? string | Date : S extends { enum: readonly (infer E)[]; } ? string extends E ? never : [E] extends [string] ? E : never : S extends { elements: infer E; } ? JTDDataDef[] : S extends { properties: Record; optionalProperties?: Record; additionalProperties?: boolean; } ? { -readonly [K in keyof S["properties"]]-?: JTDDataDef; } & { -readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef; } & ([S["additionalProperties"]] extends [true] ? Record : unknown) : S extends { properties?: Record; optionalProperties: Record; additionalProperties?: boolean; } ? { -readonly [K in keyof S["properties"]]-?: JTDDataDef; } & { -readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef; } & ([S["additionalProperties"]] extends [true] ? Record : unknown) : S extends { values: infer V; } ? Record> : S extends { discriminator: infer M; mapping: Record; } ? [M] extends [string] ? { [K in keyof S["mapping"]]: JTDDataDef & { [KM in M]: K; }; }[keyof S["mapping"]] : never : unknown) | (S extends { nullable: true; } ? null : never); export declare type JTDDataType = S extends { definitions: Record; } ? JTDDataDef : JTDDataDef>; export {};