@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.6

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 (655) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +415 -2
  3. package/dist/article.d.ts +12 -0
  4. package/dist/article.d.ts.map +1 -0
  5. package/dist/article.js +16 -0
  6. package/dist/article.js.map +1 -0
  7. package/dist/cli/args.d.ts +101 -0
  8. package/dist/cli/args.d.ts.map +1 -0
  9. package/dist/cli/args.js +158 -0
  10. package/dist/cli/args.js.map +1 -0
  11. package/dist/cli/check.d.ts +2 -0
  12. package/dist/cli/check.d.ts.map +1 -0
  13. package/dist/cli/check.js +33 -0
  14. package/dist/cli/check.js.map +1 -0
  15. package/dist/cli/compile.d.ts +2 -0
  16. package/dist/cli/compile.d.ts.map +1 -0
  17. package/dist/cli/compile.js +43 -0
  18. package/dist/cli/compile.js.map +1 -0
  19. package/dist/cli/count.d.ts +15 -0
  20. package/dist/cli/count.d.ts.map +1 -0
  21. package/dist/cli/count.js +21 -0
  22. package/dist/cli/count.js.map +1 -0
  23. package/dist/cli/dataset.d.ts +28 -0
  24. package/dist/cli/dataset.d.ts.map +1 -0
  25. package/dist/cli/dataset.js +115 -0
  26. package/dist/cli/dataset.js.map +1 -0
  27. package/dist/cli/diff.d.ts +2 -0
  28. package/dist/cli/diff.d.ts.map +1 -0
  29. package/dist/cli/diff.js +297 -0
  30. package/dist/cli/diff.js.map +1 -0
  31. package/dist/cli/explain.d.ts +2 -0
  32. package/dist/cli/explain.d.ts.map +1 -0
  33. package/dist/cli/explain.js +95 -0
  34. package/dist/cli/explain.js.map +1 -0
  35. package/dist/cli/fields.d.ts +11 -0
  36. package/dist/cli/fields.d.ts.map +1 -0
  37. package/dist/cli/fields.js +13 -0
  38. package/dist/cli/fields.js.map +1 -0
  39. package/dist/cli/main.d.ts +2 -0
  40. package/dist/cli/main.d.ts.map +1 -0
  41. package/dist/cli/main.js +40 -0
  42. package/dist/cli/main.js.map +1 -0
  43. package/dist/cli/read.d.ts +56 -0
  44. package/dist/cli/read.d.ts.map +1 -0
  45. package/dist/cli/read.js +179 -0
  46. package/dist/cli/read.js.map +1 -0
  47. package/dist/cli/render.d.ts +58 -0
  48. package/dist/cli/render.d.ts.map +1 -0
  49. package/dist/cli/render.js +422 -0
  50. package/dist/cli/render.js.map +1 -0
  51. package/dist/cli/schema.d.ts +28 -0
  52. package/dist/cli/schema.d.ts.map +1 -0
  53. package/dist/cli/schema.js +46 -0
  54. package/dist/cli/schema.js.map +1 -0
  55. package/dist/cli/suite-report.d.ts +18 -0
  56. package/dist/cli/suite-report.d.ts.map +1 -0
  57. package/dist/cli/suite-report.js +58 -0
  58. package/dist/cli/suite-report.js.map +1 -0
  59. package/dist/cli/suites.d.ts +25 -0
  60. package/dist/cli/suites.d.ts.map +1 -0
  61. package/dist/cli/suites.js +67 -0
  62. package/dist/cli/suites.js.map +1 -0
  63. package/dist/cli/terminal.d.ts +45 -0
  64. package/dist/cli/terminal.d.ts.map +1 -0
  65. package/dist/cli/terminal.js +119 -0
  66. package/dist/cli/terminal.js.map +1 -0
  67. package/dist/cli/test.d.ts +12 -0
  68. package/dist/cli/test.d.ts.map +1 -0
  69. package/dist/cli/test.js +199 -0
  70. package/dist/cli/test.js.map +1 -0
  71. package/dist/cli/usage.d.ts +15 -0
  72. package/dist/cli/usage.d.ts.map +1 -0
  73. package/dist/cli/usage.js +95 -0
  74. package/dist/cli/usage.js.map +1 -0
  75. package/dist/cli.d.ts +3 -0
  76. package/dist/cli.d.ts.map +1 -0
  77. package/dist/cli.js +51 -0
  78. package/dist/cli.js.map +1 -0
  79. package/dist/compile/artifact-members.d.ts +57 -0
  80. package/dist/compile/artifact-members.d.ts.map +1 -0
  81. package/dist/compile/artifact-members.js +130 -0
  82. package/dist/compile/artifact-members.js.map +1 -0
  83. package/dist/compile/artifact.d.ts +20 -0
  84. package/dist/compile/artifact.d.ts.map +1 -0
  85. package/dist/compile/artifact.js +87 -0
  86. package/dist/compile/artifact.js.map +1 -0
  87. package/dist/compile/compilation.d.ts +46 -0
  88. package/dist/compile/compilation.d.ts.map +1 -0
  89. package/dist/compile/compilation.js +4 -0
  90. package/dist/compile/compilation.js.map +1 -0
  91. package/dist/compile/computed.d.ts +22 -0
  92. package/dist/compile/computed.d.ts.map +1 -0
  93. package/dist/compile/computed.js +245 -0
  94. package/dist/compile/computed.js.map +1 -0
  95. package/dist/compile/condition-warnings.d.ts +12 -0
  96. package/dist/compile/condition-warnings.d.ts.map +1 -0
  97. package/dist/compile/condition-warnings.js +26 -0
  98. package/dist/compile/condition-warnings.js.map +1 -0
  99. package/dist/compile/conditions.d.ts +18 -0
  100. package/dist/compile/conditions.d.ts.map +1 -0
  101. package/dist/compile/conditions.js +22 -0
  102. package/dist/compile/conditions.js.map +1 -0
  103. package/dist/compile/cross-checks.d.ts +67 -0
  104. package/dist/compile/cross-checks.d.ts.map +1 -0
  105. package/dist/compile/cross-checks.js +238 -0
  106. package/dist/compile/cross-checks.js.map +1 -0
  107. package/dist/compile/datasets.d.ts +52 -0
  108. package/dist/compile/datasets.d.ts.map +1 -0
  109. package/dist/compile/datasets.js +183 -0
  110. package/dist/compile/datasets.js.map +1 -0
  111. package/dist/compile/dead-weight.d.ts +26 -0
  112. package/dist/compile/dead-weight.d.ts.map +1 -0
  113. package/dist/compile/dead-weight.js +244 -0
  114. package/dist/compile/dead-weight.js.map +1 -0
  115. package/dist/compile/declaration-rules.d.ts +54 -0
  116. package/dist/compile/declaration-rules.d.ts.map +1 -0
  117. package/dist/compile/declaration-rules.js +510 -0
  118. package/dist/compile/declaration-rules.js.map +1 -0
  119. package/dist/compile/declarations.d.ts +44 -0
  120. package/dist/compile/declarations.d.ts.map +1 -0
  121. package/dist/compile/declarations.js +160 -0
  122. package/dist/compile/declarations.js.map +1 -0
  123. package/dist/compile/document.d.ts +4 -0
  124. package/dist/compile/document.d.ts.map +1 -0
  125. package/dist/compile/document.js +13 -0
  126. package/dist/compile/document.js.map +1 -0
  127. package/dist/compile/expression.d.ts +38 -0
  128. package/dist/compile/expression.d.ts.map +1 -0
  129. package/dist/compile/expression.js +288 -0
  130. package/dist/compile/expression.js.map +1 -0
  131. package/dist/compile/hashes.d.ts +26 -0
  132. package/dist/compile/hashes.d.ts.map +1 -0
  133. package/dist/compile/hashes.js +96 -0
  134. package/dist/compile/hashes.js.map +1 -0
  135. package/dist/compile/item-targets.d.ts +12 -0
  136. package/dist/compile/item-targets.d.ts.map +1 -0
  137. package/dist/compile/item-targets.js +287 -0
  138. package/dist/compile/item-targets.js.map +1 -0
  139. package/dist/compile/messages.d.ts +8 -0
  140. package/dist/compile/messages.d.ts.map +1 -0
  141. package/dist/compile/messages.js +62 -0
  142. package/dist/compile/messages.js.map +1 -0
  143. package/dist/compile/option-availability.d.ts +51 -0
  144. package/dist/compile/option-availability.d.ts.map +1 -0
  145. package/dist/compile/option-availability.js +171 -0
  146. package/dist/compile/option-availability.js.map +1 -0
  147. package/dist/compile/option-codes.d.ts +27 -0
  148. package/dist/compile/option-codes.d.ts.map +1 -0
  149. package/dist/compile/option-codes.js +212 -0
  150. package/dist/compile/option-codes.js.map +1 -0
  151. package/dist/compile/references.d.ts +14 -0
  152. package/dist/compile/references.d.ts.map +1 -0
  153. package/dist/compile/references.js +126 -0
  154. package/dist/compile/references.js.map +1 -0
  155. package/dist/compile/rows-from.d.ts +27 -0
  156. package/dist/compile/rows-from.d.ts.map +1 -0
  157. package/dist/compile/rows-from.js +164 -0
  158. package/dist/compile/rows-from.js.map +1 -0
  159. package/dist/compile/rules.d.ts +58 -0
  160. package/dist/compile/rules.d.ts.map +1 -0
  161. package/dist/compile/rules.js +327 -0
  162. package/dist/compile/rules.js.map +1 -0
  163. package/dist/compile/suggestions.d.ts +52 -0
  164. package/dist/compile/suggestions.d.ts.map +1 -0
  165. package/dist/compile/suggestions.js +633 -0
  166. package/dist/compile/suggestions.js.map +1 -0
  167. package/dist/compile/targets.d.ts +22 -0
  168. package/dist/compile/targets.d.ts.map +1 -0
  169. package/dist/compile/targets.js +125 -0
  170. package/dist/compile/targets.js.map +1 -0
  171. package/dist/compile/types.d.ts +84 -0
  172. package/dist/compile/types.d.ts.map +1 -0
  173. package/dist/compile/types.js +2 -0
  174. package/dist/compile/types.js.map +1 -0
  175. package/dist/compile/warning.d.ts +45 -0
  176. package/dist/compile/warning.d.ts.map +1 -0
  177. package/dist/compile/warning.js +2 -0
  178. package/dist/compile/warning.js.map +1 -0
  179. package/dist/compile-yaml.d.ts +23 -0
  180. package/dist/compile-yaml.d.ts.map +1 -0
  181. package/dist/compile-yaml.js +30 -0
  182. package/dist/compile-yaml.js.map +1 -0
  183. package/dist/compile.d.ts +78 -0
  184. package/dist/compile.d.ts.map +1 -0
  185. package/dist/compile.js +372 -0
  186. package/dist/compile.js.map +1 -0
  187. package/dist/csv/limits.d.ts +43 -0
  188. package/dist/csv/limits.d.ts.map +1 -0
  189. package/dist/csv/limits.js +51 -0
  190. package/dist/csv/limits.js.map +1 -0
  191. package/dist/csv/scalar.d.ts +33 -0
  192. package/dist/csv/scalar.d.ts.map +1 -0
  193. package/dist/csv/scalar.js +77 -0
  194. package/dist/csv/scalar.js.map +1 -0
  195. package/dist/datasets/csv.d.ts +46 -0
  196. package/dist/datasets/csv.d.ts.map +1 -0
  197. package/dist/datasets/csv.js +293 -0
  198. package/dist/datasets/csv.js.map +1 -0
  199. package/dist/datasets/declaration.d.ts +16 -0
  200. package/dist/datasets/declaration.d.ts.map +1 -0
  201. package/dist/datasets/declaration.js +104 -0
  202. package/dist/datasets/declaration.js.map +1 -0
  203. package/dist/datasets/diagnostics.d.ts +65 -0
  204. package/dist/datasets/diagnostics.d.ts.map +1 -0
  205. package/dist/datasets/diagnostics.js +2 -0
  206. package/dist/datasets/diagnostics.js.map +1 -0
  207. package/dist/datasets/diff.d.ts +46 -0
  208. package/dist/datasets/diff.d.ts.map +1 -0
  209. package/dist/datasets/diff.js +84 -0
  210. package/dist/datasets/diff.js.map +1 -0
  211. package/dist/datasets/document.d.ts +12 -0
  212. package/dist/datasets/document.d.ts.map +1 -0
  213. package/dist/datasets/document.js +382 -0
  214. package/dist/datasets/document.js.map +1 -0
  215. package/dist/datasets/index.d.ts +43 -0
  216. package/dist/datasets/index.d.ts.map +1 -0
  217. package/dist/datasets/index.js +68 -0
  218. package/dist/datasets/index.js.map +1 -0
  219. package/dist/datasets/repair.d.ts +26 -0
  220. package/dist/datasets/repair.d.ts.map +1 -0
  221. package/dist/datasets/repair.js +60 -0
  222. package/dist/datasets/repair.js.map +1 -0
  223. package/dist/document-path.d.ts +62 -0
  224. package/dist/document-path.d.ts.map +1 -0
  225. package/dist/document-path.js +200 -0
  226. package/dist/document-path.js.map +1 -0
  227. package/dist/expr/boundary.d.ts +8 -0
  228. package/dist/expr/boundary.d.ts.map +1 -0
  229. package/dist/expr/boundary.js +243 -0
  230. package/dist/expr/boundary.js.map +1 -0
  231. package/dist/expr/compile-expr.d.ts +35 -0
  232. package/dist/expr/compile-expr.d.ts.map +1 -0
  233. package/dist/expr/compile-expr.js +66 -0
  234. package/dist/expr/compile-expr.js.map +1 -0
  235. package/dist/expr/deprecation.d.ts +23 -0
  236. package/dist/expr/deprecation.d.ts.map +1 -0
  237. package/dist/expr/deprecation.js +28 -0
  238. package/dist/expr/deprecation.js.map +1 -0
  239. package/dist/expr/diagnostics.d.ts +31 -0
  240. package/dist/expr/diagnostics.d.ts.map +1 -0
  241. package/dist/expr/diagnostics.js +34 -0
  242. package/dist/expr/diagnostics.js.map +1 -0
  243. package/dist/expr/lexer.d.ts +49 -0
  244. package/dist/expr/lexer.d.ts.map +1 -0
  245. package/dist/expr/lexer.js +277 -0
  246. package/dist/expr/lexer.js.map +1 -0
  247. package/dist/expr/lint-warnings.d.ts +11 -0
  248. package/dist/expr/lint-warnings.d.ts.map +1 -0
  249. package/dist/expr/lint-warnings.js +20 -0
  250. package/dist/expr/lint-warnings.js.map +1 -0
  251. package/dist/expr/lint.d.ts +41 -0
  252. package/dist/expr/lint.d.ts.map +1 -0
  253. package/dist/expr/lint.js +1034 -0
  254. package/dist/expr/lint.js.map +1 -0
  255. package/dist/expr/parse/aggregates.d.ts +13 -0
  256. package/dist/expr/parse/aggregates.d.ts.map +1 -0
  257. package/dist/expr/parse/aggregates.js +48 -0
  258. package/dist/expr/parse/aggregates.js.map +1 -0
  259. package/dist/expr/parse/budget.d.ts +11 -0
  260. package/dist/expr/parse/budget.d.ts.map +1 -0
  261. package/dist/expr/parse/budget.js +57 -0
  262. package/dist/expr/parse/budget.js.map +1 -0
  263. package/dist/expr/parse/grammar.d.ts +9 -0
  264. package/dist/expr/parse/grammar.d.ts.map +1 -0
  265. package/dist/expr/parse/grammar.js +699 -0
  266. package/dist/expr/parse/grammar.js.map +1 -0
  267. package/dist/expr/parse/literals.d.ts +20 -0
  268. package/dist/expr/parse/literals.d.ts.map +1 -0
  269. package/dist/expr/parse/literals.js +132 -0
  270. package/dist/expr/parse/literals.js.map +1 -0
  271. package/dist/expr/parse/stream.d.ts +60 -0
  272. package/dist/expr/parse/stream.d.ts.map +1 -0
  273. package/dist/expr/parse/stream.js +151 -0
  274. package/dist/expr/parse/stream.js.map +1 -0
  275. package/dist/expr/parser.d.ts +45 -0
  276. package/dist/expr/parser.d.ts.map +1 -0
  277. package/dist/expr/parser.js +110 -0
  278. package/dist/expr/parser.js.map +1 -0
  279. package/dist/expr/print/spell.d.ts +78 -0
  280. package/dist/expr/print/spell.d.ts.map +1 -0
  281. package/dist/expr/print/spell.js +592 -0
  282. package/dist/expr/print/spell.js.map +1 -0
  283. package/dist/expr/print.d.ts +20 -0
  284. package/dist/expr/print.d.ts.map +1 -0
  285. package/dist/expr/print.js +102 -0
  286. package/dist/expr/print.js.map +1 -0
  287. package/dist/expr/suggest.d.ts +26 -0
  288. package/dist/expr/suggest.d.ts.map +1 -0
  289. package/dist/expr/suggest.js +77 -0
  290. package/dist/expr/suggest.js.map +1 -0
  291. package/dist/expr/typecheck/aggregates.d.ts +8 -0
  292. package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
  293. package/dist/expr/typecheck/aggregates.js +334 -0
  294. package/dist/expr/typecheck/aggregates.js.map +1 -0
  295. package/dist/expr/typecheck/arithmetic.d.ts +6 -0
  296. package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
  297. package/dist/expr/typecheck/arithmetic.js +258 -0
  298. package/dist/expr/typecheck/arithmetic.js.map +1 -0
  299. package/dist/expr/typecheck/arity.d.ts +38 -0
  300. package/dist/expr/typecheck/arity.d.ts.map +1 -0
  301. package/dist/expr/typecheck/arity.js +173 -0
  302. package/dist/expr/typecheck/arity.js.map +1 -0
  303. package/dist/expr/typecheck/calls.d.ts +6 -0
  304. package/dist/expr/typecheck/calls.d.ts.map +1 -0
  305. package/dist/expr/typecheck/calls.js +137 -0
  306. package/dist/expr/typecheck/calls.js.map +1 -0
  307. package/dist/expr/typecheck/comparison.d.ts +13 -0
  308. package/dist/expr/typecheck/comparison.d.ts.map +1 -0
  309. package/dist/expr/typecheck/comparison.js +200 -0
  310. package/dist/expr/typecheck/comparison.js.map +1 -0
  311. package/dist/expr/typecheck/compound.d.ts +24 -0
  312. package/dist/expr/typecheck/compound.d.ts.map +1 -0
  313. package/dist/expr/typecheck/compound.js +175 -0
  314. package/dist/expr/typecheck/compound.js.map +1 -0
  315. package/dist/expr/typecheck/context.d.ts +44 -0
  316. package/dist/expr/typecheck/context.d.ts.map +1 -0
  317. package/dist/expr/typecheck/context.js +2 -0
  318. package/dist/expr/typecheck/context.js.map +1 -0
  319. package/dist/expr/typecheck/datasets.d.ts +17 -0
  320. package/dist/expr/typecheck/datasets.d.ts.map +1 -0
  321. package/dist/expr/typecheck/datasets.js +136 -0
  322. package/dist/expr/typecheck/datasets.js.map +1 -0
  323. package/dist/expr/typecheck/digest.d.ts +7 -0
  324. package/dist/expr/typecheck/digest.d.ts.map +1 -0
  325. package/dist/expr/typecheck/digest.js +44 -0
  326. package/dist/expr/typecheck/digest.js.map +1 -0
  327. package/dist/expr/typecheck/fold.d.ts +41 -0
  328. package/dist/expr/typecheck/fold.d.ts.map +1 -0
  329. package/dist/expr/typecheck/fold.js +71 -0
  330. package/dist/expr/typecheck/fold.js.map +1 -0
  331. package/dist/expr/typecheck/gate-folds.d.ts +22 -0
  332. package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
  333. package/dist/expr/typecheck/gate-folds.js +40 -0
  334. package/dist/expr/typecheck/gate-folds.js.map +1 -0
  335. package/dist/expr/typecheck/guards.d.ts +6 -0
  336. package/dist/expr/typecheck/guards.d.ts.map +1 -0
  337. package/dist/expr/typecheck/guards.js +38 -0
  338. package/dist/expr/typecheck/guards.js.map +1 -0
  339. package/dist/expr/typecheck/member.d.ts +17 -0
  340. package/dist/expr/typecheck/member.d.ts.map +1 -0
  341. package/dist/expr/typecheck/member.js +46 -0
  342. package/dist/expr/typecheck/member.js.map +1 -0
  343. package/dist/expr/typecheck/money.d.ts +8 -0
  344. package/dist/expr/typecheck/money.d.ts.map +1 -0
  345. package/dist/expr/typecheck/money.js +49 -0
  346. package/dist/expr/typecheck/money.js.map +1 -0
  347. package/dist/expr/typecheck/numeric.d.ts +8 -0
  348. package/dist/expr/typecheck/numeric.d.ts.map +1 -0
  349. package/dist/expr/typecheck/numeric.js +84 -0
  350. package/dist/expr/typecheck/numeric.js.map +1 -0
  351. package/dist/expr/typecheck/operands.d.ts +27 -0
  352. package/dist/expr/typecheck/operands.d.ts.map +1 -0
  353. package/dist/expr/typecheck/operands.js +106 -0
  354. package/dist/expr/typecheck/operands.js.map +1 -0
  355. package/dist/expr/typecheck/paths.d.ts +21 -0
  356. package/dist/expr/typecheck/paths.d.ts.map +1 -0
  357. package/dist/expr/typecheck/paths.js +321 -0
  358. package/dist/expr/typecheck/paths.js.map +1 -0
  359. package/dist/expr/typecheck/records.d.ts +24 -0
  360. package/dist/expr/typecheck/records.d.ts.map +1 -0
  361. package/dist/expr/typecheck/records.js +53 -0
  362. package/dist/expr/typecheck/records.js.map +1 -0
  363. package/dist/expr/typecheck/sequences.d.ts +15 -0
  364. package/dist/expr/typecheck/sequences.d.ts.map +1 -0
  365. package/dist/expr/typecheck/sequences.js +55 -0
  366. package/dist/expr/typecheck/sequences.js.map +1 -0
  367. package/dist/expr/typecheck/strings.d.ts +8 -0
  368. package/dist/expr/typecheck/strings.d.ts.map +1 -0
  369. package/dist/expr/typecheck/strings.js +188 -0
  370. package/dist/expr/typecheck/strings.js.map +1 -0
  371. package/dist/expr/typecheck/temporal.d.ts +7 -0
  372. package/dist/expr/typecheck/temporal.d.ts.map +1 -0
  373. package/dist/expr/typecheck/temporal.js +80 -0
  374. package/dist/expr/typecheck/temporal.js.map +1 -0
  375. package/dist/expr/typecheck/types.d.ts +163 -0
  376. package/dist/expr/typecheck/types.d.ts.map +1 -0
  377. package/dist/expr/typecheck/types.js +404 -0
  378. package/dist/expr/typecheck/types.js.map +1 -0
  379. package/dist/expr/typecheck.d.ts +75 -0
  380. package/dist/expr/typecheck.d.ts.map +1 -0
  381. package/dist/expr/typecheck.js +242 -0
  382. package/dist/expr/typecheck.js.map +1 -0
  383. package/dist/expr/undecided.d.ts +13 -0
  384. package/dist/expr/undecided.d.ts.map +1 -0
  385. package/dist/expr/undecided.js +58 -0
  386. package/dist/expr/undecided.js.map +1 -0
  387. package/dist/expr/values/code-points.d.ts +13 -0
  388. package/dist/expr/values/code-points.d.ts.map +1 -0
  389. package/dist/expr/values/code-points.js +25 -0
  390. package/dist/expr/values/code-points.js.map +1 -0
  391. package/dist/expr/values/inline.d.ts +77 -0
  392. package/dist/expr/values/inline.d.ts.map +1 -0
  393. package/dist/expr/values/inline.js +404 -0
  394. package/dist/expr/values/inline.js.map +1 -0
  395. package/dist/expr/values/interval.d.ts +19 -0
  396. package/dist/expr/values/interval.d.ts.map +1 -0
  397. package/dist/expr/values/interval.js +1180 -0
  398. package/dist/expr/values/interval.js.map +1 -0
  399. package/dist/index.d.ts +163 -0
  400. package/dist/index.d.ts.map +1 -0
  401. package/dist/index.js +128 -0
  402. package/dist/index.js.map +1 -0
  403. package/dist/ingest/document.d.ts +58 -0
  404. package/dist/ingest/document.d.ts.map +1 -0
  405. package/dist/ingest/document.js +83 -0
  406. package/dist/ingest/document.js.map +1 -0
  407. package/dist/ingest/yaml-document.d.ts +15 -0
  408. package/dist/ingest/yaml-document.d.ts.map +1 -0
  409. package/dist/ingest/yaml-document.js +42 -0
  410. package/dist/ingest/yaml-document.js.map +1 -0
  411. package/dist/ingest/yaml.d.ts +51 -0
  412. package/dist/ingest/yaml.d.ts.map +1 -0
  413. package/dist/ingest/yaml.js +340 -0
  414. package/dist/ingest/yaml.js.map +1 -0
  415. package/dist/layout/compile.d.ts +6 -0
  416. package/dist/layout/compile.d.ts.map +1 -0
  417. package/dist/layout/compile.js +224 -0
  418. package/dist/layout/compile.js.map +1 -0
  419. package/dist/layout/context.d.ts +12 -0
  420. package/dist/layout/context.d.ts.map +1 -0
  421. package/dist/layout/context.js +26 -0
  422. package/dist/layout/context.js.map +1 -0
  423. package/dist/layout/grammar.d.ts +34 -0
  424. package/dist/layout/grammar.d.ts.map +1 -0
  425. package/dist/layout/grammar.js +171 -0
  426. package/dist/layout/grammar.js.map +1 -0
  427. package/dist/layout/read.d.ts +54 -0
  428. package/dist/layout/read.d.ts.map +1 -0
  429. package/dist/layout/read.js +101 -0
  430. package/dist/layout/read.js.map +1 -0
  431. package/dist/layout/shape.d.ts +34 -0
  432. package/dist/layout/shape.d.ts.map +1 -0
  433. package/dist/layout/shape.js +149 -0
  434. package/dist/layout/shape.js.map +1 -0
  435. package/dist/messages/compile.d.ts +47 -0
  436. package/dist/messages/compile.d.ts.map +1 -0
  437. package/dist/messages/compile.js +202 -0
  438. package/dist/messages/compile.js.map +1 -0
  439. package/dist/messages/locale.d.ts +18 -0
  440. package/dist/messages/locale.d.ts.map +1 -0
  441. package/dist/messages/locale.js +33 -0
  442. package/dist/messages/locale.js.map +1 -0
  443. package/dist/messages/slots.d.ts +54 -0
  444. package/dist/messages/slots.d.ts.map +1 -0
  445. package/dist/messages/slots.js +137 -0
  446. package/dist/messages/slots.js.map +1 -0
  447. package/dist/overlay/compile-overlay.d.ts +29 -0
  448. package/dist/overlay/compile-overlay.d.ts.map +1 -0
  449. package/dist/overlay/compile-overlay.js +120 -0
  450. package/dist/overlay/compile-overlay.js.map +1 -0
  451. package/dist/overlay/compose.d.ts +26 -0
  452. package/dist/overlay/compose.d.ts.map +1 -0
  453. package/dist/overlay/compose.js +674 -0
  454. package/dist/overlay/compose.js.map +1 -0
  455. package/dist/overlay/types.d.ts +41 -0
  456. package/dist/overlay/types.d.ts.map +1 -0
  457. package/dist/overlay/types.js +2 -0
  458. package/dist/overlay/types.js.map +1 -0
  459. package/dist/publish/classify.d.ts +50 -0
  460. package/dist/publish/classify.d.ts.map +1 -0
  461. package/dist/publish/classify.js +85 -0
  462. package/dist/publish/classify.js.map +1 -0
  463. package/dist/publish/environment.d.ts +15 -0
  464. package/dist/publish/environment.d.ts.map +1 -0
  465. package/dist/publish/environment.js +2 -0
  466. package/dist/publish/environment.js.map +1 -0
  467. package/dist/publish/migrations.d.ts +108 -0
  468. package/dist/publish/migrations.d.ts.map +1 -0
  469. package/dist/publish/migrations.js +166 -0
  470. package/dist/publish/migrations.js.map +1 -0
  471. package/dist/publish/observation.d.ts +29 -0
  472. package/dist/publish/observation.d.ts.map +1 -0
  473. package/dist/publish/observation.js +43 -0
  474. package/dist/publish/observation.js.map +1 -0
  475. package/dist/publish/readiness.d.ts +197 -0
  476. package/dist/publish/readiness.d.ts.map +1 -0
  477. package/dist/publish/readiness.js +239 -0
  478. package/dist/publish/readiness.js.map +1 -0
  479. package/dist/publish/vectors.d.ts +50 -0
  480. package/dist/publish/vectors.d.ts.map +1 -0
  481. package/dist/publish/vectors.js +306 -0
  482. package/dist/publish/vectors.js.map +1 -0
  483. package/dist/publish/verify.d.ts +146 -0
  484. package/dist/publish/verify.d.ts.map +1 -0
  485. package/dist/publish/verify.js +548 -0
  486. package/dist/publish/verify.js.map +1 -0
  487. package/dist/scenarios/branch.d.ts +36 -0
  488. package/dist/scenarios/branch.d.ts.map +1 -0
  489. package/dist/scenarios/branch.js +30 -0
  490. package/dist/scenarios/branch.js.map +1 -0
  491. package/dist/scenarios/capture.d.ts +89 -0
  492. package/dist/scenarios/capture.d.ts.map +1 -0
  493. package/dist/scenarios/capture.js +443 -0
  494. package/dist/scenarios/capture.js.map +1 -0
  495. package/dist/scenarios/classifier.d.ts +20 -0
  496. package/dist/scenarios/classifier.d.ts.map +1 -0
  497. package/dist/scenarios/classifier.js +88 -0
  498. package/dist/scenarios/classifier.js.map +1 -0
  499. package/dist/scenarios/credit.d.ts +33 -0
  500. package/dist/scenarios/credit.d.ts.map +1 -0
  501. package/dist/scenarios/credit.js +330 -0
  502. package/dist/scenarios/credit.js.map +1 -0
  503. package/dist/scenarios/csv.d.ts +34 -0
  504. package/dist/scenarios/csv.d.ts.map +1 -0
  505. package/dist/scenarios/csv.js +1047 -0
  506. package/dist/scenarios/csv.js.map +1 -0
  507. package/dist/scenarios/data-identity.d.ts +39 -0
  508. package/dist/scenarios/data-identity.d.ts.map +1 -0
  509. package/dist/scenarios/data-identity.js +28 -0
  510. package/dist/scenarios/data-identity.js.map +1 -0
  511. package/dist/scenarios/document.d.ts +148 -0
  512. package/dist/scenarios/document.d.ts.map +1 -0
  513. package/dist/scenarios/document.js +513 -0
  514. package/dist/scenarios/document.js.map +1 -0
  515. package/dist/scenarios/environment.d.ts +64 -0
  516. package/dist/scenarios/environment.d.ts.map +1 -0
  517. package/dist/scenarios/environment.js +106 -0
  518. package/dist/scenarios/environment.js.map +1 -0
  519. package/dist/scenarios/evidence.d.ts +128 -0
  520. package/dist/scenarios/evidence.d.ts.map +1 -0
  521. package/dist/scenarios/evidence.js +179 -0
  522. package/dist/scenarios/evidence.js.map +1 -0
  523. package/dist/scenarios/expectations.d.ts +63 -0
  524. package/dist/scenarios/expectations.d.ts.map +1 -0
  525. package/dist/scenarios/expectations.js +490 -0
  526. package/dist/scenarios/expectations.js.map +1 -0
  527. package/dist/scenarios/references.d.ts +15 -0
  528. package/dist/scenarios/references.d.ts.map +1 -0
  529. package/dist/scenarios/references.js +239 -0
  530. package/dist/scenarios/references.js.map +1 -0
  531. package/dist/scenarios/report.d.ts +216 -0
  532. package/dist/scenarios/report.d.ts.map +1 -0
  533. package/dist/scenarios/report.js +54 -0
  534. package/dist/scenarios/report.js.map +1 -0
  535. package/dist/scenarios/runner.d.ts +55 -0
  536. package/dist/scenarios/runner.d.ts.map +1 -0
  537. package/dist/scenarios/runner.js +205 -0
  538. package/dist/scenarios/runner.js.map +1 -0
  539. package/dist/scenarios/vocabulary.d.ts +19 -0
  540. package/dist/scenarios/vocabulary.d.ts.map +1 -0
  541. package/dist/scenarios/vocabulary.js +56 -0
  542. package/dist/scenarios/vocabulary.js.map +1 -0
  543. package/dist/schema/catalogue.d.ts +54 -0
  544. package/dist/schema/catalogue.d.ts.map +1 -0
  545. package/dist/schema/catalogue.js +221 -0
  546. package/dist/schema/catalogue.js.map +1 -0
  547. package/dist/schema/check.d.ts +22 -0
  548. package/dist/schema/check.d.ts.map +1 -0
  549. package/dist/schema/check.js +30 -0
  550. package/dist/schema/check.js.map +1 -0
  551. package/dist/schema/closed.d.ts +19 -0
  552. package/dist/schema/closed.d.ts.map +1 -0
  553. package/dist/schema/closed.js +33 -0
  554. package/dist/schema/closed.js.map +1 -0
  555. package/dist/schema/collapse.d.ts +27 -0
  556. package/dist/schema/collapse.d.ts.map +1 -0
  557. package/dist/schema/collapse.js +143 -0
  558. package/dist/schema/collapse.js.map +1 -0
  559. package/dist/schema/controls.d.ts +46 -0
  560. package/dist/schema/controls.d.ts.map +1 -0
  561. package/dist/schema/controls.js +75 -0
  562. package/dist/schema/controls.js.map +1 -0
  563. package/dist/schema/dataset-declaration.d.ts +11 -0
  564. package/dist/schema/dataset-declaration.d.ts.map +1 -0
  565. package/dist/schema/dataset-declaration.js +11 -0
  566. package/dist/schema/dataset-declaration.js.map +1 -0
  567. package/dist/schema/declaration-warnings.d.ts +14 -0
  568. package/dist/schema/declaration-warnings.d.ts.map +1 -0
  569. package/dist/schema/declaration-warnings.js +77 -0
  570. package/dist/schema/declaration-warnings.js.map +1 -0
  571. package/dist/schema/declarations.d.ts +41 -0
  572. package/dist/schema/declarations.d.ts.map +1 -0
  573. package/dist/schema/declarations.js +1299 -0
  574. package/dist/schema/declarations.js.map +1 -0
  575. package/dist/schema/diagnostic.d.ts +118 -0
  576. package/dist/schema/diagnostic.d.ts.map +1 -0
  577. package/dist/schema/diagnostic.js +39 -0
  578. package/dist/schema/diagnostic.js.map +1 -0
  579. package/dist/schema/document.d.ts +93 -0
  580. package/dist/schema/document.d.ts.map +1 -0
  581. package/dist/schema/document.js +507 -0
  582. package/dist/schema/document.js.map +1 -0
  583. package/dist/schema/fields.d.ts +11 -0
  584. package/dist/schema/fields.d.ts.map +1 -0
  585. package/dist/schema/fields.js +265 -0
  586. package/dist/schema/fields.js.map +1 -0
  587. package/dist/schema/gates.d.ts +4 -0
  588. package/dist/schema/gates.d.ts.map +1 -0
  589. package/dist/schema/gates.js +68 -0
  590. package/dist/schema/gates.js.map +1 -0
  591. package/dist/schema/located.d.ts +27 -0
  592. package/dist/schema/located.d.ts.map +1 -0
  593. package/dist/schema/located.js +56 -0
  594. package/dist/schema/located.js.map +1 -0
  595. package/dist/schema/measurement.d.ts +9 -0
  596. package/dist/schema/measurement.d.ts.map +1 -0
  597. package/dist/schema/measurement.js +38 -0
  598. package/dist/schema/measurement.js.map +1 -0
  599. package/dist/schema/member-wording.d.ts +35 -0
  600. package/dist/schema/member-wording.d.ts.map +1 -0
  601. package/dist/schema/member-wording.js +286 -0
  602. package/dist/schema/member-wording.js.map +1 -0
  603. package/dist/schema/metaschema.d.ts +20 -0
  604. package/dist/schema/metaschema.d.ts.map +1 -0
  605. package/dist/schema/metaschema.js +476 -0
  606. package/dist/schema/metaschema.js.map +1 -0
  607. package/dist/schema/pointer.d.ts +31 -0
  608. package/dist/schema/pointer.d.ts.map +1 -0
  609. package/dist/schema/pointer.js +73 -0
  610. package/dist/schema/pointer.js.map +1 -0
  611. package/dist/schema/primary.d.ts +29 -0
  612. package/dist/schema/primary.d.ts.map +1 -0
  613. package/dist/schema/primary.js +48 -0
  614. package/dist/schema/primary.js.map +1 -0
  615. package/dist/schema/publish-vector.d.ts +17 -0
  616. package/dist/schema/publish-vector.d.ts.map +1 -0
  617. package/dist/schema/publish-vector.js +34 -0
  618. package/dist/schema/publish-vector.js.map +1 -0
  619. package/dist/schema/repair.d.ts +34 -0
  620. package/dist/schema/repair.d.ts.map +1 -0
  621. package/dist/schema/repair.js +163 -0
  622. package/dist/schema/repair.js.map +1 -0
  623. package/dist/schema/schema-v1.generated.d.ts +14 -0
  624. package/dist/schema/schema-v1.generated.d.ts.map +1 -0
  625. package/dist/schema/schema-v1.generated.js +7089 -0
  626. package/dist/schema/schema-v1.generated.js.map +1 -0
  627. package/dist/schema/screens.d.ts +4 -0
  628. package/dist/schema/screens.d.ts.map +1 -0
  629. package/dist/schema/screens.js +28 -0
  630. package/dist/schema/screens.js.map +1 -0
  631. package/dist/schema/test-values.d.ts +12 -0
  632. package/dist/schema/test-values.d.ts.map +1 -0
  633. package/dist/schema/test-values.js +97 -0
  634. package/dist/schema/test-values.js.map +1 -0
  635. package/dist/schema/unions.d.ts +46 -0
  636. package/dist/schema/unions.d.ts.map +1 -0
  637. package/dist/schema/unions.js +131 -0
  638. package/dist/schema/unions.js.map +1 -0
  639. package/dist/schema/validate-yaml.d.ts +14 -0
  640. package/dist/schema/validate-yaml.d.ts.map +1 -0
  641. package/dist/schema/validate-yaml.js +17 -0
  642. package/dist/schema/validate-yaml.js.map +1 -0
  643. package/dist/schema/validate.d.ts +46 -0
  644. package/dist/schema/validate.d.ts.map +1 -0
  645. package/dist/schema/validate.js +186 -0
  646. package/dist/schema/validate.js.map +1 -0
  647. package/dist/testing.d.ts +21 -0
  648. package/dist/testing.d.ts.map +1 -0
  649. package/dist/testing.js +28 -0
  650. package/dist/testing.js.map +1 -0
  651. package/dist/vocabulary.d.ts +6 -0
  652. package/dist/vocabulary.d.ts.map +1 -0
  653. package/dist/vocabulary.js +26 -0
  654. package/dist/vocabulary.js.map +1 -0
  655. package/package.json +66 -3
