@rotorsoft/act 2.0.0 → 2.0.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/builders/merge.d.ts.map +1 -1
- package/dist/@types/internal/zod.d.ts +2 -2
- package/dist/@types/types/ports.d.ts +23 -26
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/{chunk-MWHTNPUY.js → chunk-33D5NQNQ.js} +2 -2
- package/dist/{chunk-YFFWCVXW.cjs → chunk-3CQWJ4UA.cjs} +1 -1
- package/dist/chunk-3CQWJ4UA.cjs.map +1 -0
- package/dist/{chunk-LUHPSF3C.cjs → chunk-S2BEPQ5Z.cjs} +13 -13
- package/dist/{chunk-LUHPSF3C.cjs.map → chunk-S2BEPQ5Z.cjs.map} +1 -1
- package/dist/{chunk-SNPEQW6Z.js → chunk-UO7HNLSH.js} +1 -1
- package/dist/chunk-UO7HNLSH.js.map +1 -0
- package/dist/index.cjs +161 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +4 -4
- package/dist/test/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-SNPEQW6Z.js.map +0 -1
- package/dist/chunk-YFFWCVXW.cjs.map +0 -1
- /package/dist/{chunk-MWHTNPUY.js.map → chunk-33D5NQNQ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
var
|
|
47
|
+
var _chunkS2BEPQ5Zcjs = require('./chunk-S2BEPQ5Z.cjs');
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
@@ -77,24 +77,24 @@ var _chunkLUHPSF3Ccjs = require('./chunk-LUHPSF3C.cjs');
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
var
|
|
80
|
+
var _chunk3CQWJ4UAcjs = require('./chunk-3CQWJ4UA.cjs');
|
|
81
81
|
|
|
82
82
|
// src/signals.ts
|
|
83
83
|
process.once("SIGINT", async (arg) => {
|
|
84
|
-
|
|
85
|
-
await
|
|
84
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
85
|
+
await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "EXIT");
|
|
86
86
|
});
|
|
87
87
|
process.once("SIGTERM", async (arg) => {
|
|
88
|
-
|
|
89
|
-
await
|
|
88
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
89
|
+
await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "EXIT");
|
|
90
90
|
});
|
|
91
91
|
process.once("uncaughtException", async (arg) => {
|
|
92
|
-
|
|
93
|
-
await
|
|
92
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
93
|
+
await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "ERROR");
|
|
94
94
|
});
|
|
95
95
|
process.once("unhandledRejection", async (arg) => {
|
|
96
|
-
|
|
97
|
-
await
|
|
96
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
97
|
+
await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "ERROR");
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
// src/act.ts
|
|
@@ -202,7 +202,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
202
202
|
if (need_stats) {
|
|
203
203
|
const stats = await deps.store().query_stats(
|
|
204
204
|
{},
|
|
205
|
-
{ count: true, names: true, exclude: [
|
|
205
|
+
{ count: true, names: true, exclude: [_chunk3CQWJ4UAcjs.SNAP_EVENT] }
|
|
206
206
|
);
|
|
207
207
|
for (const [stream, s] of stats) {
|
|
208
208
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -284,7 +284,7 @@ var make_schema_pass = (deps) => {
|
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
const schema = state2.events[name];
|
|
287
|
-
const sensitive2 =
|
|
287
|
+
const sensitive2 = _chunk3CQWJ4UAcjs.pii_fields.call(void 0, schema);
|
|
288
288
|
let parse_schema = schema;
|
|
289
289
|
if (sensitive2.length > 0) {
|
|
290
290
|
const omitter = schema.omit;
|
|
@@ -418,7 +418,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
418
418
|
{
|
|
419
419
|
stream,
|
|
420
420
|
stream_exact: true,
|
|
421
|
-
names: [
|
|
421
|
+
names: [_chunk3CQWJ4UAcjs.SNAP_EVENT],
|
|
422
422
|
with_snaps: true,
|
|
423
423
|
// From the start: on its own, `with_snaps` resumes at the latest.
|
|
424
424
|
after: -1
|
|
@@ -578,7 +578,7 @@ var make_correlation_gaps_pass = () => {
|
|
|
578
578
|
seen_ids.add(e.id);
|
|
579
579
|
const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
|
|
580
580
|
const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
|
|
581
|
-
if (parent_id !== void 0 && e.name !==
|
|
581
|
+
if (parent_id !== void 0 && e.name !== _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) {
|
|
582
582
|
checks.push({ stream: e.stream, id: e.id, parent_id });
|
|
583
583
|
}
|
|
584
584
|
},
|
|
@@ -968,7 +968,7 @@ function make_deferred(handler, schedule) {
|
|
|
968
968
|
const call = handler;
|
|
969
969
|
const deferred = async (event, stream, app) => {
|
|
970
970
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
971
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
971
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunk3CQWJ4UAcjs.DeferSignal)(when);
|
|
972
972
|
return call(event, stream, app);
|
|
973
973
|
};
|
|
974
974
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
@@ -1100,7 +1100,7 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1100
1100
|
function report_once(seen, key, message) {
|
|
1101
1101
|
if (seen.has(key)) return;
|
|
1102
1102
|
seen.add(key);
|
|
1103
|
-
|
|
1103
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).error(new Error(message));
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
1106
|
// src/internal/correlation-id.ts
|
|
@@ -1128,14 +1128,14 @@ function close_correlation(correlator, actor) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
1130
|
// src/internal/drain-ops.ts
|
|
1131
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1131
|
+
var claim = (lagging, leading, by, millis, lane) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
|
|
1132
1132
|
async function fetch(leased, eventLimit) {
|
|
1133
1133
|
return Promise.all(
|
|
1134
1134
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1135
1135
|
const events = [];
|
|
1136
|
-
const stream_exact = source !== void 0 &&
|
|
1136
|
+
const stream_exact = source !== void 0 && _chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, source, stream) ? true : void 0;
|
|
1137
1137
|
try {
|
|
1138
|
-
await
|
|
1138
|
+
await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1139
1139
|
stream: source,
|
|
1140
1140
|
stream_exact,
|
|
1141
1141
|
after: at,
|
|
@@ -1155,9 +1155,9 @@ async function fetch(leased, eventLimit) {
|
|
|
1155
1155
|
})
|
|
1156
1156
|
);
|
|
1157
1157
|
}
|
|
1158
|
-
var ack = (leases) =>
|
|
1159
|
-
var block = (leases) =>
|
|
1160
|
-
var subscribe = (streams, correlated_at, correlator) =>
|
|
1158
|
+
var ack = (leases) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).ack(leases);
|
|
1159
|
+
var block = (leases) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).block(leases);
|
|
1160
|
+
var subscribe = (streams, correlated_at, correlator) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
|
|
1161
1161
|
|
|
1162
1162
|
// src/internal/event-sourcing.ts
|
|
1163
1163
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1172,29 +1172,29 @@ var check_invariants = (target, state2, schema, pii_aware) => {
|
|
|
1172
1172
|
try {
|
|
1173
1173
|
result = schema.safeParse(state2);
|
|
1174
1174
|
} catch (error) {
|
|
1175
|
-
throw new (0,
|
|
1175
|
+
throw new (0, _chunk3CQWJ4UAcjs.ValidationError)(target, state2, error);
|
|
1176
1176
|
}
|
|
1177
1177
|
if (result.success) return;
|
|
1178
1178
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1179
1179
|
const value = value_at(state2, issue.path);
|
|
1180
|
-
return value !==
|
|
1180
|
+
return value !== _chunk3CQWJ4UAcjs.REDACTED && value !== _chunk3CQWJ4UAcjs.SHREDDED;
|
|
1181
1181
|
}) : result.error.issues;
|
|
1182
1182
|
if (issues.length)
|
|
1183
|
-
throw new (0,
|
|
1183
|
+
throw new (0, _chunk3CQWJ4UAcjs.ValidationError)(
|
|
1184
1184
|
target,
|
|
1185
1185
|
state2,
|
|
1186
1186
|
_zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
|
|
1187
1187
|
);
|
|
1188
1188
|
};
|
|
1189
1189
|
var DEFAULT_BATCH = 500;
|
|
1190
|
-
var cache_put = (stream, entry) =>
|
|
1191
|
-
(err) =>
|
|
1190
|
+
var cache_put = (stream, entry) => _chunkS2BEPQ5Zcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1191
|
+
(err) => _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
|
|
1192
1192
|
err,
|
|
1193
1193
|
"cache set skipped; the next load re-folds from the store"
|
|
1194
1194
|
)
|
|
1195
1195
|
);
|
|
1196
|
-
var cache_drop = (stream) =>
|
|
1197
|
-
(err) =>
|
|
1196
|
+
var cache_drop = (stream) => _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1197
|
+
(err) => _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
|
|
1198
1198
|
err,
|
|
1199
1199
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1200
1200
|
)
|
|
@@ -1202,11 +1202,11 @@ var cache_drop = (stream) => _chunkLUHPSF3Ccjs.cache.call(void 0, ).invalidate(s
|
|
|
1202
1202
|
async function snap(snapshot) {
|
|
1203
1203
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1204
1204
|
try {
|
|
1205
|
-
const [committed] = await
|
|
1205
|
+
const [committed] = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).commit(
|
|
1206
1206
|
[
|
|
1207
1207
|
{
|
|
1208
1208
|
stream,
|
|
1209
|
-
msgs: [{ name:
|
|
1209
|
+
msgs: [{ name: _chunk3CQWJ4UAcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1210
1210
|
// IMPORTANT! - state events are committed right after the snapshot event
|
|
1211
1211
|
expectedVersion: version
|
|
1212
1212
|
}
|
|
@@ -1219,18 +1219,18 @@ async function snap(snapshot) {
|
|
|
1219
1219
|
return committed;
|
|
1220
1220
|
} catch (error) {
|
|
1221
1221
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1222
|
-
|
|
1222
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
|
|
1223
1223
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1224
1224
|
);
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
1227
1227
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1228
1228
|
try {
|
|
1229
|
-
const [committed] = await
|
|
1229
|
+
const [committed] = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).commit(
|
|
1230
1230
|
[
|
|
1231
1231
|
{
|
|
1232
1232
|
stream,
|
|
1233
|
-
msgs: [{ name:
|
|
1233
|
+
msgs: [{ name: _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1234
1234
|
expectedVersion
|
|
1235
1235
|
}
|
|
1236
1236
|
],
|
|
@@ -1238,7 +1238,7 @@ async function tombstone(stream, expectedVersion, correlation) {
|
|
|
1238
1238
|
);
|
|
1239
1239
|
return committed;
|
|
1240
1240
|
} catch (error) {
|
|
1241
|
-
if (error instanceof
|
|
1241
|
+
if (error instanceof _chunk3CQWJ4UAcjs.ConcurrencyError) return void 0;
|
|
1242
1242
|
throw error;
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
@@ -1268,9 +1268,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1268
1268
|
if (drop_closed_streams) {
|
|
1269
1269
|
await source.query(
|
|
1270
1270
|
(e) => {
|
|
1271
|
-
if (e.name ===
|
|
1271
|
+
if (e.name === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1272
1272
|
},
|
|
1273
|
-
{ names: [
|
|
1273
|
+
{ names: [_chunk3CQWJ4UAcjs.TOMBSTONE_EVENT] }
|
|
1274
1274
|
);
|
|
1275
1275
|
}
|
|
1276
1276
|
let max_id;
|
|
@@ -1292,11 +1292,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1292
1292
|
if (!is_valid(event))
|
|
1293
1293
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1294
1294
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1295
|
-
if (drop_snapshots && event.name ===
|
|
1295
|
+
if (drop_snapshots && event.name === _chunk3CQWJ4UAcjs.SNAP_EVENT) {
|
|
1296
1296
|
dropped_snaps++;
|
|
1297
1297
|
return;
|
|
1298
1298
|
}
|
|
1299
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1299
|
+
if (closed_streams.has(event.stream) && event.name !== _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) {
|
|
1300
1300
|
dropped_closed++;
|
|
1301
1301
|
return;
|
|
1302
1302
|
}
|
|
@@ -1364,18 +1364,18 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1364
1364
|
const { stream, actor, asOf } = target;
|
|
1365
1365
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1366
1366
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1367
|
-
const cached = time_travel ? void 0 : await
|
|
1367
|
+
const cached = time_travel ? void 0 : await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).get(stream);
|
|
1368
1368
|
const cache_hit = !!cached;
|
|
1369
1369
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _58 => _58.state]), () => ( (me.init ? me.init() : {})));
|
|
1370
1370
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _59 => _59.patches]), () => ( 0));
|
|
1371
1371
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _60 => _60.snaps]), () => ( 0));
|
|
1372
1372
|
let replayed = 0;
|
|
1373
1373
|
let event;
|
|
1374
|
-
await
|
|
1374
|
+
await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query(
|
|
1375
1375
|
(raw) => {
|
|
1376
|
-
if (seeded && raw.name ===
|
|
1376
|
+
if (seeded && raw.name === _chunk3CQWJ4UAcjs.SNAP_EVENT && replayed > 0) return;
|
|
1377
1377
|
event = me.view(raw, actor);
|
|
1378
|
-
if (event.name ===
|
|
1378
|
+
if (event.name === _chunk3CQWJ4UAcjs.SNAP_EVENT) {
|
|
1379
1379
|
state2 = event.data;
|
|
1380
1380
|
snaps++;
|
|
1381
1381
|
patches = 0;
|
|
@@ -1384,8 +1384,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1384
1384
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1385
1385
|
patches++;
|
|
1386
1386
|
replayed++;
|
|
1387
|
-
} else if (event.name !==
|
|
1388
|
-
|
|
1387
|
+
} else if (event.name !== _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) {
|
|
1388
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
|
|
1389
1389
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1390
1390
|
);
|
|
1391
1391
|
}
|
|
@@ -1413,7 +1413,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1413
1413
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1414
1414
|
}
|
|
1415
1415
|
);
|
|
1416
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _62 => _62.name]) ===
|
|
1416
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _62 => _62.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT;
|
|
1417
1417
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1418
1418
|
await cache_put(stream, {
|
|
1419
1419
|
stream,
|
|
@@ -1456,8 +1456,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1456
1456
|
void 0,
|
|
1457
1457
|
patch_fn
|
|
1458
1458
|
);
|
|
1459
|
-
if (_optionalChain([snapshot, 'access', _67 => _67.event, 'optionalAccess', _68 => _68.name]) ===
|
|
1460
|
-
throw new (0,
|
|
1459
|
+
if (_optionalChain([snapshot, 'access', _67 => _67.event, 'optionalAccess', _68 => _68.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT)
|
|
1460
|
+
throw new (0, _chunk3CQWJ4UAcjs.StreamClosedError)(stream);
|
|
1461
1461
|
return {
|
|
1462
1462
|
state: l.state,
|
|
1463
1463
|
stream,
|
|
@@ -1473,7 +1473,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1473
1473
|
if (!stream) throw new Error("Missing target stream");
|
|
1474
1474
|
const reactingTo = _optionalChain([options, 'optionalAccess', _69 => _69.reactingTo]);
|
|
1475
1475
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _70 => _70.correlator]), () => ( default_correlator));
|
|
1476
|
-
const validated =
|
|
1476
|
+
const validated = _chunkS2BEPQ5Zcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1477
1477
|
const opts = _optionalChain([me, 'access', _71 => _71.options, 'optionalAccess', _72 => _72[action2]]);
|
|
1478
1478
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _73 => _73.maxRetries]), () => ( 0));
|
|
1479
1479
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _74 => _74.loads, 'optionalAccess', _75 => _75[action2]]), () => ( []));
|
|
@@ -1485,8 +1485,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1485
1485
|
void 0,
|
|
1486
1486
|
patch_fn
|
|
1487
1487
|
);
|
|
1488
|
-
if (_optionalChain([snapshot, 'access', _76 => _76.event, 'optionalAccess', _77 => _77.name]) ===
|
|
1489
|
-
throw new (0,
|
|
1488
|
+
if (_optionalChain([snapshot, 'access', _76 => _76.event, 'optionalAccess', _77 => _77.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT)
|
|
1489
|
+
throw new (0, _chunk3CQWJ4UAcjs.StreamClosedError)(stream);
|
|
1490
1490
|
const own = {
|
|
1491
1491
|
state: me,
|
|
1492
1492
|
stream,
|
|
@@ -1500,7 +1500,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1500
1500
|
{ stream, state: snapshot.state },
|
|
1501
1501
|
target.actor,
|
|
1502
1502
|
patch_fn,
|
|
1503
|
-
(description) => new (0,
|
|
1503
|
+
(description) => new (0, _chunk3CQWJ4UAcjs.PreconditionError)(
|
|
1504
1504
|
action2,
|
|
1505
1505
|
validated,
|
|
1506
1506
|
target,
|
|
@@ -1513,7 +1513,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1513
1513
|
);
|
|
1514
1514
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _80 => _80.requires, 'optionalAccess', _81 => _81[action2]]), () => ( [])))
|
|
1515
1515
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1516
|
-
throw new (0,
|
|
1516
|
+
throw new (0, _chunk3CQWJ4UAcjs.PreconditionError)(
|
|
1517
1517
|
action2,
|
|
1518
1518
|
validated,
|
|
1519
1519
|
target,
|
|
@@ -1535,7 +1535,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1535
1535
|
);
|
|
1536
1536
|
to.events.push({
|
|
1537
1537
|
name: event,
|
|
1538
|
-
data:
|
|
1538
|
+
data: _chunkS2BEPQ5Zcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1539
1539
|
});
|
|
1540
1540
|
}
|
|
1541
1541
|
if (!own.events.length)
|
|
@@ -1592,7 +1592,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1592
1592
|
});
|
|
1593
1593
|
let committed;
|
|
1594
1594
|
try {
|
|
1595
|
-
committed = await
|
|
1595
|
+
committed = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).commit(
|
|
1596
1596
|
appends.map((p) => ({
|
|
1597
1597
|
stream: p.stream,
|
|
1598
1598
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1601,7 +1601,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1601
1601
|
meta
|
|
1602
1602
|
);
|
|
1603
1603
|
} catch (error) {
|
|
1604
|
-
if (error instanceof
|
|
1604
|
+
if (error instanceof _chunk3CQWJ4UAcjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1605
1605
|
throw error;
|
|
1606
1606
|
}
|
|
1607
1607
|
let row = 0;
|
|
@@ -1643,19 +1643,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1643
1643
|
}
|
|
1644
1644
|
return snapshots;
|
|
1645
1645
|
} catch (error) {
|
|
1646
|
-
if (!(error instanceof
|
|
1646
|
+
if (!(error instanceof _chunk3CQWJ4UAcjs.ConcurrencyError)) throw error;
|
|
1647
1647
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1648
1648
|
if (attempt >= max_retries) throw error;
|
|
1649
1649
|
if (_optionalChain([opts, 'optionalAccess', _90 => _90.backoff])) {
|
|
1650
1650
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1651
|
-
if (delay_ms > 0) await
|
|
1651
|
+
if (delay_ms > 0) await _chunkS2BEPQ5Zcjs.sleep.call(void 0, delay_ms);
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
|
|
1657
1657
|
// src/internal/tracing.ts
|
|
1658
|
-
var PRETTY =
|
|
1658
|
+
var PRETTY = _chunkS2BEPQ5Zcjs.config.call(void 0, ).env !== "production";
|
|
1659
1659
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1660
1660
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1661
1661
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1839,7 +1839,7 @@ function budget_exhausted(lease, options, store_failing) {
|
|
|
1839
1839
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _101 => _101.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1840
1840
|
return void 0;
|
|
1841
1841
|
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.`;
|
|
1842
|
-
|
|
1842
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).error(error);
|
|
1843
1843
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1844
1844
|
}
|
|
1845
1845
|
function fetch_failure_policy(registry) {
|
|
@@ -1855,13 +1855,13 @@ function fetch_failure_policy(registry) {
|
|
|
1855
1855
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1856
1856
|
if (!error) return { lease, handled, acked_at: at };
|
|
1857
1857
|
logger.error(error);
|
|
1858
|
-
const non_retryable = error instanceof
|
|
1858
|
+
const non_retryable = error instanceof _chunk3CQWJ4UAcjs.NonRetryableError;
|
|
1859
1859
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
1860
1860
|
if (block2)
|
|
1861
1861
|
logger.error(
|
|
1862
1862
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1863
1863
|
);
|
|
1864
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
1864
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkS2BEPQ5Zcjs.DEFAULT_BACKOFF)));
|
|
1865
1865
|
return {
|
|
1866
1866
|
lease,
|
|
1867
1867
|
handled,
|
|
@@ -1989,7 +1989,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
1989
1989
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
1990
1990
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
1991
1991
|
if (acked.length < expected)
|
|
1992
|
-
|
|
1992
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
|
|
1993
1993
|
`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.`
|
|
1994
1994
|
);
|
|
1995
1995
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
@@ -2085,9 +2085,9 @@ var DrainController = (_class3 = class {
|
|
|
2085
2085
|
if (!this.armed || this._stopped || this._inflight)
|
|
2086
2086
|
return EMPTY_DRAIN;
|
|
2087
2087
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2088
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2089
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2090
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2088
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_STREAM_LIMIT));
|
|
2089
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkS2BEPQ5Zcjs.DEFAULT_EVENT_LIMIT));
|
|
2090
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_LEASE_MILLIS));
|
|
2091
2091
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2092
2092
|
return EMPTY_DRAIN;
|
|
2093
2093
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2213,7 +2213,7 @@ function build_handle(deps) {
|
|
|
2213
2213
|
handled++;
|
|
2214
2214
|
}
|
|
2215
2215
|
} catch (error) {
|
|
2216
|
-
if (error instanceof
|
|
2216
|
+
if (error instanceof _chunk3CQWJ4UAcjs.DeferSignal) {
|
|
2217
2217
|
let defer;
|
|
2218
2218
|
try {
|
|
2219
2219
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2310,22 +2310,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2310
2310
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2311
2311
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2312
2312
|
// autoclose: `app.close` still closes it.
|
|
2313
|
-
resolver: (e) =>
|
|
2313
|
+
resolver: (e) => _chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, e.stream) ? {
|
|
2314
2314
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2315
2315
|
source: e.stream
|
|
2316
2316
|
} : void 0,
|
|
2317
2317
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2318
2318
|
// not quarantine the synthetic stream.
|
|
2319
|
-
options: { blockOnError: false, maxRetries:
|
|
2319
|
+
options: { blockOnError: false, maxRetries: _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES },
|
|
2320
2320
|
handler: async (event) => {
|
|
2321
2321
|
const aggregate = event.stream;
|
|
2322
2322
|
const window = read_window();
|
|
2323
2323
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2324
|
-
throw new (0,
|
|
2325
|
-
const stats = await
|
|
2324
|
+
throw new (0, _chunk3CQWJ4UAcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2325
|
+
const stats = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2326
2326
|
count: true,
|
|
2327
2327
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2328
|
-
exclude: [
|
|
2328
|
+
exclude: [_chunk3CQWJ4UAcjs.TOMBSTONE_EVENT, _chunk3CQWJ4UAcjs.SNAP_EVENT]
|
|
2329
2329
|
});
|
|
2330
2330
|
const entry = stats.get(aggregate);
|
|
2331
2331
|
if (!entry) return;
|
|
@@ -2361,7 +2361,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2361
2361
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2362
2362
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2363
2363
|
if (future.length)
|
|
2364
|
-
throw new (0,
|
|
2364
|
+
throw new (0, _chunk3CQWJ4UAcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2365
2365
|
}
|
|
2366
2366
|
};
|
|
2367
2367
|
const key = `__autoclose_${st.name}`;
|
|
@@ -2421,7 +2421,7 @@ async function run_close_cycle(targets, deps) {
|
|
|
2421
2421
|
deps,
|
|
2422
2422
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2423
2423
|
);
|
|
2424
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2424
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2425
2425
|
if (retired.length) _optionalChain([deps, 'access', _128 => _128.forget_subscribed, 'optionalCall', _129 => _129(retired)]);
|
|
2426
2426
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2427
2427
|
return { truncated, skipped };
|
|
@@ -2503,7 +2503,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2503
2503
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2504
2504
|
return void 0;
|
|
2505
2505
|
if (t.archive) await t.archive();
|
|
2506
|
-
const result = await
|
|
2506
|
+
const result = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).truncate([
|
|
2507
2507
|
{ stream: t.stream, before: t.before, max_id }
|
|
2508
2508
|
]);
|
|
2509
2509
|
return result.get(t.stream);
|
|
@@ -2516,10 +2516,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2516
2516
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2517
2517
|
let boundary_id;
|
|
2518
2518
|
let min_id;
|
|
2519
|
-
await
|
|
2519
|
+
await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query(
|
|
2520
2520
|
(event) => {
|
|
2521
2521
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2522
|
-
if (event.name ===
|
|
2522
|
+
if (event.name === _chunk3CQWJ4UAcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
2523
2523
|
boundary_id = event.id;
|
|
2524
2524
|
},
|
|
2525
2525
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
@@ -2530,7 +2530,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2530
2530
|
const min_at = /* @__PURE__ */ new Map();
|
|
2531
2531
|
const matches = source_matcher();
|
|
2532
2532
|
await walk_streams(
|
|
2533
|
-
|
|
2533
|
+
_chunkS2BEPQ5Zcjs.store.call(void 0, ),
|
|
2534
2534
|
(position) => {
|
|
2535
2535
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2536
2536
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2549,7 +2549,7 @@ function source_matcher() {
|
|
|
2549
2549
|
const compiled = /* @__PURE__ */ new Map();
|
|
2550
2550
|
return (source, target, stream) => {
|
|
2551
2551
|
if (!source) return true;
|
|
2552
|
-
if (
|
|
2552
|
+
if (_chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, source, target)) return source === stream;
|
|
2553
2553
|
let re = compiled.get(source);
|
|
2554
2554
|
if (!re) {
|
|
2555
2555
|
re = new RegExp(source);
|
|
@@ -2559,17 +2559,17 @@ function source_matcher() {
|
|
|
2559
2559
|
};
|
|
2560
2560
|
}
|
|
2561
2561
|
async function scan_stream_heads(streams) {
|
|
2562
|
-
const stats = await
|
|
2563
|
-
exclude: [
|
|
2562
|
+
const stats = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(streams, {
|
|
2563
|
+
exclude: [_chunk3CQWJ4UAcjs.SNAP_EVENT]
|
|
2564
2564
|
});
|
|
2565
|
-
const domain_heads = await
|
|
2566
|
-
exclude: [
|
|
2565
|
+
const domain_heads = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(streams, {
|
|
2566
|
+
exclude: [_chunk3CQWJ4UAcjs.SNAP_EVENT, _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT]
|
|
2567
2567
|
});
|
|
2568
|
-
const true_heads = await
|
|
2568
|
+
const true_heads = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2569
2569
|
const out = /* @__PURE__ */ new Map();
|
|
2570
2570
|
for (const [stream, { head }] of domain_heads) {
|
|
2571
2571
|
const marker_head = _optionalChain([stats, 'access', _131 => _131.get, 'call', _132 => _132(stream), 'optionalAccess', _133 => _133.head]);
|
|
2572
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess', _134 => _134.name]) ===
|
|
2572
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _134 => _134.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT;
|
|
2573
2573
|
out.set(stream, {
|
|
2574
2574
|
max_id: head.id,
|
|
2575
2575
|
version: true_heads.get(stream).head.version,
|
|
@@ -2592,7 +2592,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2592
2592
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2593
2593
|
const matches = source_matcher();
|
|
2594
2594
|
await walk_streams(
|
|
2595
|
-
|
|
2595
|
+
_chunkS2BEPQ5Zcjs.store.call(void 0, ),
|
|
2596
2596
|
(position) => {
|
|
2597
2597
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2598
2598
|
if (!has_work) return;
|
|
@@ -2659,7 +2659,7 @@ async function run_archive_callbacks(guarded, target_map) {
|
|
|
2659
2659
|
}
|
|
2660
2660
|
}
|
|
2661
2661
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2662
|
-
const heads = await
|
|
2662
|
+
const heads = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2663
2663
|
return guarded.filter((stream) => {
|
|
2664
2664
|
if (_optionalChain([heads, 'access', _141 => _141.get, 'call', _142 => _142(stream), 'optionalAccess', _143 => _143.head, 'access', _144 => _144.id]) === guard_events.get(stream).id)
|
|
2665
2665
|
return true;
|
|
@@ -2677,18 +2677,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2677
2677
|
meta: {
|
|
2678
2678
|
correlation,
|
|
2679
2679
|
causation: {
|
|
2680
|
-
event: { id: guard.id, name:
|
|
2680
|
+
event: { id: guard.id, name: _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2681
2681
|
}
|
|
2682
2682
|
}
|
|
2683
2683
|
};
|
|
2684
2684
|
});
|
|
2685
|
-
const truncated = await
|
|
2685
|
+
const truncated = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2686
2686
|
await Promise.all(
|
|
2687
2687
|
guarded.map(async (stream) => {
|
|
2688
2688
|
const entry = truncated.get(stream);
|
|
2689
2689
|
const state2 = seed_states.get(stream);
|
|
2690
2690
|
if (state2 && entry) {
|
|
2691
|
-
await
|
|
2691
|
+
await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).set(stream, {
|
|
2692
2692
|
stream,
|
|
2693
2693
|
state: state2,
|
|
2694
2694
|
version: entry.committed.version,
|
|
@@ -2697,7 +2697,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2697
2697
|
snaps: 1
|
|
2698
2698
|
});
|
|
2699
2699
|
} else {
|
|
2700
|
-
await
|
|
2700
|
+
await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(stream);
|
|
2701
2701
|
}
|
|
2702
2702
|
})
|
|
2703
2703
|
);
|
|
@@ -2749,7 +2749,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2749
2749
|
// never lets a resolution re-lane them.
|
|
2750
2750
|
|
|
2751
2751
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2752
|
-
__init19() {this._patterns = new (0,
|
|
2752
|
+
__init19() {this._patterns = new (0, _chunkS2BEPQ5Zcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2753
2753
|
|
|
2754
2754
|
|
|
2755
2755
|
|
|
@@ -2767,7 +2767,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2767
2767
|
on_init
|
|
2768
2768
|
}) {;_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);
|
|
2769
2769
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2770
|
-
this._dynamic_subscriptions = new (0,
|
|
2770
|
+
this._dynamic_subscriptions = new (0, _chunkS2BEPQ5Zcjs.LruMap)(max_subscribed_streams);
|
|
2771
2771
|
this._registry = registry;
|
|
2772
2772
|
this._declared_lanes = declared_lanes;
|
|
2773
2773
|
this._static_targets = static_targets;
|
|
@@ -2825,7 +2825,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2825
2825
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
2826
2826
|
_in_fetch_window(source, stream) {
|
|
2827
2827
|
if (source === void 0 || source === stream) return true;
|
|
2828
|
-
if (
|
|
2828
|
+
if (_chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, source)) return false;
|
|
2829
2829
|
let pattern = this._patterns.get(source);
|
|
2830
2830
|
if (!pattern) {
|
|
2831
2831
|
pattern = new RegExp(source);
|
|
@@ -2868,7 +2868,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2868
2868
|
const correlated = /* @__PURE__ */ new Map();
|
|
2869
2869
|
let last_id = after;
|
|
2870
2870
|
let stopped = false;
|
|
2871
|
-
const found = await
|
|
2871
|
+
const found = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query(
|
|
2872
2872
|
(event) => {
|
|
2873
2873
|
if (stopped) return;
|
|
2874
2874
|
const register = this._registry.events[event.name];
|
|
@@ -2913,9 +2913,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2913
2913
|
correlated_at: void 0
|
|
2914
2914
|
};
|
|
2915
2915
|
const seen_in_scan = correlated.has(resolved.target);
|
|
2916
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _147 => _147.lane])), () => (
|
|
2916
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _147 => _147.lane])), () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
|
|
2917
2917
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _148 => _148.priority]);
|
|
2918
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
2918
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
|
|
2919
2919
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
2920
2920
|
report_lane_conflict(
|
|
2921
2921
|
this._reported,
|
|
@@ -2989,7 +2989,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2989
2989
|
await Promise.all(
|
|
2990
2990
|
missed.map(async ([stream, entry]) => {
|
|
2991
2991
|
let row;
|
|
2992
|
-
await
|
|
2992
|
+
await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_streams(
|
|
2993
2993
|
(position) => {
|
|
2994
2994
|
row = position;
|
|
2995
2995
|
},
|
|
@@ -3001,8 +3001,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3001
3001
|
lane: row.lane
|
|
3002
3002
|
});
|
|
3003
3003
|
if (entry.priority > row.priority) return;
|
|
3004
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3005
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3004
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
|
|
3005
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
|
|
3006
3006
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3007
3007
|
report_lane_conflict(
|
|
3008
3008
|
this._reported,
|
|
@@ -3028,7 +3028,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3028
3028
|
millis: 0
|
|
3029
3029
|
});
|
|
3030
3030
|
} catch (error) {
|
|
3031
|
-
|
|
3031
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
|
|
3032
3032
|
`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)))}`
|
|
3033
3033
|
);
|
|
3034
3034
|
}
|
|
@@ -3052,7 +3052,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3052
3052
|
const { pii, ...rest } = event;
|
|
3053
3053
|
if (pii == null) {
|
|
3054
3054
|
const shredded = { ...data };
|
|
3055
|
-
for (const f of fields) shredded[f] =
|
|
3055
|
+
for (const f of fields) shredded[f] = _chunk3CQWJ4UAcjs.SHREDDED;
|
|
3056
3056
|
return { ...rest, data: shredded };
|
|
3057
3057
|
}
|
|
3058
3058
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3063,7 +3063,7 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3063
3063
|
};
|
|
3064
3064
|
}
|
|
3065
3065
|
const redacted = { ...data };
|
|
3066
|
-
for (const f of fields) redacted[f] =
|
|
3066
|
+
for (const f of fields) redacted[f] = _chunk3CQWJ4UAcjs.REDACTED;
|
|
3067
3067
|
return { ...rest, data: redacted };
|
|
3068
3068
|
}
|
|
3069
3069
|
var IDENTITY_GATE = (event) => event;
|
|
@@ -3365,7 +3365,7 @@ var Act = (_class7 = class {
|
|
|
3365
3365
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3366
3366
|
|
|
3367
3367
|
|
|
3368
|
-
__init27() {this._logger =
|
|
3368
|
+
__init27() {this._logger = _chunkS2BEPQ5Zcjs.log.call(void 0, )}
|
|
3369
3369
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3370
3370
|
|
|
3371
3371
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3387,10 +3387,10 @@ var Act = (_class7 = class {
|
|
|
3387
3387
|
this._lanes = lanes;
|
|
3388
3388
|
this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
|
|
3389
3389
|
validate_only_lanes(options.onlyLanes, this._declared_lanes);
|
|
3390
|
-
if (options.scoped)
|
|
3391
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3390
|
+
if (options.scoped) _chunkS2BEPQ5Zcjs.check_store.call(void 0, options.scoped.store);
|
|
3391
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkS2BEPQ5Zcjs.default_scope.call(void 0, )));
|
|
3392
3392
|
const ports = this._ports;
|
|
3393
|
-
this._scoped =
|
|
3393
|
+
this._scoped = _chunkS2BEPQ5Zcjs.make_run_scoped.call(void 0, {
|
|
3394
3394
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3395
3395
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3396
3396
|
get store() {
|
|
@@ -3400,14 +3400,14 @@ var Act = (_class7 = class {
|
|
|
3400
3400
|
return ports.cache;
|
|
3401
3401
|
},
|
|
3402
3402
|
// Parsed per build, so a bad window throws on every build.
|
|
3403
|
-
autoclose_window:
|
|
3403
|
+
autoclose_window: _chunkS2BEPQ5Zcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
|
|
3404
3404
|
});
|
|
3405
3405
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3406
3406
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3407
3407
|
this._cd = build_drain(this._logger);
|
|
3408
3408
|
const handle = build_handle({
|
|
3409
3409
|
logger: this._logger,
|
|
3410
|
-
reaction_scope:
|
|
3410
|
+
reaction_scope: _chunkS2BEPQ5Zcjs.make_reaction_scope.call(void 0, {
|
|
3411
3411
|
do: this.do.bind(this),
|
|
3412
3412
|
load: this.load.bind(this),
|
|
3413
3413
|
query: this.query.bind(this),
|
|
@@ -3437,12 +3437,12 @@ var Act = (_class7 = class {
|
|
|
3437
3437
|
this._ports.store,
|
|
3438
3438
|
options.listen !== false
|
|
3439
3439
|
);
|
|
3440
|
-
|
|
3440
|
+
_chunkS2BEPQ5Zcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3441
3441
|
}
|
|
3442
3442
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3443
3443
|
_build_breaker(options) {
|
|
3444
3444
|
return new CircuitBreaker(
|
|
3445
|
-
|
|
3445
|
+
_chunkS2BEPQ5Zcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
|
|
3446
3446
|
{
|
|
3447
3447
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3448
3448
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3476,7 +3476,7 @@ var Act = (_class7 = class {
|
|
|
3476
3476
|
try {
|
|
3477
3477
|
await this._run_close(targets);
|
|
3478
3478
|
} catch (error) {
|
|
3479
|
-
if (error instanceof
|
|
3479
|
+
if (error instanceof _chunk3CQWJ4UAcjs.StoreError) throw error;
|
|
3480
3480
|
this._logger.error(
|
|
3481
3481
|
error,
|
|
3482
3482
|
`Reaction-requested close of ${targets.map((t) => `"${t.stream}"`).join(", ")} failed and was not retried; close it with app.close(...) once the cause is fixed.`
|
|
@@ -3510,7 +3510,7 @@ var Act = (_class7 = class {
|
|
|
3510
3510
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3511
3511
|
_build_audit_deps() {
|
|
3512
3512
|
return {
|
|
3513
|
-
store:
|
|
3513
|
+
store: _chunkS2BEPQ5Zcjs.store,
|
|
3514
3514
|
event_to_state: this._event_to_state,
|
|
3515
3515
|
// Declared lanes, not this process's controllers: a lane another
|
|
3516
3516
|
// worker drains is not `unknown-lane`.
|
|
@@ -3523,7 +3523,7 @@ var Act = (_class7 = class {
|
|
|
3523
3523
|
registry: this.registry,
|
|
3524
3524
|
static_targets: classification.static_targets,
|
|
3525
3525
|
cd: this._cd,
|
|
3526
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3526
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunk3CQWJ4UAcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3527
3527
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3528
3528
|
// still a valid destination.
|
|
3529
3529
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3539,7 +3539,7 @@ var Act = (_class7 = class {
|
|
|
3539
3539
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3540
3540
|
async _seed_persisted_defers() {
|
|
3541
3541
|
const now = Date.now();
|
|
3542
|
-
await walk_streams(
|
|
3542
|
+
await walk_streams(_chunkS2BEPQ5Zcjs.store.call(void 0, ), (pos) => {
|
|
3543
3543
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3544
3544
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3545
3545
|
_optionalChain([controller, 'optionalAccess', _156 => _156.seed_defer, 'call', _157 => _157(pos.stream, pos.deferred_at)]);
|
|
@@ -3555,7 +3555,7 @@ var Act = (_class7 = class {
|
|
|
3555
3555
|
on_settled: (drain) => this.emit("settled", drain),
|
|
3556
3556
|
breaker: this._breaker
|
|
3557
3557
|
},
|
|
3558
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3558
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunk3CQWJ4UAcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3559
3559
|
);
|
|
3560
3560
|
}
|
|
3561
3561
|
|
|
@@ -3575,7 +3575,7 @@ var Act = (_class7 = class {
|
|
|
3575
3575
|
*/
|
|
3576
3576
|
shutdown(options) {
|
|
3577
3577
|
if (!this._shutdown_promise) {
|
|
3578
|
-
|
|
3578
|
+
_chunkS2BEPQ5Zcjs.resolveShutdownConfig.call(void 0, options);
|
|
3579
3579
|
this._shutdown_promise = (async () => {
|
|
3580
3580
|
this.stop_correlations();
|
|
3581
3581
|
this._settle.stop(true);
|
|
@@ -3593,10 +3593,10 @@ var Act = (_class7 = class {
|
|
|
3593
3593
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3594
3594
|
// default for none or 0, and for a running settle), capped.
|
|
3595
3595
|
_derive_grace_ms(running, settling) {
|
|
3596
|
-
let max = settling ?
|
|
3596
|
+
let max = settling ? _chunkS2BEPQ5Zcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3597
3597
|
for (const c of running)
|
|
3598
|
-
max = Math.max(max, c.lease_millis ||
|
|
3599
|
-
return Math.min(max,
|
|
3598
|
+
max = Math.max(max, c.lease_millis || _chunkS2BEPQ5Zcjs.DEFAULT_LEASE_MILLIS);
|
|
3599
|
+
return Math.min(max, _chunkS2BEPQ5Zcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3600
3600
|
}
|
|
3601
3601
|
async _await_inflight(grace_ms) {
|
|
3602
3602
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3680,7 +3680,7 @@ var Act = (_class7 = class {
|
|
|
3680
3680
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3681
3681
|
*/
|
|
3682
3682
|
async do(action2, target, payload, options) {
|
|
3683
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _159 => _159.reactingTo]), () => (
|
|
3683
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _159 => _159.reactingTo]), () => ( _chunkS2BEPQ5Zcjs.current_reacting.call(void 0, )));
|
|
3684
3684
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _160 => _160.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3685
3685
|
return this._scoped(async () => {
|
|
3686
3686
|
const snapshots = await this._es.action(
|
|
@@ -3755,7 +3755,7 @@ var Act = (_class7 = class {
|
|
|
3755
3755
|
return this._scoped(async () => {
|
|
3756
3756
|
let first;
|
|
3757
3757
|
let last;
|
|
3758
|
-
const count = await
|
|
3758
|
+
const count = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query((e) => {
|
|
3759
3759
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3760
3760
|
if (!first) first = gated;
|
|
3761
3761
|
last = gated;
|
|
@@ -3785,7 +3785,7 @@ var Act = (_class7 = class {
|
|
|
3785
3785
|
async query_array(query) {
|
|
3786
3786
|
return this._scoped(async () => {
|
|
3787
3787
|
const events = [];
|
|
3788
|
-
await
|
|
3788
|
+
await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query((e) => {
|
|
3789
3789
|
events.push(this.registry.query_gate(e.name)(e));
|
|
3790
3790
|
}, query);
|
|
3791
3791
|
return events;
|
|
@@ -3805,14 +3805,14 @@ var Act = (_class7 = class {
|
|
|
3805
3805
|
*/
|
|
3806
3806
|
async forget(stream) {
|
|
3807
3807
|
return this._scoped(async () => {
|
|
3808
|
-
const s =
|
|
3808
|
+
const s = _chunkS2BEPQ5Zcjs.store.call(void 0, );
|
|
3809
3809
|
if (!s.forget_pii) {
|
|
3810
3810
|
throw new Error(
|
|
3811
3811
|
`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).`
|
|
3812
3812
|
);
|
|
3813
3813
|
}
|
|
3814
3814
|
const eventCount = await s.forget_pii(stream);
|
|
3815
|
-
await
|
|
3815
|
+
await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(stream);
|
|
3816
3816
|
if (eventCount > 0) {
|
|
3817
3817
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3818
3818
|
}
|
|
@@ -3846,7 +3846,7 @@ var Act = (_class7 = class {
|
|
|
3846
3846
|
* @see {@link correlate} for dynamic stream discovery
|
|
3847
3847
|
*/
|
|
3848
3848
|
async drain(options = {}) {
|
|
3849
|
-
|
|
3849
|
+
_chunkS2BEPQ5Zcjs.resolveDrainConfig.call(void 0, options);
|
|
3850
3850
|
if (!this._drain)
|
|
3851
3851
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3852
3852
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4026,7 +4026,7 @@ var Act = (_class7 = class {
|
|
|
4026
4026
|
*/
|
|
4027
4027
|
async reset(input) {
|
|
4028
4028
|
return this._scoped(async () => {
|
|
4029
|
-
const count = await
|
|
4029
|
+
const count = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).reset(input);
|
|
4030
4030
|
for (const handler of this._batch_handlers.values())
|
|
4031
4031
|
_optionalChain([handler, 'access', _167 => _167[FOLD_RESET], 'optionalCall', _168 => _168()]);
|
|
4032
4032
|
if (count > 0) {
|
|
@@ -4062,7 +4062,7 @@ var Act = (_class7 = class {
|
|
|
4062
4062
|
*/
|
|
4063
4063
|
async unblock(input) {
|
|
4064
4064
|
return this._scoped(async () => {
|
|
4065
|
-
const count = await
|
|
4065
|
+
const count = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).unblock(input);
|
|
4066
4066
|
if (count > 0) {
|
|
4067
4067
|
this._wake();
|
|
4068
4068
|
}
|
|
@@ -4117,7 +4117,7 @@ var Act = (_class7 = class {
|
|
|
4117
4117
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4118
4118
|
}
|
|
4119
4119
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4120
|
-
const s =
|
|
4120
|
+
const s = _chunkS2BEPQ5Zcjs.store.call(void 0, );
|
|
4121
4121
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4122
4122
|
return s;
|
|
4123
4123
|
})()));
|
|
@@ -4163,7 +4163,7 @@ var Act = (_class7 = class {
|
|
|
4163
4163
|
async blocked_streams(options) {
|
|
4164
4164
|
return this._scoped(async () => {
|
|
4165
4165
|
const positions = [];
|
|
4166
|
-
await
|
|
4166
|
+
await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_streams(
|
|
4167
4167
|
(p) => {
|
|
4168
4168
|
positions.push(p);
|
|
4169
4169
|
},
|
|
@@ -4215,7 +4215,7 @@ var Act = (_class7 = class {
|
|
|
4215
4215
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4216
4216
|
*/
|
|
4217
4217
|
async prioritize(filter, priority) {
|
|
4218
|
-
return this._scoped(() =>
|
|
4218
|
+
return this._scoped(() => _chunkS2BEPQ5Zcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4219
4219
|
}
|
|
4220
4220
|
// Shared by `close()` and reaction-requested closes.
|
|
4221
4221
|
async _run_close(targets) {
|
|
@@ -4295,19 +4295,18 @@ var Act = (_class7 = class {
|
|
|
4295
4295
|
* @see {@link correlate} for manual correlation
|
|
4296
4296
|
*/
|
|
4297
4297
|
settle(options) {
|
|
4298
|
-
|
|
4298
|
+
_chunkS2BEPQ5Zcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
4299
4299
|
this._schedule(options);
|
|
4300
4300
|
}
|
|
4301
4301
|
}, _class7);
|
|
4302
4302
|
|
|
4303
4303
|
// src/builders/merge.ts
|
|
4304
4304
|
|
|
4305
|
-
function base_type_name(
|
|
4306
|
-
let
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
}
|
|
4310
|
-
return t.constructor.name;
|
|
4305
|
+
function base_type_name(schema) {
|
|
4306
|
+
let def = _chunk3CQWJ4UAcjs.def_of.call(void 0, schema);
|
|
4307
|
+
for (let inner = _chunk3CQWJ4UAcjs.inner_of.call(void 0, def); inner; inner = _chunk3CQWJ4UAcjs.inner_of.call(void 0, def))
|
|
4308
|
+
def = _chunk3CQWJ4UAcjs.def_of.call(void 0, inner);
|
|
4309
|
+
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4311
4310
|
}
|
|
4312
4311
|
function merge_schemas(existing, incoming, state_name) {
|
|
4313
4312
|
if (existing === incoming) return existing;
|
|
@@ -4493,9 +4492,9 @@ var _this_ = ({ stream }) => ({
|
|
|
4493
4492
|
|
|
4494
4493
|
// src/builders/builder-utils.ts
|
|
4495
4494
|
function register_lane(config2, lanes) {
|
|
4496
|
-
|
|
4497
|
-
if (config2.name ===
|
|
4498
|
-
throw new Error(`Lane "${
|
|
4495
|
+
_chunkS2BEPQ5Zcjs.resolveLaneConfig.call(void 0, config2);
|
|
4496
|
+
if (config2.name === _chunk3CQWJ4UAcjs.DEFAULT_LANE)
|
|
4497
|
+
throw new Error(`Lane "${_chunk3CQWJ4UAcjs.DEFAULT_LANE}" is reserved`);
|
|
4499
4498
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4500
4499
|
if (!existing) return void lanes.push(config2);
|
|
4501
4500
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4537,9 +4536,9 @@ function reaction_on(event, events, builder) {
|
|
|
4537
4536
|
// Validate the whole bag at the declaration site so a bad
|
|
4538
4537
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4539
4538
|
// not a NaN gate on the first retry.
|
|
4540
|
-
options:
|
|
4541
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _171 => _171.blockOnError]), () => (
|
|
4542
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.maxRetries]), () => (
|
|
4539
|
+
options: _chunkS2BEPQ5Zcjs.resolveReactionConfig.call(void 0, {
|
|
4540
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _171 => _171.blockOnError]), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4541
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.maxRetries]), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES)),
|
|
4543
4542
|
backoff: _optionalChain([options, 'optionalAccess', _173 => _173.backoff])
|
|
4544
4543
|
})
|
|
4545
4544
|
};
|
|
@@ -4560,7 +4559,7 @@ function reaction_on(event, events, builder) {
|
|
|
4560
4559
|
// src/internal/date-reviver.ts
|
|
4561
4560
|
|
|
4562
4561
|
function variant_schema(schema, walk) {
|
|
4563
|
-
const shape = _optionalChain([
|
|
4562
|
+
const shape = _optionalChain([_chunk3CQWJ4UAcjs.def_of.call(void 0, schema), 'optionalAccess', _174 => _174.shape]);
|
|
4564
4563
|
if (!shape) {
|
|
4565
4564
|
const dates = walk(schema);
|
|
4566
4565
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -4597,7 +4596,7 @@ function date_reviver_schema(schema) {
|
|
|
4597
4596
|
return first && recursive ? pass(true) : first;
|
|
4598
4597
|
}
|
|
4599
4598
|
function build(schema, walk) {
|
|
4600
|
-
const def =
|
|
4599
|
+
const def = _chunk3CQWJ4UAcjs.def_of.call(void 0, schema);
|
|
4601
4600
|
if (!def) return void 0;
|
|
4602
4601
|
const inner = () => walk(def.innerType);
|
|
4603
4602
|
switch (def.type) {
|
|
@@ -4643,13 +4642,13 @@ function build(schema, walk) {
|
|
|
4643
4642
|
return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
|
|
4644
4643
|
}
|
|
4645
4644
|
default:
|
|
4646
|
-
return
|
|
4645
|
+
return _chunk3CQWJ4UAcjs.inner_of.call(void 0, def) ? inner() : void 0;
|
|
4647
4646
|
}
|
|
4648
4647
|
}
|
|
4649
4648
|
|
|
4650
4649
|
// src/builders/event-builder.ts
|
|
4651
4650
|
function event_tags(schema) {
|
|
4652
|
-
const pii =
|
|
4651
|
+
const pii = _chunk3CQWJ4UAcjs.pii_schemas.call(void 0, schema);
|
|
4653
4652
|
const pii_dates = {};
|
|
4654
4653
|
for (const [key, field] of Object.entries(pii)) {
|
|
4655
4654
|
const dates = date_reviver_schema(field);
|
|
@@ -4687,7 +4686,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4687
4686
|
});
|
|
4688
4687
|
}
|
|
4689
4688
|
function build_events(registry, states, lanes, owners) {
|
|
4690
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4689
|
+
const declared = /* @__PURE__ */ new Set([_chunk3CQWJ4UAcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4691
4690
|
const lane_errors = [];
|
|
4692
4691
|
const tags = /* @__PURE__ */ new Map();
|
|
4693
4692
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4762,7 +4761,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4762
4761
|
if (reader) readers.set(event_name, reader);
|
|
4763
4762
|
}
|
|
4764
4763
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4765
|
-
if (snap2) readers.set(
|
|
4764
|
+
if (snap2) readers.set(_chunk3CQWJ4UAcjs.SNAP_EVENT, snap2);
|
|
4766
4765
|
if (readers.size === 0) continue;
|
|
4767
4766
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4768
4767
|
}
|
|
@@ -4770,7 +4769,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4770
4769
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4771
4770
|
}
|
|
4772
4771
|
function reads_as_string(schema) {
|
|
4773
|
-
const type = _optionalChain([
|
|
4772
|
+
const type = _optionalChain([_chunk3CQWJ4UAcjs.def_of.call(void 0, _chunk3CQWJ4UAcjs.output_of.call(void 0, schema)), 'optionalAccess', _178 => _178.type]);
|
|
4774
4773
|
return type === "string" || type === "transform";
|
|
4775
4774
|
}
|
|
4776
4775
|
|
|
@@ -4882,7 +4881,7 @@ function act() {
|
|
|
4882
4881
|
const list = deprecation_summary.map(
|
|
4883
4882
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4884
4883
|
).join(", ");
|
|
4885
|
-
|
|
4884
|
+
_chunkS2BEPQ5Zcjs.log.call(void 0, ).info(
|
|
4886
4885
|
`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.`
|
|
4887
4886
|
);
|
|
4888
4887
|
}
|
|
@@ -4924,7 +4923,7 @@ function act() {
|
|
|
4924
4923
|
return reaction_on(event, registry.events, builder);
|
|
4925
4924
|
},
|
|
4926
4925
|
build: (options) => {
|
|
4927
|
-
|
|
4926
|
+
_chunkS2BEPQ5Zcjs.resolveActConfig.call(void 0, options);
|
|
4928
4927
|
if (!_built) {
|
|
4929
4928
|
for (const proj of pending_projections) add_projection(proj);
|
|
4930
4929
|
for (const proj of fold_projections) {
|
|
@@ -4964,7 +4963,7 @@ function act() {
|
|
|
4964
4963
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
4965
4964
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
4966
4965
|
finalize_deprecations();
|
|
4967
|
-
if (built.advisory)
|
|
4966
|
+
if (built.advisory) _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(built.advisory);
|
|
4968
4967
|
for (const [name, state2] of states) {
|
|
4969
4968
|
if (!state2.loads) continue;
|
|
4970
4969
|
const resolved = {};
|
|
@@ -5008,7 +5007,7 @@ function act() {
|
|
|
5008
5007
|
synthesize_autoclose_reactions(
|
|
5009
5008
|
registry,
|
|
5010
5009
|
states,
|
|
5011
|
-
|
|
5010
|
+
_chunkS2BEPQ5Zcjs.current_autoclose_window
|
|
5012
5011
|
);
|
|
5013
5012
|
Object.freeze(registry.actions);
|
|
5014
5013
|
Object.freeze(registry.events);
|
|
@@ -5056,8 +5055,8 @@ function _projection(target) {
|
|
|
5056
5055
|
handler,
|
|
5057
5056
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5058
5057
|
options: {
|
|
5059
|
-
blockOnError:
|
|
5060
|
-
maxRetries:
|
|
5058
|
+
blockOnError: _chunkS2BEPQ5Zcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5059
|
+
maxRetries: _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES
|
|
5061
5060
|
}
|
|
5062
5061
|
}),
|
|
5063
5062
|
widened
|
|
@@ -5098,7 +5097,7 @@ function _projection(target) {
|
|
|
5098
5097
|
throw new Error(
|
|
5099
5098
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5100
5099
|
);
|
|
5101
|
-
const config2 =
|
|
5100
|
+
const config2 = _chunkS2BEPQ5Zcjs.resolveFoldConfig.call(void 0, options);
|
|
5102
5101
|
const fold_events = {};
|
|
5103
5102
|
for (const partial of partials)
|
|
5104
5103
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5116,8 +5115,8 @@ function _projection(target) {
|
|
|
5116
5115
|
handler: noop,
|
|
5117
5116
|
resolver: { target },
|
|
5118
5117
|
options: {
|
|
5119
|
-
blockOnError:
|
|
5120
|
-
maxRetries:
|
|
5118
|
+
blockOnError: _chunkS2BEPQ5Zcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5119
|
+
maxRetries: _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES
|
|
5121
5120
|
}
|
|
5122
5121
|
}
|
|
5123
5122
|
]
|
|
@@ -5233,7 +5232,7 @@ function action_builder(state2) {
|
|
|
5233
5232
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5234
5233
|
internal.actions[action2] = schema;
|
|
5235
5234
|
if (options) {
|
|
5236
|
-
|
|
5235
|
+
_chunkS2BEPQ5Zcjs.resolveActionConfig.call(void 0, options);
|
|
5237
5236
|
internal.options ??= {};
|
|
5238
5237
|
internal.options[action2] = options;
|
|
5239
5238
|
}
|
|
@@ -5545,5 +5544,5 @@ function write_line(writer, line) {
|
|
|
5545
5544
|
|
|
5546
5545
|
|
|
5547
5546
|
|
|
5548
|
-
exports.Act = Act; exports.ActorSchema =
|
|
5547
|
+
exports.Act = Act; exports.ActorSchema = _chunk3CQWJ4UAcjs.ActorSchema; exports.CausationEventSchema = _chunk3CQWJ4UAcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunk3CQWJ4UAcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunk3CQWJ4UAcjs.ConcurrencyError; exports.ConsoleLogger = _chunkS2BEPQ5Zcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunk3CQWJ4UAcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunk3CQWJ4UAcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_QUERY_STREAMS_LIMIT = _chunkS2BEPQ5Zcjs.DEFAULT_QUERY_STREAMS_LIMIT; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunk3CQWJ4UAcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunk3CQWJ4UAcjs.DeferSignal; exports.Environments = _chunk3CQWJ4UAcjs.Environments; exports.Errors = _chunk3CQWJ4UAcjs.Errors; exports.EventMetaSchema = _chunk3CQWJ4UAcjs.EventMetaSchema; exports.ExitCodes = _chunk3CQWJ4UAcjs.ExitCodes; exports.InMemoryCache = _chunkS2BEPQ5Zcjs.InMemoryCache; exports.InMemoryStore = _chunkS2BEPQ5Zcjs.InMemoryStore; exports.LogLevels = _chunk3CQWJ4UAcjs.LogLevels; exports.NonRetryableError = _chunk3CQWJ4UAcjs.NonRetryableError; exports.PackageSchema = _chunkS2BEPQ5Zcjs.PackageSchema; exports.PreconditionError = _chunk3CQWJ4UAcjs.PreconditionError; exports.QuerySchema = _chunk3CQWJ4UAcjs.QuerySchema; exports.REDACTED = _chunk3CQWJ4UAcjs.REDACTED; exports.SHREDDED = _chunk3CQWJ4UAcjs.SHREDDED; exports.SNAP_EVENT = _chunk3CQWJ4UAcjs.SNAP_EVENT; exports.StoreError = _chunk3CQWJ4UAcjs.StoreError; exports.StreamClosedError = _chunk3CQWJ4UAcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunk3CQWJ4UAcjs.TargetSchema; exports.ValidationError = _chunk3CQWJ4UAcjs.ValidationError; exports.ZodEmpty = _chunk3CQWJ4UAcjs.ZodEmpty; exports.act = act; exports.cache = _chunkS2BEPQ5Zcjs.cache; exports.check_appends = _chunkS2BEPQ5Zcjs.check_appends; exports.config = _chunkS2BEPQ5Zcjs.config; exports.dateReviver = _chunkS2BEPQ5Zcjs.dateReviver; exports.default_scope = _chunkS2BEPQ5Zcjs.default_scope; exports.dispose = _chunkS2BEPQ5Zcjs.dispose; exports.disposeAndExit = _chunkS2BEPQ5Zcjs.disposeAndExit; exports.extend = _chunkS2BEPQ5Zcjs.extend; exports.fair_slots = _chunkS2BEPQ5Zcjs.fair_slots; exports.is_literal_source = _chunkS2BEPQ5Zcjs.is_literal_source; exports.log = _chunkS2BEPQ5Zcjs.log; exports.pii_fields = _chunk3CQWJ4UAcjs.pii_fields; exports.port = _chunkS2BEPQ5Zcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkS2BEPQ5Zcjs.resolveAutocloseConfig2; exports.sensitive = _chunk3CQWJ4UAcjs.sensitive; exports.sleep = _chunkS2BEPQ5Zcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkS2BEPQ5Zcjs.store; exports.validate = _chunkS2BEPQ5Zcjs.validate;
|
|
5549
5548
|
//# sourceMappingURL=index.cjs.map
|