"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StageDeployment=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var stack_deployment_1=()=>{var tmp=require("./stack-deployment");return stack_deployment_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},cloud_assembly_internals_1=()=>{var tmp=require("../private/cloud-assembly-internals");return cloud_assembly_internals_1=()=>tmp,tmp},construct_internals_1=()=>{var tmp=require("../private/construct-internals");return construct_internals_1=()=>tmp,tmp};class StageDeployment{stacks;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.pipelines.StageDeployment",version:"2.256.1"};static fromStage(stage,props={}){try{jsiiDeprecationWarnings().aws_cdk_lib_Stage(stage),jsiiDeprecationWarnings().aws_cdk_lib_pipelines_StageDeploymentProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStage),error}const assembly=(0,construct_internals_1().pipelineSynth)(stage);if(assembly.stacks.length===0)throw new(core_1()).ValidationError((0,literal_string_1().lit)`GivenStageConstruct`,`The given Stage construct ('${stage.node.path}') should contain at least one Stack`,stage);const stepFromArtifact=new Map;for(const artifact of assembly.stacks){if(artifact.assumeRoleAdditionalOptions?.Tags&&artifact.assumeRoleArn)throw new(core_1()).ValidationError((0,literal_string_1().lit)`DeploymentStack`,`Deployment of stack ${artifact.stackName} requires assuming the role ${artifact.assumeRoleArn} with session tags, but assuming roles with session tags is not supported by CodePipeline.`,stage);const step=stack_deployment_1().StackDeployment.fromArtifact(artifact);stepFromArtifact.set(artifact,step)}if(props.stackSteps)for(const stackstep of props.stackSteps){const stackArtifact=assembly.getStackArtifact(stackstep.stack.artifactId),thisStep=stepFromArtifact.get(stackArtifact);if(!thisStep)throw new(core_1()).ValidationError((0,literal_string_1().lit)`LogicErrorAddedStepArtifact`,"Logic error: we just added a step for this artifact but it disappeared.",stage);thisStep.addStackSteps(stackstep.pre??[],stackstep.changeSet??[],stackstep.post??[])}for(const artifact of assembly.stacks){const thisStep=stepFromArtifact.get(artifact);if(!thisStep)throw new(core_1()).ValidationError((0,literal_string_1().lit)`LogicErrorAddedStepArtifact`,"Logic error: we just added a step for this artifact but it disappeared.",stage);const stackDependencies=artifact.dependencies.filter(cloud_assembly_internals_1().isStackArtifact);for(const dep of stackDependencies){const depStep=stepFromArtifact.get(dep);if(!depStep)throw new(core_1()).ValidationError((0,literal_string_1().lit)`StackDependsStackFound`,`Stack '${artifact.id}' depends on stack not found in same Stage: '${dep.id}'`,stage);thisStep.addStackDependency(depStep)}}return new StageDeployment(Array.from(stepFromArtifact.values()),{stageName:stage.stageName,...props})}stageName;pre;post;stackSteps;prepareStep;constructor(stacks,props={}){this.stacks=stacks,this.stageName=props.stageName??"",this.pre=props.pre??[],this.post=props.post??[],this.stackSteps=props.stackSteps??[]}addPre(...steps){try{jsiiDeprecationWarnings().aws_cdk_lib_pipelines_Step(steps)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPre),error}this.pre.push(...steps)}addPost(...steps){try{jsiiDeprecationWarnings().aws_cdk_lib_pipelines_Step(steps)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPost),error}this.post.push(...steps)}}exports.StageDeployment=StageDeployment;
