@cloudflare/config 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as TextBinding, A as ArtifactsBinding, B as JsonBinding, C as Triggers, D as AiSearchBinding, E as AiBinding, F as DispatchNamespaceBinding, G as PipelineBinding, H as LogfwdrBinding, I as DurableObjectBinding, J as RateLimitBinding, K as QueueBinding, L as FlagshipBinding, M as Bindings, N as BrowserBinding, O as AiSearchNamespaceBinding, P as D1Binding, Q as StreamBinding, R as HyperdriveBinding, S as ScheduledTrigger, T as AgentMemoryBinding, U as MediaBinding, V as KvBinding, W as MtlsCertificateBinding, X as SecretsStoreSecretBinding, Y as SecretBinding, Z as SendEmailBinding, _ as WorkerEntrypointExport, a as ConfigContext, at as TypedWorkerBinding, b as FetchTrigger, c as defineWorker, ct as VectorizeBinding, d as DurableObjectCreatedExport, dt as VpcServiceBinding, et as TypedAiBinding, f as DurableObjectDeletedExport, ft as WebSearchBinding, g as Exports, gt as bindings, h as DurableObjectTransferredExport, ht as WorkflowBinding, i as UnwrapConfig, it as TypedQueueBinding, j as AssetsBinding, k as AnalyticsEngineDatasetBinding, l as resolveWorkerDefinition, lt as VersionMetadataBinding, m as DurableObjectRenamedExport, mt as WorkerLoaderBinding, n as InferEnv, nt as TypedKvBinding, o as TypedWorkerDefinition, ot as TypedWorkflowBinding, p as DurableObjectExpectingTransferExport, pt as WorkerBinding, q as R2Binding, r as InferMainModule, rt as TypedPipelineBinding, s as UserConfigExport, st as UnsafeBinding, t as InferDurableNamespaces, tt as TypedDurableObjectBinding, u as UserConfig, ut as VpcNetworkBinding, v as WorkerEntrypointExportOptions, w as triggers, x as QueueConsumerTrigger, y as exports, z as ImagesBinding } from "./public-YTdTOrcv.mjs";
1
+ import { $ as RateLimitBinding, A as AgentMemoryBinding, B as DispatchNamespaceBinding, C as exports, D as ScheduledTrigger, E as QueueConsumerTrigger, F as ArtifactsBinding, G as JsonBinding, H as FlagshipBinding, I as AssetsBinding, J as MediaBinding, K as KvBinding, L as Bindings, M as AiSearchBinding, N as AiSearchNamespaceBinding, O as Triggers, P as AnalyticsEngineDatasetBinding, Q as R2Binding, R as BrowserBinding, S as WorkerEntrypointExportOptions, T as FetchTrigger, U as HyperdriveBinding, V as DurableObjectBinding, W as ImagesBinding, X as PipelineBinding, Y as MtlsCertificateBinding, Z as QueueBinding, _ as DurableObjectExpectingTransferExport, _t as WebSearchBinding, a as InferMainModule, at as TypedAiBinding, b as Exports, bt as WorkflowBinding, c as WorkerConfigExport, ct as TypedPipelineBinding, d as SettingsConfig, dt as TypedWorkflowBinding, et as SecretBinding, f as WorkerConfig, ft as UnsafeBinding, g as DurableObjectDeletedExport, gt as VpcServiceBinding, h as DurableObjectCreatedExport, ht as VpcNetworkBinding, i as InferEnv, it as TextBinding, j as AiBinding, k as triggers, l as WorkerConfigInput, lt as TypedQueueBinding, m as resolveExportDefinition, mt as VersionMetadataBinding, n as defineSettings, nt as SendEmailBinding, o as UnwrapConfig, ot as TypedDurableObjectBinding, p as ConfigContext, pt as VectorizeBinding, q as LogfwdrBinding, r as InferDurableNamespaces, rt as StreamBinding, s as TypedWorkerDefinition, st as TypedKvBinding, t as SettingsConfigInput, tt as SecretsStoreSecretBinding, u as defineWorker, ut as TypedWorkerBinding, v as DurableObjectRenamedExport, vt as WorkerBinding, w as EmailTrigger, x as WorkerEntrypointExport, xt as bindings, y as DurableObjectTransferredExport, yt as WorkerLoaderBinding, z as D1Binding } from "./public-myuV_kLK.mjs";
2
2
  import * as z from "zod";
3
3
  import { RawConfig } from "@cloudflare/workers-utils";
4
4
 
@@ -37,7 +37,7 @@ declare const KnownBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
37
37
  remote: z.ZodOptional<z.ZodBoolean>;
