@rotorsoft/act 2.1.0 → 2.1.1

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/act.d.ts +2 -1
  4. package/dist/@types/act.d.ts.map +1 -1
  5. package/dist/@types/builders/builder-utils.d.ts.map +1 -1
  6. package/dist/@types/internal/config.d.ts +8 -0
  7. package/dist/@types/internal/config.d.ts.map +1 -1
  8. package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
  9. package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
  10. package/dist/@types/types/action.d.ts +2 -2
  11. package/dist/@types/types/ports.d.ts +3 -3
  12. package/dist/@types/types/reaction.d.ts +2 -1
  13. package/dist/@types/types/reaction.d.ts.map +1 -1
  14. package/dist/adapter.cjs +3 -3
  15. package/dist/adapter.js +2 -2
  16. package/dist/{chunk-2377SSHX.cjs → chunk-7VYSJIXD.cjs} +1 -1
  17. package/dist/chunk-7VYSJIXD.cjs.map +1 -0
  18. package/dist/{chunk-VOVHDDET.cjs → chunk-LN3OP4OL.cjs} +27 -18
  19. package/dist/chunk-LN3OP4OL.cjs.map +1 -0
  20. package/dist/{chunk-HACJYR7Z.cjs → chunk-PZQXTGWF.cjs} +4 -4
  21. package/dist/{chunk-HACJYR7Z.cjs.map → chunk-PZQXTGWF.cjs.map} +1 -1
  22. package/dist/{chunk-KXC4ILVY.js → chunk-QPVUARKL.js} +12 -3
  23. package/dist/{chunk-KXC4ILVY.js.map → chunk-QPVUARKL.js.map} +1 -1
  24. package/dist/{chunk-SRZIVZIA.js → chunk-UXDNSZAD.js} +2 -2
  25. package/dist/{chunk-GWFLHWZV.js → chunk-W3PHEA5Q.js} +1 -1
  26. package/dist/chunk-W3PHEA5Q.js.map +1 -0
  27. package/dist/index.cjs +288 -262
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +44 -18
  30. package/dist/index.js.map +1 -1
  31. package/dist/test/index.cjs +5 -5
  32. package/dist/test/index.js +3 -3
  33. package/dist/types/index.cjs +2 -2
  34. package/dist/types/index.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-2377SSHX.cjs.map +0 -1
  37. package/dist/chunk-GWFLHWZV.js.map +0 -1
  38. package/dist/chunk-VOVHDDET.cjs.map +0 -1
  39. /package/dist/{chunk-SRZIVZIA.js.map → chunk-UXDNSZAD.js.map} +0 -0
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  current_reacting,
18
18
  dispose,
19
19
  disposeAndExit,
20
+ is_valid_target,
20
21
  log,
21
22
  make_reaction_scope,
22
23
  make_run_scoped,
@@ -33,11 +34,12 @@ import {
33
34
  resolveReactionConfig,
34
35
  resolveSettleConfig,
35
36
  resolveShutdownConfig,
37
+ resolveTargetConfig,
36
38
  sleep,
37
39
  store,
38
40
  unscoped_ports,
39
41
  validate
40
- } from "./chunk-KXC4ILVY.js";
42
+ } from "./chunk-QPVUARKL.js";
41
43
  import {
42
44
  checkAppends,
43
45
  checkVersion,
@@ -46,7 +48,7 @@ import {
46
48
  isStreamName,
47
49
  parseNotification,
48
50
  seedEvent
49
- } from "./chunk-SRZIVZIA.js";
51
+ } from "./chunk-UXDNSZAD.js";
50
52
  import {
51
53
  ActorSchema,
52
54
  CausationEventSchema,
@@ -81,7 +83,7 @@ import {
81
83
  pii_schemas,
82
84
  sensitive,
83
85
  sensitiveFields
84
- } from "./chunk-GWFLHWZV.js";
86
+ } from "./chunk-W3PHEA5Q.js";
85
87
 
86
88
  // src/signals.ts
