wrangler 0.0.0-e88a54e → 0.0.0-e8e684c7

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.
Files changed (222) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +51 -14
  3. package/bin/wrangler.js +161 -29
  4. package/kv-asset-handler.js +1 -0
  5. package/miniflare-dist/index.mjs +5484 -21
  6. package/package.json +173 -143
  7. package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
  8. package/src/__tests__/config-cache.test.ts +42 -0
  9. package/src/__tests__/configuration.test.ts +4016 -2786
  10. package/src/__tests__/dev.test.tsx +1305 -483
  11. package/src/__tests__/generate.test.ts +91 -0
  12. package/src/__tests__/guess-worker-format.test.ts +75 -48
  13. package/src/__tests__/helpers/cmd-shim.d.ts +6 -6
  14. package/src/__tests__/helpers/mock-account-id.ts +24 -24
  15. package/src/__tests__/helpers/mock-bin.ts +20 -20
  16. package/src/__tests__/helpers/mock-cfetch.ts +182 -93
  17. package/src/__tests__/helpers/mock-console.ts +59 -32
  18. package/src/__tests__/helpers/mock-dialogs.ts +121 -33
  19. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
  20. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  21. package/src/__tests__/helpers/mock-istty.ts +74 -0
  22. package/src/__tests__/helpers/mock-known-routes.ts +7 -0
  23. package/src/__tests__/helpers/mock-kv.ts +26 -26
  24. package/src/__tests__/helpers/mock-oauth-flow.ts +250 -0
  25. package/src/__tests__/helpers/mock-process.ts +39 -0
  26. package/src/__tests__/helpers/mock-stdin.ts +82 -77
  27. package/src/__tests__/helpers/mock-web-socket.ts +21 -21
  28. package/src/__tests__/helpers/run-in-tmp.ts +28 -22
  29. package/src/__tests__/helpers/run-wrangler.ts +8 -8
  30. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  31. package/src/__tests__/helpers/write-wrangler-toml.ts +9 -9
  32. package/src/__tests__/https-options.test.ts +144 -108
  33. package/src/__tests__/index.test.ts +229 -975
  34. package/src/__tests__/init.test.ts +2170 -0
  35. package/src/__tests__/jest.setup.ts +122 -34
  36. package/src/__tests__/kv.test.ts +1376 -1087
  37. package/src/__tests__/logger.test.ts +141 -0
  38. package/src/__tests__/metrics.test.ts +450 -0
  39. package/src/__tests__/package-manager.test.ts +312 -165
  40. package/src/__tests__/pages.test.ts +1270 -39
  41. package/src/__tests__/parse.test.ts +253 -245
  42. package/src/__tests__/publish.test.ts +6878 -2627
  43. package/src/__tests__/pubsub.test.ts +367 -0
  44. package/src/__tests__/r2.test.ts +328 -190
  45. package/src/__tests__/route.test.ts +22 -22
  46. package/src/__tests__/secret.test.ts +474 -407
  47. package/src/__tests__/tail.test.ts +679 -441
  48. package/src/__tests__/test-old-node-version.js +31 -0
  49. package/src/__tests__/user.test.ts +155 -0
  50. package/src/__tests__/validate-dev-props.test.ts +56 -0
  51. package/src/__tests__/version.test.ts +35 -0
  52. package/src/__tests__/whoami.test.tsx +276 -87
  53. package/src/__tests__/worker-namespace.test.ts +329 -0
  54. package/src/abort.d.ts +3 -0
  55. package/src/api/dev.ts +93 -0
  56. package/src/api/index.ts +1 -0
  57. package/src/bundle-reporter.tsx +29 -0
  58. package/src/bundle.ts +441 -110
  59. package/src/cfetch/index.ts +83 -66
  60. package/src/cfetch/internal.ts +251 -92
  61. package/src/cli.ts +22 -14
  62. package/src/config/README.md +1 -1
  63. package/src/config/config.ts +224 -179
  64. package/src/config/diagnostics.ts +61 -61
  65. package/src/config/environment.ts +430 -311
  66. package/src/config/index.ts +227 -38
  67. package/src/config/validation-helpers.ts +414 -303
  68. package/src/config/validation.ts +1745 -973
  69. package/src/config-cache.ts +85 -0
  70. package/src/create-worker-preview.ts +209 -118
  71. package/src/create-worker-upload-form.ts +275 -201
  72. package/src/dev/dev-vars.ts +36 -0
  73. package/src/dev/dev.tsx +488 -307
  74. package/src/dev/local.tsx +427 -210
  75. package/src/dev/remote.tsx +407 -188
  76. package/src/dev/use-esbuild.ts +156 -78
  77. package/src/dev/validate-dev-props.ts +31 -0
  78. package/src/dev-registry.tsx +160 -0
  79. package/src/dev.tsx +696 -0
  80. package/src/dialogs.tsx +115 -57
  81. package/src/dispatch-namespace.ts +206 -0
  82. package/src/durable.ts +102 -0
  83. package/src/entry.ts +267 -147
  84. package/src/environment-variables.ts +25 -23
  85. package/src/errors.ts +11 -0
  86. package/src/faye-websocket.d.ts +6 -0
  87. package/src/generate.ts +131 -0
  88. package/src/git-client.ts +42 -0
  89. package/src/global-wrangler-config-path.ts +26 -0
  90. package/src/https-options.ts +85 -80
  91. package/src/index.tsx +2191 -2304
  92. package/src/init.ts +622 -0
  93. package/src/inspect.ts +687 -557
  94. package/src/intl-polyfill.d.ts +139 -0
  95. package/src/is-ci.ts +14 -0
  96. package/src/is-interactive.ts +12 -0
  97. package/src/kv.ts +353 -242
  98. package/src/logger.ts +73 -0
  99. package/src/metrics/index.ts +5 -0
  100. package/src/metrics/metrics-config.ts +239 -0
  101. package/src/metrics/metrics-dispatcher.ts +96 -0
  102. package/src/metrics/metrics-usage-headers.ts +24 -0
  103. package/src/metrics/send-event.ts +92 -0
  104. package/src/miniflare-cli/assets.ts +554 -0
  105. package/src/miniflare-cli/enum-keys.ts +8 -8
  106. package/src/miniflare-cli/index.ts +199 -29
  107. package/src/miniflare-cli/request-context.ts +40 -0
  108. package/src/module-collection.ts +213 -213
  109. package/src/open-in-browser.ts +8 -16
  110. package/src/package-manager.ts +183 -90
  111. package/src/pages/build.tsx +238 -0
  112. package/src/pages/constants.ts +12 -0
  113. package/src/pages/deployments.tsx +106 -0
  114. package/src/pages/dev.tsx +528 -0
  115. package/src/pages/errors.ts +22 -0
  116. package/src/pages/functions/buildPlugin.ts +109 -0
  117. package/src/pages/functions/buildWorker.ts +155 -0
  118. package/src/pages/functions/filepath-routing.test.ts +234 -0
  119. package/src/pages/functions/filepath-routing.ts +189 -0
  120. package/src/pages/functions/identifiers.ts +78 -0
  121. package/src/pages/functions/routes-consolidation.test.ts +250 -0
  122. package/src/pages/functions/routes-consolidation.ts +73 -0
  123. package/src/pages/functions/routes-transformation.test.ts +271 -0
  124. package/src/pages/functions/routes-transformation.ts +122 -0
  125. package/src/pages/functions/routes.ts +151 -0
  126. package/src/pages/functions.tsx +96 -0
  127. package/src/pages/index.tsx +94 -0
  128. package/src/pages/projects.tsx +169 -0
  129. package/src/pages/publish.tsx +391 -0
  130. package/src/pages/types.ts +49 -0
  131. package/src/pages/upload.tsx +413 -0
  132. package/src/pages/utils.ts +12 -0
  133. package/src/parse.ts +224 -121
  134. package/src/paths.ts +6 -6
  135. package/src/preview.ts +31 -0
  136. package/src/proxy.ts +416 -370
  137. package/src/publish.ts +796 -321
  138. package/src/pubsub/index.ts +286 -0
  139. package/src/pubsub/pubsub-commands.tsx +623 -0
  140. package/src/r2.ts +100 -19
  141. package/src/selfsigned.d.ts +23 -23
  142. package/src/sites.tsx +281 -189
  143. package/src/tail/filters.ts +111 -109
  144. package/src/tail/index.ts +230 -217
  145. package/src/tail/printing.ts +92 -47
  146. package/src/update-check.ts +19 -0
  147. package/src/user/choose-account.tsx +69 -0
  148. package/src/user/env-vars.ts +46 -0
  149. package/src/user/generate-auth-url.ts +33 -0
  150. package/src/user/generate-random-state.ts +16 -0
  151. package/src/user/index.ts +3 -0
  152. package/src/user/user.tsx +1191 -0
  153. package/src/whoami.tsx +142 -42
  154. package/src/worker.ts +135 -94
  155. package/src/zones.ts +167 -0
  156. package/templates/checked-fetch.js +17 -0
  157. package/templates/first-party-worker-module-facade.ts +18 -0
  158. package/templates/format-dev-errors.ts +32 -0
  159. package/templates/gitignore +171 -0
  160. package/templates/new-worker-scheduled.js +17 -0
  161. package/templates/new-worker-scheduled.ts +32 -0
  162. package/templates/new-worker.js +3 -3
  163. package/templates/new-worker.ts +18 -3
  164. package/templates/no-op-worker.js +10 -0
  165. package/templates/pages-shim.ts +9 -0
  166. package/templates/pages-template-plugin.ts +167 -0
  167. package/templates/pages-template-worker.ts +172 -0
  168. package/templates/serve-static-assets.ts +63 -0
  169. package/templates/service-bindings-module-facade.js +54 -0
  170. package/templates/service-bindings-sw-facade.js +42 -0
  171. package/templates/tsconfig.json +95 -95
  172. package/wrangler-dist/cli.d.ts +338 -0
  173. package/wrangler-dist/cli.js +124611 -112403
  174. package/miniflare-dist/index.mjs.map +0 -7
  175. package/pages/functions/buildWorker.ts +0 -62
  176. package/pages/functions/filepath-routing.test.ts +0 -223
  177. package/pages/functions/filepath-routing.ts +0 -181
  178. package/pages/functions/identifiers.ts +0 -78
  179. package/pages/functions/routes.ts +0 -151
  180. package/pages/functions/template-worker.ts +0 -130
  181. package/src/__tests__/dev2.test.tsx +0 -154
  182. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  183. package/src/__tests__/logout.test.ts +0 -52
  184. package/src/__tests__/sentry.test.ts +0 -146
  185. package/src/pages.tsx +0 -1047
  186. package/src/reporting.ts +0 -131
  187. package/src/user.tsx +0 -1118
  188. package/templates/static-asset-facade.js +0 -47
  189. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  190. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  191. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  192. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  193. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  194. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  195. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  196. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  197. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  198. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  199. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  200. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  201. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  202. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  203. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  204. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  205. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  206. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  207. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  208. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  209. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  210. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  211. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  212. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  213. package/vendor/wrangler-mime/LICENSE +0 -21
  214. package/vendor/wrangler-mime/Mime.js +0 -97
  215. package/vendor/wrangler-mime/README.md +0 -187
  216. package/vendor/wrangler-mime/cli.js +0 -46
  217. package/vendor/wrangler-mime/index.js +0 -4
  218. package/vendor/wrangler-mime/lite.js +0 -4
  219. package/vendor/wrangler-mime/package.json +0 -52
  220. package/vendor/wrangler-mime/types/other.js +0 -1
  221. package/vendor/wrangler-mime/types/standard.js +0 -1
  222. package/wrangler-dist/cli.js.map +0 -7
