aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 5.57 kB
JavaScript
var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Trigger=exports.ProviderType=exports.GitPullRequestEvent=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var GitPullRequestEvent;(function(GitPullRequestEvent2){GitPullRequestEvent2.OPEN="OPEN",GitPullRequestEvent2.UPDATED="UPDATED",GitPullRequestEvent2.CLOSED="CLOSED"})(GitPullRequestEvent||(exports.GitPullRequestEvent=GitPullRequestEvent={}));var ProviderType;(function(ProviderType2){ProviderType2.CODE_STAR_SOURCE_CONNECTION="CodeStarSourceConnection"})(ProviderType||(exports.ProviderType=ProviderType={}));class Trigger{constructor(props){this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_TriggerProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Trigger),error}this.sourceAction=props.gitConfiguration?.sourceAction,this.validate()}validate(){if(this.props.gitConfiguration){const{sourceAction,pushFilter,pullRequestFilter}=this.props.gitConfiguration;if(sourceAction.actionProperties.provider!=="CodeStarSourceConnection")throw new Error(`provider for actionProperties in sourceAction with name '${sourceAction.actionProperties.actionName}' must be 'CodeStarSourceConnection', got '${sourceAction.actionProperties.provider}'`);if(pushFilter?.length&&pullRequestFilter?.length)throw new Error(`cannot specify both pushFilter and pullRequestFilter for the trigger with sourceAction with name '${sourceAction.actionProperties.actionName}'`);if(!pushFilter?.length&&!pullRequestFilter?.length)throw new Error(`must specify either pushFilter or pullRequestFilter for the trigger with sourceAction with name '${sourceAction.actionProperties.actionName}'`);if(pushFilter!==void 0&&pushFilter.length>3)throw new Error(`length of pushFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' must be less than or equal to 3, got ${pushFilter.length}`);if(pushFilter?.forEach(filter=>{if(filter.tagsExcludes&&filter.tagsExcludes.length>8)throw new Error(`maximum length of tagsExcludes in pushFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' is 8, got ${filter.tagsExcludes.length}`);if(filter.tagsIncludes&&filter.tagsIncludes.length>8)throw new Error(`maximum length of tagsIncludes in pushFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' is 8, got ${filter.tagsIncludes.length}`)}),pullRequestFilter!==void 0&&pullRequestFilter.length>3)throw new Error(`length of pullRequestFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' must be less than or equal to 3, got ${pullRequestFilter.length}`);pullRequestFilter?.forEach(filter=>{if(!filter.branchesExcludes&&!filter.branchesIncludes)throw new Error(`must specify branches in pullRequestFilter for sourceAction with name '${sourceAction.actionProperties.actionName}'`);if(filter.branchesExcludes&&filter.branchesExcludes.length>8)throw new Error(`maximum length of branchesExcludes in pullRequestFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' is 8, got ${filter.branchesExcludes.length}`);if(filter.branchesIncludes&&filter.branchesIncludes.length>8)throw new Error(`maximum length of branchesIncludes in pullRequestFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' is 8, got ${filter.branchesIncludes.length}`);if(filter.filePathsExcludes&&filter.filePathsExcludes.length>8)throw new Error(`maximum length of filePathsExcludes in pullRequestFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' is 8, got ${filter.filePathsExcludes.length}`);if(filter.filePathsIncludes&&filter.filePathsIncludes.length>8)throw new Error(`maximum length of filePathsIncludes in pullRequestFilter for sourceAction with name '${sourceAction.actionProperties.actionName}' is 8, got ${filter.filePathsIncludes.length}`)})}}_render(){let gitConfiguration;if(this.props.gitConfiguration){const{sourceAction,pushFilter,pullRequestFilter}=this.props.gitConfiguration,push=this.renderPushFilter(pushFilter),pullRequest=this.renderPullRequestFilter(pullRequestFilter);gitConfiguration={push:push?.length?push:void 0,pullRequest:pullRequest?.length?pullRequest:void 0,sourceActionName:sourceAction.actionProperties.actionName}}return{gitConfiguration,providerType:this.props.providerType}}renderPushFilter(pushFilter){return pushFilter?.map(filter=>({tags:{excludes:filter.tagsExcludes?.length?filter.tagsExcludes:void 0,includes:filter.tagsIncludes?.length?filter.tagsIncludes:void 0}}))}renderPullRequestFilter(pullRequest){return pullRequest?.map(filter=>{const branches=filter.branchesExcludes?.length||filter.branchesIncludes?.length?{excludes:filter.branchesExcludes?.length?filter.branchesExcludes:void 0,includes:filter.branchesIncludes?.length?filter.branchesIncludes:void 0}:void 0,filePaths=filter.filePathsExcludes?.length||filter.filePathsIncludes?.length?{excludes:filter.filePathsExcludes?.length?filter.filePathsExcludes:void 0,includes:filter.filePathsIncludes?.length?filter.filePathsIncludes:void 0}:void 0,events=filter.events?.length?Array.from(new Set(filter.events)):[GitPullRequestEvent.OPEN,GitPullRequestEvent.UPDATED,GitPullRequestEvent.CLOSED];return{branches,filePaths,events}})}}exports.Trigger=Trigger,_a=JSII_RTTI_SYMBOL_1,Trigger[_a]={fqn:"aws-cdk-lib.aws_codepipeline.Trigger",version:"2.185.0"};
;