@rotorsoft/act 1.34.2 → 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/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/index.cjs +65 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -30
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -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) {
|
|
@@ -5019,13 +5012,11 @@ function action_builder(state2) {
|
|
|
5019
5012
|
internal.options[action2] = options;
|
|
5020
5013
|
}
|
|
5021
5014
|
function given(rules) {
|
|
5022
|
-
internal.given ??= {};
|
|
5023
|
-
internal.given[action2] = rules;
|
|
5015
|
+
(internal.given ??= {})[action2] = rules;
|
|
5024
5016
|
return { requires, emit };
|
|
5025
5017
|
}
|
|
5026
5018
|
function requires(rules) {
|
|
5027
|
-
internal.requires ??= {};
|
|
5028
|
-
internal.requires[action2] = rules;
|
|
5019
|
+
(internal.requires ??= {})[action2] = rules;
|
|
5029
5020
|
return { emit };
|
|
5030
5021
|
}
|
|
5031
5022
|
function emit(handler) {
|