vr-commons 1.0.104 → 1.0.106

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.
@@ -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;
@@ -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";
@@ -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; } });
@@ -4,26 +4,31 @@ export declare const createPlanSchema: z.ZodObject<{
4
4
  userId: z.ZodString;
5
5
  deviceIds: z.ZodArray<z.ZodString, "many">;
6
6
  pricingId: z.ZodString;
7
+ productId: z.ZodString;
7
8
  }, "strip", z.ZodTypeAny, {
8
9
  userId: string;
9
10
  deviceIds: string[];
10
11
  pricingId: string;
12
+ productId: string;
11
13
  }, {
12
14
  userId: string;
13
15
  deviceIds: string[];
14
16
  pricingId: string;
17
+ productId: string;
15
18
  }>;
16
19
  }, "strip", z.ZodTypeAny, {
17
20
  body: {
18
21
  userId: string;
19
22
  deviceIds: string[];
20
23
  pricingId: string;
24
+ productId: string;
21
25
  };
22
26
  }, {
23
27
  body: {
24
28
  userId: string;
25
29
  deviceIds: string[];
26
30
  pricingId: string;
31
+ productId: string;
27
32
  };
28
33
  }>;
29
34
  export declare const listPlansSchema: z.ZodObject<{
@@ -38,49 +43,49 @@ export declare const listPlansSchema: z.ZodObject<{
38
43
  sortBy: z.ZodOptional<z.ZodEnum<["createdAt", "updatedAt", "nextInstallmentDueAt", "paidAmount", "outstandingAmount"]>>;
39
44
  sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
40
45
  }, "strip", z.ZodTypeAny, {
41
- limit: number;
42
46
  page: number;
43
- search?: string | undefined;
47
+ limit: number;
48
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
44
49
  userId?: string | undefined;
45
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
46
- sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
47
- sortOrder?: "DESC" | "ASC" | undefined;
48
50
  deviceId?: string | undefined;
49
51
  isOverdue?: "true" | "false" | undefined;
50
- }, {
51
52
  search?: string | undefined;
52
- limit?: string | undefined;
53
+ sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
54
+ sortOrder?: "ASC" | "DESC" | undefined;
55
+ }, {
56
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
53
57
  userId?: string | undefined;
54
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
55
58
  page?: string | undefined;
56
- sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
57
- sortOrder?: "DESC" | "ASC" | undefined;
59
+ limit?: string | undefined;
58
60
  deviceId?: string | undefined;
59
61
  isOverdue?: "true" | "false" | undefined;
62
+ search?: string | undefined;
63
+ sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
64
+ sortOrder?: "ASC" | "DESC" | undefined;
60
65
  }>;
61
66
  }, "strip", z.ZodTypeAny, {
62
67
  query: {
63
- limit: number;
64
68
  page: number;
65
- search?: string | undefined;
69
+ limit: number;
70
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
66
71
  userId?: string | undefined;
67
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
68
- sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
69
- sortOrder?: "DESC" | "ASC" | undefined;
70
72
  deviceId?: string | undefined;
71
73
  isOverdue?: "true" | "false" | undefined;
74
+ search?: string | undefined;
75
+ sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
76
+ sortOrder?: "ASC" | "DESC" | undefined;
72
77
  };
73
78
  }, {
74
79
  query: {
75
- search?: string | undefined;
76
- limit?: string | undefined;
80
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
77
81
  userId?: string | undefined;
78
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
79
82
  page?: string | undefined;
80
- sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
81
- sortOrder?: "DESC" | "ASC" | undefined;
83
+ limit?: string | undefined;
82
84
  deviceId?: string | undefined;
83
85
  isOverdue?: "true" | "false" | undefined;
86
+ search?: string | undefined;
87
+ sortBy?: "createdAt" | "updatedAt" | "nextInstallmentDueAt" | "paidAmount" | "outstandingAmount" | undefined;
88
+ sortOrder?: "ASC" | "DESC" | undefined;
84
89
  };
85
90
  }>;
86
91
  export declare const getPlanSchema: z.ZodObject<{
@@ -112,10 +117,10 @@ export declare const getUserPlansSchema: z.ZodObject<{
112
117
  status: z.ZodOptional<z.ZodEnum<["ACTIVE", "COMPLETED", "DEFAULTED", "CANCELLED"]>>;
113
118
  includeCompleted: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
114
119
  }, "strip", z.ZodTypeAny, {
115
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
120
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
116
121
  includeCompleted?: "true" | "false" | undefined;
117
122
  }, {
118
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
123
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
119
124
  includeCompleted?: "true" | "false" | undefined;
120
125
  }>>;
121
126
  }, "strip", z.ZodTypeAny, {
@@ -123,7 +128,7 @@ export declare const getUserPlansSchema: z.ZodObject<{
123
128
  userId: string;
124
129
  };
125
130
  query?: {
126
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
131
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
127
132
  includeCompleted?: "true" | "false" | undefined;
128
133
  } | undefined;
129
134
  }, {
@@ -131,7 +136,7 @@ export declare const getUserPlansSchema: z.ZodObject<{
131
136
  userId: string;
132
137
  };
133
138
  query?: {
134
- status?: "ACTIVE" | "DEFAULTED" | "COMPLETED" | "CANCELLED" | undefined;
139
+ status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
135
140
  includeCompleted?: "true" | "false" | undefined;
136
141
  } | undefined;
137
142
  }>;
