@crossdelta/cloudevents 0.4.1 → 0.4.21

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/README.md CHANGED
@@ -29,24 +29,24 @@ bun add @crossdelta/cloudevents zod@4
29
29
 
30
30
  ## Quick Start
31
31
 
32
- **1. Create an event handler** (`src/events/order-created.event.ts`):
32
+ **1. Create an event handler** (`src/events/orders-created.event.ts`):
33
33
 
34
34
  ```typescript
35
35
  import { handleEvent } from '@crossdelta/cloudevents'
36
36
  import { z } from 'zod'
37
37
 
38
38
  // Export schema for mock generation
39
- export const OrderCreatedSchema = z.object({
39
+ export const OrdersCreatedSchema = z.object({
40
40
  orderId: z.string(),
41
41
  total: z.number(),
42
42
  })
43
43
 
44
44
  // Export type for use in use-cases
45
- export type OrderCreatedEvent = z.infer<typeof OrderCreatedSchema>
45
+ export type OrdersCreatedEvent = z.infer<typeof OrdersCreatedSchema>
46
46
 
47
47
  export default handleEvent(
48
48
  {
49
- schema: OrderCreatedSchema,
49
+ schema: OrdersCreatedSchema,
50
50
  type: 'orders.created',
51
51
  },
52
52
  async (data) => {
@@ -251,20 +251,20 @@ await consumeJetStreamEvents({
251
251
  When multiple services consume the same event, use `createContract` to create shared event contracts:
252
252
 
253
253
  ```typescript
254
- // packages/contracts/src/schemas/order-created.schema.ts
254
+ // packages/contracts/src/events/orders-created.ts
255
255
  import { createContract } from '@crossdelta/cloudevents'
256
256
  import { z } from 'zod'
257
257
 
258
- export const OrderCreatedSchema = z.object({
258
+ export const OrdersCreatedSchema = z.object({
259
259
  orderId: z.string(),
260
260
  total: z.number(),
261
261
  })
262
262
 
263
- export type OrderCreatedData = z.infer<typeof OrderCreatedSchema>
263
+ export type OrdersCreatedData = z.infer<typeof OrdersCreatedSchema>
264
264
 
265
- export const OrderCreatedContract = createContract({
265
+ export const OrdersCreatedContract = createContract({
266
266
  type: 'orders.created',
267
- schema: OrderCreatedSchema,
267
+ schema: OrdersCreatedSchema,
268
268
  })
269
269
  ```
270
270
 
@@ -272,12 +272,12 @@ Then import and use in handlers:
272
272
 
273
273
  ```typescript
274
274
  import { handleEvent } from '@crossdelta/cloudevents'
275
- import { OrderCreatedContract } from '@my-org/contracts'
275
+ import { OrdersCreatedContract } from '@my-org/contracts'
276
276
 
277
277
  export default handleEvent(
278
- OrderCreatedContract,
278
+ OrdersCreatedContract,
279
279
  async (data) => {
280
- // data is typed as OrderCreatedData
280
+ // data is typed as OrdersCreatedData
281
281
  console.log(data.orderId)
282
282
  },
283
283
  )
@@ -53,7 +53,12 @@ const loadHandlers = async (filePath, filter) => {
53
53
  });
54
54
  }
55
55
  catch (error) {
56
- logger?.warn(`Failed to load ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
56
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
57
+ const errorStack = error instanceof Error ? error.stack : undefined;
58
+ logger?.warn(`Failed to load ${filePath}: ${errorMessage}`);
59
+ if (errorStack) {
60
+ logger?.warn(errorStack);
61
+ }
57
62
  return [];
58
63
  }
59
64
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/cloudevents",
3
- "version": "0.4.1",
3
+ "version": "0.4.21",
4
4
  "description": "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream",
5
5
  "author": "crossdelta",
6
6
  "license": "MIT",