87
89
  process.once("SIGINT", async (arg) => {
@@ -1320,24 +1322,29 @@ async function scan(source, opts = {}, callback) {
1320
1322
  return;
1321
1323
  }
1322
1324
  let remapped = migrated;
1323
- const caused_by = migrated.meta.causation.event?.id;
1324
- if (caused_by !== void 0) {
1325
- const new_caused_by = id_map.get(caused_by);
1326
- if (new_caused_by !== void 0 && new_caused_by !== caused_by) {
1327
- remapped = {
1328
- ...migrated,
1329
- meta: {
1330
- ...migrated.meta,
1331
- causation: {
1332
- ...migrated.meta.causation,
1325
+ const { action: action2, event: cause } = migrated.meta.causation;
1326
+ if (cause || stream_rename && action2) {
1327
+ remapped = {
1328
+ ...migrated,
1329
+ meta: {
1330
+ ...migrated.meta,
1331
+ causation: {
1332
+ ...migrated.meta.causation,
1333
+ ...action2 && stream_rename && {
1334
+ action: { ...action2, stream: stream_rename(action2.stream) }
1335
+ },
1336
+ ...cause && {
1333
1337
  event: {
1334
- ...migrated.meta.causation.event,
1335
- id: new_caused_by
1338
+ ...cause,
1339
+ // A cause missing from the source has no id in the new
1340
+ // log; its old id would name another event there.
1341
+ id: id_map.get(cause.id) ?? -1,
1342
+ stream: stream_rename ? stream_rename(cause.stream) : cause.stream
1336
1343
  }
1337
1344
  }
1338
1345
  }
1339
- };
1340
- }
1346
+ }
1347
+ };
1341
1348
  }
1342
1349
  const new_id = await callback(remapped);
1343
1350
  id_map.set(event.id, new_id);
@@ -2717,6 +2724,13 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
2717
2724
  `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.`
2718
2725
  );
2719
2726
  }
2727
+ function report_bad_priority(seen, handler, target, priority) {
2728
+ report_once(
2729
+ seen,
2730
+ `priority|${handler}|${String(priority)}`,
2731
+ `Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer. Skipping that event for this reaction; other reactions keep running. The equivalent static \`.to({ priority })\` is rejected at build; a dynamic resolver's priority is only knowable here.`
2732
+ );
2733
+ }
2720
2734
  function report_lane_conflict(seen, handler, target, kept, dropped) {
2721
2735
  report_once(
2722
2736
  seen,
@@ -2884,6 +2898,15 @@ var CorrelateCycle = class {
2884
2898
  return;
2885
2899
  }
2886
2900
  if (!resolved) continue;
2901
+ if (!is_valid_target(resolved)) {
2902
+ report_bad_priority(
2903
+ this._reported,
2904
+ reaction.handler.name,
2905
+ resolved.target,
2906
+ resolved.priority
2907
+ );
2908
+ continue;
2909
+ }
2887
2910
  let lane = resolved.lane;
2888
2911
  if (lane !== void 0 && !this._declared_lanes.has(lane)) {
2889
2912
  report_undeclared_lane(
@@ -4200,8 +4223,9 @@ var Act = class {
4200
4223
  * registered stream.**
4201
4224
  *
4202
4225
  * @param filter - Selection criteria (regex by default, like {@link query}).
4203
- * @param priority - New priority value. Set as-is — no clamp.
4226
+ * @param priority - New priority value, a 32-bit integer. Set as-is — no clamp.
4204
4227
  * @returns Count of streams whose priority changed.
4228
+ * @throws ZodError when `priority` isn't a 32-bit integer.
4205
4229
  *
4206
4230
  * @example Boost a specific projection mid-replay
4207
4231
  * ```typescript
@@ -4211,6 +4235,7 @@ var Act = class {
4211
4235
  * @see {@link Store.prioritize} for the underlying primitive
4212
4236
  */
4213
4237
  async prioritize(filter, priority) {
4238
+ resolveTargetConfig({ priority });
4214
4239
  return this._scoped(() => store().prioritize(filter, priority));
4215
4240
  }
4216
4241
  // Shared by `close()` and reaction-requested closes.
@@ -4512,6 +4537,7 @@ function add_reaction(events, event, name, kind, make, builder) {
4512
4537
  events[event].reactions.set(name, reaction);
4513
4538
  return Object.assign(builder, {
4514
4539
  to(resolver) {
4540
+ if (typeof resolver === "object") resolveTargetConfig(resolver);
4515
4541
  reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
4516
4542
  return builder;
4517
4543
  }