@@ -162,36 +167,43 @@ export declare const limitedUpdateSchema: z.ZodObject<{
162
167
  }>;
163
168
  body: z.ZodEffects<z.ZodObject<{
164
169
  pricingId: z.ZodOptional<z.ZodString>;
170
+ productId: z.ZodString;
165
171
  userId: z.ZodOptional<z.ZodString>;
166
172
  }, "strip", z.ZodTypeAny, {
173
+ productId: string;
167
174
  userId?: string | undefined;
168
175
  pricingId?: string | undefined;
169
176
  }, {
177
+ productId: string;
170
178
  userId?: string | undefined;
171
179
  pricingId?: string | undefined;
172
180
  }>, {
181
+ productId: string;
173
182
  userId?: string | undefined;
174
183
  pricingId?: string | undefined;
175
184
  }, {
185
+ productId: string;
176
186
  userId?: string | undefined;
177
187
  pricingId?: string | undefined;
178
188
  }>;
179
189
  }, "strip", z.ZodTypeAny, {
190
+ params: {
191
+ id: string;
192
+ };
180
193
  body: {
194
+ productId: string;
181
195
  userId?: string | undefined;
182
196
  pricingId?: string | undefined;
183
197
  };
198
+ }, {
184
199
  params: {
185
200
  id: string;
186
201
  };
187
- }, {
188
202
  body: {
203
+ productId: string;
189
204
  userId?: string | undefined;
190
205
  pricingId?: string | undefined;
191
206
  };
192
- params: {
193
- id: string;
194
- };
195
207
  }>;
196
208
  export declare const recordPaymentSchema: z.ZodObject<{
197
209
  params: z.ZodObject<{
@@ -209,33 +221,33 @@ export declare const recordPaymentSchema: z.ZodObject<{
209
221
  }, "strip", z.ZodTypeAny, {
210
222
  amount: number;
211
223
  provider: "mtn_momo" | "airtel_money";
212
- metadata?: Record<string, any> | undefined;
213
224
  providerReference?: string | undefined;
225
+ metadata?: Record<string, any> | undefined;
214
226
  }, {
215
227
  amount: number;
216
228
  provider: "mtn_momo" | "airtel_money";
217
- metadata?: Record<string, any> | undefined;
218
229
  providerReference?: string | undefined;
230
+ metadata?: Record<string, any> | undefined;
219
231
  }>;
220
232
  }, "strip", z.ZodTypeAny, {
233
+ params: {
234
+ id: string;
235
+ };
221
236
  body: {
222
237
  amount: number;
223
238
  provider: "mtn_momo" | "airtel_money";
224
- metadata?: Record<string, any> | undefined;
225
239
  providerReference?: string | undefined;
240
+ metadata?: Record<string, any> | undefined;
226
241
  };
242
+ }, {
227
243
  params: {
228
244
  id: string;
229
245
  };
230
- }, {
231
246
  body: {
232
247
  amount: number;
233
248
  provider: "mtn_momo" | "airtel_money";
234
- metadata?: Record<string, any> | undefined;
235
249
  providerReference?: string | undefined;
236
- };
237
- params: {
238
- id: string;
250
+ metadata?: Record<string, any> | undefined;
239
251
  };
240
252
  }>;
241
253
  export declare const deletePlanSchema: z.ZodObject<{
@@ -12,6 +12,7 @@ exports.createPlanSchema = zod_1.z.object({
12
12
  .min(1, "At least one device required")
13
13
  .max(10, "Maximum 10 devices per plan"),
14
14
  pricingId: zod_1.z.string().uuid("Invalid pricing ID"),
15
+ productId: zod_1.z.string().uuid("Invalid product ID"),
15
16
  }),
16
17
  });
17
18
  // ==================== READ ====================
@@ -67,6 +68,7 @@ exports.limitedUpdateSchema = zod_1.z.object({
67
68
  .object({
68
69
  // Can update pricing before any payments
69
70
  pricingId: zod_1.z.string().uuid("Invalid pricing ID").optional(),
71
+ productId: zod_1.z.string().uuid("Invalid product ID"),
70
72
  // Can reassign to different user before any payments
71
73
  userId: zod_1.z.string().uuid("Invalid user ID").optional(),
72
74
  })
@@ -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; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-commons",
3
- "version": "1.0.104",
3
+ "version": "1.0.106",
4
4
  "description": "Shared functions package",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",