@elaraai/east 0.0.1-beta.0

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 (251) hide show
  1. package/LICENSE.md +682 -0
  2. package/README.md +276 -0
  3. package/dist/src/analyze.d.ts +95 -0
  4. package/dist/src/analyze.d.ts.map +1 -0
  5. package/dist/src/analyze.js +1110 -0
  6. package/dist/src/analyze.js.map +1 -0
  7. package/dist/src/ast.d.ts +263 -0
  8. package/dist/src/ast.d.ts.map +1 -0
  9. package/dist/src/ast.js +151 -0
  10. package/dist/src/ast.js.map +1 -0
  11. package/dist/src/ast_to_ir.d.ts +24 -0
  12. package/dist/src/ast_to_ir.d.ts.map +1 -0
  13. package/dist/src/ast_to_ir.js +834 -0
  14. package/dist/src/ast_to_ir.js.map +1 -0
  15. package/dist/src/builtins.d.ts +18 -0
  16. package/dist/src/builtins.d.ts.map +1 -0
  17. package/dist/src/builtins.js +1105 -0
  18. package/dist/src/builtins.js.map +1 -0
  19. package/dist/src/comparison.d.ts +28 -0
  20. package/dist/src/comparison.d.ts.map +1 -0
  21. package/dist/src/comparison.js +1017 -0
  22. package/dist/src/comparison.js.map +1 -0
  23. package/dist/src/compile.d.ts +22 -0
  24. package/dist/src/compile.d.ts.map +1 -0
  25. package/dist/src/compile.js +3260 -0
  26. package/dist/src/compile.js.map +1 -0
  27. package/dist/src/containers/ref.d.ts +106 -0
  28. package/dist/src/containers/ref.d.ts.map +1 -0
  29. package/dist/src/containers/ref.js +100 -0
  30. package/dist/src/containers/ref.js.map +1 -0
  31. package/dist/src/containers/sortedmap.d.ts +165 -0
  32. package/dist/src/containers/sortedmap.d.ts.map +1 -0
  33. package/dist/src/containers/sortedmap.js +237 -0
  34. package/dist/src/containers/sortedmap.js.map +1 -0
  35. package/dist/src/containers/sortedset.d.ts +185 -0
  36. package/dist/src/containers/sortedset.d.ts.map +1 -0
  37. package/dist/src/containers/sortedset.js +312 -0
  38. package/dist/src/containers/sortedset.js.map +1 -0
  39. package/dist/src/containers/variant.d.ts +131 -0
  40. package/dist/src/containers/variant.d.ts.map +1 -0
  41. package/dist/src/containers/variant.js +68 -0
  42. package/dist/src/containers/variant.js.map +1 -0
  43. package/dist/src/datetime_format/parse.d.ts +50 -0
  44. package/dist/src/datetime_format/parse.d.ts.map +1 -0
  45. package/dist/src/datetime_format/parse.js +908 -0
  46. package/dist/src/datetime_format/parse.js.map +1 -0
  47. package/dist/src/datetime_format/print.d.ts +35 -0
  48. package/dist/src/datetime_format/print.d.ts.map +1 -0
  49. package/dist/src/datetime_format/print.js +157 -0
  50. package/dist/src/datetime_format/print.js.map +1 -0
  51. package/dist/src/datetime_format/tokenize.d.ts +76 -0
  52. package/dist/src/datetime_format/tokenize.d.ts.map +1 -0
  53. package/dist/src/datetime_format/tokenize.js +271 -0
  54. package/dist/src/datetime_format/tokenize.js.map +1 -0
  55. package/dist/src/datetime_format/types.d.ts +99 -0
  56. package/dist/src/datetime_format/types.d.ts.map +1 -0
  57. package/dist/src/datetime_format/types.js +103 -0
  58. package/dist/src/datetime_format/types.js.map +1 -0
  59. package/dist/src/datetime_format/validate.d.ts +51 -0
  60. package/dist/src/datetime_format/validate.d.ts.map +1 -0
  61. package/dist/src/datetime_format/validate.js +208 -0
  62. package/dist/src/datetime_format/validate.js.map +1 -0
  63. package/dist/src/default.d.ts +21 -0
  64. package/dist/src/default.d.ts.map +1 -0
  65. package/dist/src/default.js +82 -0
  66. package/dist/src/default.js.map +1 -0
  67. package/dist/src/eastir.d.ts +33 -0
  68. package/dist/src/eastir.d.ts.map +1 -0
  69. package/dist/src/eastir.js +92 -0
  70. package/dist/src/eastir.js.map +1 -0
  71. package/dist/src/error.d.ts +13 -0
  72. package/dist/src/error.d.ts.map +1 -0
  73. package/dist/src/error.js +8 -0
  74. package/dist/src/error.js.map +1 -0
  75. package/dist/src/expr/array.d.ts +1711 -0
  76. package/dist/src/expr/array.d.ts.map +1 -0
  77. package/dist/src/expr/array.js +1805 -0
  78. package/dist/src/expr/array.js.map +1 -0
  79. package/dist/src/expr/ast.d.ts +17 -0
  80. package/dist/src/expr/ast.d.ts.map +1 -0
  81. package/dist/src/expr/ast.js +302 -0
  82. package/dist/src/expr/ast.js.map +1 -0
  83. package/dist/src/expr/blob.d.ts +141 -0
  84. package/dist/src/expr/blob.d.ts.map +1 -0
  85. package/dist/src/expr/blob.js +198 -0
  86. package/dist/src/expr/blob.js.map +1 -0
  87. package/dist/src/expr/block.d.ts +201 -0
  88. package/dist/src/expr/block.d.ts.map +1 -0
  89. package/dist/src/expr/block.js +1505 -0
  90. package/dist/src/expr/block.js.map +1 -0
  91. package/dist/src/expr/boolean.d.ts +207 -0
  92. package/dist/src/expr/boolean.d.ts.map +1 -0
  93. package/dist/src/expr/boolean.js +261 -0
  94. package/dist/src/expr/boolean.js.map +1 -0
  95. package/dist/src/expr/datetime.d.ts +544 -0
  96. package/dist/src/expr/datetime.d.ts.map +1 -0
  97. package/dist/src/expr/datetime.js +980 -0
  98. package/dist/src/expr/datetime.js.map +1 -0
  99. package/dist/src/expr/dict.d.ts +1242 -0
  100. package/dist/src/expr/dict.d.ts.map +1 -0
  101. package/dist/src/expr/dict.js +1492 -0
  102. package/dist/src/expr/dict.js.map +1 -0
  103. package/dist/src/expr/expr.d.ts +95 -0
  104. package/dist/src/expr/expr.d.ts.map +1 -0
  105. package/dist/src/expr/expr.js +171 -0
  106. package/dist/src/expr/expr.js.map +1 -0
  107. package/dist/src/expr/float.d.ts +357 -0
  108. package/dist/src/expr/float.d.ts.map +1 -0
  109. package/dist/src/expr/float.js +637 -0
  110. package/dist/src/expr/float.js.map +1 -0
  111. package/dist/src/expr/function.d.ts +46 -0
  112. package/dist/src/expr/function.d.ts.map +1 -0
  113. package/dist/src/expr/function.js +58 -0
  114. package/dist/src/expr/function.js.map +1 -0
  115. package/dist/src/expr/index.d.ts +450 -0
  116. package/dist/src/expr/index.d.ts.map +1 -0
  117. package/dist/src/expr/index.js +423 -0
  118. package/dist/src/expr/index.js.map +1 -0
  119. package/dist/src/expr/integer.d.ts +256 -0
  120. package/dist/src/expr/integer.d.ts.map +1 -0
  121. package/dist/src/expr/integer.js +311 -0
  122. package/dist/src/expr/integer.js.map +1 -0
  123. package/dist/src/expr/libs/array.d.ts +106 -0
  124. package/dist/src/expr/libs/array.d.ts.map +1 -0
  125. package/dist/src/expr/libs/array.js +140 -0
  126. package/dist/src/expr/libs/array.js.map +1 -0
  127. package/dist/src/expr/libs/blob.d.ts +42 -0
  128. package/dist/src/expr/libs/blob.d.ts.map +1 -0
  129. package/dist/src/expr/libs/blob.js +70 -0
  130. package/dist/src/expr/libs/blob.js.map +1 -0
  131. package/dist/src/expr/libs/datetime.d.ts +479 -0
  132. package/dist/src/expr/libs/datetime.d.ts.map +1 -0
  133. package/dist/src/expr/libs/datetime.js +624 -0
  134. package/dist/src/expr/libs/datetime.js.map +1 -0
  135. package/dist/src/expr/libs/dict.d.ts +66 -0
  136. package/dist/src/expr/libs/dict.d.ts.map +1 -0
  137. package/dist/src/expr/libs/dict.js +77 -0
  138. package/dist/src/expr/libs/dict.js.map +1 -0
  139. package/dist/src/expr/libs/float.d.ts +299 -0
  140. package/dist/src/expr/libs/float.d.ts.map +1 -0
  141. package/dist/src/expr/libs/float.js +564 -0
  142. package/dist/src/expr/libs/float.js.map +1 -0
  143. package/dist/src/expr/libs/integer.d.ts +228 -0
  144. package/dist/src/expr/libs/integer.d.ts.map +1 -0
  145. package/dist/src/expr/libs/integer.js +398 -0
  146. package/dist/src/expr/libs/integer.js.map +1 -0
  147. package/dist/src/expr/libs/set.d.ts +59 -0
  148. package/dist/src/expr/libs/set.d.ts.map +1 -0
  149. package/dist/src/expr/libs/set.js +69 -0
  150. package/dist/src/expr/libs/set.js.map +1 -0
  151. package/dist/src/expr/libs/string.d.ts +71 -0
  152. package/dist/src/expr/libs/string.d.ts.map +1 -0
  153. package/dist/src/expr/libs/string.js +75 -0
  154. package/dist/src/expr/libs/string.js.map +1 -0
  155. package/dist/src/expr/never.d.ts +15 -0
  156. package/dist/src/expr/never.d.ts.map +1 -0
  157. package/dist/src/expr/never.js +12 -0
  158. package/dist/src/expr/never.js.map +1 -0
  159. package/dist/src/expr/null.d.ts +15 -0
  160. package/dist/src/expr/null.d.ts.map +1 -0
  161. package/dist/src/expr/null.js +12 -0
  162. package/dist/src/expr/null.js.map +1 -0
  163. package/dist/src/expr/ref.d.ts +103 -0
  164. package/dist/src/expr/ref.d.ts.map +1 -0
  165. package/dist/src/expr/ref.js +131 -0
  166. package/dist/src/expr/ref.js.map +1 -0
  167. package/dist/src/expr/regex_validation.d.ts +25 -0
  168. package/dist/src/expr/regex_validation.d.ts.map +1 -0
  169. package/dist/src/expr/regex_validation.js +130 -0
  170. package/dist/src/expr/regex_validation.js.map +1 -0
  171. package/dist/src/expr/set.d.ts +1071 -0
  172. package/dist/src/expr/set.d.ts.map +1 -0
  173. package/dist/src/expr/set.js +1137 -0
  174. package/dist/src/expr/set.js.map +1 -0
  175. package/dist/src/expr/string.d.ts +414 -0
  176. package/dist/src/expr/string.d.ts.map +1 -0
  177. package/dist/src/expr/string.js +683 -0
  178. package/dist/src/expr/string.js.map +1 -0
  179. package/dist/src/expr/struct.d.ts +48 -0
  180. package/dist/src/expr/struct.d.ts.map +1 -0
  181. package/dist/src/expr/struct.js +65 -0
  182. package/dist/src/expr/struct.js.map +1 -0
  183. package/dist/src/expr/types.d.ts +68 -0
  184. package/dist/src/expr/types.d.ts.map +1 -0
  185. package/dist/src/expr/types.js +6 -0
  186. package/dist/src/expr/types.js.map +1 -0
  187. package/dist/src/expr/variant.d.ts +137 -0
  188. package/dist/src/expr/variant.d.ts.map +1 -0
  189. package/dist/src/expr/variant.js +105 -0
  190. package/dist/src/expr/variant.js.map +1 -0
  191. package/dist/src/fuzz.d.ts +80 -0
  192. package/dist/src/fuzz.d.ts.map +1 -0
  193. package/dist/src/fuzz.js +300 -0
  194. package/dist/src/fuzz.js.map +1 -0
  195. package/dist/src/index.d.ts +21 -0
  196. package/dist/src/index.d.ts.map +1 -0
  197. package/dist/src/index.js +21 -0
  198. package/dist/src/index.js.map +1 -0
  199. package/dist/src/internal.d.ts +36 -0
  200. package/dist/src/internal.d.ts.map +1 -0
  201. package/dist/src/internal.js +11 -0
  202. package/dist/src/internal.js.map +1 -0
  203. package/dist/src/ir.d.ts +1571 -0
  204. package/dist/src/ir.d.ts.map +1 -0
  205. package/dist/src/ir.js +56 -0
  206. package/dist/src/ir.js.map +1 -0
  207. package/dist/src/location.d.ts +48 -0
  208. package/dist/src/location.d.ts.map +1 -0
  209. package/dist/src/location.js +62 -0
  210. package/dist/src/location.js.map +1 -0
  211. package/dist/src/platform.d.ts +21 -0
  212. package/dist/src/platform.d.ts.map +1 -0
  213. package/dist/src/platform.js +8 -0
  214. package/dist/src/platform.js.map +1 -0
  215. package/dist/src/serialization/beast.d.ts +39 -0
  216. package/dist/src/serialization/beast.d.ts.map +1 -0
  217. package/dist/src/serialization/beast.js +555 -0
  218. package/dist/src/serialization/beast.js.map +1 -0
  219. package/dist/src/serialization/beast2-stream.d.ts +38 -0
  220. package/dist/src/serialization/beast2-stream.d.ts.map +1 -0
  221. package/dist/src/serialization/beast2-stream.js +665 -0
  222. package/dist/src/serialization/beast2-stream.js.map +1 -0
  223. package/dist/src/serialization/beast2.d.ts +41 -0
  224. package/dist/src/serialization/beast2.d.ts.map +1 -0
  225. package/dist/src/serialization/beast2.js +489 -0
  226. package/dist/src/serialization/beast2.js.map +1 -0
  227. package/dist/src/serialization/binary-utils.d.ts +151 -0
  228. package/dist/src/serialization/binary-utils.d.ts.map +1 -0
  229. package/dist/src/serialization/binary-utils.js +929 -0
  230. package/dist/src/serialization/binary-utils.js.map +1 -0
  231. package/dist/src/serialization/east.d.ts +84 -0
  232. package/dist/src/serialization/east.d.ts.map +1 -0
  233. package/dist/src/serialization/east.js +1802 -0
  234. package/dist/src/serialization/east.js.map +1 -0
  235. package/dist/src/serialization/index.d.ts +11 -0
  236. package/dist/src/serialization/index.d.ts.map +1 -0
  237. package/dist/src/serialization/index.js +12 -0
  238. package/dist/src/serialization/index.js.map +1 -0
  239. package/dist/src/serialization/json.d.ts +36 -0
  240. package/dist/src/serialization/json.d.ts.map +1 -0
  241. package/dist/src/serialization/json.js +849 -0
  242. package/dist/src/serialization/json.js.map +1 -0
  243. package/dist/src/type_of_type.d.ts +115 -0
  244. package/dist/src/type_of_type.d.ts.map +1 -0
  245. package/dist/src/type_of_type.js +362 -0
  246. package/dist/src/type_of_type.js.map +1 -0
  247. package/dist/src/types.d.ts +648 -0
  248. package/dist/src/types.d.ts.map +1 -0
  249. package/dist/src/types.js +1631 -0
  250. package/dist/src/types.js.map +1 -0
  251. package/package.json +87 -0
