Skip to content

Commit

Permalink
fix internal type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Swain Molster committed Jul 13, 2023
1 parent 3245c49 commit 153958c
Show file tree
Hide file tree
Showing 4 changed files with 845 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build": "node build.js"
},
"devDependencies": {
"@aws-sdk/client-dynamodb": "^3.369.0",
"@lifeomic/eslint-config-standards": "^2.1.1",
"@lifeomic/jest-config": "^1.1.2",
"@lifeomic/logging": "^4.0.0",
Expand Down
14 changes: 7 additions & 7 deletions src/dynamo-streams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ describe('DynamoStreamHandler', () => {
{
eventName: 'MODIFY',
dynamodb: {
OldImage: marshall({ id: 'old-modify' }),
NewImage: marshall({ id: 'new-modify' }),
OldImage: marshall({ id: 'old-modify' }) as any,
NewImage: marshall({ id: 'new-modify' }) as any,
},
},
],
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('DynamoStreamHandler', () => {
{
eventName: 'REMOVE',
dynamodb: {
OldImage: marshall({ id: 'old-remove' }),
OldImage: marshall({ id: 'old-remove' }) as any,
},
},
],
Expand Down Expand Up @@ -189,20 +189,20 @@ describe('DynamoStreamHandler', () => {
{
eventName: 'INSERT',
dynamodb: {
NewImage: marshall({ id: 'new-insert-varied-lambda' }),
NewImage: marshall({ id: 'new-insert-varied-lambda' }) as any,
},
},
{
eventName: 'MODIFY',
dynamodb: {
OldImage: marshall({ id: 'old-modify-varied-lambda' }),
NewImage: marshall({ id: 'new-modify-varied-lambda' }),
OldImage: marshall({ id: 'old-modify-varied-lambda' }) as any,
NewImage: marshall({ id: 'new-modify-varied-lambda' }) as any,
},
},
{
eventName: 'REMOVE',
dynamodb: {
OldImage: marshall({ id: 'old-remove-varied-lambda' }),
OldImage: marshall({ id: 'old-remove-varied-lambda' }) as any,
},
},
// A second remove event to test multiple events through a single action
Expand Down
14 changes: 8 additions & 6 deletions src/dynamo-streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,13 @@ export class DynamoStreamHandler<Entity, Context> {
// Unmarshall the entities.
const oldEntity =
record.dynamodb.OldImage &&
this.config.parse(unmarshall(record.dynamodb.OldImage));
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.config.parse(unmarshall(record.dynamodb.OldImage as any));

const newEntity =
record.dynamodb.NewImage &&
this.config.parse(unmarshall(record.dynamodb.NewImage));
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.config.parse(unmarshall(record.dynamodb.NewImage as any));

// Handle INSERT events -- invoke the INSERT actions in order.
if (record.eventName === 'INSERT') {
Expand Down Expand Up @@ -266,22 +268,22 @@ export class DynamoStreamHandler<Entity, Context> {
return {
eventName: 'INSERT',
dynamodb: {
NewImage: marshall(record.entity),
NewImage: marshall(record.entity) as any,
},
};
case 'modify':
return {
eventName: 'MODIFY',
dynamodb: {
OldImage: marshall(record.oldEntity),
NewImage: marshall(record.newEntity),
OldImage: marshall(record.oldEntity) as any,
NewImage: marshall(record.newEntity) as any,
},
};
case 'remove':
return {
eventName: 'REMOVE',
dynamodb: {
OldImage: marshall(record.entity),
OldImage: marshall(record.entity) as any,
},
};
}
Expand Down
Loading

0 comments on commit 153958c

Please sign in to comment.