@konplit-services/common 1.0.296 → 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.
@@ -6,3 +6,7 @@ export declare enum PaymentOptions {
6
6
  transfer = "transfer",
7
7
  opay = "opay"
8
8
  }
9
+ export declare enum PaymentTypes {
10
+ subscription = "subscription",
11
+ payment = "payment"
12
+ }
@@ -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 with seconds.
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 with seconds.
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 and second
23
- cronExpression = `0 ${currentDate.minute()} * * * *`;
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 = `0 ${currentDate.minute()} ${currentDate.hour()} * * *`;
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 = `0 ${currentDate.minute()} ${currentDate.hour()} * * ${currentDate.day()}`;
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 = `0 ${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} * *`;
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 = `0 ${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} */3 *`;
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 = `0 ${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} */6 *`;
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 = `0 ${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} ${currentDate.month() + 1} *`;
58
+ cronExpression = `${currentDate.minute()} ${currentDate.hour()} ${adjustedDay} ${currentDate.month() + 1} *`;
66
59
  break;
67
60
  }
68
61
  default:
69
- throw new Error("Invalid interval for generating cron expression");
62
+ throw new Error(`Invalid interval for generating cron expression: ${interval}`);
70
63
  }
71
64
  return cronExpression;
72
65
  };
@@ -4,6 +4,9 @@ export declare enum SUBSCRIPTION_TYPES {
4
4
  }
5
5
  export declare enum SUBSCRIPTION_STATUS {
6
6
  PENDING = "PENDING",
7
+ ACTIVE = "ACTIVE",
8
+ "INACTIVE" = "INACTIVE",
9
+ "TRIAL" = "TRIAL",
7
10
  COMPLETED = "COMPLETED",
8
11
  SUCCESS = "SUCCESS",
9
12
  CANCELLED = "CANCELLED",
@@ -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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.296",
3
+ "version": "1.0.297",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",