@konplit-services/common 1.0.149 → 1.0.151

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.
@@ -7,6 +7,7 @@
7
7
  * @module Listener
8
8
  */
9
9
  import { NatsConnection, Msg } from "nats";
10
+ import { Status } from "../../helper";
10
11
  /**
11
12
  * Event Interface
12
13
  *
@@ -18,6 +19,10 @@ interface Event {
18
19
  subject: string;
19
20
  data: any;
20
21
  }
22
+ interface ResponseData {
23
+ status: Status.Failed | Status.Success;
24
+ data: any;
25
+ }
21
26
  /**
22
27
  * Listener Abstract Class
23
28
  *
@@ -29,7 +34,7 @@ interface Event {
29
34
  */
30
35
  export declare abstract class RequestListener<T extends Event> {
31
36
  private nc;
32
- private jc;
37
+ protected jc: import("nats").Codec<unknown>;
33
38
  /**
34
39
  * The subject associated with the event.
35
40
  * @abstract
@@ -46,7 +51,7 @@ export declare abstract class RequestListener<T extends Event> {
46
51
  * @param {T["data"]} data - The decoded data from the message
47
52
  * @param {JsMsg} msg - The raw NATS message
48
53
  */
49
- abstract onMessageResponse(data: T["data"], msg: Msg): any;
54
+ abstract onMessageResponse(data: T["data"], msg: Msg): Promise<ResponseData>;
50
55
  /**
51
56
  * Constructor for the Listener class.
52
57
  *
@@ -29,7 +29,7 @@ interface Event {
29
29
  */
30
30
  export declare abstract class ResponsePublisher<T extends Event> {
31
31
  private nc;
32
- private jc;
32
+ protected jc: import("nats").Codec<unknown>;
33
33
  /**
34
34
  * The subject associated with the event.
35
35
  * @abstract
@@ -45,7 +45,7 @@ class ResponsePublisher {
45
45
  * @param {number} timeout - The timeout duration to wait for a response
46
46
  * @returns {Promise<any>} - Resolves with the reply data from the responding service
47
47
  */
48
- request(data, timeout = 5000) {
48
+ request(data, timeout = 10000) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
50
  try {
51
51
  // Send request and wait for the response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.149",
3
+ "version": "1.0.151",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",