@vibesdotdev/infra-core 0.0.1 → 1.0.0-rc.4
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 +33 -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-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.d.ts +8 -4
- package/dist/deployment.d.ts.map +1 -1
- package/dist/deployment.js +30 -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 +34 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -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 +62 -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 +381 -0
- package/dist/kinds/build-job.kind.d.ts.map +1 -0
- package/dist/kinds/build-job.kind.js +216 -0
- package/dist/kinds/build-job.kind.js.map +1 -0
- package/dist/kinds/cache.kind.d.ts +39 -92
- package/dist/kinds/cache.kind.d.ts.map +1 -1
- package/dist/kinds/cache.kind.js +26 -51
- 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 +138 -0
- package/dist/kinds/compute-source.kind.d.ts.map +1 -0
- package/dist/kinds/compute-source.kind.js +145 -0
- package/dist/kinds/compute-source.kind.js.map +1 -0
- package/dist/kinds/compute-sources.descriptors.d.ts +45 -0
- package/dist/kinds/compute-sources.descriptors.d.ts.map +1 -0
- package/dist/kinds/compute-sources.descriptors.js +93 -0
- package/dist/kinds/compute-sources.descriptors.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-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 +40 -15
- package/dist/kinds/index.d.ts.map +1 -1
- package/dist/kinds/index.js +39 -14
- package/dist/kinds/index.js.map +1 -1
- package/dist/kinds/inventory.kind.d.ts +326 -0
- package/dist/kinds/inventory.kind.d.ts.map +1 -0
- package/dist/kinds/inventory.kind.js +188 -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 +27 -31
- package/dist/kinds/package-registry.kind.d.ts.map +1 -1
- package/dist/kinds/package-registry.kind.js +13 -26
- 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 -36
- package/dist/kinds/sandbox.kind.d.ts.map +1 -1
- package/dist/kinds/sandbox.kind.js +80 -34
- 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 +40 -0
- package/dist/kinds/spend-guard.kind.d.ts.map +1 -0
- package/dist/kinds/spend-guard.kind.js +133 -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 +115 -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 +291 -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 +336 -0
- package/dist/schemas/deployment-provider.d.ts.map +1 -0
- package/dist/schemas/deployment-provider.js +198 -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 +190 -20
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +137 -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 +132 -0
- package/dist/web-app-projection.d.ts.map +1 -0
- package/dist/web-app-projection.js +93 -0
- package/dist/web-app-projection.js.map +1 -0
- package/package.json +89 -39
- 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/src/kinds/queue.kind.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/queue
|
|
3
|
-
*
|
|
4
|
-
* Describes a message queue system.
|
|
5
|
-
*
|
|
6
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* - The base defines fields universal across adapters: id/kind/name +
|
|
9
|
-
* the queue shape (engine, topics, maxBatchSize, maxRetries, deadLetterQueue).
|
|
10
|
-
* - Adapter-specific fields (namespace, storageSize, resources, …) live under
|
|
11
|
-
* `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 QueueTopicSchema = z.object({
|
|
21
|
-
name: z.string().min(1),
|
|
22
|
-
partitions: z.number().int().positive().optional(),
|
|
23
|
-
retention: z.string().optional(),
|
|
24
|
-
replication: z.number().int().positive().optional()
|
|
25
|
-
});
|
|
26
|
-
export type QueueTopic = z.infer<typeof QueueTopicSchema>;
|
|
27
|
-
|
|
28
|
-
const QueueBaseSchema = RuntimeDescriptorSchema.extend({
|
|
29
|
-
kind: z.literal('infra/queue'),
|
|
30
|
-
|
|
31
|
-
/** Queue engine (e.g., 'cloudflare-queues', 'redpanda'). */
|
|
32
|
-
engine: z.string().min(1).optional(),
|
|
33
|
-
|
|
34
|
-
/** Topic / queue declarations. */
|
|
35
|
-
topics: z.array(QueueTopicSchema).optional(),
|
|
36
|
-
|
|
37
|
-
/** Maximum batch size. */
|
|
38
|
-
maxBatchSize: z.number().int().positive().optional(),
|
|
39
|
-
|
|
40
|
-
/** Maximum retry count. */
|
|
41
|
-
maxRetries: z.number().int().nonnegative().optional(),
|
|
42
|
-
|
|
43
|
-
/** Dead-letter queue id. */
|
|
44
|
-
deadLetterQueue: z.string().optional()
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export const DoksQueueConfigSchema = z.object({
|
|
48
|
-
/** Kubernetes namespace (default: vibes). */
|
|
49
|
-
namespace: z.string().min(1).default('vibes'),
|
|
50
|
-
/** Storage size for data volume (default: 10Gi). */
|
|
51
|
-
storageSize: z.string().min(1).default('10Gi'),
|
|
52
|
-
/** Container resources. */
|
|
53
|
-
resources: z
|
|
54
|
-
.object({
|
|
55
|
-
requests: z.object({ cpu: z.string().min(1), memory: z.string().min(1) }).optional(),
|
|
56
|
-
limits: z.object({ cpu: z.string().min(1), memory: z.string().min(1) }).optional()
|
|
57
|
-
})
|
|
58
|
-
.optional()
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export const CloudflareQueuesConfigSchema = z.object({
|
|
62
|
-
/** Maximum batch size per message. */
|
|
63
|
-
maxBatchSize: z.number().int().positive().default(10),
|
|
64
|
-
/** Maximum retry count. */
|
|
65
|
-
maxRetries: z.number().int().nonnegative().default(3),
|
|
66
|
-
/** Dead-letter queue id. */
|
|
67
|
-
deadLetterQueue: z.string().min(1).optional()
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const QueueConfigSchema = z.union([
|
|
71
|
-
DoksQueueConfigSchema.extend({ adapter: z.literal('doks-statefulset') }),
|
|
72
|
-
CloudflareQueuesConfigSchema.extend({ adapter: z.literal('cloudflare-queues') })
|
|
73
|
-
]);
|
|
74
|
-
|
|
75
|
-
export const QueueDescriptorSchema = QueueBaseSchema.extend({
|
|
76
|
-
/**
|
|
77
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
78
|
-
* package defines its own config schema under its discriminator key.
|
|
79
|
-
*/
|
|
80
|
-
config: QueueConfigSchema.optional()
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
export type QueueDescriptor = z.infer<typeof QueueDescriptorSchema>;
|
|
84
|
-
|
|
85
|
-
class DefaultQueueImplementation {
|
|
86
|
-
constructor(
|
|
87
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
88
|
-
public readonly context: unknown
|
|
89
|
-
) {}
|
|
90
|
-
|
|
91
|
-
get config(): QueueDescriptor {
|
|
92
|
-
return this.descriptor as QueueDescriptor;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const queueKind = createRuntimeKind<QueueDescriptor, DefaultQueueImplementation>({
|
|
97
|
-
id: 'infra/queue',
|
|
98
|
-
descriptorSchema: QueueDescriptorSchema,
|
|
99
|
-
defaultImplementation: DefaultQueueImplementation,
|
|
100
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
101
|
-
extractStem
|
|
102
|
-
});
|
package/src/kinds/rum.kind.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Infra RUM (Real User Monitoring) Kind
|
|
3
|
-
*
|
|
4
|
-
* Provider-agnostic schema for beacon-based front-end telemetry —
|
|
5
|
-
* page-load timing, Core Web Vitals, navigation timing. Provider impls
|
|
6
|
-
* map this shape onto native services:
|
|
7
|
-
*
|
|
8
|
-
* cloudflare-web-analytics → CF Web Analytics (sites + auto-injection rules)
|
|
9
|
-
* sentry-replay → Sentry Performance + Session Replay
|
|
10
|
-
* plausible → Plausible Analytics
|
|
11
|
-
*
|
|
12
|
-
* The kind decouples *configuration* (which hostnames, which token,
|
|
13
|
-
* which privacy mode) from *delivery* (how the beacon `<script>` tag
|
|
14
|
-
* lands in the HTML). For SvelteKit apps, the
|
|
15
|
-
* `@vibesdotdev/cloudflare-web-analytics` package provides a `handle`
|
|
16
|
-
* hook that injects the beacon via `transformPageChunk` — no
|
|
17
|
-
* per-app `app.html` edits required once the kind is wired in.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import * as z from 'zod/v4';
|
|
21
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
22
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
23
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
24
|
-
|
|
25
|
-
const RumPrivacySchema = z.object({
|
|
26
|
-
/** Drop EU visitor data at the beacon level (GDPR fast path). */
|
|
27
|
-
excludeEU: z.boolean().default(false),
|
|
28
|
-
/** Honor Do-Not-Track / Global Privacy Control headers. */
|
|
29
|
-
respectDoNotTrack: z.boolean().default(true),
|
|
30
|
-
/** Strip PII (query params, fragments) from reported URLs. */
|
|
31
|
-
stripQueryParams: z.boolean().default(false)
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export type RumPrivacy = z.infer<typeof RumPrivacySchema>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Where + how the beacon `<script>` lands in the served HTML.
|
|
38
|
-
*
|
|
39
|
-
* app-html → bake the snippet into app.html (manual; pre-Phase 3)
|
|
40
|
-
* sveltekit-hook → injected via `transformPageChunk` in handle hook (preferred)
|
|
41
|
-
* provider-auto → provider auto-injection (CF: only works on non-Worker traffic)
|
|
42
|
-
* custom → caller injects however they want; we just track config
|
|
43
|
-
*/
|
|
44
|
-
const RumInjectionSchema = z.enum([
|
|
45
|
-
'app-html',
|
|
46
|
-
'sveltekit-hook',
|
|
47
|
-
'provider-auto',
|
|
48
|
-
'custom'
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
export type RumInjection = z.infer<typeof RumInjectionSchema>;
|
|
52
|
-
|
|
53
|
-
const RumBaseSchema = RuntimeDescriptorSchema.extend({
|
|
54
|
-
kind: z.literal('infra/rum'),
|
|
55
|
-
adapter: z.string().min(1),
|
|
56
|
-
adapterConfig: z.record(z.string(), z.unknown()).optional(),
|
|
57
|
-
environment: z.string().default('local'),
|
|
58
|
-
/**
|
|
59
|
-
* Public site token (a.k.a. site_tag / beacon token / measurement
|
|
60
|
-
* id). Provider-specific format; safe to commit because it's
|
|
61
|
-
* embedded in client-side HTML for every visitor to see.
|
|
62
|
-
*
|
|
63
|
-
* Pass `{ source: 'secret', key: 'NAME' }` only when the provider
|
|
64
|
-
* explicitly wants a private token — most don't.
|
|
65
|
-
*/
|
|
66
|
-
siteToken: z.union([
|
|
67
|
-
z.string().min(1),
|
|
68
|
-
z.object({ source: z.literal('secret'), key: z.string().min(1) })
|
|
69
|
-
]),
|
|
70
|
-
/** Hostnames the beacon should report from. `*` matches all subdomains. */
|
|
71
|
-
hostnames: z.array(z.string().min(1)).default(['*']),
|
|
72
|
-
injection: RumInjectionSchema.default('sveltekit-hook'),
|
|
73
|
-
privacy: RumPrivacySchema.default(() => ({
|
|
74
|
-
excludeEU: false,
|
|
75
|
-
respectDoNotTrack: true,
|
|
76
|
-
stripQueryParams: false
|
|
77
|
-
})),
|
|
78
|
-
/** Whether the site is currently enabled. Provider impls read+write this. */
|
|
79
|
-
enabled: z.boolean().default(true)
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export type InfraRumDescriptor = z.infer<typeof RumBaseSchema>;
|
|
83
|
-
export type InfraRumDescriptorInput = z.input<typeof RumBaseSchema>;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Snapshot of a single configured RUM site on the provider. Returned
|
|
87
|
-
* by `listSites`; consumed by the CLI for table rendering and drift
|
|
88
|
-
* detection.
|
|
89
|
-
*/
|
|
90
|
-
export interface RumSiteSnapshot {
|
|
91
|
-
/** Provider-assigned site id (CF: site_tag). */
|
|
92
|
-
siteTag: string;
|
|
93
|
-
/** Friendly name (often the apex hostname). */
|
|
94
|
-
name?: string;
|
|
95
|
-
hostnames: string[];
|
|
96
|
-
enabled: boolean;
|
|
97
|
-
injection?: RumInjection;
|
|
98
|
-
/** Page-views captured in the last 24h (when available). */
|
|
99
|
-
pageViews24h?: number;
|
|
100
|
-
createdAt?: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface RumImplementation {
|
|
104
|
-
/** Enumerate the configured RUM sites on the provider. */
|
|
105
|
-
listSites(): Promise<RumSiteSnapshot[]>;
|
|
106
|
-
/** Look up a single site by siteTag. */
|
|
107
|
-
getSite(siteTag: string): Promise<RumSiteSnapshot | null>;
|
|
108
|
-
/**
|
|
109
|
-
* Ensure a site exists matching the descriptor; returns the
|
|
110
|
-
* siteTag (provider-assigned id) and whether it was created or
|
|
111
|
-
* already existed.
|
|
112
|
-
*/
|
|
113
|
-
ensureSite(descriptor: InfraRumDescriptor): Promise<{
|
|
114
|
-
siteTag: string;
|
|
115
|
-
created: boolean;
|
|
116
|
-
}>;
|
|
117
|
-
/** Toggle enabled state. */
|
|
118
|
-
setEnabled(siteTag: string, enabled: boolean): Promise<void>;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const rumKind = createRuntimeKind<InfraRumDescriptor, RumImplementation>({
|
|
122
|
-
id: 'infra/rum',
|
|
123
|
-
descriptorSchema: RumBaseSchema,
|
|
124
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
125
|
-
extractStem
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
export type InfraRumKind = InfraRumDescriptor;
|
|
129
|
-
export type InfraRumKindInput = InfraRumDescriptorInput;
|
|
130
|
-
|
|
131
|
-
export {
|
|
132
|
-
RumBaseSchema as InfraRumDescriptorSchema,
|
|
133
|
-
RumPrivacySchema,
|
|
134
|
-
RumInjectionSchema
|
|
135
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/sandbox
|
|
3
|
-
*
|
|
4
|
-
* Persistent isolated execution environment with shell, filesystem, and
|
|
5
|
-
* subprocess capabilities. Used for agent code execution, tool sandboxing,
|
|
6
|
-
* and long-running background tasks.
|
|
7
|
-
*
|
|
8
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
9
|
-
*
|
|
10
|
-
* - The base defines fields universal across every adapter:
|
|
11
|
-
* id/kind/name + the sandbox shape (entrypoint, image, limits,
|
|
12
|
-
* outboundProxy, liveView, persistent, env).
|
|
13
|
-
* - Adapter-specific fields live under `config`. Each adapter package
|
|
14
|
-
* defines its own concrete schema under its discriminator key.
|
|
15
|
-
*/
|
|
16
|
-
import * as z from 'zod/v4';
|
|
17
|
-
import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
|
|
18
|
-
import type { RuntimeKindDescriptorRecord } from '@vibesdotdev/runtime/schemas/kind';
|
|
19
|
-
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
20
|
-
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
21
|
-
import { deploymentEnvRequirementSchema } from '../schemas.ts';
|
|
22
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
23
|
-
|
|
24
|
-
export const SandboxOutboundProxySchema = z.object({
|
|
25
|
-
binding: z.string().min(1),
|
|
26
|
-
workerPath: z.string().min(1).optional(),
|
|
27
|
-
allowedHosts: z.array(z.string()).default([])
|
|
28
|
-
});
|
|
29
|
-
export type SandboxOutboundProxy = z.infer<typeof SandboxOutboundProxySchema>;
|
|
30
|
-
|
|
31
|
-
export const SandboxResourceLimitsSchema = z.object({
|
|
32
|
-
cpu: z.string().optional(),
|
|
33
|
-
memory: z.string().optional(),
|
|
34
|
-
disk: z.string().optional(),
|
|
35
|
-
maxSubprocesses: z.number().int().positive().optional(),
|
|
36
|
-
timeoutSeconds: z.number().int().positive().optional()
|
|
37
|
-
});
|
|
38
|
-
export type SandboxResourceLimits = z.infer<typeof SandboxResourceLimitsSchema>;
|
|
39
|
-
|
|
40
|
-
const SandboxBaseSchema = RuntimeDescriptorSchema.extend({
|
|
41
|
-
kind: z.literal('infra/sandbox'),
|
|
42
|
-
|
|
43
|
-
/** Shell or script to run on sandbox start. */
|
|
44
|
-
entrypoint: z.string().optional(),
|
|
45
|
-
|
|
46
|
-
/** Container image or template snapshot. */
|
|
47
|
-
image: z.string().optional(),
|
|
48
|
-
|
|
49
|
-
/** Resource limits. */
|
|
50
|
-
limits: SandboxResourceLimitsSchema.optional(),
|
|
51
|
-
|
|
52
|
-
/** Outbound egress proxy (CF Outbound Workers for Sandboxes). */
|
|
53
|
-
outboundProxy: SandboxOutboundProxySchema.optional(),
|
|
54
|
-
|
|
55
|
-
/** Enable Live View for human-in-loop debugging. */
|
|
56
|
-
liveView: z.boolean().optional(),
|
|
57
|
-
|
|
58
|
-
/** Persist state between sessions. */
|
|
59
|
-
persistent: z.boolean().optional(),
|
|
60
|
-
|
|
61
|
-
/** Environment variable requirements. */
|
|
62
|
-
env: z.array(deploymentEnvRequirementSchema).optional()
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export const CloudflareSandboxConfigSchema = z.object({
|
|
66
|
-
/** Container image or template snapshot. */
|
|
67
|
-
image: z.string().optional()
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const DockerSandboxConfigSchema = z.object({
|
|
71
|
-
/** Container image. */
|
|
72
|
-
image: z.string(),
|
|
73
|
-
/** Volume mounts (hostPath: containerPath). */
|
|
74
|
-
volumes: z.record(z.string(), z.string()).optional()
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export const DigitalOceanDropletSandboxConfigSchema = z.object({
|
|
78
|
-
/** Droplet size slug (e.g., 's-2vcpu-2gb'). */
|
|
79
|
-
dropletSize: z.string().min(1)
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export const SandboxConfigSchema = z.union([
|
|
83
|
-
CloudflareSandboxConfigSchema.extend({ adapter: z.literal('cloudflare-sandbox') }),
|
|
84
|
-
DockerSandboxConfigSchema.extend({ adapter: z.literal('docker') }),
|
|
85
|
-
DigitalOceanDropletSandboxConfigSchema.extend({ adapter: z.literal('digitalocean-droplet') })
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
export const SandboxDescriptorSchema = SandboxBaseSchema.extend({
|
|
89
|
-
/**
|
|
90
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
91
|
-
* package defines its own config schema under its discriminator key.
|
|
92
|
-
*/
|
|
93
|
-
config: SandboxConfigSchema.optional()
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
export type SandboxDescriptor = z.infer<typeof SandboxDescriptorSchema>;
|
|
97
|
-
|
|
98
|
-
class DefaultSandboxImplementation {
|
|
99
|
-
constructor(
|
|
100
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
101
|
-
public readonly context: unknown
|
|
102
|
-
) {}
|
|
103
|
-
|
|
104
|
-
get config(): SandboxDescriptor {
|
|
105
|
-
return this.descriptor as SandboxDescriptor;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const sandboxKind = createRuntimeKind<SandboxDescriptor, DefaultSandboxImplementation>({
|
|
110
|
-
id: 'infra/sandbox',
|
|
111
|
-
descriptorSchema: SandboxDescriptorSchema,
|
|
112
|
-
defaultImplementation: DefaultSandboxImplementation,
|
|
113
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
114
|
-
extractStem
|
|
115
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/web-app
|
|
3
|
-
*
|
|
4
|
-
* Describes a deployable web application (SvelteKit, static site, etc.).
|
|
5
|
-
*
|
|
6
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* - The base defines fields universal across every adapter:
|
|
9
|
-
* id/kind/name + the deployment shape every web-app declares
|
|
10
|
-
* (domain, appDir, outputDir, runtime, env, dependsOn).
|
|
11
|
-
* - Adapter-specific fields (cfWorkerName, secretsStoreId, digitaloceanAppName, …)
|
|
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 { deploymentEnvRequirementSchema } from '../schemas.ts';
|
|
21
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
22
|
-
|
|
23
|
-
export const WebAppDependencySchema = z.object({
|
|
24
|
-
serviceId: z.string().min(1),
|
|
25
|
-
reason: z.string().optional()
|
|
26
|
-
});
|
|
27
|
-
export type WebAppDependency = z.infer<typeof WebAppDependencySchema>;
|
|
28
|
-
|
|
29
|
-
const WebAppBaseSchema = RuntimeDescriptorSchema.extend({
|
|
30
|
-
kind: z.literal('infra/web-app'),
|
|
31
|
-
|
|
32
|
-
/** Primary domain for this app (e.g., 'auth.vibes.dev'). */
|
|
33
|
-
domain: z.string().min(1),
|
|
34
|
-
|
|
35
|
-
/** Application source directory (e.g., 'apps/auth-web'). */
|
|
36
|
-
appDir: z.string().min(1),
|
|
37
|
-
|
|
38
|
-
/** Build output directory (e.g., '.svelte-kit/cloudflare'). */
|
|
39
|
-
outputDir: z.string().min(1),
|
|
40
|
-
|
|
41
|
-
/** Runtime environment for app deployments. */
|
|
42
|
-
runtime: z.enum(['edge', 'node']),
|
|
43
|
-
|
|
44
|
-
/** Environment variable requirements. */
|
|
45
|
-
env: z.array(deploymentEnvRequirementSchema).optional(),
|
|
46
|
-
|
|
47
|
-
/** Service dependencies. */
|
|
48
|
-
dependsOn: z.array(WebAppDependencySchema).optional()
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const CloudflareWorkersWebAppConfigSchema = z.object({
|
|
52
|
-
/** Cloudflare Workers script name (e.g., "vibes-ai"). */
|
|
53
|
-
cfWorkerName: z.string().min(1),
|
|
54
|
-
/** Path to the `_worker.js` entry point relative to outputDir. */
|
|
55
|
-
workerEntry: z.string().min(1).default('_worker.js'),
|
|
56
|
-
/** Compatibility date for wrangler. */
|
|
57
|
-
compatibilityDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
58
|
-
/** Compatibility flags for wrangler. */
|
|
59
|
-
compatibilityFlags: z.array(z.string()).default(['nodejs_compat']),
|
|
60
|
-
/** Environment variables to include. */
|
|
61
|
-
env: z.record(z.string(), z.string()).default({}),
|
|
62
|
-
/** Cloudflare Secrets Store ID for secret bindings. */
|
|
63
|
-
secretsStoreId: z.string().min(1).optional()
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const DigitalOceanAppWebAppConfigSchema = z.object({
|
|
67
|
-
/** DigitalOcean App name. */
|
|
68
|
-
digitaloceanAppName: z.string().min(1)
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
export const WebAppConfigSchema = z.union([
|
|
72
|
-
CloudflareWorkersWebAppConfigSchema.extend({ adapter: z.literal('cloudflare-workers') }),
|
|
73
|
-
DigitalOceanAppWebAppConfigSchema.extend({ adapter: z.literal('digitalocean-apps') })
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
export const WebAppDescriptorSchema = WebAppBaseSchema.extend({
|
|
77
|
-
/**
|
|
78
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
79
|
-
* package defines its own config schema under its discriminator key.
|
|
80
|
-
*/
|
|
81
|
-
config: WebAppConfigSchema.optional()
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
export type WebAppDescriptor = z.infer<typeof WebAppDescriptorSchema>;
|
|
85
|
-
|
|
86
|
-
class DefaultWebAppImplementation {
|
|
87
|
-
constructor(
|
|
88
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
89
|
-
public readonly context: unknown
|
|
90
|
-
) {}
|
|
91
|
-
|
|
92
|
-
get config(): WebAppDescriptor {
|
|
93
|
-
return this.descriptor as WebAppDescriptor;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const webAppKind = createRuntimeKind<WebAppDescriptor, DefaultWebAppImplementation>({
|
|
98
|
-
id: 'infra/web-app',
|
|
99
|
-
descriptorSchema: WebAppDescriptorSchema,
|
|
100
|
-
defaultImplementation: DefaultWebAppImplementation,
|
|
101
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
102
|
-
extractStem
|
|
103
|
-
});
|
package/src/kinds/worker.kind.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind: infra/worker
|
|
3
|
-
*
|
|
4
|
-
* Describes a background worker process.
|
|
5
|
-
*
|
|
6
|
-
* Schema shape: strict common base + `config` discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* - The base defines fields universal across adapters: id/kind/name +
|
|
9
|
-
* the worker shape (entrypoint, queues, concurrency, scaling, env).
|
|
10
|
-
* - Adapter-specific fields (namespace, image, healthPort, …) live under
|
|
11
|
-
* `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 { deploymentEnvRequirementSchema } from '../schemas.ts';
|
|
19
|
-
import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
|
|
20
|
-
|
|
21
|
-
export const WorkerScalingSchema = z.object({
|
|
22
|
-
min: z.number().int().nonnegative().default(1),
|
|
23
|
-
max: z.number().int().positive().default(1),
|
|
24
|
-
cpu: z.string().optional(),
|
|
25
|
-
memory: z.string().optional()
|
|
26
|
-
});
|
|
27
|
-
export type WorkerScaling = z.infer<typeof WorkerScalingSchema>;
|
|
28
|
-
|
|
29
|
-
const WorkerBaseSchema = RuntimeDescriptorSchema.extend({
|
|
30
|
-
kind: z.literal('infra/worker'),
|
|
31
|
-
|
|
32
|
-
/** Path to worker entrypoint (e.g., 'packages/workers/src/ai/entrypoint.ts'). */
|
|
33
|
-
entrypoint: z.string().min(1).optional(),
|
|
34
|
-
|
|
35
|
-
/** Queue names this worker consumes from. */
|
|
36
|
-
queues: z.array(z.string().min(1)).optional(),
|
|
37
|
-
|
|
38
|
-
/** Worker concurrency. */
|
|
39
|
-
concurrency: z.number().int().positive().optional(),
|
|
40
|
-
|
|
41
|
-
/** Scaling configuration. */
|
|
42
|
-
scaling: WorkerScalingSchema.optional(),
|
|
43
|
-
|
|
44
|
-
/** Environment variable requirements. */
|
|
45
|
-
env: z.array(deploymentEnvRequirementSchema).optional()
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export const DoksDeploymentWorkerConfigSchema = z.object({
|
|
49
|
-
/** Kubernetes namespace (default: vibes). */
|
|
50
|
-
namespace: z.string().min(1).default('vibes'),
|
|
51
|
-
/** Container image (default: vibes/{id}:latest). */
|
|
52
|
-
image: z.string().min(1).optional(),
|
|
53
|
-
/** Health probe port (default: 8080). */
|
|
54
|
-
healthPort: z.number().int().positive().default(8080),
|
|
55
|
-
/** Health probe path (default: /healthz). */
|
|
56
|
-
healthPath: z.string().min(1).default('/healthz'),
|
|
57
|
-
/** Readiness probe path (default: /readyz). */
|
|
58
|
-
readyPath: z.string().min(1).default('/readyz')
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export const CloudflareWorkersWorkerConfigSchema = z.object({
|
|
62
|
-
/** Cloudflare Workers script name (e.g., "vibes-jobs"). */
|
|
63
|
-
cfWorkerName: z.string().min(1),
|
|
64
|
-
/** Path to the `_worker.js` entry point relative to outputDir. */
|
|
65
|
-
workerEntry: z.string().min(1).default('_worker.js'),
|
|
66
|
-
/** Compatibility date for wrangler. */
|
|
67
|
-
compatibilityDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
68
|
-
/** Compatibility flags for wrangler. */
|
|
69
|
-
compatibilityFlags: z.array(z.string()).default(['nodejs_compat']),
|
|
70
|
-
/** Environment variables to include. */
|
|
71
|
-
env: z.record(z.string(), z.string()).default({}),
|
|
72
|
-
/** Cloudflare Secrets Store ID for secret bindings. */
|
|
73
|
-
secretsStoreId: z.string().min(1).optional(),
|
|
74
|
-
/**
|
|
75
|
-
* Detailed queue-consumer config. When present, these override the
|
|
76
|
-
* coarse `queues: string[]` field on the base descriptor and let
|
|
77
|
-
* declarations control batch size, retries, and dead-letter routing.
|
|
78
|
-
*/
|
|
79
|
-
consumers: z
|
|
80
|
-
.array(
|
|
81
|
-
z.object({
|
|
82
|
-
queue: z.string().min(1),
|
|
83
|
-
maxBatchSize: z.number().int().positive().default(10),
|
|
84
|
-
maxRetries: z.number().int().min(0).default(3),
|
|
85
|
-
deadLetterQueue: z.string().optional()
|
|
86
|
-
})
|
|
87
|
-
)
|
|
88
|
-
.default([]),
|
|
89
|
-
/** Durable Object class bindings. */
|
|
90
|
-
durableObjects: z
|
|
91
|
-
.array(
|
|
92
|
-
z.object({
|
|
93
|
-
binding: z.string().regex(/^[_A-Z0-9]+$/),
|
|
94
|
-
className: z.string().min(1),
|
|
95
|
-
scriptName: z.string().min(1).optional()
|
|
96
|
-
})
|
|
97
|
-
)
|
|
98
|
-
.default([]),
|
|
99
|
-
/** Durable Object migrations. */
|
|
100
|
-
migrations: z
|
|
101
|
-
.array(
|
|
102
|
-
z.object({
|
|
103
|
-
tag: z.string().min(1),
|
|
104
|
-
newClasses: z.array(z.string().min(1)).optional(),
|
|
105
|
-
renamedClasses: z
|
|
106
|
-
.array(z.object({ from: z.string().min(1), to: z.string().min(1) }))
|
|
107
|
-
.optional(),
|
|
108
|
-
deletedClasses: z.array(z.string().min(1)).optional(),
|
|
109
|
-
newSqliteClasses: z.array(z.string().min(1)).optional()
|
|
110
|
-
})
|
|
111
|
-
)
|
|
112
|
-
.default([]),
|
|
113
|
-
/** Service bindings — call other Workers from this Worker. */
|
|
114
|
-
services: z
|
|
115
|
-
.array(
|
|
116
|
-
z.object({
|
|
117
|
-
binding: z.string().regex(/^[_A-Z0-9]+$/),
|
|
118
|
-
service: z.string().min(1),
|
|
119
|
-
environment: z.string().min(1).optional()
|
|
120
|
-
})
|
|
121
|
-
)
|
|
122
|
-
.default([]),
|
|
123
|
-
/** D1 database bindings. */
|
|
124
|
-
d1Databases: z
|
|
125
|
-
.array(
|
|
126
|
-
z.object({
|
|
127
|
-
binding: z.string().regex(/^[_A-Z0-9]+$/),
|
|
128
|
-
databaseName: z.string().min(1),
|
|
129
|
-
databaseId: z.string().min(1)
|
|
130
|
-
})
|
|
131
|
-
)
|
|
132
|
-
.default([]),
|
|
133
|
-
/** KV namespace bindings. */
|
|
134
|
-
kvNamespaces: z
|
|
135
|
-
.array(
|
|
136
|
-
z.object({
|
|
137
|
-
binding: z.string().min(1),
|
|
138
|
-
id: z.string().min(1)
|
|
139
|
-
})
|
|
140
|
-
)
|
|
141
|
-
.default([]),
|
|
142
|
-
/** R2 bucket bindings. */
|
|
143
|
-
r2Buckets: z
|
|
144
|
-
.array(
|
|
145
|
-
z.object({
|
|
146
|
-
binding: z.string().min(1),
|
|
147
|
-
bucketName: z.string().min(1)
|
|
148
|
-
})
|
|
149
|
-
)
|
|
150
|
-
.default([]),
|
|
151
|
-
/** Queue producer bindings (worker can also produce to queues). */
|
|
152
|
-
queueProducers: z
|
|
153
|
-
.array(
|
|
154
|
-
z.object({
|
|
155
|
-
queue: z.string().min(1),
|
|
156
|
-
binding: z.string().min(1)
|
|
157
|
-
})
|
|
158
|
-
)
|
|
159
|
-
.default([]),
|
|
160
|
-
/** Enable smart placement. */
|
|
161
|
-
smartPlacement: z.boolean().default(false),
|
|
162
|
-
/**
|
|
163
|
-
* Whether this is a job-consumer Worker. When true, deploy step
|
|
164
|
-
* auto-injects the JOB_RESULT_STORE Durable Object binding +
|
|
165
|
-
* initial migration via `generateJobConsumerWorkerConfig` from
|
|
166
|
-
* `@vibesdotdev/infra-cloudflare`.
|
|
167
|
-
*/
|
|
168
|
-
jobConsumer: z.boolean().default(false)
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
export const WorkerConfigSchema = z.union([
|
|
172
|
-
DoksDeploymentWorkerConfigSchema.extend({ adapter: z.literal('doks-deployment') }),
|
|
173
|
-
CloudflareWorkersWorkerConfigSchema.extend({ adapter: z.literal('cloudflare-workers') })
|
|
174
|
-
]);
|
|
175
|
-
|
|
176
|
-
export const WorkerDescriptorSchema = WorkerBaseSchema.extend({
|
|
177
|
-
/**
|
|
178
|
-
* Adapter-specific configuration. Discriminated union — each adapter
|
|
179
|
-
* package defines its own config schema under its discriminator key.
|
|
180
|
-
*/
|
|
181
|
-
config: WorkerConfigSchema.optional()
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
export type WorkerDescriptor = z.infer<typeof WorkerDescriptorSchema>;
|
|
185
|
-
|
|
186
|
-
class DefaultWorkerImplementation {
|
|
187
|
-
constructor(
|
|
188
|
-
public readonly descriptor: RuntimeDescriptor,
|
|
189
|
-
public readonly context: unknown
|
|
190
|
-
) {}
|
|
191
|
-
|
|
192
|
-
get config(): WorkerDescriptor {
|
|
193
|
-
return this.descriptor as WorkerDescriptor;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export const workerKind = createRuntimeKind<WorkerDescriptor, DefaultWorkerImplementation>({
|
|
198
|
-
id: 'infra/worker',
|
|
199
|
-
descriptorSchema: WorkerDescriptorSchema,
|
|
200
|
-
defaultImplementation: DefaultWorkerImplementation,
|
|
201
|
-
discoveryPattern: INFRA_DISCOVERY_PATTERN,
|
|
202
|
-
extractStem
|
|
203
|
-
});
|