@rotorsoft/act 1.33.17 → 1.33.19
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 -5
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/config.d.ts +2 -2
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +2 -2
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +1 -1
- package/dist/@types/types/reaction.d.ts +8 -6
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/@types/utils.d.ts +5 -9
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/{chunk-5KTVG7IM.js → chunk-5Z53Y7SG.js} +2 -2
- package/dist/chunk-5Z53Y7SG.js.map +1 -0
- package/dist/{chunk-PMS6BMIU.cjs → chunk-DVYTKZD5.cjs} +1 -1
- package/dist/{chunk-PMS6BMIU.cjs.map → chunk-DVYTKZD5.cjs.map} +1 -1
- package/dist/{chunk-J6QMZEQF.cjs → chunk-GEUBNZ3B.cjs} +13 -13
- package/dist/chunk-GEUBNZ3B.cjs.map +1 -0
- package/dist/{chunk-CAL4XEVN.js → chunk-HEHGZHHA.js} +1 -1
- package/dist/{chunk-CAL4XEVN.js.map → chunk-HEHGZHHA.js.map} +1 -1
- package/dist/index.cjs +159 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -23
- 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 +1 -1
- package/dist/chunk-5KTVG7IM.js.map +0 -1
- package/dist/chunk-J6QMZEQF.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkGEUBNZ3Bcjs = require('./chunk-GEUBNZ3B.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -70,24 +70,24 @@ var _chunkJ6QMZEQFcjs = require('./chunk-J6QMZEQF.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var
|
|
73
|
+
var _chunkDVYTKZD5cjs = require('./chunk-DVYTKZD5.cjs');
|
|
74
74
|
|
|
75
75
|
// src/signals.ts
|
|
76
76
|
process.once("SIGINT", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
78
|
+
await _chunkGEUBNZ3Bcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("SIGTERM", async (arg) => {
|
|
81
|
-
|
|
82
|
-
await
|
|
81
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
82
|
+
await _chunkGEUBNZ3Bcjs.disposeAndExit.call(void 0, "EXIT");
|
|
83
83
|
});
|
|
84
84
|
process.once("uncaughtException", async (arg) => {
|
|
85
|
-
|
|
86
|
-
await
|
|
85
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
86
|
+
await _chunkGEUBNZ3Bcjs.disposeAndExit.call(void 0, "ERROR");
|
|
87
87
|
});
|
|
88
88
|
process.once("unhandledRejection", async (arg) => {
|
|
89
|
-
|
|
90
|
-
await
|
|
89
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
90
|
+
await _chunkGEUBNZ3Bcjs.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: [_chunkDVYTKZD5cjs.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 = _chunkDVYTKZD5cjs.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: [_chunkDVYTKZD5cjs.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 === _chunkDVYTKZD5cjs.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 _chunkGEUBNZ3Bcjs.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 _chunkGEUBNZ3Bcjs.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 === _chunkDVYTKZD5cjs.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
|
+
_chunkGEUBNZ3Bcjs.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 _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_stats(streams, {
|
|
981
|
+
exclude: [_chunkDVYTKZD5cjs.SNAP_EVENT]
|
|
982
982
|
});
|
|
983
|
-
const domain_heads = await
|
|
984
|
-
exclude: [
|
|
983
|
+
const domain_heads = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_stats(streams, {
|
|
984
|
+
exclude: [_chunkDVYTKZD5cjs.SNAP_EVENT, _chunkDVYTKZD5cjs.TOMBSTONE_EVENT]
|
|
985
985
|
});
|
|
986
|
-
const true_heads = await
|
|
986
|
+
const true_heads = await _chunkGEUBNZ3Bcjs.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]) === _chunkDVYTKZD5cjs.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
|
+
_chunkGEUBNZ3Bcjs.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 _chunkGEUBNZ3Bcjs.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: _chunkDVYTKZD5cjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
};
|
|
1102
1102
|
});
|
|
1103
|
-
const truncated = await
|
|
1103
|
+
const truncated = await _chunkGEUBNZ3Bcjs.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 _chunkGEUBNZ3Bcjs.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 _chunkGEUBNZ3Bcjs.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
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).error(new Error(message));
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
// src/internal/correlate-cycle.ts
|
|
@@ -1177,10 +1177,10 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1177
1177
|
__init10() {this._restoring = false}
|
|
1178
1178
|
|
|
1179
1179
|
// Bounded by `maxSubscribedStreams`; static records live apart so eviction
|
|
1180
|
-
// never
|
|
1180
|
+
// never lets a resolution re-lane them.
|
|
1181
1181
|
|
|
1182
1182
|
__init11() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1183
|
-
__init12() {this._patterns = new (0,
|
|
1183
|
+
__init12() {this._patterns = new (0, _chunkGEUBNZ3Bcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1184
1184
|
|
|
1185
1185
|
|
|
1186
1186
|
|
|
@@ -1198,7 +1198,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1198
1198
|
on_init
|
|
1199
1199
|
}) {;_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);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);
|
|
1200
1200
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1201
|
-
this._dynamic_subscriptions = new (0,
|
|
1201
|
+
this._dynamic_subscriptions = new (0, _chunkGEUBNZ3Bcjs.LruMap)(max_subscribed_streams);
|
|
1202
1202
|
this._registry = registry;
|
|
1203
1203
|
this._declared_lanes = declared_lanes;
|
|
1204
1204
|
this._static_targets = static_targets;
|
|
@@ -1226,7 +1226,6 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1226
1226
|
this._checkpoint = correlated_at >= 0 ? correlated_at : Math.max(-1, watermark - COLD_START_BACK_SCAN);
|
|
1227
1227
|
for (const { stream, priority = 0, lane } of this._static_targets) {
|
|
1228
1228
|
this._static_subscriptions.set(stream, {
|
|
1229
|
-
floor: Number.POSITIVE_INFINITY,
|
|
1230
1229
|
priority,
|
|
1231
1230
|
lane
|
|
1232
1231
|
});
|
|
@@ -1257,7 +1256,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1257
1256
|
/** Would the target's own `fetch` (filtered by `source`) return this event? */
|
|
1258
1257
|
_in_fetch_window(source, stream) {
|
|
1259
1258
|
if (source === void 0 || source === stream) return true;
|
|
1260
|
-
if (
|
|
1259
|
+
if (_chunkGEUBNZ3Bcjs.is_literal_source.call(void 0, source)) return false;
|
|
1261
1260
|
let pattern = this._patterns.get(source);
|
|
1262
1261
|
if (!pattern) {
|
|
1263
1262
|
pattern = new RegExp(source);
|
|
@@ -1296,11 +1295,11 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1296
1295
|
this._lease_until = correlating ? now + CORRELATION_LEASE_MS : 0;
|
|
1297
1296
|
if (correlating === false) return idle();
|
|
1298
1297
|
}
|
|
1299
|
-
const after =
|
|
1298
|
+
const after = this._checkpoint;
|
|
1300
1299
|
const correlated = /* @__PURE__ */ new Map();
|
|
1301
1300
|
let last_id = after;
|
|
1302
1301
|
let stopped = false;
|
|
1303
|
-
const found = await
|
|
1302
|
+
const found = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query(
|
|
1304
1303
|
(event) => {
|
|
1305
1304
|
if (stopped) return;
|
|
1306
1305
|
const register = this._registry.events[event.name];
|
|
@@ -1330,9 +1329,10 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1330
1329
|
);
|
|
1331
1330
|
lane = void 0;
|
|
1332
1331
|
}
|
|
1333
|
-
const
|
|
1332
|
+
const fixed = this._static_subscriptions.get(resolved.target);
|
|
1333
|
+
const recorded = _nullishCoalesce(fixed, () => ( this._dynamic_subscriptions.get(resolved.target)));
|
|
1334
1334
|
const priority = _nullishCoalesce(resolved.priority, () => ( 0));
|
|
1335
|
-
const upgraded = !recorded || priority > recorded.
|
|
1335
|
+
const upgraded = !recorded || !fixed && priority > recorded.priority;
|
|
1336
1336
|
const carried = upgraded ? { priority, lane } : { priority: recorded.priority, lane: recorded.lane };
|
|
1337
1337
|
const entry = correlated.get(resolved.target) || {
|
|
1338
1338
|
source: resolved.source,
|
|
@@ -1344,9 +1344,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1344
1344
|
correlated_at: void 0
|
|
1345
1345
|
};
|
|
1346
1346
|
const seen_in_scan = correlated.has(resolved.target);
|
|
1347
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => (
|
|
1347
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkDVYTKZD5cjs.DEFAULT_LANE));
|
|
1348
1348
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _62 => _62.priority]);
|
|
1349
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
1349
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkDVYTKZD5cjs.DEFAULT_LANE));
|
|
1350
1350
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1351
1351
|
report_lane_conflict(
|
|
1352
1352
|
this._reported,
|
|
@@ -1370,7 +1370,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1370
1370
|
},
|
|
1371
1371
|
// Resolvers see `pii: null`: correlate runs actor-less, and one
|
|
1372
1372
|
// undecryptable row would otherwise stop every stream's reactions.
|
|
1373
|
-
{
|
|
1373
|
+
{ after, limit: query.limit, with_pii: false }
|
|
1374
1374
|
);
|
|
1375
1375
|
if (this._declared_lanes.size > 1) await this._recall(correlated);
|
|
1376
1376
|
const read = last_id > after;
|
|
@@ -1402,7 +1402,6 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1402
1402
|
for (const { stream, priority, lane } of streams) {
|
|
1403
1403
|
if (_optionalChain([correlated, 'access', _63 => _63.get, 'call', _64 => _64(stream), 'optionalAccess', _65 => _65.upgraded]))
|
|
1404
1404
|
this._dynamic_subscriptions.set(stream, {
|
|
1405
|
-
floor: priority,
|
|
1406
1405
|
priority,
|
|
1407
1406
|
lane
|
|
1408
1407
|
});
|
|
@@ -1423,7 +1422,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1423
1422
|
await Promise.all(
|
|
1424
1423
|
missed.map(async ([stream, entry]) => {
|
|
1425
1424
|
let row;
|
|
1426
|
-
await
|
|
1425
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_streams(
|
|
1427
1426
|
(position) => {
|
|
1428
1427
|
row = position;
|
|
1429
1428
|
},
|
|
@@ -1431,13 +1430,12 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1431
1430
|
);
|
|
1432
1431
|
if (!row) return;
|
|
1433
1432
|
this._dynamic_subscriptions.set(stream, {
|
|
1434
|
-
floor: row.priority,
|
|
1435
1433
|
priority: row.priority,
|
|
1436
1434
|
lane: row.lane
|
|
1437
1435
|
});
|
|
1438
1436
|
if (entry.priority > row.priority) return;
|
|
1439
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
1440
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
1437
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkDVYTKZD5cjs.DEFAULT_LANE));
|
|
1438
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkDVYTKZD5cjs.DEFAULT_LANE));
|
|
1441
1439
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
1442
1440
|
report_lane_conflict(
|
|
1443
1441
|
this._reported,
|
|
@@ -1463,7 +1461,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1463
1461
|
millis: 0
|
|
1464
1462
|
});
|
|
1465
1463
|
} catch (error) {
|
|
1466
|
-
|
|
1464
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
1467
1465
|
`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)}`
|
|
1468
1466
|
);
|
|
1469
1467
|
}
|
|
@@ -1616,14 +1614,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1616
1614
|
}
|
|
1617
1615
|
|
|
1618
1616
|
// src/internal/drain-ops.ts
|
|
1619
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1617
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkGEUBNZ3Bcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1620
1618
|
async function fetch(leased, eventLimit) {
|
|
1621
1619
|
return Promise.all(
|
|
1622
1620
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1623
1621
|
const events = [];
|
|
1624
|
-
const stream_exact = source !== void 0 &&
|
|
1622
|
+
const stream_exact = source !== void 0 && _chunkGEUBNZ3Bcjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1625
1623
|
try {
|
|
1626
|
-
await
|
|
1624
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1627
1625
|
stream: source,
|
|
1628
1626
|
stream_exact,
|
|
1629
1627
|
after: at,
|
|
@@ -1643,30 +1641,30 @@ async function fetch(leased, eventLimit) {
|
|
|
1643
1641
|
})
|
|
1644
1642
|
);
|
|
1645
1643
|
}
|
|
1646
|
-
var ack = (leases) =>
|
|
1647
|
-
var block = (leases) =>
|
|
1648
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1644
|
+
var ack = (leases) => _chunkGEUBNZ3Bcjs.store.call(void 0, ).ack(leases);
|
|
1645
|
+
var block = (leases) => _chunkGEUBNZ3Bcjs.store.call(void 0, ).block(leases);
|
|
1646
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkGEUBNZ3Bcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1649
1647
|
|
|
1650
1648
|
// src/internal/event-sourcing.ts
|
|
1651
1649
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1652
1650
|
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1653
1651
|
var validating_patch = (me, state2, partial, event) => {
|
|
1654
1652
|
const next = _actpatch.patch.call(void 0, state2, partial);
|
|
1655
|
-
return
|
|
1653
|
+
return _chunkGEUBNZ3Bcjs.validate.call(void 0,
|
|
1656
1654
|
`${me.name}.${String(event.name)}#${event.id}`,
|
|
1657
1655
|
next,
|
|
1658
1656
|
me.state
|
|
1659
1657
|
);
|
|
1660
1658
|
};
|
|
1661
1659
|
var DEFAULT_BATCH = 500;
|
|
1662
|
-
var cache_put = (stream, entry) =>
|
|
1663
|
-
(err) =>
|
|
1660
|
+
var cache_put = (stream, entry) => _chunkGEUBNZ3Bcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1661
|
+
(err) => _chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
1664
1662
|
err,
|
|
1665
1663
|
"cache set skipped; the next load re-folds from the store"
|
|
1666
1664
|
)
|
|
1667
1665
|
);
|
|
1668
|
-
var cache_drop = (stream) =>
|
|
1669
|
-
(err) =>
|
|
1666
|
+
var cache_drop = (stream) => _chunkGEUBNZ3Bcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1667
|
+
(err) => _chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
1670
1668
|
err,
|
|
1671
1669
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1672
1670
|
)
|
|
@@ -1674,9 +1672,9 @@ var cache_drop = (stream) => _chunkJ6QMZEQFcjs.cache.call(void 0, ).invalidate(s
|
|
|
1674
1672
|
async function snap(snapshot) {
|
|
1675
1673
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1676
1674
|
try {
|
|
1677
|
-
const [committed] = await
|
|
1675
|
+
const [committed] = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).commit(
|
|
1678
1676
|
stream,
|
|
1679
|
-
[{ name:
|
|
1677
|
+
[{ name: _chunkDVYTKZD5cjs.SNAP_EVENT, data: snapshot.state }],
|
|
1680
1678
|
{
|
|
1681
1679
|
correlation: meta.correlation,
|
|
1682
1680
|
causation: { event: { id, name, stream } }
|
|
@@ -1687,22 +1685,22 @@ async function snap(snapshot) {
|
|
|
1687
1685
|
return committed;
|
|
1688
1686
|
} catch (error) {
|
|
1689
1687
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1690
|
-
|
|
1688
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
1691
1689
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1692
1690
|
);
|
|
1693
1691
|
}
|
|
1694
1692
|
}
|
|
1695
1693
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1696
1694
|
try {
|
|
1697
|
-
const [committed] = await
|
|
1695
|
+
const [committed] = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).commit(
|
|
1698
1696
|
stream,
|
|
1699
|
-
[{ name:
|
|
1697
|
+
[{ name: _chunkDVYTKZD5cjs.TOMBSTONE_EVENT, data: {} }],
|
|
1700
1698
|
{ correlation, causation: {} },
|
|
1701
1699
|
expectedVersion
|
|
1702
1700
|
);
|
|
1703
1701
|
return committed;
|
|
1704
1702
|
} catch (error) {
|
|
1705
|
-
if (error instanceof
|
|
1703
|
+
if (error instanceof _chunkDVYTKZD5cjs.ConcurrencyError) return void 0;
|
|
1706
1704
|
throw error;
|
|
1707
1705
|
}
|
|
1708
1706
|
}
|
|
@@ -1732,9 +1730,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1732
1730
|
if (drop_closed_streams) {
|
|
1733
1731
|
await source.query(
|
|
1734
1732
|
(e) => {
|
|
1735
|
-
if (e.name ===
|
|
1733
|
+
if (e.name === _chunkDVYTKZD5cjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1736
1734
|
},
|
|
1737
|
-
{ names: [
|
|
1735
|
+
{ names: [_chunkDVYTKZD5cjs.TOMBSTONE_EVENT] }
|
|
1738
1736
|
);
|
|
1739
1737
|
}
|
|
1740
1738
|
let max_id;
|
|
@@ -1756,11 +1754,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1756
1754
|
if (!is_valid(event))
|
|
1757
1755
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1758
1756
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1759
|
-
if (drop_snapshots && event.name ===
|
|
1757
|
+
if (drop_snapshots && event.name === _chunkDVYTKZD5cjs.SNAP_EVENT) {
|
|
1760
1758
|
dropped_snaps++;
|
|
1761
1759
|
return;
|
|
1762
1760
|
}
|
|
1763
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1761
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkDVYTKZD5cjs.TOMBSTONE_EVENT) {
|
|
1764
1762
|
dropped_closed++;
|
|
1765
1763
|
return;
|
|
1766
1764
|
}
|
|
@@ -1827,17 +1825,17 @@ async function scan(source, opts = {}, callback) {
|
|
|
1827
1825
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1828
1826
|
const { stream, actor, asOf } = target;
|
|
1829
1827
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1830
|
-
const cached = time_travel ? void 0 : await
|
|
1828
|
+
const cached = time_travel ? void 0 : await _chunkGEUBNZ3Bcjs.cache.call(void 0, ).get(stream);
|
|
1831
1829
|
const cache_hit = !!cached;
|
|
1832
1830
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _72 => _72.state]), () => ( (me.init ? me.init() : {})));
|
|
1833
1831
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.patches]), () => ( 0));
|
|
1834
1832
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.snaps]), () => ( 0));
|
|
1835
1833
|
let replayed = 0;
|
|
1836
1834
|
let event;
|
|
1837
|
-
await
|
|
1835
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query(
|
|
1838
1836
|
(raw) => {
|
|
1839
1837
|
event = me.view(raw, actor);
|
|
1840
|
-
if (event.name ===
|
|
1838
|
+
if (event.name === _chunkDVYTKZD5cjs.SNAP_EVENT) {
|
|
1841
1839
|
state2 = event.data;
|
|
1842
1840
|
snaps++;
|
|
1843
1841
|
patches = 0;
|
|
@@ -1846,8 +1844,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1846
1844
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1847
1845
|
patches++;
|
|
1848
1846
|
replayed++;
|
|
1849
|
-
} else if (event.name !==
|
|
1850
|
-
|
|
1847
|
+
} else if (event.name !== _chunkDVYTKZD5cjs.TOMBSTONE_EVENT) {
|
|
1848
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
1851
1849
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1852
1850
|
);
|
|
1853
1851
|
}
|
|
@@ -1871,7 +1869,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1871
1869
|
...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
|
|
1872
1870
|
}
|
|
1873
1871
|
);
|
|
1874
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) ===
|
|
1872
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) === _chunkDVYTKZD5cjs.TOMBSTONE_EVENT;
|
|
1875
1873
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1876
1874
|
await cache_put(stream, {
|
|
1877
1875
|
stream,
|
|
@@ -1899,7 +1897,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1899
1897
|
if (!stream) throw new Error("Missing target stream");
|
|
1900
1898
|
const reactingTo = _optionalChain([options, 'optionalAccess', _81 => _81.reactingTo]);
|
|
1901
1899
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.correlator]), () => ( default_correlator));
|
|
1902
|
-
const validated =
|
|
1900
|
+
const validated = _chunkGEUBNZ3Bcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1903
1901
|
const opts = _optionalChain([me, 'access', _83 => _83.options, 'optionalAccess', _84 => _84[action2]]);
|
|
1904
1902
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries]), () => ( 0));
|
|
1905
1903
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1910,14 +1908,14 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1910
1908
|
void 0,
|
|
1911
1909
|
patch_fn
|
|
1912
1910
|
);
|
|
1913
|
-
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) ===
|
|
1914
|
-
throw new (0,
|
|
1911
|
+
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) === _chunkDVYTKZD5cjs.TOMBSTONE_EVENT)
|
|
1912
|
+
throw new (0, _chunkDVYTKZD5cjs.StreamClosedError)(stream);
|
|
1915
1913
|
const expected = _nullishCoalesce(expectedVersion, () => ( (snapshot.version >= 0 ? snapshot.version : void 0)));
|
|
1916
1914
|
if (me.given) {
|
|
1917
1915
|
const invariants = me.given[action2] || [];
|
|
1918
1916
|
invariants.forEach(({ valid: valid2, description }) => {
|
|
1919
1917
|
if (!valid2(snapshot.state, actor))
|
|
1920
|
-
throw new (0,
|
|
1918
|
+
throw new (0, _chunkDVYTKZD5cjs.InvariantError)(
|
|
1921
1919
|
action2,
|
|
1922
1920
|
validated,
|
|
1923
1921
|
target,
|
|
@@ -1934,7 +1932,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1934
1932
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1935
1933
|
const valid = tuples.map(([name, data]) => ({
|
|
1936
1934
|
name,
|
|
1937
|
-
data:
|
|
1935
|
+
data: _chunkGEUBNZ3Bcjs.validate.call(void 0, name, data, me.events[name])
|
|
1938
1936
|
}));
|
|
1939
1937
|
const emitted = valid.map((e) => me.message(e));
|
|
1940
1938
|
const meta = {
|
|
@@ -1959,7 +1957,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1959
1957
|
};
|
|
1960
1958
|
let committed;
|
|
1961
1959
|
try {
|
|
1962
|
-
committed = await
|
|
1960
|
+
committed = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).commit(
|
|
1963
1961
|
stream,
|
|
1964
1962
|
emitted,
|
|
1965
1963
|
meta,
|
|
@@ -1968,7 +1966,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1968
1966
|
reactingTo ? expectedVersion : expected
|
|
1969
1967
|
);
|
|
1970
1968
|
} catch (error) {
|
|
1971
|
-
if (error instanceof
|
|
1969
|
+
if (error instanceof _chunkDVYTKZD5cjs.ConcurrencyError) void cache_drop(stream);
|
|
1972
1970
|
throw error;
|
|
1973
1971
|
}
|
|
1974
1972
|
let { state: state2, patches } = snapshot;
|
|
@@ -2007,19 +2005,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
2007
2005
|
}
|
|
2008
2006
|
return snapshots;
|
|
2009
2007
|
} catch (error) {
|
|
2010
|
-
if (!(error instanceof
|
|
2008
|
+
if (!(error instanceof _chunkDVYTKZD5cjs.ConcurrencyError)) throw error;
|
|
2011
2009
|
if (expectedVersion !== void 0) throw error;
|
|
2012
2010
|
if (attempt >= max_retries) throw error;
|
|
2013
2011
|
if (_optionalChain([opts, 'optionalAccess', _94 => _94.backoff])) {
|
|
2014
2012
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
2015
|
-
if (delay_ms > 0) await
|
|
2013
|
+
if (delay_ms > 0) await _chunkGEUBNZ3Bcjs.sleep.call(void 0, delay_ms);
|
|
2016
2014
|
}
|
|
2017
2015
|
}
|
|
2018
2016
|
}
|
|
2019
2017
|
}
|
|
2020
2018
|
|
|
2021
2019
|
// src/internal/tracing.ts
|
|
2022
|
-
var PRETTY =
|
|
2020
|
+
var PRETTY = _chunkGEUBNZ3Bcjs.config.call(void 0, ).env !== "production";
|
|
2023
2021
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2024
2022
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2025
2023
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2205,7 +2203,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2205
2203
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _104 => _104.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2206
2204
|
return void 0;
|
|
2207
2205
|
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.`;
|
|
2208
|
-
|
|
2206
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).error(error);
|
|
2209
2207
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2210
2208
|
}
|
|
2211
2209
|
function fetch_failure_policy(registry) {
|
|
@@ -2221,13 +2219,13 @@ function fetch_failure_policy(registry) {
|
|
|
2221
2219
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
2222
2220
|
if (!error) return { lease, handled, acked_at: at };
|
|
2223
2221
|
logger.error(error);
|
|
2224
|
-
const non_retryable = error instanceof
|
|
2222
|
+
const non_retryable = error instanceof _chunkDVYTKZD5cjs.NonRetryableError;
|
|
2225
2223
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2226
2224
|
if (block2)
|
|
2227
2225
|
logger.error(
|
|
2228
2226
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2229
2227
|
);
|
|
2230
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2228
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkGEUBNZ3Bcjs.DEFAULT_BACKOFF)));
|
|
2231
2229
|
return {
|
|
2232
2230
|
lease,
|
|
2233
2231
|
handled,
|
|
@@ -2356,7 +2354,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2356
2354
|
const acked = await ops.ack(submitted);
|
|
2357
2355
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2358
2356
|
if (acked.length < expected)
|
|
2359
|
-
|
|
2357
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
2360
2358
|
`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.`
|
|
2361
2359
|
);
|
|
2362
2360
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2456,9 +2454,9 @@ var DrainController = (_class5 = class {
|
|
|
2456
2454
|
if (!this.armed || this._stopped || this._inflight)
|
|
2457
2455
|
return EMPTY_DRAIN;
|
|
2458
2456
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2459
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2460
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2461
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2457
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_STREAM_LIMIT));
|
|
2458
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkGEUBNZ3Bcjs.DEFAULT_EVENT_LIMIT));
|
|
2459
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_LEASE_MILLIS));
|
|
2462
2460
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2463
2461
|
return EMPTY_DRAIN;
|
|
2464
2462
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2533,7 +2531,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2533
2531
|
const { pii, ...rest } = event;
|
|
2534
2532
|
if (pii == null) {
|
|
2535
2533
|
const shredded = { ...data };
|
|
2536
|
-
for (const f of fields) shredded[f] =
|
|
2534
|
+
for (const f of fields) shredded[f] = _chunkDVYTKZD5cjs.SHREDDED;
|
|
2537
2535
|
return { ...rest, data: shredded };
|
|
2538
2536
|
}
|
|
2539
2537
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2544,7 +2542,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2544
2542
|
};
|
|
2545
2543
|
}
|
|
2546
2544
|
const redacted = { ...data };
|
|
2547
|
-
for (const f of fields) redacted[f] =
|
|
2545
|
+
for (const f of fields) redacted[f] = _chunkDVYTKZD5cjs.REDACTED;
|
|
2548
2546
|
return { ...rest, data: redacted };
|
|
2549
2547
|
}
|
|
2550
2548
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2681,7 +2679,7 @@ function make_deferred(handler, schedule) {
|
|
|
2681
2679
|
const call = handler;
|
|
2682
2680
|
const deferred = async (event, stream, app) => {
|
|
2683
2681
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2684
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2682
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkDVYTKZD5cjs.DeferSignal)(when);
|
|
2685
2683
|
return call(event, stream, app);
|
|
2686
2684
|
};
|
|
2687
2685
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2750,7 +2748,7 @@ function build_handle(deps) {
|
|
|
2750
2748
|
handled++;
|
|
2751
2749
|
}
|
|
2752
2750
|
} catch (error) {
|
|
2753
|
-
if (error instanceof
|
|
2751
|
+
if (error instanceof _chunkDVYTKZD5cjs.DeferSignal) {
|
|
2754
2752
|
let defer;
|
|
2755
2753
|
try {
|
|
2756
2754
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2857,8 +2855,8 @@ var SettleLoop = (_class6 = class {
|
|
|
2857
2855
|
* queues one more pass after it. Callers pass options, which the next
|
|
2858
2856
|
* pass uses; internal wake-ups pass none, so they never discard a
|
|
2859
2857
|
* caller's. The cycle runs correlate→drain in a
|
|
2860
|
-
* loop until no progress
|
|
2861
|
-
*
|
|
2858
|
+
* loop until a pass makes no progress (it read no events and leased no
|
|
2859
|
+
* streams) or `maxPasses` is reached, then emits the
|
|
2862
2860
|
* `"settled"` lifecycle event via {@link SettleDeps.on_settled}.
|
|
2863
2861
|
*/
|
|
2864
2862
|
schedule(options) {
|
|
@@ -2879,8 +2877,7 @@ var SettleLoop = (_class6 = class {
|
|
|
2879
2877
|
this._timer = void 0;
|
|
2880
2878
|
const {
|
|
2881
2879
|
debounceMs: _,
|
|
2882
|
-
|
|
2883
|
-
correlate: { after: _after, ...correlate_query } = {},
|
|
2880
|
+
correlate: correlate_query = {},
|
|
2884
2881
|
maxPasses = Infinity,
|
|
2885
2882
|
...drain_options
|
|
2886
2883
|
} = _nullishCoalesce(this._next, () => ( {}));
|
|
@@ -2893,7 +2890,7 @@ var SettleLoop = (_class6 = class {
|
|
|
2893
2890
|
if (scanned) this._deps.breaker.passed();
|
|
2894
2891
|
const drain = await this._deps.drain(drain_options);
|
|
2895
2892
|
passes.push(drain);
|
|
2896
|
-
const made_progress = drain.leased.length > 0 || scanned &&
|
|
2893
|
+
const made_progress = drain.leased.length > 0 || scanned && pass.read;
|
|
2897
2894
|
if (!made_progress) break;
|
|
2898
2895
|
}
|
|
2899
2896
|
if (passes.length) this._deps.on_settled(merge_drains(passes));
|
|
@@ -3018,7 +3015,7 @@ var Act = (_class7 = class {
|
|
|
3018
3015
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
3019
3016
|
|
|
3020
3017
|
|
|
3021
|
-
__init27() {this._logger =
|
|
3018
|
+
__init27() {this._logger = _chunkGEUBNZ3Bcjs.log.call(void 0, )}
|
|
3022
3019
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3023
3020
|
|
|
3024
3021
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3040,9 +3037,9 @@ var Act = (_class7 = class {
|
|
|
3040
3037
|
this._lanes = lanes;
|
|
3041
3038
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3042
3039
|
validate_only_lanes(options, lanes);
|
|
3043
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3040
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkGEUBNZ3Bcjs.default_scope.call(void 0, )));
|
|
3044
3041
|
const ports = this._ports;
|
|
3045
|
-
this._scoped =
|
|
3042
|
+
this._scoped = _chunkGEUBNZ3Bcjs.make_run_scoped.call(void 0, {
|
|
3046
3043
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3047
3044
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3048
3045
|
get store() {
|
|
@@ -3052,14 +3049,14 @@ var Act = (_class7 = class {
|
|
|
3052
3049
|
return ports.cache;
|
|
3053
3050
|
},
|
|
3054
3051
|
// Parsed per build, so a bad window throws on every build.
|
|
3055
|
-
autoclose_window:
|
|
3052
|
+
autoclose_window: _chunkGEUBNZ3Bcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3056
3053
|
});
|
|
3057
3054
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3058
3055
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3059
3056
|
this._cd = build_drain(this._logger);
|
|
3060
3057
|
const handle = build_handle({
|
|
3061
3058
|
logger: this._logger,
|
|
3062
|
-
reaction_scope:
|
|
3059
|
+
reaction_scope: _chunkGEUBNZ3Bcjs.make_reaction_scope.call(void 0, {
|
|
3063
3060
|
do: this.do.bind(this),
|
|
3064
3061
|
load: this.load.bind(this),
|
|
3065
3062
|
query: this.query.bind(this),
|
|
@@ -3089,12 +3086,12 @@ var Act = (_class7 = class {
|
|
|
3089
3086
|
this._ports.store,
|
|
3090
3087
|
options.listen !== false
|
|
3091
3088
|
);
|
|
3092
|
-
|
|
3089
|
+
_chunkGEUBNZ3Bcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3093
3090
|
}
|
|
3094
3091
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3095
3092
|
_build_breaker(options) {
|
|
3096
3093
|
return new CircuitBreaker(
|
|
3097
|
-
|
|
3094
|
+
_chunkGEUBNZ3Bcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3098
3095
|
{
|
|
3099
3096
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3100
3097
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3128,7 +3125,7 @@ var Act = (_class7 = class {
|
|
|
3128
3125
|
try {
|
|
3129
3126
|
await this._run_close(targets);
|
|
3130
3127
|
} catch (error) {
|
|
3131
|
-
if (error instanceof
|
|
3128
|
+
if (error instanceof _chunkDVYTKZD5cjs.StoreError) throw error;
|
|
3132
3129
|
this._logger.error(
|
|
3133
3130
|
error,
|
|
3134
3131
|
`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.`
|
|
@@ -3163,7 +3160,7 @@ var Act = (_class7 = class {
|
|
|
3163
3160
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3164
3161
|
_build_audit_deps() {
|
|
3165
3162
|
return {
|
|
3166
|
-
store:
|
|
3163
|
+
store: _chunkGEUBNZ3Bcjs.store,
|
|
3167
3164
|
event_to_state: this._event_to_state,
|
|
3168
3165
|
// Declared lanes, not this process's controllers: a lane another
|
|
3169
3166
|
// worker drains is not `unknown-lane`.
|
|
@@ -3176,7 +3173,7 @@ var Act = (_class7 = class {
|
|
|
3176
3173
|
registry: this.registry,
|
|
3177
3174
|
static_targets: classification.static_targets,
|
|
3178
3175
|
cd: this._cd,
|
|
3179
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3176
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkDVYTKZD5cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3180
3177
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3181
3178
|
// still a valid destination.
|
|
3182
3179
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3192,7 +3189,7 @@ var Act = (_class7 = class {
|
|
|
3192
3189
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3193
3190
|
async _seed_persisted_defers() {
|
|
3194
3191
|
const now = Date.now();
|
|
3195
|
-
await walk_streams(
|
|
3192
|
+
await walk_streams(_chunkGEUBNZ3Bcjs.store.call(void 0, ), (pos) => {
|
|
3196
3193
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3197
3194
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3198
3195
|
_optionalChain([controller, 'optionalAccess', _124 => _124.seed_defer, 'call', _125 => _125(pos.stream, pos.deferred_at)]);
|
|
@@ -3211,7 +3208,7 @@ var Act = (_class7 = class {
|
|
|
3211
3208
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3212
3209
|
breaker: this._breaker
|
|
3213
3210
|
},
|
|
3214
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3211
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkDVYTKZD5cjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3215
3212
|
);
|
|
3216
3213
|
}
|
|
3217
3214
|
|
|
@@ -3231,7 +3228,7 @@ var Act = (_class7 = class {
|
|
|
3231
3228
|
*/
|
|
3232
3229
|
shutdown(options) {
|
|
3233
3230
|
if (!this._shutdown_promise) {
|
|
3234
|
-
|
|
3231
|
+
_chunkGEUBNZ3Bcjs.resolveShutdownConfig.call(void 0, options);
|
|
3235
3232
|
this._shutdown_promise = (async () => {
|
|
3236
3233
|
this.stop_correlations();
|
|
3237
3234
|
this._settle.stop(true);
|
|
@@ -3251,10 +3248,10 @@ var Act = (_class7 = class {
|
|
|
3251
3248
|
* default for none or 0, and for a running settle), capped.
|
|
3252
3249
|
*/
|
|
3253
3250
|
_derive_grace_ms(running, settling) {
|
|
3254
|
-
let max = settling ?
|
|
3251
|
+
let max = settling ? _chunkGEUBNZ3Bcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3255
3252
|
for (const c of running)
|
|
3256
|
-
max = Math.max(max, c.lease_millis ||
|
|
3257
|
-
return Math.min(max,
|
|
3253
|
+
max = Math.max(max, c.lease_millis || _chunkGEUBNZ3Bcjs.DEFAULT_LEASE_MILLIS);
|
|
3254
|
+
return Math.min(max, _chunkGEUBNZ3Bcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3258
3255
|
}
|
|
3259
3256
|
async _await_inflight(grace_ms) {
|
|
3260
3257
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3335,7 +3332,7 @@ var Act = (_class7 = class {
|
|
|
3335
3332
|
* @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
|
|
3336
3333
|
*/
|
|
3337
3334
|
async do(action2, target, payload, options) {
|
|
3338
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => (
|
|
3335
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => ( _chunkGEUBNZ3Bcjs.current_reacting.call(void 0, )));
|
|
3339
3336
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _128 => _128.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3340
3337
|
return this._scoped(async () => {
|
|
3341
3338
|
const snapshots = await this._es.action(
|
|
@@ -3396,7 +3393,7 @@ var Act = (_class7 = class {
|
|
|
3396
3393
|
return this._scoped(async () => {
|
|
3397
3394
|
let first;
|
|
3398
3395
|
let last;
|
|
3399
|
-
const count = await
|
|
3396
|
+
const count = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query((e) => {
|
|
3400
3397
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3401
3398
|
if (!first) first = gated;
|
|
3402
3399
|
last = gated;
|
|
@@ -3426,7 +3423,7 @@ var Act = (_class7 = class {
|
|
|
3426
3423
|
async query_array(query) {
|
|
3427
3424
|
return this._scoped(async () => {
|
|
3428
3425
|
const events = [];
|
|
3429
|
-
await
|
|
3426
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query((e) => {
|
|
3430
3427
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3431
3428
|
}, query);
|
|
3432
3429
|
return events;
|
|
@@ -3446,14 +3443,14 @@ var Act = (_class7 = class {
|
|
|
3446
3443
|
*/
|
|
3447
3444
|
async forget(stream) {
|
|
3448
3445
|
return this._scoped(async () => {
|
|
3449
|
-
const s =
|
|
3446
|
+
const s = _chunkGEUBNZ3Bcjs.store.call(void 0, );
|
|
3450
3447
|
if (!s.forget_pii) {
|
|
3451
3448
|
throw new Error(
|
|
3452
3449
|
`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).`
|
|
3453
3450
|
);
|
|
3454
3451
|
}
|
|
3455
3452
|
const eventCount = await s.forget_pii(stream);
|
|
3456
|
-
await
|
|
3453
|
+
await _chunkGEUBNZ3Bcjs.cache.call(void 0, ).invalidate(stream);
|
|
3457
3454
|
if (eventCount > 0) {
|
|
3458
3455
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3459
3456
|
}
|
|
@@ -3487,7 +3484,7 @@ var Act = (_class7 = class {
|
|
|
3487
3484
|
* @see {@link correlate} for dynamic stream discovery
|
|
3488
3485
|
*/
|
|
3489
3486
|
async drain(options = {}) {
|
|
3490
|
-
|
|
3487
|
+
_chunkGEUBNZ3Bcjs.resolveDrainConfig.call(void 0, options);
|
|
3491
3488
|
if (!this._drain)
|
|
3492
3489
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3493
3490
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3552,8 +3549,9 @@ var Act = (_class7 = class {
|
|
|
3552
3549
|
* target streams their reactions resolve to (static or computed from
|
|
3553
3550
|
* the event), and marks their work so the next drain can claim it.
|
|
3554
3551
|
*
|
|
3555
|
-
* @param query -
|
|
3556
|
-
*
|
|
3552
|
+
* @param query - Only `limit` is used: the most events the pass reads
|
|
3553
|
+
* (default 10). The scan always starts at the correlation checkpoint,
|
|
3554
|
+
* which every reaction shares, so filters and `after` are ignored.
|
|
3557
3555
|
* @returns The number of newly subscribed streams and the last scanned event id
|
|
3558
3556
|
*
|
|
3559
3557
|
* @example Manual correlation
|
|
@@ -3563,7 +3561,7 @@ var Act = (_class7 = class {
|
|
|
3563
3561
|
*
|
|
3564
3562
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3565
3563
|
*/
|
|
3566
|
-
async correlate(query = {
|
|
3564
|
+
async correlate(query = { limit: 10 }) {
|
|
3567
3565
|
const pass = await this._correlate_pass(query);
|
|
3568
3566
|
return {
|
|
3569
3567
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -3575,8 +3573,7 @@ var Act = (_class7 = class {
|
|
|
3575
3573
|
if (!this._drain) return { kind: "idle", last_id: -1 };
|
|
3576
3574
|
return this._scoped(async () => {
|
|
3577
3575
|
const pass = await this._correlate.correlate(query, lease);
|
|
3578
|
-
if (pass.kind === "scanned" &&
|
|
3579
|
-
this._arm_all();
|
|
3576
|
+
if (pass.kind === "scanned" && pass.marked > 0) this._arm_all();
|
|
3580
3577
|
return pass;
|
|
3581
3578
|
});
|
|
3582
3579
|
}
|
|
@@ -3667,7 +3664,7 @@ var Act = (_class7 = class {
|
|
|
3667
3664
|
*/
|
|
3668
3665
|
async reset(input) {
|
|
3669
3666
|
return this._scoped(async () => {
|
|
3670
|
-
const count = await
|
|
3667
|
+
const count = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).reset(input);
|
|
3671
3668
|
for (const handler of this._batch_handlers.values())
|
|
3672
3669
|
_optionalChain([handler, 'access', _135 => _135[FOLD_RESET], 'optionalCall', _136 => _136()]);
|
|
3673
3670
|
if (count > 0) {
|
|
@@ -3703,7 +3700,7 @@ var Act = (_class7 = class {
|
|
|
3703
3700
|
*/
|
|
3704
3701
|
async unblock(input) {
|
|
3705
3702
|
return this._scoped(async () => {
|
|
3706
|
-
const count = await
|
|
3703
|
+
const count = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).unblock(input);
|
|
3707
3704
|
if (count > 0) {
|
|
3708
3705
|
this._wake();
|
|
3709
3706
|
}
|
|
@@ -3738,8 +3735,8 @@ var Act = (_class7 = class {
|
|
|
3738
3735
|
* `__snapshot__` events (counted in the result); `on_progress`
|
|
3739
3736
|
* fires once per event.
|
|
3740
3737
|
* @param sink - Where the events land. Defaults to this Act's store.
|
|
3741
|
-
* @returns {@link ScanResult}
|
|
3742
|
-
*
|
|
3738
|
+
* @returns The {@link ScanResult}: what was kept, migrated and dropped,
|
|
3739
|
+
* and how long it took.
|
|
3743
3740
|
*
|
|
3744
3741
|
* @example Restore a CSV backup into the connected store
|
|
3745
3742
|
* ```typescript
|
|
@@ -3758,7 +3755,7 @@ var Act = (_class7 = class {
|
|
|
3758
3755
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3759
3756
|
}
|
|
3760
3757
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3761
|
-
const s =
|
|
3758
|
+
const s = _chunkGEUBNZ3Bcjs.store.call(void 0, );
|
|
3762
3759
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3763
3760
|
return s;
|
|
3764
3761
|
})()));
|
|
@@ -3804,7 +3801,7 @@ var Act = (_class7 = class {
|
|
|
3804
3801
|
async blocked_streams(options) {
|
|
3805
3802
|
return this._scoped(async () => {
|
|
3806
3803
|
const positions = [];
|
|
3807
|
-
await
|
|
3804
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_streams(
|
|
3808
3805
|
(p) => {
|
|
3809
3806
|
positions.push(p);
|
|
3810
3807
|
},
|
|
@@ -3856,7 +3853,7 @@ var Act = (_class7 = class {
|
|
|
3856
3853
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3857
3854
|
*/
|
|
3858
3855
|
async prioritize(filter, priority) {
|
|
3859
|
-
return this._scoped(() =>
|
|
3856
|
+
return this._scoped(() => _chunkGEUBNZ3Bcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3860
3857
|
}
|
|
3861
3858
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3862
3859
|
async _run_close(targets) {
|
|
@@ -3910,7 +3907,7 @@ var Act = (_class7 = class {
|
|
|
3910
3907
|
* sets `autoSettle: false`. Call it at startup, to run what was pending
|
|
3911
3908
|
* before a restart, or with options for the next pass; the scheduling
|
|
3912
3909
|
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain in a loop until a pass makes no
|
|
3913
|
-
* progress —
|
|
3910
|
+
* progress — it read no events and leased no streams —
|
|
3914
3911
|
* then emits the `"settled"` lifecycle event, so one call fully catches
|
|
3915
3912
|
* up paginated streams without forcing callers to loop.
|
|
3916
3913
|
*
|
|
@@ -3936,7 +3933,7 @@ var Act = (_class7 = class {
|
|
|
3936
3933
|
* @see {@link correlate} for manual correlation
|
|
3937
3934
|
*/
|
|
3938
3935
|
settle(options) {
|
|
3939
|
-
|
|
3936
|
+
_chunkGEUBNZ3Bcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3940
3937
|
this._schedule(options);
|
|
3941
3938
|
}
|
|
3942
3939
|
}, _class7);
|
|
@@ -4092,16 +4089,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4092
4089
|
}),
|
|
4093
4090
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4094
4091
|
// not quarantine the synthetic stream.
|
|
4095
|
-
options: { blockOnError: false, maxRetries:
|
|
4092
|
+
options: { blockOnError: false, maxRetries: _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES },
|
|
4096
4093
|
handler: async (event) => {
|
|
4097
4094
|
const aggregate = event.stream;
|
|
4098
4095
|
const window = read_window();
|
|
4099
4096
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4100
|
-
throw new (0,
|
|
4101
|
-
const stats = await
|
|
4097
|
+
throw new (0, _chunkDVYTKZD5cjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4098
|
+
const stats = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4102
4099
|
count: true,
|
|
4103
4100
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4104
|
-
exclude: [
|
|
4101
|
+
exclude: [_chunkDVYTKZD5cjs.TOMBSTONE_EVENT, _chunkDVYTKZD5cjs.SNAP_EVENT]
|
|
4105
4102
|
});
|
|
4106
4103
|
const entry = stats.get(aggregate);
|
|
4107
4104
|
if (!entry) return;
|
|
@@ -4132,7 +4129,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4132
4129
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4133
4130
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4134
4131
|
if (future.length)
|
|
4135
|
-
throw new (0,
|
|
4132
|
+
throw new (0, _chunkDVYTKZD5cjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4136
4133
|
}
|
|
4137
4134
|
};
|
|
4138
4135
|
const key = `__autoclose_${st.name}`;
|
|
@@ -4336,9 +4333,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4336
4333
|
|
|
4337
4334
|
// src/builders/builder-utils.ts
|
|
4338
4335
|
function register_lane(config2, lanes) {
|
|
4339
|
-
|
|
4340
|
-
if (config2.name ===
|
|
4341
|
-
throw new Error(`Lane "${
|
|
4336
|
+
_chunkGEUBNZ3Bcjs.resolveLaneConfig.call(void 0, config2);
|
|
4337
|
+
if (config2.name === _chunkDVYTKZD5cjs.DEFAULT_LANE)
|
|
4338
|
+
throw new Error(`Lane "${_chunkDVYTKZD5cjs.DEFAULT_LANE}" is reserved`);
|
|
4342
4339
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4343
4340
|
if (!existing) return void lanes.push(config2);
|
|
4344
4341
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4380,9 +4377,9 @@ function reaction_on(event, events, builder) {
|
|
|
4380
4377
|
// Validate the whole bag at the declaration site so a bad
|
|
4381
4378
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4382
4379
|
// not a NaN gate on the first retry.
|
|
4383
|
-
options:
|
|
4384
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => (
|
|
4385
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => (
|
|
4380
|
+
options: _chunkGEUBNZ3Bcjs.resolveReactionConfig.call(void 0, {
|
|
4381
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4382
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES)),
|
|
4386
4383
|
backoff: _optionalChain([options, 'optionalAccess', _153 => _153.backoff])
|
|
4387
4384
|
})
|
|
4388
4385
|
};
|
|
@@ -4467,7 +4464,7 @@ function date_reviver_schema(schema) {
|
|
|
4467
4464
|
|
|
4468
4465
|
// src/builders/event-builder.ts
|
|
4469
4466
|
function event_tags(schema) {
|
|
4470
|
-
const pii =
|
|
4467
|
+
const pii = _chunkDVYTKZD5cjs.pii_schemas.call(void 0, schema);
|
|
4471
4468
|
const pii_dates = {};
|
|
4472
4469
|
for (const [key, field] of Object.entries(pii)) {
|
|
4473
4470
|
const dates = date_reviver_schema(field);
|
|
@@ -4504,7 +4501,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4504
4501
|
});
|
|
4505
4502
|
}
|
|
4506
4503
|
function build_events(registry, states, lanes, owners) {
|
|
4507
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4504
|
+
const declared = /* @__PURE__ */ new Set([_chunkDVYTKZD5cjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4508
4505
|
const lane_errors = [];
|
|
4509
4506
|
const tags = /* @__PURE__ */ new Map();
|
|
4510
4507
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4568,7 +4565,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4568
4565
|
if (reader) readers.set(event_name, reader);
|
|
4569
4566
|
}
|
|
4570
4567
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4571
|
-
if (snap2) readers.set(
|
|
4568
|
+
if (snap2) readers.set(_chunkDVYTKZD5cjs.SNAP_EVENT, snap2);
|
|
4572
4569
|
if (readers.size === 0) continue;
|
|
4573
4570
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4574
4571
|
}
|
|
@@ -4684,7 +4681,7 @@ function act() {
|
|
|
4684
4681
|
const list = deprecation_summary.map(
|
|
4685
4682
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4686
4683
|
).join(", ");
|
|
4687
|
-
|
|
4684
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).info(
|
|
4688
4685
|
`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.`
|
|
4689
4686
|
);
|
|
4690
4687
|
}
|
|
@@ -4726,7 +4723,7 @@ function act() {
|
|
|
4726
4723
|
return reaction_on(event, registry.events, builder);
|
|
4727
4724
|
},
|
|
4728
4725
|
build: (options) => {
|
|
4729
|
-
|
|
4726
|
+
_chunkGEUBNZ3Bcjs.resolveActConfig.call(void 0, options);
|
|
4730
4727
|
const patch_fn = _optionalChain([options, 'optionalAccess', _165 => _165.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4731
4728
|
if (!_built) {
|
|
4732
4729
|
for (const proj of pending_projections) add_projection(proj);
|
|
@@ -4778,7 +4775,7 @@ function act() {
|
|
|
4778
4775
|
synthesize_autoclose_reactions(
|
|
4779
4776
|
registry,
|
|
4780
4777
|
states,
|
|
4781
|
-
|
|
4778
|
+
_chunkGEUBNZ3Bcjs.current_autoclose_window
|
|
4782
4779
|
);
|
|
4783
4780
|
Object.freeze(registry.actions);
|
|
4784
4781
|
Object.freeze(registry.events);
|
|
@@ -4827,8 +4824,8 @@ function _projection(target) {
|
|
|
4827
4824
|
handler,
|
|
4828
4825
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4829
4826
|
options: {
|
|
4830
|
-
blockOnError:
|
|
4831
|
-
maxRetries:
|
|
4827
|
+
blockOnError: _chunkGEUBNZ3Bcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4828
|
+
maxRetries: _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES
|
|
4832
4829
|
}
|
|
4833
4830
|
}),
|
|
4834
4831
|
widened
|
|
@@ -4869,7 +4866,7 @@ function _projection(target) {
|
|
|
4869
4866
|
throw new Error(
|
|
4870
4867
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4871
4868
|
);
|
|
4872
|
-
const config2 =
|
|
4869
|
+
const config2 = _chunkGEUBNZ3Bcjs.resolveFoldConfig.call(void 0, options);
|
|
4873
4870
|
const fold_events = {};
|
|
4874
4871
|
for (const partial of partials)
|
|
4875
4872
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4887,8 +4884,8 @@ function _projection(target) {
|
|
|
4887
4884
|
handler: noop,
|
|
4888
4885
|
resolver: { target },
|
|
4889
4886
|
options: {
|
|
4890
|
-
blockOnError:
|
|
4891
|
-
maxRetries:
|
|
4887
|
+
blockOnError: _chunkGEUBNZ3Bcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4888
|
+
maxRetries: _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES
|
|
4892
4889
|
}
|
|
4893
4890
|
}
|
|
4894
4891
|
]
|
|
@@ -5004,7 +5001,7 @@ function action_builder(state2) {
|
|
|
5004
5001
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5005
5002
|
internal.actions[action2] = schema;
|
|
5006
5003
|
if (options) {
|
|
5007
|
-
|
|
5004
|
+
_chunkGEUBNZ3Bcjs.resolveActionConfig.call(void 0, options);
|
|
5008
5005
|
internal.options ??= {};
|
|
5009
5006
|
internal.options[action2] = options;
|
|
5010
5007
|
}
|
|
@@ -5293,5 +5290,5 @@ function write_line(writer, line) {
|
|
|
5293
5290
|
|
|
5294
5291
|
|
|
5295
5292
|
|
|
5296
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5293
|
+
exports.Act = Act; exports.ActorSchema = _chunkDVYTKZD5cjs.ActorSchema; exports.CausationEventSchema = _chunkDVYTKZD5cjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkDVYTKZD5cjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkDVYTKZD5cjs.ConcurrencyError; exports.ConsoleLogger = _chunkGEUBNZ3Bcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkDVYTKZD5cjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkDVYTKZD5cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkDVYTKZD5cjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkDVYTKZD5cjs.DeferSignal; exports.Environments = _chunkDVYTKZD5cjs.Environments; exports.Errors = _chunkDVYTKZD5cjs.Errors; exports.EventMetaSchema = _chunkDVYTKZD5cjs.EventMetaSchema; exports.ExitCodes = _chunkDVYTKZD5cjs.ExitCodes; exports.InMemoryCache = _chunkGEUBNZ3Bcjs.InMemoryCache; exports.InMemoryStore = _chunkGEUBNZ3Bcjs.InMemoryStore; exports.InvariantError = _chunkDVYTKZD5cjs.InvariantError; exports.LogLevels = _chunkDVYTKZD5cjs.LogLevels; exports.NonRetryableError = _chunkDVYTKZD5cjs.NonRetryableError; exports.PackageSchema = _chunkGEUBNZ3Bcjs.PackageSchema; exports.QuerySchema = _chunkDVYTKZD5cjs.QuerySchema; exports.REDACTED = _chunkDVYTKZD5cjs.REDACTED; exports.SHREDDED = _chunkDVYTKZD5cjs.SHREDDED; exports.SNAP_EVENT = _chunkDVYTKZD5cjs.SNAP_EVENT; exports.StoreError = _chunkDVYTKZD5cjs.StoreError; exports.StreamClosedError = _chunkDVYTKZD5cjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkDVYTKZD5cjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkDVYTKZD5cjs.TargetSchema; exports.ValidationError = _chunkDVYTKZD5cjs.ValidationError; exports.ZodEmpty = _chunkDVYTKZD5cjs.ZodEmpty; exports.act = act; exports.cache = _chunkGEUBNZ3Bcjs.cache; exports.config = _chunkGEUBNZ3Bcjs.config; exports.dateReviver = _chunkGEUBNZ3Bcjs.dateReviver; exports.default_scope = _chunkGEUBNZ3Bcjs.default_scope; exports.dispose = _chunkGEUBNZ3Bcjs.dispose; exports.disposeAndExit = _chunkGEUBNZ3Bcjs.disposeAndExit; exports.extend = _chunkGEUBNZ3Bcjs.extend; exports.is_literal_source = _chunkGEUBNZ3Bcjs.is_literal_source; exports.log = _chunkGEUBNZ3Bcjs.log; exports.pii_fields = _chunkDVYTKZD5cjs.pii_fields; exports.port = _chunkGEUBNZ3Bcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkGEUBNZ3Bcjs.resolveAutocloseConfig2; exports.sensitive = _chunkDVYTKZD5cjs.sensitive; exports.sleep = _chunkGEUBNZ3Bcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkGEUBNZ3Bcjs.store; exports.validate = _chunkGEUBNZ3Bcjs.validate;
|
|
5297
5294
|
//# sourceMappingURL=index.cjs.map
|