@konplit-services/common 1.4.1 → 1.5.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.
Files changed (77) hide show
  1. package/build/app.configs.d.ts +0 -1
  2. package/build/database/prisma-transaction-manager.d.ts +12 -0
  3. package/build/database/prisma-transaction-manager.js +89 -0
  4. package/build/events/Settlements-events/interfaces/settlement-created.interface.d.ts +2 -0
  5. package/build/events/base-events/base-event-response-publisher.js +2 -2
  6. package/build/events/base-events/base-events.listener.js +14 -19
  7. package/build/events/base-events/base-events.publisher.js +6 -6
  8. package/build/events/base-events/event.js +2 -1
  9. package/build/events/easypay-events/interfaces/recipient-webhook.interface.js +1 -1
  10. package/build/events/notification-events/interfaces/mailersend.interface.d.ts +0 -1
  11. package/build/events/subjects.d.ts +4 -4
  12. package/build/events/subjects.js +4 -4
  13. package/build/events/types/order-statu.types.js +1 -1
  14. package/build/helper/Two-fa-type.js +1 -1
  15. package/build/helper/account-balance-types.js +1 -1
  16. package/build/helper/account-status.js +1 -1
  17. package/build/helper/api-config-types.js +2 -2
  18. package/build/helper/bank-account-types.js +1 -1
  19. package/build/helper/business-category.js +2 -2
  20. package/build/helper/business-types.js +2 -2
  21. package/build/helper/bvn-validation-type.js +1 -1
  22. package/build/helper/card-types.js +1 -1
  23. package/build/helper/card_auth_type.js +1 -1
  24. package/build/helper/charges.js +4 -4
  25. package/build/helper/currency-types.js +1 -1
  26. package/build/helper/custom-paginate.js +4 -4
  27. package/build/helper/date-processing.js +3 -3
  28. package/build/helper/disputes.js +2 -2
  29. package/build/helper/encryptions.d.ts +3 -3
  30. package/build/helper/encryptions.js +2 -2
  31. package/build/helper/generate-query-params.js +1 -2
  32. package/build/helper/invoice.js +3 -3
  33. package/build/helper/keys.d.ts +0 -1
  34. package/build/helper/keys.js +17 -7
  35. package/build/helper/lang/email.js +2 -2
  36. package/build/helper/lang/language.js +8 -8
  37. package/build/helper/last-three.js +1 -2
  38. package/build/helper/location.js +1 -2
  39. package/build/helper/media-types.js +1 -1
  40. package/build/helper/nibss-scopes.js +1 -1
  41. package/build/helper/payment-options.js +2 -2
  42. package/build/helper/permistions.js +2 -2
  43. package/build/helper/plan-types.js +1 -1
  44. package/build/helper/refund.d.ts +2 -2
  45. package/build/helper/refund.js +6 -6
  46. package/build/helper/roles.js +3 -3
  47. package/build/helper/settings-types.js +5 -5
  48. package/build/helper/settlement.js +4 -4
  49. package/build/helper/status.js +2 -2
  50. package/build/helper/subaccount.js +1 -1
  51. package/build/helper/subscriptions-types.js +3 -3
  52. package/build/helper/success-response.js +1 -2
  53. package/build/helper/transaction-authentication-type.js +1 -1
  54. package/build/helper/transaction-type.js +4 -4
  55. package/build/helper/transfer.d.ts +4 -4
  56. package/build/helper/transfer.js +1 -1
  57. package/build/helper/user-types.js +1 -1
  58. package/build/helper/util/gender.js +1 -1
  59. package/build/helper/util/remove-transactionId.d.ts +2 -2
  60. package/build/helper/wallet-transaction.types.js +3 -3
  61. package/build/helper/worker-task-types.js +1 -1
  62. package/build/index.d.ts +1 -0
  63. package/build/index.js +1 -0
  64. package/build/interfaces/itransaction-manager.d.ts +6 -0
  65. package/build/interfaces/itransaction-manager.js +3 -0
  66. package/build/log-activities/actions.js +1 -1
  67. package/build/middlewares/request-log.d.ts +1 -2
  68. package/build/notification/email/send.d.ts +0 -1
  69. package/build/notification/email/send.js +2 -2
  70. package/build/notification/email/types.js +1 -1
  71. package/build/notification/sms/constants.js +1 -1
  72. package/build/notification/types.js +2 -2
  73. package/build/redis/base/index.js +1 -1
  74. package/build/services/Jwt.js +7 -7
  75. package/build/util/constants.d.ts +2 -0
  76. package/build/util/constants.js +5 -0
  77. package/package.json +5 -3
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { env } from "process";
3
2
  interface EmailTemplate {
4
3
  forgot_password: string;
@@ -0,0 +1,12 @@
1
+ import { PrismaClient, Prisma } from '@prisma/client';
2
+ import { ITransactionManager } from '../interfaces/itransaction-manager';
3
+ export declare class PrismaTransactionManager implements ITransactionManager {
4
+ private readonly prisma;
5
+ private tx;
6
+ private isTransactionActive;
7
+ constructor(prisma: PrismaClient);
8
+ beginTransaction<R>(callback: (tx: Prisma.TransactionClient) => Promise<R>): Promise<R>;
9
+ commitTransaction(): Promise<void>;
10
+ rollbackTransaction(): Promise<void>;
11
+ getQueryRunner(): PrismaClient;
12
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.PrismaTransactionManager = void 0;
25
+ const client_1 = require("@prisma/client");
26
+ const tsyringe_1 = require("tsyringe");
27
+ const constants_1 = require("../util/constants");
28
+ let PrismaTransactionManager = class PrismaTransactionManager {
29
+ constructor(prisma) {
30
+ this.prisma = prisma;
31
+ this.tx = null;
32
+ this.isTransactionActive = false;
33
+ }
34
+ beginTransaction(callback) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ if (this.isTransactionActive) {
37
+ throw new Error('A transaction is already active');
38
+ }
39
+ this.isTransactionActive = true;
40
+ try {
41
+ const result = yield this.prisma.$transaction((prisma) => __awaiter(this, void 0, void 0, function* () {
42
+ this.tx = prisma;
43
+ const callbackResult = yield callback(prisma);
44
+ return callbackResult;
45
+ }));
46
+ this.isTransactionActive = false;
47
+ this.tx = null;
48
+ return result;
49
+ }
50
+ catch (error) {
51
+ this.isTransactionActive = false;
52
+ this.tx = null;
53
+ console.error('Transaction failed:', error);
54
+ throw error;
55
+ }
56
+ });
57
+ }
58
+ commitTransaction() {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ // No-op: Prisma commits automatically when $transaction callback resolves
61
+ if (!this.isTransactionActive) {
62
+ throw new Error('No active transaction to commit');
63
+ }
64
+ // The transaction is committed automatically by $transaction
65
+ });
66
+ }
67
+ rollbackTransaction() {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ // No-op: Prisma rolls back automatically if $transaction callback throws
70
+ if (!this.isTransactionActive) {
71
+ throw new Error('No active transaction to rollback');
72
+ }
73
+ // The transaction is rolled back automatically by $transaction on error
74
+ });
75
+ }
76
+ getQueryRunner() {
77
+ if (!this.isTransactionActive || !this.tx) {
78
+ throw new Error('No active transaction');
79
+ }
80
+ return this.tx;
81
+ }
82
+ };
83
+ exports.PrismaTransactionManager = PrismaTransactionManager;
84
+ exports.PrismaTransactionManager = PrismaTransactionManager = __decorate([
85
+ (0, tsyringe_1.injectable)(),
86
+ __param(0, (0, tsyringe_1.inject)(constants_1.PRISMA_CLIENT)),
87
+ __metadata("design:paramtypes", [Object])
88
+ ], PrismaTransactionManager);
89
+ //perfect
@@ -12,6 +12,8 @@ export interface SettlementCreatedEvent {
12
12
  accountName: string;
13
13
  amount: number;
14
14
  charges: number;
15
+ stampDuty: number;
16
+ tax: number;
15
17
  settlementType: Settlement_TYPES;
16
18
  transactionDate: Date;
17
19
  schedule: SettlementSchedule;
@@ -45,8 +45,8 @@ 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 = 1000 * 60 * 5) {
49
- return __awaiter(this, void 0, void 0, function* () {
48
+ request(data_1) {
49
+ return __awaiter(this, arguments, void 0, function* (data, timeout = 1000 * 60 * 5) {
50
50
  try {
51
51
  // Send request and wait for the response
52
52
  const response = yield this.nc.request(this.subject, this.jc.encode(data), { timeout } // Timeout for the response
@@ -81,26 +81,21 @@ class Listener {
81
81
  });
82
82
  }
83
83
  listenForRequests() {
84
- var _a, e_1, _b, _c;
85
- var _d;
86
84
  return __awaiter(this, void 0, void 0, function* () {
85
+ var _a, e_1, _b, _c;
86
+ var _d;
87
87
  const subscription = (_d = this.nc) === null || _d === void 0 ? void 0 : _d.subscribe(this.subject);
88
88
  try {
89
- for (var _e = true, subscription_1 = __asyncValues(subscription), subscription_1_1; subscription_1_1 = yield subscription_1.next(), _a = subscription_1_1.done, !_a;) {
89
+ for (var _e = true, subscription_1 = __asyncValues(subscription), subscription_1_1; subscription_1_1 = yield subscription_1.next(), _a = subscription_1_1.done, !_a; _e = true) {
90
90
  _c = subscription_1_1.value;
91
91
  _e = false;
92
- try {
93
- const msg = _c;
94
- // Decode the request data
95
- const decodedRequest = this.jc.decode(msg.data);
96
- console.log("Received Request:", decodedRequest);
97
- const response = yield this.onMessageResponse(decodedRequest, msg);
98
- // Send a reply back
99
- msg.respond(this.jc.encode({ data: response }));
100
- }
101
- finally {
102
- _e = true;
103
- }
92
+ const msg = _c;
93
+ // Decode the request data
94
+ const decodedRequest = this.jc.decode(msg.data);
95
+ console.log("Received Request:", decodedRequest);
96
+ const response = yield this.onMessageResponse(decodedRequest, msg);
97
+ // Send a reply back
98
+ msg.respond(this.jc.encode({ data: response }));
104
99
  }
105
100
  }
106
101
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -122,8 +117,8 @@ class Listener {
122
117
  * @returns {Promise<void>} - Resolves when the stream is ensured to exist
123
118
  */
124
119
  ensureStream(streamName, subjects) {
125
- var _a, _b;
126
120
  return __awaiter(this, void 0, void 0, function* () {
121
+ var _a, _b;
127
122
  try {
128
123
  const jsm = yield this.client.jetstreamManager();
129
124
  yield jsm.streams.info(streamName);
@@ -141,8 +136,8 @@ class Listener {
141
136
  storage: nats_1.StorageType.File,
142
137
  max_consumers: -1,
143
138
  retention: nats_1.RetentionPolicy.Limits,
144
- max_msgs: 10000,
145
- max_bytes: 1 * 1024 * 1024 * 1024,
139
+ max_msgs: 10000, // 10,000 messages
140
+ max_bytes: 1 * 1024 * 1024 * 1024, // 5 GB
146
141
  max_age: (0, nats_1.nanos)(14 * 24 * 3600 * 1000), //2 weeks in milliseconds
147
142
  };
148
143
  yield jsm.streams.add(streamConfig);
@@ -170,8 +165,8 @@ class Listener {
170
165
  * @returns {Promise<void>} - Resolves when the consumer is ensured to exist
171
166
  */
172
167
  ensureConsumer(streamName, durableName, subject) {
173
- var _a, _b;
174
168
  return __awaiter(this, void 0, void 0, function* () {
169
+ var _a, _b;
175
170
  const jsm = yield this.client.jetstreamManager();
176
171
  try {
177
172
  yield jsm.consumers.info(streamName, durableName);
@@ -70,9 +70,9 @@ class Publisher {
70
70
  * @param {number} timeout - The timeout duration to wait for a response
71
71
  * @returns {Promise<any>} - Resolves with the reply data from the responding service
72
72
  */
73
- request(data, timeout = 5000) {
74
- var _a;
75
- return __awaiter(this, void 0, void 0, function* () {
73
+ request(data_1) {
74
+ return __awaiter(this, arguments, void 0, function* (data, timeout = 5000) {
75
+ var _a;
76
76
  try {
77
77
  // Send request and wait for the response
78
78
  const response = yield ((_a = this.nc) === null || _a === void 0 ? void 0 : _a.request(this.subject, this.jc.encode(data), { timeout } // Timeout for the response
@@ -100,8 +100,8 @@ class Publisher {
100
100
  * @returns {Promise<void>} - Resolves when the stream is ensured to exist
101
101
  */
102
102
  ensureStream(streamName, subjects) {
103
- var _a, _b;
104
103
  return __awaiter(this, void 0, void 0, function* () {
104
+ var _a, _b;
105
105
  try {
106
106
  const jsm = yield this.client.jetstreamManager();
107
107
  yield jsm.streams.info(streamName);
@@ -119,8 +119,8 @@ class Publisher {
119
119
  storage: nats_1.StorageType.File,
120
120
  retention: nats_1.RetentionPolicy.Limits,
121
121
  max_consumers: -1,
122
- max_msgs: 10000,
123
- max_bytes: 5 * 1024 * 1024 * 1024,
122
+ max_msgs: 10000, // 10,000 messages
123
+ max_bytes: 5 * 1024 * 1024 * 1024, // 5 GB
124
124
  max_age: (0, nats_1.nanos)(14 * 24 * 3600 * 1000), //2 weeks in milliseconds
125
125
  };
126
126
  yield jsm.streams.add(streamConfig);
@@ -5,4 +5,5 @@ var EventResponseStatus;
5
5
  (function (EventResponseStatus) {
6
6
  EventResponseStatus["Failed"] = "Failed";
7
7
  EventResponseStatus["Success"] = "Success";
8
- })(EventResponseStatus = exports.EventResponseStatus || (exports.EventResponseStatus = {}));
8
+ })(EventResponseStatus || (exports.EventResponseStatus = EventResponseStatus = {}));
9
+ //commenets
@@ -6,4 +6,4 @@ var RecipientWebhook;
6
6
  RecipientWebhook["created"] = "created";
7
7
  RecipientWebhook["failed"] = "failed";
8
8
  RecipientWebhook["success"] = "success";
9
- })(RecipientWebhook = exports.RecipientWebhook || (exports.RecipientWebhook = {}));
9
+ })(RecipientWebhook || (exports.RecipientWebhook = RecipientWebhook = {}));
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { StreamEvent, StreamName, Subjects } from "../../subjects";
3
2
  export interface MailersendEmailCreatedEvent {
4
3
  subject: Subjects.NotificationEmailCreated;
@@ -174,10 +174,10 @@ export declare enum Subjects {
174
174
  }
175
175
  export declare enum ResSubjects {
176
176
  VirtualDynamicAccountCreatedEvent = "res.virtual.dynamicaccount.created",
177
- BankListCreated = "res.bank.list.created",
178
- BankAccountNameCreated = "res.bank.account.name.created",
179
- NIBSSBankAccountNameCreated = "res.nibss.bank.name.created",
180
- MonoInitiationTransaction = "res.mono.initiation",
177
+ BankListCreated = "res.bank.list.created",// for fetching all bank accounts
178
+ BankAccountNameCreated = "res.bank.account.name.created",// for getting name atteched to the account
179
+ NIBSSBankAccountNameCreated = "res.nibss.bank.name.created",// for getting name atteched to the account
180
+ MonoInitiationTransaction = "res.mono.initiation",//
181
181
  NIBSSInstitutions = "res.nibss.institution.list",
182
182
  QRDynamicCodeCreated = "res.dynamic.code.created",
183
183
  CardInitiationTransaction = "res.card.initiation.transaction",
@@ -4,11 +4,11 @@ exports.ResSubjects = exports.Subjects = exports.StreamName = exports.StreamEven
4
4
  var StreamEvent;
5
5
  (function (StreamEvent) {
6
6
  StreamEvent["Event"] = "events.>";
7
- })(StreamEvent = exports.StreamEvent || (exports.StreamEvent = {}));
7
+ })(StreamEvent || (exports.StreamEvent = StreamEvent = {}));
8
8
  var StreamName;
9
9
  (function (StreamName) {
10
10
  StreamName["name"] = "EVENTS";
11
- })(StreamName = exports.StreamName || (exports.StreamName = {}));
11
+ })(StreamName || (exports.StreamName = StreamName = {}));
12
12
  var Subjects;
13
13
  (function (Subjects) {
14
14
  // Accounts Subjects
@@ -207,7 +207,7 @@ var Subjects;
207
207
  Subjects["INVOICE_DELAY_NOTIFICATION_CREATED"] = "events.invoice.delay.notification.created";
208
208
  Subjects["INVOICE_DELAY_NOTIFICATION_COMPLETED"] = "events.invoice.delay.notification.completed";
209
209
  Subjects["INVOICE_NOTIFICATION_CREATED"] = "events.invoice.delay.notification.created";
210
- })(Subjects = exports.Subjects || (exports.Subjects = {}));
210
+ })(Subjects || (exports.Subjects = Subjects = {}));
211
211
  var ResSubjects;
212
212
  (function (ResSubjects) {
213
213
  // VirtualAccount
@@ -233,4 +233,4 @@ var ResSubjects;
233
233
  ResSubjects["CashierInitiation"] = "res.cashier.initiation";
234
234
  //Temp
235
235
  ResSubjects["TempTokenUpdated"] = "res.temp.token.updated";
236
- })(ResSubjects = exports.ResSubjects || (exports.ResSubjects = {}));
236
+ })(ResSubjects || (exports.ResSubjects = ResSubjects = {}));
@@ -23,4 +23,4 @@ var OrderStatus;
23
23
  the user made the payment successfully
24
24
  */
25
25
  OrderStatus["Complete"] = "complete";
26
- })(OrderStatus = exports.OrderStatus || (exports.OrderStatus = {}));
26
+ })(OrderStatus || (exports.OrderStatus = OrderStatus = {}));
@@ -8,4 +8,4 @@ var TwoFAType;
8
8
  TwoFAType["PHONE_EMAIL"] = "PHONE_EMAIL";
9
9
  TwoFAType["TWOFA_APP"] = "TWOFA_APP";
10
10
  TwoFAType["DEFAULT_APP"] = "DEFAULT_APP";
11
- })(TwoFAType = exports.TwoFAType || (exports.TwoFAType = {}));
11
+ })(TwoFAType || (exports.TwoFAType = TwoFAType = {}));
@@ -5,5 +5,5 @@ var ACCOUNT_BALANCE_TYPE;
5
5
  (function (ACCOUNT_BALANCE_TYPE) {
6
6
  ACCOUNT_BALANCE_TYPE["ledger"] = "ledger";
7
7
  ACCOUNT_BALANCE_TYPE["main"] = "main";
8
- })(ACCOUNT_BALANCE_TYPE = exports.ACCOUNT_BALANCE_TYPE || (exports.ACCOUNT_BALANCE_TYPE = {}));
8
+ })(ACCOUNT_BALANCE_TYPE || (exports.ACCOUNT_BALANCE_TYPE = ACCOUNT_BALANCE_TYPE = {}));
9
9
  // commit
@@ -5,4 +5,4 @@ var Account_Status;
5
5
  (function (Account_Status) {
6
6
  Account_Status["active"] = "Active";
7
7
  Account_Status["blocked"] = "Blocked";
8
- })(Account_Status = exports.Account_Status || (exports.Account_Status = {}));
8
+ })(Account_Status || (exports.Account_Status = Account_Status = {}));
@@ -5,9 +5,9 @@ var KeyType;
5
5
  (function (KeyType) {
6
6
  KeyType["public"] = "public";
7
7
  KeyType["secret"] = "secret";
8
- })(KeyType = exports.KeyType || (exports.KeyType = {}));
8
+ })(KeyType || (exports.KeyType = KeyType = {}));
9
9
  var Usage;
10
10
  (function (Usage) {
11
11
  Usage["LIVE"] = "LIVE";
12
12
  Usage["TEST"] = "TEST";
13
- })(Usage = exports.Usage || (exports.Usage = {}));
13
+ })(Usage || (exports.Usage = Usage = {}));
@@ -5,4 +5,4 @@ var BANK_ACCOUNT_TYPE;
5
5
  (function (BANK_ACCOUNT_TYPE) {
6
6
  BANK_ACCOUNT_TYPE["main"] = "main";
7
7
  BANK_ACCOUNT_TYPE["sub"] = "sub";
8
- })(BANK_ACCOUNT_TYPE = exports.BANK_ACCOUNT_TYPE || (exports.BANK_ACCOUNT_TYPE = {}));
8
+ })(BANK_ACCOUNT_TYPE || (exports.BANK_ACCOUNT_TYPE = BANK_ACCOUNT_TYPE = {}));
@@ -11,11 +11,11 @@ var BUSINESS_CLASS;
11
11
  BUSINESS_CLASS["GOVERNMENT_BODY"] = "GOVERNMENT_BODY";
12
12
  BUSINESS_CLASS["PRIVATE_BODY_BY_GOVERNMENT_APPROVAL"] = "PRIVATE_BODY_BY_GOVERNMENT_APPROVAL";
13
13
  BUSINESS_CLASS["COORPORATIVE_SOCIETY"] = "COORPORATIVE_SOCIETY";
14
- })(BUSINESS_CLASS = exports.BUSINESS_CLASS || (exports.BUSINESS_CLASS = {}));
14
+ })(BUSINESS_CLASS || (exports.BUSINESS_CLASS = BUSINESS_CLASS = {}));
15
15
  var INDIVIDUAL_REQUIRED_TYPE;
16
16
  (function (INDIVIDUAL_REQUIRED_TYPE) {
17
17
  INDIVIDUAL_REQUIRED_TYPE["DRIVER_LICENSE"] = "DRIVER_LICENSE";
18
18
  INDIVIDUAL_REQUIRED_TYPE["NIN"] = "NIN";
19
19
  INDIVIDUAL_REQUIRED_TYPE["INTERNATIONAL_PASSPORT"] = "INTERNATIONAL_PASSPORT";
20
20
  INDIVIDUAL_REQUIRED_TYPE["VOTER_CARD"] = "VOTER_CARD";
21
- })(INDIVIDUAL_REQUIRED_TYPE = exports.INDIVIDUAL_REQUIRED_TYPE || (exports.INDIVIDUAL_REQUIRED_TYPE = {}));
21
+ })(INDIVIDUAL_REQUIRED_TYPE || (exports.INDIVIDUAL_REQUIRED_TYPE = INDIVIDUAL_REQUIRED_TYPE = {}));
@@ -5,7 +5,7 @@ var BUSINESS_TYPE;
5
5
  (function (BUSINESS_TYPE) {
6
6
  BUSINESS_TYPE["INDIVIDUAL"] = "INDIVIDUAL_ACCOUNT";
7
7
  BUSINESS_TYPE["BUSINESS"] = "BUSINESS_ACCOUNT";
8
- })(BUSINESS_TYPE = exports.BUSINESS_TYPE || (exports.BUSINESS_TYPE = {}));
8
+ })(BUSINESS_TYPE || (exports.BUSINESS_TYPE = BUSINESS_TYPE = {}));
9
9
  var SocialMediaType;
