@cloudflare/deploy-helpers 0.13.0 → 0.14.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/index.d.mts +27 -9
- package/dist/index.mjs +98 -161
- package/dist/metafile-esm.json +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType } from './crea
|
|
|
7
7
|
import { Options } from '@cspotcode/source-map-support';
|
|
8
8
|
import Protocol from 'devtools-protocol';
|
|
9
9
|
import { NodeJSCompatMode } from 'miniflare';
|
|
10
|
-
import { ParsedOutputWorkerConfig,
|
|
10
|
+
import { ParsedOutputWorkerConfig, ParsedOutputRootConfig } from '@cloudflare/config';
|
|
11
11
|
import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
|
|
12
12
|
|
|
13
13
|
interface BundleSize {
|
|
@@ -157,8 +157,10 @@ declare function publishRoutes(complianceConfig: ComplianceConfig, routes: Route
|
|
|
157
157
|
}): Promise<string[]>;
|
|
158
158
|
declare function publishCustomDomains(complianceConfig: ComplianceConfig, workerUrl: string, accountId: string, scriptName: string, domains: Array<RouteObject>): Promise<TriggerDeployment>;
|
|
159
159
|
|
|
160
|
+
type QueueJurisdiction = "eu" | "us" | "fedramp";
|
|
160
161
|
interface PostQueueBody {
|
|
161
162
|
queue_name: string;
|
|
163
|
+
jurisdiction?: QueueJurisdiction;
|
|
162
164
|
settings?: QueueSettings;
|
|
163
165
|
}
|
|
164
166
|
interface QueueSettings {
|
|
@@ -176,6 +178,7 @@ interface PostQueueResponse {
|
|
|
176
178
|
interface QueueResponse {
|
|
177
179
|
queue_id: string;
|
|
178
180
|
queue_name: string;
|
|
181
|
+
jurisdiction?: QueueJurisdiction;
|
|
179
182
|
created_on: string;
|
|
180
183
|
modified_on: string;
|
|
181
184
|
producers: Producer[];
|
|
@@ -703,6 +706,8 @@ type PrepareDurableObjectContainerApplicationsArgs = {
|
|
|
703
706
|
dispatchNamespace?: string;
|
|
704
707
|
dryRun: boolean;
|
|
705
708
|
scriptName: string;
|
|
709
|
+
/** Version uploads cannot initialize applications without named images. */
|
|
710
|
+
requireExistingImageLessApplications?: boolean;
|
|
706
711
|
};
|
|
707
712
|
type DurableObjectContainerApplication = Pick<ResolvedDurableObjectContainerApp, "class_name" | "name">;
|
|
708
713
|
type VersionedDurableObjectContainerApplication = DurableObjectContainerApplication & {
|
|
@@ -711,13 +716,24 @@ type VersionedDurableObjectContainerApplication = DurableObjectContainerApplicat
|
|
|
711
716
|
type PreparedContainerImages = Record<string, Record<string, string>>;
|
|
712
717
|
declare function createDurableObjectContainerApplication(application: DurableObjectContainerApplication, namespaceId: string): Promise<void>;
|
|
713
718
|
/**
|
|
714
|
-
* Read managed application identities from selected Worker versions.
|
|
719
|
+
* Read managed application identities from native images on selected Worker versions.
|
|
715
720
|
*
|
|
716
|
-
*
|
|
721
|
+
* Named images identify managed classes. Versions may add or remove images, but
|
|
722
|
+
* must agree on those classes' names and known namespace IDs. Image-less classes
|
|
723
|
+
* rely on applications provisioned by a normal deploy.
|
|
717
724
|
* Application-wide settings are deliberately not read from local config or
|
|
718
725
|
* restored with a Worker version.
|
|
719
726
|
*/
|
|
720
727
|
declare function getVersionedDurableObjectContainerApplications(versions: ApiVersion[], scriptName: string): VersionedDurableObjectContainerApplication[];
|
|
728
|
+
/**
|
|
729
|
+
* Require existing applications for version uploads without named images.
|
|
730
|
+
* These versions carry no managed-policy discriminator, so versions deploy
|
|
731
|
+
* cannot initialize their applications. A normal deploy must provision them first.
|
|
732
|
+
*/
|
|
733
|
+
declare function validateImageLessContainerApplicationsForUpload(config: ContainerlessConfig, containers: DurableObjectContainerApp[], { accountId, scriptName }: {
|
|
734
|
+
accountId: string;
|
|
735
|
+
scriptName: string;
|
|
736
|
+
}): Promise<void>;
|
|
721
737
|
/** Resolve every versioned application's namespace without creating applications. */
|
|
722
738
|
declare function resolveVersionedDurableObjectContainerApplications(config: Config, { applications, accountId, scriptName, allowMissingNamespaces, }: {
|
|
723
739
|
applications: VersionedDurableObjectContainerApplication[];
|
|
@@ -737,7 +753,7 @@ declare function deployVersionedDurableObjectContainerApplications(config: Confi
|
|
|
737
753
|
scriptName: string;
|
|
738
754
|
}): Promise<void>;
|
|
739
755
|
/** Validate managed classes and prepare their named images before Worker upload. */
|
|
740
|
-
declare function prepareDurableObjectContainerApplications(config: ContainerlessConfig, durableObjectContainerConfig: DurableObjectContainerApp[], builtImages: BuiltDurableObjectContainerImage[], { accountId, dryRun, scriptName, dispatchNamespace, }: PrepareDurableObjectContainerApplicationsArgs): Promise<PreparedContainerImages>;
|
|
756
|
+
declare function prepareDurableObjectContainerApplications(config: ContainerlessConfig, durableObjectContainerConfig: DurableObjectContainerApp[], builtImages: BuiltDurableObjectContainerImage[], { accountId, dryRun, scriptName, dispatchNamespace, requireExistingImageLessApplications, }: PrepareDurableObjectContainerApplicationsArgs): Promise<PreparedContainerImages>;
|
|
741
757
|
/**
|
|
742
758
|
* Apply explicit application settings after an uploaded Worker's namespaces exist.
|
|
743
759
|
*
|
|
@@ -1155,17 +1171,19 @@ type PreviewResult = {
|
|
|
1155
1171
|
deployment: DeploymentResource;
|
|
1156
1172
|
isNewPreview: boolean;
|
|
1157
1173
|
};
|
|
1158
|
-
type
|
|
1159
|
-
|
|
1174
|
+
type PreviewBuildOutputRootConfig = ParsedOutputRootConfig & {
|
|
1175
|
+
buildContext: ParsedOutputRootConfig["buildContext"] & {
|
|
1176
|
+
isPreview: true;
|
|
1177
|
+
};
|
|
1160
1178
|
};
|
|
1161
1179
|
type PreviewBuildOutput = {
|
|
1162
1180
|
workerConfig: ParsedOutputWorkerConfig;
|
|
1163
|
-
|
|
1181
|
+
rootConfig: PreviewBuildOutputRootConfig;
|
|
1164
1182
|
buildResult?: WorkerBuildResult;
|
|
1165
1183
|
assets?: Pick<PreviewAssetsOptions, "directory" | "_headers" | "_redirects">;
|
|
1166
1184
|
};
|
|
1167
1185
|
/** Verify that Build Output was produced with Preview configuration. */
|
|
1168
|
-
declare function
|
|
1186
|
+
declare function assertPreviewBuildOutputRootConfig(rootConfig: ParsedOutputRootConfig | undefined): asserts rootConfig is PreviewBuildOutputRootConfig;
|
|
1169
1187
|
type PreviewCallbacks = {
|
|
1170
1188
|
productionBindingsExpectedInPreview?: Record<string, {
|
|
1171
1189
|
type: string;
|
|
@@ -1256,4 +1274,4 @@ type DrawConnectedChildBoxOptions = {
|
|
|
1256
1274
|
*/
|
|
1257
1275
|
declare function drawConnectedChildBox(contentLines: string[], options?: DrawConnectedChildBoxOptions): string;
|
|
1258
1276
|
|
|
1259
|
-
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 PreviewBuildOutput, type
|
|
1277
|
+
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 PreviewBuildOutput, type PreviewBuildOutputRootConfig, type PreviewCallbacks, type PreviewDeleteArgs, type PreviewDeploymentModule, type PreviewRequestOptions, type PreviewResource, type PreviewResult, type Producer, type ProvisionBindingsResult, type PullRequestMetadata, type PurgeQueueBody, type PurgeQueueResponse, type QueueJurisdiction, 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, assertPreviewBuildOutputRootConfig, 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, extractBuildOutputBindings, 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, previewBuildOutput, 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, validateImageLessContainerApplicationsForUpload, 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,
|
|
14
|
-
import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS,
|
|
13
|
+
import { SchedulingPolicy, ApplicationsService, listDurableObjects, ApiError, 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, getResolvedDurableObjectContainerApps, 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, defaultWranglerConfig } from '@cloudflare/workers-utils';
|
|
15
15
|
import { Response, FormData } from 'undici';
|
|
16
16
|
import chalk6 from 'chalk';
|
|
17
17
|
import PQueue from 'p-queue';
|
|
@@ -6523,59 +6523,6 @@ function formatVersions(versions, traffic) {
|
|
|
6523
6523
|
}).join("\n\n");
|
|
6524
6524
|
}
|
|
6525
6525
|
__name(formatVersions, "formatVersions");
|
|
6526
|
-
async function clearRemovedContainerImagesBindings(config2, durableObjectContainerConfig, bindings, workerUrl) {
|
|
6527
|
-
if (durableObjectContainerConfig.length > 0) {
|
|
6528
|
-
return;
|
|
6529
|
-
}
|
|
6530
|
-
const settings = await fetchResult(
|
|
6531
|
-
config2,
|
|
6532
|
-
`${workerUrl}/settings`
|
|
6533
|
-
);
|
|
6534
|
-
if (settings.bindings.some(({ name }) => name === CONTAINER_IMAGES_BINDING)) {
|
|
6535
|
-
bindings[CONTAINER_IMAGES_BINDING] ??= { type: "json", value: {} };
|
|
6536
|
-
}
|
|
6537
|
-
}
|
|
6538
|
-
__name(clearRemovedContainerImagesBindings, "clearRemovedContainerImagesBindings");
|
|
6539
|
-
function addContainerImagesBinding(durableObjectContainerConfig, bindings, preparedContainerImages, options = {}) {
|
|
6540
|
-
const shouldInheritExisting = options.preserveExisting && options.workerExists && options.hasExistingBinding;
|
|
6541
|
-
if (options.preserveExisting && !shouldInheritExisting) {
|
|
6542
|
-
return;
|
|
6543
|
-
}
|
|
6544
|
-
if (durableObjectContainerConfig.length === 0 && !shouldInheritExisting) {
|
|
6545
|
-
return;
|
|
6546
|
-
}
|
|
6547
|
-
if (bindings[CONTAINER_IMAGES_BINDING] !== void 0) {
|
|
6548
|
-
throw new UserError(
|
|
6549
|
-
`The binding name "${CONTAINER_IMAGES_BINDING}" is reserved for Durable Object-managed Container images.`,
|
|
6550
|
-
{
|
|
6551
|
-
telemetryMessage: "durable object container images binding name conflict"
|
|
6552
|
-
}
|
|
6553
|
-
);
|
|
6554
|
-
}
|
|
6555
|
-
if (options.preserveExisting) {
|
|
6556
|
-
bindings[CONTAINER_IMAGES_BINDING] = { type: "inherit" };
|
|
6557
|
-
return;
|
|
6558
|
-
}
|
|
6559
|
-
bindings[CONTAINER_IMAGES_BINDING] = {
|
|
6560
|
-
type: "json",
|
|
6561
|
-
value: Object.fromEntries(
|
|
6562
|
-
getResolvedDurableObjectContainerApps(
|
|
6563
|
-
durableObjectContainerConfig,
|
|
6564
|
-
options.exports
|
|
6565
|
-
).map((container) => {
|
|
6566
|
-
const configuredImages = Object.keys(container.images ?? {});
|
|
6567
|
-
const preparedImages = preparedContainerImages[container.class_name];
|
|
6568
|
-
if (configuredImages.length > 0 && preparedImages === void 0) {
|
|
6569
|
-
throw new Error(
|
|
6570
|
-
`Container images for Durable Object class "${container.class_name}" were not prepared before upload.`
|
|
6571
|
-
);
|
|
6572
|
-
}
|
|
6573
|
-
return [container.class_name, preparedImages ?? {}];
|
|
6574
|
-
})
|
|
6575
|
-
)
|
|
6576
|
-
};
|
|
6577
|
-
}
|
|
6578
|
-
__name(addContainerImagesBinding, "addContainerImagesBinding");
|
|
6579
6526
|
function getContainerMetadata(containers, preparedContainerImages = {}, options = {}) {
|
|
6580
6527
|
const managedClasses = new Map(
|
|
6581
6528
|
getResolvedDurableObjectContainerApps(containers, options.exports).map(
|
|
@@ -6625,8 +6572,7 @@ async function getContainerMetadataForRolloutSkip(config2, containers, {
|
|
|
6625
6572
|
allowUnprepared: true,
|
|
6626
6573
|
exports: config2.exports
|
|
6627
6574
|
}
|
|
6628
|
-
)
|
|
6629
|
-
hasExistingContainerImagesBinding: false
|
|
6575
|
+
)
|
|
6630
6576
|
};
|
|
6631
6577
|
}
|
|
6632
6578
|
if (dispatchNamespace !== void 0) {
|
|
@@ -6652,22 +6598,6 @@ async function getContainerMetadataForRolloutSkip(config2, containers, {
|
|
|
6652
6598
|
void 0,
|
|
6653
6599
|
latestDeployment.versions.map(({ version_id }) => version_id)
|
|
6654
6600
|
);
|
|
6655
|
-
const containerImagesBindingByVersion = versions.map(
|
|
6656
|
-
(version2) => version2.resources.bindings.some(
|
|
6657
|
-
(binding) => binding.name === CONTAINER_IMAGES_BINDING
|
|
6658
|
-
)
|
|
6659
|
-
);
|
|
6660
|
-
const hasExistingContainerImagesBinding = containerImagesBindingByVersion[0] ?? false;
|
|
6661
|
-
if (containerImagesBindingByVersion.some(
|
|
6662
|
-
(hasBinding) => hasBinding !== hasExistingContainerImagesBinding
|
|
6663
|
-
)) {
|
|
6664
|
-
throw new UserError(
|
|
6665
|
-
`All currently deployed Worker Versions must have identical ${CONTAINER_IMAGES_BINDING} binding presence when using --containers-rollout=none.`,
|
|
6666
|
-
{
|
|
6667
|
-
telemetryMessage: "rollout none inconsistent durable object container image binding"
|
|
6668
|
-
}
|
|
6669
|
-
);
|
|
6670
|
-
}
|
|
6671
6601
|
const containerMetadataByVersion = versions.map(
|
|
6672
6602
|
(version2) => version2.resources?.script_runtime?.containers
|
|
6673
6603
|
);
|
|
@@ -6676,8 +6606,7 @@ async function getContainerMetadataForRolloutSkip(config2, containers, {
|
|
|
6676
6606
|
);
|
|
6677
6607
|
if (existingMetadata.length === 0) {
|
|
6678
6608
|
return {
|
|
6679
|
-
containers: void 0
|
|
6680
|
-
hasExistingContainerImagesBinding
|
|
6609
|
+
containers: void 0
|
|
6681
6610
|
};
|
|
6682
6611
|
}
|
|
6683
6612
|
const expectedMetadata = existingMetadata[0];
|
|
@@ -6692,8 +6621,7 @@ async function getContainerMetadataForRolloutSkip(config2, containers, {
|
|
|
6692
6621
|
);
|
|
6693
6622
|
}
|
|
6694
6623
|
return {
|
|
6695
|
-
containers: existingMetadata[0]
|
|
6696
|
-
hasExistingContainerImagesBinding
|
|
6624
|
+
containers: existingMetadata[0]
|
|
6697
6625
|
};
|
|
6698
6626
|
}
|
|
6699
6627
|
__name(getContainerMetadataForRolloutSkip, "getContainerMetadataForRolloutSkip");
|
|
@@ -6745,24 +6673,6 @@ async function createDurableObjectContainerApplication(application, namespaceId)
|
|
|
6745
6673
|
);
|
|
6746
6674
|
}
|
|
6747
6675
|
__name(createDurableObjectContainerApplication, "createDurableObjectContainerApplication");
|
|
6748
|
-
function getContainerImageClasses(version2) {
|
|
6749
|
-
const binding = version2.resources.bindings.find(
|
|
6750
|
-
(candidate) => candidate.name === CONTAINER_IMAGES_BINDING
|
|
6751
|
-
);
|
|
6752
|
-
if (binding === void 0) {
|
|
6753
|
-
return void 0;
|
|
6754
|
-
}
|
|
6755
|
-
if (binding.type !== "json" || typeof binding.json !== "object" || binding.json === null || Array.isArray(binding.json)) {
|
|
6756
|
-
throw new UserError(
|
|
6757
|
-
`Worker Version ${version2.id} has invalid ${CONTAINER_IMAGES_BINDING} metadata.`,
|
|
6758
|
-
{
|
|
6759
|
-
telemetryMessage: "versions deploy invalid durable object container image binding"
|
|
6760
|
-
}
|
|
6761
|
-
);
|
|
6762
|
-
}
|
|
6763
|
-
return new Set(Object.keys(binding.json));
|
|
6764
|
-
}
|
|
6765
|
-
__name(getContainerImageClasses, "getContainerImageClasses");
|
|
6766
6676
|
function getNamespaceId(version2, scriptName, className) {
|
|
6767
6677
|
const binding = version2.resources.bindings.find(
|
|
6768
6678
|
(candidate) => candidate.type === "durable_object_namespace" && candidate.class_name === className && (candidate.script_name === void 0 || candidate.script_name === scriptName)
|
|
@@ -6770,18 +6680,17 @@ function getNamespaceId(version2, scriptName, className) {
|
|
|
6770
6680
|
return binding?.type === "durable_object_namespace" ? binding.namespace_id : void 0;
|
|
6771
6681
|
}
|
|
6772
6682
|
__name(getNamespaceId, "getNamespaceId");
|
|
6773
|
-
function getDurableObjectContainerApplicationsFromVersion(version2, scriptName) {
|
|
6774
|
-
const containerClasses = getContainerImageClasses(version2);
|
|
6775
|
-
if (containerClasses === void 0) {
|
|
6776
|
-
return [];
|
|
6777
|
-
}
|
|
6683
|
+
function getDurableObjectContainerApplicationsFromVersion(version2, scriptName, containerClasses) {
|
|
6778
6684
|
const containers = version2.resources.script_runtime.containers ?? [];
|
|
6779
|
-
return [...containerClasses].sort().
|
|
6685
|
+
return [...containerClasses].sort().flatMap((className) => {
|
|
6780
6686
|
const matchingContainers = containers.filter(
|
|
6781
6687
|
(container2) => container2.class_name === className
|
|
6782
6688
|
);
|
|
6689
|
+
if (matchingContainers.length === 0) {
|
|
6690
|
+
return [];
|
|
6691
|
+
}
|
|
6783
6692
|
const [container] = matchingContainers;
|
|
6784
|
-
if (matchingContainers.length !== 1 || container?.name
|
|
6693
|
+
if (typeof className !== "string" || className.length === 0 || matchingContainers.length !== 1 || !container?.name) {
|
|
6785
6694
|
throw new UserError(
|
|
6786
6695
|
`Worker Version ${version2.id} has invalid Durable Object-managed Container metadata for class "${className}".`,
|
|
6787
6696
|
{
|
|
@@ -6798,8 +6707,17 @@ function getDurableObjectContainerApplicationsFromVersion(version2, scriptName)
|
|
|
6798
6707
|
}
|
|
6799
6708
|
__name(getDurableObjectContainerApplicationsFromVersion, "getDurableObjectContainerApplicationsFromVersion");
|
|
6800
6709
|
function getVersionedDurableObjectContainerApplications(versions, scriptName) {
|
|
6710
|
+
const containerClasses = new Set(
|
|
6711
|
+
versions.flatMap(
|
|
6712
|
+
(version2) => (version2.resources.script_runtime.containers ?? []).filter((container) => Object.keys(container.images ?? {}).length > 0).map((container) => container.class_name)
|
|
6713
|
+
)
|
|
6714
|
+
);
|
|
6801
6715
|
const applicationsByVersion = versions.map(
|
|
6802
|
-
(version2) => getDurableObjectContainerApplicationsFromVersion(
|
|
6716
|
+
(version2) => getDurableObjectContainerApplicationsFromVersion(
|
|
6717
|
+
version2,
|
|
6718
|
+
scriptName,
|
|
6719
|
+
containerClasses
|
|
6720
|
+
)
|
|
6803
6721
|
);
|
|
6804
6722
|
const [firstApplications = []] = applicationsByVersion;
|
|
6805
6723
|
const expectedDefinition = JSON.stringify(
|
|
@@ -6838,6 +6756,52 @@ function getVersionedDurableObjectContainerApplications(versions, scriptName) {
|
|
|
6838
6756
|
});
|
|
6839
6757
|
}
|
|
6840
6758
|
__name(getVersionedDurableObjectContainerApplications, "getVersionedDurableObjectContainerApplications");
|
|
6759
|
+
function validateApplicationIdentity(application, namespaceId, existing) {
|
|
6760
|
+
if (existing.id !== namespaceId || existing.durable_objects?.namespace_id !== namespaceId || existing.scheduling_policy !== SchedulingPolicy.DURABLE_OBJECT || existing.name !== application.name) {
|
|
6761
|
+
throw new UserError(
|
|
6762
|
+
`The application for Durable Object namespace "${namespaceId}" does not match Container "${application.name}". The existing name, namespace, and scheduling policy must match before its settings can be applied.`,
|
|
6763
|
+
{
|
|
6764
|
+
telemetryMessage: "durable object container application identity mismatch"
|
|
6765
|
+
}
|
|
6766
|
+
);
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
__name(validateApplicationIdentity, "validateApplicationIdentity");
|
|
6770
|
+
async function validateImageLessContainerApplicationsForUpload(config2, containers, { accountId, scriptName }) {
|
|
6771
|
+
const imageLessContainers = getResolvedDurableObjectContainerApps(
|
|
6772
|
+
containers,
|
|
6773
|
+
config2.exports
|
|
6774
|
+
).filter((container) => Object.keys(container.images ?? {}).length === 0);
|
|
6775
|
+
if (imageLessContainers.length === 0) {
|
|
6776
|
+
return;
|
|
6777
|
+
}
|
|
6778
|
+
const namespaces = await listDurableObjects(config2, accountId);
|
|
6779
|
+
for (const container of imageLessContainers) {
|
|
6780
|
+
const namespace = namespaces.find(
|
|
6781
|
+
(candidate) => candidate.class === container.class_name && candidate.script === scriptName && candidate.preview === void 0 && candidate.dispatch_namespace === void 0
|
|
6782
|
+
);
|
|
6783
|
+
let existing;
|
|
6784
|
+
if (namespace !== void 0) {
|
|
6785
|
+
try {
|
|
6786
|
+
existing = await ApplicationsService.getApplication(namespace.id);
|
|
6787
|
+
} catch (error51) {
|
|
6788
|
+
if (!(error51 instanceof ApiError) || error51.status !== 404) {
|
|
6789
|
+
throw error51;
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6792
|
+
}
|
|
6793
|
+
if (namespace === void 0 || existing === void 0) {
|
|
6794
|
+
throw new UserError(
|
|
6795
|
+
`Container "${container.name}" has no named images and has not been provisioned. Run \`wrangler deploy\` to create its Durable Object-managed application before using \`wrangler versions upload\`, or configure at least one named image.`,
|
|
6796
|
+
{
|
|
6797
|
+
telemetryMessage: "versions upload image less container application missing"
|
|
6798
|
+
}
|
|
6799
|
+
);
|
|
6800
|
+
}
|
|
6801
|
+
validateApplicationIdentity(container, namespace.id, existing);
|
|
6802
|
+
}
|
|
6803
|
+
}
|
|
6804
|
+
__name(validateImageLessContainerApplicationsForUpload, "validateImageLessContainerApplicationsForUpload");
|
|
6841
6805
|
async function applyApplication(application, namespaceId, settings = {}, updateExisting = false) {
|
|
6842
6806
|
let existing;
|
|
6843
6807
|
try {
|
|
@@ -6851,14 +6815,7 @@ async function applyApplication(application, namespaceId, settings = {}, updateE
|
|
|
6851
6815
|
);
|
|
6852
6816
|
return;
|
|
6853
6817
|
}
|
|
6854
|
-
|
|
6855
|
-
throw new UserError(
|
|
6856
|
-
`The application for Durable Object namespace "${namespaceId}" does not match Container "${application.name}". The existing name, namespace, and scheduling policy must match before its settings can be applied.`,
|
|
6857
|
-
{
|
|
6858
|
-
telemetryMessage: "durable object container application identity mismatch"
|
|
6859
|
-
}
|
|
6860
|
-
);
|
|
6861
|
-
}
|
|
6818
|
+
validateApplicationIdentity(application, namespaceId, existing);
|
|
6862
6819
|
if (!updateExisting) {
|
|
6863
6820
|
return;
|
|
6864
6821
|
}
|
|
@@ -7013,7 +6970,8 @@ async function prepareDurableObjectContainerApplications(config2, durableObjectC
|
|
|
7013
6970
|
accountId,
|
|
7014
6971
|
dryRun,
|
|
7015
6972
|
scriptName,
|
|
7016
|
-
dispatchNamespace
|
|
6973
|
+
dispatchNamespace,
|
|
6974
|
+
requireExistingImageLessApplications = false
|
|
7017
6975
|
}) {
|
|
7018
6976
|
validateDurableObjectContainerApplications(
|
|
7019
6977
|
config2,
|
|
@@ -7048,6 +7006,14 @@ async function prepareDurableObjectContainerApplications(config2, durableObjectC
|
|
|
7048
7006
|
}
|
|
7049
7007
|
}
|
|
7050
7008
|
}
|
|
7009
|
+
if (!dryRun && requireExistingImageLessApplications) {
|
|
7010
|
+
assert6(accountId);
|
|
7011
|
+
await validateImageLessContainerApplicationsForUpload(
|
|
7012
|
+
config2,
|
|
7013
|
+
durableObjectContainerConfig,
|
|
7014
|
+
{ accountId, scriptName }
|
|
7015
|
+
);
|
|
7016
|
+
}
|
|
7051
7017
|
const containers = managedContainers.filter(
|
|
7052
7018
|
(container) => Object.keys(container.images ?? {}).length > 0
|
|
7053
7019
|
);
|
|
@@ -25493,25 +25459,6 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25493
25459
|
type: "deploy",
|
|
25494
25460
|
workerExists
|
|
25495
25461
|
});
|
|
25496
|
-
if (!skipContainerChanges && keepVars && !isDryRun && workerExists) {
|
|
25497
|
-
await clearRemovedContainerImagesBindings(
|
|
25498
|
-
config2,
|
|
25499
|
-
durableObjectContainerConfig,
|
|
25500
|
-
bindings,
|
|
25501
|
-
workerUrl
|
|
25502
|
-
);
|
|
25503
|
-
}
|
|
25504
|
-
addContainerImagesBinding(
|
|
25505
|
-
durableObjectContainerConfig,
|
|
25506
|
-
bindings,
|
|
25507
|
-
preparedContainerImages ?? {},
|
|
25508
|
-
{
|
|
25509
|
-
preserveExisting: skipContainerChanges,
|
|
25510
|
-
exports: config2.exports,
|
|
25511
|
-
workerExists,
|
|
25512
|
-
hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
|
|
25513
|
-
}
|
|
25514
|
-
);
|
|
25515
25462
|
if (workersSitesAssets.manifest) {
|
|
25516
25463
|
modules.push({
|
|
25517
25464
|
name: "__STATIC_CONTENT_MANIFEST",
|
|
@@ -25948,10 +25895,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25948
25895
|
const { entry, compatibilityDate, compatibilityFlags, keepVars, accountId } = props;
|
|
25949
25896
|
const assetsOptions = resolveAssetOptions(props, config2);
|
|
25950
25897
|
const { name } = validateWorkerProps(props, config2);
|
|
25951
|
-
const { workerTag, tags,
|
|
25952
|
-
props,
|
|
25953
|
-
config2
|
|
25954
|
-
);
|
|
25898
|
+
const { workerTag, tags, aborted: aborted2 } = await preUploadApiChecks(props, config2);
|
|
25955
25899
|
if (aborted2) {
|
|
25956
25900
|
return { versionId: null, workerTag };
|
|
25957
25901
|
}
|
|
@@ -26001,7 +25945,8 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
26001
25945
|
{
|
|
26002
25946
|
accountId,
|
|
26003
25947
|
dryRun: Boolean(props.dryRun),
|
|
26004
|
-
scriptName
|
|
25948
|
+
scriptName,
|
|
25949
|
+
requireExistingImageLessApplications: true
|
|
26005
25950
|
}
|
|
26006
25951
|
);
|
|
26007
25952
|
const assetsUploadResult = assetsOptions && !props.dryRun ? await syncAssets(config2, accountId, assetsOptions.directory, scriptName) : void 0;
|
|
@@ -26020,20 +25965,6 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
26020
25965
|
}
|
|
26021
25966
|
}
|
|
26022
25967
|
addRequiredSecretsInheritBindings(config2, bindings, { type: "upload" });
|
|
26023
|
-
if (keepVars && !props.dryRun && workerExists) {
|
|
26024
|
-
await clearRemovedContainerImagesBindings(
|
|
26025
|
-
config2,
|
|
26026
|
-
durableObjectContainerConfig,
|
|
26027
|
-
bindings,
|
|
26028
|
-
workerUrl
|
|
26029
|
-
);
|
|
26030
|
-
}
|
|
26031
|
-
addContainerImagesBinding(
|
|
26032
|
-
durableObjectContainerConfig,
|
|
26033
|
-
bindings,
|
|
26034
|
-
preparedContainerImages ?? {},
|
|
26035
|
-
{ exports: config2.exports }
|
|
26036
|
-
);
|
|
26037
25968
|
const placement = parseConfigPlacement(config2.placement);
|
|
26038
25969
|
const entryPointName = path__default.basename(resolvedEntryPointPath);
|
|
26039
25970
|
const main = {
|
|
@@ -26221,7 +26152,9 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
26221
26152
|
assert6(versionId);
|
|
26222
26153
|
await deployDurableObjectContainerApplications(
|
|
26223
26154
|
config2,
|
|
26224
|
-
durableObjectContainerConfig
|
|
26155
|
+
durableObjectContainerConfig.filter(
|
|
26156
|
+
(container) => Object.keys(container.images ?? {}).length > 0
|
|
26157
|
+
),
|
|
26225
26158
|
{
|
|
26226
26159
|
versionId,
|
|
26227
26160
|
accountId,
|
|
@@ -27056,14 +26989,14 @@ function assemblePreviewScriptSettings(config2) {
|
|
|
27056
26989
|
return result;
|
|
27057
26990
|
}
|
|
27058
26991
|
__name(assemblePreviewScriptSettings, "assemblePreviewScriptSettings");
|
|
27059
|
-
function
|
|
27060
|
-
if (
|
|
26992
|
+
function assertPreviewBuildOutputRootConfig(rootConfig) {
|
|
26993
|
+
if (rootConfig?.buildContext.isPreview !== true) {
|
|
27061
26994
|
throw new UserError("Build Output was not created by a Preview build.", {
|
|
27062
26995
|
telemetryMessage: "preview build output missing preview intent"
|
|
27063
26996
|
});
|
|
27064
26997
|
}
|
|
27065
26998
|
}
|
|
27066
|
-
__name(
|
|
26999
|
+
__name(assertPreviewBuildOutputRootConfig, "assertPreviewBuildOutputRootConfig");
|
|
27067
27000
|
function buildPreviewContainerConfig(config2, parentWorkerName, previewSlug, previewContainers) {
|
|
27068
27001
|
const previews = config2.previews;
|
|
27069
27002
|
const previewDOBindings = previews?.durable_objects?.bindings ?? [];
|
|
@@ -27712,8 +27645,8 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
27712
27645
|
}
|
|
27713
27646
|
__name(preview, "preview");
|
|
27714
27647
|
async function previewBuildOutput(accountId, args, buildOutput) {
|
|
27715
|
-
const { workerConfig,
|
|
27716
|
-
|
|
27648
|
+
const { workerConfig, rootConfig, buildResult, assets } = buildOutput;
|
|
27649
|
+
assertPreviewBuildOutputRootConfig(rootConfig);
|
|
27717
27650
|
if (workerConfig.domains?.length) {
|
|
27718
27651
|
throw new UserError(
|
|
27719
27652
|
"Preview uploads from Build Output don't support the `domains` field.",
|
|
@@ -27756,10 +27689,14 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27756
27689
|
}
|
|
27757
27690
|
);
|
|
27758
27691
|
}
|
|
27759
|
-
const
|
|
27760
|
-
|
|
27761
|
-
|
|
27762
|
-
|
|
27692
|
+
const { buildContext: _buildContext, ...settings } = rootConfig;
|
|
27693
|
+
const { manifest: _manifest, ...worker } = workerConfig;
|
|
27694
|
+
const convertedConfig = convertToWranglerConfig({
|
|
27695
|
+
...settings,
|
|
27696
|
+
worker,
|
|
27697
|
+
// TODO: Add support for Containers in Preview uploads from Build Output.
|
|
27698
|
+
containers: []
|
|
27699
|
+
});
|
|
27763
27700
|
const previewBuildResult = buildResult && {
|
|
27764
27701
|
...buildResult,
|
|
27765
27702
|
mainModuleName: workerConfig.manifest?.mainModule
|
|
@@ -27994,4 +27931,4 @@ __name(formatBindings, "formatBindings");
|
|
|
27994
27931
|
* THE SOFTWARE.
|
|
27995
27932
|
*/
|
|
27996
27933
|
|
|
27997
|
-
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, NO_ACTIVE_PREVIEW_URLS_MESSAGE, NoInputError, PREVIEW_DOMAIN_PROVISIONING_NOTE, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewScriptSettings,
|
|
27934
|
+
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, NO_ACTIVE_PREVIEW_URLS_MESSAGE, NoInputError, PREVIEW_DOMAIN_PROVISIONING_NOTE, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewScriptSettings, assertPreviewBuildOutputRootConfig, 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, extractBuildOutputBindings, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatNoActivePreviewUrlsMessage, generatePreviewAlias, getBindingValue, getBranchName2 as 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, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, prepareDurableObjectContainerApplications, preview, previewBuildOutput, 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, validateImageLessContainerApplicationsForUpload, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, workerNotFoundErrorMessage };
|