@rotorsoft/act 1.37.4 → 1.37.6
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/builders/act-builder.d.ts +2 -1
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/event-builder.d.ts +0 -1
- package/dist/@types/builders/event-builder.d.ts.map +1 -1
- package/dist/@types/builders/merge.d.ts.map +1 -1
- package/dist/@types/builders/slice-builder.d.ts +2 -1
- package/dist/@types/builders/slice-builder.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-policy.d.ts +8 -7
- package/dist/@types/internal/autoclose-policy.d.ts.map +1 -1
- package/dist/@types/internal/date-reviver.d.ts.map +1 -1
- package/dist/@types/internal/zod.d.ts +6 -3
- package/dist/@types/internal/zod.d.ts.map +1 -1
- package/dist/@types/sensitive.d.ts +1 -2
- package/dist/@types/sensitive.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +7 -3
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +5 -7
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/{chunk-PN5GNW6E.cjs → chunk-H6KVPVP4.cjs} +18 -7
- package/dist/chunk-H6KVPVP4.cjs.map +1 -0
- package/dist/{chunk-FBZY2F5W.js → chunk-HXW3TPP6.js} +2 -2
- package/dist/{chunk-UPKDCTS2.cjs → chunk-PRDX3HP6.cjs} +13 -13
- package/dist/{chunk-UPKDCTS2.cjs.map → chunk-PRDX3HP6.cjs.map} +1 -1
- package/dist/{chunk-CB2OLGJK.js → chunk-V5ZB54DC.js} +17 -6
- package/dist/chunk-V5ZB54DC.js.map +1 -0
- package/dist/index.cjs +168 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -14
- 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-CB2OLGJK.js.map +0 -1
- package/dist/chunk-PN5GNW6E.cjs.map +0 -1
- /package/dist/{chunk-FBZY2F5W.js.map → chunk-HXW3TPP6.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkPRDX3HP6cjs = require('./chunk-PRDX3HP6.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -73,24 +73,25 @@ var _chunkUPKDCTS2cjs = require('./chunk-UPKDCTS2.cjs');
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
var _chunkH6KVPVP4cjs = require('./chunk-H6KVPVP4.cjs');
|
|
77
78
|
|
|
78
79
|
// src/signals.ts
|
|
79
80
|
process.once("SIGINT", async (arg) => {
|
|
80
|
-
|
|
81
|
-
await
|
|
81
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
82
|
+
await _chunkPRDX3HP6cjs.disposeAndExit.call(void 0, "EXIT");
|
|
82
83
|
});
|
|
83
84
|
process.once("SIGTERM", async (arg) => {
|
|
84
|
-
|
|
85
|
-
await
|
|
85
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
86
|
+
await _chunkPRDX3HP6cjs.disposeAndExit.call(void 0, "EXIT");
|
|
86
87
|
});
|
|
87
88
|
process.once("uncaughtException", async (arg) => {
|
|
88
|
-
|
|
89
|
-
await
|
|
89
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
90
|
+
await _chunkPRDX3HP6cjs.disposeAndExit.call(void 0, "ERROR");
|
|
90
91
|
});
|
|
91
92
|
process.once("unhandledRejection", async (arg) => {
|
|
92
|
-
|
|
93
|
-
await
|
|
93
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
94
|
+
await _chunkPRDX3HP6cjs.disposeAndExit.call(void 0, "ERROR");
|
|
94
95
|
});
|
|
95
96
|
|
|
96
97
|
// src/act.ts
|
|
@@ -198,7 +199,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
198
199
|
if (need_stats) {
|
|
199
200
|
const stats = await deps.store().query_stats(
|
|
200
201
|
{},
|
|
201
|
-
{ count: true, names: true, exclude: [
|
|
202
|
+
{ count: true, names: true, exclude: [_chunkH6KVPVP4cjs.SNAP_EVENT] }
|
|
202
203
|
);
|
|
203
204
|
for (const [stream, s] of stats) {
|
|
204
205
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -280,7 +281,7 @@ var make_schema_pass = (deps) => {
|
|
|
280
281
|
return;
|
|
281
282
|
}
|
|
282
283
|
const schema = state2.events[name];
|
|
283
|
-
const sensitive2 =
|
|
284
|
+
const sensitive2 = _chunkH6KVPVP4cjs.pii_fields.call(void 0, schema);
|
|
284
285
|
let parse_schema = schema;
|
|
285
286
|
if (sensitive2.length > 0) {
|
|
286
287
|
const omitter = schema.omit;
|
|
@@ -414,7 +415,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
414
415
|
{
|
|
415
416
|
stream,
|
|
416
417
|
stream_exact: true,
|
|
417
|
-
names: [
|
|
418
|
+
names: [_chunkH6KVPVP4cjs.SNAP_EVENT],
|
|
418
419
|
with_snaps: true
|
|
419
420
|
}
|
|
420
421
|
);
|
|
@@ -841,7 +842,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
841
842
|
deps,
|
|
842
843
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
843
844
|
);
|
|
844
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
845
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkH6KVPVP4cjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
845
846
|
if (retired.length) _optionalChain([deps, 'access', _42 => _42.forget_subscribed, 'optionalCall', _43 => _43(retired)]);
|
|
846
847
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
847
848
|
return { truncated, skipped };
|
|
@@ -923,7 +924,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
923
924
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
924
925
|
return void 0;
|
|
925
926
|
if (t.archive) await t.archive();
|
|
926
|
-
const result = await
|
|
927
|
+
const result = await _chunkPRDX3HP6cjs.store.call(void 0, ).truncate([
|
|
927
928
|
{ stream: t.stream, before: t.before, max_id }
|
|
928
929
|
]);
|
|
929
930
|
return result.get(t.stream);
|
|
@@ -936,10 +937,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
936
937
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
937
938
|
let boundary_id;
|
|
938
939
|
let min_id;
|
|
939
|
-
await
|
|
940
|
+
await _chunkPRDX3HP6cjs.store.call(void 0, ).query(
|
|
940
941
|
(event) => {
|
|
941
942
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
942
|
-
if (event.name ===
|
|
943
|
+
if (event.name === _chunkH6KVPVP4cjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
943
944
|
boundary_id = event.id;
|
|
944
945
|
},
|
|
945
946
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -950,7 +951,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
950
951
|
const min_at = /* @__PURE__ */ new Map();
|
|
951
952
|
const matches = source_matcher();
|
|
952
953
|
await walk_streams(
|
|
953
|
-
|
|
954
|
+
_chunkPRDX3HP6cjs.store.call(void 0, ),
|
|
954
955
|
(position) => {
|
|
955
956
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
956
957
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -978,17 +979,17 @@ function source_matcher() {
|
|
|
978
979
|
};
|
|
979
980
|
}
|
|
980
981
|
async function scan_stream_heads(streams) {
|
|
981
|
-
const stats = await
|
|
982
|
-
exclude: [
|
|
982
|
+
const stats = await _chunkPRDX3HP6cjs.store.call(void 0, ).query_stats(streams, {
|
|
983
|
+
exclude: [_chunkH6KVPVP4cjs.SNAP_EVENT]
|
|
983
984
|
});
|
|
984
|
-
const domain_heads = await
|
|
985
|
-
exclude: [
|
|
985
|
+
const domain_heads = await _chunkPRDX3HP6cjs.store.call(void 0, ).query_stats(streams, {
|
|
986
|
+
exclude: [_chunkH6KVPVP4cjs.SNAP_EVENT, _chunkH6KVPVP4cjs.TOMBSTONE_EVENT]
|
|
986
987
|
});
|
|
987
|
-
const true_heads = await
|
|
988
|
+
const true_heads = await _chunkPRDX3HP6cjs.store.call(void 0, ).query_stats(streams, {});
|
|
988
989
|
const out = /* @__PURE__ */ new Map();
|
|
989
990
|
for (const [stream, { head }] of domain_heads) {
|
|
990
991
|
const marker_head = _optionalChain([stats, 'access', _45 => _45.get, 'call', _46 => _46(stream), 'optionalAccess', _47 => _47.head]);
|
|
991
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) ===
|
|
992
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunkH6KVPVP4cjs.TOMBSTONE_EVENT;
|
|
992
993
|
out.set(stream, {
|
|
993
994
|
max_id: head.id,
|
|
994
995
|
version: true_heads.get(stream).head.version,
|
|
@@ -1012,7 +1013,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
1012
1013
|
const matches = source_matcher();
|
|
1013
1014
|
const targets = [...stream_info.keys()];
|
|
1014
1015
|
await walk_streams(
|
|
1015
|
-
|
|
1016
|
+
_chunkPRDX3HP6cjs.store.call(void 0, ),
|
|
1016
1017
|
(position) => {
|
|
1017
1018
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
1018
1019
|
if (!has_work) return;
|
|
@@ -1078,7 +1079,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
1078
1079
|
}
|
|
1079
1080
|
}
|
|
1080
1081
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
1081
|
-
const heads = await
|
|
1082
|
+
const heads = await _chunkPRDX3HP6cjs.store.call(void 0, ).query_stats(guarded, {});
|
|
1082
1083
|
return guarded.filter((stream) => {
|
|
1083
1084
|
if (_optionalChain([heads, 'access', _55 => _55.get, 'call', _56 => _56(stream), 'optionalAccess', _57 => _57.head, 'access', _58 => _58.id]) === guard_events.get(stream).id)
|
|
1084
1085
|
return true;
|
|
@@ -1096,18 +1097,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1096
1097
|
meta: {
|
|
1097
1098
|
correlation,
|
|
1098
1099
|
causation: {
|
|
1099
|
-
event: { id: guard.id, name:
|
|
1100
|
+
event: { id: guard.id, name: _chunkH6KVPVP4cjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
1100
1101
|
}
|
|
1101
1102
|
}
|
|
1102
1103
|
};
|
|
1103
1104
|
});
|
|
1104
|
-
const truncated = await
|
|
1105
|
+
const truncated = await _chunkPRDX3HP6cjs.store.call(void 0, ).truncate(trunc_targets);
|
|
1105
1106
|
await Promise.all(
|
|
1106
1107
|
guarded.map(async (stream) => {
|
|
1107
1108
|
const entry = truncated.get(stream);
|
|
1108
1109
|
const state2 = seed_states.get(stream);
|
|
1109
1110
|
if (state2 && entry) {
|
|
1110
|
-
await
|
|
1111
|
+
await _chunkPRDX3HP6cjs.cache.call(void 0, ).set(stream, {
|
|
1111
1112
|
stream,
|
|
1112
1113
|
state: state2,
|
|
1113
1114
|
version: entry.committed.version,
|
|
@@ -1116,7 +1117,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1116
1117
|
snaps: 1
|
|
1117
1118
|
});
|
|
1118
1119
|
} else {
|
|
1119
|
-
await
|
|
1120
|
+
await _chunkPRDX3HP6cjs.cache.call(void 0, ).invalidate(stream);
|
|
1120
1121
|
}
|
|
1121
1122
|
})
|
|
1122
1123
|
);
|
|
@@ -1130,7 +1131,7 @@ var _crypto = require('crypto');
|
|
|
1130
1131
|
function report_once(seen, key, message) {
|
|
1131
1132
|
if (seen.has(key)) return;
|
|
1132
1133
|
seen.add(key);
|
|
1133
|
-
|
|
1134
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).error(new Error(message));
|
|
1134
1135
|
}
|
|
1135
1136
|
|
|
1136
1137
|
// src/internal/correlate-cycle.ts
|
|
@@ -1177,7 +1178,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1177
1178
|
// never lets a resolution re-lane them.
|
|
1178
1179
|
|
|
1179
1180
|
__init11() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1180
|
-
__init12() {this._patterns = new (0,
|
|
1181
|
+
__init12() {this._patterns = new (0, _chunkPRDX3HP6cjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1181
1182
|
|
|
1182
1183
|
|
|
1183
1184
|
|
|
@@ -1195,7 +1196,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1195
1196
|
on_init
|
|
1196
1197
|
}) {;_class3.prototype.__init3.call(this);_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);
|
|
1197
1198
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1198
|
-
this._dynamic_subscriptions = new (0,
|
|
1199
|
+
this._dynamic_subscriptions = new (0, _chunkPRDX3HP6cjs.LruMap)(max_subscribed_streams);
|
|
1199
1200
|
this._registry = registry;
|
|
1200
1201
|
this._declared_lanes = declared_lanes;
|
|
1201
1202
|
this._static_targets = static_targets;
|
|
@@ -1253,7 +1254,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1253
1254
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
1254
1255
|
_in_fetch_window(source, stream) {
|
|
1255
1256
|
if (source === void 0 || source === stream) return true;
|
|
1256
|
-
if (
|
|
1257
|
+
if (_chunkPRDX3HP6cjs.is_literal_source.call(void 0, source)) return false;
|
|
1257
1258
|
let pattern = this._patterns.get(source);
|
|
1258
1259
|
if (!pattern) {
|
|
1259
1260
|
pattern = new RegExp(source);
|
|
@@ -1296,7 +1297,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1296
1297
|
const correlated = /* @__PURE__ */ new Map();
|
|
1297
1298
|
let last_id = after;
|
|
1298
1299
|
let stopped = false;
|
|
1299
|
-
const found = await
|
|
1300
|
+
const found = await _chunkPRDX3HP6cjs.store.call(void 0, ).query(
|
|
1300
1301
|
(event) => {
|
|
1301
1302
|
if (stopped) return;
|
|
1302
1303
|
const register = this._registry.events[event.name];
|
|
@@ -1341,9 +1342,9 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1341
1342
|
correlated_at: void 0
|
|
1342
1343
|
};
|
|
1343
1344
|
const seen_in_scan = correlated.has(resolved.target);
|
|
1344
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => (
|
|
1345
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkH6KVPVP4cjs.DEFAULT_LANE));
|
|
1345
1346
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _62 => _62.priority]);
|
|
1346
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
1347
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkH6KVPVP4cjs.DEFAULT_LANE));
|
|
1347
1348
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1348
1349
|
report_lane_conflict(
|
|
1349
1350
|
this._reported,
|
|
@@ -1417,7 +1418,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1417
1418
|
await Promise.all(
|
|
1418
1419
|
missed.map(async ([stream, entry]) => {
|
|
1419
1420
|
let row;
|
|
1420
|
-
await
|
|
1421
|
+
await _chunkPRDX3HP6cjs.store.call(void 0, ).query_streams(
|
|
1421
1422
|
(position) => {
|
|
1422
1423
|
row = position;
|
|
1423
1424
|
},
|
|
@@ -1429,8 +1430,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1429
1430
|
lane: row.lane
|
|
1430
1431
|
});
|
|
1431
1432
|
if (entry.priority > row.priority) return;
|
|
1432
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
1433
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
1433
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkH6KVPVP4cjs.DEFAULT_LANE));
|
|
1434
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkH6KVPVP4cjs.DEFAULT_LANE));
|
|
1434
1435
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
1435
1436
|
report_lane_conflict(
|
|
1436
1437
|
this._reported,
|
|
@@ -1456,8 +1457,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1456
1457
|
millis: 0
|
|
1457
1458
|
});
|
|
1458
1459
|
} catch (error) {
|
|
1459
|
-
|
|
1460
|
-
`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)}`
|
|
1460
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).warn(
|
|
1461
|
+
`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(_nullishCoalesce(error.cause, () => ( error)))}`
|
|
1461
1462
|
);
|
|
1462
1463
|
}
|
|
1463
1464
|
}
|
|
@@ -1609,14 +1610,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1609
1610
|
}
|
|
1610
1611
|
|
|
1611
1612
|
// src/internal/drain-ops.ts
|
|
1612
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1613
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkPRDX3HP6cjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1613
1614
|
async function fetch(leased, eventLimit) {
|
|
1614
1615
|
return Promise.all(
|
|
1615
1616
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1616
1617
|
const events = [];
|
|
1617
|
-
const stream_exact = source !== void 0 &&
|
|
1618
|
+
const stream_exact = source !== void 0 && _chunkPRDX3HP6cjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1618
1619
|
try {
|
|
1619
|
-
await
|
|
1620
|
+
await _chunkPRDX3HP6cjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1620
1621
|
stream: source,
|
|
1621
1622
|
stream_exact,
|
|
1622
1623
|
after: at,
|
|
@@ -1636,9 +1637,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1636
1637
|
})
|
|
1637
1638
|
);
|
|
1638
1639
|
}
|
|
1639
|
-
var ack = (leases) =>
|
|
1640
|
-
var block = (leases) =>
|
|
1641
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1640
|
+
var ack = (leases) => _chunkPRDX3HP6cjs.store.call(void 0, ).ack(leases);
|
|
1641
|
+
var block = (leases) => _chunkPRDX3HP6cjs.store.call(void 0, ).block(leases);
|
|
1642
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkPRDX3HP6cjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1642
1643
|
|
|
1643
1644
|
// src/internal/event-sourcing.ts
|
|
1644
1645
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1653,29 +1654,29 @@ var check_invariants = (target, state2, schema, pii_aware) => {
|
|
|
1653
1654
|
try {
|
|
1654
1655
|
result = schema.safeParse(state2);
|
|
1655
1656
|
} catch (error) {
|
|
1656
|
-
throw new (0,
|
|
1657
|
+
throw new (0, _chunkH6KVPVP4cjs.ValidationError)(target, state2, error);
|
|
1657
1658
|
}
|
|
1658
1659
|
if (result.success) return;
|
|
1659
1660
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1660
1661
|
const value = value_at(state2, issue.path);
|
|
1661
|
-
return value !==
|
|
1662
|
+
return value !== _chunkH6KVPVP4cjs.REDACTED && value !== _chunkH6KVPVP4cjs.SHREDDED;
|
|
1662
1663
|
}) : result.error.issues;
|
|
1663
1664
|
if (issues.length)
|
|
1664
|
-
throw new (0,
|
|
1665
|
+
throw new (0, _chunkH6KVPVP4cjs.ValidationError)(
|
|
1665
1666
|
target,
|
|
1666
1667
|
state2,
|
|
1667
1668
|
_zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
|
|
1668
1669
|
);
|
|
1669
1670
|
};
|
|
1670
1671
|
var DEFAULT_BATCH = 500;
|
|
1671
|
-
var cache_put = (stream, entry) =>
|
|
1672
|
-
(err) =>
|
|
1672
|
+
var cache_put = (stream, entry) => _chunkPRDX3HP6cjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1673
|
+
(err) => _chunkPRDX3HP6cjs.log.call(void 0, ).warn(
|
|
1673
1674
|
err,
|
|
1674
1675
|
"cache set skipped; the next load re-folds from the store"
|
|
1675
1676
|
)
|
|
1676
1677
|
);
|
|
1677
|
-
var cache_drop = (stream) =>
|
|
1678
|
-
(err) =>
|
|
1678
|
+
var cache_drop = (stream) => _chunkPRDX3HP6cjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1679
|
+
(err) => _chunkPRDX3HP6cjs.log.call(void 0, ).warn(
|
|
1679
1680
|
err,
|
|
1680
1681
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1681
1682
|
)
|
|
@@ -1683,9 +1684,9 @@ var cache_drop = (stream) => _chunkUPKDCTS2cjs.cache.call(void 0, ).invalidate(s
|
|
|
1683
1684
|
async function snap(snapshot) {
|
|
1684
1685
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1685
1686
|
try {
|
|
1686
|
-
const [committed] = await
|
|
1687
|
+
const [committed] = await _chunkPRDX3HP6cjs.store.call(void 0, ).commit(
|
|
1687
1688
|
stream,
|
|
1688
|
-
[{ name:
|
|
1689
|
+
[{ name: _chunkH6KVPVP4cjs.SNAP_EVENT, data: snapshot.state }],
|
|
1689
1690
|
{
|
|
1690
1691
|
correlation: meta.correlation,
|
|
1691
1692
|
causation: { event: { id, name, stream } }
|
|
@@ -1696,22 +1697,22 @@ async function snap(snapshot) {
|
|
|
1696
1697
|
return committed;
|
|
1697
1698
|
} catch (error) {
|
|
1698
1699
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1699
|
-
|
|
1700
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).warn(
|
|
1700
1701
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1701
1702
|
);
|
|
1702
1703
|
}
|
|
1703
1704
|
}
|
|
1704
1705
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1705
1706
|
try {
|
|
1706
|
-
const [committed] = await
|
|
1707
|
+
const [committed] = await _chunkPRDX3HP6cjs.store.call(void 0, ).commit(
|
|
1707
1708
|
stream,
|
|
1708
|
-
[{ name:
|
|
1709
|
+
[{ name: _chunkH6KVPVP4cjs.TOMBSTONE_EVENT, data: {} }],
|
|
1709
1710
|
{ correlation, causation: {} },
|
|
1710
1711
|
expectedVersion
|
|
1711
1712
|
);
|
|
1712
1713
|
return committed;
|
|
1713
1714
|
} catch (error) {
|
|
1714
|
-
if (error instanceof
|
|
1715
|
+
if (error instanceof _chunkH6KVPVP4cjs.ConcurrencyError) return void 0;
|
|
1715
1716
|
throw error;
|
|
1716
1717
|
}
|
|
1717
1718
|
}
|
|
@@ -1741,9 +1742,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1741
1742
|
if (drop_closed_streams) {
|
|
1742
1743
|
await source.query(
|
|
1743
1744
|
(e) => {
|
|
1744
|
-
if (e.name ===
|
|
1745
|
+
if (e.name === _chunkH6KVPVP4cjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1745
1746
|
},
|
|
1746
|
-
{ names: [
|
|
1747
|
+
{ names: [_chunkH6KVPVP4cjs.TOMBSTONE_EVENT] }
|
|
1747
1748
|
);
|
|
1748
1749
|
}
|
|
1749
1750
|
let max_id;
|
|
@@ -1765,11 +1766,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1765
1766
|
if (!is_valid(event))
|
|
1766
1767
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1767
1768
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1768
|
-
if (drop_snapshots && event.name ===
|
|
1769
|
+
if (drop_snapshots && event.name === _chunkH6KVPVP4cjs.SNAP_EVENT) {
|
|
1769
1770
|
dropped_snaps++;
|
|
1770
1771
|
return;
|
|
1771
1772
|
}
|
|
1772
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1773
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkH6KVPVP4cjs.TOMBSTONE_EVENT) {
|
|
1773
1774
|
dropped_closed++;
|
|
1774
1775
|
return;
|
|
1775
1776
|
}
|
|
@@ -1836,17 +1837,17 @@ async function scan(source, opts = {}, callback) {
|
|
|
1836
1837
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1837
1838
|
const { stream, actor, asOf } = target;
|
|
1838
1839
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1839
|
-
const cached = time_travel ? void 0 : await
|
|
1840
|
+
const cached = time_travel ? void 0 : await _chunkPRDX3HP6cjs.cache.call(void 0, ).get(stream);
|
|
1840
1841
|
const cache_hit = !!cached;
|
|
1841
1842
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.state]), () => ( (me.init ? me.init() : {})));
|
|
1842
1843
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.patches]), () => ( 0));
|
|
1843
1844
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _75 => _75.snaps]), () => ( 0));
|
|
1844
1845
|
let replayed = 0;
|
|
1845
1846
|
let event;
|
|
1846
|
-
await
|
|
1847
|
+
await _chunkPRDX3HP6cjs.store.call(void 0, ).query(
|
|
1847
1848
|
(raw) => {
|
|
1848
1849
|
event = me.view(raw, actor);
|
|
1849
|
-
if (event.name ===
|
|
1850
|
+
if (event.name === _chunkH6KVPVP4cjs.SNAP_EVENT) {
|
|
1850
1851
|
state2 = event.data;
|
|
1851
1852
|
snaps++;
|
|
1852
1853
|
patches = 0;
|
|
@@ -1855,8 +1856,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1855
1856
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1856
1857
|
patches++;
|
|
1857
1858
|
replayed++;
|
|
1858
|
-
} else if (event.name !==
|
|
1859
|
-
|
|
1859
|
+
} else if (event.name !== _chunkH6KVPVP4cjs.TOMBSTONE_EVENT) {
|
|
1860
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).warn(
|
|
1860
1861
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1861
1862
|
);
|
|
1862
1863
|
}
|
|
@@ -1880,7 +1881,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1880
1881
|
...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
|
|
1881
1882
|
}
|
|
1882
1883
|
);
|
|
1883
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _77 => _77.name]) ===
|
|
1884
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _77 => _77.name]) === _chunkH6KVPVP4cjs.TOMBSTONE_EVENT;
|
|
1884
1885
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1885
1886
|
await cache_put(stream, {
|
|
1886
1887
|
stream,
|
|
@@ -1908,7 +1909,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1908
1909
|
if (!stream) throw new Error("Missing target stream");
|
|
1909
1910
|
const reactingTo = _optionalChain([options, 'optionalAccess', _82 => _82.reactingTo]);
|
|
1910
1911
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _83 => _83.correlator]), () => ( default_correlator));
|
|
1911
|
-
const validated =
|
|
1912
|
+
const validated = _chunkPRDX3HP6cjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1912
1913
|
const opts = _optionalChain([me, 'access', _84 => _84.options, 'optionalAccess', _85 => _85[action2]]);
|
|
1913
1914
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _86 => _86.maxRetries]), () => ( 0));
|
|
1914
1915
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1919,12 +1920,12 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1919
1920
|
void 0,
|
|
1920
1921
|
patch_fn
|
|
1921
1922
|
);
|
|
1922
|
-
if (_optionalChain([snapshot, 'access', _87 => _87.event, 'optionalAccess', _88 => _88.name]) ===
|
|
1923
|
-
throw new (0,
|
|
1923
|
+
if (_optionalChain([snapshot, 'access', _87 => _87.event, 'optionalAccess', _88 => _88.name]) === _chunkH6KVPVP4cjs.TOMBSTONE_EVENT)
|
|
1924
|
+
throw new (0, _chunkH6KVPVP4cjs.StreamClosedError)(stream);
|
|
1924
1925
|
const expected = _nullishCoalesce(expectedVersion, () => ( snapshot.version));
|
|
1925
1926
|
for (const { valid, description } of _nullishCoalesce(_optionalChain([me, 'access', _89 => _89.given, 'optionalAccess', _90 => _90[action2]]), () => ( [])))
|
|
1926
1927
|
if (!valid(snapshot.state, actor))
|
|
1927
|
-
throw new (0,
|
|
1928
|
+
throw new (0, _chunkH6KVPVP4cjs.InvariantError)(
|
|
1928
1929
|
action2,
|
|
1929
1930
|
validated,
|
|
1930
1931
|
target,
|
|
@@ -1933,7 +1934,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1933
1934
|
);
|
|
1934
1935
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _91 => _91.requires, 'optionalAccess', _92 => _92[action2]]), () => ( [])))
|
|
1935
1936
|
if (!holds(validated, snapshot.state, actor))
|
|
1936
|
-
throw new (0,
|
|
1937
|
+
throw new (0, _chunkH6KVPVP4cjs.PreconditionError)(
|
|
1937
1938
|
action2,
|
|
1938
1939
|
validated,
|
|
1939
1940
|
target,
|
|
@@ -1946,7 +1947,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1946
1947
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1947
1948
|
const events = tuples.map(([name, data]) => ({
|
|
1948
1949
|
name,
|
|
1949
|
-
data:
|
|
1950
|
+
data: _chunkPRDX3HP6cjs.validate.call(void 0, name, data, me.events[name])
|
|
1950
1951
|
}));
|
|
1951
1952
|
const emitted = events.map((e) => me.message(e));
|
|
1952
1953
|
const meta = {
|
|
@@ -1993,9 +1994,9 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1993
1994
|
);
|
|
1994
1995
|
let committed;
|
|
1995
1996
|
try {
|
|
1996
|
-
committed = await
|
|
1997
|
+
committed = await _chunkPRDX3HP6cjs.store.call(void 0, ).commit(stream, emitted, meta, expected);
|
|
1997
1998
|
} catch (error) {
|
|
1998
|
-
if (error instanceof
|
|
1999
|
+
if (error instanceof _chunkH6KVPVP4cjs.ConcurrencyError) void cache_drop(stream);
|
|
1999
2000
|
throw error;
|
|
2000
2001
|
}
|
|
2001
2002
|
const snapshots = committed.map((row, i) => ({
|
|
@@ -2022,19 +2023,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
2022
2023
|
});
|
|
2023
2024
|
return snapshots;
|
|
2024
2025
|
} catch (error) {
|
|
2025
|
-
if (!(error instanceof
|
|
2026
|
+
if (!(error instanceof _chunkH6KVPVP4cjs.ConcurrencyError)) throw error;
|
|
2026
2027
|
if (expectedVersion !== void 0) throw error;
|
|
2027
2028
|
if (attempt >= max_retries) throw error;
|
|
2028
2029
|
if (_optionalChain([opts, 'optionalAccess', _99 => _99.backoff])) {
|
|
2029
2030
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
2030
|
-
if (delay_ms > 0) await
|
|
2031
|
+
if (delay_ms > 0) await _chunkPRDX3HP6cjs.sleep.call(void 0, delay_ms);
|
|
2031
2032
|
}
|
|
2032
2033
|
}
|
|
2033
2034
|
}
|
|
2034
2035
|
}
|
|
2035
2036
|
|
|
2036
2037
|
// src/internal/tracing.ts
|
|
2037
|
-
var PRETTY =
|
|
2038
|
+
var PRETTY = _chunkPRDX3HP6cjs.config.call(void 0, ).env !== "production";
|
|
2038
2039
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2039
2040
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2040
2041
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2218,7 +2219,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2218
2219
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _110 => _110.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2219
2220
|
return void 0;
|
|
2220
2221
|
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.`;
|
|
2221
|
-
|
|
2222
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).error(error);
|
|
2222
2223
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2223
2224
|
}
|
|
2224
2225
|
function fetch_failure_policy(registry) {
|
|
@@ -2234,13 +2235,13 @@ function fetch_failure_policy(registry) {
|
|
|
2234
2235
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
2235
2236
|
if (!error) return { lease, handled, acked_at: at };
|
|
2236
2237
|
logger.error(error);
|
|
2237
|
-
const non_retryable = error instanceof
|
|
2238
|
+
const non_retryable = error instanceof _chunkH6KVPVP4cjs.NonRetryableError;
|
|
2238
2239
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2239
2240
|
if (block2)
|
|
2240
2241
|
logger.error(
|
|
2241
2242
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2242
2243
|
);
|
|
2243
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2244
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkPRDX3HP6cjs.DEFAULT_BACKOFF)));
|
|
2244
2245
|
return {
|
|
2245
2246
|
lease,
|
|
2246
2247
|
handled,
|
|
@@ -2368,7 +2369,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2368
2369
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2369
2370
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2370
2371
|
if (acked.length < expected)
|
|
2371
|
-
|
|
2372
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).warn(
|
|
2372
2373
|
`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.`
|
|
2373
2374
|
);
|
|
2374
2375
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2464,9 +2465,9 @@ var DrainController = (_class5 = class {
|
|
|
2464
2465
|
if (!this.armed || this._stopped || this._inflight)
|
|
2465
2466
|
return EMPTY_DRAIN;
|
|
2466
2467
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2467
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2468
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2469
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2468
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkPRDX3HP6cjs.DEFAULT_STREAM_LIMIT));
|
|
2469
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkPRDX3HP6cjs.DEFAULT_EVENT_LIMIT));
|
|
2470
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkPRDX3HP6cjs.DEFAULT_LEASE_MILLIS));
|
|
2470
2471
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2471
2472
|
return EMPTY_DRAIN;
|
|
2472
2473
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2541,7 +2542,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2541
2542
|
const { pii, ...rest } = event;
|
|
2542
2543
|
if (pii == null) {
|
|
2543
2544
|
const shredded = { ...data };
|
|
2544
|
-
for (const f of fields) shredded[f] =
|
|
2545
|
+
for (const f of fields) shredded[f] = _chunkH6KVPVP4cjs.SHREDDED;
|
|
2545
2546
|
return { ...rest, data: shredded };
|
|
2546
2547
|
}
|
|
2547
2548
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -2552,7 +2553,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
2552
2553
|
};
|
|
2553
2554
|
}
|
|
2554
2555
|
const redacted = { ...data };
|
|
2555
|
-
for (const f of fields) redacted[f] =
|
|
2556
|
+
for (const f of fields) redacted[f] = _chunkH6KVPVP4cjs.REDACTED;
|
|
2556
2557
|
return { ...rest, data: redacted };
|
|
2557
2558
|
}
|
|
2558
2559
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -2689,7 +2690,7 @@ function make_deferred(handler, schedule) {
|
|
|
2689
2690
|
const call = handler;
|
|
2690
2691
|
const deferred = async (event, stream, app) => {
|
|
2691
2692
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
2692
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
2693
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkH6KVPVP4cjs.DeferSignal)(when);
|
|
2693
2694
|
return call(event, stream, app);
|
|
2694
2695
|
};
|
|
2695
2696
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -2758,7 +2759,7 @@ function build_handle(deps) {
|
|
|
2758
2759
|
handled++;
|
|
2759
2760
|
}
|
|
2760
2761
|
} catch (error) {
|
|
2761
|
-
if (error instanceof
|
|
2762
|
+
if (error instanceof _chunkH6KVPVP4cjs.DeferSignal) {
|
|
2762
2763
|
let defer;
|
|
2763
2764
|
try {
|
|
2764
2765
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -3030,7 +3031,7 @@ var Act = (_class7 = class {
|
|
|
3030
3031
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3031
3032
|
|
|
3032
3033
|
|
|
3033
|
-
__init27() {this._logger =
|
|
3034
|
+
__init27() {this._logger = _chunkPRDX3HP6cjs.log.call(void 0, )}
|
|
3034
3035
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3035
3036
|
|
|
3036
3037
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3052,9 +3053,9 @@ var Act = (_class7 = class {
|
|
|
3052
3053
|
this._lanes = lanes;
|
|
3053
3054
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3054
3055
|
validate_only_lanes(options.onlyLanes, this._declared_lanes);
|
|
3055
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3056
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkPRDX3HP6cjs.default_scope.call(void 0, )));
|
|
3056
3057
|
const ports = this._ports;
|
|
3057
|
-
this._scoped =
|
|
3058
|
+
this._scoped = _chunkPRDX3HP6cjs.make_run_scoped.call(void 0, {
|
|
3058
3059
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3059
3060
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3060
3061
|
get store() {
|
|
@@ -3064,14 +3065,14 @@ var Act = (_class7 = class {
|
|
|
3064
3065
|
return ports.cache;
|
|
3065
3066
|
},
|
|
3066
3067
|
// Parsed per build, so a bad window throws on every build.
|
|
3067
|
-
autoclose_window:
|
|
3068
|
+
autoclose_window: _chunkPRDX3HP6cjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3068
3069
|
});
|
|
3069
3070
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3070
3071
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3071
3072
|
this._cd = build_drain(this._logger);
|
|
3072
3073
|
const handle = build_handle({
|
|
3073
3074
|
logger: this._logger,
|
|
3074
|
-
reaction_scope:
|
|
3075
|
+
reaction_scope: _chunkPRDX3HP6cjs.make_reaction_scope.call(void 0, {
|
|
3075
3076
|
do: this.do.bind(this),
|
|
3076
3077
|
load: this.load.bind(this),
|
|
3077
3078
|
query: this.query.bind(this),
|
|
@@ -3101,12 +3102,12 @@ var Act = (_class7 = class {
|
|
|
3101
3102
|
this._ports.store,
|
|
3102
3103
|
options.listen !== false
|
|
3103
3104
|
);
|
|
3104
|
-
|
|
3105
|
+
_chunkPRDX3HP6cjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3105
3106
|
}
|
|
3106
3107
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3107
3108
|
_build_breaker(options) {
|
|
3108
3109
|
return new CircuitBreaker(
|
|
3109
|
-
|
|
3110
|
+
_chunkPRDX3HP6cjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3110
3111
|
{
|
|
3111
3112
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3112
3113
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3140,7 +3141,7 @@ var Act = (_class7 = class {
|
|
|
3140
3141
|
try {
|
|
3141
3142
|
await this._run_close(targets);
|
|
3142
3143
|
} catch (error) {
|
|
3143
|
-
if (error instanceof
|
|
3144
|
+
if (error instanceof _chunkH6KVPVP4cjs.StoreError) throw error;
|
|
3144
3145
|
this._logger.error(
|
|
3145
3146
|
error,
|
|
3146
3147
|
`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.`
|
|
@@ -3174,7 +3175,7 @@ var Act = (_class7 = class {
|
|
|
3174
3175
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3175
3176
|
_build_audit_deps() {
|
|
3176
3177
|
return {
|
|
3177
|
-
store:
|
|
3178
|
+
store: _chunkPRDX3HP6cjs.store,
|
|
3178
3179
|
event_to_state: this._event_to_state,
|
|
3179
3180
|
// Declared lanes, not this process's controllers: a lane another
|
|
3180
3181
|
// worker drains is not `unknown-lane`.
|
|
@@ -3187,7 +3188,7 @@ var Act = (_class7 = class {
|
|
|
3187
3188
|
registry: this.registry,
|
|
3188
3189
|
static_targets: classification.static_targets,
|
|
3189
3190
|
cd: this._cd,
|
|
3190
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3191
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkH6KVPVP4cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3191
3192
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3192
3193
|
// still a valid destination.
|
|
3193
3194
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3203,7 +3204,7 @@ var Act = (_class7 = class {
|
|
|
3203
3204
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3204
3205
|
async _seed_persisted_defers() {
|
|
3205
3206
|
const now = Date.now();
|
|
3206
|
-
await walk_streams(
|
|
3207
|
+
await walk_streams(_chunkPRDX3HP6cjs.store.call(void 0, ), (pos) => {
|
|
3207
3208
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3208
3209
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3209
3210
|
_optionalChain([controller, 'optionalAccess', _132 => _132.seed_defer, 'call', _133 => _133(pos.stream, pos.deferred_at)]);
|
|
@@ -3219,7 +3220,7 @@ var Act = (_class7 = class {
|
|
|
3219
3220
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3220
3221
|
breaker: this._breaker
|
|
3221
3222
|
},
|
|
3222
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3223
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkH6KVPVP4cjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3223
3224
|
);
|
|
3224
3225
|
}
|
|
3225
3226
|
|
|
@@ -3239,7 +3240,7 @@ var Act = (_class7 = class {
|
|
|
3239
3240
|
*/
|
|
3240
3241
|
shutdown(options) {
|
|
3241
3242
|
if (!this._shutdown_promise) {
|
|
3242
|
-
|
|
3243
|
+
_chunkPRDX3HP6cjs.resolveShutdownConfig.call(void 0, options);
|
|
3243
3244
|
this._shutdown_promise = (async () => {
|
|
3244
3245
|
this.stop_correlations();
|
|
3245
3246
|
this._settle.stop(true);
|
|
@@ -3257,10 +3258,10 @@ var Act = (_class7 = class {
|
|
|
3257
3258
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3258
3259
|
// default for none or 0, and for a running settle), capped.
|
|
3259
3260
|
_derive_grace_ms(running, settling) {
|
|
3260
|
-
let max = settling ?
|
|
3261
|
+
let max = settling ? _chunkPRDX3HP6cjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3261
3262
|
for (const c of running)
|
|
3262
|
-
max = Math.max(max, c.lease_millis ||
|
|
3263
|
-
return Math.min(max,
|
|
3263
|
+
max = Math.max(max, c.lease_millis || _chunkPRDX3HP6cjs.DEFAULT_LEASE_MILLIS);
|
|
3264
|
+
return Math.min(max, _chunkPRDX3HP6cjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3264
3265
|
}
|
|
3265
3266
|
async _await_inflight(grace_ms) {
|
|
3266
3267
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3343,7 +3344,7 @@ var Act = (_class7 = class {
|
|
|
3343
3344
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3344
3345
|
*/
|
|
3345
3346
|
async do(action2, target, payload, options) {
|
|
3346
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _135 => _135.reactingTo]), () => (
|
|
3347
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _135 => _135.reactingTo]), () => ( _chunkPRDX3HP6cjs.current_reacting.call(void 0, )));
|
|
3347
3348
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _136 => _136.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3348
3349
|
return this._scoped(async () => {
|
|
3349
3350
|
const snapshots = await this._es.action(
|
|
@@ -3409,7 +3410,7 @@ var Act = (_class7 = class {
|
|
|
3409
3410
|
return this._scoped(async () => {
|
|
3410
3411
|
let first;
|
|
3411
3412
|
let last;
|
|
3412
|
-
const count = await
|
|
3413
|
+
const count = await _chunkPRDX3HP6cjs.store.call(void 0, ).query((e) => {
|
|
3413
3414
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3414
3415
|
if (!first) first = gated;
|
|
3415
3416
|
last = gated;
|
|
@@ -3439,7 +3440,7 @@ var Act = (_class7 = class {
|
|
|
3439
3440
|
async query_array(query) {
|
|
3440
3441
|
return this._scoped(async () => {
|
|
3441
3442
|
const events = [];
|
|
3442
|
-
await
|
|
3443
|
+
await _chunkPRDX3HP6cjs.store.call(void 0, ).query((e) => {
|
|
3443
3444
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3444
3445
|
}, query);
|
|
3445
3446
|
return events;
|
|
@@ -3459,14 +3460,14 @@ var Act = (_class7 = class {
|
|
|
3459
3460
|
*/
|
|
3460
3461
|
async forget(stream) {
|
|
3461
3462
|
return this._scoped(async () => {
|
|
3462
|
-
const s =
|
|
3463
|
+
const s = _chunkPRDX3HP6cjs.store.call(void 0, );
|
|
3463
3464
|
if (!s.forget_pii) {
|
|
3464
3465
|
throw new Error(
|
|
3465
3466
|
`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).`
|
|
3466
3467
|
);
|
|
3467
3468
|
}
|
|
3468
3469
|
const eventCount = await s.forget_pii(stream);
|
|
3469
|
-
await
|
|
3470
|
+
await _chunkPRDX3HP6cjs.cache.call(void 0, ).invalidate(stream);
|
|
3470
3471
|
if (eventCount > 0) {
|
|
3471
3472
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3472
3473
|
}
|
|
@@ -3500,7 +3501,7 @@ var Act = (_class7 = class {
|
|
|
3500
3501
|
* @see {@link correlate} for dynamic stream discovery
|
|
3501
3502
|
*/
|
|
3502
3503
|
async drain(options = {}) {
|
|
3503
|
-
|
|
3504
|
+
_chunkPRDX3HP6cjs.resolveDrainConfig.call(void 0, options);
|
|
3504
3505
|
if (!this._drain)
|
|
3505
3506
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3506
3507
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3680,7 +3681,7 @@ var Act = (_class7 = class {
|
|
|
3680
3681
|
*/
|
|
3681
3682
|
async reset(input) {
|
|
3682
3683
|
return this._scoped(async () => {
|
|
3683
|
-
const count = await
|
|
3684
|
+
const count = await _chunkPRDX3HP6cjs.store.call(void 0, ).reset(input);
|
|
3684
3685
|
for (const handler of this._batch_handlers.values())
|
|
3685
3686
|
_optionalChain([handler, 'access', _143 => _143[FOLD_RESET], 'optionalCall', _144 => _144()]);
|
|
3686
3687
|
if (count > 0) {
|
|
@@ -3716,7 +3717,7 @@ var Act = (_class7 = class {
|
|
|
3716
3717
|
*/
|
|
3717
3718
|
async unblock(input) {
|
|
3718
3719
|
return this._scoped(async () => {
|
|
3719
|
-
const count = await
|
|
3720
|
+
const count = await _chunkPRDX3HP6cjs.store.call(void 0, ).unblock(input);
|
|
3720
3721
|
if (count > 0) {
|
|
3721
3722
|
this._wake();
|
|
3722
3723
|
}
|
|
@@ -3771,7 +3772,7 @@ var Act = (_class7 = class {
|
|
|
3771
3772
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3772
3773
|
}
|
|
3773
3774
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3774
|
-
const s =
|
|
3775
|
+
const s = _chunkPRDX3HP6cjs.store.call(void 0, );
|
|
3775
3776
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3776
3777
|
return s;
|
|
3777
3778
|
})()));
|
|
@@ -3817,7 +3818,7 @@ var Act = (_class7 = class {
|
|
|
3817
3818
|
async blocked_streams(options) {
|
|
3818
3819
|
return this._scoped(async () => {
|
|
3819
3820
|
const positions = [];
|
|
3820
|
-
await
|
|
3821
|
+
await _chunkPRDX3HP6cjs.store.call(void 0, ).query_streams(
|
|
3821
3822
|
(p) => {
|
|
3822
3823
|
positions.push(p);
|
|
3823
3824
|
},
|
|
@@ -3869,7 +3870,7 @@ var Act = (_class7 = class {
|
|
|
3869
3870
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3870
3871
|
*/
|
|
3871
3872
|
async prioritize(filter, priority) {
|
|
3872
|
-
return this._scoped(() =>
|
|
3873
|
+
return this._scoped(() => _chunkPRDX3HP6cjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3873
3874
|
}
|
|
3874
3875
|
// Shared by `close()` and reaction-requested closes.
|
|
3875
3876
|
async _run_close(targets) {
|
|
@@ -3949,7 +3950,7 @@ var Act = (_class7 = class {
|
|
|
3949
3950
|
* @see {@link correlate} for manual correlation
|
|
3950
3951
|
*/
|
|
3951
3952
|
settle(options) {
|
|
3952
|
-
|
|
3953
|
+
_chunkPRDX3HP6cjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3953
3954
|
this._schedule(options);
|
|
3954
3955
|
}
|
|
3955
3956
|
}, _class7);
|
|
@@ -4018,9 +4019,13 @@ function policy_min_after_days(options) {
|
|
|
4018
4019
|
if (_optionalChain([parsed, 'access', _147 => _147.or, 'optionalAccess', _148 => _148.after])) windows.push(parsed.or.after.days);
|
|
4019
4020
|
return windows.length ? Math.min(...windows) : void 0;
|
|
4020
4021
|
}
|
|
4022
|
+
function policy_after_windows(options) {
|
|
4023
|
+
const parsed = AutoclosePolicySchema.parse(options);
|
|
4024
|
+
return [parsed.after, _optionalChain([parsed, 'access', _149 => _149.or, 'optionalAccess', _150 => _150.after])].flatMap((w) => w ? [w.days] : []);
|
|
4025
|
+
}
|
|
4021
4026
|
function policy_keep_days(options) {
|
|
4022
4027
|
const parsed = AutoclosePolicySchema.parse(options);
|
|
4023
|
-
return _optionalChain([parsed, 'access',
|
|
4028
|
+
return _optionalChain([parsed, 'access', _151 => _151.keep, 'optionalAccess', _152 => _152.days]);
|
|
4024
4029
|
}
|
|
4025
4030
|
function compile_autoclose_policy(options) {
|
|
4026
4031
|
const parsed = AutoclosePolicySchema.parse(options);
|
|
@@ -4052,7 +4057,7 @@ function hour_in_zone(now, timeZone) {
|
|
|
4052
4057
|
hour: "2-digit",
|
|
4053
4058
|
hourCycle: "h23"
|
|
4054
4059
|
}).formatToParts(now);
|
|
4055
|
-
return Number(_optionalChain([parts, 'access',
|
|
4060
|
+
return Number(_optionalChain([parts, 'access', _153 => _153.find, 'call', _154 => _154((p) => p.type === "hour"), 'optionalAccess', _155 => _155.value]));
|
|
4056
4061
|
}
|
|
4057
4062
|
function hour_in_range(hour, start, end) {
|
|
4058
4063
|
return start < end ? hour >= start && hour < end : hour >= start || hour < end;
|
|
@@ -4089,7 +4094,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4089
4094
|
for (const st of states.values()) {
|
|
4090
4095
|
const predicate = st.autoclose;
|
|
4091
4096
|
if (!predicate) continue;
|
|
4092
|
-
const
|
|
4097
|
+
const after_windows = st.autoclose_after_windows;
|
|
4093
4098
|
const keep_days = st.autoclose_keep_days;
|
|
4094
4099
|
const archiver = st.archive;
|
|
4095
4100
|
const reaction = {
|
|
@@ -4105,16 +4110,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4105
4110
|
}),
|
|
4106
4111
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4107
4112
|
// not quarantine the synthetic stream.
|
|
4108
|
-
options: { blockOnError: false, maxRetries:
|
|
4113
|
+
options: { blockOnError: false, maxRetries: _chunkPRDX3HP6cjs.DEFAULT_MAX_RETRIES },
|
|
4109
4114
|
handler: async (event) => {
|
|
4110
4115
|
const aggregate = event.stream;
|
|
4111
4116
|
const window = read_window();
|
|
4112
4117
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4113
|
-
throw new (0,
|
|
4114
|
-
const stats = await
|
|
4118
|
+
throw new (0, _chunkH6KVPVP4cjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4119
|
+
const stats = await _chunkPRDX3HP6cjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4115
4120
|
count: true,
|
|
4116
4121
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4117
|
-
exclude: [
|
|
4122
|
+
exclude: [_chunkH6KVPVP4cjs.TOMBSTONE_EVENT, _chunkH6KVPVP4cjs.SNAP_EVENT]
|
|
4118
4123
|
});
|
|
4119
4124
|
const entry = stats.get(aggregate);
|
|
4120
4125
|
if (!entry) return;
|
|
@@ -4139,18 +4144,18 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4139
4144
|
});
|
|
4140
4145
|
}
|
|
4141
4146
|
const dues = [];
|
|
4142
|
-
|
|
4143
|
-
dues.push(days_after(head.created,
|
|
4147
|
+
for (const days of after_windows)
|
|
4148
|
+
dues.push(days_after(head.created, days));
|
|
4144
4149
|
if (keep_days !== void 0)
|
|
4145
4150
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
4146
4151
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
4147
4152
|
if (future.length)
|
|
4148
|
-
throw new (0,
|
|
4153
|
+
throw new (0, _chunkH6KVPVP4cjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
4149
4154
|
}
|
|
4150
4155
|
};
|
|
4151
4156
|
const key = `__autoclose_${st.name}`;
|
|
4152
4157
|
for (const event_name of Object.keys(st.events)) {
|
|
4153
|
-
_optionalChain([registry, 'access',
|
|
4158
|
+
_optionalChain([registry, 'access', _156 => _156.events, 'access', _157 => _157[event_name], 'optionalAccess', _158 => _158.reactions, 'access', _159 => _159.set, 'call', _160 => _160(
|
|
4154
4159
|
key,
|
|
4155
4160
|
reaction
|
|
4156
4161
|
)]);
|
|
@@ -4230,6 +4235,7 @@ function autoclose_of(existing, state2) {
|
|
|
4230
4235
|
return {
|
|
4231
4236
|
autoclose: owner.autoclose,
|
|
4232
4237
|
autoclose_after_days: owner.autoclose_after_days,
|
|
4238
|
+
autoclose_after_windows: owner.autoclose_after_windows,
|
|
4233
4239
|
autoclose_keep_days: owner.autoclose_keep_days
|
|
4234
4240
|
};
|
|
4235
4241
|
}
|
|
@@ -4350,9 +4356,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4350
4356
|
|
|
4351
4357
|
// src/builders/builder-utils.ts
|
|
4352
4358
|
function register_lane(config2, lanes) {
|
|
4353
|
-
|
|
4354
|
-
if (config2.name ===
|
|
4355
|
-
throw new Error(`Lane "${
|
|
4359
|
+
_chunkPRDX3HP6cjs.resolveLaneConfig.call(void 0, config2);
|
|
4360
|
+
if (config2.name === _chunkH6KVPVP4cjs.DEFAULT_LANE)
|
|
4361
|
+
throw new Error(`Lane "${_chunkH6KVPVP4cjs.DEFAULT_LANE}" is reserved`);
|
|
4356
4362
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4357
4363
|
if (!existing) return void lanes.push(config2);
|
|
4358
4364
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4394,10 +4400,10 @@ function reaction_on(event, events, builder) {
|
|
|
4394
4400
|
// Validate the whole bag at the declaration site so a bad
|
|
4395
4401
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4396
4402
|
// not a NaN gate on the first retry.
|
|
4397
|
-
options:
|
|
4398
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4399
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4400
|
-
backoff: _optionalChain([options, 'optionalAccess',
|
|
4403
|
+
options: _chunkPRDX3HP6cjs.resolveReactionConfig.call(void 0, {
|
|
4404
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _161 => _161.blockOnError]), () => ( _chunkPRDX3HP6cjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4405
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _162 => _162.maxRetries]), () => ( _chunkPRDX3HP6cjs.DEFAULT_MAX_RETRIES)),
|
|
4406
|
+
backoff: _optionalChain([options, 'optionalAccess', _163 => _163.backoff])
|
|
4401
4407
|
})
|
|
4402
4408
|
};
|
|
4403
4409
|
},
|
|
@@ -4417,7 +4423,7 @@ function reaction_on(event, events, builder) {
|
|
|
4417
4423
|
// src/internal/date-reviver.ts
|
|
4418
4424
|
|
|
4419
4425
|
function variant_schema(schema) {
|
|
4420
|
-
const shape = _optionalChain([
|
|
4426
|
+
const shape = _optionalChain([_chunkH6KVPVP4cjs.def_of.call(void 0, schema), 'optionalAccess', _164 => _164.shape]);
|
|
4421
4427
|
if (!shape) {
|
|
4422
4428
|
const dates = date_reviver_schema(schema);
|
|
4423
4429
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -4432,7 +4438,7 @@ function variant_schema(schema) {
|
|
|
4432
4438
|
return { schema: _zod.z.looseObject(next), dated };
|
|
4433
4439
|
}
|
|
4434
4440
|
function date_reviver_schema(schema) {
|
|
4435
|
-
const def =
|
|
4441
|
+
const def = _chunkH6KVPVP4cjs.def_of.call(void 0, schema);
|
|
4436
4442
|
if (!def) return void 0;
|
|
4437
4443
|
const inner = () => date_reviver_schema(def.innerType);
|
|
4438
4444
|
switch (def.type) {
|
|
@@ -4465,24 +4471,17 @@ function date_reviver_schema(schema) {
|
|
|
4465
4471
|
return variants.some((v) => v.dated) ? _zod.z.union(variants.map((v) => v.schema)) : void 0;
|
|
4466
4472
|
}
|
|
4467
4473
|
case "nullable":
|
|
4468
|
-
return _optionalChain([inner, 'call',
|
|
4474
|
+
return _optionalChain([inner, 'call', _165 => _165(), 'optionalAccess', _166 => _166.nullable, 'call', _167 => _167()]);
|
|
4469
4475
|
case "pipe":
|
|
4470
4476
|
return date_reviver_schema(def.out);
|
|
4471
|
-
case "optional":
|
|
4472
|
-
case "nonoptional":
|
|
4473
|
-
case "readonly":
|
|
4474
|
-
case "default":
|
|
4475
|
-
case "prefault":
|
|
4476
|
-
case "catch":
|
|
4477
|
-
return inner();
|
|
4478
4477
|
default:
|
|
4479
|
-
return void 0;
|
|
4478
|
+
return _chunkH6KVPVP4cjs.inner_of.call(void 0, def) ? inner() : void 0;
|
|
4480
4479
|
}
|
|
4481
4480
|
}
|
|
4482
4481
|
|
|
4483
4482
|
// src/builders/event-builder.ts
|
|
4484
4483
|
function event_tags(schema) {
|
|
4485
|
-
const pii =
|
|
4484
|
+
const pii = _chunkH6KVPVP4cjs.pii_schemas.call(void 0, schema);
|
|
4486
4485
|
const pii_dates = {};
|
|
4487
4486
|
for (const [key, field] of Object.entries(pii)) {
|
|
4488
4487
|
const dates = date_reviver_schema(field);
|
|
@@ -4520,7 +4519,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4520
4519
|
});
|
|
4521
4520
|
}
|
|
4522
4521
|
function build_events(registry, states, lanes, owners) {
|
|
4523
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4522
|
+
const declared = /* @__PURE__ */ new Set([_chunkH6KVPVP4cjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4524
4523
|
const lane_errors = [];
|
|
4525
4524
|
const tags = /* @__PURE__ */ new Map();
|
|
4526
4525
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4595,7 +4594,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4595
4594
|
if (reader) readers.set(event_name, reader);
|
|
4596
4595
|
}
|
|
4597
4596
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4598
|
-
if (snap2) readers.set(
|
|
4597
|
+
if (snap2) readers.set(_chunkH6KVPVP4cjs.SNAP_EVENT, snap2);
|
|
4599
4598
|
if (readers.size === 0) continue;
|
|
4600
4599
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4601
4600
|
}
|
|
@@ -4603,7 +4602,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4603
4602
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4604
4603
|
}
|
|
4605
4604
|
function reads_as_string(schema) {
|
|
4606
|
-
const type = _optionalChain([
|
|
4605
|
+
const type = _optionalChain([_chunkH6KVPVP4cjs.def_of.call(void 0, _chunkH6KVPVP4cjs.output_of.call(void 0, schema)), 'optionalAccess', _168 => _168.type]);
|
|
4607
4606
|
return type === "string" || type === "transform";
|
|
4608
4607
|
}
|
|
4609
4608
|
|
|
@@ -4661,7 +4660,7 @@ function act() {
|
|
|
4661
4660
|
let _built = false;
|
|
4662
4661
|
const read_wrap = (original) => {
|
|
4663
4662
|
const wrapped = async (events, stream) => {
|
|
4664
|
-
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access',
|
|
4663
|
+
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _169 => _169.get, 'call', _170 => _170(e.name), 'optionalCall', _171 => _171(e)]), () => ( e)));
|
|
4665
4664
|
return original(read, stream);
|
|
4666
4665
|
};
|
|
4667
4666
|
const reset = original[FOLD_RESET];
|
|
@@ -4702,7 +4701,7 @@ function act() {
|
|
|
4702
4701
|
});
|
|
4703
4702
|
}
|
|
4704
4703
|
for (const [action_name, handler] of Object.entries(state2.on)) {
|
|
4705
|
-
const static_target = _optionalChain([handler, 'optionalAccess',
|
|
4704
|
+
const static_target = _optionalChain([handler, 'optionalAccess', _172 => _172._static_emit]);
|
|
4706
4705
|
if (static_target && deprecated.has(static_target)) {
|
|
4707
4706
|
const current = current_version_of(static_target, event_names);
|
|
4708
4707
|
throw new Error(
|
|
@@ -4715,7 +4714,7 @@ function act() {
|
|
|
4715
4714
|
const list = deprecation_summary.map(
|
|
4716
4715
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4717
4716
|
).join(", ");
|
|
4718
|
-
|
|
4717
|
+
_chunkPRDX3HP6cjs.log.call(void 0, ).info(
|
|
4719
4718
|
`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.`
|
|
4720
4719
|
);
|
|
4721
4720
|
}
|
|
@@ -4757,7 +4756,7 @@ function act() {
|
|
|
4757
4756
|
return reaction_on(event, registry.events, builder);
|
|
4758
4757
|
},
|
|
4759
4758
|
build: (options) => {
|
|
4760
|
-
|
|
4759
|
+
_chunkPRDX3HP6cjs.resolveActConfig.call(void 0, options);
|
|
4761
4760
|
if (!_built) {
|
|
4762
4761
|
for (const proj of pending_projections) add_projection(proj);
|
|
4763
4762
|
for (const proj of fold_projections) {
|
|
@@ -4775,7 +4774,7 @@ function act() {
|
|
|
4775
4774
|
`State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
|
|
4776
4775
|
);
|
|
4777
4776
|
const claimed = fold_specs.find((s) => s.target === proj.target);
|
|
4778
|
-
if (_optionalChain([claimed, 'optionalAccess',
|
|
4777
|
+
if (_optionalChain([claimed, 'optionalAccess', _173 => _173.projection]) === proj) continue;
|
|
4779
4778
|
if (batch_handlers.has(proj.target) || claimed)
|
|
4780
4779
|
throw new Error(
|
|
4781
4780
|
`Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
|
|
@@ -4797,7 +4796,7 @@ function act() {
|
|
|
4797
4796
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
4798
4797
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
4799
4798
|
finalize_deprecations();
|
|
4800
|
-
if (built.advisory)
|
|
4799
|
+
if (built.advisory) _chunkPRDX3HP6cjs.log.call(void 0, ).warn(built.advisory);
|
|
4801
4800
|
for (const state2 of states.values()) {
|
|
4802
4801
|
if (state2.disclose) _dp.set(state2.name, state2.disclose);
|
|
4803
4802
|
if (state2.autoclose) _ac.set(state2.name, state2.autoclose);
|
|
@@ -4809,7 +4808,7 @@ function act() {
|
|
|
4809
4808
|
synthesize_autoclose_reactions(
|
|
4810
4809
|
registry,
|
|
4811
4810
|
states,
|
|
4812
|
-
|
|
4811
|
+
_chunkPRDX3HP6cjs.current_autoclose_window
|
|
4813
4812
|
);
|
|
4814
4813
|
Object.freeze(registry.actions);
|
|
4815
4814
|
Object.freeze(registry.events);
|
|
@@ -4857,8 +4856,8 @@ function _projection(target) {
|
|
|
4857
4856
|
handler,
|
|
4858
4857
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4859
4858
|
options: {
|
|
4860
|
-
blockOnError:
|
|
4861
|
-
maxRetries:
|
|
4859
|
+
blockOnError: _chunkPRDX3HP6cjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4860
|
+
maxRetries: _chunkPRDX3HP6cjs.DEFAULT_MAX_RETRIES
|
|
4862
4861
|
}
|
|
4863
4862
|
}),
|
|
4864
4863
|
widened
|
|
@@ -4899,7 +4898,7 @@ function _projection(target) {
|
|
|
4899
4898
|
throw new Error(
|
|
4900
4899
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4901
4900
|
);
|
|
4902
|
-
const config2 =
|
|
4901
|
+
const config2 = _chunkPRDX3HP6cjs.resolveFoldConfig.call(void 0, options);
|
|
4903
4902
|
const fold_events = {};
|
|
4904
4903
|
for (const partial of partials)
|
|
4905
4904
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4917,8 +4916,8 @@ function _projection(target) {
|
|
|
4917
4916
|
handler: noop,
|
|
4918
4917
|
resolver: { target },
|
|
4919
4918
|
options: {
|
|
4920
|
-
blockOnError:
|
|
4921
|
-
maxRetries:
|
|
4919
|
+
blockOnError: _chunkPRDX3HP6cjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4920
|
+
maxRetries: _chunkPRDX3HP6cjs.DEFAULT_MAX_RETRIES
|
|
4922
4921
|
}
|
|
4923
4922
|
}
|
|
4924
4923
|
]
|
|
@@ -5034,7 +5033,7 @@ function action_builder(state2) {
|
|
|
5034
5033
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5035
5034
|
internal.actions[action2] = schema;
|
|
5036
5035
|
if (options) {
|
|
5037
|
-
|
|
5036
|
+
_chunkPRDX3HP6cjs.resolveActionConfig.call(void 0, options);
|
|
5038
5037
|
internal.options ??= {};
|
|
5039
5038
|
internal.options[action2] = options;
|
|
5040
5039
|
}
|
|
@@ -5091,6 +5090,7 @@ function action_builder(state2) {
|
|
|
5091
5090
|
policy
|
|
5092
5091
|
);
|
|
5093
5092
|
internal.autoclose_after_days = policy_min_after_days(policy);
|
|
5093
|
+
internal.autoclose_after_windows = policy_after_windows(policy);
|
|
5094
5094
|
internal.autoclose_keep_days = policy_keep_days(policy);
|
|
5095
5095
|
return builder;
|
|
5096
5096
|
},
|
|
@@ -5327,5 +5327,5 @@ function write_line(writer, line) {
|
|
|
5327
5327
|
|
|
5328
5328
|
|
|
5329
5329
|
|
|
5330
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5330
|
+
exports.Act = Act; exports.ActorSchema = _chunkH6KVPVP4cjs.ActorSchema; exports.CausationEventSchema = _chunkH6KVPVP4cjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkH6KVPVP4cjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkH6KVPVP4cjs.ConcurrencyError; exports.ConsoleLogger = _chunkPRDX3HP6cjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkH6KVPVP4cjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkH6KVPVP4cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkH6KVPVP4cjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkH6KVPVP4cjs.DeferSignal; exports.Environments = _chunkH6KVPVP4cjs.Environments; exports.Errors = _chunkH6KVPVP4cjs.Errors; exports.EventMetaSchema = _chunkH6KVPVP4cjs.EventMetaSchema; exports.ExitCodes = _chunkH6KVPVP4cjs.ExitCodes; exports.InMemoryCache = _chunkPRDX3HP6cjs.InMemoryCache; exports.InMemoryStore = _chunkPRDX3HP6cjs.InMemoryStore; exports.InvariantError = _chunkH6KVPVP4cjs.InvariantError; exports.LogLevels = _chunkH6KVPVP4cjs.LogLevels; exports.NonRetryableError = _chunkH6KVPVP4cjs.NonRetryableError; exports.PackageSchema = _chunkPRDX3HP6cjs.PackageSchema; exports.PreconditionError = _chunkH6KVPVP4cjs.PreconditionError; exports.QuerySchema = _chunkH6KVPVP4cjs.QuerySchema; exports.REDACTED = _chunkH6KVPVP4cjs.REDACTED; exports.SHREDDED = _chunkH6KVPVP4cjs.SHREDDED; exports.SNAP_EVENT = _chunkH6KVPVP4cjs.SNAP_EVENT; exports.StoreError = _chunkH6KVPVP4cjs.StoreError; exports.StreamClosedError = _chunkH6KVPVP4cjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkH6KVPVP4cjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkH6KVPVP4cjs.TargetSchema; exports.ValidationError = _chunkH6KVPVP4cjs.ValidationError; exports.ZodEmpty = _chunkH6KVPVP4cjs.ZodEmpty; exports.act = act; exports.cache = _chunkPRDX3HP6cjs.cache; exports.config = _chunkPRDX3HP6cjs.config; exports.dateReviver = _chunkPRDX3HP6cjs.dateReviver; exports.default_scope = _chunkPRDX3HP6cjs.default_scope; exports.dispose = _chunkPRDX3HP6cjs.dispose; exports.disposeAndExit = _chunkPRDX3HP6cjs.disposeAndExit; exports.extend = _chunkPRDX3HP6cjs.extend; exports.is_literal_source = _chunkPRDX3HP6cjs.is_literal_source; exports.log = _chunkPRDX3HP6cjs.log; exports.pii_fields = _chunkH6KVPVP4cjs.pii_fields; exports.port = _chunkPRDX3HP6cjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkPRDX3HP6cjs.resolveAutocloseConfig2; exports.sensitive = _chunkH6KVPVP4cjs.sensitive; exports.sleep = _chunkPRDX3HP6cjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkPRDX3HP6cjs.store; exports.validate = _chunkPRDX3HP6cjs.validate;
|
|
5331
5331
|
//# sourceMappingURL=index.cjs.map
|