@crossdelta/platform-sdk 0.7.9 → 0.7.11

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.
@@ -11,9 +11,9 @@ This package contains **shared event definitions** (contracts) for events that a
11
11
  ```
12
12
  src/
13
13
  ├── events/ # Event contracts and mock data
14
- │ ├── order-created.ts # Contract definition
15
- │ ├── order-created.mock.json # Mock data for testing
16
- │ └── index.ts # Re-exports
14
+ │ ├── orders-created.ts # Contract definition
15
+ │ ├── orders-created.mock.json # Mock data for testing
16
+ │ └── index.ts # Re-exports
17
17
  └── index.ts # Main exports
18
18
  ```
19
19
 
@@ -29,9 +29,9 @@ src/
29
29
 
30
30
  ```ts
31
31
  import { handleEvent } from '@crossdelta/cloudevents'
32
- import { OrderCreatedContract, type OrderCreatedData } from '{{scope}}/contracts'
32
+ import { OrdersCreatedContract, type OrdersCreatedData } from '{{scope}}/contracts'
33
33
 
34
- export default handleEvent(OrderCreatedContract, async (data: OrderCreatedData) => {
34
+ export default handleEvent(OrdersCreatedContract, async (data: OrdersCreatedData) => {
35
35
  // data is fully typed from contract
36
36
  console.log(data.orderId, data.customerId)
37
37
  })
@@ -41,10 +41,10 @@ export default handleEvent(OrderCreatedContract, async (data: OrderCreatedData)
41
41
 
42
42
  ```ts
43
43
  import { publish } from '@crossdelta/cloudevents'
44
- import { OrderCreatedContract } from '{{scope}}/contracts'
44
+ import { OrdersCreatedContract } from '{{scope}}/contracts'
45
45
 
46
46
  // Type-safe publishing with contract
47
- await publish(OrderCreatedContract, {
47
+ await publish(OrdersCreatedContract, {
48
48
  orderId: 'order-123',
49
49
  customerId: 'cust-456',
50
50
  total: 99.99,
@@ -55,9 +55,9 @@ await publish(OrderCreatedContract, {
55
55
  ### In Use-Cases
56
56
 
57
57
  ```ts
58
- import type { OrderCreatedData } from '{{scope}}/contracts'
58
+ import type { OrdersCreatedData } from '{{scope}}/contracts'
59
59
 
60
- export const processOrder = async (data: OrderCreatedData) => {
60
+ export const processOrder = async (data: OrdersCreatedData) => {
61
61
  // Use typed event data
62
62
  }
63
63
  ```
@@ -68,25 +68,25 @@ Contracts are **auto-generated** when you create event handlers:
68
68
 
69
69
  ```bash
70
70
  # 1. Create service with event handler
71
- pf new hono-micro notifications --ai -d "Sends emails on order.created events"
71
+ pf new hono-micro notifications --ai -d "Sends emails on orders.created events"
72
72
 
73
73
  # 2. Generate contract (if missing) and mock data
74
74
  pf event:generate services/notifications
75
75
  ```
76
76
 
77
77
  This creates:
78
- - `packages/contracts/src/events/order-created.ts` (contract)
79
- - `packages/contracts/src/events/order-created.mock.json` (mock)
78
+ - `packages/contracts/src/events/orders-created.ts` (contract)
79
+ - `packages/contracts/src/events/orders-created.mock.json` (mock)
80
80
  - Updates `packages/contracts/src/index.ts` (exports)
81
81
 
82
82
  ### Manual Contract Creation
83
83
 
84
84
  ```ts
85
- // packages/contracts/src/events/order-created.ts
85
+ // packages/contracts/src/events/orders-created.ts
86
86
  import { createContract } from '@crossdelta/cloudevents'
87
87
  import { z } from 'zod'
88
88
 
89
- export const OrderCreatedSchema = z.object({
89
+ export const OrdersCreatedSchema = z.object({
90
90
  orderId: z.string(),
91
91
  customerId: z.string(),
92
92
  total: z.number(),
@@ -97,12 +97,12 @@ export const OrderCreatedSchema = z.object({
97
97
  })),
98
98
  })
99
99
 
100
- export const OrderCreatedContract = createContract({
101
- type: 'order.created',
102
- schema: OrderCreatedSchema,
100
+ export const OrdersCreatedContract = createContract({
101
+ type: 'orders.created',
102
+ schema: OrdersCreatedSchema,
103
103
  })
104
104
 
105
- export type OrderCreatedData = z.infer<typeof OrderCreatedContract.schema>
105
+ export type OrdersCreatedData = z.infer<typeof OrdersCreatedContract.schema>
106
106
  ```
107
107
 
108
108
  ## Testing with Mocks
@@ -112,10 +112,10 @@ export type OrderCreatedData = z.infer<typeof OrderCreatedContract.schema>
112
112
  pf event:list
113
113
 
114
114
  # Publish mock event
115
- pf event:publish order.created
115
+ pf event:publish orders.created
116
116
 
117
117
  # Publish with custom data
118
- pf event:publish order.created --data '{"orderId":"test-123"}'
118
+ pf event:publish orders.created --data '{"orderId":"test-123"}'
119
119
  ```
120
120
 
121
121
  ## Guidelines
@@ -128,7 +128,7 @@ pf event:publish order.created --data '{"orderId":"test-123"}'
128
128
  - ❌ Don't include event handlers in this package
129
129
 
130
130
  **Naming conventions:**
131
- - Contracts: `OrderCreatedContract`
132
- - Types: `OrderCreatedData`
133
- - Files: `order-created.ts`
134
- - Event types: `order.created` (dot notation)
131
+ - Contracts: `OrdersCreatedContract` (plural namespace)
132
+ - Types: `OrdersCreatedData`
133
+ - Files: `orders-created.ts`
134
+ - Event types: `orders.created` (plural namespace, dot notation)
@@ -9,7 +9,7 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@crossdelta/cloudevents": "^0.4.1",
12
+ "@crossdelta/cloudevents": "^0.4.21",
13
13
  "zod": "^4.0.0"
14
14
  },
15
15
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/platform-sdk",
3
- "version": "0.7.9",
3
+ "version": "0.7.11",
4
4
  "description": "Your AI-powered platform engineer. Scaffold complete Turborepo workspaces, generate microservice boilerplate with natural language, and deploy to the cloud — all from one CLI",
5
5
  "keywords": [
6
6
  "cli",