vr-models 1.0.21 → 1.0.23

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.
@@ -13,7 +13,8 @@ export interface BanAttributes {
13
13
  revokedAt?: Date;
14
14
  revokedBy?: string;
15
15
  revocationReason?: string;
16
- user?: User;
16
+ user: User;
17
+ admin: User;
17
18
  }
18
19
  export interface BanCreationAttributes extends Omit<BanAttributes, "id" | "createdAt" | "updatedAt"> {
19
20
  id?: string;
@@ -32,6 +33,7 @@ export declare class Ban extends Model<InferAttributes<Ban>, InferCreationAttrib
32
33
  revokedBy: CreationOptional<string | undefined>;
33
34
  revocationReason: CreationOptional<string | undefined>;
34
35
  user: NonAttribute<User>;
36
+ admin: NonAttribute<User>;
35
37
  static initialize(sequelize: any): void;
36
38
  static associate(models: Record<string, ModelStatic<Model>>): void;
37
39
  }
@@ -16,7 +16,7 @@ export interface DevicePaymentPlanAttributes {
16
16
  createdAt: Date;
17
17
  updatedAt: Date;
18
18
  devices?: Device[];
19
- user?: User;
19
+ user: User;
20
20
  installments?: Installment[];
21
21
  }
22
22
  export interface DevicePaymentPlanCreationAttributes extends Omit<DevicePaymentPlanAttributes, "id" | "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "lastPaymentAt" | "nextInstallmentDueAt" | "status" | "completedAt" | "devices" | "installments"> {
@@ -38,7 +38,7 @@ export declare class DevicePaymentPlan extends Model<InferAttributes<DevicePayme
38
38
  readonly createdAt: CreationOptional<Date>;
39
39
  readonly updatedAt: CreationOptional<Date>;
40
40
  devices?: NonAttribute<Device[]>;
41
- user?: NonAttribute<User>;
41
+ user: NonAttribute<User>;
42
42
  installments?: NonAttribute<Installment[]>;
43
43
  static initialize(sequelize: any): void;
44
44
  static associate(models: Record<string, ModelStatic<Model>>): void;
@@ -2,6 +2,8 @@ import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonA
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
+ import { Ban } from "./ban.models";
6
+ import { Suspension } from "./suspension.models";
5
7
  export interface DeletionStatus {
6
8
  deleted: boolean;
7
9
  deletedAt?: Date | null;
@@ -20,11 +22,6 @@ export interface UserAttributes {
20
22
  plateNumber: string | null;
21
23
  nationalId: string;
22
24
  isActive: boolean;
23
- isSuspended: boolean;
24
- bannedAt: Date | null;
25
- banReason: string | null;
26
- suspendedAt: Date | null;
27
- suspensionReason: string | null;
28
25
  forgotPassword: boolean;
29
26
  otp: string | null;
30
27
  otpExpiresAt: Date | null;
@@ -37,6 +34,8 @@ export interface UserAttributes {
37
34
  devices?: Device[];
38
35
  payments?: Payment[];
39
36
  securityClearance?: SecurityClearance;
37
+ bans?: Ban[];
38
+ suspensions?: Suspension[];
40
39
  }
41
40
  export interface UserCreationAttributes extends Omit<UserAttributes, "id" | "createdAt" | "isActive" | "isSuspended" | "forgotPassword" | "isDeactivated" | "tokenVersion"> {
42
41
  id?: string;
@@ -82,10 +81,6 @@ export declare class User extends Model<InferAttributes<User>, InferCreationAttr
82
81
  generateOTP(): Promise<string>;
83
82
  clearOTP(): Promise<void>;
84
83
  validateOTP(otp: string): Promise<boolean>;
85
- suspend(reason: string): Promise<void>;
86
- unsuspend(): Promise<void>;
87
- ban(reason: string): Promise<void>;
88
- unban(): Promise<void>;
89
84
  deactivate(): Promise<void>;
90
85
  activate(): Promise<void>;
91
86
  }
@@ -199,28 +199,6 @@ class User extends vr_migrations_1.Model {
199
199
  }
200
200
  return new Date() < this.otpExpiresAt;
201
201
  }
202
- async suspend(reason) {
203
- this.isSuspended = true;
204
- this.suspendedAt = new Date();
205
- this.suspensionReason = reason;
206
- await this.save();
207
- }
208
- async unsuspend() {
209
- this.isSuspended = false;
210
- this.suspendedAt = null;
211
- this.suspensionReason = null;
212
- await this.save();
213
- }
214
- async ban(reason) {
215
- this.bannedAt = new Date();
216
- this.banReason = reason;
217
- await this.save();
218
- }
219
- async unban() {
220
- this.bannedAt = null;
221
- this.banReason = null;
222
- await this.save();
223
- }
224
202
  async deactivate() {
225
203
  this.isDeactivated = true;
226
204
  this.deactivatedAt = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-models",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Shared database models package for VR applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",