vr-commons 1.0.86 → 1.0.88
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/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 +152 -0
- package/dist/validations/users.operation.validations.js +72 -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;
|
|
@@ -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, deleteUserSchema, getUsersSchema, } 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.getUsersSchema = exports.deleteUserSchema = 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, "deleteUserSchema", { enumerable: true, get: function () { return users_operation_validations_1.deleteUserSchema; } });
|
|
80
|
+
Object.defineProperty(exports, "getUsersSchema", { enumerable: true, get: function () { return users_operation_validations_1.getUsersSchema; } });
|
|
@@ -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,152 @@
|
|
|
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
|
+
phoneNumber?: string | undefined;
|
|
22
|
+
jacketId?: string | null | undefined;
|
|
23
|
+
email?: string | null | undefined;
|
|
24
|
+
plateNumber?: string | null | undefined;
|
|
25
|
+
nationalId?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
firstName?: string | undefined;
|
|
28
|
+
lastName?: string | undefined;
|
|
29
|
+
phoneNumber?: string | undefined;
|
|
30
|
+
jacketId?: string | null | undefined;
|
|
31
|
+
email?: string | null | undefined;
|
|
32
|
+
plateNumber?: string | null | undefined;
|
|
33
|
+
nationalId?: string | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
params: {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
body: {
|
|
40
|
+
firstName?: string | undefined;
|
|
41
|
+
lastName?: string | undefined;
|
|
42
|
+
phoneNumber?: string | undefined;
|
|
43
|
+
jacketId?: string | null | undefined;
|
|
44
|
+
email?: string | null | undefined;
|
|
45
|
+
plateNumber?: string | null | undefined;
|
|
46
|
+
nationalId?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
params: {
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
body: {
|
|
53
|
+
firstName?: string | undefined;
|
|
54
|
+
lastName?: string | undefined;
|
|
55
|
+
phoneNumber?: string | undefined;
|
|
56
|
+
jacketId?: string | null | undefined;
|
|
57
|
+
email?: string | null | undefined;
|
|
58
|
+
plateNumber?: string | null | undefined;
|
|
59
|
+
nationalId?: 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
|
+
page?: number | undefined;
|
|
92
|
+
limit?: number | undefined;
|
|
93
|
+
search?: string | undefined;
|
|
94
|
+
isActive?: "true" | "false" | undefined;
|
|
95
|
+
isSuspended?: "true" | "false" | undefined;
|
|
96
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
97
|
+
securityClearanceId?: string | undefined;
|
|
98
|
+
sortBy?: "firstName" | "lastName" | "phoneNumber" | "createdAt" | undefined;
|
|
99
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
page?: string | undefined;
|
|
102
|
+
limit?: string | undefined;
|
|
103
|
+
search?: string | undefined;
|
|
104
|
+
isActive?: "true" | "false" | undefined;
|
|
105
|
+
isSuspended?: "true" | "false" | undefined;
|
|
106
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
107
|
+
securityClearanceId?: string | undefined;
|
|
108
|
+
sortBy?: "firstName" | "lastName" | "phoneNumber" | "createdAt" | undefined;
|
|
109
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
query: {
|
|
113
|
+
page?: number | undefined;
|
|
114
|
+
limit?: number | undefined;
|
|
115
|
+
search?: string | undefined;
|
|
116
|
+
isActive?: "true" | "false" | undefined;
|
|
117
|
+
isSuspended?: "true" | "false" | undefined;
|
|
118
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
119
|
+
securityClearanceId?: string | undefined;
|
|
120
|
+
sortBy?: "firstName" | "lastName" | "phoneNumber" | "createdAt" | undefined;
|
|
121
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
122
|
+
};
|
|
123
|
+
}, {
|
|
124
|
+
query: {
|
|
125
|
+
page?: string | undefined;
|
|
126
|
+
limit?: string | undefined;
|
|
127
|
+
search?: string | undefined;
|
|
128
|
+
isActive?: "true" | "false" | undefined;
|
|
129
|
+
isSuspended?: "true" | "false" | undefined;
|
|
130
|
+
isDeactivated?: "true" | "false" | undefined;
|
|
131
|
+
securityClearanceId?: string | undefined;
|
|
132
|
+
sortBy?: "firstName" | "lastName" | "phoneNumber" | "createdAt" | undefined;
|
|
133
|
+
sortOrder?: "ASC" | "DESC" | 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
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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
|
+
});
|