UNPKG

1.91 kBTypeScriptView Raw
1import { Handler } from "../handler";
2
3// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
4export type SQSHandler = Handler<SQSEvent, SQSBatchResponse | void>;
5
6// SQS
7// https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html#supported-event-source-sqs
8export interface SQSRecord {
9 messageId: string;
10 receiptHandle: string;
11 body: string;
12 attributes: SQSRecordAttributes;
13 messageAttributes: SQSMessageAttributes;
14 md5OfBody: string;
15 md5OfMessageAttributes?: string;
16 eventSource: string;
17 eventSourceARN: string;
18 awsRegion: string;
19}
20
21export interface SQSEvent {
22 Records: SQSRecord[];
23}
24
25export interface SQSRecordAttributes {
26 AWSTraceHeader?: string | undefined;
27 ApproximateReceiveCount: string;
28 SentTimestamp: string;
29 SenderId: string;
30 ApproximateFirstReceiveTimestamp: string;
31 SequenceNumber?: string | undefined;
32 MessageGroupId?: string | undefined;
33 MessageDeduplicationId?: string | undefined;
34 DeadLetterQueueSourceArn?: string | undefined; // Undocumented, but used by AWS to support their re-drive functionality in the console
35}
36
37export type SQSMessageAttributeDataType = "String" | "Number" | "Binary" | string;
38
39export interface SQSMessageAttribute {
40 stringValue?: string | undefined;
41 binaryValue?: string | undefined;
42 stringListValues?: string[] | undefined; // Not implemented. Reserved for future use.
43 binaryListValues?: string[] | undefined; // Not implemented. Reserved for future use.
44 dataType: SQSMessageAttributeDataType;
45}
46
47export interface SQSMessageAttributes {
48 [name: string]: SQSMessageAttribute;
49}
50
51// https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting
52export interface SQSBatchResponse {
53 batchItemFailures: SQSBatchItemFailure[];
54}
55
56export interface SQSBatchItemFailure {
57 itemIdentifier: string;
58}