@cloudflare/config 0.14.0 → 0.16.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.
@@ -1,7 +1,174 @@
1
1
  import { Pipeline, PipelineRecord } from "cloudflare:pipelines";
2
2
 
3
- //#region src/inference.d.ts
3
+ //#region src/exports.d.ts
4
4
 
5
+ /**
6
+ * Storage backend for the Durable Object.
7
+ *
8
+ * Containers are only supported on the SQLite storage engine, so `container` is
9
+ * only offered alongside `storage: "sqlite"`.
10
+ */
11
+ type DurableObjectStorageOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
12
+ /**
13
+ * Selects the SQLite-backed storage engine (recommended for new
14
+ * classes).
15
+ */
16
+ storage: "sqlite";
17
+ /**
18
+ * Attach a Container application to this Durable Object by config reference.
19
+ */
20
+ container?: TContainer;
21
+ } | {
22
+ /** Selects the legacy key-value storage engine. */
23
+ storage: "legacy-kv";
24
+ };
25
+ /**
26
+ * Declares a provisioned Durable Object class exported from this Worker.
27
+ *
28
+ * For more information about Durable Objects, see the documentation at
29
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
30
+ *
31
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
32
+ */
33
+ type DurableObjectCreatedExportOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
34
+ state?: "created";
35
+ } & DurableObjectStorageOptions<TContainer>;
36
+ /**
37
+ * Retire a provisioned Durable Object namespace whose class has
38
+ * been removed from code.
39
+ *
40
+ * During deploy, the class must not be exported in the uploaded code, and no
41
+ * other Worker may hold a `durableObject` binding to the namespace.
42
+ */
43
+ interface DurableObjectDeletedExportOptions {
44
+ state: "deleted";
45
+ }
46
+ /**
47
+ * Rename a provisioned Durable Object namespace's class. The
48
+ * `renamedTo` value must also appear as a live (`state: "created"`)
49
+ * `durableObject` entry in the same `exports` map.
50
+ */
51
+ interface DurableObjectRenamedExportOptions {
52
+ state: "renamed";
53
+ /**
54
+ * The destination class name. Must be a valid JavaScript identifier and
55
+ * must appear as a live (`state: "created"`) `durableObject` entry in the
56
+ * same `exports` map.
57
+ */
58
+ renamedTo: string;
59
+ }
60
+ /**
61
+ * Transfer ownership of a Durable Object namespace to another Worker in the same account.
62
+ * The target Worker must first deploy an `expectingTransfer` entry naming this Worker via `transferFrom`.
63
+ */
64
+ interface DurableObjectTransferredExportOptions {
65
+ state: "transferred";
66
+ /**
67
+ * The destination Worker. Must reference a Worker in the same account.
68
+ */
69
+ transferredTo: string;
70
+ }
71
+ /**
72
+ * Prepare to receive cross-Worker Durable Object transfer.
73
+ * Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
74
+ */
75
+ type DurableObjectExpectingTransferExportOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
76
+ state: "expecting-transfer";
77
+ /**
78
+ * The source Worker for the two-phase cross-Worker transfer.
79
+ */
80
+ transferFrom: string;
81
+ } & DurableObjectStorageOptions<TContainer>;
82
+ type DurableObjectCreatedExport<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = DurableObjectCreatedExportOptions<TContainer> & {
83
+ type: "durable-object";
84
+ };
85
+ interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
86
+ type: "durable-object";
87
+ }
88
+ interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
89
+ type: "durable-object";
90
+ }
91
+ interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
92
+ type: "durable-object";
93
+ }
94
+ type DurableObjectExpectingTransferExport<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = DurableObjectExpectingTransferExportOptions<TContainer> & {
95
+ type: "durable-object";
96
+ };
97
+ type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
98
+ type DurableObjectExports = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport;
99
+ interface WorkerEntrypointExportOptions {
100
+ cache?: {
101
+ /** Whether cache is enabled for this entrypoint. */
102
+ enabled: boolean;
103
+ };
104
+ }
105
+ interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
106
+ type: "worker";
107
+ }
108
+ /**
109
+ * Configuration for named exports declared by the Worker. Each entry's
110
+ * key is the exported class name; the value configures the export.
111
+ */
112
+ interface Exports {
113
+ /**
114
+ * Declares a Durable Object class defined by this Worker.
115
+ *
116
+ * For more information about Durable Objects, see the documentation at
117
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
118
+ *
119
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
120
+ */
121
+ durableObject<TContainer extends ContainerDefinition | undefined = undefined>(options: DurableObjectCreatedExportOptions<TContainer>): DurableObjectCreatedExport<TContainer>;
122
+ /**
123
+ * Retire a provisioned Durable Object namespace whose class has been removed from code.
124
+ */
125
+ durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
126
+ /**
127
+ * Rename a provisioned Durable Object namespace's class.
128
+ */
129
+ durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
130
+ /**
131
+ * Transfer ownership of a Durable Object namespace to another Worker in the same account.
132
+ */
133
+ durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
134
+ /**
135
+ * Prepare to receive cross-Worker Durable Object transfer.
136
+ * The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
137
+ */
138
+ durableObject<TContainer extends ContainerDefinition | undefined = undefined>(options: DurableObjectExpectingTransferExportOptions<TContainer>): DurableObjectExpectingTransferExport<TContainer>;
139
+ durableObject(options: DurableObjectExportOptions): DurableObjectExports;
140
+ /** Declares a WorkerEntrypoint export defined by this Worker. */
141
+ worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
142
+ }
143
+ /**
144
+ * Exports builder for configuring Worker exports.
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * import { defineConfig, defineContainer, defineWorker, exports } from "@cloudflare/config";
149
+ *
150
+ * const myContainer = defineContainer({
151
+ * name: "my-container",
152
+ * image: { dockerfile: "./Dockerfile" },
153
+ * });
154
+ *
155
+ * const worker = defineWorker({
156
+ * exports: {
157
+ * MyDurableObject: exports.durableObject({ storage: "sqlite" }),
158
+ * MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
159
+ * OldClass: exports.durableObject({ state: "deleted" }),
160
+ * OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
161
+ * Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
162
+ * Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
163
+ * },
164
+ * });
165
+ *
166
+ * export default defineConfig({ worker, containers: [myContainer] });
167
+ * ```
168
+ */
169
+ declare const exports: Exports;
170
+ //#endregion
171
+ //#region src/inference.d.ts
5
172
  /**
6
173
  * The Worker's entry module, imported with the `{ type: "cf-worker" }` import attribute
7
174
  * @example
@@ -132,7 +299,7 @@ type InferWorkerEntrypointExports<TUnwrappedConfig> = Exclude<keyof InferMainMod
132
299
  * Unwrap function and promise types to get the underlying config.
133
300
  * Use this to normalize a config before passing it to other inference utilities.
134
301
  */
