@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.
package/README.md CHANGED
@@ -33,17 +33,42 @@
33
33
  <br />
34
34
 
35
35
  ---
36
- ## πŸš€ Quick Start
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ # Pick your package manager
41
+ bun add -g @crossdelta/platform-sdk
42
+ npm install -g @crossdelta/platform-sdk
43
+ pnpm add -g @crossdelta/platform-sdk
44
+ ```
45
+
46
+ <details>
47
+ <summary>Alternative: Auto-installer or use without installing</summary>
48
+
49
+ ```bash
50
+ # Auto-installer (detects package manager, offers to install Bun if needed)
51
+ curl -fsSL https://unpkg.com/@crossdelta/platform-sdk@latest/install.sh | bash
52
+
53
+ # Or run directly without global install
54
+ bunx @crossdelta/platform-sdk new workspace my-platform
55
+ npx @crossdelta/platform-sdk new workspace my-platform
56
+ ```
57
+
58
+ </details>
59
+
60
+ ---
61
+
62
+ ## Quick Start
37
63
 
38
64
  ```bash
39
- # Create workspace (works with bunx/npx/pnpm dlx/yarn dlx)
40
- bunx @crossdelta/platform-sdk new workspace my-platform -y
65
+ # Create workspace
66
+ pf new workspace my-platform -y
41
67
  cd my-platform
42
68
 
43
69
  # Generate microservice with AI
44
- # (first time: run `pf setup --ai` to configure provider)
45
- bunx @crossdelta/platform-sdk new hono-micro services/orders --ai \
46
- -d "Handle order creation and payment"
70
+ pf setup --ai # Configure AI provider (first time only)
71
+ pf new hono-micro services/orders --ai -d "Handle order creation and payment"
47
72
 
48
73
  # Start development
49
74
  pf dev
@@ -71,43 +96,8 @@ pf pulumi up # β†’ runs in infra/ directory
71
96
 
72
97
  **Why:** Keeps commands consistent across the team and works from any subdirectory.
73
98
 
74
- **How it works:** `pf` walks up to find your workspace root, then proxies to your scripts. Configured commands via `pf.commands` can override the working directory or command. Registered `pf` commands (like `pf new`) take precedence.
75
-
76
99
  > **πŸ“– Note:** You can be productive with `pf` in minutes using the commands above. The sections below are reference documentationβ€”explore them when you need specific details.
77
100
 
