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.
Files changed (285) hide show
  1. package/CHANGELOG.md +67 -6
  2. package/README.md +98 -17
  3. package/dist/adapters/index.d.ts +50 -8
  4. package/dist/adapters/index.d.ts.map +1 -1
  5. package/dist/adapters/index.js +169 -48
  6. package/dist/aot/index.d.ts +18 -2
  7. package/dist/aot/index.d.ts.map +1 -1
  8. package/dist/aot/index.js +93 -14
  9. package/dist/async/index.d.ts +28 -56
  10. package/dist/async/index.d.ts.map +1 -1
  11. package/dist/async/index.js +94 -37
  12. package/dist/builders/composite.d.ts +37 -6
  13. package/dist/builders/composite.d.ts.map +1 -1
  14. package/dist/builders/composite.js +84 -10
  15. package/dist/builders/index.d.ts +2 -0
  16. package/dist/builders/index.d.ts.map +1 -1
  17. package/dist/builders/index.js +2 -0
  18. package/dist/builders/modifier.d.ts +30 -5
  19. package/dist/builders/modifier.d.ts.map +1 -1
  20. package/dist/builders/modifier.js +38 -5
  21. package/dist/builders/object/guard.d.ts +18 -22
  22. package/dist/builders/object/guard.d.ts.map +1 -1
  23. package/dist/builders/object/guard.js +26 -26
  24. package/dist/builders/object/index.d.ts +2 -0
  25. package/dist/builders/object/index.d.ts.map +1 -1
  26. package/dist/builders/object/index.js +2 -0
  27. package/dist/builders/object/schema.d.ts +55 -9
  28. package/dist/builders/object/schema.d.ts.map +1 -1
  29. package/dist/builders/object/schema.js +92 -15
  30. package/dist/builders/object/types.d.ts +5 -31
  31. package/dist/builders/object/types.d.ts.map +1 -1
  32. package/dist/builders/object/types.js +2 -0
  33. package/dist/builders/scalar.d.ts +29 -8
  34. package/dist/builders/scalar.d.ts.map +1 -1
  35. package/dist/builders/scalar.js +33 -8
  36. package/dist/builders/table.d.ts +4 -0
  37. package/dist/builders/table.d.ts.map +1 -1
  38. package/dist/builders/table.js +4 -0
  39. package/dist/builders/types.d.ts +14 -4
  40. package/dist/builders/types.d.ts.map +1 -1
  41. package/dist/builders/types.js +2 -0
  42. package/dist/compile/check-composite.d.ts +22 -1
  43. package/dist/compile/check-composite.d.ts.map +1 -1
  44. package/dist/compile/check-composite.js +564 -24
  45. package/dist/compile/check-scalar.d.ts +78 -0
  46. package/dist/compile/check-scalar.d.ts.map +1 -1
  47. package/dist/compile/check-scalar.js +432 -1
  48. package/dist/compile/check.d.ts +12 -0
  49. package/dist/compile/check.d.ts.map +1 -1
  50. package/dist/compile/check.js +37 -0
  51. package/dist/compile/context.d.ts +47 -9
  52. package/dist/compile/context.d.ts.map +1 -1
  53. package/dist/compile/context.js +51 -8
  54. package/dist/compile/graph-predicate.d.ts +4 -2
  55. package/dist/compile/graph-predicate.d.ts.map +1 -1
  56. package/dist/compile/graph-predicate.js +1907 -171
  57. package/dist/compile/guard.d.ts +15 -24
  58. package/dist/compile/guard.d.ts.map +1 -1
  59. package/dist/compile/guard.js +158 -74
  60. package/dist/compile/index.d.ts +3 -1
  61. package/dist/compile/index.d.ts.map +1 -1
  62. package/dist/compile/index.js +2 -0
  63. package/dist/compile/issue.d.ts +110 -0
  64. package/dist/compile/issue.d.ts.map +1 -1
  65. package/dist/compile/issue.js +184 -1
  66. package/dist/compile/names.d.ts +12 -2
  67. package/dist/compile/names.d.ts.map +1 -1
  68. package/dist/compile/names.js +19 -3
  69. package/dist/compile/predicate.d.ts +24 -0
  70. package/dist/compile/predicate.d.ts.map +1 -1
  71. package/dist/compile/predicate.js +131 -5
  72. package/dist/compile/runtime.d.ts +80 -12
  73. package/dist/compile/runtime.d.ts.map +1 -1
  74. package/dist/compile/runtime.js +25 -6
  75. package/dist/compile/source.d.ts +10 -2
  76. package/dist/compile/source.d.ts.map +1 -1
  77. package/dist/compile/source.js +361 -26
  78. package/dist/compile/types.d.ts +20 -0
  79. package/dist/compile/types.d.ts.map +1 -1
  80. package/dist/compile/types.js +2 -0
  81. package/dist/decoder/index.d.ts +32 -46
  82. package/dist/decoder/index.d.ts.map +1 -1
  83. package/dist/decoder/index.js +102 -38
  84. package/dist/evaluate/check-composite.d.ts +59 -0
  85. package/dist/evaluate/check-composite.d.ts.map +1 -1
  86. package/dist/evaluate/check-composite.js +151 -3
  87. package/dist/evaluate/check-scalar.d.ts +16 -0
  88. package/dist/evaluate/check-scalar.d.ts.map +1 -1
  89. package/dist/evaluate/check-scalar.js +32 -0
  90. package/dist/evaluate/check.d.ts +7 -0
  91. package/dist/evaluate/check.d.ts.map +1 -1
  92. package/dist/evaluate/check.js +43 -0
  93. package/dist/evaluate/index.d.ts +2 -0
  94. package/dist/evaluate/index.d.ts.map +1 -1
  95. package/dist/evaluate/index.js +2 -0
  96. package/dist/evaluate/issue.d.ts +11 -1
  97. package/dist/evaluate/issue.d.ts.map +1 -1
  98. package/dist/evaluate/issue.js +15 -1
  99. package/dist/evaluate/predicate.d.ts +16 -5
  100. package/dist/evaluate/predicate.d.ts.map +1 -1
  101. package/dist/evaluate/predicate.js +20 -5
  102. package/dist/evaluate/shared.d.ts +59 -13
  103. package/dist/evaluate/shared.d.ts.map +1 -1
  104. package/dist/evaluate/shared.js +66 -8
  105. package/dist/evaluate/state.d.ts +35 -13
  106. package/dist/evaluate/state.d.ts.map +1 -1
  107. package/dist/evaluate/state.js +35 -2
  108. package/dist/guard/base.d.ts +79 -29
  109. package/dist/guard/base.d.ts.map +1 -1
  110. package/dist/guard/base.js +91 -29
  111. package/dist/guard/error.d.ts +10 -5
  112. package/dist/guard/error.d.ts.map +1 -1
  113. package/dist/guard/error.js +10 -5
  114. package/dist/guard/index.d.ts +2 -0
  115. package/dist/guard/index.d.ts.map +1 -1
  116. package/dist/guard/index.js +2 -0
  117. package/dist/guard/number.d.ts +26 -11
  118. package/dist/guard/number.d.ts.map +1 -1
  119. package/dist/guard/number.js +30 -11
  120. package/dist/guard/props.d.ts +27 -3
  121. package/dist/guard/props.d.ts.map +1 -1
  122. package/dist/guard/props.js +27 -3
  123. package/dist/guard/read.d.ts +62 -9
  124. package/dist/guard/read.d.ts.map +1 -1
  125. package/dist/guard/read.js +83 -10
  126. package/dist/guard/registry.d.ts +12 -2
  127. package/dist/guard/registry.d.ts.map +1 -1
  128. package/dist/guard/registry.js +15 -3
  129. package/dist/guard/string.d.ts +33 -13
  130. package/dist/guard/string.d.ts.map +1 -1
  131. package/dist/guard/string.js +37 -13
  132. package/dist/guard/types.d.ts +92 -40
  133. package/dist/guard/types.d.ts.map +1 -1
  134. package/dist/guard/types.js +2 -0
  135. package/dist/index.d.ts +1 -1
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/internal/index.d.ts +42 -6
  138. package/dist/internal/index.d.ts.map +1 -1
  139. package/dist/internal/index.js +51 -8
  140. package/dist/ir/builder.d.ts +16 -126
  141. package/dist/ir/builder.d.ts.map +1 -1
  142. package/dist/ir/builder.js +77 -137
  143. package/dist/ir/freeze.d.ts +4 -0
  144. package/dist/ir/freeze.d.ts.map +1 -1
  145. package/dist/ir/freeze.js +59 -0
  146. package/dist/ir/index.d.ts +3 -1
  147. package/dist/ir/index.d.ts.map +1 -1
  148. package/dist/ir/index.js +2 -0
  149. package/dist/ir/regexp.d.ts +2 -0
  150. package/dist/ir/regexp.d.ts.map +1 -1
  151. package/dist/ir/regexp.js +2 -0
  152. package/dist/ir/types.d.ts +90 -55
  153. package/dist/ir/types.d.ts.map +1 -1
  154. package/dist/ir/types.js +2 -0
  155. package/dist/ir/validate.d.ts +8 -1
  156. package/dist/ir/validate.d.ts.map +1 -1
  157. package/dist/ir/validate.js +477 -61
  158. package/dist/issue/index.d.ts +41 -9
  159. package/dist/issue/index.d.ts.map +1 -1
  160. package/dist/issue/index.js +61 -11
  161. package/dist/json-schema/emit-combinator.d.ts +44 -4
  162. package/dist/json-schema/emit-combinator.d.ts.map +1 -1
  163. package/dist/json-schema/emit-combinator.js +44 -4
  164. package/dist/json-schema/emit-composite.d.ts +10 -0
  165. package/dist/json-schema/emit-composite.d.ts.map +1 -1
  166. package/dist/json-schema/emit-composite.js +15 -1
  167. package/dist/json-schema/emit-scalar.d.ts +26 -3
  168. package/dist/json-schema/emit-scalar.d.ts.map +1 -1
  169. package/dist/json-schema/emit-scalar.js +70 -9
  170. package/dist/json-schema/emit-types.d.ts +11 -1
  171. package/dist/json-schema/emit-types.d.ts.map +1 -1
  172. package/dist/json-schema/emit-types.js +2 -0
  173. package/dist/json-schema/emit.d.ts +12 -1
  174. package/dist/json-schema/emit.d.ts.map +1 -1
  175. package/dist/json-schema/emit.js +12 -1
  176. package/dist/json-schema/freeze.d.ts +13 -2
  177. package/dist/json-schema/freeze.d.ts.map +1 -1
  178. package/dist/json-schema/freeze.js +41 -8
  179. package/dist/json-schema/index.d.ts +16 -2
  180. package/dist/json-schema/index.d.ts.map +1 -1
  181. package/dist/json-schema/index.js +23 -3
  182. package/dist/json-schema/issue.d.ts +4 -1
  183. package/dist/json-schema/issue.d.ts.map +1 -1
  184. package/dist/json-schema/issue.js +4 -1
  185. package/dist/json-schema/read.d.ts +24 -3
  186. package/dist/json-schema/read.d.ts.map +1 -1
  187. package/dist/json-schema/read.js +59 -12
  188. package/dist/json-schema/types.d.ts +38 -15
  189. package/dist/json-schema/types.d.ts.map +1 -1
  190. package/dist/json-schema/types.js +2 -0
  191. package/dist/kind/index.d.ts +15 -28
  192. package/dist/kind/index.d.ts.map +1 -1
  193. package/dist/kind/index.js +15 -10
  194. package/dist/lower/index.d.ts +6 -1
  195. package/dist/lower/index.d.ts.map +1 -1
  196. package/dist/lower/index.js +411 -44
  197. package/dist/message/index.d.ts +46 -10
  198. package/dist/message/index.d.ts.map +1 -1
  199. package/dist/message/index.js +88 -17
  200. package/dist/optimize/algebraic.d.ts +54 -0
  201. package/dist/optimize/algebraic.d.ts.map +1 -0
  202. package/dist/optimize/algebraic.js +314 -0
  203. package/dist/optimize/compact.d.ts +8 -1
  204. package/dist/optimize/compact.d.ts.map +1 -1
  205. package/dist/optimize/compact.js +13 -2
  206. package/dist/optimize/domain.d.ts +16 -0
  207. package/dist/optimize/domain.d.ts.map +1 -0
  208. package/dist/optimize/domain.js +615 -0
  209. package/dist/optimize/fold-boolean.d.ts +17 -2
  210. package/dist/optimize/fold-boolean.d.ts.map +1 -1
  211. package/dist/optimize/fold-boolean.js +59 -14
  212. package/dist/optimize/fold-common.d.ts +43 -8
  213. package/dist/optimize/fold-common.d.ts.map +1 -1
  214. package/dist/optimize/fold-common.js +37 -6
  215. package/dist/optimize/fold-constraints.d.ts +33 -0
  216. package/dist/optimize/fold-constraints.d.ts.map +1 -0
  217. package/dist/optimize/fold-constraints.js +484 -0
  218. package/dist/optimize/fold-scalar.d.ts +98 -13
  219. package/dist/optimize/fold-scalar.d.ts.map +1 -1
  220. package/dist/optimize/fold-scalar.js +98 -13
  221. package/dist/optimize/fold.d.ts +8 -1
  222. package/dist/optimize/fold.d.ts.map +1 -1
  223. package/dist/optimize/fold.js +22 -2
  224. package/dist/optimize/index.d.ts +9 -1
  225. package/dist/optimize/index.d.ts.map +1 -1
  226. package/dist/optimize/index.js +18 -3
  227. package/dist/optimize/map-node.d.ts +3 -1
  228. package/dist/optimize/map-node.d.ts.map +1 -1
  229. package/dist/optimize/map-node.js +45 -3
  230. package/dist/optimize/peephole.d.ts +16 -0
  231. package/dist/optimize/peephole.d.ts.map +1 -0
  232. package/dist/optimize/peephole.js +254 -0
  233. package/dist/optimize/remap.d.ts +2 -0
  234. package/dist/optimize/remap.d.ts.map +1 -1
  235. package/dist/optimize/remap.js +2 -0
  236. package/dist/optimize/rewrite.d.ts +13 -8
  237. package/dist/optimize/rewrite.d.ts.map +1 -1
  238. package/dist/optimize/rewrite.js +13 -8
  239. package/dist/plan/cache.d.ts +9 -3
  240. package/dist/plan/cache.d.ts.map +1 -1
  241. package/dist/plan/cache.js +21 -5
  242. package/dist/plan/index.d.ts +2 -0
  243. package/dist/plan/index.d.ts.map +1 -1
  244. package/dist/plan/index.js +2 -0
  245. package/dist/plan/predicate.d.ts +2 -0
  246. package/dist/plan/predicate.d.ts.map +1 -1
  247. package/dist/plan/predicate.js +268 -29
  248. package/dist/plan/schema-predicate.d.ts +6 -0
  249. package/dist/plan/schema-predicate.d.ts.map +1 -1
  250. package/dist/plan/schema-predicate.js +117 -13
  251. package/dist/plan/types.d.ts +2 -0
  252. package/dist/plan/types.d.ts.map +1 -1
  253. package/dist/plan/types.js +2 -0
  254. package/dist/result/index.d.ts +19 -5
  255. package/dist/result/index.d.ts.map +1 -1
  256. package/dist/result/index.js +10 -2
  257. package/dist/schema/common.d.ts +69 -6
  258. package/dist/schema/common.d.ts.map +1 -1
  259. package/dist/schema/common.js +104 -10
  260. package/dist/schema/freeze.d.ts +4 -0
  261. package/dist/schema/freeze.d.ts.map +1 -1
  262. package/dist/schema/freeze.js +18 -0
  263. package/dist/schema/index.d.ts +3 -0
  264. package/dist/schema/index.d.ts.map +1 -1
  265. package/dist/schema/index.js +3 -0
  266. package/dist/schema/lazy.d.ts +4 -0
  267. package/dist/schema/lazy.d.ts.map +1 -1
  268. package/dist/schema/lazy.js +4 -0
  269. package/dist/schema/literal.d.ts +7 -1
  270. package/dist/schema/literal.d.ts.map +1 -1
  271. package/dist/schema/literal.js +7 -1
  272. package/dist/schema/types.d.ts +20 -96
  273. package/dist/schema/types.d.ts.map +1 -1
  274. package/dist/schema/types.js +5 -1
  275. package/dist/schema/undefined.d.ts +17 -0
  276. package/dist/schema/undefined.d.ts.map +1 -0
  277. package/dist/schema/undefined.js +72 -0
  278. package/dist/schema/validate.d.ts +8 -1
  279. package/dist/schema/validate.d.ts.map +1 -1
  280. package/dist/schema/validate.js +146 -55
  281. package/docs/api.md +57 -0
  282. package/docs/assets/benchmark-headline.svg +163 -0
  283. package/docs/engine-notes.md +58 -15
  284. package/docs/index.html +130 -110
  285. 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 emit string.
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 = check.value;
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 = check.value;
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
- result.pattern = check.regex.source;
45
+ patterns.push(check.regex.source);
32
46
  }
