@konplit-services/common 1.0.295 → 1.0.297
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/events/invoices-events/interfaces/invoice-payment-created.interface.d.ts +1 -0
- package/build/helper/payment-options.d.ts +4 -0
- package/build/helper/payment-options.js +6 -1
- package/build/helper/subscription-cron-expression.d.ts +1 -1
- package/build/helper/subscription-cron-expression.js +13 -20
- package/build/helper/subscriptions-types.d.ts +3 -0
- package/build/helper/subscriptions-types.js +3 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PaymentOptions = void 0;
|
|
3
|
+
exports.PaymentTypes = exports.PaymentOptions = void 0;
|
|
4
4
|
var PaymentOptions;
|
|
5
5
|
(function (PaymentOptions) {
|
|
6
6
|
PaymentOptions["card"] = "card";
|
|
@@ -10,3 +10,8 @@ var PaymentOptions;
|
|
|
10
10
|
PaymentOptions["transfer"] = "transfer";
|
|
11
11
|
PaymentOptions["opay"] = "opay";
|
|
12
12
|
})(PaymentOptions = exports.PaymentOptions || (exports.PaymentOptions = {}));
|
|
13
|
+
var PaymentTypes;
|
|
14
|
+
(function (PaymentTypes) {
|
|
15
|
+
PaymentTypes["subscription"] = "subscription";
|
|
16
|
+
PaymentTypes["payment"] = "payment";
|
|
17
|
+
})(PaymentTypes = exports.PaymentTypes || (exports.PaymentTypes = {}));
|
|
@@ -3,6 +3,6 @@ import { PLAN_INTERVAL } from "./plan-types";
|
|
|
3
3
|
* Generates a cron expression based on the current date and selected interval.
|
|
4
4
|
*
|
|
5
5
|
* @param {PLAN_INTERVAL} interval - The subscription interval.
|
|
6
|
-
* @returns {string} - The generated cron expression
|
|
6
|
+
* @returns {string} - The generated cron expression.
|
|
7
7
|
*/
|
|
8
8
|
export declare const generateCronExpression: (interval: PLAN_INTERVAL) => string;
|
|
@@ -12,61 +12,54 @@ dayjs_1.default.extend(utc_1.default);
|
|
|
12
12
|
* Generates a cron expression based on the current date and selected interval.
|
|
13
13
|
*
|
|
14
14
|
* @param {PLAN_INTERVAL} interval - The subscription interval.
|
|
15
|
-
* @returns {string} - The generated cron expression
|
|
15
|
+
* @returns {string} - The generated cron expression.
|
|
16
16
|
*/
|
|
17
17
|
const generateCronExpression = (interval) => {
|
|
18
18
|
const currentDate = (0, dayjs_1.default)().utc(); // Get current date in UTC
|
|
19
19
|
let cronExpression = "";
|
|
20
20
|
switch (interval) {
|
|
21
|
-
case plan_types_1.PLAN_INTERVAL.HOURLY:
|
|
22
|
-
// Run every hour at the same minute
|
|
23
|
-
cronExpression =
|
|
21
|
+
case plan_types_1.PLAN_INTERVAL.HOURLY:
|
|
22
|
+
// Run every hour at the same minute
|
|
23
|
+
cronExpression = `${currentDate.minute()} * * * *`;
|
|
24
24
|
break;
|
|
25
|
-
|
|
26
|
-
case plan_types_1.PLAN_INTERVAL.DAILY: {
|
|
25
|
+
case plan_types_1.PLAN_INTERVAL.DAILY:
|
|
27
26
|
// Run at the same time every day
|
|
28
|
-
cronExpression =
|
|
27
|
+
cronExpression = `${currentDate.minute()} ${currentDate.hour()} * * *`;
|
|
29
28
|
break;
|
|
30
|
-
|
|
31
|
-
case plan_types_1.PLAN_INTERVAL.WEEKLY: {
|
|
29
|
+
case plan_types_1.PLAN_INTERVAL.WEEKLY:
|
|
32
30
|
// Run at the same time, same day of the week
|
|
33
|
-
cronExpression =
|
|
31
|
+
cronExpression = `${currentDate.minute()} ${currentDate.hour()} * * ${currentDate.day()}`;
|
|
34
32
|
break;
|
|
35
|
-
}
|
|
36
33
|
case plan_types_1.PLAN_INTERVAL.MONTHLY: {
|
|
37
34
|
const dayOfMonth = currentDate.date();
|
|
38
|
-
// If day > 28, fallback to the 28th
|
|
39
35
|
const adjustedDay = dayOfMonth > 28 ? 28 : dayOfMonth;
|
|
40
36
|
// Run at the same time on the same day every month
|
|
41
|
-
cronExpression =
|
|
37
|
+
cronExpression = `${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} * *`;
|
|
42
38
|
break;
|
|
43
39
|
}
|
|
44
40
|
case plan_types_1.PLAN_INTERVAL.QUARTERLY: {
|
|
45
41
|
const dayOfMonth = currentDate.date();
|
|
46
|
-
// If day > 28, fallback to the 28th
|
|
47
42
|
const adjustedDay = dayOfMonth > 28 ? 28 : dayOfMonth;
|
|
48
43
|
// Every 3rd month
|
|
49
|
-
cronExpression =
|
|
44
|
+
cronExpression = `${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} */3 *`;
|
|
50
45
|
break;
|
|
51
46
|
}
|
|
52
47
|
case plan_types_1.PLAN_INTERVAL["6MONTHS"]: {
|
|
53
48
|
const dayOfMonth = currentDate.date();
|
|
54
|
-
// If day > 28, fallback to the 28th
|
|
55
49
|
const adjustedDay = dayOfMonth > 28 ? 28 : dayOfMonth;
|
|
56
50
|
// Every 6th month
|
|
57
|
-
cronExpression =
|
|
51
|
+
cronExpression = `${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} */6 *`;
|
|
58
52
|
break;
|
|
59
53
|
}
|
|
60
54
|
case plan_types_1.PLAN_INTERVAL.YEARLY: {
|
|
61
55
|
const dayOfMonth = currentDate.date();
|
|
62
|
-
// If day > 28, fallback to the 28th
|
|
63
56
|
const adjustedDay = dayOfMonth > 28 ? 28 : dayOfMonth;
|
|
64
57
|
// Run at the same time, same day, same month every year
|
|
65
|
-
cronExpression =
|
|
58
|
+
cronExpression = `${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} ${currentDate.month() + 1} *`;
|
|
66
59
|
break;
|
|
67
60
|
}
|
|
68
61
|
default:
|
|
69
|
-
throw new Error(
|
|
62
|
+
throw new Error(`Invalid interval for generating cron expression: ${interval}`);
|
|
70
63
|
}
|
|
71
64
|
return cronExpression;
|
|
72
65
|
};
|
|
@@ -9,6 +9,9 @@ var SUBSCRIPTION_TYPES;
|
|
|
9
9
|
var SUBSCRIPTION_STATUS;
|
|
10
10
|
(function (SUBSCRIPTION_STATUS) {
|
|
11
11
|
SUBSCRIPTION_STATUS["PENDING"] = "PENDING";
|
|
12
|
+
SUBSCRIPTION_STATUS["ACTIVE"] = "ACTIVE";
|
|
13
|
+
SUBSCRIPTION_STATUS["INACTIVE"] = "INACTIVE";
|
|
14
|
+
SUBSCRIPTION_STATUS["TRIAL"] = "TRIAL";
|
|
12
15
|
SUBSCRIPTION_STATUS["COMPLETED"] = "COMPLETED";
|
|
13
16
|
SUBSCRIPTION_STATUS["SUCCESS"] = "SUCCESS";
|
|
14
17
|
SUBSCRIPTION_STATUS["CANCELLED"] = "CANCELLED";
|