@elaraai/e3 1.0.79 → 1.0.80

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 (99) hide show
  1. package/README.md +11 -2
  2. package/dist/src/browser.d.ts +5 -4
  3. package/dist/src/browser.d.ts.map +1 -1
  4. package/dist/src/browser.js +3 -2
  5. package/dist/src/browser.js.map +1 -1
  6. package/dist/src/dataset-file.d.ts +17 -19
  7. package/dist/src/dataset-file.d.ts.map +1 -1
  8. package/dist/src/dataset-file.js +26 -45
  9. package/dist/src/dataset-file.js.map +1 -1
  10. package/dist/src/export.d.ts +2 -3
  11. package/dist/src/export.d.ts.map +1 -1
  12. package/dist/src/export.js +150 -80
  13. package/dist/src/export.js.map +1 -1
  14. package/dist/src/export.spec.js +177 -57
  15. package/dist/src/export.spec.js.map +1 -1
  16. package/dist/src/function.spec.js +29 -58
  17. package/dist/src/function.spec.js.map +1 -1
  18. package/dist/src/functions-link.spec.js +19 -17
  19. package/dist/src/functions-link.spec.js.map +1 -1
  20. package/dist/src/index.d.ts +56 -8
  21. package/dist/src/index.d.ts.map +1 -1
  22. package/dist/src/index.js +11 -4
  23. package/dist/src/index.js.map +1 -1
  24. package/dist/src/input.d.ts +8 -5
  25. package/dist/src/input.d.ts.map +1 -1
  26. package/dist/src/input.js +8 -5
  27. package/dist/src/input.js.map +1 -1
  28. package/dist/src/migration.d.ts +172 -0
  29. package/dist/src/migration.d.ts.map +1 -0
  30. package/dist/src/migration.js +108 -0
  31. package/dist/src/migration.js.map +1 -0
  32. package/dist/src/migration.spec.d.ts +6 -0
  33. package/dist/src/migration.spec.d.ts.map +1 -0
  34. package/dist/src/migration.spec.js +197 -0
  35. package/dist/src/migration.spec.js.map +1 -0
  36. package/dist/src/mutation-programs.spec.d.ts +6 -0
  37. package/dist/src/mutation-programs.spec.d.ts.map +1 -0
  38. package/dist/src/mutation-programs.spec.js +310 -0
  39. package/dist/src/mutation-programs.spec.js.map +1 -0
  40. package/dist/src/mutation.d.ts +117 -9
  41. package/dist/src/mutation.d.ts.map +1 -1
  42. package/dist/src/mutation.js +104 -46
  43. package/dist/src/mutation.js.map +1 -1
  44. package/dist/src/open-beast-link.spec.js +10 -8
  45. package/dist/src/open-beast-link.spec.js.map +1 -1
  46. package/dist/src/output.d.ts +117 -0
  47. package/dist/src/output.d.ts.map +1 -0
  48. package/dist/src/output.js +119 -0
  49. package/dist/src/output.js.map +1 -0
  50. package/dist/src/package.d.ts +7 -5
  51. package/dist/src/package.d.ts.map +1 -1
  52. package/dist/src/package.js +98 -8
  53. package/dist/src/package.js.map +1 -1
  54. package/dist/src/package.spec.d.ts +6 -0
  55. package/dist/src/package.spec.d.ts.map +1 -0
  56. package/dist/src/package.spec.js +16 -0
  57. package/dist/src/package.spec.js.map +1 -0
  58. package/dist/src/record-guards.d.ts +41 -0
  59. package/dist/src/record-guards.d.ts.map +1 -0
  60. package/dist/src/record-guards.js +44 -0
  61. package/dist/src/record-guards.js.map +1 -0
  62. package/dist/src/record-index.d.ts +129 -0
  63. package/dist/src/record-index.d.ts.map +1 -0
  64. package/dist/src/record-index.js +144 -0
  65. package/dist/src/record-index.js.map +1 -0
  66. package/dist/src/record-index.spec.d.ts +6 -0
  67. package/dist/src/record-index.spec.d.ts.map +1 -0
  68. package/dist/src/record-index.spec.js +160 -0
  69. package/dist/src/record-index.spec.js.map +1 -0
  70. package/dist/src/record-programs.d.ts +128 -0
  71. package/dist/src/record-programs.d.ts.map +1 -0
  72. package/dist/src/record-programs.js +480 -0
  73. package/dist/src/record-programs.js.map +1 -0
  74. package/dist/src/record.d.ts.map +1 -1
  75. package/dist/src/record.js +2 -0
  76. package/dist/src/record.js.map +1 -1
  77. package/dist/src/record.spec.js +71 -13
  78. package/dist/src/record.spec.js.map +1 -1
  79. package/dist/src/runner.d.ts +6 -9
  80. package/dist/src/runner.d.ts.map +1 -1
  81. package/dist/src/runner.js +9 -25
  82. package/dist/src/runner.js.map +1 -1
  83. package/dist/src/runner.spec.js +16 -34
  84. package/dist/src/runner.spec.js.map +1 -1
  85. package/dist/src/sha256.d.ts +4 -3
  86. package/dist/src/sha256.d.ts.map +1 -1
  87. package/dist/src/sha256.js +20 -17
  88. package/dist/src/sha256.js.map +1 -1
  89. package/dist/src/sha256.spec.js +10 -0
  90. package/dist/src/sha256.spec.js.map +1 -1
  91. package/dist/src/task.d.ts +116 -251
  92. package/dist/src/task.d.ts.map +1 -1
  93. package/dist/src/task.js +169 -435
  94. package/dist/src/task.js.map +1 -1
  95. package/dist/src/task.spec.js +174 -489
  96. package/dist/src/task.spec.js.map +1 -1
  97. package/dist/src/types.d.ts +215 -23
  98. package/dist/src/types.d.ts.map +1 -1
  99. package/package.json +4 -4