10
10
  (function (SocialMediaType) {
11
11
  SocialMediaType["facebook"] = "facebook";
@@ -13,4 +13,4 @@ var SocialMediaType;
13
13
  SocialMediaType["youtube"] = "youtube";
14
14
  SocialMediaType["x"] = "x";
15
15
  SocialMediaType["linkedin"] = "linkedin";
16
- })(SocialMediaType = exports.SocialMediaType || (exports.SocialMediaType = {}));
16
+ })(SocialMediaType || (exports.SocialMediaType = SocialMediaType = {}));
@@ -5,4 +5,4 @@ var BVNVALIDATIONTYPE;
5
5
  (function (BVNVALIDATIONTYPE) {
6
6
  BVNVALIDATIONTYPE["bvn"] = "bvn";
7
7
  BVNVALIDATIONTYPE["bank_account"] = "bank_account";
8
- })(BVNVALIDATIONTYPE = exports.BVNVALIDATIONTYPE || (exports.BVNVALIDATIONTYPE = {}));
8
+ })(BVNVALIDATIONTYPE || (exports.BVNVALIDATIONTYPE = BVNVALIDATIONTYPE = {}));
@@ -14,7 +14,7 @@ var CARD_TYPES;
14
14
  CARD_TYPES["diners"] = "DINERS";