38
38
  }, z.core.$strict>, z.ZodObject<{
39
39
  type: z.ZodLiteral<"dispatch-namespace">;
40
- namespace: z.ZodString;
40
+ namespace: z.ZodOptional<z.ZodString>;
41
41
  outbound: z.ZodOptional<z.ZodObject<{
42
42
  workerName: z.ZodString;
43
43
  parameters: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -49,7 +49,7 @@ declare const KnownBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
49
49
  exportName: z.ZodString;
50
50
  }, z.core.$strict>, z.ZodObject<{
51
51
  type: z.ZodLiteral<"flagship">;
52
- id: z.ZodString;
52
+ id: z.ZodOptional<z.ZodString>;
53
53
  remote: z.ZodOptional<z.ZodBoolean>;
54
54
  }, z.core.$strict>, z.ZodObject<{
55
55
  type: z.ZodLiteral<"hyperdrive">;
@@ -81,7 +81,7 @@ declare const KnownBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
81
81
  remote: z.ZodOptional<z.ZodBoolean>;
82
82
  }, z.core.$strict>, z.ZodObject<{
83
83
  type: z.ZodLiteral<"queue">;
84
- name: z.ZodString;
84
+ name: z.ZodOptional<z.ZodString>;
85
85
  deliveryDelay: z.ZodOptional<z.ZodNumber>;
86
86
  remote: z.ZodOptional<z.ZodBoolean>;
87
87
  }, z.core.$strict>, z.ZodObject<{
@@ -159,8 +159,8 @@ type BindingOutput = z.output<typeof KnownBindingSchema> | z.output<typeof Unsaf
159
159
  * base schema.
160
160
  */
161
161
  declare const InputWorkerSchema: z.ZodObject<{
162
+ type: z.ZodLiteral<"worker">;
162
163
  name: z.ZodString;
163
- accountId: z.ZodOptional<z.ZodString>;
164
164
  compatibilityDate: z.ZodString;
165
165
  compatibilityFlags: z.ZodOptional<z.ZodArray<z.ZodString>>;
166
166
  assets: z.ZodOptional<z.ZodObject<{
@@ -179,6 +179,9 @@ declare const InputWorkerSchema: z.ZodObject<{
179
179
  }, z.core.$strict>>;
180
180
  domains: z.ZodOptional<z.ZodArray<z.ZodString>>;
181
181
  triggers: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
182
+ type: z.ZodLiteral<"email">;
183
+ addresses: z.ZodArray<z.ZodString>;
184
+ }, z.core.$strict>, z.ZodObject<{
182
185
  type: z.ZodLiteral<"fetch">;
183
186
  pattern: z.ZodString;
184
187
  zone: z.ZodOptional<z.ZodString>;
@@ -244,10 +247,168 @@ declare const InputWorkerSchema: z.ZodObject<{
244
247
  }, z.core.$strict>>;
245
248
  workersDev: z.ZodOptional<z.ZodBoolean>;
246
249
  previewUrls: z.ZodOptional<z.ZodBoolean>;
250
+ firstPartyWorker: z.ZodOptional<z.ZodBoolean>;
251
+ unsafe: z.ZodOptional<z.ZodObject<{
252
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
253
+ capnp: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
254
+ basePath: z.ZodString;
255
+ sourceSchemas: z.ZodArray<z.ZodString>;
256
+ compiledSchema: z.ZodOptional<z.ZodNever>;
257
+ }, z.core.$strict>, z.ZodObject<{
258
+ basePath: z.ZodOptional<z.ZodNever>;
259
+ sourceSchemas: z.ZodOptional<z.ZodNever>;
260
+ compiledSchema: z.ZodString;
261
+ }, z.core.$strict>]>>;
262
+ }, z.core.$strict>>;
263
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<BindingOutput, BindingInput, z.core.$ZodTypeInternals<BindingOutput, BindingInput>>>>;
264
+ exports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
265
+ type: z.ZodLiteral<"durable-object">;
266
+ state: z.ZodOptional<z.ZodLiteral<"created">>;
267
+ storage: z.ZodEnum<{
268
+ sqlite: "sqlite";
269
+ "legacy-kv": "legacy-kv";
270
+ }>;
271
+ }, z.core.$strict>, z.ZodObject<{
272
+ type: z.ZodLiteral<"durable-object">;
273
+ state: z.ZodLiteral<"deleted">;
274
+ }, z.core.$strict>, z.ZodObject<{
275
+ type: z.ZodLiteral<"durable-object">;
276
+ state: z.ZodLiteral<"renamed">;
277
+ renamedTo: z.ZodString;
278
+ }, z.core.$strict>, z.ZodObject<{
279
+ type: z.ZodLiteral<"durable-object">;
280
+ state: z.ZodLiteral<"transferred">;
281
+ transferredTo: z.ZodString;
282
+ }, z.core.$strict>, z.ZodObject<{
283
+ type: z.ZodLiteral<"durable-object">;
284
+ state: z.ZodLiteral<"expecting-transfer">;
285
+ storage: z.ZodEnum<{
286
+ sqlite: "sqlite";
287
+ "legacy-kv": "legacy-kv";
288
+ }>;
289
+ transferFrom: z.ZodString;
290
+ }, z.core.$strict>, z.ZodObject<{
291
+ type: z.ZodLiteral<"worker">;
292
+ cache: z.ZodOptional<z.ZodObject<{
293
+ enabled: z.ZodBoolean;
294
+ }, z.core.$strict>>;
295
+ }, z.core.$strict>]>>>;
296
+ entrypoint: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
297
+ default: z.ZodString;
298
+ }, z.core.$strict>]>, z.ZodTransform<string, string | {
299
+ default: string;
300
+ }>>>;
301
+ }, z.core.$strict>;
302
+ type ParsedInputWorkerConfig = z.output<typeof InputWorkerSchema>;
303
+ /**
304
+ * Settings schema — validates the named `settings` export of a
305
+ * `cloudflare.config.ts`. Holds account/deployment settings shared by the other exports.
306
+ */
307
+ declare const SettingsSchema: z.ZodObject<{
308
+ type: z.ZodLiteral<"settings">;
309
+ accountId: z.ZodOptional<z.ZodString>;
247
310
  complianceRegion: z.ZodOptional<z.ZodEnum<{
248
311
  public: "public";
249
312
  "fedramp-high": "fedramp-high";
250
313
  }>>;
314
+ }, z.core.$strict>;
315
+ type ParsedSettingsConfig = z.output<typeof SettingsSchema>;
316
+ /**
317
+ * Schema for the resolved config exports, keyed by export
318
+ * name. Each value is discriminated on its `type` field. Reserves the
319
+ * `settings` export name exclusively for settings configs: a `settings`
320
+ * config must live on the `settings` export, and the `settings` export
321
+ * may only hold a `settings` config.
322
+ */
323
+ declare const ConfigExportsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
324
+ type: z.ZodLiteral<"worker">;
325
+ name: z.ZodString;
326
+ compatibilityDate: z.ZodString;
327
+ compatibilityFlags: z.ZodOptional<z.ZodArray<z.ZodString>>;
328
+ assets: z.ZodOptional<z.ZodObject<{
329
+ htmlHandling: z.ZodOptional<z.ZodEnum<{
330
+ "auto-trailing-slash": "auto-trailing-slash";
331
+ "drop-trailing-slash": "drop-trailing-slash";
332
+ "force-trailing-slash": "force-trailing-slash";
333
+ none: "none";
334
+ }>>;
335
+ notFoundHandling: z.ZodOptional<z.ZodEnum<{
336
+ none: "none";
337
+ "single-page-application": "single-page-application";
338
+ "404-page": "404-page";
339
+ }>>;
340
+ runWorkerFirst: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodBoolean]>>;
341
+ }, z.core.$strict>>;
342
+ domains: z.ZodOptional<z.ZodArray<z.ZodString>>;
343
+ triggers: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
344
+ type: z.ZodLiteral<"email">;
345
+ addresses: z.ZodArray<z.ZodString>;
346
+ }, z.core.$strict>, z.ZodObject<{
347
+ type: z.ZodLiteral<"fetch">;
348
+ pattern: z.ZodString;
349
+ zone: z.ZodOptional<z.ZodString>;
350
+ }, z.core.$strict>, z.ZodObject<{
351
+ type: z.ZodLiteral<"queue">;
352
+ name: z.ZodString;
353
+ deadLetterQueue: z.ZodOptional<z.ZodString>;
354
+ maxBatchSize: z.ZodOptional<z.ZodNumber>;
355
+ maxBatchTimeout: z.ZodOptional<z.ZodNumber>;
356
+ maxConcurrency: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
357
+ maxRetries: z.ZodOptional<z.ZodNumber>;
358
+ retryDelay: z.ZodOptional<z.ZodNumber>;
359
+ visibilityTimeoutMs: z.ZodOptional<z.ZodNumber>;
360
+ }, z.core.$strict>, z.ZodObject<{
361
+ type: z.ZodLiteral<"scheduled">;
362
+ schedule: z.ZodString;
363
+ }, z.core.$strict>], "type">>>;
364
+ tailConsumers: z.ZodOptional<z.ZodArray<z.ZodObject<{
365
+ workerName: z.ZodString;
366
+ streaming: z.ZodOptional<z.ZodBoolean>;
367
+ }, z.core.$strict>>>;
368
+ cache: z.ZodOptional<z.ZodObject<{
369
+ enabled: z.ZodBoolean;
370
+ crossVersionCache: z.ZodOptional<z.ZodBoolean>;
371
+ }, z.core.$strict>>;
372
+ placement: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
373
+ mode: z.ZodEnum<{
374
+ off: "off";
375
+ smart: "smart";
376
+ }>;
377
+ hint: z.ZodOptional<z.ZodString>;
378
+ }, z.core.$strict>, z.ZodObject<{
379
+ mode: z.ZodOptional<z.ZodLiteral<"targeted">>;
380
+ region: z.ZodString;
381
+ }, z.core.$strict>, z.ZodObject<{
382
+ mode: z.ZodOptional<z.ZodLiteral<"targeted">>;
383
+ host: z.ZodString;
384
+ }, z.core.$strict>, z.ZodObject<{
385
+ mode: z.ZodOptional<z.ZodLiteral<"targeted">>;
386
+ hostname: z.ZodString;
387
+ }, z.core.$strict>]>>;
388
+ limits: z.ZodOptional<z.ZodObject<{
389
+ cpuMs: z.ZodOptional<z.ZodNumber>;
390
+ subrequests: z.ZodOptional<z.ZodNumber>;
391
+ }, z.core.$strict>>;
392
+ logpush: z.ZodOptional<z.ZodBoolean>;
393
+ observability: z.ZodOptional<z.ZodObject<{
394
+ enabled: z.ZodOptional<z.ZodBoolean>;
395
+ headSamplingRate: z.ZodOptional<z.ZodNumber>;
396
+ logs: z.ZodOptional<z.ZodObject<{
397
+ enabled: z.ZodOptional<z.ZodBoolean>;
398
+ headSamplingRate: z.ZodOptional<z.ZodNumber>;
399
+ invocationLogs: z.ZodOptional<z.ZodBoolean>;
400
+ persist: z.ZodOptional<z.ZodBoolean>;
401
+ destinations: z.ZodOptional<z.ZodArray<z.ZodString>>;
402
+ }, z.core.$strict>>;
403
+ traces: z.ZodOptional<z.ZodObject<{
404
+ enabled: z.ZodOptional<z.ZodBoolean>;
405
+ headSamplingRate: z.ZodOptional<z.ZodNumber>;
406
+ persist: z.ZodOptional<z.ZodBoolean>;
407
+ destinations: z.ZodOptional<z.ZodArray<z.ZodString>>;
408
+ }, z.core.$strict>>;
409
+ }, z.core.$strict>>;
410
+ workersDev: z.ZodOptional<z.ZodBoolean>;
411
+ previewUrls: z.ZodOptional<z.ZodBoolean>;
251
412
  firstPartyWorker: z.ZodOptional<z.ZodBoolean>;
252
413
  unsafe: z.ZodOptional<z.ZodObject<{
253
414
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -299,8 +460,15 @@ declare const InputWorkerSchema: z.ZodObject<{
299
460
  }, z.core.$strict>]>, z.ZodTransform<string, string | {
300
461
  default: string;
301
462
  }>>>;
