@rotorsoft/act 1.33.19 → 1.34.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/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +2 -2
- package/dist/@types/builders/merge.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts +1 -1
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +2 -3
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +28 -0
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/builders.d.ts +113 -25
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/@types/types/errors.d.ts +13 -6
- package/dist/@types/types/errors.d.ts.map +1 -1
- package/dist/{chunk-5Z53Y7SG.js → chunk-5F2TQ4PT.js} +2 -2
- package/dist/{chunk-HEHGZHHA.js → chunk-BKCNU6FF.js} +10 -5
- package/dist/chunk-BKCNU6FF.js.map +1 -0
- package/dist/{chunk-GEUBNZ3B.cjs → chunk-BTLM7SW4.cjs} +13 -13
- package/dist/{chunk-GEUBNZ3B.cjs.map → chunk-BTLM7SW4.cjs.map} +1 -1
- package/dist/{chunk-DVYTKZD5.cjs → chunk-RF5MV72K.cjs} +10 -5
- package/dist/chunk-RF5MV72K.cjs.map +1 -0
- package/dist/index.cjs +168 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -12
- 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-DVYTKZD5.cjs.map +0 -1
- package/dist/chunk-HEHGZHHA.js.map +0 -1
- /package/dist/{chunk-5Z53Y7SG.js.map → chunk-5F2TQ4PT.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkBTLM7SW4cjs = require('./chunk-BTLM7SW4.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -70,24 +70,24 @@ var _chunkGEUBNZ3Bcjs = require('./chunk-GEUBNZ3B.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var
|
|
73
|
+
var _chunkRF5MV72Kcjs = require('./chunk-RF5MV72K.cjs');
|
|
74
74
|
|
|
75
75
|
// src/signals.ts
|
|
76
76
|
process.once("SIGINT", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
78
|
+
await _chunkBTLM7SW4cjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("SIGTERM", async (arg) => {
|
|
81
|
-
|
|
82
|
-
await
|
|
81
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
82
|
+
await _chunkBTLM7SW4cjs.disposeAndExit.call(void 0, "EXIT");
|
|
83
83
|
});
|
|
84
84
|
process.once("uncaughtException", async (arg) => {
|
|
85
|
-
|
|
86
|
-
await
|
|
85
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
86
|
+
await _chunkBTLM7SW4cjs.disposeAndExit.call(void 0, "ERROR");
|
|
87
87
|
});
|
|
88
88
|
process.once("unhandledRejection", async (arg) => {
|
|
89
|
-
|
|
90
|
-
await
|
|
89
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
90
|
+
await _chunkBTLM7SW4cjs.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: [_chunkRF5MV72Kcjs.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 = _chunkRF5MV72Kcjs.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: [_chunkRF5MV72Kcjs.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 === _chunkRF5MV72Kcjs.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 _chunkBTLM7SW4cjs.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 _chunkBTLM7SW4cjs.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 === _chunkRF5MV72Kcjs.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
|
+
_chunkBTLM7SW4cjs.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 _chunkBTLM7SW4cjs.store.call(void 0, ).query_stats(streams, {
|
|
981
|
+
exclude: [_chunkRF5MV72Kcjs.SNAP_EVENT]
|
|
982
982
|
});
|
|
983
|
-
const domain_heads = await
|
|
984
|
-
exclude: [
|
|
983
|
+
const domain_heads = await _chunkBTLM7SW4cjs.store.call(void 0, ).query_stats(streams, {
|
|
984
|
+
exclude: [_chunkRF5MV72Kcjs.SNAP_EVENT, _chunkRF5MV72Kcjs.TOMBSTONE_EVENT]
|
|
985
985
|
});
|
|
986
|
-
const true_heads = await
|
|
986
|
+
const true_heads = await _chunkBTLM7SW4cjs.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]) === _chunkRF5MV72Kcjs.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
|
+
_chunkBTLM7SW4cjs.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 _chunkBTLM7SW4cjs.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: _chunkRF5MV72Kcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
};
|
|
1102
1102
|
});
|
|
1103
|
-
const truncated = await
|
|
1103
|
+
const truncated = await _chunkBTLM7SW4cjs.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 _chunkBTLM7SW4cjs.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 _chunkBTLM7SW4cjs.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
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).error(new Error(message));
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
// src/internal/correlate-cycle.ts
|
|
@@ -1180,7 +1180,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1180
1180
|
// never lets a resolution re-lane them.
|
|
1181
1181
|
|
|
1182
1182
|
__init11() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1183
|
-
__init12() {this._patterns = new (0,
|
|
1183
|
+
__init12() {this._patterns = new (0, _chunkBTLM7SW4cjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1184
1184
|
|
|
1185
1185
|
|
|
1186
1186
|
|
|
@@ -1198,7 +1198,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1198
1198
|
on_init
|
|
1199
1199
|
}) {;_class3.prototype.__init3.call(this);_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);
|
|
1200
1200
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1201
|
-
this._dynamic_subscriptions = new (0,
|
|
1201
|
+
this._dynamic_subscriptions = new (0, _chunkBTLM7SW4cjs.LruMap)(max_subscribed_streams);
|
|
1202
1202
|
this._registry = registry;
|
|
1203
1203
|
this._declared_lanes = declared_lanes;
|
|
1204
1204
|
this._static_targets = static_targets;
|
|
@@ -1256,7 +1256,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1256
1256
|
/** Would the target's own `fetch` (filtered by `source`) return this event? */
|
|
1257
1257
|
_in_fetch_window(source, stream) {
|
|
1258
1258
|
if (source === void 0 || source === stream) return true;
|
|
1259
|
-
if (
|
|
1259
|
+
if (_chunkBTLM7SW4cjs.is_literal_source.call(void 0, source)) return false;
|
|
1260
1260
|
let pattern = this._patterns.get(source);
|
|
1261
1261
|
if (!pattern) {
|
|
1262
1262
|
pattern = new RegExp(source);
|
|
@@ -1299,7 +1299,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1299
1299
|
const correlated = /* @__PURE__ */ new Map();
|
|
1300
1300
|
let last_id = after;
|
|
1301
1301
|
let stopped = false;
|
|
1302
|
-
const found = await
|
|
1302
|
+
const found = await _chunkBTLM7SW4cjs.store.call(void 0, ).query(
|
|
1303
1303
|
(event) => {
|
|
1304
1304
|
if (stopped) return;
|
|
1305
1305
|
const register = this._registry.events[event.name];
|
|
@@ -1344,9 +1344,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1344
1344
|
correlated_at: void 0
|
|
1345
1345
|
};
|
|
1346
1346
|
const seen_in_scan = correlated.has(resolved.target);
|
|
1347
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => (
|
|
1347
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkRF5MV72Kcjs.DEFAULT_LANE));
|
|
1348
1348
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _62 => _62.priority]);
|
|
1349
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
1349
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkRF5MV72Kcjs.DEFAULT_LANE));
|
|
1350
1350
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1351
1351
|
report_lane_conflict(
|
|
1352
1352
|
this._reported,
|
|
@@ -1422,7 +1422,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1422
1422
|
await Promise.all(
|
|
1423
1423
|
missed.map(async ([stream, entry]) => {
|
|
1424
1424
|
let row;
|
|
1425
|
-
await
|
|
1425
|
+
await _chunkBTLM7SW4cjs.store.call(void 0, ).query_streams(
|
|
1426
1426
|
(position) => {
|
|
1427
1427
|
row = position;
|
|
1428
1428
|
},
|
|
@@ -1434,8 +1434,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1434
1434
|
lane: row.lane
|
|
1435
1435
|
});
|
|
1436
1436
|
if (entry.priority > row.priority) return;
|
|
1437
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
1438
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
1437
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkRF5MV72Kcjs.DEFAULT_LANE));
|
|
1438
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkRF5MV72Kcjs.DEFAULT_LANE));
|
|
1439
1439
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
1440
1440
|
report_lane_conflict(
|
|
1441
1441
|
this._reported,
|
|
@@ -1461,7 +1461,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1461
1461
|
millis: 0
|
|
1462
1462
|
});
|
|
1463
1463
|
} catch (error) {
|
|
1464
|
-
|
|
1464
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).warn(
|
|
1465
1465
|
`Could not hand back the correlation lease during shutdown; it expires on its own within ${CORRELATION_LEASE_MS}ms and correlation resumes normally after that. On a single-writer store this usually means another connection holds the database. Cause: ${String(error)}`
|
|
1466
1466
|
);
|
|
1467
1467
|
}
|
|
@@ -1614,14 +1614,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
|
|
1616
1616
|
// src/internal/drain-ops.ts
|
|
1617
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1617
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkBTLM7SW4cjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1618
1618
|
async function fetch(leased, eventLimit) {
|
|
1619
1619
|
return Promise.all(
|
|
1620
1620
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1621
1621
|
const events = [];
|
|
1622
|
-
const stream_exact = source !== void 0 &&
|
|
1622
|
+
const stream_exact = source !== void 0 && _chunkBTLM7SW4cjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1623
1623
|
try {
|
|
1624
|
-
await
|
|
1624
|
+
await _chunkBTLM7SW4cjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1625
1625
|
stream: source,
|
|
1626
1626
|
stream_exact,
|
|
1627
1627
|
after: at,
|
|
@@ -1641,30 +1641,30 @@ async function fetch(leased, eventLimit) {
|
|
|
1641
1641
|
})
|
|
1642
1642
|
);
|
|
1643
1643
|
}
|
|
1644
|
-
var ack = (leases) =>
|
|
1645
|
-
var block = (leases) =>
|
|
1646
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1644
|
+
var ack = (leases) => _chunkBTLM7SW4cjs.store.call(void 0, ).ack(leases);
|
|
1645
|
+
var block = (leases) => _chunkBTLM7SW4cjs.store.call(void 0, ).block(leases);
|
|
1646
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkBTLM7SW4cjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1647
1647
|
|
|
1648
1648
|
// src/internal/event-sourcing.ts
|
|
1649
1649
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1650
1650
|
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1651
1651
|
var validating_patch = (me, state2, partial, event) => {
|
|
1652
1652
|
const next = _actpatch.patch.call(void 0, state2, partial);
|
|
1653
|
-
return
|
|
1653
|
+
return _chunkBTLM7SW4cjs.validate.call(void 0,
|
|
1654
1654
|
`${me.name}.${String(event.name)}#${event.id}`,
|
|
1655
1655
|
next,
|
|
1656
1656
|
me.state
|
|
1657
1657
|
);
|
|
1658
1658
|
};
|
|
1659
1659
|
var DEFAULT_BATCH = 500;
|
|
1660
|
-
var cache_put = (stream, entry) =>
|
|
1661
|
-
(err) =>
|
|
1660
|
+
var cache_put = (stream, entry) => _chunkBTLM7SW4cjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1661
|
+
(err) => _chunkBTLM7SW4cjs.log.call(void 0, ).warn(
|
|
1662
1662
|
err,
|
|
1663
1663
|
"cache set skipped; the next load re-folds from the store"
|
|
1664
1664
|
)
|
|
1665
1665
|
);
|
|
1666
|
-
var cache_drop = (stream) =>
|
|
1667
|
-
(err) =>
|
|
1666
|
+
var cache_drop = (stream) => _chunkBTLM7SW4cjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1667
|
+
(err) => _chunkBTLM7SW4cjs.log.call(void 0, ).warn(
|
|
1668
1668
|
err,
|
|
1669
1669
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1670
1670
|
)
|
|
@@ -1672,9 +1672,9 @@ var cache_drop = (stream) => _chunkGEUBNZ3Bcjs.cache.call(void 0, ).invalidate(s
|
|
|
1672
1672
|
async function snap(snapshot) {
|
|
1673
1673
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1674
1674
|
try {
|
|
1675
|
-
const [committed] = await
|
|
1675
|
+
const [committed] = await _chunkBTLM7SW4cjs.store.call(void 0, ).commit(
|
|
1676
1676
|
stream,
|
|
1677
|
-
[{ name:
|
|
1677
|
+
[{ name: _chunkRF5MV72Kcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1678
1678
|
{
|
|
1679
1679
|
correlation: meta.correlation,
|
|
1680
1680
|
causation: { event: { id, name, stream } }
|
|
@@ -1685,22 +1685,22 @@ async function snap(snapshot) {
|
|
|
1685
1685
|
return committed;
|
|
1686
1686
|
} catch (error) {
|
|
1687
1687
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1688
|
-
|
|
1688
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).warn(
|
|
1689
1689
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1690
1690
|
);
|
|
1691
1691
|
}
|
|
1692
1692
|
}
|
|
1693
1693
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1694
1694
|
try {
|
|
1695
|
-
const [committed] = await
|
|
1695
|
+
const [committed] = await _chunkBTLM7SW4cjs.store.call(void 0, ).commit(
|
|
1696
1696
|
stream,
|
|
1697
|
-
[{ name:
|
|
1697
|
+
[{ name: _chunkRF5MV72Kcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1698
1698
|
{ correlation, causation: {} },
|
|
1699
1699
|
expectedVersion
|
|
1700
1700
|
);
|
|
1701
1701
|
return committed;
|
|
1702
1702
|
} catch (error) {
|
|
1703
|
-
if (error instanceof
|
|
1703
|
+
if (error instanceof _chunkRF5MV72Kcjs.ConcurrencyError) return void 0;
|
|
1704
1704
|
throw error;
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
@@ -1730,9 +1730,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1730
1730
|
if (drop_closed_streams) {
|
|
1731
1731
|
await source.query(
|
|
1732
1732
|
(e) => {
|
|
1733
|
-
if (e.name ===
|
|
1733
|
+
if (e.name === _chunkRF5MV72Kcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1734
1734
|
},
|
|
1735
|
-
{ names: [
|
|
1735
|
+
{ names: [_chunkRF5MV72Kcjs.TOMBSTONE_EVENT] }
|
|
1736
1736
|
);
|
|
1737
1737
|
}
|
|
1738
1738
|
let max_id;
|
|
@@ -1754,11 +1754,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1754
1754
|
if (!is_valid(event))
|
|
1755
1755
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1756
1756
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1757
|
-
if (drop_snapshots && event.name ===
|
|
1757
|
+
if (drop_snapshots && event.name === _chunkRF5MV72Kcjs.SNAP_EVENT) {
|
|
1758
1758
|
dropped_snaps++;
|
|
1759
1759
|
return;
|
|
1760
1760
|
}
|
|
1761
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1761
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkRF5MV72Kcjs.TOMBSTONE_EVENT) {
|
|
1762
1762
|
dropped_closed++;
|
|
1763
1763
|
return;
|
|
1764
1764
|
}
|
|
@@ -1825,17 +1825,17 @@ async function scan(source, opts = {}, callback) {
|
|
|
1825
1825
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1826
1826
|
const { stream, actor, asOf } = target;
|
|
1827
1827
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1828
|
-
const cached = time_travel ? void 0 : await
|
|
1828
|
+
const cached = time_travel ? void 0 : await _chunkBTLM7SW4cjs.cache.call(void 0, ).get(stream);
|
|
1829
1829
|
const cache_hit = !!cached;
|
|
1830
1830
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _72 => _72.state]), () => ( (me.init ? me.init() : {})));
|
|
1831
1831
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.patches]), () => ( 0));
|
|
1832
1832
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.snaps]), () => ( 0));
|
|
1833
1833
|
let replayed = 0;
|
|
1834
1834
|
let event;
|
|
1835
|
-
await
|
|
1835
|
+
await _chunkBTLM7SW4cjs.store.call(void 0, ).query(
|
|
1836
1836
|
(raw) => {
|
|
1837
1837
|
event = me.view(raw, actor);
|
|
1838
|
-
if (event.name ===
|
|
1838
|
+
if (event.name === _chunkRF5MV72Kcjs.SNAP_EVENT) {
|
|
1839
1839
|
state2 = event.data;
|
|
1840
1840
|
snaps++;
|
|
1841
1841
|
patches = 0;
|
|
@@ -1844,8 +1844,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1844
1844
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1845
1845
|
patches++;
|
|
1846
1846
|
replayed++;
|
|
1847
|
-
} else if (event.name !==
|
|
1848
|
-
|
|
1847
|
+
} else if (event.name !== _chunkRF5MV72Kcjs.TOMBSTONE_EVENT) {
|
|
1848
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).warn(
|
|
1849
1849
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1850
1850
|
);
|
|
1851
1851
|
}
|
|
@@ -1869,7 +1869,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1869
1869
|
...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
|
|
1870
1870
|
}
|
|
1871
1871
|
);
|
|
1872
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) ===
|
|
1872
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _76 => _76.name]) === _chunkRF5MV72Kcjs.TOMBSTONE_EVENT;
|
|
1873
1873
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1874
1874
|
await cache_put(stream, {
|
|
1875
1875
|
stream,
|
|
@@ -1897,7 +1897,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1897
1897
|
if (!stream) throw new Error("Missing target stream");
|
|
1898
1898
|
const reactingTo = _optionalChain([options, 'optionalAccess', _81 => _81.reactingTo]);
|
|
1899
1899
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.correlator]), () => ( default_correlator));
|
|
1900
|
-
const validated =
|
|
1900
|
+
const validated = _chunkBTLM7SW4cjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1901
1901
|
const opts = _optionalChain([me, 'access', _83 => _83.options, 'optionalAccess', _84 => _84[action2]]);
|
|
1902
1902
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries]), () => ( 0));
|
|
1903
1903
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1908,14 +1908,14 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1908
1908
|
void 0,
|
|
1909
1909
|
patch_fn
|
|
1910
1910
|
);
|
|
1911
|
-
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) ===
|
|
1912
|
-
throw new (0,
|
|
1911
|
+
if (_optionalChain([snapshot, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.name]) === _chunkRF5MV72Kcjs.TOMBSTONE_EVENT)
|
|
1912
|
+
throw new (0, _chunkRF5MV72Kcjs.StreamClosedError)(stream);
|
|
1913
1913
|
const expected = _nullishCoalesce(expectedVersion, () => ( (snapshot.version >= 0 ? snapshot.version : void 0)));
|
|
1914
1914
|
if (me.given) {
|
|
1915
1915
|
const invariants = me.given[action2] || [];
|
|
1916
1916
|
invariants.forEach(({ valid: valid2, description }) => {
|
|
1917
1917
|
if (!valid2(snapshot.state, actor))
|
|
1918
|
-
throw new (0,
|
|
1918
|
+
throw new (0, _chunkRF5MV72Kcjs.InvariantError)(
|
|
1919
1919
|
action2,
|
|
1920
1920
|
validated,
|
|
1921
1921
|
target,
|
|
@@ -1924,6 +1924,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1924
1924
|
);
|
|
1925
1925
|
});
|
|
1926
1926
|
}
|
|
1927
|
+
if (me.requires) {
|
|
1928
|
+
const preconditions = me.requires[action2] || [];
|
|
1929
|
+
for (const { holds, description } of preconditions)
|
|
1930
|
+
if (!holds(validated, snapshot.state, actor))
|
|
1931
|
+
throw new (0, _chunkRF5MV72Kcjs.InvariantError)(
|
|
1932
|
+
action2,
|
|
1933
|
+
validated,
|
|
1934
|
+
target,
|
|
1935
|
+
snapshot,
|
|
1936
|
+
description,
|
|
1937
|
+
"precondition"
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1927
1940
|
const result = me.on[action2](validated, snapshot, target);
|
|
1928
1941
|
if (!result) return [snapshot];
|
|
1929
1942
|
if (Array.isArray(result) && result.length === 0) {
|
|
@@ -1932,7 +1945,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1932
1945
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1933
1946
|
const valid = tuples.map(([name, data]) => ({
|
|
1934
1947
|
name,
|
|
1935
|
-
data:
|
|
1948
|
+
data: _chunkBTLM7SW4cjs.validate.call(void 0, name, data, me.events[name])
|
|
1936
1949
|
}));
|
|
1937
1950
|
const emitted = valid.map((e) => me.message(e));
|
|
1938
1951
|
const meta = {
|
|
@@ -1957,7 +1970,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1957
1970
|
};
|
|
1958
1971
|
let committed;
|
|
1959
1972
|
try {
|
|
1960
|
-
committed = await
|
|
1973
|
+
committed = await _chunkBTLM7SW4cjs.store.call(void 0, ).commit(
|
|
1961
1974
|
stream,
|
|
1962
1975
|
emitted,
|
|
1963
1976
|
meta,
|
|
@@ -1966,7 +1979,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1966
1979
|
reactingTo ? expectedVersion : expected
|
|
1967
1980
|
);
|
|
1968
1981
|
} catch (error) {
|
|
1969
|
-
if (error instanceof
|
|
1982
|
+
if (error instanceof _chunkRF5MV72Kcjs.ConcurrencyError) void cache_drop(stream);
|
|
1970
1983
|
throw error;
|
|
1971
1984
|
}
|
|
1972
1985
|
let { state: state2, patches } = snapshot;
|
|
@@ -2005,19 +2018,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
2005
2018
|
}
|
|
2006
2019
|
return snapshots;
|
|
2007
2020
|
} catch (error) {
|
|
2008
|
-
if (!(error instanceof
|
|
2021
|
+
if (!(error instanceof _chunkRF5MV72Kcjs.ConcurrencyError)) throw error;
|
|
2009
2022
|
if (expectedVersion !== void 0) throw error;
|
|
2010
2023
|
if (attempt >= max_retries) throw error;
|
|
2011
2024
|
if (_optionalChain([opts, 'optionalAccess', _94 => _94.backoff])) {
|
|
2012
2025
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
2013
|
-
if (delay_ms > 0) await
|
|
2026
|
+
if (delay_ms > 0) await _chunkBTLM7SW4cjs.sleep.call(void 0, delay_ms);
|
|
2014
2027
|
}
|
|
2015
2028
|
}
|
|
2016
2029
|
}
|
|
2017
2030
|
}
|
|
2018
2031
|
|
|
2019
2032
|
// src/internal/tracing.ts
|
|
2020
|
-
var PRETTY =
|
|
2033
|
+
var PRETTY = _chunkBTLM7SW4cjs.config.call(void 0, ).env !== "production";
|
|
2021
2034
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2022
2035
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2023
2036
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2203,7 +2216,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2203
2216
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _104 => _104.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2204
2217
|
return void 0;
|
|
2205
2218
|
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.`;
|
|
2206
|
-
|
|
2219
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).error(error);
|
|
2207
2220
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2208
2221
|
}
|
|
2209
2222
|
function fetch_failure_policy(registry) {
|
|
@@ -2219,13 +2232,13 @@ function fetch_failure_policy(registry) {
|
|
|
2219
2232
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
2220
2233
|
if (!error) return { lease, handled, acked_at: at };
|
|
2221
2234
|
logger.error(error);
|
|
2222
|
-
const non_retryable = error instanceof
|
|
2235
|
+
const non_retryable = error instanceof _chunkRF5MV72Kcjs.NonRetryableError;
|
|
2223
2236
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2224
2237
|
if (block2)
|
|
2225
2238
|
logger.error(
|
|
2226
2239
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2227
2240
|
);
|
|
2228
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2241
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkBTLM7SW4cjs.DEFAULT_BACKOFF)));
|
|
2229
2242
|
return {
|
|
2230
2243
|
lease,
|
|
2231
2244
|
handled,
|
|
@@ -2343,18 +2356,17 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2343
2356
|
return handle({ ...lease, at }, payloads);
|
|
2344
2357
|
})
|
|
2345
2358
|
);
|
|
2346
|
-
const
|
|
2347
|
-
|
|
2348
|
-
);
|
|
2359
|
+
const to_block = handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }));
|
|
2360
|
+
const blocked = to_block.length ? await ops.block(to_block) : [];
|
|
2349
2361
|
if (blocked.length) deps.on_blocked(blocked);
|
|
2350
2362
|
const submitted = handled.flatMap((h, i) => {
|
|
2351
2363
|
const advance = h.handled > 0 ? h.acked_at : leased[i].at;
|
|
2352
2364
|
return h.defer !== void 0 ? { ...h.lease, at: advance, due: h.defer, retry: -1 } : h.next_attempt_at !== void 0 ? { ...h.lease, at: advance, due: h.next_attempt_at } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : [];
|
|
2353
2365
|
});
|
|
2354
|
-
const acked = await ops.ack(submitted);
|
|
2366
|
+
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2355
2367
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2356
2368
|
if (acked.length < expected)
|
|
2357
|
-
|
|
2369
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).warn(
|
|
2358
2370
|
`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.`
|
|
2359
2371
|
);
|
|
2360
2372
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2454,9 +2466,9 @@ var DrainController = (_class5 = class {
|
|
|
2454
2466
|
if (!this.armed || this._stopped || this._inflight)
|
|
2455
2467
|
return EMPTY_DRAIN;
|
|
2456
2468
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2457
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2458
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2459
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2469
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkBTLM7SW4cjs.DEFAULT_STREAM_LIMIT));
|
|
2470
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkBTLM7SW4cjs.DEFAULT_EVENT_LIMIT));
|
|
2471
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkBTLM7SW4cjs.DEFAULT_LEASE_MILLIS));
|
|
2460
2472
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2461
2473
|
return EMPTY_DRAIN;
|
|
2462
2474
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2531,7 +2543,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2531
2543
|
const { pii, ...rest } = event;
|
|
2532
2544
|
if (pii == null) {
|
|
2533
2545
|
const shredded = { ...data };
|
|
2534
|
-
for (const f of fields) shredded[f] =
|
|
2546
|
+
for (const f of fields) shredded[f] = _chunkRF5MV72Kcjs.SHREDDED;
|
|
2535
2547
|
return { ...rest, data: shredded };
|
|
2536
2548
|
}
|
|
2537
2549
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2542,7 +2554,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2542
2554
|
};
|
|
2543
2555
|
}
|
|
2544
2556
|
const redacted = { ...data };
|
|
2545
|
-
for (const f of fields) redacted[f] =
|
|
2557
|
+
for (const f of fields) redacted[f] = _chunkRF5MV72Kcjs.REDACTED;
|
|
2546
2558
|
return { ...rest, data: redacted };
|
|
2547
2559
|
}
|
|
2548
2560
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2679,7 +2691,7 @@ function make_deferred(handler, schedule) {
|
|
|
2679
2691
|
const call = handler;
|
|
2680
2692
|
const deferred = async (event, stream, app) => {
|
|
2681
2693
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2682
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2694
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkRF5MV72Kcjs.DeferSignal)(when);
|
|
2683
2695
|
return call(event, stream, app);
|
|
2684
2696
|
};
|
|
2685
2697
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2748,7 +2760,7 @@ function build_handle(deps) {
|
|
|
2748
2760
|
handled++;
|
|
2749
2761
|
}
|
|
2750
2762
|
} catch (error) {
|
|
2751
|
-
if (error instanceof
|
|
2763
|
+
if (error instanceof _chunkRF5MV72Kcjs.DeferSignal) {
|
|
2752
2764
|
let defer;
|
|
2753
2765
|
try {
|
|
2754
2766
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2854,9 +2866,8 @@ var SettleLoop = (_class6 = class {
|
|
|
2854
2866
|
* `debounceMs` brings it forward), and a call during a running cycle
|
|
2855
2867
|
* queues one more pass after it. Callers pass options, which the next
|
|
2856
2868
|
* pass uses; internal wake-ups pass none, so they never discard a
|
|
2857
|
-
* caller's. The cycle runs correlate→drain
|
|
2858
|
-
*
|
|
2859
|
-
* streams) or `maxPasses` is reached, then emits the
|
|
2869
|
+
* caller's. The cycle runs correlate→drain passes until one makes no
|
|
2870
|
+
* progress (see {@link SettleOptions.maxPasses}), then emits the
|
|
2860
2871
|
* `"settled"` lifecycle event via {@link SettleDeps.on_settled}.
|
|
2861
2872
|
*/
|
|
2862
2873
|
schedule(options) {
|
|
@@ -3015,7 +3026,7 @@ var Act = (_class7 = class {
|
|
|
3015
3026
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
3016
3027
|
|
|
3017
3028
|
|
|
3018
|
-
__init27() {this._logger =
|
|
3029
|
+
__init27() {this._logger = _chunkBTLM7SW4cjs.log.call(void 0, )}
|
|
3019
3030
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3020
3031
|
|
|
3021
3032
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3037,9 +3048,9 @@ var Act = (_class7 = class {
|
|
|
3037
3048
|
this._lanes = lanes;
|
|
3038
3049
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3039
3050
|
validate_only_lanes(options, lanes);
|
|
3040
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3051
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkBTLM7SW4cjs.default_scope.call(void 0, )));
|
|
3041
3052
|
const ports = this._ports;
|
|
3042
|
-
this._scoped =
|
|
3053
|
+
this._scoped = _chunkBTLM7SW4cjs.make_run_scoped.call(void 0, {
|
|
3043
3054
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3044
3055
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3045
3056
|
get store() {
|
|
@@ -3049,14 +3060,14 @@ var Act = (_class7 = class {
|
|
|
3049
3060
|
return ports.cache;
|
|
3050
3061
|
},
|
|
3051
3062
|
// Parsed per build, so a bad window throws on every build.
|
|
3052
|
-
autoclose_window:
|
|
3063
|
+
autoclose_window: _chunkBTLM7SW4cjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3053
3064
|
});
|
|
3054
3065
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3055
3066
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3056
3067
|
this._cd = build_drain(this._logger);
|
|
3057
3068
|
const handle = build_handle({
|
|
3058
3069
|
logger: this._logger,
|
|
3059
|
-
reaction_scope:
|
|
3070
|
+
reaction_scope: _chunkBTLM7SW4cjs.make_reaction_scope.call(void 0, {
|
|
3060
3071
|
do: this.do.bind(this),
|
|
3061
3072
|
load: this.load.bind(this),
|
|
3062
3073
|
query: this.query.bind(this),
|
|
@@ -3086,12 +3097,12 @@ var Act = (_class7 = class {
|
|
|
3086
3097
|
this._ports.store,
|
|
3087
3098
|
options.listen !== false
|
|
3088
3099
|
);
|
|
3089
|
-
|
|
3100
|
+
_chunkBTLM7SW4cjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3090
3101
|
}
|
|
3091
3102
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3092
3103
|
_build_breaker(options) {
|
|
3093
3104
|
return new CircuitBreaker(
|
|
3094
|
-
|
|
3105
|
+
_chunkBTLM7SW4cjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3095
3106
|
{
|
|
3096
3107
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3097
3108
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3125,7 +3136,7 @@ var Act = (_class7 = class {
|
|
|
3125
3136
|
try {
|
|
3126
3137
|
await this._run_close(targets);
|
|
3127
3138
|
} catch (error) {
|
|
3128
|
-
if (error instanceof
|
|
3139
|
+
if (error instanceof _chunkRF5MV72Kcjs.StoreError) throw error;
|
|
3129
3140
|
this._logger.error(
|
|
3130
3141
|
error,
|
|
3131
3142
|
`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.`
|
|
@@ -3160,7 +3171,7 @@ var Act = (_class7 = class {
|
|
|
3160
3171
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3161
3172
|
_build_audit_deps() {
|
|
3162
3173
|
return {
|
|
3163
|
-
store:
|
|
3174
|
+
store: _chunkBTLM7SW4cjs.store,
|
|
3164
3175
|
event_to_state: this._event_to_state,
|
|
3165
3176
|
// Declared lanes, not this process's controllers: a lane another
|
|
3166
3177
|
// worker drains is not `unknown-lane`.
|
|
@@ -3173,7 +3184,7 @@ var Act = (_class7 = class {
|
|
|
3173
3184
|
registry: this.registry,
|
|
3174
3185
|
static_targets: classification.static_targets,
|
|
3175
3186
|
cd: this._cd,
|
|
3176
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3187
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkRF5MV72Kcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3177
3188
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3178
3189
|
// still a valid destination.
|
|
3179
3190
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3189,7 +3200,7 @@ var Act = (_class7 = class {
|
|
|
3189
3200
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3190
3201
|
async _seed_persisted_defers() {
|
|
3191
3202
|
const now = Date.now();
|
|
3192
|
-
await walk_streams(
|
|
3203
|
+
await walk_streams(_chunkBTLM7SW4cjs.store.call(void 0, ), (pos) => {
|
|
3193
3204
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3194
3205
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3195
3206
|
_optionalChain([controller, 'optionalAccess', _124 => _124.seed_defer, 'call', _125 => _125(pos.stream, pos.deferred_at)]);
|
|
@@ -3208,7 +3219,7 @@ var Act = (_class7 = class {
|
|
|
3208
3219
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3209
3220
|
breaker: this._breaker
|
|
3210
3221
|
},
|
|
3211
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3222
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkRF5MV72Kcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3212
3223
|
);
|
|
3213
3224
|
}
|
|
3214
3225
|
|
|
@@ -3228,7 +3239,7 @@ var Act = (_class7 = class {
|
|
|
3228
3239
|
*/
|
|
3229
3240
|
shutdown(options) {
|
|
3230
3241
|
if (!this._shutdown_promise) {
|
|
3231
|
-
|
|
3242
|
+
_chunkBTLM7SW4cjs.resolveShutdownConfig.call(void 0, options);
|
|
3232
3243
|
this._shutdown_promise = (async () => {
|
|
3233
3244
|
this.stop_correlations();
|
|
3234
3245
|
this._settle.stop(true);
|
|
@@ -3248,10 +3259,10 @@ var Act = (_class7 = class {
|
|
|
3248
3259
|
* default for none or 0, and for a running settle), capped.
|
|
3249
3260
|
*/
|
|
3250
3261
|
_derive_grace_ms(running, settling) {
|
|
3251
|
-
let max = settling ?
|
|
3262
|
+
let max = settling ? _chunkBTLM7SW4cjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3252
3263
|
for (const c of running)
|
|
3253
|
-
max = Math.max(max, c.lease_millis ||
|
|
3254
|
-
return Math.min(max,
|
|
3264
|
+
max = Math.max(max, c.lease_millis || _chunkBTLM7SW4cjs.DEFAULT_LEASE_MILLIS);
|
|
3265
|
+
return Math.min(max, _chunkBTLM7SW4cjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3255
3266
|
}
|
|
3256
3267
|
async _await_inflight(grace_ms) {
|
|
3257
3268
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3332,7 +3343,7 @@ var Act = (_class7 = class {
|
|
|
3332
3343
|
* @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
|
|
3333
3344
|
*/
|
|
3334
3345
|
async do(action2, target, payload, options) {
|
|
3335
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => (
|
|
3346
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => ( _chunkBTLM7SW4cjs.current_reacting.call(void 0, )));
|
|
3336
3347
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _128 => _128.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3337
3348
|
return this._scoped(async () => {
|
|
3338
3349
|
const snapshots = await this._es.action(
|
|
@@ -3393,7 +3404,7 @@ var Act = (_class7 = class {
|
|
|
3393
3404
|
return this._scoped(async () => {
|
|
3394
3405
|
let first;
|
|
3395
3406
|
let last;
|
|
3396
|
-
const count = await
|
|
3407
|
+
const count = await _chunkBTLM7SW4cjs.store.call(void 0, ).query((e) => {
|
|
3397
3408
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3398
3409
|
if (!first) first = gated;
|
|
3399
3410
|
last = gated;
|
|
@@ -3423,7 +3434,7 @@ var Act = (_class7 = class {
|
|
|
3423
3434
|
async query_array(query) {
|
|
3424
3435
|
return this._scoped(async () => {
|
|
3425
3436
|
const events = [];
|
|
3426
|
-
await
|
|
3437
|
+
await _chunkBTLM7SW4cjs.store.call(void 0, ).query((e) => {
|
|
3427
3438
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3428
3439
|
}, query);
|
|
3429
3440
|
return events;
|
|
@@ -3443,14 +3454,14 @@ var Act = (_class7 = class {
|
|
|
3443
3454
|
*/
|
|
3444
3455
|
async forget(stream) {
|
|
3445
3456
|
return this._scoped(async () => {
|
|
3446
|
-
const s =
|
|
3457
|
+
const s = _chunkBTLM7SW4cjs.store.call(void 0, );
|
|
3447
3458
|
if (!s.forget_pii) {
|
|
3448
3459
|
throw new Error(
|
|
3449
3460
|
`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).`
|
|
3450
3461
|
);
|
|
3451
3462
|
}
|
|
3452
3463
|
const eventCount = await s.forget_pii(stream);
|
|
3453
|
-
await
|
|
3464
|
+
await _chunkBTLM7SW4cjs.cache.call(void 0, ).invalidate(stream);
|
|
3454
3465
|
if (eventCount > 0) {
|
|
3455
3466
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3456
3467
|
}
|
|
@@ -3484,7 +3495,7 @@ var Act = (_class7 = class {
|
|
|
3484
3495
|
* @see {@link correlate} for dynamic stream discovery
|
|
3485
3496
|
*/
|
|
3486
3497
|
async drain(options = {}) {
|
|
3487
|
-
|
|
3498
|
+
_chunkBTLM7SW4cjs.resolveDrainConfig.call(void 0, options);
|
|
3488
3499
|
if (!this._drain)
|
|
3489
3500
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3490
3501
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3664,7 +3675,7 @@ var Act = (_class7 = class {
|
|
|
3664
3675
|
*/
|
|
3665
3676
|
async reset(input) {
|
|
3666
3677
|
return this._scoped(async () => {
|
|
3667
|
-
const count = await
|
|
3678
|
+
const count = await _chunkBTLM7SW4cjs.store.call(void 0, ).reset(input);
|
|
3668
3679
|
for (const handler of this._batch_handlers.values())
|
|
3669
3680
|
_optionalChain([handler, 'access', _135 => _135[FOLD_RESET], 'optionalCall', _136 => _136()]);
|
|
3670
3681
|
if (count > 0) {
|
|
@@ -3700,7 +3711,7 @@ var Act = (_class7 = class {
|
|
|
3700
3711
|
*/
|
|
3701
3712
|
async unblock(input) {
|
|
3702
3713
|
return this._scoped(async () => {
|
|
3703
|
-
const count = await
|
|
3714
|
+
const count = await _chunkBTLM7SW4cjs.store.call(void 0, ).unblock(input);
|
|
3704
3715
|
if (count > 0) {
|
|
3705
3716
|
this._wake();
|
|
3706
3717
|
}
|
|
@@ -3755,7 +3766,7 @@ var Act = (_class7 = class {
|
|
|
3755
3766
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3756
3767
|
}
|
|
3757
3768
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3758
|
-
const s =
|
|
3769
|
+
const s = _chunkBTLM7SW4cjs.store.call(void 0, );
|
|
3759
3770
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3760
3771
|
return s;
|
|
3761
3772
|
})()));
|
|
@@ -3801,7 +3812,7 @@ var Act = (_class7 = class {
|
|
|
3801
3812
|
async blocked_streams(options) {
|
|
3802
3813
|
return this._scoped(async () => {
|
|
3803
3814
|
const positions = [];
|
|
3804
|
-
await
|
|
3815
|
+
await _chunkBTLM7SW4cjs.store.call(void 0, ).query_streams(
|
|
3805
3816
|
(p) => {
|
|
3806
3817
|
positions.push(p);
|
|
3807
3818
|
},
|
|
@@ -3853,7 +3864,7 @@ var Act = (_class7 = class {
|
|
|
3853
3864
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3854
3865
|
*/
|
|
3855
3866
|
async prioritize(filter, priority) {
|
|
3856
|
-
return this._scoped(() =>
|
|
3867
|
+
return this._scoped(() => _chunkBTLM7SW4cjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3857
3868
|
}
|
|
3858
3869
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3859
3870
|
async _run_close(targets) {
|
|
@@ -3906,8 +3917,8 @@ var Act = (_class7 = class {
|
|
|
3906
3917
|
* `unblock()`, `restore()`) schedules this on its own unless the app
|
|
3907
3918
|
* sets `autoSettle: false`. Call it at startup, to run what was pending
|
|
3908
3919
|
* before a restart, or with options for the next pass; the scheduling
|
|
3909
|
-
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain
|
|
3910
|
-
*
|
|
3920
|
+
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain
|
|
3921
|
+
* passes until one makes no progress (see {@link SettleOptions.maxPasses}),
|
|
3911
3922
|
* then emits the `"settled"` lifecycle event, so one call fully catches
|
|
3912
3923
|
* up paginated streams without forcing callers to loop.
|
|
3913
3924
|
*
|
|
@@ -3933,7 +3944,7 @@ var Act = (_class7 = class {
|
|
|
3933
3944
|
* @see {@link correlate} for manual correlation
|
|
3934
3945
|
*/
|
|
3935
3946
|
settle(options) {
|
|
3936
|
-
|
|
3947
|
+
_chunkBTLM7SW4cjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3937
3948
|
this._schedule(options);
|
|
3938
3949
|
}
|
|
3939
3950
|
}, _class7);
|
|
@@ -4089,16 +4100,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4089
4100
|
}),
|
|
4090
4101
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4091
4102
|
// not quarantine the synthetic stream.
|
|
4092
|
-
options: { blockOnError: false, maxRetries:
|
|
4103
|
+
options: { blockOnError: false, maxRetries: _chunkBTLM7SW4cjs.DEFAULT_MAX_RETRIES },
|
|
4093
4104
|
handler: async (event) => {
|
|
4094
4105
|
const aggregate = event.stream;
|
|
4095
4106
|
const window = read_window();
|
|
4096
4107
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4097
|
-
throw new (0,
|
|
4098
|
-
const stats = await
|
|
4108
|
+
throw new (0, _chunkRF5MV72Kcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4109
|
+
const stats = await _chunkBTLM7SW4cjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4099
4110
|
count: true,
|
|
4100
4111
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4101
|
-
exclude: [
|
|
4112
|
+
exclude: [_chunkRF5MV72Kcjs.TOMBSTONE_EVENT, _chunkRF5MV72Kcjs.SNAP_EVENT]
|
|
4102
4113
|
});
|
|
4103
4114
|
const entry = stats.get(aggregate);
|
|
4104
4115
|
if (!entry) return;
|
|
@@ -4129,7 +4140,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4129
4140
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4130
4141
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4131
4142
|
if (future.length)
|
|
4132
|
-
throw new (0,
|
|
4143
|
+
throw new (0, _chunkRF5MV72Kcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4133
4144
|
}
|
|
4134
4145
|
};
|
|
4135
4146
|
const key = `__autoclose_${st.name}`;
|
|
@@ -4241,6 +4252,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
|
|
|
4241
4252
|
patch: merged_patch,
|
|
4242
4253
|
on: { ...existing.on, ...state2.on },
|
|
4243
4254
|
given: { ...existing.given, ...state2.given },
|
|
4255
|
+
requires: { ...existing.requires, ...state2.requires },
|
|
4244
4256
|
snap: pick_declared(existing.snap, state2.snap, "snap strategy", state2.name),
|
|
4245
4257
|
// Per-action retry policy is keyed by action name, so the two partials'
|
|
4246
4258
|
// maps combine. Left `undefined` when neither declared one, so the
|
|
@@ -4333,9 +4345,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4333
4345
|
|
|
4334
4346
|
// src/builders/builder-utils.ts
|
|
4335
4347
|
function register_lane(config2, lanes) {
|
|
4336
|
-
|
|
4337
|
-
if (config2.name ===
|
|
4338
|
-
throw new Error(`Lane "${
|
|
4348
|
+
_chunkBTLM7SW4cjs.resolveLaneConfig.call(void 0, config2);
|
|
4349
|
+
if (config2.name === _chunkRF5MV72Kcjs.DEFAULT_LANE)
|
|
4350
|
+
throw new Error(`Lane "${_chunkRF5MV72Kcjs.DEFAULT_LANE}" is reserved`);
|
|
4339
4351
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4340
4352
|
if (!existing) return void lanes.push(config2);
|
|
4341
4353
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4377,9 +4389,9 @@ function reaction_on(event, events, builder) {
|
|
|
4377
4389
|
// Validate the whole bag at the declaration site so a bad
|
|
4378
4390
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4379
4391
|
// not a NaN gate on the first retry.
|
|
4380
|
-
options:
|
|
4381
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => (
|
|
4382
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => (
|
|
4392
|
+
options: _chunkBTLM7SW4cjs.resolveReactionConfig.call(void 0, {
|
|
4393
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => ( _chunkBTLM7SW4cjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4394
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => ( _chunkBTLM7SW4cjs.DEFAULT_MAX_RETRIES)),
|
|
4383
4395
|
backoff: _optionalChain([options, 'optionalAccess', _153 => _153.backoff])
|
|
4384
4396
|
})
|
|
4385
4397
|
};
|
|
@@ -4464,7 +4476,7 @@ function date_reviver_schema(schema) {
|
|
|
4464
4476
|
|
|
4465
4477
|
// src/builders/event-builder.ts
|
|
4466
4478
|
function event_tags(schema) {
|
|
4467
|
-
const pii =
|
|
4479
|
+
const pii = _chunkRF5MV72Kcjs.pii_schemas.call(void 0, schema);
|
|
4468
4480
|
const pii_dates = {};
|
|
4469
4481
|
for (const [key, field] of Object.entries(pii)) {
|
|
4470
4482
|
const dates = date_reviver_schema(field);
|
|
@@ -4501,7 +4513,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4501
4513
|
});
|
|
4502
4514
|
}
|
|
4503
4515
|
function build_events(registry, states, lanes, owners) {
|
|
4504
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4516
|
+
const declared = /* @__PURE__ */ new Set([_chunkRF5MV72Kcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4505
4517
|
const lane_errors = [];
|
|
4506
4518
|
const tags = /* @__PURE__ */ new Map();
|
|
4507
4519
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4565,7 +4577,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4565
4577
|
if (reader) readers.set(event_name, reader);
|
|
4566
4578
|
}
|
|
4567
4579
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4568
|
-
if (snap2) readers.set(
|
|
4580
|
+
if (snap2) readers.set(_chunkRF5MV72Kcjs.SNAP_EVENT, snap2);
|
|
4569
4581
|
if (readers.size === 0) continue;
|
|
4570
4582
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4571
4583
|
}
|
|
@@ -4681,7 +4693,7 @@ function act() {
|
|
|
4681
4693
|
const list = deprecation_summary.map(
|
|
4682
4694
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4683
4695
|
).join(", ");
|
|
4684
|
-
|
|
4696
|
+
_chunkBTLM7SW4cjs.log.call(void 0, ).info(
|
|
4685
4697
|
`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.`
|
|
4686
4698
|
);
|
|
4687
4699
|
}
|
|
@@ -4723,7 +4735,7 @@ function act() {
|
|
|
4723
4735
|
return reaction_on(event, registry.events, builder);
|
|
4724
4736
|
},
|
|
4725
4737
|
build: (options) => {
|
|
4726
|
-
|
|
4738
|
+
_chunkBTLM7SW4cjs.resolveActConfig.call(void 0, options);
|
|
4727
4739
|
const patch_fn = _optionalChain([options, 'optionalAccess', _165 => _165.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4728
4740
|
if (!_built) {
|
|
4729
4741
|
for (const proj of pending_projections) add_projection(proj);
|
|
@@ -4775,7 +4787,7 @@ function act() {
|
|
|
4775
4787
|
synthesize_autoclose_reactions(
|
|
4776
4788
|
registry,
|
|
4777
4789
|
states,
|
|
4778
|
-
|
|
4790
|
+
_chunkBTLM7SW4cjs.current_autoclose_window
|
|
4779
4791
|
);
|
|
4780
4792
|
Object.freeze(registry.actions);
|
|
4781
4793
|
Object.freeze(registry.events);
|
|
@@ -4824,8 +4836,8 @@ function _projection(target) {
|
|
|
4824
4836
|
handler,
|
|
4825
4837
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4826
4838
|
options: {
|
|
4827
|
-
blockOnError:
|
|
4828
|
-
maxRetries:
|
|
4839
|
+
blockOnError: _chunkBTLM7SW4cjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4840
|
+
maxRetries: _chunkBTLM7SW4cjs.DEFAULT_MAX_RETRIES
|
|
4829
4841
|
}
|
|
4830
4842
|
}),
|
|
4831
4843
|
widened
|
|
@@ -4866,7 +4878,7 @@ function _projection(target) {
|
|
|
4866
4878
|
throw new Error(
|
|
4867
4879
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4868
4880
|
);
|
|
4869
|
-
const config2 =
|
|
4881
|
+
const config2 = _chunkBTLM7SW4cjs.resolveFoldConfig.call(void 0, options);
|
|
4870
4882
|
const fold_events = {};
|
|
4871
4883
|
for (const partial of partials)
|
|
4872
4884
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4884,8 +4896,8 @@ function _projection(target) {
|
|
|
4884
4896
|
handler: noop,
|
|
4885
4897
|
resolver: { target },
|
|
4886
4898
|
options: {
|
|
4887
|
-
blockOnError:
|
|
4888
|
-
maxRetries:
|
|
4899
|
+
blockOnError: _chunkBTLM7SW4cjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4900
|
+
maxRetries: _chunkBTLM7SW4cjs.DEFAULT_MAX_RETRIES
|
|
4889
4901
|
}
|
|
4890
4902
|
}
|
|
4891
4903
|
]
|
|
@@ -5001,13 +5013,18 @@ function action_builder(state2) {
|
|
|
5001
5013
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5002
5014
|
internal.actions[action2] = schema;
|
|
5003
5015
|
if (options) {
|
|
5004
|
-
|
|
5016
|
+
_chunkBTLM7SW4cjs.resolveActionConfig.call(void 0, options);
|
|
5005
5017
|
internal.options ??= {};
|
|
5006
5018
|
internal.options[action2] = options;
|
|
5007
5019
|
}
|
|
5008
5020
|
function given(rules) {
|
|
5009
5021
|
internal.given ??= {};
|
|
5010
5022
|
internal.given[action2] = rules;
|
|
5023
|
+
return { requires, emit };
|
|
5024
|
+
}
|
|
5025
|
+
function requires(rules) {
|
|
5026
|
+
internal.requires ??= {};
|
|
5027
|
+
internal.requires[action2] = rules;
|
|
5011
5028
|
return { emit };
|
|
5012
5029
|
}
|
|
5013
5030
|
function emit(handler) {
|
|
@@ -5025,7 +5042,7 @@ function action_builder(state2) {
|
|
|
5025
5042
|
}
|
|
5026
5043
|
return builder;
|
|
5027
5044
|
}
|
|
5028
|
-
return { given, emit };
|
|
5045
|
+
return { given, requires, emit };
|
|
5029
5046
|
},
|
|
5030
5047
|
snap(snap2) {
|
|
5031
5048
|
internal.snap = snap2;
|
|
@@ -5290,5 +5307,5 @@ function write_line(writer, line) {
|
|
|
5290
5307
|
|
|
5291
5308
|
|
|
5292
5309
|
|
|
5293
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5310
|
+
exports.Act = Act; exports.ActorSchema = _chunkRF5MV72Kcjs.ActorSchema; exports.CausationEventSchema = _chunkRF5MV72Kcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkRF5MV72Kcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkRF5MV72Kcjs.ConcurrencyError; exports.ConsoleLogger = _chunkBTLM7SW4cjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkRF5MV72Kcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkRF5MV72Kcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkRF5MV72Kcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkRF5MV72Kcjs.DeferSignal; exports.Environments = _chunkRF5MV72Kcjs.Environments; exports.Errors = _chunkRF5MV72Kcjs.Errors; exports.EventMetaSchema = _chunkRF5MV72Kcjs.EventMetaSchema; exports.ExitCodes = _chunkRF5MV72Kcjs.ExitCodes; exports.InMemoryCache = _chunkBTLM7SW4cjs.InMemoryCache; exports.InMemoryStore = _chunkBTLM7SW4cjs.InMemoryStore; exports.InvariantError = _chunkRF5MV72Kcjs.InvariantError; exports.LogLevels = _chunkRF5MV72Kcjs.LogLevels; exports.NonRetryableError = _chunkRF5MV72Kcjs.NonRetryableError; exports.PackageSchema = _chunkBTLM7SW4cjs.PackageSchema; exports.QuerySchema = _chunkRF5MV72Kcjs.QuerySchema; exports.REDACTED = _chunkRF5MV72Kcjs.REDACTED; exports.SHREDDED = _chunkRF5MV72Kcjs.SHREDDED; exports.SNAP_EVENT = _chunkRF5MV72Kcjs.SNAP_EVENT; exports.StoreError = _chunkRF5MV72Kcjs.StoreError; exports.StreamClosedError = _chunkRF5MV72Kcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkRF5MV72Kcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkRF5MV72Kcjs.TargetSchema; exports.ValidationError = _chunkRF5MV72Kcjs.ValidationError; exports.ZodEmpty = _chunkRF5MV72Kcjs.ZodEmpty; exports.act = act; exports.cache = _chunkBTLM7SW4cjs.cache; exports.config = _chunkBTLM7SW4cjs.config; exports.dateReviver = _chunkBTLM7SW4cjs.dateReviver; exports.default_scope = _chunkBTLM7SW4cjs.default_scope; exports.dispose = _chunkBTLM7SW4cjs.dispose; exports.disposeAndExit = _chunkBTLM7SW4cjs.disposeAndExit; exports.extend = _chunkBTLM7SW4cjs.extend; exports.is_literal_source = _chunkBTLM7SW4cjs.is_literal_source; exports.log = _chunkBTLM7SW4cjs.log; exports.pii_fields = _chunkRF5MV72Kcjs.pii_fields; exports.port = _chunkBTLM7SW4cjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkBTLM7SW4cjs.resolveAutocloseConfig2; exports.sensitive = _chunkRF5MV72Kcjs.sensitive; exports.sleep = _chunkBTLM7SW4cjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkBTLM7SW4cjs.store; exports.validate = _chunkBTLM7SW4cjs.validate;
|
|
5294
5311
|
//# sourceMappingURL=index.cjs.map
|