typesea 0.1.0 → 0.2.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 +67 -6
- package/README.md +98 -17
- package/dist/adapters/index.d.ts +50 -8
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +169 -48
- package/dist/aot/index.d.ts +18 -2
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +93 -14
- package/dist/async/index.d.ts +28 -56
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +94 -37
- package/dist/builders/composite.d.ts +37 -6
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +84 -10
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +2 -0
- package/dist/builders/modifier.d.ts +30 -5
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +38 -5
- package/dist/builders/object/guard.d.ts +18 -22
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +26 -26
- package/dist/builders/object/index.d.ts +2 -0
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +2 -0
- package/dist/builders/object/schema.d.ts +55 -9
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +92 -15
- package/dist/builders/object/types.d.ts +5 -31
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/object/types.js +2 -0
- package/dist/builders/scalar.d.ts +29 -8
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +33 -8
- package/dist/builders/table.d.ts +4 -0
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +4 -0
- package/dist/builders/types.d.ts +14 -4
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +2 -0
- package/dist/compile/check-composite.d.ts +22 -1
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +564 -24
- package/dist/compile/check-scalar.d.ts +78 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +432 -1
- package/dist/compile/check.d.ts +12 -0
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +37 -0
- package/dist/compile/context.d.ts +47 -9
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +51 -8
- package/dist/compile/graph-predicate.d.ts +4 -2
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +1907 -171
- package/dist/compile/guard.d.ts +15 -24
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +158 -74
- package/dist/compile/index.d.ts +3 -1
- package/dist/compile/index.d.ts.map +1 -1
- package/dist/compile/index.js +2 -0
- package/dist/compile/issue.d.ts +110 -0
- package/dist/compile/issue.d.ts.map +1 -1
- package/dist/compile/issue.js +184 -1
- package/dist/compile/names.d.ts +12 -2
- package/dist/compile/names.d.ts.map +1 -1
- package/dist/compile/names.js +19 -3
- package/dist/compile/predicate.d.ts +24 -0
- package/dist/compile/predicate.d.ts.map +1 -1
- package/dist/compile/predicate.js +131 -5
- package/dist/compile/runtime.d.ts +80 -12
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +25 -6
- package/dist/compile/source.d.ts +10 -2
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +361 -26
- package/dist/compile/types.d.ts +20 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/compile/types.js +2 -0
- package/dist/decoder/index.d.ts +32 -46
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +102 -38
- package/dist/evaluate/check-composite.d.ts +59 -0
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +151 -3
- package/dist/evaluate/check-scalar.d.ts +16 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +32 -0
- package/dist/evaluate/check.d.ts +7 -0
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +43 -0
- package/dist/evaluate/index.d.ts +2 -0
- package/dist/evaluate/index.d.ts.map +1 -1
- package/dist/evaluate/index.js +2 -0
- package/dist/evaluate/issue.d.ts +11 -1
- package/dist/evaluate/issue.d.ts.map +1 -1
- package/dist/evaluate/issue.js +15 -1
- package/dist/evaluate/predicate.d.ts +16 -5
- package/dist/evaluate/predicate.d.ts.map +1 -1
- package/dist/evaluate/predicate.js +20 -5
- package/dist/evaluate/shared.d.ts +59 -13
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +66 -8
- package/dist/evaluate/state.d.ts +35 -13
- package/dist/evaluate/state.d.ts.map +1 -1
- package/dist/evaluate/state.js +35 -2
- package/dist/guard/base.d.ts +79 -29
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +91 -29
- package/dist/guard/error.d.ts +10 -5
- package/dist/guard/error.d.ts.map +1 -1
- package/dist/guard/error.js +10 -5
- 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 +26 -11
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +30 -11
- package/dist/guard/props.d.ts +27 -3
- package/dist/guard/props.d.ts.map +1 -1
- package/dist/guard/props.js +27 -3
- package/dist/guard/read.d.ts +62 -9
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +83 -10
- package/dist/guard/registry.d.ts +12 -2
- package/dist/guard/registry.d.ts.map +1 -1
- package/dist/guard/registry.js +15 -3
- package/dist/guard/string.d.ts +33 -13
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +37 -13
- package/dist/guard/types.d.ts +92 -40
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/types.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/index.d.ts +42 -6
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +51 -8
- package/dist/ir/builder.d.ts +16 -126
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +77 -137
- package/dist/ir/freeze.d.ts +4 -0
- package/dist/ir/freeze.d.ts.map +1 -1
- package/dist/ir/freeze.js +59 -0
- package/dist/ir/index.d.ts +3 -1
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js +2 -0
- package/dist/ir/regexp.d.ts +2 -0
- package/dist/ir/regexp.d.ts.map +1 -1
- package/dist/ir/regexp.js +2 -0
- package/dist/ir/types.d.ts +90 -55
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/types.js +2 -0
- package/dist/ir/validate.d.ts +8 -1
- package/dist/ir/validate.d.ts.map +1 -1
- package/dist/ir/validate.js +477 -61
- package/dist/issue/index.d.ts +41 -9
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +61 -11
- package/dist/json-schema/emit-combinator.d.ts +44 -4
- package/dist/json-schema/emit-combinator.d.ts.map +1 -1
- package/dist/json-schema/emit-combinator.js +44 -4
- package/dist/json-schema/emit-composite.d.ts +10 -0
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +15 -1
- package/dist/json-schema/emit-scalar.d.ts +26 -3
- package/dist/json-schema/emit-scalar.d.ts.map +1 -1
- package/dist/json-schema/emit-scalar.js +70 -9
- package/dist/json-schema/emit-types.d.ts +11 -1
- package/dist/json-schema/emit-types.d.ts.map +1 -1
- package/dist/json-schema/emit-types.js +2 -0
- package/dist/json-schema/emit.d.ts +12 -1
- package/dist/json-schema/emit.d.ts.map +1 -1
- package/dist/json-schema/emit.js +12 -1
- package/dist/json-schema/freeze.d.ts +13 -2
- package/dist/json-schema/freeze.d.ts.map +1 -1
- package/dist/json-schema/freeze.js +41 -8
- package/dist/json-schema/index.d.ts +16 -2
- package/dist/json-schema/index.d.ts.map +1 -1
- package/dist/json-schema/index.js +23 -3
- package/dist/json-schema/issue.d.ts +4 -1
- package/dist/json-schema/issue.d.ts.map +1 -1
- package/dist/json-schema/issue.js +4 -1
- package/dist/json-schema/read.d.ts +24 -3
- package/dist/json-schema/read.d.ts.map +1 -1
- package/dist/json-schema/read.js +59 -12
- package/dist/json-schema/types.d.ts +38 -15
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +2 -0
- package/dist/kind/index.d.ts +15 -28
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +15 -10
- package/dist/lower/index.d.ts +6 -1
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +411 -44
- package/dist/message/index.d.ts +46 -10
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +88 -17
- package/dist/optimize/algebraic.d.ts +54 -0
- package/dist/optimize/algebraic.d.ts.map +1 -0
- package/dist/optimize/algebraic.js +314 -0
- package/dist/optimize/compact.d.ts +8 -1
- package/dist/optimize/compact.d.ts.map +1 -1
- package/dist/optimize/compact.js +13 -2
- package/dist/optimize/domain.d.ts +16 -0
- package/dist/optimize/domain.d.ts.map +1 -0
- package/dist/optimize/domain.js +615 -0
- package/dist/optimize/fold-boolean.d.ts +17 -2
- package/dist/optimize/fold-boolean.d.ts.map +1 -1
- package/dist/optimize/fold-boolean.js +59 -14
- package/dist/optimize/fold-common.d.ts +43 -8
- package/dist/optimize/fold-common.d.ts.map +1 -1
- package/dist/optimize/fold-common.js +37 -6
- package/dist/optimize/fold-constraints.d.ts +33 -0
- package/dist/optimize/fold-constraints.d.ts.map +1 -0
- package/dist/optimize/fold-constraints.js +484 -0
- package/dist/optimize/fold-scalar.d.ts +98 -13
- package/dist/optimize/fold-scalar.d.ts.map +1 -1
- package/dist/optimize/fold-scalar.js +98 -13
- package/dist/optimize/fold.d.ts +8 -1
- package/dist/optimize/fold.d.ts.map +1 -1
- package/dist/optimize/fold.js +22 -2
- package/dist/optimize/index.d.ts +9 -1
- package/dist/optimize/index.d.ts.map +1 -1
- package/dist/optimize/index.js +18 -3
- package/dist/optimize/map-node.d.ts +3 -1
- package/dist/optimize/map-node.d.ts.map +1 -1
- package/dist/optimize/map-node.js +45 -3
- package/dist/optimize/peephole.d.ts +16 -0
- package/dist/optimize/peephole.d.ts.map +1 -0
- package/dist/optimize/peephole.js +254 -0
- package/dist/optimize/remap.d.ts +2 -0
- package/dist/optimize/remap.d.ts.map +1 -1
- package/dist/optimize/remap.js +2 -0
- package/dist/optimize/rewrite.d.ts +13 -8
- package/dist/optimize/rewrite.d.ts.map +1 -1
- package/dist/optimize/rewrite.js +13 -8
- package/dist/plan/cache.d.ts +9 -3
- package/dist/plan/cache.d.ts.map +1 -1
- package/dist/plan/cache.js +21 -5
- package/dist/plan/index.d.ts +2 -0
- package/dist/plan/index.d.ts.map +1 -1
- package/dist/plan/index.js +2 -0
- package/dist/plan/predicate.d.ts +2 -0
- package/dist/plan/predicate.d.ts.map +1 -1
- package/dist/plan/predicate.js +268 -29
- package/dist/plan/schema-predicate.d.ts +6 -0
- package/dist/plan/schema-predicate.d.ts.map +1 -1
- package/dist/plan/schema-predicate.js +117 -13
- package/dist/plan/types.d.ts +2 -0
- package/dist/plan/types.d.ts.map +1 -1
- package/dist/plan/types.js +2 -0
- package/dist/result/index.d.ts +19 -5
- package/dist/result/index.d.ts.map +1 -1
- package/dist/result/index.js +10 -2
- package/dist/schema/common.d.ts +69 -6
- package/dist/schema/common.d.ts.map +1 -1
- package/dist/schema/common.js +104 -10
- package/dist/schema/freeze.d.ts +4 -0
- package/dist/schema/freeze.d.ts.map +1 -1
- package/dist/schema/freeze.js +18 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +3 -0
- package/dist/schema/lazy.d.ts +4 -0
- package/dist/schema/lazy.d.ts.map +1 -1
- package/dist/schema/lazy.js +4 -0
- package/dist/schema/literal.d.ts +7 -1
- package/dist/schema/literal.d.ts.map +1 -1
- package/dist/schema/literal.js +7 -1
- package/dist/schema/types.d.ts +20 -96
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +5 -1
- package/dist/schema/undefined.d.ts +17 -0
- package/dist/schema/undefined.d.ts.map +1 -0
- package/dist/schema/undefined.js +72 -0
- package/dist/schema/validate.d.ts +8 -1
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +146 -55
- package/docs/api.md +57 -0
- package/docs/assets/benchmark-headline.svg +163 -0
- package/docs/engine-notes.md +58 -15
- package/docs/index.html +130 -110
- package/package.json +65 -65
|
@@ -1,18 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file check-composite.ts
|
|
3
3
|
* @brief Composite diagnostic schema interpreters.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import { ObjectModeTag, PresenceTag, SchemaTag } from "../kind/index.js";
|
|
8
|
+
import { schemaCanAcceptUndefined } from "../schema/index.js";
|
|
6
9
|
import { pushIssue } from "./issue.js";
|
|
7
|
-
import { actualType, findDiscriminatedUnionCase, hasObjectKey, isDataPropertyDescriptor, isPlainRecord, isStrictTrue, literalToExpected, readOwnDataProperty } from "./shared.js";
|
|
10
|
+
import { actualType, findDiscriminatedUnionCase, hasObjectKey, isArrayIndexKey, isDataPropertyDescriptor, isPlainRecord, isStrictTrue, literalToExpected, readOwnDataProperty } from "./shared.js";
|
|
8
11
|
/**
|
|
9
12
|
* @brief collect array issues.
|
|
13
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
14
|
+
* aligned with compiled behavior.
|
|
15
|
+
* @param item Schema applied to each logical array slot.
|
|
16
|
+
* @param value Candidate value supplied by the caller.
|
|
17
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
18
|
+
* @param issues Output issue buffer.
|
|
19
|
+
* @param state Shared recursion and cycle state.
|
|
20
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
21
|
+
* @post Every pushed path segment is popped before return.
|
|
10
22
|
*/
|
|
11
23
|
export function collectArrayIssues(item, value, path, issues, state, collectChild) {
|
|
12
24
|
if (!Array.isArray(value)) {
|
|
13
25
|
pushIssue(path, issues, "expected_array", "array", actualType(value));
|
|
14
26
|
return;
|
|
15
27
|
}
|
|
28
|
+
if (schemaCanAcceptUndefined(item)) {
|
|
29
|
+
/*
|
|
30
|
+
* A sparse hole is observationally undefined for this item schema. Walking
|
|
31
|
+
* present descriptors keeps huge sparse inputs proportional to stored
|
|
32
|
+
* slots while preserving accessor rejection.
|
|
33
|
+
*/
|
|
34
|
+
collectPresentArrayIssues(item, value, path, issues, state, collectChild);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
/*
|
|
38
|
+
* When undefined is not valid, each missing descriptor is a real validation
|
|
39
|
+
* failure. The length loop keeps diagnostics tied to the failing index.
|
|
40
|
+
*/
|
|
16
41
|
for (let index = 0; index < value.length; index += 1) {
|
|
17
42
|
const itemProperty = readArrayIndexDataProperty(value, index);
|
|
18
43
|
path.push(index);
|
|
@@ -25,8 +50,55 @@ export function collectArrayIssues(item, value, path, issues, state, collectChil
|
|
|
25
50
|
path.pop();
|
|
26
51
|
}
|
|
27
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* @brief collect present array issues.
|
|
55
|
+
* @details Holes are equivalent to `undefined` when the item schema accepts it,
|
|
56
|
+
* so only actual own index slots need descriptor checks and child validation.
|
|
57
|
+
* @param item Schema applied to each present own index.
|
|
58
|
+
* @param value Array already proven by the caller.
|
|
59
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
60
|
+
* @param issues Output issue buffer.
|
|
61
|
+
* @param state Shared recursion and cycle state.
|
|
62
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
63
|
+
* @post Non-index own properties are ignored to match normal array iteration.
|
|
64
|
+
*/
|
|
65
|
+
function collectPresentArrayIssues(item, value, path, issues, state, collectChild) {
|
|
66
|
+
const keys = Object.getOwnPropertyNames(value);
|
|
67
|
+
for (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {
|
|
68
|
+
const key = keys[keyIndex];
|
|
69
|
+
if (key === undefined || !isArrayIndexKey(key, value.length)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
/*
|
|
73
|
+
* Descriptor lookup is still mandatory on present indexes. It blocks
|
|
74
|
+
* getter-backed slots without invoking user code during validation.
|
|
75
|
+
*/
|
|
76
|
+
const itemProperty = readArrayKeyDataProperty(value, key);
|
|
77
|
+
if (itemProperty === undefined) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const index = Number(key);
|
|
81
|
+
path.push(index);
|
|
82
|
+
if (itemProperty === null) {
|
|
83
|
+
pushIssue(path, issues, "expected_array", "data property", "accessor");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
collectChild(item, itemProperty.value, path, issues, state);
|
|
87
|
+
}
|
|
88
|
+
path.pop();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
28
91
|
/**
|
|
29
92
|
* @brief collect tuple issues.
|
|
93
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
94
|
+
* aligned with compiled behavior.
|
|
95
|
+
* @param items Tuple item schemas.
|
|
96
|
+
* @param value Candidate runtime value.
|
|
97
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
98
|
+
* @param issues Output issue buffer.
|
|
99
|
+
* @param state Shared recursion and cycle state.
|
|
100
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
101
|
+
* @post Every pushed tuple index is popped before return.
|
|
30
102
|
*/
|
|
31
103
|
export function collectTupleIssues(items, value, path, issues, state, collectChild) {
|
|
32
104
|
if (!Array.isArray(value)) {
|
|
@@ -37,6 +109,10 @@ export function collectTupleIssues(items, value, path, issues, state, collectChi
|
|
|
37
109
|
pushIssue(path, issues, "expected_tuple_length", `length ${String(items.length)}`, `length ${String(value.length)}`);
|
|
38
110
|
}
|
|
39
111
|
const count = value.length < items.length ? value.length : items.length;
|
|
112
|
+
/*
|
|
113
|
+
* Length mismatch is reported once, then overlapping indexes are still
|
|
114
|
+
* diagnosed so callers get useful nested errors for present slots.
|
|
115
|
+
*/
|
|
40
116
|
for (let index = 0; index < count; index += 1) {
|
|
41
117
|
const item = items[index];
|
|
42
118
|
if (item === undefined) {
|
|
@@ -54,12 +130,25 @@ export function collectTupleIssues(items, value, path, issues, state, collectChi
|
|
|
54
130
|
}
|
|
55
131
|
}
|
|
56
132
|
/**
|
|
57
|
-
* @brief
|
|
133
|
+
* @brief Read one array index for diagnostic collection.
|
|
58
134
|
* @details Reads an array element through its descriptor so validation does not execute getters.
|
|
135
|
+
* @param value Array being inspected.
|
|
136
|
+
* @param index Numeric array index.
|
|
59
137
|
* @returns Data descriptor for elements, undefined for holes, and null for accessors.
|
|
60
138
|
*/
|
|
61
139
|
function readArrayIndexDataProperty(value, index) {
|
|
62
|
-
|
|
140
|
+
return readArrayKeyDataProperty(value, String(index));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @brief Read one canonical array index key for diagnostic collection.
|
|
144
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
145
|
+
* aligned with compiled behavior.
|
|
146
|
+
* @param value Array being inspected.
|
|
147
|
+
* @param key Canonical array index key.
|
|
148
|
+
* @returns Data descriptor for elements, undefined for holes, and null for accessors.
|
|
149
|
+
*/
|
|
150
|
+
function readArrayKeyDataProperty(value, key) {
|
|
151
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
63
152
|
if (descriptor === undefined) {
|
|
64
153
|
return undefined;
|
|
65
154
|
}
|
|
@@ -70,6 +159,15 @@ function readArrayIndexDataProperty(value, index) {
|
|
|
70
159
|
}
|
|
71
160
|
/**
|
|
72
161
|
* @brief collect record issues.
|
|
162
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
163
|
+
* aligned with compiled behavior.
|
|
164
|
+
* @param item Schema applied to each own enumerable record value.
|
|
165
|
+
* @param value Candidate runtime value.
|
|
166
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
167
|
+
* @param issues Output issue buffer.
|
|
168
|
+
* @param state Shared recursion and cycle state.
|
|
169
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
170
|
+
* @post Every pushed record key is popped before return.
|
|
73
171
|
*/
|
|
74
172
|
export function collectRecordIssues(item, value, path, issues, state, collectChild) {
|
|
75
173
|
if (!isPlainRecord(value)) {
|
|
@@ -77,6 +175,10 @@ export function collectRecordIssues(item, value, path, issues, state, collectChi
|
|
|
77
175
|
return;
|
|
78
176
|
}
|
|
79
177
|
const keys = Object.keys(value);
|
|
178
|
+
/*
|
|
179
|
+
* Records intentionally validate enumerable own string keys. Symbols and
|
|
180
|
+
* non-enumerable slots are outside record value semantics.
|
|
181
|
+
*/
|
|
80
182
|
for (let index = 0; index < keys.length; index += 1) {
|
|
81
183
|
const key = keys[index];
|
|
82
184
|
if (key === undefined) {
|
|
@@ -95,6 +197,15 @@ export function collectRecordIssues(item, value, path, issues, state, collectChi
|
|
|
95
197
|
}
|
|
96
198
|
/**
|
|
97
199
|
* @brief collect object issues.
|
|
200
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
201
|
+
* aligned with compiled behavior.
|
|
202
|
+
* @param schema Object schema with entries and object mode.
|
|
203
|
+
* @param value Candidate runtime value.
|
|
204
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
205
|
+
* @param issues Output issue buffer.
|
|
206
|
+
* @param state Shared recursion and cycle state.
|
|
207
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
208
|
+
* @post Every pushed object key is popped before return.
|
|
98
209
|
*/
|
|
99
210
|
export function collectObjectIssues(schema, value, path, issues, state, collectChild) {
|
|
100
211
|
if (!isPlainRecord(value)) {
|
|
@@ -113,6 +224,11 @@ export function collectObjectIssues(schema, value, path, issues, state, collectC
|
|
|
113
224
|
if (property === undefined) {
|
|
114
225
|
if (entry.presence === PresenceTag.Optional &&
|
|
115
226
|
!Object.prototype.hasOwnProperty.call(record, entry.key)) {
|
|
227
|
+
/*
|
|
228
|
+
* Missing optional key is valid. An own accessor at the same key
|
|
229
|
+
* is not valid because readOwnDataProperty would have returned
|
|
230
|
+
* undefined while hasOwnProperty remains true.
|
|
231
|
+
*/
|
|
116
232
|
path.pop();
|
|
117
233
|
continue;
|
|
118
234
|
}
|
|
@@ -129,6 +245,10 @@ export function collectObjectIssues(schema, value, path, issues, state, collectC
|
|
|
129
245
|
path.pop();
|
|
130
246
|
}
|
|
131
247
|
if (schema.mode === ObjectModeTag.Strict) {
|
|
248
|
+
/*
|
|
249
|
+
* Strict objects reject symbol and non-enumerable extras as well, so
|
|
250
|
+
* Reflect.ownKeys is required instead of Object.keys.
|
|
251
|
+
*/
|
|
132
252
|
const keys = Reflect.ownKeys(record);
|
|
133
253
|
for (let index = 0; index < keys.length; index += 1) {
|
|
134
254
|
const key = keys[index];
|
|
@@ -143,6 +263,15 @@ export function collectObjectIssues(schema, value, path, issues, state, collectC
|
|
|
143
263
|
}
|
|
144
264
|
/**
|
|
145
265
|
* @brief collect discriminated union issues.
|
|
266
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
267
|
+
* aligned with compiled behavior.
|
|
268
|
+
* @param key Discriminant property key.
|
|
269
|
+
* @param cases Closed discriminated union cases.
|
|
270
|
+
* @param value Candidate runtime value.
|
|
271
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
272
|
+
* @param issues Output issue buffer.
|
|
273
|
+
* @param state Shared recursion and cycle state.
|
|
274
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
146
275
|
*/
|
|
147
276
|
export function collectDiscriminatedUnionIssues(key, cases, value, path, issues, state, collectChild) {
|
|
148
277
|
if (!isPlainRecord(value)) {
|
|
@@ -151,6 +280,10 @@ export function collectDiscriminatedUnionIssues(key, cases, value, path, issues,
|
|
|
151
280
|
}
|
|
152
281
|
const discriminantProperty = readOwnDataProperty(value, key);
|
|
153
282
|
if (discriminantProperty === undefined) {
|
|
283
|
+
/*
|
|
284
|
+
* The discriminant must be an own data property. Prototype values and
|
|
285
|
+
* accessors are rejected before branch selection.
|
|
286
|
+
*/
|
|
154
287
|
path.push(key);
|
|
155
288
|
pushIssue(path, issues, "expected_discriminant", "data property", "missing or accessor");
|
|
156
289
|
path.pop();
|
|
@@ -174,11 +307,26 @@ export function collectDiscriminatedUnionIssues(key, cases, value, path, issues,
|
|
|
174
307
|
}
|
|
175
308
|
/**
|
|
176
309
|
* @brief collect refine issues.
|
|
310
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
311
|
+
* aligned with compiled behavior.
|
|
312
|
+
* @param inner Schema validated before the predicate runs.
|
|
313
|
+
* @param predicate User predicate that must return true.
|
|
314
|
+
* @param name Refinement name used in diagnostics.
|
|
315
|
+
* @param value Candidate runtime value.
|
|
316
|
+
* @param path Mutable path stack reused by the diagnostic walker.
|
|
317
|
+
* @param issues Output issue buffer.
|
|
318
|
+
* @param state Shared recursion and cycle state.
|
|
319
|
+
* @param collectChild Dispatcher for nested schema diagnostics.
|
|
177
320
|
*/
|
|
178
321
|
export function collectRefineIssues(inner, predicate, name, value, path, issues, state, collectChild) {
|
|
179
322
|
const before = issues.length;
|
|
180
323
|
collectChild(inner, value, path, issues, state);
|
|
181
324
|
if (issues.length === before && !isStrictTrue(predicate(value))) {
|
|
325
|
+
/*
|
|
326
|
+
* Refinement predicates run only after the inner schema produced no new
|
|
327
|
+
* issues. That keeps structural failures more specific than predicate
|
|
328
|
+
* failures.
|
|
329
|
+
*/
|
|
182
330
|
pushIssue(path, issues, "expected_refinement", name, actualType(value));
|
|
183
331
|
}
|
|
184
332
|
}
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file check-scalar.ts
|
|
3
3
|
* @brief Scalar diagnostic schema interpreters.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import { SchemaTag } from "../kind/index.js";
|
|
6
8
|
import type { Issue, PathSegment } from "../issue/index.js";
|
|
7
9
|
import { type Schema } from "../schema/index.js";
|
|
8
10
|
/**
|
|
9
11
|
* @brief collect string issues.
|
|
12
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
13
|
+
* aligned with compiled behavior.
|
|
14
|
+
* @param schema String schema with scalar checks.
|
|
15
|
+
* @param value Candidate runtime value.
|
|
16
|
+
* @param path Current diagnostic path.
|
|
17
|
+
* @param issues Output issue buffer.
|
|
18
|
+
* @post Pattern checks reset lastIndex before testing.
|
|
10
19
|
*/
|
|
11
20
|
export declare function collectStringIssues(schema: Extract<Schema, {
|
|
12
21
|
readonly tag: typeof SchemaTag.String;
|
|
13
22
|
}>, value: unknown, path: PathSegment[], issues: Issue[]): void;
|
|
14
23
|
/**
|
|
15
24
|
* @brief collect number issues.
|
|
25
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
26
|
+
* aligned with compiled behavior.
|
|
27
|
+
* @param schema Number schema with scalar checks.
|
|
28
|
+
* @param value Candidate runtime value.
|
|
29
|
+
* @param path Current diagnostic path.
|
|
30
|
+
* @param issues Output issue buffer.
|
|
31
|
+
* @post Bound checks run only after the finite-number guard succeeds.
|
|
16
32
|
*/
|
|
17
33
|
export declare function collectNumberIssues(schema: Extract<Schema, {
|
|
18
34
|
readonly tag: typeof SchemaTag.Number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-scalar.d.ts","sourceRoot":"","sources":["../../src/evaluate/check-scalar.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"check-scalar.d.ts","sourceRoot":"","sources":["../../src/evaluate/check-scalar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEH,SAAS,EAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAEH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAI5B;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,GAChB,IAAI,CA4DN;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,GAChB,IAAI,CA6CN"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file check-scalar.ts
|
|
3
3
|
* @brief Scalar diagnostic schema interpreters.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import { NumberCheckTag, SchemaTag, StringCheckTag } from "../kind/index.js";
|
|
6
8
|
import { UUID_PATTERN } from "../schema/index.js";
|
|
@@ -8,6 +10,13 @@ import { pushIssue } from "./issue.js";
|
|
|
8
10
|
import { actualType } from "./shared.js";
|
|
9
11
|
/**
|
|
10
12
|
* @brief collect string issues.
|
|
13
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
14
|
+
* aligned with compiled behavior.
|
|
15
|
+
* @param schema String schema with scalar checks.
|
|
16
|
+
* @param value Candidate runtime value.
|
|
17
|
+
* @param path Current diagnostic path.
|
|
18
|
+
* @param issues Output issue buffer.
|
|
19
|
+
* @post Pattern checks reset lastIndex before testing.
|
|
11
20
|
*/
|
|
12
21
|
export function collectStringIssues(schema, value, path, issues) {
|
|
13
22
|
if (typeof value !== "string") {
|
|
@@ -15,6 +24,10 @@ export function collectStringIssues(schema, value, path, issues) {
|
|
|
15
24
|
return;
|
|
16
25
|
}
|
|
17
26
|
const checks = schema.checks;
|
|
27
|
+
/*
|
|
28
|
+
* Length and pattern checks only run after the type guard. That keeps
|
|
29
|
+
* diagnostics deterministic and avoids property reads on non-string values.
|
|
30
|
+
*/
|
|
18
31
|
for (let index = 0; index < checks.length; index += 1) {
|
|
19
32
|
const check = checks[index];
|
|
20
33
|
if (check === undefined) {
|
|
@@ -32,12 +45,20 @@ export function collectStringIssues(schema, value, path, issues) {
|
|
|
32
45
|
}
|
|
33
46
|
break;
|
|
34
47
|
case StringCheckTag.Regex:
|
|
48
|
+
/*
|
|
49
|
+
* User regexps may be global or sticky. Resetting lastIndex makes
|
|
50
|
+
* repeated validation calls independent from prior tests.
|
|
51
|
+
*/
|
|
35
52
|
check.regex.lastIndex = 0;
|
|
36
53
|
if (!check.regex.test(value)) {
|
|
37
54
|
pushIssue(path, issues, "expected_pattern", check.name, "string");
|
|
38
55
|
}
|
|
39
56
|
break;
|
|
40
57
|
case StringCheckTag.Uuid:
|
|
58
|
+
/*
|
|
59
|
+
* UUID uses the shared library pattern but follows the same reset
|
|
60
|
+
* discipline as user regexps.
|
|
61
|
+
*/
|
|
41
62
|
UUID_PATTERN.lastIndex = 0;
|
|
42
63
|
if (!UUID_PATTERN.test(value)) {
|
|
43
64
|
pushIssue(path, issues, "expected_pattern", "uuid", "string");
|
|
@@ -48,6 +69,13 @@ export function collectStringIssues(schema, value, path, issues) {
|
|
|
48
69
|
}
|
|
49
70
|
/**
|
|
50
71
|
* @brief collect number issues.
|
|
72
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
73
|
+
* aligned with compiled behavior.
|
|
74
|
+
* @param schema Number schema with scalar checks.
|
|
75
|
+
* @param value Candidate runtime value.
|
|
76
|
+
* @param path Current diagnostic path.
|
|
77
|
+
* @param issues Output issue buffer.
|
|
78
|
+
* @post Bound checks run only after the finite-number guard succeeds.
|
|
51
79
|
*/
|
|
52
80
|
export function collectNumberIssues(schema, value, path, issues) {
|
|
53
81
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -55,6 +83,10 @@ export function collectNumberIssues(schema, value, path, issues) {
|
|
|
55
83
|
return;
|
|
56
84
|
}
|
|
57
85
|
const checks = schema.checks;
|
|
86
|
+
/*
|
|
87
|
+
* Integer and bound diagnostics are separated so invalid values report all
|
|
88
|
+
* failed number constraints after the base type has been proven.
|
|
89
|
+
*/
|
|
58
90
|
for (let index = 0; index < checks.length; index += 1) {
|
|
59
91
|
const check = checks[index];
|
|
60
92
|
if (check === undefined) {
|
package/dist/evaluate/check.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file check.ts
|
|
3
3
|
* @brief Diagnostic schema interpreter dispatcher.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import type { CheckResult } from "../issue/index.js";
|
|
6
8
|
import { type Schema } from "../schema/index.js";
|
|
7
9
|
/**
|
|
8
10
|
* @brief check schema.
|
|
11
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
12
|
+
* aligned with compiled behavior.
|
|
13
|
+
* @param schema Schema used to validate the input.
|
|
14
|
+
* @param value Candidate runtime value.
|
|
15
|
+
* @returns Frozen success or diagnostic failure result.
|
|
9
16
|
*/
|
|
10
17
|
export declare function checkSchema<TValue>(schema: Schema, value: unknown): CheckResult<TValue>;
|
|
11
18
|
//# sourceMappingURL=check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/evaluate/check.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/evaluate/check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAEH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AA0B5B;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAC9B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACf,WAAW,CAAC,MAAM,CAAC,CAmBrB"}
|
package/dist/evaluate/check.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file check.ts
|
|
3
3
|
* @brief Diagnostic schema interpreter dispatcher.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import { SchemaTag } from "../kind/index.js";
|
|
6
8
|
import { freezeIssueArray } from "../issue/index.js";
|
|
@@ -14,25 +16,51 @@ import { actualType, literalToExpected } from "./shared.js";
|
|
|
14
16
|
import { enterValidation, leaveValidation, makeValidationState } from "./state.js";
|
|
15
17
|
/**
|
|
16
18
|
* @brief check schema.
|
|
19
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
20
|
+
* aligned with compiled behavior.
|
|
21
|
+
* @param schema Schema used to validate the input.
|
|
22
|
+
* @param value Candidate runtime value.
|
|
23
|
+
* @returns Frozen success or diagnostic failure result.
|
|
17
24
|
*/
|
|
18
25
|
export function checkSchema(schema, value) {
|
|
19
26
|
if (isSchemaWithState(schema, value, makeValidationState())) {
|
|
20
27
|
return ok(value);
|
|
21
28
|
}
|
|
29
|
+
/*
|
|
30
|
+
* The boolean predicate runs first to keep the valid path allocation-light.
|
|
31
|
+
* Diagnostics are collected only after failure, matching compiled check().
|
|
32
|
+
*/
|
|
22
33
|
const issues = [];
|
|
23
34
|
const path = [];
|
|
24
35
|
collectIssues(schema, value, path, issues, makeValidationState());
|
|
25
36
|
if (issues.length === 0) {
|
|
37
|
+
/*
|
|
38
|
+
* Refine predicates can fail without emitting a structural issue. Add a
|
|
39
|
+
* conservative fallback so callers never receive an empty failure.
|
|
40
|
+
*/
|
|
26
41
|
pushIssue(path, issues, "expected_refinement", "matching schema", actualType(value));
|
|
27
42
|
}
|
|
28
43
|
return err(freezeIssueArray(issues));
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
46
|
* @brief collect issues.
|
|
47
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
48
|
+
* aligned with compiled behavior.
|
|
49
|
+
* @param schema Schema node being diagnosed.
|
|
50
|
+
* @param value Candidate runtime value.
|
|
51
|
+
* @param path Mutable path stack shared by recursive diagnostic calls.
|
|
52
|
+
* @param issues Output issue buffer.
|
|
53
|
+
* @param state Shared recursion, cycle, and graph execution state.
|
|
54
|
+
* @post Calls `leaveValidation` only when `enterValidation` returned entered.
|
|
32
55
|
*/
|
|
33
56
|
function collectIssues(schema, value, path, issues, state) {
|
|
34
57
|
const entered = enterValidation(schema, value, state);
|
|
35
58
|
if (entered === "cycle") {
|
|
59
|
+
/*
|
|
60
|
+
* A repeated schema/value pair means the recursive structure is already
|
|
61
|
+
* being validated higher on the stack. Treat it as provisionally valid
|
|
62
|
+
* to break cycles without fabricating duplicate diagnostics.
|
|
63
|
+
*/
|
|
36
64
|
return;
|
|
37
65
|
}
|
|
38
66
|
if (entered === "budget") {
|
|
@@ -44,6 +72,13 @@ function collectIssues(schema, value, path, issues, state) {
|
|
|
44
72
|
}
|
|
45
73
|
/**
|
|
46
74
|
* @brief collect issues inner.
|
|
75
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
76
|
+
* aligned with compiled behavior.
|
|
77
|
+
* @param schema Schema node being diagnosed after entry admission.
|
|
78
|
+
* @param value Candidate runtime value.
|
|
79
|
+
* @param path Mutable path stack shared by recursive diagnostic calls.
|
|
80
|
+
* @param issues Output issue buffer.
|
|
81
|
+
* @param state Shared recursion, cycle, and graph execution state.
|
|
47
82
|
*/
|
|
48
83
|
function collectIssuesInner(schema, value, path, issues, state) {
|
|
49
84
|
switch (schema.tag) {
|
|
@@ -96,6 +131,10 @@ function collectIssuesInner(schema, value, path, issues, state) {
|
|
|
96
131
|
}
|
|
97
132
|
return;
|
|
98
133
|
case SchemaTag.Intersection:
|
|
134
|
+
/*
|
|
135
|
+
* Intersections accumulate diagnostics from both sides because both
|
|
136
|
+
* schemas must accept the same value.
|
|
137
|
+
*/
|
|
99
138
|
collectIssues(schema.left, value, path, issues, state);
|
|
100
139
|
collectIssues(schema.right, value, path, issues, state);
|
|
101
140
|
return;
|
|
@@ -117,6 +156,10 @@ function collectIssuesInner(schema, value, path, issues, state) {
|
|
|
117
156
|
collectIssues(schema.inner, value, path, issues, state);
|
|
118
157
|
return;
|
|
119
158
|
case SchemaTag.Lazy:
|
|
159
|
+
/*
|
|
160
|
+
* Lazy schemas resolve through the shared state so recursive lazy
|
|
161
|
+
* references are tracked consistently with predicate evaluation.
|
|
162
|
+
*/
|
|
120
163
|
collectIssues(resolveLazySchema(schema, state.resolving), value, path, issues, state);
|
|
121
164
|
return;
|
|
122
165
|
case SchemaTag.Refine:
|
package/dist/evaluate/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file index.ts
|
|
3
3
|
* @brief Public evaluation module aggregation.
|
|
4
|
+
* @details This barrel keeps public import paths stable while implementation files remain
|
|
5
|
+
* split by responsibility.
|
|
4
6
|
*/
|
|
5
7
|
export { checkSchema } from "./check.js";
|
|
6
8
|
export { isSchema } from "./predicate.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluate/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluate/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/evaluate/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file index.ts
|
|
3
3
|
* @brief Public evaluation module aggregation.
|
|
4
|
+
* @details This barrel keeps public import paths stable while implementation files remain
|
|
5
|
+
* split by responsibility.
|
|
4
6
|
*/
|
|
5
7
|
export { checkSchema } from "./check.js";
|
|
6
8
|
export { isSchema } from "./predicate.js";
|
package/dist/evaluate/issue.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file issue.ts
|
|
3
3
|
* @brief Runtime validation issue construction.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import type { Issue, PathSegment } from "../issue/index.js";
|
|
6
8
|
/**
|
|
7
|
-
* @brief
|
|
9
|
+
* @brief Append one runtime validation issue.
|
|
10
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
11
|
+
* aligned with compiled behavior.
|
|
12
|
+
* @param path Mutable path stack at the failing validation point.
|
|
13
|
+
* @param issues Output issue buffer.
|
|
14
|
+
* @param code Stable issue code.
|
|
15
|
+
* @param expected Human-readable expected value, when available.
|
|
16
|
+
* @param actual Human-readable actual value, when available.
|
|
17
|
+
* @post Stores a copied path so later stack mutation cannot alter the issue.
|
|
8
18
|
*/
|
|
9
19
|
export declare function pushIssue(path: PathSegment[], issues: Issue[], code: Issue["code"], expected: string | undefined, actual: string | undefined): void;
|
|
10
20
|
//# sourceMappingURL=issue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/evaluate/issue.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/evaluate/issue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG5D;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,EACf,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GAC3B,IAAI,CAMN"}
|
package/dist/evaluate/issue.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file issue.ts
|
|
3
3
|
* @brief Runtime validation issue construction.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import { makeIssue } from "../issue/index.js";
|
|
6
8
|
/**
|
|
7
|
-
* @brief
|
|
9
|
+
* @brief Append one runtime validation issue.
|
|
10
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
11
|
+
* aligned with compiled behavior.
|
|
12
|
+
* @param path Mutable path stack at the failing validation point.
|
|
13
|
+
* @param issues Output issue buffer.
|
|
14
|
+
* @param code Stable issue code.
|
|
15
|
+
* @param expected Human-readable expected value, when available.
|
|
16
|
+
* @param actual Human-readable actual value, when available.
|
|
17
|
+
* @post Stores a copied path so later stack mutation cannot alter the issue.
|
|
8
18
|
*/
|
|
9
19
|
export function pushIssue(path, issues, code, expected, actual) {
|
|
20
|
+
/*
|
|
21
|
+
* Diagnostic walkers reuse one path stack for speed. Copying here gives each
|
|
22
|
+
* issue immutable path semantics without forcing callers to allocate eagerly.
|
|
23
|
+
*/
|
|
10
24
|
issues.push(makeIssue(path.slice(), code, expected, actual, undefined));
|
|
11
25
|
}
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file predicate.ts
|
|
3
3
|
* @brief Compatibility entry points for IR-backed predicate execution.
|
|
4
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
5
|
+
* aligned with compiled behavior.
|
|
4
6
|
*/
|
|
5
7
|
import type { Schema } from "../schema/index.js";
|
|
6
8
|
import type { ValidationState } from "./state.js";
|
|
7
9
|
/**
|
|
8
|
-
* @brief
|
|
9
|
-
* @details
|
|
10
|
+
* @brief Execute a schema predicate through its optimized validation plan.
|
|
11
|
+
* @details This is the compatibility entry point used by guards that need a
|
|
12
|
+
* boolean answer without diagnostics.
|
|
13
|
+
* @param schema Schema used to validate the input.
|
|
14
|
+
* @param value Candidate runtime value.
|
|
10
15
|
* @returns True when the input satisfies the schema.
|
|
11
16
|
*/
|
|
12
17
|
export declare function isSchema(schema: Schema, value: unknown): boolean;
|
|
13
18
|
/**
|
|
14
|
-
* @brief
|
|
19
|
+
* @brief Execute a schema predicate with caller-owned recursion state.
|
|
15
20
|
* @details Shares recursion and cycle tracking with nested IR nodes.
|
|
16
|
-
* @
|
|
21
|
+
* @param schema Schema used to validate the input.
|
|
22
|
+
* @param value Candidate runtime value.
|
|
23
|
+
* @param state Validation state from an outer diagnostic or predicate run.
|
|
24
|
+
* @returns True when the input satisfies the schema under the shared state.
|
|
17
25
|
*/
|
|
18
26
|
export declare function isSchemaWithState(schema: Schema, value: unknown, state: ValidationState): boolean;
|
|
19
27
|
/**
|
|
20
|
-
* @brief
|
|
28
|
+
* @brief Execute union probing with shared recursion state.
|
|
21
29
|
* @details Preserves the historical helper used by diagnostic generation while
|
|
22
30
|
* routing each union option through IR-backed validation.
|
|
31
|
+
* @param options Union option schemas.
|
|
32
|
+
* @param value Candidate runtime value.
|
|
33
|
+
* @param state Validation state shared across option probes.
|
|
23
34
|
* @returns True when at least one option accepts the value.
|
|
24
35
|
*/
|
|
25
36
|
export declare function isUnionSchema(options: readonly Schema[], value: unknown, state: ValidationState): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/evaluate/predicate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/evaluate/predicate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,eAAe,GACvB,OAAO,CAET;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CACzB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,eAAe,GACvB,OAAO,CAaT"}
|