UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 15.8 kB
"use strict";var __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},__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};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenSearchDataSource=exports.ElasticsearchDataSource=exports.RdsDataSource=exports.LambdaDataSource=exports.EventBridgeDataSource=exports.HttpDataSource=exports.DynamoDbDataSource=exports.NoneDataSource=exports.BackedDataSource=exports.BaseDataSource=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},appsync_function_1=()=>{var tmp=require("./appsync-function");return appsync_function_1=()=>tmp,tmp},appsync_generated_1=()=>{var tmp=require("./appsync.generated");return appsync_generated_1=()=>tmp,tmp},resolver_1=()=>{var tmp=require("./resolver");return resolver_1=()=>tmp,tmp},aws_iam_1=()=>{var tmp=require("../../aws-iam");return aws_iam_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};class BaseDataSource extends constructs_1().Construct{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_appsync.BaseDataSource",version:"2.233.0"};name;ds;api;serviceRole;constructor(scope,id,props,extended){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_BackedDataSourceProps(props),jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_ExtendedDataSourceProps(extended)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,BaseDataSource),error}extended.type!=="NONE"&&(this.serviceRole=props.serviceRole||new(aws_iam_1()).Role(this,"ServiceRole",{assumedBy:new(aws_iam_1()).ServicePrincipal("appsync.amazonaws.com")}));const name=props.name??id,supportedName=core_1().Token.isUnresolved(name)?name:name.replace(/[\W]+/g,"");this.ds=new(appsync_generated_1()).CfnDataSource(this,"Resource",{apiId:props.api.apiId,name:supportedName,description:props.description,serviceRoleArn:this.serviceRole?.roleArn,...extended}),this.name=supportedName,this.api=props.api}createResolver(id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_BaseResolverProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.createResolver),error}return new(resolver_1()).Resolver(this.api,id,{api:this.api,dataSource:this,...props})}createFunction(id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_BaseAppsyncFunctionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.createFunction),error}return new(appsync_function_1()).AppsyncFunction(this.api,id,{api:this.api,dataSource:this,...props})}}exports.BaseDataSource=BaseDataSource;class BackedDataSource extends BaseDataSource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_appsync.BackedDataSource",version:"2.233.0"};grantPrincipal;constructor(scope,id,props,extended){super(scope,id,props,extended);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_BackedDataSourceProps(props),jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_ExtendedDataSourceProps(extended)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,BackedDataSource),error}this.grantPrincipal=this.serviceRole}}exports.BackedDataSource=BackedDataSource;class NoneDataSource extends BaseDataSource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_appsync.NoneDataSource",version:"2.233.0"};constructor(scope,id,props){super(scope,id,props,{type:"NONE"});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_NoneDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,NoneDataSource),error}}}exports.NoneDataSource=NoneDataSource;let DynamoDbDataSource=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=BackedDataSource;var DynamoDbDataSource2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),DynamoDbDataSource2=_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_appsync.DynamoDbDataSource",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-appsync.DynamoDbDataSource";constructor(scope,id,props){super(scope,id,props,{type:"AMAZON_DYNAMODB",dynamoDbConfig:{tableName:props.table.tableName,awsRegion:props.table.env.region,useCallerCredentials:props.useCallerCredentials}});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_DynamoDbDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DynamoDbDataSource2),error}props.readOnlyAccess?props.table.grantReadData(this):props.table.grantReadWriteData(this)}static{__runInitializers(_classThis,_classExtraInitializers)}};return DynamoDbDataSource2=_classThis})();exports.DynamoDbDataSource=DynamoDbDataSource;let HttpDataSource=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=BackedDataSource;var HttpDataSource2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),HttpDataSource2=_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_appsync.HttpDataSource",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-appsync.HttpDataSource";constructor(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_HttpDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,HttpDataSource2),error}const authorizationConfig=props.authorizationConfig?{authorizationType:"AWS_IAM",awsIamConfig:props.authorizationConfig}:void 0;super(scope,id,props,{type:"HTTP",httpConfig:{endpoint:props.endpoint,authorizationConfig}})}static{__runInitializers(_classThis,_classExtraInitializers)}};return HttpDataSource2=_classThis})();exports.HttpDataSource=HttpDataSource;let EventBridgeDataSource=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=BackedDataSource;var EventBridgeDataSource2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),EventBridgeDataSource2=_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_appsync.EventBridgeDataSource",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-appsync.EventBridgeDataSource";constructor(scope,id,props){super(scope,id,props,{type:"AMAZON_EVENTBRIDGE",eventBridgeConfig:{eventBusArn:props.eventBus.eventBusArn}});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_EventBridgeDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgeDataSource2),error}props.eventBus.grantPutEventsTo(this)}static{__runInitializers(_classThis,_classExtraInitializers)}};return EventBridgeDataSource2=_classThis})();exports.EventBridgeDataSource=EventBridgeDataSource;let LambdaDataSource=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=BackedDataSource;var LambdaDataSource2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),LambdaDataSource2=_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_appsync.LambdaDataSource",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-appsync.LambdaDataSource";constructor(scope,id,props){super(scope,id,props,{type:"AWS_LAMBDA",lambdaConfig:{lambdaFunctionArn:props.lambdaFunction.functionArn}});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_LambdaDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LambdaDataSource2),error}props.lambdaFunction.grantInvoke(this)}static{__runInitializers(_classThis,_classExtraInitializers)}};return LambdaDataSource2=_classThis})();exports.LambdaDataSource=LambdaDataSource;let RdsDataSource=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=BackedDataSource;var RdsDataSource2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),RdsDataSource2=_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_appsync.RdsDataSource",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-appsync.RdsDataSource";constructor(scope,id,props){super(scope,id,props,{type:"RELATIONAL_DATABASE",relationalDatabaseConfig:{rdsHttpEndpointConfig:{awsRegion:props.serverlessCluster.env.region,dbClusterIdentifier:core_1().Lazy.string({produce:()=>core_1().Stack.of(this).formatArn({service:"rds",resource:`cluster:${props.serverlessCluster.clusterIdentifier}`})}),awsSecretStoreArn:props.secretStore.secretArn,databaseName:props.databaseName},relationalDatabaseSourceType:"RDS_HTTP_ENDPOINT"}});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_RdsDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,RdsDataSource2),error}const clusterArn=core_1().Stack.of(this).formatArn({service:"rds",resource:`cluster:${props.serverlessCluster.clusterIdentifier}`});props.secretStore.grantRead(this),props.serverlessCluster.grantDataApiAccess(this),aws_iam_1().Grant.addToPrincipal({grantee:this,actions:["rds-data:DeleteItems","rds-data:ExecuteSql","rds-data:GetItems","rds-data:InsertItems","rds-data:UpdateItems"],resourceArns:[clusterArn,`${clusterArn}:*`]})}static{__runInitializers(_classThis,_classExtraInitializers)}};return RdsDataSource2=_classThis})();exports.RdsDataSource=RdsDataSource;class ElasticsearchDataSource extends BackedDataSource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_appsync.ElasticsearchDataSource",version:"2.233.0"};constructor(scope,id,props){super(scope,id,props,{type:"AMAZON_ELASTICSEARCH",elasticsearchConfig:{awsRegion:props.domain.env.region,endpoint:`https://${props.domain.domainEndpoint}`}});try{jsiiDeprecationWarnings().print("aws-cdk-lib.aws_appsync.ElasticsearchDataSource","- use `OpenSearchDataSource`"),jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_ElasticsearchDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ElasticsearchDataSource),error}props.domain.grantReadWrite(this)}}exports.ElasticsearchDataSource=ElasticsearchDataSource;let OpenSearchDataSource=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=BackedDataSource;var OpenSearchDataSource2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),OpenSearchDataSource2=_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_appsync.OpenSearchDataSource",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-appsync.OpenSearchDataSource";constructor(scope,id,props){super(scope,id,props,{type:"AMAZON_OPENSEARCH_SERVICE",openSearchServiceConfig:{awsRegion:props.domain.env.region,endpoint:`https://${props.domain.domainEndpoint}`}});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appsync_OpenSearchDataSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,OpenSearchDataSource2),error}props.domain.grantReadWrite(this)}static{__runInitializers(_classThis,_classExtraInitializers)}};return OpenSearchDataSource2=_classThis})();exports.OpenSearchDataSource=OpenSearchDataSource;