@crossdelta/platform-sdk 0.7.8 → 0.7.9
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**
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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**.
|
|
@@ -697,7 +697,7 @@ Step 3: CREATE event handler that uses those fields:
|
|
|
697
697
|
services/order-notifications/src/events/order-created.event.ts:
|
|
698
698
|
import { OrderCreatedContract, type OrderCreatedData } from '@scope/contracts'
|
|
699
699
|
export default handleEvent(OrderCreatedContract, async (data) => {
|
|
700
|
-
await sendNotification({
|
|
700
|
+
await sendNotification({
|
|
701
701
|
orderId: data.orderId, // ✅ Field exists in contract
|
|
702
702
|
customerId: data.customerId, // ✅ Field exists in contract
|
|
703
703
|
total: data.total, // ✅ Field exists in contract
|
|
@@ -742,7 +742,7 @@ export const OrderCreatedContract = createContract({
|
|
|
742
742
|
orderId: z.string(),
|
|
743
743
|
customerId: z.string(),
|
|
744
744
|
total: z.number(),
|
|
745
|
-
|
|
745
|
+
|
|
746
746
|
// OPTIONAL: Additional context fields
|
|
747
747
|
items: z.array(z.object({
|
|
748
748
|
productId: z.string(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossdelta/platform-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
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",
|