@konplit-services/common 1.0.19 → 1.0.21

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 (33) hide show
  1. package/build/app.configs.d.ts +9 -0
  2. package/build/app.configs.js +36 -0
  3. package/build/events/index.d.ts +1 -0
  4. package/build/events/index.js +1 -0
  5. package/build/events/notification-events/interfaces/index.d.ts +2 -0
  6. package/build/events/notification-events/interfaces/index.js +18 -0
  7. package/build/events/notification-events/interfaces/mailersend.interface.d.ts +18 -0
  8. package/build/events/notification-events/interfaces/mailersend.interface.js +2 -0
  9. package/build/events/notification-events/interfaces/termii-sms.interface.d.ts +8 -0
  10. package/build/events/notification-events/interfaces/termii-sms.interface.js +2 -0
  11. package/build/events/subjects.d.ts +6 -2
  12. package/build/events/subjects.js +5 -0
  13. package/build/helper/index.d.ts +0 -1
  14. package/build/helper/index.js +0 -1
  15. package/build/index.d.ts +1 -0
  16. package/build/index.js +2 -0
  17. package/build/notification/email/index.d.ts +2 -0
  18. package/build/notification/email/index.js +18 -0
  19. package/build/notification/email/send.d.ts +25 -0
  20. package/build/notification/email/send.js +56 -0
  21. package/build/notification/email/types.d.ts +22 -0
  22. package/build/notification/email/types.js +26 -0
  23. package/build/notification/index.d.ts +2 -0
  24. package/build/notification/index.js +18 -0
  25. package/build/notification/sms/constants.d.ts +3 -0
  26. package/build/notification/sms/constants.js +9 -0
  27. package/build/notification/sms/index.d.ts +2 -0
  28. package/build/notification/sms/index.js +18 -0
  29. package/build/notification/sms/send.d.ts +16 -0
  30. package/build/notification/sms/send.js +34 -0
  31. package/build/services/index.d.ts +0 -1
  32. package/build/services/index.js +0 -1
  33. package/package.json +2 -1
