@cloudflare/workers-utils 0.23.0 → 0.23.1
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/dist/browser.d.mts +3 -1
- package/dist/{config-BT23LDfr.d.mts → config-DrgFpZpF.d.mts} +525 -1
- package/dist/index.d.mts +45 -332
- package/dist/index.mjs +54 -13
- package/dist/metafile-esm.json +1 -1
- package/dist/test-helpers/index.d.mts +3 -1
- package/package.json +4 -4
package/dist/browser.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { T as TailConsumer,
|
|
1
|
+
import { T as TailConsumer, aD as WorkerMetadata, R as RawConfig } from './config-DrgFpZpF.mjs';
|
|
2
2
|
import { AssetConfig } from '@cloudflare/workers-shared';
|
|
3
3
|
import { Cloudflare } from 'cloudflare';
|
|
4
|
+
import 'node:url';
|
|
5
|
+
import 'undici';
|
|
4
6
|
|
|
5
7
|
type RoutesRes = {
|
|
6
8
|
id: string;
|
|
@@ -1,5 +1,345 @@
|
|
|
1
|
+
import { URLSearchParams } from 'node:url';
|
|
2
|
+
import { RequestInit, Response as Response$1, Headers, MockAgent } from 'undici';
|
|
1
3
|
import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
|
|
2
4
|
|
|
5
|
+
interface FetchError {
|
|
6
|
+
code: number;
|
|
7
|
+
documentation_url?: string;
|
|
8
|
+
message: string;
|
|
9
|
+
error_chain?: FetchError[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `WRANGLER_C3_COMMAND` can override the command used by `wrangler init` when delegating to C3.
|
|
14
|
+
*
|
|
15
|
+
* By default this will use `create cloudflare`.
|
|
16
|
+
*
|
|
17
|
+
* To run against the beta release of C3 use:
|
|
18
|
+
*
|
|
19
|
+
* ```sh
|
|
20
|
+
* # Tell Wrangler to use the beta version of create-cloudflare
|
|
21
|
+
* WRANGLER_C3_COMMAND="create cloudflare@beta" npx wrangler init
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* To test the integration between wrangler and C3 locally, use:
|
|
25
|
+
*
|
|
26
|
+
* ```sh
|
|
27
|
+
* # Ensure both Wrangler and C3 are built
|
|
28
|
+
* npm run build
|
|
29
|
+
* # Tell Wrangler to use the local version of create-cloudflare
|
|
30
|
+
* WRANGLER_C3_COMMAND="exec ./packages/create-cloudflare" npx wrangler init temp
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Note that you cannot use `WRANGLER_C3_COMMAND="create cloudflare@2"` if you are
|
|
34
|
+
* running Wrangler from inside the monorepo as the bin paths get messed up.
|
|
35
|
+
*/
|
|
36
|
+
declare const getC3CommandFromEnv: () => string;
|
|
37
|
+
/**
|
|
38
|
+
* `WRANGLER_SEND_METRICS` can override whether we attempt to send metrics information to Sparrow.
|
|
39
|
+
*/
|
|
40
|
+
declare const getWranglerSendMetricsFromEnv: () => boolean | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* `WRANGLER_SEND_ERROR_REPORTS` controls whether we attempt to send error reports to Sentry.
|
|
43
|
+
*
|
|
44
|
+
* Defaults to `false` to avoid noisy false-positive reports. Users can opt in
|
|
45
|
+
* by setting `WRANGLER_SEND_ERROR_REPORTS=true`.
|
|
46
|
+
*/
|
|
47
|
+
declare const getWranglerSendErrorReportsFromEnv: () => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Set `WRANGLER_API_ENVIRONMENT` environment variable to "staging" to tell Wrangler to hit the staging APIs rather than production.
|
|
50
|
+
*/
|
|
51
|
+
declare const getCloudflareApiEnvironmentFromEnv: () => "production" | "staging";
|
|
52
|
+
/**
|
|
53
|
+
* The compliance region to use for the API requests.
|
|
54
|
+
*/
|
|
55
|
+
type ComplianceConfig = Partial<Pick<Config, "compliance_region">>;
|
|
56
|
+
/** Used for commands that explicitly do not support compliance regions other than "public" */
|
|
57
|
+
declare const COMPLIANCE_REGION_CONFIG_PUBLIC: ComplianceConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Used for commands where there is no configuration available and
|
|
60
|
+
* we rely upon the CLOUDFLARE_COMPLIANCE_REGION environment variable
|
|
61
|
+
* to determine the compliance region.
|
|
62
|
+
*/
|
|
63
|
+
declare const COMPLIANCE_REGION_CONFIG_UNKNOWN: ComplianceConfig;
|
|
64
|
+
/**
|
|
65
|
+
* Set `CLOUDFLARE_COMPLIANCE_REGION` environment variable to "fedramp_high"
|
|
66
|
+
* or set the `compliance_region` property in the Wrangler configuration
|
|
67
|
+
* to tell Wrangler to run in FedRAMP High compliance region mode, rather than "public" mode.
|
|
68
|
+
*/
|
|
69
|
+
declare const getCloudflareComplianceRegion: (complianceConfig: ComplianceConfig) => "public" | "fedramp_high";
|
|
70
|
+
/**
|
|
71
|
+
* `CLOUDFLARE_API_BASE_URL` specifies the URL to the Cloudflare API.
|
|
72
|
+
*
|
|
73
|
+
* If this environment variable is not set, it will default to a URL computed from the
|
|
74
|
+
* Cloudflare compliance region and the API environment.
|
|
75
|
+
*/
|
|
76
|
+
declare const getCloudflareApiBaseUrl: (complianceConfig: ComplianceConfig) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Compute the subdomain for the compliance region.
|
|
79
|
+
*/
|
|
80
|
+
declare function getComplianceRegionSubdomain(complianceConfig: ComplianceConfig): string;
|
|
81
|
+
/**
|
|
82
|
+
* `WRANGLER_LOG_SANITIZE` specifies whether we sanitize debug logs.
|
|
83
|
+
*
|
|
84
|
+
* By default we do, since debug logs could be added to GitHub issues and shouldn't include sensitive information.
|
|
85
|
+
*/
|
|
86
|
+
declare const getSanitizeLogs: () => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* `WRANGLER_OUTPUT_FILE_DIRECTORY` specifies a directory where we should write a file containing output data in ND-JSON format.
|
|
89
|
+
*
|
|
90
|
+
* If this is set a random file will be created in this directory, and certain Wrangler commands will write entries to this file.
|
|
91
|
+
* This is overridden by the `WRANGLER_OUTPUT_FILE_PATH` environment variable.
|
|
92
|
+
*/
|
|
93
|
+
declare const getOutputFileDirectoryFromEnv: () => string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* `WRANGLER_OUTPUT_FILE_PATH` specifies a path to a file where we should write output data in ND-JSON format.
|
|
96
|
+
*
|
|
97
|
+
* If this is set certain Wrangler commands will write entries to this file.
|
|
98
|
+
* This overrides the `WRANGLER_OUTPUT_FILE_DIRECTORY` environment variable.
|
|
99
|
+
*/
|
|
100
|
+
declare const getOutputFilePathFromEnv: () => string | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* `WRANGLER_CI_MATCH_TAG` specifies a Worker tag
|
|
103
|
+
*
|
|
104
|
+
* If this is set, Wrangler will ensure the Worker being targeted has this tag
|
|
105
|
+
*/
|
|
106
|
+
declare const getCIMatchTag: () => string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* `WRANGLER_CI_OVERRIDE_NAME` specifies a Worker name
|
|
109
|
+
*
|
|
110
|
+
* If this is set, Wrangler will override the Worker name with this one
|
|
111
|
+
*/
|
|
112
|
+
declare const getCIOverrideName: () => string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* `WRANGLER_CI_OVERRIDE_NETWORK_MODE_HOST` specifies whether --network=host should be set
|
|
115
|
+
*
|
|
116
|
+
* If this is set to true, Wrangler will use the --network=host flag when calling out to docker to build container images
|
|
117
|
+
*/
|
|
118
|
+
declare const getCIOverrideNetworkModeHost: () => string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* `WRANGLER_CI_GENERATE_PREVIEW_ALIAS` specifies whether to generate a preview alias during version upload
|
|
121
|
+
*
|
|
122
|
+
* If this is set to true, Wrangler will attempt to autogenerate the preview alias by using the branch
|
|
123
|
+
* name. If the branch name is too long and an alias cannot be created, a warning will be printed to the console.
|
|
124
|
+
*/
|
|
125
|
+
declare const getCIGeneratePreviewAlias: () => "true" | "false";
|
|
126
|
+
/**
|
|
127
|
+
* `WORKERS_CI_BRANCH` is the branch name exposed by Workers CI
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
declare const getWorkersCIBranchName: () => string | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* `WRANGLER_BUILD_CONDITIONS` specifies the "build conditions" to use when importing packages at build time.
|
|
133
|
+
*
|
|
134
|
+
* See https://nodejs.org/api/packages.html#conditional-exports
|
|
135
|
+
* and https://esbuild.github.io/api/#how-conditions-work.
|
|
136
|
+
*
|
|
137
|
+
* If this is set, Wrangler will configure esbuild to use this list of conditions.
|
|
138
|
+
* The format is a string of comma separated conditions.
|
|
139
|
+
*/
|
|
140
|
+
declare const getBuildConditionsFromEnv: () => string | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* `WRANGLER_BUILD_PLATFORM` specifies the "build platform" to use when importing packages at build time.
|
|
143
|
+
*
|
|
144
|
+
* See https://esbuild.github.io/api/#platform
|
|
145
|
+
* and https://esbuild.github.io/api/#how-conditions-work.
|
|
146
|
+
*
|
|
147
|
+
* If this is set, Wrangler will configure esbuild to use this platform.
|
|
148
|
+
*/
|
|
149
|
+
declare const getBuildPlatformFromEnv: () => string | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* `WRANGLER_REGISTRY_PATH` specifies the file based dev registry folder
|
|
152
|
+
*/
|
|
153
|
+
declare const getRegistryPath: () => string;
|
|
154
|
+
/**
|
|
155
|
+
* `WRANGLER_D1_EXTRA_LOCATION_CHOICES` is an internal variable to let D1 team target their testing environments.
|
|
156
|
+
*
|
|
157
|
+
* External accounts cannot access testing environments, so should not set this variable.
|
|
158
|
+
*/
|
|
159
|
+
declare const getD1ExtraLocationChoices: () => string | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* `WRANGLER_DOCKER_BIN` specifies the path to a docker binary.
|
|
162
|
+
*
|
|
163
|
+
* By default it's `docker`.
|
|
164
|
+
*/
|
|
165
|
+
declare const getDockerPath: () => string;
|
|
166
|
+
declare const getSubdomainMixedStateCheckDisabled: () => boolean;
|
|
167
|
+
/**
|
|
168
|
+
/**
|
|
169
|
+
* `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV` specifies whether to load vars for local dev from `.env` files.
|
|
170
|
+
*/
|
|
171
|
+
declare const getCloudflareLoadDevVarsFromDotEnv: () => boolean;
|
|
172
|
+
/**
|
|
173
|
+
* `CLOUDFLARE_INCLUDE_PROCESS_ENV` specifies whether to include the `process.env` in vars loaded from `.env` for local development.
|
|
174
|
+
*/
|
|
175
|
+
declare const getCloudflareIncludeProcessEnvFromEnv: () => boolean;
|
|
176
|
+
declare const getTraceHeader: () => string | undefined;
|
|
177
|
+
declare const getDisableConfigWatching: () => boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Hide the Wrangler version banner and command status (deprecated/experimental) warnings
|
|
180
|
+
*/
|
|
181
|
+
declare const getWranglerHideBanner: () => boolean;
|
|
182
|
+
/**
|
|
183
|
+
* `CLOUDFLARE_ENV` specifies the currently selected Wrangler/Cloudflare environment.
|
|
184
|
+
*/
|
|
185
|
+
declare const getCloudflareEnv: () => string | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* `OPEN_NEXT_DEPLOY` is an environment variables that indicates that the current process is being
|
|
188
|
+
* run by the open-next deploy command
|
|
189
|
+
*/
|
|
190
|
+
declare const getOpenNextDeployFromEnv: () => string | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* `X_LOCAL_EXPLORER` enables the local explorer UI at /cdn-cgi/explorer.
|
|
193
|
+
*/
|
|
194
|
+
declare const getLocalExplorerEnabledFromEnv: () => boolean;
|
|
195
|
+
/**
|
|
196
|
+
* `X_BROWSER_HEADFUL` opens the browser in headful (visible) mode when using the
|
|
197
|
+
* Browser Run API in local development.
|
|
198
|
+
*
|
|
199
|
+
* Set to "true" to enable:
|
|
200
|
+
*
|
|
201
|
+
* ```sh
|
|
202
|
+
* X_BROWSER_HEADFUL=true vite dev
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* Note: when using `@cloudflare/playwright`, two Chrome windows may appear — the initial blank
|
|
206
|
+
* page and the one created by `browser.newPage()`. This is expected due to how Playwright handles
|
|
207
|
+
* browser contexts via CDP.
|
|
208
|
+
*/
|
|
209
|
+
declare const getBrowserRenderingHeadfulFromEnv: () => boolean;
|
|
210
|
+
/**
|
|
211
|
+
* `CLOUDFLARE_CF_FETCH_ENABLED` controls whether Miniflare fetches the `cf.json` file
|
|
212
|
+
* containing request.cf properties from workers.cloudflare.com.
|
|
213
|
+
*
|
|
214
|
+
* - If set to "false", disables fetching and uses fallback data (no files created)
|
|
215
|
+
* - If set to "true" or not set, uses the default behavior (fetches and caches cf.json)
|
|
216
|
+
*
|
|
217
|
+
* This is particularly useful for non-JavaScript projects that don't want
|
|
218
|
+
* a node_modules directory created automatically.
|
|
219
|
+
*
|
|
220
|
+
* Example:
|
|
221
|
+
* ```sh
|
|
222
|
+
* # Disable cf fetching entirely
|
|
223
|
+
* CLOUDFLARE_CF_FETCH_ENABLED=false npx wrangler dev
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare const getCfFetchEnabledFromEnv: () => boolean;
|
|
227
|
+
/**
|
|
228
|
+
* `CLOUDFLARE_CF_FETCH_PATH` specifies a custom path for caching the cf.json file.
|
|
229
|
+
*
|
|
230
|
+
* - If set, uses the specified path instead of the default node_modules/.mf/cf.json
|
|
231
|
+
* - If not set, uses the default location (node_modules/.mf/cf.json)
|
|
232
|
+
*
|
|
233
|
+
* Example:
|
|
234
|
+
* ```sh
|
|
235
|
+
* # Use a custom cache location
|
|
236
|
+
* CLOUDFLARE_CF_FETCH_PATH=/tmp/cf-cache.json npx wrangler dev
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
declare const getCfFetchPathFromEnv: () => string | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* `WRANGLER_CACHE_DIR` specifies a custom directory for Wrangler's cache files.
|
|
242
|
+
* This overrides the default `node_modules/.cache/wrangler` location.
|
|
243
|
+
* Useful for Yarn PnP or projects without node_modules.
|
|
244
|
+
*/
|
|
245
|
+
declare const getWranglerCacheDirFromEnv: () => string | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* `CLOUDFLARED_PATH` specifies a custom path to a cloudflared binary.
|
|
248
|
+
*
|
|
249
|
+
* If set, Wrangler will use this cloudflared binary instead of downloading one.
|
|
250
|
+
* The path must point to an existing executable file.
|
|
251
|
+
*/
|
|
252
|
+
declare const getCloudflaredPathFromEnv: () => string | undefined;
|
|
253
|
+
|
|
254
|
+
declare const LOGGER_LEVELS: {
|
|
255
|
+
readonly none: -1;
|
|
256
|
+
readonly error: 0;
|
|
257
|
+
readonly warn: 1;
|
|
258
|
+
readonly info: 2;
|
|
259
|
+
readonly log: 3;
|
|
260
|
+
readonly debug: 4;
|
|
261
|
+
};
|
|
262
|
+
type LoggerLevel = keyof typeof LOGGER_LEVELS;
|
|
263
|
+
type Logger = {
|
|
264
|
+
loggerLevel?: LoggerLevel;
|
|
265
|
+
debug: typeof console.debug;
|
|
266
|
+
debugWithSanitization?: (label: string, ...args: unknown[]) => void;
|
|
267
|
+
log: typeof console.log;
|
|
268
|
+
info: typeof console.info;
|
|
269
|
+
warn: typeof console.warn;
|
|
270
|
+
error: typeof console.error;
|
|
271
|
+
once?: {
|
|
272
|
+
info: typeof console.info;
|
|
273
|
+
log: typeof console.log;
|
|
274
|
+
warn: typeof console.warn;
|
|
275
|
+
error: typeof console.error;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
type ApiCredentials = {
|
|
280
|
+
apiToken: string;
|
|
281
|
+
} | {
|
|
282
|
+
authKey: string;
|
|
283
|
+
authEmail: string;
|
|
284
|
+
};
|
|
285
|
+
interface FetchResult<ResponseType = unknown> {
|
|
286
|
+
success: boolean;
|
|
287
|
+
result: ResponseType;
|
|
288
|
+
errors: FetchError[];
|
|
289
|
+
messages?: (string | {
|
|
290
|
+
code?: number;
|
|
291
|
+
message: string;
|
|
292
|
+
})[];
|
|
293
|
+
result_info?: unknown;
|
|
294
|
+
}
|
|
295
|
+
type FetchResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams, abortSignal?: AbortSignal) => Promise<ResponseType>;
|
|
296
|
+
type FetchListResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams) => Promise<ResponseType[]>;
|
|
297
|
+
type FetchPagedListResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams) => Promise<ResponseType[]>;
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* Note this requires its caller to handle credentials
|
|
301
|
+
* (need to call requireLoggedIn and requireApiToken)
|
|
302
|
+
*/
|
|
303
|
+
declare function performApiFetchBase(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<Response$1>;
|
|
304
|
+
declare function fetchInternalBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<{
|
|
305
|
+
response: ResponseType;
|
|
306
|
+
status: number;
|
|
307
|
+
}>;
|
|
308
|
+
declare function fetchResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<ResponseType>;
|
|
309
|
+
declare function fetchListResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, credentials?: ApiCredentials): Promise<ResponseType[]>;
|
|
310
|
+
declare function truncate(text: string, maxLength: number): string;
|
|
311
|
+
declare function isWAFBlockResponse(headers: Headers): boolean;
|
|
312
|
+
declare function extractWAFBlockRayId(headers: Headers): string | undefined;
|
|
313
|
+
declare function extractAccountTag(resource: string): string | undefined;
|
|
314
|
+
interface PageResultInfo {
|
|
315
|
+
page: number;
|
|
316
|
+
per_page: number;
|
|
317
|
+
count: number;
|
|
318
|
+
total_count: number;
|
|
319
|
+
}
|
|
320
|
+
declare function hasMorePages(result_info: unknown): result_info is PageResultInfo;
|
|
321
|
+
declare function renderError(err: FetchError | {
|
|
322
|
+
code?: number;
|
|
323
|
+
message?: string;
|
|
324
|
+
documentation_url?: string;
|
|
325
|
+
}, level?: number): string;
|
|
326
|
+
declare function addAuthorizationHeader(headers: Headers, auth: ApiCredentials, overrideExisting?: boolean): void;
|
|
327
|
+
declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number): never;
|
|
328
|
+
/**
|
|
329
|
+
* Fetch a raw KV value from the Cloudflare API.
|
|
330
|
+
*
|
|
331
|
+
* This is special-cased because it's the only API endpoint that returns raw
|
|
332
|
+
* binary data instead of a JSON envelope.
|
|
333
|
+
*
|
|
334
|
+
* Note: callers must call encodeURIComponent on `key` before passing it.
|
|
335
|
+
*/
|
|
336
|
+
declare function fetchKVGetValueBase(complianceConfig: ComplianceConfig, accountId: string, namespaceId: string, key: string, userAgent: string, logger: Logger, credentials: ApiCredentials): Promise<ArrayBuffer>;
|
|
337
|
+
type FetchKVGetValueFetcher = (complianceConfig: ComplianceConfig, accountId: string, namespaceId: string, key: string) => Promise<ArrayBuffer>;
|
|
338
|
+
declare function hasCursor(result_info: unknown): result_info is {
|
|
339
|
+
cursor: string;
|
|
340
|
+
};
|
|
341
|
+
declare function maybeAddTraceHeader(headers: Headers): void;
|
|
342
|
+
|
|
3
343
|
/**
|
|
4
344
|
* A symbol to inherit a binding from the deployed worker.
|
|
5
345
|
*/
|
|
@@ -683,6 +1023,16 @@ type AssetsOptions = {
|
|
|
683
1023
|
_headers?: string;
|
|
684
1024
|
run_worker_first?: boolean | string[];
|
|
685
1025
|
};
|
|
1026
|
+
/**
|
|
1027
|
+
* The result of validating and resolving the assets directory, before the
|
|
1028
|
+
* full {@link AssetsOptions} are resolved. Produced by the validation half of
|
|
1029
|
+
* `getAssetsOptions` and consumed by `resolveAssetOptions`.
|
|
1030
|
+
*/
|
|
1031
|
+
type ValidatedAssetsOptions = {
|
|
1032
|
+
directory: string;
|
|
1033
|
+
binding?: string;
|
|
1034
|
+
directoryExists: boolean;
|
|
1035
|
+
};
|
|
686
1036
|
/**
|
|
687
1037
|
* Information about the assets that should be uploaded
|
|
688
1038
|
*/
|
|
@@ -904,6 +1254,180 @@ type Binding = {
|
|
|
904
1254
|
} | {
|
|
905
1255
|
type: "inherit";
|
|
906
1256
|
};
|
|
1257
|
+
interface CfAccount {
|
|
1258
|
+
/**
|
|
1259
|
+
* An API token.
|
|
1260
|
+
*
|
|
1261
|
+
* @link https://api.cloudflare.com/#user-api-tokens-properties
|
|
1262
|
+
*/
|
|
1263
|
+
apiToken: ApiCredentials;
|
|
1264
|
+
/**
|
|
1265
|
+
* An account ID.
|
|
1266
|
+
*/
|
|
1267
|
+
accountId: string;
|
|
1268
|
+
}
|
|
1269
|
+
type HookValues = string | number | boolean | object | undefined | null;
|
|
1270
|
+
type Hook<T extends HookValues, Args extends unknown[] = []> = T | ((...args: Args) => T);
|
|
1271
|
+
type AsyncHook<T extends HookValues, Args extends unknown[] = []> = Hook<T, Args> | Hook<Promise<T>, Args>;
|
|
1272
|
+
type LogLevel = "debug" | "info" | "log" | "warn" | "error" | "none";
|
|
1273
|
+
type NodeJSCompatMode = "als" | "v1" | "v2" | null;
|
|
1274
|
+
interface StartDevWorkerInput {
|
|
1275
|
+
/** The name of the worker. */
|
|
1276
|
+
name?: string;
|
|
1277
|
+
/**
|
|
1278
|
+
* The javascript or typescript entry-point of the worker.
|
|
1279
|
+
* This is the `main` property of a Wrangler configuration file.
|
|
1280
|
+
*/
|
|
1281
|
+
entrypoint?: string;
|
|
1282
|
+
/** The configuration path of the worker, or a normalized configuration object. */
|
|
1283
|
+
config?: string | Config;
|
|
1284
|
+
/** The compatibility date for the workerd runtime. */
|
|
1285
|
+
compatibilityDate?: string;
|
|
1286
|
+
/** The compatibility flags for the workerd runtime. */
|
|
1287
|
+
compatibilityFlags?: string[];
|
|
1288
|
+
/** Specify the compliance region mode of the Worker. */
|
|
1289
|
+
complianceRegion?: Config["compliance_region"];
|
|
1290
|
+
/** Configuration for Python modules. */
|
|
1291
|
+
pythonModules?: {
|
|
1292
|
+
/** A list of glob patterns to exclude files from the python_modules directory when bundling. */
|
|
1293
|
+
exclude?: string[];
|
|
1294
|
+
};
|
|
1295
|
+
env?: string;
|
|
1296
|
+
/**
|
|
1297
|
+
* An array of paths to the .env files to load for this worker, relative to the project directory.
|
|
1298
|
+
*
|
|
1299
|
+
* If not specified, defaults to the standard `.env` files as given from Wrangler.
|
|
1300
|
+
* The project directory is where the Wrangler configuration file is located or the current working directory otherwise.
|
|
1301
|
+
*/
|
|
1302
|
+
envFiles?: string[];
|
|
1303
|
+
/** The bindings available to the worker. The specified binding type will be exposed to the worker on the `env` object under the same key. */
|
|
1304
|
+
bindings?: Record<string, Binding>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Default bindings that can be overridden by config bindings.
|
|
1307
|
+
* Useful for injecting environment-specific defaults like CF_PAGES variables.
|
|
1308
|
+
*/
|
|
1309
|
+
defaultBindings?: Record<string, Extract<Binding, {
|
|
1310
|
+
type: "plain_text";
|
|
1311
|
+
}>>;
|
|
1312
|
+
migrations?: DurableObjectMigration[];
|
|
1313
|
+
containers?: ContainerApp[];
|
|
1314
|
+
/** The triggers which will cause the worker's exported default handlers to be called. */
|
|
1315
|
+
triggers?: Trigger[];
|
|
1316
|
+
tailConsumers?: CfTailConsumer[];
|
|
1317
|
+
streamingTailConsumers?: CfTailConsumer[];
|
|
1318
|
+
/**
|
|
1319
|
+
* Whether Wrangler should send usage metrics to Cloudflare for this project.
|
|
1320
|
+
*
|
|
1321
|
+
* When defined this will override any user settings.
|
|
1322
|
+
* Otherwise, Wrangler will use the user's preference.
|
|
1323
|
+
*/
|
|
1324
|
+
sendMetrics?: boolean;
|
|
1325
|
+
/** Options applying to the worker's build step. Applies to deploy and dev. */
|
|
1326
|
+
build?: {
|
|
1327
|
+
/** Whether the worker and its dependencies are bundled. Defaults to true. */
|
|
1328
|
+
bundle?: boolean;
|
|
1329
|
+
additionalModules?: CfModule[];
|
|
1330
|
+
findAdditionalModules?: boolean;
|
|
1331
|
+
processEntrypoint?: boolean;
|
|
1332
|
+
/** Specifies types of modules matched by globs. */
|
|
1333
|
+
moduleRules?: Rule[];
|
|
1334
|
+
/** Replace global identifiers with constant expressions, e.g. { debug: 'true', version: '"1.0.0"' }. Only takes effect if bundle: true. */
|
|
1335
|
+
define?: Record<string, string>;
|
|
1336
|
+
/** Alias modules */
|
|
1337
|
+
alias?: Record<string, string>;
|
|
1338
|
+
/** Whether the bundled worker is minified. Only takes effect if bundle: true. */
|
|
1339
|
+
minify?: boolean;
|
|
1340
|
+
/** Whether to keep function names after JavaScript transpilations. */
|
|
1341
|
+
keepNames?: boolean;
|
|
1342
|
+
/** Options controlling a custom build step. */
|
|
1343
|
+
custom?: {
|
|
1344
|
+
/** Custom shell command to run before bundling. Runs even if bundle. */
|
|
1345
|
+
command?: string;
|
|
1346
|
+
/** The cwd to run the command in. */
|
|
1347
|
+
workingDirectory?: string;
|
|
1348
|
+
/** Filepath(s) to watch for changes. Upon changes, the command will be rerun. */
|
|
1349
|
+
watch?: string | string[];
|
|
1350
|
+
};
|
|
1351
|
+
jsxFactory?: string;
|
|
1352
|
+
jsxFragment?: string;
|
|
1353
|
+
tsconfig?: string;
|
|
1354
|
+
nodejsCompatMode?: Hook<NodeJSCompatMode, [Config]>;
|
|
1355
|
+
moduleRoot?: string;
|
|
1356
|
+
};
|
|
1357
|
+
/** Options applying to the worker's development preview environment. */
|
|
1358
|
+
dev?: {
|
|
1359
|
+
/** Options applying to the worker's inspector server. False disables the inspector server. */
|
|
1360
|
+
inspector?: {
|
|
1361
|
+
hostname?: string;
|
|
1362
|
+
port?: number;
|
|
1363
|
+
secure?: boolean;
|
|
1364
|
+
} | false;
|
|
1365
|
+
/** Whether the worker runs on the edge or locally. */
|
|
1366
|
+
remote?: boolean | "minimal";
|
|
1367
|
+
/** Cloudflare Account credentials. Can be provided upfront or as a function which will be called only when required. */
|
|
1368
|
+
auth?: AsyncHook<CfAccount, [Pick<Config, "account_id">]>;
|
|
1369
|
+
/** Whether local storage (KV, Durable Objects, R2, D1, etc) is persisted. You can also specify the directory to persist data to. Set to `false` to disable persistence. */
|
|
1370
|
+
persist?: string | false;
|
|
1371
|
+
/** Controls which logs are logged. */
|
|
1372
|
+
logLevel?: LogLevel;
|
|
1373
|
+
/** Whether the worker server restarts upon source/config file changes. */
|
|
1374
|
+
watch?: boolean;
|
|
1375
|
+
/** Whether a script tag is inserted on text/html responses which will reload the page upon file changes. Defaults to false. */
|
|
1376
|
+
liveReload?: boolean;
|
|
1377
|
+
/** The local address to reach your worker. Applies to remote: true (remote mode) and remote: false (local mode). */
|
|
1378
|
+
server?: {
|
|
1379
|
+
hostname?: string;
|
|
1380
|
+
port?: number;
|
|
1381
|
+
secure?: boolean;
|
|
1382
|
+
httpsKeyPath?: string;
|
|
1383
|
+
httpsCertPath?: string;
|
|
1384
|
+
};
|
|
1385
|
+
/** Controls what request.url looks like inside the worker. */
|
|
1386
|
+
origin?: {
|
|
1387
|
+
hostname?: string;
|
|
1388
|
+
secure?: boolean;
|
|
1389
|
+
};
|
|
1390
|
+
/** A hook for outbound fetch calls from within the worker. */
|
|
1391
|
+
outboundService?: ServiceFetch;
|
|
1392
|
+
/** An undici MockAgent to declaratively mock fetch calls to particular resources. */
|
|
1393
|
+
mockFetch?: MockAgent;
|
|
1394
|
+
testScheduled?: boolean;
|
|
1395
|
+
/** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */
|
|
1396
|
+
multiworkerPrimary?: boolean;
|
|
1397
|
+
/** Whether to infer the local request origin from configured routes. */
|
|
1398
|
+
inferOriginFromRoutes?: boolean;
|
|
1399
|
+
/** Whether local requests should be matched against configured routes. */
|
|
1400
|
+
routeRequestsByRoutes?: boolean;
|
|
1401
|
+
containerBuildId?: string;
|
|
1402
|
+
/** Whether to build and connect to containers during local dev. Requires Docker daemon to be running. Defaults to true. */
|
|
1403
|
+
enableContainers?: boolean;
|
|
1404
|
+
/** Path to the dev registry directory */
|
|
1405
|
+
registry?: string;
|
|
1406
|
+
/** Path to the docker executable. Defaults to 'docker' */
|
|
1407
|
+
dockerPath?: string;
|
|
1408
|
+
/** Options for the container engine */
|
|
1409
|
+
containerEngine?: ContainerEngine;
|
|
1410
|
+
/** Re-generate your worker types when your Wrangler configuration file changes */
|
|
1411
|
+
generateTypes?: boolean;
|
|
1412
|
+
/**
|
|
1413
|
+
* Experimental: Use `cloudflare.config.ts` + optional `wrangler.config.ts`
|
|
1414
|
+
* instead of `wrangler.json[c]` / `wrangler.toml`.
|
|
1415
|
+
*/
|
|
1416
|
+
experimentalNewConfig?: boolean;
|
|
1417
|
+
/** Tunnel configuration for this dev session. */
|
|
1418
|
+
tunnel?: {
|
|
1419
|
+
enabled: boolean;
|
|
1420
|
+
name?: string;
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
legacy?: {
|
|
1424
|
+
site?: Hook<Config["site"], [Config]>;
|
|
1425
|
+
useServiceEnvironments?: boolean;
|
|
1426
|
+
};
|
|
1427
|
+
unsafe?: Omit<CfUnsafe, "bindings">;
|
|
1428
|
+
assets?: string;
|
|
1429
|
+
experimental?: Record<string, never>;
|
|
1430
|
+
}
|
|
907
1431
|
/**
|
|
908
1432
|
* An entry point for the Worker.
|
|
909
1433
|
*
|
|
@@ -2723,4 +3247,4 @@ interface EnvironmentMap {
|
|
|
2723
3247
|
}
|
|
2724
3248
|
declare const defaultWranglerConfig: Config;
|
|
2725
3249
|
|
|
2726
|
-
export { type
|
|
3250
|
+
export { type CfQueue as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectMigration as D, type Environment as E, type CfKvNamespace as F, type CfSendEmailBindings as G, type CfWasmModuleBindings as H, type CfTextBlobBindings as I, type CfBrowserBinding as J, type CfAIBinding as K, type Logger as L, type CfImagesBinding as M, type CfMediaBinding as N, type Observability as O, type PreviewsConfig as P, type CfStreamBinding as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfVersionMetadataBinding as V, type WorkerMetadataBinding as W, type CfDataBlobBindings as X, type CfDurableObject as Y, type ZoneIdRoute as Z, type CfWorkflow as _, type RedirectedRawConfig as a, COMPLIANCE_REGION_CONFIG_PUBLIC as a$, type CfR2Bucket as a0, type CfD1Database as a1, type CfVectorize as a2, type CfAISearchNamespace as a3, type CfAISearch as a4, type CfWebSearch as a5, type CfAgentMemory as a6, type CfSecretsStoreSecrets as a7, type CfArtifacts as a8, type CfHelloWorld as a9, type AssetsOptions as aA, type ValidatedAssetsOptions as aB, type LegacyAssetPaths as aC, type WorkerMetadata as aD, type ServiceMetadataRes as aE, type ServiceFetch as aF, type File as aG, type BinaryFile as aH, type Trigger as aI, type CfAccount as aJ, type HookValues as aK, type Hook as aL, type AsyncHook as aM, type LogLevel as aN, type NodeJSCompatMode as aO, type StartDevWorkerInput as aP, type Entry as aQ, INHERIT_SYMBOL as aR, SERVICE_TAG_PREFIX as aS, ENVIRONMENT_TAG_PREFIX as aT, PATH_TO_DEPLOY_CONFIG as aU, JSON_CONFIG_FORMATS as aV, getC3CommandFromEnv as aW, getWranglerSendMetricsFromEnv as aX, getWranglerSendErrorReportsFromEnv as aY, getCloudflareApiEnvironmentFromEnv as aZ, type ComplianceConfig as a_, type CfFlagship as aa, type CfWorkerLoader as ab, type CfRateLimit as ac, type CfHyperdrive as ad, type CfService as ae, type CfVpcService as af, type CfVpcNetwork as ag, type CfAnalyticsEngineDataset as ah, type CfDispatchNamespace as ai, type CfMTlsCertificate as aj, type CfLogfwdr as ak, type CfLogfwdrBinding as al, type CfAssetsBinding as am, type CfPipeline as an, type CfUnsafeBinding as ao, type CfCapnp as ap, type CfUnsafe as aq, type CfDurableObjectMigrations as ar, type CfPlacement as as, type CfTailConsumer as at, type CfUserLimits as au, type CfWorkerInit as av, type CfWorkerContext as aw, type CfWorkerSourceMap as ax, type Json as ay, type AssetConfigMetadata as az, type Config as b, COMPLIANCE_REGION_CONFIG_UNKNOWN as b0, getCloudflareComplianceRegion as b1, getCloudflareApiBaseUrl as b2, getComplianceRegionSubdomain as b3, getSanitizeLogs as b4, getOutputFileDirectoryFromEnv as b5, getOutputFilePathFromEnv as b6, getCIMatchTag as b7, getCIOverrideName as b8, getCIOverrideNetworkModeHost as b9, performApiFetchBase as bA, fetchInternalBase as bB, fetchResultBase as bC, fetchListResultBase as bD, truncate as bE, isWAFBlockResponse as bF, extractWAFBlockRayId as bG, extractAccountTag as bH, hasMorePages as bI, renderError as bJ, addAuthorizationHeader as bK, throwFetchError as bL, fetchKVGetValueBase as bM, type FetchKVGetValueFetcher as bN, hasCursor as bO, maybeAddTraceHeader as bP, getCIGeneratePreviewAlias as ba, getWorkersCIBranchName as bb, getBuildConditionsFromEnv as bc, getBuildPlatformFromEnv as bd, getRegistryPath as be, getD1ExtraLocationChoices as bf, getDockerPath as bg, getSubdomainMixedStateCheckDisabled as bh, getCloudflareLoadDevVarsFromDotEnv as bi, getCloudflareIncludeProcessEnvFromEnv as bj, getTraceHeader as bk, getDisableConfigWatching as bl, getWranglerHideBanner as bm, getCloudflareEnv as bn, getOpenNextDeployFromEnv as bo, getLocalExplorerEnabledFromEnv as bp, getBrowserRenderingHeadfulFromEnv as bq, getCfFetchEnabledFromEnv as br, getCfFetchPathFromEnv as bs, getWranglerCacheDirFromEnv as bt, getCloudflaredPathFromEnv as bu, type ApiCredentials as bv, type FetchResult as bw, type FetchResultFetcher as bx, type FetchListResultFetcher as by, type FetchPagedListResultFetcher as bz, type Route as c, type RawDevConfig as d, type ConfigFields as e, type RawEnvironment as f, defaultWranglerConfig as g, LOGGER_LEVELS as h, type LoggerLevel as i, type ZoneNameRoute as j, type CustomDomainRoute as k, type CloudchamberConfig as l, type ContainerApp as m, type DurableObjectBindings as n, type WorkflowBinding as o, type EnvironmentNonInheritable as p, type Rule as q, type ConfigModuleRuleType as r, type DispatchNamespaceOutbound as s, type CacheOptions as t, type DockerConfiguration as u, type ContainerEngine as v, type CfScriptFormat as w, type CfModuleType as x, type CfModule as y, type CfVars as z };
|