@@ -5,168 +5,248 @@
5
5
  * This could be the top-level default environment, or a specific named environment.
6
6
  */
7
7
  export interface Environment
8
- extends EnvironmentInheritable,
9
- EnvironmentNonInheritable {}
8
+ extends EnvironmentInheritable,
9
+ EnvironmentNonInheritable {}
10
+
11
+ export type SimpleRoute = string;
12
+ export type ZoneIdRoute = {
13
+ pattern: string;
14
+ zone_id: string;
15
+ custom_domain?: boolean;
16
+ };
17
+ export type ZoneNameRoute = {
18
+ pattern: string;
19
+ zone_name: string;
20
+ custom_domain?: boolean;
21
+ };
22
+ export type CustomDomainRoute = { pattern: string; custom_domain: boolean };
23
+ export type Route =
24
+ | SimpleRoute
25
+ | ZoneIdRoute
26
+ | ZoneNameRoute
27
+ | CustomDomainRoute;
10
28
 
11
29
  /**
12
30
  * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
13
31
  * that can be inherited (and overridden) from the top-level environment.
14
32
  */
15
33
  interface EnvironmentInheritable {
16
- /**
17
- * The name of your worker. Alphanumeric + dashes only.
18
- *
19
- * @inheritable
20
- */
21
- name: string | undefined;
22
-
23
- /**
24
- * This is the ID of the account associated with your zone.
25
- * You might have more than one account, so make sure to use
26
- * the ID of the account associated with the zone/route you
27
- * provide, if you provide one. It can also be specified through
28
- * the CLOUDFLARE_ACCOUNT_ID environment variable.
29
- *
30
- * @inheritable
31
- */
32
- account_id: string | undefined;
33
-
34
- /**
35
- * A date in the form yyyy-mm-dd, which will be used to determine
36
- * which version of the Workers runtime is used.
37
- *
38
- * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
39
- *
40
- * @inheritable
41
- */
42
- compatibility_date: string | undefined;
43
-
44
- /**
45
- * A list of flags that enable features from upcoming features of
46
- * the Workers runtime, usually used together with compatibility_flags.
47
- *
48
- * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
49
- *
50
- * @inheritable
51
- */
52
- compatibility_flags: string[];
53
-
54
- /**
55
- * The entrypoint/path to the JavaScript file that will be executed.
56
- */
57
- main: string | undefined;
58
-
59
- /**
60
- * Whether we use <name>.<subdomain>.workers.dev to
61
- * test and deploy your worker.
62
- *
63
- * @default `true` (This is a breaking change from wrangler 1)
64
- * @breaking
65
- * @inheritable
66
- */
67
- workers_dev: boolean;
68
-
69
- /**
70
- * A list of routes that your worker should be published to.
71
- * Only one of `routes` or `route` is required.
72
- *
73
- * Only required when workers_dev is false, and there's no scheduled worker (see `triggers`)
74
- *
75
- * @inheritable
76
- */
77
- routes: string[] | undefined;
78
-
79
- /**
80
- * A route that your worker should be published to. Literally
81
- * the same as routes, but only one.
82
- * Only one of `routes` or `route` is required.
83
- *
84
- * Only required when workers_dev is false, and there's no scheduled worker
85
- *
86
- * @inheritable
87
- */
88
- route: string | undefined;
89
-
90
- /**
91
- * The function to use to replace jsx syntax.
92
- *
93
- * @default `"React.createElement"`
94
- * @inheritable
95
- */
96
- jsx_factory: string;
97
-
98
- /**
99
- * The function to use to replace jsx fragment syntax.
100
- *
101
- * @default `"React.Fragment"`
102
- * @inheritable
103
- */
104
- jsx_fragment: string;
105
-
106
- /**
107
- * "Cron" definitions to trigger a worker's "scheduled" function.
108
- *
109
- * Lets you call workers periodically, much like a cron job.
110
- *
111
- * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
112
- *
113
- * @default `{crons:[]}`
114
- * @inheritable
115
- */
116
- triggers: { crons: string[] };
117
-
118
- /**
119
- * Specifies the Usage Model for your Worker. There are two options -
120
- * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
121
- * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
122
- * For newly created Workers, if the Usage Model is omitted
123
- * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
124
- * For existing Workers, if the Usage Model is omitted, it will be
125
- * set to the Usage Model configured in the dashboard for that Worker.
126
- *
127
- * @inheritable
128
- */
129
- usage_model: undefined | "bundled" | "unbound";
130
-
131
- /**
132
- * An ordered list of rules that define which modules to import,
133
- * and what type to import them as. You will need to specify rules
134
- * to use Text, Data, and CompiledWasm modules, or when you wish to
135
- * have a .js file be treated as an ESModule instead of CommonJS.
136
- *
137
- * @inheritable
138
- */
139
- rules: Rule[];
140
-
141
- /**
142
- * Configures a custom build step to be run by Wrangler when building your Worker.
143
- *
144
- * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
145
- * for more details.
146
- *
147
- * @default {}
148
- */
149
- build: {
150
- /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
151
- command?: string;
152
- /** The directory in which the command is executed. */
153
- cwd?: string;
154
- /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
155
- watch_dir?: string;
156
- /**
157
- * Deprecated field previously used to configure the build and upload of the script.
158
- * @deprecated
159
- */
160
- upload?: DeprecatedUpload;
161
- };
162
-
163
- /**
164
- * TODO: remove this as it has been deprecated.
165
- *
166
- * This is just here for now because the `route` commands use it.
167
- * So we need to include it in this type so it is available.
168
- */
169
- zone_id?: string;
34
+ /**
35
+ * The name of your worker. Alphanumeric + dashes only.
36
+ *
37
+ * @inheritable
38
+ */
39
+ name: string | undefined;
40
+
41
+ /**
42
+ * This is the ID of the account associated with your zone.
43
+ * You might have more than one account, so make sure to use
44
+ * the ID of the account associated with the zone/route you
45
+ * provide, if you provide one. It can also be specified through
46
+ * the CLOUDFLARE_ACCOUNT_ID environment variable.
47
+ *
48
+ * @inheritable
49
+ */
50
+ account_id: string | undefined;
51
+
52
+ /**
53
+ * A date in the form yyyy-mm-dd, which will be used to determine
54
+ * which version of the Workers runtime is used.
55
+ *
56
+ * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
57
+ *
58
+ * @inheritable
59
+ */
60
+ compatibility_date: string | undefined;
61
+
62
+ /**
63
+ * A list of flags that enable features from upcoming features of
64
+ * the Workers runtime, usually used together with compatibility_flags.
65
+ *
66
+ * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
67
+ *
68
+ * @inheritable
69
+ */
70
+ compatibility_flags: string[];
71
+
72
+ /**
73
+ * The entrypoint/path to the JavaScript file that will be executed.
74
+ */
75
+ main: string | undefined;
76
+
77
+ /**
78
+ * Whether we use <name>.<subdomain>.workers.dev to
79
+ * test and deploy your worker.
80
+ *
81
+ * @default `true` (This is a breaking change from wrangler 1)
82
+ * @breaking
83
+ * @inheritable
84
+ */
85
+ workers_dev: boolean | undefined;
86
+
87
+ /**
88
+ * A list of routes that your worker should be published to.
89
+ * Only one of `routes` or `route` is required.
90
+ *
91
+ * Only required when workers_dev is false, and there's no scheduled worker (see `triggers`)
92
+ *
93
+ * @inheritable
94
+ */
95
+ routes: Route[] | undefined;
96
+
97
+ /**
98
+ * A route that your worker should be published to. Literally
99
+ * the same as routes, but only one.
100
+ * Only one of `routes` or `route` is required.
101
+ *
102
+ * Only required when workers_dev is false, and there's no scheduled worker
103
+ *
104
+ * @inheritable
105
+ */
106
+ route: Route | undefined;
107
+
108
+ /**
109
+ * Path to a custom tsconfig
110
+ */
111
+ tsconfig: string | undefined;
112
+
113
+ /**
114
+ * The function to use to replace jsx syntax.
115
+ *
116
+ * @default `"React.createElement"`
117
+ * @inheritable
118
+ */
119
+ jsx_factory: string;
120
+
121
+ /**
122
+ * The function to use to replace jsx fragment syntax.
123
+ *
124
+ * @default `"React.Fragment"`
125
+ * @inheritable
126
+ */
127
+ jsx_fragment: string;
128
+
129
+ /**
130
+ * "Cron" definitions to trigger a worker's "scheduled" function.
131
+ *
132
+ * Lets you call workers periodically, much like a cron job.
133
+ *
134
+ * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
135
+ *
136
+ * @default `{crons:[]}`
137
+ * @inheritable
138
+ */
139
+ triggers: { crons: string[] };
140
+
141
+ /**
142
+ * Specifies the Usage Model for your Worker. There are two options -
143
+ * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
144
+ * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
145
+ * For newly created Workers, if the Usage Model is omitted
146
+ * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
147
+ * For existing Workers, if the Usage Model is omitted, it will be
148
+ * set to the Usage Model configured in the dashboard for that Worker.
149
+ *
150
+ * @inheritable
151
+ */
152
+ usage_model: "bundled" | "unbound" | undefined;
153
+
154
+ /**
155
+ * An ordered list of rules that define which modules to import,
156
+ * and what type to import them as. You will need to specify rules
157
+ * to use Text, Data, and CompiledWasm modules, or when you wish to
158
+ * have a .js file be treated as an ESModule instead of CommonJS.
159
+ *
160
+ * @inheritable
161
+ */
162
+ rules: Rule[];
163
+
164
+ /**
165
+ * Configures a custom build step to be run by Wrangler when building your Worker.
166
+ *
167
+ * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
168
+ * for more details.
169
+ *
170
+ * @default {}
171
+ */
172
+ build: {
173
+ /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
174
+ command?: string;
175
+ /** The directory in which the command is executed. */
176
+ cwd?: string;
177
+ /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
178
+ watch_dir?: string | string[];
179
+ /**
180
+ * Deprecated field previously used to configure the build and upload of the script.
181
+ * @deprecated
182
+ */
183
+ upload?: DeprecatedUpload;
184
+ };
185
+
186
+ /**
187
+ * Skip internal build steps and directly publish script
188
+ * @inheritable
189
+ */
190
+ no_bundle: boolean | undefined;
191
+
192
+ /**
193
+ * Minify the script before uploading.
194
+ * @inheritable
195
+ */
196
+ minify: boolean | undefined;
197
+
198
+ /**
199
+ * Add polyfills for node builtin modules and globals
200
+ * @inheritable
201
+ */
202
+ node_compat: boolean | undefined;
203
+
204
+ /**
205
+ * Specifies namespace bindings that are bound to this Worker environment.
206
+ *
207
+ * NOTE: This field is not automatically inherited from the top level environment,
208
+ * and so must be specified in every named environment.
209
+ *
210
+ * @default `[]`
211
+ * @nonInheritable
212
+ */
213
+ dispatch_namespaces: {
214
+ /** The binding name used to refer to the bound service. */
215
+ binding: string;
216
+ /** The namespace to bind to. */
217
+ namespace: string;
218
+ }[];
219
+
220
+ /**
221
+ * Designates this worker as an internal-only "first-party" worker.
222
+ */
223
+ first_party_worker: boolean | undefined;
224
+
225
+ /**
226
+ * TODO: remove this as it has been deprecated.
227
+ *
228
+ * This is just here for now because the `route` commands use it.
229
+ * So we need to include it in this type so it is available.
230
+ */
231
+ zone_id?: string;
232
+
233
+ /**
234
+ * Specify a compiled capnp schema to use
235
+ * Then add a binding per field in the top level message that you will send to logfwdr
236
+ *
237
+ * @default `{schema:undefined,bindings:[]}`
238
+ * @inheritable
239
+ */
240
+ logfwdr: {
241
+ /** capnp schema filename */
242
+ schema: string | undefined;
243
+ bindings: {
244
+ /** The binding name used to refer to logfwdr */
245
+ name: string;
246
+ /** The destination for this logged message */
247
+ destination: string;
248
+ }[];
249
+ };
170
250
  }
