@crossdelta/platform-sdk 0.12.0 → 0.13.1
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 +22 -7
- package/bin/cli.js +144 -136
- package/bin/docs/generators/hono-bun.md +70 -26
- package/bin/docs/generators/hono-node.md +76 -26
- package/bin/docs/generators/nest.md +25 -7
- package/bin/docs/generators/service.md +302 -25
- package/bin/templates/hono-microservice/src/index.ts.hbs +18 -0
- package/bin/templates/nest-microservice/src/events/events.service.ts.hbs +7 -10
- package/bin/templates/nest-microservice/src/main.ts.hbs +1 -1
- package/bin/templates/workspace/.github/workflows/build-and-deploy.yml.hbs +0 -3
- package/bin/templates/workspace/.github/workflows/publish-packages.yml +1 -2
- package/bin/templates/workspace/infra/services/.gitkeep +0 -0
- package/bin/templates/workspace/package.json.hbs +2 -2
- package/bin/templates/workspace/packages/contracts/README.md.hbs +40 -8
- package/bin/templates/workspace/packages/contracts/package.json.hbs +2 -1
- package/bin/templates/workspace/packages/contracts/src/events/index.ts +16 -0
- package/bin/templates/workspace/packages/contracts/src/index.ts +9 -0
- package/bin/templates/workspace/packages/contracts/src/stream-policies.ts.hbs +40 -0
- package/package.json +1 -1
- package/bin/templates/workspace/infra/services/nats.ts.hbs +0 -55
- package/bin/templates/workspace/services/nats/README.md +0 -107
- package/bin/templates/workspace/services/nats/nats.conf +0 -31
- package/bin/templates/workspace/services/nats/nats.prod.conf +0 -27
- package/bin/templates/workspace/services/nats/package.json.hbs +0 -7
- package/bin/templates/workspace/services/nats/scripts/start-dev.sh.hbs +0 -55
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
|
-
<sub>
|
|
16
|
+
<sub>Frontend SDK coming soon — contract-based client models.</sub>
|
|
17
17
|
|
|
18
18
|
</p>
|
|
19
19
|
|
|
@@ -190,7 +190,7 @@ pf event publish orders.created
|
|
|
190
190
|
|
|
191
191
|
| Command | What it does |
|
|
192
192
|
|:--------|:-------------|
|
|
193
|
-
| `pf dev` | 🚀 Start NATS + all services in watch mode |
|
|
193
|
+
| `pf dev` | 🚀 Start development infrastructure (NATS) + all services in watch mode |
|
|
194
194
|
| `pf new hono-micro <path>` | ⚡ Create a Hono service (lightweight, Bun-optimized) |
|
|
195
195
|
| `pf new nest-micro <path>` | 🏢 Create a NestJS service (full-featured, decorators) |
|
|
196
196
|
| `pf event add <type> --service <path>` | 🔗 Add contract + handler + wire stream |
|
|
@@ -390,12 +390,13 @@ See [@crossdelta/infrastructure](https://www.npmjs.com/package/@crossdelta/infra
|
|
|
390
390
|
**Contracts** live in `packages/contracts/` as the single source of truth:
|
|
391
391
|
|
|
392
392
|
```typescript
|
|
393
|
-
// packages/contracts/src/events/orders
|
|
393
|
+
// packages/contracts/src/events/orders/created.ts
|
|
394
394
|
import { createContract } from '@crossdelta/cloudevents'
|
|
395
395
|
import { z } from 'zod'
|
|
396
396
|
|
|
397
397
|
export const OrdersCreatedContract = createContract({
|
|
398
398
|
type: 'orders.created',
|
|
399
|
+
channel: { stream: 'ORDERS' },
|
|
399
400
|
schema: z.object({ orderId: z.string(), total: z.number() }),
|
|
400
401
|
})
|
|
401
402
|
```
|
|
@@ -403,9 +404,9 @@ export const OrdersCreatedContract = createContract({
|
|
|
403
404
|
**Handlers** import contracts and delegate to use cases:
|
|
404
405
|
|
|
405
406
|
```typescript
|
|
406
|
-
// services/notifications/src/events/orders-created.
|
|
407
|
+
// services/notifications/src/events/orders-created.handler.ts
|
|
407
408
|
import { handleEvent } from '@crossdelta/cloudevents'
|
|
408
|
-
import { OrdersCreatedContract } from '@my-
|
|
409
|
+
import { OrdersCreatedContract } from '@my-platform/contracts'
|
|
409
410
|
import { sendOrderNotification } from '../use-cases/send-notification.use-case'
|
|
410
411
|
|
|
411
412
|
export default handleEvent(OrdersCreatedContract, async (data) => {
|
|
@@ -424,11 +425,25 @@ See [@crossdelta/cloudevents](https://www.npmjs.com/package/@crossdelta/cloudeve
|
|
|
424
425
|
|
|
425
426
|
<br />
|
|
426
427
|
|
|
427
|
-
|
|
428
|
+
> **Local NATS started by `pf dev` is development infrastructure.**
|
|
429
|
+
> **Production streams are materialized via Pulumi from contracts.**
|
|
428
430
|
|
|
429
|
-
|
|
431
|
+
Every workspace includes pre-configured NATS with JetStream for development:
|
|
432
|
+
|
|
433
|
+
**Development:**
|
|
434
|
+
- Auto-started with `pf dev` (docker-based, ephemeral)
|
|
430
435
|
- Ports: `4222` (client), `8222` (monitoring)
|
|
431
436
|
- Health check: `curl http://localhost:8222/healthz`
|
|
437
|
+
- Streams: Auto-created by `pf dev` from contracts (memory, 1h retention)
|
|
438
|
+
|
|
439
|
+
**Production:**
|
|
440
|
+
- Deployed via Pulumi (`infra/`)
|
|
441
|
+
- Streams materialized from contracts with retention policies
|
|
442
|
+
- Persistent storage (file-based) with explicit limits
|
|
443
|
+
|
|
444
|
+
> **Services never create streams** — in dev: `pf dev` auto-creates from contracts, in prod: Pulumi materializes.
|
|
445
|
+
|
|
446
|
+
See `infra/dev/README.md` for Dev-Infra vs Platform-Infra separation.
|
|
432
447
|
|
|
433
448
|
</details>
|
|
434
449
|
|