@sinclair/typebox 0.32.33 → 0.32.34
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/build/cjs/errors/errors.js +2 -2
- package/build/cjs/errors/function.js +3 -4
- package/build/cjs/type/any/any.js +1 -2
- package/build/cjs/type/array/array.js +1 -2
- package/build/cjs/type/async-iterator/async-iterator.js +1 -2
- package/build/cjs/type/awaited/awaited.js +1 -2
- package/build/cjs/type/bigint/bigint.js +1 -2
- package/build/cjs/type/boolean/boolean.js +1 -2
- package/build/cjs/type/clone/type.js +2 -3
- package/build/cjs/type/clone/value.js +1 -2
- package/build/cjs/type/composite/composite.js +1 -2
- package/build/cjs/type/const/const.js +1 -2
- package/build/cjs/type/constructor/constructor.js +1 -2
- package/build/cjs/type/constructor-parameters/constructor-parameters.js +1 -2
- package/build/cjs/type/date/date.js +1 -2
- package/build/cjs/type/deref/deref.js +1 -2
- package/build/cjs/type/discard/discard.js +1 -2
- package/build/cjs/type/enum/enum.js +1 -2
- package/build/cjs/type/exclude/exclude-from-mapped-result.js +1 -2
- package/build/cjs/type/exclude/exclude-from-template-literal.js +1 -2
- package/build/cjs/type/exclude/exclude.js +1 -2
- package/build/cjs/type/extends/extends-check.js +2 -2
- package/build/cjs/type/extends/extends-from-mapped-key.js +1 -2
- package/build/cjs/type/extends/extends-from-mapped-result.js +1 -2
- package/build/cjs/type/extends/extends-undefined.js +1 -2
- package/build/cjs/type/extends/extends.js +1 -2
- package/build/cjs/type/extract/extract-from-mapped-result.js +1 -2
- package/build/cjs/type/extract/extract-from-template-literal.js +1 -2
- package/build/cjs/type/extract/extract.js +1 -2
- package/build/cjs/type/function/function.js +1 -2
- package/build/cjs/type/guard/kind.js +45 -46
- package/build/cjs/type/guard/type.js +48 -48
- package/build/cjs/type/guard/value.js +15 -16
- package/build/cjs/type/helpers/helpers.js +1 -2
- package/build/cjs/type/indexed/indexed-from-mapped-key.js +1 -2
- package/build/cjs/type/indexed/indexed-from-mapped-result.js +1 -2
- package/build/cjs/type/indexed/indexed-property-keys.js +1 -2
- package/build/cjs/type/indexed/indexed.js +3 -4
- package/build/cjs/type/instance-type/instance-type.js +1 -2
- package/build/cjs/type/integer/integer.js +1 -2
- package/build/cjs/type/intersect/intersect-create.js +1 -2
- package/build/cjs/type/intersect/intersect-evaluated.js +1 -2
- package/build/cjs/type/intersect/intersect.js +1 -2
- package/build/cjs/type/intrinsic/capitalize.js +1 -2
- package/build/cjs/type/intrinsic/intrinsic-from-mapped-key.js +1 -2
- package/build/cjs/type/intrinsic/intrinsic.js +1 -2
- package/build/cjs/type/intrinsic/lowercase.js +1 -2
- package/build/cjs/type/intrinsic/uncapitalize.js +1 -2
- package/build/cjs/type/intrinsic/uppercase.js +1 -2
- package/build/cjs/type/iterator/iterator.js +1 -2
- package/build/cjs/type/keyof/keyof-from-mapped-result.js +1 -2
- package/build/cjs/type/keyof/keyof-property-entries.js +1 -2
- package/build/cjs/type/keyof/keyof-property-keys.js +2 -3
- package/build/cjs/type/keyof/keyof.js +2 -3
- package/build/cjs/type/literal/literal.js +1 -2
- package/build/cjs/type/mapped/mapped-key.js +1 -2
- package/build/cjs/type/mapped/mapped-result.js +1 -2
- package/build/cjs/type/mapped/mapped.js +2 -3
- package/build/cjs/type/never/never.js +1 -2
- package/build/cjs/type/not/not.js +1 -2
- package/build/cjs/type/null/null.js +1 -2
- package/build/cjs/type/number/number.js +1 -2
- package/build/cjs/type/omit/omit-from-mapped-key.js +1 -2
- package/build/cjs/type/omit/omit-from-mapped-result.js +1 -2
- package/build/cjs/type/omit/omit.js +1 -2
- package/build/cjs/type/optional/optional-from-mapped-result.js +1 -2
- package/build/cjs/type/optional/optional.js +1 -2
- package/build/cjs/type/parameters/parameters.js +1 -2
- package/build/cjs/type/partial/partial-from-mapped-result.js +1 -2
- package/build/cjs/type/partial/partial.js +1 -2
- package/build/cjs/type/pick/pick-from-mapped-key.js +1 -2
- package/build/cjs/type/pick/pick-from-mapped-result.js +1 -2
- package/build/cjs/type/pick/pick.d.ts +2 -2
- package/build/cjs/type/pick/pick.js +1 -2
- package/build/cjs/type/promise/promise.js +1 -2
- package/build/cjs/type/readonly/readonly-from-mapped-result.js +1 -2
- package/build/cjs/type/readonly/readonly.js +1 -2
- package/build/cjs/type/readonly-optional/readonly-optional.js +1 -2
- package/build/cjs/type/record/record.js +1 -2
- package/build/cjs/type/recursive/recursive.js +1 -2
- package/build/cjs/type/ref/ref.js +1 -2
- package/build/cjs/type/regexp/regexp.js +1 -2
- package/build/cjs/type/registry/format.js +6 -7
- package/build/cjs/type/registry/type.js +6 -7
- package/build/cjs/type/required/required-from-mapped-result.js +1 -2
- package/build/cjs/type/required/required.js +1 -2
- package/build/cjs/type/rest/rest.js +1 -2
- package/build/cjs/type/return-type/return-type.js +1 -2
- package/build/cjs/type/sets/set.js +8 -9
- package/build/cjs/type/strict/strict.js +1 -2
- package/build/cjs/type/string/string.js +1 -2
- package/build/cjs/type/symbol/symbol.js +1 -2
- package/build/cjs/type/template-literal/finite.js +3 -3
- package/build/cjs/type/template-literal/generate.d.ts +1 -1
- package/build/cjs/type/template-literal/generate.js +3 -3
- package/build/cjs/type/template-literal/parse.js +3 -3
- package/build/cjs/type/template-literal/pattern.js +2 -2
- package/build/cjs/type/template-literal/syntax.js +1 -2
- package/build/cjs/type/template-literal/template-literal.js +1 -2
- package/build/cjs/type/template-literal/union.js +1 -2
- package/build/cjs/type/transform/transform.js +2 -2
- package/build/cjs/type/tuple/tuple.js +1 -2
- package/build/cjs/type/type/index.d.ts +1 -1
- package/build/cjs/type/uint8array/uint8array.js +1 -2
- package/build/cjs/type/undefined/undefined.js +1 -2
- package/build/cjs/type/union/union-create.js +1 -2
- package/build/cjs/type/union/union-evaluated.js +1 -2
- package/build/cjs/type/union/union.js +1 -2
- package/build/cjs/type/unknown/unknown.js +1 -2
- package/build/cjs/type/unsafe/unsafe.js +1 -2
- package/build/cjs/type/void/void.js +1 -2
- package/build/cjs/value/cast/cast.js +2 -2
- package/build/cjs/value/check/check.js +2 -2
- package/build/cjs/value/clean/clean.js +1 -2
- package/build/cjs/value/clone/clone.js +1 -2
- package/build/cjs/value/convert/convert.js +1 -2
- package/build/cjs/value/create/create.js +2 -2
- package/build/cjs/value/default/default.js +1 -2
- package/build/cjs/value/delta/delta.js +3 -3
- package/build/cjs/value/deref/deref.js +2 -2
- package/build/cjs/value/equal/equal.js +1 -2
- package/build/cjs/value/guard/guard.js +34 -35
- package/build/cjs/value/hash/hash.js +2 -2
- package/build/cjs/value/mutate/mutate.js +2 -2
- package/build/cjs/value/pointer/pointer.js +6 -6
- package/build/cjs/value/transform/decode.js +2 -2
- package/build/cjs/value/transform/encode.js +2 -2
- package/build/cjs/value/transform/has.js +1 -2
- package/build/cjs/value/value/value.js +15 -16
- package/build/esm/type/pick/pick.d.mts +2 -2
- package/build/esm/type/template-literal/generate.d.mts +1 -1
- package/build/esm/type/type/index.d.mts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.Cast = Cast;
|
|
5
|
+
exports.Create = Create;
|
|
6
|
+
exports.Check = Check;
|
|
7
|
+
exports.Clean = Clean;
|
|
8
|
+
exports.Convert = Convert;
|
|
9
|
+
exports.Clone = Clone;
|
|
10
|
+
exports.Decode = Decode;
|
|
11
|
+
exports.Default = Default;
|
|
12
|
+
exports.Encode = Encode;
|
|
13
|
+
exports.Errors = Errors;
|
|
14
|
+
exports.Equal = Equal;
|
|
15
|
+
exports.Diff = Diff;
|
|
16
|
+
exports.Hash = Hash;
|
|
17
|
+
exports.Patch = Patch;
|
|
18
|
+
exports.Mutate = Mutate;
|
|
5
19
|
const index_1 = require("../transform/index");
|
|
6
20
|
const index_2 = require("../mutate/index");
|
|
7
21
|
const index_3 = require("../hash/index");
|
|
@@ -19,32 +33,26 @@ const index_13 = require("../../errors/index");
|
|
|
19
33
|
function Cast(...args) {
|
|
20
34
|
return index_5.Cast.apply(index_5.Cast, args);
|
|
21
35
|
}
|
|
22
|
-
exports.Cast = Cast;
|
|
23
36
|
/** Creates a value from the given type */
|
|
24
37
|
function Create(...args) {
|
|
25
38
|
return index_8.Create.apply(index_8.Create, args);
|
|
26
39
|
}
|
|
27
|
-
exports.Create = Create;
|
|
28
40
|
/** Returns true if the value matches the given type */
|
|
29
41
|
function Check(...args) {
|
|
30
42
|
return index_10.Check.apply(index_10.Check, args);
|
|
31
43
|
}
|
|
32
|
-
exports.Check = Check;
|
|
33
44
|
/** `[Mutable]` Removes excess properties from a value and returns the result. This function does not check the value and returns an unknown type. You should Check the result before use. Clean is a mutable operation. To avoid mutation, Clone the value first. */
|
|
34
45
|
function Clean(...args) {
|
|
35
46
|
return index_9.Clean.apply(index_9.Clean, args);
|
|
36
47
|
}
|
|
37
|
-
exports.Clean = Clean;
|
|
38
48
|
/** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
|
|
39
49
|
function Convert(...args) {
|
|
40
50
|
return index_7.Convert.apply(index_7.Convert, args);
|
|
41
51
|
}
|
|
42
|
-
exports.Convert = Convert;
|
|
43
52
|
/** Returns a structural clone of the given value */
|
|
44
53
|
function Clone(value) {
|
|
45
54
|
return (0, index_6.Clone)(value);
|
|
46
55
|
}
|
|
47
|
-
exports.Clone = Clone;
|
|
48
56
|
/** Decodes a value or throws if error */
|
|
49
57
|
function Decode(...args) {
|
|
50
58
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
@@ -52,12 +60,10 @@ function Decode(...args) {
|
|
|
52
60
|
throw new index_1.TransformDecodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
53
61
|
return (0, index_1.HasTransform)(schema, references) ? (0, index_1.TransformDecode)(schema, references, value) : value;
|
|
54
62
|
}
|
|
55
|
-
exports.Decode = Decode;
|
|
56
63
|
/** `[Mutable]` Generates missing properties on a value using default schema annotations if available. This function does not check the value and returns an unknown type. You should Check the result before use. Default is a mutable operation. To avoid mutation, Clone the value first. */
|
|
57
64
|
function Default(...args) {
|
|
58
65
|
return index_11.Default.apply(index_11.Default, args);
|
|
59
66
|
}
|
|
60
|
-
exports.Default = Default;
|
|
61
67
|
/** Encodes a value or throws if error */
|
|
62
68
|
function Encode(...args) {
|
|
63
69
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
@@ -66,34 +72,27 @@ function Encode(...args) {
|
|
|
66
72
|
throw new index_1.TransformEncodeCheckError(schema, encoded, Errors(schema, references, encoded).First());
|
|
67
73
|
return encoded;
|
|
68
74
|
}
|
|
69
|
-
exports.Encode = Encode;
|
|
70
75
|
/** Returns an iterator for each error in this value. */
|
|
71
76
|
function Errors(...args) {
|
|
72
77
|
return index_13.Errors.apply(index_13.Errors, args);
|
|
73
78
|
}
|
|
74
|
-
exports.Errors = Errors;
|
|
75
79
|
/** Returns true if left and right values are structurally equal */
|
|
76
80
|
function Equal(left, right) {
|
|
77
81
|
return (0, index_4.Equal)(left, right);
|
|
78
82
|
}
|
|
79
|
-
exports.Equal = Equal;
|
|
80
83
|
/** Returns edits to transform the current value into the next value */
|
|
81
84
|
function Diff(current, next) {
|
|
82
85
|
return (0, index_12.Diff)(current, next);
|
|
83
86
|
}
|
|
84
|
-
exports.Diff = Diff;
|
|
85
87
|
/** Returns a FNV1A-64 non cryptographic hash of the given value */
|
|
86
88
|
function Hash(value) {
|
|
87
89
|
return (0, index_3.Hash)(value);
|
|
88
90
|
}
|
|
89
|
-
exports.Hash = Hash;
|
|
90
91
|
/** Returns a new value with edits applied to the given value */
|
|
91
92
|
function Patch(current, edits) {
|
|
92
93
|
return (0, index_12.Patch)(current, edits);
|
|
93
94
|
}
|
|
94
|
-
exports.Patch = Patch;
|
|
95
95
|
/** `[Mutable]` Performs a deep mutable value assignment while retaining internal references. */
|
|
96
96
|
function Mutate(current, next) {
|
|
97
97
|
(0, index_2.Mutate)(current, next);
|
|
98
98
|
}
|
|
99
|
-
exports.Mutate = Mutate;
|
|
@@ -9,9 +9,9 @@ import { type TIndexPropertyKeys } from '../indexed/index.mjs';
|
|
|
9
9
|
import { type TPickFromMappedKey } from './pick-from-mapped-key.mjs';
|
|
10
10
|
import { type TPickFromMappedResult } from './pick-from-mapped-result.mjs';
|
|
11
11
|
type FromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromIntersect<R, K, [...Acc, TPick<L, K>]> : Acc;
|
|
12
|
-
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K
|
|
12
|
+
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K>;
|
|
13
13
|
type FromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromUnion<R, K, [...Acc, TPick<L, K>]> : Acc;
|
|
14
|
-
declare function FromUnion<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromUnion<T, K
|
|
14
|
+
declare function FromUnion<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromUnion<T, K>;
|
|
15
15
|
type FromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Pick<T, I & keyof T>>;
|
|
16
16
|
declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(T: T, K: K): never;
|
|
17
17
|
export type TPick<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TPick<S, K>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<FromUnion<S, K>> : T extends TObject<infer S> ? TObject<FromProperties<S, K>> : TObject<{}>;
|
|
@@ -13,7 +13,7 @@ type TStringReduceBinary<L extends string[], R extends string[], Acc extends str
|
|
|
13
13
|
type TStringReduceMany<T extends string[][]> = T extends [infer L extends string[], infer R extends string[], ...infer Rest extends string[][]] ? TStringReduceMany<[TStringReduceBinary<L, R>, ...Rest]> : T;
|
|
14
14
|
type TStringReduce<T extends string[][], O = TStringReduceMany<T>> = 0 extends keyof O ? Assert<O[0], string[]> : [];
|
|
15
15
|
type TFromTemplateLiteralUnionKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TLiteral, ...infer R extends TLiteral[]] ? [`${L['const']}`, ...TFromTemplateLiteralUnionKinds<R>] : [];
|
|
16
|
-
type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[], Acc extends TLiteralValue[][] = []> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? (L extends TLiteral<infer S extends TLiteralValue> ? TFromTemplateLiteralKinds<R, [...Acc, [S]]> : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<R, [...Acc, TFromTemplateLiteralUnionKinds<S>]> : L extends TBoolean ? TFromTemplateLiteralKinds<R, [...Acc, ['true', 'false']]> : Acc) : Acc;
|
|
16
|
+
type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[], Acc extends TLiteralValue[][] = []> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? (L extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<[...S, ...R], Acc> : L extends TLiteral<infer S extends TLiteralValue> ? TFromTemplateLiteralKinds<R, [...Acc, [S]]> : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<R, [...Acc, TFromTemplateLiteralUnionKinds<S>]> : L extends TBoolean ? TFromTemplateLiteralKinds<R, [...Acc, ['true', 'false']]> : Acc) : Acc;
|
|
17
17
|
export declare function TemplateLiteralExpressionGenerate(expression: Expression): IterableIterator<string>;
|
|
18
18
|
export type TTemplateLiteralGenerate<T extends TTemplateLiteral, F = TIsTemplateLiteralFinite<T>> = F extends true ? (T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<S> extends infer R extends string[][] ? TStringReduce<R> : [] : []) : [];
|
|
19
19
|
/** Generates a tuple of strings from the given TemplateLiteral. Returns an empty tuple if infinite. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { JsonTypeBuilder } from './json.mjs';
|
|
2
2
|
import { JavaScriptTypeBuilder } from './javascript.mjs';
|
|
3
3
|
/** JavaScript Type Builder with Static Resolution for TypeScript */
|
|
4
|
-
declare const Type: JavaScriptTypeBuilder
|
|
4
|
+
declare const Type: InstanceType<typeof JavaScriptTypeBuilder>;
|
|
5
5
|
export { JavaScriptTypeBuilder };
|
|
6
6
|
export { Type };
|