wrangler 4.98.0 → 4.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cf-wrangler.js +115 -0
- package/package.json +30 -18
- package/templates/startDevWorker/InspectorProxyWorker.ts +19 -5
- package/wrangler-dist/InspectorProxyWorker.js +10 -4
- package/wrangler-dist/cli.d.ts +417 -261
- package/wrangler-dist/cli.js +220518 -210250
- package/wrangler-dist/experimental-config.d.mts +1516 -0
- package/wrangler-dist/experimental-config.d.mts.map +1 -0
- package/wrangler-dist/experimental-config.mjs +208 -0
- package/wrangler-dist/experimental-config.mjs.map +1 -0
- package/wrangler-dist/metafile-cjs.json +1 -1
|
@@ -0,0 +1,1516 @@
|
|
|
1
|
+
import { Pipeline, PipelineRecord } from "cloudflare:pipelines";
|
|
2
|
+
|
|
3
|
+
//#region ../config/dist/public-Bjl70U0p.d.mts
|
|
4
|
+
|
|
5
|
+
//#region src/utils.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Represents any valid JSON value.
|
|
8
|
+
*/
|
|
9
|
+
type Json = string | number | boolean | null | Json[] | {
|
|
10
|
+
[key: string]: Json;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/bindings.d.ts
|
|
14
|
+
interface AgentMemoryBindingOptions {
|
|
15
|
+
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
16
|
+
namespace: string;
|
|
17
|
+
/** Whether the Agent Memory binding should be remote in local development. */
|
|
18
|
+
remote?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
22
|
+
* allows agents to persist and recall memory.
|
|
23
|
+
*/
|
|
24
|
+
interface AgentMemoryBinding extends AgentMemoryBindingOptions {
|
|
25
|
+
type: "agent-memory";
|
|
26
|
+
}
|
|
27
|
+
interface AiBindingOptions {
|
|
28
|
+
/** Whether the AI binding should be remote or not in local development. */
|
|
29
|
+
remote?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Binding to the Workers AI project.
|
|
33
|
+
*
|
|
34
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
35
|
+
*/
|
|
36
|
+
interface AiBinding extends AiBindingOptions {
|
|
37
|
+
type: "ai";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Binding to the Workers AI project.
|
|
41
|
+
*
|
|
42
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
43
|
+
*/
|
|
44
|
+
interface TypedAiBinding<TAiModelList extends AiModelListType = AiModels> extends AiBinding {
|
|
45
|
+
/** @internal Carries type parameters for inference */
|
|
46
|
+
__typeParams: [TAiModelList];
|
|
47
|
+
}
|
|
48
|
+
interface AiSearchBindingOptions {
|
|
49
|
+
/** The user-chosen instance name. Must exist in Cloudflare at deploy time. */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Whether the AI Search instance binding should be remote in local development. */
|
|
52
|
+
remote?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* AI Search instance binding. Each binding is bound directly to a single
|
|
56
|
+
* pre-existing instance within the "default" namespace.
|
|
57
|
+
*/
|
|
58
|
+
interface AiSearchBinding extends AiSearchBindingOptions {
|
|
59
|
+
type: "ai-search";
|
|
60
|
+
}
|
|
61
|
+
interface AiSearchNamespaceBindingOptions {
|
|
62
|
+
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
63
|
+
namespace: string;
|
|
64
|
+
/** Whether the AI Search namespace binding should be remote in local development. */
|
|
65
|
+
remote?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
69
|
+
* allows dynamic instance CRUD within it.
|
|
70
|
+
*/
|
|
71
|
+
interface AiSearchNamespaceBinding extends AiSearchNamespaceBindingOptions {
|
|
72
|
+
type: "ai-search-namespace";
|
|
73
|
+
}
|
|
74
|
+
interface AnalyticsEngineDatasetBindingOptions {
|
|
75
|
+
/** The name of this dataset to write to. */
|
|
76
|
+
name?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Binding to an Analytics Engine dataset.
|
|
80
|
+
*
|
|
81
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
82
|
+
*/
|
|
83
|
+
interface AnalyticsEngineDatasetBinding extends AnalyticsEngineDatasetBindingOptions {
|
|
84
|
+
type: "analytics-engine-dataset";
|
|
85
|
+
}
|
|
86
|
+
interface ArtifactsBindingOptions {
|
|
87
|
+
/** The namespace to use. */
|
|
88
|
+
namespace: string;
|
|
89
|
+
/** Whether to use the remote Artifacts service in local dev. */
|
|
90
|
+
remote?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
94
|
+
* storage on Cloudflare Workers.
|
|
95
|
+
*/
|
|
96
|
+
interface ArtifactsBinding extends ArtifactsBindingOptions {
|
|
97
|
+
type: "artifacts";
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Binding to the Worker's static assets.
|
|
101
|
+
*
|
|
102
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
103
|
+
*/
|
|
104
|
+
interface AssetsBinding {
|
|
105
|
+
type: "assets";
|
|
106
|
+
}
|
|
107
|
+
interface BrowserBindingOptions {
|
|
108
|
+
/** Whether the Browser binding should be remote or not in local development. */
|
|
109
|
+
remote?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Binding to a headless browser usable from the Worker.
|
|
113
|
+
*
|
|
114
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
115
|
+
*/
|
|
116
|
+
interface BrowserBinding extends BrowserBindingOptions {
|
|
117
|
+
type: "browser";
|
|
118
|
+
}
|
|
119
|
+
interface D1BindingOptions {
|
|
120
|
+
/** The UUID of this D1 database (not required). */
|
|
121
|
+
id?: string;
|
|
122
|
+
/** The name of this D1 database. */
|
|
123
|
+
name?: string;
|
|
124
|
+
/** Whether the D1 database should be remote or not in local development. */
|
|
125
|
+
remote?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Binding to a D1 database.
|
|
129
|
+
*
|
|
130
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
131
|
+
*/
|
|
132
|
+
interface D1Binding extends D1BindingOptions {
|
|
133
|
+
type: "d1";
|
|
134
|
+
}
|
|
135
|
+
interface DispatchNamespaceBindingOptions {
|
|
136
|
+
/** The namespace to bind to. */
|
|
137
|
+
namespace: string;
|
|
138
|
+
/** Details about the outbound Worker which will handle outbound requests from your namespace. */
|
|
139
|
+
outbound?: {
|
|
140
|
+
/** Name of the Worker handling the outbound requests. */
|
|
141
|
+
workerName: string;
|
|
142
|
+
/** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler. */
|
|
143
|
+
parameters?: string[];
|
|
144
|
+
};
|
|
145
|
+
/** Whether the Dispatch Namespace should be remote or not in local development. */
|
|
146
|
+
remote?: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Binding to a Workers for Platforms dispatch namespace.
|
|
150
|
+
*
|
|
151
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
152
|
+
*/
|
|
153
|
+
interface DispatchNamespaceBinding extends DispatchNamespaceBindingOptions {
|
|
154
|
+
type: "dispatch-namespace";
|
|
155
|
+
}
|
|
156
|
+
interface DurableObjectBindingOptions {
|
|
157
|
+
/** The name of the Worker that defines the Durable Object class. */
|
|
158
|
+
workerName: string;
|
|
159
|
+
/** The exported class name of the Durable Object. */
|
|
160
|
+
exportName: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Binding to a Durable Object class. `workerName` is the name of the Worker
|
|
164
|
+
* that defines the class; `exportName` is the exported class name.
|
|
165
|
+
*
|
|
166
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
167
|
+
*/
|
|
168
|
+
interface DurableObjectBinding extends DurableObjectBindingOptions {
|
|
169
|
+
type: "durable-object";
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Binding to a Durable Object class. `workerName` is the name of the Worker
|
|
173
|
+
* that defines the class; `exportName` is the exported class name.
|
|
174
|
+
*
|
|
175
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
176
|
+
*/
|
|
177
|
+
interface TypedDurableObjectBinding<TConfig$1, TExportName$1 extends string> extends DurableObjectBinding {
|
|
178
|
+
workerName: string;
|
|
179
|
+
exportName: TExportName$1;
|
|
180
|
+
/** @internal Carries the config type for inference */
|
|
181
|
+
__config: TConfig$1;
|
|
182
|
+
}
|
|
183
|
+
interface FlagshipBindingOptions {
|
|
184
|
+
/** The Flagship app ID to bind to. */
|
|
185
|
+
id: string;
|
|
186
|
+
/** Set to `true` to suppress the remote binding warning in local dev. Flagship bindings are always remote. */
|
|
187
|
+
remote?: boolean;
|
|
188
|
+
}
|
|
189
|
+
/** Binding to a Flagship feature-flag service. */
|
|
190
|
+
interface FlagshipBinding extends FlagshipBindingOptions {
|
|
191
|
+
type: "flagship";
|
|
192
|
+
}
|
|
193
|
+
interface HyperdriveBindingOptions {
|
|
194
|
+
/** The ID of the Hyperdrive configuration. */
|
|
195
|
+
id: string;
|
|
196
|
+
/** The local database connection string used during local development. */
|
|
197
|
+
localConnectionString?: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Binding to a Hyperdrive configuration.
|
|
201
|
+
*
|
|
202
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
203
|
+
*/
|
|
204
|
+
interface HyperdriveBinding extends HyperdriveBindingOptions {
|
|
205
|
+
type: "hyperdrive";
|
|
206
|
+
}
|
|
207
|
+
interface ImagesBindingOptions {
|
|
208
|
+
/** Whether the Images binding should be remote or not in local development. */
|
|
209
|
+
remote?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Binding to Cloudflare Images.
|
|
213
|
+
*
|
|
214
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
215
|
+
*/
|
|
216
|
+
interface ImagesBinding$1 extends ImagesBindingOptions {
|
|
217
|
+
type: "images";
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Inline JSON value made available to the Worker on `env` under the
|
|
221
|
+
* binding name.
|
|
222
|
+
*/
|
|
223
|
+
interface JsonBinding<T$1 extends Json = Json> {
|
|
224
|
+
type: "json";
|
|
225
|
+
/** The JSON value made available to the Worker. */
|
|
226
|
+
value: T$1;
|
|
227
|
+
}
|
|
228
|
+
interface KvBindingOptions {
|
|
229
|
+
/** The ID of the KV namespace. */
|
|
230
|
+
id?: string;
|
|
231
|
+
/** Whether the KV namespace should be remote or not in local development. */
|
|
232
|
+
remote?: boolean;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Binding to a Workers KV namespace.
|
|
236
|
+
*
|
|
237
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
238
|
+
*/
|
|
239
|
+
interface KvBinding extends KvBindingOptions {
|
|
240
|
+
type: "kv";
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Binding to a Workers KV namespace.
|
|
244
|
+
*
|
|
245
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
246
|
+
*/
|
|
247
|
+
interface TypedKvBinding<TKey extends string = string> extends KvBinding {
|
|
248
|
+
/** @internal Carries type parameters for inference */
|
|
249
|
+
__typeParams: [TKey];
|
|
250
|
+
}
|
|
251
|
+
interface LogfwdrBindingOptions {
|
|
252
|
+
/** The destination for this logged message. */
|
|
253
|
+
destination: string;
|
|
254
|
+
}
|
|
255
|
+
/** Binding for forwarding logs to logfwdr. */
|
|
256
|
+
interface LogfwdrBinding extends LogfwdrBindingOptions {
|
|
257
|
+
type: "logfwdr";
|
|
258
|
+
}
|
|
259
|
+
interface MediaBindingOptions {
|
|
260
|
+
/** Whether the Media binding should be remote or not. */
|
|
261
|
+
remote?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/** Binding to Cloudflare Media Transformations. */
|
|
264
|
+
interface MediaBinding$1 extends MediaBindingOptions {
|
|
265
|
+
type: "media";
|
|
266
|
+
}
|
|
267
|
+
interface MtlsCertificateBindingOptions {
|
|
268
|
+
/** The UUID of the uploaded mTLS certificate. */
|
|
269
|
+
id: string;
|
|
270
|
+
/** Whether the mTLS fetcher should be remote or not in local development. */
|
|
271
|
+
remote?: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Binding to an uploaded mTLS certificate.
|
|
275
|
+
*
|
|
276
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
277
|
+
*/
|
|
278
|
+
interface MtlsCertificateBinding extends MtlsCertificateBindingOptions {
|
|
279
|
+
type: "mtls-certificate";
|
|
280
|
+
}
|
|
281
|
+
interface PipelineBindingOptions {
|
|
282
|
+
/** Name of the Pipeline to bind. */
|
|
283
|
+
name: string;
|
|
284
|
+
/** Whether the pipeline should be remote or not in local development. */
|
|
285
|
+
remote?: boolean;
|
|
286
|
+
}
|
|
287
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
288
|
+
interface PipelineBinding extends PipelineBindingOptions {
|
|
289
|
+
type: "pipeline";
|
|
290
|
+
}
|
|
291
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
292
|
+
interface TypedPipelineBinding<TRecord extends PipelineRecord = PipelineRecord> extends PipelineBinding {
|
|
293
|
+
/** @internal Carries type parameters for inference */
|
|
294
|
+
__typeParams: [TRecord];
|
|
295
|
+
}
|
|
296
|
+
interface QueueBindingOptions {
|
|
297
|
+
/** The name of this Queue. */
|
|
298
|
+
name: string;
|
|
299
|
+
/** The number of seconds to wait before delivering a message. */
|
|
300
|
+
deliveryDelay?: number;
|
|
301
|
+
/** Whether the Queue producer should be remote or not in local development. */
|
|
302
|
+
remote?: boolean;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Producer binding to a Cloudflare Queue.
|
|
306
|
+
*
|
|
307
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
308
|
+
*/
|
|
309
|
+
interface QueueBinding extends QueueBindingOptions {
|
|
310
|
+
type: "queue";
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Producer binding to a Cloudflare Queue.
|
|
314
|
+
*
|
|
315
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
316
|
+
*/
|
|
317
|
+
interface TypedQueueBinding<TBody = unknown> extends QueueBinding {
|
|
318
|
+
/** @internal Carries type parameters for inference */
|
|
319
|
+
__typeParams: [TBody];
|
|
320
|
+
}
|
|
321
|
+
interface R2BindingOptions {
|
|
322
|
+
/** The name of this R2 bucket at the edge. */
|
|
323
|
+
name?: string;
|
|
324
|
+
/** The jurisdiction that the bucket exists in. Default if not present. */
|
|
325
|
+
jurisdiction?: string;
|
|
326
|
+
/** Whether the R2 bucket should be remote or not in local development. */
|
|
327
|
+
remote?: boolean;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Binding to an R2 bucket.
|
|
331
|
+
*
|
|
332
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
333
|
+
*/
|
|
334
|
+
interface R2Binding extends R2BindingOptions {
|
|
335
|
+
type: "r2";
|
|
336
|
+
}
|
|
337
|
+
interface RateLimitBindingOptions {
|
|
338
|
+
/** The namespace ID for this rate limiter. */
|
|
339
|
+
namespace: string;
|
|
340
|
+
/** Simple rate limiting configuration. */
|
|
341
|
+
simple: {
|
|
342
|
+
/** The maximum number of requests allowed in the time period. */
|
|
343
|
+
limit: number;
|
|
344
|
+
/** The time period in seconds (10 for ten seconds, 60 for one minute). */
|
|
345
|
+
period: 10 | 60;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/** Binding to a rate limiter. */
|
|
349
|
+
interface RateLimitBinding extends RateLimitBindingOptions {
|
|
350
|
+
type: "rate-limit";
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Declares a secret that is required by your Worker, exposed on `env` under
|
|
354
|
+
* the binding name.
|
|
355
|
+
*
|
|
356
|
+
* When defined, this binding:
|
|
357
|
+
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
358
|
+
* - Enables local dev validation with warnings for missing secrets
|
|
359
|
+
*
|
|
360
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
|
|
361
|
+
*/
|
|
362
|
+
interface SecretBinding {
|
|
363
|
+
type: "secret";
|
|
364
|
+
}
|
|
365
|
+
interface SecretsStoreSecretBindingOptions {
|
|
366
|
+
/** ID of the secret store. */
|
|
367
|
+
storeId: string;
|
|
368
|
+
/** Name of the secret. */
|
|
369
|
+
secretName: string;
|
|
370
|
+
}
|
|
371
|
+
/** Binding to a Secrets Store secret. */
|
|
372
|
+
interface SecretsStoreSecretBinding extends SecretsStoreSecretBindingOptions {
|
|
373
|
+
type: "secrets-store-secret";
|
|
374
|
+
}
|
|
375
|
+
interface SendEmailBindingOptions {
|
|
376
|
+
/** If this binding should be restricted to a specific verified address. */
|
|
377
|
+
destinationAddress?: string;
|
|
378
|
+
/** If this binding should be restricted to a set of verified addresses. */
|
|
379
|
+
allowedDestinationAddresses?: string[];
|
|
380
|
+
/** If this binding should be restricted to a set of sender addresses. */
|
|
381
|
+
allowedSenderAddresses?: string[];
|
|
382
|
+
/** Whether the binding should be remote or not in local development. */
|
|
383
|
+
remote?: boolean;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Binding for sending email from inside the Worker.
|
|
387
|
+
*
|
|
388
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
|
|
389
|
+
*/
|
|
390
|
+
interface SendEmailBinding extends SendEmailBindingOptions {
|
|
391
|
+
type: "send-email";
|
|
392
|
+
}
|
|
393
|
+
interface StreamBindingOptions {
|
|
394
|
+
/** Whether the Stream binding should be remote or not in local development. */
|
|
395
|
+
remote?: boolean;
|
|
396
|
+
}
|
|
397
|
+
/** Binding to Cloudflare Stream. */
|
|
398
|
+
interface StreamBinding$1 extends StreamBindingOptions {
|
|
399
|
+
type: "stream";
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Inline string value made available to the Worker on `env` under the
|
|
403
|
+
* binding name.
|
|
404
|
+
*
|
|
405
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
406
|
+
*/
|
|
407
|
+
interface TextBinding<T$1 extends string = string> {
|
|
408
|
+
type: "text";
|
|
409
|
+
/** The string value made available to the Worker. */
|
|
410
|
+
value: T$1;
|
|
411
|
+
}
|
|
412
|
+
interface UnsafeBindingOptions {
|
|
413
|
+
/** Local-dev plugin configuration for this unsafe binding. */
|
|
414
|
+
dev?: {
|
|
415
|
+
/** The plugin package that provides the binding's local-dev implementation. */
|
|
416
|
+
plugin: {
|
|
417
|
+
package: string;
|
|
418
|
+
name: string;
|
|
419
|
+
};
|
|
420
|
+
/** Plugin-specific options. */
|
|
421
|
+
options?: Record<string, unknown>;
|
|
422
|
+
};
|
|
423
|
+
[key: string]: unknown;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Escape-hatch binding for runtime features that aren't directly supported
|
|
427
|
+
* by this configuration. Included in the Worker's upload metadata without
|
|
428
|
+
* changes.
|
|
429
|
+
*/
|
|
430
|
+
interface UnsafeBinding extends UnsafeBindingOptions {
|
|
431
|
+
type: `unsafe:${string}`;
|
|
432
|
+
}
|
|
433
|
+
interface VectorizeBindingOptions {
|
|
434
|
+
/** The name of the Vectorize index. */
|
|
435
|
+
name: string;
|
|
436
|
+
/** Whether the Vectorize index should be remote or not in local development. */
|
|
437
|
+
remote?: boolean;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Binding to a Vectorize index.
|
|
441
|
+
*
|
|
442
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
443
|
+
*/
|
|
444
|
+
interface VectorizeBinding extends VectorizeBindingOptions {
|
|
445
|
+
type: "vectorize";
|
|
446
|
+
}
|
|
447
|
+
/** Binding to the Worker version's metadata. */
|
|
448
|
+
interface VersionMetadataBinding {
|
|
449
|
+
type: "version-metadata";
|
|
450
|
+
}
|
|
451
|
+
type VpcNetworkBindingOptions = {
|
|
452
|
+
/** The tunnel ID of the Cloudflare Tunnel to route traffic through. Mutually exclusive with `networkId`. */
|
|
453
|
+
tunnelId: string;
|
|
454
|
+
/** Whether the VPC network is remote or not. */
|
|
455
|
+
remote?: boolean;
|
|
456
|
+
} | {
|
|
457
|
+
/** The network ID to route traffic through. Mutually exclusive with `tunnelId`. */
|
|
458
|
+
networkId: string;
|
|
459
|
+
/** Whether the VPC network is remote or not. */
|
|
460
|
+
remote?: boolean;
|
|
461
|
+
};
|
|
462
|
+
/** Binding to a VPC network. */
|
|
463
|
+
type VpcNetworkBinding = VpcNetworkBindingOptions & {
|
|
464
|
+
type: "vpc-network";
|
|
465
|
+
};
|
|
466
|
+
interface VpcServiceBindingOptions {
|
|
467
|
+
/** The service ID of the VPC connectivity service. */
|
|
468
|
+
id: string;
|
|
469
|
+
/** Whether the VPC service is remote or not. */
|
|
470
|
+
remote?: boolean;
|
|
471
|
+
}
|
|
472
|
+
/** Binding to a VPC service. */
|
|
473
|
+
interface VpcServiceBinding extends VpcServiceBindingOptions {
|
|
474
|
+
type: "vpc-service";
|
|
475
|
+
}
|
|
476
|
+
interface WebSearchBindingOptions {
|
|
477
|
+
/** Whether the Web Search binding should be remote or not in local development. */
|
|
478
|
+
remote?: boolean;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Cloudflare Web Search binding. There is exactly one shared web corpus, so
|
|
482
|
+
* the binding is zero-config — only the variable name is required.
|
|
483
|
+
*/
|
|
484
|
+
interface WebSearchBinding extends WebSearchBindingOptions {
|
|
485
|
+
type: "web-search";
|
|
486
|
+
}
|
|
487
|
+
interface WorkerBindingOptions {
|
|
488
|
+
/** The name of the bound Worker. */
|
|
489
|
+
workerName: string;
|
|
490
|
+
/** The named export to bind to (defaults to the default export). */
|
|
491
|
+
exportName?: string;
|
|
492
|
+
/** Optional properties that will be made available to the service via `ctx.props`. */
|
|
493
|
+
props?: Record<string, unknown>;
|
|
494
|
+
/** Whether the service binding should be remote or not in local development. */
|
|
495
|
+
remote?: boolean;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Service binding (Worker-to-Worker). `workerName` is the name of the bound
|
|
499
|
+
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
500
|
+
* the default export).
|
|
501
|
+
*
|
|
502
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
503
|
+
*/
|
|
504
|
+
interface WorkerBinding extends WorkerBindingOptions {
|
|
505
|
+
type: "worker";
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Service binding (Worker-to-Worker). `workerName` is the name of the bound
|
|
509
|
+
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
510
|
+
* the default export).
|
|
511
|
+
*
|
|
512
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
513
|
+
*/
|
|
514
|
+
interface TypedWorkerBinding<TConfig$1, TExportName$1 extends string> extends WorkerBinding {
|
|
515
|
+
workerName: string;
|
|
516
|
+
exportName: TExportName$1;
|
|
517
|
+
/** @internal Carries the config type for inference */
|
|
518
|
+
__config: TConfig$1;
|
|
519
|
+
}
|
|
520
|
+
/** Binding to a Worker Loader. */
|
|
521
|
+
interface WorkerLoaderBinding {
|
|
522
|
+
type: "worker-loader";
|
|
523
|
+
}
|
|
524
|
+
interface WorkflowBindingOptions {
|
|
525
|
+
/** The name of the Worker that defines the Workflow. */
|
|
526
|
+
workerName: string;
|
|
527
|
+
/** The exported class name of the Workflow. */
|
|
528
|
+
exportName: string;
|
|
529
|
+
/** Whether the Workflow binding should be remote or not in local development. */
|
|
530
|
+
remote?: boolean;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Binding to a Workflow. `workerName` is the name of the Worker that defines
|
|
534
|
+
* the Workflow; `exportName` is the exported `WorkflowEntrypoint` class name.
|
|
535
|
+
*/
|
|
536
|
+
interface WorkflowBinding extends WorkflowBindingOptions {
|
|
537
|
+
type: "workflow";
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Binding to a Workflow. `workerName` is the name of the Worker that defines
|
|
541
|
+
* the Workflow; `exportName` is the exported `WorkflowEntrypoint` class name.
|
|
542
|
+
*/
|
|
543
|
+
interface TypedWorkflowBinding<TConfig$1, TExportName$1 extends string> extends WorkflowBinding {
|
|
544
|
+
workerName: string;
|
|
545
|
+
exportName: TExportName$1;
|
|
546
|
+
/** @internal Carries the config type for inference */
|
|
547
|
+
__config: TConfig$1;
|
|
548
|
+
}
|
|
549
|
+
interface Bindings {
|
|
550
|
+
/**
|
|
551
|
+
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
552
|
+
* allows agents to persist and recall memory.
|
|
553
|
+
*/
|
|
554
|
+
agentMemory(options: AgentMemoryBindingOptions): AgentMemoryBinding;
|
|
555
|
+
/**
|
|
556
|
+
* Binding to the Workers AI project.
|
|
557
|
+
*
|
|
558
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
559
|
+
*/
|
|
560
|
+
ai<TAiModelList extends AiModelListType = AiModels>(options?: AiBindingOptions): TypedAiBinding<TAiModelList>;
|
|
561
|
+
/**
|
|
562
|
+
* AI Search instance binding. Each binding is bound directly to a single
|
|
563
|
+
* pre-existing instance within the "default" namespace.
|
|
564
|
+
*/
|
|
565
|
+
aiSearch(options: AiSearchBindingOptions): AiSearchBinding;
|
|
566
|
+
/**
|
|
567
|
+
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
568
|
+
* allows dynamic instance CRUD within it.
|
|
569
|
+
*/
|
|
570
|
+
aiSearchNamespace(options: AiSearchNamespaceBindingOptions): AiSearchNamespaceBinding;
|
|
571
|
+
/**
|
|
572
|
+
* Binding to an Analytics Engine dataset.
|
|
573
|
+
*
|
|
574
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
575
|
+
*/
|
|
576
|
+
analyticsEngineDataset(options?: AnalyticsEngineDatasetBindingOptions): AnalyticsEngineDatasetBinding;
|
|
577
|
+
/**
|
|
578
|
+
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
579
|
+
* storage on Cloudflare Workers.
|
|
580
|
+
*/
|
|
581
|
+
artifacts(options: ArtifactsBindingOptions): ArtifactsBinding;
|
|
582
|
+
/**
|
|
583
|
+
* Binding to the Worker's static assets.
|
|
584
|
+
*
|
|
585
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
586
|
+
*/
|
|
587
|
+
assets(): AssetsBinding;
|
|
588
|
+
/**
|
|
589
|
+
* Binding to a headless browser usable from the Worker.
|
|
590
|
+
*
|
|
591
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
592
|
+
*/
|
|
593
|
+
browser(options?: BrowserBindingOptions): BrowserBinding;
|
|
594
|
+
/**
|
|
595
|
+
* Binding to a D1 database.
|
|
596
|
+
*
|
|
597
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
598
|
+
*/
|
|
599
|
+
d1(options?: D1BindingOptions): D1Binding;
|
|
600
|
+
/**
|
|
601
|
+
* Binding to a Workers for Platforms dispatch namespace.
|
|
602
|
+
*
|
|
603
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
604
|
+
*/
|
|
605
|
+
dispatchNamespace(options: DispatchNamespaceBindingOptions): DispatchNamespaceBinding;
|
|
606
|
+
/**
|
|
607
|
+
* Binding to a Durable Object class. `workerName` is the name of the Worker
|
|
608
|
+
* that defines the class; `exportName` is the exported class name.
|
|
609
|
+
*
|
|
610
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
611
|
+
*/
|
|
612
|
+
durableObject(options: DurableObjectBindingOptions): DurableObjectBinding;
|
|
613
|
+
/** Binding to a Flagship feature-flag service. */
|
|
614
|
+
flagship(options: FlagshipBindingOptions): FlagshipBinding;
|
|
615
|
+
/**
|
|
616
|
+
* Binding to a Hyperdrive configuration.
|
|
617
|
+
*
|
|
618
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
619
|
+
*/
|
|
620
|
+
hyperdrive(options: HyperdriveBindingOptions): HyperdriveBinding;
|
|
621
|
+
/**
|
|
622
|
+
* Binding to Cloudflare Images.
|
|
623
|
+
*
|
|
624
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
625
|
+
*/
|
|
626
|
+
images(options?: ImagesBindingOptions): ImagesBinding$1;
|
|
627
|
+
/**
|
|
628
|
+
* Inline JSON value made available to the Worker on `env` under the
|
|
629
|
+
* binding name.
|
|
630
|
+
*/
|
|
631
|
+
json<T$1 extends Json>(value: T$1): JsonBinding<T$1>;
|
|
632
|
+
/**
|
|
633
|
+
* Binding to a Workers KV namespace.
|
|
634
|
+
*
|
|
635
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
636
|
+
*/
|
|
637
|
+
kv<TKey extends string = string>(options?: KvBindingOptions): TypedKvBinding<TKey>;
|
|
638
|
+
/** Binding for forwarding logs to logfwdr. */
|
|
639
|
+
logfwdr(options: LogfwdrBindingOptions): LogfwdrBinding;
|
|
640
|
+
/** Binding to Cloudflare Media Transformations. */
|
|
641
|
+
media(options?: MediaBindingOptions): MediaBinding$1;
|
|
642
|
+
/**
|
|
643
|
+
* Binding to an uploaded mTLS certificate.
|
|
644
|
+
*
|
|
645
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
646
|
+
*/
|
|
647
|
+
mtlsCertificate(options: MtlsCertificateBindingOptions): MtlsCertificateBinding;
|
|
648
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
649
|
+
pipeline<TRecord extends PipelineRecord = PipelineRecord>(options: PipelineBindingOptions): TypedPipelineBinding<TRecord>;
|
|
650
|
+
/**
|
|
651
|
+
* Producer binding to a Cloudflare Queue.
|
|
652
|
+
*
|
|
653
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
654
|
+
*/
|
|
655
|
+
queue<TBody = unknown>(options: QueueBindingOptions): TypedQueueBinding<TBody>;
|
|
656
|
+
/**
|
|
657
|
+
* Binding to an R2 bucket.
|
|
658
|
+
*
|
|
659
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
660
|
+
*/
|
|
661
|
+
r2(options?: R2BindingOptions): R2Binding;
|
|
662
|
+
/** Binding to a rate limiter. */
|
|
663
|
+
rateLimit(options: RateLimitBindingOptions): RateLimitBinding;
|
|
664
|
+
/**
|
|
665
|
+
* Declares a secret that is required by your Worker, exposed on `env` under
|
|
666
|
+
* the binding name.
|
|
667
|
+
*
|
|
668
|
+
* When defined, this binding:
|
|
669
|
+
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
670
|
+
* - Enables local dev validation with warnings for missing secrets
|
|
671
|
+
*
|
|
672
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
|
|
673
|
+
*/
|
|
674
|
+
secret(): SecretBinding;
|
|
675
|
+
/** Binding to a Secrets Store secret. */
|
|
676
|
+
secretsStoreSecret(options: SecretsStoreSecretBindingOptions): SecretsStoreSecretBinding;
|
|
677
|
+
/**
|
|
678
|
+
* Binding for sending email from inside the Worker.
|
|
679
|
+
*
|
|
680
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
|
|
681
|
+
*/
|
|
682
|
+
sendEmail(options?: SendEmailBindingOptions): SendEmailBinding;
|
|
683
|
+
/** Binding to Cloudflare Stream. */
|
|
684
|
+
stream(options?: StreamBindingOptions): StreamBinding$1;
|
|
685
|
+
/**
|
|
686
|
+
* Inline string value made available to the Worker on `env` under the
|
|
687
|
+
* binding name.
|
|
688
|
+
*
|
|
689
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
690
|
+
*/
|
|
691
|
+
text<T$1 extends string>(value: T$1): TextBinding<T$1>;
|
|
692
|
+
/**
|
|
693
|
+
* Binding to a Vectorize index.
|
|
694
|
+
*
|
|
695
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
696
|
+
*/
|
|
697
|
+
vectorize(options: VectorizeBindingOptions): VectorizeBinding;
|
|
698
|
+
/** Binding to the Worker version's metadata. */
|
|
699
|
+
versionMetadata(): VersionMetadataBinding;
|
|
700
|
+
/** Binding to a VPC network. */
|
|
701
|
+
vpcNetwork(options: VpcNetworkBindingOptions): VpcNetworkBinding;
|
|
702
|
+
/** Binding to a VPC service. */
|
|
703
|
+
vpcService(options: VpcServiceBindingOptions): VpcServiceBinding;
|
|
704
|
+
/**
|
|
705
|
+
* Cloudflare Web Search binding. There is exactly one shared web corpus, so
|
|
706
|
+
* the binding is zero-config — only the variable name is required.
|
|
707
|
+
*/
|
|
708
|
+
webSearch(options?: WebSearchBindingOptions): WebSearchBinding;
|
|
709
|
+
/**
|
|
710
|
+
* Service binding (Worker-to-Worker). `workerName` is the name of the bound
|
|
711
|
+
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
712
|
+
* the default export).
|
|
713
|
+
*
|
|
714
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
715
|
+
*/
|
|
716
|
+
worker(options: WorkerBindingOptions): WorkerBinding;
|
|
717
|
+
/** Binding to a Worker Loader. */
|
|
718
|
+
workerLoader(): WorkerLoaderBinding;
|
|
719
|
+
}
|
|
720
|
+
declare const bindings: Bindings;
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/triggers.d.ts
|
|
723
|
+
interface FetchTriggerOptions {
|
|
724
|
+
/**
|
|
725
|
+
* A route that your Worker should be published to.
|
|
726
|
+
*
|
|
727
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
728
|
+
*/
|
|
729
|
+
pattern: string;
|
|
730
|
+
/**
|
|
731
|
+
* The DNS zone the pattern is attached to. Required when the
|
|
732
|
+
* pattern is ambiguous.
|
|
733
|
+
*/
|
|
734
|
+
zone?: string;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Fetch trigger — a route that your Worker should be published to.
|
|
738
|
+
*
|
|
739
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
740
|
+
*/
|
|
741
|
+
interface FetchTrigger extends FetchTriggerOptions {
|
|
742
|
+
type: "fetch";
|
|
743
|
+
}
|
|
744
|
+
interface QueueConsumerTriggerOptions {
|
|
745
|
+
/** The name of the queue from which this consumer should consume. */
|
|
746
|
+
name: string;
|
|
747
|
+
/** The queue to send messages that failed to be consumed. */
|
|
748
|
+
deadLetterQueue?: string;
|
|
749
|
+
/** The maximum number of messages per batch. */
|
|
750
|
+
maxBatchSize?: number;
|
|
751
|
+
/** The maximum number of seconds to wait to fill a batch with messages. */
|
|
752
|
+
maxBatchTimeout?: number;
|
|
753
|
+
/**
|
|
754
|
+
* The maximum number of concurrent consumer Worker invocations.
|
|
755
|
+
* Leaving this unset will allow your consumer to scale to the
|
|
756
|
+
* maximum concurrency needed to keep up with the message backlog.
|
|
757
|
+
*/
|
|
758
|
+
maxConcurrency?: number | null;
|
|
759
|
+
/** The maximum number of retries for each message. */
|
|
760
|
+
maxRetries?: number;
|
|
761
|
+
/** The number of seconds to wait before retrying a message. */
|
|
762
|
+
retryDelay?: number;
|
|
763
|
+
/** The number of milliseconds to wait for pulled messages to become visible again. */
|
|
764
|
+
visibilityTimeoutMs?: number;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
768
|
+
* named queue.
|
|
769
|
+
*
|
|
770
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
771
|
+
*/
|
|
772
|
+
interface QueueConsumerTrigger extends QueueConsumerTriggerOptions {
|
|
773
|
+
type: "queue";
|
|
774
|
+
}
|
|
775
|
+
interface ScheduledTriggerOptions {
|
|
776
|
+
/**
|
|
777
|
+
* A "cron" definition to trigger a Worker's "scheduled" function.
|
|
778
|
+
*
|
|
779
|
+
* Lets you call Workers periodically, much like a cron job.
|
|
780
|
+
*
|
|
781
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
782
|
+
*/
|
|
783
|
+
schedule: string;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
787
|
+
*
|
|
788
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
789
|
+
*/
|
|
790
|
+
interface ScheduledTrigger extends ScheduledTriggerOptions {
|
|
791
|
+
type: "scheduled";
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Event triggers — fetch routes, queue consumers, and cron schedules
|
|
795
|
+
* — that invoke this Worker. Construct entries with `triggers.fetch(...)`,
|
|
796
|
+
* `triggers.queue(...)`, or `triggers.scheduled(...)`.
|
|
797
|
+
*
|
|
798
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
799
|
+
*/
|
|
800
|
+
interface Triggers {
|
|
801
|
+
/**
|
|
802
|
+
* Fetch trigger — a route that your Worker should be published to.
|
|
803
|
+
*
|
|
804
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
805
|
+
*/
|
|
806
|
+
fetch(options: FetchTriggerOptions): FetchTrigger;
|
|
807
|
+
/**
|
|
808
|
+
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
809
|
+
* named queue.
|
|
810
|
+
*
|
|
811
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
812
|
+
*/
|
|
813
|
+
queue(options: QueueConsumerTriggerOptions): QueueConsumerTrigger;
|
|
814
|
+
/**
|
|
815
|
+
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
816
|
+
*
|
|
817
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
818
|
+
*/
|
|
819
|
+
scheduled(options: ScheduledTriggerOptions): ScheduledTrigger;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Triggers builder for configuring event triggers.
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```typescript
|
|
826
|
+
* import { defineWorker, triggers } from "@cloudflare/config";
|
|
827
|
+
*
|
|
828
|
+
* export default defineWorker({
|
|
829
|
+
* triggers: [
|
|
830
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
831
|
+
* triggers.queue({ name: "my-queue" }),
|
|
832
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
833
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
834
|
+
* ],
|
|
835
|
+
* });
|
|
836
|
+
* ```
|
|
837
|
+
*/
|
|
838
|
+
declare const triggers: Triggers;
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region src/exports.d.ts
|
|
841
|
+
interface DurableObjectExportOptions {
|
|
842
|
+
/**
|
|
843
|
+
* Storage backend for the Durable Object.
|
|
844
|
+
*
|
|
845
|
+
* - `"sqlite"`: selects the SQLite-backed storage engine
|
|
846
|
+
* (recommended for new classes).
|
|
847
|
+
* - `"legacy-kv"`: selects the legacy key-value storage engine.
|
|
848
|
+
*/
|
|
849
|
+
storage: "sqlite" | "legacy-kv";
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Declares a Durable Object class defined by this Worker.
|
|
853
|
+
*
|
|
854
|
+
* For more information about Durable Objects, see the documentation at
|
|
855
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
856
|
+
*
|
|
857
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
858
|
+
*/
|
|
859
|
+
interface DurableObjectExport extends DurableObjectExportOptions {
|
|
860
|
+
type: "durable-object";
|
|
861
|
+
}
|
|
862
|
+
interface WorkflowExportOptions {
|
|
863
|
+
/** The name of the Workflow. */
|
|
864
|
+
name: string;
|
|
865
|
+
/** Optional limits for the Workflow. */
|
|
866
|
+
limits?: {
|
|
867
|
+
/** Maximum number of steps a Workflow instance can execute. */
|
|
868
|
+
steps?: number;
|
|
869
|
+
};
|
|
870
|
+
/** Optional cron schedules for automatically triggering workflow instances. */
|
|
871
|
+
schedules?: string[];
|
|
872
|
+
}
|
|
873
|
+
/** Declares a Workflow defined by this Worker. */
|
|
874
|
+
interface WorkflowExport extends WorkflowExportOptions {
|
|
875
|
+
type: "workflow";
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
879
|
+
* key is the exported class name; the value configures the export.
|
|
880
|
+
*/
|
|
881
|
+
interface Exports {
|
|
882
|
+
/**
|
|
883
|
+
* Declares a Durable Object class defined by this Worker.
|
|
884
|
+
*
|
|
885
|
+
* For more information about Durable Objects, see the documentation at
|
|
886
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
887
|
+
*
|
|
888
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
889
|
+
*/
|
|
890
|
+
durableObject(options: DurableObjectExportOptions): DurableObjectExport;
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Exports builder for configuring Worker exports.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```typescript
|
|
897
|
+
* import { defineWorker, exports } from "@cloudflare/config";
|
|
898
|
+
*
|
|
899
|
+
* export default defineWorker({
|
|
900
|
+
* exports: {
|
|
901
|
+
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
902
|
+
* },
|
|
903
|
+
* });
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
906
|
+
declare const exports: Exports;
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/types.d.ts
|
|
909
|
+
/**
|
|
910
|
+
* Union of all binding definitions accepted in `env`.
|
|
911
|
+
*/
|
|
912
|
+
type Binding = AgentMemoryBinding | AiBinding | AiSearchBinding | AiSearchNamespaceBinding | AnalyticsEngineDatasetBinding | ArtifactsBinding | AssetsBinding | BrowserBinding | D1Binding | DispatchNamespaceBinding | DurableObjectBinding | FlagshipBinding | HyperdriveBinding | ImagesBinding$1 | JsonBinding | KvBinding | LogfwdrBinding | MediaBinding$1 | MtlsCertificateBinding | PipelineBinding | QueueBinding | R2Binding | RateLimitBinding | SecretBinding | SecretsStoreSecretBinding | SendEmailBinding | StreamBinding$1 | TextBinding | UnsafeBinding | VectorizeBinding | VersionMetadataBinding | VpcNetworkBinding | VpcServiceBinding | WebSearchBinding | WorkerBinding | WorkerLoaderBinding;
|
|
913
|
+
/**
|
|
914
|
+
* Union of all trigger definitions accepted in `triggers`.
|
|
915
|
+
*/
|
|
916
|
+
type Trigger = FetchTrigger | QueueConsumerTrigger | ScheduledTrigger;
|
|
917
|
+
/**
|
|
918
|
+
* Union of all export definitions accepted in `exports`.
|
|
919
|
+
*/
|
|
920
|
+
type Export = DurableObjectExport;
|
|
921
|
+
/**
|
|
922
|
+
* Worker configuration. This is the input shape passed to
|
|
923
|
+
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
924
|
+
*
|
|
925
|
+
* Fields are validated at runtime by `ConfigSchema` and normalised before
|
|
926
|
+
* being passed to downstream tooling.
|
|
927
|
+
*/
|
|
928
|
+
interface UserConfig {
|
|
929
|
+
/**
|
|
930
|
+
* The name of your Worker.
|
|
931
|
+
*/
|
|
932
|
+
name?: string;
|
|
933
|
+
/**
|
|
934
|
+
* This is the ID of the account associated with your zone.
|
|
935
|
+
* You might have more than one account, so make sure to use
|
|
936
|
+
* the ID of the account associated with the zone/route you
|
|
937
|
+
* provide, if you provide one. It can also be specified through
|
|
938
|
+
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
939
|
+
*/
|
|
940
|
+
accountId?: string;
|
|
941
|
+
/**
|
|
942
|
+
* A date in the form yyyy-mm-dd, which will be used to determine
|
|
943
|
+
* which version of the Workers runtime is used.
|
|
944
|
+
*
|
|
945
|
+
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
|
|
946
|
+
*/
|
|
947
|
+
compatibilityDate?: string;
|
|
948
|
+
/**
|
|
949
|
+
* A list of flags that enable features from upcoming features of
|
|
950
|
+
* the Workers runtime, usually used together with `compatibilityDate`.
|
|
951
|
+
*
|
|
952
|
+
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
|
|
953
|
+
*
|
|
954
|
+
* @default []
|
|
955
|
+
*/
|
|
956
|
+
compatibilityFlags?: string[];
|
|
957
|
+
/**
|
|
958
|
+
* The entrypoint module that will be executed.
|
|
959
|
+
*
|
|
960
|
+
* May be either a path string (e.g. `"./src/index.ts"`) or a module
|
|
961
|
+
* namespace imported with the `cf-worker` import attribute.
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* ```ts
|
|
965
|
+
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
966
|
+
* export default defineWorker({ entrypoint });
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
entrypoint?: string | WorkerModule;
|
|
970
|
+
/**
|
|
971
|
+
* Specify the directory of static assets to deploy/serve.
|
|
972
|
+
*
|
|
973
|
+
* More details at https://developers.cloudflare.com/workers/frameworks/
|
|
974
|
+
*
|
|
975
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
976
|
+
*/
|
|
977
|
+
assets?: {
|
|
978
|
+
/** How to handle HTML requests. */
|
|
979
|
+
htmlHandling?: "auto-trailing-slash" | "drop-trailing-slash" | "force-trailing-slash" | "none";
|
|
980
|
+
/** How to handle requests that do not match an asset. */
|
|
981
|
+
notFoundHandling?: "single-page-application" | "404-page" | "none";
|
|
982
|
+
/**
|
|
983
|
+
* Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
|
|
984
|
+
*
|
|
985
|
+
* Can also be `true`, indicating that every request should be routed to the User Worker.
|
|
986
|
+
*/
|
|
987
|
+
runWorkerFirst?: string[] | boolean;
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* Custom domains that your Worker should be published to.
|
|
991
|
+
*
|
|
992
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
993
|
+
*/
|
|
994
|
+
domains?: string[];
|
|
995
|
+
/**
|
|
996
|
+
* Event triggers — fetch routes, queue consumers, and cron schedules
|
|
997
|
+
* — that invoke this Worker. Construct entries with `triggers.fetch(...)`,
|
|
998
|
+
* `triggers.queue(...)`, or `triggers.scheduled(...)`.
|
|
999
|
+
*
|
|
1000
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
1001
|
+
*/
|
|
1002
|
+
triggers?: Trigger[];
|
|
1003
|
+
/**
|
|
1004
|
+
* A list of Tail Workers that are bound to this Worker.
|
|
1005
|
+
*
|
|
1006
|
+
* `@cloudflare/config` unifies regular and streaming tail consumers under
|
|
1007
|
+
* a single field; pass `streaming: true` to forward streaming tail events.
|
|
1008
|
+
*
|
|
1009
|
+
* @default []
|
|
1010
|
+
*/
|
|
1011
|
+
tailConsumers?: Array<{
|
|
1012
|
+
/** The name of the service tail events will be forwarded to. */
|
|
1013
|
+
workerName: string;
|
|
1014
|
+
/** Whether to stream tail events in real time. */
|
|
1015
|
+
streaming?: boolean;
|
|
1016
|
+
}>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Specify the cache behavior of the Worker.
|
|
1019
|
+
*/
|
|
1020
|
+
cache?: {
|
|
1021
|
+
/** If cache is enabled for this Worker. */
|
|
1022
|
+
enabled: boolean;
|
|
1023
|
+
};
|
|
1024
|
+
/**
|
|
1025
|
+
* Specify how the Worker should be located to minimize round-trip time.
|
|
1026
|
+
*
|
|
1027
|
+
* More details: https://developers.cloudflare.com/workers/platform/smart-placement/
|
|
1028
|
+
*/
|
|
1029
|
+
placement?: {
|
|
1030
|
+
mode: "off" | "smart";
|
|
1031
|
+
hint?: string;
|
|
1032
|
+
} | {
|
|
1033
|
+
mode?: "targeted";
|
|
1034
|
+
region: string;
|
|
1035
|
+
} | {
|
|
1036
|
+
mode?: "targeted";
|
|
1037
|
+
host: string;
|
|
1038
|
+
} | {
|
|
1039
|
+
mode?: "targeted";
|
|
1040
|
+
hostname: string;
|
|
1041
|
+
};
|
|
1042
|
+
/**
|
|
1043
|
+
* Specify limits for runtime behavior.
|
|
1044
|
+
* Only supported for the "standard" Usage Model.
|
|
1045
|
+
*
|
|
1046
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#limits
|
|
1047
|
+
*/
|
|
1048
|
+
limits?: {
|
|
1049
|
+
/** Maximum allowed CPU time for a Worker's invocation in milliseconds. */
|
|
1050
|
+
cpuMs?: number;
|
|
1051
|
+
/** Maximum allowed number of fetch requests that a Worker's invocation can execute. */
|
|
1052
|
+
subrequests?: number;
|
|
1053
|
+
};
|
|
1054
|
+
/**
|
|
1055
|
+
* Send Trace Events from this Worker to Workers Logpush.
|
|
1056
|
+
*
|
|
1057
|
+
* This will not configure a corresponding Logpush job automatically.
|
|
1058
|
+
*
|
|
1059
|
+
* For more information about Workers Logpush, see:
|
|
1060
|
+
* https://blog.cloudflare.com/logpush-for-workers/
|
|
1061
|
+
*/
|
|
1062
|
+
logpush?: boolean;
|
|
1063
|
+
/**
|
|
1064
|
+
* Specify the observability behavior of the Worker.
|
|
1065
|
+
*
|
|
1066
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#observability
|
|
1067
|
+
*/
|
|
1068
|
+
observability?: {
|
|
1069
|
+
/** If observability is enabled for this Worker. */
|
|
1070
|
+
enabled?: boolean;
|
|
1071
|
+
/** The sampling rate. */
|
|
1072
|
+
headSamplingRate?: number;
|
|
1073
|
+
logs?: {
|
|
1074
|
+
enabled?: boolean;
|
|
1075
|
+
/** The sampling rate. */
|
|
1076
|
+
headSamplingRate?: number;
|
|
1077
|
+
/** Set to false to disable invocation logs. */
|
|
1078
|
+
invocationLogs?: boolean;
|
|
1079
|
+
/**
|
|
1080
|
+
* If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
1081
|
+
*
|
|
1082
|
+
* @default true
|
|
1083
|
+
*/
|
|
1084
|
+
persist?: boolean;
|
|
1085
|
+
/**
|
|
1086
|
+
* What destinations logs emitted from the Worker should be sent to.
|
|
1087
|
+
*
|
|
1088
|
+
* @default []
|
|
1089
|
+
*/
|
|
1090
|
+
destinations?: string[];
|
|
1091
|
+
};
|
|
1092
|
+
traces?: {
|
|
1093
|
+
enabled?: boolean;
|
|
1094
|
+
/** The sampling rate. */
|
|
1095
|
+
headSamplingRate?: number;
|
|
1096
|
+
/**
|
|
1097
|
+
* If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
1098
|
+
*
|
|
1099
|
+
* @default true
|
|
1100
|
+
*/
|
|
1101
|
+
persist?: boolean;
|
|
1102
|
+
/**
|
|
1103
|
+
* What destinations traces emitted from the Worker should be sent to.
|
|
1104
|
+
*
|
|
1105
|
+
* @default []
|
|
1106
|
+
*/
|
|
1107
|
+
destinations?: string[];
|
|
1108
|
+
};
|
|
1109
|
+
};
|
|
1110
|
+
/**
|
|
1111
|
+
* Whether we use `<name>.<subdomain>.workers.dev` to
|
|
1112
|
+
* test and deploy your Worker.
|
|
1113
|
+
*
|
|
1114
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workersdev
|
|
1115
|
+
*
|
|
1116
|
+
* @default true
|
|
1117
|
+
*/
|
|
1118
|
+
workersDev?: boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* Whether we use `<version>-<name>.<subdomain>.workers.dev` to
|
|
1121
|
+
* serve Preview URLs for your Worker.
|
|
1122
|
+
*
|
|
1123
|
+
* @default false
|
|
1124
|
+
*/
|
|
1125
|
+
previewUrls?: boolean;
|
|
1126
|
+
/**
|
|
1127
|
+
* Specify the compliance region mode of the Worker.
|
|
1128
|
+
*
|
|
1129
|
+
* Although if the user does not specify a compliance region, the default is `public`,
|
|
1130
|
+
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
1131
|
+
*/
|
|
1132
|
+
complianceRegion?: "public" | "fedramp-high";
|
|
1133
|
+
/**
|
|
1134
|
+
* Designates this Worker as an internal-only "first-party" Worker.
|
|
1135
|
+
*
|
|
1136
|
+
* @internal
|
|
1137
|
+
*/
|
|
1138
|
+
firstPartyWorker?: boolean;
|
|
1139
|
+
/**
|
|
1140
|
+
* "Unsafe" tables for runtime features that aren't directly supported by
|
|
1141
|
+
* this configuration. Values are forwarded verbatim in the Worker's
|
|
1142
|
+
* upload metadata.
|
|
1143
|
+
*
|
|
1144
|
+
* @default {}
|
|
1145
|
+
*/
|
|
1146
|
+
unsafe?: {
|
|
1147
|
+
/**
|
|
1148
|
+
* Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
|
|
1149
|
+
* here will always be applied to metadata last, so can add new or override existing fields.
|
|
1150
|
+
*/
|
|
1151
|
+
metadata?: Record<string, unknown>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Used for internal capnp uploads for the Workers runtime.
|
|
1154
|
+
*/
|
|
1155
|
+
capnp?: {
|
|
1156
|
+
basePath: string;
|
|
1157
|
+
sourceSchemas: string[];
|
|
1158
|
+
compiledSchema?: never;
|
|
1159
|
+
} | {
|
|
1160
|
+
basePath?: never;
|
|
1161
|
+
sourceSchemas?: never;
|
|
1162
|
+
compiledSchema: string;
|
|
1163
|
+
};
|
|
1164
|
+
};
|
|
1165
|
+
/**
|
|
1166
|
+
* Bindings exposed on the Worker's `env` object. Construct entries with
|
|
1167
|
+
* `bindings.kv(...)`, `bindings.r2(...)`, etc.
|
|
1168
|
+
*/
|
|
1169
|
+
env?: Record<string, Binding>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
1172
|
+
* key is the exported class name; the value configures the export.
|
|
1173
|
+
* Construct entries with `exports.durableObject(...)` or
|
|
1174
|
+
* `exports.workflow(...)`.
|
|
1175
|
+
*
|
|
1176
|
+
* Two export kinds are supported:
|
|
1177
|
+
*
|
|
1178
|
+
* - `durable-object`: declares a Durable Object class defined by this
|
|
1179
|
+
* Worker. For more information about Durable Objects, see the
|
|
1180
|
+
* documentation at
|
|
1181
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
1182
|
+
*
|
|
1183
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1184
|
+
*
|
|
1185
|
+
* - `workflow`: declares a Workflow defined by this Worker.
|
|
1186
|
+
*/
|
|
1187
|
+
exports?: Record<string, Export>;
|
|
1188
|
+
}
|
|
1189
|
+
//#endregion
|
|
1190
|
+
//#region src/worker-definition.d.ts
|
|
1191
|
+
interface ConfigContext {
|
|
1192
|
+
/**
|
|
1193
|
+
* The mode the config is being evaluated in.
|
|
1194
|
+
* Set via the `--mode` CLI flag.
|
|
1195
|
+
* In Vite the mode defaults to `development` in `vite dev` and `production` in `vite build` ([more info](https://vite.dev/guide/env-and-mode.html#modes)).
|
|
1196
|
+
* In Wrangler the mode defaults to `undefined`.
|
|
1197
|
+
*/
|
|
1198
|
+
mode: string | undefined;
|
|
1199
|
+
}
|
|
1200
|
+
declare const CONFIG: unique symbol;
|
|
1201
|
+
/**
|
|
1202
|
+
* Base shape of a Worker definition. Carries the resolved config and the
|
|
1203
|
+
* untyped cross-worker binding helpers.
|
|
1204
|
+
*/
|
|
1205
|
+
interface WorkerDefinition<TConfig$1 extends UserConfig = UserConfig> extends Pick<Bindings, "durableObject" | "worker"> {
|
|
1206
|
+
[CONFIG]: TConfig$1 | Promise<TConfig$1> | ((ctx: ConfigContext) => TConfig$1 | Promise<TConfig$1>);
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Worker definition with typed cross-worker binding helpers.
|
|
1210
|
+
*/
|
|
1211
|
+
interface TypedWorkerDefinition<TConfig$1 extends UserConfig, TWorkerName extends string = InferWorkerName<TConfig$1>> extends WorkerDefinition<TConfig$1> {
|
|
1212
|
+
/**
|
|
1213
|
+
* Binding to a Durable Object class. `workerName` is the name of the Worker
|
|
1214
|
+
* that defines the class; `exportName` is the exported class name.
|
|
1215
|
+
*
|
|
1216
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1217
|
+
*/
|
|
1218
|
+
durableObject<TExportName$1 extends InferExportsByType<TConfig$1, "durable-object">>(options: {
|
|
1219
|
+
workerName: TWorkerName;
|
|
1220
|
+
exportName: TExportName$1;
|
|
1221
|
+
}): TypedDurableObjectBinding<TConfig$1, TExportName$1>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Service binding (Worker-to-Worker). `workerName` is the name of the bound
|
|
1224
|
+
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
1225
|
+
* the default export).
|
|
1226
|
+
*
|
|
1227
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
1228
|
+
*/
|
|
1229
|
+
worker<TExportName$1 extends InferWorkerEntrypointExports<TConfig$1> | undefined = undefined>(options: {
|
|
1230
|
+
workerName: TWorkerName;
|
|
1231
|
+
exportName?: TExportName$1;
|
|
1232
|
+
props?: Record<string, unknown>;
|
|
1233
|
+
remote?: boolean;
|
|
1234
|
+
}): TypedWorkerBinding<TConfig$1, TExportName$1 extends string ? TExportName$1 : "default">;
|
|
1235
|
+
}
|
|
1236
|
+
type UserConfigExport<T$1 extends UserConfig = UserConfig> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
|
|
1237
|
+
declare function defineWorker<const T$1 extends UserConfig>(config: (ctx: ConfigContext) => (UserConfig & T$1) | Promise<UserConfig & T$1>): TypedWorkerDefinition<T$1>;
|
|
1238
|
+
declare function defineWorker<const T$1 extends UserConfig>(config: (UserConfig & T$1) | Promise<UserConfig & T$1>): TypedWorkerDefinition<T$1>;
|
|
1239
|
+
//#endregion
|
|
1240
|
+
//#region src/inference.d.ts
|
|
1241
|
+
/**
|
|
1242
|
+
* The Worker's entry module, imported with the `{ type: "cf-worker" }` import attribute
|
|
1243
|
+
* @example
|
|
1244
|
+
* ```ts
|
|
1245
|
+
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
1246
|
+
* ```
|
|
1247
|
+
*/
|
|
1248
|
+
type WorkerModule = Record<string, any>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Default module type representing an unknown Worker's exports.
|
|
1251
|
+
* - default export can be `ExportedHandler` or a `WorkerEntrypoint` class constructor
|
|
1252
|
+
* - named exports can be `WorkerEntrypoint`, `DurableObject`, or `WorkflowEntrypoint` class constructors
|
|
1253
|
+
*/
|
|
1254
|
+
interface DefaultModule {
|
|
1255
|
+
default?: ExportedHandler | Constructor<Rpc.WorkerEntrypointBranded>;
|
|
1256
|
+
[key: string]: ExportedHandler | Constructor<Rpc.WorkerEntrypointBranded> | Constructor<Rpc.DurableObjectBranded> | Constructor<Rpc.WorkflowEntrypointBranded> | undefined;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Represents a class constructor that creates instances of TInstance.
|
|
1260
|
+
*/
|
|
1261
|
+
type Constructor<TInstance> = new (...args: any[]) => TInstance;
|
|
1262
|
+
/**
|
|
1263
|
+
* Extracts the instance type from a class constructor if it extends `TInstance`.
|
|
1264
|
+
*/
|
|
1265
|
+
type ExtractInstance<T$1, TInstance> = T$1 extends Constructor<TInstance> ? InstanceType<T$1> : never;
|
|
1266
|
+
/**
|
|
1267
|
+
* Mapping from binding type literals to Cloudflare runtime types.
|
|
1268
|
+
*
|
|
1269
|
+
* Entries fall into two groups:
|
|
1270
|
+
* - Parameterized bindings (ai, json, kv, pipeline, queue, text) refine their
|
|
1271
|
+
* runtime type from the binding instance via nominal matches against the
|
|
1272
|
+
* `Typed*Binding` / `JsonBinding` / `TextBinding` interfaces from
|
|
1273
|
+
* `./bindings`. When `TBinding` does not match, the entry falls back to the
|
|
1274
|
+
* unparameterized runtime type.
|
|
1275
|
+
* - Non-parameterized bindings map their type literal directly to a runtime
|
|
1276
|
+
* type and ignore `TBinding`.
|
|
1277
|
+
*
|
|
1278
|
+
* IMPORTANT: The right-hand-side identifiers in this map (e.g. `KVNamespace`,
|
|
1279
|
+
* `ImagesBinding`, `Fetcher`) must resolve to the ambient runtime types from
|
|
1280
|
+
* `@cloudflare/workers-types`, not to local config interfaces. Several local
|
|
1281
|
+
* binding interfaces in `./bindings.ts` (`ImagesBinding`, `MediaBinding`,
|
|
1282
|
+
* `StreamBinding`) share names with ambient globals — importing those local
|
|
1283
|
+
* types into this file silently shadows the globals and breaks `InferEnv`.
|
|
1284
|
+
* Only import the `Typed*Binding`, `JsonBinding`, and `TextBinding` interfaces
|
|
1285
|
+
* from `./bindings` (their names do not collide with ambient globals); never
|
|
1286
|
+
* widen the import to a wildcard or to the plain `*Binding` interfaces.
|
|
1287
|
+
*/
|
|
1288
|
+
interface BindingTypeMap<TBinding> {
|
|
1289
|
+
ai: TBinding extends TypedAiBinding<infer T> ? Ai<T> : Ai;
|
|
1290
|
+
json: TBinding extends JsonBinding<infer T> ? T : never;
|
|
1291
|
+
kv: TBinding extends TypedKvBinding<infer T> ? KVNamespace<T> : KVNamespace;
|
|
1292
|
+
pipeline: TBinding extends TypedPipelineBinding<infer T> ? Pipeline<T> : Pipeline;
|
|
1293
|
+
queue: TBinding extends TypedQueueBinding<infer T> ? Queue<T> : Queue;
|
|
1294
|
+
text: TBinding extends TextBinding<infer T> ? T : never;
|
|
1295
|
+
"agent-memory": AgentMemoryNamespace;
|
|
1296
|
+
"ai-search": AiSearchInstance;
|
|
1297
|
+
"ai-search-namespace": AiSearchNamespace;
|
|
1298
|
+
"analytics-engine-dataset": AnalyticsEngineDataset;
|
|
1299
|
+
artifacts: Artifacts;
|
|
1300
|
+
assets: Fetcher;
|
|
1301
|
+
browser: BrowserRun;
|
|
1302
|
+
d1: D1Database;
|
|
1303
|
+
"dispatch-namespace": DispatchNamespace;
|
|
1304
|
+
"durable-object": DurableObjectNamespace;
|
|
1305
|
+
flagship: Flagship;
|
|
1306
|
+
hyperdrive: Hyperdrive;
|
|
1307
|
+
images: ImagesBinding;
|
|
1308
|
+
logfwdr: any;
|
|
1309
|
+
media: MediaBinding;
|
|
1310
|
+
"mtls-certificate": Fetcher;
|
|
1311
|
+
"rate-limit": RateLimit;
|
|
1312
|
+
r2: R2Bucket;
|
|
1313
|
+
secret: string;
|
|
1314
|
+
"secrets-store-secret": SecretsStoreSecret;
|
|
1315
|
+
"send-email": SendEmail;
|
|
1316
|
+
stream: StreamBinding;
|
|
1317
|
+
vectorize: VectorizeIndex;
|
|
1318
|
+
"version-metadata": WorkerVersionMetadata;
|
|
1319
|
+
"vpc-service": Fetcher;
|
|
1320
|
+
"vpc-network": Fetcher;
|
|
1321
|
+
"web-search": WebSearch;
|
|
1322
|
+
worker: Fetcher;
|
|
1323
|
+
"worker-loader": WorkerLoader;
|
|
1324
|
+
workflow: Workflow;
|
|
1325
|
+
}
|
|
1326
|
+
type InferBindingType<TBinding> = TBinding extends TypedWorkerBinding<infer TConfig, infer TExportName extends string> ? InferMainModule<TConfig> extends infer TModule extends WorkerModule ? TExportName extends keyof TModule ? TModule[TExportName] extends Constructor<any> ? Fetcher<ExtractInstance<TModule[TExportName], Rpc.WorkerEntrypointBranded>> : Fetcher : never : never : TBinding extends TypedDurableObjectBinding<infer TConfig, infer TExportName extends string> ? InferMainModule<TConfig> extends infer TModule extends WorkerModule ? TExportName extends keyof TModule ? DurableObjectNamespace<ExtractInstance<TModule[TExportName], Rpc.DurableObjectBranded>> : never : never : TBinding extends TypedWorkflowBinding<infer TConfig, infer TExportName extends string> ? InferMainModule<TConfig> extends infer TModule extends WorkerModule ? TExportName extends keyof TModule ? ExtractInstance<TModule[TExportName], Rpc.WorkflowEntrypointBranded> extends infer TWorkflow ? TWorkflow extends {
|
|
1327
|
+
run(event: {
|
|
1328
|
+
payload: infer P;
|
|
1329
|
+
}, step: any): any;
|
|
1330
|
+
} ? Workflow<P> : Workflow : Workflow : never : never : TBinding extends {
|
|
1331
|
+
type: `unsafe:${string}`;
|
|
1332
|
+
} ? any : TBinding extends {
|
|
1333
|
+
type: infer K extends keyof BindingTypeMap<TBinding>;
|
|
1334
|
+
} ? BindingTypeMap<TBinding>[K] : never;
|
|
1335
|
+
/**
|
|
1336
|
+
* Infer the Worker name from a config.
|
|
1337
|
+
*
|
|
1338
|
+
* @example
|
|
1339
|
+
* ```typescript
|
|
1340
|
+
* import { defineWorker } from "@cloudflare/config";
|
|
1341
|
+
* import type { InferDurableNamespaces, UnwrapConfig } from "@cloudflare/config";
|
|
1342
|
+
*
|
|
1343
|
+
* const config = defineWorker({ name: "my-worker", ... });
|
|
1344
|
+
*
|
|
1345
|
+
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
1346
|
+
* // Inferred as: "my-worker"
|
|
1347
|
+
* type Name = InferWorkerName<WorkerConfig>;
|
|
1348
|
+
* ```
|
|
1349
|
+
*/
|
|
1350
|
+
type InferWorkerName<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1351
|
+
name: infer TName extends string;
|
|
1352
|
+
} ? TName : never;
|
|
1353
|
+
/**
|
|
1354
|
+
* Infer export names from a config's exports, optionally filtered by type.
|
|
1355
|
+
* When TExportType is `string` (default), returns all export names.
|
|
1356
|
+
* When TExportType is a specific literal like `"durable-object"` or `"workflow"`,
|
|
1357
|
+
* returns only exports of that type.
|
|
1358
|
+
*/
|
|
1359
|
+
type InferExportsByType<TUnwrappedConfig$1, TExportType extends string = string> = TUnwrappedConfig$1 extends {
|
|
1360
|
+
exports: infer TExports extends Record<string, {
|
|
1361
|
+
type: string;
|
|
1362
|
+
}>;
|
|
1363
|
+
} ? { [K in keyof TExports]: TExports[K] extends {
|
|
1364
|
+
type: TExportType;
|
|
1365
|
+
} ? K & string : never }[keyof TExports] : never;
|
|
1366
|
+
/**
|
|
1367
|
+
* Infer `WorkerEntrypoint` export names from a config.
|
|
1368
|
+
* Returns named module exports that are not declared as type `"durable-object"` or `"workflow"` in `exports`.
|
|
1369
|
+
* Excludes `"default"` since `exportName` should only be provided for named exports.
|
|
1370
|
+
*/
|
|
1371
|
+
type InferWorkerEntrypointExports<TUnwrappedConfig$1> = Exclude<keyof InferMainModule<TUnwrappedConfig$1> & string, "default" | InferExportsByType<TUnwrappedConfig$1, "durable-object" | "workflow">>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Unwrap function and promise types to get the underlying config.
|
|
1374
|
+
* Use this to normalize a config before passing it to other inference utilities.
|
|
1375
|
+
*/
|
|
1376
|
+
type UnwrapConfig<TConfig$1> = TConfig$1 extends WorkerDefinition<infer TUnwrappedConfig> ? TUnwrappedConfig : TConfig$1 extends UserConfigExport<infer TUnwrappedConfig> ? TUnwrappedConfig : never;
|
|
1377
|
+
/**
|
|
1378
|
+
* Infer the `Env` interface type from a Worker config.
|
|
1379
|
+
*
|
|
1380
|
+
* Transforms a config object's `env` bindings into their
|
|
1381
|
+
* corresponding Cloudflare runtime types.
|
|
1382
|
+
*
|
|
1383
|
+
* @example
|
|
1384
|
+
* ```typescript
|
|
1385
|
+
* import { defineWorker, bindings } from "@cloudflare/config";
|
|
1386
|
+
* import type { InferEnv, UnwrapConfig } from "@cloudflare/config";
|
|
1387
|
+
*
|
|
1388
|
+
* const config = defineWorker({
|
|
1389
|
+
* env: {
|
|
1390
|
+
* MY_JSON: bindings.json({ id: string }),
|
|
1391
|
+
* MY_KV: bindings.kv(),
|
|
1392
|
+
* },
|
|
1393
|
+
* });
|
|
1394
|
+
*
|
|
1395
|
+
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
1396
|
+
* // Inferred as: { MY_JSON: { id: string }; MY_KV: KVNamespace }
|
|
1397
|
+
* export type Env = InferEnv<WorkerConfig>;
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
type InferEnv<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1401
|
+
env: infer TEnv extends Record<string, any>;
|
|
1402
|
+
} ? { [K in keyof TEnv]: InferBindingType<TEnv[K]> } : never;
|
|
1403
|
+
/**
|
|
1404
|
+
* Infer the Durable Object namespace names from a Worker config's exports.
|
|
1405
|
+
* Returns a union of export names that have `type: "durable-object"`.
|
|
1406
|
+
*
|
|
1407
|
+
* @example
|
|
1408
|
+
* ```typescript
|
|
1409
|
+
* import { defineWorker } from "@cloudflare/config";
|
|
1410
|
+
* import type { InferDurableNamespaces, UnwrapConfig } from "@cloudflare/config";
|
|
1411
|
+
*
|
|
1412
|
+
* const config = defineWorker({
|
|
1413
|
+
* exports: {
|
|
1414
|
+
* MyDurableObject: { type: "durable-object", storage: "sqlite" },
|
|
1415
|
+
* MyWorkflow: { type: "workflow", name: "my-workflow" },
|
|
1416
|
+
* },
|
|
1417
|
+
* });
|
|
1418
|
+
*
|
|
1419
|
+
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
1420
|
+
* // Inferred as: "MyDurableObject"
|
|
1421
|
+
* type DurableNamespaces = InferDurableNamespaces<WorkerConfig>;
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
type InferDurableNamespaces<TUnwrappedConfig$1> = InferExportsByType<TUnwrappedConfig$1, "durable-object">;
|
|
1425
|
+
/**
|
|
1426
|
+
* Infer the main module type from a Worker config's entrypoint.
|
|
1427
|
+
* If entrypoint is a module namespace object, returns that type.
|
|
1428
|
+
* If entrypoint is a `string` or not present, returns `DefaultModule` as a fallback.
|
|
1429
|
+
*/
|
|
1430
|
+
type InferMainModule<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1431
|
+
entrypoint: infer TModule extends WorkerModule;
|
|
1432
|
+
} ? TModule : DefaultModule;
|
|
1433
|
+
//#endregion
|
|
1434
|
+
//#endregion
|
|
1435
|
+
//#region src/experimental-config/types.d.ts
|
|
1436
|
+
/**
|
|
1437
|
+
* The shape of `wrangler.config.ts` — tooling / bundling / dev-server
|
|
1438
|
+
* configuration that complements the Worker configuration authored in
|
|
1439
|
+
* `cloudflare.config.ts` via `defineWorker`.
|
|
1440
|
+
*/
|
|
1441
|
+
interface WranglerConfig {
|
|
1442
|
+
noBundle?: boolean;
|
|
1443
|
+
minify?: boolean;
|
|
1444
|
+
keepNames?: boolean;
|
|
1445
|
+
alias?: Record<string, string>;
|
|
1446
|
+
define?: Record<string, string>;
|
|
1447
|
+
findAdditionalModules?: boolean;
|
|
1448
|
+
preserveFileNames?: boolean;
|
|
1449
|
+
baseDir?: string;
|
|
1450
|
+
rules?: Array<{
|
|
1451
|
+
type: "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data" | "PythonModule" | "PythonRequirement";
|
|
1452
|
+
globs: string[];
|
|
1453
|
+
fallthrough?: boolean;
|
|
1454
|
+
}>;
|
|
1455
|
+
wasmModules?: Record<string, string>;
|
|
1456
|
+
textBlobs?: Record<string, string>;
|
|
1457
|
+
dataBlobs?: Record<string, string>;
|
|
1458
|
+
tsconfig?: string;
|
|
1459
|
+
jsxFactory?: string;
|
|
1460
|
+
jsxFragment?: string;
|
|
1461
|
+
pythonModules?: {
|
|
1462
|
+
exclude?: string[];
|
|
1463
|
+
};
|
|
1464
|
+
uploadSourceMaps?: boolean;
|
|
1465
|
+
build?: {
|
|
1466
|
+
command?: string;
|
|
1467
|
+
cwd?: string;
|
|
1468
|
+
watchDir?: string | string[];
|
|
1469
|
+
};
|
|
1470
|
+
/**
|
|
1471
|
+
* Assets directory — the only tooling-side asset setting. The runtime
|
|
1472
|
+
* asset fields (`binding`, `htmlHandling`, `notFoundHandling`,
|
|
1473
|
+
* `runWorkerFirst`) live in `cloudflare.config.ts` under `assets`.
|
|
1474
|
+
*/
|
|
1475
|
+
assetsDirectory?: string;
|
|
1476
|
+
dev?: {
|
|
1477
|
+
ip?: string;
|
|
1478
|
+
port?: number;
|
|
1479
|
+
inspectorPort?: number;
|
|
1480
|
+
inspectorIp?: string;
|
|
1481
|
+
localProtocol?: "http" | "https";
|
|
1482
|
+
upstreamProtocol?: "http" | "https";
|
|
1483
|
+
host?: string;
|
|
1484
|
+
/**
|
|
1485
|
+
* Type-generation settings. Consumed directly by the new-config
|
|
1486
|
+
* type-generation path (`regenerateNewConfigTypes`) — NOT threaded
|
|
1487
|
+
* through the merged `RawConfig`. Default: `{ generate: true }`.
|
|
1488
|
+
* Structured as an object to allow additional properties in future.
|
|
1489
|
+
*/
|
|
1490
|
+
types?: {
|
|
1491
|
+
generate?: boolean;
|
|
1492
|
+
};
|
|
1493
|
+
/**
|
|
1494
|
+
* Container-related dev settings. `containers` itself is currently not
|
|
1495
|
+
* supported under `--experimental-new-config`, but these dev-time settings are
|
|
1496
|
+
* accepted so users can enable them ahead of `containers` opening up.
|
|
1497
|
+
* They're no-ops when `containers` is absent.
|
|
1498
|
+
*/
|
|
1499
|
+
enableContainers?: boolean;
|
|
1500
|
+
/**
|
|
1501
|
+
* Either the Docker unix socket (e.g. `unix:///var/run/docker.sock`) or
|
|
1502
|
+
* a full configuration. The string form is the common case; the full
|
|
1503
|
+
* object form (with `localDocker.socketPath` and TLS settings) can be
|
|
1504
|
+
* added later if needed.
|
|
1505
|
+
*/
|
|
1506
|
+
containerEngine?: string;
|
|
1507
|
+
};
|
|
1508
|
+
sendMetrics?: boolean;
|
|
1509
|
+
}
|
|
1510
|
+
//#endregion
|
|
1511
|
+
//#region src/experimental-config/wrangler-definition.d.ts
|
|
1512
|
+
type WranglerConfigExport = WranglerConfig | Promise<WranglerConfig> | ((ctx: ConfigContext) => WranglerConfig | Promise<WranglerConfig>);
|
|
1513
|
+
declare function defineWranglerConfig(config: WranglerConfigExport): WranglerConfigExport;
|
|
1514
|
+
//#endregion
|
|
1515
|
+
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, Bindings, BrowserBinding, ConfigContext, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectExport, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding$1 as ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding$1 as MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, StreamBinding$1 as StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, UserConfig, UserConfigExport, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerLoaderBinding, WorkflowBinding, WorkflowExport, WranglerConfig, WranglerConfigExport, bindings, defineWorker, defineWranglerConfig, exports, triggers };
|
|
1516
|
+
//# sourceMappingURL=experimental-config.d.mts.map
|