vr-commons 1.0.103 → 1.0.105
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/eventlogs.admin.utils.d.ts +53 -0
- package/dist/utils/eventlogs.admin.utils.js +134 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +8 -1
- package/dist/validations/eventlogs.admin.validations.d.ts +110 -0
- package/dist/validations/eventlogs.admin.validations.js +75 -0
- package/dist/validations/index.d.ts +1 -0
- package/dist/validations/index.js +4 -1
- package/dist/validations/product.validations.d.ts +46 -51
- package/dist/validations/product.validations.js +10 -9
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EventLog, DeviceSessionPayload } from "vr-models";
|
|
2
|
+
interface FormattedDeviceSession {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
startedAt: string;
|
|
5
|
+
expiresAt: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
tokenVersion: number;
|
|
8
|
+
deviceSerialNumber: string;
|
|
9
|
+
minutesGranted: number;
|
|
10
|
+
isExtension?: boolean;
|
|
11
|
+
paymentPlanId?: string;
|
|
12
|
+
}
|
|
13
|
+
interface FormattedEventLog {
|
|
14
|
+
id: string;
|
|
15
|
+
actorType: string;
|
|
16
|
+
actorId: string | null;
|
|
17
|
+
actorName: string | null;
|
|
18
|
+
action: string;
|
|
19
|
+
entity: string;
|
|
20
|
+
entityId: string | null;
|
|
21
|
+
metadata: Record<string, any>;
|
|
22
|
+
ipAddress: string | null;
|
|
23
|
+
userAgent: string | null;
|
|
24
|
+
deviceSession: FormattedDeviceSession | null;
|
|
25
|
+
authTokenVersion: number | null;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
summary: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format device session for response
|
|
31
|
+
*/
|
|
32
|
+
export declare const formatDeviceSession: (deviceSession: DeviceSessionPayload | null) => FormattedDeviceSession | null;
|
|
33
|
+
/**
|
|
34
|
+
* Format single event log for response
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatEventLog: (log: EventLog) => FormattedEventLog;
|
|
37
|
+
/**
|
|
38
|
+
* Format multiple event logs for response
|
|
39
|
+
*/
|
|
40
|
+
export declare const formatEventLogs: (logs: EventLog[]) => FormattedEventLog[];
|
|
41
|
+
/**
|
|
42
|
+
* Build where clause for filtering
|
|
43
|
+
*/
|
|
44
|
+
export declare const buildEventLogWhereClause: (query: any) => any;
|
|
45
|
+
/**
|
|
46
|
+
* Build search conditions - using Op.like for TypeScript compatibility
|
|
47
|
+
*/
|
|
48
|
+
export declare const buildSearchConditions: (search: string) => any[];
|
|
49
|
+
/**
|
|
50
|
+
* Build search conditions for user name (firstName and lastName)
|
|
51
|
+
*/
|
|
52
|
+
export declare const buildUserSearchConditions: (firstName?: string, lastName?: string, actorName?: string) => any[];
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildUserSearchConditions = exports.buildSearchConditions = exports.buildEventLogWhereClause = exports.formatEventLogs = exports.formatEventLog = exports.formatDeviceSession = void 0;
|
|
4
|
+
// src/modules/event-logs/utils/eventLogs.utils.ts
|
|
5
|
+
const sequelize_1 = require("sequelize");
|
|
6
|
+
/**
|
|
7
|
+
* Format device session for response
|
|
8
|
+
*/
|
|
9
|
+
const formatDeviceSession = (deviceSession) => {
|
|
10
|
+
if (!deviceSession)
|
|
11
|
+
return null;
|
|
12
|
+
return {
|
|
13
|
+
sessionId: deviceSession.sessionId,
|
|
14
|
+
startedAt: new Date(deviceSession.startedAt).toISOString(),
|
|
15
|
+
expiresAt: new Date(deviceSession.expiresAt).toISOString(),
|
|
16
|
+
userId: deviceSession.userId,
|
|
17
|
+
tokenVersion: deviceSession.tokenVersion,
|
|
18
|
+
deviceSerialNumber: deviceSession.deviceSerialNumber,
|
|
19
|
+
minutesGranted: deviceSession.minutesGranted,
|
|
20
|
+
isExtension: deviceSession.isExtension,
|
|
21
|
+
paymentPlanId: deviceSession.paymentPlanId,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.formatDeviceSession = formatDeviceSession;
|
|
25
|
+
/**
|
|
26
|
+
* Format single event log for response
|
|
27
|
+
*/
|
|
28
|
+
const formatEventLog = (log) => {
|
|
29
|
+
const actorName = log.actor
|
|
30
|
+
? `${log.actor.firstName} ${log.actor.lastName}`
|
|
31
|
+
: log.actorType === "ADMIN" || log.actorType === "SUPER_ADMIN"
|
|
32
|
+
? "System"
|
|
33
|
+
: null;
|
|
34
|
+
return {
|
|
35
|
+
id: log.id,
|
|
36
|
+
actorType: log.actorType,
|
|
37
|
+
actorId: log.actorId,
|
|
38
|
+
actorName,
|
|
39
|
+
action: log.action,
|
|
40
|
+
entity: log.entity,
|
|
41
|
+
entityId: log.entityId,
|
|
42
|
+
metadata: log.metadata || {},
|
|
43
|
+
ipAddress: log.ipAddress,
|
|
44
|
+
userAgent: log.userAgent,
|
|
45
|
+
deviceSession: (0, exports.formatDeviceSession)(log.deviceSession),
|
|
46
|
+
authTokenVersion: log.authTokenVersion || null,
|
|
47
|
+
createdAt: log.createdAt.toISOString(),
|
|
48
|
+
summary: log.getSummary(),
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.formatEventLog = formatEventLog;
|
|
52
|
+
/**
|
|
53
|
+
* Format multiple event logs for response
|
|
54
|
+
*/
|
|
55
|
+
const formatEventLogs = (logs) => {
|
|
56
|
+
return logs.map(exports.formatEventLog);
|
|
57
|
+
};
|
|
58
|
+
exports.formatEventLogs = formatEventLogs;
|
|
59
|
+
/**
|
|
60
|
+
* Build where clause for filtering
|
|
61
|
+
*/
|
|
62
|
+
const buildEventLogWhereClause = (query) => {
|
|
63
|
+
const where = {};
|
|
64
|
+
if (query.actorType)
|
|
65
|
+
where.actorType = query.actorType;
|
|
66
|
+
if (query.actorId)
|
|
67
|
+
where.actorId = query.actorId;
|
|
68
|
+
if (query.action)
|
|
69
|
+
where.action = query.action;
|
|
70
|
+
if (query.entity)
|
|
71
|
+
where.entity = query.entity;
|
|
72
|
+
if (query.entityId)
|
|
73
|
+
where.entityId = query.entityId;
|
|
74
|
+
// Date range filter
|
|
75
|
+
if (query.fromDate || query.toDate) {
|
|
76
|
+
where.createdAt = {};
|
|
77
|
+
if (query.fromDate)
|
|
78
|
+
where.createdAt[sequelize_1.Op.gte] = query.fromDate;
|
|
79
|
+
if (query.toDate)
|
|
80
|
+
where.createdAt[sequelize_1.Op.lte] = query.toDate;
|
|
81
|
+
}
|
|
82
|
+
// Device session filter
|
|
83
|
+
if (query.hasDeviceSession !== undefined) {
|
|
84
|
+
if (query.hasDeviceSession) {
|
|
85
|
+
where.deviceSession = { [sequelize_1.Op.ne]: null };
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
where.deviceSession = null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return where;
|
|
92
|
+
};
|
|
93
|
+
exports.buildEventLogWhereClause = buildEventLogWhereClause;
|
|
94
|
+
/**
|
|
95
|
+
* Build search conditions - using Op.like for TypeScript compatibility
|
|
96
|
+
*/
|
|
97
|
+
const buildSearchConditions = (search) => {
|
|
98
|
+
if (!search)
|
|
99
|
+
return [];
|
|
100
|
+
const searchPattern = `%${search}%`;
|
|
101
|
+
return [
|
|
102
|
+
{ action: { [sequelize_1.Op.like]: searchPattern } },
|
|
103
|
+
{ entity: { [sequelize_1.Op.like]: searchPattern } },
|
|
104
|
+
{ actorType: { [sequelize_1.Op.like]: searchPattern } },
|
|
105
|
+
{ "$actor.firstName$": { [sequelize_1.Op.like]: searchPattern } },
|
|
106
|
+
{ "$actor.lastName$": { [sequelize_1.Op.like]: searchPattern } },
|
|
107
|
+
];
|
|
108
|
+
};
|
|
109
|
+
exports.buildSearchConditions = buildSearchConditions;
|
|
110
|
+
/**
|
|
111
|
+
* Build search conditions for user name (firstName and lastName)
|
|
112
|
+
*/
|
|
113
|
+
const buildUserSearchConditions = (firstName, lastName, actorName) => {
|
|
114
|
+
const conditions = [];
|
|
115
|
+
if (actorName) {
|
|
116
|
+
const nameParts = actorName.trim().split(" ");
|
|
117
|
+
if (nameParts.length === 1) {
|
|
118
|
+
// Single word - search both first and last name
|
|
119
|
+
conditions.push({ "$actor.firstName$": { [sequelize_1.Op.like]: `%${actorName}%` } }, { "$actor.lastName$": { [sequelize_1.Op.like]: `%${actorName}%` } });
|
|
120
|
+
}
|
|
121
|
+
else if (nameParts.length >= 2) {
|
|
122
|
+
// Two words - treat as first and last name
|
|
123
|
+
conditions.push({ "$actor.firstName$": { [sequelize_1.Op.like]: `%${nameParts[0]}%` } }, { "$actor.lastName$": { [sequelize_1.Op.like]: `%${nameParts[1]}%` } });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (firstName) {
|
|
127
|
+
conditions.push({ "$actor.firstName$": { [sequelize_1.Op.like]: `%${firstName}%` } });
|
|
128
|
+
}
|
|
129
|
+
if (lastName) {
|
|
130
|
+
conditions.push({ "$actor.lastName$": { [sequelize_1.Op.like]: `%${lastName}%` } });
|
|
131
|
+
}
|
|
132
|
+
return conditions;
|
|
133
|
+
};
|
|
134
|
+
exports.buildUserSearchConditions = buildUserSearchConditions;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export { stockUtil } from "./admin.device.utils";
|
|
|
13
13
|
export { cloudinaryUtil } from "./product.utils";
|
|
14
14
|
export { DPP_OperationsUtil } from "./admin.devicePayment.utils";
|
|
15
15
|
export { PendingRegistration, VerificationMethod, ConfirmResponse, UploadResult, StockChangeResult, } from "./types";
|
|
16
|
+
export { formatDeviceSession, formatEventLog, formatEventLogs, buildEventLogWhereClause, buildSearchConditions, buildUserSearchConditions, } from "./eventlogs.admin.utils";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isRankEqual = exports.getUserLevel = exports.sendVerificationCode = exports.sendSMS = exports.sendEmail = exports.getVerificationMethod = exports.getOTPExpiry = exports.generateOTP = exports.createDeviceSession = exports.suspensionUtil = exports.banUtil = exports.hasHigherAuthority = exports.getModeratableRoles = exports.canModerateUser = exports.canModerate = exports.softDeleteUser = exports.hashPassword = exports.validatePassword = exports.validateUniqueFields = exports.generateJacketId = exports.getSortOrder = exports.generateEventSearchConditions = exports.generateUserSearchConditions = exports.findSecurityClearanceByRole = exports.getUsersByRole = exports.getUserById = exports.isAccountAccessible = exports.canModifyAccount = exports.hasAllPermissions = exports.hasAnyPermission = exports.hasPermission = exports.hasRole = exports.formatUserListResponse = exports.formatUserProfile = exports.sendErrorResponse = exports.sendSuccessResponse = exports.logEvent = exports.formatTimeRemaining = exports.getTokenTimeRemaining = exports.generateToken = exports.shouldRefreshToken = exports.verifyToken = exports.generateRiderToken = exports.generatePassengerToken = exports.generateAdminToken = exports.checkSuspensionStatus = exports.checkIsUserBannedOrSuspended = exports.checkBanStatus = exports.hasActiveDependencies = exports.checkAccountDependencies = void 0;
|
|
4
|
-
exports.DPP_OperationsUtil = exports.cloudinaryUtil = exports.stockUtil = exports.validateHierarchy = exports.isSuperiorOrEqual = exports.isSuperior = exports.isSubordinateOrEqual = exports.isSubordinate = void 0;
|
|
4
|
+
exports.buildUserSearchConditions = exports.buildSearchConditions = exports.buildEventLogWhereClause = exports.formatEventLogs = exports.formatEventLog = exports.formatDeviceSession = exports.DPP_OperationsUtil = exports.cloudinaryUtil = exports.stockUtil = exports.validateHierarchy = exports.isSuperiorOrEqual = exports.isSuperior = exports.isSubordinateOrEqual = exports.isSubordinate = void 0;
|
|
5
5
|
var account_utils_1 = require("./account.utils");
|
|
6
6
|
Object.defineProperty(exports, "checkAccountDependencies", { enumerable: true, get: function () { return account_utils_1.checkAccountDependencies; } });
|
|
7
7
|
Object.defineProperty(exports, "hasActiveDependencies", { enumerable: true, get: function () { return account_utils_1.hasActiveDependencies; } });
|
|
@@ -81,3 +81,10 @@ var product_utils_1 = require("./product.utils");
|
|
|
81
81
|
Object.defineProperty(exports, "cloudinaryUtil", { enumerable: true, get: function () { return product_utils_1.cloudinaryUtil; } });
|
|
82
82
|
var admin_devicePayment_utils_1 = require("./admin.devicePayment.utils");
|
|
83
83
|
Object.defineProperty(exports, "DPP_OperationsUtil", { enumerable: true, get: function () { return admin_devicePayment_utils_1.DPP_OperationsUtil; } });
|
|
84
|
+
var eventlogs_admin_utils_1 = require("./eventlogs.admin.utils");
|
|
85
|
+
Object.defineProperty(exports, "formatDeviceSession", { enumerable: true, get: function () { return eventlogs_admin_utils_1.formatDeviceSession; } });
|
|
86
|
+
Object.defineProperty(exports, "formatEventLog", { enumerable: true, get: function () { return eventlogs_admin_utils_1.formatEventLog; } });
|
|
87
|
+
Object.defineProperty(exports, "formatEventLogs", { enumerable: true, get: function () { return eventlogs_admin_utils_1.formatEventLogs; } });
|
|
88
|
+
Object.defineProperty(exports, "buildEventLogWhereClause", { enumerable: true, get: function () { return eventlogs_admin_utils_1.buildEventLogWhereClause; } });
|
|
89
|
+
Object.defineProperty(exports, "buildSearchConditions", { enumerable: true, get: function () { return eventlogs_admin_utils_1.buildSearchConditions; } });
|
|
90
|
+
Object.defineProperty(exports, "buildUserSearchConditions", { enumerable: true, get: function () { return eventlogs_admin_utils_1.buildUserSearchConditions; } });
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const listEventLogsSchema: z.ZodObject<{
|
|
3
|
+
query: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
page: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>, z.ZodNumber>;
|
|
5
|
+
limit: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>, z.ZodNumber>;
|
|
6
|
+
actorType: z.ZodOptional<z.ZodEnum<["RIDER", "PASSENGER", "AGENT", "ADMIN", "SUPER_ADMIN"]>>;
|
|
7
|
+
actorId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
action: z.ZodOptional<z.ZodEnum<[string, ...string[]]>>;
|
|
9
|
+
entity: z.ZodOptional<z.ZodString>;
|
|
10
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
fromDate: z.ZodOptional<z.ZodString>;
|
|
12
|
+
toDate: z.ZodOptional<z.ZodString>;
|
|
13
|
+
search: z.ZodOptional<z.ZodString>;
|
|
14
|
+
actorName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
16
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
17
|
+
sortBy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["createdAt", "action", "entity", "actorType"]>>>;
|
|
18
|
+
sortOrder: z.ZodDefault<z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>>;
|
|
19
|
+
hasDeviceSession: z.ZodEffects<z.ZodOptional<z.ZodString>, boolean, string | undefined>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
page: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
sortBy: "actorType" | "action" | "entity" | "createdAt";
|
|
24
|
+
sortOrder: "ASC" | "DESC";
|
|
25
|
+
hasDeviceSession: boolean;
|
|
26
|
+
actorType?: "RIDER" | "PASSENGER" | "AGENT" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
27
|
+
actorId?: string | undefined;
|
|
28
|
+
action?: string | undefined;
|
|
29
|
+
entity?: string | undefined;
|
|
30
|
+
entityId?: string | undefined;
|
|
31
|
+
fromDate?: string | undefined;
|
|
32
|
+
toDate?: string | undefined;
|
|
33
|
+
search?: string | undefined;
|
|
34
|
+
actorName?: string | undefined;
|
|
35
|
+
firstName?: string | undefined;
|
|
36
|
+
lastName?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
page?: string | undefined;
|
|
39
|
+
limit?: string | undefined;
|
|
40
|
+
actorType?: "RIDER" | "PASSENGER" | "AGENT" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
41
|
+
actorId?: string | undefined;
|
|
42
|
+
action?: string | undefined;
|
|
43
|
+
entity?: string | undefined;
|
|
44
|
+
entityId?: string | undefined;
|
|
45
|
+
fromDate?: string | undefined;
|
|
46
|
+
toDate?: string | undefined;
|
|
47
|
+
search?: string | undefined;
|
|
48
|
+
actorName?: string | undefined;
|
|
49
|
+
firstName?: string | undefined;
|
|
50
|
+
lastName?: string | undefined;
|
|
51
|
+
sortBy?: "actorType" | "action" | "entity" | "createdAt" | undefined;
|
|
52
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
53
|
+
hasDeviceSession?: string | undefined;
|
|
54
|
+
}>, any, {
|
|
55
|
+
page?: string | undefined;
|
|
56
|
+
limit?: string | undefined;
|
|
57
|
+
actorType?: "RIDER" | "PASSENGER" | "AGENT" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
58
|
+
actorId?: string | undefined;
|
|
59
|
+
action?: string | undefined;
|
|
60
|
+
entity?: string | undefined;
|
|
61
|
+
entityId?: string | undefined;
|
|
62
|
+
fromDate?: string | undefined;
|
|
63
|
+
toDate?: string | undefined;
|
|
64
|
+
search?: string | undefined;
|
|
65
|
+
actorName?: string | undefined;
|
|
66
|
+
firstName?: string | undefined;
|
|
67
|
+
lastName?: string | undefined;
|
|
68
|
+
sortBy?: "actorType" | "action" | "entity" | "createdAt" | undefined;
|
|
69
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
70
|
+
hasDeviceSession?: string | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
query?: any;
|
|
74
|
+
}, {
|
|
75
|
+
query: {
|
|
76
|
+
page?: string | undefined;
|
|
77
|
+
limit?: string | undefined;
|
|
78
|
+
actorType?: "RIDER" | "PASSENGER" | "AGENT" | "ADMIN" | "SUPER_ADMIN" | undefined;
|
|
79
|
+
actorId?: string | undefined;
|
|
80
|
+
action?: string | undefined;
|
|
81
|
+
entity?: string | undefined;
|
|
82
|
+
entityId?: string | undefined;
|
|
83
|
+
fromDate?: string | undefined;
|
|
84
|
+
toDate?: string | undefined;
|
|
85
|
+
search?: string | undefined;
|
|
86
|
+
actorName?: string | undefined;
|
|
87
|
+
firstName?: string | undefined;
|
|
88
|
+
lastName?: string | undefined;
|
|
89
|
+
sortBy?: "actorType" | "action" | "entity" | "createdAt" | undefined;
|
|
90
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
91
|
+
hasDeviceSession?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
export declare const getEventLogSchema: z.ZodObject<{
|
|
95
|
+
params: z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
id: string;
|
|
99
|
+
}, {
|
|
100
|
+
id: string;
|
|
101
|
+
}>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
params: {
|
|
104
|
+
id: string;
|
|
105
|
+
};
|
|
106
|
+
}, {
|
|
107
|
+
params: {
|
|
108
|
+
id: string;
|
|
109
|
+
};
|
|
110
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventLogSchema = exports.listEventLogsSchema = void 0;
|
|
4
|
+
// src/modules/event-logs/validations/eventLogs.validations.ts
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const vr_models_1 = require("vr-models");
|
|
7
|
+
// Base schemas
|
|
8
|
+
const uuidSchema = zod_1.z.string().uuid("Invalid UUID format");
|
|
9
|
+
// Date validator for filtering - keeps as string for query param validation
|
|
10
|
+
const dateValidator = zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format");
|
|
13
|
+
// Convert readonly array to mutable tuple for zod enum
|
|
14
|
+
const eventActionsList = [...vr_models_1.EVENT_ACTIONS];
|
|
15
|
+
// ==================== GET ALL EVENT LOGS ====================
|
|
16
|
+
exports.listEventLogsSchema = zod_1.z.object({
|
|
17
|
+
query: zod_1.z
|
|
18
|
+
.object({
|
|
19
|
+
page: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.transform((val) => (val ? parseInt(val) : 1))
|
|
23
|
+
.pipe(zod_1.z.number().min(1)),
|
|
24
|
+
limit: zod_1.z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.transform((val) => (val ? parseInt(val) : 20))
|
|
28
|
+
.pipe(zod_1.z.number().min(1).max(100)),
|
|
29
|
+
actorType: zod_1.z
|
|
30
|
+
.enum(["RIDER", "PASSENGER", "AGENT", "ADMIN", "SUPER_ADMIN"])
|
|
31
|
+
.optional(),
|
|
32
|
+
actorId: uuidSchema.optional(),
|
|
33
|
+
action: zod_1.z.enum(eventActionsList).optional(),
|
|
34
|
+
entity: zod_1.z.string().optional(),
|
|
35
|
+
entityId: uuidSchema.optional(),
|
|
36
|
+
fromDate: dateValidator.optional(),
|
|
37
|
+
toDate: dateValidator.optional(),
|
|
38
|
+
// Search parameters for user names
|
|
39
|
+
search: zod_1.z.string().optional(),
|
|
40
|
+
actorName: zod_1.z.string().optional(),
|
|
41
|
+
firstName: zod_1.z.string().optional(),
|
|
42
|
+
lastName: zod_1.z.string().optional(),
|
|
43
|
+
sortBy: zod_1.z
|
|
44
|
+
.enum(["createdAt", "action", "entity", "actorType"])
|
|
45
|
+
.optional()
|
|
46
|
+
.default("createdAt"),
|
|
47
|
+
sortOrder: zod_1.z.enum(["ASC", "DESC"]).optional().default("DESC"),
|
|
48
|
+
hasDeviceSession: zod_1.z
|
|
49
|
+
.string()
|
|
50
|
+
.optional()
|
|
51
|
+
.transform((val) => val === "true"),
|
|
52
|
+
})
|
|
53
|
+
.transform((data) => {
|
|
54
|
+
// Create a new object with transformed values
|
|
55
|
+
const result = { ...data };
|
|
56
|
+
// Convert fromDate/toDate to Date objects (stores as additional properties)
|
|
57
|
+
if (data.fromDate) {
|
|
58
|
+
const fromDateObj = new Date(data.fromDate);
|
|
59
|
+
fromDateObj.setHours(0, 0, 0, 0);
|
|
60
|
+
result.fromDateObj = fromDateObj;
|
|
61
|
+
}
|
|
62
|
+
if (data.toDate) {
|
|
63
|
+
const toDateObj = new Date(data.toDate);
|
|
64
|
+
toDateObj.setHours(23, 59, 59, 999);
|
|
65
|
+
result.toDateObj = toDateObj;
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
// ==================== GET EVENT LOG BY ID ====================
|
|
71
|
+
exports.getEventLogSchema = zod_1.z.object({
|
|
72
|
+
params: zod_1.z.object({
|
|
73
|
+
id: uuidSchema,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
@@ -12,3 +12,4 @@ export { createProductSchema, updateProductSchema, getProductSchema, getProducts
|
|
|
12
12
|
export { createPricingSchema, updatePricingSchema, getPricingSchema, getPricingsSchema, deletePricingSchema, } from "./pricings.validations";
|
|
13
13
|
export { checkAvailabilitySchema, bulkCreateDevicesSchema, adminLockDeviceSchema, adminUnlockDeviceSchema, updateDeviceSchema, getDeviceSchema, getDevicesSchema, deleteDeviceSchema, disableDeviceSchema, makePermanentSchema, createDeviceSchema, } from "./admin.devices.validations";
|
|
14
14
|
export { createPlanSchema, limitedUpdateSchema, getDevicePlanSchema, getPlanSchema, getUserPlansSchema, listPlansSchema, recordPaymentSchema, deletePlanSchema, } from "./admin.devicePayment.validations";
|
|
15
|
+
export { listEventLogsSchema, getEventLogSchema, } from "./eventlogs.admin.validations";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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.exportBansSchema = exports.createSuspensionSchema = exports.createBanSchema = exports.extendSuspensionSchema = exports.revokeSuspensionSchema = exports.revokeBanSchema = exports.reviewAppealSchema = exports.listSuspensionsSchema = exports.listPendingAppealsSchema = exports.listBansSchema = exports.getUserBansSchema = exports.getUserSuspensionsSchema = exports.getSuspensionSchema = exports.getUserRestrictionsSchema = exports.getBanSchema = exports.submitSuspensionAppealSchema = exports.submitBanAppealSchema = 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.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema = exports.createPlanSchema = exports.createDeviceSchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.updateDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.bulkCreateDevicesSchema = exports.checkAvailabilitySchema = exports.deletePricingSchema = exports.getPricingsSchema = exports.getPricingSchema = exports.updatePricingSchema = exports.createPricingSchema = exports.updateStockSchema = exports.deleteProductSchema = exports.activateProductSchema = exports.deactivateProductSchema = exports.getProductsSchema = exports.getProductSchema = exports.updateProductSchema = exports.createProductSchema = exports.resetPasswordSchema = exports.upgradeToRiderSchema = exports.fireEmployeeSchema = exports.demoteAdminSchema = exports.promoteAdminSchema = exports.hireAdminSchema = exports.getUsersSchema = exports.getUserSchema = exports.deleteUserSchema = exports.updateRiderSchema = exports.updateAdminSchema = exports.changePasswordSchema = exports.strongPasswordRegex = exports.deleteAccountSchema = void 0;
|
|
4
|
+
exports.getEventLogSchema = exports.listEventLogsSchema = exports.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema = exports.createPlanSchema = exports.createDeviceSchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.updateDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.bulkCreateDevicesSchema = exports.checkAvailabilitySchema = exports.deletePricingSchema = exports.getPricingsSchema = exports.getPricingSchema = exports.updatePricingSchema = exports.createPricingSchema = exports.updateStockSchema = exports.deleteProductSchema = exports.activateProductSchema = exports.deactivateProductSchema = exports.getProductsSchema = exports.getProductSchema = exports.updateProductSchema = exports.createProductSchema = exports.resetPasswordSchema = exports.upgradeToRiderSchema = exports.fireEmployeeSchema = exports.demoteAdminSchema = exports.promoteAdminSchema = exports.hireAdminSchema = exports.getUsersSchema = exports.getUserSchema = exports.deleteUserSchema = exports.updateRiderSchema = exports.updateAdminSchema = exports.changePasswordSchema = exports.strongPasswordRegex = exports.deleteAccountSchema = 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");
|
|
@@ -120,3 +120,6 @@ Object.defineProperty(exports, "getUserPlansSchema", { enumerable: true, get: fu
|
|
|
120
120
|
Object.defineProperty(exports, "listPlansSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.listPlansSchema; } });
|
|
121
121
|
Object.defineProperty(exports, "recordPaymentSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.recordPaymentSchema; } });
|
|
122
122
|
Object.defineProperty(exports, "deletePlanSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.deletePlanSchema; } });
|
|
123
|
+
var eventlogs_admin_validations_1 = require("./eventlogs.admin.validations");
|
|
124
|
+
Object.defineProperty(exports, "listEventLogsSchema", { enumerable: true, get: function () { return eventlogs_admin_validations_1.listEventLogsSchema; } });
|
|
125
|
+
Object.defineProperty(exports, "getEventLogSchema", { enumerable: true, get: function () { return eventlogs_admin_validations_1.getEventLogSchema; } });
|
|
@@ -2,33 +2,28 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const createProductSchema: z.ZodObject<{
|
|
3
3
|
body: z.ZodObject<{
|
|
4
4
|
name: z.ZodString;
|
|
5
|
-
stock: z.ZodDefault<z.ZodOptional<z.ZodNumber
|
|
5
|
+
stock: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodNumber>>, number, unknown>;
|
|
6
6
|
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
8
7
|
}, "strip", z.ZodTypeAny, {
|
|
9
8
|
name: string;
|
|
10
9
|
stock: number;
|
|
11
|
-
isActive?: boolean | undefined;
|
|
12
10
|
description?: string | null | undefined;
|
|
13
11
|
}, {
|
|
14
12
|
name: string;
|
|
15
|
-
|
|
13
|
+
stock?: unknown;
|
|
16
14
|
description?: string | null | undefined;
|
|
17
|
-
stock?: number | undefined;
|
|
18
15
|
}>;
|
|
19
16
|
}, "strip", z.ZodTypeAny, {
|
|
20
17
|
body: {
|
|
21
18
|
name: string;
|
|
22
19
|
stock: number;
|
|
23
|
-
isActive?: boolean | undefined;
|
|
24
20
|
description?: string | null | undefined;
|
|
25
21
|
};
|
|
26
22
|
}, {
|
|
27
23
|
body: {
|
|
28
24
|
name: string;
|
|
29
|
-
|
|
25
|
+
stock?: unknown;
|
|
30
26
|
description?: string | null | undefined;
|
|
31
|
-
stock?: number | undefined;
|
|
32
27
|
};
|
|
33
28
|
}>;
|
|
34
29
|
export declare const updateProductSchema: z.ZodObject<{
|
|
@@ -40,41 +35,41 @@ export declare const updateProductSchema: z.ZodObject<{
|
|
|
40
35
|
id: string;
|
|
41
36
|
}>;
|
|
42
37
|
body: z.ZodObject<{
|
|
43
|
-
name: z.ZodOptional<z.ZodString>;
|
|
44
|
-
description: z.ZodNullable<z.ZodOptional<z.ZodString
|
|
45
|
-
stock: z.ZodOptional<z.ZodNumber>;
|
|
46
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
name: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, unknown>;
|
|
39
|
+
description: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string | null | undefined, unknown>;
|
|
40
|
+
stock: z.ZodEffects<z.ZodOptional<z.ZodNumber>, number | undefined, unknown>;
|
|
41
|
+
isActive: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
|
|
47
42
|
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
isActive?: boolean | undefined;
|
|
49
|
-
description?: string | null | undefined;
|
|
50
43
|
name?: string | undefined;
|
|
51
44
|
stock?: number | undefined;
|
|
52
|
-
}, {
|
|
53
|
-
isActive?: boolean | undefined;
|
|
54
45
|
description?: string | null | undefined;
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
isActive?: boolean | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
name?: unknown;
|
|
49
|
+
stock?: unknown;
|
|
50
|
+
description?: unknown;
|
|
51
|
+
isActive?: unknown;
|
|
57
52
|
}>;
|
|
58
53
|
}, "strip", z.ZodTypeAny, {
|
|
59
|
-
body: {
|
|
60
|
-
isActive?: boolean | undefined;
|
|
61
|
-
description?: string | null | undefined;
|
|
62
|
-
name?: string | undefined;
|
|
63
|
-
stock?: number | undefined;
|
|
64
|
-
};
|
|
65
54
|
params: {
|
|
66
55
|
id: string;
|
|
67
56
|
};
|
|
68
|
-
}, {
|
|
69
57
|
body: {
|
|
70
|
-
isActive?: boolean | undefined;
|
|
71
|
-
description?: string | null | undefined;
|
|
72
58
|
name?: string | undefined;
|
|
73
59
|
stock?: number | undefined;
|
|
60
|
+
description?: string | null | undefined;
|
|
61
|
+
isActive?: boolean | undefined;
|
|
74
62
|
};
|
|
63
|
+
}, {
|
|
75
64
|
params: {
|
|
76
65
|
id: string;
|
|
77
66
|
};
|
|
67
|
+
body: {
|
|
68
|
+
name?: unknown;
|
|
69
|
+
stock?: unknown;
|
|
70
|
+
description?: unknown;
|
|
71
|
+
isActive?: unknown;
|
|
72
|
+
};
|
|
78
73
|
}>;
|
|
79
74
|
export declare const getProductSchema: z.ZodObject<{
|
|
80
75
|
params: z.ZodObject<{
|
|
@@ -103,41 +98,41 @@ export declare const getProductsSchema: z.ZodObject<{
|
|
|
103
98
|
sortBy: z.ZodOptional<z.ZodEnum<["name", "stock", "createdAt", "updatedAt"]>>;
|
|
104
99
|
sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
|
|
105
100
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
search?: string | undefined;
|
|
107
|
-
limit?: number | undefined;
|
|
108
101
|
isActive?: "true" | "false" | undefined;
|
|
109
102
|
page?: number | undefined;
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
limit?: number | undefined;
|
|
104
|
+
search?: string | undefined;
|
|
112
105
|
minStock?: number | undefined;
|
|
106
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
107
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
113
108
|
}, {
|
|
114
|
-
search?: string | undefined;
|
|
115
|
-
limit?: string | undefined;
|
|
116
109
|
isActive?: "true" | "false" | undefined;
|
|
117
110
|
page?: string | undefined;
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
limit?: string | undefined;
|
|
112
|
+
search?: string | undefined;
|
|
120
113
|
minStock?: string | undefined;
|
|
114
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
115
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
121
116
|
}>;
|
|
122
117
|
}, "strip", z.ZodTypeAny, {
|
|
123
118
|
query: {
|
|
124
|
-
search?: string | undefined;
|
|
125
|
-
limit?: number | undefined;
|
|
126
119
|
isActive?: "true" | "false" | undefined;
|
|
127
120
|
page?: number | undefined;
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
limit?: number | undefined;
|
|
122
|
+
search?: string | undefined;
|
|
130
123
|
minStock?: number | undefined;
|
|
124
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
125
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
131
126
|
};
|
|
132
127
|
}, {
|
|
133
128
|
query: {
|
|
134
|
-
search?: string | undefined;
|
|
135
|
-
limit?: string | undefined;
|
|
136
129
|
isActive?: "true" | "false" | undefined;
|
|
137
130
|
page?: string | undefined;
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
limit?: string | undefined;
|
|
132
|
+
search?: string | undefined;
|
|
140
133
|
minStock?: string | undefined;
|
|
134
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
135
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
141
136
|
};
|
|
142
137
|
}>;
|
|
143
138
|
export declare const deleteProductSchema: z.ZodObject<{
|
|
@@ -203,26 +198,26 @@ export declare const updateStockSchema: z.ZodObject<{
|
|
|
203
198
|
operation: z.ZodEnum<["increment", "decrement", "set"]>;
|
|
204
199
|
amount: z.ZodNumber;
|
|
205
200
|
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
operation: "set" | "increment" | "decrement";
|
|
206
202
|
amount: number;
|
|
207
|
-
operation: "increment" | "decrement" | "set";
|
|
208
203
|
}, {
|
|
204
|
+
operation: "set" | "increment" | "decrement";
|
|
209
205
|
amount: number;
|
|
210
|
-
operation: "increment" | "decrement" | "set";
|
|
211
206
|
}>;
|
|
212
207
|
}, "strip", z.ZodTypeAny, {
|
|
213
|
-
body: {
|
|
214
|
-
amount: number;
|
|
215
|
-
operation: "increment" | "decrement" | "set";
|
|
216
|
-
};
|
|
217
208
|
params: {
|
|
218
209
|
id: string;
|
|
219
210
|
};
|
|
220
|
-
}, {
|
|
221
211
|
body: {
|
|
212
|
+
operation: "set" | "increment" | "decrement";
|
|
222
213
|
amount: number;
|
|
223
|
-
operation: "increment" | "decrement" | "set";
|
|
224
214
|
};
|
|
215
|
+
}, {
|
|
225
216
|
params: {
|
|
226
217
|
id: string;
|
|
227
218
|
};
|
|
219
|
+
body: {
|
|
220
|
+
operation: "set" | "increment" | "decrement";
|
|
221
|
+
amount: number;
|
|
222
|
+
};
|
|
228
223
|
}>;
|
|
@@ -12,24 +12,25 @@ const productBaseSchema = {
|
|
|
12
12
|
stock: zod_1.z.number().int().min(0, "Stock cannot be negative").optional(),
|
|
13
13
|
isActive: zod_1.z.boolean().optional(),
|
|
14
14
|
};
|
|
15
|
-
//
|
|
15
|
+
// Update product schema to handle FormData strings
|
|
16
16
|
exports.createProductSchema = zod_1.z.object({
|
|
17
17
|
body: zod_1.z.object({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
name: productBaseSchema.name,
|
|
19
|
+
stock: zod_1.z.preprocess((val) => (val ? Number(val) : 1), productBaseSchema.stock.default(1)),
|
|
20
|
+
description: productBaseSchema.description,
|
|
21
|
+
// image is handled by multer, not in validation
|
|
21
22
|
}),
|
|
22
23
|
});
|
|
23
|
-
// Update product schema
|
|
24
|
+
// Update product schema to handle FormData strings
|
|
24
25
|
exports.updateProductSchema = zod_1.z.object({
|
|
25
26
|
params: zod_1.z.object({
|
|
26
27
|
id: zod_1.z.string().uuid("Invalid product ID"),
|
|
27
28
|
}),
|
|
28
29
|
body: zod_1.z.object({
|
|
29
|
-
name: productBaseSchema.name.optional(),
|
|
30
|
-
description: productBaseSchema.description,
|
|
31
|
-
stock: productBaseSchema.stock,
|
|
32
|
-
isActive: productBaseSchema.isActive,
|
|
30
|
+
name: zod_1.z.preprocess((val) => (val === "" ? undefined : val), productBaseSchema.name.optional()),
|
|
31
|
+
description: zod_1.z.preprocess((val) => (val === "" ? null : val), productBaseSchema.description),
|
|
32
|
+
stock: zod_1.z.preprocess((val) => (val ? Number(val) : undefined), productBaseSchema.stock),
|
|
33
|
+
isActive: zod_1.z.preprocess((val) => (val === "true" ? true : val === "false" ? false : undefined), productBaseSchema.isActive),
|
|
33
34
|
}),
|
|
34
35
|
});
|
|
35
36
|
// Get product by ID schema
|