vr-commons 1.0.61 → 1.0.62

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.
@@ -1,4 +1,4 @@
1
- import { EventAction, UserRole, SessionPayload } from "vr-models";
1
+ import { EventAction, UserRole, DeviceSessionPayload } from "vr-models";
2
2
  import { Transaction } from "sequelize";
3
3
  interface LogEventInput {
4
4
  actorId?: string | null;
@@ -10,7 +10,7 @@ interface LogEventInput {
10
10
  ipAddress?: string | null;
11
11
  userAgent?: string | null;
12
12
  transaction?: Transaction;
13
- session: SessionPayload;
13
+ deviceSession: DeviceSessionPayload;
14
14
  }
15
- export declare const logEvent: ({ actorId, actorType, action, entity, entityId, metadata, ipAddress, userAgent, transaction, session, }: LogEventInput) => Promise<void>;
15
+ export declare const logEvent: ({ actorId, actorType, action, entity, entityId, metadata, ipAddress, userAgent, transaction, deviceSession, }: LogEventInput) => Promise<void>;
16
16
  export {};
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logEvent = void 0;
4
4
  const vr_models_1 = require("vr-models");
5
- const logEvent = async ({ actorId = null, actorType = "ADMIN", action, entity, entityId = null, metadata = {}, ipAddress = null, userAgent = null, transaction, session, // Required session parameter matching the model
5
+ const logEvent = async ({ actorId = null, actorType = "ADMIN", action, entity, entityId = null, metadata = {}, ipAddress = null, userAgent = null, transaction, deviceSession, // Required session parameter matching the model
6
6
  }) => {
7
7
  try {
8
8
  // Create event log with optional transaction
@@ -16,7 +16,7 @@ const logEvent = async ({ actorId = null, actorType = "ADMIN", action, entity, e
16
16
  metadata,
17
17
  ipAddress,
18
18
  userAgent,
19
- session, // Now passed as dedicated field matching the model
19
+ deviceSession, // Now passed as dedicated field matching the model
20
20
  }, { transaction });
21
21
  }
22
22
  catch (err) {
@@ -1,6 +1,6 @@
1
- import { SessionPayload } from "vr-models";
1
+ import { DeviceSessionPayload } from "vr-models";
2
2
  /**
3
3
  * Create a new device session (for BLE unlock)
4
4
  * This is separate from the long-lasting auth token
5
5
  */
6
- export declare const createDeviceSession: (userId: string, tokenVersion: number) => SessionPayload;
6
+ export declare const createDeviceSession: (userId: string, tokenVersion: number, deviceSerialNumber: string) => DeviceSessionPayload;
@@ -8,7 +8,7 @@ const SESSION_DURATION = parseInt(process.env.DEVICE_SESSION_DURATION || "15") *
8
8
  * Create a new device session (for BLE unlock)
9
9
  * This is separate from the long-lasting auth token
10
10
  */
11
- const createDeviceSession = (userId, tokenVersion) => {
11
+ const createDeviceSession = (userId, tokenVersion, deviceSerialNumber) => {
12
12
  const now = Date.now();
13
13
  return {
14
14
  sessionId: (0, uuid_1.v4)(),
@@ -16,6 +16,8 @@ const createDeviceSession = (userId, tokenVersion) => {
16
16
  expiresAt: now + SESSION_DURATION,
17
17
  userId,
18
18
  tokenVersion,
19
+ deviceSerialNumber,
20
+ minutesGranted: SESSION_DURATION,
19
21
  };
20
22
  };
21
23
  exports.createDeviceSession = createDeviceSession;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  export declare const listUserPaymentPlansSchema: z.ZodObject<{
3
3
  query: z.ZodObject<{
4
- status: z.ZodOptional<z.ZodEnum<["ACTIVE", "COMPLETED", "DEFAULTED", "CANCELLED"]>>;
4
+ status: z.ZodOptional<z.ZodEnum<["pending", "succeeded", "failed"]>>;
5
5
  page: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>, z.ZodNumber>;
6
6
  limit: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>, z.ZodNumber>;
7
7
  sortBy: z.ZodOptional<z.ZodEnum<["createdAt", "updatedAt", "nextInstallmentDueAt", "status"]>>;
@@ -9,12 +9,12 @@ export declare const listUserPaymentPlansSchema: z.ZodObject<{
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  limit: number;
11
11
  page: number;
12
- status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
12
+ status?: "pending" | "succeeded" | "failed" | undefined;
13
13
  sortBy?: "createdAt" | "updatedAt" | "status" | "nextInstallmentDueAt" | undefined;
14
14
  sortOrder?: "DESC" | "ASC" | undefined;
15
15
  }, {
16
16
  limit?: string | undefined;
17
- status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
17
+ status?: "pending" | "succeeded" | "failed" | undefined;
18
18
  page?: string | undefined;
19
19
  sortBy?: "createdAt" | "updatedAt" | "status" | "nextInstallmentDueAt" | undefined;
20
20
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -23,14 +23,14 @@ export declare const listUserPaymentPlansSchema: z.ZodObject<{
23
23
  query: {
24
24
  limit: number;
25
25
  page: number;
26
- status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
26
+ status?: "pending" | "succeeded" | "failed" | undefined;
27
27
  sortBy?: "createdAt" | "updatedAt" | "status" | "nextInstallmentDueAt" | undefined;
28
28
  sortOrder?: "DESC" | "ASC" | undefined;
29
29
  };
30
30
  }, {
31
31
  query: {
32
32
  limit?: string | undefined;
33
- status?: "ACTIVE" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
33
+ status?: "pending" | "succeeded" | "failed" | undefined;
34
34
  page?: string | undefined;
35
35
  sortBy?: "createdAt" | "updatedAt" | "status" | "nextInstallmentDueAt" | undefined;
36
36
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -21,20 +21,20 @@ export declare const extendSessionSchema: z.ZodObject<{
21
21
  deviceSerialNumber: z.ZodString;
22
22
  sessionId: z.ZodString;
23
23
  }, "strip", z.ZodTypeAny, {
24
- deviceSerialNumber: string;
25
24
  sessionId: string;
26
- }, {
27
25
  deviceSerialNumber: string;
26
+ }, {
28
27
  sessionId: string;
28
+ deviceSerialNumber: string;
29
29
  }>;
30
30
  }, "strip", z.ZodTypeAny, {
31
31
  body: {
32
- deviceSerialNumber: string;
33
32
  sessionId: string;
33
+ deviceSerialNumber: string;
34
34
  };
35
35
  }, {
36
36
  body: {
37
- deviceSerialNumber: string;
38
37
  sessionId: string;
38
+ deviceSerialNumber: string;
39
39
  };
40
40
  }>;
@@ -111,7 +111,7 @@ export declare const listSuspensionsSchema: z.ZodObject<{
111
111
  userId?: string | undefined;
112
112
  appealStatus?: "pending" | "approved" | "rejected" | undefined;
113
113
  status?: "active" | "revoked" | "expired" | undefined;
114
- sortBy?: "createdAt" | "reason" | "endsAt" | "startedAt" | undefined;
114
+ sortBy?: "createdAt" | "startedAt" | "reason" | "endsAt" | undefined;
115
115
  fromDate?: string | undefined;
116
116
  toDate?: string | undefined;
117
117
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -122,7 +122,7 @@ export declare const listSuspensionsSchema: z.ZodObject<{
122
122
  appealStatus?: "pending" | "approved" | "rejected" | undefined;
123
123
  status?: "active" | "revoked" | "expired" | undefined;
124
124
  page?: string | undefined;
125
- sortBy?: "createdAt" | "reason" | "endsAt" | "startedAt" | undefined;
125
+ sortBy?: "createdAt" | "startedAt" | "reason" | "endsAt" | undefined;
126
126
  fromDate?: string | undefined;
127
127
  toDate?: string | undefined;
128
128
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -133,7 +133,7 @@ export declare const listSuspensionsSchema: z.ZodObject<{
133
133
  userId?: string | undefined;
134
134
  appealStatus?: "pending" | "approved" | "rejected" | undefined;
135
135
  status?: "active" | "revoked" | "expired" | undefined;
136
- sortBy?: "createdAt" | "reason" | "endsAt" | "startedAt" | undefined;
136
+ sortBy?: "createdAt" | "startedAt" | "reason" | "endsAt" | undefined;
137
137
  fromDate?: string | undefined;
138
138
  toDate?: string | undefined;
139
139
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -144,7 +144,7 @@ export declare const listSuspensionsSchema: z.ZodObject<{
144
144
  appealStatus?: "pending" | "approved" | "rejected" | undefined;
145
145
  status?: "active" | "revoked" | "expired" | undefined;
146
146
  page?: string | undefined;
147
- sortBy?: "createdAt" | "reason" | "endsAt" | "startedAt" | undefined;
147
+ sortBy?: "createdAt" | "startedAt" | "reason" | "endsAt" | undefined;
148
148
  fromDate?: string | undefined;
149
149
  toDate?: string | undefined;
150
150
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -157,7 +157,7 @@ export declare const listSuspensionsSchema: z.ZodObject<{
157
157
  userId?: string | undefined;
158
158
  appealStatus?: "pending" | "approved" | "rejected" | undefined;
159
159
  status?: "active" | "revoked" | "expired" | undefined;
160
- sortBy?: "createdAt" | "reason" | "endsAt" | "startedAt" | undefined;
160
+ sortBy?: "createdAt" | "startedAt" | "reason" | "endsAt" | undefined;
161
161
  fromDate?: string | undefined;
162
162
  toDate?: string | undefined;
163
163
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -170,7 +170,7 @@ export declare const listSuspensionsSchema: z.ZodObject<{
170
170
  appealStatus?: "pending" | "approved" | "rejected" | undefined;
171
171
  status?: "active" | "revoked" | "expired" | undefined;
172
172
  page?: string | undefined;
173
- sortBy?: "createdAt" | "reason" | "endsAt" | "startedAt" | undefined;
173
+ sortBy?: "createdAt" | "startedAt" | "reason" | "endsAt" | undefined;
174
174
  fromDate?: string | undefined;
175
175
  toDate?: string | undefined;
176
176
  sortOrder?: "DESC" | "ASC" | undefined;
@@ -20,7 +20,7 @@ export declare const createUserSchema: z.ZodObject<{
20
20
  phoneNumber: string;
21
21
  password: string;
22
22
  nationalId: string;
23
- role: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN";
23
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
24
24
  jacketId?: string | null | undefined;
25
25
  email?: string | null | undefined;
26
26
  plateNumber?: string | null | undefined;
@@ -30,7 +30,7 @@ export declare const createUserSchema: z.ZodObject<{
30
30
  phoneNumber: string;
31
31
  password: string;
32
32
  nationalId: string;
33
- role: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN";
33
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
34
34
  jacketId?: string | null | undefined;
35
35
  email?: string | null | undefined;
36
36
  plateNumber?: string | null | undefined;
@@ -49,7 +49,7 @@ export declare const createUserSchema: z.ZodObject<{
49
49
  phoneNumber: string;
50
50
  password: string;
51
51
  nationalId: string;
52
- role: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN";
52
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
53
53
  jacketId?: string | null | undefined;
54
54
  email?: string | null | undefined;
55
55
  plateNumber?: string | null | undefined;
@@ -64,7 +64,7 @@ export declare const createUserSchema: z.ZodObject<{
64
64
  phoneNumber: string;
65
65
  password: string;
66
66
  nationalId: string;
67
- role: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN";
67
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
68
68
  jacketId?: string | null | undefined;
69
69
  email?: string | null | undefined;
70
70
  plateNumber?: string | null | undefined;
@@ -221,11 +221,11 @@ export declare const getAllUsersSchema: z.ZodObject<{
221
221
  order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
222
222
  }, "strip", z.ZodTypeAny, {
223
223
  order: "asc" | "desc";
224
- sortBy: "firstName" | "lastLoginAt" | "createdAt";
224
+ sortBy: "createdAt" | "firstName" | "lastLoginAt";
225
225
  search?: string | undefined;
226
226
  limit?: number | undefined;
227
227
  isActive?: boolean | undefined;
228
- role?: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN" | undefined;
228
+ role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
229
229
  isBanned?: boolean | undefined;
230
230
  isSuspended?: boolean | undefined;
231
231
  page?: number | undefined;
@@ -236,13 +236,13 @@ export declare const getAllUsersSchema: z.ZodObject<{
236
236
  order?: "asc" | "desc" | undefined;
237
237
  limit?: string | undefined;
238
238
  isActive?: "true" | "false" | undefined;
239
- role?: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN" | undefined;
239
+ role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
240
240
  isBanned?: "true" | "false" | undefined;
241
241
  isSuspended?: "true" | "false" | undefined;
242
242
  page?: string | undefined;
243
243
  startDate?: string | undefined;
244
244
  endDate?: string | undefined;
245
- sortBy?: "firstName" | "lastLoginAt" | "createdAt" | undefined;
245
+ sortBy?: "createdAt" | "firstName" | "lastLoginAt" | undefined;
246
246
  }>;
247
247
  headers: z.ZodObject<{
248
248
  authorization: z.ZodString;
@@ -254,11 +254,11 @@ export declare const getAllUsersSchema: z.ZodObject<{
254
254
  }, "strip", z.ZodTypeAny, {
255
255
  query: {
256
256
  order: "asc" | "desc";
257
- sortBy: "firstName" | "lastLoginAt" | "createdAt";
257
+ sortBy: "createdAt" | "firstName" | "lastLoginAt";
258
258
  search?: string | undefined;
259
259
  limit?: number | undefined;
260
260
  isActive?: boolean | undefined;
261
- role?: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN" | undefined;
261
+ role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
262
262
  isBanned?: boolean | undefined;
263
263
  isSuspended?: boolean | undefined;
264
264
  page?: number | undefined;
@@ -274,13 +274,13 @@ export declare const getAllUsersSchema: z.ZodObject<{
274
274
  order?: "asc" | "desc" | undefined;
275
275
  limit?: string | undefined;
276
276
  isActive?: "true" | "false" | undefined;
277
- role?: "ADMIN" | "PASSENGER" | "RIDER" | "AGENT" | "SUPER_ADMIN" | undefined;
277
+ role?: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN" | undefined;
278
278
  isBanned?: "true" | "false" | undefined;
279
279
  isSuspended?: "true" | "false" | undefined;
280
280
  page?: string | undefined;
281
281
  startDate?: string | undefined;
282
282
  endDate?: string | undefined;
283
- sortBy?: "firstName" | "lastLoginAt" | "createdAt" | undefined;
283
+ sortBy?: "createdAt" | "firstName" | "lastLoginAt" | undefined;
284
284
  };
285
285
  headers: {
286
286
  authorization: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-commons",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
4
4
  "description": "Shared functions package",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -100,7 +100,7 @@
100
100
  "date-fns": "^4.1.0",
101
101
  "rimraf": "^5.0.5",
102
102
  "typescript": "^5.3.3",
103
- "vr-models": "^1.0.39",
103
+ "vr-models": "^1.0.42",
104
104
  "zod": "^3.25.20"
105
105
  },
106
106
  "dependencies": {