@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.
@@ -1 +1 @@
1
- {"version":3,"file":"state-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/state-builder.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAGV,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAcV,MAAM,EAKP,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAC/D,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAC/B,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAmD7B"}
1
+ {"version":3,"file":"state-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/state-builder.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAGV,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAYV,MAAM,EAKP,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAC/D,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAC/B,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAmD7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"event-sourcing.d.ts","sourceRoot":"","sources":["../../../src/internal/event-sourcing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,KAAK,EAEV,SAAS,EACT,SAAS,EAGT,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,UAAU,EACV,MAAM,EAC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32 +1911,25 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1911
1911
  if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) === _chunkRF5MV72Kcjs.TOMBSTONE_EVENT)
1912
1912
  throw new (0, _chunkRF5MV72Kcjs.StreamClosedError)(stream);
1913
1913
  const expected = _nullishCoalesce(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 (0, _chunkRF5MV72Kcjs.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 (0, _chunkRF5MV72Kcjs.InvariantError)(
1932
- action2,
1933
- validated,
1934
- target,
1935
- snapshot,
1936
- description,
1937
- "precondition"
1938
- );
1939
- }
1914
+ for (const { valid: valid2, description } of _nullishCoalesce(_optionalChain([me, 'access', _88 => _88.given, 'optionalAccess', _89 => _89[action2]]), () => ( [])))
1915
+ if (!valid2(snapshot.state, actor))
1916
+ throw new (0, _chunkRF5MV72Kcjs.InvariantError)(
1917
+ action2,
1918
+ validated,
1919
+ target,
1920
+ snapshot,
1921
+ description
1922
+ );
1923
+ for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _90 => _90.requires, 'optionalAccess', _91 => _91[action2]]), () => ( [])))
1924
+ if (!holds(validated, snapshot.state, actor))
1925
+ throw new (0, _chunkRF5MV72Kcjs.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) {
@@ -1949,7 +1942,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1949
1942
  }));
1950
1943
  const emitted = valid.map((e) => me.message(e));
1951
1944
  const meta = {
1952
- correlation: _optionalChain([reactingTo, 'optionalAccess', _88 => _88.meta, 'access', _89 => _89.correlation]) || correlator({
1945
+ correlation: _optionalChain([reactingTo, 'optionalAccess', _92 => _92.meta, 'access', _93 => _93.correlation]) || correlator({
1953
1946
  action: action2,
1954
1947
  state: me.name,
1955
1948
  stream,
@@ -2002,15 +1995,15 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
2002
1995
  });
2003
1996
  const last = snapshots.at(-1);
2004
1997
  const contiguous = committed[0].version === snapshot.version + 1;
2005
- const snapped = contiguous && _optionalChain([me, 'access', _90 => _90.snap, 'optionalCall', _91 => _91(last)]);
1998
+ const snapped = contiguous && _optionalChain([me, 'access', _94 => _94.snap, 'optionalCall', _95 => _95(last)]);
2006
1999
  const snap_event = snapped ? await snap(last) : void 0;
2007
2000
  if (!me.pii_aware) {
2008
2001
  if (contiguous)
2009
2002
  void cache_put(stream, {
2010
2003
  stream,
2011
2004
  state: last.state,
2012
- version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _92 => _92.version]), () => ( last.event.version)),
2013
- event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _93 => _93.id]), () => ( last.event.id)),
2005
+ version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _96 => _96.version]), () => ( last.event.version)),
2006
+ event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _97 => _97.id]), () => ( last.event.id)),
2014
2007
  patches: snap_event ? 0 : last.patches,
2015
2008
  snaps: snap_event ? last.snaps + 1 : last.snaps
2016
2009
  });
@@ -2021,7 +2014,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
2021
2014
  if (!(error instanceof _chunkRF5MV72Kcjs.ConcurrencyError)) throw error;
2022
2015
  if (expectedVersion !== void 0) throw error;
2023
2016
  if (attempt >= max_retries) throw error;
