@vibesdotdev/infra-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +78 -0
  2. package/SPEC.md +169 -0
  3. package/dist/bootstrap/index.d.ts +5 -0
  4. package/dist/bootstrap/index.d.ts.map +1 -0
  5. package/dist/bootstrap/index.js +4 -0
  6. package/dist/bootstrap/index.js.map +1 -0
  7. package/dist/bootstrap/seed.descriptor.d.ts +31 -0
  8. package/dist/bootstrap/seed.descriptor.d.ts.map +1 -0
  9. package/dist/bootstrap/seed.descriptor.js +18 -0
  10. package/dist/bootstrap/seed.descriptor.js.map +1 -0
  11. package/dist/bootstrap/seed.impl-shape.d.ts +5 -0
  12. package/dist/bootstrap/seed.impl-shape.d.ts.map +1 -0
  13. package/dist/bootstrap/seed.impl-shape.js +2 -0
  14. package/dist/bootstrap/seed.impl-shape.js.map +1 -0
  15. package/dist/bootstrap/seed.kind.d.ts +5 -0
  16. package/dist/bootstrap/seed.kind.d.ts.map +1 -0
  17. package/dist/bootstrap/seed.kind.js +14 -0
  18. package/dist/bootstrap/seed.kind.js.map +1 -0
  19. package/dist/bootstrap/seed.runner.d.ts +18 -0
  20. package/dist/bootstrap/seed.runner.d.ts.map +1 -0
  21. package/dist/bootstrap/seed.runner.js +59 -0
  22. package/dist/bootstrap/seed.runner.js.map +1 -0
  23. package/dist/credentials/resolve.d.ts +80 -0
  24. package/dist/credentials/resolve.d.ts.map +1 -0
  25. package/dist/credentials/resolve.js +128 -0
  26. package/dist/credentials/resolve.js.map +1 -0
  27. package/dist/deployment.d.ts +9 -0
  28. package/dist/deployment.d.ts.map +1 -0
  29. package/dist/deployment.js +25 -0
  30. package/dist/deployment.js.map +1 -0
  31. package/dist/index.d.ts +32 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +21 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/infra.plugin.d.ts +18 -0
  36. package/dist/infra.plugin.d.ts.map +1 -0
  37. package/dist/infra.plugin.js +52 -0
  38. package/dist/infra.plugin.js.map +1 -0
  39. package/dist/kinds/alerts.kind.d.ts +192 -0
  40. package/dist/kinds/alerts.kind.d.ts.map +1 -0
  41. package/dist/kinds/alerts.kind.js +116 -0
  42. package/dist/kinds/alerts.kind.js.map +1 -0
  43. package/dist/kinds/artifact.kind.d.ts +96 -0
  44. package/dist/kinds/artifact.kind.d.ts.map +1 -0
  45. package/dist/kinds/artifact.kind.js +53 -0
  46. package/dist/kinds/artifact.kind.js.map +1 -0
  47. package/dist/kinds/cache.kind.d.ts +128 -0
  48. package/dist/kinds/cache.kind.d.ts.map +1 -0
  49. package/dist/kinds/cache.kind.js +90 -0
  50. package/dist/kinds/cache.kind.js.map +1 -0
  51. package/dist/kinds/database.kind.d.ts +141 -0
  52. package/dist/kinds/database.kind.d.ts.map +1 -0
  53. package/dist/kinds/database.kind.js +103 -0
  54. package/dist/kinds/database.kind.js.map +1 -0
  55. package/dist/kinds/discovery.d.ts +20 -0
  56. package/dist/kinds/discovery.d.ts.map +1 -0
  57. package/dist/kinds/discovery.js +25 -0
  58. package/dist/kinds/discovery.js.map +1 -0
  59. package/dist/kinds/git-hosting.kind.d.ts +98 -0
  60. package/dist/kinds/git-hosting.kind.d.ts.map +1 -0
  61. package/dist/kinds/git-hosting.kind.js +81 -0
  62. package/dist/kinds/git-hosting.kind.js.map +1 -0
  63. package/dist/kinds/index.d.ts +16 -0
  64. package/dist/kinds/index.d.ts.map +1 -0
  65. package/dist/kinds/index.js +16 -0
  66. package/dist/kinds/index.js.map +1 -0
  67. package/dist/kinds/logs.kind.d.ts +91 -0
  68. package/dist/kinds/logs.kind.d.ts.map +1 -0
  69. package/dist/kinds/logs.kind.js +73 -0
  70. package/dist/kinds/logs.kind.js.map +1 -0
  71. package/dist/kinds/object-storage.kind.d.ts +85 -0
  72. package/dist/kinds/object-storage.kind.d.ts.map +1 -0
  73. package/dist/kinds/object-storage.kind.js +81 -0
  74. package/dist/kinds/object-storage.kind.js.map +1 -0
  75. package/dist/kinds/observability.kind.d.ts +176 -0
  76. package/dist/kinds/observability.kind.d.ts.map +1 -0
  77. package/dist/kinds/observability.kind.js +120 -0
  78. package/dist/kinds/observability.kind.js.map +1 -0
  79. package/dist/kinds/package-registry.kind.d.ts +89 -0
  80. package/dist/kinds/package-registry.kind.d.ts.map +1 -0
  81. package/dist/kinds/package-registry.kind.js +78 -0
  82. package/dist/kinds/package-registry.kind.js.map +1 -0
  83. package/dist/kinds/queue.kind.d.ts +113 -0
  84. package/dist/kinds/queue.kind.d.ts.map +1 -0
  85. package/dist/kinds/queue.kind.js +86 -0
  86. package/dist/kinds/queue.kind.js.map +1 -0
  87. package/dist/kinds/rum.kind.d.ts +113 -0
  88. package/dist/kinds/rum.kind.d.ts.map +1 -0
  89. package/dist/kinds/rum.kind.js +80 -0
  90. package/dist/kinds/rum.kind.js.map +1 -0
  91. package/dist/kinds/sandbox.kind.d.ts +111 -0
  92. package/dist/kinds/sandbox.kind.d.ts.map +1 -0
  93. package/dist/kinds/sandbox.kind.js +94 -0
  94. package/dist/kinds/sandbox.kind.js.map +1 -0
  95. package/dist/kinds/web-app.kind.d.ts +99 -0
  96. package/dist/kinds/web-app.kind.d.ts.map +1 -0
  97. package/dist/kinds/web-app.kind.js +86 -0
  98. package/dist/kinds/web-app.kind.js.map +1 -0
  99. package/dist/kinds/worker.kind.d.ts +244 -0
  100. package/dist/kinds/worker.kind.d.ts.map +1 -0
  101. package/dist/kinds/worker.kind.js +171 -0
  102. package/dist/kinds/worker.kind.js.map +1 -0
  103. package/dist/schemas.d.ts +125 -0
  104. package/dist/schemas.d.ts.map +1 -0
  105. package/dist/schemas.js +102 -0
  106. package/dist/schemas.js.map +1 -0
  107. package/package.json +92 -0
  108. package/src/bootstrap/index.ts +15 -0
  109. package/src/bootstrap/seed.descriptor.ts +24 -0
  110. package/src/bootstrap/seed.impl-shape.ts +5 -0
  111. package/src/bootstrap/seed.kind.ts +26 -0
  112. package/src/bootstrap/seed.runner.ts +87 -0
  113. package/src/credentials/resolve.ts +205 -0
  114. package/src/deployment.ts +57 -0
  115. package/src/index.ts +149 -0
  116. package/src/infra.plugin.ts +54 -0
  117. package/src/kinds/alerts.kind.ts +164 -0
  118. package/src/kinds/artifact.kind.ts +96 -0
  119. package/src/kinds/cache.kind.ts +104 -0
  120. package/src/kinds/database.kind.ts +120 -0
  121. package/src/kinds/discovery.ts +26 -0
  122. package/src/kinds/git-hosting.kind.ts +100 -0
  123. package/src/kinds/index.ts +139 -0
  124. package/src/kinds/logs.kind.ts +104 -0
  125. package/src/kinds/object-storage.kind.ts +101 -0
  126. package/src/kinds/observability.kind.ts +178 -0
  127. package/src/kinds/package-registry.kind.ts +95 -0
  128. package/src/kinds/queue.kind.ts +102 -0
  129. package/src/kinds/rum.kind.ts +135 -0
  130. package/src/kinds/sandbox.kind.ts +115 -0
  131. package/src/kinds/web-app.kind.ts +103 -0
  132. package/src/kinds/worker.kind.ts +203 -0
  133. package/src/schemas.ts +127 -0