171
251
 
172
252
  /**
@@ -177,165 +257,204 @@ interface EnvironmentInheritable {
177
257
  * for each named environment.
178
258
  */
179
259
  interface EnvironmentNonInheritable {
180
- /**
181
- * A map of environment variables to set when deploying your worker.
182
- *
183
- * NOTE: This field is not automatically inherited from the top level environment,
184
- * and so must be specified in every named environment.
185
- *
186
- * @default `{}`
187
- * @nonInheritable
188
- */
189
- vars: { [key: string]: unknown };
190
-
191
- /**
192
- * A list of durable objects that your worker should be bound to.
193
- *
194
- * For more information about Durable Objects, see the documentation at
195
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
196
- *
197
- * NOTE: This field is not automatically inherited from the top level environment,
198
- * and so must be specified in every named environment.
199
- *
200
- * @default `{bindings:[]}`
201
- * @nonInheritable
202
- */
203
- durable_objects: {
204
- bindings: {
205
- /** The name of the binding used to refer to the Durable Object */
206
- name: string;
207
- /** The exported class name of the Durable Object */
208
- class_name: string;
209
- /** The script where the Durable Object is defined (if it's external to this worker) */
210
- script_name?: string;
211
- }[];
212
- };
213
-
214
- /**
215
- * These specify any Workers KV Namespaces you want to
216
- * access from inside your Worker.
217
- *
218
- * To learn more about KV Namespaces,
219
- * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
220
- *
221
- * NOTE: This field is not automatically inherited from the top level environment,
222
- * and so must be specified in every named environment.
223
- *
224
- * @default `[]`
225
- * @nonInheritable
226
- */
227
- kv_namespaces: {
228
- /** The binding name used to refer to the KV Namespace */
229
- binding: string;
230
- /** The ID of the KV namespace */
231
- id: string;
232
- /** The ID of the KV namespace used during `wrangler dev` */
233
- preview_id?: string;
234
- }[];
235
-
236
- /**
237
- * Specifies R2 buckets that are bound to this Worker environment.
238
- *
239
- * NOTE: This field is not automatically inherited from the top level environment,
240
- * and so must be specified in every named environment.
241
- *
242
- * @default `[]`
243
- * @nonInheritable
244
- */
245
- r2_buckets: {
246
- /** The binding name used to refer to the R2 bucket in the worker. */
247
- binding: string;
248
- /** The name of this R2 bucket at the edge. */
249
- bucket_name: string;
250
- /** The preview name of this R2 bucket at the edge. */
251
- preview_bucket_name?: string;
252
- }[];
253
-
254
- /**
255
- * "Unsafe" tables for features that aren't directly supported by wrangler.
256
- *
257
- * NOTE: This field is not automatically inherited from the top level environment,
258
- * and so must be specified in every named environment.
259
- *
260
- * @default `{ bindings: [] }`
261
- * @nonInheritable
262
- */
263
- unsafe: {
264
- /**
265
- * A set of bindings that should be put into a Worker's upload metadata without changes. These
266
- * can be used to implement bindings for features that haven't released and aren't supported
267
- * directly by wrangler or miniflare.
268
- *
269
- * @default []
270
- */
271
- bindings: {
272
- name: string;
273
- type: string;
274
- [key: string]: unknown;
275
- }[];
276
- };
260
+ /**
261
+ * A map of values to substitute when deploying your worker.
262
+ *
263
+ * NOTE: This field is not automatically inherited from the top level environment,
264
+ * and so must be specified in every named environment.
265
+ *
266
+ * @default `{}`
267
+ * @nonInheritable
268
+ */
269
+ define: Record<string, string>;
270
+ /**
271
+ * A map of environment variables to set when deploying your worker.
272
+ *
273
+ * NOTE: This field is not automatically inherited from the top level environment,
274
+ * and so must be specified in every named environment.
275
+ *
276
+ * @default `{}`
277
+ * @nonInheritable
278
+ */
279
+ vars: { [key: string]: unknown };
280
+
281
+ /**
282
+ * A list of durable objects that your worker should be bound to.
283
+ *
284
+ * For more information about Durable Objects, see the documentation at
285
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
286
+ *
287
+ * NOTE: This field is not automatically inherited from the top level environment,
288
+ * and so must be specified in every named environment.
289
+ *
290
+ * @default `{bindings:[]}`
291
+ * @nonInheritable
292
+ */
293
+ durable_objects: {
294
+ bindings: {
295
+ /** The name of the binding used to refer to the Durable Object */
296
+ name: string;
297
+ /** The exported class name of the Durable Object */
298
+ class_name: string;
299
+ /** The script where the Durable Object is defined (if it's external to this worker) */
300
+ script_name?: string;
301
+ /** The service environment of the script_name to bind to */
302
+ environment?: string;
303
+ }[];
304
+ };
305
+
306
+ /**
307
+ * These specify any Workers KV Namespaces you want to
308
+ * access from inside your Worker.
309
+ *
310
+ * To learn more about KV Namespaces,
311
+ * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
312
+ *
313
+ * NOTE: This field is not automatically inherited from the top level environment,
314
+ * and so must be specified in every named environment.
315
+ *
316
+ * @default `[]`
317
+ * @nonInheritable
318
+ */
319
+ kv_namespaces: {
320
+ /** The binding name used to refer to the KV Namespace */
321
+ binding: string;
322
+ /** The ID of the KV namespace */
323
+ id: string;
324
+ /** The ID of the KV namespace used during `wrangler dev` */
325
+ preview_id?: string;
326
+ }[];
327
+
328
+ /**
329
+ * Specifies R2 buckets that are bound to this Worker environment.
330
+ *
331
+ * NOTE: This field is not automatically inherited from the top level environment,
332
+ * and so must be specified in every named environment.
333
+ *
334
+ * @default `[]`
335
+ * @nonInheritable
336
+ */
337
+ r2_buckets: {
338
+ /** The binding name used to refer to the R2 bucket in the worker. */
339
+ binding: string;
340
+ /** The name of this R2 bucket at the edge. */
341
+ bucket_name: string;
342
+ /** The preview name of this R2 bucket at the edge. */
343
+ preview_bucket_name?: string;
344
+ }[];
345
+
346
+ /**
347
+ * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
348
+ *
349
+ * NOTE: This field is not automatically inherited from the top level environment,
350
+ * and so must be specified in every named environment.
351
+ *
352
+ * @default `[]`
353
+ * @nonInheritable
354
+ */
355
+ services:
356
+ | {
357
+ /** The binding name used to refer to the bound service. */
358
+ binding: string;
359
+ /** The name of the service. */
360
+ service: string;
361
+ /** The environment of the service (e.g. production, staging, etc). */
362
+ environment?: string;
363
+ }[]
364
+ | undefined;
365
+
366
+ /**
367
+ * "Unsafe" tables for features that aren't directly supported by wrangler.
368
+ *
369
+ * NOTE: This field is not automatically inherited from the top level environment,
370
+ * and so must be specified in every named environment.
371
+ *
372
+ * @default `{ bindings: [] }`
373
+ * @nonInheritable
374
+ */
375
+ unsafe: {
376
+ /**
377
+ * A set of bindings that should be put into a Worker's upload metadata without changes. These
378
+ * can be used to implement bindings for features that haven't released and aren't supported
379
+ * directly by wrangler or miniflare.
380
+ *
381
+ * @default []
382
+ */
383
+ bindings: {
384
+ name: string;
385
+ type: string;
386
+ [key: string]: unknown;
387
+ }[];
388
+ };
277
389
  }
