@cloudflare/config 0.15.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.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as triggers, i as exports$1, n as defineWorker, o as bindings, r as defineContainer, t as defineSettings } from "./public-Dyr8BJqf.mjs";
1
+ import { a as triggers, i as exports$1, n as defineContainer, o as bindings, r as defineWorker, t as defineConfig } from "./public-BMg6-Hxh.mjs";
2
2
  import * as nodeModule from "node:module";
3
3
  import * as z from "zod";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -324,7 +324,6 @@ const ContainerObservabilityBaseSchema = z.strictObject({
324
324
  });
325
325
  const StandardContainerObservabilitySchema = z.union([ContainerObservabilityBaseSchema.extend({ targetInstancePercentage: z.number().min(0).max(100).optional() }), ContainerObservabilityBaseSchema.extend({ targetInstanceCount: z.number().int().nonnegative().optional() })]);
326
326
  const BaseContainerSchema = z.strictObject({
327
- type: z.literal("container"),
328
327
  name: z.string().min(1),
329
328
  unsafe: z.record(z.string(), z.unknown()).optional()
330
329
  });
@@ -381,14 +380,13 @@ const DurableObjectContainerBaseSchema = BaseContainerSchema.extend({
381
380
  observability: ContainerObservabilityBaseSchema.optional()
382
381
  });
383
382
  /**
384
- * Input Container schema — validates user-authored `cloudflare.config.ts`
385
- * Container exports. Dockerfiles are built by the consuming build tool.
383
+ * Input Container schema — parses user-authored `cloudflare.config.ts`
384
+ * Container objects. Dockerfiles are built by the consuming build tool.
386
385
  */
387
386
  const InputContainerSchema = z.union([StandardContainerBaseSchema.extend({ image: InputContainerImageSchema }).superRefine(validateContainerRelationships), DurableObjectContainerBaseSchema.extend({ images: z.record(z.string(), InputContainerImageSchema).optional() })]);
388
387
  /**
389
- * Output Container schema — validates Container configs in the Build Output
390
- * Specification, after any Dockerfile has been built into a local or remote
391
- * image reference.
388
+ * Output Container schema — parses `container.config.json` files in the Build
389
+ * Output Specification, after any Dockerfile has been built into a local image reference.
392
390
  */
393
391
  const OutputContainerSchema = z.union([StandardContainerBaseSchema.extend({ image: OutputContainerImageSchema }).superRefine(validateContainerRelationships), DurableObjectContainerBaseSchema.extend({ images: z.record(z.string(), OutputContainerImageSchema).optional() })]);
