UNPKG

1.87 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 eventSource: string;
16 eventSourceARN: string;
17 awsRegion: string;
18}
19
20export interface SQSEvent {
21 Records: SQSRecord[];
22}
23
24export interface SQSRecordAttributes {
25 AWSTraceHeader?: string | undefined;
26 ApproximateReceiveCount: string;
27 SentTimestamp: string;
28 SenderId: string;
29 ApproximateFirstReceiveTimestamp: string;
30 SequenceNumber?: string | undefined;
31 MessageGroupId?: string | undefined;
32 MessageDeduplicationId?: string | undefined;
33 DeadLetterQueueSourceArn?: string | undefined; // Undocumented, but used by AWS to support their re-drive functionality in the console
34}
35
36export type SQSMessageAttributeDataType = "String" | "Number" | "Binary" | string;
37
38export interface SQSMessageAttribute {
39 stringValue?: string | undefined;
40 binaryValue?: string | undefined;
41 stringListValues?: string[] | undefined; // Not implemented. Reserved for future use.
42 binaryListValues?: string[] | undefined; // Not implemented. Reserved for future use.
43 dataType: SQSMessageAttributeDataType;
44}
45
46export interface SQSMessageAttributes {
47 [name: string]: SQSMessageAttribute;
48}
49
50// https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting
51export interface SQSBatchResponse {
52 batchItemFailures: SQSBatchItemFailure[];
53}
54
55export interface SQSBatchItemFailure {
56 itemIdentifier: string;
57}