@@ -0,0 +1,96 @@
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';
@@ -0,0 +1,104 @@
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
+ });
@@ -0,0 +1,120 @@
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
+ });
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,100 @@
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.vibes.dev'). */
33
+ url: z.string().url(),
34
+
35
+ /** Hostname for DNS resolution (e.g. 'git.vibes.dev'). */
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
+ });
@@ -0,0 +1,139 @@
1
+ export { webAppKind, WebAppDescriptorSchema, WebAppConfigSchema, CloudflareWorkersWebAppConfigSchema, DigitalOceanAppWebAppConfigSchema, type WebAppDescriptor, type WebAppDependency } from './web-app.kind';
2
+ export {
3
+ workerKind,
4
+ WorkerDescriptorSchema,
5
+ WorkerConfigSchema,
6
+ DoksDeploymentWorkerConfigSchema,
7
+ WorkerScalingSchema,
8
+ type WorkerDescriptor,
9
+ type WorkerScaling
10
+ } from './worker.kind';
11
+ export {
12
+ databaseKind,
13
+ DatabaseDescriptorSchema,
14
+ DatabaseConfigSchema,
15
+ DoksDatabaseConfigSchema,
16
+ DOManagedPostgresConfigSchema,
17
+ TursoDatabaseConfigSchema,
18
+ CloudflareD1ConfigSchema,
19
+ DatabaseBackupSchema,
20
+ type DatabaseDescriptor,
21
+ type DatabaseBackup
22
+ } from './database.kind';
23
+ export {
24
+ queueKind,
25
+ QueueDescriptorSchema,
26
+ QueueConfigSchema,
27
+ DoksQueueConfigSchema,
28
+ QueueTopicSchema,
29
+ type QueueDescriptor,
30
+ type QueueTopic
31
+ } from './queue.kind';
32
+ export { cacheKind, CacheDescriptorSchema, CacheConfigSchema, DOManagedRedisConfigSchema, type CacheDescriptor } from './cache.kind';
33
+ export {
34
+ objectStorageKind,
35
+ ObjectStorageDescriptorSchema,
36
+ ObjectStorageConfigSchema,
37
+ DOSpacesConfigSchema,
38
+ CorsRuleSchema,
39
+ LifecycleRuleSchema,
40
+ type ObjectStorageDescriptor,
41
+ type CorsRule,
42
+ type LifecycleRule
43
+ } from './object-storage.kind';
44
+ export {
45
+ sandboxKind,
46
+ SandboxDescriptorSchema,
47
+ SandboxConfigSchema,
48
+ CloudflareSandboxConfigSchema,
49
+ DockerSandboxConfigSchema,
50
+ DigitalOceanDropletSandboxConfigSchema,
51
+ SandboxOutboundProxySchema,
52
+ SandboxResourceLimitsSchema,
53
+ type SandboxDescriptor,
54
+ type SandboxOutboundProxy,
55
+ type SandboxResourceLimits
56
+ } from './sandbox.kind';
57
+ export {
58
+ gitHostingKind,
59
+ GitHostingDescriptorSchema,
60
+ GitHostingConfigSchema,
61
+ GiteaDoksGitHostingConfigSchema,
62
+ GitHostingTypeSchema,
63
+ GitHostingAuthMethodSchema,
64
+ type GitHostingDescriptor,
65
+ type GitHostingType,
66
+ type GitHostingAuthMethod
67
+ } from './git-hosting.kind';
68
+ export {
69
+ packageRegistryKind,
70
+ PackageRegistryDescriptorSchema,
71
+ PackageRegistryConfigSchema,
72
+ VerdaccioDoksPackageRegistryConfigSchema,
73
+ PackageRegistryTypeSchema,
74
+ type PackageRegistryDescriptor,
75
+ type PackageRegistryType
76
+ } from './package-registry.kind';
77
+ export {
78
+ logsKind,
79
+ InfraLogsDescriptorSchema,
80
+ type InfraLogsDescriptor,
81
+ type InfraLogsDescriptorInput,
82
+ type InfraLogsKind,
83
+ type InfraLogsKindInput,
84
+ type LogsImplementation
85
+ } from './logs.kind';
86
+ export {
87
+ artifactKind,
88
+ ArtifactDescriptorSchema,
89
+ type ArtifactDescriptor,
90
+ type ArtifactGenerator,
91
+ type ArtifactOutput
92
+ } from './artifact.kind';
93
+ export {
94
+ alertsKind,
95
+ InfraAlertsDescriptorSchema,
96
+ AlertPolicySchema,
97
+ AlertMechanismSchema,
98
+ AlertTypeSchema,
99
+ AlertWindowSchema,
100
+ type InfraAlertsDescriptor,
101
+ type InfraAlertsDescriptorInput,
102
+ type InfraAlertsKind,
103
+ type InfraAlertsKindInput,
104
+ type AlertsImplementation,
105
+ type AlertPolicy,
106
+ type AlertMechanism,
107
+ type AlertType
108
+ } from './alerts.kind.ts';
109
+ export {
110
+ observabilityKind,
111
+ InfraObservabilityDescriptorSchema,
112
+ ObservabilityScopeSchema,
113
+ ObservabilitySettingsSchema,
114
+ type InfraObservabilityDescriptor,
115
+ type InfraObservabilityDescriptorInput,
116
+ type InfraObservabilityKind,
117
+ type InfraObservabilityKindInput,
118
+ type ObservabilityImplementation,
119
+ type ObservabilityScope,
120
+ type ObservabilitySettings,
121
+ type ObservabilitySnapshot,
122
+ type SetObservabilityInput,
123
+ type SetObservabilityResult
124
+ } from './observability.kind.ts';
125
+ export {
126
+ rumKind,
127
+ InfraRumDescriptorSchema,
128
+ RumPrivacySchema,
129
+ RumInjectionSchema,
130
+ type InfraRumDescriptor,
131
+ type InfraRumDescriptorInput,
132
+ type InfraRumKind,
133
+ type InfraRumKindInput,
134
+ type RumImplementation,
135
+ type RumSiteSnapshot,
136
+ type RumPrivacy,
137
+ type RumInjection
138
+ } from './rum.kind.ts';
139
+ export { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Infra Logs Kind
3
+ *
4
+ * Descriptor schema for log sources (Workers, Pages, D1, etc.)
5
+ * Provides programmatic access to logs for tailing, queries, and analytics.
6
+ */
7
+
8
+ import * as z from 'zod/v4';
9
+ import { createRuntimeKind } from '@vibesdotdev/runtime/factory/kind';
10
+ import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
11
+ import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
12
+ import { INFRA_DISCOVERY_PATTERN, extractStem } from './discovery.ts';
13
+
14
+ const LogsBaseSchema = RuntimeDescriptorSchema.extend({
15
+ kind: z.literal('infra/logs'),
16
+ /** Adapter type (e.g., 'cloudflare-logs', 'datadog', 'splunk') */
17
+ adapter: z.string().min(1),
18
+ /** Adapter-specific configuration */
19
+ adapterConfig: z.record(z.string(), z.unknown()).optional(),
20
+ /** Log sources to monitor */
21
+ sources: z
22
+ .array(
23
+ z.object({
24
+ /** Source type */
25
+ type: z.enum(['worker', 'pages', 'd1', 'r2', 'kv']),
26
+ /** Source name/identifier */
27
+ name: z.string().min(1),
28
+ /** Optional environment filter */
29
+ environment: z.string().optional()
30
+ })
31
+ )
32
+ .default([]),
33
+ /** Default retention period */
34
+ retention: z
35
+ .object({
36
+ /** Hot storage (immediately accessible) */
37
+ hotDays: z.number().int().positive().default(7),
38
+ /** Cold storage (requires retrieval) */
39
+ coldDays: z.number().int().positive().default(30)
40
+ })
41
+ .optional(),
42
+ /** Alerting configuration */
43
+ alerts: z
44
+ .array(
45
+ z.object({
46
+ /** Alert name */
47
+ name: z.string().min(1),
48
+ /** Alert condition */
49
+ condition: z.enum(['errorRate', 'duration', 'invocationCount']),
50
+ /** Threshold value */
51
+ threshold: z.number(),
52
+ /** Time window for evaluation */
53
+ window: z.string(),
54
+ /** Notification channels */
55
+ channels: z.array(z.string()).default([])
56
+ })
57
+ )
58
+ .default([])
59
+ });
60
+
61
+ export const InfraLogsDescriptorSchema = LogsBaseSchema;
62
+ export type InfraLogsDescriptor = z.infer<typeof InfraLogsDescriptorSchema>;
63
+ export type InfraLogsDescriptorInput = z.input<typeof InfraLogsDescriptorSchema>;
64
+
65
+ export interface LogsImplementation {
66
+ /** Stream logs in real-time (returns WebSocket URL) */
67
+ tailLogs(sourceName: string, options?: { status?: 'ok' | 'error' | 'canceled'; limit?: number }): Promise<{ tailId: string; websocketUrl: string }>;
68
+ /** Stop a log tail session */
69
+ stopTail(sourceName: string, tailId: string): Promise<void>;
70
+ /** List active tail sessions */
71
+ listTails(sourceName: string): Promise<Array<{ id: string; createdAt: string }>>;
72
+ /** Get analytics summary */
73
+ getAnalytics(sourceName: string, timeRange?: { timeStart: string; timeEnd?: string }): Promise<{ totalInvocations: number; errorCount: number; errorRate: number; avgDurationMs: number; p99DurationMs: number; totalCpuTimeMs: number }>;
74
+ /** Get error rate */
75
+ getErrorRate(sourceName: string, timeRange?: { timeStart: string; timeEnd?: string }): Promise<number>;
76
+ }
77
+
78
+ export interface DefaultLogsImplementation {
79
+ generateConfig: () => InfraLogsDescriptor;
80
+ }
81
+
82
+ class DefaultLogsImplementationClass implements DefaultLogsImplementation {
83
+ generateConfig(): InfraLogsDescriptor {
84
+ return {
85
+ kind: 'infra/logs',
86
+ id: 'default-logs',
87
+ name: 'Default Logs',
88
+ adapter: 'unknown',
89
+ sources: [],
90
+ alerts: []
91
+ };
92
+ }
93
+ }
94
+
95
+ export const logsKind = createRuntimeKind<InfraLogsDescriptor, DefaultLogsImplementation>({
96
+ id: 'infra/logs',
97
+ descriptorSchema: InfraLogsDescriptorSchema,
98
+ defaultImplementation: DefaultLogsImplementationClass,
99
+ discoveryPattern: INFRA_DISCOVERY_PATTERN,
100
+ extractStem
101
+ });
102
+
103
+ export type InfraLogsKind = InfraLogsDescriptor;
104
+ export type InfraLogsKindInput = InfraLogsDescriptorInput;