wrangler 0.0.0-e64812e → 0.0.0-e6c71262

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 (374) hide show
  1. package/README.md +24 -4
  2. package/bin/wrangler.js +170 -62
  3. package/kv-asset-handler.js +1 -0
  4. package/miniflare-dist/index.mjs +1637 -81
  5. package/package.json +198 -152
  6. package/src/__tests__/access.test.ts +25 -0
  7. package/src/__tests__/api-dev.test.ts +238 -0
  8. package/src/__tests__/api-devregistry.test.ts +121 -0
  9. package/src/__tests__/api.test.ts +102 -0
  10. package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
  11. package/src/__tests__/config-cache.test.ts +30 -24
  12. package/src/__tests__/configuration.test.ts +4660 -3363
  13. package/src/__tests__/constellation.test.ts +371 -0
  14. package/src/__tests__/d1/d1.test.ts +82 -0
  15. package/src/__tests__/d1/execute.test.ts +66 -0
  16. package/src/__tests__/d1/migrate.test.ts +257 -0
  17. package/src/__tests__/d1/splitter.test.ts +255 -0
  18. package/src/__tests__/delete.test.ts +272 -0
  19. package/src/__tests__/deployments.test.ts +369 -0
  20. package/src/__tests__/dev.test.tsx +1589 -952
  21. package/src/__tests__/generate.test.ts +254 -0
  22. package/src/__tests__/get-host-from-url.test.ts +16 -0
  23. package/src/__tests__/guess-worker-format.test.ts +103 -68
  24. package/src/__tests__/helpers/cmd-shim.d.ts +6 -6
  25. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  26. package/src/__tests__/helpers/mock-account-id.ts +24 -24
  27. package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
  28. package/src/__tests__/helpers/mock-bin.ts +20 -20
  29. package/src/__tests__/helpers/mock-console.ts +64 -39
  30. package/src/__tests__/helpers/mock-dialogs.ts +88 -79
  31. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  32. package/src/__tests__/helpers/mock-get-zone-from-host.ts +11 -0
  33. package/src/__tests__/helpers/mock-http-server.ts +30 -30
  34. package/src/__tests__/helpers/mock-istty.ts +65 -18
  35. package/src/__tests__/helpers/mock-known-routes.ts +12 -0
  36. package/src/__tests__/helpers/mock-kv.ts +41 -28
  37. package/src/__tests__/helpers/mock-oauth-flow.ts +241 -233
  38. package/src/__tests__/helpers/mock-process.ts +34 -0
  39. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  40. package/src/__tests__/helpers/mock-stdin.ts +82 -77
  41. package/src/__tests__/helpers/mock-web-socket.ts +21 -21
  42. package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
  43. package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
  44. package/src/__tests__/helpers/msw/handlers/deployments.ts +160 -0
  45. package/src/__tests__/helpers/msw/handlers/namespaces.ts +81 -0
  46. package/src/__tests__/helpers/msw/handlers/oauth.ts +31 -0
  47. package/src/__tests__/helpers/msw/handlers/r2.ts +60 -0
  48. package/src/__tests__/helpers/msw/handlers/script.ts +56 -0
  49. package/src/__tests__/helpers/msw/handlers/user.ts +52 -0
  50. package/src/__tests__/helpers/msw/handlers/zones.ts +20 -0
  51. package/src/__tests__/helpers/msw/index.ts +52 -0
  52. package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
  53. package/src/__tests__/helpers/run-in-tmp.ts +27 -28
  54. package/src/__tests__/helpers/run-wrangler.ts +8 -8
  55. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  56. package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
  57. package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +5 -0
  58. package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
  59. package/src/__tests__/helpers/worker-scripts/parent-worker.js +11 -0
  60. package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
  61. package/src/__tests__/helpers/write-worker-source.ts +16 -16
  62. package/src/__tests__/helpers/write-wrangler-toml.ts +9 -9
  63. package/src/__tests__/https-options.test.ts +142 -109
  64. package/src/__tests__/index.test.ts +262 -236
  65. package/src/__tests__/init.test.ts +3388 -1603
  66. package/src/__tests__/jest.setup.ts +152 -50
  67. package/src/__tests__/kv.test.ts +1789 -1471
  68. package/src/__tests__/logger.test.ts +167 -75
  69. package/src/__tests__/logout.test.ts +47 -0
  70. package/src/__tests__/metrics.test.ts +493 -0
  71. package/src/__tests__/middleware.scheduled.test.ts +145 -0
  72. package/src/__tests__/middleware.test.ts +816 -0
  73. package/src/__tests__/mtls-certificates.test.ts +589 -0
  74. package/src/__tests__/package-manager.test.ts +303 -303
  75. package/src/__tests__/pages/deployment-list.test.ts +80 -0
  76. package/src/__tests__/pages/functions-build.test.ts +528 -0
  77. package/src/__tests__/pages/pages.test.ts +81 -0
  78. package/src/__tests__/pages/project-create.test.ts +63 -0
  79. package/src/__tests__/pages/project-list.test.ts +110 -0
  80. package/src/__tests__/pages/project-upload.test.ts +500 -0
  81. package/src/__tests__/pages/publish.test.ts +2864 -0
  82. package/src/__tests__/pages-deployment-tail.test.ts +957 -0
  83. package/src/__tests__/parse.test.ts +358 -252
  84. package/src/__tests__/paths.test.ts +39 -0
  85. package/src/__tests__/publish.test.ts +8736 -5355
  86. package/src/__tests__/pubsub.test.ts +496 -0
  87. package/src/__tests__/queues.test.ts +532 -0
  88. package/src/__tests__/r2.test.ts +369 -228
  89. package/src/__tests__/route.test.ts +18 -18
  90. package/src/__tests__/secret.test.ts +681 -469
  91. package/src/__tests__/tail.test.ts +866 -567
  92. package/src/__tests__/test-old-node-version.js +31 -0
  93. package/src/__tests__/traverse-module-graph.test.ts +220 -0
  94. package/src/__tests__/tsconfig-sanity.ts +12 -0
  95. package/src/__tests__/tsconfig.json +8 -0
  96. package/src/__tests__/tsconfig.tsbuildinfo +1 -0
  97. package/src/__tests__/type-generation.test.ts +234 -0
  98. package/src/__tests__/unstableDev.test.ts +61 -0
  99. package/src/__tests__/user.test.ts +107 -120
  100. package/src/__tests__/utils-collectKeyValues.test.ts +47 -0
  101. package/src/__tests__/validate-dev-props.test.ts +56 -0
  102. package/src/__tests__/version.test.ts +35 -0
  103. package/src/__tests__/whoami.test.tsx +165 -98
  104. package/src/__tests__/worker-namespace.test.ts +340 -0
  105. package/src/abort.d.ts +1 -1
  106. package/src/api/dev.ts +321 -0
  107. package/src/api/index.ts +11 -0
  108. package/src/api/mtls-certificate.ts +148 -0
  109. package/src/api/pages/create-worker-bundle-contents.ts +79 -0
  110. package/src/api/pages/index.ts +5 -0
  111. package/src/api/pages/publish.tsx +371 -0
  112. package/src/bundle-reporter.ts +68 -0
  113. package/src/bundle.ts +890 -161
  114. package/src/cfetch/index.ts +120 -83
  115. package/src/cfetch/internal.ts +215 -97
  116. package/src/cli.ts +23 -8
  117. package/src/config/config.ts +244 -196
  118. package/src/config/diagnostics.ts +61 -61
  119. package/src/config/environment.ts +587 -357
  120. package/src/config/index.ts +395 -196
  121. package/src/config/validation-helpers.ts +379 -357
  122. package/src/config/validation.ts +2285 -1367
  123. package/src/config-cache.ts +81 -41
  124. package/src/constellation/createProject.tsx +51 -0
  125. package/src/constellation/deleteProject.ts +51 -0
  126. package/src/constellation/deleteProjectModel.ts +76 -0
  127. package/src/constellation/index.ts +75 -0
  128. package/src/constellation/listCatalog.tsx +35 -0
  129. package/src/constellation/listModel.tsx +49 -0
  130. package/src/constellation/listProject.tsx +28 -0
  131. package/src/constellation/listRuntime.tsx +28 -0
  132. package/src/constellation/options.ts +17 -0
  133. package/src/constellation/types.ts +17 -0
  134. package/src/constellation/uploadModel.tsx +84 -0
  135. package/src/constellation/utils.ts +90 -0
  136. package/src/create-worker-preview.ts +250 -142
  137. package/src/create-worker-upload-form.ts +364 -238
  138. package/src/d1/backups.tsx +219 -0
  139. package/src/d1/constants.ts +5 -0
  140. package/src/d1/create.tsx +102 -0
  141. package/src/d1/delete.ts +53 -0
  142. package/src/d1/execute.tsx +371 -0
  143. package/src/d1/formatTimeAgo.ts +14 -0
  144. package/src/d1/index.ts +100 -0
  145. package/src/d1/list.tsx +62 -0
  146. package/src/d1/migrations/apply.tsx +235 -0
  147. package/src/d1/migrations/create.tsx +79 -0
  148. package/src/d1/migrations/helpers.ts +171 -0
  149. package/src/d1/migrations/index.ts +3 -0
  150. package/src/d1/migrations/list.tsx +95 -0
  151. package/src/d1/migrations/options.ts +23 -0
  152. package/src/d1/options.ts +22 -0
  153. package/src/d1/splitter.ts +161 -0
  154. package/src/d1/types.ts +32 -0
  155. package/src/d1/utils.ts +49 -0
  156. package/src/delete.ts +100 -0
  157. package/src/deployments.ts +368 -0
  158. package/src/deprecated/index.ts +144 -0
  159. package/src/dev/dev-vars.ts +20 -17
  160. package/src/dev/dev.tsx +538 -352
  161. package/src/dev/get-local-persistence-path.ts +31 -0
  162. package/src/dev/local.tsx +932 -298
  163. package/src/dev/remote.tsx +623 -215
  164. package/src/dev/start-server.ts +545 -0
  165. package/src/dev/use-esbuild.ts +194 -97
  166. package/src/dev/validate-dev-props.ts +40 -0
  167. package/src/dev-registry.ts +213 -0
  168. package/src/dev.tsx +937 -0
  169. package/src/dialogs.ts +136 -0
  170. package/src/dispatch-namespace.ts +211 -0
  171. package/src/docs/helpers.ts +50 -0
  172. package/src/docs/index.ts +54 -0
  173. package/src/durable.ts +87 -87
  174. package/src/entry.ts +253 -231
  175. package/src/environment-variables/factory.ts +89 -0
  176. package/src/environment-variables/misc-variables.ts +30 -0
  177. package/src/errors.ts +6 -6
  178. package/src/generate/index.ts +304 -0
  179. package/src/git-client.ts +135 -0
  180. package/src/global-wrangler-config-path.ts +26 -0
  181. package/src/https-options.ts +84 -80
  182. package/src/index.ts +769 -0
  183. package/src/init.ts +1123 -0
  184. package/src/inspect.ts +816 -595
  185. package/src/intl-polyfill.d.ts +123 -123
  186. package/src/is-ci.ts +14 -0
  187. package/src/is-interactive.ts +16 -0
  188. package/src/jest.d.ts +4 -0
  189. package/src/kv/helpers.ts +433 -0
  190. package/src/kv/index.ts +594 -0
  191. package/src/logger.ts +100 -43
  192. package/src/metrics/index.ts +5 -0
  193. package/src/metrics/metrics-config.ts +239 -0
  194. package/src/metrics/metrics-dispatcher.ts +96 -0
  195. package/src/metrics/metrics-usage-headers.ts +24 -0
  196. package/src/metrics/send-event.ts +99 -0
  197. package/src/miniflare-cli/assets.ts +251 -0
  198. package/src/miniflare-cli/index.ts +202 -33
  199. package/src/miniflare-cli/request-context.ts +18 -18
  200. package/src/miniflare-cli/tsconfig.json +9 -0
  201. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
  202. package/src/miniflare-cli/types.ts +11 -0
  203. package/src/module-collection.ts +290 -215
  204. package/src/mtls-certificate/cli.ts +155 -0
  205. package/src/open-in-browser.ts +4 -6
  206. package/src/package-manager.ts +173 -128
  207. package/src/pages/build.ts +423 -0
  208. package/src/pages/buildFunctions.ts +140 -0
  209. package/src/pages/constants.ts +18 -0
  210. package/src/pages/deployment-tails.ts +281 -0
  211. package/src/pages/deployments.tsx +84 -0
  212. package/src/pages/dev.ts +734 -0
  213. package/src/pages/errors.ts +67 -0
  214. package/src/pages/functions/buildPlugin.ts +114 -0
  215. package/src/pages/functions/buildWorker.ts +350 -0
  216. package/{pages → src/pages}/functions/filepath-routing.test.ts +113 -113
  217. package/src/pages/functions/filepath-routing.ts +189 -0
  218. package/src/pages/functions/identifiers.ts +78 -0
  219. package/src/pages/functions/routes-consolidation.test.ts +250 -0
  220. package/src/pages/functions/routes-consolidation.ts +73 -0
  221. package/src/pages/functions/routes-transformation.test.ts +282 -0
  222. package/src/pages/functions/routes-transformation.ts +115 -0
  223. package/src/pages/functions/routes-validation.test.ts +403 -0
  224. package/src/pages/functions/routes-validation.ts +202 -0
  225. package/src/pages/functions/routes.ts +151 -0
  226. package/src/pages/functions/tsconfig.json +8 -0
  227. package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
  228. package/src/pages/functions.ts +86 -0
  229. package/src/pages/hash.ts +13 -0
  230. package/src/pages/index.ts +102 -0
  231. package/src/pages/projects.tsx +159 -0
  232. package/src/pages/prompt-select-project.tsx +31 -0
  233. package/src/pages/publish.tsx +267 -0
  234. package/src/pages/types.ts +46 -0
  235. package/src/pages/upload.tsx +469 -0
  236. package/src/pages/utils.ts +23 -0
  237. package/src/parse.ts +232 -126
  238. package/src/paths.ts +53 -8
  239. package/src/proxy.ts +623 -394
  240. package/src/publish/index.ts +274 -0
  241. package/src/publish/publish.ts +1067 -0
  242. package/src/pubsub/index.ts +286 -0
  243. package/src/pubsub/pubsub-commands.ts +623 -0
  244. package/src/queues/cli/commands/consumer/add.ts +71 -0
  245. package/src/queues/cli/commands/consumer/index.ts +19 -0
  246. package/src/queues/cli/commands/consumer/remove.ts +31 -0
  247. package/src/queues/cli/commands/create.ts +25 -0
  248. package/src/queues/cli/commands/delete.ts +26 -0
  249. package/src/queues/cli/commands/index.ts +35 -0
  250. package/src/queues/cli/commands/list.ts +25 -0
  251. package/src/queues/client.ts +136 -0
  252. package/src/queues/utils.ts +18 -0
  253. package/src/r2/constants.ts +4 -0
  254. package/src/r2/helpers.ts +132 -0
  255. package/src/r2/index.ts +289 -0
  256. package/src/routes.ts +140 -0
  257. package/src/secret/index.ts +379 -0
  258. package/src/selfsigned.d.ts +23 -23
  259. package/src/sites.ts +484 -0
  260. package/src/tail/createTail.ts +415 -0
  261. package/src/tail/filters.ts +109 -111
  262. package/src/tail/index.ts +208 -296
  263. package/src/tail/printing.ts +116 -51
  264. package/src/traverse-module-graph.ts +54 -0
  265. package/src/tsconfig-sanity.ts +16 -0
  266. package/src/type-generation.ts +187 -0
  267. package/src/update-check.ts +11 -11
  268. package/src/user/access.ts +68 -0
  269. package/src/user/auth-variables.ts +113 -0
  270. package/src/user/choose-account.tsx +39 -0
  271. package/src/user/generate-auth-url.ts +33 -0
  272. package/src/user/generate-random-state.ts +16 -0
  273. package/src/user/index.ts +2 -0
  274. package/src/user/user.ts +1234 -0
  275. package/src/utils/collectKeyValues.ts +14 -0
  276. package/src/utils/render.ts +93 -0
  277. package/src/whoami.ts +135 -0
  278. package/src/worker.ts +220 -106
  279. package/src/yargs-types.ts +37 -0
  280. package/src/zones.ts +191 -0
  281. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  282. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  283. package/templates/__tests__/tsconfig.json +8 -0
  284. package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
  285. package/templates/checked-fetch.js +23 -0
  286. package/templates/d1-beta-facade.js +244 -0
  287. package/templates/facade.d.ts +14 -0
  288. package/templates/first-party-worker-module-facade.ts +19 -0
  289. package/templates/format-dev-errors.ts +34 -0
  290. package/templates/gitignore +1 -0
  291. package/templates/init-tests/test-jest-new-worker.js +23 -0
  292. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  293. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  294. package/templates/middleware/common.ts +62 -0
  295. package/templates/middleware/loader-modules.ts +84 -0
  296. package/templates/middleware/loader-sw.ts +233 -0
  297. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  298. package/templates/middleware/middleware-pretty-error.ts +40 -0
  299. package/templates/middleware/middleware-scheduled.ts +15 -0
  300. package/templates/new-worker-scheduled.js +3 -3
  301. package/templates/new-worker-scheduled.ts +15 -15
  302. package/templates/new-worker.js +3 -3
  303. package/templates/new-worker.ts +18 -15
  304. package/templates/no-op-worker.js +10 -0
  305. package/templates/pages-dev-pipeline.ts +31 -0
  306. package/templates/pages-dev-util.ts +55 -0
  307. package/templates/pages-shim.ts +12 -0
  308. package/templates/pages-template-plugin.ts +180 -0
  309. package/templates/pages-template-worker.ts +189 -0
  310. package/templates/serve-static-assets.ts +66 -0
  311. package/templates/service-bindings-module-facade.js +55 -0
  312. package/templates/service-bindings-sw-facade.js +42 -0
  313. package/templates/tsconfig-sanity.ts +11 -0
  314. package/templates/tsconfig.init.json +105 -0
  315. package/templates/tsconfig.json +6 -103
  316. package/templates/tsconfig.tsbuildinfo +1 -0
  317. package/wrangler-dist/cli.d.ts +1673 -0
  318. package/wrangler-dist/cli.js +119141 -91468
  319. package/wrangler-dist/wasm-sync.wasm +0 -0
  320. package/pages/functions/buildPlugin.ts +0 -105
  321. package/pages/functions/buildWorker.ts +0 -151
  322. package/pages/functions/filepath-routing.ts +0 -189
  323. package/pages/functions/identifiers.ts +0 -78
  324. package/pages/functions/routes.ts +0 -156
  325. package/pages/functions/template-plugin.ts +0 -147
  326. package/pages/functions/template-worker.ts +0 -143
  327. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  328. package/src/__tests__/helpers/mock-cfetch.ts +0 -211
  329. package/src/__tests__/pages.test.ts +0 -754
  330. package/src/dialogs.tsx +0 -135
  331. package/src/environment-variables.ts +0 -35
  332. package/src/index.tsx +0 -2864
  333. package/src/kv.ts +0 -408
  334. package/src/miniflare-cli/enum-keys.ts +0 -17
  335. package/src/pages.tsx +0 -2038
  336. package/src/publish.ts +0 -583
  337. package/src/r2.ts +0 -50
  338. package/src/sites.tsx +0 -295
  339. package/src/user.tsx +0 -1203
  340. package/src/whoami.tsx +0 -70
  341. package/templates/static-asset-facade.js +0 -47
  342. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  343. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  344. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  345. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  346. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  347. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  348. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  349. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  350. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  351. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  352. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  353. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  354. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  355. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  356. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  357. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  358. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  359. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  360. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  361. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  362. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  363. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  364. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  365. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  366. package/vendor/wrangler-mime/LICENSE +0 -21
  367. package/vendor/wrangler-mime/Mime.js +0 -97
  368. package/vendor/wrangler-mime/README.md +0 -187
  369. package/vendor/wrangler-mime/cli.js +0 -46
  370. package/vendor/wrangler-mime/index.js +0 -4
  371. package/vendor/wrangler-mime/lite.js +0 -4
  372. package/vendor/wrangler-mime/package.json +0 -52
  373. package/vendor/wrangler-mime/types/other.js +0 -1
  374. package/vendor/wrangler-mime/types/standard.js +0 -1
