@nightintelligence/cloudflare-workers-utils 0.35.0-patch1
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 +5 -0
- package/dist/browser.d.mts +47 -0
- package/dist/browser.mjs +4 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/chunk-3D4BXUZX.mjs +54 -0
- package/dist/chunk-3D4BXUZX.mjs.map +1 -0
- package/dist/chunk-4RE36JUD.mjs +3160 -0
- package/dist/chunk-4RE36JUD.mjs.map +1 -0
- package/dist/chunk-6LYDFTTF.mjs +40 -0
- package/dist/chunk-6LYDFTTF.mjs.map +1 -0
- package/dist/chunk-CPLEE7LH.mjs +64 -0
- package/dist/chunk-CPLEE7LH.mjs.map +1 -0
- package/dist/chunk-G5FCNCLK.mjs +47 -0
- package/dist/chunk-G5FCNCLK.mjs.map +1 -0
- package/dist/chunk-IGC3TZGH.mjs +157 -0
- package/dist/chunk-IGC3TZGH.mjs.map +1 -0
- package/dist/chunk-NXPJWJ2B.mjs +180 -0
- package/dist/chunk-NXPJWJ2B.mjs.map +1 -0
- package/dist/chunk-OPAKTV2K.mjs +75 -0
- package/dist/chunk-OPAKTV2K.mjs.map +1 -0
- package/dist/chunk-VKFVZ67V.mjs +35 -0
- package/dist/chunk-VKFVZ67V.mjs.map +1 -0
- package/dist/chunk-W7DIL5J2.mjs +267 -0
- package/dist/chunk-W7DIL5J2.mjs.map +1 -0
- package/dist/chunk-ZLUHKBEC.mjs +44 -0
- package/dist/chunk-ZLUHKBEC.mjs.map +1 -0
- package/dist/chunk-ZQ2EZEOC.mjs +477 -0
- package/dist/chunk-ZQ2EZEOC.mjs.map +1 -0
- package/dist/compatibility-date.d.mts +80 -0
- package/dist/compatibility-date.mjs +4 -0
- package/dist/compatibility-date.mjs.map +1 -0
- package/dist/compliance-j3-tqeao.d.mts +3616 -0
- package/dist/compliance.d.mts +4 -0
- package/dist/compliance.mjs +9 -0
- package/dist/compliance.mjs.map +1 -0
- package/dist/docker-path.d.mts +8 -0
- package/dist/docker-path.mjs +5 -0
- package/dist/docker-path.mjs.map +1 -0
- package/dist/errors.d.mts +55 -0
- package/dist/errors.mjs +4 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/fs-helpers.d.mts +40 -0
- package/dist/fs-helpers.mjs +4 -0
- package/dist/fs-helpers.mjs.map +1 -0
- package/dist/global-wrangler-config-path.d.mts +35 -0
- package/dist/global-wrangler-config-path.mjs +5 -0
- package/dist/global-wrangler-config-path.mjs.map +1 -0
- package/dist/index.d.mts +1263 -0
- package/dist/index.mjs +26282 -0
- package/dist/index.mjs.map +1 -0
- package/dist/local-env.d.mts +54 -0
- package/dist/local-env.mjs +178 -0
- package/dist/local-env.mjs.map +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/open-OYMIZX6T.mjs +609 -0
- package/dist/open-OYMIZX6T.mjs.map +1 -0
- package/dist/prometheus-metrics.d.mts +50 -0
- package/dist/prometheus-metrics.mjs +4 -0
- package/dist/prometheus-metrics.mjs.map +1 -0
- package/dist/test-helpers/index.d.mts +46 -0
- package/dist/test-helpers/index.mjs +310 -0
- package/dist/test-helpers/index.mjs.map +1 -0
- package/dist/zod-format.d.mts +6 -0
- package/dist/zod-format.mjs +4 -0
- package/dist/zod-format.mjs.map +1 -0
- package/package.json +126 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, E as Exports, D as DurableObjectExport, W as WorkerEntrypointExport, c as ContainerApp, d as WorkerMetadataBinding, e as CfTailConsumer, L as Logger, f as Route } from './compliance-j3-tqeao.mjs';
|
|
2
|
+
export { A as ARTIFACTS_EVENT_TYPES, g as Access, h as ApiCredentials, i as ArtifactsEventTrigger, j as ArtifactsEventType, k as AssetConfigMetadata, l as Assets, m as AssetsOptions, n as AsyncHook, o as BinaryFile, p as COMPLIANCE_REGION_CONFIG_PUBLIC, q as COMPLIANCE_REGION_CONFIG_UNKNOWN, r as CacheOptions, s as CfAIBinding, t as CfAISearch, u as CfAISearchNamespace, v as CfAccount, w as CfAgentMemory, x as CfAnalyticsEngineDataset, y as CfArtifacts, z as CfAssetsBinding, F as CfBrowserBinding, G as CfCapnp, H as CfD1Database, I as CfDataBlobBindings, J as CfDevPluginCfg, K as CfDispatchNamespace, M as CfDurableObject, N as CfDurableObjectMigrations, O as CfExports, P as CfFlagship, Q as CfHelloWorld, S as CfHyperdrive, T as CfImagesBinding, U as CfKvNamespace, V as CfLogfwdr, X as CfLogfwdrBinding, Y as CfMTlsCertificate, Z as CfMediaBinding, _ as CfModule, $ as CfModuleType, a0 as CfPipeline, a1 as CfPlacement, a2 as CfQueue, a3 as CfR2Bucket, a4 as CfRateLimit, a5 as CfScriptFormat, a6 as CfSecretsStoreSecrets, a7 as CfSendEmailBindings, a8 as CfService, a9 as CfStreamBinding, aa as CfTextBlobBindings, ab as CfUnsafe, ac as CfUnsafeBinding, ad as CfUserLimits, ae as CfVars, af as CfVectorize, ag as CfVersionMetadataBinding, ah as CfVpcNetwork, ai as CfVpcService, aj as CfWasmModuleBindings, ak as CfWebSearch, al as CfWorkerContext, am as CfWorkerInit, an as CfWorkerLoader, ao as CfWorkerSourceMap, ap as CfWorkflow, aq as CloudchamberConfig, ar as ComplianceConfig, as as ConfigFields, at as ConfigModuleRuleType, au as ConfiguredExport, av as ContainerEngine, aw as CustomDomainRoute, ax as DispatchNamespaceOutbound, ay as DockerConfiguration, az as DurableObjectBindings, aA as DurableObjectExportStorage, aB as DurableObjectMigration, aC as ENVIRONMENT_TAG_PREFIX, aD as Entry, aE as Environment, aF as EnvironmentNonInheritable, aG as ExportsReconciliationEntryBase, aH as ExportsReconciliationErrorDetail, aI as ExportsReconciliationInfo, aJ as ExportsReconciliationRename, aK as ExportsReconciliationResult, aL as ExportsReconciliationTransfer, aM as ExportsReconciliationTransferPending, aN as ExportsReconciliationWarning, aO as FetchKVGetValueFetcher, aP as FetchListResultFetcher, aQ as FetchPagedListResultFetcher, aR as FetchResult, aS as FetchResultFetcher, aT as File, aU as Hook, aV as HookValues, aW as INHERIT_SYMBOL, aX as JSON_CONFIG_FORMATS, aY as Json, aZ as LOGGER_LEVELS, a_ as LegacyAssetPaths, a$ as LocalS3Credentials, b0 as LogLevel, b1 as LoggerLevel, b2 as NodeJSCompatMode, b3 as Observability, b4 as PATH_TO_DEPLOY_CONFIG, b5 as PreviewsConfig, b6 as RawDevConfig, b7 as RawEnvironment, a as RedirectedRawConfig, b8 as Rule, b9 as SERVICE_TAG_PREFIX, ba as ServiceFetch, bb as ServiceMetadataRes, bc as StartDevWorkerInput, bd as StreamingTailConsumer, be as TailConsumer, bf as Trigger, bg as UserLimits, bh as ValidatedAssetsOptions, bi as WorkerMetadata, bj as WorkflowBinding, bk as ZoneIdRoute, bl as ZoneNameRoute, bm as addAuthorizationHeader, bn as defaultWranglerConfig, bo as extractAccountTag, bp as extractWAFBlockRayId, bq as fetchInternalBase, br as fetchKVGetValueBase, bs as fetchListResultBase, bt as fetchResultBase, bu as getBrowserRenderingHeadfulFromEnv, bv as getBuildConditionsFromEnv, bw as getBuildPlatformFromEnv, bx as getC3CommandFromEnv, by as getCIGeneratePreviewAlias, bz as getCIMatchTag, bA as getCIOverrideName, bB as getCIOverrideNetworkModeHost, bC as getCfFetchEnabledFromEnv, bD as getCfFetchPathFromEnv, bE as getCloudflareApiBaseUrl, bF as getCloudflareApiEnvironmentFromEnv, bG as getCloudflareComplianceRegion, bH as getCloudflareEnv, bI as getCloudflareIncludeProcessEnvFromEnv, bJ as getCloudflareLoadDevVarsFromDotEnv, bK as getCloudflaredPathFromEnv, bL as getComplianceRegionSubdomain, bM as getD1ExtraLocationChoices, bN as getDisableConfigWatching, bO as getLocalExplorerEnabledFromEnv, bP as getLocalObservabilityEnabledFromEnv, bQ as getNoSkillsUpdatePromptsFromEnv, bR as getOpenNextDeployFromEnv, bS as getOutputFileDirectoryFromEnv, bT as getOutputFilePathFromEnv, bU as getRegistryPath, bV as getSanitizeLogs, bW as getSubdomainMixedStateCheckDisabled, bX as getTraceHeader, bY as getWorkersCIBranchName, bZ as getWranglerCacheDirFromEnv, b_ as getWranglerHideBanner, b$ as getWranglerSendErrorReportsFromEnv, c0 as getWranglerSendMetricsFromEnv, c1 as hasCursor, c2 as hasMorePages, c3 as isDoNotTrackEnabled, c4 as isWAFBlockResponse, c5 as maybeAddTraceHeader, c6 as parseRetryAfterMs, c7 as parseRetryAfterValue, c8 as performApiFetchBase, c9 as renderError, ca as throwFetchError, cb as truncate } from './compliance-j3-tqeao.mjs';
|
|
3
|
+
import * as jsoncParser from 'jsonc-parser';
|
|
4
|
+
import { UserError, TelemetryMessage } from './errors.mjs';
|
|
5
|
+
export { CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, createFatalError } from './errors.mjs';
|
|
6
|
+
export { constructWranglerConfig } from './browser.mjs';
|
|
7
|
+
export { GetGlobalConfigPathOptions, getGlobalConfigPath, getGlobalWranglerCachePath } from './global-wrangler-config-path.mjs';
|
|
8
|
+
import { CompatDate } from './compatibility-date.mjs';
|
|
9
|
+
export { NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, getTodaysCompatDate, isCompatDate, isNodejsCompatDefaultOn, resolveNodejsCompat, stripRedundantNodejsCompatFlags } from './compatibility-date.mjs';
|
|
10
|
+
export { isDirectory, removeDir, removeDirSync } from './fs-helpers.mjs';
|
|
11
|
+
export { Counter, MetricsRegistry } from './prometheus-metrics.mjs';
|
|
12
|
+
import { ChildProcess } from 'node:child_process';
|
|
13
|
+
export { _forceColour, formatZodError } from './zod-format.mjs';
|
|
14
|
+
export { getDockerPath } from './docker-path.mjs';
|
|
15
|
+
import 'node:url';
|
|
16
|
+
import 'undici';
|
|
17
|
+
import '@cloudflare/workers-shared';
|
|
18
|
+
import 'cloudflare';
|
|
19
|
+
import 'zod';
|
|
20
|
+
|
|
21
|
+
type ResolveConfigPathOptions = {
|
|
22
|
+
useRedirectIfAvailable?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type ConfigPaths = {
|
|
25
|
+
/** Absolute path to the actual configuration being used (possibly redirected from the user's config). */
|
|
26
|
+
configPath: string | undefined;
|
|
27
|
+
/** Absolute path to the user's configuration, which may not be the same as `configPath` if it was redirected. */
|
|
28
|
+
userConfigPath: string | undefined;
|
|
29
|
+
/** Absolute path to the deploy config path used */
|
|
30
|
+
deployConfigPath: string | undefined;
|
|
31
|
+
/** Was a redirected config file read? */
|
|
32
|
+
redirected: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the path to the configuration file, given the `config` and `script` optional command line arguments.
|
|
36
|
+
* `config` takes precedence, then `script`, then we just use the cwd.
|
|
37
|
+
*
|
|
38
|
+
* Returns an object with two paths: `configPath` and `userConfigPath`. If defined these are absolute file paths.
|
|
39
|
+
*/
|
|
40
|
+
declare function resolveWranglerConfigPath({ config, script, }: {
|
|
41
|
+
config?: string;
|
|
42
|
+
script?: string;
|
|
43
|
+
}, options: {
|
|
44
|
+
useRedirectIfAvailable?: boolean;
|
|
45
|
+
}): ConfigPaths;
|
|
46
|
+
/**
|
|
47
|
+
* Find the wrangler configuration file by searching up the file-system
|
|
48
|
+
* from the current working directory.
|
|
49
|
+
*/
|
|
50
|
+
declare function findWranglerConfig(referencePath?: string, { useRedirectIfAvailable }?: {
|
|
51
|
+
useRedirectIfAvailable?: boolean | undefined;
|
|
52
|
+
}): ConfigPaths;
|
|
53
|
+
declare function isRedirectedConfig(config: Pick<ComputedFields, "configPath" | "userConfigPath">): boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Diagnostic errors and warnings.
|
|
57
|
+
*
|
|
58
|
+
* The structure is a tree, where each node can contain zero or more errors, warnings and child diagnostics objects.
|
|
59
|
+
* You can check whether the overall tree has errors or warnings, and you can render a string representation of the errors or warnings.
|
|
60
|
+
*/
|
|
61
|
+
declare class Diagnostics {
|
|
62
|
+
description: string;
|
|
63
|
+
errors: string[];
|
|
64
|
+
warnings: string[];
|
|
65
|
+
children: Diagnostics[];
|
|
66
|
+
/** Set to true when an unexpected/unknown field is encountered during validation. */
|
|
67
|
+
hasUnexpectedFields: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new Diagnostics object.
|
|
70
|
+
* @param description A general description of this collection of messages.
|
|
71
|
+
*/
|
|
72
|
+
constructor(description: string);
|
|
73
|
+
/**
|
|
74
|
+
* Merge the given `diagnostics` into this as a child.
|
|
75
|
+
*/
|
|
76
|
+
addChild(diagnostics: Diagnostics): void;
|
|
77
|
+
/** Does this or any of its children have errors. */
|
|
78
|
+
hasErrors(): boolean;
|
|
79
|
+
/** Does this or any of its children have unexpected fields. */
|
|
80
|
+
hasUnexpectedFieldsInTree(): boolean;
|
|
81
|
+
/** Render the errors of this and all its children. */
|
|
82
|
+
renderErrors(): string;
|
|
83
|
+
/** Does this or any of its children have warnings. */
|
|
84
|
+
hasWarnings(): boolean;
|
|
85
|
+
/** Render the warnings of this and all its children. */
|
|
86
|
+
renderWarnings(): string;
|
|
87
|
+
private render;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* R2 bucket names must:
|
|
92
|
+
* - contain lower case letters, numbers, and `-`
|
|
93
|
+
* - start and end with with a lower case letter or number
|
|
94
|
+
* - be between 6 and 63 characters long
|
|
95
|
+
*
|
|
96
|
+
* See https://developers.cloudflare.com/r2/buckets/create-buckets/#bucket-level-operations
|
|
97
|
+
*/
|
|
98
|
+
declare function isValidR2BucketName(name: string | undefined): name is string;
|
|
99
|
+
declare const bucketFormatMessage = "Bucket names must begin and end with an alphanumeric character, only contain lowercase letters, numbers, and hyphens, and be between 3 and 63 characters long.";
|
|
100
|
+
/**
|
|
101
|
+
* Config field names for bindings (e.g., "kv_namespaces", "d1_databases").
|
|
102
|
+
* These are the keys used in Wrangler's config file
|
|
103
|
+
*/
|
|
104
|
+
type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "websearch" | "agent_memory" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "stream" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "artifacts" | "ratelimits" | "assets" | "unsafe_hello_world" | "flagship" | "worker_loaders" | "vpc_services" | "vpc_networks";
|
|
105
|
+
/**
|
|
106
|
+
* Get a friendly name for a binding type, handling unsafe bindings
|
|
107
|
+
*/
|
|
108
|
+
declare function getBindingTypeFriendlyName(bindingType: Binding["type"]): string;
|
|
109
|
+
type NormalizeAndValidateConfigArgs = {
|
|
110
|
+
name?: string;
|
|
111
|
+
env?: string;
|
|
112
|
+
"dispatch-namespace"?: string;
|
|
113
|
+
remote?: boolean;
|
|
114
|
+
localProtocol?: string;
|
|
115
|
+
upstreamProtocol?: string;
|
|
116
|
+
script?: string;
|
|
117
|
+
enableContainers?: boolean;
|
|
118
|
+
generateTypes?: boolean;
|
|
119
|
+
};
|
|
120
|
+
declare function isPagesConfig(rawConfig: RawConfig): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Validate the given `rawConfig` object that was loaded from `configPath`.
|
|
123
|
+
*
|
|
124
|
+
* The configuration is normalized, which includes using default values for missing field,
|
|
125
|
+
* and copying over inheritable fields into named environments.
|
|
126
|
+
*
|
|
127
|
+
* Any errors or warnings from the validation are available in the returned `diagnostics` object.
|
|
128
|
+
*
|
|
129
|
+
* @param rawConfig The config loaded from `configPath`
|
|
130
|
+
* @param configPath The path to the config file
|
|
131
|
+
* @param userConfigPath
|
|
132
|
+
* @param args
|
|
133
|
+
* @param preserveOriginalMain
|
|
134
|
+
* @returns The normalized `config` and `diagnostics` message
|
|
135
|
+
*/
|
|
136
|
+
declare function normalizeAndValidateConfig(rawConfig: RawConfig, configPath: string | undefined, userConfigPath: string | undefined, args: NormalizeAndValidateConfigArgs, preserveOriginalMain?: boolean): {
|
|
137
|
+
config: Config;
|
|
138
|
+
diagnostics: Diagnostics;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Returns whether the provided `imagePath` is a path to a Dockerfile.
|
|
142
|
+
*
|
|
143
|
+
* @param imagePath path to Dockerfile or image registry path
|
|
144
|
+
* @param configPath path to the wrangler config file, if any
|
|
145
|
+
* @returns `true` if it is a dockerfile, `false` if it is a registry link, throws if neither
|
|
146
|
+
*/
|
|
147
|
+
declare function isDockerfile(imagePath: string, configPath: string | undefined): boolean;
|
|
148
|
+
|
|
149
|
+
type ExportType = Exports[string]["type"];
|
|
150
|
+
interface PartitionedExports {
|
|
151
|
+
"durable-object": Record<string, DurableObjectExport>;
|
|
152
|
+
worker: Record<string, WorkerEntrypointExport>;
|
|
153
|
+
}
|
|
154
|
+
declare function partitionExports(exports: Exports | undefined): PartitionedExports;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A container can be linked to a Durable Object from either direction:
|
|
158
|
+
*
|
|
159
|
+
* - the container names the class via `containers[].class_name`, or
|
|
160
|
+
* - the Durable Object names the container via `exports[Class].container`.
|
|
161
|
+
*
|
|
162
|
+
* This returns the second direction as a lookup of container name to Durable
|
|
163
|
+
* Object class name. Only live `durable-object` exports can attach a container,
|
|
164
|
+
* so tombstones are ignored.
|
|
165
|
+
*
|
|
166
|
+
* When two exports name the same container the first wins. That is a config
|
|
167
|
+
* error caught during validation, so the choice only affects which class a
|
|
168
|
+
* rejected config reports.
|
|
169
|
+
*/
|
|
170
|
+
declare function getContainerNameToClassNameMap(exports: Exports | undefined): Map<string, string>;
|
|
171
|
+
/**
|
|
172
|
+
* The Durable Object class a container backs, resolved from either direction of
|
|
173
|
+
* the container/Durable Object link.
|
|
174
|
+
*
|
|
175
|
+
* Returns `undefined` when the container is not linked to a Durable Object at
|
|
176
|
+
* all, which validation rejects.
|
|
177
|
+
*/
|
|
178
|
+
declare function resolveContainerClassName(container: Pick<ContainerApp, "class_name" | "name">, exports: Exports | undefined): string | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* The set of Durable Object class names that have a container attached, resolved
|
|
181
|
+
* from either direction of the container/Durable Object link.
|
|
182
|
+
*/
|
|
183
|
+
declare function getContainerDurableObjectClassNames(containers: ContainerApp[] | undefined, exports: Exports | undefined): Set<string>;
|
|
184
|
+
|
|
185
|
+
type ConfigBindingOptions = Pick<Config, "ai" | "browser" | "d1_databases" | "dispatch_namespaces" | "durable_objects" | "queues" | "r2_buckets" | "services" | "kv_namespaces" | "mtls_certificates" | "vectorize" | "workflows" | "vpc_services">;
|
|
186
|
+
|
|
187
|
+
declare function configFormat(configPath: string | undefined): "json" | "jsonc" | "toml" | "none";
|
|
188
|
+
declare function configFileName(configPath: string | undefined): "wrangler.json" | "wrangler.jsonc" | "wrangler.toml" | "Wrangler configuration";
|
|
189
|
+
declare function formatConfigSnippet(snippet: RawConfig, configPath: Config["configPath"], formatted?: boolean): string;
|
|
190
|
+
type ReadConfigCommandArgs = NormalizeAndValidateConfigArgs & {
|
|
191
|
+
config?: string;
|
|
192
|
+
script?: string;
|
|
193
|
+
};
|
|
194
|
+
type ReadConfigOptions = ResolveConfigPathOptions & {
|
|
195
|
+
hideWarnings?: boolean;
|
|
196
|
+
preserveOriginalMain?: boolean;
|
|
197
|
+
};
|
|
198
|
+
declare const experimental_readRawConfig: (args: ReadConfigCommandArgs, options?: ReadConfigOptions) => {
|
|
199
|
+
rawConfig: RawConfig;
|
|
200
|
+
configPath: string | undefined;
|
|
201
|
+
userConfigPath: string | undefined;
|
|
202
|
+
deployConfigPath: string | undefined;
|
|
203
|
+
redirected: boolean;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Returns a map of exports that are only of type "durable-object".
|
|
208
|
+
*/
|
|
209
|
+
declare function getDurableObjectExports(exports: Config["exports"] | undefined): Record<string, DurableObjectExport>;
|
|
210
|
+
declare function hasDurableObjectExports(exports: Config["exports"] | undefined): boolean;
|
|
211
|
+
|
|
212
|
+
declare const experimental_patchConfig: (configPath: string,
|
|
213
|
+
/**
|
|
214
|
+
* if you want to add something new, e.g. a binding, you can just provide that {kv_namespace:[{binding:"KV"}]}
|
|
215
|
+
* and set isArrayInsertion = true
|
|
216
|
+
*
|
|
217
|
+
* if you want to edit or delete existing array elements, you have to provide the whole array
|
|
218
|
+
* e.g. {kv_namespace:[{binding:"KV", id:"new-id"}, {binding:"KV2", id:"untouched"}]}
|
|
219
|
+
* and set isArrayInsertion = false
|
|
220
|
+
*/
|
|
221
|
+
patch: RawConfig, isArrayInsertion?: boolean) => string;
|
|
222
|
+
/**
|
|
223
|
+
* Custom error class for config patching errors
|
|
224
|
+
*/
|
|
225
|
+
declare class PatchConfigError extends Error {
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type Message = {
|
|
229
|
+
text: string;
|
|
230
|
+
location?: Location;
|
|
231
|
+
notes?: Message[];
|
|
232
|
+
kind?: "warning" | "error";
|
|
233
|
+
};
|
|
234
|
+
type MessageInit = Message & TelemetryMessage;
|
|
235
|
+
type Location = ParseFile & {
|
|
236
|
+
line: number;
|
|
237
|
+
column: number;
|
|
238
|
+
length?: number;
|
|
239
|
+
lineText?: string;
|
|
240
|
+
suggestion?: string;
|
|
241
|
+
};
|
|
242
|
+
type ParseFile = {
|
|
243
|
+
file?: string;
|
|
244
|
+
fileText?: string;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* An error that's thrown when something fails to parse.
|
|
248
|
+
*/
|
|
249
|
+
declare class ParseError extends UserError implements Message {
|
|
250
|
+
readonly text: string;
|
|
251
|
+
readonly notes: Message[];
|
|
252
|
+
readonly location?: Location;
|
|
253
|
+
readonly kind: "warning" | "error";
|
|
254
|
+
constructor({ text, notes, location, kind, telemetryMessage }: MessageInit);
|
|
255
|
+
}
|
|
256
|
+
declare class APIError extends ParseError {
|
|
257
|
+
#private;
|
|
258
|
+
code?: number;
|
|
259
|
+
accountTag?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Optional structured metadata hoisted from the first `FetchError.meta`
|
|
262
|
+
* on the v4 response envelope. Consumers can inspect this to render
|
|
263
|
+
* endpoint-specific structured error payloads.
|
|
264
|
+
*/
|
|
265
|
+
meta?: {
|
|
266
|
+
details?: unknown;
|
|
267
|
+
} & Record<string, unknown>;
|
|
268
|
+
/**
|
|
269
|
+
* Optional number of milliseconds the API asked us to wait before retrying,
|
|
270
|
+
* derived from the response's `Retry-After` header (if present).
|
|
271
|
+
*/
|
|
272
|
+
retryAfterMs?: number;
|
|
273
|
+
constructor({ status, retryAfterMs, ...rest }: MessageInit & {
|
|
274
|
+
status?: number;
|
|
275
|
+
retryAfterMs?: number;
|
|
276
|
+
});
|
|
277
|
+
get status(): number | undefined;
|
|
278
|
+
isGatewayError(): boolean;
|
|
279
|
+
isRetryable(): boolean;
|
|
280
|
+
get reportable(): boolean;
|
|
281
|
+
preventReport(): void;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Parses a TOML string to an object.
|
|
285
|
+
*
|
|
286
|
+
* Note: throws a `ParseError` if parsing fails.
|
|
287
|
+
*
|
|
288
|
+
* @param tomlContent The TOML content to parse.
|
|
289
|
+
* @param filePath Optional file path for error reporting.
|
|
290
|
+
* @returns The parsed TOML object.
|
|
291
|
+
*/
|
|
292
|
+
declare function parseTOML(tomlContent: string, filePath?: string): unknown;
|
|
293
|
+
/**
|
|
294
|
+
* A minimal type describing a package.json file.
|
|
295
|
+
*/
|
|
296
|
+
type PackageJSON = {
|
|
297
|
+
name?: string;
|
|
298
|
+
version?: string;
|
|
299
|
+
private?: boolean;
|
|
300
|
+
devDependencies?: Record<string, unknown>;
|
|
301
|
+
dependencies?: Record<string, unknown>;
|
|
302
|
+
scripts?: Record<string, unknown>;
|
|
303
|
+
/**
|
|
304
|
+
* NOTE: This is **not** a standard `package.json` field — don't confuse it
|
|
305
|
+
* with the standard `bundledDependencies`. It is a convention introduced by
|
|
306
|
+
* vite+ (https://viteplus.dev): vite+ installs `@voidzero-dev/vite-plus-core`
|
|
307
|
+
* under the `vite` npm alias and records the versions of the tools it bundles
|
|
308
|
+
* here, keyed by package name
|
|
309
|
+
* (e.g. `{ "vite": "8.1.2", "rolldown": "...", "tsdown": "..." }`).
|
|
310
|
+
*
|
|
311
|
+
* We read it to recover the underlying Vite version when Vite is installed via
|
|
312
|
+
* such an alias. It is optional and absent for the vast majority of packages.
|
|
313
|
+
*/
|
|
314
|
+
bundledVersions?: Record<string, string | undefined>;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* A typed version of `parseJSON()`.
|
|
318
|
+
*/
|
|
319
|
+
declare function parsePackageJSON(input: string, file?: string): PackageJSON;
|
|
320
|
+
/**
|
|
321
|
+
* Parses JSON and throws a `ParseError`.
|
|
322
|
+
*/
|
|
323
|
+
declare function parseJSON(input: string, file?: string): unknown;
|
|
324
|
+
/**
|
|
325
|
+
* A wrapper around `JSONC.parse` that throws a `ParseError`.
|
|
326
|
+
*/
|
|
327
|
+
declare function parseJSONC(input: string, file?: string, options?: jsoncParser.ParseOptions): unknown;
|
|
328
|
+
/**
|
|
329
|
+
* Reads a file into a node Buffer.
|
|
330
|
+
*/
|
|
331
|
+
declare function readFileSyncToBuffer(file: string): Buffer;
|
|
332
|
+
/**
|
|
333
|
+
* Reads a file and parses it based on its type.
|
|
334
|
+
*/
|
|
335
|
+
declare function readFileSync(file: string): string;
|
|
336
|
+
/**
|
|
337
|
+
* Calculates the line and column location from an index.
|
|
338
|
+
*/
|
|
339
|
+
declare function indexLocation(file: ParseFile, index: number): Location;
|
|
340
|
+
/**
|
|
341
|
+
* Guesses the line and column location of a search query.
|
|
342
|
+
*/
|
|
343
|
+
declare function searchLocation(file: ParseFile, query: unknown): Location;
|
|
344
|
+
/**
|
|
345
|
+
* Parse a human-readable time duration in seconds (including fractional)
|
|
346
|
+
*
|
|
347
|
+
* Invalid values will return NaN
|
|
348
|
+
*/
|
|
349
|
+
declare function parseHumanDuration(s: string): number;
|
|
350
|
+
declare function parseNonHyphenedUuid(uuid: string | null): string | null;
|
|
351
|
+
declare function parseByteSize(s: string, base?: number | undefined): number;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Local-dev capability of each binding type. Source of truth for
|
|
355
|
+
* `pickRemoteBindings()` and `validateBindingRemoteSetting()`.
|
|
356
|
+
*
|
|
357
|
+
* - `local-and-remote`: local simulator; `remote: true` opts into proxying.
|
|
358
|
+
* - `local-only`: local simulator only; `remote: true` is a config error.
|
|
359
|
+
* - `remote`: no local simulator *yet* — requires explicit `remote: true`.
|
|
360
|
+
* Move to `local-and-remote` once a simulator lands.
|
|
361
|
+
* - `DO-NOT-USE-this-resource-will-never-have-a-local-simulator`: no local
|
|
362
|
+
* simulator, *ever* — fundamentally remote-only. Always auto-routed; user
|
|
363
|
+
* is warned about usage charges. Adding here is permanent; prefer any
|
|
364
|
+
* other variant if a simulator is plausible.
|
|
365
|
+
*/
|
|
366
|
+
type BindingLocalSupport = "local-and-remote" | "local-only" | "remote" | "DO-NOT-USE-this-resource-will-never-have-a-local-simulator";
|
|
367
|
+
declare function getBindingLocalSupport(type: Binding["type"]): BindingLocalSupport;
|
|
368
|
+
/**
|
|
369
|
+
* Validates the user's `remote` setting for a given binding against the
|
|
370
|
+
* binding type's local-development capabilities. Throws `UserError` for
|
|
371
|
+
* invalid combinations and uses the caller-provided logger for
|
|
372
|
+
* valid-but-noteworthy ones.
|
|
373
|
+
*/
|
|
374
|
+
declare function validateBindingRemoteSetting(type: Binding["type"], remote: boolean | undefined, warn: (message: string) => void): void;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Pages now supports configuration via a Wrangler configuration file. As opposed to
|
|
378
|
+
* Workers however, Pages only supports a limited subset of all available
|
|
379
|
+
* configuration keys.
|
|
380
|
+
*
|
|
381
|
+
* This file contains all Wrangler configuration file validation things, specific to
|
|
382
|
+
* Pages.
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
declare function validatePagesConfig(config: Config, envNames: string[], projectName?: string): Diagnostics;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Returns whether `target` has the required property `property` of type `type`.
|
|
389
|
+
*
|
|
390
|
+
* @param target the object to test.
|
|
391
|
+
* @param property the property name to test.
|
|
392
|
+
* @param type the expected type of the property.
|
|
393
|
+
* @param choices optional list of allowed values for the property.
|
|
394
|
+
* @returns whether `target` has the required property `property` of type `type`, and optionally one of `choices`.
|
|
395
|
+
*/
|
|
396
|
+
declare const isRequiredProperty: <T extends object>(target: object, property: keyof T, type: TypeofType, choices?: unknown[]) => target is T;
|
|
397
|
+
/**
|
|
398
|
+
* Returns whether `target` has the optional property `property` of type `type`.
|
|
399
|
+
*
|
|
400
|
+
* @param target the object to test.
|
|
401
|
+
* @param property the property name to test.
|
|
402
|
+
* @param type the expected type of the property.
|
|
403
|
+
* @returns whether `target` has the optional property `property` of type `type`.
|
|
404
|
+
*/
|
|
405
|
+
declare const isOptionalProperty: <T extends object>(target: object, property: keyof T, type: TypeofType) => target is T;
|
|
406
|
+
/**
|
|
407
|
+
* Returns whether `target` has the property `property`.
|
|
408
|
+
*
|
|
409
|
+
* @param target the object to test.
|
|
410
|
+
* @param property the property name to test.
|
|
411
|
+
* @returns whether `target` has the property `property`.
|
|
412
|
+
*/
|
|
413
|
+
declare const hasProperty: <T extends object>(target: object, property: keyof T) => target is T;
|
|
414
|
+
/**
|
|
415
|
+
* JavaScript `typeof` operator return values.
|
|
416
|
+
*/
|
|
417
|
+
type TypeofType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
418
|
+
|
|
419
|
+
declare function assertNever(_value: never): void;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Resolves the filesystem path for an installed npm package.
|
|
423
|
+
*
|
|
424
|
+
* Tries three strategies in order:
|
|
425
|
+
* 1. `require.resolve("<pkg>/package.json")` — works when the package exports its `package.json`
|
|
426
|
+
* 2. `require.resolve("<pkg>")` — fallback for packages that don't export `package.json`
|
|
427
|
+
* 3. Direct `node_modules` filesystem lookup — fallback for ESM-only packages whose exports
|
|
428
|
+
* map has no `"require"` or `"default"` condition (and no `"./package.json"` export),
|
|
429
|
+
* which makes them invisible to `require.resolve`
|
|
430
|
+
*
|
|
431
|
+
* @param packageName - The npm package name to resolve (supports scoped packages like `@scope/pkg`)
|
|
432
|
+
* @param projectPath - The project directory to resolve from
|
|
433
|
+
* @returns The resolved directory path, or `undefined` if the package is not installed
|
|
434
|
+
*/
|
|
435
|
+
declare function getPackagePath(packageName: string, projectPath: string): string | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Checks whether an npm package is installed in a target project.
|
|
438
|
+
*
|
|
439
|
+
* @param packageName - The name of the target package
|
|
440
|
+
* @param projectPath - The path of the project to check
|
|
441
|
+
* @returns `true` if the package is installed, `false` otherwise
|
|
442
|
+
*/
|
|
443
|
+
declare function isPackageInstalled(packageName: string, projectPath: string): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Gets the exact version of an npm package installed in a project by resolving
|
|
446
|
+
* it from node_modules and reading its package.json.
|
|
447
|
+
*
|
|
448
|
+
* @param packageName - The name of the target package
|
|
449
|
+
* @param projectPath - The path of the project to check
|
|
450
|
+
* @param opts - Options
|
|
451
|
+
* @param opts.stopAtProjectPath - If `true`, stop walking up at the project's path
|
|
452
|
+
* @returns The installed version string, or `undefined` if the package is not installed
|
|
453
|
+
*/
|
|
454
|
+
declare function getInstalledPackageVersion(packageName: string, projectPath: string, opts?: {
|
|
455
|
+
stopAtProjectPath?: boolean;
|
|
456
|
+
}): string | undefined;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Maps a set of bindings defined as worker metadata bindings (straight from the Cloudflare API) to bindings defined in the local format.
|
|
460
|
+
*
|
|
461
|
+
* @param bindings The set of worker metadata bindings to convert
|
|
462
|
+
* @param accountId The ID of the account
|
|
463
|
+
* @param complianceConfig The compliance region configuration
|
|
464
|
+
* @returns A RawConfig object with its bindings populated based on the provided bindings
|
|
465
|
+
*/
|
|
466
|
+
declare function mapWorkerMetadataBindings(bindings: WorkerMetadataBinding[]): RawConfig;
|
|
467
|
+
|
|
468
|
+
interface ConvertBindingsOptions {
|
|
469
|
+
/**
|
|
470
|
+
* Use preview IDs (preview_id, preview_bucket_name, preview_database_id) instead of production IDs when resolving a binding ID.
|
|
471
|
+
* This means that the rest of Wrangler does not need to be aware of preview IDs, and can just use regular IDs.
|
|
472
|
+
*/
|
|
473
|
+
usePreviewIds?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* Exclude bindings that Pages doesn't support
|
|
476
|
+
*/
|
|
477
|
+
pages?: boolean;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Convert Config to the Record<string, Binding> format for consistent internal use.
|
|
481
|
+
*/
|
|
482
|
+
declare function convertConfigToBindings(config: Partial<Pick<Config, ConfigBindingFieldName>>, options?: ConvertBindingsOptions): Record<string, Binding>;
|
|
483
|
+
declare function isUnsafeBindingType(type: string): type is `unsafe_${string}`;
|
|
484
|
+
/**
|
|
485
|
+
* What configuration key does this binding use for referring to it's binding name?
|
|
486
|
+
*/
|
|
487
|
+
declare const nameBindings: readonly ["durable_object_namespace", "logfwdr", "ratelimit", "unsafe_ratelimit", "send_email"];
|
|
488
|
+
type FlatBinding<Type> = Extract<Binding, {
|
|
489
|
+
type: Type;
|
|
490
|
+
}> & (Type extends (typeof nameBindings)[number] ? {
|
|
491
|
+
name: string;
|
|
492
|
+
} : {
|
|
493
|
+
binding: string;
|
|
494
|
+
});
|
|
495
|
+
declare function extractBindingsOfType<Type extends Binding["type"]>(type: Type, bindings: Record<string, Binding> | undefined): FlatBinding<Type>[];
|
|
496
|
+
/**
|
|
497
|
+
* Get bindings from a Config object in the standard Record<string, Binding> format.
|
|
498
|
+
*/
|
|
499
|
+
declare function getBindings(config: Config | undefined, options?: {
|
|
500
|
+
pages?: boolean;
|
|
501
|
+
}): Record<string, Binding>;
|
|
502
|
+
|
|
503
|
+
type PrintBindingsOptions = {
|
|
504
|
+
log: (message: string) => void;
|
|
505
|
+
tailConsumers?: CfTailConsumer[];
|
|
506
|
+
streamingTailConsumers?: CfTailConsumer[];
|
|
507
|
+
containers?: ContainerApp[];
|
|
508
|
+
registry?: Record<string, {
|
|
509
|
+
debugPortAddress?: string;
|
|
510
|
+
}> | null;
|
|
511
|
+
local?: boolean;
|
|
512
|
+
isMultiWorker?: boolean;
|
|
513
|
+
remoteBindingsDisabled?: boolean;
|
|
514
|
+
name?: string;
|
|
515
|
+
provisioning?: boolean;
|
|
516
|
+
warnIfNoBindings?: boolean;
|
|
517
|
+
unsafeMetadata?: Record<string, unknown>;
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* Print all the bindings a worker would have access to.
|
|
521
|
+
* Accepts the flat binding record used by StartDevWorkerInput["bindings"].
|
|
522
|
+
*/
|
|
523
|
+
declare function printBindings(bindings: Record<string, Binding> | undefined, options: PrintBindingsOptions): void;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Environment variables supported by Wrangler for configuration and authentication.
|
|
527
|
+
* Each variable is documented with its individual JSDoc comment below.
|
|
528
|
+
*/
|
|
529
|
+
type VariableNames =
|
|
530
|
+
/** Overrides the account ID for API requests. Can also be set in Wrangler config via `account_id` field. */
|
|
531
|
+
"CLOUDFLARE_ACCOUNT_ID"
|
|
532
|
+
/** API token for authentication. Preferred over API key + email. */
|
|
533
|
+
| "CLOUDFLARE_API_TOKEN"
|
|
534
|
+
/** Legacy API key for authentication. Requires CLOUDFLARE_EMAIL. It is preferred to use `CLOUDFLARE_API_TOKEN`. */
|
|
535
|
+
| "CLOUDFLARE_API_KEY"
|
|
536
|
+
/** Email address for API key authentication. Used with `CLOUDFLARE_API_KEY`. It is preferred to use `CLOUDFLARE_API_TOKEN`. */
|
|
537
|
+
| "CLOUDFLARE_EMAIL"
|
|
538
|
+
/** Custom API base URL. Defaults to https://api.cloudflare.com/client/v4 */
|
|
539
|
+
| "CLOUDFLARE_API_BASE_URL"
|
|
540
|
+
/** Set to "fedramp_high" for FedRAMP High compliance region. This will update the API/AUTH URLs used to make requests to Cloudflare. */
|
|
541
|
+
| "CLOUDFLARE_COMPLIANCE_REGION"
|
|
542
|
+
/** API token for R2 SQL service. */
|
|
543
|
+
| "WRANGLER_R2_SQL_AUTH_TOKEN"
|
|
544
|
+
/** Controls whether to fetch the cf.json file. Set to "false" or "0" to disable fetching and use fallback data. Defaults to "true". */
|
|
545
|
+
| "CLOUDFLARE_CF_FETCH_ENABLED"
|
|
546
|
+
/** Custom path for caching the cf.json file. Overrides the default node_modules/.mf/cf.json location. */
|
|
547
|
+
| "CLOUDFLARE_CF_FETCH_PATH"
|
|
548
|
+
/** Local database connection strings for Hyperdrive development. The * should be replaced with the Hyperdrive binding name in the Worker. */
|
|
549
|
+
| `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_${string}`
|
|
550
|
+
/** Suppress Hyperdrive-related warnings during development. */
|
|
551
|
+
| "NO_HYPERDRIVE_WARNING"
|
|
552
|
+
/** Path to HTTPS private key file for running the local development server in HTTPS mode. Without this Wrangler will generate keys automatically. */
|
|
553
|
+
| "WRANGLER_HTTPS_KEY_PATH"
|
|
554
|
+
/** Path to HTTPS certificate file for running the local development server in HTTPS mode. Without this Wrangler will generate keys automatically. */
|
|
555
|
+
| "WRANGLER_HTTPS_CERT_PATH"
|
|
556
|
+
/** Load development variables from .env files (default: true). */
|
|
557
|
+
| "CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV"
|
|
558
|
+
/** Include process.env in development variables (default: false). */
|
|
559
|
+
| "CLOUDFLARE_INCLUDE_PROCESS_ENV"
|
|
560
|
+
/** Include a trace header in all API requests that Wrangler makes (for internal use only) */
|
|
561
|
+
| "WRANGLER_TRACE_ID"
|
|
562
|
+
/** Disable the check for mixed state of subdomain flags (`workers_dev`, `preview_urls`, etc.) (default: false). */
|
|
563
|
+
| "WRANGLER_DISABLE_SUBDOMAIN_MIXED_STATE_CHECK"
|
|
564
|
+
/** Set log level: "debug", "info", "log", "warn", "error". */
|
|
565
|
+
| "WRANGLER_LOG"
|
|
566
|
+
/** Directory for debug log files. */
|
|
567
|
+
| "WRANGLER_LOG_PATH"
|
|
568
|
+
/** Sanitize sensitive data in debug logs (default: true). */
|
|
569
|
+
| "WRANGLER_LOG_SANITIZE"
|
|
570
|
+
/** Directory for ND-JSON output files. */
|
|
571
|
+
| "WRANGLER_OUTPUT_FILE_DIRECTORY"
|
|
572
|
+
/** Hide the Wrangler version banner */
|
|
573
|
+
| "WRANGLER_HIDE_BANNER"
|
|
574
|
+
/** Specific path for ND-JSON output file. */
|
|
575
|
+
| "WRANGLER_OUTPUT_FILE_PATH"
|
|
576
|
+
/** Comma-separated list of build conditions for esbuild. */
|
|
577
|
+
| "WRANGLER_BUILD_CONDITIONS"
|
|
578
|
+
/** Build platform for esbuild (e.g., "node", "browser"). */
|
|
579
|
+
| "WRANGLER_BUILD_PLATFORM"
|
|
580
|
+
/** Path to file-based dev registry folder. */
|
|
581
|
+
| "WRANGLER_REGISTRY_PATH"
|
|
582
|
+
/** Additional D1 location choices (internal use). */
|
|
583
|
+
| "WRANGLER_D1_EXTRA_LOCATION_CHOICES"
|
|
584
|
+
/** The Workers environment to target (equivalent to the `--env` CLI param) */
|
|
585
|
+
| "CLOUDFLARE_ENV"
|
|
586
|
+
/** Custom directory for Wrangler's cache files (overrides `node_modules/.cache/wrangler`). */
|
|
587
|
+
| "WRANGLER_CACHE_DIR"
|
|
588
|
+
/** Custom path to cloudflared binary (overrides automatic binary management). */
|
|
589
|
+
| "CLOUDFLARED_PATH"
|
|
590
|
+
/** Set to "staging" to use staging APIs instead of production. */
|
|
591
|
+
| "WRANGLER_API_ENVIRONMENT"
|
|
592
|
+
/** Custom auth domain (usually auto-configured). */
|
|
593
|
+
| "WRANGLER_AUTH_DOMAIN"
|
|
594
|
+
/** Custom auth URL (usually auto-configured). */
|
|
595
|
+
| "WRANGLER_AUTH_URL"
|
|
596
|
+
/** Custom OAuth client ID (usually auto-configured). */
|
|
597
|
+
| "WRANGLER_CLIENT_ID"
|
|
598
|
+
/** Custom OAuth client ID for the `cf` CLI's OAuth app (usually auto-configured). */
|
|
599
|
+
| "CLOUDFLARE_CLIENT_ID"
|
|
600
|
+
/** Custom token URL (usually auto-configured). */
|
|
601
|
+
| "WRANGLER_TOKEN_URL"
|
|
602
|
+
/** Custom token revocation URL (usually auto-configured). */
|
|
603
|
+
| "WRANGLER_REVOKE_URL"
|
|
604
|
+
/** Direct authorization token for API requests. */
|
|
605
|
+
| "WRANGLER_CF_AUTHORIZATION_TOKEN"
|
|
606
|
+
/** Cloudflare Access Service Token Client ID. Used to authenticate with Access-protected domains in non-interactive environments (e.g. CI). */
|
|
607
|
+
| "CLOUDFLARE_ACCESS_CLIENT_ID"
|
|
608
|
+
/** Cloudflare Access Service Token Client Secret. Used with CLOUDFLARE_ACCESS_CLIENT_ID. */
|
|
609
|
+
| "CLOUDFLARE_ACCESS_CLIENT_SECRET"
|
|
610
|
+
/**
|
|
611
|
+
* Store OAuth credentials in the OS keychain instead of a plaintext TOML
|
|
612
|
+
* file. Overrides the persistent `keyring_enabled` preference written by
|
|
613
|
+
* `wrangler login --use-keyring`.
|
|
614
|
+
*/
|
|
615
|
+
| "CLOUDFLARE_AUTH_USE_KEYRING"
|
|
616
|
+
/** Enable the local explorer UI at /cdn-cgi/local/explorer (experimental, default: false). */
|
|
617
|
+
| "X_LOCAL_EXPLORER"
|
|
618
|
+
/** Enable local-dev observability capture (experimental, default: false). */
|
|
619
|
+
| "X_LOCAL_OBSERVABILITY"
|
|
620
|
+
/** Open the browser in headful (visible) mode when using the Browser Run API in local dev (default: false). */
|
|
621
|
+
| "X_BROWSER_HEADFUL"
|
|
622
|
+
/** Override command used by `wrangler init` (default: "create cloudflare"). */
|
|
623
|
+
| "WRANGLER_C3_COMMAND"
|
|
624
|
+
/** Enable/disable telemetry data collection. */
|
|
625
|
+
| "WRANGLER_SEND_METRICS"
|
|
626
|
+
/** Enable/disable error reporting to Sentry. */
|
|
627
|
+
| "WRANGLER_SEND_ERROR_REPORTS"
|
|
628
|
+
/** Suppress the prompt that offers to update Cloudflare agent skills. */
|
|
629
|
+
| "WRANGLER_NO_SKILLS_UPDATE_PROMPTS"
|
|
630
|
+
/** CI branch name (internal use). */
|
|
631
|
+
| "WORKERS_CI_BRANCH"
|
|
632
|
+
/** CI tag matching configuration (internal use). */
|
|
633
|
+
| "WRANGLER_CI_MATCH_TAG"
|
|
634
|
+
/** CI override name configuration (internal use). */
|
|
635
|
+
| "WRANGLER_CI_OVERRIDE_NAME"
|
|
636
|
+
/** CI network mode host override (internal use). */
|
|
637
|
+
| "WRANGLER_CI_OVERRIDE_NETWORK_MODE_HOST"
|
|
638
|
+
/** CI preview alias generation (internal use). */
|
|
639
|
+
| "WRANGLER_CI_GENERATE_PREVIEW_ALIAS"
|
|
640
|
+
/** Disable config watching in ConfigController. */
|
|
641
|
+
| "WRANGLER_CI_DISABLE_CONFIG_WATCHING"
|
|
642
|
+
/** Disable telemetry when set to an opt-out value. */
|
|
643
|
+
| "DO_NOT_TRACK"
|
|
644
|
+
/** Path to docker binary (default: "docker"). */
|
|
645
|
+
| "WRANGLER_DOCKER_BIN"
|
|
646
|
+
/** Docker host configuration (handled separately from environment variable factory). */
|
|
647
|
+
| "WRANGLER_DOCKER_HOST"
|
|
648
|
+
/** Docker host configuration (handled separately from environment variable factory). */
|
|
649
|
+
| "DOCKER_HOST"
|
|
650
|
+
/** Environment variable used to signal that the current process is being run by the open-next deploy command. */
|
|
651
|
+
| "OPEN_NEXT_DEPLOY";
|
|
652
|
+
type DeprecatedNames = "CF_ACCOUNT_ID" | "CF_API_TOKEN" | "CF_API_KEY" | "CF_EMAIL" | "CF_API_BASE_URL";
|
|
653
|
+
type ElementType<A> = A extends readonly (infer T)[] ? T : never;
|
|
654
|
+
/**
|
|
655
|
+
* Create a function used to access a boolean environment variable. It may return undefined if the variable is not set.
|
|
656
|
+
*
|
|
657
|
+
* This is not memoized to allow us to change the value at runtime, such as in testing.
|
|
658
|
+
*
|
|
659
|
+
* The environment variable must be either "true" or "false" (after lowercasing), otherwise it will throw an error.
|
|
660
|
+
*/
|
|
661
|
+
declare function getBooleanEnvironmentVariableFactory(options: {
|
|
662
|
+
variableName: VariableNames;
|
|
663
|
+
}): () => boolean | undefined;
|
|
664
|
+
declare function getBooleanEnvironmentVariableFactory(options: {
|
|
665
|
+
variableName: VariableNames;
|
|
666
|
+
defaultValue: boolean | (() => boolean);
|
|
667
|
+
}): () => boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Create a function used to access an environment variable. It may return undefined if the variable is not set.
|
|
670
|
+
*
|
|
671
|
+
* This is not memoized to allow us to change the value at runtime, such as in testing.
|
|
672
|
+
* A warning is shown if the client is using a deprecated version - but only once.
|
|
673
|
+
* If a list of choices is provided, then the environment variable must be one of those given.
|
|
674
|
+
*/
|
|
675
|
+
declare function getEnvironmentVariableFactory<Choices extends readonly string[]>(options: {
|
|
676
|
+
variableName: VariableNames;
|
|
677
|
+
deprecatedName?: DeprecatedNames;
|
|
678
|
+
choices?: Choices;
|
|
679
|
+
}): () => ElementType<Choices> | undefined;
|
|
680
|
+
/**
|
|
681
|
+
* Create a function used to access an environment variable, with a default value if the variable is not set.
|
|
682
|
+
*
|
|
683
|
+
* This is not memoized to allow us to change the value at runtime, such as in testing.
|
|
684
|
+
* A warning is shown if the client is using a deprecated version - but only once.
|
|
685
|
+
* If a list of choices is provided, then the environment variable must be one of those given.
|
|
686
|
+
*/
|
|
687
|
+
declare function getEnvironmentVariableFactory<Choices extends readonly string[]>(options: {
|
|
688
|
+
variableName: VariableNames;
|
|
689
|
+
deprecatedName?: DeprecatedNames;
|
|
690
|
+
defaultValue: () => ElementType<Choices>;
|
|
691
|
+
readonly choices?: Choices;
|
|
692
|
+
}): () => ElementType<Choices>;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* The compatibility date to use when the user has not specified one.
|
|
696
|
+
*
|
|
697
|
+
* This is the release date of the `workerd` version pinned in the pnpm catalog,
|
|
698
|
+
* so it is fixed for a given release of workers-sdk and updated whenever
|
|
699
|
+
* `workerd` is upgraded.
|
|
700
|
+
*
|
|
701
|
+
* It deliberately tracks `workerd` rather than the current date, because
|
|
702
|
+
* workerd rejects a compatibility date later than either of:
|
|
703
|
+
*
|
|
704
|
+
* - its `MAXIMUM_COMPATIBILITY_DATE`, which is its release date plus 7 days, or
|
|
705
|
+
* - today's date (UTC).
|
|
706
|
+
*
|
|
707
|
+
* Run `pnpm update:compat-date` to refresh this value; `pnpm check:compat-date`
|
|
708
|
+
* asserts that it matches the pinned `workerd` version.
|
|
709
|
+
*
|
|
710
|
+
* @see https://github.com/cloudflare/workerd/blob/main/src/workerd/io/BUILD.bazel
|
|
711
|
+
* @see https://github.com/cloudflare/workerd/blob/main/src/workerd/io/compatibility-date.c%2B%2B
|
|
712
|
+
*/
|
|
713
|
+
declare const DEFAULT_COMPAT_DATE: CompatDate;
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* A file-backed key/value cache scoped to a consumer's cache directory.
|
|
717
|
+
*
|
|
718
|
+
* The mechanism is generic (JSON blobs keyed by file name); the only
|
|
719
|
+
* consumer-specific input is the logger used for debug output, so the whole
|
|
720
|
+
* bundle is built by {@link createConfigCache}. Wrangler wraps this with its
|
|
721
|
+
* logger singleton in `src/config-cache.ts`; `@cloudflare/workers-auth` builds
|
|
722
|
+
* its own instance with the logger injected into `createWranglerAuth`.
|
|
723
|
+
*/
|
|
724
|
+
interface ConfigCache {
|
|
725
|
+
getCacheFolder: () => string;
|
|
726
|
+
getConfigCache: <T>(fileName: string) => Partial<T>;
|
|
727
|
+
saveToConfigCache: <T>(fileName: string, newValues: Partial<T>) => void;
|
|
728
|
+
purgeConfigCaches: () => void;
|
|
729
|
+
}
|
|
730
|
+
interface ConfigCacheOptions {
|
|
731
|
+
/**
|
|
732
|
+
* Namespace for the cache directory, so different Cloudflare CLIs get
|
|
733
|
+
* isolated caches (`<node_modules>/.cache/<namespace>` or
|
|
734
|
+
* `.<namespace>/cache`). Defaults to `"wrangler"` for backward compatibility.
|
|
735
|
+
*
|
|
736
|
+
* `purgeConfigCaches()` deletes the whole cache folder, so a non-default
|
|
737
|
+
* namespace also ensures e.g. `cf login`/`logout` never wipes wrangler's
|
|
738
|
+
* cache.
|
|
739
|
+
*/
|
|
740
|
+
namespace?: string;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Build a file-backed config cache bound to the given logger.
|
|
744
|
+
*/
|
|
745
|
+
declare function createConfigCache(logger: Logger, options?: ConfigCacheOptions): ConfigCache;
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* A short-lived directory. Automatically removed when the process exits, but
|
|
749
|
+
* can be removed earlier by calling `remove()`.
|
|
750
|
+
*/
|
|
751
|
+
interface EphemeralDirectory {
|
|
752
|
+
path: string;
|
|
753
|
+
remove(): void;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Gets the path to the project's `.wrangler` folder.
|
|
757
|
+
*/
|
|
758
|
+
declare function getWranglerHiddenDirPath(projectRoot: string | undefined): string;
|
|
759
|
+
/**
|
|
760
|
+
* Removes stale `.wrangler/tmp/*` entries left behind by previous wrangler
|
|
761
|
+
* sessions that exited abnormally (SIGKILL, OOM, host crash) and so missed
|
|
762
|
+
* the `signal-exit` cleanup. Runs at most once per tmp root per process.
|
|
763
|
+
*
|
|
764
|
+
* Exported for tests.
|
|
765
|
+
*/
|
|
766
|
+
declare function sweepStaleWranglerTmpDirs(tmpRoot: string): void;
|
|
767
|
+
/**
|
|
768
|
+
* Gets a temporary directory in the project's `.wrangler` folder with the
|
|
769
|
+
* specified prefix. We create temporary directories in `.wrangler` as opposed
|
|
770
|
+
* to the OS's temporary directory to avoid issues with different drive letters
|
|
771
|
+
* on Windows. For example, when `esbuild` outputs a file to a different drive
|
|
772
|
+
* than the input sources, the generated source maps are incorrect.
|
|
773
|
+
*/
|
|
774
|
+
declare function getWranglerTmpDir(projectRoot: string | undefined, prefix: string, cleanup?: boolean): EphemeralDirectory;
|
|
775
|
+
|
|
776
|
+
interface QuickTunnelResult {
|
|
777
|
+
mode: "quick";
|
|
778
|
+
publicUrl: URL;
|
|
779
|
+
}
|
|
780
|
+
interface NamedTunnelResult {
|
|
781
|
+
mode: "named";
|
|
782
|
+
}
|
|
783
|
+
type TunnelResult = QuickTunnelResult | NamedTunnelResult;
|
|
784
|
+
interface Tunnel {
|
|
785
|
+
ready: () => Promise<TunnelResult>;
|
|
786
|
+
isOpen: () => boolean;
|
|
787
|
+
dispose: () => void;
|
|
788
|
+
extendExpiry: (ms?: number) => void;
|
|
789
|
+
}
|
|
790
|
+
interface TunnelOptions {
|
|
791
|
+
origin: URL;
|
|
792
|
+
token?: string;
|
|
793
|
+
timeoutMs?: number;
|
|
794
|
+
expiryMs?: number;
|
|
795
|
+
reminderIntervalMs?: number;
|
|
796
|
+
extendHint?: string;
|
|
797
|
+
logger?: Pick<Logger, "debug" | "log" | "warn">;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Start a Cloudflare Quick Tunnel for a local dev origin.
|
|
801
|
+
*
|
|
802
|
+
* Spawns `cloudflared tunnel --url <origin>` and waits for the public URL
|
|
803
|
+
* to appear in its stderr output. Returns a controller with a `ready()`
|
|
804
|
+
* promise that resolves once the tunnel URL is available, and a `dispose()`
|
|
805
|
+
* function to stop the tunnel.
|
|
806
|
+
*/
|
|
807
|
+
declare function startTunnel(options: TunnelOptions): Tunnel;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* cloudflared binary management for Wrangler tunnel commands.
|
|
811
|
+
*
|
|
812
|
+
* This module handles downloading, caching, and running the cloudflared binary.
|
|
813
|
+
* It uses the Cloudflare update worker (update.argotunnel.com) to resolve
|
|
814
|
+
* the latest version and download URL, matching cloudflared's own update mechanism.
|
|
815
|
+
*/
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Spawn cloudflared process with automatic binary management
|
|
819
|
+
*/
|
|
820
|
+
declare function spawnCloudflared(args: string[], options?: {
|
|
821
|
+
stdio?: "inherit" | "pipe";
|
|
822
|
+
env?: Record<string, string>;
|
|
823
|
+
skipVersionCheck?: boolean;
|
|
824
|
+
confirmDownload?: (message: string) => Promise<boolean>;
|
|
825
|
+
logger?: Pick<Logger, "debug" | "log" | "warn">;
|
|
826
|
+
}): Promise<ChildProcess>;
|
|
827
|
+
|
|
828
|
+
type NpmVersionCheckResult = {
|
|
829
|
+
status: "up-to-date";
|
|
830
|
+
} | {
|
|
831
|
+
status: "update-available";
|
|
832
|
+
latest: string;
|
|
833
|
+
} | {
|
|
834
|
+
status: "failed";
|
|
835
|
+
};
|
|
836
|
+
/**
|
|
837
|
+
* Checks if a newer version of a package is available on npm.
|
|
838
|
+
*
|
|
839
|
+
* Uses the `update-check` library to query the npm registry for the latest
|
|
840
|
+
* version. The dist tag used for comparison depends on the current version —
|
|
841
|
+
* "beta" for pre-release versions (0.0.0-*) and "latest" for stable versions.
|
|
842
|
+
*
|
|
843
|
+
* @param name - The npm package name to check
|
|
844
|
+
* @param version - The current version to compare against
|
|
845
|
+
* @returns A discriminated result:
|
|
846
|
+
* - `{ status: "update-available", latest: string }` if a newer version exists
|
|
847
|
+
* - `{ status: "up-to-date" }` if the installed version is already the latest
|
|
848
|
+
* - `{ status: "failed" }` if the check could not be completed (network error, timeout, etc.)
|
|
849
|
+
*/
|
|
850
|
+
declare function fetchLatestNpmVersion(name: string, version: string): Promise<NpmVersionCheckResult>;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Returns whether the process can handle interactive input (e.g. hotkeys).
|
|
854
|
+
*
|
|
855
|
+
* A process is considered interactive when **both** conditions are met:
|
|
856
|
+
* - It is **not** running in a Cloudflare CI environment (Pages or Workers CI).
|
|
857
|
+
* - `stdin` and `stdout` are connected to a TTY (not piped from/to another process).
|
|
858
|
+
*
|
|
859
|
+
* Note: generic CI environments (e.g. GitHub Actions) do **not** disable interactivity,
|
|
860
|
+
* because a real PTY may still be attached and hotkeys should still work.
|
|
861
|
+
*
|
|
862
|
+
* Use this for features that require a TTY but should remain functional in generic CI:
|
|
863
|
+
* - Registering hotkeys (e.g. `x` to exit `wrangler dev`)
|
|
864
|
+
* - Enabling raw mode / keypress handling
|
|
865
|
+
* - Showing animated spinners or progress indicators
|
|
866
|
+
* - Reading secrets from an interactive prompt vs stdin
|
|
867
|
+
*
|
|
868
|
+
* Use {@link isNonInteractiveOrCI} instead when user input should be suppressed
|
|
869
|
+
* in **all** CI environments.
|
|
870
|
+
*
|
|
871
|
+
* @returns `true` if the process is interactive, `false` otherwise.
|
|
872
|
+
*/
|
|
873
|
+
declare function isInteractive(): boolean;
|
|
874
|
+
/**
|
|
875
|
+
* Returns whether the process should not prompt the user.
|
|
876
|
+
*
|
|
877
|
+
* Returns `true` when the process is non-interactive (no TTY) **or** running
|
|
878
|
+
* in any CI environment (detected via `ci-info`). This is stricter than
|
|
879
|
+
* {@link isInteractive} which only checks for Cloudflare-specific CI,
|
|
880
|
+
* because user prompts should never appear in CI even when a PTY is attached.
|
|
881
|
+
*
|
|
882
|
+
* Use this for anything that should be suppressed or adapted in CI:
|
|
883
|
+
* - User prompts (confirmations, text input, select dialogs)
|
|
884
|
+
* - OAuth login flows
|
|
885
|
+
* - Output format decisions (JSON in CI, pretty when interactive)
|
|
886
|
+
* - Banner / decoration display
|
|
887
|
+
* - Redacting sensitive info (account names, emails) in CI logs
|
|
888
|
+
* - Writing config changes back to disk (e.g. provisioned resource IDs)
|
|
889
|
+
*
|
|
890
|
+
* @returns `true` if the process is non-interactive or running in CI.
|
|
891
|
+
*/
|
|
892
|
+
declare function isNonInteractiveOrCI(): boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Whether the process is running in any CI environment (per `ci-info`).
|
|
895
|
+
*
|
|
896
|
+
* Distinct from {@link isNonInteractiveOrCI}: this ignores TTY state, so it is
|
|
897
|
+
* `true` only for genuine CI, not for merely non-interactive contexts (agents,
|
|
898
|
+
* piped commands). Used for behaviour that should key off CI specifically — e.g.
|
|
899
|
+
* redacting account names / emails in public CI logs while still showing them to
|
|
900
|
+
* non-interactive local tooling.
|
|
901
|
+
*
|
|
902
|
+
* Exposed from this package (rather than having consumers `import "ci-info"`
|
|
903
|
+
* directly) so the value flows through the mockable `ci-info` boundary and
|
|
904
|
+
* consumers don't take a fresh, unmockable dependency on it.
|
|
905
|
+
*/
|
|
906
|
+
declare function isCI(): boolean;
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Wrapper around the `open` package that gracefully handles environments where
|
|
910
|
+
* a browser opener (e.g. `xdg-open` on Linux) is unavailable. In those cases
|
|
911
|
+
* the URL is printed so the user can copy-paste it manually, rather than
|
|
912
|
+
* crashing with a confusing "file not found" error.
|
|
913
|
+
*
|
|
914
|
+
* The consumer's `logger` is passed in rather than imported: this package is
|
|
915
|
+
* shared across CLIs and has no logger singleton of its own.
|
|
916
|
+
*
|
|
917
|
+
* @param url the URL to point the browser at
|
|
918
|
+
* @param logger the consumer's logger, used to surface the manual-open fallback
|
|
919
|
+
*/
|
|
920
|
+
declare function openInBrowser(url: string, logger: Logger): Promise<void>;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Write an entry to the output file.
|
|
924
|
+
*
|
|
925
|
+
* Control whether (and where) to write this file by setting either
|
|
926
|
+
* `WRANGLER_OUTPUT_FILE_DIRECTORY` or `WRANGLER_OUTPUT_FILE_PATH`.
|
|
927
|
+
*
|
|
928
|
+
* @param entry The structured output entry to append.
|
|
929
|
+
* @returns Nothing.
|
|
930
|
+
*/
|
|
931
|
+
declare function writeOutput(entry: OutputEntry): void;
|
|
932
|
+
/**
|
|
933
|
+
* Clear the cached output file path.
|
|
934
|
+
*
|
|
935
|
+
* @returns Nothing.
|
|
936
|
+
*/
|
|
937
|
+
declare function clearOutputFilePath(): void;
|
|
938
|
+
interface OutputEntryBase<T extends string> {
|
|
939
|
+
version: number;
|
|
940
|
+
type: T;
|
|
941
|
+
}
|
|
942
|
+
interface OutputEntryBundleSize {
|
|
943
|
+
/** The uncompressed size of the Worker bundle. */
|
|
944
|
+
raw_bytes: number;
|
|
945
|
+
/** The gzip-compressed size of the Worker bundle. */
|
|
946
|
+
gzip_bytes: number;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* All the different types of entry that can be written to the output file.
|
|
950
|
+
*/
|
|
951
|
+
type OutputEntry = OutputEntrySession | OutputEntryDeployment | OutputEntryPreview | OutputEntryPagesDeployment | OutputEntryVersionUpload | OutputEntryVersionDeployment | OutputEntryPagesDeploymentDetailed | OutputEntryCommandFailed | OutputEntryAutoConfig;
|
|
952
|
+
interface OutputEntrySession extends OutputEntryBase<"wrangler-session"> {
|
|
953
|
+
version: 1;
|
|
954
|
+
/** The semver version string taken from Wrangler's package.json. */
|
|
955
|
+
wrangler_version: string;
|
|
956
|
+
/** The arguments passed to Wrangler. */
|
|
957
|
+
command_line_args: string[];
|
|
958
|
+
/** The absolute path to a file that contains debug logs for this Wrangler instance. */
|
|
959
|
+
log_file_path: string;
|
|
960
|
+
}
|
|
961
|
+
interface OutputEntryDeployment extends OutputEntryBase<"deploy"> {
|
|
962
|
+
version: 1;
|
|
963
|
+
/** The name of the Worker. */
|
|
964
|
+
worker_name: string | null;
|
|
965
|
+
/** The GUID that identifies the Worker. This never changes even if the name is changed. */
|
|
966
|
+
worker_tag: string | null;
|
|
967
|
+
/** A GUID that identifies this deployed version of the Worker. This version is associated with an automatically created deployment, with this version set at 100%. */
|
|
968
|
+
version_id: string | null;
|
|
969
|
+
/** A list of URLs that represent the HTTP triggers associated with this deployment */
|
|
970
|
+
targets: string[] | undefined;
|
|
971
|
+
/** set if the worker's name was overridden */
|
|
972
|
+
worker_name_overridden: boolean;
|
|
973
|
+
/** wrangler environment used */
|
|
974
|
+
wrangler_environment: string | undefined;
|
|
975
|
+
/** Exact Worker bundle sizes in bytes. */
|
|
976
|
+
bundle_size?: OutputEntryBundleSize;
|
|
977
|
+
}
|
|
978
|
+
interface OutputEntryPreview extends OutputEntryBase<"preview"> {
|
|
979
|
+
version: 1;
|
|
980
|
+
/** The name of the Worker. */
|
|
981
|
+
worker_name: string | null;
|
|
982
|
+
/** The ID of the Preview resource. */
|
|
983
|
+
preview_id: string;
|
|
984
|
+
/** The human-readable name of the Preview resource. */
|
|
985
|
+
preview_name: string;
|
|
986
|
+
/** The slug of the Preview resource. */
|
|
987
|
+
preview_slug: string;
|
|
988
|
+
/** A list of URLs associated with the Preview resource. */
|
|
989
|
+
preview_urls: string[] | undefined;
|
|
990
|
+
/** The ID of the Preview deployment resource. */
|
|
991
|
+
deployment_id: string;
|
|
992
|
+
/** A list of URLs associated with the Preview deployment. */
|
|
993
|
+
deployment_urls: string[] | undefined;
|
|
994
|
+
}
|
|
995
|
+
interface OutputEntryAutoConfig extends OutputEntryBase<"autoconfig"> {
|
|
996
|
+
version: 1;
|
|
997
|
+
/** The command that triggered autoconfig */
|
|
998
|
+
command: "setup" | "deploy";
|
|
999
|
+
/** The summary of the autoconfig process */
|
|
1000
|
+
summary: {
|
|
1001
|
+
wranglerConfig?: {
|
|
1002
|
+
name?: string;
|
|
1003
|
+
compatibility_date?: string;
|
|
1004
|
+
};
|
|
1005
|
+
[key: string]: unknown;
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
interface OutputEntryPagesDeployment extends OutputEntryBase<"pages-deploy"> {
|
|
1009
|
+
version: 1;
|
|
1010
|
+
/** The name of the Pages project. */
|
|
1011
|
+
pages_project: string | null;
|
|
1012
|
+
/** A GUID that identifies this Pages deployment. */
|
|
1013
|
+
deployment_id: string | null;
|
|
1014
|
+
/** The URL associated with this deployment */
|
|
1015
|
+
url: string | undefined;
|
|
1016
|
+
}
|
|
1017
|
+
interface OutputEntryPagesDeploymentDetailed extends OutputEntryBase<"pages-deploy-detailed"> {
|
|
1018
|
+
version: 1;
|
|
1019
|
+
/** The name of the Pages project. */
|
|
1020
|
+
pages_project: string | null;
|
|
1021
|
+
/** A GUID that identifies this Pages deployment. */
|
|
1022
|
+
deployment_id: string | null;
|
|
1023
|
+
/** The URL associated with this deployment */
|
|
1024
|
+
url: string | undefined;
|
|
1025
|
+
/** The Alias url, if it exists */
|
|
1026
|
+
alias: string | undefined;
|
|
1027
|
+
/** The environment being deployed to */
|
|
1028
|
+
environment: "production" | "preview";
|
|
1029
|
+
/** The production branch of the pages project */
|
|
1030
|
+
production_branch: string;
|
|
1031
|
+
deployment_trigger: {
|
|
1032
|
+
metadata: {
|
|
1033
|
+
/** Commit hash of the deployment trigger metadata for the pages project */
|
|
1034
|
+
commit_hash: string;
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
interface OutputEntryVersionUpload extends OutputEntryBase<"version-upload"> {
|
|
1039
|
+
version: 1;
|
|
1040
|
+
/** The name of the Worker. */
|
|
1041
|
+
worker_name: string | null;
|
|
1042
|
+
/** The GUID that identifies the Worker. This never changes even if the name is changed. */
|
|
1043
|
+
worker_tag: string | null;
|
|
1044
|
+
/** A GUID that identifies this uploaded, but not yet deployed, version of the Worker. This version will need to be "deployed" to receive traffic. */
|
|
1045
|
+
version_id: string | null;
|
|
1046
|
+
/** The preview URL associated with this version upload */
|
|
1047
|
+
preview_url: string | undefined;
|
|
1048
|
+
/** The ephemeral aliased preview URL associated with this version upload */
|
|
1049
|
+
preview_alias_url: string | undefined;
|
|
1050
|
+
/** set if the worker's name was overridden */
|
|
1051
|
+
worker_name_overridden: boolean;
|
|
1052
|
+
/** wrangler environment used */
|
|
1053
|
+
wrangler_environment: string | undefined;
|
|
1054
|
+
/** Exact Worker bundle sizes in bytes. */
|
|
1055
|
+
bundle_size?: OutputEntryBundleSize;
|
|
1056
|
+
}
|
|
1057
|
+
interface OutputEntryVersionDeployment extends OutputEntryBase<"version-deploy"> {
|
|
1058
|
+
version: 1;
|
|
1059
|
+
/** The name of the Worker. */
|
|
1060
|
+
worker_name: string | null;
|
|
1061
|
+
/** The GUID that identifies the Worker. This never changes even if the name is changed. */
|
|
1062
|
+
worker_tag: string | null;
|
|
1063
|
+
/** The ID of the gradual rollout deployment. */
|
|
1064
|
+
deployment_id: string;
|
|
1065
|
+
/** The percentage of traffic that goes to each version. */
|
|
1066
|
+
version_traffic: Map<string, number>;
|
|
1067
|
+
}
|
|
1068
|
+
interface OutputEntryCommandFailed extends OutputEntryBase<"command-failed"> {
|
|
1069
|
+
version: 1;
|
|
1070
|
+
/** The code in the error. */
|
|
1071
|
+
code: number | undefined;
|
|
1072
|
+
/** The message in the error. */
|
|
1073
|
+
message: string | undefined;
|
|
1074
|
+
/** How many milliseconds to retry the operation after if available. */
|
|
1075
|
+
retry_after_ms: number | undefined;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
declare function retryOnAPIFailure<T>(action: () => T | Promise<T>, logger: Logger, backoff?: number, attempts?: number, abortSignal?: AbortSignal): Promise<T>;
|
|
1079
|
+
|
|
1080
|
+
declare function formatTime(duration: number): string;
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Get the hostname on which to run a Worker.
|
|
1084
|
+
*
|
|
1085
|
+
* The most accurate place is usually
|
|
1086
|
+
* `route.pattern`, as that includes any subdomains. For example:
|
|
1087
|
+
* ```js
|
|
1088
|
+
* {
|
|
1089
|
+
* pattern: foo.example.com
|
|
1090
|
+
* zone_name: example.com
|
|
1091
|
+
* }
|
|
1092
|
+
* ```
|
|
1093
|
+
* However, in the case of patterns that _can't_ be parsed as a hostname
|
|
1094
|
+
* (primarily the pattern `*/ declare function getHostFromRoute(route: Route): string | undefined;
|
|
1095
|
+
/**
|
|
1096
|
+
* Best-effort derivation of the Cloudflare zone name that owns a given route,
|
|
1097
|
+
* for use as the `CF-Worker` header value on outbound subrequests in local
|
|
1098
|
+
* development (see https://developers.cloudflare.com/fundamentals/reference/http-headers/#cf-worker).
|
|
1099
|
+
*
|
|
1100
|
+
* In production, `CF-Worker` is set to the zone name — for a route
|
|
1101
|
+
* `foo.example.com/*` on zone `example.com`, the header is `example.com`.
|
|
1102
|
+
* When the user has explicitly told us the zone name in their route config
|
|
1103
|
+
* (`zone_name`), use it. Otherwise, fall back to {@link getHostFromRoute},
|
|
1104
|
+
* which returns the route pattern's hostname — this is the closest local
|
|
1105
|
+
* approximation without performing an API lookup, and matches the behaviour
|
|
1106
|
+
* users see when their route's hostname is already the apex (e.g.
|
|
1107
|
+
* `example.com/*`).
|
|
1108
|
+
*/
|
|
1109
|
+
declare function getZoneFromRoute(route: Route): string | undefined;
|
|
1110
|
+
/**
|
|
1111
|
+
* Given something that resembles a URL, try to extract a host from it.
|
|
1112
|
+
*/
|
|
1113
|
+
declare function getHostFromUrl(urlLike: string): string | undefined;
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* Describes a supported package manager and its associated CLI commands
|
|
1117
|
+
* and lock file conventions.
|
|
1118
|
+
*/
|
|
1119
|
+
interface PackageManager {
|
|
1120
|
+
/** The package manager identifier. */
|
|
1121
|
+
type: "npm" | "yarn" | "pnpm" | "bun" | "nub";
|
|
1122
|
+
/** The command used to execute packages (e.g. `npx`, `pnpm`, `bunx`). */
|
|
1123
|
+
npx: string;
|
|
1124
|
+
/** The command segments used to download and execute packages (e.g. `["npx"]`, `["pnpm", "dlx"]`). */
|
|
1125
|
+
dlx: string[];
|
|
1126
|
+
/** Lock file names produced by this package manager. */
|
|
1127
|
+
lockFiles: string[];
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Manage packages using npm.
|
|
1131
|
+
*/
|
|
1132
|
+
declare const NpmPackageManager: {
|
|
1133
|
+
readonly type: "npm";
|
|
1134
|
+
readonly npx: "npx";
|
|
1135
|
+
readonly dlx: ["npx"];
|
|
1136
|
+
readonly lockFiles: ["package-lock.json"];
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* Manage packages using pnpm.
|
|
1140
|
+
*/
|
|
1141
|
+
declare const PnpmPackageManager: {
|
|
1142
|
+
readonly type: "pnpm";
|
|
1143
|
+
readonly npx: "pnpm";
|
|
1144
|
+
readonly lockFiles: ["pnpm-lock.yaml"];
|
|
1145
|
+
readonly dlx: ["pnpm", "dlx"];
|
|
1146
|
+
};
|
|
1147
|
+
/**
|
|
1148
|
+
* Manage packages using yarn.
|
|
1149
|
+
*/
|
|
1150
|
+
declare const YarnPackageManager: {
|
|
1151
|
+
readonly type: "yarn";
|
|
1152
|
+
readonly npx: "yarn";
|
|
1153
|
+
readonly dlx: ["yarn", "dlx"];
|
|
1154
|
+
readonly lockFiles: ["yarn.lock"];
|
|
1155
|
+
};
|
|
1156
|
+
/**
|
|
1157
|
+
* Manage packages using bun.
|
|
1158
|
+
*/
|
|
1159
|
+
declare const BunPackageManager: {
|
|
1160
|
+
readonly type: "bun";
|
|
1161
|
+
readonly npx: "bunx";
|
|
1162
|
+
readonly dlx: ["bunx"];
|
|
1163
|
+
readonly lockFiles: ["bun.lockb", "bun.lock"];
|
|
1164
|
+
};
|
|
1165
|
+
/**
|
|
1166
|
+
* Manage packages using nub.
|
|
1167
|
+
*/
|
|
1168
|
+
declare const NubPackageManager: {
|
|
1169
|
+
readonly type: "nub";
|
|
1170
|
+
readonly npx: "nubx";
|
|
1171
|
+
readonly dlx: ["nubx"];
|
|
1172
|
+
readonly lockFiles: ["nub.lock"];
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Checks whether the provided worker name is valid, this means that:
|
|
1177
|
+
* - the name is not empty
|
|
1178
|
+
* - the name doesn't start nor ends with a dash
|
|
1179
|
+
* - the name doesn't contain special characters besides dashes
|
|
1180
|
+
* - the name is not longer than 63 characters
|
|
1181
|
+
*
|
|
1182
|
+
* See: https://developers.cloudflare.com/workers/configuration/routing/workers-dev/#limitations
|
|
1183
|
+
*
|
|
1184
|
+
* @param input The name to check
|
|
1185
|
+
* @returns Object indicating whether the name is valid, and if not a cause indicating why it isn't
|
|
1186
|
+
*/
|
|
1187
|
+
declare function checkWorkerNameValidity(input: string): {
|
|
1188
|
+
valid: false;
|
|
1189
|
+
cause: string;
|
|
1190
|
+
} | {
|
|
1191
|
+
valid: true;
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* Given an input string it converts it to a valid worker name.
|
|
1195
|
+
*
|
|
1196
|
+
* A worker name is valid if:
|
|
1197
|
+
* - the name is not empty
|
|
1198
|
+
* - the name doesn't start nor ends with a dash
|
|
1199
|
+
* - the name doesn't contain special characters besides dashes
|
|
1200
|
+
* - the name is not longer than 63 characters
|
|
1201
|
+
*
|
|
1202
|
+
* See: https://developers.cloudflare.com/workers/configuration/routing/workers-dev/#limitations
|
|
1203
|
+
*
|
|
1204
|
+
* @param input The input to convert
|
|
1205
|
+
* @returns The input itself if it was already valid, the input converted to a valid worker name otherwise
|
|
1206
|
+
*/
|
|
1207
|
+
declare function toValidWorkerName(input: string): string;
|
|
1208
|
+
/**
|
|
1209
|
+
* Derives a valid worker name from a project name (or worker name) and project path.
|
|
1210
|
+
*
|
|
1211
|
+
* The name is determined by (in order of precedence):
|
|
1212
|
+
* 1. The WRANGLER_CI_OVERRIDE_NAME environment variable (for CI environments)
|
|
1213
|
+
* 2. The provided project/worker name (if non-empty)
|
|
1214
|
+
* 3. The directory basename of the project path
|
|
1215
|
+
*
|
|
1216
|
+
* The resulting name is sanitized to be a valid worker name.
|
|
1217
|
+
*
|
|
1218
|
+
* @param projectOrWorkerName An optional project or worker name to use
|
|
1219
|
+
* @param projectPath The path to the project directory (used as fallback)
|
|
1220
|
+
* @returns A valid worker name
|
|
1221
|
+
*/
|
|
1222
|
+
declare function getWorkerName(projectOrWorkerName: string | undefined, projectPath: string): string;
|
|
1223
|
+
/**
|
|
1224
|
+
* Derives a valid worker name from a project directory.
|
|
1225
|
+
*
|
|
1226
|
+
* The name is determined by (in order of precedence):
|
|
1227
|
+
* 1. The WRANGLER_CI_OVERRIDE_NAME environment variable (for CI environments)
|
|
1228
|
+
* 2. The `name` field from package.json in the project directory
|
|
1229
|
+
* 3. The directory basename
|
|
1230
|
+
*
|
|
1231
|
+
* The resulting name is sanitized to be a valid worker name.
|
|
1232
|
+
*
|
|
1233
|
+
* @param projectPath The path to the project directory
|
|
1234
|
+
* @returns A valid worker name
|
|
1235
|
+
*/
|
|
1236
|
+
declare function getWorkerNameFromProject(projectPath: string): string;
|
|
1237
|
+
|
|
1238
|
+
type DiscriminatedPath<Discriminator extends string> = string & {
|
|
1239
|
+
_discriminator: Discriminator;
|
|
1240
|
+
};
|
|
1241
|
+
/**
|
|
1242
|
+
* A branded string that expects to be URL compatible.
|
|
1243
|
+
*
|
|
1244
|
+
* Require this type when you want callers to ensure that they have converted file-path strings into URL-safe paths.
|
|
1245
|
+
*/
|
|
1246
|
+
type UrlPath = DiscriminatedPath<"UrlPath">;
|
|
1247
|
+
/**
|
|
1248
|
+
* Convert a file-path string to a URL-path string.
|
|
1249
|
+
*
|
|
1250
|
+
* Use this helper to convert a `string` to a `UrlPath` when it is not clear whether the string needs normalizing.
|
|
1251
|
+
* Replaces all back-slashes with forward-slashes, and throws an error if the path contains a drive letter (e.g. `C:`).
|
|
1252
|
+
*
|
|
1253
|
+
* @param filePath - The file path to convert
|
|
1254
|
+
* @returns The URL-safe path
|
|
1255
|
+
*/
|
|
1256
|
+
declare function toUrlPath(filePath: string): UrlPath;
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* @deprecated new code should use getBindingTypeFriendlyName() instead
|
|
1260
|
+
*/
|
|
1261
|
+
declare const friendlyBindingNames: Record<ConfigBindingFieldName, string>;
|
|
1262
|
+
|
|
1263
|
+
export { APIError, Binding, type BindingLocalSupport, BunPackageManager, CfTailConsumer, CompatDate, Config, type ConfigBindingFieldName, type ConfigBindingOptions, type ConfigCache, type ConfigCacheOptions, ContainerApp, type ConvertBindingsOptions, DEFAULT_COMPAT_DATE, Diagnostics, DurableObjectExport, type EphemeralDirectory, type ExportType, Exports, type Location, Logger, type Message, type NormalizeAndValidateConfigArgs, NpmPackageManager, type NpmVersionCheckResult, NubPackageManager, type OutputEntry, type PackageJSON, type PackageManager, ParseError, type ParseFile, type PartitionedExports, PatchConfigError, PnpmPackageManager, type PrintBindingsOptions, RawConfig, type ResolveConfigPathOptions, Route, TelemetryMessage, type Tunnel, type TunnelOptions, type UrlPath, UserError, WorkerEntrypointExport, WorkerMetadataBinding, YarnPackageManager, assertNever, bucketFormatMessage, checkWorkerNameValidity, clearOutputFilePath, configFileName, configFormat, convertConfigToBindings, createConfigCache, experimental_patchConfig, experimental_readRawConfig, extractBindingsOfType, fetchLatestNpmVersion, findWranglerConfig, formatConfigSnippet, formatTime, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBindings, getBooleanEnvironmentVariableFactory, getContainerDurableObjectClassNames, getContainerNameToClassNameMap, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getPackagePath, getWorkerName, getWorkerNameFromProject, getWranglerHiddenDirPath, getWranglerTmpDir, getZoneFromRoute, hasDurableObjectExports, hasProperty, indexLocation, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRedirectedConfig, isRequiredProperty, isUnsafeBindingType, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, openInBrowser, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, printBindings, readFileSync, readFileSyncToBuffer, resolveContainerClassName, resolveWranglerConfigPath, retryOnAPIFailure, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, toUrlPath, toValidWorkerName, validateBindingRemoteSetting, validatePagesConfig, writeOutput };
|