2024
- if (_optionalChain([opts, 'optionalAccess', _94 => _94.backoff])) {
2017
+ if (_optionalChain([opts, 'optionalAccess', _98 => _98.backoff])) {
2025
2018
  const delay_ms = compute_backoff_delay(attempt, opts.backoff);
2026
2019
  if (delay_ms > 0) await _chunkGBAMBUDNcjs.sleep.call(void 0, delay_ms);
2027
2020
  }
@@ -2076,9 +2069,9 @@ var as_of_marker = (asOf) => {
2076
2069
  return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
2077
2070
  };
2078
2071
  var traced = (inner, exit, entry) => (async (...args) => {
2079
- _optionalChain([entry, 'optionalCall', _95 => _95(...args)]);
2072
+ _optionalChain([entry, 'optionalCall', _99 => _99(...args)]);
2080
2073
  const result = await inner(...args);
2081
- _optionalChain([exit, 'optionalCall', _96 => _96(result, ...args)]);
2074
+ _optionalChain([exit, 'optionalCall', _100 => _100(result, ...args)]);
2082
2075
  return result;
2083
2076
  });
2084
2077
  function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
@@ -2163,7 +2156,7 @@ function build_drain(logger) {
2163
2156
  subscribe: logger.level !== "trace" ? subscribe : traced(subscribe, (result, streams) => {
2164
2157
  if (!result.subscribed) return;
2165
2158
  const lanes = new Set(streams.map((s) => _nullishCoalesce(s.lane, () => ( "default"))));
2166
- const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _97 => _97[0], 'optionalAccess', _98 => _98.lane]) : void 0;
2159
+ const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _101 => _101[0], 'optionalAccess', _102 => _102.lane]) : void 0;
2167
2160
  const data = streams.map(
2168
2161
  ({ stream, lane }) => uniform_lane || !lane || lane === "default" ? hue(C_STREAM, stream) : `${hue(C_STREAM, stream)}${dim(`[${lane}]`)}`
2169
2162
  ).join(" ");
@@ -2175,7 +2168,7 @@ function build_drain(logger) {
2175
2168
  }
2176
2169
  function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
2177
2170
  if (logger.level !== "trace" || !leased.length) return;
2178
- const lane = _optionalChain([leased, 'access', _99 => _99[0], 'optionalAccess', _100 => _100.lane]);
2171
+ const lane = _optionalChain([leased, 'access', _103 => _103[0], 'optionalAccess', _104 => _104.lane]);
2179
2172
  const fetch_by_stream = new Map(fetched.map((f) => [f.stream, f]));
2180
2173
  const acked_by_stream = new Map(acked.map((a) => [a.stream, a.at]));
2181
2174
  const blocked_by_stream = new Map(blocked.map((b) => [b.stream, b.error]));
@@ -2184,8 +2177,8 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
2184
2177
  );
