@rotorsoft/act 1.34.3 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +11 -8
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +4 -2
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts +1 -6
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/projection-fold.d.ts +1 -1
- package/dist/@types/internal/projection-fold.d.ts.map +1 -1
- package/dist/@types/internal/tracing.d.ts.map +1 -1
- package/dist/@types/types/act.d.ts +5 -21
- package/dist/@types/types/act.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +34 -16
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/builders.d.ts +26 -30
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/@types/types/errors.d.ts +56 -29
- package/dist/@types/types/errors.d.ts.map +1 -1
- package/dist/{chunk-GBAMBUDN.cjs → chunk-BNTVE7RQ.cjs} +13 -13
- package/dist/{chunk-GBAMBUDN.cjs.map → chunk-BNTVE7RQ.cjs.map} +1 -1
- package/dist/{chunk-BKCNU6FF.js → chunk-DH2HW5XJ.js} +13 -4
- package/dist/chunk-DH2HW5XJ.js.map +1 -0
- package/dist/{chunk-RF5MV72K.cjs → chunk-L66OOP2F.cjs} +14 -5
- package/dist/chunk-L66OOP2F.cjs.map +1 -0
- package/dist/{chunk-IEM2NS6J.js → chunk-MHPUVTMX.js} +2 -2
- package/dist/index.cjs +233 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +76 -74
- 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 +4 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-BKCNU6FF.js.map +0 -1
- package/dist/chunk-RF5MV72K.cjs.map +0 -1
- /package/dist/{chunk-IEM2NS6J.js.map → chunk-MHPUVTMX.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkBNTVE7RQcjs = require('./chunk-BNTVE7RQ.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -70,24 +70,25 @@ var _chunkGBAMBUDNcjs = require('./chunk-GBAMBUDN.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
|
|
74
|
+
var _chunkL66OOP2Fcjs = require('./chunk-L66OOP2F.cjs');
|
|
74
75
|
|
|
75
76
|
// src/signals.ts
|
|
76
77
|
process.once("SIGINT", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
78
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
79
|
+
await _chunkBNTVE7RQcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
80
|
});
|
|
80
81
|
process.once("SIGTERM", async (arg) => {
|
|
81
|
-
|
|
82
|
-
await
|
|
82
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
83
|
+
await _chunkBNTVE7RQcjs.disposeAndExit.call(void 0, "EXIT");
|
|
83
84
|
});
|
|
84
85
|
process.once("uncaughtException", async (arg) => {
|
|
85
|
-
|
|
86
|
-
await
|
|
86
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
87
|
+
await _chunkBNTVE7RQcjs.disposeAndExit.call(void 0, "ERROR");
|
|
87
88
|
});
|
|
88
89
|
process.once("unhandledRejection", async (arg) => {
|
|
89
|
-
|
|
90
|
-
await
|
|
90
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
91
|
+
await _chunkBNTVE7RQcjs.disposeAndExit.call(void 0, "ERROR");
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
// src/act.ts
|
|
@@ -195,7 +196,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
195
196
|
if (need_stats) {
|
|
196
197
|
const stats = await deps.store().query_stats(
|
|
197
198
|
{},
|
|
198
|
-
{ count: true, names: true, exclude: [
|
|
199
|
+
{ count: true, names: true, exclude: [_chunkL66OOP2Fcjs.SNAP_EVENT] }
|
|
199
200
|
);
|
|
200
201
|
for (const [stream, s] of stats) {
|
|
201
202
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -277,7 +278,7 @@ var make_schema_pass = (deps) => {
|
|
|
277
278
|
return;
|
|
278
279
|
}
|
|
279
280
|
const schema = state2.events[name];
|
|
280
|
-
const sensitive2 =
|
|
281
|
+
const sensitive2 = _chunkL66OOP2Fcjs.pii_fields.call(void 0, schema);
|
|
281
282
|
let parse_schema = schema;
|
|
282
283
|
if (sensitive2.length > 0) {
|
|
283
284
|
const omitter = schema.omit;
|
|
@@ -411,7 +412,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
411
412
|
{
|
|
412
413
|
stream,
|
|
413
414
|
stream_exact: true,
|
|
414
|
-
names: [
|
|
415
|
+
names: [_chunkL66OOP2Fcjs.SNAP_EVENT],
|
|
415
416
|
with_snaps: true
|
|
416
417
|
}
|
|
417
418
|
);
|
|
@@ -840,7 +841,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
840
841
|
deps,
|
|
841
842
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
842
843
|
);
|
|
843
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
844
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkL66OOP2Fcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
844
845
|
if (retired.length) _optionalChain([deps, 'access', _42 => _42.forget_subscribed, 'optionalCall', _43 => _43(retired)]);
|
|
845
846
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
846
847
|
return { truncated, skipped };
|
|
@@ -922,7 +923,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
922
923
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
923
924
|
return void 0;
|
|
924
925
|
if (t.archive) await t.archive();
|
|
925
|
-
const result = await
|
|
926
|
+
const result = await _chunkBNTVE7RQcjs.store.call(void 0, ).truncate([
|
|
926
927
|
{ stream: t.stream, before: t.before, max_id }
|
|
927
928
|
]);
|
|
928
929
|
return result.get(t.stream);
|
|
@@ -935,10 +936,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
935
936
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
936
937
|
let boundary_id;
|
|
937
938
|
let min_id;
|
|
938
|
-
await
|
|
939
|
+
await _chunkBNTVE7RQcjs.store.call(void 0, ).query(
|
|
939
940
|
(event) => {
|
|
940
941
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
941
|
-
if (event.name ===
|
|
942
|
+
if (event.name === _chunkL66OOP2Fcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
942
943
|
boundary_id = event.id;
|
|
943
944
|
},
|
|
944
945
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -949,7 +950,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
949
950
|
const min_at = /* @__PURE__ */ new Map();
|
|
950
951
|
const matches = source_matcher();
|
|
951
952
|
await walk_streams(
|
|
952
|
-
|
|
953
|
+
_chunkBNTVE7RQcjs.store.call(void 0, ),
|
|
953
954
|
(position) => {
|
|
954
955
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
955
956
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -977,17 +978,17 @@ function source_matcher() {
|
|
|
977
978
|
};
|
|
978
979
|
}
|
|
979
980
|
async function scan_stream_heads(streams) {
|
|
980
|
-
const stats = await
|
|
981
|
-
exclude: [
|
|
981
|
+
const stats = await _chunkBNTVE7RQcjs.store.call(void 0, ).query_stats(streams, {
|
|
982
|
+
exclude: [_chunkL66OOP2Fcjs.SNAP_EVENT]
|
|
982
983
|
});
|
|
983
|
-
const domain_heads = await
|
|
984
|
-
exclude: [
|
|
984
|
+
const domain_heads = await _chunkBNTVE7RQcjs.store.call(void 0, ).query_stats(streams, {
|
|
985
|
+
exclude: [_chunkL66OOP2Fcjs.SNAP_EVENT, _chunkL66OOP2Fcjs.TOMBSTONE_EVENT]
|
|
985
986
|
});
|
|
986
|
-
const true_heads = await
|
|
987
|
+
const true_heads = await _chunkBNTVE7RQcjs.store.call(void 0, ).query_stats(streams, {});
|
|
987
988
|
const out = /* @__PURE__ */ new Map();
|
|
988
989
|
for (const [stream, { head }] of domain_heads) {
|
|
989
990
|
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]) ===
|
|
991
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunkL66OOP2Fcjs.TOMBSTONE_EVENT;
|
|
991
992
|
out.set(stream, {
|
|
992
993
|
max_id: head.id,
|
|
993
994
|
version: true_heads.get(stream).head.version,
|
|
@@ -1011,7 +1012,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
1011
1012
|
const matches = source_matcher();
|
|
1012
1013
|
const targets = [...stream_info.keys()];
|
|
1013
1014
|
await walk_streams(
|
|
1014
|
-
|
|
1015
|
+
_chunkBNTVE7RQcjs.store.call(void 0, ),
|
|
1015
1016
|
(position) => {
|
|
1016
1017
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
1017
1018
|
if (!has_work) return;
|
|
@@ -1077,7 +1078,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
1077
1078
|
}
|
|
1078
1079
|
}
|
|
1079
1080
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
1080
|
-
const heads = await
|
|
1081
|
+
const heads = await _chunkBNTVE7RQcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
1081
1082
|
return guarded.filter((stream) => {
|
|
1082
1083
|
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
1084
|
return true;
|
|
@@ -1095,18 +1096,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1095
1096
|
meta: {
|
|
1096
1097
|
correlation,
|
|
1097
1098
|
causation: {
|
|
1098
|
-
event: { id: guard.id, name:
|
|
1099
|
+
event: { id: guard.id, name: _chunkL66OOP2Fcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
1099
1100
|
}
|
|
1100
1101
|
}
|
|
1101
1102
|
};
|
|
1102
1103
|
});
|
|
1103
|
-
const truncated = await
|
|
1104
|
+
const truncated = await _chunkBNTVE7RQcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
1104
1105
|
await Promise.all(
|
|
1105
1106
|
guarded.map(async (stream) => {
|
|
1106
1107
|
const entry = truncated.get(stream);
|
|
1107
1108
|
const state2 = seed_states.get(stream);
|
|
1108
1109
|
if (state2 && entry) {
|
|
1109
|
-
await
|
|
1110
|
+
await _chunkBNTVE7RQcjs.cache.call(void 0, ).set(stream, {
|
|
1110
1111
|
stream,
|
|
1111
1112
|
state: state2,
|
|
1112
1113
|
version: entry.committed.version,
|
|
@@ -1115,7 +1116,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1115
1116
|
snaps: 1
|
|
1116
1117
|
});
|
|
1117
1118
|
} else {
|
|
1118
|
-
await
|
|
1119
|
+
await _chunkBNTVE7RQcjs.cache.call(void 0, ).invalidate(stream);
|
|
1119
1120
|
}
|
|
1120
1121
|
})
|
|
1121
1122
|
);
|
|
@@ -1129,7 +1130,7 @@ var _crypto = require('crypto');
|
|
|
1129
1130
|
function report_once(seen, key, message) {
|
|
1130
1131
|
if (seen.has(key)) return;
|
|
1131
1132
|
seen.add(key);
|
|
1132
|
-
|
|
1133
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).error(new Error(message));
|
|
1133
1134
|
}
|
|
1134
1135
|
|
|
1135
1136
|
// src/internal/correlate-cycle.ts
|
|
@@ -1180,7 +1181,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1180
1181
|
// never lets a resolution re-lane them.
|
|
1181
1182
|
|
|
1182
1183
|
__init11() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1183
|
-
__init12() {this._patterns = new (0,
|
|
1184
|
+
__init12() {this._patterns = new (0, _chunkBNTVE7RQcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1184
1185
|
|
|
1185
1186
|
|
|
1186
1187
|
|
|
@@ -1198,7 +1199,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1198
1199
|
on_init
|
|
1199
1200
|
}) {;_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
1201
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1201
|
-
this._dynamic_subscriptions = new (0,
|
|
1202
|
+
this._dynamic_subscriptions = new (0, _chunkBNTVE7RQcjs.LruMap)(max_subscribed_streams);
|
|
1202
1203
|
this._registry = registry;
|
|
1203
1204
|
this._declared_lanes = declared_lanes;
|
|
1204
1205
|
this._static_targets = static_targets;
|
|
@@ -1256,7 +1257,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1256
1257
|
/** Would the target's own `fetch` (filtered by `source`) return this event? */
|
|
1257
1258
|
_in_fetch_window(source, stream) {
|
|
1258
1259
|
if (source === void 0 || source === stream) return true;
|
|
1259
|
-
if (
|
|
1260
|
+
if (_chunkBNTVE7RQcjs.is_literal_source.call(void 0, source)) return false;
|
|
1260
1261
|
let pattern = this._patterns.get(source);
|
|
1261
1262
|
if (!pattern) {
|
|
1262
1263
|
pattern = new RegExp(source);
|
|
@@ -1265,9 +1266,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1265
1266
|
return pattern.test(stream);
|
|
1266
1267
|
}
|
|
1267
1268
|
/** Scan past the checkpoint, subscribe new targets and raise their work marks. */
|
|
1268
|
-
async correlate(
|
|
1269
|
+
async correlate(limit, lease = false) {
|
|
1269
1270
|
if (this._restoring) return { kind: "idle", last_id: this._checkpoint };
|
|
1270
|
-
const pass = this._scan(
|
|
1271
|
+
const pass = this._scan(limit, lease);
|
|
1271
1272
|
this._passes.add(pass);
|
|
1272
1273
|
try {
|
|
1273
1274
|
return await pass;
|
|
@@ -1275,7 +1276,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1275
1276
|
this._passes.delete(pass);
|
|
1276
1277
|
}
|
|
1277
1278
|
}
|
|
1278
|
-
async _scan(
|
|
1279
|
+
async _scan(limit, lease) {
|
|
1279
1280
|
await this._init();
|
|
1280
1281
|
const epoch = this._epoch;
|
|
1281
1282
|
const idle = () => ({
|
|
@@ -1299,7 +1300,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1299
1300
|
const correlated = /* @__PURE__ */ new Map();
|
|
1300
1301
|
let last_id = after;
|
|
1301
1302
|
let stopped = false;
|
|
1302
|
-
const found = await
|
|
1303
|
+
const found = await _chunkBNTVE7RQcjs.store.call(void 0, ).query(
|
|
1303
1304
|
(event) => {
|
|
1304
1305
|
if (stopped) return;
|
|
1305
1306
|
const register = this._registry.events[event.name];
|
|
@@ -1344,9 +1345,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1344
1345
|
correlated_at: void 0
|
|
1345
1346
|
};
|
|
1346
1347
|
const seen_in_scan = correlated.has(resolved.target);
|
|
1347
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => (
|
|
1348
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkL66OOP2Fcjs.DEFAULT_LANE));
|
|
1348
1349
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _62 => _62.priority]);
|
|
1349
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
1350
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkL66OOP2Fcjs.DEFAULT_LANE));
|
|
1350
1351
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1351
1352
|
report_lane_conflict(
|
|
1352
1353
|
this._reported,
|
|
@@ -1370,7 +1371,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1370
1371
|
},
|
|
1371
1372
|
// Resolvers see `pii: null`: correlate runs actor-less, and one
|
|
1372
1373
|
// undecryptable row would otherwise stop every stream's reactions.
|
|
1373
|
-
{ after, limit
|
|
1374
|
+
{ after, limit, with_pii: false }
|
|
1374
1375
|
);
|
|
1375
1376
|
if (this._declared_lanes.size > 1) await this._recall(correlated);
|
|
1376
1377
|
const read = last_id > after;
|
|
@@ -1409,7 +1410,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1409
1410
|
return { kind: "scanned", last_id, subscribed, marked, read };
|
|
1410
1411
|
}
|
|
1411
1412
|
this._checkpoint = last_id;
|
|
1412
|
-
if (!stopped && found !==
|
|
1413
|
+
if (!stopped && found !== limit) this._lowered = raised;
|
|
1413
1414
|
return { kind: "scanned", last_id, subscribed: 0, marked: 0, read };
|
|
1414
1415
|
}
|
|
1415
1416
|
/**
|
|
@@ -1422,7 +1423,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1422
1423
|
await Promise.all(
|
|
1423
1424
|
missed.map(async ([stream, entry]) => {
|
|
1424
1425
|
let row;
|
|
1425
|
-
await
|
|
1426
|
+
await _chunkBNTVE7RQcjs.store.call(void 0, ).query_streams(
|
|
1426
1427
|
(position) => {
|
|
1427
1428
|
row = position;
|
|
1428
1429
|
},
|
|
@@ -1434,8 +1435,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1434
1435
|
lane: row.lane
|
|
1435
1436
|
});
|
|
1436
1437
|
if (entry.priority > row.priority) return;
|
|
1437
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
1438
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
1438
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkL66OOP2Fcjs.DEFAULT_LANE));
|
|
1439
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkL66OOP2Fcjs.DEFAULT_LANE));
|
|
1439
1440
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
1440
1441
|
report_lane_conflict(
|
|
1441
1442
|
this._reported,
|
|
@@ -1461,7 +1462,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1461
1462
|
millis: 0
|
|
1462
1463
|
});
|
|
1463
1464
|
} catch (error) {
|
|
1464
|
-
|
|
1465
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).warn(
|
|
1465
1466
|
`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)}`
|
|
1466
1467
|
);
|
|
1467
1468
|
}
|
|
@@ -1614,14 +1615,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1614
1615
|
}
|
|
1615
1616
|
|
|
1616
1617
|
// src/internal/drain-ops.ts
|
|
1617
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1618
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkBNTVE7RQcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1618
1619
|
async function fetch(leased, eventLimit) {
|
|
1619
1620
|
return Promise.all(
|
|
1620
1621
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1621
1622
|
const events = [];
|
|
1622
|
-
const stream_exact = source !== void 0 &&
|
|
1623
|
+
const stream_exact = source !== void 0 && _chunkBNTVE7RQcjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1623
1624
|
try {
|
|
1624
|
-
await
|
|
1625
|
+
await _chunkBNTVE7RQcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1625
1626
|
stream: source,
|
|
1626
1627
|
stream_exact,
|
|
1627
1628
|
after: at,
|
|
@@ -1641,30 +1642,28 @@ async function fetch(leased, eventLimit) {
|
|
|
1641
1642
|
})
|
|
1642
1643
|
);
|
|
1643
1644
|
}
|
|
1644
|
-
var ack = (leases) =>
|
|
1645
|
-
var block = (leases) =>
|
|
1646
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1645
|
+
var ack = (leases) => _chunkBNTVE7RQcjs.store.call(void 0, ).ack(leases);
|
|
1646
|
+
var block = (leases) => _chunkBNTVE7RQcjs.store.call(void 0, ).block(leases);
|
|
1647
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkBNTVE7RQcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1647
1648
|
|
|
1648
1649
|
// src/internal/event-sourcing.ts
|
|
1649
1650
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1651
|
+
var _zod2 = require('zod');
|
|
1650
1652
|
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1651
|
-
var
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
next,
|
|
1656
|
-
me.state
|
|
1657
|
-
);
|
|
1653
|
+
var check_invariants = (target, state2, schema) => {
|
|
1654
|
+
const result = schema.safeParse(state2);
|
|
1655
|
+
if (!result.success)
|
|
1656
|
+
throw new (0, _chunkL66OOP2Fcjs.ValidationError)(target, state2, _zod2.prettifyError.call(void 0, result.error));
|
|
1658
1657
|
};
|
|
1659
1658
|
var DEFAULT_BATCH = 500;
|
|
1660
|
-
var cache_put = (stream, entry) =>
|
|
1661
|
-
(err) =>
|
|
1659
|
+
var cache_put = (stream, entry) => _chunkBNTVE7RQcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1660
|
+
(err) => _chunkBNTVE7RQcjs.log.call(void 0, ).warn(
|
|
1662
1661
|
err,
|
|
1663
1662
|
"cache set skipped; the next load re-folds from the store"
|
|
1664
1663
|
)
|
|
1665
1664
|
);
|
|
1666
|
-
var cache_drop = (stream) =>
|
|
1667
|
-
(err) =>
|
|
1665
|
+
var cache_drop = (stream) => _chunkBNTVE7RQcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1666
|
+
(err) => _chunkBNTVE7RQcjs.log.call(void 0, ).warn(
|
|
1668
1667
|
err,
|
|
1669
1668
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1670
1669
|
)
|
|
@@ -1672,9 +1671,9 @@ var cache_drop = (stream) => _chunkGBAMBUDNcjs.cache.call(void 0, ).invalidate(s
|
|
|
1672
1671
|
async function snap(snapshot) {
|
|
1673
1672
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1674
1673
|
try {
|
|
1675
|
-
const [committed] = await
|
|
1674
|
+
const [committed] = await _chunkBNTVE7RQcjs.store.call(void 0, ).commit(
|
|
1676
1675
|
stream,
|
|
1677
|
-
[{ name:
|
|
1676
|
+
[{ name: _chunkL66OOP2Fcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1678
1677
|
{
|
|
1679
1678
|
correlation: meta.correlation,
|
|
1680
1679
|
causation: { event: { id, name, stream } }
|
|
@@ -1685,22 +1684,22 @@ async function snap(snapshot) {
|
|
|
1685
1684
|
return committed;
|
|
1686
1685
|
} catch (error) {
|
|
1687
1686
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1688
|
-
|
|
1687
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).warn(
|
|
1689
1688
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1690
1689
|
);
|
|
1691
1690
|
}
|
|
1692
1691
|
}
|
|
1693
1692
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1694
1693
|
try {
|
|
1695
|
-
const [committed] = await
|
|
1694
|
+
const [committed] = await _chunkBNTVE7RQcjs.store.call(void 0, ).commit(
|
|
1696
1695
|
stream,
|
|
1697
|
-
[{ name:
|
|
1696
|
+
[{ name: _chunkL66OOP2Fcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1698
1697
|
{ correlation, causation: {} },
|
|
1699
1698
|
expectedVersion
|
|
1700
1699
|
);
|
|
1701
1700
|
return committed;
|
|
1702
1701
|
} catch (error) {
|
|
1703
|
-
if (error instanceof
|
|
1702
|
+
if (error instanceof _chunkL66OOP2Fcjs.ConcurrencyError) return void 0;
|
|
1704
1703
|
throw error;
|
|
1705
1704
|
}
|
|
1706
1705
|
}
|
|
@@ -1730,9 +1729,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1730
1729
|
if (drop_closed_streams) {
|
|
1731
1730
|
await source.query(
|
|
1732
1731
|
(e) => {
|
|
1733
|
-
if (e.name ===
|
|
1732
|
+
if (e.name === _chunkL66OOP2Fcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1734
1733
|
},
|
|
1735
|
-
{ names: [
|
|
1734
|
+
{ names: [_chunkL66OOP2Fcjs.TOMBSTONE_EVENT] }
|
|
1736
1735
|
);
|
|
1737
1736
|
}
|
|
1738
1737
|
let max_id;
|
|
@@ -1754,11 +1753,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1754
1753
|
if (!is_valid(event))
|
|
1755
1754
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1756
1755
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1757
|
-
if (drop_snapshots && event.name ===
|
|
1756
|
+
if (drop_snapshots && event.name === _chunkL66OOP2Fcjs.SNAP_EVENT) {
|
|
1758
1757
|
dropped_snaps++;
|
|
1759
1758
|
return;
|
|
1760
1759
|
}
|
|
1761
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1760
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkL66OOP2Fcjs.TOMBSTONE_EVENT) {
|
|
1762
1761
|
dropped_closed++;
|
|
1763
1762
|
return;
|
|
1764
1763
|
}
|
|
@@ -1825,17 +1824,17 @@ async function scan(source, opts = {}, callback) {
|
|
|
1825
1824
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1826
1825
|
const { stream, actor, asOf } = target;
|
|
1827
1826
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1828
|
-
const cached = time_travel ? void 0 : await
|
|
1827
|
+
const cached = time_travel ? void 0 : await _chunkBNTVE7RQcjs.cache.call(void 0, ).get(stream);
|
|
1829
1828
|
const cache_hit = !!cached;
|
|
1830
1829
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _72 => _72.state]), () => ( (me.init ? me.init() : {})));
|
|
1831
1830
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.patches]), () => ( 0));
|
|
1832
1831
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.snaps]), () => ( 0));
|
|
1833
1832
|
let replayed = 0;
|
|
1834
1833
|
let event;
|
|
1835
|
-
await
|
|
1834
|
+
await _chunkBNTVE7RQcjs.store.call(void 0, ).query(
|
|
1836
1835
|
(raw) => {
|
|
1837
1836
|
event = me.view(raw, actor);
|
|
1838
|
-
if (event.name ===
|
|
1837
|
+
if (event.name === _chunkL66OOP2Fcjs.SNAP_EVENT) {
|
|
1839
1838
|
state2 = event.data;
|
|
1840
1839
|
snaps++;
|
|
1841
1840
|
patches = 0;
|
|
@@ -1844,8 +1843,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1844
1843
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1845
1844
|
patches++;
|
|
1846
1845
|
replayed++;
|
|
1847
|
-
} else if (event.name !==
|
|
1848
|
-
|
|
1846
|
+
} else if (event.name !== _chunkL66OOP2Fcjs.TOMBSTONE_EVENT) {
|
|
1847
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).warn(
|
|
1849
1848
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1850
1849
|
);
|
|
1851
1850
|
}
|
|
@@ -1869,7 +1868,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1869
1868
|
...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
|
|
1870
1869
|
}
|
|
1871
1870
|
);
|
|
1872
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) ===
|
|
1871
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) === _chunkL66OOP2Fcjs.TOMBSTONE_EVENT;
|
|
1873
1872
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1874
1873
|
await cache_put(stream, {
|
|
1875
1874
|
stream,
|
|
@@ -1897,7 +1896,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1897
1896
|
if (!stream) throw new Error("Missing target stream");
|
|
1898
1897
|
const reactingTo = _optionalChain([options, 'optionalAccess', _81 => _81.reactingTo]);
|
|
1899
1898
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.correlator]), () => ( default_correlator));
|
|
1900
|
-
const validated =
|
|
1899
|
+
const validated = _chunkBNTVE7RQcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1901
1900
|
const opts = _optionalChain([me, 'access', _83 => _83.options, 'optionalAccess', _84 => _84[action2]]);
|
|
1902
1901
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries]), () => ( 0));
|
|
1903
1902
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1908,12 +1907,12 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1908
1907
|
void 0,
|
|
1909
1908
|
patch_fn
|
|
1910
1909
|
);
|
|
1911
|
-
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) ===
|
|
1912
|
-
throw new (0,
|
|
1910
|
+
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) === _chunkL66OOP2Fcjs.TOMBSTONE_EVENT)
|
|
1911
|
+
throw new (0, _chunkL66OOP2Fcjs.StreamClosedError)(stream);
|
|
1913
1912
|
const expected = _nullishCoalesce(expectedVersion, () => ( (snapshot.version >= 0 ? snapshot.version : void 0)));
|
|
1914
|
-
for (const { valid
|
|
1915
|
-
if (!
|
|
1916
|
-
throw new (0,
|
|
1913
|
+
for (const { valid, description } of _nullishCoalesce(_optionalChain([me, 'access', _88 => _88.given, 'optionalAccess', _89 => _89[action2]]), () => ( [])))
|
|
1914
|
+
if (!valid(snapshot.state, actor))
|
|
1915
|
+
throw new (0, _chunkL66OOP2Fcjs.InvariantError)(
|
|
1917
1916
|
action2,
|
|
1918
1917
|
validated,
|
|
1919
1918
|
target,
|
|
@@ -1922,25 +1921,22 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1922
1921
|
);
|
|
1923
1922
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _90 => _90.requires, 'optionalAccess', _91 => _91[action2]]), () => ( [])))
|
|
1924
1923
|
if (!holds(validated, snapshot.state, actor))
|
|
1925
|
-
throw new (0,
|
|
1924
|
+
throw new (0, _chunkL66OOP2Fcjs.PreconditionError)(
|
|
1926
1925
|
action2,
|
|
1927
1926
|
validated,
|
|
1928
1927
|
target,
|
|
1929
1928
|
snapshot,
|
|
1930
|
-
description
|
|
1931
|
-
"precondition"
|
|
1929
|
+
description
|
|
1932
1930
|
);
|
|
1933
1931
|
const result = me.on[action2](validated, snapshot, target);
|
|
1934
|
-
if (!result)
|
|
1935
|
-
if (Array.isArray(result) && result.length === 0) {
|
|
1932
|
+
if (!result || Array.isArray(result) && !result.length)
|
|
1936
1933
|
return [snapshot];
|
|
1937
|
-
}
|
|
1938
1934
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1939
|
-
const
|
|
1935
|
+
const events = tuples.map(([name, data]) => ({
|
|
1940
1936
|
name,
|
|
1941
|
-
data:
|
|
1937
|
+
data: _chunkBNTVE7RQcjs.validate.call(void 0, name, data, me.events[name])
|
|
1942
1938
|
}));
|
|
1943
|
-
const emitted =
|
|
1939
|
+
const emitted = events.map((e) => me.message(e));
|
|
1944
1940
|
const meta = {
|
|
1945
1941
|
correlation: _optionalChain([reactingTo, 'optionalAccess', _92 => _92.meta, 'access', _93 => _93.correlation]) || correlator({
|
|
1946
1942
|
action: action2,
|
|
@@ -1961,9 +1957,26 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1961
1957
|
} : void 0
|
|
1962
1958
|
}
|
|
1963
1959
|
};
|
|
1960
|
+
let { state: state2, patches } = snapshot;
|
|
1961
|
+
const created = /* @__PURE__ */ new Date();
|
|
1962
|
+
const folded = events.map((e, i) => {
|
|
1963
|
+
const event = {
|
|
1964
|
+
...e,
|
|
1965
|
+
id: -1,
|
|
1966
|
+
stream,
|
|
1967
|
+
version: snapshot.version + i + 1,
|
|
1968
|
+
created,
|
|
1969
|
+
meta
|
|
1970
|
+
};
|
|
1971
|
+
const patch2 = me.patch[event.name](event, state2);
|
|
1972
|
+
state2 = patch_fn(me, state2, patch2, event);
|
|
1973
|
+
patches++;
|
|
1974
|
+
return { state: state2, patch: patch2, patches };
|
|
1975
|
+
});
|
|
1976
|
+
check_invariants(`${me.name}.${action2}`, state2, me.state);
|
|
1964
1977
|
let committed;
|
|
1965
1978
|
try {
|
|
1966
|
-
committed = await
|
|
1979
|
+
committed = await _chunkBNTVE7RQcjs.store.call(void 0, ).commit(
|
|
1967
1980
|
stream,
|
|
1968
1981
|
emitted,
|
|
1969
1982
|
meta,
|
|
@@ -1972,27 +1985,20 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1972
1985
|
reactingTo ? expectedVersion : expected
|
|
1973
1986
|
);
|
|
1974
1987
|
} catch (error) {
|
|
1975
|
-
if (error instanceof
|
|
1988
|
+
if (error instanceof _chunkL66OOP2Fcjs.ConcurrencyError) void cache_drop(stream);
|
|
1976
1989
|
throw error;
|
|
1977
1990
|
}
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
patches
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
patches,
|
|
1990
|
-
snaps: snapshot.snaps,
|
|
1991
|
-
patch: p,
|
|
1992
|
-
cache_hit: snapshot.cache_hit,
|
|
1993
|
-
replayed: snapshot.replayed
|
|
1994
|
-
};
|
|
1995
|
-
});
|
|
1991
|
+
const snapshots = committed.map((row, i) => ({
|
|
1992
|
+
event: { ...row, data: events[i].data },
|
|
1993
|
+
state: folded[i].state,
|
|
1994
|
+
version: row.version,
|
|
1995
|
+
id: row.id,
|
|
1996
|
+
patches: folded[i].patches,
|
|
1997
|
+
snaps: snapshot.snaps,
|
|
1998
|
+
patch: folded[i].patch,
|
|
1999
|
+
cache_hit: snapshot.cache_hit,
|
|
2000
|
+
replayed: snapshot.replayed
|
|
2001
|
+
}));
|
|
1996
2002
|
const last = snapshots.at(-1);
|
|
1997
2003
|
const contiguous = committed[0].version === snapshot.version + 1;
|
|
1998
2004
|
const snapped = contiguous && _optionalChain([me, 'access', _94 => _94.snap, 'optionalCall', _95 => _95(last)]);
|
|
@@ -2011,19 +2017,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
2011
2017
|
}
|
|
2012
2018
|
return snapshots;
|
|
2013
2019
|
} catch (error) {
|
|
2014
|
-
if (!(error instanceof
|
|
2020
|
+
if (!(error instanceof _chunkL66OOP2Fcjs.ConcurrencyError)) throw error;
|
|
2015
2021
|
if (expectedVersion !== void 0) throw error;
|
|
2016
2022
|
if (attempt >= max_retries) throw error;
|
|
2017
2023
|
if (_optionalChain([opts, 'optionalAccess', _98 => _98.backoff])) {
|
|
2018
2024
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
2019
|
-
if (delay_ms > 0) await
|
|
2025
|
+
if (delay_ms > 0) await _chunkBNTVE7RQcjs.sleep.call(void 0, delay_ms);
|
|
2020
2026
|
}
|
|
2021
2027
|
}
|
|
2022
2028
|
}
|
|
2023
2029
|
}
|
|
2024
2030
|
|
|
2025
2031
|
// src/internal/tracing.ts
|
|
2026
|
-
var PRETTY =
|
|
2032
|
+
var PRETTY = _chunkBNTVE7RQcjs.config.call(void 0, ).env !== "production";
|
|
2027
2033
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2028
2034
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2029
2035
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2209,7 +2215,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2209
2215
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _108 => _108.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2210
2216
|
return void 0;
|
|
2211
2217
|
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.`;
|
|
2212
|
-
|
|
2218
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).error(error);
|
|
2213
2219
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2214
2220
|
}
|
|
2215
2221
|
function fetch_failure_policy(registry) {
|
|
@@ -2225,13 +2231,13 @@ function fetch_failure_policy(registry) {
|
|
|
2225
2231
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
2226
2232
|
if (!error) return { lease, handled, acked_at: at };
|
|
2227
2233
|
logger.error(error);
|
|
2228
|
-
const non_retryable = error instanceof
|
|
2234
|
+
const non_retryable = error instanceof _chunkL66OOP2Fcjs.NonRetryableError;
|
|
2229
2235
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2230
2236
|
if (block2)
|
|
2231
2237
|
logger.error(
|
|
2232
2238
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2233
2239
|
);
|
|
2234
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2240
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkBNTVE7RQcjs.DEFAULT_BACKOFF)));
|
|
2235
2241
|
return {
|
|
2236
2242
|
lease,
|
|
2237
2243
|
handled,
|
|
@@ -2359,7 +2365,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2359
2365
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2360
2366
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2361
2367
|
if (acked.length < expected)
|
|
2362
|
-
|
|
2368
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).warn(
|
|
2363
2369
|
`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.`
|
|
2364
2370
|
);
|
|
2365
2371
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2459,9 +2465,9 @@ var DrainController = (_class5 = class {
|
|
|
2459
2465
|
if (!this.armed || this._stopped || this._inflight)
|
|
2460
2466
|
return EMPTY_DRAIN;
|
|
2461
2467
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2462
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2463
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2464
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2468
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkBNTVE7RQcjs.DEFAULT_STREAM_LIMIT));
|
|
2469
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkBNTVE7RQcjs.DEFAULT_EVENT_LIMIT));
|
|
2470
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkBNTVE7RQcjs.DEFAULT_LEASE_MILLIS));
|
|
2465
2471
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2466
2472
|
return EMPTY_DRAIN;
|
|
2467
2473
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2536,7 +2542,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2536
2542
|
const { pii, ...rest } = event;
|
|
2537
2543
|
if (pii == null) {
|
|
2538
2544
|
const shredded = { ...data };
|
|
2539
|
-
for (const f of fields) shredded[f] =
|
|
2545
|
+
for (const f of fields) shredded[f] = _chunkL66OOP2Fcjs.SHREDDED;
|
|
2540
2546
|
return { ...rest, data: shredded };
|
|
2541
2547
|
}
|
|
2542
2548
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2547,7 +2553,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2547
2553
|
};
|
|
2548
2554
|
}
|
|
2549
2555
|
const redacted = { ...data };
|
|
2550
|
-
for (const f of fields) redacted[f] =
|
|
2556
|
+
for (const f of fields) redacted[f] = _chunkL66OOP2Fcjs.REDACTED;
|
|
2551
2557
|
return { ...rest, data: redacted };
|
|
2552
2558
|
}
|
|
2553
2559
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2569,7 +2575,7 @@ function pii_strip(event, fields) {
|
|
|
2569
2575
|
|
|
2570
2576
|
// src/internal/projection-fold.ts
|
|
2571
2577
|
var FOLD_RESET = /* @__PURE__ */ Symbol("act.fold.reset");
|
|
2572
|
-
function make_fold_handler(me, flush, config2, patch_fn
|
|
2578
|
+
function make_fold_handler(me, flush, config2, patch_fn, sensitive_fields) {
|
|
2573
2579
|
const load_me = {
|
|
2574
2580
|
...me,
|
|
2575
2581
|
view: (raw, actor) => {
|
|
@@ -2655,7 +2661,7 @@ function make_fold_handler(me, flush, config2, patch_fn = bare_patch, sensitive_
|
|
|
2655
2661
|
}
|
|
2656
2662
|
|
|
2657
2663
|
// src/internal/defer-config.ts
|
|
2658
|
-
|
|
2664
|
+
|
|
2659
2665
|
var DeferDurationSchema = _zod2.z.object({
|
|
2660
2666
|
days: _zod2.z.number().positive().optional(),
|
|
2661
2667
|
hours: _zod2.z.number().positive().optional(),
|
|
@@ -2684,7 +2690,7 @@ function make_deferred(handler, schedule) {
|
|
|
2684
2690
|
const call = handler;
|
|
2685
2691
|
const deferred = async (event, stream, app) => {
|
|
2686
2692
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2687
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2693
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkL66OOP2Fcjs.DeferSignal)(when);
|
|
2688
2694
|
return call(event, stream, app);
|
|
2689
2695
|
};
|
|
2690
2696
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2753,7 +2759,7 @@ function build_handle(deps) {
|
|
|
2753
2759
|
handled++;
|
|
2754
2760
|
}
|
|
2755
2761
|
} catch (error) {
|
|
2756
|
-
if (error instanceof
|
|
2762
|
+
if (error instanceof _chunkL66OOP2Fcjs.DeferSignal) {
|
|
2757
2763
|
let defer;
|
|
2758
2764
|
try {
|
|
2759
2765
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2933,10 +2939,8 @@ var SettleLoop = (_class6 = class {
|
|
|
2933
2939
|
}, _class6);
|
|
2934
2940
|
|
|
2935
2941
|
// src/act.ts
|
|
2936
|
-
function validate_only_lanes(
|
|
2937
|
-
|
|
2938
|
-
const declared = /* @__PURE__ */ new Set(["default", ...lanes.map((l) => l.name)]);
|
|
2939
|
-
const unknown = options.onlyLanes.filter((l) => !declared.has(l));
|
|
2942
|
+
function validate_only_lanes(only, declared) {
|
|
2943
|
+
const unknown = (_nullishCoalesce(only, () => ( []))).filter((l) => !declared.includes(l));
|
|
2940
2944
|
if (unknown.length > 0)
|
|
2941
2945
|
throw new Error(
|
|
2942
2946
|
`ActOptions.onlyLanes references undeclared lane(s): ${unknown.map((l) => `"${l}"`).join(", ")}`
|
|
@@ -3019,7 +3023,7 @@ var Act = (_class7 = class {
|
|
|
3019
3023
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
3020
3024
|
|
|
3021
3025
|
|
|
3022
|
-
__init27() {this._logger =
|
|
3026
|
+
__init27() {this._logger = _chunkBNTVE7RQcjs.log.call(void 0, )}
|
|
3023
3027
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3024
3028
|
|
|
3025
3029
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3040,10 +3044,10 @@ var Act = (_class7 = class {
|
|
|
3040
3044
|
this._batch_handlers = batch_handlers;
|
|
3041
3045
|
this._lanes = lanes;
|
|
3042
3046
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3043
|
-
validate_only_lanes(options,
|
|
3044
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3047
|
+
validate_only_lanes(options.onlyLanes, this._declared_lanes);
|
|
3048
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkBNTVE7RQcjs.default_scope.call(void 0, )));
|
|
3045
3049
|
const ports = this._ports;
|
|
3046
|
-
this._scoped =
|
|
3050
|
+
this._scoped = _chunkBNTVE7RQcjs.make_run_scoped.call(void 0, {
|
|
3047
3051
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3048
3052
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3049
3053
|
get store() {
|
|
@@ -3053,14 +3057,14 @@ var Act = (_class7 = class {
|
|
|
3053
3057
|
return ports.cache;
|
|
3054
3058
|
},
|
|
3055
3059
|
// Parsed per build, so a bad window throws on every build.
|
|
3056
|
-
autoclose_window:
|
|
3060
|
+
autoclose_window: _chunkBNTVE7RQcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3057
3061
|
});
|
|
3058
3062
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3059
3063
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3060
3064
|
this._cd = build_drain(this._logger);
|
|
3061
3065
|
const handle = build_handle({
|
|
3062
3066
|
logger: this._logger,
|
|
3063
|
-
reaction_scope:
|
|
3067
|
+
reaction_scope: _chunkBNTVE7RQcjs.make_reaction_scope.call(void 0, {
|
|
3064
3068
|
do: this.do.bind(this),
|
|
3065
3069
|
load: this.load.bind(this),
|
|
3066
3070
|
query: this.query.bind(this),
|
|
@@ -3082,7 +3086,7 @@ var Act = (_class7 = class {
|
|
|
3082
3086
|
handle,
|
|
3083
3087
|
handle_batch
|
|
3084
3088
|
);
|
|
3085
|
-
this._advise_orphaned_lanes(
|
|
3089
|
+
this._advise_orphaned_lanes();
|
|
3086
3090
|
this._audit_deps = this._build_audit_deps();
|
|
3087
3091
|
this._correlate = this._build_correlate(options, classification);
|
|
3088
3092
|
this._settle = this._build_settle(options);
|
|
@@ -3090,12 +3094,12 @@ var Act = (_class7 = class {
|
|
|
3090
3094
|
this._ports.store,
|
|
3091
3095
|
options.listen !== false
|
|
3092
3096
|
);
|
|
3093
|
-
|
|
3097
|
+
_chunkBNTVE7RQcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3094
3098
|
}
|
|
3095
3099
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3096
3100
|
_build_breaker(options) {
|
|
3097
3101
|
return new CircuitBreaker(
|
|
3098
|
-
|
|
3102
|
+
_chunkBNTVE7RQcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3099
3103
|
{
|
|
3100
3104
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3101
3105
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3107,7 +3111,7 @@ var Act = (_class7 = class {
|
|
|
3107
3111
|
/** Apps that declare no lanes pass no lane filter to `claim`. */
|
|
3108
3112
|
_build_drain_controllers(options, lanes, handle, handle_batch) {
|
|
3109
3113
|
const all_lanes = this._declared_lanes;
|
|
3110
|
-
const only_set = options.onlyLanes
|
|
3114
|
+
const only_set = _optionalChain([options, 'access', _127 => _127.onlyLanes, 'optionalAccess', _128 => _128.length]) ? new Set(options.onlyLanes) : void 0;
|
|
3111
3115
|
const active_lanes = only_set ? all_lanes.filter((n) => only_set.has(n)) : all_lanes;
|
|
3112
3116
|
const single_default_lane = lanes.length === 0;
|
|
3113
3117
|
const controllers = /* @__PURE__ */ new Map();
|
|
@@ -3129,7 +3133,7 @@ var Act = (_class7 = class {
|
|
|
3129
3133
|
try {
|
|
3130
3134
|
await this._run_close(targets);
|
|
3131
3135
|
} catch (error) {
|
|
3132
|
-
if (error instanceof
|
|
3136
|
+
if (error instanceof _chunkL66OOP2Fcjs.StoreError) throw error;
|
|
3133
3137
|
this._logger.error(
|
|
3134
3138
|
error,
|
|
3135
3139
|
`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.`
|
|
@@ -3144,15 +3148,14 @@ var Act = (_class7 = class {
|
|
|
3144
3148
|
leaseMillis: cfg.leaseMillis
|
|
3145
3149
|
}
|
|
3146
3150
|
});
|
|
3147
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
3151
|
+
if (_optionalChain([cfg, 'optionalAccess', _129 => _129.cycleMs]) !== void 0 && this._drain)
|
|
3148
3152
|
controller.start(cfg.cycleMs);
|
|
3149
3153
|
controllers.set(name, controller);
|
|
3150
3154
|
}
|
|
3151
3155
|
return controllers;
|
|
3152
3156
|
}
|
|
3153
3157
|
/** One process can't see the cluster, so it reports its own lane gaps. */
|
|
3154
|
-
_advise_orphaned_lanes(
|
|
3155
|
-
if (!options.onlyLanes || options.onlyLanes.length === 0) return;
|
|
3158
|
+
_advise_orphaned_lanes() {
|
|
3156
3159
|
const active = new Set(this._drain_controllers.keys());
|
|
3157
3160
|
const orphaned = this._declared_lanes.filter((name) => !active.has(name));
|
|
3158
3161
|
if (orphaned.length === 0) return;
|
|
@@ -3164,7 +3167,7 @@ var Act = (_class7 = class {
|
|
|
3164
3167
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3165
3168
|
_build_audit_deps() {
|
|
3166
3169
|
return {
|
|
3167
|
-
store:
|
|
3170
|
+
store: _chunkBNTVE7RQcjs.store,
|
|
3168
3171
|
event_to_state: this._event_to_state,
|
|
3169
3172
|
// Declared lanes, not this process's controllers: a lane another
|
|
3170
3173
|
// worker drains is not `unknown-lane`.
|
|
@@ -3177,7 +3180,7 @@ var Act = (_class7 = class {
|
|
|
3177
3180
|
registry: this.registry,
|
|
3178
3181
|
static_targets: classification.static_targets,
|
|
3179
3182
|
cd: this._cd,
|
|
3180
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3183
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkL66OOP2Fcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3181
3184
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3182
3185
|
// still a valid destination.
|
|
3183
3186
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3193,26 +3196,23 @@ var Act = (_class7 = class {
|
|
|
3193
3196
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3194
3197
|
async _seed_persisted_defers() {
|
|
3195
3198
|
const now = Date.now();
|
|
3196
|
-
await walk_streams(
|
|
3199
|
+
await walk_streams(_chunkBNTVE7RQcjs.store.call(void 0, ), (pos) => {
|
|
3197
3200
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3198
3201
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3199
|
-
_optionalChain([controller, 'optionalAccess',
|
|
3202
|
+
_optionalChain([controller, 'optionalAccess', _130 => _130.seed_defer, 'call', _131 => _131(pos.stream, pos.deferred_at)]);
|
|
3200
3203
|
});
|
|
3201
3204
|
}
|
|
3202
3205
|
_build_settle(options) {
|
|
3203
3206
|
return new SettleLoop(
|
|
3204
3207
|
{
|
|
3205
|
-
correlate: (q) => this._correlate_pass(
|
|
3206
|
-
{ ...q, limit: _nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)) },
|
|
3207
|
-
true
|
|
3208
|
-
),
|
|
3208
|
+
correlate: (q) => this._correlate_pass(_nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)), true),
|
|
3209
3209
|
// `settle()` validated the options, and `_schedule` skips writer-only
|
|
3210
3210
|
// instances, so the loop drains through the internal path.
|
|
3211
3211
|
drain: (o) => this._scoped(() => this._drain_all(o)),
|
|
3212
3212
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3213
3213
|
breaker: this._breaker
|
|
3214
3214
|
},
|
|
3215
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3215
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkL66OOP2Fcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3216
3216
|
);
|
|
3217
3217
|
}
|
|
3218
3218
|
|
|
@@ -3232,7 +3232,7 @@ var Act = (_class7 = class {
|
|
|
3232
3232
|
*/
|
|
3233
3233
|
shutdown(options) {
|
|
3234
3234
|
if (!this._shutdown_promise) {
|
|
3235
|
-
|
|
3235
|
+
_chunkBNTVE7RQcjs.resolveShutdownConfig.call(void 0, options);
|
|
3236
3236
|
this._shutdown_promise = (async () => {
|
|
3237
3237
|
this.stop_correlations();
|
|
3238
3238
|
this._settle.stop(true);
|
|
@@ -3240,7 +3240,7 @@ var Act = (_class7 = class {
|
|
|
3240
3240
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3241
3241
|
const disposer = await this._notify_disposer;
|
|
3242
3242
|
if (disposer) await disposer();
|
|
3243
|
-
await this._await_inflight(_optionalChain([options, 'optionalAccess',
|
|
3243
|
+
await this._await_inflight(_optionalChain([options, 'optionalAccess', _132 => _132.graceMs]));
|
|
3244
3244
|
await this._scoped(() => this._correlate.release_correlation());
|
|
3245
3245
|
this._emitter.removeAllListeners();
|
|
3246
3246
|
})();
|
|
@@ -3252,10 +3252,10 @@ var Act = (_class7 = class {
|
|
|
3252
3252
|
* default for none or 0, and for a running settle), capped.
|
|
3253
3253
|
*/
|
|
3254
3254
|
_derive_grace_ms(running, settling) {
|
|
3255
|
-
let max = settling ?
|
|
3255
|
+
let max = settling ? _chunkBNTVE7RQcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3256
3256
|
for (const c of running)
|
|
3257
|
-
max = Math.max(max, c.lease_millis ||
|
|
3258
|
-
return Math.min(max,
|
|
3257
|
+
max = Math.max(max, c.lease_millis || _chunkBNTVE7RQcjs.DEFAULT_LEASE_MILLIS);
|
|
3258
|
+
return Math.min(max, _chunkBNTVE7RQcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3259
3259
|
}
|
|
3260
3260
|
async _await_inflight(grace_ms) {
|
|
3261
3261
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3300,9 +3300,10 @@ var Act = (_class7 = class {
|
|
|
3300
3300
|
}
|
|
3301
3301
|
/**
|
|
3302
3302
|
* Executes an action: validates the payload, loads the state, checks its
|
|
3303
|
-
*
|
|
3304
|
-
*
|
|
3305
|
-
*
|
|
3303
|
+
* preconditions, runs the handler, folds the events it emits, checks the
|
|
3304
|
+
* state's invariants (its schema) on the result, and commits them with
|
|
3305
|
+
* optimistic concurrency on the stream. The reactions to those events
|
|
3306
|
+
* settle on their own (unless `autoSettle: false`).
|
|
3306
3307
|
*
|
|
3307
3308
|
* @template TKey - Action name from registered actions
|
|
3308
3309
|
* @param action - The name of the action to execute
|
|
@@ -3313,8 +3314,9 @@ var Act = (_class7 = class {
|
|
|
3313
3314
|
* framework or orchestrator-level correlator for this call only.
|
|
3314
3315
|
* @returns Array of snapshots for all affected states (usually one)
|
|
3315
3316
|
*
|
|
3316
|
-
* @throws {ValidationError} If payload doesn't match action schema
|
|
3317
|
-
*
|
|
3317
|
+
* @throws {ValidationError} If the payload doesn't match the action schema,
|
|
3318
|
+
* or the state the action leaves breaks the state schema
|
|
3319
|
+
* @throws {PreconditionError} If business rules are violated
|
|
3318
3320
|
* @throws {ConcurrencyError} If another process modified the stream
|
|
3319
3321
|
*
|
|
3320
3322
|
* @example Basic action execution
|
|
@@ -3333,11 +3335,11 @@ var Act = (_class7 = class {
|
|
|
3333
3335
|
*
|
|
3334
3336
|
* @see {@link Target} for target structure
|
|
3335
3337
|
* @see {@link Snapshot} for return value structure
|
|
3336
|
-
* @see {@link ValidationError}, {@link
|
|
3338
|
+
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3337
3339
|
*/
|
|
3338
3340
|
async do(action2, target, payload, options) {
|
|
3339
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3340
|
-
const do_options = reacting_to === _optionalChain([options, 'optionalAccess',
|
|
3341
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _133 => _133.reactingTo]), () => ( _chunkBNTVE7RQcjs.current_reacting.call(void 0, )));
|
|
3342
|
+
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _134 => _134.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3341
3343
|
return this._scoped(async () => {
|
|
3342
3344
|
const snapshots = await this._es.action(
|
|
3343
3345
|
this.registry.actions[action2],
|
|
@@ -3397,11 +3399,11 @@ var Act = (_class7 = class {
|
|
|
3397
3399
|
return this._scoped(async () => {
|
|
3398
3400
|
let first;
|
|
3399
3401
|
let last;
|
|
3400
|
-
const count = await
|
|
3402
|
+
const count = await _chunkBNTVE7RQcjs.store.call(void 0, ).query((e) => {
|
|
3401
3403
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3402
3404
|
if (!first) first = gated;
|
|
3403
3405
|
last = gated;
|
|
3404
|
-
_optionalChain([callback, 'optionalCall',
|
|
3406
|
+
_optionalChain([callback, 'optionalCall', _135 => _135(gated)]);
|
|
3405
3407
|
}, query);
|
|
3406
3408
|
return { first, last, count };
|
|
3407
3409
|
});
|
|
@@ -3427,7 +3429,7 @@ var Act = (_class7 = class {
|
|
|
3427
3429
|
async query_array(query) {
|
|
3428
3430
|
return this._scoped(async () => {
|
|
3429
3431
|
const events = [];
|
|
3430
|
-
await
|
|
3432
|
+
await _chunkBNTVE7RQcjs.store.call(void 0, ).query((e) => {
|
|
3431
3433
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3432
3434
|
}, query);
|
|
3433
3435
|
return events;
|
|
@@ -3447,14 +3449,14 @@ var Act = (_class7 = class {
|
|
|
3447
3449
|
*/
|
|
3448
3450
|
async forget(stream) {
|
|
3449
3451
|
return this._scoped(async () => {
|
|
3450
|
-
const s =
|
|
3452
|
+
const s = _chunkBNTVE7RQcjs.store.call(void 0, );
|
|
3451
3453
|
if (!s.forget_pii) {
|
|
3452
3454
|
throw new Error(
|
|
3453
3455
|
`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).`
|
|
3454
3456
|
);
|
|
3455
3457
|
}
|
|
3456
3458
|
const eventCount = await s.forget_pii(stream);
|
|
3457
|
-
await
|
|
3459
|
+
await _chunkBNTVE7RQcjs.cache.call(void 0, ).invalidate(stream);
|
|
3458
3460
|
if (eventCount > 0) {
|
|
3459
3461
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3460
3462
|
}
|
|
@@ -3488,7 +3490,7 @@ var Act = (_class7 = class {
|
|
|
3488
3490
|
* @see {@link correlate} for dynamic stream discovery
|
|
3489
3491
|
*/
|
|
3490
3492
|
async drain(options = {}) {
|
|
3491
|
-
|
|
3493
|
+
_chunkBNTVE7RQcjs.resolveDrainConfig.call(void 0, options);
|
|
3492
3494
|
if (!this._drain)
|
|
3493
3495
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3494
3496
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3528,7 +3530,7 @@ var Act = (_class7 = class {
|
|
|
3528
3530
|
}
|
|
3529
3531
|
if (to_arm.size === 0) return false;
|
|
3530
3532
|
this._correlate.arm();
|
|
3531
|
-
for (const lane of to_arm) _optionalChain([this, 'access',
|
|
3533
|
+
for (const lane of to_arm) _optionalChain([this, 'access', _136 => _136._drain_controllers, 'access', _137 => _137.get, 'call', _138 => _138(lane), 'optionalAccess', _139 => _139.arm, 'call', _140 => _140()]);
|
|
3532
3534
|
return true;
|
|
3533
3535
|
}
|
|
3534
3536
|
/** In parallel, so a slow lane never holds up a fast one. */
|
|
@@ -3567,17 +3569,17 @@ var Act = (_class7 = class {
|
|
|
3567
3569
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3568
3570
|
*/
|
|
3569
3571
|
async correlate(query = {}) {
|
|
3570
|
-
const pass = await this._correlate_pass(
|
|
3572
|
+
const pass = await this._correlate_pass(_nullishCoalesce(query.limit, () => ( 10)));
|
|
3571
3573
|
return {
|
|
3572
3574
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
3573
3575
|
last_id: pass.last_id
|
|
3574
3576
|
};
|
|
3575
3577
|
}
|
|
3576
3578
|
/** One correlate pass; arms every lane when it found work. */
|
|
3577
|
-
async _correlate_pass(
|
|
3579
|
+
async _correlate_pass(limit, lease = false) {
|
|
3578
3580
|
if (!this._drain) return { kind: "idle", last_id: -1 };
|
|
3579
3581
|
return this._scoped(async () => {
|
|
3580
|
-
const pass = await this._correlate.correlate(
|
|
3582
|
+
const pass = await this._correlate.correlate(limit, lease);
|
|
3581
3583
|
if (pass.kind === "scanned" && pass.marked > 0) this._arm_all();
|
|
3582
3584
|
return pass;
|
|
3583
3585
|
});
|
|
@@ -3595,8 +3597,9 @@ var Act = (_class7 = class {
|
|
|
3595
3597
|
* (`drain: false`) each tick is a no-op, like `settle()`.
|
|
3596
3598
|
*
|
|
3597
3599
|
* @param query - Only `limit` is used: the most events each correlate pass
|
|
3598
|
-
* reads
|
|
3599
|
-
*
|
|
3600
|
+
* reads. With no limit, or `0`, the passes use the background default
|
|
3601
|
+
* (100): a poll never reads the whole log in one tick. The scan always
|
|
3602
|
+
* starts at the correlation checkpoint, so `after` is ignored.
|
|
3600
3603
|
* @param frequency - Milliseconds between ticks (default: 10000)
|
|
3601
3604
|
* @returns `true` if the poll started, `false` if one is already running
|
|
3602
3605
|
*
|
|
@@ -3669,9 +3672,9 @@ var Act = (_class7 = class {
|
|
|
3669
3672
|
*/
|
|
3670
3673
|
async reset(input) {
|
|
3671
3674
|
return this._scoped(async () => {
|
|
3672
|
-
const count = await
|
|
3675
|
+
const count = await _chunkBNTVE7RQcjs.store.call(void 0, ).reset(input);
|
|
3673
3676
|
for (const handler of this._batch_handlers.values())
|
|
3674
|
-
_optionalChain([handler, 'access',
|
|
3677
|
+
_optionalChain([handler, 'access', _141 => _141[FOLD_RESET], 'optionalCall', _142 => _142()]);
|
|
3675
3678
|
if (count > 0) {
|
|
3676
3679
|
this._wake();
|
|
3677
3680
|
}
|
|
@@ -3705,7 +3708,7 @@ var Act = (_class7 = class {
|
|
|
3705
3708
|
*/
|
|
3706
3709
|
async unblock(input) {
|
|
3707
3710
|
return this._scoped(async () => {
|
|
3708
|
-
const count = await
|
|
3711
|
+
const count = await _chunkBNTVE7RQcjs.store.call(void 0, ).unblock(input);
|
|
3709
3712
|
if (count > 0) {
|
|
3710
3713
|
this._wake();
|
|
3711
3714
|
}
|
|
@@ -3760,7 +3763,7 @@ var Act = (_class7 = class {
|
|
|
3760
3763
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3761
3764
|
}
|
|
3762
3765
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3763
|
-
const s =
|
|
3766
|
+
const s = _chunkBNTVE7RQcjs.store.call(void 0, );
|
|
3764
3767
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3765
3768
|
return s;
|
|
3766
3769
|
})()));
|
|
@@ -3806,11 +3809,11 @@ var Act = (_class7 = class {
|
|
|
3806
3809
|
async blocked_streams(options) {
|
|
3807
3810
|
return this._scoped(async () => {
|
|
3808
3811
|
const positions = [];
|
|
3809
|
-
await
|
|
3812
|
+
await _chunkBNTVE7RQcjs.store.call(void 0, ).query_streams(
|
|
3810
3813
|
(p) => {
|
|
3811
3814
|
positions.push(p);
|
|
3812
3815
|
},
|
|
3813
|
-
{ blocked: true, after: _optionalChain([options, 'optionalAccess',
|
|
3816
|
+
{ blocked: true, after: _optionalChain([options, 'optionalAccess', _143 => _143.after]), limit: _optionalChain([options, 'optionalAccess', _144 => _144.limit]) }
|
|
3814
3817
|
);
|
|
3815
3818
|
return positions;
|
|
3816
3819
|
});
|
|
@@ -3858,7 +3861,7 @@ var Act = (_class7 = class {
|
|
|
3858
3861
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3859
3862
|
*/
|
|
3860
3863
|
async prioritize(filter, priority) {
|
|
3861
|
-
return this._scoped(() =>
|
|
3864
|
+
return this._scoped(() => _chunkBNTVE7RQcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3862
3865
|
}
|
|
3863
3866
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3864
3867
|
async _run_close(targets) {
|
|
@@ -3938,7 +3941,7 @@ var Act = (_class7 = class {
|
|
|
3938
3941
|
* @see {@link correlate} for manual correlation
|
|
3939
3942
|
*/
|
|
3940
3943
|
settle(options) {
|
|
3941
|
-
|
|
3944
|
+
_chunkBNTVE7RQcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3942
3945
|
this._schedule(options);
|
|
3943
3946
|
}
|
|
3944
3947
|
}, _class7);
|
|
@@ -4004,12 +4007,12 @@ function policy_min_after_days(options) {
|
|
|
4004
4007
|
const parsed = AutoclosePolicySchema.parse(options);
|
|
4005
4008
|
const windows = [];
|
|
4006
4009
|
if (parsed.after) windows.push(parsed.after.days);
|
|
4007
|
-
if (_optionalChain([parsed, 'access',
|
|
4010
|
+
if (_optionalChain([parsed, 'access', _145 => _145.or, 'optionalAccess', _146 => _146.after])) windows.push(parsed.or.after.days);
|
|
4008
4011
|
return windows.length ? Math.min(...windows) : void 0;
|
|
4009
4012
|
}
|
|
4010
4013
|
function policy_keep_days(options) {
|
|
4011
4014
|
const parsed = AutoclosePolicySchema.parse(options);
|
|
4012
|
-
return _optionalChain([parsed, 'access',
|
|
4015
|
+
return _optionalChain([parsed, 'access', _147 => _147.keep, 'optionalAccess', _148 => _148.days]);
|
|
4013
4016
|
}
|
|
4014
4017
|
function compile_autoclose_policy(options) {
|
|
4015
4018
|
const parsed = AutoclosePolicySchema.parse(options);
|
|
@@ -4041,7 +4044,7 @@ function hour_in_zone(now, timeZone) {
|
|
|
4041
4044
|
hour: "2-digit",
|
|
4042
4045
|
hourCycle: "h23"
|
|
4043
4046
|
}).formatToParts(now);
|
|
4044
|
-
return Number(_optionalChain([parts, 'access',
|
|
4047
|
+
return Number(_optionalChain([parts, 'access', _149 => _149.find, 'call', _150 => _150((p) => p.type === "hour"), 'optionalAccess', _151 => _151.value]));
|
|
4045
4048
|
}
|
|
4046
4049
|
function hour_in_range(hour, start, end) {
|
|
4047
4050
|
return start < end ? hour >= start && hour < end : hour >= start || hour < end;
|
|
@@ -4094,16 +4097,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4094
4097
|
}),
|
|
4095
4098
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4096
4099
|
// not quarantine the synthetic stream.
|
|
4097
|
-
options: { blockOnError: false, maxRetries:
|
|
4100
|
+
options: { blockOnError: false, maxRetries: _chunkBNTVE7RQcjs.DEFAULT_MAX_RETRIES },
|
|
4098
4101
|
handler: async (event) => {
|
|
4099
4102
|
const aggregate = event.stream;
|
|
4100
4103
|
const window = read_window();
|
|
4101
4104
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4102
|
-
throw new (0,
|
|
4103
|
-
const stats = await
|
|
4105
|
+
throw new (0, _chunkL66OOP2Fcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4106
|
+
const stats = await _chunkBNTVE7RQcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4104
4107
|
count: true,
|
|
4105
4108
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4106
|
-
exclude: [
|
|
4109
|
+
exclude: [_chunkL66OOP2Fcjs.TOMBSTONE_EVENT, _chunkL66OOP2Fcjs.SNAP_EVENT]
|
|
4107
4110
|
});
|
|
4108
4111
|
const entry = stats.get(aggregate);
|
|
4109
4112
|
if (!entry) return;
|
|
@@ -4134,12 +4137,12 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4134
4137
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4135
4138
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4136
4139
|
if (future.length)
|
|
4137
|
-
throw new (0,
|
|
4140
|
+
throw new (0, _chunkL66OOP2Fcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4138
4141
|
}
|
|
4139
4142
|
};
|
|
4140
4143
|
const key = `__autoclose_${st.name}`;
|
|
4141
4144
|
for (const event_name of Object.keys(st.events)) {
|
|
4142
|
-
_optionalChain([registry, 'access',
|
|
4145
|
+
_optionalChain([registry, 'access', _152 => _152.events, 'access', _153 => _153[event_name], 'optionalAccess', _154 => _154.reactions, 'access', _155 => _155.set, 'call', _156 => _156(
|
|
4143
4146
|
key,
|
|
4144
4147
|
reaction
|
|
4145
4148
|
)]);
|
|
@@ -4339,9 +4342,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4339
4342
|
|
|
4340
4343
|
// src/builders/builder-utils.ts
|
|
4341
4344
|
function register_lane(config2, lanes) {
|
|
4342
|
-
|
|
4343
|
-
if (config2.name ===
|
|
4344
|
-
throw new Error(`Lane "${
|
|
4345
|
+
_chunkBNTVE7RQcjs.resolveLaneConfig.call(void 0, config2);
|
|
4346
|
+
if (config2.name === _chunkL66OOP2Fcjs.DEFAULT_LANE)
|
|
4347
|
+
throw new Error(`Lane "${_chunkL66OOP2Fcjs.DEFAULT_LANE}" is reserved`);
|
|
4345
4348
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4346
4349
|
if (!existing) return void lanes.push(config2);
|
|
4347
4350
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4383,10 +4386,10 @@ function reaction_on(event, events, builder) {
|
|
|
4383
4386
|
// Validate the whole bag at the declaration site so a bad
|
|
4384
4387
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4385
4388
|
// not a NaN gate on the first retry.
|
|
4386
|
-
options:
|
|
4387
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4388
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4389
|
-
backoff: _optionalChain([options, 'optionalAccess',
|
|
4389
|
+
options: _chunkBNTVE7RQcjs.resolveReactionConfig.call(void 0, {
|
|
4390
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _157 => _157.blockOnError]), () => ( _chunkBNTVE7RQcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4391
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _158 => _158.maxRetries]), () => ( _chunkBNTVE7RQcjs.DEFAULT_MAX_RETRIES)),
|
|
4392
|
+
backoff: _optionalChain([options, 'optionalAccess', _159 => _159.backoff])
|
|
4390
4393
|
})
|
|
4391
4394
|
};
|
|
4392
4395
|
},
|
|
@@ -4405,9 +4408,9 @@ function reaction_on(event, events, builder) {
|
|
|
4405
4408
|
|
|
4406
4409
|
// src/internal/date-reviver.ts
|
|
4407
4410
|
|
|
4408
|
-
var def_of = (schema) => _nullishCoalesce(_optionalChain([schema, 'access',
|
|
4411
|
+
var def_of = (schema) => _nullishCoalesce(_optionalChain([schema, 'access', _160 => _160._zod, 'optionalAccess', _161 => _161.def]), () => ( schema.def));
|
|
4409
4412
|
function variant_schema(schema) {
|
|
4410
|
-
const shape = _optionalChain([def_of, 'call',
|
|
4413
|
+
const shape = _optionalChain([def_of, 'call', _162 => _162(schema), 'optionalAccess', _163 => _163.shape]);
|
|
4411
4414
|
if (!shape) {
|
|
4412
4415
|
const dates = date_reviver_schema(schema);
|
|
4413
4416
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -4455,7 +4458,7 @@ function date_reviver_schema(schema) {
|
|
|
4455
4458
|
return variants.some((v) => v.dated) ? _zod2.z.union(variants.map((v) => v.schema)) : void 0;
|
|
4456
4459
|
}
|
|
4457
4460
|
case "nullable":
|
|
4458
|
-
return _optionalChain([inner, 'call',
|
|
4461
|
+
return _optionalChain([inner, 'call', _164 => _164(), 'optionalAccess', _165 => _165.nullable, 'call', _166 => _166()]);
|
|
4459
4462
|
case "optional":
|
|
4460
4463
|
case "nonoptional":
|
|
4461
4464
|
case "readonly":
|
|
@@ -4470,7 +4473,7 @@ function date_reviver_schema(schema) {
|
|
|
4470
4473
|
|
|
4471
4474
|
// src/builders/event-builder.ts
|
|
4472
4475
|
function event_tags(schema) {
|
|
4473
|
-
const pii =
|
|
4476
|
+
const pii = _chunkL66OOP2Fcjs.pii_schemas.call(void 0, schema);
|
|
4474
4477
|
const pii_dates = {};
|
|
4475
4478
|
for (const [key, field] of Object.entries(pii)) {
|
|
4476
4479
|
const dates = date_reviver_schema(field);
|
|
@@ -4507,7 +4510,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4507
4510
|
});
|
|
4508
4511
|
}
|
|
4509
4512
|
function build_events(registry, states, lanes, owners) {
|
|
4510
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4513
|
+
const declared = /* @__PURE__ */ new Set([_chunkL66OOP2Fcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4511
4514
|
const lane_errors = [];
|
|
4512
4515
|
const tags = /* @__PURE__ */ new Map();
|
|
4513
4516
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4571,7 +4574,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4571
4574
|
if (reader) readers.set(event_name, reader);
|
|
4572
4575
|
}
|
|
4573
4576
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4574
|
-
if (snap2) readers.set(
|
|
4577
|
+
if (snap2) readers.set(_chunkL66OOP2Fcjs.SNAP_EVENT, snap2);
|
|
4575
4578
|
if (readers.size === 0) continue;
|
|
4576
4579
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4577
4580
|
}
|
|
@@ -4632,14 +4635,14 @@ function act() {
|
|
|
4632
4635
|
let _built = false;
|
|
4633
4636
|
const read_wrap = (original) => {
|
|
4634
4637
|
const wrapped = async (events, stream) => {
|
|
4635
|
-
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access',
|
|
4638
|
+
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _167 => _167.get, 'call', _168 => _168(e.name), 'optionalCall', _169 => _169(e)]), () => ( e)));
|
|
4636
4639
|
return original(read, stream);
|
|
4637
4640
|
};
|
|
4638
4641
|
const reset = original[FOLD_RESET];
|
|
4639
4642
|
if (reset) Object.defineProperty(wrapped, FOLD_RESET, { value: reset });
|
|
4640
4643
|
return wrapped;
|
|
4641
4644
|
};
|
|
4642
|
-
const make_batch_handlers = (
|
|
4645
|
+
const make_batch_handlers = () => {
|
|
4643
4646
|
const handlers = new Map(batch_handlers);
|
|
4644
4647
|
for (const spec of fold_specs) {
|
|
4645
4648
|
handlers.set(
|
|
@@ -4649,7 +4652,7 @@ function act() {
|
|
|
4649
4652
|
spec.merged,
|
|
4650
4653
|
spec.flush,
|
|
4651
4654
|
spec.config,
|
|
4652
|
-
|
|
4655
|
+
bare_patch,
|
|
4653
4656
|
// Head loads strip sensitive keys like the warm path.
|
|
4654
4657
|
registry.sensitive_fields
|
|
4655
4658
|
)
|
|
@@ -4674,7 +4677,7 @@ function act() {
|
|
|
4674
4677
|
});
|
|
4675
4678
|
}
|
|
4676
4679
|
for (const [action_name, handler] of Object.entries(state2.on)) {
|
|
4677
|
-
const static_target = _optionalChain([handler, 'optionalAccess',
|
|
4680
|
+
const static_target = _optionalChain([handler, 'optionalAccess', _170 => _170._static_emit]);
|
|
4678
4681
|
if (static_target && deprecated.has(static_target)) {
|
|
4679
4682
|
const current = current_version_of(static_target, event_names);
|
|
4680
4683
|
throw new Error(
|
|
@@ -4687,7 +4690,7 @@ function act() {
|
|
|
4687
4690
|
const list = deprecation_summary.map(
|
|
4688
4691
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4689
4692
|
).join(", ");
|
|
4690
|
-
|
|
4693
|
+
_chunkBNTVE7RQcjs.log.call(void 0, ).info(
|
|
4691
4694
|
`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.`
|
|
4692
4695
|
);
|
|
4693
4696
|
}
|
|
@@ -4729,8 +4732,7 @@ function act() {
|
|
|
4729
4732
|
return reaction_on(event, registry.events, builder);
|
|
4730
4733
|
},
|
|
4731
4734
|
build: (options) => {
|
|
4732
|
-
|
|
4733
|
-
const patch_fn = _optionalChain([options, 'optionalAccess', _169 => _169.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4735
|
+
_chunkBNTVE7RQcjs.resolveActConfig.call(void 0, options);
|
|
4734
4736
|
if (!_built) {
|
|
4735
4737
|
for (const proj of pending_projections) add_projection(proj);
|
|
4736
4738
|
for (const proj of fold_projections) {
|
|
@@ -4748,7 +4750,7 @@ function act() {
|
|
|
4748
4750
|
`State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
|
|
4749
4751
|
);
|
|
4750
4752
|
const claimed = fold_specs.find((s) => s.target === proj.target);
|
|
4751
|
-
if (_optionalChain([claimed, 'optionalAccess',
|
|
4753
|
+
if (_optionalChain([claimed, 'optionalAccess', _171 => _171.projection]) === proj) continue;
|
|
4752
4754
|
if (batch_handlers.has(proj.target) || claimed)
|
|
4753
4755
|
throw new Error(
|
|
4754
4756
|
`Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
|
|
@@ -4781,7 +4783,7 @@ function act() {
|
|
|
4781
4783
|
synthesize_autoclose_reactions(
|
|
4782
4784
|
registry,
|
|
4783
4785
|
states,
|
|
4784
|
-
|
|
4786
|
+
_chunkBNTVE7RQcjs.current_autoclose_window
|
|
4785
4787
|
);
|
|
4786
4788
|
Object.freeze(registry.actions);
|
|
4787
4789
|
Object.freeze(registry.events);
|
|
@@ -4791,10 +4793,9 @@ function act() {
|
|
|
4791
4793
|
return new Act(
|
|
4792
4794
|
registry,
|
|
4793
4795
|
states,
|
|
4794
|
-
make_batch_handlers(
|
|
4796
|
+
make_batch_handlers(),
|
|
4795
4797
|
options,
|
|
4796
|
-
lanes
|
|
4797
|
-
patch_fn
|
|
4798
|
+
lanes
|
|
4798
4799
|
);
|
|
4799
4800
|
},
|
|
4800
4801
|
events: registry.events
|
|
@@ -4830,8 +4831,8 @@ function _projection(target) {
|
|
|
4830
4831
|
handler,
|
|
4831
4832
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4832
4833
|
options: {
|
|
4833
|
-
blockOnError:
|
|
4834
|
-
maxRetries:
|
|
4834
|
+
blockOnError: _chunkBNTVE7RQcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4835
|
+
maxRetries: _chunkBNTVE7RQcjs.DEFAULT_MAX_RETRIES
|
|
4835
4836
|
}
|
|
4836
4837
|
}),
|
|
4837
4838
|
widened
|
|
@@ -4872,7 +4873,7 @@ function _projection(target) {
|
|
|
4872
4873
|
throw new Error(
|
|
4873
4874
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4874
4875
|
);
|
|
4875
|
-
const config2 =
|
|
4876
|
+
const config2 = _chunkBNTVE7RQcjs.resolveFoldConfig.call(void 0, options);
|
|
4876
4877
|
const fold_events = {};
|
|
4877
4878
|
for (const partial of partials)
|
|
4878
4879
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4890,8 +4891,8 @@ function _projection(target) {
|
|
|
4890
4891
|
handler: noop,
|
|
4891
4892
|
resolver: { target },
|
|
4892
4893
|
options: {
|
|
4893
|
-
blockOnError:
|
|
4894
|
-
maxRetries:
|
|
4894
|
+
blockOnError: _chunkBNTVE7RQcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4895
|
+
maxRetries: _chunkBNTVE7RQcjs.DEFAULT_MAX_RETRIES
|
|
4895
4896
|
}
|
|
4896
4897
|
}
|
|
4897
4898
|
]
|
|
@@ -5007,7 +5008,7 @@ function action_builder(state2) {
|
|
|
5007
5008
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5008
5009
|
internal.actions[action2] = schema;
|
|
5009
5010
|
if (options) {
|
|
5010
|
-
|
|
5011
|
+
_chunkBNTVE7RQcjs.resolveActionConfig.call(void 0, options);
|
|
5011
5012
|
internal.options ??= {};
|
|
5012
5013
|
internal.options[action2] = options;
|
|
5013
5014
|
}
|
|
@@ -5299,5 +5300,6 @@ function write_line(writer, line) {
|
|
|
5299
5300
|
|
|
5300
5301
|
|
|
5301
5302
|
|
|
5302
|
-
|
|
5303
|
+
|
|
5304
|
+
exports.Act = Act; exports.ActorSchema = _chunkL66OOP2Fcjs.ActorSchema; exports.CausationEventSchema = _chunkL66OOP2Fcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkL66OOP2Fcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkL66OOP2Fcjs.ConcurrencyError; exports.ConsoleLogger = _chunkBNTVE7RQcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkL66OOP2Fcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkL66OOP2Fcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkL66OOP2Fcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkL66OOP2Fcjs.DeferSignal; exports.Environments = _chunkL66OOP2Fcjs.Environments; exports.Errors = _chunkL66OOP2Fcjs.Errors; exports.EventMetaSchema = _chunkL66OOP2Fcjs.EventMetaSchema; exports.ExitCodes = _chunkL66OOP2Fcjs.ExitCodes; exports.InMemoryCache = _chunkBNTVE7RQcjs.InMemoryCache; exports.InMemoryStore = _chunkBNTVE7RQcjs.InMemoryStore; exports.InvariantError = _chunkL66OOP2Fcjs.InvariantError; exports.LogLevels = _chunkL66OOP2Fcjs.LogLevels; exports.NonRetryableError = _chunkL66OOP2Fcjs.NonRetryableError; exports.PackageSchema = _chunkBNTVE7RQcjs.PackageSchema; exports.PreconditionError = _chunkL66OOP2Fcjs.PreconditionError; exports.QuerySchema = _chunkL66OOP2Fcjs.QuerySchema; exports.REDACTED = _chunkL66OOP2Fcjs.REDACTED; exports.SHREDDED = _chunkL66OOP2Fcjs.SHREDDED; exports.SNAP_EVENT = _chunkL66OOP2Fcjs.SNAP_EVENT; exports.StoreError = _chunkL66OOP2Fcjs.StoreError; exports.StreamClosedError = _chunkL66OOP2Fcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkL66OOP2Fcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkL66OOP2Fcjs.TargetSchema; exports.ValidationError = _chunkL66OOP2Fcjs.ValidationError; exports.ZodEmpty = _chunkL66OOP2Fcjs.ZodEmpty; exports.act = act; exports.cache = _chunkBNTVE7RQcjs.cache; exports.config = _chunkBNTVE7RQcjs.config; exports.dateReviver = _chunkBNTVE7RQcjs.dateReviver; exports.default_scope = _chunkBNTVE7RQcjs.default_scope; exports.dispose = _chunkBNTVE7RQcjs.dispose; exports.disposeAndExit = _chunkBNTVE7RQcjs.disposeAndExit; exports.extend = _chunkBNTVE7RQcjs.extend; exports.is_literal_source = _chunkBNTVE7RQcjs.is_literal_source; exports.log = _chunkBNTVE7RQcjs.log; exports.pii_fields = _chunkL66OOP2Fcjs.pii_fields; exports.port = _chunkBNTVE7RQcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkBNTVE7RQcjs.resolveAutocloseConfig2; exports.sensitive = _chunkL66OOP2Fcjs.sensitive; exports.sleep = _chunkBNTVE7RQcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkBNTVE7RQcjs.store; exports.validate = _chunkBNTVE7RQcjs.validate;
|
|
5303
5305
|
//# sourceMappingURL=index.cjs.map
|