@@ -81,6 +81,8 @@ declare class AppConfigs {
81
81
  getAppName(): string;
82
82
  getJWTKEY(): string;
83
83
  getDBURI(): string;
84
+ getActivityLogDBURI(): string;
85
+ getAccountDBURI(): string;
84
86
  getNATSURI(): string;
85
87
  getNATSPassword(): string;
86
88
  getNATSUsername(): string;
@@ -107,6 +109,11 @@ declare class AppConfigs {
107
109
  getEmailTemplates(): EmailTemplate;
108
110
  getCloudinaryKey(): string;
109
111
  getMailSenderKey(): string;
112
+ getTermiiSMSKey(): {
113
+ apiKey: string;
114
+ secretKey: string;
115
+ sender: string;
116
+ };
110
117
  getCloudWatchDetails(): {
111
118
  accessKey: string;
112
119
  secretKey: string;
@@ -127,6 +134,8 @@ declare class AppConfigs {
127
134
  support_phone: string;
128
135
  ip_token: string;
129
136
  invoice_url: string;
137
+ noReplyEmail: string;
138
+ emailName: string;
130
139
  };
131
140
  getNIBSSDetails(): NIBSS;
132
141
  getFidelityDetails(): {
@@ -23,6 +23,18 @@ class AppConfigs {
23
23
  }
24
24
  return this.env.Mongo_URI;
25
25
  }
26
+ getActivityLogDBURI() {
27
+ if (!this.env.Mongo_ACTIVITY_URI) {
28
+ throw new Error("Mongo_ACTIVITY_URI is required");
29
+ }
30
+ return this.env.Mongo_ACTIVITY_URI;
31
+ }
32
+ getAccountDBURI() {
33
+ if (!this.env.MONGO_URI_ACCOUNT) {
34
+ throw new Error("MONGO_URI_ACCOUNT is required");
35
+ }
36
+ return this.env.MONGO_URI_ACCOUNT;
37
+ }
26
38
  getNATSURI() {
27
39
  if (!this.env.NATS_URI) {
28
40
  throw new Error("NATS_URI is required");
@@ -218,6 +230,22 @@ class AppConfigs {
218
230
  }
219
231
  return this.env.MAIL_SENDER_KEY;
220
232
  }
233
+ getTermiiSMSKey() {
234
+ if (!this.env.SMS_API_KEY) {
235
+ throw new Error("SMS_API_KEY is required");
236
+ }
237
+ if (!this.env.SMS_SECRET_KEY) {
238
+ throw new Error("SMS_SECRET_KEY is required");
239
+ }
240
+ if (!this.env.SMS_SENDER) {
241
+ throw new Error("SMS_SENDER is required");
242
+ }
243
+ return {
244
+ apiKey: this.env.SMS_API_KEY,
245
+ secretKey: this.env.SMS_SECRET_KEY,
246
+ sender: this.env.SMS_SENDER,
247
+ };
248
+ }
221
249
  getCloudWatchDetails() {
222
250
  if (!this.env.CLOUDWATCH_ACCESSKEY) {
223
251
  throw new Error("CLOUDWATCH_ACCESSKEY is required");
@@ -280,6 +308,12 @@ class AppConfigs {
280
308
  if (!this.env.VALUEPAY_INVOICE_URL) {
281
309
  throw new Error("VALUEPAY_INVOICE_URL is required");
282
310
  }
311
+ if (!this.env.VALUEPAY_NO_REPLY_EMAIL) {
312
+ throw new Error("VALUEPAY_NO_REPLY_EMAIL is required");
313
+ }
314
+ if (!this.env.VALUEPAY_EMAIL_NAME) {
315
+ throw new Error("VALUEPAY_NO_REPLY_EMAIL is required");
316
+ }
283
317
  return {
284
318
  visa_redirect_url: this.env.VALUEPAY_VISA_REDIRECT_URL,
285
319
  visa_callback_url: this.env.VALUEPAY_VISA_CALLBACK_URL,
@@ -288,6 +322,8 @@ class AppConfigs {
288
322
  support_phone: this.env.VALUEPAY_SUPPORT_PHONE,
289
323
  ip_token: this.env.VALUEPAY_IP_TOKEN,
290
324
  invoice_url: this.env.VALUEPAY_INVOICE_URL,
325
+ noReplyEmail: this.env.VALUEPAY_NO_REPLY_EMAIL,
326
+ emailName: this.env.VALUEPAY_EMAIL_NAME,
291
327
  };
292
328
  }
293
329
  getNIBSSDetails() {
@@ -1,5 +1,6 @@
1
1
  export * from "./subjects";
2
2
  export * from "./accounts-events/interfaces";
3
3
  export * from "./logs-events/interfaces";
4
+ export * from "./notification-events/interfaces";
4
5
  export * from "./base-events";
5
6
  export * from "./types";
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./subjects"), exports);
18
18
  __exportStar(require("./accounts-events/interfaces"), exports);
19
19
  __exportStar(require("./logs-events/interfaces"), exports);
20
+ __exportStar(require("./notification-events/interfaces"), exports);
20
21
  __exportStar(require("./base-events"), exports);
21
22
  __exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./mailersend.interface";
2
+ export * from "./termii-sms.interface";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mailersend.interface"), exports);
18
+ __exportStar(require("./termii-sms.interface"), exports);
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ import { StreamEvent, StreamName, Subjects } from "../../subjects";
3
+ export interface MailersendEmailCreatedEvent {
4
+ subject: Subjects.NotificationEmailCreated;
5
+ streamName: StreamName.NotificationName;
6
+ streamEvents: StreamEvent.Notification;
7
+ data: {
8
+ to: string;
9
+ subject: string;
10
+ templateId?: string;
11
+ data?: Record<string, any>;
12
+ pdf?: {
13
+ file: Buffer;
14
+ fileName: string;
15
+ };
16
+ sendAt?: number;
17
+ };
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { SendSmsRequest } from "../../../notification";
2
+ import { StreamEvent, StreamName, Subjects } from "../../subjects";
3
+ export interface TermiiSmsCreatedEvent {
4
+ subject: Subjects.NotificationSmsCreated;
5
+ streamName: StreamName.NotificationName;
6
+ streamEvents: StreamEvent.Notification;
7
+ data: SendSmsRequest;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,12 @@
1
1
  export declare enum StreamEvent {
2
2
  Event = "events.>",
3
- LOG = "logs.>"
3
+ LOG = "logs.>",
4
+ Notification = "notifications.>"
4
5
  }
5
6
  export declare enum StreamName {
6
7
  name = "EVENTS",
7
- logName = "LOGS"
8
+ logName = "LOGS",
9
+ NotificationName = "NOTIFICATIONS"
8
10
  }
9
11
  export declare enum Subjects {
10
12
  AccountCreated = "events.account.created",
@@ -21,6 +23,8 @@ export declare enum Subjects {
21
23
  PermissionUpdated = "events.permission.updated",
22
24
  PermissionRemoved = "events.permission.removed",
23
25
  AddPermissionToUser = "events.add.permission.to.user",
26
+ NotificationSmsCreated = "notifications.sms.created",
27
+ NotificationEmailCreated = "notifications.email.created",
24
28
  UserRoleUpdated = "events.user.role.updated",
25
29
  AdminLogCreated = "events.admin.log.created"
26
30
  }
@@ -5,11 +5,13 @@ var StreamEvent;
5
5
  (function (StreamEvent) {
6
6
  StreamEvent["Event"] = "events.>";
7
7
  StreamEvent["LOG"] = "logs.>";
8
+ StreamEvent["Notification"] = "notifications.>";
8
9
  })(StreamEvent = exports.StreamEvent || (exports.StreamEvent = {}));
9
10
  var StreamName;
10
11
  (function (StreamName) {
11
12
  StreamName["name"] = "EVENTS";
12
13
  StreamName["logName"] = "LOGS";
14
+ StreamName["NotificationName"] = "NOTIFICATIONS";
13
15
  })(StreamName = exports.StreamName || (exports.StreamName = {}));
14
16
  var Subjects;
15
17
  (function (Subjects) {
@@ -31,6 +33,9 @@ var Subjects;
31
33
  Subjects["PermissionUpdated"] = "events.permission.updated";
32
34
  Subjects["PermissionRemoved"] = "events.permission.removed";
33
35
  Subjects["AddPermissionToUser"] = "events.add.permission.to.user";
36
+ //Notification
37
+ Subjects["NotificationSmsCreated"] = "notifications.sms.created";
38
+ Subjects["NotificationEmailCreated"] = "notifications.email.created";
34
39
  // Roles
35
40
  Subjects["UserRoleUpdated"] = "events.user.role.updated";
36
41
  Subjects["AdminLogCreated"] = "events.admin.log.created";
@@ -13,7 +13,6 @@ export * from "./chargeback";
13
13
  export * from "./charges";
14
14
  export * from "./currency-types";
15
15
  export * from "./custom-paginate";
16
- export * from "./email-types";
17
16
  export * from "./extract-card-details";
18
17
  export * from "./invoice";
19
18
  export * from "./last-three";
@@ -29,7 +29,6 @@ __exportStar(require("./chargeback"), exports);
29
29
  __exportStar(require("./charges"), exports);
30
30
  __exportStar(require("./currency-types"), exports);
31
31
  __exportStar(require("./custom-paginate"), exports);
32
- __exportStar(require("./email-types"), exports);
33
32
  __exportStar(require("./extract-card-details"), exports);
34
33
  __exportStar(require("./invoice"), exports);
35
34
  __exportStar(require("./last-three"), exports);
package/build/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./services";
10
10
  export * from "./log-activities/actions";
11
11
  export * from "./swagger/config";
12
12
  export * from "./app.configs";
13
+ export * from "./notification";
package/build/index.js CHANGED
@@ -38,3 +38,5 @@ __exportStar(require("./log-activities/actions"), exports);
38
38
  __exportStar(require("./swagger/config"), exports);
39
39
  //environment variables
40
40
  __exportStar(require("./app.configs"), exports);
41
+ // Notification
42
+ __exportStar(require("./notification"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./send";
2
+ export * from "./types";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./send"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,25 @@
1
+ /// <reference types="node" />
2
+ export interface PersonalizationEntry {
3
+ email: string;
4
+ data: Record<string, any>;
5
+ }
6
+ export interface EmailData {
7
+ to: string;
8
+ subject: string;
9
+ templateId?: string;
10
+ personalization?: PersonalizationEntry[];
11
+ pdf?: {
12
+ file: Buffer;
13
+ fileName: string;
14
+ };
15
+ sendAt?: number;
16
+ }
17
+ export declare class EmailService {
18
+ private mailerSend;
19
+ constructor(apiKey: string);
20
+ /**
21
+ *
22
+ * @param data the send mail data
23
+ */
24
+ sendEmail(data: EmailData, send_email: string, sender_name: string, recipient_name?: string): Promise<void>;
25
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EmailService = void 0;
13
+ const mailersend_1 = require("mailersend");
14
+ class EmailService {
15
+ constructor(apiKey) {
16
+ this.mailerSend = new mailersend_1.MailerSend({
17
+ apiKey,
18
+ });
19
+ }
20
+ /**
21
+ *
22
+ * @param data the send mail data
23
+ */
24
+ sendEmail(data, send_email, sender_name, recipient_name = "") {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const sentFrom = new mailersend_1.Sender(send_email, sender_name);
27
+ const recipients = [new mailersend_1.Recipient(data.to, recipient_name)];
28
+ const emailParams = new mailersend_1.EmailParams()
29
+ .setFrom(sentFrom)
30
+ .setTo(recipients)
31
+ .setReplyTo(sentFrom)
32
+ .setSubject(data.subject);
33
+ if (data.templateId) {
34
+ emailParams.setTemplateId(data.templateId);
35
+ if (data.personalization) {
36
+ const personalizationArray = data.personalization.map((entry) => ({
37
+ email: entry.email,
38
+ data: entry.data,
39
+ }));
40
+ emailParams.setPersonalization(personalizationArray);
41
+ }
42
+ }
43
+ if (data.pdf) {
44
+ const pdfAttachment = [
45
+ new mailersend_1.Attachment(data.pdf.file.toString("base64"), data.pdf.fileName, "attachment"),
46
+ ];
47
+ emailParams.setAttachments(pdfAttachment);
48
+ }
49
+ if (data.sendAt) {
50
+ emailParams.setSendAt(new Date(data.sendAt * 1000).getTime());
51
+ }
52
+ yield this.mailerSend.email.send(emailParams);
53
+ });
54
+ }
55
+ }
56
+ exports.EmailService = EmailService;
@@ -0,0 +1,22 @@
1
+ export declare enum EMAIL_TYPES {
2
+ VERIFY_ACCOUNT = "VERIFY_ACCOUNT",
3
+ BUSINESS_ADDED = "BUSINESS_ADDED",
4
+ CONFIRMATION = "CONFIRMATION",
5
+ TWOFAVERIFICATION = "TWOFAVERIFICATION",
6
+ RESET_PASSWORD_REQUEST = "RESET_PASSWORD_REQUEST",
7
+ PASSWORD_CHANGED = "PASSWORD_CHANGED",
8
+ PAYEE_INVOICE = "PAYEE_INVOICE",
9
+ KEYS_GENERATED = "KEYS_GENERATED",
10
+ REFUND_REQUEST = "REFUND_REQUEST",
11
+ REFUND_UPDATE = "REFUND_UPDATE",
12
+ REFUND_SENT = "REFUND_SENT",
13
+ CHARGE_BACK_REQUEST = "CHARGE_BACK_REQUEST",
14
+ CHARGE_BACK_UPDATE = "CHARGE_BACK_UPDATE",
15
+ CHARGE_BACK_RESOLVED = "CHARGE_BACK_RESOLVED",
16
+ TRANSFER_REQUEST = "TRANSFER_REQUEST",
17
+ TRANSFER_UPDATE = "TRANSFER_UPDATE",
18
+ TRANSFER_SENT = "TRANSFER_SENT",
19
+ SETTLEMENT_CREATED = "SETTLEMENT_CREATED",
20
+ MERCHANT_CUSTOMER_PAYMENT_NOTIFICATION = "MERCHANT_CUSTOMER_PAYMENT_NOTIFICATION",
21
+ MERCHANT_BUSINESS_PAYMENT_NOTIFICATION = "MERCHANT_PAYMENT_NOTIFICATION"
22
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMAIL_TYPES = void 0;
4
+ var EMAIL_TYPES;
5
+ (function (EMAIL_TYPES) {
6
+ EMAIL_TYPES["VERIFY_ACCOUNT"] = "VERIFY_ACCOUNT";
7
+ EMAIL_TYPES["BUSINESS_ADDED"] = "BUSINESS_ADDED";
8
+ EMAIL_TYPES["CONFIRMATION"] = "CONFIRMATION";
9
+ EMAIL_TYPES["TWOFAVERIFICATION"] = "TWOFAVERIFICATION";
10
+ EMAIL_TYPES["RESET_PASSWORD_REQUEST"] = "RESET_PASSWORD_REQUEST";
11
+ EMAIL_TYPES["PASSWORD_CHANGED"] = "PASSWORD_CHANGED";
12
+ EMAIL_TYPES["PAYEE_INVOICE"] = "PAYEE_INVOICE";
13
+ EMAIL_TYPES["KEYS_GENERATED"] = "KEYS_GENERATED";
14
+ EMAIL_TYPES["REFUND_REQUEST"] = "REFUND_REQUEST";
15
+ EMAIL_TYPES["REFUND_UPDATE"] = "REFUND_UPDATE";
16
+ EMAIL_TYPES["REFUND_SENT"] = "REFUND_SENT";
17
+ EMAIL_TYPES["CHARGE_BACK_REQUEST"] = "CHARGE_BACK_REQUEST";
18
+ EMAIL_TYPES["CHARGE_BACK_UPDATE"] = "CHARGE_BACK_UPDATE";
19
+ EMAIL_TYPES["CHARGE_BACK_RESOLVED"] = "CHARGE_BACK_RESOLVED";
20
+ EMAIL_TYPES["TRANSFER_REQUEST"] = "TRANSFER_REQUEST";
21
+ EMAIL_TYPES["TRANSFER_UPDATE"] = "TRANSFER_UPDATE";
22
+ EMAIL_TYPES["TRANSFER_SENT"] = "TRANSFER_SENT";
23
+ EMAIL_TYPES["SETTLEMENT_CREATED"] = "SETTLEMENT_CREATED";
24
+ EMAIL_TYPES["MERCHANT_CUSTOMER_PAYMENT_NOTIFICATION"] = "MERCHANT_CUSTOMER_PAYMENT_NOTIFICATION";
25
+ EMAIL_TYPES["MERCHANT_BUSINESS_PAYMENT_NOTIFICATION"] = "MERCHANT_PAYMENT_NOTIFICATION";
26
+ })(EMAIL_TYPES = exports.EMAIL_TYPES || (exports.EMAIL_TYPES = {}));
@@ -0,0 +1,2 @@
1
+ export * from "./email";
2
+ export * from "./sms";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./email"), exports);
18
+ __exportStar(require("./sms"), exports);
@@ -0,0 +1,3 @@
1
+ export declare const phoneValidation: (token: string | number) => string;
2
+ export declare const twoFactor: (token: string | number) => string;
3
+ export declare const transfer: (token: string | number) => string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transfer = exports.twoFactor = exports.phoneValidation = void 0;
4
+ const phoneValidation = (token) => `Your OTP is ${token}. Use this code to complete your phone verification. This code is valid for 15 minutes. Do not share it with anyone.`;
5
+ exports.phoneValidation = phoneValidation;
6
+ const twoFactor = (token) => `Your OTP is ${token}. Use this code to complete your 2fa verification. This code is valid for 15 minutes. Do not share it with anyone.`;
7
+ exports.twoFactor = twoFactor;
8
+ const transfer = (token) => `Your OTP is ${token}. Use this code to complete your transfer process. This code is valid for 15 minutes. Do not share it with anyone.`;
9
+ exports.transfer = transfer;
@@ -0,0 +1,2 @@
1
+ export * from "./constants";
2
+ export * from "./send";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./send"), exports);
@@ -0,0 +1,16 @@
1
+ export interface SendSmsRequest {
2
+ to: string;
3
+ from: string;
4
+ sms: string;
5
+ type: string;
6
+ channel: string;
7
+ api_key?: string;
8
+ }
9
+ export interface SendSmsResponse {
10
+ message_id: string;
11
+ message: string;
12
+ balance: number;
13
+ user: string;
14
+ sms_credits_used: number;
15
+ }
16
+ export declare const sendSms: (request: SendSmsRequest) => Promise<SendSmsResponse>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.sendSms = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const sendSms = (request) => __awaiter(void 0, void 0, void 0, function* () {
18
+ var _a;
19
+ const url = "https://api.ng.termii.com/api/sms/send";
20
+ try {
21
+ const response = yield axios_1.default.post(url, request);
22
+ return response.data;
23
+ }
24
+ catch (error) {
25
+ if (axios_1.default.isAxiosError(error)) {
26
+ console.error("Axios error:", ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
27
+ }
28
+ else {
29
+ console.error("Unexpected error:", error);
30
+ }
31
+ throw error;
32
+ }
33
+ });
34
+ exports.sendSms = sendSms;
@@ -1,3 +1,2 @@
1
1
  export * from "./Jwt";
2
2
  export * from "./base.service";
3
- export * from "./mailersend";
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Jwt"), exports);
18
18
  __exportStar(require("./base.service"), exports);
19
- __exportStar(require("./mailersend"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,6 +24,7 @@
24
24
  "@types/node": "^18.6.1",
25
25
  "@types/swagger-jsdoc": "^6.0.4",
26
26
  "@types/swagger-ui-express": "^4.1.6",
27
+ "axios": "^1.7.2",
27
28
  "express": "^4.18.1",
28
29
  "express-validator": "^6.14.2",
29
30
  "ioredis": "^5.4.1",