@nwire/cron 0.12.1 → 0.13.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 (2) hide show
  1. package/dist/cron.js +18 -5
  2. package/package.json +4 -4
package/dist/cron.js CHANGED
@@ -7,8 +7,7 @@
7
7
  * deployments run cron in ONE process.
8
8
  */
9
9
  import { Cron } from "croner";
10
- import { forgeDispatcher } from "@nwire/forge";
11
- import { seedEnvelope } from "@nwire/envelope";
10
+ import { FORGE_ACTION_RUNNER_BINDING, } from "@nwire/forge";
12
11
  export function createCronWire(options) {
13
12
  const instances = options.apps;
14
13
  const schedules = [];
@@ -25,8 +24,19 @@ export function createCronWire(options) {
25
24
  }
26
25
  const { owner, action } = located;
27
26
  const cron = new Cron(expr, { timezone: options.timezone, protect: true }, async () => {
28
- const envelope = seedEnvelope({ tenant: spec.tenant });
29
- await forgeDispatcher(owner).dispatch(action, spec.input ?? {}, envelope);
27
+ // Unified inbound the tick becomes a command on the runtime's
28
+ // source chain. Fresh envelope per tick (seeded from the tenant);
29
+ // `target` is the resolved forge handler so it lands on execute.
30
+ const handler = owner.runtime.getHandler(action.name);
31
+ await owner.runtime.receive(
32
+ // Forge's HandlerDefinition satisfies the runtime's execute target
33
+ // structurally; cast across the forge↔runtime boundary.
34
+ {
35
+ kind: "command",
36
+ name: action.name,
37
+ input: spec.input ?? {},
38
+ target: handler,
39
+ }, { envelope: { tenant: spec.tenant } });
30
40
  });
31
41
  schedules.push(cron);
32
42
  }
@@ -41,7 +51,10 @@ export function createCronWire(options) {
41
51
  }
42
52
  function locateAction(apps, name) {
43
53
  for (const app of apps) {
44
- const action = forgeDispatcher(app).findActionByName(name);
54
+ if (!app.container.has(FORGE_ACTION_RUNNER_BINDING))
55
+ continue;
56
+ const runner = app.container.resolve(FORGE_ACTION_RUNNER_BINDING);
57
+ const action = runner.findActionByName(name);
45
58
  if (action)
46
59
  return { owner: app, action };
47
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/cron",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "description": "Nwire — cron interface factory. Dispatch actions on a schedule (croner-backed).",
5
5
  "keywords": [
6
6
  "cron",
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "croner": "^9.1.0",
32
- "@nwire/app": "0.12.1",
33
- "@nwire/envelope": "0.12.1",
34
- "@nwire/forge": "0.12.1"
32
+ "@nwire/app": "0.13.1",
33
+ "@nwire/envelope": "0.13.1",
34
+ "@nwire/forge": "0.13.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^22.19.9",