wrangler 0.0.0-e2b7352 → 0.0.0-e305903a

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 (264) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +51 -14
  3. package/bin/wrangler.js +154 -31
  4. package/kv-asset-handler.js +1 -0
  5. package/miniflare-dist/index.mjs +6244 -21
  6. package/package.json +185 -141
  7. package/src/__tests__/api-dev.test.ts +209 -0
  8. package/src/__tests__/api-devregistry.test.js +56 -0
  9. package/src/__tests__/api.test.ts +80 -0
  10. package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
  11. package/src/__tests__/config-cache.test.ts +42 -0
  12. package/src/__tests__/configuration.test.ts +4122 -2810
  13. package/src/__tests__/dev.test.tsx +1341 -527
  14. package/src/__tests__/dialogs.test.tsx +40 -0
  15. package/src/__tests__/generate.test.ts +91 -0
  16. package/src/__tests__/guess-worker-format.test.ts +74 -57
  17. package/src/__tests__/helpers/cmd-shim.d.ts +6 -6
  18. package/src/__tests__/helpers/mock-account-id.ts +24 -24
  19. package/src/__tests__/helpers/mock-bin.ts +20 -20
  20. package/src/__tests__/helpers/mock-cfetch.ts +202 -93
  21. package/src/__tests__/helpers/mock-console.ts +68 -32
  22. package/src/__tests__/helpers/mock-dialogs.ts +121 -33
  23. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
  24. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  25. package/src/__tests__/helpers/mock-istty.ts +74 -0
  26. package/src/__tests__/helpers/mock-known-routes.ts +7 -0
  27. package/src/__tests__/helpers/mock-kv.ts +26 -26
  28. package/src/__tests__/helpers/mock-oauth-flow.ts +252 -0
  29. package/src/__tests__/helpers/mock-process.ts +39 -0
  30. package/src/__tests__/helpers/mock-stdin.ts +82 -77
  31. package/src/__tests__/helpers/mock-web-socket.ts +21 -21
  32. package/src/__tests__/helpers/msw/handlers/index.ts +13 -0
  33. package/src/__tests__/helpers/msw/handlers/namespaces.ts +104 -0
  34. package/src/__tests__/helpers/msw/handlers/oauth.ts +36 -0
  35. package/src/__tests__/helpers/msw/handlers/r2.ts +80 -0
  36. package/src/__tests__/helpers/msw/handlers/user.ts +63 -0
  37. package/src/__tests__/helpers/msw/index.ts +4 -0
  38. package/src/__tests__/helpers/run-in-tmp.ts +28 -22
  39. package/src/__tests__/helpers/run-wrangler.ts +8 -8
  40. package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
  41. package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +5 -0
  42. package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
  43. package/src/__tests__/helpers/worker-scripts/parent-worker.js +8 -0
  44. package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
  45. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  46. package/src/__tests__/helpers/write-wrangler-toml.ts +9 -9
  47. package/src/__tests__/https-options.test.ts +144 -108
  48. package/src/__tests__/index.test.ts +233 -967
  49. package/src/__tests__/init.test.ts +2717 -0
  50. package/src/__tests__/jest.setup.ts +151 -34
  51. package/src/__tests__/kv.test.ts +1376 -1085
  52. package/src/__tests__/logger.test.ts +141 -0
  53. package/src/__tests__/metrics.test.ts +450 -0
  54. package/src/__tests__/middleware.scheduled.test.ts +135 -0
  55. package/src/__tests__/middleware.test.ts +726 -0
  56. package/src/__tests__/package-manager.test.ts +312 -165
  57. package/src/__tests__/pages.test.ts +1990 -77
  58. package/src/__tests__/parse.test.ts +253 -245
  59. package/src/__tests__/paths.test.ts +39 -0
  60. package/src/__tests__/publish.test.ts +6989 -3411
  61. package/src/__tests__/pubsub.test.ts +367 -0
  62. package/src/__tests__/r2.test.ts +363 -190
  63. package/src/__tests__/route.test.ts +22 -22
  64. package/src/__tests__/secret.test.ts +626 -407
  65. package/src/__tests__/tail.test.ts +653 -516
  66. package/src/__tests__/test-old-node-version.js +31 -0
  67. package/src/__tests__/user.test.ts +155 -0
  68. package/src/__tests__/validate-dev-props.test.ts +56 -0
  69. package/src/__tests__/version.test.ts +35 -0
  70. package/src/__tests__/whoami.test.tsx +261 -88
  71. package/src/__tests__/worker-namespace.test.ts +319 -0
  72. package/src/abort.d.ts +3 -0
  73. package/src/api/dev.ts +206 -0
  74. package/src/api/index.ts +2 -0
  75. package/src/bundle-reporter.tsx +29 -0
  76. package/src/bundle.ts +723 -122
  77. package/src/cfetch/index.ts +83 -66
  78. package/src/cfetch/internal.ts +267 -92
  79. package/src/cli.ts +24 -14
  80. package/src/config/README.md +1 -1
  81. package/src/config/config.ts +236 -179
  82. package/src/config/diagnostics.ts +61 -61
  83. package/src/config/environment.ts +450 -316
  84. package/src/config/index.ts +259 -38
  85. package/src/config/validation-helpers.ts +385 -342
  86. package/src/config/validation.ts +1797 -1099
  87. package/src/config-cache.ts +85 -0
  88. package/src/create-worker-preview.ts +233 -124
  89. package/src/create-worker-upload-form.ts +285 -201
  90. package/src/d1/backups.tsx +212 -0
  91. package/src/d1/create.tsx +54 -0
  92. package/src/d1/delete.tsx +56 -0
  93. package/src/d1/execute.tsx +294 -0
  94. package/src/d1/formatTimeAgo.ts +14 -0
  95. package/src/d1/index.ts +75 -0
  96. package/src/d1/list.tsx +48 -0
  97. package/src/d1/options.ts +12 -0
  98. package/src/d1/types.tsx +14 -0
  99. package/src/d1/utils.ts +39 -0
  100. package/src/dev/dev-vars.ts +36 -0
  101. package/src/dev/dev.tsx +501 -328
  102. package/src/dev/get-local-persistence-path.tsx +31 -0
  103. package/src/dev/local.tsx +629 -211
  104. package/src/dev/remote.tsx +398 -188
  105. package/src/dev/start-server.ts +443 -0
  106. package/src/dev/use-esbuild.ts +175 -82
  107. package/src/dev/validate-dev-props.ts +31 -0
  108. package/src/dev-registry.tsx +190 -0
  109. package/src/dev.tsx +869 -0
  110. package/src/dialogs.tsx +138 -57
  111. package/src/dispatch-namespace.ts +206 -0
  112. package/src/durable.ts +102 -0
  113. package/src/entry.ts +260 -171
  114. package/src/environment-variables.ts +40 -23
  115. package/src/errors.ts +11 -0
  116. package/src/faye-websocket.d.ts +6 -0
  117. package/src/generate.ts +131 -0
  118. package/src/git-client.ts +42 -0
  119. package/src/global-wrangler-config-path.ts +26 -0
  120. package/src/https-options.ts +85 -80
  121. package/src/index.tsx +2295 -2315
  122. package/src/init.ts +967 -0
  123. package/src/inspect.ts +687 -557
  124. package/src/intl-polyfill.d.ts +123 -123
  125. package/src/is-ci.ts +14 -0
  126. package/src/is-interactive.ts +12 -0
  127. package/src/kv.ts +353 -242
  128. package/src/logger.ts +80 -0
  129. package/src/metrics/index.ts +5 -0
  130. package/src/metrics/metrics-config.ts +239 -0
  131. package/src/metrics/metrics-dispatcher.ts +96 -0
  132. package/src/metrics/metrics-usage-headers.ts +24 -0
  133. package/src/metrics/send-event.ts +93 -0
  134. package/src/miniflare-cli/assets.ts +215 -0
  135. package/src/miniflare-cli/index.ts +201 -30
  136. package/src/miniflare-cli/request-context.ts +40 -0
  137. package/src/module-collection.ts +213 -213
  138. package/src/open-in-browser.ts +8 -16
  139. package/src/package-manager.ts +183 -90
  140. package/src/pages/build.tsx +238 -0
  141. package/src/pages/constants.ts +16 -0
  142. package/src/pages/deployments.tsx +106 -0
  143. package/src/pages/dev.tsx +684 -0
  144. package/src/pages/errors.ts +66 -0
  145. package/src/pages/functions/buildPlugin.ts +110 -0
  146. package/src/pages/functions/buildWorker.ts +156 -0
  147. package/src/pages/functions/filepath-routing.test.ts +234 -0
  148. package/src/pages/functions/filepath-routing.ts +189 -0
  149. package/src/pages/functions/identifiers.ts +78 -0
  150. package/src/pages/functions/routes-consolidation.test.ts +250 -0
  151. package/src/pages/functions/routes-consolidation.ts +73 -0
  152. package/src/pages/functions/routes-transformation.test.ts +282 -0
  153. package/src/pages/functions/routes-transformation.ts +115 -0
  154. package/src/pages/functions/routes-validation.test.ts +403 -0
  155. package/src/pages/functions/routes-validation.ts +202 -0
  156. package/src/pages/functions/routes.ts +151 -0
  157. package/src/pages/functions.tsx +82 -0
  158. package/src/pages/hash.tsx +13 -0
  159. package/src/pages/index.tsx +94 -0
  160. package/src/pages/projects.tsx +169 -0
  161. package/src/pages/publish.tsx +419 -0
  162. package/src/pages/types.ts +49 -0
  163. package/src/pages/upload.tsx +398 -0
  164. package/src/pages/utils.ts +12 -0
  165. package/src/parse.ts +224 -121
  166. package/src/paths.ts +53 -8
  167. package/src/preview.ts +31 -0
  168. package/src/proxy.ts +436 -370
  169. package/src/publish.ts +839 -324
  170. package/src/pubsub/index.ts +286 -0
  171. package/src/pubsub/pubsub-commands.tsx +623 -0
  172. package/src/r2.ts +100 -19
  173. package/src/selfsigned.d.ts +23 -23
  174. package/src/sites.tsx +281 -189
  175. package/src/tail/filters.ts +108 -110
  176. package/src/tail/index.ts +234 -218
  177. package/src/tail/printing.ts +92 -47
  178. package/src/update-check.ts +19 -0
  179. package/src/user/choose-account.tsx +69 -0
  180. package/src/user/env-vars.ts +46 -0
  181. package/src/user/generate-auth-url.ts +33 -0
  182. package/src/user/generate-random-state.ts +16 -0
  183. package/src/user/index.ts +3 -0
  184. package/src/user/user.tsx +1192 -0
  185. package/src/whoami.tsx +142 -42
  186. package/src/worker.ts +171 -100
  187. package/src/zones.ts +167 -0
  188. package/templates/checked-fetch.js +17 -0
  189. package/templates/d1-beta-facade.js +174 -0
  190. package/templates/experimental-local-cache-stubs.js +27 -0
  191. package/templates/first-party-worker-module-facade.ts +18 -0
  192. package/templates/format-dev-errors.ts +32 -0
  193. package/templates/gitignore +171 -0
  194. package/templates/init-tests/test-jest-new-worker.js +25 -0
  195. package/templates/init-tests/test-vitest-new-worker.js +26 -0
  196. package/templates/middleware/common.ts +62 -0
  197. package/templates/middleware/loader-modules.ts +84 -0
  198. package/templates/middleware/loader-sw.ts +213 -0
  199. package/templates/middleware/middleware-pretty-error.ts +40 -0
  200. package/templates/middleware/middleware-scheduled.ts +15 -0
  201. package/templates/new-worker-scheduled.js +17 -0
  202. package/templates/new-worker-scheduled.ts +32 -0
  203. package/templates/new-worker.js +3 -3
  204. package/templates/new-worker.ts +18 -3
  205. package/templates/no-op-worker.js +10 -0
  206. package/templates/pages-dev-pipeline.ts +35 -0
  207. package/templates/pages-shim.ts +9 -0
  208. package/templates/pages-template-plugin.ts +167 -0
  209. package/templates/pages-template-worker.ts +172 -0
  210. package/templates/serve-static-assets.ts +63 -0
  211. package/templates/service-bindings-module-facade.js +54 -0
  212. package/templates/service-bindings-sw-facade.js +42 -0
  213. package/templates/tsconfig.json +95 -95
  214. package/wrangler-dist/cli.d.ts +841 -0
  215. package/wrangler-dist/cli.js +129492 -108210
  216. package/miniflare-dist/index.mjs.map +0 -7
  217. package/pages/functions/buildWorker.ts +0 -62
  218. package/pages/functions/filepath-routing.test.ts +0 -223
  219. package/pages/functions/filepath-routing.ts +0 -181
  220. package/pages/functions/identifiers.ts +0 -78
  221. package/pages/functions/routes.ts +0 -151
  222. package/pages/functions/template-worker.ts +0 -130
  223. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  224. package/src/__tests__/logout.test.ts +0 -52
  225. package/src/__tests__/sentry.test.ts +0 -146
  226. package/src/miniflare-cli/enum-keys.ts +0 -17
  227. package/src/pages.tsx +0 -1061
  228. package/src/reporting.ts +0 -131
  229. package/src/user.tsx +0 -1127
  230. package/templates/static-asset-facade.js +0 -47
  231. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  232. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  233. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  234. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  235. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  236. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  237. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  238. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  239. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  240. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  241. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  242. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  243. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  244. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  245. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  246. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  247. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  248. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  249. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  250. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  251. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  252. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  253. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  254. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  255. package/vendor/wrangler-mime/LICENSE +0 -21
  256. package/vendor/wrangler-mime/Mime.js +0 -97
  257. package/vendor/wrangler-mime/README.md +0 -187
  258. package/vendor/wrangler-mime/cli.js +0 -46
  259. package/vendor/wrangler-mime/index.js +0 -4
  260. package/vendor/wrangler-mime/lite.js +0 -4
  261. package/vendor/wrangler-mime/package.json +0 -52
  262. package/vendor/wrangler-mime/types/other.js +0 -1
  263. package/vendor/wrangler-mime/types/standard.js +0 -1
  264. package/wrangler-dist/cli.js.map +0 -7
