@konplit-services/common 1.5.0 → 1.7.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.
@@ -255,6 +255,7 @@ declare class AppConfigs {
255
255
  getVirtualAccountDBURI(): string;
256
256
  getWalletDBURI(): string;
257
257
  getAdminWebUrl(): string;
258
+ getClientAppUrl(): string;
258
259
  getNATSURI(): string;
259
260
  getWebsiteDBURI(): string;
260
261
  getSettlementDBURI(): string;
@@ -113,6 +113,12 @@ class AppConfigs {
113
113
  }
114
114
  return this.env.ADMIN_WEB_URL;
115
115
  }
116
+ getClientAppUrl() {
117
+ if (!this.env.CLIENT_APP_URL) {
118
+ throw new Error("CLIENT_APP_URL is required");
119
+ }
120
+ return this.env.CLIENT_APP_URL;
121
+ }
116
122
  getNATSURI() {
117
123
  if (!this.env.NATS_URI) {
118
124
  throw new Error("NATS_URI is required");
@@ -7,6 +7,7 @@ export interface SettlementPayMerchantEvent {
7
7
  data: {
8
8
  id: string;
9
9
  merchantId: string;
10
+ merchantName: string;
10
11
  accountNumber: string;
11
12
  amount: number;
12
13
  charges: number;
@@ -8,6 +8,7 @@ export interface SettlementPayMerchantNIBSSEvent {
8
8
  id: string;
9
9
  merchantId: string;
10
10
  accountNumber: string;
11
+ merchantName: string;
11
12
  amount: number;
12
13
  charges: number;
13
14
  transactionDate: Date;
@@ -10,6 +10,7 @@ export interface SettlementTransferReservedNIBSSEvent {
10
10
  accountNumber: string;
11
11
  amount: number;
12
12
  charges: number;
13
+ merchantName: string;
13
14
  settlementProcessor: "nibss" | "interswitch";
14
15
  transactionDate: Date;
15
16
  currency?: CURRENCY_TYPE;
@@ -9,6 +9,7 @@ export interface SettlementTransferVerifyNISSEvent {
9
9
  amount: number;
10
10
  charges: number;
11
11
  settlementId: string;
12
+ merchantName: string;
12
13
  transferId: string;
13
14
  verificationTime: Date;
14
15
  };
@@ -8,6 +8,7 @@ export interface SettlementTransferInitiationEvent {
8
8
  id: string;
9
9
  merchantId: string;
10
10
  accountNumber: string;
11
+ merchantName: string;
11
12
  amount: number;
12
13
  charges: number;
13
14
  settlementProcessor: "nibss" | "interswitch";
@@ -8,6 +8,7 @@ export interface SettlementTransferReservedEvent {
8
8
  id: string;
9
9
  merchantId: string;
10
10
  accountNumber: string;
11
+ merchantName: string;
11
12
  amount: number;
12
13
  charges: number;
13
14
  settlementProcessor: "nibss" | "interswitch";
@@ -13,6 +13,7 @@ export interface SettlementUpdatedEvent {
13
13
  status?: Settlement_Status;
14
14
  settlementType: Settlement_TYPES;
15
15
  transactionDate: Date;
16
+ merchantName: string;
16
17
  currency?: CURRENCY_TYPE;
17
18
  version?: number;
18
19
  };
@@ -1,5 +1,6 @@
1
1
  import { PLAN_INTERVAL } from "./plan-types";
2
- export declare const formatDate: (dataString: string | Date) => string;
2
+ export declare const formatDate: (dateInput: string | Date | number, // support more input types
3
+ format?: string, tz?: string) => string;
3
4
  export declare const interswitchRefundDateFormat: (dataString: string) => string;
4
5
  export declare const formatDateTime: (dataString: string) => string;
5
6
  export declare const convertToDate: (date: string) => Date;
@@ -8,11 +8,23 @@ exports.canRefundFromSettlementLedgerByDay = canRefundFromSettlementLedgerByDay;
8
8
  exports.getSettlementDate = getSettlementDate;
9
9
  const dayjs_1 = __importDefault(require("dayjs"));
10
10
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
11
+ const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
11
12
  // Extend dayjs with the UTC plugin
12
13
  dayjs_1.default.extend(utc_1.default);
14
+ dayjs_1.default.extend(timezone_1.default);
15
+ const DEFAULT_TZ = "Africa/Lagos";
16
+ const DEFAULT_FORMAT = "YYYY-MM-DD";
13
17
  const plan_types_1 = require("./plan-types");
14
- const formatDate = (dataString) => {
15
- return (0, dayjs_1.default)(dataString).format("YYYY-MM-DD");
18
+ const formatDate = (dateInput, // support more input types
19
+ format = DEFAULT_FORMAT, tz = DEFAULT_TZ) => {
20
+ if (!dateInput) {
21
+ return ""; // gracefully handle empty/null
22
+ }
23
+ const parsed = (0, dayjs_1.default)(dateInput);
24
+ if (!parsed.isValid()) {
25
+ throw new Error(`Invalid date: ${dateInput}`); // fail fast in prod
26
+ }
27
+ return parsed.tz(tz).format(format);
16
28
  };
17
29
  exports.formatDate = formatDate;
18
30
  const interswitchRefundDateFormat = (dataString) => {
@@ -175,6 +175,7 @@ export interface TokenVerificationTemplateData extends EmailBase {
175
175
  export interface MerchantInvitationTemplateData extends EmailBase {
176
176
  merchant_name: string;
177
177
  to: string;
178
+ url?: string;
178
179
  }
179
180
  export interface CustomerWelcomeTemplateData extends EmailBase {
180
181
  first_name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",