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,14 +1,20 @@
1
1
  import type { Result } from "../result/index.js";
2
2
  /**
3
- * @brief path segment.
3
+ * @brief One segment in a validation issue path.
4
+ * @details Strings represent object keys and numbers represent array indexes.
5
+ * The path formatter decides how those segments become user-facing text.
4
6
  */
5
7
  export type PathSegment = string | number;
6
8
  /**
7
- * @brief issue code.
9
+ * @brief Closed set of validation issue codes emitted by TypeSea.
10
+ * @details Codes are stable machine-readable diagnostics shared by interpreters,
11
+ * compiled collectors, adapters, and message catalogs.
8
12
  */
9
13
  export type IssueCode = "expected_string" | "expected_number" | "expected_bigint" | "expected_symbol" | "expected_boolean" | "expected_never" | "expected_literal" | "expected_array" | "expected_tuple" | "expected_tuple_length" | "expected_object" | "expected_record" | "expected_integer" | "expected_min_length" | "expected_max_length" | "expected_pattern" | "expected_gte" | "expected_lte" | "expected_required_key" | "expected_union" | "expected_discriminant" | "expected_refinement" | "expected_depth_limit" | "unrecognized_key";
10
14
  /**
11
- * @brief issue.
15
+ * @brief Immutable validation diagnostic.
16
+ * @details The message field is optional so hot boolean validation and
17
+ * low-level collectors can defer human-readable formatting until requested.
12
18
  */