15
15
  CARD_TYPES["jcb"] = "JCB";
16
16
  CARD_TYPES["china_union_pay"] = "CHINA_UNION_PAY";
17
- })(CARD_TYPES = exports.CARD_TYPES || (exports.CARD_TYPES = {}));
17
+ })(CARD_TYPES || (exports.CARD_TYPES = CARD_TYPES = {}));
18
18
  const creditCardType = (cc) => {
19
19
  // Input validation
20
20
  if (typeof cc !== "string" || !/^\d+$/.test(cc)) {
@@ -6,4 +6,4 @@ var CARD_ATH_TYPE;
6
6
  CARD_ATH_TYPE["user_otp"] = "user_otp";
7
7
  CARD_ATH_TYPE["user_3ds"] = "user_3ds";
8
8
  CARD_ATH_TYPE["no_auth"] = "no_auth";
9
- })(CARD_ATH_TYPE = exports.CARD_ATH_TYPE || (exports.CARD_ATH_TYPE = {}));
9
+ })(CARD_ATH_TYPE || (exports.CARD_ATH_TYPE = CARD_ATH_TYPE = {}));
@@ -8,18 +8,18 @@ var TOPUP_TRANSACTIONS;
8
8
  TOPUP_TRANSACTIONS["BUY_AIRTIME"] = "BUY_AIRTIME";
