From 1f1aefb128fb69e8c4e08f04147fe16adc3e2e4e Mon Sep 17 00:00:00 2001 From: Jacob Gardner Date: Tue, 26 Feb 2019 13:09:22 -0600 Subject: [PATCH] Add server properties to connection object --- types/amqplib/callback_api.d.ts | 106 ++++++++++++++++++++++++++------ 1 file changed, 88 insertions(+), 18 deletions(-) diff --git a/types/amqplib/callback_api.d.ts b/types/amqplib/callback_api.d.ts index 9fca3972e4..5d92376606 100644 --- a/types/amqplib/callback_api.d.ts +++ b/types/amqplib/callback_api.d.ts @@ -2,36 +2,92 @@ import events = require('events'); import { Replies, Options, Message } from './properties'; export * from './properties'; +export interface ServerProperties { + host: string; + product: string; + version: string; + platform?: string; + copyright?: string; + information?: string; +} + export interface Connection extends events.EventEmitter { close(callback?: (err: any) => void): void; createChannel(callback: (err: any, channel: Channel) => void): void; createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void; + serverProperties: ServerProperties; } export interface Channel extends events.EventEmitter { close(callback: (err: any) => void): void; - assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err: any, ok: Replies.AssertQueue) => void): void; + assertQueue( + queue?: string, + options?: Options.AssertQueue, + callback?: (err: any, ok: Replies.AssertQueue) => void + ): void; checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void; - deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err: any, ok: Replies.DeleteQueue) => void): void; + deleteQueue( + queue: string, + options?: Options.DeleteQueue, + callback?: (err: any, ok: Replies.DeleteQueue) => void + ): void; purgeQueue(queue: string, callback?: (err: any, ok: Replies.PurgeQueue) => void): void; - bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; - unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; + bindQueue( + queue: string, + source: string, + pattern: string, + args?: any, + callback?: (err: any, ok: Replies.Empty) => void + ): void; + unbindQueue( + queue: string, + source: string, + pattern: string, + args?: any, + callback?: (err: any, ok: Replies.Empty) => void + ): void; - assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void; + assertExchange( + exchange: string, + type: string, + options?: Options.AssertExchange, + callback?: (err: any, ok: Replies.AssertExchange) => void + ): void; checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void; - deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void; + deleteExchange( + exchange: string, + options?: Options.DeleteExchange, + callback?: (err: any, ok: Replies.Empty) => void + ): void; - bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; - unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; + bindExchange( + destination: string, + source: string, + pattern: string, + args?: any, + callback?: (err: any, ok: Replies.Empty) => void + ): void; + unbindExchange( + destination: string, + source: string, + pattern: string, + args?: any, + callback?: (err: any, ok: Replies.Empty) => void + ): void; publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; - consume(queue: string, onMessage: (msg: Message | null) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void; + consume( + queue: string, + onMessage: (msg: Message | null) => any, + options?: Options.Consume, + callback?: (err: any, ok: Replies.Consume) => void + ): void; cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void; get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | false) => void): void; @@ -48,22 +104,36 @@ export interface Channel extends events.EventEmitter { } export interface ConfirmChannel extends Channel { - publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; - sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; + publish( + exchange: string, + routingKey: string, + content: Buffer, + options?: Options.Publish, + callback?: (err: any, ok: Replies.Empty) => void + ): boolean; + sendToQueue( + queue: string, + content: Buffer, + options?: Options.Publish, + callback?: (err: any, ok: Replies.Empty) => void + ): boolean; waitForConfirms(callback?: (err: any) => void): void; } export const credentials: { external(): { - mechanism: string; - response(): Buffer; + mechanism: string; + response(): Buffer; }; - plain(username: string, password: string): { - mechanism: string; - response(): Buffer; - username: string; - password: string; + plain( + username: string, + password: string + ): { + mechanism: string; + response(): Buffer; + username: string; + password: string; }; };