@cloudflare/workers-utils 0.33.1 → 0.35.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/browser.mjs +1 -1
- package/dist/chunk-3IYLA2JH.mjs +73 -0
- package/dist/{chunk-IV7UMGT2.mjs → chunk-6VP24PQU.mjs} +1 -1
- package/dist/chunk-7AX24RFK.mjs +265 -0
- package/dist/chunk-C6O4ION7.mjs +42 -0
- package/dist/chunk-MCNIGVAF.mjs +45 -0
- package/dist/{chunk-QFKPUV4H.mjs → chunk-V6JSHOVJ.mjs} +16 -115
- package/dist/chunk-WO2IAW6M.mjs +62 -0
- package/dist/chunk-XUGGRRBO.mjs +178 -0
- package/dist/compatibility-date.d.mts +80 -0
- package/dist/compatibility-date.mjs +2 -0
- package/dist/{config-CRUFg2tu.d.mts → compliance-j3-tqeao.d.mts} +64 -17
- package/dist/compliance.d.mts +4 -0
- package/dist/compliance.mjs +7 -0
- package/dist/docker-path.d.mts +8 -0
- package/dist/docker-path.mjs +3 -0
- package/dist/errors.d.mts +55 -0
- package/dist/errors.mjs +2 -0
- package/dist/index.d.mts +238 -145
- package/dist/index.mjs +1656 -703
- package/dist/metafile-esm.json +1 -1
- package/dist/open-PBXRGS4R.mjs +3 -3
- package/dist/test-helpers/index.d.mts +6 -2
- package/dist/test-helpers/index.mjs +39 -2
- package/dist/zod-format.d.mts +6 -0
- package/dist/zod-format.mjs +2 -0
- package/package.json +24 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
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, L as Logger,
|
|
2
|
-
export { A as ARTIFACTS_EVENT_TYPES,
|
|
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
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';
|
|
4
6
|
export { constructWranglerConfig } from './browser.mjs';
|
|
5
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';
|
|
6
10
|
export { isDirectory, removeDir, removeDirSync } from './fs-helpers.mjs';
|
|
7
11
|
export { Counter, MetricsRegistry } from './prometheus-metrics.mjs';
|
|
8
12
|
import { ChildProcess } from 'node:child_process';
|
|
9
|
-
|
|
13
|
+
export { _forceColour, formatZodError } from './zod-format.mjs';
|
|
14
|
+
export { getDockerPath } from './docker-path.mjs';
|
|
10
15
|
import 'node:url';
|
|
11
16
|
import 'undici';
|
|
12
17
|
import '@cloudflare/workers-shared';
|
|
13
18
|
import 'cloudflare';
|
|
19
|
+
import 'zod';
|
|
14
20
|
|
|
15
21
|
type ResolveConfigPathOptions = {
|
|
16
22
|
useRedirectIfAvailable?: boolean;
|
|
@@ -219,60 +225,6 @@ patch: RawConfig, isArrayInsertion?: boolean) => string;
|
|
|
219
225
|
declare class PatchConfigError extends Error {
|
|
220
226
|
}
|
|
221
227
|
|
|
222
|
-
/**
|
|
223
|
-
* This is used to provide telemetry with a sanitised error
|
|
224
|
-
* message that could not have any user-identifying information.
|
|
225
|
-
* Set to `true` to duplicate `message`.
|
|
226
|
-
* */
|
|
227
|
-
type TelemetryMessage = {
|
|
228
|
-
telemetryMessage: string | boolean;
|
|
229
|
-
};
|
|
230
|
-
type UserErrorOptions = ErrorOptions & TelemetryMessage;
|
|
231
|
-
type FatalErrorOptions = UserErrorOptions & {
|
|
232
|
-
code?: number;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* Base class for errors where the user has done something wrong. These are not
|
|
236
|
-
* reported to Sentry. API errors are intentionally *not* `UserError`s, and are
|
|
237
|
-
* reported to Sentry. This will help us understand which API errors need better
|
|
238
|
-
* messaging.
|
|
239
|
-
*/
|
|
240
|
-
declare class UserError extends Error {
|
|
241
|
-
telemetryMessage: string | undefined;
|
|
242
|
-
constructor(message: string, options: UserErrorOptions);
|
|
243
|
-
}
|
|
244
|
-
declare class DeprecationError extends UserError {
|
|
245
|
-
constructor(message: string, options: TelemetryMessage);
|
|
246
|
-
}
|
|
247
|
-
declare class FatalError extends UserError {
|
|
248
|
-
readonly code: number | undefined;
|
|
249
|
-
constructor(message: string, options: FatalErrorOptions);
|
|
250
|
-
}
|
|
251
|
-
declare class CommandLineArgsError extends UserError {
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* JsonFriendlyFatalError is used to output JSON when wrangler crashes, useful for --json mode.
|
|
255
|
-
*
|
|
256
|
-
* To use, pass stringify'd json into the constructor like so:
|
|
257
|
-
* ```js
|
|
258
|
-
* throw new JsonFriendlyFatalError(JSON.stringify({ error: messageToDisplay }), {
|
|
259
|
-
* telemetryMessage: false,
|
|
260
|
-
* });
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
declare class JsonFriendlyFatalError extends FatalError {
|
|
264
|
-
}
|
|
265
|
-
declare class MissingConfigError extends Error {
|
|
266
|
-
telemetryMessage: string | undefined;
|
|
267
|
-
constructor(key: string);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Create either a FatalError or JsonFriendlyFatalError depending upon `isJson` parameter.
|
|
271
|
-
*
|
|
272
|
-
* If `isJson` is true, then the `message` is JSON stringified.
|
|
273
|
-
*/
|
|
274
|
-
declare function createFatalError(message: unknown, isJson: boolean, options: FatalErrorOptions): Error;
|
|
275
|
-
|
|
276
228
|
type Message = {
|
|
277
229
|
text: string;
|
|
278
230
|
location?: Location;
|
|
@@ -400,7 +352,7 @@ declare function parseByteSize(s: string, base?: number | undefined): number;
|
|
|
400
352
|
|
|
401
353
|
/**
|
|
402
354
|
* Local-dev capability of each binding type. Source of truth for
|
|
403
|
-
* `pickRemoteBindings()` and `
|
|
355
|
+
* `pickRemoteBindings()` and `validateBindingRemoteSetting()`.
|
|
404
356
|
*
|
|
405
357
|
* - `local-and-remote`: local simulator; `remote: true` opts into proxying.
|
|
406
358
|
* - `local-only`: local simulator only; `remote: true` is a config error.
|
|
@@ -413,6 +365,13 @@ declare function parseByteSize(s: string, base?: number | undefined): number;
|
|
|
413
365
|
*/
|
|
414
366
|
type BindingLocalSupport = "local-and-remote" | "local-only" | "remote" | "DO-NOT-USE-this-resource-will-never-have-a-local-simulator";
|
|
415
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;
|
|
416
375
|
|
|
417
376
|
/**
|
|
418
377
|
* Pages now supports configuration via a Wrangler configuration file. As opposed to
|
|
@@ -462,11 +421,14 @@ declare function assertNever(_value: never): void;
|
|
|
462
421
|
/**
|
|
463
422
|
* Resolves the filesystem path for an installed npm package.
|
|
464
423
|
*
|
|
465
|
-
* Tries
|
|
466
|
-
* 1. `require.resolve("<pkg>/package.json")`
|
|
467
|
-
* 2. `require.resolve("<pkg>")`
|
|
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`
|
|
468
430
|
*
|
|
469
|
-
* @param packageName - The npm package name to resolve
|
|
431
|
+
* @param packageName - The npm package name to resolve (supports scoped packages like `@scope/pkg`)
|
|
470
432
|
* @param projectPath - The project directory to resolve from
|
|
471
433
|
* @returns The resolved directory path, or `undefined` if the package is not installed
|
|
472
434
|
*/
|
|
@@ -503,6 +465,63 @@ declare function getInstalledPackageVersion(packageName: string, projectPath: st
|
|
|
503
465
|
*/
|
|
504
466
|
declare function mapWorkerMetadataBindings(bindings: WorkerMetadataBinding[]): RawConfig;
|
|
505
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
|
+
|
|
506
525
|
/**
|
|
507
526
|
* Environment variables supported by Wrangler for configuration and authentication.
|
|
508
527
|
* Each variable is documented with its individual JSDoc comment below.
|
|
@@ -672,85 +691,6 @@ declare function getEnvironmentVariableFactory<Choices extends readonly string[]
|
|
|
672
691
|
readonly choices?: Choices;
|
|
673
692
|
}): () => ElementType<Choices>;
|
|
674
693
|
|
|
675
|
-
type YYYY = `${number}${number}${number}${number}`;
|
|
676
|
-
type MM = `${number}${number}`;
|
|
677
|
-
type DD = `${number}${number}`;
|
|
678
|
-
/**
|
|
679
|
-
* Represents a valid compatibility date, a string such as `2025-09-27`
|
|
680
|
-
*/
|
|
681
|
-
type CompatDate = `${YYYY}-${MM}-${DD}`;
|
|
682
|
-
/**
|
|
683
|
-
* Discern whether a string represents a compatibility date (`YYYY-MM-DD`)
|
|
684
|
-
*
|
|
685
|
-
* @param str The target string
|
|
686
|
-
* @returns true if the string represents a compatibility date, false otherwise
|
|
687
|
-
*/
|
|
688
|
-
declare function isCompatDate(str: string): str is CompatDate;
|
|
689
|
-
/**
|
|
690
|
-
* Returns today's date as a compatibility date string (`YYYY-MM-DD`).
|
|
691
|
-
*/
|
|
692
|
-
declare function getTodaysCompatDate(): CompatDate;
|
|
693
|
-
/**
|
|
694
|
-
* The compatibility date on which the `nodejs_compat` and `nodejs_compat_v2`
|
|
695
|
-
* compatibility flags became enabled by default in workerd.
|
|
696
|
-
*
|
|
697
|
-
* From this date onwards, specifying either flag explicitly is a validation
|
|
698
|
-
* error ("The compatibility flag nodejs_compat became the default as of
|
|
699
|
-
* 2026-08-04 so does not need to be specified anymore"), so tooling must not
|
|
700
|
-
* add them to configurations using such a compatibility date.
|
|
701
|
-
*
|
|
702
|
-
* @see https://github.com/cloudflare/workerd/blob/main/src/workerd/io/compatibility-date.capnp
|
|
703
|
-
*/
|
|
704
|
-
declare const NODEJS_COMPAT_DEFAULT_ON_DATE = "2026-08-04";
|
|
705
|
-
/**
|
|
706
|
-
* Whether workerd enables Node.js compatibility by default for the given
|
|
707
|
-
* compatibility date, i.e. without the `nodejs_compat` flag being specified.
|
|
708
|
-
*
|
|
709
|
-
* @param compatibilityDate The compatibility date to check
|
|
710
|
-
* @returns true if the date is on or after {@link NODEJS_COMPAT_DEFAULT_ON_DATE}
|
|
711
|
-
*/
|
|
712
|
-
declare function isNodejsCompatDefaultOn(compatibilityDate: string | undefined): boolean;
|
|
713
|
-
/**
|
|
714
|
-
* The compatibility date on which `nodejs_compat` started implying
|
|
715
|
-
* `nodejs_compat_v2`.
|
|
716
|
-
*/
|
|
717
|
-
declare const NODEJS_COMPAT_V2_SWITCH_OVER_DATE = "2024-09-23";
|
|
718
|
-
/**
|
|
719
|
-
* Resolves whether workerd will enable the `nodejs_compat` and
|
|
720
|
-
* `nodejs_compat_v2` features, mirroring how workerd itself resolves them from
|
|
721
|
-
* the compatibility date and flags:
|
|
722
|
-
* - Both are enabled by default from {@link NODEJS_COMPAT_DEFAULT_ON_DATE}
|
|
723
|
-
* onwards, and each must be turned off separately from that date, with
|
|
724
|
-
* `no_nodejs_compat` and `no_nodejs_compat_v2` respectively.
|
|
725
|
-
* - Before that date, `nodejs_compat` implies `nodejs_compat_v2` from
|
|
726
|
-
* {@link NODEJS_COMPAT_V2_SWITCH_OVER_DATE} onwards.
|
|
727
|
-
*
|
|
728
|
-
* @param compatibilityDate The compatibility date
|
|
729
|
-
* @param compatibilityFlags The compatibility flags
|
|
730
|
-
*/
|
|
731
|
-
declare function resolveNodejsCompat(compatibilityDate: string, compatibilityFlags: string[]): {
|
|
732
|
-
isNodejsCompatEnabled: boolean;
|
|
733
|
-
isNodejsCompatV2Enabled: boolean;
|
|
734
|
-
};
|
|
735
|
-
/**
|
|
736
|
-
* Removes the `nodejs_compat` and `nodejs_compat_v2` flags from a list of
|
|
737
|
-
* compatibility flags when the compatibility date already enables them.
|
|
738
|
-
*
|
|
739
|
-
* workerd rejects a compatibility flag that its compatibility date enables by
|
|
740
|
-
* default, so from {@link NODEJS_COMPAT_DEFAULT_ON_DATE} onwards specifying
|
|
741
|
-
* either flag stops a Worker from starting up. Removing them is a no-op for
|
|
742
|
-
* such a date, so tooling can accept the redundant flags rather than failing.
|
|
743
|
-
*
|
|
744
|
-
* A flag is kept when its matching opt-out is specified too, since workerd
|
|
745
|
-
* reports those as contradictory and the enable flag wins there - dropping it
|
|
746
|
-
* would silently switch Node.js compatibility off instead.
|
|
747
|
-
*
|
|
748
|
-
* @param compatibilityDate The compatibility date
|
|
749
|
-
* @param compatibilityFlags The compatibility flags
|
|
750
|
-
* @returns The flags, without the ones the date makes redundant
|
|
751
|
-
*/
|
|
752
|
-
declare function stripRedundantNodejsCompatFlags(compatibilityDate: string | undefined, compatibilityFlags: string[]): string[];
|
|
753
|
-
|
|
754
694
|
/**
|
|
755
695
|
* The compatibility date to use when the user has not specified one.
|
|
756
696
|
*
|
|
@@ -979,6 +919,162 @@ declare function isCI(): boolean;
|
|
|
979
919
|
*/
|
|
980
920
|
declare function openInBrowser(url: string, logger: Logger): Promise<void>;
|
|
981
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
|
+
|
|
982
1078
|
declare function retryOnAPIFailure<T>(action: () => T | Promise<T>, logger: Logger, backoff?: number, attempts?: number, abortSignal?: AbortSignal): Promise<T>;
|
|
983
1079
|
|
|
984
1080
|
declare function formatTime(duration: number): string;
|
|
@@ -1139,9 +1235,6 @@ declare function getWorkerName(projectOrWorkerName: string | undefined, projectP
|
|
|
1139
1235
|
*/
|
|
1140
1236
|
declare function getWorkerNameFromProject(projectPath: string): string;
|
|
1141
1237
|
|
|
1142
|
-
declare function _forceColour(enabled?: boolean): void;
|
|
1143
|
-
declare function formatZodError(error: z.ZodError, input: unknown): string;
|
|
1144
|
-
|
|
1145
1238
|
type DiscriminatedPath<Discriminator extends string> = string & {
|
|
1146
1239
|
_discriminator: Discriminator;
|
|
1147
1240
|
};
|
|
@@ -1167,4 +1260,4 @@ declare function toUrlPath(filePath: string): UrlPath;
|
|
|
1167
1260
|
*/
|
|
1168
1261
|
declare const friendlyBindingNames: Record<ConfigBindingFieldName, string>;
|
|
1169
1262
|
|
|
1170
|
-
export { APIError, Binding, type BindingLocalSupport, BunPackageManager,
|
|
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 };
|