@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/act-builder.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAEV,KAAK,EAKL,MAAM,EACN,cAAc,EACd,OAAO,EAER,MAAM,mBAAmB,CAAC;AA8B3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAEjB,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,EAChD,OAAO,SAAS,OAAO,GAAG,EAAE,EAC5B,QAAQ,SAAS,OAAO,GAAG,EAAE,EAC7B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,KACzB,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"act-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/act-builder.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAEV,KAAK,EAKL,MAAM,EACN,cAAc,EACd,OAAO,EAER,MAAM,mBAAmB,CAAC;AA8B3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAEjB,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,EAChD,OAAO,SAAS,OAAO,GAAG,EAAE,EAC5B,QAAQ,SAAS,OAAO,GAAG,EAAE,EAC7B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,KACzB,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAwVhE"}
|
|
@@ -12,15 +12,30 @@
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
import { type DeferSchedule } from "../internal/defer-config.js";
|
|
15
|
-
import type { Committed, EventRegister, LaneConfig, ReactionHandler, ReactionOptions, ReactionResolver, Schemas } from "../types/index.js";
|
|
15
|
+
import type { Committed, EventRegister, LaneConfig, Reaction, ReactionHandler, ReactionOptions, ReactionResolver, Schemas } from "../types/index.js";
|
|
16
16
|
/**
|
|
17
|
-
* Validate and register a drain lane
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Validate and register a drain lane, the one rule for `withLane` on an Act
|
|
18
|
+
* or a slice and for the lanes a slice brings to `withSlice`, in any order.
|
|
19
|
+
* Validating here means a bad lane bag throws at declaration, not by
|
|
20
|
+
* silently draining nothing. `"default"` is reserved; a name declares one
|
|
21
|
+
* config, so declaring it again with the same config is a no-op and with a
|
|
22
|
+
* different one throws. Mutates `lanes` in place.
|
|
20
23
|
*
|
|
21
24
|
* @internal
|
|
22
25
|
*/
|
|
23
26
|
export declare function register_lane(config: LaneConfig, lanes: LaneConfig[]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Register a reaction once, keyed by its handler's name, and hand back
|
|
29
|
+
* `builder` patched with `.to(...)`, which reroutes the same reaction in
|
|
30
|
+
* place (no second `Map.set()`). The one registration step for reactions and
|
|
31
|
+
* projection handlers: the named-function and duplicate guards run before
|
|
32
|
+
* `make` builds the reaction, and `kind` picks the wording of their errors.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function add_reaction<TEvents extends Schemas, TKey extends keyof TEvents, TBuilder extends object>(events: EventRegister<TEvents>, event: TKey, name: string, kind: "Reaction" | "Projection", make: () => Reaction<TEvents, TKey>, builder: TBuilder): TBuilder & {
|
|
37
|
+
to(resolver: ReactionResolver<TEvents, TKey> | string): TBuilder;
|
|
38
|
+
};
|
|
24
39
|
/**
|
|
25
40
|
* Build the `.on(event)` step shared by both builders. Registers a reaction
|
|
26
41
|
* (named-function + duplicate guards, fail-fast literal-schedule validation,
|
|
@@ -33,13 +48,13 @@ export declare function register_lane(config: LaneConfig, lanes: LaneConfig[]):
|
|
|
33
48
|
*
|
|
34
49
|
* @internal
|
|
35
50
|
*/
|
|
36
|
-
export declare function reaction_on<TEvents extends Schemas, TKey extends keyof TEvents, TBuilder>(event: TKey, events: EventRegister<TEvents>, builder: TBuilder): {
|
|
37
|
-
do: (handler: ReactionHandler<TEvents, TKey>, options?: Partial<ReactionOptions>) =>
|
|
38
|
-
to(resolver: ReactionResolver<TEvents, TKey>
|
|
51
|
+
export declare function reaction_on<TEvents extends Schemas, TKey extends keyof TEvents, TBuilder extends object>(event: TKey, events: EventRegister<TEvents>, builder: TBuilder): {
|
|
52
|
+
do: (handler: ReactionHandler<TEvents, TKey>, options?: Partial<ReactionOptions>) => TBuilder & {
|
|
53
|
+
to(resolver: string | ReactionResolver<TEvents, TKey>): TBuilder;
|
|
39
54
|
};
|
|
40
55
|
defer: (schedule: DeferSchedule<Committed<TEvents, TKey>>) => {
|
|
41
|
-
do: (handler: ReactionHandler<TEvents, TKey>, options?: Partial<ReactionOptions>) =>
|
|
42
|
-
to(resolver: ReactionResolver<TEvents, TKey>
|
|
56
|
+
do: (handler: ReactionHandler<TEvents, TKey>, options?: Partial<ReactionOptions>) => TBuilder & {
|
|
57
|
+
to(resolver: string | ReactionResolver<TEvents, TKey>): TBuilder;
|
|
43
58
|
};
|
|
44
59
|
};
|
|
45
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder-utils.d.ts","sourceRoot":"","sources":["../../../src/builders/builder-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"builder-utils.d.ts","sourceRoot":"","sources":["../../../src/builders/builder-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,QAAQ,EACR,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,OAAO,EACR,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAc3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,OAAO,SAAS,OAAO,EACvB,IAAI,SAAS,MAAM,OAAO,EAC1B,QAAQ,SAAS,MAAM,EAEvB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,KAAK,EAAE,IAAI,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GAAG,YAAY,EAC/B,IAAI,EAAE,MAAM,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,EACnC,OAAO,EAAE,QAAQ;iBAeF,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,MAAM;EAMxD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,OAAO,SAAS,OAAO,EACvB,IAAI,SAAS,MAAM,OAAO,EAC1B,QAAQ,SAAS,MAAM,EACvB,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ;IAgC5D,EAAE,YACS,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,YAC7B,OAAO,CAAC,eAAe,CAAC;;;IAEpC,KAAK,aAAa,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACvD,EAAE,YACS,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,YAC7B,OAAO,CAAC,eAAe,CAAC;;;;EAIzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/projection-builder.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"projection-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/projection-builder.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAOV,OAAO,EAER,MAAM,mBAAmB,CAAC;AAgM3B;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,GAAG,EAAE,EACrD,MAAM,EAAE,MAAM,GACb,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,GAAG,EAAE,EACrD,MAAM,CAAC,EAAE,SAAS,GACjB,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/slice-builder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"slice-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/slice-builder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAqB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EACV,KAAK,EAGL,MAAM,EACN,cAAc,EACd,OAAO,EAER,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,KAAK,CAEnB,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,EAChD,OAAO,SAAS,OAAO,GAAG,EAAE,EAC5B,QAAQ,SAAS,OAAO,GAAG,EAAE,EAC7B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,KACzB,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CA0ClE"}
|
package/dist/index.cjs
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
|
+
_chunkO6QIJQRNcjs.resolveLaneConfig.call(void 0, config2);
|
|
4301
4302
|
if (config2.name === _chunk7AHW7FCNcjs.DEFAULT_LANE)
|
|
4302
4303
|
throw new Error(`Lane "${_chunk7AHW7FCNcjs.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: _chunkO6QIJQRNcjs.resolveReactionConfig.call(void 0, {
|
|
4346
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _155 => _155.blockOnError]), () => ( _chunkO6QIJQRNcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4347
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.maxRetries]), () => ( _chunkO6QIJQRNcjs.DEFAULT_MAX_RETRIES)),
|
|
4348
|
+
backoff: _optionalChain([options, 'optionalAccess', _157 => _157.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: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4780
|
-
options: {
|
|
4781
|
-
blockOnError: _chunkO6QIJQRNcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4782
|
-
maxRetries: _chunkO6QIJQRNcjs.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: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
4791
|
+
options: {
|
|
4792
|
+
blockOnError: _chunkO6QIJQRNcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
4793
|
+
maxRetries: _chunkO6QIJQRNcjs.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),
|