9
9
  TOPUP_TRANSACTIONS["TV_SUBSCRIPTION"] = "TV_SUBSCRIPTION";
10
10
  TOPUP_TRANSACTIONS["TRANSFER"] = "TRANSFER";
11
- })(TOPUP_TRANSACTIONS = exports.TOPUP_TRANSACTIONS || (exports.TOPUP_TRANSACTIONS = {}));
11
+ })(TOPUP_TRANSACTIONS || (exports.TOPUP_TRANSACTIONS = TOPUP_TRANSACTIONS = {}));
12
12
  var TRANSACTION_CHARGES_TYPE;
13
13
  (function (TRANSACTION_CHARGES_TYPE) {
14
14
  TRANSACTION_CHARGES_TYPE["FUND_WALLET"] = "FUND_WALLET";
15
15
  TRANSACTION_CHARGES_TYPE["UPDATE_TRANSACTION"] = "UPDATE_TRANSACTION";
16
- })(TRANSACTION_CHARGES_TYPE = exports.TRANSACTION_CHARGES_TYPE || (exports.TRANSACTION_CHARGES_TYPE = {}));
16
+ })(TRANSACTION_CHARGES_TYPE || (exports.TRANSACTION_CHARGES_TYPE = TRANSACTION_CHARGES_TYPE = {}));
17
17
  var ORIGIN;
