typesea 0.2.0 → 0.3.0
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 +18 -0
- package/README.md +45 -11
- 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 +71 -8
- package/docs/engine-notes.md +4 -0
- package/docs/index.html +1340 -722
- package/docs/ko/api.md +375 -0
- package/docs/ko/engine-notes.md +156 -0
- package/docs/ko/readme.md +378 -0
- package/package.json +3 -2
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { ObjectModeTag } from "../../kind/index.js";
|
|
8
8
|
import { BaseGuard } from "../../guard/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { readGuardSchema } from "../../internal/index.js";
|
|
10
|
+
import { deepPartialObjectSchema, mergeObjectSchemas, objectSchema, objectSchemaWithCatchall, objectSchemaWithMode, omitObjectSchema, partialObjectSchema, pickObjectSchema, readObjectConstructorSchema, readObjectKeySelection, readObjectMethodSchema, requiredObjectSchema } from "./schema.js";
|
|
10
11
|
/**
|
|
11
12
|
* @brief Guard subclass with object-specific shape operations.
|
|
12
13
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
@@ -23,6 +24,12 @@ export class ObjectGuard extends BaseGuard {
|
|
|
23
24
|
extend(extension) {
|
|
24
25
|
return extendObjectGuard(this, extension);
|
|
25
26
|
}
|
|
27
|
+
safeExtend(extension) {
|
|
28
|
+
return extendObjectGuard(this, extension);
|
|
29
|
+
}
|
|
30
|
+
merge(other) {
|
|
31
|
+
return mergeObjectGuard(this, other);
|
|
32
|
+
}
|
|
26
33
|
pick(keys) {
|
|
27
34
|
return pickObjectGuard(this, keys);
|
|
28
35
|
}
|
|
@@ -32,6 +39,24 @@ export class ObjectGuard extends BaseGuard {
|
|
|
32
39
|
partial() {
|
|
33
40
|
return partialObjectGuard(this);
|
|
34
41
|
}
|
|
42
|
+
deepPartial() {
|
|
43
|
+
return deepPartialObjectGuard(this);
|
|
44
|
+
}
|
|
45
|
+
required() {
|
|
46
|
+
return requiredObjectGuard(this);
|
|
47
|
+
}
|
|
48
|
+
strict() {
|
|
49
|
+
return objectModeGuard(this, ObjectModeTag.Strict);
|
|
50
|
+
}
|
|
51
|
+
passthrough() {
|
|
52
|
+
return objectModeGuard(this, ObjectModeTag.Passthrough);
|
|
53
|
+
}
|
|
54
|
+
strip() {
|
|
55
|
+
return objectModeGuard(this, ObjectModeTag.Passthrough);
|
|
56
|
+
}
|
|
57
|
+
catchall(guard) {
|
|
58
|
+
return catchallObjectGuard(this, guard);
|
|
59
|
+
}
|
|
35
60
|
}
|
|
36
61
|
/**
|
|
37
62
|
* @brief Build an object guard that accepts unspecified enumerable keys.
|
|
@@ -57,16 +82,25 @@ export function extend(guard, extension) {
|
|
|
57
82
|
return extendObjectGuard(guard, extension);
|
|
58
83
|
}
|
|
59
84
|
/**
|
|
60
|
-
* @brief Execute
|
|
61
|
-
* @details
|
|
85
|
+
* @brief Execute safe extend.
|
|
86
|
+
* @details Runtime construction follows the same hardened schema merge as
|
|
87
|
+
* extend. The method name gives callers a Zod-compatible, intention-revealing
|
|
88
|
+
* API for shape extension.
|
|
62
89
|
*/
|
|
63
|
-
export function
|
|
64
|
-
return
|
|
90
|
+
export function safeExtend(guard, extension) {
|
|
91
|
+
return extendObjectGuard(guard, extension);
|
|
65
92
|
}
|
|
66
93
|
/**
|
|
67
|
-
* @brief Execute
|
|
68
|
-
* @details
|
|
94
|
+
* @brief Execute object merge.
|
|
95
|
+
* @details The left object keeps its unknown-key mode. The right object supplies
|
|
96
|
+
* overriding fields and, when present, a catchall schema.
|
|
69
97
|
*/
|
|
98
|
+
export function merge(guard, other) {
|
|
99
|
+
return mergeObjectGuard(guard, other);
|
|
100
|
+
}
|
|
101
|
+
export function pick(guard, keys) {
|
|
102
|
+
return pickObjectGuard(guard, keys);
|
|
103
|
+
}
|
|
70
104
|
export function omit(guard, keys) {
|
|
71
105
|
return omitObjectGuard(guard, keys);
|
|
72
106
|
}
|
|
@@ -77,6 +111,45 @@ export function omit(guard, keys) {
|
|
|
77
111
|
export function partial(guard) {
|
|
78
112
|
return partialObjectGuard(guard);
|
|
79
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* @brief Execute deep partial.
|
|
116
|
+
*/
|
|
117
|
+
export function deepPartial(guard) {
|
|
118
|
+
return deepPartialObjectGuard(guard);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @brief Execute required.
|
|
122
|
+
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
123
|
+
*/
|
|
124
|
+
export function required(guard) {
|
|
125
|
+
return requiredObjectGuard(guard);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @brief Convert an object guard to strict unknown-key policy.
|
|
129
|
+
*/
|
|
130
|
+
export function strict(guard) {
|
|
131
|
+
return objectModeGuard(guard, ObjectModeTag.Strict);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @brief Convert an object guard to passthrough unknown-key policy.
|
|
135
|
+
*/
|
|
136
|
+
export function passthrough(guard) {
|
|
137
|
+
return objectModeGuard(guard, ObjectModeTag.Passthrough);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @brief Accept unknown keys without producing a stripped output copy.
|
|
141
|
+
* @details TypeSea guard validation returns the original value, so Zod-style
|
|
142
|
+
* strip has validation semantics equivalent to passthrough.
|
|
143
|
+
*/
|
|
144
|
+
export function strip(guard) {
|
|
145
|
+
return objectModeGuard(guard, ObjectModeTag.Passthrough);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @brief Validate every undeclared own key with a catchall schema.
|
|
149
|
+
*/
|
|
150
|
+
export function catchall(guard, value) {
|
|
151
|
+
return catchallObjectGuard(guard, value);
|
|
152
|
+
}
|
|
80
153
|
/**
|
|
81
154
|
* @brief Execute extend object guard.
|
|
82
155
|
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
@@ -85,6 +158,14 @@ function extendObjectGuard(guard, extension) {
|
|
|
85
158
|
const schema = readObjectMethodSchema(guard, "object extend receiver");
|
|
86
159
|
return new ObjectGuard(mergeObjectSchemas(schema, objectSchema(extension, schema.mode)));
|
|
87
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* @brief Execute merge object guard.
|
|
163
|
+
*/
|
|
164
|
+
function mergeObjectGuard(guard, other) {
|
|
165
|
+
const base = readObjectMethodSchema(guard, "object merge receiver");
|
|
166
|
+
const extension = readObjectMethodSchema(other, "object merge argument");
|
|
167
|
+
return new ObjectGuard(mergeObjectSchemas(base, extension));
|
|
168
|
+
}
|
|
88
169
|
/**
|
|
89
170
|
* @brief Execute pick object guard.
|
|
90
171
|
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
@@ -111,3 +192,32 @@ function partialObjectGuard(guard) {
|
|
|
111
192
|
const schema = readObjectMethodSchema(guard, "object partial receiver");
|
|
112
193
|
return new ObjectGuard(partialObjectSchema(schema));
|
|
113
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* @brief Execute deep partial object guard.
|
|
197
|
+
*/
|
|
198
|
+
function deepPartialObjectGuard(guard) {
|
|
199
|
+
const schema = readObjectMethodSchema(guard, "object deepPartial receiver");
|
|
200
|
+
return new ObjectGuard(deepPartialObjectSchema(schema));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @brief Execute required object guard.
|
|
204
|
+
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
205
|
+
*/
|
|
206
|
+
function requiredObjectGuard(guard) {
|
|
207
|
+
const schema = readObjectMethodSchema(guard, "object required receiver");
|
|
208
|
+
return new ObjectGuard(requiredObjectSchema(schema));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @brief Execute object mode rewrite.
|
|
212
|
+
*/
|
|
213
|
+
function objectModeGuard(guard, mode) {
|
|
214
|
+
const schema = readObjectMethodSchema(guard, "object mode receiver");
|
|
215
|
+
return new ObjectGuard(objectSchemaWithMode(schema, mode));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @brief Execute object catchall rewrite.
|
|
219
|
+
*/
|
|
220
|
+
function catchallObjectGuard(guard, value) {
|
|
221
|
+
const schema = readObjectMethodSchema(guard, "object catchall receiver");
|
|
222
|
+
return new ObjectGuard(objectSchemaWithCatchall(schema, readGuardSchema(value, "object catchall schema")));
|
|
223
|
+
}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
|
-
export { ObjectGuard, extend, object, omit, partial, pick, strictObject } from "./guard.js";
|
|
8
|
-
export type { InferObject, MergeObjectShapes, ObjectGuardMode, ObjectShape, OmitObjectShape, PartialObjectShape, PickObjectShape } from "./types.js";
|
|
7
|
+
export { ObjectGuard, catchall, deepPartial, extend, merge, object, omit, partial, passthrough, pick, required, safeExtend, strict, strictObject, strip } from "./guard.js";
|
|
8
|
+
export type { DeepPartialObjectShape, DeepPartialValue, InferObject, MaskSelectedKeys, MergeObjectShapes, ObjectKeyMask, ObjectGuardMode, ObjectShape, OmitObjectShape, OmitObjectShapeByMask, PartialObjectShape, PickObjectShape, PickObjectShapeByMask, RequiredObjectShape } from "./types.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builders/object/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,WAAW,EACX,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builders/object/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,WAAW,EACX,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,YAAY,CAAC;AACpB,YAAY,EACR,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,YAAY,CAAC"}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
|
-
export { ObjectGuard, extend, object, omit, partial, pick, strictObject } from "./guard.js";
|
|
7
|
+
export { ObjectGuard, catchall, deepPartial, extend, merge, object, omit, partial, passthrough, pick, required, safeExtend, strict, strictObject, strip } from "./guard.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* with stable metadata.
|
|
6
6
|
*/
|
|
7
7
|
import { ObjectModeTag } from "../../kind/index.js";
|
|
8
|
-
import type { ObjectEntry, ObjectSchema } from "../../schema/index.js";
|
|
8
|
+
import type { ObjectEntry, ObjectSchema, Schema } from "../../schema/index.js";
|
|
9
9
|
import type { ObjectShape } from "./types.js";
|
|
10
10
|
/**
|
|
11
11
|
* @brief Normalize an object shape into ordered entries and lookup metadata.
|
|
@@ -18,7 +18,21 @@ export declare function objectSchema(shape: ObjectShape, mode: ObjectModeTag): O
|
|
|
18
18
|
* @details Duplicate keys are rejected here so pick/omit/extend cannot create
|
|
19
19
|
* a schema that disagrees with its strict-key lookup table.
|
|
20
20
|
*/
|
|
21
|
-
export declare function objectSchemaFromEntries(sourceEntries: readonly ObjectEntry[], mode: ObjectModeTag): ObjectSchema;
|
|
21
|
+
export declare function objectSchemaFromEntries(sourceEntries: readonly ObjectEntry[], mode: ObjectModeTag, catchall: Schema | undefined): ObjectSchema;
|
|
22
|
+
/**
|
|
23
|
+
* @brief Rebuild an object schema with a different unknown-key mode.
|
|
24
|
+
* @param schema Source object schema.
|
|
25
|
+
* @param mode Unknown-key policy for the rebuilt schema.
|
|
26
|
+
* @returns Object schema with identical entries and catchall policy.
|
|
27
|
+
*/
|
|
28
|
+
export declare function objectSchemaWithMode(schema: ObjectSchema, mode: ObjectModeTag): ObjectSchema;
|
|
29
|
+
/**
|
|
30
|
+
* @brief Rebuild an object schema with an unknown-key validator.
|
|
31
|
+
* @param schema Source object schema.
|
|
32
|
+
* @param catchall Schema applied to every undeclared own key.
|
|
33
|
+
* @returns Object schema that validates extra keys with the supplied schema.
|
|
34
|
+
*/
|
|
35
|
+
export declare function objectSchemaWithCatchall(schema: ObjectSchema, catchall: Schema): ObjectSchema;
|
|
22
36
|
/**
|
|
23
37
|
* @brief Validate the schema value handed to an ObjectGuard constructor.
|
|
24
38
|
* @details Constructors are public JavaScript entry points, so the guard checks
|
|
@@ -76,6 +90,23 @@ export declare function omitObjectSchema(schema: ObjectSchema, keys: readonly st
|
|
|
76
90
|
* @returns Rebuilt object schema with optional entries.
|
|
77
91
|
*/
|
|
78
92
|
export declare function partialObjectSchema(schema: ObjectSchema): ObjectSchema;
|
|
93
|
+
/**
|
|
94
|
+
* @brief Recursively convert object entries to optional presence.
|
|
95
|
+
* @param schema Source object schema.
|
|
96
|
+
* @returns Rebuilt object schema with nested object/container children partialized.
|
|
97
|
+
* @details Lazy and refinement schemas are treated as semantic barriers because
|
|
98
|
+
* their runtime callbacks may depend on the original exact value domain.
|
|
99
|
+
*/
|
|
100
|
+
export declare function deepPartialObjectSchema(schema: ObjectSchema): ObjectSchema;
|
|
101
|
+
/**
|
|
102
|
+
* @brief Convert every object entry to required presence.
|
|
103
|
+
* @param schema Source object schema.
|
|
104
|
+
* @returns Rebuilt object schema with required entries.
|
|
105
|
+
* @details Object construction already stripped Optional wrappers into entry
|
|
106
|
+
* presence metadata. Requiring a field therefore only needs to flip that
|
|
107
|
+
* metadata back to Required while preserving each value-domain schema.
|
|
108
|
+
*/
|
|
109
|
+
export declare function requiredObjectSchema(schema: ObjectSchema): ObjectSchema;
|
|
79
110
|
/**
|
|
80
111
|
* @brief Validate the key list supplied to object pick and omit operations.
|
|
81
112
|
* @details The returned array contains only known, unique string keys. This
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/builders/object/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,aAAa,EAGhB,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EACR,WAAW,EAEX,YAAY,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/builders/object/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,aAAa,EAGhB,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EACR,WAAW,EAEX,YAAY,EACZ,MAAM,EACT,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAY9C;;;;GAIG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,aAAa,GACpB,YAAY,CAsBd;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,aAAa,EAAE,SAAS,WAAW,EAAE,EACrC,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC7B,YAAY,CAwBd;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,aAAa,GACpB,YAAY,CAEd;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,MAAM,GACjB,YAAY,CAEd;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAKzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAMlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,YAAY,GACxB,YAAY,CAmBd;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,SAAS,MAAM,EAAE,GACxB,YAAY,CAad;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,SAAS,MAAM,EAAE,GACxB,YAAY,CASd;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAatE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAgB1E;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAavE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GACd,SAAS,MAAM,EAAE,CAsBnB"}
|
|
@@ -31,14 +31,14 @@ export function objectSchema(shape, mode) {
|
|
|
31
31
|
presence: entrySchema.presence
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
return objectSchemaFromEntries(entries, mode);
|
|
34
|
+
return objectSchemaFromEntries(entries, mode, undefined);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* @brief Rebuild object metadata after shape transformations.
|
|
38
38
|
* @details Duplicate keys are rejected here so pick/omit/extend cannot create
|
|
39
39
|
* a schema that disagrees with its strict-key lookup table.
|
|
40
40
|
*/
|
|
41
|
-
export function objectSchemaFromEntries(sourceEntries, mode) {
|
|
41
|
+
export function objectSchemaFromEntries(sourceEntries, mode, catchall) {
|
|
42
42
|
const entries = new Array(sourceEntries.length);
|
|
43
43
|
const keys = new Array(sourceEntries.length);
|
|
44
44
|
const keyLookup = makeObjectKeyLookup();
|
|
@@ -59,9 +59,28 @@ export function objectSchemaFromEntries(sourceEntries, mode) {
|
|
|
59
59
|
entries,
|
|
60
60
|
keys,
|
|
61
61
|
keyLookup,
|
|
62
|
-
mode
|
|
62
|
+
mode,
|
|
63
|
+
catchall
|
|
63
64
|
};
|
|
64
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @brief Rebuild an object schema with a different unknown-key mode.
|
|
68
|
+
* @param schema Source object schema.
|
|
69
|
+
* @param mode Unknown-key policy for the rebuilt schema.
|
|
70
|
+
* @returns Object schema with identical entries and catchall policy.
|
|
71
|
+
*/
|
|
72
|
+
export function objectSchemaWithMode(schema, mode) {
|
|
73
|
+
return objectSchemaFromEntries(schema.entries, mode, schema.catchall);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @brief Rebuild an object schema with an unknown-key validator.
|
|
77
|
+
* @param schema Source object schema.
|
|
78
|
+
* @param catchall Schema applied to every undeclared own key.
|
|
79
|
+
* @returns Object schema that validates extra keys with the supplied schema.
|
|
80
|
+
*/
|
|
81
|
+
export function objectSchemaWithCatchall(schema, catchall) {
|
|
82
|
+
return objectSchemaFromEntries(schema.entries, schema.mode, catchall);
|
|
83
|
+
}
|
|
65
84
|
/**
|
|
66
85
|
* @brief Validate the schema value handed to an ObjectGuard constructor.
|
|
67
86
|
* @details Constructors are public JavaScript entry points, so the guard checks
|
|
@@ -115,7 +134,7 @@ export function mergeObjectSchemas(base, extension) {
|
|
|
115
134
|
entries.push(entry);
|
|
116
135
|
}
|
|
117
136
|
}
|
|
118
|
-
return objectSchemaFromEntries(entries, base.mode);
|
|
137
|
+
return objectSchemaFromEntries(entries, base.mode, extension.catchall ?? base.catchall);
|
|
119
138
|
}
|
|
120
139
|
/**
|
|
121
140
|
* @brief Build an object schema containing only a validated key selection.
|
|
@@ -138,7 +157,7 @@ export function pickObjectSchema(schema, keys) {
|
|
|
138
157
|
}
|
|
139
158
|
entries[index] = entry;
|
|
140
159
|
}
|
|
141
|
-
return objectSchemaFromEntries(entries, schema.mode);
|
|
160
|
+
return objectSchemaFromEntries(entries, schema.mode, schema.catchall);
|
|
142
161
|
}
|
|
143
162
|
/**
|
|
144
163
|
* @brief Build an object schema with a validated key selection removed.
|
|
@@ -156,7 +175,7 @@ export function omitObjectSchema(schema, keys) {
|
|
|
156
175
|
entries.push(entry);
|
|
157
176
|
}
|
|
158
177
|
}
|
|
159
|
-
return objectSchemaFromEntries(entries, schema.mode);
|
|
178
|
+
return objectSchemaFromEntries(entries, schema.mode, schema.catchall);
|
|
160
179
|
}
|
|
161
180
|
/**
|
|
162
181
|
* @brief Convert every object entry to optional presence.
|
|
@@ -178,7 +197,53 @@ export function partialObjectSchema(schema) {
|
|
|
178
197
|
};
|
|
179
198
|
}
|
|
180
199
|
}
|
|
181
|
-
return objectSchemaFromEntries(entries, schema.mode);
|
|
200
|
+
return objectSchemaFromEntries(entries, schema.mode, schema.catchall);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @brief Recursively convert object entries to optional presence.
|
|
204
|
+
* @param schema Source object schema.
|
|
205
|
+
* @returns Rebuilt object schema with nested object/container children partialized.
|
|
206
|
+
* @details Lazy and refinement schemas are treated as semantic barriers because
|
|
207
|
+
* their runtime callbacks may depend on the original exact value domain.
|
|
208
|
+
*/
|
|
209
|
+
export function deepPartialObjectSchema(schema) {
|
|
210
|
+
const entries = new Array(schema.entries.length);
|
|
211
|
+
for (let index = 0; index < schema.entries.length; index += 1) {
|
|
212
|
+
const entry = schema.entries[index];
|
|
213
|
+
if (entry !== undefined) {
|
|
214
|
+
entries[index] = {
|
|
215
|
+
key: entry.key,
|
|
216
|
+
schema: deepPartialSchema(entry.schema),
|
|
217
|
+
presence: PresenceTag.Optional
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const catchall = schema.catchall === undefined
|
|
222
|
+
? undefined
|
|
223
|
+
: deepPartialSchema(schema.catchall);
|
|
224
|
+
return objectSchemaFromEntries(entries, schema.mode, catchall);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @brief Convert every object entry to required presence.
|
|
228
|
+
* @param schema Source object schema.
|
|
229
|
+
* @returns Rebuilt object schema with required entries.
|
|
230
|
+
* @details Object construction already stripped Optional wrappers into entry
|
|
231
|
+
* presence metadata. Requiring a field therefore only needs to flip that
|
|
232
|
+
* metadata back to Required while preserving each value-domain schema.
|
|
233
|
+
*/
|
|
234
|
+
export function requiredObjectSchema(schema) {
|
|
235
|
+
const entries = new Array(schema.entries.length);
|
|
236
|
+
for (let index = 0; index < schema.entries.length; index += 1) {
|
|
237
|
+
const entry = schema.entries[index];
|
|
238
|
+
if (entry !== undefined) {
|
|
239
|
+
entries[index] = {
|
|
240
|
+
key: entry.key,
|
|
241
|
+
schema: entry.schema,
|
|
242
|
+
presence: PresenceTag.Required
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return objectSchemaFromEntries(entries, schema.mode, schema.catchall);
|
|
182
247
|
}
|
|
183
248
|
/**
|
|
184
249
|
* @brief Validate the key list supplied to object pick and omit operations.
|
|
@@ -191,8 +256,11 @@ export function partialObjectSchema(schema) {
|
|
|
191
256
|
* @returns Ordered key selection accepted by the object builder.
|
|
192
257
|
*/
|
|
193
258
|
export function readObjectKeySelection(keys, schema, label) {
|
|
259
|
+
if (isRecord(keys)) {
|
|
260
|
+
return readObjectKeyMask(keys, schema, label);
|
|
261
|
+
}
|
|
194
262
|
if (!isUnknownArray(keys)) {
|
|
195
|
-
throw new TypeError(`${label} must be an array`);
|
|
263
|
+
throw new TypeError(`${label} must be an array or key mask`);
|
|
196
264
|
}
|
|
197
265
|
const selected = new Array(keys.length);
|
|
198
266
|
for (let index = 0; index < keys.length; index += 1) {
|
|
@@ -210,6 +278,128 @@ export function readObjectKeySelection(keys, schema, label) {
|
|
|
210
278
|
}
|
|
211
279
|
return selected;
|
|
212
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* @brief Validate a Zod-style object key mask.
|
|
283
|
+
* @param mask Candidate object whose selected keys have value true.
|
|
284
|
+
* @param schema Object schema whose keys define the valid selection domain.
|
|
285
|
+
* @param label Human-readable API label used in thrown errors.
|
|
286
|
+
* @returns Ordered key selection accepted by object pick and omit.
|
|
287
|
+
*/
|
|
288
|
+
function readObjectKeyMask(mask, schema, label) {
|
|
289
|
+
const keys = Object.keys(mask);
|
|
290
|
+
const selected = [];
|
|
291
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
292
|
+
const key = keys[index];
|
|
293
|
+
if (key === undefined) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (mask[key] !== true) {
|
|
297
|
+
throw new TypeError(`${label} mask values must be true`);
|
|
298
|
+
}
|
|
299
|
+
if (!hasObjectKey(schema.keyLookup, key)) {
|
|
300
|
+
throw new TypeError(`${label} contains unknown object key ${key}`);
|
|
301
|
+
}
|
|
302
|
+
selected.push(key);
|
|
303
|
+
}
|
|
304
|
+
return selected;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @brief Recursively partialize pure schema containers.
|
|
308
|
+
* @param schema Schema to rewrite.
|
|
309
|
+
* @returns Schema with nested object fields made optional where safe.
|
|
310
|
+
*/
|
|
311
|
+
function deepPartialSchema(schema) {
|
|
312
|
+
switch (schema.tag) {
|
|
313
|
+
case SchemaTag.Object:
|
|
314
|
+
return deepPartialObjectSchema(schema);
|
|
315
|
+
case SchemaTag.Array:
|
|
316
|
+
return {
|
|
317
|
+
tag: SchemaTag.Array,
|
|
318
|
+
item: deepPartialSchema(schema.item),
|
|
319
|
+
checks: schema.checks
|
|
320
|
+
};
|
|
321
|
+
case SchemaTag.Tuple:
|
|
322
|
+
return {
|
|
323
|
+
tag: SchemaTag.Tuple,
|
|
324
|
+
items: mapDeepPartialSchemas(schema.items),
|
|
325
|
+
rest: schema.rest === undefined
|
|
326
|
+
? undefined
|
|
327
|
+
: deepPartialSchema(schema.rest)
|
|
328
|
+
};
|
|
329
|
+
case SchemaTag.Record:
|
|
330
|
+
return {
|
|
331
|
+
tag: SchemaTag.Record,
|
|
332
|
+
value: deepPartialSchema(schema.value)
|
|
333
|
+
};
|
|
334
|
+
case SchemaTag.Map:
|
|
335
|
+
return {
|
|
336
|
+
tag: SchemaTag.Map,
|
|
337
|
+
key: deepPartialSchema(schema.key),
|
|
338
|
+
value: deepPartialSchema(schema.value)
|
|
339
|
+
};
|
|
340
|
+
case SchemaTag.Set:
|
|
341
|
+
return {
|
|
342
|
+
tag: SchemaTag.Set,
|
|
343
|
+
item: deepPartialSchema(schema.item)
|
|
344
|
+
};
|
|
345
|
+
case SchemaTag.Property:
|
|
346
|
+
return {
|
|
347
|
+
tag: SchemaTag.Property,
|
|
348
|
+
base: deepPartialSchema(schema.base),
|
|
349
|
+
key: schema.key,
|
|
350
|
+
value: deepPartialSchema(schema.value)
|
|
351
|
+
};
|
|
352
|
+
case SchemaTag.Union:
|
|
353
|
+
return {
|
|
354
|
+
tag: SchemaTag.Union,
|
|
355
|
+
options: mapDeepPartialSchemas(schema.options)
|
|
356
|
+
};
|
|
357
|
+
case SchemaTag.Intersection:
|
|
358
|
+
return {
|
|
359
|
+
tag: SchemaTag.Intersection,
|
|
360
|
+
left: deepPartialSchema(schema.left),
|
|
361
|
+
right: deepPartialSchema(schema.right)
|
|
362
|
+
};
|
|
363
|
+
case SchemaTag.Optional:
|
|
364
|
+
return {
|
|
365
|
+
tag: SchemaTag.Optional,
|
|
366
|
+
inner: deepPartialSchema(schema.inner)
|
|
367
|
+
};
|
|
368
|
+
case SchemaTag.Undefinedable:
|
|
369
|
+
return {
|
|
370
|
+
tag: SchemaTag.Undefinedable,
|
|
371
|
+
inner: deepPartialSchema(schema.inner)
|
|
372
|
+
};
|
|
373
|
+
case SchemaTag.Nullable:
|
|
374
|
+
return {
|
|
375
|
+
tag: SchemaTag.Nullable,
|
|
376
|
+
inner: deepPartialSchema(schema.inner)
|
|
377
|
+
};
|
|
378
|
+
case SchemaTag.Brand:
|
|
379
|
+
return {
|
|
380
|
+
tag: SchemaTag.Brand,
|
|
381
|
+
inner: deepPartialSchema(schema.inner),
|
|
382
|
+
brand: schema.brand
|
|
383
|
+
};
|
|
384
|
+
default:
|
|
385
|
+
return schema;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @brief Deep-partialize a schema vector.
|
|
390
|
+
* @param schemas Source schema vector.
|
|
391
|
+
* @returns New schema vector preserving index order.
|
|
392
|
+
*/
|
|
393
|
+
function mapDeepPartialSchemas(schemas) {
|
|
394
|
+
const mapped = new Array(schemas.length);
|
|
395
|
+
for (let index = 0; index < schemas.length; index += 1) {
|
|
396
|
+
const schema = schemas[index];
|
|
397
|
+
if (schema !== undefined) {
|
|
398
|
+
mapped[index] = deepPartialSchema(schema);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return mapped;
|
|
402
|
+
}
|
|
213
403
|
/**
|
|
214
404
|
* @brief Find an object entry by key using the ordered entry vector.
|
|
215
405
|
* @details The ordered vector is the source of truth for diagnostic and codegen
|
|
@@ -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","source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,CAAC,IAAI,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK;CACnE,CAAC,MAAM,KAAK,CAAC,CAAC;AAEf,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,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;A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