|
1 | 1 | "use strict"; |
2 | 2 |
|
3 | | -const aws = require('aws-sdk'); |
| 3 | +const { DynamoDB } = require('@aws-sdk/client-dynamodb'); |
| 4 | +const { DynamoDBStreams } = require('@aws-sdk/client-dynamodb-streams'); |
| 5 | +const { unmarshall } = require('@aws-sdk/util-dynamodb'); |
| 6 | + |
4 | 7 | const EventEmitter = require('events').EventEmitter; |
5 | 8 | const schedule = require('tempus-fugit').schedule; |
6 | 9 | const ms = require('ms'); |
@@ -29,11 +32,13 @@ class DynamodDBSubscriber extends EventEmitter { |
29 | 32 | } |
30 | 33 |
|
31 | 34 | this._ddbStream = params.endpoint |
32 | | - ? new aws.DynamoDBStreams({ |
33 | | - region: params.region, |
34 | | - endpoint: params.endpoint |
35 | | - }) |
36 | | - : new aws.DynamoDBStreams({ region: params.region }); |
| 35 | + ? new DynamoDBStreams({ |
| 36 | + region: params.region, |
| 37 | + endpoint: params.endpoint |
| 38 | + }) |
| 39 | + : new DynamoDBStreams({ |
| 40 | + region: params.region |
| 41 | + }); |
37 | 42 | } |
38 | 43 |
|
39 | 44 | _getOpenShards (callback) { |
@@ -119,7 +124,7 @@ class DynamodDBSubscriber extends EventEmitter { |
119 | 124 |
|
120 | 125 | if (data.Records && data.Records.length > 0) { |
121 | 126 | data.Records.forEach(r => { |
122 | | - const key = r.dynamodb && r.dynamodb.Keys && aws.DynamoDB.Converter.output({M: r.dynamodb.Keys}); |
| 127 | + const key = r.dynamodb && r.dynamodb.Keys && unmarshall(r.dynamodb.Keys); |
123 | 128 | this.emit('record', r, key); |
124 | 129 | }); |
125 | 130 | } |
@@ -159,8 +164,13 @@ class DynamodDBSubscriber extends EventEmitter { |
159 | 164 | cb => { |
160 | 165 | if (this._streamArn) { return cb(); } |
161 | 166 | const dynamo = this._endpoint |
162 | | - ? new aws.DynamoDB({ region: this._region, endpoint: this._endpoint }) |
163 | | - : new aws.DynamoDB({ region: this._region }); |
| 167 | + ? new DynamoDB({ |
| 168 | + region: this._region, |
| 169 | + endpoint: this._endpoint |
| 170 | + }) |
| 171 | + : new DynamoDB({ |
| 172 | + region: this._region |
| 173 | + }); |
164 | 174 | dynamo.describeTable({ TableName: this._table }, (err, tableDescription) => { |
165 | 175 | if (err) { |
166 | 176 | return cb(); |
|
0 commit comments