-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathsqs.types.ts
58 lines (48 loc) · 1.54 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
54
55
56
57
58
import type { MessageAttributeValue } from '@aws-sdk/client-sqs';
import type { LoggerService, ModuleMetadata, Type } from '@nestjs/common';
import type { Consumer, ConsumerOptions, StopOptions } from 'sqs-consumer';
import type { Producer } from 'sqs-producer';
export type ProducerOptions = Parameters<typeof Producer.create>[0];
export type QueueName = string;
export type SqsConsumerOptions = Omit<ConsumerOptions, 'handleMessage' | 'handleMessageBatch'> & {
name: QueueName;
stopOptions?: StopOptions;
};
export type SqsConsumerMapValues = {
instance: Consumer;
stopOptions: StopOptions;
};
export type SqsProducerOptions = ProducerOptions & {
name: QueueName;
};
export interface SqsOptions {
consumers?: SqsConsumerOptions[];
producers?: SqsProducerOptions[];
logger?: LoggerService;
globalStopOptions?: StopOptions;
}
export interface SqsModuleOptionsFactory {
createOptions(): Promise<SqsOptions> | SqsOptions;
}
export interface SqsModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
useExisting?: Type<SqsModuleOptionsFactory>;
useClass?: Type<SqsModuleOptionsFactory>;
useFactory?: (...args: any[]) => Promise<SqsOptions> | SqsOptions;
inject?: any[];
}
export interface Message<T = any> {
id: string;
body: T;
groupId?: string;
deduplicationId?: string;
delaySeconds?: number;
messageAttributes?: Record<string, MessageAttributeValue>;
}
export interface SqsMessageHandlerMeta {
name: string;
batch?: boolean;
}
export interface SqsConsumerEventHandlerMeta {
name: string;
eventName: string;
}