@elaraai/e3-types 1.0.5 → 1.0.6
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/dist/src/api.d.ts +272 -0
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +97 -0
- package/dist/src/api.js.map +1 -1
- package/dist/src/function.d.ts +129 -0
- package/dist/src/function.d.ts.map +1 -0
- package/dist/src/function.js +36 -0
- package/dist/src/function.js.map +1 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/package.d.ts +14 -0
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js +39 -1
- package/dist/src/package.js.map +1 -1
- package/dist/src/runner.d.ts +48 -0
- package/dist/src/runner.d.ts.map +1 -0
- package/dist/src/runner.js +49 -0
- package/dist/src/runner.js.map +1 -0
- package/package.json +2 -2
- package/src/api.ts +116 -0
- package/src/function.ts +41 -0
- package/src/index.ts +33 -0
- package/src/package.ts +40 -1
- package/src/runner.ts +56 -0
package/src/runner.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Runner wire types for e3 functions.
|
|
8
|
+
*
|
|
9
|
+
* `RunnerType` is the wire image of the SDK's `Runner` union (minus its
|
|
10
|
+
* `custom` raw-argv runtime — see the security note below). It pins the
|
|
11
|
+
* executable to a known runtime for every tag, so a function call can never
|
|
12
|
+
* name its own executable; only platform flags vary.
|
|
13
|
+
*
|
|
14
|
+
* A `platforms` entry is just a `-p <name>` flag on the wire; the SDK's
|
|
15
|
+
* `Platform<Known> | { custom }` distinction is authoring sugar that
|
|
16
|
+
* collapses to a string.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { VariantType, StructType, ArrayType, StringType, ValueTypeOf } from '@elaraai/east';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Wire representation of a function's runner.
|
|
23
|
+
*
|
|
24
|
+
* Each tag names a known runtime binary; `platforms` are passed as `-p`
|
|
25
|
+
* flags. There is deliberately no raw-argv case: a resolved-argv field would
|
|
26
|
+
* let any caller choose the executable and every flag — arbitrary command
|
|
27
|
+
* execution by construction.
|
|
28
|
+
*/
|
|
29
|
+
export const RunnerType = VariantType({
|
|
30
|
+
east_node: StructType({ platforms: ArrayType(StringType) }),
|
|
31
|
+
east_py: StructType({ platforms: ArrayType(StringType) }),
|
|
32
|
+
east_c: StructType({ platforms: ArrayType(StringType) }),
|
|
33
|
+
});
|
|
34
|
+
export type RunnerType = typeof RunnerType;
|
|
35
|
+
|
|
36
|
+
export type RunnerValue = ValueTypeOf<typeof RunnerType>;
|
|
37
|
+
|
|
38
|
+
function flags(platforms: string[]): string[] {
|
|
39
|
+
return platforms.flatMap((p) => ['-p', p]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a {@link RunnerType} value to the argv prefix (the wire-value
|
|
44
|
+
* analogue of the SDK's `runnerToCommand`). Lives in e3-types so both
|
|
45
|
+
* e3-core (local) and the cloud execution kernel import the one resolver.
|
|
46
|
+
*
|
|
47
|
+
* Variant tags use underscores (`east_node`) mapped to the binary name
|
|
48
|
+
* (`east-node`) here.
|
|
49
|
+
*/
|
|
50
|
+
export function runnerToArgv(r: RunnerValue): string[] {
|
|
51
|
+
switch (r.type) {
|
|
52
|
+
case 'east_node': return ['east-node', 'run', ...flags(r.value.platforms)];
|
|
53
|
+
case 'east_py': return ['east-py', 'run', ...flags(r.value.platforms)];
|
|
54
|
+
case 'east_c': return ['east-c', 'run', ...flags(r.value.platforms)];
|
|
55
|
+
}
|
|
56
|
+
}
|