@@ -0,0 +1,70 @@
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
+ import { get_location } from "../../location.js";
6
+ import { BlobType } from "../../types.js";
7
+ import { Expr } from "../expr.js";
8
+ /** Standard library for blobs */
9
+ export default {
10
+ /**
11
+ * Encodes a value to the binary East format (BEAST).
12
+ *
13
+ * @param value - The East value to encode
14
+ * @param version - The BEAST format version to use: `'v1'` or `'v2'` (default: `'v1'`)
15
+ * @returns A blob expression containing the encoded binary data
16
+ *
17
+ * @throws Error when an unsupported version string is provided
18
+ *
19
+ * @remarks
20
+ * BEAST (Binary East) is a compact binary serialization format for East values.
21
+ * Version 1 (v1) is the original format, while version 2 (v2) provides improved
22
+ * encoding for certain types.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * // Encode an array to BEAST v1 format
27
+ * const encodeArray = East.function([ArrayType(IntegerType)], BlobType, ($, arr) => {
28
+ * $.return(East.Blob.encodeBeast(arr));
29
+ * });
30
+ * const compiled = East.compile(encodeArray.toIR(), []);
31
+ * const blob = compiled([1n, 2n, 3n]); // Binary blob containing encoded array
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // Encode using BEAST v2 format
37
+ * const encodeV2 = East.function([IntegerType], BlobType, ($, num) => {
38
+ * $.return(East.Blob.encodeBeast(num, 'v2'));
39
+ * });
40
+ * const compiled = East.compile(encodeV2.toIR(), []);
41
+ * const blob = compiled(42n); // Binary blob with v2 encoding
42
+ * ```
43
+ */
44
+ encodeBeast(value, version = 'v1') {
45
+ if (version === 'v1') {
46
+ return Expr.fromAst({
47
+ ast_type: "Builtin",
48
+ type: BlobType,
49
+ location: get_location(2),
50
+ builtin: "BlobEncodeBeast",
51
+ type_parameters: [Expr.type(value)],
52
+ arguments: [Expr.ast(value)],
53
+ });
54
+ }
55
+ else if (version === 'v2') {
56
+ return Expr.fromAst({
57
+ ast_type: "Builtin",
58
+ type: BlobType,
59
+ location: get_location(2),
60
+ builtin: "BlobEncodeBeast2",
61
+ type_parameters: [Expr.type(value)],
62
+ arguments: [Expr.ast(value)],
63
+ });
64
+ }
65
+ else {
66
+ throw new Error(`Unsupported Beast version: ${version}`);
67
+ }
68
+ }
69
+ };
70
+ //# sourceMappingURL=blob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob.js","sourceRoot":"","sources":["../../../../src/expr/libs/blob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,iCAAiC;AACjC,eAAe;IACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,WAAW,CAAC,KAAW,EAAE,UAAuB,IAAI;QAClD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,QAAQ,EAAE,SAAS;gBACnB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;gBACzB,OAAO,EAAE,iBAAiB;gBAC1B,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnC,SAAS,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aAC7B,CAAa,CAAC;QACjB,CAAC;aAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,QAAQ,EAAE,SAAS;gBACnB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;gBACzB,OAAO,EAAE,kBAAkB;gBAC3B,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnC,SAAS,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aAC7B,CAAa,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,479 @@
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
+ import { DateTimeType, IntegerType } from "../../types.js";
6
+ import { fromComponents, fromEpochMilliseconds, parseFormatted } from "../datetime.js";
7
+ /** Standard library functions for datetimes */
8
+ declare const _default: {
9
+ /**
10
+ * Creates a DateTime from milliseconds since Unix epoch.
11
+ *
12
+ * @param milliseconds - The number of milliseconds since Unix epoch
13
+ * @returns A DateTime expression representing the specified instant
14
+ *
15
+ * @remarks
16
+ * Similar to JavaScript's `new Date(ms)`, this function converts a timestamp
17
+ * (milliseconds since January 1, 1970 00:00:00 UTC) into an East DateTime.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const fromEpoch = East.function([IntegerType], DateTimeType, ($, ms) => {
22
+ * $.return(East.DateTime.fromEpochMilliseconds(ms));
23
+ * });
24
+ * const compiled = East.compile(fromEpoch.toIR(), []);
25
+ * compiled(0n); // 1970-01-01T00:00:00.000Z
26
+ * compiled(1609459200000n); // 2021-01-01T00:00:00.000Z
27
+ * ```
28
+ */
29
+ fromEpochMilliseconds: typeof fromEpochMilliseconds;
30
+ /**
31
+ * Creates a DateTime from individual date and time components.
32
+ *
33
+ * @param year - The year component
34
+ * @param month - The month component (1-12, default: 1)
35
+ * @param day - The day component (1-31, default: 1)
36
+ * @param hour - The hour component (0-23, default: 0)
37
+ * @param minute - The minute component (0-59, default: 0)
38
+ * @param second - The second component (0-59, default: 0)
39
+ * @param millisecond - The millisecond component (0-999, default: 0)
40
+ * @returns A DateTime expression representing the specified instant
41
+ *
42
+ * @remarks
43
+ * Components are: year, month (1-12), day (1-31), hour (0-23), minute (0-59),
44
+ * second (0-59), and millisecond (0-999).
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const makeDate = East.function([IntegerType], DateTimeType, ($, year) => {
49
+ * $.return(East.DateTime.fromComponents(year, 1n, 15n));
50
+ * });
51
+ * const compiled = East.compile(makeDate.toIR(), []);
52
+ * compiled(2025n); // 2025-01-15T00:00:00.000Z
53
+ * ```
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const makeDateTime = East.function([], DateTimeType, ($) => {
58
+ * $.return(East.DateTime.fromComponents(2025n, 1n, 15n, 14n, 30n, 0n, 500n));
59
+ * });
60
+ * const compiled = East.compile(makeDateTime.toIR(), []);
61
+ * compiled(); // 2025-01-15T14:30:00.500Z
62
+ * ```
63
+ */
64
+ fromComponents: typeof fromComponents;
65
+ /**
66
+ * Parses a formatted string into a DateTime using Day.js-style format tokens.
67
+ *
68
+ * @param input - The string to parse
69
+ * @param format - The format string using Day.js-style tokens (e.g., `"YYYY-MM-DD HH:mm:ss"`)
70
+ * @returns A DateTime expression representing the parsed instant
71
+ *
72
+ * @remarks
73
+ * The format string is parsed at compile time into structured tokens.
74
+ * Use backslash to escape characters: `\Y` produces literal "Y".
75
+ * All parsing is done in UTC (naive datetime).
76
+ *
77
+ * Supported tokens:
78
+ * - Year: YYYY (4-digit), YY (2-digit, 00-99 → 2000-2099)
79
+ * - Month: M (1-12), MM (01-12), MMM (Jan), MMMM (January) - case insensitive
80
+ * - Day: D (1-31), DD (01-31)
81
+ * - Weekday: dd (Su), ddd (Sun), dddd (Sunday) - consumed but not validated
82
+ * - Hour 24h: H (0-23), HH (00-23)
83
+ * - Hour 12h: h (1-12), hh (01-12) - requires A/a token
84
+ * - Minute: m (0-59), mm (00-59)
85
+ * - Second: s (0-59), ss (00-59)
86
+ * - Millisecond: SSS (000-999)
87
+ * - AM/PM: A (AM/PM), a (am/pm) - case insensitive
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const parseDate = East.function([StringType], DateTimeType, ($, dateStr) => {
92
+ * $.return(East.DateTime.parseFormatted(dateStr, "YYYY-MM-DD"));
93
+ * });
94
+ * const compiled = East.compile(parseDate.toIR(), []);
95
+ * compiled("2025-01-15"); // 2025-01-15T00:00:00.000Z
96
+ * ```
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const parseDateTime = East.function([StringType], DateTimeType, ($, str) => {
101
+ * $.return(East.DateTime.parseFormatted(str, "MM/DD/YYYY HH:mm"));
102
+ * });
103
+ * const compiled = East.compile(parseDateTime.toIR(), []);
104
+ * compiled("01/15/2025 14:30"); // 2025-01-15T14:30:00.000Z
105
+ * ```
106
+ */
107
+ parseFormatted: typeof parseFormatted;
108
+ /**
109
+ * Rounds a DateTime down to the nearest multiple of milliseconds.
110
+ *
111
+ * @param date - The DateTime to round
112
+ * @param step - The millisecond step size to round to
113
+ * @returns A DateTime expression rounded down to the nearest multiple of the step
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const roundMs = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
118
+ * $.return(East.DateTime.roundDownMillisecond(dt, step));
119
+ * });
120
+ * const compiled = East.compile(roundMs.toIR(), []);
121
+ * // Round down to nearest 100ms
122
+ * compiled(East.DateTime.fromEpochMilliseconds(1234n), 100n); // Rounded to 1200ms
123
+ * ```
124
+ */
125
+ roundDownMillisecond: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
126
+ /**
127
+ * Rounds a DateTime down to the nearest multiple of seconds.
128
+ *
129
+ * @param date - The DateTime to round
130
+ * @param step - The second step size to round to
131
+ * @returns A DateTime expression rounded down to the nearest multiple of the step
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const roundSec = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
136
+ * $.return(East.DateTime.roundDownSecond(dt, step));
137
+ * });
138
+ * const compiled = East.compile(roundSec.toIR(), []);
139
+ * // Round down to nearest 30 seconds
140
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 0n, 45n), 30n); // Rounds to 30s
141
+ * ```
142
+ */
143
+ roundDownSecond: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
144
+ /**
145
+ * Rounds a DateTime down to the nearest multiple of minutes.
146
+ *
147
+ * @param date - The DateTime to round
148
+ * @param step - The minute step size to round to
149
+ * @returns A DateTime expression rounded down to the nearest multiple of the step
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * const roundMin = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
154
+ * $.return(East.DateTime.roundDownMinute(dt, step));
155
+ * });
156
+ * const compiled = East.compile(roundMin.toIR(), []);
157
+ * // Round down to nearest 15 minutes
158
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 22n), 15n); // Rounds to 15 min
159
+ * ```
160
+ */
161
+ roundDownMinute: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
162
+ /**
163
+ * Rounds a DateTime down to the nearest multiple of hours.
164
+ *
165
+ * @param date - The DateTime to round
166
+ * @param step - The hour step size to round to
167
+ * @returns A DateTime expression rounded down to the nearest multiple of the step
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const roundHour = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
172
+ * $.return(East.DateTime.roundDownHour(dt, step));
173
+ * });
174
+ * const compiled = East.compile(roundHour.toIR(), []);
175
+ * // Round down to nearest 6 hours
176
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 8n), 6n); // Rounds to 6:00
177
+ * ```
178
+ */
179
+ roundDownHour: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
180
+ /**
181
+ * Rounds a DateTime up to the nearest multiple of milliseconds.
182
+ *
183
+ * @param date - The DateTime to round
184
+ * @param step - The millisecond step size to round to
185
+ * @returns A DateTime expression rounded up to the nearest multiple of the step
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const roundUpMs = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
190
+ * $.return(East.DateTime.roundUpMillisecond(dt, step));
191
+ * });
192
+ * const compiled = East.compile(roundUpMs.toIR(), []);
193
+ * // Round up to nearest 100ms
194
+ * compiled(East.DateTime.fromEpochMilliseconds(1234n), 100n); // Rounds to 1300ms
195
+ * ```
196
+ */
197
+ roundUpMillisecond: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
198
+ /**
199
+ * Rounds a DateTime to the nearest multiple of milliseconds.
200
+ *
201
+ * @param date - The DateTime to round
202
+ * @param step - The millisecond step size to round to
203
+ * @returns A DateTime expression rounded to the nearest multiple of the step
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * const roundNearMs = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
208
+ * $.return(East.DateTime.roundNearestMillisecond(dt, step));
209
+ * });
210
+ * const compiled = East.compile(roundNearMs.toIR(), []);
211
+ * // Round to nearest 100ms
212
+ * compiled(East.DateTime.fromEpochMilliseconds(1234n), 100n); // Rounds to 1200ms
213
+ * compiled(East.DateTime.fromEpochMilliseconds(1289n), 100n); // Rounds to 1300ms
214
+ * ```
215
+ */
216
+ roundNearestMillisecond: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
217
+ /**
218
+ * Rounds a DateTime up to the nearest multiple of seconds.
219
+ *
220
+ * @param date - The DateTime to round
221
+ * @param step - The second step size to round to
222
+ * @returns A DateTime expression rounded up to the nearest multiple of the step
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * const roundUpSec = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
227
+ * $.return(East.DateTime.roundUpSecond(dt, step));
228
+ * });
229
+ * const compiled = East.compile(roundUpSec.toIR(), []);
230
+ * // Round up to nearest 30 seconds
231
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 0n, 15n), 30n); // Rounds to 30s
232
+ * ```
233
+ */
234
+ roundUpSecond: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
235
+ /**
236
+ * Rounds a DateTime to the nearest multiple of seconds.
237
+ *
238
+ * @param date - The DateTime to round
239
+ * @param step - The second step size to round to
240
+ * @returns A DateTime expression rounded to the nearest multiple of the step
241
+ *
242
+ * @example
243
+ * ```ts
244
+ * const roundNearSec = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
245
+ * $.return(East.DateTime.roundNearestSecond(dt, step));
246
+ * });
247
+ * const compiled = East.compile(roundNearSec.toIR(), []);
248
+ * // Round to nearest 30 seconds
249
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 0n, 22n), 30n); // Rounds to 30s
250
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 0n, 38n), 30n); // Rounds to 30s
251
+ * ```
252
+ */
253
+ roundNearestSecond: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
254
+ /**
255
+ * Rounds a DateTime up to the nearest multiple of minutes.
256
+ *
257
+ * @param date - The DateTime to round
258
+ * @param step - The minute step size to round to
259
+ * @returns A DateTime expression rounded up to the nearest multiple of the step
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * const roundUpMin = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
264
+ * $.return(East.DateTime.roundUpMinute(dt, step));
265
+ * });
266
+ * const compiled = East.compile(roundUpMin.toIR(), []);
267
+ * // Round up to nearest 15 minutes
268
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 22n), 15n); // Rounds to 30 min
269
+ * ```
270
+ */
271
+ roundUpMinute: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
272
+ /**
273
+ * Rounds a DateTime to the nearest multiple of minutes.
274
+ *
275
+ * @param date - The DateTime to round
276
+ * @param step - The minute step size to round to
277
+ * @returns A DateTime expression rounded to the nearest multiple of the step
278
+ *
279
+ * @example
280
+ * ```ts
281
+ * const roundNearMin = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
282
+ * $.return(East.DateTime.roundNearestMinute(dt, step));
283
+ * });
284
+ * const compiled = East.compile(roundNearMin.toIR(), []);
285
+ * // Round to nearest 15 minutes
286
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 22n), 15n); // Rounds to 15 min
287
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 0n, 38n), 15n); // Rounds to 45 min
288
+ * ```
289
+ */
290
+ roundNearestMinute: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
291
+ /**
292
+ * Rounds a DateTime up to the nearest multiple of hours.
293
+ *
294
+ * @param date - The DateTime to round
295
+ * @param step - The hour step size to round to
296
+ * @returns A DateTime expression rounded up to the nearest multiple of the step
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * const roundUpHr = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
301
+ * $.return(East.DateTime.roundUpHour(dt, step));
302
+ * });
303
+ * const compiled = East.compile(roundUpHr.toIR(), []);
304
+ * // Round up to nearest 6 hours
305
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 8n), 6n); // Rounds to 12:00
306
+ * ```
307
+ */
308
+ roundUpHour: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
309
+ /**
310
+ * Rounds a DateTime to the nearest multiple of hours.
311
+ *
312
+ * @param date - The DateTime to round
313
+ * @param step - The hour step size to round to
314
+ * @returns A DateTime expression rounded to the nearest multiple of the step
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * const roundNearHr = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
319
+ * $.return(East.DateTime.roundNearestHour(dt, step));
320
+ * });
321
+ * const compiled = East.compile(roundNearHr.toIR(), []);
322
+ * // Round to nearest 6 hours
323
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 8n), 6n); // Rounds to 6:00
324
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 10n), 6n); // Rounds to 12:00
325
+ * ```
326
+ */
327
+ roundNearestHour: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
328
+ /**
329
+ * Rounds a DateTime down to the nearest multiple of days.
330
+ *
331
+ * @param date - The DateTime to round
332
+ * @param step - The day step size to round to
333
+ * @returns A DateTime expression rounded down to the nearest multiple of the step
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * const roundDownD = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
338
+ * $.return(East.DateTime.roundDownDay(dt, step));
339
+ * });
340
+ * const compiled = East.compile(roundDownD.toIR(), []);
341
+ * // Round down to nearest day
342
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 12n, 30n), 1n); // Rounds to start of day
343
+ * ```
344
+ */
345
+ roundDownDay: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
346
+ /**
347
+ * Rounds a DateTime up to the nearest multiple of days.
348
+ *
349
+ * @param date - The DateTime to round
350
+ * @param step - The day step size to round to
351
+ * @returns A DateTime expression rounded up to the nearest multiple of the step
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * const roundUpD = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
356
+ * $.return(East.DateTime.roundUpDay(dt, step));
357
+ * });
358
+ * const compiled = East.compile(roundUpD.toIR(), []);
359
+ * // Round up to nearest day
360
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 12n, 30n), 1n); // Rounds to next day start
361
+ * ```
362
+ */
363
+ roundUpDay: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
364
+ /**
365
+ * Rounds a DateTime to the nearest multiple of days.
366
+ *
367
+ * @param date - The DateTime to round
368
+ * @param step - The day step size to round to
369
+ * @returns A DateTime expression rounded to the nearest multiple of the step
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * const roundNearD = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
374
+ * $.return(East.DateTime.roundNearestDay(dt, step));
375
+ * });
376
+ * const compiled = East.compile(roundNearD.toIR(), []);
377
+ * // Round to nearest day
378
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 8n), 1n); // Rounds to start of day
379
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 1n, 16n), 1n); // Rounds to next day start
380
+ * ```
381
+ */
382
+ roundNearestDay: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
383
+ /**
384
+ * Rounds a DateTime down to the nearest Monday (ISO week start).
385
+ *
386
+ * @param date - The DateTime to round
387
+ * @param step - The week step size to round to
388
+ * @returns A DateTime expression rounded down to the nearest multiple of weeks (starting on Monday)
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * const roundDownWk = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
393
+ * $.return(East.DateTime.roundDownWeek(dt, step));
394
+ * });
395
+ * const compiled = East.compile(roundDownWk.toIR(), []);
396
+ * // Round down to nearest Monday
397
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 3n), 1n); // Rounds to previous Monday
398
+ * ```
399
+ */
400
+ roundDownWeek: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
401
+ /**
402
+ * Rounds a DateTime up to the nearest Monday (ISO week start).
403
+ *
404
+ * @param date - The DateTime to round
405
+ * @param step - The week step size to round to
406
+ * @returns A DateTime expression rounded up to the nearest multiple of weeks (starting on Monday)
407
+ *
408
+ * @example
409
+ * ```ts
410
+ * const roundUpWk = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
411
+ * $.return(East.DateTime.roundUpWeek(dt, step));
412
+ * });
413
+ * const compiled = East.compile(roundUpWk.toIR(), []);
414
+ * // Round up to nearest Monday
415
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 3n), 1n); // Rounds to next Monday
416
+ * ```
417
+ */
418
+ roundUpWeek: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
419
+ /**
420
+ * Rounds a DateTime to the nearest Monday (ISO week start).
421
+ *
422
+ * @param date - The DateTime to round
423
+ * @param step - The week step size to round to
424
+ * @returns A DateTime expression rounded to the nearest multiple of weeks (starting on Monday)
425
+ *
426
+ * @example
427
+ * ```ts
428
+ * const roundNearWk = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
429
+ * $.return(East.DateTime.roundNearestWeek(dt, step));
430
+ * });
431
+ * const compiled = East.compile(roundNearWk.toIR(), []);
432
+ * // Round to nearest Monday
433
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 3n), 1n); // Rounds to closest Monday
434
+ * ```
435
+ */
436
+ roundNearestWeek: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
437
+ /**
438
+ * Rounds a DateTime down to the nearest month boundary.
439
+ *
440
+ * @param date - The DateTime to round
441
+ * @param step - The month step size to round to
442
+ * @returns A DateTime expression rounded down to the first day of the nearest multiple of months
443
+ *
444
+ * @example
445
+ * ```ts
446
+ * const roundDownMo = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
447
+ * $.return(East.DateTime.roundDownMonth(dt, step));
448
+ * });
449
+ * const compiled = East.compile(roundDownMo.toIR(), []);
450
+ * // Round down to nearest month (first day of the month at midnight)
451
+ * compiled(East.DateTime.fromComponents(2025n, 1n, 15n), 1n); // Rounds to Jan 1, 2025
452
+ * // Round down to nearest quarter (Jan 1, Apr 1, Jul 1, Oct 1)
453
+ * compiled(East.DateTime.fromComponents(2025n, 5n, 15n), 3n); // Rounds to Apr 1, 2025
454
+ * ```
455
+ */
456
+ roundDownMonth: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
457
+ /**
458
+ * Rounds a DateTime down to the nearest year boundary.
459
+ *
460
+ * @param date - The DateTime to round
461
+ * @param step - The year step size to round to
462
+ * @returns A DateTime expression rounded down to January 1st of the nearest multiple of years
463
+ *
464
+ * @example
465
+ * ```ts
466
+ * const roundDownYr = East.function([DateTimeType, IntegerType], DateTimeType, ($, dt, step) => {
467
+ * $.return(East.DateTime.roundDownYear(dt, step));
468
+ * });
469
+ * const compiled = East.compile(roundDownYr.toIR(), []);
470
+ * // Round down to nearest year (January 1st at midnight)
471
+ * compiled(East.DateTime.fromComponents(2025n, 6n, 15n), 1n); // Rounds to Jan 1, 2025
472
+ * // Round down to nearest decade
473
+ * compiled(East.DateTime.fromComponents(2025n, 6n, 15n), 10n); // Rounds to Jan 1, 2020
474
+ * ```
475
+ */
476
+ roundDownYear: import("../function.js").CallableFunctionExpr<[DateTimeType, IntegerType], DateTimeType>;
477
+ };
478
+ export default _default;
479
+ //# sourceMappingURL=datetime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../../src/expr/libs/datetime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGvF,+CAA+C;;IAE7C;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAUH;;;;;;;;;;;;;;;;OAgBG;;IAWH;;;;;;;;;;;;;;;;OAgBG;;IAWH;;;;;;;;;;;;;;;;OAgBG;;IAWH;;;;;;;;;;;;;;;;OAgBG;;IAeH;;;;;;;;;;;;;;;;;OAiBG;;IAmBH;;;;;;;;;;;;;;;;OAgBG;;IAgBH;;;;;;;;;;;;;;;;;OAiBG;;IAoBH;;;;;;;;;;;;;;;;OAgBG;;IAgBH;;;;;;;;;;;;;;;;;OAiBG;;IAoBH;;;;;;;;;;;;;;;;OAgBG;;IAgBH;;;;;;;;;;;;;;;;;OAiBG;;IAoBH;;;;;;;;;;;;;;;;OAgBG;;IAYH;;;;;;;;;;;;;;;;OAgBG;;IAgBH;;;;;;;;;;;;;;;;;OAiBG;;IAoBH;;;;;;;;;;;;;;;;OAgBG;;IAmBH;;;;;;;;;;;;;;;;OAgBG;;IAwBH;;;;;;;;;;;;;;;;OAgBG;;IA4BH;;;;;;;;;;;;;;;;;;OAkBG;;IAkBH;;;;;;;;;;;;;;;;;;OAkBG;;;AAlvBL,wBA8vBC"}