@sinclair/typebox 0.26.0-dev.1 → 0.26.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/compiler.d.ts +33 -33
- package/compiler/compiler.js +536 -536
- package/compiler/index.d.ts +2 -2
- package/compiler/index.js +47 -47
- package/errors/errors.d.ts +84 -77
- package/errors/errors.js +570 -553
- package/errors/index.d.ts +1 -1
- package/errors/index.js +44 -44
- package/package.json +2 -2
- package/readme.md +4 -10
- package/system/index.d.ts +1 -1
- package/system/index.js +44 -44
- package/system/system.d.ts +20 -20
- package/system/system.js +69 -69
- package/typebox.d.ts +648 -648
- package/typebox.js +1881 -1875
- package/value/cast.d.ts +26 -26
- package/value/cast.js +348 -348
- package/value/check.d.ts +8 -8
- package/value/check.js +450 -450
- package/value/clone.d.ts +3 -3
- package/value/clone.js +71 -71
- package/value/convert.d.ts +13 -13
- package/value/convert.js +345 -345
- package/value/create.d.ts +18 -18
- package/value/create.js +430 -430
- package/value/delta.d.ts +43 -43
- package/value/delta.js +204 -204
- package/value/equal.d.ts +3 -3
- package/value/equal.js +80 -80
- package/value/hash.d.ts +8 -8
- package/value/hash.js +208 -208
- package/value/index.d.ts +5 -5
- package/value/index.js +56 -55
- package/value/is.d.ts +11 -11
- package/value/is.js +53 -53
- package/value/pointer.d.ts +24 -24
- package/value/pointer.js +142 -142
- package/value/value.d.ts +26 -26
- package/value/value.js +93 -93
package/typebox.d.ts
CHANGED
|
@@ -1,648 +1,648 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type
|
|
10
|
-
export type
|
|
11
|
-
export type
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[Modifier]?: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
export type
|
|
87
|
-
export type
|
|
88
|
-
export type
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
[Key in keyof
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
export type
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
export type TExtract<T extends TSchema, U extends TSchema> = T extends TUnion<infer S> ? TExtractArray<S, U> : T extends U ? T : TNever;
|
|
139
|
-
export type TFunctionParameters<T extends readonly TSchema[], P extends unknown[]> = [...{
|
|
140
|
-
[K in keyof T]: Static<Assert<T[K], TSchema>, P>;
|
|
141
|
-
}];
|
|
142
|
-
export interface TFunction<T extends readonly TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
143
|
-
[Kind]: 'Function';
|
|
144
|
-
static: (...param: TFunctionParameters<T, this['params']>) => Static<U, this['params']>;
|
|
145
|
-
type: 'object';
|
|
146
|
-
instanceOf: 'Function';
|
|
147
|
-
parameters: T;
|
|
148
|
-
returns: U;
|
|
149
|
-
}
|
|
150
|
-
export interface TInteger extends TSchema, NumericOptions<number> {
|
|
151
|
-
[Kind]: 'Integer';
|
|
152
|
-
static: number;
|
|
153
|
-
type: 'integer';
|
|
154
|
-
}
|
|
155
|
-
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
156
|
-
export interface IntersectOptions extends SchemaOptions {
|
|
157
|
-
unevaluatedProperties?: TUnevaluatedProperties;
|
|
158
|
-
}
|
|
159
|
-
export type TIntersectStatic<T extends TSchema[], P extends unknown[]> = TupleToIntersect<{
|
|
160
|
-
[K in keyof T]: Static<Assert<T[K], TSchema>, P>;
|
|
161
|
-
}>;
|
|
162
|
-
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
163
|
-
[Kind]: 'Intersect';
|
|
164
|
-
type?: 'object';
|
|
165
|
-
static: TIntersectStatic<T, this['params']>;
|
|
166
|
-
allOf: [...T];
|
|
167
|
-
}
|
|
168
|
-
export type TKeyOfTuple<T extends TSchema> = {
|
|
169
|
-
[K in keyof Static<T>]: TLiteral<Assert<K, TLiteralValue>>;
|
|
170
|
-
} extends infer U ? UnionToTuple<Exclude<{
|
|
171
|
-
[K in keyof U]: U[K];
|
|
172
|
-
}[keyof U], undefined>> : never;
|
|
173
|
-
export type TKeyOf<T extends TSchema = TSchema
|
|
174
|
-
]) extends infer R ?
|
|
175
|
-
export type TLiteralValue = string | number | boolean | bigint;
|
|
176
|
-
export interface TLiteral<T extends TLiteralValue = TLiteralValue> extends TSchema {
|
|
177
|
-
[Kind]: 'Literal';
|
|
178
|
-
static: T;
|
|
179
|
-
const: T;
|
|
180
|
-
}
|
|
181
|
-
export interface TNever extends TSchema {
|
|
182
|
-
[Kind]: 'Never';
|
|
183
|
-
static: never;
|
|
184
|
-
allOf: [{
|
|
185
|
-
type: 'boolean';
|
|
186
|
-
const: false;
|
|
187
|
-
}, {
|
|
188
|
-
type: 'boolean';
|
|
189
|
-
const: true;
|
|
190
|
-
}];
|
|
191
|
-
}
|
|
192
|
-
export type TNotStatic<_ extends TSchema = TSchema, T extends TSchema = TSchema> = Static<T>;
|
|
193
|
-
export interface TNot<Not extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
|
|
194
|
-
[Kind]: 'Not';
|
|
195
|
-
static: TNotStatic<Not, T>;
|
|
196
|
-
allOf: [{
|
|
197
|
-
not: Not;
|
|
198
|
-
}, T];
|
|
199
|
-
}
|
|
200
|
-
export interface TNull extends TSchema {
|
|
201
|
-
[Kind]: 'Null';
|
|
202
|
-
static: null;
|
|
203
|
-
type: 'null';
|
|
204
|
-
}
|
|
205
|
-
export interface TNumber extends TSchema, NumericOptions<number> {
|
|
206
|
-
[Kind]: 'Number';
|
|
207
|
-
static: number;
|
|
208
|
-
type: 'number';
|
|
209
|
-
}
|
|
210
|
-
export type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
211
|
-
[K in keyof T]: T[K] extends TReadonlyOptional<TSchema> ? K : never;
|
|
212
|
-
}[keyof T];
|
|
213
|
-
export type ReadonlyPropertyKeys<T extends TProperties> = {
|
|
214
|
-
[K in keyof T]: T[K] extends TReadonly<TSchema> ? K : never;
|
|
215
|
-
}[keyof T];
|
|
216
|
-
export type OptionalPropertyKeys<T extends TProperties> = {
|
|
217
|
-
[K in keyof T]: T[K] extends TOptional<TSchema> ? K : never;
|
|
218
|
-
}[keyof T];
|
|
219
|
-
export type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
220
|
-
export type PropertiesReducer<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
|
|
221
|
-
export type PropertiesReduce<T extends TProperties, P extends unknown[]> = PropertiesReducer<T, {
|
|
222
|
-
[K in keyof T]: Static<T[K], P>;
|
|
223
|
-
}>;
|
|
224
|
-
export type TProperties = Record<keyof any, TSchema>;
|
|
225
|
-
export type ObjectProperties<T> = T extends TObject<infer U> ? U : never;
|
|
226
|
-
export type ObjectPropertyKeys<T> = T extends TObject<infer U> ? keyof U : never;
|
|
227
|
-
export type TAdditionalProperties = undefined | TSchema | boolean;
|
|
228
|
-
export interface ObjectOptions extends SchemaOptions {
|
|
229
|
-
additionalProperties?: TAdditionalProperties;
|
|
230
|
-
minProperties?: number;
|
|
231
|
-
maxProperties?: number;
|
|
232
|
-
}
|
|
233
|
-
export interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
234
|
-
[Kind]: 'Object';
|
|
235
|
-
static: PropertiesReduce<T, this['params']>;
|
|
236
|
-
additionalProperties?: TAdditionalProperties;
|
|
237
|
-
type: 'object';
|
|
238
|
-
properties: T;
|
|
239
|
-
required?: string[];
|
|
240
|
-
}
|
|
241
|
-
export type TOmitArray<T extends TSchema[], K extends keyof any> = Assert<{
|
|
242
|
-
[K2 in keyof T]: TOmit<Assert<T[K2], TSchema>, K>;
|
|
243
|
-
}, TSchema[]>;
|
|
244
|
-
export type TOmitProperties<T extends TProperties, K extends keyof any> = Evaluate<Assert<Omit<T, K>, TProperties>>;
|
|
245
|
-
export type TOmit<T extends TSchema, K extends keyof any
|
|
246
|
-
export type TParameters<T extends TFunction> = TTuple<T['parameters']>;
|
|
247
|
-
export type TPartialArray<T extends TSchema[]> = Assert<{
|
|
248
|
-
[K in keyof T]: TPartial<Assert<T[K], TSchema>>;
|
|
249
|
-
}, TSchema[]>;
|
|
250
|
-
export type TPartialProperties<T extends TProperties> = Evaluate<Assert<{
|
|
251
|
-
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonlyOptional<U> : T[K] extends TReadonly<infer U> ? TReadonlyOptional<U> : T[K] extends TOptional<infer U> ? TOptional<U> : TOptional<T[K]>;
|
|
252
|
-
}, TProperties>>;
|
|
253
|
-
export type TPartial<T extends TSchema
|
|
254
|
-
export type TPickArray<T extends TSchema[], K extends keyof any> = {
|
|
255
|
-
[K2 in keyof T]: TPick<Assert<T[K2], TSchema>, K>;
|
|
256
|
-
};
|
|
257
|
-
export type TPickProperties<T extends TProperties, K extends keyof any> = Pick<T, Assert<Extract<K, keyof T>, keyof T>> extends infer R ? ({
|
|
258
|
-
[K in keyof R]: Assert<R[K], TSchema> extends TSchema ? R[K] : never;
|
|
259
|
-
}) : never;
|
|
260
|
-
export type TPick<T extends TSchema, K extends keyof any
|
|
261
|
-
export type TPromiseStatic<T extends TSchema, P extends unknown[]> = Promise<Static<T, P>>;
|
|
262
|
-
export interface TPromise<T extends TSchema = TSchema> extends TSchema {
|
|
263
|
-
[Kind]: 'Promise';
|
|
264
|
-
static: TPromiseStatic<T, this['params']>;
|
|
265
|
-
type: 'object';
|
|
266
|
-
instanceOf: 'Promise';
|
|
267
|
-
item: TSchema;
|
|
268
|
-
}
|
|
269
|
-
export type TRecordKey = TString | TNumeric | TUnion<TLiteral<any>[]>;
|
|
270
|
-
export type TRecordPropertiesFromUnionLiteral<K extends TUnion<TLiteral<string | number>[]>, T extends TSchema> = Static<K> extends string ? {
|
|
271
|
-
[X in Static<K>]: T;
|
|
272
|
-
} : never;
|
|
273
|
-
export type TRecordPropertiesFromLiteral<K extends TLiteral<string | number>, T extends TSchema> = Evaluate<{
|
|
274
|
-
[K2 in K['const']]: T;
|
|
275
|
-
}>;
|
|
276
|
-
export type TRecordStatic<K extends TRecordKey, T extends TSchema, P extends unknown[]> = Record<Static<K>, Static<T, P>>;
|
|
277
|
-
export interface TRecord<K extends TRecordKey = TRecordKey, T extends TSchema = TSchema> extends TSchema {
|
|
278
|
-
[Kind]: 'Record';
|
|
279
|
-
static: TRecordStatic<K, T, this['params']>;
|
|
280
|
-
type: 'object';
|
|
281
|
-
patternProperties: {
|
|
282
|
-
[pattern: string]: T;
|
|
283
|
-
};
|
|
284
|
-
additionalProperties: false;
|
|
285
|
-
}
|
|
286
|
-
export interface TSelf extends TSchema {
|
|
287
|
-
[Kind]: 'Self';
|
|
288
|
-
static: this['params'][0];
|
|
289
|
-
$ref: string;
|
|
290
|
-
}
|
|
291
|
-
export type TRecursiveReduce<T extends TSchema> = Static<T, [TRecursiveReduce<T>]>;
|
|
292
|
-
export interface TRecursive<T extends TSchema> extends TSchema {
|
|
293
|
-
static: TRecursiveReduce<T>;
|
|
294
|
-
}
|
|
295
|
-
export type TRefStatic<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
296
|
-
export interface TRef<T extends TSchema = TSchema> extends TSchema {
|
|
297
|
-
[Kind]: 'Ref';
|
|
298
|
-
static: TRefStatic<T, this['params']>;
|
|
299
|
-
$ref: string;
|
|
300
|
-
}
|
|
301
|
-
export type TReturnType<T extends TFunction> = T['returns'];
|
|
302
|
-
export type TRequiredArray<T extends TSchema[]> = Assert<{
|
|
303
|
-
[K in keyof T]: TRequired<Assert<T[K], TSchema>>;
|
|
304
|
-
}, TSchema[]>;
|
|
305
|
-
export type TRequiredProperties<T extends TProperties> = Evaluate<Assert<{
|
|
306
|
-
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonly<U> : T[K] extends TReadonly<infer U> ? TReadonly<U> : T[K] extends TOptional<infer U> ? U : T[K];
|
|
307
|
-
}, TProperties>>;
|
|
308
|
-
export type TRequired<T extends TSchema
|
|
309
|
-
export type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex';
|
|
310
|
-
export interface StringOptions<Format extends string> extends SchemaOptions {
|
|
311
|
-
minLength?: number;
|
|
312
|
-
maxLength?: number;
|
|
313
|
-
pattern?: string;
|
|
314
|
-
format?: Format;
|
|
315
|
-
contentEncoding?: '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64';
|
|
316
|
-
contentMediaType?: string;
|
|
317
|
-
}
|
|
318
|
-
export interface TString<Format extends string = string> extends TSchema, StringOptions<Format> {
|
|
319
|
-
[Kind]: 'String';
|
|
320
|
-
static: string;
|
|
321
|
-
type: 'string';
|
|
322
|
-
}
|
|
323
|
-
export type SymbolValue = string | number | undefined;
|
|
324
|
-
export interface TSymbol extends TSchema, SchemaOptions {
|
|
325
|
-
[Kind]: 'Symbol';
|
|
326
|
-
static: symbol;
|
|
327
|
-
type: 'null';
|
|
328
|
-
typeOf: 'Symbol';
|
|
329
|
-
}
|
|
330
|
-
export type TTupleIntoArray<T extends TTuple<TSchema[]>> = T extends TTuple<infer R> ? Assert<R, TSchema[]> : never;
|
|
331
|
-
export type TTupleStatic<T extends TSchema[], P extends unknown[]> = {
|
|
332
|
-
[K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : T[K];
|
|
333
|
-
};
|
|
334
|
-
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
335
|
-
[Kind]: 'Tuple';
|
|
336
|
-
static: TTupleStatic<T, this['params']>;
|
|
337
|
-
type: 'array';
|
|
338
|
-
items?: T;
|
|
339
|
-
additionalItems?: false;
|
|
340
|
-
minItems: number;
|
|
341
|
-
maxItems: number;
|
|
342
|
-
}
|
|
343
|
-
export interface TUndefined extends TSchema {
|
|
344
|
-
[Kind]: 'Undefined';
|
|
345
|
-
static: undefined;
|
|
346
|
-
type: 'null';
|
|
347
|
-
typeOf: 'Undefined';
|
|
348
|
-
}
|
|
349
|
-
export type TUnionOfLiteralArray<T extends TLiteral<string>[]> = {
|
|
350
|
-
[K in keyof T]: Assert<T[K], TLiteral>['const'];
|
|
351
|
-
}[number];
|
|
352
|
-
export type TUnionOfLiteral<T extends TUnion<TLiteral<string>[]>> = TUnionOfLiteralArray<T['anyOf']>;
|
|
353
|
-
export
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
export
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
function
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
function
|
|
423
|
-
|
|
424
|
-
function
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
/** `[Utility]`
|
|
524
|
-
protected
|
|
525
|
-
/** `[Standard]` Omits compositing symbols from this schema */
|
|
526
|
-
Strict<T extends TSchema>(schema: T): T;
|
|
527
|
-
}
|
|
528
|
-
export declare class StandardTypeBuilder extends TypeBuilder {
|
|
529
|
-
/** `[Modifier]` Creates a Optional property */
|
|
530
|
-
Optional<T extends TSchema>(schema: T): TOptional<T>;
|
|
531
|
-
/** `[Modifier]` Creates a ReadonlyOptional property */
|
|
532
|
-
ReadonlyOptional<T extends TSchema>(schema: T): TReadonlyOptional<T>;
|
|
533
|
-
/** `[Modifier]` Creates a Readonly object or property */
|
|
534
|
-
Readonly<T extends TSchema>(schema: T): TReadonly<T>;
|
|
535
|
-
/** `[Standard]` Creates an Any type */
|
|
536
|
-
Any(options?: SchemaOptions): TAny;
|
|
537
|
-
/** `[Standard]` Creates an Array type */
|
|
538
|
-
Array<T extends TSchema>(items: T, options?: ArrayOptions): TArray<T>;
|
|
539
|
-
/** `[Standard]` Creates a Boolean type */
|
|
540
|
-
Boolean(options?: SchemaOptions): TBoolean;
|
|
541
|
-
/** `[Standard]` Creates a Composite object type that will Union any overlapping properties of the given Object array */
|
|
542
|
-
Composite<T extends TObject[]>(schemas: [...T], options?: ObjectOptions): TComposite<T>;
|
|
543
|
-
/** `[Standard]` Dereferences the given TRef to its target type */
|
|
544
|
-
Deref<T extends TRef>(schema: T): TDeref<T>;
|
|
545
|
-
/** `[Standard]` Creates a Enum type */
|
|
546
|
-
Enum<T extends Record<string, string | number>>(item: T, options?: SchemaOptions): TEnum<T>;
|
|
547
|
-
/** `[Standard]` A conditional type expression that will return the true type if the left type extends the right */
|
|
548
|
-
Extends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(left: L, right: R, trueType: T, falseType: U, options?: SchemaOptions): TExtends<L, R, T, U>;
|
|
549
|
-
/** `[Standard]` Excludes from the left type any type that is not assignable to the right */
|
|
550
|
-
Exclude<L extends TSchema, R extends TSchema>(left: L, right: R, options?: SchemaOptions): TExclude<L, R>;
|
|
551
|
-
/** `[Standard]` Extracts from left left any type that is assignable to the right */
|
|
552
|
-
Extract<L extends TSchema, R extends TSchema>(left: L, right: R, options?: SchemaOptions): TExtract<L, R>;
|
|
553
|
-
/** `[Standard]` Creates an Integer type */
|
|
554
|
-
Integer(options?: NumericOptions<number>): TInteger;
|
|
555
|
-
/** `[Standard]` Creates a Intersect type */
|
|
556
|
-
Intersect(allOf: [], options?: SchemaOptions): TNever;
|
|
557
|
-
/** `[Standard]` Creates a Intersect type */
|
|
558
|
-
Intersect<T extends [TSchema]>(allOf: [...T], options?: SchemaOptions): T[0];
|
|
559
|
-
Intersect<T extends TSchema[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>;
|
|
560
|
-
/** `[Standard]` Creates a KeyOf type */
|
|
561
|
-
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
562
|
-
/** `[Standard]` Creates a Literal type */
|
|
563
|
-
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
564
|
-
/** `[Standard]` Creates a Never type */
|
|
565
|
-
Never(options?: SchemaOptions): TNever;
|
|
566
|
-
/** `[Standard]` Creates a Not type. The first argument is the disallowed type, the second is the allowed. */
|
|
567
|
-
Not<N extends TSchema, T extends TSchema>(not: N, schema: T, options?: SchemaOptions): TNot<N, T>;
|
|
568
|
-
/** `[Standard]` Creates a Null type */
|
|
569
|
-
Null(options?: SchemaOptions): TNull;
|
|
570
|
-
/** `[Standard]` Creates a Number type */
|
|
571
|
-
Number(options?: NumericOptions<number>): TNumber;
|
|
572
|
-
/** `[Standard]` Creates an Object type */
|
|
573
|
-
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
574
|
-
/** `[Standard]` Creates a mapped type whose keys are omitted from the given type */
|
|
575
|
-
Omit<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TOmit<T, K[number]>;
|
|
576
|
-
/** `[Standard]` Creates a mapped type whose keys are omitted from the given type */
|
|
577
|
-
Omit<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TOmit<T, TUnionOfLiteral<K>>;
|
|
578
|
-
/** `[Standard]` Creates a mapped type where all properties are Optional */
|
|
579
|
-
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
580
|
-
/** `[Standard]` Creates a mapped type whose keys are picked from the given type */
|
|
581
|
-
Pick<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TPick<T, K[number]>;
|
|
582
|
-
/** `[Standard]` Creates a mapped type whose keys are picked from the given type */
|
|
583
|
-
Pick<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TPick<T, TUnionOfLiteral<K>>;
|
|
584
|
-
/** `[Standard]` Creates an Object type from the given Literal Union */
|
|
585
|
-
Record<K extends TUnion<TLiteral<string | number>[]>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordPropertiesFromUnionLiteral<K, T>>;
|
|
586
|
-
/** `[Standard]` Creates an Object type from the given Literal Union */
|
|
587
|
-
Record<K extends TLiteral<string | number>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordPropertiesFromLiteral<K, T>>;
|
|
588
|
-
/** `[Standard]` Creates a Record type */
|
|
589
|
-
Record<K extends TString | TNumeric, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecord<K, T>;
|
|
590
|
-
/** `[Standard]` Creates a Recursive type */
|
|
591
|
-
Recursive<T extends TSchema>(callback: (self: TSelf) => T, options?: SchemaOptions): TRecursive<T>;
|
|
592
|
-
/** `[Standard]` Creates a Ref type. The referenced type must contain a $id */
|
|
593
|
-
Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>;
|
|
594
|
-
/** `[Standard]` Creates a mapped type where all properties are Required */
|
|
595
|
-
Required<T extends TSchema>(schema: T, options?: SchemaOptions): TRequired<T>;
|
|
596
|
-
/** `[Standard]` Creates a String type */
|
|
597
|
-
String<Format extends string>(options?: StringOptions<StringFormatOption | Format>): TString<Format>;
|
|
598
|
-
/** `[Standard]` Creates a Tuple type */
|
|
599
|
-
Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
600
|
-
/** `[Standard]` Creates a Union type */
|
|
601
|
-
Union(anyOf: [], options?: SchemaOptions): TNever;
|
|
602
|
-
/** `[Standard]` Creates a Union type */
|
|
603
|
-
Union<T extends [TSchema]>(anyOf: [...T], options?: SchemaOptions): T[0];
|
|
604
|
-
/** `[Standard]` Creates a Union type */
|
|
605
|
-
Union<T extends TSchema[]>(anyOf: [...T], options?: SchemaOptions): TUnion<T>;
|
|
606
|
-
/** `[Standard]` Creates an Unknown type */
|
|
607
|
-
Unknown(options?: SchemaOptions): TUnknown;
|
|
608
|
-
/** `[Standard]` Creates a Unsafe type that infers for the generic argument */
|
|
609
|
-
Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
|
|
610
|
-
}
|
|
611
|
-
export declare class ExtendedTypeBuilder extends StandardTypeBuilder {
|
|
612
|
-
/** `[Extended]` Creates a BigInt type */
|
|
613
|
-
BigInt(options?: NumericOptions<bigint>): TBigInt;
|
|
614
|
-
/** `[Extended]` Extracts the ConstructorParameters from the given Constructor type */
|
|
615
|
-
ConstructorParameters<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
|
|
616
|
-
/** `[Extended]` Creates a Constructor type */
|
|
617
|
-
Constructor<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TConstructor<TTupleIntoArray<T>, U>;
|
|
618
|
-
/** `[Extended]` Creates a Constructor type */
|
|
619
|
-
Constructor<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TConstructor<T, U>;
|
|
620
|
-
/** `[Extended]` Creates a Date type */
|
|
621
|
-
Date(options?: DateOptions): TDate;
|
|
622
|
-
/** `[Extended]` Creates a Function type */
|
|
623
|
-
Function<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TFunction<TTupleIntoArray<T>, U>;
|
|
624
|
-
/** `[Extended]` Creates a Function type */
|
|
625
|
-
Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
|
|
626
|
-
/** `[Extended]` Extracts the InstanceType from the given Constructor */
|
|
627
|
-
InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
|
|
628
|
-
/** `[Extended]` Extracts the Parameters from the given Function type */
|
|
629
|
-
Parameters<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TParameters<T>;
|
|
630
|
-
/** `[Extended]` Creates a Promise type */
|
|
631
|
-
Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
|
|
632
|
-
/** `[Extended]` Creates a regular expression type */
|
|
633
|
-
RegEx(regex: RegExp, options?: SchemaOptions): TString;
|
|
634
|
-
/** `[Extended]` Extracts the ReturnType from the given Function */
|
|
635
|
-
ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
|
|
636
|
-
/** `[Extended]` Creates a Symbol type */
|
|
637
|
-
Symbol(options?: SchemaOptions): TSymbol;
|
|
638
|
-
/** `[Extended]` Creates a Undefined type */
|
|
639
|
-
Undefined(options?: SchemaOptions): TUndefined;
|
|
640
|
-
/** `[Extended]` Creates a Uint8Array type */
|
|
641
|
-
Uint8Array(options?: Uint8ArrayOptions): TUint8Array;
|
|
642
|
-
/** `[Extended]` Creates a Void type */
|
|
643
|
-
Void(options?: SchemaOptions): TVoid;
|
|
644
|
-
}
|
|
645
|
-
/** JSON Schema TypeBuilder with Static Resolution for TypeScript */
|
|
646
|
-
export declare const StandardType: StandardTypeBuilder;
|
|
647
|
-
/** JSON Schema TypeBuilder with Static Resolution for TypeScript */
|
|
648
|
-
export declare const Type: ExtendedTypeBuilder;
|
|
1
|
+
export declare const Recursive: unique symbol;
|
|
2
|
+
export declare const Modifier: unique symbol;
|
|
3
|
+
export declare const Hint: unique symbol;
|
|
4
|
+
export declare const Kind: unique symbol;
|
|
5
|
+
export type TupleToIntersect<T extends any[]> = T extends [infer I] ? I : T extends [infer I, ...infer R] ? I & TupleToIntersect<R> : never;
|
|
6
|
+
export type TupleToUnion<T extends any[]> = {
|
|
7
|
+
[K in keyof T]: T[K];
|
|
8
|
+
}[number];
|
|
9
|
+
export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
|
|
10
|
+
export type UnionLast<U> = UnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
|
|
11
|
+
export type UnionToTuple<U, L = UnionLast<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, L>>, L];
|
|
12
|
+
export type Assert<T, E> = T extends E ? T : never;
|
|
13
|
+
export type Evaluate<T> = T extends infer O ? {
|
|
14
|
+
[K in keyof O]: O[K];
|
|
15
|
+
} : never;
|
|
16
|
+
export type Ensure<T> = T extends infer U ? U : never;
|
|
17
|
+
export type TModifier = TReadonlyOptional<TSchema> | TOptional<TSchema> | TReadonly<TSchema>;
|
|
18
|
+
export type TReadonly<T extends TSchema> = T & {
|
|
19
|
+
[Modifier]: 'Readonly';
|
|
20
|
+
};
|
|
21
|
+
export type TOptional<T extends TSchema> = T & {
|
|
22
|
+
[Modifier]: 'Optional';
|
|
23
|
+
};
|
|
24
|
+
export type TReadonlyOptional<T extends TSchema> = T & {
|
|
25
|
+
[Modifier]: 'ReadonlyOptional';
|
|
26
|
+
};
|
|
27
|
+
export interface SchemaOptions {
|
|
28
|
+
$schema?: string;
|
|
29
|
+
/** Id for this schema */
|
|
30
|
+
readonly $id?: string;
|
|
31
|
+
/** Title of this schema */
|
|
32
|
+
title?: string;
|
|
33
|
+
/** Description of this schema */
|
|
34
|
+
description?: string;
|
|
35
|
+
/** Default value for this schema */
|
|
36
|
+
default?: any;
|
|
37
|
+
/** Example values matching this schema */
|
|
38
|
+
examples?: any;
|
|
39
|
+
[prop: string]: any;
|
|
40
|
+
}
|
|
41
|
+
export interface TKind {
|
|
42
|
+
[Kind]: string;
|
|
43
|
+
}
|
|
44
|
+
export interface TSchema extends SchemaOptions, TKind {
|
|
45
|
+
[Modifier]?: string;
|
|
46
|
+
[Recursive]?: string;
|
|
47
|
+
[Hint]?: string;
|
|
48
|
+
params: unknown[];
|
|
49
|
+
static: unknown;
|
|
50
|
+
}
|
|
51
|
+
export type TAnySchema = TSchema | TAny | TArray | TBigInt | TBoolean | TConstructor | TDate | TEnum | TFunction | TInteger | TIntersect | TLiteral | TNot | TNull | TNumber | TObject | TPromise | TRecord | TRef | TSelf | TString | TSymbol | TTuple | TUndefined | TUnion | TUint8Array | TUnknown | TVoid;
|
|
52
|
+
export type TNumeric = TInteger | TNumber;
|
|
53
|
+
export interface NumericOptions<N extends number | bigint> extends SchemaOptions {
|
|
54
|
+
exclusiveMaximum?: N;
|
|
55
|
+
exclusiveMinimum?: N;
|
|
56
|
+
maximum?: N;
|
|
57
|
+
minimum?: N;
|
|
58
|
+
multipleOf?: N;
|
|
59
|
+
}
|
|
60
|
+
export interface TAny extends TSchema {
|
|
61
|
+
[Kind]: 'Any';
|
|
62
|
+
static: any;
|
|
63
|
+
}
|
|
64
|
+
export interface ArrayOptions extends SchemaOptions {
|
|
65
|
+
uniqueItems?: boolean;
|
|
66
|
+
minItems?: number;
|
|
67
|
+
maxItems?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
70
|
+
[Kind]: 'Array';
|
|
71
|
+
static: Static<T, this['params']>[];
|
|
72
|
+
type: 'array';
|
|
73
|
+
items: T;
|
|
74
|
+
}
|
|
75
|
+
export interface TBigInt extends TSchema, NumericOptions<bigint> {
|
|
76
|
+
[Kind]: 'BigInt';
|
|
77
|
+
static: bigint;
|
|
78
|
+
type: 'null';
|
|
79
|
+
typeOf: 'BigInt';
|
|
80
|
+
}
|
|
81
|
+
export interface TBoolean extends TSchema {
|
|
82
|
+
[Kind]: 'Boolean';
|
|
83
|
+
static: boolean;
|
|
84
|
+
type: 'boolean';
|
|
85
|
+
}
|
|
86
|
+
export type TConstructorParameters<T extends TConstructor<TSchema[], TSchema>> = TTuple<T['parameters']>;
|
|
87
|
+
export type TDeref<T> = T extends TRef<infer U> ? TDeref<U> : T;
|
|
88
|
+
export type TInstanceType<T extends TConstructor<TSchema[], TSchema>> = T['returns'];
|
|
89
|
+
export type TCompositeUnion<Left extends TSchema, Right extends TSchema> = Ensure<TUnion<[Left, Right]>>;
|
|
90
|
+
export type TCompositeMerge<T extends TObject, Output extends Record<any, TSchema>> = Evaluate<{
|
|
91
|
+
[Key in keyof T['properties']]: Key extends keyof Output ? TCompositeUnion<T['properties'][Key], Output[Key]> : T['properties'][Key];
|
|
92
|
+
} & {
|
|
93
|
+
[Key in keyof Output]: Key extends keyof T['properties'] ? TCompositeUnion<T['properties'][Key], Output[Key]> : Output[Key];
|
|
94
|
+
}>;
|
|
95
|
+
export type TCompositeReduce<T extends TObject[], Output extends {}> = T extends [infer L, ...infer R] ? TCompositeReduce<[...Assert<R, TObject[]>], TCompositeMerge<Assert<L, TObject>, Output>> : T extends [] ? Output : never;
|
|
96
|
+
export type TComposite<T extends TObject[]> = Ensure<TObject<TCompositeReduce<T, {}>>>;
|
|
97
|
+
export type TConstructorParameterArray<T extends readonly TSchema[], P extends unknown[]> = [...{
|
|
98
|
+
[K in keyof T]: Static<Assert<T[K], TSchema>, P>;
|
|
99
|
+
}];
|
|
100
|
+
export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
101
|
+
[Kind]: 'Constructor';
|
|
102
|
+
static: new (...param: TConstructorParameterArray<T, this['params']>) => Static<U, this['params']>;
|
|
103
|
+
type: 'object';
|
|
104
|
+
instanceOf: 'Constructor';
|
|
105
|
+
parameters: T;
|
|
106
|
+
returns: U;
|
|
107
|
+
}
|
|
108
|
+
export interface DateOptions extends SchemaOptions {
|
|
109
|
+
exclusiveMaximumTimestamp?: number;
|
|
110
|
+
exclusiveMinimumTimestamp?: number;
|
|
111
|
+
maximumTimestamp?: number;
|
|
112
|
+
minimumTimestamp?: number;
|
|
113
|
+
}
|
|
114
|
+
export interface TDate extends TSchema, DateOptions {
|
|
115
|
+
[Kind]: 'Date';
|
|
116
|
+
static: Date;
|
|
117
|
+
type: 'object';
|
|
118
|
+
instanceOf: 'Date';
|
|
119
|
+
}
|
|
120
|
+
export interface TEnumOption<T> {
|
|
121
|
+
type: 'number' | 'string';
|
|
122
|
+
const: T;
|
|
123
|
+
}
|
|
124
|
+
export type TEnumStatic<T extends Record<string, string | number>> = T[keyof T];
|
|
125
|
+
export interface TEnum<T extends Record<string, string | number> = Record<string, string | number>> extends TSchema {
|
|
126
|
+
[Kind]: 'Union';
|
|
127
|
+
static: TEnumStatic<T>;
|
|
128
|
+
anyOf: TLiteral<string | number>[];
|
|
129
|
+
}
|
|
130
|
+
export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = (Static<L> extends Static<R> ? T : U) extends infer O ? UnionToTuple<O> extends [infer X, infer Y] ? TUnion<[Assert<X, TSchema>, Assert<Y, TSchema>]> : Assert<O, TSchema> : never;
|
|
131
|
+
export type TExcludeArray<T extends TSchema[], U extends TSchema> = Assert<UnionToTuple<{
|
|
132
|
+
[K in keyof T]: Static<Assert<T[K], TSchema>> extends Static<U> ? never : T[K];
|
|
133
|
+
}[number]>, TSchema[]> extends infer R ? TUnionResult<Assert<R, TSchema[]>> : never;
|
|
134
|
+
export type TExclude<T extends TSchema, U extends TSchema> = T extends TUnion<infer S> ? TExcludeArray<S, U> : T extends U ? TNever : T;
|
|
135
|
+
export type TExtractArray<T extends TSchema[], U extends TSchema> = Assert<UnionToTuple<{
|
|
136
|
+
[K in keyof T]: Static<Assert<T[K], TSchema>> extends Static<U> ? T[K] : never;
|
|
137
|
+
}[number]>, TSchema[]> extends infer R ? TUnionResult<Assert<R, TSchema[]>> : never;
|
|
138
|
+
export type TExtract<T extends TSchema, U extends TSchema> = T extends TUnion<infer S> ? TExtractArray<S, U> : T extends U ? T : TNever;
|
|
139
|
+
export type TFunctionParameters<T extends readonly TSchema[], P extends unknown[]> = [...{
|
|
140
|
+
[K in keyof T]: Static<Assert<T[K], TSchema>, P>;
|
|
141
|
+
}];
|
|
142
|
+
export interface TFunction<T extends readonly TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
143
|
+
[Kind]: 'Function';
|
|
144
|
+
static: (...param: TFunctionParameters<T, this['params']>) => Static<U, this['params']>;
|
|
145
|
+
type: 'object';
|
|
146
|
+
instanceOf: 'Function';
|
|
147
|
+
parameters: T;
|
|
148
|
+
returns: U;
|
|
149
|
+
}
|
|
150
|
+
export interface TInteger extends TSchema, NumericOptions<number> {
|
|
151
|
+
[Kind]: 'Integer';
|
|
152
|
+
static: number;
|
|
153
|
+
type: 'integer';
|
|
154
|
+
}
|
|
155
|
+
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
156
|
+
export interface IntersectOptions extends SchemaOptions {
|
|
157
|
+
unevaluatedProperties?: TUnevaluatedProperties;
|
|
158
|
+
}
|
|
159
|
+
export type TIntersectStatic<T extends TSchema[], P extends unknown[]> = TupleToIntersect<{
|
|
160
|
+
[K in keyof T]: Static<Assert<T[K], TSchema>, P>;
|
|
161
|
+
}>;
|
|
162
|
+
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
163
|
+
[Kind]: 'Intersect';
|
|
164
|
+
type?: 'object';
|
|
165
|
+
static: TIntersectStatic<T, this['params']>;
|
|
166
|
+
allOf: [...T];
|
|
167
|
+
}
|
|
168
|
+
export type TKeyOfTuple<T extends TSchema> = {
|
|
169
|
+
[K in keyof Static<T>]: TLiteral<Assert<K, TLiteralValue>>;
|
|
170
|
+
} extends infer U ? UnionToTuple<Exclude<{
|
|
171
|
+
[K in keyof U]: U[K];
|
|
172
|
+
}[keyof U], undefined>> : never;
|
|
173
|
+
export type TKeyOf<T extends TSchema = TSchema, D = TDeref<T>> = (D extends TIntersect ? TKeyOfTuple<T> : D extends TUnion ? TKeyOfTuple<T> : D extends TObject ? TKeyOfTuple<T> : [
|
|
174
|
+
]) extends infer R ? TUnionResult<Assert<R, TSchema[]>> : never;
|
|
175
|
+
export type TLiteralValue = string | number | boolean | bigint;
|
|
176
|
+
export interface TLiteral<T extends TLiteralValue = TLiteralValue> extends TSchema {
|
|
177
|
+
[Kind]: 'Literal';
|
|
178
|
+
static: T;
|
|
179
|
+
const: T;
|
|
180
|
+
}
|
|
181
|
+
export interface TNever extends TSchema {
|
|
182
|
+
[Kind]: 'Never';
|
|
183
|
+
static: never;
|
|
184
|
+
allOf: [{
|
|
185
|
+
type: 'boolean';
|
|
186
|
+
const: false;
|
|
187
|
+
}, {
|
|
188
|
+
type: 'boolean';
|
|
189
|
+
const: true;
|
|
190
|
+
}];
|
|
191
|
+
}
|
|
192
|
+
export type TNotStatic<_ extends TSchema = TSchema, T extends TSchema = TSchema> = Static<T>;
|
|
193
|
+
export interface TNot<Not extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
|
|
194
|
+
[Kind]: 'Not';
|
|
195
|
+
static: TNotStatic<Not, T>;
|
|
196
|
+
allOf: [{
|
|
197
|
+
not: Not;
|
|
198
|
+
}, T];
|
|
199
|
+
}
|
|
200
|
+
export interface TNull extends TSchema {
|
|
201
|
+
[Kind]: 'Null';
|
|
202
|
+
static: null;
|
|
203
|
+
type: 'null';
|
|
204
|
+
}
|
|
205
|
+
export interface TNumber extends TSchema, NumericOptions<number> {
|
|
206
|
+
[Kind]: 'Number';
|
|
207
|
+
static: number;
|
|
208
|
+
type: 'number';
|
|
209
|
+
}
|
|
210
|
+
export type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
211
|
+
[K in keyof T]: T[K] extends TReadonlyOptional<TSchema> ? K : never;
|
|
212
|
+
}[keyof T];
|
|
213
|
+
export type ReadonlyPropertyKeys<T extends TProperties> = {
|
|
214
|
+
[K in keyof T]: T[K] extends TReadonly<TSchema> ? K : never;
|
|
215
|
+
}[keyof T];
|
|
216
|
+
export type OptionalPropertyKeys<T extends TProperties> = {
|
|
217
|
+
[K in keyof T]: T[K] extends TOptional<TSchema> ? K : never;
|
|
218
|
+
}[keyof T];
|
|
219
|
+
export type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
220
|
+
export type PropertiesReducer<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
|
|
221
|
+
export type PropertiesReduce<T extends TProperties, P extends unknown[]> = PropertiesReducer<T, {
|
|
222
|
+
[K in keyof T]: Static<T[K], P>;
|
|
223
|
+
}>;
|
|
224
|
+
export type TProperties = Record<keyof any, TSchema>;
|
|
225
|
+
export type ObjectProperties<T> = T extends TObject<infer U> ? U : never;
|
|
226
|
+
export type ObjectPropertyKeys<T> = T extends TObject<infer U> ? keyof U : never;
|
|
227
|
+
export type TAdditionalProperties = undefined | TSchema | boolean;
|
|
228
|
+
export interface ObjectOptions extends SchemaOptions {
|
|
229
|
+
additionalProperties?: TAdditionalProperties;
|
|
230
|
+
minProperties?: number;
|
|
231
|
+
maxProperties?: number;
|
|
232
|
+
}
|
|
233
|
+
export interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
234
|
+
[Kind]: 'Object';
|
|
235
|
+
static: PropertiesReduce<T, this['params']>;
|
|
236
|
+
additionalProperties?: TAdditionalProperties;
|
|
237
|
+
type: 'object';
|
|
238
|
+
properties: T;
|
|
239
|
+
required?: string[];
|
|
240
|
+
}
|
|
241
|
+
export type TOmitArray<T extends TSchema[], K extends keyof any> = Assert<{
|
|
242
|
+
[K2 in keyof T]: TOmit<Assert<T[K2], TSchema>, K>;
|
|
243
|
+
}, TSchema[]>;
|
|
244
|
+
export type TOmitProperties<T extends TProperties, K extends keyof any> = Evaluate<Assert<Omit<T, K>, TProperties>>;
|
|
245
|
+
export type TOmit<T extends TSchema, K extends keyof any, D = TDeref<T>> = D extends TIntersect<infer S> ? TIntersect<TOmitArray<S, K>> : D extends TUnion<infer S> ? TUnion<TOmitArray<S, K>> : D extends TObject<infer S> ? TObject<TOmitProperties<S, K>> : D;
|
|
246
|
+
export type TParameters<T extends TFunction> = TTuple<T['parameters']>;
|
|
247
|
+
export type TPartialArray<T extends TSchema[]> = Assert<{
|
|
248
|
+
[K in keyof T]: TPartial<Assert<T[K], TSchema>>;
|
|
249
|
+
}, TSchema[]>;
|
|
250
|
+
export type TPartialProperties<T extends TProperties> = Evaluate<Assert<{
|
|
251
|
+
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonlyOptional<U> : T[K] extends TReadonly<infer U> ? TReadonlyOptional<U> : T[K] extends TOptional<infer U> ? TOptional<U> : TOptional<T[K]>;
|
|
252
|
+
}, TProperties>>;
|
|
253
|
+
export type TPartial<T extends TSchema, D = TDeref<T>> = D extends TIntersect<infer S> ? TIntersect<TPartialArray<S>> : D extends TUnion<infer S> ? TUnion<TPartialArray<S>> : D extends TObject<infer S> ? TObject<TPartialProperties<S>> : D;
|
|
254
|
+
export type TPickArray<T extends TSchema[], K extends keyof any> = {
|
|
255
|
+
[K2 in keyof T]: TPick<Assert<T[K2], TSchema>, K>;
|
|
256
|
+
};
|
|
257
|
+
export type TPickProperties<T extends TProperties, K extends keyof any> = Pick<T, Assert<Extract<K, keyof T>, keyof T>> extends infer R ? ({
|
|
258
|
+
[K in keyof R]: Assert<R[K], TSchema> extends TSchema ? R[K] : never;
|
|
259
|
+
}) : never;
|
|
260
|
+
export type TPick<T extends TSchema, K extends keyof any, D = TDeref<T>> = D extends TIntersect<infer S> ? TIntersect<TPickArray<S, K>> : D extends TUnion<infer S> ? TUnion<TPickArray<S, K>> : D extends TObject<infer S> ? TObject<TPickProperties<S, K>> : D;
|
|
261
|
+
export type TPromiseStatic<T extends TSchema, P extends unknown[]> = Promise<Static<T, P>>;
|
|
262
|
+
export interface TPromise<T extends TSchema = TSchema> extends TSchema {
|
|
263
|
+
[Kind]: 'Promise';
|
|
264
|
+
static: TPromiseStatic<T, this['params']>;
|
|
265
|
+
type: 'object';
|
|
266
|
+
instanceOf: 'Promise';
|
|
267
|
+
item: TSchema;
|
|
268
|
+
}
|
|
269
|
+
export type TRecordKey = TString | TNumeric | TUnion<TLiteral<any>[]>;
|
|
270
|
+
export type TRecordPropertiesFromUnionLiteral<K extends TUnion<TLiteral<string | number>[]>, T extends TSchema> = Static<K> extends string ? {
|
|
271
|
+
[X in Static<K>]: T;
|
|
272
|
+
} : never;
|
|
273
|
+
export type TRecordPropertiesFromLiteral<K extends TLiteral<string | number>, T extends TSchema> = Evaluate<{
|
|
274
|
+
[K2 in K['const']]: T;
|
|
275
|
+
}>;
|
|
276
|
+
export type TRecordStatic<K extends TRecordKey, T extends TSchema, P extends unknown[]> = Record<Static<K>, Static<T, P>>;
|
|
277
|
+
export interface TRecord<K extends TRecordKey = TRecordKey, T extends TSchema = TSchema> extends TSchema {
|
|
278
|
+
[Kind]: 'Record';
|
|
279
|
+
static: TRecordStatic<K, T, this['params']>;
|
|
280
|
+
type: 'object';
|
|
281
|
+
patternProperties: {
|
|
282
|
+
[pattern: string]: T;
|
|
283
|
+
};
|
|
284
|
+
additionalProperties: false;
|
|
285
|
+
}
|
|
286
|
+
export interface TSelf extends TSchema {
|
|
287
|
+
[Kind]: 'Self';
|
|
288
|
+
static: this['params'][0];
|
|
289
|
+
$ref: string;
|
|
290
|
+
}
|
|
291
|
+
export type TRecursiveReduce<T extends TSchema> = Static<T, [TRecursiveReduce<T>]>;
|
|
292
|
+
export interface TRecursive<T extends TSchema> extends TSchema {
|
|
293
|
+
static: TRecursiveReduce<T>;
|
|
294
|
+
}
|
|
295
|
+
export type TRefStatic<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
296
|
+
export interface TRef<T extends TSchema = TSchema> extends TSchema {
|
|
297
|
+
[Kind]: 'Ref';
|
|
298
|
+
static: TRefStatic<T, this['params']>;
|
|
299
|
+
$ref: string;
|
|
300
|
+
}
|
|
301
|
+
export type TReturnType<T extends TFunction> = T['returns'];
|
|
302
|
+
export type TRequiredArray<T extends TSchema[]> = Assert<{
|
|
303
|
+
[K in keyof T]: TRequired<Assert<T[K], TSchema>>;
|
|
304
|
+
}, TSchema[]>;
|
|
305
|
+
export type TRequiredProperties<T extends TProperties> = Evaluate<Assert<{
|
|
306
|
+
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonly<U> : T[K] extends TReadonly<infer U> ? TReadonly<U> : T[K] extends TOptional<infer U> ? U : T[K];
|
|
307
|
+
}, TProperties>>;
|
|
308
|
+
export type TRequired<T extends TSchema, D = TDeref<T>> = D extends TIntersect<infer S> ? TIntersect<TRequiredArray<S>> : D extends TUnion<infer S> ? TUnion<TRequiredArray<S>> : D extends TObject<infer S> ? TObject<TRequiredProperties<S>> : D;
|
|
309
|
+
export type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex';
|
|
310
|
+
export interface StringOptions<Format extends string> extends SchemaOptions {
|
|
311
|
+
minLength?: number;
|
|
312
|
+
maxLength?: number;
|
|
313
|
+
pattern?: string;
|
|
314
|
+
format?: Format;
|
|
315
|
+
contentEncoding?: '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64';
|
|
316
|
+
contentMediaType?: string;
|
|
317
|
+
}
|
|
318
|
+
export interface TString<Format extends string = string> extends TSchema, StringOptions<Format> {
|
|
319
|
+
[Kind]: 'String';
|
|
320
|
+
static: string;
|
|
321
|
+
type: 'string';
|
|
322
|
+
}
|
|
323
|
+
export type SymbolValue = string | number | undefined;
|
|
324
|
+
export interface TSymbol extends TSchema, SchemaOptions {
|
|
325
|
+
[Kind]: 'Symbol';
|
|
326
|
+
static: symbol;
|
|
327
|
+
type: 'null';
|
|
328
|
+
typeOf: 'Symbol';
|
|
329
|
+
}
|
|
330
|
+
export type TTupleIntoArray<T extends TTuple<TSchema[]>> = T extends TTuple<infer R> ? Assert<R, TSchema[]> : never;
|
|
331
|
+
export type TTupleStatic<T extends TSchema[], P extends unknown[]> = {
|
|
332
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : T[K];
|
|
333
|
+
};
|
|
334
|
+
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
335
|
+
[Kind]: 'Tuple';
|
|
336
|
+
static: TTupleStatic<T, this['params']>;
|
|
337
|
+
type: 'array';
|
|
338
|
+
items?: T;
|
|
339
|
+
additionalItems?: false;
|
|
340
|
+
minItems: number;
|
|
341
|
+
maxItems: number;
|
|
342
|
+
}
|
|
343
|
+
export interface TUndefined extends TSchema {
|
|
344
|
+
[Kind]: 'Undefined';
|
|
345
|
+
static: undefined;
|
|
346
|
+
type: 'null';
|
|
347
|
+
typeOf: 'Undefined';
|
|
348
|
+
}
|
|
349
|
+
export type TUnionOfLiteralArray<T extends TLiteral<string>[]> = {
|
|
350
|
+
[K in keyof T]: Assert<T[K], TLiteral>['const'];
|
|
351
|
+
}[number];
|
|
352
|
+
export type TUnionOfLiteral<T extends TUnion<TLiteral<string>[]>> = TUnionOfLiteralArray<T['anyOf']>;
|
|
353
|
+
export type TUnionResult<T extends TSchema[]> = T extends [] ? TNever : T extends [infer S] ? S : TUnion<T>;
|
|
354
|
+
export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
355
|
+
[Kind]: 'Union';
|
|
356
|
+
static: {
|
|
357
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K], this['params']> : never;
|
|
358
|
+
}[number];
|
|
359
|
+
anyOf: T;
|
|
360
|
+
}
|
|
361
|
+
export interface Uint8ArrayOptions extends SchemaOptions {
|
|
362
|
+
maxByteLength?: number;
|
|
363
|
+
minByteLength?: number;
|
|
364
|
+
}
|
|
365
|
+
export interface TUint8Array extends TSchema, Uint8ArrayOptions {
|
|
366
|
+
[Kind]: 'Uint8Array';
|
|
367
|
+
static: Uint8Array;
|
|
368
|
+
instanceOf: 'Uint8Array';
|
|
369
|
+
type: 'object';
|
|
370
|
+
}
|
|
371
|
+
export interface TUnknown extends TSchema {
|
|
372
|
+
[Kind]: 'Unknown';
|
|
373
|
+
static: unknown;
|
|
374
|
+
}
|
|
375
|
+
export interface UnsafeOptions extends SchemaOptions {
|
|
376
|
+
[Kind]?: string;
|
|
377
|
+
}
|
|
378
|
+
export interface TUnsafe<T> extends TSchema {
|
|
379
|
+
[Kind]: string;
|
|
380
|
+
static: T;
|
|
381
|
+
}
|
|
382
|
+
export interface TVoid extends TSchema {
|
|
383
|
+
[Kind]: 'Void';
|
|
384
|
+
static: void;
|
|
385
|
+
type: 'null';
|
|
386
|
+
typeOf: 'Void';
|
|
387
|
+
}
|
|
388
|
+
/** Creates a static type from a TypeBox type */
|
|
389
|
+
export type Static<T extends TSchema, P extends unknown[] = []> = (T & {
|
|
390
|
+
params: P;
|
|
391
|
+
})['static'];
|
|
392
|
+
export type TypeRegistryValidationFunction<TSchema> = (schema: TSchema, value: unknown) => boolean;
|
|
393
|
+
export declare namespace TypeRegistry {
|
|
394
|
+
/** Clears all user defined types */
|
|
395
|
+
function Clear(): void;
|
|
396
|
+
/** Returns true if this registry contains this kind */
|
|
397
|
+
function Has(kind: string): boolean;
|
|
398
|
+
/** Sets a validation function for a user defined type */
|
|
399
|
+
function Set<TSchema = unknown>(kind: string, func: TypeRegistryValidationFunction<TSchema>): void;
|
|
400
|
+
/** Gets a custom validation function for a user defined type */
|
|
401
|
+
function Get(kind: string): TypeRegistryValidationFunction<any> | undefined;
|
|
402
|
+
}
|
|
403
|
+
export declare namespace ReferenceRegistry {
|
|
404
|
+
/** Clears the reference registry */
|
|
405
|
+
function Clear(): void;
|
|
406
|
+
/** Returns true if this registry contains this schema */
|
|
407
|
+
function Has(schema: TSchema): boolean;
|
|
408
|
+
/** Sets this schema on this registry if a $id exists */
|
|
409
|
+
function Set(schema: TSchema): void;
|
|
410
|
+
/** Dereferences the schema one level deep */
|
|
411
|
+
function DerefOne(schema: TSchema): TSchema;
|
|
412
|
+
/** Dereferences the schema recursively */
|
|
413
|
+
function Deref(schema: TSchema): TSchema;
|
|
414
|
+
}
|
|
415
|
+
export type FormatRegistryValidationFunction = (value: string) => boolean;
|
|
416
|
+
/** Provides functions to create user defined string formats */
|
|
417
|
+
export declare namespace FormatRegistry {
|
|
418
|
+
/** Clears all user defined string formats */
|
|
419
|
+
function Clear(): void;
|
|
420
|
+
/** Returns true if the user defined string format exists */
|
|
421
|
+
function Has(format: string): boolean;
|
|
422
|
+
/** Sets a validation function for a user defined string format */
|
|
423
|
+
function Set(format: string, func: FormatRegistryValidationFunction): void;
|
|
424
|
+
/** Gets a validation function for a user defined string format */
|
|
425
|
+
function Get(format: string): FormatRegistryValidationFunction | undefined;
|
|
426
|
+
}
|
|
427
|
+
export declare class TypeGuardUnknownTypeError extends Error {
|
|
428
|
+
readonly schema: unknown;
|
|
429
|
+
constructor(schema: unknown);
|
|
430
|
+
}
|
|
431
|
+
export declare namespace TypeGuard {
|
|
432
|
+
/** Returns true if the given schema is TAny */
|
|
433
|
+
function TAny(schema: unknown): schema is TAny;
|
|
434
|
+
/** Returns true if the given schema is TArray */
|
|
435
|
+
function TArray(schema: unknown): schema is TArray;
|
|
436
|
+
/** Returns true if the given schema is TSymbol */
|
|
437
|
+
function TBigInt(schema: unknown): schema is TBigInt;
|
|
438
|
+
/** Returns true if the given schema is TBoolean */
|
|
439
|
+
function TBoolean(schema: unknown): schema is TBoolean;
|
|
440
|
+
/** Returns true if the given schema is TConstructor */
|
|
441
|
+
function TConstructor(schema: unknown): schema is TConstructor;
|
|
442
|
+
/** Returns true if the given schema is TDate */
|
|
443
|
+
function TDate(schema: unknown): schema is TDate;
|
|
444
|
+
/** Returns true if the given schema is TFunction */
|
|
445
|
+
function TFunction(schema: unknown): schema is TFunction;
|
|
446
|
+
/** Returns true if the given schema is TInteger */
|
|
447
|
+
function TInteger(schema: unknown): schema is TInteger;
|
|
448
|
+
/** Returns true if the given schema is TIntersect */
|
|
449
|
+
function TIntersect(schema: unknown): schema is TIntersect;
|
|
450
|
+
/** Returns true if the given schema is TKind */
|
|
451
|
+
function TKind(schema: unknown): schema is Record<typeof Kind | string, unknown>;
|
|
452
|
+
/** Returns true if the given schema is TLiteral */
|
|
453
|
+
function TLiteral(schema: unknown): schema is TLiteral;
|
|
454
|
+
/** Returns true if the given schema is TNever */
|
|
455
|
+
function TNever(schema: unknown): schema is TNever;
|
|
456
|
+
/** Returns true if the given schema is TNot */
|
|
457
|
+
function TNot(schema: unknown): schema is TNot;
|
|
458
|
+
/** Returns true if the given schema is TNull */
|
|
459
|
+
function TNull(schema: unknown): schema is TNull;
|
|
460
|
+
/** Returns true if the given schema is TNumber */
|
|
461
|
+
function TNumber(schema: unknown): schema is TNumber;
|
|
462
|
+
/** Returns true if the given schema is TObject */
|
|
463
|
+
function TObject(schema: unknown): schema is TObject;
|
|
464
|
+
/** Returns true if the given schema is TPromise */
|
|
465
|
+
function TPromise(schema: unknown): schema is TPromise;
|
|
466
|
+
/** Returns true if the given schema is TRecord */
|
|
467
|
+
function TRecord(schema: unknown): schema is TRecord;
|
|
468
|
+
/** Returns true if the given schema is TSelf */
|
|
469
|
+
function TSelf(schema: unknown): schema is TSelf;
|
|
470
|
+
/** Returns true if the given schema is TRef */
|
|
471
|
+
function TRef(schema: unknown): schema is TRef;
|
|
472
|
+
/** Returns true if the given schema is TString */
|
|
473
|
+
function TString(schema: unknown): schema is TString;
|
|
474
|
+
/** Returns true if the given schema is TSymbol */
|
|
475
|
+
function TSymbol(schema: unknown): schema is TSymbol;
|
|
476
|
+
/** Returns true if the given schema is TTuple */
|
|
477
|
+
function TTuple(schema: unknown): schema is TTuple;
|
|
478
|
+
/** Returns true if the given schema is TUndefined */
|
|
479
|
+
function TUndefined(schema: unknown): schema is TUndefined;
|
|
480
|
+
/** Returns true if the given schema is TUnion */
|
|
481
|
+
function TUnion(schema: unknown): schema is TUnion;
|
|
482
|
+
/** Returns true if the given schema is TUnion<Literal<string>[]> */
|
|
483
|
+
function TUnionLiteral(schema: unknown): schema is TUnion<TLiteral<string>[]>;
|
|
484
|
+
/** Returns true if the given schema is TUint8Array */
|
|
485
|
+
function TUint8Array(schema: unknown): schema is TUint8Array;
|
|
486
|
+
/** Returns true if the given schema is TUnknown */
|
|
487
|
+
function TUnknown(schema: unknown): schema is TUnknown;
|
|
488
|
+
/** Returns true if the given schema is TVoid */
|
|
489
|
+
function TVoid(schema: unknown): schema is TVoid;
|
|
490
|
+
/** Returns true if this schema has the ReadonlyOptional modifier */
|
|
491
|
+
function TReadonlyOptional<T extends TSchema>(schema: T): schema is TReadonlyOptional<T>;
|
|
492
|
+
/** Returns true if this schema has the Readonly modifier */
|
|
493
|
+
function TReadonly<T extends TSchema>(schema: T): schema is TReadonly<T>;
|
|
494
|
+
/** Returns true if this schema has the Optional modifier */
|
|
495
|
+
function TOptional<T extends TSchema>(schema: T): schema is TOptional<T>;
|
|
496
|
+
/** Returns true if the given schema is TSchema */
|
|
497
|
+
function TSchema(schema: unknown): schema is TSchema;
|
|
498
|
+
}
|
|
499
|
+
export declare namespace ExtendsUndefined {
|
|
500
|
+
/** Fast undefined check for properties of type undefined */
|
|
501
|
+
function Check(schema: TSchema): boolean;
|
|
502
|
+
}
|
|
503
|
+
export declare enum TypeExtendsResult {
|
|
504
|
+
Union = 0,
|
|
505
|
+
True = 1,
|
|
506
|
+
False = 2
|
|
507
|
+
}
|
|
508
|
+
export declare namespace TypeExtends {
|
|
509
|
+
function Extends(left: TSchema, right: TSchema): TypeExtendsResult;
|
|
510
|
+
}
|
|
511
|
+
/** Specialized Clone for Types. Clones and removes non self-referential identifiers */
|
|
512
|
+
export declare namespace TypeClone {
|
|
513
|
+
/** Clones a type. This function will omit non-self referential identifiers on the cloned type. */
|
|
514
|
+
function Clone<T extends TSchema>(schema: T, options: SchemaOptions): T;
|
|
515
|
+
}
|
|
516
|
+
export declare namespace ObjectMap {
|
|
517
|
+
function Map<T = TSchema>(schema: TSchema, callback: (object: TObject) => TObject, options: SchemaOptions): T;
|
|
518
|
+
}
|
|
519
|
+
export declare namespace KeyResolver {
|
|
520
|
+
function Resolve<T extends TSchema>(schema: T): string[];
|
|
521
|
+
}
|
|
522
|
+
export declare class TypeBuilder {
|
|
523
|
+
/** `[Utility]` Creates a schema without `static` and `params` types */
|
|
524
|
+
protected Create<T>(schema: Omit<T, 'static' | 'params'>): T;
|
|
525
|
+
/** `[Standard]` Omits compositing symbols from this schema */
|
|
526
|
+
Strict<T extends TSchema>(schema: T): T;
|
|
527
|
+
}
|
|
528
|
+
export declare class StandardTypeBuilder extends TypeBuilder {
|
|
529
|
+
/** `[Modifier]` Creates a Optional property */
|
|
530
|
+
Optional<T extends TSchema>(schema: T): TOptional<T>;
|
|
531
|
+
/** `[Modifier]` Creates a ReadonlyOptional property */
|
|
532
|
+
ReadonlyOptional<T extends TSchema>(schema: T): TReadonlyOptional<T>;
|
|
533
|
+
/** `[Modifier]` Creates a Readonly object or property */
|
|
534
|
+
Readonly<T extends TSchema>(schema: T): TReadonly<T>;
|
|
535
|
+
/** `[Standard]` Creates an Any type */
|
|
536
|
+
Any(options?: SchemaOptions): TAny;
|
|
537
|
+
/** `[Standard]` Creates an Array type */
|
|
538
|
+
Array<T extends TSchema>(items: T, options?: ArrayOptions): TArray<T>;
|
|
539
|
+
/** `[Standard]` Creates a Boolean type */
|
|
540
|
+
Boolean(options?: SchemaOptions): TBoolean;
|
|
541
|
+
/** `[Standard]` Creates a Composite object type that will Union any overlapping properties of the given Object array */
|
|
542
|
+
Composite<T extends TObject[]>(schemas: [...T], options?: ObjectOptions): TComposite<T>;
|
|
543
|
+
/** `[Standard]` Dereferences the given TRef to its target type */
|
|
544
|
+
Deref<T extends TRef>(schema: T): TDeref<T>;
|
|
545
|
+
/** `[Standard]` Creates a Enum type */
|
|
546
|
+
Enum<T extends Record<string, string | number>>(item: T, options?: SchemaOptions): TEnum<T>;
|
|
547
|
+
/** `[Standard]` A conditional type expression that will return the true type if the left type extends the right */
|
|
548
|
+
Extends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(left: L, right: R, trueType: T, falseType: U, options?: SchemaOptions): TExtends<L, R, T, U>;
|
|
549
|
+
/** `[Standard]` Excludes from the left type any type that is not assignable to the right */
|
|
550
|
+
Exclude<L extends TSchema, R extends TSchema>(left: L, right: R, options?: SchemaOptions): TExclude<L, R>;
|
|
551
|
+
/** `[Standard]` Extracts from left left any type that is assignable to the right */
|
|
552
|
+
Extract<L extends TSchema, R extends TSchema>(left: L, right: R, options?: SchemaOptions): TExtract<L, R>;
|
|
553
|
+
/** `[Standard]` Creates an Integer type */
|
|
554
|
+
Integer(options?: NumericOptions<number>): TInteger;
|
|
555
|
+
/** `[Standard]` Creates a Intersect type */
|
|
556
|
+
Intersect(allOf: [], options?: SchemaOptions): TNever;
|
|
557
|
+
/** `[Standard]` Creates a Intersect type */
|
|
558
|
+
Intersect<T extends [TSchema]>(allOf: [...T], options?: SchemaOptions): T[0];
|
|
559
|
+
Intersect<T extends TSchema[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>;
|
|
560
|
+
/** `[Standard]` Creates a KeyOf type */
|
|
561
|
+
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
562
|
+
/** `[Standard]` Creates a Literal type */
|
|
563
|
+
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
564
|
+
/** `[Standard]` Creates a Never type */
|
|
565
|
+
Never(options?: SchemaOptions): TNever;
|
|
566
|
+
/** `[Standard]` Creates a Not type. The first argument is the disallowed type, the second is the allowed. */
|
|
567
|
+
Not<N extends TSchema, T extends TSchema>(not: N, schema: T, options?: SchemaOptions): TNot<N, T>;
|
|
568
|
+
/** `[Standard]` Creates a Null type */
|
|
569
|
+
Null(options?: SchemaOptions): TNull;
|
|
570
|
+
/** `[Standard]` Creates a Number type */
|
|
571
|
+
Number(options?: NumericOptions<number>): TNumber;
|
|
572
|
+
/** `[Standard]` Creates an Object type */
|
|
573
|
+
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
574
|
+
/** `[Standard]` Creates a mapped type whose keys are omitted from the given type */
|
|
575
|
+
Omit<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TOmit<T, K[number]>;
|
|
576
|
+
/** `[Standard]` Creates a mapped type whose keys are omitted from the given type */
|
|
577
|
+
Omit<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TOmit<T, TUnionOfLiteral<K>>;
|
|
578
|
+
/** `[Standard]` Creates a mapped type where all properties are Optional */
|
|
579
|
+
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
580
|
+
/** `[Standard]` Creates a mapped type whose keys are picked from the given type */
|
|
581
|
+
Pick<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TPick<T, K[number]>;
|
|
582
|
+
/** `[Standard]` Creates a mapped type whose keys are picked from the given type */
|
|
583
|
+
Pick<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TPick<T, TUnionOfLiteral<K>>;
|
|
584
|
+
/** `[Standard]` Creates an Object type from the given Literal Union */
|
|
585
|
+
Record<K extends TUnion<TLiteral<string | number>[]>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordPropertiesFromUnionLiteral<K, T>>;
|
|
586
|
+
/** `[Standard]` Creates an Object type from the given Literal Union */
|
|
587
|
+
Record<K extends TLiteral<string | number>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordPropertiesFromLiteral<K, T>>;
|
|
588
|
+
/** `[Standard]` Creates a Record type */
|
|
589
|
+
Record<K extends TString | TNumeric, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecord<K, T>;
|
|
590
|
+
/** `[Standard]` Creates a Recursive type */
|
|
591
|
+
Recursive<T extends TSchema>(callback: (self: TSelf) => T, options?: SchemaOptions): TRecursive<T>;
|
|
592
|
+
/** `[Standard]` Creates a Ref type. The referenced type must contain a $id */
|
|
593
|
+
Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>;
|
|
594
|
+
/** `[Standard]` Creates a mapped type where all properties are Required */
|
|
595
|
+
Required<T extends TSchema>(schema: T, options?: SchemaOptions): TRequired<T>;
|
|
596
|
+
/** `[Standard]` Creates a String type */
|
|
597
|
+
String<Format extends string>(options?: StringOptions<StringFormatOption | Format>): TString<Format>;
|
|
598
|
+
/** `[Standard]` Creates a Tuple type */
|
|
599
|
+
Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
600
|
+
/** `[Standard]` Creates a Union type */
|
|
601
|
+
Union(anyOf: [], options?: SchemaOptions): TNever;
|
|
602
|
+
/** `[Standard]` Creates a Union type */
|
|
603
|
+
Union<T extends [TSchema]>(anyOf: [...T], options?: SchemaOptions): T[0];
|
|
604
|
+
/** `[Standard]` Creates a Union type */
|
|
605
|
+
Union<T extends TSchema[]>(anyOf: [...T], options?: SchemaOptions): TUnion<T>;
|
|
606
|
+
/** `[Standard]` Creates an Unknown type */
|
|
607
|
+
Unknown(options?: SchemaOptions): TUnknown;
|
|
608
|
+
/** `[Standard]` Creates a Unsafe type that infers for the generic argument */
|
|
609
|
+
Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
|
|
610
|
+
}
|
|
611
|
+
export declare class ExtendedTypeBuilder extends StandardTypeBuilder {
|
|
612
|
+
/** `[Extended]` Creates a BigInt type */
|
|
613
|
+
BigInt(options?: NumericOptions<bigint>): TBigInt;
|
|
614
|
+
/** `[Extended]` Extracts the ConstructorParameters from the given Constructor type */
|
|
615
|
+
ConstructorParameters<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
|
|
616
|
+
/** `[Extended]` Creates a Constructor type */
|
|
617
|
+
Constructor<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TConstructor<TTupleIntoArray<T>, U>;
|
|
618
|
+
/** `[Extended]` Creates a Constructor type */
|
|
619
|
+
Constructor<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TConstructor<T, U>;
|
|
620
|
+
/** `[Extended]` Creates a Date type */
|
|
621
|
+
Date(options?: DateOptions): TDate;
|
|
622
|
+
/** `[Extended]` Creates a Function type */
|
|
623
|
+
Function<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TFunction<TTupleIntoArray<T>, U>;
|
|
624
|
+
/** `[Extended]` Creates a Function type */
|
|
625
|
+
Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
|
|
626
|
+
/** `[Extended]` Extracts the InstanceType from the given Constructor */
|
|
627
|
+
InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
|
|
628
|
+
/** `[Extended]` Extracts the Parameters from the given Function type */
|
|
629
|
+
Parameters<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TParameters<T>;
|
|
630
|
+
/** `[Extended]` Creates a Promise type */
|
|
631
|
+
Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
|
|
632
|
+
/** `[Extended]` Creates a regular expression type */
|
|
633
|
+
RegEx(regex: RegExp, options?: SchemaOptions): TString;
|
|
634
|
+
/** `[Extended]` Extracts the ReturnType from the given Function */
|
|
635
|
+
ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
|
|
636
|
+
/** `[Extended]` Creates a Symbol type */
|
|
637
|
+
Symbol(options?: SchemaOptions): TSymbol;
|
|
638
|
+
/** `[Extended]` Creates a Undefined type */
|
|
639
|
+
Undefined(options?: SchemaOptions): TUndefined;
|
|
640
|
+
/** `[Extended]` Creates a Uint8Array type */
|
|
641
|
+
Uint8Array(options?: Uint8ArrayOptions): TUint8Array;
|
|
642
|
+
/** `[Extended]` Creates a Void type */
|
|
643
|
+
Void(options?: SchemaOptions): TVoid;
|
|
644
|
+
}
|
|
645
|
+
/** JSON Schema TypeBuilder with Static Resolution for TypeScript */
|
|
646
|
+
export declare const StandardType: StandardTypeBuilder;
|
|
647
|
+
/** JSON Schema TypeBuilder with Static Resolution for TypeScript */
|
|
648
|
+
export declare const Type: ExtendedTypeBuilder;
|