vr-commons 1.0.112 → 1.0.114
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/middlewares/auth.users.middlewares.js +2 -2
- package/dist/utils/profiles.utils.d.ts +1 -2
- package/dist/utils/profiles.utils.js +3 -4
- package/dist/validations/account.validations.d.ts +231 -0
- package/dist/validations/account.validations.js +136 -3
- package/dist/validations/admin.devicePayment.validations.d.ts +50 -50
- package/dist/validations/admin.devices.validations.d.ts +28 -28
- package/dist/validations/appSpecs.validations.d.ts +18 -18
- package/dist/validations/appeals.validations.d.ts +8 -8
- package/dist/validations/auth.validations.d.ts +189 -47
- package/dist/validations/auth.validations.js +133 -18
- package/dist/validations/bans.validations.d.ts +8 -8
- package/dist/validations/devicePaymentPlan.validations.d.ts +16 -16
- package/dist/validations/eventlogs.admin.validations.d.ts +14 -14
- package/dist/validations/moderation.validations.d.ts +114 -114
- package/dist/validations/payinstallment.validations.d.ts +5 -5
- package/dist/validations/pricing.validations.d.ts +30 -30
- package/dist/validations/pricings.validations.d.ts +30 -30
- package/dist/validations/product.validations.d.ts +28 -28
- package/dist/validations/profiles.validations.d.ts +265 -117
- package/dist/validations/profiles.validations.js +135 -46
- package/dist/validations/suspensions.validations.d.ts +8 -8
- package/dist/validations/users.admin.validations.d.ts +213 -62
- package/dist/validations/users.admin.validations.js +105 -13
- package/package.json +2 -2
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateProfileSchema = exports.deleteAccountSchema = exports.deactivateAccountSchema = exports.updateRiderProfileSchema = exports.createRiderSchema = exports.updatePassengerProfileSchema = exports.passengerSignupSchema = exports.viewProfileSchema = exports.getAllUsersSchema = exports.updateUserProfileSchema = exports.getUserByIdSchema = exports.createUserSchema = exports.jacketIdRegex = exports.phoneNumberRegex = void 0;
|
|
3
|
+
exports.setPrimaryContactSchema = exports.deleteContactSchema = exports.confirmVerificationSchema = exports.verifyContactSchema = exports.addContactSchema = exports.updateProfileSchema = exports.deleteAccountSchema = exports.deactivateAccountSchema = exports.updateRiderProfileSchema = exports.createRiderSchema = exports.updatePassengerProfileSchema = exports.passengerSignupSchema = exports.viewProfileSchema = exports.getAllUsersSchema = exports.updateUserProfileSchema = exports.getUserByIdSchema = exports.createUserSchema = exports.validateContactValue = exports.detectContactType = exports.strongPasswordRegex = exports.jacketIdRegex = exports.emailRegex = exports.phoneNumberRegex = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// ============================================================================
|
|
6
6
|
// COMMON VALIDATIONS
|
|
7
7
|
// ============================================================================
|
|
8
|
-
exports.phoneNumberRegex =
|
|
8
|
+
exports.phoneNumberRegex = /^\+250(78|79|73|72)[0-9]{7}$/;
|
|
9
|
+
exports.emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
9
10
|
exports.jacketIdRegex = /^JKT-\d{9}$/;
|
|
10
|
-
const
|
|
11
|
+
const plateRegex = /^[A-Z0-9]{3,10}$/i;
|
|
12
|
+
exports.strongPasswordRegex = /^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&#^()_\-+=])[A-Za-z\d@$!%*?&#^()_\-+=]{8,}$/;
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// CONTACT VALIDATION HELPERS
|
|
15
|
+
// ============================================================================
|
|
16
|
+
const detectContactType = (value) => {
|
|
17
|
+
if (!value)
|
|
18
|
+
return "UNKNOWN";
|
|
19
|
+
if (exports.emailRegex.test(value)) {
|
|
20
|
+
return "EMAIL";
|
|
21
|
+
}
|
|
22
|
+
if (exports.phoneNumberRegex.test(value)) {
|
|
23
|
+
return "PHONE";
|
|
24
|
+
}
|
|
25
|
+
return "UNKNOWN";
|
|
26
|
+
};
|
|
27
|
+
exports.detectContactType = detectContactType;
|
|
28
|
+
const validateContactValue = (value) => {
|
|
29
|
+
return exports.emailRegex.test(value) || exports.phoneNumberRegex.test(value);
|
|
30
|
+
};
|
|
31
|
+
exports.validateContactValue = validateContactValue;
|
|
11
32
|
// Birth date validation helpers
|
|
12
33
|
const isValidBirthDate = (date, month, year) => {
|
|
13
34
|
const maxDays = new Date(year, month, 0).getDate();
|
|
@@ -28,25 +49,22 @@ exports.createUserSchema = zod_1.z.object({
|
|
|
28
49
|
.string()
|
|
29
50
|
.min(2, "Last name must be at least 2 characters")
|
|
30
51
|
.max(100, "Last name cannot exceed 100 characters"),
|
|
31
|
-
|
|
52
|
+
contactValue: zod_1.z
|
|
32
53
|
.string()
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
.optional()
|
|
38
|
-
.nullable()
|
|
39
|
-
.or(zod_1.z.literal("")),
|
|
54
|
+
.min(1, "Email or phone number is required")
|
|
55
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
56
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
57
|
+
}),
|
|
40
58
|
password: zod_1.z
|
|
41
59
|
.string()
|
|
42
|
-
.
|
|
43
|
-
.max(100, "Password cannot exceed 100 characters")
|
|
60
|
+
.regex(exports.strongPasswordRegex, "Password must be at least 8 characters, include 1 uppercase letter, 1 number and 1 symbol")
|
|
44
61
|
.optional(),
|
|
45
62
|
role: zod_1.z.enum(["AGENT", "RIDER", "PASSENGER", "ADMIN", "SUPER_ADMIN"], {
|
|
46
63
|
errorMap: () => ({ message: "Invalid role specified" }),
|
|
47
64
|
}),
|
|
48
65
|
plateNumber: zod_1.z
|
|
49
66
|
.string()
|
|
67
|
+
.regex(plateRegex, "Invalid plate number format")
|
|
50
68
|
.max(20, "Plate number cannot exceed 20 characters")
|
|
51
69
|
.optional()
|
|
52
70
|
.nullable(),
|
|
@@ -104,28 +122,23 @@ exports.updateUserProfileSchema = zod_1.z.object({
|
|
|
104
122
|
.min(2, "Last name must be at least 2 characters")
|
|
105
123
|
.max(100, "Last name cannot exceed 100 characters")
|
|
106
124
|
.optional(),
|
|
107
|
-
|
|
108
|
-
.string()
|
|
109
|
-
.email("Invalid email address")
|
|
110
|
-
.optional()
|
|
111
|
-
.nullable()
|
|
112
|
-
.or(zod_1.z.literal("")),
|
|
113
|
-
phoneNumber: zod_1.z
|
|
125
|
+
contactValue: zod_1.z
|
|
114
126
|
.string()
|
|
115
|
-
.
|
|
127
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
128
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
129
|
+
})
|
|
116
130
|
.optional(),
|
|
117
131
|
plateNumber: zod_1.z
|
|
118
132
|
.string()
|
|
133
|
+
.regex(plateRegex, "Invalid plate number format")
|
|
119
134
|
.max(20, "Plate number cannot exceed 20 characters")
|
|
120
135
|
.optional()
|
|
121
136
|
.nullable(),
|
|
122
137
|
isActive: zod_1.z.boolean().optional(),
|
|
123
|
-
isSuspended: zod_1.z.boolean().optional(),
|
|
124
138
|
isDeactivated: zod_1.z.boolean().optional(),
|
|
125
139
|
password: zod_1.z
|
|
126
140
|
.string()
|
|
127
|
-
.
|
|
128
|
-
.max(100, "Password cannot exceed 100 characters")
|
|
141
|
+
.regex(exports.strongPasswordRegex, "Password must be at least 8 characters, include 1 uppercase letter, 1 number and 1 symbol")
|
|
129
142
|
.optional(),
|
|
130
143
|
gender: zod_1.z.enum(["male", "female"]).optional(),
|
|
131
144
|
birthDate: zod_1.z.number().min(1).max(31).optional(),
|
|
@@ -172,15 +185,12 @@ exports.getAllUsersSchema = zod_1.z.object({
|
|
|
172
185
|
.enum(["true", "false"])
|
|
173
186
|
.transform((val) => val === "true")
|
|
174
187
|
.optional(),
|
|
175
|
-
|
|
176
|
-
.enum(["true", "false"])
|
|
177
|
-
.transform((val) => val === "true")
|
|
178
|
-
.optional(),
|
|
179
|
-
isBanned: zod_1.z
|
|
188
|
+
isDeactivated: zod_1.z
|
|
180
189
|
.enum(["true", "false"])
|
|
181
190
|
.transform((val) => val === "true")
|
|
182
191
|
.optional(),
|
|
183
192
|
gender: zod_1.z.enum(["male", "female"]).optional(),
|
|
193
|
+
contactType: zod_1.z.enum(["EMAIL", "PHONE", "WHATSAPP"]).optional(),
|
|
184
194
|
search: zod_1.z.string().optional(),
|
|
185
195
|
startDate: zod_1.z.string().optional(),
|
|
186
196
|
endDate: zod_1.z.string().optional(),
|
|
@@ -224,27 +234,24 @@ exports.passengerSignupSchema = zod_1.z.object({
|
|
|
224
234
|
.string()
|
|
225
235
|
.min(2, "Last name must be at least 2 characters")
|
|
226
236
|
.max(100, "Last name cannot exceed 100 characters"),
|
|
227
|
-
|
|
237
|
+
contactValue: zod_1.z
|
|
228
238
|
.string()
|
|
229
|
-
.
|
|
239
|
+
.min(1, "Email or phone number is required")
|
|
240
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
241
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
242
|
+
}),
|
|
230
243
|
jacketId: zod_1.z
|
|
231
244
|
.string()
|
|
232
245
|
.regex(exports.jacketIdRegex, "Jacket ID must be in format JKT-000000000")
|
|
233
246
|
.optional(),
|
|
234
|
-
email: zod_1.z
|
|
235
|
-
.string()
|
|
236
|
-
.email("Invalid email address")
|
|
237
|
-
.optional()
|
|
238
|
-
.nullable()
|
|
239
|
-
.or(zod_1.z.literal("")),
|
|
240
247
|
password: zod_1.z
|
|
241
248
|
.string()
|
|
242
|
-
.
|
|
243
|
-
.max(100, "Password cannot exceed 100 characters")
|
|
249
|
+
.regex(exports.strongPasswordRegex, "Password must be at least 8 characters, include 1 uppercase letter, 1 number and 1 symbol")
|
|
244
250
|
.optional()
|
|
245
251
|
.nullable(),
|
|
246
252
|
plateNumber: zod_1.z
|
|
247
253
|
.string()
|
|
254
|
+
.regex(plateRegex, "Invalid plate number format")
|
|
248
255
|
.max(20, "Plate number cannot exceed 20 characters")
|
|
249
256
|
.optional()
|
|
250
257
|
.nullable(),
|
|
@@ -280,6 +287,12 @@ exports.updatePassengerProfileSchema = zod_1.z.object({
|
|
|
280
287
|
.min(2, "Last name must be at least 2 characters")
|
|
281
288
|
.max(100, "Last name cannot exceed 100 characters")
|
|
282
289
|
.optional(),
|
|
290
|
+
contactValue: zod_1.z
|
|
291
|
+
.string()
|
|
292
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
293
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
294
|
+
})
|
|
295
|
+
.optional(),
|
|
283
296
|
gender: zod_1.z.enum(["male", "female"]).optional(),
|
|
284
297
|
birthDate: zod_1.z.number().min(1).max(31).optional(),
|
|
285
298
|
birthMonth: zod_1.z.number().min(1).max(12).optional(),
|
|
@@ -327,11 +340,15 @@ exports.createRiderSchema = zod_1.z.object({
|
|
|
327
340
|
.string()
|
|
328
341
|
.min(2, "Last name must be at least 2 characters")
|
|
329
342
|
.max(100, "Last name cannot exceed 100 characters"),
|
|
330
|
-
|
|
343
|
+
contactValue: zod_1.z
|
|
331
344
|
.string()
|
|
332
|
-
.
|
|
345
|
+
.min(1, "Email or phone number is required")
|
|
346
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
347
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
348
|
+
}),
|
|
333
349
|
plateNumber: zod_1.z
|
|
334
350
|
.string()
|
|
351
|
+
.regex(plateRegex, "Invalid plate number format")
|
|
335
352
|
.max(20, "Plate number cannot exceed 20 characters"),
|
|
336
353
|
jacketId: zod_1.z
|
|
337
354
|
.string()
|
|
@@ -371,12 +388,15 @@ exports.updateRiderProfileSchema = zod_1.z.object({
|
|
|
371
388
|
.min(2, "Last name must be at least 2 characters")
|
|
372
389
|
.max(100, "Last name cannot exceed 100 characters")
|
|
373
390
|
.optional(),
|
|
374
|
-
|
|
391
|
+
contactValue: zod_1.z
|
|
375
392
|
.string()
|
|
376
|
-
.
|
|
393
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
394
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
395
|
+
})
|
|
377
396
|
.optional(),
|
|
378
397
|
plateNumber: zod_1.z
|
|
379
398
|
.string()
|
|
399
|
+
.regex(plateRegex, "Invalid plate number format")
|
|
380
400
|
.max(20, "Plate number cannot exceed 20 characters")
|
|
381
401
|
.optional(),
|
|
382
402
|
jacketId: zod_1.z
|
|
@@ -456,16 +476,18 @@ exports.deleteAccountSchema = zod_1.z.object({
|
|
|
456
476
|
}),
|
|
457
477
|
}),
|
|
458
478
|
});
|
|
479
|
+
// Update Profile Schema (for users)
|
|
459
480
|
exports.updateProfileSchema = zod_1.z.object({
|
|
460
481
|
body: zod_1.z
|
|
461
482
|
.object({
|
|
462
483
|
firstName: zod_1.z.string().min(2).max(50).optional(),
|
|
463
484
|
lastName: zod_1.z.string().min(2).max(50).optional(),
|
|
464
|
-
|
|
485
|
+
contactValue: zod_1.z
|
|
465
486
|
.string()
|
|
466
|
-
.
|
|
487
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
488
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
489
|
+
})
|
|
467
490
|
.optional(),
|
|
468
|
-
email: zod_1.z.string().email("Invalid email").optional(),
|
|
469
491
|
gender: zod_1.z.enum(["male", "female"]).optional(),
|
|
470
492
|
birthDate: zod_1.z.number().min(1).max(31).optional(),
|
|
471
493
|
birthMonth: zod_1.z.number().min(1).max(12).optional(),
|
|
@@ -492,3 +514,70 @@ exports.updateProfileSchema = zod_1.z.object({
|
|
|
492
514
|
path: ["birthDate"],
|
|
493
515
|
}),
|
|
494
516
|
});
|
|
517
|
+
// ============================================================================
|
|
518
|
+
// CONTACT MANAGEMENT SCHEMAS
|
|
519
|
+
// ============================================================================
|
|
520
|
+
// Add Contact Schema
|
|
521
|
+
exports.addContactSchema = zod_1.z.object({
|
|
522
|
+
body: zod_1.z.object({
|
|
523
|
+
contactValue: zod_1.z
|
|
524
|
+
.string()
|
|
525
|
+
.min(1, "Email or phone number is required")
|
|
526
|
+
.refine((val) => (0, exports.validateContactValue)(val), {
|
|
527
|
+
message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
|
|
528
|
+
}),
|
|
529
|
+
type: zod_1.z.enum(["EMAIL", "PHONE", "WHATSAPP"]).optional(),
|
|
530
|
+
}),
|
|
531
|
+
headers: zod_1.z.object({
|
|
532
|
+
authorization: zod_1.z.string().regex(/^Bearer /, {
|
|
533
|
+
message: "Authorization header must start with 'Bearer '",
|
|
534
|
+
}),
|
|
535
|
+
}),
|
|
536
|
+
});
|
|
537
|
+
// Verify Contact Schema (send OTP)
|
|
538
|
+
exports.verifyContactSchema = zod_1.z.object({
|
|
539
|
+
params: zod_1.z.object({
|
|
540
|
+
contactId: zod_1.z.string().uuid("Invalid contact ID format"),
|
|
541
|
+
}),
|
|
542
|
+
headers: zod_1.z.object({
|
|
543
|
+
authorization: zod_1.z.string().regex(/^Bearer /, {
|
|
544
|
+
message: "Authorization header must start with 'Bearer '",
|
|
545
|
+
}),
|
|
546
|
+
}),
|
|
547
|
+
});
|
|
548
|
+
// Confirm Verification Schema
|
|
549
|
+
exports.confirmVerificationSchema = zod_1.z.object({
|
|
550
|
+
body: zod_1.z.object({
|
|
551
|
+
otp: zod_1.z.string().length(6, "OTP must be 6 digits"),
|
|
552
|
+
}),
|
|
553
|
+
params: zod_1.z.object({
|
|
554
|
+
contactId: zod_1.z.string().uuid("Invalid contact ID format"),
|
|
555
|
+
}),
|
|
556
|
+
headers: zod_1.z.object({
|
|
557
|
+
authorization: zod_1.z.string().regex(/^Bearer /, {
|
|
558
|
+
message: "Authorization header must start with 'Bearer '",
|
|
559
|
+
}),
|
|
560
|
+
}),
|
|
561
|
+
});
|
|
562
|
+
// Delete Contact Schema
|
|
563
|
+
exports.deleteContactSchema = zod_1.z.object({
|
|
564
|
+
params: zod_1.z.object({
|
|
565
|
+
contactId: zod_1.z.string().uuid("Invalid contact ID format"),
|
|
566
|
+
}),
|
|
567
|
+
headers: zod_1.z.object({
|
|
568
|
+
authorization: zod_1.z.string().regex(/^Bearer /, {
|
|
569
|
+
message: "Authorization header must start with 'Bearer '",
|
|
570
|
+
}),
|
|
571
|
+
}),
|
|
572
|
+
});
|
|
573
|
+
// Set Primary Contact Schema
|
|
574
|
+
exports.setPrimaryContactSchema = zod_1.z.object({
|
|
575
|
+
params: zod_1.z.object({
|
|
576
|
+
contactId: zod_1.z.string().uuid("Invalid contact ID format"),
|
|
577
|
+
}),
|
|
578
|
+
headers: zod_1.z.object({
|
|
579
|
+
authorization: zod_1.z.string().regex(/^Bearer /, {
|
|
580
|
+
message: "Authorization header must start with 'Bearer '",
|
|
581
|
+
}),
|
|
582
|
+
}),
|
|
583
|
+
});
|
|
@@ -35,21 +35,21 @@ export declare const getUserSuspensionsSchema: z.ZodObject<{
|
|
|
35
35
|
includeResolved?: "true" | "false" | undefined;
|
|
36
36
|
}>;
|
|
37
37
|
}, "strip", z.ZodTypeAny, {
|
|
38
|
-
params: {
|
|
39
|
-
userId: string;
|
|
40
|
-
};
|
|
41
38
|
query: {
|
|
42
39
|
status?: "active" | "expired" | "revoked" | undefined;
|
|
43
40
|
includeResolved?: "true" | "false" | undefined;
|
|
44
41
|
};
|
|
45
|
-
}, {
|
|
46
42
|
params: {
|
|
47
43
|
userId: string;
|
|
48
44
|
};
|
|
45
|
+
}, {
|
|
49
46
|
query: {
|
|
50
47
|
status?: "active" | "expired" | "revoked" | undefined;
|
|
51
48
|
includeResolved?: "true" | "false" | undefined;
|
|
52
49
|
};
|
|
50
|
+
params: {
|
|
51
|
+
userId: string;
|
|
52
|
+
};
|
|
53
53
|
}>;
|
|
54
54
|
export declare const createSuspensionSchema: z.ZodObject<{
|
|
55
55
|
params: z.ZodObject<{
|
|
@@ -70,19 +70,19 @@ export declare const createSuspensionSchema: z.ZodObject<{
|
|
|
70
70
|
endsAt: string;
|
|
71
71
|
}>;
|
|
72
72
|
}, "strip", z.ZodTypeAny, {
|
|
73
|
-
params: {
|
|
74
|
-
userId: string;
|
|
75
|
-
};
|
|
76
73
|
body: {
|
|
77
74
|
reason: string;
|
|
78
75
|
endsAt: string;
|
|
79
76
|
};
|
|
80
|
-
}, {
|
|
81
77
|
params: {
|
|
82
78
|
userId: string;
|
|
83
79
|
};
|
|
80
|
+
}, {
|
|
84
81
|
body: {
|
|
85
82
|
reason: string;
|
|
86
83
|
endsAt: string;
|
|
87
84
|
};
|
|
85
|
+
params: {
|
|
86
|
+
userId: string;
|
|
87
|
+
};
|
|
88
88
|
}>;
|