+/** 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<string, SomeJTDSchemaType>;
+ optionalProperties?: Record<string, SomeJTDSchemaType>;
+ additionalProperties?: boolean;
+} | {
+ properties?: Record<string, SomeJTDSchemaType>;
+ optionalProperties: Record<string, SomeJTDSchemaType>;
+ additionalProperties?: boolean;
+} | {
+ discriminator: string;
+ mapping: Record<string, SomeJTDSchemaType>;
+} | {}) & {
+ nullable?: boolean;
+ metadata?: Record<string, unknown>;
+ definitions?: Record<string, SomeJTDSchemaType>;
+};
/** required keys of an object, not undefined */
declare type RequiredKeys<T> = {
[K in keyof T]-?: undefined extends T[K] ? never : K;
declare type IsValues<T> = false extends IsUnion<Exclude<T, null>> ? TypeEquality<keyof Exclude<T, null>, 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<T, Union extends boolean> = Union extends IsUnion<Exclude<T, null>> ? null extends EnumString<keyof Exclude<T, null>> ? false : true : false;
-/** numeric strings */
-declare type NumberType = "float32" | "float64" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32";
-/** string strings */
-declare type StringType = "string" | "timestamp";
/** actual schema */
export declare type JTDSchemaType<T, D extends Record<string, unknown> = Record<string, never>> = (// refs - where null wasn't specified, must match exactly
(null extends EnumString<keyof D> ? never : ({
} : true extends IsElements<Exclude<T, null>> ? T extends readonly (infer E)[] ? {
elements: JTDSchemaType<E, D>;
} : never : true extends IsValues<T> ? T extends Record<string, infer V> ? {
- values: JTDSchemaType<V>;
+ values: JTDSchemaType<V, D>;
} : never : true extends IsRecord<T, false> ? ([RequiredKeys<Exclude<T, null>>] extends [never] ? {
properties?: Record<string, never>;
} : {
};
declare type JTDDataDef<S, D extends Record<string, unknown>> = (S extends {
ref: string;
-} ? JTDDataDef<D[S["ref"]], D> : S extends {
+} ? D extends {
+ [K in S["ref"]]: infer V;
+} ? JTDDataDef<V, D> : never : S extends {
type: NumberType;
} ? number : S extends {
+ type: "boolean";
+} ? boolean : S extends {
type: "string";
} ? string : S extends {
type: "timestamp";