@rotorsoft/act 2.0.4 → 2.1.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.map +1 -1
- package/dist/@types/adapter.d.ts +85 -0
- package/dist/@types/adapter.d.ts.map +1 -0
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/config.d.ts +3 -9
- package/dist/@types/config.d.ts.map +1 -1
- package/dist/@types/deprecated.d.ts +57 -0
- package/dist/@types/deprecated.d.ts.map +1 -0
- package/dist/@types/index.d.ts +12 -9
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-reaction.d.ts.map +1 -1
- package/dist/@types/internal/close-cycle.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-ops.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +1 -3
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/scoped.d.ts +1 -1
- package/dist/@types/sensitive.d.ts +6 -2
- package/dist/@types/sensitive.d.ts.map +1 -1
- package/dist/@types/types/index.d.ts +1 -1
- package/dist/@types/types/index.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +4 -0
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/schemas.d.ts +1 -1
- package/dist/@types/types/schemas.d.ts.map +1 -1
- package/dist/@types/utils.d.ts +0 -105
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/adapter.cjs +20 -0
- package/dist/adapter.cjs.map +1 -0
- package/dist/adapter.js +20 -0
- package/dist/adapter.js.map +1 -0
- package/dist/{chunk-VD4BLAY4.cjs → chunk-2377SSHX.cjs} +7 -3
- package/dist/chunk-2377SSHX.cjs.map +1 -0
- package/dist/{chunk-ESFICIG2.js → chunk-GWFLHWZV.js} +6 -2
- package/dist/{chunk-ESFICIG2.js.map → chunk-GWFLHWZV.js.map} +1 -1
- package/dist/chunk-HACJYR7Z.cjs +62 -0
- package/dist/chunk-HACJYR7Z.cjs.map +1 -0
- package/dist/{chunk-3JULRYQO.js → chunk-KXC4ILVY.js} +168 -227
- package/dist/chunk-KXC4ILVY.js.map +1 -0
- package/dist/chunk-SRZIVZIA.js +62 -0
- package/dist/chunk-SRZIVZIA.js.map +1 -0
- package/dist/{chunk-XW4EAUS6.cjs → chunk-VOVHDDET.cjs} +195 -254
- package/dist/chunk-VOVHDDET.cjs.map +1 -0
- package/dist/index.cjs +193 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +68 -40
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +5 -4
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +3 -2
- package/dist/test/index.js.map +1 -1
- package/dist/types/index.cjs +6 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +7 -3
- package/package.json +6 -1
- package/dist/chunk-3JULRYQO.js.map +0 -1
- package/dist/chunk-VD4BLAY4.cjs.map +0 -1
- package/dist/chunk-XW4EAUS6.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
var _chunkVOVHDDETcjs = require('./chunk-VOVHDDET.cjs');
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
|
|
@@ -45,10 +46,10 @@
|
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
|
|
49
|
+
var _chunkHACJYR7Zcjs = require('./chunk-HACJYR7Z.cjs');
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
var _chunkXW4EAUS6cjs = require('./chunk-XW4EAUS6.cjs');
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
|
|
@@ -80,25 +81,24 @@ var _chunkXW4EAUS6cjs = require('./chunk-XW4EAUS6.cjs');
|
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
var _chunkVD4BLAY4cjs = require('./chunk-VD4BLAY4.cjs');
|
|
84
|
+
var _chunk2377SSHXcjs = require('./chunk-2377SSHX.cjs');
|
|
85
85
|
|
|
86
86
|
// src/signals.ts
|
|
87
87
|
process.once("SIGINT", async (arg) => {
|
|
88
|
-
|
|
89
|
-
await
|
|
88
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
89
|
+
await _chunkVOVHDDETcjs.disposeAndExit.call(void 0, "EXIT");
|
|
90
90
|
});
|
|
91
91
|
process.once("SIGTERM", async (arg) => {
|
|
92
|
-
|
|
93
|
-
await
|
|
92
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
93
|
+
await _chunkVOVHDDETcjs.disposeAndExit.call(void 0, "EXIT");
|
|
94
94
|
});
|
|
95
95
|
process.once("uncaughtException", async (arg) => {
|
|
96
|
-
|
|
97
|
-
await
|
|
96
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
97
|
+
await _chunkVOVHDDETcjs.disposeAndExit.call(void 0, "ERROR");
|
|
98
98
|
});
|
|
99
99
|
process.once("unhandledRejection", async (arg) => {
|
|
100
|
-
|
|
101
|
-
await
|
|
100
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
101
|
+
await _chunkVOVHDDETcjs.disposeAndExit.call(void 0, "ERROR");
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
// src/act.ts
|
|
@@ -206,7 +206,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
206
206
|
if (need_stats) {
|
|
207
207
|
const stats = await deps.store().query_stats(
|
|
208
208
|
{},
|
|
209
|
-
{ count: true, names: true, exclude: [
|
|
209
|
+
{ count: true, names: true, exclude: [_chunk2377SSHXcjs.SNAP_EVENT] }
|
|
210
210
|
);
|
|
211
211
|
for (const [stream, s] of stats) {
|
|
212
212
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -288,7 +288,7 @@ var make_schema_pass = (deps) => {
|
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
const schema = state2.events[name];
|
|
291
|
-
const sensitive2 =
|
|
291
|
+
const sensitive2 = _chunk2377SSHXcjs.sensitiveFields.call(void 0, schema);
|
|
292
292
|
let parse_schema = schema;
|
|
293
293
|
if (sensitive2.length > 0) {
|
|
294
294
|
const omitter = schema.omit;
|
|
@@ -422,7 +422,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
422
422
|
{
|
|
423
423
|
stream,
|
|
424
424
|
stream_exact: true,
|
|
425
|
-
names: [
|
|
425
|
+
names: [_chunk2377SSHXcjs.SNAP_EVENT],
|
|
426
426
|
with_snaps: true,
|
|
427
427
|
// From the start: on its own, `with_snaps` resumes at the latest.
|
|
428
428
|
after: -1
|
|
@@ -582,7 +582,7 @@ var make_correlation_gaps_pass = () => {
|
|
|
582
582
|
seen_ids.add(e.id);
|
|
583
583
|
const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
|
|
584
584
|
const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
|
|
585
|
-
if (parent_id !== void 0 && e.name !==
|
|
585
|
+
if (parent_id !== void 0 && e.name !== _chunk2377SSHXcjs.TOMBSTONE_EVENT) {
|
|
586
586
|
checks.push({ stream: e.stream, id: e.id, parent_id });
|
|
587
587
|
}
|
|
588
588
|
},
|
|
@@ -965,7 +965,7 @@ function make_deferred(handler, schedule) {
|
|
|
965
965
|
const call = handler;
|
|
966
966
|
const deferred = async (event, stream, app) => {
|
|
967
967
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
968
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
968
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunk2377SSHXcjs.DeferSignal)(when);
|
|
969
969
|
return call(event, stream, app);
|
|
970
970
|
};
|
|
971
971
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -1097,7 +1097,7 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1097
1097
|
function report_once(seen, key, message) {
|
|
1098
1098
|
if (seen.has(key)) return;
|
|
1099
1099
|
seen.add(key);
|
|
1100
|
-
|
|
1100
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).error(new Error(message));
|
|
1101
1101
|
}
|
|
1102
1102
|
|
|
1103
1103
|
// src/internal/correlation-id.ts
|
|
@@ -1125,14 +1125,14 @@ function close_correlation(correlator, actor) {
|
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
1127
1127
|
// src/internal/drain-ops.ts
|
|
1128
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1128
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkVOVHDDETcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1129
1129
|
async function fetch(leased, eventLimit) {
|
|
1130
1130
|
return Promise.all(
|
|
1131
1131
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1132
1132
|
const events = [];
|
|
1133
|
-
const stream_exact = source !== void 0 &&
|
|
1133
|
+
const stream_exact = source !== void 0 && _chunkHACJYR7Zcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1134
1134
|
try {
|
|
1135
|
-
await
|
|
1135
|
+
await _chunkVOVHDDETcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1136
1136
|
stream: source,
|
|
1137
1137
|
stream_exact,
|
|
1138
1138
|
after: at,
|
|
@@ -1152,9 +1152,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1152
1152
|
})
|
|
1153
1153
|
);
|
|
1154
1154
|
}
|
|
1155
|
-
var ack = (leases) =>
|
|
1156
|
-
var block = (leases) =>
|
|
1157
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1155
|
+
var ack = (leases) => _chunkVOVHDDETcjs.store.call(void 0, ).ack(leases);
|
|
1156
|
+
var block = (leases) => _chunkVOVHDDETcjs.store.call(void 0, ).block(leases);
|
|
1157
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkVOVHDDETcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1158
1158
|
|
|
1159
1159
|
// src/internal/event-sourcing.ts
|
|
1160
1160
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1169,29 +1169,29 @@ var check_invariants = (target, state2, schema, pii_aware) => {
|
|
|
1169
1169
|
try {
|
|
1170
1170
|
result = schema.safeParse(state2);
|
|
1171
1171
|
} catch (error) {
|
|
1172
|
-
throw new (0,
|
|
1172
|
+
throw new (0, _chunk2377SSHXcjs.ValidationError)(target, state2, error);
|
|
1173
1173
|
}
|
|
1174
1174
|
if (result.success) return;
|
|
1175
1175
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1176
1176
|
const value = value_at(state2, issue.path);
|
|
1177
|
-
return value !==
|
|
1177
|
+
return value !== _chunk2377SSHXcjs.REDACTED && value !== _chunk2377SSHXcjs.SHREDDED;
|
|
1178
1178
|
}) : result.error.issues;
|
|
1179
1179
|
if (issues.length)
|
|
1180
|
-
throw new (0,
|
|
1180
|
+
throw new (0, _chunk2377SSHXcjs.ValidationError)(
|
|
1181
1181
|
target,
|
|
1182
1182
|
state2,
|
|
1183
1183
|
_zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
|
|
1184
1184
|
);
|
|
1185
1185
|
};
|
|
1186
1186
|
var DEFAULT_BATCH = 500;
|
|
1187
|
-
var cache_put = (stream, entry) =>
|
|
1188
|
-
(err) =>
|
|
1187
|
+
var cache_put = (stream, entry) => _chunkVOVHDDETcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1188
|
+
(err) => _chunkVOVHDDETcjs.log.call(void 0, ).warn(
|
|
1189
1189
|
err,
|
|
1190
1190
|
"cache set skipped; the next load re-folds from the store"
|
|
1191
1191
|
)
|
|
1192
1192
|
);
|
|
1193
|
-
var cache_drop = (stream) =>
|
|
1194
|
-
(err) =>
|
|
1193
|
+
var cache_drop = (stream) => _chunkVOVHDDETcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1194
|
+
(err) => _chunkVOVHDDETcjs.log.call(void 0, ).warn(
|
|
1195
1195
|
err,
|
|
1196
1196
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1197
1197
|
)
|
|
@@ -1199,11 +1199,11 @@ var cache_drop = (stream) => _chunkXW4EAUS6cjs.cache.call(void 0, ).invalidate(s
|
|
|
1199
1199
|
async function snap(snapshot) {
|
|
1200
1200
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1201
1201
|
try {
|
|
1202
|
-
const [committed] = await
|
|
1202
|
+
const [committed] = await _chunkVOVHDDETcjs.store.call(void 0, ).commit(
|
|
1203
1203
|
[
|
|
1204
1204
|
{
|
|
1205
1205
|
stream,
|
|
1206
|
-
msgs: [{ name:
|
|
1206
|
+
msgs: [{ name: _chunk2377SSHXcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1207
1207
|
// IMPORTANT! - state events are committed right after the snapshot event
|
|
1208
1208
|
expectedVersion: version
|
|
1209
1209
|
}
|
|
@@ -1216,18 +1216,18 @@ async function snap(snapshot) {
|
|
|
1216
1216
|
return committed;
|
|
1217
1217
|
} catch (error) {
|
|
1218
1218
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1219
|
-
|
|
1219
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).warn(
|
|
1220
1220
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1221
1221
|
);
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
1224
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1225
1225
|
try {
|
|
1226
|
-
const [committed] = await
|
|
1226
|
+
const [committed] = await _chunkVOVHDDETcjs.store.call(void 0, ).commit(
|
|
1227
1227
|
[
|
|
1228
1228
|
{
|
|
1229
1229
|
stream,
|
|
1230
|
-
msgs: [{ name:
|
|
1230
|
+
msgs: [{ name: _chunk2377SSHXcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1231
1231
|
expectedVersion
|
|
1232
1232
|
}
|
|
1233
1233
|
],
|
|
@@ -1235,7 +1235,7 @@ async function tombstone(stream, expectedVersion, correlation) {
|
|
|
1235
1235
|
);
|
|
1236
1236
|
return committed;
|
|
1237
1237
|
} catch (error) {
|
|
1238
|
-
if (error instanceof
|
|
1238
|
+
if (error instanceof _chunk2377SSHXcjs.ConcurrencyError) return void 0;
|
|
1239
1239
|
throw error;
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
@@ -1265,9 +1265,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1265
1265
|
if (drop_closed_streams) {
|
|
1266
1266
|
await source.query(
|
|
1267
1267
|
(e) => {
|
|
1268
|
-
if (e.name ===
|
|
1268
|
+
if (e.name === _chunk2377SSHXcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1269
1269
|
},
|
|
1270
|
-
{ names: [
|
|
1270
|
+
{ names: [_chunk2377SSHXcjs.TOMBSTONE_EVENT] }
|
|
1271
1271
|
);
|
|
1272
1272
|
}
|
|
1273
1273
|
let max_id;
|
|
@@ -1289,11 +1289,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1289
1289
|
if (!is_valid(event))
|
|
1290
1290
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1291
1291
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1292
|
-
if (drop_snapshots && event.name ===
|
|
1292
|
+
if (drop_snapshots && event.name === _chunk2377SSHXcjs.SNAP_EVENT) {
|
|
1293
1293
|
dropped_snaps++;
|
|
1294
1294
|
return;
|
|
1295
1295
|
}
|
|
1296
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1296
|
+
if (closed_streams.has(event.stream) && event.name !== _chunk2377SSHXcjs.TOMBSTONE_EVENT) {
|
|
1297
1297
|
dropped_closed++;
|
|
1298
1298
|
return;
|
|
1299
1299
|
}
|
|
@@ -1361,18 +1361,18 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1361
1361
|
const { stream, actor, asOf } = target;
|
|
1362
1362
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1363
1363
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1364
|
-
const cached = time_travel ? void 0 : await
|
|
1364
|
+
const cached = time_travel ? void 0 : await _chunkVOVHDDETcjs.cache.call(void 0, ).get(stream);
|
|
1365
1365
|
const cache_hit = !!cached;
|
|
1366
1366
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _56 => _56.state]), () => ( (me.init ? me.init() : {})));
|
|
1367
1367
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _57 => _57.patches]), () => ( 0));
|
|
1368
1368
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _58 => _58.snaps]), () => ( 0));
|
|
1369
1369
|
let replayed = 0;
|
|
1370
1370
|
let event;
|
|
1371
|
-
await
|
|
1371
|
+
await _chunkVOVHDDETcjs.store.call(void 0, ).query(
|
|
1372
1372
|
(raw) => {
|
|
1373
|
-
if (seeded && raw.name ===
|
|
1373
|
+
if (seeded && raw.name === _chunk2377SSHXcjs.SNAP_EVENT && replayed > 0) return;
|
|
1374
1374
|
event = me.view(raw, actor);
|
|
1375
|
-
if (event.name ===
|
|
1375
|
+
if (event.name === _chunk2377SSHXcjs.SNAP_EVENT) {
|
|
1376
1376
|
state2 = event.data;
|
|
1377
1377
|
snaps++;
|
|
1378
1378
|
patches = 0;
|
|
@@ -1381,8 +1381,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1381
1381
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1382
1382
|
patches++;
|
|
1383
1383
|
replayed++;
|
|
1384
|
-
} else if (event.name !==
|
|
1385
|
-
|
|
1384
|
+
} else if (event.name !== _chunk2377SSHXcjs.TOMBSTONE_EVENT) {
|
|
1385
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).warn(
|
|
1386
1386
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1387
1387
|
);
|
|
1388
1388
|
}
|
|
@@ -1410,7 +1410,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1410
1410
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1411
1411
|
}
|
|
1412
1412
|
);
|
|
1413
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _60 => _60.name]) ===
|
|
1413
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _60 => _60.name]) === _chunk2377SSHXcjs.TOMBSTONE_EVENT;
|
|
1414
1414
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1415
1415
|
await cache_put(stream, {
|
|
1416
1416
|
stream,
|
|
@@ -1453,8 +1453,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1453
1453
|
void 0,
|
|
1454
1454
|
patch_fn
|
|
1455
1455
|
);
|
|
1456
|
-
if (_optionalChain([snapshot, 'access', _65 => _65.event, 'optionalAccess', _66 => _66.name]) ===
|
|
1457
|
-
throw new (0,
|
|
1456
|
+
if (_optionalChain([snapshot, 'access', _65 => _65.event, 'optionalAccess', _66 => _66.name]) === _chunk2377SSHXcjs.TOMBSTONE_EVENT)
|
|
1457
|
+
throw new (0, _chunk2377SSHXcjs.StreamClosedError)(stream);
|
|
1458
1458
|
return {
|
|
1459
1459
|
state: l.state,
|
|
1460
1460
|
stream,
|
|
@@ -1470,7 +1470,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1470
1470
|
if (!stream) throw new Error("Missing target stream");
|
|
1471
1471
|
const reactingTo = _optionalChain([options, 'optionalAccess', _67 => _67.reactingTo]);
|
|
1472
1472
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.correlator]), () => ( default_correlator));
|
|
1473
|
-
const validated =
|
|
1473
|
+
const validated = _chunkVOVHDDETcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1474
1474
|
const opts = _optionalChain([me, 'access', _69 => _69.options, 'optionalAccess', _70 => _70[action2]]);
|
|
1475
1475
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _71 => _71.maxRetries]), () => ( 0));
|
|
1476
1476
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _72 => _72.loads, 'optionalAccess', _73 => _73[action2]]), () => ( []));
|
|
@@ -1482,8 +1482,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1482
1482
|
void 0,
|
|
1483
1483
|
patch_fn
|
|
1484
1484
|
);
|
|
1485
|
-
if (_optionalChain([snapshot, 'access', _74 => _74.event, 'optionalAccess', _75 => _75.name]) ===
|
|
1486
|
-
throw new (0,
|
|
1485
|
+
if (_optionalChain([snapshot, 'access', _74 => _74.event, 'optionalAccess', _75 => _75.name]) === _chunk2377SSHXcjs.TOMBSTONE_EVENT)
|
|
1486
|
+
throw new (0, _chunk2377SSHXcjs.StreamClosedError)(stream);
|
|
1487
1487
|
const own = {
|
|
1488
1488
|
state: me,
|
|
1489
1489
|
stream,
|
|
@@ -1497,7 +1497,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1497
1497
|
{ stream, state: snapshot.state },
|
|
1498
1498
|
target.actor,
|
|
1499
1499
|
patch_fn,
|
|
1500
|
-
(description) => new (0,
|
|
1500
|
+
(description) => new (0, _chunk2377SSHXcjs.PreconditionError)(
|
|
1501
1501
|
action2,
|
|
1502
1502
|
validated,
|
|
1503
1503
|
target,
|
|
@@ -1510,7 +1510,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1510
1510
|
);
|
|
1511
1511
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _78 => _78.requires, 'optionalAccess', _79 => _79[action2]]), () => ( [])))
|
|
1512
1512
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1513
|
-
throw new (0,
|
|
1513
|
+
throw new (0, _chunk2377SSHXcjs.PreconditionError)(
|
|
1514
1514
|
action2,
|
|
1515
1515
|
validated,
|
|
1516
1516
|
target,
|
|
@@ -1532,7 +1532,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1532
1532
|
);
|
|
1533
1533
|
to.events.push({
|
|
1534
1534
|
name: event,
|
|
1535
|
-
data:
|
|
1535
|
+
data: _chunkVOVHDDETcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1536
1536
|
});
|
|
1537
1537
|
}
|
|
1538
1538
|
if (!own.events.length)
|
|
@@ -1589,7 +1589,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1589
1589
|
});
|
|
1590
1590
|
let committed;
|
|
1591
1591
|
try {
|
|
1592
|
-
committed = await
|
|
1592
|
+
committed = await _chunkVOVHDDETcjs.store.call(void 0, ).commit(
|
|
1593
1593
|
appends.map((p) => ({
|
|
1594
1594
|
stream: p.stream,
|
|
1595
1595
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1598,7 +1598,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1598
1598
|
meta
|
|
1599
1599
|
);
|
|
1600
1600
|
} catch (error) {
|
|
1601
|
-
if (error instanceof
|
|
1601
|
+
if (error instanceof _chunk2377SSHXcjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1602
1602
|
throw error;
|
|
1603
1603
|
}
|
|
1604
1604
|
let row = 0;
|
|
@@ -1640,19 +1640,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1640
1640
|
}
|
|
1641
1641
|
return snapshots;
|
|
1642
1642
|
} catch (error) {
|
|
1643
|
-
if (!(error instanceof
|
|
1643
|
+
if (!(error instanceof _chunk2377SSHXcjs.ConcurrencyError)) throw error;
|
|
1644
1644
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1645
1645
|
if (attempt >= max_retries) throw error;
|
|
1646
1646
|
if (_optionalChain([opts, 'optionalAccess', _88 => _88.backoff])) {
|
|
1647
1647
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1648
|
-
if (delay_ms > 0) await
|
|
1648
|
+
if (delay_ms > 0) await _chunkVOVHDDETcjs.sleep.call(void 0, delay_ms);
|
|
1649
1649
|
}
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
1653
|
|
|
1654
1654
|
// src/internal/tracing.ts
|
|
1655
|
-
var PRETTY =
|
|
1655
|
+
var PRETTY = _chunkVOVHDDETcjs.config.call(void 0, ).env !== "production";
|
|
1656
1656
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1657
1657
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1658
1658
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1836,7 +1836,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
1836
1836
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _99 => _99.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1837
1837
|
return void 0;
|
|
1838
1838
|
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.`;
|
|
1839
|
-
|
|
1839
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).error(error);
|
|
1840
1840
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1841
1841
|
}
|
|
1842
1842
|
function fetch_failure_policy(registry) {
|
|
@@ -1852,13 +1852,13 @@ function fetch_failure_policy(registry) {
|
|
|
1852
1852
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1853
1853
|
if (!error) return { lease, handled, acked_at: at };
|
|
1854
1854
|
logger.error(error);
|
|
1855
|
-
const non_retryable = error instanceof
|
|
1855
|
+
const non_retryable = error instanceof _chunk2377SSHXcjs.NonRetryableError;
|
|
1856
1856
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
1857
1857
|
if (block2)
|
|
1858
1858
|
logger.error(
|
|
1859
1859
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1860
1860
|
);
|
|
1861
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
1861
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkVOVHDDETcjs.DEFAULT_BACKOFF)));
|
|
1862
1862
|
return {
|
|
1863
1863
|
lease,
|
|
1864
1864
|
handled,
|
|
@@ -1986,7 +1986,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
1986
1986
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
1987
1987
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
1988
1988
|
if (acked.length < expected)
|
|
1989
|
-
|
|
1989
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).warn(
|
|
1990
1990
|
`drain: ${expected - acked.length} of ${expected} acks were dropped \u2014 the lease was taken by another worker mid-handler. That work will be redelivered (at-least-once), but persistent drops mean leaseMillis is too short for this handler.`
|
|
1991
1991
|
);
|
|
1992
1992
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2082,9 +2082,9 @@ var DrainController = (_class3 = class {
|
|
|
2082
2082
|
if (!this.armed || this._stopped || this._inflight)
|
|
2083
2083
|
return EMPTY_DRAIN;
|
|
2084
2084
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2085
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2086
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2087
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2085
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkVOVHDDETcjs.DEFAULT_STREAM_LIMIT));
|
|
2086
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkVOVHDDETcjs.DEFAULT_EVENT_LIMIT));
|
|
2087
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkVOVHDDETcjs.DEFAULT_LEASE_MILLIS));
|
|
2088
2088
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2089
2089
|
return EMPTY_DRAIN;
|
|
2090
2090
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2210,7 +2210,7 @@ function build_handle(deps) {
|
|
|
2210
2210
|
handled++;
|
|
2211
2211
|
}
|
|
2212
2212
|
} catch (error) {
|
|
2213
|
-
if (error instanceof
|
|
2213
|
+
if (error instanceof _chunk2377SSHXcjs.DeferSignal) {
|
|
2214
2214
|
let defer;
|
|
2215
2215
|
try {
|
|
2216
2216
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2307,22 +2307,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2307
2307
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2308
2308
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2309
2309
|
// autoclose: `app.close` still closes it.
|
|
2310
|
-
resolver: (e) =>
|
|
2310
|
+
resolver: (e) => _chunkHACJYR7Zcjs.isStreamName.call(void 0, e.stream) ? {
|
|
2311
2311
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2312
2312
|
source: e.stream
|
|
2313
2313
|
} : void 0,
|
|
2314
2314
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2315
2315
|
// not quarantine the synthetic stream.
|
|
2316
|
-
options: { blockOnError: false, maxRetries:
|
|
2316
|
+
options: { blockOnError: false, maxRetries: _chunkVOVHDDETcjs.DEFAULT_MAX_RETRIES },
|
|
2317
2317
|
handler: async (event) => {
|
|
2318
2318
|
const aggregate = event.stream;
|
|
2319
2319
|
const window = read_window();
|
|
2320
2320
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2321
|
-
throw new (0,
|
|
2322
|
-
const stats = await
|
|
2321
|
+
throw new (0, _chunk2377SSHXcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2322
|
+
const stats = await _chunkVOVHDDETcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2323
2323
|
count: true,
|
|
2324
2324
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2325
|
-
exclude: [
|
|
2325
|
+
exclude: [_chunk2377SSHXcjs.TOMBSTONE_EVENT, _chunk2377SSHXcjs.SNAP_EVENT]
|
|
2326
2326
|
});
|
|
2327
2327
|
const entry = stats.get(aggregate);
|
|
2328
2328
|
if (!entry) return;
|
|
@@ -2358,7 +2358,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2358
2358
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2359
2359
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2360
2360
|
if (future.length)
|
|
2361
|
-
throw new (0,
|
|
2361
|
+
throw new (0, _chunk2377SSHXcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2362
2362
|
}
|
|
2363
2363
|
};
|
|
2364
2364
|
const key = `__autoclose_${st.name}`;
|
|
@@ -2418,7 +2418,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
2418
2418
|
deps,
|
|
2419
2419
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2420
2420
|
);
|
|
2421
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2421
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunk2377SSHXcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2422
2422
|
if (retired.length) _optionalChain([deps, 'access', _126 => _126.forget_subscribed, 'optionalCall', _127 => _127(retired)]);
|
|
2423
2423
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2424
2424
|
return { truncated, skipped };
|
|
@@ -2500,7 +2500,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2500
2500
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2501
2501
|
return void 0;
|
|
2502
2502
|
if (t.archive) await t.archive();
|
|
2503
|
-
const result = await
|
|
2503
|
+
const result = await _chunkVOVHDDETcjs.store.call(void 0, ).truncate([
|
|
2504
2504
|
{ stream: t.stream, before: t.before, max_id }
|
|
2505
2505
|
]);
|
|
2506
2506
|
return result.get(t.stream);
|
|
@@ -2513,10 +2513,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2513
2513
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2514
2514
|
let boundary_id;
|
|
2515
2515
|
let min_id;
|
|
2516
|
-
await
|
|
2516
|
+
await _chunkVOVHDDETcjs.store.call(void 0, ).query(
|
|
2517
2517
|
(event) => {
|
|
2518
2518
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2519
|
-
if (event.name ===
|
|
2519
|
+
if (event.name === _chunk2377SSHXcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
2520
2520
|
boundary_id = event.id;
|
|
2521
2521
|
},
|
|
2522
2522
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -2527,7 +2527,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2527
2527
|
const min_at = /* @__PURE__ */ new Map();
|
|
2528
2528
|
const matches = source_matcher();
|
|
2529
2529
|
await walk_streams(
|
|
2530
|
-
|
|
2530
|
+
_chunkVOVHDDETcjs.store.call(void 0, ),
|
|
2531
2531
|
(position) => {
|
|
2532
2532
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2533
2533
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2546,7 +2546,7 @@ function source_matcher() {
|
|
|
2546
2546
|
const compiled = /* @__PURE__ */ new Map();
|
|
2547
2547
|
return (source, target, stream) => {
|
|
2548
2548
|
if (!source) return true;
|
|
2549
|
-
if (
|
|
2549
|
+
if (_chunkHACJYR7Zcjs.isStreamName.call(void 0, source, target)) return source === stream;
|
|
2550
2550
|
let re = compiled.get(source);
|
|
2551
2551
|
if (!re) {
|
|
2552
2552
|
re = new RegExp(source);
|
|
@@ -2556,17 +2556,17 @@ function source_matcher() {
|
|
|
2556
2556
|
};
|
|
2557
2557
|
}
|
|
2558
2558
|
async function scan_stream_heads(streams) {
|
|
2559
|
-
const stats = await
|
|
2560
|
-
exclude: [
|
|
2559
|
+
const stats = await _chunkVOVHDDETcjs.store.call(void 0, ).query_stats(streams, {
|
|
2560
|
+
exclude: [_chunk2377SSHXcjs.SNAP_EVENT]
|
|
2561
2561
|
});
|
|
2562
|
-
const domain_heads = await
|
|
2563
|
-
exclude: [
|
|
2562
|
+
const domain_heads = await _chunkVOVHDDETcjs.store.call(void 0, ).query_stats(streams, {
|
|
2563
|
+
exclude: [_chunk2377SSHXcjs.SNAP_EVENT, _chunk2377SSHXcjs.TOMBSTONE_EVENT]
|
|
2564
2564
|
});
|
|
2565
|
-
const true_heads = await
|
|
2565
|
+
const true_heads = await _chunkVOVHDDETcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2566
2566
|
const out = /* @__PURE__ */ new Map();
|
|
2567
2567
|
for (const [stream, { head }] of domain_heads) {
|
|
2568
2568
|
const marker_head = _optionalChain([stats, 'access', _129 => _129.get, 'call', _130 => _130(stream), 'optionalAccess', _131 => _131.head]);
|
|
2569
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess', _132 => _132.name]) ===
|
|
2569
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _132 => _132.name]) === _chunk2377SSHXcjs.TOMBSTONE_EVENT;
|
|
2570
2570
|
out.set(stream, {
|
|
2571
2571
|
max_id: head.id,
|
|
2572
2572
|
version: true_heads.get(stream).head.version,
|
|
@@ -2589,7 +2589,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2589
2589
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2590
2590
|
const matches = source_matcher();
|
|
2591
2591
|
await walk_streams(
|
|
2592
|
-
|
|
2592
|
+
_chunkVOVHDDETcjs.store.call(void 0, ),
|
|
2593
2593
|
(position) => {
|
|
2594
2594
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2595
2595
|
if (!has_work) return;
|
|
@@ -2656,7 +2656,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
2656
2656
|
}
|
|
2657
2657
|
}
|
|
2658
2658
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2659
|
-
const heads = await
|
|
2659
|
+
const heads = await _chunkVOVHDDETcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2660
2660
|
return guarded.filter((stream) => {
|
|
2661
2661
|
if (_optionalChain([heads, 'access', _139 => _139.get, 'call', _140 => _140(stream), 'optionalAccess', _141 => _141.head, 'access', _142 => _142.id]) === guard_events.get(stream).id)
|
|
2662
2662
|
return true;
|
|
@@ -2674,18 +2674,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2674
2674
|
meta: {
|
|
2675
2675
|
correlation,
|
|
2676
2676
|
causation: {
|
|
2677
|
-
event: { id: guard.id, name:
|
|
2677
|
+
event: { id: guard.id, name: _chunk2377SSHXcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2678
2678
|
}
|
|
2679
2679
|
}
|
|
2680
2680
|
};
|
|
2681
2681
|
});
|
|
2682
|
-
const truncated = await
|
|
2682
|
+
const truncated = await _chunkVOVHDDETcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2683
2683
|
await Promise.all(
|
|
2684
2684
|
guarded.map(async (stream) => {
|
|
2685
2685
|
const entry = truncated.get(stream);
|
|
2686
2686
|
const state2 = seed_states.get(stream);
|
|
2687
2687
|
if (state2 && entry) {
|
|
2688
|
-
await
|
|
2688
|
+
await _chunkVOVHDDETcjs.cache.call(void 0, ).set(stream, {
|
|
2689
2689
|
stream,
|
|
2690
2690
|
state: state2,
|
|
2691
2691
|
version: entry.committed.version,
|
|
@@ -2694,7 +2694,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2694
2694
|
snaps: 1
|
|
2695
2695
|
});
|
|
2696
2696
|
} else {
|
|
2697
|
-
await
|
|
2697
|
+
await _chunkVOVHDDETcjs.cache.call(void 0, ).invalidate(stream);
|
|
2698
2698
|
}
|
|
2699
2699
|
})
|
|
2700
2700
|
);
|
|
@@ -2746,7 +2746,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2746
2746
|
// never lets a resolution re-lane them.
|
|
2747
2747
|
|
|
2748
2748
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2749
|
-
__init19() {this._patterns = new (0,
|
|
2749
|
+
__init19() {this._patterns = new (0, _chunkVOVHDDETcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2750
2750
|
|
|
2751
2751
|
|
|
2752
2752
|
|
|
@@ -2764,7 +2764,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2764
2764
|
on_init
|
|
2765
2765
|
}) {;_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);
|
|
2766
2766
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2767
|
-
this._dynamic_subscriptions = new (0,
|
|
2767
|
+
this._dynamic_subscriptions = new (0, _chunkVOVHDDETcjs.LruMap)(max_subscribed_streams);
|
|
2768
2768
|
this._registry = registry;
|
|
2769
2769
|
this._declared_lanes = declared_lanes;
|
|
2770
2770
|
this._static_targets = static_targets;
|
|
@@ -2822,7 +2822,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2822
2822
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
2823
2823
|
_in_fetch_window(source, stream) {
|
|
2824
2824
|
if (source === void 0 || source === stream) return true;
|
|
2825
|
-
if (
|
|
2825
|
+
if (_chunkHACJYR7Zcjs.isStreamName.call(void 0, source)) return false;
|
|
2826
2826
|
let pattern = this._patterns.get(source);
|
|
2827
2827
|
if (!pattern) {
|
|
2828
2828
|
pattern = new RegExp(source);
|
|
@@ -2865,7 +2865,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2865
2865
|
const correlated = /* @__PURE__ */ new Map();
|
|
2866
2866
|
let last_id = after;
|
|
2867
2867
|
let stopped = false;
|
|
2868
|
-
const found = await
|
|
2868
|
+
const found = await _chunkVOVHDDETcjs.store.call(void 0, ).query(
|
|
2869
2869
|
(event) => {
|
|
2870
2870
|
if (stopped) return;
|
|
2871
2871
|
const register = this._registry.events[event.name];
|
|
@@ -2910,9 +2910,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2910
2910
|
correlated_at: void 0
|
|
2911
2911
|
};
|
|
2912
2912
|
const seen_in_scan = correlated.has(resolved.target);
|
|
2913
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _145 => _145.lane])), () => (
|
|
2913
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _145 => _145.lane])), () => ( _chunk2377SSHXcjs.DEFAULT_LANE));
|
|
2914
2914
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _146 => _146.priority]);
|
|
2915
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
2915
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunk2377SSHXcjs.DEFAULT_LANE));
|
|
2916
2916
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
2917
2917
|
report_lane_conflict(
|
|
2918
2918
|
this._reported,
|
|
@@ -2986,7 +2986,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2986
2986
|
await Promise.all(
|
|
2987
2987
|
missed.map(async ([stream, entry]) => {
|
|
2988
2988
|
let row;
|
|
2989
|
-
await
|
|
2989
|
+
await _chunkVOVHDDETcjs.store.call(void 0, ).query_streams(
|
|
2990
2990
|
(position) => {
|
|
2991
2991
|
row = position;
|
|
2992
2992
|
},
|
|
@@ -2998,8 +2998,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2998
2998
|
lane: row.lane
|
|
2999
2999
|
});
|
|
3000
3000
|
if (entry.priority > row.priority) return;
|
|
3001
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3002
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3001
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunk2377SSHXcjs.DEFAULT_LANE));
|
|
3002
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunk2377SSHXcjs.DEFAULT_LANE));
|
|
3003
3003
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3004
3004
|
report_lane_conflict(
|
|
3005
3005
|
this._reported,
|
|
@@ -3025,7 +3025,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3025
3025
|
millis: 0
|
|
3026
3026
|
});
|
|
3027
3027
|
} catch (error) {
|
|
3028
|
-
|
|
3028
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).warn(
|
|
3029
3029
|
`Could not hand back the correlation lease during shutdown; it expires on its own within ${CORRELATION_LEASE_MS}ms and correlation resumes normally after that. On a single-writer store this usually means another connection holds the database. Cause: ${String(_nullishCoalesce(error.cause, () => ( error)))}`
|
|
3030
3030
|
);
|
|
3031
3031
|
}
|
|
@@ -3049,7 +3049,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3049
3049
|
const { pii, ...rest } = event;
|
|
3050
3050
|
if (pii == null) {
|
|
3051
3051
|
const shredded = { ...data };
|
|
3052
|
-
for (const f of fields) shredded[f] =
|
|
3052
|
+
for (const f of fields) shredded[f] = _chunk2377SSHXcjs.SHREDDED;
|
|
3053
3053
|
return { ...rest, data: shredded };
|
|
3054
3054
|
}
|
|
3055
3055
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3060,7 +3060,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3060
3060
|
};
|
|
3061
3061
|
}
|
|
3062
3062
|
const redacted = { ...data };
|
|
3063
|
-
for (const f of fields) redacted[f] =
|
|
3063
|
+
for (const f of fields) redacted[f] = _chunk2377SSHXcjs.REDACTED;
|
|
3064
3064
|
return { ...rest, data: redacted };
|
|
3065
3065
|
}
|
|
3066
3066
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -3362,7 +3362,7 @@ var Act = (_class7 = class {
|
|
|
3362
3362
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3363
3363
|
|
|
3364
3364
|
|
|
3365
|
-
__init27() {this._logger =
|
|
3365
|
+
__init27() {this._logger = _chunkVOVHDDETcjs.log.call(void 0, )}
|
|
3366
3366
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3367
3367
|
|
|
3368
3368
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3384,10 +3384,10 @@ var Act = (_class7 = class {
|
|
|
3384
3384
|
this._lanes = lanes;
|
|
3385
3385
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3386
3386
|
validate_only_lanes(options.onlyLanes, this._declared_lanes);
|
|
3387
|
-
if (options.scoped)
|
|
3388
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3387
|
+
if (options.scoped) _chunkVOVHDDETcjs.check_store.call(void 0, options.scoped.store);
|
|
3388
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkVOVHDDETcjs.unscoped_ports.call(void 0, )));
|
|
3389
3389
|
const ports = this._ports;
|
|
3390
|
-
this._scoped =
|
|
3390
|
+
this._scoped = _chunkVOVHDDETcjs.make_run_scoped.call(void 0, {
|
|
3391
3391
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3392
3392
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3393
3393
|
get store() {
|
|
@@ -3397,14 +3397,14 @@ var Act = (_class7 = class {
|
|
|
3397
3397
|
return ports.cache;
|
|
3398
3398
|
},
|
|
3399
3399
|
// Parsed per build, so a bad window throws on every build.
|
|
3400
|
-
autoclose_window:
|
|
3400
|
+
autoclose_window: _chunkVOVHDDETcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3401
3401
|
});
|
|
3402
3402
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3403
3403
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3404
3404
|
this._cd = build_drain(this._logger);
|
|
3405
3405
|
const handle = build_handle({
|
|
3406
3406
|
logger: this._logger,
|
|
3407
|
-
reaction_scope:
|
|
3407
|
+
reaction_scope: _chunkVOVHDDETcjs.make_reaction_scope.call(void 0, {
|
|
3408
3408
|
do: this.do.bind(this),
|
|
3409
3409
|
load: this.load.bind(this),
|
|
3410
3410
|
query: this.query.bind(this),
|
|
@@ -3434,12 +3434,12 @@ var Act = (_class7 = class {
|
|
|
3434
3434
|
this._ports.store,
|
|
3435
3435
|
options.listen !== false
|
|
3436
3436
|
);
|
|
3437
|
-
|
|
3437
|
+
_chunkVOVHDDETcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3438
3438
|
}
|
|
3439
3439
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3440
3440
|
_build_breaker(options) {
|
|
3441
3441
|
return new CircuitBreaker(
|
|
3442
|
-
|
|
3442
|
+
_chunkVOVHDDETcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3443
3443
|
{
|
|
3444
3444
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3445
3445
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3473,7 +3473,7 @@ var Act = (_class7 = class {
|
|
|
3473
3473
|
try {
|
|
3474
3474
|
await this._run_close(targets);
|
|
3475
3475
|
} catch (error) {
|
|
3476
|
-
if (error instanceof
|
|
3476
|
+
if (error instanceof _chunk2377SSHXcjs.StoreError) throw error;
|
|
3477
3477
|
this._logger.error(
|
|
3478
3478
|
error,
|
|
3479
3479
|
`Reaction-requested close of ${targets.map((t) => `"${t.stream}"`).join(", ")} failed and was not retried; close it with app.close(...) once the cause is fixed.`
|
|
@@ -3507,7 +3507,7 @@ var Act = (_class7 = class {
|
|
|
3507
3507
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3508
3508
|
_build_audit_deps() {
|
|
3509
3509
|
return {
|
|
3510
|
-
store:
|
|
3510
|
+
store: _chunkVOVHDDETcjs.store,
|
|
3511
3511
|
event_to_state: this._event_to_state,
|
|
3512
3512
|
// Declared lanes, not this process's controllers: a lane another
|
|
3513
3513
|
// worker drains is not `unknown-lane`.
|
|
@@ -3520,7 +3520,7 @@ var Act = (_class7 = class {
|
|
|
3520
3520
|
registry: this.registry,
|
|
3521
3521
|
static_targets: classification.static_targets,
|
|
3522
3522
|
cd: this._cd,
|
|
3523
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3523
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunk2377SSHXcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3524
3524
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3525
3525
|
// still a valid destination.
|
|
3526
3526
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3536,7 +3536,7 @@ var Act = (_class7 = class {
|
|
|
3536
3536
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3537
3537
|
async _seed_persisted_defers() {
|
|
3538
3538
|
const now = Date.now();
|
|
3539
|
-
await walk_streams(
|
|
3539
|
+
await walk_streams(_chunkVOVHDDETcjs.store.call(void 0, ), (pos) => {
|
|
3540
3540
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3541
3541
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3542
3542
|
_optionalChain([controller, 'optionalAccess', _154 => _154.seed_defer, 'call', _155 => _155(pos.stream, pos.deferred_at)]);
|
|
@@ -3552,7 +3552,7 @@ var Act = (_class7 = class {
|
|
|
3552
3552
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3553
3553
|
breaker: this._breaker
|
|
3554
3554
|
},
|
|
3555
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3555
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunk2377SSHXcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3556
3556
|
);
|
|
3557
3557
|
}
|
|
3558
3558
|
|
|
@@ -3572,7 +3572,7 @@ var Act = (_class7 = class {
|
|
|
3572
3572
|
*/
|
|
3573
3573
|
shutdown(options) {
|
|
3574
3574
|
if (!this._shutdown_promise) {
|
|
3575
|
-
|
|
3575
|
+
_chunkVOVHDDETcjs.resolveShutdownConfig.call(void 0, options);
|
|
3576
3576
|
this._shutdown_promise = (async () => {
|
|
3577
3577
|
this.stop_correlations();
|
|
3578
3578
|
this._settle.stop(true);
|
|
@@ -3590,10 +3590,10 @@ var Act = (_class7 = class {
|
|
|
3590
3590
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3591
3591
|
// default for none or 0, and for a running settle), capped.
|
|
3592
3592
|
_derive_grace_ms(running, settling) {
|
|
3593
|
-
let max = settling ?
|
|
3593
|
+
let max = settling ? _chunkVOVHDDETcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3594
3594
|
for (const c of running)
|
|
3595
|
-
max = Math.max(max, c.lease_millis ||
|
|
3596
|
-
return Math.min(max,
|
|
3595
|
+
max = Math.max(max, c.lease_millis || _chunkVOVHDDETcjs.DEFAULT_LEASE_MILLIS);
|
|
3596
|
+
return Math.min(max, _chunkVOVHDDETcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3597
3597
|
}
|
|
3598
3598
|
async _await_inflight(grace_ms) {
|
|
3599
3599
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3677,7 +3677,7 @@ var Act = (_class7 = class {
|
|
|
3677
3677
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3678
3678
|
*/
|
|
3679
3679
|
async do(action2, target, payload, options) {
|
|
3680
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _157 => _157.reactingTo]), () => (
|
|
3680
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _157 => _157.reactingTo]), () => ( _chunkVOVHDDETcjs.current_reacting.call(void 0, )));
|
|
3681
3681
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _158 => _158.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3682
3682
|
return this._scoped(async () => {
|
|
3683
3683
|
const snapshots = await this._es.action(
|
|
@@ -3688,7 +3688,6 @@ var Act = (_class7 = class {
|
|
|
3688
3688
|
do_options
|
|
3689
3689
|
);
|
|
3690
3690
|
if (!snapshots[0].patch) return snapshots;
|
|
3691
|
-
const me = this.registry.actions[action2];
|
|
3692
3691
|
this._wake(snapshots.map((s) => s.event.name));
|
|
3693
3692
|
const by_stream = /* @__PURE__ */ new Map();
|
|
3694
3693
|
for (const s of snapshots) {
|
|
@@ -3696,10 +3695,10 @@ var Act = (_class7 = class {
|
|
|
3696
3695
|
if (of_stream) of_stream.push(s);
|
|
3697
3696
|
else by_stream.set(s.event.stream, [s]);
|
|
3698
3697
|
}
|
|
3699
|
-
for (const
|
|
3700
|
-
const owner =
|
|
3701
|
-
|
|
3702
|
-
)
|
|
3698
|
+
for (const of_stream of by_stream.values()) {
|
|
3699
|
+
const owner = this._event_to_state.get(
|
|
3700
|
+
of_stream[0].event.name
|
|
3701
|
+
);
|
|
3703
3702
|
this.emit("committed", of_stream);
|
|
3704
3703
|
this._notify(`committed:${owner.name}`, of_stream);
|
|
3705
3704
|
}
|
|
@@ -3752,7 +3751,7 @@ var Act = (_class7 = class {
|
|
|
3752
3751
|
return this._scoped(async () => {
|
|
3753
3752
|
let first;
|
|
3754
3753
|
let last;
|
|
3755
|
-
const count = await
|
|
3754
|
+
const count = await _chunkVOVHDDETcjs.store.call(void 0, ).query((e) => {
|
|
3756
3755
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3757
3756
|
if (!first) first = gated;
|
|
3758
3757
|
last = gated;
|
|
@@ -3782,7 +3781,7 @@ var Act = (_class7 = class {
|
|
|
3782
3781
|
async query_array(query) {
|
|
3783
3782
|
return this._scoped(async () => {
|
|
3784
3783
|
const events = [];
|
|
3785
|
-
await
|
|
3784
|
+
await _chunkVOVHDDETcjs.store.call(void 0, ).query((e) => {
|
|
3786
3785
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3787
3786
|
}, query);
|
|
3788
3787
|
return events;
|
|
@@ -3802,14 +3801,14 @@ var Act = (_class7 = class {
|
|
|
3802
3801
|
*/
|
|
3803
3802
|
async forget(stream) {
|
|
3804
3803
|
return this._scoped(async () => {
|
|
3805
|
-
const s =
|
|
3804
|
+
const s = _chunkVOVHDDETcjs.store.call(void 0, );
|
|
3806
3805
|
if (!s.forget_pii) {
|
|
3807
3806
|
throw new Error(
|
|
3808
3807
|
`Store does not implement forget_pii \u2014 adapter cannot comply with sensitive-data erasure. Use an adapter that declares pii_isolation: true (e.g. @rotorsoft/act on the in-memory store).`
|
|
3809
3808
|
);
|
|
3810
3809
|
}
|
|
3811
3810
|
const eventCount = await s.forget_pii(stream);
|
|
3812
|
-
await
|
|
3811
|
+
await _chunkVOVHDDETcjs.cache.call(void 0, ).invalidate(stream);
|
|
3813
3812
|
if (eventCount > 0) {
|
|
3814
3813
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3815
3814
|
}
|
|
@@ -3843,7 +3842,7 @@ var Act = (_class7 = class {
|
|
|
3843
3842
|
* @see {@link correlate} for dynamic stream discovery
|
|
3844
3843
|
*/
|
|
3845
3844
|
async drain(options = {}) {
|
|
3846
|
-
|
|
3845
|
+
_chunkVOVHDDETcjs.resolveDrainConfig.call(void 0, options);
|
|
3847
3846
|
if (!this._drain)
|
|
3848
3847
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3849
3848
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4023,7 +4022,7 @@ var Act = (_class7 = class {
|
|
|
4023
4022
|
*/
|
|
4024
4023
|
async reset(input) {
|
|
4025
4024
|
return this._scoped(async () => {
|
|
4026
|
-
const count = await
|
|
4025
|
+
const count = await _chunkVOVHDDETcjs.store.call(void 0, ).reset(input);
|
|
4027
4026
|
for (const handler of this._batch_handlers.values())
|
|
4028
4027
|
_optionalChain([handler, 'access', _165 => _165[FOLD_RESET], 'optionalCall', _166 => _166()]);
|
|
4029
4028
|
if (count > 0) {
|
|
@@ -4059,7 +4058,7 @@ var Act = (_class7 = class {
|
|
|
4059
4058
|
*/
|
|
4060
4059
|
async unblock(input) {
|
|
4061
4060
|
return this._scoped(async () => {
|
|
4062
|
-
const count = await
|
|
4061
|
+
const count = await _chunkVOVHDDETcjs.store.call(void 0, ).unblock(input);
|
|
4063
4062
|
if (count > 0) {
|
|
4064
4063
|
this._wake();
|
|
4065
4064
|
}
|
|
@@ -4114,7 +4113,7 @@ var Act = (_class7 = class {
|
|
|
4114
4113
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4115
4114
|
}
|
|
4116
4115
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4117
|
-
const s =
|
|
4116
|
+
const s = _chunkVOVHDDETcjs.store.call(void 0, );
|
|
4118
4117
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4119
4118
|
return s;
|
|
4120
4119
|
})()));
|
|
@@ -4160,7 +4159,7 @@ var Act = (_class7 = class {
|
|
|
4160
4159
|
async blocked_streams(options) {
|
|
4161
4160
|
return this._scoped(async () => {
|
|
4162
4161
|
const positions = [];
|
|
4163
|
-
await
|
|
4162
|
+
await _chunkVOVHDDETcjs.store.call(void 0, ).query_streams(
|
|
4164
4163
|
(p) => {
|
|
4165
4164
|
positions.push(p);
|
|
4166
4165
|
},
|
|
@@ -4212,7 +4211,7 @@ var Act = (_class7 = class {
|
|
|
4212
4211
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4213
4212
|
*/
|
|
4214
4213
|
async prioritize(filter, priority) {
|
|
4215
|
-
return this._scoped(() =>
|
|
4214
|
+
return this._scoped(() => _chunkVOVHDDETcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4216
4215
|
}
|
|
4217
4216
|
// Shared by `close()` and reaction-requested closes.
|
|
4218
4217
|
async _run_close(targets) {
|
|
@@ -4292,7 +4291,7 @@ var Act = (_class7 = class {
|
|
|
4292
4291
|
* @see {@link correlate} for manual correlation
|
|
4293
4292
|
*/
|
|
4294
4293
|
settle(options) {
|
|
4295
|
-
|
|
4294
|
+
_chunkVOVHDDETcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
4296
4295
|
this._schedule(options);
|
|
4297
4296
|
}
|
|
4298
4297
|
}, _class7);
|
|
@@ -4300,9 +4299,9 @@ var Act = (_class7 = class {
|
|
|
4300
4299
|
// src/builders/merge.ts
|
|
4301
4300
|
|
|
4302
4301
|
function base_type_name(schema) {
|
|
4303
|
-
let def =
|
|
4304
|
-
for (let inner =
|
|
4305
|
-
def =
|
|
4302
|
+
let def = _chunk2377SSHXcjs.def_of.call(void 0, schema);
|
|
4303
|
+
for (let inner = _chunk2377SSHXcjs.inner_of.call(void 0, def); inner; inner = _chunk2377SSHXcjs.inner_of.call(void 0, def))
|
|
4304
|
+
def = _chunk2377SSHXcjs.def_of.call(void 0, inner);
|
|
4306
4305
|
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4307
4306
|
}
|
|
4308
4307
|
function merge_schemas(existing, incoming, state_name) {
|
|
@@ -4489,9 +4488,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4489
4488
|
|
|
4490
4489
|
// src/builders/builder-utils.ts
|
|
4491
4490
|
function register_lane(config2, lanes) {
|
|
4492
|
-
|
|
4493
|
-
if (config2.name ===
|
|
4494
|
-
throw new Error(`Lane "${
|
|
4491
|
+
_chunkVOVHDDETcjs.resolveLaneConfig.call(void 0, config2);
|
|
4492
|
+
if (config2.name === _chunk2377SSHXcjs.DEFAULT_LANE)
|
|
4493
|
+
throw new Error(`Lane "${_chunk2377SSHXcjs.DEFAULT_LANE}" is reserved`);
|
|
4495
4494
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4496
4495
|
if (!existing) return void lanes.push(config2);
|
|
4497
4496
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4533,9 +4532,9 @@ function reaction_on(event, events, builder) {
|
|
|
4533
4532
|
// Validate the whole bag at the declaration site so a bad
|
|
4534
4533
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4535
4534
|
// not a NaN gate on the first retry.
|
|
4536
|
-
options:
|
|
4537
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _169 => _169.blockOnError]), () => (
|
|
4538
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.maxRetries]), () => (
|
|
4535
|
+
options: _chunkVOVHDDETcjs.resolveReactionConfig.call(void 0, {
|
|
4536
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _169 => _169.blockOnError]), () => ( _chunkVOVHDDETcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4537
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.maxRetries]), () => ( _chunkVOVHDDETcjs.DEFAULT_MAX_RETRIES)),
|
|
4539
4538
|
backoff: _optionalChain([options, 'optionalAccess', _171 => _171.backoff])
|
|
4540
4539
|
})
|
|
4541
4540
|
};
|
|
@@ -4556,7 +4555,7 @@ function reaction_on(event, events, builder) {
|
|
|
4556
4555
|
// src/internal/date-reviver.ts
|
|
4557
4556
|
|
|
4558
4557
|
function variant_schema(schema, walk) {
|
|
4559
|
-
const shape = _optionalChain([
|
|
4558
|
+
const shape = _optionalChain([_chunk2377SSHXcjs.def_of.call(void 0, schema), 'optionalAccess', _172 => _172.shape]);
|
|
4560
4559
|
if (!shape) {
|
|
4561
4560
|
const dates = walk(schema);
|
|
4562
4561
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -4593,7 +4592,7 @@ function date_reviver_schema(schema) {
|
|
|
4593
4592
|
return first && recursive ? pass(true) : first;
|
|
4594
4593
|
}
|
|
4595
4594
|
function build(schema, walk) {
|
|
4596
|
-
const def =
|
|
4595
|
+
const def = _chunk2377SSHXcjs.def_of.call(void 0, schema);
|
|
4597
4596
|
if (!def) return void 0;
|
|
4598
4597
|
const inner = () => walk(def.innerType);
|
|
4599
4598
|
switch (def.type) {
|
|
@@ -4639,13 +4638,13 @@ function build(schema, walk) {
|
|
|
4639
4638
|
return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
|
|
4640
4639
|
}
|
|
4641
4640
|
default:
|
|
4642
|
-
return
|
|
4641
|
+
return _chunk2377SSHXcjs.inner_of.call(void 0, def) ? inner() : void 0;
|
|
4643
4642
|
}
|
|
4644
4643
|
}
|
|
4645
4644
|
|
|
4646
4645
|
// src/builders/event-builder.ts
|
|
4647
4646
|
function event_tags(schema) {
|
|
4648
|
-
const pii =
|
|
4647
|
+
const pii = _chunk2377SSHXcjs.pii_schemas.call(void 0, schema);
|
|
4649
4648
|
const pii_dates = {};
|
|
4650
4649
|
for (const [key, field] of Object.entries(pii)) {
|
|
4651
4650
|
const dates = date_reviver_schema(field);
|
|
@@ -4683,7 +4682,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4683
4682
|
});
|
|
4684
4683
|
}
|
|
4685
4684
|
function build_events(registry, states, lanes, owners) {
|
|
4686
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4685
|
+
const declared = /* @__PURE__ */ new Set([_chunk2377SSHXcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4687
4686
|
const lane_errors = [];
|
|
4688
4687
|
const tags = /* @__PURE__ */ new Map();
|
|
4689
4688
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4758,7 +4757,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4758
4757
|
if (reader) readers.set(event_name, reader);
|
|
4759
4758
|
}
|
|
4760
4759
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4761
|
-
if (snap2) readers.set(
|
|
4760
|
+
if (snap2) readers.set(_chunk2377SSHXcjs.SNAP_EVENT, snap2);
|
|
4762
4761
|
if (readers.size === 0) continue;
|
|
4763
4762
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4764
4763
|
}
|
|
@@ -4766,7 +4765,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4766
4765
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4767
4766
|
}
|
|
4768
4767
|
function reads_as_string(schema) {
|
|
4769
|
-
const type = _optionalChain([
|
|
4768
|
+
const type = _optionalChain([_chunk2377SSHXcjs.def_of.call(void 0, _chunk2377SSHXcjs.output_of.call(void 0, schema)), 'optionalAccess', _176 => _176.type]);
|
|
4770
4769
|
return type === "string" || type === "transform";
|
|
4771
4770
|
}
|
|
4772
4771
|
|
|
@@ -4878,7 +4877,7 @@ function act() {
|
|
|
4878
4877
|
const list = deprecation_summary.map(
|
|
4879
4878
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4880
4879
|
).join(", ");
|
|
4881
|
-
|
|
4880
|
+
_chunkVOVHDDETcjs.log.call(void 0, ).info(
|
|
4882
4881
|
`Act registered ${deprecation_summary.length} deprecated event(s): ${list}. These are legacy versions kept for the read path. Consider truncating closed streams via app.close() when feasible to reduce historical event load. See docs/docs/architecture/event-schema-evolution.md.`
|
|
4883
4882
|
);
|
|
4884
4883
|
}
|
|
@@ -4920,7 +4919,7 @@ function act() {
|
|
|
4920
4919
|
return reaction_on(event, registry.events, builder);
|
|
4921
4920
|
},
|
|
4922
4921
|
build: (options) => {
|
|
4923
|
-
|
|
4922
|
+
_chunkVOVHDDETcjs.resolveActConfig.call(void 0, options);
|
|
4924
4923
|
if (!_built) {
|
|
4925
4924
|
for (const proj of pending_projections) add_projection(proj);
|
|
4926
4925
|
for (const proj of fold_projections) {
|
|
@@ -4960,7 +4959,7 @@ function act() {
|
|
|
4960
4959
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
4961
4960
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
4962
4961
|
finalize_deprecations();
|
|
4963
|
-
if (built.advisory)
|
|
4962
|
+
if (built.advisory) _chunkVOVHDDETcjs.log.call(void 0, ).warn(built.advisory);
|
|
4964
4963
|
for (const [name, state2] of states) {
|
|
4965
4964
|
if (!state2.loads) continue;
|
|
4966
4965
|
const resolved = {};
|
|
@@ -5004,7 +5003,7 @@ function act() {
|
|
|
5004
5003
|
synthesize_autoclose_reactions(
|
|
5005
5004
|
registry,
|
|
5006
5005
|
states,
|
|
5007
|
-
|
|
5006
|
+
_chunkVOVHDDETcjs.current_autoclose_window
|
|
5008
5007
|
);
|
|
5009
5008
|
Object.freeze(registry.actions);
|
|
5010
5009
|
Object.freeze(registry.events);
|
|
@@ -5052,8 +5051,8 @@ function _projection(target) {
|
|
|
5052
5051
|
handler,
|
|
5053
5052
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5054
5053
|
options: {
|
|
5055
|
-
blockOnError:
|
|
5056
|
-
maxRetries:
|
|
5054
|
+
blockOnError: _chunkVOVHDDETcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5055
|
+
maxRetries: _chunkVOVHDDETcjs.DEFAULT_MAX_RETRIES
|
|
5057
5056
|
}
|
|
5058
5057
|
}),
|
|
5059
5058
|
widened
|
|
@@ -5094,7 +5093,7 @@ function _projection(target) {
|
|
|
5094
5093
|
throw new Error(
|
|
5095
5094
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5096
5095
|
);
|
|
5097
|
-
const config2 =
|
|
5096
|
+
const config2 = _chunkVOVHDDETcjs.resolveFoldConfig.call(void 0, options);
|
|
5098
5097
|
const fold_events = {};
|
|
5099
5098
|
for (const partial of partials)
|
|
5100
5099
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5112,8 +5111,8 @@ function _projection(target) {
|
|
|
5112
5111
|
handler: noop,
|
|
5113
5112
|
resolver: { target },
|
|
5114
5113
|
options: {
|
|
5115
|
-
blockOnError:
|
|
5116
|
-
maxRetries:
|
|
5114
|
+
blockOnError: _chunkVOVHDDETcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5115
|
+
maxRetries: _chunkVOVHDDETcjs.DEFAULT_MAX_RETRIES
|
|
5117
5116
|
}
|
|
5118
5117
|
}
|
|
5119
5118
|
]
|
|
@@ -5229,7 +5228,7 @@ function action_builder(state2) {
|
|
|
5229
5228
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5230
5229
|
internal.actions[action2] = schema;
|
|
5231
5230
|
if (options) {
|
|
5232
|
-
|
|
5231
|
+
_chunkVOVHDDETcjs.resolveActionConfig.call(void 0, options);
|
|
5233
5232
|
internal.options ??= {};
|
|
5234
5233
|
internal.options[action2] = options;
|
|
5235
5234
|
}
|
|
@@ -5488,6 +5487,35 @@ function write_line(writer, line) {
|
|
|
5488
5487
|
});
|
|
5489
5488
|
}
|
|
5490
5489
|
|
|
5490
|
+
// src/deprecated.ts
|
|
5491
|
+
var check_appends = _chunkHACJYR7Zcjs.checkAppends;
|
|
5492
|
+
var throw_if_stale = _chunkHACJYR7Zcjs.checkVersion;
|
|
5493
|
+
var concurrency_error = _chunkHACJYR7Zcjs.concurrencyError;
|
|
5494
|
+
var seed_event = _chunkHACJYR7Zcjs.seedEvent;
|
|
5495
|
+
var fair_slots = _chunkHACJYR7Zcjs.fairSlots;
|
|
5496
|
+
var is_literal_source = _chunkHACJYR7Zcjs.isStreamName;
|
|
5497
|
+
var notification_of = _chunkHACJYR7Zcjs.parseNotification;
|
|
5498
|
+
var DEFAULT_QUERY_STREAMS_LIMIT2 = _chunk2377SSHXcjs.DEFAULT_QUERY_STREAMS_LIMIT;
|
|
5499
|
+
var ActorSchema2 = _chunk2377SSHXcjs.ActorSchema;
|
|
5500
|
+
var TargetSchema2 = _chunk2377SSHXcjs.TargetSchema;
|
|
5501
|
+
var EventMetaSchema2 = _chunk2377SSHXcjs.EventMetaSchema;
|
|
5502
|
+
var CausationEventSchema2 = _chunk2377SSHXcjs.CausationEventSchema;
|
|
5503
|
+
var CommittedMetaSchema2 = _chunk2377SSHXcjs.CommittedMetaSchema;
|
|
5504
|
+
var QuerySchema2 = _chunk2377SSHXcjs.QuerySchema;
|
|
5505
|
+
var Environments2 = _chunk2377SSHXcjs.Environments;
|
|
5506
|
+
var LogLevels2 = _chunk2377SSHXcjs.LogLevels;
|
|
5507
|
+
var ExitCodes2 = _chunk2377SSHXcjs.ExitCodes;
|
|
5508
|
+
var DEFAULT_LANE2 = _chunk2377SSHXcjs.DEFAULT_LANE;
|
|
5509
|
+
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunk2377SSHXcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5510
|
+
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunk2377SSHXcjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5511
|
+
var PackageSchema = _chunkVOVHDDETcjs.package_schema;
|
|
5512
|
+
var default_scope = _chunkVOVHDDETcjs.unscoped_ports;
|
|
5513
|
+
var resolveAutocloseConfig2 = _chunkVOVHDDETcjs.resolveAutocloseConfig;
|
|
5514
|
+
var extend = (source, schema, target) => ({ ...target, ..._chunkVOVHDDETcjs.validate.call(void 0, "config", source, schema) });
|
|
5515
|
+
var ISO_8601 = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d+)?(Z|[+-][0-2][0-9]:[0-5][0-9])?$/;
|
|
5516
|
+
var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value;
|
|
5517
|
+
|
|
5518
|
+
|
|
5491
5519
|
|
|
5492
5520
|
|
|
5493
5521
|
|
|
@@ -5546,5 +5574,5 @@ function write_line(writer, line) {
|
|
|
5546
5574
|
|
|
5547
5575
|
|
|
5548
5576
|
|
|
5549
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5577
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunk2377SSHXcjs.ConcurrencyError; exports.ConsoleLogger = _chunkVOVHDDETcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = DEFAULT_LANE2; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = DEFAULT_MAX_SUBSCRIBED_STREAMS2; exports.DEFAULT_QUERY_STREAMS_LIMIT = DEFAULT_QUERY_STREAMS_LIMIT2; exports.DEFAULT_SETTLE_DEBOUNCE_MS = DEFAULT_SETTLE_DEBOUNCE_MS2; exports.DeferSignal = _chunk2377SSHXcjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunk2377SSHXcjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkVOVHDDETcjs.InMemoryCache; exports.InMemoryStore = _chunkVOVHDDETcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunk2377SSHXcjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunk2377SSHXcjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunk2377SSHXcjs.REDACTED; exports.SHREDDED = _chunk2377SSHXcjs.SHREDDED; exports.SNAP_EVENT = _chunk2377SSHXcjs.SNAP_EVENT; exports.StoreError = _chunk2377SSHXcjs.StoreError; exports.StreamClosedError = _chunk2377SSHXcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunk2377SSHXcjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunk2377SSHXcjs.ValidationError; exports.ZodEmpty = _chunk2377SSHXcjs.ZodEmpty; exports.act = act; exports.cache = _chunkVOVHDDETcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkVOVHDDETcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkVOVHDDETcjs.dispose; exports.disposeAndExit = _chunkVOVHDDETcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkVOVHDDETcjs.log; exports.notification_of = notification_of; exports.pii_fields = _chunk2377SSHXcjs.pii_fields; exports.port = _chunkVOVHDDETcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = resolveAutocloseConfig2; exports.seed_event = seed_event; exports.sensitive = _chunk2377SSHXcjs.sensitive; exports.sensitiveFields = _chunk2377SSHXcjs.sensitiveFields; exports.sleep = _chunkVOVHDDETcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkVOVHDDETcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkVOVHDDETcjs.validate;
|
|
5550
5578
|
//# sourceMappingURL=index.cjs.map
|