@rotorsoft/act 2.1.13 → 2.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/event-builder.d.ts +7 -3
- package/dist/@types/builders/event-builder.d.ts.map +1 -1
- package/dist/@types/builders/merge.d.ts.map +1 -1
- package/dist/@types/deprecated.d.ts +10 -0
- package/dist/@types/deprecated.d.ts.map +1 -1
- package/dist/@types/index.d.ts +2 -3
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/@types/internal/audit.d.ts +2 -0
- package/dist/@types/internal/audit.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +9 -0
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/pii.d.ts +1 -1
- package/dist/@types/{sensitive.d.ts → internal/sensitive.d.ts} +0 -24
- package/dist/@types/internal/sensitive.d.ts.map +1 -0
- package/dist/@types/types/action-rules.d.ts +177 -0
- package/dist/@types/types/action-rules.d.ts.map +1 -0
- package/dist/@types/types/builders.d.ts +15 -311
- package/dist/@types/types/builders.d.ts.map +1 -1
- package/dist/@types/types/projection.d.ts +135 -0
- package/dist/@types/types/projection.d.ts.map +1 -0
- package/dist/@types/types/registry.d.ts +7 -4
- package/dist/@types/types/registry.d.ts.map +1 -1
- package/dist/@types/types/schemas.d.ts +0 -1
- package/dist/@types/types/schemas.d.ts.map +1 -1
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.js +2 -2
- package/dist/{chunk-PDMLWC77.cjs → chunk-DCWPJFXR.cjs} +11 -11
- package/dist/{chunk-PDMLWC77.cjs.map → chunk-DCWPJFXR.cjs.map} +1 -1
- package/dist/{chunk-MWLATJDX.js → chunk-EIGZVFT7.js} +2 -2
- package/dist/{chunk-FYI7O7W6.js → chunk-GDPBPAML.js} +5 -93
- package/dist/chunk-GDPBPAML.js.map +1 -0
- package/dist/{chunk-R5PT4AYJ.js → chunk-SCH4GLWM.js} +11 -3
- package/dist/chunk-SCH4GLWM.js.map +1 -0
- package/dist/{chunk-QSXWCJ2U.cjs → chunk-UEGKXCSQ.cjs} +40 -128
- package/dist/chunk-UEGKXCSQ.cjs.map +1 -0
- package/dist/{chunk-OW67FBYO.cjs → chunk-WDIBO6AW.cjs} +62 -54
- package/dist/chunk-WDIBO6AW.cjs.map +1 -0
- package/dist/index.cjs +598 -507
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +110 -19
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +9 -9
- package/dist/test/index.js +3 -3
- package/dist/types/index.cjs +2 -6
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +3 -7
- package/package.json +1 -1
- package/dist/@types/sensitive.d.ts.map +0 -1
- package/dist/chunk-FYI7O7W6.js.map +0 -1
- package/dist/chunk-OW67FBYO.cjs.map +0 -1
- package/dist/chunk-QSXWCJ2U.cjs.map +0 -1
- package/dist/chunk-R5PT4AYJ.js.map +0 -1
- /package/dist/{chunk-MWLATJDX.js.map → chunk-EIGZVFT7.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkWDIBO6AWcjs = require('./chunk-WDIBO6AW.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ var _chunkOW67FBYOcjs = require('./chunk-OW67FBYO.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunkDCWPJFXRcjs = require('./chunk-DCWPJFXR.cjs');
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -66,32 +66,26 @@ var _chunkPDMLWC77cjs = require('./chunk-PDMLWC77.cjs');
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var _chunkQSXWCJ2Ucjs = require('./chunk-QSXWCJ2U.cjs');
|
|
69
|
+
var _chunkUEGKXCSQcjs = require('./chunk-UEGKXCSQ.cjs');
|
|
76
70
|
|
|
77
71
|
// src/signals.ts
|
|
78
72
|
process.once("SIGINT", async (arg) => {
|
|
79
|
-
|
|
80
|
-
await
|
|
73
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
74
|
+
await _chunkWDIBO6AWcjs.disposeAndExit.call(void 0, "EXIT");
|
|
81
75
|
});
|
|
82
76
|
process.once("SIGTERM", async (arg) => {
|
|
83
|
-
|
|
84
|
-
await
|
|
77
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
78
|
+
await _chunkWDIBO6AWcjs.disposeAndExit.call(void 0, "EXIT");
|
|
85
79
|
});
|
|
86
80
|
process.once("uncaughtException", async (arg) => {
|
|
87
81
|
process.exitCode = 1;
|
|
88
|
-
|
|
89
|
-
await
|
|
82
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
83
|
+
await _chunkWDIBO6AWcjs.disposeAndExit.call(void 0, "ERROR");
|
|
90
84
|
});
|
|
91
85
|
process.once("unhandledRejection", async (arg) => {
|
|
92
86
|
process.exitCode = 1;
|
|
93
|
-
|
|
94
|
-
await
|
|
87
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
88
|
+
await _chunkWDIBO6AWcjs.disposeAndExit.call(void 0, "ERROR");
|
|
95
89
|
});
|
|
96
90
|
|
|
97
91
|
// src/act.ts
|
|
@@ -107,7 +101,7 @@ function parse(name) {
|
|
|
107
101
|
}
|
|
108
102
|
return { base: name, version: 1 };
|
|
109
103
|
}
|
|
110
|
-
|
|
104
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, parse, "parse");
|
|
111
105
|
function deprecated_event_names(names) {
|
|
112
106
|
const groups = /* @__PURE__ */ new Map();
|
|
113
107
|
for (const name of names) {
|
|
@@ -133,7 +127,7 @@ function deprecated_event_names(names) {
|
|
|
133
127
|
}
|
|
134
128
|
return deprecated;
|
|
135
129
|
}
|
|
136
|
-
|
|
130
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, deprecated_event_names, "deprecated_event_names");
|
|
137
131
|
function current_version_of(deprecated_name, all_names) {
|
|
138
132
|
const target = parse(deprecated_name);
|
|
139
133
|
let highest;
|
|
@@ -144,7 +138,7 @@ function current_version_of(deprecated_name, all_names) {
|
|
|
144
138
|
}
|
|
145
139
|
return highest && highest.version > target.version ? highest.name : void 0;
|
|
146
140
|
}
|
|
147
|
-
|
|
141
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, current_version_of, "current_version_of");
|
|
148
142
|
|
|
149
143
|
// src/internal/walk-streams.ts
|
|
150
144
|
var DEFAULT_STREAM_PAGE = 500;
|
|
@@ -166,7 +160,7 @@ async function walk_streams(store2, callback, query) {
|
|
|
166
160
|
after = last;
|
|
167
161
|
}
|
|
168
162
|
}
|
|
169
|
-
|
|
163
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, walk_streams, "walk_streams");
|
|
170
164
|
|
|
171
165
|
// src/internal/audit.ts
|
|
172
166
|
var DEFAULTS = {
|
|
@@ -203,7 +197,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
203
197
|
if (need_stats) {
|
|
204
198
|
const stats = await deps.store().query_stats(
|
|
205
199
|
{},
|
|
206
|
-
{ count: true, names: true, exclude: [
|
|
200
|
+
{ count: true, names: true, exclude: [_chunkUEGKXCSQcjs.SNAP_EVENT] }
|
|
207
201
|
);
|
|
208
202
|
for (const [stream, s] of stats) {
|
|
209
203
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -231,7 +225,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
231
225
|
for (const f of p.drain()) yield f;
|
|
232
226
|
}
|
|
233
227
|
}
|
|
234
|
-
|
|
228
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, audit, "audit");
|
|
235
229
|
async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
|
|
236
230
|
let cursor = _optionalChain([query, 'optionalAccess', _14 => _14.after]);
|
|
237
231
|
let remaining = _optionalChain([query, 'optionalAccess', _15 => _15.limit]);
|
|
@@ -267,8 +261,8 @@ async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
|
|
|
267
261
|
}
|
|
268
262
|
}
|
|
269
263
|
}
|
|
270
|
-
|
|
271
|
-
var make_schema_pass = /* @__PURE__ */
|
|
264
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, scan_events_resiliently, "scan_events_resiliently");
|
|
265
|
+
var make_schema_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps) => {
|
|
272
266
|
const findings = [];
|
|
273
267
|
return {
|
|
274
268
|
category: "schema",
|
|
@@ -287,7 +281,7 @@ var make_schema_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (de
|
|
|
287
281
|
return;
|
|
288
282
|
}
|
|
289
283
|
const schema = state2.events[name];
|
|
290
|
-
const sensitive2 =
|
|
284
|
+
const sensitive2 = deps.sensitive_fields(name);
|
|
291
285
|
let parse_schema = schema;
|
|
292
286
|
if (sensitive2.length > 0) {
|
|
293
287
|
const omitter = schema.omit;
|
|
@@ -311,10 +305,10 @@ var make_schema_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (de
|
|
|
311
305
|
});
|
|
312
306
|
}
|
|
313
307
|
},
|
|
314
|
-
drain: /* @__PURE__ */
|
|
308
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
315
309
|
};
|
|
316
310
|
}, "make_schema_pass");
|
|
317
|
-
var classify_deprecated_by_state = /* @__PURE__ */
|
|
311
|
+
var classify_deprecated_by_state = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps) => {
|
|
318
312
|
const names_by_state = /* @__PURE__ */ new Map();
|
|
319
313
|
for (const [name, state2] of deps.event_to_state) {
|
|
320
314
|
let set = names_by_state.get(state2);
|
|
@@ -332,7 +326,7 @@ var classify_deprecated_by_state = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call
|
|
|
332
326
|
}
|
|
333
327
|
return deprecated_to_current;
|
|
334
328
|
}, "classify_deprecated_by_state");
|
|
335
|
-
var make_deprecated_load_pass = /* @__PURE__ */
|
|
329
|
+
var make_deprecated_load_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps, options) => {
|
|
336
330
|
const share_min = _nullishCoalesce(_optionalChain([options, 'access', _17 => _17.thresholds, 'optionalAccess', _18 => _18.deprecated_min]), () => ( DEFAULTS.deprecated_min));
|
|
337
331
|
const totals = /* @__PURE__ */ new Map();
|
|
338
332
|
const per_stream = /* @__PURE__ */ new Map();
|
|
@@ -372,7 +366,7 @@ var make_deprecated_load_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(vo
|
|
|
372
366
|
}
|
|
373
367
|
};
|
|
374
368
|
}, "make_deprecated_load_pass");
|
|
375
|
-
var make_close_candidate_pass = /* @__PURE__ */
|
|
369
|
+
var make_close_candidate_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps, options) => {
|
|
376
370
|
const idle_days = _nullishCoalesce(_optionalChain([options, 'access', _19 => _19.thresholds, 'optionalAccess', _20 => _20.idle_days]), () => ( DEFAULTS.idle_days));
|
|
377
371
|
const terminal_events = new Set(_nullishCoalesce(_optionalChain([options, 'access', _21 => _21.thresholds, 'optionalAccess', _22 => _22.terminal_events]), () => ( [])));
|
|
378
372
|
const idle_cutoff = Date.now() - idle_days * 24 * 60 * 60 * 1e3;
|
|
@@ -395,10 +389,10 @@ var make_close_candidate_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(vo
|
|
|
395
389
|
restart_supported: restart_is_supported(deps, head_name)
|
|
396
390
|
});
|
|
397
391
|
},
|
|
398
|
-
drain: /* @__PURE__ */
|
|
392
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
399
393
|
};
|
|
400
394
|
}, "make_close_candidate_pass");
|
|
401
|
-
var make_restart_candidate_pass = /* @__PURE__ */
|
|
395
|
+
var make_restart_candidate_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps, options) => {
|
|
402
396
|
const threshold = _nullishCoalesce(_optionalChain([options, 'access', _23 => _23.thresholds, 'optionalAccess', _24 => _24.restart_min]), () => ( DEFAULTS.restart_min));
|
|
403
397
|
const candidates = [];
|
|
404
398
|
const findings = [];
|
|
@@ -421,7 +415,7 @@ var make_restart_candidate_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(
|
|
|
421
415
|
{
|
|
422
416
|
stream,
|
|
423
417
|
stream_exact: true,
|
|
424
|
-
names: [
|
|
418
|
+
names: [_chunkUEGKXCSQcjs.SNAP_EVENT],
|
|
425
419
|
with_snaps: true,
|
|
426
420
|
// From the start: on its own, `with_snaps` resumes at the latest.
|
|
427
421
|
after: -1
|
|
@@ -435,10 +429,10 @@ var make_restart_candidate_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(
|
|
|
435
429
|
});
|
|
436
430
|
}
|
|
437
431
|
},
|
|
438
|
-
drain: /* @__PURE__ */
|
|
432
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
439
433
|
};
|
|
440
434
|
}, "make_restart_candidate_pass");
|
|
441
|
-
var make_reaction_health_pass = /* @__PURE__ */
|
|
435
|
+
var make_reaction_health_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (_deps, options) => {
|
|
442
436
|
const near_block = _nullishCoalesce(_optionalChain([options, 'access', _25 => _25.thresholds, 'optionalAccess', _26 => _26.near_block]), () => ( DEFAULTS.near_block));
|
|
443
437
|
const stuck_minutes = _nullishCoalesce(_optionalChain([options, 'access', _27 => _27.thresholds, 'optionalAccess', _28 => _28.stuck_minutes]), () => ( DEFAULTS.stuck_minutes));
|
|
444
438
|
const stuck_cutoff = Date.now() - stuck_minutes * 60 * 1e3;
|
|
@@ -479,10 +473,10 @@ var make_reaction_health_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(vo
|
|
|
479
473
|
});
|
|
480
474
|
}
|
|
481
475
|
},
|
|
482
|
-
drain: /* @__PURE__ */
|
|
476
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
483
477
|
};
|
|
484
478
|
}, "make_reaction_health_pass");
|
|
485
|
-
var make_snapshot_drift_pass = /* @__PURE__ */
|
|
479
|
+
var make_snapshot_drift_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps, options) => {
|
|
486
480
|
const drift_min = _nullishCoalesce(_optionalChain([options, 'access', _29 => _29.thresholds, 'optionalAccess', _30 => _30.drift_min]), () => ( DEFAULTS.drift_min));
|
|
487
481
|
const candidates = [];
|
|
488
482
|
const findings = [];
|
|
@@ -534,10 +528,10 @@ var make_snapshot_drift_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(voi
|
|
|
534
528
|
});
|
|
535
529
|
}
|
|
536
530
|
},
|
|
537
|
-
drain: /* @__PURE__ */
|
|
531
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
538
532
|
};
|
|
539
533
|
}, "make_snapshot_drift_pass");
|
|
540
|
-
var make_routing_health_pass = /* @__PURE__ */
|
|
534
|
+
var make_routing_health_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (deps) => {
|
|
541
535
|
const findings = [];
|
|
542
536
|
const seen_event_names = /* @__PURE__ */ new Set();
|
|
543
537
|
return {
|
|
@@ -569,10 +563,10 @@ var make_routing_health_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(voi
|
|
|
569
563
|
}
|
|
570
564
|
return Promise.resolve();
|
|
571
565
|
},
|
|
572
|
-
drain: /* @__PURE__ */
|
|
566
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
573
567
|
};
|
|
574
568
|
}, "make_routing_health_pass");
|
|
575
|
-
var make_correlation_gaps_pass = /* @__PURE__ */
|
|
569
|
+
var make_correlation_gaps_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => {
|
|
576
570
|
const seen_ids = /* @__PURE__ */ new Set();
|
|
577
571
|
const checks = [];
|
|
578
572
|
return {
|
|
@@ -581,7 +575,7 @@ var make_correlation_gaps_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(v
|
|
|
581
575
|
seen_ids.add(e.id);
|
|
582
576
|
const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
|
|
583
577
|
const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
|
|
584
|
-
if (parent_id !== void 0 && e.name !==
|
|
578
|
+
if (parent_id !== void 0 && e.name !== _chunkUEGKXCSQcjs.TOMBSTONE_EVENT) {
|
|
585
579
|
checks.push({ stream: e.stream, id: e.id, parent_id });
|
|
586
580
|
}
|
|
587
581
|
},
|
|
@@ -601,7 +595,7 @@ var make_correlation_gaps_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(v
|
|
|
601
595
|
}
|
|
602
596
|
};
|
|
603
597
|
}, "make_correlation_gaps_pass");
|
|
604
|
-
var make_clock_anomalies_pass = /* @__PURE__ */
|
|
598
|
+
var make_clock_anomalies_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => {
|
|
605
599
|
const findings = [];
|
|
606
600
|
const last_per_stream = /* @__PURE__ */ new Map();
|
|
607
601
|
return {
|
|
@@ -627,14 +621,14 @@ var make_clock_anomalies_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(vo
|
|
|
627
621
|
}
|
|
628
622
|
last_per_stream.set(e.stream, created);
|
|
629
623
|
},
|
|
630
|
-
drain: /* @__PURE__ */
|
|
624
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
631
625
|
};
|
|
632
626
|
}, "make_clock_anomalies_pass");
|
|
633
627
|
function restart_is_supported(deps, head_event_name) {
|
|
634
628
|
const state2 = deps.event_to_state.get(head_event_name);
|
|
635
629
|
return _optionalChain([state2, 'optionalAccess', _35 => _35.snap]) !== void 0;
|
|
636
630
|
}
|
|
637
|
-
|
|
631
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, restart_is_supported, "restart_is_supported");
|
|
638
632
|
function make_unreadable_events_pass() {
|
|
639
633
|
const findings = [];
|
|
640
634
|
return {
|
|
@@ -648,10 +642,10 @@ function make_unreadable_events_pass() {
|
|
|
648
642
|
error
|
|
649
643
|
});
|
|
650
644
|
},
|
|
651
|
-
drain: /* @__PURE__ */
|
|
645
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => findings, "drain")
|
|
652
646
|
};
|
|
653
647
|
}
|
|
654
|
-
|
|
648
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, make_unreadable_events_pass, "make_unreadable_events_pass");
|
|
655
649
|
var PASS_FACTORIES = {
|
|
656
650
|
schema: make_schema_pass,
|
|
657
651
|
"deprecated-load": make_deprecated_load_pass,
|
|
@@ -668,7 +662,7 @@ var PASS_FACTORIES = {
|
|
|
668
662
|
// src/internal/circuit-breaker.ts
|
|
669
663
|
var CircuitBreaker = (_class = class {
|
|
670
664
|
static {
|
|
671
|
-
|
|
665
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "CircuitBreaker");
|
|
672
666
|
}
|
|
673
667
|
__init() {this._failures = 0}
|
|
674
668
|
|
|
@@ -761,7 +755,7 @@ var CircuitBreaker = (_class = class {
|
|
|
761
755
|
|
|
762
756
|
// src/internal/classify.ts
|
|
763
757
|
var ALL_LANES = /* @__PURE__ */ Symbol("act/all-lanes");
|
|
764
|
-
var describe_source = /* @__PURE__ */
|
|
758
|
+
var describe_source = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (source) => source === void 0 ? "no source (every stream)" : `"${source}"`, "describe_source");
|
|
765
759
|
function classify_registry(registry, states) {
|
|
766
760
|
const statics = /* @__PURE__ */ new Map();
|
|
767
761
|
const target_lanes = /* @__PURE__ */ new Map();
|
|
@@ -812,43 +806,43 @@ function classify_registry(registry, states) {
|
|
|
812
806
|
event_to_lanes
|
|
813
807
|
};
|
|
814
808
|
}
|
|
815
|
-
|
|
809
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, classify_registry, "classify_registry");
|
|
816
810
|
|
|
817
811
|
// src/internal/autoclose-policy.ts
|
|
818
812
|
var DAY_MS = 864e5;
|
|
819
813
|
function days_after(date, days) {
|
|
820
814
|
return new Date(date.getTime() + days * DAY_MS);
|
|
821
815
|
}
|
|
822
|
-
|
|
816
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, days_after, "days_after");
|
|
823
817
|
function days_before_now(days) {
|
|
824
818
|
return new Date(Date.now() - days * DAY_MS);
|
|
825
819
|
}
|
|
826
|
-
|
|
820
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, days_before_now, "days_before_now");
|
|
827
821
|
function compile_after(after) {
|
|
828
822
|
return (_stream, head) => days_after(head.created, after.days) <= /* @__PURE__ */ new Date();
|
|
829
823
|
}
|
|
830
|
-
|
|
824
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, compile_after, "compile_after");
|
|
831
825
|
function compile_is(is) {
|
|
832
826
|
const set = new Set(typeof is === "string" ? [is] : is);
|
|
833
827
|
return (_stream, head) => set.has(head.name);
|
|
834
828
|
}
|
|
835
|
-
|
|
829
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, compile_is, "compile_is");
|
|
836
830
|
function compile_reaches(reaches) {
|
|
837
831
|
return (_stream, _head, count) => count >= reaches;
|
|
838
832
|
}
|
|
839
|
-
|
|
833
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, compile_reaches, "compile_reaches");
|
|
840
834
|
function policy_after_windows(options) {
|
|
841
|
-
const parsed =
|
|
835
|
+
const parsed = _chunkWDIBO6AWcjs.check.call(void 0, "autoclose_policy", options);
|
|
842
836
|
return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
|
|
843
837
|
}
|
|
844
|
-
|
|
838
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, policy_after_windows, "policy_after_windows");
|
|
845
839
|
function policy_keep_days(options) {
|
|
846
|
-
const parsed =
|
|
840
|
+
const parsed = _chunkWDIBO6AWcjs.check.call(void 0, "autoclose_policy", options);
|
|
847
841
|
return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
|
|
848
842
|
}
|
|
849
|
-
|
|
843
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, policy_keep_days, "policy_keep_days");
|
|
850
844
|
function compile_autoclose_policy(options) {
|
|
851
|
-
const parsed =
|
|
845
|
+
const parsed = _chunkWDIBO6AWcjs.check.call(void 0, "autoclose_policy", options);
|
|
852
846
|
const and_preds = [];
|
|
853
847
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
854
848
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -869,7 +863,7 @@ function compile_autoclose_policy(options) {
|
|
|
869
863
|
return false;
|
|
870
864
|
};
|
|
871
865
|
}
|
|
872
|
-
|
|
866
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, compile_autoclose_policy, "compile_autoclose_policy");
|
|
873
867
|
|
|
874
868
|
// src/internal/autoclose-window.ts
|
|
875
869
|
function hour_in_zone(now, timeZone) {
|
|
@@ -880,24 +874,24 @@ function hour_in_zone(now, timeZone) {
|
|
|
880
874
|
}).formatToParts(now);
|
|
881
875
|
return Number(_optionalChain([parts, 'access', _46 => _46.find, 'call', _47 => _47((p) => p.type === "hour"), 'optionalAccess', _48 => _48.value]));
|
|
882
876
|
}
|
|
883
|
-
|
|
877
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, hour_in_zone, "hour_in_zone");
|
|
884
878
|
function hour_in_range(hour, start, end) {
|
|
885
879
|
return start < end ? hour >= start && hour < end : hour >= start || hour < end;
|
|
886
880
|
}
|
|
887
|
-
|
|
881
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, hour_in_range, "hour_in_range");
|
|
888
882
|
function is_dst_gap_open(now, timeZone, start) {
|
|
889
883
|
const hour = hour_in_zone(now, timeZone);
|
|
890
884
|
if (hour <= start) return false;
|
|
891
885
|
const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
|
|
892
886
|
return prev === start - 1 && hour === start + 1;
|
|
893
887
|
}
|
|
894
|
-
|
|
888
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, is_dst_gap_open, "is_dst_gap_open");
|
|
895
889
|
function in_autoclose_window(window, now) {
|
|
896
890
|
if (!window) return true;
|
|
897
891
|
const hour = hour_in_zone(now, window.timeZone);
|
|
898
892
|
return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
|
|
899
893
|
}
|
|
900
|
-
|
|
894
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, in_autoclose_window, "in_autoclose_window");
|
|
901
895
|
function next_window_open(window, now) {
|
|
902
896
|
const start_ms = now.getTime();
|
|
903
897
|
for (let h = 0; h <= 48; h++) {
|
|
@@ -912,30 +906,30 @@ function next_window_open(window, now) {
|
|
|
912
906
|
}
|
|
913
907
|
return new Date(start_ms + 864e5);
|
|
914
908
|
}
|
|
915
|
-
|
|
909
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, next_window_open, "next_window_open");
|
|
916
910
|
|
|
917
911
|
// src/internal/defer-config.ts
|
|
918
912
|
function duration_ms(d) {
|
|
919
913
|
return (_nullishCoalesce(d.days, () => ( 0))) * 864e5 + (_nullishCoalesce(d.hours, () => ( 0))) * 36e5 + (_nullishCoalesce(d.minutes, () => ( 0))) * 6e4;
|
|
920
914
|
}
|
|
921
|
-
|
|
915
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, duration_ms, "duration_ms");
|
|
922
916
|
function resolve_defer_at(when, event) {
|
|
923
|
-
const parsed =
|
|
917
|
+
const parsed = _chunkWDIBO6AWcjs.check.call(void 0, "defer", when);
|
|
924
918
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
925
919
|
return parsed.at.getTime();
|
|
926
920
|
}
|
|
927
|
-
|
|
921
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, resolve_defer_at, "resolve_defer_at");
|
|
928
922
|
function make_deferred(handler, schedule) {
|
|
929
923
|
const call = handler;
|
|
930
|
-
const deferred = /* @__PURE__ */
|
|
924
|
+
const deferred = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async (event, stream, app) => {
|
|
931
925
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
932
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
926
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkUEGKXCSQcjs.DeferSignal)(when);
|
|
933
927
|
return call(event, stream, app);
|
|
934
928
|
}, "deferred");
|
|
935
929
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
936
930
|
return deferred;
|
|
937
931
|
}
|
|
938
|
-
|
|
932
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, make_deferred, "make_deferred");
|
|
939
933
|
|
|
940
934
|
// src/internal/drain-cycle.ts
|
|
941
935
|
var _crypto = require('crypto');
|
|
@@ -964,13 +958,13 @@ function compute_backoff_delay(retry, opts) {
|
|
|
964
958
|
if (opts.jitter) delay = delay * (0.5 + Math.random());
|
|
965
959
|
return Math.max(0, Math.floor(delay));
|
|
966
960
|
}
|
|
967
|
-
|
|
961
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, compute_backoff_delay, "compute_backoff_delay");
|
|
968
962
|
|
|
969
963
|
// src/internal/defer-timer.ts
|
|
970
964
|
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
971
965
|
var DeferTimer = (_class2 = class {
|
|
972
966
|
static {
|
|
973
|
-
|
|
967
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "DeferTimer");
|
|
974
968
|
}
|
|
975
969
|
__init2() {this._due = /* @__PURE__ */ new Map()}
|
|
976
970
|
|
|
@@ -1061,15 +1055,15 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1061
1055
|
if (total === 0) return RATIO_DEFAULT;
|
|
1062
1056
|
return Math.max(RATIO_MIN, Math.min(RATIO_MAX, lagging_avg / total));
|
|
1063
1057
|
}
|
|
1064
|
-
|
|
1058
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, compute_lag_lead_ratio, "compute_lag_lead_ratio");
|
|
1065
1059
|
|
|
1066
1060
|
// src/internal/report-once.ts
|
|
1067
1061
|
function report_once(seen, key, message) {
|
|
1068
1062
|
if (seen.has(key)) return;
|
|
1069
1063
|
seen.add(key);
|
|
1070
|
-
|
|
1064
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).error(new Error(message));
|
|
1071
1065
|
}
|
|
1072
|
-
|
|
1066
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, report_once, "report_once");
|
|
1073
1067
|
|
|
1074
1068
|
// src/internal/correlation-id.ts
|
|
1075
1069
|
|
|
@@ -1079,8 +1073,8 @@ var SEG_SPACE = BASE ** SEG_WIDTH;
|
|
|
1079
1073
|
function seg(n) {
|
|
1080
1074
|
return n.toString(BASE).padStart(SEG_WIDTH, "0");
|
|
1081
1075
|
}
|
|
1082
|
-
|
|
1083
|
-
var default_correlator = /* @__PURE__ */
|
|
1076
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, seg, "seg");
|
|
1077
|
+
var default_correlator = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, ({ state: state2, action: action2 }) => {
|
|
1084
1078
|
const s = state2.slice(0, SEG_WIDTH).toLowerCase();
|
|
1085
1079
|
const a = action2.slice(0, SEG_WIDTH).toLowerCase();
|
|
1086
1080
|
const ts = seg(Date.now() % SEG_SPACE);
|
|
@@ -1095,17 +1089,17 @@ function close_correlation(correlator, actor) {
|
|
|
1095
1089
|
actor
|
|
1096
1090
|
});
|
|
1097
1091
|
}
|
|
1098
|
-
|
|
1092
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, close_correlation, "close_correlation");
|
|
1099
1093
|
|
|
1100
1094
|
// src/internal/drain-ops.ts
|
|
1101
|
-
var claim = /* @__PURE__ */
|
|
1095
|
+
var claim = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (lagging, leading, by, millis, lane) => _chunkWDIBO6AWcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane), "claim");
|
|
1102
1096
|
async function fetch(leased, eventLimit) {
|
|
1103
1097
|
return Promise.all(
|
|
1104
1098
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1105
1099
|
const events = [];
|
|
1106
|
-
const stream_exact = source !== void 0 &&
|
|
1100
|
+
const stream_exact = source !== void 0 && _chunkDCWPJFXRcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1107
1101
|
try {
|
|
1108
|
-
await
|
|
1102
|
+
await _chunkWDIBO6AWcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1109
1103
|
stream: source,
|
|
1110
1104
|
stream_exact,
|
|
1111
1105
|
after: at,
|
|
@@ -1125,19 +1119,68 @@ async function fetch(leased, eventLimit) {
|
|
|
1125
1119
|
})
|
|
1126
1120
|
);
|
|
1127
1121
|
}
|
|
1128
|
-
|
|
1129
|
-
var ack = /* @__PURE__ */
|
|
1130
|
-
var block = /* @__PURE__ */
|
|
1131
|
-
var subscribe = /* @__PURE__ */
|
|
1122
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, fetch, "fetch");
|
|
1123
|
+
var ack = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (leases) => _chunkWDIBO6AWcjs.store.call(void 0, ).ack(leases), "ack");
|
|
1124
|
+
var block = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (leases) => _chunkWDIBO6AWcjs.store.call(void 0, ).block(leases), "block");
|
|
1125
|
+
var subscribe = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (streams, correlated_at, correlator) => _chunkWDIBO6AWcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator), "subscribe");
|
|
1132
1126
|
|
|
1133
1127
|
// src/internal/event-sourcing.ts
|
|
1134
1128
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
1135
|
-
var
|
|
1129
|
+
var _zod2 = require('zod');
|
|
1136
1130
|
|
|
1137
1131
|
// src/internal/date-reviver.ts
|
|
1138
1132
|
|
|
1133
|
+
|
|
1134
|
+
// src/internal/zod.ts
|
|
1135
|
+
var def_of = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (schema) => _optionalChain([schema, 'optionalAccess', _50 => _50._zod, 'optionalAccess', _51 => _51.def]), "def_of");
|
|
1136
|
+
var SINGLE_INNER = [
|
|
1137
|
+
"optional",
|
|
1138
|
+
"nullable",
|
|
1139
|
+
"default",
|
|
1140
|
+
"prefault",
|
|
1141
|
+
"nonoptional",
|
|
1142
|
+
"readonly",
|
|
1143
|
+
"catch"
|
|
1144
|
+
];
|
|
1145
|
+
var inner_of = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (def) => SINGLE_INNER.includes(def.type) ? def.innerType : void 0, "inner_of");
|
|
1146
|
+
function wrapped(schema) {
|
|
1147
|
+
const def = def_of(schema);
|
|
1148
|
+
if (!def) return [];
|
|
1149
|
+
if (def.type === "pipe") return [def.in, def.out];
|
|
1150
|
+
if (def.type === "lazy") return [def.getter()];
|
|
1151
|
+
const inner = inner_of(def);
|
|
1152
|
+
return inner ? [inner] : [];
|
|
1153
|
+
}
|
|
1154
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, wrapped, "wrapped");
|
|
1155
|
+
function some_layer(schema, test) {
|
|
1156
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1157
|
+
const visit = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (s) => {
|
|
1158
|
+
if (seen.has(s)) return false;
|
|
1159
|
+
seen.add(s);
|
|
1160
|
+
const def = def_of(s);
|
|
1161
|
+
return !!def && (test(def) || wrapped(s).some(visit));
|
|
1162
|
+
}, "visit");
|
|
1163
|
+
return visit(schema);
|
|
1164
|
+
}
|
|
1165
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, some_layer, "some_layer");
|
|
1166
|
+
function output_of(schema) {
|
|
1167
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1168
|
+
let cur = schema;
|
|
1169
|
+
while (!seen.has(cur)) {
|
|
1170
|
+
seen.add(cur);
|
|
1171
|
+
const def = def_of(cur);
|
|
1172
|
+
if (!def) return cur;
|
|
1173
|
+
const next = def.type === "pipe" ? def.out : wrapped(cur)[0];
|
|
1174
|
+
if (!next) return cur;
|
|
1175
|
+
cur = next;
|
|
1176
|
+
}
|
|
1177
|
+
return cur;
|
|
1178
|
+
}
|
|
1179
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, output_of, "output_of");
|
|
1180
|
+
|
|
1181
|
+
// src/internal/date-reviver.ts
|
|
1139
1182
|
function variant_schema(schema, walk) {
|
|
1140
|
-
const shape = _optionalChain([
|
|
1183
|
+
const shape = _optionalChain([def_of, 'call', _52 => _52(schema), 'optionalAccess', _53 => _53.shape]);
|
|
1141
1184
|
if (!shape) {
|
|
1142
1185
|
const dates = walk(schema);
|
|
1143
1186
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -1149,19 +1192,19 @@ function variant_schema(schema, walk) {
|
|
|
1149
1192
|
if (dates) dated = true;
|
|
1150
1193
|
next[key] = (_nullishCoalesce(dates, () => ( field))).optional();
|
|
1151
1194
|
}
|
|
1152
|
-
return { schema:
|
|
1195
|
+
return { schema: _zod2.z.looseObject(next), dated };
|
|
1153
1196
|
}
|
|
1154
|
-
|
|
1197
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, variant_schema, "variant_schema");
|
|
1155
1198
|
function date_reviver_schema(schema) {
|
|
1156
1199
|
let recursive = false;
|
|
1157
|
-
const pass = /* @__PURE__ */
|
|
1200
|
+
const pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (tie) => {
|
|
1158
1201
|
const done = /* @__PURE__ */ new Map();
|
|
1159
1202
|
const active = /* @__PURE__ */ new Set();
|
|
1160
|
-
const walk = /* @__PURE__ */
|
|
1203
|
+
const walk = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (node) => {
|
|
1161
1204
|
if (done.has(node)) return done.get(node);
|
|
1162
1205
|
if (active.has(node)) {
|
|
1163
1206
|
recursive = true;
|
|
1164
|
-
return tie ?
|
|
1207
|
+
return tie ? _zod2.z.lazy(() => done.get(node)) : void 0;
|
|
1165
1208
|
}
|
|
1166
1209
|
active.add(node);
|
|
1167
1210
|
const result = build(node, walk);
|
|
@@ -1174,14 +1217,14 @@ function date_reviver_schema(schema) {
|
|
|
1174
1217
|
const first = pass(false);
|
|
1175
1218
|
return first && recursive ? pass(true) : first;
|
|
1176
1219
|
}
|
|
1177
|
-
|
|
1220
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, date_reviver_schema, "date_reviver_schema");
|
|
1178
1221
|
function build(schema, walk) {
|
|
1179
|
-
const def =
|
|
1222
|
+
const def = def_of(schema);
|
|
1180
1223
|
if (!def) return void 0;
|
|
1181
|
-
const inner = /* @__PURE__ */
|
|
1224
|
+
const inner = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => walk(def.innerType), "inner");
|
|
1182
1225
|
switch (def.type) {
|
|
1183
1226
|
case "date":
|
|
1184
|
-
return
|
|
1227
|
+
return _zod2.z.coerce.date();
|
|
1185
1228
|
case "object": {
|
|
1186
1229
|
const shape = def.shape;
|
|
1187
1230
|
if (!shape) return void 0;
|
|
@@ -1190,28 +1233,28 @@ function build(schema, walk) {
|
|
|
1190
1233
|
const dates = walk(field);
|
|
1191
1234
|
if (dates) dated[key] = dates.optional();
|
|
1192
1235
|
}
|
|
1193
|
-
return Object.keys(dated).length ?
|
|
1236
|
+
return Object.keys(dated).length ? _zod2.z.looseObject(dated) : void 0;
|
|
1194
1237
|
}
|
|
1195
1238
|
case "array": {
|
|
1196
1239
|
const element = walk(def.element);
|
|
1197
|
-
return element &&
|
|
1240
|
+
return element && _zod2.z.array(element);
|
|
1198
1241
|
}
|
|
1199
1242
|
case "tuple": {
|
|
1200
1243
|
const items = def.items.map((i) => walk(i));
|
|
1201
|
-
return items.some(Boolean) ?
|
|
1244
|
+
return items.some(Boolean) ? _zod2.z.tuple(items.map((i) => _nullishCoalesce(i, () => ( _zod2.z.unknown())))) : void 0;
|
|
1202
1245
|
}
|
|
1203
1246
|
case "record": {
|
|
1204
1247
|
const value = walk(def.valueType);
|
|
1205
|
-
return value &&
|
|
1248
|
+
return value && _zod2.z.record(_zod2.z.string(), value);
|
|
1206
1249
|
}
|
|
1207
1250
|
case "union": {
|
|
1208
1251
|
const variants = def.options.map(
|
|
1209
1252
|
(o) => variant_schema(o, walk)
|
|
1210
1253
|
);
|
|
1211
|
-
return variants.some((v) => v.dated) ?
|
|
1254
|
+
return variants.some((v) => v.dated) ? _zod2.z.union(variants.map((v) => v.schema)) : void 0;
|
|
1212
1255
|
}
|
|
1213
1256
|
case "nullable":
|
|
1214
|
-
return _optionalChain([inner, 'call',
|
|
1257
|
+
return _optionalChain([inner, 'call', _54 => _54(), 'optionalAccess', _55 => _55.nullable, 'call', _56 => _56()]);
|
|
1215
1258
|
case "pipe":
|
|
1216
1259
|
return walk(def.out);
|
|
1217
1260
|
case "lazy":
|
|
@@ -1222,45 +1265,45 @@ function build(schema, walk) {
|
|
|
1222
1265
|
return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
|
|
1223
1266
|
}
|
|
1224
1267
|
default:
|
|
1225
|
-
return
|
|
1268
|
+
return inner_of(def) ? inner() : void 0;
|
|
1226
1269
|
}
|
|
1227
1270
|
}
|
|
1228
|
-
|
|
1271
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, build, "build");
|
|
1229
1272
|
|
|
1230
1273
|
// src/internal/event-sourcing.ts
|
|
1231
|
-
var bare_patch = /* @__PURE__ */
|
|
1232
|
-
var value_at = /* @__PURE__ */
|
|
1233
|
-
(at, key) => _optionalChain([at, 'optionalAccess',
|
|
1274
|
+
var bare_patch = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial), "bare_patch");
|
|
1275
|
+
var value_at = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (value, path) => path.reduce(
|
|
1276
|
+
(at, key) => _optionalChain([at, 'optionalAccess', _57 => _57[key]]),
|
|
1234
1277
|
value
|
|
1235
1278
|
), "value_at");
|
|
1236
|
-
var check_invariants = /* @__PURE__ */
|
|
1279
|
+
var check_invariants = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (target, state2, schema, pii_aware) => {
|
|
1237
1280
|
let result;
|
|
1238
1281
|
try {
|
|
1239
1282
|
result = schema.safeParse(state2);
|
|
1240
1283
|
} catch (error) {
|
|
1241
|
-
throw new (0,
|
|
1284
|
+
throw new (0, _chunkUEGKXCSQcjs.ValidationError)(target, state2, error);
|
|
1242
1285
|
}
|
|
1243
1286
|
if (result.success) return;
|
|
1244
1287
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1245
1288
|
const value = value_at(state2, issue.path);
|
|
1246
|
-
return value !==
|
|
1289
|
+
return value !== _chunkUEGKXCSQcjs.REDACTED && value !== _chunkUEGKXCSQcjs.SHREDDED;
|
|
1247
1290
|
}) : result.error.issues;
|
|
1248
1291
|
if (issues.length)
|
|
1249
|
-
throw new (0,
|
|
1292
|
+
throw new (0, _chunkUEGKXCSQcjs.ValidationError)(
|
|
1250
1293
|
target,
|
|
1251
1294
|
state2,
|
|
1252
|
-
|
|
1295
|
+
_zod2.prettifyError.call(void 0, new (0, _zod2.ZodError)(issues))
|
|
1253
1296
|
);
|
|
1254
1297
|
}, "check_invariants");
|
|
1255
1298
|
var DEFAULT_BATCH = 500;
|
|
1256
|
-
var cache_put = /* @__PURE__ */
|
|
1257
|
-
(err) =>
|
|
1299
|
+
var cache_put = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (stream, entry) => _chunkWDIBO6AWcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1300
|
+
(err) => _chunkWDIBO6AWcjs.log.call(void 0, ).warn(
|
|
1258
1301
|
err,
|
|
1259
1302
|
"cache set skipped; the next load re-folds from the store"
|
|
1260
1303
|
)
|
|
1261
1304
|
), "cache_put");
|
|
1262
|
-
var cache_drop = /* @__PURE__ */
|
|
1263
|
-
(err) =>
|
|
1305
|
+
var cache_drop = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (stream) => _chunkWDIBO6AWcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1306
|
+
(err) => _chunkWDIBO6AWcjs.log.call(void 0, ).warn(
|
|
1264
1307
|
err,
|
|
1265
1308
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1266
1309
|
)
|
|
@@ -1268,11 +1311,11 @@ var cache_drop = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (stream)
|
|
|
1268
1311
|
async function snap(snapshot) {
|
|
1269
1312
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1270
1313
|
try {
|
|
1271
|
-
const [committed] = await
|
|
1314
|
+
const [committed] = await _chunkWDIBO6AWcjs.store.call(void 0, ).commit(
|
|
1272
1315
|
[
|
|
1273
1316
|
{
|
|
1274
1317
|
stream,
|
|
1275
|
-
msgs: [{ name:
|
|
1318
|
+
msgs: [{ name: _chunkUEGKXCSQcjs.SNAP_EVENT, data: snapshot.state }],
|
|
1276
1319
|
// IMPORTANT! - state events are committed right after the snapshot event
|
|
1277
1320
|
expectedVersion: version
|
|
1278
1321
|
}
|
|
@@ -1285,19 +1328,19 @@ async function snap(snapshot) {
|
|
|
1285
1328
|
return committed;
|
|
1286
1329
|
} catch (error) {
|
|
1287
1330
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1288
|
-
|
|
1331
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).warn(
|
|
1289
1332
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1290
1333
|
);
|
|
1291
1334
|
}
|
|
1292
1335
|
}
|
|
1293
|
-
|
|
1336
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, snap, "snap");
|
|
1294
1337
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1295
1338
|
try {
|
|
1296
|
-
const [committed] = await
|
|
1339
|
+
const [committed] = await _chunkWDIBO6AWcjs.store.call(void 0, ).commit(
|
|
1297
1340
|
[
|
|
1298
1341
|
{
|
|
1299
1342
|
stream,
|
|
1300
|
-
msgs: [{ name:
|
|
1343
|
+
msgs: [{ name: _chunkUEGKXCSQcjs.TOMBSTONE_EVENT, data: {} }],
|
|
1301
1344
|
expectedVersion
|
|
1302
1345
|
}
|
|
1303
1346
|
],
|
|
@@ -1305,18 +1348,18 @@ async function tombstone(stream, expectedVersion, correlation) {
|
|
|
1305
1348
|
);
|
|
1306
1349
|
return committed;
|
|
1307
1350
|
} catch (error) {
|
|
1308
|
-
if (error instanceof
|
|
1351
|
+
if (error instanceof _chunkUEGKXCSQcjs.ConcurrencyError) return void 0;
|
|
1309
1352
|
throw error;
|
|
1310
1353
|
}
|
|
1311
1354
|
}
|
|
1312
|
-
|
|
1355
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, tombstone, "tombstone");
|
|
1313
1356
|
function is_valid(event) {
|
|
1314
1357
|
if (event.version < 0) return false;
|
|
1315
1358
|
if (!(event.created instanceof Date) || Number.isNaN(event.created.getTime()))
|
|
1316
1359
|
return false;
|
|
1317
1360
|
return true;
|
|
1318
1361
|
}
|
|
1319
|
-
|
|
1362
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, is_valid, "is_valid");
|
|
1320
1363
|
async function scan(source, opts = {}, callback) {
|
|
1321
1364
|
const {
|
|
1322
1365
|
drop_snapshots = false,
|
|
@@ -1344,9 +1387,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1344
1387
|
if (drop_closed_streams) {
|
|
1345
1388
|
await source.query(
|
|
1346
1389
|
(e) => {
|
|
1347
|
-
if (e.name ===
|
|
1390
|
+
if (e.name === _chunkUEGKXCSQcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1348
1391
|
},
|
|
1349
|
-
{ names: [
|
|
1392
|
+
{ names: [_chunkUEGKXCSQcjs.TOMBSTONE_EVENT] }
|
|
1350
1393
|
);
|
|
1351
1394
|
}
|
|
1352
1395
|
let max_id;
|
|
@@ -1371,20 +1414,20 @@ async function scan(source, opts = {}, callback) {
|
|
|
1371
1414
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1372
1415
|
const has_history = started.has(event.stream);
|
|
1373
1416
|
started.add(event.stream);
|
|
1374
|
-
if (drop_snapshots && event.name ===
|
|
1417
|
+
if (drop_snapshots && event.name === _chunkUEGKXCSQcjs.SNAP_EVENT && has_history) {
|
|
1375
1418
|
dropped_snaps++;
|
|
1376
1419
|
return;
|
|
1377
1420
|
}
|
|
1378
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1421
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkUEGKXCSQcjs.TOMBSTONE_EVENT) {
|
|
1379
1422
|
dropped_closed++;
|
|
1380
1423
|
return;
|
|
1381
1424
|
}
|
|
1382
1425
|
let migrated = event;
|
|
1383
|
-
const migration = _optionalChain([event_migrations, 'optionalAccess',
|
|
1426
|
+
const migration = _optionalChain([event_migrations, 'optionalAccess', _58 => _58[event.name]]);
|
|
1384
1427
|
if (migration) {
|
|
1385
|
-
const revived = _optionalChain([migration_dates, 'access',
|
|
1428
|
+
const revived = _optionalChain([migration_dates, 'access', _59 => _59.get, 'call', _60 => _60(event.name), 'optionalAccess', _61 => _61.safeParse, 'call', _62 => _62(event.data)]);
|
|
1386
1429
|
const old_data = migration.from_schema.parse(
|
|
1387
|
-
_optionalChain([revived, 'optionalAccess',
|
|
1430
|
+
_optionalChain([revived, 'optionalAccess', _63 => _63.success]) ? revived.data : event.data
|
|
1388
1431
|
);
|
|
1389
1432
|
const new_data = migration.migrate(old_data);
|
|
1390
1433
|
migration.to_schema.parse(new_data);
|
|
@@ -1422,7 +1465,7 @@ async function scan(source, opts = {}, callback) {
|
|
|
1422
1465
|
// A cause missing from the source has no id in the new
|
|
1423
1466
|
// log; its old id would name another event there.
|
|
1424
1467
|
id: _nullishCoalesce(id_map.get(cause.id), () => ( -1)),
|
|
1425
|
-
name: _nullishCoalesce(_optionalChain([event_migrations, 'optionalAccess',
|
|
1468
|
+
name: _nullishCoalesce(_optionalChain([event_migrations, 'optionalAccess', _64 => _64[cause.name], 'optionalAccess', _65 => _65.to]), () => ( cause.name)),
|
|
1426
1469
|
stream: stream_rename ? stream_rename(cause.stream) : cause.stream
|
|
1427
1470
|
}
|
|
1428
1471
|
}
|
|
@@ -1448,23 +1491,23 @@ async function scan(source, opts = {}, callback) {
|
|
|
1448
1491
|
}
|
|
1449
1492
|
};
|
|
1450
1493
|
}
|
|
1451
|
-
|
|
1494
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, scan, "scan");
|
|
1452
1495
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1453
1496
|
const { stream, actor, asOf } = target;
|
|
1454
1497
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1455
1498
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1456
|
-
const cached = time_travel ? void 0 : await
|
|
1499
|
+
const cached = time_travel ? void 0 : await _chunkWDIBO6AWcjs.cache.call(void 0, ).get(stream);
|
|
1457
1500
|
const cache_hit = !!cached;
|
|
1458
|
-
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1459
|
-
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1460
|
-
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1501
|
+
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _66 => _66.state]), () => ( (me.init ? me.init() : {})));
|
|
1502
|
+
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _67 => _67.patches]), () => ( 0));
|
|
1503
|
+
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _68 => _68.snaps]), () => ( 0));
|
|
1461
1504
|
let replayed = 0;
|
|
1462
1505
|
let event;
|
|
1463
|
-
await
|
|
1506
|
+
await _chunkWDIBO6AWcjs.store.call(void 0, ).query(
|
|
1464
1507
|
(raw) => {
|
|
1465
|
-
if (seeded && raw.name ===
|
|
1508
|
+
if (seeded && raw.name === _chunkUEGKXCSQcjs.SNAP_EVENT && replayed > 0) return;
|
|
1466
1509
|
event = me.view(raw, actor);
|
|
1467
|
-
if (event.name ===
|
|
1510
|
+
if (event.name === _chunkUEGKXCSQcjs.SNAP_EVENT) {
|
|
1468
1511
|
state2 = event.data;
|
|
1469
1512
|
snaps++;
|
|
1470
1513
|
patches = 0;
|
|
@@ -1473,12 +1516,12 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1473
1516
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1474
1517
|
patches++;
|
|
1475
1518
|
replayed++;
|
|
1476
|
-
} else if (event.name !==
|
|
1477
|
-
|
|
1519
|
+
} else if (event.name !== _chunkUEGKXCSQcjs.TOMBSTONE_EVENT) {
|
|
1520
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).warn(
|
|
1478
1521
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1479
1522
|
);
|
|
1480
1523
|
}
|
|
1481
|
-
_optionalChain([callback, 'optionalCall',
|
|
1524
|
+
_optionalChain([callback, 'optionalCall', _69 => _69({
|
|
1482
1525
|
event,
|
|
1483
1526
|
state: state2,
|
|
1484
1527
|
version: event.version,
|
|
@@ -1502,7 +1545,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1502
1545
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1503
1546
|
}
|
|
1504
1547
|
);
|
|
1505
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess',
|
|
1548
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _70 => _70.name]) === _chunkUEGKXCSQcjs.TOMBSTONE_EVENT;
|
|
1506
1549
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1507
1550
|
await cache_put(stream, {
|
|
1508
1551
|
stream,
|
|
@@ -1516,16 +1559,16 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1516
1559
|
return {
|
|
1517
1560
|
event,
|
|
1518
1561
|
state: state2,
|
|
1519
|
-
version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1562
|
+
version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _71 => _71.version]), () => ( _optionalChain([cached, 'optionalAccess', _72 => _72.version]))), () => ( -1)),
|
|
1520
1563
|
// Captured with `state`, so consumers never race a separate cache lookup.
|
|
1521
|
-
id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1564
|
+
id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _73 => _73.id]), () => ( _optionalChain([cached, 'optionalAccess', _74 => _74.event_id]))), () => ( -1)),
|
|
1522
1565
|
patches,
|
|
1523
1566
|
snaps,
|
|
1524
1567
|
cache_hit,
|
|
1525
1568
|
replayed
|
|
1526
1569
|
};
|
|
1527
1570
|
}
|
|
1528
|
-
|
|
1571
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, load, "load");
|
|
1529
1572
|
async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
1530
1573
|
const streams = loads.map((l) => l.target(payload, own.state));
|
|
1531
1574
|
streams.forEach((stream, i) => {
|
|
@@ -1546,8 +1589,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1546
1589
|
void 0,
|
|
1547
1590
|
patch_fn
|
|
1548
1591
|
);
|
|
1549
|
-
if (_optionalChain([snapshot, 'access',
|
|
1550
|
-
throw new (0,
|
|
1592
|
+
if (_optionalChain([snapshot, 'access', _75 => _75.event, 'optionalAccess', _76 => _76.name]) === _chunkUEGKXCSQcjs.TOMBSTONE_EVENT)
|
|
1593
|
+
throw new (0, _chunkUEGKXCSQcjs.StreamClosedError)(stream);
|
|
1551
1594
|
return {
|
|
1552
1595
|
state: l.state,
|
|
1553
1596
|
stream,
|
|
@@ -1558,16 +1601,16 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1558
1601
|
})
|
|
1559
1602
|
);
|
|
1560
1603
|
}
|
|
1561
|
-
|
|
1604
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, load_others, "load_others");
|
|
1562
1605
|
async function action(me, action2, target, payload, options, patch_fn = bare_patch) {
|
|
1563
1606
|
const { stream, expectedVersion, actor } = target;
|
|
1564
1607
|
if (!stream) throw new Error("Missing target stream");
|
|
1565
|
-
const reactingTo = _optionalChain([options, 'optionalAccess',
|
|
1566
|
-
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1567
|
-
const validated =
|
|
1568
|
-
const opts = _optionalChain([me, 'access',
|
|
1569
|
-
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1570
|
-
const loads = _nullishCoalesce(_optionalChain([me, 'access',
|
|
1608
|
+
const reactingTo = _optionalChain([options, 'optionalAccess', _77 => _77.reactingTo]);
|
|
1609
|
+
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _78 => _78.correlator]), () => ( default_correlator));
|
|
1610
|
+
const validated = _chunkWDIBO6AWcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1611
|
+
const opts = _optionalChain([me, 'access', _79 => _79.options, 'optionalAccess', _80 => _80[action2]]);
|
|
1612
|
+
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _81 => _81.maxRetries]), () => ( 0));
|
|
1613
|
+
const loads = _nullishCoalesce(_optionalChain([me, 'access', _82 => _82.loads, 'optionalAccess', _83 => _83[action2]]), () => ( []));
|
|
1571
1614
|
for (let attempt = 0; ; attempt++) {
|
|
1572
1615
|
try {
|
|
1573
1616
|
const snapshot = await load(
|
|
@@ -1576,8 +1619,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1576
1619
|
void 0,
|
|
1577
1620
|
patch_fn
|
|
1578
1621
|
);
|
|
1579
|
-
if (_optionalChain([snapshot, 'access',
|
|
1580
|
-
throw new (0,
|
|
1622
|
+
if (_optionalChain([snapshot, 'access', _84 => _84.event, 'optionalAccess', _85 => _85.name]) === _chunkUEGKXCSQcjs.TOMBSTONE_EVENT)
|
|
1623
|
+
throw new (0, _chunkUEGKXCSQcjs.StreamClosedError)(stream);
|
|
1581
1624
|
const own = {
|
|
1582
1625
|
state: me,
|
|
1583
1626
|
stream,
|
|
@@ -1591,7 +1634,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1591
1634
|
{ stream, state: snapshot.state },
|
|
1592
1635
|
target.actor,
|
|
1593
1636
|
patch_fn,
|
|
1594
|
-
(description) => new (0,
|
|
1637
|
+
(description) => new (0, _chunkUEGKXCSQcjs.PreconditionError)(
|
|
1595
1638
|
action2,
|
|
1596
1639
|
validated,
|
|
1597
1640
|
target,
|
|
@@ -1600,11 +1643,11 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1600
1643
|
)
|
|
1601
1644
|
) : [];
|
|
1602
1645
|
const loaded = Object.fromEntries(
|
|
1603
|
-
others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess',
|
|
1646
|
+
others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess', _86 => _86.snapshot, 'access', _87 => _87.state])])
|
|
1604
1647
|
);
|
|
1605
|
-
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access',
|
|
1648
|
+
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _88 => _88.requires, 'optionalAccess', _89 => _89[action2]]), () => ( [])))
|
|
1606
1649
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1607
|
-
throw new (0,
|
|
1650
|
+
throw new (0, _chunkUEGKXCSQcjs.PreconditionError)(
|
|
1608
1651
|
action2,
|
|
1609
1652
|
validated,
|
|
1610
1653
|
target,
|
|
@@ -1626,7 +1669,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1626
1669
|
);
|
|
1627
1670
|
to.events.push({
|
|
1628
1671
|
name: event,
|
|
1629
|
-
data:
|
|
1672
|
+
data: _chunkWDIBO6AWcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1630
1673
|
});
|
|
1631
1674
|
}
|
|
1632
1675
|
if (!own.events.length)
|
|
@@ -1634,10 +1677,10 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1634
1677
|
`Action "${action2}" appends only to the streams it loads; it must append an event to its own stream too`
|
|
1635
1678
|
);
|
|
1636
1679
|
const appends = [own, ...others].filter(
|
|
1637
|
-
(p) => !!_optionalChain([p, 'optionalAccess',
|
|
1680
|
+
(p) => !!_optionalChain([p, 'optionalAccess', _90 => _90.events, 'access', _91 => _91.length])
|
|
1638
1681
|
);
|
|
1639
1682
|
const meta = {
|
|
1640
|
-
correlation: _optionalChain([reactingTo, 'optionalAccess',
|
|
1683
|
+
correlation: _optionalChain([reactingTo, 'optionalAccess', _92 => _92.meta, 'access', _93 => _93.correlation]) || correlator({
|
|
1641
1684
|
action: action2,
|
|
1642
1685
|
state: me.name,
|
|
1643
1686
|
stream,
|
|
@@ -1683,7 +1726,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1683
1726
|
});
|
|
1684
1727
|
let committed;
|
|
1685
1728
|
try {
|
|
1686
|
-
committed = await
|
|
1729
|
+
committed = await _chunkWDIBO6AWcjs.store.call(void 0, ).commit(
|
|
1687
1730
|
appends.map((p) => ({
|
|
1688
1731
|
stream: p.stream,
|
|
1689
1732
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1692,7 +1735,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1692
1735
|
meta
|
|
1693
1736
|
);
|
|
1694
1737
|
} catch (error) {
|
|
1695
|
-
if (error instanceof
|
|
1738
|
+
if (error instanceof _chunkUEGKXCSQcjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1696
1739
|
throw error;
|
|
1697
1740
|
}
|
|
1698
1741
|
let row = 0;
|
|
@@ -1715,13 +1758,13 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1715
1758
|
};
|
|
1716
1759
|
});
|
|
1717
1760
|
const last = appended.at(-1);
|
|
1718
|
-
const snap_event = _optionalChain([owner, 'access',
|
|
1761
|
+
const snap_event = _optionalChain([owner, 'access', _94 => _94.snap, 'optionalCall', _95 => _95(last)]) ? await snap(last) : void 0;
|
|
1719
1762
|
if (!owner.pii_aware)
|
|
1720
1763
|
void cache_put(append.stream, {
|
|
1721
1764
|
stream: append.stream,
|
|
1722
1765
|
state: last.state,
|
|
1723
|
-
version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess',
|
|
1724
|
-
event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess',
|
|
1766
|
+
version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _96 => _96.version]), () => ( last.event.version)),
|
|
1767
|
+
event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _97 => _97.id]), () => ( last.event.id)),
|
|
1725
1768
|
patches: snap_event ? 0 : last.patches,
|
|
1726
1769
|
snaps: snap_event ? last.snaps + 1 : last.snaps
|
|
1727
1770
|
});
|
|
@@ -1734,20 +1777,20 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1734
1777
|
}
|
|
1735
1778
|
return snapshots;
|
|
1736
1779
|
} catch (error) {
|
|
1737
|
-
if (!(error instanceof
|
|
1780
|
+
if (!(error instanceof _chunkUEGKXCSQcjs.ConcurrencyError)) throw error;
|
|
1738
1781
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1739
1782
|
if (attempt >= max_retries) throw error;
|
|
1740
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
1783
|
+
if (_optionalChain([opts, 'optionalAccess', _98 => _98.backoff])) {
|
|
1741
1784
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1742
|
-
if (delay_ms > 0) await
|
|
1785
|
+
if (delay_ms > 0) await _chunkWDIBO6AWcjs.sleep.call(void 0, delay_ms);
|
|
1743
1786
|
}
|
|
1744
1787
|
}
|
|
1745
1788
|
}
|
|
1746
1789
|
}
|
|
1747
|
-
|
|
1790
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, action, "action");
|
|
1748
1791
|
|
|
1749
1792
|
// src/internal/tracing.ts
|
|
1750
|
-
var PRETTY =
|
|
1793
|
+
var PRETTY = _chunkWDIBO6AWcjs.config.call(void 0, ).env !== "production";
|
|
1751
1794
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1752
1795
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1753
1796
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1756,14 +1799,14 @@ var C_DRAIN = "\x1B[38;5;244m";
|
|
|
1756
1799
|
var C_HIT = "\x1B[38;5;82m";
|
|
1757
1800
|
var C_MISS = "\x1B[38;5;220m";
|
|
1758
1801
|
var C_RESET = "\x1B[0m";
|
|
1759
|
-
var es_caption = /* @__PURE__ */
|
|
1802
|
+
var es_caption = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (caption, color, body) => PRETTY ? `${color}${body}${C_RESET}` : `${caption}: ${body}`, "es_caption");
|
|
1760
1803
|
var C_LANE = "\x1B[38;5;183m";
|
|
1761
1804
|
var C_DIM = "\x1B[38;5;240m";
|
|
1762
1805
|
var C_ERR = "\x1B[38;5;196m";
|
|
1763
1806
|
var C_STREAM = "\x1B[38;5;226m";
|
|
1764
|
-
var dim = /* @__PURE__ */
|
|
1765
|
-
var hue = /* @__PURE__ */
|
|
1766
|
-
var drain_caption = /* @__PURE__ */
|
|
1807
|
+
var dim = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (text) => PRETTY ? `${C_DIM}${text}${C_RESET}` : text, "dim");
|
|
1808
|
+
var hue = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (color, text) => PRETTY ? `${color}${text}${C_RESET}` : text, "hue");
|
|
1809
|
+
var drain_caption = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (caption, lane) => {
|
|
1767
1810
|
const show_lane = lane && lane !== "default";
|
|
1768
1811
|
if (PRETTY) {
|
|
1769
1812
|
const tag = `${C_DRAIN}>> ${caption}${C_RESET}`;
|
|
@@ -1771,17 +1814,17 @@ var drain_caption = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (capti
|
|
|
1771
1814
|
}
|
|
1772
1815
|
return show_lane ? `>> ${caption} ${lane}` : `>> ${caption}`;
|
|
1773
1816
|
}, "drain_caption");
|
|
1774
|
-
var cache_marker = /* @__PURE__ */
|
|
1817
|
+
var cache_marker = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (hit) => {
|
|
1775
1818
|
const word = hit ? "hit" : "miss";
|
|
1776
1819
|
if (!PRETTY) return word;
|
|
1777
1820
|
return `${hit ? C_HIT : C_MISS}${word}${C_RESET}${C_GREEN}`;
|
|
1778
1821
|
}, "cache_marker");
|
|
1779
|
-
var stats_marker = /* @__PURE__ */
|
|
1822
|
+
var stats_marker = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (version, replayed, snaps, patches) => {
|
|
1780
1823
|
const text = `v=${version} replayed=${replayed} snaps=${snaps} patches=${patches}`;
|
|
1781
1824
|
if (!PRETTY) return text;
|
|
1782
1825
|
return `${C_DRAIN}${text}${C_RESET}${C_GREEN}`;
|
|
1783
1826
|
}, "stats_marker");
|
|
1784
|
-
var as_of_marker = /* @__PURE__ */
|
|
1827
|
+
var as_of_marker = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (asOf) => {
|
|
1785
1828
|
if (!asOf) return "";
|
|
1786
1829
|
const parts = [];
|
|
1787
1830
|
if (asOf.before !== void 0) parts.push(`before=${asOf.before}`);
|
|
@@ -1792,22 +1835,22 @@ var as_of_marker = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (asOf)
|
|
|
1792
1835
|
if (asOf.limit !== void 0) parts.push(`limit=${asOf.limit}`);
|
|
1793
1836
|
return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
|
|
1794
1837
|
}, "as_of_marker");
|
|
1795
|
-
var traced = /* @__PURE__ */
|
|
1796
|
-
_optionalChain([entry, 'optionalCall',
|
|
1838
|
+
var traced = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (inner, exit, entry) => (async (...args) => {
|
|
1839
|
+
_optionalChain([entry, 'optionalCall', _99 => _99(...args)]);
|
|
1797
1840
|
const result = await inner(...args);
|
|
1798
|
-
_optionalChain([exit, 'optionalCall',
|
|
1841
|
+
_optionalChain([exit, 'optionalCall', _100 => _100(result, ...args)]);
|
|
1799
1842
|
return result;
|
|
1800
1843
|
}), "traced");
|
|
1801
1844
|
function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
|
|
1802
|
-
const bound_action = /* @__PURE__ */
|
|
1845
|
+
const bound_action = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (me, action_name, target, payload, options) => action(
|
|
1803
1846
|
me,
|
|
1804
1847
|
action_name,
|
|
1805
1848
|
target,
|
|
1806
1849
|
payload,
|
|
1807
|
-
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1850
|
+
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _101 => _101.correlator]), () => ( correlator)) },
|
|
1808
1851
|
patch_fn
|
|
1809
1852
|
), "bound_action");
|
|
1810
|
-
const bound_load = /* @__PURE__ */
|
|
1853
|
+
const bound_load = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (me, target, callback) => load(me, target, callback, patch_fn), "bound_load");
|
|
1811
1854
|
if (logger.level !== "trace") {
|
|
1812
1855
|
return {
|
|
1813
1856
|
snap,
|
|
@@ -1869,7 +1912,7 @@ function build_es(logger, correlator = default_correlator, patch_fn = bare_patch
|
|
|
1869
1912
|
})
|
|
1870
1913
|
};
|
|
1871
1914
|
}
|
|
1872
|
-
|
|
1915
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, build_es, "build_es");
|
|
1873
1916
|
function build_drain(logger) {
|
|
1874
1917
|
return {
|
|
1875
1918
|
claim,
|
|
@@ -1879,7 +1922,7 @@ function build_drain(logger) {
|
|
|
1879
1922
|
subscribe: logger.level !== "trace" ? subscribe : traced(subscribe, (result, streams) => {
|
|
1880
1923
|
if (!result.subscribed) return;
|
|
1881
1924
|
const lanes = new Set(streams.map((s) => _nullishCoalesce(s.lane, () => ( "default"))));
|
|
1882
|
-
const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access',
|
|
1925
|
+
const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _102 => _102[0], 'optionalAccess', _103 => _103.lane]) : void 0;
|
|
1883
1926
|
const data = streams.map(
|
|
1884
1927
|
({ stream, lane }) => uniform_lane || !lane || lane === "default" ? hue(C_STREAM, stream) : `${hue(C_STREAM, stream)}${dim(`[${lane}]`)}`
|
|
1885
1928
|
).join(" ");
|
|
@@ -1889,10 +1932,10 @@ function build_drain(logger) {
|
|
|
1889
1932
|
})
|
|
1890
1933
|
};
|
|
1891
1934
|
}
|
|
1892
|
-
|
|
1935
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, build_drain, "build_drain");
|
|
1893
1936
|
function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
1894
1937
|
if (logger.level !== "trace" || !leased.length) return;
|
|
1895
|
-
const lane = _optionalChain([leased, 'access',
|
|
1938
|
+
const lane = _optionalChain([leased, 'access', _104 => _104[0], 'optionalAccess', _105 => _105.lane]);
|
|
1896
1939
|
const fetch_by_stream = new Map(fetched.map((f) => [f.stream, f]));
|
|
1897
1940
|
const acked_by_stream = new Map(acked.map((a) => [a.stream, a.at]));
|
|
1898
1941
|
const blocked_by_stream = new Map(blocked.map((b) => [b.stream, b.error]));
|
|
@@ -1901,8 +1944,8 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
|
1901
1944
|
);
|
|
1902
1945
|
const detail = leased.map(({ stream, at, retry }) => {
|
|
1903
1946
|
const f = fetch_by_stream.get(stream);
|
|
1904
|
-
const key = _optionalChain([f, 'optionalAccess',
|
|
1905
|
-
const events = _optionalChain([f, 'optionalAccess',
|
|
1947
|
+
const key = _optionalChain([f, 'optionalAccess', _106 => _106.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
|
|
1948
|
+
const events = _optionalChain([f, 'optionalAccess', _107 => _107.events, 'access', _108 => _108.length]) ? ` ${dim(
|
|
1906
1949
|
`[${f.events.map(({ id, name }) => `#${id} ${String(name)}`).join(", ")}]`
|
|
1907
1950
|
)}` : "";
|
|
1908
1951
|
const acked_at = acked_by_stream.get(stream);
|
|
@@ -1927,17 +1970,17 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
|
1927
1970
|
}).join(", ");
|
|
1928
1971
|
logger.trace(`${drain_caption("drained", lane)} ${detail}`);
|
|
1929
1972
|
}
|
|
1930
|
-
|
|
1973
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, trace_cycle, "trace_cycle");
|
|
1931
1974
|
|
|
1932
1975
|
// src/internal/drain-cycle.ts
|
|
1933
1976
|
function budget_exhausted(lease, options, store_failing) {
|
|
1934
|
-
if (store_failing || !_optionalChain([options, 'optionalAccess',
|
|
1977
|
+
if (store_failing || !_optionalChain([options, 'optionalAccess', _109 => _109.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1935
1978
|
return void 0;
|
|
1936
1979
|
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.`;
|
|
1937
|
-
|
|
1980
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).error(error);
|
|
1938
1981
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1939
1982
|
}
|
|
1940
|
-
|
|
1983
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, budget_exhausted, "budget_exhausted");
|
|
1941
1984
|
function fetch_failure_policy(registry) {
|
|
1942
1985
|
let blockOnError = true;
|
|
1943
1986
|
let maxRetries = 0;
|
|
@@ -1948,17 +1991,17 @@ function fetch_failure_policy(registry) {
|
|
|
1948
1991
|
}
|
|
1949
1992
|
return { blockOnError, maxRetries };
|
|
1950
1993
|
}
|
|
1951
|
-
|
|
1994
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, fetch_failure_policy, "fetch_failure_policy");
|
|
1952
1995
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1953
1996
|
if (!error) return { lease, handled, acked_at: at };
|
|
1954
1997
|
logger.error(error);
|
|
1955
|
-
const non_retryable = error instanceof
|
|
1998
|
+
const non_retryable = error instanceof _chunkUEGKXCSQcjs.NonRetryableError;
|
|
1956
1999
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
1957
2000
|
if (block2)
|
|
1958
2001
|
logger.error(
|
|
1959
2002
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1960
2003
|
);
|
|
1961
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2004
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkWDIBO6AWcjs.DEFAULT_BACKOFF)));
|
|
1962
2005
|
return {
|
|
1963
2006
|
lease,
|
|
1964
2007
|
handled,
|
|
@@ -1969,7 +2012,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
1969
2012
|
failed_at
|
|
1970
2013
|
};
|
|
1971
2014
|
}
|
|
1972
|
-
|
|
2015
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, finalize, "finalize");
|
|
1973
2016
|
function warn_misrouted(seen, stream, handler, event) {
|
|
1974
2017
|
report_once(
|
|
1975
2018
|
seen,
|
|
@@ -1977,7 +2020,7 @@ function warn_misrouted(seen, stream, handler, event) {
|
|
|
1977
2020
|
`Reaction "${handler}" on "${event}" resolved to target "${stream}", which a projection already serves. A target is served by one batch handler or one state projection, so this reaction can never run \u2014 and delivering to it would hand the projection an aggregate from another stream. Skipping it. The equivalent static \`.to({ target })\` is rejected at build; a dynamic resolver's target is only knowable here.`
|
|
1978
2021
|
);
|
|
1979
2022
|
}
|
|
1980
|
-
|
|
2023
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, warn_misrouted, "warn_misrouted");
|
|
1981
2024
|
async function run_drain_cycle(deps, cycle) {
|
|
1982
2025
|
const { ops, registry, batch_handlers, handle, handle_batch, lane } = deps;
|
|
1983
2026
|
const {
|
|
@@ -1999,7 +2042,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
1999
2042
|
const fetched = await ops.fetch(leased, eventLimit);
|
|
2000
2043
|
const fetch_map = /* @__PURE__ */ new Map();
|
|
2001
2044
|
const fetch_window_at = fetched.reduce(
|
|
2002
|
-
(max, { at, events }) => Math.max(max, _optionalChain([events, 'access',
|
|
2045
|
+
(max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _110 => _110.at, 'call', _111 => _111(-1), 'optionalAccess', _112 => _112.id]) || at),
|
|
2003
2046
|
0
|
|
2004
2047
|
);
|
|
2005
2048
|
for (const f of fetched) {
|
|
@@ -2063,11 +2106,11 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2063
2106
|
deps.logger
|
|
2064
2107
|
)
|
|
2065
2108
|
);
|
|
2066
|
-
const at = _optionalChain([entry, 'access',
|
|
2109
|
+
const at = _optionalChain([entry, 'access', _113 => _113.fetch, 'access', _114 => _114.events, 'access', _115 => _115.at, 'call', _116 => _116(-1), 'optionalAccess', _117 => _117.id]) || fetch_window_at;
|
|
2067
2110
|
const { payloads } = entry;
|
|
2068
2111
|
const exhausted = budget_exhausted(
|
|
2069
2112
|
lease,
|
|
2070
|
-
_optionalChain([payloads, 'access',
|
|
2113
|
+
_optionalChain([payloads, 'access', _118 => _118[0], 'optionalAccess', _119 => _119.options]),
|
|
2071
2114
|
store_failing
|
|
2072
2115
|
);
|
|
2073
2116
|
if (exhausted) return Promise.resolve(exhausted);
|
|
@@ -2088,13 +2131,13 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2088
2131
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2089
2132
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2090
2133
|
if (acked.length < expected)
|
|
2091
|
-
|
|
2134
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).warn(
|
|
2092
2135
|
`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.`
|
|
2093
2136
|
);
|
|
2094
2137
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
2095
2138
|
return { leased, fetched, handled, acked, blocked, closeable };
|
|
2096
2139
|
}
|
|
2097
|
-
|
|
2140
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, run_drain_cycle, "run_drain_cycle");
|
|
2098
2141
|
var EMPTY_DRAIN = {
|
|
2099
2142
|
fetched: [],
|
|
2100
2143
|
leased: [],
|
|
@@ -2109,11 +2152,11 @@ function merge_drains(drains) {
|
|
|
2109
2152
|
blocked: drains.flatMap((d) => d.blocked)
|
|
2110
2153
|
};
|
|
2111
2154
|
}
|
|
2112
|
-
|
|
2155
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_drains, "merge_drains");
|
|
2113
2156
|
var RETRY = "";
|
|
2114
2157
|
var DrainController = (_class3 = class {
|
|
2115
2158
|
static {
|
|
2116
|
-
|
|
2159
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "DrainController");
|
|
2117
2160
|
}
|
|
2118
2161
|
// Armed while `_raised` is ahead of `_lowered` (the raise count the last
|
|
2119
2162
|
// empty claim saw), so a claim never lowers over a raise that landed
|
|
@@ -2157,7 +2200,7 @@ var DrainController = (_class3 = class {
|
|
|
2157
2200
|
}
|
|
2158
2201
|
/** This lane's configured lease, or `undefined`; the shutdown grace basis. */
|
|
2159
2202
|
get lease_millis() {
|
|
2160
|
-
return _optionalChain([this, 'access',
|
|
2203
|
+
return _optionalChain([this, 'access', _120 => _120._deps, 'access', _121 => _121.defaults, 'optionalAccess', _122 => _122.leaseMillis]);
|
|
2161
2204
|
}
|
|
2162
2205
|
get lane() {
|
|
2163
2206
|
return this._deps.lane;
|
|
@@ -2168,7 +2211,7 @@ var DrainController = (_class3 = class {
|
|
|
2168
2211
|
*/
|
|
2169
2212
|
start(cycleMs) {
|
|
2170
2213
|
const run = this._deps.run_scoped;
|
|
2171
|
-
const tick = /* @__PURE__ */
|
|
2214
|
+
const tick = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async () => {
|
|
2172
2215
|
if (this.armed) await run(() => this.drain());
|
|
2173
2216
|
if (this._stopped) return;
|
|
2174
2217
|
this._worker = setTimeout(tick, cycleMs);
|
|
@@ -2189,9 +2232,9 @@ var DrainController = (_class3 = class {
|
|
|
2189
2232
|
if (!this.armed || this._stopped || this._inflight)
|
|
2190
2233
|
return EMPTY_DRAIN;
|
|
2191
2234
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2192
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2193
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2194
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2235
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkWDIBO6AWcjs.DEFAULT_STREAM_LIMIT));
|
|
2236
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkWDIBO6AWcjs.DEFAULT_EVENT_LIMIT));
|
|
2237
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkWDIBO6AWcjs.DEFAULT_LEASE_MILLIS));
|
|
2195
2238
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2196
2239
|
return EMPTY_DRAIN;
|
|
2197
2240
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2252,7 +2295,7 @@ var DrainController = (_class3 = class {
|
|
|
2252
2295
|
// src/internal/reaction-dispatch.ts
|
|
2253
2296
|
var CloseSignal = class extends Error {
|
|
2254
2297
|
static {
|
|
2255
|
-
|
|
2298
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "CloseSignal");
|
|
2256
2299
|
}
|
|
2257
2300
|
/**
|
|
2258
2301
|
* Stream to close. Omitted → the reaction's own lease stream (a self-close).
|
|
@@ -2286,11 +2329,11 @@ var CloseSignal = class extends Error {
|
|
|
2286
2329
|
constructor(opts) {
|
|
2287
2330
|
super("reaction requested close");
|
|
2288
2331
|
this.name = "CloseSignal";
|
|
2289
|
-
this.stream = _optionalChain([opts, 'optionalAccess',
|
|
2290
|
-
this.archive = _optionalChain([opts, 'optionalAccess',
|
|
2291
|
-
this.at = _optionalChain([opts, 'optionalAccess',
|
|
2292
|
-
this.before = _optionalChain([opts, 'optionalAccess',
|
|
2293
|
-
this.defer = _optionalChain([opts, 'optionalAccess',
|
|
2332
|
+
this.stream = _optionalChain([opts, 'optionalAccess', _123 => _123.stream]);
|
|
2333
|
+
this.archive = _optionalChain([opts, 'optionalAccess', _124 => _124.archive]);
|
|
2334
|
+
this.at = _optionalChain([opts, 'optionalAccess', _125 => _125.at]);
|
|
2335
|
+
this.before = _optionalChain([opts, 'optionalAccess', _126 => _126.before]);
|
|
2336
|
+
this.defer = _optionalChain([opts, 'optionalAccess', _127 => _127.defer]);
|
|
2294
2337
|
}
|
|
2295
2338
|
};
|
|
2296
2339
|
function build_handle(deps) {
|
|
@@ -2320,7 +2363,7 @@ function build_handle(deps) {
|
|
|
2320
2363
|
handled++;
|
|
2321
2364
|
}
|
|
2322
2365
|
} catch (error) {
|
|
2323
|
-
if (error instanceof
|
|
2366
|
+
if (error instanceof _chunkUEGKXCSQcjs.DeferSignal) {
|
|
2324
2367
|
let defer;
|
|
2325
2368
|
try {
|
|
2326
2369
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2344,7 +2387,7 @@ function build_handle(deps) {
|
|
|
2344
2387
|
// Advance to the live head the handler evaluated against (when
|
|
2345
2388
|
// provided) so the close-cycle guard sees this reaction caught up.
|
|
2346
2389
|
acked_at: _nullishCoalesce(error.at, () => ( event.id)),
|
|
2347
|
-
defer: _optionalChain([error, 'access',
|
|
2390
|
+
defer: _optionalChain([error, 'access', _128 => _128.defer, 'optionalAccess', _129 => _129.getTime, 'call', _130 => _130()]),
|
|
2348
2391
|
// Close the signalled stream (the autoclose reaction's aggregate,
|
|
2349
2392
|
// which differs from its synthetic lease stream); a self-closing
|
|
2350
2393
|
// user reaction omits it and closes its own lease stream. A
|
|
@@ -2369,7 +2412,7 @@ function build_handle(deps) {
|
|
|
2369
2412
|
return finalize(lease, handled, at, void 0, payloads[0].options, logger);
|
|
2370
2413
|
};
|
|
2371
2414
|
}
|
|
2372
|
-
|
|
2415
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, build_handle, "build_handle");
|
|
2373
2416
|
function build_handle_batch(logger) {
|
|
2374
2417
|
return async (lease, payloads, batchHandler) => {
|
|
2375
2418
|
const stream = lease.stream;
|
|
@@ -2398,7 +2441,7 @@ function build_handle_batch(logger) {
|
|
|
2398
2441
|
}
|
|
2399
2442
|
};
|
|
2400
2443
|
}
|
|
2401
|
-
|
|
2444
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, build_handle_batch, "build_handle_batch");
|
|
2402
2445
|
|
|
2403
2446
|
// src/internal/autoclose-reaction.ts
|
|
2404
2447
|
var AUTOCLOSE_TARGET_PREFIX = "__autoclose__:";
|
|
@@ -2419,22 +2462,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2419
2462
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2420
2463
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2421
2464
|
// autoclose: `app.close` still closes it.
|
|
2422
|
-
resolver: /* @__PURE__ */
|
|
2465
|
+
resolver: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (e) => _chunkDCWPJFXRcjs.isStreamName.call(void 0, e.stream) ? {
|
|
2423
2466
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2424
2467
|
source: e.stream
|
|
2425
2468
|
} : void 0, "resolver"),
|
|
2426
2469
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2427
2470
|
// not quarantine the synthetic stream.
|
|
2428
|
-
options: { blockOnError: false, maxRetries:
|
|
2429
|
-
handler: /* @__PURE__ */
|
|
2471
|
+
options: { blockOnError: false, maxRetries: _chunkWDIBO6AWcjs.DEFAULT_MAX_RETRIES },
|
|
2472
|
+
handler: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async (event) => {
|
|
2430
2473
|
const aggregate = event.stream;
|
|
2431
2474
|
const window = read_window();
|
|
2432
2475
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2433
|
-
throw new (0,
|
|
2434
|
-
const stats = await
|
|
2476
|
+
throw new (0, _chunkUEGKXCSQcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2477
|
+
const stats = await _chunkWDIBO6AWcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2435
2478
|
count: true,
|
|
2436
2479
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2437
|
-
exclude: [
|
|
2480
|
+
exclude: [_chunkUEGKXCSQcjs.TOMBSTONE_EVENT, _chunkUEGKXCSQcjs.SNAP_EVENT]
|
|
2438
2481
|
});
|
|
2439
2482
|
const entry = stats.get(aggregate);
|
|
2440
2483
|
if (!entry) return;
|
|
@@ -2472,19 +2515,19 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2472
2515
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2473
2516
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2474
2517
|
if (future.length)
|
|
2475
|
-
throw new (0,
|
|
2518
|
+
throw new (0, _chunkUEGKXCSQcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2476
2519
|
}, "handler")
|
|
2477
2520
|
};
|
|
2478
2521
|
const key = `__autoclose_${st.name}`;
|
|
2479
2522
|
for (const event_name of Object.keys(st.events)) {
|
|
2480
|
-
_optionalChain([registry, 'access',
|
|
2523
|
+
_optionalChain([registry, 'access', _131 => _131.events, 'access', _132 => _132[event_name], 'optionalAccess', _133 => _133.reactions, 'access', _134 => _134.set, 'call', _135 => _135(
|
|
2481
2524
|
key,
|
|
2482
2525
|
reaction
|
|
2483
2526
|
)]);
|
|
2484
2527
|
}
|
|
2485
2528
|
}
|
|
2486
2529
|
}
|
|
2487
|
-
|
|
2530
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, synthesize_autoclose_reactions, "synthesize_autoclose_reactions");
|
|
2488
2531
|
|
|
2489
2532
|
// src/internal/close-cycle.ts
|
|
2490
2533
|
var CLOSE_CATCH_UP_LIMIT = 1e3;
|
|
@@ -2498,10 +2541,10 @@ async function catch_up_correlation(cursor, correlate, until) {
|
|
|
2498
2541
|
}
|
|
2499
2542
|
return cursor.checkpoint;
|
|
2500
2543
|
}
|
|
2501
|
-
|
|
2544
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, catch_up_correlation, "catch_up_correlation");
|
|
2502
2545
|
var CloseLock = (_class4 = class {constructor() { _class4.prototype.__init9.call(this); }
|
|
2503
2546
|
static {
|
|
2504
|
-
|
|
2547
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "CloseLock");
|
|
2505
2548
|
}
|
|
2506
2549
|
__init9() {this._tails = /* @__PURE__ */ new Map()}
|
|
2507
2550
|
/** Run `work` after every earlier close of `stream` has settled. */
|
|
@@ -2509,7 +2552,7 @@ var CloseLock = (_class4 = class {constructor() { _class4.prototype.__init9.call
|
|
|
2509
2552
|
const prev = _nullishCoalesce(this._tails.get(stream), () => ( Promise.resolve()));
|
|
2510
2553
|
const next = prev.then(work, work);
|
|
2511
2554
|
this._tails.set(stream, next);
|
|
2512
|
-
const cleanup = /* @__PURE__ */
|
|
2555
|
+
const cleanup = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => {
|
|
2513
2556
|
if (this._tails.get(stream) === next) this._tails.delete(stream);
|
|
2514
2557
|
}, "cleanup");
|
|
2515
2558
|
next.then(cleanup, cleanup);
|
|
@@ -2537,12 +2580,12 @@ async function run_close_cycle(targets, deps) {
|
|
|
2537
2580
|
deps,
|
|
2538
2581
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2539
2582
|
);
|
|
2540
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2541
|
-
if (retired.length) _optionalChain([deps, 'access',
|
|
2583
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkUEGKXCSQcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2584
|
+
if (retired.length) _optionalChain([deps, 'access', _136 => _136.forget_subscribed, 'optionalCall', _137 => _137(retired)]);
|
|
2542
2585
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2543
2586
|
return { truncated, skipped };
|
|
2544
2587
|
}
|
|
2545
|
-
|
|
2588
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, run_close_cycle, "run_close_cycle");
|
|
2546
2589
|
function with_stream_locks(streams, deps, work) {
|
|
2547
2590
|
const with_lock = _nullishCoalesce(deps.with_stream_lock, () => ( ((_stream, w) => w())));
|
|
2548
2591
|
return [...streams].sort().reduceRight(
|
|
@@ -2550,7 +2593,7 @@ function with_stream_locks(streams, deps, work) {
|
|
|
2550
2593
|
work
|
|
2551
2594
|
)();
|
|
2552
2595
|
}
|
|
2553
|
-
|
|
2596
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, with_stream_locks, "with_stream_locks");
|
|
2554
2597
|
async function run_full_closes(full, target_map, deps, skipped) {
|
|
2555
2598
|
const none = /* @__PURE__ */ new Map();
|
|
2556
2599
|
const streams = full.map((t) => t.stream);
|
|
@@ -2560,7 +2603,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
|
|
|
2560
2603
|
const info = stream_info.get(target.stream);
|
|
2561
2604
|
if (!info) continue;
|
|
2562
2605
|
const owner = deps.event_to_state.get(info.last_event_name);
|
|
2563
|
-
if (_optionalChain([owner, 'optionalAccess',
|
|
2606
|
+
if (_optionalChain([owner, 'optionalAccess', _138 => _138.pii_aware])) {
|
|
2564
2607
|
deps.logger.error(
|
|
2565
2608
|
`Refusing to close "${target.stream}" with restart: state "${owner.name}" carries sensitive fields, so a restart seed would persist redacted values while deleting the originals. Close it without restart to retire the stream, or leave it open.`
|
|
2566
2609
|
);
|
|
@@ -2606,7 +2649,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
|
|
|
2606
2649
|
deps.correlation
|
|
2607
2650
|
);
|
|
2608
2651
|
}
|
|
2609
|
-
|
|
2652
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, run_full_closes, "run_full_closes");
|
|
2610
2653
|
async function run_windowed_closes(windowed, deps, skipped) {
|
|
2611
2654
|
const checkpoint = deps.reactive ? await deps.catch_up_correlation(Number.MAX_SAFE_INTEGER) : -1;
|
|
2612
2655
|
const min_at = deps.reactive ? await probe_min_watermarks(
|
|
@@ -2622,7 +2665,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2622
2665
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2623
2666
|
return void 0;
|
|
2624
2667
|
if (t.archive) await t.archive();
|
|
2625
|
-
const result = await
|
|
2668
|
+
const result = await _chunkWDIBO6AWcjs.store.call(void 0, ).truncate([
|
|
2626
2669
|
{ stream: t.stream, before: t.before, max_id }
|
|
2627
2670
|
]);
|
|
2628
2671
|
return result.get(t.stream);
|
|
@@ -2632,26 +2675,26 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2632
2675
|
}
|
|
2633
2676
|
return truncated;
|
|
2634
2677
|
}
|
|
2635
|
-
|
|
2678
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, run_windowed_closes, "run_windowed_closes");
|
|
2636
2679
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2637
2680
|
let boundary_id;
|
|
2638
2681
|
let min_id;
|
|
2639
|
-
await
|
|
2682
|
+
await _chunkWDIBO6AWcjs.store.call(void 0, ).query(
|
|
2640
2683
|
(event) => {
|
|
2641
2684
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2642
|
-
if (event.name ===
|
|
2685
|
+
if (event.name === _chunkUEGKXCSQcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
2643
2686
|
boundary_id = event.id;
|
|
2644
2687
|
},
|
|
2645
2688
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
2646
2689
|
);
|
|
2647
2690
|
return boundary_id !== void 0 && min_id < boundary_id;
|
|
2648
2691
|
}
|
|
2649
|
-
|
|
2692
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, windowed_prune_pending, "windowed_prune_pending");
|
|
2650
2693
|
async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
2651
2694
|
const min_at = /* @__PURE__ */ new Map();
|
|
2652
2695
|
const matches = source_matcher();
|
|
2653
2696
|
await walk_streams(
|
|
2654
|
-
|
|
2697
|
+
_chunkWDIBO6AWcjs.store.call(void 0, ),
|
|
2655
2698
|
(position) => {
|
|
2656
2699
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2657
2700
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2666,12 +2709,12 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2666
2709
|
);
|
|
2667
2710
|
return min_at;
|
|
2668
2711
|
}
|
|
2669
|
-
|
|
2712
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, probe_min_watermarks, "probe_min_watermarks");
|
|
2670
2713
|
function source_matcher() {
|
|
2671
2714
|
const compiled = /* @__PURE__ */ new Map();
|
|
2672
2715
|
return (source, target, stream) => {
|
|
2673
2716
|
if (!source) return true;
|
|
2674
|
-
if (
|
|
2717
|
+
if (_chunkDCWPJFXRcjs.isStreamName.call(void 0, source, target)) return source === stream;
|
|
2675
2718
|
let re = compiled.get(source);
|
|
2676
2719
|
if (!re) {
|
|
2677
2720
|
re = new RegExp(source);
|
|
@@ -2680,19 +2723,19 @@ function source_matcher() {
|
|
|
2680
2723
|
return re.test(stream);
|
|
2681
2724
|
};
|
|
2682
2725
|
}
|
|
2683
|
-
|
|
2726
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, source_matcher, "source_matcher");
|
|
2684
2727
|
async function scan_stream_heads(streams) {
|
|
2685
|
-
const stats = await
|
|
2686
|
-
exclude: [
|
|
2728
|
+
const stats = await _chunkWDIBO6AWcjs.store.call(void 0, ).query_stats(streams, {
|
|
2729
|
+
exclude: [_chunkUEGKXCSQcjs.SNAP_EVENT]
|
|
2687
2730
|
});
|
|
2688
|
-
const domain_heads = await
|
|
2689
|
-
exclude: [
|
|
2731
|
+
const domain_heads = await _chunkWDIBO6AWcjs.store.call(void 0, ).query_stats(streams, {
|
|
2732
|
+
exclude: [_chunkUEGKXCSQcjs.SNAP_EVENT, _chunkUEGKXCSQcjs.TOMBSTONE_EVENT]
|
|
2690
2733
|
});
|
|
2691
|
-
const true_heads = await
|
|
2734
|
+
const true_heads = await _chunkWDIBO6AWcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2692
2735
|
const out = /* @__PURE__ */ new Map();
|
|
2693
2736
|
for (const [stream, { head }] of domain_heads) {
|
|
2694
|
-
const marker_head = _optionalChain([stats, 'access',
|
|
2695
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess',
|
|
2737
|
+
const marker_head = _optionalChain([stats, 'access', _139 => _139.get, 'call', _140 => _140(stream), 'optionalAccess', _141 => _141.head]);
|
|
2738
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _142 => _142.name]) === _chunkUEGKXCSQcjs.TOMBSTONE_EVENT;
|
|
2696
2739
|
out.set(stream, {
|
|
2697
2740
|
max_id: head.id,
|
|
2698
2741
|
version: true_heads.get(stream).head.version,
|
|
@@ -2702,7 +2745,7 @@ async function scan_stream_heads(streams) {
|
|
|
2702
2745
|
}
|
|
2703
2746
|
return out;
|
|
2704
2747
|
}
|
|
2705
|
-
|
|
2748
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, scan_stream_heads, "scan_stream_heads");
|
|
2706
2749
|
async function partition_by_safety(stream_info, reactive, skipped, page_size, catch_up_correlation2) {
|
|
2707
2750
|
if (!reactive) return [...stream_info.keys()];
|
|
2708
2751
|
let needed = -1;
|
|
@@ -2716,7 +2759,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2716
2759
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2717
2760
|
const matches = source_matcher();
|
|
2718
2761
|
await walk_streams(
|
|
2719
|
-
|
|
2762
|
+
_chunkWDIBO6AWcjs.store.call(void 0, ),
|
|
2720
2763
|
(position) => {
|
|
2721
2764
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2722
2765
|
if (!has_work) return;
|
|
@@ -2736,7 +2779,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2736
2779
|
}
|
|
2737
2780
|
return safe;
|
|
2738
2781
|
}
|
|
2739
|
-
|
|
2782
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, partition_by_safety, "partition_by_safety");
|
|
2740
2783
|
async function guard_with_tombstones(safe, stream_info, correlation, tombstone2, skipped) {
|
|
2741
2784
|
const guarded = [];
|
|
2742
2785
|
const guard_events = /* @__PURE__ */ new Map();
|
|
@@ -2759,11 +2802,11 @@ async function guard_with_tombstones(safe, stream_info, correlation, tombstone2,
|
|
|
2759
2802
|
);
|
|
2760
2803
|
return { guarded, guard_events };
|
|
2761
2804
|
}
|
|
2762
|
-
|
|
2805
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, guard_with_tombstones, "guard_with_tombstones");
|
|
2763
2806
|
async function load_restart_seeds(guarded, target_map, stream_info, event_to_state, load2, logger) {
|
|
2764
2807
|
const seed_states = /* @__PURE__ */ new Map();
|
|
2765
2808
|
await Promise.all(
|
|
2766
|
-
guarded.filter((s) => _optionalChain([target_map, 'access',
|
|
2809
|
+
guarded.filter((s) => _optionalChain([target_map, 'access', _143 => _143.get, 'call', _144 => _144(s), 'optionalAccess', _145 => _145.restart])).map(async (stream) => {
|
|
2767
2810
|
const last_event_name = stream_info.get(stream).last_event_name;
|
|
2768
2811
|
const owner_state = event_to_state.get(last_event_name);
|
|
2769
2812
|
if (!owner_state) {
|
|
@@ -2778,24 +2821,24 @@ async function load_restart_seeds(guarded, target_map, stream_info, event_to_sta
|
|
|
2778
2821
|
);
|
|
2779
2822
|
return seed_states;
|
|
2780
2823
|
}
|
|
2781
|
-
|
|
2824
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, load_restart_seeds, "load_restart_seeds");
|
|
2782
2825
|
async function run_archive_callbacks(guarded, target_map) {
|
|
2783
2826
|
for (const stream of guarded) {
|
|
2784
|
-
const archive_fn = _optionalChain([target_map, 'access',
|
|
2827
|
+
const archive_fn = _optionalChain([target_map, 'access', _146 => _146.get, 'call', _147 => _147(stream), 'optionalAccess', _148 => _148.archive]);
|
|
2785
2828
|
if (archive_fn) await archive_fn();
|
|
2786
2829
|
}
|
|
2787
2830
|
}
|
|
2788
|
-
|
|
2831
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, run_archive_callbacks, "run_archive_callbacks");
|
|
2789
2832
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2790
|
-
const heads = await
|
|
2833
|
+
const heads = await _chunkWDIBO6AWcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2791
2834
|
return guarded.filter((stream) => {
|
|
2792
|
-
if (_optionalChain([heads, 'access',
|
|
2835
|
+
if (_optionalChain([heads, 'access', _149 => _149.get, 'call', _150 => _150(stream), 'optionalAccess', _151 => _151.head, 'access', _152 => _152.id]) === guard_events.get(stream).id)
|
|
2793
2836
|
return true;
|
|
2794
2837
|
skipped.push(stream);
|
|
2795
2838
|
return false;
|
|
2796
2839
|
});
|
|
2797
2840
|
}
|
|
2798
|
-
|
|
2841
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, heads_still_guarded, "heads_still_guarded");
|
|
2799
2842
|
async function truncate_and_warm_cache(guarded, seed_states, guard_events, correlation) {
|
|
2800
2843
|
const trunc_targets = guarded.map((stream) => {
|
|
2801
2844
|
const snapshot = seed_states.get(stream);
|
|
@@ -2806,18 +2849,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2806
2849
|
meta: {
|
|
2807
2850
|
correlation,
|
|
2808
2851
|
causation: {
|
|
2809
|
-
event: { id: guard.id, name:
|
|
2852
|
+
event: { id: guard.id, name: _chunkUEGKXCSQcjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2810
2853
|
}
|
|
2811
2854
|
}
|
|
2812
2855
|
};
|
|
2813
2856
|
});
|
|
2814
|
-
const truncated = await
|
|
2857
|
+
const truncated = await _chunkWDIBO6AWcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2815
2858
|
await Promise.all(
|
|
2816
2859
|
guarded.map(async (stream) => {
|
|
2817
2860
|
const entry = truncated.get(stream);
|
|
2818
2861
|
const state2 = seed_states.get(stream);
|
|
2819
2862
|
if (state2 && entry) {
|
|
2820
|
-
await
|
|
2863
|
+
await _chunkWDIBO6AWcjs.cache.call(void 0, ).set(stream, {
|
|
2821
2864
|
stream,
|
|
2822
2865
|
state: state2,
|
|
2823
2866
|
version: entry.committed.version,
|
|
@@ -2826,19 +2869,19 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2826
2869
|
snaps: 1
|
|
2827
2870
|
});
|
|
2828
2871
|
} else {
|
|
2829
|
-
await
|
|
2872
|
+
await _chunkWDIBO6AWcjs.cache.call(void 0, ).invalidate(stream);
|
|
2830
2873
|
}
|
|
2831
2874
|
})
|
|
2832
2875
|
);
|
|
2833
2876
|
return truncated;
|
|
2834
2877
|
}
|
|
2835
|
-
|
|
2878
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, truncate_and_warm_cache, "truncate_and_warm_cache");
|
|
2836
2879
|
|
|
2837
2880
|
// src/internal/correlate-cycle.ts
|
|
2838
2881
|
|
|
2839
2882
|
var COLD_START_BACK_SCAN = 1e4;
|
|
2840
2883
|
var CORRELATION_LEASE_MS = 5e3;
|
|
2841
|
-
var registry_key = /* @__PURE__ */
|
|
2884
|
+
var registry_key = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (events) => {
|
|
2842
2885
|
const shape = Object.keys(events).filter((name) => events[name].reactions.size > 0).sort().map((name) => [name, [...events[name].reactions.keys()].sort()]);
|
|
2843
2886
|
return _crypto.createHash.call(void 0, "sha256").update(JSON.stringify(shape)).digest("hex").slice(0, 32);
|
|
2844
2887
|
}, "registry_key");
|
|
@@ -2850,7 +2893,7 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
|
|
|
2850
2893
|
`Reaction "${handler}" resolved onto undeclared lane "${lane}" \u2014 for example target "${target}". Declared lanes: ${[...declared].map((l) => `"${l}"`).join(", ")}. No controller claims it, so the stream would never drain \u2014 running it on "default" instead. The equivalent static \`.to({ lane })\` is rejected at build; a dynamic resolver's lane is only knowable here.`
|
|
2851
2894
|
);
|
|
2852
2895
|
}
|
|
2853
|
-
|
|
2896
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, report_undeclared_lane, "report_undeclared_lane");
|
|
2854
2897
|
function report_bad_priority(seen, handler, target, priority) {
|
|
2855
2898
|
report_once(
|
|
2856
2899
|
seen,
|
|
@@ -2858,7 +2901,7 @@ function report_bad_priority(seen, handler, target, priority) {
|
|
|
2858
2901
|
`Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer. Running it at priority 0 instead. The equivalent static \`.to({ priority })\` is rejected at build; a dynamic resolver's priority is only knowable here.`
|
|
2859
2902
|
);
|
|
2860
2903
|
}
|
|
2861
|
-
|
|
2904
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, report_bad_priority, "report_bad_priority");
|
|
2862
2905
|
function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
2863
2906
|
report_once(
|
|
2864
2907
|
seen,
|
|
@@ -2866,10 +2909,10 @@ function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
|
2866
2909
|
`Reaction "${handler}" resolved lane "${dropped}" for a stream already on "${kept}" \u2014 for example "${target}". These are conflicting lane assignments from two dynamic resolutions at equal priority. Keeping "${kept}", the lane it was first discovered on \u2014 re-laning a live stream would move it out from under a worker holding its lease. The reaction resolving "${dropped}" runs inside the "${kept}" lane's budget, and a process restricted to "${dropped}" via onlyLanes never runs it. The equivalent static declaration is rejected at build; align the resolvers, or split the target.`
|
|
2867
2910
|
);
|
|
2868
2911
|
}
|
|
2869
|
-
|
|
2912
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, report_lane_conflict, "report_lane_conflict");
|
|
2870
2913
|
var CorrelateCycle = (_class5 = class {
|
|
2871
2914
|
static {
|
|
2872
|
-
|
|
2915
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "CorrelateCycle");
|
|
2873
2916
|
}
|
|
2874
2917
|
__init10() {this._checkpoint = -1}
|
|
2875
2918
|
// Lease holder id; per instance, so a restart never inherits a stale claim.
|
|
@@ -2892,7 +2935,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2892
2935
|
// never lets a resolution re-lane them.
|
|
2893
2936
|
|
|
2894
2937
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2895
|
-
__init19() {this._patterns = new (0,
|
|
2938
|
+
__init19() {this._patterns = new (0, _chunkWDIBO6AWcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2896
2939
|
|
|
2897
2940
|
|
|
2898
2941
|
|
|
@@ -2910,7 +2953,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2910
2953
|
on_init
|
|
2911
2954
|
}) {;_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);
|
|
2912
2955
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2913
|
-
this._dynamic_subscriptions = new (0,
|
|
2956
|
+
this._dynamic_subscriptions = new (0, _chunkWDIBO6AWcjs.LruMap)(max_subscribed_streams);
|
|
2914
2957
|
this._registry = registry;
|
|
2915
2958
|
this._declared_lanes = declared_lanes;
|
|
2916
2959
|
this._static_targets = static_targets;
|
|
@@ -2942,7 +2985,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2942
2985
|
lane
|
|
2943
2986
|
});
|
|
2944
2987
|
}
|
|
2945
|
-
await _optionalChain([this, 'access',
|
|
2988
|
+
await _optionalChain([this, 'access', _153 => _153._on_init, 'optionalCall', _154 => _154()]);
|
|
2946
2989
|
}
|
|
2947
2990
|
/**
|
|
2948
2991
|
* Replace the log with no pass in flight, then cold-start: a pass that
|
|
@@ -2968,7 +3011,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2968
3011
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
2969
3012
|
_in_fetch_window(source, stream) {
|
|
2970
3013
|
if (source === void 0 || source === stream) return true;
|
|
2971
|
-
if (
|
|
3014
|
+
if (_chunkDCWPJFXRcjs.isStreamName.call(void 0, source)) return false;
|
|
2972
3015
|
let pattern = this._patterns.get(source);
|
|
2973
3016
|
if (!pattern) {
|
|
2974
3017
|
pattern = new RegExp(source);
|
|
@@ -2990,7 +3033,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2990
3033
|
async _scan(limit, lease) {
|
|
2991
3034
|
await this._init();
|
|
2992
3035
|
const epoch = this._epoch;
|
|
2993
|
-
const idle = /* @__PURE__ */
|
|
3036
|
+
const idle = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => ({
|
|
2994
3037
|
kind: "idle",
|
|
2995
3038
|
last_id: this._checkpoint
|
|
2996
3039
|
}), "idle");
|
|
@@ -3011,7 +3054,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3011
3054
|
const correlated = /* @__PURE__ */ new Map();
|
|
3012
3055
|
let last_id = after;
|
|
3013
3056
|
let stopped = false;
|
|
3014
|
-
const found = await
|
|
3057
|
+
const found = await _chunkWDIBO6AWcjs.store.call(void 0, ).query(
|
|
3015
3058
|
(event) => {
|
|
3016
3059
|
if (stopped) return;
|
|
3017
3060
|
const register = this._registry.events[event.name];
|
|
@@ -3031,7 +3074,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3031
3074
|
}
|
|
3032
3075
|
if (!resolved) continue;
|
|
3033
3076
|
try {
|
|
3034
|
-
|
|
3077
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "target", resolved);
|
|
3035
3078
|
} catch (e2) {
|
|
3036
3079
|
report_bad_priority(
|
|
3037
3080
|
this._reported,
|
|
@@ -3067,9 +3110,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3067
3110
|
correlated_at: void 0
|
|
3068
3111
|
};
|
|
3069
3112
|
const seen_in_scan = correlated.has(resolved.target);
|
|
3070
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess',
|
|
3071
|
-
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess',
|
|
3072
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
3113
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _155 => _155.lane])), () => ( _chunkUEGKXCSQcjs.DEFAULT_LANE));
|
|
3114
|
+
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _156 => _156.priority]);
|
|
3115
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkUEGKXCSQcjs.DEFAULT_LANE));
|
|
3073
3116
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
3074
3117
|
report_lane_conflict(
|
|
3075
3118
|
this._reported,
|
|
@@ -3123,7 +3166,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3123
3166
|
).length;
|
|
3124
3167
|
this._checkpoint = last_id;
|
|
3125
3168
|
for (const { stream, priority, lane } of streams) {
|
|
3126
|
-
if (_optionalChain([correlated, 'access',
|
|
3169
|
+
if (_optionalChain([correlated, 'access', _157 => _157.get, 'call', _158 => _158(stream), 'optionalAccess', _159 => _159.upgraded]))
|
|
3127
3170
|
this._dynamic_subscriptions.set(stream, {
|
|
3128
3171
|
priority,
|
|
3129
3172
|
lane
|
|
@@ -3143,7 +3186,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3143
3186
|
await Promise.all(
|
|
3144
3187
|
missed.map(async ([stream, entry]) => {
|
|
3145
3188
|
let row;
|
|
3146
|
-
await
|
|
3189
|
+
await _chunkWDIBO6AWcjs.store.call(void 0, ).query_streams(
|
|
3147
3190
|
(position) => {
|
|
3148
3191
|
row = position;
|
|
3149
3192
|
},
|
|
@@ -3155,8 +3198,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3155
3198
|
lane: row.lane
|
|
3156
3199
|
});
|
|
3157
3200
|
if (entry.priority > row.priority) return;
|
|
3158
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3159
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3201
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkUEGKXCSQcjs.DEFAULT_LANE));
|
|
3202
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkUEGKXCSQcjs.DEFAULT_LANE));
|
|
3160
3203
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3161
3204
|
report_lane_conflict(
|
|
3162
3205
|
this._reported,
|
|
@@ -3182,7 +3225,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3182
3225
|
millis: 0
|
|
3183
3226
|
});
|
|
3184
3227
|
} catch (error) {
|
|
3185
|
-
|
|
3228
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).warn(
|
|
3186
3229
|
`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)))}`
|
|
3187
3230
|
);
|
|
3188
3231
|
}
|
|
@@ -3201,13 +3244,13 @@ function pii_split(emitted, fields) {
|
|
|
3201
3244
|
}
|
|
3202
3245
|
return { name: emitted.name, data, pii };
|
|
3203
3246
|
}
|
|
3204
|
-
|
|
3247
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, pii_split, "pii_split");
|
|
3205
3248
|
function pii_gate(event, fields, predicate, actor) {
|
|
3206
3249
|
const data = event.data;
|
|
3207
3250
|
const { pii, ...rest } = event;
|
|
3208
3251
|
if (pii == null) {
|
|
3209
3252
|
const shredded = { ...data };
|
|
3210
|
-
for (const f of fields) shredded[f] =
|
|
3253
|
+
for (const f of fields) shredded[f] = _chunkUEGKXCSQcjs.SHREDDED;
|
|
3211
3254
|
return { ...rest, data: shredded };
|
|
3212
3255
|
}
|
|
3213
3256
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3218,15 +3261,15 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3218
3261
|
};
|
|
3219
3262
|
}
|
|
3220
3263
|
const redacted = { ...data };
|
|
3221
|
-
for (const f of fields) redacted[f] =
|
|
3264
|
+
for (const f of fields) redacted[f] = _chunkUEGKXCSQcjs.REDACTED;
|
|
3222
3265
|
return { ...rest, data: redacted };
|
|
3223
3266
|
}
|
|
3224
|
-
|
|
3225
|
-
var IDENTITY_GATE = /* @__PURE__ */
|
|
3267
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, pii_gate, "pii_gate");
|
|
3268
|
+
var IDENTITY_GATE = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (event) => event, "IDENTITY_GATE");
|
|
3226
3269
|
function make_gate(fields, predicate) {
|
|
3227
3270
|
return (event, actor) => pii_gate(event, fields, predicate, actor);
|
|
3228
3271
|
}
|
|
3229
|
-
|
|
3272
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, make_gate, "make_gate");
|
|
3230
3273
|
function pii_strip(event, fields) {
|
|
3231
3274
|
const data = event.data;
|
|
3232
3275
|
const stripped = {};
|
|
@@ -3239,22 +3282,22 @@ function pii_strip(event, fields) {
|
|
|
3239
3282
|
data: stripped
|
|
3240
3283
|
};
|
|
3241
3284
|
}
|
|
3242
|
-
|
|
3285
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, pii_strip, "pii_strip");
|
|
3243
3286
|
|
|
3244
3287
|
// src/internal/projection-fold.ts
|
|
3245
3288
|
var FOLD_RESET = /* @__PURE__ */ Symbol("act.fold.reset");
|
|
3246
3289
|
function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
3247
3290
|
const load_me = {
|
|
3248
3291
|
...me,
|
|
3249
|
-
view: /* @__PURE__ */
|
|
3292
|
+
view: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (raw, actor) => {
|
|
3250
3293
|
const viewed = me.view(raw, actor);
|
|
3251
3294
|
const fields = sensitive_fields(viewed.name);
|
|
3252
3295
|
return fields.length ? pii_strip(viewed, fields) : viewed;
|
|
3253
3296
|
}, "view")
|
|
3254
3297
|
};
|
|
3255
3298
|
const cache2 = /* @__PURE__ */ new Map();
|
|
3256
|
-
const row = /* @__PURE__ */
|
|
3257
|
-
const flush_dirty = /* @__PURE__ */
|
|
3299
|
+
const row = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, ({ dirty: _, ...row2 }) => row2, "row");
|
|
3300
|
+
const flush_dirty = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async () => {
|
|
3258
3301
|
const rows = [];
|
|
3259
3302
|
const flushed = [];
|
|
3260
3303
|
for (const f of cache2.values())
|
|
@@ -3266,7 +3309,7 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3266
3309
|
await flush(rows);
|
|
3267
3310
|
for (const f of flushed) f.dirty = false;
|
|
3268
3311
|
}, "flush_dirty");
|
|
3269
|
-
const first_sight = /* @__PURE__ */
|
|
3312
|
+
const first_sight = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async (stream) => {
|
|
3270
3313
|
if (cache2.size >= config2.maxCachedStates) {
|
|
3271
3314
|
const oldest = cache2.keys().next().value;
|
|
3272
3315
|
const evictee = cache2.get(oldest);
|
|
@@ -3286,7 +3329,7 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3286
3329
|
cache2.set(stream, seated);
|
|
3287
3330
|
return seated;
|
|
3288
3331
|
}, "first_sight");
|
|
3289
|
-
const handler = /* @__PURE__ */
|
|
3332
|
+
const handler = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async (events) => {
|
|
3290
3333
|
let folded_since_flush = 0;
|
|
3291
3334
|
for (const event of events) {
|
|
3292
3335
|
const stream = event.stream;
|
|
@@ -3324,15 +3367,15 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3324
3367
|
}
|
|
3325
3368
|
await flush_dirty();
|
|
3326
3369
|
}, "handler");
|
|
3327
|
-
Object.defineProperty(handler, FOLD_RESET, { value: /* @__PURE__ */
|
|
3370
|
+
Object.defineProperty(handler, FOLD_RESET, { value: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => cache2.clear(), "value") });
|
|
3328
3371
|
return handler;
|
|
3329
3372
|
}
|
|
3330
|
-
|
|
3373
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, make_fold_handler, "make_fold_handler");
|
|
3331
3374
|
|
|
3332
3375
|
// src/internal/settle.ts
|
|
3333
3376
|
var SettleLoop = (_class6 = class {
|
|
3334
3377
|
static {
|
|
3335
|
-
|
|
3378
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "SettleLoop");
|
|
3336
3379
|
}
|
|
3337
3380
|
__init21() {this._timer = void 0}
|
|
3338
3381
|
// The cycle in flight, set while one runs. Shutdown waits for it
|
|
@@ -3370,7 +3413,7 @@ var SettleLoop = (_class6 = class {
|
|
|
3370
3413
|
this._pending = true;
|
|
3371
3414
|
return;
|
|
3372
3415
|
}
|
|
3373
|
-
const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3416
|
+
const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _160 => _160.debounceMs]), () => ( this._default_debounce_ms));
|
|
3374
3417
|
const due = Date.now() + delay;
|
|
3375
3418
|
if (this._timer) {
|
|
3376
3419
|
if (due >= this._due) return;
|
|
@@ -3435,7 +3478,7 @@ var SettleLoop = (_class6 = class {
|
|
|
3435
3478
|
// src/act.ts
|
|
3436
3479
|
var Act = (_class7 = class {
|
|
3437
3480
|
static {
|
|
3438
|
-
|
|
3481
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "Act");
|
|
3439
3482
|
}
|
|
3440
3483
|
__init26() {this._emitter = new (0, _events2.default)()}
|
|
3441
3484
|
|
|
@@ -3523,7 +3566,7 @@ var Act = (_class7 = class {
|
|
|
3523
3566
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3524
3567
|
|
|
3525
3568
|
|
|
3526
|
-
__init27() {this._logger =
|
|
3569
|
+
__init27() {this._logger = _chunkWDIBO6AWcjs.log.call(void 0, )}
|
|
3527
3570
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3528
3571
|
|
|
3529
3572
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3552,10 +3595,11 @@ var Act = (_class7 = class {
|
|
|
3552
3595
|
throw new Error(
|
|
3553
3596
|
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3554
3597
|
);
|
|
3555
|
-
|
|
3556
|
-
|
|
3598
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "act", options);
|
|
3599
|
+
if (options.scoped) _chunkWDIBO6AWcjs.check.call(void 0, "store", options.scoped.store);
|
|
3600
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkWDIBO6AWcjs.unscoped_ports.call(void 0, )));
|
|
3557
3601
|
const ports = this._ports;
|
|
3558
|
-
this._scoped =
|
|
3602
|
+
this._scoped = _chunkWDIBO6AWcjs.make_run_scoped.call(void 0, {
|
|
3559
3603
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3560
3604
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3561
3605
|
get store() {
|
|
@@ -3565,14 +3609,14 @@ var Act = (_class7 = class {
|
|
|
3565
3609
|
return ports.cache;
|
|
3566
3610
|
},
|
|
3567
3611
|
// Parsed per build, so a bad window throws on every build.
|
|
3568
|
-
autoclose_window:
|
|
3612
|
+
autoclose_window: _chunkWDIBO6AWcjs.check.call(void 0, "autoclose", options).autocloseWindow
|
|
3569
3613
|
});
|
|
3570
3614
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3571
3615
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3572
3616
|
this._cd = build_drain(this._logger);
|
|
3573
3617
|
const handle = build_handle({
|
|
3574
3618
|
logger: this._logger,
|
|
3575
|
-
reaction_scope:
|
|
3619
|
+
reaction_scope: _chunkWDIBO6AWcjs.make_reaction_scope.call(void 0, {
|
|
3576
3620
|
do: this.do.bind(this),
|
|
3577
3621
|
load: this.load.bind(this),
|
|
3578
3622
|
query: this.query.bind(this),
|
|
@@ -3602,24 +3646,24 @@ var Act = (_class7 = class {
|
|
|
3602
3646
|
this._ports.store,
|
|
3603
3647
|
options.listen !== false
|
|
3604
3648
|
);
|
|
3605
|
-
|
|
3649
|
+
_chunkWDIBO6AWcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3606
3650
|
}
|
|
3607
3651
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3608
3652
|
_build_breaker(options) {
|
|
3609
3653
|
return new CircuitBreaker(
|
|
3610
|
-
|
|
3654
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "circuit_breaker", _nullishCoalesce(options.circuitBreaker, () => ( {}))),
|
|
3611
3655
|
{
|
|
3612
|
-
on_error: /* @__PURE__ */
|
|
3656
|
+
on_error: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (error, circuit) => this._emit_error(error, circuit), "on_error"),
|
|
3613
3657
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
3614
3658
|
// half-open probe that closes or re-opens the breaker.
|
|
3615
|
-
on_retry: /* @__PURE__ */
|
|
3659
|
+
on_retry: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => this._schedule(), "on_retry")
|
|
3616
3660
|
}
|
|
3617
3661
|
);
|
|
3618
3662
|
}
|
|
3619
3663
|
// Apps that declare no lanes pass no lane filter to `claim`.
|
|
3620
3664
|
_build_drain_controllers(options, lanes, handle, handle_batch) {
|
|
3621
3665
|
const all_lanes = this._declared_lanes;
|
|
3622
|
-
const only_set = _optionalChain([options, 'access',
|
|
3666
|
+
const only_set = _optionalChain([options, 'access', _161 => _161.onlyLanes, 'optionalAccess', _162 => _162.length]) ? new Set(options.onlyLanes) : void 0;
|
|
3623
3667
|
const active_lanes = only_set ? all_lanes.filter((n) => only_set.has(n)) : all_lanes;
|
|
3624
3668
|
const single_default_lane = lanes.length === 0;
|
|
3625
3669
|
const controllers = /* @__PURE__ */ new Map();
|
|
@@ -3632,16 +3676,16 @@ var Act = (_class7 = class {
|
|
|
3632
3676
|
batch_handlers: this._batch_handlers,
|
|
3633
3677
|
handle,
|
|
3634
3678
|
handle_batch,
|
|
3635
|
-
on_acked: /* @__PURE__ */
|
|
3636
|
-
on_blocked: /* @__PURE__ */
|
|
3679
|
+
on_acked: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (acked) => this.emit("acked", acked), "on_acked"),
|
|
3680
|
+
on_blocked: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (blocked) => this.emit("blocked", blocked), "on_blocked"),
|
|
3637
3681
|
// Reaction-requested close: the same machinery as `app.close`.
|
|
3638
3682
|
// A store failure reaches the breaker; anything else (the archive
|
|
3639
3683
|
// callback is app code) is logged here, never counted.
|
|
3640
|
-
on_close: /* @__PURE__ */
|
|
3684
|
+
on_close: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async (targets) => {
|
|
3641
3685
|
try {
|
|
3642
3686
|
await this._run_close(targets);
|
|
3643
3687
|
} catch (error) {
|
|
3644
|
-
if (error instanceof
|
|
3688
|
+
if (error instanceof _chunkUEGKXCSQcjs.StoreError) throw error;
|
|
3645
3689
|
this._logger.error(
|
|
3646
3690
|
error,
|
|
3647
3691
|
`Reaction-requested close of ${targets.map((t) => `"${t.stream}"`).join(", ")} failed; the policy retries it (a full close the next day, a prune on the stream's next commit), or close it now with app.close(...) once the cause is fixed.`
|
|
@@ -3656,7 +3700,7 @@ var Act = (_class7 = class {
|
|
|
3656
3700
|
leaseMillis: cfg.leaseMillis
|
|
3657
3701
|
}
|
|
3658
3702
|
});
|
|
3659
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
3703
|
+
if (_optionalChain([cfg, 'optionalAccess', _163 => _163.cycleMs]) !== void 0 && this._drain)
|
|
3660
3704
|
controller.start(cfg.cycleMs);
|
|
3661
3705
|
controllers.set(name, controller);
|
|
3662
3706
|
}
|
|
@@ -3675,8 +3719,9 @@ var Act = (_class7 = class {
|
|
|
3675
3719
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3676
3720
|
_build_audit_deps() {
|
|
3677
3721
|
return {
|
|
3678
|
-
store:
|
|
3722
|
+
store: _chunkWDIBO6AWcjs.store,
|
|
3679
3723
|
event_to_state: this._event_to_state,
|
|
3724
|
+
sensitive_fields: this.registry.sensitive_fields,
|
|
3680
3725
|
// Declared lanes, not this process's controllers: a lane another
|
|
3681
3726
|
// worker drains is not `unknown-lane`.
|
|
3682
3727
|
declared_lanes: new Set(this._declared_lanes),
|
|
@@ -3688,14 +3733,14 @@ var Act = (_class7 = class {
|
|
|
3688
3733
|
registry: this.registry,
|
|
3689
3734
|
static_targets: classification.static_targets,
|
|
3690
3735
|
cd: this._cd,
|
|
3691
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3736
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkUEGKXCSQcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3692
3737
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3693
3738
|
// still a valid destination.
|
|
3694
3739
|
declared_lanes: new Set(this._declared_lanes),
|
|
3695
3740
|
// Built after the controllers, so their keys are the active lanes.
|
|
3696
3741
|
shard: this._drain_controllers.size < this._declared_lanes.length ? [...this._drain_controllers.keys()] : void 0,
|
|
3697
3742
|
// Only reached on a draining app: writer-only ones never correlate.
|
|
3698
|
-
on_init: /* @__PURE__ */
|
|
3743
|
+
on_init: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async () => {
|
|
3699
3744
|
this._arm_all();
|
|
3700
3745
|
await this._seed_persisted_defers();
|
|
3701
3746
|
}, "on_init")
|
|
@@ -3704,23 +3749,23 @@ var Act = (_class7 = class {
|
|
|
3704
3749
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3705
3750
|
async _seed_persisted_defers() {
|
|
3706
3751
|
const now = Date.now();
|
|
3707
|
-
await walk_streams(
|
|
3752
|
+
await walk_streams(_chunkWDIBO6AWcjs.store.call(void 0, ), (pos) => {
|
|
3708
3753
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3709
3754
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3710
|
-
_optionalChain([controller, 'optionalAccess',
|
|
3755
|
+
_optionalChain([controller, 'optionalAccess', _164 => _164.seed_defer, 'call', _165 => _165(pos.stream, pos.deferred_at)]);
|
|
3711
3756
|
});
|
|
3712
3757
|
}
|
|
3713
3758
|
_build_settle(options) {
|
|
3714
3759
|
return new SettleLoop(
|
|
3715
3760
|
{
|
|
3716
|
-
correlate: /* @__PURE__ */
|
|
3761
|
+
correlate: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (q) => this._correlate_pass(_nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)), true), "correlate"),
|
|
3717
3762
|
// `settle()` validated the options, and `_schedule` skips writer-only
|
|
3718
3763
|
// instances, so the loop drains through the internal path.
|
|
3719
|
-
drain: /* @__PURE__ */
|
|
3720
|
-
on_settled: /* @__PURE__ */
|
|
3764
|
+
drain: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (o) => this._scoped(() => this._drain_all(o)), "drain"),
|
|
3765
|
+
on_settled: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (drain) => this.emit("settled", drain), "on_settled"),
|
|
3721
3766
|
breaker: this._breaker
|
|
3722
3767
|
},
|
|
3723
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3768
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkUEGKXCSQcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3724
3769
|
);
|
|
3725
3770
|
}
|
|
3726
3771
|
|
|
@@ -3740,7 +3785,7 @@ var Act = (_class7 = class {
|
|
|
3740
3785
|
*/
|
|
3741
3786
|
shutdown(options) {
|
|
3742
3787
|
if (!this._shutdown_promise) {
|
|
3743
|
-
|
|
3788
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "shutdown", _nullishCoalesce(options, () => ( {})));
|
|
3744
3789
|
this._shutdown_promise = (async () => {
|
|
3745
3790
|
this.stop_correlations();
|
|
3746
3791
|
this._settle.stop(true);
|
|
@@ -3748,7 +3793,7 @@ var Act = (_class7 = class {
|
|
|
3748
3793
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3749
3794
|
const disposer = await this._notify_disposer;
|
|
3750
3795
|
if (disposer) await disposer();
|
|
3751
|
-
await this._await_inflight(_optionalChain([options, 'optionalAccess',
|
|
3796
|
+
await this._await_inflight(_optionalChain([options, 'optionalAccess', _166 => _166.graceMs]));
|
|
3752
3797
|
await this._scoped(() => this._correlate.release_correlation());
|
|
3753
3798
|
this._emitter.removeAllListeners();
|
|
3754
3799
|
})();
|
|
@@ -3758,10 +3803,10 @@ var Act = (_class7 = class {
|
|
|
3758
3803
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3759
3804
|
// default for none or 0, and for a running settle), capped.
|
|
3760
3805
|
_derive_grace_ms(running, settling) {
|
|
3761
|
-
let max = settling ?
|
|
3806
|
+
let max = settling ? _chunkWDIBO6AWcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3762
3807
|
for (const c of running)
|
|
3763
|
-
max = Math.max(max, c.lease_millis ||
|
|
3764
|
-
return Math.min(max,
|
|
3808
|
+
max = Math.max(max, c.lease_millis || _chunkWDIBO6AWcjs.DEFAULT_LEASE_MILLIS);
|
|
3809
|
+
return Math.min(max, _chunkWDIBO6AWcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3765
3810
|
}
|
|
3766
3811
|
async _await_inflight(grace_ms) {
|
|
3767
3812
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3845,8 +3890,8 @@ var Act = (_class7 = class {
|
|
|
3845
3890
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3846
3891
|
*/
|
|
3847
3892
|
async do(action2, target, payload, options) {
|
|
3848
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3849
|
-
const do_options = reacting_to === _optionalChain([options, 'optionalAccess',
|
|
3893
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _167 => _167.reactingTo]), () => ( _chunkWDIBO6AWcjs.current_reacting.call(void 0, )));
|
|
3894
|
+
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3850
3895
|
return this._scoped(async () => {
|
|
3851
3896
|
const snapshots = await this._es.action(
|
|
3852
3897
|
this.registry.actions[action2],
|
|
@@ -3919,11 +3964,11 @@ var Act = (_class7 = class {
|
|
|
3919
3964
|
return this._scoped(async () => {
|
|
3920
3965
|
let first;
|
|
3921
3966
|
let last;
|
|
3922
|
-
const count = await
|
|
3967
|
+
const count = await _chunkWDIBO6AWcjs.store.call(void 0, ).query((e) => {
|
|
3923
3968
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3924
3969
|
if (!first) first = gated;
|
|
3925
3970
|
last = gated;
|
|
3926
|
-
_optionalChain([callback, 'optionalCall',
|
|
3971
|
+
_optionalChain([callback, 'optionalCall', _169 => _169(gated)]);
|
|
3927
3972
|
}, query);
|
|
3928
3973
|
return { first, last, count };
|
|
3929
3974
|
});
|
|
@@ -3965,14 +4010,14 @@ var Act = (_class7 = class {
|
|
|
3965
4010
|
*/
|
|
3966
4011
|
async forget(stream) {
|
|
3967
4012
|
return this._scoped(async () => {
|
|
3968
|
-
const s =
|
|
4013
|
+
const s = _chunkWDIBO6AWcjs.store.call(void 0, );
|
|
3969
4014
|
if (!s.forget_pii) {
|
|
3970
4015
|
throw new Error(
|
|
3971
4016
|
`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).`
|
|
3972
4017
|
);
|
|
3973
4018
|
}
|
|
3974
4019
|
const eventCount = await s.forget_pii(stream);
|
|
3975
|
-
await
|
|
4020
|
+
await _chunkWDIBO6AWcjs.cache.call(void 0, ).invalidate(stream);
|
|
3976
4021
|
if (eventCount > 0) {
|
|
3977
4022
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3978
4023
|
}
|
|
@@ -4006,7 +4051,7 @@ var Act = (_class7 = class {
|
|
|
4006
4051
|
* @see {@link correlate} for dynamic stream discovery
|
|
4007
4052
|
*/
|
|
4008
4053
|
async drain(options = {}) {
|
|
4009
|
-
|
|
4054
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "drain", options);
|
|
4010
4055
|
if (!this._drain)
|
|
4011
4056
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
4012
4057
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4044,7 +4089,7 @@ var Act = (_class7 = class {
|
|
|
4044
4089
|
}
|
|
4045
4090
|
if (to_arm.size === 0) return false;
|
|
4046
4091
|
this._correlate.arm();
|
|
4047
|
-
for (const lane of to_arm) _optionalChain([this, 'access',
|
|
4092
|
+
for (const lane of to_arm) _optionalChain([this, 'access', _170 => _170._drain_controllers, 'access', _171 => _171.get, 'call', _172 => _172(lane), 'optionalAccess', _173 => _173.arm, 'call', _174 => _174()]);
|
|
4048
4093
|
return true;
|
|
4049
4094
|
}
|
|
4050
4095
|
// In parallel, so a slow lane never holds up a fast one.
|
|
@@ -4083,6 +4128,7 @@ var Act = (_class7 = class {
|
|
|
4083
4128
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
4084
4129
|
*/
|
|
4085
4130
|
async correlate(query = {}) {
|
|
4131
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "page", query);
|
|
4086
4132
|
const pass = await this._correlate_pass(_nullishCoalesce(query.limit, () => ( 10)));
|
|
4087
4133
|
return {
|
|
4088
4134
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -4128,6 +4174,8 @@ var Act = (_class7 = class {
|
|
|
4128
4174
|
* @see {@link stop_correlations} to stop the poll
|
|
4129
4175
|
*/
|
|
4130
4176
|
start_correlations(query = {}, frequency = 1e4) {
|
|
4177
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "page", query);
|
|
4178
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "poll", { frequency });
|
|
4131
4179
|
if (this._poll) return false;
|
|
4132
4180
|
this._poll_limit = query.limit || void 0;
|
|
4133
4181
|
this._poll = setInterval(() => {
|
|
@@ -4164,7 +4212,7 @@ var Act = (_class7 = class {
|
|
|
4164
4212
|
// and an extra clear costs one head load per stream.
|
|
4165
4213
|
_reset_folds() {
|
|
4166
4214
|
for (const handler of this._batch_handlers.values())
|
|
4167
|
-
_optionalChain([handler, 'access',
|
|
4215
|
+
_optionalChain([handler, 'access', _175 => _175[FOLD_RESET], 'optionalCall', _176 => _176()]);
|
|
4168
4216
|
}
|
|
4169
4217
|
/**
|
|
4170
4218
|
* Reset reaction stream watermarks and settle them, replaying their
|
|
@@ -4193,7 +4241,7 @@ var Act = (_class7 = class {
|
|
|
4193
4241
|
*/
|
|
4194
4242
|
async reset(input) {
|
|
4195
4243
|
return this._scoped(async () => {
|
|
4196
|
-
const count = await
|
|
4244
|
+
const count = await _chunkWDIBO6AWcjs.store.call(void 0, ).reset(input);
|
|
4197
4245
|
this._reset_folds();
|
|
4198
4246
|
if (count > 0) {
|
|
4199
4247
|
this._wake();
|
|
@@ -4228,7 +4276,7 @@ var Act = (_class7 = class {
|
|
|
4228
4276
|
*/
|
|
4229
4277
|
async unblock(input) {
|
|
4230
4278
|
return this._scoped(async () => {
|
|
4231
|
-
const count = await
|
|
4279
|
+
const count = await _chunkWDIBO6AWcjs.store.call(void 0, ).unblock(input);
|
|
4232
4280
|
if (count > 0) {
|
|
4233
4281
|
this._wake();
|
|
4234
4282
|
}
|
|
@@ -4276,7 +4324,7 @@ var Act = (_class7 = class {
|
|
|
4276
4324
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4277
4325
|
*/
|
|
4278
4326
|
async restore(source, opts = {}, sink) {
|
|
4279
|
-
|
|
4327
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "scan", opts);
|
|
4280
4328
|
return this._scoped(async () => {
|
|
4281
4329
|
const started = Date.now();
|
|
4282
4330
|
if (opts.dry_run) {
|
|
@@ -4284,14 +4332,14 @@ var Act = (_class7 = class {
|
|
|
4284
4332
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4285
4333
|
}
|
|
4286
4334
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4287
|
-
const s =
|
|
4335
|
+
const s = _chunkWDIBO6AWcjs.store.call(void 0, );
|
|
4288
4336
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4289
4337
|
return s;
|
|
4290
4338
|
})()));
|
|
4291
4339
|
let kept = 0;
|
|
4292
4340
|
let migrated = 0;
|
|
4293
4341
|
let dropped = { closed_streams: 0, snapshots: 0 };
|
|
4294
|
-
const run = /* @__PURE__ */
|
|
4342
|
+
const run = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => target.restore(async (callback) => {
|
|
4295
4343
|
const partial = await scan(source, opts, callback);
|
|
4296
4344
|
kept = partial.kept;
|
|
4297
4345
|
migrated = partial.migrated;
|
|
@@ -4329,13 +4377,14 @@ var Act = (_class7 = class {
|
|
|
4329
4377
|
* ```
|
|
4330
4378
|
*/
|
|
4331
4379
|
async blocked_streams(options) {
|
|
4380
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "page", _nullishCoalesce(options, () => ( {})));
|
|
4332
4381
|
return this._scoped(async () => {
|
|
4333
4382
|
const positions = [];
|
|
4334
|
-
await
|
|
4383
|
+
await _chunkWDIBO6AWcjs.store.call(void 0, ).query_streams(
|
|
4335
4384
|
(p) => {
|
|
4336
4385
|
positions.push(p);
|
|
4337
4386
|
},
|
|
4338
|
-
{ blocked: true, after: _optionalChain([options, 'optionalAccess',
|
|
4387
|
+
{ blocked: true, after: _optionalChain([options, 'optionalAccess', _177 => _177.after]), limit: _optionalChain([options, 'optionalAccess', _178 => _178.limit]) }
|
|
4339
4388
|
);
|
|
4340
4389
|
return positions;
|
|
4341
4390
|
});
|
|
@@ -4357,7 +4406,7 @@ var Act = (_class7 = class {
|
|
|
4357
4406
|
* ```
|
|
4358
4407
|
*/
|
|
4359
4408
|
async *audit(categories, options) {
|
|
4360
|
-
|
|
4409
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "audit", _nullishCoalesce(options, () => ( {})));
|
|
4361
4410
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4362
4411
|
while (true) {
|
|
4363
4412
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4385,15 +4434,15 @@ var Act = (_class7 = class {
|
|
|
4385
4434
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4386
4435
|
*/
|
|
4387
4436
|
async prioritize(filter, priority) {
|
|
4388
|
-
|
|
4389
|
-
return this._scoped(() =>
|
|
4437
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "target", { priority });
|
|
4438
|
+
return this._scoped(() => _chunkWDIBO6AWcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4390
4439
|
}
|
|
4391
4440
|
// Shared by `close()` and reaction-requested closes.
|
|
4392
4441
|
async _run_close(targets) {
|
|
4393
4442
|
const close_actor = { id: "$close", name: "close" };
|
|
4394
4443
|
const result = await run_close_cycle(targets, {
|
|
4395
4444
|
reactive: this._reactive,
|
|
4396
|
-
catch_up_correlation: /* @__PURE__ */
|
|
4445
|
+
catch_up_correlation: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (until) => catch_up_correlation(
|
|
4397
4446
|
this._correlate,
|
|
4398
4447
|
(limit) => this.correlate({ limit }),
|
|
4399
4448
|
until
|
|
@@ -4403,8 +4452,8 @@ var Act = (_class7 = class {
|
|
|
4403
4452
|
tombstone: this._es.tombstone,
|
|
4404
4453
|
logger: this._logger,
|
|
4405
4454
|
correlation: close_correlation(this._correlator, close_actor),
|
|
4406
|
-
with_stream_lock: /* @__PURE__ */
|
|
4407
|
-
forget_subscribed: /* @__PURE__ */
|
|
4455
|
+
with_stream_lock: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (stream, work) => this._close_lock.run(stream, work), "with_stream_lock"),
|
|
4456
|
+
forget_subscribed: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (streams) => this._correlate.forget_subscribed(streams), "forget_subscribed")
|
|
4408
4457
|
});
|
|
4409
4458
|
this.emit("closed", result);
|
|
4410
4459
|
return result;
|
|
@@ -4466,7 +4515,7 @@ var Act = (_class7 = class {
|
|
|
4466
4515
|
* @see {@link correlate} for manual correlation
|
|
4467
4516
|
*/
|
|
4468
4517
|
settle(options) {
|
|
4469
|
-
|
|
4518
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "settle", _nullishCoalesce(options, () => ( {})));
|
|
4470
4519
|
this._schedule(options);
|
|
4471
4520
|
}
|
|
4472
4521
|
}, _class7);
|
|
@@ -4474,12 +4523,12 @@ var Act = (_class7 = class {
|
|
|
4474
4523
|
// src/builders/merge.ts
|
|
4475
4524
|
|
|
4476
4525
|
function base_type_name(schema) {
|
|
4477
|
-
let def =
|
|
4478
|
-
for (let inner =
|
|
4479
|
-
def =
|
|
4526
|
+
let def = def_of(schema);
|
|
4527
|
+
for (let inner = inner_of(def); inner; inner = inner_of(def))
|
|
4528
|
+
def = def_of(inner);
|
|
4480
4529
|
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4481
4530
|
}
|
|
4482
|
-
|
|
4531
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, base_type_name, "base_type_name");
|
|
4483
4532
|
function merge_schemas(existing, incoming, state_name) {
|
|
4484
4533
|
if (existing === incoming) return existing;
|
|
4485
4534
|
const existing_object = as_object(existing, "existing", state_name);
|
|
@@ -4499,18 +4548,18 @@ function merge_schemas(existing, incoming, state_name) {
|
|
|
4499
4548
|
}
|
|
4500
4549
|
return existing_object.extend(incoming_shape);
|
|
4501
4550
|
}
|
|
4502
|
-
|
|
4551
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_schemas, "merge_schemas");
|
|
4503
4552
|
function as_object(schema, side, state_name) {
|
|
4504
|
-
if (schema instanceof
|
|
4553
|
+
if (schema instanceof _zod2.ZodObject) return schema;
|
|
4505
4554
|
throw new Error(
|
|
4506
4555
|
`Cannot merge state schemas for "${state_name}": the ${side} partial's schema is a ${schema.constructor.name}, not a z.object. Partials of the same state are merged by extending their shapes, so declare every partial's state as a plain z.object({ ... }).`
|
|
4507
4556
|
);
|
|
4508
4557
|
}
|
|
4509
|
-
|
|
4558
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, as_object, "as_object");
|
|
4510
4559
|
function merge_inits(existing, incoming) {
|
|
4511
4560
|
return () => ({ ...existing(), ...incoming() });
|
|
4512
4561
|
}
|
|
4513
|
-
|
|
4562
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_inits, "merge_inits");
|
|
4514
4563
|
function register_state(state2, states, actions, events) {
|
|
4515
4564
|
const existing = states.get(state2.name);
|
|
4516
4565
|
if (existing) {
|
|
@@ -4519,25 +4568,30 @@ function register_state(state2, states, actions, events) {
|
|
|
4519
4568
|
register_new_state(state2, states, actions, events);
|
|
4520
4569
|
}
|
|
4521
4570
|
}
|
|
4522
|
-
|
|
4571
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, register_state, "register_state");
|
|
4572
|
+
var shared_name = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (name) => new Error(
|
|
4573
|
+
`Action and event share the name "${name}" \u2014 action and event names must be unique across the application. Rename one of them.`
|
|
4574
|
+
), "shared_name");
|
|
4523
4575
|
function register_new_state(state2, states, actions, events) {
|
|
4524
4576
|
states.set(state2.name, state2);
|
|
4525
4577
|
for (const name of Object.keys(state2.actions)) {
|
|
4526
4578
|
if (actions[name]) throw new Error(`Duplicate action "${name}"`);
|
|
4579
|
+
if (events[name]) throw shared_name(name);
|
|
4527
4580
|
actions[name] = state2;
|
|
4528
4581
|
}
|
|
4529
4582
|
for (const name of Object.keys(state2.events)) {
|
|
4530
4583
|
if (events[name]) throw new Error(`Duplicate event "${name}"`);
|
|
4584
|
+
if (actions[name]) throw shared_name(name);
|
|
4531
4585
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4532
4586
|
}
|
|
4533
4587
|
}
|
|
4534
|
-
|
|
4588
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, register_new_state, "register_new_state");
|
|
4535
4589
|
function pick_declared(existing, incoming, what, state_name) {
|
|
4536
4590
|
if (existing && incoming && existing !== incoming)
|
|
4537
4591
|
throw new Error(`Duplicate ${what} for state "${state_name}"`);
|
|
4538
4592
|
return _nullishCoalesce(incoming, () => ( existing));
|
|
4539
4593
|
}
|
|
4540
|
-
|
|
4594
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, pick_declared, "pick_declared");
|
|
4541
4595
|
function autoclose_of(existing, state2) {
|
|
4542
4596
|
pick_declared(
|
|
4543
4597
|
existing.autoclose,
|
|
@@ -4553,11 +4607,12 @@ function autoclose_of(existing, state2) {
|
|
|
4553
4607
|
autoclose_keep_days: owner.autoclose_keep_days
|
|
4554
4608
|
};
|
|
4555
4609
|
}
|
|
4556
|
-
|
|
4610
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, autoclose_of, "autoclose_of");
|
|
4557
4611
|
function merge_into_existing(state2, existing, states, actions, events) {
|
|
4558
4612
|
for (const name of Object.keys(state2.actions)) {
|
|
4559
4613
|
if (existing.on[name] === state2.on[name]) continue;
|
|
4560
4614
|
if (actions[name]) throw new Error(`Duplicate action "${name}"`);
|
|
4615
|
+
if (events[name] || state2.events[name]) throw shared_name(name);
|
|
4561
4616
|
}
|
|
4562
4617
|
for (const name of Object.keys(state2.events)) {
|
|
4563
4618
|
if (existing.events[name] === state2.events[name]) continue;
|
|
@@ -4567,6 +4622,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
|
|
|
4567
4622
|
);
|
|
4568
4623
|
}
|
|
4569
4624
|
if (events[name]) throw new Error(`Duplicate event "${name}"`);
|
|
4625
|
+
if (actions[name]) throw shared_name(name);
|
|
4570
4626
|
}
|
|
4571
4627
|
const merged_patch = merge_patches(existing.patch, state2.patch, state2.name);
|
|
4572
4628
|
const merged = {
|
|
@@ -4609,7 +4665,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
|
|
|
4609
4665
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4610
4666
|
}
|
|
4611
4667
|
}
|
|
4612
|
-
|
|
4668
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_into_existing, "merge_into_existing");
|
|
4613
4669
|
function merge_patches(existing, incoming, state_name) {
|
|
4614
4670
|
const merged = { ...existing };
|
|
4615
4671
|
for (const name of Object.keys(incoming)) {
|
|
@@ -4632,7 +4688,7 @@ function merge_patches(existing, incoming, state_name) {
|
|
|
4632
4688
|
}
|
|
4633
4689
|
return merged;
|
|
4634
4690
|
}
|
|
4635
|
-
|
|
4691
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_patches, "merge_patches");
|
|
4636
4692
|
function merge_event_register(target, source) {
|
|
4637
4693
|
for (const [event_name, source_reg] of Object.entries(source)) {
|
|
4638
4694
|
const target_reg = target[event_name];
|
|
@@ -4647,7 +4703,7 @@ function merge_event_register(target, source) {
|
|
|
4647
4703
|
}
|
|
4648
4704
|
}
|
|
4649
4705
|
}
|
|
4650
|
-
|
|
4706
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_event_register, "merge_event_register");
|
|
4651
4707
|
function merge_projection(proj, events) {
|
|
4652
4708
|
for (const event_name of Object.keys(proj.events)) {
|
|
4653
4709
|
const proj_register = proj.events[event_name];
|
|
@@ -4667,17 +4723,17 @@ function merge_projection(proj, events) {
|
|
|
4667
4723
|
}
|
|
4668
4724
|
}
|
|
4669
4725
|
}
|
|
4670
|
-
|
|
4671
|
-
var _this_ = /* @__PURE__ */
|
|
4726
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, merge_projection, "merge_projection");
|
|
4727
|
+
var _this_ = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, ({ stream }) => ({
|
|
4672
4728
|
source: stream,
|
|
4673
4729
|
target: stream
|
|
4674
4730
|
}), "_this_");
|
|
4675
4731
|
|
|
4676
4732
|
// src/builders/builder-utils.ts
|
|
4677
4733
|
function register_lane(config2, lanes) {
|
|
4678
|
-
|
|
4679
|
-
if (config2.name ===
|
|
4680
|
-
throw new Error(`Lane "${
|
|
4734
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "lane", config2);
|
|
4735
|
+
if (config2.name === _chunkUEGKXCSQcjs.DEFAULT_LANE)
|
|
4736
|
+
throw new Error(`Lane "${_chunkUEGKXCSQcjs.DEFAULT_LANE}" is reserved`);
|
|
4681
4737
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4682
4738
|
if (!existing) return void lanes.push(config2);
|
|
4683
4739
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4685,7 +4741,7 @@ function register_lane(config2, lanes) {
|
|
|
4685
4741
|
`Lane "${config2.name}" was already declared with a different config`
|
|
4686
4742
|
);
|
|
4687
4743
|
}
|
|
4688
|
-
|
|
4744
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, register_lane, "register_lane");
|
|
4689
4745
|
function add_reaction(events, event, name, kind, make, builder) {
|
|
4690
4746
|
if (!name)
|
|
4691
4747
|
throw new Error(
|
|
@@ -4700,57 +4756,84 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4700
4756
|
events[event].reactions.set(name, reaction);
|
|
4701
4757
|
return Object.assign(builder, {
|
|
4702
4758
|
to(resolver) {
|
|
4703
|
-
if (typeof resolver === "object")
|
|
4759
|
+
if (typeof resolver === "object") _chunkWDIBO6AWcjs.check.call(void 0, "target", resolver);
|
|
4704
4760
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4705
4761
|
return builder;
|
|
4706
4762
|
}
|
|
4707
4763
|
});
|
|
4708
4764
|
}
|
|
4709
|
-
|
|
4765
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, add_reaction, "add_reaction");
|
|
4710
4766
|
function reaction_on(event, events, builder) {
|
|
4711
|
-
const register = /* @__PURE__ */
|
|
4767
|
+
const register = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (handler, options, schedule) => add_reaction(
|
|
4712
4768
|
events,
|
|
4713
4769
|
event,
|
|
4714
4770
|
handler.name,
|
|
4715
4771
|
"Reaction",
|
|
4716
4772
|
() => {
|
|
4717
4773
|
if (schedule && typeof schedule !== "function")
|
|
4718
|
-
|
|
4774
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "defer", schedule);
|
|
4719
4775
|
return {
|
|
4720
4776
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4721
4777
|
resolver: _this_,
|
|
4722
4778
|
// Validate the whole bag at the declaration site so a bad
|
|
4723
4779
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4724
4780
|
// not a NaN gate on the first retry.
|
|
4725
|
-
options:
|
|
4726
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4727
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4728
|
-
backoff: _optionalChain([options, 'optionalAccess',
|
|
4781
|
+
options: _chunkWDIBO6AWcjs.check.call(void 0, "reaction", {
|
|
4782
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _179 => _179.blockOnError]), () => ( _chunkWDIBO6AWcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4783
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _180 => _180.maxRetries]), () => ( _chunkWDIBO6AWcjs.DEFAULT_MAX_RETRIES)),
|
|
4784
|
+
backoff: _optionalChain([options, 'optionalAccess', _181 => _181.backoff])
|
|
4729
4785
|
})
|
|
4730
4786
|
};
|
|
4731
4787
|
},
|
|
4732
4788
|
builder
|
|
4733
4789
|
), "register");
|
|
4734
4790
|
return {
|
|
4735
|
-
do: /* @__PURE__ */
|
|
4736
|
-
defer: /* @__PURE__ */
|
|
4737
|
-
do: /* @__PURE__ */
|
|
4791
|
+
do: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (handler, options) => register(handler, options), "do"),
|
|
4792
|
+
defer: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (schedule) => ({
|
|
4793
|
+
do: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (handler, options) => register(handler, options, schedule), "do")
|
|
4738
4794
|
}), "defer")
|
|
4739
4795
|
};
|
|
4740
4796
|
}
|
|
4741
|
-
|
|
4797
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, reaction_on, "reaction_on");
|
|
4742
4798
|
|
|
4743
4799
|
// src/builders/event-builder.ts
|
|
4744
4800
|
|
|
4801
|
+
|
|
4802
|
+
// src/internal/sensitive.ts
|
|
4803
|
+
var SENSITIVE = /* @__PURE__ */ Symbol.for("act.sensitive");
|
|
4804
|
+
var is_pii = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (schema) => some_layer(schema, (def) => def[SENSITIVE] === true), "is_pii");
|
|
4805
|
+
function pii_schemas(schema) {
|
|
4806
|
+
const shape = schema.shape;
|
|
4807
|
+
if (shape && typeof shape === "object") {
|
|
4808
|
+
const fields = {};
|
|
4809
|
+
for (const key of Object.keys(shape))
|
|
4810
|
+
if (is_pii(shape[key])) fields[key] = shape[key];
|
|
4811
|
+
return fields;
|
|
4812
|
+
}
|
|
4813
|
+
const options = schema.options;
|
|
4814
|
+
if (Array.isArray(options)) {
|
|
4815
|
+
const fields = {};
|
|
4816
|
+
for (const option of options)
|
|
4817
|
+
for (const [key, field] of Object.entries(
|
|
4818
|
+
pii_schemas(option)
|
|
4819
|
+
))
|
|
4820
|
+
fields[key] ??= field;
|
|
4821
|
+
return fields;
|
|
4822
|
+
}
|
|
4823
|
+
return {};
|
|
4824
|
+
}
|
|
4825
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, pii_schemas, "pii_schemas");
|
|
4826
|
+
|
|
4827
|
+
// src/builders/event-builder.ts
|
|
4745
4828
|
function event_tags(schema) {
|
|
4746
|
-
const pii =
|
|
4829
|
+
const pii = pii_schemas(schema);
|
|
4747
4830
|
const pii_dates = {};
|
|
4748
4831
|
for (const [key, field] of Object.entries(pii)) {
|
|
4749
4832
|
const dates = date_reviver_schema(field);
|
|
4750
4833
|
if (dates) pii_dates[key] = dates.optional();
|
|
4751
4834
|
}
|
|
4752
4835
|
const data_reviver_schema = date_reviver_schema(schema);
|
|
4753
|
-
const revive = /* @__PURE__ */
|
|
4836
|
+
const revive = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (schema2) => (data) => {
|
|
4754
4837
|
const revived = schema2.safeParse(data);
|
|
4755
4838
|
return revived.success ? revived.data : data;
|
|
4756
4839
|
}, "revive");
|
|
@@ -4758,10 +4841,10 @@ function event_tags(schema) {
|
|
|
4758
4841
|
return {
|
|
4759
4842
|
sensitive: pii,
|
|
4760
4843
|
date_reviver: data_reviver_schema && revive(data_reviver_schema),
|
|
4761
|
-
pii_date_reviver: dated_pii ? revive(
|
|
4844
|
+
pii_date_reviver: dated_pii ? revive(_zod2.z.looseObject(pii_dates)) : void 0
|
|
4762
4845
|
};
|
|
4763
4846
|
}
|
|
4764
|
-
|
|
4847
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, event_tags, "event_tags");
|
|
4765
4848
|
function make_event_reader(tags, disclosure, predicate = null) {
|
|
4766
4849
|
const { date_reviver, pii_date_reviver } = tags;
|
|
4767
4850
|
const sensitive2 = Object.keys(tags.sensitive);
|
|
@@ -4781,9 +4864,9 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4781
4864
|
);
|
|
4782
4865
|
});
|
|
4783
4866
|
}
|
|
4784
|
-
|
|
4867
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, make_event_reader, "make_event_reader");
|
|
4785
4868
|
function build_events(registry, states, lanes, owners) {
|
|
4786
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4869
|
+
const declared = /* @__PURE__ */ new Set([_chunkUEGKXCSQcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4787
4870
|
const lane_errors = [];
|
|
4788
4871
|
const tags = /* @__PURE__ */ new Map();
|
|
4789
4872
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4816,9 +4899,9 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4816
4899
|
handler_readers.set(event_name, handler_reader);
|
|
4817
4900
|
for (const [name, reaction] of def.reactions) {
|
|
4818
4901
|
const inner = reaction.handler;
|
|
4819
|
-
const
|
|
4820
|
-
Object.defineProperty(
|
|
4821
|
-
reaction.handler =
|
|
4902
|
+
const wrapped2 = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (evt, stream, app) => inner(handler_reader(evt), stream, app), "wrapped");
|
|
4903
|
+
Object.defineProperty(wrapped2, "name", { value: inner.name });
|
|
4904
|
+
reaction.handler = wrapped2;
|
|
4822
4905
|
def.reactions.set(name, reaction);
|
|
4823
4906
|
}
|
|
4824
4907
|
}
|
|
@@ -4858,19 +4941,23 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4858
4941
|
if (reader) readers.set(event_name, reader);
|
|
4859
4942
|
}
|
|
4860
4943
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4861
|
-
if (snap2) readers.set(
|
|
4944
|
+
if (snap2) readers.set(_chunkUEGKXCSQcjs.SNAP_EVENT, snap2);
|
|
4862
4945
|
if (readers.size === 0) continue;
|
|
4863
4946
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4864
4947
|
}
|
|
4948
|
+
for (const [action_name, state2] of Object.entries(registry.actions)) {
|
|
4949
|
+
const fields = Object.keys(pii_schemas(state2.actions[action_name]));
|
|
4950
|
+
if (fields.length > 0) sensitive2.set(action_name, fields);
|
|
4951
|
+
}
|
|
4865
4952
|
const advisory = advised.size > 0 ? `Act has ${advised.size} sensitive field(s) whose type isn't a string: ${[...advised].join(", ")}. A caller who may not see one reads "[REDACTED]" or "[SHREDDED]" there instead, which its type doesn't allow. Declare sensitive fields as strings. See docs/docs/guides/sensitive-data.md.` : void 0;
|
|
4866
4953
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4867
4954
|
}
|
|
4868
|
-
|
|
4955
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, build_events, "build_events");
|
|
4869
4956
|
function reads_as_string(schema) {
|
|
4870
|
-
const type = _optionalChain([
|
|
4957
|
+
const type = _optionalChain([def_of, 'call', _182 => _182(output_of(schema)), 'optionalAccess', _183 => _183.type]);
|
|
4871
4958
|
return type === "string" || type === "transform";
|
|
4872
4959
|
}
|
|
4873
|
-
|
|
4960
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, reads_as_string, "reads_as_string");
|
|
4874
4961
|
|
|
4875
4962
|
// src/builders/act-builder.ts
|
|
4876
4963
|
function register_batch_handler(proj, batch_handlers) {
|
|
@@ -4883,7 +4970,7 @@ function register_batch_handler(proj, batch_handlers) {
|
|
|
4883
4970
|
}
|
|
4884
4971
|
batch_handlers.set(proj.target, proj.batchHandler);
|
|
4885
4972
|
}
|
|
4886
|
-
|
|
4973
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, register_batch_handler, "register_batch_handler");
|
|
4887
4974
|
function act() {
|
|
4888
4975
|
const states = /* @__PURE__ */ new Map();
|
|
4889
4976
|
const _sf = /* @__PURE__ */ new Map();
|
|
@@ -4897,16 +4984,16 @@ function act() {
|
|
|
4897
4984
|
const registry = {
|
|
4898
4985
|
actions: {},
|
|
4899
4986
|
events: {},
|
|
4900
|
-
sensitive_fields: /* @__PURE__ */
|
|
4901
|
-
query_gate: /* @__PURE__ */
|
|
4902
|
-
disclosure_predicate: /* @__PURE__ */
|
|
4903
|
-
deprecated_events: /* @__PURE__ */
|
|
4904
|
-
autoclose_policy: /* @__PURE__ */
|
|
4905
|
-
autoclose_archiver: /* @__PURE__ */
|
|
4987
|
+
sensitive_fields: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (name) => _nullishCoalesce(_sf.get(name), () => ( [])), "sensitive_fields"),
|
|
4988
|
+
query_gate: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (event_name) => _nullishCoalesce(_qg.get(event_name), () => ( IDENTITY_GATE)), "query_gate"),
|
|
4989
|
+
disclosure_predicate: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (state_name) => _nullishCoalesce(_dp.get(state_name), () => ( null)), "disclosure_predicate"),
|
|
4990
|
+
deprecated_events: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (state_name) => _nullishCoalesce(_de.get(state_name), () => ( EMPTY_DEPRECATED)), "deprecated_events"),
|
|
4991
|
+
autoclose_policy: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (state_name) => _nullishCoalesce(_ac.get(state_name), () => ( null)), "autoclose_policy"),
|
|
4992
|
+
autoclose_archiver: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (state_name) => _nullishCoalesce(_aa.get(state_name), () => ( null)), "autoclose_archiver")
|
|
4906
4993
|
};
|
|
4907
4994
|
const pending_projections = [];
|
|
4908
4995
|
const projection_reactions = /* @__PURE__ */ new Set();
|
|
4909
|
-
const record_projection_reactions = /* @__PURE__ */
|
|
4996
|
+
const record_projection_reactions = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (proj) => {
|
|
4910
4997
|
if (!proj.batchHandler && !proj.fold) return;
|
|
4911
4998
|
for (const register of Object.values(
|
|
4912
4999
|
proj.events
|
|
@@ -4916,7 +5003,7 @@ function act() {
|
|
|
4916
5003
|
}, "record_projection_reactions");
|
|
4917
5004
|
const fold_projections = [];
|
|
4918
5005
|
const batch_handlers = /* @__PURE__ */ new Map();
|
|
4919
|
-
const add_projection = /* @__PURE__ */
|
|
5006
|
+
const add_projection = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (proj) => {
|
|
4920
5007
|
record_projection_reactions(proj);
|
|
4921
5008
|
merge_projection(proj, registry.events);
|
|
4922
5009
|
register_batch_handler(proj, batch_handlers);
|
|
@@ -4925,16 +5012,16 @@ function act() {
|
|
|
4925
5012
|
const fold_specs = [];
|
|
4926
5013
|
const lanes = [];
|
|
4927
5014
|
let _built = false;
|
|
4928
|
-
const read_wrap = /* @__PURE__ */
|
|
4929
|
-
const
|
|
4930
|
-
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access',
|
|
5015
|
+
const read_wrap = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (original) => {
|
|
5016
|
+
const wrapped2 = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, async (events, stream) => {
|
|
5017
|
+
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _184 => _184.get, 'call', _185 => _185(e.name), 'optionalCall', _186 => _186(e)]), () => ( e)));
|
|
4931
5018
|
return original(read, stream);
|
|
4932
5019
|
}, "wrapped");
|
|
4933
5020
|
const reset = original[FOLD_RESET];
|
|
4934
|
-
if (reset) Object.defineProperty(
|
|
4935
|
-
return
|
|
5021
|
+
if (reset) Object.defineProperty(wrapped2, FOLD_RESET, { value: reset });
|
|
5022
|
+
return wrapped2;
|
|
4936
5023
|
}, "read_wrap");
|
|
4937
|
-
const make_batch_handlers = /* @__PURE__ */
|
|
5024
|
+
const make_batch_handlers = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => {
|
|
4938
5025
|
const handlers = new Map(batch_handlers);
|
|
4939
5026
|
for (const spec of fold_specs) {
|
|
4940
5027
|
handlers.set(
|
|
@@ -4952,7 +5039,7 @@ function act() {
|
|
|
4952
5039
|
}
|
|
4953
5040
|
return handlers;
|
|
4954
5041
|
}, "make_batch_handlers");
|
|
4955
|
-
const finalize_deprecations = /* @__PURE__ */
|
|
5042
|
+
const finalize_deprecations = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => {
|
|
4956
5043
|
const deprecation_summary = [];
|
|
4957
5044
|
for (const state2 of states.values()) {
|
|
4958
5045
|
const event_names = Object.keys(state2.events);
|
|
@@ -4968,7 +5055,7 @@ function act() {
|
|
|
4968
5055
|
});
|
|
4969
5056
|
}
|
|
4970
5057
|
for (const [action_name, handler] of Object.entries(state2.on)) {
|
|
4971
|
-
const static_target = _optionalChain([handler, 'optionalAccess',
|
|
5058
|
+
const static_target = _optionalChain([handler, 'optionalAccess', _187 => _187._static_emit]);
|
|
4972
5059
|
if (static_target && deprecated.has(static_target)) {
|
|
4973
5060
|
const current = current_version_of(static_target, event_names);
|
|
4974
5061
|
throw new Error(
|
|
@@ -4981,23 +5068,23 @@ function act() {
|
|
|
4981
5068
|
const list = deprecation_summary.map(
|
|
4982
5069
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4983
5070
|
).join(", ");
|
|
4984
|
-
|
|
5071
|
+
_chunkWDIBO6AWcjs.log.call(void 0, ).info(
|
|
4985
5072
|
`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.`
|
|
4986
5073
|
);
|
|
4987
5074
|
}
|
|
4988
5075
|
}, "finalize_deprecations");
|
|
4989
|
-
const closed = /* @__PURE__ */
|
|
5076
|
+
const closed = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (method) => {
|
|
4990
5077
|
throw new Error(
|
|
4991
5078
|
`act().${method}() was called after build(); the registry is already classified. Register everything before build() \u2014 build() itself may be called repeatedly (e.g. once per tenant with ActOptions.scoped).`
|
|
4992
5079
|
);
|
|
4993
5080
|
}, "closed");
|
|
4994
5081
|
const builder = {
|
|
4995
|
-
withState: /* @__PURE__ */
|
|
5082
|
+
withState: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (state2) => {
|
|
4996
5083
|
if (_built) closed("withState");
|
|
4997
5084
|
register_state(state2, states, registry.actions, registry.events);
|
|
4998
5085
|
return builder;
|
|
4999
5086
|
}, "withState"),
|
|
5000
|
-
withSlice: /* @__PURE__ */
|
|
5087
|
+
withSlice: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (input) => {
|
|
5001
5088
|
if (_built) closed("withSlice");
|
|
5002
5089
|
for (const s of input.states.values()) {
|
|
5003
5090
|
register_state(s, states, registry.actions, registry.events);
|
|
@@ -5007,23 +5094,22 @@ function act() {
|
|
|
5007
5094
|
for (const lane of input.lanes) register_lane(lane, lanes);
|
|
5008
5095
|
return builder;
|
|
5009
5096
|
}, "withSlice"),
|
|
5010
|
-
withProjection: /* @__PURE__ */
|
|
5097
|
+
withProjection: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (proj) => {
|
|
5011
5098
|
if (_built) closed("withProjection");
|
|
5012
5099
|
add_projection(proj);
|
|
5013
5100
|
return builder;
|
|
5014
5101
|
}, "withProjection"),
|
|
5015
|
-
withActor: /* @__PURE__ */
|
|
5016
|
-
withLane: /* @__PURE__ */
|
|
5102
|
+
withActor: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => builder, "withActor"),
|
|
5103
|
+
withLane: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (config2) => {
|
|
5017
5104
|
if (_built) closed("withLane");
|
|
5018
5105
|
register_lane(config2, lanes);
|
|
5019
5106
|
return builder;
|
|
5020
5107
|
}, "withLane"),
|
|
5021
|
-
on: /* @__PURE__ */
|
|
5108
|
+
on: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (event) => {
|
|
5022
5109
|
if (_built) closed("on");
|
|
5023
5110
|
return reaction_on(event, registry.events, builder);
|
|
5024
5111
|
}, "on"),
|
|
5025
|
-
build: /* @__PURE__ */
|
|
5026
|
-
_chunkOW67FBYOcjs.check.call(void 0, "act", _nullishCoalesce(options, () => ( {})));
|
|
5112
|
+
build: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (options) => {
|
|
5027
5113
|
if (!_built) {
|
|
5028
5114
|
for (const proj of pending_projections) add_projection(proj);
|
|
5029
5115
|
for (const proj of fold_projections) {
|
|
@@ -5041,7 +5127,7 @@ function act() {
|
|
|
5041
5127
|
`State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
|
|
5042
5128
|
);
|
|
5043
5129
|
const claimed = fold_specs.find((s) => s.target === proj.target);
|
|
5044
|
-
if (_optionalChain([claimed, 'optionalAccess',
|
|
5130
|
+
if (_optionalChain([claimed, 'optionalAccess', _188 => _188.projection]) === proj) continue;
|
|
5045
5131
|
if (batch_handlers.has(proj.target) || claimed)
|
|
5046
5132
|
throw new Error(
|
|
5047
5133
|
`Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
|
|
@@ -5063,7 +5149,7 @@ function act() {
|
|
|
5063
5149
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
5064
5150
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
5065
5151
|
finalize_deprecations();
|
|
5066
|
-
if (built.advisory)
|
|
5152
|
+
if (built.advisory) _chunkWDIBO6AWcjs.log.call(void 0, ).warn(built.advisory);
|
|
5067
5153
|
for (const [name, state2] of states) {
|
|
5068
5154
|
if (!state2.loads) continue;
|
|
5069
5155
|
const resolved = {};
|
|
@@ -5075,7 +5161,7 @@ function act() {
|
|
|
5075
5161
|
`Action "${action2}" loads "${l.state.name}", which is not registered \u2014 add it via withState/withSlice before build()`
|
|
5076
5162
|
);
|
|
5077
5163
|
const deprecated = l.events.find(
|
|
5078
|
-
(e) => _optionalChain([_de, 'access',
|
|
5164
|
+
(e) => _optionalChain([_de, 'access', _189 => _189.get, 'call', _190 => _190(registered.name), 'optionalAccess', _191 => _191.has, 'call', _192 => _192(e)])
|
|
5079
5165
|
);
|
|
5080
5166
|
if (deprecated)
|
|
5081
5167
|
throw new Error(
|
|
@@ -5107,7 +5193,7 @@ function act() {
|
|
|
5107
5193
|
synthesize_autoclose_reactions(
|
|
5108
5194
|
registry,
|
|
5109
5195
|
states,
|
|
5110
|
-
|
|
5196
|
+
_chunkWDIBO6AWcjs.current_autoclose_window
|
|
5111
5197
|
);
|
|
5112
5198
|
Object.freeze(registry.actions);
|
|
5113
5199
|
Object.freeze(registry.events);
|
|
@@ -5126,14 +5212,14 @@ function act() {
|
|
|
5126
5212
|
};
|
|
5127
5213
|
return builder;
|
|
5128
5214
|
}
|
|
5129
|
-
|
|
5215
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, act, "act");
|
|
5130
5216
|
|
|
5131
5217
|
// src/builders/projection-builder.ts
|
|
5132
5218
|
function _projection(target) {
|
|
5133
5219
|
const events = {};
|
|
5134
5220
|
const default_resolver = typeof target === "string" ? { target } : void 0;
|
|
5135
5221
|
const base = {
|
|
5136
|
-
on: /* @__PURE__ */
|
|
5222
|
+
on: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (entry) => {
|
|
5137
5223
|
const keys = Object.keys(entry);
|
|
5138
5224
|
if (keys.length !== 1) throw new Error(".on() requires exactly one key");
|
|
5139
5225
|
const event = keys[0];
|
|
@@ -5145,7 +5231,7 @@ function _projection(target) {
|
|
|
5145
5231
|
};
|
|
5146
5232
|
}
|
|
5147
5233
|
return {
|
|
5148
|
-
do: /* @__PURE__ */
|
|
5234
|
+
do: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (handler) => {
|
|
5149
5235
|
const widened = base;
|
|
5150
5236
|
return add_reaction(
|
|
5151
5237
|
events,
|
|
@@ -5156,8 +5242,8 @@ function _projection(target) {
|
|
|
5156
5242
|
handler,
|
|
5157
5243
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5158
5244
|
options: {
|
|
5159
|
-
blockOnError:
|
|
5160
|
-
maxRetries:
|
|
5245
|
+
blockOnError: _chunkWDIBO6AWcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5246
|
+
maxRetries: _chunkWDIBO6AWcjs.DEFAULT_MAX_RETRIES
|
|
5161
5247
|
}
|
|
5162
5248
|
}),
|
|
5163
5249
|
widened
|
|
@@ -5165,7 +5251,7 @@ function _projection(target) {
|
|
|
5165
5251
|
}, "do")
|
|
5166
5252
|
};
|
|
5167
5253
|
}, "on"),
|
|
5168
|
-
build: /* @__PURE__ */
|
|
5254
|
+
build: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => ({
|
|
5169
5255
|
_tag: "Projection",
|
|
5170
5256
|
events,
|
|
5171
5257
|
...target !== void 0 && { target }
|
|
@@ -5174,20 +5260,20 @@ function _projection(target) {
|
|
|
5174
5260
|
};
|
|
5175
5261
|
if (typeof target === "string") {
|
|
5176
5262
|
return Object.assign(base, {
|
|
5177
|
-
batch: /* @__PURE__ */
|
|
5178
|
-
build: /* @__PURE__ */
|
|
5263
|
+
batch: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (handler) => ({
|
|
5264
|
+
build: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => ({
|
|
5179
5265
|
_tag: "Projection",
|
|
5180
5266
|
events,
|
|
5181
5267
|
target,
|
|
5182
5268
|
batchHandler: handler
|
|
5183
5269
|
}), "build")
|
|
5184
5270
|
}), "batch"),
|
|
5185
|
-
of: /* @__PURE__ */
|
|
5271
|
+
of: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (...args) => {
|
|
5186
5272
|
if (Object.keys(events).length > 0)
|
|
5187
5273
|
throw new Error(
|
|
5188
5274
|
`Projection "${target}" mixes .of() with .on() handlers \u2014 a projection either folds a state or declares handlers, never both`
|
|
5189
5275
|
);
|
|
5190
|
-
const is_state = /* @__PURE__ */
|
|
5276
|
+
const is_state = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (a) => !!a && typeof a.init === "function", "is_state");
|
|
5191
5277
|
const partials = args.filter(is_state);
|
|
5192
5278
|
const options = _nullishCoalesce(args.find((a) => !is_state(a)), () => ( {}));
|
|
5193
5279
|
if (partials.length === 0)
|
|
@@ -5198,7 +5284,7 @@ function _projection(target) {
|
|
|
5198
5284
|
throw new Error(
|
|
5199
5285
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5200
5286
|
);
|
|
5201
|
-
const config2 =
|
|
5287
|
+
const config2 = _chunkWDIBO6AWcjs.check.call(void 0, "fold", options);
|
|
5202
5288
|
const fold_events = {};
|
|
5203
5289
|
for (const partial of partials)
|
|
5204
5290
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5216,8 +5302,8 @@ function _projection(target) {
|
|
|
5216
5302
|
handler: noop,
|
|
5217
5303
|
resolver: { target },
|
|
5218
5304
|
options: {
|
|
5219
|
-
blockOnError:
|
|
5220
|
-
maxRetries:
|
|
5305
|
+
blockOnError: _chunkWDIBO6AWcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5306
|
+
maxRetries: _chunkWDIBO6AWcjs.DEFAULT_MAX_RETRIES
|
|
5221
5307
|
}
|
|
5222
5308
|
}
|
|
5223
5309
|
]
|
|
@@ -5225,8 +5311,8 @@ function _projection(target) {
|
|
|
5225
5311
|
};
|
|
5226
5312
|
}
|
|
5227
5313
|
return {
|
|
5228
|
-
flush: /* @__PURE__ */
|
|
5229
|
-
build: /* @__PURE__ */
|
|
5314
|
+
flush: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (handler) => ({
|
|
5315
|
+
build: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => ({
|
|
5230
5316
|
_tag: "Projection",
|
|
5231
5317
|
events: fold_events,
|
|
5232
5318
|
target,
|
|
@@ -5239,11 +5325,11 @@ function _projection(target) {
|
|
|
5239
5325
|
}
|
|
5240
5326
|
return base;
|
|
5241
5327
|
}
|
|
5242
|
-
|
|
5328
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, _projection, "_projection");
|
|
5243
5329
|
function projection(target) {
|
|
5244
5330
|
return _projection(target);
|
|
5245
5331
|
}
|
|
5246
|
-
|
|
5332
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, projection, "projection");
|
|
5247
5333
|
|
|
5248
5334
|
// src/builders/slice-builder.ts
|
|
5249
5335
|
function slice() {
|
|
@@ -5253,20 +5339,20 @@ function slice() {
|
|
|
5253
5339
|
const projections = [];
|
|
5254
5340
|
const lanes = [];
|
|
5255
5341
|
const builder = {
|
|
5256
|
-
withState: /* @__PURE__ */
|
|
5342
|
+
withState: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (state2) => {
|
|
5257
5343
|
register_state(state2, states, actions, events);
|
|
5258
5344
|
return builder;
|
|
5259
5345
|
}, "withState"),
|
|
5260
|
-
withProjection: /* @__PURE__ */
|
|
5346
|
+
withProjection: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (proj) => {
|
|
5261
5347
|
projections.push(proj);
|
|
5262
5348
|
return builder;
|
|
5263
5349
|
}, "withProjection"),
|
|
5264
|
-
withLane: /* @__PURE__ */
|
|
5350
|
+
withLane: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (config2) => {
|
|
5265
5351
|
register_lane(config2, lanes);
|
|
5266
5352
|
return builder;
|
|
5267
5353
|
}, "withLane"),
|
|
5268
|
-
on: /* @__PURE__ */
|
|
5269
|
-
build: /* @__PURE__ */
|
|
5354
|
+
on: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (event) => reaction_on(event, events, builder), "on"),
|
|
5355
|
+
build: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, () => ({
|
|
5270
5356
|
_tag: "Slice",
|
|
5271
5357
|
states,
|
|
5272
5358
|
events,
|
|
@@ -5277,7 +5363,7 @@ function slice() {
|
|
|
5277
5363
|
};
|
|
5278
5364
|
return builder;
|
|
5279
5365
|
}
|
|
5280
|
-
|
|
5366
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, slice, "slice");
|
|
5281
5367
|
|
|
5282
5368
|
// src/builders/state-builder.ts
|
|
5283
5369
|
function state(entry) {
|
|
@@ -5309,8 +5395,8 @@ function state(entry) {
|
|
|
5309
5395
|
// `act().build()` flips both on states with `sensitive(...)`
|
|
5310
5396
|
// events to bake in the gate / split and gate the cache write.
|
|
5311
5397
|
pii_aware: false,
|
|
5312
|
-
view: /* @__PURE__ */
|
|
5313
|
-
message: /* @__PURE__ */
|
|
5398
|
+
view: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (event) => event, "view"),
|
|
5399
|
+
message: /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (validated) => validated, "message")
|
|
5314
5400
|
};
|
|
5315
5401
|
const builder = action_builder(internal);
|
|
5316
5402
|
return Object.assign(builder, {
|
|
@@ -5324,7 +5410,7 @@ function state(entry) {
|
|
|
5324
5410
|
}
|
|
5325
5411
|
};
|
|
5326
5412
|
}
|
|
5327
|
-
|
|
5413
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, state, "state");
|
|
5328
5414
|
function action_builder(state2) {
|
|
5329
5415
|
const internal = state2;
|
|
5330
5416
|
const builder = {
|
|
@@ -5337,7 +5423,7 @@ function action_builder(state2) {
|
|
|
5337
5423
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5338
5424
|
internal.actions[action2] = schema;
|
|
5339
5425
|
if (options) {
|
|
5340
|
-
|
|
5426
|
+
_chunkWDIBO6AWcjs.check.call(void 0, "action", options);
|
|
5341
5427
|
internal.options ??= {};
|
|
5342
5428
|
internal.options[action2] = options;
|
|
5343
5429
|
}
|
|
@@ -5361,12 +5447,12 @@ function action_builder(state2) {
|
|
|
5361
5447
|
(internal.loads ??= {})[action2] = loads;
|
|
5362
5448
|
return { loads: load2, requires, emit };
|
|
5363
5449
|
}
|
|
5364
|
-
|
|
5450
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, load2, "load");
|
|
5365
5451
|
function requires(rules) {
|
|
5366
5452
|
(internal.requires ??= {})[action2] = rules;
|
|
5367
5453
|
return { emit };
|
|
5368
5454
|
}
|
|
5369
|
-
|
|
5455
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, requires, "requires");
|
|
5370
5456
|
function emit(handler) {
|
|
5371
5457
|
if (typeof handler === "string") {
|
|
5372
5458
|
const event_name = handler;
|
|
@@ -5382,7 +5468,7 @@ function action_builder(state2) {
|
|
|
5382
5468
|
}
|
|
5383
5469
|
return builder;
|
|
5384
5470
|
}
|
|
5385
|
-
|
|
5471
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, emit, "emit");
|
|
5386
5472
|
return { loads: load2, requires, emit };
|
|
5387
5473
|
},
|
|
5388
5474
|
snap(snap2) {
|
|
@@ -5433,7 +5519,7 @@ function action_builder(state2) {
|
|
|
5433
5519
|
};
|
|
5434
5520
|
return builder;
|
|
5435
5521
|
}
|
|
5436
|
-
|
|
5522
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, action_builder, "action_builder");
|
|
5437
5523
|
|
|
5438
5524
|
// src/csv.ts
|
|
5439
5525
|
var _fs = require('fs');
|
|
@@ -5449,7 +5535,7 @@ var CSV_COLUMNS = [
|
|
|
5449
5535
|
];
|
|
5450
5536
|
var CsvFile = class {
|
|
5451
5537
|
static {
|
|
5452
|
-
|
|
5538
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, this, "CsvFile");
|
|
5453
5539
|
}
|
|
5454
5540
|
|
|
5455
5541
|
|
|
@@ -5544,7 +5630,7 @@ async function* linesFromFile(path) {
|
|
|
5544
5630
|
stream.close();
|
|
5545
5631
|
}
|
|
5546
5632
|
}
|
|
5547
|
-
|
|
5633
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, linesFromFile, "linesFromFile");
|
|
5548
5634
|
async function* linesFromBlob(blob) {
|
|
5549
5635
|
let start = 0;
|
|
5550
5636
|
while (start < blob.length) {
|
|
@@ -5555,7 +5641,7 @@ async function* linesFromBlob(blob) {
|
|
|
5555
5641
|
await Promise.resolve();
|
|
5556
5642
|
}
|
|
5557
5643
|
}
|
|
5558
|
-
|
|
5644
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, linesFromBlob, "linesFromBlob");
|
|
5559
5645
|
function parse_csv_line(line) {
|
|
5560
5646
|
const fields = [];
|
|
5561
5647
|
let i = 0;
|
|
@@ -5589,12 +5675,12 @@ function parse_csv_line(line) {
|
|
|
5589
5675
|
}
|
|
5590
5676
|
return fields;
|
|
5591
5677
|
}
|
|
5592
|
-
|
|
5678
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, parse_csv_line, "parse_csv_line");
|
|
5593
5679
|
function csv_escape(value) {
|
|
5594
5680
|
if (/[",\n\r]/.test(value)) return `"${value.replace(/"/g, '""')}"`;
|
|
5595
5681
|
return value;
|
|
5596
5682
|
}
|
|
5597
|
-
|
|
5683
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, csv_escape, "csv_escape");
|
|
5598
5684
|
function write_line(writer, line) {
|
|
5599
5685
|
return new Promise((resolve, reject) => {
|
|
5600
5686
|
writer.write(`${line}
|
|
@@ -5604,34 +5690,39 @@ function write_line(writer, line) {
|
|
|
5604
5690
|
});
|
|
5605
5691
|
});
|
|
5606
5692
|
}
|
|
5607
|
-
|
|
5693
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, write_line, "write_line");
|
|
5608
5694
|
|
|
5609
5695
|
// src/deprecated.ts
|
|
5610
|
-
var check_appends =
|
|
5611
|
-
var throw_if_stale =
|
|
5612
|
-
var concurrency_error =
|
|
5613
|
-
var seed_event =
|
|
5614
|
-
var fair_slots =
|
|
5615
|
-
var is_literal_source =
|
|
5616
|
-
var notification_of =
|
|
5617
|
-
var DEFAULT_QUERY_STREAMS_LIMIT2 =
|
|
5618
|
-
var ActorSchema2 =
|
|
5619
|
-
var TargetSchema2 =
|
|
5620
|
-
var EventMetaSchema2 =
|
|
5621
|
-
var CausationEventSchema2 =
|
|
5622
|
-
var CommittedMetaSchema2 =
|
|
5623
|
-
var QuerySchema2 =
|
|
5624
|
-
var Environments2 =
|
|
5625
|
-
var LogLevels2 =
|
|
5626
|
-
var ExitCodes2 =
|
|
5627
|
-
var DEFAULT_LANE2 =
|
|
5628
|
-
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 =
|
|
5629
|
-
var DEFAULT_SETTLE_DEBOUNCE_MS2 =
|
|
5630
|
-
var PackageSchema =
|
|
5631
|
-
var default_scope =
|
|
5632
|
-
var extend = /* @__PURE__ */
|
|
5696
|
+
var check_appends = _chunkDCWPJFXRcjs.checkAppends;
|
|
5697
|
+
var throw_if_stale = _chunkDCWPJFXRcjs.checkVersion;
|
|
5698
|
+
var concurrency_error = _chunkDCWPJFXRcjs.concurrencyError;
|
|
5699
|
+
var seed_event = _chunkDCWPJFXRcjs.seedEvent;
|
|
5700
|
+
var fair_slots = _chunkDCWPJFXRcjs.fairSlots;
|
|
5701
|
+
var is_literal_source = _chunkDCWPJFXRcjs.isStreamName;
|
|
5702
|
+
var notification_of = _chunkDCWPJFXRcjs.parseNotification;
|
|
5703
|
+
var DEFAULT_QUERY_STREAMS_LIMIT2 = _chunkUEGKXCSQcjs.DEFAULT_QUERY_STREAMS_LIMIT;
|
|
5704
|
+
var ActorSchema2 = _chunkUEGKXCSQcjs.ActorSchema;
|
|
5705
|
+
var TargetSchema2 = _chunkUEGKXCSQcjs.TargetSchema;
|
|
5706
|
+
var EventMetaSchema2 = _chunkUEGKXCSQcjs.EventMetaSchema;
|
|
5707
|
+
var CausationEventSchema2 = _chunkUEGKXCSQcjs.CausationEventSchema;
|
|
5708
|
+
var CommittedMetaSchema2 = _chunkUEGKXCSQcjs.CommittedMetaSchema;
|
|
5709
|
+
var QuerySchema2 = _chunkUEGKXCSQcjs.QuerySchema;
|
|
5710
|
+
var Environments2 = _chunkUEGKXCSQcjs.Environments;
|
|
5711
|
+
var LogLevels2 = _chunkUEGKXCSQcjs.LogLevels;
|
|
5712
|
+
var ExitCodes2 = _chunkUEGKXCSQcjs.ExitCodes;
|
|
5713
|
+
var DEFAULT_LANE2 = _chunkUEGKXCSQcjs.DEFAULT_LANE;
|
|
5714
|
+
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkUEGKXCSQcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5715
|
+
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkUEGKXCSQcjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5716
|
+
var PackageSchema = _chunkWDIBO6AWcjs.package_schema;
|
|
5717
|
+
var default_scope = _chunkWDIBO6AWcjs.unscoped_ports;
|
|
5718
|
+
var extend = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (source, schema, target) => ({ ...target, ..._chunkWDIBO6AWcjs.validate.call(void 0, "config", source, schema) }), "extend");
|
|
5633
5719
|
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])?$/;
|
|
5634
|
-
var dateReviver = /* @__PURE__ */
|
|
5720
|
+
var dateReviver = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
|
|
5721
|
+
function sensitiveFields(schema) {
|
|
5722
|
+
return Object.keys(pii_schemas(schema));
|
|
5723
|
+
}
|
|
5724
|
+
_chunkUEGKXCSQcjs.__name.call(void 0, sensitiveFields, "sensitiveFields");
|
|
5725
|
+
var pii_fields = sensitiveFields;
|
|
5635
5726
|
|
|
5636
5727
|
|
|
5637
5728
|
|
|
@@ -5691,5 +5782,5 @@ var dateReviver = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (_key, v
|
|
|
5691
5782
|
|
|
5692
5783
|
|
|
5693
5784
|
|
|
5694
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError =
|
|
5785
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkUEGKXCSQcjs.ConcurrencyError; exports.ConsoleLogger = _chunkWDIBO6AWcjs.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 = _chunkUEGKXCSQcjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunkUEGKXCSQcjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkWDIBO6AWcjs.InMemoryCache; exports.InMemoryStore = _chunkWDIBO6AWcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunkUEGKXCSQcjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunkUEGKXCSQcjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunkUEGKXCSQcjs.REDACTED; exports.SHREDDED = _chunkUEGKXCSQcjs.SHREDDED; exports.SNAP_EVENT = _chunkUEGKXCSQcjs.SNAP_EVENT; exports.StoreError = _chunkUEGKXCSQcjs.StoreError; exports.StreamClosedError = _chunkUEGKXCSQcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkUEGKXCSQcjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunkUEGKXCSQcjs.ValidationError; exports.ZodEmpty = _chunkUEGKXCSQcjs.ZodEmpty; exports.act = act; exports.cache = _chunkWDIBO6AWcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkWDIBO6AWcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkWDIBO6AWcjs.dispose; exports.disposeAndExit = _chunkWDIBO6AWcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkWDIBO6AWcjs.log; exports.notification_of = notification_of; exports.pii_fields = pii_fields; exports.port = _chunkWDIBO6AWcjs.port; exports.projection = projection; exports.seed_event = seed_event; exports.sensitive = _chunkUEGKXCSQcjs.sensitive; exports.sensitiveFields = sensitiveFields; exports.sleep = _chunkWDIBO6AWcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkWDIBO6AWcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkWDIBO6AWcjs.validate;
|
|
5695
5786
|
//# sourceMappingURL=index.cjs.map
|