@rotorsoft/act 1.35.1 → 1.35.2

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
@@ -40,7 +40,7 @@ import {
40
40
  sleep,
41
41
  store,
42
42
  validate
43
- } from "./chunk-MHPUVTMX.js";
43
+ } from "./chunk-SVVVS6GA.js";
44
44
  import {
45
45
  ActorSchema,
46
46
  CausationEventSchema,
@@ -71,7 +71,7 @@ import {
71
71
  pii_fields,
72
72
  pii_schemas,
73
73
  sensitive
74
- } from "./chunk-DH2HW5XJ.js";
74
+ } from "./chunk-H2QN755D.js";
75
75
 
76
76
  // src/signals.ts
77
77
  process.once("SIGINT", async (arg) => {
@@ -1927,7 +1927,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1927
1927
  );
1928
1928
  if (snapshot.event?.name === TOMBSTONE_EVENT)
1929
1929
  throw new StreamClosedError(stream);
1930
- const expected = expectedVersion ?? (snapshot.version >= 0 ? snapshot.version : void 0);
1930
+ const expected = expectedVersion ?? snapshot.version;
1931
1931
  for (const { valid, description } of me.given?.[action2] ?? [])
1932
1932
  if (!valid(snapshot.state, actor))
1933
1933
  throw new InvariantError(
@@ -1999,14 +1999,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1999
1999
  );
2000
2000
  let committed;
2001
2001
  try {
2002
- committed = await store().commit(
2003
- stream,
2004
- emitted,
2005
- meta,
2006
- // Reactions skip the inferred version guard (leases already
2007
- // serialize them); an explicit expectedVersion is still honored.
2008
- reactingTo ? expectedVersion : expected
2009
- );
2002
+ committed = await store().commit(stream, emitted, meta, expected);
2010
2003
  } catch (error) {
2011
2004
  if (error instanceof ConcurrencyError) void cache_drop(stream);
2012
2005
  throw error;
@@ -2023,21 +2016,16 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
2023
2016
  replayed: snapshot.replayed
2024
2017
  }));
2025
2018
  const last = snapshots.at(-1);
2026
- const contiguous = committed[0].version === snapshot.version + 1;
2027
- const snapped = contiguous && me.snap?.(last);
2028
- const snap_event = snapped ? await snap(last) : void 0;
2029
- if (!me.pii_aware) {
2030
- if (contiguous)
2031
- void cache_put(stream, {
2032
- stream,
2033
- state: last.state,
2034
- version: snap_event?.version ?? last.event.version,
2035
- event_id: snap_event?.id ?? last.event.id,
2036
- patches: snap_event ? 0 : last.patches,
2037
- snaps: snap_event ? last.snaps + 1 : last.snaps
2038
- });
2039
- else void cache_drop(stream);
2040
- }
2019
+ const snap_event = me.snap?.(last) ? await snap(last) : void 0;
2020
+ if (!me.pii_aware)
2021
+ void cache_put(stream, {
2022
+ stream,
2023
+ state: last.state,
2024
+ version: snap_event?.version ?? last.event.version,
2025
+ event_id: snap_event?.id ?? last.event.id,
2026
+ patches: snap_event ? 0 : last.patches,
2027
+ snaps: snap_event ? last.snaps + 1 : last.snaps
2028
+ });
2041
2029
  return snapshots;
2042
2030
  } catch (error) {
2043
2031
  if (!(error instanceof ConcurrencyError)) throw error;