/
sqs.types.ts
53 lines (46 loc) 路 1.38 KB
/
sqs.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type { SQS } from 'aws-sdk';
import type { ConsumerOptions } from 'sqs-consumer';
import type { Producer } from 'sqs-producer';
export type ProducerOptions = Parameters<typeof Producer.create>[0];
export type QueueName = string;
export enum SqsConsumerEvent {
RESPONSE_PROCESSED = 'response_processed',
EMPTY = 'empty',
MESSAGE_RECEIVED = 'message_received',
MESSAGE_PROCESSED = 'message_processed',
ERROR = 'error',
TIMEOUT_ERROR = 'timeout_error',
PROCESSING_ERROR = 'processing_error',
STOPPED = 'stopped',
}
export type SqsConsumerOptions = Omit<
ConsumerOptions,
'handleMessage' | 'handleMessageBatch' | 'queueUrl' | 'region' | 'sqs'
>;
export type SqsProducerOptions = Omit<ProducerOptions, 'queueUrl' | 'region' | 'sqs'>;
export type SqsConfigOption = SQS.Types.ClientConfiguration & {
accountNumber: string;
};
export enum SqsQueueType {
All = 'ALL',
Producer = 'PRODUCER',
Consumer = 'CONSUMER',
}
export type SqsQueueOption = {
name: QueueName;
type?: SqsQueueType;
consumerOptions?: SqsConsumerOptions;
producerOptions?: SqsProducerOptions;
};
export type SqsQueueOptions = Array<SqsQueueOption>;
export type SqsMetadata = {
name: QueueName;
messageHandler: {
batch?: boolean;
handleMessage: (...args: any[]) => any;
};
eventHandler: Array<{
eventName: string | SqsConsumerEvent;
handleEvent: (...args: any[]) => any;
}>;
};