@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +34 -2
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +12 -0
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts +31 -1
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts +7 -2
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/index.d.ts +1 -0
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/@types/internal/reactions.d.ts +5 -4
- package/dist/@types/internal/reactions.d.ts.map +1 -1
- package/dist/@types/internal/sensitive.d.ts +147 -0
- package/dist/@types/internal/sensitive.d.ts.map +1 -0
- package/dist/@types/internal/tracing.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +57 -0
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/registry.d.ts +9 -1
- package/dist/@types/types/registry.d.ts.map +1 -1
- package/dist/@types/types/schemas.d.ts +36 -0
- package/dist/@types/types/schemas.d.ts.map +1 -1
- package/dist/{chunk-I4L224TZ.js → chunk-3ZTFNAY7.js} +46 -6
- package/dist/chunk-3ZTFNAY7.js.map +1 -0
- package/dist/chunk-XSBT63QX.js +267 -0
- package/dist/chunk-XSBT63QX.js.map +1 -0
- package/dist/index.cjs +335 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +155 -32
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +106 -60
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +11 -11
- package/dist/test/index.js.map +1 -1
- package/dist/types/index.cjs +52 -34
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +9 -3
- package/package.json +2 -2
- package/dist/chunk-I4L224TZ.js.map +0 -1
- package/dist/chunk-PMAZTOSO.js +0 -164
- package/dist/chunk-PMAZTOSO.js.map +0 -1
package/dist/test/index.cjs
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
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 =
|
|
4139
|
-
stream:
|
|
4144
|
+
var TargetSchema = import_zod2.z.object({
|
|
4145
|
+
stream: import_zod2.z.string(),
|
|
4140
4146
|
actor: ActorSchema,
|
|
4141
|
-
expectedVersion:
|
|
4147
|
+
expectedVersion: import_zod2.z.number().optional()
|
|
4142
4148
|
}).loose().readonly();
|
|
4143
|
-
var CausationEventSchema =
|
|
4144
|
-
id:
|
|
4145
|
-
name:
|
|
4146
|
-
stream:
|
|
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 =
|
|
4149
|
-
correlation:
|
|
4150
|
-
causation:
|
|
4151
|
-
action: TargetSchema.and(
|
|
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 =
|
|
4156
|
-
id:
|
|
4157
|
-
stream:
|
|
4158
|
-
version:
|
|
4159
|
-
created:
|
|
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 =
|
|
4163
|
-
stream:
|
|
4164
|
-
names:
|
|
4165
|
-
before:
|
|
4166
|
-
after:
|
|
4167
|
-
limit:
|
|
4168
|
-
created_before:
|
|
4169
|
-
created_after:
|
|
4170
|
-
backward:
|
|
4171
|
-
correlation:
|
|
4172
|
-
with_snaps:
|
|
4173
|
-
stream_exact:
|
|
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
|
|
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
|
|
4199
|
-
throw new ValidationError(target, payload, (0,
|
|
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 =
|
|
4214
|
-
name:
|
|
4215
|
-
version:
|
|
4216
|
-
description:
|
|
4217
|
-
author:
|
|
4218
|
-
license:
|
|
4219
|
-
dependencies:
|
|
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:
|
|
4238
|
-
logLevel:
|
|
4239
|
-
logSingleLine:
|
|
4240
|
-
sleepMs:
|
|
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(
|
|
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(
|
|
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;
|