@rotorsoft/act 2.1.1 → 2.1.2
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/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 +220 -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 +192 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -13
- 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
|
}
|
|
@@ -1267,9 +1267,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1267
1267
|
if (drop_closed_streams) {
|
|
1268
1268
|
await source.query(
|
|
1269
1269
|
(e) => {
|
|
1270
|
-
if (e.name ===
|
|
1270
|
+
if (e.name === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1271
1271
|
},
|
|
1272
|
-
{ names: [
|
|
1272
|
+
{ names: [_chunkQFYPSI6Pcjs.TOMBSTONE_EVENT] }
|
|
1273
1273
|
);
|
|
1274
1274
|
}
|
|
1275
1275
|
let max_id;
|
|
@@ -1291,11 +1291,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1291
1291
|
if (!is_valid(event))
|
|
1292
1292
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1293
1293
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1294
|
-
if (drop_snapshots && event.name ===
|
|
1294
|
+
if (drop_snapshots && event.name === _chunkQFYPSI6Pcjs.SNAP_EVENT) {
|
|
1295
1295
|
dropped_snaps++;
|
|
1296
1296
|
return;
|
|
1297
1297
|
}
|
|
1298
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1298
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) {
|
|
1299
1299
|
dropped_closed++;
|
|
1300
1300
|
return;
|
|
1301
1301
|
}
|
|
@@ -1368,18 +1368,18 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1368
1368
|
const { stream, actor, asOf } = target;
|
|
1369
1369
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1370
1370
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1371
|
-
const cached = time_travel ? void 0 : await
|
|
1371
|
+
const cached = time_travel ? void 0 : await _chunkQWYMR7ZPcjs.cache.call(void 0, ).get(stream);
|
|
1372
1372
|
const cache_hit = !!cached;
|
|
1373
1373
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _52 => _52.state]), () => ( (me.init ? me.init() : {})));
|
|
1374
1374
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _53 => _53.patches]), () => ( 0));
|
|
1375
1375
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _54 => _54.snaps]), () => ( 0));
|
|
1376
1376
|
let replayed = 0;
|
|
1377
1377
|
let event;
|
|
1378
|
-
await
|
|
1378
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query(
|
|
1379
1379
|
(raw) => {
|
|
1380
|
-
if (seeded && raw.name ===
|
|
1380
|
+
if (seeded && raw.name === _chunkQFYPSI6Pcjs.SNAP_EVENT && replayed > 0) return;
|
|
1381
1381
|
event = me.view(raw, actor);
|
|
1382
|
-
if (event.name ===
|
|
1382
|
+
if (event.name === _chunkQFYPSI6Pcjs.SNAP_EVENT) {
|
|
1383
1383
|
state2 = event.data;
|
|
1384
1384
|
snaps++;
|
|
1385
1385
|
patches = 0;
|
|
@@ -1388,8 +1388,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1388
1388
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1389
1389
|
patches++;
|
|
1390
1390
|
replayed++;
|
|
1391
|
-
} else if (event.name !==
|
|
1392
|
-
|
|
1391
|
+
} else if (event.name !== _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT) {
|
|
1392
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1393
1393
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1394
1394
|
);
|
|
1395
1395
|
}
|
|
@@ -1417,7 +1417,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1417
1417
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1418
1418
|
}
|
|
1419
1419
|
);
|
|
1420
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _56 => _56.name]) ===
|
|
1420
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _56 => _56.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT;
|
|
1421
1421
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1422
1422
|
await cache_put(stream, {
|
|
1423
1423
|
stream,
|
|
@@ -1460,8 +1460,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1460
1460
|
void 0,
|
|
1461
1461
|
patch_fn
|
|
1462
1462
|
);
|
|
1463
|
-
if (_optionalChain([snapshot, 'access', _61 => _61.event, 'optionalAccess', _62 => _62.name]) ===
|
|
1464
|
-
throw new (0,
|
|
1463
|
+
if (_optionalChain([snapshot, 'access', _61 => _61.event, 'optionalAccess', _62 => _62.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT)
|
|
1464
|
+
throw new (0, _chunkQFYPSI6Pcjs.StreamClosedError)(stream);
|
|
1465
1465
|
return {
|
|
1466
1466
|
state: l.state,
|
|
1467
1467
|
stream,
|
|
@@ -1477,7 +1477,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1477
1477
|
if (!stream) throw new Error("Missing target stream");
|
|
1478
1478
|
const reactingTo = _optionalChain([options, 'optionalAccess', _63 => _63.reactingTo]);
|
|
1479
1479
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _64 => _64.correlator]), () => ( default_correlator));
|
|
1480
|
-
const validated =
|
|
1480
|
+
const validated = _chunkQWYMR7ZPcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1481
1481
|
const opts = _optionalChain([me, 'access', _65 => _65.options, 'optionalAccess', _66 => _66[action2]]);
|
|
1482
1482
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _67 => _67.maxRetries]), () => ( 0));
|
|
1483
1483
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _68 => _68.loads, 'optionalAccess', _69 => _69[action2]]), () => ( []));
|
|
@@ -1489,8 +1489,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1489
1489
|
void 0,
|
|
1490
1490
|
patch_fn
|
|
1491
1491
|
);
|
|
1492
|
-
if (_optionalChain([snapshot, 'access', _70 => _70.event, 'optionalAccess', _71 => _71.name]) ===
|
|
1493
|
-
throw new (0,
|
|
1492
|
+
if (_optionalChain([snapshot, 'access', _70 => _70.event, 'optionalAccess', _71 => _71.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT)
|
|
1493
|
+
throw new (0, _chunkQFYPSI6Pcjs.StreamClosedError)(stream);
|
|
1494
1494
|
const own = {
|
|
1495
1495
|
state: me,
|
|
1496
1496
|
stream,
|
|
@@ -1504,7 +1504,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1504
1504
|
{ stream, state: snapshot.state },
|
|
1505
1505
|
target.actor,
|
|
1506
1506
|
patch_fn,
|
|
1507
|
-
(description) => new (0,
|
|
1507
|
+
(description) => new (0, _chunkQFYPSI6Pcjs.PreconditionError)(
|
|
1508
1508
|
action2,
|
|
1509
1509
|
validated,
|
|
1510
1510
|
target,
|
|
@@ -1517,7 +1517,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1517
1517
|
);
|
|
1518
1518
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _74 => _74.requires, 'optionalAccess', _75 => _75[action2]]), () => ( [])))
|
|
1519
1519
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1520
|
-
throw new (0,
|
|
1520
|
+
throw new (0, _chunkQFYPSI6Pcjs.PreconditionError)(
|
|
1521
1521
|
action2,
|
|
1522
1522
|
validated,
|
|
1523
1523
|
target,
|
|
@@ -1539,7 +1539,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1539
1539
|
);
|
|
1540
1540
|
to.events.push({
|
|
1541
1541
|
name: event,
|
|
1542
|
-
data:
|
|
1542
|
+
data: _chunkQWYMR7ZPcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1543
1543
|
});
|
|
1544
1544
|
}
|
|
1545
1545
|
if (!own.events.length)
|
|
@@ -1596,7 +1596,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1596
1596
|
});
|
|
1597
1597
|
let committed;
|
|
1598
1598
|
try {
|
|
1599
|
-
committed = await
|
|
1599
|
+
committed = await _chunkQWYMR7ZPcjs.store.call(void 0, ).commit(
|
|
1600
1600
|
appends.map((p) => ({
|
|
1601
1601
|
stream: p.stream,
|
|
1602
1602
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1605,7 +1605,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1605
1605
|
meta
|
|
1606
1606
|
);
|
|
1607
1607
|
} catch (error) {
|
|
1608
|
-
if (error instanceof
|
|
1608
|
+
if (error instanceof _chunkQFYPSI6Pcjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1609
1609
|
throw error;
|
|
1610
1610
|
}
|
|
1611
1611
|
let row = 0;
|
|
@@ -1647,19 +1647,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1647
1647
|
}
|
|
1648
1648
|
return snapshots;
|
|
1649
1649
|
} catch (error) {
|
|
1650
|
-
if (!(error instanceof
|
|
1650
|
+
if (!(error instanceof _chunkQFYPSI6Pcjs.ConcurrencyError)) throw error;
|
|
1651
1651
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1652
1652
|
if (attempt >= max_retries) throw error;
|
|
1653
1653
|
if (_optionalChain([opts, 'optionalAccess', _84 => _84.backoff])) {
|
|
1654
1654
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1655
|
-
if (delay_ms > 0) await
|
|
1655
|
+
if (delay_ms > 0) await _chunkQWYMR7ZPcjs.sleep.call(void 0, delay_ms);
|
|
1656
1656
|
}
|
|
1657
1657
|
}
|
|
1658
1658
|
}
|
|
1659
1659
|
}
|
|
1660
1660
|
|
|
1661
1661
|
// src/internal/tracing.ts
|
|
1662
|
-
var PRETTY =
|
|
1662
|
+
var PRETTY = _chunkQWYMR7ZPcjs.config.call(void 0, ).env !== "production";
|
|
1663
1663
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1664
1664
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1665
1665
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1843,7 +1843,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
1843
1843
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _95 => _95.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1844
1844
|
return void 0;
|
|
1845
1845
|
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
|
-
|
|
1846
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).error(error);
|
|
1847
1847
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1848
1848
|
}
|
|
1849
1849
|
function fetch_failure_policy(registry) {
|
|
@@ -1859,13 +1859,13 @@ function fetch_failure_policy(registry) {
|
|
|
1859
1859
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1860
1860
|
if (!error) return { lease, handled, acked_at: at };
|
|
1861
1861
|
logger.error(error);
|
|
1862
|
-
const non_retryable = error instanceof
|
|
1862
|
+
const non_retryable = error instanceof _chunkQFYPSI6Pcjs.NonRetryableError;
|
|
1863
1863
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
1864
1864
|
if (block2)
|
|
1865
1865
|
logger.error(
|
|
1866
1866
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1867
1867
|
);
|
|
1868
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
1868
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkQWYMR7ZPcjs.DEFAULT_BACKOFF)));
|
|
1869
1869
|
return {
|
|
1870
1870
|
lease,
|
|
1871
1871
|
handled,
|
|
@@ -1993,7 +1993,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
1993
1993
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
1994
1994
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
1995
1995
|
if (acked.length < expected)
|
|
1996
|
-
|
|
1996
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
1997
1997
|
`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
1998
|
);
|
|
1999
1999
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2089,9 +2089,9 @@ var DrainController = (_class3 = class {
|
|
|
2089
2089
|
if (!this.armed || this._stopped || this._inflight)
|
|
2090
2090
|
return EMPTY_DRAIN;
|
|
2091
2091
|
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)), () => (
|
|
2092
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkQWYMR7ZPcjs.DEFAULT_STREAM_LIMIT));
|
|
2093
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkQWYMR7ZPcjs.DEFAULT_EVENT_LIMIT));
|
|
2094
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkQWYMR7ZPcjs.DEFAULT_LEASE_MILLIS));
|
|
2095
2095
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2096
2096
|
return EMPTY_DRAIN;
|
|
2097
2097
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2217,7 +2217,7 @@ function build_handle(deps) {
|
|
|
2217
2217
|
handled++;
|
|
2218
2218
|
}
|
|
2219
2219
|
} catch (error) {
|
|
2220
|
-
if (error instanceof
|
|
2220
|
+
if (error instanceof _chunkQFYPSI6Pcjs.DeferSignal) {
|
|
2221
2221
|
let defer;
|
|
2222
2222
|
try {
|
|
2223
2223
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2314,22 +2314,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2314
2314
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2315
2315
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2316
2316
|
// autoclose: `app.close` still closes it.
|
|
2317
|
-
resolver: (e) =>
|
|
2317
|
+
resolver: (e) => _chunkD7LQNOEVcjs.isStreamName.call(void 0, e.stream) ? {
|
|
2318
2318
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2319
2319
|
source: e.stream
|
|
2320
2320
|
} : void 0,
|
|
2321
2321
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2322
2322
|
// not quarantine the synthetic stream.
|
|
2323
|
-
options: { blockOnError: false, maxRetries:
|
|
2323
|
+
options: { blockOnError: false, maxRetries: _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES },
|
|
2324
2324
|
handler: async (event) => {
|
|
2325
2325
|
const aggregate = event.stream;
|
|
2326
2326
|
const window = read_window();
|
|
2327
2327
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2328
|
-
throw new (0,
|
|
2329
|
-
const stats = await
|
|
2328
|
+
throw new (0, _chunkQFYPSI6Pcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2329
|
+
const stats = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2330
2330
|
count: true,
|
|
2331
2331
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2332
|
-
exclude: [
|
|
2332
|
+
exclude: [_chunkQFYPSI6Pcjs.TOMBSTONE_EVENT, _chunkQFYPSI6Pcjs.SNAP_EVENT]
|
|
2333
2333
|
});
|
|
2334
2334
|
const entry = stats.get(aggregate);
|
|
2335
2335
|
if (!entry) return;
|
|
@@ -2365,7 +2365,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2365
2365
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2366
2366
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2367
2367
|
if (future.length)
|
|
2368
|
-
throw new (0,
|
|
2368
|
+
throw new (0, _chunkQFYPSI6Pcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2369
2369
|
}
|
|
2370
2370
|
};
|
|
2371
2371
|
const key = `__autoclose_${st.name}`;
|
|
@@ -2425,7 +2425,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
2425
2425
|
deps,
|
|
2426
2426
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2427
2427
|
);
|
|
2428
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2428
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2429
2429
|
if (retired.length) _optionalChain([deps, 'access', _122 => _122.forget_subscribed, 'optionalCall', _123 => _123(retired)]);
|
|
2430
2430
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2431
2431
|
return { truncated, skipped };
|
|
@@ -2507,7 +2507,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2507
2507
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2508
2508
|
return void 0;
|
|
2509
2509
|
if (t.archive) await t.archive();
|
|
2510
|
-
const result = await
|
|
2510
|
+
const result = await _chunkQWYMR7ZPcjs.store.call(void 0, ).truncate([
|
|
2511
2511
|
{ stream: t.stream, before: t.before, max_id }
|
|
2512
2512
|
]);
|
|
2513
2513
|
return result.get(t.stream);
|
|
@@ -2520,10 +2520,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2520
2520
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2521
2521
|
let boundary_id;
|
|
2522
2522
|
let min_id;
|
|
2523
|
-
await
|
|
2523
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query(
|
|
2524
2524
|
(event) => {
|
|
2525
2525
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2526
|
-
if (event.name ===
|
|
2526
|
+
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
2527
|
boundary_id = event.id;
|
|
2528
2528
|
},
|
|
2529
2529
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -2534,7 +2534,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2534
2534
|
const min_at = /* @__PURE__ */ new Map();
|
|
2535
2535
|
const matches = source_matcher();
|
|
2536
2536
|
await walk_streams(
|
|
2537
|
-
|
|
2537
|
+
_chunkQWYMR7ZPcjs.store.call(void 0, ),
|
|
2538
2538
|
(position) => {
|
|
2539
2539
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2540
2540
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2553,7 +2553,7 @@ function source_matcher() {
|
|
|
2553
2553
|
const compiled = /* @__PURE__ */ new Map();
|
|
2554
2554
|
return (source, target, stream) => {
|
|
2555
2555
|
if (!source) return true;
|
|
2556
|
-
if (
|
|
2556
|
+
if (_chunkD7LQNOEVcjs.isStreamName.call(void 0, source, target)) return source === stream;
|
|
2557
2557
|
let re = compiled.get(source);
|
|
2558
2558
|
if (!re) {
|
|
2559
2559
|
re = new RegExp(source);
|
|
@@ -2563,17 +2563,17 @@ function source_matcher() {
|
|
|
2563
2563
|
};
|
|
2564
2564
|
}
|
|
2565
2565
|
async function scan_stream_heads(streams) {
|
|
2566
|
-
const stats = await
|
|
2567
|
-
exclude: [
|
|
2566
|
+
const stats = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(streams, {
|
|
2567
|
+
exclude: [_chunkQFYPSI6Pcjs.SNAP_EVENT]
|
|
2568
2568
|
});
|
|
2569
|
-
const domain_heads = await
|
|
2570
|
-
exclude: [
|
|
2569
|
+
const domain_heads = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(streams, {
|
|
2570
|
+
exclude: [_chunkQFYPSI6Pcjs.SNAP_EVENT, _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT]
|
|
2571
2571
|
});
|
|
2572
|
-
const true_heads = await
|
|
2572
|
+
const true_heads = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2573
2573
|
const out = /* @__PURE__ */ new Map();
|
|
2574
2574
|
for (const [stream, { head }] of domain_heads) {
|
|
2575
2575
|
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]) ===
|
|
2576
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _128 => _128.name]) === _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT;
|
|
2577
2577
|
out.set(stream, {
|
|
2578
2578
|
max_id: head.id,
|
|
2579
2579
|
version: true_heads.get(stream).head.version,
|
|
@@ -2596,7 +2596,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2596
2596
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2597
2597
|
const matches = source_matcher();
|
|
2598
2598
|
await walk_streams(
|
|
2599
|
-
|
|
2599
|
+
_chunkQWYMR7ZPcjs.store.call(void 0, ),
|
|
2600
2600
|
(position) => {
|
|
2601
2601
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2602
2602
|
if (!has_work) return;
|
|
@@ -2663,7 +2663,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
2663
2663
|
}
|
|
2664
2664
|
}
|
|
2665
2665
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2666
|
-
const heads = await
|
|
2666
|
+
const heads = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2667
2667
|
return guarded.filter((stream) => {
|
|
2668
2668
|
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
2669
|
return true;
|
|
@@ -2681,18 +2681,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2681
2681
|
meta: {
|
|
2682
2682
|
correlation,
|
|
2683
2683
|
causation: {
|
|
2684
|
-
event: { id: guard.id, name:
|
|
2684
|
+
event: { id: guard.id, name: _chunkQFYPSI6Pcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2685
2685
|
}
|
|
2686
2686
|
}
|
|
2687
2687
|
};
|
|
2688
2688
|
});
|
|
2689
|
-
const truncated = await
|
|
2689
|
+
const truncated = await _chunkQWYMR7ZPcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2690
2690
|
await Promise.all(
|
|
2691
2691
|
guarded.map(async (stream) => {
|
|
2692
2692
|
const entry = truncated.get(stream);
|
|
2693
2693
|
const state2 = seed_states.get(stream);
|
|
2694
2694
|
if (state2 && entry) {
|
|
2695
|
-
await
|
|
2695
|
+
await _chunkQWYMR7ZPcjs.cache.call(void 0, ).set(stream, {
|
|
2696
2696
|
stream,
|
|
2697
2697
|
state: state2,
|
|
2698
2698
|
version: entry.committed.version,
|
|
@@ -2701,7 +2701,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2701
2701
|
snaps: 1
|
|
2702
2702
|
});
|
|
2703
2703
|
} else {
|
|
2704
|
-
await
|
|
2704
|
+
await _chunkQWYMR7ZPcjs.cache.call(void 0, ).invalidate(stream);
|
|
2705
2705
|
}
|
|
2706
2706
|
})
|
|
2707
2707
|
);
|
|
@@ -2727,8 +2727,8 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
|
|
|
2727
2727
|
function report_bad_priority(seen, handler, target, priority) {
|
|
2728
2728
|
report_once(
|
|
2729
2729
|
seen,
|
|
2730
|
-
`priority|${handler}
|
|
2731
|
-
`Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer.
|
|
2730
|
+
`priority|${handler}`,
|
|
2731
|
+
`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
2732
|
);
|
|
2733
2733
|
}
|
|
2734
2734
|
function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
@@ -2760,7 +2760,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2760
2760
|
// never lets a resolution re-lane them.
|
|
2761
2761
|
|
|
2762
2762
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2763
|
-
__init19() {this._patterns = new (0,
|
|
2763
|
+
__init19() {this._patterns = new (0, _chunkQWYMR7ZPcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2764
2764
|
|
|
2765
2765
|
|
|
2766
2766
|
|
|
@@ -2778,7 +2778,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2778
2778
|
on_init
|
|
2779
2779
|
}) {;_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
2780
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2781
|
-
this._dynamic_subscriptions = new (0,
|
|
2781
|
+
this._dynamic_subscriptions = new (0, _chunkQWYMR7ZPcjs.LruMap)(max_subscribed_streams);
|
|
2782
2782
|
this._registry = registry;
|
|
2783
2783
|
this._declared_lanes = declared_lanes;
|
|
2784
2784
|
this._static_targets = static_targets;
|
|
@@ -2836,7 +2836,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2836
2836
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
2837
2837
|
_in_fetch_window(source, stream) {
|
|
2838
2838
|
if (source === void 0 || source === stream) return true;
|
|
2839
|
-
if (
|
|
2839
|
+
if (_chunkD7LQNOEVcjs.isStreamName.call(void 0, source)) return false;
|
|
2840
2840
|
let pattern = this._patterns.get(source);
|
|
2841
2841
|
if (!pattern) {
|
|
2842
2842
|
pattern = new RegExp(source);
|
|
@@ -2879,7 +2879,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2879
2879
|
const correlated = /* @__PURE__ */ new Map();
|
|
2880
2880
|
let last_id = after;
|
|
2881
2881
|
let stopped = false;
|
|
2882
|
-
const found = await
|
|
2882
|
+
const found = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query(
|
|
2883
2883
|
(event) => {
|
|
2884
2884
|
if (stopped) return;
|
|
2885
2885
|
const register = this._registry.events[event.name];
|
|
@@ -2898,14 +2898,14 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2898
2898
|
return;
|
|
2899
2899
|
}
|
|
2900
2900
|
if (!resolved) continue;
|
|
2901
|
-
if (!
|
|
2901
|
+
if (!_chunkQWYMR7ZPcjs.is_valid_target.call(void 0, resolved)) {
|
|
2902
2902
|
report_bad_priority(
|
|
2903
2903
|
this._reported,
|
|
2904
2904
|
reaction.handler.name,
|
|
2905
2905
|
resolved.target,
|
|
2906
2906
|
resolved.priority
|
|
2907
2907
|
);
|
|
2908
|
-
|
|
2908
|
+
resolved = { ...resolved, priority: 0 };
|
|
2909
2909
|
}
|
|
2910
2910
|
let lane = resolved.lane;
|
|
2911
2911
|
if (lane !== void 0 && !this._declared_lanes.has(lane)) {
|
|
@@ -2933,9 +2933,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2933
2933
|
correlated_at: void 0
|
|
2934
2934
|
};
|
|
2935
2935
|
const seen_in_scan = correlated.has(resolved.target);
|
|
2936
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _141 => _141.lane])), () => (
|
|
2936
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _141 => _141.lane])), () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
2937
2937
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _142 => _142.priority]);
|
|
2938
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
2938
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
2939
2939
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
2940
2940
|
report_lane_conflict(
|
|
2941
2941
|
this._reported,
|
|
@@ -3009,7 +3009,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3009
3009
|
await Promise.all(
|
|
3010
3010
|
missed.map(async ([stream, entry]) => {
|
|
3011
3011
|
let row;
|
|
3012
|
-
await
|
|
3012
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_streams(
|
|
3013
3013
|
(position) => {
|
|
3014
3014
|
row = position;
|
|
3015
3015
|
},
|
|
@@ -3021,8 +3021,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3021
3021
|
lane: row.lane
|
|
3022
3022
|
});
|
|
3023
3023
|
if (entry.priority > row.priority) return;
|
|
3024
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3025
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3024
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
3025
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkQFYPSI6Pcjs.DEFAULT_LANE));
|
|
3026
3026
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3027
3027
|
report_lane_conflict(
|
|
3028
3028
|
this._reported,
|
|
@@ -3048,7 +3048,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3048
3048
|
millis: 0
|
|
3049
3049
|
});
|
|
3050
3050
|
} catch (error) {
|
|
3051
|
-
|
|
3051
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).warn(
|
|
3052
3052
|
`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
3053
|
);
|
|
3054
3054
|
}
|
|
@@ -3072,7 +3072,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3072
3072
|
const { pii, ...rest } = event;
|
|
3073
3073
|
if (pii == null) {
|
|
3074
3074
|
const shredded = { ...data };
|
|
3075
|
-
for (const f of fields) shredded[f] =
|
|
3075
|
+
for (const f of fields) shredded[f] = _chunkQFYPSI6Pcjs.SHREDDED;
|
|
3076
3076
|
return { ...rest, data: shredded };
|
|
3077
3077
|
}
|
|
3078
3078
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3083,7 +3083,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3083
3083
|
};
|
|
3084
3084
|
}
|
|
3085
3085
|
const redacted = { ...data };
|
|
3086
|
-
for (const f of fields) redacted[f] =
|
|
3086
|
+
for (const f of fields) redacted[f] = _chunkQFYPSI6Pcjs.REDACTED;
|
|
3087
3087
|
return { ...rest, data: redacted };
|
|
3088
3088
|
}
|
|
3089
3089
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -3385,7 +3385,7 @@ var Act = (_class7 = class {
|
|
|
3385
3385
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3386
3386
|
|
|
3387
3387
|
|
|
3388
|
-
__init27() {this._logger =
|
|
3388
|
+
__init27() {this._logger = _chunkQWYMR7ZPcjs.log.call(void 0, )}
|
|
3389
3389
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3390
3390
|
|
|
3391
3391
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3407,10 +3407,10 @@ var Act = (_class7 = class {
|
|
|
3407
3407
|
this._lanes = lanes;
|
|
3408
3408
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3409
3409
|
validate_only_lanes(options.onlyLanes, this._declared_lanes);
|
|
3410
|
-
if (options.scoped)
|
|
3411
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3410
|
+
if (options.scoped) _chunkQWYMR7ZPcjs.check_store.call(void 0, options.scoped.store);
|
|
3411
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkQWYMR7ZPcjs.unscoped_ports.call(void 0, )));
|
|
3412
3412
|
const ports = this._ports;
|
|
3413
|
-
this._scoped =
|
|
3413
|
+
this._scoped = _chunkQWYMR7ZPcjs.make_run_scoped.call(void 0, {
|
|
3414
3414
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3415
3415
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3416
3416
|
get store() {
|
|
@@ -3420,14 +3420,14 @@ var Act = (_class7 = class {
|
|
|
3420
3420
|
return ports.cache;
|
|
3421
3421
|
},
|
|
3422
3422
|
// Parsed per build, so a bad window throws on every build.
|
|
3423
|
-
autoclose_window:
|
|
3423
|
+
autoclose_window: _chunkQWYMR7ZPcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3424
3424
|
});
|
|
3425
3425
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3426
3426
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3427
3427
|
this._cd = build_drain(this._logger);
|
|
3428
3428
|
const handle = build_handle({
|
|
3429
3429
|
logger: this._logger,
|
|
3430
|
-
reaction_scope:
|
|
3430
|
+
reaction_scope: _chunkQWYMR7ZPcjs.make_reaction_scope.call(void 0, {
|
|
3431
3431
|
do: this.do.bind(this),
|
|
3432
3432
|
load: this.load.bind(this),
|
|
3433
3433
|
query: this.query.bind(this),
|
|
@@ -3457,12 +3457,12 @@ var Act = (_class7 = class {
|
|
|
3457
3457
|
this._ports.store,
|
|
3458
3458
|
options.listen !== false
|
|
3459
3459
|
);
|
|
3460
|
-
|
|
3460
|
+
_chunkQWYMR7ZPcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3461
3461
|
}
|
|
3462
3462
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3463
3463
|
_build_breaker(options) {
|
|
3464
3464
|
return new CircuitBreaker(
|
|
3465
|
-
|
|
3465
|
+
_chunkQWYMR7ZPcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3466
3466
|
{
|
|
3467
3467
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3468
3468
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3496,7 +3496,7 @@ var Act = (_class7 = class {
|
|
|
3496
3496
|
try {
|
|
3497
3497
|
await this._run_close(targets);
|
|
3498
3498
|
} catch (error) {
|
|
3499
|
-
if (error instanceof
|
|
3499
|
+
if (error instanceof _chunkQFYPSI6Pcjs.StoreError) throw error;
|
|
3500
3500
|
this._logger.error(
|
|
3501
3501
|
error,
|
|
3502
3502
|
`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 +3530,7 @@ var Act = (_class7 = class {
|
|
|
3530
3530
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3531
3531
|
_build_audit_deps() {
|
|
3532
3532
|
return {
|
|
3533
|
-
store:
|
|
3533
|
+
store: _chunkQWYMR7ZPcjs.store,
|
|
3534
3534
|
event_to_state: this._event_to_state,
|
|
3535
3535
|
// Declared lanes, not this process's controllers: a lane another
|
|
3536
3536
|
// worker drains is not `unknown-lane`.
|
|
@@ -3543,7 +3543,7 @@ var Act = (_class7 = class {
|
|
|
3543
3543
|
registry: this.registry,
|
|
3544
3544
|
static_targets: classification.static_targets,
|
|
3545
3545
|
cd: this._cd,
|
|
3546
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3546
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkQFYPSI6Pcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3547
3547
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3548
3548
|
// still a valid destination.
|
|
3549
3549
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3559,7 +3559,7 @@ var Act = (_class7 = class {
|
|
|
3559
3559
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3560
3560
|
async _seed_persisted_defers() {
|
|
3561
3561
|
const now = Date.now();
|
|
3562
|
-
await walk_streams(
|
|
3562
|
+
await walk_streams(_chunkQWYMR7ZPcjs.store.call(void 0, ), (pos) => {
|
|
3563
3563
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3564
3564
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3565
3565
|
_optionalChain([controller, 'optionalAccess', _150 => _150.seed_defer, 'call', _151 => _151(pos.stream, pos.deferred_at)]);
|
|
@@ -3575,7 +3575,7 @@ var Act = (_class7 = class {
|
|
|
3575
3575
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3576
3576
|
breaker: this._breaker
|
|
3577
3577
|
},
|
|
3578
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3578
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkQFYPSI6Pcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3579
3579
|
);
|
|
3580
3580
|
}
|
|
3581
3581
|
|
|
@@ -3595,7 +3595,7 @@ var Act = (_class7 = class {
|
|
|
3595
3595
|
*/
|
|
3596
3596
|
shutdown(options) {
|
|
3597
3597
|
if (!this._shutdown_promise) {
|
|
3598
|
-
|
|
3598
|
+
_chunkQWYMR7ZPcjs.resolveShutdownConfig.call(void 0, options);
|
|
3599
3599
|
this._shutdown_promise = (async () => {
|
|
3600
3600
|
this.stop_correlations();
|
|
3601
3601
|
this._settle.stop(true);
|
|
@@ -3613,10 +3613,10 @@ var Act = (_class7 = class {
|
|
|
3613
3613
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3614
3614
|
// default for none or 0, and for a running settle), capped.
|
|
3615
3615
|
_derive_grace_ms(running, settling) {
|
|
3616
|
-
let max = settling ?
|
|
3616
|
+
let max = settling ? _chunkQWYMR7ZPcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3617
3617
|
for (const c of running)
|
|
3618
|
-
max = Math.max(max, c.lease_millis ||
|
|
3619
|
-
return Math.min(max,
|
|
3618
|
+
max = Math.max(max, c.lease_millis || _chunkQWYMR7ZPcjs.DEFAULT_LEASE_MILLIS);
|
|
3619
|
+
return Math.min(max, _chunkQWYMR7ZPcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3620
3620
|
}
|
|
3621
3621
|
async _await_inflight(grace_ms) {
|
|
3622
3622
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3700,7 +3700,7 @@ var Act = (_class7 = class {
|
|
|
3700
3700
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3701
3701
|
*/
|
|
3702
3702
|
async do(action2, target, payload, options) {
|
|
3703
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _153 => _153.reactingTo]), () => (
|
|
3703
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _153 => _153.reactingTo]), () => ( _chunkQWYMR7ZPcjs.current_reacting.call(void 0, )));
|
|
3704
3704
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _154 => _154.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3705
3705
|
return this._scoped(async () => {
|
|
3706
3706
|
const snapshots = await this._es.action(
|
|
@@ -3774,7 +3774,7 @@ var Act = (_class7 = class {
|
|
|
3774
3774
|
return this._scoped(async () => {
|
|
3775
3775
|
let first;
|
|
3776
3776
|
let last;
|
|
3777
|
-
const count = await
|
|
3777
|
+
const count = await _chunkQWYMR7ZPcjs.store.call(void 0, ).query((e) => {
|
|
3778
3778
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3779
3779
|
if (!first) first = gated;
|
|
3780
3780
|
last = gated;
|
|
@@ -3802,13 +3802,9 @@ var Act = (_class7 = class {
|
|
|
3802
3802
|
* @see {@link query} for large result sets
|
|
3803
3803
|
*/
|
|
3804
3804
|
async query_array(query) {
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
events.push(this.registry.query_gate(e.name)(e));
|
|
3809
|
-
}, query);
|
|
3810
|
-
return events;
|
|
3811
|
-
});
|
|
3805
|
+
const events = [];
|
|
3806
|
+
await this.query(query, (e) => events.push(e));
|
|
3807
|
+
return events;
|
|
3812
3808
|
}
|
|
3813
3809
|
/**
|
|
3814
3810
|
* Wipe the sensitive-data payload for every event on the stream — see
|
|
@@ -3824,14 +3820,14 @@ var Act = (_class7 = class {
|
|
|
3824
3820
|
*/
|
|
3825
3821
|
async forget(stream) {
|
|
3826
3822
|
return this._scoped(async () => {
|
|
3827
|
-
const s =
|
|
3823
|
+
const s = _chunkQWYMR7ZPcjs.store.call(void 0, );
|
|
3828
3824
|
if (!s.forget_pii) {
|
|
3829
3825
|
throw new Error(
|
|
3830
3826
|
`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
3827
|
);
|
|
3832
3828
|
}
|
|
3833
3829
|
const eventCount = await s.forget_pii(stream);
|
|
3834
|
-
await
|
|
3830
|
+
await _chunkQWYMR7ZPcjs.cache.call(void 0, ).invalidate(stream);
|
|
3835
3831
|
if (eventCount > 0) {
|
|
3836
3832
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3837
3833
|
}
|
|
@@ -3865,7 +3861,7 @@ var Act = (_class7 = class {
|
|
|
3865
3861
|
* @see {@link correlate} for dynamic stream discovery
|
|
3866
3862
|
*/
|
|
3867
3863
|
async drain(options = {}) {
|
|
3868
|
-
|
|
3864
|
+
_chunkQWYMR7ZPcjs.resolveDrainConfig.call(void 0, options);
|
|
3869
3865
|
if (!this._drain)
|
|
3870
3866
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3871
3867
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4045,7 +4041,7 @@ var Act = (_class7 = class {
|
|
|
4045
4041
|
*/
|
|
4046
4042
|
async reset(input) {
|
|
4047
4043
|
return this._scoped(async () => {
|
|
4048
|
-
const count = await
|
|
4044
|
+
const count = await _chunkQWYMR7ZPcjs.store.call(void 0, ).reset(input);
|
|
4049
4045
|
for (const handler of this._batch_handlers.values())
|
|
4050
4046
|
_optionalChain([handler, 'access', _161 => _161[FOLD_RESET], 'optionalCall', _162 => _162()]);
|
|
4051
4047
|
if (count > 0) {
|
|
@@ -4081,7 +4077,7 @@ var Act = (_class7 = class {
|
|
|
4081
4077
|
*/
|
|
4082
4078
|
async unblock(input) {
|
|
4083
4079
|
return this._scoped(async () => {
|
|
4084
|
-
const count = await
|
|
4080
|
+
const count = await _chunkQWYMR7ZPcjs.store.call(void 0, ).unblock(input);
|
|
4085
4081
|
if (count > 0) {
|
|
4086
4082
|
this._wake();
|
|
4087
4083
|
}
|
|
@@ -4136,7 +4132,7 @@ var Act = (_class7 = class {
|
|
|
4136
4132
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4137
4133
|
}
|
|
4138
4134
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4139
|
-
const s =
|
|
4135
|
+
const s = _chunkQWYMR7ZPcjs.store.call(void 0, );
|
|
4140
4136
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4141
4137
|
return s;
|
|
4142
4138
|
})()));
|
|
@@ -4182,7 +4178,7 @@ var Act = (_class7 = class {
|
|
|
4182
4178
|
async blocked_streams(options) {
|
|
4183
4179
|
return this._scoped(async () => {
|
|
4184
4180
|
const positions = [];
|
|
4185
|
-
await
|
|
4181
|
+
await _chunkQWYMR7ZPcjs.store.call(void 0, ).query_streams(
|
|
4186
4182
|
(p) => {
|
|
4187
4183
|
positions.push(p);
|
|
4188
4184
|
},
|
|
@@ -4235,8 +4231,8 @@ var Act = (_class7 = class {
|
|
|
4235
4231
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4236
4232
|
*/
|
|
4237
4233
|
async prioritize(filter, priority) {
|
|
4238
|
-
|
|
4239
|
-
return this._scoped(() =>
|
|
4234
|
+
_chunkQWYMR7ZPcjs.resolveTargetConfig.call(void 0, { priority });
|
|
4235
|
+
return this._scoped(() => _chunkQWYMR7ZPcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4240
4236
|
}
|
|
4241
4237
|
// Shared by `close()` and reaction-requested closes.
|
|
4242
4238
|
async _run_close(targets) {
|
|
@@ -4316,7 +4312,7 @@ var Act = (_class7 = class {
|
|
|
4316
4312
|
* @see {@link correlate} for manual correlation
|
|
4317
4313
|
*/
|
|
4318
4314
|
settle(options) {
|
|
4319
|
-
|
|
4315
|
+
_chunkQWYMR7ZPcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
4320
4316
|
this._schedule(options);
|
|
4321
4317
|
}
|
|
4322
4318
|
}, _class7);
|
|
@@ -4324,9 +4320,9 @@ var Act = (_class7 = class {
|
|
|
4324
4320
|
// src/builders/merge.ts
|
|
4325
4321
|
|
|
4326
4322
|
function base_type_name(schema) {
|
|
4327
|
-
let def =
|
|
4328
|
-
for (let inner =
|
|
4329
|
-
def =
|
|
4323
|
+
let def = _chunkQFYPSI6Pcjs.def_of.call(void 0, schema);
|
|
4324
|
+
for (let inner = _chunkQFYPSI6Pcjs.inner_of.call(void 0, def); inner; inner = _chunkQFYPSI6Pcjs.inner_of.call(void 0, def))
|
|
4325
|
+
def = _chunkQFYPSI6Pcjs.def_of.call(void 0, inner);
|
|
4330
4326
|
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4331
4327
|
}
|
|
4332
4328
|
function merge_schemas(existing, incoming, state_name) {
|
|
@@ -4513,9 +4509,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4513
4509
|
|
|
4514
4510
|
// src/builders/builder-utils.ts
|
|
4515
4511
|
function register_lane(config2, lanes) {
|
|
4516
|
-
|
|
4517
|
-
if (config2.name ===
|
|
4518
|
-
throw new Error(`Lane "${
|
|
4512
|
+
_chunkQWYMR7ZPcjs.resolveLaneConfig.call(void 0, config2);
|
|
4513
|
+
if (config2.name === _chunkQFYPSI6Pcjs.DEFAULT_LANE)
|
|
4514
|
+
throw new Error(`Lane "${_chunkQFYPSI6Pcjs.DEFAULT_LANE}" is reserved`);
|
|
4519
4515
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4520
4516
|
if (!existing) return void lanes.push(config2);
|
|
4521
4517
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4537,7 +4533,7 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4537
4533
|
events[event].reactions.set(name, reaction);
|
|
4538
4534
|
return Object.assign(builder, {
|
|
4539
4535
|
to(resolver) {
|
|
4540
|
-
if (typeof resolver === "object")
|
|
4536
|
+
if (typeof resolver === "object") _chunkQWYMR7ZPcjs.resolveTargetConfig.call(void 0, resolver);
|
|
4541
4537
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4542
4538
|
return builder;
|
|
4543
4539
|
}
|
|
@@ -4558,9 +4554,9 @@ function reaction_on(event, events, builder) {
|
|
|
4558
4554
|
// Validate the whole bag at the declaration site so a bad
|
|
4559
4555
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4560
4556
|
// 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]), () => (
|
|
4557
|
+
options: _chunkQWYMR7ZPcjs.resolveReactionConfig.call(void 0, {
|
|
4558
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _165 => _165.blockOnError]), () => ( _chunkQWYMR7ZPcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4559
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _166 => _166.maxRetries]), () => ( _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES)),
|
|
4564
4560
|
backoff: _optionalChain([options, 'optionalAccess', _167 => _167.backoff])
|
|
4565
4561
|
})
|
|
4566
4562
|
};
|
|
@@ -4581,7 +4577,7 @@ function reaction_on(event, events, builder) {
|
|
|
4581
4577
|
// src/internal/date-reviver.ts
|
|
4582
4578
|
|
|
4583
4579
|
function variant_schema(schema, walk) {
|
|
4584
|
-
const shape = _optionalChain([
|
|
4580
|
+
const shape = _optionalChain([_chunkQFYPSI6Pcjs.def_of.call(void 0, schema), 'optionalAccess', _168 => _168.shape]);
|
|
4585
4581
|
if (!shape) {
|
|
4586
4582
|
const dates = walk(schema);
|
|
4587
4583
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -4618,7 +4614,7 @@ function date_reviver_schema(schema) {
|
|
|
4618
4614
|
return first && recursive ? pass(true) : first;
|
|
4619
4615
|
}
|
|
4620
4616
|
function build(schema, walk) {
|
|
4621
|
-
const def =
|
|
4617
|
+
const def = _chunkQFYPSI6Pcjs.def_of.call(void 0, schema);
|
|
4622
4618
|
if (!def) return void 0;
|
|
4623
4619
|
const inner = () => walk(def.innerType);
|
|
4624
4620
|
switch (def.type) {
|
|
@@ -4664,13 +4660,13 @@ function build(schema, walk) {
|
|
|
4664
4660
|
return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
|
|
4665
4661
|
}
|
|
4666
4662
|
default:
|
|
4667
|
-
return
|
|
4663
|
+
return _chunkQFYPSI6Pcjs.inner_of.call(void 0, def) ? inner() : void 0;
|
|
4668
4664
|
}
|
|
4669
4665
|
}
|
|
4670
4666
|
|
|
4671
4667
|
// src/builders/event-builder.ts
|
|
4672
4668
|
function event_tags(schema) {
|
|
4673
|
-
const pii =
|
|
4669
|
+
const pii = _chunkQFYPSI6Pcjs.pii_schemas.call(void 0, schema);
|
|
4674
4670
|
const pii_dates = {};
|
|
4675
4671
|
for (const [key, field] of Object.entries(pii)) {
|
|
4676
4672
|
const dates = date_reviver_schema(field);
|
|
@@ -4708,7 +4704,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4708
4704
|
});
|
|
4709
4705
|
}
|
|
4710
4706
|
function build_events(registry, states, lanes, owners) {
|
|
4711
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4707
|
+
const declared = /* @__PURE__ */ new Set([_chunkQFYPSI6Pcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4712
4708
|
const lane_errors = [];
|
|
4713
4709
|
const tags = /* @__PURE__ */ new Map();
|
|
4714
4710
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4783,7 +4779,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4783
4779
|
if (reader) readers.set(event_name, reader);
|
|
4784
4780
|
}
|
|
4785
4781
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4786
|
-
if (snap2) readers.set(
|
|
4782
|
+
if (snap2) readers.set(_chunkQFYPSI6Pcjs.SNAP_EVENT, snap2);
|
|
4787
4783
|
if (readers.size === 0) continue;
|
|
4788
4784
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4789
4785
|
}
|
|
@@ -4791,7 +4787,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4791
4787
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4792
4788
|
}
|
|
4793
4789
|
function reads_as_string(schema) {
|
|
4794
|
-
const type = _optionalChain([
|
|
4790
|
+
const type = _optionalChain([_chunkQFYPSI6Pcjs.def_of.call(void 0, _chunkQFYPSI6Pcjs.output_of.call(void 0, schema)), 'optionalAccess', _172 => _172.type]);
|
|
4795
4791
|
return type === "string" || type === "transform";
|
|
4796
4792
|
}
|
|
4797
4793
|
|
|
@@ -4903,7 +4899,7 @@ function act() {
|
|
|
4903
4899
|
const list = deprecation_summary.map(
|
|
4904
4900
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4905
4901
|
).join(", ");
|
|
4906
|
-
|
|
4902
|
+
_chunkQWYMR7ZPcjs.log.call(void 0, ).info(
|
|
4907
4903
|
`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
4904
|
);
|
|
4909
4905
|
}
|
|
@@ -4945,7 +4941,7 @@ function act() {
|
|
|
4945
4941
|
return reaction_on(event, registry.events, builder);
|
|
4946
4942
|
},
|
|
4947
4943
|
build: (options) => {
|
|
4948
|
-
|
|
4944
|
+
_chunkQWYMR7ZPcjs.resolveActConfig.call(void 0, options);
|
|
4949
4945
|
if (!_built) {
|
|
4950
4946
|
for (const proj of pending_projections) add_projection(proj);
|
|
4951
4947
|
for (const proj of fold_projections) {
|
|
@@ -4985,7 +4981,7 @@ function act() {
|
|
|
4985
4981
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
4986
4982
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
4987
4983
|
finalize_deprecations();
|
|
4988
|
-
if (built.advisory)
|
|
4984
|
+
if (built.advisory) _chunkQWYMR7ZPcjs.log.call(void 0, ).warn(built.advisory);
|
|
4989
4985
|
for (const [name, state2] of states) {
|
|
4990
4986
|
if (!state2.loads) continue;
|
|
4991
4987
|
const resolved = {};
|
|
@@ -5029,7 +5025,7 @@ function act() {
|
|
|
5029
5025
|
synthesize_autoclose_reactions(
|
|
5030
5026
|
registry,
|
|
5031
5027
|
states,
|
|
5032
|
-
|
|
5028
|
+
_chunkQWYMR7ZPcjs.current_autoclose_window
|
|
5033
5029
|
);
|
|
5034
5030
|
Object.freeze(registry.actions);
|
|
5035
5031
|
Object.freeze(registry.events);
|
|
@@ -5077,8 +5073,8 @@ function _projection(target) {
|
|
|
5077
5073
|
handler,
|
|
5078
5074
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5079
5075
|
options: {
|
|
5080
|
-
blockOnError:
|
|
5081
|
-
maxRetries:
|
|
5076
|
+
blockOnError: _chunkQWYMR7ZPcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5077
|
+
maxRetries: _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES
|
|
5082
5078
|
}
|
|
5083
5079
|
}),
|
|
5084
5080
|
widened
|
|
@@ -5119,7 +5115,7 @@ function _projection(target) {
|
|
|
5119
5115
|
throw new Error(
|
|
5120
5116
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5121
5117
|
);
|
|
5122
|
-
const config2 =
|
|
5118
|
+
const config2 = _chunkQWYMR7ZPcjs.resolveFoldConfig.call(void 0, options);
|
|
5123
5119
|
const fold_events = {};
|
|
5124
5120
|
for (const partial of partials)
|
|
5125
5121
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5137,8 +5133,8 @@ function _projection(target) {
|
|
|
5137
5133
|
handler: noop,
|
|
5138
5134
|
resolver: { target },
|
|
5139
5135
|
options: {
|
|
5140
|
-
blockOnError:
|
|
5141
|
-
maxRetries:
|
|
5136
|
+
blockOnError: _chunkQWYMR7ZPcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5137
|
+
maxRetries: _chunkQWYMR7ZPcjs.DEFAULT_MAX_RETRIES
|
|
5142
5138
|
}
|
|
5143
5139
|
}
|
|
5144
5140
|
]
|
|
@@ -5254,7 +5250,7 @@ function action_builder(state2) {
|
|
|
5254
5250
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5255
5251
|
internal.actions[action2] = schema;
|
|
5256
5252
|
if (options) {
|
|
5257
|
-
|
|
5253
|
+
_chunkQWYMR7ZPcjs.resolveActionConfig.call(void 0, options);
|
|
5258
5254
|
internal.options ??= {};
|
|
5259
5255
|
internal.options[action2] = options;
|
|
5260
5256
|
}
|
|
@@ -5514,30 +5510,30 @@ function write_line(writer, line) {
|
|
|
5514
5510
|
}
|
|
5515
5511
|
|
|
5516
5512
|
// 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, ...
|
|
5513
|
+
var check_appends = _chunkD7LQNOEVcjs.checkAppends;
|
|
5514
|
+
var throw_if_stale = _chunkD7LQNOEVcjs.checkVersion;
|
|
5515
|
+
var concurrency_error = _chunkD7LQNOEVcjs.concurrencyError;
|
|
5516
|
+
var seed_event = _chunkD7LQNOEVcjs.seedEvent;
|
|
5517
|
+
var fair_slots = _chunkD7LQNOEVcjs.fairSlots;
|
|
5518
|
+
var is_literal_source = _chunkD7LQNOEVcjs.isStreamName;
|
|
5519
|
+
var notification_of = _chunkD7LQNOEVcjs.parseNotification;
|
|
5520
|
+
var DEFAULT_QUERY_STREAMS_LIMIT2 = _chunkQFYPSI6Pcjs.DEFAULT_QUERY_STREAMS_LIMIT;
|
|
5521
|
+
var ActorSchema2 = _chunkQFYPSI6Pcjs.ActorSchema;
|
|
5522
|
+
var TargetSchema2 = _chunkQFYPSI6Pcjs.TargetSchema;
|
|
5523
|
+
var EventMetaSchema2 = _chunkQFYPSI6Pcjs.EventMetaSchema;
|
|
5524
|
+
var CausationEventSchema2 = _chunkQFYPSI6Pcjs.CausationEventSchema;
|
|
5525
|
+
var CommittedMetaSchema2 = _chunkQFYPSI6Pcjs.CommittedMetaSchema;
|
|
5526
|
+
var QuerySchema2 = _chunkQFYPSI6Pcjs.QuerySchema;
|
|
5527
|
+
var Environments2 = _chunkQFYPSI6Pcjs.Environments;
|
|
5528
|
+
var LogLevels2 = _chunkQFYPSI6Pcjs.LogLevels;
|
|
5529
|
+
var ExitCodes2 = _chunkQFYPSI6Pcjs.ExitCodes;
|
|
5530
|
+
var DEFAULT_LANE2 = _chunkQFYPSI6Pcjs.DEFAULT_LANE;
|
|
5531
|
+
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkQFYPSI6Pcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5532
|
+
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkQFYPSI6Pcjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5533
|
+
var PackageSchema = _chunkQWYMR7ZPcjs.package_schema;
|
|
5534
|
+
var default_scope = _chunkQWYMR7ZPcjs.unscoped_ports;
|
|
5535
|
+
var resolveAutocloseConfig2 = _chunkQWYMR7ZPcjs.resolveAutocloseConfig;
|
|
5536
|
+
var extend = (source, schema, target) => ({ ...target, ..._chunkQWYMR7ZPcjs.validate.call(void 0, "config", source, schema) });
|
|
5541
5537
|
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
5538
|
var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value;
|
|
5543
5539
|
|
|
@@ -5600,5 +5596,5 @@ var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(va
|
|
|
5600
5596
|
|
|
5601
5597
|
|
|
5602
5598
|
|
|
5603
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError =
|
|
5599
|
+
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
5600
|
//# sourceMappingURL=index.cjs.map
|