@@ -0,0 +1,841 @@
1
+ /// <reference types="node" />
2
+
3
+ import { Blob as Blob_2 } from 'buffer';
4
+ import Dispatcher = require('./dispatcher');
5
+ import { ReadableStream } from 'stream/web';
6
+ import { URL as URL_2 } from 'url';
7
+ import { URLSearchParams as URLSearchParams_2 } from 'url';
8
+
9
+ declare interface BlobPropertyBag {
10
+ type?: string
11
+ endings?: 'native' | 'transparent'
12
+ }
13
+
14
+ declare type BodyInit =
15
+ | ArrayBuffer
16
+ | AsyncIterable<Uint8Array>
17
+ | Blob_2
18
+ | FormData
19
+ | Iterable<Uint8Array>
20
+ | NodeJS.ArrayBufferView
21
+ | URLSearchParams_2
22
+ | null
23
+ | string
24
+
25
+ declare interface BodyMixin {
26
+ readonly body: ReadableStream | null
27
+ readonly bodyUsed: boolean
28
+
29
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
30
+ readonly blob: () => Promise<Blob_2>
31
+ readonly formData: () => Promise<FormData>
32
+ readonly json: () => Promise<unknown>
33
+ readonly text: () => Promise<string>
34
+ }
35
+
36
+ /**
37
+ * The possible types for a `Rule`.
38
+ */
39
+ declare type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data";
40
+
41
+ declare type CustomDomainRoute = {
42
+ pattern: string;
43
+ custom_domain: boolean;
44
+ };
45
+
46
+ /**
47
+ * Deprecated upload configuration.
48
+ */
49
+ declare interface DeprecatedUpload {
50
+ /**
51
+ * The format of the Worker script.
52
+ *
53
+ * @deprecated We infer the format automatically now.
54
+ */
55
+ format?: "modules" | "service-worker";
56
+ /**
57
+ * The directory you wish to upload your worker from,
58
+ * relative to the wrangler.toml file.
59
+ *
60
+ * Defaults to the directory containing the wrangler.toml file.
61
+ *
62
+ * @deprecated
63
+ */
64
+ dir?: string;
65
+ /**
66
+ * The path to the Worker script, relative to `upload.dir`.
67
+ *
68
+ * @deprecated This will be replaced by a command line argument.
69
+ */
70
+ main?: string;
71
+ /**
72
+ * @deprecated This is now defined at the top level `rules` field.
73
+ */
74
+ rules?: Environment["rules"];
75
+ }
76
+
77
+ declare interface DevApiOptions {
78
+ testMode?: boolean;
79
+ disableExperimentalWarning?: boolean;
80
+ }
81
+
82
+ declare interface DevOptions {
83
+ config?: string;
84
+ env?: string;
85
+ ip?: string;
86
+ port?: number;
87
+ bundle?: boolean;
88
+ inspectorPort?: number;
89
+ localProtocol?: "http" | "https";
90
+ assets?: string;
91
+ site?: string;
92
+ siteInclude?: string[];
93
+ siteExclude?: string[];
94
+ nodeCompat?: boolean;
95
+ compatibilityDate?: string;
96
+ compatibilityFlags?: string[];
97
+ persist?: boolean;
98
+ persistTo?: string;
99
+ liveReload?: boolean;
100
+ watch?: boolean;
101
+ vars?: {
102
+ [key: string]: unknown;
103
+ };
104
+ kv?: {
105
+ binding: string;
106
+ id: string;
107
+ preview_id?: string;
108
+ }[];
109
+ durableObjects?: {
110
+ name: string;
111
+ class_name: string;
112
+ script_name?: string | undefined;
113
+ environment?: string | undefined;
114
+ }[];
115
+ r2?: {
116
+ binding: string;
117
+ bucket_name: string;
118
+ preview_bucket_name?: string;
119
+ }[];
120
+ d1Databases?: Environment["d1_databases"];
121
+ showInteractiveDevSession?: boolean;
122
+ logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
123
+ logPrefix?: string;
124
+ inspect?: boolean;
125
+ forceLocal?: boolean;
126
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
127
+ _?: (string | number)[];
128
+ $0?: string;
129
+ testScheduled?: boolean;
130
+ }
131
+
132
+ declare interface EnablePagesAssetsServiceBindingOptions {
133
+ proxyPort?: number;
134
+ directory?: string;
135
+ }
136
+
137
+ /**
138
+ * The `Environment` interface declares all the configuration fields that
139
+ * can be specified for an environment.
140
+ *
141
+ * This could be the top-level default environment, or a specific named environment.
142
+ */
143
+ declare interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
144
+ }
145
+
146
+ /**
147
+ * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
148
+ * that can be inherited (and overridden) from the top-level environment.
149
+ */
150
+ declare interface EnvironmentInheritable {
151
+ /**
152
+ * The name of your worker. Alphanumeric + dashes only.
153
+ *
154
+ * @inheritable
155
+ */
156
+ name: string | undefined;
157
+ /**
158
+ * This is the ID of the account associated with your zone.
159
+ * You might have more than one account, so make sure to use
160
+ * the ID of the account associated with the zone/route you
161
+ * provide, if you provide one. It can also be specified through
162
+ * the CLOUDFLARE_ACCOUNT_ID environment variable.
163
+ *
164
+ * @inheritable
165
+ */
166
+ account_id: string | undefined;
167
+ /**
168
+ * A date in the form yyyy-mm-dd, which will be used to determine
169
+ * which version of the Workers runtime is used.
170
+ *
171
+ * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
172
+ *
173
+ * @inheritable
174
+ */
175
+ compatibility_date: string | undefined;
176
+ /**
177
+ * A list of flags that enable features from upcoming features of
178
+ * the Workers runtime, usually used together with compatibility_flags.
179
+ *
180
+ * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
181
+ *
182
+ * @inheritable
183
+ */
184
+ compatibility_flags: string[];
185
+ /**
186
+ * The entrypoint/path to the JavaScript file that will be executed.
187
+ */
188
+ main: string | undefined;
189
+ /**
190
+ * Whether we use <name>.<subdomain>.workers.dev to
191
+ * test and deploy your worker.
192
+ *
193
+ * @default `true` (This is a breaking change from wrangler 1)
194
+ * @breaking
195
+ * @inheritable
196
+ */
197
+ workers_dev: boolean | undefined;
198
+ /**
199
+ * A list of routes that your worker should be published to.
200
+ * Only one of `routes` or `route` is required.
201
+ *
202
+ * Only required when workers_dev is false, and there's no scheduled worker (see `triggers`)
203
+ *
204
+ * @inheritable
205
+ */
206
+ routes: Route[] | undefined;
207
+ /**
208
+ * A route that your worker should be published to. Literally
209
+ * the same as routes, but only one.
210
+ * Only one of `routes` or `route` is required.
211
+ *
212
+ * Only required when workers_dev is false, and there's no scheduled worker
213
+ *
214
+ * @inheritable
215
+ */
216
+ route: Route | undefined;
217
+ /**
218
+ * Path to a custom tsconfig
219
+ */
220
+ tsconfig: string | undefined;
221
+ /**
222
+ * The function to use to replace jsx syntax.
223
+ *
224
+ * @default `"React.createElement"`
225
+ * @inheritable
226
+ */
227
+ jsx_factory: string;
228
+ /**
229
+ * The function to use to replace jsx fragment syntax.
230
+ *
231
+ * @default `"React.Fragment"`
232
+ * @inheritable
233
+ */
234
+ jsx_fragment: string;
235
+ /**
236
+ * "Cron" definitions to trigger a worker's "scheduled" function.
237
+ *
238
+ * Lets you call workers periodically, much like a cron job.
239
+ *
240
+ * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
241
+ *
242
+ * @default `{crons:[]}`
243
+ * @inheritable
244
+ */
245
+ triggers: {
246
+ crons: string[];
247
+ };
248
+ /**
249
+ * Specifies the Usage Model for your Worker. There are two options -
250
+ * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
251
+ * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
252
+ * For newly created Workers, if the Usage Model is omitted
253
+ * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
254
+ * For existing Workers, if the Usage Model is omitted, it will be
255
+ * set to the Usage Model configured in the dashboard for that Worker.
256
+ *
257
+ * @inheritable
258
+ */
259
+ usage_model: "bundled" | "unbound" | undefined;
260
+ /**
261
+ * An ordered list of rules that define which modules to import,
262
+ * and what type to import them as. You will need to specify rules
263
+ * to use Text, Data, and CompiledWasm modules, or when you wish to
264
+ * have a .js file be treated as an ESModule instead of CommonJS.
265
+ *
266
+ * @inheritable
267
+ */
268
+ rules: Rule[];
269
+ /**
270
+ * Configures a custom build step to be run by Wrangler when building your Worker.
271
+ *
272
+ * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
273
+ * for more details.
274
+ *
275
+ * @default {}
276
+ */
277
+ build: {
278
+ /** 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. */
279
+ command?: string;
280
+ /** The directory in which the command is executed. */
281
+ cwd?: string;
282
+ /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
283
+ watch_dir?: string | string[];
284
+ /**
285
+ * Deprecated field previously used to configure the build and upload of the script.
286
+ * @deprecated
287
+ */
288
+ upload?: DeprecatedUpload;
289
+ };
290
+ /**
291
+ * Skip internal build steps and directly publish script
292
+ * @inheritable
293
+ */
294
+ no_bundle: boolean | undefined;
295
+ /**
296
+ * Minify the script before uploading.
297
+ * @inheritable
298
+ */
299
+ minify: boolean | undefined;
300
+ /**
301
+ * Add polyfills for node builtin modules and globals
302
+ * @inheritable
303
+ */
304
+ node_compat: boolean | undefined;
305
+ /**
306
+ * Specifies namespace bindings that are bound to this Worker environment.
307
+ *
308
+ * NOTE: This field is not automatically inherited from the top level environment,
309
+ * and so must be specified in every named environment.
310
+ *
311
+ * @default `[]`
312
+ * @nonInheritable
313
+ */
314
+ dispatch_namespaces: {
315
+ /** The binding name used to refer to the bound service. */
316
+ binding: string;
317
+ /** The namespace to bind to. */
318
+ namespace: string;
319
+ }[];
320
+ /**
321
+ * Designates this worker as an internal-only "first-party" worker.
322
+ */
323
+ first_party_worker: boolean | undefined;
324
+ /**
325
+ * TODO: remove this as it has been deprecated.
326
+ *
327
+ * This is just here for now because the `route` commands use it.
328
+ * So we need to include it in this type so it is available.
329
+ */
330
+ zone_id?: string;
331
+ /**
332
+ * Specify a compiled capnp schema to use
333
+ * Then add a binding per field in the top level message that you will send to logfwdr
334
+ *
335
+ * @default `{schema:undefined,bindings:[]}`
336
+ * @inheritable
337
+ */
338
+ logfwdr: {
339
+ /** capnp schema filename */
340
+ schema: string | undefined;
341
+ bindings: {
342
+ /** The binding name used to refer to logfwdr */
343
+ name: string;
344
+ /** The destination for this logged message */
345
+ destination: string;
346
+ }[];
347
+ };
348
+ }
349
+
350
+ /**
351
+ * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
352
+ * that cannot be inherited from the top-level environment, and must be defined specifically.
353
+ *
354
+ * If any of these fields are defined at the top-level then they should also be specifically defined
355
+ * for each named environment.
356
+ */
357
+ declare interface EnvironmentNonInheritable {
358
+ /**
359
+ * A map of values to substitute when deploying your worker.
360
+ *
361
+ * NOTE: This field is not automatically inherited from the top level environment,
362
+ * and so must be specified in every named environment.
363
+ *
364
+ * @default `{}`
365
+ * @nonInheritable
366
+ */
367
+ define: Record<string, string>;
368
+ /**
369
+ * A map of environment variables to set when deploying your worker.
370
+ *
371
+ * NOTE: This field is not automatically inherited from the top level environment,
372
+ * and so must be specified in every named environment.
373
+ *
374
+ * @default `{}`
375
+ * @nonInheritable
376
+ */
377
+ vars: {
378
+ [key: string]: unknown;
379
+ };
380
+ /**
381
+ * A list of durable objects that your worker should be bound to.
382
+ *
383
+ * For more information about Durable Objects, see the documentation at
384
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
385
+ *
386
+ * NOTE: This field is not automatically inherited from the top level environment,
387
+ * and so must be specified in every named environment.
388
+ *
389
+ * @default `{bindings:[]}`
390
+ * @nonInheritable
391
+ */
392
+ durable_objects: {
393
+ bindings: {
394
+ /** The name of the binding used to refer to the Durable Object */
395
+ name: string;
396
+ /** The exported class name of the Durable Object */
397
+ class_name: string;
398
+ /** The script where the Durable Object is defined (if it's external to this worker) */
399
+ script_name?: string;
400
+ /** The service environment of the script_name to bind to */
401
+ environment?: string;
402
+ }[];
403
+ };
404
+ /**
405
+ * These specify any Workers KV Namespaces you want to
406
+ * access from inside your Worker.
407
+ *
408
+ * To learn more about KV Namespaces,
409
+ * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
410
+ *
411
+ * NOTE: This field is not automatically inherited from the top level environment,
412
+ * and so must be specified in every named environment.
413
+ *
414
+ * @default `[]`
415
+ * @nonInheritable
416
+ */
417
+ kv_namespaces: {
418
+ /** The binding name used to refer to the KV Namespace */
419
+ binding: string;
420
+ /** The ID of the KV namespace */
421
+ id: string;
422
+ /** The ID of the KV namespace used during `wrangler dev` */
423
+ preview_id?: string;
424
+ }[];
425
+ /**
426
+ * Specifies R2 buckets that are bound to this Worker environment.
427
+ *
428
+ * NOTE: This field is not automatically inherited from the top level environment,
429
+ * and so must be specified in every named environment.
430
+ *
431
+ * @default `[]`
432
+ * @nonInheritable
433
+ */
434
+ r2_buckets: {
435
+ /** The binding name used to refer to the R2 bucket in the worker. */
436
+ binding: string;
437
+ /** The name of this R2 bucket at the edge. */
438
+ bucket_name: string;
439
+ /** The preview name of this R2 bucket at the edge. */
440
+ preview_bucket_name?: string;
441
+ }[];
442
+ /**
443
+ * Specifies D1 databases that are bound to this Worker environment.
444
+ *
445
+ * NOTE: This field is not automatically inherited from the top level environment,
446
+ * and so must be specified in every named environment.
447
+ *
448
+ * @default `[]`
449
+ * @nonInheritable
450
+ */
451
+ d1_databases: {
452
+ /** The binding name used to refer to the D1 database in the worker. */
453
+ binding: string;
454
+ /** The name of this D1 database. */
455
+ database_name: string;
456
+ /** The UUID of this D1 database (not required). */
457
+ database_id: string;
458
+ /** The UUID of this D1 database for Wrangler Dev (if specified). */
459
+ preview_database_id?: string;
460
+ }[];
461
+ /**
462
+ * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
463
+ *
464
+ * NOTE: This field is not automatically inherited from the top level environment,
465
+ * and so must be specified in every named environment.
466
+ *
467
+ * @default `[]`
468
+ * @nonInheritable
469
+ */
470
+ services: {
471
+ /** The binding name used to refer to the bound service. */
472
+ binding: string;
473
+ /** The name of the service. */
474
+ service: string;
475
+ /** The environment of the service (e.g. production, staging, etc). */
476
+ environment?: string;
477
+ }[] | undefined;
478
+ /**
479
+ * "Unsafe" tables for features that aren't directly supported by wrangler.
480
+ *
481
+ * NOTE: This field is not automatically inherited from the top level environment,
482
+ * and so must be specified in every named environment.
483
+ *
484
+ * @default `{ bindings: [] }`
485
+ * @nonInheritable
486
+ */
487
+ unsafe: {
488
+ /**
489
+ * A set of bindings that should be put into a Worker's upload metadata without changes. These
490
+ * can be used to implement bindings for features that haven't released and aren't supported
491
+ * directly by wrangler or miniflare.
492
+ *
493
+ * @default []
494
+ */
495
+ bindings: {
496
+ name: string;
497
+ type: string;
498
+ [key: string]: unknown;
499
+ }[];
500
+ };
501
+ }
502
+
503
+ declare class File extends Blob_2 {
504
+ /**
505
+ * Creates a new File instance.
506
+ *
507
+ * @param fileBits An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
508
+ * @param fileName The name of the file.
509
+ * @param options An options object containing optional attributes for the file.
510
+ */
511
+ constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FilePropertyBag)
512
+
513
+ /**
514
+ * Name of the file referenced by the File object.
515
+ */
516
+ readonly name: string
517
+
518
+ /**
519
+ * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
520
+ */
521
+ readonly lastModified: number
522
+
523
+ readonly [Symbol.toStringTag]: string
524
+ }
525
+
526
+ declare interface FilePropertyBag extends BlobPropertyBag {
527
+ /**
528
+ * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
529
+ */
530
+ lastModified?: number
531
+ }
532
+
533
+ /**
534
+ * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch().
535
+ */
536
+ declare class FormData {
537
+ /**
538
+ * Appends a new value onto an existing key inside a FormData object,
539
+ * or adds the key if it does not already exist.
540
+ *
541
+ * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
542
+ *
543
+ * @param name The name of the field whose data is contained in `value`.
544
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
545
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
546
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
547
+ */
548
+ append(name: string, value: unknown, fileName?: string): void
549
+
550
+ /**
551
+ * Set a new value for an existing key inside FormData,
552
+ * or add the new field if it does not already exist.
553
+ *
554
+ * @param name The name of the field whose data is contained in `value`.
555
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
556
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
557
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
558
+ *
559
+ */
560
+ set(name: string, value: unknown, fileName?: string): void
561
+
562
+ /**
563
+ * Returns the first value associated with a given key from within a `FormData` object.
564
+ * If you expect multiple values and want all of them, use the `getAll()` method instead.
565
+ *
566
+ * @param {string} name A name of the value you want to retrieve.
567
+ *
568
+ * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
569
+ */
570
+ get(name: string): FormDataEntryValue | null
571
+
572
+ /**
573
+ * Returns all the values associated with a given key from within a `FormData` object.
574
+ *
575
+ * @param {string} name A name of the value you want to retrieve.
576
+ *
577
+ * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
578
+ */
579
+ getAll(name: string): FormDataEntryValue[]
580
+
581
+ /**
582
+ * Returns a boolean stating whether a `FormData` object contains a certain key.
583
+ *
584
+ * @param name A string representing the name of the key you want to test for.
585
+ *
586
+ * @return A boolean value.
587
+ */
588
+ has(name: string): boolean
589
+
590
+ /**
591
+ * Deletes a key and its value(s) from a `FormData` object.
592
+ *
593
+ * @param name The name of the key you want to delete.
594
+ */
595
+ delete(name: string): void
596
+
597
+ /**
598
+ * Executes given callback function for each field of the FormData instance
599
+ */
600
+ forEach: (
601
+ callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void,
602
+ thisArg?: unknown
603
+ ) => void
604
+
605
+ /**
606
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
607
+ * Each key is a `string`.
608
+ */
609
+ keys: () => SpecIterableIterator<string>
610
+
611
+ /**
612
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
613
+ * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
614
+ */
615
+ values: () => SpecIterableIterator<FormDataEntryValue>
616
+
617
+ /**
618
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
619
+ * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
620
+ */
621
+ entries: () => SpecIterableIterator<[string, FormDataEntryValue]>
622
+
623
+ /**
624
+ * An alias for FormData#entries()
625
+ */
626
+ [Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>
627
+
628
+ readonly [Symbol.toStringTag]: string
629
+ }
630
+
631
+ /**
632
+ * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
633
+ */
634
+ declare type FormDataEntryValue = string | File
635
+
636
+ declare class Headers implements SpecIterable<[string, string]> {
637
+ constructor (init?: HeadersInit)
638
+ readonly append: (name: string, value: string) => void
639
+ readonly delete: (name: string) => void
640
+ readonly get: (name: string) => string | null
641
+ readonly has: (name: string) => boolean
642
+ readonly set: (name: string, value: string) => void
643
+ readonly forEach: (
644
+ callbackfn: (value: string, key: string, iterable: Headers) => void,
645
+ thisArg?: unknown
646
+ ) => void
647
+
648
+ readonly keys: () => SpecIterableIterator<string>
649
+ readonly values: () => SpecIterableIterator<string>
650
+ readonly entries: () => SpecIterableIterator<[string, string]>
651
+ readonly [Symbol.iterator]: () => SpecIterator<[string, string]>
652
+ }
653
+
654
+ declare type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
655
+
656
+ declare type ReferrerPolicy =
657
+ | ''
658
+ | 'no-referrer'
659
+ | 'no-referrer-when-downgrade'
660
+ | 'origin'
661
+ | 'origin-when-cross-origin'
662
+ | 'same-origin'
663
+ | 'strict-origin'
664
+ | 'strict-origin-when-cross-origin'
665
+ | 'unsafe-url';
666
+
667
+ declare class Request implements BodyMixin {
668
+ constructor (input: RequestInfo, init?: RequestInit)
669
+
670
+ readonly cache: RequestCache
671
+ readonly credentials: RequestCredentials
672
+ readonly destination: RequestDestination
673
+ readonly headers: Headers
674
+ readonly integrity: string
675
+ readonly method: string
676
+ readonly mode: RequestMode
677
+ readonly redirect: RequestRedirect
678
+ readonly referrerPolicy: string
679
+ readonly url: string
680
+
681
+ readonly keepalive: boolean
682
+ readonly signal: AbortSignal
683
+
684
+ readonly body: ReadableStream | null
685
+ readonly bodyUsed: boolean
686
+
687
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
688
+ readonly blob: () => Promise<Blob_2>
689
+ readonly formData: () => Promise<FormData>
690
+ readonly json: () => Promise<unknown>
691
+ readonly text: () => Promise<string>
692
+
693
+ readonly clone: () => Request
694
+ }
695
+
696
+ declare type RequestCache =
697
+ | 'default'
698
+ | 'force-cache'
699
+ | 'no-cache'
700
+ | 'no-store'
701
+ | 'only-if-cached'
702
+ | 'reload'
703
+
704
+ declare type RequestCredentials = 'omit' | 'include' | 'same-origin'
705
+
706
+ declare type RequestDestination =
707
+ | ''
708
+ | 'audio'
709
+ | 'audioworklet'
710
+ | 'document'
711
+ | 'embed'
712
+ | 'font'
713
+ | 'image'
714
+ | 'manifest'
715
+ | 'object'
716
+ | 'paintworklet'
717
+ | 'report'
718
+ | 'script'
719
+ | 'sharedworker'
720
+ | 'style'
721
+ | 'track'
722
+ | 'video'
723
+ | 'worker'
724
+ | 'xslt'
725
+
726
+ declare type RequestInfo = string | URL_2 | Request
727
+
728
+ declare interface RequestInit {
729
+ method?: string
730
+ keepalive?: boolean
731
+ headers?: HeadersInit
732
+ body?: BodyInit
733
+ redirect?: RequestRedirect
734
+ integrity?: string
735
+ signal?: AbortSignal
736
+ credentials?: RequestCredentials
737
+ mode?: RequestMode
738
+ referrer?: string
739
+ referrerPolicy?: ReferrerPolicy
740
+ window?: null
741
+ dispatcher?: Dispatcher
742
+ }
743
+
744
+ declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
745
+
746
+ declare type RequestRedirect = 'error' | 'follow' | 'manual'
747
+
748
+ declare class Response implements BodyMixin {
749
+ constructor (body?: BodyInit, init?: ResponseInit)
750
+
751
+ readonly headers: Headers
752
+ readonly ok: boolean
753
+ readonly status: number
754
+ readonly statusText: string
755
+ readonly type: ResponseType
756
+ readonly url: string
757
+ readonly redirected: boolean
758
+
759
+ readonly body: ReadableStream | null
760
+ readonly bodyUsed: boolean
761
+
762
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
763
+ readonly blob: () => Promise<Blob_2>
764
+ readonly formData: () => Promise<FormData>
765
+ readonly json: () => Promise<unknown>
766
+ readonly text: () => Promise<string>
767
+
768
+ readonly clone: () => Response
769
+
770
+ static error (): Response
771
+ static json(data: any, init?: ResponseInit): Response
772
+ static redirect (url: string | URL_2, status: ResponseRedirectStatus): Response
773
+ }
774
+
775
+ declare interface ResponseInit {
776
+ readonly status?: number
777
+ readonly statusText?: string
778
+ readonly headers?: HeadersInit
779
+ }
780
+
781
+ declare type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308
782
+
783
+ declare type ResponseType =
784
+ | 'basic'
785
+ | 'cors'
786
+ | 'default'
787
+ | 'error'
788
+ | 'opaque'
789
+ | 'opaqueredirect'
790
+
791
+ declare type Route = SimpleRoute | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
792
+
793
+ /**
794
+ * A bundling resolver rule, defining the modules type for paths that match the specified globs.
795
+ */
796
+ declare type Rule = {
797
+ type: ConfigModuleRuleType;
798
+ globs: string[];
799
+ fallthrough?: boolean;
800
+ };
801
+
802
+ declare type SimpleRoute = string;
803
+
804
+ declare interface SpecIterable<T> {
805
+ [Symbol.iterator](): SpecIterator<T>;
806
+ }
807
+
808
+ declare interface SpecIterableIterator<T> extends SpecIterator<T> {
809
+ [Symbol.iterator](): SpecIterableIterator<T>;
810
+ }
811
+
812
+ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
813
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
814
+ }
815
+
816
+ /**
817
+ * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
818
+ */
819
+ export declare function unstable_dev(script: string, options?: DevOptions, apiOptions?: DevApiOptions): Promise<UnstableDevWorker>;
820
+
821
+ export declare interface UnstableDevWorker {
822
+ port: number;
823
+ address: string;
824
+ stop: () => Promise<void>;
825
+ fetch: (input?: RequestInfo, init?: RequestInit) => Promise<Response>;
826
+ waitUntilExit: () => Promise<void>;
827
+ }
828
+
829
+ declare type ZoneIdRoute = {
830
+ pattern: string;
831
+ zone_id: string;
832
+ custom_domain?: boolean;
833
+ };
834
+
835
+ declare type ZoneNameRoute = {
836
+ pattern: string;
837
+ zone_name: string;
838
+ custom_domain?: boolean;
839
+ };
840
+
841
+ export { }