@opra/rabbitmq 1.19.7 → 1.21.0
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/config-builder.js +1 -1
- package/cjs/rabbitmq-adapter.js +13 -15
- package/cjs/rabbitmq-context.js +13 -14
- package/esm/config-builder.js +1 -1
- package/esm/rabbitmq-adapter.js +13 -15
- package/esm/rabbitmq-context.js +13 -14
- package/package.json +3 -3
- package/types/rabbitmq-adapter.d.ts +1 -1
- package/types/rabbitmq-context.d.ts +12 -14
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.getMqApi().controllers.values()) {
|
|
18
18
|
let instance = controller.instance;
|
|
19
19
|
if (!instance && controller.ctor)
|
|
20
20
|
instance = new controller.ctor();
|
package/cjs/rabbitmq-adapter.js
CHANGED
|
@@ -36,7 +36,7 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
36
36
|
this._controllerInstances = new Map();
|
|
37
37
|
this._consumers = [];
|
|
38
38
|
this._status = 'idle';
|
|
39
|
-
this.
|
|
39
|
+
this.transform = 'mq';
|
|
40
40
|
this.platform = RabbitmqAdapter.PlatformName;
|
|
41
41
|
this._document = document;
|
|
42
42
|
this._config = config;
|
|
@@ -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.getMqApi();
|
|
60
60
|
}
|
|
61
61
|
get connection() {
|
|
62
62
|
return this._connection;
|
|
@@ -152,18 +152,17 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
152
152
|
_createHandler(args) {
|
|
153
153
|
const { controller, instance, operation } = args;
|
|
154
154
|
/** Prepare parsers */
|
|
155
|
-
const decodePayload = operation.
|
|
155
|
+
const decodePayload = operation.generateCodec('decode', {
|
|
156
156
|
scope: this.scope,
|
|
157
|
-
|
|
157
|
+
ignoreReadonlyFields: true,
|
|
158
158
|
});
|
|
159
159
|
operation.headers.forEach(header => {
|
|
160
160
|
let decode = this[core_1.kAssetCache].get(header, 'decode');
|
|
161
161
|
if (!decode) {
|
|
162
|
-
decode =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}) || valgen_1.vg.isAny();
|
|
162
|
+
decode = header.generateCodec('decode', {
|
|
163
|
+
scope: this.scope,
|
|
164
|
+
ignoreReadonlyFields: true,
|
|
165
|
+
});
|
|
167
166
|
this[core_1.kAssetCache].set(header, 'decode', decode);
|
|
168
167
|
}
|
|
169
168
|
});
|
|
@@ -181,12 +180,11 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
181
180
|
const headers = {};
|
|
182
181
|
/** Create context */
|
|
183
182
|
const context = new rabbitmq_context_js_1.RabbitmqContext({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
operationHandler,
|
|
183
|
+
__adapter: this,
|
|
184
|
+
__contDef: controller,
|
|
185
|
+
__controller: instance,
|
|
186
|
+
__oprDef: operation,
|
|
187
|
+
__handler: operationHandler,
|
|
190
188
|
queue,
|
|
191
189
|
consumer,
|
|
192
190
|
message,
|
package/cjs/rabbitmq-context.js
CHANGED
|
@@ -14,21 +14,20 @@ class RabbitmqContext extends core_1.ExecutionContext {
|
|
|
14
14
|
constructor(init) {
|
|
15
15
|
super({
|
|
16
16
|
...init,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
__docNode: init.__oprDef?.node ||
|
|
18
|
+
init.__contDef?.node ||
|
|
19
|
+
init.__adapter.document.node,
|
|
20
|
+
transport: 'mq',
|
|
21
|
+
platform: 'rabbitmq',
|
|
20
22
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.operation = init.operation;
|
|
30
|
-
if (init.operationHandler)
|
|
31
|
-
this.operationHandler = init.operationHandler;
|
|
23
|
+
if (init.__contDef)
|
|
24
|
+
this.__contDef = init.__contDef;
|
|
25
|
+
if (init.__oprDef)
|
|
26
|
+
this.__oprDef = init.__oprDef;
|
|
27
|
+
if (init.__controller)
|
|
28
|
+
this.__controller = init.__controller;
|
|
29
|
+
if (init.__handler)
|
|
30
|
+
this.__handler = init.__handler;
|
|
32
31
|
this.consumer = init.consumer;
|
|
33
32
|
this.queue = init.queue;
|
|
34
33
|
this.message = init.message;
|
package/esm/config-builder.js
CHANGED
|
@@ -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.getMqApi().controllers.values()) {
|
|
15
15
|
let instance = controller.instance;
|
|
16
16
|
if (!instance && controller.ctor)
|
|
17
17
|
instance = new controller.ctor();
|
package/esm/rabbitmq-adapter.js
CHANGED
|
@@ -32,7 +32,7 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
32
32
|
this._controllerInstances = new Map();
|
|
33
33
|
this._consumers = [];
|
|
34
34
|
this._status = 'idle';
|
|
35
|
-
this.
|
|
35
|
+
this.transform = 'mq';
|
|
36
36
|
this.platform = RabbitmqAdapter.PlatformName;
|
|
37
37
|
this._document = document;
|
|
38
38
|
this._config = config;
|
|
@@ -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.getMqApi();
|
|
56
56
|
}
|
|
57
57
|
get connection() {
|
|
58
58
|
return this._connection;
|
|
@@ -148,18 +148,17 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
148
148
|
_createHandler(args) {
|
|
149
149
|
const { controller, instance, operation } = args;
|
|
150
150
|
/** Prepare parsers */
|
|
151
|
-
const decodePayload = operation.
|
|
151
|
+
const decodePayload = operation.generateCodec('decode', {
|
|
152
152
|
scope: this.scope,
|
|
153
|
-
|
|
153
|
+
ignoreReadonlyFields: true,
|
|
154
154
|
});
|
|
155
155
|
operation.headers.forEach(header => {
|
|
156
156
|
let decode = this[kAssetCache].get(header, 'decode');
|
|
157
157
|
if (!decode) {
|
|
158
|
-
decode =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}) || vg.isAny();
|
|
158
|
+
decode = header.generateCodec('decode', {
|
|
159
|
+
scope: this.scope,
|
|
160
|
+
ignoreReadonlyFields: true,
|
|
161
|
+
});
|
|
163
162
|
this[kAssetCache].set(header, 'decode', decode);
|
|
164
163
|
}
|
|
165
164
|
});
|
|
@@ -177,12 +176,11 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
177
176
|
const headers = {};
|
|
178
177
|
/** Create context */
|
|
179
178
|
const context = new RabbitmqContext({
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
operationHandler,
|
|
179
|
+
__adapter: this,
|
|
180
|
+
__contDef: controller,
|
|
181
|
+
__controller: instance,
|
|
182
|
+
__oprDef: operation,
|
|
183
|
+
__handler: operationHandler,
|
|
186
184
|
queue,
|
|
187
185
|
consumer,
|
|
188
186
|
message,
|
package/esm/rabbitmq-context.js
CHANGED
|
@@ -11,21 +11,20 @@ export class RabbitmqContext extends ExecutionContext {
|
|
|
11
11
|
constructor(init) {
|
|
12
12
|
super({
|
|
13
13
|
...init,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
__docNode: init.__oprDef?.node ||
|
|
15
|
+
init.__contDef?.node ||
|
|
16
|
+
init.__adapter.document.node,
|
|
17
|
+
transport: 'mq',
|
|
18
|
+
platform: 'rabbitmq',
|
|
17
19
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.operation = init.operation;
|
|
27
|
-
if (init.operationHandler)
|
|
28
|
-
this.operationHandler = init.operationHandler;
|
|
20
|
+
if (init.__contDef)
|
|
21
|
+
this.__contDef = init.__contDef;
|
|
22
|
+
if (init.__oprDef)
|
|
23
|
+
this.__oprDef = init.__oprDef;
|
|
24
|
+
if (init.__controller)
|
|
25
|
+
this.__controller = init.__controller;
|
|
26
|
+
if (init.__handler)
|
|
27
|
+
this.__handler = init.__handler;
|
|
29
28
|
this.consumer = init.consumer;
|
|
30
29
|
this.queue = init.queue;
|
|
31
30
|
this.message = init.message;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/rabbitmq",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "Opra RabbitMQ adapter",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"valgen": "^5.18.2"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@opra/common": "^1.
|
|
18
|
-
"@opra/core": "^1.
|
|
17
|
+
"@opra/common": "^1.21.0",
|
|
18
|
+
"@opra/core": "^1.21.0",
|
|
19
19
|
"rabbitmq-client": ">=5.0.0 <6"
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
@@ -15,7 +15,7 @@ export declare class RabbitmqAdapter extends PlatformAdapter<RabbitmqAdapter.Eve
|
|
|
15
15
|
protected _connection?: rabbit.Connection;
|
|
16
16
|
protected _consumers: rabbit.Consumer[];
|
|
17
17
|
protected _status: RabbitmqAdapter.Status;
|
|
18
|
-
readonly
|
|
18
|
+
readonly transform: OpraSchema.Transport;
|
|
19
19
|
readonly platform = "rabbitmq";
|
|
20
20
|
readonly interceptors: (RabbitmqAdapter.InterceptorFunction | RabbitmqAdapter.IRabbitmqInterceptor)[];
|
|
21
21
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MQController, MQOperation
|
|
1
|
+
import { MQController, MQOperation } 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';
|
|
@@ -8,13 +8,11 @@ import type { RabbitmqAdapter } from './rabbitmq-adapter';
|
|
|
8
8
|
* It extends the ExecutionContext and implements the AsyncEventEmitter.
|
|
9
9
|
*/
|
|
10
10
|
export declare class RabbitmqContext extends ExecutionContext implements AsyncEventEmitter {
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
readonly operation?: MQOperation;
|
|
17
|
-
readonly operationHandler?: Function;
|
|
11
|
+
readonly __contDef: MQController;
|
|
12
|
+
readonly __oprDef: MQOperation;
|
|
13
|
+
readonly __controller: any;
|
|
14
|
+
readonly __handler?: Function;
|
|
15
|
+
readonly __adapter: RabbitmqAdapter;
|
|
18
16
|
readonly queue: string;
|
|
19
17
|
readonly consumer: rabbit.Consumer;
|
|
20
18
|
readonly message: rabbit.AsyncMessage;
|
|
@@ -28,13 +26,13 @@ export declare class RabbitmqContext extends ExecutionContext implements AsyncEv
|
|
|
28
26
|
constructor(init: RabbitmqContext.Initiator);
|
|
29
27
|
}
|
|
30
28
|
export declare namespace RabbitmqContext {
|
|
31
|
-
interface Initiator extends Omit<ExecutionContext.Initiator, '
|
|
32
|
-
|
|
29
|
+
interface Initiator extends Omit<ExecutionContext.Initiator, '__adapter' | 'transport' | 'platform' | '__docNode'> {
|
|
30
|
+
__adapter: RabbitmqAdapter;
|
|
31
|
+
__contDef?: MQController;
|
|
32
|
+
__controller?: any;
|
|
33
|
+
__oprDef?: MQOperation;
|
|
34
|
+
__handler?: Function;
|
|
33
35
|
consumer: rabbit.Consumer;
|
|
34
|
-
controller?: MQController;
|
|
35
|
-
controllerInstance?: any;
|
|
36
|
-
operation?: MQOperation;
|
|
37
|
-
operationHandler?: Function;
|
|
38
36
|
content: any;
|
|
39
37
|
headers: Record<string, any>;
|
|
40
38
|
queue: string;
|