18
18
  (function (ORIGIN) {
19
19
  ORIGIN["wallet"] = "wallet";
20
- })(ORIGIN = exports.ORIGIN || (exports.ORIGIN = {}));
20
+ })(ORIGIN || (exports.ORIGIN = ORIGIN = {}));
21
21
  var REVENUE_TYPE;
22
22
  (function (REVENUE_TYPE) {
23
23
  REVENUE_TYPE["transfer"] = "transfer";
24
24
  REVENUE_TYPE["transaction"] = "transaction";
25
- })(REVENUE_TYPE = exports.REVENUE_TYPE || (exports.REVENUE_TYPE = {}));
25
+ })(REVENUE_TYPE || (exports.REVENUE_TYPE = REVENUE_TYPE = {}));
@@ -5,4 +5,4 @@ var CURRENCY_TYPE;
5
5
  (function (CURRENCY_TYPE) {
6
6
  CURRENCY_TYPE["NGN"] = "NGN";
7
7
  CURRENCY_TYPE["USD"] = "USD";
8
- })(CURRENCY_TYPE = exports.CURRENCY_TYPE || (exports.CURRENCY_TYPE = {}));
8
+ })(CURRENCY_TYPE || (exports.CURRENCY_TYPE = CURRENCY_TYPE = {}));
@@ -9,10 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.generateQueryObject = exports.paginate = void 0;
12
+ exports.generateQueryObject = void 0;
13
+ exports.paginate = paginate;
13
14
  const date_processing_1 = require("./date-processing");
