@rotorsoft/act 2.1.1 → 2.1.3
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/csv.d.ts +2 -1
- package/dist/@types/csv.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/scoped.d.ts +2 -4
- package/dist/@types/scoped.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +1 -213
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/index.d.ts +1 -0
- package/dist/@types/types/index.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +2 -1
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/restore.d.ts +222 -0
- package/dist/@types/types/restore.d.ts.map +1 -0
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.js +2 -2
- package/dist/{chunk-QPVUARKL.js → chunk-ADMH76IO.js} +3 -3
- package/dist/{chunk-QPVUARKL.js.map → chunk-ADMH76IO.js.map} +1 -1
- package/dist/{chunk-W3PHEA5Q.js → chunk-C35J3SNT.js} +1 -1
- package/dist/chunk-C35J3SNT.js.map +1 -0
- package/dist/{chunk-PZQXTGWF.cjs → chunk-D7LQNOEV.cjs} +4 -4
- package/dist/{chunk-PZQXTGWF.cjs.map → chunk-D7LQNOEV.cjs.map} +1 -1
- package/dist/{chunk-7VYSJIXD.cjs → chunk-QFYPSI6P.cjs} +1 -1
- package/dist/chunk-QFYPSI6P.cjs.map +1 -0
- package/dist/{chunk-LN3OP4OL.cjs → chunk-QWYMR7ZP.cjs} +17 -17
- package/dist/{chunk-LN3OP4OL.cjs.map → chunk-QWYMR7ZP.cjs.map} +1 -1
- package/dist/{chunk-UXDNSZAD.js → chunk-TUALNYW2.js} +2 -2
- package/dist/index.cjs +195 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -14
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +5 -5
- package/dist/test/index.js +3 -3
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7VYSJIXD.cjs.map +0 -1
- package/dist/chunk-W3PHEA5Q.js.map +0 -1
- /package/dist/{chunk-UXDNSZAD.js.map → chunk-TUALNYW2.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
var
|
|
42
|
+
var _chunkQWYMR7ZPcjs = require('./chunk-QWYMR7ZP.cjs');
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ var _chunkLN3OP4OLcjs = require('./chunk-LN3OP4OL.cjs');
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunkD7LQNOEVcjs = require('./chunk-D7LQNOEV.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
@@ -83,24 +83,24 @@ var _chunkPZQXTGWFcjs = require('./chunk-PZQXTGWF.cjs');
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
var
|
|
86
|
+
var _chunkQFYPSI6Pcjs = require('./chunk-QFYPSI6P.cjs');
|
|
87
87
|
|
|
88
88
|
// src/signals.ts
|
|
89
89
|
process.once("SIGINT", async (arg) => {
|
|
90
|
-
|
|
91
|
-
await
|
|
90
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
91
|
+
await _chunkQWYMR7ZPcjs.disposeAndExit.call(void 0, "EXIT");
|
|
92
92
|
});
|
|
93
93
|
process.once("SIGTERM", async (arg) => {
|
|
94
|
-
|
|
95
|
-
await
|
|
94
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
95
|
+
await _chunkQWYMR7ZPcjs.disposeAndExit.call(void 0, "EXIT");
|
|
96
96
|
});
|
|
97
97
|
process.once("uncaughtException", async (arg) => {
|
|
98
|
-
|
|
99
|
-
await
|
|
98
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
99
|
+
await _chunkQWYMR7ZPcjs.disposeAndExit.call(void 0, "ERROR");
|
|
100
100
|
});
|
|
101
101
|
process.once("unhandledRejection", async (arg) => {
|
|
102
|
-
|
|
103
|
-
await
|
|
102
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
103
|
+
await _chunkQWYMR7ZPcjs.disposeAndExit.call(void 0, "ERROR");
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
// src/act.ts
|
|
@@ -208,7 +208,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
208
208
|
if (need_stats) {
|
|
209
209
|
const stats = await deps.store().query_stats(
|
|
210
210
|
{},
|
|
211
|
-
{ count: true, names: true, exclude: [
|
|
211
|
+
{ count: true, names: true, exclude: [_chunkQFYPSI6Pcjs.SNAP_EVENT] }
|
|
212
212
|
);
|
|
213
213
|
for (const [stream, s] of stats) {
|
|
214
214
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -290,7 +290,7 @@ var make_schema_pass = (deps) => {
|
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
const schema = state2.events[name];
|
|
293
|
-
const sensitive2 =
|
|
293
|
+
const sensitive2 = _chunkQFYPSI6Pcjs.sensitiveFields.call(void 0, schema);
|
|
294
294
|
let parse_schema = schema;
|
|
295
295
|
if (sensitive2.length > 0) {
|
|
296
296
|
const omitter = schema.omit;
|
|
@@ -424,7 +424,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
424
424
|
{
|
|
425
425
|
stream,
|
|
426
426
|
stream_exact: true,
|
|
427
|
-
names: [
|
|
427
|
+
names: [_chunkQFYPSI6Pcjs.SNAP_EVENT],
|
|
428
428
|
with_snaps: true,
|
|
429
429
|
// From the start: on its own, `with_snaps` resumes at the latest.
|
|
430
430
|
after: -1
|
|
@@ -584,7 +584,7 @@ var make_correlation_gaps_pass = () => {
|
|
|
584
584
|
seen_ids.add(e.id);
|
|
585
585
|
const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
|
|
586
586
|
const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
|
|
587
|
-
if (parent_id !== void 0 && e.name !==
|
|
587
|
+
if (parent_id !== void 0 && e.name !== _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) {
|
|
588
588
|
checks.push({ stream: e.stream, id: e.id, parent_id });
|
|
589
589
|
}
|
|
590
590
|
},
|
|
@@ -967,7 +967,7 @@ function make_deferred(handler, schedule) {
|
|
|
967
967
|
const call = handler;
|
|
968
968
|
const deferred = async (event, stream, app) => {
|
|
969
969
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
970
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
970
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkQFYPSI6Pcjs.DeferSignal)(when);
|
|
971
971
|
return call(event, stream, app);
|
|
972
972
|
};
|
|
973
973
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -1099,7 +1099,7 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1099
1099
|
function report_once(seen, key, message) {
|
|
1100
1100
|
if (seen.has(key)) return;
|
|
1101
1101
|
seen.add(key);
|
|
1102
|
-
|
|
1102
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).error(new Error(message));
|
|
1103
1103
|
}
|
|
1104
1104
|
|
|
1105
1105
|
// src/internal/correlation-id.ts
|
|
@@ -1127,14 +1127,14 @@ function close_correlation(correlator, actor) {
|
|
|
1127
1127
|
}
|
|
1128
1128
|
|
|
1129
1129
|
// src/internal/drain-ops.ts
|
|
1130
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1130
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkQWYMR7ZPcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1131
1131
|
async function fetch(leased, eventLimit) {
|
|
1132
1132
|
return Promise.all(
|
|
1133
1133
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1134
1134
|
const events = [];
|
|
1135
|
-
const stream_exact = source !== void 0 &&
|
|
1135
|
+
const stream_exact = source !== void 0 && _chunkD7LQNOEVcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1136
1136
|
try {
|
|
1137
|
-
await
|
|
1137
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1138
1138
|
stream: source,
|
|
1139
1139
|
stream_exact,
|
|
1140
1140
|
after: at,
|
|
@@ -1154,9 +1154,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1154
1154
|
})
|
|
1155
1155
|
);
|
|
1156
1156
|
}
|
|
1157
|
-
var ack = (leases) =>
|
|
1158
|
-
var block = (leases) =>
|
|
1159
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1157
|
+
var ack = (leases) => _chunkQWYMR7ZPcjs.store.call(void 0, ).ack(leases);
|
|
1158
|
+
var block = (leases) => _chunkQWYMR7ZPcjs.store.call(void 0, ).block(leases);
|
|
1159
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkQWYMR7ZPcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1160
1160
|
|
|
1161
1161
|
// src/internal/event-sourcing.ts
|
|
1162
1162
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1171,29 +1171,29 @@ var check_invariants = (target, state2, schema, pii_aware) => {
|
|
|
1171
1171
|
try {
|
|
1172
1172
|
result = schema.safeParse(state2);
|
|
1173
1173
|
} catch (error) {
|
|
1174
|
-
throw new (0,
|
|
1174
|
+
throw new (0, _chunkQFYPSI6Pcjs.ValidationError)(target, state2, error);
|
|
1175
1175
|
}
|
|
1176
1176
|
if (result.success) return;
|
|
1177
1177
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1178
1178
|
const value = value_at(state2, issue.path);
|
|
1179
|
-
return value !==
|
|
1179
|
+
return value !== _chunkQFYPSI6Pcjs.REDACTED && value !== _chunkQFYPSI6Pcjs.SHREDDED;
|
|
1180
1180
|
}) : result.error.issues;
|
|
1181
1181
|
if (issues.length)
|
|
1182
|
-
throw new (0,
|
|
1182
|
+
throw new (0, _chunkQFYPSI6Pcjs.ValidationError)(
|
|
1183
1183
|
target,
|
|
1184
1184
|
state2,
|
|
1185
1185
|
_zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
|
|
1186
1186
|
);
|
|
1187
1187
|
};
|
|
1188
1188
|
var DEFAULT_BATCH = 500;
|
|
1189
|
-
var cache_put = (stream, entry) =>
|
|
1190
|
-
(err) =>
|
|
1189
|
+
var cache_put = (stream, entry) => _chunkQWYMR7ZPcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1190
|
+
(err) => _chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1191
1191
|
err,
|
|
1192
1192
|
"cache set skipped; the next load re-folds from the store"
|
|
1193
1193
|
)
|
|
1194
1194
|
);
|
|
1195
|
-
var cache_drop = (stream) =>
|
|
1196
|
-
(err) =>
|
|
1195
|
+
var cache_drop = (stream) => _chunkQWYMR7ZPcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1196
|
+
(err) => _chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1197
1197
|
err,
|
|
1198
1198
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1199
1199
|
)
|
|
@@ -1201,11 +1201,11 @@ var cache_drop = (stream) => _chunkLN3OP4OLcjs.cache.call(void 0, ).invalidate(s
|
|
|
1201
1201
|
async function snap(snapshot) {
|
|
1202
1202
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1203
1203
|
try {
|
|
1204
|
-
const [committed] = await
|
|
1204
|
+
const [committed] = await _chunkQWYMR7ZPcjs.store.call(void 0, ).commit(
|
|
1205
1205
|
[
|
|
1206
1206
|
{
|
|
1207
1207
|
stream,
|
|
1208
|
-
msgs: [{ name:
|
|
1208
|
+
msgs: [{ name: _chunkQFYPSI6Pcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1209
1209
|
// IMPORTANT! - state events are committed right after the snapshot event
|
|
1210
1210
|
expectedVersion: version
|
|
1211
1211
|
}
|
|
@@ -1218,18 +1218,18 @@ async function snap(snapshot) {
|
|
|
1218
1218
|
return committed;
|
|
1219
1219
|
} catch (error) {
|
|
1220
1220
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1221
|
-
|
|
1221
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1222
1222
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1223
1223
|
);
|
|
1224
1224
|
}
|
|
1225
1225
|
}
|
|
1226
1226
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1227
1227
|
try {
|
|
1228
|
-
const [committed] = await
|
|
1228
|
+
const [committed] = await _chunkQWYMR7ZPcjs.store.call(void 0, ).commit(
|
|
1229
1229
|
[
|
|
1230
1230
|
{
|
|
1231
1231
|
stream,
|
|
1232
|
-
msgs: [{ name:
|
|
1232
|
+
msgs: [{ name: _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1233
1233
|
expectedVersion
|
|
1234
1234
|
}
|
|
1235
1235
|
],
|
|
@@ -1237,7 +1237,7 @@ async function tombstone(stream, expectedVersion, correlation) {
|
|
|
1237
1237
|
);
|
|
1238
1238
|
return committed;
|
|
1239
1239
|
} catch (error) {
|
|
1240
|
-
if (error instanceof
|
|
1240
|
+
if (error instanceof _chunkQFYPSI6Pcjs.ConcurrencyError) return void 0;
|
|
1241
1241
|
throw error;
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
@@ -1263,13 +1263,14 @@ async function scan(source, opts = {}, callback) {
|
|
|
1263
1263
|
let migrated_count = 0;
|
|
1264
1264
|
let processed = 0;
|
|
1265
1265
|
let at;
|
|
1266
|
+
const started = /* @__PURE__ */ new Set();
|
|
1266
1267
|
const closed_streams = /* @__PURE__ */ new Set();
|
|
1267
1268
|
if (drop_closed_streams) {
|
|
1268
1269
|
await source.query(
|
|
1269
1270
|
(e) => {
|
|
1270
|
-
if (e.name ===
|
|
1271
|
+
if (e.name === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1271
1272
|
},
|
|
1272
|
-
{ names: [
|
|
1273
|
+
{ names: [_chunkQFYPSI6Pcjs.TOMBSTONE_EVENT] }
|
|
1273
1274
|
);
|
|
1274
1275
|
}
|
|
1275
1276
|
let max_id;
|
|
@@ -1291,11 +1292,13 @@ async function scan(source, opts = {}, callback) {
|
|
|
1291
1292
|
if (!is_valid(event))
|
|
1292
1293
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1293
1294
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1294
|
-
|
|
1295
|
+
const has_history = started.has(event.stream);
|
|
1296
|
+
started.add(event.stream);
|
|
1297
|
+
if (drop_snapshots && event.name === _chunkQFYPSI6Pcjs.SNAP_EVENT && has_history) {
|
|
1295
1298
|
dropped_snaps++;
|
|
1296
1299
|
return;
|
|
1297
1300
|
}
|
|
1298
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1301
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) {
|
|
1299
1302
|
dropped_closed++;
|
|
1300
1303
|
return;
|
|
1301
1304
|
}
|
|
@@ -1368,18 +1371,18 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1368
1371
|
const { stream, actor, asOf } = target;
|
|
1369
1372
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1370
1373
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1371
|
-
const cached = time_travel ? void 0 : await
|
|
1374
|
+
const cached = time_travel ? void 0 : await _chunkQWYMR7ZPcjs.cache.call(void 0, ).get(stream);
|
|
1372
1375
|
const cache_hit = !!cached;
|
|
1373
1376
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _52 => _52.state]), () => ( (me.init ? me.init() : {})));
|
|
1374
1377
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _53 => _53.patches]), () => ( 0));
|
|
1375
1378
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _54 => _54.snaps]), () => ( 0));
|
|
1376
1379
|
let replayed = 0;
|
|
1377
1380
|
let event;
|
|
1378
|
-
await
|
|
1381
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query(
|
|
1379
1382
|
(raw) => {
|
|
1380
|
-
if (seeded && raw.name ===
|
|
1383
|
+
if (seeded && raw.name === _chunkQFYPSI6Pcjs.SNAP_EVENT && replayed > 0) return;
|
|
1381
1384
|
event = me.view(raw, actor);
|
|
1382
|
-
if (event.name ===
|
|
1385
|
+
if (event.name === _chunkQFYPSI6Pcjs.SNAP_EVENT) {
|
|
1383
1386
|
state2 = event.data;
|
|
1384
1387
|
snaps++;
|
|
1385
1388
|
patches = 0;
|
|
@@ -1388,8 +1391,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1388
1391
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1389
1392
|
patches++;
|
|
1390
1393
|
replayed++;
|
|
1391
|
-
} else if (event.name !==
|
|
1392
|
-
|
|
1394
|
+
} else if (event.name !== _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) {
|
|
1395
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1393
1396
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1394
1397
|
);
|
|
1395
1398
|
}
|
|
@@ -1417,7 +1420,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1417
1420
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1418
1421
|
}
|
|
1419
1422
|
);
|
|
1420
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _56 => _56.name]) ===
|
|
1423
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _56 => _56.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT;
|
|
1421
1424
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1422
1425
|
await cache_put(stream, {
|
|
1423
1426
|
stream,
|
|
@@ -1460,8 +1463,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1460
1463
|
void 0,
|
|
1461
1464
|
patch_fn
|
|
1462
1465
|
);
|
|
1463
|
-
if (_optionalChain([snapshot, 'access', _61 => _61.event, 'optionalAccess', _62 => _62.name]) ===
|
|
1464
|
-
throw new (0,
|
|
1466
|
+
if (_optionalChain([snapshot, 'access', _61 => _61.event, 'optionalAccess', _62 => _62.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT)
|
|
1467
|
+
throw new (0, _chunkQFYPSI6Pcjs.StreamClosedError)(stream);
|
|
1465
1468
|
return {
|
|
1466
1469
|
state: l.state,
|
|
1467
1470
|
stream,
|
|
@@ -1477,7 +1480,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1477
1480
|
if (!stream) throw new Error("Missing target stream");
|
|
1478
1481
|
const reactingTo = _optionalChain([options, 'optionalAccess', _63 => _63.reactingTo]);
|
|
1479
1482
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _64 => _64.correlator]), () => ( default_correlator));
|
|
1480
|
-
const validated =
|
|
1483
|
+
const validated = _chunkQWYMR7ZPcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1481
1484
|
const opts = _optionalChain([me, 'access', _65 => _65.options, 'optionalAccess', _66 => _66[action2]]);
|
|
1482
1485
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _67 => _67.maxRetries]), () => ( 0));
|
|
1483
1486
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _68 => _68.loads, 'optionalAccess', _69 => _69[action2]]), () => ( []));
|
|
@@ -1489,8 +1492,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1489
1492
|
void 0,
|
|
1490
1493
|
patch_fn
|
|
1491
1494
|
);
|
|
1492
|
-
if (_optionalChain([snapshot, 'access', _70 => _70.event, 'optionalAccess', _71 => _71.name]) ===
|
|
1493
|
-
throw new (0,
|
|
1495
|
+
if (_optionalChain([snapshot, 'access', _70 => _70.event, 'optionalAccess', _71 => _71.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT)
|
|
1496
|
+
throw new (0, _chunkQFYPSI6Pcjs.StreamClosedError)(stream);
|
|
1494
1497
|
const own = {
|
|
1495
1498
|
state: me,
|
|
1496
1499
|
stream,
|
|
@@ -1504,7 +1507,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1504
1507
|
{ stream, state: snapshot.state },
|
|
1505
1508
|
target.actor,
|
|
1506
1509
|
patch_fn,
|
|
1507
|
-
(description) => new (0,
|
|
1510
|
+
(description) => new (0, _chunkQFYPSI6Pcjs.PreconditionError)(
|
|
1508
1511
|
action2,
|
|
1509
1512
|
validated,
|
|
1510
1513
|
target,
|
|
@@ -1517,7 +1520,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1517
1520
|
);
|
|
1518
1521
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _74 => _74.requires, 'optionalAccess', _75 => _75[action2]]), () => ( [])))
|
|
1519
1522
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1520
|
-
throw new (0,
|
|
1523
|
+
throw new (0, _chunkQFYPSI6Pcjs.PreconditionError)(
|
|
1521
1524
|
action2,
|
|
1522
1525
|
validated,
|
|
1523
1526
|
target,
|
|
@@ -1539,7 +1542,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1539
1542
|
);
|
|
1540
1543
|
to.events.push({
|
|
1541
1544
|
name: event,
|
|
1542
|
-
data:
|
|
1545
|
+
data: _chunkQWYMR7ZPcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1543
1546
|
});
|
|
1544
1547
|
}
|
|
1545
1548
|
if (!own.events.length)
|
|
@@ -1596,7 +1599,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1596
1599
|
});
|
|
1597
1600
|
let committed;
|
|
1598
1601
|
try {
|
|
1599
|
-
committed = await
|
|
1602
|
+
committed = await _chunkQWYMR7ZPcjs.store.call(void 0, ).commit(
|
|
1600
1603
|
appends.map((p) => ({
|
|
1601
1604
|
stream: p.stream,
|
|
1602
1605
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1605,7 +1608,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1605
1608
|
meta
|
|
1606
1609
|
);
|
|
1607
1610
|
} catch (error) {
|
|
1608
|
-
if (error instanceof
|
|
1611
|
+
if (error instanceof _chunkQFYPSI6Pcjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1609
1612
|
throw error;
|
|
1610
1613
|
}
|
|
1611
1614
|
let row = 0;
|
|
@@ -1647,19 +1650,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1647
1650
|
}
|
|
1648
1651
|
return snapshots;
|
|
1649
1652
|
} catch (error) {
|
|
1650
|
-
if (!(error instanceof
|
|
1653
|
+
if (!(error instanceof _chunkQFYPSI6Pcjs.ConcurrencyError)) throw error;
|
|
1651
1654
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1652
1655
|
if (attempt >= max_retries) throw error;
|
|
1653
1656
|
if (_optionalChain([opts, 'optionalAccess', _84 => _84.backoff])) {
|
|
1654
1657
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1655
|
-
if (delay_ms > 0) await
|
|
1658
|
+
if (delay_ms > 0) await _chunkQWYMR7ZPcjs.sleep.call(void 0, delay_ms);
|
|
1656
1659
|
}
|
|
1657
1660
|
}
|
|
1658
1661
|
}
|
|
1659
1662
|
}
|
|
1660
1663
|
|
|
1661
1664
|
// src/internal/tracing.ts
|
|
1662
|
-
var PRETTY =
|
|
1665
|
+
var PRETTY = _chunkQWYMR7ZPcjs.config.call(void 0, ).env !== "production";
|
|
1663
1666
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1664
1667
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1665
1668
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1843,7 +1846,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
1843
1846
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _95 => _95.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1844
1847
|
return void 0;
|
|
1845
1848
|
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.`;
|
|
1846
|
-
|
|
1849
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).error(error);
|
|
1847
1850
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1848
1851
|
}
|
|
1849
1852
|
function fetch_failure_policy(registry) {
|
|
@@ -1859,13 +1862,13 @@ function fetch_failure_policy(registry) {
|
|
|
1859
1862
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1860
1863
|
if (!error) return { lease, handled, acked_at: at };
|
|
1861
1864
|
logger.error(error);
|
|
1862
|
-
const non_retryable = error instanceof
|
|
1865
|
+
const non_retryable = error instanceof _chunkQFYPSI6Pcjs.NonRetryableError;
|
|
1863
1866
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
1864
1867
|
if (block2)
|
|
1865
1868
|
logger.error(
|
|
1866
1869
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1867
1870
|
);
|
|
1868
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
1871
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkQWYMR7ZPcjs.DEFAULT_BACKOFF)));
|
|
1869
1872
|
return {
|
|
1870
1873
|
lease,
|
|
1871
1874
|
handled,
|
|
@@ -1993,7 +1996,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
1993
1996
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
1994
1997
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
1995
1998
|
if (acked.length < expected)
|
|
1996
|
-
|
|
1999
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1997
2000
|
`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.`
|
|
1998
2001
|
);
|
|
1999
2002
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2089,9 +2092,9 @@ var DrainController = (_class3 = class {
|
|
|
2089
2092
|
if (!this.armed || this._stopped || this._inflight)
|
|
2090
2093
|
return EMPTY_DRAIN;
|
|
2091
2094
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2092
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2093
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2094
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2095
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkQWYMR7ZPcjs.DEFAULT_STREAM_LIMIT));
|
|
2096
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkQWYMR7ZPcjs.DEFAULT_EVENT_LIMIT));
|
|
2097
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkQWYMR7ZPcjs.DEFAULT_LEASE_MILLIS));
|
|
2095
2098
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2096
2099
|
return EMPTY_DRAIN;
|
|
2097
2100
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2217,7 +2220,7 @@ function build_handle(deps) {
|
|
|
2217
2220
|
handled++;
|
|
2218
2221
|
}
|
|
2219
2222
|
} catch (error) {
|
|
2220
|
-
if (error instanceof
|
|
2223
|
+
if (error instanceof _chunkQFYPSI6Pcjs.DeferSignal) {
|
|
2221
2224
|
let defer;
|
|
2222
2225
|
try {
|
|
2223
2226
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2314,22 +2317,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2314
2317
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2315
2318
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2316
2319
|
// autoclose: `app.close` still closes it.
|
|
2317
|
-
resolver: (e) =>
|
|
2320
|
+
resolver: (e) => _chunkD7LQNOEVcjs.isStreamName.call(void 0, e.stream) ? {
|
|
2318
2321
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2319
2322
|
source: e.stream
|
|
2320
2323
|
} : void 0,
|
|
2321
2324
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2322
2325
|
// not quarantine the synthetic stream.
|
|
2323
|
-
options: { blockOnError: false, maxRetries:
|
|
2326
|
+
options: { blockOnError: false, maxRetries: _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES },
|
|
2324
2327
|
handler: async (event) => {
|
|
2325
2328
|
const aggregate = event.stream;
|
|
2326
2329
|
const window = read_window();
|
|
2327
2330
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2328
|
-
throw new (0,
|
|
2329
|
-
const stats = await
|
|
2331
|
+
throw new (0, _chunkQFYPSI6Pcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2332
|
+
const stats = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2330
2333
|
count: true,
|
|
2331
2334
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2332
|
-
exclude: [
|
|
2335
|
+
exclude: [_chunkQFYPSI6Pcjs.TOMBSTONE_EVENT, _chunkQFYPSI6Pcjs.SNAP_EVENT]
|
|
2333
2336
|
});
|
|
2334
2337
|
const entry = stats.get(aggregate);
|
|
2335
2338
|
if (!entry) return;
|
|
@@ -2365,7 +2368,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2365
2368
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2366
2369
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2367
2370
|
if (future.length)
|
|
2368
|
-
throw new (0,
|
|
2371
|
+
throw new (0, _chunkQFYPSI6Pcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2369
2372
|
}
|
|
2370
2373
|
};
|
|
2371
2374
|
const key = `__autoclose_${st.name}`;
|
|
@@ -2425,7 +2428,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
2425
2428
|
deps,
|
|
2426
2429
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2427
2430
|
);
|
|
2428
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2431
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2429
2432
|
if (retired.length) _optionalChain([deps, 'access', _122 => _122.forget_subscribed, 'optionalCall', _123 => _123(retired)]);
|
|
2430
2433
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2431
2434
|
return { truncated, skipped };
|
|
@@ -2507,7 +2510,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2507
2510
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2508
2511
|
return void 0;
|
|
2509
2512
|
if (t.archive) await t.archive();
|
|
2510
|
-
const result = await
|
|
2513
|
+
const result = await _chunkQWYMR7ZPcjs.store.call(void 0, ).truncate([
|
|
2511
2514
|
{ stream: t.stream, before: t.before, max_id }
|
|
2512
2515
|
]);
|
|
2513
2516
|
return result.get(t.stream);
|
|
@@ -2520,10 +2523,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2520
2523
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2521
2524
|
let boundary_id;
|
|
2522
2525
|
let min_id;
|
|
2523
|
-
await
|
|
2526
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query(
|
|
2524
2527
|
(event) => {
|
|
2525
2528
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2526
|
-
if (event.name ===
|
|
2529
|
+
if (event.name === _chunkQFYPSI6Pcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
2527
2530
|
boundary_id = event.id;
|
|
2528
2531
|
},
|
|
2529
2532
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -2534,7 +2537,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2534
2537
|
const min_at = /* @__PURE__ */ new Map();
|
|
2535
2538
|
const matches = source_matcher();
|
|
2536
2539
|
await walk_streams(
|
|
2537
|
-
|
|
2540
|
+
_chunkQWYMR7ZPcjs.store.call(void 0, ),
|
|
2538
2541
|
(position) => {
|
|
2539
2542
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2540
2543
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2553,7 +2556,7 @@ function source_matcher() {
|
|
|
2553
2556
|
const compiled = /* @__PURE__ */ new Map();
|
|
2554
2557
|
return (source, target, stream) => {
|
|
2555
2558
|
if (!source) return true;
|
|
2556
|
-
if (
|
|
2559
|
+
if (_chunkD7LQNOEVcjs.isStreamName.call(void 0, source, target)) return source === stream;
|
|
2557
2560
|
let re = compiled.get(source);
|
|
2558
2561
|
if (!re) {
|
|
2559
2562
|
re = new RegExp(source);
|
|
@@ -2563,17 +2566,17 @@ function source_matcher() {
|
|
|
2563
2566
|
};
|
|
2564
2567
|
}
|
|
2565
2568
|
async function scan_stream_heads(streams) {
|
|
2566
|
-
const stats = await
|
|
2567
|
-
exclude: [
|
|
2569
|
+
const stats = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(streams, {
|
|
2570
|
+
exclude: [_chunkQFYPSI6Pcjs.SNAP_EVENT]
|
|
2568
2571
|
});
|
|
2569
|
-
const domain_heads = await
|
|
2570
|
-
exclude: [
|
|
2572
|
+
const domain_heads = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(streams, {
|
|
2573
|
+
exclude: [_chunkQFYPSI6Pcjs.SNAP_EVENT, _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT]
|
|
2571
2574
|
});
|
|
2572
|
-
const true_heads = await
|
|
2575
|
+
const true_heads = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2573
2576
|
const out = /* @__PURE__ */ new Map();
|
|
2574
2577
|
for (const [stream, { head }] of domain_heads) {
|
|
2575
2578
|
const marker_head = _optionalChain([stats, 'access', _125 => _125.get, 'call', _126 => _126(stream), 'optionalAccess', _127 => _127.head]);
|
|
2576
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess', _128 => _128.name]) ===
|
|
2579
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _128 => _128.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT;
|
|
2577
2580
|
out.set(stream, {
|
|
2578
2581
|
max_id: head.id,
|
|
2579
2582
|
version: true_heads.get(stream).head.version,
|
|
@@ -2596,7 +2599,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2596
2599
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2597
2600
|
const matches = source_matcher();
|
|
2598
2601
|
await walk_streams(
|
|
2599
|
-
|
|
2602
|
+
_chunkQWYMR7ZPcjs.store.call(void 0, ),
|
|
2600
2603
|
(position) => {
|
|
2601
2604
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2602
2605
|
if (!has_work) return;
|
|
@@ -2663,7 +2666,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
2663
2666
|
}
|
|
2664
2667
|
}
|
|
2665
2668
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2666
|
-
const heads = await
|
|
2669
|
+
const heads = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2667
2670
|
return guarded.filter((stream) => {
|
|
2668
2671
|
if (_optionalChain([heads, 'access', _135 => _135.get, 'call', _136 => _136(stream), 'optionalAccess', _137 => _137.head, 'access', _138 => _138.id]) === guard_events.get(stream).id)
|
|
2669
2672
|
return true;
|
|
@@ -2681,18 +2684,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2681
2684
|
meta: {
|
|
2682
2685
|
correlation,
|
|
2683
2686
|
causation: {
|
|
2684
|
-
event: { id: guard.id, name:
|
|
2687
|
+
event: { id: guard.id, name: _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2685
2688
|
}
|
|
2686
2689
|
}
|
|
2687
2690
|
};
|
|
2688
2691
|
});
|
|
2689
|
-
const truncated = await
|
|
2692
|
+
const truncated = await _chunkQWYMR7ZPcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2690
2693
|
await Promise.all(
|
|
2691
2694
|
guarded.map(async (stream) => {
|
|
2692
2695
|
const entry = truncated.get(stream);
|
|
2693
2696
|
const state2 = seed_states.get(stream);
|
|
2694
2697
|
if (state2 && entry) {
|
|
2695
|
-
await
|
|
2698
|
+
await _chunkQWYMR7ZPcjs.cache.call(void 0, ).set(stream, {
|
|
2696
2699
|
stream,
|
|
2697
2700
|
state: state2,
|
|
2698
2701
|
version: entry.committed.version,
|
|
@@ -2701,7 +2704,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2701
2704
|
snaps: 1
|
|
2702
2705
|
});
|
|
2703
2706
|
} else {
|
|
2704
|
-
await
|
|
2707
|
+
await _chunkQWYMR7ZPcjs.cache.call(void 0, ).invalidate(stream);
|
|
2705
2708
|
}
|
|
2706
2709
|
})
|
|
2707
2710
|
);
|
|
@@ -2727,8 +2730,8 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
|
|
|
2727
2730
|
function report_bad_priority(seen, handler, target, priority) {
|
|
2728
2731
|
report_once(
|
|
2729
2732
|
seen,
|
|
2730
|
-
`priority|${handler}
|
|
2731
|
-
`Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer.
|
|
2733
|
+
`priority|${handler}`,
|
|
2734
|
+
`Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer. Running it at priority 0 instead. The equivalent static \`.to({ priority })\` is rejected at build; a dynamic resolver's priority is only knowable here.`
|
|
2732
2735
|
);
|
|
2733
2736
|
}
|
|
2734
2737
|
function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
@@ -2760,7 +2763,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2760
2763
|
// never lets a resolution re-lane them.
|
|
2761
2764
|
|
|
2762
2765
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2763
|
-
__init19() {this._patterns = new (0,
|
|
2766
|
+
__init19() {this._patterns = new (0, _chunkQWYMR7ZPcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2764
2767
|
|
|
2765
2768
|
|
|
2766
2769
|
|
|
@@ -2778,7 +2781,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2778
2781
|
on_init
|
|
2779
2782
|
}) {;_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);
|
|
2780
2783
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2781
|
-
this._dynamic_subscriptions = new (0,
|
|
2784
|
+
this._dynamic_subscriptions = new (0, _chunkQWYMR7ZPcjs.LruMap)(max_subscribed_streams);
|
|
2782
2785
|
this._registry = registry;
|
|
2783
2786
|
this._declared_lanes = declared_lanes;
|
|
2784
2787
|
this._static_targets = static_targets;
|
|
@@ -2836,7 +2839,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2836
2839
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
2837
2840
|
_in_fetch_window(source, stream) {
|
|
2838
2841
|
if (source === void 0 || source === stream) return true;
|
|
2839
|
-
if (
|
|
2842
|
+
if (_chunkD7LQNOEVcjs.isStreamName.call(void 0, source)) return false;
|
|
2840
2843
|
let pattern = this._patterns.get(source);
|
|
2841
2844
|
if (!pattern) {
|
|
2842
2845
|
pattern = new RegExp(source);
|
|
@@ -2879,7 +2882,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2879
2882
|
const correlated = /* @__PURE__ */ new Map();
|
|
2880
2883
|
let last_id = after;
|
|
2881
2884
|
let stopped = false;
|
|
2882
|
-
const found = await
|
|
2885
|
+
const found = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query(
|
|
2883
2886
|
(event) => {
|
|
2884
2887
|
if (stopped) return;
|
|
2885
2888
|
const register = this._registry.events[event.name];
|
|
@@ -2898,14 +2901,14 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2898
2901
|
return;
|
|
2899
2902
|
}
|
|
2900
2903
|
if (!resolved) continue;
|
|
2901
|
-
if (!
|
|
2904
|
+
if (!_chunkQWYMR7ZPcjs.is_valid_target.call(void 0, resolved)) {
|
|
2902
2905
|
report_bad_priority(
|
|
2903
2906
|
this._reported,
|
|
2904
2907
|
reaction.handler.name,
|
|
2905
2908
|
resolved.target,
|
|
2906
2909
|
resolved.priority
|
|
2907
2910
|
);
|
|
2908
|
-
|
|
2911
|
+
resolved = { ...resolved, priority: 0 };
|
|
2909
2912
|
}
|
|
2910
2913
|
let lane = resolved.lane;
|
|
2911
2914
|
if (lane !== void 0 && !this._declared_lanes.has(lane)) {
|
|
@@ -2933,9 +2936,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2933
2936
|
correlated_at: void 0
|
|
2934
2937
|
};
|
|
2935
2938
|
const seen_in_scan = correlated.has(resolved.target);
|
|
2936
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _141 => _141.lane])), () => (
|
|
2939
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _141 => _141.lane])), () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
2937
2940
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _142 => _142.priority]);
|
|
2938
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
2941
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
2939
2942
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
2940
2943
|
report_lane_conflict(
|
|
2941
2944
|
this._reported,
|
|
@@ -3009,7 +3012,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3009
3012
|
await Promise.all(
|
|
3010
3013
|
missed.map(async ([stream, entry]) => {
|
|
3011
3014
|
let row;
|
|
3012
|
-
await
|
|
3015
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_streams(
|
|
3013
3016
|
(position) => {
|
|
3014
3017
|
row = position;
|
|
3015
3018
|
},
|
|
@@ -3021,8 +3024,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3021
3024
|
lane: row.lane
|
|
3022
3025
|
});
|
|
3023
3026
|
if (entry.priority > row.priority) return;
|
|
3024
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3025
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3027
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
3028
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
3026
3029
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3027
3030
|
report_lane_conflict(
|
|
3028
3031
|
this._reported,
|
|
@@ -3048,7 +3051,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3048
3051
|
millis: 0
|
|
3049
3052
|
});
|
|
3050
3053
|
} catch (error) {
|
|
3051
|
-
|
|
3054
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
3052
3055
|
`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)))}`
|
|
3053
3056
|
);
|
|
3054
3057
|
}
|
|
@@ -3072,7 +3075,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3072
3075
|
const { pii, ...rest } = event;
|
|
3073
3076
|
if (pii == null) {
|
|
3074
3077
|
const shredded = { ...data };
|
|
3075
|
-
for (const f of fields) shredded[f] =
|
|
3078
|
+
for (const f of fields) shredded[f] = _chunkQFYPSI6Pcjs.SHREDDED;
|
|
3076
3079
|
return { ...rest, data: shredded };
|
|
3077
3080
|
}
|
|
3078
3081
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3083,7 +3086,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3083
3086
|
};
|
|
3084
3087
|
}
|
|
3085
3088
|
const redacted = { ...data };
|
|
3086
|
-
for (const f of fields) redacted[f] =
|
|
3089
|
+
for (const f of fields) redacted[f] = _chunkQFYPSI6Pcjs.REDACTED;
|
|
3087
3090
|
return { ...rest, data: redacted };
|
|
3088
3091
|
}
|
|
3089
3092
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -3385,7 +3388,7 @@ var Act = (_class7 = class {
|
|
|
3385
3388
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3386
3389
|
|
|
3387
3390
|
|
|
3388
|
-
__init27() {this._logger =
|
|
3391
|
+
__init27() {this._logger = _chunkQWYMR7ZPcjs.log.call(void 0, )}
|
|
3389
3392
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3390
3393
|
|
|
3391
3394
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3407,10 +3410,10 @@ var Act = (_class7 = class {
|
|
|
3407
3410
|
this._lanes = lanes;
|
|
3408
3411
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3409
3412
|
validate_only_lanes(options.onlyLanes, this._declared_lanes);
|
|
3410
|
-
if (options.scoped)
|
|
3411
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3413
|
+
if (options.scoped) _chunkQWYMR7ZPcjs.check_store.call(void 0, options.scoped.store);
|
|
3414
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkQWYMR7ZPcjs.unscoped_ports.call(void 0, )));
|
|
3412
3415
|
const ports = this._ports;
|
|
3413
|
-
this._scoped =
|
|
3416
|
+
this._scoped = _chunkQWYMR7ZPcjs.make_run_scoped.call(void 0, {
|
|
3414
3417
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3415
3418
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3416
3419
|
get store() {
|
|
@@ -3420,14 +3423,14 @@ var Act = (_class7 = class {
|
|
|
3420
3423
|
return ports.cache;
|
|
3421
3424
|
},
|
|
3422
3425
|
// Parsed per build, so a bad window throws on every build.
|
|
3423
|
-
autoclose_window:
|
|
3426
|
+
autoclose_window: _chunkQWYMR7ZPcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3424
3427
|
});
|
|
3425
3428
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3426
3429
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3427
3430
|
this._cd = build_drain(this._logger);
|
|
3428
3431
|
const handle = build_handle({
|
|
3429
3432
|
logger: this._logger,
|
|
3430
|
-
reaction_scope:
|
|
3433
|
+
reaction_scope: _chunkQWYMR7ZPcjs.make_reaction_scope.call(void 0, {
|
|
3431
3434
|
do: this.do.bind(this),
|
|
3432
3435
|
load: this.load.bind(this),
|
|
3433
3436
|
query: this.query.bind(this),
|
|
@@ -3457,12 +3460,12 @@ var Act = (_class7 = class {
|
|
|
3457
3460
|
this._ports.store,
|
|
3458
3461
|
options.listen !== false
|
|
3459
3462
|
);
|
|
3460
|
-
|
|
3463
|
+
_chunkQWYMR7ZPcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3461
3464
|
}
|
|
3462
3465
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3463
3466
|
_build_breaker(options) {
|
|
3464
3467
|
return new CircuitBreaker(
|
|
3465
|
-
|
|
3468
|
+
_chunkQWYMR7ZPcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3466
3469
|
{
|
|
3467
3470
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3468
3471
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3496,7 +3499,7 @@ var Act = (_class7 = class {
|
|
|
3496
3499
|
try {
|
|
3497
3500
|
await this._run_close(targets);
|
|
3498
3501
|
} catch (error) {
|
|
3499
|
-
if (error instanceof
|
|
3502
|
+
if (error instanceof _chunkQFYPSI6Pcjs.StoreError) throw error;
|
|
3500
3503
|
this._logger.error(
|
|
3501
3504
|
error,
|
|
3502
3505
|
`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.`
|
|
@@ -3530,7 +3533,7 @@ var Act = (_class7 = class {
|
|
|
3530
3533
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3531
3534
|
_build_audit_deps() {
|
|
3532
3535
|
return {
|
|
3533
|
-
store:
|
|
3536
|
+
store: _chunkQWYMR7ZPcjs.store,
|
|
3534
3537
|
event_to_state: this._event_to_state,
|
|
3535
3538
|
// Declared lanes, not this process's controllers: a lane another
|
|
3536
3539
|
// worker drains is not `unknown-lane`.
|
|
@@ -3543,7 +3546,7 @@ var Act = (_class7 = class {
|
|
|
3543
3546
|
registry: this.registry,
|
|
3544
3547
|
static_targets: classification.static_targets,
|
|
3545
3548
|
cd: this._cd,
|
|
3546
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3549
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkQFYPSI6Pcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3547
3550
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3548
3551
|
// still a valid destination.
|
|
3549
3552
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3559,7 +3562,7 @@ var Act = (_class7 = class {
|
|
|
3559
3562
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3560
3563
|
async _seed_persisted_defers() {
|
|
3561
3564
|
const now = Date.now();
|
|
3562
|
-
await walk_streams(
|
|
3565
|
+
await walk_streams(_chunkQWYMR7ZPcjs.store.call(void 0, ), (pos) => {
|
|
3563
3566
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3564
3567
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3565
3568
|
_optionalChain([controller, 'optionalAccess', _150 => _150.seed_defer, 'call', _151 => _151(pos.stream, pos.deferred_at)]);
|
|
@@ -3575,7 +3578,7 @@ var Act = (_class7 = class {
|
|
|
3575
3578
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3576
3579
|
breaker: this._breaker
|
|
3577
3580
|
},
|
|
3578
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3581
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkQFYPSI6Pcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3579
3582
|
);
|
|
3580
3583
|
}
|
|
3581
3584
|
|
|
@@ -3595,7 +3598,7 @@ var Act = (_class7 = class {
|
|
|
3595
3598
|
*/
|
|
3596
3599
|
shutdown(options) {
|
|
3597
3600
|
if (!this._shutdown_promise) {
|
|
3598
|
-
|
|
3601
|
+
_chunkQWYMR7ZPcjs.resolveShutdownConfig.call(void 0, options);
|
|
3599
3602
|
this._shutdown_promise = (async () => {
|
|
3600
3603
|
this.stop_correlations();
|
|
3601
3604
|
this._settle.stop(true);
|
|
@@ -3613,10 +3616,10 @@ var Act = (_class7 = class {
|
|
|
3613
3616
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3614
3617
|
// default for none or 0, and for a running settle), capped.
|
|
3615
3618
|
_derive_grace_ms(running, settling) {
|
|
3616
|
-
let max = settling ?
|
|
3619
|
+
let max = settling ? _chunkQWYMR7ZPcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3617
3620
|
for (const c of running)
|
|
3618
|
-
max = Math.max(max, c.lease_millis ||
|
|
3619
|
-
return Math.min(max,
|
|
3621
|
+
max = Math.max(max, c.lease_millis || _chunkQWYMR7ZPcjs.DEFAULT_LEASE_MILLIS);
|
|
3622
|
+
return Math.min(max, _chunkQWYMR7ZPcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3620
3623
|
}
|
|
3621
3624
|
async _await_inflight(grace_ms) {
|
|
3622
3625
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3700,7 +3703,7 @@ var Act = (_class7 = class {
|
|
|
3700
3703
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3701
3704
|
*/
|
|
3702
3705
|
async do(action2, target, payload, options) {
|
|
3703
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _153 => _153.reactingTo]), () => (
|
|
3706
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _153 => _153.reactingTo]), () => ( _chunkQWYMR7ZPcjs.current_reacting.call(void 0, )));
|
|
3704
3707
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _154 => _154.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3705
3708
|
return this._scoped(async () => {
|
|
3706
3709
|
const snapshots = await this._es.action(
|
|
@@ -3774,7 +3777,7 @@ var Act = (_class7 = class {
|
|
|
3774
3777
|
return this._scoped(async () => {
|
|
3775
3778
|
let first;
|
|
3776
3779
|
let last;
|
|
3777
|
-
const count = await
|
|
3780
|
+
const count = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query((e) => {
|
|
3778
3781
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3779
3782
|
if (!first) first = gated;
|
|
3780
3783
|
last = gated;
|
|
@@ -3802,13 +3805,9 @@ var Act = (_class7 = class {
|
|
|
3802
3805
|
* @see {@link query} for large result sets
|
|
3803
3806
|
*/
|
|
3804
3807
|
async query_array(query) {
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
events.push(this.registry.query_gate(e.name)(e));
|
|
3809
|
-
}, query);
|
|
3810
|
-
return events;
|
|
3811
|
-
});
|
|
3808
|
+
const events = [];
|
|
3809
|
+
await this.query(query, (e) => events.push(e));
|
|
3810
|
+
return events;
|
|
3812
3811
|
}
|
|
3813
3812
|
/**
|
|
3814
3813
|
* Wipe the sensitive-data payload for every event on the stream — see
|
|
@@ -3824,14 +3823,14 @@ var Act = (_class7 = class {
|
|
|
3824
3823
|
*/
|
|
3825
3824
|
async forget(stream) {
|
|
3826
3825
|
return this._scoped(async () => {
|
|
3827
|
-
const s =
|
|
3826
|
+
const s = _chunkQWYMR7ZPcjs.store.call(void 0, );
|
|
3828
3827
|
if (!s.forget_pii) {
|
|
3829
3828
|
throw new Error(
|
|
3830
3829
|
`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).`
|
|
3831
3830
|
);
|
|
3832
3831
|
}
|
|
3833
3832
|
const eventCount = await s.forget_pii(stream);
|
|
3834
|
-
await
|
|
3833
|
+
await _chunkQWYMR7ZPcjs.cache.call(void 0, ).invalidate(stream);
|
|
3835
3834
|
if (eventCount > 0) {
|
|
3836
3835
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3837
3836
|
}
|
|
@@ -3865,7 +3864,7 @@ var Act = (_class7 = class {
|
|
|
3865
3864
|
* @see {@link correlate} for dynamic stream discovery
|
|
3866
3865
|
*/
|
|
3867
3866
|
async drain(options = {}) {
|
|
3868
|
-
|
|
3867
|
+
_chunkQWYMR7ZPcjs.resolveDrainConfig.call(void 0, options);
|
|
3869
3868
|
if (!this._drain)
|
|
3870
3869
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3871
3870
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4045,7 +4044,7 @@ var Act = (_class7 = class {
|
|
|
4045
4044
|
*/
|
|
4046
4045
|
async reset(input) {
|
|
4047
4046
|
return this._scoped(async () => {
|
|
4048
|
-
const count = await
|
|
4047
|
+
const count = await _chunkQWYMR7ZPcjs.store.call(void 0, ).reset(input);
|
|
4049
4048
|
for (const handler of this._batch_handlers.values())
|
|
4050
4049
|
_optionalChain([handler, 'access', _161 => _161[FOLD_RESET], 'optionalCall', _162 => _162()]);
|
|
4051
4050
|
if (count > 0) {
|
|
@@ -4081,7 +4080,7 @@ var Act = (_class7 = class {
|
|
|
4081
4080
|
*/
|
|
4082
4081
|
async unblock(input) {
|
|
4083
4082
|
return this._scoped(async () => {
|
|
4084
|
-
const count = await
|
|
4083
|
+
const count = await _chunkQWYMR7ZPcjs.store.call(void 0, ).unblock(input);
|
|
4085
4084
|
if (count > 0) {
|
|
4086
4085
|
this._wake();
|
|
4087
4086
|
}
|
|
@@ -4136,7 +4135,7 @@ var Act = (_class7 = class {
|
|
|
4136
4135
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4137
4136
|
}
|
|
4138
4137
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4139
|
-
const s =
|
|
4138
|
+
const s = _chunkQWYMR7ZPcjs.store.call(void 0, );
|
|
4140
4139
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4141
4140
|
return s;
|
|
4142
4141
|
})()));
|
|
@@ -4182,7 +4181,7 @@ var Act = (_class7 = class {
|
|
|
4182
4181
|
async blocked_streams(options) {
|
|
4183
4182
|
return this._scoped(async () => {
|
|
4184
4183
|
const positions = [];
|
|
4185
|
-
await
|
|
4184
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_streams(
|
|
4186
4185
|
(p) => {
|
|
4187
4186
|
positions.push(p);
|
|
4188
4187
|
},
|
|
@@ -4235,8 +4234,8 @@ var Act = (_class7 = class {
|
|
|
4235
4234
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4236
4235
|
*/
|
|
4237
4236
|
async prioritize(filter, priority) {
|
|
4238
|
-
|
|
4239
|
-
return this._scoped(() =>
|
|
4237
|
+
_chunkQWYMR7ZPcjs.resolveTargetConfig.call(void 0, { priority });
|
|
4238
|
+
return this._scoped(() => _chunkQWYMR7ZPcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4240
4239
|
}
|
|
4241
4240
|
// Shared by `close()` and reaction-requested closes.
|
|
4242
4241
|
async _run_close(targets) {
|
|
@@ -4316,7 +4315,7 @@ var Act = (_class7 = class {
|
|
|
4316
4315
|
* @see {@link correlate} for manual correlation
|
|
4317
4316
|
*/
|
|
4318
4317
|
settle(options) {
|
|
4319
|
-
|
|
4318
|
+
_chunkQWYMR7ZPcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
4320
4319
|
this._schedule(options);
|
|
4321
4320
|
}
|
|
4322
4321
|
}, _class7);
|
|
@@ -4324,9 +4323,9 @@ var Act = (_class7 = class {
|
|
|
4324
4323
|
// src/builders/merge.ts
|
|
4325
4324
|
|
|
4326
4325
|
function base_type_name(schema) {
|
|
4327
|
-
let def =
|
|
4328
|
-
for (let inner =
|
|
4329
|
-
def =
|
|
4326
|
+
let def = _chunkQFYPSI6Pcjs.def_of.call(void 0, schema);
|
|
4327
|
+
for (let inner = _chunkQFYPSI6Pcjs.inner_of.call(void 0, def); inner; inner = _chunkQFYPSI6Pcjs.inner_of.call(void 0, def))
|
|
4328
|
+
def = _chunkQFYPSI6Pcjs.def_of.call(void 0, inner);
|
|
4330
4329
|
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4331
4330
|
}
|
|
4332
4331
|
function merge_schemas(existing, incoming, state_name) {
|
|
@@ -4513,9 +4512,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4513
4512
|
|
|
4514
4513
|
// src/builders/builder-utils.ts
|
|
4515
4514
|
function register_lane(config2, lanes) {
|
|
4516
|
-
|
|
4517
|
-
if (config2.name ===
|
|
4518
|
-
throw new Error(`Lane "${
|
|
4515
|
+
_chunkQWYMR7ZPcjs.resolveLaneConfig.call(void 0, config2);
|
|
4516
|
+
if (config2.name === _chunkQFYPSI6Pcjs.DEFAULT_LANE)
|
|
4517
|
+
throw new Error(`Lane "${_chunkQFYPSI6Pcjs.DEFAULT_LANE}" is reserved`);
|
|
4519
4518
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4520
4519
|
if (!existing) return void lanes.push(config2);
|
|
4521
4520
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4537,7 +4536,7 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4537
4536
|
events[event].reactions.set(name, reaction);
|
|
4538
4537
|
return Object.assign(builder, {
|
|
4539
4538
|
to(resolver) {
|
|
4540
|
-
if (typeof resolver === "object")
|
|
4539
|
+
if (typeof resolver === "object") _chunkQWYMR7ZPcjs.resolveTargetConfig.call(void 0, resolver);
|
|
4541
4540
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4542
4541
|
return builder;
|
|
4543
4542
|
}
|
|
@@ -4558,9 +4557,9 @@ function reaction_on(event, events, builder) {
|
|
|
4558
4557
|
// Validate the whole bag at the declaration site so a bad
|
|
4559
4558
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4560
4559
|
// not a NaN gate on the first retry.
|
|
4561
|
-
options:
|
|
4562
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _165 => _165.blockOnError]), () => (
|
|
4563
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _166 => _166.maxRetries]), () => (
|
|
4560
|
+
options: _chunkQWYMR7ZPcjs.resolveReactionConfig.call(void 0, {
|
|
4561
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _165 => _165.blockOnError]), () => ( _chunkQWYMR7ZPcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4562
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _166 => _166.maxRetries]), () => ( _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES)),
|
|
4564
4563
|
backoff: _optionalChain([options, 'optionalAccess', _167 => _167.backoff])
|
|
4565
4564
|
})
|
|
4566
4565
|
};
|
|
@@ -4581,7 +4580,7 @@ function reaction_on(event, events, builder) {
|
|
|
4581
4580
|
// src/internal/date-reviver.ts
|
|
4582
4581
|
|
|
4583
4582
|
function variant_schema(schema, walk) {
|
|
4584
|
-
const shape = _optionalChain([
|
|
4583
|
+
const shape = _optionalChain([_chunkQFYPSI6Pcjs.def_of.call(void 0, schema), 'optionalAccess', _168 => _168.shape]);
|
|
4585
4584
|
if (!shape) {
|
|
4586
4585
|
const dates = walk(schema);
|
|
4587
4586
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -4618,7 +4617,7 @@ function date_reviver_schema(schema) {
|
|
|
4618
4617
|
return first && recursive ? pass(true) : first;
|
|
4619
4618
|
}
|
|
4620
4619
|
function build(schema, walk) {
|
|
4621
|
-
const def =
|
|
4620
|
+
const def = _chunkQFYPSI6Pcjs.def_of.call(void 0, schema);
|
|
4622
4621
|
if (!def) return void 0;
|
|
4623
4622
|
const inner = () => walk(def.innerType);
|
|
4624
4623
|
switch (def.type) {
|
|
@@ -4664,13 +4663,13 @@ function build(schema, walk) {
|
|
|
4664
4663
|
return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
|
|
4665
4664
|
}
|
|
4666
4665
|
default:
|
|
4667
|
-
return
|
|
4666
|
+
return _chunkQFYPSI6Pcjs.inner_of.call(void 0, def) ? inner() : void 0;
|
|
4668
4667
|
}
|
|
4669
4668
|
}
|
|
4670
4669
|
|
|
4671
4670
|
// src/builders/event-builder.ts
|
|
4672
4671
|
function event_tags(schema) {
|
|
4673
|
-
const pii =
|
|
4672
|
+
const pii = _chunkQFYPSI6Pcjs.pii_schemas.call(void 0, schema);
|
|
4674
4673
|
const pii_dates = {};
|
|
4675
4674
|
for (const [key, field] of Object.entries(pii)) {
|
|
4676
4675
|
const dates = date_reviver_schema(field);
|
|
@@ -4708,7 +4707,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4708
4707
|
});
|
|
4709
4708
|
}
|
|
4710
4709
|
function build_events(registry, states, lanes, owners) {
|
|
4711
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4710
|
+
const declared = /* @__PURE__ */ new Set([_chunkQFYPSI6Pcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4712
4711
|
const lane_errors = [];
|
|
4713
4712
|
const tags = /* @__PURE__ */ new Map();
|
|
4714
4713
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4783,7 +4782,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4783
4782
|
if (reader) readers.set(event_name, reader);
|
|
4784
4783
|
}
|
|
4785
4784
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4786
|
-
if (snap2) readers.set(
|
|
4785
|
+
if (snap2) readers.set(_chunkQFYPSI6Pcjs.SNAP_EVENT, snap2);
|
|
4787
4786
|
if (readers.size === 0) continue;
|
|
4788
4787
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4789
4788
|
}
|
|
@@ -4791,7 +4790,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4791
4790
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4792
4791
|
}
|
|
4793
4792
|
function reads_as_string(schema) {
|
|
4794
|
-
const type = _optionalChain([
|
|
4793
|
+
const type = _optionalChain([_chunkQFYPSI6Pcjs.def_of.call(void 0, _chunkQFYPSI6Pcjs.output_of.call(void 0, schema)), 'optionalAccess', _172 => _172.type]);
|
|
4795
4794
|
return type === "string" || type === "transform";
|
|
4796
4795
|
}
|
|
4797
4796
|
|
|
@@ -4903,7 +4902,7 @@ function act() {
|
|
|
4903
4902
|
const list = deprecation_summary.map(
|
|
4904
4903
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4905
4904
|
).join(", ");
|
|
4906
|
-
|
|
4905
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).info(
|
|
4907
4906
|
`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.`
|
|
4908
4907
|
);
|
|
4909
4908
|
}
|
|
@@ -4945,7 +4944,7 @@ function act() {
|
|
|
4945
4944
|
return reaction_on(event, registry.events, builder);
|
|
4946
4945
|
},
|
|
4947
4946
|
build: (options) => {
|
|
4948
|
-
|
|
4947
|
+
_chunkQWYMR7ZPcjs.resolveActConfig.call(void 0, options);
|
|
4949
4948
|
if (!_built) {
|
|
4950
4949
|
for (const proj of pending_projections) add_projection(proj);
|
|
4951
4950
|
for (const proj of fold_projections) {
|
|
@@ -4985,7 +4984,7 @@ function act() {
|
|
|
4985
4984
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
4986
4985
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
4987
4986
|
finalize_deprecations();
|
|
4988
|
-
if (built.advisory)
|
|
4987
|
+
if (built.advisory) _chunkQWYMR7ZPcjs.log.call(void 0, ).warn(built.advisory);
|
|
4989
4988
|
for (const [name, state2] of states) {
|
|
4990
4989
|
if (!state2.loads) continue;
|
|
4991
4990
|
const resolved = {};
|
|
@@ -5029,7 +5028,7 @@ function act() {
|
|
|
5029
5028
|
synthesize_autoclose_reactions(
|
|
5030
5029
|
registry,
|
|
5031
5030
|
states,
|
|
5032
|
-
|
|
5031
|
+
_chunkQWYMR7ZPcjs.current_autoclose_window
|
|
5033
5032
|
);
|
|
5034
5033
|
Object.freeze(registry.actions);
|
|
5035
5034
|
Object.freeze(registry.events);
|
|
@@ -5077,8 +5076,8 @@ function _projection(target) {
|
|
|
5077
5076
|
handler,
|
|
5078
5077
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5079
5078
|
options: {
|
|
5080
|
-
blockOnError:
|
|
5081
|
-
maxRetries:
|
|
5079
|
+
blockOnError: _chunkQWYMR7ZPcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5080
|
+
maxRetries: _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES
|
|
5082
5081
|
}
|
|
5083
5082
|
}),
|
|
5084
5083
|
widened
|
|
@@ -5119,7 +5118,7 @@ function _projection(target) {
|
|
|
5119
5118
|
throw new Error(
|
|
5120
5119
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5121
5120
|
);
|
|
5122
|
-
const config2 =
|
|
5121
|
+
const config2 = _chunkQWYMR7ZPcjs.resolveFoldConfig.call(void 0, options);
|
|
5123
5122
|
const fold_events = {};
|
|
5124
5123
|
for (const partial of partials)
|
|
5125
5124
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5137,8 +5136,8 @@ function _projection(target) {
|
|
|
5137
5136
|
handler: noop,
|
|
5138
5137
|
resolver: { target },
|
|
5139
5138
|
options: {
|
|
5140
|
-
blockOnError:
|
|
5141
|
-
maxRetries:
|
|
5139
|
+
blockOnError: _chunkQWYMR7ZPcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5140
|
+
maxRetries: _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES
|
|
5142
5141
|
}
|
|
5143
5142
|
}
|
|
5144
5143
|
]
|
|
@@ -5254,7 +5253,7 @@ function action_builder(state2) {
|
|
|
5254
5253
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5255
5254
|
internal.actions[action2] = schema;
|
|
5256
5255
|
if (options) {
|
|
5257
|
-
|
|
5256
|
+
_chunkQWYMR7ZPcjs.resolveActionConfig.call(void 0, options);
|
|
5258
5257
|
internal.options ??= {};
|
|
5259
5258
|
internal.options[action2] = options;
|
|
5260
5259
|
}
|
|
@@ -5514,30 +5513,30 @@ function write_line(writer, line) {
|
|
|
5514
5513
|
}
|
|
5515
5514
|
|
|
5516
5515
|
// src/deprecated.ts
|
|
5517
|
-
var check_appends =
|
|
5518
|
-
var throw_if_stale =
|
|
5519
|
-
var concurrency_error =
|
|
5520
|
-
var seed_event =
|
|
5521
|
-
var fair_slots =
|
|
5522
|
-
var is_literal_source =
|
|
5523
|
-
var notification_of =
|
|
5524
|
-
var DEFAULT_QUERY_STREAMS_LIMIT2 =
|
|
5525
|
-
var ActorSchema2 =
|
|
5526
|
-
var TargetSchema2 =
|
|
5527
|
-
var EventMetaSchema2 =
|
|
5528
|
-
var CausationEventSchema2 =
|
|
5529
|
-
var CommittedMetaSchema2 =
|
|
5530
|
-
var QuerySchema2 =
|
|
5531
|
-
var Environments2 =
|
|
5532
|
-
var LogLevels2 =
|
|
5533
|
-
var ExitCodes2 =
|
|
5534
|
-
var DEFAULT_LANE2 =
|
|
5535
|
-
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 =
|
|
5536
|
-
var DEFAULT_SETTLE_DEBOUNCE_MS2 =
|
|
5537
|
-
var PackageSchema =
|
|
5538
|
-
var default_scope =
|
|
5539
|
-
var resolveAutocloseConfig2 =
|
|
5540
|
-
var extend = (source, schema, target) => ({ ...target, ...
|
|
5516
|
+
var check_appends = _chunkD7LQNOEVcjs.checkAppends;
|
|
5517
|
+
var throw_if_stale = _chunkD7LQNOEVcjs.checkVersion;
|
|
5518
|
+
var concurrency_error = _chunkD7LQNOEVcjs.concurrencyError;
|
|
5519
|
+
var seed_event = _chunkD7LQNOEVcjs.seedEvent;
|
|
5520
|
+
var fair_slots = _chunkD7LQNOEVcjs.fairSlots;
|
|
5521
|
+
var is_literal_source = _chunkD7LQNOEVcjs.isStreamName;
|
|
5522
|
+
var notification_of = _chunkD7LQNOEVcjs.parseNotification;
|
|
5523
|
+
var DEFAULT_QUERY_STREAMS_LIMIT2 = _chunkQFYPSI6Pcjs.DEFAULT_QUERY_STREAMS_LIMIT;
|
|
5524
|
+
var ActorSchema2 = _chunkQFYPSI6Pcjs.ActorSchema;
|
|
5525
|
+
var TargetSchema2 = _chunkQFYPSI6Pcjs.TargetSchema;
|
|
5526
|
+
var EventMetaSchema2 = _chunkQFYPSI6Pcjs.EventMetaSchema;
|
|
5527
|
+
var CausationEventSchema2 = _chunkQFYPSI6Pcjs.CausationEventSchema;
|
|
5528
|
+
var CommittedMetaSchema2 = _chunkQFYPSI6Pcjs.CommittedMetaSchema;
|
|
5529
|
+
var QuerySchema2 = _chunkQFYPSI6Pcjs.QuerySchema;
|
|
5530
|
+
var Environments2 = _chunkQFYPSI6Pcjs.Environments;
|
|
5531
|
+
var LogLevels2 = _chunkQFYPSI6Pcjs.LogLevels;
|
|
5532
|
+
var ExitCodes2 = _chunkQFYPSI6Pcjs.ExitCodes;
|
|
5533
|
+
var DEFAULT_LANE2 = _chunkQFYPSI6Pcjs.DEFAULT_LANE;
|
|
5534
|
+
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkQFYPSI6Pcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5535
|
+
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkQFYPSI6Pcjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5536
|
+
var PackageSchema = _chunkQWYMR7ZPcjs.package_schema;
|
|
5537
|
+
var default_scope = _chunkQWYMR7ZPcjs.unscoped_ports;
|
|
5538
|
+
var resolveAutocloseConfig2 = _chunkQWYMR7ZPcjs.resolveAutocloseConfig;
|
|
5539
|
+
var extend = (source, schema, target) => ({ ...target, ..._chunkQWYMR7ZPcjs.validate.call(void 0, "config", source, schema) });
|
|
5541
5540
|
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])?$/;
|
|
5542
5541
|
var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value;
|
|
5543
5542
|
|
|
@@ -5600,5 +5599,5 @@ var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(va
|
|
|
5600
5599
|
|
|
5601
5600
|
|
|
5602
5601
|
|
|
5603
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError =
|
|
5602
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkQFYPSI6Pcjs.ConcurrencyError; exports.ConsoleLogger = _chunkQWYMR7ZPcjs.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 = _chunkQFYPSI6Pcjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunkQFYPSI6Pcjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkQWYMR7ZPcjs.InMemoryCache; exports.InMemoryStore = _chunkQWYMR7ZPcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunkQFYPSI6Pcjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunkQFYPSI6Pcjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunkQFYPSI6Pcjs.REDACTED; exports.SHREDDED = _chunkQFYPSI6Pcjs.SHREDDED; exports.SNAP_EVENT = _chunkQFYPSI6Pcjs.SNAP_EVENT; exports.StoreError = _chunkQFYPSI6Pcjs.StoreError; exports.StreamClosedError = _chunkQFYPSI6Pcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunkQFYPSI6Pcjs.ValidationError; exports.ZodEmpty = _chunkQFYPSI6Pcjs.ZodEmpty; exports.act = act; exports.cache = _chunkQWYMR7ZPcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkQWYMR7ZPcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkQWYMR7ZPcjs.dispose; exports.disposeAndExit = _chunkQWYMR7ZPcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkQWYMR7ZPcjs.log; exports.notification_of = notification_of; exports.pii_fields = _chunkQFYPSI6Pcjs.pii_fields; exports.port = _chunkQWYMR7ZPcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = resolveAutocloseConfig2; exports.seed_event = seed_event; exports.sensitive = _chunkQFYPSI6Pcjs.sensitive; exports.sensitiveFields = _chunkQFYPSI6Pcjs.sensitiveFields; exports.sleep = _chunkQWYMR7ZPcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkQWYMR7ZPcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkQWYMR7ZPcjs.validate;
|
|
5604
5603
|
//# sourceMappingURL=index.cjs.map
|