@@ -0,0 +1,1673 @@
1
+ /// <reference types="node" />
2
+
3
+ import { Blob as Blob_2 } from 'buffer';
4
+ import { ConnectionOptions } from 'tls';
5
+ import { Duplex } from 'stream';
6
+ import { EventEmitter } from 'events';
7
+ import { IpcNetConnectOpts } from 'net';
8
+ import { Readable } from 'stream';
9
+ import { ReadableStream } from 'stream/web';
10
+ import { Socket } from 'net';
11
+ import { TcpNetConnectOpts } from 'net';
12
+ import { TlsOptions } from 'tls';
13
+ import { TLSSocket } from 'tls';
14
+ import { URL as URL_2 } from 'url';
15
+ import { URLSearchParams as URLSearchParams_2 } from 'url';
16
+ import { Writable } from 'stream';
17
+
18
+ declare type AbortSignal_2 = unknown;
19
+
20
+ declare interface BlobPropertyBag {
21
+ type?: string
22
+ endings?: 'native' | 'transparent'
23
+ }
24
+
25
+ declare type BodyInit =
26
+ | ArrayBuffer
27
+ | AsyncIterable<Uint8Array>
28
+ | Blob_2
29
+ | FormData
30
+ | Iterable<Uint8Array>
31
+ | NodeJS.ArrayBufferView
32
+ | URLSearchParams_2
33
+ | null
34
+ | string
35
+
36
+ declare interface BodyMixin {
37
+ readonly body: ReadableStream | null
38
+ readonly bodyUsed: boolean
39
+
40
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
41
+ readonly blob: () => Promise<Blob_2>
42
+ readonly formData: () => Promise<FormData>
43
+ readonly json: () => Promise<unknown>
44
+ readonly text: () => Promise<string>
45
+ }
46
+
47
+ declare class BodyReadable extends Readable {
48
+ constructor(
49
+ resume?: (this: Readable, size: number) => void | null,
50
+ abort?: () => void | null,
51
+ contentType?: string
52
+ )
53
+
54
+ /** Consumes and returns the body as a string
55
+ * https://fetch.spec.whatwg.org/#dom-body-text
56
+ */
57
+ text(): Promise<string>
58
+
59
+ /** Consumes and returns the body as a JavaScript Object
60
+ * https://fetch.spec.whatwg.org/#dom-body-json
61
+ */
62
+ json(): Promise<any>
63
+
64
+ /** Consumes and returns the body as a Blob
65
+ * https://fetch.spec.whatwg.org/#dom-body-blob
66
+ */
67
+ blob(): Promise<Blob_2>
68
+
69
+ /** Consumes and returns the body as an ArrayBuffer
70
+ * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
71
+ */
72
+ arrayBuffer(): Promise<ArrayBuffer>
73
+
74
+ /** Not implemented
75
+ *
76
+ * https://fetch.spec.whatwg.org/#dom-body-formdata
77
+ */
78
+ formData(): Promise<never>
79
+
80
+ /** Returns true if the body is not null and the body has been consumed
81
+ *
82
+ * Otherwise, returns false
83
+ *
84
+ * https://fetch.spec.whatwg.org/#dom-body-bodyused
85
+ */
86
+ readonly bodyUsed: boolean
87
+
88
+ /** Throws on node 16.6.0
89
+ *
90
+ * If body is null, it should return null as the body
91
+ *
92
+ * If body is not null, should return the body as a ReadableStream
93
+ *
94
+ * https://fetch.spec.whatwg.org/#dom-body-body
95
+ */
96
+ readonly body: never | undefined
97
+
98
+ /** Dumps the response body by reading `limit` number of bytes.
99
+ * @param opts.limit Number of bytes to read (optional) - Default: 262144
100
+ */
101
+ dump(opts?: { limit: number }): Promise<void>
102
+ }
103
+
104
+ declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
105
+
106
+ declare namespace buildConnector {
107
+ type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
108
+ maxCachedSessions?: number | null;
109
+ socketPath?: string | null;
110
+ timeout?: number | null;
111
+ port?: number;
112
+ keepAlive?: boolean | null;
113
+ keepAliveInitialDelay?: number | null;
114
+ }
115
+
116
+ interface Options {
117
+ hostname: string
118
+ host?: string
119
+ protocol: string
120
+ port: string
121
+ servername?: string
122
+ localAddress?: string | null
123
+ httpSocket?: Socket
124
+ }
125
+
126
+ type Callback = (...args: CallbackArgs) => void
127
+ type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
128
+
129
+ type connector = connectorAsync | connectorSync
130
+
131
+ interface connectorSync {
132
+ (options: buildConnector.Options): Socket | TLSSocket
133
+ }
134
+
135
+ interface connectorAsync {
136
+ (options: buildConnector.Options, callback: buildConnector.Callback): void
137
+ }
138
+ }
139
+
140
+ /** A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default. */
141
+ declare class Client extends Dispatcher {
142
+ constructor(url: string | URL_2, options?: Client.Options);
143
+ /** Property to get and set the pipelining factor. */
144
+ pipelining: number;
145
+ /** `true` after `client.close()` has been called. */
146
+ closed: boolean;
147
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
148
+ destroyed: boolean;
149
+ }
150
+
151
+ declare namespace Client {
152
+ interface Options {
153
+ /** the timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
154
+ keepAliveTimeout?: number | null;
155
+ /** the maximum allowed `idleTimeout` when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
156
+ keepAliveMaxTimeout?: number | null;
157
+ /** A number subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
158
+ keepAliveTimeoutThreshold?: number | null;
159
+ /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
160
+ pipelining?: number | null;
161
+ /** **/
162
+ connect?: buildConnector.BuildOptions | buildConnector.connector | null;
163
+ /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
164
+ maxHeaderSize?: number | null;
165
+ /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
166
+ bodyTimeout?: number | null;
167
+ /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
168
+ headersTimeout?: number | null;
169
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
170
+ strictContentLength?: boolean;
171
+ /** @deprecated use the connect option instead */
172
+ tls?: TlsOptions | null;
173
+ /** */
174
+ maxRequestsPerClient?: number;
175
+ /** Max response body size in bytes, -1 is disabled */
176
+ maxResponseSize?: number | null;
177
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
178
+ autoSelectFamily?: boolean;
179
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
180
+ autoSelectFamilyAttemptTimeout?: number;
181
+
182
+ interceptors?: {Client: readonly Dispatcher[] | undefined}
183
+ }
184
+
185
+ interface SocketInfo {
186
+ localAddress?: string
187
+ localPort?: number
188
+ remoteAddress?: string
189
+ remotePort?: number
190
+ remoteFamily?: string
191
+ timeout?: number
192
+ bytesWritten?: number
193
+ bytesRead?: number
194
+ }
195
+
196
+
197
+ }
198
+
199
+ /**
200
+ * The possible types for a `Rule`.
201
+ */
202
+ declare type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data";
203
+
204
+ declare type CustomDomainRoute = {
205
+ pattern: string;
206
+ custom_domain: boolean;
207
+ };
208
+
209
+ export declare function deleteMTlsCertificate(accountId: string, certificateId: string): Promise<unknown>;
210
+
211
+ /**
212
+ * Deprecated upload configuration.
213
+ */
214
+ declare interface DeprecatedUpload {
215
+ /**
216
+ * The format of the Worker script.
217
+ *
218
+ * @deprecated We infer the format automatically now.
219
+ */
220
+ format?: "modules" | "service-worker";
221
+ /**
222
+ * The directory you wish to upload your worker from,
223
+ * relative to the wrangler.toml file.
224
+ *
225
+ * Defaults to the directory containing the wrangler.toml file.
226
+ *
227
+ * @deprecated
228
+ */
229
+ dir?: string;
230
+ /**
231
+ * The path to the Worker script, relative to `upload.dir`.
232
+ *
233
+ * @deprecated This will be replaced by a command line argument.
234
+ */
235
+ main?: string;
236
+ /**
237
+ * @deprecated This is now defined at the top level `rules` field.
238
+ */
239
+ rules?: Environment["rules"];
240
+ }
241
+
242
+ /** Dispatcher is the core API used to dispatch requests. */
243
+ declare class Dispatcher extends EventEmitter {
244
+ /** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
245
+ dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
246
+ /** Starts two-way communications with the requested resource. */
247
+ connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
248
+ connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
249
+ /** Performs an HTTP request. */
250
+ request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
251
+ request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
252
+ /** For easy use with `stream.pipeline`. */
253
+ pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
254
+ /** A faster version of `Dispatcher.request`. */
255
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
256
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
257
+ /** Upgrade to a different protocol. */
258
+ upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
259
+ upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
260
+ /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
261
+ close(): Promise<void>;
262
+ close(callback: () => void): void;
263
+ /** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
264
+ destroy(): Promise<void>;
265
+ destroy(err: Error | null): Promise<void>;
266
+ destroy(callback: () => void): void;
267
+ destroy(err: Error | null, callback: () => void): void;
268
+
269
+ on(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
270
+ on(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
271
+ on(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
272
+ on(eventName: 'drain', callback: (origin: URL_2) => void): this;
273
+
274
+
275
+ once(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
276
+ once(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
277
+ once(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
278
+ once(eventName: 'drain', callback: (origin: URL_2) => void): this;
279
+
280
+
281
+ off(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
282
+ off(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
283
+ off(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
284
+ off(eventName: 'drain', callback: (origin: URL_2) => void): this;
285
+
286
+
287
+ addListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
288
+ addListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
289
+ addListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
290
+ addListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
291
+
292
+ removeListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
293
+ removeListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
294
+ removeListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
295
+ removeListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
296
+
297
+ prependListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
298
+ prependListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
299
+ prependListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
300
+ prependListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
301
+
302
+ prependOnceListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
303
+ prependOnceListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
304
+ prependOnceListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
305
+ prependOnceListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
306
+
307
+ listeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
308
+ listeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
309
+ listeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
310
+ listeners(eventName: 'drain'): ((origin: URL_2) => void)[];
311
+
312
+ rawListeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
313
+ rawListeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
314
+ rawListeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
315
+ rawListeners(eventName: 'drain'): ((origin: URL_2) => void)[];
316
+
317
+ emit(eventName: 'connect', origin: URL_2, targets: readonly Dispatcher[]): boolean;
318
+ emit(eventName: 'disconnect', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
319
+ emit(eventName: 'connectionError', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
320
+ emit(eventName: 'drain', origin: URL_2): boolean;
321
+ }
322
+
323
+ declare namespace Dispatcher {
324
+ interface DispatchOptions {
325
+ origin?: string | URL_2;
326
+ path: string;
327
+ method: HttpMethod;
328
+ /** Default: `null` */
329
+ body?: string | Buffer | Uint8Array | Readable | null | FormData;
330
+ /** Default: `null` */
331
+ headers?: IncomingHttpHeaders | string[] | null;
332
+ /** Query string params to be embedded in the request URL. Default: `null` */
333
+ query?: Record<string, any>;
334
+ /** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
335
+ idempotent?: boolean;
336
+ /** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. */
337
+ blocking?: boolean;
338
+ /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
339
+ upgrade?: boolean | string | null;
340
+ /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
341
+ headersTimeout?: number | null;
342
+ /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
343
+ bodyTimeout?: number | null;
344
+ /** Whether the request should stablish a keep-alive or not. Default `false` */
345
+ reset?: boolean;
346
+ /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
347
+ throwOnError?: boolean;
348
+ }
349
+ interface ConnectOptions {
350
+ path: string;
351
+ /** Default: `null` */
352
+ headers?: IncomingHttpHeaders | string[] | null;
353
+ /** Default: `null` */
354
+ signal?: AbortSignal_2 | EventEmitter | null;
355
+ /** This argument parameter is passed through to `ConnectData` */
356
+ opaque?: unknown;
357
+ /** Default: 0 */
358
+ maxRedirections?: number;
359
+ /** Default: `null` */
360
+ responseHeader?: 'raw' | null;
361
+ }
362
+ interface RequestOptions extends DispatchOptions {
363
+ /** Default: `null` */
364
+ opaque?: unknown;
365
+ /** Default: `null` */
366
+ signal?: AbortSignal_2 | EventEmitter | null;
367
+ /** Default: 0 */
368
+ maxRedirections?: number;
369
+ /** Default: `null` */
370
+ onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
371
+ /** Default: `null` */
372
+ responseHeader?: 'raw' | null;
373
+ }
374
+ interface PipelineOptions extends RequestOptions {
375
+ /** `true` if the `handler` will return an object stream. Default: `false` */
376
+ objectMode?: boolean;
377
+ }
378
+ interface UpgradeOptions {
379
+ path: string;
380
+ /** Default: `'GET'` */
381
+ method?: string;
382
+ /** Default: `null` */
383
+ headers?: IncomingHttpHeaders | string[] | null;
384
+ /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
385
+ protocol?: string;
386
+ /** Default: `null` */
387
+ signal?: AbortSignal_2 | EventEmitter | null;
388
+ /** Default: 0 */
389
+ maxRedirections?: number;
390
+ /** Default: `null` */
391
+ responseHeader?: 'raw' | null;
392
+ }
393
+ interface ConnectData {
394
+ statusCode: number;
395
+ headers: IncomingHttpHeaders;
396
+ socket: Duplex;
397
+ opaque: unknown;
398
+ }
399
+ interface ResponseData {
400
+ statusCode: number;
401
+ headers: IncomingHttpHeaders;
402
+ body: BodyReadable & BodyMixin;
403
+ trailers: Record<string, string>;
404
+ opaque: unknown;
405
+ context: object;
406
+ }
407
+ interface PipelineHandlerData {
408
+ statusCode: number;
409
+ headers: IncomingHttpHeaders;
410
+ opaque: unknown;
411
+ body: BodyReadable;
412
+ context: object;
413
+ }
414
+ interface StreamData {
415
+ opaque: unknown;
416
+ trailers: Record<string, string>;
417
+ }
418
+ interface UpgradeData {
419
+ headers: IncomingHttpHeaders;
420
+ socket: Duplex;
421
+ opaque: unknown;
422
+ }
423
+ interface StreamFactoryData {
424
+ statusCode: number;
425
+ headers: IncomingHttpHeaders;
426
+ opaque: unknown;
427
+ context: object;
428
+ }
429
+ type StreamFactory = (data: StreamFactoryData) => Writable;
430
+ interface DispatchHandlers {
431
+ /** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
432
+ onConnect?(abort: () => void): void;
433
+ /** Invoked when an error has occurred. */
434
+ onError?(err: Error): void;
435
+ /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
436
+ onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
437
+ /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
438
+ onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void): boolean;
439
+ /** Invoked when response payload data is received. */
440
+ onData?(chunk: Buffer): boolean;
441
+ /** Invoked when response payload and trailers have been received and the request has completed. */
442
+ onComplete?(trailers: string[] | null): void;
443
+ /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
444
+ onBodySent?(chunkSize: number, totalBytesSent: number): void;
445
+ }
446
+ type PipelineHandler = (data: PipelineHandlerData) => Readable;
447
+ type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
448
+
449
+ /**
450
+ * @link https://fetch.spec.whatwg.org/#body-mixin
451
+ */
452
+ interface BodyMixin {
453
+ readonly body?: never; // throws on node v16.6.0
454
+ readonly bodyUsed: boolean;
455
+ arrayBuffer(): Promise<ArrayBuffer>;
456
+ blob(): Promise<Blob_2>;
457
+ formData(): Promise<never>;
458
+ json(): Promise<any>;
459
+ text(): Promise<string>;
460
+ }
461
+
462
+ interface DispatchInterceptor {
463
+ (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
464
+ }
465
+ }
466
+
467
+ declare type DurableObjectBindings = {
468
+ /** The name of the binding used to refer to the Durable Object */
469
+ name: string;
470
+ /** The exported class name of the Durable Object */
471
+ class_name: string;
472
+ /** The script where the Durable Object is defined (if it's external to this worker) */
473
+ script_name?: string;
474
+ /** The service environment of the script_name to bind to */
475
+ environment?: string;
476
+ }[];
477
+
478
+ declare interface EnablePagesAssetsServiceBindingOptions {
479
+ proxyPort?: number;
480
+ directory?: string;
481
+ }
482
+
483
+ /**
484
+ * The `Environment` interface declares all the configuration fields that
485
+ * can be specified for an environment.
486
+ *
487
+ * This could be the top-level default environment, or a specific named environment.
488
+ */
489
+ declare interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
490
+ }
491
+
492
+ /**
493
+ * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
494
+ * that can be inherited (and overridden) from the top-level environment.
495
+ */
496
+ declare interface EnvironmentInheritable {
497
+ /**
498
+ * The name of your worker. Alphanumeric + dashes only.
499
+ *
500
+ * @inheritable
501
+ */
502
+ name: string | undefined;
503
+ /**
504
+ * This is the ID of the account associated with your zone.
505
+ * You might have more than one account, so make sure to use
506
+ * the ID of the account associated with the zone/route you
507
+ * provide, if you provide one. It can also be specified through
508
+ * the CLOUDFLARE_ACCOUNT_ID environment variable.
509
+ *
510
+ * @inheritable
511
+ */
512
+ account_id: string | undefined;
513
+ /**
514
+ * A date in the form yyyy-mm-dd, which will be used to determine
515
+ * which version of the Workers runtime is used.
516
+ *
517
+ * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
518
+ *
519
+ * @inheritable
520
+ */
521
+ compatibility_date: string | undefined;
522
+ /**
523
+ * A list of flags that enable features from upcoming features of
524
+ * the Workers runtime, usually used together with compatibility_flags.
525
+ *
526
+ * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
527
+ *
528
+ * @inheritable
529
+ */
530
+ compatibility_flags: string[];
531
+ /**
532
+ * The entrypoint/path to the JavaScript file that will be executed.
533
+ */
534
+ main: string | undefined;
535
+ /**
536
+ * The directory in which module rules should be evaluated in a `--no-bundle` worker
537
+ * This defaults to dirname(main) when left undefined
538
+ */
539
+ base_dir: string | undefined;
540
+ /**
541
+ * Whether we use <name>.<subdomain>.workers.dev to
542
+ * test and deploy your worker.
543
+ *
544
+ * @default `true` (This is a breaking change from Wrangler v1)
545
+ * @breaking
546
+ * @inheritable
547
+ */
548
+ workers_dev: boolean | undefined;
549
+ /**
550
+ * A list of routes that your worker should be published to.
551
+ * Only one of `routes` or `route` is required.
552
+ *
553
+ * Only required when workers_dev is false, and there's no scheduled worker (see `triggers`)
554
+ *
555
+ * @inheritable
556
+ */
557
+ routes: Route[] | undefined;
558
+ /**
559
+ * A route that your worker should be published to. Literally
560
+ * the same as routes, but only one.
561
+ * Only one of `routes` or `route` is required.
562
+ *
563
+ * Only required when workers_dev is false, and there's no scheduled worker
564
+ *
565
+ * @inheritable
566
+ */
567
+ route: Route | undefined;
568
+ /**
569
+ * Path to a custom tsconfig
570
+ */
571
+ tsconfig: string | undefined;
572
+ /**
573
+ * The function to use to replace jsx syntax.
574
+ *
575
+ * @default `"React.createElement"`
576
+ * @inheritable
577
+ */
578
+ jsx_factory: string;
579
+ /**
580
+ * The function to use to replace jsx fragment syntax.
581
+ *
582
+ * @default `"React.Fragment"`
583
+ * @inheritable
584
+ */
585
+ jsx_fragment: string;
586
+ /**
587
+ * "Cron" definitions to trigger a worker's "scheduled" function.
588
+ *
589
+ * Lets you call workers periodically, much like a cron job.
590
+ *
591
+ * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
592
+ *
593
+ * @default `{crons:[]}`
594
+ * @inheritable
595
+ */
596
+ triggers: {
597
+ crons: string[];
598
+ };
599
+ /**
600
+ * Specifies the Usage Model for your Worker. There are two options -
601
+ * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
602
+ * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
603
+ * For newly created Workers, if the Usage Model is omitted
604
+ * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
605
+ * For existing Workers, if the Usage Model is omitted, it will be
606
+ * set to the Usage Model configured in the dashboard for that Worker.
607
+ *
608
+ * @inheritable
609
+ */
610
+ usage_model: "bundled" | "unbound" | undefined;
611
+ /**
612
+ * An ordered list of rules that define which modules to import,
613
+ * and what type to import them as. You will need to specify rules
614
+ * to use Text, Data, and CompiledWasm modules, or when you wish to
615
+ * have a .js file be treated as an ESModule instead of CommonJS.
616
+ *
617
+ * @inheritable
618
+ */
619
+ rules: Rule[];
620
+ /**
621
+ * Configures a custom build step to be run by Wrangler when building your Worker.
622
+ *
623
+ * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
624
+ * for more details.
625
+ *
626
+ * @default {}
627
+ */
628
+ build: {
629
+ /** 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. */
630
+ command?: string;
631
+ /** The directory in which the command is executed. */
632
+ cwd?: string;
633
+ /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
634
+ watch_dir?: string | string[];
635
+ /**
636
+ * Deprecated field previously used to configure the build and upload of the script.
637
+ * @deprecated
638
+ */
639
+ upload?: DeprecatedUpload;
640
+ };
641
+ /**
642
+ * Skip internal build steps and directly publish script
643
+ * @inheritable
644
+ */
645
+ no_bundle: boolean | undefined;
646
+ /**
647
+ * Minify the script before uploading.
648
+ * @inheritable
649
+ */
650
+ minify: boolean | undefined;
651
+ /**
652
+ * Add polyfills for node builtin modules and globals
653
+ * @inheritable
654
+ */
655
+ node_compat: boolean | undefined;
656
+ /**
657
+ * Specifies namespace bindings that are bound to this Worker environment.
658
+ *
659
+ * NOTE: This field is not automatically inherited from the top level environment,
660
+ * and so must be specified in every named environment.
661
+ *
662
+ * @default `[]`
663
+ * @nonInheritable
664
+ */
665
+ dispatch_namespaces: {
666
+ /** The binding name used to refer to the bound service. */
667
+ binding: string;
668
+ /** The namespace to bind to. */
669
+ namespace: string;
670
+ }[];
671
+ /**
672
+ * Designates this worker as an internal-only "first-party" worker.
673
+ */
674
+ first_party_worker: boolean | undefined;
675
+ /**
676
+ * TODO: remove this as it has been deprecated.
677
+ *
678
+ * This is just here for now because the `route` commands use it.
679
+ * So we need to include it in this type so it is available.
680
+ */
681
+ zone_id?: string;
682
+ /**
683
+ * Specify a compiled capnp schema to use
684
+ * Then add a binding per field in the top level message that you will send to logfwdr
685
+ *
686
+ * @default `{schema:undefined,bindings:[]}`
687
+ * @inheritable
688
+ */
689
+ logfwdr: {
690
+ /** capnp schema filename */
691
+ schema: string | undefined;
692
+ bindings: {
693
+ /** The binding name used to refer to logfwdr */
694
+ name: string;
695
+ /** The destination for this logged message */
696
+ destination: string;
697
+ }[];
698
+ };
699
+ /**
700
+ * Send Trace Events from this worker to Workers Logpush.
701
+ *
702
+ * This will not configure a corresponding Logpush job automatically.
703
+ *
704
+ * For more information about Workers Logpush, see:
705
+ * https://blog.cloudflare.com/logpush-for-workers/
706
+ *
707
+ * @inheritable
708
+ */
709
+ logpush: boolean | undefined;
710
+ /**
711
+ * Specify how the worker should be located to minimize round-trip time.
712
+ *
713
+ * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
714
+ */
715
+ placement: {
716
+ mode: "off" | "smart";
717
+ } | undefined;
718
+ }
719
+
720
+ /**
721
+ * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
722
+ * that cannot be inherited from the top-level environment, and must be defined specifically.
723
+ *
724
+ * If any of these fields are defined at the top-level then they should also be specifically defined
725
+ * for each named environment.
726
+ */
727
+ declare interface EnvironmentNonInheritable {
728
+ /**
729
+ * A map of values to substitute when deploying your worker.
730
+ *
731
+ * NOTE: This field is not automatically inherited from the top level environment,
732
+ * and so must be specified in every named environment.
733
+ *
734
+ * @default `{}`
735
+ * @nonInheritable
736
+ */
737
+ define: Record<string, string>;
738
+ /**
739
+ * A map of environment variables to set when deploying your worker.
740
+ *
741
+ * NOTE: This field is not automatically inherited from the top level environment,
742
+ * and so must be specified in every named environment.
743
+ *
744
+ * @default `{}`
745
+ * @nonInheritable
746
+ */
747
+ vars: {
748
+ [key: string]: unknown;
749
+ };
750
+ /**
751
+ * A list of durable objects that your worker should be bound to.
752
+ *
753
+ * For more information about Durable Objects, see the documentation at
754
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
755
+ *
756
+ * NOTE: This field is not automatically inherited from the top level environment,
757
+ * and so must be specified in every named environment.
758
+ *
759
+ * @default `{bindings:[]}`
760
+ * @nonInheritable
761
+ */
762
+ durable_objects: {
763
+ bindings: DurableObjectBindings;
764
+ };
765
+ /**
766
+ * These specify any Workers KV Namespaces you want to
767
+ * access from inside your Worker.
768
+ *
769
+ * To learn more about KV Namespaces,
770
+ * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
771
+ *
772
+ * NOTE: This field is not automatically inherited from the top level environment,
773
+ * and so must be specified in every named environment.
774
+ *
775
+ * @default `[]`
776
+ * @nonInheritable
777
+ */
778
+ kv_namespaces: {
779
+ /** The binding name used to refer to the KV Namespace */
780
+ binding: string;
781
+ /** The ID of the KV namespace */
782
+ id: string;
783
+ /** The ID of the KV namespace used during `wrangler dev` */
784
+ preview_id?: string;
785
+ }[];
786
+ /**
787
+ * These specify bindings to send email from inside your Worker.
788
+ *
789
+ * NOTE: This field is not automatically inherited from the top level environment,
790
+ * and so must be specified in every named environment.
791
+ *
792
+ * @default `[]`
793
+ * @nonInheritable
794
+ */
795
+ send_email: {
796
+ /** The binding name used to refer to the this binding */
797
+ name: string;
798
+ /** If this binding should be restricted to a specific verified address */
799
+ destination_address?: string;
800
+ /** If this binding should be restricted to a set of verified addresses */
801
+ allowed_destination_addresses?: string[];
802
+ }[];
803
+ /**
804
+ * Specifies Queues that are bound to this Worker environment.
805
+ *
806
+ * NOTE: This field is not automatically inherited from the top level environment,
807
+ * and so must be specified in every named environment.
808
+ *
809
+ * @default `{}`
810
+ * @nonInheritable
811
+ */
812
+ queues: {
813
+ /** Producer bindings */
814
+ producers?: {
815
+ /** The binding name used to refer to the Queue in the worker. */
816
+ binding: string;
817
+ /** The name of this Queue. */
818
+ queue: string;
819
+ }[];
820
+ /** Consumer configuration */
821
+ consumers?: {
822
+ /** The name of the queue from which this script should consume. */
823
+ queue: string;
824
+ /** The maximum number of messages per batch */
825
+ max_batch_size?: number;
826
+ /** The maximum number of seconds to wait to fill a batch with messages. */
827
+ max_batch_timeout?: number;
828
+ /** The maximum number of retries for each message. */
829
+ max_retries?: number;
830
+ /** The queue to send messages that failed to be consumed. */
831
+ dead_letter_queue?: string;
832
+ /** The maximum number of concurrent consumer Worker invocations. Leaving this unset will allow your consumer to scale to the maximum concurrency needed to keep up with the message backlog. */
833
+ max_concurrency?: number | null;
834
+ }[];
835
+ };
836
+ /**
837
+ * Specifies R2 buckets that are bound to this Worker environment.
838
+ *
839
+ * NOTE: This field is not automatically inherited from the top level environment,
840
+ * and so must be specified in every named environment.
841
+ *
842
+ * @default `[]`
843
+ * @nonInheritable
844
+ */
845
+ r2_buckets: {
846
+ /** The binding name used to refer to the R2 bucket in the worker. */
847
+ binding: string;
848
+ /** The name of this R2 bucket at the edge. */
849
+ bucket_name: string;
850
+ /** The preview name of this R2 bucket at the edge. */
851
+ preview_bucket_name?: string;
852
+ }[];
853
+ /**
854
+ * Specifies D1 databases that are bound to this Worker environment.
855
+ *
856
+ * NOTE: This field is not automatically inherited from the top level environment,
857
+ * and so must be specified in every named environment.
858
+ *
859
+ * @default `[]`
860
+ * @nonInheritable
861
+ */
862
+ d1_databases: {
863
+ /** The binding name used to refer to the D1 database in the worker. */
864
+ binding: string;
865
+ /** The name of this D1 database. */
866
+ database_name: string;
867
+ /** The UUID of this D1 database (not required). */
868
+ database_id: string;
869
+ /** The UUID of this D1 database for Wrangler Dev (if specified). */
870
+ preview_database_id?: string;
871
+ /** The name of the migrations table for this D1 database (defaults to 'd1_migrations'). */
872
+ migrations_table?: string;
873
+ /** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
874
+ migrations_dir?: string;
875
+ /** Internal use only. */
876
+ database_internal_env?: string;
877
+ }[];
878
+ /**
879
+ * Specifies Constellation projects that are bound to this Worker environment.
880
+ *
881
+ * NOTE: This field is not automatically inherited from the top level environment,
882
+ * and so must be specified in every named environment.
883
+ *
884
+ * @default `[]`
885
+ * @nonInheritable
886
+ */
887
+ constellation: {
888
+ /** The binding name used to refer to the project in the worker. */
889
+ binding: string;
890
+ /** The id of the project. */
891
+ project_id: string;
892
+ }[];
893
+ /**
894
+ * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
895
+ *
896
+ * NOTE: This field is not automatically inherited from the top level environment,
897
+ * and so must be specified in every named environment.
898
+ *
899
+ * @default `[]`
900
+ * @nonInheritable
901
+ */
902
+ services: {
903
+ /** The binding name used to refer to the bound service. */
904
+ binding: string;
905
+ /** The name of the service. */
906
+ service: string;
907
+ /** The environment of the service (e.g. production, staging, etc). */
908
+ environment?: string;
909
+ }[] | undefined;
910
+ /**
911
+ * Specifies analytics engine datasets that are bound to this Worker environment.
912
+ *
913
+ * NOTE: This field is not automatically inherited from the top level environment,
914
+ * and so must be specified in every named environment.
915
+ *
916
+ * @default `[]`
917
+ * @nonInheritable
918
+ */
919
+ analytics_engine_datasets: {
920
+ /** The binding name used to refer to the dataset in the worker. */
921
+ binding: string;
922
+ /** The name of this dataset to write to. */
923
+ dataset?: string;
924
+ }[];
925
+ /**
926
+ * A browser that will be usable from the worker.
927
+ */
928
+ browser: {
929
+ binding: string;
930
+ } | undefined;
931
+ /**
932
+ * "Unsafe" tables for features that aren't directly supported by wrangler.
933
+ *
934
+ * NOTE: This field is not automatically inherited from the top level environment,
935
+ * and so must be specified in every named environment.
936
+ *
937
+ * @nonInheritable
938
+ */
939
+ unsafe: {
940
+ /**
941
+ * A set of bindings that should be put into a Worker's upload metadata without changes. These
942
+ * can be used to implement bindings for features that haven't released and aren't supported
943
+ * directly by wrangler or miniflare.
944
+ */
945
+ bindings?: {
946
+ name: string;
947
+ type: string;
948
+ [key: string]: unknown;
949
+ }[];
950
+ /**
951
+ * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
952
+ * here will always be applied to metadata last, so can add new or override existing fields.
953
+ */
954
+ metadata?: {
955
+ [key: string]: string;
956
+ };
957
+ };
958
+ mtls_certificates: {
959
+ /** The binding name used to refer to the certificate in the worker */
960
+ binding: string;
961
+ /** The uuid of the uploaded mTLS certificate */
962
+ certificate_id: string;
963
+ }[];
964
+ }
965
+
966
+ declare namespace Errors {
967
+ class UndiciError extends Error { }
968
+
969
+ /** Connect timeout error. */
970
+ class ConnectTimeoutError extends UndiciError {
971
+ name: 'ConnectTimeoutError';
972
+ code: 'UND_ERR_CONNECT_TIMEOUT';
973
+ }
974
+
975
+ /** A header exceeds the `headersTimeout` option. */
976
+ class HeadersTimeoutError extends UndiciError {
977
+ name: 'HeadersTimeoutError';
978
+ code: 'UND_ERR_HEADERS_TIMEOUT';
979
+ }
980
+
981
+ /** Headers overflow error. */
982
+ class HeadersOverflowError extends UndiciError {
983
+ name: 'HeadersOverflowError'
984
+ code: 'UND_ERR_HEADERS_OVERFLOW'
985
+ }
986
+
987
+ /** A body exceeds the `bodyTimeout` option. */
988
+ class BodyTimeoutError extends UndiciError {
989
+ name: 'BodyTimeoutError';
990
+ code: 'UND_ERR_BODY_TIMEOUT';
991
+ }
992
+
993
+ class ResponseStatusCodeError extends UndiciError {
994
+ name: 'ResponseStatusCodeError';
995
+ code: 'UND_ERR_RESPONSE_STATUS_CODE';
996
+ body: null | Record<string, any> | string
997
+ status: number
998
+ statusCode: number
999
+ headers: IncomingHttpHeaders | string[] | null;
1000
+ }
1001
+
1002
+ /** Passed an invalid argument. */
1003
+ class InvalidArgumentError extends UndiciError {
1004
+ name: 'InvalidArgumentError';
1005
+ code: 'UND_ERR_INVALID_ARG';
1006
+ }
1007
+
1008
+ /** Returned an invalid value. */
1009
+ class InvalidReturnValueError extends UndiciError {
1010
+ name: 'InvalidReturnValueError';
1011
+ code: 'UND_ERR_INVALID_RETURN_VALUE';
1012
+ }
1013
+
1014
+ /** The request has been aborted by the user. */
1015
+ class RequestAbortedError extends UndiciError {
1016
+ name: 'AbortError';
1017
+ code: 'UND_ERR_ABORTED';
1018
+ }
1019
+
1020
+ /** Expected error with reason. */
1021
+ class InformationalError extends UndiciError {
1022
+ name: 'InformationalError';
1023
+ code: 'UND_ERR_INFO';
1024
+ }
1025
+
1026
+ /** Request body length does not match content-length header. */
1027
+ class RequestContentLengthMismatchError extends UndiciError {
1028
+ name: 'RequestContentLengthMismatchError';
1029
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
1030
+ }
1031
+
1032
+ /** Response body length does not match content-length header. */
1033
+ class ResponseContentLengthMismatchError extends UndiciError {
1034
+ name: 'ResponseContentLengthMismatchError';
1035
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
1036
+ }
1037
+
1038
+ /** Trying to use a destroyed client. */
1039
+ class ClientDestroyedError extends UndiciError {
1040
+ name: 'ClientDestroyedError';
1041
+ code: 'UND_ERR_DESTROYED';
1042
+ }
1043
+
1044
+ /** Trying to use a closed client. */
1045
+ class ClientClosedError extends UndiciError {
1046
+ name: 'ClientClosedError';
1047
+ code: 'UND_ERR_CLOSED';
1048
+ }
1049
+
1050
+ /** There is an error with the socket. */
1051
+ class SocketError extends UndiciError {
1052
+ name: 'SocketError';
1053
+ code: 'UND_ERR_SOCKET';
1054
+ socket: Client.SocketInfo | null
1055
+ }
1056
+
1057
+ /** Encountered unsupported functionality. */
1058
+ class NotSupportedError extends UndiciError {
1059
+ name: 'NotSupportedError';
1060
+ code: 'UND_ERR_NOT_SUPPORTED';
1061
+ }
1062
+
1063
+ /** No upstream has been added to the BalancedPool. */
1064
+ class BalancedPoolMissingUpstreamError extends UndiciError {
1065
+ name: 'MissingUpstreamError';
1066
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM';
1067
+ }
1068
+
1069
+ class HTTPParserError extends UndiciError {
1070
+ name: 'HTTPParserError';
1071
+ code: string;
1072
+ }
1073
+
1074
+ /** The response exceed the length allowed. */
1075
+ class ResponseExceededMaxSizeError extends UndiciError {
1076
+ name: 'ResponseExceededMaxSizeError';
1077
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
1078
+ }
1079
+ }
1080
+
1081
+ declare class File extends Blob_2 {
1082
+ /**
1083
+ * Creates a new File instance.
1084
+ *
1085
+ * @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).
1086
+ * @param fileName The name of the file.
1087
+ * @param options An options object containing optional attributes for the file.
1088
+ */
1089
+ constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FilePropertyBag)
1090
+
1091
+ /**
1092
+ * Name of the file referenced by the File object.
1093
+ */
1094
+ readonly name: string
1095
+
1096
+ /**
1097
+ * 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.
1098
+ */
1099
+ readonly lastModified: number
1100
+
1101
+ readonly [Symbol.toStringTag]: string
1102
+ }
1103
+
1104
+ declare interface FilePropertyBag extends BlobPropertyBag {
1105
+ /**
1106
+ * 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.
1107
+ */
1108
+ lastModified?: number
1109
+ }
1110
+
1111
+ /**
1112
+ * 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().
1113
+ */
1114
+ declare class FormData {
1115
+ /**
1116
+ * Appends a new value onto an existing key inside a FormData object,
1117
+ * or adds the key if it does not already exist.
1118
+ *
1119
+ * 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.
1120
+ *
1121
+ * @param name The name of the field whose data is contained in `value`.
1122
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
1123
+ 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.
1124
+ * @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.
1125
+ */
1126
+ append(name: string, value: unknown, fileName?: string): void
1127
+
1128
+ /**
1129
+ * Set a new value for an existing key inside FormData,
1130
+ * or add the new field if it does not already exist.
1131
+ *
1132
+ * @param name The name of the field whose data is contained in `value`.
1133
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
1134
+ 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.
1135
+ * @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.
1136
+ *
1137
+ */
1138
+ set(name: string, value: unknown, fileName?: string): void
1139
+
1140
+ /**
1141
+ * Returns the first value associated with a given key from within a `FormData` object.
1142
+ * If you expect multiple values and want all of them, use the `getAll()` method instead.
1143
+ *
1144
+ * @param {string} name A name of the value you want to retrieve.
1145
+ *
1146
+ * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
1147
+ */
1148
+ get(name: string): FormDataEntryValue | null
1149
+
1150
+ /**
1151
+ * Returns all the values associated with a given key from within a `FormData` object.
1152
+ *
1153
+ * @param {string} name A name of the value you want to retrieve.
1154
+ *
1155
+ * @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.
1156
+ */
1157
+ getAll(name: string): FormDataEntryValue[]
1158
+
1159
+ /**
1160
+ * Returns a boolean stating whether a `FormData` object contains a certain key.
1161
+ *
1162
+ * @param name A string representing the name of the key you want to test for.
1163
+ *
1164
+ * @return A boolean value.
1165
+ */
1166
+ has(name: string): boolean
1167
+
1168
+ /**
1169
+ * Deletes a key and its value(s) from a `FormData` object.
1170
+ *
1171
+ * @param name The name of the key you want to delete.
1172
+ */
1173
+ delete(name: string): void
1174
+
1175
+ /**
1176
+ * Executes given callback function for each field of the FormData instance
1177
+ */
1178
+ forEach: (
1179
+ callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void,
1180
+ thisArg?: unknown
1181
+ ) => void
1182
+
1183
+ /**
1184
+ * 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.
1185
+ * Each key is a `string`.
1186
+ */
1187
+ keys: () => SpecIterableIterator<string>
1188
+
1189
+ /**
1190
+ * 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.
1191
+ * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
1192
+ */
1193
+ values: () => SpecIterableIterator<FormDataEntryValue>
1194
+
1195
+ /**
1196
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
1197
+ * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
1198
+ */
1199
+ entries: () => SpecIterableIterator<[string, FormDataEntryValue]>
1200
+
1201
+ /**
1202
+ * An alias for FormData#entries()
1203
+ */
1204
+ [Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>
1205
+
1206
+ readonly [Symbol.toStringTag]: string
1207
+ }
1208
+
1209
+ /**
1210
+ * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
1211
+ */
1212
+ declare type FormDataEntryValue = string | File
1213
+
1214
+ /**
1215
+ * fetches an mTLS certificate from the account mTLS certificate store by ID
1216
+ */
1217
+ export declare function getMTlsCertificate(accountId: string, id: string): Promise<MTlsCertificateResponse>;
1218
+
1219
+ /**
1220
+ * fetches an mTLS certificate from the account mTLS certificate store by name. will throw an error if no certificates are found, or multiple are found with that name
1221
+ */
1222
+ export declare function getMTlsCertificateByName(accountId: string, name: string): Promise<MTlsCertificateResponse>;
1223
+
1224
+ declare class Headers implements SpecIterable<[string, string]> {
1225
+ constructor (init?: HeadersInit)
1226
+ readonly append: (name: string, value: string) => void
1227
+ readonly delete: (name: string) => void
1228
+ readonly get: (name: string) => string | null
1229
+ readonly has: (name: string) => boolean
1230
+ readonly set: (name: string, value: string) => void
1231
+ readonly getSetCookie: () => string[]
1232
+ readonly forEach: (
1233
+ callbackfn: (value: string, key: string, iterable: Headers) => void,
1234
+ thisArg?: unknown
1235
+ ) => void
1236
+
1237
+ readonly keys: () => SpecIterableIterator<string>
1238
+ readonly values: () => SpecIterableIterator<string>
1239
+ readonly entries: () => SpecIterableIterator<[string, string]>
1240
+ readonly [Symbol.iterator]: () => SpecIterator<[string, string]>
1241
+ }
1242
+
1243
+ declare type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
1244
+
1245
+ /**
1246
+ * The header type declaration of `undici`.
1247
+ */
1248
+ declare type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
1249
+
1250
+ /**
1251
+ * lists mTLS certificates for an account. filtering by name is supported
1252
+ */
1253
+ export declare function listMTlsCertificates(accountId: string, filter: MTlsCertificateListFilter): Promise<MTlsCertificateResponse[]>;
1254
+
1255
+ /**
1256
+ * details for uploading an mTLS certificate via the ssl api
1257
+ */
1258
+ declare interface MTlsCertificateBody {
1259
+ certificateChain: string;
1260
+ privateKey: string;
1261
+ name?: string;
1262
+ }
1263
+
1264
+ /**
1265
+ * supported filters for listing mTLS certificates via the ssl api
1266
+ */
1267
+ declare interface MTlsCertificateListFilter {
1268
+ name?: string;
1269
+ }
1270
+
1271
+ /**
1272
+ * the representation of an mTLS certificate in the account certificate store
1273
+ */
1274
+ declare interface MTlsCertificateResponse {
1275
+ id: string;
1276
+ name?: string;
1277
+ ca: boolean;
1278
+ certificates: string;
1279
+ expires_on: string;
1280
+ issuer: string;
1281
+ serial_number: string;
1282
+ signature: string;
1283
+ uploaded_on: string;
1284
+ }
1285
+
1286
+ /**
1287
+ * details for uploading an mTLS certificate from disk
1288
+ */
1289
+ declare interface MTlsCertificateUploadDetails {
1290
+ certificateChainFilename: string;
1291
+ privateKeyFilename: string;
1292
+ name?: string;
1293
+ }
1294
+
1295
+ declare interface PagesPublishOptions {
1296
+ /**
1297
+ * Path to static assets to publish to Pages
1298
+ */
1299
+ directory: string;
1300
+ /**
1301
+ * The Cloudflare Account ID that owns the project that's
1302
+ * being published
1303
+ */
1304
+ accountId: string;
1305
+ /**
1306
+ * The name of the project to be published
1307
+ */
1308
+ projectName: string;
1309
+ /**
1310
+ * Branch name to use. Defaults to production branch
1311
+ */
1312
+ branch?: string;
1313
+ /**
1314
+ * Whether or not to skip local file upload result caching
1315
+ */
1316
+ skipCaching?: boolean;
1317
+ /**
1318
+ * Commit message associated to deployment
1319
+ */
1320
+ commitMessage?: string;
1321
+ /**
1322
+ * Commit hash associated to deployment
1323
+ */
1324
+ commitHash?: string;
1325
+ /**
1326
+ * Whether or not the deployment should be considered to be
1327
+ * in a dirty commit state
1328
+ */
1329
+ commitDirty?: boolean;
1330
+ /**
1331
+ * Path to the project's functions directory. Default uses
1332
+ * the current working directory + /functions since this is
1333
+ * typically called in a CLI
1334
+ */
1335
+ functionsDirectory?: string;
1336
+ /**
1337
+ * Whether to run bundling on `_worker.js` before deploying.
1338
+ * Default: true
1339
+ */
1340
+ bundle?: boolean;
1341
+ }
1342
+
1343
+ /**
1344
+ * Publish a directory to an account/project.
1345
+ * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
1346
+ * variable set
1347
+ */
1348
+ declare function publish({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesPublishOptions): Promise<{
1349
+ environment: "production" | "preview";
1350
+ id: string;
1351
+ project_id: string;
1352
+ url: string;
1353
+ project_name: string;
1354
+ build_config: {
1355
+ build_command: string;
1356
+ destination_dir: string;
1357
+ root_dir: string;
1358
+ web_analytics_tag?: string | undefined;
1359
+ web_analytics_token?: string | undefined;
1360
+ fast_builds?: boolean | undefined;
1361
+ };
1362
+ created_on: string;
1363
+ production_branch: string;
1364
+ deployment_trigger: {
1365
+ type: string;
1366
+ metadata: {
1367
+ branch: string;
1368
+ commit_hash: string;
1369
+ commit_message: string;
1370
+ };
1371
+ };
1372
+ latest_stage: {
1373
+ name: "build" | "queued" | "initialize" | "clone_repo" | "deploy";
1374
+ status: "active" | "canceled" | "success" | "idle" | "failure" | "skipped";
1375
+ started_on: string | null;
1376
+ ended_on: string | null;
1377
+ };
1378
+ stages: {
1379
+ name: "build" | "queued" | "initialize" | "clone_repo" | "deploy";
1380
+ status: "active" | "canceled" | "success" | "idle" | "failure" | "skipped";
1381
+ started_on: string | null;
1382
+ ended_on: string | null;
1383
+ }[];
1384
+ aliases: string[];
1385
+ modified_on: string;
1386
+ short_id: string;
1387
+ build_image_major_version: number;
1388
+ kv_namespaces?: any;
1389
+ source?: {
1390
+ type: "github" | "gitlab";
1391
+ config: {
1392
+ owner: string;
1393
+ repo_name: string;
1394
+ production_branch?: string | undefined;
1395
+ pr_comments_enabled?: boolean | undefined;
1396
+ deployments_enabled?: boolean | undefined;
1397
+ production_deployments_enabled?: boolean | undefined;
1398
+ preview_deployment_setting?: "none" | "all" | "custom" | undefined;
1399
+ preview_branch_includes?: string[] | undefined;
1400
+ preview_branch_excludes?: string[] | undefined;
1401
+ };
1402
+ } | undefined;
1403
+ env_vars?: any;
1404
+ durable_object_namespaces?: any;
1405
+ is_skipped?: boolean | undefined;
1406
+ files?: {
1407
+ [x: string]: string | undefined;
1408
+ } | undefined;
1409
+ }>;
1410
+
1411
+ declare type ReferrerPolicy =
1412
+ | ''
1413
+ | 'no-referrer'
1414
+ | 'no-referrer-when-downgrade'
1415
+ | 'origin'
1416
+ | 'origin-when-cross-origin'
1417
+ | 'same-origin'
1418
+ | 'strict-origin'
1419
+ | 'strict-origin-when-cross-origin'
1420
+ | 'unsafe-url';
1421
+
1422
+ declare class Request implements BodyMixin {
1423
+ constructor (input: RequestInfo, init?: RequestInit)
1424
+
1425
+ readonly cache: RequestCache
1426
+ readonly credentials: RequestCredentials
1427
+ readonly destination: RequestDestination
1428
+ readonly headers: Headers
1429
+ readonly integrity: string
1430
+ readonly method: string
1431
+ readonly mode: RequestMode
1432
+ readonly redirect: RequestRedirect
1433
+ readonly referrerPolicy: string
1434
+ readonly url: string
1435
+
1436
+ readonly keepalive: boolean
1437
+ readonly signal: AbortSignal
1438
+ readonly duplex: RequestDuplex
1439
+
1440
+ readonly body: ReadableStream | null
1441
+ readonly bodyUsed: boolean
1442
+
1443
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
1444
+ readonly blob: () => Promise<Blob_2>
1445
+ readonly formData: () => Promise<FormData>
1446
+ readonly json: () => Promise<unknown>
1447
+ readonly text: () => Promise<string>
1448
+
1449
+ readonly clone: () => Request
1450
+ }
1451
+
1452
+ declare type RequestCache =
1453
+ | 'default'
1454
+ | 'force-cache'
1455
+ | 'no-cache'
1456
+ | 'no-store'
1457
+ | 'only-if-cached'
1458
+ | 'reload'
1459
+
1460
+ declare type RequestCredentials = 'omit' | 'include' | 'same-origin'
1461
+
1462
+ declare type RequestDestination =
1463
+ | ''
1464
+ | 'audio'
1465
+ | 'audioworklet'
1466
+ | 'document'
1467
+ | 'embed'
1468
+ | 'font'
1469
+ | 'image'
1470
+ | 'manifest'
1471
+ | 'object'
1472
+ | 'paintworklet'
1473
+ | 'report'
1474
+ | 'script'
1475
+ | 'sharedworker'
1476
+ | 'style'
1477
+ | 'track'
1478
+ | 'video'
1479
+ | 'worker'
1480
+ | 'xslt'
1481
+
1482
+ declare type RequestDuplex = 'half'
1483
+
1484
+ declare type RequestInfo = string | URL_2 | Request
1485
+
1486
+ declare interface RequestInit {
1487
+ method?: string
1488
+ keepalive?: boolean
1489
+ headers?: HeadersInit
1490
+ body?: BodyInit
1491
+ redirect?: RequestRedirect
1492
+ integrity?: string
1493
+ signal?: AbortSignal
1494
+ credentials?: RequestCredentials
1495
+ mode?: RequestMode
1496
+ referrer?: string
1497
+ referrerPolicy?: ReferrerPolicy
1498
+ window?: null
1499
+ dispatcher?: Dispatcher
1500
+ duplex?: RequestDuplex
1501
+ }
1502
+
1503
+ declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
1504
+
1505
+ declare type RequestRedirect = 'error' | 'follow' | 'manual'
1506
+
1507
+ declare class Response implements BodyMixin {
1508
+ constructor (body?: BodyInit, init?: ResponseInit)
1509
+
1510
+ readonly headers: Headers
1511
+ readonly ok: boolean
1512
+ readonly status: number
1513
+ readonly statusText: string
1514
+ readonly type: ResponseType
1515
+ readonly url: string
1516
+ readonly redirected: boolean
1517
+
1518
+ readonly body: ReadableStream | null
1519
+ readonly bodyUsed: boolean
1520
+
1521
+ readonly arrayBuffer: () => Promise<ArrayBuffer>
1522
+ readonly blob: () => Promise<Blob_2>
1523
+ readonly formData: () => Promise<FormData>
1524
+ readonly json: () => Promise<unknown>
1525
+ readonly text: () => Promise<string>
1526
+
1527
+ readonly clone: () => Response
1528
+
1529
+ static error (): Response
1530
+ static json(data: any, init?: ResponseInit): Response
1531
+ static redirect (url: string | URL_2, status: ResponseRedirectStatus): Response
1532
+ }
1533
+
1534
+ declare interface ResponseInit {
1535
+ readonly status?: number
1536
+ readonly statusText?: string
1537
+ readonly headers?: HeadersInit
1538
+ }
1539
+
1540
+ declare type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308
1541
+
1542
+ declare type ResponseType =
1543
+ | 'basic'
1544
+ | 'cors'
1545
+ | 'default'
1546
+ | 'error'
1547
+ | 'opaque'
1548
+ | 'opaqueredirect'
1549
+
1550
+ declare type Route = SimpleRoute | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
1551
+
1552
+ /**
1553
+ * A bundling resolver rule, defining the modules type for paths that match the specified globs.
1554
+ */
1555
+ declare type Rule = {
1556
+ type: ConfigModuleRuleType;
1557
+ globs: string[];
1558
+ fallthrough?: boolean;
1559
+ };
1560
+
1561
+ declare type SimpleRoute = string;
1562
+
1563
+ declare interface SpecIterable<T> {
1564
+ [Symbol.iterator](): SpecIterator<T>;
1565
+ }
1566
+
1567
+ declare interface SpecIterableIterator<T> extends SpecIterator<T> {
1568
+ [Symbol.iterator](): SpecIterableIterator<T>;
1569
+ }
1570
+
1571
+ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
1572
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
1573
+ }
1574
+
1575
+ /**
1576
+ * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
1577
+ */
1578
+ export declare function unstable_dev(script: string, options?: UnstableDevOptions, apiOptions?: unknown): Promise<UnstableDevWorker>;
1579
+
1580
+ export declare const unstable_pages: {
1581
+ publish: typeof publish;
1582
+ };
1583
+
1584
+ export declare interface UnstableDevOptions {
1585
+ config?: string;
1586
+ env?: string;
1587
+ ip?: string;
1588
+ port?: number;
1589
+ bundle?: boolean;
1590
+ inspectorPort?: number;
1591
+ localProtocol?: "http" | "https";
1592
+ assets?: string;
1593
+ site?: string;
1594
+ siteInclude?: string[];
1595
+ siteExclude?: string[];
1596
+ nodeCompat?: boolean;
1597
+ compatibilityDate?: string;
1598
+ compatibilityFlags?: string[];
1599
+ persist?: boolean;
1600
+ persistTo?: string;
1601
+ vars?: {
1602
+ [key: string]: unknown;
1603
+ };
1604
+ kv?: {
1605
+ binding: string;
1606
+ id: string;
1607
+ preview_id?: string;
1608
+ }[];
1609
+ durableObjects?: {
1610
+ name: string;
1611
+ class_name: string;
1612
+ script_name?: string | undefined;
1613
+ environment?: string | undefined;
1614
+ }[];
1615
+ r2?: {
1616
+ binding: string;
1617
+ bucket_name: string;
1618
+ preview_bucket_name?: string;
1619
+ }[];
1620
+ processEntrypoint?: boolean;
1621
+ moduleRoot?: string;
1622
+ rules?: Rule[];
1623
+ logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
1624
+ inspect?: boolean;
1625
+ local?: boolean;
1626
+ accountId?: string;
1627
+ experimental?: {
1628
+ d1Databases?: Environment["d1_databases"];
1629
+ disableExperimentalWarning?: boolean;
1630
+ disableDevRegistry?: boolean;
1631
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
1632
+ experimentalLocal?: boolean;
1633
+ experimentalLocalRemoteKv?: boolean;
1634
+ forceLocal?: boolean;
1635
+ liveReload?: boolean;
1636
+ showInteractiveDevSession?: boolean;
1637
+ testMode?: boolean;
1638
+ testScheduled?: boolean;
1639
+ watch?: boolean;
1640
+ };
1641
+ }
1642
+
1643
+ export declare interface UnstableDevWorker {
1644
+ port: number;
1645
+ address: string;
1646
+ stop: () => Promise<void>;
1647
+ fetch: (input?: RequestInfo, init?: RequestInit) => Promise<Response>;
1648
+ waitUntilExit: () => Promise<void>;
1649
+ }
1650
+
1651
+ /**
1652
+ * uploads an mTLS certificate and private key pair to the account mTLS certificate store
1653
+ */
1654
+ export declare function uploadMTlsCertificate(accountId: string, body: MTlsCertificateBody): Promise<MTlsCertificateResponse>;
1655
+
1656
+ /**
1657
+ * reads an mTLS certificate and private key pair from disk and uploads it to the account mTLS certificate store
1658
+ */
1659
+ export declare function uploadMTlsCertificateFromFs(accountId: string, details: MTlsCertificateUploadDetails): Promise<MTlsCertificateResponse>;
1660
+
1661
+ declare type ZoneIdRoute = {
1662
+ pattern: string;
1663
+ zone_id: string;
1664
+ custom_domain?: boolean;
1665
+ };
1666
+
1667
+ declare type ZoneNameRoute = {
1668
+ pattern: string;
1669
+ zone_name: string;
1670
+ custom_domain?: boolean;
1671
+ };
1672
+
1673
+ export { }