diff --git a/types/index.d.ts b/types/index.d.ts index bf85409..00496c2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -6,6 +6,11 @@ export function Middleware(mwOpts: import("./src").MiddlewareOptions): { started(): Promise; stopped(): Promise; }; +export const Tracing: () => { + name: string; + created(_broker: any): void; + localChannel: (handler: any, chan: any) => any; +}; export const Adapters: { Base: typeof import("./src/adapters/base"); AMQP: typeof import("./src/adapters/amqp"); diff --git a/types/src/adapters/amqp.d.ts b/types/src/adapters/amqp.d.ts index 890bf67..c354aaa 100644 --- a/types/src/adapters/amqp.d.ts +++ b/types/src/adapters/amqp.d.ts @@ -17,6 +17,12 @@ export = AmqpAdapter; * @property {Object} amqp.exchangeOptions AMQP lib exchange configuration * @property {Object} amqp.messageOptions AMQP lib message configuration * @property {Object} amqp.consumerOptions AMQP lib consume configuration + * @property {publishAssertExchange} amqp.publishAssertExchange AMQP lib exchange configuration for one-time calling assertExchange() before publishing in new exchange by sendToChannel + */ +/** + * @typedef {Object} publishAssertExchange + * @property {Boolean} enabled Enable/disable one-time calling channel.assertExchange() before publishing in new exchange by sendToChannel + * @property {Object} exchangeOptions AMQP lib exchange configuration https://amqp-node.github.io/amqplib/channel_api.html#channel_assertExchange */ /** * @typedef {Object} SubscriptionEntry @@ -47,6 +53,10 @@ declare class AmqpAdapter extends BaseAdapter { stopping: boolean; connectAttempt: number; connectionCount: number; + /** + * @type {Set} + */ + assertedExchanges: Set; /** * Connect to the adapter with reconnecting logic */ @@ -96,7 +106,7 @@ declare class AmqpAdapter extends BaseAdapter { publish(channelName: string, payload: any, opts?: any | null): Promise; } declare namespace AmqpAdapter { - export { AMQPLibConnection, AMQPLibChannel, ServiceBroker, Logger, Channel, BaseDefaultOptions, AmqpDefaultOptions, SubscriptionEntry }; + export { AMQPLibConnection, AMQPLibChannel, ServiceBroker, Logger, Channel, BaseDefaultOptions, AmqpDefaultOptions, publishAssertExchange, SubscriptionEntry }; } import BaseAdapter = require("./base"); /** @@ -117,6 +127,7 @@ type AmqpDefaultOptions = { exchangeOptions: any; messageOptions: any; consumerOptions: any; + publishAssertExchange: publishAssertExchange; }; }; /** @@ -153,3 +164,13 @@ type ServiceBroker = import("moleculer").ServiceBroker; * Logger instance */ type Logger = import("moleculer").LoggerInstance; +type publishAssertExchange = { + /** + * Enable/disable one-time calling channel.assertExchange() before publishing in new exchange by sendToChannel + */ + enabled: boolean; + /** + * AMQP lib exchange configuration https://amqp-node.github.io/amqplib/channel_api.html#channel_assertExchange + */ + exchangeOptions: any; +}; diff --git a/types/src/index.d.ts b/types/src/index.d.ts index 184bc04..a418de9 100644 --- a/types/src/index.d.ts +++ b/types/src/index.d.ts @@ -64,6 +64,14 @@ export type DeadLetteringOptions = { * Name of the dead-letter exchange (only for AMQP adapter) */ exchangeName: string; + /** + * Options for the dead-letter exchange (only for AMQP adapter) + */ + exchangeOptions: any; + /** + * Options for the dead-letter queue (only for AMQP adapter) + */ + queueOptions: any; }; /** * Base consumer configuration @@ -142,33 +150,23 @@ export type MiddlewareOptions = { */ adapter: string | AdapterConfig; /** - * Property name of channels definition in service schema - * - * @default "channels" + * Property name of channels definition in service schema. */ - schemaProperty?: string; + schemaProperty: string | null; /** - * Method name to send messages. Default is "sendToChannel" - * - * @default "sendToChannel" + * Method name to send messages. */ - sendMethodName?: string; + sendMethodName: string | null; /** * Property name of the adapter instance in broker instance. - * - * @default "channelAdapter" */ - adapterPropertyName?: string; + adapterPropertyName: string | null; /** * Method name to add to service in order to trigger channel handlers. - * - * @default "emitLocalChannelHandler" */ - channelHandlerTrigger?: string; + channelHandlerTrigger: string | null; /** * Using Moleculer context in channel handlers by default. - * - * @default false */ - context?: boolean; + context: boolean | null; }; diff --git a/types/src/tracing.d.ts b/types/src/tracing.d.ts new file mode 100644 index 0000000..76f543e --- /dev/null +++ b/types/src/tracing.d.ts @@ -0,0 +1,6 @@ +declare function _exports(): { + name: string; + created(_broker: any): void; + localChannel: (handler: any, chan: any) => any; +}; +export = _exports;