@elaraai/east 1.0.79 → 1.0.81

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 (379) hide show
  1. package/README.md +1 -1
  2. package/dist/src/builtins.d.ts +1 -1
  3. package/dist/src/builtins.d.ts.map +1 -1
  4. package/dist/src/builtins.js +19 -0
  5. package/dist/src/builtins.js.map +1 -1
  6. package/dist/src/codegen/spellings.d.ts.map +1 -1
  7. package/dist/src/codegen/spellings.js +3 -0
  8. package/dist/src/codegen/spellings.js.map +1 -1
  9. package/dist/src/comparison.d.ts +54 -0
  10. package/dist/src/comparison.d.ts.map +1 -1
  11. package/dist/src/comparison.equivalent.spec.d.ts +6 -0
  12. package/dist/src/comparison.equivalent.spec.d.ts.map +1 -0
  13. package/dist/src/comparison.equivalent.spec.js +130 -0
  14. package/dist/src/comparison.equivalent.spec.js.map +1 -0
  15. package/dist/src/comparison.js +97 -25
  16. package/dist/src/comparison.js.map +1 -1
  17. package/dist/src/compile/builtins/array.d.ts +60 -0
  18. package/dist/src/compile/builtins/array.d.ts.map +1 -0
  19. package/dist/src/compile/builtins/array.js +691 -0
  20. package/dist/src/compile/builtins/array.js.map +1 -0
  21. package/dist/src/compile/builtins/blob.d.ts +18 -0
  22. package/dist/src/compile/builtins/blob.d.ts.map +1 -0
  23. package/dist/src/compile/builtins/blob.js +150 -0
  24. package/dist/src/compile/builtins/blob.js.map +1 -0
  25. package/dist/src/compile/builtins/compare.d.ts +18 -0
  26. package/dist/src/compile/builtins/compare.d.ts.map +1 -0
  27. package/dist/src/compile/builtins/compare.js +52 -0
  28. package/dist/src/compile/builtins/compare.js.map +1 -0
  29. package/dist/src/compile/builtins/datetime.d.ts +21 -0
  30. package/dist/src/compile/builtins/datetime.d.ts.map +1 -0
  31. package/dist/src/compile/builtins/datetime.js +46 -0
  32. package/dist/src/compile/builtins/datetime.js.map +1 -0
  33. package/dist/src/compile/builtins/dict.d.ts +47 -0
  34. package/dist/src/compile/builtins/dict.d.ts.map +1 -0
  35. package/dist/src/compile/builtins/dict.js +576 -0
  36. package/dist/src/compile/builtins/dict.js.map +1 -0
  37. package/dist/src/compile/builtins/index.d.ts +9 -0
  38. package/dist/src/compile/builtins/index.d.ts.map +1 -0
  39. package/dist/src/compile/builtins/index.js +28 -0
  40. package/dist/src/compile/builtins/index.js.map +1 -0
  41. package/dist/src/compile/builtins/matrix.d.ts +31 -0
  42. package/dist/src/compile/builtins/matrix.d.ts.map +1 -0
  43. package/dist/src/compile/builtins/matrix.js +310 -0
  44. package/dist/src/compile/builtins/matrix.js.map +1 -0
  45. package/dist/src/compile/builtins/primitives.d.ts +36 -0
  46. package/dist/src/compile/builtins/primitives.d.ts.map +1 -0
  47. package/dist/src/compile/builtins/primitives.js +67 -0
  48. package/dist/src/compile/builtins/primitives.js.map +1 -0
  49. package/dist/src/compile/builtins/ref.d.ts +11 -0
  50. package/dist/src/compile/builtins/ref.d.ts.map +1 -0
  51. package/dist/src/compile/builtins/ref.js +30 -0
  52. package/dist/src/compile/builtins/ref.js.map +1 -0
  53. package/dist/src/compile/builtins/set.d.ts +42 -0
  54. package/dist/src/compile/builtins/set.d.ts.map +1 -0
  55. package/dist/src/compile/builtins/set.js +410 -0
  56. package/dist/src/compile/builtins/set.js.map +1 -0
  57. package/dist/src/compile/builtins/sparse.d.ts +19 -0
  58. package/dist/src/compile/builtins/sparse.d.ts.map +1 -0
  59. package/dist/src/compile/builtins/sparse.js +143 -0
  60. package/dist/src/compile/builtins/sparse.js.map +1 -0
  61. package/dist/src/compile/builtins/string.d.ts +34 -0
  62. package/dist/src/compile/builtins/string.d.ts.map +1 -0
  63. package/dist/src/compile/builtins/string.js +238 -0
  64. package/dist/src/compile/builtins/string.js.map +1 -0
  65. package/dist/src/compile/builtins/tree.d.ts +32 -0
  66. package/dist/src/compile/builtins/tree.d.ts.map +1 -0
  67. package/dist/src/compile/builtins/tree.js +108 -0
  68. package/dist/src/compile/builtins/tree.js.map +1 -0
  69. package/dist/src/compile/builtins/vector.d.ts +44 -0
  70. package/dist/src/compile/builtins/vector.d.ts.map +1 -0
  71. package/dist/src/compile/builtins/vector.js +463 -0
  72. package/dist/src/compile/builtins/vector.js.map +1 -0
  73. package/dist/src/compile/constructors.d.ts +13 -0
  74. package/dist/src/compile/constructors.d.ts.map +1 -0
  75. package/dist/src/compile/constructors.js +179 -0
  76. package/dist/src/compile/constructors.js.map +1 -0
  77. package/dist/src/compile/control.d.ts +13 -0
  78. package/dist/src/compile/control.d.ts.map +1 -0
  79. package/dist/src/compile/control.js +513 -0
  80. package/dist/src/compile/control.js.map +1 -0
  81. package/dist/src/compile/functions.d.ts +13 -0
  82. package/dist/src/compile/functions.d.ts.map +1 -0
  83. package/dist/src/compile/functions.js +492 -0
  84. package/dist/src/compile/functions.js.map +1 -0
  85. package/dist/src/compile/ir.d.ts +19 -0
  86. package/dist/src/compile/ir.d.ts.map +1 -0
  87. package/dist/src/compile/ir.js +193 -0
  88. package/dist/src/compile/ir.js.map +1 -0
  89. package/dist/src/compile/runtime.d.ts +75 -0
  90. package/dist/src/compile/runtime.d.ts.map +1 -0
  91. package/dist/src/compile/runtime.js +114 -0
  92. package/dist/src/compile/runtime.js.map +1 -0
  93. package/dist/src/compile/type_parameters.d.ts +4 -0
  94. package/dist/src/compile/type_parameters.d.ts.map +1 -0
  95. package/dist/src/compile/type_parameters.js +55 -0
  96. package/dist/src/compile/type_parameters.js.map +1 -0
  97. package/dist/src/compile/typed_arrays.d.ts +28 -0
  98. package/dist/src/compile/typed_arrays.d.ts.map +1 -0
  99. package/dist/src/compile/typed_arrays.js +77 -0
  100. package/dist/src/compile/typed_arrays.js.map +1 -0
  101. package/dist/src/compile.d.ts +6 -41
  102. package/dist/src/compile.d.ts.map +1 -1
  103. package/dist/src/compile.js +8 -4415
  104. package/dist/src/compile.js.map +1 -1
  105. package/dist/src/compile.open_beast.spec.js +5 -4
  106. package/dist/src/compile.open_beast.spec.js.map +1 -1
  107. package/dist/src/compile.signature.spec.d.ts +6 -0
  108. package/dist/src/compile.signature.spec.d.ts.map +1 -0
  109. package/dist/src/compile.signature.spec.js +53 -0
  110. package/dist/src/compile.signature.spec.js.map +1 -0
  111. package/dist/src/containers/sortedmap.d.ts +2 -1
  112. package/dist/src/containers/sortedmap.d.ts.map +1 -1
  113. package/dist/src/containers/sortedmap.js +4 -2
  114. package/dist/src/containers/sortedmap.js.map +1 -1
  115. package/dist/src/containers/sortedset.d.ts +2 -1
  116. package/dist/src/containers/sortedset.d.ts.map +1 -1
  117. package/dist/src/containers/sortedset.js +4 -2
  118. package/dist/src/containers/sortedset.js.map +1 -1
  119. package/dist/src/error.d.ts +15 -0
  120. package/dist/src/error.d.ts.map +1 -1
  121. package/dist/src/error.js +16 -0
  122. package/dist/src/error.js.map +1 -1
  123. package/dist/src/expr/array.d.ts +158 -81
  124. package/dist/src/expr/array.d.ts.map +1 -1
  125. package/dist/src/expr/array.js +68 -51
  126. package/dist/src/expr/array.js.map +1 -1
  127. package/dist/src/expr/ast.d.ts.map +1 -1
  128. package/dist/src/expr/ast.js +13 -0
  129. package/dist/src/expr/ast.js.map +1 -1
  130. package/dist/src/expr/blob.d.ts +8 -8
  131. package/dist/src/expr/blob.js +8 -8
  132. package/dist/src/expr/block.d.ts +18 -5
  133. package/dist/src/expr/block.d.ts.map +1 -1
  134. package/dist/src/expr/block.js +19 -0
  135. package/dist/src/expr/block.js.map +1 -1
  136. package/dist/src/expr/boolean.d.ts +10 -10
  137. package/dist/src/expr/boolean.js +10 -10
  138. package/dist/src/expr/datetime.d.ts +28 -28
  139. package/dist/src/expr/datetime.js +28 -28
  140. package/dist/src/expr/dict.d.ts +101 -51
  141. package/dist/src/expr/dict.d.ts.map +1 -1
  142. package/dist/src/expr/dict.js +97 -36
  143. package/dist/src/expr/dict.js.map +1 -1
  144. package/dist/src/expr/float.d.ts +23 -23
  145. package/dist/src/expr/float.js +23 -23
  146. package/dist/src/expr/integer.d.ts +17 -17
  147. package/dist/src/expr/integer.js +11 -11
  148. package/dist/src/expr/libs/array.d.ts +6 -6
  149. package/dist/src/expr/libs/array.js +6 -6
  150. package/dist/src/expr/libs/blob.d.ts +2 -2
  151. package/dist/src/expr/libs/blob.js +2 -2
  152. package/dist/src/expr/libs/datetime.d.ts +25 -25
  153. package/dist/src/expr/libs/datetime.js +25 -25
  154. package/dist/src/expr/libs/dict.d.ts +2 -2
  155. package/dist/src/expr/libs/dict.js +2 -2
  156. package/dist/src/expr/libs/float.d.ts +15 -15
  157. package/dist/src/expr/libs/float.js +15 -15
  158. package/dist/src/expr/libs/integer.d.ts +12 -12
  159. package/dist/src/expr/libs/integer.js +12 -12
  160. package/dist/src/expr/libs/set.d.ts +2 -2
  161. package/dist/src/expr/libs/set.js +2 -2
  162. package/dist/src/expr/libs/string.d.ts +4 -4
  163. package/dist/src/expr/libs/string.js +4 -4
  164. package/dist/src/expr/recursive.d.ts +22 -5
  165. package/dist/src/expr/recursive.d.ts.map +1 -1
  166. package/dist/src/expr/recursive.js +22 -5
  167. package/dist/src/expr/recursive.js.map +1 -1
  168. package/dist/src/expr/ref.d.ts +5 -5
  169. package/dist/src/expr/ref.js +5 -5
  170. package/dist/src/expr/set.d.ts +96 -51
  171. package/dist/src/expr/set.d.ts.map +1 -1
  172. package/dist/src/expr/set.js +85 -29
  173. package/dist/src/expr/set.js.map +1 -1
  174. package/dist/src/expr/string.d.ts +28 -28
  175. package/dist/src/expr/string.js +28 -28
  176. package/dist/src/expr/struct.d.ts.map +1 -1
  177. package/dist/src/expr/struct.js +2 -2
  178. package/dist/src/expr/variant.d.ts +12 -12
  179. package/dist/src/expr/variant.js +7 -7
  180. package/dist/src/function_symbols.d.ts +28 -0
  181. package/dist/src/function_symbols.d.ts.map +1 -0
  182. package/dist/src/function_symbols.js +28 -0
  183. package/dist/src/function_symbols.js.map +1 -0
  184. package/dist/src/index.d.ts +1 -0
  185. package/dist/src/index.d.ts.map +1 -1
  186. package/dist/src/index.js +1 -0
  187. package/dist/src/index.js.map +1 -1
  188. package/dist/src/location.d.ts +32 -0
  189. package/dist/src/location.d.ts.map +1 -1
  190. package/dist/src/location.js +38 -0
  191. package/dist/src/location.js.map +1 -1
  192. package/dist/src/location.spec.js +89 -1
  193. package/dist/src/location.spec.js.map +1 -1
  194. package/dist/src/patch/index.d.ts +1 -1
  195. package/dist/src/patch/index.d.ts.map +1 -1
  196. package/dist/src/patch/index.js +1 -1
  197. package/dist/src/patch/index.js.map +1 -1
  198. package/dist/src/patch/type_of_patch.d.ts +25 -1
  199. package/dist/src/patch/type_of_patch.d.ts.map +1 -1
  200. package/dist/src/patch/type_of_patch.js +33 -10
  201. package/dist/src/patch/type_of_patch.js.map +1 -1
  202. package/dist/src/platform.spec.js +19 -1
  203. package/dist/src/platform.spec.js.map +1 -1
  204. package/dist/src/runner_protocol.d.ts +357 -0
  205. package/dist/src/runner_protocol.d.ts.map +1 -0
  206. package/dist/src/runner_protocol.js +154 -0
  207. package/dist/src/runner_protocol.js.map +1 -0
  208. package/dist/src/serialization/beast2/index.d.ts +22 -5
  209. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  210. package/dist/src/serialization/beast2/index.js +13 -2
  211. package/dist/src/serialization/beast2/index.js.map +1 -1
  212. package/dist/src/serialization/beast2/index.spec.js +84 -3
  213. package/dist/src/serialization/beast2/index.spec.js.map +1 -1
  214. package/dist/src/serialization/beast2/shared.d.ts +32 -3
  215. package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
  216. package/dist/src/serialization/beast2/shared.js +135 -10
  217. package/dist/src/serialization/beast2/shared.js.map +1 -1
  218. package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
  219. package/dist/src/serialization/beast2/v4/container.js +5 -3
  220. package/dist/src/serialization/beast2/v4/container.js.map +1 -1
  221. package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts +6 -0
  222. package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts.map +1 -0
  223. package/dist/src/serialization/beast2/v5/aliasing.spec.js +75 -0
  224. package/dist/src/serialization/beast2/v5/aliasing.spec.js.map +1 -0
  225. package/dist/src/serialization/beast2/v5/boundary.d.ts +176 -0
  226. package/dist/src/serialization/beast2/v5/boundary.d.ts.map +1 -0
  227. package/dist/src/serialization/beast2/v5/boundary.js +297 -0
  228. package/dist/src/serialization/beast2/v5/boundary.js.map +1 -0
  229. package/dist/src/serialization/beast2/v5/boundary.spec.d.ts +6 -0
  230. package/dist/src/serialization/beast2/v5/boundary.spec.d.ts.map +1 -0
  231. package/dist/src/serialization/beast2/v5/boundary.spec.js +479 -0
  232. package/dist/src/serialization/beast2/v5/boundary.spec.js.map +1 -0
  233. package/dist/src/serialization/beast2/v5/canonical.d.ts +101 -0
  234. package/dist/src/serialization/beast2/v5/canonical.d.ts.map +1 -0
  235. package/dist/src/serialization/beast2/v5/canonical.js +436 -0
  236. package/dist/src/serialization/beast2/v5/canonical.js.map +1 -0
  237. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts +6 -0
  238. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts.map +1 -0
  239. package/dist/src/serialization/beast2/v5/canonical.spec.js +124 -0
  240. package/dist/src/serialization/beast2/v5/canonical.spec.js.map +1 -0
  241. package/dist/src/serialization/beast2/v5/codec.d.ts +6 -5
  242. package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
  243. package/dist/src/serialization/beast2/v5/codec.js +18 -3
  244. package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
  245. package/dist/src/serialization/beast2/v5/deflate.d.ts +24 -2
  246. package/dist/src/serialization/beast2/v5/deflate.d.ts.map +1 -1
  247. package/dist/src/serialization/beast2/v5/deflate.js +47 -12
  248. package/dist/src/serialization/beast2/v5/deflate.js.map +1 -1
  249. package/dist/src/serialization/beast2/v5/deflate.spec.js +15 -1
  250. package/dist/src/serialization/beast2/v5/deflate.spec.js.map +1 -1
  251. package/dist/src/serialization/beast2/v5/elements.d.ts +66 -0
  252. package/dist/src/serialization/beast2/v5/elements.d.ts.map +1 -0
  253. package/dist/src/serialization/beast2/v5/elements.js +325 -0
  254. package/dist/src/serialization/beast2/v5/elements.js.map +1 -0
  255. package/dist/src/serialization/beast2/v5/elements.spec.d.ts +6 -0
  256. package/dist/src/serialization/beast2/v5/elements.spec.d.ts.map +1 -0
  257. package/dist/src/serialization/beast2/v5/elements.spec.js +161 -0
  258. package/dist/src/serialization/beast2/v5/elements.spec.js.map +1 -0
  259. package/dist/src/serialization/beast2/v5/frame-pool.d.ts +62 -21
  260. package/dist/src/serialization/beast2/v5/frame-pool.d.ts.map +1 -1
  261. package/dist/src/serialization/beast2/v5/frame-pool.js +138 -27
  262. package/dist/src/serialization/beast2/v5/frame-pool.js.map +1 -1
  263. package/dist/src/serialization/beast2/v5/frame-pool.spec.js +198 -71
  264. package/dist/src/serialization/beast2/v5/frame-pool.spec.js.map +1 -1
  265. package/dist/src/serialization/beast2/v5/frame-worker.js +25 -15
  266. package/dist/src/serialization/beast2/v5/frame-worker.js.map +1 -1
  267. package/dist/src/serialization/beast2/v5/frames.d.ts +22 -12
  268. package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
  269. package/dist/src/serialization/beast2/v5/frames.js +52 -27
  270. package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
  271. package/dist/src/serialization/beast2/v5/geometry.d.ts +38 -1
  272. package/dist/src/serialization/beast2/v5/geometry.d.ts.map +1 -1
  273. package/dist/src/serialization/beast2/v5/geometry.js +73 -1
  274. package/dist/src/serialization/beast2/v5/geometry.js.map +1 -1
  275. package/dist/src/serialization/beast2/v5/geometry.spec.js +34 -23
  276. package/dist/src/serialization/beast2/v5/geometry.spec.js.map +1 -1
  277. package/dist/src/serialization/beast2/v5/index.spec.js +32 -28
  278. package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
  279. package/dist/src/serialization/beast2/v5/intake.d.ts +98 -0
  280. package/dist/src/serialization/beast2/v5/intake.d.ts.map +1 -0
  281. package/dist/src/serialization/beast2/v5/intake.js +462 -0
  282. package/dist/src/serialization/beast2/v5/intake.js.map +1 -0
  283. package/dist/src/serialization/beast2/v5/intake.spec.d.ts +6 -0
  284. package/dist/src/serialization/beast2/v5/intake.spec.d.ts.map +1 -0
  285. package/dist/src/serialization/beast2/v5/intake.spec.js +202 -0
  286. package/dist/src/serialization/beast2/v5/intake.spec.js.map +1 -0
  287. package/dist/src/serialization/beast2/v5/lazy.d.ts +42 -1
  288. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  289. package/dist/src/serialization/beast2/v5/lazy.js +143 -28
  290. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  291. package/dist/src/serialization/beast2/v5/lazy.spec.js +102 -24
  292. package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
  293. package/dist/src/serialization/beast2/v5/manifest-writer.d.ts +110 -0
  294. package/dist/src/serialization/beast2/v5/manifest-writer.d.ts.map +1 -0
  295. package/dist/src/serialization/beast2/v5/manifest-writer.js +118 -0
  296. package/dist/src/serialization/beast2/v5/manifest-writer.js.map +1 -0
  297. package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts +6 -0
  298. package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts.map +1 -0
  299. package/dist/src/serialization/beast2/v5/manifest-writer.spec.js +207 -0
  300. package/dist/src/serialization/beast2/v5/manifest-writer.spec.js.map +1 -0
  301. package/dist/src/serialization/beast2/v5/manifest.d.ts +241 -0
  302. package/dist/src/serialization/beast2/v5/manifest.d.ts.map +1 -0
  303. package/dist/src/serialization/beast2/v5/manifest.js +233 -0
  304. package/dist/src/serialization/beast2/v5/manifest.js.map +1 -0
  305. package/dist/src/serialization/beast2/v5/merge.d.ts +93 -0
  306. package/dist/src/serialization/beast2/v5/merge.d.ts.map +1 -0
  307. package/dist/src/serialization/beast2/v5/merge.js +202 -0
  308. package/dist/src/serialization/beast2/v5/merge.js.map +1 -0
  309. package/dist/src/serialization/beast2/v5/merge.spec.d.ts +6 -0
  310. package/dist/src/serialization/beast2/v5/merge.spec.d.ts.map +1 -0
  311. package/dist/src/serialization/beast2/v5/merge.spec.js +118 -0
  312. package/dist/src/serialization/beast2/v5/merge.spec.js.map +1 -0
  313. package/dist/src/serialization/beast2/v5/recut.d.ts +143 -0
  314. package/dist/src/serialization/beast2/v5/recut.d.ts.map +1 -0
  315. package/dist/src/serialization/beast2/v5/recut.js +365 -0
  316. package/dist/src/serialization/beast2/v5/recut.js.map +1 -0
  317. package/dist/src/serialization/beast2/v5/recut.spec.d.ts +6 -0
  318. package/dist/src/serialization/beast2/v5/recut.spec.d.ts.map +1 -0
  319. package/dist/src/serialization/beast2/v5/recut.spec.js +215 -0
  320. package/dist/src/serialization/beast2/v5/recut.spec.js.map +1 -0
  321. package/dist/src/serialization/beast2/v5/runs.d.ts +148 -0
  322. package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -0
  323. package/dist/src/serialization/beast2/v5/runs.js +260 -0
  324. package/dist/src/serialization/beast2/v5/runs.js.map +1 -0
  325. package/dist/src/serialization/beast2/v5/runs.spec.d.ts +6 -0
  326. package/dist/src/serialization/beast2/v5/runs.spec.d.ts.map +1 -0
  327. package/dist/src/serialization/beast2/v5/runs.spec.js +182 -0
  328. package/dist/src/serialization/beast2/v5/runs.spec.js.map +1 -0
  329. package/dist/src/serialization/beast2/v5/sha256.d.ts +19 -0
  330. package/dist/src/serialization/beast2/v5/sha256.d.ts.map +1 -0
  331. package/dist/src/serialization/beast2/v5/sha256.js +103 -0
  332. package/dist/src/serialization/beast2/v5/sha256.js.map +1 -0
  333. package/dist/src/serialization/beast2/v5/sha256.spec.d.ts +6 -0
  334. package/dist/src/serialization/beast2/v5/sha256.spec.d.ts.map +1 -0
  335. package/dist/src/serialization/beast2/v5/sha256.spec.js +42 -0
  336. package/dist/src/serialization/beast2/v5/sha256.spec.js.map +1 -0
  337. package/dist/src/serialization/beast2/v5/stream.d.ts +273 -86
  338. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  339. package/dist/src/serialization/beast2/v5/stream.js +576 -244
  340. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  341. package/dist/src/serialization/beast2/v5/sync-reader.spec.js +24 -10
  342. package/dist/src/serialization/beast2/v5/sync-reader.spec.js.map +1 -1
  343. package/dist/src/serialization/index.d.ts +1 -1
  344. package/dist/src/serialization/index.d.ts.map +1 -1
  345. package/dist/src/serialization/index.js +1 -1
  346. package/dist/src/serialization/index.js.map +1 -1
  347. package/dist/src/serialization/json.d.ts +28 -0
  348. package/dist/src/serialization/json.d.ts.map +1 -1
  349. package/dist/src/serialization/json.js +141 -30
  350. package/dist/src/serialization/json.js.map +1 -1
  351. package/dist/src/serialization/json.spec.js +47 -2
  352. package/dist/src/serialization/json.spec.js.map +1 -1
  353. package/dist/src/serialization/json_schema.d.ts +15 -11
  354. package/dist/src/serialization/json_schema.d.ts.map +1 -1
  355. package/dist/src/serialization/json_schema.js +21 -36
  356. package/dist/src/serialization/json_schema.js.map +1 -1
  357. package/dist/src/serialization/json_schema.spec.js +26 -32
  358. package/dist/src/serialization/json_schema.spec.js.map +1 -1
  359. package/dist/src/serialization/json_schema_to_type.d.ts +10 -5
  360. package/dist/src/serialization/json_schema_to_type.d.ts.map +1 -1
  361. package/dist/src/serialization/json_schema_to_type.js +13 -6
  362. package/dist/src/serialization/json_schema_to_type.js.map +1 -1
  363. package/dist/src/serialization/json_schema_to_type.spec.js +19 -0
  364. package/dist/src/serialization/json_schema_to_type.spec.js.map +1 -1
  365. package/dist/src/string_order.d.ts +36 -0
  366. package/dist/src/string_order.d.ts.map +1 -0
  367. package/dist/src/string_order.js +64 -0
  368. package/dist/src/string_order.js.map +1 -0
  369. package/dist/src/string_order.spec.d.ts +6 -0
  370. package/dist/src/string_order.spec.d.ts.map +1 -0
  371. package/dist/src/string_order.spec.js +79 -0
  372. package/dist/src/string_order.spec.js.map +1 -0
  373. package/dist/src/type_of_type.d.ts +17 -0
  374. package/dist/src/type_of_type.d.ts.map +1 -1
  375. package/dist/src/type_of_type.js +66 -0
  376. package/dist/src/type_of_type.js.map +1 -1
  377. package/dist/src/type_of_type.to_etv.spec.js +69 -1
  378. package/dist/src/type_of_type.to_etv.spec.js.map +1 -1
  379. package/package.json +1 -1