@@ -0,0 +1,58 @@
1
+ import type { JsonIngestReason } from '@azx-pbc/axiom-runtime';
2
+ import type { SchemaDiagnostic } from '../schema/diagnostic.js';
3
+ import type { YamlRefusalReason } from './yaml.js';
4
+ /**
5
+ * The two authoring spellings, and the boundary that reads JSON.
6
+ *
7
+ * A document is written as JSON or as YAML; the artifact is JSON either way. The format is
8
+ * chosen from the file extension and nothing else, so a `.json` file that happens to parse as
9
+ * YAML is still read as JSON and a `.yaml` file is never sniffed. Central input (`-`) has no
10
+ * extension, so it keeps the JSON meaning the command line has always given it.
11
+ *
12
+ * YAML lives in `yaml-document.ts` rather than behind the `format` argument here. `yaml`
13
+ * declares no `sideEffects` flag, so a bundler cannot drop it once this module imports it —
14
+ * even for a caller that only compiles JSON. Keeping the two readers in separate modules is
15
+ * what makes an import of `compile` cost the JSON reader alone; `test/packaging/size-budget`
16
+ * holds the result.
17
+ */
18
+ export type DocumentFormat = 'json' | 'yaml';
19
+ /** The format a path names, by extension alone. */
20
+ export declare function documentFormatOf(path: string): DocumentFormat;
21
+ /** One document read into the plain value the restriction profile admits. */
22
+ export type IngestedDocument = {
23
+ readonly ok: true;
24
+ readonly value: unknown;
25
+ } | {
26
+ readonly ok: false;
27
+ readonly diagnostics: readonly SchemaDiagnostic[];
28
+ };
29
+ /**
30
+ * The repair an ingestion refusal implies, where one form has a second spelling an author
31
+ * reaches for. A number outside the canonical profile is almost always a decimal or a money
32
+ * amount written the way a calculator would show it, so the refusal says how the wire contract
33
+ * spells it instead. The JSON and YAML front doors share this sentence, so one value refused
34
+ * by both reads the same.
35
+ */
36
+ export declare function ingestGuidance(reason: JsonIngestReason | YamlRefusalReason): string;
37
+ /**
38
+ * The refusal sentence a non-text source earns before any text reader sees it, or `undefined`
39
+ * when the caller supplied a string.
40
+ *
41
+ * The declared type is text, but a JavaScript caller can hand over anything: a request body,
42
+ * a stored value, or the result of a failed read. Every text front door checks this predicate
43
+ * and answers with a tagged diagnostic at `$` rather than letting a reader's `TypeError` escape.
44
+ */
45
+ export declare function nonTextSourceDetail(source: unknown, subject?: string): string | undefined;
46
+ /**
47
+ * The refusal a non-text source earns before either authoring reader sees it.
48
+ */
49
+ export declare function nonTextIngestRefusal(source: unknown, code: 'JSON_INGEST_ERROR' | 'YAML_INGEST_ERROR'): IngestedDocument;
50
+ /**
51
+ * Ingests one JSON document's text as the plain value the restriction profile admits.
52
+ *
53
+ * A non-text source is refused as ingestion data here, so `compile`'s guard is not the only
54
+ * place the contract is kept: a caller that reads a file and forwards the result crosses the
55
+ * same boundary.
56
+ */
57
+ export declare function ingestJsonDocument(source: string): IngestedDocument;
58
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/ingest/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAG7D;AAED,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAAE,CAAC;AAE9E;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,MAAM,CAInF;AAmBD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,SAAiB,GAAG,MAAM,GAAG,SAAS,CAGjG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,mBAAmB,GAAG,mBAAmB,GAC9C,gBAAgB,CAWlB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAQnE"}
@@ -0,0 +1,83 @@
1
+ import { JsonIngestError, parseRestrictedJson } from '@azx-pbc/axiom-runtime';
2
+ /** The format a path names, by extension alone. */
3
+ export function documentFormatOf(path) {
4
+ const lower = path.toLowerCase();
5
+ return lower.endsWith('.yaml') || lower.endsWith('.yml') ? 'yaml' : 'json';
6
+ }
7
+ /**
8
+ * The repair an ingestion refusal implies, where one form has a second spelling an author
9
+ * reaches for. A number outside the canonical profile is almost always a decimal or a money
10
+ * amount written the way a calculator would show it, so the refusal says how the wire contract
11
+ * spells it instead. The JSON and YAML front doors share this sentence, so one value refused
12
+ * by both reads the same.
13
+ */
14
+ export function ingestGuidance(reason) {
15
+ return reason === 'integer'
16
+ ? '; write decimals and money minor units as canonical decimal strings, never as JSON numbers'
17
+ : '';
18
+ }
19
+ function jsonIngestDiagnostic(cause) {
20
+ return {
21
+ code: 'JSON_INGEST_ERROR',
22
+ path: cause.path === '' ? '$' : cause.path,
23
+ detail: `${cause.message}${ingestGuidance(cause.reason)}`,
24
+ offset: cause.offset,
25
+ offsetSource: 'document',
26
+ };
27
+ }
28
+ /** What a caller supplied instead of document text, named without reading into it. */
29
+ function describeSource(source) {
30
+ if (source === null)
31
+ return 'null';
32
+ if (Array.isArray(source))
33
+ return 'an array';
34
+ return `a value of type ${typeof source}`;
35
+ }
36
+ /**
37
+ * The refusal sentence a non-text source earns before any text reader sees it, or `undefined`
38
+ * when the caller supplied a string.
39
+ *
40
+ * The declared type is text, but a JavaScript caller can hand over anything: a request body,
41
+ * a stored value, or the result of a failed read. Every text front door checks this predicate
42
+ * and answers with a tagged diagnostic at `$` rather than letting a reader's `TypeError` escape.
43
+ */
44
+ export function nonTextSourceDetail(source, subject = 'the document') {
45
+ if (typeof source === 'string')
46
+ return undefined;
47
+ return `${subject} must be supplied as text; received ${describeSource(source)}`;
48
+ }
49
+ /**
50
+ * The refusal a non-text source earns before either authoring reader sees it.
51
+ */
52
+ export function nonTextIngestRefusal(source, code) {
53
+ return {
54
+ ok: false,
55
+ diagnostics: [
56
+ {
57
+ code,
58
+ path: '$',
59
+ detail: `the document must be supplied as text; received ${describeSource(source)}`,
60
+ },
61
+ ],
62
+ };
63
+ }
64
+ /**
65
+ * Ingests one JSON document's text as the plain value the restriction profile admits.
66
+ *
67
+ * A non-text source is refused as ingestion data here, so `compile`'s guard is not the only
68
+ * place the contract is kept: a caller that reads a file and forwards the result crosses the
69
+ * same boundary.
70
+ */
71
+ export function ingestJsonDocument(source) {
72
+ if (typeof source !== 'string')
73
+ return nonTextIngestRefusal(source, 'JSON_INGEST_ERROR');
74
+ try {
75
+ return { ok: true, value: parseRestrictedJson(source) };
76
+ }
77
+ catch (cause) {
78
+ if (!(cause instanceof JsonIngestError))
79
+ throw cause;
80
+ return { ok: false, diagnostics: [jsonIngestDiagnostic(cause)] };
81
+ }
82
+ }
83
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/ingest/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAqB9E,mDAAmD;AACnD,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7E,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAA4C;IACzE,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,4FAA4F;QAC9F,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAsB;IAClD,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;QAC1C,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACzD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE,UAAU;KACzB,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,SAAS,cAAc,CAAC,MAAe;IACrC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAC7C,OAAO,mBAAmB,OAAO,MAAM,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe,EAAE,OAAO,GAAG,cAAc;IAC3E,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACjD,OAAO,GAAG,OAAO,uCAAuC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAe,EACf,IAA+C;IAE/C,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,IAAI;gBACJ,IAAI,EAAE,GAAG;gBACT,MAAM,EAAE,mDAAmD,cAAc,CAAC,MAAM,CAAC,EAAE;aACpF;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACzF,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,eAAe,CAAC;YAAE,MAAM,KAAK,CAAC;QACrD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;IACnE,CAAC;AACH,CAAC","sourcesContent":["import { JsonIngestError, parseRestrictedJson } from '@azx-pbc/axiom-runtime';\nimport type { JsonIngestReason } from '@azx-pbc/axiom-runtime';\nimport type { SchemaDiagnostic } from '../schema/diagnostic.js';\nimport type { YamlRefusalReason } from './yaml.js';\n\n/**\n * The two authoring spellings, and the boundary that reads JSON.\n *\n * A document is written as JSON or as YAML; the artifact is JSON either way. The format is\n * chosen from the file extension and nothing else, so a `.json` file that happens to parse as\n * YAML is still read as JSON and a `.yaml` file is never sniffed. Central input (`-`) has no\n * extension, so it keeps the JSON meaning the command line has always given it.\n *\n * YAML lives in `yaml-document.ts` rather than behind the `format` argument here. `yaml`\n * declares no `sideEffects` flag, so a bundler cannot drop it once this module imports it —\n * even for a caller that only compiles JSON. Keeping the two readers in separate modules is\n * what makes an import of `compile` cost the JSON reader alone; `test/packaging/size-budget`\n * holds the result.\n */\nexport type DocumentFormat = 'json' | 'yaml';\n\n/** The format a path names, by extension alone. */\nexport function documentFormatOf(path: string): DocumentFormat {\n const lower = path.toLowerCase();\n return lower.endsWith('.yaml') || lower.endsWith('.yml') ? 'yaml' : 'json';\n}\n\n/** One document read into the plain value the restriction profile admits. */\nexport type IngestedDocument =\n | { readonly ok: true; readonly value: unknown }\n | { readonly ok: false; readonly diagnostics: readonly SchemaDiagnostic[] };\n\n/**\n * The repair an ingestion refusal implies, where one form has a second spelling an author\n * reaches for. A number outside the canonical profile is almost always a decimal or a money\n * amount written the way a calculator would show it, so the refusal says how the wire contract\n * spells it instead. The JSON and YAML front doors share this sentence, so one value refused\n * by both reads the same.\n */\nexport function ingestGuidance(reason: JsonIngestReason | YamlRefusalReason): string {\n return reason === 'integer'\n ? '; write decimals and money minor units as canonical decimal strings, never as JSON numbers'\n : '';\n}\n\nfunction jsonIngestDiagnostic(cause: JsonIngestError): SchemaDiagnostic {\n return {\n code: 'JSON_INGEST_ERROR',\n path: cause.path === '' ? '$' : cause.path,\n detail: `${cause.message}${ingestGuidance(cause.reason)}`,\n offset: cause.offset,\n offsetSource: 'document',\n };\n}\n\n/** What a caller supplied instead of document text, named without reading into it. */\nfunction describeSource(source: unknown): string {\n if (source === null) return 'null';\n if (Array.isArray(source)) return 'an array';\n return `a value of type ${typeof source}`;\n}\n\n/**\n * The refusal sentence a non-text source earns before any text reader sees it, or `undefined`\n * when the caller supplied a string.\n *\n * The declared type is text, but a JavaScript caller can hand over anything: a request body,\n * a stored value, or the result of a failed read. Every text front door checks this predicate\n * and answers with a tagged diagnostic at `$` rather than letting a reader's `TypeError` escape.\n */\nexport function nonTextSourceDetail(source: unknown, subject = 'the document'): string | undefined {\n if (typeof source === 'string') return undefined;\n return `${subject} must be supplied as text; received ${describeSource(source)}`;\n}\n\n/**\n * The refusal a non-text source earns before either authoring reader sees it.\n */\nexport function nonTextIngestRefusal(\n source: unknown,\n code: 'JSON_INGEST_ERROR' | 'YAML_INGEST_ERROR',\n): IngestedDocument {\n return {\n ok: false,\n diagnostics: [\n {\n code,\n path: '$',\n detail: `the document must be supplied as text; received ${describeSource(source)}`,\n },\n ],\n };\n}\n\n/**\n * Ingests one JSON document's text as the plain value the restriction profile admits.\n *\n * A non-text source is refused as ingestion data here, so `compile`'s guard is not the only\n * place the contract is kept: a caller that reads a file and forwards the result crosses the\n * same boundary.\n */\nexport function ingestJsonDocument(source: string): IngestedDocument {\n if (typeof source !== 'string') return nonTextIngestRefusal(source, 'JSON_INGEST_ERROR');\n try {\n return { ok: true, value: parseRestrictedJson(source) };\n } catch (cause) {\n if (!(cause instanceof JsonIngestError)) throw cause;\n return { ok: false, diagnostics: [jsonIngestDiagnostic(cause)] };\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { DocumentFormat, IngestedDocument } from './document.js';
2
+ /**
3
+ * Ingests one document's text as the plain value the rest of the compiler validates, reading it
4
+ * through the strict YAML profile in `yaml.ts`: anchors and aliases resolve into a plain value,
5
+ * the constructs JSON cannot express are refused, and the value then crosses the same
6
+ * restriction walk the JSON reader applies. Nothing downstream knows which spelling was used.
7
+ */
8
+ export declare function ingestYamlDocument(source: string): IngestedDocument;
9
+ /**
10
+ * Ingests one document by the format its caller named. The format comes from a path extension,
11
+ * never from sniffing the text, so a `.json` file is always read by the JSON reader and a
12
+ * `.yaml`/`.yml` file by the YAML one.
13
+ */
14
+ export declare function ingestDocument(source: string, format: DocumentFormat): IngestedDocument;
15
+ //# sourceMappingURL=yaml-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-document.d.ts","sourceRoot":"","sources":["../../src/ingest/yaml-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAuBtE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAKnE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAEvF"}
@@ -0,0 +1,42 @@
1
+ import { ingestGuidance, ingestJsonDocument, nonTextIngestRefusal } from './document.js';
2
+ import { parseRestrictedYaml } from './yaml.js';
3
+ /**
4
+ * The YAML front door, and the dispatch that picks a front door by the caller's stated format.
5
+ *
6
+ * This module is deliberately separate from `document.ts`: it is the only compiler module that
7
+ * reaches the `yaml` parser, so a browser bundle whose entry imports `compile` never carries the
8
+ * parser (`test/packaging/size-budget` holds the measured cost). The module is reachable from
9
+ * `compileYaml`, `compileDocument` and the CLI, which all need it.
10
+ */
11
+ function yamlIngestDiagnostic(refusal) {
12
+ return {
13
+ code: 'YAML_INGEST_ERROR',
14
+ path: refusal.path,
15
+ detail: `${refusal.detail}${ingestGuidance(refusal.reason)}`,
16
+ ...(refusal.offset === undefined ? {} : { offset: refusal.offset }),
17
+ offsetSource: 'document',
18
+ };
19
+ }
20
+ /**
21
+ * Ingests one document's text as the plain value the rest of the compiler validates, reading it
22
+ * through the strict YAML profile in `yaml.ts`: anchors and aliases resolve into a plain value,
23
+ * the constructs JSON cannot express are refused, and the value then crosses the same
24
+ * restriction walk the JSON reader applies. Nothing downstream knows which spelling was used.
25
+ */
26
+ export function ingestYamlDocument(source) {
27
+ if (typeof source !== 'string')
28
+ return nonTextIngestRefusal(source, 'YAML_INGEST_ERROR');
29
+ const ingested = parseRestrictedYaml(source);
30
+ if (ingested.ok)
31
+ return { ok: true, value: ingested.value };
32
+ return { ok: false, diagnostics: [yamlIngestDiagnostic(ingested.refusal)] };
33
+ }
34
+ /**
35
+ * Ingests one document by the format its caller named. The format comes from a path extension,
36
+ * never from sniffing the text, so a `.json` file is always read by the JSON reader and a
37
+ * `.yaml`/`.yml` file by the YAML one.
38
+ */
39
+ export function ingestDocument(source, format) {
40
+ return format === 'yaml' ? ingestYamlDocument(source) : ingestJsonDocument(source);
41
+ }
42
+ //# sourceMappingURL=yaml-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-document.js","sourceRoot":"","sources":["../../src/ingest/yaml-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGhD;;;;;;;GAOG;AAEH,SAAS,oBAAoB,CAAC,OAAoB;IAChD,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC5D,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;QACnE,YAAY,EAAE,UAAU;KACzB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACzF,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC5D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,MAAsB;IACnE,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import type { SchemaDiagnostic } from '../schema/diagnostic.js';\nimport { ingestGuidance, ingestJsonDocument, nonTextIngestRefusal } from './document.js';\nimport type { DocumentFormat, IngestedDocument } from './document.js';\nimport { parseRestrictedYaml } from './yaml.js';\nimport type { YamlRefusal } from './yaml.js';\n\n/**\n * The YAML front door, and the dispatch that picks a front door by the caller's stated format.\n *\n * This module is deliberately separate from `document.ts`: it is the only compiler module that\n * reaches the `yaml` parser, so a browser bundle whose entry imports `compile` never carries the\n * parser (`test/packaging/size-budget` holds the measured cost). The module is reachable from\n * `compileYaml`, `compileDocument` and the CLI, which all need it.\n */\n\nfunction yamlIngestDiagnostic(refusal: YamlRefusal): SchemaDiagnostic {\n return {\n code: 'YAML_INGEST_ERROR',\n path: refusal.path,\n detail: `${refusal.detail}${ingestGuidance(refusal.reason)}`,\n ...(refusal.offset === undefined ? {} : { offset: refusal.offset }),\n offsetSource: 'document',\n };\n}\n\n/**\n * Ingests one document's text as the plain value the rest of the compiler validates, reading it\n * through the strict YAML profile in `yaml.ts`: anchors and aliases resolve into a plain value,\n * the constructs JSON cannot express are refused, and the value then crosses the same\n * restriction walk the JSON reader applies. Nothing downstream knows which spelling was used.\n */\nexport function ingestYamlDocument(source: string): IngestedDocument {\n if (typeof source !== 'string') return nonTextIngestRefusal(source, 'YAML_INGEST_ERROR');\n const ingested = parseRestrictedYaml(source);\n if (ingested.ok) return { ok: true, value: ingested.value };\n return { ok: false, diagnostics: [yamlIngestDiagnostic(ingested.refusal)] };\n}\n\n/**\n * Ingests one document by the format its caller named. The format comes from a path extension,\n * never from sniffing the text, so a `.json` file is always read by the JSON reader and a\n * `.yaml`/`.yml` file by the YAML one.\n */\nexport function ingestDocument(source: string, format: DocumentFormat): IngestedDocument {\n return format === 'yaml' ? ingestYamlDocument(source) : ingestJsonDocument(source);\n}\n"]}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The YAML authoring front door.
3
+ *
4
+ * YAML is a way to write the document, never the document's form: this module turns one YAML
5
+ * stream into the plain JavaScript value the restricted profile admits, and nothing downstream
6
+ * can tell which spelling the author used. It parses with the JSON-safe core schema and the
7
+ * options below, so no feature is enabled that would then have to be undone:
8
+ *
9
+ * - `schema: 'core'` resolves only null, booleans, integers, floats and strings. A timestamp is
10
+ * not a core type, so a plain date stays the text it was written as; an explicit
11
+ * `!!timestamp` tag is refused by name rather than silently becoming a `Date`.
12
+ * - `merge: true` makes the parser mark a `<<` key as the merge key, so the walk can refuse it
13
+ * by name. Merge keys are two spellings of "this member came from there", which is the drift
14
+ * the document contract refuses.
15
+ * - `uniqueKeys: true` makes the parser report a duplicate mapping key; the walk adds the path
16
+ * and reuses the restricted reader's `duplicate_member` message.
17
+ * - `maxAliasCount` bounds alias expansion, so a "billion laughs" document is a refusal rather
18
+ * than a process that runs out of memory.
19
+ *
20
+ * Anchors and aliases are syntax sugar: they are resolved into the plain value before the
21
+ * restriction walk, and an alias that constructs a cycle is refused with the path where the
22
+ * cycle closes rather than followed forever.
23
+ */
24
+ /** The construct a YAML refusal names. The diagnostic code stays `YAML_INGEST_ERROR`. */
25
+ export type YamlRefusalReason = 'empty' | 'multiple_documents' | 'syntax' | 'custom_tag' | 'merge_key' | 'duplicate_member' | 'non_string_key' | 'yaml_version' | 'alias_limit' | 'negative_zero' | 'integer' | 'unsafe_integer' | 'unpaired_surrogate' | 'nesting' | 'cycle' | 'non_json_value';
26
+ /** One reason a YAML stream cannot become a document, with the construct and where it is. */
27
+ export interface YamlRefusal {
28
+ /** The document path in the compiler's `$.a.b[0]` notation. */
29
+ readonly path: string;
30
+ readonly reason: YamlRefusalReason;
31
+ readonly detail: string;
32
+ /** The code-unit offset in the YAML source, when the AST named one. */
33
+ readonly offset?: number;
34
+ }
35
+ /** What one YAML stream produced: the plain value, or why it is not one. */
36
+ export type YamlIngest = {
37
+ readonly ok: true;
38
+ readonly value: unknown;
39
+ } | {
40
+ readonly ok: false;
41
+ readonly refusal: YamlRefusal;
42
+ };
43
+ /**
44
+ * Ingests one YAML stream as the plain value the restricted profile admits.
45
+ *
46
+ * A YAML refusal is the ingestion boundary's own answer: it names the construct, the path and —
47
+ * where the syntax tree carries one — the source offset, so the command line can print the
48
+ * line, the column and the line itself.
49
+ */
50
+ export declare function parseRestrictedYaml(source: string): YamlIngest;
51
+ //# sourceMappingURL=yaml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/ingest/yaml.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,yFAAyF;AACzF,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,oBAAoB,GACpB,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,aAAa,GACb,eAAe,GACf,SAAS,GACT,gBAAgB,GAChB,oBAAoB,GACpB,SAAS,GACT,OAAO,GACP,gBAAgB,CAAC;AAErB,6FAA6F;AAC7F,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAuU1D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CA8E9D"}
@@ -0,0 +1,340 @@
1
+ import { restrictedNumberTextRefusal, restrictedValueRefusal } from '@azx-pbc/axiom-runtime';
2
+ import { isAlias, isMap, isNode, isPair, isScalar, isSeq, parseAllDocuments } from 'yaml';
3
+ import { documentMemberPath } from '../document-path.js';
4
+ /** One anchor may be expanded this many times before the document is refused as hostile. */
5
+ const MAX_ALIAS_COUNT = 100;
6
+ /**
7
+ * The parser options. Each one is a decision to keep the value JSON-safe, not a convenience:
8
+ * a document that depends on a YAML feature JSON cannot express would make the artifact depend
9
+ * on the authoring format.
10
+ */
11
+ const PARSE_OPTIONS = {
12
+ schema: 'core',
13
+ merge: true,
14
+ uniqueKeys: true,
15
+ version: '1.2',
16
+ maxAliasCount: MAX_ALIAS_COUNT,
17
+ logLevel: 'silent',
18
+ prettyErrors: false,
19
+ };
20
+ const DUPLICATE_KEY_CODE = 'DUPLICATE_KEY';
21
+ const TAG_PROBLEM_CODE = 'TAG_RESOLVE_FAILED';
22
+ /**
23
+ * The parser's own code for a stack it could not complete.
24
+ *
25
+ * The `yaml` parser recurses while it builds its syntax tree, so a document deeper than the call
26
+ * stack is reported as `RESOURCE_EXHAUSTION` before this module sees a node. That failure is the
27
+ * profile's `nesting` refusal in everything but name; mapping it here is what stops a hostile
28
+ * document surfacing as a generic syntax error whose detail is a host stack message.
29
+ */
30
+ const RESOURCE_EXHAUSTION_CODE = 'RESOURCE_EXHAUSTION';
31
+ /**
32
+ * The deepest container nesting the restricted profile admits, mirrored from
33
+ * `MAX_NESTING_DEPTH` in the runtime's canonical profile.
34
+ *
35
+ * The YAML front door cannot import the runtime's internal constant, so the number is stated
36
+ * here and `test/robustness/depth.test.ts` pins the two together: 128 levels accept, 129 refuse,
37
+ * on both authoring spellings. The value is used only in a refusal sentence; the enforcement
38
+ * remains the profile's own value walk.
39
+ */
40
+ const NESTING_LIMIT = 128;
41
+ /** Whether a thrown value is the host running out of stack rather than a document defect. */
42
+ function isStackExhaustion(cause) {
43
+ if (cause instanceof RangeError)
44
+ return true;
45
+ return (cause instanceof Error &&
46
+ (/Maximum call stack size exceeded/iu.test(cause.message) ||
47
+ /Stack overflow/iu.test(cause.message)));
48
+ }
49
+ /** The refusal a recursion cutoff earns, stated in the profile's own vocabulary. */
50
+ function nestingRefusal(offset) {
51
+ return refusal('$', 'nesting', `nesting deeper than ${String(NESTING_LIMIT)} levels; flatten the mapping so it nests less deeply`, offset);
52
+ }
53
+ function refusal(path, reason, detail, offset) {
54
+ return {
55
+ path,
56
+ reason,
57
+ detail,
58
+ ...(offset === undefined ? {} : { offset }),
59
+ };
60
+ }
61
+ /** How a node's source spells its tag, in the `!!name` form an author reads. */
62
+ function tagSpelling(tag) {
63
+ const prefix = 'tag:yaml.org,2002:';
64
+ return tag.startsWith(prefix) ? `!!${tag.slice(prefix.length)}` : tag;
65
+ }
66
+ /** The child path of one mapping member, in the injective notation every diagnostic uses. */
67
+ function memberPath(path, key) {
68
+ return documentMemberPath(path, key);
69
+ }
70
+ /** The name a mapping key contributes to a path, for a key that is a plain scalar. */
71
+ function scalarKeyText(node) {
72
+ return String(node.value);
73
+ }
74
+ /**
75
+ * The refusal an explicit tag earns, with the timestamp named as the case that would otherwise
76
+ * become a non-JSON value. A tag is a format-specific feature; the profile admits plain scalars,
77
+ * so even a tag naming a JSON type is refused rather than trusted to stay harmless.
78
+ *
79
+ * Every node kind is checked, not just a scalar: the parser resolves `!!map` and `!!seq` on a
80
+ * collection without reporting an unresolved tag, so relying on that warning would admit a
81
+ * `!!seq` list as if it were spelling rather than a construct JSON cannot express.
82
+ */
83
+ function tagRefusal(node, path) {
84
+ if (node.tag === undefined)
85
+ return undefined;
86
+ const spelling = tagSpelling(node.tag);
87
+ const offset = node.range?.[0];
88
+ if (isScalar(node) && node.tag === 'tag:yaml.org,2002:timestamp') {
89
+ return refusal(path, 'custom_tag', `\`${spelling}\` would read this scalar as a Date, which JSON cannot state; write the date as a quoted string such as "2026-03-01"`, offset);
90
+ }
91
+ return refusal(path, 'custom_tag', `a document is plain scalars, and JSON cannot express the explicit tag \`${spelling}\`; remove it`, offset);
92
+ }
93
+ /**
94
+ * The refusal a plain numeric scalar earns when its spelling is not a canonical JSON integer.
95
+ * The text reader's rule is called here, so `0x10`, `1e3` and `1.0` are refused exactly as the
96
+ * same spellings are in JSON.
97
+ */
98
+ function numberRefusal(node, path) {
99
+ if (node.type !== 'PLAIN' || typeof node.value !== 'number')
100
+ return undefined;
101
+ const source = node.source;
102
+ if (source === undefined)
103
+ return undefined;
104
+ const refusalOfText = restrictedNumberTextRefusal(source);
105
+ if (refusalOfText === undefined)
106
+ return undefined;
107
+ return refusal(path, refusalOfText.reason, refusalOfText.detail, node.range?.[0]);
108
+ }
109
+ function scalarRefusal(node, path) {
110
+ return tagRefusal(node, path) ?? numberRefusal(node, path);
111
+ }
112
+ /** Whether `pos` falls inside a node's source range. */
113
+ function rangeContains(range, pos) {
114
+ return range !== undefined && range !== null && range[0] <= pos && pos < range[1];
115
+ }
116
+ /** The mapping or list that holds the node at `pos`, with the path the walk reached it by. */
117
+ function locatePair(node, pos, path) {
118
+ if (isMap(node)) {
119
+ for (const pair of node.items) {
120
+ if (!isPair(pair))
121
+ continue;
122
+ const key = pair.key;
123
+ if (isScalar(key) && rangeContains(key.range, pos)) {
124
+ return { path, key: scalarKeyText(key), offset: key.range?.[0] ?? pos };
125
+ }
126
+ if (isScalar(key)) {
127
+ const found = locatePair(pair.value, pos, memberPath(path, scalarKeyText(key)));
128
+ if (found !== undefined)
129
+ return found;
130
+ continue;
131
+ }
132
+ const found = locatePair(pair.value, pos, path);
133
+ if (found !== undefined)
134
+ return found;
135
+ }
136
+ return undefined;
137
+ }
138
+ if (isSeq(node)) {
139
+ for (const [index, item] of node.items.entries()) {
140
+ const found = locatePair(item, pos, `${path}[${String(index)}]`);
141
+ if (found !== undefined)
142
+ return found;
143
+ }
144
+ }
145
+ return undefined;
146
+ }
147
+ /** The first reason the parser itself reported, with a duplicate key located by path. */
148
+ function parserRefusal(document) {
149
+ // A stack the parser could not complete is the profile's nesting refusal: the document is
150
+ // deeper than any bound the profile could check after the parse, and the host message is a
151
+ // fact about this engine rather than a diagnosis an author can act on.
152
+ const exhausted = document.errors.find((error) => error.code === RESOURCE_EXHAUSTION_CODE);
153
+ if (exhausted !== undefined)
154
+ return nestingRefusal(exhausted.pos[0]);
155
+ const duplicate = document.errors.find((error) => error.code === DUPLICATE_KEY_CODE);
156
+ if (duplicate !== undefined) {
157
+ const site = locatePair(document.contents, duplicate.pos[0], '$');
158
+ return refusal(site?.path ?? '$', 'duplicate_member', `duplicate object member ${JSON.stringify(site?.key ?? '')}`, site?.offset ?? duplicate.pos[0]);
159
+ }
160
+ const first = document.errors[0];
161
+ if (first === undefined)
162
+ return undefined;
163
+ const detail = first.message.split('\n')[0] ?? first.message;
164
+ return refusal('$', 'syntax', detail.replace(/ at line \d+, column \d+:$/u, ''), first.pos[0]);
165
+ }
166
+ /** The warning an unresolved tag produced, if the parser reported one before the walk did. */
167
+ function warningRefusal(document) {
168
+ const warning = document.warnings.find((entry) => entry.code === TAG_PROBLEM_CODE);
169
+ if (warning === undefined)
170
+ return undefined;
171
+ const detail = warning.message.split('\n')[0] ?? warning.message;
172
+ return refusal('$', 'custom_tag', detail.replace(/ at line \d+, column \d+:$/u, ''), warning.pos[0]);
173
+ }
174
+ /**
175
+ * The first strict-profile refusal in one node, with the path the walk reached it by.
176
+ *
177
+ * The walk reads the syntax tree rather than the resolved value so it can name what the value
178
+ * can no longer say: a tag, a merge key, a non-string key, or the source spelling of a number.
179
+ */
180
+ function walkNode(node, path) {
181
+ if (isAlias(node))
182
+ return undefined;
183
+ if (!isNode(node))
184
+ return undefined;
185
+ // A tag is refused at the node the author tagged, before any member is read: a mapping or a
186
+ // sequence tagged `!!map`/`!!seq` would otherwise reach the value walk indistinguishable from
187
+ // an untagged one.
188
+ const tagged = tagRefusal(node, path);
189
+ if (tagged !== undefined)
190
+ return tagged;
191
+ if (isScalar(node))
192
+ return numberRefusal(node, path);
193
+ if (isSeq(node)) {
194
+ for (const [index, item] of node.items.entries()) {
195
+ const found = walkNode(item, `${path}[${String(index)}]`);
196
+ if (found !== undefined)
197
+ return found;
198
+ }
199
+ return undefined;
200
+ }
201
+ if (isMap(node))
202
+ return walkMap(node, path);
203
+ return undefined;
204
+ }
205
+ function walkMap(node, path) {
206
+ for (const pair of node.items) {
207
+ if (!isPair(pair))
208
+ continue;
209
+ const key = pair.key;
210
+ if (!isScalar(key)) {
211
+ return refusal(path, 'non_string_key', 'a mapping key must be a string; JSON object keys are strings, so a collection or alias key is refused');
212
+ }
213
+ if (key.type === 'PLAIN' && key.source === '<<') {
214
+ return refusal(path, 'merge_key', 'a merge key (`<<`) is refused; write the merged members explicitly in this mapping', key.range?.[0]);
215
+ }
216
+ if (typeof key.value !== 'string') {
217
+ return refusal(path, 'non_string_key', `a mapping key must be a string, not ${typeof key.value}; JSON object keys are strings`, key.range?.[0]);
218
+ }
219
+ const keyRefusal = scalarRefusal(key, memberPath(path, key.value));
220
+ if (keyRefusal !== undefined)
221
+ return keyRefusal;
222
+ const found = walkNode(pair.value, memberPath(path, key.value));
223
+ if (found !== undefined)
224
+ return found;
225
+ }
226
+ return undefined;
227
+ }
228
+ /**
229
+ * Resolves the document into a plain value, refusing an alias expansion the parser considers
230
+ * hostile. A cyclic alias resolves successfully here and is refused by the value walk, which
231
+ * can name the path at which the value contains itself.
232
+ */
233
+ function resolveValue(document) {
234
+ try {
235
+ return { ok: true, value: document.toJS({ maxAliasCount: MAX_ALIAS_COUNT }) };
236
+ }
237
+ catch (cause) {
238
+ // A recursion cutoff here is the same profile nesting refusal as one the parser reported:
239
+ // the value tree is too deep for this engine to resolve, not a document the profile could
240
+ // describe. Checking it before the alias rule keeps a stack message out of the diagnosis.
241
+ if (isStackExhaustion(cause))
242
+ return { ok: false, refusal: nestingRefusal() };
243
+ const detail = cause instanceof Error ? cause.message : 'the document could not be resolved';
244
+ // The parser refuses an expansion bomb and an alias that names no anchor with the same
245
+ // error class; the message is the only thing that tells them apart, and the repair differs.
246
+ if (/alias count/iu.test(detail)) {
247
+ return {
248
+ ok: false,
249
+ refusal: refusal('$', 'alias_limit', `the document expands an alias more than ${String(MAX_ALIAS_COUNT)} times: ${detail}`),
250
+ };
251
+ }
252
+ return {
253
+ ok: false,
254
+ refusal: refusal('$', 'syntax', `the document could not be resolved: ${detail}`),
255
+ };
256
+ }
257
+ }
258
+ /**
259
+ * Ingests one YAML stream as the plain value the restricted profile admits.
260
+ *
261
+ * A YAML refusal is the ingestion boundary's own answer: it names the construct, the path and —
262
+ * where the syntax tree carries one — the source offset, so the command line can print the
263
+ * line, the column and the line itself.
264
+ */
265
+ export function parseRestrictedYaml(source) {
266
+ let documents;
267
+ try {
268
+ documents = parseAllDocuments(source, PARSE_OPTIONS);
269
+ }
270
+ catch (cause) {
271
+ // A parser that throws its own stack exhaustion has not produced a document to diagnose.
272
+ // The depth is the profile's refusal, so it is answered as one rather than escaping as a
273
+ // host `RangeError`.
274
+ if (isStackExhaustion(cause))
275
+ return { ok: false, refusal: nestingRefusal() };
276
+ throw cause;
277
+ }
278
+ if (documents.length === 0) {
279
+ return { ok: false, refusal: refusal('$', 'empty', 'the document is empty') };
280
+ }
281
+ if (documents.length > 1) {
282
+ const second = documents[1];
283
+ return {
284
+ ok: false,
285
+ refusal: refusal('$', 'multiple_documents', `multiple YAML documents in one stream (${String(documents.length)}); a schema document is one document`, second?.range?.[0]),
286
+ };
287
+ }
288
+ const document = documents[0];
289
+ if (document === undefined) {
290
+ return { ok: false, refusal: refusal('$', 'empty', 'the document is empty') };
291
+ }
292
+ // `---` on its own is an empty document, not a null value: the author wrote no content, and
293
+ // saying so is more useful than a metaschema refusal that says the document is not an object.
294
+ if (isScalar(document.contents) &&
295
+ document.contents.value === null &&
296
+ document.contents.source === '') {
297
+ return { ok: false, refusal: refusal('$', 'empty', 'the document is empty') };
298
+ }
299
+ const parser = parserRefusal(document);
300
+ if (parser !== undefined)
301
+ return { ok: false, refusal: parser };
302
+ const version = document.directives?.yaml;
303
+ if (version?.explicit === true && version.version !== '1.2') {
304
+ return {
305
+ ok: false,
306
+ refusal: refusal('$', 'yaml_version', `a \`%YAML ${version.version}\` directive is refused; the profile is YAML 1.2 and a document may not declare another version`, document.range?.[0]),
307
+ };
308
+ }
309
+ // The syntax tree names a tag where the value can no longer say it, so it is walked before the
310
+ // parser's unresolved-tag warning, which states the same fact with less information. The walk
311
+ // itself recurses over the tree, so a tree the parser built but this walk cannot descend is
312
+ // the profile's nesting refusal rather than a host stack error.
313
+ let syntax;
314
+ try {
315
+ syntax = walkNode(document.contents, '$');
316
+ }
317
+ catch (cause) {
318
+ if (isStackExhaustion(cause))
319
+ return { ok: false, refusal: nestingRefusal() };
320
+ throw cause;
321
+ }
322
+ if (syntax !== undefined)
323
+ return { ok: false, refusal: syntax };
324
+ const warning = warningRefusal(document);
325
+ if (warning !== undefined)
326
+ return { ok: false, refusal: warning };
327
+ const resolved = resolveValue(document);
328
+ if (!resolved.ok)
329
+ return resolved;
330
+ const value = resolved.value;
331
+ const profile = restrictedValueRefusal(value);
332
+ if (profile !== undefined) {
333
+ return {
334
+ ok: false,
335
+ refusal: refusal(profile.path, profile.reason, profile.detail),
336
+ };
337
+ }
338
+ return { ok: true, value };
339
+ }
340
+ //# sourceMappingURL=yaml.js.map