13
19
  export interface Issue {
14
20
  readonly path: readonly PathSegment[];
@@ -18,27 +24,53 @@ export interface Issue {
18
24
  readonly message: string | undefined;
19
25
  }
20
26
  /**
21
- * @brief check result.
27
+ * @brief Result shape returned by diagnostic validation APIs.
28
+ * @details Success carries the accepted value, failure carries a frozen issue
29
+ * array suitable for message formatting or adapter conversion.
22
30
  */
23
31
  export type CheckResult<TValue> = Result<TValue, readonly Issue[]>;
24
32
  /**
25
- * @brief make issue.
33
+ * @brief Construct one issue record without freezing it.
34
+ * @details Collectors use this helper while building mutable arrays, then
35
+ * freeze the final array at the API boundary.
36
+ * @param path Path to the failing value.
37
+ * @param code Stable issue code.
38
+ * @param expected Expected-value label, when available.
39
+ * @param actual Actual-value label, when available.
40
+ * @param message Pre-rendered human message, when available.
41
+ * @returns Mutable issue record ready for collection.
26
42
  */
27
43
  export declare function makeIssue(path: readonly PathSegment[], code: IssueCode, expected: string | undefined, actual: string | undefined, message: string | undefined): Issue;
28
44
  /**
29
- * @brief copy issue array.
45
+ * @brief Defensive-copy externally supplied issue arrays before publication.
46
+ * @details Adapter and user callback boundaries may hand back mutable objects.
47
+ * Copying revalidates shape and ensures TypeSea publishes frozen diagnostics.
48
+ * @param value Candidate issue array.
49
+ * @returns Frozen issue array with copied paths.
30
50
  */
31
51
  export declare function copyIssueArray(value: unknown): readonly Issue[];
32
52
  /**
33
- * @brief finalize issue array.
53
+ * @brief Normalize generated collector output into the public immutable shape.
54
+ * @details Generated collectors return arrays only on failure. Empty arrays use
55
+ * the shared sentinel so failed-but-empty states cannot allocate repeatedly.
56
+ * @param value Candidate issue array from a collector.
57
+ * @returns Frozen public issue array.
34
58
  */
35
59
  export declare function finalizeIssueArray(value: unknown): readonly Issue[];
36
60
  /**
37
- * @brief freeze issue array.
61
+ * @brief Freeze issues and their path arrays in-place.
62
+ * @details Paths are built mutably for speed during collection, then hardened
63
+ * before callers can retain or format the diagnostics.
64
+ * @param issues Issue array to harden.
65
+ * @returns The same issue array after freezing.
38
66
  */
39
67
  export declare function freezeIssueArray(issues: readonly Issue[]): readonly Issue[];
40
68
  /**
41
- * @brief is issue code value.
69
+ * @brief Check whether a value is one of TypeSea's stable issue codes.
70
+ * @details Issue helpers publish frozen diagnostics so adapters and callers cannot mutate
71
+ * validation results later.
72
+ * @param value Candidate issue code.
73
+ * @returns True when the value belongs to the closed issue-code set.
42
74
  */
43
75
  export declare function isIssueCodeValue(value: unknown): value is IssueCode;
44
76
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/issue/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,uBAAuB,GACvB,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,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,KAAK,EAAE,CAS/D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,KAAK,EAAE,CAQnE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,KAAK,EAAE,CAS3E;AA6DD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CA8BnE"}
@@ -1,9 +1,20 @@
1
1
  /**
2
- * @brief empty issues.
2
+ * @brief Shared success sentinel for compiled check() paths.
3
+ * @details Reusing a frozen empty array avoids allocating diagnostics for
4
+ * successful validation.
3
5
  */
4
6
  const EMPTY_ISSUES = Object.freeze([]);
7
+ const EMPTY_PATH = Object.freeze([]);
5
8
  /**
6
- * @brief make issue.
9
+ * @brief Construct one issue record without freezing it.
10
+ * @details Collectors use this helper while building mutable arrays, then
11
+ * freeze the final array at the API boundary.
12
+ * @param path Path to the failing value.
13
+ * @param code Stable issue code.
14
+ * @param expected Expected-value label, when available.
15
+ * @param actual Actual-value label, when available.
16
+ * @param message Pre-rendered human message, when available.
17
+ * @returns Mutable issue record ready for collection.
7
18
  */
8
19
  export function makeIssue(path, code, expected, actual, message) {
9
20
  return {
@@ -15,7 +26,11 @@ export function makeIssue(path, code, expected, actual, message) {
15
26
  };
16
27
  }
17
28
  /**
18
- * @brief copy issue array.
29
+ * @brief Defensive-copy externally supplied issue arrays before publication.
30
+ * @details Adapter and user callback boundaries may hand back mutable objects.
31
+ * Copying revalidates shape and ensures TypeSea publishes frozen diagnostics.
32
+ * @param value Candidate issue array.
33
+ * @returns Frozen issue array with copied paths.
19
34
  */
20
35
  export function copyIssueArray(value) {
21
36
  if (!isUnknownArray(value)) {
@@ -28,7 +43,11 @@ export function copyIssueArray(value) {
28
43
  return freezeIssueArray(copied);
29
44
  }
30
45
  /**
31
- * @brief finalize issue array.
46
+ * @brief Normalize generated collector output into the public immutable shape.
47
+ * @details Generated collectors return arrays only on failure. Empty arrays use
48
+ * the shared sentinel so failed-but-empty states cannot allocate repeatedly.
49
+ * @param value Candidate issue array from a collector.
50
+ * @returns Frozen public issue array.
32
51
  */
33
52
  export function finalizeIssueArray(value) {
34
53
  if (!isUnknownArray(value)) {
@@ -40,7 +59,11 @@ export function finalizeIssueArray(value) {
40
59
  return copyIssueArray(value);
41
60
  }
42
61
  /**
43
- * @brief freeze issue array.
62
+ * @brief Freeze issues and their path arrays in-place.
63
+ * @details Paths are built mutably for speed during collection, then hardened
64
+ * before callers can retain or format the diagnostics.
65
+ * @param issues Issue array to harden.
66
+ * @returns The same issue array after freezing.
44
67
  */
45
68
  export function freezeIssueArray(issues) {
46
69
  for (let index = 0; index < issues.length; index += 1) {
@@ -53,7 +76,11 @@ export function freezeIssueArray(issues) {
53
76
  return Object.freeze(issues);
54
77
  }
55
78
  /**
56
- * @brief copy issue.
79
+ * @brief Copy and validate one issue-like object.
80
+ * @details Only own data read syntax is used here because the candidate object
81
+ * has already been reduced to a plain record by `isRecord`.
82
+ * @param value Candidate issue object.
83
+ * @returns Normalized mutable issue record.
57
84
  */
58
85
  function copyIssue(value) {
59
86
  if (!isRecord(value)) {
@@ -75,12 +102,19 @@ function copyIssue(value) {
75
102
  return makeIssue(path, code, expected, actual, message);
76
103
  }
77
104
  /**
78
- * @brief copy path.
105
+ * @brief Copy and validate an issue path.
106
+ * @details Negative and fractional numeric segments are rejected because TypeSea
107
+ * only emits non-negative array indexes.
108
+ * @param value Candidate path array.
109
+ * @returns Copied path, or the shared empty-path sentinel.
79
110
  */
80
111
  function copyPath(value) {
81
112
  if (!isUnknownArray(value)) {
82
113
  throw new TypeError("issue path must be an array");
83
114
  }
115
+ if (value.length === 0) {
116
+ return EMPTY_PATH;
117
+ }
84
118
  const copied = new Array(value.length);
85
119
  for (let index = 0; index < value.length; index += 1) {
86
120
  const segment = value[index];
@@ -99,7 +133,11 @@ function copyPath(value) {
99
133
  return copied;
100
134
  }
101
135
  /**
102
- * @brief is issue code value.
136
+ * @brief Check whether a value is one of TypeSea's stable issue codes.
137
+ * @details Issue helpers publish frozen diagnostics so adapters and callers cannot mutate
138
+ * validation results later.
139
+ * @param value Candidate issue code.
140
+ * @returns True when the value belongs to the closed issue-code set.
103
141
  */
104
142
  export function isIssueCodeValue(value) {
105
143
  switch (value) {
@@ -133,19 +171,31 @@ export function isIssueCodeValue(value) {
133
171
  }
134
172
  }
135
173
  /**
136
- * @brief is optional string.
174
+ * @brief Accept optional text fields used by issue diagnostics.
175
+ * @details Issue helpers publish frozen diagnostics so adapters and callers cannot mutate
176
+ * validation results later.
177
+ * @param value Candidate issue text field.
178
+ * @returns True for string values and undefined.
137
179
  */
138
180
  function isOptionalString(value) {
139
181
  return value === undefined || typeof value === "string";
140
182
  }
141
183
  /**
142
- * @brief is record.
184
+ * @brief Check whether a value can be read as an issue-like record.
185
+ * @details Issue helpers publish frozen diagnostics so adapters and callers cannot mutate
186
+ * validation results later.
187
+ * @param value Candidate runtime value.
188
+ * @returns True for non-array object values.
143
189
  */
144
190
  function isRecord(value) {
145
191
  return typeof value === "object" && value !== null && !Array.isArray(value);
146
192
  }
147
193
  /**
148
- * @brief is unknown array.
194
+ * @brief Check whether a value is an array before indexed reads.
195
+ * @details Issue helpers publish frozen diagnostics so adapters and callers cannot mutate
196
+ * validation results later.
197
+ * @param value Candidate runtime value.
198
+ * @returns True when the value is an array.
149
199
  */
150
200
  function isUnknownArray(value) {
151
201
  return Array.isArray(value);
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * @file emit-combinator.ts
3
3
  * @brief Combinator 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 { SchemaTag } from "../kind/index.js";
6
8
  import type { PathSegment } from "../issue/index.js";
@@ -8,21 +10,59 @@ import type { Schema } from "../schema/index.js";
8
10
  import type { JsonSchemaEmitter } from "./emit-types.js";
9
11
  import type { JsonSchema, JsonSchemaDialect, JsonSchemaExportIssue } from "./types.js";
10
12
  /**
11
- * @brief emit union.
13
+ * @brief Emit a TypeSea union as a JSON Schema `anyOf` list.
14
+ * @details Each branch is emitted with its index appended to the issue path so
15
+ * unsupported children can be reported precisely. A single failed child aborts
16
+ * the whole union because dropping a branch would make the exported schema
17
+ * stricter than the TypeSea validator.
18
+ * @param options Union option schemas in declaration order.
19
+ * @param path Mutable issue path stack owned by the export walk.
20
+ * @param issues Mutable export issue buffer.
21
+ * @param emitChild Recursive schema emitter callback.
22
+ * @param dialect Target JSON Schema dialect.
23
+ * @returns JSON Schema union, or undefined when a child cannot be emitted.
12
24
  */
13
25
  export declare function emitUnion(options: readonly Schema[], path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
14
26
  /**
15
- * @brief emit intersection.
27
+ * @brief Emit a TypeSea intersection as a JSON Schema `allOf` pair.
28
+ * @details Both sides must be representable. If either side fails, the exported
29
+ * schema would no longer model the same acceptance set, so the emitter reports
30
+ * the failed side and returns undefined.
31
+ * @param left Left intersection operand.
32
+ * @param right Right intersection operand.
33
+ * @param path Mutable issue path stack owned by the export walk.
34
+ * @param issues Mutable export issue buffer.
35
+ * @param emitChild Recursive schema emitter callback.
36
+ * @param dialect Target JSON Schema dialect.
37
+ * @returns JSON Schema intersection, or undefined when a side cannot be emitted.
16
38
  */
17
39
  export declare function emitIntersection(left: Schema, right: Schema, path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
18
40
  /**
19
- * @brief emit discriminated union.
41
+ * @brief Emit a discriminated union through the general union exporter.
42
+ * @details JSON Schema output does not need TypeSea's dispatch table; it only
43
+ * needs the branch schemas. The discriminant proof has already been enforced at
44
+ * builder time, so preserving branch order is enough for diagnostics.
45
+ * @param cases Discriminated-union cases from the TypeSea schema.
46
+ * @param path Mutable issue path stack owned by the export walk.
47
+ * @param issues Mutable export issue buffer.
48
+ * @param emitChild Recursive schema emitter callback.
49
+ * @param dialect Target JSON Schema dialect.
50
+ * @returns JSON Schema union, or undefined when a child cannot be emitted.
20
51
  */
21
52
  export declare function emitDiscriminatedUnion(cases: Extract<Schema, {
22
53
  readonly tag: typeof SchemaTag.DiscriminatedUnion;
23
54
  }>["cases"], path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
24
55
  /**
25
- * @brief emit nullable.
56
+ * @brief Emit a nullable wrapper as an `anyOf` with `null`.
57
+ * @details The wrapped schema is emitted first so unsupported inner constructs
58
+ * are reported at a stable `nullable` path segment instead of silently widening
59
+ * to just null.
60
+ * @param inner Inner TypeSea schema.
61
+ * @param path Mutable issue path stack owned by the export walk.
62
+ * @param issues Mutable export issue buffer.
63
+ * @param emitChild Recursive schema emitter callback.
64
+ * @param dialect Target JSON Schema dialect.
65
+ * @returns Nullable JSON Schema, or undefined when the inner schema fails.
26
66
  */
27
67
  export declare function emitNullable(inner: Schema, path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
28
68
  //# sourceMappingURL=emit-combinator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emit-combinator.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit-combinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EACV,UAAU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
@@ -1,11 +1,23 @@
1
1
  /**
2
2
  * @file emit-combinator.ts
3
3
  * @brief Combinator 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 { SchemaTag } from "../kind/index.js";
6
8
  import { pushJsonSchemaIssue } from "./issue.js";
7
9
  /**
8
- * @brief emit union.
10
+ * @brief Emit a TypeSea union as a JSON Schema `anyOf` list.
11
+ * @details Each branch is emitted with its index appended to the issue path so
12
+ * unsupported children can be reported precisely. A single failed child aborts
13
+ * the whole union because dropping a branch would make the exported schema
14
+ * stricter than the TypeSea validator.
15
+ * @param options Union option schemas in declaration order.
16
+ * @param path Mutable issue path stack owned by the export walk.
17
+ * @param issues Mutable export issue buffer.
18
+ * @param emitChild Recursive schema emitter callback.
19
+ * @param dialect Target JSON Schema dialect.
20
+ * @returns JSON Schema union, or undefined when a child cannot be emitted.
9
21
  */
10
22
  export function emitUnion(options, path, issues, emitChild, dialect) {
11
23
  const emitted = new Array(options.length);
@@ -34,7 +46,17 @@ export function emitUnion(options, path, issues, emitChild, dialect) {
34
46
  };
35
47
  }
36
48
  /**
37
- * @brief emit intersection.
49
+ * @brief Emit a TypeSea intersection as a JSON Schema `allOf` pair.
50
+ * @details Both sides must be representable. If either side fails, the exported
51
+ * schema would no longer model the same acceptance set, so the emitter reports
52
+ * the failed side and returns undefined.
53
+ * @param left Left intersection operand.
54
+ * @param right Right intersection operand.
55
+ * @param path Mutable issue path stack owned by the export walk.
56
+ * @param issues Mutable export issue buffer.
57
+ * @param emitChild Recursive schema emitter callback.
58
+ * @param dialect Target JSON Schema dialect.
59
+ * @returns JSON Schema intersection, or undefined when a side cannot be emitted.
38
60
  */
39
61
  export function emitIntersection(left, right, path, issues, emitChild, dialect) {
40
62
  path.push("left");
@@ -61,7 +83,16 @@ export function emitIntersection(left, right, path, issues, emitChild, dialect)
61
83
  };
62
84
  }
63
85
  /**
64
- * @brief emit discriminated union.
86
+ * @brief Emit a discriminated union through the general union exporter.
87
+ * @details JSON Schema output does not need TypeSea's dispatch table; it only
88
+ * needs the branch schemas. The discriminant proof has already been enforced at
89
+ * builder time, so preserving branch order is enough for diagnostics.
90
+ * @param cases Discriminated-union cases from the TypeSea schema.
91
+ * @param path Mutable issue path stack owned by the export walk.
92
+ * @param issues Mutable export issue buffer.
93
+ * @param emitChild Recursive schema emitter callback.
94
+ * @param dialect Target JSON Schema dialect.
95
+ * @returns JSON Schema union, or undefined when a child cannot be emitted.
65
96
  */
66
97
  export function emitDiscriminatedUnion(cases, path, issues, emitChild, dialect) {
67
98
  const options = new Array(cases.length);
@@ -74,7 +105,16 @@ export function emitDiscriminatedUnion(cases, path, issues, emitChild, dialect)
74
105
  return emitUnion(options, path, issues, emitChild, dialect);
75
106
  }
76
107
  /**
77
- * @brief emit nullable.
108
+ * @brief Emit a nullable wrapper as an `anyOf` with `null`.
109
+ * @details The wrapped schema is emitted first so unsupported inner constructs
110
+ * are reported at a stable `nullable` path segment instead of silently widening
111
+ * to just null.
112
+ * @param inner Inner TypeSea schema.
113
+ * @param path Mutable issue path stack owned by the export walk.
114
+ * @param issues Mutable export issue buffer.
115
+ * @param emitChild Recursive schema emitter callback.
116
+ * @param dialect Target JSON Schema dialect.
117
+ * @returns Nullable JSON Schema, or undefined when the inner schema fails.
78
118
  */
79
119
  export function emitNullable(inner, path, issues, emitChild, dialect) {
80
120
  path.push("nullable");
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * @file emit-composite.ts
3
3
  * @brief Container 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 { SchemaTag } from "../kind/index.js";
6
8
  import type { PathSegment } from "../issue/index.js";
@@ -9,18 +11,26 @@ import type { JsonSchemaEmitter } from "./emit-types.js";
9
11
  import type { JsonSchema, JsonSchemaDialect, JsonSchemaExportIssue } from "./types.js";
10
12
  /**
11
13
  * @brief emit array.
14
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
15
+ * report a structured export issue.
12
16
  */
13
17
  export declare function emitArray(item: Schema, path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
14
18
  /**
15
19
  * @brief emit tuple.
20
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
21
+ * report a structured export issue.
16
22
  */
17
23
  export declare function emitTuple(items: readonly Schema[], path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
18
24
  /**
19
25
  * @brief emit record.
26
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
27
+ * report a structured export issue.
20
28
  */
21
29
  export declare function emitRecord(value: Schema, path: PathSegment[], issues: JsonSchemaExportIssue[], emitChild: JsonSchemaEmitter, dialect: JsonSchemaDialect): JsonSchema | undefined;
22
30
  /**
23
31
  * @brief emit object.
32
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
33
+ * report a structured export issue.
24
34
  */
25
35
  export declare function emitObject(schema: Extract<Schema, {
26
36
  readonly tag: typeof SchemaTag.Object;
@@ -1 +1 @@
1
- {"version":3,"file":"emit-composite.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit-composite.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,SAAS,EACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,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jB,qBAAqB,EAExB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iBAAiB,GAC3B,UAAU,GAAG,SAAS,CAaxB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACrB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iBAAiB,GAC3B,UAAU,GAAG,SAAS,CAqCxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iBAAiB,GAC3B,UAAU,GAAG,SAAS,CAaxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACtB,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iBAAiB,GAC3B,UAAU,GAAG,SAAS,CAoCxB"}
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * @file emit-composite.ts
3
3
  * @brief Container 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 { ObjectModeTag, PresenceTag, SchemaTag } from "../kind/index.js";
6
8
  import { pushJsonSchemaIssue } from "./issue.js";
7
9
  /**
8
10
  * @brief emit array.
11
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
12
+ * report a structured export issue.
9
13
  */
10
14
  export function emitArray(item, path, issues, emitChild, dialect) {
11
15
  path.push("items");
@@ -23,6 +27,8 @@ export function emitArray(item, path, issues, emitChild, dialect) {
23
27
  }
24
28
  /**
25
29
  * @brief emit tuple.
30
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
31
+ * report a structured export issue.
26
32
  */
27
33
  export function emitTuple(items, path, issues, emitChild, dialect) {
28
34
  const emitted = new Array(items.length);
@@ -64,6 +70,8 @@ export function emitTuple(items, path, issues, emitChild, dialect) {
64
70
  }
65
71
  /**
66
72
  * @brief emit record.
73
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
74
+ * report a structured export issue.
67
75
  */
68
76
  export function emitRecord(value, path, issues, emitChild, dialect) {
69
77
  path.push("additionalProperties");
@@ -81,6 +89,8 @@ export function emitRecord(value, path, issues, emitChild, dialect) {
81
89
  }
82
90
  /**
83
91
  * @brief emit object.
92
+ * @details JSON Schema helpers emit only representations that preserve TypeSea semantics or
93
+ * report a structured export issue.
84
94
  */
85
95
  export function emitObject(schema, path, issues, emitChild, dialect) {
86
96
  const properties = makeJsonSchemaProperties();
@@ -120,7 +130,11 @@ export function emitObject(schema, path, issues, emitChild, dialect) {
120
130
  return result;
121
131
  }
122
132
  /**
123
- * @brief make json schema properties.
133
+ * @brief Allocate the JSON Schema property table with no prototype chain.
134
+ * @details Object schema keys originate from user models. A null-prototype map
135
+ * prevents names such as `constructor` from colliding with inherited object
136
+ * members while keeping writes monomorphic for the emitter loop.
137
+ * @returns Empty mutable property table for an object schema emission pass.
124
138
  */
125
139
  function makeJsonSchemaProperties() {
126
140
  return Object.create(null);
@@ -1,25 +1,48 @@
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 { SchemaTag } from "../kind/index.js";
6
8
  import type { PathSegment } from "../issue/index.js";
7
9
  import { type LiteralValue, type Schema } from "../schema/index.js";
8
10
  import type { JsonSchema, JsonSchemaExportIssue } from "./types.js";
9
11
  /**
10
- * @brief emit string.
12
+ * @brief Emit TypeSea string checks into JSON Schema string keywords.
13
+ * @details Repeated min and max checks collapse to the strongest bounds.
14
+ * Regular expressions are emitted only when their flags can be preserved by the
15
+ * JSON Schema `pattern` keyword; unsupported flags are reported as issues.
16
+ * @param schema String schema to emit.
17
+ * @param path Mutable issue path stack owned by the export walk.
18
+ * @param issues Mutable export issue buffer.
19
+ * @returns JSON Schema string object.
11
20
  */
12
21
  export declare function emitString(schema: Extract<Schema, {
13
22
  readonly tag: typeof SchemaTag.String;
14
23
  }>, path: PathSegment[], issues: JsonSchemaExportIssue[]): JsonSchema;
15
24
  /**
16
- * @brief emit number.
25
+ * @brief Emit TypeSea number checks into JSON Schema number keywords.
26
+ * @details Integer checks narrow the emitted type, while finite lower and upper
27
+ * bounds collapse to the strongest minimum and maximum. Non-finite bounds are
28
+ * rejected because JSON Schema cannot preserve them portably.
29
+ * @param schema Number schema to emit.
30
+ * @param path Mutable issue path stack owned by the export walk.
31
+ * @param issues Mutable export issue buffer.
32
+ * @returns JSON Schema number object, or undefined when bounds are unsupported.
17
33
  */
18
34
  export declare function emitNumber(schema: Extract<Schema, {
19
35
  readonly tag: typeof SchemaTag.Number;
20
36
  }>, path: PathSegment[], issues: JsonSchemaExportIssue[]): JsonSchema | undefined;
21
37
  /**
22
- * @brief emit literal.
38
+ * @brief Emit a literal schema as a JSON Schema `const` value.
39
+ * @details Only JSON-compatible literals are accepted. Undefined, bigint,
40
+ * symbol, NaN, infinity, and negative zero have no faithful JSON Schema literal
41
+ * encoding, so they become export issues instead of weakened output.
42
+ * @param value Literal value carried by the TypeSea schema.
43
+ * @param path Mutable issue path stack owned by the export walk.
44
+ * @param issues Mutable export issue buffer.
45
+ * @returns JSON Schema const object, or undefined for unsupported literals.
23
46
  */
24
47
  export declare function emitLiteral(value: LiteralValue, path: PathSegment[], issues: JsonSchemaExportIssue[]): JsonSchema | undefined;
25
48
  //# sourceMappingURL=emit-scalar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emit-scalar.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit-scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,SAAS,EAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,GAC9B,UAAU,CAkCZ;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,GAC9B,UAAU,GAAG,SAAS,CAiCxB;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,qBAAqB,EAAE,GAC9B,UAAU,GAAG,SAAS,CAyBxB"}
1
+ {"version":3,"file":"emit-scalar.d.ts","sourceRoot":"","sources":["../../src/json-schema/emit-scalar.ts"],"names":[],"mappings":"AAAA;;;;;GAK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