@vibesdotdev/infra-core 0.0.1 → 1.0.0-rc.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/LICENSE +18 -0
- package/README.md +34 -63
- package/dist/bootstrap/seed.descriptor.d.ts +1 -1
- package/dist/bootstrap/seed.descriptor.d.ts.map +1 -1
- package/dist/bootstrap/seed.descriptor.js +1 -1
- package/dist/bootstrap/seed.descriptor.js.map +1 -1
- package/dist/bootstrap/seed.impl-shape.d.ts +1 -1
- package/dist/bootstrap/seed.impl-shape.d.ts.map +1 -1
- package/dist/bootstrap/seed.kind.d.ts +1 -3
- package/dist/bootstrap/seed.kind.d.ts.map +1 -1
- package/dist/bootstrap/seed.kind.js +17 -4
- package/dist/bootstrap/seed.kind.js.map +1 -1
- package/dist/bootstrap/seed.runner.d.ts +9 -2
- package/dist/bootstrap/seed.runner.d.ts.map +1 -1
- package/dist/bootstrap/seed.runner.js +37 -18
- package/dist/bootstrap/seed.runner.js.map +1 -1
- package/dist/capped-id.d.ts +19 -0
- package/dist/capped-id.d.ts.map +1 -0
- package/dist/capped-id.js +64 -0
- package/dist/capped-id.js.map +1 -0
- package/dist/cli/generate/artifact/artifact.cli-command.descriptor.d.ts +23 -0
- package/dist/cli/generate/artifact/artifact.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/generate/artifact/artifact.cli-command.descriptor.js +33 -0
- package/dist/cli/generate/artifact/artifact.cli-command.descriptor.js.map +1 -0
- package/dist/cli/generate/artifact/artifact.cli-command.impl.d.ts +24 -0
- package/dist/cli/generate/artifact/artifact.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/generate/artifact/artifact.cli-command.impl.js +73 -0
- package/dist/cli/generate/artifact/artifact.cli-command.impl.js.map +1 -0
- package/dist/cli/generate/context.d.ts +17 -0
- package/dist/cli/generate/context.d.ts.map +1 -0
- package/dist/cli/generate/context.js +24 -0
- package/dist/cli/generate/context.js.map +1 -0
- package/dist/cli/generate/generate/generate.cli-command.descriptor.d.ts +30 -0
- package/dist/cli/generate/generate/generate.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/generate/generate/generate.cli-command.descriptor.js +25 -0
- package/dist/cli/generate/generate/generate.cli-command.descriptor.js.map +1 -0
- package/dist/cli/generate/generate/generate.cli-command.impl.d.ts +25 -0
- package/dist/cli/generate/generate/generate.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/generate/generate/generate.cli-command.impl.js +64 -0
- package/dist/cli/generate/generate/generate.cli-command.impl.js.map +1 -0
- package/dist/cli/generate/generate-core.d.ts +51 -0
- package/dist/cli/generate/generate-core.d.ts.map +1 -0
- package/dist/cli/generate/generate-core.js +172 -0
- package/dist/cli/generate/generate-core.js.map +1 -0
- package/dist/cli/generate/index.d.ts +5 -0
- package/dist/cli/generate/index.d.ts.map +1 -0
- package/dist/cli/generate/index.js +5 -0
- package/dist/cli/generate/index.js.map +1 -0
- package/dist/credentials/resolve.d.ts +82 -22
- package/dist/credentials/resolve.d.ts.map +1 -1
- package/dist/credentials/resolve.js +251 -77
- package/dist/credentials/resolve.js.map +1 -1
- package/dist/deployment-budget.d.ts +319 -0
- package/dist/deployment-budget.d.ts.map +1 -0
- package/dist/deployment-budget.js +660 -0
- package/dist/deployment-budget.js.map +1 -0
- package/dist/deployment-environment.d.ts +30 -0
- package/dist/deployment-environment.d.ts.map +1 -0
- package/dist/deployment-environment.js +53 -0
- package/dist/deployment-environment.js.map +1 -0
- package/dist/deployment-graph.d.ts +185 -0
- package/dist/deployment-graph.d.ts.map +1 -0
- package/dist/deployment-graph.js +705 -0
- package/dist/deployment-graph.js.map +1 -0
- package/dist/deployment.d.ts +25 -4
- package/dist/deployment.d.ts.map +1 -1
- package/dist/deployment.js +105 -0
- package/dist/deployment.js.map +1 -1
- package/dist/doks/cloud/base.d.ts +49 -0
- package/dist/doks/cloud/base.d.ts.map +1 -0
- package/dist/doks/cloud/base.js +138 -0
- package/dist/doks/cloud/base.js.map +1 -0
- package/dist/doks/cloud/factory.d.ts +18 -0
- package/dist/doks/cloud/factory.d.ts.map +1 -0
- package/dist/doks/cloud/factory.js +22 -0
- package/dist/doks/cloud/factory.js.map +1 -0
- package/dist/doks/cloud/index.d.ts +5 -0
- package/dist/doks/cloud/index.d.ts.map +1 -0
- package/dist/doks/cloud/index.js +4 -0
- package/dist/doks/cloud/index.js.map +1 -0
- package/dist/doks/types.d.ts +95 -0
- package/dist/doks/types.d.ts.map +1 -0
- package/dist/doks/types.js +14 -0
- package/dist/doks/types.js.map +1 -0
- package/dist/generate/index.d.ts +29 -0
- package/dist/generate/index.d.ts.map +1 -0
- package/dist/generate/index.js +28 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/generate/infra-generate.plugin.d.ts +3 -0
- package/dist/generate/infra-generate.plugin.d.ts.map +1 -0
- package/dist/generate/infra-generate.plugin.js +23 -0
- package/dist/generate/infra-generate.plugin.js.map +1 -0
- package/dist/generate/plugin.d.ts +2 -0
- package/dist/generate/plugin.d.ts.map +1 -0
- package/dist/generate/plugin.js +2 -0
- package/dist/generate/plugin.js.map +1 -0
- package/dist/heartbeat/cron-heartbeat.d.ts +97 -0
- package/dist/heartbeat/cron-heartbeat.d.ts.map +1 -0
- package/dist/heartbeat/cron-heartbeat.js +200 -0
- package/dist/heartbeat/cron-heartbeat.js.map +1 -0
- package/dist/index.d.ts +37 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/dist/infra.plugin.d.ts +1 -1
- package/dist/infra.plugin.d.ts.map +1 -1
- package/dist/infra.plugin.js +64 -12
- package/dist/infra.plugin.js.map +1 -1
- package/dist/kinds/alerts.kind.d.ts +64 -25
- package/dist/kinds/alerts.kind.d.ts.map +1 -1
- package/dist/kinds/alerts.kind.js +43 -16
- package/dist/kinds/alerts.kind.js.map +1 -1
- package/dist/kinds/artifact.kind.d.ts +58 -10
- package/dist/kinds/artifact.kind.d.ts.map +1 -1
- package/dist/kinds/artifact.kind.js +26 -9
- package/dist/kinds/artifact.kind.js.map +1 -1
- package/dist/kinds/billing.kind.d.ts +88 -0
- package/dist/kinds/billing.kind.d.ts.map +1 -0
- package/dist/kinds/billing.kind.js +48 -0
- package/dist/kinds/billing.kind.js.map +1 -0
- package/dist/kinds/build-job.kind.d.ts +383 -0
- package/dist/kinds/build-job.kind.d.ts.map +1 -0
- package/dist/kinds/build-job.kind.js +218 -0
- package/dist/kinds/build-job.kind.js.map +1 -0
- package/dist/kinds/cache-byte-store.d.ts +23 -0
- package/dist/kinds/cache-byte-store.d.ts.map +1 -0
- package/dist/kinds/cache-byte-store.js +9 -0
- package/dist/kinds/cache-byte-store.js.map +1 -0
- package/dist/kinds/cache.kind.d.ts +38 -94
- package/dist/kinds/cache.kind.d.ts.map +1 -1
- package/dist/kinds/cache.kind.js +39 -50
- package/dist/kinds/cache.kind.js.map +1 -1
- package/dist/kinds/cluster.kind.d.ts +154 -0
- package/dist/kinds/cluster.kind.d.ts.map +1 -0
- package/dist/kinds/cluster.kind.js +99 -0
- package/dist/kinds/cluster.kind.js.map +1 -0
- package/dist/kinds/compute-source.kind.d.ts +155 -0
- package/dist/kinds/compute-source.kind.d.ts.map +1 -0
- package/dist/kinds/compute-source.kind.js +158 -0
- package/dist/kinds/compute-source.kind.js.map +1 -0
- package/dist/kinds/container-registry.kind.d.ts +62 -0
- package/dist/kinds/container-registry.kind.d.ts.map +1 -0
- package/dist/kinds/container-registry.kind.js +47 -0
- package/dist/kinds/container-registry.kind.js.map +1 -0
- package/dist/kinds/database-migrator.kind.d.ts +6 -0
- package/dist/kinds/database-migrator.kind.d.ts.map +1 -0
- package/dist/kinds/database-migrator.kind.js +28 -0
- package/dist/kinds/database-migrator.kind.js.map +1 -0
- package/dist/kinds/database.kind.d.ts +114 -93
- package/dist/kinds/database.kind.d.ts.map +1 -1
- package/dist/kinds/database.kind.js +93 -54
- package/dist/kinds/database.kind.js.map +1 -1
- package/dist/kinds/deployment-provider.kind.d.ts +5 -0
- package/dist/kinds/deployment-provider.kind.d.ts.map +1 -0
- package/dist/kinds/deployment-provider.kind.js +11 -0
- package/dist/kinds/deployment-provider.kind.js.map +1 -0
- package/dist/kinds/discovery.d.ts +5 -12
- package/dist/kinds/discovery.d.ts.map +1 -1
- package/dist/kinds/discovery.js +5 -17
- package/dist/kinds/discovery.js.map +1 -1
- package/dist/kinds/dns.kind.d.ts +162 -0
- package/dist/kinds/dns.kind.d.ts.map +1 -0
- package/dist/kinds/dns.kind.js +54 -0
- package/dist/kinds/dns.kind.js.map +1 -0
- package/dist/kinds/drift.kind.d.ts +115 -0
- package/dist/kinds/drift.kind.d.ts.map +1 -0
- package/dist/kinds/drift.kind.js +60 -0
- package/dist/kinds/drift.kind.js.map +1 -0
- package/dist/kinds/edge-hostname.kind.d.ts +124 -0
- package/dist/kinds/edge-hostname.kind.d.ts.map +1 -0
- package/dist/kinds/edge-hostname.kind.js +87 -0
- package/dist/kinds/edge-hostname.kind.js.map +1 -0
- package/dist/kinds/edge-tls.kind.d.ts +194 -0
- package/dist/kinds/edge-tls.kind.d.ts.map +1 -0
- package/dist/kinds/edge-tls.kind.js +58 -0
- package/dist/kinds/edge-tls.kind.js.map +1 -0
- package/dist/kinds/firewall.kind.d.ts +92 -0
- package/dist/kinds/firewall.kind.d.ts.map +1 -0
- package/dist/kinds/firewall.kind.js +59 -0
- package/dist/kinds/firewall.kind.js.map +1 -0
- package/dist/kinds/git-hosting.kind.d.ts +36 -38
- package/dist/kinds/git-hosting.kind.d.ts.map +1 -1
- package/dist/kinds/git-hosting.kind.js +23 -34
- package/dist/kinds/git-hosting.kind.js.map +1 -1
- package/dist/kinds/index.d.ts +41 -15
- package/dist/kinds/index.d.ts.map +1 -1
- package/dist/kinds/index.js +40 -14
- package/dist/kinds/index.js.map +1 -1
- package/dist/kinds/inventory.kind.d.ts +245 -0
- package/dist/kinds/inventory.kind.d.ts.map +1 -0
- package/dist/kinds/inventory.kind.js +243 -0
- package/dist/kinds/inventory.kind.js.map +1 -0
- package/dist/kinds/load-balancer.kind.d.ts +135 -0
- package/dist/kinds/load-balancer.kind.d.ts.map +1 -0
- package/dist/kinds/load-balancer.kind.js +71 -0
- package/dist/kinds/load-balancer.kind.js.map +1 -0
- package/dist/kinds/logs.kind.d.ts +74 -3
- package/dist/kinds/logs.kind.d.ts.map +1 -1
- package/dist/kinds/logs.kind.js +26 -17
- package/dist/kinds/logs.kind.js.map +1 -1
- package/dist/kinds/nfs.kind.d.ts +67 -0
- package/dist/kinds/nfs.kind.d.ts.map +1 -0
- package/dist/kinds/nfs.kind.js +45 -0
- package/dist/kinds/nfs.kind.js.map +1 -0
- package/dist/kinds/node-pool.kind.d.ts +134 -0
- package/dist/kinds/node-pool.kind.d.ts.map +1 -0
- package/dist/kinds/node-pool.kind.js +88 -0
- package/dist/kinds/node-pool.kind.js.map +1 -0
- package/dist/kinds/object-storage.kind.d.ts +50 -24
- package/dist/kinds/object-storage.kind.d.ts.map +1 -1
- package/dist/kinds/object-storage.kind.js +40 -23
- package/dist/kinds/object-storage.kind.js.map +1 -1
- package/dist/kinds/observability.kind.d.ts +104 -6
- package/dist/kinds/observability.kind.d.ts.map +1 -1
- package/dist/kinds/observability.kind.js +67 -9
- package/dist/kinds/observability.kind.js.map +1 -1
- package/dist/kinds/package-registry.kind.d.ts +141 -35
- package/dist/kinds/package-registry.kind.d.ts.map +1 -1
- package/dist/kinds/package-registry.kind.js +55 -25
- package/dist/kinds/package-registry.kind.js.map +1 -1
- package/dist/kinds/queue.kind.d.ts +67 -63
- package/dist/kinds/queue.kind.d.ts.map +1 -1
- package/dist/kinds/queue.kind.js +55 -33
- package/dist/kinds/queue.kind.js.map +1 -1
- package/dist/kinds/read-descriptor.d.ts +15 -0
- package/dist/kinds/read-descriptor.d.ts.map +1 -0
- package/dist/kinds/read-descriptor.js +11 -0
- package/dist/kinds/read-descriptor.js.map +1 -0
- package/dist/kinds/rum.kind.d.ts +36 -6
- package/dist/kinds/rum.kind.d.ts.map +1 -1
- package/dist/kinds/rum.kind.js +6 -7
- package/dist/kinds/rum.kind.js.map +1 -1
- package/dist/kinds/sandbox.kind.d.ts +136 -40
- package/dist/kinds/sandbox.kind.d.ts.map +1 -1
- package/dist/kinds/sandbox.kind.js +82 -43
- package/dist/kinds/sandbox.kind.js.map +1 -1
- package/dist/kinds/select-compute-source.d.ts +72 -0
- package/dist/kinds/select-compute-source.d.ts.map +1 -0
- package/dist/kinds/select-compute-source.js +170 -0
- package/dist/kinds/select-compute-source.js.map +1 -0
- package/dist/kinds/service-release.kind.d.ts +771 -0
- package/dist/kinds/service-release.kind.d.ts.map +1 -0
- package/dist/kinds/service-release.kind.js +676 -0
- package/dist/kinds/service-release.kind.js.map +1 -0
- package/dist/kinds/spend-guard.kind.d.ts +41 -0
- package/dist/kinds/spend-guard.kind.d.ts.map +1 -0
- package/dist/kinds/spend-guard.kind.js +140 -0
- package/dist/kinds/spend-guard.kind.js.map +1 -0
- package/dist/kinds/utilization.kind.d.ts +88 -0
- package/dist/kinds/utilization.kind.d.ts.map +1 -0
- package/dist/kinds/utilization.kind.js +62 -0
- package/dist/kinds/utilization.kind.js.map +1 -0
- package/dist/kinds/volume.kind.d.ts +54 -0
- package/dist/kinds/volume.kind.d.ts.map +1 -0
- package/dist/kinds/volume.kind.js +39 -0
- package/dist/kinds/volume.kind.js.map +1 -0
- package/dist/kinds/vpc.kind.d.ts +61 -0
- package/dist/kinds/vpc.kind.d.ts.map +1 -0
- package/dist/kinds/vpc.kind.js +51 -0
- package/dist/kinds/vpc.kind.js.map +1 -0
- package/dist/kinds/web-app.kind.d.ts +118 -45
- package/dist/kinds/web-app.kind.d.ts.map +1 -1
- package/dist/kinds/web-app.kind.js +69 -42
- package/dist/kinds/web-app.kind.js.map +1 -1
- package/dist/kinds/worker.kind.d.ts +129 -188
- package/dist/kinds/worker.kind.d.ts.map +1 -1
- package/dist/kinds/worker.kind.js +45 -123
- package/dist/kinds/worker.kind.js.map +1 -1
- package/dist/schemas/database-migration.d.ts +173 -0
- package/dist/schemas/database-migration.d.ts.map +1 -0
- package/dist/schemas/database-migration.js +88 -0
- package/dist/schemas/database-migration.js.map +1 -0
- package/dist/schemas/deployment-environment.d.ts +11 -0
- package/dist/schemas/deployment-environment.d.ts.map +1 -0
- package/dist/schemas/deployment-environment.js +9 -0
- package/dist/schemas/deployment-environment.js.map +1 -0
- package/dist/schemas/deployment-provider.d.ts +383 -0
- package/dist/schemas/deployment-provider.d.ts.map +1 -0
- package/dist/schemas/deployment-provider.js +211 -0
- package/dist/schemas/deployment-provider.js.map +1 -0
- package/dist/schemas/log-stream.d.ts +27 -0
- package/dist/schemas/log-stream.d.ts.map +1 -0
- package/dist/schemas/log-stream.js +31 -0
- package/dist/schemas/log-stream.js.map +1 -0
- package/dist/schemas/spend-guard.d.ts +155 -0
- package/dist/schemas/spend-guard.d.ts.map +1 -0
- package/dist/schemas/spend-guard.js +61 -0
- package/dist/schemas/spend-guard.js.map +1 -0
- package/dist/schemas.d.ts +195 -20
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +151 -31
- package/dist/schemas.js.map +1 -1
- package/dist/service.d.ts +87 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +199 -0
- package/dist/service.js.map +1 -0
- package/dist/settle-work.d.ts +20 -0
- package/dist/settle-work.d.ts.map +1 -0
- package/dist/settle-work.js +22 -0
- package/dist/settle-work.js.map +1 -0
- package/dist/web-app-projection.d.ts +208 -0
- package/dist/web-app-projection.d.ts.map +1 -0
- package/dist/web-app-projection.js +95 -0
- package/dist/web-app-projection.js.map +1 -0
- package/package.json +123 -40
- package/SPEC.md +0 -169
- package/src/bootstrap/index.ts +0 -15
- package/src/bootstrap/seed.descriptor.ts +0 -24
- package/src/bootstrap/seed.impl-shape.ts +0 -5
- package/src/bootstrap/seed.kind.ts +0 -26
- package/src/bootstrap/seed.runner.ts +0 -87
- package/src/credentials/resolve.ts +0 -205
- package/src/deployment.ts +0 -57
- package/src/index.ts +0 -149
- package/src/infra.plugin.ts +0 -54
- package/src/kinds/alerts.kind.ts +0 -164
- package/src/kinds/artifact.kind.ts +0 -96
- package/src/kinds/cache.kind.ts +0 -104
- package/src/kinds/database.kind.ts +0 -120
- package/src/kinds/discovery.ts +0 -26
- package/src/kinds/git-hosting.kind.ts +0 -100
- package/src/kinds/index.ts +0 -139
- package/src/kinds/logs.kind.ts +0 -104
- package/src/kinds/object-storage.kind.ts +0 -101
- package/src/kinds/observability.kind.ts +0 -178
- package/src/kinds/package-registry.kind.ts +0 -95
- package/src/kinds/queue.kind.ts +0 -102
- package/src/kinds/rum.kind.ts +0 -135
- package/src/kinds/sandbox.kind.ts +0 -115
- package/src/kinds/web-app.kind.ts +0 -103
- package/src/kinds/worker.kind.ts +0 -203
- package/src/schemas.ts +0 -127
package/SPEC.md
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
# @vibesdotdev/infra-core
|
|
2
|
-
|
|
3
|
-
Provider-agnostic contract for deployable infrastructure. Defines the runtime
|
|
4
|
-
kinds, descriptor schemas, and deployment factories that adapter packages and
|
|
5
|
-
consuming apps share. Adapter packages
|
|
6
|
-
([`infra-cloudflare`](../infra-cloudflare/SPEC.md),
|
|
7
|
-
[`infra-doks`](../infra-doks/SPEC.md)) implement provider-specific behavior
|
|
8
|
-
against these kinds; consumed by per-app `deployment.config.ts` files, by
|
|
9
|
-
`*.infra.ts` resource declarations under workspace `infra/`, by
|
|
10
|
-
[`secrets`](../secrets/SPEC.md) for env-requirement resolution, and by
|
|
11
|
-
[`deploy`](../deploy/SPEC.md) for orchestration.
|
|
12
|
-
|
|
13
|
-
## Owns
|
|
14
|
-
|
|
15
|
-
- **Runtime kinds:** `infra/web-app`, `infra/worker`, `infra/database`,
|
|
16
|
-
`infra/queue`, `infra/cache`, `infra/object-storage`, `infra/sandbox`,
|
|
17
|
-
`infra/git-hosting`, `infra/package-registry`.
|
|
18
|
-
- **Plugin descriptors registered by the plugin:** `infraPlugin` (id `infra`)
|
|
19
|
-
registers all 9 kinds with `discoveryPattern: "**/*.infra.ts"` and
|
|
20
|
-
pass-through default implementations exposing the validated descriptor as
|
|
21
|
-
`config`.
|
|
22
|
-
- **Schemas** (`./schemas`): atomic Zod schemas — provider enum, runtime enum,
|
|
23
|
-
origin, build, env requirement, dependency, upstream — and the assembled
|
|
24
|
-
`appDeploymentSchema`. Single source of truth for cross-cutting shapes;
|
|
25
|
-
kind descriptor schemas compose from these primitives.
|
|
26
|
-
- **Kind descriptors** (`./kinds`): one file per kind, each defining a Zod
|
|
27
|
-
descriptor schema (composed from `./schemas`) and a pass-through default
|
|
28
|
-
`Implementation` class wired through `createRuntimeKind`.
|
|
29
|
-
- **Deployment factories** (`./deployment`): `createAppDeployment`,
|
|
30
|
-
`createDeploymentOrigin`, `createDeploymentEnvRequirement`,
|
|
31
|
-
`createDeploymentDependency`, `getPrimaryOrigin`, `getUpstreamOriginEnv`.
|
|
32
|
-
These produce the validated objects authored in per-app
|
|
33
|
-
`deployment.config.ts` files.
|
|
34
|
-
|
|
35
|
-
## Does not own
|
|
36
|
-
|
|
37
|
-
- Cloudflare Workers / Workers / Queues / R2 / KV implementations →
|
|
38
|
-
[`infra-cloudflare`](../infra-cloudflare/SPEC.md).
|
|
39
|
-
- DigitalOcean App Platform / DOKS / Spaces / Managed DB / Managed Redis
|
|
40
|
-
implementations → [`infra-doks`](../infra-doks/SPEC.md).
|
|
41
|
-
- Standalone Kubernetes / Docker / DO Droplet implementations — no adapter
|
|
42
|
-
package exists yet (see migration debt).
|
|
43
|
-
- Deployment orchestration, manifest generation, env materialization, and the
|
|
44
|
-
`infra/` workspace tree (`infra/manifest.ts`, `infra/generate.ts`,
|
|
45
|
-
`infra/resources/`) → [`deploy`](../deploy/SPEC.md). Per-app
|
|
46
|
-
`deployment.config.ts` files live in `apps/<app>-web/`.
|
|
47
|
-
- Env-requirement resolution against descriptors →
|
|
48
|
-
[`secrets`](../secrets/SPEC.md).
|
|
49
|
-
- AI inference selection. Inference is an `ai/provider` + `ai/adapter`
|
|
50
|
-
concern — see [`ai`](../ai/SPEC.md) and
|
|
51
|
-
[`ai-providers`](../ai-providers/SPEC.md). No `infra/inference` kind exists
|
|
52
|
-
or should be added.
|
|
53
|
-
|
|
54
|
-
## Hard rules
|
|
55
|
-
|
|
56
|
-
- Core never imports adapter packages. Dependencies are exactly
|
|
57
|
-
`@vibesdotdev/runtime` + `zod`.
|
|
58
|
-
- Shared shapes live in `./schemas`. Kind descriptor schemas compose from
|
|
59
|
-
`./schemas`. Do not redeclare an env-requirement schema or any other
|
|
60
|
-
primitive inside a kind file.
|
|
61
|
-
- New deployable resource types are added as new kinds in `src/kinds/`.
|
|
62
|
-
Provider-specific concepts (Wrangler bindings, Helm values, Spaces CORS,
|
|
63
|
-
CF Sandbox outbound proxy specifics, etc.) belong in adapter packages
|
|
64
|
-
registering implementations against the existing kinds.
|
|
65
|
-
- Inference is not an infra kind. New inference strategies (CF Unified
|
|
66
|
-
Inference, Agents bindings, etc.) are added as `ai/provider` descriptors +
|
|
67
|
-
adapters in [`ai-providers`](../ai-providers/SPEC.md).
|
|
68
|
-
- Default implementations are inert pass-throughs that expose the validated
|
|
69
|
-
descriptor as `config`. Real provider behavior must come from an adapter
|
|
70
|
-
package registering an implementation for the same kind.
|
|
71
|
-
- Kind discovery pattern is `**/*.infra.ts` for every kind. Apps and the
|
|
72
|
-
`infra/` workspace declare concrete resources in `*.infra.ts` files; do
|
|
73
|
-
not change the pattern per kind.
|
|
74
|
-
- Pure TypeScript only. No `$env`, `$server`, `$app`, `@sveltejs/kit`,
|
|
75
|
-
Svelte, Drizzle, or filesystem APIs in this package.
|
|
76
|
-
- `deploymentProviderSchema` enumerates exactly the providers backed by an
|
|
77
|
-
active adapter package. Adding a provider value without a corresponding
|
|
78
|
-
adapter is a contract lie — add the adapter or omit the value.
|
|
79
|
-
- `appDeploymentSchema` cross-validates provider against runtime and origin
|
|
80
|
-
hostnames (e.g. `cloudflare-workers` requires `edge`; `digitalocean-app`
|
|
81
|
-
requires `node` or `worker`). Nonsense combinations fail at parse time,
|
|
82
|
-
not deploy time.
|
|
83
|
-
|
|
84
|
-
## Migration debt (completed)
|
|
85
|
-
|
|
86
|
-
- [x] `envRequirementSchema` is locally redeclared in
|
|
87
|
-
`src/kinds/web-app.kind.ts`, `src/kinds/worker.kind.ts`, and
|
|
88
|
-
`src/kinds/sandbox.kind.ts` instead of imported from `./schemas`.
|
|
89
|
-
**Resolution:** Kinds now import `deploymentEnvRequirementSchema` from `./schemas`.
|
|
90
|
-
All kind files use `import { z } from 'zod/v4'` style for consistency.
|
|
91
|
-
- [x] `package.json#exports` includes `"./kinds/*": "./src/kinds/*.ts"`.
|
|
92
|
-
**Resolution:** Wildcard removed. All 26 consumers updated to use `./kinds`
|
|
93
|
-
aggregate subpath instead of deep imports.
|
|
94
|
-
- [x] `deploymentProviderSchema` declares `digitalocean-droplet`,
|
|
95
|
-
`digitalocean-kubernetes`, `kubernetes`, and `docker`, but only
|
|
96
|
-
`digitalocean-app` (via `infra-doks`) and `cloudflare-workers` (via
|
|
97
|
-
`infra-cloudflare`) have active adapter implementations.
|
|
98
|
-
**Resolution:** Trimmed to only `cloudflare-workers` and `digitalocean-app`.
|
|
99
|
-
- [x] `appDeploymentSchema` does not cross-validate provider against runtime.
|
|
100
|
-
**Resolution:** Added `.refine()` enforcing provider × runtime matrix:
|
|
101
|
-
- `cloudflare-workers`: `edge`, `worker`
|
|
102
|
-
- `digitalocean-app`: `node`, `worker`
|
|
103
|
-
- [x] `discoveryPattern` and `extractStem` are duplicated identically across all
|
|
104
|
-
9 kind files.
|
|
105
|
-
**Resolution:** Extracted shared helper in `src/kinds/discovery.ts` with
|
|
106
|
-
`INFRA_DISCOVERY_PATTERN` constant and `extractStem()` function. All 7
|
|
107
|
-
kind files now import and reuse.
|
|
108
|
-
- [x] `WebAppDescriptor` and `appDeploymentSchema` describe overlapping concepts
|
|
109
|
-
(`appDir`, `outputDir`, `runtime`, `env`).
|
|
110
|
-
**Resolution:** The parallel surfaces are **intentional**:
|
|
111
|
-
- `WebAppDescriptor` (runtime-discovered resource) lives at `infra/web-app`
|
|
112
|
-
kind with `adapter`, `domain`, `env`, etc. Used by runtime discovery.
|
|
113
|
-
- `appDeploymentSchema` (authored deployment config) lives in `./schemas` and
|
|
114
|
-
is used by `deployment.config.ts` files with `provider`, `build`, `origins`,
|
|
115
|
-
etc. Both shapes reference similar fields but serve different consumers.
|
|
116
|
-
No merging; keep parallel with potential future composition via shared
|
|
117
|
-
fragment schemas if divergence becomes problematic.
|
|
118
|
-
|
|
119
|
-
## Migration debt
|
|
120
|
-
|
|
121
|
-
- [x] **`adapter` discriminator → `config` field migration.** All 7 original
|
|
122
|
-
infra kinds declare `adapter: z.string()` as a top-level discriminator field.
|
|
123
|
-
This field is not in `RuntimeDescriptorSchema` and `createRuntimeAsset` could not
|
|
124
|
-
validate it. Every infra kind has moved `adapter` and all adapter-specific
|
|
125
|
-
fields into a `config` object validated against the kind's registered
|
|
126
|
-
`descriptorSchema`. **Affected kinds:** `infra/web-app`, `infra/worker`,
|
|
127
|
-
`infra/database`, `infra/queue`, `infra/cache`, `infra/object-storage`,
|
|
128
|
-
`infra/sandbox`, `infra/git-hosting`, `infra/package-registry`.
|
|
129
|
-
- [x] `infra/web-app`: added `WebAppConfigSchema` union
|
|
130
|
-
(cloudflare-workers, digitalocean-apps)
|
|
131
|
-
- [x] `infra/worker`: added `WorkerConfigSchema` union
|
|
132
|
-
(doks-deployment, cloudflare-workers)
|
|
133
|
-
- [x] `infra/database`: added `DatabaseConfigSchema` union
|
|
134
|
-
(doks-statefulset, do-managed-postgres, turso)
|
|
135
|
-
- [x] `infra/queue`: added `QueueConfigSchema` union
|
|
136
|
-
(doks-statefulset, cloudflare-queues)
|
|
137
|
-
- [x] `infra/cache`: added `CacheConfigSchema` union
|
|
138
|
-
(do-managed-redis, cloudflare-kv, doks-redis)
|
|
139
|
-
- [x] `infra/object-storage`: added `ObjectStorageConfigSchema` union
|
|
140
|
-
(do-spaces, cloudflare-r2)
|
|
141
|
-
- [x] `infra/sandbox`: already had all variants (cloudflare-sandbox, docker,
|
|
142
|
-
digitalocean-droplet)
|
|
143
|
-
- [x] `infra/git-hosting`: added `GitHostingConfigSchema` union (gitea-doks)
|
|
144
|
-
- [x] `infra/package-registry`: added `PackageRegistryConfigSchema` union
|
|
145
|
-
(verdaccio-doks)
|
|
146
|
-
|
|
147
|
-
## Public entrypoints
|
|
148
|
-
|
|
149
|
-
`.`, `./schemas`, `./kinds`, `./deployment`, `./plugin`.
|
|
150
|
-
|
|
151
|
-
Wildcard / migration-era subpaths: `./kinds/*` — do not normalize new code
|
|
152
|
-
against this.
|
|
153
|
-
|
|
154
|
-
## Verification
|
|
155
|
-
|
|
156
|
-
`bun test` from `packages/infra-core`. Covers all 9 schemas (accept-valid +
|
|
157
|
-
reject-invalid), all 9 kind descriptor structures, plugin registration shape
|
|
158
|
-
(id, kinds count, kind IDs, discovery pattern, no dependencies, no lifecycle
|
|
159
|
-
hooks), and all 6 factory functions. `bun --bun tsc -p tsconfig.json
|
|
160
|
-
--noEmit` is the type gate.
|
|
161
|
-
|
|
162
|
-
## Links
|
|
163
|
-
|
|
164
|
-
- [infra-cloudflare/SPEC.md](../infra-cloudflare/SPEC.md)
|
|
165
|
-
- [infra-doks/SPEC.md](../infra-doks/SPEC.md)
|
|
166
|
-
- [deploy/SPEC.md](../deploy/SPEC.md)
|
|
167
|
-
- [secrets/SPEC.md](../secrets/SPEC.md)
|
|
168
|
-
- [runtime/SPEC.md](../runtime/SPEC.md)
|
|
169
|
-
- [ai/SPEC.md](../ai/SPEC.md), [ai-providers/SPEC.md](../ai-providers/SPEC.md)
|
package/src/bootstrap/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { bootstrapSeedKind } from './seed.kind.ts';
|
|
2
|
-
export {
|
|
3
|
-
bootstrapSeedConditionSchema,
|
|
4
|
-
bootstrapSeedDescriptorSchema,
|
|
5
|
-
bootstrapSeedModeSchema,
|
|
6
|
-
type BootstrapSeedCondition,
|
|
7
|
-
type BootstrapSeedDescriptor,
|
|
8
|
-
type BootstrapSeedMode
|
|
9
|
-
} from './seed.descriptor.ts';
|
|
10
|
-
export type { BootstrapSeedImpl } from './seed.impl-shape.ts';
|
|
11
|
-
export {
|
|
12
|
-
runBootstrapSeeds,
|
|
13
|
-
type BootstrapSeedRunOptions,
|
|
14
|
-
type BootstrapSeedRunResult
|
|
15
|
-
} from './seed.runner.ts';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export const bootstrapSeedModeSchema = z.enum(['cold-start', 'deploy']);
|
|
4
|
-
export type BootstrapSeedMode = z.infer<typeof bootstrapSeedModeSchema>;
|
|
5
|
-
|
|
6
|
-
export const bootstrapSeedConditionSchema = z.discriminatedUnion('kind', [
|
|
7
|
-
z.object({ kind: z.literal('always') }),
|
|
8
|
-
z.object({
|
|
9
|
-
kind: z.literal('env-keys-present'),
|
|
10
|
-
keys: z.array(z.string().min(1)).min(1)
|
|
11
|
-
})
|
|
12
|
-
]);
|
|
13
|
-
export type BootstrapSeedCondition = z.infer<typeof bootstrapSeedConditionSchema>;
|
|
14
|
-
|
|
15
|
-
export const bootstrapSeedDescriptorSchema = z.object({
|
|
16
|
-
kind: z.literal('bootstrap/seed'),
|
|
17
|
-
id: z.string().min(1),
|
|
18
|
-
description: z.string().optional(),
|
|
19
|
-
executeOn: z.array(bootstrapSeedModeSchema).min(1),
|
|
20
|
-
condition: bootstrapSeedConditionSchema.optional(),
|
|
21
|
-
priority: z.number().int().optional()
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export type BootstrapSeedDescriptor = z.infer<typeof bootstrapSeedDescriptorSchema>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { RuntimeDescriptor, RuntimeKindDescriptor } from '@vibesdotdev/runtime/schemas/kind';
|
|
2
|
-
import {
|
|
3
|
-
bootstrapSeedDescriptorSchema,
|
|
4
|
-
type BootstrapSeedDescriptor
|
|
5
|
-
} from './seed.descriptor.ts';
|
|
6
|
-
import type { BootstrapSeedImpl } from './seed.impl-shape.ts';
|
|
7
|
-
|
|
8
|
-
class UnregisteredBootstrapSeed implements BootstrapSeedImpl {
|
|
9
|
-
constructor(_descriptor: RuntimeDescriptor) {}
|
|
10
|
-
async run(): Promise<void> {
|
|
11
|
-
// No-op when no impl loader is registered for this descriptor id.
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const bootstrapSeedKind: RuntimeKindDescriptor<
|
|
16
|
-
BootstrapSeedDescriptor,
|
|
17
|
-
BootstrapSeedImpl,
|
|
18
|
-
never
|
|
19
|
-
> = {
|
|
20
|
-
id: 'bootstrap/seed',
|
|
21
|
-
descriptorSchema: bootstrapSeedDescriptorSchema,
|
|
22
|
-
defaultImplementation: UnregisteredBootstrapSeed as unknown as new (
|
|
23
|
-
descriptor: RuntimeDescriptor
|
|
24
|
-
) => BootstrapSeedImpl,
|
|
25
|
-
contexts: []
|
|
26
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { VibesRuntime } from '@vibesdotdev/runtime';
|
|
2
|
-
import { getLogger } from '@vibesdotdev/logging';
|
|
3
|
-
import type {
|
|
4
|
-
BootstrapSeedCondition,
|
|
5
|
-
BootstrapSeedDescriptor,
|
|
6
|
-
BootstrapSeedMode
|
|
7
|
-
} from './seed.descriptor.ts';
|
|
8
|
-
import type { BootstrapSeedImpl } from './seed.impl-shape.ts';
|
|
9
|
-
|
|
10
|
-
const log = getLogger('infra.bootstrap.seed');
|
|
11
|
-
|
|
12
|
-
export interface BootstrapSeedRunResult {
|
|
13
|
-
ran: string[];
|
|
14
|
-
skipped: Array<{ id: string; reason: string }>;
|
|
15
|
-
failed: Array<{ id: string; error: string }>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface BootstrapSeedRunOptions {
|
|
19
|
-
env: Record<string, string | undefined>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function runBootstrapSeeds(
|
|
23
|
-
runtime: VibesRuntime,
|
|
24
|
-
mode: BootstrapSeedMode,
|
|
25
|
-
options: BootstrapSeedRunOptions
|
|
26
|
-
): Promise<BootstrapSeedRunResult> {
|
|
27
|
-
const allDescriptors = runtime
|
|
28
|
-
.assets('bootstrap/seed')
|
|
29
|
-
.descriptors() as unknown as readonly BootstrapSeedDescriptor[];
|
|
30
|
-
|
|
31
|
-
const result: BootstrapSeedRunResult = { ran: [], skipped: [], failed: [] };
|
|
32
|
-
const runnable: BootstrapSeedDescriptor[] = [];
|
|
33
|
-
|
|
34
|
-
for (const descriptor of allDescriptors) {
|
|
35
|
-
if (!descriptor.executeOn.includes(mode)) {
|
|
36
|
-
result.skipped.push({
|
|
37
|
-
id: descriptor.id,
|
|
38
|
-
reason: `mode ${mode} not in executeOn`
|
|
39
|
-
});
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (!evaluateCondition(descriptor.condition, options.env)) {
|
|
43
|
-
result.skipped.push({
|
|
44
|
-
id: descriptor.id,
|
|
45
|
-
reason: 'condition not met'
|
|
46
|
-
});
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
runnable.push(descriptor);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
runnable.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
|
|
53
|
-
|
|
54
|
-
for (const descriptor of runnable) {
|
|
55
|
-
try {
|
|
56
|
-
const impl = (await runtime
|
|
57
|
-
.query('bootstrap/seed')
|
|
58
|
-
.withId(descriptor.id)
|
|
59
|
-
.resolve()) as BootstrapSeedImpl;
|
|
60
|
-
await impl.run(runtime, options.env);
|
|
61
|
-
result.ran.push(descriptor.id);
|
|
62
|
-
log.info('bootstrap seed completed', {
|
|
63
|
-
id: descriptor.id,
|
|
64
|
-
mode,
|
|
65
|
-
priority: descriptor.priority ?? 100
|
|
66
|
-
});
|
|
67
|
-
} catch (err) {
|
|
68
|
-
const error = err instanceof Error ? err.message : String(err);
|
|
69
|
-
result.failed.push({ id: descriptor.id, error });
|
|
70
|
-
log.error('bootstrap seed failed', { id: descriptor.id, mode, error });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function evaluateCondition(
|
|
78
|
-
condition: BootstrapSeedCondition | undefined,
|
|
79
|
-
env: Record<string, string | undefined>
|
|
80
|
-
): boolean {
|
|
81
|
-
if (!condition) return true;
|
|
82
|
-
if (condition.kind === 'always') return true;
|
|
83
|
-
if (condition.kind === 'env-keys-present') {
|
|
84
|
-
return condition.keys.every((key) => Boolean(env[key]));
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider-agnostic credential resolution for infra/* adapters.
|
|
3
|
-
*
|
|
4
|
-
* Routes through the `secrets/store` runtime kind so every adapter
|
|
5
|
-
* (alerts, RUM, observability, …) reads from the same credential chain
|
|
6
|
-
* the rest of the platform uses. The chain (highest precedence first):
|
|
7
|
-
*
|
|
8
|
-
* 1. process.env (CI / explicit overrides)
|
|
9
|
-
* 2. The tier-resolved secrets/store implementation
|
|
10
|
-
* - local tier → encrypted-local → env-file
|
|
11
|
-
* - production → cloudflare-secrets-store → cloudflare-api
|
|
12
|
-
*
|
|
13
|
-
* Adapters declare the secret KEY NAMES (e.g. CLOUDFLARE_API_TOKEN) on
|
|
14
|
-
* their descriptor's `adapterConfig` and use this helper to resolve
|
|
15
|
-
* the values. The helper supports `keyCandidates` for fallback chains
|
|
16
|
-
* (e.g. prefer a scoped CLOUDFLARE_NOTIFICATIONS_API_TOKEN, fall back
|
|
17
|
-
* to the broad CLOUDFLARE_API_TOKEN).
|
|
18
|
-
*
|
|
19
|
-
* Why a helper instead of inlining the secrets/store query: provider
|
|
20
|
-
* adapters live in different packages and shouldn't all duplicate the
|
|
21
|
-
* tier-walk + env-overlay logic. Keeping it in infra-core makes the
|
|
22
|
-
* abstraction explicit ("infra/* adapters route credentials through
|
|
23
|
-
* vibes secrets") and gives us one place to evolve the chain (e.g.
|
|
24
|
-
* adding 1Password CLI as a backend).
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
28
|
-
|
|
29
|
-
export type EnvironmentTier = 'local' | 'dev' | 'staging' | 'production';
|
|
30
|
-
|
|
31
|
-
export interface ResolveAdapterCredentialOptions {
|
|
32
|
-
/**
|
|
33
|
-
* Ordered list of candidate keys. First one that resolves to a
|
|
34
|
-
* non-empty value wins. Useful for scoped → fallback patterns:
|
|
35
|
-
* ['CLOUDFLARE_NOTIFICATIONS_API_TOKEN', 'CLOUDFLARE_API_TOKEN']
|
|
36
|
-
*/
|
|
37
|
-
keyCandidates: readonly string[];
|
|
38
|
-
/**
|
|
39
|
-
* Environment name to read from the secrets store (default: 'local').
|
|
40
|
-
* Maps onto vault.environments[name] in encrypted-local.
|
|
41
|
-
*/
|
|
42
|
-
environment?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Tier hint for runtime store selection. Defaults to inferring from
|
|
45
|
-
* the environment name when it matches a known tier; falls back to
|
|
46
|
-
* 'local' otherwise.
|
|
47
|
-
*/
|
|
48
|
-
tier?: EnvironmentTier;
|
|
49
|
-
/**
|
|
50
|
-
* Whether to consult process.env first. Defaults true — CI/CD and
|
|
51
|
-
* explicit shell overrides should win. Pass false to force
|
|
52
|
-
* store-only resolution.
|
|
53
|
-
*/
|
|
54
|
-
includeProcessEnv?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Optional human-readable name for the credential, used in error
|
|
57
|
-
* messages when no candidate resolves (e.g. "Cloudflare API token").
|
|
58
|
-
*/
|
|
59
|
-
humanName?: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface ResolvedAdapterCredential {
|
|
63
|
-
/** The KEY that resolved (one of keyCandidates). Useful for audit. */
|
|
64
|
-
key: string;
|
|
65
|
-
/** The resolved secret value. Never logged. */
|
|
66
|
-
value: string;
|
|
67
|
-
/** Where the value came from: 'process.env' or the store backend id. */
|
|
68
|
-
source: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface SecretsStoreImplShape {
|
|
72
|
-
id?: string;
|
|
73
|
-
get?(environment: string, key: string): Promise<string | undefined>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
interface SecretsStoreDescriptorShape {
|
|
77
|
-
id: string;
|
|
78
|
-
priority?: number;
|
|
79
|
-
tiers?: readonly EnvironmentTier[] | EnvironmentTier[];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Tier-aware backend selection. Mirrors the secrets/store kind's own
|
|
84
|
-
* resolver (`packages/secrets/src/kinds/store.kind.ts`) so callers
|
|
85
|
-
* don't need to import internal helpers.
|
|
86
|
-
*/
|
|
87
|
-
function pickBackend(
|
|
88
|
-
descriptors: SecretsStoreDescriptorShape[],
|
|
89
|
-
tier: EnvironmentTier
|
|
90
|
-
): SecretsStoreDescriptorShape | undefined {
|
|
91
|
-
if (descriptors.length === 0) return undefined;
|
|
92
|
-
const matches = descriptors.filter((d) => (d.tiers ?? []).includes(tier));
|
|
93
|
-
const pool = matches.length > 0 ? matches : descriptors;
|
|
94
|
-
pool.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
95
|
-
return pool[0];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function inferTier(environment: string, override?: EnvironmentTier): EnvironmentTier {
|
|
99
|
-
if (override) return override;
|
|
100
|
-
if (environment === 'local' || environment === 'dev' || environment === 'staging' || environment === 'production') {
|
|
101
|
-
return environment;
|
|
102
|
-
}
|
|
103
|
-
return 'local';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Resolve a single credential by walking the candidate keys against
|
|
108
|
-
* process.env then the active secrets store. Returns the first match.
|
|
109
|
-
*
|
|
110
|
-
* Throws when no candidate resolves — adapters should let this bubble
|
|
111
|
-
* up so the CLI surfaces a clean "missing credentials" message rather
|
|
112
|
-
* than a vague "401 Unauthorized" downstream.
|
|
113
|
-
*/
|
|
114
|
-
export async function resolveAdapterCredential(
|
|
115
|
-
options: ResolveAdapterCredentialOptions
|
|
116
|
-
): Promise<ResolvedAdapterCredential> {
|
|
117
|
-
const env = options.environment ?? 'local';
|
|
118
|
-
const tier = inferTier(env, options.tier);
|
|
119
|
-
const includeEnv = options.includeProcessEnv ?? true;
|
|
120
|
-
|
|
121
|
-
// 1. process.env (CI / shell override)
|
|
122
|
-
if (includeEnv) {
|
|
123
|
-
for (const key of options.keyCandidates) {
|
|
124
|
-
const v = process.env[key];
|
|
125
|
-
if (v && v.length > 0) {
|
|
126
|
-
return { key, value: v, source: 'process.env' };
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 2. secrets/store runtime resolution (tier-aware, priority-ordered)
|
|
132
|
-
const runtime = getVibesRuntime();
|
|
133
|
-
if (!runtime.hasKind('secrets/store')) {
|
|
134
|
-
throw new Error(
|
|
135
|
-
`No secrets/store kind registered; cannot resolve ${options.humanName ?? options.keyCandidates[0]}. ` +
|
|
136
|
-
'Load the secrets plugin (and a backend like encrypted-local) before calling this adapter.'
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const descriptors = runtime
|
|
141
|
-
.assets('secrets/store')
|
|
142
|
-
.descriptors() as SecretsStoreDescriptorShape[];
|
|
143
|
-
// `VIBES_DEBUG_SECRETS=1` dumps the visible descriptor pool when
|
|
144
|
-
// you're tracing why a credential is missing or getting misrouted.
|
|
145
|
-
if (process.env.VIBES_DEBUG_SECRETS === '1') {
|
|
146
|
-
console.error(`[secrets-debug] descriptors visible at tier=${tier}:`);
|
|
147
|
-
for (const d of descriptors) {
|
|
148
|
-
console.error(` - id=${d.id} priority=${d.priority ?? '-'} tiers=${JSON.stringify(d.tiers)}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const target = pickBackend(descriptors, tier);
|
|
152
|
-
if (!target) {
|
|
153
|
-
throw new Error(
|
|
154
|
-
`No secrets/store backend available for tier=${tier}. Register a backend ` +
|
|
155
|
-
'(encrypted-local for local, cloudflare-secrets-store for production) before calling this adapter.'
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const store = (await runtime
|
|
160
|
-
.query('secrets/store')
|
|
161
|
-
.withId(target.id)
|
|
162
|
-
.resolve()) as SecretsStoreImplShape;
|
|
163
|
-
|
|
164
|
-
if (!store || typeof store.get !== 'function') {
|
|
165
|
-
throw new Error(
|
|
166
|
-
`Resolved secrets/store '${target.id}' has no get() method for ${options.humanName ?? options.keyCandidates[0]}.`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
for (const key of options.keyCandidates) {
|
|
171
|
-
try {
|
|
172
|
-
const v = await store.get(env, key);
|
|
173
|
-
if (v && v.length > 0) {
|
|
174
|
-
return { key, value: v, source: target.id };
|
|
175
|
-
}
|
|
176
|
-
} catch {
|
|
177
|
-
// next candidate
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
throw new Error(
|
|
182
|
-
`Missing credential: none of [${options.keyCandidates.join(', ')}] resolved from process.env or ` +
|
|
183
|
-
`${target.id} (environment=${env}, tier=${tier}). ` +
|
|
184
|
-
`Set the value with \`vibes secrets set --environment ${env} ${options.keyCandidates[0]} <value>\`.`
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Convenience wrapper for resolving multiple credentials at once.
|
|
190
|
-
* Each key gets a candidate list of one (the key itself). Use the
|
|
191
|
-
* single-credential form when you need fallback chains.
|
|
192
|
-
*/
|
|
193
|
-
export async function resolveAdapterCredentials(
|
|
194
|
-
keys: readonly string[],
|
|
195
|
-
options?: Omit<ResolveAdapterCredentialOptions, 'keyCandidates' | 'humanName'>
|
|
196
|
-
): Promise<Record<string, ResolvedAdapterCredential>> {
|
|
197
|
-
const out: Record<string, ResolvedAdapterCredential> = {};
|
|
198
|
-
for (const key of keys) {
|
|
199
|
-
out[key] = await resolveAdapterCredential({
|
|
200
|
-
keyCandidates: [key],
|
|
201
|
-
...(options ?? {})
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return out;
|
|
205
|
-
}
|
package/src/deployment.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
appDeploymentSchema,
|
|
3
|
-
deploymentDependencySchema,
|
|
4
|
-
deploymentEnvRequirementSchema,
|
|
5
|
-
deploymentOriginSchema,
|
|
6
|
-
type AppDeployment,
|
|
7
|
-
type AppDeploymentInput,
|
|
8
|
-
type DeploymentDependency,
|
|
9
|
-
type DeploymentEnvRequirement,
|
|
10
|
-
type DeploymentOrigin,
|
|
11
|
-
type DeploymentUpstream
|
|
12
|
-
} from './schemas.ts';
|
|
13
|
-
|
|
14
|
-
export function createAppDeployment(input: AppDeploymentInput): AppDeployment {
|
|
15
|
-
return appDeploymentSchema.parse(input);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function createDeploymentOrigin(input: DeploymentOrigin): DeploymentOrigin {
|
|
19
|
-
return deploymentOriginSchema.parse(input);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function createDeploymentEnvRequirement(
|
|
23
|
-
input: DeploymentEnvRequirement
|
|
24
|
-
): DeploymentEnvRequirement {
|
|
25
|
-
return deploymentEnvRequirementSchema.parse(input);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function createDeploymentDependency(input: DeploymentDependency): DeploymentDependency {
|
|
29
|
-
return deploymentDependencySchema.parse(input);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getPrimaryOrigin(deployment: AppDeployment): DeploymentOrigin {
|
|
33
|
-
return (
|
|
34
|
-
deployment.origins.find((origin) => origin.kind === 'primary') ?? deployment.origins[0]
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function getUpstreamOriginEnv(
|
|
39
|
-
upstream: DeploymentUpstream
|
|
40
|
-
): Record<string, string> {
|
|
41
|
-
if (!upstream.originEnvVar) {
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
[upstream.originEnvVar]: upstream.origin
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type {
|
|
51
|
-
AppDeployment,
|
|
52
|
-
AppDeploymentInput,
|
|
53
|
-
DeploymentDependency,
|
|
54
|
-
DeploymentEnvRequirement,
|
|
55
|
-
DeploymentOrigin,
|
|
56
|
-
DeploymentUpstream
|
|
57
|
-
};
|