2185
2178
  const detail = leased.map(({ stream, at, retry }) => {
2186
2179
  const f = fetch_by_stream.get(stream);
2187
- const key = _optionalChain([f, 'optionalAccess', _101 => _101.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
2188
- const events = _optionalChain([f, 'optionalAccess', _102 => _102.events, 'access', _103 => _103.length]) ? ` ${dim(
2180
+ const key = _optionalChain([f, 'optionalAccess', _105 => _105.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
2181
+ const events = _optionalChain([f, 'optionalAccess', _106 => _106.events, 'access', _107 => _107.length]) ? ` ${dim(
2189
2182
  `[${f.events.map(({ id, name }) => `#${id} ${String(name)}`).join(", ")}]`
2190
2183
  )}` : "";
2191
2184
  const acked_at = acked_by_stream.get(stream);
@@ -2213,7 +2206,7 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
2213
2206
 
2214
2207
  // src/internal/drain-cycle.ts
2215
2208
  function budget_exhausted(lease, options, store_failing) {
2216
- if (store_failing || !_optionalChain([options, 'optionalAccess', _104 => _104.blockOnError]) || lease.retry <= options.maxRetries)
2209
+ if (store_failing || !_optionalChain([options, 'optionalAccess', _108 => _108.blockOnError]) || lease.retry <= options.maxRetries)
2217
2210
  return void 0;
2218
2211
  const error = `Blocking ${lease.stream} after ${lease.retry} claims with no acknowledged progress \u2014 the retry budget (${options.maxRetries}) was spent without the handler ever reporting an error. That means every attempt lost its lease before it could ack: move the reaction to a lane whose leaseMillis covers the handler, then unblock the stream.`;
2219
2212
  _chunkGBAMBUDNcjs.log.call(void 0, ).error(error);
@@ -2277,7 +2270,7 @@ async function run_drain_cycle(deps, cycle) {
2277
2270
  const fetched = await ops.fetch(leased, eventLimit);
2278
2271
  const fetch_map = /* @__PURE__ */ new Map();
2279
2272
  const fetch_window_at = fetched.reduce(
2280
- (max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _105 => _105.at, 'call', _106 => _106(-1), 'optionalAccess', _107 => _107.id]) || at),
2273
+ (max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _109 => _109.at, 'call', _110 => _110(-1), 'optionalAccess', _111 => _111.id]) || at),
2281
2274
  0
2282
2275
  );
2283
2276
  for (const f of fetched) {
@@ -2341,11 +2334,11 @@ async function run_drain_cycle(deps, cycle) {
2341
2334
  deps.logger
2342
2335
  )
2343
2336
  );
2344
- const at = _optionalChain([entry, 'access', _108 => _108.fetch, 'access', _109 => _109.events, 'access', _110 => _110.at, 'call', _111 => _111(-1), 'optionalAccess', _112 => _112.id]) || fetch_window_at;
2337
+ const at = _optionalChain([entry, 'access', _112 => _112.fetch, 'access', _113 => _113.events, 'access', _114 => _114.at, 'call', _115 => _115(-1), 'optionalAccess', _116 => _116.id]) || fetch_window_at;
2345
2338
  const { payloads } = entry;
2346
2339
  const exhausted = budget_exhausted(
2347
2340
  lease,
2348
- _optionalChain([payloads, 'access', _113 => _113[0], 'optionalAccess', _114 => _114.options]),
2341
+ _optionalChain([payloads, 'access', _117 => _117[0], 'optionalAccess', _118 => _118.options]),
2349
2342
  store_failing
2350
2343
  );
2351
2344
  if (exhausted) return Promise.resolve(exhausted);
@@ -2434,7 +2427,7 @@ var DrainController = (_class5 = class {
2434
2427
  }
2435
2428
  /** This lane's configured lease, or `undefined`; the shutdown grace basis. */
2436
2429
  get lease_millis() {
2437
- return _optionalChain([this, 'access', _115 => _115._deps, 'access', _116 => _116.defaults, 'optionalAccess', _117 => _117.leaseMillis]);
2430
+ return _optionalChain([this, 'access', _119 => _119._deps, 'access', _120 => _120.defaults, 'optionalAccess', _121 => _121.leaseMillis]);
2438
2431
  }
2439
2432
  get lane() {
2440
2433
  return this._deps.lane;
@@ -2727,10 +2720,10 @@ var CloseSignal = class extends Error {
2727
2720
  constructor(opts) {
2728
2721
  super("reaction requested close");
2729
2722
  this.name = "CloseSignal";
2730
- this.stream = _optionalChain([opts, 'optionalAccess', _118 => _118.stream]);
2731
- this.archive = _optionalChain([opts, 'optionalAccess', _119 => _119.archive]);
2732
- this.at = _optionalChain([opts, 'optionalAccess', _120 => _120.at]);
2733
- this.before = _optionalChain([opts, 'optionalAccess', _121 => _121.before]);
2723
+ this.stream = _optionalChain([opts, 'optionalAccess', _122 => _122.stream]);
2724
+ this.archive = _optionalChain([opts, 'optionalAccess', _123 => _123.archive]);
2725
+ this.at = _optionalChain([opts, 'optionalAccess', _124 => _124.at]);
2726
+ this.before = _optionalChain([opts, 'optionalAccess', _125 => _125.before]);
2734
2727
  }
2735
2728
  };
2736
2729
  function build_handle(deps) {
@@ -2877,7 +2870,7 @@ var SettleLoop = (_class6 = class {
2877
2870
  this._pending = true;
2878
2871
  return;
2879
2872
  }
2880
- const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _122 => _122.debounceMs]), () => ( this._default_debounce_ms));
2873
+ const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _126 => _126.debounceMs]), () => ( this._default_debounce_ms));
2881
2874
  const due = Date.now() + delay;
2882
2875
  if (this._timer) {
2883
2876
  if (due >= this._due) return;
@@ -3151,7 +3144,7 @@ var Act = (_class7 = class {
3151
3144
  leaseMillis: cfg.leaseMillis
3152
3145
  }
3153
3146
  });
3154
- if (_optionalChain([cfg, 'optionalAccess', _123 => _123.cycleMs]) !== void 0 && options.drain !== false)
3147
+ if (_optionalChain([cfg, 'optionalAccess', _127 => _127.cycleMs]) !== void 0 && options.drain !== false)
3155
3148
  controller.start(cfg.cycleMs);
3156
3149
  controllers.set(name, controller);
3157
3150
  }
@@ -3203,7 +3196,7 @@ var Act = (_class7 = class {
3203
3196
  await walk_streams(_chunkGBAMBUDNcjs.store.call(void 0, ), (pos) => {
3204
3197
  if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
3205
3198
  const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
3206
- _optionalChain([controller, 'optionalAccess', _124 => _124.seed_defer, 'call', _125 => _125(pos.stream, pos.deferred_at)]);
3199
+ _optionalChain([controller, 'optionalAccess', _128 => _128.seed_defer, 'call', _129 => _129(pos.stream, pos.deferred_at)]);
3207
3200
  });
3208
3201
  }
3209
3202
  _build_settle(options) {
@@ -3247,7 +3240,7 @@ var Act = (_class7 = class {
3247
3240
  for (const c of this._drain_controllers.values()) c.stop();
3248
3241
  const disposer = await this._notify_disposer;
3249
3242
  if (disposer) await disposer();
3250
- await this._await_inflight(_optionalChain([options, 'optionalAccess', _126 => _126.graceMs]));
3243
+ await this._await_inflight(_optionalChain([options, 'optionalAccess', _130 => _130.graceMs]));
3251
3244
  await this._scoped(() => this._correlate.release_correlation());
3252
3245
  this._emitter.removeAllListeners();
3253
3246
  })();
@@ -3343,8 +3336,8 @@ var Act = (_class7 = class {
3343
3336
  * @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
3344
3337
  */
3345
3338
  async do(action2, target, payload, options) {
3346
- const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => ( _chunkGBAMBUDNcjs.current_reacting.call(void 0, )));
3347
- const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _128 => _128.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
3339
+ const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.reactingTo]), () => ( _chunkGBAMBUDNcjs.current_reacting.call(void 0, )));
3340
+ const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _132 => _132.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
3348
3341
  return this._scoped(async () => {
3349
3342
  const snapshots = await this._es.action(
3350
3343
  this.registry.actions[action2],
@@ -3408,7 +3401,7 @@ var Act = (_class7 = class {
3408
3401
  const gated = this.registry.query_gate(e.name)(e);
3409
3402
  if (!first) first = gated;
3410
3403
  last = gated;
3411
- _optionalChain([callback, 'optionalCall', _129 => _129(gated)]);
3404
+ _optionalChain([callback, 'optionalCall', _133 => _133(gated)]);
3412
3405
  }, query);
3413
3406
  return { first, last, count };
3414
3407
  });
@@ -3535,7 +3528,7 @@ var Act = (_class7 = class {
3535
3528
  }
3536
3529
  if (to_arm.size === 0) return false;
3537
3530
  this._correlate.arm();
3538
- for (const lane of to_arm) _optionalChain([this, 'access', _130 => _130._drain_controllers, 'access', _131 => _131.get, 'call', _132 => _132(lane), 'optionalAccess', _133 => _133.arm, 'call', _134 => _134()]);
3531
+ for (const lane of to_arm) _optionalChain([this, 'access', _134 => _134._drain_controllers, 'access', _135 => _135.get, 'call', _136 => _136(lane), 'optionalAccess', _137 => _137.arm, 'call', _138 => _138()]);
3539
3532
  return true;
3540
3533
  }
3541
3534
  /** In parallel, so a slow lane never holds up a fast one. */
@@ -3678,7 +3671,7 @@ var Act = (_class7 = class {
3678
3671
  return this._scoped(async () => {
3679
3672
  const count = await _chunkGBAMBUDNcjs.store.call(void 0, ).reset(input);
3680
3673
  for (const handler of this._batch_handlers.values())
3681
- _optionalChain([handler, 'access', _135 => _135[FOLD_RESET], 'optionalCall', _136 => _136()]);
3674
+ _optionalChain([handler, 'access', _139 => _139[FOLD_RESET], 'optionalCall', _140 => _140()]);
3682
3675
  if (count > 0) {
3683
3676
  this._wake();
3684
3677
  }
@@ -3817,7 +3810,7 @@ var Act = (_class7 = class {
3817
3810
  (p) => {
3818
3811
  positions.push(p);
3819
3812
  },
3820
- { blocked: true, after: _optionalChain([options, 'optionalAccess', _137 => _137.after]), limit: _optionalChain([options, 'optionalAccess', _138 => _138.limit]) }
3813
+ { blocked: true, after: _optionalChain([options, 'optionalAccess', _141 => _141.after]), limit: _optionalChain([options, 'optionalAccess', _142 => _142.limit]) }
3821
3814
  );
3822
3815
  return positions;
3823
3816
  });
@@ -4011,12 +4004,12 @@ function policy_min_after_days(options) {
4011
4004
  const parsed = AutoclosePolicySchema.parse(options);
4012
4005
  const windows = [];
4013
4006
  if (parsed.after) windows.push(parsed.after.days);
4014
- if (_optionalChain([parsed, 'access', _139 => _139.or, 'optionalAccess', _140 => _140.after])) windows.push(parsed.or.after.days);
4007
+ if (_optionalChain([parsed, 'access', _143 => _143.or, 'optionalAccess', _144 => _144.after])) windows.push(parsed.or.after.days);
4015
4008
  return windows.length ? Math.min(...windows) : void 0;
4016
4009
  }
4017
4010
  function policy_keep_days(options) {
4018
4011
  const parsed = AutoclosePolicySchema.parse(options);
4019
- return _optionalChain([parsed, 'access', _141 => _141.keep, 'optionalAccess', _142 => _142.days]);
4012
+ return _optionalChain([parsed, 'access', _145 => _145.keep, 'optionalAccess', _146 => _146.days]);
4020
4013
  }
4021
4014
  function compile_autoclose_policy(options) {
4022
4015
  const parsed = AutoclosePolicySchema.parse(options);
@@ -4048,7 +4041,7 @@ function hour_in_zone(now, timeZone) {
4048
4041
  hour: "2-digit",
4049
4042
  hourCycle: "h23"
4050
4043
  }).formatToParts(now);
4051
- return Number(_optionalChain([parts, 'access', _143 => _143.find, 'call', _144 => _144((p) => p.type === "hour"), 'optionalAccess', _145 => _145.value]));
4044
+ return Number(_optionalChain([parts, 'access', _147 => _147.find, 'call', _148 => _148((p) => p.type === "hour"), 'optionalAccess', _149 => _149.value]));
4052
4045
  }
4053
4046
  function hour_in_range(hour, start, end) {
4054
4047
  return start < end ? hour >= start && hour < end : hour >= start || hour < end;
@@ -4146,7 +4139,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
4146
4139
  };
4147
4140
  const key = `__autoclose_${st.name}`;
4148
4141
  for (const event_name of Object.keys(st.events)) {
4149
- _optionalChain([registry, 'access', _146 => _146.events, 'access', _147 => _147[event_name], 'optionalAccess', _148 => _148.reactions, 'access', _149 => _149.set, 'call', _150 => _150(
4142
+ _optionalChain([registry, 'access', _150 => _150.events, 'access', _151 => _151[event_name], 'optionalAccess', _152 => _152.reactions, 'access', _153 => _153.set, 'call', _154 => _154(
4150
4143
  key,
4151
4144
  reaction
4152
4145
  )]);
@@ -4391,9 +4384,9 @@ function reaction_on(event, events, builder) {
4391
4384
  // `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
4392
4385
  // not a NaN gate on the first retry.
4393
4386
  options: _chunkGBAMBUDNcjs.resolveReactionConfig.call(void 0, {
4394
- blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => ( _chunkGBAMBUDNcjs.DEFAULT_BLOCK_ON_ERROR)),
4395
- maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => ( _chunkGBAMBUDNcjs.DEFAULT_MAX_RETRIES)),
4396
- backoff: _optionalChain([options, 'optionalAccess', _153 => _153.backoff])
4387
+ blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _155 => _155.blockOnError]), () => ( _chunkGBAMBUDNcjs.DEFAULT_BLOCK_ON_ERROR)),
4388
+ maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.maxRetries]), () => ( _chunkGBAMBUDNcjs.DEFAULT_MAX_RETRIES)),
4389
+ backoff: _optionalChain([options, 'optionalAccess', _157 => _157.backoff])
4397
4390
  })
