@opra/kafka 1.19.7 → 1.20.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/kafka-adapter.js +18 -20
- package/cjs/kafka-context.js +13 -14
- package/esm/kafka-adapter.js +18 -20
- package/esm/kafka-context.js +13 -14
- package/package.json +3 -3
- package/types/kafka-adapter.d.ts +1 -1
- package/types/kafka-context.d.ts +12 -14
package/cjs/kafka-adapter.js
CHANGED
|
@@ -29,7 +29,7 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
29
29
|
this._consumers = new Map();
|
|
30
30
|
this._handlerArgs = [];
|
|
31
31
|
this._status = 'idle';
|
|
32
|
-
this.
|
|
32
|
+
this.transform = 'mq';
|
|
33
33
|
this.platform = KafkaAdapter.PlatformName;
|
|
34
34
|
this._document = document;
|
|
35
35
|
this._config = config;
|
|
@@ -50,7 +50,7 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
get api() {
|
|
53
|
-
return this.document.
|
|
53
|
+
return this.document.getMqApi();
|
|
54
54
|
}
|
|
55
55
|
get kafka() {
|
|
56
56
|
return this._kafka;
|
|
@@ -221,7 +221,7 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
221
221
|
* @protected
|
|
222
222
|
*/
|
|
223
223
|
async _createAllConsumers() {
|
|
224
|
-
for (const controller of this.document.
|
|
224
|
+
for (const controller of this.document.getMqApi().controllers.values()) {
|
|
225
225
|
let instance = controller.instance;
|
|
226
226
|
if (!instance && controller.ctor)
|
|
227
227
|
instance = new controller.ctor();
|
|
@@ -281,22 +281,21 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
281
281
|
const parseKey = request_parser_js_1.RequestParser.STRING;
|
|
282
282
|
const parsePayload = request_parser_js_1.RequestParser.STRING;
|
|
283
283
|
/** Prepare decoders */
|
|
284
|
-
const decodeKey = operation.
|
|
284
|
+
const decodeKey = operation.generateKeyCodec('decode', {
|
|
285
285
|
scope: this.scope,
|
|
286
|
-
|
|
287
|
-
})
|
|
288
|
-
const decodePayload = operation.
|
|
286
|
+
ignoreReadonlyFields: true,
|
|
287
|
+
});
|
|
288
|
+
const decodePayload = operation.generateCodec('decode', {
|
|
289
289
|
scope: this.scope,
|
|
290
|
-
|
|
291
|
-
})
|
|
290
|
+
ignoreReadonlyFields: true,
|
|
291
|
+
});
|
|
292
292
|
operation.headers.forEach(header => {
|
|
293
293
|
let decode = this[core_1.kAssetCache].get(header, 'decode');
|
|
294
294
|
if (!decode) {
|
|
295
|
-
decode =
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}) || valgen_1.vg.isAny();
|
|
295
|
+
decode = header.generateCodec('decode', {
|
|
296
|
+
scope: this.scope,
|
|
297
|
+
ignoreReadonlyFields: true,
|
|
298
|
+
});
|
|
300
299
|
this[core_1.kAssetCache].set(header, 'decode', decode);
|
|
301
300
|
}
|
|
302
301
|
});
|
|
@@ -331,12 +330,11 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
331
330
|
}
|
|
332
331
|
/** Create context */
|
|
333
332
|
const context = new kafka_context_js_1.KafkaContext({
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
operationHandler,
|
|
333
|
+
__adapter: this,
|
|
334
|
+
__contDef: controller,
|
|
335
|
+
__controller: instance,
|
|
336
|
+
__oprDef: operation,
|
|
337
|
+
__handler: operationHandler,
|
|
340
338
|
topic,
|
|
341
339
|
partition,
|
|
342
340
|
payload,
|
package/cjs/kafka-context.js
CHANGED
|
@@ -14,21 +14,20 @@ class KafkaContext 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: 'kafka',
|
|
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.partition = init.partition;
|
|
33
32
|
this.headers = init.headers || {};
|
|
34
33
|
this.topic = init.topic;
|
package/esm/kafka-adapter.js
CHANGED
|
@@ -26,7 +26,7 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
26
26
|
this._consumers = new Map();
|
|
27
27
|
this._handlerArgs = [];
|
|
28
28
|
this._status = 'idle';
|
|
29
|
-
this.
|
|
29
|
+
this.transform = 'mq';
|
|
30
30
|
this.platform = KafkaAdapter.PlatformName;
|
|
31
31
|
this._document = document;
|
|
32
32
|
this._config = config;
|
|
@@ -47,7 +47,7 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
get api() {
|
|
50
|
-
return this.document.
|
|
50
|
+
return this.document.getMqApi();
|
|
51
51
|
}
|
|
52
52
|
get kafka() {
|
|
53
53
|
return this._kafka;
|
|
@@ -218,7 +218,7 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
218
218
|
* @protected
|
|
219
219
|
*/
|
|
220
220
|
async _createAllConsumers() {
|
|
221
|
-
for (const controller of this.document.
|
|
221
|
+
for (const controller of this.document.getMqApi().controllers.values()) {
|
|
222
222
|
let instance = controller.instance;
|
|
223
223
|
if (!instance && controller.ctor)
|
|
224
224
|
instance = new controller.ctor();
|
|
@@ -278,22 +278,21 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
278
278
|
const parseKey = RequestParser.STRING;
|
|
279
279
|
const parsePayload = RequestParser.STRING;
|
|
280
280
|
/** Prepare decoders */
|
|
281
|
-
const decodeKey = operation.
|
|
281
|
+
const decodeKey = operation.generateKeyCodec('decode', {
|
|
282
282
|
scope: this.scope,
|
|
283
|
-
|
|
284
|
-
})
|
|
285
|
-
const decodePayload = operation.
|
|
283
|
+
ignoreReadonlyFields: true,
|
|
284
|
+
});
|
|
285
|
+
const decodePayload = operation.generateCodec('decode', {
|
|
286
286
|
scope: this.scope,
|
|
287
|
-
|
|
288
|
-
})
|
|
287
|
+
ignoreReadonlyFields: true,
|
|
288
|
+
});
|
|
289
289
|
operation.headers.forEach(header => {
|
|
290
290
|
let decode = this[kAssetCache].get(header, 'decode');
|
|
291
291
|
if (!decode) {
|
|
292
|
-
decode =
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}) || vg.isAny();
|
|
292
|
+
decode = header.generateCodec('decode', {
|
|
293
|
+
scope: this.scope,
|
|
294
|
+
ignoreReadonlyFields: true,
|
|
295
|
+
});
|
|
297
296
|
this[kAssetCache].set(header, 'decode', decode);
|
|
298
297
|
}
|
|
299
298
|
});
|
|
@@ -328,12 +327,11 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
328
327
|
}
|
|
329
328
|
/** Create context */
|
|
330
329
|
const context = new KafkaContext({
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
operationHandler,
|
|
330
|
+
__adapter: this,
|
|
331
|
+
__contDef: controller,
|
|
332
|
+
__controller: instance,
|
|
333
|
+
__oprDef: operation,
|
|
334
|
+
__handler: operationHandler,
|
|
337
335
|
topic,
|
|
338
336
|
partition,
|
|
339
337
|
payload,
|
package/esm/kafka-context.js
CHANGED
|
@@ -11,21 +11,20 @@ export class KafkaContext 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: 'kafka',
|
|
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.partition = init.partition;
|
|
30
29
|
this.headers = init.headers || {};
|
|
31
30
|
this.topic = init.topic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/kafka",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Opra Kafka adapter",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"valgen": "^5.18.2"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@opra/common": "^1.
|
|
14
|
-
"@opra/core": "^1.
|
|
13
|
+
"@opra/common": "^1.20.0",
|
|
14
|
+
"@opra/core": "^1.20.0",
|
|
15
15
|
"kafkajs": ">=2.2.4 <3"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
package/types/kafka-adapter.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class KafkaAdapter extends PlatformAdapter<KafkaAdapter.Events> {
|
|
|
29
29
|
protected _handlerArgs: HandlerArguments[];
|
|
30
30
|
protected _kafka: Kafka;
|
|
31
31
|
protected _status: KafkaAdapter.Status;
|
|
32
|
-
readonly
|
|
32
|
+
readonly transform: OpraSchema.Transport;
|
|
33
33
|
readonly platform = "kafka";
|
|
34
34
|
readonly interceptors: (KafkaAdapter.InterceptorFunction | KafkaAdapter.IKafkaInterceptor)[];
|
|
35
35
|
/**
|
package/types/kafka-context.d.ts
CHANGED
|
@@ -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 { KafkaMessage } from 'kafkajs';
|
|
4
4
|
import type { AsyncEventEmitter } from 'node-events-async';
|
|
@@ -8,13 +8,11 @@ import type { KafkaAdapter } from './kafka-adapter.js';
|
|
|
8
8
|
* It extends the ExecutionContext and implements the AsyncEventEmitter.
|
|
9
9
|
*/
|
|
10
10
|
export declare class KafkaContext 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: KafkaAdapter;
|
|
18
16
|
readonly topic: string;
|
|
19
17
|
readonly key: any;
|
|
20
18
|
readonly payload: any;
|
|
@@ -30,12 +28,12 @@ export declare class KafkaContext extends ExecutionContext implements AsyncEvent
|
|
|
30
28
|
constructor(init: KafkaContext.Initiator);
|
|
31
29
|
}
|
|
32
30
|
export declare namespace KafkaContext {
|
|
33
|
-
interface Initiator extends Omit<ExecutionContext.Initiator, '
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
interface Initiator extends Omit<ExecutionContext.Initiator, '__adapter' | 'transport' | 'platform' | '__docNode'> {
|
|
32
|
+
__adapter: KafkaAdapter;
|
|
33
|
+
__contDef?: MQController;
|
|
34
|
+
__controller?: any;
|
|
35
|
+
__oprDef?: MQOperation;
|
|
36
|
+
__handler?: Function;
|
|
39
37
|
topic: string;
|
|
40
38
|
partition: number;
|
|
41
39
|
key: any;
|