@crossdelta/platform-sdk 0.7.8 → 0.7.10

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
@@ -167,12 +167,8 @@ my-platform/
167
167
  │ └── nats/ # NATS message broker (auto-scaffolded)
168
168
  ├── apps/ # Frontend apps (optional: Qwik, Next.js, etc.)
169
169
  ├── packages/ # Shared libraries
170
- │ ├── contracts/ # Event contracts (Schema Registry)
170
+ │ ├── contracts/ # Event contracts (Schema Registry - created when generating Event Consumers)
171
171
  │ │ └── src/
172
- │ │ ├── events/ # Event schemas with Zod validation
173
- │ │ │ ├── order-created.ts
174
- │ │ │ ├── order-created.mock.json
175
- │ │ │ └── payment-processed.ts
176
172
  │ │ └── index.ts # Export all contracts
177
173
  │ ├── cloudevents/ # Event publishing/consuming toolkit
178
174
  │ ├── telemetry/ # OpenTelemetry setup
@@ -188,6 +184,8 @@ my-platform/
188
184
  └── .env.local # Auto-generated from infra configs
189
185
  ```
190
186
 
187
+ > **Note:** The `packages/contracts` package starts with just an `index.ts`. Event contract files (e.g., `events/order-created.ts`) are automatically generated when you create **Event Consumer** services with `pf new hono-micro --ai`.
188
+
191
189
  ### Key Architectural Decisions
192
190
 
193
191
  1. **NATS + JetStream baseline** — Event-driven communication is built-in, not bolted on
@@ -200,7 +198,7 @@ my-platform/
200
198
 
201
199
  ### Event-Driven Mental Model
202
200
 
203
- Services communicate via **CloudEvents** over **NATS JetStream** with **type-safe contracts**:
201
+ Services communicate via **CloudEvents** over **NATS JetStream** using the **Schema Registry** as single source of truth:
204
202
 
205
203
  ```typescript
206
204
  // packages/contracts/src/events/order-created.ts (Schema Registry)
@@ -222,20 +220,20 @@ export type OrderCreatedData = z.infer<typeof OrderCreatedContract.schema>
222
220
  import { publish } from '@crossdelta/cloudevents'
223
221
  import { OrderCreatedContract } from '@my-platform/contracts'
224
222
 
225
- await publish(OrderCreatedContract, {
226
- orderId: '123',
223
+ await publish(OrderCreatedContract, {
224
+ orderId: '123',
227
225
  customerId: 'cust-456',
228
- total: 99.99
226
+ total: 99.99
229
227
  })
230
228
 
231
229
  // Service B auto-discovers and handles it (Event Consumer)
232
230
  // File: services/notifications/src/events/order-created.event.ts
233
231
  import { handleEvent } from '@crossdelta/cloudevents'
234
232
  import { OrderCreatedContract, type OrderCreatedData } from '@my-platform/contracts'
235
- export default handleEvent(
236
- { schema: OrderCreatedSchema, type: 'orders.created' },
237
- async (data) => { await sendNotification(data) }
238
- )
233
+
234
+ export default handleEvent(OrderCreatedContract, async (data: OrderCreatedData) => {
235
+ await sendNotification(data)
236
+ })
239
237
  ```
240
238
 
241
239
  No manual NATS subscriptions. No boilerplate. Just **convention over configuration**.