typesea 0.2.0 → 0.3.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/CHANGELOG.md +40 -0
- package/README.md +104 -41
- package/SECURITY.md +52 -0
- package/dist/aot/index.d.ts +1 -1
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +22 -3
- package/dist/builders/composite.d.ts +6 -3
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +22 -13
- package/dist/builders/index.d.ts +6 -5
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +5 -4
- package/dist/builders/modifier.d.ts +6 -0
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +14 -0
- package/dist/builders/object/guard.d.ts +54 -2
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +117 -7
- package/dist/builders/object/index.d.ts +2 -2
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +1 -1
- package/dist/builders/object/schema.d.ts +33 -2
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +198 -8
- package/dist/builders/object/types.d.ts +15 -0
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/runtime.d.ts +40 -0
- package/dist/builders/runtime.d.ts.map +1 -0
- package/dist/builders/runtime.js +150 -0
- package/dist/builders/scalar.d.ts +20 -1
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +54 -1
- package/dist/builders/table.d.ts +31 -5
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +31 -5
- package/dist/builders/types.d.ts +6 -0
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/compile/check-composite.d.ts +3 -1
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +143 -11
- package/dist/compile/check-scalar.d.ts +10 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +138 -2
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +25 -3
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +2 -0
- package/dist/compile/first.d.ts +26 -0
- package/dist/compile/first.d.ts.map +1 -0
- package/dist/compile/first.js +850 -0
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +389 -18
- package/dist/compile/guard.d.ts +2 -1
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +54 -8
- package/dist/compile/predicate.d.ts.map +1 -1
- package/dist/compile/predicate.js +156 -5
- package/dist/compile/runtime.d.ts +20 -1
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +31 -0
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +27 -3
- package/dist/compile/types.d.ts +2 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/decoder/index.d.ts +60 -0
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +164 -1
- package/dist/evaluate/check-composite.d.ts +52 -2
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +193 -6
- package/dist/evaluate/check-scalar.d.ts +9 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +92 -3
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +19 -4
- package/dist/evaluate/shared.d.ts +19 -0
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +35 -0
- package/dist/guard/array.d.ts +48 -0
- package/dist/guard/array.d.ts.map +1 -0
- package/dist/guard/array.js +84 -0
- package/dist/guard/base.d.ts +32 -2
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +74 -3
- package/dist/guard/date.d.ts +34 -0
- package/dist/guard/date.d.ts.map +1 -0
- package/dist/guard/date.js +60 -0
- package/dist/guard/index.d.ts +2 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- package/dist/guard/number.d.ts +60 -0
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +129 -0
- package/dist/guard/read.d.ts +53 -1
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +102 -0
- package/dist/guard/string.d.ts +82 -0
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +213 -0
- package/dist/guard/types.d.ts +18 -0
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/ir/builder.d.ts +3 -3
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +5 -2
- package/dist/ir/freeze.js +7 -0
- package/dist/ir/types.d.ts +4 -1
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/validate.d.ts.map +1 -1
- package/dist/ir/validate.js +35 -1
- package/dist/issue/index.d.ts +1 -1
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +4 -0
- package/dist/json-schema/emit-composite.d.ts +6 -2
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +66 -12
- package/dist/json-schema/emit-scalar.d.ts.map +1 -1
- package/dist/json-schema/emit-scalar.js +54 -1
- package/dist/json-schema/emit.d.ts.map +1 -1
- package/dist/json-schema/emit.js +11 -2
- package/dist/json-schema/types.d.ts +7 -1
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/kind/index.d.ts +25 -0
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +26 -3
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +52 -3
- package/dist/message/index.d.ts +18 -0
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +67 -0
- package/dist/optimize/domain.js +6 -2
- package/dist/optimize/map-node.d.ts.map +1 -1
- package/dist/optimize/map-node.js +3 -0
- package/dist/plan/cache.js +13 -1
- package/dist/plan/predicate.d.ts.map +1 -1
- package/dist/plan/predicate.js +33 -3
- package/dist/plan/schema-predicate.d.ts.map +1 -1
- package/dist/plan/schema-predicate.js +267 -8
- package/dist/schema/freeze.js +22 -0
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/types.d.ts +89 -4
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +8 -1
- package/dist/schema/undefined.d.ts.map +1 -1
- package/dist/schema/undefined.js +5 -0
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +111 -4
- package/docs/api.md +79 -10
- package/docs/assets/benchmark-headline.svg +33 -33
- package/docs/engine-notes.md +9 -5
- package/docs/index.html +1366 -722
- package/docs/ko/api.md +383 -0
- package/docs/ko/engine-notes.md +156 -0
- package/docs/ko/readme.md +404 -0
- package/package.json +6 -2
|
@@ -31,7 +31,22 @@ export type MergeObjectShapes<TBase extends ObjectShape, TExtension extends Obje
|
|
|
31
31
|
export type PartialObjectShape<TShape extends ObjectShape> = {
|
|
32
32
|
readonly [TKey in keyof TShape]: BaseGuard<GuardValue<TShape[TKey]>, "optional">;
|
|
33
33
|
};
|
|
34
|
+
export type DeepPartialValue<TValue> = TValue extends (infer TItem)[] ? DeepPartialValue<TItem>[] : TValue extends readonly (infer TItem)[] ? readonly DeepPartialValue<TItem>[] : TValue extends object ? {
|
|
35
|
+
readonly [TKey in keyof TValue]?: DeepPartialValue<TValue[TKey]>;
|
|
36
|
+
} : TValue;
|
|
37
|
+
export type DeepPartialObjectShape<TShape extends ObjectShape> = {
|
|
38
|
+
readonly [TKey in keyof TShape]: BaseGuard<DeepPartialValue<GuardValue<TShape[TKey]>>, "optional">;
|
|
39
|
+
};
|
|
40
|
+
export type RequiredObjectShape<TShape extends ObjectShape> = {
|
|
41
|
+
readonly [TKey in keyof TShape]: BaseGuard<GuardValue<TShape[TKey]>>;
|
|
42
|
+
};
|
|
43
|
+
export type ObjectKeyMask<TShape extends ObjectShape> = Partial<Readonly<Record<StringKeyOf<TShape>, true>>>;
|
|
44
|
+
export type MaskSelectedKeys<TShape extends ObjectShape, TMask extends ObjectKeyMask<TShape>> = {
|
|
45
|
+
[TKey in keyof TMask]-?: TMask[TKey] extends true ? TKey : never;
|
|
46
|
+
}[keyof TMask];
|
|
34
47
|
export type PickObjectShape<TShape extends ObjectShape, TKey extends string> = Pick<TShape, Extract<keyof TShape, TKey>>;
|
|
48
|
+
export type PickObjectShapeByMask<TShape extends ObjectShape, TMask extends ObjectKeyMask<TShape>> = Pick<TShape, Extract<keyof TShape, MaskSelectedKeys<TShape, TMask>>>;
|
|
35
49
|
export type OmitObjectShape<TShape extends ObjectShape, TKey extends string> = Omit<TShape, Extract<keyof TShape, TKey>>;
|
|
50
|
+
export type OmitObjectShapeByMask<TShape extends ObjectShape, TMask extends ObjectKeyMask<TShape>> = Omit<TShape, Extract<keyof TShape, MaskSelectedKeys<TShape, TMask>>>;
|
|
36
51
|
export type StringKeyOf<TValue> = Extract<keyof TValue, string>;
|
|
37
52
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/builders/object/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACR,SAAS,EACT,KAAK,EACL,aAAa,EACb,UAAU,EACV,KAAK,EACL,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAE7E,MAAM,MAAM,eAAe,GACrB,OAAO,aAAa,CAAC,WAAW,GAChC,OAAO,aAAa,CAAC,MAAM,CAAC;AAElC,MAAM,MAAM,YAAY,C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MAAM,MAAM,eAAe,CACvB,MAAM,SAAS,WAAW,EAC1B,IAAI,SAAS,MAAM,IACnB,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,CAC7B,MAAM,SAAS,WAAW,EAC1B,KAAK,SAAS,aAAa,CAAC,MAAM,CAAC,IACnC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAEzE,MAAM,MAAM,WAAW,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file runtime.ts
|
|
3
|
+
* @brief Runtime-object guard builders.
|
|
4
|
+
* @details These builders describe JavaScript object domains that JSON Schema
|
|
5
|
+
* and AOT source cannot faithfully serialize.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseGuard, type Guard, type Infer, type Presence } from "../guard/index.js";
|
|
8
|
+
export type InstanceConstructor<TValue> = abstract new (...args: never[]) => TValue;
|
|
9
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
10
|
+
export interface JsonArray {
|
|
11
|
+
readonly length: number;
|
|
12
|
+
readonly [index: number]: JsonValue;
|
|
13
|
+
}
|
|
14
|
+
export interface JsonObject {
|
|
15
|
+
readonly [key: string]: JsonValue;
|
|
16
|
+
}
|
|
17
|
+
export type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
18
|
+
/**
|
|
19
|
+
* @brief Build a guard backed by ordinary instanceof semantics.
|
|
20
|
+
* @param constructor Constructor function used as the instance domain.
|
|
21
|
+
* @returns Fresh guard accepting values whose prototype chain matches constructor.
|
|
22
|
+
* @throws TypeError when constructor is not callable.
|
|
23
|
+
*/
|
|
24
|
+
export declare function instanceOf<TValue>(constructor: InstanceConstructor<TValue>): BaseGuard<TValue>;
|
|
25
|
+
/**
|
|
26
|
+
* @brief Require one own data property after a base guard succeeds.
|
|
27
|
+
* @param base Guard applied to the candidate value first.
|
|
28
|
+
* @param key Own string property key to inspect.
|
|
29
|
+
* @param value Guard applied to the property value.
|
|
30
|
+
* @returns Fresh guard preserving the base domain and recording the property type.
|
|
31
|
+
*/
|
|
32
|
+
export declare function property<TBase extends Guard<unknown, Presence>, const TKey extends string, TValue extends Guard<unknown, Presence>>(base: TBase, key: TKey, value: TValue): BaseGuard<Infer<TBase> & Readonly<Record<TKey, Infer<TValue>>>>;
|
|
33
|
+
/**
|
|
34
|
+
* @brief Build a recursive JSON-value guard.
|
|
35
|
+
* @returns Fresh guard accepting JSON-serializable values.
|
|
36
|
+
* @details The guard accepts finite numbers because TypeSea number semantics
|
|
37
|
+
* reject NaN and infinities. Object values are string-keyed records.
|
|
38
|
+
*/
|
|
39
|
+
export declare function json(): BaseGuard<JsonValue>;
|
|
40
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/builders/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIrF,MAAM,MAAM,mBAAmB,CAAC,MAAM,IAClC,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,MAAM,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED,MAAM,MAAM,SAAS,GACf,aAAa,GACb,SAAS,GACT,UAAU,CAAC;AAEjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAC7B,WAAW,EAAE,mBAAmB,CAAC,MAAM,CAAC,GACzC,SAAS,CAAC,MAAM,CAAC,CAcnB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACpB,KAAK,SAAS,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EACtC,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,MAAM,SAAS,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAEvC,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAUjE;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,IAAI,SAAS,CAAC,SAAS,CAAC,CAU3C"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file runtime.ts
|
|
3
|
+
* @brief Runtime-object guard builders.
|
|
4
|
+
* @details These builders describe JavaScript object domains that JSON Schema
|
|
5
|
+
* and AOT source cannot faithfully serialize.
|
|
6
|
+
*/
|
|
7
|
+
import { SchemaTag } from "../kind/index.js";
|
|
8
|
+
import { BaseGuard } from "../guard/index.js";
|
|
9
|
+
import { readGuardSchema } from "../internal/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* @brief Build a guard backed by ordinary instanceof semantics.
|
|
12
|
+
* @param constructor Constructor function used as the instance domain.
|
|
13
|
+
* @returns Fresh guard accepting values whose prototype chain matches constructor.
|
|
14
|
+
* @throws TypeError when constructor is not callable.
|
|
15
|
+
*/
|
|
16
|
+
export function instanceOf(constructor) {
|
|
17
|
+
const rawConstructor = constructor;
|
|
18
|
+
if (typeof rawConstructor !== "function") {
|
|
19
|
+
throw new TypeError("instanceOf constructor must be a function");
|
|
20
|
+
}
|
|
21
|
+
if (!hasObjectPrototype(rawConstructor)) {
|
|
22
|
+
throw new TypeError("instanceOf constructor must expose an object prototype");
|
|
23
|
+
}
|
|
24
|
+
const ctor = rawConstructor;
|
|
25
|
+
return new BaseGuard({
|
|
26
|
+
tag: SchemaTag.InstanceOf,
|
|
27
|
+
constructor: ctor,
|
|
28
|
+
name: readConstructorName(ctor)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @brief Require one own data property after a base guard succeeds.
|
|
33
|
+
* @param base Guard applied to the candidate value first.
|
|
34
|
+
* @param key Own string property key to inspect.
|
|
35
|
+
* @param value Guard applied to the property value.
|
|
36
|
+
* @returns Fresh guard preserving the base domain and recording the property type.
|
|
37
|
+
*/
|
|
38
|
+
export function property(base, key, value) {
|
|
39
|
+
if (typeof key !== "string") {
|
|
40
|
+
throw new TypeError("property key must be a string");
|
|
41
|
+
}
|
|
42
|
+
return new BaseGuard({
|
|
43
|
+
tag: SchemaTag.Property,
|
|
44
|
+
base: readGuardSchema(base, "property base"),
|
|
45
|
+
key,
|
|
46
|
+
value: readGuardSchema(value, "property value")
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @brief Build a recursive JSON-value guard.
|
|
51
|
+
* @returns Fresh guard accepting JSON-serializable values.
|
|
52
|
+
* @details The guard accepts finite numbers because TypeSea number semantics
|
|
53
|
+
* reject NaN and infinities. Object values are string-keyed records.
|
|
54
|
+
*/
|
|
55
|
+
export function json() {
|
|
56
|
+
let cached;
|
|
57
|
+
const root = new BaseGuard({
|
|
58
|
+
tag: SchemaTag.Lazy,
|
|
59
|
+
get: () => {
|
|
60
|
+
cached ??= makeJsonSchema(root.schema);
|
|
61
|
+
return cached;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return root;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @brief Materialize the recursive JSON schema after the root guard exists.
|
|
68
|
+
* @param root Recursive root schema used by arrays and records.
|
|
69
|
+
* @returns Union schema for every JSON value variant.
|
|
70
|
+
*/
|
|
71
|
+
function makeJsonSchema(root) {
|
|
72
|
+
return {
|
|
73
|
+
tag: SchemaTag.Union,
|
|
74
|
+
options: [
|
|
75
|
+
{
|
|
76
|
+
tag: SchemaTag.String,
|
|
77
|
+
checks: []
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
tag: SchemaTag.Number,
|
|
81
|
+
checks: []
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
tag: SchemaTag.Boolean
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
tag: SchemaTag.Literal,
|
|
88
|
+
value: null
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
tag: SchemaTag.Array,
|
|
92
|
+
item: root,
|
|
93
|
+
checks: []
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
tag: SchemaTag.Refine,
|
|
97
|
+
inner: {
|
|
98
|
+
tag: SchemaTag.Record,
|
|
99
|
+
value: root
|
|
100
|
+
},
|
|
101
|
+
predicate: isJsonObject,
|
|
102
|
+
name: "json_object"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @brief Accept only JSON object containers.
|
|
109
|
+
* @param value Candidate value already checked as a record.
|
|
110
|
+
* @returns True for ordinary or null-prototype objects.
|
|
111
|
+
*/
|
|
112
|
+
function isJsonObject(value) {
|
|
113
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
const prototype = Object.getPrototypeOf(value);
|
|
117
|
+
return prototype === Object.prototype || prototype === null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @brief Read a stable diagnostic name from a constructor function.
|
|
121
|
+
* @param constructor Function supplied to instanceOf.
|
|
122
|
+
* @returns Constructor name or a generic fallback.
|
|
123
|
+
*/
|
|
124
|
+
function readConstructorName(constructor) {
|
|
125
|
+
const descriptor = Object.getOwnPropertyDescriptor(constructor, "name");
|
|
126
|
+
const name = descriptor !== undefined && "value" in descriptor
|
|
127
|
+
? descriptor.value
|
|
128
|
+
: undefined;
|
|
129
|
+
return descriptor !== undefined &&
|
|
130
|
+
"value" in descriptor &&
|
|
131
|
+
typeof name === "string" &&
|
|
132
|
+
name.length !== 0
|
|
133
|
+
? name
|
|
134
|
+
: "constructor";
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @brief Check that a function can participate in ordinary instance checks.
|
|
138
|
+
* @param constructor Function supplied to instanceOf.
|
|
139
|
+
* @returns True when the function exposes an object prototype slot.
|
|
140
|
+
*/
|
|
141
|
+
function hasObjectPrototype(constructor) {
|
|
142
|
+
const descriptor = Object.getOwnPropertyDescriptor(constructor, "prototype");
|
|
143
|
+
if (descriptor === undefined ||
|
|
144
|
+
!("value" in descriptor)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const prototype = descriptor.value;
|
|
148
|
+
return (typeof prototype === "object" && prototype !== null) ||
|
|
149
|
+
typeof prototype === "function";
|
|
150
|
+
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
|
-
import { BaseGuard, NumberGuard, StringGuard } from "../guard/index.js";
|
|
7
|
+
import { BaseGuard, DateGuard, NumberGuard, StringGuard } from "../guard/index.js";
|
|
8
8
|
import type { LiteralValue } from "../schema/index.js";
|
|
9
|
+
export type EnumValues = readonly [string, ...string[]];
|
|
9
10
|
/**
|
|
10
11
|
* @brief Shared string guard singleton.
|
|
11
12
|
* @details Primitive guards are immutable, so exporting one instance avoids
|
|
@@ -30,6 +31,12 @@ export declare const neverGuard: BaseGuard<never, "required">;
|
|
|
30
31
|
* with stable metadata.
|
|
31
32
|
*/
|
|
32
33
|
export declare const numberGuard: NumberGuard<"required">;
|
|
34
|
+
/**
|
|
35
|
+
* @brief Shared valid Date guard singleton.
|
|
36
|
+
* @details Date validation accepts Date objects whose time value is finite.
|
|
37
|
+
* Invalid Date instances are rejected.
|
|
38
|
+
*/
|
|
39
|
+
export declare const dateGuard: DateGuard<"required">;
|
|
33
40
|
/**
|
|
34
41
|
* @brief Shared bigint guard singleton.
|
|
35
42
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
@@ -48,6 +55,9 @@ export declare const symbolGuard: BaseGuard<symbol, "required">;
|
|
|
48
55
|
* with stable metadata.
|
|
49
56
|
*/
|
|
50
57
|
export declare const booleanGuard: BaseGuard<boolean, "required">;
|
|
58
|
+
export declare const nullGuard: BaseGuard<null, "required">;
|
|
59
|
+
export declare const undefinedGuard: BaseGuard<undefined, "required">;
|
|
60
|
+
export declare const voidGuard: BaseGuard<undefined, "required">;
|
|
51
61
|
/**
|
|
52
62
|
* @brief Build a literal guard after rejecting non-literal runtime values.
|
|
53
63
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
@@ -57,4 +67,13 @@ export declare const booleanGuard: BaseGuard<boolean, "required">;
|
|
|
57
67
|
* @throws TypeError when the value cannot be represented as a TypeSea literal.
|
|
58
68
|
*/
|
|
59
69
|
export declare function literal<const TValue extends LiteralValue>(value: TValue): BaseGuard<TValue>;
|
|
70
|
+
/**
|
|
71
|
+
* @brief Build a string literal enum guard.
|
|
72
|
+
* @param values Non-empty tuple of string literals.
|
|
73
|
+
* @returns Fresh guard accepting exactly one supplied enum member.
|
|
74
|
+
* @throws TypeError when values are empty, non-strings, or duplicated.
|
|
75
|
+
* @details The public export is aliased as `enum`; this internal name avoids
|
|
76
|
+
* spelling a reserved word as a local binding.
|
|
77
|
+
*/
|
|
78
|
+
export declare function enumValues<const TValues extends EnumValues>(values: TValues): BaseGuard<TValues[number]>;
|
|
60
79
|
//# sourceMappingURL=scalar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/builders/scalar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACH,SAAS,EACT,WAAW,EACX,WAAW,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/builders/scalar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACH,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,oBAAoB,CAAC;AAG/D,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,WAAW,yBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,gCAEvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,8BAErB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,yBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,uBAGpB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,gCAEvB,CAAC;AAEH,eAAO,MAAM,SAAS,6BAGpB,CAAC;AAEH,eAAO,MAAM,cAAc,kCAGzB,CAAC;AAEH,eAAO,MAAM,SAAS,kCAAiB,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,MAAM,SAAS,YAAY,EACrD,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,MAAM,CAAC,CAYnB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EACvD,MAAM,EAAE,OAAO,GAChB,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CA0B5B"}
|
package/dist/builders/scalar.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
7
|
import { SchemaTag } from "../kind/index.js";
|
|
8
|
-
import { BaseGuard, NumberGuard, StringGuard } from "../guard/index.js";
|
|
8
|
+
import { BaseGuard, DateGuard, NumberGuard, StringGuard } from "../guard/index.js";
|
|
9
9
|
import { isLiteralValue } from "../schema/index.js";
|
|
10
10
|
/**
|
|
11
11
|
* @brief Shared string guard singleton.
|
|
@@ -41,6 +41,15 @@ export const numberGuard = new NumberGuard({
|
|
|
41
41
|
tag: SchemaTag.Number,
|
|
42
42
|
checks: []
|
|
43
43
|
});
|
|
44
|
+
/**
|
|
45
|
+
* @brief Shared valid Date guard singleton.
|
|
46
|
+
* @details Date validation accepts Date objects whose time value is finite.
|
|
47
|
+
* Invalid Date instances are rejected.
|
|
48
|
+
*/
|
|
49
|
+
export const dateGuard = new DateGuard({
|
|
50
|
+
tag: SchemaTag.Date,
|
|
51
|
+
checks: []
|
|
52
|
+
});
|
|
44
53
|
/**
|
|
45
54
|
* @brief Shared bigint guard singleton.
|
|
46
55
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
@@ -65,6 +74,15 @@ export const symbolGuard = new BaseGuard({
|
|
|
65
74
|
export const booleanGuard = new BaseGuard({
|
|
66
75
|
tag: SchemaTag.Boolean
|
|
67
76
|
});
|
|
77
|
+
export const nullGuard = new BaseGuard({
|
|
78
|
+
tag: SchemaTag.Literal,
|
|
79
|
+
value: null
|
|
80
|
+
});
|
|
81
|
+
export const undefinedGuard = new BaseGuard({
|
|
82
|
+
tag: SchemaTag.Literal,
|
|
83
|
+
value: undefined
|
|
84
|
+
});
|
|
85
|
+
export const voidGuard = undefinedGuard;
|
|
68
86
|
/**
|
|
69
87
|
* @brief Build a literal guard after rejecting non-literal runtime values.
|
|
70
88
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
@@ -86,3 +104,38 @@ export function literal(value) {
|
|
|
86
104
|
value
|
|
87
105
|
});
|
|
88
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* @brief Build a string literal enum guard.
|
|
109
|
+
* @param values Non-empty tuple of string literals.
|
|
110
|
+
* @returns Fresh guard accepting exactly one supplied enum member.
|
|
111
|
+
* @throws TypeError when values are empty, non-strings, or duplicated.
|
|
112
|
+
* @details The public export is aliased as `enum`; this internal name avoids
|
|
113
|
+
* spelling a reserved word as a local binding.
|
|
114
|
+
*/
|
|
115
|
+
export function enumValues(values) {
|
|
116
|
+
const rawValues = values;
|
|
117
|
+
if (!Array.isArray(rawValues) || rawValues.length === 0) {
|
|
118
|
+
throw new TypeError("enum values must be a non-empty string array");
|
|
119
|
+
}
|
|
120
|
+
const checkedValues = rawValues;
|
|
121
|
+
const options = new Array(checkedValues.length);
|
|
122
|
+
for (let index = 0; index < checkedValues.length; index += 1) {
|
|
123
|
+
const value = checkedValues[index];
|
|
124
|
+
if (typeof value !== "string") {
|
|
125
|
+
throw new TypeError("enum values must be strings");
|
|
126
|
+
}
|
|
127
|
+
for (let seen = 0; seen < index; seen += 1) {
|
|
128
|
+
if (Object.is(checkedValues[seen], value)) {
|
|
129
|
+
throw new TypeError("enum values must be unique");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
options[index] = {
|
|
133
|
+
tag: SchemaTag.Literal,
|
|
134
|
+
value
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return new BaseGuard({
|
|
138
|
+
tag: SchemaTag.Union,
|
|
139
|
+
options
|
|
140
|
+
});
|
|
141
|
+
}
|
package/dist/builders/table.d.ts
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
7
|
import { asyncDecoder, asyncPipe, asyncRefine, asyncTransform } from "../async/index.js";
|
|
8
|
-
import { decoder, pipe, transform } from "../decoder/index.js";
|
|
9
|
-
import { array, discriminatedUnion, intersect, record, tuple, union } from "./composite.js";
|
|
10
|
-
import { lazy, nullable, optional, refine, undefinedable } from "./modifier.js";
|
|
11
|
-
import { extend, object, omit, partial, pick, strictObject } from "./object/index.js";
|
|
12
|
-
import { literal } from "./scalar.js";
|
|
8
|
+
import { catchValue, codec, decoder, defaultValue, pipe, prefault, transform } from "../decoder/index.js";
|
|
9
|
+
import { array, discriminatedUnion, intersect, map, record, set, tuple, union } from "./composite.js";
|
|
10
|
+
import { lazy, nullable, nullish, optional, refine, undefinedable } from "./modifier.js";
|
|
11
|
+
import { catchall, deepPartial, extend, merge, object, omit, partial, passthrough, pick, required, safeExtend, strict, strictObject, strip } from "./object/index.js";
|
|
12
|
+
import { enumValues, literal } from "./scalar.js";
|
|
13
|
+
import { instanceOf, json, property } from "./runtime.js";
|
|
13
14
|
/**
|
|
14
15
|
* @brief t.
|
|
15
16
|
* @details Frozen namespace of all public builders. Freezing prevents accidental
|
|
@@ -20,26 +21,51 @@ export declare const t: Readonly<{
|
|
|
20
21
|
readonly never: import("../index.js").BaseGuard<never, "required">;
|
|
21
22
|
readonly string: import("../index.js").StringGuard<"required">;
|
|
22
23
|
readonly number: import("../index.js").NumberGuard<"required">;
|
|
24
|
+
readonly date: import("../index.js").DateGuard<"required">;
|
|
23
25
|
readonly bigint: import("../index.js").BaseGuard<bigint, "required">;
|
|
24
26
|
readonly symbol: import("../index.js").BaseGuard<symbol, "required">;
|
|
25
27
|
readonly boolean: import("../index.js").BaseGuard<boolean, "required">;
|
|
28
|
+
readonly null: import("../index.js").BaseGuard<null, "required">;
|
|
29
|
+
readonly undefined: import("../index.js").BaseGuard<undefined, "required">;
|
|
30
|
+
readonly void: import("../index.js").BaseGuard<undefined, "required">;
|
|
26
31
|
readonly literal: typeof literal;
|
|
32
|
+
readonly enum: typeof enumValues;
|
|
33
|
+
readonly enumValues: typeof enumValues;
|
|
27
34
|
readonly array: typeof array;
|
|
28
35
|
readonly tuple: typeof tuple;
|
|
29
36
|
readonly record: typeof record;
|
|
37
|
+
readonly map: typeof map;
|
|
38
|
+
readonly set: typeof set;
|
|
39
|
+
readonly instanceOf: typeof instanceOf;
|
|
40
|
+
readonly property: typeof property;
|
|
41
|
+
readonly json: typeof json;
|
|
30
42
|
readonly decoder: typeof decoder;
|
|
43
|
+
readonly default: typeof defaultValue;
|
|
44
|
+
readonly defaultValue: typeof defaultValue;
|
|
45
|
+
readonly prefault: typeof prefault;
|
|
46
|
+
readonly catch: typeof catchValue;
|
|
47
|
+
readonly codec: typeof codec;
|
|
31
48
|
readonly object: typeof object;
|
|
32
49
|
readonly strictObject: typeof strictObject;
|
|
33
50
|
readonly extend: typeof extend;
|
|
51
|
+
readonly merge: typeof merge;
|
|
34
52
|
readonly pick: typeof pick;
|
|
35
53
|
readonly omit: typeof omit;
|
|
36
54
|
readonly partial: typeof partial;
|
|
55
|
+
readonly deepPartial: typeof deepPartial;
|
|
56
|
+
readonly required: typeof required;
|
|
57
|
+
readonly safeExtend: typeof safeExtend;
|
|
58
|
+
readonly strict: typeof strict;
|
|
59
|
+
readonly passthrough: typeof passthrough;
|
|
60
|
+
readonly strip: typeof strip;
|
|
61
|
+
readonly catchall: typeof catchall;
|
|
37
62
|
readonly union: typeof union;
|
|
38
63
|
readonly intersect: typeof intersect;
|
|
39
64
|
readonly discriminatedUnion: typeof discriminatedUnion;
|
|
40
65
|
readonly optional: typeof optional;
|
|
41
66
|
readonly undefinedable: typeof undefinedable;
|
|
42
67
|
readonly nullable: typeof nullable;
|
|
68
|
+
readonly nullish: typeof nullish;
|
|
43
69
|
readonly lazy: typeof lazy;
|
|
44
70
|
readonly refine: typeof refine;
|
|
45
71
|
readonly transform: typeof transform;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/builders/table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/builders/table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EACH,UAAU,EACV,KAAK,EAEL,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,SAAS,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,KAAK,EACL,kBAAkB,EAClB,SAAS,EACT,GAAG,EACH,MAAM,EACN,GAAG,EACH,KAAK,EACL,KAAK,EACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EACN,aAAa,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,QAAQ,EACR,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,MAAM,EACN,YAAY,EACZ,KAAK,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIH,UAAU,EACV,OAAO,EASV,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,UAAU,EACV,IAAI,EACJ,QAAQ,EACX,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DH,CAAC"}
|
package/dist/builders/table.js
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
7
|
import { asyncDecoder, asyncPipe, asyncRefine, asyncTransform } from "../async/index.js";
|
|
8
|
-
import { coerce, decoder, pipe, transform } from "../decoder/index.js";
|
|
9
|
-
import { array, discriminatedUnion, intersect, record, tuple, union } from "./composite.js";
|
|
10
|
-
import { lazy, nullable, optional, refine, undefinedable } from "./modifier.js";
|
|
11
|
-
import { extend, object, omit, partial, pick, strictObject } from "./object/index.js";
|
|
12
|
-
import { bigintGuard, booleanGuard, literal, neverGuard, numberGuard, stringGuard, symbolGuard, unknownGuard } from "./scalar.js";
|
|
8
|
+
import { catchValue, codec, coerce, decoder, defaultValue, pipe, prefault, transform } from "../decoder/index.js";
|
|
9
|
+
import { array, discriminatedUnion, intersect, map, record, set, tuple, union } from "./composite.js";
|
|
10
|
+
import { lazy, nullable, nullish, optional, refine, undefinedable } from "./modifier.js";
|
|
11
|
+
import { catchall, deepPartial, extend, merge, object, omit, partial, passthrough, pick, required, safeExtend, strict, strictObject, strip } from "./object/index.js";
|
|
12
|
+
import { bigintGuard, booleanGuard, dateGuard, enumValues, literal, neverGuard, nullGuard, numberGuard, stringGuard, symbolGuard, unknownGuard, undefinedGuard, voidGuard } from "./scalar.js";
|
|
13
|
+
import { instanceOf, json, property } from "./runtime.js";
|
|
13
14
|
/**
|
|
14
15
|
* @brief t.
|
|
15
16
|
* @details Frozen namespace of all public builders. Freezing prevents accidental
|
|
@@ -20,26 +21,51 @@ export const t = Object.freeze({
|
|
|
20
21
|
never: neverGuard,
|
|
21
22
|
string: stringGuard,
|
|
22
23
|
number: numberGuard,
|
|
24
|
+
date: dateGuard,
|
|
23
25
|
bigint: bigintGuard,
|
|
24
26
|
symbol: symbolGuard,
|
|
25
27
|
boolean: booleanGuard,
|
|
28
|
+
null: nullGuard,
|
|
29
|
+
undefined: undefinedGuard,
|
|
30
|
+
void: voidGuard,
|
|
26
31
|
literal,
|
|
32
|
+
enum: enumValues,
|
|
33
|
+
enumValues,
|
|
27
34
|
array,
|
|
28
35
|
tuple,
|
|
29
36
|
record,
|
|
37
|
+
map,
|
|
38
|
+
set,
|
|
39
|
+
instanceOf,
|
|
40
|
+
property,
|
|
41
|
+
json,
|
|
30
42
|
decoder,
|
|
43
|
+
default: defaultValue,
|
|
44
|
+
defaultValue,
|
|
45
|
+
prefault,
|
|
46
|
+
catch: catchValue,
|
|
47
|
+
codec,
|
|
31
48
|
object,
|
|
32
49
|
strictObject,
|
|
33
50
|
extend,
|
|
51
|
+
merge,
|
|
34
52
|
pick,
|
|
35
53
|
omit,
|
|
36
54
|
partial,
|
|
55
|
+
deepPartial,
|
|
56
|
+
required,
|
|
57
|
+
safeExtend,
|
|
58
|
+
strict,
|
|
59
|
+
passthrough,
|
|
60
|
+
strip,
|
|
61
|
+
catchall,
|
|
37
62
|
union,
|
|
38
63
|
intersect,
|
|
39
64
|
discriminatedUnion,
|
|
40
65
|
optional,
|
|
41
66
|
undefinedable,
|
|
42
67
|
nullable,
|
|
68
|
+
nullish,
|
|
43
69
|
lazy,
|
|
44
70
|
refine,
|
|
45
71
|
transform,
|
package/dist/builders/types.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export type TupleShape = readonly Guard<unknown, Presence>[];
|
|
|
19
19
|
export type InferTuple<TShape extends TupleShape> = {
|
|
20
20
|
readonly [TKey in keyof TShape]: Infer<TShape[TKey]>;
|
|
21
21
|
};
|
|
22
|
+
export type InferTupleWithRest<TShape extends TupleShape, TRest extends Guard<unknown, Presence>> = readonly [
|
|
23
|
+
...{
|
|
24
|
+
[TKey in keyof TShape]: Infer<TShape[TKey]>;
|
|
25
|
+
},
|
|
26
|
+
...Infer<TRest>[]
|
|
27
|
+
];
|
|
22
28
|
/**
|
|
23
29
|
* @brief Non-empty union builder input.
|
|
24
30
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/builders/types.ts"],"names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O,EAAE,QAAQ,CAAC,EAAE,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,UAAU,IAAI;IAChD,QAAQ,EAAE,IAAI,IAAI,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAC1B,MAAM,SAAS,UAAU,EACzB,KAAK,SAAS,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,IACtC,SAAS;IACT,GAAG;SACE,IAAI,IAAI,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KAC9C;IACD,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CAC/B,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IACjE,MAAM,SAAS,IAAI,GACjB,MAAM,GACN;IACM,QAAQ,EAAE,KAAK,IAAI,MAAM,MAAM,GAAG,KAAK,SAAS,MAAM,GAChD,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,GACtD,MAAM,CAAC,KAAK,CAAC,GACb,KAAK,GACb,KAAK;CACV,CAAC"}
|
|
@@ -25,7 +25,9 @@ export type CheckFunctionEmitter = (schema: Schema, context: EmitContext) => str
|
|
|
25
25
|
* @param emitChild Fallback emitter for non-leaf child validators.
|
|
26
26
|
* @returns JavaScript source for array diagnostics.
|
|
27
27
|
*/
|
|
28
|
-
export declare function emitArrayCheck(
|
|
28
|
+
export declare function emitArrayCheck(schema: Extract<Schema, {
|
|
29
|
+
readonly tag: typeof SchemaTag.Array;
|
|
30
|
+
}>, value: string, path: string, issues: string, context: EmitContext, emitChild: CheckFunctionEmitter): string;
|
|
29
31
|
/**
|
|
30
32
|
* @brief emit tuple check.
|
|
31
33
|
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-composite.d.ts","sourceRoot":"","sources":["../../src/compile/check-composite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"check-composite.d.ts","sourceRoot":"","sources":["../../src/compile/check-composite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAIH,SAAS,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEH,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAkB5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,KACnB,MAAM,CAAC;AAEZ;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,KAAK,CAAA;CAAE,CAAC,EACjE,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAoB,GAChC,MAAM,CAmFR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAA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