@cloudflare/config 0.29.0 → 0.29.1
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 +1 -1
- package/dist/index.mjs +48 -50
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -886,7 +886,7 @@ declare const InputSettingsSchema: z.ZodObject<{
|
|
|
886
886
|
}>>;
|
|
887
887
|
}, z.core.$strip>;
|
|
888
888
|
type ParsedInputSettingsConfig = z.output<typeof InputSettingsSchema>;
|
|
889
|
-
/** The resolved,
|
|
889
|
+
/** The resolved project configuration, including relationships between resources. */
|
|
890
890
|
declare const InputConfigSchema: z.ZodObject<{
|
|
891
891
|
worker: z.ZodOptional<z.ZodObject<{
|
|
892
892
|
name: z.ZodString;
|
package/dist/index.mjs
CHANGED
|
@@ -617,12 +617,58 @@ const InputSettingsSchema = z.object({
|
|
|
617
617
|
accountId: z.string().optional(),
|
|
618
618
|
complianceRegion: z.enum(["public", "fedramp-high"]).optional()
|
|
619
619
|
});
|
|
620
|
-
/**
|
|
620
|
+
/** Validate relationships after resource definitions have been resolved to names. */
|
|
621
|
+
function validateInputConfigRelationships(config, ctx) {
|
|
622
|
+
const firstIndexByName = /* @__PURE__ */ new Map();
|
|
623
|
+
for (const [index, container] of config.containers.entries()) {
|
|
624
|
+
const firstIndex = firstIndexByName.get(container.name);
|
|
625
|
+
if (firstIndex !== void 0) {
|
|
626
|
+
ctx.addIssue({
|
|
627
|
+
code: "custom",
|
|
628
|
+
path: [
|
|
629
|
+
"containers",
|
|
630
|
+
index,
|
|
631
|
+
"name"
|
|
632
|
+
],
|
|
633
|
+
message: `The Container name "${container.name}" is also used by \`containers[${firstIndex}]\`. Container names must be unique.`
|
|
634
|
+
});
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
firstIndexByName.set(container.name, index);
|
|
638
|
+
}
|
|
639
|
+
const firstExportByContainerName = /* @__PURE__ */ new Map();
|
|
640
|
+
for (const [exportName, workerExport] of Object.entries(config.worker?.exports ?? {})) {
|
|
641
|
+
if (workerExport.type !== "durable-object" || !("container" in workerExport) || workerExport.container === void 0) continue;
|
|
642
|
+
const containerName = workerExport.container;
|
|
643
|
+
const issuePath = [
|
|
644
|
+
"worker",
|
|
645
|
+
"exports",
|
|
646
|
+
exportName,
|
|
647
|
+
"container"
|
|
648
|
+
];
|
|
649
|
+
if (!firstIndexByName.has(containerName)) ctx.addIssue({
|
|
650
|
+
code: "custom",
|
|
651
|
+
path: issuePath,
|
|
652
|
+
message: `The referenced Container "${containerName}" is not included in the \`containers\` array.`
|
|
653
|
+
});
|
|
654
|
+
const firstExportName = firstExportByContainerName.get(containerName);
|
|
655
|
+
if (firstExportName !== void 0) {
|
|
656
|
+
ctx.addIssue({
|
|
657
|
+
code: "custom",
|
|
658
|
+
path: issuePath,
|
|
659
|
+
message: `The Container "${containerName}" is already referenced by \`worker.exports.${firstExportName}\`. A Container can only be linked to one Durable Object.`
|
|
660
|
+
});
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
firstExportByContainerName.set(containerName, exportName);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
/** The resolved project configuration, including relationships between resources. */
|
|
621
667
|
const InputConfigSchema = z.strictObject({
|
|
622
668
|
...InputSettingsSchema.shape,
|
|
623
669
|
worker: InputWorkerSchema.optional(),
|
|
624
670
|
containers: z.array(InputContainerSchema).default([])
|
|
625
|
-
});
|
|
671
|
+
}).superRefine(validateInputConfigRelationships);
|
|
626
672
|
const BuildContextSchema = z.strictObject({
|
|
627
673
|
isPreview: z.boolean(),
|
|
628
674
|
mode: z.string().optional()
|
|
@@ -1713,53 +1759,6 @@ function prefixIssues(issues, prefix) {
|
|
|
1713
1759
|
path: [prefix, ...issue.path]
|
|
1714
1760
|
}));
|
|
1715
1761
|
}
|
|
1716
|
-
function validateUniqueContainerNames(config) {
|
|
1717
|
-
const issues = [];
|
|
1718
|
-
const firstIndexByName = /* @__PURE__ */ new Map();
|
|
1719
|
-
for (const [index, container] of config.containers.entries()) {
|
|
1720
|
-
const firstIndex = firstIndexByName.get(container.name);
|
|
1721
|
-
if (firstIndex !== void 0) {
|
|
1722
|
-
issues.push({
|
|
1723
|
-
code: "custom",
|
|
1724
|
-
input: container.name,
|
|
1725
|
-
path: [
|
|
1726
|
-
"containers",
|
|
1727
|
-
index,
|
|
1728
|
-
"name"
|
|
1729
|
-
],
|
|
1730
|
-
message: `The Container name "${container.name}" is also used by \`containers[${firstIndex}]\`. Container names must be unique.`
|
|
1731
|
-
});
|
|
1732
|
-
continue;
|
|
1733
|
-
}
|
|
1734
|
-
firstIndexByName.set(container.name, index);
|
|
1735
|
-
}
|
|
1736
|
-
return issues;
|
|
1737
|
-
}
|
|
1738
|
-
function validateContainerLinks(config) {
|
|
1739
|
-
const issues = [];
|
|
1740
|
-
const firstExportByContainerName = /* @__PURE__ */ new Map();
|
|
1741
|
-
for (const [exportName, workerExport] of Object.entries(config.worker?.exports ?? {})) {
|
|
1742
|
-
if (workerExport.type !== "durable-object" || !("container" in workerExport) || workerExport.container === void 0) continue;
|
|
1743
|
-
const containerName = workerExport.container;
|
|
1744
|
-
const firstExportName = firstExportByContainerName.get(containerName);
|
|
1745
|
-
if (firstExportName !== void 0) {
|
|
1746
|
-
issues.push({
|
|
1747
|
-
code: "custom",
|
|
1748
|
-
input: containerName,
|
|
1749
|
-
path: [
|
|
1750
|
-
"worker",
|
|
1751
|
-
"exports",
|
|
1752
|
-
exportName,
|
|
1753
|
-
"container"
|
|
1754
|
-
],
|
|
1755
|
-
message: `The Container "${containerName}" is already referenced by \`worker.exports.${firstExportName}\`. A Container can only be linked to one Durable Object.`
|
|
1756
|
-
});
|
|
1757
|
-
continue;
|
|
1758
|
-
}
|
|
1759
|
-
firstExportByContainerName.set(containerName, exportName);
|
|
1760
|
-
}
|
|
1761
|
-
return issues;
|
|
1762
|
-
}
|
|
1763
1762
|
/** Resolve and parse the default configuration export. */
|
|
1764
1763
|
async function resolveAndParseConfig(input, ctx) {
|
|
1765
1764
|
const resolveDefinition = createDefinitionResolver(ctx);
|
|
@@ -1779,7 +1778,6 @@ async function resolveAndParseConfig(input, ctx) {
|
|
|
1779
1778
|
const result = InputConfigSchema.safeParse(candidate);
|
|
1780
1779
|
const issues = [...prefixIssues(normalizedWorker.issues, "worker")];
|
|
1781
1780
|
if (!result.success) issues.push(...result.error.issues);
|
|
1782
|
-
else issues.push(...validateUniqueContainerNames(result.data), ...validateContainerLinks(result.data));
|
|
1783
1781
|
return issues.length > 0 ? {
|
|
1784
1782
|
success: false,
|
|
1785
1783
|
error: new z.ZodError(issues)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/config",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.1",
|
|
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.6.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cloudflare/workers-types": "^5.
|
|
34
|
+
"@cloudflare/workers-types": "^5.20261101.1",
|
|
35
35
|
"ts-dedent": "^2.2.0",
|
|
36
36
|
"tsdown": "0.16.3",
|
|
37
37
|
"typescript": "5.8.3",
|
|
38
38
|
"vitest": "5.0.4",
|
|
39
|
-
"@cloudflare/workers-
|
|
40
|
-
"@cloudflare/workers-
|
|
39
|
+
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
40
|
+
"@cloudflare/workers-utils": "0.50.2"
|
|
41
41
|
},
|
|
42
42
|
"workers-sdk": {
|
|
43
43
|
"prerelease": true
|