@rotorsoft/act 2.1.15 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +6 -3
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/builders/event-builder.d.ts +3 -11
- package/dist/@types/builders/event-builder.d.ts.map +1 -1
- package/dist/@types/disposers.d.ts +4 -1
- package/dist/@types/disposers.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +8 -0
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/sensitive.d.ts +4 -2
- package/dist/@types/internal/sensitive.d.ts.map +1 -1
- package/dist/@types/internal/zod.d.ts +6 -0
- package/dist/@types/internal/zod.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +2 -1
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/types/builders.d.ts +25 -11
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/@types/types/registry.d.ts +7 -4
- package/dist/@types/types/registry.d.ts.map +1 -1
- package/dist/{chunk-3WHD4VPP.cjs → chunk-DDGMSQSO.cjs} +31 -16
- package/dist/chunk-DDGMSQSO.cjs.map +1 -0
- package/dist/{chunk-CWWTVYIN.js → chunk-OFBVOZIA.js} +26 -11
- package/dist/chunk-OFBVOZIA.js.map +1 -0
- package/dist/index.cjs +199 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +3 -3
- package/dist/test/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-3WHD4VPP.cjs.map +0 -1
- package/dist/chunk-CWWTVYIN.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkDDGMSQSOcjs = require('./chunk-DDGMSQSO.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -70,22 +70,22 @@ var _chunkLA2BPKNScjs = require('./chunk-LA2BPKNS.cjs');
|
|
|
70
70
|
|
|
71
71
|
// src/signals.ts
|
|
72
72
|
process.once("SIGINT", async (arg) => {
|
|
73
|
-
|
|
74
|
-
await
|
|
73
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
74
|
+
await _chunkDDGMSQSOcjs.disposeAndExit.call(void 0, "EXIT");
|
|
75
75
|
});
|
|
76
76
|
process.once("SIGTERM", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
78
|
+
await _chunkDDGMSQSOcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("uncaughtException", async (arg) => {
|
|
81
81
|
process.exitCode = 1;
|
|
82
|
-
|
|
83
|
-
await
|
|
82
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
83
|
+
await _chunkDDGMSQSOcjs.disposeAndExit.call(void 0, "ERROR");
|
|
84
84
|
});
|
|
85
85
|
process.once("unhandledRejection", async (arg) => {
|
|
86
86
|
process.exitCode = 1;
|
|
87
|
-
|
|
88
|
-
await
|
|
87
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
88
|
+
await _chunkDDGMSQSOcjs.disposeAndExit.call(void 0, "ERROR");
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
// src/act.ts
|
|
@@ -832,17 +832,17 @@ function compile_reaches(reaches) {
|
|
|
832
832
|
}
|
|
833
833
|
_chunkLA2BPKNScjs.__name.call(void 0, compile_reaches, "compile_reaches");
|
|
834
834
|
function policy_after_windows(options) {
|
|
835
|
-
const parsed =
|
|
835
|
+
const parsed = _chunkDDGMSQSOcjs.check.call(void 0, "autoclose_policy", options);
|
|
836
836
|
return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
|
|
837
837
|
}
|
|
838
838
|
_chunkLA2BPKNScjs.__name.call(void 0, policy_after_windows, "policy_after_windows");
|
|
839
839
|
function policy_keep_days(options) {
|
|
840
|
-
const parsed =
|
|
840
|
+
const parsed = _chunkDDGMSQSOcjs.check.call(void 0, "autoclose_policy", options);
|
|
841
841
|
return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
|
|
842
842
|
}
|
|
843
843
|
_chunkLA2BPKNScjs.__name.call(void 0, policy_keep_days, "policy_keep_days");
|
|
844
844
|
function compile_autoclose_policy(options) {
|
|
845
|
-
const parsed =
|
|
845
|
+
const parsed = _chunkDDGMSQSOcjs.check.call(void 0, "autoclose_policy", options);
|
|
846
846
|
const and_preds = [];
|
|
847
847
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
848
848
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -914,7 +914,7 @@ function duration_ms(d) {
|
|
|
914
914
|
}
|
|
915
915
|
_chunkLA2BPKNScjs.__name.call(void 0, duration_ms, "duration_ms");
|
|
916
916
|
function resolve_defer_at(when, event) {
|
|
917
|
-
const parsed =
|
|
917
|
+
const parsed = _chunkDDGMSQSOcjs.check.call(void 0, "defer", when);
|
|
918
918
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
919
919
|
return parsed.at.getTime();
|
|
920
920
|
}
|
|
@@ -1061,7 +1061,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, compute_lag_lead_ratio, "compute_lag_lead_
|
|
|
1061
1061
|
function report_once(seen, key, message) {
|
|
1062
1062
|
if (seen.has(key)) return;
|
|
1063
1063
|
seen.add(key);
|
|
1064
|
-
|
|
1064
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).error(new Error(message));
|
|
1065
1065
|
}
|
|
1066
1066
|
_chunkLA2BPKNScjs.__name.call(void 0, report_once, "report_once");
|
|
1067
1067
|
|
|
@@ -1092,14 +1092,14 @@ function close_correlation(correlator, actor) {
|
|
|
1092
1092
|
_chunkLA2BPKNScjs.__name.call(void 0, close_correlation, "close_correlation");
|
|
1093
1093
|
|
|
1094
1094
|
// src/internal/drain-ops.ts
|
|
1095
|
-
var claim = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (lagging, leading, by, millis, lane) =>
|
|
1095
|
+
var claim = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (lagging, leading, by, millis, lane) => _chunkDDGMSQSOcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane), "claim");
|
|
1096
1096
|
async function fetch(leased, eventLimit) {
|
|
1097
1097
|
return Promise.all(
|
|
1098
1098
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1099
1099
|
const events = [];
|
|
1100
1100
|
const stream_exact = source !== void 0 && _chunkQITJ63HGcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1101
1101
|
try {
|
|
1102
|
-
await
|
|
1102
|
+
await _chunkDDGMSQSOcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1103
1103
|
stream: source,
|
|
1104
1104
|
stream_exact,
|
|
1105
1105
|
after: at,
|
|
@@ -1120,9 +1120,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1120
1120
|
);
|
|
1121
1121
|
}
|
|
1122
1122
|
_chunkLA2BPKNScjs.__name.call(void 0, fetch, "fetch");
|
|
1123
|
-
var ack = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) =>
|
|
1124
|
-
var block = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) =>
|
|
1125
|
-
var subscribe = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (streams, correlated_at, correlator) =>
|
|
1123
|
+
var ack = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) => _chunkDDGMSQSOcjs.store.call(void 0, ).ack(leases), "ack");
|
|
1124
|
+
var block = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) => _chunkDDGMSQSOcjs.store.call(void 0, ).block(leases), "block");
|
|
1125
|
+
var subscribe = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (streams, correlated_at, correlator) => _chunkDDGMSQSOcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator), "subscribe");
|
|
1126
1126
|
|
|
1127
1127
|
// src/internal/event-sourcing.ts
|
|
1128
1128
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1152,6 +1152,11 @@ function wrapped(schema) {
|
|
|
1152
1152
|
return inner ? [inner] : [];
|
|
1153
1153
|
}
|
|
1154
1154
|
_chunkLA2BPKNScjs.__name.call(void 0, wrapped, "wrapped");
|
|
1155
|
+
function parts_of(schema) {
|
|
1156
|
+
const def = def_of(schema);
|
|
1157
|
+
return _optionalChain([def, 'optionalAccess', _52 => _52.type]) === "intersection" ? [def.left, def.right] : wrapped(schema);
|
|
1158
|
+
}
|
|
1159
|
+
_chunkLA2BPKNScjs.__name.call(void 0, parts_of, "parts_of");
|
|
1155
1160
|
function some_layer(schema, test) {
|
|
1156
1161
|
const seen = /* @__PURE__ */ new Set();
|
|
1157
1162
|
const visit = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (s) => {
|
|
@@ -1180,7 +1185,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, output_of, "output_of");
|
|
|
1180
1185
|
|
|
1181
1186
|
// src/internal/date-reviver.ts
|
|
1182
1187
|
function variant_schema(schema, walk) {
|
|
1183
|
-
const shape = _optionalChain([def_of, 'call',
|
|
1188
|
+
const shape = _optionalChain([def_of, 'call', _53 => _53(schema), 'optionalAccess', _54 => _54.shape]);
|
|
1184
1189
|
if (!shape) {
|
|
1185
1190
|
const dates = walk(schema);
|
|
1186
1191
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -1254,7 +1259,7 @@ function build(schema, walk) {
|
|
|
1254
1259
|
return variants.some((v) => v.dated) ? _zod2.z.union(variants.map((v) => v.schema)) : void 0;
|
|
1255
1260
|
}
|
|
1256
1261
|
case "nullable":
|
|
1257
|
-
return _optionalChain([inner, 'call',
|
|
1262
|
+
return _optionalChain([inner, 'call', _55 => _55(), 'optionalAccess', _56 => _56.nullable, 'call', _57 => _57()]);
|
|
1258
1263
|
case "pipe":
|
|
1259
1264
|
return walk(def.out);
|
|
1260
1265
|
case "lazy":
|
|
@@ -1273,7 +1278,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, build, "build");
|
|
|
1273
1278
|
// src/internal/event-sourcing.ts
|
|
1274
1279
|
var bare_patch = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial), "bare_patch");
|
|
1275
1280
|
var value_at = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (value, path) => path.reduce(
|
|
1276
|
-
(at, key) => _optionalChain([at, 'optionalAccess',
|
|
1281
|
+
(at, key) => _optionalChain([at, 'optionalAccess', _58 => _58[key]]),
|
|
1277
1282
|
value
|
|
1278
1283
|
), "value_at");
|
|
1279
1284
|
var check_invariants = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (target, state2, schema, pii_aware) => {
|
|
@@ -1296,14 +1301,14 @@ var check_invariants = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (ta
|
|
|
1296
1301
|
);
|
|
1297
1302
|
}, "check_invariants");
|
|
1298
1303
|
var DEFAULT_BATCH = 500;
|
|
1299
|
-
var cache_put = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream, entry) =>
|
|
1300
|
-
(err) =>
|
|
1304
|
+
var cache_put = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream, entry) => _chunkDDGMSQSOcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1305
|
+
(err) => _chunkDDGMSQSOcjs.log.call(void 0, ).warn(
|
|
1301
1306
|
err,
|
|
1302
1307
|
"cache set skipped; the next load re-folds from the store"
|
|
1303
1308
|
)
|
|
1304
1309
|
), "cache_put");
|
|
1305
|
-
var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream) =>
|
|
1306
|
-
(err) =>
|
|
1310
|
+
var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream) => _chunkDDGMSQSOcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1311
|
+
(err) => _chunkDDGMSQSOcjs.log.call(void 0, ).warn(
|
|
1307
1312
|
err,
|
|
1308
1313
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1309
1314
|
)
|
|
@@ -1311,7 +1316,7 @@ var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream)
|
|
|
1311
1316
|
async function snap(snapshot) {
|
|
1312
1317
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1313
1318
|
try {
|
|
1314
|
-
const [committed] = await
|
|
1319
|
+
const [committed] = await _chunkDDGMSQSOcjs.store.call(void 0, ).commit(
|
|
1315
1320
|
[
|
|
1316
1321
|
{
|
|
1317
1322
|
stream,
|
|
@@ -1328,7 +1333,7 @@ async function snap(snapshot) {
|
|
|
1328
1333
|
return committed;
|
|
1329
1334
|
} catch (error) {
|
|
1330
1335
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1331
|
-
|
|
1336
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).warn(
|
|
1332
1337
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1333
1338
|
);
|
|
1334
1339
|
}
|
|
@@ -1336,7 +1341,7 @@ async function snap(snapshot) {
|
|
|
1336
1341
|
_chunkLA2BPKNScjs.__name.call(void 0, snap, "snap");
|
|
1337
1342
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1338
1343
|
try {
|
|
1339
|
-
const [committed] = await
|
|
1344
|
+
const [committed] = await _chunkDDGMSQSOcjs.store.call(void 0, ).commit(
|
|
1340
1345
|
[
|
|
1341
1346
|
{
|
|
1342
1347
|
stream,
|
|
@@ -1423,11 +1428,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1423
1428
|
return;
|
|
1424
1429
|
}
|
|
1425
1430
|
let migrated = event;
|
|
1426
|
-
const migration = _optionalChain([event_migrations, 'optionalAccess',
|
|
1431
|
+
const migration = _optionalChain([event_migrations, 'optionalAccess', _59 => _59[event.name]]);
|
|
1427
1432
|
if (migration) {
|
|
1428
|
-
const revived = _optionalChain([migration_dates, 'access',
|
|
1433
|
+
const revived = _optionalChain([migration_dates, 'access', _60 => _60.get, 'call', _61 => _61(event.name), 'optionalAccess', _62 => _62.safeParse, 'call', _63 => _63(event.data)]);
|
|
1429
1434
|
const old_data = migration.from_schema.parse(
|
|
1430
|
-
_optionalChain([revived, 'optionalAccess',
|
|
1435
|
+
_optionalChain([revived, 'optionalAccess', _64 => _64.success]) ? revived.data : event.data
|
|
1431
1436
|
);
|
|
1432
1437
|
const new_data = migration.migrate(old_data);
|
|
1433
1438
|
migration.to_schema.parse(new_data);
|
|
@@ -1465,7 +1470,7 @@ async function scan(source, opts = {}, callback) {
|
|
|
1465
1470
|
// A cause missing from the source has no id in the new
|
|
1466
1471
|
// log; its old id would name another event there.
|
|
1467
1472
|
id: _nullishCoalesce(id_map.get(cause.id), () => ( -1)),
|
|
1468
|
-
name: _nullishCoalesce(_optionalChain([event_migrations, 'optionalAccess',
|
|
1473
|
+
name: _nullishCoalesce(_optionalChain([event_migrations, 'optionalAccess', _65 => _65[cause.name], 'optionalAccess', _66 => _66.to]), () => ( cause.name)),
|
|
1469
1474
|
stream: stream_rename ? stream_rename(cause.stream) : cause.stream
|
|
1470
1475
|
}
|
|
1471
1476
|
}
|
|
@@ -1496,14 +1501,14 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1496
1501
|
const { stream, actor, asOf } = target;
|
|
1497
1502
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1498
1503
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1499
|
-
const cached = time_travel ? void 0 : await
|
|
1504
|
+
const cached = time_travel ? void 0 : await _chunkDDGMSQSOcjs.cache.call(void 0, ).get(stream);
|
|
1500
1505
|
const cache_hit = !!cached;
|
|
1501
|
-
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1502
|
-
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1503
|
-
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1506
|
+
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _67 => _67.state]), () => ( (me.init ? me.init() : {})));
|
|
1507
|
+
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _68 => _68.patches]), () => ( 0));
|
|
1508
|
+
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _69 => _69.snaps]), () => ( 0));
|
|
1504
1509
|
let replayed = 0;
|
|
1505
1510
|
let event;
|
|
1506
|
-
await
|
|
1511
|
+
await _chunkDDGMSQSOcjs.store.call(void 0, ).query(
|
|
1507
1512
|
(raw) => {
|
|
1508
1513
|
if (seeded && raw.name === _chunkLA2BPKNScjs.SNAP_EVENT && replayed > 0) return;
|
|
1509
1514
|
event = me.view(raw, actor);
|
|
@@ -1517,11 +1522,11 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1517
1522
|
patches++;
|
|
1518
1523
|
replayed++;
|
|
1519
1524
|
} else if (event.name !== _chunkLA2BPKNScjs.TOMBSTONE_EVENT) {
|
|
1520
|
-
|
|
1525
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).warn(
|
|
1521
1526
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1522
1527
|
);
|
|
1523
1528
|
}
|
|
1524
|
-
_optionalChain([callback, 'optionalCall',
|
|
1529
|
+
_optionalChain([callback, 'optionalCall', _70 => _70({
|
|
1525
1530
|
event,
|
|
1526
1531
|
state: state2,
|
|
1527
1532
|
version: event.version,
|
|
@@ -1545,7 +1550,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1545
1550
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1546
1551
|
}
|
|
1547
1552
|
);
|
|
1548
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess',
|
|
1553
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _71 => _71.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT;
|
|
1549
1554
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1550
1555
|
await cache_put(stream, {
|
|
1551
1556
|
stream,
|
|
@@ -1559,9 +1564,9 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1559
1564
|
return {
|
|
1560
1565
|
event,
|
|
1561
1566
|
state: state2,
|
|
1562
|
-
version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1567
|
+
version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _72 => _72.version]), () => ( _optionalChain([cached, 'optionalAccess', _73 => _73.version]))), () => ( -1)),
|
|
1563
1568
|
// Captured with `state`, so consumers never race a separate cache lookup.
|
|
1564
|
-
id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1569
|
+
id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _74 => _74.id]), () => ( _optionalChain([cached, 'optionalAccess', _75 => _75.event_id]))), () => ( -1)),
|
|
1565
1570
|
patches,
|
|
1566
1571
|
snaps,
|
|
1567
1572
|
cache_hit,
|
|
@@ -1589,7 +1594,7 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1589
1594
|
void 0,
|
|
1590
1595
|
patch_fn
|
|
1591
1596
|
);
|
|
1592
|
-
if (_optionalChain([snapshot, 'access',
|
|
1597
|
+
if (_optionalChain([snapshot, 'access', _76 => _76.event, 'optionalAccess', _77 => _77.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT)
|
|
1593
1598
|
throw new (0, _chunkLA2BPKNScjs.StreamClosedError)(stream);
|
|
1594
1599
|
return {
|
|
1595
1600
|
state: l.state,
|
|
@@ -1605,12 +1610,12 @@ _chunkLA2BPKNScjs.__name.call(void 0, load_others, "load_others");
|
|
|
1605
1610
|
async function action(me, action2, target, payload, options, patch_fn = bare_patch) {
|
|
1606
1611
|
const { stream, expectedVersion, actor } = target;
|
|
1607
1612
|
if (!stream) throw new Error("Missing target stream");
|
|
1608
|
-
const reactingTo = _optionalChain([options, 'optionalAccess',
|
|
1609
|
-
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1610
|
-
const validated =
|
|
1611
|
-
const opts = _optionalChain([me, 'access',
|
|
1612
|
-
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1613
|
-
const loads = _nullishCoalesce(_optionalChain([me, 'access',
|
|
1613
|
+
const reactingTo = _optionalChain([options, 'optionalAccess', _78 => _78.reactingTo]);
|
|
1614
|
+
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _79 => _79.correlator]), () => ( default_correlator));
|
|
1615
|
+
const validated = _chunkDDGMSQSOcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1616
|
+
const opts = _optionalChain([me, 'access', _80 => _80.options, 'optionalAccess', _81 => _81[action2]]);
|
|
1617
|
+
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _82 => _82.maxRetries]), () => ( 0));
|
|
1618
|
+
const loads = _nullishCoalesce(_optionalChain([me, 'access', _83 => _83.loads, 'optionalAccess', _84 => _84[action2]]), () => ( []));
|
|
1614
1619
|
for (let attempt = 0; ; attempt++) {
|
|
1615
1620
|
try {
|
|
1616
1621
|
const snapshot = await load(
|
|
@@ -1619,7 +1624,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1619
1624
|
void 0,
|
|
1620
1625
|
patch_fn
|
|
1621
1626
|
);
|
|
1622
|
-
if (_optionalChain([snapshot, 'access',
|
|
1627
|
+
if (_optionalChain([snapshot, 'access', _85 => _85.event, 'optionalAccess', _86 => _86.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT)
|
|
1623
1628
|
throw new (0, _chunkLA2BPKNScjs.StreamClosedError)(stream);
|
|
1624
1629
|
const own = {
|
|
1625
1630
|
state: me,
|
|
@@ -1643,9 +1648,9 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1643
1648
|
)
|
|
1644
1649
|
) : [];
|
|
1645
1650
|
const loaded = Object.fromEntries(
|
|
1646
|
-
others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess',
|
|
1651
|
+
others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess', _87 => _87.snapshot, 'access', _88 => _88.state])])
|
|
1647
1652
|
);
|
|
1648
|
-
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access',
|
|
1653
|
+
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _89 => _89.requires, 'optionalAccess', _90 => _90[action2]]), () => ( [])))
|
|
1649
1654
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1650
1655
|
throw new (0, _chunkLA2BPKNScjs.PreconditionError)(
|
|
1651
1656
|
action2,
|
|
@@ -1669,7 +1674,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1669
1674
|
);
|
|
1670
1675
|
to.events.push({
|
|
1671
1676
|
name: event,
|
|
1672
|
-
data:
|
|
1677
|
+
data: _chunkDDGMSQSOcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1673
1678
|
});
|
|
1674
1679
|
}
|
|
1675
1680
|
if (!own.events.length)
|
|
@@ -1677,10 +1682,10 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1677
1682
|
`Action "${action2}" appends only to the streams it loads; it must append an event to its own stream too`
|
|
1678
1683
|
);
|
|
1679
1684
|
const appends = [own, ...others].filter(
|
|
1680
|
-
(p) => !!_optionalChain([p, 'optionalAccess',
|
|
1685
|
+
(p) => !!_optionalChain([p, 'optionalAccess', _91 => _91.events, 'access', _92 => _92.length])
|
|
1681
1686
|
);
|
|
1682
1687
|
const meta = {
|
|
1683
|
-
correlation: _optionalChain([reactingTo, 'optionalAccess',
|
|
1688
|
+
correlation: _optionalChain([reactingTo, 'optionalAccess', _93 => _93.meta, 'access', _94 => _94.correlation]) || correlator({
|
|
1684
1689
|
action: action2,
|
|
1685
1690
|
state: me.name,
|
|
1686
1691
|
stream,
|
|
@@ -1726,7 +1731,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1726
1731
|
});
|
|
1727
1732
|
let committed;
|
|
1728
1733
|
try {
|
|
1729
|
-
committed = await
|
|
1734
|
+
committed = await _chunkDDGMSQSOcjs.store.call(void 0, ).commit(
|
|
1730
1735
|
appends.map((p) => ({
|
|
1731
1736
|
stream: p.stream,
|
|
1732
1737
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1758,13 +1763,13 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1758
1763
|
};
|
|
1759
1764
|
});
|
|
1760
1765
|
const last = appended.at(-1);
|
|
1761
|
-
const snap_event = _optionalChain([owner, 'access',
|
|
1766
|
+
const snap_event = _optionalChain([owner, 'access', _95 => _95.snap, 'optionalCall', _96 => _96(last)]) ? await snap(last) : void 0;
|
|
1762
1767
|
if (!owner.pii_aware)
|
|
1763
1768
|
void cache_put(append.stream, {
|
|
1764
1769
|
stream: append.stream,
|
|
1765
1770
|
state: last.state,
|
|
1766
|
-
version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess',
|
|
1767
|
-
event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess',
|
|
1771
|
+
version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _97 => _97.version]), () => ( last.event.version)),
|
|
1772
|
+
event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _98 => _98.id]), () => ( last.event.id)),
|
|
1768
1773
|
patches: snap_event ? 0 : last.patches,
|
|
1769
1774
|
snaps: snap_event ? last.snaps + 1 : last.snaps
|
|
1770
1775
|
});
|
|
@@ -1780,9 +1785,9 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1780
1785
|
if (!(error instanceof _chunkLA2BPKNScjs.ConcurrencyError)) throw error;
|
|
1781
1786
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1782
1787
|
if (attempt >= max_retries) throw error;
|
|
1783
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
1788
|
+
if (_optionalChain([opts, 'optionalAccess', _99 => _99.backoff])) {
|
|
1784
1789
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1785
|
-
if (delay_ms > 0) await
|
|
1790
|
+
if (delay_ms > 0) await _chunkDDGMSQSOcjs.sleep.call(void 0, delay_ms);
|
|
1786
1791
|
}
|
|
1787
1792
|
}
|
|
1788
1793
|
}
|
|
@@ -1790,7 +1795,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1790
1795
|
_chunkLA2BPKNScjs.__name.call(void 0, action, "action");
|
|
1791
1796
|
|
|
1792
1797
|
// src/internal/tracing.ts
|
|
1793
|
-
var PRETTY =
|
|
1798
|
+
var PRETTY = _chunkDDGMSQSOcjs.config.call(void 0, ).env !== "production";
|
|
1794
1799
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1795
1800
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1796
1801
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1836,9 +1841,9 @@ var as_of_marker = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (asOf)
|
|
|
1836
1841
|
return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
|
|
1837
1842
|
}, "as_of_marker");
|
|
1838
1843
|
var traced = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (inner, exit, entry) => (async (...args) => {
|
|
1839
|
-
_optionalChain([entry, 'optionalCall',
|
|
1844
|
+
_optionalChain([entry, 'optionalCall', _100 => _100(...args)]);
|
|
1840
1845
|
const result = await inner(...args);
|
|
1841
|
-
_optionalChain([exit, 'optionalCall',
|
|
1846
|
+
_optionalChain([exit, 'optionalCall', _101 => _101(result, ...args)]);
|
|
1842
1847
|
return result;
|
|
1843
1848
|
}), "traced");
|
|
1844
1849
|
function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
|
|
@@ -1847,7 +1852,7 @@ function build_es(logger, correlator = default_correlator, patch_fn = bare_patch
|
|
|
1847
1852
|
action_name,
|
|
1848
1853
|
target,
|
|
1849
1854
|
payload,
|
|
1850
|
-
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1855
|
+
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _102 => _102.correlator]), () => ( correlator)) },
|
|
1851
1856
|
patch_fn
|
|
1852
1857
|
), "bound_action");
|
|
1853
1858
|
const bound_load = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (me, target, callback) => load(me, target, callback, patch_fn), "bound_load");
|
|
@@ -1922,7 +1927,7 @@ function build_drain(logger) {
|
|
|
1922
1927
|
subscribe: logger.level !== "trace" ? subscribe : traced(subscribe, (result, streams) => {
|
|
1923
1928
|
if (!result.subscribed) return;
|
|
1924
1929
|
const lanes = new Set(streams.map((s) => _nullishCoalesce(s.lane, () => ( "default"))));
|
|
1925
|
-
const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access',
|
|
1930
|
+
const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _103 => _103[0], 'optionalAccess', _104 => _104.lane]) : void 0;
|
|
1926
1931
|
const data = streams.map(
|
|
1927
1932
|
({ stream, lane }) => uniform_lane || !lane || lane === "default" ? hue(C_STREAM, stream) : `${hue(C_STREAM, stream)}${dim(`[${lane}]`)}`
|
|
1928
1933
|
).join(" ");
|
|
@@ -1935,7 +1940,7 @@ function build_drain(logger) {
|
|
|
1935
1940
|
_chunkLA2BPKNScjs.__name.call(void 0, build_drain, "build_drain");
|
|
1936
1941
|
function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
1937
1942
|
if (logger.level !== "trace" || !leased.length) return;
|
|
1938
|
-
const lane = _optionalChain([leased, 'access',
|
|
1943
|
+
const lane = _optionalChain([leased, 'access', _105 => _105[0], 'optionalAccess', _106 => _106.lane]);
|
|
1939
1944
|
const fetch_by_stream = new Map(fetched.map((f) => [f.stream, f]));
|
|
1940
1945
|
const acked_by_stream = new Map(acked.map((a) => [a.stream, a.at]));
|
|
1941
1946
|
const blocked_by_stream = new Map(blocked.map((b) => [b.stream, b.error]));
|
|
@@ -1944,8 +1949,8 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
|
1944
1949
|
);
|
|
1945
1950
|
const detail = leased.map(({ stream, at, retry }) => {
|
|
1946
1951
|
const f = fetch_by_stream.get(stream);
|
|
1947
|
-
const key = _optionalChain([f, 'optionalAccess',
|
|
1948
|
-
const events = _optionalChain([f, 'optionalAccess',
|
|
1952
|
+
const key = _optionalChain([f, 'optionalAccess', _107 => _107.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
|
|
1953
|
+
const events = _optionalChain([f, 'optionalAccess', _108 => _108.events, 'access', _109 => _109.length]) ? ` ${dim(
|
|
1949
1954
|
`[${f.events.map(({ id, name }) => `#${id} ${String(name)}`).join(", ")}]`
|
|
1950
1955
|
)}` : "";
|
|
1951
1956
|
const acked_at = acked_by_stream.get(stream);
|
|
@@ -1974,10 +1979,10 @@ _chunkLA2BPKNScjs.__name.call(void 0, trace_cycle, "trace_cycle");
|
|
|
1974
1979
|
|
|
1975
1980
|
// src/internal/drain-cycle.ts
|
|
1976
1981
|
function budget_exhausted(lease, options, store_failing) {
|
|
1977
|
-
if (store_failing || !_optionalChain([options, 'optionalAccess',
|
|
1982
|
+
if (store_failing || !_optionalChain([options, 'optionalAccess', _110 => _110.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1978
1983
|
return void 0;
|
|
1979
1984
|
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.`;
|
|
1980
|
-
|
|
1985
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).error(error);
|
|
1981
1986
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1982
1987
|
}
|
|
1983
1988
|
_chunkLA2BPKNScjs.__name.call(void 0, budget_exhausted, "budget_exhausted");
|
|
@@ -2001,7 +2006,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
2001
2006
|
logger.error(
|
|
2002
2007
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2003
2008
|
);
|
|
2004
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2009
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkDDGMSQSOcjs.DEFAULT_BACKOFF)));
|
|
2005
2010
|
return {
|
|
2006
2011
|
lease,
|
|
2007
2012
|
handled,
|
|
@@ -2042,7 +2047,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2042
2047
|
const fetched = await ops.fetch(leased, eventLimit);
|
|
2043
2048
|
const fetch_map = /* @__PURE__ */ new Map();
|
|
2044
2049
|
const fetch_window_at = fetched.reduce(
|
|
2045
|
-
(max, { at, events }) => Math.max(max, _optionalChain([events, 'access',
|
|
2050
|
+
(max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _111 => _111.at, 'call', _112 => _112(-1), 'optionalAccess', _113 => _113.id]) || at),
|
|
2046
2051
|
0
|
|
2047
2052
|
);
|
|
2048
2053
|
for (const f of fetched) {
|
|
@@ -2106,11 +2111,11 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2106
2111
|
deps.logger
|
|
2107
2112
|
)
|
|
2108
2113
|
);
|
|
2109
|
-
const at = _optionalChain([entry, 'access',
|
|
2114
|
+
const at = _optionalChain([entry, 'access', _114 => _114.fetch, 'access', _115 => _115.events, 'access', _116 => _116.at, 'call', _117 => _117(-1), 'optionalAccess', _118 => _118.id]) || fetch_window_at;
|
|
2110
2115
|
const { payloads } = entry;
|
|
2111
2116
|
const exhausted = budget_exhausted(
|
|
2112
2117
|
lease,
|
|
2113
|
-
_optionalChain([payloads, 'access',
|
|
2118
|
+
_optionalChain([payloads, 'access', _119 => _119[0], 'optionalAccess', _120 => _120.options]),
|
|
2114
2119
|
store_failing
|
|
2115
2120
|
);
|
|
2116
2121
|
if (exhausted) return Promise.resolve(exhausted);
|
|
@@ -2131,7 +2136,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2131
2136
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2132
2137
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2133
2138
|
if (acked.length < expected)
|
|
2134
|
-
|
|
2139
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).warn(
|
|
2135
2140
|
`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.`
|
|
2136
2141
|
);
|
|
2137
2142
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2200,7 +2205,7 @@ var DrainController = (_class3 = class {
|
|
|
2200
2205
|
}
|
|
2201
2206
|
/** This lane's configured lease, or `undefined`; the shutdown grace basis. */
|
|
2202
2207
|
get lease_millis() {
|
|
2203
|
-
return _optionalChain([this, 'access',
|
|
2208
|
+
return _optionalChain([this, 'access', _121 => _121._deps, 'access', _122 => _122.defaults, 'optionalAccess', _123 => _123.leaseMillis]);
|
|
2204
2209
|
}
|
|
2205
2210
|
get lane() {
|
|
2206
2211
|
return this._deps.lane;
|
|
@@ -2232,9 +2237,9 @@ var DrainController = (_class3 = class {
|
|
|
2232
2237
|
if (!this.armed || this._stopped || this._inflight)
|
|
2233
2238
|
return EMPTY_DRAIN;
|
|
2234
2239
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2235
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2236
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2237
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2240
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkDDGMSQSOcjs.DEFAULT_STREAM_LIMIT));
|
|
2241
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkDDGMSQSOcjs.DEFAULT_EVENT_LIMIT));
|
|
2242
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkDDGMSQSOcjs.DEFAULT_LEASE_MILLIS));
|
|
2238
2243
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2239
2244
|
return EMPTY_DRAIN;
|
|
2240
2245
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2329,11 +2334,11 @@ var CloseSignal = class extends Error {
|
|
|
2329
2334
|
constructor(opts) {
|
|
2330
2335
|
super("reaction requested close");
|
|
2331
2336
|
this.name = "CloseSignal";
|
|
2332
|
-
this.stream = _optionalChain([opts, 'optionalAccess',
|
|
2333
|
-
this.archive = _optionalChain([opts, 'optionalAccess',
|
|
2334
|
-
this.at = _optionalChain([opts, 'optionalAccess',
|
|
2335
|
-
this.before = _optionalChain([opts, 'optionalAccess',
|
|
2336
|
-
this.defer = _optionalChain([opts, 'optionalAccess',
|
|
2337
|
+
this.stream = _optionalChain([opts, 'optionalAccess', _124 => _124.stream]);
|
|
2338
|
+
this.archive = _optionalChain([opts, 'optionalAccess', _125 => _125.archive]);
|
|
2339
|
+
this.at = _optionalChain([opts, 'optionalAccess', _126 => _126.at]);
|
|
2340
|
+
this.before = _optionalChain([opts, 'optionalAccess', _127 => _127.before]);
|
|
2341
|
+
this.defer = _optionalChain([opts, 'optionalAccess', _128 => _128.defer]);
|
|
2337
2342
|
}
|
|
2338
2343
|
};
|
|
2339
2344
|
function build_handle(deps) {
|
|
@@ -2387,7 +2392,7 @@ function build_handle(deps) {
|
|
|
2387
2392
|
// Advance to the live head the handler evaluated against (when
|
|
2388
2393
|
// provided) so the close-cycle guard sees this reaction caught up.
|
|
2389
2394
|
acked_at: _nullishCoalesce(error.at, () => ( event.id)),
|
|
2390
|
-
defer: _optionalChain([error, 'access',
|
|
2395
|
+
defer: _optionalChain([error, 'access', _129 => _129.defer, 'optionalAccess', _130 => _130.getTime, 'call', _131 => _131()]),
|
|
2391
2396
|
// Close the signalled stream (the autoclose reaction's aggregate,
|
|
2392
2397
|
// which differs from its synthetic lease stream); a self-closing
|
|
2393
2398
|
// user reaction omits it and closes its own lease stream. A
|
|
@@ -2468,13 +2473,13 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2468
2473
|
} : void 0, "resolver"),
|
|
2469
2474
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2470
2475
|
// not quarantine the synthetic stream.
|
|
2471
|
-
options: { blockOnError: false, maxRetries:
|
|
2476
|
+
options: { blockOnError: false, maxRetries: _chunkDDGMSQSOcjs.DEFAULT_MAX_RETRIES },
|
|
2472
2477
|
handler: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (event) => {
|
|
2473
2478
|
const aggregate = event.stream;
|
|
2474
2479
|
const window = read_window();
|
|
2475
2480
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2476
2481
|
throw new (0, _chunkLA2BPKNScjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2477
|
-
const stats = await
|
|
2482
|
+
const stats = await _chunkDDGMSQSOcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2478
2483
|
count: true,
|
|
2479
2484
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2480
2485
|
exclude: [_chunkLA2BPKNScjs.TOMBSTONE_EVENT, _chunkLA2BPKNScjs.SNAP_EVENT]
|
|
@@ -2520,7 +2525,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2520
2525
|
};
|
|
2521
2526
|
const key = `__autoclose_${st.name}`;
|
|
2522
2527
|
for (const event_name of Object.keys(st.events)) {
|
|
2523
|
-
_optionalChain([registry, 'access',
|
|
2528
|
+
_optionalChain([registry, 'access', _132 => _132.events, 'access', _133 => _133[event_name], 'optionalAccess', _134 => _134.reactions, 'access', _135 => _135.set, 'call', _136 => _136(
|
|
2524
2529
|
key,
|
|
2525
2530
|
reaction
|
|
2526
2531
|
)]);
|
|
@@ -2581,7 +2586,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
2581
2586
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2582
2587
|
);
|
|
2583
2588
|
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkLA2BPKNScjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2584
|
-
if (retired.length) _optionalChain([deps, 'access',
|
|
2589
|
+
if (retired.length) _optionalChain([deps, 'access', _137 => _137.forget_subscribed, 'optionalCall', _138 => _138(retired)]);
|
|
2585
2590
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2586
2591
|
return { truncated, skipped };
|
|
2587
2592
|
}
|
|
@@ -2603,7 +2608,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
|
|
|
2603
2608
|
const info = stream_info.get(target.stream);
|
|
2604
2609
|
if (!info) continue;
|
|
2605
2610
|
const owner = deps.event_to_state.get(info.last_event_name);
|
|
2606
|
-
if (_optionalChain([owner, 'optionalAccess',
|
|
2611
|
+
if (_optionalChain([owner, 'optionalAccess', _139 => _139.pii_aware])) {
|
|
2607
2612
|
deps.logger.error(
|
|
2608
2613
|
`Refusing to close "${target.stream}" with restart: state "${owner.name}" carries sensitive fields, so a restart seed would persist redacted values while deleting the originals. Close it without restart to retire the stream, or leave it open.`
|
|
2609
2614
|
);
|
|
@@ -2665,7 +2670,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2665
2670
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2666
2671
|
return void 0;
|
|
2667
2672
|
if (t.archive) await t.archive();
|
|
2668
|
-
const result = await
|
|
2673
|
+
const result = await _chunkDDGMSQSOcjs.store.call(void 0, ).truncate([
|
|
2669
2674
|
{ stream: t.stream, before: t.before, max_id }
|
|
2670
2675
|
]);
|
|
2671
2676
|
return result.get(t.stream);
|
|
@@ -2679,7 +2684,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, run_windowed_closes, "run_windowed_closes"
|
|
|
2679
2684
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2680
2685
|
let boundary_id;
|
|
2681
2686
|
let min_id;
|
|
2682
|
-
await
|
|
2687
|
+
await _chunkDDGMSQSOcjs.store.call(void 0, ).query(
|
|
2683
2688
|
(event) => {
|
|
2684
2689
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2685
2690
|
if (event.name === _chunkLA2BPKNScjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
@@ -2694,7 +2699,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2694
2699
|
const min_at = /* @__PURE__ */ new Map();
|
|
2695
2700
|
const matches = source_matcher();
|
|
2696
2701
|
await walk_streams(
|
|
2697
|
-
|
|
2702
|
+
_chunkDDGMSQSOcjs.store.call(void 0, ),
|
|
2698
2703
|
(position) => {
|
|
2699
2704
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2700
2705
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2725,17 +2730,17 @@ function source_matcher() {
|
|
|
2725
2730
|
}
|
|
2726
2731
|
_chunkLA2BPKNScjs.__name.call(void 0, source_matcher, "source_matcher");
|
|
2727
2732
|
async function scan_stream_heads(streams) {
|
|
2728
|
-
const stats = await
|
|
2733
|
+
const stats = await _chunkDDGMSQSOcjs.store.call(void 0, ).query_stats(streams, {
|
|
2729
2734
|
exclude: [_chunkLA2BPKNScjs.SNAP_EVENT]
|
|
2730
2735
|
});
|
|
2731
|
-
const domain_heads = await
|
|
2736
|
+
const domain_heads = await _chunkDDGMSQSOcjs.store.call(void 0, ).query_stats(streams, {
|
|
2732
2737
|
exclude: [_chunkLA2BPKNScjs.SNAP_EVENT, _chunkLA2BPKNScjs.TOMBSTONE_EVENT]
|
|
2733
2738
|
});
|
|
2734
|
-
const true_heads = await
|
|
2739
|
+
const true_heads = await _chunkDDGMSQSOcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2735
2740
|
const out = /* @__PURE__ */ new Map();
|
|
2736
2741
|
for (const [stream, { head }] of domain_heads) {
|
|
2737
|
-
const marker_head = _optionalChain([stats, 'access',
|
|
2738
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess',
|
|
2742
|
+
const marker_head = _optionalChain([stats, 'access', _140 => _140.get, 'call', _141 => _141(stream), 'optionalAccess', _142 => _142.head]);
|
|
2743
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _143 => _143.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT;
|
|
2739
2744
|
out.set(stream, {
|
|
2740
2745
|
max_id: head.id,
|
|
2741
2746
|
version: true_heads.get(stream).head.version,
|
|
@@ -2759,7 +2764,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2759
2764
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2760
2765
|
const matches = source_matcher();
|
|
2761
2766
|
await walk_streams(
|
|
2762
|
-
|
|
2767
|
+
_chunkDDGMSQSOcjs.store.call(void 0, ),
|
|
2763
2768
|
(position) => {
|
|
2764
2769
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2765
2770
|
if (!has_work) return;
|
|
@@ -2806,7 +2811,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, guard_with_tombstones, "guard_with_tombsto
|
|
|
2806
2811
|
async function load_restart_seeds(guarded, target_map, stream_info, event_to_state, load2, logger) {
|
|
2807
2812
|
const seed_states = /* @__PURE__ */ new Map();
|
|
2808
2813
|
await Promise.all(
|
|
2809
|
-
guarded.filter((s) => _optionalChain([target_map, 'access',
|
|
2814
|
+
guarded.filter((s) => _optionalChain([target_map, 'access', _144 => _144.get, 'call', _145 => _145(s), 'optionalAccess', _146 => _146.restart])).map(async (stream) => {
|
|
2810
2815
|
const last_event_name = stream_info.get(stream).last_event_name;
|
|
2811
2816
|
const owner_state = event_to_state.get(last_event_name);
|
|
2812
2817
|
if (!owner_state) {
|
|
@@ -2824,15 +2829,15 @@ async function load_restart_seeds(guarded, target_map, stream_info, event_to_sta
|
|
|
2824
2829
|
_chunkLA2BPKNScjs.__name.call(void 0, load_restart_seeds, "load_restart_seeds");
|
|
2825
2830
|
async function run_archive_callbacks(guarded, target_map) {
|
|
2826
2831
|
for (const stream of guarded) {
|
|
2827
|
-
const archive_fn = _optionalChain([target_map, 'access',
|
|
2832
|
+
const archive_fn = _optionalChain([target_map, 'access', _147 => _147.get, 'call', _148 => _148(stream), 'optionalAccess', _149 => _149.archive]);
|
|
2828
2833
|
if (archive_fn) await archive_fn();
|
|
2829
2834
|
}
|
|
2830
2835
|
}
|
|
2831
2836
|
_chunkLA2BPKNScjs.__name.call(void 0, run_archive_callbacks, "run_archive_callbacks");
|
|
2832
2837
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2833
|
-
const heads = await
|
|
2838
|
+
const heads = await _chunkDDGMSQSOcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2834
2839
|
return guarded.filter((stream) => {
|
|
2835
|
-
if (_optionalChain([heads, 'access',
|
|
2840
|
+
if (_optionalChain([heads, 'access', _150 => _150.get, 'call', _151 => _151(stream), 'optionalAccess', _152 => _152.head, 'access', _153 => _153.id]) === guard_events.get(stream).id)
|
|
2836
2841
|
return true;
|
|
2837
2842
|
skipped.push(stream);
|
|
2838
2843
|
return false;
|
|
@@ -2854,13 +2859,13 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2854
2859
|
}
|
|
2855
2860
|
};
|
|
2856
2861
|
});
|
|
2857
|
-
const truncated = await
|
|
2862
|
+
const truncated = await _chunkDDGMSQSOcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2858
2863
|
await Promise.all(
|
|
2859
2864
|
guarded.map(async (stream) => {
|
|
2860
2865
|
const entry = truncated.get(stream);
|
|
2861
2866
|
const state2 = seed_states.get(stream);
|
|
2862
2867
|
if (state2 && entry) {
|
|
2863
|
-
await
|
|
2868
|
+
await _chunkDDGMSQSOcjs.cache.call(void 0, ).set(stream, {
|
|
2864
2869
|
stream,
|
|
2865
2870
|
state: state2,
|
|
2866
2871
|
version: entry.committed.version,
|
|
@@ -2869,7 +2874,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2869
2874
|
snaps: 1
|
|
2870
2875
|
});
|
|
2871
2876
|
} else {
|
|
2872
|
-
await
|
|
2877
|
+
await _chunkDDGMSQSOcjs.cache.call(void 0, ).invalidate(stream);
|
|
2873
2878
|
}
|
|
2874
2879
|
})
|
|
2875
2880
|
);
|
|
@@ -2935,7 +2940,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2935
2940
|
// never lets a resolution re-lane them.
|
|
2936
2941
|
|
|
2937
2942
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2938
|
-
__init19() {this._patterns = new (0,
|
|
2943
|
+
__init19() {this._patterns = new (0, _chunkDDGMSQSOcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2939
2944
|
|
|
2940
2945
|
|
|
2941
2946
|
|
|
@@ -2953,7 +2958,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2953
2958
|
on_init
|
|
2954
2959
|
}) {;_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);
|
|
2955
2960
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2956
|
-
this._dynamic_subscriptions = new (0,
|
|
2961
|
+
this._dynamic_subscriptions = new (0, _chunkDDGMSQSOcjs.LruMap)(max_subscribed_streams);
|
|
2957
2962
|
this._registry = registry;
|
|
2958
2963
|
this._declared_lanes = declared_lanes;
|
|
2959
2964
|
this._static_targets = static_targets;
|
|
@@ -2985,7 +2990,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2985
2990
|
lane
|
|
2986
2991
|
});
|
|
2987
2992
|
}
|
|
2988
|
-
await _optionalChain([this, 'access',
|
|
2993
|
+
await _optionalChain([this, 'access', _154 => _154._on_init, 'optionalCall', _155 => _155()]);
|
|
2989
2994
|
}
|
|
2990
2995
|
/**
|
|
2991
2996
|
* Replace the log with no pass in flight, then cold-start: a pass that
|
|
@@ -3054,7 +3059,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3054
3059
|
const correlated = /* @__PURE__ */ new Map();
|
|
3055
3060
|
let last_id = after;
|
|
3056
3061
|
let stopped = false;
|
|
3057
|
-
const found = await
|
|
3062
|
+
const found = await _chunkDDGMSQSOcjs.store.call(void 0, ).query(
|
|
3058
3063
|
(event) => {
|
|
3059
3064
|
if (stopped) return;
|
|
3060
3065
|
const register = this._registry.events[event.name];
|
|
@@ -3074,7 +3079,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3074
3079
|
}
|
|
3075
3080
|
if (!resolved) continue;
|
|
3076
3081
|
try {
|
|
3077
|
-
|
|
3082
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "target", resolved);
|
|
3078
3083
|
} catch (e2) {
|
|
3079
3084
|
report_bad_priority(
|
|
3080
3085
|
this._reported,
|
|
@@ -3110,8 +3115,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3110
3115
|
correlated_at: void 0
|
|
3111
3116
|
};
|
|
3112
3117
|
const seen_in_scan = correlated.has(resolved.target);
|
|
3113
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess',
|
|
3114
|
-
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess',
|
|
3118
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _156 => _156.lane])), () => ( _chunkLA2BPKNScjs.DEFAULT_LANE));
|
|
3119
|
+
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _157 => _157.priority]);
|
|
3115
3120
|
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkLA2BPKNScjs.DEFAULT_LANE));
|
|
3116
3121
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
3117
3122
|
report_lane_conflict(
|
|
@@ -3166,7 +3171,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3166
3171
|
).length;
|
|
3167
3172
|
this._checkpoint = last_id;
|
|
3168
3173
|
for (const { stream, priority, lane } of streams) {
|
|
3169
|
-
if (_optionalChain([correlated, 'access',
|
|
3174
|
+
if (_optionalChain([correlated, 'access', _158 => _158.get, 'call', _159 => _159(stream), 'optionalAccess', _160 => _160.upgraded]))
|
|
3170
3175
|
this._dynamic_subscriptions.set(stream, {
|
|
3171
3176
|
priority,
|
|
3172
3177
|
lane
|
|
@@ -3186,7 +3191,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3186
3191
|
await Promise.all(
|
|
3187
3192
|
missed.map(async ([stream, entry]) => {
|
|
3188
3193
|
let row;
|
|
3189
|
-
await
|
|
3194
|
+
await _chunkDDGMSQSOcjs.store.call(void 0, ).query_streams(
|
|
3190
3195
|
(position) => {
|
|
3191
3196
|
row = position;
|
|
3192
3197
|
},
|
|
@@ -3225,7 +3230,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3225
3230
|
millis: 0
|
|
3226
3231
|
});
|
|
3227
3232
|
} catch (error) {
|
|
3228
|
-
|
|
3233
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).warn(
|
|
3229
3234
|
`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)))}`
|
|
3230
3235
|
);
|
|
3231
3236
|
}
|
|
@@ -3413,7 +3418,7 @@ var SettleLoop = (_class6 = class {
|
|
|
3413
3418
|
this._pending = true;
|
|
3414
3419
|
return;
|
|
3415
3420
|
}
|
|
3416
|
-
const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3421
|
+
const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _161 => _161.debounceMs]), () => ( this._default_debounce_ms));
|
|
3417
3422
|
const due = Date.now() + delay;
|
|
3418
3423
|
if (this._timer) {
|
|
3419
3424
|
if (due >= this._due) return;
|
|
@@ -3566,7 +3571,7 @@ var Act = (_class7 = class {
|
|
|
3566
3571
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3567
3572
|
|
|
3568
3573
|
|
|
3569
|
-
__init27() {this._logger =
|
|
3574
|
+
__init27() {this._logger = _chunkDDGMSQSOcjs.log.call(void 0, )}
|
|
3570
3575
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3571
3576
|
|
|
3572
3577
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3595,11 +3600,11 @@ var Act = (_class7 = class {
|
|
|
3595
3600
|
throw new Error(
|
|
3596
3601
|
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3597
3602
|
);
|
|
3598
|
-
|
|
3599
|
-
if (options.scoped)
|
|
3600
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3603
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "act", options);
|
|
3604
|
+
if (options.scoped) _chunkDDGMSQSOcjs.check.call(void 0, "store", options.scoped.store);
|
|
3605
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkDDGMSQSOcjs.unscoped_ports.call(void 0, )));
|
|
3601
3606
|
const ports = this._ports;
|
|
3602
|
-
this._scoped =
|
|
3607
|
+
this._scoped = _chunkDDGMSQSOcjs.make_run_scoped.call(void 0, {
|
|
3603
3608
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3604
3609
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3605
3610
|
get store() {
|
|
@@ -3609,14 +3614,14 @@ var Act = (_class7 = class {
|
|
|
3609
3614
|
return ports.cache;
|
|
3610
3615
|
},
|
|
3611
3616
|
// Parsed per build, so a bad window throws on every build.
|
|
3612
|
-
autoclose_window:
|
|
3617
|
+
autoclose_window: _chunkDDGMSQSOcjs.check.call(void 0, "autoclose", options).autocloseWindow
|
|
3613
3618
|
});
|
|
3614
3619
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3615
3620
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3616
3621
|
this._cd = build_drain(this._logger);
|
|
3617
3622
|
const handle = build_handle({
|
|
3618
3623
|
logger: this._logger,
|
|
3619
|
-
reaction_scope:
|
|
3624
|
+
reaction_scope: _chunkDDGMSQSOcjs.make_reaction_scope.call(void 0, {
|
|
3620
3625
|
do: this.do.bind(this),
|
|
3621
3626
|
load: this.load.bind(this),
|
|
3622
3627
|
query: this.query.bind(this),
|
|
@@ -3646,12 +3651,12 @@ var Act = (_class7 = class {
|
|
|
3646
3651
|
this._ports.store,
|
|
3647
3652
|
options.listen !== false
|
|
3648
3653
|
);
|
|
3649
|
-
|
|
3654
|
+
_chunkDDGMSQSOcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3650
3655
|
}
|
|
3651
3656
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3652
3657
|
_build_breaker(options) {
|
|
3653
3658
|
return new CircuitBreaker(
|
|
3654
|
-
|
|
3659
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "circuit_breaker", _nullishCoalesce(options.circuitBreaker, () => ( {}))),
|
|
3655
3660
|
{
|
|
3656
3661
|
on_error: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (error, circuit) => this._emit_error(error, circuit), "on_error"),
|
|
3657
3662
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3663,7 +3668,7 @@ var Act = (_class7 = class {
|
|
|
3663
3668
|
// Apps that declare no lanes pass no lane filter to `claim`.
|
|
3664
3669
|
_build_drain_controllers(options, lanes, handle, handle_batch) {
|
|
3665
3670
|
const all_lanes = this._declared_lanes;
|
|
3666
|
-
const only_set = _optionalChain([options, 'access',
|
|
3671
|
+
const only_set = _optionalChain([options, 'access', _162 => _162.onlyLanes, 'optionalAccess', _163 => _163.length]) ? new Set(options.onlyLanes) : void 0;
|
|
3667
3672
|
const active_lanes = only_set ? all_lanes.filter((n) => only_set.has(n)) : all_lanes;
|
|
3668
3673
|
const single_default_lane = lanes.length === 0;
|
|
3669
3674
|
const controllers = /* @__PURE__ */ new Map();
|
|
@@ -3700,7 +3705,7 @@ var Act = (_class7 = class {
|
|
|
3700
3705
|
leaseMillis: cfg.leaseMillis
|
|
3701
3706
|
}
|
|
3702
3707
|
});
|
|
3703
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
3708
|
+
if (_optionalChain([cfg, 'optionalAccess', _164 => _164.cycleMs]) !== void 0 && this._drain)
|
|
3704
3709
|
controller.start(cfg.cycleMs);
|
|
3705
3710
|
controllers.set(name, controller);
|
|
3706
3711
|
}
|
|
@@ -3719,7 +3724,7 @@ var Act = (_class7 = class {
|
|
|
3719
3724
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3720
3725
|
_build_audit_deps() {
|
|
3721
3726
|
return {
|
|
3722
|
-
store:
|
|
3727
|
+
store: _chunkDDGMSQSOcjs.store,
|
|
3723
3728
|
event_to_state: this._event_to_state,
|
|
3724
3729
|
sensitive_fields: this.registry.sensitive_fields,
|
|
3725
3730
|
// Declared lanes, not this process's controllers: a lane another
|
|
@@ -3749,10 +3754,10 @@ var Act = (_class7 = class {
|
|
|
3749
3754
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3750
3755
|
async _seed_persisted_defers() {
|
|
3751
3756
|
const now = Date.now();
|
|
3752
|
-
await walk_streams(
|
|
3757
|
+
await walk_streams(_chunkDDGMSQSOcjs.store.call(void 0, ), (pos) => {
|
|
3753
3758
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3754
3759
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3755
|
-
_optionalChain([controller, 'optionalAccess',
|
|
3760
|
+
_optionalChain([controller, 'optionalAccess', _165 => _165.seed_defer, 'call', _166 => _166(pos.stream, pos.deferred_at)]);
|
|
3756
3761
|
});
|
|
3757
3762
|
}
|
|
3758
3763
|
_build_settle(options) {
|
|
@@ -3785,7 +3790,7 @@ var Act = (_class7 = class {
|
|
|
3785
3790
|
*/
|
|
3786
3791
|
shutdown(options) {
|
|
3787
3792
|
if (!this._shutdown_promise) {
|
|
3788
|
-
|
|
3793
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "shutdown", _nullishCoalesce(options, () => ( {})));
|
|
3789
3794
|
this._shutdown_promise = (async () => {
|
|
3790
3795
|
this.stop_correlations();
|
|
3791
3796
|
this._settle.stop(true);
|
|
@@ -3793,7 +3798,7 @@ var Act = (_class7 = class {
|
|
|
3793
3798
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3794
3799
|
const disposer = await this._notify_disposer;
|
|
3795
3800
|
if (disposer) await disposer();
|
|
3796
|
-
await this._await_inflight(_optionalChain([options, 'optionalAccess',
|
|
3801
|
+
await this._await_inflight(_optionalChain([options, 'optionalAccess', _167 => _167.graceMs]));
|
|
3797
3802
|
await this._scoped(() => this._correlate.release_correlation());
|
|
3798
3803
|
this._emitter.removeAllListeners();
|
|
3799
3804
|
})();
|
|
@@ -3803,10 +3808,10 @@ var Act = (_class7 = class {
|
|
|
3803
3808
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3804
3809
|
// default for none or 0, and for a running settle), capped.
|
|
3805
3810
|
_derive_grace_ms(running, settling) {
|
|
3806
|
-
let max = settling ?
|
|
3811
|
+
let max = settling ? _chunkDDGMSQSOcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3807
3812
|
for (const c of running)
|
|
3808
|
-
max = Math.max(max, c.lease_millis ||
|
|
3809
|
-
return Math.min(max,
|
|
3813
|
+
max = Math.max(max, c.lease_millis || _chunkDDGMSQSOcjs.DEFAULT_LEASE_MILLIS);
|
|
3814
|
+
return Math.min(max, _chunkDDGMSQSOcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3810
3815
|
}
|
|
3811
3816
|
async _await_inflight(grace_ms) {
|
|
3812
3817
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3890,8 +3895,8 @@ var Act = (_class7 = class {
|
|
|
3890
3895
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3891
3896
|
*/
|
|
3892
3897
|
async do(action2, target, payload, options) {
|
|
3893
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3894
|
-
const do_options = reacting_to === _optionalChain([options, 'optionalAccess',
|
|
3898
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]), () => ( _chunkDDGMSQSOcjs.current_reacting.call(void 0, )));
|
|
3899
|
+
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _169 => _169.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3895
3900
|
return this._scoped(async () => {
|
|
3896
3901
|
const snapshots = await this._es.action(
|
|
3897
3902
|
this.registry.actions[action2],
|
|
@@ -3933,6 +3938,7 @@ var Act = (_class7 = class {
|
|
|
3933
3938
|
actor: void 0,
|
|
3934
3939
|
asOf
|
|
3935
3940
|
} : streamOrTarget;
|
|
3941
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "page", _nullishCoalesce(target.asOf, () => ( {})));
|
|
3936
3942
|
return await this._es.load(merged, target, callback);
|
|
3937
3943
|
});
|
|
3938
3944
|
}
|
|
@@ -3961,15 +3967,15 @@ var Act = (_class7 = class {
|
|
|
3961
3967
|
* @see {@link query_array} for loading events into memory
|
|
3962
3968
|
*/
|
|
3963
3969
|
async query(query, callback) {
|
|
3964
|
-
|
|
3970
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "page", query);
|
|
3965
3971
|
return this._scoped(async () => {
|
|
3966
3972
|
let first;
|
|
3967
3973
|
let last;
|
|
3968
|
-
const count = await
|
|
3974
|
+
const count = await _chunkDDGMSQSOcjs.store.call(void 0, ).query((e) => {
|
|
3969
3975
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3970
3976
|
if (!first) first = gated;
|
|
3971
3977
|
last = gated;
|
|
3972
|
-
_optionalChain([callback, 'optionalCall',
|
|
3978
|
+
_optionalChain([callback, 'optionalCall', _170 => _170(gated)]);
|
|
3973
3979
|
}, query);
|
|
3974
3980
|
return { first, last, count };
|
|
3975
3981
|
});
|
|
@@ -4011,14 +4017,14 @@ var Act = (_class7 = class {
|
|
|
4011
4017
|
*/
|
|
4012
4018
|
async forget(stream) {
|
|
4013
4019
|
return this._scoped(async () => {
|
|
4014
|
-
const s =
|
|
4020
|
+
const s = _chunkDDGMSQSOcjs.store.call(void 0, );
|
|
4015
4021
|
if (!s.forget_pii) {
|
|
4016
4022
|
throw new Error(
|
|
4017
4023
|
`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).`
|
|
4018
4024
|
);
|
|
4019
4025
|
}
|
|
4020
4026
|
const eventCount = await s.forget_pii(stream);
|
|
4021
|
-
await
|
|
4027
|
+
await _chunkDDGMSQSOcjs.cache.call(void 0, ).invalidate(stream);
|
|
4022
4028
|
if (eventCount > 0) {
|
|
4023
4029
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
4024
4030
|
}
|
|
@@ -4052,7 +4058,7 @@ var Act = (_class7 = class {
|
|
|
4052
4058
|
* @see {@link correlate} for dynamic stream discovery
|
|
4053
4059
|
*/
|
|
4054
4060
|
async drain(options = {}) {
|
|
4055
|
-
|
|
4061
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "drain", options);
|
|
4056
4062
|
if (!this._drain)
|
|
4057
4063
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
4058
4064
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4090,7 +4096,7 @@ var Act = (_class7 = class {
|
|
|
4090
4096
|
}
|
|
4091
4097
|
if (to_arm.size === 0) return false;
|
|
4092
4098
|
this._correlate.arm();
|
|
4093
|
-
for (const lane of to_arm) _optionalChain([this, 'access',
|
|
4099
|
+
for (const lane of to_arm) _optionalChain([this, 'access', _171 => _171._drain_controllers, 'access', _172 => _172.get, 'call', _173 => _173(lane), 'optionalAccess', _174 => _174.arm, 'call', _175 => _175()]);
|
|
4094
4100
|
return true;
|
|
4095
4101
|
}
|
|
4096
4102
|
// In parallel, so a slow lane never holds up a fast one.
|
|
@@ -4129,7 +4135,7 @@ var Act = (_class7 = class {
|
|
|
4129
4135
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
4130
4136
|
*/
|
|
4131
4137
|
async correlate(query = {}) {
|
|
4132
|
-
|
|
4138
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "page", query);
|
|
4133
4139
|
const pass = await this._correlate_pass(_nullishCoalesce(query.limit, () => ( 10)));
|
|
4134
4140
|
return {
|
|
4135
4141
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -4175,8 +4181,8 @@ var Act = (_class7 = class {
|
|
|
4175
4181
|
* @see {@link stop_correlations} to stop the poll
|
|
4176
4182
|
*/
|
|
4177
4183
|
start_correlations(query = {}, frequency = 1e4) {
|
|
4178
|
-
|
|
4179
|
-
|
|
4184
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "page", query);
|
|
4185
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "poll", { frequency });
|
|
4180
4186
|
if (this._poll) return false;
|
|
4181
4187
|
this._poll_limit = query.limit || void 0;
|
|
4182
4188
|
this._poll = setInterval(() => {
|
|
@@ -4213,7 +4219,7 @@ var Act = (_class7 = class {
|
|
|
4213
4219
|
// and an extra clear costs one head load per stream.
|
|
4214
4220
|
_reset_folds() {
|
|
4215
4221
|
for (const handler of this._batch_handlers.values())
|
|
4216
|
-
_optionalChain([handler, 'access',
|
|
4222
|
+
_optionalChain([handler, 'access', _176 => _176[FOLD_RESET], 'optionalCall', _177 => _177()]);
|
|
4217
4223
|
}
|
|
4218
4224
|
/**
|
|
4219
4225
|
* Reset reaction stream watermarks and settle them, replaying their
|
|
@@ -4242,7 +4248,7 @@ var Act = (_class7 = class {
|
|
|
4242
4248
|
*/
|
|
4243
4249
|
async reset(input) {
|
|
4244
4250
|
return this._scoped(async () => {
|
|
4245
|
-
const count = await
|
|
4251
|
+
const count = await _chunkDDGMSQSOcjs.store.call(void 0, ).reset(input);
|
|
4246
4252
|
this._reset_folds();
|
|
4247
4253
|
if (count > 0) {
|
|
4248
4254
|
this._wake();
|
|
@@ -4277,7 +4283,7 @@ var Act = (_class7 = class {
|
|
|
4277
4283
|
*/
|
|
4278
4284
|
async unblock(input) {
|
|
4279
4285
|
return this._scoped(async () => {
|
|
4280
|
-
const count = await
|
|
4286
|
+
const count = await _chunkDDGMSQSOcjs.store.call(void 0, ).unblock(input);
|
|
4281
4287
|
if (count > 0) {
|
|
4282
4288
|
this._wake();
|
|
4283
4289
|
}
|
|
@@ -4325,7 +4331,7 @@ var Act = (_class7 = class {
|
|
|
4325
4331
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4326
4332
|
*/
|
|
4327
4333
|
async restore(source, opts = {}, sink) {
|
|
4328
|
-
|
|
4334
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "scan", opts);
|
|
4329
4335
|
return this._scoped(async () => {
|
|
4330
4336
|
const started = Date.now();
|
|
4331
4337
|
if (opts.dry_run) {
|
|
@@ -4333,7 +4339,7 @@ var Act = (_class7 = class {
|
|
|
4333
4339
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4334
4340
|
}
|
|
4335
4341
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4336
|
-
const s =
|
|
4342
|
+
const s = _chunkDDGMSQSOcjs.store.call(void 0, );
|
|
4337
4343
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4338
4344
|
return s;
|
|
4339
4345
|
})()));
|
|
@@ -4378,14 +4384,14 @@ var Act = (_class7 = class {
|
|
|
4378
4384
|
* ```
|
|
4379
4385
|
*/
|
|
4380
4386
|
async blocked_streams(options) {
|
|
4381
|
-
|
|
4387
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "page", { limit: _optionalChain([options, 'optionalAccess', _178 => _178.limit]) });
|
|
4382
4388
|
return this._scoped(async () => {
|
|
4383
4389
|
const positions = [];
|
|
4384
|
-
await
|
|
4390
|
+
await _chunkDDGMSQSOcjs.store.call(void 0, ).query_streams(
|
|
4385
4391
|
(p) => {
|
|
4386
4392
|
positions.push(p);
|
|
4387
4393
|
},
|
|
4388
|
-
{ blocked: true, after: _optionalChain([options, 'optionalAccess',
|
|
4394
|
+
{ blocked: true, after: _optionalChain([options, 'optionalAccess', _179 => _179.after]), limit: _optionalChain([options, 'optionalAccess', _180 => _180.limit]) }
|
|
4389
4395
|
);
|
|
4390
4396
|
return positions;
|
|
4391
4397
|
});
|
|
@@ -4407,7 +4413,7 @@ var Act = (_class7 = class {
|
|
|
4407
4413
|
* ```
|
|
4408
4414
|
*/
|
|
4409
4415
|
async *audit(categories, options) {
|
|
4410
|
-
|
|
4416
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "audit", _nullishCoalesce(options, () => ( {})));
|
|
4411
4417
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4412
4418
|
while (true) {
|
|
4413
4419
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4435,8 +4441,8 @@ var Act = (_class7 = class {
|
|
|
4435
4441
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4436
4442
|
*/
|
|
4437
4443
|
async prioritize(filter, priority) {
|
|
4438
|
-
|
|
4439
|
-
return this._scoped(() =>
|
|
4444
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "target", { priority });
|
|
4445
|
+
return this._scoped(() => _chunkDDGMSQSOcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4440
4446
|
}
|
|
4441
4447
|
// Shared by `close()` and reaction-requested closes.
|
|
4442
4448
|
async _run_close(targets) {
|
|
@@ -4516,7 +4522,7 @@ var Act = (_class7 = class {
|
|
|
4516
4522
|
* @see {@link correlate} for manual correlation
|
|
4517
4523
|
*/
|
|
4518
4524
|
settle(options) {
|
|
4519
|
-
|
|
4525
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "settle", _nullishCoalesce(options, () => ( {})));
|
|
4520
4526
|
this._schedule(options);
|
|
4521
4527
|
}
|
|
4522
4528
|
}, _class7);
|
|
@@ -4732,7 +4738,7 @@ var _this_ = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, ({ stream })
|
|
|
4732
4738
|
|
|
4733
4739
|
// src/builders/builder-utils.ts
|
|
4734
4740
|
function register_lane(config2, lanes) {
|
|
4735
|
-
|
|
4741
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "lane", config2);
|
|
4736
4742
|
if (config2.name === _chunkLA2BPKNScjs.DEFAULT_LANE)
|
|
4737
4743
|
throw new Error(`Lane "${_chunkLA2BPKNScjs.DEFAULT_LANE}" is reserved`);
|
|
4738
4744
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
@@ -4757,7 +4763,7 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4757
4763
|
events[event].reactions.set(name, reaction);
|
|
4758
4764
|
return Object.assign(builder, {
|
|
4759
4765
|
to(resolver) {
|
|
4760
|
-
if (typeof resolver === "object")
|
|
4766
|
+
if (typeof resolver === "object") _chunkDDGMSQSOcjs.check.call(void 0, "target", resolver);
|
|
4761
4767
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4762
4768
|
return builder;
|
|
4763
4769
|
}
|
|
@@ -4772,17 +4778,17 @@ function reaction_on(event, events, builder) {
|
|
|
4772
4778
|
"Reaction",
|
|
4773
4779
|
() => {
|
|
4774
4780
|
if (schedule && typeof schedule !== "function")
|
|
4775
|
-
|
|
4781
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "defer", schedule);
|
|
4776
4782
|
return {
|
|
4777
4783
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4778
4784
|
resolver: _this_,
|
|
4779
4785
|
// Validate the whole bag at the declaration site so a bad
|
|
4780
4786
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4781
4787
|
// not a NaN gate on the first retry.
|
|
4782
|
-
options:
|
|
4783
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4784
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4785
|
-
backoff: _optionalChain([options, 'optionalAccess',
|
|
4788
|
+
options: _chunkDDGMSQSOcjs.check.call(void 0, "reaction", {
|
|
4789
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _181 => _181.blockOnError]), () => ( _chunkDDGMSQSOcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4790
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.maxRetries]), () => ( _chunkDDGMSQSOcjs.DEFAULT_MAX_RETRIES)),
|
|
4791
|
+
backoff: _optionalChain([options, 'optionalAccess', _183 => _183.backoff])
|
|
4786
4792
|
})
|
|
4787
4793
|
};
|
|
4788
4794
|
},
|
|
@@ -4804,24 +4810,19 @@ _chunkLA2BPKNScjs.__name.call(void 0, reaction_on, "reaction_on");
|
|
|
4804
4810
|
var SENSITIVE = /* @__PURE__ */ Symbol.for("act.sensitive");
|
|
4805
4811
|
var is_pii = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (schema) => some_layer(schema, (def) => def[SENSITIVE] === true), "is_pii");
|
|
4806
4812
|
function pii_schemas(schema) {
|
|
4813
|
+
const fields = {};
|
|
4807
4814
|
const shape = schema.shape;
|
|
4808
4815
|
if (shape && typeof shape === "object") {
|
|
4809
|
-
const fields = {};
|
|
4810
4816
|
for (const key of Object.keys(shape))
|
|
4811
4817
|
if (is_pii(shape[key])) fields[key] = shape[key];
|
|
4812
4818
|
return fields;
|
|
4813
4819
|
}
|
|
4814
4820
|
const options = schema.options;
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
for (const
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
))
|
|
4821
|
-
fields[key] ??= field;
|
|
4822
|
-
return fields;
|
|
4823
|
-
}
|
|
4824
|
-
return {};
|
|
4821
|
+
const parts = Array.isArray(options) ? options : parts_of(schema);
|
|
4822
|
+
for (const part of parts)
|
|
4823
|
+
for (const [key, field] of Object.entries(pii_schemas(part)))
|
|
4824
|
+
fields[key] ??= field;
|
|
4825
|
+
return fields;
|
|
4825
4826
|
}
|
|
4826
4827
|
_chunkLA2BPKNScjs.__name.call(void 0, pii_schemas, "pii_schemas");
|
|
4827
4828
|
|
|
@@ -4955,7 +4956,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4955
4956
|
}
|
|
4956
4957
|
_chunkLA2BPKNScjs.__name.call(void 0, build_events, "build_events");
|
|
4957
4958
|
function reads_as_string(schema) {
|
|
4958
|
-
const type = _optionalChain([def_of, 'call',
|
|
4959
|
+
const type = _optionalChain([def_of, 'call', _184 => _184(output_of(schema)), 'optionalAccess', _185 => _185.type]);
|
|
4959
4960
|
return type === "string" || type === "transform";
|
|
4960
4961
|
}
|
|
4961
4962
|
_chunkLA2BPKNScjs.__name.call(void 0, reads_as_string, "reads_as_string");
|
|
@@ -5015,7 +5016,7 @@ function act() {
|
|
|
5015
5016
|
let _built = false;
|
|
5016
5017
|
const read_wrap = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (original) => {
|
|
5017
5018
|
const wrapped2 = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (events, stream) => {
|
|
5018
|
-
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access',
|
|
5019
|
+
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _186 => _186.get, 'call', _187 => _187(e.name), 'optionalCall', _188 => _188(e)]), () => ( e)));
|
|
5019
5020
|
return original(read, stream);
|
|
5020
5021
|
}, "wrapped");
|
|
5021
5022
|
const reset = original[FOLD_RESET];
|
|
@@ -5056,7 +5057,7 @@ function act() {
|
|
|
5056
5057
|
});
|
|
5057
5058
|
}
|
|
5058
5059
|
for (const [action_name, handler] of Object.entries(state2.on)) {
|
|
5059
|
-
const static_target = _optionalChain([handler, 'optionalAccess',
|
|
5060
|
+
const static_target = _optionalChain([handler, 'optionalAccess', _189 => _189._static_emit]);
|
|
5060
5061
|
if (static_target && deprecated.has(static_target)) {
|
|
5061
5062
|
const current = current_version_of(static_target, event_names);
|
|
5062
5063
|
throw new Error(
|
|
@@ -5069,7 +5070,7 @@ function act() {
|
|
|
5069
5070
|
const list = deprecation_summary.map(
|
|
5070
5071
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
5071
5072
|
).join(", ");
|
|
5072
|
-
|
|
5073
|
+
_chunkDDGMSQSOcjs.log.call(void 0, ).info(
|
|
5073
5074
|
`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.`
|
|
5074
5075
|
);
|
|
5075
5076
|
}
|
|
@@ -5128,7 +5129,7 @@ function act() {
|
|
|
5128
5129
|
`State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
|
|
5129
5130
|
);
|
|
5130
5131
|
const claimed = fold_specs.find((s) => s.target === proj.target);
|
|
5131
|
-
if (_optionalChain([claimed, 'optionalAccess',
|
|
5132
|
+
if (_optionalChain([claimed, 'optionalAccess', _190 => _190.projection]) === proj) continue;
|
|
5132
5133
|
if (batch_handlers.has(proj.target) || claimed)
|
|
5133
5134
|
throw new Error(
|
|
5134
5135
|
`Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
|
|
@@ -5150,7 +5151,7 @@ function act() {
|
|
|
5150
5151
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
5151
5152
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
5152
5153
|
finalize_deprecations();
|
|
5153
|
-
if (built.advisory)
|
|
5154
|
+
if (built.advisory) _chunkDDGMSQSOcjs.log.call(void 0, ).warn(built.advisory);
|
|
5154
5155
|
for (const [name, state2] of states) {
|
|
5155
5156
|
if (!state2.loads) continue;
|
|
5156
5157
|
const resolved = {};
|
|
@@ -5162,7 +5163,7 @@ function act() {
|
|
|
5162
5163
|
`Action "${action2}" loads "${l.state.name}", which is not registered \u2014 add it via withState/withSlice before build()`
|
|
5163
5164
|
);
|
|
5164
5165
|
const deprecated = l.events.find(
|
|
5165
|
-
(e) => _optionalChain([_de, 'access',
|
|
5166
|
+
(e) => _optionalChain([_de, 'access', _191 => _191.get, 'call', _192 => _192(registered.name), 'optionalAccess', _193 => _193.has, 'call', _194 => _194(e)])
|
|
5166
5167
|
);
|
|
5167
5168
|
if (deprecated)
|
|
5168
5169
|
throw new Error(
|
|
@@ -5194,7 +5195,7 @@ function act() {
|
|
|
5194
5195
|
synthesize_autoclose_reactions(
|
|
5195
5196
|
registry,
|
|
5196
5197
|
states,
|
|
5197
|
-
|
|
5198
|
+
_chunkDDGMSQSOcjs.current_autoclose_window
|
|
5198
5199
|
);
|
|
5199
5200
|
Object.freeze(registry.actions);
|
|
5200
5201
|
Object.freeze(registry.events);
|
|
@@ -5243,8 +5244,8 @@ function _projection(target) {
|
|
|
5243
5244
|
handler,
|
|
5244
5245
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5245
5246
|
options: {
|
|
5246
|
-
blockOnError:
|
|
5247
|
-
maxRetries:
|
|
5247
|
+
blockOnError: _chunkDDGMSQSOcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5248
|
+
maxRetries: _chunkDDGMSQSOcjs.DEFAULT_MAX_RETRIES
|
|
5248
5249
|
}
|
|
5249
5250
|
}),
|
|
5250
5251
|
widened
|
|
@@ -5285,7 +5286,7 @@ function _projection(target) {
|
|
|
5285
5286
|
throw new Error(
|
|
5286
5287
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5287
5288
|
);
|
|
5288
|
-
const config2 =
|
|
5289
|
+
const config2 = _chunkDDGMSQSOcjs.check.call(void 0, "fold", options);
|
|
5289
5290
|
const fold_events = {};
|
|
5290
5291
|
for (const partial of partials)
|
|
5291
5292
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5303,8 +5304,8 @@ function _projection(target) {
|
|
|
5303
5304
|
handler: noop,
|
|
5304
5305
|
resolver: { target },
|
|
5305
5306
|
options: {
|
|
5306
|
-
blockOnError:
|
|
5307
|
-
maxRetries:
|
|
5307
|
+
blockOnError: _chunkDDGMSQSOcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5308
|
+
maxRetries: _chunkDDGMSQSOcjs.DEFAULT_MAX_RETRIES
|
|
5308
5309
|
}
|
|
5309
5310
|
}
|
|
5310
5311
|
]
|
|
@@ -5424,7 +5425,7 @@ function action_builder(state2) {
|
|
|
5424
5425
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5425
5426
|
internal.actions[action2] = schema;
|
|
5426
5427
|
if (options) {
|
|
5427
|
-
|
|
5428
|
+
_chunkDDGMSQSOcjs.check.call(void 0, "action", options);
|
|
5428
5429
|
internal.options ??= {};
|
|
5429
5430
|
internal.options[action2] = options;
|
|
5430
5431
|
}
|
|
@@ -5714,9 +5715,9 @@ var ExitCodes2 = _chunkLA2BPKNScjs.ExitCodes;
|
|
|
5714
5715
|
var DEFAULT_LANE2 = _chunkLA2BPKNScjs.DEFAULT_LANE;
|
|
5715
5716
|
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkLA2BPKNScjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5716
5717
|
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkLA2BPKNScjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5717
|
-
var PackageSchema =
|
|
5718
|
-
var default_scope =
|
|
5719
|
-
var extend = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (source, schema, target) => ({ ...target, ...
|
|
5718
|
+
var PackageSchema = _chunkDDGMSQSOcjs.package_schema;
|
|
5719
|
+
var default_scope = _chunkDDGMSQSOcjs.unscoped_ports;
|
|
5720
|
+
var extend = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (source, schema, target) => ({ ...target, ..._chunkDDGMSQSOcjs.validate.call(void 0, "config", source, schema) }), "extend");
|
|
5720
5721
|
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])?$/;
|
|
5721
5722
|
var dateReviver = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
|
|
5722
5723
|
function sensitiveFields(schema) {
|
|
@@ -5783,5 +5784,5 @@ var pii_fields = sensitiveFields;
|
|
|
5783
5784
|
|
|
5784
5785
|
|
|
5785
5786
|
|
|
5786
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkLA2BPKNScjs.ConcurrencyError; exports.ConsoleLogger =
|
|
5787
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkLA2BPKNScjs.ConcurrencyError; exports.ConsoleLogger = _chunkDDGMSQSOcjs.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 = _chunkLA2BPKNScjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunkLA2BPKNScjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkDDGMSQSOcjs.InMemoryCache; exports.InMemoryStore = _chunkDDGMSQSOcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunkLA2BPKNScjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunkLA2BPKNScjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunkLA2BPKNScjs.REDACTED; exports.SHREDDED = _chunkLA2BPKNScjs.SHREDDED; exports.SNAP_EVENT = _chunkLA2BPKNScjs.SNAP_EVENT; exports.StoreError = _chunkLA2BPKNScjs.StoreError; exports.StreamClosedError = _chunkLA2BPKNScjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkLA2BPKNScjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunkLA2BPKNScjs.ValidationError; exports.ZodEmpty = _chunkLA2BPKNScjs.ZodEmpty; exports.act = act; exports.cache = _chunkDDGMSQSOcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkDDGMSQSOcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkDDGMSQSOcjs.dispose; exports.disposeAndExit = _chunkDDGMSQSOcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkDDGMSQSOcjs.log; exports.notification_of = notification_of; exports.pii_fields = pii_fields; exports.port = _chunkDDGMSQSOcjs.port; exports.projection = projection; exports.seed_event = seed_event; exports.sensitive = _chunkLA2BPKNScjs.sensitive; exports.sensitiveFields = sensitiveFields; exports.sleep = _chunkDDGMSQSOcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkDDGMSQSOcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkDDGMSQSOcjs.validate;
|
|
5787
5788
|
//# sourceMappingURL=index.cjs.map
|