vr-commons 1.0.98 → 1.0.100
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/admin/auth.admin.middlewares.d.ts +3 -0
- 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/shared/account.shared.middlewares.d.ts +4 -0
- package/dist/middlewares/shared/account.shared.middlewares.js +64 -0
- 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 +4 -0
- package/dist/middlewares/users/auth.users.middlewares.js +131 -0
- 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 +38 -38
- package/dist/validations/admin.devicePayment.validations.js +2 -2
- package/package.json +1 -1
|
@@ -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);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
export declare function checkIsUserBanned(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
3
|
+
export declare function checkIsUserSuspended(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
4
|
+
export declare function checkUserAccountStatus(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsUserBanned = checkIsUserBanned;
|
|
4
|
+
exports.checkIsUserSuspended = checkIsUserSuspended;
|
|
5
|
+
exports.checkUserAccountStatus = checkUserAccountStatus;
|
|
6
|
+
const account_utils_1 = require("../../utils/account.utils");
|
|
7
|
+
const response_utils_1 = require("../../utils/response.utils");
|
|
8
|
+
// Check if user is banned
|
|
9
|
+
async function checkIsUserBanned(req, res, next) {
|
|
10
|
+
try {
|
|
11
|
+
const userId = req.userId;
|
|
12
|
+
if (!userId) {
|
|
13
|
+
return next();
|
|
14
|
+
}
|
|
15
|
+
const { isBanned, banDetails } = await (0, account_utils_1.checkBanStatus)(userId);
|
|
16
|
+
if (isBanned && banDetails && !banDetails.revokedAt) {
|
|
17
|
+
const message = banDetails.isPermanent
|
|
18
|
+
? "Your account has been permanently banned"
|
|
19
|
+
: `Your account was banned at: ${banDetails.bannedAt.toISOString()}`;
|
|
20
|
+
return (0, response_utils_1.sendErrorResponse)(res, message, 403, banDetails);
|
|
21
|
+
}
|
|
22
|
+
next();
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
next(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Check if user is suspended
|
|
29
|
+
async function checkIsUserSuspended(req, res, next) {
|
|
30
|
+
try {
|
|
31
|
+
const userId = req.userId;
|
|
32
|
+
if (!userId) {
|
|
33
|
+
return next();
|
|
34
|
+
}
|
|
35
|
+
const { isSuspended, suspensionDetails } = await (0, account_utils_1.checkSuspensionStatus)(userId);
|
|
36
|
+
if (isSuspended && suspensionDetails) {
|
|
37
|
+
const daysRemaining = Math.ceil((new Date(suspensionDetails.endsAt).getTime() - new Date().getTime()) /
|
|
38
|
+
(1000 * 60 * 60 * 24));
|
|
39
|
+
const message = `Your account is suspended for ${daysRemaining} more day(s) until ${suspensionDetails.endsAt.toISOString()}`;
|
|
40
|
+
return (0, response_utils_1.sendErrorResponse)(res, message, 403, suspensionDetails);
|
|
41
|
+
}
|
|
42
|
+
next();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
next(error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Combined check for both ban and suspension
|
|
49
|
+
async function checkUserAccountStatus(req, res, next) {
|
|
50
|
+
try {
|
|
51
|
+
const userId = req.userId;
|
|
52
|
+
if (!userId) {
|
|
53
|
+
return next();
|
|
54
|
+
}
|
|
55
|
+
const result = await (0, account_utils_1.checkIsUserBannedOrSuspended)(userId);
|
|
56
|
+
if (result.isRestricted) {
|
|
57
|
+
return (0, response_utils_1.sendErrorResponse)(res, result.message, 403, result.details);
|
|
58
|
+
}
|
|
59
|
+
next();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
next(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -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; } });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
import { UserRole } from "vr-models";
|
|
3
|
+
export declare const checkUserAuthentication: (allowedRoles: UserRole[]) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4
|
+
export declare const checkAdminAuthentication: (allowedRoles: UserRole[]) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -0,0 +1,131 @@
|
|
|
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 = exports.checkUserAuthentication = 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 authTokens_utils_1 = require("../../utils/authTokens.utils");
|
|
11
|
+
const checkUserAuthentication = (allowedRoles) => async (req, res, next) => {
|
|
12
|
+
try {
|
|
13
|
+
const authHeader = req.headers.authorization;
|
|
14
|
+
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
15
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Missing or invalid token", 401);
|
|
16
|
+
}
|
|
17
|
+
const token = authHeader.split(" ")[1];
|
|
18
|
+
let payload;
|
|
19
|
+
try {
|
|
20
|
+
payload = jsonwebtoken_1.default.verify(token, process.env.JWT_SECRET);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error instanceof jsonwebtoken_1.default.TokenExpiredError) {
|
|
24
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Token expired. Please re-verify your phone.", 401);
|
|
25
|
+
}
|
|
26
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Token invalid", 401);
|
|
27
|
+
}
|
|
28
|
+
const user = await vr_models_1.User.findOne({
|
|
29
|
+
where: { id: payload.userId },
|
|
30
|
+
include: [
|
|
31
|
+
{
|
|
32
|
+
model: vr_models_1.SecurityClearance,
|
|
33
|
+
as: "securityClearance",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
// Check if user exists
|
|
38
|
+
if (!user || !user.securityClearance) {
|
|
39
|
+
return (0, response_utils_1.sendErrorResponse)(res, "User not found", 400);
|
|
40
|
+
}
|
|
41
|
+
// 🔐 Token versioning (logout all devices)
|
|
42
|
+
if (user.tokenVersion !== payload.tokenVersion) {
|
|
43
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Session expired. Please re-verify your phone.", 401);
|
|
44
|
+
}
|
|
45
|
+
// 🧱 Role enforcement
|
|
46
|
+
if (!allowedRoles.includes(user.securityClearance.role)) {
|
|
47
|
+
return (0, response_utils_1.sendErrorResponse)(res, "Access denied", 403);
|
|
48
|
+
}
|
|
49
|
+
// ✅ Extend req with user info
|
|
50
|
+
req.userId = user.id;
|
|
51
|
+
req.firstName = user.firstName;
|
|
52
|
+
req.lastName = user.lastName;
|
|
53
|
+
req.scRole = user.securityClearance.role;
|
|
54
|
+
req.scLevel = user.securityClearance.level;
|
|
55
|
+
req.tokenVersion = user.tokenVersion;
|
|
56
|
+
// Optional: Add sessionId if present in payload (for backward compatibility)
|
|
57
|
+
if (payload.sessionId) {
|
|
58
|
+
req.sessionId = payload.sessionId;
|
|
59
|
+
}
|
|
60
|
+
// 🔄 Auto-refresh token if it's about to expire (within 5 days)
|
|
61
|
+
if ((0, authTokens_utils_1.shouldRefreshToken)(token)) {
|
|
62
|
+
const newToken = (0, authTokens_utils_1.generateToken)(user.id, user.securityClearance.role, user.securityClearance.level, user.tokenVersion, payload.sessionId, // Preserve sessionId if exists
|
|
63
|
+
user.securityClearance.role === "ADMIN"
|
|
64
|
+
? "ADMIN"
|
|
65
|
+
: user.securityClearance.role === "RIDER"
|
|
66
|
+
? "RIDER"
|
|
67
|
+
: "PASSENGER");
|
|
68
|
+
// Set new token in response header for client to update
|
|
69
|
+
res.setHeader("X-New-Token", newToken);
|
|
70
|
+
res.setHeader("X-Token-Refreshed", "true");
|
|
71
|
+
console.log(`🔄 Auto-refreshed token for user ${user.id}`);
|
|
72
|
+
}
|
|
73
|
+
next();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error("Authentication error:", error);
|
|
77
|
+
next(error);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
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; } });
|
|
@@ -32,55 +32,55 @@ export declare const listPlansSchema: z.ZodObject<{
|
|
|
32
32
|
limit: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>>;
|
|
33
33
|
userId: z.ZodOptional<z.ZodString>;
|
|
34
34
|
deviceId: z.ZodOptional<z.ZodString>;
|
|
35
|
-
status: z.ZodOptional<z.ZodEnum<["
|
|
35
|
+
status: z.ZodOptional<z.ZodEnum<["ACTIVE", "COMPLETED", "DEFAULTED", "CANCELLED"]>>;
|
|
36
36
|
isOverdue: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
37
37
|
search: z.ZodOptional<z.ZodString>;
|
|
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
|
-
limit: number;
|
|
42
41
|
page: number;
|
|
43
|
-
|
|
42
|
+
limit: number;
|
|
43
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
44
44
|
userId?: string | undefined;
|
|
45
|
-
status?: "PENDING" | "SUCCESSFUL" | "FAILED" | undefined;
|
|
46
|
-
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
47
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
48
45
|
deviceId?: string | undefined;
|
|
49
46
|
isOverdue?: "true" | "false" | undefined;
|
|
50
|
-
}, {
|
|
51
47
|
search?: string | undefined;
|
|
52
|
-
|
|
48
|
+
sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
|
|
49
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
53
52
|
userId?: string | undefined;
|
|
54
|
-
status?: "PENDING" | "SUCCESSFUL" | "FAILED" | undefined;
|
|
55
53
|
page?: string | undefined;
|
|
56
|
-
|
|
57
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
54
|
+
limit?: string | undefined;
|
|
58
55
|
deviceId?: string | undefined;
|
|
59
56
|
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
|
-
limit: number;
|
|
64
63
|
page: number;
|
|
65
|
-
|
|
64
|
+
limit: number;
|
|
65
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
66
66
|
userId?: string | undefined;
|
|
67
|
-
status?: "PENDING" | "SUCCESSFUL" | "FAILED" | undefined;
|
|
68
|
-
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
69
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
70
67
|
deviceId?: string | undefined;
|
|
71
68
|
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
|
-
|
|
76
|
-
limit?: string | undefined;
|
|
75
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
77
76
|
userId?: string | undefined;
|
|
78
|
-
status?: "PENDING" | "SUCCESSFUL" | "FAILED" | undefined;
|
|
79
77
|
page?: string | undefined;
|
|
80
|
-
|
|
81
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
78
|
+
limit?: string | undefined;
|
|
82
79
|
deviceId?: string | undefined;
|
|
83
80
|
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<{
|
|
@@ -109,13 +109,13 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
109
109
|
userId: string;
|
|
110
110
|
}>;
|
|
111
111
|
query: z.ZodOptional<z.ZodObject<{
|
|
112
|
-
status: z.ZodOptional<z.ZodEnum<["
|
|
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?: "
|
|
115
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
116
116
|
includeCompleted?: "true" | "false" | undefined;
|
|
117
117
|
}, {
|
|
118
|
-
status?: "
|
|
118
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "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?: "
|
|
126
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "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?: "
|
|
134
|
+
status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "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
|
+
};
|
|
180
183
|
body: {
|
|
181
184
|
userId?: string | undefined;
|
|
182
185
|
pricingId?: string | undefined;
|
|
183
186
|
};
|
|
187
|
+
}, {
|
|
184
188
|
params: {
|
|
185
189
|
id: string;
|
|
186
190
|
};
|
|
187
|
-
}, {
|
|
188
191
|
body: {
|
|
189
192
|
userId?: string | undefined;
|
|
190
193
|
pricingId?: string | undefined;
|
|
191
194
|
};
|
|
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
|
-
metadata?: Record<string, any> | undefined;
|
|
213
212
|
providerReference?: string | undefined;
|
|
213
|
+
metadata?: Record<string, any> | undefined;
|
|
214
214
|
}, {
|
|
215
215
|
amount: number;
|
|
216
216
|
provider: "mtn_momo" | "airtel_money";
|
|
217
|
-
metadata?: Record<string, any> | undefined;
|
|
218
217
|
providerReference?: string | undefined;
|
|
218
|
+
metadata?: Record<string, any> | undefined;
|
|
219
219
|
}>;
|
|
220
220
|
}, "strip", z.ZodTypeAny, {
|
|
221
|
+
params: {
|
|
222
|
+
id: string;
|
|
223
|
+
};
|
|
221
224
|
body: {
|
|
222
225
|
amount: number;
|
|
223
226
|
provider: "mtn_momo" | "airtel_money";
|
|
224
|
-
metadata?: Record<string, any> | undefined;
|
|
225
227
|
providerReference?: string | undefined;
|
|
228
|
+
metadata?: Record<string, any> | undefined;
|
|
226
229
|
};
|
|
230
|
+
}, {
|
|
227
231
|
params: {
|
|
228
232
|
id: string;
|
|
229
233
|
};
|
|
230
|
-
}, {
|
|
231
234
|
body: {
|
|
232
235
|
amount: number;
|
|
233
236
|
provider: "mtn_momo" | "airtel_money";
|
|
234
|
-
metadata?: Record<string, any> | undefined;
|
|
235
237
|
providerReference?: string | undefined;
|
|
236
|
-
|
|
237
|
-
params: {
|
|
238
|
-
id: string;
|
|
238
|
+
metadata?: Record<string, any> | undefined;
|
|
239
239
|
};
|
|
240
240
|
}>;
|
|
241
241
|
export declare const deletePlanSchema: z.ZodObject<{
|
|
@@ -21,7 +21,7 @@ exports.listPlansSchema = zod_1.z.object({
|
|
|
21
21
|
limit: zod_1.z.string().regex(/^\d+$/).transform(Number).optional().default("20"),
|
|
22
22
|
userId: zod_1.z.string().uuid().optional(),
|
|
23
23
|
deviceId: zod_1.z.string().uuid().optional(),
|
|
24
|
-
status: zod_1.z.enum(vr_models_1.
|
|
24
|
+
status: zod_1.z.enum(vr_models_1.PAYMENT_PLAN_STATUS).optional(),
|
|
25
25
|
isOverdue: zod_1.z.enum(["true", "false"]).optional(),
|
|
26
26
|
search: zod_1.z.string().optional(),
|
|
27
27
|
sortBy: zod_1.z
|
|
@@ -47,7 +47,7 @@ exports.getUserPlansSchema = zod_1.z.object({
|
|
|
47
47
|
}),
|
|
48
48
|
query: zod_1.z
|
|
49
49
|
.object({
|
|
50
|
-
status: zod_1.z.enum(vr_models_1.
|
|
50
|
+
status: zod_1.z.enum(vr_models_1.PAYMENT_PLAN_STATUS).optional(),
|
|
51
51
|
includeCompleted: zod_1.z.enum(["true", "false"]).optional(),
|
|
52
52
|
})
|
|
53
53
|
.optional(),
|