135
- type UnwrapConfig<TConfig$1> = TConfig$1 extends ((...args: any[]) => infer TReturn) ? UnwrapConfig<TReturn> : TConfig$1 extends Promise<infer TCompletion> ? UnwrapConfig<TCompletion> : TConfig$1;
302
+ type UnwrapConfig<TConfig> = TConfig extends ((...args: any[]) => infer TReturn) ? UnwrapConfig<TReturn> : TConfig extends Promise<infer TCompletion> ? UnwrapConfig<TCompletion> : TConfig;
136
303
  /**
137
304
  * Infer the `Env` interface type from a Worker config.
138
305
  *
@@ -202,218 +369,6 @@ type InferMainModule<TUnwrappedConfig> = TUnwrappedConfig extends {
202
369
  entrypoint: infer TModule extends WorkerModule;
203
370
  } ? TModule : DefaultModule;
204
371
  //#endregion
205
- //#region src/utils.d.ts
206
- /**
207
- * Represents any valid JSON value.
208
- */
209
- type Json = string | number | boolean | null | Json[] | {
210
- [key: string]: Json;
211
- };
212
- //#endregion
213
- //#region src/definition.d.ts
214
- interface ConfigContext {
215
- /**
216
- * The mode the config is being evaluated in.
217
- * Set via the `--mode` CLI flag.
218
- * 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)).
219
- * In Wrangler the mode defaults to `undefined`.
220
- */
221
- mode: string | undefined;
222
- }
223
- /**
224
- * The authored config in any of its supported shapes: a plain value, a promise,
225
- * or a function of {@link ConfigContext}.
226
- */
227
- type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
228
- type ConfigObject = Record<string, unknown>;
229
- type ConfigWithType<T$1 extends ConfigObject, TType extends string> = T$1 & {
230
- type: TType;
231
- };
232
- //#endregion
233
- //#region src/container-definition.d.ts
234
- type ContainerConfigExport<T$1 extends ContainerConfig = ContainerConfig> = ConfigInput<T$1>;
235
- type DistributiveOmit<T$1, K$1 extends PropertyKey> = T$1 extends unknown ? Omit<T$1, K$1> : never;
236
- /**
237
- * Authored Container config shape — {@link ContainerConfig} without the `type`
238
- * discriminant, which `defineContainer` injects.
239
- */
240
- type ContainerConfigInput = DistributiveOmit<ContainerConfig, "type">;
241
- /** Declare a Container application. */
242
- declare const defineContainer: <const TInput extends ConfigInput<ContainerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
243
- [x: string]: unknown;
244
- }> ? Promise<ConfigWithType<TConfig, "container">> : TResult extends {
245
- [x: string]: unknown;
246
- } ? ConfigWithType<TResult, "container"> : never : TInput extends Promise<infer TConfig extends {
247
- [x: string]: unknown;
248
- }> ? Promise<ConfigWithType<TConfig, "container">> : TInput extends {
249
- [x: string]: unknown;
250
- } ? ConfigWithType<TInput, "container"> : never;
251
- //#endregion
252
- //#region src/exports.d.ts
253
- /**
254
- * Storage backend for the Durable Object.
255
- *
256
- * Containers are only supported on the SQLite storage engine, so `container` is
257
- * only offered alongside `storage: "sqlite"`.
258
- */
259
- type DurableObjectStorageOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
260
- /**
261
- * Selects the SQLite-backed storage engine (recommended for new
262
- * classes).
263
- */
264
- storage: "sqlite";
265
- /**
266
- * Attach a Container application to this Durable Object by config reference.
267
- */
268
- container?: TContainer;
269
- } | {
270
- /** Selects the legacy key-value storage engine. */
271
- storage: "legacy-kv";
272
- };
273
- /**
274
- * Declares a provisioned Durable Object class exported from this Worker.
275
- *
276
- * For more information about Durable Objects, see the documentation at
277
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
278
- *
279
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
280
- */
281
- type DurableObjectCreatedExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
282
- state?: "created";
283
- } & DurableObjectStorageOptions<TContainer>;
284
- /**
285
- * Retire a provisioned Durable Object namespace whose class has
286
- * been removed from code.
287
- *
288
- * During deploy, the class must not be exported in the uploaded code, and no
289
- * other Worker may hold a `durableObject` binding to the namespace.
290
- */
291
- interface DurableObjectDeletedExportOptions {
292
- state: "deleted";
293
- }
294
- /**
295
- * Rename a provisioned Durable Object namespace's class. The
296
- * `renamedTo` value must also appear as a live (`state: "created"`)
297
- * `durableObject` entry in the same `exports` map.
298
- */
299
- interface DurableObjectRenamedExportOptions {
300
- state: "renamed";
301
- /**
302
- * The destination class name. Must be a valid JavaScript identifier and
303
- * must appear as a live (`state: "created"`) `durableObject` entry in the
304
- * same `exports` map.
305
- */
306
- renamedTo: string;
307
- }
308
- /**
309
- * Transfer ownership of a Durable Object namespace to another Worker in the same account.
310
- * The target Worker must first deploy an `expectingTransfer` entry naming this Worker via `transferFrom`.
311
- */
312
- interface DurableObjectTransferredExportOptions {
313
- state: "transferred";
314
- /**
315
- * The destination Worker. Must reference a Worker in the same account.
316
- */
317
- transferredTo: string;
318
- }
319
- /**
320
- * Prepare to receive cross-Worker Durable Object transfer.
321
- * Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
322
- */
323
- type DurableObjectExpectingTransferExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
324
- state: "expecting-transfer";
325
- /**
326
- * The source Worker for the two-phase cross-Worker transfer.
327
- */
328
- transferFrom: string;
329
- } & DurableObjectStorageOptions<TContainer>;
330
- type DurableObjectCreatedExport<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = DurableObjectCreatedExportOptions<TContainer> & {
331
- type: "durable-object";
332
- };
333
- interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
334
- type: "durable-object";
335
- }
336
- interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
337
- type: "durable-object";
338
- }
339
- interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
340
- type: "durable-object";
341
- }
342
- type DurableObjectExpectingTransferExport<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = DurableObjectExpectingTransferExportOptions<TContainer> & {
343
- type: "durable-object";
344
- };
345
- type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
346
- type DurableObjectExports = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport;
347
- interface WorkerEntrypointExportOptions {
348
- cache?: {
349
- /** Whether cache is enabled for this entrypoint. */
350
- enabled: boolean;
351
- };
352
- }
353
- interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
354
- type: "worker";
355
- }
356
- /**
357
- * Configuration for named exports declared by the Worker. Each entry's
358
- * key is the exported class name; the value configures the export.
359
- */
360
- interface Exports {
361
- /**
362
- * Declares a Durable Object class defined by this Worker.
363
- *
364
- * For more information about Durable Objects, see the documentation at
365
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
366
- *
367
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
368
- */
369
- durableObject<TContainer extends ContainerConfigExport | undefined = undefined>(options: DurableObjectCreatedExportOptions<TContainer>): DurableObjectCreatedExport<TContainer>;
370
- /**
371
- * Retire a provisioned Durable Object namespace whose class has been removed from code.
372
- */
373
- durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
374
- /**
375
- * Rename a provisioned Durable Object namespace's class.
376
- */
377
- durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
378
- /**
379
- * Transfer ownership of a Durable Object namespace to another Worker in the same account.
380
- */
381
- durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
382
- /**
383
- * Prepare to receive cross-Worker Durable Object transfer.
384
- * The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
385
- */
386
- durableObject<TContainer extends ContainerConfigExport | undefined = undefined>(options: DurableObjectExpectingTransferExportOptions<TContainer>): DurableObjectExpectingTransferExport<TContainer>;
387
- durableObject(options: DurableObjectExportOptions): DurableObjectExports;
388
- /** Declares a WorkerEntrypoint export defined by this Worker. */
389
- worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
390
- }
391
- /**
392
- * Exports builder for configuring Worker exports.
393
- *
394
- * @example
395
- * ```typescript
396
- * import { defineContainer, defineWorker, exports } from "@cloudflare/config";
397
- *
398
- * const myContainer = defineContainer({
399
- * name: "my-container",
400
- * image: { dockerfile: "./Dockerfile" },
401
- * });
402
- *
403
- * export default defineWorker({
404
- * exports: {
405
- * MyDurableObject: exports.durableObject({ storage: "sqlite" }),
406
- * MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
407
- * OldClass: exports.durableObject({ state: "deleted" }),
408
- * OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
409
- * Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
410
- * Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
411
- * },
412
- * });
413
- * ```
414
- */
415
- declare const exports: Exports;
416
- //#endregion
417
372
  //#region src/triggers.d.ts
