@mizchi/k1c 0.1.0

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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/dist/canary/dispatcher-template.d.ts +17 -0
  4. package/dist/canary/dispatcher-template.js +42 -0
  5. package/dist/canary/effects-cloudflare.d.ts +9 -0
  6. package/dist/canary/effects-cloudflare.js +66 -0
  7. package/dist/canary/rollout-command.d.ts +15 -0
  8. package/dist/canary/rollout-command.js +92 -0
  9. package/dist/canary/runtime.d.ts +59 -0
  10. package/dist/canary/runtime.js +138 -0
  11. package/dist/canary/state-machine.d.ts +72 -0
  12. package/dist/canary/state-machine.js +161 -0
  13. package/dist/cli/args.d.ts +51 -0
  14. package/dist/cli/args.js +239 -0
  15. package/dist/cli/canary-integration.d.ts +11 -0
  16. package/dist/cli/canary-integration.js +101 -0
  17. package/dist/cli/format.d.ts +4 -0
  18. package/dist/cli/format.js +44 -0
  19. package/dist/cli/main.d.ts +3 -0
  20. package/dist/cli/main.js +158 -0
  21. package/dist/cli/run.d.ts +16 -0
  22. package/dist/cli/run.js +246 -0
  23. package/dist/manifest/lower.d.ts +22 -0
  24. package/dist/manifest/lower.js +913 -0
  25. package/dist/manifest/parse.d.ts +22 -0
  26. package/dist/manifest/parse.js +106 -0
  27. package/dist/manifest/schemas.d.ts +10359 -0
  28. package/dist/manifest/schemas.js +309 -0
  29. package/dist/manifest/types.d.ts +246 -0
  30. package/dist/manifest/types.js +12 -0
  31. package/dist/providers/configmap.d.ts +8 -0
  32. package/dist/providers/configmap.js +29 -0
  33. package/dist/providers/custom-domain.d.ts +11 -0
  34. package/dist/providers/custom-domain.js +120 -0
  35. package/dist/providers/d1-database.d.ts +9 -0
  36. package/dist/providers/d1-database.js +106 -0
  37. package/dist/providers/dispatch-namespace.d.ts +8 -0
  38. package/dist/providers/dispatch-namespace.js +100 -0
  39. package/dist/providers/dns-record.d.ts +14 -0
  40. package/dist/providers/dns-record.js +136 -0
  41. package/dist/providers/errors.d.ts +8 -0
  42. package/dist/providers/errors.js +64 -0
  43. package/dist/providers/hyperdrive.d.ts +27 -0
  44. package/dist/providers/hyperdrive.js +168 -0
  45. package/dist/providers/index.d.ts +6 -0
  46. package/dist/providers/index.js +36 -0
  47. package/dist/providers/kv-namespace.d.ts +8 -0
  48. package/dist/providers/kv-namespace.js +90 -0
  49. package/dist/providers/logpush-job.d.ts +17 -0
  50. package/dist/providers/logpush-job.js +181 -0
  51. package/dist/providers/queue.d.ts +10 -0
  52. package/dist/providers/queue.js +124 -0
  53. package/dist/providers/r2-bucket.d.ts +11 -0
  54. package/dist/providers/r2-bucket.js +98 -0
  55. package/dist/providers/registry.d.ts +9 -0
  56. package/dist/providers/registry.js +22 -0
  57. package/dist/providers/secret.d.ts +8 -0
  58. package/dist/providers/secret.js +30 -0
  59. package/dist/providers/types.d.ts +69 -0
  60. package/dist/providers/types.js +12 -0
  61. package/dist/providers/vectorize.d.ts +11 -0
  62. package/dist/providers/vectorize.js +110 -0
  63. package/dist/providers/worker.d.ts +106 -0
  64. package/dist/providers/worker.js +430 -0
  65. package/dist/providers/workflow.d.ts +10 -0
  66. package/dist/providers/workflow.js +103 -0
  67. package/dist/reconciler/apply.d.ts +10 -0
  68. package/dist/reconciler/apply.js +114 -0
  69. package/dist/reconciler/fake-provider.d.ts +48 -0
  70. package/dist/reconciler/fake-provider.js +83 -0
  71. package/dist/reconciler/plan.d.ts +6 -0
  72. package/dist/reconciler/plan.js +124 -0
  73. package/dist/reconciler/topo.d.ts +10 -0
  74. package/dist/reconciler/topo.js +53 -0
  75. package/dist/reconciler/types.d.ts +54 -0
  76. package/dist/reconciler/types.js +8 -0
  77. package/package.json +61 -0
