@cloudflare/workers-utils 0.28.0 → 0.30.0
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 +1 -1
- package/dist/{chunk-Y3JVLYM6.mjs → chunk-3K53PSCY.mjs} +11 -1
- package/dist/{config-BadLPAp8.d.mts → config-BEcnaWpD.d.mts} +48 -2
- package/dist/index.d.mts +32 -4
- package/dist/index.mjs +137 -29
- package/dist/metafile-esm.json +1 -1
- package/dist/test-helpers/index.d.mts +1 -1
- package/dist/test-helpers/index.mjs +1 -1
- package/package.json +3 -3
package/dist/browser.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TailConsumer,
|
|
1
|
+
import { T as TailConsumer, aL as WorkerMetadata, R as RawConfig } from './config-BEcnaWpD.mjs';
|
|
2
2
|
import { AssetConfig } from '@cloudflare/workers-shared';
|
|
3
3
|
import { Cloudflare } from 'cloudflare';
|
|
4
4
|
import 'node:url';
|
|
@@ -2382,10 +2382,20 @@ var APIError = class extends ParseError {
|
|
|
2382
2382
|
* endpoint-specific structured error payloads.
|
|
2383
2383
|
*/
|
|
2384
2384
|
meta;
|
|
2385
|
-
|
|
2385
|
+
/**
|
|
2386
|
+
* Optional number of milliseconds the API asked us to wait before retrying,
|
|
2387
|
+
* derived from the response's `Retry-After` header (if present).
|
|
2388
|
+
*/
|
|
2389
|
+
retryAfterMs;
|
|
2390
|
+
constructor({
|
|
2391
|
+
status,
|
|
2392
|
+
retryAfterMs,
|
|
2393
|
+
...rest
|
|
2394
|
+
}) {
|
|
2386
2395
|
super(rest);
|
|
2387
2396
|
this.name = this.constructor.name;
|
|
2388
2397
|
this.#status = status;
|
|
2398
|
+
this.retryAfterMs = retryAfterMs;
|
|
2389
2399
|
}
|
|
2390
2400
|
get status() {
|
|
2391
2401
|
return this.#status;
|
|
@@ -204,6 +204,21 @@ declare const getOpenNextDeployFromEnv: () => string | undefined;
|
|
|
204
204
|
* `X_LOCAL_EXPLORER` enables the local explorer UI at /cdn-cgi/explorer.
|
|
205
205
|
*/
|
|
206
206
|
declare const getLocalExplorerEnabledFromEnv: () => boolean;
|
|
207
|
+
/**
|
|
208
|
+
* `X_LOCAL_OBSERVABILITY` turns on local-dev observability capture. Both
|
|
209
|
+
* `wrangler dev` and the Vite plugin read it and pass it through as the one
|
|
210
|
+
* `unsafeObservability` Miniflare option, which makes core attach the trace
|
|
211
|
+
* collector to each user worker.
|
|
212
|
+
*
|
|
213
|
+
* Temporarily defaults to `false` for release: defaulting it on attaches extra
|
|
214
|
+
* per-worker services (collector + streaming tail) that destabilise the
|
|
215
|
+
* multi-process dev-registry scenario on Windows (workerd socket "fetch
|
|
216
|
+
* failed"). Capture is now opt-in — set `X_LOCAL_OBSERVABILITY=true`, or turn it
|
|
217
|
+
* on from the Local Explorer's Observability tab (Vite dev), which reloads the
|
|
218
|
+
* runtime with capture enabled. The explorer UI itself (`X_LOCAL_EXPLORER`)
|
|
219
|
+
* stays on by default so the tab is always available.
|
|
220
|
+
*/
|
|
221
|
+
declare const getLocalObservabilityEnabledFromEnv: () => boolean;
|
|
207
222
|
/**
|
|
208
223
|
* `X_BROWSER_HEADFUL` opens the browser in headful (visible) mode when using the
|
|
209
224
|
* Browser Run API in local development.
|
|
@@ -317,11 +332,22 @@ declare function performApiFetchBase(complianceConfig: ComplianceConfig, resourc
|
|
|
317
332
|
declare function fetchInternalBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<{
|
|
318
333
|
response: ResponseType;
|
|
319
334
|
status: number;
|
|
335
|
+
retryAfterMs?: number;
|
|
320
336
|
}>;
|
|
321
337
|
declare function fetchResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<ResponseType>;
|
|
322
338
|
declare function fetchListResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, credentials?: ApiCredentials): Promise<ResponseType[]>;
|
|
323
339
|
declare function truncate(text: string, maxLength: number): string;
|
|
324
340
|
declare function isWAFBlockResponse(headers: Headers): boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Parses a `Retry-After` header value (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After)
|
|
343
|
+
* into milliseconds to wait before retrying, or `undefined` if absent/unparsable.
|
|
344
|
+
*
|
|
345
|
+
* Per the HTTP spec, `Retry-After` may either be a number of delay-seconds,
|
|
346
|
+
* or an HTTP-date after which the request may be retried.
|
|
347
|
+
*/
|
|
348
|
+
declare function parseRetryAfterValue(retryAfter: string | null | undefined): number | undefined;
|
|
349
|
+
/** Same as {@link parseRetryAfterValue}, reading the value from a `Headers` object. */
|
|
350
|
+
declare function parseRetryAfterMs(headers: Headers): number | undefined;
|
|
325
351
|
declare function extractWAFBlockRayId(headers: Headers): string | undefined;
|
|
326
352
|
declare function extractAccountTag(resource: string): string | undefined;
|
|
327
353
|
interface PageResultInfo {
|
|
@@ -337,7 +363,7 @@ declare function renderError(err: FetchError | {
|
|
|
337
363
|
documentation_url?: string;
|
|
338
364
|
}, level?: number): string;
|
|
339
365
|
declare function addAuthorizationHeader(headers: Headers, auth: ApiCredentials, overrideExisting?: boolean): void;
|
|
340
|
-
declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number): never;
|
|
366
|
+
declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number, retryAfterMs?: number): never;
|
|
341
367
|
/**
|
|
342
368
|
* Fetch a raw KV value from the Cloudflare API.
|
|
343
369
|
*
|
|
@@ -542,6 +568,11 @@ interface CfR2Bucket {
|
|
|
542
568
|
jurisdiction?: string;
|
|
543
569
|
remote?: boolean;
|
|
544
570
|
raw?: boolean;
|
|
571
|
+
/** Settings that only apply to local development */
|
|
572
|
+
local_dev?: {
|
|
573
|
+
/** EXPERIMENTAL: credentials for the local S3-compatible endpoint */
|
|
574
|
+
experimental_s3_credentials?: LocalS3Credentials;
|
|
575
|
+
};
|
|
545
576
|
}
|
|
546
577
|
interface CfD1Database {
|
|
547
578
|
binding: string;
|
|
@@ -1565,6 +1596,11 @@ type Entry = {
|
|
|
1565
1596
|
interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
|
|
1566
1597
|
}
|
|
1567
1598
|
type SimpleRoute = string;
|
|
1599
|
+
/** AWS SigV4 credentials for miniflare's local S3-compatible endpoint */
|
|
1600
|
+
interface LocalS3Credentials {
|
|
1601
|
+
accessKeyId: string;
|
|
1602
|
+
secretAccessKey: string;
|
|
1603
|
+
}
|
|
1568
1604
|
type ZoneIdRoute = {
|
|
1569
1605
|
pattern: string;
|
|
1570
1606
|
zone_id: string;
|
|
@@ -2487,6 +2523,16 @@ interface EnvironmentNonInheritable {
|
|
|
2487
2523
|
jurisdiction?: string;
|
|
2488
2524
|
/** Whether the R2 bucket should be remote or not in local development */
|
|
2489
2525
|
remote?: boolean;
|
|
2526
|
+
/** Settings that only apply to local development */
|
|
2527
|
+
local_dev?: {
|
|
2528
|
+
/**
|
|
2529
|
+
* EXPERIMENTAL: AWS SigV4 credentials for the local S3-compatible
|
|
2530
|
+
* endpoint. When set, the bucket is served at
|
|
2531
|
+
* `/cdn-cgi/local/r2/s3/<bucket-name>` during local development.
|
|
2532
|
+
* Ignored when the bucket runs remotely.
|
|
2533
|
+
*/
|
|
2534
|
+
experimental_s3_credentials?: LocalS3Credentials;
|
|
2535
|
+
};
|
|
2490
2536
|
}[];
|
|
2491
2537
|
/**
|
|
2492
2538
|
* Specifies D1 databases that are bound to this Worker environment.
|
|
@@ -3447,4 +3493,4 @@ interface EnvironmentMap {
|
|
|
3447
3493
|
}
|
|
3448
3494
|
declare const defaultWranglerConfig: Config;
|
|
3449
3495
|
|
|
3450
|
-
export { type
|
|
3496
|
+
export { type CfMediaBinding as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectExport as D, type Exports as E, type DockerConfiguration as F, type ContainerEngine as G, type CfScriptFormat as H, type CfModuleType as I, type CfModule as J, type CfVars as K, type Logger as L, type CfKvNamespace as M, type CfSendEmailBindings as N, type Observability as O, type PreviewsConfig as P, type CfWasmModuleBindings as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfTextBlobBindings as V, type WorkerEntrypointExport as W, type CfBrowserBinding as X, type CfAIBinding as Y, type ZoneIdRoute as Z, type CfImagesBinding as _, type RedirectedRawConfig as a, type Hook as a$, type CfStreamBinding as a0, type CfVersionMetadataBinding as a1, type CfDataBlobBindings as a2, type CfDurableObject as a3, type CfWorkflow as a4, type CfQueue as a5, type CfR2Bucket as a6, type CfD1Database as a7, type CfVectorize as a8, type CfAISearchNamespace as a9, type CfPlacement as aA, type CfTailConsumer as aB, type CfUserLimits as aC, type CfWorkerInit as aD, type CfWorkerContext as aE, type CfWorkerSourceMap as aF, type Json as aG, type AssetConfigMetadata as aH, type AssetsOptions as aI, type ValidatedAssetsOptions as aJ, type LegacyAssetPaths as aK, type WorkerMetadata as aL, type ExportsReconciliationEntryBase as aM, type ExportsReconciliationInfo as aN, type ExportsReconciliationWarning as aO, type ExportsReconciliationErrorDetail as aP, type ExportsReconciliationRename as aQ, type ExportsReconciliationTransfer as aR, type ExportsReconciliationTransferPending as aS, type ExportsReconciliationResult as aT, type ServiceMetadataRes as aU, type ServiceFetch as aV, type File as aW, type BinaryFile as aX, type Trigger as aY, type CfAccount as aZ, type HookValues as a_, type CfAISearch as aa, type CfWebSearch as ab, type CfAgentMemory as ac, type CfSecretsStoreSecrets as ad, type CfArtifacts as ae, type CfHelloWorld as af, type CfFlagship as ag, type CfWorkerLoader as ah, type CfRateLimit as ai, type CfHyperdrive as aj, type CfDevPluginCfg as ak, type CfService as al, type CfVpcService as am, type CfVpcNetwork as an, type CfAnalyticsEngineDataset as ao, type CfDispatchNamespace as ap, type CfMTlsCertificate as aq, type CfLogfwdr as ar, type CfLogfwdrBinding as as, type CfAssetsBinding as at, type CfPipeline as au, type CfUnsafeBinding as av, type CfCapnp as aw, type CfUnsafe as ax, type CfDurableObjectMigrations as ay, type CfExports as az, type Config as b, hasMorePages as b$, type AsyncHook as b0, type LogLevel as b1, type NodeJSCompatMode as b2, type StartDevWorkerInput as b3, type Entry as b4, INHERIT_SYMBOL as b5, SERVICE_TAG_PREFIX as b6, ENVIRONMENT_TAG_PREFIX as b7, PATH_TO_DEPLOY_CONFIG as b8, JSON_CONFIG_FORMATS as b9, getTraceHeader as bA, getDisableConfigWatching as bB, getWranglerHideBanner as bC, getCloudflareEnv as bD, getOpenNextDeployFromEnv as bE, getLocalExplorerEnabledFromEnv as bF, getLocalObservabilityEnabledFromEnv as bG, getBrowserRenderingHeadfulFromEnv as bH, getCfFetchEnabledFromEnv as bI, getCfFetchPathFromEnv as bJ, getWranglerCacheDirFromEnv as bK, getCloudflaredPathFromEnv as bL, type ApiCredentials as bM, type FetchResult as bN, type FetchResultFetcher as bO, type FetchListResultFetcher as bP, type FetchPagedListResultFetcher as bQ, performApiFetchBase as bR, fetchInternalBase as bS, fetchResultBase as bT, fetchListResultBase as bU, truncate as bV, isWAFBlockResponse as bW, parseRetryAfterValue as bX, parseRetryAfterMs as bY, extractWAFBlockRayId as bZ, extractAccountTag as b_, getC3CommandFromEnv as ba, getWranglerSendMetricsFromEnv as bb, getWranglerSendErrorReportsFromEnv as bc, getCloudflareApiEnvironmentFromEnv as bd, type ComplianceConfig as be, COMPLIANCE_REGION_CONFIG_PUBLIC as bf, COMPLIANCE_REGION_CONFIG_UNKNOWN as bg, getCloudflareComplianceRegion as bh, getCloudflareApiBaseUrl as bi, getComplianceRegionSubdomain as bj, getSanitizeLogs as bk, getOutputFileDirectoryFromEnv as bl, getOutputFilePathFromEnv as bm, getCIMatchTag as bn, getCIOverrideName as bo, getCIOverrideNetworkModeHost as bp, getCIGeneratePreviewAlias as bq, getWorkersCIBranchName as br, getBuildConditionsFromEnv as bs, getBuildPlatformFromEnv as bt, getRegistryPath as bu, getD1ExtraLocationChoices as bv, getDockerPath as bw, getSubdomainMixedStateCheckDisabled as bx, getCloudflareLoadDevVarsFromDotEnv as by, getCloudflareIncludeProcessEnvFromEnv as bz, type WorkerMetadataBinding as c, renderError as c0, addAuthorizationHeader as c1, throwFetchError as c2, fetchKVGetValueBase as c3, type FetchKVGetValueFetcher as c4, hasCursor as c5, maybeAddTraceHeader as c6, type Route as d, type RawDevConfig as e, type ConfigFields as f, type RawEnvironment as g, defaultWranglerConfig as h, LOGGER_LEVELS as i, type LoggerLevel as j, type Environment as k, type LocalS3Credentials as l, type ZoneNameRoute as m, type CustomDomainRoute as n, type CloudchamberConfig as o, type ContainerApp as p, type DurableObjectMigration as q, type DurableObjectExportStorage as r, type ConfiguredExport as s, type DurableObjectBindings as t, type WorkflowBinding as u, type EnvironmentNonInheritable as v, type Rule as w, type ConfigModuleRuleType as x, type DispatchNamespaceOutbound as y, type CacheOptions as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 WorkerMetadataBinding, L as Logger, d as Route } from './config-
|
|
2
|
-
export {
|
|
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 WorkerMetadataBinding, L as Logger, d as Route } from './config-BEcnaWpD.mjs';
|
|
2
|
+
export { bM as ApiCredentials, aH as AssetConfigMetadata, A as Assets, aI as AssetsOptions, b0 as AsyncHook, aX as BinaryFile, bf as COMPLIANCE_REGION_CONFIG_PUBLIC, bg as COMPLIANCE_REGION_CONFIG_UNKNOWN, z as CacheOptions, Y as CfAIBinding, aa as CfAISearch, a9 as CfAISearchNamespace, aZ as CfAccount, ac as CfAgentMemory, ao as CfAnalyticsEngineDataset, ae as CfArtifacts, at as CfAssetsBinding, X as CfBrowserBinding, aw as CfCapnp, a7 as CfD1Database, a2 as CfDataBlobBindings, ak as CfDevPluginCfg, ap as CfDispatchNamespace, a3 as CfDurableObject, ay as CfDurableObjectMigrations, az as CfExports, ag as CfFlagship, af as CfHelloWorld, aj as CfHyperdrive, _ as CfImagesBinding, M as CfKvNamespace, ar as CfLogfwdr, as as CfLogfwdrBinding, aq as CfMTlsCertificate, $ as CfMediaBinding, J as CfModule, I as CfModuleType, au as CfPipeline, aA as CfPlacement, a5 as CfQueue, a6 as CfR2Bucket, ai as CfRateLimit, H as CfScriptFormat, ad as CfSecretsStoreSecrets, N as CfSendEmailBindings, al as CfService, a0 as CfStreamBinding, aB as CfTailConsumer, V as CfTextBlobBindings, ax as CfUnsafe, av as CfUnsafeBinding, aC as CfUserLimits, K as CfVars, a8 as CfVectorize, a1 as CfVersionMetadataBinding, an as CfVpcNetwork, am as CfVpcService, Q as CfWasmModuleBindings, ab as CfWebSearch, aE as CfWorkerContext, aD as CfWorkerInit, ah as CfWorkerLoader, aF as CfWorkerSourceMap, a4 as CfWorkflow, o as CloudchamberConfig, be as ComplianceConfig, f as ConfigFields, x as ConfigModuleRuleType, s as ConfiguredExport, p as ContainerApp, G as ContainerEngine, n as CustomDomainRoute, y as DispatchNamespaceOutbound, F as DockerConfiguration, t as DurableObjectBindings, r as DurableObjectExportStorage, q as DurableObjectMigration, b7 as ENVIRONMENT_TAG_PREFIX, b4 as Entry, k as Environment, v as EnvironmentNonInheritable, aM as ExportsReconciliationEntryBase, aP as ExportsReconciliationErrorDetail, aN as ExportsReconciliationInfo, aQ as ExportsReconciliationRename, aT as ExportsReconciliationResult, aR as ExportsReconciliationTransfer, aS as ExportsReconciliationTransferPending, aO as ExportsReconciliationWarning, c4 as FetchKVGetValueFetcher, bP as FetchListResultFetcher, bQ as FetchPagedListResultFetcher, bN as FetchResult, bO as FetchResultFetcher, aW as File, a$ as Hook, a_ as HookValues, b5 as INHERIT_SYMBOL, b9 as JSON_CONFIG_FORMATS, aG as Json, i as LOGGER_LEVELS, aK as LegacyAssetPaths, l as LocalS3Credentials, b1 as LogLevel, j as LoggerLevel, b2 as NodeJSCompatMode, O as Observability, b8 as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, e as RawDevConfig, g as RawEnvironment, a as RedirectedRawConfig, w as Rule, b6 as SERVICE_TAG_PREFIX, aV as ServiceFetch, aU as ServiceMetadataRes, b3 as StartDevWorkerInput, S as StreamingTailConsumer, T as TailConsumer, aY as Trigger, U as UserLimits, aJ as ValidatedAssetsOptions, aL as WorkerMetadata, u as WorkflowBinding, Z as ZoneIdRoute, m as ZoneNameRoute, c1 as addAuthorizationHeader, h as defaultWranglerConfig, b_ as extractAccountTag, bZ as extractWAFBlockRayId, bS as fetchInternalBase, c3 as fetchKVGetValueBase, bU as fetchListResultBase, bT as fetchResultBase, bH as getBrowserRenderingHeadfulFromEnv, bs as getBuildConditionsFromEnv, bt as getBuildPlatformFromEnv, ba as getC3CommandFromEnv, bq as getCIGeneratePreviewAlias, bn as getCIMatchTag, bo as getCIOverrideName, bp as getCIOverrideNetworkModeHost, bI as getCfFetchEnabledFromEnv, bJ as getCfFetchPathFromEnv, bi as getCloudflareApiBaseUrl, bd as getCloudflareApiEnvironmentFromEnv, bh as getCloudflareComplianceRegion, bD as getCloudflareEnv, bz as getCloudflareIncludeProcessEnvFromEnv, by as getCloudflareLoadDevVarsFromDotEnv, bL as getCloudflaredPathFromEnv, bj as getComplianceRegionSubdomain, bv as getD1ExtraLocationChoices, bB as getDisableConfigWatching, bw as getDockerPath, bF as getLocalExplorerEnabledFromEnv, bG as getLocalObservabilityEnabledFromEnv, bE as getOpenNextDeployFromEnv, bl as getOutputFileDirectoryFromEnv, bm as getOutputFilePathFromEnv, bu as getRegistryPath, bk as getSanitizeLogs, bx as getSubdomainMixedStateCheckDisabled, bA as getTraceHeader, br as getWorkersCIBranchName, bK as getWranglerCacheDirFromEnv, bC as getWranglerHideBanner, bc as getWranglerSendErrorReportsFromEnv, bb as getWranglerSendMetricsFromEnv, c5 as hasCursor, b$ as hasMorePages, bW as isWAFBlockResponse, c6 as maybeAddTraceHeader, bY as parseRetryAfterMs, bX as parseRetryAfterValue, bR as performApiFetchBase, c0 as renderError, c2 as throwFetchError, bV as truncate } from './config-BEcnaWpD.mjs';
|
|
3
3
|
import * as jsoncParser from 'jsonc-parser';
|
|
4
4
|
export { constructWranglerConfig } from './browser.mjs';
|
|
5
5
|
export { GetGlobalConfigPathOptions, getGlobalConfigPath, getGlobalWranglerCachePath } from './global-wrangler-config-path.mjs';
|
|
@@ -283,8 +283,14 @@ declare class APIError extends ParseError {
|
|
|
283
283
|
meta?: {
|
|
284
284
|
details?: unknown;
|
|
285
285
|
} & Record<string, unknown>;
|
|
286
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Optional number of milliseconds the API asked us to wait before retrying,
|
|
288
|
+
* derived from the response's `Retry-After` header (if present).
|
|
289
|
+
*/
|
|
290
|
+
retryAfterMs?: number;
|
|
291
|
+
constructor({ status, retryAfterMs, ...rest }: MessageInit & {
|
|
287
292
|
status?: number;
|
|
293
|
+
retryAfterMs?: number;
|
|
288
294
|
});
|
|
289
295
|
get status(): number | undefined;
|
|
290
296
|
isGatewayError(): boolean;
|
|
@@ -560,6 +566,8 @@ type VariableNames =
|
|
|
560
566
|
| "CLOUDFLARE_AUTH_USE_KEYRING"
|
|
561
567
|
/** Enable the local explorer UI at /cdn-cgi/explorer (experimental, default: false). */
|
|
562
568
|
| "X_LOCAL_EXPLORER"
|
|
569
|
+
/** Enable local-dev observability capture (experimental, default: false). */
|
|
570
|
+
| "X_LOCAL_OBSERVABILITY"
|
|
563
571
|
/** Open the browser in headful (visible) mode when using the Browser Run API in local dev (default: false). */
|
|
564
572
|
| "X_BROWSER_HEADFUL"
|
|
565
573
|
/** Override command used by `wrangler init` (default: "create cloudflare"). */
|
|
@@ -1016,9 +1024,29 @@ declare function getWorkerName(projectOrWorkerName: string | undefined, projectP
|
|
|
1016
1024
|
*/
|
|
1017
1025
|
declare function getWorkerNameFromProject(projectPath: string): string;
|
|
1018
1026
|
|
|
1027
|
+
type DiscriminatedPath<Discriminator extends string> = string & {
|
|
1028
|
+
_discriminator: Discriminator;
|
|
1029
|
+
};
|
|
1030
|
+
/**
|
|
1031
|
+
* A branded string that expects to be URL compatible.
|
|
1032
|
+
*
|
|
1033
|
+
* Require this type when you want callers to ensure that they have converted file-path strings into URL-safe paths.
|
|
1034
|
+
*/
|
|
1035
|
+
type UrlPath = DiscriminatedPath<"UrlPath">;
|
|
1036
|
+
/**
|
|
1037
|
+
* Convert a file-path string to a URL-path string.
|
|
1038
|
+
*
|
|
1039
|
+
* Use this helper to convert a `string` to a `UrlPath` when it is not clear whether the string needs normalizing.
|
|
1040
|
+
* Replaces all back-slashes with forward-slashes, and throws an error if the path contains a drive letter (e.g. `C:`).
|
|
1041
|
+
*
|
|
1042
|
+
* @param filePath - The file path to convert
|
|
1043
|
+
* @returns The URL-safe path
|
|
1044
|
+
*/
|
|
1045
|
+
declare function toUrlPath(filePath: string): UrlPath;
|
|
1046
|
+
|
|
1019
1047
|
/**
|
|
1020
1048
|
* @deprecated new code should use getBindingTypeFriendlyName() instead
|
|
1021
1049
|
*/
|
|
1022
1050
|
declare const friendlyBindingNames: Record<ConfigBindingFieldName, string>;
|
|
1023
1051
|
|
|
1024
|
-
export { APIError, Binding, type BindingLocalSupport, BunPackageManager, CommandLineArgsError, type CompatDate, Config, type ConfigBindingFieldName, type ConfigBindingOptions, type ConfigCache, type ConfigCacheOptions, DeprecationError, Diagnostics, DurableObjectExport, type EphemeralDirectory, type ExportType, Exports, FatalError, JsonFriendlyFatalError, type Location, Logger, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, NpmPackageManager, type NpmVersionCheckResult, NubPackageManager, type PackageJSON, type PackageManager, ParseError, type ParseFile, type PartitionedExports, PatchConfigError, PnpmPackageManager, RawConfig, type ResolveConfigPathOptions, Route, type TelemetryMessage, type Tunnel, type TunnelOptions, UserError, WorkerEntrypointExport, WorkerMetadataBinding, YarnPackageManager, assertNever, bucketFormatMessage, checkWorkerNameValidity, configFileName, configFormat, createConfigCache, createFatalError, experimental_patchConfig, experimental_readRawConfig, fetchLatestNpmVersion, findWranglerConfig, formatConfigSnippet, formatTime, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getPackagePath, getTodaysCompatDate, getWorkerName, getWorkerNameFromProject, getWranglerHiddenDirPath, getWranglerTmpDir, getZoneFromRoute, hasDurableObjectExports, hasProperty, indexLocation, isCI, isCompatDate, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, openInBrowser, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, retryOnAPIFailure, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, toValidWorkerName, validatePagesConfig };
|
|
1052
|
+
export { APIError, Binding, type BindingLocalSupport, BunPackageManager, CommandLineArgsError, type CompatDate, Config, type ConfigBindingFieldName, type ConfigBindingOptions, type ConfigCache, type ConfigCacheOptions, DeprecationError, Diagnostics, DurableObjectExport, type EphemeralDirectory, type ExportType, Exports, FatalError, JsonFriendlyFatalError, type Location, Logger, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, NpmPackageManager, type NpmVersionCheckResult, NubPackageManager, type PackageJSON, type PackageManager, ParseError, type ParseFile, type PartitionedExports, PatchConfigError, PnpmPackageManager, RawConfig, type ResolveConfigPathOptions, Route, type TelemetryMessage, type Tunnel, type TunnelOptions, type UrlPath, UserError, WorkerEntrypointExport, WorkerMetadataBinding, YarnPackageManager, assertNever, bucketFormatMessage, checkWorkerNameValidity, configFileName, configFormat, createConfigCache, createFatalError, experimental_patchConfig, experimental_readRawConfig, fetchLatestNpmVersion, findWranglerConfig, formatConfigSnippet, formatTime, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getPackagePath, getTodaysCompatDate, getWorkerName, getWorkerNameFromProject, getWranglerHiddenDirPath, getWranglerTmpDir, getZoneFromRoute, hasDurableObjectExports, hasProperty, indexLocation, isCI, isCompatDate, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, openInBrowser, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, retryOnAPIFailure, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, toUrlPath, toValidWorkerName, validatePagesConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ export { assertNever, constructWranglerConfig, getTodaysCompatDate, isCompatDate
|
|
|
2
2
|
import { getGlobalConfigPath } from './chunk-34VZWBGB.mjs';
|
|
3
3
|
export { getGlobalConfigPath, getGlobalWranglerCachePath } from './chunk-34VZWBGB.mjs';
|
|
4
4
|
export { MetricsRegistry } from './chunk-Z62CVNHJ.mjs';
|
|
5
|
-
import { partitionExports, UserError,
|
|
6
|
-
export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-
|
|
5
|
+
import { partitionExports, UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, FatalError, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, dir, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-3K53PSCY.mjs';
|
|
6
|
+
export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-3K53PSCY.mjs';
|
|
7
7
|
import { isDirectory, removeDirSync } from './chunk-53IMCORZ.mjs';
|
|
8
8
|
export { isDirectory, removeDir, removeDirSync } from './chunk-53IMCORZ.mjs';
|
|
9
9
|
import { __commonJS, __name, __require, __export, __toESM } from './chunk-Q72B4Q5Z.mjs';
|
|
@@ -18,6 +18,7 @@ import { fetch, Headers, FormData, Response } from 'undici';
|
|
|
18
18
|
import { URLSearchParams } from 'node:url';
|
|
19
19
|
import * as timersPromises from 'node:timers/promises';
|
|
20
20
|
import { setTimeout as setTimeout$1 } from 'node:timers/promises';
|
|
21
|
+
import { assert as assert$1 } from 'node:console';
|
|
21
22
|
|
|
22
23
|
// ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json
|
|
23
24
|
var require_vendors = __commonJS({
|
|
@@ -16992,6 +16993,10 @@ var getLocalExplorerEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
|
16992
16993
|
variableName: "X_LOCAL_EXPLORER",
|
|
16993
16994
|
defaultValue: true
|
|
16994
16995
|
});
|
|
16996
|
+
var getLocalObservabilityEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
16997
|
+
variableName: "X_LOCAL_OBSERVABILITY",
|
|
16998
|
+
defaultValue: false
|
|
16999
|
+
});
|
|
16995
17000
|
var getBrowserRenderingHeadfulFromEnv = getBooleanEnvironmentVariableFactory({
|
|
16996
17001
|
variableName: "X_BROWSER_HEADFUL",
|
|
16997
17002
|
defaultValue: false
|
|
@@ -17520,14 +17525,21 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
|
|
|
17520
17525
|
const diagnostics = new Diagnostics(
|
|
17521
17526
|
`Processing ${configPath ? path2__default.relative(process.cwd(), configPath) : "wrangler"} configuration:`
|
|
17522
17527
|
);
|
|
17528
|
+
const isRedirectedConfig2 = isRedirectedRawConfig(
|
|
17529
|
+
rawConfig,
|
|
17530
|
+
configPath,
|
|
17531
|
+
userConfigPath
|
|
17532
|
+
);
|
|
17523
17533
|
if ("legacy_env" in rawConfig) {
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17534
|
+
if (!isRedirectedConfig2) {
|
|
17535
|
+
diagnostics.errors.push(
|
|
17536
|
+
dedent`
|
|
17537
|
+
The "legacy_env" field is no longer supported, so please remove it from your configuration file.
|
|
17538
|
+
Service environments have been removed, and each environment is now deployed as its own Worker named "<name>-<environment>". This matches the behaviour of "legacy_env = true", which was the default, so removing the field will not change how your Worker is deployed.
|
|
17539
|
+
Refer to https://developers.cloudflare.com/workers/wrangler/environments/ for more information.
|
|
17540
|
+
`
|
|
17541
|
+
);
|
|
17542
|
+
}
|
|
17531
17543
|
delete rawConfig.legacy_env;
|
|
17532
17544
|
}
|
|
17533
17545
|
validateOptionalProperty(
|
|
@@ -17603,11 +17615,6 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
|
|
|
17603
17615
|
isDispatchNamespace,
|
|
17604
17616
|
preserveOriginalMain
|
|
17605
17617
|
);
|
|
17606
|
-
const isRedirectedConfig2 = isRedirectedRawConfig(
|
|
17607
|
-
rawConfig,
|
|
17608
|
-
configPath,
|
|
17609
|
-
userConfigPath
|
|
17610
|
-
);
|
|
17611
17618
|
const definedEnvironments = Object.keys(rawConfig.env ?? {});
|
|
17612
17619
|
if (isRedirectedConfig2 && definedEnvironments.length > 0) {
|
|
17613
17620
|
diagnostics.errors.push(
|
|
@@ -20592,12 +20599,47 @@ var validateR2Binding = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
|
|
20592
20599
|
if (!isRemoteValid(value, field, diagnostics)) {
|
|
20593
20600
|
isValid = false;
|
|
20594
20601
|
}
|
|
20602
|
+
if (hasProperty(value, "local_dev")) {
|
|
20603
|
+
const localDev = value.local_dev;
|
|
20604
|
+
if (typeof localDev !== "object" || localDev === null) {
|
|
20605
|
+
diagnostics.errors.push(
|
|
20606
|
+
`"${field}" bindings should, optionally, have an object "local_dev" field but got ${JSON.stringify(
|
|
20607
|
+
value
|
|
20608
|
+
)}.`
|
|
20609
|
+
);
|
|
20610
|
+
isValid = false;
|
|
20611
|
+
} else {
|
|
20612
|
+
experimental(
|
|
20613
|
+
diagnostics,
|
|
20614
|
+
{ local_dev: localDev },
|
|
20615
|
+
"local_dev.experimental_s3_credentials"
|
|
20616
|
+
);
|
|
20617
|
+
if (hasProperty(localDev, "experimental_s3_credentials")) {
|
|
20618
|
+
const credentials = localDev.experimental_s3_credentials;
|
|
20619
|
+
if (typeof credentials !== "object" || credentials === null || !isRequiredProperty(credentials, "accessKeyId", "string") || !isRequiredProperty(credentials, "secretAccessKey", "string")) {
|
|
20620
|
+
diagnostics.errors.push(
|
|
20621
|
+
`"${field}" bindings should, optionally, have a "local_dev.experimental_s3_credentials" field with string "accessKeyId" and "secretAccessKey" fields, but got ${JSON.stringify(
|
|
20622
|
+
value
|
|
20623
|
+
)}.`
|
|
20624
|
+
);
|
|
20625
|
+
isValid = false;
|
|
20626
|
+
}
|
|
20627
|
+
}
|
|
20628
|
+
validateAdditionalProperties(
|
|
20629
|
+
diagnostics,
|
|
20630
|
+
`${field}.local_dev`,
|
|
20631
|
+
Object.keys(localDev),
|
|
20632
|
+
["experimental_s3_credentials"]
|
|
20633
|
+
);
|
|
20634
|
+
}
|
|
20635
|
+
}
|
|
20595
20636
|
validateAdditionalProperties(diagnostics, field, Object.keys(value), [
|
|
20596
20637
|
"binding",
|
|
20597
20638
|
"bucket_name",
|
|
20598
20639
|
"preview_bucket_name",
|
|
20599
20640
|
"jurisdiction",
|
|
20600
|
-
"remote"
|
|
20641
|
+
"remote",
|
|
20642
|
+
"local_dev"
|
|
20601
20643
|
]);
|
|
20602
20644
|
return isValid;
|
|
20603
20645
|
}, "validateR2Binding");
|
|
@@ -24052,6 +24094,7 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
|
|
|
24052
24094
|
logHeaders(response.headers, logger);
|
|
24053
24095
|
logger.debugWithSanitization?.("RESPONSE:", jsonText);
|
|
24054
24096
|
logger.debug("-- END CF API RESPONSE");
|
|
24097
|
+
const retryAfterMs = parseRetryAfterMs(response.headers);
|
|
24055
24098
|
if (!jsonText && (response.status === 204 || response.status === 205)) {
|
|
24056
24099
|
return {
|
|
24057
24100
|
response: {
|
|
@@ -24060,7 +24103,8 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
|
|
|
24060
24103
|
errors: [],
|
|
24061
24104
|
messages: []
|
|
24062
24105
|
},
|
|
24063
|
-
status: response.status
|
|
24106
|
+
status: response.status,
|
|
24107
|
+
retryAfterMs
|
|
24064
24108
|
};
|
|
24065
24109
|
}
|
|
24066
24110
|
if (isWAFBlockResponse(response.headers)) {
|
|
@@ -24069,12 +24113,13 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
|
|
|
24069
24113
|
method,
|
|
24070
24114
|
resource,
|
|
24071
24115
|
response.status,
|
|
24072
|
-
response.statusText
|
|
24116
|
+
response.statusText,
|
|
24117
|
+
retryAfterMs
|
|
24073
24118
|
);
|
|
24074
24119
|
}
|
|
24075
24120
|
try {
|
|
24076
24121
|
const json2 = parseJSON(jsonText);
|
|
24077
|
-
return { response: json2, status: response.status };
|
|
24122
|
+
return { response: json2, status: response.status, retryAfterMs };
|
|
24078
24123
|
} catch {
|
|
24079
24124
|
const rayId = extractWAFBlockRayId(response.headers);
|
|
24080
24125
|
throw new APIError({
|
|
@@ -24089,13 +24134,18 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
|
|
|
24089
24134
|
...rayId ? [{ text: `Cloudflare Ray ID: ${rayId}` }] : []
|
|
24090
24135
|
],
|
|
24091
24136
|
status: response.status,
|
|
24137
|
+
retryAfterMs,
|
|
24092
24138
|
telemetryMessage: false
|
|
24093
24139
|
});
|
|
24094
24140
|
}
|
|
24095
24141
|
}
|
|
24096
24142
|
__name(fetchInternalBase, "fetchInternalBase");
|
|
24097
24143
|
async function fetchResultBase(complianceConfig, resource, init = {}, userAgent, logger, queryParams, abortSignal, credentials) {
|
|
24098
|
-
const {
|
|
24144
|
+
const {
|
|
24145
|
+
response: json2,
|
|
24146
|
+
status,
|
|
24147
|
+
retryAfterMs
|
|
24148
|
+
} = await fetchInternalBase(
|
|
24099
24149
|
complianceConfig,
|
|
24100
24150
|
resource,
|
|
24101
24151
|
init,
|
|
@@ -24108,7 +24158,7 @@ async function fetchResultBase(complianceConfig, resource, init = {}, userAgent,
|
|
|
24108
24158
|
if (json2.success) {
|
|
24109
24159
|
return json2.result;
|
|
24110
24160
|
} else {
|
|
24111
|
-
throwFetchError(resource, json2, status);
|
|
24161
|
+
throwFetchError(resource, json2, status, retryAfterMs);
|
|
24112
24162
|
}
|
|
24113
24163
|
}
|
|
24114
24164
|
__name(fetchResultBase, "fetchResultBase");
|
|
@@ -24121,7 +24171,11 @@ async function fetchListResultBase(complianceConfig, resource, init = {}, userAg
|
|
|
24121
24171
|
queryParams = new URLSearchParams(queryParams);
|
|
24122
24172
|
queryParams.set("cursor", cursor);
|
|
24123
24173
|
}
|
|
24124
|
-
const {
|
|
24174
|
+
const {
|
|
24175
|
+
response: json2,
|
|
24176
|
+
status,
|
|
24177
|
+
retryAfterMs
|
|
24178
|
+
} = await fetchInternalBase(
|
|
24125
24179
|
complianceConfig,
|
|
24126
24180
|
resource,
|
|
24127
24181
|
init,
|
|
@@ -24139,7 +24193,7 @@ async function fetchListResultBase(complianceConfig, resource, init = {}, userAg
|
|
|
24139
24193
|
getMoreResults = false;
|
|
24140
24194
|
}
|
|
24141
24195
|
} else {
|
|
24142
|
-
throwFetchError(resource, json2, status);
|
|
24196
|
+
throwFetchError(resource, json2, status, retryAfterMs);
|
|
24143
24197
|
}
|
|
24144
24198
|
}
|
|
24145
24199
|
return results;
|
|
@@ -24157,6 +24211,24 @@ function isWAFBlockResponse(headers) {
|
|
|
24157
24211
|
return headers.get("cf-mitigated") === "challenge";
|
|
24158
24212
|
}
|
|
24159
24213
|
__name(isWAFBlockResponse, "isWAFBlockResponse");
|
|
24214
|
+
function parseRetryAfterValue(retryAfter) {
|
|
24215
|
+
if (!retryAfter) {
|
|
24216
|
+
return void 0;
|
|
24217
|
+
}
|
|
24218
|
+
if (/^\d+$/.test(retryAfter.trim())) {
|
|
24219
|
+
return Number(retryAfter) * 1e3;
|
|
24220
|
+
}
|
|
24221
|
+
const retryAfterDate = new Date(retryAfter);
|
|
24222
|
+
if (!Number.isNaN(retryAfterDate.getTime())) {
|
|
24223
|
+
return Math.max(0, retryAfterDate.getTime() - Date.now());
|
|
24224
|
+
}
|
|
24225
|
+
return void 0;
|
|
24226
|
+
}
|
|
24227
|
+
__name(parseRetryAfterValue, "parseRetryAfterValue");
|
|
24228
|
+
function parseRetryAfterMs(headers) {
|
|
24229
|
+
return parseRetryAfterValue(headers.get("Retry-After"));
|
|
24230
|
+
}
|
|
24231
|
+
__name(parseRetryAfterMs, "parseRetryAfterMs");
|
|
24160
24232
|
function extractWAFBlockRayId(headers) {
|
|
24161
24233
|
return headers.get("cf-ray") ?? void 0;
|
|
24162
24234
|
}
|
|
@@ -24236,7 +24308,7 @@ function escapeCharacter(character) {
|
|
|
24236
24308
|
}).join("");
|
|
24237
24309
|
}
|
|
24238
24310
|
__name(escapeCharacter, "escapeCharacter");
|
|
24239
|
-
function throwFetchError(resource, response, status) {
|
|
24311
|
+
function throwFetchError(resource, response, status, retryAfterMs) {
|
|
24240
24312
|
const errors = response.errors ?? [];
|
|
24241
24313
|
for (const error52 of errors) {
|
|
24242
24314
|
maybeThrowFriendlyError(error52);
|
|
@@ -24254,10 +24326,19 @@ function throwFetchError(resource, response, status) {
|
|
|
24254
24326
|
notes.push({ text: fallbackMessage });
|
|
24255
24327
|
}
|
|
24256
24328
|
}
|
|
24329
|
+
if (retryAfterMs !== void 0) {
|
|
24330
|
+
notes.push({
|
|
24331
|
+
text: `The API responded with a "Retry-After" header indicating you should wait ${Math.ceil(retryAfterMs / 1e3)} second(s) before retrying.`
|
|
24332
|
+
});
|
|
24333
|
+
}
|
|
24257
24334
|
const error51 = new APIError({
|
|
24258
24335
|
text: `A request to the Cloudflare API (${resource}) failed.`,
|
|
24259
24336
|
notes,
|
|
24260
24337
|
status,
|
|
24338
|
+
// hoist the parsed `Retry-After` header (if any) so consumers such as
|
|
24339
|
+
// `retryOnAPIFailure()` can back off for the amount of time the API
|
|
24340
|
+
// asked us to wait, e.g. when rate limited (HTTP 429).
|
|
24341
|
+
retryAfterMs,
|
|
24261
24342
|
telemetryMessage: false
|
|
24262
24343
|
});
|
|
24263
24344
|
const code = errors[0]?.code;
|
|
@@ -24272,7 +24353,7 @@ function throwFetchError(resource, response, status) {
|
|
|
24272
24353
|
throw error51;
|
|
24273
24354
|
}
|
|
24274
24355
|
__name(throwFetchError, "throwFetchError");
|
|
24275
|
-
function throwWAFBlockError(headers, method, resource, status, statusText) {
|
|
24356
|
+
function throwWAFBlockError(headers, method, resource, status, statusText, retryAfterMs) {
|
|
24276
24357
|
const rayId = extractWAFBlockRayId(headers);
|
|
24277
24358
|
throw new APIError({
|
|
24278
24359
|
text: "The Cloudflare API responded with a WAF block page instead of the expected JSON response",
|
|
@@ -24289,6 +24370,7 @@ function throwWAFBlockError(headers, method, resource, status, statusText) {
|
|
|
24289
24370
|
}
|
|
24290
24371
|
],
|
|
24291
24372
|
status,
|
|
24373
|
+
retryAfterMs,
|
|
24292
24374
|
telemetryMessage: false
|
|
24293
24375
|
});
|
|
24294
24376
|
}
|
|
@@ -24401,23 +24483,41 @@ ${url2}`
|
|
|
24401
24483
|
}
|
|
24402
24484
|
__name(handleBrowserOpenError, "handleBrowserOpenError");
|
|
24403
24485
|
var MAX_ATTEMPTS = 3;
|
|
24486
|
+
var MAX_RETRY_AFTER_MS = 6e4;
|
|
24404
24487
|
async function retryOnAPIFailure(action, logger, backoff = 0, attempts = MAX_ATTEMPTS, abortSignal) {
|
|
24405
24488
|
try {
|
|
24406
24489
|
return await action();
|
|
24407
24490
|
} catch (err) {
|
|
24408
24491
|
if (err instanceof APIError) {
|
|
24409
|
-
if (!err.isRetryable()) {
|
|
24492
|
+
if (!err.isRetryable() && err.status !== 429) {
|
|
24410
24493
|
throw err;
|
|
24411
24494
|
}
|
|
24412
24495
|
} else if (err instanceof DOMException && err.name === "TimeoutError") ; else if (!(err instanceof TypeError)) {
|
|
24413
24496
|
throw err;
|
|
24414
24497
|
}
|
|
24415
|
-
|
|
24416
|
-
|
|
24498
|
+
const retryAfterMs = err instanceof APIError ? err.retryAfterMs : void 0;
|
|
24499
|
+
if (retryAfterMs !== void 0 && retryAfterMs > MAX_RETRY_AFTER_MS) {
|
|
24500
|
+
throw err;
|
|
24501
|
+
}
|
|
24417
24502
|
if (attempts <= 1) {
|
|
24418
24503
|
throw err;
|
|
24419
24504
|
}
|
|
24420
|
-
|
|
24505
|
+
const jitter = Math.random() * 1e3;
|
|
24506
|
+
let wait = backoff;
|
|
24507
|
+
if (retryAfterMs !== void 0) {
|
|
24508
|
+
wait = retryAfterMs + jitter;
|
|
24509
|
+
} else if (err instanceof APIError && err.status === 429) {
|
|
24510
|
+
wait = Math.max(backoff, 1e3) + jitter;
|
|
24511
|
+
}
|
|
24512
|
+
if (retryAfterMs !== void 0) {
|
|
24513
|
+
logger.info(
|
|
24514
|
+
`Received a "Retry-After" header from the Cloudflare API. Waiting ${Math.ceil(retryAfterMs / 1e3)} second(s) before retrying...`
|
|
24515
|
+
);
|
|
24516
|
+
} else {
|
|
24517
|
+
logger.debug(`Retrying API call after error...`);
|
|
24518
|
+
logger.debug(err);
|
|
24519
|
+
}
|
|
24520
|
+
await setTimeout$1(wait, void 0, { signal: abortSignal });
|
|
24421
24521
|
return retryOnAPIFailure(
|
|
24422
24522
|
action,
|
|
24423
24523
|
logger,
|
|
@@ -24564,6 +24664,14 @@ function getWorkerNameFromProject(projectPath) {
|
|
|
24564
24664
|
return getWorkerName(packageJsonName, projectPath);
|
|
24565
24665
|
}
|
|
24566
24666
|
__name(getWorkerNameFromProject, "getWorkerNameFromProject");
|
|
24667
|
+
function toUrlPath(filePath) {
|
|
24668
|
+
assert$1(
|
|
24669
|
+
!/^[a-z]:/i.test(filePath),
|
|
24670
|
+
"Tried to convert a Windows file path with a drive to a URL path."
|
|
24671
|
+
);
|
|
24672
|
+
return filePath.replace(/\\/g, "/");
|
|
24673
|
+
}
|
|
24674
|
+
__name(toUrlPath, "toUrlPath");
|
|
24567
24675
|
|
|
24568
24676
|
// src/index.ts
|
|
24569
24677
|
var friendlyBindingNames2 = friendlyBindingNames;
|
|
@@ -24601,4 +24709,4 @@ safe-buffer/index.js:
|
|
|
24601
24709
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
24602
24710
|
*/
|
|
24603
24711
|
|
|
24604
|
-
export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toValidWorkerName, truncate, validatePagesConfig };
|
|
24712
|
+
export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toUrlPath, toValidWorkerName, truncate, validatePagesConfig };
|