@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,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Web App (Workers + Static Assets) Implementation
|
|
3
|
+
*
|
|
4
|
+
* Generates the COMPLETE wrangler.jsonc shape for SvelteKit (and other SSR-asset)
|
|
5
|
+
* apps that deploy as a Cloudflare Worker with a Static Assets binding —
|
|
6
|
+
* the production target for every web app in this monorepo.
|
|
7
|
+
*
|
|
8
|
+
* `createCloudflareWebAppDeployment({ ... })` takes the provider-agnostic
|
|
9
|
+
* `AppDeployment` plus every Cloudflare-specific config group, and emits a
|
|
10
|
+
* `WranglerWebAppConfig` covering every wrangler key currently in use across
|
|
11
|
+
* the repo: `name`, `main`, `compatibility_date`, `compatibility_flags`,
|
|
12
|
+
* `assets`, `routes`, `placement`, `vars`, `secrets_store_secrets`, `secrets.required`,
|
|
13
|
+
* `d1_databases`, `r2_buckets`, `services`, `observability`, `triggers`,
|
|
14
|
+
* `queues`, `durable_objects`, `migrations`, `send_email`, `workers_dev`,
|
|
15
|
+
* `preview_urls`.
|
|
16
|
+
*
|
|
17
|
+
* The output of `generateWranglerConfig()` is the authoritative shape;
|
|
18
|
+
* `apps/<name>/wrangler.jsonc` is a build artifact written by
|
|
19
|
+
* `vibes infra deploy regenerate` (the sole supported path) from each app's
|
|
20
|
+
* `deployment.config.ts`. Drift is caught by the CLI with `--check`.
|
|
21
|
+
*/
|
|
22
|
+
import * as z from 'zod/v4';
|
|
23
|
+
import type { AppDeployment } from '@vibesdotdev/infra-core/deployment';
|
|
24
|
+
export declare const CloudflareWebAppDescriptorSchema: z.ZodObject<{
|
|
25
|
+
kind: z.ZodLiteral<"infra/web-app">;
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
adapter: z.ZodLiteral<"cloudflare-workers">;
|
|
29
|
+
cfWorkerName: z.ZodString;
|
|
30
|
+
outputDir: z.ZodString;
|
|
31
|
+
workerEntry: z.ZodDefault<z.ZodString>;
|
|
32
|
+
compatibilityDate: z.ZodOptional<z.ZodString>;
|
|
33
|
+
compatibilityFlags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
34
|
+
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
35
|
+
secretsStoreId: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type CloudflareWebAppDescriptor = z.infer<typeof CloudflareWebAppDescriptorSchema>;
|
|
38
|
+
export type CloudflareWebAppDescriptorInput = z.input<typeof CloudflareWebAppDescriptorSchema>;
|
|
39
|
+
export interface WranglerSecretsStoreBinding {
|
|
40
|
+
binding: string;
|
|
41
|
+
store_id: string;
|
|
42
|
+
secret_name: string;
|
|
43
|
+
}
|
|
44
|
+
export interface WranglerWebAppRoute {
|
|
45
|
+
pattern: string;
|
|
46
|
+
custom_domain?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface WranglerWebAppAssets {
|
|
49
|
+
directory: string;
|
|
50
|
+
binding?: string;
|
|
51
|
+
not_found_handling?: 'none' | 'single-page-application' | '404-page';
|
|
52
|
+
run_worker_first?: boolean | string[];
|
|
53
|
+
}
|
|
54
|
+
export interface WranglerD1Database {
|
|
55
|
+
binding: string;
|
|
56
|
+
database_name: string;
|
|
57
|
+
database_id?: string;
|
|
58
|
+
migrations_dir?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface WranglerR2Bucket {
|
|
61
|
+
binding: string;
|
|
62
|
+
bucket_name: string;
|
|
63
|
+
}
|
|
64
|
+
export interface WranglerServiceBinding {
|
|
65
|
+
binding: string;
|
|
66
|
+
service: string;
|
|
67
|
+
entrypoint?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface WranglerObservability {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
head_sampling_rate?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface WranglerAiBinding {
|
|
74
|
+
binding: string;
|
|
75
|
+
staging?: boolean;
|
|
76
|
+
remote?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface WranglerPlacement {
|
|
79
|
+
mode: 'smart';
|
|
80
|
+
}
|
|
81
|
+
export interface WranglerTriggers {
|
|
82
|
+
crons: string[];
|
|
83
|
+
}
|
|
84
|
+
export interface WranglerQueueProducer {
|
|
85
|
+
queue: string;
|
|
86
|
+
binding: string;
|
|
87
|
+
}
|
|
88
|
+
export interface WranglerQueueConsumer {
|
|
89
|
+
queue: string;
|
|
90
|
+
max_batch_size?: number;
|
|
91
|
+
max_batch_timeout?: number;
|
|
92
|
+
max_retries?: number;
|
|
93
|
+
dead_letter_queue?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface WranglerQueues {
|
|
96
|
+
producers?: WranglerQueueProducer[];
|
|
97
|
+
consumers?: WranglerQueueConsumer[];
|
|
98
|
+
}
|
|
99
|
+
export interface WranglerDurableObjectBinding {
|
|
100
|
+
name: string;
|
|
101
|
+
class_name: string;
|
|
102
|
+
script_name?: string;
|
|
103
|
+
environment?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface WranglerDurableObjects {
|
|
106
|
+
bindings: WranglerDurableObjectBinding[];
|
|
107
|
+
}
|
|
108
|
+
export interface WranglerMigration {
|
|
109
|
+
tag: string;
|
|
110
|
+
new_classes?: string[];
|
|
111
|
+
new_sqlite_classes?: string[];
|
|
112
|
+
deleted_classes?: string[];
|
|
113
|
+
renamed_classes?: Array<{
|
|
114
|
+
from: string;
|
|
115
|
+
to: string;
|
|
116
|
+
}>;
|
|
117
|
+
transferred_classes?: Array<{
|
|
118
|
+
from: string;
|
|
119
|
+
from_script: string;
|
|
120
|
+
to: string;
|
|
121
|
+
}>;
|
|
122
|
+
}
|
|
123
|
+
export interface WranglerSendEmailBinding {
|
|
124
|
+
name: string;
|
|
125
|
+
destination_address?: string;
|
|
126
|
+
allowed_destination_addresses?: string[];
|
|
127
|
+
}
|
|
128
|
+
export interface WranglerAnalyticsEngineBinding {
|
|
129
|
+
binding: string;
|
|
130
|
+
dataset: string;
|
|
131
|
+
}
|
|
132
|
+
export interface WranglerWebAppConfig {
|
|
133
|
+
$schema?: string;
|
|
134
|
+
name: string;
|
|
135
|
+
/** Worker entry. Omitted only for `staticAssetsOnly` configs (e.g. apps/docs). */
|
|
136
|
+
main?: string;
|
|
137
|
+
compatibility_date: string;
|
|
138
|
+
compatibility_flags: string[];
|
|
139
|
+
workers_dev?: boolean;
|
|
140
|
+
preview_urls?: boolean;
|
|
141
|
+
upload_source_maps?: boolean;
|
|
142
|
+
observability?: WranglerObservability;
|
|
143
|
+
placement?: WranglerPlacement;
|
|
144
|
+
/** Always present: every CF Worker in this repo binds static assets. */
|
|
145
|
+
assets: WranglerWebAppAssets;
|
|
146
|
+
routes?: WranglerWebAppRoute[];
|
|
147
|
+
vars?: Record<string, string>;
|
|
148
|
+
secrets_store_secrets?: WranglerSecretsStoreBinding[];
|
|
149
|
+
secrets?: {
|
|
150
|
+
required: string[];
|
|
151
|
+
};
|
|
152
|
+
d1_databases?: WranglerD1Database[];
|
|
153
|
+
kv_namespaces?: Array<{
|
|
154
|
+
binding: string;
|
|
155
|
+
id: string;
|
|
156
|
+
preview_id?: string;
|
|
157
|
+
}>;
|
|
158
|
+
r2_buckets?: WranglerR2Bucket[];
|
|
159
|
+
services?: WranglerServiceBinding[];
|
|
160
|
+
ai?: WranglerAiBinding;
|
|
161
|
+
triggers?: WranglerTriggers;
|
|
162
|
+
queues?: WranglerQueues;
|
|
163
|
+
durable_objects?: WranglerDurableObjects;
|
|
164
|
+
migrations?: WranglerMigration[];
|
|
165
|
+
send_email?: WranglerSendEmailBinding[];
|
|
166
|
+
analytics_engine_datasets?: WranglerAnalyticsEngineBinding[];
|
|
167
|
+
/** esbuild/wrangler bundler rules (e.g. to treat leaked .svelte icon files from @lucide/svelte as text). */
|
|
168
|
+
rules?: Array<{
|
|
169
|
+
type: string;
|
|
170
|
+
globs: string[];
|
|
171
|
+
fallthrough?: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Shared Workers Analytics Engine dataset used for per-org bandwidth
|
|
176
|
+
* attribution. Bound automatically into every customer-facing Worker so
|
|
177
|
+
* the `billing.bandwidth-sampler` job has a uniform write target. Apps
|
|
178
|
+
* that need to opt out can pass `analyticsEngineDatasets: []`.
|
|
179
|
+
*/
|
|
180
|
+
export declare const SHARED_BANDWIDTH_TELEMETRY_DATASET: WranglerAnalyticsEngineBinding;
|
|
181
|
+
/**
|
|
182
|
+
* Provider-agnostic cloudflare-side configuration for `createCloudflareWebAppDeployment`.
|
|
183
|
+
* Every field is optional; the generator emits only what the app declares so
|
|
184
|
+
* existing apps that don't (e.g.) bind R2 don't get an empty `r2_buckets: []`
|
|
185
|
+
* key in their wrangler.jsonc.
|
|
186
|
+
*/
|
|
187
|
+
export interface CloudflareWebAppOptions {
|
|
188
|
+
workerName: string;
|
|
189
|
+
deployment: AppDeployment;
|
|
190
|
+
compatibilityDate?: string;
|
|
191
|
+
compatibilityFlags?: string[];
|
|
192
|
+
/** When set, secret env vars are emitted as `secrets_store_secrets[]`. */
|
|
193
|
+
secretsStoreId?: string;
|
|
194
|
+
/** `_worker.js`-relative path inside outputDir; defaults to `_worker.js`. */
|
|
195
|
+
workerEntry?: string;
|
|
196
|
+
/** Override `assets.binding`; defaults to `ASSETS`. */
|
|
197
|
+
assetsBinding?: string;
|
|
198
|
+
/** Override `assets.not_found_handling`; defaults to `'none'`. */
|
|
199
|
+
assetsNotFoundHandling?: 'none' | 'single-page-application' | '404-page';
|
|
200
|
+
/** Override `assets.run_worker_first`; defaults to `true` for SSR adapters. */
|
|
201
|
+
assetsRunWorkerFirst?: boolean | string[];
|
|
202
|
+
/** Omit `main` and emit a static-assets-only Worker (used for `apps/docs`). */
|
|
203
|
+
staticAssetsOnly?: boolean;
|
|
204
|
+
/** `workers_dev` flag — defaults to omitted (CF default behavior). */
|
|
205
|
+
workersDev?: boolean;
|
|
206
|
+
/** `preview_urls` flag — defaults to omitted (CF default behavior). */
|
|
207
|
+
previewUrls?: boolean;
|
|
208
|
+
/** Observability config; pass `{ enabled: true }` to emit `observability: { enabled: true }`. */
|
|
209
|
+
observability?: WranglerObservability;
|
|
210
|
+
/** Placement config; use `{ mode: 'smart' }` for Cloudflare Smart Placement. */
|
|
211
|
+
placement?: WranglerPlacement;
|
|
212
|
+
/** Convenience flag for `placement: { mode: 'smart' }`. */
|
|
213
|
+
smartPlacement?: boolean;
|
|
214
|
+
/** D1 database bindings. */
|
|
215
|
+
d1Databases?: WranglerD1Database[];
|
|
216
|
+
/** KV namespace bindings. */
|
|
217
|
+
kvNamespaces?: Array<{
|
|
218
|
+
binding: string;
|
|
219
|
+
id: string;
|
|
220
|
+
preview_id?: string;
|
|
221
|
+
}>;
|
|
222
|
+
/** R2 bucket bindings. */
|
|
223
|
+
r2Buckets?: WranglerR2Bucket[];
|
|
224
|
+
/** Worker-to-Worker Service Bindings (e.g. `AUTH_SERVICE` → `vibes-auth`). */
|
|
225
|
+
services?: WranglerServiceBinding[];
|
|
226
|
+
/** Cloudflare Workers AI binding. */
|
|
227
|
+
ai?: WranglerAiBinding;
|
|
228
|
+
/** `triggers.crons` cron expressions. */
|
|
229
|
+
crons?: string[];
|
|
230
|
+
/** CF Queue producer bindings. */
|
|
231
|
+
queueProducers?: WranglerQueueProducer[];
|
|
232
|
+
/** CF Queue consumer configs (declared on the consuming Worker). */
|
|
233
|
+
queueConsumers?: WranglerQueueConsumer[];
|
|
234
|
+
/** Durable Object class bindings. */
|
|
235
|
+
durableObjects?: WranglerDurableObjectBinding[];
|
|
236
|
+
/** DO migration tags (required when declaring `durableObjects`). */
|
|
237
|
+
migrations?: WranglerMigration[];
|
|
238
|
+
/** `send_email[]` bindings for the Cloudflare Email Workers API. */
|
|
239
|
+
sendEmail?: WranglerSendEmailBinding[];
|
|
240
|
+
/**
|
|
241
|
+
* Workers Analytics Engine dataset bindings. Used for per-org bandwidth
|
|
242
|
+
* attribution by `@vibesdotdev/cloudflare-bandwidth-telemetry` (see
|
|
243
|
+
* `billing.bandwidth-sampler`). All customer-facing Workers in this
|
|
244
|
+
* monorepo share the same `bandwidth_egress` dataset.
|
|
245
|
+
*/
|
|
246
|
+
analyticsEngineDatasets?: WranglerAnalyticsEngineBinding[];
|
|
247
|
+
/**
|
|
248
|
+
* When `true` (default), this deployment is managed by the Vibes infra system
|
|
249
|
+
* and wrangler.jsonc should be regenerated from the deployment config.
|
|
250
|
+
* Set to `false` to opt out of automatic wrangler.jsonc regeneration.
|
|
251
|
+
*/
|
|
252
|
+
managed?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* When `true`, run `wrangler d1 migrations apply` for each declared D1 database
|
|
255
|
+
* with a `migrations_dir` before deploying the Worker. Defaults to `false`.
|
|
256
|
+
*/
|
|
257
|
+
autoMigrateD1?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* When `true`, upload source maps alongside the Worker for better production
|
|
260
|
+
* stack traces. Defaults to `true` for all managed deployments.
|
|
261
|
+
*/
|
|
262
|
+
uploadSourceMaps?: boolean;
|
|
263
|
+
/** Additional wrangler/esbuild rules (e.g. to treat third-party .svelte icon files as text so wrangler bundling doesn't fail). */
|
|
264
|
+
rules?: Array<{
|
|
265
|
+
type: string;
|
|
266
|
+
globs: string[];
|
|
267
|
+
fallthrough?: boolean;
|
|
268
|
+
}>;
|
|
269
|
+
}
|
|
270
|
+
export interface CloudflareWebAppDeployment {
|
|
271
|
+
workerName: string;
|
|
272
|
+
deployment: AppDeployment;
|
|
273
|
+
compatibilityDate: string;
|
|
274
|
+
/**
|
|
275
|
+
* When `true`, this deployment is managed by the Vibes infra system
|
|
276
|
+
* and wrangler.jsonc should be regenerated from the deployment config.
|
|
277
|
+
* Defaults to `true` for all Cloudflare web app deployments.
|
|
278
|
+
*/
|
|
279
|
+
managed: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* When `true`, run D1 migrations before deploying the Worker.
|
|
282
|
+
*/
|
|
283
|
+
autoMigrateD1: boolean;
|
|
284
|
+
generateWranglerConfig(): WranglerWebAppConfig;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Create a Cloudflare Workers + Static Assets deployment wrapper.
|
|
288
|
+
*/
|
|
289
|
+
export declare function createCloudflareWebAppDeployment(options: CloudflareWebAppOptions): CloudflareWebAppDeployment;
|
|
290
|
+
/**
|
|
291
|
+
* Generate a Workers Static Assets descriptor from an existing AppDeployment.
|
|
292
|
+
*/
|
|
293
|
+
export declare function generateCloudflareWebAppDescriptor(deployment: AppDeployment, cfWorkerName: string): CloudflareWebAppDescriptor;
|
|
294
|
+
//# sourceMappingURL=web-app.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-app.impl.d.ts","sourceRoot":"","sources":["../../src/implementations/web-app.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAExE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;iBAuB3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC1F,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE/F,MAAM,WAAW,2BAA2B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EA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AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,uBAAuB,GAC9B,0BAA0B,CA2J5B;AAED;;GAEG;AACH,wBAAgB,kCAAkC,CACjD,UAAU,EAAE,aAAa,EACzB,YAAY,EAAE,MAAM,GAClB,0BAA0B,CAa5B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Web App (Workers + Static Assets) Implementation
|
|
3
|
+
*
|
|
4
|
+
* Generates the COMPLETE wrangler.jsonc shape for SvelteKit (and other SSR-asset)
|
|
5
|
+
* apps that deploy as a Cloudflare Worker with a Static Assets binding —
|
|
6
|
+
* the production target for every web app in this monorepo.
|
|
7
|
+
*
|
|
8
|
+
* `createCloudflareWebAppDeployment({ ... })` takes the provider-agnostic
|
|
9
|
+
* `AppDeployment` plus every Cloudflare-specific config group, and emits a
|
|
10
|
+
* `WranglerWebAppConfig` covering every wrangler key currently in use across
|
|
11
|
+
* the repo: `name`, `main`, `compatibility_date`, `compatibility_flags`,
|
|
12
|
+
* `assets`, `routes`, `placement`, `vars`, `secrets_store_secrets`, `secrets.required`,
|
|
13
|
+
* `d1_databases`, `r2_buckets`, `services`, `observability`, `triggers`,
|
|
14
|
+
* `queues`, `durable_objects`, `migrations`, `send_email`, `workers_dev`,
|
|
15
|
+
* `preview_urls`.
|
|
16
|
+
*
|
|
17
|
+
* The output of `generateWranglerConfig()` is the authoritative shape;
|
|
18
|
+
* `apps/<name>/wrangler.jsonc` is a build artifact written by
|
|
19
|
+
* `vibes infra deploy regenerate` (the sole supported path) from each app's
|
|
20
|
+
* `deployment.config.ts`. Drift is caught by the CLI with `--check`.
|
|
21
|
+
*/
|
|
22
|
+
import * as z from 'zod/v4';
|
|
23
|
+
export const CloudflareWebAppDescriptorSchema = z.object({
|
|
24
|
+
kind: z.literal('infra/web-app'),
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
name: z.string().min(1),
|
|
27
|
+
adapter: z.literal('cloudflare-workers'),
|
|
28
|
+
/** Cloudflare Workers script name (e.g., "vibes-ai") */
|
|
29
|
+
cfWorkerName: z.string().min(1),
|
|
30
|
+
/** Build output directory consumed by both `main` and `assets.directory` */
|
|
31
|
+
outputDir: z.string().min(1),
|
|
32
|
+
/** Path to the `_worker.js` entry point relative to `outputDir` */
|
|
33
|
+
workerEntry: z.string().min(1).default('_worker.js'),
|
|
34
|
+
/** Compatibility date for wrangler */
|
|
35
|
+
compatibilityDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
36
|
+
/** Compatibility flags for wrangler */
|
|
37
|
+
compatibilityFlags: z.array(z.string()).default(['nodejs_compat']),
|
|
38
|
+
/** Environment variables to include */
|
|
39
|
+
env: z.record(z.string(), z.string()).default({}),
|
|
40
|
+
/**
|
|
41
|
+
* Account-level Cloudflare Secrets Store ID. When set, secret env vars
|
|
42
|
+
* emit as `secrets_store_secrets[]` bindings; otherwise the generator
|
|
43
|
+
* falls back to `secrets.required[]` for deploy-time validation.
|
|
44
|
+
*/
|
|
45
|
+
secretsStoreId: z.string().min(1).optional()
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Shared Workers Analytics Engine dataset used for per-org bandwidth
|
|
49
|
+
* attribution. Bound automatically into every customer-facing Worker so
|
|
50
|
+
* the `billing.bandwidth-sampler` job has a uniform write target. Apps
|
|
51
|
+
* that need to opt out can pass `analyticsEngineDatasets: []`.
|
|
52
|
+
*/
|
|
53
|
+
export const SHARED_BANDWIDTH_TELEMETRY_DATASET = {
|
|
54
|
+
binding: 'BANDWIDTH_TELEMETRY',
|
|
55
|
+
dataset: 'bandwidth_egress'
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Create a Cloudflare Workers + Static Assets deployment wrapper.
|
|
59
|
+
*/
|
|
60
|
+
export function createCloudflareWebAppDeployment(options) {
|
|
61
|
+
const { workerName, deployment, compatibilityDate, compatibilityFlags = ['nodejs_compat'], secretsStoreId, workerEntry = '_worker.js', assetsBinding = 'ASSETS', assetsNotFoundHandling = 'none', assetsRunWorkerFirst = true, staticAssetsOnly = false, workersDev, previewUrls, observability, placement, smartPlacement, d1Databases, kvNamespaces, r2Buckets, services, ai, crons, queueProducers, queueConsumers, durableObjects, migrations, sendEmail, analyticsEngineDatasets, managed = true, autoMigrateD1 = false, uploadSourceMaps = true, rules } = options;
|
|
62
|
+
if (kvNamespaces?.length)
|
|
63
|
+
deployment.kvNamespaces = kvNamespaces;
|
|
64
|
+
const compatDate = compatibilityDate ?? new Date().toISOString().slice(0, 10);
|
|
65
|
+
return {
|
|
66
|
+
workerName,
|
|
67
|
+
deployment,
|
|
68
|
+
compatibilityDate: compatDate,
|
|
69
|
+
managed,
|
|
70
|
+
autoMigrateD1,
|
|
71
|
+
generateWranglerConfig() {
|
|
72
|
+
// wrangler.jsonc paths are resolved relative to the directory wrangler
|
|
73
|
+
// runs from. CI / infra-deploy both invoke `wrangler deploy --cwd <appDir>`,
|
|
74
|
+
// so the assets directory and `main` must be APP-relative even though
|
|
75
|
+
// `deployment.build.outputDir` is workspace-relative (that form is used
|
|
76
|
+
// by the build command and other consumers).
|
|
77
|
+
const rawOutputDir = deployment.build.outputDir.replace(/\/$/, '');
|
|
78
|
+
const appDir = deployment.build.appDir.replace(/\/$/, '');
|
|
79
|
+
const outputDir = rawOutputDir.startsWith(`${appDir}/`)
|
|
80
|
+
? rawOutputDir.slice(appDir.length + 1)
|
|
81
|
+
: rawOutputDir;
|
|
82
|
+
const assets = staticAssetsOnly
|
|
83
|
+
? {
|
|
84
|
+
directory: outputDir,
|
|
85
|
+
not_found_handling: assetsNotFoundHandling
|
|
86
|
+
}
|
|
87
|
+
: {
|
|
88
|
+
directory: outputDir,
|
|
89
|
+
binding: assetsBinding,
|
|
90
|
+
not_found_handling: assetsNotFoundHandling,
|
|
91
|
+
run_worker_first: assetsRunWorkerFirst
|
|
92
|
+
};
|
|
93
|
+
const config = {
|
|
94
|
+
$schema: 'node_modules/wrangler/config-schema.json',
|
|
95
|
+
name: workerName,
|
|
96
|
+
compatibility_date: compatDate,
|
|
97
|
+
compatibility_flags: compatibilityFlags,
|
|
98
|
+
assets
|
|
99
|
+
};
|
|
100
|
+
if (!staticAssetsOnly) {
|
|
101
|
+
config.main = `${outputDir}/${workerEntry}`;
|
|
102
|
+
}
|
|
103
|
+
if (workersDev !== undefined)
|
|
104
|
+
config.workers_dev = workersDev;
|
|
105
|
+
if (previewUrls !== undefined)
|
|
106
|
+
config.preview_urls = previewUrls;
|
|
107
|
+
if (uploadSourceMaps)
|
|
108
|
+
config.upload_source_maps = true;
|
|
109
|
+
if (observability)
|
|
110
|
+
config.observability = observability;
|
|
111
|
+
if (placement)
|
|
112
|
+
config.placement = placement;
|
|
113
|
+
else if (smartPlacement)
|
|
114
|
+
config.placement = { mode: 'smart' };
|
|
115
|
+
const primaryRoutes = deployment.origins
|
|
116
|
+
.filter((o) => o.kind === 'primary')
|
|
117
|
+
.map((o) => ({ pattern: o.hostname, custom_domain: true }));
|
|
118
|
+
if (primaryRoutes.length > 0) {
|
|
119
|
+
config.routes = primaryRoutes;
|
|
120
|
+
}
|
|
121
|
+
const plainEnvVars = {};
|
|
122
|
+
for (const envVar of deployment.env) {
|
|
123
|
+
if (!envVar.secret && envVar.value !== undefined) {
|
|
124
|
+
plainEnvVars[envVar.name] = envVar.value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (Object.keys(plainEnvVars).length > 0) {
|
|
128
|
+
config.vars = plainEnvVars;
|
|
129
|
+
}
|
|
130
|
+
const secretEnvVars = deployment.env
|
|
131
|
+
.filter((envVar) => envVar.secret)
|
|
132
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
133
|
+
if (secretEnvVars.length > 0) {
|
|
134
|
+
if (secretsStoreId) {
|
|
135
|
+
config.secrets_store_secrets = secretEnvVars
|
|
136
|
+
.map((envVar) => ({
|
|
137
|
+
binding: envVar.name,
|
|
138
|
+
store_id: secretsStoreId,
|
|
139
|
+
secret_name: envVar.storeKey ?? envVar.name
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
config.secrets = {
|
|
144
|
+
required: secretEnvVars
|
|
145
|
+
.filter((envVar) => envVar.required !== false)
|
|
146
|
+
.map((envVar) => envVar.name)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (d1Databases?.length)
|
|
151
|
+
config.d1_databases = d1Databases;
|
|
152
|
+
if (kvNamespaces?.length)
|
|
153
|
+
config.kv_namespaces = kvNamespaces;
|
|
154
|
+
if (r2Buckets?.length)
|
|
155
|
+
config.r2_buckets = r2Buckets;
|
|
156
|
+
if (services?.length)
|
|
157
|
+
config.services = services;
|
|
158
|
+
if (ai)
|
|
159
|
+
config.ai = ai;
|
|
160
|
+
if (crons?.length)
|
|
161
|
+
config.triggers = { crons };
|
|
162
|
+
if (queueProducers?.length || queueConsumers?.length) {
|
|
163
|
+
config.queues = {};
|
|
164
|
+
if (queueProducers?.length)
|
|
165
|
+
config.queues.producers = queueProducers;
|
|
166
|
+
if (queueConsumers?.length)
|
|
167
|
+
config.queues.consumers = queueConsumers;
|
|
168
|
+
}
|
|
169
|
+
if (durableObjects?.length) {
|
|
170
|
+
config.durable_objects = { bindings: durableObjects };
|
|
171
|
+
}
|
|
172
|
+
if (migrations?.length)
|
|
173
|
+
config.migrations = migrations;
|
|
174
|
+
if (sendEmail?.length)
|
|
175
|
+
config.send_email = sendEmail;
|
|
176
|
+
// WAE binding default: every customer-facing Worker gets
|
|
177
|
+
// BANDWIDTH_TELEMETRY → bandwidth_egress so the
|
|
178
|
+
// billing.bandwidth-sampler aggregator can attribute bytes per
|
|
179
|
+
// org. Opt out by passing `analyticsEngineDatasets: []`.
|
|
180
|
+
const resolvedAnalyticsBindings = analyticsEngineDatasets ?? [SHARED_BANDWIDTH_TELEMETRY_DATASET];
|
|
181
|
+
if (resolvedAnalyticsBindings.length > 0) {
|
|
182
|
+
config.analytics_engine_datasets = resolvedAnalyticsBindings;
|
|
183
|
+
}
|
|
184
|
+
if (rules?.length)
|
|
185
|
+
config.rules = rules;
|
|
186
|
+
return config;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Generate a Workers Static Assets descriptor from an existing AppDeployment.
|
|
192
|
+
*/
|
|
193
|
+
export function generateCloudflareWebAppDescriptor(deployment, cfWorkerName) {
|
|
194
|
+
return CloudflareWebAppDescriptorSchema.parse({
|
|
195
|
+
kind: 'infra/web-app',
|
|
196
|
+
id: deployment.appId,
|
|
197
|
+
name: deployment.appName,
|
|
198
|
+
adapter: 'cloudflare-workers',
|
|
199
|
+
cfWorkerName,
|
|
200
|
+
outputDir: deployment.build.outputDir,
|
|
201
|
+
env: deployment.env.reduce((acc, e) => {
|
|
202
|
+
if (e.value)
|
|
203
|
+
acc[e.name] = e.value;
|
|
204
|
+
return acc;
|
|
205
|
+
}, {})
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=web-app.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-app.impl.js","sourceRoot":"","sources":["../../src/implementations/web-app.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAChC,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,wDAAwD;IACxD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAA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