@crossdelta/platform-sdk 0.9.4 → 0.10.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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["../../biome.json"]
3
+ }
@@ -5,6 +5,7 @@
5
5
  "moduleResolution": "Bundler",
6
6
  "strict": true,
7
7
  "lib": ["ES2022"],
8
+ "types": ["bun"],
8
9
  "jsx": "react-jsx",
9
10
  "jsxImportSource": "hono/jsx",
10
11
  "esModuleInterop": true,
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": ["../../biome.json"],
3
+ "linter": {
4
+ "rules": {
5
+ "style": {
6
+ "useImportType": "off"
7
+ }
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,17 @@
1
+ import type { INestApplication, Type } from '@nestjs/common'
2
+
3
+ let app: INestApplication
4
+
5
+ export const setAppContext = (nestApp: INestApplication): void => {
6
+ app = nestApp
7
+ }
8
+
9
+ export const getAppContext = (): INestApplication => {
10
+ if (!app) throw new Error('App context not initialized')
11
+ return app
12
+ }
13
+
14
+ export const getService = <T>(serviceClass: Type<T>): T => {
15
+ return getAppContext().get(serviceClass)
16
+ }
17
+
@@ -0,0 +1,8 @@
1
+ import { Module } from '@nestjs/common'
2
+ import { EventsService } from './events.service'
3
+
4
+ @Module({
5
+ providers: [EventsService],
6
+ exports: [EventsService],
7
+ })
8
+ export class EventsModule {}
@@ -0,0 +1,25 @@
1
+ import { Injectable, Logger } from '@nestjs/common'
2
+ import { consumeJetStreamStreams, ensureJetStreamStreams } from '@crossdelta/cloudevents'
3
+
4
+ @Injectable()
5
+ export class EventsService {
6
+ private readonly logger = new Logger(EventsService.name)
7
+
8
+ async startConsumers(): Promise<void> {
9
+ // Configure your streams here
10
+ // Example:
11
+ // await ensureJetStreamStreams({
12
+ // streams: [
13
+ // { stream: 'ORDERS', subjects: ['orders.*'] },
14
+ // ],
15
+ // })
16
+
17
+ // consumeJetStreamStreams({
18
+ // streams: ['ORDERS'],
19
+ // consumer: '{{serviceName}}',
20
+ // discover: './src/events/**/*.event.ts',
21
+ // })
22
+
23
+ this.logger.log('Event consumers ready (configure streams in events.service.ts)')
24
+ }
25
+ }
@@ -5,6 +5,8 @@ import { env } from 'node:process'
5
5
  import { ConsoleLogger } from '@nestjs/common'
6
6
  import { NestFactory } from '@nestjs/core'
7
7
  import { AppModule } from './app.module'
8
+ import { setAppContext } from './app.context'
9
+ import { EventsService } from './events/events.service'
8
10
 
9
11
  const port = Number(process.env.PORT || process.env.{{envKey}}_PORT) || {{defaultPort}}
10
12
  const serviceName = '{{displayName}}'
@@ -17,6 +19,13 @@ const logger = new ConsoleLogger({
17
19
  async function bootstrap() {
18
20
  const app = await NestFactory.create(AppModule, { logger })
19
21
 
22
+ // Make app context available to event handlers
23
+ setAppContext(app)
24
+
25
+ // Start NATS event consumers
26
+ const eventsService = app.get(EventsService)
27
+ await eventsService.startConsumers()
28
+
20
29
  await app
21
30
  .listen(port)
22
31
  .then(() => logger.log(`${serviceName} is running on port ${port}`))
@@ -16,6 +16,7 @@ Always generate **minimal diffs**, never full rewrites.
16
16
  - Single quotes, no semicolons, 2-space indent, trailing commas.
17
17
  - Alphabetically sorted imports; no unused imports.
18
18
  - Arrow functions over `function` declarations.
19
+ - Template literals over string concatenation.
19
20
  - Prefer pure and functional programming patterns (map/filter/reduce).
20
21
  - Avoid mutable state and imperative loops.
21
22
  - No decorative section header blocks (no ASCII art separators like `// ─────────────`).
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.3.7/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
3
3
  "formatter": {
4
4
  "indentStyle": "space"
5
5
  },
@@ -16,9 +16,6 @@
16
16
  "commands": {
17
17
  "pulumi": {
18
18
  "cwd": "infra"
19
- },
20
- "audit": {
21
- "command": "bun audit"
22
19
  }
23
20
  },
24
21
  "paths": {
@@ -40,9 +37,8 @@
40
37
  }
41
38
  },
42
39
  "dependencies": {
43
- "@crossdelta/cloudevents": "latest",
44
- "@crossdelta/telemetry": "latest",
45
- "bun": "^1.2.7"
40
+ "@crossdelta/cloudevents": "^0.4.23",
41
+ "@crossdelta/telemetry": "^0.1.4"
46
42
  },
47
43
  "devDependencies": {
48
44
  "@biomejs/biome": "2.3.7",
@@ -2,6 +2,8 @@
2
2
  "name": "{{scope}}/contracts",
3
3
  "private": true,
4
4
  "type": "module",
5
+ "main": "./src/index.ts",
6
+ "types": "./src/index.ts",
5
7
  "exports": {
6
8
  ".": {
7
9
  "types": "./src/index.ts",
@@ -9,7 +11,7 @@
9
11
  }
10
12
  },
11
13
  "dependencies": {
12
- "@crossdelta/cloudevents": "^0.4.22",
14
+ "@crossdelta/cloudevents": "^0.5.0",
13
15
  "zod": "^4.0.0"
14
16
  },
15
17
  "devDependencies": {
@@ -1,5 +1,4 @@
1
1
  {
2
- "extends": "../../tsconfig.json",
3
2
  "compilerOptions": {
4
3
  "outDir": "./dist",
5
4
  "rootDir": "./src"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/platform-sdk",
3
- "version": "0.9.4",
3
+ "version": "0.10.1",
4
4
  "description": "Platform toolkit for event-driven microservices — keeping code and infrastructure in lockstep.",
5
5
  "keywords": [
6
6
  "cli",
@@ -48,6 +48,28 @@
48
48
  "name": "Marcelle Hövelmanns",
49
49
  "email": "mail@hoevelmanns.io"
50
50
  },
51
+ "generatorConfig": {
52
+ "serviceTypes": {
53
+ "hono": {
54
+ "commandType": "hono-micro",
55
+ "entryPoint": "src/index.ts",
56
+ "skipFiles": [
57
+ "package.json",
58
+ "tsconfig.json",
59
+ "Dockerfile"
60
+ ]
61
+ },
62
+ "nest": {
63
+ "commandType": "nest-micro",
64
+ "entryPoint": "src/main.ts",
65
+ "skipFiles": [
66
+ "package.json",
67
+ "tsconfig.json",
68
+ "Dockerfile"
69
+ ]
70
+ }
71
+ }
72
+ },
51
73
  "scripts": {
52
74
  "start:dev": "node esbuild.config.mjs --watch",
53
75
  "build:cli": "node esbuild.config.mjs",
@@ -66,7 +88,7 @@
66
88
  "external": [
67
89
  "@crossdelta/infrastructure",
68
90
  "@faker-js/faker",
69
- "@anatine/zod-mock",
91
+ "@inquirer/prompts",
70
92
  "ai",
71
93
  "@ai-sdk/openai",
72
94
  "@ai-sdk/anthropic",
@@ -74,19 +96,22 @@
74
96
  "handlebars",
75
97
  "zx",
76
98
  "listr2",
99
+ "enquirer",
77
100
  "execa",
78
101
  "globby",
79
102
  "fs-extra",
80
103
  "chalk",
81
104
  "ora",
82
105
  "jiti",
83
- "zod"
106
+ "zod",
107
+ "ts-morph",
108
+ "commander",
109
+ "chokidar"
84
110
  ]
85
111
  },
86
112
  "dependencies": {
87
113
  "@ai-sdk/anthropic": "^2.0.53",
88
114
  "@ai-sdk/openai": "^2.0.79",
89
- "@anatine/zod-mock": "^3.14.0",
90
115
  "@angular-devkit/core": "^21.0.0",
91
116
  "@faker-js/faker": "^9.8.0",
92
117
  "@inquirer/prompts": "^7.5.0",
@@ -109,6 +134,7 @@
109
134
  "package-up": "^5.0.0",
110
135
  "rimraf": "^6.1.2",
111
136
  "terminal-link": "^4.0.0",
137
+ "ts-morph": "^27.0.0",
112
138
  "vite": "^6.3.4",
113
139
  "zod": "^3.24.3",
114
140
  "zx": "^8.5.3"
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Service Types Configuration",
4
+ "description": "Configuration for different microservice types in the Platform SDK",
5
+ "type": "object",
6
+ "properties": {
7
+ "serviceTypes": {
8
+ "type": "object",
9
+ "additionalProperties": {
10
+ "type": "object",
11
+ "required": ["commandType", "entryPoint", "skipFiles"],
12
+ "properties": {
13
+ "commandType": {
14
+ "type": "string",
15
+ "description": "CLI command type for scaffolding (e.g., 'hono-micro', 'nest-micro')"
16
+ },
17
+ "entryPoint": {
18
+ "type": "string",
19
+ "description": "Relative path to the service entry point file"
20
+ },
21
+ "skipFiles": {
22
+ "type": "array",
23
+ "description": "Files that should not be overwritten by AI generation",
24
+ "items": {
25
+ "type": "string"
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "required": ["serviceTypes"]
33
+ }
@@ -1,18 +0,0 @@
1
- // IMPORTANT: telemetry must be imported first to patch modules before they're loaded
2
- import '@crossdelta/telemetry'
3
-
4
- import { Hono } from 'hono'
5
-
6
- const port = Number(process.env.PORT || process.env.{{envKey}}_PORT) || 8080
7
- const app = new Hono()
8
-
9
- app.get('/health', (c) => {
10
- return c.json({ status: 'ok' })
11
- })
12
-
13
- Bun.serve({
14
- port,
15
- fetch: app.fetch,
16
- })
17
-
18
- console.log(`🚀 Service ready at http://localhost:${port}`)