vr-commons 1.0.99 → 1.0.101
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.middlewares.d.ts → admin/auth.admin.middlewares.d.ts} +0 -1
- package/dist/middlewares/admin/auth.admin.middlewares.js +60 -0
- package/dist/middlewares/admin/index.d.ts +1 -0
- package/dist/middlewares/admin/index.js +5 -0
- package/dist/middlewares/index.d.ts +3 -2
- package/dist/middlewares/index.js +17 -8
- package/dist/middlewares/{account.middlewares.js → shared/account.shared.middlewares.js} +2 -2
- package/dist/middlewares/shared/index.d.ts +1 -0
- package/dist/middlewares/shared/index.js +7 -0
- package/dist/middlewares/users/auth.users.middlewares.d.ts +3 -0
- package/dist/middlewares/{auth.middlewares.js → users/auth.users.middlewares.js} +3 -54
- package/dist/middlewares/users/index.d.ts +1 -0
- package/dist/middlewares/users/index.js +5 -0
- package/dist/validations/admin.devicePayment.validations.d.ts +36 -36
- package/dist/validations/admin.devices.validations.d.ts +32 -32
- package/package.json +1 -1
- package/dist/validations/user.management.validations.d.ts +0 -56
- package/dist/validations/user.management.validations.js +0 -40
- package/dist/validations/users.operation.validations.d.ts +0 -152
- package/dist/validations/users.operation.validations.js +0 -72
- /package/dist/middlewares/{account.middlewares.d.ts → shared/account.shared.middlewares.d.ts} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from "express";
|
|
2
2
|
import { UserRole } from "vr-models";
|
|
3
|
-
export declare const checkUserAuthentication: (allowedRoles: UserRole[]) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4
3
|
export declare const checkAdminAuthentication: (allowedRoles: UserRole[]) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkAdminAuthentication = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const vr_models_1 = require("vr-models");
|
|
9
|
+
const response_utils_1 = require("../../utils/response.utils");
|
|
10
|
+
const checkAdminAuthentication = (allowedRoles) => async (req, res, next) => {
|
|
11
|
+
try {
|
|
12
|
+
const token = req.cookies?.access_token;
|
|
13
|
+
if (!token) {
|
|
14
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Authentication required", 401);
|
|
15
|
+
}
|
|
16
|
+
let payload;
|
|
17
|
+
try {
|
|
18
|
+
payload = jsonwebtoken_1.default.verify(token, process.env.JWT_SECRET);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof jsonwebtoken_1.default.TokenExpiredError) {
|
|
22
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Session expired. Please login again.", 401);
|
|
23
|
+
}
|
|
24
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Invalid session", 401);
|
|
25
|
+
}
|
|
26
|
+
const user = await vr_models_1.User.findOne({
|
|
27
|
+
where: { id: payload.userId },
|
|
28
|
+
include: [
|
|
29
|
+
{
|
|
30
|
+
model: vr_models_1.SecurityClearance,
|
|
31
|
+
as: "securityClearance",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
if (!user || !user.securityClearance) {
|
|
36
|
+
return (0, response_utils_1.sendErrorResponse)(res, "User not found", 400);
|
|
37
|
+
}
|
|
38
|
+
// 🔐 Token versioning
|
|
39
|
+
if (user.tokenVersion !== payload.tokenVersion) {
|
|
40
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Session expired", 401);
|
|
41
|
+
}
|
|
42
|
+
// 🧱 Role enforcement
|
|
43
|
+
if (!allowedRoles.includes(user.securityClearance.role)) {
|
|
44
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Access denied", 403);
|
|
45
|
+
}
|
|
46
|
+
// Attach user to request (same as before)
|
|
47
|
+
req.userId = user.id;
|
|
48
|
+
req.firstName = user.firstName;
|
|
49
|
+
req.lastName = user.lastName;
|
|
50
|
+
req.scRole = user.securityClearance.role;
|
|
51
|
+
req.scLevel = user.securityClearance.level;
|
|
52
|
+
req.tokenVersion = user.tokenVersion;
|
|
53
|
+
next();
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error("Authentication error:", error);
|
|
57
|
+
next(error);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.checkAdminAuthentication = checkAdminAuthentication;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkAdminAuthentication } from "./auth.admin.middlewares";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAdminAuthentication = void 0;
|
|
4
|
+
var auth_admin_middlewares_1 = require("./auth.admin.middlewares");
|
|
5
|
+
Object.defineProperty(exports, "checkAdminAuthentication", { enumerable: true, get: function () { return auth_admin_middlewares_1.checkAdminAuthentication; } });
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from "./admin";
|
|
2
|
+
export * from "./shared";
|
|
3
|
+
export * from "./users";
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "checkAdminAuthentication", { enumerable: true, get: function () { return auth_middlewares_1.checkAdminAuthentication; } });
|
|
7
|
-
var account_middlewares_1 = require("./account.middlewares");
|
|
8
|
-
Object.defineProperty(exports, "checkUserAccountStatus", { enumerable: true, get: function () { return account_middlewares_1.checkUserAccountStatus; } });
|
|
9
|
-
Object.defineProperty(exports, "checkIsUserBanned", { enumerable: true, get: function () { return account_middlewares_1.checkIsUserBanned; } });
|
|
10
|
-
Object.defineProperty(exports, "checkIsUserSuspended", { enumerable: true, get: function () { return account_middlewares_1.checkIsUserSuspended; } });
|
|
17
|
+
__exportStar(require("./admin"), exports);
|
|
18
|
+
__exportStar(require("./shared"), exports);
|
|
19
|
+
__exportStar(require("./users"), exports);
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.checkIsUserBanned = checkIsUserBanned;
|
|
4
4
|
exports.checkIsUserSuspended = checkIsUserSuspended;
|
|
5
5
|
exports.checkUserAccountStatus = checkUserAccountStatus;
|
|
6
|
-
const account_utils_1 = require("
|
|
7
|
-
const response_utils_1 = require("
|
|
6
|
+
const account_utils_1 = require("../../utils/account.utils");
|
|
7
|
+
const response_utils_1 = require("../../utils/response.utils");
|
|
8
8
|
// Check if user is banned
|
|
9
9
|
async function checkIsUserBanned(req, res, next) {
|
|
10
10
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkIsUserBanned, checkIsUserSuspended, checkUserAccountStatus, } from "./account.shared.middlewares";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkUserAccountStatus = exports.checkIsUserSuspended = exports.checkIsUserBanned = void 0;
|
|
4
|
+
var account_shared_middlewares_1 = require("./account.shared.middlewares");
|
|
5
|
+
Object.defineProperty(exports, "checkIsUserBanned", { enumerable: true, get: function () { return account_shared_middlewares_1.checkIsUserBanned; } });
|
|
6
|
+
Object.defineProperty(exports, "checkIsUserSuspended", { enumerable: true, get: function () { return account_shared_middlewares_1.checkIsUserSuspended; } });
|
|
7
|
+
Object.defineProperty(exports, "checkUserAccountStatus", { enumerable: true, get: function () { return account_shared_middlewares_1.checkUserAccountStatus; } });
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.checkUserAuthentication = void 0;
|
|
7
7
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
8
|
const vr_models_1 = require("vr-models");
|
|
9
|
-
const response_utils_1 = require("
|
|
10
|
-
const authTokens_utils_1 = require("
|
|
9
|
+
const response_utils_1 = require("../../utils/response.utils");
|
|
10
|
+
const authTokens_utils_1 = require("../../utils/authTokens.utils");
|
|
11
11
|
const checkUserAuthentication = (allowedRoles) => async (req, res, next) => {
|
|
12
12
|
try {
|
|
13
13
|
const authHeader = req.headers.authorization;
|
|
@@ -78,54 +78,3 @@ const checkUserAuthentication = (allowedRoles) => async (req, res, next) => {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
exports.checkUserAuthentication = checkUserAuthentication;
|
|
81
|
-
const checkAdminAuthentication = (allowedRoles) => async (req, res, next) => {
|
|
82
|
-
try {
|
|
83
|
-
const token = req.cookies?.access_token;
|
|
84
|
-
if (!token) {
|
|
85
|
-
return (0, response_utils_1.sendErrorResponse)(res, "Authentication required", 401);
|
|
86
|
-
}
|
|
87
|
-
let payload;
|
|
88
|
-
try {
|
|
89
|
-
payload = jsonwebtoken_1.default.verify(token, process.env.JWT_SECRET);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
if (error instanceof jsonwebtoken_1.default.TokenExpiredError) {
|
|
93
|
-
return (0, response_utils_1.sendErrorResponse)(res, "Session expired. Please login again.", 401);
|
|
94
|
-
}
|
|
95
|
-
return (0, response_utils_1.sendErrorResponse)(res, "Invalid session", 401);
|
|
96
|
-
}
|
|
97
|
-
const user = await vr_models_1.User.findOne({
|
|
98
|
-
where: { id: payload.userId },
|
|
99
|
-
include: [
|
|
100
|
-
{
|
|
101
|
-
model: vr_models_1.SecurityClearance,
|
|
102
|
-
as: "securityClearance",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
});
|
|
106
|
-
if (!user || !user.securityClearance) {
|
|
107
|
-
return (0, response_utils_1.sendErrorResponse)(res, "User not found", 400);
|
|
108
|
-
}
|
|
109
|
-
// 🔐 Token versioning
|
|
110
|
-
if (user.tokenVersion !== payload.tokenVersion) {
|
|
111
|
-
return (0, response_utils_1.sendErrorResponse)(res, "Session expired", 401);
|
|
112
|
-
}
|
|
113
|
-
// 🧱 Role enforcement
|
|
114
|
-
if (!allowedRoles.includes(user.securityClearance.role)) {
|
|
115
|
-
return (0, response_utils_1.sendErrorResponse)(res, "Access denied", 403);
|
|
116
|
-
}
|
|
117
|
-
// Attach user to request (same as before)
|
|
118
|
-
req.userId = user.id;
|
|
119
|
-
req.firstName = user.firstName;
|
|
120
|
-
req.lastName = user.lastName;
|
|
121
|
-
req.scRole = user.securityClearance.role;
|
|
122
|
-
req.scLevel = user.securityClearance.level;
|
|
123
|
-
req.tokenVersion = user.tokenVersion;
|
|
124
|
-
next();
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
console.error("Authentication error:", error);
|
|
128
|
-
next(error);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
exports.checkAdminAuthentication = checkAdminAuthentication;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkUserAuthentication } from "./auth.users.middlewares";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkUserAuthentication = void 0;
|
|
4
|
+
var auth_users_middlewares_1 = require("./auth.users.middlewares");
|
|
5
|
+
Object.defineProperty(exports, "checkUserAuthentication", { enumerable: true, get: function () { return auth_users_middlewares_1.checkUserAuthentication; } });
|
|
@@ -38,49 +38,49 @@ export declare const listPlansSchema: z.ZodObject<{
|
|
|
38
38
|
sortBy: z.ZodOptional<z.ZodEnum<["createdAt", "updatedAt", "nextInstallmentDueAt", "paidAmount", "outstandingAmount"]>>;
|
|
39
39
|
sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
|
|
40
40
|
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
page: number;
|
|
42
41
|
limit: number;
|
|
43
|
-
|
|
42
|
+
page: number;
|
|
43
|
+
search?: string | undefined;
|
|
44
44
|
userId?: string | undefined;
|
|
45
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
46
|
+
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
47
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
45
48
|
deviceId?: string | undefined;
|
|
46
49
|
isOverdue?: "true" | "false" | undefined;
|
|
47
|
-
search?: string | undefined;
|
|
48
|
-
sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
|
|
49
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
50
50
|
}, {
|
|
51
|
-
|
|
51
|
+
search?: string | undefined;
|
|
52
|
+
limit?: string | undefined;
|
|
52
53
|
userId?: string | undefined;
|
|
54
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
53
55
|
page?: string | undefined;
|
|
54
|
-
|
|
56
|
+
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
57
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
55
58
|
deviceId?: string | undefined;
|
|
56
59
|
isOverdue?: "true" | "false" | undefined;
|
|
57
|
-
search?: string | undefined;
|
|
58
|
-
sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
|
|
59
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
60
60
|
}>;
|
|
61
61
|
}, "strip", z.ZodTypeAny, {
|
|
62
62
|
query: {
|
|
63
|
-
page: number;
|
|
64
63
|
limit: number;
|
|
65
|
-
|
|
64
|
+
page: number;
|
|
65
|
+
search?: string | undefined;
|
|
66
66
|
userId?: string | undefined;
|
|
67
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
68
|
+
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
69
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
67
70
|
deviceId?: string | undefined;
|
|
68
71
|
isOverdue?: "true" | "false" | undefined;
|
|
69
|
-
search?: string | undefined;
|
|
70
|
-
sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
|
|
71
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
72
72
|
};
|
|
73
73
|
}, {
|
|
74
74
|
query: {
|
|
75
|
-
|
|
75
|
+
search?: string | undefined;
|
|
76
|
+
limit?: string | undefined;
|
|
76
77
|
userId?: string | undefined;
|
|
78
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
77
79
|
page?: string | undefined;
|
|
78
|
-
|
|
80
|
+
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
81
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
79
82
|
deviceId?: string | undefined;
|
|
80
83
|
isOverdue?: "true" | "false" | undefined;
|
|
81
|
-
search?: string | undefined;
|
|
82
|
-
sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
|
|
83
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
84
84
|
};
|
|
85
85
|
}>;
|
|
86
86
|
export declare const getPlanSchema: z.ZodObject<{
|
|
@@ -112,10 +112,10 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
112
112
|
status: z.ZodOptional<z.ZodEnum<["ACTIVE", "COMPLETED", "DEFAULTED", "CANCELLED"]>>;
|
|
113
113
|
includeCompleted: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
114
114
|
}, "strip", z.ZodTypeAny, {
|
|
115
|
-
status?: "ACTIVE" | "
|
|
115
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
116
116
|
includeCompleted?: "true" | "false" | undefined;
|
|
117
117
|
}, {
|
|
118
|
-
status?: "ACTIVE" | "
|
|
118
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
119
119
|
includeCompleted?: "true" | "false" | undefined;
|
|
120
120
|
}>>;
|
|
121
121
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -123,7 +123,7 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
123
123
|
userId: string;
|
|
124
124
|
};
|
|
125
125
|
query?: {
|
|
126
|
-
status?: "ACTIVE" | "
|
|
126
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
127
127
|
includeCompleted?: "true" | "false" | undefined;
|
|
128
128
|
} | undefined;
|
|
129
129
|
}, {
|
|
@@ -131,7 +131,7 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
131
131
|
userId: string;
|
|
132
132
|
};
|
|
133
133
|
query?: {
|
|
134
|
-
status?: "ACTIVE" | "
|
|
134
|
+
status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
|
|
135
135
|
includeCompleted?: "true" | "false" | undefined;
|
|
136
136
|
} | undefined;
|
|
137
137
|
}>;
|
|
@@ -177,21 +177,21 @@ export declare const limitedUpdateSchema: z.ZodObject<{
|
|
|
177
177
|
pricingId?: string | undefined;
|
|
178
178
|
}>;
|
|
179
179
|
}, "strip", z.ZodTypeAny, {
|
|
180
|
-
params: {
|
|
181
|
-
id: string;
|
|
182
|
-
};
|
|
183
180
|
body: {
|
|
184
181
|
userId?: string | undefined;
|
|
185
182
|
pricingId?: string | undefined;
|
|
186
183
|
};
|
|
187
|
-
}, {
|
|
188
184
|
params: {
|
|
189
185
|
id: string;
|
|
190
186
|
};
|
|
187
|
+
}, {
|
|
191
188
|
body: {
|
|
192
189
|
userId?: string | undefined;
|
|
193
190
|
pricingId?: string | undefined;
|
|
194
191
|
};
|
|
192
|
+
params: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
195
195
|
}>;
|
|
196
196
|
export declare const recordPaymentSchema: z.ZodObject<{
|
|
197
197
|
params: z.ZodObject<{
|
|
@@ -209,33 +209,33 @@ export declare const recordPaymentSchema: z.ZodObject<{
|
|
|
209
209
|
}, "strip", z.ZodTypeAny, {
|
|
210
210
|
amount: number;
|
|
211
211
|
provider: "mtn_momo" | "airtel_money";
|
|
212
|
-
providerReference?: string | undefined;
|
|
213
212
|
metadata?: Record<string, any> | undefined;
|
|
213
|
+
providerReference?: string | undefined;
|
|
214
214
|
}, {
|
|
215
215
|
amount: number;
|
|
216
216
|
provider: "mtn_momo" | "airtel_money";
|
|
217
|
-
providerReference?: string | undefined;
|
|
218
217
|
metadata?: Record<string, any> | undefined;
|
|
218
|
+
providerReference?: string | undefined;
|
|
219
219
|
}>;
|
|
220
220
|
}, "strip", z.ZodTypeAny, {
|
|
221
|
-
params: {
|
|
222
|
-
id: string;
|
|
223
|
-
};
|
|
224
221
|
body: {
|
|
225
222
|
amount: number;
|
|
226
223
|
provider: "mtn_momo" | "airtel_money";
|
|
227
|
-
providerReference?: string | undefined;
|
|
228
224
|
metadata?: Record<string, any> | undefined;
|
|
225
|
+
providerReference?: string | undefined;
|
|
229
226
|
};
|
|
230
|
-
}, {
|
|
231
227
|
params: {
|
|
232
228
|
id: string;
|
|
233
229
|
};
|
|
230
|
+
}, {
|
|
234
231
|
body: {
|
|
235
232
|
amount: number;
|
|
236
233
|
provider: "mtn_momo" | "airtel_money";
|
|
237
|
-
providerReference?: string | undefined;
|
|
238
234
|
metadata?: Record<string, any> | undefined;
|
|
235
|
+
providerReference?: string | undefined;
|
|
236
|
+
};
|
|
237
|
+
params: {
|
|
238
|
+
id: string;
|
|
239
239
|
};
|
|
240
240
|
}>;
|
|
241
241
|
export declare const deletePlanSchema: z.ZodObject<{
|
|
@@ -4,21 +4,21 @@ export declare const createDeviceSchema: z.ZodObject<{
|
|
|
4
4
|
serialNumber: z.ZodString;
|
|
5
5
|
productId: z.ZodString;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
serialNumber: string;
|
|
8
7
|
productId: string;
|
|
9
|
-
}, {
|
|
10
8
|
serialNumber: string;
|
|
9
|
+
}, {
|
|
11
10
|
productId: string;
|
|
11
|
+
serialNumber: string;
|
|
12
12
|
}>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
body: {
|
|
15
|
-
serialNumber: string;
|
|
16
15
|
productId: string;
|
|
16
|
+
serialNumber: string;
|
|
17
17
|
};
|
|
18
18
|
}, {
|
|
19
19
|
body: {
|
|
20
|
-
serialNumber: string;
|
|
21
20
|
productId: string;
|
|
21
|
+
serialNumber: string;
|
|
22
22
|
};
|
|
23
23
|
}>;
|
|
24
24
|
export declare const bulkCreateDevicesSchema: z.ZodObject<{
|
|
@@ -65,23 +65,23 @@ export declare const updateDeviceSchema: z.ZodObject<{
|
|
|
65
65
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
66
66
|
}>;
|
|
67
67
|
}, "strip", z.ZodTypeAny, {
|
|
68
|
-
params: {
|
|
69
|
-
id: string;
|
|
70
|
-
};
|
|
71
68
|
body: {
|
|
72
69
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
73
70
|
serialNumber?: string | undefined;
|
|
74
71
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
75
72
|
};
|
|
76
|
-
}, {
|
|
77
73
|
params: {
|
|
78
74
|
id: string;
|
|
79
75
|
};
|
|
76
|
+
}, {
|
|
80
77
|
body: {
|
|
81
78
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
82
79
|
serialNumber?: string | undefined;
|
|
83
80
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
84
81
|
};
|
|
82
|
+
params: {
|
|
83
|
+
id: string;
|
|
84
|
+
};
|
|
85
85
|
}>;
|
|
86
86
|
export declare const getDeviceSchema: z.ZodObject<{
|
|
87
87
|
params: z.ZodObject<{
|
|
@@ -113,53 +113,53 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
113
113
|
sortBy: z.ZodOptional<z.ZodEnum<["serialNumber", "status", "createdAt", "updatedAt"]>>;
|
|
114
114
|
sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
|
|
115
115
|
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
search?: string | undefined;
|
|
117
|
+
limit?: number | undefined;
|
|
116
118
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
119
|
+
page?: number | undefined;
|
|
120
|
+
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
121
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
117
122
|
productId?: string | undefined;
|
|
118
123
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
119
|
-
page?: number | undefined;
|
|
120
|
-
limit?: number | undefined;
|
|
121
124
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
122
125
|
isAssigned?: "true" | "false" | undefined;
|
|
123
|
-
search?: string | undefined;
|
|
124
|
-
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
125
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
126
126
|
}, {
|
|
127
|
+
search?: string | undefined;
|
|
128
|
+
limit?: string | undefined;
|
|
127
129
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
130
|
+
page?: string | undefined;
|
|
131
|
+
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
132
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
128
133
|
productId?: string | undefined;
|
|
129
134
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
130
|
-
page?: string | undefined;
|
|
131
|
-
limit?: string | undefined;
|
|
132
135
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
133
136
|
isAssigned?: "true" | "false" | undefined;
|
|
134
|
-
search?: string | undefined;
|
|
135
|
-
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
136
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
137
137
|
}>;
|
|
138
138
|
}, "strip", z.ZodTypeAny, {
|
|
139
139
|
query: {
|
|
140
|
+
search?: string | undefined;
|
|
141
|
+
limit?: number | undefined;
|
|
140
142
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
143
|
+
page?: number | undefined;
|
|
144
|
+
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
145
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
141
146
|
productId?: string | undefined;
|
|
142
147
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
143
|
-
page?: number | undefined;
|
|
144
|
-
limit?: number | undefined;
|
|
145
148
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
146
149
|
isAssigned?: "true" | "false" | undefined;
|
|
147
|
-
search?: string | undefined;
|
|
148
|
-
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
149
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
150
150
|
};
|
|
151
151
|
}, {
|
|
152
152
|
query: {
|
|
153
|
+
search?: string | undefined;
|
|
154
|
+
limit?: string | undefined;
|
|
153
155
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
156
|
+
page?: string | undefined;
|
|
157
|
+
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
158
|
+
sortOrder?: "DESC" | "ASC" | undefined;
|
|
154
159
|
productId?: string | undefined;
|
|
155
160
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
156
|
-
page?: string | undefined;
|
|
157
|
-
limit?: string | undefined;
|
|
158
161
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
159
162
|
isAssigned?: "true" | "false" | undefined;
|
|
160
|
-
search?: string | undefined;
|
|
161
|
-
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
162
|
-
sortOrder?: "ASC" | "DESC" | undefined;
|
|
163
163
|
};
|
|
164
164
|
}>;
|
|
165
165
|
export declare const deleteDeviceSchema: z.ZodObject<{
|
|
@@ -242,19 +242,19 @@ export declare const disableDeviceSchema: z.ZodObject<{
|
|
|
242
242
|
reason: string;
|
|
243
243
|
}>;
|
|
244
244
|
}, "strip", z.ZodTypeAny, {
|
|
245
|
-
params: {
|
|
246
|
-
id: string;
|
|
247
|
-
};
|
|
248
245
|
body: {
|
|
249
246
|
reason: string;
|
|
250
247
|
};
|
|
251
|
-
}, {
|
|
252
248
|
params: {
|
|
253
249
|
id: string;
|
|
254
250
|
};
|
|
251
|
+
}, {
|
|
255
252
|
body: {
|
|
256
253
|
reason: string;
|
|
257
254
|
};
|
|
255
|
+
params: {
|
|
256
|
+
id: string;
|
|
257
|
+
};
|
|
258
258
|
}>;
|
|
259
259
|
export declare const makePermanentSchema: z.ZodObject<{
|
|
260
260
|
params: z.ZodObject<{
|
package/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const upgradeToRiderSchema: z.ZodObject<{
|
|
3
|
-
params: z.ZodObject<{
|
|
4
|
-
userId: z.ZodString;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
userId: string;
|
|
7
|
-
}, {
|
|
8
|
-
userId: string;
|
|
9
|
-
}>;
|
|
10
|
-
body: z.ZodEffects<z.ZodObject<{
|
|
11
|
-
jacketId: z.ZodString;
|
|
12
|
-
nationalId: z.ZodString;
|
|
13
|
-
phoneNumber: z.ZodEffects<z.ZodString, string, string>;
|
|
14
|
-
plateNumber: z.ZodOptional<z.ZodString>;
|
|
15
|
-
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
phoneNumber: string;
|
|
17
|
-
nationalId: string;
|
|
18
|
-
jacketId: string;
|
|
19
|
-
plateNumber?: string | undefined;
|
|
20
|
-
}, {
|
|
21
|
-
phoneNumber: string;
|
|
22
|
-
nationalId: string;
|
|
23
|
-
jacketId: string;
|
|
24
|
-
plateNumber?: string | undefined;
|
|
25
|
-
}>, {
|
|
26
|
-
phoneNumber: string;
|
|
27
|
-
nationalId: string;
|
|
28
|
-
jacketId: string;
|
|
29
|
-
plateNumber?: string | undefined;
|
|
30
|
-
}, {
|
|
31
|
-
phoneNumber: string;
|
|
32
|
-
nationalId: string;
|
|
33
|
-
jacketId: string;
|
|
34
|
-
plateNumber?: string | undefined;
|
|
35
|
-
}>;
|
|
36
|
-
}, "strip", z.ZodTypeAny, {
|
|
37
|
-
params: {
|
|
38
|
-
userId: string;
|
|
39
|
-
};
|
|
40
|
-
body: {
|
|
41
|
-
phoneNumber: string;
|
|
42
|
-
nationalId: string;
|
|
43
|
-
jacketId: string;
|
|
44
|
-
plateNumber?: string | undefined;
|
|
45
|
-
};
|
|
46
|
-
}, {
|
|
47
|
-
params: {
|
|
48
|
-
userId: string;
|
|
49
|
-
};
|
|
50
|
-
body: {
|
|
51
|
-
phoneNumber: string;
|
|
52
|
-
nationalId: string;
|
|
53
|
-
jacketId: string;
|
|
54
|
-
plateNumber?: string | undefined;
|
|
55
|
-
};
|
|
56
|
-
}>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upgradeToRiderSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const auth_validations_1 = require("./auth.validations");
|
|
6
|
-
const nationalIdRegex = /^[A-Z0-9]{5,20}$/i;
|
|
7
|
-
const jacketIdRegex = /^[A-Z0-9]{5,20}$/i;
|
|
8
|
-
const plateNumberRegex = /^[A-Z0-9]{3,10}$/i;
|
|
9
|
-
exports.upgradeToRiderSchema = zod_1.z.object({
|
|
10
|
-
params: zod_1.z.object({
|
|
11
|
-
userId: zod_1.z.string().uuid("Invalid user ID format"),
|
|
12
|
-
}),
|
|
13
|
-
body: zod_1.z
|
|
14
|
-
.object({
|
|
15
|
-
jacketId: zod_1.z
|
|
16
|
-
.string()
|
|
17
|
-
.regex(jacketIdRegex, "Jacket ID must be alphanumeric, 5-20 characters")
|
|
18
|
-
.min(5, "Jacket ID must be at least 5 characters")
|
|
19
|
-
.max(20, "Jacket ID cannot exceed 20 characters"),
|
|
20
|
-
nationalId: zod_1.z
|
|
21
|
-
.string()
|
|
22
|
-
.regex(nationalIdRegex, "National ID must be alphanumeric, 5-20 characters")
|
|
23
|
-
.min(5, "National ID must be at least 5 characters")
|
|
24
|
-
.max(20, "National ID cannot exceed 20 characters"),
|
|
25
|
-
phoneNumber: zod_1.z
|
|
26
|
-
.string()
|
|
27
|
-
.regex(auth_validations_1.phoneRegex, "Invalid phone number format. Use format: +250788123456")
|
|
28
|
-
.refine((phone) => phone === phone, "Phone number verification required"),
|
|
29
|
-
plateNumber: zod_1.z
|
|
30
|
-
.string()
|
|
31
|
-
.regex(plateNumberRegex, "Plate number must be alphanumeric, 3-10 characters")
|
|
32
|
-
.min(3, "Plate number must be at least 3 characters")
|
|
33
|
-
.max(10, "Plate number cannot exceed 10 characters")
|
|
34
|
-
.optional(),
|
|
35
|
-
})
|
|
36
|
-
.refine((data) => data.phoneNumber, {
|
|
37
|
-
message: "Phone number is required",
|
|
38
|
-
path: ["phoneNumber"],
|
|
39
|
-
}),
|
|
40
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
});
|
/package/dist/middlewares/{account.middlewares.d.ts → shared/account.shared.middlewares.d.ts}
RENAMED
|
File without changes
|