1 | import events = require("events");
|
2 | import { Message, Options, Replies, ServerProperties } from "./properties";
|
3 | export * from "./properties";
|
4 |
|
5 | export interface Connection extends events.EventEmitter {
|
6 | close(callback?: (err: any) => void): void;
|
7 | createChannel(callback: (err: any, channel: Channel) => void): void;
|
8 | createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
|
9 | connection: {
|
10 | serverProperties: ServerProperties;
|
11 | };
|
12 | }
|
13 |
|
14 | export interface Channel extends events.EventEmitter {
|
15 | connection: Connection;
|
16 |
|
17 | close(callback: (err: any) => void): void;
|
18 |
|
19 | assertQueue(
|
20 | queue?: string,
|
21 | options?: Options.AssertQueue,
|
22 | callback?: (err: any, ok: Replies.AssertQueue) => void,
|
23 | ): void;
|
24 | checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
25 |
|
26 | deleteQueue(
|
27 | queue: string,
|
28 | options?: Options.DeleteQueue,
|
29 | callback?: (err: any, ok: Replies.DeleteQueue) => void,
|
30 | ): void;
|
31 | purgeQueue(queue: string, callback?: (err: any, ok: Replies.PurgeQueue) => void): void;
|
32 |
|
33 | bindQueue(
|
34 | queue: string,
|
35 | source: string,
|
36 | pattern: string,
|
37 | args?: any,
|
38 | callback?: (err: any, ok: Replies.Empty) => void,
|
39 | ): void;
|
40 | unbindQueue(
|
41 | queue: string,
|
42 | source: string,
|
43 | pattern: string,
|
44 | args?: any,
|
45 | callback?: (err: any, ok: Replies.Empty) => void,
|
46 | ): void;
|
47 |
|
48 | assertExchange(
|
49 | exchange: string,
|
50 | type: string,
|
51 | options?: Options.AssertExchange,
|
52 | callback?: (err: any, ok: Replies.AssertExchange) => void,
|
53 | ): void;
|
54 | checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
55 |
|
56 | deleteExchange(
|
57 | exchange: string,
|
58 | options?: Options.DeleteExchange,
|
59 | callback?: (err: any, ok: Replies.Empty) => void,
|
60 | ): void;
|
61 |
|
62 | bindExchange(
|
63 | destination: string,
|
64 | source: string,
|
65 | pattern: string,
|
66 | args?: any,
|
67 | callback?: (err: any, ok: Replies.Empty) => void,
|
68 | ): void;
|
69 | unbindExchange(
|
70 | destination: string,
|
71 | source: string,
|
72 | pattern: string,
|
73 | args?: any,
|
74 | callback?: (err: any, ok: Replies.Empty) => void,
|
75 | ): void;
|
76 |
|
77 | publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
78 | sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
79 |
|
80 | consume(
|
81 | queue: string,
|
82 | onMessage: (msg: Message | null) => void,
|
83 | options?: Options.Consume,
|
84 | callback?: (err: any, ok: Replies.Consume) => void,
|
85 | ): void;
|
86 |
|
87 | cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
88 | get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | false) => void): void;
|
89 |
|
90 | ack(message: Message, allUpTo?: boolean): void;
|
91 | ackAll(): void;
|
92 |
|
93 | nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
94 | nackAll(requeue?: boolean): void;
|
95 | reject(message: Message, requeue?: boolean): void;
|
96 |
|
97 | prefetch(count: number, global?: boolean): void;
|
98 | recover(callback?: (err: any, ok: Replies.Empty) => void): void;
|
99 | }
|
100 |
|
101 | export interface ConfirmChannel extends Channel {
|
102 | publish(
|
103 | exchange: string,
|
104 | routingKey: string,
|
105 | content: Buffer,
|
106 | options?: Options.Publish,
|
107 | callback?: (err: any, ok: Replies.Empty) => void,
|
108 | ): boolean;
|
109 | sendToQueue(
|
110 | queue: string,
|
111 | content: Buffer,
|
112 | options?: Options.Publish,
|
113 | callback?: (err: any, ok: Replies.Empty) => void,
|
114 | ): boolean;
|
115 |
|
116 | waitForConfirms(callback?: (err: any) => void): void;
|
117 | }
|
118 |
|
119 | export const credentials: {
|
120 | amqplain(username: string, password: string): {
|
121 | mechanism: string;
|
122 | response(): Buffer;
|
123 | username: string;
|
124 | password: string;
|
125 | };
|
126 | external(): {
|
127 | mechanism: string;
|
128 | response(): Buffer;
|
129 | };
|
130 | plain(username: string, password: string): {
|
131 | mechanism: string;
|
132 | response(): Buffer;
|
133 | username: string;
|
134 | password: string;
|
135 | };
|
136 | };
|
137 |
|
138 | export function connect(callback: (err: any, connection: Connection) => void): void;
|
139 | export function connect(url: string | Options.Connect, callback: (err: any, connection: Connection) => void): void;
|
140 | export function connect(
|
141 | url: string | Options.Connect,
|
142 | socketOptions: any,
|
143 | callback: (err: any, connection: Connection) => void,
|
144 | ): void;
|