394
392
  const DurableObjectCreatedExportSchema = z.strictObject({
@@ -530,7 +528,6 @@ const UnsafeSchema = z.strictObject({
530
528
  * (user-authored) and output (on-disk) Worker configs.
531
529
  */
532
530
  const BaseWorkerSchema = z.strictObject({
533
- type: z.literal("worker"),
534
531
  name: z.string(),
535
532
  compatibilityDate: z.string(),
536
533
  compatibilityFlags: z.array(z.string()).optional(),
@@ -551,75 +548,37 @@ const BaseWorkerSchema = z.strictObject({
551
548
  exports: z.record(z.string(), ExportSchema).optional()
552
549
  });
553
550
  /**
554
- * Input Worker schema — the shape that user-authored `cloudflare.config.ts`
555
- * files are validated against. Adds an optional `entrypoint` field to the
556
- * base schema.
551
+ * Input Worker schema — parses Worker definitions from user-authored
552
+ * `cloudflare.config.ts` files. Adds an optional `entrypoint` field to the base
553
+ * schema.
557
554
  */
558
555
  const InputWorkerSchema = BaseWorkerSchema.extend({ entrypoint: z.union([z.string(), z.strictObject({ default: z.string() })]).transform((value) => typeof value === "string" ? value : value.default).optional() });
559
556
  /**
560
- * Input settings schema — validates the named `settings` export of a
561
- * `cloudflare.config.ts`. Holds account/deployment settings shared by the other exports.
557
+ * Input settings schema — parses the account settings at the top level of
558
+ * `cloudflare.config.ts`.
562
559
  */
563
- const InputSettingsSchema = z.strictObject({
564
- type: z.literal("settings"),
560
+ const InputSettingsSchema = z.object({
565
561
  accountId: z.string().optional(),
566
562
  complianceRegion: z.enum(["public", "fedramp-high"]).optional()
567
563
  });
568
- /**
569
- * Output settings schema — the shape of the top-level `config.json` in the
570
- * Build Output Specification. Adds the build mode and Preview intent.
571
- */
572
- const OutputSettingsSchema = InputSettingsSchema.extend({
573
- isPreview: z.boolean().optional(),
564
+ /** The resolved, user-authored project configuration. */
565
+ const InputConfigSchema = z.strictObject({
566
+ ...InputSettingsSchema.shape,
567
+ worker: InputWorkerSchema.optional(),
568
+ containers: z.array(InputContainerSchema).default([])
569
+ });
570
+ const BuildContextSchema = z.strictObject({
571
+ isPreview: z.boolean(),
574
572
  mode: z.string().optional()
575
573
  });
576
- const DEFAULT_EXPORT_NAME = "default";
577
- const SETTINGS_EXPORT_NAME = "settings";
578
- const SUPPORTED_EXPORT_TYPES = new Set([
579
- "container",
580
- "worker",
581
- "settings"
582
- ]);
583
- function invalidConfigExportMessage(exportName) {
584
- return `The \`${exportName}\` export is not a supported export type. Move constants, helper functions, and other unsupported exports to a separate module.`;
585
- }
586
- const ConfigExportsTypeSchema = z.record(z.string(), z.unknown()).check((ctx) => {
587
- for (const [key, value] of Object.entries(ctx.value)) {
588
- const isObject = typeof value === "object" && value !== null;
589
- const type = isObject && "type" in value ? value.type : void 0;
590
- if (typeof type !== "string" || !SUPPORTED_EXPORT_TYPES.has(type)) {
591
- ctx.issues.push({
592
- code: "custom",
593
- input: value,
594
- path: isObject ? [key, "type"] : [key],
595
- message: invalidConfigExportMessage(key)
596
- });
597
- continue;
598
- }
599
- if (key === DEFAULT_EXPORT_NAME && type !== "worker") {
600
- ctx.issues.push({
601
- code: "custom",
602
- input: value,
603
- path: [key],
604
- message: `The \`${DEFAULT_EXPORT_NAME}\` export is reserved for a \`worker\` config; found a \`${type}\` config.`
605
- });
606
- continue;
607
- }
608
- const isSettingsName = key === SETTINGS_EXPORT_NAME;
609
- const isSettingsType = type === "settings";
610
- if (isSettingsType && !isSettingsName) ctx.issues.push({
611
- code: "custom",
612
- input: value,
613
- path: [key],
614
- message: `A \`settings\` config is only allowed on the \`${SETTINGS_EXPORT_NAME}\` export; found one on the \`${key}\` export.`
615
- });
616
- else if (isSettingsName && !isSettingsType) ctx.issues.push({
617
- code: "custom",
618
- input: value,
619
- path: [key],
620
- message: `The \`${SETTINGS_EXPORT_NAME}\` export is reserved for a \`settings\` config; found a \`${type}\` config.`
621
- });
622
- }
574
+ /**
575
+ * The shape of the root `config.json` in the Build Output Specification.
576
+ * Account settings remain at the top level while build context is grouped
577
+ * under `buildContext`.
578
+ */
579
+ const OutputRootConfigSchema = z.strictObject({
580
+ ...InputSettingsSchema.shape,
581
+ buildContext: BuildContextSchema
623
582
  });
624
583
  const ModuleTypeSchema = z.enum([
625
584
  "esm",
@@ -651,9 +610,9 @@ const ManifestSchema = z.strictObject({
651
610
  });
652
611
  });
653
612
  /**
654
- * Output Worker schema — the shape of the Worker's `config.json` in the
655
- * Build Output Specification. Adds an optional `manifest` field to the
656
- * base schema.
613
+ * Output Worker schema — the shape of the Worker's `worker.config.json` in the
614
+ * Build Output Specification. Adds an optional `manifest` field to the base
615
+ * schema.
657
616
  */
658
617
  const OutputWorkerSchema = BaseWorkerSchema.extend({ manifest: ManifestSchema.optional() });
659
618
 
@@ -719,7 +678,8 @@ function generateTypes({ configPath, packageName = "@cloudflare/config" }) {
719
678
  return import_dist.dedent`
720
679
  /* eslint-disable */
721
680
  // Generated by @cloudflare/config
722
- type __WorkerConfig = import("${packageName}").UnwrapConfig<typeof import("${configPath.replace(/\.(ts|js|mts|mjs)$/, "")}").default>;
681
+ type __Config = import("${packageName}").UnwrapConfig<typeof import("${configPath.replace(/\.(ts|js|mts|mjs)$/, "")}").default>;
682
+ type __WorkerConfig = import("${packageName}").UnwrapConfig<__Config["worker"]>;
723
683
  type __Env = import("${packageName}").InferEnv<__WorkerConfig>;
724
684
 
725
685
  declare namespace Cloudflare {
@@ -810,27 +770,25 @@ const ROLLOUT_KIND_MAP = {
810
770
  /**
811
771
  * Convert a parsed `@cloudflare/config` config into a Wrangler `RawConfig`.
812
772
  *
813
- * The caller is responsible for unwrapping any function/promise wrappers and
814
- * validating the configs against their corresponding input schemas before
815
- * passing them in.
773
+ * The caller is responsible for resolving any function/promise wrappers and
774
+ * parsing the configuration before passing it in.
816
775
  *
817
- * @param workerConfig The parsed (post-validation) Worker config.
818
- * @param settingsConfig The optional parsed settings config, whose fields
819
- * are merged onto the result.
820
- * @param containerExports The parsed Container exports to include in the
821
- * result.
776
+ * @param config The parsed configuration.
822
777
  * @returns The corresponding Wrangler `RawConfig`.
823
778
  */
824
- function convertToWranglerConfig(workerConfig, settingsConfig, containerExports = []) {
779
+ function convertToWranglerConfig(config) {
825
780
  const result = {};
826
- convertTopLevel(workerConfig, result);
827
- convertBindingsAndAssets(workerConfig, result);
828
- convertExports(workerConfig, result);
829
- convertDomains(workerConfig, result);
830
- convertTriggers(workerConfig, result);
831
- convertTailConsumers(workerConfig, result);
832
- if (settingsConfig !== void 0) convertSettings(settingsConfig, result);
833
- if (containerExports.length > 0) result.containers = containerExports.map((container) => convertContainer(container));
781
+ const { worker, containers } = config;
782
+ if (worker !== void 0) {
783
+ convertTopLevel(worker, result);
784
+ convertBindingsAndAssets(worker, result);
785
+ convertExports(worker, result);
786
+ convertDomains(worker, result);
787
+ convertTriggers(worker, result);
788
+ convertTailConsumers(worker, result);
789
+ }
790
+ convertSettings(config, result);
791
+ if (containers.length > 0) result.containers = containers.map((container) => convertContainer(container));
834
792
  return result;
835
793
  }
836
794
  function convertContainer(container) {
@@ -1431,31 +1389,22 @@ const CF_NO_CACHE_QUERY_KEY = "cf-no-cache";
1431
1389
  const RE_NODE_MODULES = /[/\\]node_modules[/\\]/;
1432
1390
  const depsStore = new AsyncLocalStorage();
1433
1391
  /**
1434
- * Dynamically import a worker config file from disk.
1392
+ * Dynamically import a Cloudflare config file from disk.
1435
1393
  *
1436
- * Returns all of the module's exports (keyed by export name, including
1437
- * `default`), plus the set of file paths imported during resolution. Callers
1438
- * are responsible for unwrapping function/promise/definition wrappers around
1439
- * each export and validating them.
1394
+ * Returns the module's default export plus the set of file paths imported
1395
+ * during resolution.
1440
1396
  *
1441
1397
  * @param configPath Filesystem path to the config file. Relative paths are
1442
1398
  * resolved against `process.cwd()`.
1443
- * @param options.include When provided, only exports whose names are listed
1444
- * survive into the returned `exports` map. Filtering happens before any
1445
- * resolution or validation.
1446
1399
  */
1447
- async function loadConfig(configPath, options) {
1400
+ async function loadConfig(configPath) {
1448
1401
  registerConfigHooks();
1449
1402
  const url = pathToFileURL(configPath).href;
1450
1403
  const dependencies = /* @__PURE__ */ new Set();
1451
1404
  const mod = await depsStore.run(dependencies, () => import(url, { with: { [CF_ATTR]: CF_NO_CACHE_VALUE } }));
1452
- const exports$2 = {};
1453
- for (const [name, value] of Object.entries(mod)) {
1454
- if (options?.include && !options.include.includes(name)) continue;
1455
- exports$2[name] = value;
1456
- }
1405
+ if (!("default" in mod)) throw new Error(`The config file "${configPath}" does not have a default export. Export your configuration with \`export default defineConfig({ ... })\`.`);
1457
1406
  return {
1458
- exports: exports$2,
1407
+ config: mod.default,
1459
1408
  dependencies
1460
1409
  };
1461
1410
  }
@@ -1547,23 +1496,11 @@ const CROSS_WORKER_BINDING_TYPES = new Set([
1547
1496
  "worker",
1548
1497
  "workflow"
1549
1498
  ]);
1550
- /**
1551
- * Selects the Container exports from a validated project configuration.
1552
- *
1553
- * @param config - Validated exports keyed by their JavaScript export names.
1554
- * @returns Container configurations keyed by those same export names.
1555
- */
1556
- function getContainerConfigExports(config) {
1557
- return Object.fromEntries(Object.entries(config).filter((entry) => entry[1]?.type === "container"));
1558
- }
1559
1499
  function isRecord(value) {
1560
1500
  return typeof value === "object" && value !== null;
1561
1501
  }
1562
- function isConfigReference(value) {
1563
- return typeof value === "function" || isRecord(value);
1564
- }
1565
- function normalizeConfigReference(reference, resolved, expectedType) {
1566
- return isRecord(resolved) && resolved.type === expectedType && typeof resolved.name === "string" ? resolved.name : reference;
1502
+ function normalizeConfigReference(reference, resolved) {
1503
+ return isRecord(resolved) && typeof resolved.name === "string" ? resolved.name : reference;
1567
1504
  }
1568
1505
  function createDefinitionResolver(ctx) {
1569
1506
  const resolvedDefinitions = /* @__PURE__ */ new Map();
@@ -1581,11 +1518,11 @@ async function normalizeWorkerReferences(resolved, resolveDefinition) {
1581
1518
  if (!isRecord(resolved) || !isRecord(resolved.env)) return resolved;
1582
1519
  const env = { ...resolved.env };
1583
1520
  for (const [bindingName, binding] of Object.entries(env)) {
1584
- if (!isRecord(binding) || typeof binding.type !== "string" || !CROSS_WORKER_BINDING_TYPES.has(binding.type) || !isConfigReference(binding.worker)) continue;
1521
+ if (!isRecord(binding) || typeof binding.type !== "string" || !CROSS_WORKER_BINDING_TYPES.has(binding.type) || typeof binding.worker === "string") continue;
1585
1522
  const target = await resolveDefinition(binding.worker);
1586
1523
  env[bindingName] = {
1587
1524
  ...binding,
1588
- worker: normalizeConfigReference(binding.worker, target, "worker")
1525
+ worker: normalizeConfigReference(binding.worker, target)
1589
1526
  };
1590
1527
  }
1591
1528
  return {
@@ -1593,7 +1530,7 @@ async function normalizeWorkerReferences(resolved, resolveDefinition) {
1593
1530
  env
1594
1531
  };
1595
1532
  }
1596
- async function normalizeContainerReferences(resolved, resolveDefinition, resolvedExports) {
1533
+ async function normalizeContainerReferences(resolved, resolveDefinition, containers) {
1597
1534
  const issues = [];
1598
1535
  if (!isRecord(resolved) || !isRecord(resolved.exports)) return {
1599
1536
  value: resolved,
@@ -1612,7 +1549,7 @@ async function normalizeContainerReferences(resolved, resolveDefinition, resolve
1612
1549
  exportName,
1613
1550
  "container"
1614
1551
  ],
1615
- message: "Container provided as a string. Reference an exported Container definition instead."
1552
+ message: "Container provided as a string. Reference a Container definition instead, for example `container: myContainer`."
1616
1553
  });
1617
1554
  workerExports[exportName] = {
1618
1555
  ...workerExport,
@@ -1621,7 +1558,7 @@ async function normalizeContainerReferences(resolved, resolveDefinition, resolve
1621
1558
  continue;
1622
1559
  }
1623
1560
  const target = await resolveDefinition(reference);
1624
- if (isRecord(target) && target.type === "container" && typeof target.name === "string" && !Object.values(resolvedExports).includes(target)) {
1561
+ if (isRecord(target) && typeof target.name === "string" && !containers.includes(target)) {
1625
1562
  issues.push({
1626
1563
  code: "custom",
1627
1564
  input: reference,
@@ -1630,7 +1567,7 @@ async function normalizeContainerReferences(resolved, resolveDefinition, resolve
1630
1567
  exportName,
1631
1568
  "container"
1632
1569
  ],
1633
- message: `The referenced Container "${target.name}" is not exported.`
1570
+ message: `The referenced Container "${target.name}" is not included in the \`containers\` array.`
1634
1571
  });
1635
1572
  workerExports[exportName] = {
1636
1573
  ...workerExport,
@@ -1640,7 +1577,7 @@ async function normalizeContainerReferences(resolved, resolveDefinition, resolve
1640
1577
  }
1641
1578
  workerExports[exportName] = {
1642
1579
  ...workerExport,
1643
- container: normalizeConfigReference(reference, target, "container")
1580
+ container: normalizeConfigReference(reference, target)
1644
1581
  };
1645
1582
  }
1646
1583
  return {
@@ -1651,8 +1588,8 @@ async function normalizeContainerReferences(resolved, resolveDefinition, resolve
1651
1588
  issues
1652
1589
  };
1653
1590
  }
1654
- async function normalizeConfigReferences(resolved, resolveDefinition, resolvedExports) {
1655
- return normalizeContainerReferences(await normalizeWorkerReferences(resolved, resolveDefinition), resolveDefinition, resolvedExports);
1591
+ async function normalizeWorkerConfig(resolved, resolveDefinition, containers) {
1592
+ return normalizeContainerReferences(await normalizeWorkerReferences(resolved, resolveDefinition), resolveDefinition, containers);
1656
1593
  }
1657
1594
  function prefixIssues(issues, prefix) {
1658
1595
  return issues.map((issue) => ({
@@ -1660,129 +1597,99 @@ function prefixIssues(issues, prefix) {
1660
1597
  path: [prefix, ...issue.path]
1661
1598
  }));
1662
1599
  }
1663
- function validateUniqueResourceNames(configExports) {
1600
+ function validateUniqueContainerNames(config) {
1664
1601
  const issues = [];
1665
- const exportNameByResourceName = {
1666
- container: /* @__PURE__ */ new Map(),
1667
- worker: /* @__PURE__ */ new Map()
1668
- };
1669
- for (const [exportName, config] of Object.entries(configExports)) {
1670
- if (config.type !== "container" && config.type !== "worker") continue;
1671
- const resourceType = config.type === "container" ? "Container" : "Worker";
1672
- const exportNames = exportNameByResourceName[config.type];
1673
- const previousExportName = exportNames.get(config.name);
1674
- if (previousExportName !== void 0) {
1602
+ const firstIndexByName = /* @__PURE__ */ new Map();
1603
+ for (const [index, container] of config.containers.entries()) {
1604
+ const firstIndex = firstIndexByName.get(container.name);
1605
+ if (firstIndex !== void 0) {
1675
1606
  issues.push({
1676
1607
  code: "custom",
1677
- input: config.name,
1678
- path: [exportName, "name"],
1679
- message: `The ${resourceType} name "${config.name}" is also used by the "${previousExportName}" export. ${resourceType} names must be unique.`
1608
+ input: container.name,
1609
+ path: [
1610
+ "containers",
1611
+ index,
1612
+ "name"
1613
+ ],
1614
+ message: `The Container name "${container.name}" is also used by \`containers[${firstIndex}]\`. Container names must be unique.`
1680
1615
  });
1681
1616
  continue;
1682
1617
  }
1683
- exportNames.set(config.name, exportName);
1618
+ firstIndexByName.set(container.name, index);
1684
1619
  }
1685
1620
  return issues;
1686
1621
  }
1687
- function validateContainerExportLinks(configExports) {
1622
+ function validateContainerLinks(config) {
1688
1623
  const issues = [];
1689
- const containerNames = /* @__PURE__ */ new Set();
1690
- for (const config of Object.values(configExports)) if (config.type === "container") containerNames.add(config.name);
1691
- const firstReferenceByContainerName = /* @__PURE__ */ new Map();
1692
- for (const [workerExportName, config] of Object.entries(configExports)) {
1693
- if (config.type !== "worker") continue;
1694
- for (const [durableObjectExportName, workerExport] of Object.entries(config.exports ?? {})) {
1695
- if (workerExport.type !== "durable-object" || !("container" in workerExport) || workerExport.container === void 0) continue;
1696
- const containerName = workerExport.container;
1697
- const path = [
1698
- workerExportName,
1699
- "exports",
1700
- durableObjectExportName,
1701
- "container"
1702
- ];
1703
- if (!containerNames.has(containerName)) {
1704
- issues.push({
1705
- code: "custom",
1706
- input: containerName,
1707
- path,
1708
- message: `The Container "${containerName}" is not exported from this configuration.`
1709
- });
1710
- continue;
1711
- }
1712
- const firstReference = firstReferenceByContainerName.get(containerName);
1713
- if (firstReference !== void 0) {
1714
- issues.push({
1715
- code: "custom",
1716
- input: containerName,
1717
- path,
1718
- message: `The Container "${containerName}" is already referenced by "${firstReference.workerExportName}.exports.${firstReference.durableObjectExportName}". A Container can only be linked to one Durable Object.`
1719
- });
1720
- continue;
1721
- }
1722
- firstReferenceByContainerName.set(containerName, {
1723
- workerExportName,
1724
- durableObjectExportName
1624
+ const firstExportByContainerName = /* @__PURE__ */ new Map();
1625
+ for (const [exportName, workerExport] of Object.entries(config.worker?.exports ?? {})) {
1626
+ if (workerExport.type !== "durable-object" || !("container" in workerExport) || workerExport.container === void 0) continue;
1627
+ const containerName = workerExport.container;
1628
+ const firstExportName = firstExportByContainerName.get(containerName);
1629
+ if (firstExportName !== void 0) {
1630
+ issues.push({
1631
+ code: "custom",
1632
+ input: containerName,
1633
+ path: [
1634
+ "worker",
1635
+ "exports",
1636
+ exportName,
1637
+ "container"
1638
+ ],
1639
+ message: `The Container "${containerName}" is already referenced by \`worker.exports.${firstExportName}\`. A Container can only be linked to one Durable Object.`
1725
1640
  });
1641
+ continue;
1726
1642
  }
1643
+ firstExportByContainerName.set(containerName, exportName);
1727
1644
  }
1728
1645
  return issues;
1729
1646
  }
1730
- /**
1731
- * Resolve and validate loaded `cloudflare.config.ts` exports.
1732
- *
1733
- * Config inputs are resolved once by identity. Top-level Worker and Container
1734
- * exports are also parsed once by identity. References are resolved only far
1735
- * enough to replace them with resource names, then Container links are
1736
- * validated across the exported resources.
1737
- */
1738
- async function resolveAndValidateConfigExports(exports$2, ctx) {
1647
+ /** Resolve and parse the default configuration export. */
1648
+ async function resolveAndParseConfig(input, ctx) {
1739
1649
  const resolveDefinition = createDefinitionResolver(ctx);
1740
- const parsedResources = /* @__PURE__ */ new Map();
1741
- const resolvedExports = {};
1742
- for (const [name, input] of Object.entries(exports$2)) resolvedExports[name] = await resolveDefinition(input);
1743
- const typeResult = ConfigExportsTypeSchema.safeParse(resolvedExports);
1744
- if (!typeResult.success) return typeResult;
1745
- const issues = [];
1746
- const data = {};
1747
- const resolvedSettings = resolvedExports.settings;
1748
- const settingsResult = resolvedSettings ? InputSettingsSchema.safeParse(resolvedSettings) : void 0;
1749
- if (settingsResult) if (settingsResult.success) data.settings = settingsResult.data;
1750
- else issues.push(...prefixIssues(settingsResult.error.issues, "settings"));
1751
- for (const [name, input] of Object.entries(exports$2)) {
1752
- const resolved = resolvedExports[name];
1753
- if (!isRecord(resolved)) continue;
1754
- if (resolved.type !== "worker" && resolved.type !== "container") continue;
1755
- let result = parsedResources.get(input);
1756
- if (!result) {
1757
- if (resolved.type === "worker") {
1758
- const normalized = await normalizeConfigReferences(resolved, resolveDefinition, resolvedExports);
1759
- issues.push(...prefixIssues(normalized.issues, name));
1760
- result = InputWorkerSchema.safeParse(normalized.value);
1761
- } else result = InputContainerSchema.safeParse(resolved);
1762
- parsedResources.set(input, result);
1763
- if (!result.success) issues.push(...prefixIssues(result.error.issues, name));
1764
- }
1765
- if (result.success) data[name] = result.data;
1766
- }
1767
- issues.push(...validateUniqueResourceNames(data), ...validateContainerExportLinks(data));
1650
+ const resolved = await resolveDefinition(input);
1651
+ if (!isRecord(resolved)) return InputConfigSchema.safeParse(resolved);
1652
+ const containerInputs = Array.isArray(resolved.containers) ? resolved.containers : [];
1653
+ const containers = await Promise.all(containerInputs.map((container) => resolveDefinition(container)));
1654
+ const normalizedWorker = resolved.worker === void 0 ? {
1655
+ value: void 0,
1656
+ issues: []
1657
+ } : await normalizeWorkerConfig(await resolveDefinition(resolved.worker), resolveDefinition, containers);
1658
+ const candidate = {
1659
+ ...resolved,
1660
+ ...resolved.worker === void 0 ? {} : { worker: normalizedWorker.value },
1661
+ ...Array.isArray(resolved.containers) ? { containers } : {}
1662
+ };
1663
+ const result = InputConfigSchema.safeParse(candidate);
1664
+ const issues = [...prefixIssues(normalizedWorker.issues, "worker")];
1665
+ if (!result.success) issues.push(...result.error.issues);
1666
+ else issues.push(...validateUniqueContainerNames(result.data), ...validateContainerLinks(result.data));
1768
1667
  return issues.length > 0 ? {
1769
1668
  success: false,
1770
1669
  error: new z.ZodError(issues)
1771
- } : {
1772
- success: true,
1773
- data
1670
+ } : result;
1671
+ }
1672
+ /** Resolve and parse only the account settings in a configuration definition. */
1673
+ async function resolveAndParseConfigSettings(input, ctx) {
1674
+ const resolved = await createDefinitionResolver(ctx)(input);
1675
+ return InputSettingsSchema.safeParse(resolved);
1676
+ }
1677
+ /** Load and parse `cloudflare.config.ts`'s default export. */
1678
+ async function loadAndParseConfig(configPath, ctx) {
1679
+ const { config, dependencies } = await loadConfig(configPath);
1680
+ return {
1681
+ result: await resolveAndParseConfig(config, ctx),
1682
+ dependencies
1774
1683
  };
1775
1684
  }
1776
- /**
1777
- * Load a `cloudflare.config.ts`, resolve all exports, and validate them.
1778
- */
1779
- async function loadAndValidateConfig(configPath, ctx, options) {
1780
- const { exports: exports$2, dependencies } = await loadConfig(configPath, options);
1685
+ /** Load and parse only account settings from the default export. */
1686
+ async function loadAndParseConfigSettings(configPath, ctx) {
1687
+ const { config, dependencies } = await loadConfig(configPath);
1781
1688
  return {
1782
- result: await resolveAndValidateConfigExports(exports$2, ctx),
1689
+ result: await resolveAndParseConfigSettings(config, ctx),
1783
1690
  dependencies
1784
1691
  };
1785
1692
  }
1786
1693
 
1787
1694
  //#endregion
1788
- export { AnalyticsEngineDatasetBindingSchema, AssetsSchema, BindingSchema, BrowserBindingSchema, D1BindingSchema, DurableObjectCreatedExportSchema, DurableObjectDeletedExportSchema, DurableObjectExpectingTransferExportSchema, DurableObjectRenamedExportSchema, DurableObjectTransferredExportSchema, ExportSchema, FlagshipBindingSchema, HyperdriveBindingSchema, InputContainerSchema, InputSettingsSchema, InputWorkerSchema, KVBindingSchema, KnownBindingSchema, ModuleTypeSchema, OutputContainerSchema, OutputSettingsSchema, OutputWorkerSchema, QueueBindingSchema, R2BindingSchema, TailConsumerSchema, UnsafeBindingSchema, WorkerBindingSchema, WorkerEntrypointExportSchema, bindings, convertToWranglerConfig, defineContainer, defineSettings, defineWorker, exports$1 as exports, generateTypes, getContainerConfigExports, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveAndValidateConfigExports, triggers, validateSingletonBindings };
1695
+ export { AnalyticsEngineDatasetBindingSchema, AssetsSchema, BindingSchema, BrowserBindingSchema, D1BindingSchema, DurableObjectCreatedExportSchema, DurableObjectDeletedExportSchema, DurableObjectExpectingTransferExportSchema, DurableObjectRenamedExportSchema, DurableObjectTransferredExportSchema, ExportSchema, FlagshipBindingSchema, HyperdriveBindingSchema, InputConfigSchema, InputContainerSchema, InputSettingsSchema, InputWorkerSchema, KVBindingSchema, KnownBindingSchema, ModuleTypeSchema, OutputContainerSchema, OutputRootConfigSchema, OutputWorkerSchema, QueueBindingSchema, R2BindingSchema, TailConsumerSchema, UnsafeBindingSchema, WorkerBindingSchema, WorkerEntrypointExportSchema, bindings, convertToWranglerConfig, defineConfig, defineContainer, defineWorker, exports$1 as exports, generateTypes, loadAndParseConfig, loadAndParseConfigSettings, loadConfig, registerConfigHooks, resolveAndParseConfig, resolveAndParseConfigSettings, triggers, validateSingletonBindings };