@@ -0,0 +1,309 @@
1
+ import { z } from 'zod';
2
+ const objectMetaSchema = z.object({
3
+ name: z.string().min(1),
4
+ namespace: z.string().optional(),
5
+ labels: z.record(z.string()).optional(),
6
+ annotations: z.record(z.string()).optional(),
7
+ });
8
+ const envVarSourceSchema = z.object({
9
+ configMapKeyRef: z
10
+ .object({ name: z.string(), key: z.string() })
11
+ .optional(),
12
+ secretKeyRef: z
13
+ .object({ name: z.string(), key: z.string() })
14
+ .optional(),
15
+ });
16
+ const envVarSchema = z.object({
17
+ name: z.string(),
18
+ value: z.string().optional(),
19
+ valueFrom: envVarSourceSchema.optional(),
20
+ });
21
+ const volumeMountSchema = z.object({
22
+ name: z.string(),
23
+ mountPath: z.string(),
24
+ });
25
+ const volumeSchema = z.object({
26
+ name: z.string(),
27
+ r2BucketRef: z.object({ name: z.string() }).optional(),
28
+ kvNamespaceRef: z.object({ name: z.string() }).optional(),
29
+ serviceRef: z.object({ name: z.string() }).optional(),
30
+ hyperdriveRef: z.object({ name: z.string() }).optional(),
31
+ d1DatabaseRef: z.object({ name: z.string() }).optional(),
32
+ queueRef: z.object({ name: z.string() }).optional(),
33
+ vectorizeRef: z.object({ name: z.string() }).optional(),
34
+ analyticsEngineRef: z.object({ dataset: z.string() }).optional(),
35
+ });
36
+ const containerSchema = z.object({
37
+ name: z.string(),
38
+ image: z.string(),
39
+ env: z.array(envVarSchema).optional(),
40
+ volumeMounts: z.array(volumeMountSchema).optional(),
41
+ });
42
+ const podSpecSchema = z.object({
43
+ containers: z.array(containerSchema).min(1),
44
+ volumes: z.array(volumeSchema).optional(),
45
+ });
46
+ const podTemplateSpecSchema = z.object({
47
+ metadata: objectMetaSchema.partial({ name: true }).optional(),
48
+ spec: podSpecSchema,
49
+ });
50
+ const deploymentSpecSchema = z.object({
51
+ replicas: z.number().int().nonnegative().optional(),
52
+ selector: z.object({ matchLabels: z.record(z.string()) }),
53
+ template: podTemplateSpecSchema,
54
+ });
55
+ export const deploymentSchema = z.object({
56
+ apiVersion: z.literal('apps/v1'),
57
+ kind: z.literal('Deployment'),
58
+ metadata: objectMetaSchema,
59
+ spec: deploymentSpecSchema,
60
+ });
61
+ const statefulSetSpecSchema = z.object({
62
+ replicas: z.number().int().nonnegative().optional(),
63
+ serviceName: z.string().optional(),
64
+ selector: z.object({ matchLabels: z.record(z.string()) }),
65
+ template: podTemplateSpecSchema,
66
+ });
67
+ export const statefulSetSchema = z.object({
68
+ apiVersion: z.literal('apps/v1'),
69
+ kind: z.literal('StatefulSet'),
70
+ metadata: objectMetaSchema,
71
+ spec: statefulSetSpecSchema,
72
+ });
73
+ const blueGreenSchema = z.object({
74
+ autoPromotionEnabled: z.boolean().optional(),
75
+ scaleDownDelaySeconds: z.number().int().nonnegative().optional(),
76
+ });
77
+ const canaryStepSchema = z.union([
78
+ z.object({ setWeight: z.number().min(0).max(100) }),
79
+ z.object({ pause: z.object({ duration: z.string().optional() }) }),
80
+ ]);
81
+ const canarySchema = z.object({
82
+ steps: z.array(canaryStepSchema),
83
+ });
84
+ const rolloutStrategySchema = z.union([
85
+ z.object({ blueGreen: blueGreenSchema }),
86
+ z.object({ canary: canarySchema }),
87
+ ]);
88
+ const rolloutSpecSchema = z.object({
89
+ replicas: z.number().int().nonnegative().optional(),
90
+ selector: z.object({ matchLabels: z.record(z.string()) }),
91
+ template: podTemplateSpecSchema,
92
+ strategy: rolloutStrategySchema,
93
+ });
94
+ export const rolloutSchema = z.object({
95
+ apiVersion: z.literal('argoproj.io/v1alpha1'),
96
+ kind: z.literal('Rollout'),
97
+ metadata: objectMetaSchema,
98
+ spec: rolloutSpecSchema,
99
+ });
100
+ const cronJobSpecSchema = z.object({
101
+ schedule: z.string().min(1),
102
+ jobTemplate: z.object({
103
+ spec: z.object({ template: podTemplateSpecSchema }),
104
+ }),
105
+ successfulJobsHistoryLimit: z.number().int().nonnegative().optional(),
106
+ failedJobsHistoryLimit: z.number().int().nonnegative().optional(),
107
+ suspend: z.boolean().optional(),
108
+ });
109
+ export const cronJobSchema = z.object({
110
+ apiVersion: z.literal('batch/v1'),
111
+ kind: z.literal('CronJob'),
112
+ metadata: objectMetaSchema,
113
+ spec: cronJobSpecSchema,
114
+ });
115
+ export const configMapSchema = z.object({
116
+ apiVersion: z.literal('v1'),
117
+ kind: z.literal('ConfigMap'),
118
+ metadata: objectMetaSchema,
119
+ data: z.record(z.string()).optional(),
120
+ });
121
+ export const secretSchema = z.object({
122
+ apiVersion: z.literal('v1'),
123
+ kind: z.literal('Secret'),
124
+ metadata: objectMetaSchema,
125
+ type: z.string().optional(),
126
+ data: z.record(z.string()).optional(),
127
+ stringData: z.record(z.string()).optional(),
128
+ });
129
+ export const namespaceSchema = z.object({
130
+ apiVersion: z.literal('v1'),
131
+ kind: z.literal('Namespace'),
132
+ metadata: objectMetaSchema,
133
+ });
134
+ export const serviceSchema = z.object({
135
+ apiVersion: z.literal('v1'),
136
+ kind: z.literal('Service'),
137
+ metadata: objectMetaSchema,
138
+ spec: z.object({
139
+ type: z.enum(['ClusterIP', 'LoadBalancer']).optional(),
140
+ selector: z.record(z.string()),
141
+ ports: z
142
+ .array(z.object({
143
+ port: z.number().int().positive(),
144
+ targetPort: z.number().int().positive().optional(),
145
+ name: z.string().optional(),
146
+ protocol: z.enum(['TCP', 'UDP']).optional(),
147
+ }))
148
+ .optional(),
149
+ }),
150
+ });
151
+ export const r2BucketSchema = z.object({
152
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
153
+ kind: z.literal('R2Bucket'),
154
+ metadata: objectMetaSchema,
155
+ spec: z.object({
156
+ location: z.enum(['wnam', 'enam', 'weur', 'eeur', 'apac', 'oc']).optional(),
157
+ storageClass: z.enum(['Standard', 'InfrequentAccess']).optional(),
158
+ }),
159
+ });
160
+ export const kvNamespaceSchema = z.object({
161
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
162
+ kind: z.literal('KVNamespace'),
163
+ metadata: objectMetaSchema,
164
+ spec: z.object({
165
+ title: z.string().optional(),
166
+ }),
167
+ });
168
+ export const dispatchNamespaceSchema = z.object({
169
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
170
+ kind: z.literal('DispatchNamespace'),
171
+ metadata: objectMetaSchema,
172
+ spec: z.object({}).strict().optional().default({}),
173
+ });
174
+ export const hyperdriveSchema = z.object({
175
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
176
+ kind: z.literal('Hyperdrive'),
177
+ metadata: objectMetaSchema,
178
+ spec: z.object({
179
+ origin: z.object({
180
+ scheme: z.enum(['postgres', 'postgresql', 'mysql']),
181
+ host: z.string().min(1),
182
+ port: z.number().int().positive(),
183
+ database: z.string().min(1),
184
+ user: z.string().min(1),
185
+ passwordSecretRef: z.object({ name: z.string(), key: z.string() }),
186
+ }),
187
+ caching: z
188
+ .object({
189
+ disabled: z.boolean().optional(),
190
+ maxAge: z.number().int().nonnegative().optional(),
191
+ staleWhileRevalidate: z.number().int().nonnegative().optional(),
192
+ })
193
+ .optional(),
194
+ originConnectionLimit: z.number().int().positive().optional(),
195
+ }),
196
+ });
197
+ export const d1DatabaseSchema = z.object({
198
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
199
+ kind: z.literal('D1Database'),
200
+ metadata: objectMetaSchema,
201
+ spec: z
202
+ .object({
203
+ primaryLocationHint: z
204
+ .enum(['wnam', 'enam', 'weur', 'eeur', 'apac', 'oc'])
205
+ .optional(),
206
+ })
207
+ .optional()
208
+ .default({}),
209
+ });
210
+ export const queueSchema = z.object({
211
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
212
+ kind: z.literal('Queue'),
213
+ metadata: objectMetaSchema,
214
+ spec: z
215
+ .object({
216
+ consumer: z.object({ workerName: z.string() }).optional(),
217
+ })
218
+ .optional()
219
+ .default({}),
220
+ });
221
+ export const vectorizeSchema = z.object({
222
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
223
+ kind: z.literal('Vectorize'),
224
+ metadata: objectMetaSchema,
225
+ spec: z.object({
226
+ dimensions: z.number().int().positive(),
227
+ metric: z.enum(['cosine', 'euclidean', 'dot-product']),
228
+ description: z.string().optional(),
229
+ }),
230
+ });
231
+ export const dnsRecordSchema = z.object({
232
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
233
+ kind: z.literal('DNSRecord'),
234
+ metadata: objectMetaSchema,
235
+ spec: z.object({
236
+ zoneId: z.string(),
237
+ type: z.enum(['A', 'AAAA', 'CNAME', 'TXT', 'MX']),
238
+ name: z.string(),
239
+ content: z.string(),
240
+ ttl: z.number().int().nonnegative().optional(),
241
+ proxied: z.boolean().optional(),
242
+ priority: z.number().int().nonnegative().optional(),
243
+ }),
244
+ });
245
+ const jobSpecSchema = z.object({
246
+ template: podTemplateSpecSchema,
247
+ backoffLimit: z.number().int().nonnegative().optional(),
248
+ activeDeadlineSeconds: z.number().int().positive().optional(),
249
+ completions: z.number().int().positive().optional(),
250
+ parallelism: z.number().int().positive().optional(),
251
+ });
252
+ export const jobSchema = z.object({
253
+ apiVersion: z.literal('batch/v1'),
254
+ kind: z.literal('Job'),
255
+ metadata: objectMetaSchema,
256
+ spec: jobSpecSchema,
257
+ });
258
+ export const logpushJobSchema = z.object({
259
+ apiVersion: z.literal('cloudflare.k1c.io/v1alpha1'),
260
+ kind: z.literal('LogpushJob'),
261
+ metadata: objectMetaSchema,
262
+ spec: z
263
+ .object({
264
+ zoneId: z.string().optional(),
265
+ accountId: z.string().optional(),
266
+ dataset: z.enum([
267
+ 'http_requests',
268
+ 'workers_trace_events',
269
+ 'firewall_events',
270
+ 'access_requests',
271
+ 'audit_logs',
272
+ 'dns_logs',
273
+ 'spectrum_events',
274
+ 'nel_reports',
275
+ 'gateway_dns',
276
+ 'gateway_http',
277
+ 'gateway_network',
278
+ 'magic_ids_detections',
279
+ 'network_analytics_logs',
280
+ ]),
281
+ destinationConf: z.string().min(1),
282
+ enabled: z.boolean().optional(),
283
+ filter: z.string().optional(),
284
+ })
285
+ .refine((s) => (s.zoneId !== undefined) !== (s.accountId !== undefined), {
286
+ message: 'LogpushJob.spec must specify exactly one of zoneId / accountId',
287
+ }),
288
+ });
289
+ export const k1cResourceSchema = z.discriminatedUnion('kind', [
290
+ deploymentSchema,
291
+ rolloutSchema,
292
+ statefulSetSchema,
293
+ cronJobSchema,
294
+ jobSchema,
295
+ configMapSchema,
296
+ secretSchema,
297
+ namespaceSchema,
298
+ serviceSchema,
299
+ r2BucketSchema,
300
+ kvNamespaceSchema,
301
+ dispatchNamespaceSchema,
302
+ hyperdriveSchema,
303
+ d1DatabaseSchema,
304
+ queueSchema,
305
+ vectorizeSchema,
306
+ dnsRecordSchema,
307
+ logpushJobSchema,
308
+ ]);
309
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1,246 @@
1
+ export interface ObjectMeta {
2
+ readonly name: string;
3
+ readonly namespace?: string;
4
+ readonly labels?: Readonly<Record<string, string>>;
5
+ readonly annotations?: Readonly<Record<string, string>>;
6
+ }
7
+ export interface BaseResource<Kind extends string, ApiVersion extends string, Spec> {
8
+ readonly apiVersion: ApiVersion;
9
+ readonly kind: Kind;
10
+ readonly metadata: ObjectMeta;
11
+ readonly spec: Spec;
12
+ }
13
+ export interface ContainerSpec {
14
+ readonly name: string;
15
+ readonly image: string;
16
+ readonly env?: ReadonlyArray<EnvVar>;
17
+ readonly volumeMounts?: ReadonlyArray<VolumeMount>;
18
+ }
19
+ export interface EnvVar {
20
+ readonly name: string;
21
+ readonly value?: string;
22
+ readonly valueFrom?: EnvVarSource;
23
+ }
24
+ export interface EnvVarSource {
25
+ readonly configMapKeyRef?: {
26
+ readonly name: string;
27
+ readonly key: string;
28
+ };
29
+ readonly secretKeyRef?: {
30
+ readonly name: string;
31
+ readonly key: string;
32
+ };
33
+ }
34
+ export interface VolumeMount {
35
+ readonly name: string;
36
+ readonly mountPath: string;
37
+ }
38
+ export interface Volume {
39
+ readonly name: string;
40
+ readonly r2BucketRef?: {
41
+ readonly name: string;
42
+ };
43
+ readonly kvNamespaceRef?: {
44
+ readonly name: string;
45
+ };
46
+ readonly serviceRef?: {
47
+ readonly name: string;
48
+ };
49
+ readonly hyperdriveRef?: {
50
+ readonly name: string;
51
+ };
52
+ readonly d1DatabaseRef?: {
53
+ readonly name: string;
54
+ };
55
+ readonly queueRef?: {
56
+ readonly name: string;
57
+ };
58
+ readonly vectorizeRef?: {
59
+ readonly name: string;
60
+ };
61
+ readonly analyticsEngineRef?: {
62
+ readonly dataset: string;
63
+ };
64
+ }
65
+ export interface PodTemplateSpec {
66
+ readonly metadata?: ObjectMeta;
67
+ readonly spec: PodSpec;
68
+ }
69
+ export interface PodSpec {
70
+ readonly containers: ReadonlyArray<ContainerSpec>;
71
+ readonly volumes?: ReadonlyArray<Volume>;
72
+ }
73
+ export interface DeploymentSpec {
74
+ readonly replicas?: number;
75
+ readonly selector: {
76
+ readonly matchLabels: Readonly<Record<string, string>>;
77
+ };
78
+ readonly template: PodTemplateSpec;
79
+ }
80
+ export type Deployment = BaseResource<'Deployment', 'apps/v1', DeploymentSpec>;
81
+ export interface StatefulSetSpec {
82
+ readonly replicas?: number;
83
+ readonly serviceName?: string;
84
+ readonly selector: {
85
+ readonly matchLabels: Readonly<Record<string, string>>;
86
+ };
87
+ readonly template: PodTemplateSpec;
88
+ }
89
+ export type StatefulSet = BaseResource<'StatefulSet', 'apps/v1', StatefulSetSpec>;
90
+ export interface BlueGreenStrategy {
91
+ readonly autoPromotionEnabled?: boolean;
92
+ readonly scaleDownDelaySeconds?: number;
93
+ }
94
+ export interface CanaryStrategy {
95
+ readonly steps: ReadonlyArray<CanaryStep>;
96
+ }
97
+ export type CanaryStep = {
98
+ readonly setWeight: number;
99
+ } | {
100
+ readonly pause: {
101
+ readonly duration?: string;
102
+ };
103
+ };
104
+ export type RolloutStrategy = {
105
+ readonly blueGreen: BlueGreenStrategy;
106
+ } | {
107
+ readonly canary: CanaryStrategy;
108
+ };
109
+ export interface RolloutSpec {
110
+ readonly replicas?: number;
111
+ readonly selector: {
112
+ readonly matchLabels: Readonly<Record<string, string>>;
113
+ };
114
+ readonly template: PodTemplateSpec;
115
+ readonly strategy: RolloutStrategy;
116
+ }
117
+ export type Rollout = BaseResource<'Rollout', 'argoproj.io/v1alpha1', RolloutSpec>;
118
+ export interface JobTemplateSpec {
119
+ readonly spec: {
120
+ readonly template: PodTemplateSpec;
121
+ };
122
+ }
123
+ export interface CronJobSpec {
124
+ readonly schedule: string;
125
+ readonly jobTemplate: JobTemplateSpec;
126
+ readonly successfulJobsHistoryLimit?: number;
127
+ readonly failedJobsHistoryLimit?: number;
128
+ readonly suspend?: boolean;
129
+ }
130
+ export type CronJob = BaseResource<'CronJob', 'batch/v1', CronJobSpec>;
131
+ export interface ConfigMapResource extends BaseResource<'ConfigMap', 'v1', never> {
132
+ readonly data?: Readonly<Record<string, string>>;
133
+ }
134
+ export interface SecretResource extends BaseResource<'Secret', 'v1', never> {
135
+ readonly type?: string;
136
+ readonly data?: Readonly<Record<string, string>>;
137
+ readonly stringData?: Readonly<Record<string, string>>;
138
+ }
139
+ export interface NamespaceResource extends BaseResource<'Namespace', 'v1', never> {
140
+ }
141
+ export interface ServicePort {
142
+ readonly port: number;
143
+ readonly targetPort?: number;
144
+ readonly name?: string;
145
+ readonly protocol?: 'TCP' | 'UDP';
146
+ }
147
+ export interface ServiceSpec {
148
+ readonly type?: 'ClusterIP' | 'LoadBalancer';
149
+ readonly selector: Readonly<Record<string, string>>;
150
+ readonly ports?: ReadonlyArray<ServicePort>;
151
+ }
152
+ export type ServiceResource = BaseResource<'Service', 'v1', ServiceSpec>;
153
+ export interface R2BucketSpec {
154
+ readonly location?: 'wnam' | 'enam' | 'weur' | 'eeur' | 'apac' | 'oc';
155
+ readonly storageClass?: 'Standard' | 'InfrequentAccess';
156
+ }
157
+ export type R2Bucket = BaseResource<'R2Bucket', 'cloudflare.k1c.io/v1alpha1', R2BucketSpec>;
158
+ export interface KVNamespaceSpec {
159
+ readonly title?: string;
160
+ }
161
+ export type KVNamespace = BaseResource<'KVNamespace', 'cloudflare.k1c.io/v1alpha1', KVNamespaceSpec>;
162
+ export interface DispatchNamespaceSpec {
163
+ readonly _placeholder?: never;
164
+ }
165
+ export type DispatchNamespace = BaseResource<'DispatchNamespace', 'cloudflare.k1c.io/v1alpha1', DispatchNamespaceSpec>;
166
+ export type HyperdriveScheme = 'postgres' | 'postgresql' | 'mysql';
167
+ export interface HyperdriveOrigin {
168
+ readonly scheme: HyperdriveScheme;
169
+ readonly host: string;
170
+ readonly port: number;
171
+ readonly database: string;
172
+ readonly user: string;
173
+ /** The password value is read from the referenced Secret at lower time. */
174
+ readonly passwordSecretRef: {
175
+ readonly name: string;
176
+ readonly key: string;
177
+ };
178
+ }
179
+ export interface HyperdriveCaching {
180
+ readonly disabled?: boolean;
181
+ readonly maxAge?: number;
182
+ readonly staleWhileRevalidate?: number;
183
+ }
184
+ export interface HyperdriveSpec {
185
+ readonly origin: HyperdriveOrigin;
186
+ readonly caching?: HyperdriveCaching;
187
+ readonly originConnectionLimit?: number;
188
+ }
189
+ export type Hyperdrive = BaseResource<'Hyperdrive', 'cloudflare.k1c.io/v1alpha1', HyperdriveSpec>;
190
+ export interface D1DatabaseSpec {
191
+ readonly primaryLocationHint?: 'wnam' | 'enam' | 'weur' | 'eeur' | 'apac' | 'oc';
192
+ }
193
+ export type D1Database = BaseResource<'D1Database', 'cloudflare.k1c.io/v1alpha1', D1DatabaseSpec>;
194
+ export interface QueueSpec {
195
+ /** Optional consumer Worker (referenced by name). The dispatched Worker must exist
196
+ * in the same namespace and is wired via `cloudflare.workers.queues.consumers`. */
197
+ readonly consumer?: {
198
+ readonly workerName: string;
199
+ };
200
+ }
201
+ export type Queue = BaseResource<'Queue', 'cloudflare.k1c.io/v1alpha1', QueueSpec>;
202
+ export interface VectorizeSpec {
203
+ readonly dimensions: number;
204
+ readonly metric: 'cosine' | 'euclidean' | 'dot-product';
205
+ readonly description?: string;
206
+ }
207
+ export type Vectorize = BaseResource<'Vectorize', 'cloudflare.k1c.io/v1alpha1', VectorizeSpec>;
208
+ export interface DNSRecordSpec {
209
+ readonly zoneId: string;
210
+ readonly type: 'A' | 'AAAA' | 'CNAME' | 'TXT' | 'MX';
211
+ readonly name: string;
212
+ readonly content: string;
213
+ readonly ttl?: number;
214
+ readonly proxied?: boolean;
215
+ readonly priority?: number;
216
+ }
217
+ export type DNSRecord = BaseResource<'DNSRecord', 'cloudflare.k1c.io/v1alpha1', DNSRecordSpec>;
218
+ export interface JobSpec {
219
+ readonly template: PodTemplateSpec;
220
+ readonly backoffLimit?: number;
221
+ readonly activeDeadlineSeconds?: number;
222
+ readonly completions?: number;
223
+ readonly parallelism?: number;
224
+ }
225
+ export type Job = BaseResource<'Job', 'batch/v1', JobSpec>;
226
+ export interface LogpushJobSpec {
227
+ /** Either zoneId or accountId is required (mutually exclusive). */
228
+ readonly zoneId?: string;
229
+ readonly accountId?: string;
230
+ readonly dataset: 'http_requests' | 'workers_trace_events' | 'firewall_events' | 'access_requests' | 'audit_logs' | 'dns_logs' | 'spectrum_events' | 'nel_reports' | 'gateway_dns' | 'gateway_http' | 'gateway_network' | 'magic_ids_detections' | 'network_analytics_logs';
231
+ readonly destinationConf: string;
232
+ readonly enabled?: boolean;
233
+ readonly filter?: string;
234
+ }
235
+ export type LogpushJob = BaseResource<'LogpushJob', 'cloudflare.k1c.io/v1alpha1', LogpushJobSpec>;
236
+ export type K1cResource = Deployment | Rollout | StatefulSet | CronJob | Job | ConfigMapResource | SecretResource | NamespaceResource | ServiceResource | R2Bucket | KVNamespace | DispatchNamespace | Hyperdrive | D1Database | Queue | Vectorize | DNSRecord | LogpushJob;
237
+ export type ResourceKind = K1cResource['kind'];
238
+ export interface ResourceRef {
239
+ readonly apiVersion: string;
240
+ readonly kind: ResourceKind;
241
+ readonly namespace: string;
242
+ readonly name: string;
243
+ }
244
+ export declare function refOf(resource: K1cResource): ResourceRef;
245
+ export declare function refKey(ref: ResourceRef): string;
246
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,12 @@
1
+ export function refOf(resource) {
2
+ return {
3
+ apiVersion: resource.apiVersion,
4
+ kind: resource.kind,
5
+ namespace: resource.metadata.namespace ?? 'default',
6
+ name: resource.metadata.name,
7
+ };
8
+ }
9
+ export function refKey(ref) {
10
+ return `${ref.apiVersion}/${ref.kind}/${ref.namespace}/${ref.name}`;
11
+ }
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import type { CloudflareResourceProvider } from './types.ts';
3
+ export interface ConfigMapProperties {
4
+ readonly data: Readonly<Record<string, string>>;
5
+ }
6
+ export declare const configMapSchema: z.ZodType<ConfigMapProperties>;
7
+ export declare const configMapProvider: CloudflareResourceProvider<ConfigMapProperties>;
8
+ //# sourceMappingURL=configmap.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { NotFound } from "./types.js";
3
+ export const configMapSchema = z.object({
4
+ data: z.record(z.string()),
5
+ });
6
+ export const configMapProvider = {
7
+ resourceType: 'ConfigMap',
8
+ schema: configMapSchema,
9
+ async *list(_ctx) {
10
+ // ConfigMap is virtual: its presence is derived from referenced Workers.
11
+ return;
12
+ },
13
+ async read(_ctx, _nativeId) {
14
+ // Read is satisfied from the resource graph in the reconciler, not from CF API.
15
+ throw new Error('configMapProvider.read should be served by the reconciler graph, not invoked directly');
16
+ },
17
+ async create(_ctx, _label, _desired) {
18
+ // No-op: writing the values happens during Worker create.
19
+ return { kind: 'sync', nativeId: _label, properties: _desired };
20
+ },
21
+ async update(_ctx, _nativeId, _prior, _desired) {
22
+ // Update is realized by re-applying referenced Workers; the Worker provider picks up new vars.
23
+ return { kind: 'noop' };
24
+ },
25
+ async delete(_ctx, _nativeId) {
26
+ return { kind: 'sync' };
27
+ },
28
+ };
29
+ //# sourceMappingURL=configmap.js.map
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import type { CloudflareResourceProvider } from './types.ts';
3
+ export interface CustomDomainProperties {
4
+ readonly hostname: string;
5
+ readonly service: string;
6
+ readonly zoneId: string;
7
+ readonly environment: string;
8
+ }
9
+ export declare const customDomainSchema: z.ZodType<CustomDomainProperties>;
10
+ export declare const customDomainProvider: CloudflareResourceProvider<CustomDomainProperties>;
11
+ //# sourceMappingURL=custom-domain.d.ts.map