@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,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Infrastructure Plugin
|
|
3
|
+
*
|
|
4
|
+
* Registers Cloudflare provider implementations for each infra kind.
|
|
5
|
+
* When a descriptor's adapter/engine matches a Cloudflare provider,
|
|
6
|
+
* the corresponding config generator is loaded.
|
|
7
|
+
*
|
|
8
|
+
* Web apps deploy via @sveltejs/adapter-cloudflare Workers Static Assets,
|
|
9
|
+
* configured per-app in apps/{app}-web/wrangler.jsonc. The Pages module
|
|
10
|
+
* provides `createCloudflarePagesDeployment` and `renderWranglerJson`
|
|
11
|
+
* for consumers that need programmatic wrangler config generation.
|
|
12
|
+
*/
|
|
13
|
+
import { createRuntimePlugin, createRuntimeImplementation, createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
14
|
+
import { generateCloudflareWorkerConfig, CloudflareWorkerDescriptorSchema } from './implementations/workers.impl';
|
|
15
|
+
import { generateCloudflareQueueConfig, CloudflareQueueDescriptorSchema } from './implementations/queues.impl';
|
|
16
|
+
import { generateCloudflareR2Config, CloudflareR2DescriptorSchema } from './implementations/r2.impl';
|
|
17
|
+
import { generateCloudflareKVConfig, CloudflareKVDescriptorSchema } from './implementations/kv.impl';
|
|
18
|
+
import { generateCloudflarePagesDescriptor, CloudflarePagesDescriptorSchema } from './implementations/pages.impl';
|
|
19
|
+
import { CloudflareWebAppDescriptorSchema } from './implementations/web-app.impl';
|
|
20
|
+
import { CloudflareLogsDescriptorSchema, createCloudflareLogsImplementation } from './implementations/logs.impl';
|
|
21
|
+
import { CloudflareAlertsDescriptorSchema, createCloudflareAlertsImplementation } from './implementations/alerts.impl';
|
|
22
|
+
import { CloudflareObservabilityDescriptorSchema, createCloudflareObservabilityImplementation } from './implementations/observability.impl';
|
|
23
|
+
import { CloudflareRumDescriptorSchema, createCloudflareRumImplementation } from './implementations/rum.impl';
|
|
24
|
+
import cloudflareApiDescriptor from './secrets/cloudflare-api.descriptor';
|
|
25
|
+
import cloudflareSecretsStoreDescriptor from './secrets/cloudflare-secrets-store.descriptor';
|
|
26
|
+
import cloudflareAlertsDescriptor from "./implementations/alerts.descriptor.js";
|
|
27
|
+
import cloudflareLogsDescriptor from './implementations/logs.descriptor';
|
|
28
|
+
import cloudflareObservabilityDescriptor from "./implementations/observability.descriptor.js";
|
|
29
|
+
import cloudflareRumDescriptor from "./implementations/rum.descriptor.js";
|
|
30
|
+
function createWorkerImpl(input) {
|
|
31
|
+
const descriptor = CloudflareWorkerDescriptorSchema.parse(input);
|
|
32
|
+
return createRuntimeImplementation({
|
|
33
|
+
id: 'cloudflare-workers',
|
|
34
|
+
kind: 'infra/worker',
|
|
35
|
+
priority: 10,
|
|
36
|
+
implementation: {
|
|
37
|
+
generateConfig: () => generateCloudflareWorkerConfig(descriptor)
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function createQueueImpl(input) {
|
|
42
|
+
const descriptor = CloudflareQueueDescriptorSchema.parse(input);
|
|
43
|
+
return createRuntimeImplementation({
|
|
44
|
+
id: 'cloudflare-queues',
|
|
45
|
+
kind: 'infra/queue',
|
|
46
|
+
priority: 10,
|
|
47
|
+
implementation: {
|
|
48
|
+
generateConfig: () => generateCloudflareQueueConfig(descriptor)
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function createR2Impl(input) {
|
|
53
|
+
const descriptor = CloudflareR2DescriptorSchema.parse(input);
|
|
54
|
+
return createRuntimeImplementation({
|
|
55
|
+
id: 'cloudflare-r2',
|
|
56
|
+
kind: 'infra/object-storage',
|
|
57
|
+
priority: 10,
|
|
58
|
+
implementation: {
|
|
59
|
+
generateConfig: () => generateCloudflareR2Config(descriptor)
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function createKVImpl(input) {
|
|
64
|
+
const descriptor = CloudflareKVDescriptorSchema.parse(input);
|
|
65
|
+
return createRuntimeImplementation({
|
|
66
|
+
id: 'cloudflare-kv',
|
|
67
|
+
kind: 'infra/cache',
|
|
68
|
+
priority: 10,
|
|
69
|
+
implementation: {
|
|
70
|
+
generateConfig: () => generateCloudflareKVConfig(descriptor)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function createPagesImpl(input) {
|
|
75
|
+
const descriptor = CloudflarePagesDescriptorSchema.parse(input);
|
|
76
|
+
return createRuntimeImplementation({
|
|
77
|
+
id: 'cloudflare-pages',
|
|
78
|
+
kind: 'infra/web-app',
|
|
79
|
+
priority: 10,
|
|
80
|
+
implementation: {
|
|
81
|
+
generateConfig: () => descriptor,
|
|
82
|
+
getProjectName: () => descriptor.cfProjectName
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function createWebAppImpl(input) {
|
|
87
|
+
const descriptor = CloudflareWebAppDescriptorSchema.parse(input);
|
|
88
|
+
return createRuntimeImplementation({
|
|
89
|
+
id: 'cloudflare-web-app',
|
|
90
|
+
kind: 'infra/web-app',
|
|
91
|
+
priority: 20,
|
|
92
|
+
implementation: {
|
|
93
|
+
generateConfig: () => descriptor,
|
|
94
|
+
getWorkerName: () => descriptor.cfWorkerName
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function createLogsImpl(input) {
|
|
99
|
+
const descriptor = CloudflareLogsDescriptorSchema.parse(input);
|
|
100
|
+
const impl = createCloudflareLogsImplementation(descriptor);
|
|
101
|
+
return createRuntimeImplementation({
|
|
102
|
+
id: 'cloudflare-logs',
|
|
103
|
+
kind: 'infra/logs',
|
|
104
|
+
priority: 10,
|
|
105
|
+
implementation: impl
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function createAlertsImpl(input) {
|
|
109
|
+
const descriptor = CloudflareAlertsDescriptorSchema.parse(input);
|
|
110
|
+
const impl = createCloudflareAlertsImplementation(descriptor);
|
|
111
|
+
return createRuntimeImplementation({
|
|
112
|
+
id: 'cloudflare-alerts',
|
|
113
|
+
kind: 'infra/alerts',
|
|
114
|
+
priority: 10,
|
|
115
|
+
implementation: impl
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function createObservabilityImpl(input) {
|
|
119
|
+
const descriptor = CloudflareObservabilityDescriptorSchema.parse(input);
|
|
120
|
+
const impl = createCloudflareObservabilityImplementation(descriptor);
|
|
121
|
+
return createRuntimeImplementation({
|
|
122
|
+
id: 'cloudflare-workers-observability',
|
|
123
|
+
kind: 'infra/observability',
|
|
124
|
+
priority: 10,
|
|
125
|
+
implementation: impl
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function createRumImpl(input) {
|
|
129
|
+
const descriptor = CloudflareRumDescriptorSchema.parse(input);
|
|
130
|
+
const impl = createCloudflareRumImplementation(descriptor);
|
|
131
|
+
return createRuntimeImplementation({
|
|
132
|
+
id: 'cloudflare-web-analytics',
|
|
133
|
+
kind: 'infra/rum',
|
|
134
|
+
priority: 10,
|
|
135
|
+
implementation: impl
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export { createWorkerImpl, createQueueImpl, createR2Impl, createKVImpl, createPagesImpl, createWebAppImpl, createLogsImpl, createAlertsImpl, createObservabilityImpl, createRumImpl };
|
|
139
|
+
export default createRuntimePlugin({
|
|
140
|
+
id: 'infra-cloudflare',
|
|
141
|
+
name: 'Cloudflare Infrastructure',
|
|
142
|
+
description: 'Cloudflare provider implementations for infra kinds (Workers, Queues, R2, KV, Pages)',
|
|
143
|
+
dependencies: ['infra'],
|
|
144
|
+
// Surface the secrets/store descriptors at the asset level so the secrets
|
|
145
|
+
// CLI (`vibes secrets push/pull/list`) can enumerate available remotes
|
|
146
|
+
// alongside the loaders below. Loader-only registration leaves the
|
|
147
|
+
// descriptors invisible to `runtime.assets('secrets/store').descriptors()`.
|
|
148
|
+
descriptors: [
|
|
149
|
+
cloudflareApiDescriptor,
|
|
150
|
+
cloudflareSecretsStoreDescriptor,
|
|
151
|
+
cloudflareAlertsDescriptor,
|
|
152
|
+
cloudflareLogsDescriptor,
|
|
153
|
+
cloudflareObservabilityDescriptor,
|
|
154
|
+
cloudflareRumDescriptor
|
|
155
|
+
],
|
|
156
|
+
onActivate: async (runtime) => {
|
|
157
|
+
runtime.registerLoader('infra/worker', 'cloudflare-workers', async () => {
|
|
158
|
+
return createWorkerImpl({
|
|
159
|
+
kind: 'infra/worker',
|
|
160
|
+
id: 'cloudflare-workers',
|
|
161
|
+
name: 'Cloudflare Workers',
|
|
162
|
+
adapter: 'cloudflare-workers',
|
|
163
|
+
workerName: 'default-worker',
|
|
164
|
+
main: 'src/worker.ts'
|
|
165
|
+
});
|
|
166
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
167
|
+
runtime.registerLoader('infra/queue', 'cloudflare-queues', async () => {
|
|
168
|
+
return createQueueImpl({
|
|
169
|
+
kind: 'infra/queue',
|
|
170
|
+
id: 'cloudflare-queues',
|
|
171
|
+
name: 'Cloudflare Queues',
|
|
172
|
+
engine: 'cloudflare-queues',
|
|
173
|
+
queueName: 'default',
|
|
174
|
+
binding: 'DEFAULT_QUEUE'
|
|
175
|
+
});
|
|
176
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
177
|
+
runtime.registerLoader('infra/object-storage', 'cloudflare-r2', async () => {
|
|
178
|
+
return createR2Impl({
|
|
179
|
+
kind: 'infra/object-storage',
|
|
180
|
+
id: 'cloudflare-r2',
|
|
181
|
+
name: 'Cloudflare R2',
|
|
182
|
+
adapter: 'cloudflare-r2',
|
|
183
|
+
binding: 'STORAGE',
|
|
184
|
+
bucketName: 'default'
|
|
185
|
+
});
|
|
186
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
187
|
+
runtime.registerLoader('infra/cache', 'cloudflare-kv', async () => {
|
|
188
|
+
return createKVImpl({
|
|
189
|
+
kind: 'infra/cache',
|
|
190
|
+
id: 'cloudflare-kv',
|
|
191
|
+
name: 'Cloudflare KV',
|
|
192
|
+
engine: 'cloudflare-kv',
|
|
193
|
+
binding: 'CACHE',
|
|
194
|
+
namespaceId: 'default'
|
|
195
|
+
});
|
|
196
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
197
|
+
runtime.registerLoader('infra/alerts', 'cloudflare-alerts', async () => {
|
|
198
|
+
return createAlertsImpl({
|
|
199
|
+
kind: 'infra/alerts',
|
|
200
|
+
id: 'cloudflare-alerts',
|
|
201
|
+
name: 'Cloudflare Alerts',
|
|
202
|
+
adapter: 'cloudflare-alerts',
|
|
203
|
+
policies: []
|
|
204
|
+
});
|
|
205
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
206
|
+
runtime.registerLoader('infra/observability', 'cloudflare-workers-observability', async () => {
|
|
207
|
+
return createObservabilityImpl({
|
|
208
|
+
kind: 'infra/observability',
|
|
209
|
+
id: 'cloudflare-workers-observability',
|
|
210
|
+
name: 'Cloudflare Workers Observability',
|
|
211
|
+
adapter: 'cloudflare-workers-observability'
|
|
212
|
+
});
|
|
213
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
214
|
+
runtime.registerLoader('infra/rum', 'cloudflare-web-analytics', async () => {
|
|
215
|
+
return createRumImpl({
|
|
216
|
+
kind: 'infra/rum',
|
|
217
|
+
id: 'cloudflare-web-analytics',
|
|
218
|
+
name: 'Cloudflare Web Analytics',
|
|
219
|
+
adapter: 'cloudflare-web-analytics',
|
|
220
|
+
siteToken: '96bb815cb0bc4afc87a793e6f34652b2'
|
|
221
|
+
});
|
|
222
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
223
|
+
runtime.registerLoader('secrets/store', 'cloudflare-api', async () => {
|
|
224
|
+
const { createCloudflareApiStore } = await import('./secrets/cloudflare-api.impl');
|
|
225
|
+
// Pass a resolver that derives project names from runtime-resolved infra/web-app
|
|
226
|
+
// descriptors. CF-specific fields live under the kind's `adapterConfig` escape
|
|
227
|
+
// hatch (see infra-core/kinds/web-app.kind.ts). When `adapterConfig.cfProjectName`
|
|
228
|
+
// is set, it wins; otherwise the project name is derived from the descriptor id.
|
|
229
|
+
const resolver = () => {
|
|
230
|
+
if (runtime.hasKind('infra/web-app')) {
|
|
231
|
+
const apps = runtime.query('infra/web-app').descriptors();
|
|
232
|
+
return apps.map((a) => {
|
|
233
|
+
const explicit = a.config?.cfProjectName;
|
|
234
|
+
return explicit ?? `vibes-${a.id.replace(/-app$/, '')}`;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return [];
|
|
238
|
+
};
|
|
239
|
+
return createCloudflareApiStore(resolver);
|
|
240
|
+
}, { priority: 20, origin: 'infra-cloudflare' });
|
|
241
|
+
runtime.registerLoader('secrets/store', 'cloudflare-secrets-store', async () => {
|
|
242
|
+
const { createCloudflareSecretsStore } = await import('./secrets/cloudflare-secrets-store.impl');
|
|
243
|
+
return createCloudflareSecretsStore();
|
|
244
|
+
}, { priority: 30, origin: 'infra-cloudflare' });
|
|
245
|
+
runtime.registerLoader('infra/web-app', 'cloudflare-pages', async () => {
|
|
246
|
+
return createPagesImpl({
|
|
247
|
+
kind: 'infra/web-app',
|
|
248
|
+
id: 'cloudflare-pages',
|
|
249
|
+
name: 'Cloudflare Pages',
|
|
250
|
+
adapter: 'cloudflare-workers',
|
|
251
|
+
cfProjectName: 'default-project',
|
|
252
|
+
outputDir: '.svelte-kit/cloudflare',
|
|
253
|
+
compatibilityFlags: ['nodejs_compat'],
|
|
254
|
+
env: {}
|
|
255
|
+
});
|
|
256
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
257
|
+
runtime.registerLoader('infra/web-app', 'cloudflare-web-app', async () => {
|
|
258
|
+
return createWebAppImpl({
|
|
259
|
+
kind: 'infra/web-app',
|
|
260
|
+
id: 'cloudflare-web-app',
|
|
261
|
+
name: 'Cloudflare Workers + Static Assets',
|
|
262
|
+
adapter: 'cloudflare-workers',
|
|
263
|
+
cfWorkerName: 'default-worker',
|
|
264
|
+
outputDir: '.svelte-kit/cloudflare',
|
|
265
|
+
compatibilityFlags: ['nodejs_compat'],
|
|
266
|
+
env: {}
|
|
267
|
+
});
|
|
268
|
+
}, { priority: 20, origin: 'infra-cloudflare' });
|
|
269
|
+
// Framework-level Cloudflare Logs descriptor. The list of workers to
|
|
270
|
+
// observe is *not* hardcoded here — that's app inventory, owned by
|
|
271
|
+
// each consumer's `deployment.config.ts`. CLI surfaces (e.g.
|
|
272
|
+
// `vibes infra logs`) discover sources from those configs and pass
|
|
273
|
+
// the requested worker name into the connector at call time.
|
|
274
|
+
runtime.registerLoader('infra/logs', 'cloudflare-logs', async () => {
|
|
275
|
+
return createLogsImpl({
|
|
276
|
+
kind: 'infra/logs',
|
|
277
|
+
id: 'cloudflare-logs',
|
|
278
|
+
name: 'Cloudflare Logs',
|
|
279
|
+
adapter: 'cloudflare-logs',
|
|
280
|
+
adapterConfig: {
|
|
281
|
+
accountId: { source: 'secret', key: 'CLOUDFLARE_ACCOUNT_ID' },
|
|
282
|
+
apiToken: { source: 'secret', key: 'CLOUDFLARE_API_TOKEN' }
|
|
283
|
+
},
|
|
284
|
+
sources: [],
|
|
285
|
+
retention: {
|
|
286
|
+
hotDays: 7,
|
|
287
|
+
coldDays: 30
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}, { priority: 10, origin: 'infra-cloudflare' });
|
|
291
|
+
// infra/artifact: Cloudflare Worker wrangler.jsonc generator
|
|
292
|
+
runtime.registerDescriptor('infra/artifact', {
|
|
293
|
+
id: 'wrangler-jsonc',
|
|
294
|
+
kind: 'infra/artifact',
|
|
295
|
+
description: 'Generates wrangler.jsonc configuration from infra/worker descriptors'
|
|
296
|
+
});
|
|
297
|
+
runtime.registerLoader('infra/artifact', 'wrangler-jsonc', async () => {
|
|
298
|
+
return createRuntimeImplementation({
|
|
299
|
+
id: 'wrangler-toml',
|
|
300
|
+
kind: 'infra/artifact',
|
|
301
|
+
priority: 10,
|
|
302
|
+
implementation: {
|
|
303
|
+
async generate(context) {
|
|
304
|
+
const resources = context?.resources || [];
|
|
305
|
+
const outputDir = context?.outputDir || './infra/generated';
|
|
306
|
+
const workerDescriptors = resources.filter((r) => r.kind === 'infra/worker');
|
|
307
|
+
if (workerDescriptors.length === 0) {
|
|
308
|
+
return {
|
|
309
|
+
content: '# No infra/worker descriptors found\n',
|
|
310
|
+
filename: 'wrangler.toml',
|
|
311
|
+
path: `${outputDir}/cloudflare/wrangler.toml`,
|
|
312
|
+
metadata: { sourceKind: 'infra/worker', format: 'toml', generator: 'wrangler-toml' }
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const configs = [];
|
|
316
|
+
for (const descriptor of workerDescriptors) {
|
|
317
|
+
const parsed = CloudflareWorkerDescriptorSchema.parse(descriptor);
|
|
318
|
+
const config = generateCloudflareWorkerConfig(parsed);
|
|
319
|
+
const jsonContent = JSON.stringify(config, null, 2);
|
|
320
|
+
configs.push(`// Worker: ${descriptor.id}\n${jsonContent}`);
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
content: configs.join('\n\n'),
|
|
324
|
+
filename: 'wrangler.jsonc',
|
|
325
|
+
path: `${outputDir}/cloudflare/wrangler.jsonc`,
|
|
326
|
+
metadata: { sourceKind: 'infra/worker', format: 'jsonc', generator: 'wrangler-jsonc' }
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
//# sourceMappingURL=cloudflare.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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CAAC;4BAC5E,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;4BACpD,OAAO,CAAC,IAAI,CAAC,cAAc,UAAU,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC,CAAC;wBAC7D,CAAC;wBAED,OAAO;4BACN,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;4BAC7B,QAAQ,EAAE,gBAAgB;4BAC1B,IAAI,EAAE,GAAG,SAAS,4BAA4B;4BAC9C,QAAQ,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE;yBACtF,CAAC;oBACH,CAAC;iBACD;aACD,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Cloudflare Alerts descriptor — registered at plugin load
|
|
3
|
+
* time so `runtime.assets('infra/alerts').descriptors()` returns at
|
|
4
|
+
* least one entry the moment the infra-cloudflare plugin is loaded.
|
|
5
|
+
*
|
|
6
|
+
* The descriptor only carries adapter identity + credential pointers;
|
|
7
|
+
* actual policy bodies live either on the provider (created via the
|
|
8
|
+
* CLI / dashboard) or in a sibling `account.config.ts` declarative file.
|
|
9
|
+
*/
|
|
10
|
+
import type { InfraAlertsDescriptor } from '@vibesdotdev/infra-core/kinds';
|
|
11
|
+
declare const descriptor: InfraAlertsDescriptor;
|
|
12
|
+
export default descriptor;
|
|
13
|
+
//# sourceMappingURL=alerts.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.descriptor.d.ts","sourceRoot":"","sources":["../../src/implementations/alerts.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E,QAAA,MAAM,UAAU,EAAE,qBAkBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Cloudflare Alerts descriptor — registered at plugin load
|
|
3
|
+
* time so `runtime.assets('infra/alerts').descriptors()` returns at
|
|
4
|
+
* least one entry the moment the infra-cloudflare plugin is loaded.
|
|
5
|
+
*
|
|
6
|
+
* The descriptor only carries adapter identity + credential pointers;
|
|
7
|
+
* actual policy bodies live either on the provider (created via the
|
|
8
|
+
* CLI / dashboard) or in a sibling `account.config.ts` declarative file.
|
|
9
|
+
*/
|
|
10
|
+
const descriptor = {
|
|
11
|
+
kind: 'infra/alerts',
|
|
12
|
+
id: 'cloudflare-alerts',
|
|
13
|
+
name: 'Cloudflare Alerts',
|
|
14
|
+
description: 'Cloudflare Notifications policies (billing, usage, error-rate)',
|
|
15
|
+
adapter: 'cloudflare-alerts',
|
|
16
|
+
adapterConfig: {
|
|
17
|
+
apiTokenEnvVar: 'CLOUDFLARE_NOTIFICATIONS_API_TOKEN',
|
|
18
|
+
apiTokenFallbackEnvVar: 'CLOUDFLARE_API_TOKEN',
|
|
19
|
+
accountIdEnvVar: 'CLOUDFLARE_ACCOUNT_ID'
|
|
20
|
+
},
|
|
21
|
+
// CLI ops resolve credentials from the LOCAL secrets vault by
|
|
22
|
+
// default. Production Workers that consume this adapter set the
|
|
23
|
+
// values via Cloudflare Secrets Store bindings — they never go
|
|
24
|
+
// through vibes secrets at runtime. CLI commands can pass
|
|
25
|
+
// `--environment` to read from a different vault.
|
|
26
|
+
environment: 'local',
|
|
27
|
+
policies: []
|
|
28
|
+
};
|
|
29
|
+
export default descriptor;
|
|
30
|
+
//# sourceMappingURL=alerts.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.descriptor.js","sourceRoot":"","sources":["../../src/implementations/alerts.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,UAAU,GAA0B;IACzC,IAAI,EAAE,cAAc;IACpB,EAAE,EAAE,mBAAmB;IACvB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,gEAAgE;IAC7E,OAAO,EAAE,mBAAmB;IAC5B,aAAa,EAAE;QACd,cAAc,EAAE,oCAAoC;QACpD,sBAAsB,EAAE,sBAAsB;QAC9C,eAAe,EAAE,uBAAuB;KACxC;IACD,8DAA8D;IAC9D,gEAAgE;IAChE,+DAA+D;IAC/D,0DAA0D;IAC1D,kDAAkD;IAClD,WAAW,EAAE,OAAO;IACpB,QAAQ,EAAE,EAAE;CACZ,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Alerts Implementation
|
|
3
|
+
*
|
|
4
|
+
* Maps the provider-agnostic `infra/alerts` kind onto Cloudflare's
|
|
5
|
+
* Notifications API (`/accounts/:account/alerting/v3/policies`).
|
|
6
|
+
*
|
|
7
|
+
* Native type translation:
|
|
8
|
+
* budget → billing_budget_alert
|
|
9
|
+
* usage → billing_usage_alert
|
|
10
|
+
* error-rate → workers_alert (filter: outcome=exception)
|
|
11
|
+
* latency → (not supported by CF — adapter throws on create)
|
|
12
|
+
* custom → adapter passes through the `native_alert_type` filter
|
|
13
|
+
*
|
|
14
|
+
* Credentials: prefers a scoped CLOUDFLARE_NOTIFICATIONS_API_TOKEN (with
|
|
15
|
+
* notifications:edit), falls back to CLOUDFLARE_API_TOKEN for read-only
|
|
16
|
+
* operations. Account id from CLOUDFLARE_ACCOUNT_ID. Both resolve via
|
|
17
|
+
* the standard runtime secrets chain (encrypted-local + env file +
|
|
18
|
+
* CF Secrets Store).
|
|
19
|
+
*/
|
|
20
|
+
import * as z from 'zod/v4';
|
|
21
|
+
import type { AlertsImplementation } from '@vibesdotdev/infra-core/kinds';
|
|
22
|
+
export declare const CloudflareAlertsDescriptorSchema: z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"infra/alerts">;
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
description: z.ZodOptional<z.ZodString>;
|
|
27
|
+
adapter: z.ZodLiteral<"cloudflare-alerts">;
|
|
28
|
+
adapterConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
+
environment: z.ZodDefault<z.ZodString>;
|
|
30
|
+
policies: z.ZodDefault<z.ZodArray<z.ZodUnknown>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type CloudflareAlertsDescriptorInput = z.input<typeof CloudflareAlertsDescriptorSchema>;
|
|
33
|
+
export type CloudflareAlertsDescriptor = z.infer<typeof CloudflareAlertsDescriptorSchema>;
|
|
34
|
+
export declare function createCloudflareAlertsImplementation(input: CloudflareAlertsDescriptorInput): AlertsImplementation;
|
|
35
|
+
//# sourceMappingURL=alerts.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.impl.d.ts","sourceRoot":"","sources":["../../src/implementations/alerts.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGvF,eAAO,MAAM,gCAAgC;;;;;;;;;iBAa3C,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;AA+R1F,wBAAgB,oCAAoC,CACnD,KAAK,EAAE,+BAA+B,GACpC,oBAAoB,CAEtB"}
|