"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DynamoEventSource=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),stream_1=require("./stream"),core_1=require("../../core");class DynamoEventSource extends stream_1.StreamEventSource{constructor(table,props){super(props),this.table=table,this._eventSourceMappingId=void 0,this._eventSourceMappingArn=void 0;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_dynamodb_ITable(table),jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_event_sources_DynamoEventSourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DynamoEventSource),error}if(this.props.batchSize!==void 0&&!core_1.Token.isUnresolved(this.props.batchSize)&&(this.props.batchSize<1||this.props.batchSize>1e4))throw new Error(`Maximum batch size must be between 1 and 10000 inclusive (given ${this.props.batchSize})`)}bind(target){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_IFunction(target)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(!this.table.tableStreamArn)throw new Error(`DynamoDB Streams must be enabled on the table ${this.table.node.path}`);const eventSourceMapping=target.addEventSourceMapping(`DynamoDBEventSource:${core_1.Names.nodeUniqueId(this.table.node)}`,this.enrichMappingOptions({eventSourceArn:this.table.tableStreamArn}));this._eventSourceMappingId=eventSourceMapping.eventSourceMappingId,this._eventSourceMappingArn=eventSourceMapping.eventSourceMappingArn,this.table.grantStreamRead(target)}get eventSourceMappingId(){if(!this._eventSourceMappingId)throw new Error("DynamoEventSource is not yet bound to an event source mapping");return this._eventSourceMappingId}get eventSourceMappingArn(){if(!this._eventSourceMappingArn)throw new Error("DynamoEventSource is not yet bound to an event source mapping");return this._eventSourceMappingArn}}exports.DynamoEventSource=DynamoEventSource,_a=JSII_RTTI_SYMBOL_1,DynamoEventSource[_a]={fqn:"aws-cdk-lib.aws_lambda_event_sources.DynamoEventSource",version:"2.96.1"};
