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,15 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file emit-scalar.ts
|
|
3
3
|
* @brief Scalar TypeSea schema to JSON Schema emitters.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import { NumberCheckTag, SchemaTag, StringCheckTag } from "../kind/index.js";
|
|
6
8
|
import { UUID_PATTERN } from "../schema/index.js";
|
|
7
9
|
import { pushJsonSchemaIssue } from "./issue.js";
|
|
8
10
|
/**
|
|
9
|
-
* @brief
|
|
11
|
+
* @brief Emit TypeSea string checks into JSON Schema string keywords.
|
|
12
|
+
* @details Repeated min and max checks collapse to the strongest bounds.
|
|
13
|
+
* Regular expressions are emitted only when their flags can be preserved by the
|
|
14
|
+
* JSON Schema `pattern` keyword; unsupported flags are reported as issues.
|
|
15
|
+
* @param schema String schema to emit.
|
|
16
|
+
* @param path Mutable issue path stack owned by the export walk.
|
|
17
|
+
* @param issues Mutable export issue buffer.
|
|
18
|
+
* @returns JSON Schema string object.
|
|
10
19
|
*/
|
|
11
20
|
export function emitString(schema, path, issues) {
|
|
12
21
|
const result = { type: "string" };
|
|
22
|
+
const patterns = [];
|
|
13
23
|
const checks = schema.checks;
|
|
14
24
|
for (let index = 0; index < checks.length; index += 1) {
|
|
15
25
|
const check = checks[index];
|
|
@@ -18,29 +28,41 @@ export function emitString(schema, path, issues) {
|
|
|
18
28
|
}
|
|
19
29
|
switch (check.tag) {
|
|
20
30
|
case StringCheckTag.Min:
|
|
21
|
-
result.minLength =
|
|
31
|
+
result.minLength = result.minLength === undefined
|
|
32
|
+
? check.value
|
|
33
|
+
: Math.max(result.minLength, check.value);
|
|
22
34
|
break;
|
|
23
35
|
case StringCheckTag.Max:
|
|
24
|
-
result.maxLength =
|
|
36
|
+
result.maxLength = result.maxLength === undefined
|
|
37
|
+
? check.value
|
|
38
|
+
: Math.min(result.maxLength, check.value);
|
|
25
39
|
break;
|
|
26
40
|
case StringCheckTag.Regex:
|
|
27
41
|
if (check.regex.flags.length !== 0) {
|
|
28
42
|
pushJsonSchemaIssue(path, issues, "unsupported_regex_flags", "JSON Schema pattern cannot preserve RegExp flags");
|
|
29
43
|
}
|
|
30
44
|
else {
|
|
31
|
-
|
|
45
|
+
patterns.push(check.regex.source);
|
|
32
46
|
}
|
|
33
47
|
break;
|
|
34
48
|
case StringCheckTag.Uuid:
|
|
35
49
|
result.format = "uuid";
|
|
36
|
-
|
|
50
|
+
patterns.push(UUID_PATTERN.source);
|
|
37
51
|
break;
|
|
38
52
|
}
|
|
39
53
|
}
|
|
54
|
+
appendStringPatterns(result, patterns);
|
|
40
55
|
return result;
|
|
41
56
|
}
|
|
42
57
|
/**
|
|
43
|
-
* @brief
|
|
58
|
+
* @brief Emit TypeSea number checks into JSON Schema number keywords.
|
|
59
|
+
* @details Integer checks narrow the emitted type, while finite lower and upper
|
|
60
|
+
* bounds collapse to the strongest minimum and maximum. Non-finite bounds are
|
|
61
|
+
* rejected because JSON Schema cannot preserve them portably.
|
|
62
|
+
* @param schema Number schema to emit.
|
|
63
|
+
* @param path Mutable issue path stack owned by the export walk.
|
|
64
|
+
* @param issues Mutable export issue buffer.
|
|
65
|
+
* @returns JSON Schema number object, or undefined when bounds are unsupported.
|
|
44
66
|
*/
|
|
45
67
|
export function emitNumber(schema, path, issues) {
|
|
46
68
|
const before = issues.length;
|
|
@@ -60,7 +82,9 @@ export function emitNumber(schema, path, issues) {
|
|
|
60
82
|
pushJsonSchemaIssue(path, issues, "unsupported_number_bound", "Number bounds must be finite");
|
|
61
83
|
}
|
|
62
84
|
else {
|
|
63
|
-
result.minimum =
|
|
85
|
+
result.minimum = result.minimum === undefined
|
|
86
|
+
? check.value
|
|
87
|
+
: Math.max(result.minimum, check.value);
|
|
64
88
|
}
|
|
65
89
|
break;
|
|
66
90
|
case NumberCheckTag.Lte:
|
|
@@ -68,7 +92,9 @@ export function emitNumber(schema, path, issues) {
|
|
|
68
92
|
pushJsonSchemaIssue(path, issues, "unsupported_number_bound", "Number bounds must be finite");
|
|
69
93
|
}
|
|
70
94
|
else {
|
|
71
|
-
result.maximum =
|
|
95
|
+
result.maximum = result.maximum === undefined
|
|
96
|
+
? check.value
|
|
97
|
+
: Math.min(result.maximum, check.value);
|
|
72
98
|
}
|
|
73
99
|
break;
|
|
74
100
|
}
|
|
@@ -79,7 +105,14 @@ export function emitNumber(schema, path, issues) {
|
|
|
79
105
|
return result;
|
|
80
106
|
}
|
|
81
107
|
/**
|
|
82
|
-
* @brief
|
|
108
|
+
* @brief Emit a literal schema as a JSON Schema `const` value.
|
|
109
|
+
* @details Only JSON-compatible literals are accepted. Undefined, bigint,
|
|
110
|
+
* symbol, NaN, infinity, and negative zero have no faithful JSON Schema literal
|
|
111
|
+
* encoding, so they become export issues instead of weakened output.
|
|
112
|
+
* @param value Literal value carried by the TypeSea schema.
|
|
113
|
+
* @param path Mutable issue path stack owned by the export walk.
|
|
114
|
+
* @param issues Mutable export issue buffer.
|
|
115
|
+
* @returns JSON Schema const object, or undefined for unsupported literals.
|
|
83
116
|
*/
|
|
84
117
|
export function emitLiteral(value, path, issues) {
|
|
85
118
|
if (value === undefined) {
|
|
@@ -102,3 +135,31 @@ export function emitLiteral(value, path, issues) {
|
|
|
102
135
|
}
|
|
103
136
|
return { const: value };
|
|
104
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* @brief Append JSON Schema pattern constraints without weakening repeated checks.
|
|
140
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
141
|
+
* report a structured export issue.
|
|
142
|
+
* @param result Mutable string schema output.
|
|
143
|
+
* @param patterns Ordered TypeSea pattern sources.
|
|
144
|
+
* @post One pattern stays inline; multiple patterns become an `allOf` chain.
|
|
145
|
+
*/
|
|
146
|
+
function appendStringPatterns(result, patterns) {
|
|
147
|
+
if (patterns.length === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (patterns.length === 1) {
|
|
151
|
+
const pattern = patterns[0];
|
|
152
|
+
if (pattern !== undefined) {
|
|
153
|
+
result.pattern = pattern;
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const schemas = new Array(patterns.length);
|
|
158
|
+
for (let index = 0; index < patterns.length; index += 1) {
|
|
159
|
+
const pattern = patterns[index];
|
|
160
|
+
if (pattern !== undefined) {
|
|
161
|
+
schemas[index] = { pattern };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
result.allOf = schemas;
|
|
165
|
+
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file emit-types.ts
|
|
3
3
|
* @brief Internal JSON Schema emitter contracts.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import type { PathSegment } from "../issue/index.js";
|
|
6
8
|
import type { Schema } from "../schema/index.js";
|
|
7
9
|
import type { JsonSchema, JsonSchemaDialect, JsonSchemaExportIssue } from "./types.js";
|
|
8
10
|
/**
|
|
9
|
-
* @brief
|
|
11
|
+
* @brief Recursive emitter callback shared by JSON Schema emitter modules.
|
|
12
|
+
* @details Child emitters receive the same path stack and issue buffer as their
|
|
13
|
+
* parent, which avoids allocating intermediate diagnostic collections during a
|
|
14
|
+
* deep schema walk.
|
|
15
|
+
* @param schema Schema node to convert.
|
|
16
|
+
* @param path Mutable issue path stack owned by the export walk.
|
|
17
|
+
* @param issues Mutable export issue buffer.
|
|
18
|
+
* @param dialect Target JSON Schema dialect.
|
|
19
|
+
* @returns JSON Schema fragment, boolean schema, or undefined on failure.
|
|
10
20
|
*/
|
|
11
21
|
export type JsonSchemaEmitter = (schema: Schema, path: PathSegment[], issues: JsonSchemaExportIssue[], dialect: JsonSchemaDialect) => JsonSchema | undefined;
|
|
12
22
|
//# sourceMappingURL=emit-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-types.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit-types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"emit-types.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACR,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,OAAO,EAAE,iBAAiB,KACzB,UAAU,GAAG,SAAS,CAAC"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file emit.ts
|
|
3
3
|
* @brief TypeSea schema to JSON Schema emitter dispatcher.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import type { PathSegment } from "../issue/index.js";
|
|
6
8
|
import type { Schema } from "../schema/index.js";
|
|
7
9
|
import type { JsonSchema, JsonSchemaDialect, JsonSchemaExportIssue } from "./types.js";
|
|
8
10
|
/**
|
|
9
|
-
* @brief
|
|
11
|
+
* @brief Dispatch one TypeSea schema node to the matching JSON Schema emitter.
|
|
12
|
+
* @details Unsupported runtime-only features are reported as structured export
|
|
13
|
+
* issues instead of being erased. That fail-closed policy prevents the exporter
|
|
14
|
+
* from producing a schema that appears equivalent while accepting a different
|
|
15
|
+
* value set.
|
|
16
|
+
* @param schema Schema node currently being emitted.
|
|
17
|
+
* @param path Mutable issue path stack owned by the export walk.
|
|
18
|
+
* @param issues Mutable export issue buffer.
|
|
19
|
+
* @param dialect Target JSON Schema dialect.
|
|
20
|
+
* @returns JSON Schema fragment, boolean schema, or undefined on failure.
|
|
10
21
|
*/
|
|
11
22
|
export declare function emitSchema(schema: Schema, path: PathSegment[], issues: JsonSchemaExportIssue[], dialect: JsonSchemaDialect): JsonSchema | undefined;
|
|
12
23
|
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmBjD,OAAO,KAAK,EACR,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,OAAO,EAAE,iBAAiB,GAC3B,UAAU,GAAG,SAAS,CA2DxB"}
|
package/dist/json-schema/emit.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file emit.ts
|
|
3
3
|
* @brief TypeSea schema to JSON Schema emitter dispatcher.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import { SchemaTag } from "../kind/index.js";
|
|
6
8
|
import { emitDiscriminatedUnion, emitIntersection, emitNullable, emitUnion } from "./emit-combinator.js";
|
|
@@ -8,7 +10,16 @@ import { emitArray, emitObject, emitRecord, emitTuple } from "./emit-composite.j
|
|
|
8
10
|
import { emitLiteral, emitNumber, emitString } from "./emit-scalar.js";
|
|
9
11
|
import { pushJsonSchemaIssue } from "./issue.js";
|
|
10
12
|
/**
|
|
11
|
-
* @brief
|
|
13
|
+
* @brief Dispatch one TypeSea schema node to the matching JSON Schema emitter.
|
|
14
|
+
* @details Unsupported runtime-only features are reported as structured export
|
|
15
|
+
* issues instead of being erased. That fail-closed policy prevents the exporter
|
|
16
|
+
* from producing a schema that appears equivalent while accepting a different
|
|
17
|
+
* value set.
|
|
18
|
+
* @param schema Schema node currently being emitted.
|
|
19
|
+
* @param path Mutable issue path stack owned by the export walk.
|
|
20
|
+
* @param issues Mutable export issue buffer.
|
|
21
|
+
* @param dialect Target JSON Schema dialect.
|
|
22
|
+
* @returns JSON Schema fragment, boolean schema, or undefined on failure.
|
|
12
23
|
*/
|
|
13
24
|
export function emitSchema(schema, path, issues, dialect) {
|
|
14
25
|
switch (schema.tag) {
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file freeze.ts
|
|
3
3
|
* @brief Immutable JSON Schema export results.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import type { JsonSchema, JsonSchemaExportIssue } from "./types.js";
|
|
6
8
|
/**
|
|
7
|
-
* @brief freeze
|
|
9
|
+
* @brief Deep-freeze a JSON Schema export result before publication.
|
|
10
|
+
* @details Exported schemas may be shared across framework adapters. Freezing
|
|
11
|
+
* prevents later mutation from changing validation semantics after a schema was
|
|
12
|
+
* handed to another subsystem.
|
|
13
|
+
* @param schema JSON Schema fragment or boolean schema.
|
|
14
|
+
* @returns The same schema value after recursive hardening.
|
|
8
15
|
*/
|
|
9
16
|
export declare function freezeJsonSchema(schema: JsonSchema): JsonSchema;
|
|
10
17
|
/**
|
|
11
|
-
* @brief
|
|
18
|
+
* @brief Freeze JSON Schema export issues and their path arrays.
|
|
19
|
+
* @details Paths are mutable during traversal for stack efficiency, then frozen
|
|
20
|
+
* at the boundary so callers cannot rewrite diagnostic locations later.
|
|
21
|
+
* @param issues Export issues collected during emission.
|
|
22
|
+
* @returns The same issue array after recursive hardening.
|
|
12
23
|
*/
|
|
13
24
|
export declare function freezeJsonSchemaIssues(issues: readonly JsonSchemaExportIssue[]): readonly JsonSchemaExportIssue[];
|
|
14
25
|
//# sourceMappingURL=freeze.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../../src/json-schema/freeze.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../../src/json-schema/freeze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACR,UAAU,EACV,qBAAqB,EAExB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAK/D;AAoID;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,SAAS,qBAAqB,EAAE,GACzC,SAAS,qBAAqB,EAAE,CASlC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file freeze.ts
|
|
3
3
|
* @brief Immutable JSON Schema export results.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
/**
|
|
6
|
-
* @brief freeze
|
|
8
|
+
* @brief Deep-freeze a JSON Schema export result before publication.
|
|
9
|
+
* @details Exported schemas may be shared across framework adapters. Freezing
|
|
10
|
+
* prevents later mutation from changing validation semantics after a schema was
|
|
11
|
+
* handed to another subsystem.
|
|
12
|
+
* @param schema JSON Schema fragment or boolean schema.
|
|
13
|
+
* @returns The same schema value after recursive hardening.
|
|
7
14
|
*/
|
|
8
15
|
export function freezeJsonSchema(schema) {
|
|
9
16
|
if (typeof schema === "boolean") {
|
|
@@ -12,7 +19,13 @@ export function freezeJsonSchema(schema) {
|
|
|
12
19
|
return freezeJsonSchemaInner(schema, new WeakSet());
|
|
13
20
|
}
|
|
14
21
|
/**
|
|
15
|
-
* @brief freeze
|
|
22
|
+
* @brief Recursively freeze one object-shaped JSON Schema fragment.
|
|
23
|
+
* @details A WeakSet protects against repeated references introduced by callers
|
|
24
|
+
* or future emitters. Current emission is tree-shaped, but this guard keeps the
|
|
25
|
+
* hardener robust at the module boundary.
|
|
26
|
+
* @param schema Object-shaped JSON Schema fragment.
|
|
27
|
+
* @param frozen Objects already processed by this hardening walk.
|
|
28
|
+
* @returns The same object after nested values are frozen.
|
|
16
29
|
*/
|
|
17
30
|
function freezeJsonSchemaInner(schema, frozen) {
|
|
18
31
|
if (frozen.has(schema)) {
|
|
@@ -52,8 +65,12 @@ function freezeJsonSchemaInner(schema, frozen) {
|
|
|
52
65
|
return Object.freeze(schema);
|
|
53
66
|
}
|
|
54
67
|
/**
|
|
55
|
-
* @brief
|
|
56
|
-
* @details
|
|
68
|
+
* @brief Freeze the dialect-dependent `items` payload.
|
|
69
|
+
* @details Draft-07 tuple output stores an array under `items`, while newer
|
|
70
|
+
* dialects use object-shaped homogeneous item schemas. Both representations are
|
|
71
|
+
* hardened here before the parent schema is frozen.
|
|
72
|
+
* @param items JSON Schema `items` payload to harden.
|
|
73
|
+
* @param frozen Objects already processed by this hardening walk.
|
|
57
74
|
*/
|
|
58
75
|
function freezeJsonSchemaItems(items, frozen) {
|
|
59
76
|
if (Array.isArray(items)) {
|
|
@@ -64,7 +81,11 @@ function freezeJsonSchemaItems(items, frozen) {
|
|
|
64
81
|
freezeJsonSchemaValue(schema, frozen);
|
|
65
82
|
}
|
|
66
83
|
/**
|
|
67
|
-
* @brief
|
|
84
|
+
* @brief Freeze one nested JSON Schema value when it is object-shaped.
|
|
85
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
86
|
+
* report a structured export issue.
|
|
87
|
+
* @param schema Boolean or object-shaped JSON Schema fragment.
|
|
88
|
+
* @param frozen Objects already processed by this hardening walk.
|
|
68
89
|
*/
|
|
69
90
|
function freezeJsonSchemaValue(schema, frozen) {
|
|
70
91
|
if (typeof schema !== "boolean") {
|
|
@@ -72,7 +93,11 @@ function freezeJsonSchemaValue(schema, frozen) {
|
|
|
72
93
|
}
|
|
73
94
|
}
|
|
74
95
|
/**
|
|
75
|
-
* @brief
|
|
96
|
+
* @brief Freeze an array of nested schema fragments.
|
|
97
|
+
* @details Elements are hardened before the array itself so no mutable child is
|
|
98
|
+
* reachable through the frozen container.
|
|
99
|
+
* @param schemas Array of JSON Schema fragments.
|
|
100
|
+
* @param frozen Objects already processed by this hardening walk.
|
|
76
101
|
*/
|
|
77
102
|
function freezeJsonSchemaArray(schemas, frozen) {
|
|
78
103
|
for (let index = 0; index < schemas.length; index += 1) {
|
|
@@ -84,7 +109,11 @@ function freezeJsonSchemaArray(schemas, frozen) {
|
|
|
84
109
|
Object.freeze(schemas);
|
|
85
110
|
}
|
|
86
111
|
/**
|
|
87
|
-
* @brief
|
|
112
|
+
* @brief Freeze an object-property schema table.
|
|
113
|
+
* @details Property tables are traversed by own enumerable keys because JSON
|
|
114
|
+
* Schema object maps are data dictionaries, not prototype-based classes.
|
|
115
|
+
* @param properties Property-name to schema table.
|
|
116
|
+
* @param frozen Objects already processed by this hardening walk.
|
|
88
117
|
*/
|
|
89
118
|
function freezeJsonSchemaProperties(properties, frozen) {
|
|
90
119
|
const keys = Object.keys(properties);
|
|
@@ -100,7 +129,11 @@ function freezeJsonSchemaProperties(properties, frozen) {
|
|
|
100
129
|
Object.freeze(properties);
|
|
101
130
|
}
|
|
102
131
|
/**
|
|
103
|
-
* @brief
|
|
132
|
+
* @brief Freeze JSON Schema export issues and their path arrays.
|
|
133
|
+
* @details Paths are mutable during traversal for stack efficiency, then frozen
|
|
134
|
+
* at the boundary so callers cannot rewrite diagnostic locations later.
|
|
135
|
+
* @param issues Export issues collected during emission.
|
|
136
|
+
* @returns The same issue array after recursive hardening.
|
|
104
137
|
*/
|
|
105
138
|
export function freezeJsonSchemaIssues(issues) {
|
|
106
139
|
for (let index = 0; index < issues.length; index += 1) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file index.ts
|
|
3
3
|
* @brief Public JSON Schema export module.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import { type AsyncDecoder } from "../async/index.js";
|
|
6
8
|
import { type Decoder } from "../decoder/index.js";
|
|
@@ -10,11 +12,23 @@ import type { Schema } from "../schema/index.js";
|
|
|
10
12
|
import type { JsonSchema, JsonSchemaExportIssue, JsonSchemaOptions } from "./types.js";
|
|
11
13
|
export type { JsonSchema, JsonSchemaDialect, JsonSchemaExportCode, JsonSchemaExportIssue, JsonSchemaObject, JsonSchemaOptions, JsonSchemaPrimitive, JsonSchemaTypeName } from "./types.js";
|
|
12
14
|
/**
|
|
13
|
-
* @brief
|
|
15
|
+
* @brief Export the schema behind a guard or decoder as JSON Schema.
|
|
16
|
+
* @details Decoder values are rejected before emission because transform logic
|
|
17
|
+
* has no lossless JSON Schema representation. This keeps the exporter honest:
|
|
18
|
+
* it returns a schema only when the runtime validator can be expressed without
|
|
19
|
+
* hidden TypeSea execution.
|
|
20
|
+
* @param guard Guard or decoder value provided by public callers.
|
|
21
|
+
* @param options Optional dialect and schema id configuration.
|
|
22
|
+
* @returns Export result with either a frozen JSON Schema document or issues.
|
|
14
23
|
*/
|
|
15
24
|
export declare function toJsonSchema<TValue>(guard: Guard<TValue, Presence> | Decoder<TValue> | AsyncDecoder<TValue>, options?: Partial<JsonSchemaOptions>): Result<JsonSchema, readonly JsonSchemaExportIssue[]>;
|
|
16
25
|
/**
|
|
17
|
-
* @brief schema
|
|
26
|
+
* @brief Export a raw TypeSea schema into a JSON Schema document.
|
|
27
|
+
* @details This internal-facing helper skips guard extraction but still routes
|
|
28
|
+
* through the same emitter and issue accumulator as the public guard API.
|
|
29
|
+
* @param schema Schema value that already passed TypeSea construction checks.
|
|
30
|
+
* @param options Optional dialect and schema id configuration.
|
|
31
|
+
* @returns Export result with a frozen JSON Schema document or diagnostics.
|
|
18
32
|
*/
|
|
19
33
|
export declare function schemaToJsonSchema(schema: Schema, options?: Partial<JsonSchemaOptions>): Result<JsonSchema, readonly JsonSchemaExportIssue[]>;
|
|
20
34
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json-schema/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json-schema/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAajD,OAAO,KAAK,EACR,UAAU,EAEV,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACR,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EACrB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAC/B,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EACvE,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACrC,MAAM,CAAC,UAAU,EAAE,SAAS,qBAAqB,EAAE,CAAC,CAsBtD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACrC,MAAM,CAAC,UAAU,EAAE,SAAS,qBAAqB,EAAE,CAAC,CAEtD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file index.ts
|
|
3
3
|
* @brief Public JSON Schema export module.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import { isAsyncDecoderValue } from "../async/index.js";
|
|
6
8
|
import { isDecoderValue } from "../decoder/index.js";
|
|
@@ -9,7 +11,14 @@ import { emitSchema } from "./emit.js";
|
|
|
9
11
|
import { freezeJsonSchema, freezeJsonSchemaIssues } from "./freeze.js";
|
|
10
12
|
import { JSON_SCHEMA_2020_12_ID, JSON_SCHEMA_DRAFT_07_ID, readJsonSchemaGuardSchema, readJsonSchemaOptions, readJsonSchemaSchema } from "./read.js";
|
|
11
13
|
/**
|
|
12
|
-
* @brief
|
|
14
|
+
* @brief Export the schema behind a guard or decoder as JSON Schema.
|
|
15
|
+
* @details Decoder values are rejected before emission because transform logic
|
|
16
|
+
* has no lossless JSON Schema representation. This keeps the exporter honest:
|
|
17
|
+
* it returns a schema only when the runtime validator can be expressed without
|
|
18
|
+
* hidden TypeSea execution.
|
|
19
|
+
* @param guard Guard or decoder value provided by public callers.
|
|
20
|
+
* @param options Optional dialect and schema id configuration.
|
|
21
|
+
* @returns Export result with either a frozen JSON Schema document or issues.
|
|
13
22
|
*/
|
|
14
23
|
export function toJsonSchema(guard, options) {
|
|
15
24
|
if (isAsyncDecoderValue(guard)) {
|
|
@@ -35,13 +44,24 @@ export function toJsonSchema(guard, options) {
|
|
|
35
44
|
return exportJsonSchema(readJsonSchemaGuardSchema(guard), options);
|
|
36
45
|
}
|
|
37
46
|
/**
|
|
38
|
-
* @brief schema
|
|
47
|
+
* @brief Export a raw TypeSea schema into a JSON Schema document.
|
|
48
|
+
* @details This internal-facing helper skips guard extraction but still routes
|
|
49
|
+
* through the same emitter and issue accumulator as the public guard API.
|
|
50
|
+
* @param schema Schema value that already passed TypeSea construction checks.
|
|
51
|
+
* @param options Optional dialect and schema id configuration.
|
|
52
|
+
* @returns Export result with a frozen JSON Schema document or diagnostics.
|
|
39
53
|
*/
|
|
40
54
|
export function schemaToJsonSchema(schema, options) {
|
|
41
55
|
return exportJsonSchema(readJsonSchemaSchema(schema), options);
|
|
42
56
|
}
|
|
43
57
|
/**
|
|
44
|
-
* @brief
|
|
58
|
+
* @brief Run the JSON Schema emitter and attach the dialect marker.
|
|
59
|
+
* @details The emitter writes structural failures into `issues` instead of
|
|
60
|
+
* throwing so callers can inspect every unsupported node discovered during the
|
|
61
|
+
* walk. Boolean schemas are wrapped to preserve a document-shaped top level.
|
|
62
|
+
* @param schema TypeSea schema selected for export.
|
|
63
|
+
* @param options User supplied export options, still unresolved.
|
|
64
|
+
* @returns Frozen JSON Schema document on success, or frozen export issues.
|
|
45
65
|
*/
|
|
46
66
|
function exportJsonSchema(schema, options) {
|
|
47
67
|
const config = readJsonSchemaOptions(options);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file issue.ts
|
|
3
3
|
* @brief JSON Schema export issue construction.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import type { PathSegment } from "../issue/index.js";
|
|
6
8
|
import type { JsonSchemaExportCode, JsonSchemaExportIssue } from "./types.js";
|
|
7
9
|
/**
|
|
8
|
-
* @brief push json schema issue.
|
|
10
|
+
* @brief Execute push json schema issue.
|
|
11
|
+
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
9
12
|
*/
|
|
10
13
|
export declare function pushJsonSchemaIssue(path: readonly PathSegment[], issues: JsonSchemaExportIssue[], code: JsonSchemaExportCode, message: string): void;
|
|
11
14
|
//# sourceMappingURL=issue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/json-schema/issue.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/json-schema/issue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACR,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,SAAS,WAAW,EAAE,EAC5B,MAAM,EAAE,qBAAqB,EAAE,EAC/B,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,MAAM,GAChB,IAAI,CAMN"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file issue.ts
|
|
3
3
|
* @brief JSON Schema export issue construction.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
/**
|
|
6
|
-
* @brief push json schema issue.
|
|
8
|
+
* @brief Execute push json schema issue.
|
|
9
|
+
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
7
10
|
*/
|
|
8
11
|
export function pushJsonSchemaIssue(path, issues, code, message) {
|
|
9
12
|
issues.push({
|
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file read.ts
|
|
3
3
|
* @brief Input normalization for JSON Schema export.
|
|
4
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
5
|
+
* report a structured export issue.
|
|
4
6
|
*/
|
|
5
7
|
import { type Schema } from "../schema/index.js";
|
|
6
8
|
import type { JsonSchemaOptions } from "./types.js";
|
|
7
9
|
/**
|
|
8
10
|
* @brief draft 07 schema id.
|
|
11
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
12
|
+
* report a structured export issue.
|
|
9
13
|
* @invariant The value is the default dialect marker for TypeSea JSON Schema output.
|
|
10
14
|
*/
|
|
11
15
|
export declare const JSON_SCHEMA_DRAFT_07_ID = "http://json-schema.org/draft-07/schema#";
|
|
12
16
|
/**
|
|
13
17
|
* @brief draft 2020 12 schema id.
|
|
18
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
19
|
+
* report a structured export issue.
|
|
14
20
|
* @invariant The value selects the `prefixItems` tuple keyword set.
|
|
15
21
|
*/
|
|
16
22
|
export declare const JSON_SCHEMA_2020_12_ID = "https://json-schema.org/draft/2020-12/schema";
|
|
17
23
|
/**
|
|
18
|
-
* @brief
|
|
24
|
+
* @brief Read the schema carried by a guard for JSON Schema export.
|
|
25
|
+
* @param guard Candidate guard-like value.
|
|
26
|
+
* @returns Frozen schema accepted by the exporter.
|
|
27
|
+
* @throws TypeError when the receiver does not expose a valid TypeSea schema.
|
|
28
|
+
* @details Export can be used at package or build boundaries, so forged
|
|
29
|
+
* prototype schema fields are rejected before conversion begins.
|
|
19
30
|
*/
|
|
20
31
|
export declare function readJsonSchemaGuardSchema(guard: unknown): Schema;
|
|
21
32
|
/**
|
|
22
|
-
* @brief
|
|
33
|
+
* @brief Validate and freeze a direct schema export input.
|
|
34
|
+
* @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
|
|
35
|
+
* report a structured export issue.
|
|
36
|
+
* @param schema Candidate TypeSea schema.
|
|
37
|
+
* @returns Frozen schema tree safe for traversal by emitters.
|
|
38
|
+
* @throws TypeError when the schema shape is malformed.
|
|
23
39
|
*/
|
|
24
40
|
export declare function readJsonSchemaSchema(schema: unknown): Schema;
|
|
25
41
|
/**
|
|
26
|
-
* @brief
|
|
42
|
+
* @brief Normalize JSON Schema exporter options.
|
|
43
|
+
* @param options Candidate options object.
|
|
44
|
+
* @returns Dialect and schema id with defaults filled in.
|
|
45
|
+
* @throws TypeError when option fields are not supported.
|
|
46
|
+
* @details Options are read through own data slots so a caller cannot influence
|
|
47
|
+
* export dialect through inherited getters or prototype state.
|
|
27
48
|
*/
|
|
28
49
|
export declare function readJsonSchemaOptions(options: unknown): JsonSchemaOptions;
|
|
29
50
|
//# sourceMappingURL=read.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/json-schema/read.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/json-schema/read.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAER,iBAAiB,EACpB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKhE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAK5D;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAmBzE"}
|