@crossdelta/platform-sdk 0.11.3 → 0.13.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/platform-sdk",
3
- "version": "0.11.3",
3
+ "version": "0.13.0",
4
4
  "description": "Platform toolkit for event-driven microservices — keeping code and infrastructure in lockstep.",
5
5
  "keywords": [
6
6
  "cli",
@@ -49,136 +49,132 @@
49
49
  },
50
50
  "generatorConfig": {
51
51
  "docs": {
52
- "base": [
53
- "service.md",
54
- "code-style.md",
55
- "testing.md"
56
- ],
52
+ "base": ["service.md", "code-style.md", "testing.md"],
57
53
  "frameworks": {
58
54
  "hono": {
59
- "bun": "hono-bun.md",
60
- "node": "hono-node.md"
61
- },
62
- "nest": "nest.md"
63
- }
64
- },
65
- "serviceTypes": {
66
- "hono": {
67
- "commandType": "hono-micro",
68
- "entryPoint": "src/index.ts",
69
- "skipFiles": [
70
- "package.json",
71
- "tsconfig.json",
72
- "Dockerfile"
73
- ]
55
+ "bun": "hono-bun.md",
56
+ "node": "hono-node.md"
74
57
  },
75
- "nest": {
76
- "commandType": "nest-micro",
77
- "entryPoint": "src/main.ts",
78
- "skipFiles": [
79
- "package.json",
80
- "tsconfig.json",
81
- "Dockerfile"
82
- ]
83
- }
58
+ "nest": "nest.md"
84
59
  }
85
60
  },
