@rotorsoft/act 2.1.16 → 2.2.1
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 +4 -3
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/disposers.d.ts +4 -1
- package/dist/@types/disposers.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +8 -0
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +2 -1
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/test/sandbox.d.ts.map +1 -1
- package/dist/@types/types/builders.d.ts +20 -11
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/@types/types/registry.d.ts +5 -2
- package/dist/@types/types/registry.d.ts.map +1 -1
- package/dist/{chunk-3WHD4VPP.cjs → chunk-K4FF6ZXO.cjs} +37 -21
- package/dist/chunk-K4FF6ZXO.cjs.map +1 -0
- package/dist/{chunk-CWWTVYIN.js → chunk-LHSNV3VN.js} +32 -16
- package/dist/chunk-LHSNV3VN.js.map +1 -0
- package/dist/index.cjs +120 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +14 -7
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +12 -5
- package/dist/test/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-3WHD4VPP.cjs.map +0 -1
- package/dist/chunk-CWWTVYIN.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkK4FF6ZXOcjs = require('./chunk-K4FF6ZXO.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -70,22 +70,22 @@ var _chunkLA2BPKNScjs = require('./chunk-LA2BPKNS.cjs');
|
|
|
70
70
|
|
|
71
71
|
// src/signals.ts
|
|
72
72
|
process.once("SIGINT", async (arg) => {
|
|
73
|
-
|
|
74
|
-
await
|
|
73
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
74
|
+
await _chunkK4FF6ZXOcjs.disposeAndExit.call(void 0, "EXIT");
|
|
75
75
|
});
|
|
76
76
|
process.once("SIGTERM", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
78
|
+
await _chunkK4FF6ZXOcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("uncaughtException", async (arg) => {
|
|
81
81
|
process.exitCode = 1;
|
|
82
|
-
|
|
83
|
-
await
|
|
82
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
83
|
+
await _chunkK4FF6ZXOcjs.disposeAndExit.call(void 0, "ERROR");
|
|
84
84
|
});
|
|
85
85
|
process.once("unhandledRejection", async (arg) => {
|
|
86
86
|
process.exitCode = 1;
|
|
87
|
-
|
|
88
|
-
await
|
|
87
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
88
|
+
await _chunkK4FF6ZXOcjs.disposeAndExit.call(void 0, "ERROR");
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
// src/act.ts
|
|
@@ -832,17 +832,17 @@ function compile_reaches(reaches) {
|
|
|
832
832
|
}
|
|
833
833
|
_chunkLA2BPKNScjs.__name.call(void 0, compile_reaches, "compile_reaches");
|
|
834
834
|
function policy_after_windows(options) {
|
|
835
|
-
const parsed =
|
|
835
|
+
const parsed = _chunkK4FF6ZXOcjs.check.call(void 0, "autoclose_policy", options);
|
|
836
836
|
return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
|
|
837
837
|
}
|
|
838
838
|
_chunkLA2BPKNScjs.__name.call(void 0, policy_after_windows, "policy_after_windows");
|
|
839
839
|
function policy_keep_days(options) {
|
|
840
|
-
const parsed =
|
|
840
|
+
const parsed = _chunkK4FF6ZXOcjs.check.call(void 0, "autoclose_policy", options);
|
|
841
841
|
return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
|
|
842
842
|
}
|
|
843
843
|
_chunkLA2BPKNScjs.__name.call(void 0, policy_keep_days, "policy_keep_days");
|
|
844
844
|
function compile_autoclose_policy(options) {
|
|
845
|
-
const parsed =
|
|
845
|
+
const parsed = _chunkK4FF6ZXOcjs.check.call(void 0, "autoclose_policy", options);
|
|
846
846
|
const and_preds = [];
|
|
847
847
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
848
848
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -914,7 +914,7 @@ function duration_ms(d) {
|
|
|
914
914
|
}
|
|
915
915
|
_chunkLA2BPKNScjs.__name.call(void 0, duration_ms, "duration_ms");
|
|
916
916
|
function resolve_defer_at(when, event) {
|
|
917
|
-
const parsed =
|
|
917
|
+
const parsed = _chunkK4FF6ZXOcjs.check.call(void 0, "defer", when);
|
|
918
918
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
919
919
|
return parsed.at.getTime();
|
|
920
920
|
}
|
|
@@ -1061,7 +1061,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, compute_lag_lead_ratio, "compute_lag_lead_
|
|
|
1061
1061
|
function report_once(seen, key, message) {
|
|
1062
1062
|
if (seen.has(key)) return;
|
|
1063
1063
|
seen.add(key);
|
|
1064
|
-
|
|
1064
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).error(new Error(message));
|
|
1065
1065
|
}
|
|
1066
1066
|
_chunkLA2BPKNScjs.__name.call(void 0, report_once, "report_once");
|
|
1067
1067
|
|
|
@@ -1092,14 +1092,14 @@ function close_correlation(correlator, actor) {
|
|
|
1092
1092
|
_chunkLA2BPKNScjs.__name.call(void 0, close_correlation, "close_correlation");
|
|
1093
1093
|
|
|
1094
1094
|
// src/internal/drain-ops.ts
|
|
1095
|
-
var claim = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (lagging, leading, by, millis, lane) =>
|
|
1095
|
+
var claim = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (lagging, leading, by, millis, lane) => _chunkK4FF6ZXOcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane), "claim");
|
|
1096
1096
|
async function fetch(leased, eventLimit) {
|
|
1097
1097
|
return Promise.all(
|
|
1098
1098
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1099
1099
|
const events = [];
|
|
1100
1100
|
const stream_exact = source !== void 0 && _chunkQITJ63HGcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1101
1101
|
try {
|
|
1102
|
-
await
|
|
1102
|
+
await _chunkK4FF6ZXOcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1103
1103
|
stream: source,
|
|
1104
1104
|
stream_exact,
|
|
1105
1105
|
after: at,
|
|
@@ -1120,9 +1120,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1120
1120
|
);
|
|
1121
1121
|
}
|
|
1122
1122
|
_chunkLA2BPKNScjs.__name.call(void 0, fetch, "fetch");
|
|
1123
|
-
var ack = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) =>
|
|
1124
|
-
var block = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) =>
|
|
1125
|
-
var subscribe = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (streams, correlated_at, correlator) =>
|
|
1123
|
+
var ack = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) => _chunkK4FF6ZXOcjs.store.call(void 0, ).ack(leases), "ack");
|
|
1124
|
+
var block = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) => _chunkK4FF6ZXOcjs.store.call(void 0, ).block(leases), "block");
|
|
1125
|
+
var subscribe = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (streams, correlated_at, correlator) => _chunkK4FF6ZXOcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator), "subscribe");
|
|
1126
1126
|
|
|
1127
1127
|
// src/internal/event-sourcing.ts
|
|
1128
1128
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1301,14 +1301,14 @@ var check_invariants = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (ta
|
|
|
1301
1301
|
);
|
|
1302
1302
|
}, "check_invariants");
|
|
1303
1303
|
var DEFAULT_BATCH = 500;
|
|
1304
|
-
var cache_put = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream, entry) =>
|
|
1305
|
-
(err) =>
|
|
1304
|
+
var cache_put = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream, entry) => _chunkK4FF6ZXOcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1305
|
+
(err) => _chunkK4FF6ZXOcjs.log.call(void 0, ).warn(
|
|
1306
1306
|
err,
|
|
1307
1307
|
"cache set skipped; the next load re-folds from the store"
|
|
1308
1308
|
)
|
|
1309
1309
|
), "cache_put");
|
|
1310
|
-
var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream) =>
|
|
1311
|
-
(err) =>
|
|
1310
|
+
var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream) => _chunkK4FF6ZXOcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1311
|
+
(err) => _chunkK4FF6ZXOcjs.log.call(void 0, ).warn(
|
|
1312
1312
|
err,
|
|
1313
1313
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1314
1314
|
)
|
|
@@ -1316,7 +1316,7 @@ var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream)
|
|
|
1316
1316
|
async function snap(snapshot) {
|
|
1317
1317
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1318
1318
|
try {
|
|
1319
|
-
const [committed] = await
|
|
1319
|
+
const [committed] = await _chunkK4FF6ZXOcjs.store.call(void 0, ).commit(
|
|
1320
1320
|
[
|
|
1321
1321
|
{
|
|
1322
1322
|
stream,
|
|
@@ -1333,7 +1333,7 @@ async function snap(snapshot) {
|
|
|
1333
1333
|
return committed;
|
|
1334
1334
|
} catch (error) {
|
|
1335
1335
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1336
|
-
|
|
1336
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).warn(
|
|
1337
1337
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1338
1338
|
);
|
|
1339
1339
|
}
|
|
@@ -1341,7 +1341,7 @@ async function snap(snapshot) {
|
|
|
1341
1341
|
_chunkLA2BPKNScjs.__name.call(void 0, snap, "snap");
|
|
1342
1342
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1343
1343
|
try {
|
|
1344
|
-
const [committed] = await
|
|
1344
|
+
const [committed] = await _chunkK4FF6ZXOcjs.store.call(void 0, ).commit(
|
|
1345
1345
|
[
|
|
1346
1346
|
{
|
|
1347
1347
|
stream,
|
|
@@ -1501,14 +1501,14 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1501
1501
|
const { stream, actor, asOf } = target;
|
|
1502
1502
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1503
1503
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1504
|
-
const cached = time_travel ? void 0 : await
|
|
1504
|
+
const cached = time_travel ? void 0 : await _chunkK4FF6ZXOcjs.cache.call(void 0, ).get(stream);
|
|
1505
1505
|
const cache_hit = !!cached;
|
|
1506
1506
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _67 => _67.state]), () => ( (me.init ? me.init() : {})));
|
|
1507
1507
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _68 => _68.patches]), () => ( 0));
|
|
1508
1508
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _69 => _69.snaps]), () => ( 0));
|
|
1509
1509
|
let replayed = 0;
|
|
1510
1510
|
let event;
|
|
1511
|
-
await
|
|
1511
|
+
await _chunkK4FF6ZXOcjs.store.call(void 0, ).query(
|
|
1512
1512
|
(raw) => {
|
|
1513
1513
|
if (seeded && raw.name === _chunkLA2BPKNScjs.SNAP_EVENT && replayed > 0) return;
|
|
1514
1514
|
event = me.view(raw, actor);
|
|
@@ -1522,7 +1522,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1522
1522
|
patches++;
|
|
1523
1523
|
replayed++;
|
|
1524
1524
|
} else if (event.name !== _chunkLA2BPKNScjs.TOMBSTONE_EVENT) {
|
|
1525
|
-
|
|
1525
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).warn(
|
|
1526
1526
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1527
1527
|
);
|
|
1528
1528
|
}
|
|
@@ -1612,7 +1612,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1612
1612
|
if (!stream) throw new Error("Missing target stream");
|
|
1613
1613
|
const reactingTo = _optionalChain([options, 'optionalAccess', _78 => _78.reactingTo]);
|
|
1614
1614
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _79 => _79.correlator]), () => ( default_correlator));
|
|
1615
|
-
const validated =
|
|
1615
|
+
const validated = _chunkK4FF6ZXOcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1616
1616
|
const opts = _optionalChain([me, 'access', _80 => _80.options, 'optionalAccess', _81 => _81[action2]]);
|
|
1617
1617
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _82 => _82.maxRetries]), () => ( 0));
|
|
1618
1618
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _83 => _83.loads, 'optionalAccess', _84 => _84[action2]]), () => ( []));
|
|
@@ -1674,7 +1674,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1674
1674
|
);
|
|
1675
1675
|
to.events.push({
|
|
1676
1676
|
name: event,
|
|
1677
|
-
data:
|
|
1677
|
+
data: _chunkK4FF6ZXOcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1678
1678
|
});
|
|
1679
1679
|
}
|
|
1680
1680
|
if (!own.events.length)
|
|
@@ -1731,7 +1731,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1731
1731
|
});
|
|
1732
1732
|
let committed;
|
|
1733
1733
|
try {
|
|
1734
|
-
committed = await
|
|
1734
|
+
committed = await _chunkK4FF6ZXOcjs.store.call(void 0, ).commit(
|
|
1735
1735
|
appends.map((p) => ({
|
|
1736
1736
|
stream: p.stream,
|
|
1737
1737
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1787,7 +1787,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1787
1787
|
if (attempt >= max_retries) throw error;
|
|
1788
1788
|
if (_optionalChain([opts, 'optionalAccess', _99 => _99.backoff])) {
|
|
1789
1789
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1790
|
-
if (delay_ms > 0) await
|
|
1790
|
+
if (delay_ms > 0) await _chunkK4FF6ZXOcjs.sleep.call(void 0, delay_ms);
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
1793
|
}
|
|
@@ -1795,7 +1795,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1795
1795
|
_chunkLA2BPKNScjs.__name.call(void 0, action, "action");
|
|
1796
1796
|
|
|
1797
1797
|
// src/internal/tracing.ts
|
|
1798
|
-
var PRETTY =
|
|
1798
|
+
var PRETTY = _chunkK4FF6ZXOcjs.config.call(void 0, ).env !== "production";
|
|
1799
1799
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1800
1800
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1801
1801
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1982,7 +1982,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
1982
1982
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _110 => _110.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1983
1983
|
return void 0;
|
|
1984
1984
|
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.`;
|
|
1985
|
-
|
|
1985
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).error(error);
|
|
1986
1986
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1987
1987
|
}
|
|
1988
1988
|
_chunkLA2BPKNScjs.__name.call(void 0, budget_exhausted, "budget_exhausted");
|
|
@@ -2006,7 +2006,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
2006
2006
|
logger.error(
|
|
2007
2007
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2008
2008
|
);
|
|
2009
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2009
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkK4FF6ZXOcjs.DEFAULT_BACKOFF)));
|
|
2010
2010
|
return {
|
|
2011
2011
|
lease,
|
|
2012
2012
|
handled,
|
|
@@ -2136,7 +2136,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2136
2136
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2137
2137
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2138
2138
|
if (acked.length < expected)
|
|
2139
|
-
|
|
2139
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).warn(
|
|
2140
2140
|
`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.`
|
|
2141
2141
|
);
|
|
2142
2142
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2237,9 +2237,9 @@ var DrainController = (_class3 = class {
|
|
|
2237
2237
|
if (!this.armed || this._stopped || this._inflight)
|
|
2238
2238
|
return EMPTY_DRAIN;
|
|
2239
2239
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2240
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2241
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2242
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2240
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkK4FF6ZXOcjs.DEFAULT_STREAM_LIMIT));
|
|
2241
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkK4FF6ZXOcjs.DEFAULT_EVENT_LIMIT));
|
|
2242
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkK4FF6ZXOcjs.DEFAULT_LEASE_MILLIS));
|
|
2243
2243
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2244
2244
|
return EMPTY_DRAIN;
|
|
2245
2245
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2473,13 +2473,13 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2473
2473
|
} : void 0, "resolver"),
|
|
2474
2474
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2475
2475
|
// not quarantine the synthetic stream.
|
|
2476
|
-
options: { blockOnError: false, maxRetries:
|
|
2476
|
+
options: { blockOnError: false, maxRetries: _chunkK4FF6ZXOcjs.DEFAULT_MAX_RETRIES },
|
|
2477
2477
|
handler: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (event) => {
|
|
2478
2478
|
const aggregate = event.stream;
|
|
2479
2479
|
const window = read_window();
|
|
2480
2480
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2481
2481
|
throw new (0, _chunkLA2BPKNScjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2482
|
-
const stats = await
|
|
2482
|
+
const stats = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2483
2483
|
count: true,
|
|
2484
2484
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2485
2485
|
exclude: [_chunkLA2BPKNScjs.TOMBSTONE_EVENT, _chunkLA2BPKNScjs.SNAP_EVENT]
|
|
@@ -2670,7 +2670,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2670
2670
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2671
2671
|
return void 0;
|
|
2672
2672
|
if (t.archive) await t.archive();
|
|
2673
|
-
const result = await
|
|
2673
|
+
const result = await _chunkK4FF6ZXOcjs.store.call(void 0, ).truncate([
|
|
2674
2674
|
{ stream: t.stream, before: t.before, max_id }
|
|
2675
2675
|
]);
|
|
2676
2676
|
return result.get(t.stream);
|
|
@@ -2684,7 +2684,7 @@ _chunkLA2BPKNScjs.__name.call(void 0, run_windowed_closes, "run_windowed_closes"
|
|
|
2684
2684
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2685
2685
|
let boundary_id;
|
|
2686
2686
|
let min_id;
|
|
2687
|
-
await
|
|
2687
|
+
await _chunkK4FF6ZXOcjs.store.call(void 0, ).query(
|
|
2688
2688
|
(event) => {
|
|
2689
2689
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2690
2690
|
if (event.name === _chunkLA2BPKNScjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
@@ -2699,7 +2699,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2699
2699
|
const min_at = /* @__PURE__ */ new Map();
|
|
2700
2700
|
const matches = source_matcher();
|
|
2701
2701
|
await walk_streams(
|
|
2702
|
-
|
|
2702
|
+
_chunkK4FF6ZXOcjs.store.call(void 0, ),
|
|
2703
2703
|
(position) => {
|
|
2704
2704
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2705
2705
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2730,13 +2730,13 @@ function source_matcher() {
|
|
|
2730
2730
|
}
|
|
2731
2731
|
_chunkLA2BPKNScjs.__name.call(void 0, source_matcher, "source_matcher");
|
|
2732
2732
|
async function scan_stream_heads(streams) {
|
|
2733
|
-
const stats = await
|
|
2733
|
+
const stats = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_stats(streams, {
|
|
2734
2734
|
exclude: [_chunkLA2BPKNScjs.SNAP_EVENT]
|
|
2735
2735
|
});
|
|
2736
|
-
const domain_heads = await
|
|
2736
|
+
const domain_heads = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_stats(streams, {
|
|
2737
2737
|
exclude: [_chunkLA2BPKNScjs.SNAP_EVENT, _chunkLA2BPKNScjs.TOMBSTONE_EVENT]
|
|
2738
2738
|
});
|
|
2739
|
-
const true_heads = await
|
|
2739
|
+
const true_heads = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2740
2740
|
const out = /* @__PURE__ */ new Map();
|
|
2741
2741
|
for (const [stream, { head }] of domain_heads) {
|
|
2742
2742
|
const marker_head = _optionalChain([stats, 'access', _140 => _140.get, 'call', _141 => _141(stream), 'optionalAccess', _142 => _142.head]);
|
|
@@ -2764,7 +2764,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2764
2764
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2765
2765
|
const matches = source_matcher();
|
|
2766
2766
|
await walk_streams(
|
|
2767
|
-
|
|
2767
|
+
_chunkK4FF6ZXOcjs.store.call(void 0, ),
|
|
2768
2768
|
(position) => {
|
|
2769
2769
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2770
2770
|
if (!has_work) return;
|
|
@@ -2835,7 +2835,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
2835
2835
|
}
|
|
2836
2836
|
_chunkLA2BPKNScjs.__name.call(void 0, run_archive_callbacks, "run_archive_callbacks");
|
|
2837
2837
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2838
|
-
const heads = await
|
|
2838
|
+
const heads = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2839
2839
|
return guarded.filter((stream) => {
|
|
2840
2840
|
if (_optionalChain([heads, 'access', _150 => _150.get, 'call', _151 => _151(stream), 'optionalAccess', _152 => _152.head, 'access', _153 => _153.id]) === guard_events.get(stream).id)
|
|
2841
2841
|
return true;
|
|
@@ -2859,13 +2859,13 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2859
2859
|
}
|
|
2860
2860
|
};
|
|
2861
2861
|
});
|
|
2862
|
-
const truncated = await
|
|
2862
|
+
const truncated = await _chunkK4FF6ZXOcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2863
2863
|
await Promise.all(
|
|
2864
2864
|
guarded.map(async (stream) => {
|
|
2865
2865
|
const entry = truncated.get(stream);
|
|
2866
2866
|
const state2 = seed_states.get(stream);
|
|
2867
2867
|
if (state2 && entry) {
|
|
2868
|
-
await
|
|
2868
|
+
await _chunkK4FF6ZXOcjs.cache.call(void 0, ).set(stream, {
|
|
2869
2869
|
stream,
|
|
2870
2870
|
state: state2,
|
|
2871
2871
|
version: entry.committed.version,
|
|
@@ -2874,7 +2874,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2874
2874
|
snaps: 1
|
|
2875
2875
|
});
|
|
2876
2876
|
} else {
|
|
2877
|
-
await
|
|
2877
|
+
await _chunkK4FF6ZXOcjs.cache.call(void 0, ).invalidate(stream);
|
|
2878
2878
|
}
|
|
2879
2879
|
})
|
|
2880
2880
|
);
|
|
@@ -2940,7 +2940,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2940
2940
|
// never lets a resolution re-lane them.
|
|
2941
2941
|
|
|
2942
2942
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2943
|
-
__init19() {this._patterns = new (0,
|
|
2943
|
+
__init19() {this._patterns = new (0, _chunkK4FF6ZXOcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2944
2944
|
|
|
2945
2945
|
|
|
2946
2946
|
|
|
@@ -2958,7 +2958,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2958
2958
|
on_init
|
|
2959
2959
|
}) {;_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);
|
|
2960
2960
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2961
|
-
this._dynamic_subscriptions = new (0,
|
|
2961
|
+
this._dynamic_subscriptions = new (0, _chunkK4FF6ZXOcjs.LruMap)(max_subscribed_streams);
|
|
2962
2962
|
this._registry = registry;
|
|
2963
2963
|
this._declared_lanes = declared_lanes;
|
|
2964
2964
|
this._static_targets = static_targets;
|
|
@@ -3059,7 +3059,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3059
3059
|
const correlated = /* @__PURE__ */ new Map();
|
|
3060
3060
|
let last_id = after;
|
|
3061
3061
|
let stopped = false;
|
|
3062
|
-
const found = await
|
|
3062
|
+
const found = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query(
|
|
3063
3063
|
(event) => {
|
|
3064
3064
|
if (stopped) return;
|
|
3065
3065
|
const register = this._registry.events[event.name];
|
|
@@ -3079,7 +3079,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3079
3079
|
}
|
|
3080
3080
|
if (!resolved) continue;
|
|
3081
3081
|
try {
|
|
3082
|
-
|
|
3082
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "target", resolved);
|
|
3083
3083
|
} catch (e2) {
|
|
3084
3084
|
report_bad_priority(
|
|
3085
3085
|
this._reported,
|
|
@@ -3191,7 +3191,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3191
3191
|
await Promise.all(
|
|
3192
3192
|
missed.map(async ([stream, entry]) => {
|
|
3193
3193
|
let row;
|
|
3194
|
-
await
|
|
3194
|
+
await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_streams(
|
|
3195
3195
|
(position) => {
|
|
3196
3196
|
row = position;
|
|
3197
3197
|
},
|
|
@@ -3230,7 +3230,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3230
3230
|
millis: 0
|
|
3231
3231
|
});
|
|
3232
3232
|
} catch (error) {
|
|
3233
|
-
|
|
3233
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).warn(
|
|
3234
3234
|
`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)))}`
|
|
3235
3235
|
);
|
|
3236
3236
|
}
|
|
@@ -3571,7 +3571,7 @@ var Act = (_class7 = class {
|
|
|
3571
3571
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3572
3572
|
|
|
3573
3573
|
|
|
3574
|
-
__init27() {this._logger =
|
|
3574
|
+
__init27() {this._logger = _chunkK4FF6ZXOcjs.log.call(void 0, )}
|
|
3575
3575
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3576
3576
|
|
|
3577
3577
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3600,11 +3600,11 @@ var Act = (_class7 = class {
|
|
|
3600
3600
|
throw new Error(
|
|
3601
3601
|
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3602
3602
|
);
|
|
3603
|
-
|
|
3604
|
-
if (options.scoped)
|
|
3605
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3603
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "act", options);
|
|
3604
|
+
if (options.scoped) _chunkK4FF6ZXOcjs.check.call(void 0, "store", options.scoped.store);
|
|
3605
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkK4FF6ZXOcjs.unscoped_ports.call(void 0, )));
|
|
3606
3606
|
const ports = this._ports;
|
|
3607
|
-
this._scoped =
|
|
3607
|
+
this._scoped = _chunkK4FF6ZXOcjs.make_run_scoped.call(void 0, {
|
|
3608
3608
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3609
3609
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3610
3610
|
get store() {
|
|
@@ -3614,14 +3614,14 @@ var Act = (_class7 = class {
|
|
|
3614
3614
|
return ports.cache;
|
|
3615
3615
|
},
|
|
3616
3616
|
// Parsed per build, so a bad window throws on every build.
|
|
3617
|
-
autoclose_window:
|
|
3617
|
+
autoclose_window: _chunkK4FF6ZXOcjs.check.call(void 0, "autoclose", options).autocloseWindow
|
|
3618
3618
|
});
|
|
3619
3619
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3620
3620
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3621
3621
|
this._cd = build_drain(this._logger);
|
|
3622
3622
|
const handle = build_handle({
|
|
3623
3623
|
logger: this._logger,
|
|
3624
|
-
reaction_scope:
|
|
3624
|
+
reaction_scope: _chunkK4FF6ZXOcjs.make_reaction_scope.call(void 0, {
|
|
3625
3625
|
do: this.do.bind(this),
|
|
3626
3626
|
load: this.load.bind(this),
|
|
3627
3627
|
query: this.query.bind(this),
|
|
@@ -3651,12 +3651,12 @@ var Act = (_class7 = class {
|
|
|
3651
3651
|
this._ports.store,
|
|
3652
3652
|
options.listen !== false
|
|
3653
3653
|
);
|
|
3654
|
-
|
|
3654
|
+
_chunkK4FF6ZXOcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3655
3655
|
}
|
|
3656
3656
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3657
3657
|
_build_breaker(options) {
|
|
3658
3658
|
return new CircuitBreaker(
|
|
3659
|
-
|
|
3659
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "circuit_breaker", _nullishCoalesce(options.circuitBreaker, () => ( {}))),
|
|
3660
3660
|
{
|
|
3661
3661
|
on_error: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (error, circuit) => this._emit_error(error, circuit), "on_error"),
|
|
3662
3662
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3724,7 +3724,7 @@ var Act = (_class7 = class {
|
|
|
3724
3724
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3725
3725
|
_build_audit_deps() {
|
|
3726
3726
|
return {
|
|
3727
|
-
store:
|
|
3727
|
+
store: _chunkK4FF6ZXOcjs.store,
|
|
3728
3728
|
event_to_state: this._event_to_state,
|
|
3729
3729
|
sensitive_fields: this.registry.sensitive_fields,
|
|
3730
3730
|
// Declared lanes, not this process's controllers: a lane another
|
|
@@ -3754,7 +3754,7 @@ var Act = (_class7 = class {
|
|
|
3754
3754
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3755
3755
|
async _seed_persisted_defers() {
|
|
3756
3756
|
const now = Date.now();
|
|
3757
|
-
await walk_streams(
|
|
3757
|
+
await walk_streams(_chunkK4FF6ZXOcjs.store.call(void 0, ), (pos) => {
|
|
3758
3758
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3759
3759
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3760
3760
|
_optionalChain([controller, 'optionalAccess', _165 => _165.seed_defer, 'call', _166 => _166(pos.stream, pos.deferred_at)]);
|
|
@@ -3790,7 +3790,7 @@ var Act = (_class7 = class {
|
|
|
3790
3790
|
*/
|
|
3791
3791
|
shutdown(options) {
|
|
3792
3792
|
if (!this._shutdown_promise) {
|
|
3793
|
-
|
|
3793
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "shutdown", _nullishCoalesce(options, () => ( {})));
|
|
3794
3794
|
this._shutdown_promise = (async () => {
|
|
3795
3795
|
this.stop_correlations();
|
|
3796
3796
|
this._settle.stop(true);
|
|
@@ -3808,10 +3808,10 @@ var Act = (_class7 = class {
|
|
|
3808
3808
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3809
3809
|
// default for none or 0, and for a running settle), capped.
|
|
3810
3810
|
_derive_grace_ms(running, settling) {
|
|
3811
|
-
let max = settling ?
|
|
3811
|
+
let max = settling ? _chunkK4FF6ZXOcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3812
3812
|
for (const c of running)
|
|
3813
|
-
max = Math.max(max, c.lease_millis ||
|
|
3814
|
-
return Math.min(max,
|
|
3813
|
+
max = Math.max(max, c.lease_millis || _chunkK4FF6ZXOcjs.DEFAULT_LEASE_MILLIS);
|
|
3814
|
+
return Math.min(max, _chunkK4FF6ZXOcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3815
3815
|
}
|
|
3816
3816
|
async _await_inflight(grace_ms) {
|
|
3817
3817
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3895,7 +3895,7 @@ var Act = (_class7 = class {
|
|
|
3895
3895
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3896
3896
|
*/
|
|
3897
3897
|
async do(action2, target, payload, options) {
|
|
3898
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]), () => (
|
|
3898
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]), () => ( _chunkK4FF6ZXOcjs.current_reacting.call(void 0, )));
|
|
3899
3899
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _169 => _169.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3900
3900
|
return this._scoped(async () => {
|
|
3901
3901
|
const snapshots = await this._es.action(
|
|
@@ -3938,6 +3938,7 @@ var Act = (_class7 = class {
|
|
|
3938
3938
|
actor: void 0,
|
|
3939
3939
|
asOf
|
|
3940
3940
|
} : streamOrTarget;
|
|
3941
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "page", _nullishCoalesce(target.asOf, () => ( {})));
|
|
3941
3942
|
return await this._es.load(merged, target, callback);
|
|
3942
3943
|
});
|
|
3943
3944
|
}
|
|
@@ -3966,11 +3967,11 @@ var Act = (_class7 = class {
|
|
|
3966
3967
|
* @see {@link query_array} for loading events into memory
|
|
3967
3968
|
*/
|
|
3968
3969
|
async query(query, callback) {
|
|
3969
|
-
|
|
3970
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "page", query);
|
|
3970
3971
|
return this._scoped(async () => {
|
|
3971
3972
|
let first;
|
|
3972
3973
|
let last;
|
|
3973
|
-
const count = await
|
|
3974
|
+
const count = await _chunkK4FF6ZXOcjs.store.call(void 0, ).query((e) => {
|
|
3974
3975
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3975
3976
|
if (!first) first = gated;
|
|
3976
3977
|
last = gated;
|
|
@@ -4016,14 +4017,14 @@ var Act = (_class7 = class {
|
|
|
4016
4017
|
*/
|
|
4017
4018
|
async forget(stream) {
|
|
4018
4019
|
return this._scoped(async () => {
|
|
4019
|
-
const s =
|
|
4020
|
+
const s = _chunkK4FF6ZXOcjs.store.call(void 0, );
|
|
4020
4021
|
if (!s.forget_pii) {
|
|
4021
4022
|
throw new Error(
|
|
4022
4023
|
`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).`
|
|
4023
4024
|
);
|
|
4024
4025
|
}
|
|
4025
4026
|
const eventCount = await s.forget_pii(stream);
|
|
4026
|
-
await
|
|
4027
|
+
await _chunkK4FF6ZXOcjs.cache.call(void 0, ).invalidate(stream);
|
|
4027
4028
|
if (eventCount > 0) {
|
|
4028
4029
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
4029
4030
|
}
|
|
@@ -4057,7 +4058,7 @@ var Act = (_class7 = class {
|
|
|
4057
4058
|
* @see {@link correlate} for dynamic stream discovery
|
|
4058
4059
|
*/
|
|
4059
4060
|
async drain(options = {}) {
|
|
4060
|
-
|
|
4061
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "drain", options);
|
|
4061
4062
|
if (!this._drain)
|
|
4062
4063
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
4063
4064
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4134,7 +4135,7 @@ var Act = (_class7 = class {
|
|
|
4134
4135
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
4135
4136
|
*/
|
|
4136
4137
|
async correlate(query = {}) {
|
|
4137
|
-
|
|
4138
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "page", query);
|
|
4138
4139
|
const pass = await this._correlate_pass(_nullishCoalesce(query.limit, () => ( 10)));
|
|
4139
4140
|
return {
|
|
4140
4141
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -4180,8 +4181,8 @@ var Act = (_class7 = class {
|
|
|
4180
4181
|
* @see {@link stop_correlations} to stop the poll
|
|
4181
4182
|
*/
|
|
4182
4183
|
start_correlations(query = {}, frequency = 1e4) {
|
|
4183
|
-
|
|
4184
|
-
|
|
4184
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "page", query);
|
|
4185
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "poll", { frequency });
|
|
4185
4186
|
if (this._poll) return false;
|
|
4186
4187
|
this._poll_limit = query.limit || void 0;
|
|
4187
4188
|
this._poll = setInterval(() => {
|
|
@@ -4247,7 +4248,7 @@ var Act = (_class7 = class {
|
|
|
4247
4248
|
*/
|
|
4248
4249
|
async reset(input) {
|
|
4249
4250
|
return this._scoped(async () => {
|
|
4250
|
-
const count = await
|
|
4251
|
+
const count = await _chunkK4FF6ZXOcjs.store.call(void 0, ).reset(input);
|
|
4251
4252
|
this._reset_folds();
|
|
4252
4253
|
if (count > 0) {
|
|
4253
4254
|
this._wake();
|
|
@@ -4282,7 +4283,7 @@ var Act = (_class7 = class {
|
|
|
4282
4283
|
*/
|
|
4283
4284
|
async unblock(input) {
|
|
4284
4285
|
return this._scoped(async () => {
|
|
4285
|
-
const count = await
|
|
4286
|
+
const count = await _chunkK4FF6ZXOcjs.store.call(void 0, ).unblock(input);
|
|
4286
4287
|
if (count > 0) {
|
|
4287
4288
|
this._wake();
|
|
4288
4289
|
}
|
|
@@ -4330,7 +4331,7 @@ var Act = (_class7 = class {
|
|
|
4330
4331
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4331
4332
|
*/
|
|
4332
4333
|
async restore(source, opts = {}, sink) {
|
|
4333
|
-
|
|
4334
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "scan", opts);
|
|
4334
4335
|
return this._scoped(async () => {
|
|
4335
4336
|
const started = Date.now();
|
|
4336
4337
|
if (opts.dry_run) {
|
|
@@ -4338,7 +4339,7 @@ var Act = (_class7 = class {
|
|
|
4338
4339
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4339
4340
|
}
|
|
4340
4341
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4341
|
-
const s =
|
|
4342
|
+
const s = _chunkK4FF6ZXOcjs.store.call(void 0, );
|
|
4342
4343
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4343
4344
|
return s;
|
|
4344
4345
|
})()));
|
|
@@ -4383,14 +4384,14 @@ var Act = (_class7 = class {
|
|
|
4383
4384
|
* ```
|
|
4384
4385
|
*/
|
|
4385
4386
|
async blocked_streams(options) {
|
|
4386
|
-
|
|
4387
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "page", { limit: _optionalChain([options, 'optionalAccess', _178 => _178.limit]) });
|
|
4387
4388
|
return this._scoped(async () => {
|
|
4388
4389
|
const positions = [];
|
|
4389
|
-
await
|
|
4390
|
+
await _chunkK4FF6ZXOcjs.store.call(void 0, ).query_streams(
|
|
4390
4391
|
(p) => {
|
|
4391
4392
|
positions.push(p);
|
|
4392
4393
|
},
|
|
4393
|
-
{ blocked: true, after: _optionalChain([options, 'optionalAccess',
|
|
4394
|
+
{ blocked: true, after: _optionalChain([options, 'optionalAccess', _179 => _179.after]), limit: _optionalChain([options, 'optionalAccess', _180 => _180.limit]) }
|
|
4394
4395
|
);
|
|
4395
4396
|
return positions;
|
|
4396
4397
|
});
|
|
@@ -4412,7 +4413,7 @@ var Act = (_class7 = class {
|
|
|
4412
4413
|
* ```
|
|
4413
4414
|
*/
|
|
4414
4415
|
async *audit(categories, options) {
|
|
4415
|
-
|
|
4416
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "audit", _nullishCoalesce(options, () => ( {})));
|
|
4416
4417
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4417
4418
|
while (true) {
|
|
4418
4419
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4440,8 +4441,8 @@ var Act = (_class7 = class {
|
|
|
4440
4441
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4441
4442
|
*/
|
|
4442
4443
|
async prioritize(filter, priority) {
|
|
4443
|
-
|
|
4444
|
-
return this._scoped(() =>
|
|
4444
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "target", { priority });
|
|
4445
|
+
return this._scoped(() => _chunkK4FF6ZXOcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4445
4446
|
}
|
|
4446
4447
|
// Shared by `close()` and reaction-requested closes.
|
|
4447
4448
|
async _run_close(targets) {
|
|
@@ -4521,7 +4522,7 @@ var Act = (_class7 = class {
|
|
|
4521
4522
|
* @see {@link correlate} for manual correlation
|
|
4522
4523
|
*/
|
|
4523
4524
|
settle(options) {
|
|
4524
|
-
|
|
4525
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "settle", _nullishCoalesce(options, () => ( {})));
|
|
4525
4526
|
this._schedule(options);
|
|
4526
4527
|
}
|
|
4527
4528
|
}, _class7);
|
|
@@ -4737,7 +4738,7 @@ var _this_ = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, ({ stream })
|
|
|
4737
4738
|
|
|
4738
4739
|
// src/builders/builder-utils.ts
|
|
4739
4740
|
function register_lane(config2, lanes) {
|
|
4740
|
-
|
|
4741
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "lane", config2);
|
|
4741
4742
|
if (config2.name === _chunkLA2BPKNScjs.DEFAULT_LANE)
|
|
4742
4743
|
throw new Error(`Lane "${_chunkLA2BPKNScjs.DEFAULT_LANE}" is reserved`);
|
|
4743
4744
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
@@ -4762,7 +4763,7 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4762
4763
|
events[event].reactions.set(name, reaction);
|
|
4763
4764
|
return Object.assign(builder, {
|
|
4764
4765
|
to(resolver) {
|
|
4765
|
-
if (typeof resolver === "object")
|
|
4766
|
+
if (typeof resolver === "object") _chunkK4FF6ZXOcjs.check.call(void 0, "target", resolver);
|
|
4766
4767
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4767
4768
|
return builder;
|
|
4768
4769
|
}
|
|
@@ -4777,17 +4778,17 @@ function reaction_on(event, events, builder) {
|
|
|
4777
4778
|
"Reaction",
|
|
4778
4779
|
() => {
|
|
4779
4780
|
if (schedule && typeof schedule !== "function")
|
|
4780
|
-
|
|
4781
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "defer", schedule);
|
|
4781
4782
|
return {
|
|
4782
4783
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4783
4784
|
resolver: _this_,
|
|
4784
4785
|
// Validate the whole bag at the declaration site so a bad
|
|
4785
4786
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4786
4787
|
// not a NaN gate on the first retry.
|
|
4787
|
-
options:
|
|
4788
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4789
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4790
|
-
backoff: _optionalChain([options, 'optionalAccess',
|
|
4788
|
+
options: _chunkK4FF6ZXOcjs.check.call(void 0, "reaction", {
|
|
4789
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _181 => _181.blockOnError]), () => ( _chunkK4FF6ZXOcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4790
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.maxRetries]), () => ( _chunkK4FF6ZXOcjs.DEFAULT_MAX_RETRIES)),
|
|
4791
|
+
backoff: _optionalChain([options, 'optionalAccess', _183 => _183.backoff])
|
|
4791
4792
|
})
|
|
4792
4793
|
};
|
|
4793
4794
|
},
|
|
@@ -4955,7 +4956,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4955
4956
|
}
|
|
4956
4957
|
_chunkLA2BPKNScjs.__name.call(void 0, build_events, "build_events");
|
|
4957
4958
|
function reads_as_string(schema) {
|
|
4958
|
-
const type = _optionalChain([def_of, 'call',
|
|
4959
|
+
const type = _optionalChain([def_of, 'call', _184 => _184(output_of(schema)), 'optionalAccess', _185 => _185.type]);
|
|
4959
4960
|
return type === "string" || type === "transform";
|
|
4960
4961
|
}
|
|
4961
4962
|
_chunkLA2BPKNScjs.__name.call(void 0, reads_as_string, "reads_as_string");
|
|
@@ -5015,7 +5016,7 @@ function act() {
|
|
|
5015
5016
|
let _built = false;
|
|
5016
5017
|
const read_wrap = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (original) => {
|
|
5017
5018
|
const wrapped2 = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (events, stream) => {
|
|
5018
|
-
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access',
|
|
5019
|
+
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _186 => _186.get, 'call', _187 => _187(e.name), 'optionalCall', _188 => _188(e)]), () => ( e)));
|
|
5019
5020
|
return original(read, stream);
|
|
5020
5021
|
}, "wrapped");
|
|
5021
5022
|
const reset = original[FOLD_RESET];
|
|
@@ -5056,7 +5057,7 @@ function act() {
|
|
|
5056
5057
|
});
|
|
5057
5058
|
}
|
|
5058
5059
|
for (const [action_name, handler] of Object.entries(state2.on)) {
|
|
5059
|
-
const static_target = _optionalChain([handler, 'optionalAccess',
|
|
5060
|
+
const static_target = _optionalChain([handler, 'optionalAccess', _189 => _189._static_emit]);
|
|
5060
5061
|
if (static_target && deprecated.has(static_target)) {
|
|
5061
5062
|
const current = current_version_of(static_target, event_names);
|
|
5062
5063
|
throw new Error(
|
|
@@ -5069,7 +5070,7 @@ function act() {
|
|
|
5069
5070
|
const list = deprecation_summary.map(
|
|
5070
5071
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
5071
5072
|
).join(", ");
|
|
5072
|
-
|
|
5073
|
+
_chunkK4FF6ZXOcjs.log.call(void 0, ).info(
|
|
5073
5074
|
`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.`
|
|
5074
5075
|
);
|
|
5075
5076
|
}
|
|
@@ -5128,7 +5129,7 @@ function act() {
|
|
|
5128
5129
|
`State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
|
|
5129
5130
|
);
|
|
5130
5131
|
const claimed = fold_specs.find((s) => s.target === proj.target);
|
|
5131
|
-
if (_optionalChain([claimed, 'optionalAccess',
|
|
5132
|
+
if (_optionalChain([claimed, 'optionalAccess', _190 => _190.projection]) === proj) continue;
|
|
5132
5133
|
if (batch_handlers.has(proj.target) || claimed)
|
|
5133
5134
|
throw new Error(
|
|
5134
5135
|
`Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
|
|
@@ -5150,7 +5151,7 @@ function act() {
|
|
|
5150
5151
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
5151
5152
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
5152
5153
|
finalize_deprecations();
|
|
5153
|
-
if (built.advisory)
|
|
5154
|
+
if (built.advisory) _chunkK4FF6ZXOcjs.log.call(void 0, ).warn(built.advisory);
|
|
5154
5155
|
for (const [name, state2] of states) {
|
|
5155
5156
|
if (!state2.loads) continue;
|
|
5156
5157
|
const resolved = {};
|
|
@@ -5162,7 +5163,7 @@ function act() {
|
|
|
5162
5163
|
`Action "${action2}" loads "${l.state.name}", which is not registered \u2014 add it via withState/withSlice before build()`
|
|
5163
5164
|
);
|
|
5164
5165
|
const deprecated = l.events.find(
|
|
5165
|
-
(e) => _optionalChain([_de, 'access',
|
|
5166
|
+
(e) => _optionalChain([_de, 'access', _191 => _191.get, 'call', _192 => _192(registered.name), 'optionalAccess', _193 => _193.has, 'call', _194 => _194(e)])
|
|
5166
5167
|
);
|
|
5167
5168
|
if (deprecated)
|
|
5168
5169
|
throw new Error(
|
|
@@ -5194,7 +5195,7 @@ function act() {
|
|
|
5194
5195
|
synthesize_autoclose_reactions(
|
|
5195
5196
|
registry,
|
|
5196
5197
|
states,
|
|
5197
|
-
|
|
5198
|
+
_chunkK4FF6ZXOcjs.current_autoclose_window
|
|
5198
5199
|
);
|
|
5199
5200
|
Object.freeze(registry.actions);
|
|
5200
5201
|
Object.freeze(registry.events);
|
|
@@ -5243,8 +5244,8 @@ function _projection(target) {
|
|
|
5243
5244
|
handler,
|
|
5244
5245
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5245
5246
|
options: {
|
|
5246
|
-
blockOnError:
|
|
5247
|
-
maxRetries:
|
|
5247
|
+
blockOnError: _chunkK4FF6ZXOcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5248
|
+
maxRetries: _chunkK4FF6ZXOcjs.DEFAULT_MAX_RETRIES
|
|
5248
5249
|
}
|
|
5249
5250
|
}),
|
|
5250
5251
|
widened
|
|
@@ -5285,7 +5286,7 @@ function _projection(target) {
|
|
|
5285
5286
|
throw new Error(
|
|
5286
5287
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5287
5288
|
);
|
|
5288
|
-
const config2 =
|
|
5289
|
+
const config2 = _chunkK4FF6ZXOcjs.check.call(void 0, "fold", options);
|
|
5289
5290
|
const fold_events = {};
|
|
5290
5291
|
for (const partial of partials)
|
|
5291
5292
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5303,8 +5304,8 @@ function _projection(target) {
|
|
|
5303
5304
|
handler: noop,
|
|
5304
5305
|
resolver: { target },
|
|
5305
5306
|
options: {
|
|
5306
|
-
blockOnError:
|
|
5307
|
-
maxRetries:
|
|
5307
|
+
blockOnError: _chunkK4FF6ZXOcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5308
|
+
maxRetries: _chunkK4FF6ZXOcjs.DEFAULT_MAX_RETRIES
|
|
5308
5309
|
}
|
|
5309
5310
|
}
|
|
5310
5311
|
]
|
|
@@ -5424,7 +5425,7 @@ function action_builder(state2) {
|
|
|
5424
5425
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5425
5426
|
internal.actions[action2] = schema;
|
|
5426
5427
|
if (options) {
|
|
5427
|
-
|
|
5428
|
+
_chunkK4FF6ZXOcjs.check.call(void 0, "action", options);
|
|
5428
5429
|
internal.options ??= {};
|
|
5429
5430
|
internal.options[action2] = options;
|
|
5430
5431
|
}
|
|
@@ -5714,9 +5715,9 @@ var ExitCodes2 = _chunkLA2BPKNScjs.ExitCodes;
|
|
|
5714
5715
|
var DEFAULT_LANE2 = _chunkLA2BPKNScjs.DEFAULT_LANE;
|
|
5715
5716
|
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkLA2BPKNScjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5716
5717
|
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkLA2BPKNScjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5717
|
-
var PackageSchema =
|
|
5718
|
-
var default_scope =
|
|
5719
|
-
var extend = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (source, schema, target) => ({ ...target, ...
|
|
5718
|
+
var PackageSchema = _chunkK4FF6ZXOcjs.package_schema;
|
|
5719
|
+
var default_scope = _chunkK4FF6ZXOcjs.unscoped_ports;
|
|
5720
|
+
var extend = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (source, schema, target) => ({ ...target, ..._chunkK4FF6ZXOcjs.validate.call(void 0, "config", source, schema) }), "extend");
|
|
5720
5721
|
var ISO_8601 = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d+)?(Z|[+-][0-2][0-9]:[0-5][0-9])?$/;
|
|
5721
5722
|
var dateReviver = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
|
|
5722
5723
|
function sensitiveFields(schema) {
|
|
@@ -5783,5 +5784,5 @@ var pii_fields = sensitiveFields;
|
|
|
5783
5784
|
|
|
5784
5785
|
|
|
5785
5786
|
|
|
5786
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkLA2BPKNScjs.ConcurrencyError; exports.ConsoleLogger =
|
|
5787
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkLA2BPKNScjs.ConcurrencyError; exports.ConsoleLogger = _chunkK4FF6ZXOcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = DEFAULT_LANE2; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = DEFAULT_MAX_SUBSCRIBED_STREAMS2; exports.DEFAULT_QUERY_STREAMS_LIMIT = DEFAULT_QUERY_STREAMS_LIMIT2; exports.DEFAULT_SETTLE_DEBOUNCE_MS = DEFAULT_SETTLE_DEBOUNCE_MS2; exports.DeferSignal = _chunkLA2BPKNScjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunkLA2BPKNScjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkK4FF6ZXOcjs.InMemoryCache; exports.InMemoryStore = _chunkK4FF6ZXOcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunkLA2BPKNScjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunkLA2BPKNScjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunkLA2BPKNScjs.REDACTED; exports.SHREDDED = _chunkLA2BPKNScjs.SHREDDED; exports.SNAP_EVENT = _chunkLA2BPKNScjs.SNAP_EVENT; exports.StoreError = _chunkLA2BPKNScjs.StoreError; exports.StreamClosedError = _chunkLA2BPKNScjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkLA2BPKNScjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunkLA2BPKNScjs.ValidationError; exports.ZodEmpty = _chunkLA2BPKNScjs.ZodEmpty; exports.act = act; exports.cache = _chunkK4FF6ZXOcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkK4FF6ZXOcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkK4FF6ZXOcjs.dispose; exports.disposeAndExit = _chunkK4FF6ZXOcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkK4FF6ZXOcjs.log; exports.notification_of = notification_of; exports.pii_fields = pii_fields; exports.port = _chunkK4FF6ZXOcjs.port; exports.projection = projection; exports.seed_event = seed_event; exports.sensitive = _chunkLA2BPKNScjs.sensitive; exports.sensitiveFields = sensitiveFields; exports.sleep = _chunkK4FF6ZXOcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkK4FF6ZXOcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkK4FF6ZXOcjs.validate;
|
|
5787
5788
|
//# sourceMappingURL=index.cjs.map
|