Skip to content

Commit

Permalink
Add types I missed
Browse files Browse the repository at this point in the history
  • Loading branch information
ramhr committed Mar 10, 2024
1 parent 35a8461 commit 7eeea4d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion types/modules/arnavmq.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Consumer = require('./consumer');
import { Connection } from './connection';
import { ConnectionHooks, ConsumerHooks, ProducerHooks } from './hooks';

declare function arnavmq(connection: any): arnavmq.Arnavmq;
declare function arnavmq(connection: Connection): arnavmq.Arnavmq;

declare namespace arnavmq {
export type Arnavmq = {
Expand Down
6 changes: 3 additions & 3 deletions types/modules/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ interface ChannelConfig {

declare class Channels {
constructor(connection: amqp.Connection, config: ChannelConfig);
private _connection: amqp.Connection;
private _config: ChannelConfig;
private _channels: Map<string, { chann: Promise<amqp.Channel>; config: ChannelConfig }>;
private readonly _connection: amqp.Connection;
private readonly _config: ChannelConfig;
private readonly _channels: Map<string, { chann: Promise<amqp.Channel>; config: ChannelConfig }>;
get(queue: string, config: ChannelConfig): Promise<amqp.Channel>;
defaultChannel(): Promise<amqp.Channel>;
/**
Expand Down
13 changes: 13 additions & 0 deletions types/modules/connection.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import amqp = require('amqplib');
import channels = require('./channels');
import { Logger } from './logger';
import { ConnectionHooks } from './hooks/connection_hooks';

interface ConnectionConfig {
/**
Expand Down Expand Up @@ -56,6 +57,13 @@ interface ConnectionConfig {
declare class Connection {
constructor(config: ConnectionConfig);

private _connectionPromise: Promise<amqp.Connection>;
private _config: ConnectionConfig;
public hooks: ConnectionHooks;

get config(): ConnectionConfig;
set config(value: ConnectionConfig);

getConnection(): Promise<amqp.Connection>;
getChannel(queue: string, config: channels.ChannelConfig): Promise<amqp.Channel>;
getDefaultChannel(): Promise<amqp.Channel>;
Expand All @@ -65,6 +73,8 @@ declare class Connection {
* @param func the callback function to execute when the event is called
*/
addListener(on: string, func: Function): Promise<void>;

private _connect(): Promise<amqp.Connection>;
}

declare function connection(config: ConnectionConfig): Connection;
Expand All @@ -80,6 +90,9 @@ declare namespace connection {
* @param func the callback function to execute when the event is called
*/
addListener(on: string, func: Function): Promise<void>;

get config(): ConnectionConfig;
set config(value: ConnectionConfig);
}

export { ConnectionConfig };
Expand Down
2 changes: 1 addition & 1 deletion types/modules/producer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare class Producer {
*
* [queue: string] -> [correlationId: string] -> {responsePromise, timeoutId}
*/
amqpRPCQueues: Record<
private readonly amqpRPCQueues: Record<
string,
Record<string, { responsePromise: pDefer.DeferredPromise<unknown>; timeoutId: NodeJS.Timeout }>
>;
Expand Down

0 comments on commit 7eeea4d

Please sign in to comment.