418
373
  interface FetchTriggerOptions {
419
374
  /**
@@ -562,23 +517,47 @@ interface Triggers {
562
517
  *
563
518
  * @example
564
519
  * ```typescript
565
- * import { defineWorker, triggers } from "@cloudflare/config";
520
+ * import { defineConfig, triggers } from "@cloudflare/config";
566
521
  *
567
- * export default defineWorker({
568
- * triggers: [
569
- * triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
570
- * triggers.queue({ name: "my-queue" }),
571
- * triggers.scheduled({ schedule: "0 * * * *" }),
572
- * triggers.scheduled({ schedule: "30 0 * * *" }),
573
- * triggers.email({ addresses: ["support@example.com"] }),
574
- * triggers.connect({ protocol: "tcp", port: 5432 }),
575
- * ],
522
+ * export default defineConfig({
523
+ * worker: {
524
+ * name: "my-worker",
525
+ * compatibilityDate: "2026-09-17",
526
+ * triggers: [
527
+ * triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
528
+ * triggers.queue({ name: "my-queue" }),
529
+ * triggers.scheduled({ schedule: "0 * * * *" }),
530
+ * triggers.scheduled({ schedule: "30 0 * * *" }),
531
+ * triggers.email({ addresses: ["support@example.com"] }),
532
+ * triggers.connect({ protocol: "tcp", port: 5432 }),
533
+ * ],
534
+ * },
576
535
  * });
577
536
  * ```
578
537
  */
579
538
  declare const triggers: Triggers;
580
539
  //#endregion
581
540
  //#region src/types.d.ts
541
+ /** Account-level values shared by the resources in a configuration. */
542
+ interface Settings {
543
+ /**
544
+ * This is the ID of the account associated with your zone. It can also be
545
+ * specified through the `CLOUDFLARE_ACCOUNT_ID` environment variable.
546
+ */
547
+ accountId?: string;
548
+ /**
549
+ * The compliance boundary in which commands should operate. When omitted,
550
+ * this can be supplied through `CLOUDFLARE_COMPLIANCE_REGION`.
551
+ */
552
+ complianceRegion?: "public" | "fedramp-high";
553
+ }
554
+ /** The authored shape of `cloudflare.config.ts`'s default export. */
555
+ interface CloudflareConfig extends Settings {
556
+ /** The Worker defined by this configuration. */
557
+ worker?: ConfigInput<WorkerConfig>;
558
+ /** Container applications defined by this configuration. */
559
+ containers?: ConfigInput<ContainerConfig>[];
560
+ }
582
561
  /**
583
562
  * Union of all binding definitions accepted in `env`.
584
563
  */
@@ -614,15 +593,27 @@ type ContainerImage = {
614
593
  */
615
594
  reference: string;
616
595
  };
596
+ /** Application-wide observability settings shared by all Containers. */
597
+ interface ContainerObservabilityConfig {
598
+ /** Whether observability is enabled. */
599
+ enabled?: boolean;
600
+ logs?: {
601
+ /** Whether log collection is enabled. */
602
+ enabled?: boolean;
603
+ };
604
+ }
605
+ /** Observability settings for a standard Container application. */
606
+ type StandardContainerObservabilityConfig = ContainerObservabilityConfig & ({
607
+ /** Percentage of Container instances targeted for observability. */
608
+ targetInstancePercentage?: number;
609
+ targetInstanceCount?: never;
610
+ } | {
611
+ targetInstancePercentage?: never;
612
+ /** Number of Container instances targeted for observability. */
613
+ targetInstanceCount?: number;
614
+ });
617
615
  /** Fields shared by all Container application configurations. */
618
616
  interface BaseContainerConfig {
619
- /**
620
- * Discriminates this config as a Container config.
621
- *
622
- * Injected automatically by `defineContainer`; only needs to be written by
623
- * hand when authoring a raw config object without the helper.
624
- */
625
- type: "container";
626
617
  /**
627
618
  * Name of the application.
628
619
  *
@@ -630,23 +621,6 @@ interface BaseContainerConfig {
630
621
  * Object's `exports` entry via its `container` field.
631
622
  */
632
623
  name: string;
633
- /** Configures observability for Container instances. */
634
- observability?: {
635
- /** Whether observability is enabled. */
636
- enabled?: boolean;
637
- logs?: {
638
- /** Whether log collection is enabled. */
639
- enabled?: boolean;
640
- };
641
- } & ({
642
- /** Percentage of Container instances targeted for observability. */
643
- targetInstancePercentage?: number;
644
- targetInstanceCount?: never;
645
- } | {
646
- targetInstancePercentage?: never;
647
- /** Number of Container instances targeted for observability. */
648
- targetInstanceCount?: number;
649
- });
650
624
  /**
651
625
  * Passed through without client-side validation or transformation.
652
626
  *
@@ -656,6 +630,8 @@ interface BaseContainerConfig {
656
630
  }
657
631
  /** A Container application managed with a standard scheduling policy. */
658
632
  interface StandardContainerConfig extends BaseContainerConfig {
633
+ /** Configures observability and optional targeting for Container instances. */
634
+ observability?: StandardContainerObservabilityConfig;
659
635
  /** The image to build or deploy. */
660
636
  image: ContainerImage;
661
637
  /**
@@ -760,29 +736,27 @@ interface StandardContainerConfig extends BaseContainerConfig {
760
736
  /** A Container application managed by a Durable Object. */
761
737
  interface DurableObjectContainerConfig extends BaseContainerConfig {
762
738
  schedulingPolicy: "durable-object";
739
+ /**
740
+ * Configures application-wide observability. Instance targeting is not
741
+ * supported for Durable Object-managed Containers.
742
+ */
743
+ observability?: ContainerObservabilityConfig;
763
744
  /** Named images that the Durable Object can start. */
764
745
  images?: Record<string, ContainerImage>;
765
746
  }
766
747
  /**
767
748
  * Container application configuration. This is the input shape passed to
768
- * `defineContainer` and is validated at runtime by `InputContainerSchema`.
749
+ * `defineContainer` and parsed at runtime by `InputContainerSchema`.
769
750
  */
770
751
  type ContainerConfig = DurableObjectContainerConfig | StandardContainerConfig;
771
752
  /**
772
753
  * Worker configuration. This is the input shape passed to
773
754
  * [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
774
755
  *
775
- * Fields are validated at runtime by `InputWorkerSchema` and normalised before
756
+ * Fields are parsed and normalised at runtime by `InputWorkerSchema` before
776
757
  * being passed to downstream tooling.
777
758
  */
778
759
  interface WorkerConfig {
779
- /**
780
- * Discriminates this config as a Worker config.
781
- *
782
- * Injected automatically by `defineWorker`; only needs to be written by
783
- * hand when authoring a raw config object without the helper.
784
- */
785
- type: "worker";
786
760
  /**
787
761
  * The name of your Worker.
788
762
  */
@@ -811,8 +785,10 @@ interface WorkerConfig {
811
785
  *
812
786
  * @example
813
787
  * ```ts
788
+ * import { defineConfig, defineWorker } from "@cloudflare/config";
814
789
  * import * as entrypoint from "./src" with { type: "cf-worker" };
815
- * export default defineWorker({ entrypoint });
790
+ * const worker = defineWorker({ entrypoint });
791
+ * export default defineConfig({ worker });
816
792
  * ```
817
793
  */
818
794
  entrypoint?: string | WorkerModule;
@@ -1038,52 +1014,81 @@ interface WorkerConfig {
1038
1014
  */
1039
1015
  exports?: Record<string, Export>;
1040
1016
  }
1041
- /**
1042
- * Settings shared by the other exports.
1043
- * Authored as a named `settings` export via
1044
- * `defineSettings`.
1045
- */
1046
- interface SettingsConfig {
1047
- /**
1048
- * Discriminates this config as a settings config.
1049
- *
1050
- * Injected automatically by `defineSettings`; only needs to be written by
1051
- * hand when authoring a raw config object without the helper.
1052
- */
1053
- type: "settings";
1054
- /**
1055
- * This is the ID of the account associated with your zone.
1056
- * You might have more than one account, so make sure to use
1057
- * the ID of the account associated with the zone/route you
1058
- * provide, if you provide one. It can also be specified through
1059
- * the CLOUDFLARE_ACCOUNT_ID environment variable.
1060
- */
1061
- accountId?: string;
1017
+ //#endregion
1018
+ //#region src/definition.d.ts
1019
+ interface ConfigContext {
1020
+ /** Whether the config is being evaluated for a Preview build. */
1021
+ isPreview: boolean;
1062
1022
  /**
1063
- * Specify the compliance region mode of the Worker.
1064
- *
1065
- * Although if the user does not specify a compliance region, the default is `public`,
1066
- * it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
1023
+ * The mode the config is being evaluated in.
1024
+ * Set via the `--mode` CLI flag.
1025
+ * 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)).
1026
+ * In Wrangler the mode defaults to `undefined`.
1067
1027
  */
1068
- complianceRegion?: "public" | "fedramp-high";
1028
+ mode: string | undefined;
1069
1029
  }
1030
+ /**
1031
+ * A configuration value, promise, or factory. Factories can be passed directly
1032
+ * for automatic resolution with the current context or called explicitly with
1033
+ * another context before they are used.
1034
+ */
1035
+ type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
1036
+ type ContainerDefinition<T$1 extends ContainerConfig = ContainerConfig> = ConfigInput<T$1>;
1037
+ type WorkerDefinition<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
1038
+ /** A Worker name, value, promise, or context-aware factory. */
1039
+ type WorkerReference = string | WorkerDefinition;
1040
+ /**
1041
+ * Used to define the default export in `cloudflare.config.ts`.
1042
+ *
1043
+ * @example
1044
+ * ```typescript
1045
+ * import { defineConfig } from "@cloudflare/config";
1046
+ *
1047
+ * export default defineConfig({
1048
+ * worker: {
1049
+ * name: "my-worker",
1050
+ * compatibilityDate: "2026-09-17",
1051
+ * },
1052
+ * });
1053
+ * ```
1054
+ */
1055
+ declare const defineConfig: <const TInput extends ConfigInput<CloudflareConfig>>(config: TInput) => TInput;
1056
+ /**
1057
+ * Define a Container.
1058
+ *
1059
+ * @example
1060
+ * ```typescript
1061
+ * import { defineContainer } from "@cloudflare/config";
1062
+ *
1063
+ * const container = defineContainer({
1064
+ * name: "my-container",
1065
+ * image: { dockerfile: "./Dockerfile" },
1066
+ * });
1067
+ * ```
1068
+ */
1069
+ declare const defineContainer: <const TInput extends ConfigInput<ContainerConfig>>(config: TInput) => TInput;
1070
+ /**
1071
+ * Define a Worker.
1072
+ *
1073
+ * @example
1074
+ * ```typescript
1075
+ * import { defineWorker } from "@cloudflare/config";
1076
+ *
1077
+ * const worker = defineWorker({
1078
+ * name: "my-worker",
1079
+ * compatibilityDate: "2026-09-17",
1080
+ * });
1081
+ * ```
1082
+ */
1083
+ declare const defineWorker: <const TInput extends ConfigInput<WorkerConfig>>(config: TInput) => TInput;
1070
1084
  //#endregion
1071
- //#region src/worker-definition.d.ts
1072
- type WorkerConfigExport<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
1073
- /**
1074
- * Authored Worker config shape — {@link WorkerConfig} without the `type`
1075
- * discriminant, which `defineWorker` injects.
1076
- */
1077
- type WorkerConfigInput = Omit<WorkerConfig, "type">;
1078
- declare const defineWorker: <const TInput extends ConfigInput<WorkerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
1079
- [x: string]: unknown;
1080
- }> ? Promise<ConfigWithType<TConfig, "worker">> : TResult extends {
1081
- [x: string]: unknown;
1082
- } ? ConfigWithType<TResult, "worker"> : never : TInput extends Promise<infer TConfig extends {
1083
- [x: string]: unknown;
1084
- }> ? Promise<ConfigWithType<TConfig, "worker">> : TInput extends {
1085
- [x: string]: unknown;
1086
- } ? ConfigWithType<TInput, "worker"> : never;
1085
+ //#region src/utils.d.ts
1086
+ /**
1087
+ * Represents any valid JSON value.
1088
+ */
1089
+ type Json = string | number | boolean | null | Json[] | {
1090
+ [key: string]: Json;
1091
+ };
1087
1092
  //#endregion
1088
1093
  //#region src/bindings.d.ts
1089
1094
  /** Options that control a binding during local development. */
@@ -1233,7 +1238,6 @@ interface DispatchNamespaceBindingOptions {
1233
1238
  interface DispatchNamespaceBinding extends DispatchNamespaceBindingOptions {
1234
1239
  type: "dispatch-namespace";
1235
1240
  }
1236
- type WorkerReference = string | WorkerConfigExport;
1237
1241
  type ReferencedWorkerConfig<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? never : UnwrapConfig<TWorker$1>;
1238
1242
  type DurableObjectExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferDurableNamespaces<ReferencedWorkerConfig<TWorker$1>>;
1239
1243
  type WorkerEntrypointExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferWorkerEntrypointExports<ReferencedWorkerConfig<TWorker$1>>;
@@ -1771,25 +1775,4 @@ interface Bindings {
1771
1775
  }
1772
1776
  declare const bindings: Bindings;
1773
1777
  //#endregion
1774
- //#region src/settings-definition.d.ts
1775
- type SettingsConfigExport<T$1 extends SettingsConfig = SettingsConfig> = ConfigInput<T$1>;
1776
- /**
1777
- * Authored settings config shape — {@link SettingsConfig} without the `type`
1778
- * discriminant, which `defineSettings` injects.
1779
- */
1780
- type SettingsConfigInput = Omit<SettingsConfig, "type">;
1781
- /**
1782
- * Declare shared settings.
1783
- * Authored as a named `settings` export.
1784
- */
1785
- declare const defineSettings: <const TInput extends ConfigInput<SettingsConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
1786
- [x: string]: unknown;
1787
- }> ? Promise<ConfigWithType<TConfig, "settings">> : TResult extends {
1788
- [x: string]: unknown;
1789
- } ? ConfigWithType<TResult, "settings"> : never : TInput extends Promise<infer TConfig extends {
1790
- [x: string]: unknown;
1791
- }> ? Promise<ConfigWithType<TConfig, "settings">> : TInput extends {
1792
- [x: string]: unknown;
1793
- } ? ConfigWithType<TInput, "settings"> : never;
1794
- //#endregion
1795
- export { WorkerConfig as $, SecretsStoreSecretBinding as A, VersionMetadataBinding as B, MediaBinding$1 as C, UnwrapConfig as Ct, R2Binding as D, QueueBinding as E, TypedKvBinding as F, WorkerReference as G, VpcServiceBinding as H, TypedPipelineBinding as I, WorkerConfigExport as J, WorkflowBinding as K, TypedQueueBinding as L, StreamBinding$1 as M, TextBinding as N, RateLimitBinding as O, TypedAiBinding as P, SettingsConfig as Q, UnsafeBinding as R, LogfwdrBinding as S, InferMainModule as St, PipelineBinding as T, WorkerBinding as U, VpcNetworkBinding as V, WorkerLoaderBinding as W, defineWorker as X, WorkerConfigInput as Y, ContainerConfig as Z, FlagshipBinding as _, ContainerConfigInput as _t, AiBinding as a, Triggers as at, JsonBinding as b, InferDurableNamespaces as bt, AnalyticsEngineDatasetBinding as c, DurableObjectDeletedExport as ct, BindingDevOptions as d, DurableObjectTransferredExport as dt, ConnectTrigger as et, Bindings as f, Exports as ft, DurableObjectBinding as g, ContainerConfigExport as gt, DispatchNamespaceBinding as h, exports as ht, AgentMemoryBinding as i, ScheduledTrigger as it, SendEmailBinding as j, SecretBinding as k, ArtifactsBinding as l, DurableObjectExpectingTransferExport as lt, D1Binding as m, WorkerEntrypointExportOptions as mt, SettingsConfigInput as n, FetchTrigger as nt, AiSearchBinding as o, triggers as ot, BrowserBinding as p, WorkerEntrypointExport as pt, bindings as q, defineSettings as r, QueueConsumerTrigger as rt, AiSearchNamespaceBinding as s, DurableObjectCreatedExport as st, SettingsConfigExport as t, EmailTrigger as tt, AssetsBinding as u, DurableObjectRenamedExport as ut, HyperdriveBinding as v, defineContainer as vt, MtlsCertificateBinding as w, KvBinding as x, InferEnv as xt, ImagesBinding$1 as y, ConfigContext as yt, VectorizeBinding as z };
1778
+ export { Settings as $, TextBinding as A, WorkerBinding as B, QueueBinding as C, SecretsStoreSecretBinding as D, SecretBinding as E, UnsafeBinding as F, ContainerDefinition as G, WorkflowBinding as H, VectorizeBinding as I, defineConfig as J, WorkerDefinition as K, VersionMetadataBinding as L, TypedKvBinding as M, TypedPipelineBinding as N, SendEmailBinding as O, TypedQueueBinding as P, ContainerConfig as Q, VpcNetworkBinding as R, PipelineBinding as S, RateLimitBinding as T, bindings as U, WorkerLoaderBinding as V, ConfigContext as W, defineWorker as X, defineContainer as Y, CloudflareConfig as Z, JsonBinding as _, Exports as _t, AnalyticsEngineDatasetBinding as a, ScheduledTrigger as at, MediaBinding$1 as b, exports as bt, BindingDevOptions as c, InferDurableNamespaces as ct, D1Binding as d, UnwrapConfig as dt, WorkerConfig as et, DispatchNamespaceBinding as f, DurableObjectCreatedExport as ft, ImagesBinding$1 as g, DurableObjectTransferredExport as gt, HyperdriveBinding as h, DurableObjectRenamedExport as ht, AiSearchNamespaceBinding as i, QueueConsumerTrigger as it, TypedAiBinding as j, StreamBinding$1 as k, Bindings as l, InferEnv as lt, FlagshipBinding as m, DurableObjectExpectingTransferExport as mt, AiBinding as n, EmailTrigger as nt, ArtifactsBinding as o, Triggers as ot, DurableObjectBinding as p, DurableObjectDeletedExport as pt, WorkerReference as q, AiSearchBinding as r, FetchTrigger as rt, AssetsBinding as s, triggers as st, AgentMemoryBinding as t, ConnectTrigger as tt, BrowserBinding as u, InferMainModule as ut, KvBinding as v, WorkerEntrypointExport as vt, R2Binding as w, MtlsCertificateBinding as x, LogfwdrBinding as y, WorkerEntrypointExportOptions as yt, VpcServiceBinding as z };