mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #21021 from MichaelMarner/aws-lambda-dynamo
Add aws-lambda DynamoDB stream event types
This commit is contained in:
@@ -109,6 +109,101 @@ str = apiGwEvt.queryStringParameters["example"];
|
||||
str = apiGwEvt.stageVariables["example"];
|
||||
apiGwEvtReqCtx = apiGwEvt.requestContext;
|
||||
|
||||
/* DynamoDB Stream Event */
|
||||
var dynamoDBStreamEvent: AWSLambda.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
+48
@@ -8,6 +8,7 @@
|
||||
// Yoriki Yamaguchi <https://github.com/y13i>
|
||||
// wwwy3y3 <https://github.com/wwwy3y3>
|
||||
// Ishaan Malhi <https://github.com/OrthoDex>
|
||||
// Michael Marner <https://github.com/MichaelMarner>
|
||||
// Daniel Cottone <https://github.com/daniel-cottone>
|
||||
// Kostya Misura <https://github.com/kostya-misura>
|
||||
// Markus Tacker <https://github.com/coderbyheart>
|
||||
@@ -65,6 +66,53 @@ interface CustomAuthorizerEvent {
|
||||
requestContext?: APIGatewayEventRequestContext;
|
||||
}
|
||||
|
||||
// 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;
|
||||
eventSourceARN?: 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