@rotorsoft/act 1.9.0 → 1.10.1
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 +46 -14
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/console-logger.d.ts +2 -2
- package/dist/@types/adapters/console-logger.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +6 -6
- 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 +33 -3
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/internal/audit.d.ts +4 -4
- package/dist/@types/internal/audit.d.ts.map +1 -1
- package/dist/@types/internal/backoff.d.ts +1 -1
- package/dist/@types/internal/backoff.d.ts.map +1 -1
- package/dist/@types/internal/build-classify.d.ts +11 -11
- package/dist/@types/internal/build-classify.d.ts.map +1 -1
- package/dist/@types/internal/close-cycle.d.ts +3 -3
- package/dist/@types/internal/close-cycle.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +4 -4
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/correlator.d.ts +2 -2
- package/dist/@types/internal/correlator.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts +20 -20
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-ratio.d.ts +1 -1
- package/dist/@types/internal/drain-ratio.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts +9 -4
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/event-versions.d.ts +2 -2
- package/dist/@types/internal/event-versions.d.ts.map +1 -1
- package/dist/@types/internal/index.d.ts +8 -7
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/@types/internal/merge.d.ts +3 -3
- package/dist/@types/internal/merge.d.ts.map +1 -1
- package/dist/@types/internal/reactions.d.ts +11 -10
- 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/settle.d.ts +3 -3
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/@types/internal/tracing.d.ts +5 -5
- 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-F4S2JOPN.js → chunk-3Z2HU726.js} +134 -133
- package/dist/chunk-3Z2HU726.js.map +1 -0
- package/dist/chunk-BY5JPOZR.js +267 -0
- package/dist/chunk-BY5JPOZR.js.map +1 -0
- package/dist/index.cjs +835 -616
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +567 -439
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +194 -187
- 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 +3 -3
- package/dist/chunk-F4S2JOPN.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
|
|
@@ -3998,7 +3998,7 @@ var ConsoleLogger = class _ConsoleLogger {
|
|
|
3998
3998
|
this._pretty = pretty;
|
|
3999
3999
|
this.level = level;
|
|
4000
4000
|
const threshold = LEVEL_VALUES[level] ?? 30;
|
|
4001
|
-
const write = pretty ? this.
|
|
4001
|
+
const write = pretty ? this._pretty_write.bind(this, bindings) : this._json_write.bind(this, bindings);
|
|
4002
4002
|
this.fatal = write.bind(this, "fatal", 60);
|
|
4003
4003
|
this.error = threshold <= 50 ? write.bind(this, "error", 50) : noop;
|
|
4004
4004
|
this.warn = threshold <= 40 ? write.bind(this, "warn", 40) : noop;
|
|
@@ -4017,24 +4017,24 @@ var ConsoleLogger = class _ConsoleLogger {
|
|
|
4017
4017
|
bindings
|
|
4018
4018
|
});
|
|
4019
4019
|
}
|
|
4020
|
-
|
|
4020
|
+
_json_write(bindings, level, _num, obj_or_msg, msg) {
|
|
4021
4021
|
let obj;
|
|
4022
4022
|
let message;
|
|
4023
|
-
if (typeof
|
|
4024
|
-
message =
|
|
4023
|
+
if (typeof obj_or_msg === "string") {
|
|
4024
|
+
message = obj_or_msg;
|
|
4025
4025
|
obj = {};
|
|
4026
|
-
} else if (
|
|
4027
|
-
message = msg ??
|
|
4026
|
+
} else if (obj_or_msg instanceof Error) {
|
|
4027
|
+
message = msg ?? obj_or_msg.message;
|
|
4028
4028
|
obj = {
|
|
4029
|
-
error: { message:
|
|
4030
|
-
stack:
|
|
4029
|
+
error: { message: obj_or_msg.message, name: obj_or_msg.name },
|
|
4030
|
+
stack: obj_or_msg.stack
|
|
4031
4031
|
};
|
|
4032
|
-
} else if (
|
|
4032
|
+
} else if (obj_or_msg !== null && typeof obj_or_msg === "object") {
|
|
4033
4033
|
message = msg;
|
|
4034
|
-
obj = { ...
|
|
4034
|
+
obj = { ...obj_or_msg };
|
|
4035
4035
|
} else {
|
|
4036
4036
|
message = msg;
|
|
4037
|
-
obj = { value:
|
|
4037
|
+
obj = { value: obj_or_msg };
|
|
4038
4038
|
}
|
|
4039
4039
|
const entry = Object.assign({ level, time: Date.now() }, bindings, obj);
|
|
4040
4040
|
if (message) entry.msg = message;
|
|
@@ -4051,36 +4051,36 @@ var ConsoleLogger = class _ConsoleLogger {
|
|
|
4051
4051
|
}
|
|
4052
4052
|
process.stdout.write(line + "\n");
|
|
4053
4053
|
}
|
|
4054
|
-
|
|
4054
|
+
_pretty_write(bindings, level, _num, obj_or_msg, msg) {
|
|
4055
4055
|
const color = LEVEL_COLORS[level];
|
|
4056
4056
|
const tag = `${color}${level.toUpperCase().padEnd(5)}${RESET}`;
|
|
4057
4057
|
const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
4058
4058
|
let message;
|
|
4059
4059
|
let data;
|
|
4060
|
-
if (typeof
|
|
4061
|
-
message =
|
|
4062
|
-
} else if (
|
|
4063
|
-
message = msg ??
|
|
4064
|
-
data =
|
|
4060
|
+
if (typeof obj_or_msg === "string") {
|
|
4061
|
+
message = obj_or_msg;
|
|
4062
|
+
} else if (obj_or_msg instanceof Error) {
|
|
4063
|
+
message = msg ?? obj_or_msg.message;
|
|
4064
|
+
data = obj_or_msg.stack;
|
|
4065
4065
|
} else {
|
|
4066
4066
|
message = msg ?? "";
|
|
4067
|
-
if (
|
|
4067
|
+
if (obj_or_msg !== void 0 && obj_or_msg !== null) {
|
|
4068
4068
|
try {
|
|
4069
|
-
data = JSON.stringify(
|
|
4069
|
+
data = JSON.stringify(obj_or_msg);
|
|
4070
4070
|
} catch {
|
|
4071
4071
|
data = "[unserializable]";
|
|
4072
4072
|
}
|
|
4073
4073
|
}
|
|
4074
4074
|
}
|
|
4075
|
-
const
|
|
4076
|
-
const parts = [ts, tag, message, data,
|
|
4075
|
+
const bind_str = bindings && Object.keys(bindings).length ? ` ${JSON.stringify(bindings)}` : "";
|
|
4076
|
+
const parts = [ts, tag, message, data, bind_str].filter(Boolean);
|
|
4077
4077
|
process.stdout.write(parts.join(" ") + "\n");
|
|
4078
4078
|
}
|
|
4079
4079
|
};
|
|
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,41 +4216,41 @@ 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",
|
|
4223
4229
|
version: "0.0.0-fallback",
|
|
4224
4230
|
description: "Synthetic fallback \u2014 package.json could not be loaded"
|
|
4225
4231
|
};
|
|
4226
|
-
var
|
|
4232
|
+
var get_package = () => {
|
|
4227
4233
|
try {
|
|
4228
4234
|
const raw = fs.readFileSync("package.json");
|
|
4229
4235
|
return JSON.parse(raw.toString());
|
|
4230
4236
|
} catch (err) {
|
|
4231
|
-
|
|
4237
|
+
pkg_load_error = err;
|
|
4232
4238
|
return FALLBACK_PACKAGE;
|
|
4233
4239
|
}
|
|
4234
4240
|
};
|
|
4235
|
-
var
|
|
4241
|
+
var pkg_load_error;
|
|
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";
|
|
4244
4250
|
var logLevel = LOG_LEVEL || (NODE_ENV === "test" ? "fatal" : NODE_ENV === "production" ? "info" : "trace");
|
|
4245
4251
|
var logSingleLine = (LOG_SINGLE_LINE || "true") === "true";
|
|
4246
4252
|
var sleepMs = parseInt(NODE_ENV === "test" ? "0" : SLEEP_MS ?? "100", 10);
|
|
4247
|
-
var pkg =
|
|
4253
|
+
var pkg = get_package();
|
|
4248
4254
|
var _validated;
|
|
4249
4255
|
var config = () => {
|
|
4250
4256
|
if (!_validated) {
|
|
@@ -4252,12 +4258,12 @@ var config = () => {
|
|
|
4252
4258
|
{ ...pkg, env, logLevel, logSingleLine, sleepMs },
|
|
4253
4259
|
BaseSchema
|
|
4254
4260
|
);
|
|
4255
|
-
if (
|
|
4256
|
-
const msg =
|
|
4261
|
+
if (pkg_load_error) {
|
|
4262
|
+
const msg = pkg_load_error instanceof Error ? pkg_load_error.message : typeof pkg_load_error === "string" ? pkg_load_error : "unknown error";
|
|
4257
4263
|
log().warn(
|
|
4258
4264
|
`[act] Could not read package.json (${msg}); using synthetic name="${FALLBACK_PACKAGE.name}" version="${FALLBACK_PACKAGE.version}".`
|
|
4259
4265
|
);
|
|
4260
|
-
|
|
4266
|
+
pkg_load_error = void 0;
|
|
4261
4267
|
}
|
|
4262
4268
|
}
|
|
4263
4269
|
return _validated;
|
|
@@ -4325,14 +4331,14 @@ var InMemoryStream = class {
|
|
|
4325
4331
|
* Bump the priority via {@link subscribe}: keeps the maximum across
|
|
4326
4332
|
* reactions so the highest-priority registrant wins.
|
|
4327
4333
|
*/
|
|
4328
|
-
|
|
4334
|
+
bump_priority(priority) {
|
|
4329
4335
|
if (priority > this._priority) this._priority = priority;
|
|
4330
4336
|
}
|
|
4331
4337
|
/**
|
|
4332
4338
|
* Set the priority outright via {@link prioritize}: operator
|
|
4333
4339
|
* runtime override that ignores the build-time `max()` invariant.
|
|
4334
4340
|
*/
|
|
4335
|
-
|
|
4341
|
+
set_priority(priority) {
|
|
4336
4342
|
this._priority = priority;
|
|
4337
4343
|
}
|
|
4338
4344
|
get is_available() {
|
|
@@ -4454,28 +4460,28 @@ var InMemoryStore = class {
|
|
|
4454
4460
|
// stored stream positions and other metadata
|
|
4455
4461
|
_streams = /* @__PURE__ */ new Map();
|
|
4456
4462
|
// last committed version per stream — O(1) replacement for filter-on-commit
|
|
4457
|
-
|
|
4463
|
+
_stream_versions = /* @__PURE__ */ new Map();
|
|
4458
4464
|
// max non-snapshot event id per stream — drives the source-pattern probe in claim()
|
|
4459
4465
|
// without scanning the full event log.
|
|
4460
|
-
|
|
4466
|
+
_max_event_id_by_stream = /* @__PURE__ */ new Map();
|
|
4461
4467
|
// global max non-snapshot event id — fast pre-check for source-less streams in claim()
|
|
4462
|
-
|
|
4468
|
+
_max_non_snap_event_id = -1;
|
|
4463
4469
|
// stream → (event_id → cloned sensitive payload). Two-level so `forget_pii`
|
|
4464
4470
|
// is O(1) — drop the inner Map for the stream and the wipe is done — mirroring
|
|
4465
4471
|
// the `DELETE WHERE stream = ?` scope that durable adapters get from their
|
|
4466
4472
|
// stream index. Entries exist only for events committed with a non-null
|
|
4467
4473
|
// `pii` field; absence means "no PII" (returned as `null` on load).
|
|
4468
4474
|
_pii = /* @__PURE__ */ new Map();
|
|
4469
|
-
|
|
4475
|
+
_reset_indexes() {
|
|
4470
4476
|
this._events.length = 0;
|
|
4471
|
-
this.
|
|
4472
|
-
this.
|
|
4473
|
-
this.
|
|
4477
|
+
this._stream_versions.clear();
|
|
4478
|
+
this._max_event_id_by_stream.clear();
|
|
4479
|
+
this._max_non_snap_event_id = -1;
|
|
4474
4480
|
this._pii.clear();
|
|
4475
4481
|
}
|
|
4476
4482
|
// Attach the isolated PII payload (or null) to an event before handing it to
|
|
4477
4483
|
// a caller. Allocation-free for events without PII — by far the common case.
|
|
4478
|
-
|
|
4484
|
+
_with_pii(e) {
|
|
4479
4485
|
const pii = this._pii.get(e.stream)?.get(e.id);
|
|
4480
4486
|
return pii ? { ...e, pii } : e;
|
|
4481
4487
|
}
|
|
@@ -4485,7 +4491,7 @@ var InMemoryStore = class {
|
|
|
4485
4491
|
*/
|
|
4486
4492
|
async dispose() {
|
|
4487
4493
|
await sleep();
|
|
4488
|
-
this.
|
|
4494
|
+
this._reset_indexes();
|
|
4489
4495
|
}
|
|
4490
4496
|
/**
|
|
4491
4497
|
* Seed the store with initial data (no-op for in-memory).
|
|
@@ -4500,7 +4506,7 @@ var InMemoryStore = class {
|
|
|
4500
4506
|
*/
|
|
4501
4507
|
async drop() {
|
|
4502
4508
|
await sleep();
|
|
4503
|
-
this.
|
|
4509
|
+
this._reset_indexes();
|
|
4504
4510
|
this._streams = /* @__PURE__ */ new Map();
|
|
4505
4511
|
}
|
|
4506
4512
|
in_query(query, e) {
|
|
@@ -4534,7 +4540,7 @@ var InMemoryStore = class {
|
|
|
4534
4540
|
if (query.after && e.id <= query.after) break;
|
|
4535
4541
|
if (query.created_after && e.created <= query.created_after) break;
|
|
4536
4542
|
await Promise.resolve(
|
|
4537
|
-
callback(this.
|
|
4543
|
+
callback(this._with_pii(e))
|
|
4538
4544
|
);
|
|
4539
4545
|
count++;
|
|
4540
4546
|
if (query?.limit && count >= query.limit) break;
|
|
@@ -4548,7 +4554,7 @@ var InMemoryStore = class {
|
|
|
4548
4554
|
if (query?.before && e.id >= query.before) break;
|
|
4549
4555
|
if (query?.created_before && e.created >= query.created_before) break;
|
|
4550
4556
|
await Promise.resolve(
|
|
4551
|
-
callback(this.
|
|
4557
|
+
callback(this._with_pii(e))
|
|
4552
4558
|
);
|
|
4553
4559
|
count++;
|
|
4554
4560
|
if (query?.limit && count >= query.limit) break;
|
|
@@ -4567,17 +4573,17 @@ var InMemoryStore = class {
|
|
|
4567
4573
|
*/
|
|
4568
4574
|
async commit(stream, msgs, meta, expectedVersion) {
|
|
4569
4575
|
await sleep();
|
|
4570
|
-
const
|
|
4571
|
-
if (typeof expectedVersion === "number" &&
|
|
4576
|
+
const current_version = this._stream_versions.get(stream) ?? -1;
|
|
4577
|
+
if (typeof expectedVersion === "number" && current_version !== expectedVersion) {
|
|
4572
4578
|
throw new ConcurrencyError(
|
|
4573
4579
|
stream,
|
|
4574
|
-
|
|
4580
|
+
current_version,
|
|
4575
4581
|
msgs,
|
|
4576
4582
|
expectedVersion
|
|
4577
4583
|
);
|
|
4578
4584
|
}
|
|
4579
|
-
let version =
|
|
4580
|
-
let
|
|
4585
|
+
let version = current_version + 1;
|
|
4586
|
+
let last_non_snap_id = -1;
|
|
4581
4587
|
const committed = msgs.map(({ name, data, pii }) => {
|
|
4582
4588
|
const c = {
|
|
4583
4589
|
id: this._events.length,
|
|
@@ -4590,21 +4596,21 @@ var InMemoryStore = class {
|
|
|
4590
4596
|
};
|
|
4591
4597
|
this._events.push(c);
|
|
4592
4598
|
if (pii != null) {
|
|
4593
|
-
let
|
|
4594
|
-
if (!
|
|
4595
|
-
|
|
4596
|
-
this._pii.set(stream,
|
|
4599
|
+
let per_stream = this._pii.get(stream);
|
|
4600
|
+
if (!per_stream) {
|
|
4601
|
+
per_stream = /* @__PURE__ */ new Map();
|
|
4602
|
+
this._pii.set(stream, per_stream);
|
|
4597
4603
|
}
|
|
4598
|
-
|
|
4604
|
+
per_stream.set(c.id, structuredClone(pii));
|
|
4599
4605
|
}
|
|
4600
|
-
if (name !== SNAP_EVENT)
|
|
4606
|
+
if (name !== SNAP_EVENT) last_non_snap_id = c.id;
|
|
4601
4607
|
version++;
|
|
4602
|
-
return this.
|
|
4608
|
+
return this._with_pii(c);
|
|
4603
4609
|
});
|
|
4604
|
-
this.
|
|
4605
|
-
if (
|
|
4606
|
-
this.
|
|
4607
|
-
this.
|
|
4610
|
+
this._stream_versions.set(stream, version - 1);
|
|
4611
|
+
if (last_non_snap_id >= 0) {
|
|
4612
|
+
this._max_event_id_by_stream.set(stream, last_non_snap_id);
|
|
4613
|
+
this._max_non_snap_event_id = last_non_snap_id;
|
|
4608
4614
|
}
|
|
4609
4615
|
return committed;
|
|
4610
4616
|
}
|
|
@@ -4619,26 +4625,26 @@ var InMemoryStore = class {
|
|
|
4619
4625
|
*/
|
|
4620
4626
|
async claim(lagging, leading, by, millis, lane) {
|
|
4621
4627
|
await sleep();
|
|
4622
|
-
const
|
|
4623
|
-
const
|
|
4624
|
-
let re =
|
|
4628
|
+
const source_regex = /* @__PURE__ */ new Map();
|
|
4629
|
+
const get_regex = (source) => {
|
|
4630
|
+
let re = source_regex.get(source);
|
|
4625
4631
|
if (!re) {
|
|
4626
4632
|
re = new RegExp(source);
|
|
4627
|
-
|
|
4633
|
+
source_regex.set(source, re);
|
|
4628
4634
|
}
|
|
4629
4635
|
return re;
|
|
4630
4636
|
};
|
|
4631
|
-
const
|
|
4637
|
+
const has_work = (s) => {
|
|
4632
4638
|
if (s.at < 0) return true;
|
|
4633
|
-
if (!s.source) return s.at < this.
|
|
4634
|
-
const re =
|
|
4635
|
-
for (const [
|
|
4636
|
-
if (maxId > s.at && re.test(
|
|
4639
|
+
if (!s.source) return s.at < this._max_non_snap_event_id;
|
|
4640
|
+
const re = get_regex(s.source);
|
|
4641
|
+
for (const [stream_name, maxId] of this._max_event_id_by_stream) {
|
|
4642
|
+
if (maxId > s.at && re.test(stream_name)) return true;
|
|
4637
4643
|
}
|
|
4638
4644
|
return false;
|
|
4639
4645
|
};
|
|
4640
4646
|
const available = [...this._streams.values()].filter(
|
|
4641
|
-
(s) => s.is_available &&
|
|
4647
|
+
(s) => s.is_available && has_work(s) && (lane === void 0 || s.lane === lane)
|
|
4642
4648
|
);
|
|
4643
4649
|
const lag = available.sort((a, b2) => b2.priority - a.priority || a.at - b2.at).slice(0, lagging).map((s) => ({
|
|
4644
4650
|
stream: s.stream,
|
|
@@ -4682,7 +4688,7 @@ var InMemoryStore = class {
|
|
|
4682
4688
|
} of streams) {
|
|
4683
4689
|
const existing = this._streams.get(stream);
|
|
4684
4690
|
if (existing) {
|
|
4685
|
-
existing.
|
|
4691
|
+
existing.bump_priority(priority);
|
|
4686
4692
|
existing.lane = lane;
|
|
4687
4693
|
} else {
|
|
4688
4694
|
this._streams.set(
|
|
@@ -4720,17 +4726,17 @@ var InMemoryStore = class {
|
|
|
4720
4726
|
* cached in the closure so callers can apply it across the streams
|
|
4721
4727
|
* map without re-compiling per iteration.
|
|
4722
4728
|
*/
|
|
4723
|
-
|
|
4724
|
-
const
|
|
4725
|
-
const
|
|
4729
|
+
_filter_predicate(filter) {
|
|
4730
|
+
const stream_re = filter.stream && !filter.stream_exact ? new RegExp(filter.stream) : void 0;
|
|
4731
|
+
const source_re = filter.source && !filter.source_exact ? new RegExp(filter.source) : void 0;
|
|
4726
4732
|
return (s) => {
|
|
4727
4733
|
if (filter.stream !== void 0) {
|
|
4728
|
-
if (filter.stream_exact ? s.stream !== filter.stream : !
|
|
4734
|
+
if (filter.stream_exact ? s.stream !== filter.stream : !stream_re.test(s.stream))
|
|
4729
4735
|
return false;
|
|
4730
4736
|
}
|
|
4731
4737
|
if (filter.source !== void 0) {
|
|
4732
4738
|
if (s.source === void 0) return false;
|
|
4733
|
-
if (filter.source_exact ? s.source !== filter.source : !
|
|
4739
|
+
if (filter.source_exact ? s.source !== filter.source : !source_re.test(s.source))
|
|
4734
4740
|
return false;
|
|
4735
4741
|
}
|
|
4736
4742
|
if (filter.blocked !== void 0 && s.blocked !== filter.blocked)
|
|
@@ -4759,7 +4765,7 @@ var InMemoryStore = class {
|
|
|
4759
4765
|
}
|
|
4760
4766
|
}
|
|
4761
4767
|
} else {
|
|
4762
|
-
const matches = this.
|
|
4768
|
+
const matches = this._filter_predicate(input);
|
|
4763
4769
|
for (const s of this._streams.values()) {
|
|
4764
4770
|
if (matches(s)) {
|
|
4765
4771
|
s.reset();
|
|
@@ -4804,7 +4810,7 @@ var InMemoryStore = class {
|
|
|
4804
4810
|
if (s?.unblock()) count++;
|
|
4805
4811
|
}
|
|
4806
4812
|
} else {
|
|
4807
|
-
const matches = this.
|
|
4813
|
+
const matches = this._filter_predicate({ ...input, blocked: true });
|
|
4808
4814
|
for (const s of this._streams.values()) {
|
|
4809
4815
|
if (matches(s) && s.unblock()) count++;
|
|
4810
4816
|
}
|
|
@@ -4822,12 +4828,12 @@ var InMemoryStore = class {
|
|
|
4822
4828
|
*/
|
|
4823
4829
|
async prioritize(filter, priority) {
|
|
4824
4830
|
await sleep();
|
|
4825
|
-
const matches = this.
|
|
4831
|
+
const matches = this._filter_predicate(filter);
|
|
4826
4832
|
let count = 0;
|
|
4827
4833
|
for (const s of this._streams.values()) {
|
|
4828
4834
|
if (!matches(s)) continue;
|
|
4829
4835
|
if (s.priority !== priority) {
|
|
4830
|
-
s.
|
|
4836
|
+
s.set_priority(priority);
|
|
4831
4837
|
count++;
|
|
4832
4838
|
}
|
|
4833
4839
|
}
|
|
@@ -4843,8 +4849,8 @@ var InMemoryStore = class {
|
|
|
4843
4849
|
const limit = query?.limit ?? 100;
|
|
4844
4850
|
const after = query?.after;
|
|
4845
4851
|
const blocked = query?.blocked;
|
|
4846
|
-
const
|
|
4847
|
-
const
|
|
4852
|
+
const stream_re = query?.stream && !query.stream_exact ? new RegExp(query.stream) : void 0;
|
|
4853
|
+
const source_re = query?.source && !query.source_exact ? new RegExp(query.source) : void 0;
|
|
4848
4854
|
const sorted = [...this._streams.values()].sort(
|
|
4849
4855
|
(a, b2) => a.stream.localeCompare(b2.stream)
|
|
4850
4856
|
);
|
|
@@ -4852,12 +4858,12 @@ var InMemoryStore = class {
|
|
|
4852
4858
|
for (const s of sorted) {
|
|
4853
4859
|
if (after !== void 0 && s.stream <= after) continue;
|
|
4854
4860
|
if (query?.stream !== void 0) {
|
|
4855
|
-
if (query.stream_exact ? s.stream !== query.stream : !
|
|
4861
|
+
if (query.stream_exact ? s.stream !== query.stream : !stream_re.test(s.stream))
|
|
4856
4862
|
continue;
|
|
4857
4863
|
}
|
|
4858
4864
|
if (query?.source !== void 0) {
|
|
4859
4865
|
if (s.source === void 0) continue;
|
|
4860
|
-
if (query.source_exact ? s.source !== query.source : !
|
|
4866
|
+
if (query.source_exact ? s.source !== query.source : !source_re.test(s.source))
|
|
4861
4867
|
continue;
|
|
4862
4868
|
}
|
|
4863
4869
|
if (blocked !== void 0 && s.blocked !== blocked) continue;
|
|
@@ -4898,44 +4904,44 @@ var InMemoryStore = class {
|
|
|
4898
4904
|
async query_stats(input, options) {
|
|
4899
4905
|
await sleep();
|
|
4900
4906
|
const exclude = new Set(options?.exclude ?? []);
|
|
4901
|
-
const
|
|
4902
|
-
const
|
|
4903
|
-
const
|
|
4907
|
+
const want_tail = options?.tail ?? false;
|
|
4908
|
+
const want_count = options?.count ?? false;
|
|
4909
|
+
const want_names = options?.names ?? false;
|
|
4904
4910
|
const before = options?.before;
|
|
4905
|
-
const
|
|
4911
|
+
const array_targets = Array.isArray(input) ? new Set(input) : null;
|
|
4906
4912
|
const filter = Array.isArray(input) ? null : input;
|
|
4907
|
-
const
|
|
4908
|
-
const
|
|
4909
|
-
const
|
|
4910
|
-
const cached =
|
|
4913
|
+
const stream_re = filter?.stream && !filter.stream_exact ? new RegExp(filter.stream) : void 0;
|
|
4914
|
+
const scope_cache = /* @__PURE__ */ new Map();
|
|
4915
|
+
const in_scope = (stream) => {
|
|
4916
|
+
const cached = scope_cache.get(stream);
|
|
4911
4917
|
if (cached !== void 0) return cached;
|
|
4912
4918
|
let ok = true;
|
|
4913
|
-
if (
|
|
4914
|
-
ok =
|
|
4919
|
+
if (array_targets) {
|
|
4920
|
+
ok = array_targets.has(stream);
|
|
4915
4921
|
} else if (filter?.stream !== void 0) {
|
|
4916
4922
|
ok = filter.stream_exact ? stream === filter.stream : (
|
|
4917
|
-
// biome-ignore lint/style/noNonNullAssertion:
|
|
4918
|
-
|
|
4923
|
+
// biome-ignore lint/style/noNonNullAssertion: stream_re set when stream is regex
|
|
4924
|
+
stream_re.test(stream)
|
|
4919
4925
|
);
|
|
4920
4926
|
}
|
|
4921
|
-
|
|
4927
|
+
scope_cache.set(stream, ok);
|
|
4922
4928
|
return ok;
|
|
4923
4929
|
};
|
|
4924
4930
|
const acc = /* @__PURE__ */ new Map();
|
|
4925
4931
|
for (const e of this._events) {
|
|
4926
4932
|
if (before !== void 0 && e.id >= before) continue;
|
|
4927
|
-
if (!
|
|
4933
|
+
if (!in_scope(e.stream)) continue;
|
|
4928
4934
|
if (exclude.has(e.name)) continue;
|
|
4929
4935
|
let a = acc.get(e.stream);
|
|
4930
4936
|
if (!a) {
|
|
4931
4937
|
a = { head: e, count: 0 };
|
|
4932
|
-
if (
|
|
4933
|
-
if (
|
|
4938
|
+
if (want_tail) a.tail = e;
|
|
4939
|
+
if (want_names) a.names = {};
|
|
4934
4940
|
acc.set(e.stream, a);
|
|
4935
4941
|
}
|
|
4936
4942
|
a.head = e;
|
|
4937
4943
|
a.count++;
|
|
4938
|
-
if (
|
|
4944
|
+
if (want_names) {
|
|
4939
4945
|
const n = String(e.name);
|
|
4940
4946
|
a.names[n] = (a.names[n] ?? 0) + 1;
|
|
4941
4947
|
}
|
|
@@ -4943,9 +4949,9 @@ var InMemoryStore = class {
|
|
|
4943
4949
|
const out = /* @__PURE__ */ new Map();
|
|
4944
4950
|
for (const [stream, a] of acc) {
|
|
4945
4951
|
const stats = { head: a.head };
|
|
4946
|
-
if (
|
|
4947
|
-
if (
|
|
4948
|
-
if (
|
|
4952
|
+
if (want_tail) stats.tail = a.tail;
|
|
4953
|
+
if (want_count) stats.count = a.count;
|
|
4954
|
+
if (want_names) stats.names = a.names;
|
|
4949
4955
|
out.set(stream, stats);
|
|
4950
4956
|
}
|
|
4951
4957
|
return out;
|
|
@@ -4957,18 +4963,18 @@ var InMemoryStore = class {
|
|
|
4957
4963
|
*/
|
|
4958
4964
|
async truncate(targets) {
|
|
4959
4965
|
await sleep();
|
|
4960
|
-
const
|
|
4961
|
-
const
|
|
4966
|
+
const deleted_counts = /* @__PURE__ */ new Map();
|
|
4967
|
+
const stream_set = new Set(targets.map((t) => t.stream));
|
|
4962
4968
|
for (const e of this._events) {
|
|
4963
|
-
if (
|
|
4964
|
-
|
|
4969
|
+
if (stream_set.has(e.stream)) {
|
|
4970
|
+
deleted_counts.set(e.stream, (deleted_counts.get(e.stream) ?? 0) + 1);
|
|
4965
4971
|
}
|
|
4966
4972
|
}
|
|
4967
|
-
this._events = this._events.filter((e) => !
|
|
4968
|
-
for (const stream of
|
|
4973
|
+
this._events = this._events.filter((e) => !stream_set.has(e.stream));
|
|
4974
|
+
for (const stream of stream_set) {
|
|
4969
4975
|
this._streams.delete(stream);
|
|
4970
|
-
this.
|
|
4971
|
-
this.
|
|
4976
|
+
this._stream_versions.delete(stream);
|
|
4977
|
+
this._max_event_id_by_stream.delete(stream);
|
|
4972
4978
|
}
|
|
4973
4979
|
const result = /* @__PURE__ */ new Map();
|
|
4974
4980
|
for (const { stream, snapshot, meta } of targets) {
|
|
@@ -4982,18 +4988,19 @@ var InMemoryStore = class {
|
|
|
4982
4988
|
meta: meta ?? { correlation: "", causation: {} }
|
|
4983
4989
|
};
|
|
4984
4990
|
this._events.push(event);
|
|
4985
|
-
this.
|
|
4991
|
+
this._stream_versions.set(stream, 0);
|
|
4986
4992
|
if (event.name !== SNAP_EVENT) {
|
|
4987
|
-
this.
|
|
4993
|
+
this._max_event_id_by_stream.set(stream, event.id);
|
|
4988
4994
|
}
|
|
4989
4995
|
result.set(stream, {
|
|
4990
|
-
deleted:
|
|
4996
|
+
deleted: deleted_counts.get(stream) ?? 0,
|
|
4991
4997
|
committed: event
|
|
4992
4998
|
});
|
|
4993
4999
|
}
|
|
4994
5000
|
let max = -1;
|
|
4995
|
-
for (const id of this.
|
|
4996
|
-
|
|
5001
|
+
for (const id of this._max_event_id_by_stream.values())
|
|
5002
|
+
if (id > max) max = id;
|
|
5003
|
+
this._max_non_snap_event_id = max;
|
|
4997
5004
|
return result;
|
|
4998
5005
|
}
|
|
4999
5006
|
/**
|
|
@@ -5010,34 +5017,34 @@ var InMemoryStore = class {
|
|
|
5010
5017
|
*/
|
|
5011
5018
|
async restore(driver) {
|
|
5012
5019
|
await sleep();
|
|
5013
|
-
const
|
|
5014
|
-
const
|
|
5015
|
-
const
|
|
5016
|
-
const
|
|
5017
|
-
const
|
|
5020
|
+
const prev_events = this._events;
|
|
5021
|
+
const prev_streams = this._streams;
|
|
5022
|
+
const prev_stream_versions = this._stream_versions;
|
|
5023
|
+
const prev_max_event_id_by_stream = this._max_event_id_by_stream;
|
|
5024
|
+
const prev_max_non_snap_event_id = this._max_non_snap_event_id;
|
|
5018
5025
|
this._events = [];
|
|
5019
5026
|
this._streams = /* @__PURE__ */ new Map();
|
|
5020
|
-
this.
|
|
5021
|
-
this.
|
|
5022
|
-
this.
|
|
5027
|
+
this._stream_versions = /* @__PURE__ */ new Map();
|
|
5028
|
+
this._max_event_id_by_stream = /* @__PURE__ */ new Map();
|
|
5029
|
+
this._max_non_snap_event_id = -1;
|
|
5023
5030
|
try {
|
|
5024
5031
|
await driver(async (event) => {
|
|
5025
5032
|
const id = this._events.length;
|
|
5026
5033
|
const committed = { ...event, id };
|
|
5027
5034
|
this._events.push(committed);
|
|
5028
|
-
this.
|
|
5035
|
+
this._stream_versions.set(event.stream, event.version);
|
|
5029
5036
|
if (event.name !== SNAP_EVENT) {
|
|
5030
|
-
this.
|
|
5031
|
-
this.
|
|
5037
|
+
this._max_event_id_by_stream.set(event.stream, id);
|
|
5038
|
+
this._max_non_snap_event_id = id;
|
|
5032
5039
|
}
|
|
5033
5040
|
return id;
|
|
5034
5041
|
});
|
|
5035
5042
|
} catch (err) {
|
|
5036
|
-
this._events =
|
|
5037
|
-
this._streams =
|
|
5038
|
-
this.
|
|
5039
|
-
this.
|
|
5040
|
-
this.
|
|
5043
|
+
this._events = prev_events;
|
|
5044
|
+
this._streams = prev_streams;
|
|
5045
|
+
this._stream_versions = prev_stream_versions;
|
|
5046
|
+
this._max_event_id_by_stream = prev_max_event_id_by_stream;
|
|
5047
|
+
this._max_non_snap_event_id = prev_max_non_snap_event_id;
|
|
5041
5048
|
throw err;
|
|
5042
5049
|
}
|
|
5043
5050
|
}
|