@rotorsoft/act 1.33.5 → 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/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/builder-utils.d.ts +24 -9
- package/dist/@types/builders/builder-utils.d.ts.map +1 -1
- package/dist/@types/builders/projection-builder.d.ts.map +1 -1
- package/dist/@types/builders/slice-builder.d.ts.map +1 -1
- package/dist/index.cjs +67 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -71
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4298,43 +4298,59 @@ var _this_ = ({ stream }) => ({
|
|
|
4298
4298
|
|
|
4299
4299
|
// src/builders/builder-utils.ts
|
|
4300
4300
|
function register_lane(config2, lanes) {
|
|
4301
|
+
resolveLaneConfig(config2);
|
|
4301
4302
|
if (config2.name === DEFAULT_LANE)
|
|
4302
4303
|
throw new Error(`Lane "${DEFAULT_LANE}" is reserved`);
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4304
|
+
const existing = lanes.find((l) => l.name === config2.name);
|
|
4305
|
+
if (!existing) return void lanes.push(config2);
|
|
4306
|
+
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
4307
|
+
throw new Error(
|
|
4308
|
+
`Lane "${config2.name}" was already declared with a different config`
|
|
4309
|
+
);
|
|
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
|
+
});
|
|
4306
4329
|
}
|
|
4307
4330
|
function reaction_on(event, events, builder) {
|
|
4308
|
-
const register = (handler, options, schedule) =>
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
return Object.assign(builder, {
|
|
4332
|
-
to(resolver) {
|
|
4333
|
-
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4334
|
-
return builder;
|
|
4335
|
-
}
|
|
4336
|
-
});
|
|
4337
|
-
};
|
|
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
|
+
);
|
|
4338
4354
|
return {
|
|
4339
4355
|
do: (handler, options) => register(handler, options),
|
|
4340
4356
|
defer: (schedule) => ({
|
|
@@ -4653,18 +4669,7 @@ function act() {
|
|
|
4653
4669
|
}
|
|
4654
4670
|
merge_event_register(registry.events, input.events);
|
|
4655
4671
|
pending_projections.push(...input.projections);
|
|
4656
|
-
for (const
|
|
4657
|
-
const existing = lanes.find((l) => l.name === slice_lane.name);
|
|
4658
|
-
if (!existing) {
|
|
4659
|
-
lanes.push(slice_lane);
|
|
4660
|
-
continue;
|
|
4661
|
-
}
|
|
4662
|
-
if (existing.leaseMillis !== slice_lane.leaseMillis || existing.streamLimit !== slice_lane.streamLimit || existing.cycleMs !== slice_lane.cycleMs) {
|
|
4663
|
-
throw new Error(
|
|
4664
|
-
`Lane "${slice_lane.name}" was already declared with a different config`
|
|
4665
|
-
);
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4672
|
+
for (const lane of input.lanes) register_lane(lane, lanes);
|
|
4668
4673
|
return builder;
|
|
4669
4674
|
},
|
|
4670
4675
|
withProjection: (proj) => {
|
|
@@ -4675,7 +4680,7 @@ function act() {
|
|
|
4675
4680
|
withActor: () => builder,
|
|
4676
4681
|
withLane: (config2) => {
|
|
4677
4682
|
if (_built) closed("withLane");
|
|
4678
|
-
register_lane(
|
|
4683
|
+
register_lane(config2, lanes);
|
|
4679
4684
|
return builder;
|
|
4680
4685
|
},
|
|
4681
4686
|
on: (event) => {
|
|
@@ -4774,31 +4779,22 @@ function _projection(target) {
|
|
|
4774
4779
|
}
|
|
4775
4780
|
return {
|
|
4776
4781
|
do: (handler) => {
|
|
4777
|
-
const reaction = {
|
|
4778
|
-
handler,
|
|
4779
|
-
resolver: default_resolver ?? _this_,
|
|
4780
|
-
options: {
|
|
4781
|
-
blockOnError: DEFAULT_BLOCK_ON_ERROR,
|
|
4782
|
-
maxRetries: DEFAULT_MAX_RETRIES
|
|
4783
|
-
}
|
|
4784
|
-
};
|
|
4785
|
-
const register = events[event];
|
|
4786
|
-
if (!handler.name)
|
|
4787
|
-
throw new Error(
|
|
4788
|
-
`Projection handler for "${event}" must be a named function`
|
|
4789
|
-
);
|
|
4790
|
-
if (register.reactions.has(handler.name))
|
|
4791
|
-
throw new Error(
|
|
4792
|
-
`Duplicate projection handler "${handler.name}" for event "${event}". Projection handlers are keyed by function name; rename one of them.`
|
|
4793
|
-
);
|
|
4794
|
-
register.reactions.set(handler.name, reaction);
|
|
4795
4782
|
const widened = base;
|
|
4796
|
-
return
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
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
|
+
);
|
|
4802
4798
|
}
|
|
4803
4799
|
};
|
|
4804
4800
|
},
|
|
@@ -4897,7 +4893,7 @@ function slice() {
|
|
|
4897
4893
|
return builder;
|
|
4898
4894
|
},
|
|
4899
4895
|
withLane: (config2) => {
|
|
4900
|
-
register_lane(
|
|
4896
|
+
register_lane(config2, lanes);
|
|
4901
4897
|
return builder;
|
|
4902
4898
|
},
|
|
4903
4899
|
on: (event) => reaction_on(event, events, builder),
|