wrangler 0.0.0-e88a54e → 0.0.0-e8a2a1d9

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 (173) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +47 -16
  3. package/bin/wrangler.js +123 -32
  4. package/kv-asset-handler.js +1 -0
  5. package/package.json +155 -86
  6. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  7. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  8. package/templates/__tests__/tsconfig.json +8 -0
  9. package/templates/checked-fetch.js +30 -0
  10. package/templates/facade.d.ts +17 -0
  11. package/templates/gitignore +172 -0
  12. package/templates/init-tests/test-jest-new-worker.js +23 -0
  13. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  14. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  15. package/templates/middleware/common.ts +67 -0
  16. package/templates/middleware/loader-modules.ts +137 -0
  17. package/templates/middleware/loader-sw.ts +228 -0
  18. package/templates/middleware/middleware-d1-beta.d.ts +3 -0
  19. package/templates/middleware/middleware-miniflare3-json-error.ts +33 -0
  20. package/templates/middleware/middleware-multiworker-dev.d.ts +4 -0
  21. package/templates/middleware/middleware-multiworker-dev.ts +68 -0
  22. package/templates/middleware/middleware-pretty-error.ts +40 -0
  23. package/templates/middleware/middleware-scheduled.ts +15 -0
  24. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  25. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  26. package/templates/modules-watch-stub.js +4 -0
  27. package/templates/new-worker-scheduled.js +17 -0
  28. package/templates/new-worker-scheduled.ts +32 -0
  29. package/templates/new-worker.js +3 -3
  30. package/templates/new-worker.ts +22 -4
  31. package/templates/no-op-worker.js +10 -0
  32. package/templates/pages-dev-pipeline.ts +31 -0
  33. package/templates/pages-dev-util.ts +55 -0
  34. package/templates/pages-shim.ts +9 -0
  35. package/templates/pages-template-plugin.ts +190 -0
  36. package/templates/pages-template-worker.ts +198 -0
  37. package/templates/startDevWorker/InspectorProxyWorker.ts +652 -0
  38. package/templates/startDevWorker/ProxyWorker.ts +252 -0
  39. package/templates/tsconfig-sanity.ts +11 -0
  40. package/templates/tsconfig.init.json +105 -0
  41. package/templates/tsconfig.json +6 -103
  42. package/wrangler-dist/InspectorProxyWorker.js +460 -0
  43. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  44. package/wrangler-dist/ProxyWorker.js +186 -0
  45. package/wrangler-dist/ProxyWorker.js.map +6 -0
  46. package/wrangler-dist/cli.d.ts +23507 -0
  47. package/wrangler-dist/cli.js +152534 -132977
  48. package/wrangler-dist/wasm-sync.wasm +0 -0
  49. package/import_meta_url.js +0 -3
  50. package/miniflare-config-stubs/.env.empty +0 -0
  51. package/miniflare-config-stubs/package.empty.json +0 -1
  52. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  53. package/miniflare-dist/index.mjs +0 -79
  54. package/miniflare-dist/index.mjs.map +0 -7
  55. package/pages/functions/buildWorker.ts +0 -62
  56. package/pages/functions/filepath-routing.test.ts +0 -223
  57. package/pages/functions/filepath-routing.ts +0 -181
  58. package/pages/functions/identifiers.ts +0 -78
  59. package/pages/functions/routes.ts +0 -151
  60. package/pages/functions/template-worker.ts +0 -130
  61. package/src/__tests__/configuration.test.ts +0 -2796
  62. package/src/__tests__/dev.test.tsx +0 -496
  63. package/src/__tests__/dev2.test.tsx +0 -154
  64. package/src/__tests__/guess-worker-format.test.ts +0 -58
  65. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  66. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  67. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  68. package/src/__tests__/helpers/mock-account-id.ts +0 -48
  69. package/src/__tests__/helpers/mock-bin.ts +0 -36
  70. package/src/__tests__/helpers/mock-cfetch.ts +0 -207
  71. package/src/__tests__/helpers/mock-console.ts +0 -70
  72. package/src/__tests__/helpers/mock-dialogs.ts +0 -65
  73. package/src/__tests__/helpers/mock-kv.ts +0 -33
  74. package/src/__tests__/helpers/mock-stdin.ts +0 -103
  75. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  76. package/src/__tests__/helpers/run-in-tmp.ts +0 -32
  77. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  78. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  79. package/src/__tests__/https-options.test.ts +0 -127
  80. package/src/__tests__/index.test.ts +0 -991
  81. package/src/__tests__/jest.setup.ts +0 -69
  82. package/src/__tests__/kv.test.ts +0 -1382
  83. package/src/__tests__/logout.test.ts +0 -52
  84. package/src/__tests__/package-manager.test.ts +0 -206
  85. package/src/__tests__/pages.test.ts +0 -44
  86. package/src/__tests__/parse.test.ts +0 -322
  87. package/src/__tests__/publish.test.ts +0 -2704
  88. package/src/__tests__/r2.test.ts +0 -198
  89. package/src/__tests__/route.test.ts +0 -45
  90. package/src/__tests__/secret.test.ts +0 -425
  91. package/src/__tests__/sentry.test.ts +0 -146
  92. package/src/__tests__/tail.test.ts +0 -564
  93. package/src/__tests__/whoami.test.tsx +0 -100
  94. package/src/bundle.ts +0 -142
  95. package/src/cfetch/index.ts +0 -104
  96. package/src/cfetch/internal.ts +0 -139
  97. package/src/cli.ts +0 -19
  98. package/src/config/README.md +0 -107
  99. package/src/config/config.ts +0 -218
  100. package/src/config/diagnostics.ts +0 -80
  101. package/src/config/environment.ts +0 -366
  102. package/src/config/index.ts +0 -62
  103. package/src/config/validation-helpers.ts +0 -486
  104. package/src/config/validation.ts +0 -1090
  105. package/src/create-worker-preview.ts +0 -166
  106. package/src/create-worker-upload-form.ts +0 -217
  107. package/src/dev/dev.tsx +0 -364
  108. package/src/dev/local.tsx +0 -232
  109. package/src/dev/remote.tsx +0 -203
  110. package/src/dev/use-esbuild.ts +0 -100
  111. package/src/dialogs.tsx +0 -77
  112. package/src/entry.ts +0 -208
  113. package/src/environment-variables.ts +0 -33
  114. package/src/https-options.ts +0 -122
  115. package/src/index.tsx +0 -2373
  116. package/src/inspect.ts +0 -617
  117. package/src/kv.ts +0 -319
  118. package/src/miniflare-cli/README.md +0 -30
  119. package/src/miniflare-cli/enum-keys.ts +0 -17
  120. package/src/miniflare-cli/index.ts +0 -37
  121. package/src/module-collection.ts +0 -258
  122. package/src/open-in-browser.ts +0 -25
  123. package/src/package-manager.ts +0 -126
  124. package/src/pages.tsx +0 -1047
  125. package/src/parse.ts +0 -183
  126. package/src/paths.ts +0 -26
  127. package/src/proxy.ts +0 -440
  128. package/src/publish.ts +0 -347
  129. package/src/r2.ts +0 -50
  130. package/src/reporting.ts +0 -131
  131. package/src/selfsigned.d.ts +0 -29
  132. package/src/sites.tsx +0 -280
  133. package/src/tail/filters.ts +0 -279
  134. package/src/tail/index.ts +0 -299
  135. package/src/tail/printing.ts +0 -62
  136. package/src/user.tsx +0 -1118
  137. package/src/whoami.tsx +0 -69
  138. package/src/worker.ts +0 -163
  139. package/templates/static-asset-facade.js +0 -47
  140. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  141. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  142. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  143. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  144. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  145. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  146. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  147. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  148. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  149. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  150. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  151. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  152. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  153. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  154. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  155. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  156. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  157. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  158. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  159. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  160. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  161. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  162. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  163. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  164. package/vendor/wrangler-mime/LICENSE +0 -21
  165. package/vendor/wrangler-mime/Mime.js +0 -97
  166. package/vendor/wrangler-mime/README.md +0 -187
  167. package/vendor/wrangler-mime/cli.js +0 -46
  168. package/vendor/wrangler-mime/index.js +0 -4
  169. package/vendor/wrangler-mime/lite.js +0 -4
  170. package/vendor/wrangler-mime/package.json +0 -52
  171. package/vendor/wrangler-mime/types/other.js +0 -1
  172. package/vendor/wrangler-mime/types/standard.js +0 -1
  173. package/wrangler-dist/cli.js.map +0 -7