86
- "scripts": {
87
- "start:dev": "node esbuild.config.mjs --watch",
88
- "build:cli": "node esbuild.config.mjs",
89
- "build:cli:copy": "cp cli/integration.collection.json bin/integration.collection.json && rm -rf bin/templates && mkdir -p bin/templates && cp -r cli/src/commands/create/workspace/templates bin/templates/workspace && cp -r cli/src/commands/create/hono-microservice/templates bin/templates/hono-microservice && cp -r cli/src/commands/create/nest-microservice/templates bin/templates/nest-microservice && mkdir -p bin/docs/generators && cp -r docs/generators/* bin/docs/generators/",
90
- "build:schematics:transpile": "tsc --project tsconfig.schematics.json",
91
- "build:schematics:copy": "cp -R schematics/* dist/schematics && find dist/schematics -name '*.ts' -delete",
92
- "build:schematics": "npm run build:schematics:transpile && npm run build:schematics:copy",
93
- "build": "npm run build:cli && npm run build:schematics && npm run build:cli:copy",
94
- "prepublishOnly": "npm run build",
95
- "lint": "biome lint --fix",
96
- "test": "bun test",
97
- "test:watch": "bun test --watch"
98
- },
99
- "schematics": "./dist/schematics/collection.json",
100
- "esbuild": {
101
- "external": [
102
- "@crossdelta/infrastructure",
103
- "@faker-js/faker",
104
- "@inquirer/prompts",
105
- "ai",
106
- "@ai-sdk/openai",
107
- "@ai-sdk/anthropic",
108
- "handlebars",
109
- "listr2",
110
- "enquirer",
111
- "execa",
112
- "globby",
113
- "fs-extra",
114
- "chalk",
115
- "ora",
116
- "jiti",
117
- "zod",
118
- "ts-morph",
119
- "commander",
120
- "chokidar"
121
- ]
122
- },
123
- "dependencies": {
124
- "@ai-sdk/anthropic": "^2.0.53",
125
- "@ai-sdk/openai": "^2.0.79",
126
- "@angular-devkit/core": "^21.0.0",
127
- "@faker-js/faker": "^9.8.0",
128
- "@inquirer/prompts": "^7.5.0",
129
- "@listr2/prompt-adapter-enquirer": "^2.0.15",
130
- "ai": "^5.0.108",
131
- "chalk": "^5.4.1",
132
- "chokidar": "^5.0.0",
133
- "cli-table3": "^0.6.5",
134
- "commander": "^13.1.0",
135
- "dotenv": "^17.2.3",
136
- "enquirer": "^2.4.1",
137
- "execa": "^9.5.2",
138
- "fs-extra": "^11.3.0",
139
- "globby": "^14.1.0",
140
- "handlebars": "^4.7.8",
141
- "jiti": "^2.6.1",
142
- "listr2": "^8.3.2",
143
- "ora": "^8.2.0",
144
- "package-up": "^5.0.0",
145
- "rimraf": "^6.1.2",
146
- "terminal-link": "^4.0.0",
147
- "ts-morph": "^27.0.0",
148
- "zod": "^3.24.3"
149
- },
150
- "peerDependencies": {
151
- "@crossdelta/cloudevents": "*",
152
- "@crossdelta/infrastructure": "*",
153
- "@nestjs/schematics": "^11.0.5",
154
- "turbo": "^2.0.0"
155
- },
156
- "peerDependenciesMeta": {
157
- "@crossdelta/cloudevents": {
158
- "optional": true
159
- },
160
- "@crossdelta/infrastructure": {
161
- "optional": true
61
+ "serviceTypes": {
62
+ "hono": {
63
+ "commandType": "hono-micro",
64
+ "entryPoint": "src/index.ts",
65
+ "skipFiles": [
66
+ "package.json",
67
+ "tsconfig.json",
68
+ "Dockerfile"
69
+ ]
162
70
  },
163
- "@nestjs/schematics": {
164
- "optional": true
165
- },
166
- "turbo": {
167
- "optional": true
71
+ "nest": {
72
+ "commandType": "nest-micro",
73
+ "entryPoint": "src/main.ts",
74
+ "skipFiles": [
75
+ "package.json",
76
+ "tsconfig.json",
77
+ "Dockerfile"
78
+ ]
168
79
  }
80
+ }
81
+ },
82
+ "scripts": {
83
+ "start:dev": "node esbuild.config.mjs --watch",
84
+ "build:cli": "node esbuild.config.mjs",
85
+ "build:cli:copy": "cp cli/integration.collection.json bin/integration.collection.json && rm -rf bin/templates && mkdir -p bin/templates && cp -r cli/src/commands/create/workspace/templates bin/templates/workspace && cp -r cli/src/commands/create/hono-microservice/templates bin/templates/hono-microservice && cp -r cli/src/commands/create/nest-microservice/templates bin/templates/nest-microservice && mkdir -p bin/docs/generators && cp -r docs/generators/* bin/docs/generators/",
86
+ "build:schematics:transpile": "tsc --project tsconfig.schematics.json",
87
+ "build:schematics:copy": "cp -R schematics/* dist/schematics && find dist/schematics -name '*.ts' -delete",
88
+ "build:schematics": "npm run build:schematics:transpile && npm run build:schematics:copy",
89
+ "build": "npm run build:cli && npm run build:schematics && npm run build:cli:copy",
90
+ "prepublishOnly": "npm run build",
91
+ "lint": "biome lint --fix",
92
+ "test": "bun test",
93
+ "test:watch": "bun test --watch"
94
+ },
95
+ "schematics": "./dist/schematics/collection.json",
96
+ "esbuild": {
97
+ "external": [
98
+ "@crossdelta/infrastructure",
99
+ "@faker-js/faker",
100
+ "@inquirer/prompts",
101
+ "ai",
102
+ "@ai-sdk/openai",
103
+ "@ai-sdk/anthropic",
104
+ "handlebars",
105
+ "listr2",
106
+ "enquirer",
107
+ "execa",
108
+ "globby",
109
+ "fs-extra",
110
+ "chalk",
111
+ "ora",
112
+ "jiti",
113
+ "zod",
114
+ "ts-morph",
115
+ "commander",
116
+ "chokidar"
117
+ ]
118
+ },
119
+ "dependencies": {
120
+ "@ai-sdk/anthropic": "^2.0.53",
121
+ "@ai-sdk/openai": "^2.0.79",
122
+ "@angular-devkit/core": "^21.0.0",
123
+ "@faker-js/faker": "^9.8.0",
124
+ "@inquirer/prompts": "^7.5.0",
125
+ "@listr2/prompt-adapter-enquirer": "^2.0.15",
126
+ "ai": "^5.0.108",
127
+ "chalk": "^5.4.1",
128
+ "chokidar": "^5.0.0",
129
+ "cli-table3": "^0.6.5",
130
+ "commander": "^13.1.0",
131
+ "dotenv": "^17.2.3",
132
+ "enquirer": "^2.4.1",
133
+ "execa": "^9.5.2",
134
+ "fs-extra": "^11.3.0",
135
+ "globby": "^14.1.0",
136
+ "handlebars": "^4.7.8",
137
+ "jiti": "^2.6.1",
138
+ "listr2": "^8.3.2",
139
+ "ora": "^8.2.0",
140
+ "package-up": "^5.0.0",
141
+ "rimraf": "^6.1.2",
142
+ "terminal-link": "^4.0.0",
143
+ "ts-morph": "^27.0.0",
144
+ "zod": "^3.24.3"
145
+ },
146
+ "peerDependencies": {
147
+ "@crossdelta/cloudevents": "*",
148
+ "@crossdelta/infrastructure": "*",
149
+ "@nestjs/schematics": "^11.0.5",
150
+ "turbo": "^2.0.0"
151
+ },
152
+ "peerDependenciesMeta": {
153
+ "@crossdelta/cloudevents": {
154
+ "optional": true
155
+ },
156
+ "@crossdelta/infrastructure": {
157
+ "optional": true
169
158
  },
170
- "devDependencies": {
171
- "@angular-devkit/core": "^21.0.0",
172
- "@angular-devkit/schematics": "^21.0.0",
173
- "@angular-devkit/schematics-cli": "^19.2.10",
174
- "@eslint/js": "^9.22.0",
175
- "@nestjs/schematics": "^11.0.9",
176
- "@types/fs-extra": "^11.0.4",
177
- "bun-types": "^1.3.4",
178
- "comment-json": "^4.4.1",
179
- "esbuild": "^0.25.3",
180
- "eslint": "^9.25.1",
181
- "typescript": "^5.8.3",
182
- "typescript-eslint": "^8.31.1"
159
+ "@nestjs/schematics": {
160
+ "optional": true
161
+ },
162
+ "turbo": {
163
+ "optional": true
183
164
  }
165
+ },
166
+ "devDependencies": {
167
+ "@angular-devkit/core": "^21.0.0",
168
+ "@angular-devkit/schematics": "^21.0.0",
169
+ "@angular-devkit/schematics-cli": "^19.2.10",
170
+ "@eslint/js": "^9.22.0",
171
+ "@nestjs/schematics": "^11.0.9",
172
+ "@types/fs-extra": "^11.0.4",
173
+ "bun-types": "^1.3.4",
174
+ "comment-json": "^4.4.1",
175
+ "esbuild": "^0.25.3",
176
+ "eslint": "^9.25.1",
177
+ "typescript": "^5.8.3",
178
+ "typescript-eslint": "^8.31.1"
179
+ }
184
180
  }
@@ -1,55 +0,0 @@
1
- import type { K8sServiceConfig } from '@crossdelta/infrastructure'
2
-
3
- /**
4
- * NATS message broker configuration.
5
- *
6
- * Provides event-driven communication via CloudEvents and JetStream.
7
- *
8
- * Internal-only service - accessed via cluster DNS:
9
- * nats://nats.{{projectName}}.svc.cluster.local:4222
10
- *
11
- * Local development:
12
- * nats://localhost:4222
13
- */
14
- const config: K8sServiceConfig = {
15
- name: 'nats',
16
- containerPort: 4222,
17
- replicas: 1,
18
- image: 'nats:2.10-alpine',
19
- command: ['-c', '/etc/nats/nats.prod.conf'],
20
- healthCheck: {
21
- port: 8222,
22
- path: '/healthz',
23
- },
24
- resources: {
25
- requests: { cpu: '50m', memory: '128Mi' },
26
- limits: { cpu: '200m', memory: '256Mi' },
27
- },
28
- volumes: [
29
- {
30
- name: 'nats-config',
31
- configMap: 'nats-config',
32
- mountPath: '/etc/nats',
33
- },
34
- {
35
- name: 'nats-data',
36
- persistentVolumeClaim: 'nats-data',
37
- mountPath: '/data',
38
- },
39
- ],
40
- env: {
41
- // Authentication for production
42
- NATS_USER: process.env.NATS_USER || 'admin',
43
- NATS_PASSWORD: process.env.NATS_PASSWORD || 'changeme',
44
- },
45
- // Expose monitoring port (internal only)
46
- additionalPorts: [
47
- {
48
- name: 'http',
49
- port: 8222,
50
- targetPort: 8222,
51
- },
52
- ],
53
- }
54
-
55
- export default config
@@ -1,107 +0,0 @@
1
- # NATS Message Broker
2
-
3
- > 🚀 **Event-driven communication** powered by NATS + JetStream
4
-
5
- Message broker for CloudEvents-based microservices communication using [`@crossdelta/cloudevents`](https://github.com/crossdelta/platform/tree/main/packages/cloudevents).
6
-
7
- ## ⚡ Quick Start
8
-
9
- ```bash
10
- # Start NATS in Docker (auto-started with `bun dev`)
11
- bun run start:dev
12
-
13
- # Check health
14
- curl http://localhost:8222/healthz
15
-
16
- # View JetStream status
17
- curl http://localhost:8222/jsz
18
- ```
19
-
20
- ## 🔌 Connecting to NATS
21
-
22
- Services connect via environment variables:
23
-
24
- | Environment | URL | Description |
25
- |-------------|-----|-------------|
26
- | **Local** | `nats://localhost:4222` | Docker container |
27
- | **Kubernetes** | `nats://nats.<namespace>.svc.cluster.local:4222` | Internal service DNS |
28
-
29
- **Example:**
30
- ```typescript
31
- import { publish } from '@crossdelta/cloudevents'
32
-
33
- await publish('orders.created', { orderId: 'ord_123', total: 99.99 })
34
- ```
35
-
36
- ## 📊 Monitoring & Health Checks
37
-
38
- NATS exposes HTTP endpoints for monitoring:
39
-
40
- | Endpoint | Purpose |
41
- |----------|---------|
42
- | `http://localhost:8222/healthz` | Health check (`{"status":"ok"}`) |
43
- | `http://localhost:8222/jsz` | JetStream statistics (streams, consumers, messages) |
44
- | `http://localhost:8222/varz` | Server variables (connections, memory, uptime) |
45
- | `http://localhost:8222/connz` | Active connections |
46
-
47
- ## 🗄️ JetStream Persistence
48
-
49
- JetStream provides durable event streaming with at-least-once delivery:
50
-
51
- - **Local Dev:** `.nats-data/` directory (git-ignored)
52
- - **Production:** Persistent volume mounted at `/data`
53
- - **Streams:** Auto-created by `@crossdelta/cloudevents` consumer setup
54
-
55
- **Stream Configuration:**
56
- - Retention: Interest-based (messages deleted after all consumers ack)
57
- - Deduplication: 2-minute window
58
- - Max message age: 24 hours (configurable via `nats.prod.conf`)
59
-
60
- ## 🛠️ Configuration
61
-
62
- ### Local Development (`nats.conf`)
63
- - JetStream enabled with local file storage
64
- - No authentication (Docker network isolation)
65
- - Ports: 4222 (client), 8222 (HTTP monitoring)
66
-
67
- ### Production (`nats.prod.conf`)
68
- - Token-based authentication (via `NATS_TOKEN` env var)
69
- - Persistent storage at `/data`
70
- - Resource limits configured via Kubernetes
71
-
72
- ## 📦 Environment Variables
73
-
74
- Generated automatically in `.env.local` via `bun dev`:
75
-
76
- ```bash
77
- NATS_PORT=4222 # Client port
78
- NATS_HTTP_PORT=8222 # HTTP monitoring port
79
- NATS_IMAGE=nats:2.10-alpine # Docker image
80
- ```
81
-
82
- ## 🐳 Docker Commands
83
-
84
- ```bash
85
- # Start (via npm script)
86
- bun run start:dev
87
-
88
- # Manual start
89
- docker run -d --name my-nats \
90
- -p 4222:4222 -p 8222:8222 \
91
- -v $(pwd)/.nats-data:/data \
92
- -v $(pwd)/nats.conf:/etc/nats/nats.conf:ro \
93
- nats:2.10-alpine -c /etc/nats/nats.conf
94
-
95
- # View logs
96
- docker logs -f my-nats
97
-
98
- # Stop & remove
99
- docker rm -f my-nats
100
- ```
101
-
102
- ## 📚 Learn More
103
-
104
- - [NATS Documentation](https://docs.nats.io/)
105
- - [JetStream Guide](https://docs.nats.io/nats-concepts/jetstream)
106
- - [`@crossdelta/cloudevents` Package](https://github.com/crossdelta/platform/tree/main/packages/cloudevents)
107
- - [CloudEvents Specification](https://cloudevents.io/)
@@ -1,31 +0,0 @@
1
- # NATS Server Configuration
2
- # Used by both local development and production
3
- # See: https://docs.nats.io/running-a-nats-service/configuration
4
-
5
- # Server identification
6
- server_name: nats
7
-
8
- # Client connections
9
- listen: 0.0.0.0:4222
10
-
11
- # HTTP monitoring
12
- http: 0.0.0.0:8222
13
-
14
- # JetStream configuration
15
- jetstream {
16
- # Store directory for persistence
17
- # Local: mounted from .nats-data/
18
- # Production: mounted from DO Volume
19
- store_dir: /data/jetstream
20
-
21
- # Memory storage limit (1GB)
22
- max_mem_store: 1Gb
23
-
24
- # File storage limit (10GB - matches DO Volume size)
25
- max_file_store: 10Gb
26
- }
27
-
28
- # Logging
29
- debug: false
30
- trace: false
31
- logtime: true
@@ -1,27 +0,0 @@
1
- # NATS Server Configuration - Production
2
- # Includes authentication for secure public access
3
- # See: https://docs.nats.io/running-a-nats-service/configuration
4
-
5
- # Server identification
6
- server_name: nats
7
-
8
- # Client connections
9
- listen: 0.0.0.0:4222
10
-
11
- # HTTP monitoring (internal only)
12
- http: 127.0.0.1:8222
13
-
14
- # Authentication - required for production
15
- # Env vars: NATS_USER, NATS_PASSWORD
16
- authorization {
17
- user: $NATS_USER
18
- password: $NATS_PASSWORD
19
- timeout: 5
20
- }
21
-
22
- # JetStream configuration
23
- jetstream {
24
- store_dir: /data/jetstream
25
- max_mem: 256M
26
- max_file: 2G
27
- }
@@ -1,7 +0,0 @@
1
- {
2
- "name": "@{{projectName}}/nats",
3
- "private": true,
4
- "scripts": {
5
- "start:dev": "./scripts/start-dev.sh"
6
- }
7
- }
@@ -1,55 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- # Load environment variables from root .env.local
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
- ROOT_DIR="$SCRIPT_DIR/../../.."
7
- ENV_FILE="$ROOT_DIR/.env.local"
8
-
9
- if [[ -f "$ENV_FILE" ]]; then
10
- set -a
11
- source "$ENV_FILE"
12
- set +a
13
- else
14
- echo "[NATS] Warning: $ENV_FILE not found. Run 'pf dev' or your package manager's 'generate-env' script first."
15
- fi
16
-
17
- # Container name (local dev only)
18
- CONTAINER_NAME="{{projectName}}-nats"
19
-
20
- # Ports from .env.local (generated from infra/services/nats.ts)
21
- NATS_PORT="${NATS_PORT:-4222}"
22
- NATS_HTTP_PORT="${NATS_HTTP_PORT:-8222}"
23
- NATS_IMAGE="${NATS_IMAGE:-nats:2.10-alpine}"
24
-
25
- # Config file (shared between local and production)
26
- NATS_CONF="$SCRIPT_DIR/../nats.conf"
27
-
28
- # Data directory for JetStream persistence (local dev)
29
- NATS_DATA_DIR="${NATS_DATA_DIR:-$ROOT_DIR/.nats-data}"
30
-
31
- # Stop and remove existing container if it exists (ensures clean state)
32
- if docker ps -a --format '\{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
33
- echo "[NATS] Removing existing container..."
34
- docker rm -f "$CONTAINER_NAME" > /dev/null 2>&1 || true
35
- fi
36
-
37
- # Ensure data directory exists
38
- mkdir -p "$NATS_DATA_DIR"
39
-
40
- # Create new container with shared config file
41
- # Config file: services/nats/nats.conf (same as production)
42
- echo "[NATS] Starting with JetStream on ports ${NATS_PORT} (client) and ${NATS_HTTP_PORT} (http)..."
43
- echo "[NATS] Using config: $NATS_CONF"
44
- echo "[NATS] Data directory: $NATS_DATA_DIR"
45
- echo ""
46
-
47
- # Start container in foreground (logs streaming) so Turbo keeps watching
48
- docker run --rm \
49
- --name "$CONTAINER_NAME" \
50
- -p "${NATS_PORT}:4222" \
51
- -p "${NATS_HTTP_PORT}:8222" \
52
- -v "${NATS_DATA_DIR}:/data" \
53
- -v "${NATS_CONF}:/etc/nats/nats.conf:ro" \
54
- "$NATS_IMAGE" \
55
- -c /etc/nats/nats.conf