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