aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 12.3 kB
JavaScript
;var __runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RepositoryNotificationEvents=exports.RepositoryEventTrigger=exports.Repository=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var codecommit_grants_generated_1=()=>{var tmp=require("./codecommit-grants.generated");return codecommit_grants_generated_1=()=>tmp,tmp},codecommit_generated_1=()=>{var tmp=require("./codecommit.generated");return codecommit_generated_1=()=>tmp,tmp},notifications=()=>{var tmp=require("../../aws-codestarnotifications");return notifications=()=>tmp,tmp},events=()=>{var tmp=require("../../aws-events");return events=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};class RepositoryBase extends core_1().Resource{grants=codecommit_grants_generated_1().RepositoryGrants.fromRepository(this);get repositoryRef(){return{repositoryId:this.repositoryName,repositoryArn:this.repositoryArn}}onEvent(id,options={}){const rule=new(events()).Rule(this,id,options);return rule.addEventPattern({source:["aws.codecommit"],resources:[this.repositoryArn]}),rule.addTarget(options.target),rule}onStateChange(id,options={}){const rule=this.onEvent(id,options);return rule.addEventPattern({detailType:["CodeCommit Repository State Change"]}),rule}onReferenceCreated(id,options={}){const rule=this.onStateChange(id,options);return rule.addEventPattern({detail:{event:["referenceCreated"]}}),rule}onReferenceUpdated(id,options={}){const rule=this.onStateChange(id,options);return rule.addEventPattern({detail:{event:["referenceCreated","referenceUpdated"]}}),rule}onReferenceDeleted(id,options={}){const rule=this.onStateChange(id,options);return rule.addEventPattern({detail:{event:["referenceDeleted"]}}),rule}onPullRequestStateChange(id,options={}){const rule=this.onEvent(id,options);return rule.addEventPattern({detailType:["CodeCommit Pull Request State Change"]}),rule}onCommentOnPullRequest(id,options={}){const rule=this.onEvent(id,options);return rule.addEventPattern({detailType:["CodeCommit Comment on Pull Request"]}),rule}onCommentOnCommit(id,options={}){const rule=this.onEvent(id,options);return rule.addEventPattern({detailType:["CodeCommit Comment on Commit"]}),rule}onCommit(id,options={}){const rule=this.onReferenceUpdated(id,options);return options.branches&&rule.addEventPattern({detail:{referenceName:options.branches}}),rule}grant(grantee,...actions){return iam().Grant.addToPrincipal({grantee,actions,resourceArns:[this.repositoryArn]})}grantPull(grantee){return this.grants.pull(grantee)}grantPullPush(grantee){return this.grants.pullPush(grantee)}grantRead(grantee){return this.grants.read(grantee)}notifyOn(id,target,options){return new(notifications()).NotificationRule(this,id,{...options,source:this,targets:[target]})}notifyOnPullRequestComment(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.PULL_REQUEST_COMMENT]})}notifyOnApprovalStatusChanged(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.APPROVAL_STATUS_CHANGED]})}notifyOnApprovalRuleOverridden(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.APPROVAL_RULE_OVERRIDDEN]})}notifyOnPullRequestCreated(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.PULL_REQUEST_CREATED]})}notifiyOnPullRequestMerged(id,target,options){return this.notifyOnPullRequestMerged(id,target,options)}notifyOnPullRequestMerged(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.PULL_REQUEST_MERGED]})}notifyOnBranchOrTagCreated(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.BRANCH_OR_TAG_CREATED]})}notifyOnBranchOrTagDeleted(id,target,options){return this.notifyOn(id,target,{...options,events:[RepositoryNotificationEvents.BRANCH_OR_TAG_DELETED]})}bindAsNotificationRuleSource(_scope){return{sourceArn:this.repositoryArn}}}let Repository=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=RepositoryBase,_instanceExtraInitializers=[],_notify_decorators;var Repository2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;_notify_decorators=[(0,metadata_resource_1().MethodMetadata)()],__esDecorate(this,null,_notify_decorators,{kind:"method",name:"notify",static:!1,private:!1,access:{has:obj=>"notify"in obj,get:obj=>obj.notify},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),Repository2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_codecommit.Repository",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-codecommit.Repository";static fromRepositoryArn(scope,id,repositoryArn){const stack=core_1().Stack.of(scope),arn=stack.splitArn(repositoryArn,core_1().ArnFormat.NO_RESOURCE_NAME),repositoryName=arn.resource,region=arn.region;class Import extends RepositoryBase{repositoryArn=repositoryArn;repositoryName=repositoryName;repositoryCloneUrlHttp=makeCloneUrl(stack,repositoryName,"https",region);repositoryCloneUrlSsh=makeCloneUrl(stack,repositoryName,"ssh",region);repositoryCloneUrlGrc=makeCloneUrl(stack,repositoryName,"grc",region)}return new Import(scope,id,{account:arn.account,region})}static fromRepositoryName(scope,id,repositoryName){const stack=core_1().Stack.of(scope);class Import extends RepositoryBase{repositoryName=repositoryName;repositoryArn=core_1().Stack.of(scope).formatArn({service:"codecommit",resource:repositoryName});repositoryCloneUrlHttp=makeCloneUrl(stack,repositoryName,"https");repositoryCloneUrlSsh=makeCloneUrl(stack,repositoryName,"ssh");repositoryCloneUrlGrc=makeCloneUrl(stack,repositoryName,"grc")}return new Import(scope,id)}repositoryArn=__runInitializers(this,_instanceExtraInitializers);repositoryName;repositoryCloneUrlHttp;repositoryCloneUrlSsh;repositoryCloneUrlGrc;triggers=new Array;constructor(scope,id,props){super(scope,id,{physicalName:props.repositoryName});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codecommit_RepositoryProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Repository2),error}(0,metadata_resource_1().addConstructMetadata)(this,props);const repository=new(codecommit_generated_1()).CfnRepository(this,"Resource",{repositoryName:props.repositoryName,repositoryDescription:props.description,triggers:core_1().Lazy.any({produce:()=>this.triggers},{omitEmptyArray:!0}),code:props.code?.bind(this)?.code,kmsKeyId:props.kmsKey?.keyRef.keyArn});this.repositoryName=this.getResourceNameAttribute(repository.attrName),this.repositoryArn=this.getResourceArnAttribute(repository.attrArn,{service:"codecommit",resource:this.physicalName}),this.repositoryCloneUrlHttp=repository.attrCloneUrlHttp,this.repositoryCloneUrlSsh=repository.attrCloneUrlSsh,this.repositoryCloneUrlGrc=makeCloneUrl(core_1().Stack.of(this),this.repositoryName,"grc")}notify(arn,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codecommit_RepositoryTriggerOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.notify),error}let evt=options&&options.events;evt&&evt.length>1&&evt.indexOf(RepositoryEventTrigger.ALL)>-1&&(evt=[RepositoryEventTrigger.ALL]);const customData=options&&options.customData,branches=options&&options.branches;let name=options&&options.name;if(name||(name=this.node.path+"/"+arn),this.triggers.find(prop=>prop.name===name))throw new(core_1()).ValidationError(`Unable to set repository trigger named ${name} because trigger names must be unique`,this);return this.triggers.push({destinationArn:arn,name,customData,branches,events:evt||[RepositoryEventTrigger.ALL]}),this}static{__runInitializers(_classThis,_classExtraInitializers)}};return Repository2=_classThis})();exports.Repository=Repository;var RepositoryEventTrigger;(function(RepositoryEventTrigger2){RepositoryEventTrigger2.ALL="all",RepositoryEventTrigger2.UPDATE_REF="updateReference",RepositoryEventTrigger2.CREATE_REF="createReference",RepositoryEventTrigger2.DELETE_REF="deleteReference"})(RepositoryEventTrigger||(exports.RepositoryEventTrigger=RepositoryEventTrigger={}));function makeCloneUrl(stack,repositoryName,protocol,region){switch(protocol){case"https":case"ssh":return`${protocol}://git-codecommit.${region??stack.region}.${stack.urlSuffix}/v1/repos/${repositoryName}`;case"grc":return`codecommit::${region??stack.region}://${repositoryName}`}}var RepositoryNotificationEvents;(function(RepositoryNotificationEvents2){RepositoryNotificationEvents2.COMMIT_COMMENT="codecommit-repository-comments-on-commits",RepositoryNotificationEvents2.PULL_REQUEST_COMMENT="codecommit-repository-comments-on-pull-requests",RepositoryNotificationEvents2.APPROVAL_STATUS_CHANGED="codecommit-repository-approvals-status-changed",RepositoryNotificationEvents2.APPROVAL_RULE_OVERRIDDEN="codecommit-repository-approvals-rule-override",RepositoryNotificationEvents2.PULL_REQUEST_CREATED="codecommit-repository-pull-request-created",RepositoryNotificationEvents2.PULL_REQUEST_SOURCE_UPDATED="codecommit-repository-pull-request-source-updated",RepositoryNotificationEvents2.PULL_REQUEST_STATUS_CHANGED="codecommit-repository-pull-request-status-changed",RepositoryNotificationEvents2.PULL_REQUEST_MERGED="codecommit-repository-pull-request-merged",RepositoryNotificationEvents2.BRANCH_OR_TAG_CREATED="codecommit-repository-branches-and-tags-created",RepositoryNotificationEvents2.BRANCH_OR_TAG_DELETED="codecommit-repository-branches-and-tags-deleted",RepositoryNotificationEvents2.BRANCH_OR_TAG_UPDATED="codecommit-repository-branches-and-tags-updated"})(RepositoryNotificationEvents||(exports.RepositoryNotificationEvents=RepositoryNotificationEvents={}));