@cloudflare/deploy-helpers 0.25.0 → 0.26.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.
@@ -102,6 +102,8 @@ type SharedDeployVersionsProps = {
102
102
  skipProvisioningConfigWriteback: boolean;
103
103
  /** From --strict arg. In strict mode, conflicting pre-upload checks abort instead of auto-continuing. */
104
104
  strict: boolean;
105
+ /** Optional consumer-specific message shown when strict mode aborts in a non-interactive session. */
106
+ strictModeAbortMessage?: string;
105
107
  /** Container configuration and locally built image state. */
106
108
  containers: ContainerDeployConfig;
107
109
  /** Whether the resolved Worker name differs from the pre-merge config/args name. */
@@ -1,3 +1,3 @@
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-qB2Gxcuw.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-BY_xpg-t.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, C as ContainerlessConfig, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment, B as BuiltDurableObjectContainerImage } from './context-qB2Gxcuw.mjs';
2
- export { b as ContainerDeployConfig, c as DeployHelpersContext, i as initDeployHelpersContext } from './context-qB2Gxcuw.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-BY_xpg-t.mjs';
2
+ export { b as ContainerDeployConfig, c as DeployHelpersContext, i as initDeployHelpersContext } from './context-BY_xpg-t.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, ResolvedDurableObjectContainerApp, DurableObjectContainerApp, ExportsReconciliationErrorDetail, ExportsReconciliationResult, StartDevWorkerInput, Json, CacheOptions, PreviewsConfig } from '@cloudflare/workers-utils';
5
5
  import { FormData } from 'undici';
