1 |
|
2 |
|
3 | import * as events from "events";
|
4 | import { ConsumeMessage, GetMessage, Message, Options, Replies, ServerProperties } from "./properties";
|
5 | export * from "./properties";
|
6 |
|
7 | export interface Connection extends events.EventEmitter {
|
8 | close(): Promise<void>;
|
9 | createChannel(): Promise<Channel>;
|
10 | createConfirmChannel(): Promise<ConfirmChannel>;
|
11 | connection: {
|
12 | serverProperties: ServerProperties;
|
13 | };
|
14 | updateSecret(newSecret: Buffer, reason: string): Promise<void>;
|
15 | }
|
16 |
|
17 | export interface Channel extends events.EventEmitter {
|
18 | connection: Connection;
|
19 |
|
20 | close(): Promise<void>;
|
21 |
|
22 | assertQueue(queue: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
|
23 | checkQueue(queue: string): Promise<Replies.AssertQueue>;
|
24 |
|
25 | deleteQueue(queue: string, options?: Options.DeleteQueue): Promise<Replies.DeleteQueue>;
|
26 | purgeQueue(queue: string): Promise<Replies.PurgeQueue>;
|
27 |
|
28 | bindQueue(queue: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
29 | unbindQueue(queue: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
30 |
|
31 | assertExchange(
|
32 | exchange: string,
|
33 | type: "direct" | "topic" | "headers" | "fanout" | "match" | string,
|
34 | options?: Options.AssertExchange,
|
35 | ): Promise<Replies.AssertExchange>;
|
36 | checkExchange(exchange: string): Promise<Replies.Empty>;
|
37 |
|
38 | deleteExchange(exchange: string, options?: Options.DeleteExchange): Promise<Replies.Empty>;
|
39 |
|
40 | bindExchange(destination: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
41 | unbindExchange(destination: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
42 |
|
43 | publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
44 | sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
45 |
|
46 | consume(
|
47 | queue: string,
|
48 | onMessage: (msg: ConsumeMessage | null) => void,
|
49 | options?: Options.Consume,
|
50 | ): Promise<Replies.Consume>;
|
51 |
|
52 | cancel(consumerTag: string): Promise<Replies.Empty>;
|
53 | get(queue: string, options?: Options.Get): Promise<GetMessage | false>;
|
54 |
|
55 | ack(message: Message, allUpTo?: boolean): void;
|
56 | ackAll(): void;
|
57 |
|
58 | nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
59 | nackAll(requeue?: boolean): void;
|
60 | reject(message: Message, requeue?: boolean): void;
|
61 |
|
62 | prefetch(count: number, global?: boolean): Promise<Replies.Empty>;
|
63 | recover(): Promise<Replies.Empty>;
|
64 | }
|
65 |
|
66 | export interface ConfirmChannel extends Channel {
|
67 | publish(
|
68 | exchange: string,
|
69 | routingKey: string,
|
70 | content: Buffer,
|
71 | options?: Options.Publish,
|
72 | callback?: (err: any, ok: Replies.Empty) => void,
|
73 | ): boolean;
|
74 | sendToQueue(
|
75 | queue: string,
|
76 | content: Buffer,
|
77 | options?: Options.Publish,
|
78 | callback?: (err: any, ok: Replies.Empty) => void,
|
79 | ): boolean;
|
80 |
|
81 | waitForConfirms(): Promise<void>;
|
82 | }
|
83 |
|
84 | export const credentials: {
|
85 | amqplain(username: string, password: string): {
|
86 | mechanism: string;
|
87 | response(): Buffer;
|
88 | username: string;
|
89 | password: string;
|
90 | };
|
91 | external(): {
|
92 | mechanism: string;
|
93 | response(): Buffer;
|
94 | };
|
95 | plain(username: string, password: string): {
|
96 | mechanism: string;
|
97 | response(): Buffer;
|
98 | username: string;
|
99 | password: string;
|
100 | };
|
101 | };
|
102 |
|
103 | export function connect(url: string | Options.Connect, socketOptions?: any): Promise<Connection>;
|