@konplit-services/common 1.0.148 → 1.0.150

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,7 +7,7 @@
7
7
  * @module Listener
8
8
  */
9
9
  import { NatsConnection, Msg } from "nats";
10
- import { StreamEvent, StreamName } from "../subjects";
10
+ import { Status } from "../../helper";
11
11
  /**
12
12
  * Event Interface
13
13
  *
@@ -17,8 +17,10 @@ import { StreamEvent, StreamName } from "../subjects";
17
17
  */
18
18
  interface Event {
19
19
  subject: string;
20
- streamEvents: StreamEvent;
21
- streamName: StreamName;
20
+ data: any;
21
+ }
22
+ interface ResponseData {
23
+ status: Status.Failed | Status.Success;
22
24
  data: any;
23
25
  }
24
26
  /**
@@ -32,7 +34,7 @@ interface Event {
32
34
  */
33
35
  export declare abstract class RequestListener<T extends Event> {
34
36
  private nc;
35
- private jc;
37
+ protected jc: import("nats").Codec<unknown>;
36
38
  /**
37
39
  * The subject associated with the event.
38
40
  * @abstract
@@ -49,7 +51,7 @@ export declare abstract class RequestListener<T extends Event> {
49
51
  * @param {T["data"]} data - The decoded data from the message
50
52
  * @param {JsMsg} msg - The raw NATS message
51
53
  */
52
- abstract onMessageResponse(data: T["data"], msg: Msg): any;
54
+ abstract onMessageResponse(data: T["data"], msg: Msg): ResponseData;
53
55
  /**
54
56
  * Constructor for the Listener class.
55
57
  *
@@ -7,7 +7,6 @@
7
7
  * @module Publisher
8
8
  */
9
9
  import { NatsConnection } from "nats";
10
- import { StreamEvent, StreamName } from "../subjects";
11
10
  /**
12
11
  * Event Interface
13
12
  *
@@ -17,8 +16,6 @@ import { StreamEvent, StreamName } from "../subjects";
17
16
  */
18
17
  interface Event {
19
18
  subject: string;
20
- streamEvents: StreamEvent;
21
- streamName: StreamName;
22
19
  data: any;
23
20
  }
24
21
  /**
@@ -32,7 +29,7 @@ interface Event {
32
29
  */
33
30
  export declare abstract class ResponsePublisher<T extends Event> {
34
31
  private nc;
35
- private jc;
32
+ protected jc: import("nats").Codec<unknown>;
36
33
  /**
37
34
  * The subject associated with the event.
38
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
@@ -41,6 +41,8 @@ export declare enum Subjects {
41
41
  TransactionProcessing = "events.transaction.processing",
42
42
  TransactionCancelled = "events.transaction.cancelled",
43
43
  TransactionDeclined = "events.transaction.declined",
44
- VirtualFixedAccountCreatedEvent = "events.virtualfixedaccount.created",
45
- VirtualDynamicAccountCreatedEvent = "events.virtual.dynamicaccount.created"
44
+ VirtualFixedAccountCreatedEvent = "events.virtualfixedaccount.created"
45
+ }
46
+ export declare enum ResSubjects {
47
+ VirtualDynamicAccountCreatedEvent = "res.virtual.dynamicaccount.created"
46
48
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Subjects = exports.StreamName = exports.StreamEvent = void 0;
3
+ exports.ResSubjects = exports.Subjects = exports.StreamName = exports.StreamEvent = void 0;
4
4
  var StreamEvent;
5
5
  (function (StreamEvent) {
6
6
  StreamEvent["Event"] = "events.>";
@@ -62,5 +62,8 @@ var Subjects;
62
62
  Subjects["TransactionDeclined"] = "events.transaction.declined";
63
63
  //Virtual Fixed Account
64
64
  Subjects["VirtualFixedAccountCreatedEvent"] = "events.virtualfixedaccount.created";
65
- Subjects["VirtualDynamicAccountCreatedEvent"] = "events.virtual.dynamicaccount.created";
66
65
  })(Subjects = exports.Subjects || (exports.Subjects = {}));
66
+ var ResSubjects;
67
+ (function (ResSubjects) {
68
+ ResSubjects["VirtualDynamicAccountCreatedEvent"] = "res.virtual.dynamicaccount.created";
69
+ })(ResSubjects = exports.ResSubjects || (exports.ResSubjects = {}));
@@ -1,9 +1,7 @@
1
1
  import { TRANSACTION_CHARGES_TYPE } from "../../../helper";
2
- import { StreamEvent, StreamName, Subjects } from "../../subjects";
2
+ import { ResSubjects } from "../../subjects";
3
3
  export interface VirtualDynamicAccountCreatedEvent {
4
- subject: Subjects.VirtualDynamicAccountCreatedEvent;
5
- streamName: StreamName.name;
6
- streamEvents: StreamEvent.Event;
4
+ subject: ResSubjects.VirtualDynamicAccountCreatedEvent;
7
5
  data: {
8
6
  merchantId: string;
9
7
  accountId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.148",
3
+ "version": "1.0.150",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",