vr-models 1.0.42 → 1.0.43

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.
@@ -22,7 +22,7 @@ export interface EventLogAttributes {
22
22
  metadata: Record<string, any>;
23
23
  ipAddress: string | null;
24
24
  userAgent: string | null;
25
- deviceSession: DeviceSessionPayload | null;
25
+ deviceSession?: DeviceSessionPayload | null;
26
26
  authTokenVersion?: number;
27
27
  createdAt: Date;
28
28
  actor?: User;
@@ -112,10 +112,11 @@ class EventLog extends vr_migrations_1.Model {
112
112
  type: vr_migrations_1.DataTypes.TEXT,
113
113
  allowNull: true,
114
114
  },
115
+ // In EventLog.initialize()
115
116
  deviceSession: {
116
117
  type: vr_migrations_1.DataTypes.JSONB,
117
118
  allowNull: true,
118
- field: "session", // Keep column name as 'session' for backward compatibility
119
+ field: "session",
119
120
  validate: {
120
121
  isValidDeviceSessionObject(value) {
121
122
  if (value === null || value === undefined)
@@ -123,12 +124,44 @@ class EventLog extends vr_migrations_1.Model {
123
124
  if (typeof value !== "object" || Array.isArray(value)) {
124
125
  throw new Error("Device session must be a session object");
125
126
  }
126
- if (typeof value.sessionId !== "string" ||
127
- typeof value.startedAt !== "number" ||
128
- typeof value.expiresAt !== "number" ||
129
- typeof value.userId !== "string" ||
130
- typeof value.tokenVersion !== "number") {
131
- throw new Error("Invalid device session object: must have sessionId, startedAt, expiresAt, userId, and tokenVersion");
127
+ // Required fields for device sessions
128
+ const required = [
129
+ "sessionId",
130
+ "startedAt",
131
+ "expiresAt",
132
+ "userId",
133
+ "tokenVersion",
134
+ "deviceSerialNumber",
135
+ "minutesGranted",
136
+ "isExtension",
137
+ "paymentPlanId",
138
+ ];
139
+ for (const field of required) {
140
+ if (!(field in value)) {
141
+ throw new Error(`Device session missing required field: ${field}`);
142
+ }
143
+ }
144
+ // Type validation
145
+ if (typeof value.sessionId !== "string") {
146
+ throw new Error("sessionId must be a string");
147
+ }
148
+ if (typeof value.startedAt !== "number") {
149
+ throw new Error("startedAt must be a number");
150
+ }
151
+ if (typeof value.expiresAt !== "number") {
152
+ throw new Error("expiresAt must be a number");
153
+ }
154
+ if (typeof value.userId !== "string") {
155
+ throw new Error("userId must be a string");
156
+ }
157
+ if (typeof value.tokenVersion !== "number") {
158
+ throw new Error("tokenVersion must be a number");
159
+ }
160
+ if (typeof value.deviceSerialNumber !== "string") {
161
+ throw new Error("deviceSerialNumber must be a string");
162
+ }
163
+ if (typeof value.minutesGranted !== "number") {
164
+ throw new Error("minutesGranted must be a number");
132
165
  }
133
166
  },
134
167
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-models",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "Shared database models package for VR applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",