@beignet/provider-event-bus-memory 0.0.50 → 0.0.52
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/CHANGELOG.md +14 -0
- package/README.md +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +21 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @beignet/provider-event-bus-memory
|
|
2
2
|
|
|
3
|
+
## 0.0.52
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b39bb6e: Clarify that Beignet applications require Node.js 22.12 or newer and can use
|
|
8
|
+
npm, pnpm, Yarn, or Bun for package management and framework commands.
|
|
9
|
+
- ac76ab9: Reject event payloads with `EventTransportError` when they are not canonical JSON or change when validated again after transport, before publishing or recording them durably. Direct memory and recording-bus publication must be awaited while validation completes.
|
|
10
|
+
|
|
11
|
+
## 0.0.51
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 4f033a6: Forward canonical event payloads, expose framework error ownership through CORS, run focused-route misses through the fallback lifecycle, and inspect formatted route handlers with the TypeScript AST.
|
|
16
|
+
|
|
3
17
|
## 0.0.50
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @beignet/provider-event-bus-memory
|
|
2
2
|
|
|
3
|
-
> **Runtime:** Beignet requires Node.js 22.12 or newer. Bun
|
|
4
|
-
> supported for Beignet commands.
|
|
3
|
+
> **Runtime:** Beignet requires Node.js 22.12 or newer. Bun is optional.
|
|
5
4
|
|
|
6
5
|
> [!CAUTION]
|
|
7
6
|
> Beignet is experimental alpha software. The `0.0.x` package line is for early
|
|
@@ -159,7 +158,8 @@ export async function stopOrderListeners() {
|
|
|
159
158
|
|
|
160
159
|
### `publish<E>(event, payload, options?): Promise<void> | void`
|
|
161
160
|
|
|
162
|
-
Publish a domain event with a typed payload.
|
|
161
|
+
Publish a domain event with a typed payload. Await the result so payload
|
|
162
|
+
validation and the configured delivery mode complete before continuing.
|
|
163
163
|
|
|
164
164
|
```typescript
|
|
165
165
|
await eventBus.publish(UserRegistered, {
|
|
@@ -250,6 +250,13 @@ describe("User Registration", () => {
|
|
|
250
250
|
- **Memory-only**: No persistence - events are lost if the process crashes
|
|
251
251
|
- **Order**: Handlers are called in the order they were subscribed
|
|
252
252
|
- **Multiple handlers**: Multiple handlers can subscribe to the same event
|
|
253
|
+
- **Transport-stable payloads**: Direct publication, `publishEvent(...)`, and
|
|
254
|
+
use-case helpers reject non-JSON output and transforms whose canonical JSON
|
|
255
|
+
changes when validated again. This keeps local behavior aligned with
|
|
256
|
+
serialized providers.
|
|
257
|
+
- **Canonical helper delivery**: Producer helpers preserve parsed and
|
|
258
|
+
transport-stable payload state through in-process delivery, so registered
|
|
259
|
+
listeners do not repeat validation unnecessarily.
|
|
253
260
|
- **Error handling**: Handler errors reject `publish(...)` unless
|
|
254
261
|
`onHandlerError` is configured
|
|
255
262
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,6BAA6B,CAAC;IAEhD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAElC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,KACb,IAAI,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,6BACf,SAAQ,IAAI,CAAC,qBAAqB,EAAE,iBAAiB,CAAC;IACtD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,qBAA0B,GAClC,YAAY,CAmHd;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,6BAAkC;;kBAiB5C"}
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* await subscription.unsubscribe();
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
+
import { prepareEventPayloadForTransport, } from "@beignet/core/events";
|
|
29
30
|
import { createProvider, createProviderInstrumentation, } from "@beignet/core/providers";
|
|
30
31
|
import { captureTraceCarrier, parseTraceCarrier } from "@beignet/core/tracing";
|
|
31
32
|
/**
|
|
@@ -75,7 +76,9 @@ export function createMemoryEventBus(options = {}) {
|
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
return {
|
|
78
|
-
publish(event, payload, publishOptions) {
|
|
79
|
+
async publish(event, payload, publishOptions) {
|
|
80
|
+
const prepared = await prepareEventPayloadForTransport(event, payload, publishOptions);
|
|
81
|
+
const canonicalPayload = prepared.payload;
|
|
79
82
|
instrumentation.record({
|
|
80
83
|
type: "eventBus",
|
|
81
84
|
eventName: event.name,
|
|
@@ -84,19 +87,23 @@ export function createMemoryEventBus(options = {}) {
|
|
|
84
87
|
if (!subs || subs.size === 0)
|
|
85
88
|
return;
|
|
86
89
|
const subscribers = [...subs];
|
|
87
|
-
const trace = parseTraceCarrier(publishOptions
|
|
90
|
+
const trace = parseTraceCarrier(prepared.publishOptions.trace) ??
|
|
88
91
|
captureTraceCarrier(options.instrumentation);
|
|
89
|
-
const deliveryOptions =
|
|
92
|
+
const deliveryOptions = { ...prepared.publishOptions };
|
|
93
|
+
if (trace)
|
|
94
|
+
deliveryOptions.trace = trace;
|
|
95
|
+
else
|
|
96
|
+
delete deliveryOptions.trace;
|
|
90
97
|
if (delivery === "fire-and-forget") {
|
|
91
98
|
for (const handler of subscribers) {
|
|
92
99
|
try {
|
|
93
|
-
const result = handler(
|
|
100
|
+
const result = handler(canonicalPayload, deliveryOptions);
|
|
94
101
|
Promise.resolve(result).catch((error) => {
|
|
95
|
-
reportHandlerError(error, event.name,
|
|
102
|
+
reportHandlerError(error, event.name, canonicalPayload);
|
|
96
103
|
});
|
|
97
104
|
}
|
|
98
105
|
catch (error) {
|
|
99
|
-
reportHandlerError(error, event.name,
|
|
106
|
+
reportHandlerError(error, event.name, canonicalPayload);
|
|
100
107
|
}
|
|
101
108
|
}
|
|
102
109
|
return;
|
|
@@ -104,10 +111,10 @@ export function createMemoryEventBus(options = {}) {
|
|
|
104
111
|
return (async () => {
|
|
105
112
|
for (const handler of subscribers) {
|
|
106
113
|
try {
|
|
107
|
-
await handler(
|
|
114
|
+
await handler(canonicalPayload, deliveryOptions);
|
|
108
115
|
}
|
|
109
116
|
catch (error) {
|
|
110
|
-
reportHandlerError(error, event.name,
|
|
117
|
+
reportHandlerError(error, event.name, canonicalPayload);
|
|
111
118
|
if (!onHandlerError)
|
|
112
119
|
throw error;
|
|
113
120
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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,EAAE;YACb,OAAO;gBACL,KAAK,EAAE;oBACL,QAAQ,EAAE,oBAAoB,CAAC;wBAC7B,GAAG,eAAe;wBAClB,eAAe,EAAE,KAAK;qBACvB,CAAC;iBACmC;aACxC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beignet/provider-event-bus-memory",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "In-memory event bus provider for Beignet - implements EventBusPort for single-process applications",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@beignet/core": "*",
|
|
60
60
|
"@beignet/devtools": "*",
|
|
61
|
-
"@types/bun": "^1.
|
|
61
|
+
"@types/bun": "^1.4.0",
|
|
62
62
|
"@types/node": "^22.0.0",
|
|
63
63
|
"typescript": "^5.3.0",
|
|
64
64
|
"zod": "^4.0.0"
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,10 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import
|
|
30
|
+
import {
|
|
31
|
+
type EventPublishOptions,
|
|
32
|
+
prepareEventPayloadForTransport,
|
|
33
|
+
} from "@beignet/core/events";
|
|
31
34
|
import type { EventBusPort } from "@beignet/core/ports";
|
|
32
35
|
import {
|
|
33
36
|
createProvider,
|
|
@@ -163,7 +166,14 @@ export function createMemoryEventBus(
|
|
|
163
166
|
};
|
|
164
167
|
|
|
165
168
|
return {
|
|
166
|
-
publish(event, payload, publishOptions) {
|
|
169
|
+
async publish(event, payload, publishOptions) {
|
|
170
|
+
const prepared = await prepareEventPayloadForTransport(
|
|
171
|
+
event,
|
|
172
|
+
payload,
|
|
173
|
+
publishOptions,
|
|
174
|
+
);
|
|
175
|
+
const canonicalPayload = prepared.payload;
|
|
176
|
+
|
|
167
177
|
instrumentation.record({
|
|
168
178
|
type: "eventBus",
|
|
169
179
|
eventName: event.name,
|
|
@@ -174,19 +184,21 @@ export function createMemoryEventBus(
|
|
|
174
184
|
|
|
175
185
|
const subscribers = [...subs];
|
|
176
186
|
const trace =
|
|
177
|
-
parseTraceCarrier(publishOptions
|
|
187
|
+
parseTraceCarrier(prepared.publishOptions.trace) ??
|
|
178
188
|
captureTraceCarrier(options.instrumentation);
|
|
179
|
-
const deliveryOptions =
|
|
189
|
+
const deliveryOptions = { ...prepared.publishOptions };
|
|
190
|
+
if (trace) deliveryOptions.trace = trace;
|
|
191
|
+
else delete deliveryOptions.trace;
|
|
180
192
|
|
|
181
193
|
if (delivery === "fire-and-forget") {
|
|
182
194
|
for (const handler of subscribers) {
|
|
183
195
|
try {
|
|
184
|
-
const result = handler(
|
|
196
|
+
const result = handler(canonicalPayload, deliveryOptions);
|
|
185
197
|
Promise.resolve(result).catch((error: unknown) => {
|
|
186
|
-
reportHandlerError(error, event.name,
|
|
198
|
+
reportHandlerError(error, event.name, canonicalPayload);
|
|
187
199
|
});
|
|
188
200
|
} catch (error) {
|
|
189
|
-
reportHandlerError(error, event.name,
|
|
201
|
+
reportHandlerError(error, event.name, canonicalPayload);
|
|
190
202
|
}
|
|
191
203
|
}
|
|
192
204
|
|
|
@@ -196,9 +208,9 @@ export function createMemoryEventBus(
|
|
|
196
208
|
return (async () => {
|
|
197
209
|
for (const handler of subscribers) {
|
|
198
210
|
try {
|
|
199
|
-
await handler(
|
|
211
|
+
await handler(canonicalPayload, deliveryOptions);
|
|
200
212
|
} catch (error) {
|
|
201
|
-
reportHandlerError(error, event.name,
|
|
213
|
+
reportHandlerError(error, event.name, canonicalPayload);
|
|
202
214
|
if (!onHandlerError) throw error;
|
|
203
215
|
}
|
|
204
216
|
}
|