@vibesdotdev/infra-core 0.0.2 → 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 +28 -1
- 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 +21 -32
- 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 +139 -33
- 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 +121 -37
- 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/src/kinds/alerts.kind.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Infra Alerts Kind
|
|
3
|
-
*
|
|
4
|
-
* Provider-agnostic schema for alerting / notification policies that
|
|
5
|
-
* span billing (budget + per-product usage), reliability (error rate,
|
|
6
|
-
* latency), and operational lifecycle (deploys, subscription changes).
|
|
7
|
-
*
|
|
8
|
-
* Per-provider implementations (cloudflare-alerts, do-monitoring,
|
|
9
|
-
* cloudwatch-alarms) map this shape onto the native API. Where a
|
|
10
|
-
* provider doesn't support a `type`, the impl rejects with a clear
|
|
11
|
-
* "unsupported" error rather than silently falling back.
|
|
12
|
-
*
|
|
13
|
-
* Configuration is declarative — typically encoded in an
|
|
14
|
-
* `infra/account.config.ts` or `infra/alerts.infra.ts` file alongside
|
|
15
|
-
* `infra/dns.ts`. The CLI (`vibes infra alerts list|create|delete`)
|
|
16
|
-
* wraps the same primitive for one-off ops and drift detection.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import * as z from 'zod/v4';
|
|
20
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
21
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
22
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Delivery channel for an alert. Provider impls translate these to
|
|
26
|
-
* native delivery slots (e.g. CF's `mechanisms.email[]`).
|
|
27
|
-
*/
|
|
28
|
-
const AlertMechanismSchema = z.discriminatedUnion('kind', [
|
|
29
|
-
z.object({
|
|
30
|
-
kind: z.literal('email'),
|
|
31
|
-
/** Email address — must be a verified destination on the provider. */
|
|
32
|
-
target: z.email()
|
|
33
|
-
}),
|
|
34
|
-
z.object({
|
|
35
|
-
kind: z.literal('webhook'),
|
|
36
|
-
/** Outbound webhook URL. */
|
|
37
|
-
target: z.string().url(),
|
|
38
|
-
/** Optional secret name (in the active secrets store) used for HMAC signing. */
|
|
39
|
-
secretRef: z.string().optional()
|
|
40
|
-
}),
|
|
41
|
-
z.object({
|
|
42
|
-
kind: z.literal('pagerduty'),
|
|
43
|
-
/** PagerDuty integration key (Events API v2). */
|
|
44
|
-
target: z.string().min(1)
|
|
45
|
-
}),
|
|
46
|
-
z.object({
|
|
47
|
-
kind: z.literal('slack'),
|
|
48
|
-
/** Slack webhook URL (Incoming Webhooks). */
|
|
49
|
-
target: z.string().url()
|
|
50
|
-
})
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
export type AlertMechanism = z.infer<typeof AlertMechanismSchema>;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Cross-provider alert categories. Each maps to one or more native
|
|
57
|
-
* alert types per provider.
|
|
58
|
-
*/
|
|
59
|
-
const AlertTypeSchema = z.enum([
|
|
60
|
-
/** Total cost crossed a dollar threshold for the current billing period. */
|
|
61
|
-
'budget',
|
|
62
|
-
/** Per-product usage crossed a numeric threshold (events/req/GB/etc.). */
|
|
63
|
-
'usage',
|
|
64
|
-
/** Worker/service error rate over a rolling window. */
|
|
65
|
-
'error-rate',
|
|
66
|
-
/** P99 latency or wall-time crossed a threshold. */
|
|
67
|
-
'latency',
|
|
68
|
-
/** Catch-all for provider-specific types not yet modeled here. */
|
|
69
|
-
'custom'
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
export type AlertType = z.infer<typeof AlertTypeSchema>;
|
|
73
|
-
|
|
74
|
-
const AlertWindowSchema = z.enum(['5m', '15m', '1h', '6h', '24h', '7d', '30d']);
|
|
75
|
-
|
|
76
|
-
const AlertPolicySchema = z.object({
|
|
77
|
-
/** Stable id for diffing. Auto-generated when omitted. */
|
|
78
|
-
id: z.string().min(1).optional(),
|
|
79
|
-
/** Human-readable name (also surfaced by the provider). */
|
|
80
|
-
name: z.string().min(1),
|
|
81
|
-
type: AlertTypeSchema,
|
|
82
|
-
/**
|
|
83
|
-
* Threshold value. `budget` reads it as USD (or local currency).
|
|
84
|
-
* `usage`/`error-rate`/`latency` read it as units defined by the
|
|
85
|
-
* filter (event count, %, ms).
|
|
86
|
-
*/
|
|
87
|
-
threshold: z.number().nonnegative(),
|
|
88
|
-
/** Optional secondary threshold for tiered alerts. */
|
|
89
|
-
warningThreshold: z.number().nonnegative().optional(),
|
|
90
|
-
/** Rolling window for `usage`/`error-rate`/`latency`. Ignored for `budget`. */
|
|
91
|
-
window: AlertWindowSchema.optional(),
|
|
92
|
-
/**
|
|
93
|
-
* Adapter-specific filters. Examples:
|
|
94
|
-
* { product: 'workers_observability' } // usage on a specific CF product
|
|
95
|
-
* { worker: 'vibes-account' } // error-rate scoped to one worker
|
|
96
|
-
* { native_alert_type: 'health_check_status_notification' } // custom escape
|
|
97
|
-
*/
|
|
98
|
-
filters: z.record(z.string(), z.string()).default({}),
|
|
99
|
-
mechanisms: z.array(AlertMechanismSchema).min(1),
|
|
100
|
-
enabled: z.boolean().default(true),
|
|
101
|
-
description: z.string().optional()
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
export type AlertPolicy = z.infer<typeof AlertPolicySchema>;
|
|
105
|
-
|
|
106
|
-
const AlertsBaseSchema = RuntimeDescriptorSchema.extend({
|
|
107
|
-
kind: z.literal('infra/alerts'),
|
|
108
|
-
/** Adapter id (e.g. 'cloudflare-alerts', 'do-monitoring'). */
|
|
109
|
-
adapter: z.string().min(1),
|
|
110
|
-
adapterConfig: z.record(z.string(), z.unknown()).optional(),
|
|
111
|
-
/**
|
|
112
|
-
* Default environment name for credential resolution via `vibes
|
|
113
|
-
* secrets`. Defaults to 'local' since the CLI / dev workflow is
|
|
114
|
-
* the primary caller; production Workers that consume this adapter
|
|
115
|
-
* read credentials from CF Secrets Store bindings directly, not
|
|
116
|
-
* through this descriptor.
|
|
117
|
-
*/
|
|
118
|
-
environment: z.string().default('local'),
|
|
119
|
-
policies: z.array(AlertPolicySchema).default([])
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
export type InfraAlertsDescriptor = z.infer<typeof AlertsBaseSchema>;
|
|
123
|
-
export type InfraAlertsDescriptorInput = z.input<typeof AlertsBaseSchema>;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Implementation contract every provider implements. Operations are
|
|
127
|
-
* idempotent: `applyPolicies` reconciles the live policy set to the
|
|
128
|
-
* desired set without trampling unrelated policies on the provider.
|
|
129
|
-
*/
|
|
130
|
-
export interface AlertsImplementation {
|
|
131
|
-
/** List policies currently configured on the provider. */
|
|
132
|
-
listPolicies(): Promise<Array<AlertPolicy & { providerId: string }>>;
|
|
133
|
-
/** Create a single policy. Returns the provider-assigned id. */
|
|
134
|
-
createPolicy(policy: AlertPolicy): Promise<{ providerId: string }>;
|
|
135
|
-
/** Delete a policy by provider id. */
|
|
136
|
-
deletePolicy(providerId: string): Promise<void>;
|
|
137
|
-
/**
|
|
138
|
-
* Diff desired (descriptor) against live; return the set of policies
|
|
139
|
-
* that need create/update/delete. Empty arrays = in sync.
|
|
140
|
-
*/
|
|
141
|
-
diff(desired: AlertPolicy[]): Promise<{
|
|
142
|
-
create: AlertPolicy[];
|
|
143
|
-
update: Array<{ providerId: string; policy: AlertPolicy }>;
|
|
144
|
-
delete: Array<{ providerId: string; name: string }>;
|
|
145
|
-
}>;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export const alertsKind = createRuntimeKind<InfraAlertsDescriptor, AlertsImplementation>({
|
|
149
|
-
id: 'infra/alerts',
|
|
150
|
-
descriptorSchema: AlertsBaseSchema,
|
|
151
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
152
|
-
extractStem
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
export type InfraAlertsKind = InfraAlertsDescriptor;
|
|
156
|
-
export type InfraAlertsKindInput = InfraAlertsDescriptorInput;
|
|
157
|
-
|
|
158
|
-
export {
|
|
159
|
-
AlertsBaseSchema as InfraAlertsDescriptorSchema,
|
|
160
|
-
AlertPolicySchema,
|
|
161
|
-
AlertMechanismSchema,
|
|
162
|
-
AlertTypeSchema,
|
|
163
|
-
AlertWindowSchema
|
|
164
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/artifact
|
|
3
|
-
*
|
|
4
|
-
* Generic descriptor for generatable infrastructure artifacts.
|
|
5
|
-
*
|
|
6
|
-
* This kind is intentionally unopinionated about what gets generated.
|
|
7
|
-
* Adapter implementations (infra-kubernetes, infra-helm, infra-cloudflare, etc.)
|
|
8
|
-
* define their own descriptor shapes and generation logic.
|
|
9
|
-
*
|
|
10
|
-
* Usage pattern:
|
|
11
|
-
* 1. Adapters register artifact generators with custom descriptors
|
|
12
|
-
* 2. Query: runtime.query('infra/artifact').all()
|
|
13
|
-
* 3. Resolve implementation and call its generate method
|
|
14
|
-
* 4. Implementation returns artifact content (format determined by impl)
|
|
15
|
-
*/
|
|
16
|
-
import * as z from 'zod/v4';
|
|
17
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
18
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
19
|
-
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
20
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Minimal base schema for artifact descriptors.
|
|
24
|
-
*
|
|
25
|
-
* Implementations extend this with their own fields (source resources,
|
|
26
|
-
* output format, generation options, etc.).
|
|
27
|
-
*/
|
|
28
|
-
const ArtifactBaseSchema = RuntimeDescriptorSchema.extend({
|
|
29
|
-
kind: z.literal('infra/artifact')
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Generic artifact generator interface.
|
|
34
|
-
*
|
|
35
|
-
* Implementations define their own input/output shapes.
|
|
36
|
-
*/
|
|
37
|
-
export interface ArtifactGenerator {
|
|
38
|
-
/**
|
|
39
|
-
* Generate artifact content.
|
|
40
|
-
*
|
|
41
|
-
* @param options - Implementation-specific options (descriptor, context, etc.)
|
|
42
|
-
* @returns Generated artifact (content + metadata)
|
|
43
|
-
*/
|
|
44
|
-
generate(options?: unknown): Promise<ArtifactOutput>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Generated artifact output (generic shape).
|
|
49
|
-
*
|
|
50
|
-
* Implementations may return more specific types.
|
|
51
|
-
*/
|
|
52
|
-
export interface ArtifactOutput {
|
|
53
|
-
/** Generated content (string for text formats, Buffer for binary) */
|
|
54
|
-
content: string | Buffer;
|
|
55
|
-
/** Recommended filename (including extension) */
|
|
56
|
-
filename: string;
|
|
57
|
-
/** Full output path */
|
|
58
|
-
path: string;
|
|
59
|
-
/** Optional metadata */
|
|
60
|
-
metadata?: Record<string, unknown>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Artifact descriptor type (base shape, implementations extend)
|
|
65
|
-
*/
|
|
66
|
-
export type ArtifactDescriptor = z.infer<typeof ArtifactBaseSchema>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Artifact descriptor schema
|
|
70
|
-
*/
|
|
71
|
-
export const ArtifactDescriptorSchema = ArtifactBaseSchema;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Artifact kind descriptor for runtime registration.
|
|
75
|
-
*
|
|
76
|
-
* Note: This kind has no default implementation. Adapters must register
|
|
77
|
-
* their own implementations via runtime plugins.
|
|
78
|
-
*/
|
|
79
|
-
class NoOpArtifactImplementation implements ArtifactGenerator {
|
|
80
|
-
async generate(options?: unknown): Promise<ArtifactOutput> {
|
|
81
|
-
throw new Error(
|
|
82
|
-
'No artifact generator registered. Adapter plugins (infra-kubernetes, infra-helm, etc.) must register implementations.'
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export const artifactKind = createRuntimeKind<ArtifactDescriptor, NoOpArtifactImplementation>({
|
|
88
|
-
id: 'infra/artifact',
|
|
89
|
-
descriptorSchema: ArtifactDescriptorSchema,
|
|
90
|
-
defaultImplementation: NoOpArtifactImplementation,
|
|
91
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
92
|
-
extractStem
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Re-export discovery helpers
|
|
96
|
-
export { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
package/src/kinds/cache.kind.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/cache
|
|
3
|
-
*
|
|
4
|
-
* Describes a cache service.
|
|
5
|
-
*
|
|
6
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* - The base defines fields universal across adapters: id/kind/name +
|
|
9
|
-
* the cache shape (engine, maxMemory, eviction, namespace).
|
|
10
|
-
* - Adapter-specific fields (region, version, numNodes, size, …)
|
|
11
|
-
* live under `config`. Each adapter package defines its own concrete schema.
|
|
12
|
-
*/
|
|
13
|
-
import * as z from 'zod/v4';
|
|
14
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
15
|
-
import type { RuntimeKindDescriptorRecord } from '@vibesdotdev/runtime/schemas/kind';
|
|
16
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
17
|
-
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
18
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
19
|
-
|
|
20
|
-
const CacheBaseSchema = RuntimeDescriptorSchema.extend({
|
|
21
|
-
kind: z.literal('infra/cache'),
|
|
22
|
-
|
|
23
|
-
/** Cache engine (e.g., 'cloudflare-kv', 'redis'). */
|
|
24
|
-
engine: z.string().min(1).optional(),
|
|
25
|
-
|
|
26
|
-
/** Maximum memory hint. */
|
|
27
|
-
maxMemory: z.string().optional(),
|
|
28
|
-
|
|
29
|
-
/** Eviction policy. */
|
|
30
|
-
eviction: z.enum(['lru', 'lfu', 'ttl']).optional(),
|
|
31
|
-
|
|
32
|
-
/** Logical namespace within the cache. */
|
|
33
|
-
namespace: z.string().optional()
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const DOManagedRedisConfigSchema = z.object({
|
|
37
|
-
/** Max memory allocation (e.g., '256mb', '1gb'). */
|
|
38
|
-
maxMemory: z.string().min(1).optional(),
|
|
39
|
-
/** Eviction policy: lru, lfu, or ttl. */
|
|
40
|
-
eviction: z.enum(['lru', 'lfu', 'ttl']).optional(),
|
|
41
|
-
/** DO region (default: nyc1). */
|
|
42
|
-
region: z.string().min(1).default('nyc1'),
|
|
43
|
-
/** Redis version (default: 7). */
|
|
44
|
-
version: z.string().min(1).default('7'),
|
|
45
|
-
/** Number of nodes (default: 1). */
|
|
46
|
-
numNodes: z.number().int().positive().default(1),
|
|
47
|
-
/** Database size tier (optional, derived from maxMemory if not set). */
|
|
48
|
-
size: z.string().min(1).optional()
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const CloudflareKVCacheConfigSchema = z.object({
|
|
52
|
-
/** Logical namespace within the KV store. */
|
|
53
|
-
namespace: z.string().min(1)
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const DOKSRedisCacheConfigSchema = z.object({
|
|
57
|
-
/** Kubernetes namespace (default: vibes). */
|
|
58
|
-
namespace: z.string().min(1).default('vibes'),
|
|
59
|
-
/** Container image (default: redis:{version}). */
|
|
60
|
-
image: z.string().min(1).optional(),
|
|
61
|
-
/** Redis version (default: 7). */
|
|
62
|
-
version: z.string().min(1).default('7'),
|
|
63
|
-
/** Max memory allocation (e.g., '256mb'). */
|
|
64
|
-
maxMemory: z.string().optional(),
|
|
65
|
-
/** Eviction policy: lru, lfu, or ttl. */
|
|
66
|
-
eviction: z.enum(['lru', 'lfu', 'ttl']).optional(),
|
|
67
|
-
/** Storage size (default: 1Gi). */
|
|
68
|
-
storageSize: z.string().min(1).default('1Gi')
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
export const CacheConfigSchema = z.union([
|
|
72
|
-
DOManagedRedisConfigSchema.extend({ adapter: z.literal('do-managed-redis') }),
|
|
73
|
-
CloudflareKVCacheConfigSchema.extend({ adapter: z.literal('cloudflare-kv') }),
|
|
74
|
-
DOKSRedisCacheConfigSchema.extend({ adapter: z.literal('doks-redis') })
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
export const CacheDescriptorSchema = CacheBaseSchema.extend({
|
|
78
|
-
/**
|
|
79
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
80
|
-
* package defines its own config schema under its discriminator key.
|
|
81
|
-
*/
|
|
82
|
-
config: CacheConfigSchema.optional()
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
export type CacheDescriptor = z.infer<typeof CacheDescriptorSchema>;
|
|
86
|
-
|
|
87
|
-
class DefaultCacheImplementation {
|
|
88
|
-
constructor(
|
|
89
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
90
|
-
public readonly context: unknown
|
|
91
|
-
) {}
|
|
92
|
-
|
|
93
|
-
get config(): CacheDescriptor {
|
|
94
|
-
return this.descriptor as CacheDescriptor;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const cacheKind = createRuntimeKind<CacheDescriptor, DefaultCacheImplementation>({
|
|
99
|
-
id: 'infra/cache',
|
|
100
|
-
descriptorSchema: CacheDescriptorSchema,
|
|
101
|
-
defaultImplementation: DefaultCacheImplementation,
|
|
102
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
103
|
-
extractStem
|
|
104
|
-
});
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/database
|
|
3
|
-
*
|
|
4
|
-
* Describes a database instance.
|
|
5
|
-
*
|
|
6
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* - The base defines fields universal across adapters: id/kind/name +
|
|
9
|
-
* the database shape (engine, size, replicas, backups).
|
|
10
|
-
* - Adapter-specific fields (namespace, storageSize, version, region, …)
|
|
11
|
-
* live under `config`. Each adapter package defines its own concrete schema.
|
|
12
|
-
*/
|
|
13
|
-
import * as z from 'zod/v4';
|
|
14
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
15
|
-
import type { RuntimeKindDescriptorRecord } from '@vibesdotdev/runtime/schemas/kind';
|
|
16
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
17
|
-
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
18
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
19
|
-
|
|
20
|
-
export const DatabaseBackupSchema = z.object({
|
|
21
|
-
enabled: z.boolean().default(false),
|
|
22
|
-
schedule: z.string().optional(),
|
|
23
|
-
retention: z.string().optional()
|
|
24
|
-
});
|
|
25
|
-
export type DatabaseBackup = z.infer<typeof DatabaseBackupSchema>;
|
|
26
|
-
|
|
27
|
-
const DatabaseBaseSchema = RuntimeDescriptorSchema.extend({
|
|
28
|
-
kind: z.literal('infra/database'),
|
|
29
|
-
|
|
30
|
-
/** Database engine (e.g., 'turso', 'postgres'). */
|
|
31
|
-
engine: z.string().min(1).optional(),
|
|
32
|
-
|
|
33
|
-
/** Instance size hint. */
|
|
34
|
-
size: z.string().optional(),
|
|
35
|
-
|
|
36
|
-
/** Replica count. */
|
|
37
|
-
replicas: z.number().int().nonnegative().optional(),
|
|
38
|
-
|
|
39
|
-
/** Backup configuration. */
|
|
40
|
-
backups: DatabaseBackupSchema.optional()
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export const DoksDatabaseConfigSchema = z.object({
|
|
44
|
-
/** Kubernetes namespace (default: vibes). */
|
|
45
|
-
namespace: z.string().min(1).default('vibes'),
|
|
46
|
-
/** Storage size for pgdata volume (default: 10Gi). */
|
|
47
|
-
storageSize: z.string().min(1).default('10Gi'),
|
|
48
|
-
/** Container resources. */
|
|
49
|
-
resources: z
|
|
50
|
-
.object({
|
|
51
|
-
requests: z.object({ cpu: z.string().min(1), memory: z.string().min(1) }).optional(),
|
|
52
|
-
limits: z.object({ cpu: z.string().min(1), memory: z.string().min(1) }).optional()
|
|
53
|
-
})
|
|
54
|
-
.optional(),
|
|
55
|
-
/** Postgres version tag (default: 16-alpine). */
|
|
56
|
-
version: z.string().min(1).default('16-alpine')
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export const DOManagedPostgresConfigSchema = z.object({
|
|
60
|
-
/** Database size tier (default: db-s-1vcpu-1gb). */
|
|
61
|
-
size: z.string().min(1).default('db-s-1vcpu-1gb'),
|
|
62
|
-
/** DO region (default: nyc1). */
|
|
63
|
-
region: z.string().min(1).default('nyc1'),
|
|
64
|
-
/** Postgres version (default: 16). */
|
|
65
|
-
version: z.string().min(1).default('16')
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
export const TursoDatabaseConfigSchema = z.object({
|
|
69
|
-
/** Turso database name (defaults to descriptor id). */
|
|
70
|
-
database: z.string().min(1).optional(),
|
|
71
|
-
/** Edge region for replication (default: aws:iad1). */
|
|
72
|
-
region: z.string().min(1).default('aws:iad1')
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export const CloudflareD1ConfigSchema = z.object({
|
|
76
|
-
/** D1 adapter name (always 'cloudflare-d1'). */
|
|
77
|
-
adapter: z.literal('cloudflare-d1'),
|
|
78
|
-
/** Binding name for D1 in Cloudflare Workers (default: 'DB'). */
|
|
79
|
-
binding: z.string().min(1).default('DB'),
|
|
80
|
-
/** D1 database name. */
|
|
81
|
-
databaseName: z.string().min(1),
|
|
82
|
-
/** ID of the consuming app (for wrangler.jsonc generation). */
|
|
83
|
-
consumerAppId: z.string().min(1)
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
export const DatabaseConfigSchema = z.union([
|
|
87
|
-
DoksDatabaseConfigSchema.extend({ adapter: z.literal('doks-statefulset') }),
|
|
88
|
-
DOManagedPostgresConfigSchema.extend({ adapter: z.literal('do-managed-postgres') }),
|
|
89
|
-
TursoDatabaseConfigSchema.extend({ adapter: z.literal('turso') }),
|
|
90
|
-
CloudflareD1ConfigSchema
|
|
91
|
-
]);
|
|
92
|
-
|
|
93
|
-
export const DatabaseDescriptorSchema = DatabaseBaseSchema.extend({
|
|
94
|
-
/**
|
|
95
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
96
|
-
* package defines its own config schema under its discriminator key.
|
|
97
|
-
*/
|
|
98
|
-
config: DatabaseConfigSchema.optional()
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
export type DatabaseDescriptor = z.infer<typeof DatabaseDescriptorSchema>;
|
|
102
|
-
|
|
103
|
-
class DefaultDatabaseImplementation {
|
|
104
|
-
constructor(
|
|
105
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
106
|
-
public readonly context: unknown
|
|
107
|
-
) {}
|
|
108
|
-
|
|
109
|
-
get config(): DatabaseDescriptor {
|
|
110
|
-
return this.descriptor as DatabaseDescriptor;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const databaseKind = createRuntimeKind<DatabaseDescriptor, DefaultDatabaseImplementation>({
|
|
115
|
-
id: 'infra/database',
|
|
116
|
-
descriptorSchema: DatabaseDescriptorSchema,
|
|
117
|
-
defaultImplementation: DefaultDatabaseImplementation,
|
|
118
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
119
|
-
extractStem
|
|
120
|
-
});
|
package/src/kinds/discovery.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared discovery helpers for infra resource kinds.
|
|
3
|
-
*
|
|
4
|
-
* All infra kinds use the same discovery pattern for *.infra.ts files.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Glob pattern for discovering infra resource declaration files.
|
|
9
|
-
*/
|
|
10
|
-
export const INFRA_DISCOVERY_PATTERN = '**/*.infra.ts';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Extract the stem (base name without extension) from an infra file.
|
|
14
|
-
* Matches both .infra.ts and .infra.tsx extensions.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* extractStem('auth.infra.ts') // 'auth'
|
|
18
|
-
* extractStem('my-service.infra.tsx') // 'my-service'
|
|
19
|
-
* extractStem('not-infra.ts') // null
|
|
20
|
-
*/
|
|
21
|
-
export function extractStem(filename: string): string | null {
|
|
22
|
-
const match = filename.match(/^(.+)\.infra\.tsx?$/);
|
|
23
|
-
const stem = match ? match[1]! : null;
|
|
24
|
-
// Return null for empty stem (e.g., '.infra.ts')
|
|
25
|
-
return stem && stem.length > 0 ? stem : null;
|
|
26
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/git-hosting
|
|
3
|
-
*
|
|
4
|
-
* Describes a git hosting service instance (e.g. Gitea, Forgejo).
|
|
5
|
-
*
|
|
6
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* - The base (this file) defines fields that are universal across every
|
|
9
|
-
* adapter: id/kind/name + the hosting shape every git host declares
|
|
10
|
-
* (domain, url, storagePath, authMethod, etc.).
|
|
11
|
-
* - Adapter-specific fields (dropletSize, dockerImage, volumeSizeGb, …)
|
|
12
|
-
* live exclusively under `config`. Each adapter package defines its own
|
|
13
|
-
* concrete schema under its discriminator key.
|
|
14
|
-
*/
|
|
15
|
-
import * as z from 'zod/v4';
|
|
16
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
17
|
-
import type { RuntimeKindDescriptorRecord } from '@vibesdotdev/runtime/schemas/kind';
|
|
18
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
19
|
-
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
20
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
21
|
-
import { deploymentEnvRequirementSchema } from '../schemas.ts';
|
|
22
|
-
|
|
23
|
-
export const GitHostingTypeSchema = z.enum(['gitea', 'forgejo']);
|
|
24
|
-
export type GitHostingType = z.infer<typeof GitHostingTypeSchema>;
|
|
25
|
-
|
|
26
|
-
export const GitHostingAuthMethodSchema = z.enum(['local', 'oauth', 'token']);
|
|
27
|
-
export type GitHostingAuthMethod = z.infer<typeof GitHostingAuthMethodSchema>;
|
|
28
|
-
|
|
29
|
-
const GitHostingBaseSchema = RuntimeDescriptorSchema.extend({
|
|
30
|
-
kind: z.literal('infra/git-hosting'),
|
|
31
|
-
|
|
32
|
-
/** Primary access URL (e.g. 'https://git.example.com'). */
|
|
33
|
-
url: z.string().url(),
|
|
34
|
-
|
|
35
|
-
/** Hostname for DNS resolution (e.g. 'git.example.com'). */
|
|
36
|
-
hostname: z.string().min(1),
|
|
37
|
-
|
|
38
|
-
/** Git hosting software type. */
|
|
39
|
-
type: GitHostingTypeSchema,
|
|
40
|
-
|
|
41
|
-
/** Storage mount path inside the container. */
|
|
42
|
-
storagePath: z.string().min(1).default('/data'),
|
|
43
|
-
|
|
44
|
-
/** Authentication method. */
|
|
45
|
-
authMethod: GitHostingAuthMethodSchema.default('token'),
|
|
46
|
-
|
|
47
|
-
/** Whether TLS is enabled. */
|
|
48
|
-
ssl: z.boolean().default(true),
|
|
49
|
-
|
|
50
|
-
/** Environment variable requirements. */
|
|
51
|
-
env: z.array(deploymentEnvRequirementSchema).optional()
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export const GiteaDoksGitHostingConfigSchema = z.object({
|
|
55
|
-
/** DigitalOcean Droplet size. */
|
|
56
|
-
dropletSize: z.string().default('s-2vcpu-2gb'),
|
|
57
|
-
/** Docker image for the Gitea container. */
|
|
58
|
-
dockerImage: z.string().default('gitea/gitea:1.21'),
|
|
59
|
-
/** Volume size in GiB for persistent storage. */
|
|
60
|
-
volumeSizeGb: z.number().int().positive().default(50),
|
|
61
|
-
/** Primary domain for the Gitea instance. */
|
|
62
|
-
domain: z.string().min(1),
|
|
63
|
-
/** SSH port exposed on the service. */
|
|
64
|
-
sshPort: z.number().int().positive().default(22),
|
|
65
|
-
/** HTTP port exposed on the service. */
|
|
66
|
-
httpPort: z.number().int().positive().default(3000)
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export const GitHostingConfigSchema = z.union([
|
|
70
|
-
GiteaDoksGitHostingConfigSchema.extend({ adapter: z.literal('gitea-doks') })
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
export const GitHostingDescriptorSchema = GitHostingBaseSchema.extend({
|
|
74
|
-
/**
|
|
75
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
76
|
-
* package defines its own config schema under its discriminator key.
|
|
77
|
-
*/
|
|
78
|
-
config: GitHostingConfigSchema.optional()
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export type GitHostingDescriptor = z.infer<typeof GitHostingDescriptorSchema>;
|
|
82
|
-
|
|
83
|
-
class DefaultGitHostingImplementation {
|
|
84
|
-
constructor(
|
|
85
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
86
|
-
public readonly context: unknown
|
|
87
|
-
) {}
|
|
88
|
-
|
|
89
|
-
get config(): GitHostingDescriptor {
|
|
90
|
-
return this.descriptor as GitHostingDescriptor;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const gitHostingKind = createRuntimeKind<GitHostingDescriptor, DefaultGitHostingImplementation>({
|
|
95
|
-
id: 'infra/git-hosting',
|
|
96
|
-
descriptorSchema: GitHostingDescriptorSchema,
|
|
97
|
-
defaultImplementation: DefaultGitHostingImplementation,
|
|
98
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
99
|
-
extractStem
|
|
100
|
-
});
|