33
47
  break;
34
48
  case StringCheckTag.Uuid:
35
49
  result.format = "uuid";
36
- result.pattern = UUID_PATTERN.source;
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 emit number.
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 = check.value;
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 = check.value;
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 emit literal.
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 json schema emitter.
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;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,OAAO,EAAE,iBAAiB,KACvB,UAAU,GAAG,SAAS,CAAC"}
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,5 +1,7 @@
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
  export {};
@@ -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 emit schema.
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;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmBjD,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,OAAO,EAAE,iBAAiB,GACzB,UAAU,GAAG,SAAS,CA2DxB"}
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"}
@@ -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 emit schema.
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 json schema.
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 freeze json schema issues.
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;;;GAGG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAK/D;AA8GD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,qBAAqB,EAAE,GACvC,SAAS,qBAAqB,EAAE,CASlC"}
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 json schema.
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 json schema inner.
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 freeze json schema items.
56
- * @details Handles both homogeneous `items` schemas and draft-07 tuple item arrays.
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 freeze json schema value.
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 freeze json schema array.
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 freeze json schema properties.
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 freeze json schema issues.
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 to json schema.
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 to json 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;;;GAGG;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,EACV,UAAU,EAEV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EACjC,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,GACnC,MAAM,CAAC,UAAU,EAAE,SAAS,qBAAqB,EAAE,CAAC,CAsBtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACnC,MAAM,CAAC,UAAU,EAAE,SAAS,qBAAqB,EAAE,CAAC,CAEtD"}
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 to json schema.
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 to json 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 export json schema.
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;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,WAAW,EAAE,EAC5B,MAAM,EAAE,qBAAqB,EAAE,EAC/B,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,MAAM,GACd,IAAI,CAMN"}
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 read json schema guard schema.
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 read json schema schema.
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 read json schema options.
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;;;GAGG;AAEH,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAK5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAmBzE"}
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"}