@rotorsoft/act 1.34.1 → 1.34.3
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/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +3 -2
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-cache.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/merge.d.ts.map +1 -1
- package/dist/@types/builders/projection-builder.d.ts.map +1 -1
- package/dist/@types/builders/slice-builder.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +1 -2
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/test/sandbox.d.ts.map +1 -1
- package/dist/@types/types/builders.d.ts +61 -138
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/{chunk-BTLM7SW4.cjs → chunk-GBAMBUDN.cjs} +1 -1
- package/dist/chunk-GBAMBUDN.cjs.map +1 -0
- package/dist/{chunk-5F2TQ4PT.js → chunk-IEM2NS6J.js} +1 -1
- package/dist/chunk-IEM2NS6J.js.map +1 -0
- package/dist/index.cjs +164 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -36
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +3 -3
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-5F2TQ4PT.js.map +0 -1
- package/dist/chunk-BTLM7SW4.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
sleep,
|
|
41
41
|
store,
|
|
42
42
|
validate
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-IEM2NS6J.js";
|
|
44
44
|
import {
|
|
45
45
|
ActorSchema,
|
|
46
46
|
CausationEventSchema,
|
|
@@ -1911,32 +1911,25 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1911
1911
|
if (snapshot.event?.name === TOMBSTONE_EVENT)
|
|
1912
1912
|
throw new StreamClosedError(stream);
|
|
1913
1913
|
const expected = expectedVersion ?? (snapshot.version >= 0 ? snapshot.version : void 0);
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
validated,
|
|
1934
|
-
target,
|
|
1935
|
-
snapshot,
|
|
1936
|
-
description,
|
|
1937
|
-
"precondition"
|
|
1938
|
-
);
|
|
1939
|
-
}
|
|
1914
|
+
for (const { valid: valid2, description } of me.given?.[action2] ?? [])
|
|
1915
|
+
if (!valid2(snapshot.state, actor))
|
|
1916
|
+
throw new InvariantError(
|
|
1917
|
+
action2,
|
|
1918
|
+
validated,
|
|
1919
|
+
target,
|
|
1920
|
+
snapshot,
|
|
1921
|
+
description
|
|
1922
|
+
);
|
|
1923
|
+
for (const { holds, description } of me.requires?.[action2] ?? [])
|
|
1924
|
+
if (!holds(validated, snapshot.state, actor))
|
|
1925
|
+
throw new InvariantError(
|
|
1926
|
+
action2,
|
|
1927
|
+
validated,
|
|
1928
|
+
target,
|
|
1929
|
+
snapshot,
|
|
1930
|
+
description,
|
|
1931
|
+
"precondition"
|
|
1932
|
+
);
|
|
1940
1933
|
const result = me.on[action2](validated, snapshot, target);
|
|
1941
1934
|
if (!result) return [snapshot];
|
|
1942
1935
|
if (Array.isArray(result) && result.length === 0) {
|
|
@@ -3561,8 +3554,9 @@ var Act = class {
|
|
|
3561
3554
|
* the event), and marks their work so the next drain can claim it.
|
|
3562
3555
|
*
|
|
3563
3556
|
* @param query - Only `limit` is used: the most events the pass reads
|
|
3564
|
-
* (
|
|
3565
|
-
* which every reaction shares, so
|
|
3557
|
+
* (10 when the query has none; `0` reads everything). The scan always
|
|
3558
|
+
* starts at the correlation checkpoint, which every reaction shares, so
|
|
3559
|
+
* filters and `after` are ignored.
|
|
3566
3560
|
* @returns The number of newly subscribed streams and the last scanned event id
|
|
3567
3561
|
*
|
|
3568
3562
|
* @example Manual correlation
|
|
@@ -3572,8 +3566,8 @@ var Act = class {
|
|
|
3572
3566
|
*
|
|
3573
3567
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3574
3568
|
*/
|
|
3575
|
-
async correlate(query = {
|
|
3576
|
-
const pass = await this._correlate_pass(query);
|
|
3569
|
+
async correlate(query = {}) {
|
|
3570
|
+
const pass = await this._correlate_pass({ limit: query.limit ?? 10 });
|
|
3577
3571
|
return {
|
|
3578
3572
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
3579
3573
|
last_id: pass.last_id
|
|
@@ -4230,7 +4224,7 @@ function autoclose_of(existing, state2) {
|
|
|
4230
4224
|
}
|
|
4231
4225
|
function merge_into_existing(state2, existing, states, actions, events) {
|
|
4232
4226
|
for (const name of Object.keys(state2.actions)) {
|
|
4233
|
-
if (existing.
|
|
4227
|
+
if (existing.on[name] === state2.on[name]) continue;
|
|
4234
4228
|
if (actions[name]) throw new Error(`Duplicate action "${name}"`);
|
|
4235
4229
|
}
|
|
4236
4230
|
for (const name of Object.keys(state2.events)) {
|
|
@@ -5018,13 +5012,11 @@ function action_builder(state2) {
|
|
|
5018
5012
|
internal.options[action2] = options;
|
|
5019
5013
|
}
|
|
5020
5014
|
function given(rules) {
|
|
5021
|
-
internal.given ??= {};
|
|
5022
|
-
internal.given[action2] = rules;
|
|
5015
|
+
(internal.given ??= {})[action2] = rules;
|
|
5023
5016
|
return { requires, emit };
|
|
5024
5017
|
}
|
|
5025
5018
|
function requires(rules) {
|
|
5026
|
-
internal.requires ??= {};
|
|
5027
|
-
internal.requires[action2] = rules;
|
|
5019
|
+
(internal.requires ??= {})[action2] = rules;
|
|
5028
5020
|
return { emit };
|
|
5029
5021
|
}
|
|
5030
5022
|
function emit(handler) {
|