"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodePipelineSource=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cp_actions=require("../../../aws-codepipeline-actions"),core_1=require("../../../core"),constructs_1=require("constructs"),blueprint_1=require("../blueprint");class CodePipelineSource extends blueprint_1.Step{constructor(){super(...arguments);this.isSource=!0}static gitHub(repoString,branch,props={}){return jsiiDeprecationWarnings.aws_cdk_lib_pipelines_GitHubSourceOptions(props),new GitHubSource(repoString,branch,props)}static s3(bucket,objectKey,props={}){return jsiiDeprecationWarnings.aws_cdk_lib_aws_s3_IBucket(bucket),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_S3SourceOptions(props),new S3Source(bucket,objectKey,props)}static connection(repoString,branch,props){return jsiiDeprecationWarnings.aws_cdk_lib_pipelines_ConnectionSourceOptions(props),new CodeStarConnectionSource(repoString,branch,props)}static codeCommit(repository,branch,props={}){return jsiiDeprecationWarnings.aws_cdk_lib_aws_codecommit_IRepository(repository),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_CodeCommitSourceOptions(props),new CodeCommitSource(repository,branch,props)}produceAction(stage,options){jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_IStage(stage),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_ProduceActionOptions(options);const output=options.artifacts.toCodePipeline(this.primaryOutput),action=this.getAction(output,options.actionName,options.runOrder);return stage.addAction(action),{runOrdersConsumed:1}}}exports.CodePipelineSource=CodePipelineSource,_a=JSII_RTTI_SYMBOL_1,CodePipelineSource[_a]={fqn:"aws-cdk-lib.pipelines.CodePipelineSource",version:"2.13.0"};class GitHubSource extends CodePipelineSource{constructor(repoString,branch,props){var _b;super(repoString);this.branch=branch,this.props=props;const parts=repoString.split("/");if(core_1.Token.isUnresolved(repoString)||parts.length!==2)throw new Error(`GitHub repository name should be a resolved string like '<owner>/<repo>', got '${repoString}'`);this.owner=parts[0],this.repo=parts[1],this.authentication=(_b=props.authentication)!==null&&_b!==void 0?_b:core_1.SecretValue.secretsManager("github-token"),this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,actionName,runOrder){return new cp_actions.GitHubSourceAction({output,actionName,runOrder,oauthToken:this.authentication,owner:this.owner,repo:this.repo,branch:this.branch,trigger:this.props.trigger})}}class S3Source extends CodePipelineSource{constructor(bucket,objectKey,props){super(constructs_1.Node.of(bucket).addr);this.bucket=bucket,this.objectKey=objectKey,this.props=props,this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,_actionName,runOrder){var _b;return new cp_actions.S3SourceAction({output,actionName:(_b=this.props.actionName)!==null&&_b!==void 0?_b:this.bucket.bucketName,runOrder,bucketKey:this.objectKey,trigger:this.props.trigger,bucket:this.bucket})}}class CodeStarConnectionSource extends CodePipelineSource{constructor(repoString,branch,props){super(repoString);this.branch=branch,this.props=props;const parts=repoString.split("/");if(core_1.Token.isUnresolved(repoString)||parts.length!==2)throw new Error(`CodeStar repository name should be a resolved string like '<owner>/<repo>', got '${repoString}'`);this.owner=parts[0],this.repo=parts[1],this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,actionName,runOrder){return new cp_actions.CodeStarConnectionsSourceAction({output,actionName,runOrder,connectionArn:this.props.connectionArn,owner:this.owner,repo:this.repo,branch:this.branch,codeBuildCloneOutput:this.props.codeBuildCloneOutput,triggerOnPush:this.props.triggerOnPush})}}class CodeCommitSource extends CodePipelineSource{constructor(repository,branch,props){super(core_1.Token.isUnresolved(repository.repositoryName)?constructs_1.Node.of(repository).addr:repository.repositoryName);this.repository=repository,this.branch=branch,this.props=props,this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,_actionName,runOrder){return new cp_actions.CodeCommitSourceAction({output,actionName:this.repository.repositoryName,runOrder,branch:this.branch,trigger:this.props.trigger,repository:this.repository,eventRole:this.props.eventRole,codeBuildCloneOutput:this.props.codeBuildCloneOutput})}}
//# sourceMappingURL=codepipeline-source.js.map