14
- function paginate(model, options = {}) {
15
- return __awaiter(this, void 0, void 0, function* () {
15
+ function paginate(model_1) {
16
+ return __awaiter(this, arguments, void 0, function* (model, options = {}) {
16
17
  const page = options.page || 1;
17
18
  const limit = options.limit || 20;
18
19
  const skip = (page - 1) * limit;
@@ -53,7 +54,6 @@ function paginate(model, options = {}) {
53
54
  return paginationInfo;
54
55
  });
55
56
  }
56
- exports.paginate = paginate;
57
57
  const generateQueryObject = (filters, searchesFieldNames = [], select = "", populate = []) => {
58
58
  const { status, limit, page, sort_by = "createdAt", order = "desc", merchantId, accountId, dateField, } = filters;
59
59
  const excludes = [
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSettlementDate = exports.canRefundFromSettlementLedgerByDay = exports.calculateDelay = exports.getFutureDateFromPlan = exports.getDuration = exports.convertDateToUTC = exports.convertDateToUTCString = exports.convertDateToUTCRange = exports.convertDateToUTCRangeString = exports.isTodayOrFuture = exports.getStartAndEndDate = exports.getCurrentDayRange = exports.getPreviousDayRange = exports.convertToDate = exports.formatDateTime = exports.interswitchRefundDateFormat = exports.formatDate = void 0;
6
+ exports.calculateDelay = exports.getFutureDateFromPlan = exports.getDuration = exports.convertDateToUTC = exports.convertDateToUTCString = exports.convertDateToUTCRange = exports.convertDateToUTCRangeString = exports.isTodayOrFuture = exports.getStartAndEndDate = exports.getCurrentDayRange = exports.getPreviousDayRange = exports.convertToDate = exports.formatDateTime = exports.interswitchRefundDateFormat = exports.formatDate = void 0;
7
+ exports.canRefundFromSettlementLedgerByDay = canRefundFromSettlementLedgerByDay;
8
+ exports.getSettlementDate = getSettlementDate;
7
9
  const dayjs_1 = __importDefault(require("dayjs"));
8
10
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
9
11
  // Extend dayjs with the UTC plugin
@@ -190,7 +192,6 @@ function canRefundFromSettlementLedgerByDay(transactionCreatedAt, bufferInMinute
190
192
  // 2. There’s still enough buffer time before the new day starts
191
193
  return now.isBefore(cutoffTime);
192
194
  }
193
- exports.canRefundFromSettlementLedgerByDay = canRefundFromSettlementLedgerByDay;
194
195
  function getSettlementDate(transactionDate = new Date()) {
195
196
  const txDate = (0, dayjs_1.default)(transactionDate);
196
197
  const day = txDate.day(); // 0 = Sunday, ..., 6 = Saturday
@@ -206,4 +207,3 @@ function getSettlementDate(transactionDate = new Date()) {
206
207
  }
207
208
  return settlementDate.toDate(); // Return native Date object
208
209
  }
209
- exports.getSettlementDate = getSettlementDate;
@@ -9,7 +9,7 @@ var DISPUTE_STATUS;
9
9
  DISPUTE_STATUS["LOST"] = "LOST";
10
10
  DISPUTE_STATUS["PENDING"] = "PENDING";
11
11
  DISPUTE_STATUS["UNDER_REVIEW"] = "UNDER_REVIEW";
12
- })(DISPUTE_STATUS = exports.DISPUTE_STATUS || (exports.DISPUTE_STATUS = {}));
12
+ })(DISPUTE_STATUS || (exports.DISPUTE_STATUS = DISPUTE_STATUS = {}));
13
13
  var DisputeReasonCode;
14
14
  (function (DisputeReasonCode) {
15
15
  DisputeReasonCode["FRAUD"] = "10.4";
@@ -17,4 +17,4 @@ var DisputeReasonCode;
17
17
  DisputeReasonCode["DUPLICATE"] = "12.6";
18
18
  DisputeReasonCode["NOT_AUTHORIZED"] = "10.5";
19
19
  DisputeReasonCode["OTHER"] = "other";
20
- })(DisputeReasonCode = exports.DisputeReasonCode || (exports.DisputeReasonCode = {}));
20
+ })(DisputeReasonCode || (exports.DisputeReasonCode = DisputeReasonCode = {}));
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ import { BinaryLike, CipherKey } from "crypto";
2
2
  /**
3
3
  * this is how the aes key and iv should be generated
4
4
  *
@@ -15,7 +15,7 @@ export declare const generateAesKeyAndIv: () => {
15
15
  * @param iv
16
16
  * @returns base 64 of the iv and encrypted data in iv:data
17
17
  */