278
390
 
279
391
  /**
280
392
  * The environment configuration properties that have been deprecated.
281
393
  */
282
394
  interface EnvironmentDeprecated {
283
- /**
284
- * The zone ID of the zone you want to deploy to. You can find this
285
- * in your domain page on the dashboard.
286
- *
287
- * @deprecated This is unnecessary since we can deduce this from routes directly.
288
- */
289
- zone_id?: string;
290
-
291
- /**
292
- * A list of services that your worker should be bound to.
293
- *
294
- * @default `[]`
295
- * @deprecated DO NOT USE. We'd added this to test the new service binding system, but the proper way to test experimental features is to use `unsafe.bindings` configuration.
296
- */
297
- experimental_services?: {
298
- /** The binding name used to refer to the Service */
299
- name: string;
300
- /** The name of the Service being bound */
301
- service: string;
302
- /** The Service's environment */
303
- environment: string;
304
- }[];
395
+ /**
396
+ * The zone ID of the zone you want to deploy to. You can find this
397
+ * in your domain page on the dashboard.
398
+ *
399
+ * @deprecated This is unnecessary since we can deduce this from routes directly.
400
+ */
401
+ zone_id?: string;
402
+
403
+ /**
404
+ * Legacy way of defining KVNamespaces that is no longer supported.
405
+ *
406
+ * @deprecated DO NOT USE. This was a legacy bug from wrangler 1, that we do not want to support.
407
+ */
408
+ "kv-namespaces"?: string;
409
+
410
+ /**
411
+ * A list of services that your worker should be bound to.
412
+ *
413
+ * @default `[]`
414
+ * @deprecated DO NOT USE. We'd added this to test the new service binding system, but the proper way to test experimental features is to use `unsafe.bindings` configuration.
415
+ */
416
+ experimental_services?: {
417
+ /** The binding name used to refer to the Service */
418
+ name: string;
419
+ /** The name of the Service being bound */
420
+ service: string;
421
+ /** The Service's environment */
422
+ environment: string;
423
+ }[];
305
424
  }
