@go-to-k/cdkd 0.142.0 → 0.144.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.
@@ -860,6 +860,12 @@ var AssemblyReader = class {
860
860
  if (dependencyNames.length > 0) this.logger.debug(`Stack '${stackName}' depends on: [${dependencyNames.join(", ")}]`);
861
861
  let env;
862
862
  if (artifact.environment) env = parseEnvironment(artifact.environment);
863
+ const nestedTemplates = {};
864
+ for (const [logicalId, resource] of Object.entries(template.Resources ?? {})) {
865
+ if (resource?.Type !== "AWS::CloudFormation::Stack") continue;
866
+ const assetPath = resource.Metadata?.["aws:asset:path"];
867
+ if (typeof assetPath === "string" && assetPath.length > 0) nestedTemplates[logicalId] = join(assemblyDir, assetPath);
868
+ }
863
869
  return {
864
870
  stackName,
865
871
  displayName: artifact.displayName ?? stackName,
@@ -869,7 +875,8 @@ var AssemblyReader = class {
869
875
  dependencyNames,
870
876
  region: env?.region !== "unknown-region" ? env?.region : void 0,
871
877
  account: env?.account !== "unknown-account" ? env?.account : void 0,
872
- ...props?.terminationProtection !== void 0 && { terminationProtection: props.terminationProtection }
878
+ ...props?.terminationProtection !== void 0 && { terminationProtection: props.terminationProtection },
879
+ ...Object.keys(nestedTemplates).length > 0 && { nestedTemplates }
873
880
  };
874
881
  }
875
882
  /**
@@ -8923,6 +8930,23 @@ var DeployEngine = class {
8923
8930
  };
8924
8931
  }
8925
8932
  /**
8933
+ * Stamp `parentStack` / `parentLogicalId` / `parentRegion` (schema v6+)
8934
+ * onto a state object that's about to be saved, when this engine was
8935
+ * constructed with `options.parentStackInfo` (= it's deploying a
8936
+ * nested-stack child). Returns the state unchanged for top-level
8937
+ * deploys so the three v6 fields stay absent from non-child state files.
8938
+ */
8939
+ withParentInfo(state) {
8940
+ if (!this.options.parentStackInfo) return state;
8941
+ const { parentStack, parentLogicalId, parentRegion } = this.options.parentStackInfo;
8942
+ return {
8943
+ ...state,
8944
+ parentStack,
8945
+ parentLogicalId,
8946
+ parentRegion
8947
+ };
8948
+ }
8949
+ /**
8926
8950
  * Kick off `provider.readCurrentState` for a freshly-created/updated
8927
8951
  * resource without blocking the deploy critical path. The promise
8928
8952
  * lands in `observedCaptureTasks` keyed by `logicalId`; the deploy's
@@ -9092,7 +9116,7 @@ var DeployEngine = class {
9092
9116
  const saveOptions = {};
9093
9117
  if (currentEtag !== void 0) saveOptions.expectedEtag = currentEtag;
9094
9118
  if (migrationPending) saveOptions.migrateLegacy = true;
9095
- await this.stateBackend.saveState(stackName, this.stackRegion, refreshedState, saveOptions);
9119
+ await this.stateBackend.saveState(stackName, this.stackRegion, this.withParentInfo(refreshedState), saveOptions);
9096
9120
  this.logger.debug("Persisted refreshed observedProperties (no-change path)");
9097
9121
  } catch (saveError) {
9098
9122
  this.logger.warn(`Failed to persist refreshed observedProperties: ${saveError instanceof Error ? saveError.message : String(saveError)} — drift baseline will be re-fetched on next deploy.`);
@@ -9129,7 +9153,7 @@ var DeployEngine = class {
9129
9153
  };
9130
9154
  const { state: newState, actualCounts } = await this.executeDeployment(template, currentState, changes, dag, executionLevels, stackName, parameterValues, conditions, currentEtag, progress, migrationPending);
9131
9155
  await this.drainObservedCaptures(newState.resources);
9132
- const newEtag = await this.stateBackend.saveState(stackName, this.stackRegion, newState);
9156
+ const newEtag = await this.stateBackend.saveState(stackName, this.stackRegion, this.withParentInfo(newState));
9133
9157
  this.logger.debug(`State saved (ETag: ${newEtag})`);
9134
9158
  if (this.exportIndexStore) await this.exportIndexStore.updateForStack(stackName, this.stackRegion, newState.outputs ?? {});
9135
9159
  const durationMs = Date.now() - startTime;
@@ -9191,7 +9215,7 @@ var DeployEngine = class {
9191
9215
  };
9192
9216
  const migrate = pendingMigration;
9193
9217
  const expectedEtag = migrate ? void 0 : currentEtag;
9194
- currentEtag = await this.stateBackend.saveState(stackName, this.stackRegion, partialState, {
9218
+ currentEtag = await this.stateBackend.saveState(stackName, this.stackRegion, this.withParentInfo(partialState), {
9195
9219
  ...expectedEtag !== void 0 && { expectedEtag },
9196
9220
  migrateLegacy: migrate
9197
9221
  });
@@ -9297,7 +9321,7 @@ var DeployEngine = class {
9297
9321
  };
9298
9322
  const migrate = pendingMigration;
9299
9323
  const expectedEtag = migrate ? void 0 : currentEtag;
9300
- currentEtag = await this.stateBackend.saveState(stackName, this.stackRegion, preRollbackState, {
9324
+ currentEtag = await this.stateBackend.saveState(stackName, this.stackRegion, this.withParentInfo(preRollbackState), {
9301
9325
  ...expectedEtag !== void 0 && { expectedEtag },
9302
9326
  migrateLegacy: migrate
9303
9327
  });
@@ -9324,7 +9348,7 @@ var DeployEngine = class {
9324
9348
  ...currentState.imports && currentState.imports.length > 0 && { imports: currentState.imports },
9325
9349
  lastModified: Date.now()
9326
9350
  };
9327
- await this.stateBackend.saveState(stackName, this.stackRegion, postRollbackState, { ...currentEtag !== void 0 && { expectedEtag: currentEtag } });
9351
+ await this.stateBackend.saveState(stackName, this.stackRegion, this.withParentInfo(postRollbackState), { ...currentEtag !== void 0 && { expectedEtag: currentEtag } });
9328
9352
  this.logger.debug("State saved after deployment failure");
9329
9353
  } catch (saveError) {
9330
9354
  this.logger.debug(`Retrying state save after rollback (ETag mismatch): ${saveError instanceof Error ? saveError.message : String(saveError)}`);
@@ -9339,7 +9363,7 @@ var DeployEngine = class {
9339
9363
  ...currentState.imports && currentState.imports.length > 0 && { imports: currentState.imports },
9340
9364
  lastModified: Date.now()
9341
9365
  };
9342
- await this.stateBackend.saveState(stackName, this.stackRegion, postRollbackState, { ...freshEtag !== void 0 && { expectedEtag: freshEtag } });
9366
+ await this.stateBackend.saveState(stackName, this.stackRegion, this.withParentInfo(postRollbackState), { ...freshEtag !== void 0 && { expectedEtag: freshEtag } });
9343
9367
  this.logger.debug("State saved after deployment failure (retry succeeded)");
9344
9368
  } catch (retryError) {
9345
9369
  this.logger.warn(`Failed to save state after rollback: ${retryError instanceof Error ? retryError.message : String(retryError)}`);
@@ -9901,4 +9925,4 @@ var DeployEngine = class {
9901
9925
 
9902
9926
  //#endregion
9903
9927
  export { ConfigError as $, AssetPublisher as A, resolveStateBucketWithDefault as B, applyRoleArnIfSet as C, LockManager as D, TemplateParser as E, getDefaultStateBucketName as F, MIGRATE_TMP_PREFIX as G, warnDeprecatedNoPrefixCliFlag as H, getLegacyStateBucketName as I, AssemblyReader as J, findLargeInlineResources as K, resolveApp as L, WorkGraph as M, buildDockerImage as N, S3StateBackend as O, Synthesizer as P, CdkdError as Q, resolveCaptureObservedState as R, IntrinsicFunctionResolver as S, DagBuilder as T, CFN_TEMPLATE_BODY_LIMIT as U, resolveStateBucketWithDefaultAndSource as V, CFN_TEMPLATE_URL_LIMIT as W, resolveBucketRegion as X, clearBucketRegionCache as Y, AssetError as Z, normalizeAwsTagsToCfn as _, normalizeAwsError as _t, withRetry as a, MissingCdkCliError as at, CloudControlProvider as b, cyan as c, ResourceTimeoutError as ct, red as d, StackHasActiveImportsError as dt, DependencyError as et, yellow as f, StackTerminationProtectionError as ft, matchesCdkPath as g, isCdkdError as gt, CDK_PATH_TAG as h, formatError as ht, withResourceDeadline as i, LockError as it, stringifyValue as j, shouldRetainResource as k, gray as l, ResourceUpdateNotSupportedError as lt, collectInlinePolicyNamesManagedBySiblings as m, SynthesisError as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, LocalMigrateError as nt, IMPLICIT_DELETE_DEPENDENCIES as o, PartialFailureError as ot, IAMRoleProvider as p, StateError as pt, uploadCfnTemplate as q, DeployEngine as r, LocalStartServiceError as rt, bold as s, ProvisioningError as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, LocalInvokeBuildError as tt, green as u, RouteDiscoveryError as ut, resolveExplicitPhysicalId as v, withErrorHandling as vt, DiffCalculator as w, assertRegionMatch as x, ProviderRegistry as y, resolveSkipPrefix as z };
9904
- //# sourceMappingURL=deploy-engine-Dff3_JMn.js.map
9928
+ //# sourceMappingURL=deploy-engine-DjnWyAAc.js.map