@rotorsoft/act 1.8.0 → 1.10.0

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.
Files changed (42) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/@types/act.d.ts +34 -2
  3. package/dist/@types/act.d.ts.map +1 -1
  4. package/dist/@types/adapters/in-memory-store.d.ts +12 -0
  5. package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
  6. package/dist/@types/builders/act-builder.d.ts.map +1 -1
  7. package/dist/@types/builders/state-builder.d.ts +31 -1
  8. package/dist/@types/builders/state-builder.d.ts.map +1 -1
  9. package/dist/@types/internal/event-sourcing.d.ts +7 -2
  10. package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
  11. package/dist/@types/internal/index.d.ts +1 -0
  12. package/dist/@types/internal/index.d.ts.map +1 -1
  13. package/dist/@types/internal/reactions.d.ts +5 -4
  14. package/dist/@types/internal/reactions.d.ts.map +1 -1
  15. package/dist/@types/internal/sensitive.d.ts +147 -0
  16. package/dist/@types/internal/sensitive.d.ts.map +1 -0
  17. package/dist/@types/internal/tracing.d.ts.map +1 -1
  18. package/dist/@types/types/action.d.ts +57 -0
  19. package/dist/@types/types/action.d.ts.map +1 -1
  20. package/dist/@types/types/registry.d.ts +9 -1
  21. package/dist/@types/types/registry.d.ts.map +1 -1
  22. package/dist/@types/types/schemas.d.ts +36 -0
  23. package/dist/@types/types/schemas.d.ts.map +1 -1
  24. package/dist/{chunk-I4L224TZ.js → chunk-3ZTFNAY7.js} +46 -6
  25. package/dist/chunk-3ZTFNAY7.js.map +1 -0
  26. package/dist/chunk-XSBT63QX.js +267 -0
  27. package/dist/chunk-XSBT63QX.js.map +1 -0
  28. package/dist/index.cjs +335 -82
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.js +155 -32
  31. package/dist/index.js.map +1 -1
  32. package/dist/test/index.cjs +106 -60
  33. package/dist/test/index.cjs.map +1 -1
  34. package/dist/test/index.js +11 -11
  35. package/dist/test/index.js.map +1 -1
  36. package/dist/types/index.cjs +52 -34
  37. package/dist/types/index.cjs.map +1 -1
  38. package/dist/types/index.js +9 -3
  39. package/package.json +2 -2
  40. package/dist/chunk-I4L224TZ.js.map +0 -1
  41. package/dist/chunk-PMAZTOSO.js +0 -164
  42. package/dist/chunk-PMAZTOSO.js.map +0 -1
