@rotorsoft/act 1.33.10 → 1.33.12
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 -7
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +5 -2
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +1 -1
- package/dist/@types/types/ports.d.ts +5 -7
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/{chunk-7AHW7FCN.cjs → chunk-AVXVMZ4B.cjs} +1 -1
- package/dist/{chunk-7AHW7FCN.cjs.map → chunk-AVXVMZ4B.cjs.map} +1 -1
- package/dist/{chunk-6J2QWD4Q.cjs → chunk-P3B7HVFD.cjs} +96 -111
- package/dist/chunk-P3B7HVFD.cjs.map +1 -0
- package/dist/{chunk-KHFMCJDR.js → chunk-URF33KO3.js} +1 -1
- package/dist/{chunk-KHFMCJDR.js.map → chunk-URF33KO3.js.map} +1 -1
- package/dist/{chunk-OCJXGHN6.js → chunk-YZ2NKMVS.js} +76 -91
- package/dist/chunk-YZ2NKMVS.js.map +1 -0
- package/dist/index.cjs +168 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -33
- 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-6J2QWD4Q.cjs.map +0 -1
- package/dist/chunk-OCJXGHN6.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkP3B7HVFDcjs = require('./chunk-P3B7HVFD.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -70,24 +70,24 @@ var _chunk6J2QWD4Qcjs = require('./chunk-6J2QWD4Q.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var
|
|
73
|
+
var _chunkAVXVMZ4Bcjs = require('./chunk-AVXVMZ4B.cjs');
|
|
74
74
|
|
|
75
75
|
// src/signals.ts
|
|
76
76
|
process.once("SIGINT", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
78
|
+
await _chunkP3B7HVFDcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("SIGTERM", async (arg) => {
|
|
81
|
-
|
|
82
|
-
await
|
|
81
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
82
|
+
await _chunkP3B7HVFDcjs.disposeAndExit.call(void 0, "EXIT");
|
|
83
83
|
});
|
|
84
84
|
process.once("uncaughtException", async (arg) => {
|
|
85
|
-
|
|
86
|
-
await
|
|
85
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
86
|
+
await _chunkP3B7HVFDcjs.disposeAndExit.call(void 0, "ERROR");
|
|
87
87
|
});
|
|
88
88
|
process.once("unhandledRejection", async (arg) => {
|
|
89
|
-
|
|
90
|
-
await
|
|
89
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
90
|
+
await _chunkP3B7HVFDcjs.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: [_chunkAVXVMZ4Bcjs.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 = _chunkAVXVMZ4Bcjs.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: [_chunkAVXVMZ4Bcjs.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 === _chunkAVXVMZ4Bcjs.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 _chunkP3B7HVFDcjs.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 _chunkP3B7HVFDcjs.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 === _chunkAVXVMZ4Bcjs.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
|
+
_chunkP3B7HVFDcjs.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 _chunkP3B7HVFDcjs.store.call(void 0, ).query_stats(streams, {
|
|
981
|
+
exclude: [_chunkAVXVMZ4Bcjs.SNAP_EVENT]
|
|
982
982
|
});
|
|
983
|
-
const domain_heads = await
|
|
984
|
-
exclude: [
|
|
983
|
+
const domain_heads = await _chunkP3B7HVFDcjs.store.call(void 0, ).query_stats(streams, {
|
|
984
|
+
exclude: [_chunkAVXVMZ4Bcjs.SNAP_EVENT, _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT]
|
|
985
985
|
});
|
|
986
|
-
const true_heads = await
|
|
986
|
+
const true_heads = await _chunkP3B7HVFDcjs.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]) === _chunkAVXVMZ4Bcjs.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
|
+
_chunkP3B7HVFDcjs.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 _chunkP3B7HVFDcjs.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: _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
};
|
|
1102
1102
|
});
|
|
1103
|
-
const truncated = await
|
|
1103
|
+
const truncated = await _chunkP3B7HVFDcjs.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 _chunkP3B7HVFDcjs.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 _chunkP3B7HVFDcjs.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
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).error(new Error(message));
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
// src/internal/correlate-cycle.ts
|
|
@@ -1168,14 +1168,17 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1168
1168
|
*/
|
|
1169
1169
|
__init7() {this._raised = 1}
|
|
1170
1170
|
__init8() {this._lowered = 0}
|
|
1171
|
-
/**
|
|
1172
|
-
|
|
1171
|
+
/**
|
|
1172
|
+
* Bumped by a release (shutdown) and a restart (restore), so a scan or
|
|
1173
|
+
* lease reply that was out across one writes nothing.
|
|
1174
|
+
*/
|
|
1175
|
+
__init9() {this._epoch = 0}
|
|
1173
1176
|
|
|
1174
1177
|
// Bounded by `maxSubscribedStreams`; static records live apart so eviction
|
|
1175
1178
|
// never drops their +Infinity floor.
|
|
1176
1179
|
|
|
1177
1180
|
__init10() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1178
|
-
__init11() {this._patterns = new (0,
|
|
1181
|
+
__init11() {this._patterns = new (0, _chunkP3B7HVFDcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1179
1182
|
|
|
1180
1183
|
|
|
1181
1184
|
|
|
@@ -1193,7 +1196,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1193
1196
|
on_init
|
|
1194
1197
|
}) {;_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);
|
|
1195
1198
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1196
|
-
this._dynamic_subscriptions = new (0,
|
|
1199
|
+
this._dynamic_subscriptions = new (0, _chunkP3B7HVFDcjs.LruMap)(max_subscribed_streams);
|
|
1197
1200
|
this._registry = registry;
|
|
1198
1201
|
this._declared_lanes = declared_lanes;
|
|
1199
1202
|
this._static_targets = static_targets;
|
|
@@ -1240,6 +1243,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1240
1243
|
this._dynamic_subscriptions.clear();
|
|
1241
1244
|
this._static_subscriptions.clear();
|
|
1242
1245
|
this._raised++;
|
|
1246
|
+
this._epoch++;
|
|
1243
1247
|
}
|
|
1244
1248
|
/** Forget dynamic targets whose rows a full close deleted, so they re-subscribe. */
|
|
1245
1249
|
forget_subscribed(streams) {
|
|
@@ -1248,7 +1252,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1248
1252
|
/** Would the target's own `fetch` (filtered by `source`) return this event? */
|
|
1249
1253
|
_in_fetch_window(source, stream) {
|
|
1250
1254
|
if (source === void 0 || source === stream) return true;
|
|
1251
|
-
if (
|
|
1255
|
+
if (_chunkP3B7HVFDcjs.is_literal_source.call(void 0, source)) return false;
|
|
1252
1256
|
let pattern = this._patterns.get(source);
|
|
1253
1257
|
if (!pattern) {
|
|
1254
1258
|
pattern = new RegExp(source);
|
|
@@ -1259,38 +1263,31 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1259
1263
|
/** Scan past the checkpoint, subscribe new targets and raise their work marks. */
|
|
1260
1264
|
async correlate(query = { after: -1, limit: 10 }, lease = false) {
|
|
1261
1265
|
await this.init();
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1266
|
+
const epoch = this._epoch;
|
|
1267
|
+
const idle = () => ({
|
|
1268
|
+
subscribed: 0,
|
|
1269
|
+
last_id: this._checkpoint,
|
|
1270
|
+
marked: 0,
|
|
1271
|
+
scanned: false
|
|
1272
|
+
});
|
|
1273
|
+
if (this._raised === this._lowered) return idle();
|
|
1269
1274
|
const raised = this._raised;
|
|
1270
1275
|
const now = Date.now();
|
|
1271
1276
|
if (lease && now >= this._lease_until - CORRELATION_LEASE_MS / 2) {
|
|
1272
|
-
const releases = this._releases;
|
|
1273
1277
|
const { correlating } = await this._cd.subscribe([], void 0, {
|
|
1274
1278
|
key: this._key,
|
|
1275
1279
|
by: this._by,
|
|
1276
1280
|
millis: CORRELATION_LEASE_MS
|
|
1277
1281
|
});
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
if (correlating === false || released)
|
|
1282
|
-
return {
|
|
1283
|
-
subscribed: 0,
|
|
1284
|
-
last_id: this._checkpoint,
|
|
1285
|
-
marked: 0,
|
|
1286
|
-
scanned: false
|
|
1287
|
-
};
|
|
1282
|
+
if (this._epoch !== epoch) return idle();
|
|
1283
|
+
this._lease_until = correlating ? now + CORRELATION_LEASE_MS : 0;
|
|
1284
|
+
if (correlating === false) return idle();
|
|
1288
1285
|
}
|
|
1289
1286
|
const after = Math.max(this._checkpoint, query.after || -1);
|
|
1290
1287
|
const correlated = /* @__PURE__ */ new Map();
|
|
1291
1288
|
let last_id = after;
|
|
1292
1289
|
let stopped = false;
|
|
1293
|
-
const found = await
|
|
1290
|
+
const found = await _chunkP3B7HVFDcjs.store.call(void 0, ).query(
|
|
1294
1291
|
(event) => {
|
|
1295
1292
|
if (stopped) return;
|
|
1296
1293
|
const register = this._registry.events[event.name];
|
|
@@ -1334,9 +1331,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1334
1331
|
correlated_at: void 0
|
|
1335
1332
|
};
|
|
1336
1333
|
const seen_in_scan = correlated.has(resolved.target);
|
|
1337
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => (
|
|
1334
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkAVXVMZ4Bcjs.DEFAULT_LANE));
|
|
1338
1335
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _62 => _62.priority]);
|
|
1339
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
1336
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkAVXVMZ4Bcjs.DEFAULT_LANE));
|
|
1340
1337
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1341
1338
|
report_lane_conflict(
|
|
1342
1339
|
this._reported,
|
|
@@ -1363,6 +1360,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1363
1360
|
{ ...query, after, with_pii: false }
|
|
1364
1361
|
);
|
|
1365
1362
|
if (this._declared_lanes.size > 1) await this._recall(correlated);
|
|
1363
|
+
if (this._epoch !== epoch) return idle();
|
|
1366
1364
|
const streams = [];
|
|
1367
1365
|
for (const [stream, entry] of correlated) {
|
|
1368
1366
|
if (entry.upgraded || entry.correlated_at !== void 0)
|
|
@@ -1375,14 +1373,13 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1375
1373
|
});
|
|
1376
1374
|
}
|
|
1377
1375
|
if (streams.length) {
|
|
1378
|
-
const held = lease && this._lease_until > 0;
|
|
1379
1376
|
const renewed_at = Date.now();
|
|
1380
1377
|
const { subscribed, correlating } = await this._cd.subscribe(
|
|
1381
1378
|
streams,
|
|
1382
1379
|
last_id,
|
|
1383
|
-
|
|
1380
|
+
lease ? { key: this._key, by: this._by, millis: CORRELATION_LEASE_MS } : void 0
|
|
1384
1381
|
);
|
|
1385
|
-
if (
|
|
1382
|
+
if (lease && correlating !== false)
|
|
1386
1383
|
this._lease_until = renewed_at + CORRELATION_LEASE_MS;
|
|
1387
1384
|
const marked = streams.filter(
|
|
1388
1385
|
(entry) => entry.correlated_at !== void 0
|
|
@@ -1412,7 +1409,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1412
1409
|
await Promise.all(
|
|
1413
1410
|
missed.map(async ([stream, entry]) => {
|
|
1414
1411
|
let row;
|
|
1415
|
-
await
|
|
1412
|
+
await _chunkP3B7HVFDcjs.store.call(void 0, ).query_streams(
|
|
1416
1413
|
(position) => {
|
|
1417
1414
|
row = position;
|
|
1418
1415
|
},
|
|
@@ -1425,8 +1422,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1425
1422
|
lane: row.lane
|
|
1426
1423
|
});
|
|
1427
1424
|
if (entry.priority > row.priority) return;
|
|
1428
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
1429
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
1425
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkAVXVMZ4Bcjs.DEFAULT_LANE));
|
|
1426
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkAVXVMZ4Bcjs.DEFAULT_LANE));
|
|
1430
1427
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
1431
1428
|
report_lane_conflict(
|
|
1432
1429
|
this._reported,
|
|
@@ -1445,14 +1442,14 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1445
1442
|
async release_correlation() {
|
|
1446
1443
|
try {
|
|
1447
1444
|
this._lease_until = 0;
|
|
1448
|
-
this.
|
|
1445
|
+
this._epoch++;
|
|
1449
1446
|
await this._cd.subscribe([], void 0, {
|
|
1450
1447
|
key: this._key,
|
|
1451
1448
|
by: this._by,
|
|
1452
1449
|
millis: 0
|
|
1453
1450
|
});
|
|
1454
1451
|
} catch (error) {
|
|
1455
|
-
|
|
1452
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).warn(
|
|
1456
1453
|
`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)}`
|
|
1457
1454
|
);
|
|
1458
1455
|
}
|
|
@@ -1605,14 +1602,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1605
1602
|
}
|
|
1606
1603
|
|
|
1607
1604
|
// src/internal/drain-ops.ts
|
|
1608
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1605
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkP3B7HVFDcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1609
1606
|
async function fetch(leased, eventLimit) {
|
|
1610
1607
|
return Promise.all(
|
|
1611
1608
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1612
1609
|
const events = [];
|
|
1613
|
-
const stream_exact = source !== void 0 &&
|
|
1610
|
+
const stream_exact = source !== void 0 && _chunkP3B7HVFDcjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1614
1611
|
try {
|
|
1615
|
-
await
|
|
1612
|
+
await _chunkP3B7HVFDcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1616
1613
|
stream: source,
|
|
1617
1614
|
stream_exact,
|
|
1618
1615
|
after: at,
|
|
@@ -1632,30 +1629,30 @@ async function fetch(leased, eventLimit) {
|
|
|
1632
1629
|
})
|
|
1633
1630
|
);
|
|
1634
1631
|
}
|
|
1635
|
-
var ack = (leases) =>
|
|
1636
|
-
var block = (leases) =>
|
|
1637
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1632
|
+
var ack = (leases) => _chunkP3B7HVFDcjs.store.call(void 0, ).ack(leases);
|
|
1633
|
+
var block = (leases) => _chunkP3B7HVFDcjs.store.call(void 0, ).block(leases);
|
|
1634
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkP3B7HVFDcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1638
1635
|
|
|
1639
1636
|
// src/internal/event-sourcing.ts
|
|
1640
1637
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1641
1638
|
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1642
1639
|
var validating_patch = (me, state2, partial, event) => {
|
|
1643
1640
|
const next = _actpatch.patch.call(void 0, state2, partial);
|
|
1644
|
-
return
|
|
1641
|
+
return _chunkP3B7HVFDcjs.validate.call(void 0,
|
|
1645
1642
|
`${me.name}.${String(event.name)}#${event.id}`,
|
|
1646
1643
|
next,
|
|
1647
1644
|
me.state
|
|
1648
1645
|
);
|
|
1649
1646
|
};
|
|
1650
1647
|
var DEFAULT_BATCH = 500;
|
|
1651
|
-
var cache_put = (stream, entry) =>
|
|
1652
|
-
(err) =>
|
|
1648
|
+
var cache_put = (stream, entry) => _chunkP3B7HVFDcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1649
|
+
(err) => _chunkP3B7HVFDcjs.log.call(void 0, ).warn(
|
|
1653
1650
|
err,
|
|
1654
1651
|
"cache set skipped; the next load re-folds from the store"
|
|
1655
1652
|
)
|
|
1656
1653
|
);
|
|
1657
|
-
var cache_drop = (stream) =>
|
|
1658
|
-
(err) =>
|
|
1654
|
+
var cache_drop = (stream) => _chunkP3B7HVFDcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1655
|
+
(err) => _chunkP3B7HVFDcjs.log.call(void 0, ).warn(
|
|
1659
1656
|
err,
|
|
1660
1657
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1661
1658
|
)
|
|
@@ -1663,9 +1660,9 @@ var cache_drop = (stream) => _chunk6J2QWD4Qcjs.cache.call(void 0, ).invalidate(s
|
|
|
1663
1660
|
async function snap(snapshot) {
|
|
1664
1661
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1665
1662
|
try {
|
|
1666
|
-
const [committed] = await
|
|
1663
|
+
const [committed] = await _chunkP3B7HVFDcjs.store.call(void 0, ).commit(
|
|
1667
1664
|
stream,
|
|
1668
|
-
[{ name:
|
|
1665
|
+
[{ name: _chunkAVXVMZ4Bcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1669
1666
|
{
|
|
1670
1667
|
correlation: meta.correlation,
|
|
1671
1668
|
causation: { event: { id, name, stream } }
|
|
@@ -1676,22 +1673,22 @@ async function snap(snapshot) {
|
|
|
1676
1673
|
return committed;
|
|
1677
1674
|
} catch (error) {
|
|
1678
1675
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1679
|
-
|
|
1676
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).warn(
|
|
1680
1677
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1681
1678
|
);
|
|
1682
1679
|
}
|
|
1683
1680
|
}
|
|
1684
1681
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1685
1682
|
try {
|
|
1686
|
-
const [committed] = await
|
|
1683
|
+
const [committed] = await _chunkP3B7HVFDcjs.store.call(void 0, ).commit(
|
|
1687
1684
|
stream,
|
|
1688
|
-
[{ name:
|
|
1685
|
+
[{ name: _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1689
1686
|
{ correlation, causation: {} },
|
|
1690
1687
|
expectedVersion
|
|
1691
1688
|
);
|
|
1692
1689
|
return committed;
|
|
1693
1690
|
} catch (error) {
|
|
1694
|
-
if (error instanceof
|
|
1691
|
+
if (error instanceof _chunkAVXVMZ4Bcjs.ConcurrencyError) return void 0;
|
|
1695
1692
|
throw error;
|
|
1696
1693
|
}
|
|
1697
1694
|
}
|
|
@@ -1721,9 +1718,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1721
1718
|
if (drop_closed_streams) {
|
|
1722
1719
|
await source.query(
|
|
1723
1720
|
(e) => {
|
|
1724
|
-
if (e.name ===
|
|
1721
|
+
if (e.name === _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1725
1722
|
},
|
|
1726
|
-
{ names: [
|
|
1723
|
+
{ names: [_chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT] }
|
|
1727
1724
|
);
|
|
1728
1725
|
}
|
|
1729
1726
|
let max_id;
|
|
@@ -1745,11 +1742,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1745
1742
|
if (!is_valid(event))
|
|
1746
1743
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1747
1744
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1748
|
-
if (drop_snapshots && event.name ===
|
|
1745
|
+
if (drop_snapshots && event.name === _chunkAVXVMZ4Bcjs.SNAP_EVENT) {
|
|
1749
1746
|
dropped_snaps++;
|
|
1750
1747
|
return;
|
|
1751
1748
|
}
|
|
1752
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1749
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT) {
|
|
1753
1750
|
dropped_closed++;
|
|
1754
1751
|
return;
|
|
1755
1752
|
}
|
|
@@ -1816,17 +1813,17 @@ async function scan(source, opts = {}, callback) {
|
|
|
1816
1813
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1817
1814
|
const { stream, actor, asOf } = target;
|
|
1818
1815
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1819
|
-
const cached = time_travel ? void 0 : await
|
|
1816
|
+
const cached = time_travel ? void 0 : await _chunkP3B7HVFDcjs.cache.call(void 0, ).get(stream);
|
|
1820
1817
|
const cache_hit = !!cached;
|
|
1821
1818
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _72 => _72.state]), () => ( (me.init ? me.init() : {})));
|
|
1822
1819
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.patches]), () => ( 0));
|
|
1823
1820
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.snaps]), () => ( 0));
|
|
1824
1821
|
let replayed = 0;
|
|
1825
1822
|
let event;
|
|
1826
|
-
await
|
|
1823
|
+
await _chunkP3B7HVFDcjs.store.call(void 0, ).query(
|
|
1827
1824
|
(raw) => {
|
|
1828
1825
|
event = me.view(raw, actor);
|
|
1829
|
-
if (event.name ===
|
|
1826
|
+
if (event.name === _chunkAVXVMZ4Bcjs.SNAP_EVENT) {
|
|
1830
1827
|
state2 = event.data;
|
|
1831
1828
|
snaps++;
|
|
1832
1829
|
patches = 0;
|
|
@@ -1835,8 +1832,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1835
1832
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1836
1833
|
patches++;
|
|
1837
1834
|
replayed++;
|
|
1838
|
-
} else if (event.name !==
|
|
1839
|
-
|
|
1835
|
+
} else if (event.name !== _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT) {
|
|
1836
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).warn(
|
|
1840
1837
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1841
1838
|
);
|
|
1842
1839
|
}
|
|
@@ -1860,7 +1857,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1860
1857
|
...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
|
|
1861
1858
|
}
|
|
1862
1859
|
);
|
|
1863
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) ===
|
|
1860
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) === _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT;
|
|
1864
1861
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1865
1862
|
await cache_put(stream, {
|
|
1866
1863
|
stream,
|
|
@@ -1888,7 +1885,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1888
1885
|
if (!stream) throw new Error("Missing target stream");
|
|
1889
1886
|
const reactingTo = _optionalChain([options, 'optionalAccess', _81 => _81.reactingTo]);
|
|
1890
1887
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.correlator]), () => ( default_correlator));
|
|
1891
|
-
const validated =
|
|
1888
|
+
const validated = _chunkP3B7HVFDcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1892
1889
|
const opts = _optionalChain([me, 'access', _83 => _83.options, 'optionalAccess', _84 => _84[action2]]);
|
|
1893
1890
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries]), () => ( 0));
|
|
1894
1891
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1899,14 +1896,14 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1899
1896
|
void 0,
|
|
1900
1897
|
patch_fn
|
|
1901
1898
|
);
|
|
1902
|
-
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) ===
|
|
1903
|
-
throw new (0,
|
|
1899
|
+
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) === _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT)
|
|
1900
|
+
throw new (0, _chunkAVXVMZ4Bcjs.StreamClosedError)(stream);
|
|
1904
1901
|
const expected = _nullishCoalesce(expectedVersion, () => ( (snapshot.version >= 0 ? snapshot.version : void 0)));
|
|
1905
1902
|
if (me.given) {
|
|
1906
1903
|
const invariants = me.given[action2] || [];
|
|
1907
1904
|
invariants.forEach(({ valid: valid2, description }) => {
|
|
1908
1905
|
if (!valid2(snapshot.state, actor))
|
|
1909
|
-
throw new (0,
|
|
1906
|
+
throw new (0, _chunkAVXVMZ4Bcjs.InvariantError)(
|
|
1910
1907
|
action2,
|
|
1911
1908
|
validated,
|
|
1912
1909
|
target,
|
|
@@ -1923,7 +1920,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1923
1920
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1924
1921
|
const valid = tuples.map(([name, data]) => ({
|
|
1925
1922
|
name,
|
|
1926
|
-
data:
|
|
1923
|
+
data: _chunkP3B7HVFDcjs.validate.call(void 0, name, data, me.events[name])
|
|
1927
1924
|
}));
|
|
1928
1925
|
const emitted = valid.map((e) => me.message(e));
|
|
1929
1926
|
const meta = {
|
|
@@ -1948,7 +1945,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1948
1945
|
};
|
|
1949
1946
|
let committed;
|
|
1950
1947
|
try {
|
|
1951
|
-
committed = await
|
|
1948
|
+
committed = await _chunkP3B7HVFDcjs.store.call(void 0, ).commit(
|
|
1952
1949
|
stream,
|
|
1953
1950
|
emitted,
|
|
1954
1951
|
meta,
|
|
@@ -1957,7 +1954,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1957
1954
|
reactingTo ? expectedVersion : expected
|
|
1958
1955
|
);
|
|
1959
1956
|
} catch (error) {
|
|
1960
|
-
if (error instanceof
|
|
1957
|
+
if (error instanceof _chunkAVXVMZ4Bcjs.ConcurrencyError) void cache_drop(stream);
|
|
1961
1958
|
throw error;
|
|
1962
1959
|
}
|
|
1963
1960
|
let { state: state2, patches } = snapshot;
|
|
@@ -1996,19 +1993,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1996
1993
|
}
|
|
1997
1994
|
return snapshots;
|
|
1998
1995
|
} catch (error) {
|
|
1999
|
-
if (!(error instanceof
|
|
1996
|
+
if (!(error instanceof _chunkAVXVMZ4Bcjs.ConcurrencyError)) throw error;
|
|
2000
1997
|
if (expectedVersion !== void 0) throw error;
|
|
2001
1998
|
if (attempt >= max_retries) throw error;
|
|
2002
1999
|
if (_optionalChain([opts, 'optionalAccess', _94 => _94.backoff])) {
|
|
2003
2000
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
2004
|
-
if (delay_ms > 0) await
|
|
2001
|
+
if (delay_ms > 0) await _chunkP3B7HVFDcjs.sleep.call(void 0, delay_ms);
|
|
2005
2002
|
}
|
|
2006
2003
|
}
|
|
2007
2004
|
}
|
|
2008
2005
|
}
|
|
2009
2006
|
|
|
2010
2007
|
// src/internal/tracing.ts
|
|
2011
|
-
var PRETTY =
|
|
2008
|
+
var PRETTY = _chunkP3B7HVFDcjs.config.call(void 0, ).env !== "production";
|
|
2012
2009
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2013
2010
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2014
2011
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2194,7 +2191,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2194
2191
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _104 => _104.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2195
2192
|
return void 0;
|
|
2196
2193
|
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.`;
|
|
2197
|
-
|
|
2194
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).error(error);
|
|
2198
2195
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2199
2196
|
}
|
|
2200
2197
|
function fetch_failure_policy(registry) {
|
|
@@ -2210,13 +2207,13 @@ function fetch_failure_policy(registry) {
|
|
|
2210
2207
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
2211
2208
|
if (!error) return { lease, handled, acked_at: at };
|
|
2212
2209
|
logger.error(error);
|
|
2213
|
-
const non_retryable = error instanceof
|
|
2210
|
+
const non_retryable = error instanceof _chunkAVXVMZ4Bcjs.NonRetryableError;
|
|
2214
2211
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2215
2212
|
if (block2)
|
|
2216
2213
|
logger.error(
|
|
2217
2214
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2218
2215
|
);
|
|
2219
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2216
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkP3B7HVFDcjs.DEFAULT_BACKOFF)));
|
|
2220
2217
|
return {
|
|
2221
2218
|
lease,
|
|
2222
2219
|
handled,
|
|
@@ -2345,7 +2342,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2345
2342
|
const acked = await ops.ack(submitted);
|
|
2346
2343
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2347
2344
|
if (acked.length < expected)
|
|
2348
|
-
|
|
2345
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).warn(
|
|
2349
2346
|
`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.`
|
|
2350
2347
|
);
|
|
2351
2348
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2436,9 +2433,9 @@ var DrainController = (_class5 = class {
|
|
|
2436
2433
|
if (!this.armed || this._stopped || this._inflight)
|
|
2437
2434
|
return EMPTY_DRAIN;
|
|
2438
2435
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2439
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2440
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2441
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2436
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkP3B7HVFDcjs.DEFAULT_STREAM_LIMIT));
|
|
2437
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkP3B7HVFDcjs.DEFAULT_EVENT_LIMIT));
|
|
2438
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkP3B7HVFDcjs.DEFAULT_LEASE_MILLIS));
|
|
2442
2439
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2443
2440
|
return EMPTY_DRAIN;
|
|
2444
2441
|
try {
|
|
@@ -2509,7 +2506,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2509
2506
|
const { pii, ...rest } = event;
|
|
2510
2507
|
if (pii == null) {
|
|
2511
2508
|
const shredded = { ...data };
|
|
2512
|
-
for (const f of fields) shredded[f] =
|
|
2509
|
+
for (const f of fields) shredded[f] = _chunkAVXVMZ4Bcjs.SHREDDED;
|
|
2513
2510
|
return { ...rest, data: shredded };
|
|
2514
2511
|
}
|
|
2515
2512
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2520,7 +2517,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2520
2517
|
};
|
|
2521
2518
|
}
|
|
2522
2519
|
const redacted = { ...data };
|
|
2523
|
-
for (const f of fields) redacted[f] =
|
|
2520
|
+
for (const f of fields) redacted[f] = _chunkAVXVMZ4Bcjs.REDACTED;
|
|
2524
2521
|
return { ...rest, data: redacted };
|
|
2525
2522
|
}
|
|
2526
2523
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2657,7 +2654,7 @@ function make_deferred(handler, schedule) {
|
|
|
2657
2654
|
const call = handler;
|
|
2658
2655
|
const deferred = async (event, stream, app) => {
|
|
2659
2656
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2660
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2657
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkAVXVMZ4Bcjs.DeferSignal)(when);
|
|
2661
2658
|
return call(event, stream, app);
|
|
2662
2659
|
};
|
|
2663
2660
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2726,7 +2723,7 @@ function build_handle(deps) {
|
|
|
2726
2723
|
handled++;
|
|
2727
2724
|
}
|
|
2728
2725
|
} catch (error) {
|
|
2729
|
-
if (error instanceof
|
|
2726
|
+
if (error instanceof _chunkAVXVMZ4Bcjs.DeferSignal) {
|
|
2730
2727
|
let defer;
|
|
2731
2728
|
try {
|
|
2732
2729
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -3002,7 +2999,7 @@ var Act = (_class7 = class {
|
|
|
3002
2999
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
3003
3000
|
|
|
3004
3001
|
|
|
3005
|
-
__init26() {this._logger =
|
|
3002
|
+
__init26() {this._logger = _chunkP3B7HVFDcjs.log.call(void 0, )}
|
|
3006
3003
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3007
3004
|
|
|
3008
3005
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3024,9 +3021,9 @@ var Act = (_class7 = class {
|
|
|
3024
3021
|
this._lanes = lanes;
|
|
3025
3022
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3026
3023
|
validate_only_lanes(options, lanes);
|
|
3027
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3024
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkP3B7HVFDcjs.default_scope.call(void 0, )));
|
|
3028
3025
|
const ports = this._ports;
|
|
3029
|
-
this._scoped =
|
|
3026
|
+
this._scoped = _chunkP3B7HVFDcjs.make_run_scoped.call(void 0, {
|
|
3030
3027
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3031
3028
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3032
3029
|
get store() {
|
|
@@ -3036,14 +3033,14 @@ var Act = (_class7 = class {
|
|
|
3036
3033
|
return ports.cache;
|
|
3037
3034
|
},
|
|
3038
3035
|
// Parsed per build, so a bad window throws on every build.
|
|
3039
|
-
autoclose_window:
|
|
3036
|
+
autoclose_window: _chunkP3B7HVFDcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3040
3037
|
});
|
|
3041
3038
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3042
3039
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3043
3040
|
this._cd = build_drain(this._logger);
|
|
3044
3041
|
const handle = build_handle({
|
|
3045
3042
|
logger: this._logger,
|
|
3046
|
-
reaction_scope:
|
|
3043
|
+
reaction_scope: _chunkP3B7HVFDcjs.make_reaction_scope.call(void 0, {
|
|
3047
3044
|
do: this.do.bind(this),
|
|
3048
3045
|
load: this.load.bind(this),
|
|
3049
3046
|
query: this.query.bind(this),
|
|
@@ -3073,12 +3070,12 @@ var Act = (_class7 = class {
|
|
|
3073
3070
|
this._ports.store,
|
|
3074
3071
|
options.listen !== false
|
|
3075
3072
|
);
|
|
3076
|
-
|
|
3073
|
+
_chunkP3B7HVFDcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3077
3074
|
}
|
|
3078
3075
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3079
3076
|
_build_breaker(options) {
|
|
3080
3077
|
return new CircuitBreaker(
|
|
3081
|
-
|
|
3078
|
+
_chunkP3B7HVFDcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3082
3079
|
{
|
|
3083
3080
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3084
3081
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3112,7 +3109,7 @@ var Act = (_class7 = class {
|
|
|
3112
3109
|
try {
|
|
3113
3110
|
await this._run_close(targets);
|
|
3114
3111
|
} catch (error) {
|
|
3115
|
-
if (error instanceof
|
|
3112
|
+
if (error instanceof _chunkAVXVMZ4Bcjs.StoreError) throw error;
|
|
3116
3113
|
this._logger.error(
|
|
3117
3114
|
error,
|
|
3118
3115
|
`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.`
|
|
@@ -3147,7 +3144,7 @@ var Act = (_class7 = class {
|
|
|
3147
3144
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3148
3145
|
_build_audit_deps() {
|
|
3149
3146
|
return {
|
|
3150
|
-
store:
|
|
3147
|
+
store: _chunkP3B7HVFDcjs.store,
|
|
3151
3148
|
event_to_state: this._event_to_state,
|
|
3152
3149
|
// Declared lanes, not this process's controllers: a lane another
|
|
3153
3150
|
// worker drains is not `unknown-lane`.
|
|
@@ -3160,7 +3157,7 @@ var Act = (_class7 = class {
|
|
|
3160
3157
|
registry: this.registry,
|
|
3161
3158
|
static_targets: classification.static_targets,
|
|
3162
3159
|
cd: this._cd,
|
|
3163
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3160
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkAVXVMZ4Bcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3164
3161
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3165
3162
|
// still a valid destination.
|
|
3166
3163
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3176,7 +3173,7 @@ var Act = (_class7 = class {
|
|
|
3176
3173
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3177
3174
|
async _seed_persisted_defers() {
|
|
3178
3175
|
const now = Date.now();
|
|
3179
|
-
await walk_streams(
|
|
3176
|
+
await walk_streams(_chunkP3B7HVFDcjs.store.call(void 0, ), (pos) => {
|
|
3180
3177
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3181
3178
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3182
3179
|
_optionalChain([controller, 'optionalAccess', _126 => _126.seed_defer, 'call', _127 => _127(pos.stream, pos.deferred_at)]);
|
|
@@ -3197,14 +3194,15 @@ var Act = (_class7 = class {
|
|
|
3197
3194
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3198
3195
|
breaker: this._breaker
|
|
3199
3196
|
},
|
|
3200
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3197
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkAVXVMZ4Bcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3201
3198
|
);
|
|
3202
3199
|
}
|
|
3203
3200
|
|
|
3204
3201
|
/**
|
|
3205
|
-
* Per-instance teardown: stops scheduling,
|
|
3206
|
-
* to `graceMs` to reach their
|
|
3207
|
-
* until it expires), then
|
|
3202
|
+
* Per-instance teardown: stops scheduling, removes the notify
|
|
3203
|
+
* subscription, gives the cycles in flight up to `graceMs` to reach their
|
|
3204
|
+
* `ack` (an abandoned handler holds its lease until it expires), then
|
|
3205
|
+
* hands back the correlation lease and removes listeners.
|
|
3208
3206
|
* The budget is a ceiling, not a delay.
|
|
3209
3207
|
*
|
|
3210
3208
|
* Idempotent: repeated calls return the same promise, with the first
|
|
@@ -3216,7 +3214,7 @@ var Act = (_class7 = class {
|
|
|
3216
3214
|
*/
|
|
3217
3215
|
shutdown(options) {
|
|
3218
3216
|
if (!this._shutdown_promise) {
|
|
3219
|
-
|
|
3217
|
+
_chunkP3B7HVFDcjs.resolveShutdownConfig.call(void 0, options);
|
|
3220
3218
|
this._shutdown_promise = (async () => {
|
|
3221
3219
|
this.stop_correlations();
|
|
3222
3220
|
this._settle.stop(true);
|
|
@@ -3236,10 +3234,10 @@ var Act = (_class7 = class {
|
|
|
3236
3234
|
* default for none or 0, and for a running settle), capped.
|
|
3237
3235
|
*/
|
|
3238
3236
|
_derive_grace_ms(running, settling) {
|
|
3239
|
-
let max = settling ?
|
|
3237
|
+
let max = settling ? _chunkP3B7HVFDcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3240
3238
|
for (const c of running)
|
|
3241
|
-
max = Math.max(max, c.lease_millis ||
|
|
3242
|
-
return Math.min(max,
|
|
3239
|
+
max = Math.max(max, c.lease_millis || _chunkP3B7HVFDcjs.DEFAULT_LEASE_MILLIS);
|
|
3240
|
+
return Math.min(max, _chunkP3B7HVFDcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3243
3241
|
}
|
|
3244
3242
|
async _await_inflight(grace_ms) {
|
|
3245
3243
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3319,7 +3317,7 @@ var Act = (_class7 = class {
|
|
|
3319
3317
|
* @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
|
|
3320
3318
|
*/
|
|
3321
3319
|
async do(action2, target, payload, options) {
|
|
3322
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _129 => _129.reactingTo]), () => (
|
|
3320
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _129 => _129.reactingTo]), () => ( _chunkP3B7HVFDcjs.current_reacting.call(void 0, )));
|
|
3323
3321
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _130 => _130.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3324
3322
|
return this._scoped(async () => {
|
|
3325
3323
|
const snapshots = await this._es.action(
|
|
@@ -3380,7 +3378,7 @@ var Act = (_class7 = class {
|
|
|
3380
3378
|
return this._scoped(async () => {
|
|
3381
3379
|
let first;
|
|
3382
3380
|
let last;
|
|
3383
|
-
const count = await
|
|
3381
|
+
const count = await _chunkP3B7HVFDcjs.store.call(void 0, ).query((e) => {
|
|
3384
3382
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3385
3383
|
if (!first) first = gated;
|
|
3386
3384
|
last = gated;
|
|
@@ -3410,7 +3408,7 @@ var Act = (_class7 = class {
|
|
|
3410
3408
|
async query_array(query) {
|
|
3411
3409
|
return this._scoped(async () => {
|
|
3412
3410
|
const events = [];
|
|
3413
|
-
await
|
|
3411
|
+
await _chunkP3B7HVFDcjs.store.call(void 0, ).query((e) => {
|
|
3414
3412
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3415
3413
|
}, query);
|
|
3416
3414
|
return events;
|
|
@@ -3430,14 +3428,14 @@ var Act = (_class7 = class {
|
|
|
3430
3428
|
*/
|
|
3431
3429
|
async forget(stream) {
|
|
3432
3430
|
return this._scoped(async () => {
|
|
3433
|
-
const s =
|
|
3431
|
+
const s = _chunkP3B7HVFDcjs.store.call(void 0, );
|
|
3434
3432
|
if (!s.forget_pii) {
|
|
3435
3433
|
throw new Error(
|
|
3436
3434
|
`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).`
|
|
3437
3435
|
);
|
|
3438
3436
|
}
|
|
3439
3437
|
const eventCount = await s.forget_pii(stream);
|
|
3440
|
-
await
|
|
3438
|
+
await _chunkP3B7HVFDcjs.cache.call(void 0, ).invalidate(stream);
|
|
3441
3439
|
if (eventCount > 0) {
|
|
3442
3440
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3443
3441
|
}
|
|
@@ -3471,7 +3469,7 @@ var Act = (_class7 = class {
|
|
|
3471
3469
|
* @see {@link correlate} for dynamic stream discovery
|
|
3472
3470
|
*/
|
|
3473
3471
|
async drain(options = {}) {
|
|
3474
|
-
|
|
3472
|
+
_chunkP3B7HVFDcjs.resolveDrainConfig.call(void 0, options);
|
|
3475
3473
|
if (!this._drain)
|
|
3476
3474
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3477
3475
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3654,7 +3652,7 @@ var Act = (_class7 = class {
|
|
|
3654
3652
|
*/
|
|
3655
3653
|
async reset(input) {
|
|
3656
3654
|
return this._scoped(async () => {
|
|
3657
|
-
const count = await
|
|
3655
|
+
const count = await _chunkP3B7HVFDcjs.store.call(void 0, ).reset(input);
|
|
3658
3656
|
for (const handler of this._batch_handlers.values())
|
|
3659
3657
|
_optionalChain([handler, 'access', _137 => _137[FOLD_RESET], 'optionalCall', _138 => _138()]);
|
|
3660
3658
|
if (count > 0) {
|
|
@@ -3690,7 +3688,7 @@ var Act = (_class7 = class {
|
|
|
3690
3688
|
*/
|
|
3691
3689
|
async unblock(input) {
|
|
3692
3690
|
return this._scoped(async () => {
|
|
3693
|
-
const count = await
|
|
3691
|
+
const count = await _chunkP3B7HVFDcjs.store.call(void 0, ).unblock(input);
|
|
3694
3692
|
if (count > 0) {
|
|
3695
3693
|
this._wake();
|
|
3696
3694
|
}
|
|
@@ -3739,7 +3737,7 @@ var Act = (_class7 = class {
|
|
|
3739
3737
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3740
3738
|
}
|
|
3741
3739
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3742
|
-
const s =
|
|
3740
|
+
const s = _chunkP3B7HVFDcjs.store.call(void 0, );
|
|
3743
3741
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3744
3742
|
return s;
|
|
3745
3743
|
})()));
|
|
@@ -3784,7 +3782,7 @@ var Act = (_class7 = class {
|
|
|
3784
3782
|
async blocked_streams(options) {
|
|
3785
3783
|
return this._scoped(async () => {
|
|
3786
3784
|
const positions = [];
|
|
3787
|
-
await
|
|
3785
|
+
await _chunkP3B7HVFDcjs.store.call(void 0, ).query_streams(
|
|
3788
3786
|
(p) => {
|
|
3789
3787
|
positions.push(p);
|
|
3790
3788
|
},
|
|
@@ -3836,7 +3834,7 @@ var Act = (_class7 = class {
|
|
|
3836
3834
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3837
3835
|
*/
|
|
3838
3836
|
async prioritize(filter, priority) {
|
|
3839
|
-
return this._scoped(() =>
|
|
3837
|
+
return this._scoped(() => _chunkP3B7HVFDcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3840
3838
|
}
|
|
3841
3839
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3842
3840
|
async _run_close(targets) {
|
|
@@ -3888,10 +3886,8 @@ var Act = (_class7 = class {
|
|
|
3888
3886
|
* A local change that frees reaction work (a commit, `reset()`,
|
|
3889
3887
|
* `unblock()`, `restore()`) schedules this on its own unless the app
|
|
3890
3888
|
* sets `autoSettle: false`. Call it at startup, to run what was pending
|
|
3891
|
-
* before a restart, or with options for the next pass
|
|
3892
|
-
*
|
|
3893
|
-
* `debounceMs` brings it forward), and a call during a running cycle
|
|
3894
|
-
* queues one more pass after it. Runs correlate→drain in a loop until a pass makes no
|
|
3889
|
+
* before a restart, or with options for the next pass; the scheduling
|
|
3890
|
+
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain in a loop until a pass makes no
|
|
3895
3891
|
* progress — no new subscriptions, no events read, no streams leased —
|
|
3896
3892
|
* then emits the `"settled"` lifecycle event, so one call fully catches
|
|
3897
3893
|
* up paginated streams without forcing callers to loop.
|
|
@@ -3918,7 +3914,7 @@ var Act = (_class7 = class {
|
|
|
3918
3914
|
* @see {@link correlate} for manual correlation
|
|
3919
3915
|
*/
|
|
3920
3916
|
settle(options) {
|
|
3921
|
-
|
|
3917
|
+
_chunkP3B7HVFDcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3922
3918
|
this._schedule(options);
|
|
3923
3919
|
}
|
|
3924
3920
|
}, _class7);
|
|
@@ -4074,16 +4070,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4074
4070
|
}),
|
|
4075
4071
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4076
4072
|
// not quarantine the synthetic stream.
|
|
4077
|
-
options: { blockOnError: false, maxRetries:
|
|
4073
|
+
options: { blockOnError: false, maxRetries: _chunkP3B7HVFDcjs.DEFAULT_MAX_RETRIES },
|
|
4078
4074
|
handler: async (event) => {
|
|
4079
4075
|
const aggregate = event.stream;
|
|
4080
4076
|
const window = read_window();
|
|
4081
4077
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4082
|
-
throw new (0,
|
|
4083
|
-
const stats = await
|
|
4078
|
+
throw new (0, _chunkAVXVMZ4Bcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4079
|
+
const stats = await _chunkP3B7HVFDcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4084
4080
|
count: true,
|
|
4085
4081
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4086
|
-
exclude: [
|
|
4082
|
+
exclude: [_chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT, _chunkAVXVMZ4Bcjs.SNAP_EVENT]
|
|
4087
4083
|
});
|
|
4088
4084
|
const entry = stats.get(aggregate);
|
|
4089
4085
|
if (!entry) return;
|
|
@@ -4114,7 +4110,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4114
4110
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4115
4111
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4116
4112
|
if (future.length)
|
|
4117
|
-
throw new (0,
|
|
4113
|
+
throw new (0, _chunkAVXVMZ4Bcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4118
4114
|
}
|
|
4119
4115
|
};
|
|
4120
4116
|
const key = `__autoclose_${st.name}`;
|
|
@@ -4318,9 +4314,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4318
4314
|
|
|
4319
4315
|
// src/builders/builder-utils.ts
|
|
4320
4316
|
function register_lane(config2, lanes) {
|
|
4321
|
-
|
|
4322
|
-
if (config2.name ===
|
|
4323
|
-
throw new Error(`Lane "${
|
|
4317
|
+
_chunkP3B7HVFDcjs.resolveLaneConfig.call(void 0, config2);
|
|
4318
|
+
if (config2.name === _chunkAVXVMZ4Bcjs.DEFAULT_LANE)
|
|
4319
|
+
throw new Error(`Lane "${_chunkAVXVMZ4Bcjs.DEFAULT_LANE}" is reserved`);
|
|
4324
4320
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4325
4321
|
if (!existing) return void lanes.push(config2);
|
|
4326
4322
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4362,9 +4358,9 @@ function reaction_on(event, events, builder) {
|
|
|
4362
4358
|
// Validate the whole bag at the declaration site so a bad
|
|
4363
4359
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4364
4360
|
// not a NaN gate on the first retry.
|
|
4365
|
-
options:
|
|
4366
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _153 => _153.blockOnError]), () => (
|
|
4367
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _154 => _154.maxRetries]), () => (
|
|
4361
|
+
options: _chunkP3B7HVFDcjs.resolveReactionConfig.call(void 0, {
|
|
4362
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _153 => _153.blockOnError]), () => ( _chunkP3B7HVFDcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4363
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _154 => _154.maxRetries]), () => ( _chunkP3B7HVFDcjs.DEFAULT_MAX_RETRIES)),
|
|
4368
4364
|
backoff: _optionalChain([options, 'optionalAccess', _155 => _155.backoff])
|
|
4369
4365
|
})
|
|
4370
4366
|
};
|
|
@@ -4449,7 +4445,7 @@ function date_reviver_schema(schema) {
|
|
|
4449
4445
|
|
|
4450
4446
|
// src/builders/event-builder.ts
|
|
4451
4447
|
function event_tags(schema) {
|
|
4452
|
-
const pii =
|
|
4448
|
+
const pii = _chunkAVXVMZ4Bcjs.pii_schemas.call(void 0, schema);
|
|
4453
4449
|
const pii_dates = {};
|
|
4454
4450
|
for (const [key, field] of Object.entries(pii)) {
|
|
4455
4451
|
const dates = date_reviver_schema(field);
|
|
@@ -4486,7 +4482,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4486
4482
|
});
|
|
4487
4483
|
}
|
|
4488
4484
|
function build_events(registry, states, lanes, owners) {
|
|
4489
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4485
|
+
const declared = /* @__PURE__ */ new Set([_chunkAVXVMZ4Bcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4490
4486
|
const lane_errors = [];
|
|
4491
4487
|
const tags = /* @__PURE__ */ new Map();
|
|
4492
4488
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4550,7 +4546,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4550
4546
|
if (reader) readers.set(event_name, reader);
|
|
4551
4547
|
}
|
|
4552
4548
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4553
|
-
if (snap2) readers.set(
|
|
4549
|
+
if (snap2) readers.set(_chunkAVXVMZ4Bcjs.SNAP_EVENT, snap2);
|
|
4554
4550
|
if (readers.size === 0) continue;
|
|
4555
4551
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4556
4552
|
}
|
|
@@ -4666,7 +4662,7 @@ function act() {
|
|
|
4666
4662
|
const list = deprecation_summary.map(
|
|
4667
4663
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4668
4664
|
).join(", ");
|
|
4669
|
-
|
|
4665
|
+
_chunkP3B7HVFDcjs.log.call(void 0, ).info(
|
|
4670
4666
|
`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.`
|
|
4671
4667
|
);
|
|
4672
4668
|
}
|
|
@@ -4708,7 +4704,7 @@ function act() {
|
|
|
4708
4704
|
return reaction_on(event, registry.events, builder);
|
|
4709
4705
|
},
|
|
4710
4706
|
build: (options) => {
|
|
4711
|
-
|
|
4707
|
+
_chunkP3B7HVFDcjs.resolveActConfig.call(void 0, options);
|
|
4712
4708
|
const patch_fn = _optionalChain([options, 'optionalAccess', _167 => _167.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4713
4709
|
if (!_built) {
|
|
4714
4710
|
for (const proj of pending_projections) add_projection(proj);
|
|
@@ -4760,7 +4756,7 @@ function act() {
|
|
|
4760
4756
|
synthesize_autoclose_reactions(
|
|
4761
4757
|
registry,
|
|
4762
4758
|
states,
|
|
4763
|
-
|
|
4759
|
+
_chunkP3B7HVFDcjs.current_autoclose_window
|
|
4764
4760
|
);
|
|
4765
4761
|
Object.freeze(registry.actions);
|
|
4766
4762
|
Object.freeze(registry.events);
|
|
@@ -4809,8 +4805,8 @@ function _projection(target) {
|
|
|
4809
4805
|
handler,
|
|
4810
4806
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4811
4807
|
options: {
|
|
4812
|
-
blockOnError:
|
|
4813
|
-
maxRetries:
|
|
4808
|
+
blockOnError: _chunkP3B7HVFDcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4809
|
+
maxRetries: _chunkP3B7HVFDcjs.DEFAULT_MAX_RETRIES
|
|
4814
4810
|
}
|
|
4815
4811
|
}),
|
|
4816
4812
|
widened
|
|
@@ -4851,7 +4847,7 @@ function _projection(target) {
|
|
|
4851
4847
|
throw new Error(
|
|
4852
4848
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4853
4849
|
);
|
|
4854
|
-
const config2 =
|
|
4850
|
+
const config2 = _chunkP3B7HVFDcjs.resolveFoldConfig.call(void 0, options);
|
|
4855
4851
|
const fold_events = {};
|
|
4856
4852
|
for (const partial of partials)
|
|
4857
4853
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4869,8 +4865,8 @@ function _projection(target) {
|
|
|
4869
4865
|
handler: noop,
|
|
4870
4866
|
resolver: { target },
|
|
4871
4867
|
options: {
|
|
4872
|
-
blockOnError:
|
|
4873
|
-
maxRetries:
|
|
4868
|
+
blockOnError: _chunkP3B7HVFDcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4869
|
+
maxRetries: _chunkP3B7HVFDcjs.DEFAULT_MAX_RETRIES
|
|
4874
4870
|
}
|
|
4875
4871
|
}
|
|
4876
4872
|
]
|
|
@@ -4986,7 +4982,7 @@ function action_builder(state2) {
|
|
|
4986
4982
|
throw new Error(`Duplicate action "${action2}"`);
|
|
4987
4983
|
internal.actions[action2] = schema;
|
|
4988
4984
|
if (options) {
|
|
4989
|
-
|
|
4985
|
+
_chunkP3B7HVFDcjs.resolveActionConfig.call(void 0, options);
|
|
4990
4986
|
internal.options ??= {};
|
|
4991
4987
|
internal.options[action2] = options;
|
|
4992
4988
|
}
|
|
@@ -5275,5 +5271,5 @@ function write_line(writer, line) {
|
|
|
5275
5271
|
|
|
5276
5272
|
|
|
5277
5273
|
|
|
5278
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5274
|
+
exports.Act = Act; exports.ActorSchema = _chunkAVXVMZ4Bcjs.ActorSchema; exports.CausationEventSchema = _chunkAVXVMZ4Bcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkAVXVMZ4Bcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkAVXVMZ4Bcjs.ConcurrencyError; exports.ConsoleLogger = _chunkP3B7HVFDcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkAVXVMZ4Bcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkAVXVMZ4Bcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkAVXVMZ4Bcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkAVXVMZ4Bcjs.DeferSignal; exports.Environments = _chunkAVXVMZ4Bcjs.Environments; exports.Errors = _chunkAVXVMZ4Bcjs.Errors; exports.EventMetaSchema = _chunkAVXVMZ4Bcjs.EventMetaSchema; exports.ExitCodes = _chunkAVXVMZ4Bcjs.ExitCodes; exports.InMemoryCache = _chunkP3B7HVFDcjs.InMemoryCache; exports.InMemoryStore = _chunkP3B7HVFDcjs.InMemoryStore; exports.InvariantError = _chunkAVXVMZ4Bcjs.InvariantError; exports.LogLevels = _chunkAVXVMZ4Bcjs.LogLevels; exports.NonRetryableError = _chunkAVXVMZ4Bcjs.NonRetryableError; exports.PackageSchema = _chunkP3B7HVFDcjs.PackageSchema; exports.QuerySchema = _chunkAVXVMZ4Bcjs.QuerySchema; exports.REDACTED = _chunkAVXVMZ4Bcjs.REDACTED; exports.SHREDDED = _chunkAVXVMZ4Bcjs.SHREDDED; exports.SNAP_EVENT = _chunkAVXVMZ4Bcjs.SNAP_EVENT; exports.StoreError = _chunkAVXVMZ4Bcjs.StoreError; exports.StreamClosedError = _chunkAVXVMZ4Bcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkAVXVMZ4Bcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkAVXVMZ4Bcjs.TargetSchema; exports.ValidationError = _chunkAVXVMZ4Bcjs.ValidationError; exports.ZodEmpty = _chunkAVXVMZ4Bcjs.ZodEmpty; exports.act = act; exports.cache = _chunkP3B7HVFDcjs.cache; exports.config = _chunkP3B7HVFDcjs.config; exports.dateReviver = _chunkP3B7HVFDcjs.dateReviver; exports.default_scope = _chunkP3B7HVFDcjs.default_scope; exports.dispose = _chunkP3B7HVFDcjs.dispose; exports.disposeAndExit = _chunkP3B7HVFDcjs.disposeAndExit; exports.extend = _chunkP3B7HVFDcjs.extend; exports.is_literal_source = _chunkP3B7HVFDcjs.is_literal_source; exports.log = _chunkP3B7HVFDcjs.log; exports.pii_fields = _chunkAVXVMZ4Bcjs.pii_fields; exports.port = _chunkP3B7HVFDcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkP3B7HVFDcjs.resolveAutocloseConfig2; exports.sensitive = _chunkAVXVMZ4Bcjs.sensitive; exports.sleep = _chunkP3B7HVFDcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkP3B7HVFDcjs.store; exports.validate = _chunkP3B7HVFDcjs.validate;
|
|
5279
5275
|
//# sourceMappingURL=index.cjs.map
|