typesea 0.1.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 +85 -6
- package/README.md +143 -28
- 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 +19 -3
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +115 -17
- 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 +43 -9
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +100 -17
- package/dist/builders/index.d.ts +8 -5
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +7 -4
- package/dist/builders/modifier.d.ts +36 -5
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +52 -5
- package/dist/builders/object/guard.d.ts +72 -24
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +139 -29
- package/dist/builders/object/index.d.ts +4 -2
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +3 -1
- package/dist/builders/object/schema.d.ts +88 -11
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +290 -23
- package/dist/builders/object/types.d.ts +20 -31
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/object/types.js +2 -0
- 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 +49 -9
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +87 -9
- package/dist/builders/table.d.ts +35 -5
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +35 -5
- package/dist/builders/types.d.ts +20 -4
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +2 -0
- package/dist/compile/check-composite.d.ts +25 -2
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +699 -27
- package/dist/compile/check-scalar.d.ts +88 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +570 -3
- package/dist/compile/check.d.ts +12 -0
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +62 -3
- package/dist/compile/context.d.ts +47 -9
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +53 -8
- 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 +4 -2
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +2272 -165
- package/dist/compile/guard.d.ts +16 -24
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +202 -72
- 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 +287 -10
- package/dist/compile/runtime.d.ts +100 -13
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +56 -6
- package/dist/compile/source.d.ts +10 -2
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +385 -26
- package/dist/compile/types.d.ts +22 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/compile/types.js +2 -0
- package/dist/decoder/index.d.ts +92 -46
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +266 -39
- package/dist/evaluate/check-composite.d.ts +111 -2
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +343 -8
- package/dist/evaluate/check-scalar.d.ts +25 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +124 -3
- package/dist/evaluate/check.d.ts +7 -0
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +62 -4
- 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 +78 -13
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +101 -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/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 +111 -31
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +165 -32
- 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/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 +4 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +4 -0
- package/dist/guard/number.d.ts +86 -11
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +159 -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 +115 -10
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +185 -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 +115 -13
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +250 -13
- package/dist/guard/types.d.ts +110 -40
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/types.js +2 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- 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 +17 -127
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +80 -137
- package/dist/ir/freeze.d.ts +4 -0
- package/dist/ir/freeze.d.ts.map +1 -1
- package/dist/ir/freeze.js +66 -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 +94 -56
- 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 +511 -61
- package/dist/issue/index.d.ts +42 -10
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +65 -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 +16 -2
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +81 -13
- 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 +124 -10
- 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 +23 -3
- 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 +45 -16
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +2 -0
- package/dist/kind/index.d.ts +40 -28
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +41 -13
- package/dist/lower/index.d.ts +6 -1
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +462 -46
- package/dist/message/index.d.ts +64 -10
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +155 -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 +619 -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 +48 -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 +34 -6
- 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 +298 -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 +382 -19
- 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 +40 -0
- package/dist/schema/index.d.ts +5 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +4 -1
- 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 +109 -100
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +13 -2
- package/dist/schema/undefined.d.ts +17 -0
- package/dist/schema/undefined.d.ts.map +1 -0
- package/dist/schema/undefined.js +77 -0
- package/dist/schema/validate.d.ts +8 -1
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +255 -57
- package/docs/api.md +128 -8
- package/docs/assets/benchmark-headline.svg +163 -0
- package/docs/engine-notes.md +62 -15
- package/docs/index.html +1340 -702
- 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 +66 -65
|
@@ -1,13 +1,22 @@
|
|
|
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
|
-
import { NumberCheckTag, SchemaTag, StringCheckTag } from "../kind/index.js";
|
|
6
|
-
import { UUID_PATTERN } from "../schema/index.js";
|
|
7
|
+
import { DateCheckTag, NumberCheckTag, SchemaTag, StringCheckTag } from "../kind/index.js";
|
|
8
|
+
import { EMAIL_PATTERN, IPV4_PATTERN, IPV6_PATTERN, ISO_DATETIME_PATTERN, ISO_DATE_PATTERN, ULID_PATTERN, URL_PATTERN, UUID_PATTERN } from "../schema/index.js";
|
|
7
9
|
import { pushIssue } from "./issue.js";
|
|
8
|
-
import { actualType } from "./shared.js";
|
|
10
|
+
import { actualType, isValidDateObject, readDateTime } 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,22 +45,111 @@ 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");
|
|
44
65
|
}
|
|
45
66
|
break;
|
|
67
|
+
case StringCheckTag.Email:
|
|
68
|
+
EMAIL_PATTERN.lastIndex = 0;
|
|
69
|
+
if (!EMAIL_PATTERN.test(value)) {
|
|
70
|
+
pushIssue(path, issues, "expected_pattern", "email", "string");
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case StringCheckTag.Url:
|
|
74
|
+
URL_PATTERN.lastIndex = 0;
|
|
75
|
+
if (!URL_PATTERN.test(value)) {
|
|
76
|
+
pushIssue(path, issues, "expected_pattern", "url", "string");
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case StringCheckTag.IsoDate:
|
|
80
|
+
ISO_DATE_PATTERN.lastIndex = 0;
|
|
81
|
+
if (!ISO_DATE_PATTERN.test(value)) {
|
|
82
|
+
pushIssue(path, issues, "expected_pattern", "iso_date", "string");
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case StringCheckTag.IsoDateTime:
|
|
86
|
+
ISO_DATETIME_PATTERN.lastIndex = 0;
|
|
87
|
+
if (!ISO_DATETIME_PATTERN.test(value)) {
|
|
88
|
+
pushIssue(path, issues, "expected_pattern", "iso_datetime", "string");
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case StringCheckTag.Ulid:
|
|
92
|
+
ULID_PATTERN.lastIndex = 0;
|
|
93
|
+
if (!ULID_PATTERN.test(value)) {
|
|
94
|
+
pushIssue(path, issues, "expected_pattern", "ulid", "string");
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
case StringCheckTag.Ipv4:
|
|
98
|
+
IPV4_PATTERN.lastIndex = 0;
|
|
99
|
+
if (!IPV4_PATTERN.test(value)) {
|
|
100
|
+
pushIssue(path, issues, "expected_pattern", "ipv4", "string");
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case StringCheckTag.Ipv6:
|
|
104
|
+
IPV6_PATTERN.lastIndex = 0;
|
|
105
|
+
if (!IPV6_PATTERN.test(value)) {
|
|
106
|
+
pushIssue(path, issues, "expected_pattern", "ipv6", "string");
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @brief Collect Date issues.
|
|
114
|
+
* @param value Candidate runtime value.
|
|
115
|
+
* @param path Current diagnostic path.
|
|
116
|
+
* @param issues Output issue buffer.
|
|
117
|
+
*/
|
|
118
|
+
export function collectDateIssues(schema, value, path, issues) {
|
|
119
|
+
if (!isValidDateObject(value)) {
|
|
120
|
+
pushIssue(path, issues, "expected_date", "valid Date", actualType(value));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const time = readDateTime(value);
|
|
124
|
+
const checks = schema.checks;
|
|
125
|
+
for (let index = 0; index < checks.length; index += 1) {
|
|
126
|
+
const check = checks[index];
|
|
127
|
+
if (check === undefined) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
switch (check.tag) {
|
|
131
|
+
case DateCheckTag.Min:
|
|
132
|
+
if (time < check.value) {
|
|
133
|
+
pushIssue(path, issues, "expected_gte", `>= ${new Date(check.value).toISOString()}`, new Date(time).toISOString());
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case DateCheckTag.Max:
|
|
137
|
+
if (time > check.value) {
|
|
138
|
+
pushIssue(path, issues, "expected_lte", `<= ${new Date(check.value).toISOString()}`, new Date(time).toISOString());
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
46
141
|
}
|
|
47
142
|
}
|
|
48
143
|
}
|
|
49
144
|
/**
|
|
50
145
|
* @brief collect number issues.
|
|
146
|
+
* @details Interpreter helpers keep safe descriptor-based reads and diagnostic collection
|
|
147
|
+
* aligned with compiled behavior.
|
|
148
|
+
* @param schema Number schema with scalar checks.
|
|
149
|
+
* @param value Candidate runtime value.
|
|
150
|
+
* @param path Current diagnostic path.
|
|
151
|
+
* @param issues Output issue buffer.
|
|
152
|
+
* @post Bound checks run only after the finite-number guard succeeds.
|
|
51
153
|
*/
|
|
52
154
|
export function collectNumberIssues(schema, value, path, issues) {
|
|
53
155
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -55,6 +157,10 @@ export function collectNumberIssues(schema, value, path, issues) {
|
|
|
55
157
|
return;
|
|
56
158
|
}
|
|
57
159
|
const checks = schema.checks;
|
|
160
|
+
/*
|
|
161
|
+
* Integer and bound diagnostics are separated so invalid values report all
|
|
162
|
+
* failed number constraints after the base type has been proven.
|
|
163
|
+
*/
|
|
58
164
|
for (let index = 0; index < checks.length; index += 1) {
|
|
59
165
|
const check = checks[index];
|
|
60
166
|
if (check === undefined) {
|
|
@@ -76,6 +182,21 @@ export function collectNumberIssues(schema, value, path, issues) {
|
|
|
76
182
|
pushIssue(path, issues, "expected_lte", `<= ${String(check.value)}`, String(value));
|
|
77
183
|
}
|
|
78
184
|
break;
|
|
185
|
+
case NumberCheckTag.Gt:
|
|
186
|
+
if (value <= check.value) {
|
|
187
|
+
pushIssue(path, issues, "expected_gt", `> ${String(check.value)}`, String(value));
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case NumberCheckTag.Lt:
|
|
191
|
+
if (value >= check.value) {
|
|
192
|
+
pushIssue(path, issues, "expected_lt", `< ${String(check.value)}`, String(value));
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case NumberCheckTag.MultipleOf:
|
|
196
|
+
if (value % check.value !== 0) {
|
|
197
|
+
pushIssue(path, issues, "expected_multiple_of", `multiple of ${String(check.value)}`, String(value));
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
79
200
|
}
|
|
80
201
|
}
|
|
81
202
|
}
|
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;AA+B5B;;;;;;;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,38 +1,66 @@
|
|
|
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";
|
|
7
9
|
import { err, ok } from "../result/index.js";
|
|
8
10
|
import { resolveLazySchema } from "../schema/index.js";
|
|
9
|
-
import { collectArrayIssues, collectDiscriminatedUnionIssues, collectObjectIssues, collectRecordIssues, collectRefineIssues, collectTupleIssues } from "./check-composite.js";
|
|
10
|
-
import { collectNumberIssues, collectStringIssues } from "./check-scalar.js";
|
|
11
|
+
import { collectArrayIssues, collectDiscriminatedUnionIssues, collectInstanceOfIssues, collectMapIssues, collectObjectIssues, collectPropertyIssues, collectRecordIssues, collectRefineIssues, collectSetIssues, collectTupleIssues } from "./check-composite.js";
|
|
12
|
+
import { collectDateIssues, collectNumberIssues, collectStringIssues } from "./check-scalar.js";
|
|
11
13
|
import { pushIssue } from "./issue.js";
|
|
12
14
|
import { isSchemaWithState, isUnionSchema } from "./predicate.js";
|
|
13
15
|
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) {
|
|
@@ -58,6 +93,9 @@ function collectIssuesInner(schema, value, path, issues, state) {
|
|
|
58
93
|
case SchemaTag.Number:
|
|
59
94
|
collectNumberIssues(schema, value, path, issues);
|
|
60
95
|
return;
|
|
96
|
+
case SchemaTag.Date:
|
|
97
|
+
collectDateIssues(schema, value, path, issues);
|
|
98
|
+
return;
|
|
61
99
|
case SchemaTag.BigInt:
|
|
62
100
|
if (typeof value !== "bigint") {
|
|
63
101
|
pushIssue(path, issues, "expected_bigint", "bigint", actualType(value));
|
|
@@ -79,14 +117,26 @@ function collectIssuesInner(schema, value, path, issues, state) {
|
|
|
79
117
|
}
|
|
80
118
|
return;
|
|
81
119
|
case SchemaTag.Array:
|
|
82
|
-
collectArrayIssues(schema
|
|
120
|
+
collectArrayIssues(schema, value, path, issues, state, collectIssues);
|
|
83
121
|
return;
|
|
84
122
|
case SchemaTag.Tuple:
|
|
85
|
-
collectTupleIssues(schema
|
|
123
|
+
collectTupleIssues(schema, value, path, issues, state, collectIssues);
|
|
86
124
|
return;
|
|
87
125
|
case SchemaTag.Record:
|
|
88
126
|
collectRecordIssues(schema.value, value, path, issues, state, collectIssues);
|
|
89
127
|
return;
|
|
128
|
+
case SchemaTag.Map:
|
|
129
|
+
collectMapIssues(schema, value, path, issues, state, collectIssues);
|
|
130
|
+
return;
|
|
131
|
+
case SchemaTag.Set:
|
|
132
|
+
collectSetIssues(schema, value, path, issues, state, collectIssues);
|
|
133
|
+
return;
|
|
134
|
+
case SchemaTag.InstanceOf:
|
|
135
|
+
collectInstanceOfIssues(schema, value, path, issues);
|
|
136
|
+
return;
|
|
137
|
+
case SchemaTag.Property:
|
|
138
|
+
collectPropertyIssues(schema, value, path, issues, state, collectIssues);
|
|
139
|
+
return;
|
|
90
140
|
case SchemaTag.Object:
|
|
91
141
|
collectObjectIssues(schema, value, path, issues, state, collectIssues);
|
|
92
142
|
return;
|
|
@@ -96,6 +146,10 @@ function collectIssuesInner(schema, value, path, issues, state) {
|
|
|
96
146
|
}
|
|
97
147
|
return;
|
|
98
148
|
case SchemaTag.Intersection:
|
|
149
|
+
/*
|
|
150
|
+
* Intersections accumulate diagnostics from both sides because both
|
|
151
|
+
* schemas must accept the same value.
|
|
152
|
+
*/
|
|
99
153
|
collectIssues(schema.left, value, path, issues, state);
|
|
100
154
|
collectIssues(schema.right, value, path, issues, state);
|
|
101
155
|
return;
|
|
@@ -117,6 +171,10 @@ function collectIssuesInner(schema, value, path, issues, state) {
|
|
|
117
171
|
collectIssues(schema.inner, value, path, issues, state);
|
|
118
172
|
return;
|
|
119
173
|
case SchemaTag.Lazy:
|
|
174
|
+
/*
|
|
175
|
+
* Lazy schemas resolve through the shared state so recursive lazy
|
|
176
|
+
* references are tracked consistently with predicate evaluation.
|
|
177
|
+
*/
|
|
120
178
|
collectIssues(resolveLazySchema(schema, state.resolving), value, path, issues, state);
|
|
121
179
|
return;
|
|
122
180
|
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"}
|
|
@@ -1,28 +1,39 @@
|
|
|
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 { executeSchemaPredicate, executeSchemaPredicateWithState } from "../plan/index.js";
|
|
6
8
|
/**
|
|
7
|
-
* @brief
|
|
8
|
-
* @details
|
|
9
|
+
* @brief Execute a schema predicate through its optimized validation plan.
|
|
10
|
+
* @details This is the compatibility entry point used by guards that need a
|
|
11
|
+
* boolean answer without diagnostics.
|
|
12
|
+
* @param schema Schema used to validate the input.
|
|
13
|
+
* @param value Candidate runtime value.
|
|
9
14
|
* @returns True when the input satisfies the schema.
|
|
10
15
|
*/
|
|
11
16
|
export function isSchema(schema, value) {
|
|
12
17
|
return executeSchemaPredicate(schema, value);
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
|
-
* @brief
|
|
20
|
+
* @brief Execute a schema predicate with caller-owned recursion state.
|
|
16
21
|
* @details Shares recursion and cycle tracking with nested IR nodes.
|
|
17
|
-
* @
|
|
22
|
+
* @param schema Schema used to validate the input.
|
|
23
|
+
* @param value Candidate runtime value.
|
|
24
|
+
* @param state Validation state from an outer diagnostic or predicate run.
|
|
25
|
+
* @returns True when the input satisfies the schema under the shared state.
|
|
18
26
|
*/
|
|
19
27
|
export function isSchemaWithState(schema, value, state) {
|
|
20
28
|
return executeSchemaPredicateWithState(schema, value, state);
|
|
21
29
|
}
|
|
22
30
|
/**
|
|
23
|
-
* @brief
|
|
31
|
+
* @brief Execute union probing with shared recursion state.
|
|
24
32
|
* @details Preserves the historical helper used by diagnostic generation while
|
|
25
33
|
* routing each union option through IR-backed validation.
|
|
34
|
+
* @param options Union option schemas.
|
|
35
|
+
* @param value Candidate runtime value.
|
|
36
|
+
* @param state Validation state shared across option probes.
|
|
26
37
|
* @returns True when at least one option accepts the value.
|
|
27
38
|
*/
|
|
28
39
|
export function isUnionSchema(options, value, state) {
|
|
@@ -30,6 +41,10 @@ export function isUnionSchema(options, value, state) {
|
|
|
30
41
|
const option = options[index];
|
|
31
42
|
if (option !== undefined &&
|
|
32
43
|
executeSchemaPredicateWithState(option, value, state)) {
|
|
44
|
+
/*
|
|
45
|
+
* Union diagnostics only need to know whether at least one branch
|
|
46
|
+
* accepts. Detailed branch diagnostics would allocate on a hot helper.
|
|
47
|
+
*/
|
|
33
48
|
return true;
|
|
34
49
|
}
|
|
35
50
|
}
|