@@ -2,65 +2,123 @@
2
2
  * Copyright (c) 2025 Elara AI Pty Ltd
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
- import { Expr, AsyncEastIR, walkIR, equalFor, EastTypeType, toEastTypeValue, printType } from '@elaraai/east';
5
+ import { Expr, NullType, PatchType, printType } from '@elaraai/east';
6
+ import { editTypeOf } from '@elaraai/e3-types';
7
+ import { hasKeyedDelta } from './record-programs.js';
8
+ import { checkPure, sameEastType } from './record-guards.js';
6
9
  import { DEFAULT_RUNNER, runnerToVariant } from './runner.js';
7
- // Structural East-type equality, the same primitive the redeploy type-change
8
- // guard uses (e3-core workspaces.ts): compare the encoded EastTypeValues.
9
- const typeValueEqual = equalFor(EastTypeType);
10
- const sameEastType = (a, b) => typeValueEqual(toEastTypeValue(a), toEastTypeValue(b));
11
- export function mutation(name, rec, fn, config) {
12
- if (!name) {
13
- throw new Error('e3.mutation requires a non-empty name');
10
+ /** A mutation's name is an identifier, as a migration's and an index's are: it
11
+ * names the commits the mutation makes, beside e3's own, which begin with `$`,
12
+ * and `e3 mutate` addresses it as `record.mutation`. */
13
+ const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
14
+ /** Refuses a mutation name that is not an identifier. */
15
+ function checkName(surface, name) {
16
+ if (!IDENTIFIER.test(name)) {
17
+ throw new Error(`e3.${surface} requires a name that is an identifier, got '${name}' — it names the record's ` +
18
+ `commits beside e3's own, which begin with '$', and \`e3 mutate\` addresses it as record.mutation.`);
14
19
  }
20
+ }
21
+ /** The shared guards: a synchronous, platform-free body whose leading
22
+ * parameter is the record's state. Returns the body's signature. */
23
+ function checkBody(surface, name, rec, fn) {
24
+ checkName(surface, name);
25
+ checkPure(`e3.${surface} '${name}' body`, fn, {
26
+ async: 'an async body implies platform IO, which the compare-and-swap retry loop cannot safely re-run against fresher state.',
27
+ platform: 'the compare-and-swap retry loop re-runs the mutation, so a platform call makes the committed record non-deterministic across retries.',
28
+ });
29
+ const signature = Expr.type(fn);
30
+ if (signature.inputs.length < 1 || !sameEastType(rec.type, signature.inputs[0])) {
31
+ const got = signature.inputs.length ? printType(signature.inputs[0]) : 'no parameters';
32
+ throw new Error(`e3.${surface} '${name}' body's first parameter must be the record's ` +
33
+ `state type ${printType(rec.type)}, but got ${got}.`);
34
+ }
35
+ return signature;
36
+ }
37
+ /** Refuses a form whose delta cannot be addressed by key. An Array record's
38
+ * patch is positional and a scalar's is a whole replace, so neither can be
39
+ * applied segment by segment — and both are exactly what the `reduce` form
40
+ * already handles by writing the state whole. */
41
+ function checkKeyed(surface, name, rec) {
42
+ if (!hasKeyedDelta(rec.type)) {
43
+ throw new Error(`e3.${surface} '${name}' writes a delta addressed by key, so it needs a ` +
44
+ `Dict or Set record — '${rec.name}' holds ${printType(rec.type)}. Use ` +
45
+ `e3.mutation.reduce, whose reducer returns the whole state.`);
46
+ }
47
+ }
48
+ function reduce(name, rec, fn, config) {
15
49
  const runner = config?.runner ?? DEFAULT_RUNNER;
16
50
  // Validate eagerly so a bad runner fails at definition time, not export time.
17
51
  runnerToVariant(runner);
18
- // Keep the full EastIR bundle (IR + source map) so export.ts can encode
19
- // with encodeEastIR and preserve source locations.
20
- const eastIR = fn.toIR();
21
- if (eastIR instanceof AsyncEastIR) {
22
- throw new Error(`e3.mutation '${name}' reducer must be a synchronous East function — ` +
23
- `an async reducer implies platform IO, which the compare-and-swap retry ` +
24
- `loop cannot safely re-run against fresher state.`);
52
+ const signature = checkBody('mutation.reduce', name, rec, fn);
53
+ // The reducer is (state, ...args) => state: the return must be the record's
54
+ // state type too. The typed overload enforces this at compile time, but a
55
+ // dynamic / cast caller could pass a mismatched function — and because
56
+ // MutationObject omits the output type (it IS the record type), a mismatch
57
+ // would be silently undetectable downstream.
58
+ if (!sameEastType(rec.type, signature.output)) {
59
+ throw new Error(`e3.mutation.reduce '${name}' reducer must return the record's state type ` +
60
+ `${printType(rec.type)}, but returns ${printType(signature.output)}.`);
25
61
  }
26
- // The reducer must be pure: the compare-and-swap loop re-runs it against
27
- // fresher state, so any platform call (Random, Time, IO, …) makes the
28
- // committed record non-deterministic. A *sync* platform call is an ordinary
29
- // FunctionIR, so the async check above doesn't catch it — walk the whole body
30
- // (walkIR descends into nested closures, loop bodies and collection-op lambdas).
31
- walkIR(eastIR.ir, (node) => {
32
- if (node.type === 'Platform') {
33
- throw new Error(`e3.mutation '${name}' reducer must not call platform functions ` +
34
- `(found '${node.value.name}') — the compare-and-swap retry loop re-runs ` +
35
- `the reducer, so a platform call makes the committed record ` +
36
- `non-deterministic across retries.`);
37
- }
38
- });
39
- const fnType = Expr.type(fn);
40
- // The reducer is (state, ...args) => state: both the leading parameter and
41
- // the return must be the record's state type. The typed overload enforces
42
- // this at compile time, but a dynamic / cast caller could pass a mismatched
43
- // function — and because MutationObject omits the output type (it IS the
44
- // record type), a mismatch would be silently undetectable downstream. Guard
45
- // it at definition time.
46
- if (fnType.inputs.length < 1 || !sameEastType(rec.type, fnType.inputs[0])) {
47
- const got = fnType.inputs.length ? printType(fnType.inputs[0]) : 'no parameters';
48
- throw new Error(`e3.mutation '${name}' reducer's first parameter must be the record's ` +
49
- `state type ${printType(rec.type)}, but got ${got}.`);
62
+ return {
63
+ kind: 'mutation',
64
+ name,
65
+ record: rec,
66
+ form: 'reduce',
67
+ // Keep the full EastIR bundle (IR + source map) so export.ts can encode
68
+ // with encodeEastIR and preserve source locations.
69
+ body: fn.toIR(),
70
+ fn,
71
+ // The extra parameter types are everything after the leading state parameter.
72
+ argTypes: signature.inputs.slice(1),
73
+ runner,
74
+ };
75
+ }
76
+ function edit(name, rec, fn, config) {
77
+ const runner = config?.runner ?? DEFAULT_RUNNER;
78
+ runnerToVariant(runner);
79
+ checkKeyed('mutation.edit', name, rec);
80
+ const signature = checkBody('mutation.edit', name, rec, fn);
81
+ const editType = editTypeOf(rec.type);
82
+ const last = signature.inputs[signature.inputs.length - 1];
83
+ if (signature.inputs.length < 2 || last === undefined || !sameEastType(editType, last)) {
84
+ throw new Error(`e3.mutation.edit '${name}' body's LAST parameter must be the edit ` +
85
+ `capability ${printType(editType)} — e3.mutation.editType(record.type) — but got ` +
86
+ `${last === undefined ? 'no parameters' : printType(last)}.`);
50
87
  }
51
- if (!sameEastType(rec.type, fnType.output)) {
52
- throw new Error(`e3.mutation '${name}' reducer must return the record's state type ` +
53
- `${printType(rec.type)}, but returns ${printType(fnType.output)}.`);
88
+ if (!sameEastType(NullType, signature.output)) {
89
+ throw new Error(`e3.mutation.edit '${name}' body writes through 'edit' and returns Null, ` +
90
+ `but returns ${printType(signature.output)}. Use e3.mutation.reduce for a reducer ` +
91
+ `that returns the whole state.`);
54
92
  }
55
- // The extra parameter types are everything after the leading state parameter.
56
- const argTypes = fnType.inputs.slice(1);
57
93
  return {
58
94
  kind: 'mutation',
59
95
  name,
60
96
  record: rec,
61
- body: eastIR,
62
- argTypes,
97
+ form: 'edit',
98
+ body: fn.toIR(),
99
+ fn,
100
+ // The extra parameters sit between the leading state and the trailing edit.
101
+ argTypes: signature.inputs.slice(1, -1),
102
+ runner,
103
+ };
104
+ }
105
+ function patch(rec, name = 'patch', config) {
106
+ checkName('mutation.patch', name);
107
+ const runner = config?.runner ?? DEFAULT_RUNNER;
108
+ runnerToVariant(runner);
109
+ checkKeyed('mutation.patch', name, rec);
110
+ return {
111
+ kind: 'mutation',
112
+ name,
113
+ record: rec,
114
+ form: 'patch',
115
+ argTypes: [PatchType(rec.type)],
63
116
  runner,
64
117
  };
65
118
  }
119
+ /**
120
+ * The write forms of a record: {@link reduce}, {@link edit} and {@link patch},
121
+ * and `editType`, the type of the capability an `edit` body writes through.
122
+ */
123
+ export const mutation = { reduce, edit, patch, editType: editTypeOf };
66
124
  //# sourceMappingURL=mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutation.js","sourceRoot":"","sources":["../../src/mutation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE9G,OAAO,EAAE,cAAc,EAAE,eAAe,EAAuB,MAAM,aAAa,CAAC;AAEnF,6EAA6E;AAC7E,0EAA0E;AAC1E,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC9C,MAAM,YAAY,GAAG,CAAC,CAAW,EAAE,CAAW,EAAW,EAAE,CACzD,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AA+CzD,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,GAAc,EACd,EAAwD,EACxD,MAAoC;IAEpC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,cAAc,CAAC;IAChD,8EAA8E;IAC9E,eAAe,CAAC,MAAM,CAAC,CAAC;IAExB,wEAAwE;IACxE,mDAAmD;IACnD,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACzB,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;QAClC,MAAM,IA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,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
@@ -19,7 +19,7 @@ import * as os from 'node:os';
19
19
  import * as path from 'node:path';
20
20
  import yauzl from 'yauzl';
21
21
  import { East, DictType, FunctionType, IntegerType, StringType, StructType, decodeBeast2For, decodeEastIR, walkIR, IMPORT_PLATFORM, variant } from '@elaraai/east';
22
- import { DatasetRefType } from '@elaraai/e3-types';
22
+ import { decodePackageObject, decodeTaskObject } from '@elaraai/e3-types';
23
23
  import { export_ } from './export.js';
24
24
  import { package_ } from './package.js';
25
25
  import { task } from './task.js';
@@ -88,12 +88,14 @@ async function readZip(zipPath) {
88
88
  });
89
89
  });
90
90
  }
91
- /** The IR object a bundle holds for `data/<refPath>.ref`. */
92
- function irAt(entries, refPath) {
93
- const ref = decodeBeast2For(DatasetRefType)(new Uint8Array(entries.get(`data/${refPath}.ref`)));
94
- assert.strictEqual(ref.type, 'value');
95
- const hash = ref.value.hash;
96
- return decodeEastIR(new Uint8Array(entries.get(`objects/${hash.slice(0, 2)}/${hash.slice(2)}.beast2`)));
91
+ /** The program the task object of a bundle's task `name` names. */
92
+ function programOf(entries, name) {
93
+ const object = (hash) => new Uint8Array(entries.get(`objects/${hash.slice(0, 2)}/${hash.slice(2)}.beast2`));
94
+ const pkgRef = [...entries.keys()].find((key) => key.startsWith('packages/'));
95
+ const pkg = decodePackageObject(object(decodeBeast2For(StringType)(entries.get(pkgRef))));
96
+ const task = decodeTaskObject(object(pkg.tasks.get(name)));
97
+ assert.strictEqual(task.body.type, 'east');
98
+ return decodeEastIR(object(task.body.value.program));
97
99
  }
98
100
  const STOCK_RUNNERS = [
99
101
  { runtime: 'east-node', platforms: ['@elaraai/east-node-std'] },
@@ -117,7 +119,7 @@ describe('FileSystem.openBeast links on every stock runner (#660)', () => {
117
119
  const pkg = package_('importer', '1.0.0', use);
118
120
  const zipPath = path.join(tempDir, `importer-${runner.runtime}.zip`);
119
121
  await export_(pkg, zipPath, { functions: [manifest] });
120
- const bundle = irAt(await readZip(zipPath), 'tasks/sum_rows/function_ir');
122
+ const bundle = programOf(await readZip(zipPath), 'sum_rows');
121
123
  assert.strictEqual(countImports(bundle.ir), 0, 'the import resolved to embedded IR');
122
124
  assert.deepStrictEqual(genericPlatformCalls(bundle.ir), [{ name: 'fs_open_beast', typeParameters: 1 }]);
123
125
  });
@@ -1 +1 @@
1
- {"version":3,"file":"open-beast-link.spec.js","sourceRoot":"","sources":["../../src/open-beast-link.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EACjE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AAE1D,+DAA+D;AAC/D,+C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AG,CAAC,CAAC,CAAC,CAAC,EAAE;YAC/F,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,uBAAuB,CAAC,EAAE;SACvE,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,OAAO,CAClB,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAC7E,qKAAqK,CACtK,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,117 @@
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
+ * Output kinds for `e3.streamTask` — `e3.output.*`.
7
+ *
8
+ * A stream task's body emits its output instead of returning it, and the
9
+ * output kind says what `emit` takes and how the parts of the output combine,
10
+ * whichever unit emitted them. Emission order is free: the platform sorts sets
11
+ * and dicts.
12
+ */
13
+ import type { BlockBuilder, EastType, ExprType, SubtypeExprOrValue, ValueTypeOf } from '@elaraai/east';
14
+ import type { ArrayOutputDef, DictOutputDef, FoldOutputDef, SetOutputDef } from './types.js';
15
+ /**
16
+ * An Array output: `emit(t)` appends an element. Parts concatenate: in
17
+ * emission order within a unit, and units in input order.
18
+ *
19
+ * @typeParam T - The element type
20
+ * @param type - The element type
21
+ * @returns The output kind
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const balances = e3.streamTask('balances', {
26
+ * inputs: [events],
27
+ * output: e3.output.array(FloatType),
28
+ * }, ($, events, emit) => {
29
+ * const balance = $.let(0.0);
30
+ * $.for(events, ($, event) => {
31
+ * $.assign(balance, balance.add(event.amount));
32
+ * $(emit(balance));
33
+ * });
34
+ * });
35
+ * ```
36
+ */
37
+ declare function array<T extends EastType>(type: T): ArrayOutputDef<T>;
38
+ /**
39
+ * A Set output: `emit(t)` adds an element, and an element emitted twice is
40
+ * held once. Parts combine by union.
41
+ *
42
+ * @typeParam T - The element type
43
+ * @param type - The element type
44
+ * @returns The output kind
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const accounts = e3.streamTask('accounts', {
49
+ * inputs: [e3.partition(events)],
50
+ * output: e3.output.set(StringType),
51
+ * }, ($, events, emit) => {
52
+ * $.for(events, ($, event) => { $(emit(event.account)); });
53
+ * });
54
+ * ```
55
+ */
56
+ declare function set<T extends EastType>(type: T): SetOutputDef<T>;
57
+ /**
58
+ * A Dict output: `emit(k, v)` adds an entry. Parts combine by key; the values
59
+ * of a key emitted more than once fold with `merge`, in input order, and
60
+ * without `merge` a repeated key fails the task, naming it.
61
+ *
62
+ * @typeParam K - The key type
63
+ * @typeParam V - The value type
64
+ * @param key - The key type
65
+ * @param value - The value type
66
+ * @param config - `merge`, an associative function of the key and two values
67
+ * @returns The output kind
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const totals = e3.streamTask('totals', {
72
+ * inputs: [e3.partition(sales)],
73
+ * output: e3.output.dict(StringType, FloatType, { merge: ($, account, a, b) => a.add(b) }),
74
+ * }, ($, sales, emit) => {
75
+ * $.for(sales, ($, sale) => { $(emit(sale.account, sale.amount)); });
76
+ * });
77
+ * ```
78
+ */
79
+ declare function dict<K extends EastType, V extends EastType>(key: K, value: V, config?: {
80
+ merge?: ($: BlockBuilder<V>, key: ExprType<K>, a: ExprType<V>, b: ExprType<V>) => SubtypeExprOrValue<V> | void;
81
+ }): DictOutputDef<K, V>;
82
+ /**
83
+ * A fold output: every value `emit(t)` is given is folded with `combine`,
84
+ * starting from `zero`, in input order, and the output is the result.
85
+ *
86
+ * @typeParam T - The folded value's type
87
+ * @param type - The folded value's type
88
+ * @param config - `zero`, an identity of `combine`; `combine`, associative
89
+ * @returns The output kind
90
+ * @throws {Error} When `zero` is not a value of `type`
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const revenue = e3.streamTask('revenue', {
95
+ * inputs: [e3.partition(sales)],
96
+ * output: e3.output.fold(FloatType, { zero: 0.0, combine: ($, a, b) => a.add(b) }),
97
+ * }, ($, sales, emit) => {
98
+ * $.for(sales, ($, sale) => { $(emit(sale.amount)); });
99
+ * });
100
+ * ```
101
+ */
102
+ declare function fold<T extends EastType>(type: T, config: {
103
+ zero: ValueTypeOf<T>;
104
+ combine: ($: BlockBuilder<T>, a: ExprType<T>, b: ExprType<T>) => SubtypeExprOrValue<T> | void;
105
+ }): FoldOutputDef<T>;
106
+ /**
107
+ * The output kinds a stream task emits into: `array`, `set`, `dict` and
108
+ * `fold`.
109
+ */
110
+ export declare const output: {
111
+ array: typeof array;
112
+ set: typeof set;
113
+ dict: typeof dict;
114
+ fold: typeof fold;
115
+ };
116
+ export {};
117
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvG,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,KAAK,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAE7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,GAAG,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEzD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAClD,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;CAAE,GAC1H,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAOrB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,IAAI,CAAC,CAAC,SAAS,QAAQ,EAC9B,IAAI,EAAE,CAAC,EACP,MAAM,EAAE;IACN,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/F,GACA,aAAa,CAAC,CAAC,CAAC,CAWlB;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;CAA6B,CAAC"}
@@ -0,0 +1,119 @@
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 { ArrayType, DictType, East, FunctionType, NullType, SetType, isValueOf, printType } from '@elaraai/east';
6
+ /**
7
+ * An Array output: `emit(t)` appends an element. Parts concatenate: in
8
+ * emission order within a unit, and units in input order.
9
+ *
10
+ * @typeParam T - The element type
11
+ * @param type - The element type
12
+ * @returns The output kind
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const balances = e3.streamTask('balances', {
17
+ * inputs: [events],
18
+ * output: e3.output.array(FloatType),
19
+ * }, ($, events, emit) => {
20
+ * const balance = $.let(0.0);
21
+ * $.for(events, ($, event) => {
22
+ * $.assign(balance, balance.add(event.amount));
23
+ * $(emit(balance));
24
+ * });
25
+ * });
26
+ * ```
27
+ */
28
+ function array(type) {
29
+ return { kind: 'array', type: ArrayType(type), emit: FunctionType([type], NullType) };
30
+ }
31
+ /**
32
+ * A Set output: `emit(t)` adds an element, and an element emitted twice is
33
+ * held once. Parts combine by union.
34
+ *
35
+ * @typeParam T - The element type
36
+ * @param type - The element type
37
+ * @returns The output kind
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const accounts = e3.streamTask('accounts', {
42
+ * inputs: [e3.partition(events)],
43
+ * output: e3.output.set(StringType),
44
+ * }, ($, events, emit) => {
45
+ * $.for(events, ($, event) => { $(emit(event.account)); });
46
+ * });
47
+ * ```
48
+ */
49
+ function set(type) {
50
+ return { kind: 'set', type: SetType(type), emit: FunctionType([type], NullType) };
51
+ }
52
+ /**
53
+ * A Dict output: `emit(k, v)` adds an entry. Parts combine by key; the values
54
+ * of a key emitted more than once fold with `merge`, in input order, and
55
+ * without `merge` a repeated key fails the task, naming it.
56
+ *
57
+ * @typeParam K - The key type
58
+ * @typeParam V - The value type
59
+ * @param key - The key type
60
+ * @param value - The value type
61
+ * @param config - `merge`, an associative function of the key and two values
62
+ * @returns The output kind
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const totals = e3.streamTask('totals', {
67
+ * inputs: [e3.partition(sales)],
68
+ * output: e3.output.dict(StringType, FloatType, { merge: ($, account, a, b) => a.add(b) }),
69
+ * }, ($, sales, emit) => {
70
+ * $.for(sales, ($, sale) => { $(emit(sale.account, sale.amount)); });
71
+ * });
72
+ * ```
73
+ */
74
+ function dict(key, value, config) {
75
+ return {
76
+ kind: 'dict',
77
+ type: DictType(key, value),
78
+ emit: FunctionType([key, value], NullType),
79
+ ...(config?.merge !== undefined && { merge: East.function([key, value, value], value, config.merge).toIR() }),
80
+ };
81
+ }
82
+ /**
83
+ * A fold output: every value `emit(t)` is given is folded with `combine`,
84
+ * starting from `zero`, in input order, and the output is the result.
85
+ *
86
+ * @typeParam T - The folded value's type
87
+ * @param type - The folded value's type
88
+ * @param config - `zero`, an identity of `combine`; `combine`, associative
89
+ * @returns The output kind
90
+ * @throws {Error} When `zero` is not a value of `type`
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const revenue = e3.streamTask('revenue', {
95
+ * inputs: [e3.partition(sales)],
96
+ * output: e3.output.fold(FloatType, { zero: 0.0, combine: ($, a, b) => a.add(b) }),
97
+ * }, ($, sales, emit) => {
98
+ * $.for(sales, ($, sale) => { $(emit(sale.amount)); });
99
+ * });
100
+ * ```
101
+ */
102
+ function fold(type, config) {
103
+ if (!isValueOf(config.zero, type)) {
104
+ throw new Error(`e3.output.fold: zero is not a value of ${printType(type)}`);
105
+ }
106
+ return {
107
+ kind: 'fold',
108
+ type,
109
+ emit: FunctionType([type], NullType),
110
+ zero: config.zero,
111
+ combine: East.function([type, type], type, config.combine).toIR(),
112
+ };
113
+ }
114
+ /**
115
+ * The output kinds a stream task emits into: `array`, `set`, `dict` and
116
+ * `fold`.
117
+ */
118
+ export const output = { array, set, dict, fold };
119
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGjH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAS,KAAK,CAAqB,IAAO;IACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAA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,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAc,CAAC,CAAC,IAAI,EAAE;KACzE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC"}
@@ -2,10 +2,7 @@
2
2
  * Copyright (c) 2025 Elara AI Pty Ltd
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
- /**
6
- * Package definitions for e3.
7
- */
8
- import type { FunctionDef, MutationDef, PackageDef, PackageItem } from './types.js';
5
+ import type { FunctionDef, MigrationDef, MutationDef, RecordIndexDef, PackageDef, PackageItem } from './types.js';
9
6
  /**
10
7
  * Creates a package definition from items.
11
8
  *
@@ -22,6 +19,11 @@ import type { FunctionDef, MutationDef, PackageDef, PackageItem } from './types.
22
19
  * @param version - Package version
23
20
  * @param items - Items to include (datasets, tasks)
24
21
  * @returns A PackageDef with typed access to contents
22
+ * @throws {Error} When the name or the version cannot be a file name — a
23
+ * repository keeps the package at `packages/<name>/<version>` — when a
24
+ * record is given two different mutations, indexes or migrations of one
25
+ * name, or when a record's migrations are not one chain that leaves it as
26
+ * its declared type
25
27
  *
26
28
  * @example
27
29
  * ```ts
@@ -37,5 +39,5 @@ import type { FunctionDef, MutationDef, PackageDef, PackageItem } from './types.
37
39
  * const helloTask = pkg.tasks.say_hello;
38
40
  * ```
39
41
  */
40
- export declare function package_(name: string, version: string, ...items: (PackageItem | FunctionDef | MutationDef | PackageDef<any>)[]): PackageDef<Record<string, unknown>>;
42
+ export declare function package_(name: string, version: string, ...items: (PackageItem | FunctionDef | MutationDef | RecordIndexDef | MigrationDef | PackageDef<any>)[]): PackageDef<Record<string, unknown>>;
41
43
  //# sourceMappingURL=package.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EAGZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,KAAK,EAAE,CAAC,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,GACtE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2HrC"}
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,cAAc,EACd,UAAU,EACV,WAAW,EAGZ,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,KAAK,EAAE,CAAC,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,cAAc,GAAG,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,GACtG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4MrC"}