@crossdelta/cloudevents 0.5.4 → 0.5.5

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/README.md +24 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ Type-safe event-driven microservices with [NATS](https://nats.io) and [Zod](http
11
11
  └──────────────┘ │ │ └──────────────┘
12
12
  └──────────────┘
13
13
  │ │
14
- publishNatsRawEvent(...) │ handleEvent(...)
14
+ publish(...) │ handleEvent(...)
15
15
  ▼ ▼
16
16
  ┌──────────────┐ ┌──────────────┐
17
17
  │ { orderId, │ │ Zod schema │
@@ -286,14 +286,32 @@ export const OrdersCreatedContract = createContract({
286
286
  ```typescript
287
287
  interface ChannelConfig {
288
288
  stream: string // JetStream stream name (e.g., 'ORDERS')
289
- subject?: string // NATS subject (defaults to event type)
289
+ subject?: string // NATS subject (optional override)
290
290
  }
291
291
  ```
292
292
 
293
- **Subject Defaulting:**
294
- - If `subject` is **not provided**, it defaults to the event `type`
295
- - This follows the convention: `orders.created` subject `orders.created`
296
- - Override when needed: `subject: 'orders.v1.created'`
293
+ **Subject Routing (CRITICAL):**
294
+ - **Without `subject`**: Domain is auto-pluralized: `customer.created` subject `customers.created`
295
+ - **With `subject`**: Uses exact subject specified (no auto-pluralization)
296
+ - **Why pluralize**: Stream subjects are plural (`customers.*`), event types are singular (`customer.created`)
297
+
298
+ **Examples:**
299
+ ```typescript
300
+ // Auto-pluralized subject
301
+ createContract({
302
+ type: 'order.created', // Event type: singular
303
+ channel: { stream: 'ORDERS' }, // Subject: orders.created (plural)
304
+ })
305
+
306
+ // Custom subject (no auto-pluralization)
307
+ createContract({
308
+ type: 'order.created',
309
+ channel: {
310
+ stream: 'ORDERS',
311
+ subject: 'orders.v1.created' // Exact subject, no auto-pluralization
312
+ },
313
+ })
314
+ ```
297
315
 
298
316
  ### Multiple Events, Same Stream
299
317
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/cloudevents",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream",
5
5
  "author": "crossdelta",
6
6
  "license": "MIT",