@hastehaul/common 2.4.0 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,8 +42,8 @@ class RedisWrapper {
42
42
  * @param {string} host - The Redis server host address (default is "customer-redis-srv").
43
43
  * @param {number} port - The Redis server port number (default is 6379).
44
44
  */
45
- connect(host, port, useSentinel = false) {
46
- return __awaiter(this, void 0, void 0, function* () {
45
+ connect(host_1, port_1) {
46
+ return __awaiter(this, arguments, void 0, function* (host, port, useSentinel = false) {
47
47
  return new Promise((resolve, reject) => {
48
48
  this._redisClient = useSentinel
49
49
  ? new ioredis_1.default({
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import http from "http";
3
2
  import { Server } from 'socket.io';
4
3
  /**
@@ -64,8 +64,8 @@ class NatsConsumer {
64
64
  * Messages are processed asynchronously up to the maximum concurrent limit.
65
65
  */
66
66
  consume() {
67
- var _a, e_1, _b, _c;
68
67
  return __awaiter(this, void 0, void 0, function* () {
68
+ var _a, e_1, _b, _c;
69
69
  console.log(this.stream, this.durableName, this.subject);
70
70
  try {
71
71
  const jsm = yield this.client.jetstreamManager();
@@ -9,7 +9,7 @@ export declare abstract class AbstractWorker {
9
9
  *
10
10
  * @param {string} queueName - The name of the job queue that this worker will process jobs from.
11
11
  */
12
- constructor(queueName: string, useReplicas?: boolean);
12
+ constructor(queueName: string, useReplicas?: boolean, opts?: WorkerOptions | undefined);
13
13
  /**
14
14
  * Abstract method to process jobs retrieved from the job queue.
15
15
  *
@@ -13,13 +13,9 @@ class AbstractWorker {
13
13
  *
14
14
  * @param {string} queueName - The name of the job queue that this worker will process jobs from.
15
15
  */
16
- constructor(queueName, useReplicas = true) {
16
+ constructor(queueName, useReplicas = true, opts) {
17
17
  // Create a worker instance with the provided queueName and bind the 'process' method to this worker.
18
- this.worker = new bullmq_1.Worker(queueName, this.process.bind(this), {
19
- connection: useReplicas ? redis_wrapper_1.rWrapper.masterClient : redis_connection_wrapper_1.redisWrapper.client,
20
- autorun: false,
21
- prefix: '{BULLMQ}',
22
- });
18
+ this.worker = new bullmq_1.Worker(queueName, this.process.bind(this), Object.assign({ connection: useReplicas ? redis_wrapper_1.rWrapper.masterClient : redis_connection_wrapper_1.redisWrapper.client, autorun: false, prefix: '{BULLMQ}' }, opts));
23
19
  // Handle errors that may occur during job processing.
24
20
  this.worker.on("error", (err) => {
25
21
  console.error(`${queueName} Error: `, err);
@@ -1,49 +1,49 @@
1
1
  export declare enum Events {
2
- CHARGE_SUCCESS = "charge.success",
3
- TRANSFER_SUCCESS = "transfer.success",
4
- TRANSFER_FAILED = "transfer.failed",
5
- TRANSFER_REVERSED = "transfer.reversed",
6
- PAYMENT_REQUEST_PENDING = "paymentrequest.pending",
2
+ CHARGE_SUCCESS = "charge.success",// Charge was successful
3
+ TRANSFER_SUCCESS = "transfer.success",// Transfer was successful
4
+ TRANSFER_FAILED = "transfer.failed",// Transfer attempt failed
5
+ TRANSFER_REVERSED = "transfer.reversed",// A completed transfer was reversed
6
+ PAYMENT_REQUEST_PENDING = "paymentrequest.pending",// Payment request is pending
7
7
  PAYMENT_REQUEST_SUCCESS = "paymentrequest.success"
8
8
  }
9
9
  export declare enum Status {
10
- NEW = "new",
11
- PENDING = "pending",
12
- SUCCESS = "success",
13
- ACTIVE = "active",
14
- DELETED = "deleted",
15
- EXPIRED = "expired",
16
- BLOCKED = "blocked",
10
+ NEW = "new",// New item or entity
11
+ PENDING = "pending",// Awaiting processing or action
12
+ SUCCESS = "success",// Successful completion
13
+ ACTIVE = "active",// Currently active or operational
14
+ DELETED = "deleted",// Deleted or removed
15
+ EXPIRED = "expired",// Expired or no longer valid
16
+ BLOCKED = "blocked",// Blocked from use
17
17
  SUSPENDED = "suspended"
18
18
  }
19
19
  export declare enum SmsStatus {
20
- SMS_PENDING = "sms-pending",
21
- SMS_FAILED = "sms-failed",
20
+ SMS_PENDING = "sms-pending",// SMS is awaiting delivery
21
+ SMS_FAILED = "sms-failed",// SMS delivery attempt failed
22
22
  SMS_SENT = "sms-sent"
23
23
  }
24
24
  export declare enum OtpStatus {
25
- OTP_INCORRECT = "otp-incorrect",
26
- OTP_EXPIRED = "otp-expired",
25
+ OTP_INCORRECT = "otp-incorrect",// OTP provided was incorrect
26
+ OTP_EXPIRED = "otp-expired",// OTP has expired
27
27
  OTP_VERIFIED = "otp-verified"
28
28
  }
29
29
  export declare enum AccountStatus {
30
- AccountBlocked = 5000,
31
- AccountSuspendedTimeNotElapsed = 5001,
32
- AccountSuspendedTimeElapsed = 5002,
33
- OTPVerifiedAllowAccessAccountActive = 2000,
34
- TokenRefreshSuccess = 2001,
35
- NotNewCustomer = 2100,
36
- IsNewCustomer = 2101,
37
- NotAllowedToPerformAction = 2201,
38
- DefaultBadRequestError = 2301,
39
- Default2302 = 2302,
40
- DefaultDatabaseError = 2303,
41
- NotAuthorized = 2304,
42
- DefaultNotFoundError = 2305,
43
- ResourceNotFoundError = 2306,
44
- SystemError = 2307,
45
- TooManyRequestError = 2308,
46
- IncorrectOrNotFoundOTP = 2400,
30
+ AccountBlocked = 5000,// 5000 => Account blocked
31
+ AccountSuspendedTimeNotElapsed = 5001,// 5001 => Account Suspended => time not elapsed
32
+ AccountSuspendedTimeElapsed = 5002,// 5002 => Account Suspended => time elapsed
33
+ OTPVerifiedAllowAccessAccountActive = 2000,// 2000 => OTP verified Allow Access / Account Active
34
+ TokenRefreshSuccess = 2001,// 2001 => Token Refresh Success
35
+ NotNewCustomer = 2100,// 2100 => SMS Pending => Not a new customer
36
+ IsNewCustomer = 2101,// 2101 => SMS Pending => Is a new customer
37
+ NotAllowedToPerformAction = 2201,// 2201 => not allowed to perform this action
38
+ DefaultBadRequestError = 2301,// 2301 => default badRequestError
39
+ Default2302 = 2302,// 2302 => default
40
+ DefaultDatabaseError = 2303,// 2303 => default databaseError
41
+ NotAuthorized = 2304,// 2304 => Not Authorized
42
+ DefaultNotFoundError = 2305,// 2305 => default Not found Error
43
+ ResourceNotFoundError = 2306,// 2306 => Resource not found Error
44
+ SystemError = 2307,// 2307 => System Error
45
+ TooManyRequestError = 2308,// 2308 => Too Many request error
46
+ IncorrectOrNotFoundOTP = 2400,// 2400 => Incorrect/Not Found OTP
47
47
  OTPExpired = 2401
48
48
  }
49
49
  export declare enum StatusCodes {
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.generateRandomCodesAsync = void 0;
12
+ exports.generateRandomCodesAsync = generateRandomCodesAsync;
13
13
  /**
14
14
  * Generates random codes as an async function using await.
15
15
  *
@@ -54,4 +54,3 @@ function generateRandomCodesAsync(characters, numberOfCodes, codeSize, includeHy
54
54
  return codes;
55
55
  });
56
56
  }
57
- exports.generateRandomCodesAsync = generateRandomCodesAsync;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.readDirectoryRecursive = void 0;
15
+ exports.readDirectoryRecursive = readDirectoryRecursive;
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  /**
@@ -38,4 +38,3 @@ function readDirectoryRecursive(dirPath, filter) {
38
38
  return files;
39
39
  });
40
40
  }
41
- exports.readDirectoryRecursive = readDirectoryRecursive;
@@ -3,28 +3,28 @@ 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.getValueFromSettings = exports.generateIdentifier = exports.formatDatetimeToHumanReadable = exports.colorize = exports.hasElapsed = void 0;
6
+ exports.hasElapsed = hasElapsed;
7
+ exports.colorize = colorize;
8
+ exports.formatDatetimeToHumanReadable = formatDatetimeToHumanReadable;
9
+ exports.generateIdentifier = generateIdentifier;
10
+ exports.getValueFromSettings = getValueFromSettings;
7
11
  const moment_1 = __importDefault(require("moment"));
8
12
  function hasElapsed(expirationDate) {
9
13
  const currentDate = (0, moment_1.default)();
10
14
  const targetDate = (0, moment_1.default)(expirationDate);
11
15
  return targetDate.isBefore(currentDate);
12
16
  }
13
- exports.hasElapsed = hasElapsed;
14
17
  // Function to add color to console logs
15
18
  function colorize(text, colorCode) {
16
19
  return `\x1b[${colorCode}m${text}\x1b[0m`;
17
20
  }
18
- exports.colorize = colorize;
19
21
  function formatDatetimeToHumanReadable(datetime, format) {
20
22
  return (0, moment_1.default)(datetime).format(format || 'MMMM D, YYYY h:mm A');
21
23
  }
22
- exports.formatDatetimeToHumanReadable = formatDatetimeToHumanReadable;
23
24
  function generateIdentifier(messageContent) {
24
25
  // You can use any hash function or strategy that suits your needs
25
26
  return Buffer.from(messageContent).toString('base64');
26
27
  }
27
- exports.generateIdentifier = generateIdentifier;
28
28
  function getValueFromSettings(settings, key, envVar, defaultValue) {
29
29
  if (settings.length > 0) {
30
30
  const setting = settings.find(item => item.key === key);
@@ -33,4 +33,3 @@ function getValueFromSettings(settings, key, envVar, defaultValue) {
33
33
  }
34
34
  return process.env[envVar] || defaultValue;
35
35
  }
36
- exports.getValueFromSettings = getValueFromSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "2.4.0",
3
+ "version": "2.4.3",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@vsky/accesscontrol": "^3.0.14",
29
- "bullmq": "^4.6.3",
29
+ "bullmq": "^4.13.0",
30
30
  "express": "^4.18.2",
31
31
  "ioredis": "^5.3.2",
32
32
  "jsonwebtoken": "^9.0.1",