@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.5

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 (755) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +714 -2
  3. package/dist/cache/index.d.ts +191 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/index.js +361 -0
  6. package/dist/cache/index.js.map +1 -0
  7. package/dist/canonical/jcs.d.ts +78 -0
  8. package/dist/canonical/jcs.d.ts.map +1 -0
  9. package/dist/canonical/jcs.js +500 -0
  10. package/dist/canonical/jcs.js.map +1 -0
  11. package/dist/canonical/restricted-json.d.ts +7 -0
  12. package/dist/canonical/restricted-json.d.ts.map +1 -0
  13. package/dist/canonical/restricted-json.js +318 -0
  14. package/dist/canonical/restricted-json.js.map +1 -0
  15. package/dist/canonical/restricted-value.d.ts +59 -0
  16. package/dist/canonical/restricted-value.d.ts.map +1 -0
  17. package/dist/canonical/restricted-value.js +156 -0
  18. package/dist/canonical/restricted-value.js.map +1 -0
  19. package/dist/canonical/restricted.d.ts +85 -0
  20. package/dist/canonical/restricted.d.ts.map +1 -0
  21. package/dist/canonical/restricted.js +163 -0
  22. package/dist/canonical/restricted.js.map +1 -0
  23. package/dist/canonical/signature.d.ts +38 -0
  24. package/dist/canonical/signature.d.ts.map +1 -0
  25. package/dist/canonical/signature.js +47 -0
  26. package/dist/canonical/signature.js.map +1 -0
  27. package/dist/eval/access/delivery.d.ts +63 -0
  28. package/dist/eval/access/delivery.d.ts.map +1 -0
  29. package/dist/eval/access/delivery.js +98 -0
  30. package/dist/eval/access/delivery.js.map +1 -0
  31. package/dist/eval/access/overlay.d.ts +72 -0
  32. package/dist/eval/access/overlay.d.ts.map +1 -0
  33. package/dist/eval/access/overlay.js +402 -0
  34. package/dist/eval/access/overlay.js.map +1 -0
  35. package/dist/eval/access/projection.d.ts +159 -0
  36. package/dist/eval/access/projection.d.ts.map +1 -0
  37. package/dist/eval/access/projection.js +211 -0
  38. package/dist/eval/access/projection.js.map +1 -0
  39. package/dist/eval/access/window.d.ts +128 -0
  40. package/dist/eval/access/window.d.ts.map +1 -0
  41. package/dist/eval/access/window.js +254 -0
  42. package/dist/eval/access/window.js.map +1 -0
  43. package/dist/eval/access/write.d.ts +113 -0
  44. package/dist/eval/access/write.d.ts.map +1 -0
  45. package/dist/eval/access/write.js +119 -0
  46. package/dist/eval/access/write.js.map +1 -0
  47. package/dist/eval/addressing.d.ts +131 -0
  48. package/dist/eval/addressing.d.ts.map +1 -0
  49. package/dist/eval/addressing.js +270 -0
  50. package/dist/eval/addressing.js.map +1 -0
  51. package/dist/eval/budget.d.ts +143 -0
  52. package/dist/eval/budget.d.ts.map +1 -0
  53. package/dist/eval/budget.js +387 -0
  54. package/dist/eval/budget.js.map +1 -0
  55. package/dist/eval/computed.d.ts +46 -0
  56. package/dist/eval/computed.d.ts.map +1 -0
  57. package/dist/eval/computed.js +89 -0
  58. package/dist/eval/computed.js.map +1 -0
  59. package/dist/eval/denials.d.ts +64 -0
  60. package/dist/eval/denials.d.ts.map +1 -0
  61. package/dist/eval/denials.js +87 -0
  62. package/dist/eval/denials.js.map +1 -0
  63. package/dist/eval/engine/cancellation.d.ts +12 -0
  64. package/dist/eval/engine/cancellation.d.ts.map +1 -0
  65. package/dist/eval/engine/cancellation.js +56 -0
  66. package/dist/eval/engine/cancellation.js.map +1 -0
  67. package/dist/eval/engine/delta.d.ts +104 -0
  68. package/dist/eval/engine/delta.d.ts.map +1 -0
  69. package/dist/eval/engine/delta.js +466 -0
  70. package/dist/eval/engine/delta.js.map +1 -0
  71. package/dist/eval/engine/deps.d.ts +136 -0
  72. package/dist/eval/engine/deps.d.ts.map +1 -0
  73. package/dist/eval/engine/deps.js +345 -0
  74. package/dist/eval/engine/deps.js.map +1 -0
  75. package/dist/eval/engine/identity.d.ts +128 -0
  76. package/dist/eval/engine/identity.d.ts.map +1 -0
  77. package/dist/eval/engine/identity.js +398 -0
  78. package/dist/eval/engine/identity.js.map +1 -0
  79. package/dist/eval/engine/index.d.ts +200 -0
  80. package/dist/eval/engine/index.d.ts.map +1 -0
  81. package/dist/eval/engine/index.js +1242 -0
  82. package/dist/eval/engine/index.js.map +1 -0
  83. package/dist/eval/engine/measurement.d.ts +23 -0
  84. package/dist/eval/engine/measurement.d.ts.map +1 -0
  85. package/dist/eval/engine/measurement.js +42 -0
  86. package/dist/eval/engine/measurement.js.map +1 -0
  87. package/dist/eval/engine/naive.d.ts +19 -0
  88. package/dist/eval/engine/naive.d.ts.map +1 -0
  89. package/dist/eval/engine/naive.js +59 -0
  90. package/dist/eval/engine/naive.js.map +1 -0
  91. package/dist/eval/engine/ops.d.ts +214 -0
  92. package/dist/eval/engine/ops.d.ts.map +1 -0
  93. package/dist/eval/engine/ops.js +1422 -0
  94. package/dist/eval/engine/ops.js.map +1 -0
  95. package/dist/eval/engine/patches.d.ts +40 -0
  96. package/dist/eval/engine/patches.d.ts.map +1 -0
  97. package/dist/eval/engine/patches.js +125 -0
  98. package/dist/eval/engine/patches.js.map +1 -0
  99. package/dist/eval/engine/ports.d.ts +71 -0
  100. package/dist/eval/engine/ports.d.ts.map +1 -0
  101. package/dist/eval/engine/ports.js +2 -0
  102. package/dist/eval/engine/ports.js.map +1 -0
  103. package/dist/eval/engine/session.d.ts +116 -0
  104. package/dist/eval/engine/session.d.ts.map +1 -0
  105. package/dist/eval/engine/session.js +653 -0
  106. package/dist/eval/engine/session.js.map +1 -0
  107. package/dist/eval/engine/snapshot.d.ts +97 -0
  108. package/dist/eval/engine/snapshot.d.ts.map +1 -0
  109. package/dist/eval/engine/snapshot.js +221 -0
  110. package/dist/eval/engine/snapshot.js.map +1 -0
  111. package/dist/eval/engine/subscriptions.d.ts +47 -0
  112. package/dist/eval/engine/subscriptions.d.ts.map +1 -0
  113. package/dist/eval/engine/subscriptions.js +103 -0
  114. package/dist/eval/engine/subscriptions.js.map +1 -0
  115. package/dist/eval/engine/trace.d.ts +77 -0
  116. package/dist/eval/engine/trace.d.ts.map +1 -0
  117. package/dist/eval/engine/trace.js +140 -0
  118. package/dist/eval/engine/trace.js.map +1 -0
  119. package/dist/eval/error-diagnostic.d.ts +26 -0
  120. package/dist/eval/error-diagnostic.d.ts.map +1 -0
  121. package/dist/eval/error-diagnostic.js +63 -0
  122. package/dist/eval/error-diagnostic.js.map +1 -0
  123. package/dist/eval/evaluate-expr.d.ts +44 -0
  124. package/dist/eval/evaluate-expr.d.ts.map +1 -0
  125. package/dist/eval/evaluate-expr.js +149 -0
  126. package/dist/eval/evaluate-expr.js.map +1 -0
  127. package/dist/eval/evaluate.d.ts +282 -0
  128. package/dist/eval/evaluate.d.ts.map +1 -0
  129. package/dist/eval/evaluate.js +391 -0
  130. package/dist/eval/evaluate.js.map +1 -0
  131. package/dist/eval/evolution/relocate.d.ts +72 -0
  132. package/dist/eval/evolution/relocate.d.ts.map +1 -0
  133. package/dist/eval/evolution/relocate.js +427 -0
  134. package/dist/eval/evolution/relocate.js.map +1 -0
  135. package/dist/eval/evolution/select.d.ts +11 -0
  136. package/dist/eval/evolution/select.d.ts.map +1 -0
  137. package/dist/eval/evolution/select.js +53 -0
  138. package/dist/eval/evolution/select.js.map +1 -0
  139. package/dist/eval/evolution/upcast.d.ts +13 -0
  140. package/dist/eval/evolution/upcast.d.ts.map +1 -0
  141. package/dist/eval/evolution/upcast.js +88 -0
  142. package/dist/eval/evolution/upcast.js.map +1 -0
  143. package/dist/eval/expr/aggregates.d.ts +75 -0
  144. package/dist/eval/expr/aggregates.d.ts.map +1 -0
  145. package/dist/eval/expr/aggregates.js +991 -0
  146. package/dist/eval/expr/aggregates.js.map +1 -0
  147. package/dist/eval/expr/arithmetic.d.ts +26 -0
  148. package/dist/eval/expr/arithmetic.d.ts.map +1 -0
  149. package/dist/eval/expr/arithmetic.js +387 -0
  150. package/dist/eval/expr/arithmetic.js.map +1 -0
  151. package/dist/eval/expr/between.d.ts +17 -0
  152. package/dist/eval/expr/between.d.ts.map +1 -0
  153. package/dist/eval/expr/between.js +46 -0
  154. package/dist/eval/expr/between.js.map +1 -0
  155. package/dist/eval/expr/binder.d.ts +96 -0
  156. package/dist/eval/expr/binder.d.ts.map +1 -0
  157. package/dist/eval/expr/binder.js +253 -0
  158. package/dist/eval/expr/binder.js.map +1 -0
  159. package/dist/eval/expr/call-dispatch.d.ts +28 -0
  160. package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
  161. package/dist/eval/expr/call-dispatch.js +114 -0
  162. package/dist/eval/expr/call-dispatch.js.map +1 -0
  163. package/dist/eval/expr/collections.d.ts +20 -0
  164. package/dist/eval/expr/collections.d.ts.map +1 -0
  165. package/dist/eval/expr/collections.js +66 -0
  166. package/dist/eval/expr/collections.js.map +1 -0
  167. package/dist/eval/expr/compare.d.ts +36 -0
  168. package/dist/eval/expr/compare.d.ts.map +1 -0
  169. package/dist/eval/expr/compare.js +115 -0
  170. package/dist/eval/expr/compare.js.map +1 -0
  171. package/dist/eval/expr/datasets.d.ts +28 -0
  172. package/dist/eval/expr/datasets.d.ts.map +1 -0
  173. package/dist/eval/expr/datasets.js +304 -0
  174. package/dist/eval/expr/datasets.js.map +1 -0
  175. package/dist/eval/expr/digest.d.ts +23 -0
  176. package/dist/eval/expr/digest.d.ts.map +1 -0
  177. package/dist/eval/expr/digest.js +89 -0
  178. package/dist/eval/expr/digest.js.map +1 -0
  179. package/dist/eval/expr/domains.d.ts +19 -0
  180. package/dist/eval/expr/domains.d.ts.map +1 -0
  181. package/dist/eval/expr/domains.js +18 -0
  182. package/dist/eval/expr/domains.js.map +1 -0
  183. package/dist/eval/expr/host.d.ts +152 -0
  184. package/dist/eval/expr/host.d.ts.map +1 -0
  185. package/dist/eval/expr/host.js +36 -0
  186. package/dist/eval/expr/host.js.map +1 -0
  187. package/dist/eval/expr/lists.d.ts +24 -0
  188. package/dist/eval/expr/lists.d.ts.map +1 -0
  189. package/dist/eval/expr/lists.js +155 -0
  190. package/dist/eval/expr/lists.js.map +1 -0
  191. package/dist/eval/expr/member.d.ts +15 -0
  192. package/dist/eval/expr/member.d.ts.map +1 -0
  193. package/dist/eval/expr/member.js +32 -0
  194. package/dist/eval/expr/member.js.map +1 -0
  195. package/dist/eval/expr/money-ops.d.ts +10 -0
  196. package/dist/eval/expr/money-ops.d.ts.map +1 -0
  197. package/dist/eval/expr/money-ops.js +17 -0
  198. package/dist/eval/expr/money-ops.js.map +1 -0
  199. package/dist/eval/expr/operands.d.ts +27 -0
  200. package/dist/eval/expr/operands.d.ts.map +1 -0
  201. package/dist/eval/expr/operands.js +167 -0
  202. package/dist/eval/expr/operands.js.map +1 -0
  203. package/dist/eval/expr/presence.d.ts +27 -0
  204. package/dist/eval/expr/presence.d.ts.map +1 -0
  205. package/dist/eval/expr/presence.js +140 -0
  206. package/dist/eval/expr/presence.js.map +1 -0
  207. package/dist/eval/expr/records.d.ts +22 -0
  208. package/dist/eval/expr/records.d.ts.map +1 -0
  209. package/dist/eval/expr/records.js +101 -0
  210. package/dist/eval/expr/records.js.map +1 -0
  211. package/dist/eval/expr/rule-refs.d.ts +25 -0
  212. package/dist/eval/expr/rule-refs.d.ts.map +1 -0
  213. package/dist/eval/expr/rule-refs.js +60 -0
  214. package/dist/eval/expr/rule-refs.js.map +1 -0
  215. package/dist/eval/expr/sequences.d.ts +26 -0
  216. package/dist/eval/expr/sequences.d.ts.map +1 -0
  217. package/dist/eval/expr/sequences.js +151 -0
  218. package/dist/eval/expr/sequences.js.map +1 -0
  219. package/dist/eval/expr/value.d.ts +99 -0
  220. package/dist/eval/expr/value.d.ts.map +1 -0
  221. package/dist/eval/expr/value.js +14 -0
  222. package/dist/eval/expr/value.js.map +1 -0
  223. package/dist/eval/expression.d.ts +142 -0
  224. package/dist/eval/expression.d.ts.map +1 -0
  225. package/dist/eval/expression.js +446 -0
  226. package/dist/eval/expression.js.map +1 -0
  227. package/dist/eval/firing.d.ts +68 -0
  228. package/dist/eval/firing.d.ts.map +1 -0
  229. package/dist/eval/firing.js +222 -0
  230. package/dist/eval/firing.js.map +1 -0
  231. package/dist/eval/gate.d.ts +110 -0
  232. package/dist/eval/gate.d.ts.map +1 -0
  233. package/dist/eval/gate.js +278 -0
  234. package/dist/eval/gate.js.map +1 -0
  235. package/dist/eval/layout-visibility.d.ts +18 -0
  236. package/dist/eval/layout-visibility.d.ts.map +1 -0
  237. package/dist/eval/layout-visibility.js +61 -0
  238. package/dist/eval/layout-visibility.js.map +1 -0
  239. package/dist/eval/option-availability.d.ts +26 -0
  240. package/dist/eval/option-availability.d.ts.map +1 -0
  241. package/dist/eval/option-availability.js +580 -0
  242. package/dist/eval/option-availability.js.map +1 -0
  243. package/dist/eval/options-boundary.d.ts +15 -0
  244. package/dist/eval/options-boundary.d.ts.map +1 -0
  245. package/dist/eval/options-boundary.js +40 -0
  246. package/dist/eval/options-boundary.js.map +1 -0
  247. package/dist/eval/options.d.ts +99 -0
  248. package/dist/eval/options.d.ts.map +1 -0
  249. package/dist/eval/options.js +96 -0
  250. package/dist/eval/options.js.map +1 -0
  251. package/dist/eval/overrides.d.ts +116 -0
  252. package/dist/eval/overrides.d.ts.map +1 -0
  253. package/dist/eval/overrides.js +176 -0
  254. package/dist/eval/overrides.js.map +1 -0
  255. package/dist/eval/paths.d.ts +25 -0
  256. package/dist/eval/paths.d.ts.map +1 -0
  257. package/dist/eval/paths.js +47 -0
  258. package/dist/eval/paths.js.map +1 -0
  259. package/dist/eval/presentation-reads.d.ts +20 -0
  260. package/dist/eval/presentation-reads.d.ts.map +1 -0
  261. package/dist/eval/presentation-reads.js +2 -0
  262. package/dist/eval/presentation-reads.js.map +1 -0
  263. package/dist/eval/presentation.d.ts +122 -0
  264. package/dist/eval/presentation.d.ts.map +1 -0
  265. package/dist/eval/presentation.js +255 -0
  266. package/dist/eval/presentation.js.map +1 -0
  267. package/dist/eval/reader/context-value.d.ts +41 -0
  268. package/dist/eval/reader/context-value.d.ts.map +1 -0
  269. package/dist/eval/reader/context-value.js +129 -0
  270. package/dist/eval/reader/context-value.js.map +1 -0
  271. package/dist/eval/reader/covered.d.ts +53 -0
  272. package/dist/eval/reader/covered.d.ts.map +1 -0
  273. package/dist/eval/reader/covered.js +139 -0
  274. package/dist/eval/reader/covered.js.map +1 -0
  275. package/dist/eval/reader/declarations.d.ts +182 -0
  276. package/dist/eval/reader/declarations.d.ts.map +1 -0
  277. package/dist/eval/reader/declarations.js +153 -0
  278. package/dist/eval/reader/declarations.js.map +1 -0
  279. package/dist/eval/reader/member-access.d.ts +87 -0
  280. package/dist/eval/reader/member-access.d.ts.map +1 -0
  281. package/dist/eval/reader/member-access.js +212 -0
  282. package/dist/eval/reader/member-access.js.map +1 -0
  283. package/dist/eval/reader/memo.d.ts +34 -0
  284. package/dist/eval/reader/memo.d.ts.map +1 -0
  285. package/dist/eval/reader/memo.js +67 -0
  286. package/dist/eval/reader/memo.js.map +1 -0
  287. package/dist/eval/reader/overlay.d.ts +74 -0
  288. package/dist/eval/reader/overlay.d.ts.map +1 -0
  289. package/dist/eval/reader/overlay.js +365 -0
  290. package/dist/eval/reader/overlay.js.map +1 -0
  291. package/dist/eval/reader/questions.d.ts +37 -0
  292. package/dist/eval/reader/questions.d.ts.map +1 -0
  293. package/dist/eval/reader/questions.js +78 -0
  294. package/dist/eval/reader/questions.js.map +1 -0
  295. package/dist/eval/reader/resolve.d.ts +84 -0
  296. package/dist/eval/reader/resolve.d.ts.map +1 -0
  297. package/dist/eval/reader/resolve.js +310 -0
  298. package/dist/eval/reader/resolve.js.map +1 -0
  299. package/dist/eval/reader/value-read.d.ts +50 -0
  300. package/dist/eval/reader/value-read.d.ts.map +1 -0
  301. package/dist/eval/reader/value-read.js +133 -0
  302. package/dist/eval/reader/value-read.js.map +1 -0
  303. package/dist/eval/reader/withheld.d.ts +48 -0
  304. package/dist/eval/reader/withheld.d.ts.map +1 -0
  305. package/dist/eval/reader/withheld.js +108 -0
  306. package/dist/eval/reader/withheld.js.map +1 -0
  307. package/dist/eval/reader-paths.d.ts +24 -0
  308. package/dist/eval/reader-paths.d.ts.map +1 -0
  309. package/dist/eval/reader-paths.js +23 -0
  310. package/dist/eval/reader-paths.js.map +1 -0
  311. package/dist/eval/reader.d.ts +281 -0
  312. package/dist/eval/reader.d.ts.map +1 -0
  313. package/dist/eval/reader.js +560 -0
  314. package/dist/eval/reader.js.map +1 -0
  315. package/dist/eval/receipt.d.ts +37 -0
  316. package/dist/eval/receipt.d.ts.map +1 -0
  317. package/dist/eval/receipt.js +222 -0
  318. package/dist/eval/receipt.js.map +1 -0
  319. package/dist/eval/report/assemble.d.ts +84 -0
  320. package/dist/eval/report/assemble.d.ts.map +1 -0
  321. package/dist/eval/report/assemble.js +277 -0
  322. package/dist/eval/report/assemble.js.map +1 -0
  323. package/dist/eval/report/fold.d.ts +18 -0
  324. package/dist/eval/report/fold.d.ts.map +1 -0
  325. package/dist/eval/report/fold.js +58 -0
  326. package/dist/eval/report/fold.js.map +1 -0
  327. package/dist/eval/rule/alternatives.d.ts +23 -0
  328. package/dist/eval/rule/alternatives.d.ts.map +1 -0
  329. package/dist/eval/rule/alternatives.js +46 -0
  330. package/dist/eval/rule/alternatives.js.map +1 -0
  331. package/dist/eval/rule/behaviour.d.ts +47 -0
  332. package/dist/eval/rule/behaviour.d.ts.map +1 -0
  333. package/dist/eval/rule/behaviour.js +249 -0
  334. package/dist/eval/rule/behaviour.js.map +1 -0
  335. package/dist/eval/rule/compute.d.ts +46 -0
  336. package/dist/eval/rule/compute.d.ts.map +1 -0
  337. package/dist/eval/rule/compute.js +158 -0
  338. package/dist/eval/rule/compute.js.map +1 -0
  339. package/dist/eval/rule/create-state.d.ts +42 -0
  340. package/dist/eval/rule/create-state.d.ts.map +1 -0
  341. package/dist/eval/rule/create-state.js +134 -0
  342. package/dist/eval/rule/create-state.js.map +1 -0
  343. package/dist/eval/rule/diagnostics.d.ts +24 -0
  344. package/dist/eval/rule/diagnostics.d.ts.map +1 -0
  345. package/dist/eval/rule/diagnostics.js +45 -0
  346. package/dist/eval/rule/diagnostics.js.map +1 -0
  347. package/dist/eval/rule/execution.d.ts +24 -0
  348. package/dist/eval/rule/execution.d.ts.map +1 -0
  349. package/dist/eval/rule/execution.js +495 -0
  350. package/dist/eval/rule/execution.js.map +1 -0
  351. package/dist/eval/rule/gate.d.ts +12 -0
  352. package/dist/eval/rule/gate.d.ts.map +1 -0
  353. package/dist/eval/rule/gate.js +34 -0
  354. package/dist/eval/rule/gate.js.map +1 -0
  355. package/dist/eval/rule/item.d.ts +11 -0
  356. package/dist/eval/rule/item.d.ts.map +1 -0
  357. package/dist/eval/rule/item.js +265 -0
  358. package/dist/eval/rule/item.js.map +1 -0
  359. package/dist/eval/rule/prepare.d.ts +64 -0
  360. package/dist/eval/rule/prepare.d.ts.map +1 -0
  361. package/dist/eval/rule/prepare.js +131 -0
  362. package/dist/eval/rule/prepare.js.map +1 -0
  363. package/dist/eval/rule/result.d.ts +97 -0
  364. package/dist/eval/rule/result.d.ts.map +1 -0
  365. package/dist/eval/rule/result.js +347 -0
  366. package/dist/eval/rule/result.js.map +1 -0
  367. package/dist/eval/rule/runner.d.ts +128 -0
  368. package/dist/eval/rule/runner.d.ts.map +1 -0
  369. package/dist/eval/rule/runner.js +296 -0
  370. package/dist/eval/rule/runner.js.map +1 -0
  371. package/dist/eval/rule/screen.d.ts +32 -0
  372. package/dist/eval/rule/screen.d.ts.map +1 -0
  373. package/dist/eval/rule/screen.js +73 -0
  374. package/dist/eval/rule/screen.js.map +1 -0
  375. package/dist/eval/rule/state.d.ts +137 -0
  376. package/dist/eval/rule/state.d.ts.map +1 -0
  377. package/dist/eval/rule/state.js +2 -0
  378. package/dist/eval/rule/state.js.map +1 -0
  379. package/dist/eval/rule/steps.d.ts +44 -0
  380. package/dist/eval/rule/steps.d.ts.map +1 -0
  381. package/dist/eval/rule/steps.js +367 -0
  382. package/dist/eval/rule/steps.js.map +1 -0
  383. package/dist/eval/rule/visibility.d.ts +18 -0
  384. package/dist/eval/rule/visibility.d.ts.map +1 -0
  385. package/dist/eval/rule/visibility.js +79 -0
  386. package/dist/eval/rule/visibility.js.map +1 -0
  387. package/dist/eval/seal.d.ts +74 -0
  388. package/dist/eval/seal.d.ts.map +1 -0
  389. package/dist/eval/seal.js +154 -0
  390. package/dist/eval/seal.js.map +1 -0
  391. package/dist/eval/signature-coverage.d.ts +19 -0
  392. package/dist/eval/signature-coverage.d.ts.map +1 -0
  393. package/dist/eval/signature-coverage.js +160 -0
  394. package/dist/eval/signature-coverage.js.map +1 -0
  395. package/dist/eval/state/derive.d.ts +72 -0
  396. package/dist/eval/state/derive.d.ts.map +1 -0
  397. package/dist/eval/state/derive.js +61 -0
  398. package/dist/eval/state/derive.js.map +1 -0
  399. package/dist/eval/state/describe.d.ts +18 -0
  400. package/dist/eval/state/describe.d.ts.map +1 -0
  401. package/dist/eval/state/describe.js +19 -0
  402. package/dist/eval/state/describe.js.map +1 -0
  403. package/dist/eval/state/field-state.d.ts +471 -0
  404. package/dist/eval/state/field-state.d.ts.map +1 -0
  405. package/dist/eval/state/field-state.js +1604 -0
  406. package/dist/eval/state/field-state.js.map +1 -0
  407. package/dist/eval/state/measurement.d.ts +136 -0
  408. package/dist/eval/state/measurement.d.ts.map +1 -0
  409. package/dist/eval/state/measurement.js +209 -0
  410. package/dist/eval/state/measurement.js.map +1 -0
  411. package/dist/eval/state/options.d.ts +21 -0
  412. package/dist/eval/state/options.d.ts.map +1 -0
  413. package/dist/eval/state/options.js +3 -0
  414. package/dist/eval/state/options.js.map +1 -0
  415. package/dist/eval/state/readiness.d.ts +400 -0
  416. package/dist/eval/state/readiness.d.ts.map +1 -0
  417. package/dist/eval/state/readiness.js +1067 -0
  418. package/dist/eval/state/readiness.js.map +1 -0
  419. package/dist/eval/state/snapshot.d.ts +130 -0
  420. package/dist/eval/state/snapshot.d.ts.map +1 -0
  421. package/dist/eval/state/snapshot.js +35 -0
  422. package/dist/eval/state/snapshot.js.map +1 -0
  423. package/dist/eval/state/unavailable-options.d.ts +54 -0
  424. package/dist/eval/state/unavailable-options.d.ts.map +1 -0
  425. package/dist/eval/state/unavailable-options.js +82 -0
  426. package/dist/eval/state/unavailable-options.js.map +1 -0
  427. package/dist/eval/state/value-state.d.ts +38 -0
  428. package/dist/eval/state/value-state.d.ts.map +1 -0
  429. package/dist/eval/state/value-state.js +52 -0
  430. package/dist/eval/state/value-state.js.map +1 -0
  431. package/dist/eval/submission/admission.d.ts +50 -0
  432. package/dist/eval/submission/admission.d.ts.map +1 -0
  433. package/dist/eval/submission/admission.js +174 -0
  434. package/dist/eval/submission/admission.js.map +1 -0
  435. package/dist/eval/submission/authority.d.ts +71 -0
  436. package/dist/eval/submission/authority.d.ts.map +1 -0
  437. package/dist/eval/submission/authority.js +118 -0
  438. package/dist/eval/submission/authority.js.map +1 -0
  439. package/dist/eval/submission/datasets.d.ts +28 -0
  440. package/dist/eval/submission/datasets.d.ts.map +1 -0
  441. package/dist/eval/submission/datasets.js +109 -0
  442. package/dist/eval/submission/datasets.js.map +1 -0
  443. package/dist/eval/submission/index.d.ts +15 -0
  444. package/dist/eval/submission/index.d.ts.map +1 -0
  445. package/dist/eval/submission/index.js +13 -0
  446. package/dist/eval/submission/index.js.map +1 -0
  447. package/dist/eval/submission/refusals.d.ts +103 -0
  448. package/dist/eval/submission/refusals.d.ts.map +1 -0
  449. package/dist/eval/submission/refusals.js +15 -0
  450. package/dist/eval/submission/refusals.js.map +1 -0
  451. package/dist/eval/submission/signatures.d.ts +7 -0
  452. package/dist/eval/submission/signatures.d.ts.map +1 -0
  453. package/dist/eval/submission/signatures.js +215 -0
  454. package/dist/eval/submission/signatures.js.map +1 -0
  455. package/dist/eval/submission/writes.d.ts +51 -0
  456. package/dist/eval/submission/writes.d.ts.map +1 -0
  457. package/dist/eval/submission/writes.js +203 -0
  458. package/dist/eval/submission/writes.js.map +1 -0
  459. package/dist/eval/submission.d.ts +53 -0
  460. package/dist/eval/submission.d.ts.map +1 -0
  461. package/dist/eval/submission.js +521 -0
  462. package/dist/eval/submission.js.map +1 -0
  463. package/dist/eval/suggestions-to-engine.d.ts +18 -0
  464. package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
  465. package/dist/eval/suggestions-to-engine.js +40 -0
  466. package/dist/eval/suggestions-to-engine.js.map +1 -0
  467. package/dist/eval/suggestions.d.ts +17 -0
  468. package/dist/eval/suggestions.d.ts.map +1 -0
  469. package/dist/eval/suggestions.js +314 -0
  470. package/dist/eval/suggestions.js.map +1 -0
  471. package/dist/eval/undecided.d.ts +64 -0
  472. package/dist/eval/undecided.d.ts.map +1 -0
  473. package/dist/eval/undecided.js +101 -0
  474. package/dist/eval/undecided.js.map +1 -0
  475. package/dist/eval/verdict.d.ts +66 -0
  476. package/dist/eval/verdict.d.ts.map +1 -0
  477. package/dist/eval/verdict.js +106 -0
  478. package/dist/eval/verdict.js.map +1 -0
  479. package/dist/eval/verify-signature.d.ts +78 -0
  480. package/dist/eval/verify-signature.d.ts.map +1 -0
  481. package/dist/eval/verify-signature.js +185 -0
  482. package/dist/eval/verify-signature.js.map +1 -0
  483. package/dist/eval/version-dispatch.d.ts +38 -0
  484. package/dist/eval/version-dispatch.d.ts.map +1 -0
  485. package/dist/eval/version-dispatch.js +61 -0
  486. package/dist/eval/version-dispatch.js.map +1 -0
  487. package/dist/eval/visibility.d.ts +33 -0
  488. package/dist/eval/visibility.d.ts.map +1 -0
  489. package/dist/eval/visibility.js +83 -0
  490. package/dist/eval/visibility.js.map +1 -0
  491. package/dist/evaluate.d.ts +24 -0
  492. package/dist/evaluate.d.ts.map +1 -0
  493. package/dist/evaluate.js +18 -0
  494. package/dist/evaluate.js.map +1 -0
  495. package/dist/expr/builtin-docs.d.ts +51 -0
  496. package/dist/expr/builtin-docs.d.ts.map +1 -0
  497. package/dist/expr/builtin-docs.js +874 -0
  498. package/dist/expr/builtin-docs.js.map +1 -0
  499. package/dist/expr/builtins.d.ts +50 -0
  500. package/dist/expr/builtins.d.ts.map +1 -0
  501. package/dist/expr/builtins.js +966 -0
  502. package/dist/expr/builtins.js.map +1 -0
  503. package/dist/expr/decimal-precision.d.ts +39 -0
  504. package/dist/expr/decimal-precision.d.ts.map +1 -0
  505. package/dist/expr/decimal-precision.js +62 -0
  506. package/dist/expr/decimal-precision.js.map +1 -0
  507. package/dist/expr/decimal.d.ts +172 -0
  508. package/dist/expr/decimal.d.ts.map +1 -0
  509. package/dist/expr/decimal.js +782 -0
  510. package/dist/expr/decimal.js.map +1 -0
  511. package/dist/expr/deprecations.d.ts +34 -0
  512. package/dist/expr/deprecations.d.ts.map +1 -0
  513. package/dist/expr/deprecations.js +17 -0
  514. package/dist/expr/deprecations.js.map +1 -0
  515. package/dist/expr/diagnostics.d.ts +21 -0
  516. package/dist/expr/diagnostics.d.ts.map +1 -0
  517. package/dist/expr/diagnostics.js +231 -0
  518. package/dist/expr/diagnostics.js.map +1 -0
  519. package/dist/expr/direction.d.ts +30 -0
  520. package/dist/expr/direction.d.ts.map +1 -0
  521. package/dist/expr/direction.js +77 -0
  522. package/dist/expr/direction.js.map +1 -0
  523. package/dist/expr/example-expression.d.ts +62 -0
  524. package/dist/expr/example-expression.d.ts.map +1 -0
  525. package/dist/expr/example-expression.js +670 -0
  526. package/dist/expr/example-expression.js.map +1 -0
  527. package/dist/expr/instant.d.ts +49 -0
  528. package/dist/expr/instant.d.ts.map +1 -0
  529. package/dist/expr/instant.js +111 -0
  530. package/dist/expr/instant.js.map +1 -0
  531. package/dist/expr/logic.d.ts +17 -0
  532. package/dist/expr/logic.d.ts.map +1 -0
  533. package/dist/expr/logic.js +65 -0
  534. package/dist/expr/logic.js.map +1 -0
  535. package/dist/expr/messages.d.ts +45 -0
  536. package/dist/expr/messages.d.ts.map +1 -0
  537. package/dist/expr/messages.js +280 -0
  538. package/dist/expr/messages.js.map +1 -0
  539. package/dist/expr/money.d.ts +38 -0
  540. package/dist/expr/money.d.ts.map +1 -0
  541. package/dist/expr/money.js +127 -0
  542. package/dist/expr/money.js.map +1 -0
  543. package/dist/expr/ordering.d.ts +56 -0
  544. package/dist/expr/ordering.d.ts.map +1 -0
  545. package/dist/expr/ordering.js +167 -0
  546. package/dist/expr/ordering.js.map +1 -0
  547. package/dist/expr/pattern.d.ts +44 -0
  548. package/dist/expr/pattern.d.ts.map +1 -0
  549. package/dist/expr/pattern.js +458 -0
  550. package/dist/expr/pattern.js.map +1 -0
  551. package/dist/expr/plain-date.d.ts +90 -0
  552. package/dist/expr/plain-date.d.ts.map +1 -0
  553. package/dist/expr/plain-date.js +230 -0
  554. package/dist/expr/plain-date.js.map +1 -0
  555. package/dist/expr/plural-categories.d.ts +8 -0
  556. package/dist/expr/plural-categories.d.ts.map +1 -0
  557. package/dist/expr/plural-categories.js +15 -0
  558. package/dist/expr/plural-categories.js.map +1 -0
  559. package/dist/expr/plural-keys.d.ts +39 -0
  560. package/dist/expr/plural-keys.d.ts.map +1 -0
  561. package/dist/expr/plural-keys.js +46 -0
  562. package/dist/expr/plural-keys.js.map +1 -0
  563. package/dist/expr/plural.d.ts +33 -0
  564. package/dist/expr/plural.d.ts.map +1 -0
  565. package/dist/expr/plural.js +50 -0
  566. package/dist/expr/plural.js.map +1 -0
  567. package/dist/expr/quantity.d.ts +31 -0
  568. package/dist/expr/quantity.d.ts.map +1 -0
  569. package/dist/expr/quantity.js +83 -0
  570. package/dist/expr/quantity.js.map +1 -0
  571. package/dist/expr/reduce.d.ts +50 -0
  572. package/dist/expr/reduce.d.ts.map +1 -0
  573. package/dist/expr/reduce.js +236 -0
  574. package/dist/expr/reduce.js.map +1 -0
  575. package/dist/expr/regex.d.ts +108 -0
  576. package/dist/expr/regex.d.ts.map +1 -0
  577. package/dist/expr/regex.js +1210 -0
  578. package/dist/expr/regex.js.map +1 -0
  579. package/dist/expr/select-locale.d.ts +67 -0
  580. package/dist/expr/select-locale.d.ts.map +1 -0
  581. package/dist/expr/select-locale.js +219 -0
  582. package/dist/expr/select-locale.js.map +1 -0
  583. package/dist/expr/sequences.d.ts +123 -0
  584. package/dist/expr/sequences.d.ts.map +1 -0
  585. package/dist/expr/sequences.js +234 -0
  586. package/dist/expr/sequences.js.map +1 -0
  587. package/dist/expr/strings.d.ts +50 -0
  588. package/dist/expr/strings.d.ts.map +1 -0
  589. package/dist/expr/strings.js +184 -0
  590. package/dist/expr/strings.js.map +1 -0
  591. package/dist/expr/validation.d.ts +32 -0
  592. package/dist/expr/validation.d.ts.map +1 -0
  593. package/dist/expr/validation.js +182 -0
  594. package/dist/expr/validation.js.map +1 -0
  595. package/dist/graph/freeze.d.ts +4 -0
  596. package/dist/graph/freeze.d.ts.map +1 -0
  597. package/dist/graph/freeze.js +52 -0
  598. package/dist/graph/freeze.js.map +1 -0
  599. package/dist/graph/index.d.ts +15 -0
  600. package/dist/graph/index.d.ts.map +1 -0
  601. package/dist/graph/index.js +13 -0
  602. package/dist/graph/index.js.map +1 -0
  603. package/dist/graph/inspect.d.ts +76 -0
  604. package/dist/graph/inspect.d.ts.map +1 -0
  605. package/dist/graph/inspect.js +263 -0
  606. package/dist/graph/inspect.js.map +1 -0
  607. package/dist/graph/read-walk.d.ts +101 -0
  608. package/dist/graph/read-walk.d.ts.map +1 -0
  609. package/dist/graph/read-walk.js +358 -0
  610. package/dist/graph/read-walk.js.map +1 -0
  611. package/dist/graph/record-index.d.ts +24 -0
  612. package/dist/graph/record-index.d.ts.map +1 -0
  613. package/dist/graph/record-index.js +35 -0
  614. package/dist/graph/record-index.js.map +1 -0
  615. package/dist/index.d.ts +104 -0
  616. package/dist/index.d.ts.map +1 -0
  617. package/dist/index.js +139 -0
  618. package/dist/index.js.map +1 -0
  619. package/dist/lookup/digest.d.ts +51 -0
  620. package/dist/lookup/digest.d.ts.map +1 -0
  621. package/dist/lookup/digest.js +46 -0
  622. package/dist/lookup/digest.js.map +1 -0
  623. package/dist/lookup/index.d.ts +28 -0
  624. package/dist/lookup/index.d.ts.map +1 -0
  625. package/dist/lookup/index.js +27 -0
  626. package/dist/lookup/index.js.map +1 -0
  627. package/dist/lookup/install.d.ts +48 -0
  628. package/dist/lookup/install.d.ts.map +1 -0
  629. package/dist/lookup/install.js +315 -0
  630. package/dist/lookup/install.js.map +1 -0
  631. package/dist/lookup/pass.d.ts +55 -0
  632. package/dist/lookup/pass.d.ts.map +1 -0
  633. package/dist/lookup/pass.js +212 -0
  634. package/dist/lookup/pass.js.map +1 -0
  635. package/dist/lookup/pins.d.ts +34 -0
  636. package/dist/lookup/pins.d.ts.map +1 -0
  637. package/dist/lookup/pins.js +39 -0
  638. package/dist/lookup/pins.js.map +1 -0
  639. package/dist/lookup/provenance.d.ts +23 -0
  640. package/dist/lookup/provenance.d.ts.map +1 -0
  641. package/dist/lookup/provenance.js +78 -0
  642. package/dist/lookup/provenance.js.map +1 -0
  643. package/dist/lookup/readiness.d.ts +13 -0
  644. package/dist/lookup/readiness.d.ts.map +1 -0
  645. package/dist/lookup/readiness.js +57 -0
  646. package/dist/lookup/readiness.js.map +1 -0
  647. package/dist/lookup/resolve.d.ts +24 -0
  648. package/dist/lookup/resolve.d.ts.map +1 -0
  649. package/dist/lookup/resolve.js +201 -0
  650. package/dist/lookup/resolve.js.map +1 -0
  651. package/dist/lookup/store.d.ts +41 -0
  652. package/dist/lookup/store.d.ts.map +1 -0
  653. package/dist/lookup/store.js +74 -0
  654. package/dist/lookup/store.js.map +1 -0
  655. package/dist/model/access.d.ts +200 -0
  656. package/dist/model/access.d.ts.map +1 -0
  657. package/dist/model/access.js +125 -0
  658. package/dist/model/access.js.map +1 -0
  659. package/dist/model/artifact-members.d.ts +3 -0
  660. package/dist/model/artifact-members.d.ts.map +1 -0
  661. package/dist/model/artifact-members.js +38 -0
  662. package/dist/model/artifact-members.js.map +1 -0
  663. package/dist/model/composition.d.ts +47 -0
  664. package/dist/model/composition.d.ts.map +1 -0
  665. package/dist/model/composition.js +66 -0
  666. package/dist/model/composition.js.map +1 -0
  667. package/dist/model/domain.d.ts +51 -0
  668. package/dist/model/domain.d.ts.map +1 -0
  669. package/dist/model/domain.js +75 -0
  670. package/dist/model/domain.js.map +1 -0
  671. package/dist/model/duration.d.ts +31 -0
  672. package/dist/model/duration.d.ts.map +1 -0
  673. package/dist/model/duration.js +136 -0
  674. package/dist/model/duration.js.map +1 -0
  675. package/dist/model/errors.d.ts +58 -0
  676. package/dist/model/errors.d.ts.map +1 -0
  677. package/dist/model/errors.js +81 -0
  678. package/dist/model/errors.js.map +1 -0
  679. package/dist/model/evolution.d.ts +177 -0
  680. package/dist/model/evolution.d.ts.map +1 -0
  681. package/dist/model/evolution.js +5 -0
  682. package/dist/model/evolution.js.map +1 -0
  683. package/dist/model/expr-children.d.ts +15 -0
  684. package/dist/model/expr-children.d.ts.map +1 -0
  685. package/dist/model/expr-children.js +45 -0
  686. package/dist/model/expr-children.js.map +1 -0
  687. package/dist/model/guards.d.ts +9 -0
  688. package/dist/model/guards.d.ts.map +1 -0
  689. package/dist/model/guards.js +11 -0
  690. package/dist/model/guards.js.map +1 -0
  691. package/dist/model/input.d.ts +42 -0
  692. package/dist/model/input.d.ts.map +1 -0
  693. package/dist/model/input.js +26 -0
  694. package/dist/model/input.js.map +1 -0
  695. package/dist/model/integer.d.ts +14 -0
  696. package/dist/model/integer.d.ts.map +1 -0
  697. package/dist/model/integer.js +16 -0
  698. package/dist/model/integer.js.map +1 -0
  699. package/dist/model/intrinsic.d.ts +18 -0
  700. package/dist/model/intrinsic.d.ts.map +1 -0
  701. package/dist/model/intrinsic.js +21 -0
  702. package/dist/model/intrinsic.js.map +1 -0
  703. package/dist/model/layout.d.ts +129 -0
  704. package/dist/model/layout.d.ts.map +1 -0
  705. package/dist/model/layout.js +2 -0
  706. package/dist/model/layout.js.map +1 -0
  707. package/dist/model/media.d.ts +33 -0
  708. package/dist/model/media.d.ts.map +1 -0
  709. package/dist/model/media.js +86 -0
  710. package/dist/model/media.js.map +1 -0
  711. package/dist/model/members.generated.d.ts +11 -0
  712. package/dist/model/members.generated.d.ts.map +1 -0
  713. package/dist/model/members.generated.js +71 -0
  714. package/dist/model/members.generated.js.map +1 -0
  715. package/dist/model/row-address.d.ts +27 -0
  716. package/dist/model/row-address.d.ts.map +1 -0
  717. package/dist/model/row-address.js +146 -0
  718. package/dist/model/row-address.js.map +1 -0
  719. package/dist/model/schema.d.ts +108 -0
  720. package/dist/model/schema.d.ts.map +1 -0
  721. package/dist/model/schema.js +2 -0
  722. package/dist/model/schema.js.map +1 -0
  723. package/dist/model/shape.d.ts +193 -0
  724. package/dist/model/shape.d.ts.map +1 -0
  725. package/dist/model/shape.js +2 -0
  726. package/dist/model/shape.js.map +1 -0
  727. package/dist/model/time.d.ts +61 -0
  728. package/dist/model/time.d.ts.map +1 -0
  729. package/dist/model/time.js +110 -0
  730. package/dist/model/time.js.map +1 -0
  731. package/dist/model/types.d.ts +1329 -0
  732. package/dist/model/types.d.ts.map +1 -0
  733. package/dist/model/types.js +424 -0
  734. package/dist/model/types.js.map +1 -0
  735. package/dist/model/values.d.ts +91 -0
  736. package/dist/model/values.d.ts.map +1 -0
  737. package/dist/model/values.js +195 -0
  738. package/dist/model/values.js.map +1 -0
  739. package/dist/model/wire.d.ts +356 -0
  740. package/dist/model/wire.d.ts.map +1 -0
  741. package/dist/model/wire.js +1504 -0
  742. package/dist/model/wire.js.map +1 -0
  743. package/dist/offline/index.d.ts +374 -0
  744. package/dist/offline/index.d.ts.map +1 -0
  745. package/dist/offline/index.js +422 -0
  746. package/dist/offline/index.js.map +1 -0
  747. package/dist/testing.d.ts +30 -0
  748. package/dist/testing.d.ts.map +1 -0
  749. package/dist/testing.js +42 -0
  750. package/dist/testing.js.map +1 -0
  751. package/dist/version.d.ts +30 -0
  752. package/dist/version.d.ts.map +1 -0
  753. package/dist/version.js +116 -0
  754. package/dist/version.js.map +1 -0
  755. package/package.json +98 -3
