vr-commons 1.0.85 → 1.0.87
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/account.utils.d.ts +5 -0
- package/dist/utils/account.utils.js +14 -1
- package/dist/utils/profiles.utils.d.ts +5 -1
- package/dist/utils/profiles.utils.js +50 -29
- package/dist/validations/auth.validations.d.ts +57 -35
- package/dist/validations/auth.validations.js +25 -16
- package/dist/validations/devices.validations.js +1 -1
- package/dist/validations/index.d.ts +1 -0
- package/dist/validations/index.js +6 -1
- package/dist/validations/profiles.validations.d.ts +43 -43
- package/dist/validations/profiles.validations.js +2 -1
- package/dist/validations/users.operation.validations.d.ts +280 -0
- package/dist/validations/users.operation.validations.js +109 -0
- package/package.json +1 -1
|
@@ -24,3 +24,8 @@ export declare const checkAccountDependencies: (userId: string, transaction?: an
|
|
|
24
24
|
messages: string[];
|
|
25
25
|
}>;
|
|
26
26
|
export declare const hasActiveDependencies: (userId: string, transaction?: Transaction) => Promise<boolean>;
|
|
27
|
+
export declare const canUserBeModified: (userId: string, transaction?: any) => Promise<{
|
|
28
|
+
allowed: boolean;
|
|
29
|
+
message?: string;
|
|
30
|
+
details?: any;
|
|
31
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasActiveDependencies = exports.checkAccountDependencies = exports.checkIsUserBannedOrSuspended = void 0;
|
|
3
|
+
exports.canUserBeModified = exports.hasActiveDependencies = exports.checkAccountDependencies = exports.checkIsUserBannedOrSuspended = void 0;
|
|
4
4
|
exports.checkBanStatus = checkBanStatus;
|
|
5
5
|
exports.checkSuspensionStatus = checkSuspensionStatus;
|
|
6
6
|
const vr_models_1 = require("vr-models");
|
|
@@ -116,3 +116,16 @@ const hasActiveDependencies = async (userId, transaction) => {
|
|
|
116
116
|
return result.hasDependencies;
|
|
117
117
|
};
|
|
118
118
|
exports.hasActiveDependencies = hasActiveDependencies;
|
|
119
|
+
// Add this helper function to check if user can be modified
|
|
120
|
+
const canUserBeModified = async (userId, transaction) => {
|
|
121
|
+
const { hasDependencies, activeDevicePlans, pendingPayments, messages } = await (0, exports.checkAccountDependencies)(userId, transaction);
|
|
122
|
+
if (hasDependencies) {
|
|
123
|
+
return {
|
|
124
|
+
allowed: false,
|
|
125
|
+
message: `Cannot modify user with active dependencies: ${messages.join(", ")}`,
|
|
126
|
+
details: { activeDevicePlans, pendingPayments, dependencies: messages },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return { allowed: true };
|
|
130
|
+
};
|
|
131
|
+
exports.canUserBeModified = canUserBeModified;
|
|
@@ -150,8 +150,12 @@ export declare const getSortOrder: (sortBy?: string, order?: string) => any[];
|
|
|
150
150
|
* Generate unique jacket ID
|
|
151
151
|
*/
|
|
152
152
|
export declare const generateJacketId: () => Promise<string>;
|
|
153
|
+
export interface ValidationError {
|
|
154
|
+
field: string;
|
|
155
|
+
message: string;
|
|
156
|
+
}
|
|
153
157
|
/**
|
|
154
|
-
* Validate unique user fields
|
|
158
|
+
* Validate unique user fields (phone number is in PhoneContact table)
|
|
155
159
|
*/
|
|
156
160
|
export declare const validateUniqueFields: (fields: {
|
|
157
161
|
phoneNumber?: string;
|
|
@@ -381,41 +381,62 @@ const generateJacketId = async () => {
|
|
|
381
381
|
return jacketId;
|
|
382
382
|
};
|
|
383
383
|
exports.generateJacketId = generateJacketId;
|
|
384
|
-
// ============================================================================
|
|
385
|
-
// VALIDATION FUNCTIONS
|
|
386
|
-
// ============================================================================
|
|
387
384
|
/**
|
|
388
|
-
* Validate unique user fields
|
|
385
|
+
* Validate unique user fields (phone number is in PhoneContact table)
|
|
389
386
|
*/
|
|
390
387
|
const validateUniqueFields = async (fields, excludeUserId) => {
|
|
391
388
|
const errors = [];
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const where = { [field]: value };
|
|
389
|
+
// Check phone number (in PhoneContact table)
|
|
390
|
+
if (fields.phoneNumber) {
|
|
391
|
+
const phoneWhere = { phoneNumber: fields.phoneNumber, isActive: true };
|
|
396
392
|
if (excludeUserId) {
|
|
397
|
-
|
|
393
|
+
phoneWhere.userId = { [sequelize_1.Op.ne]: excludeUserId };
|
|
398
394
|
}
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
errors.push({
|
|
395
|
+
const existingPhone = await vr_models_1.PhoneContact.findOne({
|
|
396
|
+
where: phoneWhere,
|
|
397
|
+
include: [{ model: vr_models_1.User, as: "user", attributes: ["id"] }],
|
|
398
|
+
});
|
|
399
|
+
if (existingPhone && existingPhone.userId !== excludeUserId) {
|
|
400
|
+
errors.push({
|
|
401
|
+
field: "phoneNumber",
|
|
402
|
+
message: "Phone number already registered",
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
// Check nationalId (on User model)
|
|
407
|
+
if (fields.nationalId) {
|
|
408
|
+
const userWhere = { nationalId: fields.nationalId };
|
|
409
|
+
if (excludeUserId) {
|
|
410
|
+
userWhere.id = { [sequelize_1.Op.ne]: excludeUserId };
|
|
411
|
+
}
|
|
412
|
+
const existingUser = await vr_models_1.User.findOne({ where: userWhere });
|
|
413
|
+
if (existingUser) {
|
|
414
|
+
errors.push({
|
|
415
|
+
field: "nationalId",
|
|
416
|
+
message: "National ID already registered",
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// Check email (on User model)
|
|
421
|
+
if (fields.email) {
|
|
422
|
+
const userWhere = { email: fields.email };
|
|
423
|
+
if (excludeUserId) {
|
|
424
|
+
userWhere.id = { [sequelize_1.Op.ne]: excludeUserId };
|
|
425
|
+
}
|
|
426
|
+
const existingUser = await vr_models_1.User.findOne({ where: userWhere });
|
|
427
|
+
if (existingUser) {
|
|
428
|
+
errors.push({ field: "email", message: "Email already registered" });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
// Check jacketId (on User model)
|
|
432
|
+
if (fields.jacketId) {
|
|
433
|
+
const userWhere = { jacketId: fields.jacketId };
|
|
434
|
+
if (excludeUserId) {
|
|
435
|
+
userWhere.id = { [sequelize_1.Op.ne]: excludeUserId };
|
|
436
|
+
}
|
|
437
|
+
const existingUser = await vr_models_1.User.findOne({ where: userWhere });
|
|
438
|
+
if (existingUser) {
|
|
439
|
+
errors.push({ field: "jacketId", message: "Jacket ID already taken" });
|
|
419
440
|
}
|
|
420
441
|
}
|
|
421
442
|
return errors;
|
|
@@ -1,37 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const phoneRegex: RegExp;
|
|
3
3
|
export declare const passwordRegex: RegExp;
|
|
4
|
-
export declare const riderLoginSchema: z.ZodObject<{
|
|
5
|
-
body: z.ZodObject<{
|
|
6
|
-
phoneNumber: z.ZodString;
|
|
7
|
-
nationalId: z.ZodString;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
phoneNumber: string;
|
|
10
|
-
nationalId: string;
|
|
11
|
-
}, {
|
|
12
|
-
phoneNumber: string;
|
|
13
|
-
nationalId: string;
|
|
14
|
-
}>;
|
|
15
|
-
query: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
16
|
-
params: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
17
|
-
headers: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
body: {
|
|
20
|
-
phoneNumber: string;
|
|
21
|
-
nationalId: string;
|
|
22
|
-
};
|
|
23
|
-
params?: {} | undefined;
|
|
24
|
-
query?: {} | undefined;
|
|
25
|
-
headers?: {} | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
body: {
|
|
28
|
-
phoneNumber: string;
|
|
29
|
-
nationalId: string;
|
|
30
|
-
};
|
|
31
|
-
params?: {} | undefined;
|
|
32
|
-
query?: {} | undefined;
|
|
33
|
-
headers?: {} | undefined;
|
|
34
|
-
}>;
|
|
35
4
|
export declare const userLoginSchema: z.ZodObject<{
|
|
36
5
|
body: z.ZodObject<{
|
|
37
6
|
email: z.ZodString;
|
|
@@ -71,6 +40,28 @@ export declare const forgotPasswordSchema: z.ZodObject<{
|
|
|
71
40
|
email: string;
|
|
72
41
|
};
|
|
73
42
|
}>;
|
|
43
|
+
export declare const changePasswordSchema: z.ZodObject<{
|
|
44
|
+
body: z.ZodObject<{
|
|
45
|
+
oldPassword: z.ZodString;
|
|
46
|
+
newPassword: z.ZodString;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
oldPassword: string;
|
|
49
|
+
newPassword: string;
|
|
50
|
+
}, {
|
|
51
|
+
oldPassword: string;
|
|
52
|
+
newPassword: string;
|
|
53
|
+
}>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
body: {
|
|
56
|
+
oldPassword: string;
|
|
57
|
+
newPassword: string;
|
|
58
|
+
};
|
|
59
|
+
}, {
|
|
60
|
+
body: {
|
|
61
|
+
oldPassword: string;
|
|
62
|
+
newPassword: string;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
74
65
|
export declare const refreshTokenSchema: z.ZodObject<{
|
|
75
66
|
body: z.ZodObject<{
|
|
76
67
|
refreshToken: z.ZodString;
|
|
@@ -96,35 +87,66 @@ export declare const registerSchema: z.ZodObject<{
|
|
|
96
87
|
email: z.ZodOptional<z.ZodString>;
|
|
97
88
|
password: z.ZodString;
|
|
98
89
|
}, "strict", z.ZodTypeAny, {
|
|
99
|
-
phoneNumber: string;
|
|
100
90
|
password: string;
|
|
101
91
|
firstName: string;
|
|
102
92
|
lastName: string;
|
|
93
|
+
phoneNumber: string;
|
|
103
94
|
email?: string | undefined;
|
|
104
95
|
}, {
|
|
105
|
-
phoneNumber: string;
|
|
106
96
|
password: string;
|
|
107
97
|
firstName: string;
|
|
108
98
|
lastName: string;
|
|
99
|
+
phoneNumber: string;
|
|
109
100
|
email?: string | undefined;
|
|
110
101
|
}>;
|
|
111
102
|
}, "strip", z.ZodTypeAny, {
|
|
112
103
|
body: {
|
|
113
|
-
phoneNumber: string;
|
|
114
104
|
password: string;
|
|
115
105
|
firstName: string;
|
|
116
106
|
lastName: string;
|
|
107
|
+
phoneNumber: string;
|
|
117
108
|
email?: string | undefined;
|
|
118
109
|
};
|
|
119
110
|
}, {
|
|
120
111
|
body: {
|
|
121
|
-
phoneNumber: string;
|
|
122
112
|
password: string;
|
|
123
113
|
firstName: string;
|
|
124
114
|
lastName: string;
|
|
115
|
+
phoneNumber: string;
|
|
125
116
|
email?: string | undefined;
|
|
126
117
|
};
|
|
127
118
|
}>;
|
|
119
|
+
export declare const riderLoginSchema: z.ZodObject<{
|
|
120
|
+
body: z.ZodObject<{
|
|
121
|
+
phoneNumber: z.ZodString;
|
|
122
|
+
nationalId: z.ZodString;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
phoneNumber: string;
|
|
125
|
+
nationalId: string;
|
|
126
|
+
}, {
|
|
127
|
+
phoneNumber: string;
|
|
128
|
+
nationalId: string;
|
|
129
|
+
}>;
|
|
130
|
+
query: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
131
|
+
params: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
132
|
+
headers: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
body: {
|
|
135
|
+
phoneNumber: string;
|
|
136
|
+
nationalId: string;
|
|
137
|
+
};
|
|
138
|
+
params?: {} | undefined;
|
|
139
|
+
query?: {} | undefined;
|
|
140
|
+
headers?: {} | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
body: {
|
|
143
|
+
phoneNumber: string;
|
|
144
|
+
nationalId: string;
|
|
145
|
+
};
|
|
146
|
+
params?: {} | undefined;
|
|
147
|
+
query?: {} | undefined;
|
|
148
|
+
headers?: {} | undefined;
|
|
149
|
+
}>;
|
|
128
150
|
export declare const requestOtpSchema: z.ZodObject<{
|
|
129
151
|
body: z.ZodObject<{
|
|
130
152
|
phoneNumber: z.ZodString;
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resendOtpSchema = exports.verifyOtpSchema = exports.requestOtpSchema = exports.registerSchema = exports.refreshTokenSchema = exports.
|
|
3
|
+
exports.resendOtpSchema = exports.verifyOtpSchema = exports.requestOtpSchema = exports.riderLoginSchema = exports.registerSchema = exports.refreshTokenSchema = exports.changePasswordSchema = exports.forgotPasswordSchema = exports.userLoginSchema = exports.passwordRegex = exports.phoneRegex = void 0;
|
|
4
|
+
// src/validations/auth.schema.ts
|
|
4
5
|
const zod_1 = require("zod");
|
|
5
6
|
exports.phoneRegex = /^\+250(78|79|73|72)[0-9]{7}$/;
|
|
6
7
|
exports.passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$/;
|
|
7
|
-
|
|
8
|
-
body: zod_1.z.object({
|
|
9
|
-
phoneNumber: zod_1.z
|
|
10
|
-
.string()
|
|
11
|
-
.trim()
|
|
12
|
-
.min(10, "Phone number must be at least 10 digits")
|
|
13
|
-
.max(15, "Phone number must be at most 15 digits"),
|
|
14
|
-
nationalId: zod_1.z.string().min(16, "National ID must be atleast 16 digits"),
|
|
15
|
-
}),
|
|
16
|
-
query: zod_1.z.object({}).optional(),
|
|
17
|
-
params: zod_1.z.object({}).optional(),
|
|
18
|
-
headers: zod_1.z.object({}).optional(),
|
|
19
|
-
});
|
|
8
|
+
// ==================== ADMIN AUTH VALIDATIONS ====================
|
|
20
9
|
exports.userLoginSchema = zod_1.z.object({
|
|
21
10
|
body: zod_1.z.object({
|
|
22
11
|
email: zod_1.z.string().email(),
|
|
@@ -28,6 +17,14 @@ exports.forgotPasswordSchema = zod_1.z.object({
|
|
|
28
17
|
email: zod_1.z.string().email(),
|
|
29
18
|
}),
|
|
30
19
|
});
|
|
20
|
+
exports.changePasswordSchema = zod_1.z.object({
|
|
21
|
+
body: zod_1.z.object({
|
|
22
|
+
oldPassword: zod_1.z.string().min(1, "Old password is required"),
|
|
23
|
+
newPassword: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(exports.passwordRegex, "Password must be at least 6 characters with at least one letter and one number"),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
31
28
|
exports.refreshTokenSchema = zod_1.z.object({
|
|
32
29
|
body: zod_1.z.object({
|
|
33
30
|
refreshToken: zod_1.z.string().min(1, "Refresh token is required"),
|
|
@@ -52,6 +49,20 @@ exports.registerSchema = zod_1.z.object({
|
|
|
52
49
|
})
|
|
53
50
|
.strict(),
|
|
54
51
|
});
|
|
52
|
+
// ==================== USER (RIDER/PASSENGER) AUTH VALIDATIONS ====================
|
|
53
|
+
exports.riderLoginSchema = zod_1.z.object({
|
|
54
|
+
body: zod_1.z.object({
|
|
55
|
+
phoneNumber: zod_1.z
|
|
56
|
+
.string()
|
|
57
|
+
.trim()
|
|
58
|
+
.min(10, "Phone number must be at least 10 digits")
|
|
59
|
+
.max(15, "Phone number must be at most 15 digits"),
|
|
60
|
+
nationalId: zod_1.z.string().min(16, "National ID must be atleast 16 digits"),
|
|
61
|
+
}),
|
|
62
|
+
query: zod_1.z.object({}).optional(),
|
|
63
|
+
params: zod_1.z.object({}).optional(),
|
|
64
|
+
headers: zod_1.z.object({}).optional(),
|
|
65
|
+
});
|
|
55
66
|
exports.requestOtpSchema = zod_1.z.object({
|
|
56
67
|
body: zod_1.z.object({
|
|
57
68
|
phoneNumber: zod_1.z
|
|
@@ -76,8 +87,6 @@ exports.verifyOtpSchema = zod_1.z.object({
|
|
|
76
87
|
.optional(),
|
|
77
88
|
})
|
|
78
89
|
.refine((data) => {
|
|
79
|
-
// If it's a new user, firstName and lastName are required
|
|
80
|
-
// We'll check this in service by checking if user exists
|
|
81
90
|
return true;
|
|
82
91
|
}, {
|
|
83
92
|
message: "First name and last name are required for new users",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extendSessionSchema = exports.unlockDeviceSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const serialRegex = /^[A-Z0-9]{8,
|
|
5
|
+
const serialRegex = /^[A-Z0-9]{8,24}$/i;
|
|
6
6
|
exports.unlockDeviceSchema = zod_1.z.object({
|
|
7
7
|
body: zod_1.z.object({
|
|
8
8
|
deviceSerialNumber: zod_1.z
|
|
@@ -11,3 +11,4 @@ export { unlockDeviceSchema, extendSessionSchema } from "./devices.validations";
|
|
|
11
11
|
export { payInstallmentSchema } from "./payinstallment.validations";
|
|
12
12
|
export { updateProfileSchema, requestPhoneChangeSchema, verifyPhoneChangeSchema, deleteAccountSchema, strongPasswordRegex, changePasswordSchema, } from "./account.validations";
|
|
13
13
|
export { upgradeToRiderSchema } from "./user.management.validations";
|
|
14
|
+
export { updateUserSchema, getUserSchema, deactivateUserSchema, deleteUserSchema, } from "./users.operation.validations";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteAccountSchema = exports.verifyPhoneChangeSchema = exports.requestPhoneChangeSchema = exports.updateProfileSchema = exports.payInstallmentSchema = exports.extendSessionSchema = exports.unlockDeviceSchema = exports.getUserPaymentPlanSchema = exports.listUserPaymentPlansSchema = exports.getAppSpecsSchema = exports.activateAppSpecsSchema = exports.getActiveAppSpecsSchema = exports.listAppSpecsSchema = exports.updateAppSpecsSchema = exports.createAppSpecsSchema = exports.createSuspensionSchema = exports.getUserSuspensionsSchema = exports.getSuspensionSchema = exports.createBanSchema = exports.getUserRestrictionsSchema = exports.getBanSchema = exports.submitSuspensionAppealSchema = exports.submitBanAppealSchema = exports.exportBansSchema = exports.extendSuspensionSchema = exports.revokeSuspensionSchema = exports.revokeBanSchema = exports.reviewAppealSchema = exports.listSuspensionsSchema = exports.listPendingAppealsSchema = exports.listBansSchema = exports.deactivateAccountSchema = exports.createRiderSchema = exports.updateRiderProfileSchema = exports.updatePassengerProfileSchema = exports.passengerSignupSchema = exports.viewProfileSchema = exports.getAllUsersSchema = exports.updateUserProfileSchema = exports.getUserByIdSchema = exports.createUserSchema = exports.requestOtpSchema = exports.resendOtpSchema = exports.verifyOtpSchema = exports.registerSchema = exports.refreshTokenSchema = exports.userLoginSchema = exports.forgotPasswordSchema = exports.riderLoginSchema = exports.validate = void 0;
|
|
4
|
-
exports.upgradeToRiderSchema = exports.changePasswordSchema = exports.strongPasswordRegex = void 0;
|
|
4
|
+
exports.deleteUserSchema = exports.deactivateUserSchema = exports.getUserSchema = exports.updateUserSchema = exports.upgradeToRiderSchema = exports.changePasswordSchema = exports.strongPasswordRegex = void 0;
|
|
5
5
|
var validate_validations_1 = require("./validate.validations");
|
|
6
6
|
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_validations_1.validate; } });
|
|
7
7
|
var auth_validations_1 = require("./auth.validations");
|
|
@@ -73,3 +73,8 @@ Object.defineProperty(exports, "strongPasswordRegex", { enumerable: true, get: f
|
|
|
73
73
|
Object.defineProperty(exports, "changePasswordSchema", { enumerable: true, get: function () { return account_validations_1.changePasswordSchema; } });
|
|
74
74
|
var user_management_validations_1 = require("./user.management.validations");
|
|
75
75
|
Object.defineProperty(exports, "upgradeToRiderSchema", { enumerable: true, get: function () { return user_management_validations_1.upgradeToRiderSchema; } });
|
|
76
|
+
var users_operation_validations_1 = require("./users.operation.validations");
|
|
77
|
+
Object.defineProperty(exports, "updateUserSchema", { enumerable: true, get: function () { return users_operation_validations_1.updateUserSchema; } });
|
|
78
|
+
Object.defineProperty(exports, "getUserSchema", { enumerable: true, get: function () { return users_operation_validations_1.getUserSchema; } });
|
|
79
|
+
Object.defineProperty(exports, "deactivateUserSchema", { enumerable: true, get: function () { return users_operation_validations_1.deactivateUserSchema; } });
|
|
80
|
+
Object.defineProperty(exports, "deleteUserSchema", { enumerable: true, get: function () { return users_operation_validations_1.deleteUserSchema; } });
|
|
@@ -9,29 +9,29 @@ export declare const createUserSchema: z.ZodObject<{
|
|
|
9
9
|
phoneNumber: z.ZodString;
|
|
10
10
|
nationalId: z.ZodString;
|
|
11
11
|
email: z.ZodUnion<[z.ZodNullable<z.ZodOptional<z.ZodString>>, z.ZodLiteral<"">]>;
|
|
12
|
-
password: z.ZodString
|
|
12
|
+
password: z.ZodOptional<z.ZodString>;
|
|
13
13
|
role: z.ZodEnum<["AGENT", "RIDER", "PASSENGER", "ADMIN", "SUPER_ADMIN"]>;
|
|
14
14
|
plateNumber: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
15
|
jacketId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
17
|
firstName: string;
|
|
18
18
|
lastName: string;
|
|
19
|
-
password: string;
|
|
20
19
|
nationalId: string;
|
|
21
|
-
role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
|
|
22
20
|
phoneNumber: string;
|
|
21
|
+
role: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN";
|
|
23
22
|
jacketId?: string | null | undefined;
|
|
24
23
|
email?: string | null | undefined;
|
|
24
|
+
password?: string | undefined;
|
|
25
25
|
plateNumber?: string | null | undefined;
|
|
26
26
|
}, {
|
|
27
27
|
firstName: string;
|
|
28
28
|
lastName: string;
|
|
29
|
-
password: string;
|
|
30
29
|
nationalId: string;
|
|
31
|
-
role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
|
|
32
30
|
phoneNumber: string;
|
|
31
|
+
role: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN";
|
|
33
32
|
jacketId?: string | null | undefined;
|
|
34
33
|
email?: string | null | undefined;
|
|
34
|
+
password?: string | undefined;
|
|
35
35
|
plateNumber?: string | null | undefined;
|
|
36
36
|
}>;
|
|
37
37
|
headers: z.ZodObject<{
|
|
@@ -45,12 +45,12 @@ export declare const createUserSchema: z.ZodObject<{
|
|
|
45
45
|
body: {
|
|
46
46
|
firstName: string;
|
|
47
47
|
lastName: string;
|
|
48
|
-
password: string;
|
|
49
48
|
nationalId: string;
|
|
50
|
-
role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
|
|
51
49
|
phoneNumber: string;
|
|
50
|
+
role: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN";
|
|
52
51
|
jacketId?: string | null | undefined;
|
|
53
52
|
email?: string | null | undefined;
|
|
53
|
+
password?: string | undefined;
|
|
54
54
|
plateNumber?: string | null | undefined;
|
|
55
55
|
};
|
|
56
56
|
headers: {
|
|
@@ -60,12 +60,12 @@ export declare const createUserSchema: z.ZodObject<{
|
|
|
60
60
|
body: {
|
|
61
61
|
firstName: string;
|
|
62
62
|
lastName: string;
|
|
63
|
-
password: string;
|
|
64
63
|
nationalId: string;
|
|
65
|
-
role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
|
|
66
64
|
phoneNumber: string;
|
|
65
|
+
role: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN";
|
|
67
66
|
jacketId?: string | null | undefined;
|
|
68
67
|
email?: string | null | undefined;
|
|
68
|
+
password?: string | undefined;
|
|
69
69
|
plateNumber?: string | null | undefined;
|
|
70
70
|
};
|
|
71
71
|
headers: {
|
|
@@ -128,8 +128,8 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
128
128
|
plateNumber?: string | null | undefined;
|
|
129
129
|
isActive?: boolean | undefined;
|
|
130
130
|
isDeactivated?: boolean | undefined;
|
|
131
|
-
phoneNumber?: string | undefined;
|
|
132
131
|
isSuspended?: boolean | undefined;
|
|
132
|
+
phoneNumber?: string | undefined;
|
|
133
133
|
}, {
|
|
134
134
|
firstName?: string | undefined;
|
|
135
135
|
lastName?: string | undefined;
|
|
@@ -138,8 +138,8 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
138
138
|
plateNumber?: string | null | undefined;
|
|
139
139
|
isActive?: boolean | undefined;
|
|
140
140
|
isDeactivated?: boolean | undefined;
|
|
141
|
-
phoneNumber?: string | undefined;
|
|
142
141
|
isSuspended?: boolean | undefined;
|
|
142
|
+
phoneNumber?: string | undefined;
|
|
143
143
|
}>, {
|
|
144
144
|
firstName?: string | undefined;
|
|
145
145
|
lastName?: string | undefined;
|
|
@@ -148,8 +148,8 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
148
148
|
plateNumber?: string | null | undefined;
|
|
149
149
|
isActive?: boolean | undefined;
|
|
150
150
|
isDeactivated?: boolean | undefined;
|
|
151
|
-
phoneNumber?: string | undefined;
|
|
152
151
|
isSuspended?: boolean | undefined;
|
|
152
|
+
phoneNumber?: string | undefined;
|
|
153
153
|
}, {
|
|
154
154
|
firstName?: string | undefined;
|
|
155
155
|
lastName?: string | undefined;
|
|
@@ -158,8 +158,8 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
158
158
|
plateNumber?: string | null | undefined;
|
|
159
159
|
isActive?: boolean | undefined;
|
|
160
160
|
isDeactivated?: boolean | undefined;
|
|
161
|
-
phoneNumber?: string | undefined;
|
|
162
161
|
isSuspended?: boolean | undefined;
|
|
162
|
+
phoneNumber?: string | undefined;
|
|
163
163
|
}>;
|
|
164
164
|
headers: z.ZodObject<{
|
|
165
165
|
authorization: z.ZodString;
|
|
@@ -169,6 +169,9 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
169
169
|
authorization: string;
|
|
170
170
|
}>;
|
|
171
171
|
}, "strip", z.ZodTypeAny, {
|
|
172
|
+
params: {
|
|
173
|
+
userId: string;
|
|
174
|
+
};
|
|
172
175
|
body: {
|
|
173
176
|
firstName?: string | undefined;
|
|
174
177
|
lastName?: string | undefined;
|
|
@@ -177,16 +180,16 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
177
180
|
plateNumber?: string | null | undefined;
|
|
178
181
|
isActive?: boolean | undefined;
|
|
179
182
|
isDeactivated?: boolean | undefined;
|
|
180
|
-
phoneNumber?: string | undefined;
|
|
181
183
|
isSuspended?: boolean | undefined;
|
|
182
|
-
|
|
183
|
-
params: {
|
|
184
|
-
userId: string;
|
|
184
|
+
phoneNumber?: string | undefined;
|
|
185
185
|
};
|
|
186
186
|
headers: {
|
|
187
187
|
authorization: string;
|
|
188
188
|
};
|
|
189
189
|
}, {
|
|
190
|
+
params: {
|
|
191
|
+
userId: string;
|
|
192
|
+
};
|
|
190
193
|
body: {
|
|
191
194
|
firstName?: string | undefined;
|
|
192
195
|
lastName?: string | undefined;
|
|
@@ -195,11 +198,8 @@ export declare const updateUserProfileSchema: z.ZodObject<{
|
|
|
195
198
|
plateNumber?: string | null | undefined;
|
|
196
199
|
isActive?: boolean | undefined;
|
|
197
200
|
isDeactivated?: boolean | undefined;
|
|
198
|
-
phoneNumber?: string | undefined;
|
|
199
201
|
isSuspended?: boolean | undefined;
|
|
200
|
-
|
|
201
|
-
params: {
|
|
202
|
-
userId: string;
|
|
202
|
+
phoneNumber?: string | undefined;
|
|
203
203
|
};
|
|
204
204
|
headers: {
|
|
205
205
|
authorization: string;
|
|
@@ -220,13 +220,13 @@ export declare const getAllUsersSchema: z.ZodObject<{
|
|
|
220
220
|
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
221
221
|
}, "strip", z.ZodTypeAny, {
|
|
222
222
|
order: "asc" | "desc";
|
|
223
|
-
sortBy: "
|
|
223
|
+
sortBy: "createdAt" | "firstName" | "lastLoginAt";
|
|
224
224
|
search?: string | undefined;
|
|
225
225
|
limit?: number | undefined;
|
|
226
226
|
isActive?: boolean | undefined;
|
|
227
|
-
role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
|
|
228
227
|
isBanned?: boolean | undefined;
|
|
229
228
|
isSuspended?: boolean | undefined;
|
|
229
|
+
role?: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
230
230
|
page?: number | undefined;
|
|
231
231
|
startDate?: string | undefined;
|
|
232
232
|
endDate?: string | undefined;
|
|
@@ -235,13 +235,13 @@ export declare const getAllUsersSchema: z.ZodObject<{
|
|
|
235
235
|
order?: "asc" | "desc" | undefined;
|
|
236
236
|
limit?: string | undefined;
|
|
237
237
|
isActive?: "true" | "false" | undefined;
|
|
238
|
-
role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
|
|
239
238
|
isBanned?: "true" | "false" | undefined;
|
|
240
239
|
isSuspended?: "true" | "false" | undefined;
|
|
240
|
+
role?: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
241
241
|
page?: string | undefined;
|
|
242
242
|
startDate?: string | undefined;
|
|
243
243
|
endDate?: string | undefined;
|
|
244
|
-
sortBy?: "
|
|
244
|
+
sortBy?: "createdAt" | "firstName" | "lastLoginAt" | undefined;
|
|
245
245
|
}>;
|
|
246
246
|
headers: z.ZodObject<{
|
|
247
247
|
authorization: z.ZodString;
|
|
@@ -251,38 +251,38 @@ export declare const getAllUsersSchema: z.ZodObject<{
|
|
|
251
251
|
authorization: string;
|
|
252
252
|
}>;
|
|
253
253
|
}, "strip", z.ZodTypeAny, {
|
|
254
|
+
headers: {
|
|
255
|
+
authorization: string;
|
|
256
|
+
};
|
|
254
257
|
query: {
|
|
255
258
|
order: "asc" | "desc";
|
|
256
|
-
sortBy: "
|
|
259
|
+
sortBy: "createdAt" | "firstName" | "lastLoginAt";
|
|
257
260
|
search?: string | undefined;
|
|
258
261
|
limit?: number | undefined;
|
|
259
262
|
isActive?: boolean | undefined;
|
|
260
|
-
role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
|
|
261
263
|
isBanned?: boolean | undefined;
|
|
262
264
|
isSuspended?: boolean | undefined;
|
|
265
|
+
role?: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
263
266
|
page?: number | undefined;
|
|
264
267
|
startDate?: string | undefined;
|
|
265
268
|
endDate?: string | undefined;
|
|
266
269
|
};
|
|
270
|
+
}, {
|
|
267
271
|
headers: {
|
|
268
272
|
authorization: string;
|
|
269
273
|
};
|
|
270
|
-
}, {
|
|
271
274
|
query: {
|
|
272
275
|
search?: string | undefined;
|
|
273
276
|
order?: "asc" | "desc" | undefined;
|
|
274
277
|
limit?: string | undefined;
|
|
275
278
|
isActive?: "true" | "false" | undefined;
|
|
276
|
-
role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
|
|
277
279
|
isBanned?: "true" | "false" | undefined;
|
|
278
280
|
isSuspended?: "true" | "false" | undefined;
|
|
281
|
+
role?: "AGENT" | "RIDER" | "PASSENGER" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
279
282
|
page?: string | undefined;
|
|
280
283
|
startDate?: string | undefined;
|
|
281
284
|
endDate?: string | undefined;
|
|
282
|
-
sortBy?: "
|
|
283
|
-
};
|
|
284
|
-
headers: {
|
|
285
|
-
authorization: string;
|
|
285
|
+
sortBy?: "createdAt" | "firstName" | "lastLoginAt" | undefined;
|
|
286
286
|
};
|
|
287
287
|
}>;
|
|
288
288
|
export declare const viewProfileSchema: z.ZodObject<{
|
|
@@ -300,16 +300,16 @@ export declare const viewProfileSchema: z.ZodObject<{
|
|
|
300
300
|
headers: {
|
|
301
301
|
authorization: string;
|
|
302
302
|
};
|
|
303
|
+
params?: {} | undefined;
|
|
303
304
|
body?: {} | undefined;
|
|
304
305
|
query?: {} | undefined;
|
|
305
|
-
params?: {} | undefined;
|
|
306
306
|
}, {
|
|
307
307
|
headers: {
|
|
308
308
|
authorization: string;
|
|
309
309
|
};
|
|
310
|
+
params?: {} | undefined;
|
|
310
311
|
body?: {} | undefined;
|
|
311
312
|
query?: {} | undefined;
|
|
312
|
-
params?: {} | undefined;
|
|
313
313
|
}>;
|
|
314
314
|
export declare const passengerSignupSchema: z.ZodObject<{
|
|
315
315
|
body: z.ZodObject<{
|
|
@@ -444,8 +444,8 @@ export declare const createRiderSchema: z.ZodObject<{
|
|
|
444
444
|
nationalId: string;
|
|
445
445
|
phoneNumber: string;
|
|
446
446
|
};
|
|
447
|
-
query?: {} | undefined;
|
|
448
447
|
params?: {} | undefined;
|
|
448
|
+
query?: {} | undefined;
|
|
449
449
|
}, {
|
|
450
450
|
body: {
|
|
451
451
|
firstName: string;
|
|
@@ -455,8 +455,8 @@ export declare const createRiderSchema: z.ZodObject<{
|
|
|
455
455
|
nationalId: string;
|
|
456
456
|
phoneNumber: string;
|
|
457
457
|
};
|
|
458
|
-
query?: {} | undefined;
|
|
459
458
|
params?: {} | undefined;
|
|
459
|
+
query?: {} | undefined;
|
|
460
460
|
}>;
|
|
461
461
|
export declare const updateRiderProfileSchema: z.ZodObject<{
|
|
462
462
|
params: z.ZodObject<{
|
|
@@ -511,6 +511,9 @@ export declare const updateRiderProfileSchema: z.ZodObject<{
|
|
|
511
511
|
authorization: string;
|
|
512
512
|
}>;
|
|
513
513
|
}, "strip", z.ZodTypeAny, {
|
|
514
|
+
params: {
|
|
515
|
+
id: string;
|
|
516
|
+
};
|
|
514
517
|
body: {
|
|
515
518
|
firstName: string;
|
|
516
519
|
lastName: string;
|
|
@@ -519,14 +522,14 @@ export declare const updateRiderProfileSchema: z.ZodObject<{
|
|
|
519
522
|
nationalId: string;
|
|
520
523
|
phoneNumber: string;
|
|
521
524
|
};
|
|
522
|
-
params: {
|
|
523
|
-
id: string;
|
|
524
|
-
};
|
|
525
525
|
headers: {
|
|
526
526
|
authorization: string;
|
|
527
527
|
};
|
|
528
528
|
query?: {} | undefined;
|
|
529
529
|
}, {
|
|
530
|
+
params: {
|
|
531
|
+
id: string;
|
|
532
|
+
};
|
|
530
533
|
body: {
|
|
531
534
|
firstName: string;
|
|
532
535
|
lastName: string;
|
|
@@ -535,9 +538,6 @@ export declare const updateRiderProfileSchema: z.ZodObject<{
|
|
|
535
538
|
nationalId: string;
|
|
536
539
|
phoneNumber: string;
|
|
537
540
|
};
|
|
538
|
-
params: {
|
|
539
|
-
id: string;
|
|
540
|
-
};
|
|
541
541
|
headers: {
|
|
542
542
|
authorization: string;
|
|
543
543
|
};
|
|
@@ -38,7 +38,8 @@ exports.createUserSchema = zod_1.z.object({
|
|
|
38
38
|
password: zod_1.z
|
|
39
39
|
.string()
|
|
40
40
|
.min(6, "Password must be at least 6 characters")
|
|
41
|
-
.max(100, "Password cannot exceed 100 characters")
|
|
41
|
+
.max(100, "Password cannot exceed 100 characters")
|
|
42
|
+
.optional(),
|
|
42
43
|
role: zod_1.z.enum(["AGENT", "RIDER", "PASSENGER", "ADMIN", "SUPER_ADMIN"], {
|
|
43
44
|
errorMap: () => ({ message: "Invalid role specified" }),
|
|
44
45
|
}),
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const updateUserSchema: z.ZodObject<{
|
|
3
|
+
params: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
id: string;
|
|
7
|
+
}, {
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
10
|
+
body: z.ZodObject<{
|
|
11
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
12
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
13
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
14
|
+
jacketId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16
|
+
plateNumber: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
nationalId: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
firstName?: string | undefined;
|
|
20
|
+
lastName?: string | undefined;
|
|
21
|
+
jacketId?: string | null | undefined;
|
|
22
|
+
email?: string | null | undefined;
|
|
23
|
+
plateNumber?: string | null | undefined;
|
|
24
|
+
nationalId?: string | undefined;
|
|
25
|
+
phoneNumber?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
firstName?: string | undefined;
|
|
28
|
+
lastName?: string | undefined;
|
|
29
|
+
jacketId?: string | null | undefined;
|
|
30
|
+
email?: string | null | undefined;
|
|
31
|
+
plateNumber?: string | null | undefined;
|
|
32
|
+
nationalId?: string | undefined;
|
|
33
|
+
phoneNumber?: string | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
params: {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
body: {
|
|
40
|
+
firstName?: string | undefined;
|
|
41
|
+
lastName?: string | undefined;
|
|
42
|
+
jacketId?: string | null | undefined;
|
|
43
|
+
email?: string | null | undefined;
|
|
44
|
+
plateNumber?: string | null | undefined;
|
|
45
|
+
nationalId?: string | undefined;
|
|
46
|
+
phoneNumber?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
params: {
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
body: {
|
|
53
|
+
firstName?: string | undefined;
|
|
54
|
+
lastName?: string | undefined;
|
|
55
|
+
jacketId?: string | null | undefined;
|
|
56
|
+
email?: string | null | undefined;
|
|
57
|
+
plateNumber?: string | null | undefined;
|
|
58
|
+
nationalId?: string | undefined;
|
|
59
|
+
phoneNumber?: string | undefined;
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
export declare const getUserSchema: z.ZodObject<{
|
|
63
|
+
params: z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
id: string;
|
|
67
|
+
}, {
|
|
68
|
+
id: string;
|
|
69
|
+
}>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
params: {
|
|
72
|
+
id: string;
|
|
73
|
+
};
|
|
74
|
+
}, {
|
|
75
|
+
params: {
|
|
76
|
+
id: string;
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
79
|
+
export declare const getUsersSchema: z.ZodObject<{
|
|
80
|
+
query: z.ZodObject<{
|
|
81
|
+
page: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
82
|
+
limit: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
83
|
+
search: z.ZodOptional<z.ZodString>;
|
|
84
|
+
isActive: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
85
|
+
isSuspended: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
86
|
+
isDeactivated: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
87
|
+
securityClearanceId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
sortBy: z.ZodOptional<z.ZodEnum<["createdAt", "firstName", "lastName", "phoneNumber"]>>;
|
|
89
|
+
sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
search?: string | undefined;
|
|
92
|
+
limit?: number | undefined;
|
|
93
|
+
securityClearanceId?: string | undefined;
|
|
94
|
+
isActive?: "true" | "false" | undefined;
|
|
95
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
96
|
+
isSuspended?: "true" | "false" | undefined;
|
|
97
|
+
page?: number | undefined;
|
|
98
|
+
sortBy?: "createdAt" | "firstName" | "lastName" | "phoneNumber" | undefined;
|
|
99
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
search?: string | undefined;
|
|
102
|
+
limit?: string | undefined;
|
|
103
|
+
securityClearanceId?: string | undefined;
|
|
104
|
+
isActive?: "true" | "false" | undefined;
|
|
105
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
106
|
+
isSuspended?: "true" | "false" | undefined;
|
|
107
|
+
page?: string | undefined;
|
|
108
|
+
sortBy?: "createdAt" | "firstName" | "lastName" | "phoneNumber" | undefined;
|
|
109
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
query: {
|
|
113
|
+
search?: string | undefined;
|
|
114
|
+
limit?: number | undefined;
|
|
115
|
+
securityClearanceId?: string | undefined;
|
|
116
|
+
isActive?: "true" | "false" | undefined;
|
|
117
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
118
|
+
isSuspended?: "true" | "false" | undefined;
|
|
119
|
+
page?: number | undefined;
|
|
120
|
+
sortBy?: "createdAt" | "firstName" | "lastName" | "phoneNumber" | undefined;
|
|
121
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
122
|
+
};
|
|
123
|
+
}, {
|
|
124
|
+
query: {
|
|
125
|
+
search?: string | undefined;
|
|
126
|
+
limit?: string | undefined;
|
|
127
|
+
securityClearanceId?: string | undefined;
|
|
128
|
+
isActive?: "true" | "false" | undefined;
|
|
129
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
130
|
+
isSuspended?: "true" | "false" | undefined;
|
|
131
|
+
page?: string | undefined;
|
|
132
|
+
sortBy?: "createdAt" | "firstName" | "lastName" | "phoneNumber" | undefined;
|
|
133
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
134
|
+
};
|
|
135
|
+
}>;
|
|
136
|
+
export declare const deleteUserSchema: z.ZodObject<{
|
|
137
|
+
params: z.ZodObject<{
|
|
138
|
+
id: z.ZodString;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
id: string;
|
|
141
|
+
}, {
|
|
142
|
+
id: string;
|
|
143
|
+
}>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
params: {
|
|
146
|
+
id: string;
|
|
147
|
+
};
|
|
148
|
+
}, {
|
|
149
|
+
params: {
|
|
150
|
+
id: string;
|
|
151
|
+
};
|
|
152
|
+
}>;
|
|
153
|
+
export declare const suspendUserSchema: z.ZodObject<{
|
|
154
|
+
params: z.ZodObject<{
|
|
155
|
+
id: z.ZodString;
|
|
156
|
+
}, "strip", z.ZodTypeAny, {
|
|
157
|
+
id: string;
|
|
158
|
+
}, {
|
|
159
|
+
id: string;
|
|
160
|
+
}>;
|
|
161
|
+
body: z.ZodObject<{
|
|
162
|
+
reason: z.ZodString;
|
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
|
164
|
+
reason: string;
|
|
165
|
+
}, {
|
|
166
|
+
reason: string;
|
|
167
|
+
}>;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
params: {
|
|
170
|
+
id: string;
|
|
171
|
+
};
|
|
172
|
+
body: {
|
|
173
|
+
reason: string;
|
|
174
|
+
};
|
|
175
|
+
}, {
|
|
176
|
+
params: {
|
|
177
|
+
id: string;
|
|
178
|
+
};
|
|
179
|
+
body: {
|
|
180
|
+
reason: string;
|
|
181
|
+
};
|
|
182
|
+
}>;
|
|
183
|
+
export declare const unsuspendUserSchema: z.ZodObject<{
|
|
184
|
+
params: z.ZodObject<{
|
|
185
|
+
id: z.ZodString;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
id: string;
|
|
188
|
+
}, {
|
|
189
|
+
id: string;
|
|
190
|
+
}>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
params: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
195
|
+
}, {
|
|
196
|
+
params: {
|
|
197
|
+
id: string;
|
|
198
|
+
};
|
|
199
|
+
}>;
|
|
200
|
+
export declare const banUserSchema: z.ZodObject<{
|
|
201
|
+
params: z.ZodObject<{
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
id: string;
|
|
205
|
+
}, {
|
|
206
|
+
id: string;
|
|
207
|
+
}>;
|
|
208
|
+
body: z.ZodObject<{
|
|
209
|
+
reason: z.ZodString;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
reason: string;
|
|
212
|
+
}, {
|
|
213
|
+
reason: string;
|
|
214
|
+
}>;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
params: {
|
|
217
|
+
id: string;
|
|
218
|
+
};
|
|
219
|
+
body: {
|
|
220
|
+
reason: string;
|
|
221
|
+
};
|
|
222
|
+
}, {
|
|
223
|
+
params: {
|
|
224
|
+
id: string;
|
|
225
|
+
};
|
|
226
|
+
body: {
|
|
227
|
+
reason: string;
|
|
228
|
+
};
|
|
229
|
+
}>;
|
|
230
|
+
export declare const unbanUserSchema: z.ZodObject<{
|
|
231
|
+
params: z.ZodObject<{
|
|
232
|
+
id: z.ZodString;
|
|
233
|
+
}, "strip", z.ZodTypeAny, {
|
|
234
|
+
id: string;
|
|
235
|
+
}, {
|
|
236
|
+
id: string;
|
|
237
|
+
}>;
|
|
238
|
+
}, "strip", z.ZodTypeAny, {
|
|
239
|
+
params: {
|
|
240
|
+
id: string;
|
|
241
|
+
};
|
|
242
|
+
}, {
|
|
243
|
+
params: {
|
|
244
|
+
id: string;
|
|
245
|
+
};
|
|
246
|
+
}>;
|
|
247
|
+
export declare const deactivateUserSchema: z.ZodObject<{
|
|
248
|
+
params: z.ZodObject<{
|
|
249
|
+
id: z.ZodString;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
id: string;
|
|
252
|
+
}, {
|
|
253
|
+
id: string;
|
|
254
|
+
}>;
|
|
255
|
+
}, "strip", z.ZodTypeAny, {
|
|
256
|
+
params: {
|
|
257
|
+
id: string;
|
|
258
|
+
};
|
|
259
|
+
}, {
|
|
260
|
+
params: {
|
|
261
|
+
id: string;
|
|
262
|
+
};
|
|
263
|
+
}>;
|
|
264
|
+
export declare const activateUserSchema: z.ZodObject<{
|
|
265
|
+
params: z.ZodObject<{
|
|
266
|
+
id: z.ZodString;
|
|
267
|
+
}, "strip", z.ZodTypeAny, {
|
|
268
|
+
id: string;
|
|
269
|
+
}, {
|
|
270
|
+
id: string;
|
|
271
|
+
}>;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
params: {
|
|
274
|
+
id: string;
|
|
275
|
+
};
|
|
276
|
+
}, {
|
|
277
|
+
params: {
|
|
278
|
+
id: string;
|
|
279
|
+
};
|
|
280
|
+
}>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activateUserSchema = exports.deactivateUserSchema = exports.unbanUserSchema = exports.banUserSchema = exports.unsuspendUserSchema = exports.suspendUserSchema = exports.deleteUserSchema = exports.getUsersSchema = exports.getUserSchema = exports.updateUserSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const auth_validations_1 = require("./auth.validations");
|
|
6
|
+
// Base user schema
|
|
7
|
+
const userBaseSchema = {
|
|
8
|
+
firstName: zod_1.z
|
|
9
|
+
.string()
|
|
10
|
+
.min(2, "First name must be at least 2 characters")
|
|
11
|
+
.max(100),
|
|
12
|
+
lastName: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.min(2, "Last name must be at least 2 characters")
|
|
15
|
+
.max(100),
|
|
16
|
+
phoneNumber: zod_1.z.string().regex(auth_validations_1.phoneRegex, "Invalid phone number format"),
|
|
17
|
+
jacketId: zod_1.z.string().max(100).nullable().optional(),
|
|
18
|
+
email: zod_1.z.string().email("Invalid email format").nullable().optional(),
|
|
19
|
+
password: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.min(6, "Password must be at least 6 characters")
|
|
22
|
+
.nullable()
|
|
23
|
+
.optional(),
|
|
24
|
+
plateNumber: zod_1.z.string().max(100).nullable().optional(),
|
|
25
|
+
nationalId: zod_1.z
|
|
26
|
+
.string()
|
|
27
|
+
.min(5, "National ID must be at least 5 characters")
|
|
28
|
+
.max(100),
|
|
29
|
+
};
|
|
30
|
+
// Update user schema
|
|
31
|
+
exports.updateUserSchema = zod_1.z.object({
|
|
32
|
+
params: zod_1.z.object({
|
|
33
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
34
|
+
}),
|
|
35
|
+
body: zod_1.z.object({
|
|
36
|
+
firstName: userBaseSchema.firstName.optional(),
|
|
37
|
+
lastName: userBaseSchema.lastName.optional(),
|
|
38
|
+
phoneNumber: userBaseSchema.phoneNumber.optional(),
|
|
39
|
+
jacketId: userBaseSchema.jacketId,
|
|
40
|
+
email: userBaseSchema.email,
|
|
41
|
+
plateNumber: userBaseSchema.plateNumber,
|
|
42
|
+
nationalId: userBaseSchema.nationalId.optional(),
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
// Get user by ID schema
|
|
46
|
+
exports.getUserSchema = zod_1.z.object({
|
|
47
|
+
params: zod_1.z.object({
|
|
48
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
// Get all users schema (with pagination)
|
|
52
|
+
exports.getUsersSchema = zod_1.z.object({
|
|
53
|
+
query: zod_1.z.object({
|
|
54
|
+
page: zod_1.z.string().regex(/^\d+$/).transform(Number).optional(),
|
|
55
|
+
limit: zod_1.z.string().regex(/^\d+$/).transform(Number).optional(),
|
|
56
|
+
search: zod_1.z.string().optional(),
|
|
57
|
+
isActive: zod_1.z.enum(["true", "false"]).optional(),
|
|
58
|
+
isSuspended: zod_1.z.enum(["true", "false"]).optional(),
|
|
59
|
+
isDeactivated: zod_1.z.enum(["true", "false"]).optional(),
|
|
60
|
+
securityClearanceId: zod_1.z.string().uuid().optional(),
|
|
61
|
+
sortBy: zod_1.z
|
|
62
|
+
.enum(["createdAt", "firstName", "lastName", "phoneNumber"])
|
|
63
|
+
.optional(),
|
|
64
|
+
sortOrder: zod_1.z.enum(["ASC", "DESC"]).optional(),
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
// Delete user schema
|
|
68
|
+
exports.deleteUserSchema = zod_1.z.object({
|
|
69
|
+
params: zod_1.z.object({
|
|
70
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
// Toggle user status schemas
|
|
74
|
+
exports.suspendUserSchema = zod_1.z.object({
|
|
75
|
+
params: zod_1.z.object({
|
|
76
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
77
|
+
}),
|
|
78
|
+
body: zod_1.z.object({
|
|
79
|
+
reason: zod_1.z.string().min(1, "Suspension reason is required"),
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
exports.unsuspendUserSchema = zod_1.z.object({
|
|
83
|
+
params: zod_1.z.object({
|
|
84
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
exports.banUserSchema = zod_1.z.object({
|
|
88
|
+
params: zod_1.z.object({
|
|
89
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
90
|
+
}),
|
|
91
|
+
body: zod_1.z.object({
|
|
92
|
+
reason: zod_1.z.string().min(1, "Ban reason is required"),
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
exports.unbanUserSchema = zod_1.z.object({
|
|
96
|
+
params: zod_1.z.object({
|
|
97
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
exports.deactivateUserSchema = zod_1.z.object({
|
|
101
|
+
params: zod_1.z.object({
|
|
102
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
105
|
+
exports.activateUserSchema = zod_1.z.object({
|
|
106
|
+
params: zod_1.z.object({
|
|
107
|
+
id: zod_1.z.string().uuid("Invalid user ID"),
|
|
108
|
+
}),
|
|
109
|
+
});
|