18
- export declare const encryptWithAes: (data: string, aesKey: Buffer, iv: Buffer) => string;
18
+ export declare const encryptWithAes: (data: string, aesKey: CipherKey, iv: BinaryLike) => string;
19
19
  /**
20
20
  *
21
21
  * @param aesKey the key generated for encryption
@@ -36,7 +36,7 @@ export declare const decryptWithRsaPrivateKey: (encryptedAesKey: string, private
36
36
  * @param aesKey the AES key as Buffer obtain from the decryption of the data
37
37
  * @returns return data as string
38
38
  */
39
- export declare const decryptWithAes: (encryptedDataWithIv: string, aesKey: Buffer) => string;
39
+ export declare const decryptWithAes: (encryptedDataWithIv: string, aesKey: CipherKey) => string;
40
40
  /**
41
41
  *
42
42
  * @param data data to be encrpted as string
@@ -48,7 +48,7 @@ const encryptWithRsaPublicKey = (aesKey, publicKey) => {
48
48
  key: publicKey,
49
49
  padding: crypto_1.default.constants.RSA_PKCS1_OAEP_PADDING,
50
50
  oaepHash: "sha256",
51
- }, aesKey);
51
+ }, new Uint8Array(aesKey));
52
52
  return encryptedKey.toString("base64");
53
53
  };
54
54
  exports.encryptWithRsaPublicKey = encryptWithRsaPublicKey;
@@ -63,7 +63,7 @@ const decryptWithRsaPrivateKey = (encryptedAesKey, privateKey) => {
63
63
  key: privateKey,
64
64
  padding: crypto_1.default.constants.RSA_PKCS1_OAEP_PADDING,
65
65
  oaepHash: "sha256",
66
- }, Buffer.from(encryptedAesKey, "base64"));
66
+ }, new Uint8Array(Buffer.from(encryptedAesKey, "base64")));
67
67
  return decryptedKey;
68
68
  };
69
69
  exports.decryptWithRsaPrivateKey = decryptWithRsaPrivateKey;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateQueryParams = void 0;
3
+ exports.generateQueryParams = generateQueryParams;
4
4
  function generateQueryParams(params) {
5
5
  // Check if params is empty
6
6
  if (Object.keys(params).length === 0) {
@@ -15,4 +15,3 @@ function generateQueryParams(params) {
15
15
  const fullUrl = `?${queryString}`;
16
16
  return fullUrl;
17
17
  }
18
- exports.generateQueryParams = generateQueryParams;
@@ -7,17 +7,17 @@ var INVOICE_STATUS;
7
7
  INVOICE_STATUS["PAID"] = "PAID";
8
8
  INVOICE_STATUS["CANCELLED"] = "CANCELLED";
9
9
  INVOICE_STATUS["DRAFT"] = "DRAFT";
10
- })(INVOICE_STATUS = exports.INVOICE_STATUS || (exports.INVOICE_STATUS = {}));
10
+ })(INVOICE_STATUS || (exports.INVOICE_STATUS = INVOICE_STATUS = {}));
11
11
  var DISCOUNT_TYPE;
12
12
  (function (DISCOUNT_TYPE) {
13
13
  DISCOUNT_TYPE["PERCENT"] = "PERCENT";
14
14
  DISCOUNT_TYPE["FLAT"] = "FLAT";
15
15
  DISCOUNT_TYPE["NONE"] = "NONE";
16
- })(DISCOUNT_TYPE = exports.DISCOUNT_TYPE || (exports.DISCOUNT_TYPE = {}));
16
+ })(DISCOUNT_TYPE || (exports.DISCOUNT_TYPE = DISCOUNT_TYPE = {}));
17
17
  var TAX_TYPE;
18
18
  (function (TAX_TYPE) {
19
19
  TAX_TYPE["PERCENT"] = "PERCENT";
20
20
  TAX_TYPE["FLAT"] = "FLAT";
21
21
  TAX_TYPE["NONE"] = "NONE";
22
- })(TAX_TYPE = exports.TAX_TYPE || (exports.TAX_TYPE = {}));
22
+ })(TAX_TYPE || (exports.TAX_TYPE = TAX_TYPE = {}));
23
23
  //
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * Hashing a secret using sha256
4
3
  * @param secret - the secret to hash
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };