@cloudflare/deploy-helpers 0.11.1 → 0.11.2

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,5 +1,5 @@
1
- import { ContainerNormalizedConfig, BuiltContainerDeployment } from '@cloudflare/containers-shared';
2
- import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, Config, CfModule, CfWorkerSourceMap, CfModuleType } from '@cloudflare/workers-utils';
1
+ import { BuiltImage, ContainerNormalizedConfig, BuiltContainerImage } from '@cloudflare/containers-shared';
2
+ import { ContainerApp, Config, FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, CfModule, CfWorkerSourceMap, CfModuleType } from '@cloudflare/workers-utils';
3
3
 
4
4
  /**
5
5
  * client needs to handle logger and fetch/auth implementation
@@ -28,6 +28,25 @@ type DeployHelpersContext = {
28
28
  fallbackOption?: number;
29
29
  }) => Promise<Values>;
30
30
  };
31
+ type ContainerlessConfig = Omit<Config, "containers">;
32
+ type BuiltDurableObjectContainerImage = BuiltImage & {
33
+ className: string;
34
+ imageName: string;
35
+ };
36
+ type ContainerDeployConfig = {
37
+ /** Original resolved container configuration. */
38
+ source: ContainerApp[] | undefined;
39
+ standard: {
40
+ /** Normalized non-Durable-Object container applications. */
41
+ normalized: ContainerNormalizedConfig[];
42
+ /** Locally built images awaiting deployment or cleanup. */
43
+ builtImages: BuiltContainerImage[];
44
+ };
45
+ durableObjects: {
46
+ /** Locally built named images awaiting upload or cleanup. */
47
+ builtImages: BuiltDurableObjectContainerImage[];
48
+ };
49
+ };
31
50
  /**
32
51
  * Shared fields produced by merging CLI args with wrangler config.
33
52
  * After this point, no raw config/arg merging should happen.
@@ -86,6 +105,8 @@ type SharedDeployVersionsProps = {
86
105
  skipProvisioningConfigWriteback: boolean;
87
106
  /** From --strict arg. In strict mode, conflicting pre-upload checks abort instead of auto-continuing. */
88
107
  strict: boolean;
108
+ /** Container configuration and locally built image state. */
109
+ containers: ContainerDeployConfig;
89
110
  /** Whether the resolved Worker name differs from the pre-merge config/args name. */
90
111
  workerNameOverridden?: boolean;
91
112
  };
