@vibesdotdev/infra-cloudflare 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.
- package/README.md +107 -0
- package/SPEC.md +166 -0
- package/dist/cloudflare.plugin.d.ts +73 -0
- package/dist/cloudflare.plugin.d.ts.map +1 -0
- package/dist/cloudflare.plugin.js +334 -0
- package/dist/cloudflare.plugin.js.map +1 -0
- package/dist/implementations/alerts.descriptor.d.ts +13 -0
- package/dist/implementations/alerts.descriptor.d.ts.map +1 -0
- package/dist/implementations/alerts.descriptor.js +30 -0
- package/dist/implementations/alerts.descriptor.js.map +1 -0
- package/dist/implementations/alerts.impl.d.ts +35 -0
- package/dist/implementations/alerts.impl.d.ts.map +1 -0
- package/dist/implementations/alerts.impl.js +283 -0
- package/dist/implementations/alerts.impl.js.map +1 -0
- package/dist/implementations/kv.impl.d.ts +29 -0
- package/dist/implementations/kv.impl.d.ts.map +1 -0
- package/dist/implementations/kv.impl.js +36 -0
- package/dist/implementations/kv.impl.js.map +1 -0
- package/dist/implementations/logs.descriptor.d.ts +15 -0
- package/dist/implementations/logs.descriptor.d.ts.map +1 -0
- package/dist/implementations/logs.descriptor.js +26 -0
- package/dist/implementations/logs.descriptor.js.map +1 -0
- package/dist/implementations/logs.impl.d.ts +108 -0
- package/dist/implementations/logs.impl.d.ts.map +1 -0
- package/dist/implementations/logs.impl.js +154 -0
- package/dist/implementations/logs.impl.js.map +1 -0
- package/dist/implementations/observability.descriptor.d.ts +9 -0
- package/dist/implementations/observability.descriptor.d.ts.map +1 -0
- package/dist/implementations/observability.descriptor.js +22 -0
- package/dist/implementations/observability.descriptor.js.map +1 -0
- package/dist/implementations/observability.impl.d.ts +35 -0
- package/dist/implementations/observability.impl.d.ts.map +1 -0
- package/dist/implementations/observability.impl.js +229 -0
- package/dist/implementations/observability.impl.js.map +1 -0
- package/dist/implementations/pages.impl.d.ts +98 -0
- package/dist/implementations/pages.impl.d.ts.map +1 -0
- package/dist/implementations/pages.impl.js +132 -0
- package/dist/implementations/pages.impl.js.map +1 -0
- package/dist/implementations/queues.impl.d.ts +29 -0
- package/dist/implementations/queues.impl.d.ts.map +1 -0
- package/dist/implementations/queues.impl.js +34 -0
- package/dist/implementations/queues.impl.js.map +1 -0
- package/dist/implementations/r2.impl.d.ts +31 -0
- package/dist/implementations/r2.impl.d.ts.map +1 -0
- package/dist/implementations/r2.impl.js +41 -0
- package/dist/implementations/r2.impl.js.map +1 -0
- package/dist/implementations/rum.descriptor.d.ts +13 -0
- package/dist/implementations/rum.descriptor.d.ts.map +1 -0
- package/dist/implementations/rum.descriptor.js +32 -0
- package/dist/implementations/rum.descriptor.js.map +1 -0
- package/dist/implementations/rum.impl.d.ts +34 -0
- package/dist/implementations/rum.impl.d.ts.map +1 -0
- package/dist/implementations/rum.impl.js +153 -0
- package/dist/implementations/rum.impl.js.map +1 -0
- package/dist/implementations/web-app.impl.d.ts +294 -0
- package/dist/implementations/web-app.impl.d.ts.map +1 -0
- package/dist/implementations/web-app.impl.js +208 -0
- package/dist/implementations/web-app.impl.js.map +1 -0
- package/dist/implementations/workers.impl.d.ts +157 -0
- package/dist/implementations/workers.impl.d.ts.map +1 -0
- package/dist/implementations/workers.impl.js +247 -0
- package/dist/implementations/workers.impl.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/pages.d.ts +9 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +9 -0
- package/dist/pages.js.map +1 -0
- package/dist/regen.d.ts +58 -0
- package/dist/regen.d.ts.map +1 -0
- package/dist/regen.js +69 -0
- package/dist/regen.js.map +1 -0
- package/dist/secrets/cloudflare-api.descriptor.d.ts +18 -0
- package/dist/secrets/cloudflare-api.descriptor.d.ts.map +1 -0
- package/dist/secrets/cloudflare-api.descriptor.js +32 -0
- package/dist/secrets/cloudflare-api.descriptor.js.map +1 -0
- package/dist/secrets/cloudflare-api.impl.d.ts +30 -0
- package/dist/secrets/cloudflare-api.impl.d.ts.map +1 -0
- package/dist/secrets/cloudflare-api.impl.js +111 -0
- package/dist/secrets/cloudflare-api.impl.js.map +1 -0
- package/dist/secrets/cloudflare-secrets-store.descriptor.d.ts +10 -0
- package/dist/secrets/cloudflare-secrets-store.descriptor.d.ts.map +1 -0
- package/dist/secrets/cloudflare-secrets-store.descriptor.js +24 -0
- package/dist/secrets/cloudflare-secrets-store.descriptor.js.map +1 -0
- package/dist/secrets/cloudflare-secrets-store.impl.d.ts +27 -0
- package/dist/secrets/cloudflare-secrets-store.impl.d.ts.map +1 -0
- package/dist/secrets/cloudflare-secrets-store.impl.js +72 -0
- package/dist/secrets/cloudflare-secrets-store.impl.js.map +1 -0
- package/dist/secrets/index.d.ts +6 -0
- package/dist/secrets/index.d.ts.map +1 -0
- package/dist/secrets/index.js +6 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/resolve-cf-credentials.d.ts +18 -0
- package/dist/secrets/resolve-cf-credentials.d.ts.map +1 -0
- package/dist/secrets/resolve-cf-credentials.js +57 -0
- package/dist/secrets/resolve-cf-credentials.js.map +1 -0
- package/dist/web-app.d.ts +11 -0
- package/dist/web-app.d.ts.map +1 -0
- package/dist/web-app.js +11 -0
- package/dist/web-app.js.map +1 -0
- package/package.json +153 -0
- package/src/cloudflare.plugin.ts +477 -0
- package/src/implementations/alerts.descriptor.ts +33 -0
- package/src/implementations/alerts.impl.ts +332 -0
- package/src/implementations/kv.impl.ts +51 -0
- package/src/implementations/logs.descriptor.ts +29 -0
- package/src/implementations/logs.impl.ts +201 -0
- package/src/implementations/observability.descriptor.ts +25 -0
- package/src/implementations/observability.impl.ts +307 -0
- package/src/implementations/pages.impl.ts +189 -0
- package/src/implementations/queues.impl.ts +48 -0
- package/src/implementations/r2.impl.ts +58 -0
- package/src/implementations/rum.descriptor.ts +35 -0
- package/src/implementations/rum.impl.ts +192 -0
- package/src/implementations/web-app.impl.ts +494 -0
- package/src/implementations/workers.impl.ts +336 -0
- package/src/index.ts +60 -0
- package/src/pages.ts +18 -0
- package/src/regen.ts +87 -0
- package/src/secrets/cloudflare-api.descriptor.ts +35 -0
- package/src/secrets/cloudflare-api.impl.ts +131 -0
- package/src/secrets/cloudflare-secrets-store.descriptor.ts +27 -0
- package/src/secrets/cloudflare-secrets-store.impl.ts +87 -0
- package/src/secrets/index.ts +13 -0
- package/src/secrets/resolve-cf-credentials.ts +63 -0
- package/src/web-app.ts +32 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Workers Implementation
|
|
3
|
+
*
|
|
4
|
+
* Config generator for `infra/worker` kind when adapter is `cloudflare-workers`.
|
|
5
|
+
* Takes an infra descriptor and outputs a wrangler config for a CF Worker
|
|
6
|
+
* that consumes from CF Queues.
|
|
7
|
+
*/
|
|
8
|
+
import * as z from 'zod/v4';
|
|
9
|
+
export declare const CloudflareWorkerDescriptorSchema: z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"infra/worker">;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
adapter: z.ZodLiteral<"cloudflare-workers">;
|
|
14
|
+
workerName: z.ZodString;
|
|
15
|
+
main: z.ZodDefault<z.ZodString>;
|
|
16
|
+
compatibilityDate: z.ZodOptional<z.ZodString>;
|
|
17
|
+
compatibilityFlags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
vars: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
19
|
+
consumers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
20
|
+
queue: z.ZodString;
|
|
21
|
+
maxBatchSize: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
deadLetterQueue: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>>;
|
|
25
|
+
kvNamespaces: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
26
|
+
binding: z.ZodString;
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
r2Buckets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
30
|
+
binding: z.ZodString;
|
|
31
|
+
bucketName: z.ZodString;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
queueProducers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
34
|
+
queue: z.ZodString;
|
|
35
|
+
binding: z.ZodString;
|
|
36
|
+
}, z.core.$strip>>>;
|
|
37
|
+
durableObjects: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
38
|
+
binding: z.ZodString;
|
|
39
|
+
className: z.ZodString;
|
|
40
|
+
scriptName: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>>>;
|
|
42
|
+
migrations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
43
|
+
tag: z.ZodString;
|
|
44
|
+
newClasses: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
renamedClasses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
46
|
+
from: z.ZodString;
|
|
47
|
+
to: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
49
|
+
deletedClasses: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
newSqliteClasses: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
|
+
}, z.core.$strip>>>;
|
|
52
|
+
services: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
53
|
+
binding: z.ZodString;
|
|
54
|
+
service: z.ZodString;
|
|
55
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>>>;
|
|
57
|
+
d1Databases: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
58
|
+
binding: z.ZodString;
|
|
59
|
+
databaseName: z.ZodString;
|
|
60
|
+
databaseId: z.ZodString;
|
|
61
|
+
}, z.core.$strip>>>;
|
|
62
|
+
smartPlacement: z.ZodDefault<z.ZodBoolean>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type CloudflareWorkerDescriptorInput = z.input<typeof CloudflareWorkerDescriptorSchema>;
|
|
65
|
+
export type CloudflareWorkerDescriptor = z.infer<typeof CloudflareWorkerDescriptorSchema>;
|
|
66
|
+
export interface WranglerWorkerConfig {
|
|
67
|
+
$schema?: string;
|
|
68
|
+
name: string;
|
|
69
|
+
main: string;
|
|
70
|
+
compatibility_date: string;
|
|
71
|
+
compatibility_flags: string[];
|
|
72
|
+
vars?: Record<string, string>;
|
|
73
|
+
placement?: {
|
|
74
|
+
mode: string;
|
|
75
|
+
};
|
|
76
|
+
queues?: {
|
|
77
|
+
consumers?: Array<{
|
|
78
|
+
queue: string;
|
|
79
|
+
max_batch_size: number;
|
|
80
|
+
max_retries: number;
|
|
81
|
+
dead_letter_queue?: string;
|
|
82
|
+
}>;
|
|
83
|
+
producers?: Array<{
|
|
84
|
+
queue: string;
|
|
85
|
+
binding: string;
|
|
86
|
+
}>;
|
|
87
|
+
};
|
|
88
|
+
kv_namespaces?: Array<{
|
|
89
|
+
binding: string;
|
|
90
|
+
id: string;
|
|
91
|
+
}>;
|
|
92
|
+
r2_buckets?: Array<{
|
|
93
|
+
binding: string;
|
|
94
|
+
bucket_name: string;
|
|
95
|
+
}>;
|
|
96
|
+
durable_objects?: {
|
|
97
|
+
bindings: Array<{
|
|
98
|
+
name: string;
|
|
99
|
+
class_name: string;
|
|
100
|
+
script_name?: string;
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
migrations?: Array<{
|
|
104
|
+
tag: string;
|
|
105
|
+
new_classes?: string[];
|
|
106
|
+
renamed_classes?: Array<{
|
|
107
|
+
from: string;
|
|
108
|
+
to: string;
|
|
109
|
+
}>;
|
|
110
|
+
deleted_classes?: string[];
|
|
111
|
+
new_sqlite_classes?: string[];
|
|
112
|
+
}>;
|
|
113
|
+
services?: Array<{
|
|
114
|
+
binding: string;
|
|
115
|
+
service: string;
|
|
116
|
+
environment?: string;
|
|
117
|
+
}>;
|
|
118
|
+
d1_databases?: Array<{
|
|
119
|
+
binding: string;
|
|
120
|
+
database_name: string;
|
|
121
|
+
database_id: string;
|
|
122
|
+
}>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Generate a wrangler config from a Workers descriptor.
|
|
126
|
+
*/
|
|
127
|
+
export declare function generateCloudflareWorkerConfig(descriptor: CloudflareWorkerDescriptor): WranglerWorkerConfig;
|
|
128
|
+
/**
|
|
129
|
+
* Convention defaults for cloud Flow job consumers.
|
|
130
|
+
*
|
|
131
|
+
* The `workers` runtime cloud impl rendezvous protocol expects a Durable
|
|
132
|
+
* Object class named `JobResultStore` exported from the consumer worker
|
|
133
|
+
* and exposed under the binding `JOB_RESULT_STORE`. Apps shouldn't
|
|
134
|
+
* re-derive this every time — call `generateJobConsumerWorkerConfig`
|
|
135
|
+
* and the convention is filled in.
|
|
136
|
+
*/
|
|
137
|
+
export declare const JOB_RESULT_STORE_BINDING = "JOB_RESULT_STORE";
|
|
138
|
+
export declare const JOB_RESULT_STORE_CLASS = "JobResultStore";
|
|
139
|
+
export declare const JOB_RESULT_STORE_INITIAL_MIGRATION_TAG = "v1-job-result-store";
|
|
140
|
+
export type JobConsumerWorkerInput = Omit<CloudflareWorkerDescriptorInput, 'durableObjects' | 'migrations'> & {
|
|
141
|
+
/** Extra DO bindings beyond the JOB_RESULT_STORE convention. */
|
|
142
|
+
extraDurableObjects?: NonNullable<CloudflareWorkerDescriptorInput['durableObjects']>;
|
|
143
|
+
/** Extra migrations appended after the JobResultStore registration. */
|
|
144
|
+
extraMigrations?: NonNullable<CloudflareWorkerDescriptorInput['migrations']>;
|
|
145
|
+
};
|
|
146
|
+
/** Re-exported convention bindings for use in tests + descriptor declarations. */
|
|
147
|
+
/**
|
|
148
|
+
* Generate a wrangler config for a worker that consumes cloud Flow jobs.
|
|
149
|
+
*
|
|
150
|
+
* Injects the `JOB_RESULT_STORE` → `JobResultStore` DO binding and the
|
|
151
|
+
* initial migration that registers `JobResultStore` as a SQLite-backed
|
|
152
|
+
* Durable Object (the modern default — required for new DO classes on
|
|
153
|
+
* accounts created after 2024-04-01). Callers may add extra DO bindings
|
|
154
|
+
* and migrations via `extraDurableObjects` / `extraMigrations`.
|
|
155
|
+
*/
|
|
156
|
+
export declare function generateJobConsumerWorkerConfig(input: JobConsumerWorkerInput): WranglerWorkerConfig;
|
|
157
|
+
//# sourceMappingURL=workers.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.impl.d.ts","sourceRoot":"","sources":["../../src/implementations/workers.impl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAS5B,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsG3C,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC/F,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,MAAM,WAAW,oBAAoB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,MAAM,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,KAAK,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;YACd,c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AW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtF;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC7C,UAAU,EAAE,0BAA0B,GACpC,oBAAoB,CAoHtB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,eAAO,MAAM,sCAAsC,wBAAwB,CAAC;AAE5E,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,+BAA+B,EAC/B,gBAAgB,GAAG,YAAY,CAC/B,GAAG;IACH,gEAAgE;IAChE,mBAAmB,CAAC,EAAE,WAAW,CAAC,+BAA+B,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACrF,uEAAuE;IACvE,eAAe,CAAC,EAAE,WAAW,CAAC,+BAA+B,CAAC,YAAY,CAAC,CAAC,CAAC;CAC7E,CAAC;AAEF,kFAAkF;AAElF;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,sBAAsB,GAC3B,oBAAoB,CAmBtB"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Workers Implementation
|
|
3
|
+
*
|
|
4
|
+
* Config generator for `infra/worker` kind when adapter is `cloudflare-workers`.
|
|
5
|
+
* Takes an infra descriptor and outputs a wrangler config for a CF Worker
|
|
6
|
+
* that consumes from CF Queues.
|
|
7
|
+
*/
|
|
8
|
+
import * as z from 'zod/v4';
|
|
9
|
+
const QueueConsumerSchema = z.object({
|
|
10
|
+
queue: z.string().min(1),
|
|
11
|
+
maxBatchSize: z.number().int().positive().default(10),
|
|
12
|
+
maxRetries: z.number().int().min(0).default(3),
|
|
13
|
+
deadLetterQueue: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
export const CloudflareWorkerDescriptorSchema = z.object({
|
|
16
|
+
kind: z.literal('infra/worker'),
|
|
17
|
+
id: z.string().min(1),
|
|
18
|
+
name: z.string().min(1),
|
|
19
|
+
adapter: z.literal('cloudflare-workers'),
|
|
20
|
+
/** Wrangler worker name (e.g. "vibes-billing-worker") */
|
|
21
|
+
workerName: z.string().min(1),
|
|
22
|
+
/** Entry point for the worker */
|
|
23
|
+
main: z.string().min(1).default('src/worker.ts'),
|
|
24
|
+
compatibilityDate: z
|
|
25
|
+
.string()
|
|
26
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/)
|
|
27
|
+
.optional(),
|
|
28
|
+
compatibilityFlags: z.array(z.string()).default(['nodejs_compat']),
|
|
29
|
+
/** Environment variables */
|
|
30
|
+
vars: z.record(z.string(), z.string()).default({}),
|
|
31
|
+
/** Queue consumers this worker processes */
|
|
32
|
+
consumers: z.array(QueueConsumerSchema).default([]),
|
|
33
|
+
/** KV namespace bindings */
|
|
34
|
+
kvNamespaces: z
|
|
35
|
+
.array(z.object({
|
|
36
|
+
binding: z.string().min(1),
|
|
37
|
+
id: z.string().min(1)
|
|
38
|
+
}))
|
|
39
|
+
.default([]),
|
|
40
|
+
/** R2 bucket bindings */
|
|
41
|
+
r2Buckets: z
|
|
42
|
+
.array(z.object({
|
|
43
|
+
binding: z.string().min(1),
|
|
44
|
+
bucketName: z.string().min(1)
|
|
45
|
+
}))
|
|
46
|
+
.default([]),
|
|
47
|
+
/** Queue producer bindings (worker can also produce to queues) */
|
|
48
|
+
queueProducers: z
|
|
49
|
+
.array(z.object({
|
|
50
|
+
queue: z.string().min(1),
|
|
51
|
+
binding: z.string().min(1)
|
|
52
|
+
}))
|
|
53
|
+
.default([]),
|
|
54
|
+
/** Durable Object class bindings */
|
|
55
|
+
durableObjects: z
|
|
56
|
+
.array(z.object({
|
|
57
|
+
binding: z.string().regex(/^[_A-Z0-9]+$/),
|
|
58
|
+
className: z.string().min(1),
|
|
59
|
+
/** Cross-script DO bindings; omit when the DO class is in this same worker */
|
|
60
|
+
scriptName: z.string().min(1).optional()
|
|
61
|
+
}))
|
|
62
|
+
.default([]),
|
|
63
|
+
/**
|
|
64
|
+
* Durable Object migrations. Each entry corresponds to one
|
|
65
|
+
* `[[migrations]]` block in wrangler.toml. The first deploy of any new
|
|
66
|
+
* DO class needs `newClasses: ['ClassName']` under a fresh tag; later
|
|
67
|
+
* renames/deletes append further migration entries.
|
|
68
|
+
*/
|
|
69
|
+
migrations: z
|
|
70
|
+
.array(z.object({
|
|
71
|
+
tag: z.string().min(1),
|
|
72
|
+
newClasses: z.array(z.string().min(1)).optional(),
|
|
73
|
+
renamedClasses: z
|
|
74
|
+
.array(z.object({ from: z.string().min(1), to: z.string().min(1) }))
|
|
75
|
+
.optional(),
|
|
76
|
+
deletedClasses: z.array(z.string().min(1)).optional(),
|
|
77
|
+
newSqliteClasses: z.array(z.string().min(1)).optional()
|
|
78
|
+
}))
|
|
79
|
+
.default([]),
|
|
80
|
+
/**
|
|
81
|
+
* Service bindings — call other Workers by name from this Worker via
|
|
82
|
+
* `env.<binding>.fetch(...)`.
|
|
83
|
+
*/
|
|
84
|
+
services: z
|
|
85
|
+
.array(z.object({
|
|
86
|
+
binding: z.string().regex(/^[_A-Z0-9]+$/),
|
|
87
|
+
service: z.string().min(1),
|
|
88
|
+
environment: z.string().min(1).optional()
|
|
89
|
+
}))
|
|
90
|
+
.default([]),
|
|
91
|
+
/**
|
|
92
|
+
* D1 database bindings — `env.<binding>` exposes a D1 client.
|
|
93
|
+
*/
|
|
94
|
+
d1Databases: z
|
|
95
|
+
.array(z.object({
|
|
96
|
+
binding: z.string().regex(/^[_A-Z0-9]+$/),
|
|
97
|
+
databaseName: z.string().min(1),
|
|
98
|
+
databaseId: z.string().min(1)
|
|
99
|
+
}))
|
|
100
|
+
.default([]),
|
|
101
|
+
/** Enable smart placement */
|
|
102
|
+
smartPlacement: z.boolean().default(false)
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Generate a wrangler config from a Workers descriptor.
|
|
106
|
+
*/
|
|
107
|
+
export function generateCloudflareWorkerConfig(descriptor) {
|
|
108
|
+
const parsed = CloudflareWorkerDescriptorSchema.parse(descriptor);
|
|
109
|
+
const compatibilityDate = parsed.compatibilityDate ?? new Date().toISOString().slice(0, 10);
|
|
110
|
+
const config = {
|
|
111
|
+
$schema: 'node_modules/wrangler/config-schema.json',
|
|
112
|
+
name: parsed.workerName,
|
|
113
|
+
main: parsed.main,
|
|
114
|
+
compatibility_date: compatibilityDate,
|
|
115
|
+
compatibility_flags: parsed.compatibilityFlags
|
|
116
|
+
};
|
|
117
|
+
if (Object.keys(parsed.vars).length > 0) {
|
|
118
|
+
config.vars = parsed.vars;
|
|
119
|
+
}
|
|
120
|
+
if (parsed.smartPlacement) {
|
|
121
|
+
config.placement = { mode: 'smart' };
|
|
122
|
+
}
|
|
123
|
+
const queues = {};
|
|
124
|
+
if (parsed.consumers.length > 0) {
|
|
125
|
+
queues.consumers = parsed.consumers.map((c) => {
|
|
126
|
+
const consumer = {
|
|
127
|
+
queue: c.queue,
|
|
128
|
+
max_batch_size: c.maxBatchSize,
|
|
129
|
+
max_retries: c.maxRetries
|
|
130
|
+
};
|
|
131
|
+
if (c.deadLetterQueue) {
|
|
132
|
+
consumer.dead_letter_queue = c.deadLetterQueue;
|
|
133
|
+
}
|
|
134
|
+
return consumer;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (parsed.queueProducers.length > 0) {
|
|
138
|
+
queues.producers = parsed.queueProducers.map((p) => ({
|
|
139
|
+
queue: p.queue,
|
|
140
|
+
binding: p.binding
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
if (queues.consumers || queues.producers) {
|
|
144
|
+
config.queues = queues;
|
|
145
|
+
}
|
|
146
|
+
if (parsed.kvNamespaces.length > 0) {
|
|
147
|
+
config.kv_namespaces = parsed.kvNamespaces.map((ns) => ({
|
|
148
|
+
binding: ns.binding,
|
|
149
|
+
id: ns.id
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
if (parsed.r2Buckets.length > 0) {
|
|
153
|
+
config.r2_buckets = parsed.r2Buckets.map((bucket) => ({
|
|
154
|
+
binding: bucket.binding,
|
|
155
|
+
bucket_name: bucket.bucketName
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
if (parsed.durableObjects.length > 0) {
|
|
159
|
+
config.durable_objects = {
|
|
160
|
+
bindings: parsed.durableObjects.map((binding) => {
|
|
161
|
+
const out = {
|
|
162
|
+
name: binding.binding,
|
|
163
|
+
class_name: binding.className
|
|
164
|
+
};
|
|
165
|
+
if (binding.scriptName)
|
|
166
|
+
out.script_name = binding.scriptName;
|
|
167
|
+
return out;
|
|
168
|
+
})
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (parsed.migrations.length > 0) {
|
|
172
|
+
config.migrations = parsed.migrations.map((migration) => {
|
|
173
|
+
const out = { tag: migration.tag };
|
|
174
|
+
if (migration.newClasses?.length)
|
|
175
|
+
out.new_classes = migration.newClasses;
|
|
176
|
+
if (migration.renamedClasses?.length)
|
|
177
|
+
out.renamed_classes = migration.renamedClasses;
|
|
178
|
+
if (migration.deletedClasses?.length)
|
|
179
|
+
out.deleted_classes = migration.deletedClasses;
|
|
180
|
+
if (migration.newSqliteClasses?.length)
|
|
181
|
+
out.new_sqlite_classes = migration.newSqliteClasses;
|
|
182
|
+
return out;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (parsed.services.length > 0) {
|
|
186
|
+
config.services = parsed.services.map((service) => {
|
|
187
|
+
const out = {
|
|
188
|
+
binding: service.binding,
|
|
189
|
+
service: service.service
|
|
190
|
+
};
|
|
191
|
+
if (service.environment)
|
|
192
|
+
out.environment = service.environment;
|
|
193
|
+
return out;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (parsed.d1Databases.length > 0) {
|
|
197
|
+
config.d1_databases = parsed.d1Databases.map((db) => ({
|
|
198
|
+
binding: db.binding,
|
|
199
|
+
database_name: db.databaseName,
|
|
200
|
+
database_id: db.databaseId
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
return config;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Convention defaults for cloud Flow job consumers.
|
|
207
|
+
*
|
|
208
|
+
* The `workers` runtime cloud impl rendezvous protocol expects a Durable
|
|
209
|
+
* Object class named `JobResultStore` exported from the consumer worker
|
|
210
|
+
* and exposed under the binding `JOB_RESULT_STORE`. Apps shouldn't
|
|
211
|
+
* re-derive this every time — call `generateJobConsumerWorkerConfig`
|
|
212
|
+
* and the convention is filled in.
|
|
213
|
+
*/
|
|
214
|
+
export const JOB_RESULT_STORE_BINDING = 'JOB_RESULT_STORE';
|
|
215
|
+
export const JOB_RESULT_STORE_CLASS = 'JobResultStore';
|
|
216
|
+
export const JOB_RESULT_STORE_INITIAL_MIGRATION_TAG = 'v1-job-result-store';
|
|
217
|
+
/** Re-exported convention bindings for use in tests + descriptor declarations. */
|
|
218
|
+
/**
|
|
219
|
+
* Generate a wrangler config for a worker that consumes cloud Flow jobs.
|
|
220
|
+
*
|
|
221
|
+
* Injects the `JOB_RESULT_STORE` → `JobResultStore` DO binding and the
|
|
222
|
+
* initial migration that registers `JobResultStore` as a SQLite-backed
|
|
223
|
+
* Durable Object (the modern default — required for new DO classes on
|
|
224
|
+
* accounts created after 2024-04-01). Callers may add extra DO bindings
|
|
225
|
+
* and migrations via `extraDurableObjects` / `extraMigrations`.
|
|
226
|
+
*/
|
|
227
|
+
export function generateJobConsumerWorkerConfig(input) {
|
|
228
|
+
const { extraDurableObjects = [], extraMigrations = [], ...rest } = input;
|
|
229
|
+
return generateCloudflareWorkerConfig({
|
|
230
|
+
...rest,
|
|
231
|
+
durableObjects: [
|
|
232
|
+
{
|
|
233
|
+
binding: JOB_RESULT_STORE_BINDING,
|
|
234
|
+
className: JOB_RESULT_STORE_CLASS
|
|
235
|
+
},
|
|
236
|
+
...extraDurableObjects
|
|
237
|
+
],
|
|
238
|
+
migrations: [
|
|
239
|
+
{
|
|
240
|
+
tag: JOB_RESULT_STORE_INITIAL_MIGRATION_TAG,
|
|
241
|
+
newSqliteClasses: [JOB_RESULT_STORE_CLASS]
|
|
242
|
+
},
|
|
243
|
+
...extraMigrations
|
|
244
|
+
]
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=workers.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.impl.js","sourceRoot":"","sources":["../../src/implementations/workers.impl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC;IACxC,yDAAyD;IACzD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,iCAAiC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GA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AC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACvD,MAAM,CAAC,MAAM,sCAAsC,GAAG,qBAAqB,CAAC;AAY5E,kFAAkF;AAElF;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAC9C,KAA6B;IAE7B,MAAM,EAAE,mBAAmB,GAAG,EAAE,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC1E,OAAO,8BAA8B,CAAC;QACrC,GAAG,IAAI;QACP,cAAc,EAAE;YACf;gBACC,OAAO,EAAE,wBAAwB;gBACjC,SAAS,EAAE,sBAAsB;aACjC;YACD,GAAG,mBAAmB;SACtB;QACD,UAAU,EAAE;YACX;gBACC,GAAG,EAAE,sCAAsC;gBAC3C,gBAAgB,EAAE,CAAC,sBAAsB,CAAC;aAC1C;YACD,GAAG,eAAe;SAClB;KAC6B,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { CloudflareWorkerDescriptorSchema, generateCloudflareWorkerConfig, JOB_RESULT_STORE_BINDING, JOB_RESULT_STORE_CLASS, JOB_RESULT_STORE_INITIAL_MIGRATION_TAG, generateJobConsumerWorkerConfig } from './implementations/workers.impl';
|
|
2
|
+
export type { CloudflareWorkerDescriptorInput, CloudflareWorkerDescriptor, WranglerWorkerConfig, JobConsumerWorkerInput } from './implementations/workers.impl';
|
|
3
|
+
export { CloudflareLogsDescriptorSchema, createCloudflareLogsImplementation, type CloudflareLogsDescriptorInput, type CloudflareLogsDescriptor, type LogsImplementation } from './implementations/logs.impl';
|
|
4
|
+
export { CloudflareQueueDescriptorSchema, generateCloudflareQueueConfig } from './implementations/queues.impl';
|
|
5
|
+
export type { CloudflareQueueDescriptor, WranglerQueueProducerConfig } from './implementations/queues.impl';
|
|
6
|
+
export { CloudflareR2DescriptorSchema, generateCloudflareR2Config } from './implementations/r2.impl';
|
|
7
|
+
export type { CloudflareR2Descriptor, WranglerR2Config } from './implementations/r2.impl';
|
|
8
|
+
export { CloudflareKVDescriptorSchema, generateCloudflareKVConfig } from './implementations/kv.impl';
|
|
9
|
+
export type { CloudflareKVDescriptor, WranglerKVConfig } from './implementations/kv.impl';
|
|
10
|
+
export { CloudflarePagesDescriptorSchema, createCloudflarePagesDeployment, renderWranglerJson, generateCloudflarePagesDescriptor } from './implementations/pages.impl';
|
|
11
|
+
export type { CloudflarePagesDescriptor, CloudflarePagesDescriptorInput, CloudflarePagesDeployment, WranglerSecretsStoreBinding, WranglerPagesConfig } from './implementations/pages.impl';
|
|
12
|
+
export { cloudflareApiDescriptor, createCloudflareApiStore } from './secrets/index.ts';
|
|
13
|
+
export { cloudflareApiDescriptor as cloudflareApiDescriptorDefault } from './secrets/index.ts';
|
|
14
|
+
export { cloudflareSecretsStoreDescriptor, createCloudflareSecretsStore } from './secrets/index.ts';
|
|
15
|
+
export { cloudflareSecretsStoreDescriptor as cloudflareSecretsStoreDescriptorDefault } from './secrets/index.ts';
|
|
16
|
+
export { default as cloudflarePlugin } from './cloudflare.plugin';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gCAAgC,EAChC,8BAA8B,EAC9B,wBAAwB,EACxB,sBAAsB,EACtB,sCAAsC,EACtC,+BAA+B,EAC/B,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACX,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,8BAA8B,EAC9B,kCAAkC,EAClC,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EACN,4BAA4B,EAC5B,0BAA0B,EAC1B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACN,4BAA4B,EAC5B,0BAA0B,EAC1B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACN,+BAA+B,EAC/B,+BAA+B,EAC/B,kBAAkB,EAClB,iCAAiC,EACjC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACX,yBAAyB,EACzB,8BAA8B,EAC9B,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,uBAAuB,EACvB,wBAAwB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,IAAI,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gCAAgC,IAAI,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { CloudflareWorkerDescriptorSchema, generateCloudflareWorkerConfig, JOB_RESULT_STORE_BINDING, JOB_RESULT_STORE_CLASS, JOB_RESULT_STORE_INITIAL_MIGRATION_TAG, generateJobConsumerWorkerConfig } from './implementations/workers.impl.js';
|
|
2
|
+
export { CloudflareLogsDescriptorSchema, createCloudflareLogsImplementation } from './implementations/logs.impl.js';
|
|
3
|
+
export { CloudflareQueueDescriptorSchema, generateCloudflareQueueConfig } from './implementations/queues.impl.js';
|
|
4
|
+
export { CloudflareR2DescriptorSchema, generateCloudflareR2Config } from './implementations/r2.impl.js';
|
|
5
|
+
export { CloudflareKVDescriptorSchema, generateCloudflareKVConfig } from './implementations/kv.impl.js';
|
|
6
|
+
export { CloudflarePagesDescriptorSchema, createCloudflarePagesDeployment, renderWranglerJson, generateCloudflarePagesDescriptor } from './implementations/pages.impl.js';
|
|
7
|
+
export { cloudflareApiDescriptor, createCloudflareApiStore } from "./secrets/index.js";
|
|
8
|
+
export { cloudflareApiDescriptor as cloudflareApiDescriptorDefault } from "./secrets/index.js";
|
|
9
|
+
export { cloudflareSecretsStoreDescriptor, createCloudflareSecretsStore } from "./secrets/index.js";
|
|
10
|
+
export { cloudflareSecretsStoreDescriptor as cloudflareSecretsStoreDescriptorDefault } from "./secrets/index.js";
|
|
11
|
+
export { default as cloudflarePlugin } from './cloudflare.plugin.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gCAAgC,EAChC,8BAA8B,EAC9B,wBAAwB,EACxB,sBAAsB,EACtB,sCAAsC,EACtC,+BAA+B,EAC/B,MAAM,gCAAgC,CAAC;AAOxC,OAAO,EACN,8BAA8B,EAC9B,kCAAkC,EAIlC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACN,4BAA4B,EAC5B,0BAA0B,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,4BAA4B,EAC5B,0BAA0B,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,+BAA+B,EAC/B,+BAA+B,EAC/B,kBAAkB,EAClB,iCAAiC,EACjC,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EACN,uBAAuB,EACvB,wBAAwB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,IAAI,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gCAAgC,IAAI,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/pages.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Pages Deployment Module
|
|
3
|
+
*
|
|
4
|
+
* Public entrypoint for Cloudflare Pages deployment helpers.
|
|
5
|
+
* Re-exports the Pages implementation for creating wrangler configs
|
|
6
|
+
* and rendering deployment artifacts.
|
|
7
|
+
*/
|
|
8
|
+
export { createCloudflarePagesDeployment, renderWranglerJson, generateCloudflarePagesDescriptor, CloudflarePagesDescriptorSchema, type CloudflarePagesDeployment, type CloudflarePagesDescriptor, type CloudflarePagesDescriptorInput, type WranglerPagesConfig } from './implementations/pages.impl';
|
|
9
|
+
//# sourceMappingURL=pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,+BAA+B,EAC/B,kBAAkB,EAClB,iCAAiC,EACjC,+BAA+B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,EACxB,MAAM,8BAA8B,CAAC"}
|
package/dist/pages.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Pages Deployment Module
|
|
3
|
+
*
|
|
4
|
+
* Public entrypoint for Cloudflare Pages deployment helpers.
|
|
5
|
+
* Re-exports the Pages implementation for creating wrangler configs
|
|
6
|
+
* and rendering deployment artifacts.
|
|
7
|
+
*/
|
|
8
|
+
export { createCloudflarePagesDeployment, renderWranglerJson, generateCloudflarePagesDescriptor, CloudflarePagesDescriptorSchema } from './implementations/pages.impl.js';
|
|
9
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,+BAA+B,EAC/B,kBAAkB,EAClB,iCAAiC,EACjC,+BAA+B,EAK/B,MAAM,8BAA8B,CAAC"}
|
package/dist/regen.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare wrangler.jsonc regeneration.
|
|
3
|
+
*
|
|
4
|
+
* Pure render layer for the deploy-pipeline regen check. Given a
|
|
5
|
+
* `CloudflareWebAppDeployment` (the default export of a managed
|
|
6
|
+
* `apps/<name>/deployment.config.ts`), produces the canonical
|
|
7
|
+
* wrangler.jsonc string.
|
|
8
|
+
*
|
|
9
|
+
* The render is intentionally separate from filesystem I/O — the
|
|
10
|
+
* `@vibesdotdev/infra-deploy` orchestrator owns reading the on-disk
|
|
11
|
+
* wrangler.jsonc, diffing, and writing. This module's only job is
|
|
12
|
+
* to turn typed config → canonical JSONC string.
|
|
13
|
+
*
|
|
14
|
+
* Subprocess use: this module is dynamically imported from inside
|
|
15
|
+
* the `infra-deploy/config-loader` subprocess so the rendered string
|
|
16
|
+
* can be returned to the orchestrator without requiring infra-deploy
|
|
17
|
+
* to take a static dep on infra-cloudflare.
|
|
18
|
+
*/
|
|
19
|
+
import type { CloudflareWebAppDeployment } from './implementations/web-app.impl';
|
|
20
|
+
/**
|
|
21
|
+
* Canonical header for Workers + Static Assets wrangler.jsonc.
|
|
22
|
+
* Includes the "(Workers + assets shape, per deployment.config.ts)"
|
|
23
|
+
* qualifier to distinguish it from Pages output.
|
|
24
|
+
*/
|
|
25
|
+
export declare const WEB_APP_HEADER_LINES: string[];
|
|
26
|
+
export interface WranglerRenderResult {
|
|
27
|
+
/** True iff the deployment opted in via `managed: true`. */
|
|
28
|
+
managed: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Canonical wrangler.jsonc string. Null when the source isn't a
|
|
31
|
+
* managed Cloudflare web-app deployment (regen skipped).
|
|
32
|
+
*/
|
|
33
|
+
rendered: string | null;
|
|
34
|
+
/** Workers script name, for logging. */
|
|
35
|
+
workerName: string | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Structural type guard for the wrapper. Avoids importing classes —
|
|
39
|
+
* any object with `generateWranglerConfig`, `workerName`, and `managed`
|
|
40
|
+
* is treated as a `CloudflareWebAppDeployment`. The cost of a false
|
|
41
|
+
* positive is a render attempt that throws, which the caller catches.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isCloudflareWebAppDeployment(x: unknown): x is CloudflareWebAppDeployment;
|
|
44
|
+
/**
|
|
45
|
+
* Render the canonical wrangler.jsonc string for a managed web-app
|
|
46
|
+
* deployment. Always uses `WEB_APP_HEADER_LINES`; rendered output is
|
|
47
|
+
* tab-indented JSON with a trailing newline.
|
|
48
|
+
*/
|
|
49
|
+
export declare function renderManagedWranglerJsonc(webAppDeployment: CloudflareWebAppDeployment): string;
|
|
50
|
+
/**
|
|
51
|
+
* Inspect the default export of a `deployment.config.ts` module and
|
|
52
|
+
* — when it's a managed Cloudflare web-app — return the rendered
|
|
53
|
+
* wrangler.jsonc string. Designed to be called from a subprocess
|
|
54
|
+
* loader; never throws on a non-managed export, just returns
|
|
55
|
+
* `{ managed: false, rendered: null, workerName: null }`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function renderWranglerJsoncFromDefaultExport(raw: unknown): WranglerRenderResult;
|
|
58
|
+
//# sourceMappingURL=regen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regen.d.ts","sourceRoot":"","sources":["../src/regen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAGjF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACpC,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wCAAwC;IACxC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,0BAA0B,CAQxF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,gBAAgB,EAAE,0BAA0B,GAAG,MAAM,CAG/F;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CASvF"}
|
package/dist/regen.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare wrangler.jsonc regeneration.
|
|
3
|
+
*
|
|
4
|
+
* Pure render layer for the deploy-pipeline regen check. Given a
|
|
5
|
+
* `CloudflareWebAppDeployment` (the default export of a managed
|
|
6
|
+
* `apps/<name>/deployment.config.ts`), produces the canonical
|
|
7
|
+
* wrangler.jsonc string.
|
|
8
|
+
*
|
|
9
|
+
* The render is intentionally separate from filesystem I/O — the
|
|
10
|
+
* `@vibesdotdev/infra-deploy` orchestrator owns reading the on-disk
|
|
11
|
+
* wrangler.jsonc, diffing, and writing. This module's only job is
|
|
12
|
+
* to turn typed config → canonical JSONC string.
|
|
13
|
+
*
|
|
14
|
+
* Subprocess use: this module is dynamically imported from inside
|
|
15
|
+
* the `infra-deploy/config-loader` subprocess so the rendered string
|
|
16
|
+
* can be returned to the orchestrator without requiring infra-deploy
|
|
17
|
+
* to take a static dep on infra-cloudflare.
|
|
18
|
+
*/
|
|
19
|
+
import { renderWranglerJson } from './implementations/pages.impl.js';
|
|
20
|
+
/**
|
|
21
|
+
* Canonical header for Workers + Static Assets wrangler.jsonc.
|
|
22
|
+
* Includes the "(Workers + assets shape, per deployment.config.ts)"
|
|
23
|
+
* qualifier to distinguish it from Pages output.
|
|
24
|
+
*/
|
|
25
|
+
export const WEB_APP_HEADER_LINES = [
|
|
26
|
+
'Generated by @vibesdotdev/infra-cloudflare (Workers + assets shape, per deployment.config.ts)',
|
|
27
|
+
'https://developers.cloudflare.com/workers/wrangler/configuration/'
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Structural type guard for the wrapper. Avoids importing classes —
|
|
31
|
+
* any object with `generateWranglerConfig`, `workerName`, and `managed`
|
|
32
|
+
* is treated as a `CloudflareWebAppDeployment`. The cost of a false
|
|
33
|
+
* positive is a render attempt that throws, which the caller catches.
|
|
34
|
+
*/
|
|
35
|
+
export function isCloudflareWebAppDeployment(x) {
|
|
36
|
+
if (!x || typeof x !== 'object')
|
|
37
|
+
return false;
|
|
38
|
+
const obj = x;
|
|
39
|
+
return (typeof obj.generateWranglerConfig === 'function' &&
|
|
40
|
+
typeof obj.workerName === 'string' &&
|
|
41
|
+
typeof obj.managed === 'boolean');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render the canonical wrangler.jsonc string for a managed web-app
|
|
45
|
+
* deployment. Always uses `WEB_APP_HEADER_LINES`; rendered output is
|
|
46
|
+
* tab-indented JSON with a trailing newline.
|
|
47
|
+
*/
|
|
48
|
+
export function renderManagedWranglerJsonc(webAppDeployment) {
|
|
49
|
+
const config = webAppDeployment.generateWranglerConfig();
|
|
50
|
+
return renderWranglerJson(config, { headerLines: WEB_APP_HEADER_LINES });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Inspect the default export of a `deployment.config.ts` module and
|
|
54
|
+
* — when it's a managed Cloudflare web-app — return the rendered
|
|
55
|
+
* wrangler.jsonc string. Designed to be called from a subprocess
|
|
56
|
+
* loader; never throws on a non-managed export, just returns
|
|
57
|
+
* `{ managed: false, rendered: null, workerName: null }`.
|
|
58
|
+
*/
|
|
59
|
+
export function renderWranglerJsoncFromDefaultExport(raw) {
|
|
60
|
+
if (!isCloudflareWebAppDeployment(raw)) {
|
|
61
|
+
return { managed: false, rendered: null, workerName: null };
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
managed: raw.managed,
|
|
65
|
+
rendered: raw.managed ? renderManagedWranglerJsonc(raw) : null,
|
|
66
|
+
workerName: raw.workerName
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=regen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regen.js","sourceRoot":"","sources":["../src/regen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,+FAA+F;IAC/F,mEAAmE;CACnE,CAAC;AAcF;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,CAAU;IACtD,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,GAAG,GAAG,CAA4B,CAAC;IACzC,OAAO,CACN,OAAO,GAAG,CAAC,sBAAsB,KAAK,UAAU;QAChD,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ;QAClC,OAAO,GAAG,CAAC,OAAO,KAAK,SAAS,CAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,gBAA4C;IACtF,MAAM,MAAM,GAAG,gBAAgB,CAAC,sBAAsB,EAAwC,CAAC;IAC/F,OAAO,kBAAkB,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oCAAoC,CAAC,GAAY;IAChE,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO;QACN,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;QAC9D,UAAU,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare API Backend Descriptor
|
|
3
|
+
*
|
|
4
|
+
* Pushes secrets to Cloudflare Pages/Workers via the REST API.
|
|
5
|
+
* Write-only: CF does not expose secret values after setting.
|
|
6
|
+
*/
|
|
7
|
+
import type { SecretsStoreDescriptor } from '@vibesdotdev/secrets/kinds/store.schema';
|
|
8
|
+
/**
|
|
9
|
+
* Cloudflare API secrets backend descriptor.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Project names can be provided via descriptor.config.cfProjectNames.
|
|
13
|
+
* If not provided, the implementation will attempt to derive them from
|
|
14
|
+
* runtime-resolved infra/web-app descriptors (requires runtime context).
|
|
15
|
+
*/
|
|
16
|
+
declare const descriptor: SecretsStoreDescriptor;
|
|
17
|
+
export default descriptor;
|
|
18
|
+
//# sourceMappingURL=cloudflare-api.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare-api.descriptor.d.ts","sourceRoot":"","sources":["../../src/secrets/cloudflare-api.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEtF;;;;;;;GAOG;AACH,QAAA,MAAM,UAAU,EAAE,sBAejB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|