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

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,242 @@
1
+ import { RESERVED_CONTEXT_ROOTS, memberOf } from '@azx-pbc/axiom-runtime';
2
+ import { ExpressionCompileError } from './diagnostics.js';
3
+ import { analyseExpression } from './lint.js';
4
+ import { closestNames } from './suggest.js';
5
+ import { callType } from './typecheck/calls.js';
6
+ import { compareType } from './typecheck/comparison.js';
7
+ import { coalesceType, comprehensionType, conditionalType, listType, logicalType, notType, } from './typecheck/compound.js';
8
+ import { gateFoldDetail, isGateFoldOperator } from './typecheck/gate-folds.js';
9
+ import { pathType } from './typecheck/paths.js';
10
+ import { arrayElementType, literalMoneyDomain, literalQuantityDomain, primitiveType, } from './typecheck/types.js';
11
+ export { typeName } from './typecheck/types.js';
12
+ const INDEX_BY_DECLARATIONS = new WeakMap();
13
+ function checkerIndex(declarations) {
14
+ const cached = INDEX_BY_DECLARATIONS.get(declarations);
15
+ if (cached !== undefined)
16
+ return cached;
17
+ const fields = new Map((declarations.fields ?? []).map((field) => [field.fieldId, field]));
18
+ const arraysById = new Map();
19
+ const indexArrays = (members) => {
20
+ for (const member of members) {
21
+ if (member.primitive === 'array')
22
+ arraysById.set(member.fieldId, member);
23
+ indexArrays(member.fields ?? []);
24
+ }
25
+ };
26
+ indexArrays(declarations.fields ?? []);
27
+ const contextRoots = new Map((declarations.context?.roots ?? []).map((root) => [root.path.replace(/^context\./, ''), root]));
28
+ // The reserved roots are in scope for every schema, declared or not. A declaration of one is
29
+ // refused at the document boundary, so no declared root can shadow the environment's value.
30
+ for (const root of RESERVED_CONTEXT_ROOTS) {
31
+ if (!contextRoots.has(root.path)) {
32
+ contextRoots.set(root.path, { path: root.path, primitive: root.primitive });
33
+ }
34
+ }
35
+ const datasets = new Map((declarations.datasets ?? []).map((dataset) => [dataset.tableId, dataset]));
36
+ const index = { fields, arraysById, contextRoots, datasets };
37
+ INDEX_BY_DECLARATIONS.set(declarations, index);
38
+ return index;
39
+ }
40
+ /** The compiler's per-expression state: declarations, binders and source offsets. */
41
+ class Checker {
42
+ offsets;
43
+ powerOperators;
44
+ lengthProperties;
45
+ inlinedNodes;
46
+ fields;
47
+ contextRoots;
48
+ datasets;
49
+ scopedBindings = new Map();
50
+ /** Where a fold that is legal but undecided on an empty list is recorded. */
51
+ onUndecidedFold;
52
+ /** Whether this build admits `matches`; a build that forbids regex refuses every call. */
53
+ allowRegex;
54
+ /**
55
+ * Whether this expression may read the gate fold. A document compiles its gate rules with
56
+ * the fold in force; `compileExpr` has no gate host, so it passes false and the name is
57
+ * refused rather than compiled into a call nothing can answer.
58
+ */
59
+ allowGateFolds;
60
+ constructor(declarations, offsets, scope = {}, powerOperators = new WeakSet(), lengthProperties = new WeakSet()) {
61
+ this.offsets = offsets;
62
+ this.powerOperators = powerOperators;
63
+ this.lengthProperties = lengthProperties;
64
+ this.inlinedNodes = scope.inlinedNodes;
65
+ this.onUndecidedFold = scope.onUndecidedFold;
66
+ this.allowRegex = scope.allowRegex ?? true;
67
+ this.allowGateFolds = scope.allowGateFolds ?? true;
68
+ // The four maps are derived from the compilation's one declaration object, so they are
69
+ // built once per compilation rather than once per expression slot: a 500-field document
70
+ // with 500 rules otherwise rebuilds every index 500 times.
71
+ const index = checkerIndex(declarations);
72
+ this.fields = index.fields;
73
+ this.contextRoots = index.contextRoots;
74
+ this.datasets = index.datasets;
75
+ // An item-scoped expression reads its row through the same implicit binders a comprehension
76
+ // offers, so they are already in scope when the expression is checked. Field ids are unique
77
+ // across the document, and an option may belong to a row of an array a record holds.
78
+ const itemFieldId = scope.itemFieldId;
79
+ if (itemFieldId !== undefined) {
80
+ const array = index.arraysById.get(itemFieldId);
81
+ if (array === undefined) {
82
+ throw new ExpressionCompileError('UNKNOWN_IDENTIFIER', 0, `an item-scoped expression addresses \`${itemFieldId}\`, which is not a declared array`, closestNames(itemFieldId, [...index.arraysById.keys()]));
83
+ }
84
+ const element = arrayElementType(array);
85
+ if (element === undefined) {
86
+ throw new ExpressionCompileError('UNKNOWN_IDENTIFIER', 0, `an item-scoped expression addresses \`${itemFieldId}\`, which declares no item type`);
87
+ }
88
+ const bindings = new Map();
89
+ for (const name of ['$it', '$prev', '$next'])
90
+ bindings.set(name, element);
91
+ bindings.set('$i', primitiveType('integer'));
92
+ // `$row` is the owner's own row, stable across a nested comprehension: `$it` is rebound
93
+ // by each iteration, so a body that iterates the row's own list would otherwise lose
94
+ // the row it is deciding. A bare record member stays readable by its path.
95
+ bindings.set('$row', element);
96
+ this.scopedBindings = bindings;
97
+ }
98
+ }
99
+ check(node) {
100
+ switch (node.kind) {
101
+ case 'literal':
102
+ return primitiveType(node.domain, node.domain === 'money' ? literalMoneyDomain(node.value) : undefined, false, node.domain === 'quantity' ? literalQuantityDomain(node.value) : undefined);
103
+ case 'path':
104
+ return pathType(this, node);
105
+ case 'list':
106
+ return listType(this, node);
107
+ case 'and':
108
+ case 'or':
109
+ return logicalType(this, node);
110
+ case 'not':
111
+ return notType(this, node);
112
+ case 'compare':
113
+ return compareType(this, node);
114
+ case 'if':
115
+ return conditionalType(this, node);
116
+ case 'coalesce':
117
+ return coalesceType(this, node);
118
+ case 'call': {
119
+ // The type is checked first, so an ill-formed gate fold (a computed rule id, an
120
+ // unknown arity) is refused for that cause, exactly as the document door refuses it
121
+ // before its placement cross-check. Only then is the fold's home decided.
122
+ const type = callType(this, node);
123
+ if (!this.allowGateFolds && isGateFoldOperator(node.op)) {
124
+ throw new ExpressionCompileError('RULE_REFERENCE', this.offsetOf(node), gateFoldDetail([node.op]));
125
+ }
126
+ return type;
127
+ }
128
+ case 'comprehension':
129
+ return comprehensionType(this, node);
130
+ }
131
+ }
132
+ bindings() {
133
+ return this.scopedBindings;
134
+ }
135
+ replaceBindings(bindings) {
136
+ this.scopedBindings = bindings;
137
+ }
138
+ mismatch(node, detail) {
139
+ return new ExpressionCompileError('TYPE_MISMATCH', this.offsetOf(node), detail);
140
+ }
141
+ offsetOf(node) {
142
+ return this.offsets.get(node) ?? 0;
143
+ }
144
+ isPowerOperator(node) {
145
+ return this.powerOperators.has(node);
146
+ }
147
+ isLengthProperty(node) {
148
+ return this.lengthProperties.has(node);
149
+ }
150
+ isInlinedNode(node) {
151
+ return this.inlinedNodes?.has(node) ?? false;
152
+ }
153
+ fieldAtPath(path) {
154
+ const segments = path.split('.');
155
+ const [head, ...rest] = segments;
156
+ if (head === undefined)
157
+ return undefined;
158
+ if (head.startsWith('$')) {
159
+ // `$it`, `$prev` and `$next` are rebound by every comprehension, so a declaration reached
160
+ // through them cannot be attributed to the list a fold reads. `$row` is stable, but its
161
+ // members are declared inside an array row, where v1 refuses `minItems`
162
+ // (`MODEL-2.1.17`): no declaration there can prove the list non-empty, so neither
163
+ // resolves to one.
164
+ return undefined;
165
+ }
166
+ // A context root declares an item domain but no cardinality, so it proves nothing here.
167
+ if (head === 'context')
168
+ return undefined;
169
+ const first = this.fields.get(head);
170
+ if (first === undefined)
171
+ return undefined;
172
+ let current = first;
173
+ for (const segment of rest) {
174
+ // A member reached through an array is declared inside a row, where v1 refuses
175
+ // `minItems`; the declaration exists but cannot carry the proof the fold needs.
176
+ if (current.primitive === 'array')
177
+ return undefined;
178
+ const member = memberOf(current, segment);
179
+ if (member === undefined)
180
+ return undefined;
181
+ current = member;
182
+ }
183
+ return current;
184
+ }
185
+ reportUndecidedFold(finding) {
186
+ this.onUndecidedFold?.(finding);
187
+ }
188
+ }
189
+ /** Type-checks a parsed expression against its declarations and the scope it runs in. */
190
+ export function checkExpression(declarations, node, offsets, scope = {}, powerOperators = new WeakSet(), lengthProperties = new WeakSet()) {
191
+ const checker = new Checker(declarations, offsets, scope, powerOperators, lengthProperties);
192
+ const type = checker.check(node);
193
+ // The constant and bound analysis runs once after typing, so a refusal it raises is the same
194
+ // diagnostic shape a type refusal is and a warning rides beside a document that still compiles.
195
+ // A compiled form (no `onLintFinding` callback) skips the pass: the artifact is machine-made,
196
+ // and a fixture may deliberately carry a literal the evaluator refuses at run time.
197
+ if (scope.onLintFinding !== undefined) {
198
+ for (const finding of analyseExpression(checker, node)) {
199
+ scope.onLintFinding(finding);
200
+ }
201
+ }
202
+ return type;
203
+ }
204
+ /**
205
+ * The lint pass over the analysis tree, separate from the tree the author's slot emits.
206
+ *
207
+ * `compileExpressionSlot` types the emitted node, where the `in`-to-`contains` lowering must
208
+ * land, and analyses the substituted copy, where a computed definition is visible. The copy
209
+ * brings its own offsets map, so a finding inside it keeps the position of the path it reads
210
+ * rather than collapsing to `0`.
211
+ */
212
+ export function lintExpression(declarations, node, offsets, onFinding, scope = {}) {
213
+ const checker = new Checker(declarations, offsets, scope);
214
+ for (const finding of analyseExpression(checker, node))
215
+ onFinding(finding);
216
+ }
217
+ /**
218
+ * Collects undecided-fold findings over the substituted analysis tree, where pure computed
219
+ * definitions are visible (so a computed non-empty list literal proves a fold decided).
220
+ *
221
+ * Returns `undefined` when static typing fails on the substituted tree (for example, when a
222
+ * compute rule widens an integer into a decimal field read by a decimal-only built-in, or when
223
+ * the computed definition is itself ill-typed), allowing the caller to fall back to the findings
224
+ * recorded on the emitted tree.
225
+ */
226
+ export function undecidedFolds(declarations, node, offsets, scope = {}) {
227
+ const findings = [];
228
+ const checker = new Checker(declarations, offsets, {
229
+ ...scope,
230
+ onUndecidedFold: (finding) => findings.push(finding),
231
+ });
232
+ try {
233
+ checker.check(node);
234
+ return findings;
235
+ }
236
+ catch (error) {
237
+ if (error instanceof ExpressionCompileError)
238
+ return undefined;
239
+ throw error;
240
+ }
241
+ }
242
+ //# sourceMappingURL=typecheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck.js","sourceRoot":"","sources":["../../src/expr/typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA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oB,EAAE;IAE3B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1D,KAAK,MAAM,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC;QAAE,SAAS,CAAC,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAoC,EACpC,IAAc,EACd,OAAkC,EAClC,KAAK,GAAoB,EAAE;IAE3B,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE;QACjD,GAAG,KAAK;QACR,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;KACrD,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,sBAAsB;YAAE,OAAO,SAAS,CAAC;QAC9D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { RESERVED_CONTEXT_ROOTS, memberOf } from '@azx-pbc/axiom-runtime';\nimport type {\n CompiledField,\n ContextRoot,\n DatasetDeclaration,\n ExprNode,\n ExpressionDeclarations,\n} from '@azx-pbc/axiom-runtime';\nimport { ExpressionCompileError } from './diagnostics.js';\nimport { analyseExpression } from './lint.js';\nimport type { LintFinding } from './lint.js';\nimport { closestNames } from './suggest.js';\nimport { callType } from './typecheck/calls.js';\nimport { compareType } from './typecheck/comparison.js';\nimport {\n coalesceType,\n comprehensionType,\n conditionalType,\n listType,\n logicalType,\n notType,\n} from './typecheck/compound.js';\nimport type { CheckContext } from './typecheck/context.js';\nimport type { UndecidedFold } from './typecheck/fold.js';\nimport { gateFoldDetail, isGateFoldOperator } from './typecheck/gate-folds.js';\nimport { pathType } from './typecheck/paths.js';\nimport type { StaticType } from './typecheck/types.js';\nimport {\n arrayElementType,\n literalMoneyDomain,\n literalQuantityDomain,\n primitiveType,\n} from './typecheck/types.js';\n\n/**\n * Static typing of Expr v1, `spec/semantics/expr-v1.md` section 6 and the per-built-in\n * table.\n *\n * Every expression has exactly one type, resolved against the declarations it is compiled\n * for. A refusal names the offending segment with the expected and actual types, and a\n * misspelled identifier or path segment carries a bounded suggestion drawn from the\n * declarations in scope.\n *\n * This entry resolves declarations and walks the tree; the type algebra is `typecheck/types`,\n * paths `typecheck/paths`, the structural forms `typecheck/compound`, and each operator\n * family its own module under `typecheck/`.\n */\n\nexport type { StaticType } from './typecheck/types.js';\nexport type { UndecidedFold } from './typecheck/fold.js';\nexport { typeName } from './typecheck/types.js';\n\n/**\n * The declaration maps one compilation's checkers share.\n *\n * Keyed by the declaration object the compilation owns, so the index is built once and every\n * slot reads it. Nothing here is mutated after construction: a checker only reads these maps.\n */\ninterface CheckerIndex {\n readonly fields: ReadonlyMap<string, CompiledField>;\n /** Every declared array by its document-wide id, including one a record holds. */\n readonly arraysById: ReadonlyMap<string, CompiledField>;\n readonly contextRoots: ReadonlyMap<string, ContextRoot>;\n readonly datasets: ReadonlyMap<string, DatasetDeclaration>;\n}\n\nconst INDEX_BY_DECLARATIONS = new WeakMap<ExpressionDeclarations, CheckerIndex>();\n\nfunction checkerIndex(declarations: ExpressionDeclarations): CheckerIndex {\n const cached = INDEX_BY_DECLARATIONS.get(declarations);\n if (cached !== undefined) return cached;\n const fields = new Map((declarations.fields ?? []).map((field) => [field.fieldId, field]));\n const arraysById = new Map<string, CompiledField>();\n const indexArrays = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n if (member.primitive === 'array') arraysById.set(member.fieldId, member);\n indexArrays(member.fields ?? []);\n }\n };\n indexArrays(declarations.fields ?? []);\n const contextRoots = new Map(\n (declarations.context?.roots ?? []).map((root) => [root.path.replace(/^context\\./, ''), root]),\n );\n // The reserved roots are in scope for every schema, declared or not. A declaration of one is\n // refused at the document boundary, so no declared root can shadow the environment's value.\n for (const root of RESERVED_CONTEXT_ROOTS) {\n if (!contextRoots.has(root.path)) {\n contextRoots.set(root.path, { path: root.path, primitive: root.primitive });\n }\n }\n const datasets = new Map(\n (declarations.datasets ?? []).map((dataset) => [dataset.tableId, dataset]),\n );\n const index: CheckerIndex = { fields, arraysById, contextRoots, datasets };\n INDEX_BY_DECLARATIONS.set(declarations, index);\n return index;\n}\n\n/** The compiler's per-expression state: declarations, binders and source offsets. */\nclass Checker implements CheckContext {\n private readonly offsets: WeakMap<ExprNode, number>;\n private readonly powerOperators: WeakSet<ExprNode>;\n private readonly lengthProperties: WeakSet<ExprNode>;\n private readonly inlinedNodes: WeakSet<ExprNode> | undefined;\n readonly fields: ReadonlyMap<string, CompiledField>;\n readonly contextRoots: ReadonlyMap<string, ContextRoot>;\n readonly datasets: ReadonlyMap<string, DatasetDeclaration>;\n private scopedBindings: ReadonlyMap<string, StaticType> = new Map();\n /** Where a fold that is legal but undecided on an empty list is recorded. */\n private readonly onUndecidedFold: ((finding: UndecidedFold) => void) | undefined;\n /** Whether this build admits `matches`; a build that forbids regex refuses every call. */\n readonly allowRegex: boolean;\n /**\n * Whether this expression may read the gate fold. A document compiles its gate rules with\n * the fold in force; `compileExpr` has no gate host, so it passes false and the name is\n * refused rather than compiled into a call nothing can answer.\n */\n private readonly allowGateFolds: boolean;\n\n constructor(\n declarations: ExpressionDeclarations,\n offsets: WeakMap<ExprNode, number>,\n scope: ExpressionScope = {},\n powerOperators: WeakSet<ExprNode> = new WeakSet(),\n lengthProperties: WeakSet<ExprNode> = new WeakSet(),\n ) {\n this.offsets = offsets;\n this.powerOperators = powerOperators;\n this.lengthProperties = lengthProperties;\n this.inlinedNodes = scope.inlinedNodes;\n this.onUndecidedFold = scope.onUndecidedFold;\n this.allowRegex = scope.allowRegex ?? true;\n this.allowGateFolds = scope.allowGateFolds ?? true;\n // The four maps are derived from the compilation's one declaration object, so they are\n // built once per compilation rather than once per expression slot: a 500-field document\n // with 500 rules otherwise rebuilds every index 500 times.\n const index = checkerIndex(declarations);\n this.fields = index.fields;\n this.contextRoots = index.contextRoots;\n this.datasets = index.datasets;\n // An item-scoped expression reads its row through the same implicit binders a comprehension\n // offers, so they are already in scope when the expression is checked. Field ids are unique\n // across the document, and an option may belong to a row of an array a record holds.\n const itemFieldId = scope.itemFieldId;\n if (itemFieldId !== undefined) {\n const array = index.arraysById.get(itemFieldId);\n if (array === undefined) {\n throw new ExpressionCompileError(\n 'UNKNOWN_IDENTIFIER',\n 0,\n `an item-scoped expression addresses \\`${itemFieldId}\\`, which is not a declared array`,\n closestNames(itemFieldId, [...index.arraysById.keys()]),\n );\n }\n const element = arrayElementType(array);\n if (element === undefined) {\n throw new ExpressionCompileError(\n 'UNKNOWN_IDENTIFIER',\n 0,\n `an item-scoped expression addresses \\`${itemFieldId}\\`, which declares no item type`,\n );\n }\n const bindings = new Map<string, StaticType>();\n for (const name of ['$it', '$prev', '$next'] as const) bindings.set(name, element);\n bindings.set('$i', primitiveType('integer'));\n // `$row` is the owner's own row, stable across a nested comprehension: `$it` is rebound\n // by each iteration, so a body that iterates the row's own list would otherwise lose\n // the row it is deciding. A bare record member stays readable by its path.\n bindings.set('$row', element);\n this.scopedBindings = bindings;\n }\n }\n\n check(node: ExprNode): StaticType {\n switch (node.kind) {\n case 'literal':\n return primitiveType(\n node.domain,\n node.domain === 'money' ? literalMoneyDomain(node.value) : undefined,\n false,\n node.domain === 'quantity' ? literalQuantityDomain(node.value) : undefined,\n );\n case 'path':\n return pathType(this, node);\n case 'list':\n return listType(this, node);\n case 'and':\n case 'or':\n return logicalType(this, node);\n case 'not':\n return notType(this, node);\n case 'compare':\n return compareType(this, node);\n case 'if':\n return conditionalType(this, node);\n case 'coalesce':\n return coalesceType(this, node);\n case 'call': {\n // The type is checked first, so an ill-formed gate fold (a computed rule id, an\n // unknown arity) is refused for that cause, exactly as the document door refuses it\n // before its placement cross-check. Only then is the fold's home decided.\n const type = callType(this, node);\n if (!this.allowGateFolds && isGateFoldOperator(node.op)) {\n throw new ExpressionCompileError(\n 'RULE_REFERENCE',\n this.offsetOf(node),\n gateFoldDetail([node.op]),\n );\n }\n return type;\n }\n case 'comprehension':\n return comprehensionType(this, node);\n }\n }\n\n bindings(): ReadonlyMap<string, StaticType> {\n return this.scopedBindings;\n }\n\n replaceBindings(bindings: ReadonlyMap<string, StaticType>): void {\n this.scopedBindings = bindings;\n }\n\n mismatch(node: ExprNode, detail: string): ExpressionCompileError {\n return new ExpressionCompileError('TYPE_MISMATCH', this.offsetOf(node), detail);\n }\n\n offsetOf(node: ExprNode): number {\n return this.offsets.get(node) ?? 0;\n }\n\n isPowerOperator(node: ExprNode): boolean {\n return this.powerOperators.has(node);\n }\n\n isLengthProperty(node: ExprNode): boolean {\n return this.lengthProperties.has(node);\n }\n\n isInlinedNode(node: ExprNode): boolean {\n return this.inlinedNodes?.has(node) ?? false;\n }\n\n fieldAtPath(path: string): CompiledField | undefined {\n const segments = path.split('.');\n const [head, ...rest] = segments;\n if (head === undefined) return undefined;\n if (head.startsWith('$')) {\n // `$it`, `$prev` and `$next` are rebound by every comprehension, so a declaration reached\n // through them cannot be attributed to the list a fold reads. `$row` is stable, but its\n // members are declared inside an array row, where v1 refuses `minItems`\n // (`MODEL-2.1.17`): no declaration there can prove the list non-empty, so neither\n // resolves to one.\n return undefined;\n }\n // A context root declares an item domain but no cardinality, so it proves nothing here.\n if (head === 'context') return undefined;\n const first = this.fields.get(head);\n if (first === undefined) return undefined;\n let current = first;\n for (const segment of rest) {\n // A member reached through an array is declared inside a row, where v1 refuses\n // `minItems`; the declaration exists but cannot carry the proof the fold needs.\n if (current.primitive === 'array') return undefined;\n const member = memberOf(current, segment);\n if (member === undefined) return undefined;\n current = member;\n }\n return current;\n }\n\n reportUndecidedFold(finding: UndecidedFold): void {\n this.onUndecidedFold?.(finding);\n }\n}\n\n/** The implicit binders a rule's own scope puts in force, and where fold findings go. */\nexport interface ExpressionScope {\n /** The array an item-scoped expression addresses, whose item is `$it`. */\n readonly itemFieldId?: string;\n /**\n * Where a fold that is legal but undecided on an empty list is recorded, so a caller decides\n * whether the finding becomes a warning beside the artifact or is discarded with a refusal.\n */\n readonly onUndecidedFold?: (finding: UndecidedFold) => void;\n /**\n * Whether the build admits `matches`, defaulting to true. A caller that forbids regular\n * expressions in its documents sets this false, and every `matches` call is then refused at\n * compile time with a sentence naming the build rather than the pattern.\n */\n readonly allowRegex?: boolean;\n /**\n * Where a warning the static analysis proves is recorded. The compiler attaches the document\n * path, because the checker knows the expression's offsets and not where the slot lives.\n */\n readonly onLintFinding?: (finding: LintFinding) => void;\n /**\n * Whether this expression may read the gate fold (`rule_ok`, `no_blocking` and the step\n * folds). Defaults to true; the document compiler owns the gate rule that supplies the fold,\n * while `compileExpr` has no gate host and passes false.\n */\n readonly allowGateFolds?: boolean;\n /**\n * Nodes in the checked tree that originated from an inlined computed definition rather than\n * from the current expression slot, used to avoid re-reporting aggregate warnings that already\n * belong to the definition's own slot.\n */\n readonly inlinedNodes?: WeakSet<ExprNode>;\n}\n\n/** Type-checks a parsed expression against its declarations and the scope it runs in. */\nexport function checkExpression(\n declarations: ExpressionDeclarations,\n node: ExprNode,\n offsets: WeakMap<ExprNode, number>,\n scope: ExpressionScope = {},\n powerOperators: WeakSet<ExprNode> = new WeakSet(),\n lengthProperties: WeakSet<ExprNode> = new WeakSet(),\n): StaticType {\n const checker = new Checker(declarations, offsets, scope, powerOperators, lengthProperties);\n const type = checker.check(node);\n // The constant and bound analysis runs once after typing, so a refusal it raises is the same\n // diagnostic shape a type refusal is and a warning rides beside a document that still compiles.\n // A compiled form (no `onLintFinding` callback) skips the pass: the artifact is machine-made,\n // and a fixture may deliberately carry a literal the evaluator refuses at run time.\n if (scope.onLintFinding !== undefined) {\n for (const finding of analyseExpression(checker, node)) {\n scope.onLintFinding(finding);\n }\n }\n return type;\n}\n\n/**\n * The lint pass over the analysis tree, separate from the tree the author's slot emits.\n *\n * `compileExpressionSlot` types the emitted node, where the `in`-to-`contains` lowering must\n * land, and analyses the substituted copy, where a computed definition is visible. The copy\n * brings its own offsets map, so a finding inside it keeps the position of the path it reads\n * rather than collapsing to `0`.\n */\nexport function lintExpression(\n declarations: ExpressionDeclarations,\n node: ExprNode,\n offsets: WeakMap<ExprNode, number>,\n onFinding: (finding: LintFinding) => void,\n scope: ExpressionScope = {},\n): void {\n const checker = new Checker(declarations, offsets, scope);\n for (const finding of analyseExpression(checker, node)) onFinding(finding);\n}\n\n/**\n * Collects undecided-fold findings over the substituted analysis tree, where pure computed\n * definitions are visible (so a computed non-empty list literal proves a fold decided).\n *\n * Returns `undefined` when static typing fails on the substituted tree (for example, when a\n * compute rule widens an integer into a decimal field read by a decimal-only built-in, or when\n * the computed definition is itself ill-typed), allowing the caller to fall back to the findings\n * recorded on the emitted tree.\n */\nexport function undecidedFolds(\n declarations: ExpressionDeclarations,\n node: ExprNode,\n offsets: WeakMap<ExprNode, number>,\n scope: ExpressionScope = {},\n): readonly UndecidedFold[] | undefined {\n const findings: UndecidedFold[] = [];\n const checker = new Checker(declarations, offsets, {\n ...scope,\n onUndecidedFold: (finding) => findings.push(finding),\n });\n try {\n checker.check(node);\n return findings;\n } catch (error) {\n if (error instanceof ExpressionCompileError) return undefined;\n throw error;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { CompileWarning } from '../compile/warning.js';
2
+ import type { UndecidedFold } from './typecheck/fold.js';
3
+ /**
4
+ * The warnings one expression's undecided folds produce.
5
+ *
6
+ * The catalogue owns the code, severity and message key; this module owns only the sentence the
7
+ * author reads at the expression. Each sentence names the expression, the reason it decides
8
+ * nothing and the repair, in the words an author who does not read the specification can act on:
9
+ * no clause id, no AST vocabulary, and the concrete declaration (`minItems: 1` on the member)
10
+ * that proves the list non-empty.
11
+ */
12
+ export declare function undecidedWarnings(findings: readonly UndecidedFold[], path: string): readonly CompileWarning[];
13
+ //# sourceMappingURL=undecided.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undecided.d.ts","sourceRoot":"","sources":["../../src/expr/undecided.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,IAAI,EAAE,MAAM,GACX,SAAS,cAAc,EAAE,CAW3B"}
@@ -0,0 +1,58 @@
1
+ import { diagnosticDoc } from '@azx-pbc/axiom-runtime';
2
+ /**
3
+ * The warnings one expression's undecided folds produce.
4
+ *
5
+ * The catalogue owns the code, severity and message key; this module owns only the sentence the
6
+ * author reads at the expression. Each sentence names the expression, the reason it decides
7
+ * nothing and the repair, in the words an author who does not read the specification can act on:
8
+ * no clause id, no AST vocabulary, and the concrete declaration (`minItems: 1` on the member)
9
+ * that proves the list non-empty.
10
+ */
11
+ export function undecidedWarnings(findings, path) {
12
+ const messageKey = diagnosticDoc('UNDECIDED_AGGREGATE').messageKey;
13
+ return findings.map((finding) => ({
14
+ code: 'UNDECIDED_AGGREGATE',
15
+ path,
16
+ detail: foldDetail(finding),
17
+ messageKey,
18
+ suggestions: [],
19
+ offset: finding.offset,
20
+ offsetSource: 'expression',
21
+ }));
22
+ }
23
+ /** The folded list as prose: a declared path in code, anything else as "this list". */
24
+ function listPhrase(finding) {
25
+ return finding.list === undefined ? 'this list' : `\`${finding.list}\``;
26
+ }
27
+ /** The sentence one finding renders. */
28
+ function foldDetail(finding) {
29
+ const list = listPhrase(finding);
30
+ switch (finding.op) {
31
+ case 'sum': {
32
+ // Only a money or quantity list reaches here: a numeric empty list totals decimal `0`.
33
+ const unit = finding.domain === 'duration'
34
+ ? 'an empty list of durations names no unit to total'
35
+ : finding.domain === 'quantity'
36
+ ? 'an empty list of quantities names no unit to total'
37
+ : 'an empty list of money has no currency to total';
38
+ return finding.declaration !== undefined
39
+ ? `\`${finding.op}\` over ${list} is undecided when the list is empty, because ${unit}; declare \`minItems: 1\` on \`${finding.declaration}\` if a form with no rows is impossible`
40
+ : `\`${finding.op}\` over ${list} is undecided when the list is empty, because ${unit}; aggregate a declared list that states \`minItems: 1\` if a list with no rows is impossible`;
41
+ }
42
+ case 'min':
43
+ case 'max':
44
+ return finding.declaration !== undefined
45
+ ? `\`${finding.op}\` over ${list} is undecided when the list is empty, so a form with no rows would silently decide nothing; declare \`minItems: 1\` on \`${finding.declaration}\` if this list is never empty`
46
+ : `\`${finding.op}\` over ${list} is undecided when the list is empty, so a form with no rows would silently decide nothing; aggregate a declared list that states \`minItems: 1\` if this list is never empty`;
47
+ case 'avg':
48
+ case 'median': {
49
+ const reason = finding.op === 'avg'
50
+ ? 'an empty list has no count to divide by'
51
+ : 'an empty list has no element to choose';
52
+ return finding.declaration !== undefined
53
+ ? `\`${finding.op}\` over ${list} is undecided when the list is empty, because ${reason}; declare \`minItems: 1\` on \`${finding.declaration}\` if a form with no rows is impossible`
54
+ : `\`${finding.op}\` over ${list} is undecided when the list is empty, because ${reason}; aggregate a declared list that states \`minItems: 1\` if a list with no rows is impossible`;
55
+ }
56
+ }
57
+ }
58
+ //# sourceMappingURL=undecided.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undecided.js","sourceRoot":"","sources":["../../src/expr/undecided.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAkC,EAClC,IAAY;IAEZ,MAAM,UAAU,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,UAAU,CAAC;IACnE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,qBAAqB;QAC3B,IAAI;QACJ,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C;QACX,KAAK,QAAQ,EAAE,CAAC;YACd,MAAM,MAAM,GACV,OAAO,CAAC,EAAE,KAAK,KAAK;gBAClB,CAAC,CAAC,yCAAyC;gBAC3C,CAAC,CAAC,wCAAwC,CAAC;YAC/C,OAAO,OAAO,CAAC,WAAW,KAAK,SAAS;gBACtC,CAAC,CAAC,KAAK,OAAO,CAAC,EAAE,WAAW,IAAI,iDAAiD,MAAM,kCAAkC,OAAO,CAAC,WAAW,yCAAyC;gBACrL,CAAC,CAAC,KAAK,OAAO,CAAC,EAAE,WAAW,IAAI,iDAAiD,MAAM,8FAA8F,CAAC;QAC1L,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { diagnosticDoc } from '@azx-pbc/axiom-runtime';\nimport type { CompileWarning } from '../compile/warning.js';\nimport type { UndecidedFold } from './typecheck/fold.js';\n\n/**\n * The warnings one expression's undecided folds produce.\n *\n * The catalogue owns the code, severity and message key; this module owns only the sentence the\n * author reads at the expression. Each sentence names the expression, the reason it decides\n * nothing and the repair, in the words an author who does not read the specification can act on:\n * no clause id, no AST vocabulary, and the concrete declaration (`minItems: 1` on the member)\n * that proves the list non-empty.\n */\nexport function undecidedWarnings(\n findings: readonly UndecidedFold[],\n path: string,\n): readonly CompileWarning[] {\n const messageKey = diagnosticDoc('UNDECIDED_AGGREGATE').messageKey;\n return findings.map((finding) => ({\n code: 'UNDECIDED_AGGREGATE',\n path,\n detail: foldDetail(finding),\n messageKey,\n suggestions: [],\n offset: finding.offset,\n offsetSource: 'expression',\n }));\n}\n\n/** The folded list as prose: a declared path in code, anything else as \"this list\". */\nfunction listPhrase(finding: UndecidedFold): string {\n return finding.list === undefined ? 'this list' : `\\`${finding.list}\\``;\n}\n\n/** The sentence one finding renders. */\nfunction foldDetail(finding: UndecidedFold): string {\n const list = listPhrase(finding);\n switch (finding.op) {\n case 'sum': {\n // Only a money or quantity list reaches here: a numeric empty list totals decimal `0`.\n const unit =\n finding.domain === 'duration'\n ? 'an empty list of durations names no unit to total'\n : finding.domain === 'quantity'\n ? 'an empty list of quantities names no unit to total'\n : 'an empty list of money has no currency to total';\n return finding.declaration !== undefined\n ? `\\`${finding.op}\\` over ${list} is undecided when the list is empty, because ${unit}; declare \\`minItems: 1\\` on \\`${finding.declaration}\\` if a form with no rows is impossible`\n : `\\`${finding.op}\\` over ${list} is undecided when the list is empty, because ${unit}; aggregate a declared list that states \\`minItems: 1\\` if a list with no rows is impossible`;\n }\n case 'min':\n case 'max':\n return finding.declaration !== undefined\n ? `\\`${finding.op}\\` over ${list} is undecided when the list is empty, so a form with no rows would silently decide nothing; declare \\`minItems: 1\\` on \\`${finding.declaration}\\` if this list is never empty`\n : `\\`${finding.op}\\` over ${list} is undecided when the list is empty, so a form with no rows would silently decide nothing; aggregate a declared list that states \\`minItems: 1\\` if this list is never empty`;\n case 'avg':\n case 'median': {\n const reason =\n finding.op === 'avg'\n ? 'an empty list has no count to divide by'\n : 'an empty list has no element to choose';\n return finding.declaration !== undefined\n ? `\\`${finding.op}\\` over ${list} is undecided when the list is empty, because ${reason}; declare \\`minItems: 1\\` on \\`${finding.declaration}\\` if a form with no rows is impossible`\n : `\\`${finding.op}\\` over ${list} is undecided when the list is empty, because ${reason}; aggregate a declared list that states \\`minItems: 1\\` if a list with no rows is impossible`;\n }\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * String distances the language defines in Unicode code points.
3
+ *
4
+ * Expr v1 `len` counts code points, and `index_of`, `substring` and `slice` address the same
5
+ * unit. A UTF-16 `length` would count an astral character twice, and a grapheme segmenter would
6
+ * count a combining sequence once, so both disagree with the evaluator this analysis predicts.
7
+ * `Array.from` is the deliberate spelling: it iterates code points, and the named helper keeps
8
+ * that fact visible at every caller instead of hiding it behind an operator.
9
+ */
10
+ export declare function codePointLength(text: string): number;
11
+ /** The code-point index of `find` in `text`, or `-1` when it does not occur. */
12
+ export declare function codePointIndexOf(text: string, find: string): number;
13
+ //# sourceMappingURL=code-points.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-points.d.ts","sourceRoot":"","sources":["../../../src/expr/values/code-points.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * String distances the language defines in Unicode code points.
3
+ *
4
+ * Expr v1 `len` counts code points, and `index_of`, `substring` and `slice` address the same
5
+ * unit. A UTF-16 `length` would count an astral character twice, and a grapheme segmenter would
6
+ * count a combining sequence once, so both disagree with the evaluator this analysis predicts.
7
+ * `Array.from` is the deliberate spelling: it iterates code points, and the named helper keeps
8
+ * that fact visible at every caller instead of hiding it behind an operator.
9
+ */
10
+ export function codePointLength(text) {
11
+ return Array.from(text).length;
12
+ }
13
+ /** The code-point index of `find` in `text`, or `-1` when it does not occur. */
14
+ export function codePointIndexOf(text, find) {
15
+ const subject = Array.from(text);
16
+ const needle = Array.from(find);
17
+ if (needle.length === 0)
18
+ return 0;
19
+ for (let index = 0; index + needle.length <= subject.length; index += 1) {
20
+ if (needle.every((point, offset) => subject[index + offset] === point))
21
+ return index;
22
+ }
23
+ return -1;
24
+ }
25
+ //# sourceMappingURL=code-points.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-points.js","sourceRoot":"","sources":["../../../src/expr/values/code-points.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACjC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,IAAY;IACzD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACxE,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IACvF,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC","sourcesContent":["/**\n * String distances the language defines in Unicode code points.\n *\n * Expr v1 `len` counts code points, and `index_of`, `substring` and `slice` address the same\n * unit. A UTF-16 `length` would count an astral character twice, and a grapheme segmenter would\n * count a combining sequence once, so both disagree with the evaluator this analysis predicts.\n * `Array.from` is the deliberate spelling: it iterates code points, and the named helper keeps\n * that fact visible at every caller instead of hiding it behind an operator.\n */\nexport function codePointLength(text: string): number {\n return Array.from(text).length;\n}\n\n/** The code-point index of `find` in `text`, or `-1` when it does not occur. */\nexport function codePointIndexOf(text: string, find: string): number {\n const subject = Array.from(text);\n const needle = Array.from(find);\n if (needle.length === 0) return 0;\n for (let index = 0; index + needle.length <= subject.length; index += 1) {\n if (needle.every((point, offset) => subject[index + offset] === point)) return index;\n }\n return -1;\n}\n"]}
@@ -0,0 +1,77 @@
1
+ import type { ExprNode } from '@azx-pbc/axiom-runtime';
2
+ /**
3
+ * Capture-avoiding substitution of a pure computed field at its read site.
4
+ *
5
+ * A compute rule has one declared target and one expression. When that expression has no side
6
+ * condition — no `if`, no dataset, no host fact — the rule is a definition, and a reader can
7
+ * be analysed against the definition itself rather than against the field's declared type.
8
+ * The substitution is bounded to three nested definitions and guards against cycles; a field
9
+ * with more than one writer, a host fact, or a fourth definition is left as a read and the
10
+ * caller can state why in a diagnostic detail.
11
+ */
12
+ /** One field a definition writes, when that field has exactly one pure `compute` writer. */
13
+ interface PureComputedDefinition {
14
+ readonly fieldId: string;
15
+ /** Where the definition was written, as `$.rules[7].expr`. */
16
+ readonly path: string;
17
+ /** The rule id, so a detail can name both the path and the author's handle. */
18
+ readonly ruleId: string;
19
+ readonly expr: ExprNode;
20
+ }
21
+ /** What the document says about one computed field, whether it can be inlined or not. */
22
+ export type ComputedStatus = {
23
+ readonly kind: 'pure';
24
+ readonly definition: PureComputedDefinition;
25
+ } | {
26
+ readonly kind: 'multiple';
27
+ readonly fieldId: string;
28
+ readonly paths: readonly string[];
29
+ } | {
30
+ readonly kind: 'impure';
31
+ readonly fieldId: string;
32
+ readonly path: string;
33
+ readonly ruleId: string;
34
+ readonly reason: string;
35
+ } | {
36
+ readonly kind: 'unparsed';
37
+ readonly fieldId: string;
38
+ readonly path: string;
39
+ readonly ruleId: string;
40
+ readonly reason: string;
41
+ };
42
+ export interface ComputedFieldIndex {
43
+ readonly definitions: ReadonlyMap<string, ComputedStatus>;
44
+ }
45
+ interface InlineUse {
46
+ readonly fieldId: string;
47
+ readonly path: string;
48
+ readonly ruleId: string;
49
+ }
50
+ export interface InlineResult {
51
+ readonly node: ExprNode;
52
+ readonly uses: readonly InlineUse[];
53
+ readonly notes: readonly string[];
54
+ /**
55
+ * The source offsets of `node`, when the caller supplied the parsed slot's offsets: a rebuilt
56
+ * node keeps the offset of the node it replaced, and a substituted definition's nodes are
57
+ * attributed to the read site that pulled them in. Without this the analysis tree would be
58
+ * absent from the parser's identity map and every finding would collapse to offset `0`.
59
+ */
60
+ readonly offsets?: WeakMap<ExprNode, number>;
61
+ /**
62
+ * Every node in `node` that came from an inlined computed definition rather than from the
63
+ * current expression slot. Downstream checks use this to skip warnings that already belong to
64
+ * the definition's own rule slot.
65
+ */
66
+ readonly inlinedNodes?: WeakSet<ExprNode>;
67
+ }
68
+ /**
69
+ * Inline pure computed definitions in one expression, up to three levels deep.
70
+ *
71
+ * When the caller supplies the parsed slot's offsets, the result carries offsets for the
72
+ * substituted tree: a rebuilt node keeps the offset of the node it replaced, so a refusal or a
73
+ * warning keeps the author's locus instead of collapsing to `0`.
74
+ */
75
+ export declare function inlineExpression(node: ExprNode, index: ComputedFieldIndex | undefined, offsets?: WeakMap<ExprNode, number>): InlineResult;
76
+ export {};
77
+ //# sourceMappingURL=inline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../../src/expr/values/inline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;;;;;;;;GASG;AAEH,4FAA4F;AAC5F,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAED,yFAAyF;AACzF,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAA;CAAE,GACtE;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IACE,QAAQ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