@@ -108,10 +129,6 @@ type DeployProps = SharedDeployVersionsProps & {
108
129
  oldAssetTtl: number | undefined;
109
130
  /** From --containers-rollout arg. Deploy-only. */
110
131
  containersRollout: "immediate" | "gradual" | "none" | undefined;
111
- /** Normalized Wrangler container configuration, resolved before calling deploy-helpers. */
112
- normalisedContainerConfig: ContainerNormalizedConfig[];
113
- /** Dockerfile container images built by the caller before invoking deploy-helpers. */
114
- builtContainerDeployments: BuiltContainerDeployment[];
115
132
  /**
116
133
  * When true, an existing Worker with the same name aborts the deploy instead
117
134
  * of updating it, because this run cannot confirm the local project owns the
@@ -185,4 +202,4 @@ declare let select: DeployHelpersContext["select"];
185
202
  */
186
203
  declare function initDeployHelpersContext(ctx: DeployHelpersContext): void;
187
204
 
188
- 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 };
205
+ export { type BuiltDurableObjectContainerImage as B, type ContainerlessConfig as C, 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 ContainerDeployConfig as b, type DeployHelpersContext as c, confirm as d, fetchListResult as e, fetchKVGetValue as f, fetchPagedListResult as g, fetchResult as h, initDeployHelpersContext as i, logger as l, prompt as p, select as s };
@@ -1,3 +1,3 @@
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-Bo-P841x.mjs';
1
+ export { d as confirm, f as fetchKVGetValue, e as fetchListResult, g as fetchPagedListResult, h as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-CruwKULH.mjs';
2
2
  import '@cloudflare/workers-utils';
3
3
  import '@cloudflare/containers-shared';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SharedDeployVersionsProps, D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-Bo-P841x.mjs';
2
- export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-Bo-P841x.mjs';
1
+ import { S as SharedDeployVersionsProps, D as DeployProps, C as ContainerlessConfig, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment, B as BuiltDurableObjectContainerImage } from './context-CruwKULH.mjs';
2
+ export { b as ContainerDeployConfig, c as DeployHelpersContext, i as initDeployHelpersContext } from './context-CruwKULH.mjs';
3
3
  import * as _cloudflare_workers_utils from '@cloudflare/workers-utils';
4
4
  import { CfModule, Config, AssetsOptions, ComplianceConfig, LegacyAssetPaths, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, Binding as Binding$1, RawConfig, CfCapnp, CfScriptFormat, ParseError, WorkerMetadataBinding, CfUserLimits, CfWorkerInit, TailConsumer, StreamingTailConsumer, Observability, DurableObjectContainerApp, ExportsReconciliationErrorDetail, ExportsReconciliationResult, StartDevWorkerInput, CacheOptions, PreviewsConfig } from '@cloudflare/workers-utils';
5
5
  import { FormData } from 'undici';
@@ -59,7 +59,7 @@ type DeployResult = {
59
59
  targets?: string[];
60
60
  bundleSize?: BundleSize;
61
61
  };
62
- declare function deploy(props: DeployProps, config: Config, buildResult: WorkerBuildResult, callbacks: DeployCallbacks): Promise<DeployResult>;
62
+ declare function deploy(props: DeployProps, config: ContainerlessConfig, buildResult: WorkerBuildResult, callbacks: DeployCallbacks): Promise<DeployResult>;
63
63
 
64
64
  type VersionsUploadCallbacks = Pick<DeployCallbacks, "analyseBundle">;
65
65
  type VersionsUploadResult = {
@@ -70,7 +70,7 @@ type VersionsUploadResult = {
70
70
  versionPreviewAliasUrl?: string | undefined;
71
71
  bundleSize?: BundleSize;
72
72
  };
73
- declare function versionsUpload(props: VersionsUploadProps, config: Config, buildResult: WorkerBuildResult, callbacks: VersionsUploadCallbacks): Promise<VersionsUploadResult>;
73
+ declare function versionsUpload(props: VersionsUploadProps, config: ContainerlessConfig, buildResult: WorkerBuildResult, callbacks: VersionsUploadCallbacks): Promise<VersionsUploadResult>;
74
74
 
75
75
  declare const PREVIEW_DOMAIN_PROVISIONING_NOTE = "Note: DNS and TLS certificate provisioning for Preview domains may continue after this deploy. If a new Preview URL does not work immediately, wait a few minutes and retry.";
76
76
  declare function triggersDeploy(props: TriggerProps): Promise<string[] | void>;
@@ -716,8 +716,8 @@ declare function deployVersionedDurableObjectContainerApplications(config: Confi
716
716
  accountId: string;
717
717
  scriptName: string;
718
718
  }): Promise<void>;
719
- declare function prepareDurableObjectContainerApplications(config: Config, { accountId, dryRun, scriptName, dispatchNamespace, }: PrepareDurableObjectContainerApplicationsArgs): Promise<PreparedContainerImages>;
720
- declare function deployDurableObjectContainerApplications(config: Config, { versionId, accountId, scriptName, dispatchNamespace, }: DeployDurableObjectContainerApplicationsArgs): Promise<void>;
719
+ declare function prepareDurableObjectContainerApplications(config: ContainerlessConfig, durableObjectContainerConfig: DurableObjectContainerApp[], builtImages: BuiltDurableObjectContainerImage[], { accountId, dryRun, scriptName, dispatchNamespace, }: PrepareDurableObjectContainerApplicationsArgs): Promise<PreparedContainerImages>;
720
+ declare function deployDurableObjectContainerApplications(config: ContainerlessConfig, durableObjectContainerConfig: DurableObjectContainerApp[], { versionId, accountId, scriptName, dispatchNamespace, }: DeployDurableObjectContainerApplicationsArgs): Promise<void>;
721
721
 
722
722
  type ResolveExportsUploadPayloadProps = Parameters<typeof resolveDoLifecyclePayload>[0];
723
723
  declare function resolveExportsUploadPayload(props: ResolveExportsUploadPayloadProps): Promise<{
@@ -1184,4 +1184,4 @@ type DrawConnectedChildBoxOptions = {
1184
1184
  */
1185
1185
  declare function drawConnectedChildBox(contentLines: string[], options?: DrawConnectedChildBoxOptions): string;
1186
1186
 
1187
- export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, type ApiDeployment, type ApiVersion, type AssetManifest, type AssetUploadStats, type AssetsUploadResult, type Binding, type BulkInputNullableResult, type BulkInputResult, type BundleSize, type Consumer, type ConsumerSettings, type CreatePreviewDeploymentRequestParams, type CreatePreviewRequestParams, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, type DeploymentResource, type DurableObjectContainerApplication, EXPORTS_RECONCILIATION_ERROR_CODE, type EnvBindings, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, type JsonLike, NO_ACTIVE_PREVIEW_URLS_MESSAGE, NoInputError, type NonVersionedScriptSettings, PREVIEW_DOMAIN_PROVISIONING_NOTE, type PackageDependency, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type PreparedContainerImages, type PreviewArgs, type PreviewAssetsOptions, type PreviewBaseConfig, type PreviewBaseConfigPatch, type PreviewCallbacks, type PreviewDeleteArgs, type PreviewDeploymentModule, type PreviewRequestOptions, type PreviewResource, type PreviewResult, type Producer, type ProvisionBindingsResult, type PullRequestMetadata, 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 VersionedDurableObjectContainerApplication, 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, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createDurableObjectContainerApplication, createPreview, createPreviewDeployment, createPreviewDeploymentForm, createPreviewParentWorker, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployDurableObjectContainerApplications, deployVersionedDurableObjectContainerApplications, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatNoActivePreviewUrlsMessage, generatePreviewAlias, getBindingValue, getBranchName, getCommitSha, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getPreviewOwnedContainerClassNames, getPullRequestMetadata, getQueue, getRemoteConfigDiff, getRepositoryUrl, getSettings, getSize, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getVersionedDurableObjectContainerApplications, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, prepareDurableObjectContainerApplications, preview, previewContainerAppName, previewDelete, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveVersionedDurableObjectContainerApplications, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, workerNotFoundErrorMessage };
1187
+ export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, type ApiDeployment, type ApiVersion, type AssetManifest, type AssetUploadStats, type AssetsUploadResult, type Binding, BuiltDurableObjectContainerImage, type BulkInputNullableResult, type BulkInputResult, type BundleSize, type Consumer, type ConsumerSettings, ContainerlessConfig, type CreatePreviewDeploymentRequestParams, type CreatePreviewRequestParams, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, type DeploymentResource, type DurableObjectContainerApplication, EXPORTS_RECONCILIATION_ERROR_CODE, type EnvBindings, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, type JsonLike, NO_ACTIVE_PREVIEW_URLS_MESSAGE, NoInputError, type NonVersionedScriptSettings, PREVIEW_DOMAIN_PROVISIONING_NOTE, type PackageDependency, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type PreparedContainerImages, type PreviewArgs, type PreviewAssetsOptions, type PreviewBaseConfig, type PreviewBaseConfigPatch, type PreviewCallbacks, type PreviewDeleteArgs, type PreviewDeploymentModule, type PreviewRequestOptions, type PreviewResource, type PreviewResult, type Producer, type ProvisionBindingsResult, type PullRequestMetadata, 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 VersionedDurableObjectContainerApplication, 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, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createDurableObjectContainerApplication, createPreview, createPreviewDeployment, createPreviewDeploymentForm, createPreviewParentWorker, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployDurableObjectContainerApplications, deployVersionedDurableObjectContainerApplications, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatNoActivePreviewUrlsMessage, generatePreviewAlias, getBindingValue, getBranchName, getCommitSha, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getPreviewOwnedContainerClassNames, getPullRequestMetadata, getQueue, getRemoteConfigDiff, getRepositoryUrl, getSettings, getSize, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getVersionedDurableObjectContainerApplications, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, prepareDurableObjectContainerApplications, preview, previewContainerAppName, previewDelete, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveVersionedDurableObjectContainerApplications, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, workerNotFoundErrorMessage };
package/dist/index.mjs CHANGED
@@ -10,8 +10,8 @@ import path__default, { resolve, isAbsolute, sep, extname } from 'node:path';
10
10
  import url2, { URLSearchParams as URLSearchParams$1 } from 'node:url';
11
11
  import * as cli from '@cloudflare/cli-shared-helpers';
12
12
  import { updateStatus, cancel } from '@cloudflare/cli-shared-helpers';
13
- import { SchedulingPolicy, ApplicationsService, listDurableObjects, resolveImageName, buildAndMaybePush, ContainerImagePreparationsService, ContainerImagePreparationStatus, createDurableObjectNamespaceResolver, initContainersSharedContext, pushBuiltContainerImage, deployContainers, verifyDockerInstalled } from '@cloudflare/containers-shared';
14
- import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, getDurableObjectContainerApps, CONTAINER_IMAGES_BINDING, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, getWranglerTmpDir, parsePackageJSON, getInstalledPackageVersion, FatalError, readFileSync as readFileSync$1, parseJSON, printBindings, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, writeOutput, getBindings, hasDurableObjectExports, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, getBindingTypeFriendlyName } from '@cloudflare/workers-utils';
13
+ import { SchedulingPolicy, ApplicationsService, listDurableObjects, resolveImageName, pushImageIfChanged, ContainerImagePreparationsService, ContainerImagePreparationStatus, createDurableObjectNamespaceResolver, initContainersSharedContext, pushBuiltContainerImage, deployContainers, verifyDockerInstalled } from '@cloudflare/containers-shared';
14
+ import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, CONTAINER_IMAGES_BINDING, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, getWranglerTmpDir, parsePackageJSON, getInstalledPackageVersion, FatalError, readFileSync as readFileSync$1, parseJSON, printBindings, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, writeOutput, getDurableObjectContainerApps, getBindings, hasDurableObjectExports, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, getBindingTypeFriendlyName } from '@cloudflare/workers-utils';
15
15
  import { Response, FormData } from 'undici';
