@konplit-services/common 1.26.0 → 1.27.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.
package/build/app.configs.d.ts
CHANGED
|
@@ -159,6 +159,12 @@ interface InterswitchTransfer {
|
|
|
159
159
|
terminalId: string;
|
|
160
160
|
initiatingEntity: string;
|
|
161
161
|
}
|
|
162
|
+
export interface InterswitchDispute {
|
|
163
|
+
base_url: string;
|
|
164
|
+
client_id: string;
|
|
165
|
+
secret_key: string;
|
|
166
|
+
access_token_url: string;
|
|
167
|
+
}
|
|
162
168
|
interface Opay {
|
|
163
169
|
publicKey: string;
|
|
164
170
|
secretKey: string;
|
|
@@ -357,6 +363,7 @@ declare class AppConfigs {
|
|
|
357
363
|
};
|
|
358
364
|
getInterswitchDetails(): Interswitch;
|
|
359
365
|
getInterswitchTransferDetails(): InterswitchTransfer;
|
|
366
|
+
getInterswitchDisputeDetails(): InterswitchDispute;
|
|
360
367
|
getValuPayTransferSenderDetails(): ValuePaySenderTransfer;
|
|
361
368
|
getTransactionSetting(merchantId?: string): {
|
|
362
369
|
dailyLimitKey: string;
|
package/build/app.configs.js
CHANGED
|
@@ -871,6 +871,26 @@ class AppConfigs {
|
|
|
871
871
|
initiatingEntity: this.env.INTERSWITCH_TRANSFER_INITIATING_ENTITY,
|
|
872
872
|
};
|
|
873
873
|
}
|
|
874
|
+
getInterswitchDisputeDetails() {
|
|
875
|
+
if (!this.env.INTERSWITCH_DISPUTE_BASE_URL) {
|
|
876
|
+
throw new Error("INTERSWITCH_DISPUTE_BASE_URL is required");
|
|
877
|
+
}
|
|
878
|
+
if (!this.env.INTERSWITCH_DISPUTE_CLIENT_ID) {
|
|
879
|
+
throw new Error("INTERSWITCH_DISPUTE_CLIENT_ID is required");
|
|
880
|
+
}
|
|
881
|
+
if (!this.env.INTERSWITCH_DISPUTE_SECRET_KEY) {
|
|
882
|
+
throw new Error("INTERSWITCH_DISPUTE_SECRET_KEY is required");
|
|
883
|
+
}
|
|
884
|
+
if (!this.env.INTERSWITCH_ACCESS_TOKEN_URL) {
|
|
885
|
+
throw new Error("INTERSWITCH_ACCESS_TOKEN_URL is required");
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
base_url: this.env.INTERSWITCH_DISPUTE_BASE_URL,
|
|
889
|
+
client_id: this.env.INTERSWITCH_DISPUTE_CLIENT_ID,
|
|
890
|
+
secret_key: this.env.INTERSWITCH_DISPUTE_SECRET_KEY,
|
|
891
|
+
access_token_url: this.env.INTERSWITCH_ACCESS_TOKEN_URL,
|
|
892
|
+
};
|
|
893
|
+
}
|
|
874
894
|
// VALUEPAY
|
|
875
895
|
getValuPayTransferSenderDetails() {
|
|
876
896
|
if (!this.env.VALUEPAY_TRANSFER_SENDER_LASTNAME) {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
1
2
|
import { PLAN_INTERVAL } from "./plan-types";
|
|
3
|
+
type Period = "day" | "week" | "month" | "year";
|
|
4
|
+
interface DateRange {
|
|
5
|
+
startOfPeriod: Date;
|
|
6
|
+
endOfPeriod: Date;
|
|
7
|
+
}
|
|
2
8
|
export declare const formatDate: (dateInput: string | Date | number, // support more input types
|
|
3
9
|
format?: string, tz?: string) => string;
|
|
4
10
|
export declare const interswitchRefundDateFormat: (dataString: string) => string;
|
|
@@ -12,10 +18,15 @@ export declare const getCurrentDayRange: () => {
|
|
|
12
18
|
startOfCurrentDay: Date;
|
|
13
19
|
endOfCurrentDay: Date;
|
|
14
20
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Returns the start and end of a given period for the provided date
|
|
23
|
+
*
|
|
24
|
+
* @param date - Input date (string, Date, or dayjs object)
|
|
25
|
+
* @param period - The time period to calculate range for ("day" | "week" | "month" | "year")
|
|
26
|
+
* @param timezone - Optional timezone (defaults to Africa/Lagos)
|
|
27
|
+
* @returns Object containing startOfPeriod and endOfPeriod as native Date objects (in UTC)
|
|
28
|
+
*/
|
|
29
|
+
export declare const getStartAndEndOfPeriod: (date: string | Date | dayjs.Dayjs, period?: Period, tz?: string) => DateRange;
|
|
19
30
|
export declare const isTodayOrFuture: (dateInput: string | Date) => boolean;
|
|
20
31
|
export declare const convertDateToUTCRangeString: (startDateTime: string, endDateTime: string) => {
|
|
21
32
|
startUTC: string;
|
|
@@ -3,18 +3,18 @@ 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.calculateDelay = exports.getFutureDateFromPlan = exports.getDuration = exports.convertDateToUTC = exports.convertDateToUTCString = exports.convertDateToUTCRange = exports.convertDateToUTCRangeString = exports.isTodayOrFuture = exports.
|
|
6
|
+
exports.calculateDelay = exports.getFutureDateFromPlan = exports.getDuration = exports.convertDateToUTC = exports.convertDateToUTCString = exports.convertDateToUTCRange = exports.convertDateToUTCRangeString = exports.isTodayOrFuture = exports.getStartAndEndOfPeriod = exports.getCurrentDayRange = exports.getPreviousDayRange = exports.convertToDate = exports.formatDateTime = exports.interswitchRefundDateFormat = exports.formatDate = void 0;
|
|
7
7
|
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
11
|
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
12
|
+
const plan_types_1 = require("./plan-types");
|
|
12
13
|
// Extend dayjs with the UTC plugin
|
|
13
14
|
dayjs_1.default.extend(utc_1.default);
|
|
14
15
|
dayjs_1.default.extend(timezone_1.default);
|
|
15
16
|
const DEFAULT_TZ = "Africa/Lagos";
|
|
16
17
|
const DEFAULT_FORMAT = "YYYY-MM-DD";
|
|
17
|
-
const plan_types_1 = require("./plan-types");
|
|
18
18
|
const formatDate = (dateInput, // support more input types
|
|
19
19
|
format = DEFAULT_FORMAT, tz = DEFAULT_TZ) => {
|
|
20
20
|
if (!dateInput) {
|
|
@@ -59,15 +59,49 @@ const getCurrentDayRange = () => {
|
|
|
59
59
|
return { startOfCurrentDay, endOfCurrentDay };
|
|
60
60
|
};
|
|
61
61
|
exports.getCurrentDayRange = getCurrentDayRange;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Returns the start and end of a given period for the provided date
|
|
64
|
+
*
|
|
65
|
+
* @param date - Input date (string, Date, or dayjs object)
|
|
66
|
+
* @param period - The time period to calculate range for ("day" | "week" | "month" | "year")
|
|
67
|
+
* @param timezone - Optional timezone (defaults to Africa/Lagos)
|
|
68
|
+
* @returns Object containing startOfPeriod and endOfPeriod as native Date objects (in UTC)
|
|
69
|
+
*/
|
|
70
|
+
const getStartAndEndOfPeriod = (date, period = "day", tz = DEFAULT_TZ) => {
|
|
71
|
+
// Normalize input to dayjs object in the target timezone
|
|
72
|
+
const inputDate = (0, dayjs_1.default)(date).tz(tz);
|
|
73
|
+
let start;
|
|
74
|
+
let end;
|
|
75
|
+
switch (period) {
|
|
76
|
+
case "day":
|
|
77
|
+
start = inputDate.startOf("day");
|
|
78
|
+
end = inputDate.endOf("day");
|
|
79
|
+
break;
|
|
80
|
+
case "week":
|
|
81
|
+
// Most common: week starts on Monday in many African/business contexts
|
|
82
|
+
// but we are using Sunday start → but can be changed to isoWeek
|
|
83
|
+
start = inputDate.startOf("week");
|
|
84
|
+
end = inputDate.endOf("week");
|
|
85
|
+
break;
|
|
86
|
+
case "month":
|
|
87
|
+
start = inputDate.startOf("month");
|
|
88
|
+
end = inputDate.endOf("month");
|
|
89
|
+
break;
|
|
90
|
+
case "year":
|
|
91
|
+
start = inputDate.startOf("year");
|
|
92
|
+
end = inputDate.endOf("year");
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
// This should never happen with TypeScript + union type, but good safety net
|
|
96
|
+
throw new Error(`Unsupported period: ${period}`);
|
|
97
|
+
}
|
|
98
|
+
// Return as UTC Dates (most backend systems & databases expect UTC)
|
|
99
|
+
return {
|
|
100
|
+
startOfPeriod: start.utc().toDate(),
|
|
101
|
+
endOfPeriod: end.utc().toDate(),
|
|
102
|
+
};
|
|
69
103
|
};
|
|
70
|
-
exports.
|
|
104
|
+
exports.getStartAndEndOfPeriod = getStartAndEndOfPeriod;
|
|
71
105
|
const isTodayOrFuture = (dateInput) => {
|
|
72
106
|
const input = dayjs_1.default.utc(dateInput);
|
|
73
107
|
if (!input.isValid())
|