UNPKG

2.05 kBTypeScriptView Raw
1import { Handler } from "../handler";
2
3// tslint:disable-next-line:void-return
4export type DynamoDBStreamHandler = Handler<DynamoDBStreamEvent, DynamoDBBatchResponse | void>;
5
6// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_AttributeValue.html
7export interface AttributeValue {
8 B?: string | undefined;
9 BS?: string[] | undefined;
10 BOOL?: boolean | undefined;
11 L?: AttributeValue[] | undefined;
12 M?: { [id: string]: AttributeValue } | undefined;
13 N?: string | undefined;
14 NS?: string[] | undefined;
15 NULL?: boolean | undefined;
16 S?: string | undefined;
17 SS?: string[] | undefined;
18}
19
20// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html
21export interface StreamRecord {
22 ApproximateCreationDateTime?: number | undefined;
23 Keys?: { [key: string]: AttributeValue } | undefined;
24 NewImage?: { [key: string]: AttributeValue } | undefined;
25 OldImage?: { [key: string]: AttributeValue } | undefined;
26 SequenceNumber?: string | undefined;
27 SizeBytes?: number | undefined;
28 StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES' | undefined;
29}
30
31// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html
32export interface DynamoDBRecord {
33 awsRegion?: string | undefined;
34 dynamodb?: StreamRecord | undefined;
35 eventID?: string | undefined;
36 eventName?: 'INSERT' | 'MODIFY' | 'REMOVE' | undefined;
37 eventSource?: string | undefined;
38 eventSourceARN?: string | undefined;
39 eventVersion?: string | undefined;
40 userIdentity?: any;
41}
42
43// http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update
44export interface DynamoDBStreamEvent {
45 Records: DynamoDBRecord[];
46}
47
48// https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting
49export interface DynamoDBBatchResponse {
50 batchItemFailures: DynamoDBBatchItemFailure[];
51}
52
53export interface DynamoDBBatchItemFailure {
54 itemIdentifier: string;
55}