@@ -0,0 +1,123 @@
1
+ import type { LiteralDomain, UndeterminedRows, WireValue } from '../model/types.js';
2
+ /**
3
+ * The list operators `sort`, `slice`, `distinct` and `reverse`.
4
+ *
5
+ * Each is an algorithm over a copy of the operand, never an in-place edit: an expression has
6
+ * no identity, so the list a path read must not change under a later rule. The ordering and
7
+ * equality are supplied by the caller — the compiled evaluator passes the language's own
8
+ * `compareOrdered`/`valuesEqual` with the element domains the list carries, and the value-only
9
+ * door passes the same rule stated over literals' declared domains. Keeping the algorithms
10
+ * here means the two doors can differ in what they know, never in what `sort` does.
11
+ */
12
+ /**
13
+ * One element and everything the artifact states about it.
14
+ *
15
+ * A copy must keep the element's whole declaration, not only its primitive: a row carries the
16
+ * domains of its members and the access sidebands naming withheld and unproduced members, and
17
+ * a `slice`/`reverse`/`sort` that dropped them would answer `UNKNOWN` for a projection the
18
+ * unsliced list decides and read a withheld member as an absence.
19
+ */
20
+ export interface SequenceElement {
21
+ readonly value: WireValue;
22
+ readonly domain: LiteralDomain | undefined;
23
+ /** The declared domain of each member, when the producer knew a record's members. */
24
+ readonly memberDomains?: Readonly<Record<string, LiteralDomain>>;
25
+ /** The declared members of a record element, when the producer knew them. */
26
+ readonly closedMembers?: readonly string[];
27
+ /** Dotted member paths withheld below this element's value, relative to the value. */
28
+ readonly withheldMembers?: readonly string[];
29
+ /** Members a writer could not produce, with the sentinel a read of each states. */
30
+ readonly undeterminedMembers?: UndeterminedRows[number];
31
+ }
32
+ /**
33
+ * The measurement a list's equality classes must share.
34
+ *
35
+ * Quantity and duration compare only within one unit and money only within one currency and
36
+ * scale (`MODEL-2.1.21`, `MODEL-2.1.24`); a mixed pair is the same refusal `<`, `sum` and
37
+ * `min` already give rather than a second, unequal class. The scope is the list's, so the
38
+ * first element states the unit every later element must match.
39
+ */
40
+ export interface EqualityScope {
41
+ quantityUnit?: string;
42
+ moneyCurrency?: string;
43
+ moneyScale?: number;
44
+ durationUnit?: string;
45
+ }
46
+ /**
47
+ * The one domain a list's stated elements share, for tokenising an element that states none.
48
+ *
49
+ * A store that omits its `columns` capability hands back a value whose declaration the
50
+ * artifact stated but the runtime did not receive. When every stated sibling agrees on one
51
+ * domain, that domain is the list's (with the numeric pair widening to `decimal`), so the
52
+ * domainless member is compared in it — exactly as `==` compares the two by value. A list
53
+ * that states two unrelated domains returns `undefined`, and each element keeps its own.
54
+ */
55
+ export declare function agreedDomainOf(domains: readonly (LiteralDomain | undefined)[] | undefined): LiteralDomain | undefined;
56
+ /**
57
+ * Checks that one element belongs to the list's measurement, and records it when it is first.
58
+ *
59
+ * A quantity in `kg` and one in `lb` are not two unequal values: v1 defines no unit
60
+ * conversion, so the language refuses to compare them. The message is the one
61
+ * `compareQuantities`/`compareMoney`/`compareDurations` raise, so a value-stated mismatch
62
+ * reads the same through `==`, `sort`, `sum` and `distinct`.
63
+ */
64
+ export declare function observeEquality(element: SequenceElement, scope: EqualityScope, path: string): void;
65
+ /** The ordering and equality the algorithms use. */
66
+ export interface SequenceAlgebra {
67
+ /** The language order of two elements, or `undefined` when their domains have none. */
68
+ compare(left: SequenceElement, right: SequenceElement, path: string): number | undefined;
69
+ /** The language equality of two elements (`EXPR-5.1.10`). */
70
+ equal(left: SequenceElement, right: SequenceElement, path: string): boolean;
71
+ }
72
+ /**
73
+ * The one equality token the language's distinctness operators share: `distinct`, `is_unique`
74
+ * and `count_distinct` all key a class with this function, so the three cannot answer three
75
+ * different questions about the same list. It is the equality rule `==` states — numerics by
76
+ * canonical decimal value across `integer`/`decimal`, money by currency, scale and minor
77
+ * amount, quantity and duration by unit and amount, and the remaining primitives by their
78
+ * canonical text or boolean.
79
+ *
80
+ * The choices the audit left open, now stated:
81
+ * - A domainless text value is its canonical text, with no domain prefix, so it is the same
82
+ * class as a declared `string`/`date`/`instant`/`time` spelling of that text. That is what
83
+ * `==` already answers for the pair (a value with no declaration beside one with a
84
+ * declaration falls back to wire equality), and it is the only reading under which the three
85
+ * operators and `==` agree.
86
+ * - A keyed member's domain is the member's declared primitive: the array's `items`/`fields`
87
+ * declaration for a row, and the element record's own declaration for a list literal of
88
+ * declared record fields. A member declared `string` therefore compares as text even when the
89
+ * value door never carried a per-element member map. Only an undeclared member falls back to
90
+ * the value's own shape, exactly as `valuesEqual` does.
91
+ * - A measurement domain's unit/currency mismatch is not a token at all: `observeEquality`
92
+ * refuses it before this runs, because the language refuses to compare two units rather
93
+ * than calling them unequal.
94
+ *
95
+ * The token is what makes `distinct` linear; it is not the rule, and a record or list element
96
+ * has no token because `distinct` requires a primitive element type at compile time.
97
+ */
98
+ export declare function sequenceToken(element: SequenceElement, path: string): string;
99
+ /**
100
+ * A copy in ascending canonical order, stable: two elements the order calls equal keep the
101
+ * order they arrived in. An element the order cannot place is refused, because a list with an
102
+ * unstably ordered member has no sorted form to return.
103
+ */
104
+ export declare function sortElements(elements: readonly SequenceElement[], algebra: SequenceAlgebra, path: string): readonly SequenceElement[];
105
+ /**
106
+ * The copy with the first occurrence of each value kept, in input order.
107
+ *
108
+ * Distinctness is the equality rule `==` states: numerics by value across `integer`/`decimal`,
109
+ * text by its canonical text, and a domainless member compared in the one domain its siblings
110
+ * state. A list whose quantities differ in unit or whose money differs in currency or scale is
111
+ * refused exactly as `<`, `sum` and `min` refuse it — never split into two classes. The token
112
+ * therefore observes the list's single measurement before it names an equivalence class.
113
+ */
114
+ export declare function distinctElements(elements: readonly SequenceElement[], _algebra: SequenceAlgebra, path: string): readonly SequenceElement[];
115
+ /** The copy in reverse order. */
116
+ export declare function reverseElements(elements: readonly SequenceElement[]): readonly SequenceElement[];
117
+ /**
118
+ * The `count` elements from `start`, clamped to the list: a start at or past the end is empty,
119
+ * and a window that runs past the end stops there. A negative start or count is refused, as
120
+ * `substring` refuses it, so no reading has to guess a clamp the author did not write.
121
+ */
122
+ export declare function sliceElements(elements: readonly SequenceElement[], start: number, count: number, path: string): readonly SequenceElement[];
123
+ //# sourceMappingURL=sequences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequences.d.ts","sourceRoot":"","sources":["../../src/expr/sequences.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKpF;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW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AaD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAoD5E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,MAAM,GACX,SAAS,eAAe,EAAE,CAU5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,MAAM,GACX,SAAS,eAAe,EAAE,CAiB5B;AAED,iCAAiC;AACjC,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,eAAe,EAAE,CAEhG;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,SAAS,eAAe,EAAE,CAQ5B"}
@@ -0,0 +1,234 @@
1
+ import { AxiomError } from '../model/errors.js';
2
+ import { toMoneyValue } from './money.js';
3
+ import { toQuantityValue } from './quantity.js';
4
+ import { toDurationValue } from '../model/duration.js';
5
+ /**
6
+ * The one domain a list's stated elements share, for tokenising an element that states none.
7
+ *
8
+ * A store that omits its `columns` capability hands back a value whose declaration the
9
+ * artifact stated but the runtime did not receive. When every stated sibling agrees on one
10
+ * domain, that domain is the list's (with the numeric pair widening to `decimal`), so the
11
+ * domainless member is compared in it — exactly as `==` compares the two by value. A list
12
+ * that states two unrelated domains returns `undefined`, and each element keeps its own.
13
+ */
14
+ export function agreedDomainOf(domains) {
15
+ if (domains === undefined)
16
+ return undefined;
17
+ let agreed;
18
+ for (const domain of domains) {
19
+ if (domain === undefined)
20
+ continue;
21
+ if (agreed === undefined) {
22
+ agreed = domain;
23
+ continue;
24
+ }
25
+ if (agreed === domain)
26
+ continue;
27
+ if (isNumeric(agreed) && isNumeric(domain)) {
28
+ agreed = 'decimal';
29
+ continue;
30
+ }
31
+ return undefined;
32
+ }
33
+ return agreed;
34
+ }
35
+ function isNumeric(domain) {
36
+ return domain === 'integer' || domain === 'decimal';
37
+ }
38
+ /**
39
+ * Checks that one element belongs to the list's measurement, and records it when it is first.
40
+ *
41
+ * A quantity in `kg` and one in `lb` are not two unequal values: v1 defines no unit
42
+ * conversion, so the language refuses to compare them. The message is the one
43
+ * `compareQuantities`/`compareMoney`/`compareDurations` raise, so a value-stated mismatch
44
+ * reads the same through `==`, `sort`, `sum` and `distinct`.
45
+ */
46
+ export function observeEquality(element, scope, path) {
47
+ if (element.value === null)
48
+ return;
49
+ switch (element.domain) {
50
+ case 'quantity': {
51
+ const quantity = toQuantityValue(element.value, path);
52
+ if (scope.quantityUnit === undefined) {
53
+ scope.quantityUnit = quantity.unit;
54
+ return;
55
+ }
56
+ if (scope.quantityUnit !== quantity.unit) {
57
+ throw new AxiomError('ENGINE_ERROR', `quantity operands differ in unit: ${quantity.unit} and ${scope.quantityUnit}; v1 defines no unit conversion`, path);
58
+ }
59
+ return;
60
+ }
61
+ case 'money': {
62
+ const money = toMoneyValue(element.value, path);
63
+ if (scope.moneyCurrency === undefined) {
64
+ scope.moneyCurrency = money.currency;
65
+ scope.moneyScale = money.scale;
66
+ return;
67
+ }
68
+ if (scope.moneyCurrency !== money.currency || scope.moneyScale !== money.scale) {
69
+ throw new AxiomError('ENGINE_ERROR', `money operands differ in currency or scale: ${money.currency}/${String(money.scale)} and ${scope.moneyCurrency}/${String(scope.moneyScale)}`, path);
70
+ }
71
+ return;
72
+ }
73
+ case 'duration': {
74
+ const duration = toDurationValue(element.value, path);
75
+ if (scope.durationUnit === undefined) {
76
+ scope.durationUnit = duration.unit;
77
+ return;
78
+ }
79
+ if (scope.durationUnit !== duration.unit) {
80
+ throw new AxiomError('ENGINE_ERROR', `duration operands differ in unit: ${duration.unit} and ${scope.durationUnit}; v1 defines no unit conversion`, path);
81
+ }
82
+ return;
83
+ }
84
+ default:
85
+ return;
86
+ }
87
+ }
88
+ /** Canonical decimal text without insignificant zeros: `-0`, `01.10` and `1.1` collapse. */
89
+ function decimalToken(text) {
90
+ const negative = text.startsWith('-');
91
+ const unsigned = negative ? text.slice(1) : text;
92
+ const point = unsigned.indexOf('.');
93
+ const whole = (point === -1 ? unsigned : unsigned.slice(0, point)).replace(/^0+/, '') || '0';
94
+ const fraction = point === -1 ? '' : unsigned.slice(point + 1).replace(/0+$/, '');
95
+ const magnitude = fraction === '' ? whole : `${whole}.${fraction}`;
96
+ return magnitude === '0' ? '0' : `${negative ? '-' : ''}${magnitude}`;
97
+ }
98
+ /**
99
+ * The one equality token the language's distinctness operators share: `distinct`, `is_unique`
100
+ * and `count_distinct` all key a class with this function, so the three cannot answer three
101
+ * different questions about the same list. It is the equality rule `==` states — numerics by
102
+ * canonical decimal value across `integer`/`decimal`, money by currency, scale and minor
103
+ * amount, quantity and duration by unit and amount, and the remaining primitives by their
104
+ * canonical text or boolean.
105
+ *
106
+ * The choices the audit left open, now stated:
107
+ * - A domainless text value is its canonical text, with no domain prefix, so it is the same
108
+ * class as a declared `string`/`date`/`instant`/`time` spelling of that text. That is what
109
+ * `==` already answers for the pair (a value with no declaration beside one with a
110
+ * declaration falls back to wire equality), and it is the only reading under which the three
111
+ * operators and `==` agree.
112
+ * - A keyed member's domain is the member's declared primitive: the array's `items`/`fields`
113
+ * declaration for a row, and the element record's own declaration for a list literal of
114
+ * declared record fields. A member declared `string` therefore compares as text even when the
115
+ * value door never carried a per-element member map. Only an undeclared member falls back to
116
+ * the value's own shape, exactly as `valuesEqual` does.
117
+ * - A measurement domain's unit/currency mismatch is not a token at all: `observeEquality`
118
+ * refuses it before this runs, because the language refuses to compare two units rather
119
+ * than calling them unequal.
120
+ *
121
+ * The token is what makes `distinct` linear; it is not the rule, and a record or list element
122
+ * has no token because `distinct` requires a primitive element type at compile time.
123
+ */
124
+ export function sequenceToken(element, path) {
125
+ const { domain, value } = element;
126
+ // The empty value is one value of every domain, so it is one class in every list.
127
+ if (value === null)
128
+ return 'null';
129
+ if (domain === 'integer' || domain === 'decimal') {
130
+ if (typeof value === 'number' || typeof value === 'string') {
131
+ return `n:${decimalToken(typeof value === 'number' ? String(value) : value)}`;
132
+ }
133
+ throw new AxiomError('ENGINE_ERROR', 'a numeric element is not a number', path);
134
+ }
135
+ switch (domain) {
136
+ case 'money': {
137
+ const money = toMoneyValue(value, path);
138
+ return `m:${money.currency}:${String(money.scale)}:${BigInt(money.minor).toString()}`;
139
+ }
140
+ case 'quantity': {
141
+ const quantity = toQuantityValue(value, path);
142
+ return `q:${quantity.unit}:${decimalToken(quantity.value)}`;
143
+ }
144
+ case 'duration': {
145
+ const duration = toDurationValue(value, path);
146
+ return `d:${duration.unit}:${String(duration.amount)}`;
147
+ }
148
+ case 'boolean':
149
+ if (typeof value !== 'boolean') {
150
+ throw new AxiomError('ENGINE_ERROR', 'a boolean element is not a boolean', path);
151
+ }
152
+ return `b:${String(value)}`;
153
+ case 'string':
154
+ case 'date':
155
+ case 'instant':
156
+ case 'time':
157
+ if (typeof value !== 'string') {
158
+ throw new AxiomError('ENGINE_ERROR', `a ${domain} element is not text`, path);
159
+ }
160
+ return `s:${value}`;
161
+ case undefined:
162
+ if (typeof value === 'number')
163
+ return `n:${decimalToken(String(value))}`;
164
+ if (typeof value === 'string')
165
+ return `s:${value}`;
166
+ if (typeof value === 'boolean')
167
+ return `b:${String(value)}`;
168
+ throw new AxiomError('ENGINE_ERROR', 'an element of no stated domain cannot be compared', path);
169
+ default:
170
+ throw new AxiomError('ENGINE_ERROR', `\`sort\` and \`distinct\` read elements of one primitive domain, got ${domain}`, path);
171
+ }
172
+ }
173
+ /**
174
+ * A copy in ascending canonical order, stable: two elements the order calls equal keep the
175
+ * order they arrived in. An element the order cannot place is refused, because a list with an
176
+ * unstably ordered member has no sorted form to return.
177
+ */
178
+ export function sortElements(elements, algebra, path) {
179
+ const ordered = [...elements];
180
+ ordered.sort((left, right) => {
181
+ const order = algebra.compare(left, right, path);
182
+ if (order === undefined) {
183
+ throw new AxiomError('ENGINE_ERROR', 'sort requires elements of one orderable domain', path);
184
+ }
185
+ return order;
186
+ });
187
+ return ordered;
188
+ }
189
+ /**
190
+ * The copy with the first occurrence of each value kept, in input order.
191
+ *
192
+ * Distinctness is the equality rule `==` states: numerics by value across `integer`/`decimal`,
193
+ * text by its canonical text, and a domainless member compared in the one domain its siblings
194
+ * state. A list whose quantities differ in unit or whose money differs in currency or scale is
195
+ * refused exactly as `<`, `sum` and `min` refuse it — never split into two classes. The token
196
+ * therefore observes the list's single measurement before it names an equivalence class.
197
+ */
198
+ export function distinctElements(elements, _algebra, path) {
199
+ const agreed = agreedDomainOf(elements.map((element) => element.domain));
200
+ const scope = {};
201
+ const seen = new Set();
202
+ const kept = [];
203
+ for (const element of elements) {
204
+ const resolved = element.domain === undefined && agreed !== undefined
205
+ ? { ...element, domain: agreed }
206
+ : element;
207
+ observeEquality(resolved, scope, path);
208
+ const token = sequenceToken(resolved, path);
209
+ if (seen.has(token))
210
+ continue;
211
+ seen.add(token);
212
+ kept.push(element);
213
+ }
214
+ return kept;
215
+ }
216
+ /** The copy in reverse order. */
217
+ export function reverseElements(elements) {
218
+ return [...elements].reverse();
219
+ }
220
+ /**
221
+ * The `count` elements from `start`, clamped to the list: a start at or past the end is empty,
222
+ * and a window that runs past the end stops there. A negative start or count is refused, as
223
+ * `substring` refuses it, so no reading has to guess a clamp the author did not write.
224
+ */
225
+ export function sliceElements(elements, start, count, path) {
226
+ if (!Number.isSafeInteger(start) || start < 0) {
227
+ throw new AxiomError('ENGINE_ERROR', 'slice requires a non-negative integer start', path);
228
+ }
229
+ if (!Number.isSafeInteger(count) || count < 0) {
230
+ throw new AxiomError('ENGINE_ERROR', 'slice requires a non-negative integer count', path);
231
+ }
232
+ return elements.slice(start, start + count);
233
+ }
234
+ //# sourceMappingURL=sequences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequences.js","sourceRoot":"","sources":["../../src/expr/sequences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiDvD;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA2D;IAE3D,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC5C,IAAI,MAAiC,CAAC;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,KAAK,SAAS;YAAE,SAAS;QACnC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,MAAM,CAAC;YAChB,SAAS;QACX,CAAC;QACD,IAAI,MAAM,KAAK,MAAM;YAAE,SAAS;QAChC,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,MAAM,GAAG,SAAS,CAAC;YACnB,SAAS;QACX,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,MAAqB;IACtC,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,CAAC;AACtD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAwB,EACxB,KAAoB,EACpB,IAAY;IAEZ,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;QAAE,OAAO;IACnC,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;QACvB,KAAK,UAAU,EAAE,CAAC;YAChB,MAAM,QAAQ,GAAG,eAAe,C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O,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAAC,QAAoC;IAClE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAoC,EACpC,KAAa,EACb,KAAa,EACb,IAAY;IAEZ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE,6CAA6C,EAAE,IAAI,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE,6CAA6C,EAAE,IAAI,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import { AxiomError } from '../model/errors.js';\nimport type { LiteralDomain, UndeterminedRows, WireValue } from '../model/types.js';\nimport { toMoneyValue } from './money.js';\nimport { toQuantityValue } from './quantity.js';\nimport { toDurationValue } from '../model/duration.js';\n\n/**\n * The list operators `sort`, `slice`, `distinct` and `reverse`.\n *\n * Each is an algorithm over a copy of the operand, never an in-place edit: an expression has\n * no identity, so the list a path read must not change under a later rule. The ordering and\n * equality are supplied by the caller — the compiled evaluator passes the language's own\n * `compareOrdered`/`valuesEqual` with the element domains the list carries, and the value-only\n * door passes the same rule stated over literals' declared domains. Keeping the algorithms\n * here means the two doors can differ in what they know, never in what `sort` does.\n */\n\n/**\n * One element and everything the artifact states about it.\n *\n * A copy must keep the element's whole declaration, not only its primitive: a row carries the\n * domains of its members and the access sidebands naming withheld and unproduced members, and\n * a `slice`/`reverse`/`sort` that dropped them would answer `UNKNOWN` for a projection the\n * unsliced list decides and read a withheld member as an absence.\n */\nexport interface SequenceElement {\n readonly value: WireValue;\n readonly domain: LiteralDomain | undefined;\n /** The declared domain of each member, when the producer knew a record's members. */\n readonly memberDomains?: Readonly<Record<string, LiteralDomain>>;\n /** The declared members of a record element, when the producer knew them. */\n readonly closedMembers?: readonly string[];\n /** Dotted member paths withheld below this element's value, relative to the value. */\n readonly withheldMembers?: readonly string[];\n /** Members a writer could not produce, with the sentinel a read of each states. */\n readonly undeterminedMembers?: UndeterminedRows[number];\n}\n\n/**\n * The measurement a list's equality classes must share.\n *\n * Quantity and duration compare only within one unit and money only within one currency and\n * scale (`MODEL-2.1.21`, `MODEL-2.1.24`); a mixed pair is the same refusal `<`, `sum` and\n * `min` already give rather than a second, unequal class. The scope is the list's, so the\n * first element states the unit every later element must match.\n */\nexport interface EqualityScope {\n quantityUnit?: string;\n moneyCurrency?: string;\n moneyScale?: number;\n durationUnit?: string;\n}\n\n/**\n * The one domain a list's stated elements share, for tokenising an element that states none.\n *\n * A store that omits its `columns` capability hands back a value whose declaration the\n * artifact stated but the runtime did not receive. When every stated sibling agrees on one\n * domain, that domain is the list's (with the numeric pair widening to `decimal`), so the\n * domainless member is compared in it — exactly as `==` compares the two by value. A list\n * that states two unrelated domains returns `undefined`, and each element keeps its own.\n */\nexport function agreedDomainOf(\n domains: readonly (LiteralDomain | undefined)[] | undefined,\n): LiteralDomain | undefined {\n if (domains === undefined) return undefined;\n let agreed: LiteralDomain | undefined;\n for (const domain of domains) {\n if (domain === undefined) continue;\n if (agreed === undefined) {\n agreed = domain;\n continue;\n }\n if (agreed === domain) continue;\n if (isNumeric(agreed) && isNumeric(domain)) {\n agreed = 'decimal';\n continue;\n }\n return undefined;\n }\n return agreed;\n}\n\nfunction isNumeric(domain: LiteralDomain): boolean {\n return domain === 'integer' || domain === 'decimal';\n}\n\n/**\n * Checks that one element belongs to the list's measurement, and records it when it is first.\n *\n * A quantity in `kg` and one in `lb` are not two unequal values: v1 defines no unit\n * conversion, so the language refuses to compare them. The message is the one\n * `compareQuantities`/`compareMoney`/`compareDurations` raise, so a value-stated mismatch\n * reads the same through `==`, `sort`, `sum` and `distinct`.\n */\nexport function observeEquality(\n element: SequenceElement,\n scope: EqualityScope,\n path: string,\n): void {\n if (element.value === null) return;\n switch (element.domain) {\n case 'quantity': {\n const quantity = toQuantityValue(element.value, path);\n if (scope.quantityUnit === undefined) {\n scope.quantityUnit = quantity.unit;\n return;\n }\n if (scope.quantityUnit !== quantity.unit) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `quantity operands differ in unit: ${quantity.unit} and ${scope.quantityUnit}; v1 defines no unit conversion`,\n path,\n );\n }\n return;\n }\n case 'money': {\n const money = toMoneyValue(element.value, path);\n if (scope.moneyCurrency === undefined) {\n scope.moneyCurrency = money.currency;\n scope.moneyScale = money.scale;\n return;\n }\n if (scope.moneyCurrency !== money.currency || scope.moneyScale !== money.scale) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `money operands differ in currency or scale: ${money.currency}/${String(money.scale)} and ${scope.moneyCurrency}/${String(scope.moneyScale)}`,\n path,\n );\n }\n return;\n }\n case 'duration': {\n const duration = toDurationValue(element.value, path);\n if (scope.durationUnit === undefined) {\n scope.durationUnit = duration.unit;\n return;\n }\n if (scope.durationUnit !== duration.unit) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `duration operands differ in unit: ${duration.unit} and ${scope.durationUnit}; v1 defines no unit conversion`,\n path,\n );\n }\n return;\n }\n default:\n return;\n }\n}\n\n/** The ordering and equality the algorithms use. */\nexport interface SequenceAlgebra {\n /** The language order of two elements, or `undefined` when their domains have none. */\n compare(left: SequenceElement, right: SequenceElement, path: string): number | undefined;\n /** The language equality of two elements (`EXPR-5.1.10`). */\n equal(left: SequenceElement, right: SequenceElement, path: string): boolean;\n}\n\n/** Canonical decimal text without insignificant zeros: `-0`, `01.10` and `1.1` collapse. */\nfunction decimalToken(text: string): string {\n const negative = text.startsWith('-');\n const unsigned = negative ? text.slice(1) : text;\n const point = unsigned.indexOf('.');\n const whole = (point === -1 ? unsigned : unsigned.slice(0, point)).replace(/^0+/, '') || '0';\n const fraction = point === -1 ? '' : unsigned.slice(point + 1).replace(/0+$/, '');\n const magnitude = fraction === '' ? whole : `${whole}.${fraction}`;\n return magnitude === '0' ? '0' : `${negative ? '-' : ''}${magnitude}`;\n}\n\n/**\n * The one equality token the language's distinctness operators share: `distinct`, `is_unique`\n * and `count_distinct` all key a class with this function, so the three cannot answer three\n * different questions about the same list. It is the equality rule `==` states — numerics by\n * canonical decimal value across `integer`/`decimal`, money by currency, scale and minor\n * amount, quantity and duration by unit and amount, and the remaining primitives by their\n * canonical text or boolean.\n *\n * The choices the audit left open, now stated:\n * - A domainless text value is its canonical text, with no domain prefix, so it is the same\n * class as a declared `string`/`date`/`instant`/`time` spelling of that text. That is what\n * `==` already answers for the pair (a value with no declaration beside one with a\n * declaration falls back to wire equality), and it is the only reading under which the three\n * operators and `==` agree.\n * - A keyed member's domain is the member's declared primitive: the array's `items`/`fields`\n * declaration for a row, and the element record's own declaration for a list literal of\n * declared record fields. A member declared `string` therefore compares as text even when the\n * value door never carried a per-element member map. Only an undeclared member falls back to\n * the value's own shape, exactly as `valuesEqual` does.\n * - A measurement domain's unit/currency mismatch is not a token at all: `observeEquality`\n * refuses it before this runs, because the language refuses to compare two units rather\n * than calling them unequal.\n *\n * The token is what makes `distinct` linear; it is not the rule, and a record or list element\n * has no token because `distinct` requires a primitive element type at compile time.\n */\nexport function sequenceToken(element: SequenceElement, path: string): string {\n const { domain, value } = element;\n // The empty value is one value of every domain, so it is one class in every list.\n if (value === null) return 'null';\n if (domain === 'integer' || domain === 'decimal') {\n if (typeof value === 'number' || typeof value === 'string') {\n return `n:${decimalToken(typeof value === 'number' ? String(value) : value)}`;\n }\n throw new AxiomError('ENGINE_ERROR', 'a numeric element is not a number', path);\n }\n switch (domain) {\n case 'money': {\n const money = toMoneyValue(value, path);\n return `m:${money.currency}:${String(money.scale)}:${BigInt(money.minor).toString()}`;\n }\n case 'quantity': {\n const quantity = toQuantityValue(value, path);\n return `q:${quantity.unit}:${decimalToken(quantity.value)}`;\n }\n case 'duration': {\n const duration = toDurationValue(value, path);\n return `d:${duration.unit}:${String(duration.amount)}`;\n }\n case 'boolean':\n if (typeof value !== 'boolean') {\n throw new AxiomError('ENGINE_ERROR', 'a boolean element is not a boolean', path);\n }\n return `b:${String(value)}`;\n case 'string':\n case 'date':\n case 'instant':\n case 'time':\n if (typeof value !== 'string') {\n throw new AxiomError('ENGINE_ERROR', `a ${domain} element is not text`, path);\n }\n return `s:${value}`;\n case undefined:\n if (typeof value === 'number') return `n:${decimalToken(String(value))}`;\n if (typeof value === 'string') return `s:${value}`;\n if (typeof value === 'boolean') return `b:${String(value)}`;\n throw new AxiomError(\n 'ENGINE_ERROR',\n 'an element of no stated domain cannot be compared',\n path,\n );\n default:\n throw new AxiomError(\n 'ENGINE_ERROR',\n `\\`sort\\` and \\`distinct\\` read elements of one primitive domain, got ${domain}`,\n path,\n );\n }\n}\n\n/**\n * A copy in ascending canonical order, stable: two elements the order calls equal keep the\n * order they arrived in. An element the order cannot place is refused, because a list with an\n * unstably ordered member has no sorted form to return.\n */\nexport function sortElements(\n elements: readonly SequenceElement[],\n algebra: SequenceAlgebra,\n path: string,\n): readonly SequenceElement[] {\n const ordered = [...elements];\n ordered.sort((left, right) => {\n const order = algebra.compare(left, right, path);\n if (order === undefined) {\n throw new AxiomError('ENGINE_ERROR', 'sort requires elements of one orderable domain', path);\n }\n return order;\n });\n return ordered;\n}\n\n/**\n * The copy with the first occurrence of each value kept, in input order.\n *\n * Distinctness is the equality rule `==` states: numerics by value across `integer`/`decimal`,\n * text by its canonical text, and a domainless member compared in the one domain its siblings\n * state. A list whose quantities differ in unit or whose money differs in currency or scale is\n * refused exactly as `<`, `sum` and `min` refuse it — never split into two classes. The token\n * therefore observes the list's single measurement before it names an equivalence class.\n */\nexport function distinctElements(\n elements: readonly SequenceElement[],\n _algebra: SequenceAlgebra,\n path: string,\n): readonly SequenceElement[] {\n const agreed = agreedDomainOf(elements.map((element) => element.domain));\n const scope: EqualityScope = {};\n const seen = new Set<string>();\n const kept: SequenceElement[] = [];\n for (const element of elements) {\n const resolved =\n element.domain === undefined && agreed !== undefined\n ? { ...element, domain: agreed }\n : element;\n observeEquality(resolved, scope, path);\n const token = sequenceToken(resolved, path);\n if (seen.has(token)) continue;\n seen.add(token);\n kept.push(element);\n }\n return kept;\n}\n\n/** The copy in reverse order. */\nexport function reverseElements(elements: readonly SequenceElement[]): readonly SequenceElement[] {\n return [...elements].reverse();\n}\n\n/**\n * The `count` elements from `start`, clamped to the list: a start at or past the end is empty,\n * and a window that runs past the end stops there. A negative start or count is refused, as\n * `substring` refuses it, so no reading has to guess a clamp the author did not write.\n */\nexport function sliceElements(\n elements: readonly SequenceElement[],\n start: number,\n count: number,\n path: string,\n): readonly SequenceElement[] {\n if (!Number.isSafeInteger(start) || start < 0) {\n throw new AxiomError('ENGINE_ERROR', 'slice requires a non-negative integer start', path);\n }\n if (!Number.isSafeInteger(count) || count < 0) {\n throw new AxiomError('ENGINE_ERROR', 'slice requires a non-negative integer count', path);\n }\n return elements.slice(start, start + count);\n}\n"]}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * String primitives, `spec/semantics/expr-v1.md` section 14.
3
+ *
4
+ * The runtime ships to Node, browsers and React Native's Hermes and reads no locale database,
5
+ * so case mapping is ASCII-only and ordering is by Unicode code point. A host locale can never
6
+ * change the answer, and `len` counts what a reader calls a character (a code point), not the
7
+ * UTF-16 code units a JavaScript string is stored in.
8
+ */
9
+ /** Code points in `text`: a surrogate pair is one character. */
10
+ export declare function codePointLength(text: string): number;
11
+ /** Code point order: UTF-16 code-unit order disagrees for astral text. */
12
+ export declare function compareCodePoints(a: string, b: string): number;
13
+ /** ASCII `A-Z` mapping only: every other code point is returned unchanged. */
14
+ export declare function asciiLower(text: string): string;
15
+ /** ASCII `a-z` mapping only: every other code point is returned unchanged. */
16
+ export declare function asciiUpper(text: string): string;
17
+ /** `trim`: strips leading and trailing ASCII whitespace in one linear scan. */
18
+ export declare function trimAsciiWhitespace(text: string): string;
19
+ /**
20
+ * `replace(s, find, with)`: every non-overlapping occurrence of `find`, left to right, as
21
+ * literal text. The needle is never a pattern, so no character in it is special
22
+ * (`EXPR-14.1.7`).
23
+ *
24
+ * The scan is over code points, so a needle that is astral text matches at a character
25
+ * boundary and the replacement is inserted whole. An empty `find` has no occurrence rule
26
+ * that is not degenerate, so the caller refuses it before this runs.
27
+ */
28
+ export declare function replaceAllLiteral(text: string, find: string, replacement: string): string;
29
+ /**
30
+ * `split(s, separator)`: the text between literal occurrences of `separator`, left to right.
31
+ * An empty `separator` is refused by the caller, because splitting on it has no segment rule
32
+ * the language states. An empty subject is one empty segment, not zero segments
33
+ * (`EXPR-14.1.8`).
34
+ */
35
+ export declare function splitLiteral(text: string, separator: string): string[];
36
+ /**
37
+ * `substring(s, start, length)`: `length` code points from `start`, clamped to the text.
38
+ *
39
+ * The caller refuses a negative `start` or `length`; here they are non-negative, so the only
40
+ * boundary left is the end of the text: a `start` at or past the end is the empty string, and
41
+ * a window that runs past the end stops at the end (`EXPR-14.1.9`).
42
+ */
43
+ export declare function substringCodePoints(text: string, start: number, length: number): string;
44
+ /**
45
+ * `index_of(s, find)`: the code-point index of the first literal occurrence of `find`, or
46
+ * `-1` when the text does not contain it. An empty `find` occurs at index `0`, which is the
47
+ * only index it can be said to start at (`EXPR-14.1.10`).
48
+ */
49
+ export declare function indexOfCodePoints(text: string, find: string): number;
50
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/expr/strings.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASpD;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9D;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAYD,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAcD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAyBzF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CA2BtE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOvF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAYpE"}
@@ -0,0 +1,184 @@
1
+ import { AxiomError } from '../model/errors.js';
2
+ /**
3
+ * String primitives, `spec/semantics/expr-v1.md` section 14.
4
+ *
5
+ * The runtime ships to Node, browsers and React Native's Hermes and reads no locale database,
6
+ * so case mapping is ASCII-only and ordering is by Unicode code point. A host locale can never
7
+ * change the answer, and `len` counts what a reader calls a character (a code point), not the
8
+ * UTF-16 code units a JavaScript string is stored in.
9
+ */
10
+ /** Code points in `text`: a surrogate pair is one character. */
11
+ export function codePointLength(text) {
12
+ let count = 0;
13
+ let index = 0;
14
+ while (index < text.length) {
15
+ const code = text.codePointAt(index) ?? 0;
16
+ index += code > 0xffff ? 2 : 1;
17
+ count += 1;
18
+ }
19
+ return count;
20
+ }
21
+ /** Code point order: UTF-16 code-unit order disagrees for astral text. */
22
+ export function compareCodePoints(a, b) {
23
+ let leftIndex = 0;
24
+ let rightIndex = 0;
25
+ while (leftIndex < a.length && rightIndex < b.length) {
26
+ const x = a.codePointAt(leftIndex) ?? 0;
27
+ const y = b.codePointAt(rightIndex) ?? 0;
28
+ if (x !== y)
29
+ return x < y ? -1 : 1;
30
+ leftIndex += x > 0xffff ? 2 : 1;
31
+ rightIndex += y > 0xffff ? 2 : 1;
32
+ }
33
+ if (leftIndex >= a.length && rightIndex >= b.length)
34
+ return 0;
35
+ return leftIndex >= a.length ? -1 : 1;
36
+ }
37
+ /** ASCII `A-Z` mapping only: every other code point is returned unchanged. */
38
+ export function asciiLower(text) {
39
+ let result = '';
40
+ for (const character of text) {
41
+ const code = character.codePointAt(0) ?? 0;
42
+ result += code >= 0x41 && code <= 0x5a ? String.fromCharCode(code + 0x20) : character;
43
+ }
44
+ return result;
45
+ }
46
+ /** ASCII `a-z` mapping only: every other code point is returned unchanged. */
47
+ export function asciiUpper(text) {
48
+ let result = '';
49
+ for (const character of text) {
50
+ const code = character.codePointAt(0) ?? 0;
51
+ result += code >= 0x61 && code <= 0x7a ? String.fromCharCode(code - 0x20) : character;
52
+ }
53
+ return result;
54
+ }
55
+ /**
56
+ * Whether `code` is ASCII whitespace: space, tab, line feed, carriage
57
+ * return, vertical tab and form feed. A no-break space, an em space and every other
58
+ * Unicode space are data, not padding, because the result must not depend on a locale or
59
+ * on a Unicode table this runtime does not carry.
60
+ */
61
+ function isAsciiWhitespace(code) {
62
+ return code === 0x20 || (code >= 0x09 && code <= 0x0d);
63
+ }
64
+ /** `trim`: strips leading and trailing ASCII whitespace in one linear scan. */
65
+ export function trimAsciiWhitespace(text) {
66
+ let start = 0;
67
+ let end = text.length;
68
+ while (start < end && isAsciiWhitespace(text.charCodeAt(start)))
69
+ start += 1;
70
+ while (end > start && isAsciiWhitespace(text.charCodeAt(end - 1)))
71
+ end -= 1;
72
+ return text.slice(start, end);
73
+ }
74
+ /**
75
+ * The code points of `text`, each one element of the result. A JavaScript string is a
76
+ * sequence of UTF-16 code units, so `Array.from` is the conversion that keeps a surrogate
77
+ * pair — one reader-visible character — as one element rather than two.
78
+ *
79
+ * Every string operator below indexes this array, which is what makes `substring`, `split`
80
+ * and `index_of` count characters rather than code units (`EXPR-14.1.1`, `EXPR-14.1.7`).
81
+ */
82
+ function codePoints(text) {
83
+ return Array.from(text);
84
+ }
85
+ /**
86
+ * `replace(s, find, with)`: every non-overlapping occurrence of `find`, left to right, as
87
+ * literal text. The needle is never a pattern, so no character in it is special
88
+ * (`EXPR-14.1.7`).
89
+ *
90
+ * The scan is over code points, so a needle that is astral text matches at a character
91
+ * boundary and the replacement is inserted whole. An empty `find` has no occurrence rule
92
+ * that is not degenerate, so the caller refuses it before this runs.
93
+ */
94
+ export function replaceAllLiteral(text, find, replacement) {
95
+ const subject = codePoints(text);
96
+ const needle = codePoints(find);
97
+ if (needle.length === 0) {
98
+ throw new AxiomError('ENGINE_ERROR', 'replaceAllLiteral requires a non-empty needle; the caller refuses it first');
99
+ }
100
+ let result = '';
101
+ let index = 0;
102
+ while (index < subject.length) {
103
+ let matches = index + needle.length <= subject.length;
104
+ for (let offset = 0; matches && offset < needle.length; offset += 1) {
105
+ matches = subject[index + offset] === needle[offset];
106
+ }
107
+ if (matches) {
108
+ result += replacement;
109
+ index += needle.length;
110
+ continue;
111
+ }
112
+ result += subject[index] ?? '';
113
+ index += 1;
114
+ }
115
+ return result;
116
+ }
117
+ /**
118
+ * `split(s, separator)`: the text between literal occurrences of `separator`, left to right.
119
+ * An empty `separator` is refused by the caller, because splitting on it has no segment rule
120
+ * the language states. An empty subject is one empty segment, not zero segments
121
+ * (`EXPR-14.1.8`).
122
+ */
123
+ export function splitLiteral(text, separator) {
124
+ const subject = codePoints(text);
125
+ const needle = codePoints(separator);
126
+ if (needle.length === 0) {
127
+ throw new AxiomError('ENGINE_ERROR', 'splitLiteral requires a non-empty separator; the caller refuses it first');
128
+ }
129
+ const segments = [];
130
+ let start = 0;
131
+ let index = 0;
132
+ while (index < subject.length) {
133
+ let matches = index + needle.length <= subject.length;
134
+ for (let offset = 0; matches && offset < needle.length; offset += 1) {
135
+ matches = subject[index + offset] === needle[offset];
136
+ }
137
+ if (matches) {
138
+ segments.push(subject.slice(start, index).join(''));
139
+ index += needle.length;
140
+ start = index;
141
+ continue;
142
+ }
143
+ index += 1;
144
+ }
145
+ segments.push(subject.slice(start).join(''));
146
+ return segments;
147
+ }
148
+ /**
149
+ * `substring(s, start, length)`: `length` code points from `start`, clamped to the text.
150
+ *
151
+ * The caller refuses a negative `start` or `length`; here they are non-negative, so the only
152
+ * boundary left is the end of the text: a `start` at or past the end is the empty string, and
153
+ * a window that runs past the end stops at the end (`EXPR-14.1.9`).
154
+ */
155
+ export function substringCodePoints(text, start, length) {
156
+ const subject = codePoints(text);
157
+ if (start >= subject.length || length === 0)
158
+ return '';
159
+ // The window is clamped before the addition, so a `start + length` pair near the
160
+ // canonical integer ceiling cannot overflow into an imprecise sum.
161
+ const end = length >= subject.length - start ? subject.length : start + length;
162
+ return subject.slice(start, end).join('');
163
+ }
164
+ /**
165
+ * `index_of(s, find)`: the code-point index of the first literal occurrence of `find`, or
166
+ * `-1` when the text does not contain it. An empty `find` occurs at index `0`, which is the
167
+ * only index it can be said to start at (`EXPR-14.1.10`).
168
+ */
169
+ export function indexOfCodePoints(text, find) {
170
+ const subject = codePoints(text);
171
+ const needle = codePoints(find);
172
+ if (needle.length === 0)
173
+ return 0;
174
+ for (let index = 0; index + needle.length <= subject.length; index += 1) {
175
+ let matches = true;
176
+ for (let offset = 0; matches && offset < needle.length; offset += 1) {
177
+ matches = subject[index + offset] === needle[offset];
178
+ }
179
+ if (matches)
180
+ return index;
181
+ }
182
+ return -1;
183
+ }
184
+ //# sourceMappingURL=strings.js.map