@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,188 @@
1
+ import { canonicalFlags, compilePattern, compileRegex, unsafePattern, } from '@azx-pbc/axiom-runtime';
2
+ import { ExpressionCompileError } from '../diagnostics.js';
3
+ import { isPrimitive, primitiveType, typeName } from './types.js';
4
+ /** The primitives `to_string` renders: every scalar, money included, but never a record or list. */
5
+ const TEXT_RENDERABLE = new Set([
6
+ 'string',
7
+ 'integer',
8
+ 'decimal',
9
+ 'boolean',
10
+ 'date',
11
+ 'instant',
12
+ 'money',
13
+ ]);
14
+ export function stringType(ctx, op, node, operands) {
15
+ switch (op) {
16
+ case 'len':
17
+ if (operands.typeAt(0).kind === 'list')
18
+ return primitiveType('integer');
19
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string or list');
20
+ return primitiveType('integer');
21
+ case 'lower':
22
+ case 'upper':
23
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
24
+ return primitiveType('string');
25
+ case 'trim':
26
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
27
+ return primitiveType('string');
28
+ case 'is_email':
29
+ case 'is_phone':
30
+ case 'is_url':
31
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
32
+ return primitiveType('boolean');
33
+ case 'empty':
34
+ // Any operand: a path answers from presence, which is the only way absence is
35
+ // observable, and any other expression from its value. The operand
36
+ // is still typed, so an unknown name or a misspelt member is refused here.
37
+ return primitiveType('boolean');
38
+ case 'to_string':
39
+ operands.requireType(0, (type) => type.kind === 'primitive' && TEXT_RENDERABLE.has(type.primitive), 'a string, number, boolean, date, instant or money');
40
+ return primitiveType('string');
41
+ case 'parse_integer':
42
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
43
+ // `string -> integer | null`: text that spells no canonical integer is the empty value,
44
+ // not a zero (`EXPR-7.2.9`, `EXPR-6.1.12`).
45
+ return primitiveType('integer', undefined, true);
46
+ case 'parse_decimal':
47
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
48
+ return primitiveType('decimal', undefined, true);
49
+ case 'starts_with':
50
+ case 'ends_with':
51
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
52
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
53
+ return primitiveType('boolean');
54
+ case 'contains':
55
+ // Substring test only. List membership is spelled `x in xs`, which names the value
56
+ // first; a second spelling with the operands reversed was a trap, not a convenience.
57
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
58
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
59
+ return primitiveType('boolean');
60
+ case 'ascii_match': {
61
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
62
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
63
+ const pattern = operands.nodeAt(1);
64
+ // A literal pattern is inside the compiler's reach, so an unsupported construct is
65
+ // refused here; a computed pattern is checked at evaluation.
66
+ if (pattern.kind === 'literal' && typeof pattern.value === 'string') {
67
+ try {
68
+ compilePattern(pattern.value);
69
+ }
70
+ catch (error) {
71
+ const cause = error instanceof Error ? error.message : 'the pattern is outside the subset';
72
+ throw new ExpressionCompileError('PATTERN_UNSUPPORTED', ctx.offsetOf(pattern), `${cause}; rewrite the pattern inside the supported ASCII subset`);
73
+ }
74
+ }
75
+ return primitiveType('boolean');
76
+ }
77
+ case 'replace': {
78
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
79
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
80
+ operands.requireType(2, (type) => isPrimitive(type, 'string'), 'a string');
81
+ // An empty needle has no occurrence to replace: every position would match, including
82
+ // the end, so the result would be an insertion at every character boundary rather than a
83
+ // replacement. It is refused where it is written, and at evaluation when computed.
84
+ const find = operands.nodeAt(1);
85
+ if (find.kind === 'literal' && find.value === '') {
86
+ throw ctx.mismatch(find, '`replace` requires a non-empty find operand; an empty one would insert the replacement at every character boundary');
87
+ }
88
+ return primitiveType('string');
89
+ }
90
+ case 'split': {
91
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
92
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
93
+ const separator = operands.nodeAt(1);
94
+ if (separator.kind === 'literal' && separator.value === '') {
95
+ throw ctx.mismatch(separator, '`split` requires a non-empty separator operand');
96
+ }
97
+ return { kind: 'list', element: primitiveType('string'), open: false };
98
+ }
99
+ case 'join': {
100
+ const list = operands.requireList(0);
101
+ const element = list.element;
102
+ if (element === undefined && list.open) {
103
+ throw ctx.mismatch(operands.nodeAt(0), '`join` requires a list of text, and this list declares no element type');
104
+ }
105
+ if (element !== undefined && !isPrimitive(element, 'string')) {
106
+ throw ctx.mismatch(operands.nodeAt(0), '`join` requires a list of text');
107
+ }
108
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
109
+ return primitiveType('string');
110
+ }
111
+ case 'substring': {
112
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
113
+ operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer start');
114
+ operands.requireType(2, (type) => isPrimitive(type, 'integer'), 'an integer length');
115
+ // A negative start or length has no reading the clamp rule covers: the window would begin
116
+ // before the text, and the repair is to start at zero and take the absolute length.
117
+ const start = operands.nodeAt(1);
118
+ if (start.kind === 'literal' && typeof start.value === 'number' && start.value < 0) {
119
+ throw ctx.mismatch(start, '`substring` requires a non-negative start; count from 0, because a negative start has no meaning here');
120
+ }
121
+ const length = operands.nodeAt(2);
122
+ if (length.kind === 'literal' && typeof length.value === 'number' && length.value < 0) {
123
+ throw ctx.mismatch(length, '`substring` requires a non-negative length');
124
+ }
125
+ return primitiveType('string');
126
+ }
127
+ case 'index_of':
128
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
129
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');
130
+ return primitiveType('integer');
131
+ case 'concat': {
132
+ // Variadic by signature (`EXPR-14.1.15`): `requireArity` has already held the call to
133
+ // 2..32 operands, so this walks exactly the operands the signature admits. The message
134
+ // names the position because a variadic call has no other way to point at one operand.
135
+ for (let index = 0; index < node.args.length; index += 1) {
136
+ const type = operands.typeAt(index);
137
+ if (!isPrimitive(type, 'string')) {
138
+ throw ctx.mismatch(operands.nodeAt(index), `\`concat\` argument ${String(index + 1)} requires a text operand, got ${typeName(type)}`);
139
+ }
140
+ }
141
+ return primitiveType('string');
142
+ }
143
+ case 'matches': {
144
+ if (!ctx.allowRegex) {
145
+ throw new ExpressionCompileError('PATTERN_UNSUPPORTED', ctx.offsetOf(node), 'this build disables pattern matching, so `matches` is not available; compile the document with `allowRegex: true` (the default), or test the text with `starts_with`, `ends_with` or `contains`');
146
+ }
147
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
148
+ operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string pattern');
149
+ const pattern = operands.nodeAt(1);
150
+ const flagsNode = node.args[2];
151
+ let flags;
152
+ if (flagsNode !== undefined) {
153
+ operands.requireType(2, (type) => isPrimitive(type, 'string'), 'a string of flags');
154
+ if (flagsNode.kind !== 'literal') {
155
+ // The flags decide how the pattern is compiled, so they are part of the pattern's
156
+ // identity and must be known before evaluation; a computed flag set is not a
157
+ // vocabulary the language admits.
158
+ throw ctx.mismatch(flagsNode, '`matches` flags must be a literal string, such as "i"');
159
+ }
160
+ flags = typeof flagsNode.value === 'string' ? flagsNode.value : '';
161
+ refuseReason(ctx, flagsNode, canonicalFlags(flags));
162
+ }
163
+ if (pattern.kind === 'literal' && typeof pattern.value === 'string') {
164
+ // The literal pattern is the one the compiler can prove safe and well-formed, so both
165
+ // refusals happen here rather than at a reader's runtime (`EXPR-14.1.13`).
166
+ const unsafe = unsafePattern(pattern.value, flags);
167
+ if (unsafe !== undefined) {
168
+ throw ctx.mismatch(pattern, `\`matches\` refuses this pattern: ${unsafe}`);
169
+ }
170
+ const canonical = canonicalFlags(flags ?? '');
171
+ if (canonical.kind === 'ok') {
172
+ const compiled = compileRegex(pattern.value, canonical.flags);
173
+ if (compiled.kind === 'invalid-pattern') {
174
+ throw ctx.mismatch(pattern, `\`matches\` pattern is not a valid regular expression: ${compiled.detail}`);
175
+ }
176
+ }
177
+ }
178
+ return primitiveType('boolean');
179
+ }
180
+ }
181
+ }
182
+ /** Raises the flag refusal at the flags operand, when the flag string is outside the subset. */
183
+ function refuseReason(ctx, node, canonical) {
184
+ if (canonical.kind === 'ok')
185
+ return;
186
+ throw ctx.mismatch(node, `\`matches\` ${canonical.detail}`);
187
+ }
188
+ //# sourceMappingURL=strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../src/expr/typecheck/strings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA2BlE,oGAAoG;AACpG,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IACnD,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,UAAU,UAAU,CACxB,GAAiB,EACjB,EAAkB,EAClB,IAAc,EACd,QAAkB;IAElB,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,KAAK;YACR,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM;gBAAE,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;YACxE,QAAQ,CAAC,WAAW,CAAC,C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AAC,CAAC;YACtD,CAAC;YACD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACpE,sFAAsF;gBACtF,2EAA2E;gBAC3E,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBACnD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBACzB,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,qCAAqC,MAAM,EAAE,CAAC,CAAC;gBAC7E,CAAC;gBACD,MAAM,SAAS,GAAG,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC9C,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC5B,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;oBAC9D,IAAI,QAAQ,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;wBACxC,MAAM,GAAG,CAAC,QAAQ,CAChB,OAAO,EACP,0DAA0D,QAAQ,CAAC,MAAM,EAAE,CAC5E,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC;AAED,gGAAgG;AAChG,SAAS,YAAY,CACnB,GAAiB,EACjB,IAAc,EACd,SAA4C;IAE5C,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO;IACpC,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import {\n canonicalFlags,\n compilePattern,\n compileRegex,\n unsafePattern,\n} from '@azx-pbc/axiom-runtime';\nimport type { CallNode, ExprNode } from '@azx-pbc/axiom-runtime';\nimport { ExpressionCompileError } from '../diagnostics.js';\nimport type { CheckContext } from './context.js';\nimport type { Operands } from './operands.js';\nimport type { StaticType } from './types.js';\nimport { isPrimitive, primitiveType, typeName } from './types.js';\n\n/** The string, text-rendering and pattern built-ins. */\nexport type StringOperator =\n | 'len'\n | 'lower'\n | 'upper'\n | 'trim'\n | 'is_email'\n | 'is_phone'\n | 'is_url'\n | 'empty'\n | 'to_string'\n | 'parse_integer'\n | 'parse_decimal'\n | 'starts_with'\n | 'ends_with'\n | 'contains'\n | 'ascii_match'\n | 'replace'\n | 'split'\n | 'join'\n | 'substring'\n | 'index_of'\n | 'matches'\n | 'concat';\n\n/** The primitives `to_string` renders: every scalar, money included, but never a record or list. */\nconst TEXT_RENDERABLE: ReadonlySet<string> = new Set([\n 'string',\n 'integer',\n 'decimal',\n 'boolean',\n 'date',\n 'instant',\n 'money',\n]);\n\nexport function stringType(\n ctx: CheckContext,\n op: StringOperator,\n node: CallNode,\n operands: Operands,\n): StaticType {\n switch (op) {\n case 'len':\n if (operands.typeAt(0).kind === 'list') return primitiveType('integer');\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string or list');\n return primitiveType('integer');\n case 'lower':\n case 'upper':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('string');\n case 'trim':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('string');\n case 'is_email':\n case 'is_phone':\n case 'is_url':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('boolean');\n case 'empty':\n // Any operand: a path answers from presence, which is the only way absence is\n // observable, and any other expression from its value. The operand\n // is still typed, so an unknown name or a misspelt member is refused here.\n return primitiveType('boolean');\n case 'to_string':\n operands.requireType(\n 0,\n (type) => type.kind === 'primitive' && TEXT_RENDERABLE.has(type.primitive),\n 'a string, number, boolean, date, instant or money',\n );\n return primitiveType('string');\n case 'parse_integer':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n // `string -> integer | null`: text that spells no canonical integer is the empty value,\n // not a zero (`EXPR-7.2.9`, `EXPR-6.1.12`).\n return primitiveType('integer', undefined, true);\n case 'parse_decimal':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('decimal', undefined, true);\n case 'starts_with':\n case 'ends_with':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('boolean');\n case 'contains':\n // Substring test only. List membership is spelled `x in xs`, which names the value\n // first; a second spelling with the operands reversed was a trap, not a convenience.\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('boolean');\n case 'ascii_match': {\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n const pattern = operands.nodeAt(1);\n // A literal pattern is inside the compiler's reach, so an unsupported construct is\n // refused here; a computed pattern is checked at evaluation.\n if (pattern.kind === 'literal' && typeof pattern.value === 'string') {\n try {\n compilePattern(pattern.value);\n } catch (error) {\n const cause =\n error instanceof Error ? error.message : 'the pattern is outside the subset';\n throw new ExpressionCompileError(\n 'PATTERN_UNSUPPORTED',\n ctx.offsetOf(pattern),\n `${cause}; rewrite the pattern inside the supported ASCII subset`,\n );\n }\n }\n return primitiveType('boolean');\n }\n case 'replace': {\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(2, (type) => isPrimitive(type, 'string'), 'a string');\n // An empty needle has no occurrence to replace: every position would match, including\n // the end, so the result would be an insertion at every character boundary rather than a\n // replacement. It is refused where it is written, and at evaluation when computed.\n const find = operands.nodeAt(1);\n if (find.kind === 'literal' && find.value === '') {\n throw ctx.mismatch(\n find,\n '`replace` requires a non-empty find operand; an empty one would insert the replacement at every character boundary',\n );\n }\n return primitiveType('string');\n }\n case 'split': {\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n const separator = operands.nodeAt(1);\n if (separator.kind === 'literal' && separator.value === '') {\n throw ctx.mismatch(separator, '`split` requires a non-empty separator operand');\n }\n return { kind: 'list', element: primitiveType('string'), open: false };\n }\n case 'join': {\n const list = operands.requireList(0);\n const element = list.element;\n if (element === undefined && list.open) {\n throw ctx.mismatch(\n operands.nodeAt(0),\n '`join` requires a list of text, and this list declares no element type',\n );\n }\n if (element !== undefined && !isPrimitive(element, 'string')) {\n throw ctx.mismatch(operands.nodeAt(0), '`join` requires a list of text');\n }\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('string');\n }\n case 'substring': {\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer start');\n operands.requireType(2, (type) => isPrimitive(type, 'integer'), 'an integer length');\n // A negative start or length has no reading the clamp rule covers: the window would begin\n // before the text, and the repair is to start at zero and take the absolute length.\n const start = operands.nodeAt(1);\n if (start.kind === 'literal' && typeof start.value === 'number' && start.value < 0) {\n throw ctx.mismatch(\n start,\n '`substring` requires a non-negative start; count from 0, because a negative start has no meaning here',\n );\n }\n const length = operands.nodeAt(2);\n if (length.kind === 'literal' && typeof length.value === 'number' && length.value < 0) {\n throw ctx.mismatch(length, '`substring` requires a non-negative length');\n }\n return primitiveType('string');\n }\n case 'index_of':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('integer');\n case 'concat': {\n // Variadic by signature (`EXPR-14.1.15`): `requireArity` has already held the call to\n // 2..32 operands, so this walks exactly the operands the signature admits. The message\n // names the position because a variadic call has no other way to point at one operand.\n for (let index = 0; index < node.args.length; index += 1) {\n const type = operands.typeAt(index);\n if (!isPrimitive(type, 'string')) {\n throw ctx.mismatch(\n operands.nodeAt(index),\n `\\`concat\\` argument ${String(index + 1)} requires a text operand, got ${typeName(type)}`,\n );\n }\n }\n return primitiveType('string');\n }\n case 'matches': {\n if (!ctx.allowRegex) {\n throw new ExpressionCompileError(\n 'PATTERN_UNSUPPORTED',\n ctx.offsetOf(node),\n 'this build disables pattern matching, so `matches` is not available; compile the document with `allowRegex: true` (the default), or test the text with `starts_with`, `ends_with` or `contains`',\n );\n }\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n operands.requireType(1, (type) => isPrimitive(type, 'string'), 'a string pattern');\n const pattern = operands.nodeAt(1);\n const flagsNode = node.args[2];\n let flags: string | undefined;\n if (flagsNode !== undefined) {\n operands.requireType(2, (type) => isPrimitive(type, 'string'), 'a string of flags');\n if (flagsNode.kind !== 'literal') {\n // The flags decide how the pattern is compiled, so they are part of the pattern's\n // identity and must be known before evaluation; a computed flag set is not a\n // vocabulary the language admits.\n throw ctx.mismatch(flagsNode, '`matches` flags must be a literal string, such as \"i\"');\n }\n flags = typeof flagsNode.value === 'string' ? flagsNode.value : '';\n refuseReason(ctx, flagsNode, canonicalFlags(flags));\n }\n if (pattern.kind === 'literal' && typeof pattern.value === 'string') {\n // The literal pattern is the one the compiler can prove safe and well-formed, so both\n // refusals happen here rather than at a reader's runtime (`EXPR-14.1.13`).\n const unsafe = unsafePattern(pattern.value, flags);\n if (unsafe !== undefined) {\n throw ctx.mismatch(pattern, `\\`matches\\` refuses this pattern: ${unsafe}`);\n }\n const canonical = canonicalFlags(flags ?? '');\n if (canonical.kind === 'ok') {\n const compiled = compileRegex(pattern.value, canonical.flags);\n if (compiled.kind === 'invalid-pattern') {\n throw ctx.mismatch(\n pattern,\n `\\`matches\\` pattern is not a valid regular expression: ${compiled.detail}`,\n );\n }\n }\n }\n return primitiveType('boolean');\n }\n }\n}\n\n/** Raises the flag refusal at the flags operand, when the flag string is outside the subset. */\nfunction refuseReason(\n ctx: CheckContext,\n node: ExprNode,\n canonical: ReturnType<typeof canonicalFlags>,\n): void {\n if (canonical.kind === 'ok') return;\n throw ctx.mismatch(node, `\\`matches\\` ${canonical.detail}`);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { CheckContext } from './context.js';
2
+ import type { Operands } from './operands.js';
3
+ import type { StaticType } from './types.js';
4
+ /** Date, instant, time and duration arithmetic, `MODEL-2.1.23` and `MODEL-2.1.24`. */
5
+ export type TemporalOperator = 'add_days' | 'add_months' | 'add_minutes' | 'add_years' | 'days_between' | 'months_between' | 'minutes_between' | 'start_of_day' | 'civil_date' | 'duration_minutes' | 'duration_seconds' | 'year' | 'month' | 'day' | 'weekday' | 'parse_date' | 'parse_instant';
6
+ export declare function temporalType(ctx: CheckContext, op: TemporalOperator, operands: Operands): StaticType;
7
+ //# sourceMappingURL=temporal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../../src/expr/typecheck/temporal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,YAAY,GACZ,aAAa,GACb,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,YAAY,GACZ,kBAAkB,GAClB,kBAAkB,GAClB,MAAM,GACN,OAAO,GACP,KAAK,GACL,SAAS,GACT,YAAY,GACZ,eAAe,CAAC;AAEpB,wBAAgB,YAAY,CAC1B,GAAG,EAAE,YAAY,EACjB,EAAE,EAAE,gBAAgB,EACpB,QAAQ,EAAE,QAAQ,GACjB,UAAU,CAgFZ"}
@@ -0,0 +1,80 @@
1
+ import { durationDomainOf, durationUnitName, isPrimitive, primitiveType, unifyDuration, } from './types.js';
2
+ export function temporalType(ctx, op, operands) {
3
+ switch (op) {
4
+ case 'add_days':
5
+ case 'add_months':
6
+ case 'add_years':
7
+ operands.requireType(0, (type) => isPrimitive(type, 'date'), 'a date');
8
+ operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer');
9
+ return primitiveType('date');
10
+ case 'days_between':
11
+ case 'months_between':
12
+ operands.requireType(0, (type) => isPrimitive(type, 'date'), 'a date');
13
+ operands.requireType(1, (type) => isPrimitive(type, 'date'), 'a date');
14
+ return primitiveType('integer');
15
+ case 'add_minutes': {
16
+ // A clock time wraps inside its day; an instant advances into the next one. The first
17
+ // operand chooses the family, and the second is an integer in both.
18
+ const first = operands.typeAt(0);
19
+ if (isPrimitive(first, 'time')) {
20
+ operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer');
21
+ return primitiveType('time');
22
+ }
23
+ operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');
24
+ operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer');
25
+ return primitiveType('instant');
26
+ }
27
+ case 'minutes_between': {
28
+ const first = operands.typeAt(0);
29
+ if (isPrimitive(first, 'time')) {
30
+ operands.requireType(1, (type) => isPrimitive(type, 'time'), 'a time');
31
+ return primitiveType('integer');
32
+ }
33
+ if (isPrimitive(first, 'duration')) {
34
+ operands.requireType(1, (type) => isPrimitive(type, 'duration'), 'a duration');
35
+ const left = durationDomainOf(first);
36
+ const right = durationDomainOf(operands.typeAt(1));
37
+ if (left !== undefined && right !== undefined && unifyDuration(left, right) === undefined) {
38
+ throw ctx.mismatch(operands.nodeAt(1), `\`minutes_between\` compares one duration unit, got ${durationUnitName(left)} and ${durationUnitName(right)}; v1 defines no unit conversion`);
39
+ }
40
+ return primitiveType('integer');
41
+ }
42
+ operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');
43
+ operands.requireType(1, (type) => isPrimitive(type, 'instant'), 'an instant');
44
+ return primitiveType('integer');
45
+ }
46
+ case 'year':
47
+ case 'month':
48
+ case 'day':
49
+ case 'weekday':
50
+ // A date component is stated over `date` only: an instant carries a UTC clock, and
51
+ // deriving its civil date is the timezone rule the language deliberately does not
52
+ // own. `year(civil_date(t))` is the explicit spelling.
53
+ operands.requireType(0, (type) => isPrimitive(type, 'date'), 'a date');
54
+ return primitiveType('integer');
55
+ case 'parse_date':
56
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
57
+ // `string -> date | null`: text outside the domain is the empty value, not an error
58
+ // (`EXPR-6.1.12`), and `2026-02-30` is outside the domain.
59
+ return primitiveType('date', undefined, true);
60
+ case 'parse_instant':
61
+ operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');
62
+ return primitiveType('instant', undefined, true);
63
+ case 'duration_minutes':
64
+ case 'duration_seconds':
65
+ operands.requireType(0, (type) => isPrimitive(type, 'duration'), `a duration for \`${op}\``);
66
+ return primitiveType('integer');
67
+ case 'start_of_day':
68
+ // `start_of_day(d: date)` is the identity, so it is not a built-in: the date itself is
69
+ // the answer, and a second spelling would suggest a boundary that does not exist.
70
+ operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');
71
+ return primitiveType('instant');
72
+ case 'civil_date':
73
+ // The one explicit projection from an instant to a civil date. `civil_date(d: date)`
74
+ // would be the identity and is not a built-in for the same reason `start_of_day(d)` is
75
+ // not one.
76
+ operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');
77
+ return primitiveType('date');
78
+ }
79
+ }
80
+ //# sourceMappingURL=temporal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal.js","sourceRoot":"","sources":["../../../src/expr/typecheck/temporal.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AAsBpB,MAAM,UAAU,YAAY,CAC1B,GAAiB,EACjB,EAAoB,EACpB,QAAkB;IAElB,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,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U,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;YAC7F,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;QAClC,KAAK,cAAc;YACjB,uFAAuF;YACvF,kFAAkF;YAClF,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC;YAC9E,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;QAClC,KAAK,YAAY;YACf,qFAAqF;YACrF,uFAAuF;YACvF,WAAW;YACX,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC;YAC9E,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACH,CAAC","sourcesContent":["import type { CheckContext } from './context.js';\nimport type { Operands } from './operands.js';\nimport type { StaticType } from './types.js';\nimport {\n durationDomainOf,\n durationUnitName,\n isPrimitive,\n primitiveType,\n unifyDuration,\n} from './types.js';\n\n/** Date, instant, time and duration arithmetic, `MODEL-2.1.23` and `MODEL-2.1.24`. */\nexport type TemporalOperator =\n | 'add_days'\n | 'add_months'\n | 'add_minutes'\n | 'add_years'\n | 'days_between'\n | 'months_between'\n | 'minutes_between'\n | 'start_of_day'\n | 'civil_date'\n | 'duration_minutes'\n | 'duration_seconds'\n | 'year'\n | 'month'\n | 'day'\n | 'weekday'\n | 'parse_date'\n | 'parse_instant';\n\nexport function temporalType(\n ctx: CheckContext,\n op: TemporalOperator,\n operands: Operands,\n): StaticType {\n switch (op) {\n case 'add_days':\n case 'add_months':\n case 'add_years':\n operands.requireType(0, (type) => isPrimitive(type, 'date'), 'a date');\n operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer');\n return primitiveType('date');\n case 'days_between':\n case 'months_between':\n operands.requireType(0, (type) => isPrimitive(type, 'date'), 'a date');\n operands.requireType(1, (type) => isPrimitive(type, 'date'), 'a date');\n return primitiveType('integer');\n case 'add_minutes': {\n // A clock time wraps inside its day; an instant advances into the next one. The first\n // operand chooses the family, and the second is an integer in both.\n const first = operands.typeAt(0);\n if (isPrimitive(first, 'time')) {\n operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer');\n return primitiveType('time');\n }\n operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');\n operands.requireType(1, (type) => isPrimitive(type, 'integer'), 'an integer');\n return primitiveType('instant');\n }\n case 'minutes_between': {\n const first = operands.typeAt(0);\n if (isPrimitive(first, 'time')) {\n operands.requireType(1, (type) => isPrimitive(type, 'time'), 'a time');\n return primitiveType('integer');\n }\n if (isPrimitive(first, 'duration')) {\n operands.requireType(1, (type) => isPrimitive(type, 'duration'), 'a duration');\n const left = durationDomainOf(first);\n const right = durationDomainOf(operands.typeAt(1));\n if (left !== undefined && right !== undefined && unifyDuration(left, right) === undefined) {\n throw ctx.mismatch(\n operands.nodeAt(1),\n `\\`minutes_between\\` compares one duration unit, got ${durationUnitName(left)} and ${durationUnitName(right)}; v1 defines no unit conversion`,\n );\n }\n return primitiveType('integer');\n }\n operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');\n operands.requireType(1, (type) => isPrimitive(type, 'instant'), 'an instant');\n return primitiveType('integer');\n }\n case 'year':\n case 'month':\n case 'day':\n case 'weekday':\n // A date component is stated over `date` only: an instant carries a UTC clock, and\n // deriving its civil date is the timezone rule the language deliberately does not\n // own. `year(civil_date(t))` is the explicit spelling.\n operands.requireType(0, (type) => isPrimitive(type, 'date'), 'a date');\n return primitiveType('integer');\n case 'parse_date':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n // `string -> date | null`: text outside the domain is the empty value, not an error\n // (`EXPR-6.1.12`), and `2026-02-30` is outside the domain.\n return primitiveType('date', undefined, true);\n case 'parse_instant':\n operands.requireType(0, (type) => isPrimitive(type, 'string'), 'a string');\n return primitiveType('instant', undefined, true);\n case 'duration_minutes':\n case 'duration_seconds':\n operands.requireType(0, (type) => isPrimitive(type, 'duration'), `a duration for \\`${op}\\``);\n return primitiveType('integer');\n case 'start_of_day':\n // `start_of_day(d: date)` is the identity, so it is not a built-in: the date itself is\n // the answer, and a second spelling would suggest a boundary that does not exist.\n operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');\n return primitiveType('instant');\n case 'civil_date':\n // The one explicit projection from an instant to a civil date. `civil_date(d: date)`\n // would be the identity and is not a built-in for the same reason `start_of_day(d)` is\n // not one.\n operands.requireType(0, (type) => isPrimitive(type, 'instant'), 'an instant');\n return primitiveType('date');\n }\n}\n"]}
@@ -0,0 +1,163 @@
1
+ import type { CompiledField, Primitive, WireValue } from '@azx-pbc/axiom-runtime';
2
+ import type { ValueDomain } from '@azx-pbc/axiom-runtime';
3
+ /**
4
+ * Static typing of Expr v1, `spec/semantics/expr-v1.md` section 6 and the per-built-in
5
+ * table.
6
+ *
7
+ * Every expression has exactly one type, resolved against the declarations it is compiled
8
+ * for. A refusal names the offending segment with the expected and actual types, and a
9
+ * misspelled identifier or path segment carries a bounded suggestion drawn from the
10
+ * declarations in scope.
11
+ */
12
+ /**
13
+ * The money type's two parameters: `money<currency, scale>`, each slot a literal or
14
+ * `undefined` for `unknown`.
15
+ *
16
+ * Money carries its currency and scale in the value, so `money` alone cannot say whether two
17
+ * amounts may be added. A declaration (`field.currency`, `field.scale`), a money literal and
18
+ * `money_from_minor` with literal arguments each pin one; a declaration that states neither
19
+ * is `money<unknown, unknown>`, and the runtime decides then (`EXPR-12.1.3`).
20
+ */
21
+ export interface MoneyDomain {
22
+ readonly currency: string | undefined;
23
+ readonly scale: number | undefined;
24
+ }
25
+ /**
26
+ * The quantity type's parameters: `quantity<units, scale>`, `MODEL-2.1.21`.
27
+ *
28
+ * The unit set is the field's declared domain, so two quantity types with disjoint sets cannot
29
+ * be added or compared: the compiler refuses the static mismatch and the runtime refuses a
30
+ * value-stated one. `scale` is the largest number of fractional digits the declaration admits;
31
+ * arithmetic keeps exact decimal text rather than rounding to it.
32
+ */
33
+ export interface QuantityDomain {
34
+ readonly units: readonly string[] | undefined;
35
+ readonly scale: number | undefined;
36
+ /** The declaration the domain came from, so a mixed-unit refusal can name the field. */
37
+ readonly fieldId?: string;
38
+ }
39
+ /**
40
+ * The duration type's parameter: `duration<unit>`, `MODEL-2.1.24`.
41
+ *
42
+ * The unit is the field's declared unit (default `minutes`), so two durations with different
43
+ * units cannot be added, compared or folded: the compiler refuses the static mismatch and the
44
+ * runtime refuses a value-stated one. `undefined` is the unpinned unit, where the runtime decides.
45
+ */
46
+ export interface DurationDomain {
47
+ readonly unit: string | undefined;
48
+ /** The declaration the domain came from, so a mixed-unit refusal can name the field. */
49
+ readonly fieldId?: string;
50
+ }
51
+ export type StaticType = {
52
+ readonly kind: 'primitive';
53
+ readonly primitive: Primitive | 'null';
54
+ /** The parameters a `money` type carries; absent for every other primitive. */
55
+ readonly money?: MoneyDomain;
56
+ /** The parameters a `quantity` type carries; absent for every other primitive. */
57
+ readonly quantity?: QuantityDomain;
58
+ /** The parameter a `duration` type carries; absent for every other primitive. */
59
+ readonly duration?: DurationDomain;
60
+ /**
61
+ * Whether the value may also be the empty value `null`, `EXPR-6.1.12`.
62
+ *
63
+ * `parse_integer` and `parse_decimal` answer `null` when the text spells nothing, so
64
+ * their declared type is `integer | null` and `decimal | null`. `null` is not a type
65
+ * that refuses an operation — a construct that consumes it lifts to `UNKNOWN`
66
+ * (`EXPR-5.1.12`) — so this flag exists to state the signature, and to let `??` and
67
+ * `if` report the type they actually produce, not to narrow what the operators accept.
68
+ */
69
+ readonly nullable?: true;
70
+ } | {
71
+ readonly kind: 'list';
72
+ readonly element: StaticType | undefined;
73
+ readonly open: boolean;
74
+ } | {
75
+ readonly kind: 'record';
76
+ readonly fields: readonly CompiledField[];
77
+ readonly open: boolean;
78
+ };
79
+ export declare const ORDERABLE: ReadonlySet<string>;
80
+ export declare function primitiveType(primitive: Primitive | 'null', money?: MoneyDomain, nullable?: boolean, quantity?: QuantityDomain, duration?: DurationDomain): StaticType;
81
+ /** Whether the type may also be the empty value `null`. */
82
+ export declare function isNullable(type: StaticType): boolean;
83
+ /**
84
+ * The same type with its `null` arm stated or removed.
85
+ *
86
+ * `??` replaces `null` with its right operand (`EXPR-9.1.3`), so a coalesce is nullable
87
+ * exactly when its last operand can itself be `null`; the helper states that without
88
+ * rebuilding a list or record type.
89
+ */
90
+ export declare function withNullability(type: StaticType, nullable: boolean): StaticType;
91
+ /** The parameters of a money type, or `undefined` when `type` is not money. */
92
+ export declare function moneyDomainOf(type: StaticType): MoneyDomain | undefined;
93
+ /** The parameters of a quantity type, or `undefined` when `type` is not quantity. */
94
+ export declare function quantityDomainOf(type: StaticType): QuantityDomain | undefined;
95
+ /** The parameter of a duration type, or `undefined` when `type` is not duration. */
96
+ export declare function durationDomainOf(type: StaticType): DurationDomain | undefined;
97
+ /** A duration declaration's unit, from the field or item that states it. */
98
+ export declare function durationUnitName(domain: DurationDomain): string;
99
+ /**
100
+ * The two duration units as one type, or `undefined` when the declarations name different
101
+ * units. An `unknown` unit unifies with anything and stays `unknown`; a proven difference means
102
+ * no value satisfies both, so the operation is a compile error rather than a deferred one.
103
+ */
104
+ export declare function unifyDuration(left: DurationDomain, right: DurationDomain): DurationDomain | undefined;
105
+ /** How a quantity spelling reads in a refusal: `sqm|lm@2`, with `unknown` for an unpinned slot. */
106
+ export declare function quantityName(domain: QuantityDomain): string;
107
+ /**
108
+ * The two quantity parameters as one type, or `undefined` when the two declarations share no
109
+ * unit. An `unknown` slot unifies with anything and yields `unknown`; two disjoint unit sets
110
+ * prove no value can satisfy both, so the operation is refused rather than deferred.
111
+ */
112
+ export declare function unifyQuantity(left: QuantityDomain, right: QuantityDomain): QuantityDomain | undefined;
113
+ /** How a money spelling reads in a refusal: `AUD/2`, with `unknown` for an unpinned slot. */
114
+ export declare function moneySpellingName(domain: MoneyDomain): string;
115
+ export declare function unifyMoney(left: MoneyDomain, right: MoneyDomain): MoneyDomain | undefined;
116
+ /** The money spelling a money literal states, or none when the value is not one. */
117
+ export declare function literalMoneyDomain(value: WireValue): MoneyDomain;
118
+ /** The units and scale a quantity literal states, or none when the value is not one. */
119
+ export declare function literalQuantityDomain(value: WireValue): QuantityDomain;
120
+ export declare function typeName(type: StaticType): string;
121
+ export declare function isPrimitive(type: StaticType, ...primitives: readonly string[]): boolean;
122
+ export declare function isBoolean(type: StaticType): boolean;
123
+ export declare function isNumeric(type: StaticType): boolean;
124
+ /**
125
+ * The common type two operands unify to, or `undefined`. `integer` and `decimal` widen to
126
+ * `decimal`; `null` unifies with any type because it is the empty value of every domain
127
+ * lists unify element-wise.
128
+ */
129
+ export declare function unify(left: StaticType, right: StaticType): StaticType | undefined;
130
+ /**
131
+ * The type one element of a declared array has, or `undefined` when the declaration states
132
+ * no element type.
133
+ *
134
+ * A scalar or attachment array declares `items`, so its elements are that primitive; a record
135
+ * array declares `fields`, so its elements are that record. An intrinsic array member such as
136
+ * `media_ref.tags` declares neither, and the published contract describes no element for it,
137
+ * so it is an open list. One derivation serves the array's own type and an item-scoped rule's
138
+ * `$it`, so a rule that reads a scalar element and the read of the list cannot disagree about
139
+ * what an element is.
140
+ */
141
+ /**
142
+ * The static type one value domain has, as an expression reading it would see it.
143
+ *
144
+ * The domain is the runtime's `valueDomainOf`, so the type a declaration is checked under and
145
+ * the declaration the wire reader validates are one derivation. `sourceFieldId` only names the
146
+ * declaration in a refusal (`on field \`f_q\``); it changes no part of the type.
147
+ */
148
+ export declare function staticTypeOfDomain(domain: ValueDomain, sourceFieldId?: string): StaticType;
149
+ /**
150
+ * The type one element of a declared array has, or `undefined` when the declaration states
151
+ * no element type.
152
+ *
153
+ * A scalar or attachment array declares `items`, so its elements are that primitive; a record
154
+ * array declares `fields`, so its elements are that record. An intrinsic array member such as
155
+ * `media_ref.tags` declares neither, and the published contract describes no element for it,
156
+ * so it is an open list. One derivation serves the array's own type and an item-scoped rule's
157
+ * `$it`, so a rule that reads a scalar element and the read of the list cannot disagree about
158
+ * what an element is.
159
+ */
160
+ export declare function arrayElementType(field: CompiledField): StaticType | undefined;
161
+ /** The static type one declared field's own value has, as an expression reading it would see it. */
162
+ export declare function staticTypeOf(field: CompiledField): StaticType;
163
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/expr/typecheck/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAKD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,wFAAwF;IACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,wFAAwF;IACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID,MAAM,MAAM,UAAU,GAClB;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IA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