@hastehaul/common 2.4.1 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- package/build/connections-wrappers/redis-connection-wrapper.js +2 -2
- package/build/connections-wrappers/socket-connection-wrapper.d.ts +0 -1
- package/build/events/base/base-consumer.js +1 -1
- package/build/utils/enums.d.ts +33 -33
- package/build/utils/random-codes.js +1 -2
- package/build/utils/read-dir.js +1 -2
- package/build/utils/utils.js +5 -6
- package/package.json +2 -2
@@ -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(
|
46
|
-
return __awaiter(this,
|
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({
|
@@ -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();
|
package/build/utils/enums.d.ts
CHANGED
@@ -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 =
|
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;
|
package/build/utils/read-dir.js
CHANGED
@@ -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 =
|
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;
|
package/build/utils/utils.js
CHANGED
@@ -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.
|
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.
|
3
|
+
"version": "2.4.4",
|
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": "^
|
29
|
+
"bullmq": "^5.8.3",
|
30
30
|
"express": "^4.18.2",
|
31
31
|
"ioredis": "^5.3.2",
|
32
32
|
"jsonwebtoken": "^9.0.1",
|