78
- ### No runtime installed?
79
-
80
- If you don't have a JavaScript runtime, use our installer that sets everything up.
81
- **The installer is optional** β€” you can always use `bunx`/`npx` or a global install.
82
-
83
- ```bash
84
- # Auto-installer (detects bun/pnpm/yarn/npm; if none found it can install Bun)
85
- curl -fsSL https://unpkg.com/@crossdelta/platform-sdk@latest/install.sh | bash
86
-
87
- # Then use short commands
88
- pf new workspace my-platform
89
- pf new hono-micro services/orders --ai -d "..."
90
- ```
91
-
92
- > **Security:** The installer asks permission before installing Bun (if needed) and does not run any workspace commands automatically.
93
-
94
- <details>
95
- <summary><strong>πŸ” What does the installer do?</strong></summary>
96
-
97
- The script ([view source](https://unpkg.com/@crossdelta/platform-sdk@latest/install.sh)):
98
- 1. Checks for bun/pnpm/yarn/npm
99
- 2. If none found, **asks permission** to install Bun
100
- 3. Installs `pf` CLI globally
101
-
102
- **Manual installation:**
103
- ```bash
104
- # With Bun/npm/yarn/pnpm
105
- bun add -g @crossdelta/platform-sdk
106
- # or: npm install -g @crossdelta/platform-sdk
107
- ```
108
-
109
- </details>
110
-
111
101
  <br />
112
102
 
113
103
  ---
@@ -161,30 +151,23 @@ When you create a workspace with `pf`, you get a **Turborepo monorepo** with thi
161
151
 
162
152
  ```
163
153
  my-platform/
164
- β”œβ”€β”€ services/ # Microservices (Hono, NestJS)
165
- β”‚ β”œβ”€β”€ orders/ # Example: Order processing service (Event Publisher)
166
- β”‚ β”œβ”€β”€ notifications/# Example: Notification service (Event Consumer)
154
+ β”œβ”€β”€ services/ # Microservices (generate with pf new hono-micro)
167
155
  β”‚ └── nats/ # NATS message broker (auto-scaffolded)
168
- β”œβ”€β”€ apps/ # Frontend apps (optional: Qwik, Next.js, etc.)
156
+ β”œβ”€β”€ apps/ # Frontend apps (optional)
169
157
  β”œβ”€β”€ packages/ # Shared libraries
170
- β”‚ β”œβ”€β”€ contracts/ # Event contracts (Schema Registry - created when generating Event Consumers)
171
- β”‚ β”‚ └── src/
172
- β”‚ β”‚ └── index.ts # Export all contracts
173
- β”‚ β”œβ”€β”€ cloudevents/ # Event publishing/consuming toolkit
174
- β”‚ β”œβ”€β”€ telemetry/ # OpenTelemetry setup
175
- β”‚ └── infrastructure/ # Pulumi utilities and K8s builders
158
+ β”‚ └── contracts/ # Event contracts (Schema Registry)
159
+ β”‚ └── src/
160
+ β”‚ └── index.ts
176
161
  β”œβ”€β”€ infra/ # Pulumi Infrastructure-as-Code
177
162
  β”‚ β”œβ”€β”€ index.ts # Main Pulumi program
178
- β”‚ └── services/ # Per-service K8s configs
179
- β”‚ β”œβ”€β”€ orders.ts
180
- β”‚ └── notifications.ts
163
+ β”‚ └── services/ # Per-service K8s configs (auto-generated)
181
164
  β”œβ”€β”€ .github/
182
- β”‚ └── workflows/ # CI/CD pipelines (auto-generated)
165
+ β”‚ └── workflows/ # CI/CD pipelines
183
166
  β”œβ”€β”€ turbo.json # Turborepo task orchestration
184
167
  └── .env.local # Auto-generated from infra configs
185
168
  ```
186
169
 
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`.
170
+ > **Note:** Services use external packages (`@crossdelta/cloudevents`, `@crossdelta/telemetry`, `@crossdelta/infrastructure`) installed via npm. Only `packages/contracts` is local to your workspace.
188
171
 
189
172
  ### Key Architectural Decisions
190
173
 
@@ -201,11 +184,11 @@ my-platform/
201
184
  Services communicate via **CloudEvents** over **NATS JetStream** using the **Schema Registry** as single source of truth:
202
185
 
203
186
  ```typescript
204
- // packages/contracts/src/events/order-created.ts (Schema Registry)
187
+ // packages/contracts/src/events/orders-created.ts (Schema Registry)
205
188
  import { createContract } from '@crossdelta/cloudevents'
206
189
  import { z } from 'zod'
207
190
 
208
- export const OrderCreatedContract = createContract({
191
+ export const OrdersCreatedContract = createContract({
209
192
  type: 'orders.created',
210
193
  schema: z.object({
211
194
  orderId: z.string(),
@@ -214,24 +197,24 @@ export const OrderCreatedContract = createContract({
214
197
  }),
215
198
  })
216
199
 
217
- export type OrderCreatedData = z.infer<typeof OrderCreatedContract.schema>
200
+ export type OrdersCreatedData = z.infer<typeof OrdersCreatedContract.schema>
218
201
 
219
202
  // Service A publishes an event (Event Publisher)
220
203
  import { publish } from '@crossdelta/cloudevents'
221
- import { OrderCreatedContract } from '@my-platform/contracts'
204
+ import { OrdersCreatedContract } from '@my-platform/contracts'
222
205
 
223
- await publish(OrderCreatedContract, {
206
+ await publish(OrdersCreatedContract, {
224
207
  orderId: '123',
225
208
  customerId: 'cust-456',
226
209
  total: 99.99
227
210
  })
228
211
 
229
212
  // Service B auto-discovers and handles it (Event Consumer)
230
- // File: services/notifications/src/events/order-created.event.ts
213
+ // File: services/notifications/src/events/orders-created.event.ts
231
214
  import { handleEvent } from '@crossdelta/cloudevents'
232
- import { OrderCreatedContract, type OrderCreatedData } from '@my-platform/contracts'
215
+ import { OrdersCreatedContract, type OrdersCreatedData } from '@my-platform/contracts'
233
216
 
234
- export default handleEvent(OrderCreatedContract, async (data: OrderCreatedData) => {
217
+ export default handleEvent(OrdersCreatedContract, async (data: OrdersCreatedData) => {
235
218
  await sendNotification(data)
236
219
  })
237
220
  ```
@@ -467,21 +450,21 @@ await publish('orders.created', { orderId: 'ord_123', total: 99.99 })
467
450
  ### Consume Events (Auto-Discovered)
468
451
 
469
452
  ```typescript
470
- // services/notifications/src/events/order-created.event.ts
453
+ // services/notifications/src/events/orders-created.event.ts
471
454
  import { handleEvent } from '@crossdelta/cloudevents'
472
455
  import { z } from 'zod'
473
456
 
474
- const OrderCreatedSchema = z.object({
457
+ const OrdersCreatedSchema = z.object({
475
458
  orderId: z.string(),
476
459
  total: z.number(),
477
460
  })
478
461
 
479
462
  // Export type for use in use-cases
480
- export type OrderCreatedEvent = z.infer<typeof OrderCreatedSchema>
463
+ export type OrdersCreatedEvent = z.infer<typeof OrdersCreatedSchema>
481
464
 
482
465
  export default handleEvent(
483
466
  {
484
- schema: OrderCreatedSchema,
467
+ schema: OrdersCreatedSchema,
485
468
  type: 'orders.created',
486
469
  },
487
470
  async (data) => {