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