@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,60 @@
1
+ /**
2
+ * Every dataset diagnostic code, as the tuple a gate names each by. The annotation refuses a name
3
+ * the union does not state, and the repair table below is typed
4
+ * `Record<DatasetDiagnosticCode, DatasetDiagnosticRepair>`, so the two cannot drift.
5
+ */
6
+ export const DATASET_DIAGNOSTIC_CODES = [
7
+ 'JSON_INGEST_ERROR',
8
+ 'DATASET_INVALID',
9
+ 'INVALID_HEADER',
10
+ 'INVALID_CELL',
11
+ 'INVALID_ROW',
12
+ 'CSV_BOUNDS',
13
+ 'DUPLICATE_IDENTIFIER',
14
+ 'DUPLICATE_KEY',
15
+ 'OVERLAPPING_WINDOW',
16
+ ];
17
+ /** Every dataset diagnostic code and the repair a table author can act on. */
18
+ export const DATASET_DIAGNOSTIC_REPAIRS = {
19
+ JSON_INGEST_ERROR: {
20
+ anchor: 'correct the dataset json',
21
+ repair: 'Correct the dataset JSON text at the reported offset: state each member once, close and escape every string, and write no decimal as a JSON number.',
22
+ },
23
+ DATASET_INVALID: {
24
+ anchor: 'change the table',
25
+ repair: 'Change the table member the detail names so it matches the dataset contract in `spec/semantics/datasets-v1.md`.',
26
+ },
27
+ INVALID_HEADER: {
28
+ anchor: 'spell the header',
29
+ repair: "Spell the header in the order the table's declared `columnId` list states, with no missing or extra column.",
30
+ },
31
+ INVALID_CELL: {
32
+ anchor: 'change the cell',
33
+ repair: "Change the cell to the value its column's primitive admits, or leave it empty where the column allows absence.",
34
+ },
35
+ INVALID_ROW: {
36
+ anchor: 'change the row',
37
+ repair: "Change the row so its `rowId`, key cells and output cells match the table's declared columns.",
38
+ },
39
+ CSV_BOUNDS: {
40
+ anchor: 'split the csv',
41
+ repair: 'Split the CSV so the file, each row, each column and each cell stay inside the declared limits.',
42
+ },
43
+ DUPLICATE_IDENTIFIER: {
44
+ anchor: 'choose a',
45
+ repair: 'Choose a `columnId` or `rowId` no other declaration in the table uses.',
46
+ },
47
+ DUPLICATE_KEY: {
48
+ anchor: 'choose a key',
49
+ repair: 'Choose a key no other row of the table states.',
50
+ },
51
+ OVERLAPPING_WINDOW: {
52
+ anchor: 'change `effectivefrom`',
53
+ repair: "Change `effectiveFrom` or `effectiveTo` so each version's window is disjoint from the others.",
54
+ },
55
+ };
56
+ /** The repair row for one dataset code, total over the closed union. */
57
+ export function datasetDiagnosticRepair(code) {
58
+ return DATASET_DIAGNOSTIC_REPAIRS[code];
59
+ }
60
+ //# sourceMappingURL=repair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repair.js","sourceRoot":"","sources":["../../src/datasets/repair.ts"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAqC;IACxE,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,YAAY;IACZ,sBAAsB;IACtB,eAAe;IACf,oBAAoB;CACrB,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAEnC;IACF,iBAAiB,EAAE;QACjB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EACJ,qJAAqJ;KACxJ;IACD,eAAe,EAAE;QACf,MAAM,EAAE,kBAAkB;QAC1B,MAAM,EACJ,iHAAiH;KACpH;IACD,cAAc,EAAE;QACd,MAAM,EAAE,kBAAkB;QAC1B,MAAM,EACJ,6GAA6G;KAChH;IACD,YAAY,EAAE;QACZ,MAAM,EAAE,iBAAiB;QACzB,MAAM,EACJ,gHAAgH;KACnH;IACD,WAAW,EAAE;QACX,MAAM,EAAE,gBAAgB;QACxB,MAAM,EACJ,+FAA+F;KAClG;IACD,UAAU,EAAE;QACV,MAAM,EAAE,eAAe;QACvB,MAAM,EACJ,iGAAiG;KACpG;IACD,oBAAoB,EAAE;QACpB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,wEAAwE;KACjF;IACD,aAAa,EAAE;QACb,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,gDAAgD;KACzD;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,wBAAwB;QAChC,MAAM,EACJ,+FAA+F;KAClG;CACF,CAAC;AAEF,wEAAwE;AACxE,MAAM,UAAU,uBAAuB,CAAC,IAA2B;IACjE,OAAO,0BAA0B,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { DatasetDiagnosticCode } from './diagnostics.js';\n\n/**\n * The repair a dataset diagnostic names, keyed by the closed code union.\n *\n * The dataset compiler is the second front door `axiom-cli` prints, and its detail is usually\n * the row or cell that disagreed with the declaration. A row number is not a repair, so each\n * code carries the action that removes it; the gate in `__tests__/repair-gate.test.ts` holds\n * the table to the union and to an imperative phrase.\n */\nexport interface DatasetDiagnosticRepair {\n /** The action that removes the diagnostic, in a table author's vocabulary. */\n readonly repair: string;\n /** The phrase a detail carries when it already states this repair. */\n readonly anchor: string;\n}\n\n/**\n * Every dataset diagnostic code, as the tuple a gate names each by. The annotation refuses a name\n * the union does not state, and the repair table below is typed\n * `Record<DatasetDiagnosticCode, DatasetDiagnosticRepair>`, so the two cannot drift.\n */\nexport const DATASET_DIAGNOSTIC_CODES: readonly DatasetDiagnosticCode[] = [\n 'JSON_INGEST_ERROR',\n 'DATASET_INVALID',\n 'INVALID_HEADER',\n 'INVALID_CELL',\n 'INVALID_ROW',\n 'CSV_BOUNDS',\n 'DUPLICATE_IDENTIFIER',\n 'DUPLICATE_KEY',\n 'OVERLAPPING_WINDOW',\n];\n\n/** Every dataset diagnostic code and the repair a table author can act on. */\nexport const DATASET_DIAGNOSTIC_REPAIRS: Readonly<\n Record<DatasetDiagnosticCode, DatasetDiagnosticRepair>\n> = {\n JSON_INGEST_ERROR: {\n anchor: 'correct the dataset json',\n repair:\n 'Correct the dataset JSON text at the reported offset: state each member once, close and escape every string, and write no decimal as a JSON number.',\n },\n DATASET_INVALID: {\n anchor: 'change the table',\n repair:\n 'Change the table member the detail names so it matches the dataset contract in `spec/semantics/datasets-v1.md`.',\n },\n INVALID_HEADER: {\n anchor: 'spell the header',\n repair:\n \"Spell the header in the order the table's declared `columnId` list states, with no missing or extra column.\",\n },\n INVALID_CELL: {\n anchor: 'change the cell',\n repair:\n \"Change the cell to the value its column's primitive admits, or leave it empty where the column allows absence.\",\n },\n INVALID_ROW: {\n anchor: 'change the row',\n repair:\n \"Change the row so its `rowId`, key cells and output cells match the table's declared columns.\",\n },\n CSV_BOUNDS: {\n anchor: 'split the csv',\n repair:\n 'Split the CSV so the file, each row, each column and each cell stay inside the declared limits.',\n },\n DUPLICATE_IDENTIFIER: {\n anchor: 'choose a',\n repair: 'Choose a `columnId` or `rowId` no other declaration in the table uses.',\n },\n DUPLICATE_KEY: {\n anchor: 'choose a key',\n repair: 'Choose a key no other row of the table states.',\n },\n OVERLAPPING_WINDOW: {\n anchor: 'change `effectivefrom`',\n repair:\n \"Change `effectiveFrom` or `effectiveTo` so each version's window is disjoint from the others.\",\n },\n};\n\n/** The repair row for one dataset code, total over the closed union. */\nexport function datasetDiagnosticRepair(code: DatasetDiagnosticCode): DatasetDiagnosticRepair {\n return DATASET_DIAGNOSTIC_REPAIRS[code];\n}\n"]}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The location a validator reports (`#/rules/0/expr`), as the steps a caller can act on and
3
+ * as the document-path notation every compiler diagnostic renders.
4
+ *
5
+ * The location is an RFC 6901 §6 URI fragment identifier, so each `/`-separated token is
6
+ * percent-decoded first and then JSON-Pointer-unescaped (`~1` -> `/`, `~0` -> `~`): decoding
7
+ * before splitting would turn a `/` inside a property name into a path step.
8
+ *
9
+ * When the validated document is supplied, the steps are unambiguous: a numeric token is an
10
+ * index only where the container really is an array, and every other token is the member
11
+ * name it spells. Without the document the pointer alone cannot distinguish `{"0": …}` from
12
+ * `[…]`, so a numeric token stays the string it spells — the renderer keeps the historical
13
+ * array spelling for it, while a caller that needs a decision must supply the document.
14
+ */
15
+ export declare function documentSegments(instanceLocation: string, document?: unknown): readonly (string | number)[];
16
+ /**
17
+ * One object member step appended to `parent` in injective document-path notation:
18
+ * `.name` when the member is an identifier and `["name"]` otherwise.
19
+ *
20
+ * Quoting covers a dot in a property name, a key that is all digits, a quote, a backslash
21
+ * and every control character, so two distinct locations render distinctly.
22
+ */
23
+ export declare function documentMemberPath(parent: string, member: string): string;
24
+ /**
25
+ * A validator instance location rendered in the document-path notation every compiler
26
+ * diagnostic uses (`$.rules[0].expr`).
27
+ *
28
+ * When the validated document is supplied, the notation is injective: a numeric token is
29
+ * written `[n]` only where the container really is an array, and an object member whose
30
+ * name is not an identifier is quoted. Without the document, a numeric token keeps the
31
+ * array spelling, because the pointer alone cannot distinguish `{"0": …}` from `[…]`.
32
+ */
33
+ export declare function documentPath(instanceLocation: string, document?: unknown): string;
34
+ /**
35
+ * The steps one rendered document path names: the inverse of `documentPath`.
36
+ *
37
+ * The result is tagged because a path that is not one `documentPath` produced is not a location
38
+ * at all. A caller that needed a location could otherwise read a partial answer — `$.a.b]` as
39
+ * `['a', 'b']` — and attach a diagnostic to a declaration it never named. The failure carries the
40
+ * offset it stopped at, so a caller reporting an unreadable path can quote it.
41
+ */
42
+ export type DocumentPathParse = {
43
+ readonly ok: true;
44
+ readonly segments: readonly (string | number)[];
45
+ } | {
46
+ readonly ok: false;
47
+ readonly at: number;
48
+ readonly detail: string;
49
+ };
50
+ /**
51
+ * Reads one rendered document path back into its steps.
52
+ *
53
+ * This reads the three step forms `documentPath` writes — `$`, then `.name` for a member the
54
+ * renderer spells as an identifier, `[n]` for a non-negative array index, and `["name"]` for a
55
+ * member it had to quote — so every path the renderer produces reads back to the steps it
56
+ * rendered. A quoted member is read whether or not the renderer would have spelled it dotted,
57
+ * because the two name one step; a step it does not recognise stops the parse rather than yielding
58
+ * the steps read so far, an index with a leading zero is refused because the renderer never writes
59
+ * one, and an index beyond `Number.MAX_SAFE_INTEGER` is refused because no array has one.
60
+ */
61
+ export declare function parseDocumentPath(path: string): DocumentPathParse;
62
+ //# sourceMappingURL=document-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-path.d.ts","sourceRoot":"","sources":["../src/document-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,CAAC,EAAE,OAAO,GACjB,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAyB9B;AAKD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,gBAAgB,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAiBjF;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAQzE;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CA4DjE"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * The location a validator reports (`#/rules/0/expr`), as the steps a caller can act on and
3
+ * as the document-path notation every compiler diagnostic renders.
4
+ *
5
+ * The location is an RFC 6901 §6 URI fragment identifier, so each `/`-separated token is
6
+ * percent-decoded first and then JSON-Pointer-unescaped (`~1` -> `/`, `~0` -> `~`): decoding
7
+ * before splitting would turn a `/` inside a property name into a path step.
8
+ *
9
+ * When the validated document is supplied, the steps are unambiguous: a numeric token is an
10
+ * index only where the container really is an array, and every other token is the member
11
+ * name it spells. Without the document the pointer alone cannot distinguish `{"0": …}` from
12
+ * `[…]`, so a numeric token stays the string it spells — the renderer keeps the historical
13
+ * array spelling for it, while a caller that needs a decision must supply the document.
14
+ */
15
+ export function documentSegments(instanceLocation, document) {
16
+ const pointer = instanceLocation.startsWith('#') ? instanceLocation.slice(1) : instanceLocation;
17
+ if (pointer === '')
18
+ return [];
19
+ const names = pointer
20
+ .split('/')
21
+ .slice(1)
22
+ .map((token) => decodeURIComponent(token).replaceAll('~1', '/').replaceAll('~0', '~'));
23
+ const segments = [];
24
+ let current = document;
25
+ let known = document !== undefined;
26
+ for (const name of names) {
27
+ if (known && Array.isArray(current) && /^\d+$/.test(name)) {
28
+ segments.push(Number(name));
29
+ current = current[Number(name)];
30
+ continue;
31
+ }
32
+ segments.push(name);
33
+ if (!known)
34
+ continue;
35
+ if (typeof current !== 'object' || current === null) {
36
+ known = false;
37
+ }
38
+ else {
39
+ current = Reflect.get(current, name);
40
+ }
41
+ }
42
+ return segments;
43
+ }
44
+ /** An identifier member name that renders dotted (`.name`) rather than bracket-quoted. */
45
+ const IDENTIFIER_MEMBER = /^[A-Za-z_][A-Za-z0-9_]*$/;
46
+ /**
47
+ * One object member step appended to `parent` in injective document-path notation:
48
+ * `.name` when the member is an identifier and `["name"]` otherwise.
49
+ *
50
+ * Quoting covers a dot in a property name, a key that is all digits, a quote, a backslash
51
+ * and every control character, so two distinct locations render distinctly.
52
+ */
53
+ export function documentMemberPath(parent, member) {
54
+ return IDENTIFIER_MEMBER.test(member)
55
+ ? `${parent}.${member}`
56
+ : `${parent}[${JSON.stringify(member)}]`;
57
+ }
58
+ /**
59
+ * A validator instance location rendered in the document-path notation every compiler
60
+ * diagnostic uses (`$.rules[0].expr`).
61
+ *
62
+ * When the validated document is supplied, the notation is injective: a numeric token is
63
+ * written `[n]` only where the container really is an array, and an object member whose
64
+ * name is not an identifier is quoted. Without the document, a numeric token keeps the
65
+ * array spelling, because the pointer alone cannot distinguish `{"0": …}` from `[…]`.
66
+ */
67
+ export function documentPath(instanceLocation, document) {
68
+ const known = document !== undefined;
69
+ let rendered = '$';
70
+ for (const segment of documentSegments(instanceLocation, document)) {
71
+ if (typeof segment === 'number') {
72
+ rendered += `[${String(segment)}]`;
73
+ continue;
74
+ }
75
+ if (!known && /^\d+$/.test(segment)) {
76
+ // Without the document the pointer cannot say whether this is an index or a member
77
+ // named "0"; the array spelling is the historical rendering.
78
+ rendered += `[${segment}]`;
79
+ continue;
80
+ }
81
+ rendered = documentMemberPath(rendered, segment);
82
+ }
83
+ return rendered;
84
+ }
85
+ /** An identifier step: the dotted spelling `documentPath` emits for such a member. */
86
+ const IDENTIFIER_STEP = /^[A-Za-z_][A-Za-z0-9_]*/u;
87
+ /** An array index as `documentPath` spells it: decimal, no sign, no leading zero. */
88
+ const INDEX_STEP = /^(?:0|[1-9][0-9]*)$/u;
89
+ /**
90
+ * Reads one rendered document path back into its steps.
91
+ *
92
+ * This reads the three step forms `documentPath` writes — `$`, then `.name` for a member the
93
+ * renderer spells as an identifier, `[n]` for a non-negative array index, and `["name"]` for a
94
+ * member it had to quote — so every path the renderer produces reads back to the steps it
95
+ * rendered. A quoted member is read whether or not the renderer would have spelled it dotted,
96
+ * because the two name one step; a step it does not recognise stops the parse rather than yielding
97
+ * the steps read so far, an index with a leading zero is refused because the renderer never writes
98
+ * one, and an index beyond `Number.MAX_SAFE_INTEGER` is refused because no array has one.
99
+ */
100
+ export function parseDocumentPath(path) {
101
+ if (!path.startsWith('$')) {
102
+ return { ok: false, at: 0, detail: 'a document path starts with `$`' };
103
+ }
104
+ const segments = [];
105
+ let index = 1;
106
+ while (index < path.length) {
107
+ if (path[index] === '.') {
108
+ const name = IDENTIFIER_STEP.exec(path.slice(index + 1));
109
+ if (name === null) {
110
+ return {
111
+ ok: false,
112
+ at: index,
113
+ detail: 'a `.` step names an identifier: a letter or underscore first, then letters, digits or underscores',
114
+ };
115
+ }
116
+ segments.push(name[0]);
117
+ index += name[0].length + 1;
118
+ continue;
119
+ }
120
+ if (path[index] !== '[') {
121
+ return {
122
+ ok: false,
123
+ at: index,
124
+ detail: 'a document-path step is `.name`, `[n]` or `["name"]`',
125
+ };
126
+ }
127
+ if (path[index + 1] === '"') {
128
+ const quoted = quotedStep(path, index);
129
+ if (!quoted.ok)
130
+ return quoted;
131
+ segments.push(quoted.member);
132
+ index = quoted.end;
133
+ continue;
134
+ }
135
+ const close = path.indexOf(']', index + 1);
136
+ if (close < 0) {
137
+ return { ok: false, at: index, detail: 'an `[` step is not closed by `]`' };
138
+ }
139
+ const token = path.slice(index + 1, close);
140
+ if (!INDEX_STEP.test(token)) {
141
+ return {
142
+ ok: false,
143
+ at: index,
144
+ detail: 'an index step is decimal, unsigned and without a leading zero; a member whose name is not an identifier is quoted',
145
+ };
146
+ }
147
+ const arrayIndex = Number(token);
148
+ if (!Number.isSafeInteger(arrayIndex)) {
149
+ return {
150
+ ok: false,
151
+ at: index,
152
+ detail: 'an index step names an array element, so it is a safe integer',
153
+ };
154
+ }
155
+ segments.push(arrayIndex);
156
+ index = close + 1;
157
+ }
158
+ return { ok: true, segments };
159
+ }
160
+ /**
161
+ * The member a `["…"]` step spells.
162
+ *
163
+ * The token is a JSON string literal — `JSON.stringify` wrote it — so the closing quote is found
164
+ * by walking the escapes rather than by the next `"`, which a member containing a quote would
165
+ * end early. A token that is not valid JSON is not one the renderer produced.
166
+ */
167
+ function quotedStep(path, start) {
168
+ // `start` is the `[`, so `start + 1` is the opening quote the caller found.
169
+ let index = start + 2;
170
+ let close = -1;
171
+ while (index < path.length) {
172
+ if (path[index] === '\\') {
173
+ index += 2;
174
+ continue;
175
+ }
176
+ if (path[index] === '"') {
177
+ close = index;
178
+ break;
179
+ }
180
+ index += 1;
181
+ }
182
+ if (close < 0) {
183
+ return { ok: false, at: start, detail: 'a quoted member is not closed by `"`' };
184
+ }
185
+ if (path[close + 1] !== ']') {
186
+ return { ok: false, at: close + 1, detail: 'a quoted member is closed by `]`' };
187
+ }
188
+ const literal = path.slice(start + 1, close + 1);
189
+ let decoded;
190
+ try {
191
+ decoded = JSON.parse(literal);
192
+ }
193
+ catch {
194
+ return { ok: false, at: start, detail: 'a quoted member is a JSON string literal' };
195
+ }
196
+ return typeof decoded === 'string'
197
+ ? { ok: true, member: decoded, end: close + 2 }
198
+ : { ok: false, at: start, detail: 'a quoted member is a JSON string literal' };
199
+ }
200
+ //# sourceMappingURL=document-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-path.js","sourceRoot":"","sources":["../src/document-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,gBAAwB,EACxB,QAAkB;IAElB,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAChG,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,OAAO;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,KAAK,CAAC,CAAC,CAAC;SACR,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACzF,MAAM,QAAQ,GAAwB,EAAE,CAAC;IACzC,IAAI,OAAO,GAAY,QAAQ,CAAC;IAChC,IAAI,KAAK,GAAG,QAAQ,KAAK,SAAS,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,OAA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CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,0CAA0C,EAAE,CAAC;IACtF,CAAC;IACD,OAAO,OAAO,OAAO,KAAK,QAAQ;QAChC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE;QAC/C,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,0CAA0C,EAAE,CAAC;AACnF,CAAC","sourcesContent":["/**\n * The location a validator reports (`#/rules/0/expr`), as the steps a caller can act on and\n * as the document-path notation every compiler diagnostic renders.\n *\n * The location is an RFC 6901 §6 URI fragment identifier, so each `/`-separated token is\n * percent-decoded first and then JSON-Pointer-unescaped (`~1` -> `/`, `~0` -> `~`): decoding\n * before splitting would turn a `/` inside a property name into a path step.\n *\n * When the validated document is supplied, the steps are unambiguous: a numeric token is an\n * index only where the container really is an array, and every other token is the member\n * name it spells. Without the document the pointer alone cannot distinguish `{\"0\": …}` from\n * `[…]`, so a numeric token stays the string it spells — the renderer keeps the historical\n * array spelling for it, while a caller that needs a decision must supply the document.\n */\nexport function documentSegments(\n instanceLocation: string,\n document?: unknown,\n): readonly (string | number)[] {\n const pointer = instanceLocation.startsWith('#') ? instanceLocation.slice(1) : instanceLocation;\n if (pointer === '') return [];\n const names = pointer\n .split('/')\n .slice(1)\n .map((token) => decodeURIComponent(token).replaceAll('~1', '/').replaceAll('~0', '~'));\n const segments: (string | number)[] = [];\n let current: unknown = document;\n let known = document !== undefined;\n for (const name of names) {\n if (known && Array.isArray(current) && /^\\d+$/.test(name)) {\n segments.push(Number(name));\n current = current[Number(name)];\n continue;\n }\n segments.push(name);\n if (!known) continue;\n if (typeof current !== 'object' || current === null) {\n known = false;\n } else {\n current = Reflect.get(current, name);\n }\n }\n return segments;\n}\n\n/** An identifier member name that renders dotted (`.name`) rather than bracket-quoted. */\nconst IDENTIFIER_MEMBER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * One object member step appended to `parent` in injective document-path notation:\n * `.name` when the member is an identifier and `[\"name\"]` otherwise.\n *\n * Quoting covers a dot in a property name, a key that is all digits, a quote, a backslash\n * and every control character, so two distinct locations render distinctly.\n */\nexport function documentMemberPath(parent: string, member: string): string {\n return IDENTIFIER_MEMBER.test(member)\n ? `${parent}.${member}`\n : `${parent}[${JSON.stringify(member)}]`;\n}\n\n/**\n * A validator instance location rendered in the document-path notation every compiler\n * diagnostic uses (`$.rules[0].expr`).\n *\n * When the validated document is supplied, the notation is injective: a numeric token is\n * written `[n]` only where the container really is an array, and an object member whose\n * name is not an identifier is quoted. Without the document, a numeric token keeps the\n * array spelling, because the pointer alone cannot distinguish `{\"0\": …}` from `[…]`.\n */\nexport function documentPath(instanceLocation: string, document?: unknown): string {\n const known = document !== undefined;\n let rendered = '$';\n for (const segment of documentSegments(instanceLocation, document)) {\n if (typeof segment === 'number') {\n rendered += `[${String(segment)}]`;\n continue;\n }\n if (!known && /^\\d+$/.test(segment)) {\n // Without the document the pointer cannot say whether this is an index or a member\n // named \"0\"; the array spelling is the historical rendering.\n rendered += `[${segment}]`;\n continue;\n }\n rendered = documentMemberPath(rendered, segment);\n }\n return rendered;\n}\n\n/**\n * The steps one rendered document path names: the inverse of `documentPath`.\n *\n * The result is tagged because a path that is not one `documentPath` produced is not a location\n * at all. A caller that needed a location could otherwise read a partial answer — `$.a.b]` as\n * `['a', 'b']` — and attach a diagnostic to a declaration it never named. The failure carries the\n * offset it stopped at, so a caller reporting an unreadable path can quote it.\n */\nexport type DocumentPathParse =\n | { readonly ok: true; readonly segments: readonly (string | number)[] }\n | { readonly ok: false; readonly at: number; readonly detail: string };\n\n/** An identifier step: the dotted spelling `documentPath` emits for such a member. */\nconst IDENTIFIER_STEP = /^[A-Za-z_][A-Za-z0-9_]*/u;\n\n/** An array index as `documentPath` spells it: decimal, no sign, no leading zero. */\nconst INDEX_STEP = /^(?:0|[1-9][0-9]*)$/u;\n\n/**\n * Reads one rendered document path back into its steps.\n *\n * This reads the three step forms `documentPath` writes — `$`, then `.name` for a member the\n * renderer spells as an identifier, `[n]` for a non-negative array index, and `[\"name\"]` for a\n * member it had to quote — so every path the renderer produces reads back to the steps it\n * rendered. A quoted member is read whether or not the renderer would have spelled it dotted,\n * because the two name one step; a step it does not recognise stops the parse rather than yielding\n * the steps read so far, an index with a leading zero is refused because the renderer never writes\n * one, and an index beyond `Number.MAX_SAFE_INTEGER` is refused because no array has one.\n */\nexport function parseDocumentPath(path: string): DocumentPathParse {\n if (!path.startsWith('$')) {\n return { ok: false, at: 0, detail: 'a document path starts with `$`' };\n }\n const segments: (string | number)[] = [];\n let index = 1;\n while (index < path.length) {\n if (path[index] === '.') {\n const name = IDENTIFIER_STEP.exec(path.slice(index + 1));\n if (name === null) {\n return {\n ok: false,\n at: index,\n detail:\n 'a `.` step names an identifier: a letter or underscore first, then letters, digits or underscores',\n };\n }\n segments.push(name[0]);\n index += name[0].length + 1;\n continue;\n }\n if (path[index] !== '[') {\n return {\n ok: false,\n at: index,\n detail: 'a document-path step is `.name`, `[n]` or `[\"name\"]`',\n };\n }\n if (path[index + 1] === '\"') {\n const quoted = quotedStep(path, index);\n if (!quoted.ok) return quoted;\n segments.push(quoted.member);\n index = quoted.end;\n continue;\n }\n const close = path.indexOf(']', index + 1);\n if (close < 0) {\n return { ok: false, at: index, detail: 'an `[` step is not closed by `]`' };\n }\n const token = path.slice(index + 1, close);\n if (!INDEX_STEP.test(token)) {\n return {\n ok: false,\n at: index,\n detail:\n 'an index step is decimal, unsigned and without a leading zero; a member whose name is not an identifier is quoted',\n };\n }\n const arrayIndex = Number(token);\n if (!Number.isSafeInteger(arrayIndex)) {\n return {\n ok: false,\n at: index,\n detail: 'an index step names an array element, so it is a safe integer',\n };\n }\n segments.push(arrayIndex);\n index = close + 1;\n }\n return { ok: true, segments };\n}\n\n/** One quoted member step, decoded, and the offset just past its closing `]`. */\ntype QuotedStep =\n | { readonly ok: true; readonly member: string; readonly end: number }\n | { readonly ok: false; readonly at: number; readonly detail: string };\n\n/**\n * The member a `[\"…\"]` step spells.\n *\n * The token is a JSON string literal — `JSON.stringify` wrote it — so the closing quote is found\n * by walking the escapes rather than by the next `\"`, which a member containing a quote would\n * end early. A token that is not valid JSON is not one the renderer produced.\n */\nfunction quotedStep(path: string, start: number): QuotedStep {\n // `start` is the `[`, so `start + 1` is the opening quote the caller found.\n let index = start + 2;\n let close = -1;\n while (index < path.length) {\n if (path[index] === '\\\\') {\n index += 2;\n continue;\n }\n if (path[index] === '\"') {\n close = index;\n break;\n }\n index += 1;\n }\n if (close < 0) {\n return { ok: false, at: start, detail: 'a quoted member is not closed by `\"`' };\n }\n if (path[close + 1] !== ']') {\n return { ok: false, at: close + 1, detail: 'a quoted member is closed by `]`' };\n }\n const literal = path.slice(start + 1, close + 1);\n let decoded: unknown;\n try {\n decoded = JSON.parse(literal);\n } catch {\n return { ok: false, at: start, detail: 'a quoted member is a JSON string literal' };\n }\n return typeof decoded === 'string'\n ? { ok: true, member: decoded, end: close + 2 }\n : { ok: false, at: start, detail: 'a quoted member is a JSON string literal' };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ExprNode } from '@azx-pbc/axiom-runtime';
2
+ /** A document-supplied node that is not the variant its `kind` names. */
3
+ export declare class MalformedCompiledNode extends Error {
4
+ constructor(detail: string);
5
+ }
6
+ /** The node `value` states, narrowed to the variant its `kind` names. */
7
+ export declare function exprNodeOf(value: unknown, where: string): ExprNode;
8
+ //# sourceMappingURL=boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../src/expr/boundary.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAMV,QAAQ,EAIT,MAAM,wBAAwB,CAAC;AAiFhC,yEAAyE;AACzE,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,MAAM,EAAE,MAAM,EAGzB;CACF;AAiGD,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CA2ElE"}
@@ -0,0 +1,243 @@
1
+ import { ARITHMETIC_OPERATORS, assertNever, BUILTIN_OPERATORS, COMPARISON_OPERATORS, isRecord, } from '@azx-pbc/axiom-runtime';
2
+ import { arityOf, arityText } from './typecheck/arity.js';
3
+ /**
4
+ * The checked narrowing from a metaschema-validated tree to the compiled `ExprNode` union.
5
+ *
6
+ * The closed metaschema states the members an `exprNode` may carry, but its definitions are
7
+ * shared across variants, so a tree can name one variant's `kind` beside another variant's
8
+ * members and still validate. Casting here would hand the evaluator a node it did not prove;
9
+ * this walk reads the `kind`, then the members *that* variant declares, and recurses. Every
10
+ * `kind` the union has is handled, and a new one fails the `assertNever` instead of being
11
+ * passed through as an untyped value.
12
+ */
13
+ /**
14
+ * The members each variant declares. Keyed by the union's own `kind`, so a variant added to
15
+ * `ExprNode` and forgotten here fails typecheck; reading a member outside its variant is
16
+ * refused rather than dropped, which is the per-variant closure the shared metaschema cannot
17
+ * express.
18
+ */
19
+ const VARIANT_MEMBERS = {
20
+ literal: ['domain', 'value'],
21
+ path: ['path'],
22
+ list: ['items'],
23
+ and: ['args'],
24
+ or: ['args'],
25
+ not: ['args'],
26
+ compare: ['op', 'args'],
27
+ if: ['args'],
28
+ coalesce: ['args'],
29
+ call: ['op', 'args'],
30
+ comprehension: ['binder', 'source', 'valueExpr', 'predicate'],
31
+ };
32
+ const CALL_OPERATORS = new Set([
33
+ ...ARITHMETIC_OPERATORS,
34
+ ...BUILTIN_OPERATORS,
35
+ ]);
36
+ const COMPARISONS = new Set(COMPARISON_OPERATORS);
37
+ /** Whether `kind` names a variant of the union, which is what makes the index below safe. */
38
+ function isNodeKind(kind) {
39
+ return Object.hasOwn(VARIANT_MEMBERS, kind);
40
+ }
41
+ function isComparisonOperator(op) {
42
+ return COMPARISONS.has(op);
43
+ }
44
+ function isCallOperator(op) {
45
+ return CALL_OPERATORS.has(op);
46
+ }
47
+ /**
48
+ * Every primitive a literal may name, as a map keyed by the union itself: a primitive added to
49
+ * `Primitive` and forgotten here fails typecheck, so this cannot drift from the type it mirrors.
50
+ */
51
+ const PRIMITIVE_DOMAINS = {
52
+ string: true,
53
+ boolean: true,
54
+ integer: true,
55
+ decimal: true,
56
+ money: true,
57
+ date: true,
58
+ instant: true,
59
+ time: true,
60
+ media_ref: true,
61
+ signature_ref: true,
62
+ timeslot: true,
63
+ quantity: true,
64
+ duration: true,
65
+ address: true,
66
+ coordinate: true,
67
+ record: true,
68
+ array: true,
69
+ };
70
+ /** Whether `value` is a literal domain: one primitive, or the explicitly authored `null`. */
71
+ function isLiteralDomain(value) {
72
+ return value === 'null' || Object.hasOwn(PRIMITIVE_DOMAINS, value);
73
+ }
74
+ /** A document-supplied node that is not the variant its `kind` names. */
75
+ export class MalformedCompiledNode extends Error {
76
+ constructor(detail) {
77
+ super(`the compiled document carries a malformed expression node ${detail}`);
78
+ this.name = 'MalformedCompiledNode';
79
+ }
80
+ }
81
+ function malformed(where, detail) {
82
+ throw new MalformedCompiledNode(`${where}: ${detail}`);
83
+ }
84
+ function textMember(node, member, where) {
85
+ const value = node[member];
86
+ if (typeof value !== 'string')
87
+ malformed(where, `\`${member}\` is not a string`);
88
+ return value;
89
+ }
90
+ /** The argument list of a node, each argument narrowed in turn. */
91
+ function argsOf(node, where) {
92
+ const args = node['args'];
93
+ if (!Array.isArray(args))
94
+ malformed(where, '`args` is not a list');
95
+ return args.map((arg, index) => exprNodeOf(arg, `${where}.args[${String(index)}]`));
96
+ }
97
+ /** The argument list of a node that requires at least `min` operands. */
98
+ function atLeastArgs(node, where, min) {
99
+ const args = argsOf(node, where);
100
+ if (args.length < min) {
101
+ malformed(where, `wants at least ${String(min)} operand(s), not ${String(args.length)}`);
102
+ }
103
+ return args;
104
+ }
105
+ /** The items of a `list` node, each narrowed in turn. */
106
+ function itemsOf(node, where) {
107
+ const items = node['items'];
108
+ if (!Array.isArray(items))
109
+ malformed(where, '`items` is not a list');
110
+ return items.map((item, index) => exprNodeOf(item, `${where}.items[${String(index)}]`));
111
+ }
112
+ /** The argument list of a node that fixes its arity, checked against that arity. */
113
+ function fixedArgs(node, where, arity) {
114
+ const args = argsOf(node, where);
115
+ if (args.length !== arity) {
116
+ malformed(where, `wants ${String(arity)} operand(s), not ${String(args.length)}`);
117
+ }
118
+ return args;
119
+ }
120
+ /** A wire value: the shapes the closed metaschema's `wireValue` admits, checked structurally. */
121
+ function wireValueOf(value, where) {
122
+ if (value === null || typeof value === 'string' || typeof value === 'boolean')
123
+ return value;
124
+ if (typeof value === 'number')
125
+ return value;
126
+ if (Array.isArray(value)) {
127
+ return value.map((item, index) => wireValueOf(item, `${where}[${String(index)}]`));
128
+ }
129
+ if (isRecord(value)) {
130
+ const record = {};
131
+ for (const member of Object.keys(value)) {
132
+ record[member] = wireValueOf(value[member], `${where}.${member}`);
133
+ }
134
+ return record;
135
+ }
136
+ return malformed(where, `${JSON.stringify(value) ?? typeof value} is not a wire value`);
137
+ }
138
+ function comprehensionOf(value, where) {
139
+ if (!isRecord(value))
140
+ malformed(where, 'a comprehension is not an object');
141
+ const binder = value['binder'];
142
+ if (!isRecord(binder))
143
+ malformed(where, 'a comprehension carries no binder');
144
+ const name = textMember(binder, 'name', `${where}.binder`);
145
+ const source = exprNodeOf(value['source'], `${where}.source`);
146
+ const valueExpr = value['valueExpr'] === undefined
147
+ ? undefined
148
+ : exprNodeOf(value['valueExpr'], `${where}.valueExpr`);
149
+ const predicate = value['predicate'] === undefined
150
+ ? undefined
151
+ : exprNodeOf(value['predicate'], `${where}.predicate`);
152
+ // The metaschema requires a body, and the evaluator relies on it: a source with neither is
153
+ // a comprehension that would iterate and produce nothing.
154
+ if (valueExpr === undefined && predicate === undefined) {
155
+ malformed(where, 'a comprehension carries no body: state `predicate` or `valueExpr`');
156
+ }
157
+ return {
158
+ kind: 'comprehension',
159
+ binder: { name },
160
+ source,
161
+ ...(valueExpr === undefined ? {} : { valueExpr }),
162
+ ...(predicate === undefined ? {} : { predicate }),
163
+ };
164
+ }
165
+ /** The node `value` states, narrowed to the variant its `kind` names. */
166
+ export function exprNodeOf(value, where) {
167
+ if (!isRecord(value))
168
+ malformed(where, 'a node is not an object');
169
+ const kind = textMember(value, 'kind', where);
170
+ if (!isNodeKind(kind))
171
+ malformed(where, `\`${kind}\` is not an expression node kind`);
172
+ const declared = VARIANT_MEMBERS[kind];
173
+ const extra = Object.keys(value).filter((member) => member !== 'kind' && !declared.includes(member));
174
+ if (extra.length > 0) {
175
+ malformed(where, `\`${kind}\` declares no ${extra.map((member) => `\`${member}\``).join(', ')}`);
176
+ }
177
+ switch (kind) {
178
+ case 'literal': {
179
+ const domain = textMember(value, 'domain', where);
180
+ if (!isLiteralDomain(domain))
181
+ malformed(where, `\`${domain}\` is not a literal domain`);
182
+ const node = {
183
+ kind: 'literal',
184
+ domain,
185
+ value: wireValueOf(value['value'], `${where}.value`),
186
+ };
187
+ return node;
188
+ }
189
+ case 'path':
190
+ return { kind: 'path', path: textMember(value, 'path', where) };
191
+ case 'list':
192
+ return { kind: 'list', items: itemsOf(value, where) };
193
+ case 'and':
194
+ return { kind: 'and', args: atLeastArgs(value, where, 2) };
195
+ case 'or':
196
+ return { kind: 'or', args: atLeastArgs(value, where, 2) };
197
+ case 'not': {
198
+ const [only] = fixedArgs(value, where, 1);
199
+ if (only === undefined)
200
+ malformed(where, '`not` carries no operand');
201
+ return { kind: 'not', args: [only] };
202
+ }
203
+ case 'compare': {
204
+ const op = textMember(value, 'op', where);
205
+ if (!isComparisonOperator(op))
206
+ malformed(where, `\`${op}\` is not a comparison operator`);
207
+ const [left, right] = fixedArgs(value, where, 2);
208
+ if (left === undefined || right === undefined)
209
+ malformed(where, '`compare` wants two operands');
210
+ return { kind: 'compare', op, args: [left, right] };
211
+ }
212
+ case 'if': {
213
+ const [condition, whenTrue, whenFalse] = fixedArgs(value, where, 3);
214
+ if (condition === undefined || whenTrue === undefined || whenFalse === undefined) {
215
+ malformed(where, '`if` wants three operands');
216
+ }
217
+ return { kind: 'if', args: [condition, whenTrue, whenFalse] };
218
+ }
219
+ case 'coalesce':
220
+ return { kind: 'coalesce', args: atLeastArgs(value, where, 2) };
221
+ case 'call': {
222
+ const op = textMember(value, 'op', where);
223
+ if (!isCallOperator(op))
224
+ malformed(where, `\`${op}\` is not a call operator`);
225
+ // A `call` carries an operator name, so its width is the one that name's signature
226
+ // states. Reading only a minimum let a metaschema-valid `{"op":"len","args":[a,b]}`
227
+ // through a boundary whose whole purpose is to refuse a node the evaluator cannot mean.
228
+ const arity = arityOf(op);
229
+ const args = argsOf(value, where);
230
+ if (args.length < arity.min || (arity.max !== undefined && args.length > arity.max)) {
231
+ malformed(where, `\`${op}\` takes ${arityText(arity)}, found ${String(args.length)}`);
232
+ }
233
+ const node = { kind: 'call', op, args };
234
+ return node;
235
+ }
236
+ case 'comprehension':
237
+ return comprehensionOf(value, where);
238
+ default:
239
+ // Every variant is handled above; a later one fails here rather than passing through.
240
+ return assertNever(kind);
241
+ }
242
+ }
243
+ //# sourceMappingURL=boundary.js.map