wrangler 0.0.0-e7a0cd5b → 0.0.0-e7cf0caa
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/README.md +3 -3
- package/bin/wrangler.js +30 -10
- package/miniflare-dist/index.mjs +126 -74
- package/package.json +27 -19
- package/src/__tests__/api-dev.test.ts +65 -36
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +567 -86
- package/src/__tests__/d1/d1.test.ts +82 -0
- package/src/__tests__/d1/execute.test.ts +66 -0
- package/src/__tests__/d1/migrate.test.ts +157 -0
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +91 -49
- package/src/__tests__/deployments.test.ts +330 -56
- package/src/__tests__/dev.test.tsx +198 -90
- package/src/__tests__/generate.test.ts +12 -10
- package/src/__tests__/guess-worker-format.test.ts +35 -0
- package/src/__tests__/helpers/end-event-loop.ts +6 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/mock-dialogs.ts +71 -85
- package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
- package/src/__tests__/helpers/mock-known-routes.ts +7 -2
- package/src/__tests__/helpers/mock-kv.ts +29 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +103 -92
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +128 -27
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
- package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
- package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
- package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
- package/src/__tests__/helpers/msw/index.ts +32 -1
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +90 -72
- package/src/__tests__/init.test.ts +927 -631
- package/src/__tests__/jest.setup.ts +19 -42
- package/src/__tests__/kv.test.ts +355 -231
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +94 -51
- package/src/__tests__/middleware.scheduled.test.ts +42 -32
- package/src/__tests__/middleware.test.ts +212 -122
- package/src/__tests__/mtls-certificates.test.ts +588 -0
- package/src/__tests__/pages/deployment-list.test.ts +80 -0
- package/src/__tests__/pages/functions-build.test.ts +452 -0
- package/src/__tests__/pages/pages.test.ts +81 -0
- package/src/__tests__/pages/project-create.test.ts +63 -0
- package/src/__tests__/pages/project-list.test.ts +110 -0
- package/src/__tests__/pages/project-upload.test.ts +500 -0
- package/src/__tests__/pages/publish.test.ts +2864 -0
- package/src/__tests__/pages-deployment-tail.test.ts +955 -0
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +1615 -852
- package/src/__tests__/pubsub.test.ts +226 -100
- package/src/__tests__/queues.test.ts +238 -77
- package/src/__tests__/r2.test.ts +55 -57
- package/src/__tests__/secret.test.ts +179 -130
- package/src/__tests__/tail.test.ts +267 -109
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +43 -26
- package/src/__tests__/user.test.ts +35 -72
- package/src/__tests__/whoami.test.tsx +8 -114
- package/src/__tests__/worker-namespace.test.ts +83 -69
- package/src/api/dev.ts +168 -60
- package/src/api/index.ts +10 -1
- package/src/api/mtls-certificate.ts +148 -0
- package/src/api/pages/create-worker-bundle-contents.ts +76 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +355 -0
- package/src/bundle.ts +263 -140
- package/src/cfetch/index.ts +0 -2
- package/src/cfetch/internal.ts +16 -21
- package/src/cli.ts +4 -4
- package/src/config/config.ts +14 -7
- package/src/config/environment.ts +79 -24
- package/src/config/index.ts +99 -38
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +248 -19
- package/src/create-worker-preview.ts +19 -8
- package/src/create-worker-upload-form.ts +60 -22
- package/src/d1/backups.tsx +43 -42
- package/src/d1/constants.ts +2 -0
- package/src/d1/create.tsx +44 -30
- package/src/d1/{delete.tsx → delete.ts} +11 -14
- package/src/d1/execute.tsx +209 -151
- package/src/d1/index.ts +31 -7
- package/src/d1/list.tsx +22 -10
- package/src/d1/migrations/apply.tsx +212 -0
- package/src/d1/migrations/create.tsx +79 -0
- package/src/d1/migrations/helpers.ts +172 -0
- package/src/d1/migrations/index.ts +3 -0
- package/src/d1/migrations/list.tsx +95 -0
- package/src/d1/migrations/options.ts +23 -0
- package/src/d1/options.ts +12 -2
- package/src/d1/splitter.ts +161 -0
- package/src/d1/{types.tsx → types.ts} +11 -0
- package/src/d1/utils.ts +12 -2
- package/src/delete.ts +8 -16
- package/src/deployments.ts +340 -46
- package/src/deprecated/index.ts +8 -302
- package/src/dev/dev.tsx +57 -44
- package/src/dev/local.tsx +294 -91
- package/src/dev/remote.tsx +32 -3
- package/src/dev/start-server.ts +89 -68
- package/src/dev/use-esbuild.ts +17 -18
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/{dev-registry.tsx → dev-registry.ts} +2 -1
- package/src/dev.tsx +178 -118
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +21 -17
- package/src/docs/index.ts +97 -0
- package/src/entry.ts +19 -11
- package/src/environment-variables/factory.ts +88 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +298 -0
- package/src/git-client.ts +15 -4
- package/src/{index.tsx → index.ts} +137 -63
- package/src/init.ts +249 -187
- package/src/inspect.ts +16 -1
- package/src/jest.d.ts +4 -0
- package/src/kv/index.ts +15 -17
- package/src/logger.ts +32 -5
- package/src/metrics/metrics-config.ts +3 -3
- package/src/metrics/send-event.ts +6 -1
- package/src/miniflare-cli/assets.ts +64 -28
- package/src/miniflare-cli/index.ts +4 -7
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +91 -25
- package/src/mtls-certificate/cli.ts +155 -0
- package/src/pages/build.ts +410 -0
- package/src/pages/buildFunctions.ts +140 -0
- package/src/pages/deployment-tails.ts +281 -0
- package/src/pages/deployments.tsx +11 -33
- package/src/pages/{dev.tsx → dev.ts} +147 -124
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +72 -69
- package/src/pages/functions/buildWorker.ts +249 -114
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/{functions.tsx → functions.ts} +8 -4
- package/src/pages/{index.tsx → index.ts} +11 -3
- package/src/pages/projects.tsx +12 -22
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +45 -214
- package/src/pages/types.ts +6 -9
- package/src/pages/upload.tsx +58 -14
- package/src/pages/utils.ts +14 -3
- package/src/parse.ts +23 -1
- package/src/paths.ts +1 -1
- package/src/proxy.ts +5 -0
- package/src/publish/index.ts +20 -16
- package/src/publish/publish.ts +72 -47
- package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +19 -20
- package/src/queues/cli/commands/consumer/add.ts +24 -24
- package/src/queues/cli/commands/consumer/index.ts +3 -6
- package/src/queues/cli/commands/consumer/remove.ts +11 -18
- package/src/queues/cli/commands/create.ts +8 -8
- package/src/queues/cli/commands/delete.ts +8 -8
- package/src/queues/cli/commands/index.ts +6 -4
- package/src/queues/cli/commands/list.ts +8 -8
- package/src/queues/client.ts +1 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +1 -0
- package/src/r2/index.ts +40 -28
- package/src/secret/index.ts +14 -17
- package/src/{sites.tsx → sites.ts} +1 -1
- package/src/tail/createTail.ts +94 -3
- package/src/tail/filters.ts +1 -1
- package/src/tail/index.ts +8 -11
- package/src/tail/printing.ts +15 -0
- package/src/traverse-module-graph.ts +53 -0
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +79 -57
- package/src/user/access.ts +0 -1
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -31
- package/src/user/index.ts +0 -1
- package/src/user/{user.tsx → user.ts} +123 -82
- package/src/utils/render.ts +93 -0
- package/src/{whoami.tsx → whoami.ts} +37 -71
- package/src/worker.ts +35 -3
- package/src/yargs-types.ts +22 -5
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/checked-fetch.js +9 -3
- package/templates/d1-beta-facade.js +95 -25
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +4 -3
- package/templates/format-dev-errors.ts +8 -6
- package/templates/gitignore +1 -0
- package/templates/init-tests/test-jest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/loader-modules.ts +2 -2
- package/templates/middleware/loader-sw.ts +51 -31
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/new-worker.ts +3 -0
- package/templates/pages-dev-pipeline.ts +4 -1
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +19 -10
- package/templates/serve-static-assets.ts +17 -14
- package/templates/service-bindings-module-facade.js +1 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +105 -0
- package/templates/tsconfig.json +5 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +826 -77
- package/wrangler-dist/cli.js +130734 -140838
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/api-devregistry.test.js +0 -57
- package/src/__tests__/d1.test.ts +0 -72
- package/src/__tests__/dialogs.test.tsx +0 -40
- package/src/__tests__/helpers/mock-cfetch.ts +0 -333
- package/src/__tests__/pages.test.ts +0 -2223
- package/src/dialogs.tsx +0 -163
- package/src/environment-variables.ts +0 -50
- package/src/pages/build.tsx +0 -238
- package/src/user/env-vars.ts +0 -46
- package/templates/experimental-local-cache-stubs.js +0 -27
- /package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
- /package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
- /package/src/pages/{hash.tsx → hash.ts} +0 -0
|
@@ -40,6 +40,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
40
40
|
jsx_fragment: "React.Fragment",
|
|
41
41
|
tsconfig: undefined,
|
|
42
42
|
kv_namespaces: [],
|
|
43
|
+
send_email: [],
|
|
43
44
|
legacy_env: true,
|
|
44
45
|
logfwdr: {
|
|
45
46
|
bindings: [],
|
|
@@ -55,6 +56,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
55
56
|
},
|
|
56
57
|
r2_buckets: [],
|
|
57
58
|
services: [],
|
|
59
|
+
analytics_engine_datasets: [],
|
|
58
60
|
route: undefined,
|
|
59
61
|
routes: undefined,
|
|
60
62
|
rules: [],
|
|
@@ -64,12 +66,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
64
66
|
crons: [],
|
|
65
67
|
},
|
|
66
68
|
unsafe: {
|
|
67
|
-
bindings:
|
|
69
|
+
bindings: undefined,
|
|
70
|
+
metadata: undefined,
|
|
68
71
|
},
|
|
69
72
|
dispatch_namespaces: [],
|
|
73
|
+
mtls_certificates: [],
|
|
70
74
|
usage_model: undefined,
|
|
71
75
|
vars: {},
|
|
72
|
-
metadata_binding: undefined,
|
|
73
76
|
define: {},
|
|
74
77
|
wasm_modules: undefined,
|
|
75
78
|
data_blobs: undefined,
|
|
@@ -901,6 +904,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
901
904
|
preview_id: "KV_PREVIEW_1",
|
|
902
905
|
},
|
|
903
906
|
],
|
|
907
|
+
send_email: [
|
|
908
|
+
{ name: "SEB_TARGET", destination_address: "teste@example.com" },
|
|
909
|
+
{ name: "SEB_UNRESTRICTED" },
|
|
910
|
+
{
|
|
911
|
+
name: "SEB_ALLOWLIST",
|
|
912
|
+
allowed_destination_addresses: [
|
|
913
|
+
"email1@example.com",
|
|
914
|
+
"email2@example.com",
|
|
915
|
+
],
|
|
916
|
+
},
|
|
917
|
+
],
|
|
904
918
|
r2_buckets: [
|
|
905
919
|
{ binding: "R2_BINDING_1", bucket_name: "R2_BUCKET_1" },
|
|
906
920
|
{
|
|
@@ -916,6 +930,15 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
916
930
|
environment: "SERVICE_BINDING_ENVIRONMENT_1",
|
|
917
931
|
},
|
|
918
932
|
],
|
|
933
|
+
analytics_engine_datasets: [
|
|
934
|
+
{
|
|
935
|
+
binding: "AE_BINDING_1",
|
|
936
|
+
dataset: "DATASET_1",
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
binding: "AE_BINDING_2",
|
|
940
|
+
},
|
|
941
|
+
],
|
|
919
942
|
unsafe: {
|
|
920
943
|
bindings: [
|
|
921
944
|
{ name: "UNSAFE_BINDING_1", type: "UNSAFE_TYPE_1" },
|
|
@@ -925,6 +948,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
925
948
|
extra: "UNSAFE_EXTRA_1",
|
|
926
949
|
},
|
|
927
950
|
],
|
|
951
|
+
metadata: undefined,
|
|
928
952
|
},
|
|
929
953
|
no_bundle: true,
|
|
930
954
|
minify: true,
|
|
@@ -1617,6 +1641,39 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1617
1641
|
});
|
|
1618
1642
|
});
|
|
1619
1643
|
|
|
1644
|
+
it("should error if send_email.bindings are not valid", () => {
|
|
1645
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
1646
|
+
{
|
|
1647
|
+
send_email: [
|
|
1648
|
+
{},
|
|
1649
|
+
{ binding: "VALID" },
|
|
1650
|
+
{ name: "SEB", destination_address: 123 },
|
|
1651
|
+
{
|
|
1652
|
+
name: "SEB2",
|
|
1653
|
+
allowed_destination_addresses: 123,
|
|
1654
|
+
},
|
|
1655
|
+
{
|
|
1656
|
+
name: "SEB3",
|
|
1657
|
+
destination_address: "email@example.com",
|
|
1658
|
+
allowed_destination_addresses: ["email@example.com"],
|
|
1659
|
+
},
|
|
1660
|
+
],
|
|
1661
|
+
} as unknown as RawConfig,
|
|
1662
|
+
undefined,
|
|
1663
|
+
{ env: undefined }
|
|
1664
|
+
);
|
|
1665
|
+
|
|
1666
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1667
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1668
|
+
"Processing wrangler configuration:
|
|
1669
|
+
- \\"send_email[0]\\" bindings should have a string \\"name\\" field but got {}.
|
|
1670
|
+
- \\"send_email[1]\\" bindings should have a string \\"name\\" field but got {\\"binding\\":\\"VALID\\"}.
|
|
1671
|
+
- \\"send_email[2]\\" bindings should, optionally, have a string \\"destination_address\\" field but got {\\"name\\":\\"SEB\\",\\"destination_address\\":123}.
|
|
1672
|
+
- \\"send_email[3]\\" bindings should, optionally, have a []string \\"allowed_destination_addresses\\" field but got {\\"name\\":\\"SEB2\\",\\"allowed_destination_addresses\\":123}.
|
|
1673
|
+
- \\"send_email[4]\\" bindings should have either a \\"destination_address\\" or \\"allowed_destination_addresses\\" field, but not both."
|
|
1674
|
+
`);
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1620
1677
|
describe("[d1_databases]", () => {
|
|
1621
1678
|
it("should error if d1_databases is an object", () => {
|
|
1622
1679
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
@@ -1779,6 +1836,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1779
1836
|
max_batch_timeout: null,
|
|
1780
1837
|
max_retries: "hello",
|
|
1781
1838
|
dead_letter_queue: 5,
|
|
1839
|
+
max_concurrency: "hello",
|
|
1782
1840
|
},
|
|
1783
1841
|
],
|
|
1784
1842
|
},
|
|
@@ -1794,20 +1852,21 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1794
1852
|
);
|
|
1795
1853
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1796
1854
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1855
|
+
"Processing wrangler configuration:
|
|
1856
|
+
- Unexpected fields found in queues field: \\"invalidField\\"
|
|
1857
|
+
- Unexpected fields found in queues.consumers[2] field: \\"invalidField\\""
|
|
1858
|
+
`);
|
|
1801
1859
|
|
|
1802
1860
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1861
|
+
"Processing wrangler configuration:
|
|
1862
|
+
- \\"queues.consumers[0]\\" should have a string \\"queue\\" field but got {}.
|
|
1863
|
+
- \\"queues.consumers[1]\\" should have a string \\"queue\\" field but got {\\"queue\\":22}.
|
|
1864
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_batch_size\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1865
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_batch_timeout\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1866
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_retries\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1867
|
+
- \\"queues.consumers[3]\\" should, optionally, have a string \\"dead_letter_queue\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1868
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_concurrency\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}."
|
|
1869
|
+
`);
|
|
1811
1870
|
});
|
|
1812
1871
|
});
|
|
1813
1872
|
|
|
@@ -2029,28 +2088,93 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2029
2088
|
});
|
|
2030
2089
|
});
|
|
2031
2090
|
|
|
2032
|
-
describe("[
|
|
2033
|
-
it("should
|
|
2091
|
+
describe("[analytics_engine_datasets]", () => {
|
|
2092
|
+
it("should error if analytics_engine_datasets is an object", () => {
|
|
2093
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2094
|
+
{ analytics_engine_datasets: {} } as unknown as RawConfig,
|
|
2095
|
+
undefined,
|
|
2096
|
+
{ env: undefined }
|
|
2097
|
+
);
|
|
2098
|
+
|
|
2099
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2100
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2101
|
+
"Processing wrangler configuration:
|
|
2102
|
+
- The field \\"analytics_engine_datasets\\" should be an array but got {}."
|
|
2103
|
+
`);
|
|
2104
|
+
});
|
|
2105
|
+
|
|
2106
|
+
it("should error if analytics_engine_datasets is a string", () => {
|
|
2107
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2108
|
+
{ analytics_engine_datasets: "BAD" } as unknown as RawConfig,
|
|
2109
|
+
undefined,
|
|
2110
|
+
{ env: undefined }
|
|
2111
|
+
);
|
|
2112
|
+
|
|
2113
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2114
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2115
|
+
"Processing wrangler configuration:
|
|
2116
|
+
- The field \\"analytics_engine_datasets\\" should be an array but got \\"BAD\\"."
|
|
2117
|
+
`);
|
|
2118
|
+
});
|
|
2119
|
+
|
|
2120
|
+
it("should error if analytics_engine_datasets is a number", () => {
|
|
2121
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2122
|
+
{ analytics_engine_datasets: 999 } as unknown as RawConfig,
|
|
2123
|
+
undefined,
|
|
2124
|
+
{ env: undefined }
|
|
2125
|
+
);
|
|
2126
|
+
|
|
2127
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2128
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2129
|
+
"Processing wrangler configuration:
|
|
2130
|
+
- The field \\"analytics_engine_datasets\\" should be an array but got 999."
|
|
2131
|
+
`);
|
|
2132
|
+
});
|
|
2133
|
+
|
|
2134
|
+
it("should error if analytics_engine_datasets is null", () => {
|
|
2135
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2136
|
+
{ analytics_engine_datasets: null } as unknown as RawConfig,
|
|
2137
|
+
undefined,
|
|
2138
|
+
{ env: undefined }
|
|
2139
|
+
);
|
|
2140
|
+
|
|
2141
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2142
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2143
|
+
"Processing wrangler configuration:
|
|
2144
|
+
- The field \\"analytics_engine_datasets\\" should be an array but got null."
|
|
2145
|
+
`);
|
|
2146
|
+
});
|
|
2147
|
+
|
|
2148
|
+
it("should error if analytics_engine_datasets.bindings are not valid", () => {
|
|
2034
2149
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
2035
2150
|
{
|
|
2036
|
-
|
|
2151
|
+
analytics_engine_datasets: [
|
|
2152
|
+
{},
|
|
2153
|
+
{ binding: 2333, dataset: 2444 },
|
|
2037
2154
|
{
|
|
2038
|
-
binding: "
|
|
2039
|
-
|
|
2155
|
+
binding: "AE_BINDING_2",
|
|
2156
|
+
dataset: 2555,
|
|
2040
2157
|
},
|
|
2158
|
+
{ binding: "AE_BINDING_1", dataset: "" },
|
|
2041
2159
|
],
|
|
2042
2160
|
} as unknown as RawConfig,
|
|
2043
2161
|
undefined,
|
|
2044
2162
|
{ env: undefined }
|
|
2045
2163
|
);
|
|
2046
|
-
|
|
2047
|
-
expect(diagnostics.
|
|
2048
|
-
expect(diagnostics.
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2164
|
+
|
|
2165
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2166
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2167
|
+
"Processing wrangler configuration:
|
|
2168
|
+
- \\"analytics_engine_datasets[0]\\" bindings should have a string \\"binding\\" field but got {}.
|
|
2169
|
+
- \\"analytics_engine_datasets[1]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":2333,\\"dataset\\":2444}.
|
|
2170
|
+
- \\"analytics_engine_datasets[1]\\" bindings should, optionally, have a string \\"dataset\\" field but got {\\"binding\\":2333,\\"dataset\\":2444}.
|
|
2171
|
+
- \\"analytics_engine_datasets[2]\\" bindings should, optionally, have a string \\"dataset\\" field but got {\\"binding\\":\\"AE_BINDING_2\\",\\"dataset\\":2555}.
|
|
2172
|
+
- \\"analytics_engine_datasets[3]\\" bindings should, optionally, have a string \\"dataset\\" field but got {\\"binding\\":\\"AE_BINDING_1\\",\\"dataset\\":\\"\\"}."
|
|
2173
|
+
`);
|
|
2052
2174
|
});
|
|
2175
|
+
});
|
|
2053
2176
|
|
|
2177
|
+
describe("[dispatch_namespaces]", () => {
|
|
2054
2178
|
it("should error if dispatch_namespaces is not an array", () => {
|
|
2055
2179
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
2056
2180
|
{
|
|
@@ -2060,12 +2184,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2060
2184
|
{ env: undefined }
|
|
2061
2185
|
);
|
|
2062
2186
|
|
|
2063
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
2187
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2064
2188
|
expect(diagnostics.hasErrors()).toBe(true);
|
|
2065
|
-
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2066
|
-
"Processing wrangler configuration:
|
|
2067
|
-
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time."
|
|
2068
|
-
`);
|
|
2069
2189
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2070
2190
|
"Processing wrangler configuration:
|
|
2071
2191
|
- The field \\"dispatch_namespaces\\" should be an array but got \\"just a string\\"."
|
|
@@ -2104,12 +2224,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2104
2224
|
undefined,
|
|
2105
2225
|
{ env: undefined }
|
|
2106
2226
|
);
|
|
2107
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
2227
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2108
2228
|
expect(diagnostics.hasErrors()).toBe(true);
|
|
2109
|
-
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2110
|
-
"Processing wrangler configuration:
|
|
2111
|
-
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time."
|
|
2112
|
-
`);
|
|
2113
2229
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2114
2230
|
"Processing wrangler configuration:
|
|
2115
2231
|
- \\"dispatch_namespaces[0]\\" binding should be objects, but got \\"a string\\"
|
|
@@ -2124,6 +2240,75 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2124
2240
|
});
|
|
2125
2241
|
});
|
|
2126
2242
|
|
|
2243
|
+
describe("[mtls_certificates]", () => {
|
|
2244
|
+
it("should error if mtls_certificates is not an array", () => {
|
|
2245
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2246
|
+
{
|
|
2247
|
+
mtls_certificates: "just a string",
|
|
2248
|
+
} as unknown as RawConfig,
|
|
2249
|
+
undefined,
|
|
2250
|
+
{ env: undefined }
|
|
2251
|
+
);
|
|
2252
|
+
|
|
2253
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2254
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
2255
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2256
|
+
"Processing wrangler configuration:
|
|
2257
|
+
- The field \\"mtls_certificates\\" should be an array but got \\"just a string\\"."
|
|
2258
|
+
`);
|
|
2259
|
+
});
|
|
2260
|
+
|
|
2261
|
+
it("should error on non valid mtls_certificates", () => {
|
|
2262
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2263
|
+
{
|
|
2264
|
+
mtls_certificates: [
|
|
2265
|
+
"a string",
|
|
2266
|
+
123,
|
|
2267
|
+
false,
|
|
2268
|
+
{
|
|
2269
|
+
binding: 123,
|
|
2270
|
+
namespace: 123,
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
binding: "CERT_ONE",
|
|
2274
|
+
id: "1234",
|
|
2275
|
+
},
|
|
2276
|
+
{
|
|
2277
|
+
binding: "CERT_TWO",
|
|
2278
|
+
certificate_id: 1234,
|
|
2279
|
+
},
|
|
2280
|
+
// this one is valid
|
|
2281
|
+
{
|
|
2282
|
+
binding: "CERT_THREE",
|
|
2283
|
+
certificate_id: "1234",
|
|
2284
|
+
},
|
|
2285
|
+
{
|
|
2286
|
+
binding: true,
|
|
2287
|
+
service: "1234",
|
|
2288
|
+
},
|
|
2289
|
+
],
|
|
2290
|
+
} as unknown as RawConfig,
|
|
2291
|
+
undefined,
|
|
2292
|
+
{ env: undefined }
|
|
2293
|
+
);
|
|
2294
|
+
|
|
2295
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2296
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
2297
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2298
|
+
"Processing wrangler configuration:
|
|
2299
|
+
- \\"mtls_certificates\\" bindings should be objects, but got \\"a string\\"
|
|
2300
|
+
- \\"mtls_certificates\\" bindings should be objects, but got 123
|
|
2301
|
+
- \\"mtls_certificates\\" bindings should be objects, but got false
|
|
2302
|
+
- \\"mtls_certificates[3]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":123}.
|
|
2303
|
+
- \\"mtls_certificates[3]\\" bindings should have a string \\"certificate_id\\" field but got {\\"binding\\":123,\\"namespace\\":123}.
|
|
2304
|
+
- \\"mtls_certificates[4]\\" bindings should have a string \\"certificate_id\\" field but got {\\"binding\\":\\"CERT_ONE\\",\\"id\\":\\"1234\\"}.
|
|
2305
|
+
- \\"mtls_certificates[5]\\" bindings should have a string \\"certificate_id\\" field but got {\\"binding\\":\\"CERT_TWO\\",\\"certificate_id\\":1234}.
|
|
2306
|
+
- \\"mtls_certificates[7]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":true,\\"service\\":\\"1234\\"}.
|
|
2307
|
+
- \\"mtls_certificates[7]\\" bindings should have a string \\"certificate_id\\" field but got {\\"binding\\":true,\\"service\\":\\"1234\\"}."
|
|
2308
|
+
`);
|
|
2309
|
+
});
|
|
2310
|
+
});
|
|
2311
|
+
|
|
2127
2312
|
describe("[unsafe.bindings]", () => {
|
|
2128
2313
|
it("should error if unsafe is an array", () => {
|
|
2129
2314
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
@@ -2193,7 +2378,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2193
2378
|
`);
|
|
2194
2379
|
});
|
|
2195
2380
|
|
|
2196
|
-
it("should error if unsafe.bindings
|
|
2381
|
+
it("should error if neither unsafe.bindings nor unsafe.metadata are defined", () => {
|
|
2197
2382
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
2198
2383
|
{ unsafe: {} } as unknown as RawConfig,
|
|
2199
2384
|
undefined,
|
|
@@ -2205,9 +2390,37 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2205
2390
|
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2206
2391
|
`);
|
|
2207
2392
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2393
|
+
"Processing wrangler configuration:
|
|
2394
|
+
- The field \\"unsafe\\" should contain at least one of \\"bindings\\" or \\"metadata\\" properties but got {}."
|
|
2395
|
+
`);
|
|
2396
|
+
});
|
|
2397
|
+
|
|
2398
|
+
it("should not error if at least unsafe.bindings is defined", () => {
|
|
2399
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2400
|
+
{ unsafe: { bindings: [] } } as unknown as RawConfig,
|
|
2401
|
+
undefined,
|
|
2402
|
+
{ env: undefined }
|
|
2403
|
+
);
|
|
2404
|
+
|
|
2405
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2208
2406
|
"Processing wrangler configuration:
|
|
2209
|
-
-
|
|
2407
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2408
|
+
`);
|
|
2409
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
2410
|
+
});
|
|
2411
|
+
|
|
2412
|
+
it("should not error if at least unsafe.metadata is defined", () => {
|
|
2413
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2414
|
+
{ unsafe: { metadata: {} } } as unknown as RawConfig,
|
|
2415
|
+
undefined,
|
|
2416
|
+
{ env: undefined }
|
|
2417
|
+
);
|
|
2418
|
+
|
|
2419
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2420
|
+
"Processing wrangler configuration:
|
|
2421
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2210
2422
|
`);
|
|
2423
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
2211
2424
|
});
|
|
2212
2425
|
|
|
2213
2426
|
it("should error if unsafe.bindings is an object", () => {
|
|
@@ -2317,6 +2530,74 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2317
2530
|
- binding should have a string \\"type\\" field."
|
|
2318
2531
|
`);
|
|
2319
2532
|
});
|
|
2533
|
+
|
|
2534
|
+
it("should error if unsafe.metadata is an array", () => {
|
|
2535
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2536
|
+
{ unsafe: { metadata: [] } } as unknown as RawConfig,
|
|
2537
|
+
undefined,
|
|
2538
|
+
{ env: undefined }
|
|
2539
|
+
);
|
|
2540
|
+
|
|
2541
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2542
|
+
"Processing wrangler configuration:
|
|
2543
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2544
|
+
`);
|
|
2545
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2546
|
+
"Processing wrangler configuration:
|
|
2547
|
+
- The field \\"unsafe.metadata\\" should be an object but got []."
|
|
2548
|
+
`);
|
|
2549
|
+
});
|
|
2550
|
+
|
|
2551
|
+
it("should error if unsafe.metadata is a string", () => {
|
|
2552
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2553
|
+
{ unsafe: { metadata: "BAD" } } as unknown as RawConfig,
|
|
2554
|
+
undefined,
|
|
2555
|
+
{ env: undefined }
|
|
2556
|
+
);
|
|
2557
|
+
|
|
2558
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2559
|
+
"Processing wrangler configuration:
|
|
2560
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2561
|
+
`);
|
|
2562
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2563
|
+
"Processing wrangler configuration:
|
|
2564
|
+
- The field \\"unsafe.metadata\\" should be an object but got \\"BAD\\"."
|
|
2565
|
+
`);
|
|
2566
|
+
});
|
|
2567
|
+
|
|
2568
|
+
it("should error if unsafe.metadata is a number", () => {
|
|
2569
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2570
|
+
{ unsafe: { metadata: 999 } } as unknown as RawConfig,
|
|
2571
|
+
undefined,
|
|
2572
|
+
{ env: undefined }
|
|
2573
|
+
);
|
|
2574
|
+
|
|
2575
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2576
|
+
"Processing wrangler configuration:
|
|
2577
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2578
|
+
`);
|
|
2579
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2580
|
+
"Processing wrangler configuration:
|
|
2581
|
+
- The field \\"unsafe.metadata\\" should be an object but got 999."
|
|
2582
|
+
`);
|
|
2583
|
+
});
|
|
2584
|
+
|
|
2585
|
+
it("should error if unsafe.metadata is null", () => {
|
|
2586
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2587
|
+
{ unsafe: { metadata: null } } as unknown as RawConfig,
|
|
2588
|
+
undefined,
|
|
2589
|
+
{ env: undefined }
|
|
2590
|
+
);
|
|
2591
|
+
|
|
2592
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2593
|
+
"Processing wrangler configuration:
|
|
2594
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2595
|
+
`);
|
|
2596
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2597
|
+
"Processing wrangler configuration:
|
|
2598
|
+
- The field \\"unsafe.metadata\\" should be an object but got null."
|
|
2599
|
+
`);
|
|
2600
|
+
});
|
|
2320
2601
|
});
|
|
2321
2602
|
|
|
2322
2603
|
describe("(deprecated)", () => {
|
|
@@ -2490,7 +2771,6 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2490
2771
|
minify: false,
|
|
2491
2772
|
node_compat: false,
|
|
2492
2773
|
first_party_worker: false,
|
|
2493
|
-
metadata_binding: "METADATA_ENV",
|
|
2494
2774
|
logpush: false,
|
|
2495
2775
|
};
|
|
2496
2776
|
const rawConfig: RawConfig = {
|
|
@@ -2515,7 +2795,6 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2515
2795
|
minify: true,
|
|
2516
2796
|
node_compat: true,
|
|
2517
2797
|
first_party_worker: true,
|
|
2518
|
-
metadata_binding: "METADATA_RAW",
|
|
2519
2798
|
logpush: true,
|
|
2520
2799
|
env: {
|
|
2521
2800
|
ENV1: rawEnv,
|
|
@@ -2700,16 +2979,20 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2700
2979
|
};
|
|
2701
2980
|
const kv_namespaces: RawConfig["kv_namespaces"] = [];
|
|
2702
2981
|
const r2_buckets: RawConfig["r2_buckets"] = [];
|
|
2703
|
-
const
|
|
2704
|
-
|
|
2982
|
+
const analytics_engine_datasets: RawConfig["analytics_engine_datasets"] =
|
|
2983
|
+
[];
|
|
2984
|
+
const unsafe: RawConfig["unsafe"] = {
|
|
2985
|
+
bindings: undefined,
|
|
2986
|
+
metadata: undefined,
|
|
2987
|
+
};
|
|
2705
2988
|
const rawConfig: RawConfig = {
|
|
2706
2989
|
define,
|
|
2707
2990
|
vars,
|
|
2708
2991
|
durable_objects,
|
|
2709
2992
|
kv_namespaces,
|
|
2710
2993
|
r2_buckets,
|
|
2994
|
+
analytics_engine_datasets,
|
|
2711
2995
|
unsafe,
|
|
2712
|
-
metadata_binding,
|
|
2713
2996
|
env: {
|
|
2714
2997
|
ENV1: {},
|
|
2715
2998
|
},
|
|
@@ -2728,6 +3011,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2728
3011
|
durable_objects,
|
|
2729
3012
|
kv_namespaces,
|
|
2730
3013
|
r2_buckets,
|
|
3014
|
+
analytics_engine_datasets,
|
|
2731
3015
|
unsafe,
|
|
2732
3016
|
})
|
|
2733
3017
|
);
|
|
@@ -2739,9 +3023,6 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2739
3023
|
- \\"vars\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2740
3024
|
This is not what you probably want, since \\"vars\\" is not inherited by environments.
|
|
2741
3025
|
Please add \\"vars\\" to \\"env.ENV1\\".
|
|
2742
|
-
- \\"metadata_binding\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2743
|
-
This is not what you probably want, since \\"metadata_binding\\" is not inherited by environments.
|
|
2744
|
-
Please add \\"metadata_binding\\" to \\"env.ENV1\\".
|
|
2745
3026
|
- \\"define\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2746
3027
|
This is not what you probably want, since \\"define\\" is not inherited by environments.
|
|
2747
3028
|
Please add \\"define\\" to \\"env.ENV1\\".
|
|
@@ -2754,6 +3035,9 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2754
3035
|
- \\"r2_buckets\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2755
3036
|
This is not what you probably want, since \\"r2_buckets\\" is not inherited by environments.
|
|
2756
3037
|
Please add \\"r2_buckets\\" to \\"env.ENV1\\".
|
|
3038
|
+
- \\"analytics_engine_datasets\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
3039
|
+
This is not what you probably want, since \\"analytics_engine_datasets\\" is not inherited by environments.
|
|
3040
|
+
Please add \\"analytics_engine_datasets\\" to \\"env.ENV1\\".
|
|
2757
3041
|
- \\"unsafe\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2758
3042
|
This is not what you probably want, since \\"unsafe\\" is not inherited by environments.
|
|
2759
3043
|
Please add \\"unsafe\\" to \\"env.ENV1\\"."
|
|
@@ -3455,6 +3739,114 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3455
3739
|
});
|
|
3456
3740
|
});
|
|
3457
3741
|
|
|
3742
|
+
describe("[analytics_engine_datasets]", () => {
|
|
3743
|
+
it("should error if analytics_engine_datasets is an object", () => {
|
|
3744
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3745
|
+
{
|
|
3746
|
+
env: { ENV1: { analytics_engine_datasets: {} } },
|
|
3747
|
+
} as unknown as RawConfig,
|
|
3748
|
+
undefined,
|
|
3749
|
+
{ env: "ENV1" }
|
|
3750
|
+
);
|
|
3751
|
+
|
|
3752
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3753
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3754
|
+
"Processing wrangler configuration:
|
|
3755
|
+
|
|
3756
|
+
- \\"env.ENV1\\" environment configuration
|
|
3757
|
+
- The field \\"env.ENV1.analytics_engine_datasets\\" should be an array but got {}."
|
|
3758
|
+
`);
|
|
3759
|
+
});
|
|
3760
|
+
|
|
3761
|
+
it("should error if analytics_engine_datasets is a string", () => {
|
|
3762
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3763
|
+
{
|
|
3764
|
+
env: { ENV1: { analytics_engine_datasets: "BAD" } },
|
|
3765
|
+
} as unknown as RawConfig,
|
|
3766
|
+
undefined,
|
|
3767
|
+
{ env: "ENV1" }
|
|
3768
|
+
);
|
|
3769
|
+
|
|
3770
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3771
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3772
|
+
"Processing wrangler configuration:
|
|
3773
|
+
|
|
3774
|
+
- \\"env.ENV1\\" environment configuration
|
|
3775
|
+
- The field \\"env.ENV1.analytics_engine_datasets\\" should be an array but got \\"BAD\\"."
|
|
3776
|
+
`);
|
|
3777
|
+
});
|
|
3778
|
+
|
|
3779
|
+
it("should error if analytics_engine_datasets is a number", () => {
|
|
3780
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3781
|
+
{
|
|
3782
|
+
env: { ENV1: { analytics_engine_datasets: 999 } },
|
|
3783
|
+
} as unknown as RawConfig,
|
|
3784
|
+
undefined,
|
|
3785
|
+
{ env: "ENV1" }
|
|
3786
|
+
);
|
|
3787
|
+
|
|
3788
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3789
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3790
|
+
"Processing wrangler configuration:
|
|
3791
|
+
|
|
3792
|
+
- \\"env.ENV1\\" environment configuration
|
|
3793
|
+
- The field \\"env.ENV1.analytics_engine_datasets\\" should be an array but got 999."
|
|
3794
|
+
`);
|
|
3795
|
+
});
|
|
3796
|
+
|
|
3797
|
+
it("should error if analytics_engine_datasets is null", () => {
|
|
3798
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3799
|
+
{
|
|
3800
|
+
env: { ENV1: { analytics_engine_datasets: null } },
|
|
3801
|
+
} as unknown as RawConfig,
|
|
3802
|
+
undefined,
|
|
3803
|
+
{ env: "ENV1" }
|
|
3804
|
+
);
|
|
3805
|
+
|
|
3806
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3807
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3808
|
+
"Processing wrangler configuration:
|
|
3809
|
+
|
|
3810
|
+
- \\"env.ENV1\\" environment configuration
|
|
3811
|
+
- The field \\"env.ENV1.analytics_engine_datasets\\" should be an array but got null."
|
|
3812
|
+
`);
|
|
3813
|
+
});
|
|
3814
|
+
|
|
3815
|
+
it("should error if analytics_engine_datasets.bindings are not valid", () => {
|
|
3816
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3817
|
+
{
|
|
3818
|
+
env: {
|
|
3819
|
+
ENV1: {
|
|
3820
|
+
analytics_engine_datasets: [
|
|
3821
|
+
{},
|
|
3822
|
+
{ binding: 2333, dataset: 2444 },
|
|
3823
|
+
{
|
|
3824
|
+
binding: "AE_BINDING_2",
|
|
3825
|
+
dataset: 2555,
|
|
3826
|
+
},
|
|
3827
|
+
{ binding: "AE_BINDING_1", dataset: "" },
|
|
3828
|
+
],
|
|
3829
|
+
},
|
|
3830
|
+
},
|
|
3831
|
+
} as unknown as RawConfig,
|
|
3832
|
+
undefined,
|
|
3833
|
+
{ env: "ENV1" }
|
|
3834
|
+
);
|
|
3835
|
+
|
|
3836
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3837
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3838
|
+
"Processing wrangler configuration:
|
|
3839
|
+
|
|
3840
|
+
- \\"env.ENV1\\" environment configuration
|
|
3841
|
+
- \\"env.ENV1.analytics_engine_datasets[0]\\" bindings should have a string \\"binding\\" field but got {}.
|
|
3842
|
+
- \\"env.ENV1.analytics_engine_datasets[1]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":2333,\\"dataset\\":2444}.
|
|
3843
|
+
- \\"env.ENV1.analytics_engine_datasets[1]\\" bindings should, optionally, have a string \\"dataset\\" field but got {\\"binding\\":2333,\\"dataset\\":2444}.
|
|
3844
|
+
- \\"env.ENV1.analytics_engine_datasets[2]\\" bindings should, optionally, have a string \\"dataset\\" field but got {\\"binding\\":\\"AE_BINDING_2\\",\\"dataset\\":2555}.
|
|
3845
|
+
- \\"env.ENV1.analytics_engine_datasets[3]\\" bindings should, optionally, have a string \\"dataset\\" field but got {\\"binding\\":\\"AE_BINDING_1\\",\\"dataset\\":\\"\\"}."
|
|
3846
|
+
`);
|
|
3847
|
+
});
|
|
3848
|
+
});
|
|
3849
|
+
|
|
3458
3850
|
describe("[unsafe.bindings]", () => {
|
|
3459
3851
|
it("should error if unsafe is an array", () => {
|
|
3460
3852
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
@@ -3540,7 +3932,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3540
3932
|
`);
|
|
3541
3933
|
});
|
|
3542
3934
|
|
|
3543
|
-
it("should error if unsafe.bindings
|
|
3935
|
+
it("should error if neither unsafe.bindings nor unsafe.metadata are defined", () => {
|
|
3544
3936
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
3545
3937
|
{ env: { ENV1: { unsafe: {} } } } as unknown as RawConfig,
|
|
3546
3938
|
undefined,
|
|
@@ -3554,11 +3946,47 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3554
3946
|
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3555
3947
|
`);
|
|
3556
3948
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3949
|
+
"Processing wrangler configuration:
|
|
3950
|
+
|
|
3951
|
+
- \\"env.ENV1\\" environment configuration
|
|
3952
|
+
- The field \\"env.ENV1.unsafe\\" should contain at least one of \\"bindings\\" or \\"metadata\\" properties but got {}."
|
|
3953
|
+
`);
|
|
3954
|
+
});
|
|
3955
|
+
|
|
3956
|
+
it("should not error if at least unsafe.bindings is undefined", () => {
|
|
3957
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3958
|
+
{
|
|
3959
|
+
env: { ENV1: { unsafe: { bindings: [] } } },
|
|
3960
|
+
} as unknown as RawConfig,
|
|
3961
|
+
undefined,
|
|
3962
|
+
{ env: "ENV1" }
|
|
3963
|
+
);
|
|
3964
|
+
|
|
3965
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3557
3966
|
"Processing wrangler configuration:
|
|
3558
3967
|
|
|
3559
3968
|
- \\"env.ENV1\\" environment configuration
|
|
3560
|
-
-
|
|
3969
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3561
3970
|
`);
|
|
3971
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3972
|
+
});
|
|
3973
|
+
|
|
3974
|
+
it("should not error if at least unsafe.metadata is undefined", () => {
|
|
3975
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3976
|
+
{
|
|
3977
|
+
env: { ENV1: { unsafe: { metadata: {} } } },
|
|
3978
|
+
} as unknown as RawConfig,
|
|
3979
|
+
undefined,
|
|
3980
|
+
{ env: "ENV1" }
|
|
3981
|
+
);
|
|
3982
|
+
|
|
3983
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3984
|
+
"Processing wrangler configuration:
|
|
3985
|
+
|
|
3986
|
+
- \\"env.ENV1\\" environment configuration
|
|
3987
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3988
|
+
`);
|
|
3989
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3562
3990
|
});
|
|
3563
3991
|
|
|
3564
3992
|
it("should error if unsafe.bindings is an object", () => {
|
|
@@ -3700,6 +4128,98 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3700
4128
|
- binding should have a string \\"type\\" field."
|
|
3701
4129
|
`);
|
|
3702
4130
|
});
|
|
4131
|
+
|
|
4132
|
+
it("should error if unsafe.metadata is an array", () => {
|
|
4133
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4134
|
+
{
|
|
4135
|
+
env: { ENV1: { unsafe: { metadata: [] } } },
|
|
4136
|
+
} as unknown as RawConfig,
|
|
4137
|
+
undefined,
|
|
4138
|
+
{ env: "ENV1" }
|
|
4139
|
+
);
|
|
4140
|
+
|
|
4141
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4142
|
+
"Processing wrangler configuration:
|
|
4143
|
+
|
|
4144
|
+
- \\"env.ENV1\\" environment configuration
|
|
4145
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4146
|
+
`);
|
|
4147
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4148
|
+
"Processing wrangler configuration:
|
|
4149
|
+
|
|
4150
|
+
- \\"env.ENV1\\" environment configuration
|
|
4151
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got []."
|
|
4152
|
+
`);
|
|
4153
|
+
});
|
|
4154
|
+
|
|
4155
|
+
it("should error if unsafe.metadata is a string", () => {
|
|
4156
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4157
|
+
{
|
|
4158
|
+
env: { ENV1: { unsafe: { metadata: "BAD" } } },
|
|
4159
|
+
} as unknown as RawConfig,
|
|
4160
|
+
undefined,
|
|
4161
|
+
{ env: "ENV1" }
|
|
4162
|
+
);
|
|
4163
|
+
|
|
4164
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4165
|
+
"Processing wrangler configuration:
|
|
4166
|
+
|
|
4167
|
+
- \\"env.ENV1\\" environment configuration
|
|
4168
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4169
|
+
`);
|
|
4170
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4171
|
+
"Processing wrangler configuration:
|
|
4172
|
+
|
|
4173
|
+
- \\"env.ENV1\\" environment configuration
|
|
4174
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got \\"BAD\\"."
|
|
4175
|
+
`);
|
|
4176
|
+
});
|
|
4177
|
+
|
|
4178
|
+
it("should error if unsafe.metadata is a number", () => {
|
|
4179
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4180
|
+
{
|
|
4181
|
+
env: { ENV1: { unsafe: { metadata: 999 } } },
|
|
4182
|
+
} as unknown as RawConfig,
|
|
4183
|
+
undefined,
|
|
4184
|
+
{ env: "ENV1" }
|
|
4185
|
+
);
|
|
4186
|
+
|
|
4187
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4188
|
+
"Processing wrangler configuration:
|
|
4189
|
+
|
|
4190
|
+
- \\"env.ENV1\\" environment configuration
|
|
4191
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4192
|
+
`);
|
|
4193
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4194
|
+
"Processing wrangler configuration:
|
|
4195
|
+
|
|
4196
|
+
- \\"env.ENV1\\" environment configuration
|
|
4197
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got 999."
|
|
4198
|
+
`);
|
|
4199
|
+
});
|
|
4200
|
+
|
|
4201
|
+
it("should error if unsafe.metadata is null", () => {
|
|
4202
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4203
|
+
{
|
|
4204
|
+
env: { ENV1: { unsafe: { metadata: null } } },
|
|
4205
|
+
} as unknown as RawConfig,
|
|
4206
|
+
undefined,
|
|
4207
|
+
{ env: "ENV1" }
|
|
4208
|
+
);
|
|
4209
|
+
|
|
4210
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4211
|
+
"Processing wrangler configuration:
|
|
4212
|
+
|
|
4213
|
+
- \\"env.ENV1\\" environment configuration
|
|
4214
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4215
|
+
`);
|
|
4216
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4217
|
+
"Processing wrangler configuration:
|
|
4218
|
+
|
|
4219
|
+
- \\"env.ENV1\\" environment configuration
|
|
4220
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got null."
|
|
4221
|
+
`);
|
|
4222
|
+
});
|
|
3703
4223
|
});
|
|
3704
4224
|
|
|
3705
4225
|
describe("(deprecated)", () => {
|
|
@@ -3979,45 +4499,6 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3979
4499
|
expect(result2.diagnostics.hasWarnings()).toBe(false);
|
|
3980
4500
|
});
|
|
3981
4501
|
});
|
|
3982
|
-
describe("[metadata_binding]", () => {
|
|
3983
|
-
it("should error if metadata_binding is a number", () => {
|
|
3984
|
-
const { diagnostics } = normalizeAndValidateConfig(
|
|
3985
|
-
{ env: { ENV1: { metadata_binding: 999 } } } as unknown as RawConfig,
|
|
3986
|
-
undefined,
|
|
3987
|
-
{ env: "ENV1" }
|
|
3988
|
-
);
|
|
3989
|
-
|
|
3990
|
-
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3991
|
-
"Processing wrangler configuration:
|
|
3992
|
-
"
|
|
3993
|
-
`);
|
|
3994
|
-
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3995
|
-
"Processing wrangler configuration:
|
|
3996
|
-
|
|
3997
|
-
- \\"env.ENV1\\" environment configuration
|
|
3998
|
-
- Expected \\"metadata_binding\\" to be of type string but got 999."
|
|
3999
|
-
`);
|
|
4000
|
-
});
|
|
4001
|
-
|
|
4002
|
-
it("should error if metadata_binding is null", () => {
|
|
4003
|
-
const { diagnostics } = normalizeAndValidateConfig(
|
|
4004
|
-
{ env: { ENV1: { metadata_binding: null } } } as unknown as RawConfig,
|
|
4005
|
-
undefined,
|
|
4006
|
-
{ env: "ENV1" }
|
|
4007
|
-
);
|
|
4008
|
-
|
|
4009
|
-
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4010
|
-
"Processing wrangler configuration:
|
|
4011
|
-
"
|
|
4012
|
-
`);
|
|
4013
|
-
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4014
|
-
"Processing wrangler configuration:
|
|
4015
|
-
|
|
4016
|
-
- \\"env.ENV1\\" environment configuration
|
|
4017
|
-
- Expected \\"metadata_binding\\" to be of type string but got null."
|
|
4018
|
-
`);
|
|
4019
|
-
});
|
|
4020
|
-
});
|
|
4021
4502
|
});
|
|
4022
4503
|
});
|
|
4023
4504
|
|