@cloudflare/deploy-helpers 0.2.5 → 0.3.1
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 +125 -14
- package/dist/index.mjs +540 -170
- package/dist/metafile-esm.json +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
import { D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment
|
|
1
|
+
import { S as SharedDeployVersionsProps, D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-CJdTPR7O.mjs';
|
|
2
2
|
export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-CJdTPR7O.mjs';
|
|
3
3
|
export { InputWorkerSchema, ModuleType, OutputWorkerSchema, ParsedInputWorkerConfig, ParsedOutputWorkerConfig, convertToWranglerConfig } from '@cloudflare/config';
|
|
4
|
-
import { ContainerNormalizedConfig, ImageURIConfig } from '@cloudflare/containers-shared';
|
|
5
4
|
import * as _cloudflare_workers_utils from '@cloudflare/workers-utils';
|
|
6
|
-
import { Config,
|
|
5
|
+
import { ComplianceConfig, Config, AssetsOptions, LegacyAssetPaths, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, Binding, RawConfig, ConfigBindingFieldName, CfCapnp, CfModuleType, CfWorkerInit, CfScriptFormat, CfModule, ParseError, WorkerMetadataBinding, CfUserLimits, TailConsumer, StreamingTailConsumer, Observability, ExportsReconciliationResult, ExportsReconciliationErrorDetail, StartDevWorkerInput, CfTailConsumer, ContainerApp } from '@cloudflare/workers-utils';
|
|
6
|
+
import { ContainerNormalizedConfig, ImageURIConfig } from '@cloudflare/containers-shared';
|
|
7
7
|
import { FormData } from 'undici';
|
|
8
8
|
import { Options } from '@cspotcode/source-map-support';
|
|
9
9
|
import Protocol from 'devtools-protocol';
|
|
10
10
|
import { NodeJSCompatMode, WorkerRegistry } from 'miniflare';
|
|
11
11
|
|
|
12
|
+
type AssetManifest = {
|
|
13
|
+
[path: string]: {
|
|
14
|
+
hash: string;
|
|
15
|
+
size: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type AssetUploadStats = {
|
|
19
|
+
assetUploadDurationMs: number;
|
|
20
|
+
assetUploadIsBulk: boolean;
|
|
21
|
+
assetUploadFileCount: number;
|
|
22
|
+
assetUploadTotalBytes: number;
|
|
23
|
+
};
|
|
24
|
+
type AssetsUploadResult = {
|
|
25
|
+
jwt: string;
|
|
26
|
+
assetUploadStats: AssetUploadStats;
|
|
27
|
+
};
|
|
28
|
+
declare const syncAssets: (complianceConfig: ComplianceConfig, accountId: string | undefined, assetDirectory: string, scriptName: string, dispatchNamespace?: string) => Promise<AssetsUploadResult>;
|
|
29
|
+
declare function getEdgeKvUploadConcurrency(jwt: string): number;
|
|
30
|
+
declare const buildAssetManifest: (dir: string) => Promise<AssetManifest>;
|
|
31
|
+
declare function resolveAssetOptions({ assetsDir, main }: Pick<SharedDeployVersionsProps, "assetsDir" | "main">, config: Config): AssetsOptions | undefined;
|
|
32
|
+
|
|
12
33
|
/**
|
|
13
34
|
* Wrangler-specific functions injected into `deploy()`. These remain in
|
|
14
35
|
* wrangler because they depend on wrangler-only systems (account selection,
|
|
@@ -37,6 +58,7 @@ declare function deploy(props: DeployProps, config: Config, buildResult: WorkerB
|
|
|
37
58
|
sourceMapSize?: number;
|
|
38
59
|
versionId: string | null;
|
|
39
60
|
workerTag: string | null;
|
|
61
|
+
assetUploadStats?: AssetUploadStats;
|
|
40
62
|
targets?: string[];
|
|
41
63
|
}>;
|
|
42
64
|
|
|
@@ -44,6 +66,7 @@ type VersionsUploadCallbacks = Pick<DeployCallbacks, "analyseBundle">;
|
|
|
44
66
|
declare function versionsUpload(props: VersionsUploadProps, config: Config, buildResult: WorkerBuildResult, callbacks: VersionsUploadCallbacks): Promise<{
|
|
45
67
|
versionId: string | null;
|
|
46
68
|
workerTag: string | null;
|
|
69
|
+
assetUploadStats?: AssetUploadStats;
|
|
47
70
|
versionPreviewUrl?: string | undefined;
|
|
48
71
|
versionPreviewAliasUrl?: string | undefined;
|
|
49
72
|
}>;
|
|
@@ -247,6 +270,35 @@ declare function useServiceEnvironments(config: Config | {
|
|
|
247
270
|
*/
|
|
248
271
|
/** The inherit binding references a binding that does not exist on the previous version. */
|
|
249
272
|
declare const INVALID_INHERIT_BINDING_CODE: 10057;
|
|
273
|
+
/**
|
|
274
|
+
* Blocking-error code for declarative DO exports reconciliation failures.
|
|
275
|
+
* Used to distinguish the reconciliation error envelope from other 4xx upload
|
|
276
|
+
* errors so we can render the structured per-class details.
|
|
277
|
+
*/
|
|
278
|
+
declare const EXPORTS_RECONCILIATION_ERROR_CODE = 100402;
|
|
279
|
+
/**
|
|
280
|
+
* Blocking-error code returned by EWC when a multi-version (percentage-split)
|
|
281
|
+
* deployment contains versions with divergent declarative DO `exports`. All
|
|
282
|
+
* versions in a percentage-split deploy must agree on the end-state, otherwise
|
|
283
|
+
* traffic on one branch could route to code referencing unprovisioned (or
|
|
284
|
+
* just-deleted) DO namespaces. Single-version (100%) deploys are unaffected.
|
|
285
|
+
* Resolution: deploy the version that changes `exports` at 100% first, then
|
|
286
|
+
* run the percentage-split deploy.
|
|
287
|
+
*/
|
|
288
|
+
declare const INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE = 100405;
|
|
289
|
+
/**
|
|
290
|
+
* Blocking-error code returned by EWC when a `wrangler versions upload` payload
|
|
291
|
+
* contains an actor binding (`durable_objects.bindings`) that references a
|
|
292
|
+
* Durable Object class declared in `exports` but not yet provisioned.
|
|
293
|
+
* Declarative `exports` reconcile when the version is *deployed*, so the
|
|
294
|
+
* namespace must exist before a binding can reference it. This is the
|
|
295
|
+
* exports-aware sibling of `ErrActorBindingDependsOnMigration` (10123) that
|
|
296
|
+
* already exists for the legacy `migrations` flow.
|
|
297
|
+
* Resolution: stage the new class via `ctx.exports.<ClassName>` (no binding)
|
|
298
|
+
* on `versions upload` and add the binding at deploy time, or use
|
|
299
|
+
* `wrangler deploy` to provision and bind in one step.
|
|
300
|
+
*/
|
|
301
|
+
declare const ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE = 100406;
|
|
250
302
|
|
|
251
303
|
type SecretsValidationOptions = {
|
|
252
304
|
type: "deploy";
|
|
@@ -683,6 +735,74 @@ declare function getMigrationsToUpload(scriptName: string, props: {
|
|
|
683
735
|
env: string | undefined;
|
|
684
736
|
dispatchNamespace: string | undefined;
|
|
685
737
|
}): Promise<CfWorkerInit["migrations"]>;
|
|
738
|
+
/**
|
|
739
|
+
* Resolve which Durable Object lifecycle payload to send with the upload.
|
|
740
|
+
*/
|
|
741
|
+
declare function resolveDoLifecyclePayload(props: {
|
|
742
|
+
scriptName: string;
|
|
743
|
+
isDryRun: boolean | undefined;
|
|
744
|
+
accountId: string | undefined;
|
|
745
|
+
config: Config;
|
|
746
|
+
useServiceEnvironments: boolean | undefined;
|
|
747
|
+
env: string | undefined;
|
|
748
|
+
dispatchNamespace: string | undefined;
|
|
749
|
+
}): Promise<{
|
|
750
|
+
migrations: CfWorkerInit["migrations"];
|
|
751
|
+
exports: CfWorkerInit["exports"];
|
|
752
|
+
}>;
|
|
753
|
+
|
|
754
|
+
type ResolveExportsUploadPayloadProps = Parameters<typeof resolveDoLifecyclePayload>[0];
|
|
755
|
+
declare function resolveExportsUploadPayload(props: ResolveExportsUploadPayloadProps): Promise<{
|
|
756
|
+
migrations: CfWorkerInit["migrations"];
|
|
757
|
+
exports: CfWorkerInit["exports"];
|
|
758
|
+
}>;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Render the success-side `exports_reconciliation` envelope to the logger.
|
|
762
|
+
* Emits nothing when the result has no entries to report (so a re-deploy
|
|
763
|
+
* with no DO changes doesn't add noise to the deploy output).
|
|
764
|
+
*
|
|
765
|
+
* Warnings are rendered prominently; info and removable-entry hints are lower
|
|
766
|
+
* visibility.
|
|
767
|
+
*/
|
|
768
|
+
declare function renderExportsReconciliationSuccess(result: ExportsReconciliationResult): void;
|
|
769
|
+
/**
|
|
770
|
+
* Format the structured reconciliation error details from the upload error
|
|
771
|
+
* envelope's `meta.details` field. Returns a multi-line string suitable for
|
|
772
|
+
* inclusion in a `UserError`'s message or notes. Each per-class entry is
|
|
773
|
+
* rendered with a red ✘ prefix, the scenario tag, the message, and any
|
|
774
|
+
* optional suggestion / referencing-scripts metadata.
|
|
775
|
+
*/
|
|
776
|
+
declare function renderExportsReconciliationError(details: ExportsReconciliationErrorDetail[]): string;
|
|
777
|
+
/**
|
|
778
|
+
* Type guard for `meta.details` extracted from an `APIError`'s `meta` field.
|
|
779
|
+
* Validate the array shape so the renderer can rely on the typed fields.
|
|
780
|
+
*/
|
|
781
|
+
declare function isExportsReconciliationErrorDetails(value: unknown): value is ExportsReconciliationErrorDetail[];
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Build the user-facing error message for EWC code 100405
|
|
785
|
+
* (inconsistent declarative DO `exports` across versions in a
|
|
786
|
+
* percentage-split deployment).
|
|
787
|
+
*
|
|
788
|
+
* The server's own message is already actionable; we augment it with a
|
|
789
|
+
* concrete next-step that points back at `wrangler versions deploy` and a
|
|
790
|
+
* link to the gradual-deployments docs.
|
|
791
|
+
*/
|
|
792
|
+
declare function renderInconsistentExportsAcrossVersionsError(serverMessage: string): string;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Build the user-facing error message for EWC code 100406
|
|
796
|
+
* (an actor binding references a Durable Object class declared in `exports`
|
|
797
|
+
* but not yet provisioned, on `wrangler versions upload`).
|
|
798
|
+
*
|
|
799
|
+
* EWC's own message is already fully actionable — it names the offending
|
|
800
|
+
* binding and class and spells out both remediations (deploy to provision, or
|
|
801
|
+
* drop the binding and use `ctx.exports.<ClassName>`). We surface it verbatim
|
|
802
|
+
* rather than re-deriving a less specific message client-side. The fallback is
|
|
803
|
+
* only used in the unlikely event the server sends an empty message.
|
|
804
|
+
*/
|
|
805
|
+
declare function renderBindingDependsOnExportError(serverMessage: string): string;
|
|
686
806
|
|
|
687
807
|
declare function verifyWorkerMatchesCITag(complianceConfig: ComplianceConfig, accountId: string, workerName: string, configPath: string | undefined): Promise<void>;
|
|
688
808
|
|
|
@@ -724,18 +844,9 @@ declare function printBindings(bindings: StartDevWorkerInput["bindings"], tailCo
|
|
|
724
844
|
*/
|
|
725
845
|
declare function warnOrError(type: Binding["type"], remote: boolean | undefined): void;
|
|
726
846
|
|
|
727
|
-
type AssetManifest = {
|
|
728
|
-
[path: string]: {
|
|
729
|
-
hash: string;
|
|
730
|
-
size: number;
|
|
731
|
-
};
|
|
732
|
-
};
|
|
733
|
-
declare const syncAssets: (complianceConfig: ComplianceConfig, accountId: string | undefined, assetDirectory: string, scriptName: string, dispatchNamespace?: string) => Promise<string>;
|
|
734
|
-
declare const buildAssetManifest: (dir: string) => Promise<AssetManifest>;
|
|
735
|
-
declare function resolveAssetOptions({ assetsDir, main }: Pick<SharedDeployVersionsProps, "assetsDir" | "main">, config: Config): AssetsOptions | undefined;
|
|
736
|
-
|
|
737
847
|
declare const hashFile: (filepath: string) => string;
|
|
738
848
|
|
|
849
|
+
declare const decodeJwtPayload: (token: string) => any;
|
|
739
850
|
declare const isJwtExpired: (token: string) => boolean | undefined;
|
|
740
851
|
|
|
741
852
|
type Settings = {
|
|
@@ -746,4 +857,4 @@ declare function provisionBindings(bindings: StartDevWorkerInput["bindings"], ac
|
|
|
746
857
|
}): Promise<void>;
|
|
747
858
|
declare function getSettings(complianceConfig: ComplianceConfig, accountId: string, scriptName: string): Promise<Settings>;
|
|
748
859
|
|
|
749
|
-
export { type ApiDeployment, type ApiVersion, type AssetManifest, type BulkInputNullableResult, type BulkInputResult, type Consumer, type ConsumerSettings, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, INVALID_INHERIT_BINDING_CODE, type JsonLike, NoInputError, type NonVersionedScriptSettings, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RetrieveSourceMapFunction, type RouteObject, type ScriptReference, type Settings, SharedDeployVersionsProps, TriggerDeployment, TriggerProps, type TypedConsumerResponse, type VersionCache, type VersionId, type VersionsUploadCallbacks, VersionsUploadProps, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_NOT_FOUND_CODE, WorkerBuildResult, type Workflow, type WorkflowConflict, type Zone, type ZoneIdCache, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, confirmLatestDeploymentOverwrite, convertConfigToBindings, createDeployment, createTruncatedAlias, createWorkerUploadForm, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, ensureQueuesExistByConfig, extractBindingsOfType, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, fromMimeType, generatePreviewAlias, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getMigrationsToUpload, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, moduleTypeMimeType, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderRoute, resolveAssetOptions, sanitizeBranchName, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, useServiceEnvironments, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
|
|
860
|
+
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, type ApiDeployment, type ApiVersion, type AssetManifest, type AssetUploadStats, type AssetsUploadResult, type BulkInputNullableResult, type BulkInputResult, type Consumer, type ConsumerSettings, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, type JsonLike, NoInputError, type NonVersionedScriptSettings, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RetrieveSourceMapFunction, type RouteObject, type ScriptReference, type Settings, SharedDeployVersionsProps, TriggerDeployment, TriggerProps, type TypedConsumerResponse, type VersionCache, type VersionId, type VersionsUploadCallbacks, VersionsUploadProps, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_NOT_FOUND_CODE, WorkerBuildResult, type Workflow, type WorkflowConflict, type Zone, type ZoneIdCache, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, confirmLatestDeploymentOverwrite, convertConfigToBindings, createDeployment, createTruncatedAlias, createWorkerUploadForm, decodeJwtPayload, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, ensureQueuesExistByConfig, extractBindingsOfType, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, fromMimeType, generatePreviewAlias, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getMigrationsToUpload, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, moduleTypeMimeType, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, sanitizeBranchName, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, useServiceEnvironments, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
|