@@ -232,7 +232,7 @@ function C({ force: e } = {}) {
232
232
  var d = C();
233
233
  var y = d;
234
234
 
235
- // ../../node_modules/.pnpm/@vitest+pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.js
235
+ // ../../node_modules/.pnpm/@vitest+pretty-format@4.1.8/node_modules/@vitest/pretty-format/dist/index.js
236
236
  function _mergeNamespaces(n, m) {
237
237
  m.forEach(function(e) {
238
238
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -1228,7 +1228,7 @@ var plugins = {
1228
1228
  Error: ErrorPlugin
1229
1229
  };
1230
1230
 
1231
- // ../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/display.js
1231
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.8/node_modules/@vitest/utils/dist/display.js
1232
1232
  var ansiColors = {
1233
1233
  bold: ["1", "22"],
1234
1234
  dim: ["2", "22"],
@@ -1942,7 +1942,7 @@ function objDisplay(obj, options = {}) {
1942
1942
  return str;
1943
1943
  }
1944
1944
 
1945
- // ../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/helpers.js
1945
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.8/node_modules/@vitest/utils/dist/helpers.js
1946
1946
  function assertTypes(value, name, types) {
1947
1947
  const receivedType = typeof value;
1948
1948
  const pass = types.includes(receivedType);
@@ -2037,7 +2037,7 @@ function unique(array) {
2037
2037
  return Array.from(new Set(array));
2038
2038
  }
2039
2039
 
2040
- // ../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/timers.js
2040
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.8/node_modules/@vitest/utils/dist/timers.js
2041
2041
  var SAFE_TIMERS_SYMBOL = /* @__PURE__ */ Symbol("vitest:SAFE_TIMERS");
2042
2042
  function getSafeTimers() {
2043
2043
  const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
@@ -2054,7 +2054,7 @@ function getSafeTimers() {
2054
2054
  };
2055
2055
  }
2056
2056
 
2057
- // ../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
2057
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.8/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
2058
2058
  var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2059
2059
  function normalizeWindowsPath(input = "") {
2060
2060
  if (!input) {
@@ -2151,7 +2151,7 @@ var isAbsolute = function(p) {
2151
2151
  return _IS_ABSOLUTE_RE.test(p);
2152
2152
  };
2153
2153
 
2154
- // ../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/source-map.js
2154
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.8/node_modules/@vitest/utils/dist/source-map.js
2155
2155
  var comma = ",".charCodeAt(0);
2156
2156
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2157
2157
  var intToChar = new Uint8Array(64);
@@ -2278,7 +2278,7 @@ function parseSingleV8Stack(raw) {
2278
2278
  };
2279
2279
  }
2280
2280
 
2281
- // ../../node_modules/.pnpm/@vitest+runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.js
2281
+ // ../../node_modules/.pnpm/@vitest+runner@4.1.8/node_modules/@vitest/runner/dist/chunk-artifact.js
2282
2282
  var PendingError = class extends Error {
2283
2283
  code = "VITEST_PENDING";
2284
2284
  taskId;
@@ -3831,7 +3831,7 @@ function manageArtifactAttachment(attachment) {
3831
3831
  }
3832
3832
  }
3833
3833
 
3834
- // ../../node_modules/.pnpm/vite@8.0.14_@types+node@25.9.1_esbuild@0.27.2_jiti@2.6.1_terser@5.46.1_tsx@4.22.3_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js
3834
+ // ../../node_modules/.pnpm/vite@8.0.16_@types+node@25.9.1_esbuild@0.27.2_jiti@2.6.1_terser@5.46.1_tsx@4.22.4_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js
3835
3835
  var SOURCEMAPPING_URL = "sourceMa";
3836
3836
  SOURCEMAPPING_URL += "ppingURL";
3837
3837
  var isWindows = typeof process < "u" && process.platform === "win32";
@@ -3877,7 +3877,7 @@ var envProxy = new Proxy({}, { get(_, p) {
3877
3877
  throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
3878
3878
  } });
3879
3879
 
3880
- // ../../node_modules/.pnpm/vitest@4.1.7_@types+node@25.9.1_@vitest+coverage-v8@4.1.7_vite@8.0.14_@types+node@25.9._80d5839fc632fdcd9de039dffc6761e7/node_modules/vitest/dist/index.js
3880
+ // ../../node_modules/.pnpm/vitest@4.1.8_@types+node@25.9.1_@vitest+coverage-v8@4.1.8_vite@8.0.16_@types+node@25.9._87965f5280639f5a2754f2fd84ad1804/node_modules/vitest/dist/index.js
3881
3881
  var import_expect_type = __toESM(require_dist(), 1);
3882
3882
 
3883
3883
  // src/internal/lru-map.ts
@@ -4080,7 +4080,7 @@ var ConsoleLogger = class _ConsoleLogger {
4080
4080
 
4081
4081
  // src/config.ts
4082
4082
  var fs = __toESM(require("fs"), 1);
4083
- var import_zod3 = require("zod");
4083
+ var import_zod4 = require("zod");
4084
4084
 
4085
4085
  // src/types/errors.ts
4086
4086
  var Errors = {
@@ -4129,48 +4129,54 @@ var ConcurrencyError = class extends Error {
4129
4129
  };
4130
4130
 
4131
4131
  // src/types/schemas.ts
4132
+ var import_zod2 = require("zod");
4133
+
4134
+ // src/internal/sensitive.ts
4132
4135
  var import_zod = require("zod");
4133
- var ZodEmpty = import_zod.z.record(import_zod.z.string(), import_zod.z.never());
4134
- var ActorSchema = import_zod.z.object({
4135
- id: import_zod.z.string(),
4136
- name: import_zod.z.string()
4136
+ var _registry = import_zod.z.registry();
4137
+
4138
+ // src/types/schemas.ts
4139
+ var ZodEmpty = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.never());
4140
+ var ActorSchema = import_zod2.z.object({
4141
+ id: import_zod2.z.string(),
4142
+ name: import_zod2.z.string()
4137
4143
  }).loose().readonly();
4138
- var TargetSchema = import_zod.z.object({
4139
- stream: import_zod.z.string(),
4144
+ var TargetSchema = import_zod2.z.object({
4145
+ stream: import_zod2.z.string(),
4140
4146
  actor: ActorSchema,
4141
- expectedVersion: import_zod.z.number().optional()
4147
+ expectedVersion: import_zod2.z.number().optional()
4142
4148
  }).loose().readonly();
4143
- var CausationEventSchema = import_zod.z.object({
4144
- id: import_zod.z.number(),
4145
- name: import_zod.z.string(),
4146
- stream: import_zod.z.string()
4149
+ var CausationEventSchema = import_zod2.z.object({
4150
+ id: import_zod2.z.number(),
4151
+ name: import_zod2.z.string(),
4152
+ stream: import_zod2.z.string()
4147
4153
  });
4148
- var EventMetaSchema = import_zod.z.object({
4149
- correlation: import_zod.z.string(),
4150
- causation: import_zod.z.object({
4151
- action: TargetSchema.and(import_zod.z.object({ name: import_zod.z.string() })).optional(),
4154
+ var EventMetaSchema = import_zod2.z.object({
4155
+ correlation: import_zod2.z.string(),
4156
+ causation: import_zod2.z.object({
4157
+ action: TargetSchema.and(import_zod2.z.object({ name: import_zod2.z.string() })).optional(),
4152
4158
  event: CausationEventSchema.optional()
4153
4159
  })
4154
4160
  }).readonly();
4155
- var CommittedMetaSchema = import_zod.z.object({
4156
- id: import_zod.z.number(),
4157
- stream: import_zod.z.string(),
4158
- version: import_zod.z.number(),
4159
- created: import_zod.z.date(),
4161
+ var CommittedMetaSchema = import_zod2.z.object({
4162
+ id: import_zod2.z.number(),
4163
+ stream: import_zod2.z.string(),
4164
+ version: import_zod2.z.number(),
4165
+ created: import_zod2.z.date(),
4160
4166
  meta: EventMetaSchema
4161
4167
  }).readonly();
4162
- var QuerySchema = import_zod.z.object({
4163
- stream: import_zod.z.string().optional(),
4164
- names: import_zod.z.string().array().optional(),
4165
- before: import_zod.z.number().optional(),
4166
- after: import_zod.z.number().optional(),
4167
- limit: import_zod.z.number().optional(),
4168
- created_before: import_zod.z.date().optional(),
4169
- created_after: import_zod.z.date().optional(),
4170
- backward: import_zod.z.boolean().optional(),
4171
- correlation: import_zod.z.string().optional(),
4172
- with_snaps: import_zod.z.boolean().optional(),
4173
- stream_exact: import_zod.z.boolean().optional()
4168
+ var QuerySchema = import_zod2.z.object({
4169
+ stream: import_zod2.z.string().optional(),
4170
+ names: import_zod2.z.string().array().optional(),
4171
+ before: import_zod2.z.number().optional(),
4172
+ after: import_zod2.z.number().optional(),
4173
+ limit: import_zod2.z.number().optional(),
4174
+ created_before: import_zod2.z.date().optional(),
4175
+ created_after: import_zod2.z.date().optional(),
4176
+ backward: import_zod2.z.boolean().optional(),
4177
+ correlation: import_zod2.z.string().optional(),
4178
+ with_snaps: import_zod2.z.boolean().optional(),
4179
+ stream_exact: import_zod2.z.boolean().optional()
4174
4180
  }).readonly();
4175
4181
 
4176
4182
  // src/types/index.ts
@@ -4190,13 +4196,13 @@ var LogLevels = [
4190
4196
  ];
4191
4197
 
4192
4198
  // src/utils.ts
4193
- var import_zod2 = require("zod");
4199
+ var import_zod3 = require("zod");
4194
4200
  var validate = (target, payload, schema) => {
4195
4201
  try {
4196
4202
  return schema ? schema.parse(payload) : payload;
4197
4203
  } catch (error) {
4198
- if (error instanceof import_zod2.ZodError) {
4199
- throw new ValidationError(target, payload, (0, import_zod2.prettifyError)(error));
4204
+ if (error instanceof import_zod3.ZodError) {
4205
+ throw new ValidationError(target, payload, (0, import_zod3.prettifyError)(error));
4200
4206
  }
4201
4207
  throw new ValidationError(target, payload, error);
4202
4208
  }
@@ -4210,13 +4216,13 @@ async function sleep(ms) {
4210
4216
  }
4211
4217
 
4212
4218
  // src/config.ts
4213
- var PackageSchema = import_zod3.z.object({
4214
- name: import_zod3.z.string().min(1),
4215
- version: import_zod3.z.string().min(1),
4216
- description: import_zod3.z.string().min(1).optional(),
4217
- author: import_zod3.z.object({ name: import_zod3.z.string().min(1), email: import_zod3.z.string().optional() }).optional().or(import_zod3.z.string().min(1)).optional(),
4218
- license: import_zod3.z.string().min(1).optional(),
4219
- dependencies: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).optional()
4219
+ var PackageSchema = import_zod4.z.object({
4220
+ name: import_zod4.z.string().min(1),
4221
+ version: import_zod4.z.string().min(1),
4222
+ description: import_zod4.z.string().min(1).optional(),
4223
+ author: import_zod4.z.object({ name: import_zod4.z.string().min(1), email: import_zod4.z.string().optional() }).optional().or(import_zod4.z.string().min(1)).optional(),
4224
+ license: import_zod4.z.string().min(1).optional(),
4225
+ dependencies: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.string()).optional()
4220
4226
  });
4221
4227
  var FALLBACK_PACKAGE = {
4222
4228
  name: "act-fallback",
@@ -4234,10 +4240,10 @@ var getPackage = () => {
4234
4240
  };
4235
4241
  var pkgLoadError;
4236
4242
  var BaseSchema = PackageSchema.extend({
4237
- env: import_zod3.z.enum(Environments),
4238
- logLevel: import_zod3.z.enum(LogLevels),
4239
- logSingleLine: import_zod3.z.boolean(),
4240
- sleepMs: import_zod3.z.number().int().min(0).max(5e3)
4243
+ env: import_zod4.z.enum(Environments),
4244
+ logLevel: import_zod4.z.enum(LogLevels),
4245
+ logSingleLine: import_zod4.z.boolean(),
4246
+ sleepMs: import_zod4.z.number().int().min(0).max(5e3)
4241
4247
  });
4242
4248
  var { NODE_ENV, LOG_LEVEL, LOG_SINGLE_LINE, SLEEP_MS } = process.env;
4243
4249
  var env = NODE_ENV || "development";
@@ -4460,11 +4466,24 @@ var InMemoryStore = class {
4460
4466
  _maxEventIdByStream = /* @__PURE__ */ new Map();
4461
4467
  // global max non-snapshot event id — fast pre-check for source-less streams in claim()
4462
4468
  _maxNonSnapEventId = -1;
4469
+ // stream → (event_id → cloned sensitive payload). Two-level so `forget_pii`
4470
+ // is O(1) — drop the inner Map for the stream and the wipe is done — mirroring
4471
+ // the `DELETE WHERE stream = ?` scope that durable adapters get from their
4472
+ // stream index. Entries exist only for events committed with a non-null
4473
+ // `pii` field; absence means "no PII" (returned as `null` on load).
4474
+ _pii = /* @__PURE__ */ new Map();
4463
4475
  _resetIndexes() {
4464
4476
  this._events.length = 0;
4465
4477
  this._streamVersions.clear();
4466
4478
  this._maxEventIdByStream.clear();
4467
4479
  this._maxNonSnapEventId = -1;
4480
+ this._pii.clear();
4481
+ }
4482
+ // Attach the isolated PII payload (or null) to an event before handing it to
4483
+ // a caller. Allocation-free for events without PII — by far the common case.
4484
+ _withPii(e) {
4485
+ const pii = this._pii.get(e.stream)?.get(e.id);
4486
+ return pii ? { ...e, pii } : e;
4468
4487
  }
4469
4488
  /**
4470
4489
  * Dispose of the store and clear all events.
@@ -4520,7 +4539,9 @@ var InMemoryStore = class {
4520
4539
  continue;
4521
4540
  if (query.after && e.id <= query.after) break;
4522
4541
  if (query.created_after && e.created <= query.created_after) break;
4523
- await Promise.resolve(callback(e));
4542
+ await Promise.resolve(
4543
+ callback(this._withPii(e))
4544
+ );
4524
4545
  count++;
4525
4546
  if (query?.limit && count >= query.limit) break;
4526
4547
  }
@@ -4532,7 +4553,9 @@ var InMemoryStore = class {
4532
4553
  if (query?.created_after && e.created <= query.created_after) continue;
4533
4554
  if (query?.before && e.id >= query.before) break;
4534
4555
  if (query?.created_before && e.created >= query.created_before) break;
4535
- await Promise.resolve(callback(e));
4556
+ await Promise.resolve(
4557
+ callback(this._withPii(e))
4558
+ );
4536
4559
  count++;
4537
4560
  if (query?.limit && count >= query.limit) break;
4538
4561
  }
@@ -4561,7 +4584,7 @@ var InMemoryStore = class {
4561
4584
  }
4562
4585
  let version = currentVersion + 1;
4563
4586
  let lastNonSnapId = -1;
4564
- const committed = msgs.map(({ name, data }) => {
4587
+ const committed = msgs.map(({ name, data, pii }) => {
4565
4588
  const c = {
4566
4589
  id: this._events.length,
4567
4590
  stream,
@@ -4572,9 +4595,17 @@ var InMemoryStore = class {
4572
4595
  meta
4573
4596
  };
4574
4597
  this._events.push(c);
4598
+ if (pii != null) {
4599
+ let perStream = this._pii.get(stream);
4600
+ if (!perStream) {
4601
+ perStream = /* @__PURE__ */ new Map();
4602
+ this._pii.set(stream, perStream);
4603
+ }
4604
+ perStream.set(c.id, structuredClone(pii));
4605
+ }
4575
4606
  if (name !== SNAP_EVENT) lastNonSnapId = c.id;
4576
4607
  version++;
4577
- return c;
4608
+ return this._withPii(c);
4578
4609
  });
4579
4610
  this._streamVersions.set(stream, version - 1);
4580
4611
  if (lastNonSnapId >= 0) {
@@ -4755,6 +4786,21 @@ var InMemoryStore = class {
4755
4786
  * @param input - Stream names or a filter selecting the streams to unblock.
4756
4787
  * @returns Count of streams that were actually flipped (were blocked).
4757
4788
  */
4789
+ /**
4790
+ * Wipe the sensitive-data payload for every event on the stream — see
4791
+ * {@link Store.forget_pii}. O(1) drop of the stream's inner Map; the size of
4792
+ * that Map is the count of events that had PII. Idempotent: a second call
4793
+ * finds no inner Map and returns `0`.
4794
+ *
4795
+ * @param stream - Target stream.
4796
+ * @returns Count of events whose isolated PII payload was deleted.
4797
+ */
4798
+ async forget_pii(stream) {
4799
+ await sleep();
4800
+ const count = this._pii.get(stream)?.size ?? 0;
4801
+ this._pii.delete(stream);
4802
+ return count;
4803
+ }
4758
4804
  async unblock(input) {
4759
4805
  await sleep();
4760
4806
  let count = 0;