@nwire/forge 0.11.0 → 0.11.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.
@@ -93,5 +93,6 @@ export declare const EVENT_PUBLISHING_PRIORITIES: {
93
93
  readonly projections: 600;
94
94
  readonly workflows: 400;
95
95
  readonly bus: 200;
96
+ readonly outbound: 100;
96
97
  };
97
98
  export type ForgeFrameworkSlot = (typeof forgeFrameworkSlots)[number];
@@ -29,4 +29,5 @@ export const EVENT_PUBLISHING_PRIORITIES = {
29
29
  projections: 600,
30
30
  workflows: 400,
31
31
  bus: 200,
32
+ outbound: 100,
32
33
  };
@@ -153,6 +153,9 @@ export declare class ForgeDispatcher {
153
153
  * 600 — projection folds.
154
154
  * 400 — workflow correlation + fire.
155
155
  * 200 — cross-process bus delivery (public events only).
156
+ * 100 — outbound sink drain (public events only) — feeds
157
+ * adopters that install via `installSinkStage` (bullmq,
158
+ * AMQP, telemetry-otel, …).
156
159
  *
157
160
  * Called once at plugin setup. Idempotent — re-attaching is a no-op
158
161
  * because the hook engine guards against duplicate step names.
@@ -116,6 +116,17 @@ export class ForgeDispatcher {
116
116
  this.handlers.set(name, handler);
117
117
  this.ensureActionBeforeHook(name);
118
118
  this.ensureActionAfterHook(name);
119
+ // The action declares `emits: [SomeEvent, ...]`. Any event the
120
+ // author marked `.public()` carries `$public: true` — surface it
121
+ // to the dispatcher so the EventPublishing chain's bus + outbound
122
+ // steps fire when that event flows through.
123
+ const emits = handler.action.emits;
124
+ if (emits) {
125
+ for (const ev of emits) {
126
+ if (ev.$public === true)
127
+ this.publicEventNames.add(ev.name);
128
+ }
129
+ }
119
130
  }
120
131
  registerActor(actor) {
121
132
  if (this.actors.has(actor.name)) {
@@ -630,6 +641,9 @@ export class ForgeDispatcher {
630
641
  * 600 — projection folds.
631
642
  * 400 — workflow correlation + fire.
632
643
  * 200 — cross-process bus delivery (public events only).
644
+ * 100 — outbound sink drain (public events only) — feeds
645
+ * adopters that install via `installSinkStage` (bullmq,
646
+ * AMQP, telemetry-otel, …).
633
647
  *
634
648
  * Called once at plugin setup. Idempotent — re-attaching is a no-op
635
649
  * because the hook engine guards against duplicate step names.
@@ -667,6 +681,16 @@ export class ForgeDispatcher {
667
681
  }
668
682
  await next();
669
683
  }, { name: "forge.publish.bus", priority: EVENT_PUBLISHING_PRIORITIES.bus });
684
+ hook.use(async (payload, next) => {
685
+ if (this.publicEventNames.has(payload.event.eventName)) {
686
+ // Outbound sink chain — adopters like bullmq, AMQP, telemetry-otel
687
+ // install terminal stages via `installSinkStage`. `sinkDrain`
688
+ // reads `.name` off the event; the schema is not consulted here.
689
+ const eventRef = { name: payload.event.eventName };
690
+ await this.runtime.sinkDrain(eventRef, payload.event.payload, payload.envelope);
691
+ }
692
+ await next();
693
+ }, { name: "forge.publish.outbound", priority: EVENT_PUBLISHING_PRIORITIES.outbound });
670
694
  }
671
695
  async applyExternalEvent(eventName, payload, envelope) {
672
696
  if (!this.externalEventNames.has(eventName)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/forge",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Nwire — the framework's core primitives. defineAction, defineEvent, defineHandler, defineActor, defineProjection, defineQuery, defineWorkflow, defineModule, defineApp, definePlugin, createApp. MessageEnvelope with correlation/causation. The runtime is the bus.",
5
5
  "keywords": [
6
6
  "actions",
@@ -34,16 +34,16 @@
34
34
  "emittery": "1.0.1",
35
35
  "koa": "^2.16.4",
36
36
  "zod": "^4.0.0",
37
- "@nwire/app": "0.11.0",
38
- "@nwire/bus": "0.11.0",
39
- "@nwire/dead-letter": "0.11.0",
40
- "@nwire/handler": "0.11.0",
41
- "@nwire/container": "0.11.0",
42
- "@nwire/messages": "0.11.0",
43
- "@nwire/wires": "0.11.0",
44
- "@nwire/logger": "0.11.0",
45
- "@nwire/envelope": "0.11.0",
46
- "@nwire/hooks": "0.11.0"
37
+ "@nwire/messages": "0.11.1",
38
+ "@nwire/app": "0.11.1",
39
+ "@nwire/logger": "0.11.1",
40
+ "@nwire/container": "0.11.1",
41
+ "@nwire/wires": "0.11.1",
42
+ "@nwire/hooks": "0.11.1",
43
+ "@nwire/handler": "0.11.1",
44
+ "@nwire/bus": "0.11.1",
45
+ "@nwire/envelope": "0.11.1",
46
+ "@nwire/dead-letter": "0.11.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/koa": "^2.15.0",