@rotorsoft/act 1.33.6 → 1.33.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/builders/builder-utils.d.ts +18 -6
- package/dist/@types/builders/builder-utils.d.ts.map +1 -1
- package/dist/@types/builders/projection-builder.d.ts.map +1 -1
- package/dist/index.cjs +57 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4308,37 +4308,49 @@ function register_lane(config2, lanes) {
|
|
|
4308
4308
|
`Lane "${config2.name}" was already declared with a different config`
|
|
4309
4309
|
);
|
|
4310
4310
|
}
|
|
4311
|
+
function add_reaction(events, event, name, kind, make, builder) {
|
|
4312
|
+
if (!name)
|
|
4313
|
+
throw new Error(
|
|
4314
|
+
`${kind} handler for "${String(event)}" must be a named function`
|
|
4315
|
+
);
|
|
4316
|
+
const label = kind === "Reaction" ? "reaction" : "projection handler";
|
|
4317
|
+
if (events[event].reactions.has(name))
|
|
4318
|
+
throw new Error(
|
|
4319
|
+
`Duplicate ${label} "${name}" for event "${String(event)}". ${kind} handlers are keyed by function name; rename one of them.`
|
|
4320
|
+
);
|
|
4321
|
+
const reaction = make();
|
|
4322
|
+
events[event].reactions.set(name, reaction);
|
|
4323
|
+
return Object.assign(builder, {
|
|
4324
|
+
to(resolver) {
|
|
4325
|
+
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4326
|
+
return builder;
|
|
4327
|
+
}
|
|
4328
|
+
});
|
|
4329
|
+
}
|
|
4311
4330
|
function reaction_on(event, events, builder) {
|
|
4312
|
-
const register = (handler, options, schedule) =>
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
return Object.assign(builder, {
|
|
4336
|
-
to(resolver) {
|
|
4337
|
-
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4338
|
-
return builder;
|
|
4339
|
-
}
|
|
4340
|
-
});
|
|
4341
|
-
};
|
|
4331
|
+
const register = (handler, options, schedule) => add_reaction(
|
|
4332
|
+
events,
|
|
4333
|
+
event,
|
|
4334
|
+
handler.name,
|
|
4335
|
+
"Reaction",
|
|
4336
|
+
() => {
|
|
4337
|
+
if (schedule && typeof schedule !== "function")
|
|
4338
|
+
assert_defer_when(schedule);
|
|
4339
|
+
return {
|
|
4340
|
+
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4341
|
+
resolver: _this_,
|
|
4342
|
+
// Validate the whole bag at the declaration site so a bad
|
|
4343
|
+
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4344
|
+
// not a NaN gate on the first retry.
|
|
4345
|
+
options: resolveReactionConfig({
|
|
4346
|
+
blockOnError: options?.blockOnError ?? DEFAULT_BLOCK_ON_ERROR,
|
|
4347
|
+
maxRetries: options?.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
4348
|
+
backoff: options?.backoff
|
|
4349
|
+
})
|
|
4350
|
+
};
|
|
4351
|
+
},
|
|
4352
|
+
builder
|
|
4353
|
+
);
|
|
4342
4354
|
return {
|
|
4343
4355
|
do: (handler, options) => register(handler, options),
|
|
4344
4356
|
defer: (schedule) => ({
|
|
@@ -4767,31 +4779,22 @@ function _projection(target) {
|
|
|
4767
4779
|
}
|
|
4768
4780
|
return {
|
|
4769
4781
|
do: (handler) => {
|
|
4770
|
-
const reaction = {
|
|
4771
|
-
handler,
|
|
4772
|
-
resolver: default_resolver ?? _this_,
|
|
4773
|
-
options: {
|
|
4774
|
-
blockOnError: DEFAULT_BLOCK_ON_ERROR,
|
|
4775
|
-
maxRetries: DEFAULT_MAX_RETRIES
|
|
4776
|
-
}
|
|
4777
|
-
};
|
|
4778
|
-
const register = events[event];
|
|
4779
|
-
if (!handler.name)
|
|
4780
|
-
throw new Error(
|
|
4781
|
-
`Projection handler for "${event}" must be a named function`
|
|
4782
|
-
);
|
|
4783
|
-
if (register.reactions.has(handler.name))
|
|
4784
|
-
throw new Error(
|
|
4785
|
-
`Duplicate projection handler "${handler.name}" for event "${event}". Projection handlers are keyed by function name; rename one of them.`
|
|
4786
|
-
);
|
|
4787
|
-
register.reactions.set(handler.name, reaction);
|
|
4788
4782
|
const widened = base;
|
|
4789
|
-
return
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4783
|
+
return add_reaction(
|
|
4784
|
+
events,
|
|
4785
|
+
event,
|
|
4786
|
+
handler.name,
|
|
4787
|
+
"Projection",
|
|
4788
|
+
() => ({
|
|
4789
|
+
handler,
|
|
4790
|
+
resolver: default_resolver ?? _this_,
|
|
4791
|
+
options: {
|
|
4792
|
+
blockOnError: DEFAULT_BLOCK_ON_ERROR,
|
|
4793
|
+
maxRetries: DEFAULT_MAX_RETRIES
|
|
4794
|
+
}
|
|
4795
|
+
}),
|
|
4796
|
+
widened
|
|
4797
|
+
);
|
|
4795
4798
|
}
|
|
4796
4799
|
};
|
|
4797
4800
|
},
|