mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Add types for aws-lambda DynamoDB stream events
This commit is contained in:
@@ -100,6 +100,98 @@ str = customAuthorizerEvt.type;
|
||||
str = customAuthorizerEvt.authorizationToken;
|
||||
str = customAuthorizerEvt.methodArn;
|
||||
|
||||
/* DynamoDB Stream Event */
|
||||
var dynamoDBStreamEvent: DynamoDBStreamEvent = {
|
||||
"Records": [
|
||||
{
|
||||
"eventID": "1",
|
||||
"eventVersion": "1.0",
|
||||
"dynamodb": {
|
||||
"Keys": {
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"NewImage": {
|
||||
"Message": {
|
||||
"S": "New item!"
|
||||
},
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"StreamViewType": "NEW_AND_OLD_IMAGES",
|
||||
"SequenceNumber": "111",
|
||||
"SizeBytes": 26
|
||||
},
|
||||
"awsRegion": "us-west-2",
|
||||
"eventName": "INSERT",
|
||||
"eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899",
|
||||
"eventSource": "aws:dynamodb"
|
||||
},
|
||||
{
|
||||
"eventID": "2",
|
||||
"eventVersion": "1.0",
|
||||
"dynamodb": {
|
||||
"OldImage": {
|
||||
"Message": {
|
||||
"S": "New item!"
|
||||
},
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"SequenceNumber": "222",
|
||||
"Keys": {
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"SizeBytes": 59,
|
||||
"NewImage": {
|
||||
"Message": {
|
||||
"S": "This item has changed"
|
||||
},
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"StreamViewType": "NEW_AND_OLD_IMAGES"
|
||||
},
|
||||
"awsRegion": "us-west-2",
|
||||
"eventName": "MODIFY",
|
||||
"eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899",
|
||||
"eventSource": "aws:dynamodb"
|
||||
},
|
||||
{
|
||||
"eventID": "3",
|
||||
"eventVersion": "1.0",
|
||||
"dynamodb": {
|
||||
"Keys": {
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"SizeBytes": 38,
|
||||
"SequenceNumber": "333",
|
||||
"OldImage": {
|
||||
"Message": {
|
||||
"S": "This item has changed"
|
||||
},
|
||||
"Id": {
|
||||
"N": "101"
|
||||
}
|
||||
},
|
||||
"StreamViewType": "NEW_AND_OLD_IMAGES"
|
||||
},
|
||||
"awsRegion": "us-west-2",
|
||||
"eventName": "REMOVE",
|
||||
"eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899",
|
||||
"eventSource": "aws:dynamodb"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/* SNS Event */
|
||||
snsEvtRecs = snsEvt.Records;
|
||||
|
||||
|
||||
Vendored
+47
@@ -54,6 +54,53 @@ interface CustomAuthorizerEvent {
|
||||
methodArn: string;
|
||||
}
|
||||
|
||||
// Context
|
||||
// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_AttributeValue.html
|
||||
interface AttributeValue {
|
||||
B?: string;
|
||||
BS?: Array<string>;
|
||||
BOOL?: boolean;
|
||||
L?: Array<AttributeValue>;
|
||||
M?: { [id: string]: AttributeValue };
|
||||
N?: number;
|
||||
NS?: Array<string>;
|
||||
NULL?: boolean;
|
||||
S?: string;
|
||||
SS?: Array<string>;
|
||||
}
|
||||
|
||||
// Context
|
||||
// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html
|
||||
interface StreamRecord {
|
||||
ApproximateCreationTime?: number;
|
||||
Keys?: { [key: string]: AttributeValue };
|
||||
NewImage?: { [key: string]: AttributeValue };
|
||||
OldImage?: { [key: string]: AttributeValue };
|
||||
SequenceNumber?: string;
|
||||
SizeBytes?: number;
|
||||
StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES';
|
||||
}
|
||||
|
||||
// Context
|
||||
// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html
|
||||
interface DynamoDBRecord {
|
||||
awsRegion?: string;
|
||||
dynamodb?: StreamRecord;
|
||||
eventId?: string;
|
||||
eventName?: 'INSERT' | 'MODIFY' | 'REMOVE';
|
||||
eventSource?: string;
|
||||
eventVersion?: string;
|
||||
userIdentity?: any;
|
||||
}
|
||||
|
||||
// AWS Lambda Stream event
|
||||
// Context
|
||||
// http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update
|
||||
interface DynamoDBStreamEvent {
|
||||
Records: Array<DynamoDBRecord>;
|
||||
}
|
||||
|
||||
|
||||
// SNS "event"
|
||||
interface SNSMessageAttribute {
|
||||
Type: string;
|
||||
|
||||
Reference in New Issue
Block a user