@@ -512,6 +512,7 @@ declare function deployWfpUserWorker(dispatchNamespace: string, versionId: strin
512
512
 
513
513
  declare function getDeployConfirmFunction(options: {
514
514
  strictMode?: boolean;
515
+ strictModeAbortMessage?: string;
515
516
  }): (text: string) => Promise<boolean>;
516
517
 
517
518
  /**
package/dist/index.mjs CHANGED
@@ -8547,16 +8547,35 @@ var D1Handler = class extends ProvisionResourceHandler {
8547
8547
  this.accountId,
8548
8548
  name,
8549
8549
  this.d1ListCommand,
8550
- this.d1DeleteCommand
8550
+ this.d1DeleteCommand,
8551
+ this.binding.jurisdiction
8551
8552
  );
8552
8553
  return db.uuid;
8553
8554
  }
8555
+ throwIfJurisdictionMismatch(db) {
8556
+ const requestedJurisdiction = this.binding.jurisdiction;
8557
+ if (!requestedJurisdiction || requestedJurisdiction === db.jurisdiction) {
8558
+ return;
8559
+ }
8560
+ const existingJurisdiction = db.jurisdiction ?? "default";
8561
+ const matchingConfigAction = db.jurisdiction ? `set "jurisdiction" to "${db.jurisdiction}"` : `remove "jurisdiction"`;
8562
+ throw new UserError(
8563
+ esm_default`
8564
+ D1 database "${db.name}" (${db.uuid}) is in jurisdiction "${existingJurisdiction}", but the "${this.bindingName}" binding specifies jurisdiction "${requestedJurisdiction}".
8565
+
8566
+ A D1 database's jurisdiction cannot be changed after creation. Either:
8567
+ - ${matchingConfigAction} in your configuration to keep using this database, or
8568
+ - set a new "database_name" for this binding so a new database is provisioned in "${requestedJurisdiction}" (then migrate your data).
8569
+ `,
8570
+ { telemetryMessage: "d1 provision jurisdiction mismatch" }
8571
+ );
8572
+ }
8554
8573
  async canInherit(settings) {
8555
8574
  const maybeInherited = settings?.bindings.find(
8556
8575
  (existing) => existing.type === this.type && existing.name === this.bindingName
8557
8576
  );
8558
8577
  if (maybeInherited) {
8559
- if (!this.binding.database_name) {
8578
+ if (!this.binding.database_name && !this.binding.jurisdiction) {
8560
8579
  return true;
8561
8580
  }
8562
8581
  const dbFromId = await getDatabaseInfoFromIdOrName(
@@ -8564,9 +8583,14 @@ var D1Handler = class extends ProvisionResourceHandler {
8564
8583
  this.accountId,
8565
8584
  maybeInherited.id
8566
8585
  );
8567
- if (this.binding.database_name === dbFromId.name) {
8586
+ const nameMatches = !this.binding.database_name || this.binding.database_name === dbFromId.name;
8587
+ const jurisdictionMatches = !this.binding.jurisdiction || this.binding.jurisdiction === dbFromId.jurisdiction;
8588
+ if (nameMatches && jurisdictionMatches) {
8568
8589
  return true;
8569
8590
  }
8591
+ if (nameMatches) {
8592
+ this.throwIfJurisdictionMismatch(dbFromId);
8593
+ }
8570
8594
  }
8571
8595
  return false;
8572
8596
  }
@@ -8581,6 +8605,7 @@ var D1Handler = class extends ProvisionResourceHandler {
8581
8605
  this.accountId,
8582
8606
  this.binding.database_name
8583
8607
  );
8608
+ this.throwIfJurisdictionMismatch(db);
8584
8609
  return db.uuid;
8585
8610
  } catch (e) {
8586
8611
  if (!(e instanceof APIError && e.code === 7404)) {
@@ -9261,7 +9286,7 @@ async function listFlagshipApps(complianceConfig, accountId) {
9261
9286
  );
9262
9287
  }
9263
9288
  __name(listFlagshipApps, "listFlagshipApps");
9264
- async function createD1Database(complianceConfig, accountId, name, d1ListCommand, d1DeleteCommand) {
9289
+ async function createD1Database(complianceConfig, accountId, name, d1ListCommand, d1DeleteCommand, jurisdiction) {
9265
9290
  try {
9266
9291
  return await fetchResult(
9267
9292
  complianceConfig,
@@ -9271,7 +9296,10 @@ async function createD1Database(complianceConfig, accountId, name, d1ListCommand
9271
9296
  headers: {
9272
9297
  "Content-Type": "application/json"
9273
9298
  },
9274
- body: JSON.stringify({ name })
9299
+ body: JSON.stringify({
9300
+ name,
9301
+ ...jurisdiction && { jurisdiction }
9302
+ })
9275
9303
  }
9276
9304
  );
9277
9305
  } catch (e) {
@@ -30907,13 +30935,14 @@ function populateConfigPatchObject(diff, patchObj, targetEnvironment) {
30907
30935
  }
30908
30936
  __name(populateConfigPatchObject, "populateConfigPatchObject");
30909
30937
  function getDeployConfirmFunction(options) {
30910
- const { strictMode = false } = options;
30938
+ const {
30939
+ strictMode = false,
30940
+ strictModeAbortMessage = "Aborting the upload operation because of conflicts. To override and upload anyway, remove the `--strict` flag"
30941
+ } = options;
30911
30942
  const nonInteractive = isNonInteractiveOrCI();
30912
30943
  if (nonInteractive && strictMode) {
30913
30944
  return async () => {
30914
- logger.error(
30915
- "Aborting the upload operation because of conflicts. To override and upload anyway, remove the `--strict` flag"
30916
- );
30945
+ logger.error(strictModeAbortMessage);
30917
30946
  process.exitCode = 1;
30918
30947
  return false;
30919
30948
  };
@@ -31291,7 +31320,8 @@ async function preUploadApiChecks(props, config2, queueCreateCommand) {
31291
31320
  }
31292
31321
  await verifyWorkerMatchesCITag(config2, accountId, name, config2.configPath);
31293
31322
  const deployConfirm = getDeployConfirmFunction({
31294
- strictMode: props.strict
31323
+ strictMode: props.strict,
31324
+ strictModeAbortMessage: props.strictModeAbortMessage
31295
31325
  });
31296
31326
  let workerTag = null;
31297
31327
  let tags = [];
@@ -31999,6 +32029,11 @@ async function deployWorker(props, config2, buildResult, options) {
31999
32029
  }
32000
32030
  }
32001
32031
  if (props.dispatchNamespace !== void 0) {
32032
+ if (props.triggers?.length) {
32033
+ logger.warn(
32034
+ "Cron triggers are not supported with --dispatch-namespace and will be ignored."
32035
+ );
32036
+ }
32002
32037
  deployWfpUserWorker(props.dispatchNamespace, versionId);
32003
32038
  return { versionId, workerTag, assetUploadStats, bundleSize };
32004
32039
  }