@rotorsoft/act 1.33.18 → 1.33.20
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 +4 -4
- package/dist/@types/config.d.ts +2 -2
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +2 -3
- 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 +4 -4
- package/dist/@types/utils.d.ts +5 -9
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/{chunk-3OTABSIB.js → chunk-5Z53Y7SG.js} +2 -2
- package/dist/chunk-5Z53Y7SG.js.map +1 -0
- package/dist/{chunk-N7K4FQEM.cjs → chunk-DVYTKZD5.cjs} +1 -1
- package/dist/{chunk-N7K4FQEM.cjs.map → chunk-DVYTKZD5.cjs.map} +1 -1
- package/dist/{chunk-OYR5RIFE.cjs → chunk-GEUBNZ3B.cjs} +13 -13
- package/dist/chunk-GEUBNZ3B.cjs.map +1 -0
- package/dist/{chunk-SD7SW47Z.js → chunk-HEHGZHHA.js} +1 -1
- package/dist/{chunk-SD7SW47Z.js.map → chunk-HEHGZHHA.js.map} +1 -1
- package/dist/index.cjs +154 -158
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -19
- 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-3OTABSIB.js.map +0 -1
- package/dist/chunk-OYR5RIFE.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 _chunkOYR5RIFEcjs = require('./chunk-OYR5RIFE.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);
|
|
@@ -1300,7 +1299,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
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,
|
|
@@ -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) => _chunkOYR5RIFEcjs.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,
|
|
@@ -2345,18 +2343,17 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2345
2343
|
return handle({ ...lease, at }, payloads);
|
|
2346
2344
|
})
|
|
2347
2345
|
);
|
|
2348
|
-
const
|
|
2349
|
-
|
|
2350
|
-
);
|
|
2346
|
+
const to_block = handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }));
|
|
2347
|
+
const blocked = to_block.length ? await ops.block(to_block) : [];
|
|
2351
2348
|
if (blocked.length) deps.on_blocked(blocked);
|
|
2352
2349
|
const submitted = handled.flatMap((h, i) => {
|
|
2353
2350
|
const advance = h.handled > 0 ? h.acked_at : leased[i].at;
|
|
2354
2351
|
return h.defer !== void 0 ? { ...h.lease, at: advance, due: h.defer, retry: -1 } : h.next_attempt_at !== void 0 ? { ...h.lease, at: advance, due: h.next_attempt_at } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : [];
|
|
2355
2352
|
});
|
|
2356
|
-
const acked = await ops.ack(submitted);
|
|
2353
|
+
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2357
2354
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2358
2355
|
if (acked.length < expected)
|
|
2359
|
-
|
|
2356
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).warn(
|
|
2360
2357
|
`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
2358
|
);
|
|
2362
2359
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2456,9 +2453,9 @@ var DrainController = (_class5 = class {
|
|
|
2456
2453
|
if (!this.armed || this._stopped || this._inflight)
|
|
2457
2454
|
return EMPTY_DRAIN;
|
|
2458
2455
|
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)), () => (
|
|
2456
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_STREAM_LIMIT));
|
|
2457
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkGEUBNZ3Bcjs.DEFAULT_EVENT_LIMIT));
|
|
2458
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_LEASE_MILLIS));
|
|
2462
2459
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2463
2460
|
return EMPTY_DRAIN;
|
|
2464
2461
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2533,7 +2530,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2533
2530
|
const { pii, ...rest } = event;
|
|
2534
2531
|
if (pii == null) {
|
|
2535
2532
|
const shredded = { ...data };
|
|
2536
|
-
for (const f of fields) shredded[f] =
|
|
2533
|
+
for (const f of fields) shredded[f] = _chunkDVYTKZD5cjs.SHREDDED;
|
|
2537
2534
|
return { ...rest, data: shredded };
|
|
2538
2535
|
}
|
|
2539
2536
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2544,7 +2541,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2544
2541
|
};
|
|
2545
2542
|
}
|
|
2546
2543
|
const redacted = { ...data };
|
|
2547
|
-
for (const f of fields) redacted[f] =
|
|
2544
|
+
for (const f of fields) redacted[f] = _chunkDVYTKZD5cjs.REDACTED;
|
|
2548
2545
|
return { ...rest, data: redacted };
|
|
2549
2546
|
}
|
|
2550
2547
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2681,7 +2678,7 @@ function make_deferred(handler, schedule) {
|
|
|
2681
2678
|
const call = handler;
|
|
2682
2679
|
const deferred = async (event, stream, app) => {
|
|
2683
2680
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2684
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2681
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkDVYTKZD5cjs.DeferSignal)(when);
|
|
2685
2682
|
return call(event, stream, app);
|
|
2686
2683
|
};
|
|
2687
2684
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2750,7 +2747,7 @@ function build_handle(deps) {
|
|
|
2750
2747
|
handled++;
|
|
2751
2748
|
}
|
|
2752
2749
|
} catch (error) {
|
|
2753
|
-
if (error instanceof
|
|
2750
|
+
if (error instanceof _chunkDVYTKZD5cjs.DeferSignal) {
|
|
2754
2751
|
let defer;
|
|
2755
2752
|
try {
|
|
2756
2753
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2856,9 +2853,8 @@ var SettleLoop = (_class6 = class {
|
|
|
2856
2853
|
* `debounceMs` brings it forward), and a call during a running cycle
|
|
2857
2854
|
* queues one more pass after it. Callers pass options, which the next
|
|
2858
2855
|
* pass uses; internal wake-ups pass none, so they never discard a
|
|
2859
|
-
* caller's. The cycle runs correlate→drain
|
|
2860
|
-
*
|
|
2861
|
-
* no streams leased) or `maxPasses` is reached, then emits the
|
|
2856
|
+
* caller's. The cycle runs correlate→drain passes until one makes no
|
|
2857
|
+
* progress (see {@link SettleOptions.maxPasses}), then emits the
|
|
2862
2858
|
* `"settled"` lifecycle event via {@link SettleDeps.on_settled}.
|
|
2863
2859
|
*/
|
|
2864
2860
|
schedule(options) {
|
|
@@ -3017,7 +3013,7 @@ var Act = (_class7 = class {
|
|
|
3017
3013
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
3018
3014
|
|
|
3019
3015
|
|
|
3020
|
-
__init27() {this._logger =
|
|
3016
|
+
__init27() {this._logger = _chunkGEUBNZ3Bcjs.log.call(void 0, )}
|
|
3021
3017
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3022
3018
|
|
|
3023
3019
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3039,9 +3035,9 @@ var Act = (_class7 = class {
|
|
|
3039
3035
|
this._lanes = lanes;
|
|
3040
3036
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3041
3037
|
validate_only_lanes(options, lanes);
|
|
3042
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3038
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkGEUBNZ3Bcjs.default_scope.call(void 0, )));
|
|
3043
3039
|
const ports = this._ports;
|
|
3044
|
-
this._scoped =
|
|
3040
|
+
this._scoped = _chunkGEUBNZ3Bcjs.make_run_scoped.call(void 0, {
|
|
3045
3041
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3046
3042
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3047
3043
|
get store() {
|
|
@@ -3051,14 +3047,14 @@ var Act = (_class7 = class {
|
|
|
3051
3047
|
return ports.cache;
|
|
3052
3048
|
},
|
|
3053
3049
|
// Parsed per build, so a bad window throws on every build.
|
|
3054
|
-
autoclose_window:
|
|
3050
|
+
autoclose_window: _chunkGEUBNZ3Bcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3055
3051
|
});
|
|
3056
3052
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3057
3053
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3058
3054
|
this._cd = build_drain(this._logger);
|
|
3059
3055
|
const handle = build_handle({
|
|
3060
3056
|
logger: this._logger,
|
|
3061
|
-
reaction_scope:
|
|
3057
|
+
reaction_scope: _chunkGEUBNZ3Bcjs.make_reaction_scope.call(void 0, {
|
|
3062
3058
|
do: this.do.bind(this),
|
|
3063
3059
|
load: this.load.bind(this),
|
|
3064
3060
|
query: this.query.bind(this),
|
|
@@ -3088,12 +3084,12 @@ var Act = (_class7 = class {
|
|
|
3088
3084
|
this._ports.store,
|
|
3089
3085
|
options.listen !== false
|
|
3090
3086
|
);
|
|
3091
|
-
|
|
3087
|
+
_chunkGEUBNZ3Bcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3092
3088
|
}
|
|
3093
3089
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3094
3090
|
_build_breaker(options) {
|
|
3095
3091
|
return new CircuitBreaker(
|
|
3096
|
-
|
|
3092
|
+
_chunkGEUBNZ3Bcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3097
3093
|
{
|
|
3098
3094
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3099
3095
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3127,7 +3123,7 @@ var Act = (_class7 = class {
|
|
|
3127
3123
|
try {
|
|
3128
3124
|
await this._run_close(targets);
|
|
3129
3125
|
} catch (error) {
|
|
3130
|
-
if (error instanceof
|
|
3126
|
+
if (error instanceof _chunkDVYTKZD5cjs.StoreError) throw error;
|
|
3131
3127
|
this._logger.error(
|
|
3132
3128
|
error,
|
|
3133
3129
|
`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.`
|
|
@@ -3162,7 +3158,7 @@ var Act = (_class7 = class {
|
|
|
3162
3158
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3163
3159
|
_build_audit_deps() {
|
|
3164
3160
|
return {
|
|
3165
|
-
store:
|
|
3161
|
+
store: _chunkGEUBNZ3Bcjs.store,
|
|
3166
3162
|
event_to_state: this._event_to_state,
|
|
3167
3163
|
// Declared lanes, not this process's controllers: a lane another
|
|
3168
3164
|
// worker drains is not `unknown-lane`.
|
|
@@ -3175,7 +3171,7 @@ var Act = (_class7 = class {
|
|
|
3175
3171
|
registry: this.registry,
|
|
3176
3172
|
static_targets: classification.static_targets,
|
|
3177
3173
|
cd: this._cd,
|
|
3178
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3174
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkDVYTKZD5cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3179
3175
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3180
3176
|
// still a valid destination.
|
|
3181
3177
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3191,7 +3187,7 @@ var Act = (_class7 = class {
|
|
|
3191
3187
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3192
3188
|
async _seed_persisted_defers() {
|
|
3193
3189
|
const now = Date.now();
|
|
3194
|
-
await walk_streams(
|
|
3190
|
+
await walk_streams(_chunkGEUBNZ3Bcjs.store.call(void 0, ), (pos) => {
|
|
3195
3191
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3196
3192
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3197
3193
|
_optionalChain([controller, 'optionalAccess', _124 => _124.seed_defer, 'call', _125 => _125(pos.stream, pos.deferred_at)]);
|
|
@@ -3210,7 +3206,7 @@ var Act = (_class7 = class {
|
|
|
3210
3206
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3211
3207
|
breaker: this._breaker
|
|
3212
3208
|
},
|
|
3213
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3209
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkDVYTKZD5cjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3214
3210
|
);
|
|
3215
3211
|
}
|
|
3216
3212
|
|
|
@@ -3230,7 +3226,7 @@ var Act = (_class7 = class {
|
|
|
3230
3226
|
*/
|
|
3231
3227
|
shutdown(options) {
|
|
3232
3228
|
if (!this._shutdown_promise) {
|
|
3233
|
-
|
|
3229
|
+
_chunkGEUBNZ3Bcjs.resolveShutdownConfig.call(void 0, options);
|
|
3234
3230
|
this._shutdown_promise = (async () => {
|
|
3235
3231
|
this.stop_correlations();
|
|
3236
3232
|
this._settle.stop(true);
|
|
@@ -3250,10 +3246,10 @@ var Act = (_class7 = class {
|
|
|
3250
3246
|
* default for none or 0, and for a running settle), capped.
|
|
3251
3247
|
*/
|
|
3252
3248
|
_derive_grace_ms(running, settling) {
|
|
3253
|
-
let max = settling ?
|
|
3249
|
+
let max = settling ? _chunkGEUBNZ3Bcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3254
3250
|
for (const c of running)
|
|
3255
|
-
max = Math.max(max, c.lease_millis ||
|
|
3256
|
-
return Math.min(max,
|
|
3251
|
+
max = Math.max(max, c.lease_millis || _chunkGEUBNZ3Bcjs.DEFAULT_LEASE_MILLIS);
|
|
3252
|
+
return Math.min(max, _chunkGEUBNZ3Bcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3257
3253
|
}
|
|
3258
3254
|
async _await_inflight(grace_ms) {
|
|
3259
3255
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3334,7 +3330,7 @@ var Act = (_class7 = class {
|
|
|
3334
3330
|
* @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
|
|
3335
3331
|
*/
|
|
3336
3332
|
async do(action2, target, payload, options) {
|
|
3337
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => (
|
|
3333
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => ( _chunkGEUBNZ3Bcjs.current_reacting.call(void 0, )));
|
|
3338
3334
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _128 => _128.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3339
3335
|
return this._scoped(async () => {
|
|
3340
3336
|
const snapshots = await this._es.action(
|
|
@@ -3395,7 +3391,7 @@ var Act = (_class7 = class {
|
|
|
3395
3391
|
return this._scoped(async () => {
|
|
3396
3392
|
let first;
|
|
3397
3393
|
let last;
|
|
3398
|
-
const count = await
|
|
3394
|
+
const count = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query((e) => {
|
|
3399
3395
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3400
3396
|
if (!first) first = gated;
|
|
3401
3397
|
last = gated;
|
|
@@ -3425,7 +3421,7 @@ var Act = (_class7 = class {
|
|
|
3425
3421
|
async query_array(query) {
|
|
3426
3422
|
return this._scoped(async () => {
|
|
3427
3423
|
const events = [];
|
|
3428
|
-
await
|
|
3424
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query((e) => {
|
|
3429
3425
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3430
3426
|
}, query);
|
|
3431
3427
|
return events;
|
|
@@ -3445,14 +3441,14 @@ var Act = (_class7 = class {
|
|
|
3445
3441
|
*/
|
|
3446
3442
|
async forget(stream) {
|
|
3447
3443
|
return this._scoped(async () => {
|
|
3448
|
-
const s =
|
|
3444
|
+
const s = _chunkGEUBNZ3Bcjs.store.call(void 0, );
|
|
3449
3445
|
if (!s.forget_pii) {
|
|
3450
3446
|
throw new Error(
|
|
3451
3447
|
`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).`
|
|
3452
3448
|
);
|
|
3453
3449
|
}
|
|
3454
3450
|
const eventCount = await s.forget_pii(stream);
|
|
3455
|
-
await
|
|
3451
|
+
await _chunkGEUBNZ3Bcjs.cache.call(void 0, ).invalidate(stream);
|
|
3456
3452
|
if (eventCount > 0) {
|
|
3457
3453
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3458
3454
|
}
|
|
@@ -3486,7 +3482,7 @@ var Act = (_class7 = class {
|
|
|
3486
3482
|
* @see {@link correlate} for dynamic stream discovery
|
|
3487
3483
|
*/
|
|
3488
3484
|
async drain(options = {}) {
|
|
3489
|
-
|
|
3485
|
+
_chunkGEUBNZ3Bcjs.resolveDrainConfig.call(void 0, options);
|
|
3490
3486
|
if (!this._drain)
|
|
3491
3487
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3492
3488
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3666,7 +3662,7 @@ var Act = (_class7 = class {
|
|
|
3666
3662
|
*/
|
|
3667
3663
|
async reset(input) {
|
|
3668
3664
|
return this._scoped(async () => {
|
|
3669
|
-
const count = await
|
|
3665
|
+
const count = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).reset(input);
|
|
3670
3666
|
for (const handler of this._batch_handlers.values())
|
|
3671
3667
|
_optionalChain([handler, 'access', _135 => _135[FOLD_RESET], 'optionalCall', _136 => _136()]);
|
|
3672
3668
|
if (count > 0) {
|
|
@@ -3702,7 +3698,7 @@ var Act = (_class7 = class {
|
|
|
3702
3698
|
*/
|
|
3703
3699
|
async unblock(input) {
|
|
3704
3700
|
return this._scoped(async () => {
|
|
3705
|
-
const count = await
|
|
3701
|
+
const count = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).unblock(input);
|
|
3706
3702
|
if (count > 0) {
|
|
3707
3703
|
this._wake();
|
|
3708
3704
|
}
|
|
@@ -3737,8 +3733,8 @@ var Act = (_class7 = class {
|
|
|
3737
3733
|
* `__snapshot__` events (counted in the result); `on_progress`
|
|
3738
3734
|
* fires once per event.
|
|
3739
3735
|
* @param sink - Where the events land. Defaults to this Act's store.
|
|
3740
|
-
* @returns {@link ScanResult}
|
|
3741
|
-
*
|
|
3736
|
+
* @returns The {@link ScanResult}: what was kept, migrated and dropped,
|
|
3737
|
+
* and how long it took.
|
|
3742
3738
|
*
|
|
3743
3739
|
* @example Restore a CSV backup into the connected store
|
|
3744
3740
|
* ```typescript
|
|
@@ -3757,7 +3753,7 @@ var Act = (_class7 = class {
|
|
|
3757
3753
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3758
3754
|
}
|
|
3759
3755
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3760
|
-
const s =
|
|
3756
|
+
const s = _chunkGEUBNZ3Bcjs.store.call(void 0, );
|
|
3761
3757
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3762
3758
|
return s;
|
|
3763
3759
|
})()));
|
|
@@ -3803,7 +3799,7 @@ var Act = (_class7 = class {
|
|
|
3803
3799
|
async blocked_streams(options) {
|
|
3804
3800
|
return this._scoped(async () => {
|
|
3805
3801
|
const positions = [];
|
|
3806
|
-
await
|
|
3802
|
+
await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_streams(
|
|
3807
3803
|
(p) => {
|
|
3808
3804
|
positions.push(p);
|
|
3809
3805
|
},
|
|
@@ -3855,7 +3851,7 @@ var Act = (_class7 = class {
|
|
|
3855
3851
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3856
3852
|
*/
|
|
3857
3853
|
async prioritize(filter, priority) {
|
|
3858
|
-
return this._scoped(() =>
|
|
3854
|
+
return this._scoped(() => _chunkGEUBNZ3Bcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3859
3855
|
}
|
|
3860
3856
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3861
3857
|
async _run_close(targets) {
|
|
@@ -3908,8 +3904,8 @@ var Act = (_class7 = class {
|
|
|
3908
3904
|
* `unblock()`, `restore()`) schedules this on its own unless the app
|
|
3909
3905
|
* sets `autoSettle: false`. Call it at startup, to run what was pending
|
|
3910
3906
|
* before a restart, or with options for the next pass; the scheduling
|
|
3911
|
-
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain
|
|
3912
|
-
*
|
|
3907
|
+
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain
|
|
3908
|
+
* passes until one makes no progress (see {@link SettleOptions.maxPasses}),
|
|
3913
3909
|
* then emits the `"settled"` lifecycle event, so one call fully catches
|
|
3914
3910
|
* up paginated streams without forcing callers to loop.
|
|
3915
3911
|
*
|
|
@@ -3935,7 +3931,7 @@ var Act = (_class7 = class {
|
|
|
3935
3931
|
* @see {@link correlate} for manual correlation
|
|
3936
3932
|
*/
|
|
3937
3933
|
settle(options) {
|
|
3938
|
-
|
|
3934
|
+
_chunkGEUBNZ3Bcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3939
3935
|
this._schedule(options);
|
|
3940
3936
|
}
|
|
3941
3937
|
}, _class7);
|
|
@@ -4091,16 +4087,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4091
4087
|
}),
|
|
4092
4088
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4093
4089
|
// not quarantine the synthetic stream.
|
|
4094
|
-
options: { blockOnError: false, maxRetries:
|
|
4090
|
+
options: { blockOnError: false, maxRetries: _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES },
|
|
4095
4091
|
handler: async (event) => {
|
|
4096
4092
|
const aggregate = event.stream;
|
|
4097
4093
|
const window = read_window();
|
|
4098
4094
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4099
|
-
throw new (0,
|
|
4100
|
-
const stats = await
|
|
4095
|
+
throw new (0, _chunkDVYTKZD5cjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4096
|
+
const stats = await _chunkGEUBNZ3Bcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4101
4097
|
count: true,
|
|
4102
4098
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4103
|
-
exclude: [
|
|
4099
|
+
exclude: [_chunkDVYTKZD5cjs.TOMBSTONE_EVENT, _chunkDVYTKZD5cjs.SNAP_EVENT]
|
|
4104
4100
|
});
|
|
4105
4101
|
const entry = stats.get(aggregate);
|
|
4106
4102
|
if (!entry) return;
|
|
@@ -4131,7 +4127,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4131
4127
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4132
4128
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4133
4129
|
if (future.length)
|
|
4134
|
-
throw new (0,
|
|
4130
|
+
throw new (0, _chunkDVYTKZD5cjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4135
4131
|
}
|
|
4136
4132
|
};
|
|
4137
4133
|
const key = `__autoclose_${st.name}`;
|
|
@@ -4335,9 +4331,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4335
4331
|
|
|
4336
4332
|
// src/builders/builder-utils.ts
|
|
4337
4333
|
function register_lane(config2, lanes) {
|
|
4338
|
-
|
|
4339
|
-
if (config2.name ===
|
|
4340
|
-
throw new Error(`Lane "${
|
|
4334
|
+
_chunkGEUBNZ3Bcjs.resolveLaneConfig.call(void 0, config2);
|
|
4335
|
+
if (config2.name === _chunkDVYTKZD5cjs.DEFAULT_LANE)
|
|
4336
|
+
throw new Error(`Lane "${_chunkDVYTKZD5cjs.DEFAULT_LANE}" is reserved`);
|
|
4341
4337
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4342
4338
|
if (!existing) return void lanes.push(config2);
|
|
4343
4339
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4379,9 +4375,9 @@ function reaction_on(event, events, builder) {
|
|
|
4379
4375
|
// Validate the whole bag at the declaration site so a bad
|
|
4380
4376
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4381
4377
|
// not a NaN gate on the first retry.
|
|
4382
|
-
options:
|
|
4383
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => (
|
|
4384
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => (
|
|
4378
|
+
options: _chunkGEUBNZ3Bcjs.resolveReactionConfig.call(void 0, {
|
|
4379
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4380
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => ( _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES)),
|
|
4385
4381
|
backoff: _optionalChain([options, 'optionalAccess', _153 => _153.backoff])
|
|
4386
4382
|
})
|
|
4387
4383
|
};
|
|
@@ -4466,7 +4462,7 @@ function date_reviver_schema(schema) {
|
|
|
4466
4462
|
|
|
4467
4463
|
// src/builders/event-builder.ts
|
|
4468
4464
|
function event_tags(schema) {
|
|
4469
|
-
const pii =
|
|
4465
|
+
const pii = _chunkDVYTKZD5cjs.pii_schemas.call(void 0, schema);
|
|
4470
4466
|
const pii_dates = {};
|
|
4471
4467
|
for (const [key, field] of Object.entries(pii)) {
|
|
4472
4468
|
const dates = date_reviver_schema(field);
|
|
@@ -4503,7 +4499,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4503
4499
|
});
|
|
4504
4500
|
}
|
|
4505
4501
|
function build_events(registry, states, lanes, owners) {
|
|
4506
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4502
|
+
const declared = /* @__PURE__ */ new Set([_chunkDVYTKZD5cjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4507
4503
|
const lane_errors = [];
|
|
4508
4504
|
const tags = /* @__PURE__ */ new Map();
|
|
4509
4505
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4567,7 +4563,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4567
4563
|
if (reader) readers.set(event_name, reader);
|
|
4568
4564
|
}
|
|
4569
4565
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4570
|
-
if (snap2) readers.set(
|
|
4566
|
+
if (snap2) readers.set(_chunkDVYTKZD5cjs.SNAP_EVENT, snap2);
|
|
4571
4567
|
if (readers.size === 0) continue;
|
|
4572
4568
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4573
4569
|
}
|
|
@@ -4683,7 +4679,7 @@ function act() {
|
|
|
4683
4679
|
const list = deprecation_summary.map(
|
|
4684
4680
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4685
4681
|
).join(", ");
|
|
4686
|
-
|
|
4682
|
+
_chunkGEUBNZ3Bcjs.log.call(void 0, ).info(
|
|
4687
4683
|
`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.`
|
|
4688
4684
|
);
|
|
4689
4685
|
}
|
|
@@ -4725,7 +4721,7 @@ function act() {
|
|
|
4725
4721
|
return reaction_on(event, registry.events, builder);
|
|
4726
4722
|
},
|
|
4727
4723
|
build: (options) => {
|
|
4728
|
-
|
|
4724
|
+
_chunkGEUBNZ3Bcjs.resolveActConfig.call(void 0, options);
|
|
4729
4725
|
const patch_fn = _optionalChain([options, 'optionalAccess', _165 => _165.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4730
4726
|
if (!_built) {
|
|
4731
4727
|
for (const proj of pending_projections) add_projection(proj);
|
|
@@ -4777,7 +4773,7 @@ function act() {
|
|
|
4777
4773
|
synthesize_autoclose_reactions(
|
|
4778
4774
|
registry,
|
|
4779
4775
|
states,
|
|
4780
|
-
|
|
4776
|
+
_chunkGEUBNZ3Bcjs.current_autoclose_window
|
|
4781
4777
|
);
|
|
4782
4778
|
Object.freeze(registry.actions);
|
|
4783
4779
|
Object.freeze(registry.events);
|
|
@@ -4826,8 +4822,8 @@ function _projection(target) {
|
|
|
4826
4822
|
handler,
|
|
4827
4823
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4828
4824
|
options: {
|
|
4829
|
-
blockOnError:
|
|
4830
|
-
maxRetries:
|
|
4825
|
+
blockOnError: _chunkGEUBNZ3Bcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4826
|
+
maxRetries: _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES
|
|
4831
4827
|
}
|
|
4832
4828
|
}),
|
|
4833
4829
|
widened
|
|
@@ -4868,7 +4864,7 @@ function _projection(target) {
|
|
|
4868
4864
|
throw new Error(
|
|
4869
4865
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4870
4866
|
);
|
|
4871
|
-
const config2 =
|
|
4867
|
+
const config2 = _chunkGEUBNZ3Bcjs.resolveFoldConfig.call(void 0, options);
|
|
4872
4868
|
const fold_events = {};
|
|
4873
4869
|
for (const partial of partials)
|
|
4874
4870
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4886,8 +4882,8 @@ function _projection(target) {
|
|
|
4886
4882
|
handler: noop,
|
|
4887
4883
|
resolver: { target },
|
|
4888
4884
|
options: {
|
|
4889
|
-
blockOnError:
|
|
4890
|
-
maxRetries:
|
|
4885
|
+
blockOnError: _chunkGEUBNZ3Bcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4886
|
+
maxRetries: _chunkGEUBNZ3Bcjs.DEFAULT_MAX_RETRIES
|
|
4891
4887
|
}
|
|
4892
4888
|
}
|
|
4893
4889
|
]
|
|
@@ -5003,7 +4999,7 @@ function action_builder(state2) {
|
|
|
5003
4999
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5004
5000
|
internal.actions[action2] = schema;
|
|
5005
5001
|
if (options) {
|
|
5006
|
-
|
|
5002
|
+
_chunkGEUBNZ3Bcjs.resolveActionConfig.call(void 0, options);
|
|
5007
5003
|
internal.options ??= {};
|
|
5008
5004
|
internal.options[action2] = options;
|
|
5009
5005
|
}
|
|
@@ -5292,5 +5288,5 @@ function write_line(writer, line) {
|
|
|
5292
5288
|
|
|
5293
5289
|
|
|
5294
5290
|
|
|
5295
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5291
|
+
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;
|
|
5296
5292
|
//# sourceMappingURL=index.cjs.map
|