@rotorsoft/act 2.2.4 → 2.2.5
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/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/{chunk-2CYRPAJN.js → chunk-SJJVHRME.js} +8 -1
- package/dist/chunk-SJJVHRME.js.map +1 -0
- package/dist/{chunk-XG3UD63Y.cjs → chunk-UYNNDDE7.cjs} +8 -1
- package/dist/chunk-UYNNDDE7.cjs.map +1 -0
- package/dist/index.cjs +115 -115
- package/dist/index.js +1 -1
- package/dist/test/index.cjs +3 -3
- package/dist/test/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2CYRPAJN.js.map +0 -1
- package/dist/chunk-XG3UD63Y.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var _chunkUYNNDDE7cjs = require('./chunk-UYNNDDE7.cjs');
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
@@ -71,22 +71,22 @@ var _chunk4GA3CHQWcjs = require('./chunk-4GA3CHQW.cjs');
|
|
|
71
71
|
|
|
72
72
|
// src/signals.ts
|
|
73
73
|
process.once("SIGINT", async (arg) => {
|
|
74
|
-
|
|
75
|
-
await
|
|
74
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
75
|
+
await _chunkUYNNDDE7cjs.disposeAndExit.call(void 0, "EXIT");
|
|
76
76
|
});
|
|
77
77
|
process.once("SIGTERM", async (arg) => {
|
|
78
|
-
|
|
79
|
-
await
|
|
78
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
79
|
+
await _chunkUYNNDDE7cjs.disposeAndExit.call(void 0, "EXIT");
|
|
80
80
|
});
|
|
81
81
|
process.once("uncaughtException", async (arg) => {
|
|
82
82
|
process.exitCode = 1;
|
|
83
|
-
|
|
84
|
-
await
|
|
83
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
84
|
+
await _chunkUYNNDDE7cjs.disposeAndExit.call(void 0, "ERROR");
|
|
85
85
|
});
|
|
86
86
|
process.once("unhandledRejection", async (arg) => {
|
|
87
87
|
process.exitCode = 1;
|
|
88
|
-
|
|
89
|
-
await
|
|
88
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
89
|
+
await _chunkUYNNDDE7cjs.disposeAndExit.call(void 0, "ERROR");
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
// src/act.ts
|
|
@@ -833,17 +833,17 @@ function compile_reaches(reaches) {
|
|
|
833
833
|
}
|
|
834
834
|
_chunk4GA3CHQWcjs.__name.call(void 0, compile_reaches, "compile_reaches");
|
|
835
835
|
function policy_after_windows(options) {
|
|
836
|
-
const parsed =
|
|
836
|
+
const parsed = _chunkUYNNDDE7cjs.check.call(void 0, "autoclose_policy", options);
|
|
837
837
|
return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
|
|
838
838
|
}
|
|
839
839
|
_chunk4GA3CHQWcjs.__name.call(void 0, policy_after_windows, "policy_after_windows");
|
|
840
840
|
function policy_keep_days(options) {
|
|
841
|
-
const parsed =
|
|
841
|
+
const parsed = _chunkUYNNDDE7cjs.check.call(void 0, "autoclose_policy", options);
|
|
842
842
|
return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
|
|
843
843
|
}
|
|
844
844
|
_chunk4GA3CHQWcjs.__name.call(void 0, policy_keep_days, "policy_keep_days");
|
|
845
845
|
function compile_autoclose_policy(options) {
|
|
846
|
-
const parsed =
|
|
846
|
+
const parsed = _chunkUYNNDDE7cjs.check.call(void 0, "autoclose_policy", options);
|
|
847
847
|
const and_preds = [];
|
|
848
848
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
849
849
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -915,7 +915,7 @@ function duration_ms(d) {
|
|
|
915
915
|
}
|
|
916
916
|
_chunk4GA3CHQWcjs.__name.call(void 0, duration_ms, "duration_ms");
|
|
917
917
|
function resolve_defer_at(when, event) {
|
|
918
|
-
const parsed =
|
|
918
|
+
const parsed = _chunkUYNNDDE7cjs.check.call(void 0, "defer", when);
|
|
919
919
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
920
920
|
return parsed.at.getTime();
|
|
921
921
|
}
|
|
@@ -984,7 +984,7 @@ _chunk4GA3CHQWcjs.__name.call(void 0, compute_lag_lead_ratio, "compute_lag_lead_
|
|
|
984
984
|
function report_once(seen, key, message) {
|
|
985
985
|
if (seen.has(key)) return;
|
|
986
986
|
seen.add(key);
|
|
987
|
-
|
|
987
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).error(new Error(message));
|
|
988
988
|
}
|
|
989
989
|
_chunk4GA3CHQWcjs.__name.call(void 0, report_once, "report_once");
|
|
990
990
|
|
|
@@ -1015,14 +1015,14 @@ function close_correlation(correlator, actor) {
|
|
|
1015
1015
|
_chunk4GA3CHQWcjs.__name.call(void 0, close_correlation, "close_correlation");
|
|
1016
1016
|
|
|
1017
1017
|
// src/internal/drain-ops.ts
|
|
1018
|
-
var claim = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (lagging, leading, by, millis, lane) =>
|
|
1018
|
+
var claim = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (lagging, leading, by, millis, lane) => _chunkUYNNDDE7cjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane), "claim");
|
|
1019
1019
|
async function fetch(leased, eventLimit) {
|
|
1020
1020
|
return Promise.all(
|
|
1021
1021
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1022
1022
|
const events = [];
|
|
1023
1023
|
const stream_exact = source !== void 0 && _chunkXJZ2PKJHcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1024
1024
|
try {
|
|
1025
|
-
await
|
|
1025
|
+
await _chunkUYNNDDE7cjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1026
1026
|
stream: source,
|
|
1027
1027
|
stream_exact,
|
|
1028
1028
|
after: at,
|
|
@@ -1043,9 +1043,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1043
1043
|
);
|
|
1044
1044
|
}
|
|
1045
1045
|
_chunk4GA3CHQWcjs.__name.call(void 0, fetch, "fetch");
|
|
1046
|
-
var ack = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (leases) =>
|
|
1047
|
-
var block = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (leases) =>
|
|
1048
|
-
var subscribe = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (streams, correlated_at, correlator) =>
|
|
1046
|
+
var ack = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (leases) => _chunkUYNNDDE7cjs.store.call(void 0, ).ack(leases), "ack");
|
|
1047
|
+
var block = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (leases) => _chunkUYNNDDE7cjs.store.call(void 0, ).block(leases), "block");
|
|
1048
|
+
var subscribe = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (streams, correlated_at, correlator) => _chunkUYNNDDE7cjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator), "subscribe");
|
|
1049
1049
|
|
|
1050
1050
|
// src/internal/event-sourcing.ts
|
|
1051
1051
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1224,14 +1224,14 @@ var check_invariants = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (ta
|
|
|
1224
1224
|
);
|
|
1225
1225
|
}, "check_invariants");
|
|
1226
1226
|
var DEFAULT_BATCH = 500;
|
|
1227
|
-
var cache_put = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (stream, entry) =>
|
|
1228
|
-
(err) =>
|
|
1227
|
+
var cache_put = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (stream, entry) => _chunkUYNNDDE7cjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1228
|
+
(err) => _chunkUYNNDDE7cjs.log.call(void 0, ).warn(
|
|
1229
1229
|
err,
|
|
1230
1230
|
"cache set skipped; the next load re-folds from the store"
|
|
1231
1231
|
)
|
|
1232
1232
|
), "cache_put");
|
|
1233
|
-
var cache_drop = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (stream) =>
|
|
1234
|
-
(err) =>
|
|
1233
|
+
var cache_drop = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (stream) => _chunkUYNNDDE7cjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1234
|
+
(err) => _chunkUYNNDDE7cjs.log.call(void 0, ).warn(
|
|
1235
1235
|
err,
|
|
1236
1236
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1237
1237
|
)
|
|
@@ -1239,7 +1239,7 @@ var cache_drop = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (stream)
|
|
|
1239
1239
|
async function snap(snapshot) {
|
|
1240
1240
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1241
1241
|
try {
|
|
1242
|
-
const [committed] = await
|
|
1242
|
+
const [committed] = await _chunkUYNNDDE7cjs.store.call(void 0, ).commit(
|
|
1243
1243
|
[
|
|
1244
1244
|
{
|
|
1245
1245
|
stream,
|
|
@@ -1256,7 +1256,7 @@ async function snap(snapshot) {
|
|
|
1256
1256
|
return committed;
|
|
1257
1257
|
} catch (error) {
|
|
1258
1258
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1259
|
-
|
|
1259
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).warn(
|
|
1260
1260
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1261
1261
|
);
|
|
1262
1262
|
}
|
|
@@ -1264,7 +1264,7 @@ async function snap(snapshot) {
|
|
|
1264
1264
|
_chunk4GA3CHQWcjs.__name.call(void 0, snap, "snap");
|
|
1265
1265
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1266
1266
|
try {
|
|
1267
|
-
const [committed] = await
|
|
1267
|
+
const [committed] = await _chunkUYNNDDE7cjs.store.call(void 0, ).commit(
|
|
1268
1268
|
[
|
|
1269
1269
|
{
|
|
1270
1270
|
stream,
|
|
@@ -1424,14 +1424,14 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1424
1424
|
const { stream, actor, asOf } = target;
|
|
1425
1425
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1426
1426
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1427
|
-
const cached = time_travel ? void 0 : await
|
|
1427
|
+
const cached = time_travel ? void 0 : await _chunkUYNNDDE7cjs.cache.call(void 0, ).get(stream);
|
|
1428
1428
|
const cache_hit = !!cached;
|
|
1429
1429
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _67 => _67.state]), () => ( (me.init ? me.init() : {})));
|
|
1430
1430
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _68 => _68.patches]), () => ( 0));
|
|
1431
1431
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _69 => _69.snaps]), () => ( 0));
|
|
1432
1432
|
let replayed = 0;
|
|
1433
1433
|
let event;
|
|
1434
|
-
await
|
|
1434
|
+
await _chunkUYNNDDE7cjs.store.call(void 0, ).query(
|
|
1435
1435
|
(raw) => {
|
|
1436
1436
|
if (seeded && raw.name === _chunk4GA3CHQWcjs.SNAP_EVENT && replayed > 0) return;
|
|
1437
1437
|
event = me.view(raw, actor);
|
|
@@ -1445,7 +1445,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1445
1445
|
patches++;
|
|
1446
1446
|
replayed++;
|
|
1447
1447
|
} else if (event.name !== _chunk4GA3CHQWcjs.TOMBSTONE_EVENT) {
|
|
1448
|
-
|
|
1448
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).warn(
|
|
1449
1449
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1450
1450
|
);
|
|
1451
1451
|
}
|
|
@@ -1535,7 +1535,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1535
1535
|
if (!stream) throw new Error("Missing target stream");
|
|
1536
1536
|
const reactingTo = _optionalChain([options, 'optionalAccess', _78 => _78.reactingTo]);
|
|
1537
1537
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _79 => _79.correlator]), () => ( default_correlator));
|
|
1538
|
-
const validated =
|
|
1538
|
+
const validated = _chunkUYNNDDE7cjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1539
1539
|
const opts = _optionalChain([me, 'access', _80 => _80.options, 'optionalAccess', _81 => _81[action2]]);
|
|
1540
1540
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _82 => _82.maxRetries]), () => ( 0));
|
|
1541
1541
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _83 => _83.loads, 'optionalAccess', _84 => _84[action2]]), () => ( []));
|
|
@@ -1597,7 +1597,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1597
1597
|
);
|
|
1598
1598
|
to.events.push({
|
|
1599
1599
|
name: event,
|
|
1600
|
-
data:
|
|
1600
|
+
data: _chunkUYNNDDE7cjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1601
1601
|
});
|
|
1602
1602
|
}
|
|
1603
1603
|
if (!own.events.length)
|
|
@@ -1654,7 +1654,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1654
1654
|
});
|
|
1655
1655
|
let committed;
|
|
1656
1656
|
try {
|
|
1657
|
-
committed = await
|
|
1657
|
+
committed = await _chunkUYNNDDE7cjs.store.call(void 0, ).commit(
|
|
1658
1658
|
appends.map((p) => ({
|
|
1659
1659
|
stream: p.stream,
|
|
1660
1660
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1710,7 +1710,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1710
1710
|
if (attempt >= max_retries) throw error;
|
|
1711
1711
|
if (_optionalChain([opts, 'optionalAccess', _99 => _99.backoff])) {
|
|
1712
1712
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1713
|
-
if (delay_ms > 0) await
|
|
1713
|
+
if (delay_ms > 0) await _chunkUYNNDDE7cjs.sleep.call(void 0, delay_ms);
|
|
1714
1714
|
}
|
|
1715
1715
|
}
|
|
1716
1716
|
}
|
|
@@ -1718,7 +1718,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1718
1718
|
_chunk4GA3CHQWcjs.__name.call(void 0, action, "action");
|
|
1719
1719
|
|
|
1720
1720
|
// src/internal/tracing.ts
|
|
1721
|
-
var PRETTY =
|
|
1721
|
+
var PRETTY = _chunkUYNNDDE7cjs.config.call(void 0, ).env !== "production";
|
|
1722
1722
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1723
1723
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1724
1724
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1905,7 +1905,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
1905
1905
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _110 => _110.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1906
1906
|
return void 0;
|
|
1907
1907
|
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.`;
|
|
1908
|
-
|
|
1908
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).error(error);
|
|
1909
1909
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1910
1910
|
}
|
|
1911
1911
|
_chunk4GA3CHQWcjs.__name.call(void 0, budget_exhausted, "budget_exhausted");
|
|
@@ -1929,7 +1929,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
1929
1929
|
logger.error(
|
|
1930
1930
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1931
1931
|
);
|
|
1932
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
1932
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkUYNNDDE7cjs.DEFAULT_BACKOFF)));
|
|
1933
1933
|
return {
|
|
1934
1934
|
lease,
|
|
1935
1935
|
handled,
|
|
@@ -2059,7 +2059,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2059
2059
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2060
2060
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2061
2061
|
if (acked.length < expected)
|
|
2062
|
-
|
|
2062
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).warn(
|
|
2063
2063
|
`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.`
|
|
2064
2064
|
);
|
|
2065
2065
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2097,7 +2097,7 @@ var DrainController = (_class2 = class {
|
|
|
2097
2097
|
// itself is persisted. On an idle app nothing else would drain it. It
|
|
2098
2098
|
// drains until a pass leases nothing or the controller stops, and an entry
|
|
2099
2099
|
// stays until handled or until a later pass claims nothing.
|
|
2100
|
-
__init5() {this._defer = new (0,
|
|
2100
|
+
__init5() {this._defer = new (0, _chunkUYNNDDE7cjs.DeferTimer)(() => {
|
|
2101
2101
|
this.arm();
|
|
2102
2102
|
void this._deps.run_scoped(async () => {
|
|
2103
2103
|
while ((await this.drain()).leased.length > 0) ;
|
|
@@ -2160,9 +2160,9 @@ var DrainController = (_class2 = class {
|
|
|
2160
2160
|
if (!this.armed || this._stopped || this._inflight)
|
|
2161
2161
|
return EMPTY_DRAIN;
|
|
2162
2162
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2163
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2164
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2165
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2163
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkUYNNDDE7cjs.DEFAULT_STREAM_LIMIT));
|
|
2164
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkUYNNDDE7cjs.DEFAULT_EVENT_LIMIT));
|
|
2165
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkUYNNDDE7cjs.DEFAULT_LEASE_MILLIS));
|
|
2166
2166
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2167
2167
|
return EMPTY_DRAIN;
|
|
2168
2168
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2396,13 +2396,13 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2396
2396
|
} : void 0, "resolver"),
|
|
2397
2397
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2398
2398
|
// not quarantine the synthetic stream.
|
|
2399
|
-
options: { blockOnError: false, maxRetries:
|
|
2399
|
+
options: { blockOnError: false, maxRetries: _chunkUYNNDDE7cjs.DEFAULT_MAX_RETRIES },
|
|
2400
2400
|
handler: /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, async (event) => {
|
|
2401
2401
|
const aggregate = event.stream;
|
|
2402
2402
|
const window = read_window();
|
|
2403
2403
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2404
2404
|
throw new (0, _chunk4GA3CHQWcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2405
|
-
const stats = await
|
|
2405
|
+
const stats = await _chunkUYNNDDE7cjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2406
2406
|
count: true,
|
|
2407
2407
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2408
2408
|
exclude: [_chunk4GA3CHQWcjs.TOMBSTONE_EVENT, _chunk4GA3CHQWcjs.SNAP_EVENT]
|
|
@@ -2593,7 +2593,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2593
2593
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2594
2594
|
return void 0;
|
|
2595
2595
|
if (t.archive) await t.archive();
|
|
2596
|
-
const result = await
|
|
2596
|
+
const result = await _chunkUYNNDDE7cjs.store.call(void 0, ).truncate([
|
|
2597
2597
|
{ stream: t.stream, before: t.before, max_id }
|
|
2598
2598
|
]);
|
|
2599
2599
|
return result.get(t.stream);
|
|
@@ -2607,7 +2607,7 @@ _chunk4GA3CHQWcjs.__name.call(void 0, run_windowed_closes, "run_windowed_closes"
|
|
|
2607
2607
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2608
2608
|
let boundary_id;
|
|
2609
2609
|
let min_id;
|
|
2610
|
-
await
|
|
2610
|
+
await _chunkUYNNDDE7cjs.store.call(void 0, ).query(
|
|
2611
2611
|
(event) => {
|
|
2612
2612
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2613
2613
|
if (event.name === _chunk4GA3CHQWcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
@@ -2622,7 +2622,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2622
2622
|
const min_at = /* @__PURE__ */ new Map();
|
|
2623
2623
|
const matches = source_matcher();
|
|
2624
2624
|
await walk_streams(
|
|
2625
|
-
|
|
2625
|
+
_chunkUYNNDDE7cjs.store.call(void 0, ),
|
|
2626
2626
|
(position) => {
|
|
2627
2627
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2628
2628
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2653,13 +2653,13 @@ function source_matcher() {
|
|
|
2653
2653
|
}
|
|
2654
2654
|
_chunk4GA3CHQWcjs.__name.call(void 0, source_matcher, "source_matcher");
|
|
2655
2655
|
async function scan_stream_heads(streams) {
|
|
2656
|
-
const stats = await
|
|
2656
|
+
const stats = await _chunkUYNNDDE7cjs.store.call(void 0, ).query_stats(streams, {
|
|
2657
2657
|
exclude: [_chunk4GA3CHQWcjs.SNAP_EVENT]
|
|
2658
2658
|
});
|
|
2659
|
-
const domain_heads = await
|
|
2659
|
+
const domain_heads = await _chunkUYNNDDE7cjs.store.call(void 0, ).query_stats(streams, {
|
|
2660
2660
|
exclude: [_chunk4GA3CHQWcjs.SNAP_EVENT, _chunk4GA3CHQWcjs.TOMBSTONE_EVENT]
|
|
2661
2661
|
});
|
|
2662
|
-
const true_heads = await
|
|
2662
|
+
const true_heads = await _chunkUYNNDDE7cjs.store.call(void 0, ).query_stats(streams, {});
|
|
2663
2663
|
const out = /* @__PURE__ */ new Map();
|
|
2664
2664
|
for (const [stream, { head }] of domain_heads) {
|
|
2665
2665
|
const marker_head = _optionalChain([stats, 'access', _140 => _140.get, 'call', _141 => _141(stream), 'optionalAccess', _142 => _142.head]);
|
|
@@ -2687,7 +2687,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2687
2687
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2688
2688
|
const matches = source_matcher();
|
|
2689
2689
|
await walk_streams(
|
|
2690
|
-
|
|
2690
|
+
_chunkUYNNDDE7cjs.store.call(void 0, ),
|
|
2691
2691
|
(position) => {
|
|
2692
2692
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2693
2693
|
if (!has_work) return;
|
|
@@ -2758,7 +2758,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
2758
2758
|
}
|
|
2759
2759
|
_chunk4GA3CHQWcjs.__name.call(void 0, run_archive_callbacks, "run_archive_callbacks");
|
|
2760
2760
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2761
|
-
const heads = await
|
|
2761
|
+
const heads = await _chunkUYNNDDE7cjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2762
2762
|
return guarded.filter((stream) => {
|
|
2763
2763
|
if (_optionalChain([heads, 'access', _150 => _150.get, 'call', _151 => _151(stream), 'optionalAccess', _152 => _152.head, 'access', _153 => _153.id]) === guard_events.get(stream).id)
|
|
2764
2764
|
return true;
|
|
@@ -2782,13 +2782,13 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2782
2782
|
}
|
|
2783
2783
|
};
|
|
2784
2784
|
});
|
|
2785
|
-
const truncated = await
|
|
2785
|
+
const truncated = await _chunkUYNNDDE7cjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2786
2786
|
await Promise.all(
|
|
2787
2787
|
guarded.map(async (stream) => {
|
|
2788
2788
|
const entry = truncated.get(stream);
|
|
2789
2789
|
const state2 = seed_states.get(stream);
|
|
2790
2790
|
if (state2 && entry) {
|
|
2791
|
-
await
|
|
2791
|
+
await _chunkUYNNDDE7cjs.cache.call(void 0, ).set(stream, {
|
|
2792
2792
|
stream,
|
|
2793
2793
|
state: state2,
|
|
2794
2794
|
version: entry.committed.version,
|
|
@@ -2797,7 +2797,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2797
2797
|
snaps: 1
|
|
2798
2798
|
});
|
|
2799
2799
|
} else {
|
|
2800
|
-
await
|
|
2800
|
+
await _chunkUYNNDDE7cjs.cache.call(void 0, ).invalidate(stream);
|
|
2801
2801
|
}
|
|
2802
2802
|
})
|
|
2803
2803
|
);
|
|
@@ -2863,7 +2863,7 @@ var CorrelateCycle = (_class4 = class {
|
|
|
2863
2863
|
// never lets a resolution re-lane them.
|
|
2864
2864
|
|
|
2865
2865
|
__init17() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2866
|
-
__init18() {this._patterns = new (0,
|
|
2866
|
+
__init18() {this._patterns = new (0, _chunkUYNNDDE7cjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2867
2867
|
|
|
2868
2868
|
|
|
2869
2869
|
|
|
@@ -2881,7 +2881,7 @@ var CorrelateCycle = (_class4 = class {
|
|
|
2881
2881
|
on_init
|
|
2882
2882
|
}) {;_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this);_class4.prototype.__init11.call(this);_class4.prototype.__init12.call(this);_class4.prototype.__init13.call(this);_class4.prototype.__init14.call(this);_class4.prototype.__init15.call(this);_class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this);_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this);
|
|
2883
2883
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2884
|
-
this._dynamic_subscriptions = new (0,
|
|
2884
|
+
this._dynamic_subscriptions = new (0, _chunkUYNNDDE7cjs.LruMap)(max_subscribed_streams);
|
|
2885
2885
|
this._registry = registry;
|
|
2886
2886
|
this._declared_lanes = declared_lanes;
|
|
2887
2887
|
this._static_targets = static_targets;
|
|
@@ -2982,7 +2982,7 @@ var CorrelateCycle = (_class4 = class {
|
|
|
2982
2982
|
const correlated = /* @__PURE__ */ new Map();
|
|
2983
2983
|
let last_id = after;
|
|
2984
2984
|
let stopped = false;
|
|
2985
|
-
const found = await
|
|
2985
|
+
const found = await _chunkUYNNDDE7cjs.store.call(void 0, ).query(
|
|
2986
2986
|
(event) => {
|
|
2987
2987
|
if (stopped) return;
|
|
2988
2988
|
const register = this._registry.events[event.name];
|
|
@@ -3002,7 +3002,7 @@ var CorrelateCycle = (_class4 = class {
|
|
|
3002
3002
|
}
|
|
3003
3003
|
if (!resolved) continue;
|
|
3004
3004
|
try {
|
|
3005
|
-
|
|
3005
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "target", resolved);
|
|
3006
3006
|
} catch (e2) {
|
|
3007
3007
|
report_bad_priority(
|
|
3008
3008
|
this._reported,
|
|
@@ -3114,7 +3114,7 @@ var CorrelateCycle = (_class4 = class {
|
|
|
3114
3114
|
await Promise.all(
|
|
3115
3115
|
missed.map(async ([stream, entry]) => {
|
|
3116
3116
|
let row;
|
|
3117
|
-
await
|
|
3117
|
+
await _chunkUYNNDDE7cjs.store.call(void 0, ).query_streams(
|
|
3118
3118
|
(position) => {
|
|
3119
3119
|
row = position;
|
|
3120
3120
|
},
|
|
@@ -3153,7 +3153,7 @@ var CorrelateCycle = (_class4 = class {
|
|
|
3153
3153
|
millis: 0
|
|
3154
3154
|
});
|
|
3155
3155
|
} catch (error) {
|
|
3156
|
-
|
|
3156
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).warn(
|
|
3157
3157
|
`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)))}`
|
|
3158
3158
|
);
|
|
3159
3159
|
}
|
|
@@ -3494,7 +3494,7 @@ var Act = (_class6 = class {
|
|
|
3494
3494
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3495
3495
|
|
|
3496
3496
|
|
|
3497
|
-
__init26() {this._logger =
|
|
3497
|
+
__init26() {this._logger = _chunkUYNNDDE7cjs.log.call(void 0, )}
|
|
3498
3498
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3499
3499
|
|
|
3500
3500
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3523,11 +3523,11 @@ var Act = (_class6 = class {
|
|
|
3523
3523
|
throw new Error(
|
|
3524
3524
|
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3525
3525
|
);
|
|
3526
|
-
|
|
3527
|
-
if (options.scoped)
|
|
3528
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3526
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "act", options);
|
|
3527
|
+
if (options.scoped) _chunkUYNNDDE7cjs.check.call(void 0, "store", options.scoped.store);
|
|
3528
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkUYNNDDE7cjs.unscoped_ports.call(void 0, )));
|
|
3529
3529
|
const ports = this._ports;
|
|
3530
|
-
this._scoped =
|
|
3530
|
+
this._scoped = _chunkUYNNDDE7cjs.make_run_scoped.call(void 0, {
|
|
3531
3531
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3532
3532
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3533
3533
|
get store() {
|
|
@@ -3537,14 +3537,14 @@ var Act = (_class6 = class {
|
|
|
3537
3537
|
return ports.cache;
|
|
3538
3538
|
},
|
|
3539
3539
|
// Parsed per build, so a bad window throws on every build.
|
|
3540
|
-
autoclose_window:
|
|
3540
|
+
autoclose_window: _chunkUYNNDDE7cjs.check.call(void 0, "autoclose", options).autocloseWindow
|
|
3541
3541
|
});
|
|
3542
3542
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3543
3543
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3544
3544
|
this._cd = build_drain(this._logger);
|
|
3545
3545
|
const handle = build_handle({
|
|
3546
3546
|
logger: this._logger,
|
|
3547
|
-
reaction_scope:
|
|
3547
|
+
reaction_scope: _chunkUYNNDDE7cjs.make_reaction_scope.call(void 0, {
|
|
3548
3548
|
do: this.do.bind(this),
|
|
3549
3549
|
load: this.load.bind(this),
|
|
3550
3550
|
query: this.query.bind(this),
|
|
@@ -3574,12 +3574,12 @@ var Act = (_class6 = class {
|
|
|
3574
3574
|
this._ports.store,
|
|
3575
3575
|
options.listen !== false
|
|
3576
3576
|
);
|
|
3577
|
-
|
|
3577
|
+
_chunkUYNNDDE7cjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3578
3578
|
}
|
|
3579
3579
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3580
3580
|
_build_breaker(options) {
|
|
3581
3581
|
return new CircuitBreaker(
|
|
3582
|
-
|
|
3582
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "circuit_breaker", _nullishCoalesce(options.circuitBreaker, () => ( {}))),
|
|
3583
3583
|
{
|
|
3584
3584
|
on_error: /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (error, circuit) => this._emit_error(error, circuit), "on_error"),
|
|
3585
3585
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3647,7 +3647,7 @@ var Act = (_class6 = class {
|
|
|
3647
3647
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3648
3648
|
_build_audit_deps() {
|
|
3649
3649
|
return {
|
|
3650
|
-
store:
|
|
3650
|
+
store: _chunkUYNNDDE7cjs.store,
|
|
3651
3651
|
event_to_state: this._event_to_state,
|
|
3652
3652
|
sensitive_fields: this.registry.sensitive_fields,
|
|
3653
3653
|
// Declared lanes, not this process's controllers: a lane another
|
|
@@ -3677,7 +3677,7 @@ var Act = (_class6 = class {
|
|
|
3677
3677
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3678
3678
|
async _seed_persisted_defers() {
|
|
3679
3679
|
const now = Date.now();
|
|
3680
|
-
await walk_streams(
|
|
3680
|
+
await walk_streams(_chunkUYNNDDE7cjs.store.call(void 0, ), (pos) => {
|
|
3681
3681
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3682
3682
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3683
3683
|
_optionalChain([controller, 'optionalAccess', _165 => _165.seed_defer, 'call', _166 => _166(pos.stream, pos.deferred_at)]);
|
|
@@ -3713,7 +3713,7 @@ var Act = (_class6 = class {
|
|
|
3713
3713
|
*/
|
|
3714
3714
|
shutdown(options) {
|
|
3715
3715
|
if (!this._shutdown_promise) {
|
|
3716
|
-
|
|
3716
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "shutdown", _nullishCoalesce(options, () => ( {})));
|
|
3717
3717
|
this._shutdown_promise = (async () => {
|
|
3718
3718
|
this.stop_correlations();
|
|
3719
3719
|
this._settle.stop(true);
|
|
@@ -3731,10 +3731,10 @@ var Act = (_class6 = class {
|
|
|
3731
3731
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3732
3732
|
// default for none or 0, and for a running settle), capped.
|
|
3733
3733
|
_derive_grace_ms(running, settling) {
|
|
3734
|
-
let max = settling ?
|
|
3734
|
+
let max = settling ? _chunkUYNNDDE7cjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3735
3735
|
for (const c of running)
|
|
3736
|
-
max = Math.max(max, c.lease_millis ||
|
|
3737
|
-
return Math.min(max,
|
|
3736
|
+
max = Math.max(max, c.lease_millis || _chunkUYNNDDE7cjs.DEFAULT_LEASE_MILLIS);
|
|
3737
|
+
return Math.min(max, _chunkUYNNDDE7cjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3738
3738
|
}
|
|
3739
3739
|
async _await_inflight(grace_ms) {
|
|
3740
3740
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3818,7 +3818,7 @@ var Act = (_class6 = class {
|
|
|
3818
3818
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3819
3819
|
*/
|
|
3820
3820
|
async do(action2, target, payload, options) {
|
|
3821
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]), () => (
|
|
3821
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]), () => ( _chunkUYNNDDE7cjs.current_reacting.call(void 0, )));
|
|
3822
3822
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _169 => _169.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3823
3823
|
return this._scoped(async () => {
|
|
3824
3824
|
const snapshots = await this._es.action(
|
|
@@ -3861,7 +3861,7 @@ var Act = (_class6 = class {
|
|
|
3861
3861
|
actor: void 0,
|
|
3862
3862
|
asOf
|
|
3863
3863
|
} : streamOrTarget;
|
|
3864
|
-
|
|
3864
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "page", _nullishCoalesce(target.asOf, () => ( {})));
|
|
3865
3865
|
return await this._es.load(merged, target, callback);
|
|
3866
3866
|
});
|
|
3867
3867
|
}
|
|
@@ -3890,11 +3890,11 @@ var Act = (_class6 = class {
|
|
|
3890
3890
|
* @see {@link query_array} for loading events into memory
|
|
3891
3891
|
*/
|
|
3892
3892
|
async query(query, callback) {
|
|
3893
|
-
|
|
3893
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "page", query);
|
|
3894
3894
|
return this._scoped(async () => {
|
|
3895
3895
|
let first;
|
|
3896
3896
|
let last;
|
|
3897
|
-
const count = await
|
|
3897
|
+
const count = await _chunkUYNNDDE7cjs.store.call(void 0, ).query((e) => {
|
|
3898
3898
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3899
3899
|
if (!first) first = gated;
|
|
3900
3900
|
last = gated;
|
|
@@ -3940,14 +3940,14 @@ var Act = (_class6 = class {
|
|
|
3940
3940
|
*/
|
|
3941
3941
|
async forget(stream) {
|
|
3942
3942
|
return this._scoped(async () => {
|
|
3943
|
-
const s =
|
|
3943
|
+
const s = _chunkUYNNDDE7cjs.store.call(void 0, );
|
|
3944
3944
|
if (!s.forget_pii) {
|
|
3945
3945
|
throw new Error(
|
|
3946
3946
|
`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).`
|
|
3947
3947
|
);
|
|
3948
3948
|
}
|
|
3949
3949
|
const eventCount = await s.forget_pii(stream);
|
|
3950
|
-
await
|
|
3950
|
+
await _chunkUYNNDDE7cjs.cache.call(void 0, ).invalidate(stream);
|
|
3951
3951
|
if (eventCount > 0) {
|
|
3952
3952
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3953
3953
|
}
|
|
@@ -3981,7 +3981,7 @@ var Act = (_class6 = class {
|
|
|
3981
3981
|
* @see {@link correlate} for dynamic stream discovery
|
|
3982
3982
|
*/
|
|
3983
3983
|
async drain(options = {}) {
|
|
3984
|
-
|
|
3984
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "drain", options);
|
|
3985
3985
|
if (!this._drain)
|
|
3986
3986
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3987
3987
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4058,7 +4058,7 @@ var Act = (_class6 = class {
|
|
|
4058
4058
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
4059
4059
|
*/
|
|
4060
4060
|
async correlate(query = {}) {
|
|
4061
|
-
|
|
4061
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "page", query);
|
|
4062
4062
|
const pass = await this._correlate_pass(_nullishCoalesce(query.limit, () => ( 10)));
|
|
4063
4063
|
return {
|
|
4064
4064
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -4104,8 +4104,8 @@ var Act = (_class6 = class {
|
|
|
4104
4104
|
* @see {@link stop_correlations} to stop the poll
|
|
4105
4105
|
*/
|
|
4106
4106
|
start_correlations(query = {}, frequency = 1e4) {
|
|
4107
|
-
|
|
4108
|
-
|
|
4107
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "page", query);
|
|
4108
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "poll", { frequency });
|
|
4109
4109
|
if (this._poll) return false;
|
|
4110
4110
|
this._poll_limit = query.limit || void 0;
|
|
4111
4111
|
this._poll = setInterval(() => {
|
|
@@ -4171,7 +4171,7 @@ var Act = (_class6 = class {
|
|
|
4171
4171
|
*/
|
|
4172
4172
|
async reset(input) {
|
|
4173
4173
|
return this._scoped(async () => {
|
|
4174
|
-
const count = await
|
|
4174
|
+
const count = await _chunkUYNNDDE7cjs.store.call(void 0, ).reset(input);
|
|
4175
4175
|
this._reset_folds();
|
|
4176
4176
|
if (count > 0) {
|
|
4177
4177
|
this._wake();
|
|
@@ -4206,7 +4206,7 @@ var Act = (_class6 = class {
|
|
|
4206
4206
|
*/
|
|
4207
4207
|
async unblock(input) {
|
|
4208
4208
|
return this._scoped(async () => {
|
|
4209
|
-
const count = await
|
|
4209
|
+
const count = await _chunkUYNNDDE7cjs.store.call(void 0, ).unblock(input);
|
|
4210
4210
|
if (count > 0) {
|
|
4211
4211
|
this._wake();
|
|
4212
4212
|
}
|
|
@@ -4254,7 +4254,7 @@ var Act = (_class6 = class {
|
|
|
4254
4254
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4255
4255
|
*/
|
|
4256
4256
|
async restore(source, opts = {}, sink) {
|
|
4257
|
-
|
|
4257
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "scan", opts);
|
|
4258
4258
|
return this._scoped(async () => {
|
|
4259
4259
|
const started = Date.now();
|
|
4260
4260
|
if (opts.dry_run) {
|
|
@@ -4262,7 +4262,7 @@ var Act = (_class6 = class {
|
|
|
4262
4262
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4263
4263
|
}
|
|
4264
4264
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4265
|
-
const s =
|
|
4265
|
+
const s = _chunkUYNNDDE7cjs.store.call(void 0, );
|
|
4266
4266
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4267
4267
|
return s;
|
|
4268
4268
|
})()));
|
|
@@ -4278,7 +4278,7 @@ var Act = (_class6 = class {
|
|
|
4278
4278
|
if (sink) await run();
|
|
4279
4279
|
else {
|
|
4280
4280
|
await this._correlate.restart(run);
|
|
4281
|
-
await
|
|
4281
|
+
await _chunkUYNNDDE7cjs.cache.call(void 0, ).clear();
|
|
4282
4282
|
this._reset_folds();
|
|
4283
4283
|
this._wake();
|
|
4284
4284
|
}
|
|
@@ -4308,10 +4308,10 @@ var Act = (_class6 = class {
|
|
|
4308
4308
|
* ```
|
|
4309
4309
|
*/
|
|
4310
4310
|
async blocked_streams(options) {
|
|
4311
|
-
|
|
4311
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "page", { limit: _optionalChain([options, 'optionalAccess', _178 => _178.limit]) });
|
|
4312
4312
|
return this._scoped(async () => {
|
|
4313
4313
|
const positions = [];
|
|
4314
|
-
await
|
|
4314
|
+
await _chunkUYNNDDE7cjs.store.call(void 0, ).query_streams(
|
|
4315
4315
|
(p) => {
|
|
4316
4316
|
positions.push(p);
|
|
4317
4317
|
},
|
|
@@ -4337,7 +4337,7 @@ var Act = (_class6 = class {
|
|
|
4337
4337
|
* ```
|
|
4338
4338
|
*/
|
|
4339
4339
|
async *audit(categories, options) {
|
|
4340
|
-
|
|
4340
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "audit", _nullishCoalesce(options, () => ( {})));
|
|
4341
4341
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4342
4342
|
while (true) {
|
|
4343
4343
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4365,8 +4365,8 @@ var Act = (_class6 = class {
|
|
|
4365
4365
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4366
4366
|
*/
|
|
4367
4367
|
async prioritize(filter, priority) {
|
|
4368
|
-
|
|
4369
|
-
return this._scoped(() =>
|
|
4368
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "target", { priority });
|
|
4369
|
+
return this._scoped(() => _chunkUYNNDDE7cjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4370
4370
|
}
|
|
4371
4371
|
// Shared by `close()` and reaction-requested closes.
|
|
4372
4372
|
async _run_close(targets) {
|
|
@@ -4446,7 +4446,7 @@ var Act = (_class6 = class {
|
|
|
4446
4446
|
* @see {@link correlate} for manual correlation
|
|
4447
4447
|
*/
|
|
4448
4448
|
settle(options) {
|
|
4449
|
-
|
|
4449
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "settle", _nullishCoalesce(options, () => ( {})));
|
|
4450
4450
|
this._schedule(options);
|
|
4451
4451
|
}
|
|
4452
4452
|
}, _class6);
|
|
@@ -4662,7 +4662,7 @@ var _this_ = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, ({ stream })
|
|
|
4662
4662
|
|
|
4663
4663
|
// src/builders/builder-utils.ts
|
|
4664
4664
|
function register_lane(config2, lanes) {
|
|
4665
|
-
|
|
4665
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "lane", config2);
|
|
4666
4666
|
if (config2.name === _chunk4GA3CHQWcjs.DEFAULT_LANE)
|
|
4667
4667
|
throw new Error(`Lane "${_chunk4GA3CHQWcjs.DEFAULT_LANE}" is reserved`);
|
|
4668
4668
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
@@ -4687,7 +4687,7 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4687
4687
|
events[event].reactions.set(name, reaction);
|
|
4688
4688
|
return Object.assign(builder, {
|
|
4689
4689
|
to(resolver) {
|
|
4690
|
-
if (typeof resolver === "object")
|
|
4690
|
+
if (typeof resolver === "object") _chunkUYNNDDE7cjs.check.call(void 0, "target", resolver);
|
|
4691
4691
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4692
4692
|
return builder;
|
|
4693
4693
|
}
|
|
@@ -4702,16 +4702,16 @@ function reaction_on(event, events, builder) {
|
|
|
4702
4702
|
"Reaction",
|
|
4703
4703
|
() => {
|
|
4704
4704
|
if (schedule && typeof schedule !== "function")
|
|
4705
|
-
|
|
4705
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "defer", schedule);
|
|
4706
4706
|
return {
|
|
4707
4707
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4708
4708
|
resolver: _this_,
|
|
4709
4709
|
// Validate the whole bag at the declaration site so a bad
|
|
4710
4710
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4711
4711
|
// not a NaN gate on the first retry.
|
|
4712
|
-
options:
|
|
4713
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _181 => _181.blockOnError]), () => (
|
|
4714
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.maxRetries]), () => (
|
|
4712
|
+
options: _chunkUYNNDDE7cjs.check.call(void 0, "reaction", {
|
|
4713
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _181 => _181.blockOnError]), () => ( _chunkUYNNDDE7cjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4714
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.maxRetries]), () => ( _chunkUYNNDDE7cjs.DEFAULT_MAX_RETRIES)),
|
|
4715
4715
|
backoff: _optionalChain([options, 'optionalAccess', _183 => _183.backoff])
|
|
4716
4716
|
})
|
|
4717
4717
|
};
|
|
@@ -4994,7 +4994,7 @@ function act() {
|
|
|
4994
4994
|
const list = deprecation_summary.map(
|
|
4995
4995
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4996
4996
|
).join(", ");
|
|
4997
|
-
|
|
4997
|
+
_chunkUYNNDDE7cjs.log.call(void 0, ).info(
|
|
4998
4998
|
`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.`
|
|
4999
4999
|
);
|
|
5000
5000
|
}
|
|
@@ -5075,7 +5075,7 @@ function act() {
|
|
|
5075
5075
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
5076
5076
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
5077
5077
|
finalize_deprecations();
|
|
5078
|
-
if (built.advisory)
|
|
5078
|
+
if (built.advisory) _chunkUYNNDDE7cjs.log.call(void 0, ).warn(built.advisory);
|
|
5079
5079
|
for (const [name, state2] of states) {
|
|
5080
5080
|
if (!state2.loads) continue;
|
|
5081
5081
|
const resolved = {};
|
|
@@ -5119,7 +5119,7 @@ function act() {
|
|
|
5119
5119
|
synthesize_autoclose_reactions(
|
|
5120
5120
|
registry,
|
|
5121
5121
|
states,
|
|
5122
|
-
|
|
5122
|
+
_chunkUYNNDDE7cjs.current_autoclose_window
|
|
5123
5123
|
);
|
|
5124
5124
|
Object.freeze(registry.actions);
|
|
5125
5125
|
Object.freeze(registry.events);
|
|
@@ -5168,8 +5168,8 @@ function _projection(target) {
|
|
|
5168
5168
|
handler,
|
|
5169
5169
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5170
5170
|
options: {
|
|
5171
|
-
blockOnError:
|
|
5172
|
-
maxRetries:
|
|
5171
|
+
blockOnError: _chunkUYNNDDE7cjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5172
|
+
maxRetries: _chunkUYNNDDE7cjs.DEFAULT_MAX_RETRIES
|
|
5173
5173
|
}
|
|
5174
5174
|
}),
|
|
5175
5175
|
widened
|
|
@@ -5210,7 +5210,7 @@ function _projection(target) {
|
|
|
5210
5210
|
throw new Error(
|
|
5211
5211
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5212
5212
|
);
|
|
5213
|
-
const config2 =
|
|
5213
|
+
const config2 = _chunkUYNNDDE7cjs.check.call(void 0, "fold", options);
|
|
5214
5214
|
const fold_events = {};
|
|
5215
5215
|
for (const partial of partials)
|
|
5216
5216
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5228,8 +5228,8 @@ function _projection(target) {
|
|
|
5228
5228
|
handler: noop,
|
|
5229
5229
|
resolver: { target },
|
|
5230
5230
|
options: {
|
|
5231
|
-
blockOnError:
|
|
5232
|
-
maxRetries:
|
|
5231
|
+
blockOnError: _chunkUYNNDDE7cjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5232
|
+
maxRetries: _chunkUYNNDDE7cjs.DEFAULT_MAX_RETRIES
|
|
5233
5233
|
}
|
|
5234
5234
|
}
|
|
5235
5235
|
]
|
|
@@ -5349,7 +5349,7 @@ function action_builder(state2) {
|
|
|
5349
5349
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5350
5350
|
internal.actions[action2] = schema;
|
|
5351
5351
|
if (options) {
|
|
5352
|
-
|
|
5352
|
+
_chunkUYNNDDE7cjs.check.call(void 0, "action", options);
|
|
5353
5353
|
internal.options ??= {};
|
|
5354
5354
|
internal.options[action2] = options;
|
|
5355
5355
|
}
|
|
@@ -5639,9 +5639,9 @@ var ExitCodes2 = _chunk4GA3CHQWcjs.ExitCodes;
|
|
|
5639
5639
|
var DEFAULT_LANE2 = _chunk4GA3CHQWcjs.DEFAULT_LANE;
|
|
5640
5640
|
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunk4GA3CHQWcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5641
5641
|
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunk4GA3CHQWcjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5642
|
-
var PackageSchema =
|
|
5643
|
-
var default_scope =
|
|
5644
|
-
var extend = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (source, schema, target) => ({ ...target, ...
|
|
5642
|
+
var PackageSchema = _chunkUYNNDDE7cjs.package_schema;
|
|
5643
|
+
var default_scope = _chunkUYNNDDE7cjs.unscoped_ports;
|
|
5644
|
+
var extend = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (source, schema, target) => ({ ...target, ..._chunkUYNNDDE7cjs.validate.call(void 0, "config", source, schema) }), "extend");
|
|
5645
5645
|
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])?$/;
|
|
5646
5646
|
var dateReviver = /* @__PURE__ */ _chunk4GA3CHQWcjs.__name.call(void 0, (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
|
|
5647
5647
|
function sensitiveFields(schema) {
|
|
@@ -5708,5 +5708,5 @@ var pii_fields = sensitiveFields;
|
|
|
5708
5708
|
|
|
5709
5709
|
|
|
5710
5710
|
|
|
5711
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunk4GA3CHQWcjs.ConcurrencyError; exports.ConsoleLogger =
|
|
5711
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunk4GA3CHQWcjs.ConcurrencyError; exports.ConsoleLogger = _chunkUYNNDDE7cjs.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 = _chunk4GA3CHQWcjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunk4GA3CHQWcjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkUYNNDDE7cjs.InMemoryCache; exports.InMemoryStore = _chunkUYNNDDE7cjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunk4GA3CHQWcjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunk4GA3CHQWcjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunk4GA3CHQWcjs.REDACTED; exports.SHREDDED = _chunk4GA3CHQWcjs.SHREDDED; exports.SNAP_EVENT = _chunk4GA3CHQWcjs.SNAP_EVENT; exports.StoreError = _chunk4GA3CHQWcjs.StoreError; exports.StreamClosedError = _chunk4GA3CHQWcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunk4GA3CHQWcjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunk4GA3CHQWcjs.ValidationError; exports.ZodEmpty = _chunk4GA3CHQWcjs.ZodEmpty; exports.act = act; exports.cache = _chunkUYNNDDE7cjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkUYNNDDE7cjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkUYNNDDE7cjs.dispose; exports.disposeAndExit = _chunkUYNNDDE7cjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkUYNNDDE7cjs.log; exports.notification_of = notification_of; exports.pii_fields = pii_fields; exports.port = _chunkUYNNDDE7cjs.port; exports.projection = projection; exports.seed_event = seed_event; exports.sensitive = _chunk4GA3CHQWcjs.sensitive; exports.sensitiveFields = sensitiveFields; exports.sleep = _chunkUYNNDDE7cjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkUYNNDDE7cjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkUYNNDDE7cjs.validate;
|
|
5712
5712
|
//# sourceMappingURL=index.cjs.map
|