vr-commons 1.0.114 → 1.0.115
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/dist/utils/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { canModerate, canModerateUser, getModeratableRoles, hasHigherAuthority,
|
|
|
7
7
|
export { banUtil } from "./bans.utils";
|
|
8
8
|
export { suspensionUtil } from "./suspension.utils";
|
|
9
9
|
export { createDeviceSession } from "./session.utils";
|
|
10
|
-
export { generateOTP, getOTPExpiry, getVerificationMethod, sendEmail, sendSMS, sendVerificationCode, } from "./verification.utils";
|
|
10
|
+
export { generateOTP, getOTPExpiry, getVerificationMethod, sendEmail, sendSMS, sendVerificationCode, detectContactType, validateContactValue, } from "./verification.utils";
|
|
11
11
|
export { getUserLevel, isRankEqual, isSubordinate, isSubordinateOrEqual, isSuperior, isSuperiorOrEqual, validateHierarchy, } from "./hierarchy.utils";
|
|
12
12
|
export { stockUtil } from "./admin.device.utils";
|
|
13
13
|
export { cloudinaryUtil } from "./product.utils";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.buildUserSearchConditions = exports.buildSearchConditions = exports.buildEventLogWhereClause = exports.formatEventLogs = exports.formatEventLog = exports.formatDeviceSession = exports.DPP_OperationsUtil = exports.cloudinaryUtil = exports.stockUtil = exports.validateHierarchy = exports.isSuperiorOrEqual = exports.isSuperior = exports.isSubordinateOrEqual = exports.isSubordinate = void 0;
|
|
3
|
+
exports.validateContactValue = exports.detectContactType = exports.sendVerificationCode = exports.sendSMS = exports.sendEmail = exports.getVerificationMethod = exports.getOTPExpiry = exports.generateOTP = exports.createDeviceSession = exports.suspensionUtil = exports.banUtil = exports.hasHigherAuthority = exports.getModeratableRoles = exports.canModerateUser = exports.canModerate = exports.softDeleteUser = exports.hashPassword = exports.validatePassword = exports.validateUniqueFields = exports.generateJacketId = exports.getSortOrder = exports.generateEventSearchConditions = exports.generateUserSearchConditions = exports.findSecurityClearanceByRole = exports.getUsersByRole = exports.getUserById = exports.isAccountAccessible = exports.canModifyAccount = exports.hasAllPermissions = exports.hasAnyPermission = exports.hasPermission = exports.hasRole = exports.formatUserListResponse = exports.formatUserProfile = exports.sendErrorResponse = exports.sendSuccessResponse = exports.logEvent = exports.formatTimeRemaining = exports.getTokenTimeRemaining = exports.generateToken = exports.shouldRefreshToken = exports.verifyToken = exports.generateRiderToken = exports.generatePassengerToken = exports.generateAdminToken = exports.checkSuspensionStatus = exports.checkIsUserBannedOrSuspended = exports.checkBanStatus = exports.hasActiveDependencies = exports.checkAccountDependencies = void 0;
|
|
4
|
+
exports.buildUserSearchConditions = exports.buildSearchConditions = exports.buildEventLogWhereClause = exports.formatEventLogs = exports.formatEventLog = exports.formatDeviceSession = exports.DPP_OperationsUtil = exports.cloudinaryUtil = exports.stockUtil = exports.validateHierarchy = exports.isSuperiorOrEqual = exports.isSuperior = exports.isSubordinateOrEqual = exports.isSubordinate = exports.isRankEqual = exports.getUserLevel = void 0;
|
|
5
5
|
var account_utils_1 = require("./account.utils");
|
|
6
6
|
Object.defineProperty(exports, "checkAccountDependencies", { enumerable: true, get: function () { return account_utils_1.checkAccountDependencies; } });
|
|
7
7
|
Object.defineProperty(exports, "hasActiveDependencies", { enumerable: true, get: function () { return account_utils_1.hasActiveDependencies; } });
|
|
@@ -67,6 +67,8 @@ Object.defineProperty(exports, "getVerificationMethod", { enumerable: true, get:
|
|
|
67
67
|
Object.defineProperty(exports, "sendEmail", { enumerable: true, get: function () { return verification_utils_1.sendEmail; } });
|
|
68
68
|
Object.defineProperty(exports, "sendSMS", { enumerable: true, get: function () { return verification_utils_1.sendSMS; } });
|
|
69
69
|
Object.defineProperty(exports, "sendVerificationCode", { enumerable: true, get: function () { return verification_utils_1.sendVerificationCode; } });
|
|
70
|
+
Object.defineProperty(exports, "detectContactType", { enumerable: true, get: function () { return verification_utils_1.detectContactType; } });
|
|
71
|
+
Object.defineProperty(exports, "validateContactValue", { enumerable: true, get: function () { return verification_utils_1.validateContactValue; } });
|
|
70
72
|
var hierarchy_utils_1 = require("./hierarchy.utils");
|
|
71
73
|
Object.defineProperty(exports, "getUserLevel", { enumerable: true, get: function () { return hierarchy_utils_1.getUserLevel; } });
|
|
72
74
|
Object.defineProperty(exports, "isRankEqual", { enumerable: true, get: function () { return hierarchy_utils_1.isRankEqual; } });
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { VerificationMethod } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Regular expressions for contact validation
|
|
4
|
+
*/
|
|
5
|
+
export declare const phoneRegex: RegExp;
|
|
6
|
+
export declare const emailRegex: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* Detect the type of contact value
|
|
9
|
+
* @param value - The contact value to check (email or phone number)
|
|
10
|
+
* @returns The contact type: 'EMAIL', 'PHONE', 'WHATSAPP', or 'UNKNOWN'
|
|
11
|
+
*/
|
|
12
|
+
export declare const detectContactType: (value: string) => "EMAIL" | "PHONE" | "WHATSAPP" | "UNKNOWN";
|
|
13
|
+
/**
|
|
14
|
+
* Validate if a contact value is valid (either email or phone)
|
|
15
|
+
* @param value - The contact value to validate
|
|
16
|
+
* @returns True if valid email or phone, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare const validateContactValue: (value: string) => boolean;
|
|
2
19
|
export declare const getVerificationMethod: () => VerificationMethod;
|
|
3
20
|
export declare const generateOTP: (length?: number) => string;
|
|
4
21
|
export declare const getOTPExpiry: (minutes?: number) => Date;
|
|
@@ -3,8 +3,44 @@ 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.sendVerificationCode = exports.sendEmail = exports.sendSMS = exports.getOTPExpiry = exports.generateOTP = exports.getVerificationMethod = void 0;
|
|
6
|
+
exports.sendVerificationCode = exports.sendEmail = exports.sendSMS = exports.getOTPExpiry = exports.generateOTP = exports.getVerificationMethod = exports.validateContactValue = exports.detectContactType = exports.emailRegex = exports.phoneRegex = void 0;
|
|
7
7
|
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
8
|
+
// ==================== CONTACT VALIDATION HELPERS ====================
|
|
9
|
+
/**
|
|
10
|
+
* Regular expressions for contact validation
|
|
11
|
+
*/
|
|
12
|
+
exports.phoneRegex = /^\+250(78|79|73|72)[0-9]{7}$/;
|
|
13
|
+
exports.emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
14
|
+
/**
|
|
15
|
+
* Detect the type of contact value
|
|
16
|
+
* @param value - The contact value to check (email or phone number)
|
|
17
|
+
* @returns The contact type: 'EMAIL', 'PHONE', 'WHATSAPP', or 'UNKNOWN'
|
|
18
|
+
*/
|
|
19
|
+
const detectContactType = (value) => {
|
|
20
|
+
if (!value)
|
|
21
|
+
return "UNKNOWN";
|
|
22
|
+
// Check if it's an email
|
|
23
|
+
if (exports.emailRegex.test(value)) {
|
|
24
|
+
return "EMAIL";
|
|
25
|
+
}
|
|
26
|
+
// Check if it's a phone number
|
|
27
|
+
if (exports.phoneRegex.test(value)) {
|
|
28
|
+
return "PHONE";
|
|
29
|
+
}
|
|
30
|
+
return "UNKNOWN";
|
|
31
|
+
};
|
|
32
|
+
exports.detectContactType = detectContactType;
|
|
33
|
+
/**
|
|
34
|
+
* Validate if a contact value is valid (either email or phone)
|
|
35
|
+
* @param value - The contact value to validate
|
|
36
|
+
* @returns True if valid email or phone, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
const validateContactValue = (value) => {
|
|
39
|
+
if (!value)
|
|
40
|
+
return false;
|
|
41
|
+
return exports.emailRegex.test(value) || exports.phoneRegex.test(value);
|
|
42
|
+
};
|
|
43
|
+
exports.validateContactValue = validateContactValue;
|
|
8
44
|
// Get verification method from env
|
|
9
45
|
const getVerificationMethod = () => {
|
|
10
46
|
const method = process.env.VERIFICATION_METHOD?.toUpperCase();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { validate } from "./validate.validations";
|
|
2
|
-
export { riderLoginSchema, forgotPasswordSchema, userLoginSchema, refreshTokenSchema, registerSchema, verifyOtpSchema, resendOtpSchema, requestOtpSchema, } from "./auth.validations";
|
|
2
|
+
export { riderLoginSchema, forgotPasswordSchema, userLoginSchema, refreshTokenSchema, registerSchema, verifyOtpSchema, resendOtpSchema, requestOtpSchema, phoneRegex, emailRegex, passwordRegex, } from "./auth.validations";
|
|
3
3
|
export { createUserSchema, getUserByIdSchema, updateUserProfileSchema, getAllUsersSchema, viewProfileSchema, passengerSignupSchema, updatePassengerProfileSchema, updateRiderProfileSchema, createRiderSchema, deactivateAccountSchema, } from "./profiles.validations";
|
|
4
4
|
export { submitBanAppealSchema, submitSuspensionAppealSchema, getBanSchema, getUserRestrictionsSchema, getSuspensionSchema, getUserSuspensionsSchema, getUserBansSchema, listBansSchema, listPendingAppealsSchema, listSuspensionsSchema, reviewAppealSchema, revokeBanSchema, revokeSuspensionSchema, extendSuspensionSchema, createBanSchema, createSuspensionSchema, exportBansSchema, } from "./moderation.validations";
|
|
5
5
|
export { createAppSpecsSchema, updateAppSpecsSchema, listAppSpecsSchema, getActiveAppSpecsSchema, activateAppSpecsSchema, getAppSpecsSchema, } from "./appSpecs.validations";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.payInstallmentSchema = exports.extendSessionSchema = exports.unlockDeviceSchema = exports.getUserPaymentPlanSchema = exports.listUserPaymentPlansSchema = exports.getAppSpecsSchema = exports.activateAppSpecsSchema = exports.getActiveAppSpecsSchema = exports.listAppSpecsSchema = exports.updateAppSpecsSchema = exports.createAppSpecsSchema = exports.exportBansSchema = exports.createSuspensionSchema = exports.createBanSchema = exports.extendSuspensionSchema = exports.revokeSuspensionSchema = exports.revokeBanSchema = exports.reviewAppealSchema = exports.listSuspensionsSchema = exports.listPendingAppealsSchema = exports.listBansSchema = exports.getUserBansSchema = exports.getUserSuspensionsSchema = exports.getSuspensionSchema = exports.getUserRestrictionsSchema = exports.getBanSchema = exports.submitSuspensionAppealSchema = exports.submitBanAppealSchema = exports.deactivateAccountSchema = exports.createRiderSchema = exports.updateRiderProfileSchema = exports.updatePassengerProfileSchema = exports.passengerSignupSchema = exports.viewProfileSchema = exports.getAllUsersSchema = exports.updateUserProfileSchema = exports.getUserByIdSchema = exports.createUserSchema = exports.passwordRegex = exports.emailRegex = exports.phoneRegex = exports.requestOtpSchema = exports.resendOtpSchema = exports.verifyOtpSchema = exports.registerSchema = exports.refreshTokenSchema = exports.userLoginSchema = exports.forgotPasswordSchema = exports.riderLoginSchema = exports.validate = void 0;
|
|
4
|
+
exports.listEventLogsSchema = exports.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema = exports.createPlanSchema = exports.createDeviceSchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.updateDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.bulkCreateDevicesSchema = exports.checkAvailabilitySchema = exports.deletePricingSchema = exports.getPricingsSchema = exports.getPricingSchema = exports.updatePricingSchema = exports.createPricingSchema = exports.updateStockSchema = exports.deleteProductSchema = exports.activateProductSchema = exports.deactivateProductSchema = exports.getProductsSchema = exports.getProductSchema = exports.updateProductSchema = exports.createProductSchema = exports.resetPasswordSchema = exports.upgradeToRiderSchema = exports.fireEmployeeSchema = exports.demoteAdminSchema = exports.promoteAdminSchema = exports.hireAdminSchema = exports.getUsersSchema = exports.getUserSchema = exports.deleteUserSchema = exports.updateRiderSchema = exports.updateAdminSchema = exports.changePasswordSchema = exports.strongPasswordRegex = exports.deleteAccountSchema = exports.verifyPhoneChangeSchema = exports.requestPhoneChangeSchema = exports.updateProfileSchema = void 0;
|
|
5
|
+
exports.getEventLogSchema = void 0;
|
|
5
6
|
var validate_validations_1 = require("./validate.validations");
|
|
6
7
|
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_validations_1.validate; } });
|
|
7
8
|
var auth_validations_1 = require("./auth.validations");
|
|
@@ -13,6 +14,9 @@ Object.defineProperty(exports, "registerSchema", { enumerable: true, get: functi
|
|
|
13
14
|
Object.defineProperty(exports, "verifyOtpSchema", { enumerable: true, get: function () { return auth_validations_1.verifyOtpSchema; } });
|
|
14
15
|
Object.defineProperty(exports, "resendOtpSchema", { enumerable: true, get: function () { return auth_validations_1.resendOtpSchema; } });
|
|
15
16
|
Object.defineProperty(exports, "requestOtpSchema", { enumerable: true, get: function () { return auth_validations_1.requestOtpSchema; } });
|
|
17
|
+
Object.defineProperty(exports, "phoneRegex", { enumerable: true, get: function () { return auth_validations_1.phoneRegex; } });
|
|
18
|
+
Object.defineProperty(exports, "emailRegex", { enumerable: true, get: function () { return auth_validations_1.emailRegex; } });
|
|
19
|
+
Object.defineProperty(exports, "passwordRegex", { enumerable: true, get: function () { return auth_validations_1.passwordRegex; } });
|
|
16
20
|
var profiles_validations_1 = require("./profiles.validations");
|
|
17
21
|
// Admin/Super Admin Schema
|
|
18
22
|
Object.defineProperty(exports, "createUserSchema", { enumerable: true, get: function () { return profiles_validations_1.createUserSchema; } });
|