4398
4391
  };
4399
4392
  },
@@ -4412,9 +4405,9 @@ function reaction_on(event, events, builder) {
4412
4405
 
4413
4406
  // src/internal/date-reviver.ts
4414
4407
 
4415
- var def_of = (schema) => _nullishCoalesce(_optionalChain([schema, 'access', _154 => _154._zod, 'optionalAccess', _155 => _155.def]), () => ( schema.def));
4408
+ var def_of = (schema) => _nullishCoalesce(_optionalChain([schema, 'access', _158 => _158._zod, 'optionalAccess', _159 => _159.def]), () => ( schema.def));
4416
4409
  function variant_schema(schema) {
4417
- const shape = _optionalChain([def_of, 'call', _156 => _156(schema), 'optionalAccess', _157 => _157.shape]);
4410
+ const shape = _optionalChain([def_of, 'call', _160 => _160(schema), 'optionalAccess', _161 => _161.shape]);
4418
4411
  if (!shape) {
4419
4412
  const dates = date_reviver_schema(schema);
4420
4413
  return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
@@ -4462,7 +4455,7 @@ function date_reviver_schema(schema) {
4462
4455
  return variants.some((v) => v.dated) ? _zod2.z.union(variants.map((v) => v.schema)) : void 0;
4463
4456
  }
4464
4457
  case "nullable":
4465
- return _optionalChain([inner, 'call', _158 => _158(), 'optionalAccess', _159 => _159.nullable, 'call', _160 => _160()]);
4458
+ return _optionalChain([inner, 'call', _162 => _162(), 'optionalAccess', _163 => _163.nullable, 'call', _164 => _164()]);
4466
4459
  case "optional":
4467
4460
  case "nonoptional":
4468
4461
  case "readonly":
@@ -4639,7 +4632,7 @@ function act() {
4639
4632
  let _built = false;
4640
4633
  const read_wrap = (original) => {
4641
4634
  const wrapped = async (events, stream) => {
4642
- const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _161 => _161.get, 'call', _162 => _162(e.name), 'optionalCall', _163 => _163(e)]), () => ( e)));
4635
+ const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _165 => _165.get, 'call', _166 => _166(e.name), 'optionalCall', _167 => _167(e)]), () => ( e)));
4643
4636
  return original(read, stream);