16
16
  import chalk6 from 'chalk';
17
17
  import PQueue from 'p-queue';
@@ -6490,8 +6490,8 @@ function formatVersions(versions, traffic) {
6490
6490
  }).join("\n\n");
6491
6491
  }
6492
6492
  __name(formatVersions, "formatVersions");
6493
- async function clearRemovedContainerImagesBindings(config2, bindings, workerUrl) {
6494
- if (getDurableObjectContainerApps(config2.containers).length > 0) {
6493
+ async function clearRemovedContainerImagesBindings(config2, durableObjectContainerConfig, bindings, workerUrl) {
6494
+ if (durableObjectContainerConfig.length > 0) {
6495
6495
  return;
6496
6496
  }
6497
6497
  const settings = await fetchResult(
@@ -6503,13 +6503,12 @@ async function clearRemovedContainerImagesBindings(config2, bindings, workerUrl)
6503
6503
  }
6504
6504
  }
6505
6505
  __name(clearRemovedContainerImagesBindings, "clearRemovedContainerImagesBindings");
6506
- function addContainerImagesBinding(config2, bindings, preparedContainerImages, options = {}) {
6507
- const containers = getDurableObjectContainerApps(config2.containers);
6506
+ function addContainerImagesBinding(durableObjectContainerConfig, bindings, preparedContainerImages, options = {}) {
6508
6507
  const shouldInheritExisting = options.preserveExisting && options.workerExists && options.hasExistingBinding;
6509
6508
  if (options.preserveExisting && !shouldInheritExisting) {
6510
6509
  return;
6511
6510
  }
6512
- if (containers.length === 0 && !shouldInheritExisting) {
6511
+ if (durableObjectContainerConfig.length === 0 && !shouldInheritExisting) {
6513
6512
  return;
6514
6513
  }
6515
6514
  if (bindings[CONTAINER_IMAGES_BINDING] !== void 0) {
@@ -6527,7 +6526,7 @@ function addContainerImagesBinding(config2, bindings, preparedContainerImages, o
6527
6526
  bindings[CONTAINER_IMAGES_BINDING] = {
6528
6527
  type: "json",
6529
6528
  value: Object.fromEntries(
6530
- containers.map((container) => {
6529
+ durableObjectContainerConfig.map((container) => {
6531
6530
  const configuredImages = Object.keys(container.images ?? {});
6532
6531
  const preparedImages = preparedContainerImages[container.class_name];
6533
6532
  if (configuredImages.length > 0 && preparedImages === void 0) {
@@ -6541,8 +6540,8 @@ function addContainerImagesBinding(config2, bindings, preparedContainerImages, o
6541
6540
  };
6542
6541
  }
6543
6542
  __name(addContainerImagesBinding, "addContainerImagesBinding");
6544
- function getContainerMetadata(config2, preparedContainerImages = {}, options = {}) {
6545
- const metadata = config2.containers?.map((container) => {
6543
+ function getContainerMetadata(containers, preparedContainerImages = {}, options = {}) {
6544
+ return containers?.map((container) => {
6546
6545
  if (isDurableObjectContainerApp(container)) {
6547
6546
  const configuredImages = Object.keys(container.images ?? {});
6548
6547
  const images = preparedContainerImages[container.class_name];
@@ -6563,11 +6562,10 @@ function getContainerMetadata(config2, preparedContainerImages = {}, options = {
6563
6562
  class_name: container.class_name
6564
6563
  }
6565
6564
  };
6566
- }) ?? [];
6567
- return config2.containers === void 0 ? void 0 : metadata;
6565
+ });
6568
6566
  }
6569
6567
  __name(getContainerMetadata, "getContainerMetadata");
6570
- async function getContainerMetadataForRolloutSkip(config2, {
6568
+ async function getContainerMetadataForRolloutSkip(config2, containers, {
6571
6569
  accountId,
6572
6570
  scriptName,
6573
6571
  dispatchNamespace,
@@ -6576,7 +6574,7 @@ async function getContainerMetadataForRolloutSkip(config2, {
6576
6574
  dryRun = false
6577
6575
  }) {
6578
6576
  const configuredMetadata = getContainerMetadata(
6579
- config2,
6577
+ containers,
6580
6578
  {},
6581
6579
  {
6582
6580
  allowUnprepared: true
@@ -6825,12 +6823,7 @@ async function deployVersionedDurableObjectContainerApplications(config2, args)
6825
6823
  }
6826
6824
  }
6827
6825
  __name(deployVersionedDurableObjectContainerApplications, "deployVersionedDurableObjectContainerApplications");
6828
- function buildTag(scriptName, className, imageName) {
6829
- const repository = `${scriptName}-${className}-${imageName}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
6830
- return `${repository}:wrangler-${Date.now().toString(36)}`;
6831
- }
6832
- __name(buildTag, "buildTag");
6833
- async function buildOrResolveImage(config2, container, imageName, imageConfig, scriptName, dryRun, accountId) {
6826
+ async function buildOrResolveImage(config2, container, imageName, imageConfig, builtImages, dryRun, accountId) {
6834
6827
  if (isRegistryImage(imageConfig)) {
6835
6828
  if (dryRun) {
6836
6829
  return imageConfig.image;
@@ -6838,24 +6831,39 @@ async function buildOrResolveImage(config2, container, imageName, imageConfig, s
6838
6831
  assert5(accountId, "Expected accountId to resolve container image name");
6839
6832
  return resolveImageName(accountId, imageConfig.image, config2);
6840
6833
  }
6841
- const baseDir = config2.configPath ? path__default.dirname(config2.configPath) : process.cwd();
6842
- const dockerfile = path__default.resolve(baseDir, imageConfig.dockerfile);
6843
- const tag = buildTag(scriptName, container.class_name, imageName);
6844
- logger.log("Building image", tag);
6845
- const imageRef = await buildAndMaybePush(
6846
- {
6847
- tag,
6848
- pathToDockerfile: dockerfile,
6849
- buildContext: path__default.dirname(dockerfile),
6850
- platform: "linux/amd64"
6851
- },
6852
- getDockerPath(),
6853
- !dryRun,
6854
- void 0,
6855
- true,
6856
- config2
6834
+ const builtImage = builtImages.find(
6835
+ (candidate) => candidate.className === container.class_name && candidate.imageName === imageName
6857
6836
  );
6858
- return "remoteDigest" in imageRef ? imageRef.remoteDigest : imageRef.newTag;
6837
+ if (builtImage === void 0) {
6838
+ throw new Error(
6839
+ `Container image "${imageName}" for Durable Object class "${container.class_name}" was not built before upload.`
6840
+ );
6841
+ }
6842
+ if (dryRun) {
6843
+ return builtImage.localTag;
6844
+ }
6845
+ try {
6846
+ const imageRef = await pushImageIfChanged({
6847
+ pathToDocker: getDockerPath(),
6848
+ sourceTag: builtImage.localTag,
6849
+ targetTag: builtImage.localTag,
6850
+ accountId,
6851
+ complianceConfig: config2,
6852
+ cleanupSourceTag: true
6853
+ });
6854
+ builtImage.localTagCleaned = true;
6855
+ return "remoteDigest" in imageRef ? imageRef.remoteDigest : imageRef.newTag;
6856
+ } catch (error51) {
6857
+ if (error51 instanceof Error) {
6858
+ throw new UserError(error51.message, {
6859
+ cause: error51,
6860
+ telemetryMessage: "durable object container image push failed"
6861
+ });
6862
+ }
6863
+ throw new UserError("An unknown error occurred", {
6864
+ telemetryMessage: "durable object container image push failed"
6865
+ });
6866
+ }
6859
6867
  }
6860
6868
  __name(buildOrResolveImage, "buildOrResolveImage");
6861
6869
  async function waitForImagePreparation(image) {
@@ -6892,22 +6900,23 @@ async function waitForImagePreparation(image) {
6892
6900
  );
6893
6901
  }
6894
6902
  __name(waitForImagePreparation, "waitForImagePreparation");
6895
- async function prepareDurableObjectContainerApplications(config2, {
6903
+ async function prepareDurableObjectContainerApplications(config2, durableObjectContainerConfig, builtImages, {
6896
6904
  accountId,
6897
6905
  dryRun,
6898
6906
  scriptName,
6899
6907
  dispatchNamespace
6900
6908
  }) {
6901
- validateDurableObjectContainerApplications(config2);
6909
+ validateDurableObjectContainerApplications(
6910
+ config2,
6911
+ durableObjectContainerConfig
6912
+ );
6902
6913
  if (!dryRun) {
6903
6914
  assert5(accountId, "Expected accountId to prepare container applications");
6904
6915
  const storageByClass = getDurableObjectClassNameToUseSQLiteMap(
6905
6916
  config2.migrations,
6906
6917
  config2.exports
6907
6918
  );
6908
- const unknownStorage = getDurableObjectContainerApps(
6909
- config2.containers
6910
- ).filter(
6919
+ const unknownStorage = durableObjectContainerConfig.filter(
6911
6920
  (container) => storageByClass.get(container.class_name) === void 0
6912
6921
  );
6913
6922
  if (unknownStorage.length > 0) {
@@ -6926,7 +6935,7 @@ async function prepareDurableObjectContainerApplications(config2, {
6926
6935
  }
6927
6936
  }
6928
6937
  }
6929
- const containers = getDurableObjectContainerApps(config2.containers).filter(
6938
+ const containers = durableObjectContainerConfig.filter(
6930
6939
  (container) => Object.keys(container.images ?? {}).length > 0
6931
6940
  );
6932
6941
  if (containers.length === 0) {
@@ -6950,7 +6959,7 @@ async function prepareDurableObjectContainerApplications(config2, {
6950
6959
  container,
6951
6960
  imageName,
6952
6961
  imageConfig,
6953
- scriptName,
6962
+ builtImages,
6954
6963
  dryRun,
6955
6964
  accountId
6956
6965
  );
@@ -6973,13 +6982,13 @@ ${imageLine}`);
6973
6982
  return Object.fromEntries(imagesByClass);
6974
6983
  }
6975
6984
  __name(prepareDurableObjectContainerApplications, "prepareDurableObjectContainerApplications");
6976
- async function deployDurableObjectContainerApplications(config2, {
6985
+ async function deployDurableObjectContainerApplications(config2, durableObjectContainerConfig, {
6977
6986
  versionId,
6978
6987
  accountId,
6979
6988
  scriptName,
6980
6989
  dispatchNamespace
6981
6990
  }) {
6982
- const containers = getDurableObjectContainerApps(config2.containers);
6991
+ const containers = durableObjectContainerConfig;
6983
6992
  if (containers.length === 0) {
6984
6993
  return;
6985
6994
  }
@@ -8374,7 +8383,6 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
8374
8383
  log: logger.log,
8375
8384
  tailConsumers: config2.tail_consumers,
8376
8385
  streamingTailConsumers: config2.streaming_tail_consumers,
8377
- containers: config2.containers,
8378
8386
  provisioning: true
8379
8387
  }
8380
8388
  );
@@ -25042,7 +25050,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
25042
25050
  );
25043
25051
  }
25044
25052
  } else {
25045
- if (config2.containers?.some(
25053
+ if (props.containers.source?.some(
25046
25054
  (container) => !isDurableObjectContainerApp(container)
25047
25055
  )) {
25048
25056
  logger.warn(
@@ -25272,8 +25280,11 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25272
25280
  }
25273
25281
  }
25274
25282
  const isDryRun = props.dryRun;
25275
- const normalisedContainerConfig = props.normalisedContainerConfig;
25276
- const builtContainerDeployments = props.builtContainerDeployments;
25283
+ const normalisedContainerConfig = props.containers.standard.normalized;
25284
+ const builtContainerImages = props.containers.standard.builtImages;
25285
+ const durableObjectContainerConfig = getDurableObjectContainerApps(
25286
+ props.containers.source
25287
+ );
25277
25288
  const shouldDeployContainers = normalisedContainerConfig.length > 0 && props.containersRollout !== "none";
25278
25289
  const {
25279
25290
  modules,
@@ -25284,21 +25295,30 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25284
25295
  sourceMaps
25285
25296
  } = buildResult;
25286
25297
  const skipContainerChanges = props.containersRollout === "none";
25287
- const preparedContainerImages = skipContainerChanges ? void 0 : await prepareDurableObjectContainerApplications(config2, {
25288
- accountId,
25289
- dryRun: Boolean(isDryRun),
25290
- scriptName,
25291
- dispatchNamespace: props.dispatchNamespace
25292
- });
25293
- const rolloutSkipContainerState = skipContainerChanges ? await getContainerMetadataForRolloutSkip(config2, {
25294
- accountId,
25295
- scriptName,
25296
- dispatchNamespace: props.dispatchNamespace,
25297
- workerExists,
25298
- latestDeployment,
25299
- dryRun: isDryRun
25300
- }) : void 0;
25301
- const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(config2, preparedContainerImages);
25298
+ const preparedContainerImages = skipContainerChanges ? void 0 : await prepareDurableObjectContainerApplications(
25299
+ config2,
25300
+ durableObjectContainerConfig,
25301
+ props.containers.durableObjects.builtImages,
25302
+ {
25303
+ accountId,
25304
+ dryRun: Boolean(isDryRun),
25305
+ scriptName,
25306
+ dispatchNamespace: props.dispatchNamespace
25307
+ }
25308
+ );
25309
+ const rolloutSkipContainerState = skipContainerChanges ? await getContainerMetadataForRolloutSkip(
25310
+ config2,
25311
+ props.containers.source,
25312
+ {
25313
+ accountId,
25314
+ scriptName,
25315
+ dispatchNamespace: props.dispatchNamespace,
25316
+ workerExists,
25317
+ latestDeployment,
25318
+ dryRun: isDryRun
25319
+ }
25320
+ ) : void 0;
25321
+ const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(props.containers.source, preparedContainerImages);
25302
25322
  const { migrations, exports: exports$1 } = await resolveExportsUploadPayload({
25303
25323
  scriptName,
25304
25324
  isDryRun,
@@ -25353,13 +25373,23 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25353
25373
  workerExists
25354
25374
  });
25355
25375
  if (!skipContainerChanges && keepVars && !isDryRun && workerExists) {
25356
- await clearRemovedContainerImagesBindings(config2, bindings, workerUrl);
25376
+ await clearRemovedContainerImagesBindings(
25377
+ config2,
25378
+ durableObjectContainerConfig,
25379
+ bindings,
25380
+ workerUrl
25381
+ );
25357
25382
  }
25358
- addContainerImagesBinding(config2, bindings, preparedContainerImages ?? {}, {
25359
- preserveExisting: skipContainerChanges,
25360
- workerExists,
25361
- hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
25362
- });
25383
+ addContainerImagesBinding(
25384
+ durableObjectContainerConfig,
25385
+ bindings,
25386
+ preparedContainerImages ?? {},
25387
+ {
25388
+ preserveExisting: skipContainerChanges,
25389
+ workerExists,
25390
+ hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
25391
+ }
25392
+ );
25363
25393
  if (workersSitesAssets.manifest) {
25364
25394
  modules.push({
25365
25395
  name: "__STATIC_CONTENT_MANIFEST",
@@ -25418,7 +25448,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25418
25448
  );
25419
25449
  const bundleSize = await getSize([...modules, { content }]);
25420
25450
  printBundleSize(bundleSize);
25421
- const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && config2.containers === void 0 && // Rollout skip can recover Container metadata absent from local config.
25451
+ const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && props.containers.source === void 0 && // Rollout skip can recover Container metadata absent from local config.
25422
25452
  containerMetadata === void 0;
25423
25453
  let workerBundle;
25424
25454
  const dockerPath = getDockerPath();
@@ -25440,7 +25470,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25440
25470
  log: logger.log,
25441
25471
  tailConsumers: config2.tail_consumers,
25442
25472
  streamingTailConsumers: config2.streaming_tail_consumers,
25443
- containers: config2.containers,
25473
+ containers: props.containers.source,
25444
25474
  warnIfNoBindings: true,
25445
25475
  unsafeMetadata: config2.unsafe?.metadata
25446
25476
  });
@@ -25575,7 +25605,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25575
25605
  log: logger.log,
25576
25606
  tailConsumers: config2.tail_consumers,
25577
25607
  streamingTailConsumers: config2.streaming_tail_consumers,
25578
- containers: config2.containers,
25608
+ containers: props.containers.source,
25579
25609
  unsafeMetadata: config2.unsafe?.metadata
25580
25610
  });
25581
25611
  provisionBindingsResult?.warnOnSkippedProvisioning();
@@ -25603,7 +25633,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25603
25633
  log: logger.log,
25604
25634
  tailConsumers: config2.tail_consumers,
25605
25635
  streamingTailConsumers: config2.streaming_tail_consumers,
25606
- containers: config2.containers,
25636
+ containers: props.containers.source,
25607
25637
  unsafeMetadata: config2.unsafe?.metadata
25608
25638
  });
25609
25639
  }
@@ -25673,17 +25703,17 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25673
25703
  const containerDeployments = [];
25674
25704
  for (const container of normalisedContainerConfig) {
25675
25705
  if ("dockerfile" in container) {
25676
- const builtContainerDeployment = builtContainerDeployments.find(
25677
- (deployment) => deployment.container === container
25706
+ const builtImage = builtContainerImages.find(
25707
+ (image) => image.container === container
25678
25708
  );
25679
25709
  assert5(
25680
- builtContainerDeployment,
25710
+ builtImage,
25681
25711
  "Expected container image to be built before upload"
25682
25712
  );
25683
25713
  containerDeployments.push({
25684
25714
  container,
25685
25715
  imageRef: await pushBuiltContainerImage(
25686
- builtContainerDeployment.builtImage,
25716
+ builtImage,
25687
25717
  versionId,
25688
25718
  dockerPath,
25689
25719
  accountId,
@@ -25704,15 +25734,19 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25704
25734
  dispatchNamespace: props.dispatchNamespace
25705
25735
  });
25706
25736
  }
25707
- if (!skipContainerChanges && getDurableObjectContainerApps(config2.containers).length > 0) {
25737
+ if (!skipContainerChanges && durableObjectContainerConfig.length > 0) {
25708
25738
  assert5(versionId && accountId);
25709
25739
  try {
25710
- await deployDurableObjectContainerApplications(config2, {
25711
- versionId,
25712
- accountId,
25713
- scriptName,
25714
- dispatchNamespace: props.dispatchNamespace
25715
- });
25740
+ await deployDurableObjectContainerApplications(
25741
+ config2,
25742
+ durableObjectContainerConfig,
25743
+ {
25744
+ versionId,
25745
+ accountId,
25746
+ scriptName,
25747
+ dispatchNamespace: props.dispatchNamespace
25748
+ }
25749
+ );
25716
25750
  } catch (error51) {
25717
25751
  throw new UserError(
25718
25752
  "The Worker version was deployed, but Wrangler could not finish creating its Durable Object-managed Container applications. Re-run the same `wrangler deploy` command to retry the idempotent application creation and finish deployment.",
@@ -25834,11 +25868,19 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25834
25868
  { telemetryMessage: "versions upload pending durable object migration" }
25835
25869
  );
25836
25870
  }
25837
- const preparedContainerImages = await prepareDurableObjectContainerApplications(config2, {
25838
- accountId,
25839
- dryRun: Boolean(props.dryRun),
25840
- scriptName
25841
- });
25871
+ const durableObjectContainerConfig = getDurableObjectContainerApps(
25872
+ props.containers.source
25873
+ );
25874
+ const preparedContainerImages = await prepareDurableObjectContainerApplications(
25875
+ config2,
25876
+ durableObjectContainerConfig,
25877
+ props.containers.durableObjects.builtImages,
25878
+ {
25879
+ accountId,
25880
+ dryRun: Boolean(props.dryRun),
25881
+ scriptName
25882
+ }
25883
+ );
25842
25884
  const assetsUploadResult = assetsOptions && !props.dryRun ? await syncAssets(config2, accountId, assetsOptions.directory, scriptName) : void 0;
25843
25885
  const assetsJwt = assetsUploadResult?.jwt;
25844
25886
  if (props.secretsFile) {
@@ -25856,9 +25898,18 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25856
25898
  }
25857
25899
  addRequiredSecretsInheritBindings(config2, bindings, { type: "upload" });
25858
25900
  if (keepVars && !props.dryRun && workerExists) {
25859
- await clearRemovedContainerImagesBindings(config2, bindings, workerUrl);
25901
+ await clearRemovedContainerImagesBindings(
25902
+ config2,
25903
+ durableObjectContainerConfig,
25904
+ bindings,
25905
+ workerUrl
25906
+ );
25860
25907
  }
25861
- addContainerImagesBinding(config2, bindings, preparedContainerImages ?? {});
25908
+ addContainerImagesBinding(
25909
+ durableObjectContainerConfig,
25910
+ bindings,
25911
+ preparedContainerImages ?? {}
25912
+ );
25862
25913
  const placement = parseConfigPlacement(config2);
25863
25914
  const entryPointName = path__default.basename(resolvedEntryPointPath);
25864
25915
  const main = {
@@ -25873,7 +25924,10 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25873
25924
  migrations,
25874
25925
  exports: exports$1,
25875
25926
  modules,
25876
- containers: getContainerMetadata(config2, preparedContainerImages),
25927
+ containers: getContainerMetadata(
25928
+ props.containers.source,
25929
+ preparedContainerImages
25930
+ ),
25877
25931
  sourceMaps,
25878
25932
  compatibility_date: compatibilityDate,
25879
25933
  compatibility_flags: compatibilityFlags,
@@ -26037,13 +26091,17 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
26037
26091
  return { versionId, workerTag, bundleSize };
26038
26092
  }
26039
26093
  assert5(accountId);
26040
- if (!hasDurableObjectExports(config2.exports) && getDurableObjectContainerApps(config2.containers).length > 0) {
26094
+ if (!hasDurableObjectExports(config2.exports) && durableObjectContainerConfig.length > 0) {
26041
26095
  assert5(versionId);
26042
- await deployDurableObjectContainerApplications(config2, {
26043
- versionId,
26044
- accountId,
26045
- scriptName
26046
- });
26096
+ await deployDurableObjectContainerApplications(
26097
+ config2,
26098
+ durableObjectContainerConfig,
26099
+ {
26100
+ versionId,
26101
+ accountId,
26102
+ scriptName
26103
+ }
26104
+ );
26047
26105
  }
26048
26106
  const uploadMs = Date.now() - start;
26049
26107
  logger.log("Uploaded", workerName, formatTime(uploadMs));