@@ -0,0 +1,325 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * A collection's elements, read from its bytes as they arrive.
7
+ *
8
+ * A store that takes collections from outside — a delivered file, an upload, a
9
+ * program's output — cannot keep their bytes: the cuts, the aliasing, the codec
10
+ * and the compressor all enter them, and none is known to be the canonical
11
+ * writer's. What it can keep is the value, so it reads the elements and writes
12
+ * them again through the Writer. This is the reading half, and it never holds
13
+ * the value: the blob is read front to back, a frame at a time, and each
14
+ * segment's elements are decoded against a definition table of their own and
15
+ * handed over one by one.
16
+ *
17
+ * No index is needed, so the bytes can be a stream with nothing ahead of it. A
18
+ * segment is the unit of memory, and the one limit is on it: a frame whose
19
+ * logical bytes exceed {@link RUN_MAX_BYTES} is refused before it is read. That
20
+ * is what refuses a large value encoded whole — one frame holding everything —
21
+ * a writer that batched segments too big to decode at once, and an older Writer
22
+ * that bounded a segment by its element count alone, whose segments of wide
23
+ * elements grew past it.
24
+ */
25
+ import { EastTypeValueType, isTypeValueEqual } from "../../../type_of_type.js";
26
+ import { printFor } from "../../east.js";
27
+ import { compareFor } from "../../../comparison.js";
28
+ import { SortedSet } from "../../../containers/sortedset.js";
29
+ import { SortedMap } from "../../../containers/sortedmap.js";
30
+ import { BufferReader } from "../../binary-utils.js";
31
+ import { buildPlatformContext } from "../shared.js";
32
+ import { MAGIC_BYTES, decodeBeast2V4For, readBeast2V4Type } from "../v4/container.js";
33
+ import { asTypeValue, readTypeSection } from "./type-section.js";
34
+ import { MAGIC_BYTES_V5, TAG_NEW, buildV5Decoder, isSegmentedRoot, readSourceMapSectionV5 } from "./codec.js";
35
+ import { CODEC_DEFLATE, CODEC_NONE, CODEC_ZSTD, FRAME_HEADER_MAX, inflateRawSync } from "./frames.js";
36
+ import { RUN_MAX_BYTES } from "./runs.js";
37
+ import { SEGMENT_MAX_BYTES } from "./boundary.js";
38
+ /** Head reads the header sections are parsed from, in order: neither section
39
+ * says how long it is before it is parsed. The first holds any ordinary
40
+ * type section, so a stream is read no further ahead than it has to be; the
41
+ * last is a ceiling — a type section wider than 16 MiB is malformed, not
42
+ * merely large. */
43
+ const HEAD_PROBE_BYTES = [4 * 1024, 256 * 1024, 16 * 1024 * 1024];
44
+ /**
45
+ * The bytes of a stream as they arrive, with enough buffered to parse the next
46
+ * thing: a header, a frame, the whole of a small legacy blob.
47
+ */
48
+ class ChunkQueue {
49
+ iterator;
50
+ chunks = [];
51
+ /** How much of `chunks[0]` has been taken. */
52
+ head = 0;
53
+ ended = false;
54
+ /** Bytes buffered and not yet taken. */
55
+ available = 0;
56
+ /** Bytes taken so far — the stream offset of the next byte. */
57
+ offset = 0;
58
+ constructor(source) {
59
+ this.iterator = Symbol.asyncIterator in source
60
+ ? source[Symbol.asyncIterator]()
61
+ : source[Symbol.iterator]();
62
+ }
63
+ /** Buffers at least `n` bytes, or everything left when the stream ends
64
+ * first; answers whether `n` are buffered. */
65
+ async fill(n) {
66
+ while (this.available < n && !this.ended) {
67
+ const next = await this.iterator.next();
68
+ if (next.done === true) {
69
+ this.ended = true;
70
+ break;
71
+ }
72
+ if (next.value.length === 0)
73
+ continue;
74
+ this.chunks.push(next.value);
75
+ this.available += next.value.length;
76
+ }
77
+ return this.available >= n;
78
+ }
79
+ /** The next `n` buffered bytes, contiguous, without taking them. */
80
+ peek(n) {
81
+ const first = this.chunks[0];
82
+ if (first !== undefined && first.length - this.head >= n)
83
+ return first.subarray(this.head, this.head + n);
84
+ const out = new Uint8Array(n);
85
+ let at = 0;
86
+ for (let i = 0; at < n; i++) {
87
+ const chunk = this.chunks[i];
88
+ const from = i === 0 ? this.head : 0;
89
+ const length = Math.min(chunk.length - from, n - at);
90
+ out.set(chunk.subarray(from, from + length), at);
91
+ at += length;
92
+ }
93
+ return out;
94
+ }
95
+ /** Takes the next `n` buffered bytes, contiguous. */
96
+ take(n) {
97
+ const bytes = this.peek(n);
98
+ this.skip(n);
99
+ return bytes;
100
+ }
101
+ /** Drops the next `n` buffered bytes. */
102
+ skip(n) {
103
+ this.available -= n;
104
+ this.offset += n;
105
+ while (n > 0) {
106
+ const room = this.chunks[0].length - this.head;
107
+ if (room > n) {
108
+ this.head += n;
109
+ return;
110
+ }
111
+ n -= room;
112
+ this.chunks.shift();
113
+ this.head = 0;
114
+ }
115
+ }
116
+ /** Stops reading the stream, releasing whatever it holds open. */
117
+ async close() {
118
+ if (this.ended)
119
+ return;
120
+ this.ended = true;
121
+ await this.iterator.return?.();
122
+ }
123
+ }
124
+ /**
125
+ * Builds a reader of a collection's elements from its beast2 bytes: `read(chunks)`
126
+ * yields the elements in order — an Array's in position, a Set's or Dict's
127
+ * ascending — decoding one segment of the source at a time.
128
+ *
129
+ * Any container a collection is written in reads: a v5 blob, indexed or not,
130
+ * cut canonically or batched by its writer, compressed or not, and a v4 blob.
131
+ * Nothing about the source's layout survives into what is yielded, so writing
132
+ * the elements through the Writer gives the canonical bytes of the value.
133
+ *
134
+ * @param type - the collection type (Array/Set/Dict) the bytes must hold
135
+ * @param options - decode options (platform functions for decoded functions)
136
+ * @returns a function reading the elements out of a stream of byte chunks
137
+ * @throws {TypeError} When `type` is not an Array, Set or Dict type.
138
+ *
139
+ * @remarks
140
+ * Memory is one segment of the source. Each segment decodes against a
141
+ * definition table of its own, which is what a self-contained blob — every
142
+ * writer's default — promises; a segment that aliases a container defined in
143
+ * an earlier one is refused, naming it. A frame whose logical bytes exceed
144
+ * {@link RUN_MAX_BYTES} is refused before it is read, and so is a v4 blob
145
+ * longer than that, since v4 has no segments: the fix is to write the value
146
+ * segmented. The generator rejects on the first such refusal, on bytes that
147
+ * hold another type, and on a malformed container; what it yielded before
148
+ * stands. The stream is read no further than the value's last segment, and is
149
+ * closed however the reading ends.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * const type = DictType(StringType, IntegerType);
154
+ * const blob = encodeBeast2For(type)(new Map([["a", 1n], ["b", 2n]]));
155
+ * for await (const [key, value] of decodeBeast2ElementsFor(type)([blob])) {
156
+ * // "a" 1n, then "b" 2n
157
+ * }
158
+ * ```
159
+ */
160
+ export function decodeBeast2ElementsFor(type, options) {
161
+ const typeValue = asTypeValue(type);
162
+ if (!isSegmentedRoot(typeValue)) {
163
+ throw new TypeError(`beast2: elements are read from Array, Set or Dict values, not ${typeValue.type}`);
164
+ }
165
+ const kind = typeValue.type;
166
+ const typeCtx = new Map();
167
+ let decodeElement;
168
+ if (kind === "Dict") {
169
+ const key = buildV5Decoder(typeValue.value.key, typeCtx);
170
+ const value = buildV5Decoder(typeValue.value.value, typeCtx);
171
+ decodeElement = (reader, ctx) => [key(reader, ctx), value(reader, ctx)];
172
+ }
173
+ else {
174
+ decodeElement = buildV5Decoder(typeValue.value, typeCtx);
175
+ }
176
+ const platform = buildPlatformContext(options);
177
+ const frozen = options?.frozen ?? false;
178
+ const printType = printFor(EastTypeValueType);
179
+ const checkType = (wire) => {
180
+ if (!isTypeValueEqual(wire, typeValue)) {
181
+ throw new Error(`beast2: the bytes hold ${printType(wire)}, not ${printType(typeValue)}`);
182
+ }
183
+ };
184
+ /** A v4 blob's elements: v4 has no segments, so the blob is read whole —
185
+ * within the same limit as a frame. */
186
+ async function* legacyElements(queue) {
187
+ if (await queue.fill(RUN_MAX_BYTES + 1)) {
188
+ throw new Error(`beast2: a v4 blob longer than ${RUN_MAX_BYTES} bytes has no segments to read it in — ` +
189
+ `re-encode it with version 5, segmented`);
190
+ }
191
+ const bytes = queue.take(queue.available);
192
+ checkType(readBeast2V4Type(bytes));
193
+ const value = decodeBeast2V4For(typeValue, options)(bytes);
194
+ if (kind === "Array") {
195
+ yield* value;
196
+ }
197
+ else if (kind === "Set") {
198
+ yield* value instanceof SortedSet ? value : [...value].sort(compareFor(typeValue.value));
199
+ }
200
+ else {
201
+ const cmp = compareFor(typeValue.value.key);
202
+ yield* value instanceof SortedMap
203
+ ? value.entries()
204
+ : [...value.entries()].sort((a, b) => cmp(a[0], b[0]));
205
+ }
206
+ }
207
+ /** The v5 value stream's elements, the header sections already taken. */
208
+ async function* streamElements(queue, sourceMap) {
209
+ let frames = 0;
210
+ /** The next frame's logical bytes. */
211
+ const nextFrame = async () => {
212
+ const at = queue.offset;
213
+ await queue.fill(FRAME_HEADER_MAX);
214
+ if (queue.available === 0) {
215
+ throw new Error(`beast2 v5: truncated value stream (expected a frame at offset ${at})`);
216
+ }
217
+ const reader = new BufferReader(queue.peek(Math.min(FRAME_HEADER_MAX, queue.available)), 0);
218
+ const codec = reader.readVarint();
219
+ const logicalBytes = reader.readVarint();
220
+ const payloadBytes = reader.readVarint();
221
+ if (codec !== CODEC_NONE && codec !== CODEC_DEFLATE) {
222
+ throw new Error(codec === CODEC_ZSTD
223
+ ? `beast2 v5: frame uses codec 2 (zstd), which this runtime does not support`
224
+ : `beast2 v5: unknown frame codec ${codec}`);
225
+ }
226
+ if (logicalBytes > RUN_MAX_BYTES) {
227
+ throw new Error(`beast2: frame ${frames} at offset ${at} holds ${logicalBytes} bytes, more than the ${RUN_MAX_BYTES} a ` +
228
+ `collection is read in at once — write it again with a current Writer, whose segments stay under ` +
229
+ `${SEGMENT_MAX_BYTES} bytes: it was encoded whole, or cut by an older Writer that bounded a segment by ` +
230
+ `its element count alone`);
231
+ }
232
+ if (codec === CODEC_NONE && payloadBytes !== logicalBytes) {
233
+ throw new Error(`beast2 v5: uncompressed frame lengths disagree (${payloadBytes} != ${logicalBytes})`);
234
+ }
235
+ const headerBytes = reader.offset;
236
+ if (!await queue.fill(headerBytes + payloadBytes)) {
237
+ throw new Error(`beast2 v5: truncated frame (payload of ${payloadBytes} bytes runs past end of input)`);
238
+ }
239
+ queue.skip(headerBytes);
240
+ const payload = queue.take(payloadBytes);
241
+ frames++;
242
+ return new BufferReader(codec === CODEC_NONE ? payload : inflateRawSync(payload, logicalBytes), 0);
243
+ };
244
+ let reader = await nextFrame();
245
+ while (reader.offset === reader.buffer.length)
246
+ reader = await nextFrame();
247
+ const tag = reader.readUint8();
248
+ if (tag !== TAG_NEW) {
249
+ throw new Error(`beast2 v5: root container must be NEW (tag 0x${tag.toString(16)})`);
250
+ }
251
+ for (let segment = 0;; segment++) {
252
+ while (reader.offset === reader.buffer.length)
253
+ reader = await nextFrame();
254
+ const count = reader.readVarint();
255
+ if (count === 0)
256
+ break;
257
+ // A segment's elements decode against a table of their own: a REF that
258
+ // reaches past it aliases a container this reader no longer holds.
259
+ const ctx = { containers: [], sourceMap, frozen, ...platform };
260
+ for (let i = 0; i < count; i++) {
261
+ let element;
262
+ try {
263
+ element = decodeElement(reader, ctx);
264
+ }
265
+ catch (err) {
266
+ const message = err instanceof Error ? err.message : String(err);
267
+ throw new Error(`beast2 v5: segment ${segment}: ${message.replace(/^beast2 v5: /, "")}`);
268
+ }
269
+ yield element;
270
+ }
271
+ }
272
+ if (reader.offset !== reader.buffer.length) {
273
+ throw new Error(`beast2 v5: ${reader.buffer.length - reader.offset} logical bytes after the root terminator`);
274
+ }
275
+ }
276
+ return async function* (chunks) {
277
+ const queue = new ChunkQueue(chunks);
278
+ try {
279
+ if (!await queue.fill(MAGIC_BYTES_V5.length)) {
280
+ throw new Error(`Data too short for Beast2 format: ${queue.available} bytes`);
281
+ }
282
+ const magic = queue.peek(MAGIC_BYTES_V5.length);
283
+ for (let i = 0; i < 7; i++) {
284
+ if (magic[i] !== MAGIC_BYTES_V5[i]) {
285
+ throw new Error(`Invalid Beast2 magic at offset ${i}: expected 0x${MAGIC_BYTES_V5[i].toString(16)}, got 0x${magic[i].toString(16)}`);
286
+ }
287
+ }
288
+ if (magic[7] === MAGIC_BYTES[7]) {
289
+ yield* legacyElements(queue);
290
+ return;
291
+ }
292
+ if (magic[7] !== MAGIC_BYTES_V5[7]) {
293
+ throw new Error(`Unknown Beast2 version: 0x${magic[7].toString(16)}`);
294
+ }
295
+ let header = null;
296
+ let lastError;
297
+ for (const probe of HEAD_PROBE_BYTES) {
298
+ const whole = !await queue.fill(probe);
299
+ try {
300
+ const reader = new BufferReader(queue.peek(Math.min(probe, queue.available)), MAGIC_BYTES_V5.length);
301
+ const { rootType } = readTypeSection(reader);
302
+ header = { rootType, sourceMap: readSourceMapSectionV5(reader), length: reader.offset };
303
+ break;
304
+ }
305
+ catch (err) {
306
+ // A short head fails as a malformed one does: grow it first, and
307
+ // report the failure once the whole header is in hand.
308
+ if (whole)
309
+ throw err;
310
+ lastError = err;
311
+ }
312
+ }
313
+ if (header === null) {
314
+ throw new Error(`beast2: header not readable in the first ${HEAD_PROBE_BYTES[HEAD_PROBE_BYTES.length - 1]} bytes — ${lastError instanceof Error ? lastError.message : String(lastError)}`);
315
+ }
316
+ checkType(header.rootType);
317
+ queue.skip(header.length);
318
+ yield* streamElements(queue, header.sourceMap);
319
+ }
320
+ finally {
321
+ await queue.close();
322
+ }
323
+ };
324
+ }
325
+ //# sourceMappingURL=elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/elements.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAsB,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEnG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAA4B,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBA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,OAAO,GAAG,EAAE,CAAC;oBACb,iEAAiE;oBACjE,uDAAuD;oBACvD,IAAI,KAAK;wBAAE,MAAM,GAAG,CAAC;oBACrB,SAAS,GAAG,GAAG,CAAC;gBAClB,CAAC;YACH,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,YACvG,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC1E,CAAC;YACD,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC1B,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAuC,CAAC;QACvF,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=elements.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.spec.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/elements.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Reading a collection's elements from its bytes as they arrive: every
7
+ * container a collection is written in, a segment at a time, with the limit on
8
+ * a segment's size and the refusals that come with reading a stream.
9
+ */
10
+ import { describe, test } from "node:test";
11
+ import assert from "node:assert/strict";
12
+ import { ArrayType, DictType, IntegerType, SetType, StringType, StructType } from "../../../types.js";
13
+ import { compareFor } from "../../../comparison.js";
14
+ import { SortedMap, SortedSet } from "../../../index.js";
15
+ import { Beast2ElementWriter, Beast2Writer, decodeBeast2ElementsFor, encodeBeast2For, encodeBeast2PagedFor, encodeBeast2SegmentsFor, readBeast2Extents, RUN_MAX_BYTES, } from "../index.js";
16
+ const RowType = StructType({ id: IntegerType, name: StringType });
17
+ const TableType = DictType(StringType, RowType);
18
+ /** Every element the reader yields, in order. */
19
+ async function readAll(elements) {
20
+ const out = [];
21
+ for await (const element of elements)
22
+ out.push(element);
23
+ return out;
24
+ }
25
+ /** The bytes `size` at a time. */
26
+ function* chunked(bytes, size) {
27
+ for (let at = 0; at < bytes.length; at += size)
28
+ yield bytes.subarray(at, at + size);
29
+ }
30
+ describe("decodeBeast2ElementsFor", () => {
31
+ test("reads a Dict from each container it is written in", async () => {
32
+ const value = new SortedMap(Array.from({ length: 5_000 }, (_, i) => [`k${String(i).padStart(7, "0")}`, { id: BigInt(i), name: `row-${i}` }]), compareFor(StringType));
33
+ const expected = [...value];
34
+ const batches = [];
35
+ for (let i = 0; i < expected.length; i += 700)
36
+ batches.push(new SortedMap(expected.slice(i, i + 700), compareFor(StringType)));
37
+ const containers = {
38
+ "paged": encodeBeast2PagedFor(TableType)(value),
39
+ "paged, uncompressed": encodeBeast2PagedFor(TableType, { codec: "none" })(value),
40
+ "encoded whole": encodeBeast2For(TableType)(value),
41
+ "encoded whole, with an index": encodeBeast2For(TableType, { index: true })(value),
42
+ "batched by the writer": encodeBeast2SegmentsFor(TableType)(batches),
43
+ "v4": encodeBeast2For(TableType, { version: 4 })(value),
44
+ };
45
+ for (const [name, blob] of Object.entries(containers)) {
46
+ assert.deepEqual(await readAll(decodeBeast2ElementsFor(TableType)([blob])), expected, name);
47
+ }
48
+ });
49
+ test("reads Arrays and Sets, and an empty collection", async () => {
50
+ const rows = Array.from({ length: 3_000 }, (_, i) => ({ id: BigInt(i), name: `row-${i}` }));
51
+ assert.deepEqual(await readAll(decodeBeast2ElementsFor(ArrayType(RowType))([encodeBeast2PagedFor(ArrayType(RowType))(rows)])), rows);
52
+ const names = new SortedSet(Array.from({ length: 3_000 }, (_, i) => `n${String(i).padStart(5, "0")}`), compareFor(StringType));
53
+ const setType = SetType(StringType);
54
+ assert.deepEqual(await readAll(decodeBeast2ElementsFor(setType)([encodeBeast2For(setType)(names)])), [...names]);
55
+ assert.deepEqual(await readAll(decodeBeast2ElementsFor(TableType)([encodeBeast2PagedFor(TableType)(new Map())])), []);
56
+ assert.deepEqual(await readAll(decodeBeast2ElementsFor(TableType)([encodeBeast2For(TableType)(new Map())])), []);
57
+ });
58
+ test("hands the Writer the elements it writes the canonical blob from", async () => {
59
+ // Whatever container the value came in, the Writer given what the reader
60
+ // yields writes the value's canonical bytes.
61
+ const value = new SortedMap(Array.from({ length: 20_000 }, (_, i) => [`k${String(i).padStart(7, "0")}`, { id: BigInt(i), name: `row-${i}` }]), compareFor(StringType));
62
+ const expected = encodeBeast2PagedFor(TableType)(value);
63
+ const batches = [];
64
+ const entries = [...value];
65
+ for (let i = 0; i < entries.length; i += 333)
66
+ batches.push(new SortedMap(entries.slice(i, i + 333), compareFor(StringType)));
67
+ for (const source of [encodeBeast2SegmentsFor(TableType)(batches), encodeBeast2For(TableType)(value), expected]) {
68
+ const chunks = [];
69
+ const writer = new Beast2ElementWriter(TableType, (bytes) => chunks.push(bytes.slice()));
70
+ for await (const element of decodeBeast2ElementsFor(TableType)([source]))
71
+ writer.add(element);
72
+ writer.finish();
73
+ assert.deepEqual(new Uint8Array(Buffer.concat(chunks)), expected);
74
+ }
75
+ });
76
+ test("keeps the aliasing inside an element", async () => {
77
+ // Two fields naming one array: an element's own REF, which its segment's
78
+ // table resolves.
79
+ const type = DictType(StringType, StructType({ a: ArrayType(IntegerType), b: ArrayType(IntegerType) }));
80
+ const shared = [1n, 2n, 3n];
81
+ const value = new SortedMap([["x", { a: shared, b: shared }], ["y", { a: [4n], b: [5n] }]], compareFor(StringType));
82
+ const read = await readAll(decodeBeast2ElementsFor(type)([encodeBeast2PagedFor(type)(value)]));
83
+ const first = read[0][1];
84
+ assert.deepEqual(first, { a: shared, b: shared });
85
+ assert.equal(first.a, first.b, "the two fields are one array, as they were written");
86
+ });
87
+ test("reads a stream a byte at a time, and pulls it only as far as it has read", async () => {
88
+ const value = new SortedMap(Array.from({ length: 20_000 }, (_, i) => [`k${String(i).padStart(7, "0")}`, { id: BigInt(i), name: `row-${i}` }]), compareFor(StringType));
89
+ const blob = encodeBeast2PagedFor(TableType)(value);
90
+ assert.deepEqual(await readAll(decodeBeast2ElementsFor(TableType)(chunked(blob, 1))), [...value]);
91
+ // The first element needs the header and the first segment's frame, and
92
+ // nothing after them.
93
+ const extents = readBeast2Extents(blob);
94
+ let pulled = 0;
95
+ const source = (function* () {
96
+ for (const chunk of chunked(blob, 1024)) {
97
+ pulled += chunk.length;
98
+ yield chunk;
99
+ }
100
+ })();
101
+ const elements = decodeBeast2ElementsFor(TableType)(source);
102
+ await elements.next();
103
+ assert.ok(pulled <= extents.offsets[1] + 1024, `pulled ${pulled} bytes to read the first element; its segment ends at ${extents.offsets[1]}`);
104
+ await elements.return(undefined);
105
+ });
106
+ test("closes the stream when the reading ends early", async () => {
107
+ let closed = false;
108
+ const blob = encodeBeast2PagedFor(TableType)(new SortedMap(Array.from({ length: 10_000 }, (_, i) => [`k${String(i).padStart(7, "0")}`, { id: BigInt(i), name: `row-${i}` }]), compareFor(StringType)));
109
+ const source = (async function* () {
110
+ try {
111
+ yield* chunked(blob, 4096);
112
+ }
113
+ finally {
114
+ closed = true;
115
+ }
116
+ })();
117
+ for await (const element of decodeBeast2ElementsFor(TableType)(source)) {
118
+ void element;
119
+ break;
120
+ }
121
+ assert.ok(closed);
122
+ });
123
+ test("refuses a frame larger than a collection is read in, before reading it", async () => {
124
+ // A whole-value encode is one frame; this one declares more logical bytes
125
+ // than the limit, and none of them follow.
126
+ const type = ArrayType(StringType);
127
+ const head = encodeBeast2For(type, { codec: "none" })([]);
128
+ const header = head.subarray(0, head.length - 5); // up to the one frame: codec, lengths, TAG_NEW, 0
129
+ const frameHeader = new Uint8Array(21);
130
+ let at = 0;
131
+ const varint = (v) => {
132
+ for (; v >= 0x80; v = Math.floor(v / 128))
133
+ frameHeader[at++] = (v & 0x7f) | 0x80;
134
+ frameHeader[at++] = v;
135
+ };
136
+ varint(0);
137
+ varint(RUN_MAX_BYTES + 1);
138
+ varint(RUN_MAX_BYTES + 1);
139
+ await assert.rejects(readAll(decodeBeast2ElementsFor(type)([header, frameHeader.subarray(0, at)])), /holds 67108865 bytes, more than the 67108864 a collection is read in at once — write it again with a current Writer, whose segments stay under 8388608 bytes/);
140
+ });
141
+ test("refuses a segment that aliases a container in an earlier one", async () => {
142
+ // A writer told not to scope its aliasing: the second batch names the
143
+ // array the first defined.
144
+ const type = ArrayType(ArrayType(IntegerType));
145
+ const shared = [1n, 2n];
146
+ const chunks = [];
147
+ const writer = new Beast2Writer(type, (bytes) => chunks.push(bytes.slice()), { selfContained: false });
148
+ writer.write([shared]);
149
+ writer.write([shared]);
150
+ writer.finish();
151
+ await assert.rejects(readAll(decodeBeast2ElementsFor(type)([new Uint8Array(Buffer.concat(chunks))])), /beast2 v5: segment 1: container backref delta 1 out of range/);
152
+ });
153
+ test("refuses bytes that hold another type", async () => {
154
+ await assert.rejects(readAll(decodeBeast2ElementsFor(TableType)([encodeBeast2PagedFor(ArrayType(StringType))(["a"])])), /the bytes hold .*Array.*, not .*Dict/);
155
+ await assert.rejects(readAll(decodeBeast2ElementsFor(TableType)([encodeBeast2For(ArrayType(StringType), { version: 4 })(["a"])])), /the bytes hold .*Array.*, not .*Dict/);
156
+ });
157
+ test("refuses a non-collection type up front", () => {
158
+ assert.throws(() => decodeBeast2ElementsFor(IntegerType), /Array, Set or Dict values, not Integer/);
159
+ });
160
+ });
161
+ //# sourceMappingURL=elements.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.spec.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/elements.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;AAClE,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAEhD,iDAAiD;AACjD,KAAK,UAAU,OAAO,CAAI,QAA0B;IAClD,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,QAAQ;QAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kCAAkC;AAClC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAiB,EAAE,IAAY;IAC/C,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,IAAI;QAAE,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,E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