@cloudflare/deploy-helpers 0.7.1 → 0.8.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.
@@ -1,4 +1,4 @@
1
- import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, CfModule, CfWorkerSourceMap, CfModuleType, Config } from '@cloudflare/workers-utils';
1
+ import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, Config, CfModule, CfWorkerSourceMap, CfModuleType } from '@cloudflare/workers-utils';
2
2
 
3
3
  /**
4
4
  * client needs to handle logger and fetch/auth implementation
@@ -85,6 +85,8 @@ type SharedDeployVersionsProps = {
85
85
  skipProvisioningConfigWriteback: boolean;
86
86
  /** From --strict arg. In strict mode, conflicting pre-upload checks abort instead of auto-continuing. */
87
87
  strict: boolean;
88
+ /** Whether the resolved Worker name differs from the pre-merge config/args name. */
89
+ workerNameOverridden?: boolean;
88
90
  };
89
91
  type DeployProps = SharedDeployVersionsProps & {
90
92
  /** Discriminant for DeployProps vs VersionsUploadProps */
@@ -141,13 +143,14 @@ interface TriggerDeployment {
141
143
  }
142
144
  type TriggerProps = {
143
145
  config: Config;
144
- accountId: string;
146
+ accountId: string | undefined;
145
147
  scriptName: string;
146
148
  workerTag?: string | null;
147
- env: string | undefined;
148
149
  crons: string[] | undefined;
149
150
  routes: Route[];
150
151
  firstDeploy: boolean;
152
+ dryRun: boolean;
153
+ validated: boolean;
151
154
  };
152
155
 
153
156
  /**
@@ -176,4 +179,4 @@ declare let select: DeployHelpersContext["select"];
176
179
  */
177
180
  declare function initDeployHelpersContext(ctx: DeployHelpersContext): void;
178
181
 
179
- 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 };
182
+ 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, confirm as c, fetchListResult as d, fetchPagedListResult as e, fetchKVGetValue as f, fetchResult as g, initDeployHelpersContext as i, logger as l, prompt as p, select as s };
@@ -1,2 +1,2 @@
1
- export { g as confirm, e as fetchKVGetValue, c as fetchListResult, d as fetchPagedListResult, f as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-DPzCSVQh.mjs';
1
+ export { c as confirm, f as fetchKVGetValue, d as fetchListResult, e as fetchPagedListResult, g as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-nFHuelHB.mjs';
2
2
  import '@cloudflare/workers-utils';
@@ -1,5 +1,5 @@
1
1
  import { FormData } from 'undici';
2
- import { CfModuleType, CfWorkerInit, Binding, CfCapnp } from '@cloudflare/workers-utils';
2
+ import { CfWorkerInit, Binding, CfCapnp, CfModuleType } from '@cloudflare/workers-utils';
3
3
 
4
4
  declare const moduleTypeMimeType: {
5
5
  [type in CfModuleType]: string | undefined;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { S as SharedDeployVersionsProps, D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-DPzCSVQh.mjs';
2
- export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-DPzCSVQh.mjs';
1
+ import { S as SharedDeployVersionsProps, D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-nFHuelHB.mjs';
2
+ export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-nFHuelHB.mjs';
3
3
  import * as _cloudflare_workers_utils from '@cloudflare/workers-utils';
4
- import { ComplianceConfig, Config, AssetsOptions, LegacyAssetPaths, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, Binding as Binding$1, RawConfig, ConfigBindingFieldName, CfCapnp, CfScriptFormat, CfModule, ParseError, WorkerMetadataBinding, CfUserLimits, TailConsumer, StreamingTailConsumer, Observability, CfWorkerInit, ExportsReconciliationResult, ExportsReconciliationErrorDetail, StartDevWorkerInput, CfTailConsumer, ContainerApp, CacheOptions } from '@cloudflare/workers-utils';
4
+ import { Config, AssetsOptions, ComplianceConfig, LegacyAssetPaths, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, Binding as Binding$1, RawConfig, ConfigBindingFieldName, CfCapnp, CfScriptFormat, CfModule, ParseError, WorkerMetadataBinding, CfUserLimits, TailConsumer, StreamingTailConsumer, Observability, CfWorkerInit, ExportsReconciliationErrorDetail, ExportsReconciliationResult, StartDevWorkerInput, CfTailConsumer, ContainerApp, CacheOptions, PreviewsConfig } from '@cloudflare/workers-utils';
5
5
  import { ContainerNormalizedConfig, ImageURIConfig } from '@cloudflare/containers-shared';
6
6
  import { FormData } from 'undici';
7
7
  export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType } from './create-worker-upload-form.mjs';
@@ -54,22 +54,24 @@ type DeployCallbacks = {
54
54
  }) => Promise<void>) | undefined;
55
55
  analyseBundle: ((workerBundle: string | FormData) => Promise<Record<string, unknown>>) | undefined;
56
56
  };
57
- declare function deploy(props: DeployProps, config: Config, buildResult: WorkerBuildResult, callbacks: DeployCallbacks): Promise<{
57
+ type DeployResult = {
58
58
  sourceMapSize?: number;
59
59
  versionId: string | null;
60
60
  workerTag: string | null;
61
61
  assetUploadStats?: AssetUploadStats;
62
62
  targets?: string[];
63
- }>;
63
+ };
64
+ declare function deploy(props: DeployProps, config: Config, buildResult: WorkerBuildResult, callbacks: DeployCallbacks): Promise<DeployResult>;
64
65
 
65
66
  type VersionsUploadCallbacks = Pick<DeployCallbacks, "analyseBundle">;
66
- declare function versionsUpload(props: VersionsUploadProps, config: Config, buildResult: WorkerBuildResult, callbacks: VersionsUploadCallbacks): Promise<{
67
+ type VersionsUploadResult = {
67
68
  versionId: string | null;
68
69
  workerTag: string | null;
69
70
  assetUploadStats?: AssetUploadStats;
70
71
  versionPreviewUrl?: string | undefined;
71
72
  versionPreviewAliasUrl?: string | undefined;
72
- }>;
73
+ };
74
+ declare function versionsUpload(props: VersionsUploadProps, config: Config, buildResult: WorkerBuildResult, callbacks: VersionsUploadCallbacks): Promise<VersionsUploadResult>;
73
75
 
74
76
  declare function triggersDeploy(props: TriggerProps): Promise<string[] | void>;
75
77
  declare function getSubdomainValues(config_workers_dev: boolean | undefined, config_preview_urls: boolean | undefined, routes: Route[]): {
@@ -961,6 +963,9 @@ type CreatePreviewDeploymentRequestParams = {
961
963
  placement?: CfPlacement;
962
964
  cache?: CacheOptions;
963
965
  env?: EnvBindings;
966
+ containers?: Array<{
967
+ class_name: string;
968
+ }>;
964
969
  };
965
970
  type CreatePreviewRequestParams = {
966
971
  name: string;
@@ -1002,6 +1007,8 @@ type PreviewBaseConfig = {
1002
1007
  type PreviewBaseConfigPatch = Partial<Omit<PreviewBaseConfig, "env">> & {
1003
1008
  env?: Record<string, Binding | null>;
1004
1009
  };
1010
+ /** Create an undeployed Worker that can own Preview resources. */
1011
+ declare function createPreviewParentWorker(config: Config, accountId: string, workerName: string, workersDevEnabled: boolean, previewsEnabled: boolean): Promise<void>;
1005
1012
  declare function getPreview(config: Config, accountId: string, workerName: string, previewIdentifier: string): Promise<PreviewResource>;
1006
1013
  declare function createPreview(config: Config, accountId: string, workerName: string, request: CreatePreviewRequestParams, options?: PreviewRequestOptions): Promise<PreviewResource>;
1007
1014
  declare function editPreview(config: Config, accountId: string, workerName: string, previewIdentifier: string, request: UpdatePreviewRequestParams): Promise<PreviewResource>;
@@ -1031,6 +1038,33 @@ declare function resolveWorkerName(args: {
1031
1038
  */
1032
1039
  declare function getBindingValue(binding: Binding): string;
1033
1040
  declare function extractConfigBindings(config: Config): EnvBindings;
1041
+ /**
1042
+ * Returns the DO `class_name`s whose containers this preview owns: the classes
1043
+ * the script declares through `migrations` or `exports`, plus the classes bound
1044
+ * in the preview without a `script_name`.
1045
+ *
1046
+ * A binding is not required. A Durable Object reached only through
1047
+ * `ctx.exports` is still implemented by this script, so its container belongs
1048
+ * to this preview. A class reachable only through a `script_name` binding is
1049
+ * implemented by another Worker, which owns its own container application.
1050
+ */
1051
+ declare function getPreviewOwnedContainerClassNames(config: Config, previews: PreviewsConfig | undefined): Set<string>;
1052
+ /**
1053
+ * Compose the auto-generated container application name for a preview-scoped
1054
+ * container, in the form `{parentWorkerName}_{previewSlug}_{className}`.
1055
+ *
1056
+ * A container application name is capped at 253 characters and may not start
1057
+ * or end with a dash, contain consecutive dashes, or start with a digit. A
1058
+ * worker name is allowed all four, and the preview slug is derived from a
1059
+ * branch name, so the composed name is normalised here rather than passed
1060
+ * through.
1061
+ *
1062
+ * Wrangler looks an application up by name to choose between create and
1063
+ * modify, so a name must identify one preview container. Both normalising and
1064
+ * truncating can map two inputs onto one output, so either one earns a digest
1065
+ * of the composed name.
1066
+ */
1067
+ declare function previewContainerAppName(parentWorkerName: string, previewSlug: string, className: string): string;
1034
1068
  declare function assemblePreviewScriptSettings(config: Config): Record<string, unknown>;
1035
1069
  declare function assemblePreviewDefaults(config: Config): PreviewDefaults;
1036
1070
 
@@ -1065,11 +1099,17 @@ type PreviewResult = {
1065
1099
  deployment: DeploymentResource;
1066
1100
  isNewPreview: boolean;
1067
1101
  };
1102
+ type PreviewCallbacks = Pick<DeployCallbacks, "getNormalizedContainerOptions"> & {
1103
+ deployPreviewContainers: ((scopedConfig: Config, normalisedContainerConfig: ContainerNormalizedConfig[], deployment: DeploymentResource, accountId: string, options: {
1104
+ quiet: boolean;
1105
+ }) => Promise<void>) | undefined;
1106
+ verifyContainersScope?: (scopedConfig: Config) => Promise<void>;
1107
+ };
1068
1108
  /**
1069
1109
  * Full preview create/update + deployment orchestration.
1070
1110
  * The wrangler handler calls this after auth + build.
1071
1111
  */
1072
- declare function preview(accountId: string, args: PreviewArgs, config: Config, buildResult: WorkerBuildResult, assetsOptions: PreviewAssetsOptions | undefined): Promise<PreviewResult>;
1112
+ declare function preview(accountId: string, args: PreviewArgs, config: Config, buildResult: WorkerBuildResult, assetsOptions: PreviewAssetsOptions | undefined, callbacks: PreviewCallbacks): Promise<PreviewResult>;
1073
1113
  /**
1074
1114
  * Delete a preview and all its deployments.
1075
1115
  */
@@ -1149,4 +1189,4 @@ type DrawConnectedChildBoxOptions = {
1149
1189
  */
1150
1190
  declare function drawConnectedChildBox(contentLines: string[], options?: DrawConnectedChildBoxOptions): string;
1151
1191
 
1152
- export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, type ApiDeployment, type ApiVersion, type AssetManifest, type AssetUploadStats, type AssetsUploadResult, type Binding, type BulkInputNullableResult, type BulkInputResult, type Consumer, type ConsumerSettings, type CreatePreviewDeploymentRequestParams, type CreatePreviewRequestParams, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, type DeploymentResource, EXPORTS_RECONCILIATION_ERROR_CODE, type EnvBindings, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, type JsonLike, NoInputError, type NonVersionedScriptSettings, type PackageDependency, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type PreviewArgs, type PreviewAssetsOptions, type PreviewBaseConfig, type PreviewBaseConfigPatch, type PreviewDefaults, type PreviewDefaultsPatch, type PreviewDeleteArgs, type PreviewRequestOptions, type PreviewResource, type PreviewResult, type PreviewSettingsArgs, type PreviewSettingsUpdateArgs, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RetrieveSourceMapFunction, type RouteObject, type ScriptReference, type Settings, SharedDeployVersionsProps, TriggerDeployment, TriggerProps, type TypedConsumerResponse, type UpdatePreviewRequestParams, type VersionCache, type VersionId, type VersionsUploadCallbacks, VersionsUploadProps, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, WorkerBuildResult, type Workflow, type WorkflowConflict, type Zone, type ZoneIdCache, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewDefaults, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, convertConfigToBindings, createDeployment, createPreview, createPreviewDeployment, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, editWorkerPreviewDefaults, ensureQueuesExistByConfig, extractBindingsOfType, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatPreviewsSettings, generatePreviewAlias, getBindingValue, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkerPreviewDefaults, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, mergeDeep, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, preview, previewDelete, previewSettingsGet, previewSettingsUpdate, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
1192
+ export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, type ApiDeployment, type ApiVersion, type AssetManifest, type AssetUploadStats, type AssetsUploadResult, type Binding, type BulkInputNullableResult, type BulkInputResult, type Consumer, type ConsumerSettings, type CreatePreviewDeploymentRequestParams, type CreatePreviewRequestParams, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, type DeploymentResource, EXPORTS_RECONCILIATION_ERROR_CODE, type EnvBindings, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, type JsonLike, NoInputError, type NonVersionedScriptSettings, type PackageDependency, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type PreviewArgs, type PreviewAssetsOptions, type PreviewBaseConfig, type PreviewBaseConfigPatch, type PreviewCallbacks, type PreviewDefaults, type PreviewDefaultsPatch, type PreviewDeleteArgs, type PreviewRequestOptions, type PreviewResource, type PreviewResult, type PreviewSettingsArgs, type PreviewSettingsUpdateArgs, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RetrieveSourceMapFunction, type RouteObject, type ScriptReference, type Settings, SharedDeployVersionsProps, TriggerDeployment, TriggerProps, type TypedConsumerResponse, type UpdatePreviewRequestParams, type VersionCache, type VersionId, type VersionsUploadCallbacks, VersionsUploadProps, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, WorkerBuildResult, type Workflow, type WorkflowConflict, type Zone, type ZoneIdCache, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewDefaults, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, convertConfigToBindings, createDeployment, createPreview, createPreviewDeployment, createPreviewParentWorker, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, editWorkerPreviewDefaults, ensureQueuesExistByConfig, extractBindingsOfType, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatPreviewsSettings, generatePreviewAlias, getBindingValue, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getPreviewOwnedContainerClassNames, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkerPreviewDefaults, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, mergeDeep, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, preview, previewContainerAppName, previewDelete, previewSettingsGet, previewSettingsUpdate, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };