@crossdelta/platform-sdk 0.21.13 → 0.21.14

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.
@@ -1,56 +1,82 @@
1
- import { join } from 'node:path'
2
1
  import {
3
- buildExternalUrls,
4
- buildIngressRules,
5
- buildInternalUrls,
6
- buildServicePortEnvs,
7
- buildServices,
8
- buildServiceUrlEnvs,
9
- discoverServices,
2
+ createDOKSCluster,
3
+ createImagePullSecret,
4
+ createNamespace,
5
+ deployK8sServices,
6
+ deployRuntime,
7
+ discoverServiceConfigs,
8
+ materializeStreams,
10
9
  } from '@crossdelta/infrastructure'
11
- import { App } from '@pulumi/digitalocean'
10
+ import * as contracts from '{{scope}}/contracts'
12
11
  import { Config, getStack } from '@pulumi/pulumi'
13
12
 
14
- const allServiceConfigs = discoverServices(join(__dirname, 'services'))
15
- const serviceConfigs = allServiceConfigs.filter((config) => !config.skip)
13
+ const stack = getStack()
16
14
  const cfg = new Config()
17
- const logtailToken = cfg.requireSecret('logtailToken')
18
15
  const registryCredentials = cfg.requireSecret('registryCredentials')
19
16
 
20
- const stack = getStack()
17
+ const namespace = `{{projectName}}-${stack}`
21
18
 
22
- const doAppName = `{{projectName}}-${stack}`
19
+ const { provider, kubeconfig, endpoint } = createDOKSCluster({
20
+ name: '{{projectName}}-cluster',
21
+ clusterName: '{{projectName}}-cluster',
22
+ region: 'fra1',
23
+ ha: false,
24
+ version: '1.32.2-do.1',
25
+ nodePool: {
26
+ name: 'default',
27
+ size: 's-2vcpu-4gb',
28
+ nodeCount: 2,
29
+ labels: { environment: stack },
30
+ },
31
+ tags: ['{{projectName}}', `env:${stack}`],
32
+ })
23
33
 
24
- const app = new App('{{projectName}}', {
25
- spec: {
26
- name: doAppName,
27
- region: 'fra',
34
+ createNamespace(provider, namespace, { environment: stack })
28
35
 
29
- alerts: [{ rule: 'DEPLOYMENT_FAILED' }, { rule: 'DOMAIN_FAILED' }],
36
+ const imagePullSecretName = 'ghcr-secret'
30
37
 
31
- features: ['buildpack-stack=ubuntu-22'],
38
+ createImagePullSecret(provider, namespace, imagePullSecretName, {
39
+ registry: 'ghcr.io',
40
+ username: 'github',
41
+ password: registryCredentials,
42
+ })
32
43
 
33
- envs: [
34
- ...buildServiceUrlEnvs(serviceConfigs),
35
- ...buildServicePortEnvs(serviceConfigs),
36
- ],
44
+ const runtime = deployRuntime(provider, namespace, {
45
+ nats: {
46
+ enabled: true,
47
+ config: {
48
+ replicas: 1,
49
+ jetstream: {
50
+ enabled: true,
51
+ storageSize: '1Gi',
52
+ storageClass: 'do-block-storage',
53
+ },
54
+ },
55
+ },
56
+ })
37
57
 
38
- services: buildServices({
39
- serviceConfigs,
40
- registryCredentials,
41
- logtailToken,
42
- }),
58
+ if (runtime.natsUrl) {
59
+ const natsDepends = runtime.natsRelease ? [runtime.natsRelease] : []
43
60
 
44
- ingress: {
45
- rules: buildIngressRules(serviceConfigs),
46
- },
61
+ materializeStreams(provider, namespace, {
62
+ natsUrl: runtime.natsUrl,
63
+ contracts,
64
+ dependsOn: natsDepends,
65
+ })
66
+ }
67
+
68
+ const serviceConfigs = discoverServiceConfigs('services').map((config) => ({
69
+ ...config,
70
+ env: {
71
+ ...config.env,
72
+ ...(runtime.natsUrl && { NATS_URL: runtime.natsUrl }),
47
73
  },
74
+ }))
75
+
76
+ deployK8sServices(provider, namespace, serviceConfigs, {
77
+ imagePullSecretName,
48
78
  })
49
79
 
50
- // Outputs
51
- export const appId = app.id
52
- export const appDefaultIngress = app.defaultIngress
53
- export const internalUrls = buildInternalUrls(serviceConfigs)
54
- export const serviceUrls = app.defaultIngress.apply((baseUrl) =>
55
- buildExternalUrls(serviceConfigs, baseUrl ?? ''),
56
- )
80
+ export const clusterEndpoint = endpoint
81
+ export const clusterKubeconfig = kubeconfig
82
+ export const natsInternalUrl = runtime.natsUrl
@@ -7,8 +7,8 @@
7
7
  "pulumi": "pulumi"
8
8
  },
9
9
  "dependencies": {
10
- "@crossdelta/cloudevents": "^0.7.21",
11
- "@crossdelta/infrastructure": "^0.11.6",
10
+ "@crossdelta/cloudevents": "^0.8.1",
11
+ "@crossdelta/infrastructure": "^0.11.7",
12
12
  "{{scope}}/contracts": "workspace:*",
13
13
  "@pulumi/digitalocean": "^4.55.0",
14
14
  "@pulumi/kubernetes": "^4.21.0",
@@ -19,8 +19,8 @@
19
19
  "clean": "rm -rf dist"
20
20
  },
21
21
  "dependencies": {
22
- "@crossdelta/cloudevents": "^0.7.21",
23
- "@crossdelta/infrastructure": "^0.11.6",
22
+ "@crossdelta/cloudevents": "^0.8.1",
23
+ "@crossdelta/infrastructure": "^0.11.7",
24
24
  "zod": "^4.0.0"
25
25
  },
26
26
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/platform-sdk",
3
- "version": "0.21.13",
3
+ "version": "0.21.14",
4
4
  "description": "Platform toolkit for event-driven microservices — keeping code and infrastructure in lockstep.",
5
5
  "keywords": [
6
6
  "cli",
@@ -118,7 +118,7 @@
118
118
  "@ai-sdk/anthropic": "^2.0.53",
119
119
  "@ai-sdk/openai": "^2.0.79",
120
120
  "@angular-devkit/core": "^21.0.0",
121
- "@crossdelta/cloudevents": "^0.7.21",
121
+ "@crossdelta/cloudevents": "^0.8.1",
122
122
  "@crossdelta/flowcore": "^0.1.2",
123
123
  "@crossdelta/shared": "^0.1.0",
124
124
  "@faker-js/faker": "^9.8.0",
@@ -145,7 +145,7 @@
145
145
  "zod": "^4.0.0"
146
146
  },
147
147
  "peerDependencies": {
148
- "@crossdelta/infrastructure": "^0.11.6",
148
+ "@crossdelta/infrastructure": "^0.11.7",
149
149
  "@nestjs/schematics": "^11.0.5",
150
150
  "turbo": "^2.0.0"
151
151
  },