vr-models 1.0.54 → 1.0.56
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.
|
@@ -10,7 +10,7 @@ export interface DeviceSessionPayload {
|
|
|
10
10
|
deviceSerialNumber: string;
|
|
11
11
|
minutesGranted: number;
|
|
12
12
|
}
|
|
13
|
-
export declare const EVENT_ACTIONS: readonly ["USER_READ", "USER_CREATED", "USER_UPDATED", "USER_DELETED", "USER_SUSPENDED", "USER_BANNED", "USER_VERIFIED", "USER_UPGRADED_TO_RIDER", "USERS_LISTED", "ADMIN_FORGOT_PASSWORD", "ADMIN_LOGGED_IN", "ADMIN_LOGGED_OUT", "PASSENGER_ACCOUNT_DEACTIVATED", "PASSENGER_ACCOUNT_DELETED", "AGENT_CREATED_RIDER", "AGENT_UPDATED_RIDER", "ADMIN_CREATED_USER", "ADMIN_UPDATED_USER", "ADMIN_CHANGED_PASSWORD", "ADMIN_RESET_USER_PASSWORD", "ADMIN_BULK_PASSWORD_RESET", "SUPER_ADMIN_PASSWORD_CHANGED", "SUPER_ADMIN_CHANGED_USER_ACCOUNT_STATUS", "SUPER_ADMIN_UPDATED_USER", "SUPER_ADMIN_CREATED_USER", "PRODUCT_CREATED", "PRODUCT_READ", "PRODUCT_UPDATED", "PRODUCT_DELETED", "PRODUCTS_LISTED", "PRODUCTS_ACTIVATED", "PRODUCTS_DEACTIVATED", "PRODUCT_STOCK_SET_MANUALLY", "PRODUCT_STOCK_INCREMENTED", "PRODUCT_STOCK_DECREMENTED", "PRICING_CREATED", "PRICING_READ", "PRICING_UPDATED", "PRICING_DELETED", "DEVICE_CREATED", "DEVICES_BULK_CREATED", "DEVICE_ASSIGNED", "DEVICE_READ", "DEVICE_UPDATED", "DEVICES_LISTED", "DEVICE_LOCKED", "DEVICE_UNLOCKED", "DEVICE_DISABLED", "DEVICE_REACTIVATED", "DEVICE_DELETED_PERMANENTLY", "DEVICE_REPOSSESSED", "DEVICE_PAYMENT_PLAN_CREATED", "DEVICE_PAYMENT_PLAN_READ", "DEVICE_PAYMENT_PLAN_UPDATED", "DEVICE_PAYMENT_PLAN_MARKED_DEFAULTED", "DEVICE_PAYMENT_PLAN_SOFT_DELETED", "DEVICE_PAYMENT_PLAN_DELETED_PERMANENTLY", "PAYMENT_RECORDED", "PAYMENT_READ", "PAYMENTS_LISTED", "TRANSACTION_READ", "TRANSACTIONS_LISTED", "EVENT_LOG_READ", "EVENT_LOGS_LISTED", "SECURITY_CLEARANCE_MANAGED", "DEVICE_LOCK_OVERRIDDEN", "SESSION_EXTENDED"];
|
|
13
|
+
export declare const EVENT_ACTIONS: readonly ["USER_READ", "USER_CREATED", "ADMIN_CREATED", "PROFILE_COMPLETED", "USER_UPDATED", "USER_DELETED", "USER_SUSPENDED", "USER_BANNED", "USER_VERIFIED", "USER_UPGRADED_TO_RIDER", "USERS_LISTED", "ADMIN_FORGOT_PASSWORD", "ADMIN_LOGGED_IN", "ADMIN_LOGGED_OUT", "PASSENGER_ACCOUNT_DEACTIVATED", "PASSENGER_ACCOUNT_DELETED", "AGENT_CREATED_RIDER", "AGENT_UPDATED_RIDER", "ADMIN_CREATED_USER", "ADMIN_UPDATED_USER", "ADMIN_CHANGED_PASSWORD", "ADMIN_RESET_USER_PASSWORD", "ADMIN_BULK_PASSWORD_RESET", "SUPER_ADMIN_PASSWORD_CHANGED", "SUPER_ADMIN_CHANGED_USER_ACCOUNT_STATUS", "SUPER_ADMIN_UPDATED_USER", "SUPER_ADMIN_CREATED_USER", "PRODUCT_CREATED", "PRODUCT_READ", "PRODUCT_UPDATED", "PRODUCT_DELETED", "PRODUCTS_LISTED", "PRODUCTS_ACTIVATED", "PRODUCTS_DEACTIVATED", "PRODUCT_STOCK_SET_MANUALLY", "PRODUCT_STOCK_INCREMENTED", "PRODUCT_STOCK_DECREMENTED", "PRICING_CREATED", "PRICING_READ", "PRICING_UPDATED", "PRICING_DELETED", "DEVICE_CREATED", "DEVICES_BULK_CREATED", "DEVICE_ASSIGNED", "DEVICE_READ", "DEVICE_UPDATED", "DEVICES_LISTED", "DEVICE_LOCKED", "DEVICE_UNLOCKED", "DEVICE_DISABLED", "DEVICE_REACTIVATED", "DEVICE_DELETED_PERMANENTLY", "DEVICE_REPOSSESSED", "DEVICE_PAYMENT_PLAN_CREATED", "DEVICE_PAYMENT_PLAN_READ", "DEVICE_PAYMENT_PLAN_UPDATED", "DEVICE_PAYMENT_PLAN_MARKED_DEFAULTED", "DEVICE_PAYMENT_PLAN_SOFT_DELETED", "DEVICE_PAYMENT_PLAN_DELETED_PERMANENTLY", "PAYMENT_RECORDED", "PAYMENT_READ", "PAYMENTS_LISTED", "TRANSACTION_READ", "TRANSACTIONS_LISTED", "EVENT_LOG_READ", "EVENT_LOGS_LISTED", "SECURITY_CLEARANCE_MANAGED", "DEVICE_LOCK_OVERRIDDEN", "SESSION_EXTENDED"];
|
|
14
14
|
export type EventAction = (typeof EVENT_ACTIONS)[number];
|
|
15
15
|
export interface EventLogAttributes {
|
|
16
16
|
id: string;
|
|
@@ -4,12 +4,15 @@ import type { SecurityClearance } from "./securityClearance.models";
|
|
|
4
4
|
import type { PhoneContact } from "./phoneContact.models";
|
|
5
5
|
import { Ban } from "./ban.models";
|
|
6
6
|
import { Suspension } from "./suspension.models";
|
|
7
|
+
import { DevicePaymentPlan } from "./devicePaymentPlan.models";
|
|
7
8
|
export interface DeletionStatus {
|
|
8
9
|
deleted: boolean;
|
|
9
10
|
deletedAt?: Date | null;
|
|
10
11
|
deletedBy?: string | null;
|
|
11
12
|
reason?: string | null;
|
|
12
13
|
}
|
|
14
|
+
export declare const GENDER_OPTIONS: readonly ["male", "female"];
|
|
15
|
+
export type Gender = (typeof GENDER_OPTIONS)[number];
|
|
13
16
|
export interface UserAttributes {
|
|
14
17
|
id: string;
|
|
15
18
|
firstName: string;
|
|
@@ -19,7 +22,10 @@ export interface UserAttributes {
|
|
|
19
22
|
password?: string | null;
|
|
20
23
|
securityClearanceId: string;
|
|
21
24
|
plateNumber?: string | null;
|
|
22
|
-
|
|
25
|
+
gender: Gender;
|
|
26
|
+
birthDate?: number | null;
|
|
27
|
+
birthMonth?: number | null;
|
|
28
|
+
birthYear?: number | null;
|
|
23
29
|
primaryPhoneId: string | null;
|
|
24
30
|
isActive: boolean;
|
|
25
31
|
forgotPassword: boolean;
|
|
@@ -53,7 +59,10 @@ export declare class User extends Model<InferAttributes<User>, InferCreationAttr
|
|
|
53
59
|
password: CreationOptional<string | null>;
|
|
54
60
|
securityClearanceId: string;
|
|
55
61
|
plateNumber: CreationOptional<string | null>;
|
|
56
|
-
|
|
62
|
+
gender: Gender;
|
|
63
|
+
birthDate: CreationOptional<number | null>;
|
|
64
|
+
birthMonth: CreationOptional<number | null>;
|
|
65
|
+
birthYear: CreationOptional<number | null>;
|
|
57
66
|
primaryPhoneId: CreationOptional<string | null>;
|
|
58
67
|
isActive: CreationOptional<boolean>;
|
|
59
68
|
forgotPassword: CreationOptional<boolean>;
|
|
@@ -64,6 +73,7 @@ export declare class User extends Model<InferAttributes<User>, InferCreationAttr
|
|
|
64
73
|
deletion: CreationOptional<DeletionStatus>;
|
|
65
74
|
readonly createdAt: CreationOptional<Date>;
|
|
66
75
|
payments?: NonAttribute<Payment[]>;
|
|
76
|
+
paymentPlans?: NonAttribute<DevicePaymentPlan[]>;
|
|
67
77
|
securityClearance?: NonAttribute<SecurityClearance>;
|
|
68
78
|
primaryPhone?: NonAttribute<PhoneContact>;
|
|
69
79
|
phones?: NonAttribute<PhoneContact[]>;
|
|
@@ -76,5 +86,7 @@ export declare class User extends Model<InferAttributes<User>, InferCreationAttr
|
|
|
76
86
|
deactivate(): Promise<void>;
|
|
77
87
|
activate(): Promise<void>;
|
|
78
88
|
hasVerifiedPhone(): Promise<boolean>;
|
|
89
|
+
getBirthDate(): Date | null;
|
|
90
|
+
getAge(): number | null;
|
|
79
91
|
}
|
|
80
92
|
export type UserModel = typeof User;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.User = void 0;
|
|
3
|
+
exports.User = exports.GENDER_OPTIONS = void 0;
|
|
4
4
|
// src/models/user.models.ts
|
|
5
5
|
const vr_migrations_1 = require("vr-migrations");
|
|
6
|
+
// ==================== GENDER OPTIONS ====================
|
|
7
|
+
exports.GENDER_OPTIONS = ["male", "female"];
|
|
6
8
|
class User extends vr_migrations_1.Model {
|
|
7
9
|
// Static initialization method
|
|
8
10
|
static initialize(sequelize) {
|
|
@@ -20,11 +22,6 @@ class User extends vr_migrations_1.Model {
|
|
|
20
22
|
type: vr_migrations_1.DataTypes.STRING(100),
|
|
21
23
|
allowNull: false,
|
|
22
24
|
},
|
|
23
|
-
nationalId: {
|
|
24
|
-
type: vr_migrations_1.DataTypes.STRING(100),
|
|
25
|
-
allowNull: true,
|
|
26
|
-
unique: true,
|
|
27
|
-
},
|
|
28
25
|
jacketId: {
|
|
29
26
|
type: vr_migrations_1.DataTypes.STRING(100),
|
|
30
27
|
allowNull: true,
|
|
@@ -47,6 +44,35 @@ class User extends vr_migrations_1.Model {
|
|
|
47
44
|
type: vr_migrations_1.DataTypes.STRING(100),
|
|
48
45
|
allowNull: true,
|
|
49
46
|
},
|
|
47
|
+
gender: {
|
|
48
|
+
type: vr_migrations_1.DataTypes.ENUM("male", "female"),
|
|
49
|
+
allowNull: false,
|
|
50
|
+
defaultValue: "male",
|
|
51
|
+
},
|
|
52
|
+
birthDate: {
|
|
53
|
+
type: vr_migrations_1.DataTypes.INTEGER,
|
|
54
|
+
allowNull: true,
|
|
55
|
+
validate: {
|
|
56
|
+
min: 1,
|
|
57
|
+
max: 31,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
birthMonth: {
|
|
61
|
+
type: vr_migrations_1.DataTypes.INTEGER,
|
|
62
|
+
allowNull: true,
|
|
63
|
+
validate: {
|
|
64
|
+
min: 1,
|
|
65
|
+
max: 12,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
birthYear: {
|
|
69
|
+
type: vr_migrations_1.DataTypes.INTEGER,
|
|
70
|
+
allowNull: true,
|
|
71
|
+
validate: {
|
|
72
|
+
min: 1900,
|
|
73
|
+
max: new Date().getFullYear(),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
50
76
|
primaryPhoneId: {
|
|
51
77
|
type: vr_migrations_1.DataTypes.UUID,
|
|
52
78
|
allowNull: true,
|
|
@@ -122,25 +148,25 @@ class User extends vr_migrations_1.Model {
|
|
|
122
148
|
this.hasMany(models.DevicePaymentPlan, {
|
|
123
149
|
foreignKey: "userId",
|
|
124
150
|
as: "paymentPlans",
|
|
125
|
-
onDelete: "CASCADE",
|
|
151
|
+
onDelete: "CASCADE",
|
|
126
152
|
onUpdate: "CASCADE",
|
|
127
153
|
});
|
|
128
154
|
this.hasMany(models.Payment, {
|
|
129
155
|
foreignKey: "userId",
|
|
130
156
|
as: "payments",
|
|
131
|
-
onDelete: "SET NULL",
|
|
157
|
+
onDelete: "SET NULL",
|
|
132
158
|
onUpdate: "CASCADE",
|
|
133
159
|
});
|
|
134
160
|
this.hasMany(models.Suspension, {
|
|
135
161
|
foreignKey: "userId",
|
|
136
162
|
as: "suspensions",
|
|
137
|
-
onDelete: "SET NULL",
|
|
163
|
+
onDelete: "SET NULL",
|
|
138
164
|
onUpdate: "CASCADE",
|
|
139
165
|
});
|
|
140
166
|
this.hasMany(models.Ban, {
|
|
141
167
|
foreignKey: "userId",
|
|
142
168
|
as: "bans",
|
|
143
|
-
onDelete: "SET NULL",
|
|
169
|
+
onDelete: "SET NULL",
|
|
144
170
|
onUpdate: "CASCADE",
|
|
145
171
|
});
|
|
146
172
|
}
|
|
@@ -182,5 +208,26 @@ class User extends vr_migrations_1.Model {
|
|
|
182
208
|
});
|
|
183
209
|
return !!verifiedPhone;
|
|
184
210
|
}
|
|
211
|
+
// Helper to get full birth date as Date object
|
|
212
|
+
getBirthDate() {
|
|
213
|
+
if (this.birthYear && this.birthMonth && this.birthDate) {
|
|
214
|
+
return new Date(this.birthYear, this.birthMonth - 1, this.birthDate);
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
// Helper to get age
|
|
219
|
+
getAge() {
|
|
220
|
+
const birthDate = this.getBirthDate();
|
|
221
|
+
if (!birthDate)
|
|
222
|
+
return null;
|
|
223
|
+
const today = new Date();
|
|
224
|
+
let age = today.getFullYear() - birthDate.getFullYear();
|
|
225
|
+
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
226
|
+
if (monthDiff < 0 ||
|
|
227
|
+
(monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
|
228
|
+
age--;
|
|
229
|
+
}
|
|
230
|
+
return age;
|
|
231
|
+
}
|
|
185
232
|
}
|
|
186
233
|
exports.User = User;
|