306
425
 
307
426
  /**
308
427
  * Deprecated upload configuration.
309
428
  */
310
429
  export interface DeprecatedUpload {
311
- /**
312
- * The format of the Worker script.
313
- *
314
- * @deprecated We infer the format automatically now.
315
- */
316
- format?: "modules" | "service-worker";
317
-
318
- /**
319
- * The directory you wish to upload your worker from,
320
- * relative to the wrangler.toml file.
321
- *
322
- * Defaults to the directory containing the wrangler.toml file.
323
- *
324
- * @deprecated
325
- */
326
- dir?: string;
327
-
328
- /**
329
- * The path to the Worker script, relative to `upload.dir`.
330
- *
331
- * @deprecated This will be replaced by a command line argument.
332
- */
333
- main?: string;
334
-
335
- /**
336
- * @deprecated This is now defined at the top level `rules` field.
337
- */
338
- rules?: Environment["rules"];
430
+ /**
431
+ * The format of the Worker script.
432
+ *
433
+ * @deprecated We infer the format automatically now.
434
+ */
435
+ format?: "modules" | "service-worker";
436
+
437
+ /**
438
+ * The directory you wish to upload your worker from,
439
+ * relative to the wrangler.toml file.
440
+ *
441
+ * Defaults to the directory containing the wrangler.toml file.
442
+ *
443
+ * @deprecated
444
+ */
445
+ dir?: string;
446
+
447
+ /**
448
+ * The path to the Worker script, relative to `upload.dir`.
449
+ *
450
+ * @deprecated This will be replaced by a command line argument.
451
+ */
452
+ main?: string;
453
+
454
+ /**
455
+ * @deprecated This is now defined at the top level `rules` field.
456
+ */
457
+ rules?: Environment["rules"];
339
458
  }
340
459
 
341
460
  /**
@@ -350,17 +469,17 @@ export type RawEnvironment = Partial<Environment> & EnvironmentDeprecated;
350
469
  * A bundling resolver rule, defining the modules type for paths that match the specified globs.
351
470
  */
352
471
  export type Rule = {
353
- type: ConfigModuleRuleType;
354
- globs: string[];
355
- fallthrough?: boolean;
472
+ type: ConfigModuleRuleType;
473
+ globs: string[];
474
+ fallthrough?: boolean;
356
475
  };
357
476
 
358
477
  /**
359
478
  * The possible types for a `Rule`.
360
479
  */
361
480
  export type ConfigModuleRuleType =
362
- | "ESModule"
363
- | "CommonJS"
364
- | "CompiledWasm"
365
- | "Text"
366
- | "Data";
481
+ | "ESModule"
482
+ | "CommonJS"
483
+ | "CompiledWasm"
484
+ | "Text"
485
+ | "Data";