4644
4637
  };
4645
4638
  const reset = original[FOLD_RESET];
@@ -4681,7 +4674,7 @@ function act() {
4681
4674
  });
4682
4675
  }
4683
4676
  for (const [action_name, handler] of Object.entries(state2.on)) {
4684
- const static_target = _optionalChain([handler, 'optionalAccess', _164 => _164._static_emit]);
4677
+ const static_target = _optionalChain([handler, 'optionalAccess', _168 => _168._static_emit]);
4685
4678
  if (static_target && deprecated.has(static_target)) {
4686
4679
  const current = current_version_of(static_target, event_names);
4687
4680
  throw new Error(
@@ -4737,7 +4730,7 @@ function act() {
4737
4730
  },
4738
4731
  build: (options) => {
4739
4732
  _chunkGBAMBUDNcjs.resolveActConfig.call(void 0, options);
4740
- const patch_fn = _optionalChain([options, 'optionalAccess', _165 => _165.validateFoldedState]) === true ? validating_patch : bare_patch;
4733
+ const patch_fn = _optionalChain([options, 'optionalAccess', _169 => _169.validateFoldedState]) === true ? validating_patch : bare_patch;
4741
4734
  if (!_built) {
4742
4735
  for (const proj of pending_projections) add_projection(proj);
4743
4736
  for (const proj of fold_projections) {
@@ -4755,7 +4748,7 @@ function act() {
4755
4748
  `State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
4756
4749
  );
4757
4750
  const claimed = fold_specs.find((s) => s.target === proj.target);
4758
- if (_optionalChain([claimed, 'optionalAccess', _166 => _166.projection]) === proj) continue;
4751
+ if (_optionalChain([claimed, 'optionalAccess', _170 => _170.projection]) === proj) continue;
4759
4752
  if (batch_handlers.has(proj.target) || claimed)
4760
4753
  throw new Error(
4761
4754
  `Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
@@ -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) {