@rotorsoft/act 1.33.0 → 1.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +59 -156
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/types/act.d.ts +4 -6
- package/dist/@types/types/act.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +2 -2
- package/dist/@types/types/builders.d.ts +2 -3
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +5 -9
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/{chunk-HF433MAF.cjs → chunk-NNWP65YM.cjs} +1 -1
- package/dist/chunk-NNWP65YM.cjs.map +1 -0
- package/dist/{chunk-JABYJGT7.js → chunk-NYH6FNTM.js} +2 -2
- package/dist/{chunk-2PMUONGF.js → chunk-TJ4JRRUR.js} +1 -1
- package/dist/chunk-TJ4JRRUR.js.map +1 -0
- package/dist/{chunk-VE3MTY4A.cjs → chunk-YKL44PYX.cjs} +14 -14
- package/dist/{chunk-VE3MTY4A.cjs.map → chunk-YKL44PYX.cjs.map} +1 -1
- package/dist/index.cjs +197 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -147
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +4 -4
- package/dist/test/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-2PMUONGF.js.map +0 -1
- package/dist/chunk-HF433MAF.cjs.map +0 -1
- /package/dist/{chunk-JABYJGT7.js.map → chunk-NYH6FNTM.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkYKL44PYXcjs = require('./chunk-YKL44PYX.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -70,24 +70,24 @@ var _chunkVE3MTY4Acjs = require('./chunk-VE3MTY4A.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var
|
|
73
|
+
var _chunkNNWP65YMcjs = require('./chunk-NNWP65YM.cjs');
|
|
74
74
|
|
|
75
75
|
// src/signals.ts
|
|
76
76
|
process.once("SIGINT", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
78
|
+
await _chunkYKL44PYXcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("SIGTERM", async (arg) => {
|
|
81
|
-
|
|
82
|
-
await
|
|
81
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
82
|
+
await _chunkYKL44PYXcjs.disposeAndExit.call(void 0, "EXIT");
|
|
83
83
|
});
|
|
84
84
|
process.once("uncaughtException", async (arg) => {
|
|
85
|
-
|
|
86
|
-
await
|
|
85
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
86
|
+
await _chunkYKL44PYXcjs.disposeAndExit.call(void 0, "ERROR");
|
|
87
87
|
});
|
|
88
88
|
process.once("unhandledRejection", async (arg) => {
|
|
89
|
-
|
|
90
|
-
await
|
|
89
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
90
|
+
await _chunkYKL44PYXcjs.disposeAndExit.call(void 0, "ERROR");
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// src/act.ts
|
|
@@ -195,7 +195,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
195
195
|
if (need_stats) {
|
|
196
196
|
const stats = await deps.store().query_stats(
|
|
197
197
|
{},
|
|
198
|
-
{ count: true, names: true, exclude: [
|
|
198
|
+
{ count: true, names: true, exclude: [_chunkNNWP65YMcjs.SNAP_EVENT] }
|
|
199
199
|
);
|
|
200
200
|
for (const [stream, s] of stats) {
|
|
201
201
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -277,7 +277,7 @@ var make_schema_pass = (deps) => {
|
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
const schema = state2.events[name];
|
|
280
|
-
const sensitive2 =
|
|
280
|
+
const sensitive2 = _chunkNNWP65YMcjs.pii_fields.call(void 0, schema);
|
|
281
281
|
let parse_schema = schema;
|
|
282
282
|
if (sensitive2.length > 0) {
|
|
283
283
|
const omitter = schema.omit;
|
|
@@ -411,7 +411,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
411
411
|
{
|
|
412
412
|
stream,
|
|
413
413
|
stream_exact: true,
|
|
414
|
-
names: [
|
|
414
|
+
names: [_chunkNNWP65YMcjs.SNAP_EVENT],
|
|
415
415
|
with_snaps: true
|
|
416
416
|
}
|
|
417
417
|
);
|
|
@@ -840,7 +840,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
840
840
|
deps,
|
|
841
841
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
842
842
|
);
|
|
843
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
843
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkNNWP65YMcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
844
844
|
if (retired.length) _optionalChain([deps, 'access', _42 => _42.forget_subscribed, 'optionalCall', _43 => _43(retired)]);
|
|
845
845
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
846
846
|
return { truncated, skipped };
|
|
@@ -922,7 +922,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
922
922
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
923
923
|
return void 0;
|
|
924
924
|
if (t.archive) await t.archive();
|
|
925
|
-
const result = await
|
|
925
|
+
const result = await _chunkYKL44PYXcjs.store.call(void 0, ).truncate([
|
|
926
926
|
{ stream: t.stream, before: t.before, max_id }
|
|
927
927
|
]);
|
|
928
928
|
return result.get(t.stream);
|
|
@@ -935,10 +935,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
935
935
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
936
936
|
let boundary_id;
|
|
937
937
|
let min_id;
|
|
938
|
-
await
|
|
938
|
+
await _chunkYKL44PYXcjs.store.call(void 0, ).query(
|
|
939
939
|
(event) => {
|
|
940
940
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
941
|
-
if (event.name ===
|
|
941
|
+
if (event.name === _chunkNNWP65YMcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
942
942
|
boundary_id = event.id;
|
|
943
943
|
},
|
|
944
944
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -949,7 +949,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
949
949
|
const min_at = /* @__PURE__ */ new Map();
|
|
950
950
|
const matches = source_matcher();
|
|
951
951
|
await walk_streams(
|
|
952
|
-
|
|
952
|
+
_chunkYKL44PYXcjs.store.call(void 0, ),
|
|
953
953
|
(position) => {
|
|
954
954
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
955
955
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -977,17 +977,17 @@ function source_matcher() {
|
|
|
977
977
|
};
|
|
978
978
|
}
|
|
979
979
|
async function scan_stream_heads(streams) {
|
|
980
|
-
const stats = await
|
|
981
|
-
exclude: [
|
|
980
|
+
const stats = await _chunkYKL44PYXcjs.store.call(void 0, ).query_stats(streams, {
|
|
981
|
+
exclude: [_chunkNNWP65YMcjs.SNAP_EVENT]
|
|
982
982
|
});
|
|
983
|
-
const domain_heads = await
|
|
984
|
-
exclude: [
|
|
983
|
+
const domain_heads = await _chunkYKL44PYXcjs.store.call(void 0, ).query_stats(streams, {
|
|
984
|
+
exclude: [_chunkNNWP65YMcjs.SNAP_EVENT, _chunkNNWP65YMcjs.TOMBSTONE_EVENT]
|
|
985
985
|
});
|
|
986
|
-
const true_heads = await
|
|
986
|
+
const true_heads = await _chunkYKL44PYXcjs.store.call(void 0, ).query_stats(streams, {});
|
|
987
987
|
const out = /* @__PURE__ */ new Map();
|
|
988
988
|
for (const [stream, { head }] of domain_heads) {
|
|
989
989
|
const marker_head = _optionalChain([stats, 'access', _45 => _45.get, 'call', _46 => _46(stream), 'optionalAccess', _47 => _47.head]);
|
|
990
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) ===
|
|
990
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunkNNWP65YMcjs.TOMBSTONE_EVENT;
|
|
991
991
|
out.set(stream, {
|
|
992
992
|
max_id: head.id,
|
|
993
993
|
version: true_heads.get(stream).head.version,
|
|
@@ -1011,7 +1011,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
1011
1011
|
const matches = source_matcher();
|
|
1012
1012
|
const targets = [...stream_info.keys()];
|
|
1013
1013
|
await walk_streams(
|
|
1014
|
-
|
|
1014
|
+
_chunkYKL44PYXcjs.store.call(void 0, ),
|
|
1015
1015
|
(position) => {
|
|
1016
1016
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
1017
1017
|
if (!has_work) return;
|
|
@@ -1077,7 +1077,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
1079
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
1080
|
-
const heads = await
|
|
1080
|
+
const heads = await _chunkYKL44PYXcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
1081
1081
|
return guarded.filter((stream) => {
|
|
1082
1082
|
if (_optionalChain([heads, 'access', _55 => _55.get, 'call', _56 => _56(stream), 'optionalAccess', _57 => _57.head, 'access', _58 => _58.id]) === guard_events.get(stream).id)
|
|
1083
1083
|
return true;
|
|
@@ -1095,18 +1095,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1095
1095
|
meta: {
|
|
1096
1096
|
correlation,
|
|
1097
1097
|
causation: {
|
|
1098
|
-
event: { id: guard.id, name:
|
|
1098
|
+
event: { id: guard.id, name: _chunkNNWP65YMcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
};
|
|
1102
1102
|
});
|
|
1103
|
-
const truncated = await
|
|
1103
|
+
const truncated = await _chunkYKL44PYXcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
1104
1104
|
await Promise.all(
|
|
1105
1105
|
guarded.map(async (stream) => {
|
|
1106
1106
|
const entry = truncated.get(stream);
|
|
1107
1107
|
const state2 = seed_states.get(stream);
|
|
1108
1108
|
if (state2 && entry) {
|
|
1109
|
-
await
|
|
1109
|
+
await _chunkYKL44PYXcjs.cache.call(void 0, ).set(stream, {
|
|
1110
1110
|
stream,
|
|
1111
1111
|
state: state2,
|
|
1112
1112
|
version: entry.committed.version,
|
|
@@ -1115,7 +1115,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1115
1115
|
snaps: 1
|
|
1116
1116
|
});
|
|
1117
1117
|
} else {
|
|
1118
|
-
await
|
|
1118
|
+
await _chunkYKL44PYXcjs.cache.call(void 0, ).invalidate(stream);
|
|
1119
1119
|
}
|
|
1120
1120
|
})
|
|
1121
1121
|
);
|
|
@@ -1129,7 +1129,7 @@ var _crypto = require('crypto');
|
|
|
1129
1129
|
function report_once(seen, key, message) {
|
|
1130
1130
|
if (seen.has(key)) return;
|
|
1131
1131
|
seen.add(key);
|
|
1132
|
-
|
|
1132
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).error(new Error(message));
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
// src/internal/correlate-cycle.ts
|
|
@@ -1169,7 +1169,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1169
1169
|
// never drops their +Infinity floor.
|
|
1170
1170
|
|
|
1171
1171
|
__init8() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1172
|
-
__init9() {this._patterns = new (0,
|
|
1172
|
+
__init9() {this._patterns = new (0, _chunkYKL44PYXcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1173
1173
|
|
|
1174
1174
|
|
|
1175
1175
|
|
|
@@ -1190,7 +1190,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1190
1190
|
on_init_async
|
|
1191
1191
|
}) {;_class3.prototype.__init3.call(this);_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);
|
|
1192
1192
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1193
|
-
this._dynamic_subscriptions = new (0,
|
|
1193
|
+
this._dynamic_subscriptions = new (0, _chunkYKL44PYXcjs.LruMap)(max_subscribed_streams);
|
|
1194
1194
|
this._registry = registry;
|
|
1195
1195
|
this._declared_lanes = declared_lanes;
|
|
1196
1196
|
this._static_targets = static_targets;
|
|
@@ -1247,7 +1247,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1247
1247
|
/** Would the target's own `fetch` (filtered by `source`) return this event? */
|
|
1248
1248
|
_in_fetch_window(source, stream) {
|
|
1249
1249
|
if (source === void 0 || source === stream) return true;
|
|
1250
|
-
if (
|
|
1250
|
+
if (_chunkYKL44PYXcjs.is_literal_source.call(void 0, source)) return false;
|
|
1251
1251
|
let pattern = this._patterns.get(source);
|
|
1252
1252
|
if (!pattern) {
|
|
1253
1253
|
pattern = new RegExp(source);
|
|
@@ -1285,7 +1285,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1285
1285
|
const correlated = /* @__PURE__ */ new Map();
|
|
1286
1286
|
let last_id = after;
|
|
1287
1287
|
let stopped = false;
|
|
1288
|
-
const found = await
|
|
1288
|
+
const found = await _chunkYKL44PYXcjs.store.call(void 0, ).query(
|
|
1289
1289
|
(event) => {
|
|
1290
1290
|
if (stopped) return;
|
|
1291
1291
|
const register = this._registry.events[event.name];
|
|
@@ -1329,9 +1329,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1329
1329
|
correlated_at: void 0
|
|
1330
1330
|
};
|
|
1331
1331
|
const seen_in_scan = correlated.has(resolved.target);
|
|
1332
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _63 => _63.lane])), () => (
|
|
1332
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _63 => _63.lane])), () => ( _chunkNNWP65YMcjs.DEFAULT_LANE));
|
|
1333
1333
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _64 => _64.priority]);
|
|
1334
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
1334
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkNNWP65YMcjs.DEFAULT_LANE));
|
|
1335
1335
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1336
1336
|
report_lane_conflict(
|
|
1337
1337
|
this._reported,
|
|
@@ -1406,7 +1406,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1406
1406
|
await Promise.all(
|
|
1407
1407
|
missed.map(async ([stream, entry]) => {
|
|
1408
1408
|
let row;
|
|
1409
|
-
await
|
|
1409
|
+
await _chunkYKL44PYXcjs.store.call(void 0, ).query_streams(
|
|
1410
1410
|
(position) => {
|
|
1411
1411
|
row = position;
|
|
1412
1412
|
},
|
|
@@ -1419,8 +1419,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1419
1419
|
lane: row.lane
|
|
1420
1420
|
});
|
|
1421
1421
|
if (entry.priority > row.priority) return;
|
|
1422
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
1423
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
1422
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkNNWP65YMcjs.DEFAULT_LANE));
|
|
1423
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkNNWP65YMcjs.DEFAULT_LANE));
|
|
1424
1424
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
1425
1425
|
report_lane_conflict(
|
|
1426
1426
|
this._reported,
|
|
@@ -1445,7 +1445,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1445
1445
|
millis: 0
|
|
1446
1446
|
});
|
|
1447
1447
|
} catch (error) {
|
|
1448
|
-
|
|
1448
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).warn(
|
|
1449
1449
|
`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(error)}`
|
|
1450
1450
|
);
|
|
1451
1451
|
}
|
|
@@ -1598,14 +1598,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
1600
|
// src/internal/drain-ops.ts
|
|
1601
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1601
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkYKL44PYXcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1602
1602
|
async function fetch(leased, eventLimit) {
|
|
1603
1603
|
return Promise.all(
|
|
1604
1604
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1605
1605
|
const events = [];
|
|
1606
|
-
const stream_exact = source !== void 0 &&
|
|
1606
|
+
const stream_exact = source !== void 0 && _chunkYKL44PYXcjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1607
1607
|
try {
|
|
1608
|
-
await
|
|
1608
|
+
await _chunkYKL44PYXcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1609
1609
|
stream: source,
|
|
1610
1610
|
stream_exact,
|
|
1611
1611
|
after: at,
|
|
@@ -1625,30 +1625,30 @@ async function fetch(leased, eventLimit) {
|
|
|
1625
1625
|
})
|
|
1626
1626
|
);
|
|
1627
1627
|
}
|
|
1628
|
-
var ack = (leases) =>
|
|
1629
|
-
var block = (leases) =>
|
|
1630
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1628
|
+
var ack = (leases) => _chunkYKL44PYXcjs.store.call(void 0, ).ack(leases);
|
|
1629
|
+
var block = (leases) => _chunkYKL44PYXcjs.store.call(void 0, ).block(leases);
|
|
1630
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkYKL44PYXcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1631
1631
|
|
|
1632
1632
|
// src/internal/event-sourcing.ts
|
|
1633
1633
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1634
1634
|
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1635
1635
|
var validating_patch = (me, state2, partial, event) => {
|
|
1636
1636
|
const next = _actpatch.patch.call(void 0, state2, partial);
|
|
1637
|
-
return
|
|
1637
|
+
return _chunkYKL44PYXcjs.validate.call(void 0,
|
|
1638
1638
|
`${me.name}.${String(event.name)}#${event.id}`,
|
|
1639
1639
|
next,
|
|
1640
1640
|
me.state
|
|
1641
1641
|
);
|
|
1642
1642
|
};
|
|
1643
1643
|
var DEFAULT_BATCH = 500;
|
|
1644
|
-
var cache_put = (stream, entry) =>
|
|
1645
|
-
(err) =>
|
|
1644
|
+
var cache_put = (stream, entry) => _chunkYKL44PYXcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1645
|
+
(err) => _chunkYKL44PYXcjs.log.call(void 0, ).warn(
|
|
1646
1646
|
err,
|
|
1647
1647
|
"cache set skipped; the next load re-folds from the store"
|
|
1648
1648
|
)
|
|
1649
1649
|
);
|
|
1650
|
-
var cache_drop = (stream) =>
|
|
1651
|
-
(err) =>
|
|
1650
|
+
var cache_drop = (stream) => _chunkYKL44PYXcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1651
|
+
(err) => _chunkYKL44PYXcjs.log.call(void 0, ).warn(
|
|
1652
1652
|
err,
|
|
1653
1653
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1654
1654
|
)
|
|
@@ -1656,9 +1656,9 @@ var cache_drop = (stream) => _chunkVE3MTY4Acjs.cache.call(void 0, ).invalidate(s
|
|
|
1656
1656
|
async function snap(snapshot) {
|
|
1657
1657
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1658
1658
|
try {
|
|
1659
|
-
const [committed] = await
|
|
1659
|
+
const [committed] = await _chunkYKL44PYXcjs.store.call(void 0, ).commit(
|
|
1660
1660
|
stream,
|
|
1661
|
-
[{ name:
|
|
1661
|
+
[{ name: _chunkNNWP65YMcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1662
1662
|
{
|
|
1663
1663
|
correlation: meta.correlation,
|
|
1664
1664
|
causation: { event: { id, name, stream } }
|
|
@@ -1669,22 +1669,22 @@ async function snap(snapshot) {
|
|
|
1669
1669
|
return committed;
|
|
1670
1670
|
} catch (error) {
|
|
1671
1671
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1672
|
-
|
|
1672
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).warn(
|
|
1673
1673
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1674
1674
|
);
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
1677
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1678
1678
|
try {
|
|
1679
|
-
const [committed] = await
|
|
1679
|
+
const [committed] = await _chunkYKL44PYXcjs.store.call(void 0, ).commit(
|
|
1680
1680
|
stream,
|
|
1681
|
-
[{ name:
|
|
1681
|
+
[{ name: _chunkNNWP65YMcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1682
1682
|
{ correlation, causation: {} },
|
|
1683
1683
|
expectedVersion
|
|
1684
1684
|
);
|
|
1685
1685
|
return committed;
|
|
1686
1686
|
} catch (error) {
|
|
1687
|
-
if (error instanceof
|
|
1687
|
+
if (error instanceof _chunkNNWP65YMcjs.ConcurrencyError) return void 0;
|
|
1688
1688
|
throw error;
|
|
1689
1689
|
}
|
|
1690
1690
|
}
|
|
@@ -1714,9 +1714,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1714
1714
|
if (drop_closed_streams) {
|
|
1715
1715
|
await source.query(
|
|
1716
1716
|
(e) => {
|
|
1717
|
-
if (e.name ===
|
|
1717
|
+
if (e.name === _chunkNNWP65YMcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1718
1718
|
},
|
|
1719
|
-
{ names: [
|
|
1719
|
+
{ names: [_chunkNNWP65YMcjs.TOMBSTONE_EVENT] }
|
|
1720
1720
|
);
|
|
1721
1721
|
}
|
|
1722
1722
|
let max_id;
|
|
@@ -1738,11 +1738,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1738
1738
|
if (!is_valid(event))
|
|
1739
1739
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1740
1740
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1741
|
-
if (drop_snapshots && event.name ===
|
|
1741
|
+
if (drop_snapshots && event.name === _chunkNNWP65YMcjs.SNAP_EVENT) {
|
|
1742
1742
|
dropped_snaps++;
|
|
1743
1743
|
return;
|
|
1744
1744
|
}
|
|
1745
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1745
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkNNWP65YMcjs.TOMBSTONE_EVENT) {
|
|
1746
1746
|
dropped_closed++;
|
|
1747
1747
|
return;
|
|
1748
1748
|
}
|
|
@@ -1809,17 +1809,17 @@ async function scan(source, opts = {}, callback) {
|
|
|
1809
1809
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1810
1810
|
const { stream, actor, asOf } = target;
|
|
1811
1811
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1812
|
-
const cached = time_travel ? void 0 : await
|
|
1812
|
+
const cached = time_travel ? void 0 : await _chunkYKL44PYXcjs.cache.call(void 0, ).get(stream);
|
|
1813
1813
|
const cache_hit = !!cached;
|
|
1814
1814
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.state]), () => ( (me.init ? me.init() : {})));
|
|
1815
1815
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _75 => _75.patches]), () => ( 0));
|
|
1816
1816
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _76 => _76.snaps]), () => ( 0));
|
|
1817
1817
|
let replayed = 0;
|
|
1818
1818
|
let event;
|
|
1819
|
-
await
|
|
1819
|
+
await _chunkYKL44PYXcjs.store.call(void 0, ).query(
|
|
1820
1820
|
(raw) => {
|
|
1821
1821
|
event = me.view(raw, actor);
|
|
1822
|
-
if (event.name ===
|
|
1822
|
+
if (event.name === _chunkNNWP65YMcjs.SNAP_EVENT) {
|
|
1823
1823
|
state2 = event.data;
|
|
1824
1824
|
snaps++;
|
|
1825
1825
|
patches = 0;
|
|
@@ -1828,8 +1828,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1828
1828
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1829
1829
|
patches++;
|
|
1830
1830
|
replayed++;
|
|
1831
|
-
} else if (event.name !==
|
|
1832
|
-
|
|
1831
|
+
} else if (event.name !== _chunkNNWP65YMcjs.TOMBSTONE_EVENT) {
|
|
1832
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).warn(
|
|
1833
1833
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1834
1834
|
);
|
|
1835
1835
|
}
|
|
@@ -1853,7 +1853,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1853
1853
|
...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
|
|
1854
1854
|
}
|
|
1855
1855
|
);
|
|
1856
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _78 => _78.name]) ===
|
|
1856
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _78 => _78.name]) === _chunkNNWP65YMcjs.TOMBSTONE_EVENT;
|
|
1857
1857
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1858
1858
|
await cache_put(stream, {
|
|
1859
1859
|
stream,
|
|
@@ -1881,7 +1881,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1881
1881
|
if (!stream) throw new Error("Missing target stream");
|
|
1882
1882
|
const reactingTo = _optionalChain([options, 'optionalAccess', _83 => _83.reactingTo]);
|
|
1883
1883
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _84 => _84.correlator]), () => ( default_correlator));
|
|
1884
|
-
const validated =
|
|
1884
|
+
const validated = _chunkYKL44PYXcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1885
1885
|
const opts = _optionalChain([me, 'access', _85 => _85.options, 'optionalAccess', _86 => _86[action2]]);
|
|
1886
1886
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _87 => _87.maxRetries]), () => ( 0));
|
|
1887
1887
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1892,14 +1892,14 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1892
1892
|
void 0,
|
|
1893
1893
|
patch_fn
|
|
1894
1894
|
);
|
|
1895
|
-
if (_optionalChain([snapshot, 'access', _88 => _88.event, 'optionalAccess', _89 => _89.name]) ===
|
|
1896
|
-
throw new (0,
|
|
1895
|
+
if (_optionalChain([snapshot, 'access', _88 => _88.event, 'optionalAccess', _89 => _89.name]) === _chunkNNWP65YMcjs.TOMBSTONE_EVENT)
|
|
1896
|
+
throw new (0, _chunkNNWP65YMcjs.StreamClosedError)(stream);
|
|
1897
1897
|
const expected = _nullishCoalesce(expectedVersion, () => ( (snapshot.version >= 0 ? snapshot.version : void 0)));
|
|
1898
1898
|
if (me.given) {
|
|
1899
1899
|
const invariants = me.given[action2] || [];
|
|
1900
1900
|
invariants.forEach(({ valid: valid2, description }) => {
|
|
1901
1901
|
if (!valid2(snapshot.state, actor))
|
|
1902
|
-
throw new (0,
|
|
1902
|
+
throw new (0, _chunkNNWP65YMcjs.InvariantError)(
|
|
1903
1903
|
action2,
|
|
1904
1904
|
validated,
|
|
1905
1905
|
target,
|
|
@@ -1916,7 +1916,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1916
1916
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1917
1917
|
const valid = tuples.map(([name, data]) => ({
|
|
1918
1918
|
name,
|
|
1919
|
-
data:
|
|
1919
|
+
data: _chunkYKL44PYXcjs.validate.call(void 0, name, data, me.events[name])
|
|
1920
1920
|
}));
|
|
1921
1921
|
const emitted = valid.map((e) => me.message(e));
|
|
1922
1922
|
const meta = {
|
|
@@ -1941,7 +1941,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1941
1941
|
};
|
|
1942
1942
|
let committed;
|
|
1943
1943
|
try {
|
|
1944
|
-
committed = await
|
|
1944
|
+
committed = await _chunkYKL44PYXcjs.store.call(void 0, ).commit(
|
|
1945
1945
|
stream,
|
|
1946
1946
|
emitted,
|
|
1947
1947
|
meta,
|
|
@@ -1950,7 +1950,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1950
1950
|
reactingTo ? expectedVersion : expected
|
|
1951
1951
|
);
|
|
1952
1952
|
} catch (error) {
|
|
1953
|
-
if (error instanceof
|
|
1953
|
+
if (error instanceof _chunkNNWP65YMcjs.ConcurrencyError) void cache_drop(stream);
|
|
1954
1954
|
throw error;
|
|
1955
1955
|
}
|
|
1956
1956
|
let { state: state2, patches } = snapshot;
|
|
@@ -1989,19 +1989,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1989
1989
|
}
|
|
1990
1990
|
return snapshots;
|
|
1991
1991
|
} catch (error) {
|
|
1992
|
-
if (!(error instanceof
|
|
1992
|
+
if (!(error instanceof _chunkNNWP65YMcjs.ConcurrencyError)) throw error;
|
|
1993
1993
|
if (expectedVersion !== void 0) throw error;
|
|
1994
1994
|
if (attempt >= max_retries) throw error;
|
|
1995
1995
|
if (_optionalChain([opts, 'optionalAccess', _96 => _96.backoff])) {
|
|
1996
1996
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1997
|
-
if (delay_ms > 0) await
|
|
1997
|
+
if (delay_ms > 0) await _chunkYKL44PYXcjs.sleep.call(void 0, delay_ms);
|
|
1998
1998
|
}
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
2001
|
}
|
|
2002
2002
|
|
|
2003
2003
|
// src/internal/tracing.ts
|
|
2004
|
-
var PRETTY =
|
|
2004
|
+
var PRETTY = _chunkYKL44PYXcjs.config.call(void 0, ).env !== "production";
|
|
2005
2005
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2006
2006
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2007
2007
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2187,7 +2187,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2187
2187
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _106 => _106.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2188
2188
|
return void 0;
|
|
2189
2189
|
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.`;
|
|
2190
|
-
|
|
2190
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).error(error);
|
|
2191
2191
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2192
2192
|
}
|
|
2193
2193
|
function fetch_failure_policy(registry) {
|
|
@@ -2203,13 +2203,13 @@ function fetch_failure_policy(registry) {
|
|
|
2203
2203
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
2204
2204
|
if (!error) return { lease, handled, acked_at: at };
|
|
2205
2205
|
logger.error(error);
|
|
2206
|
-
const non_retryable = error instanceof
|
|
2206
|
+
const non_retryable = error instanceof _chunkNNWP65YMcjs.NonRetryableError;
|
|
2207
2207
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2208
2208
|
if (block2)
|
|
2209
2209
|
logger.error(
|
|
2210
2210
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2211
2211
|
);
|
|
2212
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2212
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkYKL44PYXcjs.DEFAULT_BACKOFF)));
|
|
2213
2213
|
return {
|
|
2214
2214
|
lease,
|
|
2215
2215
|
handled,
|
|
@@ -2338,7 +2338,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2338
2338
|
const acked = await ops.ack(submitted);
|
|
2339
2339
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2340
2340
|
if (acked.length < expected)
|
|
2341
|
-
|
|
2341
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).warn(
|
|
2342
2342
|
`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.`
|
|
2343
2343
|
);
|
|
2344
2344
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2424,9 +2424,9 @@ var DrainController = (_class5 = class {
|
|
|
2424
2424
|
if (!this._armed) return EMPTY_DRAIN;
|
|
2425
2425
|
if (this._locked) return EMPTY_DRAIN;
|
|
2426
2426
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2427
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2428
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2429
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2427
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkYKL44PYXcjs.DEFAULT_STREAM_LIMIT));
|
|
2428
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkYKL44PYXcjs.DEFAULT_EVENT_LIMIT));
|
|
2429
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkYKL44PYXcjs.DEFAULT_LEASE_MILLIS));
|
|
2430
2430
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2431
2431
|
return EMPTY_DRAIN;
|
|
2432
2432
|
try {
|
|
@@ -2498,7 +2498,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2498
2498
|
const { pii, ...rest } = event;
|
|
2499
2499
|
if (pii == null) {
|
|
2500
2500
|
const shredded = { ...data };
|
|
2501
|
-
for (const f of fields) shredded[f] =
|
|
2501
|
+
for (const f of fields) shredded[f] = _chunkNNWP65YMcjs.SHREDDED;
|
|
2502
2502
|
return { ...rest, data: shredded };
|
|
2503
2503
|
}
|
|
2504
2504
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2509,7 +2509,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2509
2509
|
};
|
|
2510
2510
|
}
|
|
2511
2511
|
const redacted = { ...data };
|
|
2512
|
-
for (const f of fields) redacted[f] =
|
|
2512
|
+
for (const f of fields) redacted[f] = _chunkNNWP65YMcjs.REDACTED;
|
|
2513
2513
|
return { ...rest, data: redacted };
|
|
2514
2514
|
}
|
|
2515
2515
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2646,7 +2646,7 @@ function make_deferred(handler, schedule) {
|
|
|
2646
2646
|
const call = handler;
|
|
2647
2647
|
const deferred = async (event, stream, app) => {
|
|
2648
2648
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2649
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2649
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkNNWP65YMcjs.DeferSignal)(when);
|
|
2650
2650
|
return call(event, stream, app);
|
|
2651
2651
|
};
|
|
2652
2652
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2715,7 +2715,7 @@ function build_handle(deps) {
|
|
|
2715
2715
|
handled++;
|
|
2716
2716
|
}
|
|
2717
2717
|
} catch (error) {
|
|
2718
|
-
if (error instanceof
|
|
2718
|
+
if (error instanceof _chunkNNWP65YMcjs.DeferSignal)
|
|
2719
2719
|
return {
|
|
2720
2720
|
lease,
|
|
2721
2721
|
handled,
|
|
@@ -2990,7 +2990,7 @@ var Act = (_class7 = class {
|
|
|
2990
2990
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
2991
2991
|
|
|
2992
2992
|
|
|
2993
|
-
__init25() {this._logger =
|
|
2993
|
+
__init25() {this._logger = _chunkYKL44PYXcjs.log.call(void 0, )}
|
|
2994
2994
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
2995
2995
|
|
|
2996
2996
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3020,9 +3020,9 @@ var Act = (_class7 = class {
|
|
|
3020
3020
|
this._lanes = lanes;
|
|
3021
3021
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3022
3022
|
validate_only_lanes(options, lanes);
|
|
3023
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3023
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkYKL44PYXcjs.default_scope.call(void 0, )));
|
|
3024
3024
|
const ports = this._ports;
|
|
3025
|
-
this._scoped =
|
|
3025
|
+
this._scoped = _chunkYKL44PYXcjs.make_run_scoped.call(void 0, {
|
|
3026
3026
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3027
3027
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3028
3028
|
get store() {
|
|
@@ -3032,14 +3032,14 @@ var Act = (_class7 = class {
|
|
|
3032
3032
|
return ports.cache;
|
|
3033
3033
|
},
|
|
3034
3034
|
// Parsed per build, so a bad window throws on every build.
|
|
3035
|
-
autoclose_window:
|
|
3035
|
+
autoclose_window: _chunkYKL44PYXcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3036
3036
|
});
|
|
3037
3037
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3038
3038
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3039
3039
|
this._cd = build_drain(this._logger);
|
|
3040
3040
|
this._handle = build_handle({
|
|
3041
3041
|
logger: this._logger,
|
|
3042
|
-
reaction_scope:
|
|
3042
|
+
reaction_scope: _chunkYKL44PYXcjs.make_reaction_scope.call(void 0, {
|
|
3043
3043
|
do: this._bound_do,
|
|
3044
3044
|
load: this._bound_load,
|
|
3045
3045
|
query: this._bound_query,
|
|
@@ -3062,12 +3062,12 @@ var Act = (_class7 = class {
|
|
|
3062
3062
|
this._correlate = this._build_correlate(options, classification);
|
|
3063
3063
|
this._settle = this._build_settle(options);
|
|
3064
3064
|
this._notify_disposer = this._wire_notify(this._ports.store);
|
|
3065
|
-
|
|
3065
|
+
_chunkYKL44PYXcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3066
3066
|
}
|
|
3067
3067
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3068
3068
|
_build_breaker(options) {
|
|
3069
3069
|
return new CircuitBreaker(
|
|
3070
|
-
|
|
3070
|
+
_chunkYKL44PYXcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3071
3071
|
{
|
|
3072
3072
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3073
3073
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3101,7 +3101,7 @@ var Act = (_class7 = class {
|
|
|
3101
3101
|
try {
|
|
3102
3102
|
await this._run_close(targets);
|
|
3103
3103
|
} catch (error) {
|
|
3104
|
-
if (error instanceof
|
|
3104
|
+
if (error instanceof _chunkNNWP65YMcjs.StoreError) throw error;
|
|
3105
3105
|
this._logger.error(
|
|
3106
3106
|
error,
|
|
3107
3107
|
`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.`
|
|
@@ -3136,7 +3136,7 @@ var Act = (_class7 = class {
|
|
|
3136
3136
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3137
3137
|
_build_audit_deps() {
|
|
3138
3138
|
return {
|
|
3139
|
-
store:
|
|
3139
|
+
store: _chunkYKL44PYXcjs.store,
|
|
3140
3140
|
event_to_state: this._event_to_state,
|
|
3141
3141
|
// Declared lanes, not this process's controllers: a lane another
|
|
3142
3142
|
// worker drains is not `unknown-lane`.
|
|
@@ -3149,7 +3149,7 @@ var Act = (_class7 = class {
|
|
|
3149
3149
|
registry: this.registry,
|
|
3150
3150
|
static_targets: classification.static_targets,
|
|
3151
3151
|
cd: this._cd,
|
|
3152
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3152
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkNNWP65YMcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3153
3153
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3154
3154
|
// still a valid destination.
|
|
3155
3155
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3163,7 +3163,7 @@ var Act = (_class7 = class {
|
|
|
3163
3163
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3164
3164
|
async _seed_persisted_defers() {
|
|
3165
3165
|
const now = Date.now();
|
|
3166
|
-
await walk_streams(
|
|
3166
|
+
await walk_streams(_chunkYKL44PYXcjs.store.call(void 0, ), (pos) => {
|
|
3167
3167
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3168
3168
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3169
3169
|
_optionalChain([controller, 'optionalAccess', _128 => _128.seed_defer, 'call', _129 => _129(pos.stream, pos.deferred_at)]);
|
|
@@ -3182,33 +3182,26 @@ var Act = (_class7 = class {
|
|
|
3182
3182
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3183
3183
|
breaker: this._breaker
|
|
3184
3184
|
},
|
|
3185
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3185
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkNNWP65YMcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3186
3186
|
);
|
|
3187
3187
|
}
|
|
3188
3188
|
|
|
3189
3189
|
/**
|
|
3190
|
-
* Per-instance teardown:
|
|
3191
|
-
*
|
|
3192
|
-
* listeners and
|
|
3190
|
+
* Per-instance teardown: stops scheduling, gives the cycles in flight up
|
|
3191
|
+
* to `graceMs` to reach their `ack` (an abandoned handler holds its lease
|
|
3192
|
+
* until it expires), then removes listeners and the notify subscription.
|
|
3193
|
+
* The budget is a ceiling, not a delay.
|
|
3193
3194
|
*
|
|
3194
|
-
*
|
|
3195
|
-
*
|
|
3196
|
-
*
|
|
3197
|
-
* finished during it. The budget is a ceiling, not a delay; when it runs
|
|
3198
|
-
* out, teardown proceeds anyway.
|
|
3199
|
-
*
|
|
3200
|
-
* Idempotent — repeated calls return the same promise, and the first
|
|
3201
|
-
* call's `graceMs` is the one that applies. Registered automatically with
|
|
3202
|
-
* the global `dispose()` registry at construction, so process-wide
|
|
3203
|
-
* `dispose()()` covers it; test helpers (or operators that mint
|
|
3204
|
-
* short-lived Acts) call it explicitly for prompt cleanup.
|
|
3195
|
+
* Idempotent: repeated calls return the same promise, with the first
|
|
3196
|
+
* call's `graceMs`. Registered with the global `dispose()` registry, so
|
|
3197
|
+
* `dispose()()` covers it; call it directly for prompt cleanup.
|
|
3205
3198
|
*
|
|
3206
3199
|
* @param options - See {@link ShutdownOptions}. Defaults the grace budget
|
|
3207
3200
|
* to the largest lane `leaseMillis` (capped at 30s).
|
|
3208
3201
|
*/
|
|
3209
3202
|
shutdown(options) {
|
|
3210
3203
|
if (!this._shutdown_promise) {
|
|
3211
|
-
|
|
3204
|
+
_chunkYKL44PYXcjs.resolveShutdownConfig.call(void 0, options);
|
|
3212
3205
|
this._shutdown_promise = (async () => {
|
|
3213
3206
|
this.stop_correlations();
|
|
3214
3207
|
const disposer = await this._notify_disposer;
|
|
@@ -3228,10 +3221,10 @@ var Act = (_class7 = class {
|
|
|
3228
3221
|
* default for none or 0, and for a running settle), capped.
|
|
3229
3222
|
*/
|
|
3230
3223
|
_derive_grace_ms(running, settling) {
|
|
3231
|
-
let max = settling ?
|
|
3224
|
+
let max = settling ? _chunkYKL44PYXcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3232
3225
|
for (const c of running)
|
|
3233
|
-
max = Math.max(max, c.lease_millis ||
|
|
3234
|
-
return Math.min(max,
|
|
3226
|
+
max = Math.max(max, c.lease_millis || _chunkYKL44PYXcjs.DEFAULT_LEASE_MILLIS);
|
|
3227
|
+
return Math.min(max, _chunkYKL44PYXcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3235
3228
|
}
|
|
3236
3229
|
async _await_inflight(grace_ms) {
|
|
3237
3230
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3279,15 +3272,10 @@ var Act = (_class7 = class {
|
|
|
3279
3272
|
}
|
|
3280
3273
|
}
|
|
3281
3274
|
/**
|
|
3282
|
-
* Executes an action
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3285
|
-
*
|
|
3286
|
-
* 2. Loads the current state snapshot
|
|
3287
|
-
* 3. Checks invariants (business rules)
|
|
3288
|
-
* 4. Executes the action handler to generate events
|
|
3289
|
-
* 5. Applies events to create new state
|
|
3290
|
-
* 6. Commits events to the store with optimistic concurrency control
|
|
3275
|
+
* Executes an action: validates the payload, loads the state, checks its
|
|
3276
|
+
* invariants, and commits the events its handler emits, with optimistic
|
|
3277
|
+
* concurrency on the stream. The reactions to those events settle on
|
|
3278
|
+
* their own (unless `autoSettle: false`).
|
|
3291
3279
|
*
|
|
3292
3280
|
* @template TKey - Action name from registered actions
|
|
3293
3281
|
* @param action - The name of the action to execute
|
|
@@ -3321,7 +3309,7 @@ var Act = (_class7 = class {
|
|
|
3321
3309
|
* @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
|
|
3322
3310
|
*/
|
|
3323
3311
|
async do(action2, target, payload, options) {
|
|
3324
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.reactingTo]), () => (
|
|
3312
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.reactingTo]), () => ( _chunkYKL44PYXcjs.current_reacting.call(void 0, )));
|
|
3325
3313
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _132 => _132.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3326
3314
|
return this._scoped(async () => {
|
|
3327
3315
|
const snapshots = await this._es.action(
|
|
@@ -3366,9 +3354,7 @@ var Act = (_class7 = class {
|
|
|
3366
3354
|
*
|
|
3367
3355
|
* For small result sets, consider using {@link query_array} instead.
|
|
3368
3356
|
*
|
|
3369
|
-
* @param query - Filter criteria
|
|
3370
|
-
* (`stream`, `name`, `after`, `before`, `created_after`, `created_before`,
|
|
3371
|
-
* `limit`, `with_snaps`, `stream_exact`)
|
|
3357
|
+
* @param query - Filter criteria; see {@link Query} for the fields
|
|
3372
3358
|
* @param callback - Optional callback invoked for each matching event
|
|
3373
3359
|
* @returns Object with first event, last event, and total count
|
|
3374
3360
|
*
|
|
@@ -3387,7 +3373,7 @@ var Act = (_class7 = class {
|
|
|
3387
3373
|
return this._scoped(async () => {
|
|
3388
3374
|
let first;
|
|
3389
3375
|
let last;
|
|
3390
|
-
const count = await
|
|
3376
|
+
const count = await _chunkYKL44PYXcjs.store.call(void 0, ).query((e) => {
|
|
3391
3377
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3392
3378
|
if (!first) first = gated;
|
|
3393
3379
|
last = gated;
|
|
@@ -3417,7 +3403,7 @@ var Act = (_class7 = class {
|
|
|
3417
3403
|
async query_array(query) {
|
|
3418
3404
|
return this._scoped(async () => {
|
|
3419
3405
|
const events = [];
|
|
3420
|
-
await
|
|
3406
|
+
await _chunkYKL44PYXcjs.store.call(void 0, ).query((e) => {
|
|
3421
3407
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3422
3408
|
}, query);
|
|
3423
3409
|
return events;
|
|
@@ -3437,14 +3423,14 @@ var Act = (_class7 = class {
|
|
|
3437
3423
|
*/
|
|
3438
3424
|
async forget(stream) {
|
|
3439
3425
|
return this._scoped(async () => {
|
|
3440
|
-
const s =
|
|
3426
|
+
const s = _chunkYKL44PYXcjs.store.call(void 0, );
|
|
3441
3427
|
if (!s.forget_pii) {
|
|
3442
3428
|
throw new Error(
|
|
3443
3429
|
`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).`
|
|
3444
3430
|
);
|
|
3445
3431
|
}
|
|
3446
3432
|
const eventCount = await s.forget_pii(stream);
|
|
3447
|
-
await
|
|
3433
|
+
await _chunkYKL44PYXcjs.cache.call(void 0, ).invalidate(stream);
|
|
3448
3434
|
if (eventCount > 0) {
|
|
3449
3435
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3450
3436
|
}
|
|
@@ -3452,31 +3438,23 @@ var Act = (_class7 = class {
|
|
|
3452
3438
|
});
|
|
3453
3439
|
}
|
|
3454
3440
|
/**
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3458
|
-
* 1. Polls the store for streams with uncommitted events
|
|
3459
|
-
* 2. Leases streams to prevent concurrent processing
|
|
3460
|
-
* 3. Fetches events for each leased stream
|
|
3461
|
-
* 4. Executes matching reaction handlers
|
|
3462
|
-
* 5. Acknowledges successful reactions or blocks failing ones
|
|
3441
|
+
* Runs one drain cycle: claims streams with marked work (leasing them),
|
|
3442
|
+
* fetches their events, runs the matching reactions, and acks or blocks
|
|
3443
|
+
* each stream.
|
|
3463
3444
|
*
|
|
3464
|
-
*
|
|
3465
|
-
*
|
|
3466
|
-
*
|
|
3467
|
-
*
|
|
3468
|
-
*
|
|
3469
|
-
* `correlate` is the only component that raises that mark, so a
|
|
3470
|
-
* commit no correlate has seen is not drainable, static targets included. For a
|
|
3471
|
-
* higher-level API that handles debouncing, correlation, and signaling
|
|
3472
|
-
* automatically, use {@link settle}.
|
|
3445
|
+
* A stream is claimable only once `correlate()` has marked it, static
|
|
3446
|
+
* targets included, so a commit no correlate has seen is not drainable.
|
|
3447
|
+
* Apps rarely call this: each commit settles its reactions on its own.
|
|
3448
|
+
* With `autoSettle: false`, tests walk the pipeline with `correlate()`
|
|
3449
|
+
* then `drain()` (see the testing guide).
|
|
3473
3450
|
*
|
|
3474
3451
|
* @param options - Drain configuration — see {@link DrainOptions} for fields
|
|
3475
3452
|
* (`streamLimit`, `eventLimit`, `leaseMillis`).
|
|
3476
3453
|
* @returns Drain statistics with fetched, leased, acked, and blocked counts
|
|
3477
3454
|
*
|
|
3478
|
-
* @example
|
|
3455
|
+
* @example Walking the pipeline in a test
|
|
3479
3456
|
* ```typescript
|
|
3457
|
+
* const app = act().withState(User).withProjection(Users).build({ autoSettle: false });
|
|
3480
3458
|
* await app.do("createUser", target, payload);
|
|
3481
3459
|
* await app.correlate();
|
|
3482
3460
|
* await app.drain();
|
|
@@ -3484,10 +3462,9 @@ var Act = (_class7 = class {
|
|
|
3484
3462
|
*
|
|
3485
3463
|
* @see {@link settle} for debounced correlate→drain with lifecycle events
|
|
3486
3464
|
* @see {@link correlate} for dynamic stream discovery
|
|
3487
|
-
* @see {@link start_correlations} for automatic correlation
|
|
3488
3465
|
*/
|
|
3489
3466
|
async drain(options = {}) {
|
|
3490
|
-
|
|
3467
|
+
_chunkYKL44PYXcjs.resolveDrainConfig.call(void 0, options);
|
|
3491
3468
|
if (!this._drain)
|
|
3492
3469
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3493
3470
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3551,32 +3528,20 @@ var Act = (_class7 = class {
|
|
|
3551
3528
|
return { fetched, leased, acked, blocked };
|
|
3552
3529
|
}
|
|
3553
3530
|
/**
|
|
3554
|
-
*
|
|
3555
|
-
*
|
|
3556
|
-
*
|
|
3557
|
-
* based on event content. For example, you might create a stats stream for each user
|
|
3558
|
-
* when they perform certain actions.
|
|
3559
|
-
*
|
|
3560
|
-
* This method scans events matching the query and identifies new target streams based
|
|
3561
|
-
* on reaction resolvers. It then registers these streams so they'll be picked up by
|
|
3562
|
-
* the next drain cycle.
|
|
3531
|
+
* Scans committed events from the correlation checkpoint, subscribes the
|
|
3532
|
+
* target streams their reactions resolve to (static or computed from
|
|
3533
|
+
* the event), and marks their work so the next drain can claim it.
|
|
3563
3534
|
*
|
|
3564
3535
|
* @param query - Scan filter — see {@link Query} for fields (typically
|
|
3565
|
-
* `{
|
|
3536
|
+
* `{ limit: <count> }`; the scan starts at the checkpoint)
|
|
3566
3537
|
* @returns The number of newly subscribed streams and the last scanned event id
|
|
3567
3538
|
*
|
|
3568
3539
|
* @example Manual correlation
|
|
3569
3540
|
* ```typescript
|
|
3570
|
-
*
|
|
3571
|
-
* const { subscribed, last_id } = await app.correlate({ after: 0, limit: 100 });
|
|
3572
|
-
* console.log(`Subscribed ${subscribed} new streams`);
|
|
3573
|
-
*
|
|
3574
|
-
* // Save last_id for next scan
|
|
3575
|
-
* await saveCheckpoint(last_id);
|
|
3541
|
+
* const { subscribed } = await app.correlate({ limit: 100 });
|
|
3576
3542
|
* ```
|
|
3577
3543
|
*
|
|
3578
3544
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3579
|
-
* @see {@link stop_correlations} to stop automatic correlation
|
|
3580
3545
|
*/
|
|
3581
3546
|
async correlate(query = { after: -1, limit: 10 }) {
|
|
3582
3547
|
const { subscribed, last_id } = await this._correlate_scanned(query);
|
|
@@ -3656,15 +3621,13 @@ var Act = (_class7 = class {
|
|
|
3656
3621
|
* events through their reactions.
|
|
3657
3622
|
*
|
|
3658
3623
|
* Use this to replay events through projections (or other reaction targets)
|
|
3659
|
-
* after changing handler logic.
|
|
3660
|
-
*
|
|
3661
|
-
*
|
|
3662
|
-
*
|
|
3663
|
-
*
|
|
3664
|
-
*
|
|
3665
|
-
*
|
|
3666
|
-
* give that pass batch options, or
|
|
3667
|
-
* `correlate()` / `drain()` to drive the replay by hand.
|
|
3624
|
+
* after changing handler logic. It rewinds the same watermarks as
|
|
3625
|
+
* `store().reset(streams)`, and also wakes the drain and schedules a
|
|
3626
|
+
* settle, which loops correlate→drain until the replay catches up;
|
|
3627
|
+
* `store().reset(...)` alone leaves a settled app idle. Call
|
|
3628
|
+
* `app.settle(options)` right after to give that pass batch options, or,
|
|
3629
|
+
* with `autoSettle: false`, `correlate()` / `drain()` to drive the replay
|
|
3630
|
+
* by hand.
|
|
3668
3631
|
*
|
|
3669
3632
|
* @param input - Reaction target streams (e.g., projection names) to reset, or a {@link StreamFilter} for bulk operations
|
|
3670
3633
|
* @returns Count of streams that were actually reset
|
|
@@ -3680,7 +3643,7 @@ var Act = (_class7 = class {
|
|
|
3680
3643
|
*/
|
|
3681
3644
|
async reset(input) {
|
|
3682
3645
|
return this._scoped(async () => {
|
|
3683
|
-
const count = await
|
|
3646
|
+
const count = await _chunkYKL44PYXcjs.store.call(void 0, ).reset(input);
|
|
3684
3647
|
for (const handler of this._batch_handlers.values())
|
|
3685
3648
|
_optionalChain([handler, 'access', _139 => _139[FOLD_RESET], 'optionalCall', _140 => _140()]);
|
|
3686
3649
|
if (count > 0) {
|
|
@@ -3717,7 +3680,7 @@ var Act = (_class7 = class {
|
|
|
3717
3680
|
*/
|
|
3718
3681
|
async unblock(input) {
|
|
3719
3682
|
return this._scoped(async () => {
|
|
3720
|
-
const count = await
|
|
3683
|
+
const count = await _chunkYKL44PYXcjs.store.call(void 0, ).unblock(input);
|
|
3721
3684
|
if (count > 0) {
|
|
3722
3685
|
this._arm_all();
|
|
3723
3686
|
this._settle_armed(this._reactive);
|
|
@@ -3767,7 +3730,7 @@ var Act = (_class7 = class {
|
|
|
3767
3730
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3768
3731
|
}
|
|
3769
3732
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3770
|
-
const s =
|
|
3733
|
+
const s = _chunkYKL44PYXcjs.store.call(void 0, );
|
|
3771
3734
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3772
3735
|
return s;
|
|
3773
3736
|
})()));
|
|
@@ -3813,7 +3776,7 @@ var Act = (_class7 = class {
|
|
|
3813
3776
|
async blocked_streams(options) {
|
|
3814
3777
|
return this._scoped(async () => {
|
|
3815
3778
|
const positions = [];
|
|
3816
|
-
await
|
|
3779
|
+
await _chunkYKL44PYXcjs.store.call(void 0, ).query_streams(
|
|
3817
3780
|
(p) => {
|
|
3818
3781
|
positions.push(p);
|
|
3819
3782
|
},
|
|
@@ -3823,45 +3786,20 @@ var Act = (_class7 = class {
|
|
|
3823
3786
|
});
|
|
3824
3787
|
}
|
|
3825
3788
|
/**
|
|
3826
|
-
* Operator-driven store audit
|
|
3827
|
-
*
|
|
3828
|
-
*
|
|
3829
|
-
*
|
|
3830
|
-
* driven category as `app.close()` / `app.reset()` /
|
|
3831
|
-
* `app.unblock()` / `app.blocked_streams()`: never auto-invoked by
|
|
3832
|
-
* the framework; the operator decides when to run it (CI gate,
|
|
3833
|
-
* scheduled job, ad-hoc forensics) and what to do with the
|
|
3834
|
-
* findings.
|
|
3789
|
+
* Operator-driven store audit: walks the store and yields findings per
|
|
3790
|
+
* category, each with the remediation it suggests. Never run by the
|
|
3791
|
+
* framework. Pass a subset of categories to scope the work; the iterable
|
|
3792
|
+
* can be broken early, and findings stream without buffering the report.
|
|
3835
3793
|
*
|
|
3836
|
-
*
|
|
3837
|
-
*
|
|
3794
|
+
* @param categories - Subset of categories to run (default: all).
|
|
3795
|
+
* @param options - Query window + per-category thresholds.
|
|
3796
|
+
* @returns Async iterable of {@link AuditFinding}.
|
|
3838
3797
|
*
|
|
3798
|
+
* @example Schema drift since the last scan
|
|
3839
3799
|
* ```typescript
|
|
3840
|
-
*
|
|
3841
|
-
* for await (const f of app.audit(["schema", "deprecated-load"], {
|
|
3842
|
-
* query: { created_after: lastScan },
|
|
3843
|
-
* thresholds: { deprecatedLoadShareMin: 0.10 },
|
|
3844
|
-
* })) {
|
|
3800
|
+
* for await (const f of app.audit(["schema"], { query: { created_after: lastScan } }))
|
|
3845
3801
|
* await escalate(f);
|
|
3846
|
-
* }
|
|
3847
|
-
*
|
|
3848
|
-
* // Full audit, default thresholds
|
|
3849
|
-
* for await (const f of app.audit()) console.log(f);
|
|
3850
3802
|
* ```
|
|
3851
|
-
*
|
|
3852
|
-
* Returns an `AsyncIterable` so callers can `break` early — the
|
|
3853
|
-
* underlying store paginations respect the iterator protocol and
|
|
3854
|
-
* stop cleanly. Each finding is emitted independently, so
|
|
3855
|
-
* pipelining into Slack / persistence / further analysis works
|
|
3856
|
-
* without buffering the full report in memory.
|
|
3857
|
-
*
|
|
3858
|
-
* Findings shape — see {@link AuditFinding}. The discriminated
|
|
3859
|
-
* union carries enough context for the operator to act on each
|
|
3860
|
-
* finding directly: stream id, event id, recommendation hints.
|
|
3861
|
-
*
|
|
3862
|
-
* @param categories - Subset of categories to run (default: all).
|
|
3863
|
-
* @param options - Query window + per-category thresholds.
|
|
3864
|
-
* @returns Async iterable of {@link AuditFinding}.
|
|
3865
3803
|
*/
|
|
3866
3804
|
async *audit(categories, options) {
|
|
3867
3805
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
@@ -3872,22 +3810,13 @@ var Act = (_class7 = class {
|
|
|
3872
3810
|
}
|
|
3873
3811
|
}
|
|
3874
3812
|
/**
|
|
3875
|
-
*
|
|
3876
|
-
*
|
|
3877
|
-
*
|
|
3878
|
-
*
|
|
3879
|
-
*
|
|
3880
|
-
* job should yield slots back to the rest. Build-time priorities
|
|
3881
|
-
* (set via the resolver's `priority` field) are subject to a
|
|
3882
|
-
* `max()` invariant across reactions; this API ignores that and
|
|
3883
|
-
* sets the priority outright on every matching row.
|
|
3884
|
-
*
|
|
3885
|
-
* Filter shape mirrors {@link query} / {@link Store.query_streams}:
|
|
3886
|
-
* `stream` / `source` are regex by default, exact with the
|
|
3887
|
-
* `*_exact` flags; `blocked` restricts to blocked or unblocked
|
|
3888
|
-
* rows. **An empty filter (`{}`) updates every registered stream.**
|
|
3813
|
+
* Sets the scheduling priority of every stream matching `filter`, as-is:
|
|
3814
|
+
* unlike build-time priorities (the highest across reactions wins), this
|
|
3815
|
+
* overrides them. Useful to let a long replay jump ahead of other lagging
|
|
3816
|
+
* streams, or to yield slots back. **An empty filter (`{}`) updates every
|
|
3817
|
+
* registered stream.**
|
|
3889
3818
|
*
|
|
3890
|
-
* @param filter - Selection criteria (regex by default).
|
|
3819
|
+
* @param filter - Selection criteria (regex by default, like {@link query}).
|
|
3891
3820
|
* @param priority - New priority value. Set as-is — no clamp.
|
|
3892
3821
|
* @returns Count of streams whose priority changed.
|
|
3893
3822
|
*
|
|
@@ -3897,10 +3826,9 @@ var Act = (_class7 = class {
|
|
|
3897
3826
|
* ```
|
|
3898
3827
|
*
|
|
3899
3828
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3900
|
-
* @see {@link claim} for how priority biases scheduling
|
|
3901
3829
|
*/
|
|
3902
3830
|
async prioritize(filter, priority) {
|
|
3903
|
-
return this._scoped(() =>
|
|
3831
|
+
return this._scoped(() => _chunkYKL44PYXcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3904
3832
|
}
|
|
3905
3833
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3906
3834
|
async _run_close(targets) {
|
|
@@ -3924,30 +3852,12 @@ var Act = (_class7 = class {
|
|
|
3924
3852
|
return result;
|
|
3925
3853
|
}
|
|
3926
3854
|
/**
|
|
3927
|
-
* Close the books
|
|
3928
|
-
*
|
|
3929
|
-
*
|
|
3930
|
-
*
|
|
3931
|
-
*
|
|
3932
|
-
*
|
|
3933
|
-
* 3. **Guard** — commit `__tombstone__` with `expectedVersion` to block concurrent writes
|
|
3934
|
-
* 4. **Load state** — for streams in `snapshots`, load final state while guarded (no races)
|
|
3935
|
-
* 5. **Archive** — user callback per stream (abort-all on failure, streams are guarded)
|
|
3936
|
-
* 6. **Truncate + seed** — atomic: delete all events, insert `__snapshot__` or `__tombstone__`
|
|
3937
|
-
* 7. **Cache** — invalidate (tombstoned) or warm (restarted)
|
|
3938
|
-
* 8. **Emit "closed"** — lifecycle event with results
|
|
3939
|
-
*
|
|
3940
|
-
* Targets carrying `before` take the **windowed** branch instead —
|
|
3941
|
-
* close the books on a rolling window: probe the min consumer
|
|
3942
|
-
* watermark (so the boundary never rises past a lagging reaction),
|
|
3943
|
-
* run the archive callback against the cutoff, then prune the prefix
|
|
3944
|
-
* below the closest safe `__snapshot__`. No tombstone guard (the
|
|
3945
|
-
* pre-cutoff prefix is immutable), no seed, cache untouched — the
|
|
3946
|
-
* stream stays live and keeps accepting actions. Requires the state
|
|
3947
|
-
* to snapshot via `.snap(...)`; no qualifying snapshot ⇒ the stream
|
|
3948
|
-
* lands in `skipped` (retry after the next snapshot). Windowed
|
|
3949
|
-
* entries in the result echo `before` and carry the surviving
|
|
3950
|
-
* boundary snapshot as `committed`.
|
|
3855
|
+
* Close the books: guard, archive, truncate, and optionally restart
|
|
3856
|
+
* streams. A stream with pending reactions is skipped; an archive
|
|
3857
|
+
* failure aborts the whole close while the streams are still guarded.
|
|
3858
|
+
* Targets carrying `before` prune a rolling window instead and leave the
|
|
3859
|
+
* stream live (needs `.snap(...)`). The phases and their failure
|
|
3860
|
+
* semantics are in the close-cycle architecture page.
|
|
3951
3861
|
*
|
|
3952
3862
|
* @param targets - Per-stream close options (stream, restart?, archive?, before?)
|
|
3953
3863
|
* @returns `{ truncated: TruncateResult, skipped: string[] }`
|
|
@@ -3999,7 +3909,7 @@ var Act = (_class7 = class {
|
|
|
3999
3909
|
* @see {@link correlate} for manual correlation
|
|
4000
3910
|
*/
|
|
4001
3911
|
settle(options) {
|
|
4002
|
-
|
|
3912
|
+
_chunkYKL44PYXcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
4003
3913
|
this._schedule(options);
|
|
4004
3914
|
}
|
|
4005
3915
|
}, _class7);
|
|
@@ -4155,16 +4065,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4155
4065
|
}),
|
|
4156
4066
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4157
4067
|
// not quarantine the synthetic stream.
|
|
4158
|
-
options: { blockOnError: false, maxRetries:
|
|
4068
|
+
options: { blockOnError: false, maxRetries: _chunkYKL44PYXcjs.DEFAULT_MAX_RETRIES },
|
|
4159
4069
|
handler: async (event) => {
|
|
4160
4070
|
const aggregate = event.stream;
|
|
4161
4071
|
const window = read_window();
|
|
4162
4072
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4163
|
-
throw new (0,
|
|
4164
|
-
const stats = await
|
|
4073
|
+
throw new (0, _chunkNNWP65YMcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4074
|
+
const stats = await _chunkYKL44PYXcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4165
4075
|
count: true,
|
|
4166
4076
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4167
|
-
exclude: [
|
|
4077
|
+
exclude: [_chunkNNWP65YMcjs.TOMBSTONE_EVENT, _chunkNNWP65YMcjs.SNAP_EVENT]
|
|
4168
4078
|
});
|
|
4169
4079
|
const entry = stats.get(aggregate);
|
|
4170
4080
|
if (!entry) return;
|
|
@@ -4195,7 +4105,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4195
4105
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4196
4106
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4197
4107
|
if (future.length)
|
|
4198
|
-
throw new (0,
|
|
4108
|
+
throw new (0, _chunkNNWP65YMcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4199
4109
|
}
|
|
4200
4110
|
};
|
|
4201
4111
|
const key = `__autoclose_${st.name}`;
|
|
@@ -4399,8 +4309,8 @@ var _this_ = ({ stream }) => ({
|
|
|
4399
4309
|
|
|
4400
4310
|
// src/builders/builder-utils.ts
|
|
4401
4311
|
function register_lane(config2, lanes) {
|
|
4402
|
-
if (config2.name ===
|
|
4403
|
-
throw new Error(`Lane "${
|
|
4312
|
+
if (config2.name === _chunkNNWP65YMcjs.DEFAULT_LANE)
|
|
4313
|
+
throw new Error(`Lane "${_chunkNNWP65YMcjs.DEFAULT_LANE}" is reserved`);
|
|
4404
4314
|
if (lanes.some((l) => l.name === config2.name))
|
|
4405
4315
|
throw new Error(`Lane "${config2.name}" was already declared`);
|
|
4406
4316
|
lanes.push(config2);
|
|
@@ -4422,9 +4332,9 @@ function reaction_on(event, events, builder) {
|
|
|
4422
4332
|
// Validate the whole bag at the declaration site so a bad
|
|
4423
4333
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4424
4334
|
// not a NaN gate on the first retry.
|
|
4425
|
-
options:
|
|
4426
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _155 => _155.blockOnError]), () => (
|
|
4427
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.maxRetries]), () => (
|
|
4335
|
+
options: _chunkYKL44PYXcjs.resolveReactionConfig.call(void 0, {
|
|
4336
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _155 => _155.blockOnError]), () => ( _chunkYKL44PYXcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4337
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.maxRetries]), () => ( _chunkYKL44PYXcjs.DEFAULT_MAX_RETRIES)),
|
|
4428
4338
|
backoff: _optionalChain([options, 'optionalAccess', _157 => _157.backoff])
|
|
4429
4339
|
})
|
|
4430
4340
|
};
|
|
@@ -4514,7 +4424,7 @@ function date_reviver_schema(schema) {
|
|
|
4514
4424
|
|
|
4515
4425
|
// src/builders/event-builder.ts
|
|
4516
4426
|
function event_tags(schema) {
|
|
4517
|
-
const pii =
|
|
4427
|
+
const pii = _chunkNNWP65YMcjs.pii_schemas.call(void 0, schema);
|
|
4518
4428
|
const pii_dates = {};
|
|
4519
4429
|
for (const [key, field] of Object.entries(pii)) {
|
|
4520
4430
|
const dates = date_reviver_schema(field);
|
|
@@ -4551,7 +4461,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4551
4461
|
});
|
|
4552
4462
|
}
|
|
4553
4463
|
function build_events(registry, states, lanes, owners) {
|
|
4554
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4464
|
+
const declared = /* @__PURE__ */ new Set([_chunkNNWP65YMcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4555
4465
|
const lane_errors = [];
|
|
4556
4466
|
const tags = /* @__PURE__ */ new Map();
|
|
4557
4467
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4615,7 +4525,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4615
4525
|
if (reader) readers.set(event_name, reader);
|
|
4616
4526
|
}
|
|
4617
4527
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4618
|
-
if (snap2) readers.set(
|
|
4528
|
+
if (snap2) readers.set(_chunkNNWP65YMcjs.SNAP_EVENT, snap2);
|
|
4619
4529
|
if (readers.size === 0) continue;
|
|
4620
4530
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4621
4531
|
}
|
|
@@ -4731,7 +4641,7 @@ function act() {
|
|
|
4731
4641
|
const list = deprecation_summary.map(
|
|
4732
4642
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4733
4643
|
).join(", ");
|
|
4734
|
-
|
|
4644
|
+
_chunkYKL44PYXcjs.log.call(void 0, ).info(
|
|
4735
4645
|
`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.`
|
|
4736
4646
|
);
|
|
4737
4647
|
}
|
|
@@ -4776,7 +4686,7 @@ function act() {
|
|
|
4776
4686
|
withActor: () => builder,
|
|
4777
4687
|
withLane: (config2) => {
|
|
4778
4688
|
if (_built) closed("withLane");
|
|
4779
|
-
register_lane(
|
|
4689
|
+
register_lane(_chunkYKL44PYXcjs.resolveLaneConfig.call(void 0, config2), lanes);
|
|
4780
4690
|
return builder;
|
|
4781
4691
|
},
|
|
4782
4692
|
on: (event) => {
|
|
@@ -4784,7 +4694,7 @@ function act() {
|
|
|
4784
4694
|
return reaction_on(event, registry.events, builder);
|
|
4785
4695
|
},
|
|
4786
4696
|
build: (options) => {
|
|
4787
|
-
|
|
4697
|
+
_chunkYKL44PYXcjs.resolveActConfig.call(void 0, options);
|
|
4788
4698
|
const patch_fn = _optionalChain([options, 'optionalAccess', _169 => _169.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4789
4699
|
if (!_built) {
|
|
4790
4700
|
for (const proj of pending_projections) add_projection(proj);
|
|
@@ -4836,7 +4746,7 @@ function act() {
|
|
|
4836
4746
|
synthesize_autoclose_reactions(
|
|
4837
4747
|
registry,
|
|
4838
4748
|
states,
|
|
4839
|
-
|
|
4749
|
+
_chunkYKL44PYXcjs.current_autoclose_window
|
|
4840
4750
|
);
|
|
4841
4751
|
Object.freeze(registry.actions);
|
|
4842
4752
|
Object.freeze(registry.events);
|
|
@@ -4879,8 +4789,8 @@ function _projection(target) {
|
|
|
4879
4789
|
handler,
|
|
4880
4790
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4881
4791
|
options: {
|
|
4882
|
-
blockOnError:
|
|
4883
|
-
maxRetries:
|
|
4792
|
+
blockOnError: _chunkYKL44PYXcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4793
|
+
maxRetries: _chunkYKL44PYXcjs.DEFAULT_MAX_RETRIES
|
|
4884
4794
|
}
|
|
4885
4795
|
};
|
|
4886
4796
|
const register = events[event];
|
|
@@ -4936,7 +4846,7 @@ function _projection(target) {
|
|
|
4936
4846
|
throw new Error(
|
|
4937
4847
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4938
4848
|
);
|
|
4939
|
-
const config2 =
|
|
4849
|
+
const config2 = _chunkYKL44PYXcjs.resolveFoldConfig.call(void 0, options);
|
|
4940
4850
|
const fold_events = {};
|
|
4941
4851
|
for (const partial of partials)
|
|
4942
4852
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4954,8 +4864,8 @@ function _projection(target) {
|
|
|
4954
4864
|
handler: noop,
|
|
4955
4865
|
resolver: { target },
|
|
4956
4866
|
options: {
|
|
4957
|
-
blockOnError:
|
|
4958
|
-
maxRetries:
|
|
4867
|
+
blockOnError: _chunkYKL44PYXcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4868
|
+
maxRetries: _chunkYKL44PYXcjs.DEFAULT_MAX_RETRIES
|
|
4959
4869
|
}
|
|
4960
4870
|
}
|
|
4961
4871
|
]
|
|
@@ -4998,7 +4908,7 @@ function slice() {
|
|
|
4998
4908
|
return builder;
|
|
4999
4909
|
},
|
|
5000
4910
|
withLane: (config2) => {
|
|
5001
|
-
register_lane(
|
|
4911
|
+
register_lane(_chunkYKL44PYXcjs.resolveLaneConfig.call(void 0, config2), lanes);
|
|
5002
4912
|
return builder;
|
|
5003
4913
|
},
|
|
5004
4914
|
on: (event) => reaction_on(event, events, builder),
|
|
@@ -5071,7 +4981,7 @@ function action_builder(state2) {
|
|
|
5071
4981
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5072
4982
|
internal.actions[action2] = schema;
|
|
5073
4983
|
if (options) {
|
|
5074
|
-
|
|
4984
|
+
_chunkYKL44PYXcjs.resolveActionConfig.call(void 0, options);
|
|
5075
4985
|
internal.options ??= {};
|
|
5076
4986
|
internal.options[action2] = options;
|
|
5077
4987
|
}
|
|
@@ -5360,5 +5270,5 @@ function write_line(writer, line) {
|
|
|
5360
5270
|
|
|
5361
5271
|
|
|
5362
5272
|
|
|
5363
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5273
|
+
exports.Act = Act; exports.ActorSchema = _chunkNNWP65YMcjs.ActorSchema; exports.CausationEventSchema = _chunkNNWP65YMcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkNNWP65YMcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkNNWP65YMcjs.ConcurrencyError; exports.ConsoleLogger = _chunkYKL44PYXcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkNNWP65YMcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkNNWP65YMcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkNNWP65YMcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkNNWP65YMcjs.DeferSignal; exports.Environments = _chunkNNWP65YMcjs.Environments; exports.Errors = _chunkNNWP65YMcjs.Errors; exports.EventMetaSchema = _chunkNNWP65YMcjs.EventMetaSchema; exports.ExitCodes = _chunkNNWP65YMcjs.ExitCodes; exports.InMemoryCache = _chunkYKL44PYXcjs.InMemoryCache; exports.InMemoryStore = _chunkYKL44PYXcjs.InMemoryStore; exports.InvariantError = _chunkNNWP65YMcjs.InvariantError; exports.LogLevels = _chunkNNWP65YMcjs.LogLevels; exports.NonRetryableError = _chunkNNWP65YMcjs.NonRetryableError; exports.PackageSchema = _chunkYKL44PYXcjs.PackageSchema; exports.QuerySchema = _chunkNNWP65YMcjs.QuerySchema; exports.REDACTED = _chunkNNWP65YMcjs.REDACTED; exports.SHREDDED = _chunkNNWP65YMcjs.SHREDDED; exports.SNAP_EVENT = _chunkNNWP65YMcjs.SNAP_EVENT; exports.StoreError = _chunkNNWP65YMcjs.StoreError; exports.StreamClosedError = _chunkNNWP65YMcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkNNWP65YMcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkNNWP65YMcjs.TargetSchema; exports.ValidationError = _chunkNNWP65YMcjs.ValidationError; exports.ZodEmpty = _chunkNNWP65YMcjs.ZodEmpty; exports.act = act; exports.cache = _chunkYKL44PYXcjs.cache; exports.config = _chunkYKL44PYXcjs.config; exports.dateReviver = _chunkYKL44PYXcjs.dateReviver; exports.default_scope = _chunkYKL44PYXcjs.default_scope; exports.dispose = _chunkYKL44PYXcjs.dispose; exports.disposeAndExit = _chunkYKL44PYXcjs.disposeAndExit; exports.extend = _chunkYKL44PYXcjs.extend; exports.is_literal_source = _chunkYKL44PYXcjs.is_literal_source; exports.log = _chunkYKL44PYXcjs.log; exports.pii_fields = _chunkNNWP65YMcjs.pii_fields; exports.port = _chunkYKL44PYXcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkYKL44PYXcjs.resolveAutocloseConfig2; exports.sensitive = _chunkNNWP65YMcjs.sensitive; exports.sleep = _chunkYKL44PYXcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkYKL44PYXcjs.store; exports.validate = _chunkYKL44PYXcjs.validate;
|
|
5364
5274
|
//# sourceMappingURL=index.cjs.map
|