@elaraai/east-node-cli 1.0.68 → 1.0.69
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.
- package/README.md +66 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -1
- package/dist/export-functions.d.ts +29 -0
- package/dist/export-functions.d.ts.map +1 -0
- package/dist/export-functions.js +71 -0
- package/dist/export-functions.js.map +1 -0
- package/dist/export-functions.spec.d.ts +6 -0
- package/dist/export-functions.spec.d.ts.map +1 -0
- package/dist/export-functions.spec.js +104 -0
- package/dist/export-functions.spec.js.map +1 -0
- package/dist/transpile.d.ts +58 -0
- package/dist/transpile.d.ts.map +1 -0
- package/dist/transpile.js +129 -0
- package/dist/transpile.js.map +1 -0
- package/dist/transpile.spec.d.ts +6 -0
- package/dist/transpile.spec.d.ts.map +1 -0
- package/dist/transpile.spec.js +110 -0
- package/dist/transpile.spec.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,6 +57,35 @@ east-node version
|
|
|
57
57
|
east-node version -p @elaraai/east-node-std -p @elaraai/east-node-io
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
### Transpiling IR to TypeScript
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Print an IR program as East.function builder source
|
|
64
|
+
east-node transpile ./program.beast2 -o program.ts
|
|
65
|
+
|
|
66
|
+
# Every IR file in a directory, plus the IR each printed module builds
|
|
67
|
+
# back — the round-trip check
|
|
68
|
+
east-node transpile ./ir/ -o ./ts/ --rebuild ./rebuilt/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The printed module imports `@elaraai/east` and rebuilds the same IR
|
|
72
|
+
(equal under `east-c ir normalize`): the `$`-forms for statements,
|
|
73
|
+
expression methods and `East.value(..., T)` constructions for values.
|
|
74
|
+
Builtins the TypeScript surface has no spelling for print through
|
|
75
|
+
`East.builtin(...)`. `east-py transpile` is the python twin; the two
|
|
76
|
+
printers and the cross-language sweep are described in
|
|
77
|
+
`docs/conventions/EAST_CODEGEN.md`.
|
|
78
|
+
|
|
79
|
+
### Exporting functions for another language
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Write a module's `eastFunctions` export as a function manifest that a python
|
|
83
|
+
# package (or another TypeScript package) imports with East.import_function /
|
|
84
|
+
# East.importFunction; -p names the platform packages implementing any
|
|
85
|
+
# platform calls the functions make
|
|
86
|
+
east-node export-functions dist/pricing.js -o pricing.functions.beast2 -p @elaraai/east-node-std
|
|
87
|
+
```
|
|
88
|
+
|
|
60
89
|
## CLI Reference
|
|
61
90
|
|
|
62
91
|
### `east-node run`
|
|
@@ -77,6 +106,43 @@ Options:
|
|
|
77
106
|
-h, --help Display help
|
|
78
107
|
```
|
|
79
108
|
|
|
109
|
+
### `east-node transpile`
|
|
110
|
+
|
|
111
|
+
Print an East IR program as TypeScript `East.function` builder source.
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
east-node transpile <input> [options]
|
|
115
|
+
|
|
116
|
+
Arguments:
|
|
117
|
+
input Path to an IR file (.beast2, .beast, .east, or .json), or a directory of them
|
|
118
|
+
|
|
119
|
+
Options:
|
|
120
|
+
-o, --output <path> Write the module here (a directory when <input> is one; default: stdout)
|
|
121
|
+
--name <name> The module-level export bound to the rebuilt function (default: main)
|
|
122
|
+
--import-from <specifier> The module the printed source imports East from (default: @elaraai/east)
|
|
123
|
+
--rebuild <path> Import the printed module and write the IR it builds here
|
|
124
|
+
(.beast2 or .json; a directory in directory mode)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### `east-node export-functions`
|
|
128
|
+
|
|
129
|
+
Write a module's `eastFunctions` export (name → `East.function` result) as a function manifest.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
east-node export-functions <module> -o <file> [options]
|
|
133
|
+
|
|
134
|
+
Arguments:
|
|
135
|
+
module Path to the built module exporting `eastFunctions`
|
|
136
|
+
|
|
137
|
+
Options:
|
|
138
|
+
-o, --output <file> The manifest to write (.beast2)
|
|
139
|
+
-p, --package <package...> Platform packages implementing the functions' platform calls
|
|
140
|
+
(every dependency must be provided by one; recorded as its provider)
|
|
141
|
+
--name <name> The package name importers use (default: the module file's stem)
|
|
142
|
+
--package-version <version> The version recorded in the manifest (default: 0.0.0)
|
|
143
|
+
--only <name...> Export only these functions of `eastFunctions` (default: all)
|
|
144
|
+
```
|
|
145
|
+
|
|
80
146
|
### `east-node version`
|
|
81
147
|
|
|
82
148
|
Show version information.
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2PH,wBAAgB,IAAI,IAAI,IAAI,CAwD3B"}
|
package/dist/cli.js
CHANGED
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
5
|
import { Command } from 'commander';
|
|
6
|
+
import { writeFileSync } from 'node:fs';
|
|
6
7
|
import { createRequire } from 'module';
|
|
7
8
|
import { EastError } from '@elaraai/east/internal';
|
|
8
9
|
import { loadPlatforms, loadPlatformWithMetadata } from './loader.js';
|
|
9
10
|
import { runProgram } from './runner.js';
|
|
10
11
|
import { writeSnapshot, readSnapshot } from './snapshot.js';
|
|
12
|
+
import { encodeRebuilt, isDirectory, transpile, transpileDir } from './transpile.js';
|
|
13
|
+
import { exportFunctionsFromModule } from './export-functions.js';
|
|
14
|
+
import { East } from '@elaraai/east';
|
|
11
15
|
const require = createRequire(import.meta.url);
|
|
12
16
|
const pkg = require('../package.json');
|
|
13
17
|
/** Parses the streaming-execution flags into runner options. */
|
|
@@ -111,6 +115,65 @@ async function cmdRun(irFile, options) {
|
|
|
111
115
|
: (e.stack ?? `Error: ${e.message ?? String(err)}`));
|
|
112
116
|
}
|
|
113
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* `east-node transpile` (#628): print an IR file — or every IR file in a
|
|
120
|
+
* directory — as the TypeScript `East.function` builder surface. With
|
|
121
|
+
* `--rebuild`, the printed module is imported and the IR it builds is
|
|
122
|
+
* written too: the round-trip check, and the TypeScript leg of the
|
|
123
|
+
* cross-language conformance sweep.
|
|
124
|
+
*/
|
|
125
|
+
async function cmdTranspile(input, options) {
|
|
126
|
+
try {
|
|
127
|
+
const common = {};
|
|
128
|
+
if (options.name !== undefined)
|
|
129
|
+
common.name = options.name;
|
|
130
|
+
if (options.importFrom !== undefined)
|
|
131
|
+
common.importFrom = options.importFrom;
|
|
132
|
+
if (isDirectory(input)) {
|
|
133
|
+
if (!options.output) {
|
|
134
|
+
return fail('Error: transpiling a directory needs -o <directory> for the modules');
|
|
135
|
+
}
|
|
136
|
+
const stems = await transpileDir(input, options.output, options.rebuild !== undefined ? { ...common, rebuildDir: options.rebuild } : common);
|
|
137
|
+
console.error(`Transpiled ${stems.length} IR file(s) to ${options.output}` +
|
|
138
|
+
(options.rebuild ? `, rebuilt to ${options.rebuild}` : ''));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const { source, rebuilt } = await transpile(input, { ...common, rebuild: options.rebuild !== undefined });
|
|
142
|
+
if (options.output) {
|
|
143
|
+
writeFileSync(options.output, source, 'utf-8');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
process.stdout.write(source);
|
|
147
|
+
}
|
|
148
|
+
if (options.rebuild) {
|
|
149
|
+
writeFileSync(options.rebuild, encodeRebuilt(rebuilt, options.rebuild));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
return fail(`Error: ${err.message}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* `east-node export-functions` (#628): write a module's `eastFunctions` as a
|
|
158
|
+
* function manifest other packages — in TypeScript or python — import.
|
|
159
|
+
*/
|
|
160
|
+
async function cmdExportFunctions(modulePath, options) {
|
|
161
|
+
try {
|
|
162
|
+
const opts = { packages: options.package ?? [] };
|
|
163
|
+
if (options.name !== undefined)
|
|
164
|
+
opts.name = options.name;
|
|
165
|
+
if (options.packageVersion !== undefined)
|
|
166
|
+
opts.version = options.packageVersion;
|
|
167
|
+
if (options.only !== undefined)
|
|
168
|
+
opts.only = options.only;
|
|
169
|
+
const manifest = await exportFunctionsFromModule(modulePath, opts);
|
|
170
|
+
writeFileSync(options.output, East.encodeFunctionManifest(manifest));
|
|
171
|
+
console.error(`Exported ${manifest.functions.length} function(s) of ${manifest.package}@${manifest.version} to ${options.output}`);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
return fail(`Error: ${err.message}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
114
177
|
async function cmdVersion(options) {
|
|
115
178
|
console.log(`${pkg.name} ${pkg.version}`);
|
|
116
179
|
// Try to get east version
|
|
@@ -156,6 +219,25 @@ export function main() {
|
|
|
156
219
|
.option('--stream <index>', 'Feed the given -i input (0-based) lazily, segment-by-segment')
|
|
157
220
|
.option('--lazy-inputs <bytes>', 'Open indexed collection inputs at or above this size lazily (0 disables; default 64 MiB)')
|
|
158
221
|
.action(cmdRun);
|
|
222
|
+
program
|
|
223
|
+
.command('transpile')
|
|
224
|
+
.description('Print an East IR program as TypeScript East.function builder source')
|
|
225
|
+
.argument('<input>', 'Path to an IR file (.beast2, .beast, .east, or .json), or a directory of them')
|
|
226
|
+
.option('-o, --output <path>', 'Write the module here (a directory when <input> is one; default: stdout)')
|
|
227
|
+
.option('--name <name>', 'The module-level export bound to the rebuilt function (default: main)')
|
|
228
|
+
.option('--import-from <specifier>', 'The module the printed source imports East from (default: @elaraai/east)')
|
|
229
|
+
.option('--rebuild <path>', 'Import the printed module and write the IR it builds here (.beast2 or .json; a directory in directory mode)')
|
|
230
|
+
.action(cmdTranspile);
|
|
231
|
+
program
|
|
232
|
+
.command('export-functions')
|
|
233
|
+
.description("Write a module's `eastFunctions` export as a function manifest other packages (TypeScript or python) import")
|
|
234
|
+
.argument('<module>', 'Path to the built module exporting `eastFunctions` (name -> East.function)')
|
|
235
|
+
.requiredOption('-o, --output <file>', 'The manifest to write (.beast2)')
|
|
236
|
+
.option('-p, --package <package...>', "Platform packages implementing the functions' platform calls (each dependency must be provided by one)")
|
|
237
|
+
.option('--name <name>', "The package name importers use (default: the module file's stem)")
|
|
238
|
+
.option('--package-version <version>', 'The version recorded in the manifest (default: 0.0.0)')
|
|
239
|
+
.option('--only <name...>', 'Export only these functions of `eastFunctions` (default: all)')
|
|
240
|
+
.action(cmdExportFunctions);
|
|
159
241
|
program
|
|
160
242
|
.command('version')
|
|
161
243
|
.description('Show version information')
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,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+
*/
|
|
5
|
+
import { type FunctionManifest } from '@elaraai/east';
|
|
6
|
+
/** Options for {@link exportFunctionsFromModule}. */
|
|
7
|
+
export interface ExportFunctionsOptions {
|
|
8
|
+
/** The package name importers use (default: the module file's stem). */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** The version recorded in the manifest (default `0.0.0`). */
|
|
11
|
+
version?: string;
|
|
12
|
+
/** Platform packages implementing the functions' platform calls. */
|
|
13
|
+
packages?: string[];
|
|
14
|
+
/** Export only these functions of `eastFunctions` (default: all); a name it does not export is an error naming what it does. */
|
|
15
|
+
only?: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Loads a module and builds the manifest of its `eastFunctions` export
|
|
19
|
+
* (name → `East.function` result).
|
|
20
|
+
*
|
|
21
|
+
* @param modulePath - Path to the module (a built `.js` / `.mjs`)
|
|
22
|
+
* @param options - Package name, version, the providing platform packages, and the functions to export
|
|
23
|
+
* @returns The manifest value
|
|
24
|
+
* @throws When the module has no `eastFunctions` object, a function in
|
|
25
|
+
* `only` is not exported, a function is not a closed value, or a platform
|
|
26
|
+
* dependency has no providing package
|
|
27
|
+
*/
|
|
28
|
+
export declare function exportFunctionsFromModule(modulePath: string, options?: ExportFunctionsOptions): Promise<FunctionManifest>;
|
|
29
|
+
//# sourceMappingURL=export-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-functions.d.ts","sourceRoot":"","sources":["../src/export-functions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,EAAQ,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG5D,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACnC,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,gIAAgI;IAChI,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoCnI"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
* `east-node export-functions` (#628): a module's `eastFunctions` export
|
|
7
|
+
* written as a function manifest that other packages — in TypeScript or
|
|
8
|
+
* python — import with `East.importFunction` / `East.import_function`.
|
|
9
|
+
* The twin of `east-py export-functions`.
|
|
10
|
+
*
|
|
11
|
+
* Every platform function the exported functions call must be implemented
|
|
12
|
+
* by one of the `-p` platform packages, which is recorded as the
|
|
13
|
+
* dependency's provider; a dependency no package provides is an error
|
|
14
|
+
* naming it, so an importer's runner can be checked at its own build.
|
|
15
|
+
* `only` narrows the export to the named functions — what an importer
|
|
16
|
+
* actually uses — so a sibling function's platform call never fails an
|
|
17
|
+
* export that does not need it.
|
|
18
|
+
*/
|
|
19
|
+
import { basename, extname, resolve } from 'node:path';
|
|
20
|
+
import { pathToFileURL } from 'node:url';
|
|
21
|
+
import { East } from '@elaraai/east';
|
|
22
|
+
import { loadPlatform } from './loader.js';
|
|
23
|
+
/**
|
|
24
|
+
* Loads a module and builds the manifest of its `eastFunctions` export
|
|
25
|
+
* (name → `East.function` result).
|
|
26
|
+
*
|
|
27
|
+
* @param modulePath - Path to the module (a built `.js` / `.mjs`)
|
|
28
|
+
* @param options - Package name, version, the providing platform packages, and the functions to export
|
|
29
|
+
* @returns The manifest value
|
|
30
|
+
* @throws When the module has no `eastFunctions` object, a function in
|
|
31
|
+
* `only` is not exported, a function is not a closed value, or a platform
|
|
32
|
+
* dependency has no providing package
|
|
33
|
+
*/
|
|
34
|
+
export async function exportFunctionsFromModule(modulePath, options = {}) {
|
|
35
|
+
const path = resolve(modulePath);
|
|
36
|
+
const mod = await import(pathToFileURL(path).href);
|
|
37
|
+
const exported = mod.eastFunctions;
|
|
38
|
+
if (exported === null || typeof exported !== 'object') {
|
|
39
|
+
throw new Error(`${modulePath} exports no \`eastFunctions\` object (name -> East.function result)`);
|
|
40
|
+
}
|
|
41
|
+
let functions = exported;
|
|
42
|
+
if (options.only !== undefined) {
|
|
43
|
+
const missing = options.only.filter(name => !(name in functions));
|
|
44
|
+
if (missing.length > 0) {
|
|
45
|
+
throw new Error(`${modulePath} exports no function${missing.length === 1 ? '' : 's'} ${missing.map(n => JSON.stringify(n)).join(', ')} — ` +
|
|
46
|
+
`its eastFunctions are ${Object.keys(functions).join(', ') || '(none)'}`);
|
|
47
|
+
}
|
|
48
|
+
functions = Object.fromEntries(options.only.map(name => [name, exported[name]]));
|
|
49
|
+
}
|
|
50
|
+
const providers = {};
|
|
51
|
+
for (const pkg of options.packages ?? []) {
|
|
52
|
+
for (const fn of await loadPlatform(pkg)) {
|
|
53
|
+
if (!(fn.name in providers))
|
|
54
|
+
providers[fn.name] = pkg;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const missing = new Set();
|
|
58
|
+
for (const fn of Object.values(functions)) {
|
|
59
|
+
for (const dep of East.platformDependencies(fn)) {
|
|
60
|
+
if (!(dep.name in providers))
|
|
61
|
+
missing.add(dep.name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (missing.size > 0) {
|
|
65
|
+
throw new Error(`platform function(s) no -p package provides: ${[...missing].sort().join(', ')} — ` +
|
|
66
|
+
'pass the implementing package with -p');
|
|
67
|
+
}
|
|
68
|
+
const name = options.name ?? basename(path, extname(path));
|
|
69
|
+
return East.exportFunctions(name, options.version ?? '0.0.0', functions, { providers });
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=export-functions.js.map
|
|
@@ -0,0 +1 @@
|
|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K;YACnF,uCAAuC,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,EAAE,SAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-functions.spec.d.ts","sourceRoot":"","sources":["../src/export-functions.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
* Tests for `east-node export-functions` (#628): a module's `eastFunctions`
|
|
7
|
+
* export becomes a manifest that links and runs; unprovided platform
|
|
8
|
+
* dependencies and a missing export are named.
|
|
9
|
+
*/
|
|
10
|
+
import { describe, it } from 'node:test';
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { East, EastIR, FunctionType, IntegerType } from '@elaraai/east';
|
|
16
|
+
import { exportFunctionsFromModule } from './export-functions.js';
|
|
17
|
+
const EAST = import.meta.resolve('@elaraai/east');
|
|
18
|
+
const MODULE = `
|
|
19
|
+
import { East, IntegerType, NullType, StringType } from ${JSON.stringify(EAST)};
|
|
20
|
+
const log = East.platform("log", [StringType], NullType);
|
|
21
|
+
export const double = East.function([IntegerType], IntegerType, ($, x) => x.multiply(2n));
|
|
22
|
+
export const shout = East.function([StringType], NullType, ($, s) => { $(log(s.upperCase())); });
|
|
23
|
+
export const eastFunctions = { double, shout };
|
|
24
|
+
`;
|
|
25
|
+
/**
|
|
26
|
+
* Plants the module under a fake project that also provides the `log`
|
|
27
|
+
* platform as its own `./platform` package (`acme-platform`), the way the
|
|
28
|
+
* loader resolves a project's platform from the cwd.
|
|
29
|
+
*/
|
|
30
|
+
function plant(source) {
|
|
31
|
+
const dir = mkdtempSync(join(tmpdir(), 'enc-export-'));
|
|
32
|
+
const path = join(dir, 'pricing.mjs');
|
|
33
|
+
writeFileSync(path, source, 'utf-8');
|
|
34
|
+
const pkg = join(dir, 'node_modules', 'acme-platform');
|
|
35
|
+
mkdirSync(join(pkg, 'dist'), { recursive: true });
|
|
36
|
+
writeFileSync(join(pkg, 'package.json'), JSON.stringify({
|
|
37
|
+
name: 'acme-platform', version: '1.0.0', type: 'module',
|
|
38
|
+
exports: { './platform': './dist/platform.js', './package.json': './package.json' },
|
|
39
|
+
}));
|
|
40
|
+
writeFileSync(join(pkg, 'dist', 'platform.js'), 'export default [{ name: "log", inputs: [{ type: "String", value: null }], output: { type: "Null", value: null }, type: "sync", fn: () => null }];\n');
|
|
41
|
+
return { dir, path };
|
|
42
|
+
}
|
|
43
|
+
/** Runs `fn` with `process.cwd()` at `dir`, where the fake platform package resolves. */
|
|
44
|
+
async function withCwd(dir, fn) {
|
|
45
|
+
const prev = process.cwd();
|
|
46
|
+
process.chdir(dir);
|
|
47
|
+
try {
|
|
48
|
+
return await fn();
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
process.chdir(prev);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
describe('east-node export-functions', () => {
|
|
55
|
+
it('writes a manifest that links and runs, recording each dependency\'s provider', async () => {
|
|
56
|
+
const { dir, path } = plant(MODULE);
|
|
57
|
+
try {
|
|
58
|
+
const manifest = await withCwd(dir, () => exportFunctionsFromModule(path, { version: '2.0.0', packages: ['acme-platform'] }));
|
|
59
|
+
assert.equal(manifest.package, 'pricing');
|
|
60
|
+
assert.equal(manifest.version, '2.0.0');
|
|
61
|
+
assert.deepEqual(manifest.functions.map(f => f.name), ['double', 'shout']);
|
|
62
|
+
assert.equal(manifest.functions[1].platforms[0].provider.value, 'acme-platform');
|
|
63
|
+
const back = East.decodeFunctionManifest(East.encodeFunctionManifest(manifest));
|
|
64
|
+
const imported = East.importFunction('pricing', 'double', FunctionType([IntegerType], IntegerType));
|
|
65
|
+
const user = East.function([IntegerType], IntegerType, ($, x) => imported(x).add(1n));
|
|
66
|
+
const { ir } = East.linkImports(user, [back]);
|
|
67
|
+
assert.equal(new EastIR(ir).compile([])(4n), 9n);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
rmSync(dir, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
it('names a platform dependency no package provides', async () => {
|
|
74
|
+
const { dir, path } = plant(MODULE);
|
|
75
|
+
try {
|
|
76
|
+
await assert.rejects(exportFunctionsFromModule(path, {}), /no -p package provides: log/);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
rmSync(dir, { recursive: true, force: true });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
it('exports only the named functions — a sibling\'s unprovided platform call no longer matters — and names an unknown one', async () => {
|
|
83
|
+
const { dir, path } = plant(MODULE);
|
|
84
|
+
try {
|
|
85
|
+
// `shout` calls `log`, which no -p package provides here; exporting `double` alone is fine
|
|
86
|
+
const manifest = await exportFunctionsFromModule(path, { only: ['double'] });
|
|
87
|
+
assert.deepEqual(manifest.functions.map(f => f.name), ['double']);
|
|
88
|
+
await assert.rejects(exportFunctionsFromModule(path, { only: ['double', 'nope'] }), /exports no function "nope" — its eastFunctions are double, shout/);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
rmSync(dir, { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
it('needs the eastFunctions export', async () => {
|
|
95
|
+
const { dir, path } = plant('export const x = 1;\n');
|
|
96
|
+
try {
|
|
97
|
+
await assert.rejects(exportFunctionsFromModule(path, {}), /exports no `eastFunctions` object/);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
rmSync(dir, { recursive: true, force: true });
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=export-functions.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-functions.spec.js","sourceRoot":"","sources":["../src/export-functions.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAElD,MAAM,MAAM,GAAG;0DAC2C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;;;;CAK7E,CAAC;AAEF;;;;GAIG;AACH,SAAS,KAAK,CAAC,MAAc;IACzB,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACtC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAA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C,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACrD,IAAI,CAAC;YACD,MAAM,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,mCAAmC,CAAC,CAAC;QACnG,CAAC;gBAAS,CAAC;YACP,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 type { EastIR, AsyncEastIR } from '@elaraai/east';
|
|
6
|
+
/** Options for {@link transpile}. */
|
|
7
|
+
export interface TranspileOptions {
|
|
8
|
+
/** The module-level export bound to the rebuilt function (default `main`). */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** The module specifier the printed source imports from (default `@elaraai/east`). */
|
|
11
|
+
importFrom?: string;
|
|
12
|
+
/** Import the printed module and return the IR it builds. */
|
|
13
|
+
rebuild?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The result of transpiling one IR file. */
|
|
16
|
+
export interface Transpiled {
|
|
17
|
+
/** The printed TypeScript module. */
|
|
18
|
+
source: string;
|
|
19
|
+
/** The IR the printed module builds — present when `rebuild` was requested. */
|
|
20
|
+
rebuilt?: EastIR<any, any> | AsyncEastIR<any, any>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Prints an IR file as a TypeScript module, optionally rebuilding it.
|
|
24
|
+
*
|
|
25
|
+
* @param irPath - Path to the IR file (`.beast2`, `.beast`, `.east`, or `.json`)
|
|
26
|
+
* @param options - Export name, import specifier, and whether to rebuild
|
|
27
|
+
* @returns The module source, and the rebuilt IR when requested
|
|
28
|
+
* @throws When the file is not a function IR, or the IR has a shape the
|
|
29
|
+
* TypeScript surface cannot spell (`Unprintable`), or the printed module
|
|
30
|
+
* does not rebuild
|
|
31
|
+
*/
|
|
32
|
+
export declare function transpile(irPath: string, options?: TranspileOptions): Promise<Transpiled>;
|
|
33
|
+
/**
|
|
34
|
+
* Encodes a rebuilt IR for a path: `.beast2` / `.beast` as the IR bundle
|
|
35
|
+
* (source map included), `.json` as the raw IR JSON `east-node run` reads.
|
|
36
|
+
*
|
|
37
|
+
* @param eastIR - The rebuilt IR bundle
|
|
38
|
+
* @param outPath - The path it will be written to; its extension picks the format
|
|
39
|
+
* @returns The encoded bytes
|
|
40
|
+
*/
|
|
41
|
+
export declare function encodeRebuilt(eastIR: EastIR<any, any> | AsyncEastIR<any, any>, outPath: string): Uint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* Transpiles every IR file in a directory: `<stem>.ts` under `outDir` for
|
|
44
|
+
* each `<stem>.<beast2|beast|east|json>`, and — when `rebuildDir` is given —
|
|
45
|
+
* `<stem>.beast2` there holding the IR each module builds.
|
|
46
|
+
*
|
|
47
|
+
* @param inDir - The directory of IR files (other files are ignored)
|
|
48
|
+
* @param outDir - Where the modules go (created)
|
|
49
|
+
* @param options - Export name, import specifier, and the rebuild directory
|
|
50
|
+
* @returns The stems transpiled, in order
|
|
51
|
+
* @throws On the first file that does not transpile, naming it
|
|
52
|
+
*/
|
|
53
|
+
export declare function transpileDir(inDir: string, outDir: string, options?: TranspileOptions & {
|
|
54
|
+
rebuildDir?: string;
|
|
55
|
+
}): Promise<string[]>;
|
|
56
|
+
/** Whether a path is a directory. */
|
|
57
|
+
export declare function isDirectory(path: string): boolean;
|
|
58
|
+
//# sourceMappingURL=transpile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.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
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `east-node transpile` (#628): an East IR file printed as the TypeScript
|
|
7
|
+
* `East.function` builder surface — `East.toSource` behind a CLI, the twin
|
|
8
|
+
* of `east-py transpile`.
|
|
9
|
+
*
|
|
10
|
+
* The printed module rebuilds the same IR (normalized) when imported, and a
|
|
11
|
+
* rebuild proves it here: the module is imported against this CLI's own
|
|
12
|
+
* `@elaraai/east` and the IR it builds is returned (and written, on the
|
|
13
|
+
* CLI) beside the source. That is the TypeScript leg of the cross-language
|
|
14
|
+
* round trip the east-py conformance suite drives: IR → python → IR →
|
|
15
|
+
* TypeScript → IR, every leg equal under `east-c ir normalize`.
|
|
16
|
+
*/
|
|
17
|
+
import { mkdirSync, mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { tmpdir } from 'node:os';
|
|
19
|
+
import { basename, extname, join } from 'node:path';
|
|
20
|
+
import { pathToFileURL } from 'node:url';
|
|
21
|
+
import { encodeEastIR, encodeJSONFor, IRType, toSource } from '@elaraai/east';
|
|
22
|
+
import { loadIR } from './loader.js';
|
|
23
|
+
const IR_EXTENSIONS = new Set(['.beast2', '.beast', '.east', '.json']);
|
|
24
|
+
/**
|
|
25
|
+
* Prints an IR file as a TypeScript module, optionally rebuilding it.
|
|
26
|
+
*
|
|
27
|
+
* @param irPath - Path to the IR file (`.beast2`, `.beast`, `.east`, or `.json`)
|
|
28
|
+
* @param options - Export name, import specifier, and whether to rebuild
|
|
29
|
+
* @returns The module source, and the rebuilt IR when requested
|
|
30
|
+
* @throws When the file is not a function IR, or the IR has a shape the
|
|
31
|
+
* TypeScript surface cannot spell (`Unprintable`), or the printed module
|
|
32
|
+
* does not rebuild
|
|
33
|
+
*/
|
|
34
|
+
export async function transpile(irPath, options = {}) {
|
|
35
|
+
const name = options.name ?? 'main';
|
|
36
|
+
const importFrom = options.importFrom ?? '@elaraai/east';
|
|
37
|
+
const ir = loadIR(irPath);
|
|
38
|
+
const source = toSource(ir, { name, importFrom });
|
|
39
|
+
if (!options.rebuild)
|
|
40
|
+
return { source };
|
|
41
|
+
return { source, rebuilt: await rebuild(source, name, importFrom) };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Imports a printed module against this CLI's own `@elaraai/east` and
|
|
45
|
+
* returns what its export builds.
|
|
46
|
+
*
|
|
47
|
+
* The module's import line is the printer's own (`from "<importFrom>"`);
|
|
48
|
+
* it is retargeted at the resolved package so the module loads from a
|
|
49
|
+
* temporary directory that has no `node_modules`.
|
|
50
|
+
*/
|
|
51
|
+
async function rebuild(source, name, importFrom) {
|
|
52
|
+
const east = import.meta.resolve('@elaraai/east');
|
|
53
|
+
const retargeted = source.replace(`from ${JSON.stringify(importFrom)};`, `from ${JSON.stringify(east)};`);
|
|
54
|
+
const dir = mkdtempSync(join(tmpdir(), 'east-transpile-'));
|
|
55
|
+
try {
|
|
56
|
+
const path = join(dir, 'module.mjs');
|
|
57
|
+
writeFileSync(path, retargeted, 'utf-8');
|
|
58
|
+
const mod = await import(pathToFileURL(path).href);
|
|
59
|
+
const fn = mod[name];
|
|
60
|
+
if (fn === undefined || typeof fn.toIR !== 'function') {
|
|
61
|
+
throw new Error(`the printed module has no East function export named ${JSON.stringify(name)}`);
|
|
62
|
+
}
|
|
63
|
+
return fn.toIR();
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
rmSync(dir, { recursive: true, force: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Encodes a rebuilt IR for a path: `.beast2` / `.beast` as the IR bundle
|
|
71
|
+
* (source map included), `.json` as the raw IR JSON `east-node run` reads.
|
|
72
|
+
*
|
|
73
|
+
* @param eastIR - The rebuilt IR bundle
|
|
74
|
+
* @param outPath - The path it will be written to; its extension picks the format
|
|
75
|
+
* @returns The encoded bytes
|
|
76
|
+
*/
|
|
77
|
+
export function encodeRebuilt(eastIR, outPath) {
|
|
78
|
+
const ext = extname(outPath).toLowerCase();
|
|
79
|
+
if (ext === '.beast2' || ext === '.beast')
|
|
80
|
+
return encodeEastIR(eastIR);
|
|
81
|
+
if (ext === '.json')
|
|
82
|
+
return encodeJSONFor(IRType)(eastIR.ir);
|
|
83
|
+
throw new Error(`Unsupported rebuild extension "${ext}". Supported extensions: .beast2, .beast, .json`);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Transpiles every IR file in a directory: `<stem>.ts` under `outDir` for
|
|
87
|
+
* each `<stem>.<beast2|beast|east|json>`, and — when `rebuildDir` is given —
|
|
88
|
+
* `<stem>.beast2` there holding the IR each module builds.
|
|
89
|
+
*
|
|
90
|
+
* @param inDir - The directory of IR files (other files are ignored)
|
|
91
|
+
* @param outDir - Where the modules go (created)
|
|
92
|
+
* @param options - Export name, import specifier, and the rebuild directory
|
|
93
|
+
* @returns The stems transpiled, in order
|
|
94
|
+
* @throws On the first file that does not transpile, naming it
|
|
95
|
+
*/
|
|
96
|
+
export async function transpileDir(inDir, outDir, options = {}) {
|
|
97
|
+
const files = readdirSync(inDir).filter(f => IR_EXTENSIONS.has(extname(f).toLowerCase())).sort();
|
|
98
|
+
mkdirSync(outDir, { recursive: true });
|
|
99
|
+
if (options.rebuildDir !== undefined)
|
|
100
|
+
mkdirSync(options.rebuildDir, { recursive: true });
|
|
101
|
+
const stems = [];
|
|
102
|
+
for (const file of files) {
|
|
103
|
+
const stem = basename(file, extname(file));
|
|
104
|
+
let result;
|
|
105
|
+
try {
|
|
106
|
+
result = await transpile(join(inDir, file), { ...options, rebuild: options.rebuildDir !== undefined });
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
throw new Error(`${file}: ${err.message}`);
|
|
110
|
+
}
|
|
111
|
+
writeFileSync(join(outDir, `${stem}.ts`), result.source, 'utf-8');
|
|
112
|
+
if (options.rebuildDir !== undefined) {
|
|
113
|
+
const out = join(options.rebuildDir, `${stem}.beast2`);
|
|
114
|
+
writeFileSync(out, encodeRebuilt(result.rebuilt, out));
|
|
115
|
+
}
|
|
116
|
+
stems.push(stem);
|
|
117
|
+
}
|
|
118
|
+
return stems;
|
|
119
|
+
}
|
|
120
|
+
/** Whether a path is a directory. */
|
|
121
|
+
export function isDirectory(path) {
|
|
122
|
+
try {
|
|
123
|
+
return statSync(path).isDirectory();
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=transpile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.js","sourceRoot":"","sources":["../src/transpile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAoBrC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,UAA4B,EAAE;IAC1E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,eAAe,CAAC;IACzD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I Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Tests for `east-node transpile` (#628): an IR file prints as a TypeScript
|
|
7
|
+
* module that rebuilds the same IR, in file and directory mode, for every
|
|
8
|
+
* IR file format the loader reads.
|
|
9
|
+
*/
|
|
10
|
+
import { describe, it } from 'node:test';
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { East, IntegerType, StringType, ArrayType, IRType, encodeEastIR, encodeJSONFor, decodeEastIR, toSource, isTypeValueEqual, } from '@elaraai/east';
|
|
16
|
+
import { transpile, transpileDir, encodeRebuilt } from './transpile.js';
|
|
17
|
+
const double = East.function([IntegerType], IntegerType, ($, x) => x.multiply(2n));
|
|
18
|
+
const greet = East.function([StringType, ArrayType(IntegerType)], StringType, ($, name, xs) => {
|
|
19
|
+
const total = $.let(0n);
|
|
20
|
+
$.for(xs, ($, x) => { $.assign(total, total.add(x)); });
|
|
21
|
+
return East.str `${name}: ${total}`;
|
|
22
|
+
});
|
|
23
|
+
function scratch() {
|
|
24
|
+
return mkdtempSync(join(tmpdir(), 'enc-transpile-'));
|
|
25
|
+
}
|
|
26
|
+
describe('east-node transpile', () => {
|
|
27
|
+
it('prints a beast2 IR file as a module that rebuilds the same IR', async () => {
|
|
28
|
+
const dir = scratch();
|
|
29
|
+
try {
|
|
30
|
+
const ir = double.toIR();
|
|
31
|
+
const path = join(dir, 'double.beast2');
|
|
32
|
+
writeFileSync(path, encodeEastIR(ir));
|
|
33
|
+
const { source, rebuilt } = await transpile(path, { rebuild: true });
|
|
34
|
+
assert.match(source, /^import \{ East, .* \} from "@elaraai\/east";$/m);
|
|
35
|
+
assert.match(source, /export const main = East\.function\(\[IntegerType\], IntegerType, \(\$, x\) => x\.multiply\(2n\)\);/);
|
|
36
|
+
assert.ok(rebuilt !== undefined);
|
|
37
|
+
// The rebuild is a fixpoint: printing it gives the same module back.
|
|
38
|
+
assert.equal(toSource(rebuilt, {}), toSource(ir, {}));
|
|
39
|
+
assert.ok(isTypeValueEqual(rebuilt.ir.value.type, ir.ir.value.type));
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
rmSync(dir, { recursive: true, force: true });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
it('honours the export name and import specifier, and still rebuilds', async () => {
|
|
46
|
+
const dir = scratch();
|
|
47
|
+
try {
|
|
48
|
+
const path = join(dir, 'greet.json');
|
|
49
|
+
writeFileSync(path, encodeJSONFor(IRType)(greet.toIR().ir));
|
|
50
|
+
const { source, rebuilt } = await transpile(path, { name: 'greet', importFrom: '../east/index.js', rebuild: true });
|
|
51
|
+
assert.match(source, /from "\.\.\/east\/index\.js";/);
|
|
52
|
+
assert.match(source, /export const greet = East\.function\(/);
|
|
53
|
+
assert.match(source, /\$\.for\(xs, \(\$, x, _4, label\) => \{/); // the slot the body did not name stays _N (#639)
|
|
54
|
+
assert.equal(toSource(rebuilt, { name: 'greet' }), toSource(greet, { name: 'greet' }));
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
rmSync(dir, { recursive: true, force: true });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
it('encodes a rebuilt IR by extension', async () => {
|
|
61
|
+
const dir = scratch();
|
|
62
|
+
try {
|
|
63
|
+
const path = join(dir, 'double.beast2');
|
|
64
|
+
writeFileSync(path, encodeEastIR(double.toIR()));
|
|
65
|
+
const { rebuilt } = await transpile(path, { rebuild: true });
|
|
66
|
+
const bundle = decodeEastIR(encodeRebuilt(rebuilt, join(dir, 'out.beast2')));
|
|
67
|
+
assert.equal(bundle.ir.type, 'Function');
|
|
68
|
+
const json = JSON.parse(Buffer.from(encodeRebuilt(rebuilt, join(dir, 'out.json'))).toString('utf-8'));
|
|
69
|
+
assert.equal(json.type, 'Function');
|
|
70
|
+
assert.throws(() => encodeRebuilt(rebuilt, join(dir, 'out.txt')), /Unsupported rebuild extension/);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
rmSync(dir, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
it('transpiles a directory, one module (and one rebuilt IR) per IR file', async () => {
|
|
77
|
+
const dir = scratch();
|
|
78
|
+
try {
|
|
79
|
+
const input = join(dir, 'in');
|
|
80
|
+
const out = join(dir, 'out');
|
|
81
|
+
const rebuilt = join(dir, 'rebuilt');
|
|
82
|
+
const { mkdirSync } = await import('node:fs');
|
|
83
|
+
mkdirSync(input);
|
|
84
|
+
writeFileSync(join(input, 'double.beast2'), encodeEastIR(double.toIR()));
|
|
85
|
+
writeFileSync(join(input, 'greet.json'), encodeJSONFor(IRType)(greet.toIR().ir));
|
|
86
|
+
writeFileSync(join(input, 'notes.txt'), 'not an IR file');
|
|
87
|
+
const stems = await transpileDir(input, out, { rebuildDir: rebuilt });
|
|
88
|
+
assert.deepEqual(stems, ['double', 'greet']);
|
|
89
|
+
assert.deepEqual(readdirSync(out).sort(), ['double.ts', 'greet.ts']);
|
|
90
|
+
assert.deepEqual(readdirSync(rebuilt).sort(), ['double.beast2', 'greet.beast2']);
|
|
91
|
+
assert.match(readFileSync(join(out, 'greet.ts'), 'utf-8'), /export const main = East\.function\(/);
|
|
92
|
+
assert.equal(toSource(decodeEastIR(readFileSync(join(rebuilt, 'greet.beast2'))), {}), toSource(greet, {}));
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
rmSync(dir, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
it('rejects an IR file whose root is not a function', async () => {
|
|
99
|
+
const dir = scratch();
|
|
100
|
+
try {
|
|
101
|
+
const path = join(dir, 'value.json');
|
|
102
|
+
writeFileSync(path, JSON.stringify({ type: 'Value', value: { type: { type: 'Integer', value: null }, loc_id: '0', value: { type: 'Integer', value: '1' } } }));
|
|
103
|
+
await assert.rejects(transpile(path), /must contain a function/);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
rmSync(dir, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=transpile.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.spec.js","sourceRoot":"","sources":["../src/transpile.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACH,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAChD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GACxE,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExE,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACnF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAA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|
|
2
2
|
"name": "@elaraai/east-node-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.69",
|
|
4
4
|
"description": "Command-line interface for running East IR programs with Node.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"east-node": "./bin/east-node.mjs"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"tar-stream": "^3.1.7"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@elaraai/east": "1.0.
|
|
47
|
+
"@elaraai/east": "1.0.69"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^22.18.1",
|