@sinclair/typebox 0.31.27 → 0.32.0-dev-1
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 +25 -18
- package/compiler/compiler.js +118 -107
- package/errors/errors.d.ts +7 -7
- package/errors/errors.js +48 -44
- package/index.d.ts +71 -0
- package/index.js +205 -0
- package/package.json +8 -19
- package/readme.md +188 -160
- package/system/errors.d.ts +14 -0
- package/system/errors.js +192 -0
- package/system/index.d.ts +3 -1
- package/system/index.js +10 -16
- package/system/policy.d.ts +21 -0
- package/system/policy.js +74 -0
- package/system/system.d.ts +3 -38
- package/system/system.js +15 -218
- package/type/any/any.d.ts +8 -0
- package/type/any/any.js +36 -0
- package/type/any/index.d.ts +1 -0
- package/type/any/index.js +44 -0
- package/type/array/array.d.ts +25 -0
- package/type/array/array.js +42 -0
- package/type/array/index.d.ts +1 -0
- package/type/array/index.js +44 -0
- package/type/async-iterator/async-iterator.d.ts +11 -0
- package/type/async-iterator/async-iterator.js +42 -0
- package/type/async-iterator/index.d.ts +1 -0
- package/type/async-iterator/index.js +44 -0
- package/type/awaited/awaited.d.ts +12 -0
- package/type/awaited/awaited.js +66 -0
- package/type/awaited/index.d.ts +1 -0
- package/type/awaited/index.js +44 -0
- package/type/bigint/bigint.d.ts +16 -0
- package/type/bigint/bigint.js +40 -0
- package/type/bigint/index.d.ts +1 -0
- package/type/bigint/index.js +44 -0
- package/type/boolean/boolean.d.ts +9 -0
- package/type/boolean/boolean.js +40 -0
- package/type/boolean/index.d.ts +1 -0
- package/type/boolean/index.js +44 -0
- package/type/clone/index.d.ts +2 -0
- package/type/clone/index.js +32 -0
- package/type/clone/type.d.ts +5 -0
- package/type/clone/type.js +41 -0
- package/type/clone/value.d.ts +2 -0
- package/type/clone/value.js +58 -0
- package/type/composite/composite.d.ts +15 -0
- package/type/composite/composite.js +47 -0
- package/type/composite/index.d.ts +1 -0
- package/type/composite/index.js +44 -0
- package/type/const/const.d.ts +30 -0
- package/type/const/const.js +84 -0
- package/type/const/index.d.ts +1 -0
- package/type/const/index.js +44 -0
- package/type/constructor/constructor.d.ts +17 -0
- package/type/constructor/constructor.js +43 -0
- package/type/constructor/index.d.ts +1 -0
- package/type/constructor/index.js +44 -0
- package/type/constructor-parameters/constructor-parameters.d.ts +7 -0
- package/type/constructor-parameters/constructor-parameters.js +37 -0
- package/type/constructor-parameters/index.d.ts +1 -0
- package/type/constructor-parameters/index.js +44 -0
- package/type/date/date.d.ts +21 -0
- package/type/date/date.js +40 -0
- package/type/date/index.d.ts +1 -0
- package/type/date/index.js +44 -0
- package/type/deref/deref.d.ts +24 -0
- package/type/deref/deref.js +136 -0
- package/type/deref/index.d.ts +1 -0
- package/type/deref/index.js +44 -0
- package/type/discard/discard.d.ts +1 -0
- package/type/discard/discard.js +38 -0
- package/type/discard/index.d.ts +1 -0
- package/type/discard/index.js +44 -0
- package/type/enum/enum.d.ts +14 -0
- package/type/enum/enum.js +46 -0
- package/type/enum/index.d.ts +1 -0
- package/type/enum/index.js +44 -0
- package/type/exclude/exclude.d.ts +21 -0
- package/type/exclude/exclude.js +54 -0
- package/type/exclude/index.d.ts +1 -0
- package/type/exclude/index.js +44 -0
- package/type/extends/extends-check.d.ts +9 -0
- package/type/extends/extends-check.js +654 -0
- package/type/extends/extends-undefined.d.ts +3 -0
- package/type/extends/extends-undefined.js +51 -0
- package/type/extends/extends.d.ts +9 -0
- package/type/extends/extends.js +47 -0
- package/type/extends/index.d.ts +3 -0
- package/type/extends/index.js +46 -0
- package/type/extract/extract.d.ts +20 -0
- package/type/extract/extract.js +54 -0
- package/type/extract/index.d.ts +1 -0
- package/type/extract/index.js +44 -0
- package/type/function/function.d.ts +17 -0
- package/type/function/function.js +43 -0
- package/type/function/index.d.ts +1 -0
- package/type/function/index.js +44 -0
- package/type/guard/index.d.ts +2 -0
- package/type/guard/index.js +32 -0
- package/type/guard/type.d.ts +130 -0
- package/type/guard/type.js +515 -0
- package/type/guard/value.d.ts +28 -0
- package/type/guard/value.js +100 -0
- package/type/helpers/helpers.d.ts +42 -0
- package/type/helpers/helpers.js +35 -0
- package/type/helpers/index.d.ts +1 -0
- package/type/helpers/index.js +44 -0
- package/type/index.d.ts +70 -0
- package/type/index.js +113 -0
- package/type/indexed/index.d.ts +3 -0
- package/type/indexed/index.js +46 -0
- package/type/indexed/indexed-key.d.ts +17 -0
- package/type/indexed/indexed-key.js +65 -0
- package/type/indexed/indexed-type.d.ts +33 -0
- package/type/indexed/indexed-type.js +106 -0
- package/type/indexed/indexed.d.ts +8 -0
- package/type/indexed/indexed.js +41 -0
- package/type/instance-type/index.d.ts +1 -0
- package/type/instance-type/index.js +44 -0
- package/type/instance-type/instance-type.d.ts +5 -0
- package/type/instance-type/instance-type.js +36 -0
- package/type/integer/index.d.ts +1 -0
- package/type/integer/index.js +44 -0
- package/type/integer/integer.d.ts +16 -0
- package/type/integer/integer.js +40 -0
- package/type/intersect/index.d.ts +1 -0
- package/type/intersect/index.js +44 -0
- package/type/intersect/intersect.d.ts +22 -0
- package/type/intersect/intersect.js +59 -0
- package/type/intrinsic/index.d.ts +1 -0
- package/type/intrinsic/index.js +44 -0
- package/type/intrinsic/intrinsic.d.ts +27 -0
- package/type/intrinsic/intrinsic.js +106 -0
- package/type/iterator/index.d.ts +1 -0
- package/type/iterator/index.js +44 -0
- package/type/iterator/iterator.d.ts +11 -0
- package/type/iterator/iterator.js +42 -0
- package/type/keyof/index.d.ts +3 -0
- package/type/keyof/index.js +46 -0
- package/type/keyof/keyof-string.d.ts +30 -0
- package/type/keyof/keyof-string.js +103 -0
- package/type/keyof/keyof-type.d.ts +11 -0
- package/type/keyof/keyof-type.js +48 -0
- package/type/keyof/keyof.d.ts +5 -0
- package/type/keyof/keyof.js +38 -0
- package/type/literal/index.d.ts +1 -0
- package/type/literal/index.js +44 -0
- package/type/literal/literal.d.ts +10 -0
- package/type/literal/literal.js +41 -0
- package/type/mapped/index.d.ts +1 -0
- package/type/mapped/index.js +44 -0
- package/type/mapped/mapped.d.ts +26 -0
- package/type/mapped/mapped.js +47 -0
- package/type/modifiers/index.d.ts +1 -0
- package/type/modifiers/index.js +44 -0
- package/type/modifiers/modifiers.d.ts +18 -0
- package/type/modifiers/modifiers.js +78 -0
- package/type/never/index.d.ts +1 -0
- package/type/never/index.js +44 -0
- package/type/never/never.d.ts +9 -0
- package/type/never/never.js +40 -0
- package/type/not/index.d.ts +1 -0
- package/type/not/index.js +44 -0
- package/type/not/not.d.ts +10 -0
- package/type/not/not.js +41 -0
- package/type/null/index.d.ts +1 -0
- package/type/null/index.js +44 -0
- package/type/null/null.d.ts +9 -0
- package/type/null/null.js +40 -0
- package/type/number/index.d.ts +1 -0
- package/type/number/index.js +44 -0
- package/type/number/number.d.ts +16 -0
- package/type/number/number.js +40 -0
- package/type/object/index.d.ts +1 -0
- package/type/object/index.js +44 -0
- package/type/object/object.d.ts +44 -0
- package/type/object/object.js +47 -0
- package/type/omit/index.d.ts +1 -0
- package/type/omit/index.js +44 -0
- package/type/omit/omit.d.ts +21 -0
- package/type/omit/omit.js +75 -0
- package/type/operators/index.d.ts +1 -0
- package/type/operators/index.js +44 -0
- package/type/operators/operators.d.ts +24 -0
- package/type/operators/operators.js +119 -0
- package/type/optional/index.d.ts +1 -0
- package/type/optional/index.js +44 -0
- package/type/optional/optional.d.ts +7 -0
- package/type/optional/optional.js +37 -0
- package/type/parameters/index.d.ts +1 -0
- package/type/parameters/index.js +44 -0
- package/type/parameters/parameters.d.ts +7 -0
- package/type/parameters/parameters.js +37 -0
- package/type/partial/index.d.ts +1 -0
- package/type/partial/index.js +44 -0
- package/type/partial/partial.d.ts +23 -0
- package/type/partial/partial.js +73 -0
- package/type/patterns/index.d.ts +1 -0
- package/type/patterns/index.js +44 -0
- package/type/patterns/patterns.d.ts +6 -0
- package/type/patterns/patterns.js +36 -0
- package/type/pick/index.d.ts +1 -0
- package/type/pick/index.js +44 -0
- package/type/pick/pick.d.ts +21 -0
- package/type/pick/pick.js +66 -0
- package/type/promise/index.d.ts +1 -0
- package/type/promise/index.js +44 -0
- package/type/promise/promise.d.ts +11 -0
- package/type/promise/promise.js +42 -0
- package/type/readonly/index.d.ts +1 -0
- package/type/readonly/index.js +44 -0
- package/type/readonly/readonly.d.ts +7 -0
- package/type/readonly/readonly.js +37 -0
- package/type/readonly-optional/index.d.ts +1 -0
- package/type/readonly-optional/index.js +44 -0
- package/type/readonly-optional/readonly-optional.d.ts +6 -0
- package/type/readonly-optional/readonly-optional.js +37 -0
- package/type/record/index.d.ts +1 -0
- package/type/record/index.js +44 -0
- package/type/record/record.d.ts +55 -0
- package/type/record/record.js +97 -0
- package/type/recursive/index.d.ts +1 -0
- package/type/recursive/index.js +44 -0
- package/type/recursive/recursive.d.ts +15 -0
- package/type/recursive/recursive.js +48 -0
- package/type/ref/index.d.ts +1 -0
- package/type/ref/index.js +44 -0
- package/type/ref/ref.d.ts +12 -0
- package/type/ref/ref.js +45 -0
- package/type/regexp/index.d.ts +1 -0
- package/type/regexp/index.js +44 -0
- package/type/regexp/regexp.d.ts +7 -0
- package/type/regexp/regexp.js +38 -0
- package/type/registry/format.d.ts +13 -0
- package/type/registry/format.js +62 -0
- package/type/registry/index.d.ts +2 -0
- package/type/registry/index.js +32 -0
- package/type/registry/type.d.ts +13 -0
- package/type/registry/type.js +62 -0
- package/type/required/index.d.ts +1 -0
- package/type/required/index.js +44 -0
- package/type/required/required.d.ts +23 -0
- package/type/required/required.js +72 -0
- package/type/rest/index.d.ts +1 -0
- package/type/rest/index.js +44 -0
- package/type/rest/rest.d.ts +10 -0
- package/type/rest/rest.js +41 -0
- package/type/return-type/index.d.ts +1 -0
- package/type/return-type/index.js +44 -0
- package/type/return-type/return-type.d.ts +5 -0
- package/type/return-type/return-type.js +36 -0
- package/type/schema/anyschema.d.ts +32 -0
- package/type/schema/anyschema.js +29 -0
- package/type/schema/index.d.ts +2 -0
- package/type/schema/index.js +45 -0
- package/type/schema/schema.d.ts +29 -0
- package/type/schema/schema.js +30 -0
- package/type/static/index.d.ts +1 -0
- package/type/static/index.js +44 -0
- package/type/static/static.d.ts +34 -0
- package/type/static/static.js +29 -0
- package/type/strict/index.d.ts +1 -0
- package/type/strict/index.js +44 -0
- package/type/strict/strict.d.ts +3 -0
- package/type/strict/strict.js +35 -0
- package/type/string/index.d.ts +1 -0
- package/type/string/index.js +44 -0
- package/type/string/string.d.ts +25 -0
- package/type/string/string.js +36 -0
- package/type/symbol/index.d.ts +1 -0
- package/type/symbol/index.js +44 -0
- package/type/symbol/symbol.d.ts +10 -0
- package/type/symbol/symbol.js +36 -0
- package/type/symbols/index.d.ts +1 -0
- package/type/symbols/index.js +44 -0
- package/type/symbols/symbols.d.ts +10 -0
- package/type/symbols/symbols.js +40 -0
- package/type/template-literal/finite.d.ts +16 -0
- package/type/template-literal/finite.js +71 -0
- package/type/template-literal/generate.d.ts +15 -0
- package/type/template-literal/generate.js +74 -0
- package/type/template-literal/index.d.ts +7 -0
- package/type/template-literal/index.js +50 -0
- package/type/template-literal/parser.d.ts +19 -0
- package/type/template-literal/parser.js +175 -0
- package/type/template-literal/pattern.d.ts +4 -0
- package/type/template-literal/pattern.js +61 -0
- package/type/template-literal/syntax.d.ts +20 -0
- package/type/template-literal/syntax.js +87 -0
- package/type/template-literal/template-literal.d.ts +30 -0
- package/type/template-literal/template-literal.js +43 -0
- package/type/template-literal/union.d.ts +7 -0
- package/type/template-literal/union.js +48 -0
- package/type/transform/index.d.ts +1 -0
- package/type/transform/index.js +44 -0
- package/type/transform/transform.d.ts +29 -0
- package/type/transform/transform.js +72 -0
- package/type/tuple/index.d.ts +1 -0
- package/type/tuple/index.js +44 -0
- package/type/tuple/tuple.d.ts +15 -0
- package/type/tuple/tuple.js +42 -0
- package/type/type/index.d.ts +6 -0
- package/type/type/index.js +44 -0
- package/type/type/javascript.d.ts +58 -0
- package/type/type/javascript.js +120 -0
- package/type/type/json.d.ts +139 -0
- package/type/type/json.js +255 -0
- package/type/type/type.d.ts +58 -0
- package/type/type/type.js +153 -0
- package/type/uint8array/index.d.ts +1 -0
- package/type/uint8array/index.js +44 -0
- package/type/uint8array/uint8array.d.ts +13 -0
- package/type/uint8array/uint8array.js +36 -0
- package/type/undefined/index.d.ts +1 -0
- package/type/undefined/index.js +44 -0
- package/type/undefined/undefined.d.ts +9 -0
- package/type/undefined/undefined.js +36 -0
- package/type/union/index.d.ts +1 -0
- package/type/union/index.js +44 -0
- package/type/union/union.d.ts +16 -0
- package/type/union/union.js +50 -0
- package/type/unknown/index.d.ts +1 -0
- package/type/unknown/index.js +44 -0
- package/type/unknown/unknown.d.ts +8 -0
- package/type/unknown/unknown.js +39 -0
- package/type/unsafe/index.d.ts +1 -0
- package/type/unsafe/index.js +44 -0
- package/type/unsafe/unsafe.d.ts +11 -0
- package/type/unsafe/unsafe.js +39 -0
- package/type/void/index.d.ts +1 -0
- package/type/void/index.js +44 -0
- package/type/void/void.d.ts +9 -0
- package/type/void/void.js +40 -0
- package/value/cast/cast.d.ts +23 -0
- package/value/{cast.js → cast/cast.js} +62 -83
- package/value/cast/index.d.ts +1 -0
- package/value/cast/index.js +44 -0
- package/value/check/check.d.ts +10 -0
- package/value/{check.js → check/check.js} +50 -45
- package/value/check/index.d.ts +1 -0
- package/value/check/index.js +44 -0
- package/value/clean/clean.d.ts +5 -0
- package/value/clean/clean.js +167 -0
- package/value/clean/index.d.ts +1 -0
- package/value/clean/index.js +44 -0
- package/value/{clone.js → clone/clone.js} +6 -6
- package/value/clone/index.d.ts +1 -0
- package/value/clone/index.js +44 -0
- package/value/convert/convert.d.ts +9 -0
- package/value/{convert.js → convert/convert.js} +93 -116
- package/value/convert/index.d.ts +1 -0
- package/value/convert/index.js +44 -0
- package/value/create/create.d.ts +31 -0
- package/value/{create.js → create/create.js} +69 -62
- package/value/create/index.d.ts +1 -0
- package/value/create/index.js +44 -0
- package/value/default/default.d.ts +5 -0
- package/value/default/default.js +175 -0
- package/value/default/index.d.ts +1 -0
- package/value/default/index.js +44 -0
- package/value/delta/delta.d.ts +41 -0
- package/value/{delta.js → delta/delta.js} +57 -53
- package/value/delta/index.d.ts +1 -0
- package/value/delta/index.js +44 -0
- package/value/{deref.d.ts → deref/deref.d.ts} +4 -2
- package/value/{deref.js → deref/deref.js} +1 -2
- package/value/deref/index.d.ts +1 -0
- package/value/deref/index.js +44 -0
- package/value/{equal.js → equal/equal.js} +14 -14
- package/value/equal/index.d.ts +1 -0
- package/value/equal/index.js +44 -0
- package/value/guard/index.d.ts +1 -0
- package/value/guard/index.js +44 -0
- package/value/{hash.d.ts → hash/hash.d.ts} +0 -13
- package/value/{hash.js → hash/hash.js} +26 -26
- package/value/hash/index.d.ts +1 -0
- package/value/hash/index.js +44 -0
- package/value/index.d.ts +17 -4
- package/value/index.js +91 -10
- package/value/mutate/index.d.ts +1 -0
- package/value/mutate/index.js +44 -0
- package/value/{mutate.d.ts → mutate/mutate.d.ts} +1 -1
- package/value/{mutate.js → mutate/mutate.js} +25 -25
- package/value/pointer/index.d.ts +1 -0
- package/value/pointer/index.js +31 -0
- package/value/pointer/pointer.d.ts +21 -0
- package/value/pointer/pointer.js +151 -0
- package/value/transform/decode.d.ts +19 -0
- package/value/transform/decode.js +211 -0
- package/value/transform/encode.d.ts +20 -0
- package/value/transform/encode.js +219 -0
- package/value/transform/has.d.ts +3 -0
- package/value/transform/has.js +146 -0
- package/value/transform/index.d.ts +3 -0
- package/value/transform/index.js +46 -0
- package/value/value/index.d.ts +1 -0
- package/value/value/index.js +31 -0
- package/value/value/value.d.ts +53 -0
- package/value/value/value.js +125 -0
- package/typebox.d.ts +0 -962
- package/typebox.js +0 -2364
- package/value/cast.d.ts +0 -24
- package/value/check.d.ts +0 -9
- package/value/convert.d.ts +0 -10
- package/value/create.d.ts +0 -30
- package/value/delta.d.ts +0 -41
- package/value/pointer.d.ts +0 -24
- package/value/pointer.js +0 -148
- package/value/transform.d.ts +0 -42
- package/value/transform.js +0 -517
- package/value/value.d.ts +0 -47
- package/value/value.js +0 -117
- /package/value/{clone.d.ts → clone/clone.d.ts} +0 -0
- /package/value/{equal.d.ts → equal/equal.d.ts} +0 -0
- /package/value/{guard.d.ts → guard/guard.d.ts} +0 -0
- /package/value/{guard.js → guard/guard.js} +0 -0
package/typebox.d.ts
DELETED
|
@@ -1,962 +0,0 @@
|
|
|
1
|
-
export declare const Transform: unique symbol;
|
|
2
|
-
export declare const Readonly: unique symbol;
|
|
3
|
-
export declare const Optional: unique symbol;
|
|
4
|
-
export declare const Hint: unique symbol;
|
|
5
|
-
export declare const Kind: unique symbol;
|
|
6
|
-
export declare const PatternBoolean = "(true|false)";
|
|
7
|
-
export declare const PatternNumber = "(0|[1-9][0-9]*)";
|
|
8
|
-
export declare const PatternString = "(.*)";
|
|
9
|
-
export declare const PatternBooleanExact = "^(true|false)$";
|
|
10
|
-
export declare const PatternNumberExact = "^(0|[1-9][0-9]*)$";
|
|
11
|
-
export declare const PatternStringExact = "^(.*)$";
|
|
12
|
-
export type TupleToIntersect<T extends any[]> = T extends [infer I] ? I : T extends [infer I, ...infer R] ? I & TupleToIntersect<R> : never;
|
|
13
|
-
export type TupleToUnion<T extends any[]> = {
|
|
14
|
-
[K in keyof T]: T[K];
|
|
15
|
-
}[number];
|
|
16
|
-
export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
|
|
17
|
-
export type UnionLast<U> = UnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
|
|
18
|
-
export type UnionToTuple<U, L = UnionLast<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, L>>, L];
|
|
19
|
-
export type Discard<T extends unknown[], D extends unknown> = T extends [infer L, ...infer R] ? (L extends D ? Discard<R, D> : [L, ...Discard<R, D>]) : [];
|
|
20
|
-
export type Flat<T> = T extends [] ? [] : T extends [infer L] ? [...Flat<L>] : T extends [infer L, ...infer R] ? [...Flat<L>, ...Flat<R>] : [T];
|
|
21
|
-
export type Trim<T> = T extends `${' '}${infer U}` ? Trim<U> : T extends `${infer U}${' '}` ? Trim<U> : T;
|
|
22
|
-
export type Assert<T, E> = T extends E ? T : never;
|
|
23
|
-
export type Evaluate<T> = T extends infer O ? {
|
|
24
|
-
[K in keyof O]: O[K];
|
|
25
|
-
} : never;
|
|
26
|
-
export type Ensure<T> = T extends infer U ? U : never;
|
|
27
|
-
export type AssertProperties<T> = T extends TProperties ? T : TProperties;
|
|
28
|
-
export type AssertRest<T, E extends TSchema[] = TSchema[]> = T extends E ? T : [];
|
|
29
|
-
export type AssertType<T, E extends TSchema = TSchema> = T extends E ? T : TNever;
|
|
30
|
-
export type TReadonlyOptional<T extends TSchema> = TOptional<T> & TReadonly<T>;
|
|
31
|
-
export type TReadonly<T extends TSchema> = T & {
|
|
32
|
-
[Readonly]: 'Readonly';
|
|
33
|
-
};
|
|
34
|
-
export type TOptional<T extends TSchema> = T & {
|
|
35
|
-
[Optional]: 'Optional';
|
|
36
|
-
};
|
|
37
|
-
export type ReadonlyUnwrapType<T extends TSchema> = T extends TReadonly<infer S> ? ReadonlyUnwrapType<S> : T extends TOptional<infer S> ? TOptional<ReadonlyUnwrapType<S>> : T;
|
|
38
|
-
export type ReadonlyUnwrapRest<T extends TSchema[]> = T extends [infer L, ...infer R] ? L extends TReadonly<infer S> ? [ReadonlyUnwrapType<AssertType<S>>, ...ReadonlyUnwrapRest<AssertRest<R>>] : [L, ...ReadonlyUnwrapRest<AssertRest<R>>] : [];
|
|
39
|
-
export type OptionalUnwrapType<T extends TSchema> = T extends TReadonly<infer S> ? TReadonly<OptionalUnwrapType<S>> : T extends TOptional<infer S> ? OptionalUnwrapType<S> : T;
|
|
40
|
-
export type OptionalUnwrapRest<T extends TSchema[]> = T extends [infer L, ...infer R] ? L extends TOptional<infer S> ? [OptionalUnwrapType<AssertType<S>>, ...OptionalUnwrapRest<AssertRest<R>>] : [L, ...OptionalUnwrapRest<AssertRest<R>>] : [];
|
|
41
|
-
export type IntersectOptional<T extends TSchema[]> = T extends [infer L, ...infer R] ? L extends TOptional<AssertType<L>> ? IntersectOptional<AssertRest<R>> : false : true;
|
|
42
|
-
export type IntersectResolve<T extends TSchema[], U = OptionalUnwrapRest<AssertRest<T>>> = IntersectOptional<AssertRest<T>> extends true ? TOptional<TIntersect<AssertRest<U>>> : TIntersect<AssertRest<U>>;
|
|
43
|
-
export type IntersectType<T extends TSchema[]> = T extends [] ? TNever : T extends [TSchema] ? AssertType<T[0]> : IntersectResolve<T>;
|
|
44
|
-
export type UnionOptional<T extends TSchema[]> = T extends [infer L, ...infer R] ? L extends (TOptional<AssertType<L>>) ? true : UnionOptional<AssertRest<R>> : false;
|
|
45
|
-
export type UnionResolve<T extends TSchema[], U = OptionalUnwrapRest<AssertRest<T>>> = UnionOptional<AssertRest<T>> extends true ? TOptional<TUnion<AssertRest<U>>> : TUnion<AssertRest<U>>;
|
|
46
|
-
export type UnionType<T extends TSchema[]> = T extends [] ? TNever : T extends [TSchema] ? AssertType<T[0]> : UnionResolve<T>;
|
|
47
|
-
export interface SchemaOptions {
|
|
48
|
-
$schema?: string;
|
|
49
|
-
/** Id for this schema */
|
|
50
|
-
$id?: string;
|
|
51
|
-
/** Title of this schema */
|
|
52
|
-
title?: string;
|
|
53
|
-
/** Description of this schema */
|
|
54
|
-
description?: string;
|
|
55
|
-
/** Default value for this schema */
|
|
56
|
-
default?: any;
|
|
57
|
-
/** Example values matching this schema */
|
|
58
|
-
examples?: any;
|
|
59
|
-
/** Optional annotation for readOnly */
|
|
60
|
-
readOnly?: boolean;
|
|
61
|
-
/** Optional annotation for writeOnly */
|
|
62
|
-
writeOnly?: boolean;
|
|
63
|
-
[prop: string]: any;
|
|
64
|
-
}
|
|
65
|
-
export interface TKind {
|
|
66
|
-
[Kind]: string;
|
|
67
|
-
}
|
|
68
|
-
export interface TSchema extends SchemaOptions, TKind {
|
|
69
|
-
[Readonly]?: string;
|
|
70
|
-
[Optional]?: string;
|
|
71
|
-
[Hint]?: string;
|
|
72
|
-
params: unknown[];
|
|
73
|
-
static: unknown;
|
|
74
|
-
}
|
|
75
|
-
export type TAnySchema = TSchema | TAny | TArray | TAsyncIterator | TBigInt | TBoolean | TConstructor | TDate | TEnum | TFunction | TInteger | TIntersect | TIterator | TLiteral | TNot | TNull | TNumber | TObject | TPromise | TRecord | TRef | TString | TSymbol | TTemplateLiteral | TThis | TTuple | TUndefined | TUnion | TUint8Array | TUnknown | TVoid;
|
|
76
|
-
export interface NumericOptions<N extends number | bigint> extends SchemaOptions {
|
|
77
|
-
exclusiveMaximum?: N;
|
|
78
|
-
exclusiveMinimum?: N;
|
|
79
|
-
maximum?: N;
|
|
80
|
-
minimum?: N;
|
|
81
|
-
multipleOf?: N;
|
|
82
|
-
}
|
|
83
|
-
export interface TAny extends TSchema {
|
|
84
|
-
[Kind]: 'Any';
|
|
85
|
-
static: any;
|
|
86
|
-
}
|
|
87
|
-
export interface ArrayOptions extends SchemaOptions {
|
|
88
|
-
/** The minimum number of items in this array */
|
|
89
|
-
minItems?: number;
|
|
90
|
-
/** The maximum number of items in this array */
|
|
91
|
-
maxItems?: number;
|
|
92
|
-
/** Should this schema contain unique items */
|
|
93
|
-
uniqueItems?: boolean;
|
|
94
|
-
/** A schema for which some elements should match */
|
|
95
|
-
contains?: TSchema;
|
|
96
|
-
/** A minimum number of contains schema matches */
|
|
97
|
-
minContains?: number;
|
|
98
|
-
/** A maximum number of contains schema matches */
|
|
99
|
-
maxContains?: number;
|
|
100
|
-
}
|
|
101
|
-
export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
102
|
-
[Kind]: 'Array';
|
|
103
|
-
static: Static<T, this['params']>[];
|
|
104
|
-
type: 'array';
|
|
105
|
-
items: T;
|
|
106
|
-
}
|
|
107
|
-
export interface TAsyncIterator<T extends TSchema = TSchema> extends TSchema {
|
|
108
|
-
[Kind]: 'AsyncIterator';
|
|
109
|
-
static: AsyncIterableIterator<Static<T, this['params']>>;
|
|
110
|
-
type: 'AsyncIterator';
|
|
111
|
-
items: T;
|
|
112
|
-
}
|
|
113
|
-
export type TAwaitedRest<T extends TSchema[]> = T extends [infer L, ...infer R] ? [TAwaited<AssertType<L>>, ...TAwaitedRest<AssertRest<R>>] : [];
|
|
114
|
-
export type TAwaited<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TAwaitedRest<S>> : T extends TUnion<infer S> ? TUnion<TAwaitedRest<S>> : T extends TPromise<infer S> ? TAwaited<S> : T;
|
|
115
|
-
export interface TBigInt extends TSchema, NumericOptions<bigint> {
|
|
116
|
-
[Kind]: 'BigInt';
|
|
117
|
-
static: bigint;
|
|
118
|
-
type: 'bigint';
|
|
119
|
-
}
|
|
120
|
-
export interface TBoolean extends TSchema {
|
|
121
|
-
[Kind]: 'Boolean';
|
|
122
|
-
static: boolean;
|
|
123
|
-
type: 'boolean';
|
|
124
|
-
}
|
|
125
|
-
export type TConstructorParameters<T extends TConstructor<TSchema[], TSchema>> = Ensure<TTuple<T['parameters']>>;
|
|
126
|
-
export type TInstanceType<T extends TConstructor<TSchema[], TSchema>> = T['returns'];
|
|
127
|
-
export type TCompositeKeys<T extends TObject[]> = T extends [infer L, ...infer R] ? keyof Assert<L, TObject>['properties'] | TCompositeKeys<Assert<R, TObject[]>> : never;
|
|
128
|
-
export type TCompositeIndex<T extends TIntersect<TObject[]>, K extends string[]> = K extends [infer L, ...infer R] ? {
|
|
129
|
-
[_ in Assert<L, string>]: TIndexType<T, Assert<L, string>>;
|
|
130
|
-
} & TCompositeIndex<T, Assert<R, string[]>> : {};
|
|
131
|
-
export type TCompositeReduce<T extends TObject[]> = UnionToTuple<TCompositeKeys<T>> extends infer K ? Evaluate<TCompositeIndex<TIntersect<T>, Assert<K, string[]>>> : {};
|
|
132
|
-
export type TComposite<T extends TObject[]> = TIntersect<T> extends TIntersect ? TObject<TCompositeReduce<T>> : TObject<{}>;
|
|
133
|
-
export type TConstructorReturnTypeResolve<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
134
|
-
export type TConstructorParametersResolve<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...TFunctionParametersResolve<R, P>] : [];
|
|
135
|
-
export type TConstructorResolve<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<new (...param: TConstructorParametersResolve<T, P>) => TConstructorReturnTypeResolve<U, P>>;
|
|
136
|
-
export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
137
|
-
[Kind]: 'Constructor';
|
|
138
|
-
static: TConstructorResolve<T, U, this['params']>;
|
|
139
|
-
type: 'Constructor';
|
|
140
|
-
parameters: T;
|
|
141
|
-
returns: U;
|
|
142
|
-
}
|
|
143
|
-
export interface DateOptions extends SchemaOptions {
|
|
144
|
-
/** The exclusive maximum timestamp value */
|
|
145
|
-
exclusiveMaximumTimestamp?: number;
|
|
146
|
-
/** The exclusive minimum timestamp value */
|
|
147
|
-
exclusiveMinimumTimestamp?: number;
|
|
148
|
-
/** The maximum timestamp value */
|
|
149
|
-
maximumTimestamp?: number;
|
|
150
|
-
/** The minimum timestamp value */
|
|
151
|
-
minimumTimestamp?: number;
|
|
152
|
-
/** The multiple of timestamp value */
|
|
153
|
-
multipleOfTimestamp?: number;
|
|
154
|
-
}
|
|
155
|
-
export interface TDate extends TSchema, DateOptions {
|
|
156
|
-
[Kind]: 'Date';
|
|
157
|
-
static: Date;
|
|
158
|
-
type: 'date';
|
|
159
|
-
}
|
|
160
|
-
export type TEnumRecord = Record<TEnumKey, TEnumValue>;
|
|
161
|
-
export type TEnumValue = string | number;
|
|
162
|
-
export type TEnumKey = string;
|
|
163
|
-
export interface TEnum<T extends Record<string, string | number> = Record<string, string | number>> extends TSchema {
|
|
164
|
-
[Kind]: 'Union';
|
|
165
|
-
[Hint]: 'Enum';
|
|
166
|
-
static: T[keyof T];
|
|
167
|
-
anyOf: TLiteral<T[keyof T]>[];
|
|
168
|
-
}
|
|
169
|
-
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<[AssertType<X>, AssertType<Y>]> : AssertType<O> : never;
|
|
170
|
-
export type TExcludeTemplateLiteralResult<T extends string> = UnionType<AssertRest<UnionToTuple<{
|
|
171
|
-
[K in T]: TLiteral<K>;
|
|
172
|
-
}[T]>>>;
|
|
173
|
-
export type TExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Exclude<Static<T>, Static<U>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never;
|
|
174
|
-
export type TExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
|
|
175
|
-
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K];
|
|
176
|
-
}[number]>> extends infer R ? UnionType<AssertRest<R>> : never;
|
|
177
|
-
export type TExclude<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? TExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? TExcludeArray<S, U> : T extends U ? TNever : T;
|
|
178
|
-
export type TExtractTemplateLiteralResult<T extends string> = UnionType<AssertRest<UnionToTuple<{
|
|
179
|
-
[K in T]: TLiteral<K>;
|
|
180
|
-
}[T]>>>;
|
|
181
|
-
export type TExtractTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extract<Static<T>, Static<U>> extends infer S ? TExtractTemplateLiteralResult<Assert<S, string>> : never;
|
|
182
|
-
export type TExtractArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
|
|
183
|
-
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? T[K] : never;
|
|
184
|
-
}[number]>> extends infer R ? UnionType<AssertRest<R>> : never;
|
|
185
|
-
export type TExtract<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? TExtractTemplateLiteral<T, U> : T extends TUnion<infer S> ? TExtractArray<S, U> : T extends U ? T : T;
|
|
186
|
-
export type TFunctionReturnTypeResolve<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
187
|
-
export type TFunctionParametersResolve<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...TFunctionParametersResolve<R, P>] : [];
|
|
188
|
-
export type TFunctionResolve<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<(...param: TFunctionParametersResolve<T, P>) => TFunctionReturnTypeResolve<U, P>>;
|
|
189
|
-
export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
190
|
-
[Kind]: 'Function';
|
|
191
|
-
static: TFunctionResolve<T, U, this['params']>;
|
|
192
|
-
type: 'Function';
|
|
193
|
-
parameters: T;
|
|
194
|
-
returns: U;
|
|
195
|
-
}
|
|
196
|
-
export type TIndexRest<T extends TSchema[], K extends TPropertyKey> = T extends [infer L, ...infer R] ? [TIndexType<AssertType<L>, K>, ...TIndexRest<AssertRest<R>, K>] : [];
|
|
197
|
-
export type TIndexProperty<T extends TProperties, K extends TPropertyKey> = K extends keyof T ? [T[K]] : [];
|
|
198
|
-
export type TIndexTuple<T extends TSchema[], K extends TPropertyKey> = K extends keyof T ? [T[K]] : [];
|
|
199
|
-
export type TIndexType<T extends TSchema, K extends TPropertyKey> = T extends TRecursive<infer S> ? TIndexType<S, K> : T extends TIntersect<infer S> ? IntersectType<AssertRest<Discard<Flat<TIndexRest<S, K>>, TNever>>> : T extends TUnion<infer S> ? UnionType<AssertRest<Flat<TIndexRest<S, K>>>> : T extends TObject<infer S> ? UnionType<AssertRest<Flat<TIndexProperty<S, K>>>> : T extends TTuple<infer S> ? UnionType<AssertRest<Flat<TIndexTuple<S, K>>>> : [
|
|
200
|
-
];
|
|
201
|
-
export type TIndexRestMany<T extends TSchema, K extends TPropertyKey[]> = K extends [infer L, ...infer R] ? [TIndexType<T, Assert<L, TPropertyKey>>, ...TIndexRestMany<T, Assert<R, TPropertyKey[]>>] : [
|
|
202
|
-
];
|
|
203
|
-
export type TIndex<T extends TSchema, K extends TPropertyKey[]> = T extends TRecursive<infer S> ? TIndex<S, K> : T extends TIntersect ? UnionType<Flat<TIndexRestMany<T, K>>> : T extends TUnion ? UnionType<Flat<TIndexRestMany<T, K>>> : T extends TObject ? UnionType<Flat<TIndexRestMany<T, K>>> : T extends TTuple ? UnionType<Flat<TIndexRestMany<T, K>>> : TNever;
|
|
204
|
-
export type TIntrinsicMode = 'Uppercase' | 'Lowercase' | 'Capitalize' | 'Uncapitalize';
|
|
205
|
-
export type TIntrinsicTemplateLiteral<T extends TTemplateLiteralKind[], M extends TIntrinsicMode> = M extends ('Lowercase' | 'Uppercase') ? T extends [infer L, ...infer R] ? [TIntrinsic<AssertType<L>, M>, ...TIntrinsicTemplateLiteral<AssertRest<R>, M>] : T : M extends ('Capitalize' | 'Uncapitalize') ? T extends [infer L, ...infer R] ? [TIntrinsic<AssertType<L>, M>, ...R] : T : T;
|
|
206
|
-
export type TIntrinsicLiteral<T, M extends TIntrinsicMode> = T extends string ? M extends 'Uncapitalize' ? Uncapitalize<T> : M extends 'Capitalize' ? Capitalize<T> : M extends 'Uppercase' ? Uppercase<T> : M extends 'Lowercase' ? Lowercase<T> : string : T;
|
|
207
|
-
export type TIntrinsicRest<T extends TSchema[], M extends TIntrinsicMode> = T extends [infer L, ...infer R] ? [TIntrinsic<AssertType<L>, M>, ...TIntrinsicRest<AssertRest<R>, M>] : [];
|
|
208
|
-
export type TIntrinsic<T extends TSchema, M extends TIntrinsicMode> = T extends TTemplateLiteral<infer S> ? TTemplateLiteral<TIntrinsicTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<TIntrinsicRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<TIntrinsicLiteral<S, M>> : T;
|
|
209
|
-
export interface TInteger extends TSchema, NumericOptions<number> {
|
|
210
|
-
[Kind]: 'Integer';
|
|
211
|
-
static: number;
|
|
212
|
-
type: 'integer';
|
|
213
|
-
}
|
|
214
|
-
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
215
|
-
export interface IntersectOptions extends SchemaOptions {
|
|
216
|
-
unevaluatedProperties?: TUnevaluatedProperties;
|
|
217
|
-
}
|
|
218
|
-
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
219
|
-
[Kind]: 'Intersect';
|
|
220
|
-
static: TupleToIntersect<{
|
|
221
|
-
[K in keyof T]: Static<AssertType<T[K]>, this['params']>;
|
|
222
|
-
}>;
|
|
223
|
-
type?: 'object';
|
|
224
|
-
allOf: [...T];
|
|
225
|
-
}
|
|
226
|
-
export interface TIterator<T extends TSchema = TSchema> extends TSchema {
|
|
227
|
-
[Kind]: 'Iterator';
|
|
228
|
-
static: IterableIterator<Static<T, this['params']>>;
|
|
229
|
-
type: 'Iterator';
|
|
230
|
-
items: T;
|
|
231
|
-
}
|
|
232
|
-
export type TKeyOfProperties<T extends TSchema> = Discard<Static<T> extends infer S ? UnionToTuple<{
|
|
233
|
-
[K in keyof S]: TLiteral<Assert<K, TLiteralValue>>;
|
|
234
|
-
}[keyof S]> : [], undefined>;
|
|
235
|
-
export type TKeyOfIndicesArray<T extends TSchema[]> = UnionToTuple<keyof T & `${number}`>;
|
|
236
|
-
export type TKeyOfIndices<T extends TSchema[]> = AssertRest<TKeyOfIndicesArray<T> extends infer R ? {
|
|
237
|
-
[K in keyof R]: TLiteral<Assert<R[K], TLiteralValue>>;
|
|
238
|
-
} : []>;
|
|
239
|
-
export type TKeyOf<T extends TSchema = TSchema> = (T extends TRecursive<infer S> ? TKeyOfProperties<S> : T extends TIntersect ? TKeyOfProperties<T> : T extends TUnion ? TKeyOfProperties<T> : T extends TObject ? TKeyOfProperties<T> : T extends TTuple<infer K> ? TKeyOfIndices<K> : T extends TArray ? [TNumber] : T extends TRecord<infer K> ? [K] : [
|
|
240
|
-
]) extends infer R ? UnionType<AssertRest<R>> : never;
|
|
241
|
-
export type TLiteralValue = boolean | number | string;
|
|
242
|
-
export type TLiteralBoolean = TLiteral<boolean>;
|
|
243
|
-
export type TLiteralNumber = TLiteral<number>;
|
|
244
|
-
export type TLiteralString = TLiteral<string>;
|
|
245
|
-
export interface TLiteral<T extends TLiteralValue = TLiteralValue> extends TSchema {
|
|
246
|
-
[Kind]: 'Literal';
|
|
247
|
-
static: T;
|
|
248
|
-
const: T;
|
|
249
|
-
}
|
|
250
|
-
export interface TNever extends TSchema {
|
|
251
|
-
[Kind]: 'Never';
|
|
252
|
-
static: never;
|
|
253
|
-
not: {};
|
|
254
|
-
}
|
|
255
|
-
export interface TNot<T extends TSchema = TSchema> extends TSchema {
|
|
256
|
-
[Kind]: 'Not';
|
|
257
|
-
static: T extends TNot<infer U> ? Static<U> : unknown;
|
|
258
|
-
not: T;
|
|
259
|
-
}
|
|
260
|
-
export interface TNull extends TSchema {
|
|
261
|
-
[Kind]: 'Null';
|
|
262
|
-
static: null;
|
|
263
|
-
type: 'null';
|
|
264
|
-
}
|
|
265
|
-
export interface TNumber extends TSchema, NumericOptions<number> {
|
|
266
|
-
[Kind]: 'Number';
|
|
267
|
-
static: number;
|
|
268
|
-
type: 'number';
|
|
269
|
-
}
|
|
270
|
-
export type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
271
|
-
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
|
|
272
|
-
}[keyof T];
|
|
273
|
-
export type ReadonlyPropertyKeys<T extends TProperties> = {
|
|
274
|
-
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
|
|
275
|
-
}[keyof T];
|
|
276
|
-
export type OptionalPropertyKeys<T extends TProperties> = {
|
|
277
|
-
[K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
|
|
278
|
-
}[keyof T];
|
|
279
|
-
export type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
280
|
-
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>>>)>;
|
|
281
|
-
export type PropertiesReduce<T extends TProperties, P extends unknown[]> = PropertiesReducer<T, {
|
|
282
|
-
[K in keyof T]: Static<T[K], P>;
|
|
283
|
-
}>;
|
|
284
|
-
export type TPropertyKey = string | number;
|
|
285
|
-
export type TProperties = Record<TPropertyKey, TSchema>;
|
|
286
|
-
export type ObjectProperties<T> = T extends TObject<infer U> ? U : never;
|
|
287
|
-
export type ObjectPropertyKeys<T> = T extends TObject<infer U> ? keyof U : never;
|
|
288
|
-
export type TAdditionalProperties = undefined | TSchema | boolean;
|
|
289
|
-
export interface ObjectOptions extends SchemaOptions {
|
|
290
|
-
/** Additional property constraints for this object */
|
|
291
|
-
additionalProperties?: TAdditionalProperties;
|
|
292
|
-
/** The minimum number of properties allowed on this object */
|
|
293
|
-
minProperties?: number;
|
|
294
|
-
/** The maximum number of properties allowed on this object */
|
|
295
|
-
maxProperties?: number;
|
|
296
|
-
}
|
|
297
|
-
export interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
298
|
-
[Kind]: 'Object';
|
|
299
|
-
static: PropertiesReduce<T, this['params']>;
|
|
300
|
-
additionalProperties?: TAdditionalProperties;
|
|
301
|
-
type: 'object';
|
|
302
|
-
properties: T;
|
|
303
|
-
required?: string[];
|
|
304
|
-
}
|
|
305
|
-
export type TOmitProperties<T extends TProperties, K extends keyof any> = Evaluate<AssertProperties<Omit<T, K>>>;
|
|
306
|
-
export type TOmitRest<T extends TSchema[], K extends keyof any> = AssertRest<{
|
|
307
|
-
[K2 in keyof T]: TOmit<AssertType<T[K2]>, K>;
|
|
308
|
-
}>;
|
|
309
|
-
export type TOmit<T extends TSchema = TSchema, K extends keyof any = keyof any> = T extends TRecursive<infer S> ? TRecursive<TOmit<S, K>> : T extends TIntersect<infer S> ? TIntersect<TOmitRest<S, K>> : T extends TUnion<infer S> ? TUnion<TOmitRest<S, K>> : T extends TObject<infer S> ? TObject<TOmitProperties<S, K>> : T;
|
|
310
|
-
export type TParameters<T extends TFunction> = Ensure<TTuple<T['parameters']>>;
|
|
311
|
-
export type TPartialObjectArray<T extends TObject[]> = AssertRest<{
|
|
312
|
-
[K in keyof T]: TPartial<AssertType<T[K], TObject>>;
|
|
313
|
-
}, TObject[]>;
|
|
314
|
-
export type TPartialRest<T extends TSchema[]> = AssertRest<{
|
|
315
|
-
[K in keyof T]: TPartial<AssertType<T[K]>>;
|
|
316
|
-
}>;
|
|
317
|
-
export type TPartialProperties<T extends TProperties> = Evaluate<AssertProperties<{
|
|
318
|
-
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
|
|
319
|
-
}>>;
|
|
320
|
-
export type TPartial<T extends TSchema> = T extends TRecursive<infer S> ? TRecursive<TPartial<S>> : T extends TIntersect<infer S> ? TIntersect<TPartialRest<S>> : T extends TUnion<infer S> ? TUnion<TPartialRest<S>> : T extends TObject<infer S> ? TObject<TPartialProperties<S>> : T;
|
|
321
|
-
export type TPickProperties<T extends TProperties, K extends keyof any> = Pick<T, Assert<Extract<K, keyof T>, keyof T>> extends infer R ? ({
|
|
322
|
-
[K in keyof R]: AssertType<R[K]> extends TSchema ? R[K] : never;
|
|
323
|
-
}) : never;
|
|
324
|
-
export type TPickRest<T extends TSchema[], K extends keyof any> = {
|
|
325
|
-
[K2 in keyof T]: TPick<AssertType<T[K2]>, K>;
|
|
326
|
-
};
|
|
327
|
-
export type TPick<T extends TSchema = TSchema, K extends keyof any = keyof any> = T extends TRecursive<infer S> ? TRecursive<TPick<S, K>> : T extends TIntersect<infer S> ? TIntersect<TPickRest<S, K>> : T extends TUnion<infer S> ? TUnion<TPickRest<S, K>> : T extends TObject<infer S> ? TObject<TPickProperties<S, K>> : T;
|
|
328
|
-
export interface TPromise<T extends TSchema = TSchema> extends TSchema {
|
|
329
|
-
[Kind]: 'Promise';
|
|
330
|
-
static: Promise<Static<T, this['params']>>;
|
|
331
|
-
type: 'Promise';
|
|
332
|
-
item: TSchema;
|
|
333
|
-
}
|
|
334
|
-
export type TRecordFromUnionLiteralString<K extends TLiteralString, T extends TSchema> = {
|
|
335
|
-
[_ in K['const']]: T;
|
|
336
|
-
};
|
|
337
|
-
export type TRecordFromUnionLiteralNumber<K extends TLiteralNumber, T extends TSchema> = {
|
|
338
|
-
[_ in K['const']]: T;
|
|
339
|
-
};
|
|
340
|
-
export type TRecordFromEnumKey<K extends Record<string, string | number>, T extends TSchema> = Ensure<TObject<{
|
|
341
|
-
[_ in K[keyof K]]: T;
|
|
342
|
-
}>>;
|
|
343
|
-
export type TRecordFromUnionRest<K extends TSchema[], T extends TSchema> = K extends [infer L, ...infer R] ? (L extends TUnion<infer S> ? TRecordFromUnionRest<S, T> & TRecordFromUnionRest<AssertRest<R>, T> : L extends TLiteralString ? TRecordFromUnionLiteralString<L, T> & TRecordFromUnionRest<AssertRest<R>, T> : L extends TLiteralNumber ? TRecordFromUnionLiteralNumber<L, T> & TRecordFromUnionRest<AssertRest<R>, T> : {}) : {};
|
|
344
|
-
export type TRecordFromUnion<K extends TSchema[], T extends TSchema> = Ensure<TObject<AssertProperties<Evaluate<TRecordFromUnionRest<K, T>>>>>;
|
|
345
|
-
export type TRecordFromTemplateLiteralKeyInfinite<K extends TTemplateLiteral, T extends TSchema> = Ensure<TRecord<K, T>>;
|
|
346
|
-
export type TRecordFromTemplateLiteralKeyFinite<K extends TTemplateLiteral, T extends TSchema, I = Static<K>> = Ensure<TObject<Evaluate<{
|
|
347
|
-
[_ in Assert<I, string>]: T;
|
|
348
|
-
}>>>;
|
|
349
|
-
export type TRecordFromTemplateLiteralKey<K extends TTemplateLiteral, T extends TSchema> = IsTemplateLiteralFinite<K> extends false ? TRecordFromTemplateLiteralKeyInfinite<K, T> : TRecordFromTemplateLiteralKeyFinite<K, T>;
|
|
350
|
-
export type TRecordFromLiteralStringKey<K extends TLiteralString, T extends TSchema> = Ensure<TObject<{
|
|
351
|
-
[_ in K['const']]: T;
|
|
352
|
-
}>>;
|
|
353
|
-
export type TRecordFromLiteralNumberKey<K extends TLiteralNumber, T extends TSchema> = Ensure<TObject<{
|
|
354
|
-
[_ in K['const']]: T;
|
|
355
|
-
}>>;
|
|
356
|
-
export type TRecordFromStringKey<K extends TString, T extends TSchema> = Ensure<TRecord<K, T>>;
|
|
357
|
-
export type TRecordFromNumberKey<K extends TNumber, T extends TSchema> = Ensure<TRecord<K, T>>;
|
|
358
|
-
export type TRecordFromIntegerKey<K extends TInteger, T extends TSchema> = Ensure<TRecord<K, T>>;
|
|
359
|
-
export type TRecordResolve<K extends TSchema, T extends TSchema> = K extends TEnum<infer S> ? TRecordFromEnumKey<S, T> : K extends TUnion<infer S> ? TRecordFromUnion<S, T> : K extends TTemplateLiteral ? TRecordFromTemplateLiteralKey<K, T> : K extends TLiteralString ? TRecordFromLiteralStringKey<K, T> : K extends TLiteralNumber ? TRecordFromLiteralNumberKey<K, T> : K extends TString ? TRecordFromStringKey<K, T> : K extends TNumber ? TRecordFromNumberKey<K, T> : K extends TInteger ? TRecordFromIntegerKey<K, T> : TNever;
|
|
360
|
-
export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
|
|
361
|
-
[Kind]: 'Record';
|
|
362
|
-
static: Record<Assert<Static<K>, string | number>, Static<T, this['params']>>;
|
|
363
|
-
type: 'object';
|
|
364
|
-
patternProperties: {
|
|
365
|
-
[pattern: string]: T;
|
|
366
|
-
};
|
|
367
|
-
additionalProperties: TAdditionalProperties;
|
|
368
|
-
}
|
|
369
|
-
export interface TThis extends TSchema {
|
|
370
|
-
[Kind]: 'This';
|
|
371
|
-
static: this['params'][0];
|
|
372
|
-
$ref: string;
|
|
373
|
-
}
|
|
374
|
-
export type TRecursiveReduce<T extends TSchema> = Static<T, [TRecursiveReduce<T>]>;
|
|
375
|
-
export interface TRecursive<T extends TSchema> extends TSchema {
|
|
376
|
-
[Hint]: 'Recursive';
|
|
377
|
-
static: TRecursiveReduce<T>;
|
|
378
|
-
}
|
|
379
|
-
export interface TRef<T extends TSchema = TSchema> extends TSchema {
|
|
380
|
-
[Kind]: 'Ref';
|
|
381
|
-
static: Static<T, this['params']>;
|
|
382
|
-
$ref: string;
|
|
383
|
-
}
|
|
384
|
-
export type TRest<T extends TSchema> = T extends TIntersect<infer R> ? R : T extends TUnion<infer R> ? R : T extends TTuple<infer R> ? R : [];
|
|
385
|
-
export type TReturnType<T extends TFunction> = T['returns'];
|
|
386
|
-
export type TRequiredRest<T extends TSchema[]> = AssertRest<{
|
|
387
|
-
[K in keyof T]: TRequired<AssertType<T[K]>>;
|
|
388
|
-
}>;
|
|
389
|
-
export type TRequiredProperties<T extends TProperties> = Evaluate<AssertProperties<{
|
|
390
|
-
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
391
|
-
}>>;
|
|
392
|
-
export type TRequired<T extends TSchema> = T extends TRecursive<infer S> ? TRecursive<TRequired<S>> : T extends TIntersect<infer S> ? TIntersect<TRequiredRest<S>> : T extends TUnion<infer S> ? TUnion<TRequiredRest<S>> : T extends TObject<infer S> ? TObject<TRequiredProperties<S>> : T;
|
|
393
|
-
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' | ({} & string);
|
|
394
|
-
export type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
395
|
-
export interface StringOptions extends SchemaOptions {
|
|
396
|
-
/** The maximum string length */
|
|
397
|
-
maxLength?: number;
|
|
398
|
-
/** The minimum string length */
|
|
399
|
-
minLength?: number;
|
|
400
|
-
/** A regular expression pattern this string should match */
|
|
401
|
-
pattern?: string;
|
|
402
|
-
/** A format this string should match */
|
|
403
|
-
format?: StringFormatOption;
|
|
404
|
-
/** The content encoding for this string */
|
|
405
|
-
contentEncoding?: StringContentEncodingOption;
|
|
406
|
-
/** The content media type for this string */
|
|
407
|
-
contentMediaType?: string;
|
|
408
|
-
}
|
|
409
|
-
export interface TString extends TSchema, StringOptions {
|
|
410
|
-
[Kind]: 'String';
|
|
411
|
-
static: string;
|
|
412
|
-
type: 'string';
|
|
413
|
-
}
|
|
414
|
-
export type SymbolValue = string | number | undefined;
|
|
415
|
-
export interface TSymbol extends TSchema, SchemaOptions {
|
|
416
|
-
[Kind]: 'Symbol';
|
|
417
|
-
static: symbol;
|
|
418
|
-
type: 'symbol';
|
|
419
|
-
}
|
|
420
|
-
export type TTemplateLiteralDslParserUnionLiteral<T extends string> = T extends `${infer L}|${infer R}` ? [TLiteral<Trim<L>>, ...TTemplateLiteralDslParserUnionLiteral<R>] : T extends `${infer L}` ? [TLiteral<Trim<L>>] : [
|
|
421
|
-
];
|
|
422
|
-
export type TTemplateLiteralDslParserUnion<T extends string> = UnionType<TTemplateLiteralDslParserUnionLiteral<T>>;
|
|
423
|
-
export type TTemplateLiteralDslParserTerminal<T extends string> = T extends 'boolean' ? TBoolean : T extends 'bigint' ? TBigInt : T extends 'number' ? TNumber : T extends 'string' ? TString : TTemplateLiteralDslParserUnion<T>;
|
|
424
|
-
export type TTemplateLiteralDslParserTemplate<T extends string> = T extends `{${infer L}}${infer R}` ? [TTemplateLiteralDslParserTerminal<L>, ...TTemplateLiteralDslParserTemplate<R>] : T extends `${infer L}$${infer R}` ? [TLiteral<L>, ...TTemplateLiteralDslParserTemplate<R>] : T extends `${infer L}` ? [TLiteral<L>] : [
|
|
425
|
-
];
|
|
426
|
-
export type TTemplateLiteralDslParser<T extends string> = Ensure<TTemplateLiteral<Assert<TTemplateLiteralDslParserTemplate<T>, TTemplateLiteralKind[]>>>;
|
|
427
|
-
export type IsTemplateLiteralFiniteCheck<T> = T extends TTemplateLiteral<infer U> ? IsTemplateLiteralFiniteArray<Assert<U, TTemplateLiteralKind[]>> : T extends TUnion<infer U> ? IsTemplateLiteralFiniteArray<Assert<U, TTemplateLiteralKind[]>> : T extends TString ? false : T extends TBoolean ? false : T extends TNumber ? false : T extends TInteger ? false : T extends TBigInt ? false : T extends TLiteral ? true : false;
|
|
428
|
-
export type IsTemplateLiteralFiniteArray<T extends TTemplateLiteralKind[]> = T extends [infer L, ...infer R] ? IsTemplateLiteralFiniteCheck<L> extends false ? false : IsTemplateLiteralFiniteArray<Assert<R, TTemplateLiteralKind[]>> : true;
|
|
429
|
-
export type IsTemplateLiteralFinite<T> = T extends TTemplateLiteral<infer U> ? IsTemplateLiteralFiniteArray<U> : false;
|
|
430
|
-
export type TTemplateLiteralKind = TUnion | TLiteral | TInteger | TTemplateLiteral | TNumber | TBigInt | TString | TBoolean | TNever;
|
|
431
|
-
export type TTemplateLiteralConst<T, Acc extends string> = T extends TUnion<infer U> ? {
|
|
432
|
-
[K in keyof U]: TTemplateLiteralUnion<Assert<[U[K]], TTemplateLiteralKind[]>, Acc>;
|
|
433
|
-
}[number] : T extends TTemplateLiteral ? `${Static<T>}` : T extends TLiteral<infer U> ? `${U}` : T extends TString ? `${string}` : T extends TNumber ? `${number}` : T extends TBigInt ? `${bigint}` : T extends TBoolean ? `${boolean}` : never;
|
|
434
|
-
export type TTemplateLiteralUnion<T extends TTemplateLiteralKind[], Acc extends string> = T extends [infer L, ...infer R] ? `${TTemplateLiteralConst<L, Acc>}${TTemplateLiteralUnion<Assert<R, TTemplateLiteralKind[]>, Acc>}` : Acc;
|
|
435
|
-
export type TTemplateLiteralKeyRest<T extends TTemplateLiteral> = Assert<UnionToTuple<Static<T>>, TPropertyKey[]>;
|
|
436
|
-
export interface TTemplateLiteral<T extends TTemplateLiteralKind[] = TTemplateLiteralKind[]> extends TSchema {
|
|
437
|
-
[Kind]: 'TemplateLiteral';
|
|
438
|
-
static: TTemplateLiteralUnion<T, ''>;
|
|
439
|
-
type: 'string';
|
|
440
|
-
pattern: string;
|
|
441
|
-
}
|
|
442
|
-
export type DecodeProperties<T extends TProperties> = {
|
|
443
|
-
[K in keyof T]: DecodeType<T[K]>;
|
|
444
|
-
};
|
|
445
|
-
export type DecodeRest<T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [DecodeType<L>, ...DecodeRest<R>] : [];
|
|
446
|
-
export type DecodeType<T extends TSchema> = (T extends TOptional<infer S extends TSchema> ? TOptional<DecodeType<S>> : T extends TReadonly<infer S extends TSchema> ? TReadonly<DecodeType<S>> : T extends TTransform<infer _, infer R> ? TUnsafe<R> : T extends TArray<infer S extends TSchema> ? TArray<DecodeType<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DecodeType<S>> : T extends TConstructor<infer P extends TSchema[], infer R extends TSchema> ? TConstructor<DecodeRest<P>, DecodeType<R>> : T extends TEnum<infer S> ? TEnum<S> : T extends TFunction<infer P extends TSchema[], infer R extends TSchema> ? TFunction<DecodeRest<P>, DecodeType<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<DecodeRest<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DecodeType<S>> : T extends TNot<infer S extends TSchema> ? TNot<DecodeType<S>> : T extends TObject<infer S> ? TObject<Evaluate<DecodeProperties<S>>> : T extends TPromise<infer S extends TSchema> ? TPromise<DecodeType<S>> : T extends TRecord<infer K, infer S> ? TRecord<K, DecodeType<S>> : T extends TRecursive<infer S extends TSchema> ? TRecursive<DecodeType<S>> : T extends TRef<infer S extends TSchema> ? TRef<DecodeType<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<DecodeRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<DecodeRest<S>> : T);
|
|
447
|
-
export type TransformFunction<T = any, U = any> = (value: T) => U;
|
|
448
|
-
export interface TransformOptions<I extends TSchema = TSchema, O extends unknown = unknown> {
|
|
449
|
-
Decode: TransformFunction<StaticDecode<I>, O>;
|
|
450
|
-
Encode: TransformFunction<O, StaticDecode<I>>;
|
|
451
|
-
}
|
|
452
|
-
export type TTransformResolve<T extends TSchema, P extends unknown[] = []> = T extends TTransform<infer _, infer S> ? S : Static<T, P>;
|
|
453
|
-
export interface TTransform<I extends TSchema = TSchema, O extends unknown = unknown> extends TSchema {
|
|
454
|
-
static: TTransformResolve<I, this['params']>;
|
|
455
|
-
[Transform]: TransformOptions<I, O>;
|
|
456
|
-
[key: string]: any;
|
|
457
|
-
}
|
|
458
|
-
export type TTupleRest<T extends TSchema[], P extends unknown[]> = T extends [infer L, ...infer R] ? [Static<AssertType<L>, P>, ...TTupleRest<AssertRest<R>, P>] : [];
|
|
459
|
-
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
460
|
-
[Kind]: 'Tuple';
|
|
461
|
-
static: TTupleRest<T, this['params']>;
|
|
462
|
-
type: 'array';
|
|
463
|
-
items?: T;
|
|
464
|
-
additionalItems?: false;
|
|
465
|
-
minItems: number;
|
|
466
|
-
maxItems: number;
|
|
467
|
-
}
|
|
468
|
-
export interface TUndefined extends TSchema {
|
|
469
|
-
[Kind]: 'Undefined';
|
|
470
|
-
static: undefined;
|
|
471
|
-
type: 'undefined';
|
|
472
|
-
}
|
|
473
|
-
export type TLiteralUnionReduce<T extends TLiteral<string | number>[]> = T extends [infer L, ...infer R] ? [Assert<L, TLiteral<string | number>>['const'], ...TLiteralUnionReduce<Assert<R, TLiteral<string | number>[]>>] : [
|
|
474
|
-
];
|
|
475
|
-
export type TUnionLiteralKeyRest<T extends TUnion<TLiteral<string | number>[]>> = T extends TUnion<infer S> ? TLiteralUnionReduce<Assert<S, TLiteral<string | number>[]>> : [
|
|
476
|
-
];
|
|
477
|
-
export type TUnionTemplateLiteral<T extends TTemplateLiteral, S extends string = Static<T>> = Ensure<UnionType<Assert<UnionToTuple<{
|
|
478
|
-
[K in S]: TLiteral<K>;
|
|
479
|
-
}[S]>, TLiteral[]>>>;
|
|
480
|
-
export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
481
|
-
[Kind]: 'Union';
|
|
482
|
-
static: {
|
|
483
|
-
[K in keyof T]: T[K] extends TSchema ? Static<T[K], this['params']> : never;
|
|
484
|
-
}[number];
|
|
485
|
-
anyOf: T;
|
|
486
|
-
}
|
|
487
|
-
export interface Uint8ArrayOptions extends SchemaOptions {
|
|
488
|
-
maxByteLength?: number;
|
|
489
|
-
minByteLength?: number;
|
|
490
|
-
}
|
|
491
|
-
export interface TUint8Array extends TSchema, Uint8ArrayOptions {
|
|
492
|
-
[Kind]: 'Uint8Array';
|
|
493
|
-
static: Uint8Array;
|
|
494
|
-
type: 'uint8array';
|
|
495
|
-
}
|
|
496
|
-
export interface TUnknown extends TSchema {
|
|
497
|
-
[Kind]: 'Unknown';
|
|
498
|
-
static: unknown;
|
|
499
|
-
}
|
|
500
|
-
export interface UnsafeOptions extends SchemaOptions {
|
|
501
|
-
[Kind]?: string;
|
|
502
|
-
}
|
|
503
|
-
export interface TUnsafe<T> extends TSchema {
|
|
504
|
-
[Kind]: string;
|
|
505
|
-
static: T;
|
|
506
|
-
}
|
|
507
|
-
export interface TVoid extends TSchema {
|
|
508
|
-
[Kind]: 'Void';
|
|
509
|
-
static: void;
|
|
510
|
-
type: 'void';
|
|
511
|
-
}
|
|
512
|
-
/** Creates an decoded static type from a TypeBox type */
|
|
513
|
-
export type StaticDecode<T extends TSchema, P extends unknown[] = []> = Static<DecodeType<T>, P>;
|
|
514
|
-
/** Creates an encoded static type from a TypeBox type */
|
|
515
|
-
export type StaticEncode<T extends TSchema, P extends unknown[] = []> = Static<T, P>;
|
|
516
|
-
/** Creates a static type from a TypeBox type */
|
|
517
|
-
export type Static<T extends TSchema, P extends unknown[] = []> = (T & {
|
|
518
|
-
params: P;
|
|
519
|
-
})['static'];
|
|
520
|
-
export type TypeRegistryValidationFunction<TSchema> = (schema: TSchema, value: unknown) => boolean;
|
|
521
|
-
/** A registry for user defined types */
|
|
522
|
-
export declare namespace TypeRegistry {
|
|
523
|
-
/** Returns the entries in this registry */
|
|
524
|
-
function Entries(): Map<string, TypeRegistryValidationFunction<any>>;
|
|
525
|
-
/** Clears all user defined types */
|
|
526
|
-
function Clear(): void;
|
|
527
|
-
/** Deletes a registered type */
|
|
528
|
-
function Delete(kind: string): boolean;
|
|
529
|
-
/** Returns true if this registry contains this kind */
|
|
530
|
-
function Has(kind: string): boolean;
|
|
531
|
-
/** Sets a validation function for a user defined type */
|
|
532
|
-
function Set<TSchema = unknown>(kind: string, func: TypeRegistryValidationFunction<TSchema>): void;
|
|
533
|
-
/** Gets a custom validation function for a user defined type */
|
|
534
|
-
function Get(kind: string): TypeRegistryValidationFunction<any> | undefined;
|
|
535
|
-
}
|
|
536
|
-
export declare class TypeBoxError extends Error {
|
|
537
|
-
constructor(message: string);
|
|
538
|
-
}
|
|
539
|
-
export type FormatRegistryValidationFunction = (value: string) => boolean;
|
|
540
|
-
/** A registry for user defined string formats */
|
|
541
|
-
export declare namespace FormatRegistry {
|
|
542
|
-
/** Returns the entries in this registry */
|
|
543
|
-
function Entries(): Map<string, FormatRegistryValidationFunction>;
|
|
544
|
-
/** Clears all user defined string formats */
|
|
545
|
-
function Clear(): void;
|
|
546
|
-
/** Deletes a registered format */
|
|
547
|
-
function Delete(format: string): boolean;
|
|
548
|
-
/** Returns true if the user defined string format exists */
|
|
549
|
-
function Has(format: string): boolean;
|
|
550
|
-
/** Sets a validation function for a user defined string format */
|
|
551
|
-
function Set(format: string, func: FormatRegistryValidationFunction): void;
|
|
552
|
-
/** Gets a validation function for a user defined string format */
|
|
553
|
-
function Get(format: string): FormatRegistryValidationFunction | undefined;
|
|
554
|
-
}
|
|
555
|
-
/** Provides functions to type guard raw JavaScript values */
|
|
556
|
-
export declare namespace ValueGuard {
|
|
557
|
-
/** Returns true if this value is an array */
|
|
558
|
-
function IsArray(value: unknown): value is unknown[];
|
|
559
|
-
/** Returns true if this value is bigint */
|
|
560
|
-
function IsBigInt(value: unknown): value is bigint;
|
|
561
|
-
/** Returns true if this value is a boolean */
|
|
562
|
-
function IsBoolean(value: unknown): value is boolean;
|
|
563
|
-
/** Returns true if this value is a Date object */
|
|
564
|
-
function IsDate(value: unknown): value is Date;
|
|
565
|
-
/** Returns true if this value is null */
|
|
566
|
-
function IsNull(value: unknown): value is null;
|
|
567
|
-
/** Returns true if this value is number */
|
|
568
|
-
function IsNumber(value: unknown): value is number;
|
|
569
|
-
/** Returns true if this value is an object */
|
|
570
|
-
function IsObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
571
|
-
/** Returns true if this value is string */
|
|
572
|
-
function IsString(value: unknown): value is string;
|
|
573
|
-
/** Returns true if this value is a Uint8Array */
|
|
574
|
-
function IsUint8Array(value: unknown): value is Uint8Array;
|
|
575
|
-
/** Returns true if this value is undefined */
|
|
576
|
-
function IsUndefined(value: unknown): value is undefined;
|
|
577
|
-
}
|
|
578
|
-
export declare class TypeGuardUnknownTypeError extends TypeBoxError {
|
|
579
|
-
}
|
|
580
|
-
/** Provides functions to test if JavaScript values are TypeBox types */
|
|
581
|
-
export declare namespace TypeGuard {
|
|
582
|
-
/** Returns true if the given value is TAny */
|
|
583
|
-
function TAny(schema: unknown): schema is TAny;
|
|
584
|
-
/** Returns true if the given value is TArray */
|
|
585
|
-
function TArray(schema: unknown): schema is TArray;
|
|
586
|
-
/** Returns true if the given value is TAsyncIterator */
|
|
587
|
-
function TAsyncIterator(schema: unknown): schema is TAsyncIterator;
|
|
588
|
-
/** Returns true if the given value is TBigInt */
|
|
589
|
-
function TBigInt(schema: unknown): schema is TBigInt;
|
|
590
|
-
/** Returns true if the given value is TBoolean */
|
|
591
|
-
function TBoolean(schema: unknown): schema is TBoolean;
|
|
592
|
-
/** Returns true if the given value is TConstructor */
|
|
593
|
-
function TConstructor(schema: unknown): schema is TConstructor;
|
|
594
|
-
/** Returns true if the given value is TDate */
|
|
595
|
-
function TDate(schema: unknown): schema is TDate;
|
|
596
|
-
/** Returns true if the given value is TFunction */
|
|
597
|
-
function TFunction(schema: unknown): schema is TFunction;
|
|
598
|
-
/** Returns true if the given value is TInteger */
|
|
599
|
-
function TInteger(schema: unknown): schema is TInteger;
|
|
600
|
-
/** Returns true if the given value is TIntersect */
|
|
601
|
-
function TIntersect(schema: unknown): schema is TIntersect;
|
|
602
|
-
/** Returns true if the given value is TIterator */
|
|
603
|
-
function TIterator(schema: unknown): schema is TIterator;
|
|
604
|
-
/** Returns true if the given value is a TKind with the given name. */
|
|
605
|
-
function TKindOf<T extends string>(schema: unknown, kind: T): schema is Record<PropertyKey, unknown> & {
|
|
606
|
-
[Kind]: T;
|
|
607
|
-
};
|
|
608
|
-
/** Returns true if the given value is TKind */
|
|
609
|
-
function TKind(schema: unknown): schema is Record<PropertyKey, unknown> & {
|
|
610
|
-
[Kind]: string;
|
|
611
|
-
};
|
|
612
|
-
/** Returns true if the given value is TLiteral<string> */
|
|
613
|
-
function TLiteralString(schema: unknown): schema is TLiteral<string>;
|
|
614
|
-
/** Returns true if the given value is TLiteral<number> */
|
|
615
|
-
function TLiteralNumber(schema: unknown): schema is TLiteral<number>;
|
|
616
|
-
/** Returns true if the given value is TLiteral<boolean> */
|
|
617
|
-
function TLiteralBoolean(schema: unknown): schema is TLiteral<boolean>;
|
|
618
|
-
/** Returns true if the given value is TLiteral */
|
|
619
|
-
function TLiteral(schema: unknown): schema is TLiteral;
|
|
620
|
-
/** Returns true if the given value is TNever */
|
|
621
|
-
function TNever(schema: unknown): schema is TNever;
|
|
622
|
-
/** Returns true if the given value is TNot */
|
|
623
|
-
function TNot(schema: unknown): schema is TNot;
|
|
624
|
-
/** Returns true if the given value is TNull */
|
|
625
|
-
function TNull(schema: unknown): schema is TNull;
|
|
626
|
-
/** Returns true if the given value is TNumber */
|
|
627
|
-
function TNumber(schema: unknown): schema is TNumber;
|
|
628
|
-
/** Returns true if the given value is TObject */
|
|
629
|
-
function TObject(schema: unknown): schema is TObject;
|
|
630
|
-
/** Returns true if the given value is TPromise */
|
|
631
|
-
function TPromise(schema: unknown): schema is TPromise;
|
|
632
|
-
/** Returns true if the given value is TRecord */
|
|
633
|
-
function TRecord(schema: unknown): schema is TRecord;
|
|
634
|
-
/** Returns true if this value is TRecursive */
|
|
635
|
-
function TRecursive(schema: unknown): schema is {
|
|
636
|
-
[Hint]: 'Recursive';
|
|
637
|
-
};
|
|
638
|
-
/** Returns true if the given value is TRef */
|
|
639
|
-
function TRef(schema: unknown): schema is TRef;
|
|
640
|
-
/** Returns true if the given value is TString */
|
|
641
|
-
function TString(schema: unknown): schema is TString;
|
|
642
|
-
/** Returns true if the given value is TSymbol */
|
|
643
|
-
function TSymbol(schema: unknown): schema is TSymbol;
|
|
644
|
-
/** Returns true if the given value is TTemplateLiteral */
|
|
645
|
-
function TTemplateLiteral(schema: unknown): schema is TTemplateLiteral;
|
|
646
|
-
/** Returns true if the given value is TThis */
|
|
647
|
-
function TThis(schema: unknown): schema is TThis;
|
|
648
|
-
/** Returns true of this value is TTransform */
|
|
649
|
-
function TTransform(schema: unknown): schema is {
|
|
650
|
-
[Transform]: TransformOptions;
|
|
651
|
-
};
|
|
652
|
-
/** Returns true if the given value is TTuple */
|
|
653
|
-
function TTuple(schema: unknown): schema is TTuple;
|
|
654
|
-
/** Returns true if the given value is TUndefined */
|
|
655
|
-
function TUndefined(schema: unknown): schema is TUndefined;
|
|
656
|
-
/** Returns true if the given value is TUnion<Literal<string | number>[]> */
|
|
657
|
-
function TUnionLiteral(schema: unknown): schema is TUnion<TLiteral[]>;
|
|
658
|
-
/** Returns true if the given value is TUnion */
|
|
659
|
-
function TUnion(schema: unknown): schema is TUnion;
|
|
660
|
-
/** Returns true if the given value is TUint8Array */
|
|
661
|
-
function TUint8Array(schema: unknown): schema is TUint8Array;
|
|
662
|
-
/** Returns true if the given value is TUnknown */
|
|
663
|
-
function TUnknown(schema: unknown): schema is TUnknown;
|
|
664
|
-
/** Returns true if the given value is a raw TUnsafe */
|
|
665
|
-
function TUnsafe(schema: unknown): schema is TUnsafe<unknown>;
|
|
666
|
-
/** Returns true if the given value is TVoid */
|
|
667
|
-
function TVoid(schema: unknown): schema is TVoid;
|
|
668
|
-
/** Returns true if this value has a Readonly symbol */
|
|
669
|
-
function TReadonly<T extends TSchema>(schema: T): schema is TReadonly<T>;
|
|
670
|
-
/** Returns true if this value has a Optional symbol */
|
|
671
|
-
function TOptional<T extends TSchema>(schema: T): schema is TOptional<T>;
|
|
672
|
-
/** Returns true if the given value is TSchema */
|
|
673
|
-
function TSchema(schema: unknown): schema is TSchema;
|
|
674
|
-
}
|
|
675
|
-
/** Fast undefined check used for properties of type undefined */
|
|
676
|
-
export declare namespace ExtendsUndefined {
|
|
677
|
-
function Check(schema: TSchema): boolean;
|
|
678
|
-
}
|
|
679
|
-
export declare class TypeExtendsError extends TypeBoxError {
|
|
680
|
-
}
|
|
681
|
-
export declare enum TypeExtendsResult {
|
|
682
|
-
Union = 0,
|
|
683
|
-
True = 1,
|
|
684
|
-
False = 2
|
|
685
|
-
}
|
|
686
|
-
export declare namespace TypeExtends {
|
|
687
|
-
function Extends(left: TSchema, right: TSchema): TypeExtendsResult;
|
|
688
|
-
}
|
|
689
|
-
/** Specialized Clone for Types */
|
|
690
|
-
export declare namespace TypeClone {
|
|
691
|
-
/** Clones a Rest */
|
|
692
|
-
function Rest<T extends TSchema[]>(schemas: [...T]): T;
|
|
693
|
-
/** Clones a Type */
|
|
694
|
-
function Type<T extends TSchema>(schema: T, options?: SchemaOptions): T;
|
|
695
|
-
}
|
|
696
|
-
export declare namespace IndexedAccessor {
|
|
697
|
-
function Resolve(schema: TSchema, keys: TPropertyKey[], options?: SchemaOptions): TSchema;
|
|
698
|
-
}
|
|
699
|
-
export declare namespace Intrinsic {
|
|
700
|
-
/** Applies an intrinsic string manipulation to the given type. */
|
|
701
|
-
function Map<T extends TSchema, M extends TIntrinsicMode>(schema: T, mode: M): TIntrinsic<T, M>;
|
|
702
|
-
}
|
|
703
|
-
export declare namespace ObjectMap {
|
|
704
|
-
function Map<T = TSchema>(schema: TSchema, callback: (object: TObject) => TObject, options: SchemaOptions): T;
|
|
705
|
-
}
|
|
706
|
-
export interface KeyResolverOptions {
|
|
707
|
-
includePatterns: boolean;
|
|
708
|
-
}
|
|
709
|
-
export declare namespace KeyResolver {
|
|
710
|
-
/** Resolves an array of keys in this schema */
|
|
711
|
-
function ResolveKeys(schema: TSchema, options: KeyResolverOptions): string[];
|
|
712
|
-
/** Resolves a regular expression pattern matching all keys in this schema */
|
|
713
|
-
function ResolvePattern(schema: TSchema): string;
|
|
714
|
-
}
|
|
715
|
-
export declare class KeyArrayResolverError extends TypeBoxError {
|
|
716
|
-
}
|
|
717
|
-
export declare namespace KeyArrayResolver {
|
|
718
|
-
/** Resolves an array of string[] keys from the given schema or array type. */
|
|
719
|
-
function Resolve(schema: TSchema | string[]): string[];
|
|
720
|
-
}
|
|
721
|
-
export declare namespace UnionResolver {
|
|
722
|
-
/** Returns a resolved union with interior unions flattened */
|
|
723
|
-
function Resolve(union: TUnion): TUnion;
|
|
724
|
-
}
|
|
725
|
-
export declare class TemplateLiteralPatternError extends TypeBoxError {
|
|
726
|
-
}
|
|
727
|
-
export declare namespace TemplateLiteralPattern {
|
|
728
|
-
function Create(kinds: TTemplateLiteralKind[]): string;
|
|
729
|
-
}
|
|
730
|
-
export declare namespace TemplateLiteralResolver {
|
|
731
|
-
/** Resolves a template literal as a TUnion */
|
|
732
|
-
function Resolve(template: TTemplateLiteral): TString | TUnion | TLiteral;
|
|
733
|
-
}
|
|
734
|
-
export declare class TemplateLiteralParserError extends TypeBoxError {
|
|
735
|
-
}
|
|
736
|
-
export declare namespace TemplateLiteralParser {
|
|
737
|
-
type Expression = And | Or | Const;
|
|
738
|
-
type Const = {
|
|
739
|
-
type: 'const';
|
|
740
|
-
const: string;
|
|
741
|
-
};
|
|
742
|
-
type And = {
|
|
743
|
-
type: 'and';
|
|
744
|
-
expr: Expression[];
|
|
745
|
-
};
|
|
746
|
-
type Or = {
|
|
747
|
-
type: 'or';
|
|
748
|
-
expr: Expression[];
|
|
749
|
-
};
|
|
750
|
-
/** Parses a pattern and returns an expression tree */
|
|
751
|
-
function Parse(pattern: string): Expression;
|
|
752
|
-
/** Parses a pattern and strips forward and trailing ^ and $ */
|
|
753
|
-
function ParseExact(pattern: string): Expression;
|
|
754
|
-
}
|
|
755
|
-
export declare class TemplateLiteralFiniteError extends TypeBoxError {
|
|
756
|
-
}
|
|
757
|
-
export declare namespace TemplateLiteralFinite {
|
|
758
|
-
function Check(expression: TemplateLiteralParser.Expression): boolean;
|
|
759
|
-
}
|
|
760
|
-
export declare class TemplateLiteralGeneratorError extends TypeBoxError {
|
|
761
|
-
}
|
|
762
|
-
export declare namespace TemplateLiteralGenerator {
|
|
763
|
-
function Generate(expression: TemplateLiteralParser.Expression): IterableIterator<string>;
|
|
764
|
-
}
|
|
765
|
-
export declare namespace TemplateLiteralDslParser {
|
|
766
|
-
function Parse(template_dsl: string): TTemplateLiteralKind[];
|
|
767
|
-
}
|
|
768
|
-
export declare class TransformDecodeBuilder<T extends TSchema> {
|
|
769
|
-
private readonly schema;
|
|
770
|
-
constructor(schema: T);
|
|
771
|
-
Decode<U extends unknown, D extends TransformFunction<StaticDecode<T>, U>>(decode: D): TransformEncodeBuilder<T, D>;
|
|
772
|
-
}
|
|
773
|
-
export declare class TransformEncodeBuilder<T extends TSchema, D extends TransformFunction> {
|
|
774
|
-
private readonly schema;
|
|
775
|
-
private readonly decode;
|
|
776
|
-
constructor(schema: T, decode: D);
|
|
777
|
-
Encode<E extends TransformFunction<ReturnType<D>, StaticDecode<T>>>(encode: E): TTransform<T, ReturnType<D>>;
|
|
778
|
-
}
|
|
779
|
-
export declare class TypeBuilderError extends TypeBoxError {
|
|
780
|
-
}
|
|
781
|
-
export declare class TypeBuilder {
|
|
782
|
-
/** `[Internal]` Creates a schema without `static` and `params` types */
|
|
783
|
-
protected Create<T>(schema: Omit<T, 'static' | 'params'>): T;
|
|
784
|
-
/** `[Internal]` Throws a TypeBuilder error with the given message */
|
|
785
|
-
protected Throw(message: string): never;
|
|
786
|
-
/** `[Internal]` Discards property keys from the given record type */
|
|
787
|
-
protected Discard(record: Record<PropertyKey, any>, keys: PropertyKey[]): any;
|
|
788
|
-
/** `[Json]` Omits compositing symbols from this schema */
|
|
789
|
-
Strict<T extends TSchema>(schema: T): T;
|
|
790
|
-
}
|
|
791
|
-
export declare class JsonTypeBuilder extends TypeBuilder {
|
|
792
|
-
/** `[Json]` Creates a Readonly and Optional property */
|
|
793
|
-
ReadonlyOptional<T extends TSchema>(schema: T): TReadonly<TOptional<T>>;
|
|
794
|
-
/** `[Json]` Creates a Readonly property */
|
|
795
|
-
Readonly<T extends TSchema>(schema: T): TReadonly<T>;
|
|
796
|
-
/** `[Json]` Creates an Optional property */
|
|
797
|
-
Optional<T extends TSchema>(schema: T): TOptional<T>;
|
|
798
|
-
/** `[Json]` Creates an Any type */
|
|
799
|
-
Any(options?: SchemaOptions): TAny;
|
|
800
|
-
/** `[Json]` Creates an Array type */
|
|
801
|
-
Array<T extends TSchema>(schema: T, options?: ArrayOptions): TArray<T>;
|
|
802
|
-
/** `[Json]` Creates a Boolean type */
|
|
803
|
-
Boolean(options?: SchemaOptions): TBoolean;
|
|
804
|
-
/** `[Json]` Intrinsic function to Capitalize LiteralString types */
|
|
805
|
-
Capitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, 'Capitalize'>;
|
|
806
|
-
/** `[Json]` Creates a Composite object type */
|
|
807
|
-
Composite<T extends TObject[]>(objects: [...T], options?: ObjectOptions): TComposite<T>;
|
|
808
|
-
/** `[Json]` Creates a Enum type */
|
|
809
|
-
Enum<V extends TEnumValue, T extends Record<TEnumKey, V>>(item: T, options?: SchemaOptions): TEnum<T>;
|
|
810
|
-
/** `[Json]` Creates a Conditional type */
|
|
811
|
-
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>;
|
|
812
|
-
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
813
|
-
Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
814
|
-
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
815
|
-
Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
816
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
817
|
-
Index<T extends TArray, K extends TNumber>(schema: T, keys: K, options?: SchemaOptions): AssertType<T['items']>;
|
|
818
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
819
|
-
Index<T extends TTuple, K extends (keyof Static<T>)[]>(schema: T, keys: [...K], options?: SchemaOptions): TIndex<T, Assert<K, TPropertyKey[]>>;
|
|
820
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
821
|
-
Index<T extends TTuple, K extends TNumber>(schema: T, keys: K, options?: SchemaOptions): UnionType<AssertRest<T['items']>>;
|
|
822
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
823
|
-
Index<T extends TSchema, K extends TTemplateLiteral>(schema: T, keys: K, options?: SchemaOptions): TIndex<T, TTemplateLiteralKeyRest<K>>;
|
|
824
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
825
|
-
Index<T extends TSchema, K extends TLiteral<TPropertyKey>>(schema: T, keys: K, options?: SchemaOptions): TIndex<T, [K['const']]>;
|
|
826
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
827
|
-
Index<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: [...K], options?: SchemaOptions): TIndex<T, Assert<K, TPropertyKey[]>>;
|
|
828
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
829
|
-
Index<T extends TSchema, K extends TUnion<TLiteral<TPropertyKey>[]>>(schema: T, keys: K, options?: SchemaOptions): TIndex<T, TUnionLiteralKeyRest<K>>;
|
|
830
|
-
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
831
|
-
Index<T extends TSchema, K extends TSchema>(schema: T, key: K, options?: SchemaOptions): TSchema;
|
|
832
|
-
/** `[Json]` Creates an Integer type */
|
|
833
|
-
Integer(options?: NumericOptions<number>): TInteger;
|
|
834
|
-
/** `[Json]` Creates an Intersect type */
|
|
835
|
-
Intersect(allOf: [], options?: SchemaOptions): TNever;
|
|
836
|
-
/** `[Json]` Creates an Intersect type */
|
|
837
|
-
Intersect<T extends [TSchema]>(allOf: [...T], options?: SchemaOptions): T[0];
|
|
838
|
-
/** `[Json]` Creates an Intersect type */
|
|
839
|
-
Intersect<T extends TSchema[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>;
|
|
840
|
-
/** `[Json]` Creates a KeyOf type */
|
|
841
|
-
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
842
|
-
/** `[Json]` Creates a Literal type */
|
|
843
|
-
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
844
|
-
/** `[Json]` Intrinsic function to Lowercase LiteralString types */
|
|
845
|
-
Lowercase<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, 'Lowercase'>;
|
|
846
|
-
/** `[Json]` Creates a Never type */
|
|
847
|
-
Never(options?: SchemaOptions): TNever;
|
|
848
|
-
/** `[Json]` Creates a Not type */
|
|
849
|
-
Not<T extends TSchema>(schema: T, options?: SchemaOptions): TNot<T>;
|
|
850
|
-
/** `[Json]` Creates a Null type */
|
|
851
|
-
Null(options?: SchemaOptions): TNull;
|
|
852
|
-
/** `[Json]` Creates a Number type */
|
|
853
|
-
Number(options?: NumericOptions<number>): TNumber;
|
|
854
|
-
/** `[Json]` Creates an Object type */
|
|
855
|
-
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
856
|
-
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
857
|
-
Omit<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TOmit<T, K[number]>;
|
|
858
|
-
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
859
|
-
Omit<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TOmit<T, TUnionLiteralKeyRest<K>[number]>;
|
|
860
|
-
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
861
|
-
Omit<T extends TSchema, K extends TLiteral<string>>(schema: T, key: K, options?: SchemaOptions): TOmit<T, K['const']>;
|
|
862
|
-
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
863
|
-
Omit<T extends TSchema, K extends TTemplateLiteral>(schema: T, key: K, options?: SchemaOptions): TOmit<T, TTemplateLiteralKeyRest<K>[number]>;
|
|
864
|
-
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
865
|
-
Omit<T extends TSchema, K extends TNever>(schema: T, key: K, options?: SchemaOptions): TOmit<T, never>;
|
|
866
|
-
/** `[Json]` Constructs a type where all properties are optional */
|
|
867
|
-
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
868
|
-
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
869
|
-
Pick<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TPick<T, K[number]>;
|
|
870
|
-
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
871
|
-
Pick<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TPick<T, TUnionLiteralKeyRest<K>[number]>;
|
|
872
|
-
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
873
|
-
Pick<T extends TSchema, K extends TLiteral<string>>(schema: T, key: K, options?: SchemaOptions): TPick<T, K['const']>;
|
|
874
|
-
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
875
|
-
Pick<T extends TSchema, K extends TTemplateLiteral>(schema: T, key: K, options?: SchemaOptions): TPick<T, TTemplateLiteralKeyRest<K>[number]>;
|
|
876
|
-
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
877
|
-
Pick<T extends TSchema, K extends TNever>(schema: T, key: K, options?: SchemaOptions): TPick<T, never>;
|
|
878
|
-
/** `[Json]` Creates a Record type */
|
|
879
|
-
Record<K extends TSchema, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecordResolve<K, T>;
|
|
880
|
-
/** `[Json]` Creates a Recursive type */
|
|
881
|
-
Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
|
|
882
|
-
/** `[Json]` Creates a Ref type. The referenced type must contain a $id */
|
|
883
|
-
Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>;
|
|
884
|
-
/** `[Json]` Creates a Ref type. */
|
|
885
|
-
Ref<T extends TSchema>($ref: string, options?: SchemaOptions): TRef<T>;
|
|
886
|
-
/** `[Json]` Constructs a type where all properties are required */
|
|
887
|
-
Required<T extends TSchema>(schema: T, options?: SchemaOptions): TRequired<T>;
|
|
888
|
-
/** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
|
|
889
|
-
Rest<T extends TSchema>(schema: T): TRest<T>;
|
|
890
|
-
/** `[Json]` Creates a String type */
|
|
891
|
-
String(options?: StringOptions): TString;
|
|
892
|
-
/** `[Json]` Creates a TemplateLiteral type from template dsl string */
|
|
893
|
-
TemplateLiteral<T extends string>(templateDsl: T, options?: SchemaOptions): TTemplateLiteralDslParser<T>;
|
|
894
|
-
/** `[Json]` Creates a TemplateLiteral type */
|
|
895
|
-
TemplateLiteral<T extends TTemplateLiteralKind[]>(kinds: [...T], options?: SchemaOptions): TTemplateLiteral<T>;
|
|
896
|
-
/** `[Json]` Creates a Transform type */
|
|
897
|
-
Transform<I extends TSchema>(schema: I): TransformDecodeBuilder<I>;
|
|
898
|
-
/** `[Json]` Creates a Tuple type */
|
|
899
|
-
Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
900
|
-
/** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
|
|
901
|
-
Uncapitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, 'Uncapitalize'>;
|
|
902
|
-
/** `[Json]` Creates a Union type */
|
|
903
|
-
Union(anyOf: [], options?: SchemaOptions): TNever;
|
|
904
|
-
/** `[Json]` Creates a Union type */
|
|
905
|
-
Union<T extends [TSchema]>(anyOf: [...T], options?: SchemaOptions): T[0];
|
|
906
|
-
/** `[Json]` Creates a Union type */
|
|
907
|
-
Union<T extends TSchema[]>(anyOf: [...T], options?: SchemaOptions): TUnion<T>;
|
|
908
|
-
/** `[Json-Experimental]` Converts a TemplateLiteral into a Union */
|
|
909
|
-
Union<T extends TTemplateLiteral>(template: T): TUnionTemplateLiteral<T>;
|
|
910
|
-
/** `[Json]` Creates an Unknown type */
|
|
911
|
-
Unknown(options?: SchemaOptions): TUnknown;
|
|
912
|
-
/** `[Json]` Creates a Unsafe type that will infers as the generic argument T */
|
|
913
|
-
Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
|
|
914
|
-
/** `[Json]` Intrinsic function to Uppercase LiteralString types */
|
|
915
|
-
Uppercase<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, 'Uppercase'>;
|
|
916
|
-
}
|
|
917
|
-
export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
918
|
-
/** `[JavaScript]` Creates a AsyncIterator type */
|
|
919
|
-
AsyncIterator<T extends TSchema>(items: T, options?: SchemaOptions): TAsyncIterator<T>;
|
|
920
|
-
/** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
|
|
921
|
-
Awaited<T extends TSchema>(schema: T, options?: SchemaOptions): TAwaited<T>;
|
|
922
|
-
/** `[JavaScript]` Creates a BigInt type */
|
|
923
|
-
BigInt(options?: NumericOptions<bigint>): TBigInt;
|
|
924
|
-
/** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
|
|
925
|
-
ConstructorParameters<T extends TConstructor<TSchema[], TSchema>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
|
|
926
|
-
/** `[JavaScript]` Creates a Constructor type */
|
|
927
|
-
Constructor<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TConstructor<T, U>;
|
|
928
|
-
/** `[JavaScript]` Creates a Date type */
|
|
929
|
-
Date(options?: DateOptions): TDate;
|
|
930
|
-
/** `[JavaScript]` Creates a Function type */
|
|
931
|
-
Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
|
|
932
|
-
/** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
|
|
933
|
-
InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
|
|
934
|
-
/** `[JavaScript]` Creates an Iterator type */
|
|
935
|
-
Iterator<T extends TSchema>(items: T, options?: SchemaOptions): TIterator<T>;
|
|
936
|
-
/** `[JavaScript]` Extracts the Parameters from the given Function type */
|
|
937
|
-
Parameters<T extends TFunction<TSchema[], TSchema>>(schema: T, options?: SchemaOptions): TParameters<T>;
|
|
938
|
-
/** `[JavaScript]` Creates a Promise type */
|
|
939
|
-
Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
|
|
940
|
-
/** `[JavaScript]` Creates a String type from a Regular Expression pattern */
|
|
941
|
-
RegExp(pattern: string, options?: SchemaOptions): TString;
|
|
942
|
-
/** `[JavaScript]` Creates a String type from a Regular Expression */
|
|
943
|
-
RegExp(regex: RegExp, options?: SchemaOptions): TString;
|
|
944
|
-
/**
|
|
945
|
-
* @deprecated Use `Type.RegExp`
|
|
946
|
-
*/
|
|
947
|
-
RegEx(regex: RegExp, options?: SchemaOptions): TString;
|
|
948
|
-
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
949
|
-
ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
|
|
950
|
-
/** `[JavaScript]` Creates a Symbol type */
|
|
951
|
-
Symbol(options?: SchemaOptions): TSymbol;
|
|
952
|
-
/** `[JavaScript]` Creates a Undefined type */
|
|
953
|
-
Undefined(options?: SchemaOptions): TUndefined;
|
|
954
|
-
/** `[JavaScript]` Creates a Uint8Array type */
|
|
955
|
-
Uint8Array(options?: Uint8ArrayOptions): TUint8Array;
|
|
956
|
-
/** `[JavaScript]` Creates a Void type */
|
|
957
|
-
Void(options?: SchemaOptions): TVoid;
|
|
958
|
-
}
|
|
959
|
-
/** Json Type Builder with Static Resolution for TypeScript */
|
|
960
|
-
export declare const JsonType: JsonTypeBuilder;
|
|
961
|
-
/** JavaScript Type Builder with Static Resolution for TypeScript */
|
|
962
|
-
export declare const Type: JavaScriptTypeBuilder;
|