@rotorsoft/act 2.1.9 → 2.1.11
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/builder-utils.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/deprecated.d.ts +0 -3
- package/dist/@types/deprecated.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-policy.d.ts +1 -1
- package/dist/@types/internal/autoclose-policy.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +128 -95
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/defer-config.d.ts +2 -9
- package/dist/@types/internal/defer-config.d.ts.map +1 -1
- package/dist/@types/types/act.d.ts +2 -2
- package/dist/@types/types/action.d.ts +0 -13
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.js +2 -2
- package/dist/{chunk-C35J3SNT.js → chunk-BQUOIHOR.js} +1 -1
- package/dist/chunk-BQUOIHOR.js.map +1 -0
- package/dist/{chunk-YXP6WASH.cjs → chunk-N74AN6L5.cjs} +132 -139
- package/dist/chunk-N74AN6L5.cjs.map +1 -0
- package/dist/{chunk-TUALNYW2.js → chunk-RV34EYSN.js} +2 -2
- package/dist/{chunk-D7LQNOEV.cjs → chunk-SC6TY4P2.cjs} +4 -4
- package/dist/{chunk-D7LQNOEV.cjs.map → chunk-SC6TY4P2.cjs.map} +1 -1
- package/dist/{chunk-NYDHZSYZ.js → chunk-Y2ISPWQL.js} +113 -120
- package/dist/chunk-Y2ISPWQL.js.map +1 -0
- package/dist/{chunk-QFYPSI6P.cjs → chunk-ZTHGF62O.cjs} +1 -1
- package/dist/chunk-ZTHGF62O.cjs.map +1 -0
- package/dist/index.cjs +204 -274
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -117
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +5 -5
- package/dist/test/index.js +3 -3
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-C35J3SNT.js.map +0 -1
- package/dist/chunk-NYDHZSYZ.js.map +0 -1
- package/dist/chunk-QFYPSI6P.cjs.map +0 -1
- package/dist/chunk-YXP6WASH.cjs.map +0 -1
- /package/dist/{chunk-TUALNYW2.js.map → chunk-RV34EYSN.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -11,37 +11,23 @@ import {
|
|
|
11
11
|
LruMap,
|
|
12
12
|
MAX_SHUTDOWN_GRACE_MS,
|
|
13
13
|
cache,
|
|
14
|
-
|
|
15
|
-
check_scan_options,
|
|
16
|
-
check_store,
|
|
17
|
-
check_target,
|
|
14
|
+
check,
|
|
18
15
|
config,
|
|
19
16
|
current_autoclose_window,
|
|
20
17
|
current_reacting,
|
|
21
18
|
dispose,
|
|
22
19
|
disposeAndExit,
|
|
23
|
-
is_valid_target,
|
|
24
20
|
log,
|
|
25
21
|
make_reaction_scope,
|
|
26
22
|
make_run_scoped,
|
|
27
23
|
package_schema,
|
|
28
24
|
port,
|
|
29
25
|
register_weak_disposer,
|
|
30
|
-
resolveActConfig,
|
|
31
|
-
resolveActionConfig,
|
|
32
|
-
resolveAutocloseConfig,
|
|
33
|
-
resolveCircuitBreakerConfig,
|
|
34
|
-
resolveDrainConfig,
|
|
35
|
-
resolveFoldConfig,
|
|
36
|
-
resolveLaneConfig,
|
|
37
|
-
resolveReactionConfig,
|
|
38
|
-
resolveSettleConfig,
|
|
39
|
-
resolveShutdownConfig,
|
|
40
26
|
sleep,
|
|
41
27
|
store,
|
|
42
28
|
unscoped_ports,
|
|
43
29
|
validate
|
|
44
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-Y2ISPWQL.js";
|
|
45
31
|
import {
|
|
46
32
|
checkAppends,
|
|
47
33
|
checkVersion,
|
|
@@ -50,7 +36,7 @@ import {
|
|
|
50
36
|
isStreamName,
|
|
51
37
|
parseNotification,
|
|
52
38
|
seedEvent
|
|
53
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-RV34EYSN.js";
|
|
54
40
|
import {
|
|
55
41
|
ActorSchema,
|
|
56
42
|
CausationEventSchema,
|
|
@@ -85,7 +71,7 @@ import {
|
|
|
85
71
|
pii_schemas,
|
|
86
72
|
sensitive,
|
|
87
73
|
sensitiveFields
|
|
88
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-BQUOIHOR.js";
|
|
89
75
|
|
|
90
76
|
// src/signals.ts
|
|
91
77
|
process.once("SIGINT", async (arg) => {
|
|
@@ -814,52 +800,13 @@ function classify_registry(registry, states) {
|
|
|
814
800
|
}
|
|
815
801
|
|
|
816
802
|
// src/internal/autoclose-policy.ts
|
|
817
|
-
import { z } from "zod";
|
|
818
803
|
var DAY_MS = 864e5;
|
|
819
|
-
var MIN_AFTER_DAYS = 1 / 1440;
|
|
820
|
-
var MIN_KEEP_DAYS = 1;
|
|
821
804
|
function days_after(date, days) {
|
|
822
805
|
return new Date(date.getTime() + days * DAY_MS);
|
|
823
806
|
}
|
|
824
807
|
function days_before_now(days) {
|
|
825
808
|
return new Date(Date.now() - days * DAY_MS);
|
|
826
809
|
}
|
|
827
|
-
var window_schema = (field, min_days, floor) => z.object({
|
|
828
|
-
days: z.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
|
|
829
|
-
}).refine((o) => o.days >= min_days, {
|
|
830
|
-
message: `autocloses: ${field} resolves to < ${floor}, which is too short to be a meaningful retention window`
|
|
831
|
-
});
|
|
832
|
-
var AfterSchema = window_schema("after", MIN_AFTER_DAYS, "one minute");
|
|
833
|
-
var KeepSchema = window_schema("keep", MIN_KEEP_DAYS, "one day");
|
|
834
|
-
var IsSchema = z.union([
|
|
835
|
-
z.string().min(1, "autocloses: is must be a non-empty event name"),
|
|
836
|
-
z.array(
|
|
837
|
-
z.string().min(1, "autocloses: is entries must be non-empty event names")
|
|
838
|
-
).min(1, "autocloses: is must include at least one event name").readonly()
|
|
839
|
-
]);
|
|
840
|
-
var ReachesSchema = z.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
|
|
841
|
-
var OrBlockSchema = z.object({
|
|
842
|
-
after: AfterSchema.optional(),
|
|
843
|
-
is: IsSchema.optional(),
|
|
844
|
-
reaches: ReachesSchema.optional()
|
|
845
|
-
}).strict().refine(
|
|
846
|
-
(o) => o.after !== void 0 || o.is !== void 0 || o.reaches !== void 0,
|
|
847
|
-
{
|
|
848
|
-
message: "autocloses: `or` block must include at least one of after / is / reaches"
|
|
849
|
-
}
|
|
850
|
-
);
|
|
851
|
-
var AutoclosePolicySchema = z.object({
|
|
852
|
-
after: AfterSchema.optional(),
|
|
853
|
-
is: IsSchema.optional(),
|
|
854
|
-
reaches: ReachesSchema.optional(),
|
|
855
|
-
or: OrBlockSchema.optional(),
|
|
856
|
-
keep: KeepSchema.optional()
|
|
857
|
-
}).strict().refine(
|
|
858
|
-
(o) => o.after !== void 0 || o.is !== void 0 || o.reaches !== void 0 || o.or !== void 0 || o.keep !== void 0,
|
|
859
|
-
{
|
|
860
|
-
message: "autocloses: at least one of after / is / reaches / or / keep must be specified \u2014 empty `{}` is a misconfiguration"
|
|
861
|
-
}
|
|
862
|
-
);
|
|
863
810
|
function compile_after(after) {
|
|
864
811
|
return (_stream, head) => days_after(head.created, after.days) <= /* @__PURE__ */ new Date();
|
|
865
812
|
}
|
|
@@ -871,15 +818,15 @@ function compile_reaches(reaches) {
|
|
|
871
818
|
return (_stream, _head, count) => count >= reaches;
|
|
872
819
|
}
|
|
873
820
|
function policy_after_windows(options) {
|
|
874
|
-
const parsed =
|
|
821
|
+
const parsed = check("autoclose_policy", options);
|
|
875
822
|
return [parsed.after, parsed.or?.after].flatMap((w) => w ? [w.days] : []);
|
|
876
823
|
}
|
|
877
824
|
function policy_keep_days(options) {
|
|
878
|
-
const parsed =
|
|
825
|
+
const parsed = check("autoclose_policy", options);
|
|
879
826
|
return parsed.keep?.days;
|
|
880
827
|
}
|
|
881
828
|
function compile_autoclose_policy(options) {
|
|
882
|
-
const parsed =
|
|
829
|
+
const parsed = check("autoclose_policy", options);
|
|
883
830
|
const and_preds = [];
|
|
884
831
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
885
832
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -940,31 +887,14 @@ function next_window_open(window, now) {
|
|
|
940
887
|
}
|
|
941
888
|
|
|
942
889
|
// src/internal/defer-config.ts
|
|
943
|
-
import { z as z2 } from "zod";
|
|
944
|
-
var DeferDurationSchema = z2.object({
|
|
945
|
-
days: z2.number().positive().optional(),
|
|
946
|
-
hours: z2.number().positive().optional(),
|
|
947
|
-
minutes: z2.number().positive().optional()
|
|
948
|
-
}).strict().refine((d) => d.days != null || d.hours != null || d.minutes != null, {
|
|
949
|
-
message: "defer: a duration needs at least one of days, hours, or minutes"
|
|
950
|
-
});
|
|
951
|
-
var DeferWhenSchema = z2.object({
|
|
952
|
-
after: DeferDurationSchema.optional(),
|
|
953
|
-
at: z2.date().optional()
|
|
954
|
-
}).strict().refine((w) => w.after === void 0 !== (w.at === void 0), {
|
|
955
|
-
message: "defer: specify exactly one of `after` or `at`"
|
|
956
|
-
});
|
|
957
890
|
function duration_ms(d) {
|
|
958
891
|
return (d.days ?? 0) * 864e5 + (d.hours ?? 0) * 36e5 + (d.minutes ?? 0) * 6e4;
|
|
959
892
|
}
|
|
960
893
|
function resolve_defer_at(when, event) {
|
|
961
|
-
const parsed =
|
|
894
|
+
const parsed = check("defer", when);
|
|
962
895
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
963
896
|
return parsed.at.getTime();
|
|
964
897
|
}
|
|
965
|
-
function assert_defer_when(when) {
|
|
966
|
-
DeferWhenSchema.parse(when);
|
|
967
|
-
}
|
|
968
898
|
function make_deferred(handler, schedule) {
|
|
969
899
|
const call = handler;
|
|
970
900
|
const deferred = async (event, stream, app) => {
|
|
@@ -1165,7 +1095,7 @@ import { patch } from "@rotorsoft/act-patch";
|
|
|
1165
1095
|
import { prettifyError, ZodError } from "zod";
|
|
1166
1096
|
|
|
1167
1097
|
// src/internal/date-reviver.ts
|
|
1168
|
-
import { z
|
|
1098
|
+
import { z } from "zod";
|
|
1169
1099
|
function variant_schema(schema, walk) {
|
|
1170
1100
|
const shape = def_of(schema)?.shape;
|
|
1171
1101
|
if (!shape) {
|
|
@@ -1179,7 +1109,7 @@ function variant_schema(schema, walk) {
|
|
|
1179
1109
|
if (dates) dated = true;
|
|
1180
1110
|
next[key] = (dates ?? field).optional();
|
|
1181
1111
|
}
|
|
1182
|
-
return { schema:
|
|
1112
|
+
return { schema: z.looseObject(next), dated };
|
|
1183
1113
|
}
|
|
1184
1114
|
function date_reviver_schema(schema) {
|
|
1185
1115
|
let recursive = false;
|
|
@@ -1190,7 +1120,7 @@ function date_reviver_schema(schema) {
|
|
|
1190
1120
|
if (done.has(node)) return done.get(node);
|
|
1191
1121
|
if (active.has(node)) {
|
|
1192
1122
|
recursive = true;
|
|
1193
|
-
return tie ?
|
|
1123
|
+
return tie ? z.lazy(() => done.get(node)) : void 0;
|
|
1194
1124
|
}
|
|
1195
1125
|
active.add(node);
|
|
1196
1126
|
const result = build(node, walk);
|
|
@@ -1209,7 +1139,7 @@ function build(schema, walk) {
|
|
|
1209
1139
|
const inner = () => walk(def.innerType);
|
|
1210
1140
|
switch (def.type) {
|
|
1211
1141
|
case "date":
|
|
1212
|
-
return
|
|
1142
|
+
return z.coerce.date();
|
|
1213
1143
|
case "object": {
|
|
1214
1144
|
const shape = def.shape;
|
|
1215
1145
|
if (!shape) return void 0;
|
|
@@ -1218,25 +1148,25 @@ function build(schema, walk) {
|
|
|
1218
1148
|
const dates = walk(field);
|
|
1219
1149
|
if (dates) dated[key] = dates.optional();
|
|
1220
1150
|
}
|
|
1221
|
-
return Object.keys(dated).length ?
|
|
1151
|
+
return Object.keys(dated).length ? z.looseObject(dated) : void 0;
|
|
1222
1152
|
}
|
|
1223
1153
|
case "array": {
|
|
1224
1154
|
const element = walk(def.element);
|
|
1225
|
-
return element &&
|
|
1155
|
+
return element && z.array(element);
|
|
1226
1156
|
}
|
|
1227
1157
|
case "tuple": {
|
|
1228
1158
|
const items = def.items.map((i) => walk(i));
|
|
1229
|
-
return items.some(Boolean) ?
|
|
1159
|
+
return items.some(Boolean) ? z.tuple(items.map((i) => i ?? z.unknown())) : void 0;
|
|
1230
1160
|
}
|
|
1231
1161
|
case "record": {
|
|
1232
1162
|
const value = walk(def.valueType);
|
|
1233
|
-
return value &&
|
|
1163
|
+
return value && z.record(z.string(), value);
|
|
1234
1164
|
}
|
|
1235
1165
|
case "union": {
|
|
1236
1166
|
const variants = def.options.map(
|
|
1237
1167
|
(o) => variant_schema(o, walk)
|
|
1238
1168
|
);
|
|
1239
|
-
return variants.some((v) => v.dated) ?
|
|
1169
|
+
return variants.some((v) => v.dated) ? z.union(variants.map((v) => v.schema)) : void 0;
|
|
1240
1170
|
}
|
|
1241
1171
|
case "nullable":
|
|
1242
1172
|
return inner()?.nullable();
|
|
@@ -3008,7 +2938,9 @@ var CorrelateCycle = class {
|
|
|
3008
2938
|
return;
|
|
3009
2939
|
}
|
|
3010
2940
|
if (!resolved) continue;
|
|
3011
|
-
|
|
2941
|
+
try {
|
|
2942
|
+
check("target", resolved);
|
|
2943
|
+
} catch {
|
|
3012
2944
|
report_bad_priority(
|
|
3013
2945
|
this._reported,
|
|
3014
2946
|
reaction.handler.name,
|
|
@@ -3401,13 +3333,6 @@ var SettleLoop = class {
|
|
|
3401
3333
|
};
|
|
3402
3334
|
|
|
3403
3335
|
// src/act.ts
|
|
3404
|
-
function validate_only_lanes(only, declared) {
|
|
3405
|
-
const unknown = (only ?? []).filter((l) => !declared.includes(l));
|
|
3406
|
-
if (unknown.length > 0)
|
|
3407
|
-
throw new Error(
|
|
3408
|
-
`ActOptions.onlyLanes references undeclared lane(s): ${unknown.map((l) => `"${l}"`).join(", ")}`
|
|
3409
|
-
);
|
|
3410
|
-
}
|
|
3411
3336
|
var Act = class {
|
|
3412
3337
|
_emitter = new EventEmitter();
|
|
3413
3338
|
_breaker;
|
|
@@ -3515,9 +3440,16 @@ var Act = class {
|
|
|
3515
3440
|
this._states = states;
|
|
3516
3441
|
this._batch_handlers = batch_handlers;
|
|
3517
3442
|
this._lanes = lanes;
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3443
|
+
const declared = ["default", ...lanes.map((l) => l.name)];
|
|
3444
|
+
this._declared_lanes = declared;
|
|
3445
|
+
const undeclared = (options.onlyLanes ?? []).filter(
|
|
3446
|
+
(l) => !declared.includes(l)
|
|
3447
|
+
);
|
|
3448
|
+
if (undeclared.length > 0)
|
|
3449
|
+
throw new Error(
|
|
3450
|
+
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3451
|
+
);
|
|
3452
|
+
if (options.scoped) check("store", options.scoped.store);
|
|
3521
3453
|
this._ports = options.scoped ?? unscoped_ports();
|
|
3522
3454
|
const ports = this._ports;
|
|
3523
3455
|
this._scoped = make_run_scoped({
|
|
@@ -3530,7 +3462,7 @@ var Act = class {
|
|
|
3530
3462
|
return ports.cache;
|
|
3531
3463
|
},
|
|
3532
3464
|
// Parsed per build, so a bad window throws on every build.
|
|
3533
|
-
autoclose_window:
|
|
3465
|
+
autoclose_window: check("autoclose", options).autocloseWindow
|
|
3534
3466
|
});
|
|
3535
3467
|
this._correlator = options.correlator ?? default_correlator;
|
|
3536
3468
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
@@ -3572,7 +3504,7 @@ var Act = class {
|
|
|
3572
3504
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3573
3505
|
_build_breaker(options) {
|
|
3574
3506
|
return new CircuitBreaker(
|
|
3575
|
-
|
|
3507
|
+
check("circuit_breaker", options.circuitBreaker ?? {}),
|
|
3576
3508
|
{
|
|
3577
3509
|
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3578
3510
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
@@ -3705,7 +3637,7 @@ var Act = class {
|
|
|
3705
3637
|
*/
|
|
3706
3638
|
shutdown(options) {
|
|
3707
3639
|
if (!this._shutdown_promise) {
|
|
3708
|
-
|
|
3640
|
+
check("shutdown", options ?? {});
|
|
3709
3641
|
this._shutdown_promise = (async () => {
|
|
3710
3642
|
this.stop_correlations();
|
|
3711
3643
|
this._settle.stop(true);
|
|
@@ -3971,7 +3903,7 @@ var Act = class {
|
|
|
3971
3903
|
* @see {@link correlate} for dynamic stream discovery
|
|
3972
3904
|
*/
|
|
3973
3905
|
async drain(options = {}) {
|
|
3974
|
-
|
|
3906
|
+
check("drain", options);
|
|
3975
3907
|
if (!this._drain)
|
|
3976
3908
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3977
3909
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4235,7 +4167,7 @@ var Act = class {
|
|
|
4235
4167
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4236
4168
|
*/
|
|
4237
4169
|
async restore(source, opts = {}, sink) {
|
|
4238
|
-
|
|
4170
|
+
check("scan", opts);
|
|
4239
4171
|
return this._scoped(async () => {
|
|
4240
4172
|
const started = Date.now();
|
|
4241
4173
|
if (opts.dry_run) {
|
|
@@ -4315,7 +4247,7 @@ var Act = class {
|
|
|
4315
4247
|
* ```
|
|
4316
4248
|
*/
|
|
4317
4249
|
async *audit(categories, options) {
|
|
4318
|
-
|
|
4250
|
+
check("audit", options ?? {});
|
|
4319
4251
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4320
4252
|
while (true) {
|
|
4321
4253
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4343,7 +4275,7 @@ var Act = class {
|
|
|
4343
4275
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4344
4276
|
*/
|
|
4345
4277
|
async prioritize(filter, priority) {
|
|
4346
|
-
|
|
4278
|
+
check("target", { priority });
|
|
4347
4279
|
return this._scoped(() => store().prioritize(filter, priority));
|
|
4348
4280
|
}
|
|
4349
4281
|
// Shared by `close()` and reaction-requested closes.
|
|
@@ -4424,7 +4356,7 @@ var Act = class {
|
|
|
4424
4356
|
* @see {@link correlate} for manual correlation
|
|
4425
4357
|
*/
|
|
4426
4358
|
settle(options) {
|
|
4427
|
-
|
|
4359
|
+
check("settle", options ?? {});
|
|
4428
4360
|
this._schedule(options);
|
|
4429
4361
|
}
|
|
4430
4362
|
};
|
|
@@ -4621,7 +4553,7 @@ var _this_ = ({ stream }) => ({
|
|
|
4621
4553
|
|
|
4622
4554
|
// src/builders/builder-utils.ts
|
|
4623
4555
|
function register_lane(config2, lanes) {
|
|
4624
|
-
|
|
4556
|
+
check("lane", config2);
|
|
4625
4557
|
if (config2.name === DEFAULT_LANE)
|
|
4626
4558
|
throw new Error(`Lane "${DEFAULT_LANE}" is reserved`);
|
|
4627
4559
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
@@ -4645,7 +4577,7 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4645
4577
|
events[event].reactions.set(name, reaction);
|
|
4646
4578
|
return Object.assign(builder, {
|
|
4647
4579
|
to(resolver) {
|
|
4648
|
-
if (typeof resolver === "object")
|
|
4580
|
+
if (typeof resolver === "object") check("target", resolver);
|
|
4649
4581
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4650
4582
|
return builder;
|
|
4651
4583
|
}
|
|
@@ -4659,14 +4591,14 @@ function reaction_on(event, events, builder) {
|
|
|
4659
4591
|
"Reaction",
|
|
4660
4592
|
() => {
|
|
4661
4593
|
if (schedule && typeof schedule !== "function")
|
|
4662
|
-
|
|
4594
|
+
check("defer", schedule);
|
|
4663
4595
|
return {
|
|
4664
4596
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4665
4597
|
resolver: _this_,
|
|
4666
4598
|
// Validate the whole bag at the declaration site so a bad
|
|
4667
4599
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4668
4600
|
// not a NaN gate on the first retry.
|
|
4669
|
-
options:
|
|
4601
|
+
options: check("reaction", {
|
|
4670
4602
|
blockOnError: options?.blockOnError ?? DEFAULT_BLOCK_ON_ERROR,
|
|
4671
4603
|
maxRetries: options?.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
4672
4604
|
backoff: options?.backoff
|
|
@@ -4684,7 +4616,7 @@ function reaction_on(event, events, builder) {
|
|
|
4684
4616
|
}
|
|
4685
4617
|
|
|
4686
4618
|
// src/builders/event-builder.ts
|
|
4687
|
-
import { z as
|
|
4619
|
+
import { z as z2 } from "zod";
|
|
4688
4620
|
function event_tags(schema) {
|
|
4689
4621
|
const pii = pii_schemas(schema);
|
|
4690
4622
|
const pii_dates = {};
|
|
@@ -4701,7 +4633,7 @@ function event_tags(schema) {
|
|
|
4701
4633
|
return {
|
|
4702
4634
|
sensitive: pii,
|
|
4703
4635
|
date_reviver: data_reviver_schema && revive(data_reviver_schema),
|
|
4704
|
-
pii_date_reviver: dated_pii ? revive(
|
|
4636
|
+
pii_date_reviver: dated_pii ? revive(z2.looseObject(pii_dates)) : void 0
|
|
4705
4637
|
};
|
|
4706
4638
|
}
|
|
4707
4639
|
function make_event_reader(tags, disclosure, predicate = null) {
|
|
@@ -4961,7 +4893,7 @@ function act() {
|
|
|
4961
4893
|
return reaction_on(event, registry.events, builder);
|
|
4962
4894
|
},
|
|
4963
4895
|
build: (options) => {
|
|
4964
|
-
|
|
4896
|
+
check("act", options ?? {});
|
|
4965
4897
|
if (!_built) {
|
|
4966
4898
|
for (const proj of pending_projections) add_projection(proj);
|
|
4967
4899
|
for (const proj of fold_projections) {
|
|
@@ -5135,7 +5067,7 @@ function _projection(target) {
|
|
|
5135
5067
|
throw new Error(
|
|
5136
5068
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5137
5069
|
);
|
|
5138
|
-
const config2 =
|
|
5070
|
+
const config2 = check("fold", options);
|
|
5139
5071
|
const fold_events = {};
|
|
5140
5072
|
for (const partial of partials)
|
|
5141
5073
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5270,7 +5202,7 @@ function action_builder(state2) {
|
|
|
5270
5202
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5271
5203
|
internal.actions[action2] = schema;
|
|
5272
5204
|
if (options) {
|
|
5273
|
-
|
|
5205
|
+
check("action", options);
|
|
5274
5206
|
internal.options ??= {};
|
|
5275
5207
|
internal.options[action2] = options;
|
|
5276
5208
|
}
|
|
@@ -5550,7 +5482,6 @@ var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
|
5550
5482
|
var DEFAULT_SETTLE_DEBOUNCE_MS2 = DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5551
5483
|
var PackageSchema = package_schema;
|
|
5552
5484
|
var default_scope = unscoped_ports;
|
|
5553
|
-
var resolveAutocloseConfig2 = resolveAutocloseConfig;
|
|
5554
5485
|
var extend = (source, schema, target) => ({ ...target, ...validate("config", source, schema) });
|
|
5555
5486
|
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])?$/;
|
|
5556
5487
|
var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value;
|
|
@@ -5604,7 +5535,6 @@ export {
|
|
|
5604
5535
|
pii_fields,
|
|
5605
5536
|
port,
|
|
5606
5537
|
projection,
|
|
5607
|
-
resolveAutocloseConfig2 as resolveAutocloseConfig,
|
|
5608
5538
|
seed_event,
|
|
5609
5539
|
sensitive,
|
|
5610
5540
|
sensitiveFields,
|