@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
package/README.md ADDED
@@ -0,0 +1,276 @@
1
+ # East
2
+
3
+ **East** is a statically typed, expression-based programming language embedded in TypeScript. Designed for the [Elara](https://elaraai.com/) platform, East enables you to write portable logic once and execute it across multiple environments (JavaScript, Julia, Python, and more), leveraging each language's native performance characteristics and ecosystem.
4
+
5
+ ## Features
6
+
7
+ - **🔒 Static Typing**: All types declared explicitly for speed and correctness
8
+ - **🎯 Structural Typing**: Lightweight and easy to use
9
+ - **🚀 Portable IR**: Compile to JavaScript, with Julia and Python backends coming soon
10
+ - **🔐 Controlled Side Effects**: Secure execution with platform-defined effects
11
+ - **🤖 LLM/MCP Friendly**: Designed for code generation with clear, composable TypeScript API
12
+ - **📦 Minimal Dependencies**: Single runtime dependency (sorted-btree for efficient collections)
13
+ - **🛡️ Total Ordering**: All types (even floats with NaN) have defined comparisons
14
+ - **🔄 Serializable**: Functions and data can be transmitted as IR
15
+
16
+ ## Quick Start
17
+
18
+ ### Installation
19
+
20
+ ```bash
21
+ npm install @elaraai/east
22
+ ```
23
+
24
+ ### Basic Example
25
+
26
+
27
+ ```typescript
28
+ import { East, IntegerType, ArrayType, StructType, StringType, DictType, NullType } from "@elaraai/east";
29
+
30
+ // Platform function for logging
31
+ const log = East.platform("log", [StringType], NullType);
32
+
33
+ const platform = [
34
+ log.implement(console.log),
35
+ ];
36
+
37
+ // Define sale data type
38
+ const SaleType = StructType({
39
+ product: StringType,
40
+ quantity: IntegerType,
41
+ price: IntegerType
42
+ });
43
+
44
+ // Calculate revenue per product from sales data
45
+ const calculateRevenue = East.function(
46
+ [ArrayType(SaleType)],
47
+ DictType(StringType, IntegerType),
48
+ ($, sales) => {
49
+ // Group sales by product and sum revenue (quantity × price)
50
+ const revenueByProduct = sales.groupSum(
51
+ // Group by product name
52
+ ($, sale) => sale.product,
53
+ // Sum quantity × price
54
+ ($, sale) => sale.quantity.multiply(sale.price)
55
+ );
56
+
57
+ // Log revenue for each product
58
+ $(log(East.str`Total Revenue: ${revenueByProduct.sum()}`));
59
+
60
+ $.return(revenueByProduct);
61
+ }
62
+ );
63
+
64
+ // Compile and execute
65
+ const compiled = East.compile(calculateRevenue, platform);
66
+
67
+ const sales = [
68
+ { product: "Widget", quantity: 10n, price: 50n },
69
+ { product: "Gadget", quantity: 5n, price: 100n },
70
+ { product: "Widget", quantity: 3n, price: 50n }
71
+ ];
72
+
73
+ const result = compiled(sales);
74
+ // Result: Map { "Widget" => 650n, "Gadget" => 500n }
75
+ // Logs: "Gadget: $500" and "Widget: $650"
76
+ ```
77
+
78
+ ## Type System
79
+
80
+ East supports a rich type system optimized for business logic and data processing:
81
+
82
+ | Type | ValueTypeOf<Type> | Mutability | Description |
83
+ |------|-----------------|------------|-------------|
84
+ | **Primitive Types** | | | |
85
+ | `NullType` | `null` | Immutable | Unit type (single value) |
86
+ | `BooleanType` | `boolean` | Immutable | True or false |
87
+ | `IntegerType` | `bigint` | Immutable | 64-bit signed integers |
88
+ | `FloatType` | `number` | Immutable | IEEE 754 double-precision |
89
+ | `StringType` | `string` | Immutable | UTF-8 text |
90
+ | `DateTimeType` | `Date` | Immutable | UTC timestamp with millisecond precision |
91
+ | `BlobType` | `Uint8Array` | Immutable | Binary data |
92
+ | **Compound Types** | | | |
93
+ | `ArrayType<T>` | `ValueTypeOf<T>[]` | **Mutable** | Ordered collection |
94
+ | `SetType<K>` | `Set<ValueTypeOf<K>>` | **Mutable** | Sorted set |
95
+ | `DictType<K, V>` | `Map<ValueTypeOf<K>, ValueTypeOf<V>>` | **Mutable** | Sorted dictionary |
96
+ | `StructType<Fields>` | `{...}` | Immutable | Product type (records) |
97
+ | `VariantType<Cases>` | `variant` | Immutable | Sum type (tagged unions) |
98
+ | `RecursiveType<T>` | `ValueTypeOf<T>` | Immutable | Recursive references for trees, DAGs, and circular structures |
99
+ | **Function Type** | | | |
100
+ | `FunctionType<I, O>` | Function | Immutable | First-class functions |
101
+
102
+ ## Documentation
103
+
104
+ - **[USAGE.md](USAGE.md)** - Comprehensive developer guide with API reference
105
+ - **[LICENSE.md](LICENSE.md)** - Dual licensing information (AGPL-3.0 / Commercial)
106
+ - **[CONTRIBUTING.md](CONTRIBUTING.md)** - How to contribute to East
107
+ - **[CLA.md](CLA.md)** - Contributor License Agreement
108
+
109
+ ## Key Concepts
110
+
111
+ ### Platform Functions
112
+
113
+ East code runs in a controlled environment. You define **platform functions** that your East code can call:
114
+
115
+ ```typescript
116
+ // Define platform function helper
117
+ const log = East.platform("log", [StringType], NullType);
118
+ const readFile = East.platform("readFile", [StringType], StringType);
119
+
120
+ // Provide implementations
121
+ const platform = {
122
+ log: (msg: string) => console.log(msg),
123
+ readFile: (path: string) => fs.readFileSync(path, 'utf-8')
124
+ };
125
+
126
+ // Compile with platform
127
+ const compiled = East.compile(myFunction, platform);
128
+ ```
129
+
130
+ ### Fluent Interface
131
+
132
+ Build expressions using chainable methods:
133
+
134
+ ```typescript
135
+ const myFunction = East.function([IntegerType], IntegerType, ($, x) => {
136
+ // Arithmetic
137
+ const result = x.add(10n).multiply(2n).divide(3n);
138
+
139
+ // Collections
140
+ const arr = $.let([1n, 2n, 3n]);
141
+ const doubled = arr.map(($, x, i) => x.multiply(2n));
142
+ const sum = doubled.sum();
143
+
144
+ $.return(sum);
145
+ });
146
+ ```
147
+
148
+ ### Serialization
149
+
150
+ Functions can be serialized as IR and transmitted across environments:
151
+
152
+ ```typescript
153
+ // Convert to IR
154
+ const ir = myFunction.toIR();
155
+
156
+ // Serialize to JSON (handles bigints, NaN, Infinity correctly)
157
+ const jsonData = ir.toJSON();
158
+ const jsonString = JSON.stringify(jsonData);
159
+
160
+ // Send over network, save to file, etc.
161
+ // ...
162
+
163
+ // Deserialize and compile
164
+ const receivedData = JSON.parse(jsonString);
165
+ const receivedIR = EastIR.fromJSON(receivedData);
166
+ const compiled = receivedIR.compile(platform);
167
+ ```
168
+
169
+ ## Examples
170
+
171
+ See the [examples](./examples) directory for more:
172
+
173
+ - **[example.ts](./examples/example.ts)** - Basic examples demonstrating core features
174
+
175
+ ## Development
176
+
177
+ ### Building
178
+
179
+ ```bash
180
+ npm run build # Compile TypeScript to JavaScript
181
+ npm run test # Run test suite (requires build first)
182
+ npm run lint # Check code quality with ESLint
183
+ npm run example # Run the basic example
184
+ ```
185
+
186
+ ### Testing
187
+
188
+ East has a comprehensive test suite with tests covering:
189
+
190
+ - Type system operations
191
+ - Serialization formats (BEAST v1/v2, JSON, EAST text format)
192
+ - Collections and functional operations
193
+ - Error handling and edge cases
194
+
195
+ ### Release Process
196
+
197
+ East uses automated releases via GitHub Actions. The process differs for stable and beta releases:
198
+
199
+ #### Stable Releases
200
+
201
+ For stable releases (published to npm with `latest` tag):
202
+
203
+ ```bash
204
+ npm run release:patch # 0.0.1 → 0.0.2
205
+ npm run release:minor # 0.0.1 → 0.1.0
206
+ npm run release:major # 0.0.1 → 1.0.0
207
+ ```
208
+
209
+ These commands will:
210
+ 1. Bump the version in `package.json`
211
+ 2. Create a git commit with message `chore: bump version to X.Y.Z`
212
+ 3. Create a git tag `vX.Y.Z`
213
+ 4. Push the commit and tag to GitHub
214
+ 5. GitHub Actions automatically builds, tests, and publishes to npm with `latest` tag
215
+
216
+ #### Beta Releases
217
+
218
+ For beta/prerelease versions (published to npm with `beta` tag):
219
+
220
+ ```bash
221
+ npm run release:prepatch # 0.0.1 → 0.0.2-beta.0
222
+ npm run release:preminor # 0.0.1 → 0.1.0-beta.0
223
+ npm run release:premajor # 0.0.1 → 1.0.0-beta.0
224
+ npm run release:prerelease # 0.0.1-beta.0 → 0.0.1-beta.1
225
+ ```
226
+
227
+ Beta releases follow the same automated process but are published to npm with the `beta` tag.
228
+
229
+ #### Manual Version Bumping (Dry Run)
230
+
231
+ To update the version without committing or tagging:
232
+
233
+ ```bash
234
+ npm run version:patch:dry
235
+ npm run version:minor:dry
236
+ npm run version:major:dry
237
+ npm run version:prepatch:dry
238
+ npm run version:preminor:dry
239
+ npm run version:premajor:dry
240
+ npm run version:prerelease:dry
241
+ ```
242
+
243
+ #### Requirements
244
+
245
+ - **Automated Publishing**: Requires `NPM_TOKEN` secret configured in GitHub repository settings
246
+ - **Pre-publish Checks**: All tests and linting must pass before publishing (enforced by `prepublishOnly` hook)
247
+ - **Node Version**: Requires Node.js ≥22.0.0
248
+
249
+ ## License
250
+
251
+ This project is dual-licensed:
252
+
253
+ - **Open Source**: [AGPL-3.0](LICENSE.md) - Free for open source use with source disclosure requirements
254
+ - **Commercial**: Available for proprietary use - contact support@elara.ai
255
+
256
+ See [LICENSE.md](LICENSE.md) for full details.
257
+
258
+ ## Contributing
259
+
260
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
261
+
262
+ **Note**: Contributors must sign our [CLA](CLA.md) before we can accept pull requests. This allows us to offer commercial licenses while keeping the project open source.
263
+
264
+ ## Links
265
+
266
+ - **Website**: [https://elaraai.com/](https://elaraai.com/)
267
+ - **Repository**: [https://github.com/elaraai/East](https://github.com/elaraai/East)
268
+ - **Issues**: [https://github.com/elaraai/East/issues](https://github.com/elaraai/East/issues)
269
+ - **Email**: support@elara.ai
270
+
271
+ ## About Elara
272
+
273
+ East is developed by [Elara AI Pty Ltd](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across work management, purchasing, customer engagement, and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.
274
+
275
+ ---
276
+
@@ -0,0 +1,95 @@
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
+ * Analysis and validation of IR for JavaScript backend compilation.
7
+ *
8
+ * This module provides backend-specific enrichment of universal IR,
9
+ * computing metadata needed for efficient JavaScript closure compilation.
10
+ * Different backends (Julia, Python, etc.) would have their own analysis modules.
11
+ */
12
+ import type { IR } from "./ir.js";
13
+ import type { EastTypeValue } from "./type_of_type.js";
14
+ /**
15
+ * Platform definition for JavaScript backend.
16
+ *
17
+ * Maps platform function names to their implementations and async metadata.
18
+ * Different JavaScript execution environments may provide different platforms
19
+ * with the same functions but different async characteristics.
20
+ *
21
+ * Types are stored as EastTypeValue (IR representation) rather than EastType
22
+ * (front-end representation) to avoid repeated conversion during analysis.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const log = East.platform("log", [StringType], NullType);
27
+ * const readFile = East.platform("readFile", [StringType], StringType);
28
+ *
29
+ * const platform = [
30
+ * log.implement(console.log),
31
+ * readFile.implementAsync(fs.promises.readFile),
32
+ * ];
33
+ * ```
34
+ */
35
+ export type PlatformDefinition = {
36
+ name: string;
37
+ inputs: EastTypeValue[];
38
+ output: EastTypeValue;
39
+ type: 'sync' | 'async';
40
+ };
41
+ export type AnalyzedIR<T extends IR = IR> = T & {
42
+ value: {
43
+ isAsync: boolean;
44
+ };
45
+ };
46
+ /**
47
+ * Variable metadata tracked during analysis.
48
+ *
49
+ * Tracks type information and other properties needed for optimization
50
+ * and code generation.
51
+ */
52
+ export interface VariableMetadata {
53
+ /** The East type of this variable */
54
+ type: EastTypeValue;
55
+ /** Whether this variable can be mutated (let vs const) */
56
+ mutable: boolean;
57
+ /** The IR node that defined this variable (VariableIR from Let or Function parameter) */
58
+ definedBy: IR;
59
+ /** Whether this variable is captured by a nested function (mutated during analysis) */
60
+ captured: boolean;
61
+ }
62
+ /**
63
+ * Variable context mapping names to their metadata.
64
+ *
65
+ * Used during analysis to track variable types and properties.
66
+ */
67
+ export type VariableContext = Record<string, VariableMetadata>;
68
+ /**
69
+ * Analyze IR tree and produce enriched IR for JavaScript backend.
70
+ *
71
+ * This function:
72
+ * - Validates the IR (type checking, variable scope, etc.)
73
+ * - Computes which nodes require async compilation
74
+ * - Returns enriched IR with metadata populated (isAsync, etc.)
75
+ *
76
+ * @param ir - The IR tree to analyze
77
+ * @param platformDef - Platform function definitions with async metadata
78
+ * @param ctx - Variable context mapping variable names to their metadata
79
+ * @returns Enriched IR with metadata fields populated
80
+ * @throws {Error} If IR is invalid (type errors, undefined variables, etc.)
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const ir = // ... parsed East program
85
+ * const platform = [
86
+ * log.implement(console.log),
87
+ * fetch.implementAsync(fetch)
88
+ * ];
89
+ *
90
+ * const enrichedIR = analyzeIR(ir, platform, {});
91
+ * const compiled = compile_internal(enrichedIR, {}, platform);
92
+ * ```
93
+ */
94
+ export declare function analyzeIR(ir: IR, platformDef: PlatformDefinition[], ctx?: VariableContext): AnalyzedIR;
95
+ //# sourceMappingURL=analyze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAc,EAAE,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,mBAAmB,CAAC;AAOxE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG;IAAE,KAAK,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,CAAC;AAGhF;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,EAAE,aAAa,CAAC;IAEpB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAC;IAEjB,yFAAyF;IACzF,SAAS,EAAE,EAAE,CAAC;IAEd,uFAAuF;IACvF,QAAQ,EAAE,OAAO,CAAC;CAYnB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CACvB,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,kBAAkB,EAAE,EACjC,GAAG,GAAE,eAAoB,GACxB,UAAU,CAo6CZ"}