302
- }, z.core.$strict>;
303
- type ParsedInputWorkerConfig = z.output<typeof InputWorkerSchema>;
463
+ }, z.core.$strict>, z.ZodObject<{
464
+ type: z.ZodLiteral<"settings">;
465
+ accountId: z.ZodOptional<z.ZodString>;
466
+ complianceRegion: z.ZodOptional<z.ZodEnum<{
467
+ public: "public";
468
+ "fedramp-high": "fedramp-high";
469
+ }>>;
470
+ }, z.core.$strict>], "type">>;
471
+ type ParsedConfigExports = z.output<typeof ConfigExportsSchema>;
304
472
  declare const ModuleTypeSchema: z.ZodEnum<{
305
473
  json: "json";
306
474
  text: "text";
@@ -319,8 +487,8 @@ type ModuleType = z.output<typeof ModuleTypeSchema>;
319
487
  * base schema.
320
488
  */
321
489
  declare const OutputWorkerSchema: z.ZodObject<{
490
+ type: z.ZodLiteral<"worker">;
322
491
  name: z.ZodString;
323
- accountId: z.ZodOptional<z.ZodString>;
324
492
  compatibilityDate: z.ZodString;
325
493
  compatibilityFlags: z.ZodOptional<z.ZodArray<z.ZodString>>;
326
494
  assets: z.ZodOptional<z.ZodObject<{
@@ -339,6 +507,9 @@ declare const OutputWorkerSchema: z.ZodObject<{
339
507
  }, z.core.$strict>>;
340
508
  domains: z.ZodOptional<z.ZodArray<z.ZodString>>;
341
509
  triggers: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
510
+ type: z.ZodLiteral<"email">;
511
+ addresses: z.ZodArray<z.ZodString>;
512
+ }, z.core.$strict>, z.ZodObject<{
342
513
  type: z.ZodLiteral<"fetch">;
343
514
  pattern: z.ZodString;
344
515
  zone: z.ZodOptional<z.ZodString>;
@@ -404,10 +575,6 @@ declare const OutputWorkerSchema: z.ZodObject<{
404
575
  }, z.core.$strict>>;
405
576
  workersDev: z.ZodOptional<z.ZodBoolean>;
406
577
  previewUrls: z.ZodOptional<z.ZodBoolean>;
407
- complianceRegion: z.ZodOptional<z.ZodEnum<{
408
- public: "public";
409
- "fedramp-high": "fedramp-high";
410
- }>>;
411
578
  firstPartyWorker: z.ZodOptional<z.ZodBoolean>;
412
579
  unsafe: z.ZodOptional<z.ZodObject<{
413
580
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -484,10 +651,18 @@ declare const BUILD_OUTPUT_VERSION = "v0";
484
651
  * Project-relative root.
485
652
  */
486
653
  declare const BUILD_OUTPUT_ROOT = ".cloudflare/output";
654
+ /**
655
+ * Filename of the top-level (root) config holding shared settings.
656
+ */
657
+ declare const ROOT_CONFIG_FILENAME = "config.json";
487
658
  /**
488
659
  * Filename of the per-Worker config.
489
660
  */
490
661
  declare const WORKER_CONFIG_FILENAME = "worker.config.json";
662
+ /**
663
+ * Absolute path to the top-level `config.json` for the current project.
664
+ */
665
+ declare function getRootConfigPath(root: string): string;
491
666
  /**
492
667
  * Clean the build output directory.
493
668
  */
@@ -516,6 +691,11 @@ declare function getWorkerAssetsDir(root: string, workerName: string): string;
516
691
  * - Assets-only mode: `manifest` is omitted (no bundle/ directory).
517
692
  */
518
693
  declare function writeOutputWorkerConfig(root: string, parsedConfig: ParsedInputWorkerConfig, manifest?: ParsedOutputWorkerConfig["manifest"]): Promise<void>;
694
+ /**
695
+ * Write the top-level `config.json` holding shared settings to the Build
696
+ * Output API tree.
697
+ */
698
+ declare function writeRootOutputConfig(root: string, settings: ParsedSettingsConfig): Promise<void>;
519
699
  //#endregion
520
700
  //#region src/generate.d.ts
521
701
  interface GenerateTypesOptions {
@@ -559,10 +739,12 @@ declare function generateTypes({
559
739
  * The caller is responsible for unwrapping any function/promise wrapper around
560
740
  * the config and validating it against `InputWorkerSchema` before passing it in.
561
741
  *
562
- * @param config The parsed (post-validation) config.
742
+ * @param workerConfig The parsed (post-validation) Worker config.
743
+ * @param settingsConfig The optional parsed settings config, whose fields
744
+ * are merged onto the result.
563
745
  * @returns The corresponding Wrangler `RawConfig`.
564
746
  */
565
- declare function convertToWranglerConfig(config: ParsedInputWorkerConfig): RawConfig;
747
+ declare function convertToWranglerConfig(workerConfig: ParsedInputWorkerConfig, settingsConfig?: ParsedSettingsConfig): RawConfig;
566
748
  //#endregion
567
749
  //#region src/load.d.ts
568
750
  /**
@@ -577,18 +759,26 @@ declare function convertToWranglerConfig(config: ParsedInputWorkerConfig): RawCo
577
759
  /**
578
760
  * Dynamically import a worker config file from disk.
579
761
  *
580
- * Returns the module's default export, plus the set of file paths
581
- * imported during resolution. Callers are responsible for unwrapping
582
- * function/promise wrappers around the returned value and validating it
583
- * against `InputWorkerSchema`.
762
+ * Returns all of the module's exports (keyed by export name, including
763
+ * `default`), plus the set of file paths imported during resolution. Callers
764
+ * are responsible for unwrapping function/promise/definition wrappers around
765
+ * each export and validating them.
584
766
  *
585
767
  * @param configPath Filesystem path to the config file. Relative paths are
586
768
  * resolved against `process.cwd()`.
769
+ * @param options.include When provided, only exports whose names are listed
770
+ * survive into the returned `exports` map. Filtering happens before any
771
+ * resolution or validation.
587
772
  */
588
- declare function loadConfig(configPath: string): Promise<LoadConfigResult>;
773
+ declare function loadConfig(configPath: string, options?: {
774
+ include?: string[];
775
+ }): Promise<LoadConfigResult>;
589
776
  interface LoadConfigResult {
590
- /** The default export of the config module */
591
- config: unknown;
777
+ /**
778
+ * All exports of the config module, keyed by export name (including
779
+ * `default`). Filtered by `options.include` when provided.
780
+ */
781
+ exports: Record<string, unknown>;
592
782
  /**
593
783
  * Absolute file paths imported while resolving the config.
594
784
  * `cf-worker` entrypoints are NOT included — they are
@@ -617,4 +807,21 @@ interface LoadConfigResult {
617
807
  */
618
808
  declare function registerConfigHooks(): () => void;
619
809
  //#endregion
620
- export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BUILD_OUTPUT_ROOT, BUILD_OUTPUT_VERSION, Bindings, BrowserBinding, ConfigContext, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, InputWorkerSchema, JsonBinding, KvBinding, type LoadConfigResult, LogfwdrBinding, MediaBinding, type ModuleType, ModuleTypeSchema, MtlsCertificateBinding, OutputWorkerSchema, type ParsedInputWorkerConfig, type ParsedOutputWorkerConfig, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, UserConfig, UserConfigExport, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WORKER_CONFIG_FILENAME, WebSearchBinding, WorkerBinding, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkflowBinding, bindings, cleanBuildOutputDir, convertToWranglerConfig, defineWorker, exports, generateTypes, getWorkerAssetsDir, getWorkerBundleDir, getWorkerConfigPath, getWorkersDir, loadConfig, registerConfigHooks, resolveWorkerDefinition, triggers, writeOutputWorkerConfig };
810
+ //#region src/config-loader.d.ts
811
+ interface LoadAndValidateConfigResult {
812
+ /**
813
+ * Zod result for the validated exports record, keyed by JS export name.
814
+ * Consumers format `result.error` themselves.
815
+ */
816
+ result: z.ZodSafeParseResult<ParsedConfigExports>;
817
+ /** Transitive deps imported while resolving the config (node_modules excluded). */
818
+ dependencies: Set<string>;
819
+ }
820
+ /**
821
+ * Load a `cloudflare.config.ts`, resolve all exports, and validate against {@link ConfigExportsSchema}.
822
+ */
823
+ declare function loadAndValidateConfig(configPath: string, ctx: ConfigContext, options?: {
824
+ include?: string[];
825
+ }): Promise<LoadAndValidateConfigResult>;
826
+ //#endregion
827
+ export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BUILD_OUTPUT_ROOT, BUILD_OUTPUT_VERSION, Bindings, BrowserBinding, ConfigContext, ConfigExportsSchema, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, InputWorkerSchema, JsonBinding, KvBinding, type LoadAndValidateConfigResult, type LoadConfigResult, LogfwdrBinding, MediaBinding, type ModuleType, ModuleTypeSchema, MtlsCertificateBinding, OutputWorkerSchema, type ParsedConfigExports, type ParsedInputWorkerConfig, type ParsedOutputWorkerConfig, type ParsedSettingsConfig, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, ROOT_CONFIG_FILENAME, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigInput, SettingsSchema, StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WORKER_CONFIG_FILENAME, WebSearchBinding, WorkerBinding, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkflowBinding, bindings, cleanBuildOutputDir, convertToWranglerConfig, defineSettings, defineWorker, exports, generateTypes, getRootConfigPath, getWorkerAssetsDir, getWorkerBundleDir, getWorkerConfigPath, getWorkersDir, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveExportDefinition, triggers, writeOutputWorkerConfig, writeRootOutputConfig };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as bindings, i as triggers, n as resolveWorkerDefinition, r as exports$1, t as defineWorker } from "./public-CFHebTo4.mjs";
1
+ import { a as triggers, i as exports$1, n as defineWorker, o as bindings, r as resolveExportDefinition, t as defineSettings } from "./public-D2QZv1n6.mjs";
2
2
  import * as nodeModule from "node:module";
3
3
  import * as fsp from "node:fs/promises";
4
4
  import * as path from "node:path";
@@ -15,7 +15,7 @@ var __commonJS = (cb, mod) => function() {
15
15
  };
16
16
 
17
17
  //#endregion
18
- //#region ../workers-utils/dist/chunk-DDRU76YD.mjs
18
+ //#region ../workers-utils/dist/chunk-Q72B4Q5Z.mjs
19
19
  var __defProp = Object.defineProperty;
20
20
  var __name = (target, value) => __defProp(target, "name", {
21
21
  value,
@@ -23,7 +23,7 @@ var __name = (target, value) => __defProp(target, "name", {
23
23
  });
24
24
 
25
25
  //#endregion
26
- //#region ../workers-utils/dist/chunk-OC543JY3.mjs
26
+ //#region ../workers-utils/dist/chunk-53IMCORZ.mjs
27
27
  function isDirectory(path$1) {
28
28
  return fs2.statSync(path$1, { throwIfNoEntry: false })?.isDirectory() ?? false;
29
29
  }
@@ -50,7 +50,7 @@ function removeDirSync(dirPath) {
50
50
  __name(removeDirSync, "removeDirSync");
51
51
 
52
52
  //#endregion
53
- //#region ../workers-utils/dist/chunk-XPMIK7N6.mjs
53
+ //#region ../workers-utils/dist/chunk-Y3JVLYM6.mjs
54
54
  function partitionExports(exports$2) {
55
55
  const partitioned = {
56
56
  "durable-object": {},
@@ -2519,6 +2519,10 @@ const BUILD_OUTPUT_VERSION = "v0";
2519
2519
  */
2520
2520
  const BUILD_OUTPUT_ROOT = ".cloudflare/output";
2521
2521
  /**
2522
+ * Filename of the top-level (root) config holding shared settings.
2523
+ */
2524
+ const ROOT_CONFIG_FILENAME = "config.json";
2525
+ /**
2522
2526
  * Filename of the per-Worker config.
2523
2527
  */
2524
2528
  const WORKER_CONFIG_FILENAME = "worker.config.json";
@@ -2529,6 +2533,12 @@ function getBuildOutputDir(root) {
2529
2533
  return path.resolve(root, BUILD_OUTPUT_ROOT);
2530
2534
  }
2531
2535
  /**
2536
+ * Absolute path to the top-level `config.json` for the current project.
2537
+ */
2538
+ function getRootConfigPath(root) {
2539
+ return path.join(getBuildOutputDir(root), BUILD_OUTPUT_VERSION, ROOT_CONFIG_FILENAME);
2540
+ }
2541
+ /**
2532
2542
  * Clean the build output directory.
2533
2543
  */
2534
2544
  async function cleanBuildOutputDir(root) {
@@ -2576,6 +2586,15 @@ async function writeOutputWorkerConfig(root, parsedConfig, manifest) {
2576
2586
  const configPath = getWorkerConfigPath(root, outputConfig.name);
2577
2587
  await fsp.writeFile(configPath, JSON.stringify(outputConfig));
2578
2588
  }
2589
+ /**
2590
+ * Write the top-level `config.json` holding shared settings to the Build
2591
+ * Output API tree.
2592
+ */
2593
+ async function writeRootOutputConfig(root, settings) {
2594
+ const configPath = getRootConfigPath(root);
2595
+ await fsp.mkdir(path.dirname(configPath), { recursive: true });
2596
+ await fsp.writeFile(configPath, JSON.stringify(settings));
2597
+ }
2579
2598
 
2580
2599
  //#endregion
2581
2600
  //#region src/schema.ts
@@ -2635,7 +2654,7 @@ const KnownBindingSchema = z.discriminatedUnion("type", [
2635
2654
  }),
2636
2655
  z.strictObject({
2637
2656
  type: z.literal("dispatch-namespace"),
2638
- namespace: z.string(),
2657
+ namespace: z.string().optional(),
2639
2658
  outbound: z.strictObject({
2640
2659
  workerName: z.string(),
2641
2660
  parameters: z.array(z.string()).optional()
@@ -2649,7 +2668,7 @@ const KnownBindingSchema = z.discriminatedUnion("type", [
2649
2668
  }),
2650
2669
  z.strictObject({
2651
2670
  type: z.literal("flagship"),
2652
- id: z.string(),
2671
+ id: z.string().optional(),
2653
2672
  remote: z.boolean().optional()
2654
2673
  }),
2655
2674
  z.strictObject({
@@ -2690,7 +2709,7 @@ const KnownBindingSchema = z.discriminatedUnion("type", [
2690
2709
  }),
2691
2710
  z.strictObject({
2692
2711
  type: z.literal("queue"),
2693
- name: z.string(),
2712
+ name: z.string().optional(),
2694
2713
  deliveryDelay: z.number().optional(),
2695
2714
  remote: z.boolean().optional()
2696
2715
  }),
@@ -2894,6 +2913,10 @@ const TailConsumerSchema = z.strictObject({
2894
2913
  streaming: z.boolean().optional()
2895
2914
  });
2896
2915
  const TriggerSchema = z.discriminatedUnion("type", [
2916
+ z.strictObject({
2917
+ type: z.literal("email"),
2918
+ addresses: z.array(z.string())
2919
+ }),
2897
2920
  z.strictObject({
2898
2921
  type: z.literal("fetch"),
2899
2922
  pattern: z.string(),
@@ -2932,8 +2955,8 @@ const UnsafeSchema = z.strictObject({
2932
2955
  * (user-authored) and output (on-disk) Worker configs.
2933
2956
  */
2934
2957
  const BaseWorkerSchema = z.strictObject({
2958
+ type: z.literal("worker"),
2935
2959
  name: z.string(),
2936
- accountId: z.string().optional(),
2937
2960
  compatibilityDate: z.string(),
2938
2961
  compatibilityFlags: z.array(z.string()).optional(),
2939
2962
  assets: AssetsSchema.optional(),
@@ -2947,7 +2970,6 @@ const BaseWorkerSchema = z.strictObject({
2947
2970
  observability: ObservabilitySchema.optional(),
2948
2971
  workersDev: z.boolean().optional(),
2949
2972
  previewUrls: z.boolean().optional(),
2950
- complianceRegion: z.enum(["public", "fedramp-high"]).optional(),
2951
2973
  firstPartyWorker: z.boolean().optional(),
2952
2974
  unsafe: UnsafeSchema.optional(),
2953
2975
  env: EnvSchema,
@@ -2959,6 +2981,45 @@ const BaseWorkerSchema = z.strictObject({
2959
2981
  * base schema.
2960
2982
  */
2961
2983
  const InputWorkerSchema = BaseWorkerSchema.extend({ entrypoint: z.union([z.string(), z.strictObject({ default: z.string() })]).transform((value) => typeof value === "string" ? value : value.default).optional() });
2984
+ /**
2985
+ * Settings schema — validates the named `settings` export of a
2986
+ * `cloudflare.config.ts`. Holds account/deployment settings shared by the other exports.
2987
+ */
2988
+ const SettingsSchema = z.strictObject({
2989
+ type: z.literal("settings"),
2990
+ accountId: z.string().optional(),
2991
+ complianceRegion: z.enum(["public", "fedramp-high"]).optional()
2992
+ });
2993
+ /**
2994
+ * Discriminated union of the config kinds a single export may resolve to.
2995
+ */
2996
+ const ConfigExportSchema = z.discriminatedUnion("type", [InputWorkerSchema, SettingsSchema]);
2997
+ const SETTINGS_EXPORT_NAME = "settings";
2998
+ /**
2999
+ * Schema for the resolved config exports, keyed by export
3000
+ * name. Each value is discriminated on its `type` field. Reserves the
3001
+ * `settings` export name exclusively for settings configs: a `settings`
3002
+ * config must live on the `settings` export, and the `settings` export
3003
+ * may only hold a `settings` config.
3004
+ */
3005
+ const ConfigExportsSchema = z.record(z.string(), ConfigExportSchema).check((ctx) => {
3006
+ for (const [key, value] of Object.entries(ctx.value)) {
3007
+ const isSettingsName = key === SETTINGS_EXPORT_NAME;
3008
+ const isSettingsType = value.type === "settings";
3009
+ if (isSettingsType && !isSettingsName) ctx.issues.push({
3010
+ code: "custom",
3011
+ input: value,
3012
+ path: [key],
3013
+ message: `A \`settings\` config is only allowed on the \`${SETTINGS_EXPORT_NAME}\` export; found one on the \`${key}\` export.`
3014
+ });
3015
+ else if (isSettingsName && !isSettingsType) ctx.issues.push({
3016
+ code: "custom",
3017
+ input: value,
3018
+ path: [key],
3019
+ message: `The \`${SETTINGS_EXPORT_NAME}\` export is reserved for a \`settings\` config; found a \`${value.type}\` config.`
3020
+ });
3021
+ }
3022
+ });
2962
3023
  const ModuleTypeSchema = z.enum([
2963
3024
  "esm",
2964
3025
  "cjs",
@@ -3066,29 +3127,38 @@ function generateTypes({ configPath, packageName = "@cloudflare/config" }) {
3066
3127
  * The caller is responsible for unwrapping any function/promise wrapper around
3067
3128
  * the config and validating it against `InputWorkerSchema` before passing it in.
3068
3129
  *
3069
- * @param config The parsed (post-validation) config.
3130
+ * @param workerConfig The parsed (post-validation) Worker config.
3131
+ * @param settingsConfig The optional parsed settings config, whose fields
3132
+ * are merged onto the result.
3070
3133
  * @returns The corresponding Wrangler `RawConfig`.
3071
3134
  */
3072
- function convertToWranglerConfig(config) {
3135
+ function convertToWranglerConfig(workerConfig, settingsConfig) {
3073
3136
  const result = {};
3074
- convertTopLevel(config, result);
3075
- convertBindingsAndAssets(config, result);
3076
- convertExports(config, result);
3077
- convertDomains(config, result);
3078
- convertTriggers(config, result);
3079
- convertTailConsumers(config, result);
3137
+ convertTopLevel(workerConfig, result);
3138
+ convertBindingsAndAssets(workerConfig, result);
3139
+ convertExports(workerConfig, result);
3140
+ convertDomains(workerConfig, result);
3141
+ convertTriggers(workerConfig, result);
3142
+ convertTailConsumers(workerConfig, result);
3143
+ if (settingsConfig !== void 0) convertSettings(settingsConfig, result);
3080
3144
  return result;
3081
3145
  }
3146
+ /**
3147
+ * Merge a parsed settings config's fields (`account_id`, `compliance_region`)
3148
+ * onto an existing Wrangler `RawConfig`.
3149
+ */
3150
+ function convertSettings(settings, result) {
3151
+ if (settings.accountId !== void 0) result.account_id = settings.accountId;
3152
+ if (settings.complianceRegion !== void 0) result.compliance_region = settings.complianceRegion === "fedramp-high" ? "fedramp_high" : "public";
3153
+ }
3082
3154
  function convertTopLevel(config, result) {
3083
3155
  if (config.name !== void 0) result.name = config.name;
3084
3156
  if (typeof config.entrypoint === "string") result.main = config.entrypoint;
3085
- if (config.accountId !== void 0) result.account_id = config.accountId;
3086
3157
  if (config.compatibilityDate !== void 0) result.compatibility_date = config.compatibilityDate;
3087
3158
  if (config.compatibilityFlags !== void 0) result.compatibility_flags = config.compatibilityFlags;
3088
3159
  if (config.workersDev !== void 0) result.workers_dev = config.workersDev;
3089
3160
  if (config.previewUrls !== void 0) result.preview_urls = config.previewUrls;
3090
3161
  if (config.logpush !== void 0) result.logpush = config.logpush;
3091
- if (config.complianceRegion !== void 0) result.compliance_region = config.complianceRegion === "fedramp-high" ? "fedramp_high" : "public";
3092
3162
  if (config.firstPartyWorker !== void 0) result.first_party_worker = config.firstPartyWorker;
3093
3163
  if (config.placement !== void 0) result.placement = config.placement;
3094
3164
  if (config.limits !== void 0) {
@@ -3520,7 +3590,12 @@ function convertTriggers(config, result) {
3520
3590
  const crons = [];
3521
3591
  const routes = result.routes ? [...result.routes] : [];
3522
3592
  const queueConsumers = result.queues?.consumers ? [...result.queues.consumers] : [];
3593
+ let addresses;
3523
3594
  for (const trigger of triggers$1) switch (trigger.type) {
3595
+ case "email":
3596
+ addresses ??= [];
3597
+ addresses.push(...trigger.addresses);
3598
+ break;
3524
3599
  case "scheduled":
3525
3600
  crons.push(trigger.schedule);
3526
3601
  break;
@@ -3554,6 +3629,7 @@ function convertTriggers(config, result) {
3554
3629
  ...result.queues ?? {},
3555
3630
  consumers: queueConsumers
3556
3631
  };
3632
+ if (addresses !== void 0) result.addresses = addresses;
3557
3633
  }
3558
3634
  function convertDomains(config, result) {
3559
3635
  if (!config.domains || config.domains.length === 0) return;
@@ -3605,20 +3681,29 @@ const depsStore = new AsyncLocalStorage();
3605
3681
  /**
3606
3682
  * Dynamically import a worker config file from disk.
3607
3683
  *
3608
- * Returns the module's default export, plus the set of file paths
3609
- * imported during resolution. Callers are responsible for unwrapping
3610
- * function/promise wrappers around the returned value and validating it
3611
- * against `InputWorkerSchema`.
3684
+ * Returns all of the module's exports (keyed by export name, including
3685
+ * `default`), plus the set of file paths imported during resolution. Callers
3686
+ * are responsible for unwrapping function/promise/definition wrappers around
3687
+ * each export and validating them.
3612
3688
  *
3613
3689
  * @param configPath Filesystem path to the config file. Relative paths are
3614
3690
  * resolved against `process.cwd()`.
3691
+ * @param options.include When provided, only exports whose names are listed
3692
+ * survive into the returned `exports` map. Filtering happens before any
3693
+ * resolution or validation.
3615
3694
  */
3616
- async function loadConfig(configPath) {
3695
+ async function loadConfig(configPath, options) {
3617
3696
  registerConfigHooks();
3618
3697
  const url = pathToFileURL(configPath).href;
3619
3698
  const dependencies = /* @__PURE__ */ new Set();
3699
+ const mod = await depsStore.run(dependencies, () => import(url, { with: { [CF_ATTR]: CF_NO_CACHE_VALUE } }));
3700
+ const exports$2 = {};
3701
+ for (const [name, value] of Object.entries(mod)) {
3702
+ if (options?.include && !options.include.includes(name)) continue;
3703
+ exports$2[name] = value;
3704
+ }
3620
3705
  return {
3621
- config: (await depsStore.run(dependencies, () => import(url, { with: { [CF_ATTR]: CF_NO_CACHE_VALUE } }))).default,
3706
+ exports: exports$2,
3622
3707
  dependencies
3623
3708
  };
3624
3709
  }
@@ -3704,4 +3789,19 @@ function cleanupImportAttributes(context) {
3704
3789
  }
3705
3790
 
3706
3791
  //#endregion
3707
- export { BUILD_OUTPUT_ROOT, BUILD_OUTPUT_VERSION, InputWorkerSchema, ModuleTypeSchema, OutputWorkerSchema, WORKER_CONFIG_FILENAME, bindings, cleanBuildOutputDir, convertToWranglerConfig, defineWorker, exports$1 as exports, generateTypes, getWorkerAssetsDir, getWorkerBundleDir, getWorkerConfigPath, getWorkersDir, loadConfig, registerConfigHooks, resolveWorkerDefinition, triggers, writeOutputWorkerConfig };
3792
+ //#region src/config-loader.ts
3793
+ /**
3794
+ * Load a `cloudflare.config.ts`, resolve all exports, and validate against {@link ConfigExportsSchema}.
3795
+ */
3796
+ async function loadAndValidateConfig(configPath, ctx, options) {
3797
+ const { exports: exports$2, dependencies } = await loadConfig(configPath, options);
3798
+ const resolved = {};
3799
+ for (const [name, value] of Object.entries(exports$2)) resolved[name] = await resolveExportDefinition(value, ctx);
3800
+ return {
3801
+ result: ConfigExportsSchema.safeParse(resolved),
3802
+ dependencies
3803
+ };
3804
+ }
3805
+
3806
+ //#endregion
3807
+ export { BUILD_OUTPUT_ROOT, BUILD_OUTPUT_VERSION, ConfigExportsSchema, InputWorkerSchema, ModuleTypeSchema, OutputWorkerSchema, ROOT_CONFIG_FILENAME, SettingsSchema, WORKER_CONFIG_FILENAME, bindings, cleanBuildOutputDir, convertToWranglerConfig, defineSettings, defineWorker, exports$1 as exports, generateTypes, getRootConfigPath, getWorkerAssetsDir, getWorkerBundleDir, getWorkerConfigPath, getWorkersDir, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveExportDefinition, triggers, writeOutputWorkerConfig, writeRootOutputConfig };
@@ -145,6 +145,7 @@ const bindings = {
145
145
  * triggers.queue({ name: "my-queue" }),
146
146
  * triggers.scheduled({ schedule: "0 * * * *" }),
147
147
  * triggers.scheduled({ schedule: "30 0 * * *" }),
148
+ * triggers.email({ addresses: ["support@example.com"] }),
148
149
  * ],
149
150
  * });
150
151
  * ```
@@ -161,6 +162,10 @@ const triggers = {
161
162
  scheduled: (options) => ({
162
163
  type: "scheduled",
163
164
  ...options
165
+ }),
166
+ email: (options) => ({
167
+ type: "email",
168
+ ...options
164
169
  })
165
170
  };
166
171
 
@@ -201,12 +206,43 @@ const exports = {
201
206
  worker
202
207
  };
203
208
 
209
+ //#endregion
210
+ //#region src/definition.ts
211
+ const DEFINITION = Symbol.for("@cloudflare/config:definition");
212
+ /**
213
+ * Unwrap an authored config from its value / promise / function shape, awaiting
214
+ * the result. A function config is invoked with {@link ConfigContext}.
215
+ */
216
+ async function unwrap(config, ctx) {
217
+ return typeof config === "function" ? await config(ctx) : await config;
218
+ }
219
+ /**
220
+ * Resolve any `cloudflare.config.ts` export to its plain config value.
221
+ *
222
+ * A `define*` helper stores its authored config plus `type` under the
223
+ * {@link DEFINITION} symbol; here we unwrap the config and stamp `type` back on.
224
+ * Every other export — a raw object/promise/function — is unwrapped as-is and
225
+ * already carries its own `type`. Discrimination happens afterwards via `type`.
226
+ */
227
+ async function resolveExportDefinition(def, ctx) {
228
+ if (typeof def === "object" && def !== null && DEFINITION in def) {
229
+ const { config, type } = def[DEFINITION];
230
+ return {
231
+ ...await unwrap(config, ctx),
232
+ type
233
+ };
234
+ }
235
+ return await unwrap(def, ctx);
236
+ }
237
+
204
238
  //#endregion
205
239
  //#region src/worker-definition.ts
206
- const CONFIG = Symbol.for("@cloudflare/config:worker-config");
207
240
  function defineWorker(config) {
208
241
  return {
209
- [CONFIG]: config,
242
+ [DEFINITION]: {
243
+ config,
244
+ type: "worker"
245
+ },
210
246
  durableObject(options) {
211
247
  return {
212
248
  type: "durable-object",
@@ -221,10 +257,19 @@ function defineWorker(config) {
221
257
  }
222
258
  };
223
259
  }
224
- async function resolveWorkerDefinition(def, ctx) {
225
- const raw = typeof def === "object" && def !== null && CONFIG in def ? def[CONFIG] : def;
226
- return await (typeof raw === "function" ? raw(ctx) : raw);
260
+
261
+ //#endregion
262
+ //#region src/settings-definition.ts
263
+ /**
264
+ * Declare shared settings.
265
+ * Authored as a named `settings` export.
266
+ */
267
+ function defineSettings(config) {
268
+ return { [DEFINITION]: {
269
+ config,
270
+ type: "settings"
271
+ } };
227
272
  }
228
273
 
229
274
  //#endregion
230
- export { bindings as a, triggers as i, resolveWorkerDefinition as n, exports as r, defineWorker as t };
275
+ export { triggers as a, exports as i, defineWorker as n, bindings as o, resolveExportDefinition as r, defineSettings as t };
@@ -132,7 +132,7 @@ interface D1Binding extends D1BindingOptions {
132
132
  }
133
133
  interface DispatchNamespaceBindingOptions {
134
134
  /** The namespace to bind to. */
135
- namespace: string;
135
+ namespace?: string;
136
136
  /** Details about the outbound Worker which will handle outbound requests from your namespace. */
137
137
  outbound?: {
138
138
  /** Name of the Worker handling the outbound requests. */
@@ -180,7 +180,7 @@ interface TypedDurableObjectBinding<TConfig$1, TExportName$1 extends string> ext
180
180
  }
181
181
  interface FlagshipBindingOptions {
182
182
  /** The Flagship app ID to bind to. */
183
- id: string;
183
+ id?: string;
184
184
  /** Set to `true` to suppress the remote binding warning in local dev. Flagship bindings are always remote. */
185
185
  remote?: boolean;
186
186
  }
@@ -293,7 +293,7 @@ interface TypedPipelineBinding<TRecord extends PipelineRecord = PipelineRecord>
293
293
  }
294
294
  interface QueueBindingOptions {
295
295
  /** The name of this Queue. */
296
- name: string;
296
+ name?: string;
297
297
  /** The number of seconds to wait before delivering a message. */
298
298
  deliveryDelay?: number;
299
299
  /** Whether the Queue producer should be remote or not in local development. */
@@ -600,7 +600,7 @@ interface Bindings {
600
600
  *
601
601
  * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
602
602
  */
603
- dispatchNamespace(options: DispatchNamespaceBindingOptions): DispatchNamespaceBinding;
603
+ dispatchNamespace(options?: DispatchNamespaceBindingOptions): DispatchNamespaceBinding;
604
604
  /**
605
605
  * Binding to a Durable Object class. `workerName` is the name of the Worker
606
606
  * that defines the class; `exportName` is the exported class name.
@@ -609,7 +609,7 @@ interface Bindings {
609
609
  */
610
610
  durableObject(options: DurableObjectBindingOptions): DurableObjectBinding;
611
611
  /** Binding to a Flagship feature-flag service. */
612
- flagship(options: FlagshipBindingOptions): FlagshipBinding;
612
+ flagship(options?: FlagshipBindingOptions): FlagshipBinding;
613
613
  /**
614
614
  * Binding to a Hyperdrive configuration.
615
615
  *
@@ -650,7 +650,7 @@ interface Bindings {
650
650
  *
651
651
  * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
652
652
  */
653
- queue<TBody = unknown>(options: QueueBindingOptions): TypedQueueBinding<TBody>;
653
+ queue<TBody = unknown>(options?: QueueBindingOptions): TypedQueueBinding<TBody>;
654
654
  /**
655
655
  * Binding to an R2 bucket.
656
656
  *
@@ -788,10 +788,27 @@ interface ScheduledTriggerOptions {
788
788
  interface ScheduledTrigger extends ScheduledTriggerOptions {
789
789
  type: "scheduled";
790
790
  }
791
+ interface EmailTriggerOptions {
792
+ /**
793
+ * Inbound Email Routing addresses handled by this Worker.
794
+ *
795
+ * Each entry is a literal recipient address (e.g. `"support@example.com"`)
796
+ * or a `*@domain` catch-all (e.g. `"*@example.com"`).
797
+ */
798
+ addresses: string[];
799
+ }
800
+ /**
801
+ * Email trigger — invokes this Worker for the configured Email Routing
802
+ * addresses.
803
+ */
804
+ interface EmailTrigger extends EmailTriggerOptions {
805
+ type: "email";
806
+ }
791
807
  /**
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(...)`.
808
+ * Event triggers — fetch routes, queue consumers, cron schedules, and Email
809
+ * Routing addresses — that invoke this Worker. Construct entries with
810
+ * `triggers.fetch(...)`, `triggers.queue(...)`, `triggers.scheduled(...)`, or
811
+ * `triggers.email(...)`.
795
812
  *
796
813
  * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
797
814
  */
@@ -815,6 +832,11 @@ interface Triggers {
815
832
  * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
816
833
  */
817
834
  scheduled(options: ScheduledTriggerOptions): ScheduledTrigger;
835
+ /**
836
+ * Email trigger — invokes this Worker for the configured Email Routing
837
+ * addresses.
838
+ */
839
+ email(options: EmailTriggerOptions): EmailTrigger;
818
840
  }
819
841
  /**
820
842
  * Triggers builder for configuring event triggers.
@@ -829,6 +851,7 @@ interface Triggers {
829
851
  * triggers.queue({ name: "my-queue" }),
830
852
  * triggers.scheduled({ schedule: "0 * * * *" }),
831
853
  * triggers.scheduled({ schedule: "30 0 * * *" }),
854
+ * triggers.email({ addresses: ["support@example.com"] }),
832
855
  * ],
833
856
  * });
834
857
  * ```
@@ -983,6 +1006,32 @@ interface Exports {
983
1006
  */
984
1007
  declare const exports: Exports;
985
1008
  //#endregion
1009
+ //#region src/definition.d.ts
1010
+ interface ConfigContext {
1011
+ /**
1012
+ * The mode the config is being evaluated in.
1013
+ * Set via the `--mode` CLI flag.
1014
+ * 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)).
1015
+ * In Wrangler the mode defaults to `undefined`.
1016
+ */
1017
+ mode: string | undefined;
1018
+ }
1019
+ declare const DEFINITION: unique symbol;
1020
+ /**
1021
+ * The authored config in any of its supported shapes: a plain value, a promise,
1022
+ * or a function of {@link ConfigContext}.
1023
+ */
1024
+ type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
1025
+ /**
1026
+ * Resolve any `cloudflare.config.ts` export to its plain config value.
1027
+ *
1028
+ * A `define*` helper stores its authored config plus `type` under the
1029
+ * {@link DEFINITION} symbol; here we unwrap the config and stamp `type` back on.
1030
+ * Every other export — a raw object/promise/function — is unwrapped as-is and
1031
+ * already carries its own `type`. Discrimination happens afterwards via `type`.
1032
+ */
1033
+ declare function resolveExportDefinition(def: unknown, ctx: ConfigContext): Promise<unknown>;
1034
+ //#endregion
986
1035
  //#region src/types.d.ts
987
1036
  /**
988
1037
  * Union of all binding definitions accepted in `env`.
@@ -991,7 +1040,7 @@ type Binding = AgentMemoryBinding | AiBinding | AiSearchBinding | AiSearchNamesp
991
1040
  /**
992
1041
  * Union of all trigger definitions accepted in `triggers`.
993
1042
  */
994
- type Trigger = FetchTrigger | QueueConsumerTrigger | ScheduledTrigger;
1043
+ type Trigger = EmailTrigger | FetchTrigger | QueueConsumerTrigger | ScheduledTrigger;
995
1044
  /**
996
1045
  * Union of all export definitions accepted in `exports`. Worker entries
997
1046
  * configure WorkerEntrypoint exports. Durable Object entries configure live
@@ -1005,19 +1054,18 @@ type Export = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableO
1005
1054
  * Fields are validated at runtime by `InputWorkerSchema` and normalised before
1006
1055
  * being passed to downstream tooling.
1007
1056
  */
1008
- interface UserConfig {
1057
+ interface WorkerConfig {
1009
1058
  /**
1010
- * The name of your Worker.
1059
+ * Discriminates this config as a Worker config.
1060
+ *
1061
+ * Injected automatically by `defineWorker`; only needs to be written by
1062
+ * hand when authoring a raw config object without the helper.
1011
1063
  */
1012
- name: string;
1064
+ type: "worker";
1013
1065
  /**
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.
1066
+ * The name of your Worker.
1019
1067
  */
1020
- accountId?: string;
1068
+ name: string;
1021
1069
  /**
1022
1070
  * A date in the form yyyy-mm-dd, which will be used to determine
1023
1071
  * which version of the Workers runtime is used.
@@ -1073,9 +1121,10 @@ interface UserConfig {
1073
1121
  */
1074
1122
  domains?: string[];
1075
1123
  /**
1076
- * Event triggers — fetch routes, queue consumers, and cron schedules
1124
+ * Event triggers — fetch routes, queue consumers, cron schedules, and Email
1125
+ * Routing addresses
1077
1126
  * — that invoke this Worker. Construct entries with `triggers.fetch(...)`,
1078
- * `triggers.queue(...)`, or `triggers.scheduled(...)`.
1127
+ * `triggers.queue(...)`, `triggers.scheduled(...)`, or `triggers.email(...)`.
1079
1128
  *
1080
1129
  * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
1081
1130
  */
@@ -1205,13 +1254,6 @@ interface UserConfig {
1205
1254
  * @default false
1206
1255
  */
1207
1256
  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
1257
  /**
1216
1258
  * Designates this Worker as an internal-only "first-party" Worker.
1217
1259
  *
@@ -1263,29 +1305,51 @@ interface UserConfig {
1263
1305
  */
1264
1306
  exports?: Record<string, Export>;
1265
1307
  }
1266
- //#endregion
1267
- //#region src/worker-definition.d.ts
1268
- interface ConfigContext {
1308
+ /**
1309
+ * Settings shared by the other exports.
1310
+ * Authored as a named `settings` export via
1311
+ * `defineSettings`.
1312
+ */
1313
+ interface SettingsConfig {
1269
1314
  /**
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`.
1315
+ * Discriminates this config as a settings config.
1316
+ *
1317
+ * Injected automatically by `defineSettings`; only needs to be written by
1318
+ * hand when authoring a raw config object without the helper.
1274
1319
  */
1275
- mode: string | undefined;
1320
+ type: "settings";
1321
+ /**
1322
+ * This is the ID of the account associated with your zone.
1323
+ * You might have more than one account, so make sure to use
1324
+ * the ID of the account associated with the zone/route you
1325
+ * provide, if you provide one. It can also be specified through
1326
+ * the CLOUDFLARE_ACCOUNT_ID environment variable.
1327
+ */
1328
+ accountId?: string;
1329
+ /**
1330
+ * Specify the compliance region mode of the Worker.
1331
+ *
1332
+ * Although if the user does not specify a compliance region, the default is `public`,
1333
+ * it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
1334
+ */
1335
+ complianceRegion?: "public" | "fedramp-high";
1276
1336
  }
1277
- declare const CONFIG: unique symbol;
1337
+ //#endregion
1338
+ //#region src/worker-definition.d.ts
1278
1339
  /**
1279
- * Base shape of a Worker definition. Carries the resolved config and the
1280
- * untyped cross-worker binding helpers.
1340
+ * Base shape of a Worker definition. Carries the authored config (under
1341
+ * {@link DEFINITION}) and the untyped cross-worker binding helpers.
1281
1342
  */
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>);
1343
+ interface WorkerDefinition<TConfig$1 extends WorkerConfig = WorkerConfig> extends Pick<Bindings, "durableObject" | "worker"> {
1344
+ [DEFINITION]: {
1345
+ config: ConfigInput<Omit<TConfig$1, "type">>;
1346
+ type: "worker";
1347
+ };
1284
1348
  }
1285
1349
  /**
1286
1350
  * Worker definition with typed cross-worker binding helpers.
1287
1351
  */
1288
- interface TypedWorkerDefinition<TConfig$1 extends UserConfig, TWorkerName extends string = InferWorkerName<TConfig$1>> extends WorkerDefinition<TConfig$1> {
1352
+ interface TypedWorkerDefinition<TConfig$1 extends WorkerConfig, TWorkerName extends string = InferWorkerName<TConfig$1>> extends WorkerDefinition<TConfig$1> {
1289
1353
  /**
1290
1354
  * Binding to a Durable Object class. `workerName` is the name of the Worker
1291
1355
  * that defines the class; `exportName` is the exported class name.
@@ -1310,10 +1374,18 @@ interface TypedWorkerDefinition<TConfig$1 extends UserConfig, TWorkerName extend
1310
1374
  remote?: boolean;
1311
1375
  }): TypedWorkerBinding<TConfig$1, TExportName$1 extends string ? TExportName$1 : "default">;
1312
1376
  }
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>;
1377
+ type WorkerConfigExport<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
1378
+ /**
1379
+ * Authored Worker config shape — {@link WorkerConfig} without the `type`
1380
+ * discriminant, which `defineWorker` injects.
1381
+ */
1382
+ type WorkerConfigInput = Omit<WorkerConfig, "type">;
1383
+ declare function defineWorker<const T$1 extends WorkerConfigInput>(config: (ctx: ConfigContext) => (WorkerConfigInput & T$1) | Promise<WorkerConfigInput & T$1>): TypedWorkerDefinition<T$1 & {
1384
+ type: "worker";
1385
+ }>;
1386
+ declare function defineWorker<const T$1 extends WorkerConfigInput>(config: (WorkerConfigInput & T$1) | Promise<WorkerConfigInput & T$1>): TypedWorkerDefinition<T$1 & {
1387
+ type: "worker";
1388
+ }>;
1317
1389
  //#endregion
1318
1390
  //#region src/inference.d.ts
1319
1391
  /**
@@ -1451,7 +1523,7 @@ type InferWorkerEntrypointExports<TUnwrappedConfig$1> = Exclude<keyof InferMainM
1451
1523
  * Unwrap function and promise types to get the underlying config.
1452
1524
  * Use this to normalize a config before passing it to other inference utilities.
1453
1525
  */
1454
- type UnwrapConfig<TConfig$1> = TConfig$1 extends WorkerDefinition<infer TUnwrappedConfig> ? TUnwrappedConfig : TConfig$1 extends UserConfigExport<infer TUnwrappedConfig> ? TUnwrappedConfig : never;
1526
+ type UnwrapConfig<TConfig$1> = TConfig$1 extends WorkerDefinition<infer TUnwrappedConfig> ? TUnwrappedConfig : TConfig$1 extends WorkerConfigExport<infer TUnwrappedConfig> ? TUnwrappedConfig : never;
1455
1527
  /**
1456
1528
  * Infer the `Env` interface type from a Worker config.
1457
1529
  *
@@ -1521,4 +1593,21 @@ type InferMainModule<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
1521
1593
  entrypoint: infer TModule extends WorkerModule;
1522
1594
  } ? TModule : DefaultModule;
1523
1595
  //#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 };
1596
+ //#region src/settings-definition.d.ts
1597
+ /**
1598
+ * Authored settings config shape — {@link SettingsConfig} without the `type`
1599
+ * discriminant, which `defineSettings` injects.
1600
+ */
1601
+ type SettingsConfigInput = Omit<SettingsConfig, "type">;
1602
+ /**
1603
+ * Declare shared settings.
1604
+ * Authored as a named `settings` export.
1605
+ */
1606
+ declare function defineSettings(config: ConfigInput<SettingsConfigInput>): {
1607
+ [DEFINITION]: {
1608
+ config: ConfigInput<SettingsConfigInput>;
1609
+ type: string;
1610
+ };
1611
+ };
1612
+ //#endregion
1613
+ export { RateLimitBinding as $, AgentMemoryBinding as A, DispatchNamespaceBinding as B, exports as C, ScheduledTrigger as D, QueueConsumerTrigger as E, ArtifactsBinding as F, JsonBinding as G, FlagshipBinding as H, AssetsBinding as I, MediaBinding$1 as J, KvBinding as K, Bindings as L, AiSearchBinding as M, AiSearchNamespaceBinding as N, Triggers as O, AnalyticsEngineDatasetBinding as P, R2Binding as Q, BrowserBinding as R, WorkerEntrypointExportOptions as S, FetchTrigger as T, HyperdriveBinding as U, DurableObjectBinding as V, ImagesBinding$1 as W, PipelineBinding as X, MtlsCertificateBinding as Y, QueueBinding as Z, DurableObjectExpectingTransferExport as _, WebSearchBinding as _t, InferMainModule as a, TypedAiBinding as at, Exports as b, WorkflowBinding as bt, WorkerConfigExport as c, TypedPipelineBinding as ct, SettingsConfig as d, TypedWorkflowBinding as dt, SecretBinding as et, WorkerConfig as f, UnsafeBinding as ft, DurableObjectDeletedExport as g, VpcServiceBinding as gt, DurableObjectCreatedExport as h, VpcNetworkBinding as ht, InferEnv as i, TextBinding as it, AiBinding as j, triggers as k, WorkerConfigInput as l, TypedQueueBinding as lt, resolveExportDefinition as m, VersionMetadataBinding as mt, defineSettings as n, SendEmailBinding as nt, UnwrapConfig as o, TypedDurableObjectBinding as ot, ConfigContext as p, VectorizeBinding as pt, LogfwdrBinding as q, InferDurableNamespaces as r, StreamBinding$1 as rt, TypedWorkerDefinition as s, TypedKvBinding as st, SettingsConfigInput as t, SecretsStoreSecretBinding as tt, defineWorker as u, TypedWorkerBinding as ut, DurableObjectRenamedExport as v, WorkerBinding as vt, EmailTrigger as w, WorkerEntrypointExport as x, bindings as xt, DurableObjectTransferredExport as y, WorkerLoaderBinding as yt, D1Binding as z };
package/dist/public.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as TextBinding, A as ArtifactsBinding, B as JsonBinding, C as Triggers, D as AiSearchBinding, E as AiBinding, F as DispatchNamespaceBinding, G as PipelineBinding, H as LogfwdrBinding, I as DurableObjectBinding, J as RateLimitBinding, K as QueueBinding, L as FlagshipBinding, M as Bindings, N as BrowserBinding, O as AiSearchNamespaceBinding, P as D1Binding, Q as StreamBinding, R as HyperdriveBinding, S as ScheduledTrigger, T as AgentMemoryBinding, U as MediaBinding, V as KvBinding, W as MtlsCertificateBinding, X as SecretsStoreSecretBinding, Y as SecretBinding, Z as SendEmailBinding, _ as WorkerEntrypointExport, a as ConfigContext, at as TypedWorkerBinding, b as FetchTrigger, c as defineWorker, ct as VectorizeBinding, d as DurableObjectCreatedExport, dt as VpcServiceBinding, et as TypedAiBinding, f as DurableObjectDeletedExport, ft as WebSearchBinding, g as Exports, gt as bindings, h as DurableObjectTransferredExport, ht as WorkflowBinding, i as UnwrapConfig, it as TypedQueueBinding, j as AssetsBinding, k as AnalyticsEngineDatasetBinding, lt as VersionMetadataBinding, m as DurableObjectRenamedExport, mt as WorkerLoaderBinding, n as InferEnv, nt as TypedKvBinding, o as TypedWorkerDefinition, ot as TypedWorkflowBinding, p as DurableObjectExpectingTransferExport, pt as WorkerBinding, q as R2Binding, r as InferMainModule, rt as TypedPipelineBinding, s as UserConfigExport, st as UnsafeBinding, t as InferDurableNamespaces, tt as TypedDurableObjectBinding, u as UserConfig, ut as VpcNetworkBinding, v as WorkerEntrypointExportOptions, w as triggers, x as QueueConsumerTrigger, y as exports, z as ImagesBinding } from "./public-YTdTOrcv.mjs";
2
- export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, Bindings, BrowserBinding, ConfigContext, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, UserConfig, UserConfigExport, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkflowBinding, bindings, defineWorker, exports, triggers };
1
+ import { $ as RateLimitBinding, A as AgentMemoryBinding, B as DispatchNamespaceBinding, C as exports, D as ScheduledTrigger, E as QueueConsumerTrigger, F as ArtifactsBinding, G as JsonBinding, H as FlagshipBinding, I as AssetsBinding, J as MediaBinding, K as KvBinding, L as Bindings, M as AiSearchBinding, N as AiSearchNamespaceBinding, O as Triggers, P as AnalyticsEngineDatasetBinding, Q as R2Binding, R as BrowserBinding, S as WorkerEntrypointExportOptions, T as FetchTrigger, U as HyperdriveBinding, V as DurableObjectBinding, W as ImagesBinding, X as PipelineBinding, Y as MtlsCertificateBinding, Z as QueueBinding, _ as DurableObjectExpectingTransferExport, _t as WebSearchBinding, a as InferMainModule, at as TypedAiBinding, b as Exports, bt as WorkflowBinding, c as WorkerConfigExport, ct as TypedPipelineBinding, d as SettingsConfig, dt as TypedWorkflowBinding, et as SecretBinding, f as WorkerConfig, ft as UnsafeBinding, g as DurableObjectDeletedExport, gt as VpcServiceBinding, h as DurableObjectCreatedExport, ht as VpcNetworkBinding, i as InferEnv, it as TextBinding, j as AiBinding, k as triggers, l as WorkerConfigInput, lt as TypedQueueBinding, mt as VersionMetadataBinding, n as defineSettings, nt as SendEmailBinding, o as UnwrapConfig, ot as TypedDurableObjectBinding, p as ConfigContext, pt as VectorizeBinding, q as LogfwdrBinding, r as InferDurableNamespaces, rt as StreamBinding, s as TypedWorkerDefinition, st as TypedKvBinding, t as SettingsConfigInput, tt as SecretsStoreSecretBinding, u as defineWorker, ut as TypedWorkerBinding, v as DurableObjectRenamedExport, vt as WorkerBinding, w as EmailTrigger, x as WorkerEntrypointExport, xt as bindings, y as DurableObjectTransferredExport, yt as WorkerLoaderBinding, z as D1Binding } from "./public-myuV_kLK.mjs";
2
+ export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, Bindings, BrowserBinding, ConfigContext, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigInput, StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkflowBinding, bindings, defineSettings, defineWorker, exports, triggers };
package/dist/public.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as bindings, i as triggers, r as exports, t as defineWorker } from "./public-CFHebTo4.mjs";
1
+ import { a as triggers, i as exports, n as defineWorker, o as bindings, t as defineSettings } from "./public-D2QZv1n6.mjs";
2
2
 
3
- export { bindings, defineWorker, exports, triggers };
3
+ export { bindings, defineSettings, defineWorker, exports, triggers };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/config",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Definitions and utilities for configuring Cloudflare Workers and related products. This is not yet stable enough for external use — APIs may change without notice.",
5
5
  "homepage": "https://github.com/cloudflare/workers-sdk/tree/main/packages/config#readme",
6
6
  "bugs": {
@@ -31,13 +31,13 @@
31
31
  "zod": "4.4.3"
32
32
  },
33
33
  "devDependencies": {
34
- "@cloudflare/workers-types": "^5.20260710.1",
34
+ "@cloudflare/workers-types": "^5.20260721.1",
35
35
  "ts-dedent": "^2.2.0",
36
36
  "tsdown": "0.16.3",
37
37
  "typescript": "5.8.3",
38
38
  "vitest": "4.1.0",
39
39
  "@cloudflare/workers-tsconfig": "0.0.0",
40
- "@cloudflare/workers-utils": "0.27.0"
40
+ "@cloudflare/workers-utils": "0.28.0"
41
41
  },
42
42
  "workers-sdk": {
43
43
  "prerelease": true