Skip to content

Commit

Permalink
Add more useful type exports. (#70)
Browse files Browse the repository at this point in the history
* Add more useful type exports.

* 0.16.2

* Change method to private.
  • Loading branch information
ramhr committed Mar 17, 2024
1 parent 013e8c1 commit d320fb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arnavmq",
"version": "0.16.1",
"version": "0.16.2",
"description": "ArnavMQ is a RabbitMQ wrapper",
"keywords": [
"rabbitmq",
Expand Down
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import arnavmq = require('./modules/arnavmq');
declare function arnavmqFactory(config: ConnectionConfig): arnavmq.Arnavmq;

declare namespace arnavmqFactory {
export type ArnavmqFactory = (config: ConnectionConfig) => arnavmq.Arnavmq;
export type Arnavmq = arnavmq.Arnavmq;
export type ArnavmqFactory = (config: ConnectionConfig) => Arnavmq;

export { ConnectionConfig, Connection, Consumer, Producer, ConnectionHooks, ConsumerHooks, ProducerHooks };
}
Expand Down
4 changes: 4 additions & 0 deletions types/modules/consumer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ declare class Consumer {
): Promise<void>;
}

declare namespace Consumer {
export { ConsumeOptions, ConsumeCallback };
}

export = Consumer;
16 changes: 10 additions & 6 deletions types/modules/producer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare class ProducerError extends Error {
constructor(error: { name: string; message: string });
}

interface PublishOptions extends amqp.Options.Publish {
interface ProduceOptions extends amqp.Options.Publish {
routingKey?: string;
rpc?: boolean;
}
Expand Down Expand Up @@ -45,7 +45,7 @@ declare class Producer {
* @param msg The message to publish
* @param options The publish options
*/
publishOrSendToQueue(queue: string, msg: Buffer, options: PublishOptions): Promise<boolean>;
private publishOrSendToQueue(queue: string, msg: Buffer, options: ProduceOptions): Promise<boolean>;
/**
* Start a timer to reject the pending RPC call if no answer is received within the given timeout
* @param queue The queue where the RPC request was sent
Expand All @@ -61,7 +61,7 @@ declare class Producer {
* @param options contain rpc property (if true, enable rpc for this message)
* @return Resolves when message is correctly sent, or when response is received when rpc is enabled
*/
private checkRpc(queue: string, msg: Buffer, options: PublishOptions): Promise<boolean>;
private checkRpc(queue: string, msg: Buffer, options: ProduceOptions): Promise<boolean>;
/**
* @deprecated Use publish instead
* Ensure channel exists and send message using `checkRpc`
Expand All @@ -70,18 +70,22 @@ declare class Producer {
* @param options message options (persistent, durable, rpc, etc.)
* @return checkRpc response
*/
produce(queue: string, msg: unknown, options: PublishOptions): Promise<unknown>;
produce(queue: string, msg: unknown, options: ProduceOptions): Promise<unknown>;
/** @see Producer.produce */
publish(queue: string, msg: unknown, options: PublishOptions): Promise<unknown>;
publish(queue: string, msg: unknown, options: ProduceOptions): Promise<unknown>;

private _sendToQueue(
queue: string,
message: unknown,
settings: PublishOptions,
settings: ProduceOptions,
currentRetryNumber: number,
): Promise<unknown>;

private _shouldRetry(error: Error | ProducerError, currentRetryNumber: number): boolean;
}

declare namespace Producer {
export { ProduceOptions, ProducerError };
}

export = Producer;

0 comments on commit d320fb1

Please sign in to comment.