@elaraai/e3 1.0.98 → 1.0.100
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 +4 -5
- package/dist/src/browser.d.ts +2 -0
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +6 -0
- package/dist/src/browser.js.map +1 -1
- package/dist/src/environment-capture.d.ts +21 -0
- package/dist/src/environment-capture.d.ts.map +1 -1
- package/dist/src/environment-capture.js +48 -0
- package/dist/src/environment-capture.js.map +1 -1
- package/dist/src/export.d.ts +10 -5
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/export.js +31 -47
- package/dist/src/export.js.map +1 -1
- package/dist/src/export.spec.js +27 -16
- package/dist/src/export.spec.js.map +1 -1
- package/dist/src/function.d.ts.map +1 -1
- package/dist/src/function.js.map +1 -1
- package/dist/src/functions-cache.d.ts +60 -0
- package/dist/src/functions-cache.d.ts.map +1 -0
- package/dist/src/functions-cache.js +165 -0
- package/dist/src/functions-cache.js.map +1 -0
- package/dist/src/functions-link.spec.js +191 -12
- package/dist/src/functions-link.spec.js.map +1 -1
- package/dist/src/functions-resolve.d.ts +52 -23
- package/dist/src/functions-resolve.d.ts.map +1 -1
- package/dist/src/functions-resolve.js +244 -96
- package/dist/src/functions-resolve.js.map +1 -1
- package/dist/src/index.d.ts +8 -61
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +53 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +29 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/lazy-build.d.ts +25 -0
- package/dist/src/lazy-build.d.ts.map +1 -0
- package/dist/src/lazy-build.js +56 -0
- package/dist/src/lazy-build.js.map +1 -0
- package/dist/src/lazy-build.spec.d.ts +6 -0
- package/dist/src/lazy-build.spec.d.ts.map +1 -0
- package/dist/src/lazy-build.spec.js +153 -0
- package/dist/src/lazy-build.spec.js.map +1 -0
- package/dist/src/migration.d.ts +20 -163
- package/dist/src/migration.d.ts.map +1 -1
- package/dist/src/migration.js +37 -34
- package/dist/src/migration.js.map +1 -1
- package/dist/src/migration.spec.js +83 -78
- package/dist/src/migration.spec.js.map +1 -1
- package/dist/src/mutation-programs.spec.js +211 -118
- package/dist/src/mutation-programs.spec.js.map +1 -1
- package/dist/src/mutation.d.ts +37 -141
- package/dist/src/mutation.d.ts.map +1 -1
- package/dist/src/mutation.js +66 -28
- package/dist/src/mutation.js.map +1 -1
- package/dist/src/open-beast-link.spec.js +1 -1
- package/dist/src/open-beast-link.spec.js.map +1 -1
- package/dist/src/output.js.map +1 -1
- package/dist/src/package.d.ts +2 -38
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js +42 -175
- package/dist/src/package.js.map +1 -1
- package/dist/src/record-area.d.ts +49 -37
- package/dist/src/record-area.d.ts.map +1 -1
- package/dist/src/record-area.js +211 -131
- package/dist/src/record-area.js.map +1 -1
- package/dist/src/record-area.spec.js +79 -62
- package/dist/src/record-area.spec.js.map +1 -1
- package/dist/src/record-arguments.d.ts +55 -0
- package/dist/src/record-arguments.d.ts.map +1 -0
- package/dist/src/record-arguments.js +72 -0
- package/dist/src/record-arguments.js.map +1 -0
- package/dist/src/record-builders.d.ts +547 -0
- package/dist/src/record-builders.d.ts.map +1 -0
- package/dist/src/record-builders.js +112 -0
- package/dist/src/record-builders.js.map +1 -0
- package/dist/src/record-declared.spec.d.ts +6 -0
- package/dist/src/record-declared.spec.d.ts.map +1 -0
- package/dist/src/record-declared.spec.js +251 -0
- package/dist/src/record-declared.spec.js.map +1 -0
- package/dist/src/record-guards.d.ts +114 -1
- package/dist/src/record-guards.d.ts.map +1 -1
- package/dist/src/record-guards.js +153 -2
- package/dist/src/record-guards.js.map +1 -1
- package/dist/src/record-index.d.ts +128 -350
- package/dist/src/record-index.d.ts.map +1 -1
- package/dist/src/record-index.js +44 -481
- package/dist/src/record-index.js.map +1 -1
- package/dist/src/record-index.spec.js +124 -90
- package/dist/src/record-index.spec.js.map +1 -1
- package/dist/src/record-interval.d.ts +57 -36
- package/dist/src/record-interval.d.ts.map +1 -1
- package/dist/src/record-interval.js +136 -94
- package/dist/src/record-interval.js.map +1 -1
- package/dist/src/record-interval.spec.js +48 -27
- package/dist/src/record-interval.spec.js.map +1 -1
- package/dist/src/record-keys.d.ts +146 -0
- package/dist/src/record-keys.d.ts.map +1 -0
- package/dist/src/record-keys.js +178 -0
- package/dist/src/record-keys.js.map +1 -0
- package/dist/src/record-nested-programs.d.ts +1457 -0
- package/dist/src/record-nested-programs.d.ts.map +1 -0
- package/dist/src/record-nested-programs.js +1974 -0
- package/dist/src/record-nested-programs.js.map +1 -0
- package/dist/src/record-nested.d.ts +284 -0
- package/dist/src/record-nested.d.ts.map +1 -0
- package/dist/src/record-nested.js +304 -0
- package/dist/src/record-nested.js.map +1 -0
- package/dist/src/record-nested.spec.d.ts +6 -0
- package/dist/src/record-nested.spec.d.ts.map +1 -0
- package/dist/src/record-nested.spec.js +1032 -0
- package/dist/src/record-nested.spec.js.map +1 -0
- package/dist/src/record-patches.d.ts +25 -0
- package/dist/src/record-patches.d.ts.map +1 -0
- package/dist/src/record-patches.js +27 -0
- package/dist/src/record-patches.js.map +1 -0
- package/dist/src/record-programs.d.ts +192 -26
- package/dist/src/record-programs.d.ts.map +1 -1
- package/dist/src/record-programs.js +858 -350
- package/dist/src/record-programs.js.map +1 -1
- package/dist/src/record-programs.spec.d.ts +6 -0
- package/dist/src/record-programs.spec.d.ts.map +1 -0
- package/dist/src/record-programs.spec.js +242 -0
- package/dist/src/record-programs.spec.js.map +1 -0
- package/dist/src/record-series.d.ts +101 -97
- package/dist/src/record-series.d.ts.map +1 -1
- package/dist/src/record-series.js +198 -149
- package/dist/src/record-series.js.map +1 -1
- package/dist/src/record-series.spec.js +241 -120
- package/dist/src/record-series.spec.js.map +1 -1
- package/dist/src/record-tiles.d.ts +328 -37
- package/dist/src/record-tiles.d.ts.map +1 -1
- package/dist/src/record-tiles.js +289 -100
- package/dist/src/record-tiles.js.map +1 -1
- package/dist/src/record.d.ts +66 -12
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +103 -34
- package/dist/src/record.js.map +1 -1
- package/dist/src/record.spec.js +48 -63
- package/dist/src/record.spec.js.map +1 -1
- package/dist/src/task.d.ts.map +1 -1
- package/dist/src/task.js +4 -1
- package/dist/src/task.js.map +1 -1
- package/dist/src/types.d.ts +103 -37
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +7 -3
package/dist/src/mutation.d.ts
CHANGED
|
@@ -2,166 +2,62 @@
|
|
|
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
|
-
* Mutation definitions for e3 packages — the write half of the record
|
|
7
|
-
* machinery (CQRS; `e3.function` is the read half).
|
|
8
|
-
*
|
|
9
|
-
* There are three write forms and they all commit the same thing: a mutation
|
|
10
|
-
* delta, the primary's and every index's changes addressed by key, which the
|
|
11
|
-
* engine applies segment by segment. They differ in how the author says what
|
|
12
|
-
* changed — a reducer over the whole state, a body writing through an `edit`
|
|
13
|
-
* capability, or a patch sent by whoever made the edit — and so in what a
|
|
14
|
-
* write costs.
|
|
15
|
-
*
|
|
16
|
-
* All three are pure East: purity is what makes retry-on-conflict safe, since
|
|
17
|
-
* the compare-and-swap loop can re-run against fresher state with no
|
|
18
|
-
* observable side effects. They are `e3.mutation.reduce`, `e3.mutation.edit`
|
|
19
|
-
* and `e3.mutation.patch`, beside `e3.mutation.editType`, the type of the
|
|
20
|
-
* `edit` capability.
|
|
21
|
-
*/
|
|
22
|
-
import type { CallableFunctionExpr, EastType, FunctionExpr, PatchTypeOf } from '@elaraai/east';
|
|
23
|
-
import { NullType } from '@elaraai/east';
|
|
24
5
|
import { editTypeOf } from '@elaraai/e3-types';
|
|
25
6
|
import type { MutationDef, RecordDef } from './types.js';
|
|
7
|
+
import { type IndexFunction } from './record-guards.js';
|
|
26
8
|
import { type FunctionRunner } from './runner.js';
|
|
27
9
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* The reducer is an ordinary East function whose first parameter is the
|
|
31
|
-
* current state and whose return is the new state — both the record's type,
|
|
32
|
-
* enforced at compile time by the shared `T`. The extra parameter types are
|
|
33
|
-
* read off the function's signature, so there is nothing to keep in sync.
|
|
10
|
+
* Builds a reducer's definition, `(state, ...args) => state`: a pure,
|
|
11
|
+
* synchronous body whose first parameter and whose return are the record's state.
|
|
34
12
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* time. The state parameter is a frozen task input — derive the new state
|
|
39
|
-
* from a `.copy()` (or build it fresh) rather than mutating in place, which
|
|
40
|
-
* raises the uniform copy-first runtime error.
|
|
41
|
-
*
|
|
42
|
-
* The reducer sees the whole state, so its cost in the runner is the record's
|
|
43
|
-
* size however little it changes; only its write, for a Dict or Set record, is
|
|
44
|
-
* proportional to what it touched — any other record's state is written whole.
|
|
45
|
-
* {@link edit} is the form whose body reads only the entries it touches, and
|
|
46
|
-
* whose commit rewrites only the segments they live in.
|
|
47
|
-
*
|
|
48
|
-
* @typeParam Name - Mutation name (literal type)
|
|
49
|
-
* @typeParam T - The owning record's state type
|
|
50
|
-
* @typeParam Args - The EXTRA positional parameter types (after the state)
|
|
51
|
-
* @param name - Mutation name: an identifier, unique within the record
|
|
52
|
-
* @param rec - The record this mutation writes
|
|
13
|
+
* @param words - The declaration, as a refusal names it
|
|
14
|
+
* @param name - The mutation
|
|
15
|
+
* @param rec - The record it writes
|
|
53
16
|
* @param fn - The reducer `(state, ...args) => state`
|
|
54
|
-
* @param config -
|
|
55
|
-
* @returns
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* const orders = e3.record('orders', OrdersType, new Map());
|
|
60
|
-
*
|
|
61
|
-
* const placeOrder = e3.mutation.reduce('place_order', orders,
|
|
62
|
-
* East.function([OrdersType, OrderType], OrdersType, ($, state, order) => {
|
|
63
|
-
* $.if(state.has(order.id), $ => $.error(East.str`duplicate order ${order.id}`));
|
|
64
|
-
* const next = $.let(state.copy());
|
|
65
|
-
* $(next.insert(order.id, order));
|
|
66
|
-
* return next;
|
|
67
|
-
* }));
|
|
68
|
-
*
|
|
69
|
-
* const pkg = e3.package('planning', '1.0.0', orders, placeOrder);
|
|
70
|
-
* ```
|
|
17
|
+
* @param config - Its runner selection
|
|
18
|
+
* @returns The definition
|
|
19
|
+
* @throws {Error} When the name is not an identifier, the runner is not a known runtime, the body is async or calls a
|
|
20
|
+
* platform function, or its first parameter or its return is not the record's state
|
|
71
21
|
*/
|
|
72
|
-
declare function
|
|
22
|
+
export declare function reduceDefinition(words: string, name: string, rec: RecordDef, fn: IndexFunction, config: {
|
|
73
23
|
runner?: FunctionRunner;
|
|
74
|
-
}): MutationDef
|
|
24
|
+
} | undefined): MutationDef;
|
|
75
25
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
26
|
+
* Builds an edit body's definition, `(state, ...args, edit) => null`: a pure,
|
|
27
|
+
* synchronous body writing a Dict or Set record through its last parameter,
|
|
28
|
+
* the `edit` capability.
|
|
78
29
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* `edit.set(key, value)`, `edit.delete(key)` and `edit.update(key, patch)`. It
|
|
83
|
-
* never returns a state, so its commit rewrites only the segments the entries
|
|
84
|
-
* it touched live in. The state reaches its runner as the record's manifest,
|
|
85
|
-
* the segments linked, so nothing on the way reads the record whole either.
|
|
86
|
-
*
|
|
87
|
-
* Repeated edits of one key fold: `set` after anything is that `set`; `update`
|
|
88
|
-
* after `set` applies to the set value; `update` after `update` composes;
|
|
89
|
-
* `delete` after anything is `delete`. A `set` of the value the record already
|
|
90
|
-
* holds is no change. A `delete` or `update` of a key the record does not hold
|
|
91
|
-
* is a conflict naming the key, exactly as applying such a patch would be.
|
|
92
|
-
*
|
|
93
|
-
* The purity rules of {@link reduce} apply unchanged.
|
|
94
|
-
*
|
|
95
|
-
* @typeParam Name - Mutation name (literal type)
|
|
96
|
-
* @typeParam T - The owning record's state type (a Dict)
|
|
97
|
-
* @typeParam Args - The EXTRA positional parameter types (between the state and the edit)
|
|
98
|
-
* @typeParam E - The edit capability's struct type, `e3.mutation.editType(T)`
|
|
99
|
-
* @param name - Mutation name: an identifier, unique within the record
|
|
100
|
-
* @param rec - The record this mutation writes
|
|
30
|
+
* @param words - The declaration, as a refusal names it
|
|
31
|
+
* @param name - The mutation
|
|
32
|
+
* @param rec - The record it writes
|
|
101
33
|
* @param fn - The body `(state, ...args, edit) => null`
|
|
102
|
-
* @param config -
|
|
103
|
-
* @returns
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* ```ts
|
|
107
|
-
* const PlanType = StructType({ title: StringType, owner: StringType, due: DateTimeType });
|
|
108
|
-
* const plans = e3.record('plans', DictType(StringType, PlanType), new Map());
|
|
109
|
-
*
|
|
110
|
-
* // The edit capability is the body's LAST parameter; its type comes from
|
|
111
|
-
* // the record, so `edit.set` checks the key and the row.
|
|
112
|
-
* const reschedule = e3.mutation.edit('reschedule', plans,
|
|
113
|
-
* East.function([plans.type, StringType, DateTimeType, e3.mutation.editType(plans.type)], NullType,
|
|
114
|
-
* ($, state, id, due, edit) => {
|
|
115
|
-
* const plan = $.let(state.get(id));
|
|
116
|
-
* $(edit.set(id, { title: plan.title, owner: plan.owner, due }));
|
|
117
|
-
* }));
|
|
118
|
-
* ```
|
|
34
|
+
* @param config - Its runner selection
|
|
35
|
+
* @returns The definition
|
|
36
|
+
* @throws {Error} When the name is not an identifier, the runner is not a known runtime, the record is not a Dict or a
|
|
37
|
+
* Set, the body is async or calls a platform function, or its parameters or its return are not the form's
|
|
119
38
|
*/
|
|
120
|
-
declare function
|
|
39
|
+
export declare function editDefinition(words: string, name: string, rec: RecordDef, fn: IndexFunction, config: {
|
|
121
40
|
runner?: FunctionRunner;
|
|
122
|
-
}): MutationDef
|
|
41
|
+
} | undefined): MutationDef;
|
|
123
42
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* independent of the record's size: the touched keys are known before anything
|
|
134
|
-
* runs. Any other patch, such as one replacing the whole state, runs a program
|
|
135
|
-
* that checks it against the state, and on a record with indexes one run
|
|
136
|
-
* computes the index entries the change moves, since that is user East and
|
|
137
|
-
* only a runner evaluates it. That run reads the rows the patch touches, and a
|
|
138
|
-
* replace reads them all.
|
|
139
|
-
*
|
|
140
|
-
* @typeParam Name - Mutation name (literal type)
|
|
141
|
-
* @typeParam T - The owning record's state type (a Dict or a Set)
|
|
142
|
-
* @param rec - The record this mutation writes
|
|
143
|
-
* @param name - Mutation name: an identifier; defaults to `patch`
|
|
144
|
-
* @param config - Optional runner selection (known runtimes only)
|
|
145
|
-
* @returns A MutationDef to pass to `e3.package`
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```ts
|
|
149
|
-
* const plans = e3.record('plans', DictType(StringType, PlanType), new Map());
|
|
150
|
-
* const pkg = e3.package('planning', '1.0.0', plans, e3.mutation.patch(plans));
|
|
151
|
-
* ```
|
|
43
|
+
* Builds the patch door's definition: no body, its argument the change, a
|
|
44
|
+
* `PatchType` of a Dict or Set record's state.
|
|
45
|
+
*
|
|
46
|
+
* @param words - The declaration, as a refusal names it
|
|
47
|
+
* @param name - The mutation
|
|
48
|
+
* @param rec - The record it writes
|
|
49
|
+
* @param config - Its runner selection
|
|
50
|
+
* @returns The definition
|
|
51
|
+
* @throws {Error} When the name is not an identifier, the runner is not a known runtime, or the record is not a Dict or a Set
|
|
152
52
|
*/
|
|
153
|
-
declare function
|
|
53
|
+
export declare function patchDefinition(words: string, name: string, rec: RecordDef, config: {
|
|
154
54
|
runner?: FunctionRunner;
|
|
155
|
-
}): MutationDef
|
|
55
|
+
} | undefined): MutationDef;
|
|
156
56
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
57
|
+
* What a record's mutations need beside their builder: `editType(type)`, the
|
|
58
|
+
* type of the capability an `edit` body writes through, its last parameter.
|
|
159
59
|
*/
|
|
160
60
|
export declare const mutation: {
|
|
161
|
-
reduce: typeof reduce;
|
|
162
|
-
edit: typeof edit;
|
|
163
|
-
patch: typeof patch;
|
|
164
61
|
editType: typeof editTypeOf;
|
|
165
62
|
};
|
|
166
|
-
export {};
|
|
167
63
|
//# sourceMappingURL=mutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation.d.ts","sourceRoot":"","sources":["../../src/mutation.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"mutation.d.ts","sourceRoot":"","sources":["../../src/mutation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAmC,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAoDnF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,cAAc,CAAA;CAAE,GAAG,SAAS,GAC9G,WAAW,CA+Bb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,cAAc,CAAA;CAAE,GAAG,SAAS,GAC9G,WAAW,CAkCb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,cAAc,CAAA;CAAE,GAAG,SAAS,GAAG,WAAW,CAczI;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ;;CAA2B,CAAC"}
|
package/dist/src/mutation.js
CHANGED
|
@@ -2,34 +2,34 @@
|
|
|
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 {
|
|
5
|
+
import { NullType, PatchType, printType } from '@elaraai/east';
|
|
6
6
|
import { editTypeOf } from '@elaraai/e3-types';
|
|
7
7
|
import { hasKeyedDelta } from './record-programs.js';
|
|
8
|
-
import { checkPure, sameEastType } from './record-guards.js';
|
|
8
|
+
import { checkPure, sameEastType, signatureOf } from './record-guards.js';
|
|
9
9
|
import { DEFAULT_RUNNER, runnerToVariant } from './runner.js';
|
|
10
10
|
/** A mutation's name is an identifier, as a migration's and an index's are: it
|
|
11
11
|
* names the commits the mutation makes, beside e3's own, which begin with `$`,
|
|
12
12
|
* and `e3 mutate` addresses it as `record.mutation`. */
|
|
13
13
|
const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
14
14
|
/** Refuses a mutation name that is not an identifier. */
|
|
15
|
-
function checkName(
|
|
15
|
+
function checkName(words, name) {
|
|
16
16
|
if (!IDENTIFIER.test(name)) {
|
|
17
|
-
throw new Error(
|
|
17
|
+
throw new Error(`${words} requires a name that is an identifier, got '${name}' — it names the record's ` +
|
|
18
18
|
`commits beside e3's own, which begin with '$', and \`e3 mutate\` addresses it as record.mutation.`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
/** The shared guards: a synchronous, platform-free body whose leading
|
|
22
22
|
* parameter is the record's state. Returns the body's signature. */
|
|
23
|
-
function checkBody(
|
|
24
|
-
checkName(
|
|
25
|
-
checkPure(
|
|
23
|
+
function checkBody(words, name, rec, fn) {
|
|
24
|
+
checkName(words, name);
|
|
25
|
+
checkPure(`${words} '${name}' body`, fn, {
|
|
26
26
|
async: 'an async body implies platform IO, which the compare-and-swap retry loop cannot safely re-run against fresher state.',
|
|
27
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
28
|
});
|
|
29
|
-
const signature =
|
|
29
|
+
const signature = signatureOf(fn);
|
|
30
30
|
if (signature.inputs.length < 1 || !sameEastType(rec.type, signature.inputs[0])) {
|
|
31
31
|
const got = signature.inputs.length ? printType(signature.inputs[0]) : 'no parameters';
|
|
32
|
-
throw new Error(
|
|
32
|
+
throw new Error(`${words} '${name}' body's first parameter must be the record's ` +
|
|
33
33
|
`state type ${printType(rec.type)}, but got ${got}.`);
|
|
34
34
|
}
|
|
35
35
|
return signature;
|
|
@@ -38,25 +38,38 @@ function checkBody(surface, name, rec, fn) {
|
|
|
38
38
|
* patch is positional and a scalar's is a whole replace, so neither can be
|
|
39
39
|
* applied segment by segment — and both are exactly what the `reduce` form
|
|
40
40
|
* already handles by writing the state whole. */
|
|
41
|
-
function checkKeyed(
|
|
41
|
+
function checkKeyed(words, name, rec) {
|
|
42
42
|
if (!hasKeyedDelta(rec.type)) {
|
|
43
|
-
throw new Error(
|
|
43
|
+
throw new Error(`${words} '${name}' writes a delta addressed by key, so it needs a ` +
|
|
44
44
|
`Dict or Set record — '${rec.name}' holds ${printType(rec.type)}. Use ` +
|
|
45
|
-
`
|
|
45
|
+
`mutation.reduce, whose reducer returns the whole state.`);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Builds a reducer's definition, `(state, ...args) => state`: a pure,
|
|
50
|
+
* synchronous body whose first parameter and whose return are the record's state.
|
|
51
|
+
*
|
|
52
|
+
* @param words - The declaration, as a refusal names it
|
|
53
|
+
* @param name - The mutation
|
|
54
|
+
* @param rec - The record it writes
|
|
55
|
+
* @param fn - The reducer `(state, ...args) => state`
|
|
56
|
+
* @param config - Its runner selection
|
|
57
|
+
* @returns The definition
|
|
58
|
+
* @throws {Error} When the name is not an identifier, the runner is not a known runtime, the body is async or calls a
|
|
59
|
+
* platform function, or its first parameter or its return is not the record's state
|
|
60
|
+
*/
|
|
61
|
+
export function reduceDefinition(words, name, rec, fn, config) {
|
|
49
62
|
const runner = config?.runner ?? DEFAULT_RUNNER;
|
|
50
63
|
// Validate eagerly so a bad runner fails at definition time, not export time.
|
|
51
64
|
runnerToVariant(runner);
|
|
52
|
-
const signature = checkBody(
|
|
65
|
+
const signature = checkBody(words, name, rec, fn);
|
|
53
66
|
// The reducer is (state, ...args) => state: the return must be the record's
|
|
54
67
|
// state type too. The typed overload enforces this at compile time, but a
|
|
55
68
|
// dynamic / cast caller could pass a mismatched function — and because
|
|
56
69
|
// MutationObject omits the output type (it IS the record type), a mismatch
|
|
57
70
|
// would be silently undetectable downstream.
|
|
58
71
|
if (!sameEastType(rec.type, signature.output)) {
|
|
59
|
-
throw new Error(
|
|
72
|
+
throw new Error(`${words} '${name}' reducer must return the record's state type ` +
|
|
60
73
|
`${printType(rec.type)}, but returns ${printType(signature.output)}.`);
|
|
61
74
|
}
|
|
62
75
|
return {
|
|
@@ -73,21 +86,35 @@ function reduce(name, rec, fn, config) {
|
|
|
73
86
|
runner,
|
|
74
87
|
};
|
|
75
88
|
}
|
|
76
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Builds an edit body's definition, `(state, ...args, edit) => null`: a pure,
|
|
91
|
+
* synchronous body writing a Dict or Set record through its last parameter,
|
|
92
|
+
* the `edit` capability.
|
|
93
|
+
*
|
|
94
|
+
* @param words - The declaration, as a refusal names it
|
|
95
|
+
* @param name - The mutation
|
|
96
|
+
* @param rec - The record it writes
|
|
97
|
+
* @param fn - The body `(state, ...args, edit) => null`
|
|
98
|
+
* @param config - Its runner selection
|
|
99
|
+
* @returns The definition
|
|
100
|
+
* @throws {Error} When the name is not an identifier, the runner is not a known runtime, the record is not a Dict or a
|
|
101
|
+
* Set, the body is async or calls a platform function, or its parameters or its return are not the form's
|
|
102
|
+
*/
|
|
103
|
+
export function editDefinition(words, name, rec, fn, config) {
|
|
77
104
|
const runner = config?.runner ?? DEFAULT_RUNNER;
|
|
78
105
|
runnerToVariant(runner);
|
|
79
|
-
checkKeyed(
|
|
80
|
-
const signature = checkBody(
|
|
106
|
+
checkKeyed(words, name, rec);
|
|
107
|
+
const signature = checkBody(words, name, rec, fn);
|
|
81
108
|
const editType = editTypeOf(rec.type);
|
|
82
109
|
const last = signature.inputs[signature.inputs.length - 1];
|
|
83
110
|
if (signature.inputs.length < 2 || last === undefined || !sameEastType(editType, last)) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`capability ${printType(editType)} — e3.mutation.editType
|
|
111
|
+
throw new Error(`${words} '${name}' body's LAST parameter must be the edit ` +
|
|
112
|
+
`capability ${printType(editType)} — e3.mutation.editType of the record's type — but got ` +
|
|
86
113
|
`${last === undefined ? 'no parameters' : printType(last)}.`);
|
|
87
114
|
}
|
|
88
115
|
if (!sameEastType(NullType, signature.output)) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`but returns ${printType(signature.output)}. Use
|
|
116
|
+
throw new Error(`${words} '${name}' body writes through 'edit' and returns Null, ` +
|
|
117
|
+
`but returns ${printType(signature.output)}. Use mutation.reduce for a reducer ` +
|
|
91
118
|
`that returns the whole state.`);
|
|
92
119
|
}
|
|
93
120
|
return {
|
|
@@ -102,11 +129,22 @@ function edit(name, rec, fn, config) {
|
|
|
102
129
|
runner,
|
|
103
130
|
};
|
|
104
131
|
}
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Builds the patch door's definition: no body, its argument the change, a
|
|
134
|
+
* `PatchType` of a Dict or Set record's state.
|
|
135
|
+
*
|
|
136
|
+
* @param words - The declaration, as a refusal names it
|
|
137
|
+
* @param name - The mutation
|
|
138
|
+
* @param rec - The record it writes
|
|
139
|
+
* @param config - Its runner selection
|
|
140
|
+
* @returns The definition
|
|
141
|
+
* @throws {Error} When the name is not an identifier, the runner is not a known runtime, or the record is not a Dict or a Set
|
|
142
|
+
*/
|
|
143
|
+
export function patchDefinition(words, name, rec, config) {
|
|
144
|
+
checkName(words, name);
|
|
107
145
|
const runner = config?.runner ?? DEFAULT_RUNNER;
|
|
108
146
|
runnerToVariant(runner);
|
|
109
|
-
checkKeyed(
|
|
147
|
+
checkKeyed(words, name, rec);
|
|
110
148
|
return {
|
|
111
149
|
kind: 'mutation',
|
|
112
150
|
name,
|
|
@@ -117,8 +155,8 @@ function patch(rec, name = 'patch', config) {
|
|
|
117
155
|
};
|
|
118
156
|
}
|
|
119
157
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
158
|
+
* What a record's mutations need beside their builder: `editType(type)`, the
|
|
159
|
+
* type of the capability an `edit` body writes through, its last parameter.
|
|
122
160
|
*/
|
|
123
|
-
export const mutation = {
|
|
161
|
+
export const mutation = { editType: editTypeOf };
|
|
124
162
|
//# sourceMappingURL=mutation.js.map
|
package/dist/src/mutation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation.js","sourceRoot":"","sources":["../../src/mutation.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"mutation.js","sourceRoot":"","sources":["../../src/mutation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAA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AC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,CAAC,IAAI,EAAyB;QACtC,EAAE;QACF,4EAA4E;QAC5E,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,IAAY,EAAE,GAAc,EAAE,MAA+C;IAC1H,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvB,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,cAAc,CAAC;IAChD,eAAe,CAAC,MAAM,CAAC,CAAC;IACxB,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAE7B,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -94,7 +94,7 @@ function programOf(entries, name) {
|
|
|
94
94
|
const pkgRef = [...entries.keys()].find((key) => key.startsWith('packages/'));
|
|
95
95
|
const pkg = decodePackageObject(object(decodeBeast2For(StringType)(entries.get(pkgRef))));
|
|
96
96
|
const task = decodeTaskObject(object(pkg.tasks.get(name)));
|
|
97
|
-
assert.
|
|
97
|
+
assert.ok(task.body.type === 'east');
|
|
98
98
|
return decodeEastIR(object(task.body.value.program));
|
|
99
99
|
}
|
|
100
100
|
const STOCK_RUNNERS = [
|
|
@@ -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,
|
|
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,EAAW,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OA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,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;KAC9G,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,IAAI,CACX,IAAO,EACP,MAGC;IAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,0CAA0C,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI;QACJ,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;QACpC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE;KAClE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/src/package.d.ts
CHANGED
|
@@ -2,42 +2,6 @@
|
|
|
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 type { FunctionDef,
|
|
6
|
-
|
|
7
|
-
* Creates a package definition from items.
|
|
8
|
-
*
|
|
9
|
-
* Automatically collects all dependencies from the provided items.
|
|
10
|
-
* You only need to pass the "top-level" items - all inputs, intermediate
|
|
11
|
-
* tasks, and datasets they depend on are included automatically.
|
|
12
|
-
*
|
|
13
|
-
* Organizes items into a discoverable structure:
|
|
14
|
-
* - `pkg.datasets.inputs.*` - Input datasets
|
|
15
|
-
* - `pkg.datasets.outputs.*` - Output datasets
|
|
16
|
-
* - `pkg.tasks.*` - Tasks
|
|
17
|
-
*
|
|
18
|
-
* @param name - Package name
|
|
19
|
-
* @param version - Package version
|
|
20
|
-
* @param items - Items to include (datasets, tasks)
|
|
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
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const input_name = e3.input('name', StringType, variant('value', 'World'));
|
|
31
|
-
* const say_hello = e3.task('say_hello', [input_name], ...);
|
|
32
|
-
*
|
|
33
|
-
* // Only need to pass the final task - input_name is included automatically
|
|
34
|
-
* const pkg = e3.package('hello_world', '1.0.0', say_hello);
|
|
35
|
-
*
|
|
36
|
-
* // Typed access to contents
|
|
37
|
-
* const nameInput = pkg.datasets.inputs.name;
|
|
38
|
-
* const helloOutput = pkg.datasets.outputs.say_hello;
|
|
39
|
-
* const helloTask = pkg.tasks.say_hello;
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function package_(name: string, version: string, ...items: (PackageItem | FunctionDef | MutationDef | RecordIndexDef | MigrationDef | PackageDef<any>)[]): PackageDef<Record<string, unknown>>;
|
|
5
|
+
import type { FunctionDef, PackageDef, PackageItem } from './types.js';
|
|
6
|
+
export declare function package_(name: string, version: string, ...items: (PackageItem | FunctionDef | PackageDef<Record<string, unknown>>)[]): PackageDef<Record<string, unknown>>;
|
|
43
7
|
//# sourceMappingURL=package.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAEV,WAAW,EACX,UAAU,EACV,WAAW,EAGZ,MAAM,YAAY,CAAC;AAiDpB,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,KAAK,EAAE,CAAC,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAC5E,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0FrC"}
|