@hastehaul/common 1.0.21 → 1.0.24

Sign up to get free protection for your applications and to get access to all the features.
package/build/index.d.ts CHANGED
@@ -87,6 +87,7 @@ export * from "./utils/enums";
87
87
  export * from "./utils/read-dir";
88
88
  export * from "./utils/schemas";
89
89
  export * from "./utils/random-codes";
90
+ export * from "./utils/utils";
90
91
  /**
91
92
  *? Re-exports all the contents from the "base-producers" module.
92
93
  *
package/build/index.js CHANGED
@@ -115,6 +115,7 @@ __exportStar(require("./utils/read-dir"), exports);
115
115
  __exportStar(require("./utils/schemas"), exports);
116
116
  //TODO: DOCUMENT
117
117
  __exportStar(require("./utils/random-codes"), exports);
118
+ __exportStar(require("./utils/utils"), exports);
118
119
  /**
119
120
  *? Re-exports all the contents from the "base-producers" module.
120
121
  *
@@ -14,8 +14,17 @@ export declare enum Status {
14
14
  DELETED = "deleted",
15
15
  EXPIRED = "expired",
16
16
  BLOCKED = "blocked",
17
- SUSPENDED = "suspended",
18
- VACATION = "vacation"
17
+ SUSPENDED = "suspended"
18
+ }
19
+ export declare enum SmsStatus {
20
+ SMS_PENDING = "sms-pending",
21
+ SMS_FAILED = "sms-failed",
22
+ SMS_SENT = "sms-sent"
23
+ }
24
+ export declare enum OtpStatus {
25
+ OTP_INCORRECT = "otp-incorrect",
26
+ OTP_EXPIRED = "otp-expired",
27
+ OTP_VERIFIED = "otp-verified"
19
28
  }
20
29
  export declare enum StatusCodes {
21
30
  CONTINUE = 100,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StatusCodes = exports.Status = exports.Events = void 0;
3
+ exports.StatusCodes = exports.OtpStatus = exports.SmsStatus = exports.Status = exports.Events = void 0;
4
+ // Enum that defines various event types
4
5
  var Events;
5
6
  (function (Events) {
6
7
  Events["CHARGE_SUCCESS"] = "charge.success";
@@ -8,8 +9,9 @@ var Events;
8
9
  Events["TRANSFER_FAILED"] = "transfer.failed";
9
10
  Events["TRANSFER_REVERSED"] = "transfer.reversed";
10
11
  Events["PAYMENT_REQUEST_PENDING"] = "paymentrequest.pending";
11
- Events["PAYMENT_REQUEST_SUCCESS"] = "paymentrequest.success";
12
+ Events["PAYMENT_REQUEST_SUCCESS"] = "paymentrequest.success"; // Payment request was successful
12
13
  })(Events || (exports.Events = Events = {}));
14
+ // Enum that defines various status values
13
15
  var Status;
14
16
  (function (Status) {
15
17
  Status["NEW"] = "new";
@@ -20,8 +22,21 @@ var Status;
20
22
  Status["EXPIRED"] = "expired";
21
23
  Status["BLOCKED"] = "blocked";
22
24
  Status["SUSPENDED"] = "suspended";
23
- Status["VACATION"] = "vacation";
24
25
  })(Status || (exports.Status = Status = {}));
26
+ // Enum that defines various SMS status values
27
+ var SmsStatus;
28
+ (function (SmsStatus) {
29
+ SmsStatus["SMS_PENDING"] = "sms-pending";
30
+ SmsStatus["SMS_FAILED"] = "sms-failed";
31
+ SmsStatus["SMS_SENT"] = "sms-sent"; // SMS was successfully sent
32
+ })(SmsStatus || (exports.SmsStatus = SmsStatus = {}));
33
+ // Enum that defines various OTP (One-Time Password) status values
34
+ var OtpStatus;
35
+ (function (OtpStatus) {
36
+ OtpStatus["OTP_INCORRECT"] = "otp-incorrect";
37
+ OtpStatus["OTP_EXPIRED"] = "otp-expired";
38
+ OtpStatus["OTP_VERIFIED"] = "otp-verified"; // OTP was successfully verified
39
+ })(OtpStatus || (exports.OtpStatus = OtpStatus = {}));
25
40
  var StatusCodes;
26
41
  (function (StatusCodes) {
27
42
  StatusCodes[StatusCodes["CONTINUE"] = 100] = "CONTINUE";
@@ -0,0 +1,2 @@
1
+ export declare function hasElapsed(expirationDate: Date): boolean;
2
+ export declare function colorize(text: string, colorCode: number): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.colorize = exports.hasElapsed = void 0;
7
+ const moment_1 = __importDefault(require("moment"));
8
+ function hasElapsed(expirationDate) {
9
+ const currentDate = (0, moment_1.default)();
10
+ const targetDate = (0, moment_1.default)(expirationDate);
11
+ return targetDate.isBefore(currentDate);
12
+ }
13
+ exports.hasElapsed = hasElapsed;
14
+ // Function to add color to console logs
15
+ function colorize(text, colorCode) {
16
+ return `\x1b[${colorCode}m${text}\x1b[0m`;
17
+ }
18
+ exports.colorize = colorize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,6 +28,7 @@
28
28
  "express": "^4.18.2",
29
29
  "ioredis": "^5.3.2",
30
30
  "jsonwebtoken": "^9.0.1",
31
+ "moment": "^2.29.4",
31
32
  "nats": "^2.15.1",
32
33
  "socket.io": "^4.7.1"
33
34
  }