@@ -1,218 +0,0 @@
1
- import type { Environment, RawEnvironment } from "./environment";
2
-
3
- /**
4
- * This is the static type definition for the configuration object.
5
- *
6
- * It reflects a normalized and validated version of the configuration that you can write in wrangler.toml,
7
- * and optionally augment with arguments passed directly to wrangler.
8
- *
9
- * For more information about the configuration object, see the
10
- * documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
11
- *
12
- * Notes:
13
- *
14
- * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
15
- * in the top level config and should not appear in any environments.
16
- * - All top level fields in config and environments are optional in the wrangler.toml file.
17
- *
18
- * Legend for the annotations:
19
- *
20
- * - `@breaking`: the deprecation/optionality is a breaking change from wrangler 1.
21
- * - `@todo`: there's more work to be done (with details attached).
22
- */
23
- export type Config = ConfigFields<DevConfig> & Environment;
24
-
25
- export type RawConfig = Partial<ConfigFields<RawDevConfig>> &
26
- RawEnvironment &
27
- DeprecatedConfigFields &
28
- EnvironmentMap;
29
-
30
- export interface ConfigFields<Dev extends RawDevConfig> {
31
- configPath: string | undefined;
32
-
33
- /**
34
- * A boolean to enable "legacy" style wrangler environments (from wrangler 1).
35
- * These have been superseded by Services, but there may be projects that won't
36
- * (or can't) use them. If you're using a legacy environment, you can set this
37
- * to `true` to enable it.
38
- */
39
- legacy_env: boolean;
40
-
41
- /**
42
- * Options to configure the development server that your worker will use.
43
- */
44
- dev: Dev;
45
-
46
- /**
47
- * A list of migrations that should be uploaded with your Worker.
48
- *
49
- * These define changes in your Durable Object declarations.
50
- *
51
- * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
52
- *
53
- * @default `[]`
54
- */
55
- migrations: {
56
- /** A unique identifier for this migration. */
57
- tag: string;
58
- /** The new Durable Objects being defined. */
59
- new_classes?: string[];
60
- /** The Durable Objects being renamed. */
61
- renamed_classes?: {
62
- from: string;
63
- to: string;
64
- }[];
65
- /** The Durable Objects being removed. */
66
- deleted_classes?: string[];
67
- }[];
68
-
69
- /**
70
- * The definition of a Worker Site, a feature that lets you upload
71
- * static assets with your Worker.
72
- *
73
- * More details at https://developers.cloudflare.com/workers/platform/sites
74
- */
75
- site:
76
- | {
77
- /**
78
- * The directory containing your static assets.
79
- *
80
- * It must be a path relative to your wrangler.toml file.
81
- * Example: bucket = "./public"
82
- *
83
- * If there is a `site` field then it must contain this `bucket` field.
84
- */
85
- bucket: string;
86
-
87
- /**
88
- * The location of your Worker script.
89
- *
90
- * @deprecated DO NOT use this (it's a holdover from wrangler 1.x). Either use the top level `main` field, or pass the path to your entry file as a command line argument.
91
- * @breaking
92
- */
93
- "entry-point"?: string;
94
-
95
- /**
96
- * An exclusive list of .gitignore-style patterns that match file
97
- * or directory names from your bucket location. Only matched
98
- * items will be uploaded. Example: include = ["upload_dir"]
99
- *
100
- * @optional
101
- * @default `[]`
102
- */
103
- include?: string[];
104
-
105
- /**
106
- * A list of .gitignore-style patterns that match files or
107
- * directories in your bucket that should be excluded from
108
- * uploads. Example: exclude = ["ignore_dir"]
109
- *
110
- * @optional
111
- * @default `[]`
112
- */
113
- exclude?: string[];
114
- }
115
- | undefined;
116
-
117
- /**
118
- * A list of wasm modules that your worker should be bound to. This is
119
- * the "legacy" way of binding to a wasm module. ES module workers should
120
- * do proper module imports.
121
- */
122
- wasm_modules:
123
- | {
124
- [key: string]: string;
125
- }
126
- | undefined;
127
-
128
- /**
129
- * A list of text files that your worker should be bound to. This is
130
- * the "legacy" way of binding to a text file. ES module workers should
131
- * do proper module imports.
132
- */
133
- text_blobs:
134
- | {
135
- [key: string]: string;
136
- }
137
- | undefined;
138
- }
139
-
140
- export interface DevConfig {
141
- /**
142
- * IP address for the local dev server to listen on,
143
- *
144
- * @default `localhost`
145
- * @todo this needs to be implemented
146
- */
147
- ip: string;
148
-
149
- /**
150
- * Port for the local dev server to listen on
151
- *
152
- * @default `8787`
153
- */
154
- port: number;
155
-
156
- /**
157
- * Protocol that local wrangler dev server listens to requests on.
158
- *
159
- * @default `http`
160
- * @todo this needs to be implemented
161
- */
162
- local_protocol: "http" | "https";
163
-
164
- /**
165
- * Protocol that wrangler dev forwards requests on
166
- *
167
- * Setting this to `http` is not currently implemented.
168
- * See https://github.com/cloudflare/wrangler2/issues/583
169
- *
170
- * @default `https`
171
- */
172
- upstream_protocol: "https" | "http";
173
-
174
- /**
175
- * Host to forward requests to, defaults to the zone of project
176
- */
177
- host: string | undefined;
178
- }
179
-
180
- export type RawDevConfig = Partial<DevConfig>;
181
-
182
- export interface DeprecatedConfigFields {
183
- /**
184
- * The project "type". A holdover from wrangler 1.x.
185
- * Valid values were "webpack", "javascript", and "rust".
186
- *
187
- * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
188
- * @breaking
189
- */
190
- type?: "webpack" | "javascript" | "rust";
191
-
192
- /**
193
- * Path to the webpack config to use when building your worker.
194
- * A holdover from wrangler 1.x, used with `type: "webpack"`.
195
- *
196
- * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
197
- * @breaking
198
- */
199
- webpack_config?: string;
200
- }
201
-
202
- interface EnvironmentMap {
203
- /**
204
- * The `env` section defines overrides for the configuration for different environments.
205
- *
206
- * All environment fields can be specified at the top level of the config indicating the default environment settings.
207
- *
208
- * - Some fields are inherited and overridable in each environment.
209
- * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
210
- *
211
- * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
212
- *
213
- * @default `{}`
214
- */
215
- env?: {
216
- [envName: string]: RawEnvironment;
217
- };
218
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Diagnostic errors and warnings.
3
- *
4
- * The structure is a tree, where each node can contain zero or more errors, warnings and child diagnostics objects.
5
- * You can check whether the overall tree has errors or warnings, and you can render a string representation of the errors or warnings.
6
- */
7
- export class Diagnostics {
8
- errors: string[] = [];
9
- warnings: string[] = [];
10
- children: Diagnostics[] = [];
11
-
12
- /**
13
- * Create a new Diagnostics object.
14
- * @param description A general description of this collection of messages.
15
- */
16
- constructor(public description: string) {}
17
-
18
- /**
19
- * Merge the given `diagnostics` into this as a child.
20
- */
21
- addChild(diagnostics: Diagnostics): void {
22
- if (diagnostics.hasErrors() || diagnostics.hasWarnings()) {
23
- this.children.push(diagnostics);
24
- }
25
- }
26
-
27
- /** Does this or any of its children have errors. */
28
- hasErrors(): boolean {
29
- if (this.errors.length > 0) {
30
- return true;
31
- } else {
32
- return this.children.some((child) => child.hasErrors());
33
- }
34
- }
35
-
36
- /** Render the errors of this and all its children. */
37
- renderErrors(): string {
38
- return this.render("errors");
39
- }
40
-
41
- /** Does this or any of its children have warnings. */
42
- hasWarnings(): boolean {
43
- if (this.warnings.length > 0) {
44
- return true;
45
- } else {
46
- return this.children.some((child) => child.hasWarnings());
47
- }
48
- }
49
-
50
- /** Render the warnings of this and all its children. */
51
- renderWarnings(): string {
52
- return this.render("warnings");
53
- }
54
-
55
- private render(field: "errors" | "warnings"): string {
56
- const hasMethod = field === "errors" ? "hasErrors" : "hasWarnings";
57
- return indentText(
58
- `${this.description}\n` +
59
- // Output all the fields (errors or warnings) at this level
60
- this[field].map((message) => `- ${indentText(message)}`).join("\n") +
61
- // Output all the child diagnostics at the next level
62
- this.children
63
- .map((child) =>
64
- child[hasMethod]() ? "\n- " + child.render(field) : ""
65
- )
66
- .filter((output) => output !== "")
67
- .join("\n")
68
- );
69
- }
70
- }
71
-
72
- /** Indent all the but the first line by two spaces. */
73
- function indentText(str: string): string {
74
- return str
75
- .split("\n")
76
- .map((line, index) =>
77
- (index === 0 ? line : ` ${line}`).replace(/^\s*$/, "")
78
- )
79
- .join("\n");
80
- }
@@ -1,366 +0,0 @@
1
- /**
2
- * The `Environment` interface declares all the configuration fields that
3
- * can be specified for an environment.
4
- *
5
- * This could be the top-level default environment, or a specific named environment.
6
- */
7
- export interface Environment
8
- extends EnvironmentInheritable,
9
- EnvironmentNonInheritable {}
10
-
11
- /**
12
- * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
13
- * that can be inherited (and overridden) from the top-level environment.
14
- */
15
- 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;
170
- }
171
-
172
- /**
173
- * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
174
- * that cannot be inherited from the top-level environment, and must be defined specifically.
175
- *
176
- * If any of these fields are defined at the top-level then they should also be specifically defined
177
- * for each named environment.
178
- */
179
- 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
- };
277
- }
278
-
279
- /**
280
- * The environment configuration properties that have been deprecated.
281
- */
282
- 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
- }[];
305
- }
306
-
307
- /**
308
- * Deprecated upload configuration.
309
- */
310
- 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"];
339
- }
340
-
341
- /**
342
- * The raw environment configuration that we read from the config file.
343
- *
344
- * All the properties are optional, and will be replaced with defaults in the configuration that
345
- * is used in the rest of the codebase.
346
- */
347
- export type RawEnvironment = Partial<Environment> & EnvironmentDeprecated;
348
-
349
- /**
350
- * A bundling resolver rule, defining the modules type for paths that match the specified globs.
351
- */
352
- export type Rule = {
353
- type: ConfigModuleRuleType;
354
- globs: string[];
355
- fallthrough?: boolean;
356
- };
357
-
358
- /**
359
- * The possible types for a `Rule`.
360
- */
361
- export type ConfigModuleRuleType =
362
- | "ESModule"
363
- | "CommonJS"
364
- | "CompiledWasm"
365
- | "Text"
366
- | "Data";