import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, CfModule, CfWorkerSourceMap, CfModuleType, Config } from '@cloudflare/workers-utils'; /** * client needs to handle logger and fetch/auth implementation * these are passed into this package to handle any API requests/logs */ type DeployHelpersContext = { fetchResult: FetchResultFetcher; fetchListResult: FetchListResultFetcher; fetchPagedListResult: FetchPagedListResultFetcher; fetchKVGetValue: FetchKVGetValueFetcher; logger: Logger; confirm: (text: string, options?: { defaultValue?: boolean; fallbackValue?: boolean; }) => Promise; prompt: (text: string, options?: { defaultValue?: string; }) => Promise; select: (text: string, options: { choices: { title: string; description?: string; value: Values; }[]; defaultOption?: number; fallbackOption?: number; }) => Promise; }; /** * Shared fields produced by merging CLI args with wrangler config. * After this point, no raw config/arg merging should happen. * * Use props for all resolved/merged values. Only access config directly * for raw values that aren't merged with CLI args (e.g., config.durable_objects, * config.unsafe, config.tail_consumers). */ type SharedDeployVersionsProps = { /** Merged from args.script/config.main/config.site.entry-point/config.assets. */ entry: Entry; /** Merged: --name arg ?? config.name, with CI override applied. Validated as required separately. */ name: string | undefined; /** Merged: --compatibility-date arg ?? config.compatibility_date. Still optional — validated as required later. */ compatibilityDate: string | undefined; /** Merged: --compatibility-flags arg ?? config.compatibility_flags. */ compatibilityFlags: string[]; /** * Validated/resolved assets directory, merged from --assets arg and * config.assets. The full AssetsOptions are resolved later via * `resolveAssetOptions`. */ assetsDir: ValidatedAssetsOptions | undefined; /** * The user Worker entry, merged: --script arg ?? config.main. Undefined for * assets-only Workers. Drives `has_user_worker` when resolving assets. */ main: string | undefined; /** Merged: --keep-vars arg || config.keep_vars. */ keepVars: boolean; /** Merged from --site arg and config.site. */ isWorkersSite: boolean; /** From --dry-run arg. */ dryRun: boolean; /** From --env arg. */ env: string | undefined; /** From --outfile arg. */ outfile: string | undefined; /** From --tag arg. */ tag: string | undefined; /** From --message arg. */ message: string | undefined; /** From --secrets-file arg. */ secretsFile: string | undefined; /** From collectKeyValues(--var arg). CLI-only vars; config vars flow separately via getBindings(config). */ cliVars: Record; /** From --experimental-auto-create arg. */ experimentalAutoCreate: boolean; /** Resolved from requireAuth() before calling deploy-helpers. undefined only in dry-run. */ accountId: string | undefined; /** Resolved from getMetricsUsageHeaders() / config.send_metrics. Controls whether usage metrics headers are sent with upload requests. */ sendMetrics: boolean; /** Resolved from getFlag("RESOURCES_PROVISION"). Controls whether bindings are auto-provisioned before upload. */ resourcesProvision: boolean; /** Controls whether provisioned resource IDs are written back to the config file. */ skipProvisioningConfigWriteback: boolean; /** From --strict arg. In strict mode, conflicting pre-upload checks abort instead of auto-continuing. */ strict: boolean; }; type DeployProps = SharedDeployVersionsProps & { /** Discriminant for DeployProps vs VersionsUploadProps */ command: "deploy"; /** Merged from --site arg and config.site. */ legacyAssetPaths: LegacyAssetPaths | undefined; /** Merged: --triggers arg ?? config.triggers.crons. */ triggers: string[] | undefined; /** Merged: --routes arg ?? config.routes ?? config.route. AND --domains and custom_domains*/ routes: Route[]; /** Merged: --logpush arg ?? config.logpush. */ logpush: boolean | undefined; /** From --dispatch-namespace arg. Deploy-only (Workers for Platforms). */ dispatchNamespace: string | undefined; /** From --old-asset-ttl arg. Deploy-only. */ oldAssetTtl: number | undefined; /** From --containers-rollout arg. Deploy-only. */ containersRollout: "immediate" | "gradual" | "none" | undefined; /** * When true, an existing Worker with the same name aborts the deploy instead * of updating it, because this run cannot confirm the local project owns the * remote Worker. Set for non-interactive deploys with no pre-existing config * file when either the name was generated automatically (no user-supplied * name) or the deploy is the Pages-to-Workers delegation (where the name is a * Pages project name carried across, not proof of Worker ownership). Deploys * that carry a config file naming the Worker leave this false and update it as * normal. */ failIfWorkerNameTaken?: boolean; }; type VersionsUploadProps = SharedDeployVersionsProps & { /** Discriminant for DeployProps vs VersionsUploadProps */ command: "versions upload"; /** CLI-only (--preview-alias), or auto-generated from CI branch name. */ previewAlias: string | undefined; }; type WorkerBuildResult = { modules: CfModule[]; sourceMaps: CfWorkerSourceMap[] | undefined; dependencies: Record; resolvedEntryPointPath: string; bundleType: CfModuleType; content: string; }; interface TriggerDeployment { targets: string[]; error?: Error; } type TriggerProps = { config: Config; accountId: string; scriptName: string; workerTag?: string | null; env: string | undefined; crons: string[] | undefined; routes: Route[]; firstDeploy: boolean; }; /** * Module-level context globals for deploy-helpers. * * These are typed as non-nullable but are undefined until initDeployHelpersContext() * is called. Consumers must import the live binding directly (e.g. `import { logger }`) * and NOT destructure or cache the value at module-load time, otherwise they will * capture `undefined` before init runs. * * Example: * import { logger } from "./context"; // correct: live binding * const { logger } = await import("./context"); // WRONG: captures undefined */ declare let logger: Logger; declare let fetchResult: FetchResultFetcher; declare let fetchListResult: FetchListResultFetcher; declare let fetchPagedListResult: FetchPagedListResultFetcher; declare let fetchKVGetValue: FetchKVGetValueFetcher; declare let confirm: DeployHelpersContext["confirm"]; declare let prompt: DeployHelpersContext["prompt"]; declare let select: DeployHelpersContext["select"]; /** * Set the global context for deploy-helpers. Must be called once at * startup before any deploy-helpers function that needs these values. */ declare function initDeployHelpersContext(ctx: DeployHelpersContext): void; export { type DeployProps as D, type SharedDeployVersionsProps as S, type TriggerProps as T, type VersionsUploadProps as V, type WorkerBuildResult as W, type TriggerDeployment as a, type DeployHelpersContext as b, fetchListResult as c, fetchPagedListResult as d, fetchKVGetValue as e, fetchResult as f, confirm as g, initDeployHelpersContext as i, logger as l, prompt as p, select as s };