@rotorsoft/act 1.34.2 → 1.34.4

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/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
- if (me.given) {
1915
- const invariants = me.given[action2] || [];
1916
- invariants.forEach(({ valid: valid2, description }) => {
1917
- if (!valid2(snapshot.state, actor))
1918
- throw new InvariantError(
1919
- action2,
1920
- validated,
1921
- target,
1922
- snapshot,
1923
- description
1924
- );
1925
- });
1926
- }
1927
- if (me.requires) {
1928
- const preconditions = me.requires[action2] || [];
1929
- for (const { holds, description } of preconditions)
1930
- if (!holds(validated, snapshot.state, actor))
1931
- throw new InvariantError(
1932
- action2,
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) {
@@ -3602,8 +3595,9 @@ var Act = class {
3602
3595
  * (`drain: false`) each tick is a no-op, like `settle()`.
3603
3596
  *
3604
3597
  * @param query - Only `limit` is used: the most events each correlate pass
3605
- * reads (default 100). The scan always starts at the correlation
3606
- * checkpoint, so `after` is ignored.
3598
+ * reads. With no limit, or `0`, the passes use the background default
3599
+ * (100): a poll never reads the whole log in one tick. The scan always
3600
+ * starts at the correlation checkpoint, so `after` is ignored.
3607
3601
  * @param frequency - Milliseconds between ticks (default: 10000)
3608
3602
  * @returns `true` if the poll started, `false` if one is already running
3609
3603
  *
@@ -5019,13 +5013,11 @@ function action_builder(state2) {
5019
5013
  internal.options[action2] = options;
5020
5014
  }
5021
5015
  function given(rules) {
5022
- internal.given ??= {};
5023
- internal.given[action2] = rules;
5016
+ (internal.given ??= {})[action2] = rules;
5024
5017
  return { requires, emit };
5025
5018
  }
5026
5019
  function requires(rules) {
5027
- internal.requires ??= {};
5028
- internal.requires[action2] = rules;
5020
+ (internal.requires ??= {})[action2] = rules;
5029
5021
  return { emit };
5030
5022
  }
5031
5023
  function emit(handler) {