@rotorsoft/act 1.33.13 → 1.33.15
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/act.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +19 -8
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/lru-map.d.ts +5 -19
- package/dist/@types/internal/lru-map.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +2 -5
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/{chunk-MSD67APM.js → chunk-E5H3NRCT.js} +1 -1
- package/dist/chunk-E5H3NRCT.js.map +1 -0
- package/dist/{chunk-U54EW4DX.cjs → chunk-EN2KFJ7W.cjs} +1 -1
- package/dist/chunk-EN2KFJ7W.cjs.map +1 -0
- package/dist/index.cjs +120 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -23
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +3 -3
- package/dist/test/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MSD67APM.js.map +0 -1
- package/dist/chunk-U54EW4DX.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkEN2KFJ7Wcjs = require('./chunk-EN2KFJ7W.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -74,20 +74,20 @@ var _chunkPMS6BMIUcjs = require('./chunk-PMS6BMIU.cjs');
|
|
|
74
74
|
|
|
75
75
|
// src/signals.ts
|
|
76
76
|
process.once("SIGINT", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
78
|
+
await _chunkEN2KFJ7Wcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("SIGTERM", async (arg) => {
|
|
81
|
-
|
|
82
|
-
await
|
|
81
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
82
|
+
await _chunkEN2KFJ7Wcjs.disposeAndExit.call(void 0, "EXIT");
|
|
83
83
|
});
|
|
84
84
|
process.once("uncaughtException", async (arg) => {
|
|
85
|
-
|
|
86
|
-
await
|
|
85
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
86
|
+
await _chunkEN2KFJ7Wcjs.disposeAndExit.call(void 0, "ERROR");
|
|
87
87
|
});
|
|
88
88
|
process.once("unhandledRejection", async (arg) => {
|
|
89
|
-
|
|
90
|
-
await
|
|
89
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
90
|
+
await _chunkEN2KFJ7Wcjs.disposeAndExit.call(void 0, "ERROR");
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// src/act.ts
|
|
@@ -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 _chunkEN2KFJ7Wcjs.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,7 +935,7 @@ 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 _chunkEN2KFJ7Wcjs.store.call(void 0, ).query(
|
|
939
939
|
(event) => {
|
|
940
940
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
941
941
|
if (event.name === _chunkPMS6BMIUcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
@@ -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
|
+
_chunkEN2KFJ7Wcjs.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,13 +977,13 @@ function source_matcher() {
|
|
|
977
977
|
};
|
|
978
978
|
}
|
|
979
979
|
async function scan_stream_heads(streams) {
|
|
980
|
-
const stats = await
|
|
980
|
+
const stats = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query_stats(streams, {
|
|
981
981
|
exclude: [_chunkPMS6BMIUcjs.SNAP_EVENT]
|
|
982
982
|
});
|
|
983
|
-
const domain_heads = await
|
|
983
|
+
const domain_heads = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query_stats(streams, {
|
|
984
984
|
exclude: [_chunkPMS6BMIUcjs.SNAP_EVENT, _chunkPMS6BMIUcjs.TOMBSTONE_EVENT]
|
|
985
985
|
});
|
|
986
|
-
const true_heads = await
|
|
986
|
+
const true_heads = await _chunkEN2KFJ7Wcjs.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]);
|
|
@@ -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
|
+
_chunkEN2KFJ7Wcjs.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 _chunkEN2KFJ7Wcjs.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;
|
|
@@ -1100,13 +1100,13 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
1100
1100
|
}
|
|
1101
1101
|
};
|
|
1102
1102
|
});
|
|
1103
|
-
const truncated = await
|
|
1103
|
+
const truncated = await _chunkEN2KFJ7Wcjs.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 _chunkEN2KFJ7Wcjs.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 _chunkEN2KFJ7Wcjs.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
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).error(new Error(message));
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
// src/internal/correlate-cycle.ts
|
|
@@ -1177,7 +1177,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1177
1177
|
// never drops their +Infinity floor.
|
|
1178
1178
|
|
|
1179
1179
|
__init9() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
1180
|
-
__init10() {this._patterns = new (0,
|
|
1180
|
+
__init10() {this._patterns = new (0, _chunkEN2KFJ7Wcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
1181
1181
|
|
|
1182
1182
|
|
|
1183
1183
|
|
|
@@ -1195,7 +1195,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1195
1195
|
on_init
|
|
1196
1196
|
}) {;_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);
|
|
1197
1197
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1198
|
-
this._dynamic_subscriptions = new (0,
|
|
1198
|
+
this._dynamic_subscriptions = new (0, _chunkEN2KFJ7Wcjs.LruMap)(max_subscribed_streams);
|
|
1199
1199
|
this._registry = registry;
|
|
1200
1200
|
this._declared_lanes = declared_lanes;
|
|
1201
1201
|
this._static_targets = static_targets;
|
|
@@ -1246,7 +1246,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1246
1246
|
/** Would the target's own `fetch` (filtered by `source`) return this event? */
|
|
1247
1247
|
_in_fetch_window(source, stream) {
|
|
1248
1248
|
if (source === void 0 || source === stream) return true;
|
|
1249
|
-
if (
|
|
1249
|
+
if (_chunkEN2KFJ7Wcjs.is_literal_source.call(void 0, source)) return false;
|
|
1250
1250
|
let pattern = this._patterns.get(source);
|
|
1251
1251
|
if (!pattern) {
|
|
1252
1252
|
pattern = new RegExp(source);
|
|
@@ -1259,11 +1259,8 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1259
1259
|
await this._init();
|
|
1260
1260
|
const epoch = this._epoch;
|
|
1261
1261
|
const idle = () => ({
|
|
1262
|
-
|
|
1263
|
-
last_id: this._checkpoint
|
|
1264
|
-
read: false,
|
|
1265
|
-
marked: 0,
|
|
1266
|
-
scanned: false
|
|
1262
|
+
kind: "idle",
|
|
1263
|
+
last_id: this._checkpoint
|
|
1267
1264
|
});
|
|
1268
1265
|
if (this._raised === this._lowered) return idle();
|
|
1269
1266
|
const raised = this._raised;
|
|
@@ -1282,7 +1279,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1282
1279
|
const correlated = /* @__PURE__ */ new Map();
|
|
1283
1280
|
let last_id = after;
|
|
1284
1281
|
let stopped = false;
|
|
1285
|
-
const found = await
|
|
1282
|
+
const found = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query(
|
|
1286
1283
|
(event) => {
|
|
1287
1284
|
if (stopped) return;
|
|
1288
1285
|
const register = this._registry.events[event.name];
|
|
@@ -1389,11 +1386,11 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1389
1386
|
lane
|
|
1390
1387
|
});
|
|
1391
1388
|
}
|
|
1392
|
-
return {
|
|
1389
|
+
return { kind: "scanned", last_id, subscribed, marked, read };
|
|
1393
1390
|
}
|
|
1394
1391
|
this._checkpoint = last_id;
|
|
1395
1392
|
if (!stopped && found !== query.limit) this._lowered = raised;
|
|
1396
|
-
return {
|
|
1393
|
+
return { kind: "scanned", last_id, subscribed: 0, marked: 0, read };
|
|
1397
1394
|
}
|
|
1398
1395
|
/**
|
|
1399
1396
|
* Read the row of each target this scan had no record of (new or evicted),
|
|
@@ -1405,7 +1402,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1405
1402
|
await Promise.all(
|
|
1406
1403
|
missed.map(async ([stream, entry]) => {
|
|
1407
1404
|
let row;
|
|
1408
|
-
await
|
|
1405
|
+
await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query_streams(
|
|
1409
1406
|
(position) => {
|
|
1410
1407
|
row = position;
|
|
1411
1408
|
},
|
|
@@ -1445,7 +1442,7 @@ var CorrelateCycle = (_class3 = class {
|
|
|
1445
1442
|
millis: 0
|
|
1446
1443
|
});
|
|
1447
1444
|
} catch (error) {
|
|
1448
|
-
|
|
1445
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).warn(
|
|
1449
1446
|
`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)}`
|
|
1450
1447
|
);
|
|
1451
1448
|
}
|
|
@@ -1598,14 +1595,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1598
1595
|
}
|
|
1599
1596
|
|
|
1600
1597
|
// src/internal/drain-ops.ts
|
|
1601
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1598
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkEN2KFJ7Wcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1602
1599
|
async function fetch(leased, eventLimit) {
|
|
1603
1600
|
return Promise.all(
|
|
1604
1601
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1605
1602
|
const events = [];
|
|
1606
|
-
const stream_exact = source !== void 0 &&
|
|
1603
|
+
const stream_exact = source !== void 0 && _chunkEN2KFJ7Wcjs.is_literal_source.call(void 0, source) ? true : void 0;
|
|
1607
1604
|
try {
|
|
1608
|
-
await
|
|
1605
|
+
await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1609
1606
|
stream: source,
|
|
1610
1607
|
stream_exact,
|
|
1611
1608
|
after: at,
|
|
@@ -1625,30 +1622,30 @@ async function fetch(leased, eventLimit) {
|
|
|
1625
1622
|
})
|
|
1626
1623
|
);
|
|
1627
1624
|
}
|
|
1628
|
-
var ack = (leases) =>
|
|
1629
|
-
var block = (leases) =>
|
|
1630
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1625
|
+
var ack = (leases) => _chunkEN2KFJ7Wcjs.store.call(void 0, ).ack(leases);
|
|
1626
|
+
var block = (leases) => _chunkEN2KFJ7Wcjs.store.call(void 0, ).block(leases);
|
|
1627
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkEN2KFJ7Wcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1631
1628
|
|
|
1632
1629
|
// src/internal/event-sourcing.ts
|
|
1633
1630
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1634
1631
|
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1635
1632
|
var validating_patch = (me, state2, partial, event) => {
|
|
1636
1633
|
const next = _actpatch.patch.call(void 0, state2, partial);
|
|
1637
|
-
return
|
|
1634
|
+
return _chunkEN2KFJ7Wcjs.validate.call(void 0,
|
|
1638
1635
|
`${me.name}.${String(event.name)}#${event.id}`,
|
|
1639
1636
|
next,
|
|
1640
1637
|
me.state
|
|
1641
1638
|
);
|
|
1642
1639
|
};
|
|
1643
1640
|
var DEFAULT_BATCH = 500;
|
|
1644
|
-
var cache_put = (stream, entry) =>
|
|
1645
|
-
(err) =>
|
|
1641
|
+
var cache_put = (stream, entry) => _chunkEN2KFJ7Wcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1642
|
+
(err) => _chunkEN2KFJ7Wcjs.log.call(void 0, ).warn(
|
|
1646
1643
|
err,
|
|
1647
1644
|
"cache set skipped; the next load re-folds from the store"
|
|
1648
1645
|
)
|
|
1649
1646
|
);
|
|
1650
|
-
var cache_drop = (stream) =>
|
|
1651
|
-
(err) =>
|
|
1647
|
+
var cache_drop = (stream) => _chunkEN2KFJ7Wcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1648
|
+
(err) => _chunkEN2KFJ7Wcjs.log.call(void 0, ).warn(
|
|
1652
1649
|
err,
|
|
1653
1650
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1654
1651
|
)
|
|
@@ -1656,7 +1653,7 @@ var cache_drop = (stream) => _chunkU54EW4DXcjs.cache.call(void 0, ).invalidate(s
|
|
|
1656
1653
|
async function snap(snapshot) {
|
|
1657
1654
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1658
1655
|
try {
|
|
1659
|
-
const [committed] = await
|
|
1656
|
+
const [committed] = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).commit(
|
|
1660
1657
|
stream,
|
|
1661
1658
|
[{ name: _chunkPMS6BMIUcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1662
1659
|
{
|
|
@@ -1669,14 +1666,14 @@ async function snap(snapshot) {
|
|
|
1669
1666
|
return committed;
|
|
1670
1667
|
} catch (error) {
|
|
1671
1668
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1672
|
-
|
|
1669
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).warn(
|
|
1673
1670
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1674
1671
|
);
|
|
1675
1672
|
}
|
|
1676
1673
|
}
|
|
1677
1674
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1678
1675
|
try {
|
|
1679
|
-
const [committed] = await
|
|
1676
|
+
const [committed] = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).commit(
|
|
1680
1677
|
stream,
|
|
1681
1678
|
[{ name: _chunkPMS6BMIUcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1682
1679
|
{ correlation, causation: {} },
|
|
@@ -1809,14 +1806,14 @@ async function scan(source, opts = {}, callback) {
|
|
|
1809
1806
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1810
1807
|
const { stream, actor, asOf } = target;
|
|
1811
1808
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1812
|
-
const cached = time_travel ? void 0 : await
|
|
1809
|
+
const cached = time_travel ? void 0 : await _chunkEN2KFJ7Wcjs.cache.call(void 0, ).get(stream);
|
|
1813
1810
|
const cache_hit = !!cached;
|
|
1814
1811
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _72 => _72.state]), () => ( (me.init ? me.init() : {})));
|
|
1815
1812
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.patches]), () => ( 0));
|
|
1816
1813
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.snaps]), () => ( 0));
|
|
1817
1814
|
let replayed = 0;
|
|
1818
1815
|
let event;
|
|
1819
|
-
await
|
|
1816
|
+
await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query(
|
|
1820
1817
|
(raw) => {
|
|
1821
1818
|
event = me.view(raw, actor);
|
|
1822
1819
|
if (event.name === _chunkPMS6BMIUcjs.SNAP_EVENT) {
|
|
@@ -1829,7 +1826,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1829
1826
|
patches++;
|
|
1830
1827
|
replayed++;
|
|
1831
1828
|
} else if (event.name !== _chunkPMS6BMIUcjs.TOMBSTONE_EVENT) {
|
|
1832
|
-
|
|
1829
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).warn(
|
|
1833
1830
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1834
1831
|
);
|
|
1835
1832
|
}
|
|
@@ -1881,7 +1878,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1881
1878
|
if (!stream) throw new Error("Missing target stream");
|
|
1882
1879
|
const reactingTo = _optionalChain([options, 'optionalAccess', _81 => _81.reactingTo]);
|
|
1883
1880
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.correlator]), () => ( default_correlator));
|
|
1884
|
-
const validated =
|
|
1881
|
+
const validated = _chunkEN2KFJ7Wcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1885
1882
|
const opts = _optionalChain([me, 'access', _83 => _83.options, 'optionalAccess', _84 => _84[action2]]);
|
|
1886
1883
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries]), () => ( 0));
|
|
1887
1884
|
for (let attempt = 0; ; attempt++) {
|
|
@@ -1916,7 +1913,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1916
1913
|
const tuples = Array.isArray(result[0]) ? result : [result];
|
|
1917
1914
|
const valid = tuples.map(([name, data]) => ({
|
|
1918
1915
|
name,
|
|
1919
|
-
data:
|
|
1916
|
+
data: _chunkEN2KFJ7Wcjs.validate.call(void 0, name, data, me.events[name])
|
|
1920
1917
|
}));
|
|
1921
1918
|
const emitted = valid.map((e) => me.message(e));
|
|
1922
1919
|
const meta = {
|
|
@@ -1941,7 +1938,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1941
1938
|
};
|
|
1942
1939
|
let committed;
|
|
1943
1940
|
try {
|
|
1944
|
-
committed = await
|
|
1941
|
+
committed = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).commit(
|
|
1945
1942
|
stream,
|
|
1946
1943
|
emitted,
|
|
1947
1944
|
meta,
|
|
@@ -1994,14 +1991,14 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1994
1991
|
if (attempt >= max_retries) throw error;
|
|
1995
1992
|
if (_optionalChain([opts, 'optionalAccess', _94 => _94.backoff])) {
|
|
1996
1993
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1997
|
-
if (delay_ms > 0) await
|
|
1994
|
+
if (delay_ms > 0) await _chunkEN2KFJ7Wcjs.sleep.call(void 0, delay_ms);
|
|
1998
1995
|
}
|
|
1999
1996
|
}
|
|
2000
1997
|
}
|
|
2001
1998
|
}
|
|
2002
1999
|
|
|
2003
2000
|
// src/internal/tracing.ts
|
|
2004
|
-
var PRETTY =
|
|
2001
|
+
var PRETTY = _chunkEN2KFJ7Wcjs.config.call(void 0, ).env !== "production";
|
|
2005
2002
|
var C_BLUE = "\x1B[38;5;39m";
|
|
2006
2003
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
2007
2004
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -2187,7 +2184,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
2187
2184
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _104 => _104.blockOnError]) || lease.retry <= options.maxRetries)
|
|
2188
2185
|
return void 0;
|
|
2189
2186
|
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.`;
|
|
2190
|
-
|
|
2187
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).error(error);
|
|
2191
2188
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
2192
2189
|
}
|
|
2193
2190
|
function fetch_failure_policy(registry) {
|
|
@@ -2209,7 +2206,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
2209
2206
|
logger.error(
|
|
2210
2207
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2211
2208
|
);
|
|
2212
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2209
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkEN2KFJ7Wcjs.DEFAULT_BACKOFF)));
|
|
2213
2210
|
return {
|
|
2214
2211
|
lease,
|
|
2215
2212
|
handled,
|
|
@@ -2338,7 +2335,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2338
2335
|
const acked = await ops.ack(submitted);
|
|
2339
2336
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2340
2337
|
if (acked.length < expected)
|
|
2341
|
-
|
|
2338
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).warn(
|
|
2342
2339
|
`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.`
|
|
2343
2340
|
);
|
|
2344
2341
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2436,9 +2433,9 @@ var DrainController = (_class5 = class {
|
|
|
2436
2433
|
if (!this.armed || this._stopped || this._inflight)
|
|
2437
2434
|
return EMPTY_DRAIN;
|
|
2438
2435
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2439
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2440
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2441
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2436
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkEN2KFJ7Wcjs.DEFAULT_STREAM_LIMIT));
|
|
2437
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkEN2KFJ7Wcjs.DEFAULT_EVENT_LIMIT));
|
|
2438
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkEN2KFJ7Wcjs.DEFAULT_LEASE_MILLIS));
|
|
2442
2439
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2443
2440
|
return EMPTY_DRAIN;
|
|
2444
2441
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2868,11 +2865,12 @@ var SettleLoop = (_class6 = class {
|
|
|
2868
2865
|
this._inflight = (async () => {
|
|
2869
2866
|
const passes = [];
|
|
2870
2867
|
for (let i = 0; i < maxPasses && !this._stopped; i++) {
|
|
2871
|
-
const
|
|
2868
|
+
const pass = await this._deps.correlate(correlate_query);
|
|
2869
|
+
const scanned = pass.kind === "scanned";
|
|
2872
2870
|
if (scanned) this._deps.breaker.passed();
|
|
2873
2871
|
const drain = await this._deps.drain(drain_options);
|
|
2874
2872
|
passes.push(drain);
|
|
2875
|
-
const made_progress =
|
|
2873
|
+
const made_progress = drain.leased.length > 0 || scanned && (pass.subscribed > 0 || pass.read);
|
|
2876
2874
|
if (!made_progress) break;
|
|
2877
2875
|
}
|
|
2878
2876
|
if (passes.length) this._deps.on_settled(merge_drains(passes));
|
|
@@ -2997,7 +2995,7 @@ var Act = (_class7 = class {
|
|
|
2997
2995
|
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
2998
2996
|
|
|
2999
2997
|
|
|
3000
|
-
__init25() {this._logger =
|
|
2998
|
+
__init25() {this._logger = _chunkEN2KFJ7Wcjs.log.call(void 0, )}
|
|
3001
2999
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3002
3000
|
|
|
3003
3001
|
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
@@ -3019,9 +3017,9 @@ var Act = (_class7 = class {
|
|
|
3019
3017
|
this._lanes = lanes;
|
|
3020
3018
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3021
3019
|
validate_only_lanes(options, lanes);
|
|
3022
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3020
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkEN2KFJ7Wcjs.default_scope.call(void 0, )));
|
|
3023
3021
|
const ports = this._ports;
|
|
3024
|
-
this._scoped =
|
|
3022
|
+
this._scoped = _chunkEN2KFJ7Wcjs.make_run_scoped.call(void 0, {
|
|
3025
3023
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3026
3024
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3027
3025
|
get store() {
|
|
@@ -3031,14 +3029,14 @@ var Act = (_class7 = class {
|
|
|
3031
3029
|
return ports.cache;
|
|
3032
3030
|
},
|
|
3033
3031
|
// Parsed per build, so a bad window throws on every build.
|
|
3034
|
-
autoclose_window:
|
|
3032
|
+
autoclose_window: _chunkEN2KFJ7Wcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3035
3033
|
});
|
|
3036
3034
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3037
3035
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3038
3036
|
this._cd = build_drain(this._logger);
|
|
3039
3037
|
const handle = build_handle({
|
|
3040
3038
|
logger: this._logger,
|
|
3041
|
-
reaction_scope:
|
|
3039
|
+
reaction_scope: _chunkEN2KFJ7Wcjs.make_reaction_scope.call(void 0, {
|
|
3042
3040
|
do: this.do.bind(this),
|
|
3043
3041
|
load: this.load.bind(this),
|
|
3044
3042
|
query: this.query.bind(this),
|
|
@@ -3068,12 +3066,12 @@ var Act = (_class7 = class {
|
|
|
3068
3066
|
this._ports.store,
|
|
3069
3067
|
options.listen !== false
|
|
3070
3068
|
);
|
|
3071
|
-
|
|
3069
|
+
_chunkEN2KFJ7Wcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3072
3070
|
}
|
|
3073
3071
|
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
3074
3072
|
_build_breaker(options) {
|
|
3075
3073
|
return new CircuitBreaker(
|
|
3076
|
-
|
|
3074
|
+
_chunkEN2KFJ7Wcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3077
3075
|
{
|
|
3078
3076
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3079
3077
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3142,7 +3140,7 @@ var Act = (_class7 = class {
|
|
|
3142
3140
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
3143
3141
|
_build_audit_deps() {
|
|
3144
3142
|
return {
|
|
3145
|
-
store:
|
|
3143
|
+
store: _chunkEN2KFJ7Wcjs.store,
|
|
3146
3144
|
event_to_state: this._event_to_state,
|
|
3147
3145
|
// Declared lanes, not this process's controllers: a lane another
|
|
3148
3146
|
// worker drains is not `unknown-lane`.
|
|
@@ -3171,7 +3169,7 @@ var Act = (_class7 = class {
|
|
|
3171
3169
|
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
3172
3170
|
async _seed_persisted_defers() {
|
|
3173
3171
|
const now = Date.now();
|
|
3174
|
-
await walk_streams(
|
|
3172
|
+
await walk_streams(_chunkEN2KFJ7Wcjs.store.call(void 0, ), (pos) => {
|
|
3175
3173
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3176
3174
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3177
3175
|
_optionalChain([controller, 'optionalAccess', _124 => _124.seed_defer, 'call', _125 => _125(pos.stream, pos.deferred_at)]);
|
|
@@ -3180,7 +3178,7 @@ var Act = (_class7 = class {
|
|
|
3180
3178
|
_build_settle(options) {
|
|
3181
3179
|
return new SettleLoop(
|
|
3182
3180
|
{
|
|
3183
|
-
correlate: (q) => this.
|
|
3181
|
+
correlate: (q) => this._correlate_pass(
|
|
3184
3182
|
{ ...q, limit: _nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)) },
|
|
3185
3183
|
true
|
|
3186
3184
|
),
|
|
@@ -3210,7 +3208,7 @@ var Act = (_class7 = class {
|
|
|
3210
3208
|
*/
|
|
3211
3209
|
shutdown(options) {
|
|
3212
3210
|
if (!this._shutdown_promise) {
|
|
3213
|
-
|
|
3211
|
+
_chunkEN2KFJ7Wcjs.resolveShutdownConfig.call(void 0, options);
|
|
3214
3212
|
this._shutdown_promise = (async () => {
|
|
3215
3213
|
this.stop_correlations();
|
|
3216
3214
|
this._settle.stop(true);
|
|
@@ -3230,10 +3228,10 @@ var Act = (_class7 = class {
|
|
|
3230
3228
|
* default for none or 0, and for a running settle), capped.
|
|
3231
3229
|
*/
|
|
3232
3230
|
_derive_grace_ms(running, settling) {
|
|
3233
|
-
let max = settling ?
|
|
3231
|
+
let max = settling ? _chunkEN2KFJ7Wcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3234
3232
|
for (const c of running)
|
|
3235
|
-
max = Math.max(max, c.lease_millis ||
|
|
3236
|
-
return Math.min(max,
|
|
3233
|
+
max = Math.max(max, c.lease_millis || _chunkEN2KFJ7Wcjs.DEFAULT_LEASE_MILLIS);
|
|
3234
|
+
return Math.min(max, _chunkEN2KFJ7Wcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3237
3235
|
}
|
|
3238
3236
|
async _await_inflight(grace_ms) {
|
|
3239
3237
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3243,15 +3241,16 @@ var Act = (_class7 = class {
|
|
|
3243
3241
|
if (running.length === 0 && !settling) return;
|
|
3244
3242
|
const grace = _nullishCoalesce(grace_ms, () => ( this._derive_grace_ms(running, !!settling)));
|
|
3245
3243
|
if (grace <= 0) return;
|
|
3246
|
-
const inflight = running.map((c) => c.inflight);
|
|
3247
|
-
if (settling) inflight.push(settling);
|
|
3248
3244
|
let timer;
|
|
3249
3245
|
const budget = new Promise((resolve) => {
|
|
3250
3246
|
timer = setTimeout(resolve, grace);
|
|
3251
3247
|
timer.unref();
|
|
3252
3248
|
});
|
|
3253
3249
|
try {
|
|
3254
|
-
await Promise.race([
|
|
3250
|
+
await Promise.race([
|
|
3251
|
+
Promise.all([...running.map((c) => c.inflight), settling]),
|
|
3252
|
+
budget
|
|
3253
|
+
]);
|
|
3255
3254
|
} finally {
|
|
3256
3255
|
clearTimeout(timer);
|
|
3257
3256
|
}
|
|
@@ -3313,7 +3312,7 @@ var Act = (_class7 = class {
|
|
|
3313
3312
|
* @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
|
|
3314
3313
|
*/
|
|
3315
3314
|
async do(action2, target, payload, options) {
|
|
3316
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => (
|
|
3315
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.reactingTo]), () => ( _chunkEN2KFJ7Wcjs.current_reacting.call(void 0, )));
|
|
3317
3316
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _128 => _128.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3318
3317
|
return this._scoped(async () => {
|
|
3319
3318
|
const snapshots = await this._es.action(
|
|
@@ -3374,7 +3373,7 @@ var Act = (_class7 = class {
|
|
|
3374
3373
|
return this._scoped(async () => {
|
|
3375
3374
|
let first;
|
|
3376
3375
|
let last;
|
|
3377
|
-
const count = await
|
|
3376
|
+
const count = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query((e) => {
|
|
3378
3377
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3379
3378
|
if (!first) first = gated;
|
|
3380
3379
|
last = gated;
|
|
@@ -3404,7 +3403,7 @@ var Act = (_class7 = class {
|
|
|
3404
3403
|
async query_array(query) {
|
|
3405
3404
|
return this._scoped(async () => {
|
|
3406
3405
|
const events = [];
|
|
3407
|
-
await
|
|
3406
|
+
await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query((e) => {
|
|
3408
3407
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3409
3408
|
}, query);
|
|
3410
3409
|
return events;
|
|
@@ -3424,14 +3423,14 @@ var Act = (_class7 = class {
|
|
|
3424
3423
|
*/
|
|
3425
3424
|
async forget(stream) {
|
|
3426
3425
|
return this._scoped(async () => {
|
|
3427
|
-
const s =
|
|
3426
|
+
const s = _chunkEN2KFJ7Wcjs.store.call(void 0, );
|
|
3428
3427
|
if (!s.forget_pii) {
|
|
3429
3428
|
throw new Error(
|
|
3430
3429
|
`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).`
|
|
3431
3430
|
);
|
|
3432
3431
|
}
|
|
3433
3432
|
const eventCount = await s.forget_pii(stream);
|
|
3434
|
-
await
|
|
3433
|
+
await _chunkEN2KFJ7Wcjs.cache.call(void 0, ).invalidate(stream);
|
|
3435
3434
|
if (eventCount > 0) {
|
|
3436
3435
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3437
3436
|
}
|
|
@@ -3465,7 +3464,7 @@ var Act = (_class7 = class {
|
|
|
3465
3464
|
* @see {@link correlate} for dynamic stream discovery
|
|
3466
3465
|
*/
|
|
3467
3466
|
async drain(options = {}) {
|
|
3468
|
-
|
|
3467
|
+
_chunkEN2KFJ7Wcjs.resolveDrainConfig.call(void 0, options);
|
|
3469
3468
|
if (!this._drain)
|
|
3470
3469
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3471
3470
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -3542,17 +3541,20 @@ var Act = (_class7 = class {
|
|
|
3542
3541
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3543
3542
|
*/
|
|
3544
3543
|
async correlate(query = { after: -1, limit: 10 }) {
|
|
3545
|
-
const
|
|
3546
|
-
return {
|
|
3544
|
+
const pass = await this._correlate_pass(query);
|
|
3545
|
+
return {
|
|
3546
|
+
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
3547
|
+
last_id: pass.last_id
|
|
3548
|
+
};
|
|
3547
3549
|
}
|
|
3548
|
-
/**
|
|
3549
|
-
async
|
|
3550
|
-
if (!this._drain)
|
|
3551
|
-
return { subscribed: 0, last_id: -1, read: false, scanned: false };
|
|
3550
|
+
/** One correlate pass; arms every lane when it found work. */
|
|
3551
|
+
async _correlate_pass(query, lease = false) {
|
|
3552
|
+
if (!this._drain) return { kind: "idle", last_id: -1 };
|
|
3552
3553
|
return this._scoped(async () => {
|
|
3553
|
-
const
|
|
3554
|
-
if (subscribed > 0 || marked > 0)
|
|
3555
|
-
|
|
3554
|
+
const pass = await this._correlate.correlate(query, lease);
|
|
3555
|
+
if (pass.kind === "scanned" && (pass.subscribed > 0 || pass.marked > 0))
|
|
3556
|
+
this._arm_all();
|
|
3557
|
+
return pass;
|
|
3556
3558
|
});
|
|
3557
3559
|
}
|
|
3558
3560
|
/**
|
|
@@ -3642,7 +3644,7 @@ var Act = (_class7 = class {
|
|
|
3642
3644
|
*/
|
|
3643
3645
|
async reset(input) {
|
|
3644
3646
|
return this._scoped(async () => {
|
|
3645
|
-
const count = await
|
|
3647
|
+
const count = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).reset(input);
|
|
3646
3648
|
for (const handler of this._batch_handlers.values())
|
|
3647
3649
|
_optionalChain([handler, 'access', _135 => _135[FOLD_RESET], 'optionalCall', _136 => _136()]);
|
|
3648
3650
|
if (count > 0) {
|
|
@@ -3678,7 +3680,7 @@ var Act = (_class7 = class {
|
|
|
3678
3680
|
*/
|
|
3679
3681
|
async unblock(input) {
|
|
3680
3682
|
return this._scoped(async () => {
|
|
3681
|
-
const count = await
|
|
3683
|
+
const count = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).unblock(input);
|
|
3682
3684
|
if (count > 0) {
|
|
3683
3685
|
this._wake();
|
|
3684
3686
|
}
|
|
@@ -3727,7 +3729,7 @@ var Act = (_class7 = class {
|
|
|
3727
3729
|
return { ...partial, duration_ms: Date.now() - started };
|
|
3728
3730
|
}
|
|
3729
3731
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
3730
|
-
const s =
|
|
3732
|
+
const s = _chunkEN2KFJ7Wcjs.store.call(void 0, );
|
|
3731
3733
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
3732
3734
|
return s;
|
|
3733
3735
|
})()));
|
|
@@ -3772,7 +3774,7 @@ var Act = (_class7 = class {
|
|
|
3772
3774
|
async blocked_streams(options) {
|
|
3773
3775
|
return this._scoped(async () => {
|
|
3774
3776
|
const positions = [];
|
|
3775
|
-
await
|
|
3777
|
+
await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query_streams(
|
|
3776
3778
|
(p) => {
|
|
3777
3779
|
positions.push(p);
|
|
3778
3780
|
},
|
|
@@ -3824,7 +3826,7 @@ var Act = (_class7 = class {
|
|
|
3824
3826
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
3825
3827
|
*/
|
|
3826
3828
|
async prioritize(filter, priority) {
|
|
3827
|
-
return this._scoped(() =>
|
|
3829
|
+
return this._scoped(() => _chunkEN2KFJ7Wcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
3828
3830
|
}
|
|
3829
3831
|
/** Shared by `close()` and reaction-requested closes. */
|
|
3830
3832
|
async _run_close(targets) {
|
|
@@ -3904,7 +3906,7 @@ var Act = (_class7 = class {
|
|
|
3904
3906
|
* @see {@link correlate} for manual correlation
|
|
3905
3907
|
*/
|
|
3906
3908
|
settle(options) {
|
|
3907
|
-
|
|
3909
|
+
_chunkEN2KFJ7Wcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
3908
3910
|
this._schedule(options);
|
|
3909
3911
|
}
|
|
3910
3912
|
}, _class7);
|
|
@@ -4060,13 +4062,13 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
4060
4062
|
}),
|
|
4061
4063
|
// Never block on autoclose: a transient query/store error should retry,
|
|
4062
4064
|
// not quarantine the synthetic stream.
|
|
4063
|
-
options: { blockOnError: false, maxRetries:
|
|
4065
|
+
options: { blockOnError: false, maxRetries: _chunkEN2KFJ7Wcjs.DEFAULT_MAX_RETRIES },
|
|
4064
4066
|
handler: async (event) => {
|
|
4065
4067
|
const aggregate = event.stream;
|
|
4066
4068
|
const window = read_window();
|
|
4067
4069
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
4068
4070
|
throw new (0, _chunkPMS6BMIUcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
4069
|
-
const stats = await
|
|
4071
|
+
const stats = await _chunkEN2KFJ7Wcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
4070
4072
|
count: true,
|
|
4071
4073
|
tail: keep_days !== void 0 ? true : void 0,
|
|
4072
4074
|
exclude: [_chunkPMS6BMIUcjs.TOMBSTONE_EVENT, _chunkPMS6BMIUcjs.SNAP_EVENT]
|
|
@@ -4304,7 +4306,7 @@ var _this_ = ({ stream }) => ({
|
|
|
4304
4306
|
|
|
4305
4307
|
// src/builders/builder-utils.ts
|
|
4306
4308
|
function register_lane(config2, lanes) {
|
|
4307
|
-
|
|
4309
|
+
_chunkEN2KFJ7Wcjs.resolveLaneConfig.call(void 0, config2);
|
|
4308
4310
|
if (config2.name === _chunkPMS6BMIUcjs.DEFAULT_LANE)
|
|
4309
4311
|
throw new Error(`Lane "${_chunkPMS6BMIUcjs.DEFAULT_LANE}" is reserved`);
|
|
4310
4312
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
@@ -4348,9 +4350,9 @@ function reaction_on(event, events, builder) {
|
|
|
4348
4350
|
// Validate the whole bag at the declaration site so a bad
|
|
4349
4351
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4350
4352
|
// not a NaN gate on the first retry.
|
|
4351
|
-
options:
|
|
4352
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => (
|
|
4353
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => (
|
|
4353
|
+
options: _chunkEN2KFJ7Wcjs.resolveReactionConfig.call(void 0, {
|
|
4354
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _151 => _151.blockOnError]), () => ( _chunkEN2KFJ7Wcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4355
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.maxRetries]), () => ( _chunkEN2KFJ7Wcjs.DEFAULT_MAX_RETRIES)),
|
|
4354
4356
|
backoff: _optionalChain([options, 'optionalAccess', _153 => _153.backoff])
|
|
4355
4357
|
})
|
|
4356
4358
|
};
|
|
@@ -4652,7 +4654,7 @@ function act() {
|
|
|
4652
4654
|
const list = deprecation_summary.map(
|
|
4653
4655
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4654
4656
|
).join(", ");
|
|
4655
|
-
|
|
4657
|
+
_chunkEN2KFJ7Wcjs.log.call(void 0, ).info(
|
|
4656
4658
|
`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.`
|
|
4657
4659
|
);
|
|
4658
4660
|
}
|
|
@@ -4694,7 +4696,7 @@ function act() {
|
|
|
4694
4696
|
return reaction_on(event, registry.events, builder);
|
|
4695
4697
|
},
|
|
4696
4698
|
build: (options) => {
|
|
4697
|
-
|
|
4699
|
+
_chunkEN2KFJ7Wcjs.resolveActConfig.call(void 0, options);
|
|
4698
4700
|
const patch_fn = _optionalChain([options, 'optionalAccess', _165 => _165.validateFoldedState]) === true ? validating_patch : bare_patch;
|
|
4699
4701
|
if (!_built) {
|
|
4700
4702
|
for (const proj of pending_projections) add_projection(proj);
|
|
@@ -4746,7 +4748,7 @@ function act() {
|
|
|
4746
4748
|
synthesize_autoclose_reactions(
|
|
4747
4749
|
registry,
|
|
4748
4750
|
states,
|
|
4749
|
-
|
|
4751
|
+
_chunkEN2KFJ7Wcjs.current_autoclose_window
|
|
4750
4752
|
);
|
|
4751
4753
|
Object.freeze(registry.actions);
|
|
4752
4754
|
Object.freeze(registry.events);
|
|
@@ -4795,8 +4797,8 @@ function _projection(target) {
|
|
|
4795
4797
|
handler,
|
|
4796
4798
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4797
4799
|
options: {
|
|
4798
|
-
blockOnError:
|
|
4799
|
-
maxRetries:
|
|
4800
|
+
blockOnError: _chunkEN2KFJ7Wcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4801
|
+
maxRetries: _chunkEN2KFJ7Wcjs.DEFAULT_MAX_RETRIES
|
|
4800
4802
|
}
|
|
4801
4803
|
}),
|
|
4802
4804
|
widened
|
|
@@ -4837,7 +4839,7 @@ function _projection(target) {
|
|
|
4837
4839
|
throw new Error(
|
|
4838
4840
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
4839
4841
|
);
|
|
4840
|
-
const config2 =
|
|
4842
|
+
const config2 = _chunkEN2KFJ7Wcjs.resolveFoldConfig.call(void 0, options);
|
|
4841
4843
|
const fold_events = {};
|
|
4842
4844
|
for (const partial of partials)
|
|
4843
4845
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -4855,8 +4857,8 @@ function _projection(target) {
|
|
|
4855
4857
|
handler: noop,
|
|
4856
4858
|
resolver: { target },
|
|
4857
4859
|
options: {
|
|
4858
|
-
blockOnError:
|
|
4859
|
-
maxRetries:
|
|
4860
|
+
blockOnError: _chunkEN2KFJ7Wcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4861
|
+
maxRetries: _chunkEN2KFJ7Wcjs.DEFAULT_MAX_RETRIES
|
|
4860
4862
|
}
|
|
4861
4863
|
}
|
|
4862
4864
|
]
|
|
@@ -4972,7 +4974,7 @@ function action_builder(state2) {
|
|
|
4972
4974
|
throw new Error(`Duplicate action "${action2}"`);
|
|
4973
4975
|
internal.actions[action2] = schema;
|
|
4974
4976
|
if (options) {
|
|
4975
|
-
|
|
4977
|
+
_chunkEN2KFJ7Wcjs.resolveActionConfig.call(void 0, options);
|
|
4976
4978
|
internal.options ??= {};
|
|
4977
4979
|
internal.options[action2] = options;
|
|
4978
4980
|
}
|
|
@@ -5261,5 +5263,5 @@ function write_line(writer, line) {
|
|
|
5261
5263
|
|
|
5262
5264
|
|
|
5263
5265
|
|
|
5264
|
-
exports.Act = Act; exports.ActorSchema = _chunkPMS6BMIUcjs.ActorSchema; exports.CausationEventSchema = _chunkPMS6BMIUcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkPMS6BMIUcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkPMS6BMIUcjs.ConcurrencyError; exports.ConsoleLogger =
|
|
5266
|
+
exports.Act = Act; exports.ActorSchema = _chunkPMS6BMIUcjs.ActorSchema; exports.CausationEventSchema = _chunkPMS6BMIUcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkPMS6BMIUcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkPMS6BMIUcjs.ConcurrencyError; exports.ConsoleLogger = _chunkEN2KFJ7Wcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkPMS6BMIUcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkPMS6BMIUcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkPMS6BMIUcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkPMS6BMIUcjs.DeferSignal; exports.Environments = _chunkPMS6BMIUcjs.Environments; exports.Errors = _chunkPMS6BMIUcjs.Errors; exports.EventMetaSchema = _chunkPMS6BMIUcjs.EventMetaSchema; exports.ExitCodes = _chunkPMS6BMIUcjs.ExitCodes; exports.InMemoryCache = _chunkEN2KFJ7Wcjs.InMemoryCache; exports.InMemoryStore = _chunkEN2KFJ7Wcjs.InMemoryStore; exports.InvariantError = _chunkPMS6BMIUcjs.InvariantError; exports.LogLevels = _chunkPMS6BMIUcjs.LogLevels; exports.NonRetryableError = _chunkPMS6BMIUcjs.NonRetryableError; exports.PackageSchema = _chunkEN2KFJ7Wcjs.PackageSchema; exports.QuerySchema = _chunkPMS6BMIUcjs.QuerySchema; exports.REDACTED = _chunkPMS6BMIUcjs.REDACTED; exports.SHREDDED = _chunkPMS6BMIUcjs.SHREDDED; exports.SNAP_EVENT = _chunkPMS6BMIUcjs.SNAP_EVENT; exports.StoreError = _chunkPMS6BMIUcjs.StoreError; exports.StreamClosedError = _chunkPMS6BMIUcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkPMS6BMIUcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkPMS6BMIUcjs.TargetSchema; exports.ValidationError = _chunkPMS6BMIUcjs.ValidationError; exports.ZodEmpty = _chunkPMS6BMIUcjs.ZodEmpty; exports.act = act; exports.cache = _chunkEN2KFJ7Wcjs.cache; exports.config = _chunkEN2KFJ7Wcjs.config; exports.dateReviver = _chunkEN2KFJ7Wcjs.dateReviver; exports.default_scope = _chunkEN2KFJ7Wcjs.default_scope; exports.dispose = _chunkEN2KFJ7Wcjs.dispose; exports.disposeAndExit = _chunkEN2KFJ7Wcjs.disposeAndExit; exports.extend = _chunkEN2KFJ7Wcjs.extend; exports.is_literal_source = _chunkEN2KFJ7Wcjs.is_literal_source; exports.log = _chunkEN2KFJ7Wcjs.log; exports.pii_fields = _chunkPMS6BMIUcjs.pii_fields; exports.port = _chunkEN2KFJ7Wcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkEN2KFJ7Wcjs.resolveAutocloseConfig2; exports.sensitive = _chunkPMS6BMIUcjs.sensitive; exports.sleep = _chunkEN2KFJ7Wcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkEN2KFJ7Wcjs.store; exports.validate = _chunkEN2KFJ7Wcjs.validate;
|
|
5265
5267
|
//# sourceMappingURL=index.cjs.map
|