vr-models 1.0.1 → 1.0.3
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/models/device.models.d.ts +28 -3
- package/dist/models/device.models.js +91 -48
- package/dist/models/devicePaymentPlan.models.d.ts +41 -4
- package/dist/models/devicePaymentPlan.models.js +159 -91
- package/dist/models/eventLog.models.d.ts +34 -7
- package/dist/models/eventLog.models.js +40 -0
- package/dist/models/idempotencyRecord.models.d.ts +27 -2
- package/dist/models/idempotencyRecord.models.js +27 -0
- package/dist/models/payment.models.d.ts +46 -7
- package/dist/models/payment.models.js +77 -2
- package/dist/models/pricing.models.d.ts +30 -5
- package/dist/models/pricing.models.js +29 -1
- package/dist/models/product.models.d.ts +31 -4
- package/dist/models/product.models.js +53 -2
- package/dist/models/securityClearance.models.d.ts +30 -5
- package/dist/models/securityClearance.models.js +90 -48
- package/dist/models/transaction.models.d.ts +30 -4
- package/dist/models/transaction.models.js +60 -3
- package/dist/models/user.models.d.ts +51 -3
- package/dist/models/user.models.js +195 -115
- package/package.json +1 -1
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ModelStatic } from "vr-migrations";
|
|
2
|
+
import type { Payment } from "./payment.models";
|
|
3
|
+
import type { User } from "./user.models";
|
|
2
4
|
export type TransactionStatus = "succeeded" | "failed";
|
|
3
|
-
export
|
|
4
|
-
id:
|
|
5
|
+
export interface TransactionAttributes {
|
|
6
|
+
id: string;
|
|
5
7
|
userId: string;
|
|
6
8
|
paymentId: string;
|
|
7
9
|
amount: number;
|
|
8
10
|
status: TransactionStatus;
|
|
9
11
|
providerReference: string;
|
|
10
12
|
metadata: Record<string, any>;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
payment?: Payment;
|
|
16
|
+
user?: User;
|
|
17
|
+
}
|
|
18
|
+
export interface TransactionCreationAttributes extends Omit<TransactionAttributes, "id" | "createdAt" | "updatedAt" | "metadata"> {
|
|
19
|
+
id?: string;
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
export declare class Transaction extends Model<InferAttributes<Transaction>, InferCreationAttributes<Transaction>> implements TransactionAttributes {
|
|
23
|
+
id: CreationOptional<string>;
|
|
24
|
+
userId: string;
|
|
25
|
+
paymentId: string;
|
|
26
|
+
amount: number;
|
|
27
|
+
status: TransactionStatus;
|
|
28
|
+
providerReference: string;
|
|
29
|
+
metadata: CreationOptional<Record<string, any>>;
|
|
11
30
|
readonly createdAt: CreationOptional<Date>;
|
|
12
31
|
readonly updatedAt: CreationOptional<Date>;
|
|
13
|
-
payment?: NonAttribute<
|
|
14
|
-
user?: NonAttribute<
|
|
32
|
+
payment?: NonAttribute<Payment>;
|
|
33
|
+
user?: NonAttribute<User>;
|
|
15
34
|
static initialize(sequelize: any): void;
|
|
16
35
|
static associate(models: Record<string, ModelStatic<Model>>): void;
|
|
36
|
+
markAsSucceeded(metadata?: Record<string, any>): Promise<void>;
|
|
37
|
+
markAsFailed(reason: string, metadata?: Record<string, any>): Promise<void>;
|
|
38
|
+
isSuccessful(): boolean;
|
|
39
|
+
isFailed(): boolean;
|
|
40
|
+
getFormattedAmount(): string;
|
|
41
|
+
static getUserTransactions(userId: string, limit?: number): Promise<Transaction[]>;
|
|
42
|
+
static getPaymentTransactions(paymentId: string): Promise<Transaction[]>;
|
|
17
43
|
}
|
|
18
44
|
export type TransactionModel = typeof Transaction;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Transaction = void 0;
|
|
4
4
|
const vr_migrations_1 = require("vr-migrations");
|
|
5
5
|
class Transaction extends vr_migrations_1.Model {
|
|
6
|
+
// Static initialization method
|
|
6
7
|
static initialize(sequelize) {
|
|
7
8
|
this.init({
|
|
8
9
|
id: {
|
|
@@ -22,7 +23,11 @@ class Transaction extends vr_migrations_1.Model {
|
|
|
22
23
|
allowNull: false,
|
|
23
24
|
},
|
|
24
25
|
providerReference: { type: vr_migrations_1.DataTypes.STRING, allowNull: false },
|
|
25
|
-
metadata: {
|
|
26
|
+
metadata: {
|
|
27
|
+
type: vr_migrations_1.DataTypes.JSONB,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: {},
|
|
30
|
+
},
|
|
26
31
|
createdAt: { type: vr_migrations_1.DataTypes.DATE, defaultValue: vr_migrations_1.DataTypes.NOW },
|
|
27
32
|
updatedAt: { type: vr_migrations_1.DataTypes.DATE, defaultValue: vr_migrations_1.DataTypes.NOW },
|
|
28
33
|
}, {
|
|
@@ -32,9 +37,61 @@ class Transaction extends vr_migrations_1.Model {
|
|
|
32
37
|
timestamps: true,
|
|
33
38
|
});
|
|
34
39
|
}
|
|
40
|
+
// Static association method
|
|
35
41
|
static associate(models) {
|
|
36
|
-
this.belongsTo(models.Payment, {
|
|
37
|
-
|
|
42
|
+
this.belongsTo(models.Payment, {
|
|
43
|
+
foreignKey: "paymentId",
|
|
44
|
+
as: "payment",
|
|
45
|
+
onDelete: "CASCADE",
|
|
46
|
+
onUpdate: "CASCADE",
|
|
47
|
+
});
|
|
48
|
+
this.belongsTo(models.User, {
|
|
49
|
+
foreignKey: "userId",
|
|
50
|
+
as: "user",
|
|
51
|
+
onDelete: "RESTRICT",
|
|
52
|
+
onUpdate: "CASCADE",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Custom instance methods
|
|
56
|
+
async markAsSucceeded(metadata) {
|
|
57
|
+
this.status = "succeeded";
|
|
58
|
+
if (metadata) {
|
|
59
|
+
this.metadata = { ...this.metadata, ...metadata };
|
|
60
|
+
}
|
|
61
|
+
await this.save();
|
|
62
|
+
}
|
|
63
|
+
async markAsFailed(reason, metadata) {
|
|
64
|
+
this.status = "failed";
|
|
65
|
+
const failureMetadata = {
|
|
66
|
+
failureReason: reason,
|
|
67
|
+
failedAt: new Date().toISOString(),
|
|
68
|
+
...metadata,
|
|
69
|
+
};
|
|
70
|
+
this.metadata = { ...this.metadata, ...failureMetadata };
|
|
71
|
+
await this.save();
|
|
72
|
+
}
|
|
73
|
+
isSuccessful() {
|
|
74
|
+
return this.status === "succeeded";
|
|
75
|
+
}
|
|
76
|
+
isFailed() {
|
|
77
|
+
return this.status === "failed";
|
|
78
|
+
}
|
|
79
|
+
getFormattedAmount() {
|
|
80
|
+
return `RWF ${this.amount.toLocaleString()}`;
|
|
81
|
+
}
|
|
82
|
+
static async getUserTransactions(userId, limit = 50) {
|
|
83
|
+
return await this.findAll({
|
|
84
|
+
where: { userId },
|
|
85
|
+
order: [["createdAt", "DESC"]],
|
|
86
|
+
limit,
|
|
87
|
+
include: ["payment"],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
static async getPaymentTransactions(paymentId) {
|
|
91
|
+
return await this.findAll({
|
|
92
|
+
where: { paymentId },
|
|
93
|
+
order: [["createdAt", "DESC"]],
|
|
94
|
+
});
|
|
38
95
|
}
|
|
39
96
|
}
|
|
40
97
|
exports.Transaction = Transaction;
|
|
@@ -1,8 +1,45 @@
|
|
|
1
|
-
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute } from "vr-migrations";
|
|
1
|
+
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ModelStatic } from "vr-migrations";
|
|
2
2
|
import type { Device } from "./device.models";
|
|
3
3
|
import type { Payment } from "./payment.models";
|
|
4
4
|
import type { SecurityClearance } from "./securityClearance.models";
|
|
5
|
-
export
|
|
5
|
+
export interface UserAttributes {
|
|
6
|
+
id: string;
|
|
7
|
+
firstName: string;
|
|
8
|
+
lastName: string;
|
|
9
|
+
phoneNumber: string;
|
|
10
|
+
jacketId: string;
|
|
11
|
+
email: string | null;
|
|
12
|
+
password: string | null;
|
|
13
|
+
securityClearanceId: string;
|
|
14
|
+
plateNumber: string | null;
|
|
15
|
+
nationalId: string;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
isSuspended: boolean;
|
|
18
|
+
bannedAt: Date | null;
|
|
19
|
+
banReason: string | null;
|
|
20
|
+
suspendedAt: Date | null;
|
|
21
|
+
suspensionReason: string | null;
|
|
22
|
+
forgotPassword: boolean;
|
|
23
|
+
otp: string | null;
|
|
24
|
+
otpExpiresAt: Date | null;
|
|
25
|
+
isDeactivated: boolean;
|
|
26
|
+
deactivatedAt: Date | null;
|
|
27
|
+
lastLoginAt: Date | null;
|
|
28
|
+
tokenVersion: number;
|
|
29
|
+
createdAt: Date;
|
|
30
|
+
devices?: Device[];
|
|
31
|
+
payments?: Payment[];
|
|
32
|
+
securityClearance?: SecurityClearance;
|
|
33
|
+
}
|
|
34
|
+
export interface UserCreationAttributes extends Omit<UserAttributes, "id" | "createdAt" | "isActive" | "isSuspended" | "forgotPassword" | "isDeactivated" | "tokenVersion"> {
|
|
35
|
+
id?: string;
|
|
36
|
+
isActive?: boolean;
|
|
37
|
+
isSuspended?: boolean;
|
|
38
|
+
forgotPassword?: boolean;
|
|
39
|
+
isDeactivated?: boolean;
|
|
40
|
+
tokenVersion?: number;
|
|
41
|
+
}
|
|
42
|
+
export declare class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> implements UserAttributes {
|
|
6
43
|
id: CreationOptional<string>;
|
|
7
44
|
firstName: string;
|
|
8
45
|
lastName: string;
|
|
@@ -30,6 +67,17 @@ export declare class User extends Model<InferAttributes<User>, InferCreationAttr
|
|
|
30
67
|
devices?: NonAttribute<Device[]>;
|
|
31
68
|
payments?: NonAttribute<Payment[]>;
|
|
32
69
|
securityClearance?: NonAttribute<SecurityClearance>;
|
|
70
|
+
static initialize(sequelize: any): void;
|
|
71
|
+
static associate(models: Record<string, ModelStatic<Model>>): void;
|
|
72
|
+
updateLastLogin(): Promise<void>;
|
|
73
|
+
generateOTP(): Promise<string>;
|
|
74
|
+
clearOTP(): Promise<void>;
|
|
75
|
+
validateOTP(otp: string): Promise<boolean>;
|
|
76
|
+
suspend(reason: string): Promise<void>;
|
|
77
|
+
unsuspend(): Promise<void>;
|
|
78
|
+
ban(reason: string): Promise<void>;
|
|
79
|
+
unban(): Promise<void>;
|
|
80
|
+
deactivate(): Promise<void>;
|
|
81
|
+
activate(): Promise<void>;
|
|
33
82
|
}
|
|
34
|
-
export declare const initUserModel: (sequelize: any) => void;
|
|
35
83
|
export type UserModel = typeof User;
|
|
@@ -1,122 +1,202 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.User = void 0;
|
|
4
4
|
// src/models/user.models.ts
|
|
5
5
|
const vr_migrations_1 = require("vr-migrations");
|
|
6
6
|
class User extends vr_migrations_1.Model {
|
|
7
|
+
// Static initialization method
|
|
8
|
+
static initialize(sequelize) {
|
|
9
|
+
this.init({
|
|
10
|
+
id: {
|
|
11
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
12
|
+
defaultValue: vr_migrations_1.DataTypes.UUIDV4,
|
|
13
|
+
primaryKey: true,
|
|
14
|
+
},
|
|
15
|
+
firstName: {
|
|
16
|
+
type: vr_migrations_1.DataTypes.STRING(100),
|
|
17
|
+
allowNull: false,
|
|
18
|
+
},
|
|
19
|
+
lastName: {
|
|
20
|
+
type: vr_migrations_1.DataTypes.STRING(100),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
phoneNumber: {
|
|
24
|
+
type: vr_migrations_1.DataTypes.STRING(20),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
unique: true,
|
|
27
|
+
},
|
|
28
|
+
nationalId: {
|
|
29
|
+
type: vr_migrations_1.DataTypes.STRING(16),
|
|
30
|
+
allowNull: false,
|
|
31
|
+
unique: true,
|
|
32
|
+
},
|
|
33
|
+
jacketId: {
|
|
34
|
+
type: vr_migrations_1.DataTypes.STRING(50),
|
|
35
|
+
allowNull: false,
|
|
36
|
+
unique: true,
|
|
37
|
+
},
|
|
38
|
+
email: {
|
|
39
|
+
type: vr_migrations_1.DataTypes.STRING(100),
|
|
40
|
+
allowNull: true,
|
|
41
|
+
unique: true,
|
|
42
|
+
},
|
|
43
|
+
password: {
|
|
44
|
+
type: vr_migrations_1.DataTypes.STRING,
|
|
45
|
+
allowNull: true,
|
|
46
|
+
},
|
|
47
|
+
securityClearanceId: {
|
|
48
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
49
|
+
allowNull: false,
|
|
50
|
+
},
|
|
51
|
+
plateNumber: {
|
|
52
|
+
type: vr_migrations_1.DataTypes.STRING(20),
|
|
53
|
+
allowNull: true,
|
|
54
|
+
},
|
|
55
|
+
isActive: {
|
|
56
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
57
|
+
defaultValue: true,
|
|
58
|
+
},
|
|
59
|
+
isSuspended: {
|
|
60
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
61
|
+
defaultValue: false,
|
|
62
|
+
},
|
|
63
|
+
bannedAt: {
|
|
64
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
65
|
+
allowNull: true,
|
|
66
|
+
},
|
|
67
|
+
banReason: {
|
|
68
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
69
|
+
allowNull: true,
|
|
70
|
+
},
|
|
71
|
+
suspendedAt: {
|
|
72
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
73
|
+
allowNull: true,
|
|
74
|
+
},
|
|
75
|
+
suspensionReason: {
|
|
76
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
77
|
+
allowNull: true,
|
|
78
|
+
},
|
|
79
|
+
lastLoginAt: {
|
|
80
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
81
|
+
allowNull: true,
|
|
82
|
+
},
|
|
83
|
+
tokenVersion: {
|
|
84
|
+
type: vr_migrations_1.DataTypes.INTEGER,
|
|
85
|
+
allowNull: false,
|
|
86
|
+
defaultValue: 1,
|
|
87
|
+
},
|
|
88
|
+
forgotPassword: {
|
|
89
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
90
|
+
defaultValue: false,
|
|
91
|
+
},
|
|
92
|
+
otp: {
|
|
93
|
+
type: vr_migrations_1.DataTypes.STRING(6),
|
|
94
|
+
allowNull: true,
|
|
95
|
+
},
|
|
96
|
+
otpExpiresAt: {
|
|
97
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
98
|
+
allowNull: true,
|
|
99
|
+
},
|
|
100
|
+
isDeactivated: {
|
|
101
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
102
|
+
defaultValue: false,
|
|
103
|
+
},
|
|
104
|
+
deactivatedAt: {
|
|
105
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
106
|
+
allowNull: true,
|
|
107
|
+
},
|
|
108
|
+
createdAt: {
|
|
109
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
110
|
+
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
111
|
+
},
|
|
112
|
+
}, {
|
|
113
|
+
sequelize,
|
|
114
|
+
modelName: "User",
|
|
115
|
+
tableName: "users",
|
|
116
|
+
timestamps: true,
|
|
117
|
+
updatedAt: false,
|
|
118
|
+
freezeTableName: true,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// Static association method
|
|
122
|
+
static associate(models) {
|
|
123
|
+
this.belongsTo(models.SecurityClearance, {
|
|
124
|
+
foreignKey: "securityClearanceId",
|
|
125
|
+
as: "securityClearance",
|
|
126
|
+
onDelete: "RESTRICT",
|
|
127
|
+
onUpdate: "CASCADE",
|
|
128
|
+
});
|
|
129
|
+
this.hasMany(models.Device, {
|
|
130
|
+
foreignKey: "userId",
|
|
131
|
+
as: "devices",
|
|
132
|
+
onDelete: "CASCADE",
|
|
133
|
+
onUpdate: "CASCADE",
|
|
134
|
+
});
|
|
135
|
+
this.hasMany(models.Payment, {
|
|
136
|
+
foreignKey: "userId",
|
|
137
|
+
as: "payments",
|
|
138
|
+
onDelete: "CASCADE",
|
|
139
|
+
onUpdate: "CASCADE",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// Custom instance methods (example methods)
|
|
143
|
+
async updateLastLogin() {
|
|
144
|
+
this.lastLoginAt = new Date();
|
|
145
|
+
await this.save();
|
|
146
|
+
}
|
|
147
|
+
async generateOTP() {
|
|
148
|
+
const otp = Math.floor(100000 + Math.random() * 900000).toString();
|
|
149
|
+
const expires = new Date();
|
|
150
|
+
expires.setMinutes(expires.getMinutes() + 15); // OTP valid for 15 minutes
|
|
151
|
+
this.otp = otp;
|
|
152
|
+
this.otpExpiresAt = expires;
|
|
153
|
+
this.forgotPassword = true;
|
|
154
|
+
await this.save();
|
|
155
|
+
return otp;
|
|
156
|
+
}
|
|
157
|
+
async clearOTP() {
|
|
158
|
+
this.otp = null;
|
|
159
|
+
this.otpExpiresAt = null;
|
|
160
|
+
this.forgotPassword = false;
|
|
161
|
+
await this.save();
|
|
162
|
+
}
|
|
163
|
+
async validateOTP(otp) {
|
|
164
|
+
if (!this.otp || !this.otpExpiresAt || this.otp !== otp) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
return new Date() < this.otpExpiresAt;
|
|
168
|
+
}
|
|
169
|
+
async suspend(reason) {
|
|
170
|
+
this.isSuspended = true;
|
|
171
|
+
this.suspendedAt = new Date();
|
|
172
|
+
this.suspensionReason = reason;
|
|
173
|
+
await this.save();
|
|
174
|
+
}
|
|
175
|
+
async unsuspend() {
|
|
176
|
+
this.isSuspended = false;
|
|
177
|
+
this.suspendedAt = null;
|
|
178
|
+
this.suspensionReason = null;
|
|
179
|
+
await this.save();
|
|
180
|
+
}
|
|
181
|
+
async ban(reason) {
|
|
182
|
+
this.bannedAt = new Date();
|
|
183
|
+
this.banReason = reason;
|
|
184
|
+
await this.save();
|
|
185
|
+
}
|
|
186
|
+
async unban() {
|
|
187
|
+
this.bannedAt = null;
|
|
188
|
+
this.banReason = null;
|
|
189
|
+
await this.save();
|
|
190
|
+
}
|
|
191
|
+
async deactivate() {
|
|
192
|
+
this.isDeactivated = true;
|
|
193
|
+
this.deactivatedAt = new Date();
|
|
194
|
+
await this.save();
|
|
195
|
+
}
|
|
196
|
+
async activate() {
|
|
197
|
+
this.isDeactivated = false;
|
|
198
|
+
this.deactivatedAt = null;
|
|
199
|
+
await this.save();
|
|
200
|
+
}
|
|
7
201
|
}
|
|
8
202
|
exports.User = User;
|
|
9
|
-
const initUserModel = (sequelize) => {
|
|
10
|
-
User.init({
|
|
11
|
-
id: {
|
|
12
|
-
type: vr_migrations_1.DataTypes.UUID,
|
|
13
|
-
defaultValue: vr_migrations_1.DataTypes.UUIDV4,
|
|
14
|
-
primaryKey: true,
|
|
15
|
-
},
|
|
16
|
-
firstName: {
|
|
17
|
-
type: vr_migrations_1.DataTypes.STRING(100),
|
|
18
|
-
allowNull: false,
|
|
19
|
-
},
|
|
20
|
-
lastName: {
|
|
21
|
-
type: vr_migrations_1.DataTypes.STRING(100),
|
|
22
|
-
allowNull: false,
|
|
23
|
-
},
|
|
24
|
-
phoneNumber: {
|
|
25
|
-
type: vr_migrations_1.DataTypes.STRING(20),
|
|
26
|
-
allowNull: false,
|
|
27
|
-
unique: true,
|
|
28
|
-
},
|
|
29
|
-
nationalId: {
|
|
30
|
-
type: vr_migrations_1.DataTypes.STRING(16),
|
|
31
|
-
allowNull: false,
|
|
32
|
-
unique: true,
|
|
33
|
-
},
|
|
34
|
-
jacketId: {
|
|
35
|
-
type: vr_migrations_1.DataTypes.STRING(50),
|
|
36
|
-
allowNull: false,
|
|
37
|
-
unique: true,
|
|
38
|
-
},
|
|
39
|
-
email: {
|
|
40
|
-
type: vr_migrations_1.DataTypes.STRING(100),
|
|
41
|
-
allowNull: true,
|
|
42
|
-
unique: true,
|
|
43
|
-
},
|
|
44
|
-
password: {
|
|
45
|
-
type: vr_migrations_1.DataTypes.STRING,
|
|
46
|
-
allowNull: true,
|
|
47
|
-
},
|
|
48
|
-
securityClearanceId: {
|
|
49
|
-
type: vr_migrations_1.DataTypes.UUID,
|
|
50
|
-
allowNull: false,
|
|
51
|
-
},
|
|
52
|
-
plateNumber: {
|
|
53
|
-
type: vr_migrations_1.DataTypes.STRING(20),
|
|
54
|
-
allowNull: true,
|
|
55
|
-
},
|
|
56
|
-
isActive: {
|
|
57
|
-
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
58
|
-
defaultValue: true,
|
|
59
|
-
},
|
|
60
|
-
isSuspended: {
|
|
61
|
-
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
62
|
-
defaultValue: false,
|
|
63
|
-
},
|
|
64
|
-
bannedAt: {
|
|
65
|
-
type: vr_migrations_1.DataTypes.DATE,
|
|
66
|
-
allowNull: true,
|
|
67
|
-
},
|
|
68
|
-
banReason: {
|
|
69
|
-
type: vr_migrations_1.DataTypes.TEXT,
|
|
70
|
-
allowNull: true,
|
|
71
|
-
},
|
|
72
|
-
suspendedAt: {
|
|
73
|
-
type: vr_migrations_1.DataTypes.DATE,
|
|
74
|
-
allowNull: true,
|
|
75
|
-
},
|
|
76
|
-
suspensionReason: {
|
|
77
|
-
type: vr_migrations_1.DataTypes.TEXT,
|
|
78
|
-
allowNull: true,
|
|
79
|
-
},
|
|
80
|
-
lastLoginAt: {
|
|
81
|
-
type: vr_migrations_1.DataTypes.DATE,
|
|
82
|
-
allowNull: true,
|
|
83
|
-
},
|
|
84
|
-
tokenVersion: {
|
|
85
|
-
type: vr_migrations_1.DataTypes.INTEGER,
|
|
86
|
-
allowNull: false,
|
|
87
|
-
defaultValue: 1,
|
|
88
|
-
},
|
|
89
|
-
forgotPassword: {
|
|
90
|
-
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
91
|
-
defaultValue: false,
|
|
92
|
-
},
|
|
93
|
-
otp: {
|
|
94
|
-
type: vr_migrations_1.DataTypes.STRING(6),
|
|
95
|
-
allowNull: true,
|
|
96
|
-
},
|
|
97
|
-
otpExpiresAt: {
|
|
98
|
-
type: vr_migrations_1.DataTypes.DATE,
|
|
99
|
-
allowNull: true,
|
|
100
|
-
},
|
|
101
|
-
isDeactivated: {
|
|
102
|
-
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
103
|
-
defaultValue: false,
|
|
104
|
-
},
|
|
105
|
-
deactivatedAt: {
|
|
106
|
-
type: vr_migrations_1.DataTypes.DATE,
|
|
107
|
-
allowNull: true,
|
|
108
|
-
},
|
|
109
|
-
createdAt: {
|
|
110
|
-
type: vr_migrations_1.DataTypes.DATE,
|
|
111
|
-
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
112
|
-
},
|
|
113
|
-
}, {
|
|
114
|
-
sequelize,
|
|
115
|
-
modelName: "User",
|
|
116
|
-
tableName: "users",
|
|
117
|
-
timestamps: true,
|
|
118
|
-
updatedAt: false,
|
|
119
|
-
freezeTableName: true,
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
exports.initUserModel = initUserModel;
|