@opra/rabbitmq 1.19.3 → 1.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/augmentation/opra-common.augmentation.js +1 -1
- package/cjs/config-builder.js +2 -2
- package/cjs/rabbitmq-adapter.js +3 -3
- package/cjs/rabbitmq-context.js +2 -2
- package/esm/augmentation/opra-common.augmentation.js +1 -1
- package/esm/config-builder.js +3 -3
- package/esm/rabbitmq-adapter.js +4 -4
- package/esm/rabbitmq-context.js +2 -2
- package/package.json +8 -8
- package/types/augmentation/opra-common.augmentation.d.ts +1 -1
- package/types/config-builder.d.ts +5 -5
- package/types/rabbitmq-adapter.d.ts +7 -7
- package/types/rabbitmq-context.d.ts +5 -5
|
@@ -4,7 +4,7 @@ require("@opra/core");
|
|
|
4
4
|
const common_1 = require("@opra/common");
|
|
5
5
|
const constants_js_1 = require("../constants.js");
|
|
6
6
|
/** Implementation **/
|
|
7
|
-
common_1.classes.
|
|
7
|
+
common_1.classes.MQOperationDecoratorFactory.augment((decorator, decoratorChain) => {
|
|
8
8
|
decorator.RabbitMQ = (config) => {
|
|
9
9
|
decoratorChain.push((_, target, propertyKey) => {
|
|
10
10
|
if (typeof config === 'function') {
|
package/cjs/config-builder.js
CHANGED
|
@@ -14,7 +14,7 @@ class ConfigBuilder {
|
|
|
14
14
|
this.handlerArgs = [];
|
|
15
15
|
this._prepareConnectionOptions();
|
|
16
16
|
/** Initialize consumers */
|
|
17
|
-
for (const controller of this.document.
|
|
17
|
+
for (const controller of this.document.mqApi.controllers.values()) {
|
|
18
18
|
let instance = controller.instance;
|
|
19
19
|
if (!instance && controller.ctor)
|
|
20
20
|
instance = new controller.ctor();
|
|
@@ -64,7 +64,7 @@ class ConfigBuilder {
|
|
|
64
64
|
if (typeof instance[operation.name] !== 'function')
|
|
65
65
|
return;
|
|
66
66
|
const proto = controller.ctor?.prototype || Object.getPrototypeOf(instance);
|
|
67
|
-
if (Reflect.hasMetadata(common_1.
|
|
67
|
+
if (Reflect.hasMetadata(common_1.MQ_CONTROLLER_METADATA, proto, operation.name))
|
|
68
68
|
return;
|
|
69
69
|
const operationConfig = {};
|
|
70
70
|
if (this.config.defaults) {
|
package/cjs/rabbitmq-adapter.js
CHANGED
|
@@ -36,11 +36,11 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
36
36
|
this._controllerInstances = new Map();
|
|
37
37
|
this._consumers = [];
|
|
38
38
|
this._status = 'idle';
|
|
39
|
-
this.protocol = '
|
|
39
|
+
this.protocol = 'mq';
|
|
40
40
|
this.platform = RabbitmqAdapter.PlatformName;
|
|
41
41
|
this._document = document;
|
|
42
42
|
this._config = config;
|
|
43
|
-
if (!(this.document.api instanceof common_1.
|
|
43
|
+
if (!(this.document.api instanceof common_1.MQApi &&
|
|
44
44
|
this.document.api.platform === RabbitmqAdapter.PlatformName)) {
|
|
45
45
|
throw new TypeError(`The document doesn't expose a RabbitMQ Api`);
|
|
46
46
|
}
|
|
@@ -56,7 +56,7 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
get api() {
|
|
59
|
-
return this.document.
|
|
59
|
+
return this.document.mqApi;
|
|
60
60
|
}
|
|
61
61
|
get connection() {
|
|
62
62
|
return this._connection;
|
package/cjs/rabbitmq-context.js
CHANGED
|
@@ -16,11 +16,11 @@ class RabbitmqContext extends core_1.ExecutionContext {
|
|
|
16
16
|
...init,
|
|
17
17
|
document: init.adapter.document,
|
|
18
18
|
documentNode: init.controller?.node,
|
|
19
|
-
protocol: '
|
|
19
|
+
protocol: 'mq',
|
|
20
20
|
});
|
|
21
21
|
this.adapter = init.adapter;
|
|
22
22
|
this.platform = init.adapter.platform;
|
|
23
|
-
this.protocol = '
|
|
23
|
+
this.protocol = 'mq';
|
|
24
24
|
if (init.controller)
|
|
25
25
|
this.controller = init.controller;
|
|
26
26
|
if (init.controllerInstance)
|
|
@@ -2,7 +2,7 @@ import '@opra/core';
|
|
|
2
2
|
import { classes } from '@opra/common';
|
|
3
3
|
import { RMQ_OPERATION_METADATA, RMQ_OPERATION_METADATA_RESOLVER, } from '../constants.js';
|
|
4
4
|
/** Implementation **/
|
|
5
|
-
classes.
|
|
5
|
+
classes.MQOperationDecoratorFactory.augment((decorator, decoratorChain) => {
|
|
6
6
|
decorator.RabbitMQ = (config) => {
|
|
7
7
|
decoratorChain.push((_, target, propertyKey) => {
|
|
8
8
|
if (typeof config === 'function') {
|
package/esm/config-builder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { merge } from '@jsopen/objects';
|
|
2
|
-
import {
|
|
2
|
+
import { MQ_CONTROLLER_METADATA, } from '@opra/common';
|
|
3
3
|
import { RMQ_OPERATION_METADATA, RMQ_OPERATION_METADATA_RESOLVER, } from './constants.js';
|
|
4
4
|
export class ConfigBuilder {
|
|
5
5
|
constructor(document, config) {
|
|
@@ -11,7 +11,7 @@ export class ConfigBuilder {
|
|
|
11
11
|
this.handlerArgs = [];
|
|
12
12
|
this._prepareConnectionOptions();
|
|
13
13
|
/** Initialize consumers */
|
|
14
|
-
for (const controller of this.document.
|
|
14
|
+
for (const controller of this.document.mqApi.controllers.values()) {
|
|
15
15
|
let instance = controller.instance;
|
|
16
16
|
if (!instance && controller.ctor)
|
|
17
17
|
instance = new controller.ctor();
|
|
@@ -61,7 +61,7 @@ export class ConfigBuilder {
|
|
|
61
61
|
if (typeof instance[operation.name] !== 'function')
|
|
62
62
|
return;
|
|
63
63
|
const proto = controller.ctor?.prototype || Object.getPrototypeOf(instance);
|
|
64
|
-
if (Reflect.hasMetadata(
|
|
64
|
+
if (Reflect.hasMetadata(MQ_CONTROLLER_METADATA, proto, operation.name))
|
|
65
65
|
return;
|
|
66
66
|
const operationConfig = {};
|
|
67
67
|
if (this.config.defaults) {
|
package/esm/rabbitmq-adapter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import zlib from 'node:zlib';
|
|
2
2
|
import typeIs from '@browsery/type-is';
|
|
3
|
-
import {
|
|
3
|
+
import { MQApi, OpraException, } from '@opra/common';
|
|
4
4
|
import { kAssetCache, PlatformAdapter } from '@opra/core';
|
|
5
5
|
import { parse as parseContentType } from 'content-type';
|
|
6
6
|
import iconv from 'iconv-lite';
|
|
@@ -32,11 +32,11 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
32
32
|
this._controllerInstances = new Map();
|
|
33
33
|
this._consumers = [];
|
|
34
34
|
this._status = 'idle';
|
|
35
|
-
this.protocol = '
|
|
35
|
+
this.protocol = 'mq';
|
|
36
36
|
this.platform = RabbitmqAdapter.PlatformName;
|
|
37
37
|
this._document = document;
|
|
38
38
|
this._config = config;
|
|
39
|
-
if (!(this.document.api instanceof
|
|
39
|
+
if (!(this.document.api instanceof MQApi &&
|
|
40
40
|
this.document.api.platform === RabbitmqAdapter.PlatformName)) {
|
|
41
41
|
throw new TypeError(`The document doesn't expose a RabbitMQ Api`);
|
|
42
42
|
}
|
|
@@ -52,7 +52,7 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
get api() {
|
|
55
|
-
return this.document.
|
|
55
|
+
return this.document.mqApi;
|
|
56
56
|
}
|
|
57
57
|
get connection() {
|
|
58
58
|
return this._connection;
|
package/esm/rabbitmq-context.js
CHANGED
|
@@ -13,11 +13,11 @@ export class RabbitmqContext extends ExecutionContext {
|
|
|
13
13
|
...init,
|
|
14
14
|
document: init.adapter.document,
|
|
15
15
|
documentNode: init.controller?.node,
|
|
16
|
-
protocol: '
|
|
16
|
+
protocol: 'mq',
|
|
17
17
|
});
|
|
18
18
|
this.adapter = init.adapter;
|
|
19
19
|
this.platform = init.adapter.platform;
|
|
20
|
-
this.protocol = '
|
|
20
|
+
this.protocol = 'mq';
|
|
21
21
|
if (init.controller)
|
|
22
22
|
this.controller = init.controller;
|
|
23
23
|
if (init.controllerInstance)
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/rabbitmq",
|
|
3
|
-
"version": "1.19.
|
|
4
|
-
"description": "Opra RabbitMQ
|
|
3
|
+
"version": "1.19.5",
|
|
4
|
+
"description": "Opra RabbitMQ adapter",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jsopen/objects": "^2.0.
|
|
9
|
-
"@browsery/type-is": "^
|
|
8
|
+
"@jsopen/objects": "^2.0.2",
|
|
9
|
+
"@browsery/type-is": "^2.0.1",
|
|
10
10
|
"content-type": "^1.0.5",
|
|
11
|
-
"iconv-lite": "^0.
|
|
11
|
+
"iconv-lite": "^0.7.0",
|
|
12
12
|
"node-events-async": "^1.2.0",
|
|
13
13
|
"tslib": "^2.8.1",
|
|
14
|
-
"valgen": "^5.18.
|
|
14
|
+
"valgen": "^5.18.2"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@opra/common": "^1.19.
|
|
18
|
-
"@opra/core": "^1.19.
|
|
17
|
+
"@opra/common": "^1.19.5",
|
|
18
|
+
"@opra/core": "^1.19.5",
|
|
19
19
|
"rabbitmq-client": ">=5.0.0 <6"
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@opra/core';
|
|
2
2
|
import { RabbitmqAdapter } from '../rabbitmq-adapter.js';
|
|
3
3
|
declare module '@opra/common' {
|
|
4
|
-
interface
|
|
4
|
+
interface MQOperationDecorator {
|
|
5
5
|
RabbitMQ(config: RabbitmqAdapter.ConsumerConfig | (() => RabbitmqAdapter.ConsumerConfig | Promise<RabbitmqAdapter.ConsumerConfig>)): this;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ApiDocument,
|
|
1
|
+
import { ApiDocument, MQController, MQOperation } from '@opra/common';
|
|
2
2
|
import type { RabbitmqAdapter } from './rabbitmq-adapter.js';
|
|
3
3
|
export declare class ConfigBuilder {
|
|
4
4
|
readonly document: ApiDocument;
|
|
5
5
|
readonly config: RabbitmqAdapter.Config;
|
|
6
6
|
connectionOptions: RabbitmqAdapter.ConnectionOptions;
|
|
7
|
-
controllerInstances: Map<
|
|
7
|
+
controllerInstances: Map<MQController, any>;
|
|
8
8
|
handlerArgs: ConfigBuilder.OperationArguments[];
|
|
9
9
|
constructor(document: ApiDocument, config: RabbitmqAdapter.Config);
|
|
10
10
|
build(): Promise<void>;
|
|
@@ -16,13 +16,13 @@ export declare class ConfigBuilder {
|
|
|
16
16
|
* @param operation
|
|
17
17
|
* @protected
|
|
18
18
|
*/
|
|
19
|
-
protected _getConsumerConfig(controller:
|
|
19
|
+
protected _getConsumerConfig(controller: MQController, instance: any, operation: MQOperation): Promise<RabbitmqAdapter.ConsumerConfig | undefined>;
|
|
20
20
|
}
|
|
21
21
|
export declare namespace ConfigBuilder {
|
|
22
22
|
interface OperationArguments {
|
|
23
|
-
controller:
|
|
23
|
+
controller: MQController;
|
|
24
24
|
instance: any;
|
|
25
|
-
operation:
|
|
25
|
+
operation: MQOperation;
|
|
26
26
|
consumerConfig: RabbitmqAdapter.ConsumerConfig;
|
|
27
27
|
topics: string[];
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiDocument,
|
|
1
|
+
import { ApiDocument, MQApi, MQController, OpraException, OpraSchema } from '@opra/common';
|
|
2
2
|
import { PlatformAdapter } from '@opra/core';
|
|
3
3
|
import * as rabbit from 'rabbitmq-client';
|
|
4
4
|
import type { Envelope, MessageBody } from 'rabbitmq-client/lib/codec';
|
|
@@ -11,7 +11,7 @@ import { RabbitmqContext } from './rabbitmq-context.js';
|
|
|
11
11
|
export declare class RabbitmqAdapter extends PlatformAdapter<RabbitmqAdapter.Events> {
|
|
12
12
|
static readonly PlatformName = "rabbitmq";
|
|
13
13
|
protected _config: RabbitmqAdapter.Config;
|
|
14
|
-
protected _controllerInstances: Map<
|
|
14
|
+
protected _controllerInstances: Map<MQController, any>;
|
|
15
15
|
protected _connection?: rabbit.Connection;
|
|
16
16
|
protected _consumers: rabbit.Consumer[];
|
|
17
17
|
protected _status: RabbitmqAdapter.Status;
|
|
@@ -25,7 +25,7 @@ export declare class RabbitmqAdapter extends PlatformAdapter<RabbitmqAdapter.Eve
|
|
|
25
25
|
* @constructor
|
|
26
26
|
*/
|
|
27
27
|
constructor(document: ApiDocument, config: RabbitmqAdapter.Config);
|
|
28
|
-
get api():
|
|
28
|
+
get api(): MQApi;
|
|
29
29
|
get connection(): rabbit.Connection | undefined;
|
|
30
30
|
get scope(): string | undefined;
|
|
31
31
|
get status(): RabbitmqAdapter.Status;
|
|
@@ -80,9 +80,9 @@ export declare namespace RabbitmqAdapter {
|
|
|
80
80
|
intercept(context: RabbitmqContext, next: NextCallback): Promise<any>;
|
|
81
81
|
};
|
|
82
82
|
interface Events {
|
|
83
|
-
error: [Error, RabbitmqContext | undefined];
|
|
84
|
-
execute: [RabbitmqContext];
|
|
85
|
-
finish: [RabbitmqContext, any];
|
|
86
|
-
message: [rabbit.AsyncMessage, string];
|
|
83
|
+
error: [error: Error, context: RabbitmqContext | undefined];
|
|
84
|
+
execute: [context: RabbitmqContext];
|
|
85
|
+
finish: [context: RabbitmqContext, result: any];
|
|
86
|
+
message: [message: rabbit.AsyncMessage, queue: string];
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MQController, MQOperation, OpraSchema } from '@opra/common';
|
|
2
2
|
import { ExecutionContext } from '@opra/core';
|
|
3
3
|
import type { AsyncEventEmitter } from 'node-events-async';
|
|
4
4
|
import * as rabbit from 'rabbitmq-client';
|
|
@@ -11,9 +11,9 @@ export declare class RabbitmqContext extends ExecutionContext implements AsyncEv
|
|
|
11
11
|
readonly protocol: OpraSchema.Transport;
|
|
12
12
|
readonly platform: string;
|
|
13
13
|
readonly adapter: RabbitmqAdapter;
|
|
14
|
-
readonly controller?:
|
|
14
|
+
readonly controller?: MQController;
|
|
15
15
|
readonly controllerInstance?: any;
|
|
16
|
-
readonly operation?:
|
|
16
|
+
readonly operation?: MQOperation;
|
|
17
17
|
readonly operationHandler?: Function;
|
|
18
18
|
readonly queue: string;
|
|
19
19
|
readonly consumer: rabbit.Consumer;
|
|
@@ -31,9 +31,9 @@ export declare namespace RabbitmqContext {
|
|
|
31
31
|
interface Initiator extends Omit<ExecutionContext.Initiator, 'document' | 'protocol' | 'documentNode'> {
|
|
32
32
|
adapter: RabbitmqAdapter;
|
|
33
33
|
consumer: rabbit.Consumer;
|
|
34
|
-
controller?:
|
|
34
|
+
controller?: MQController;
|
|
35
35
|
controllerInstance?: any;
|
|
36
|
-
operation?:
|
|
36
|
+
operation?: MQOperation;
|
|
37
37
|
operationHandler?: Function;
|
|
38
38
|
content: any;
|
|
39
39
|
headers: Record<string, any>;
|