vr-models 1.0.28 → 1.0.30
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,6 +1,13 @@
|
|
|
1
1
|
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ModelStatic } from "vr-migrations";
|
|
2
2
|
import type { User } from "./user.models";
|
|
3
3
|
import { UserRole } from "./securityClearance.models";
|
|
4
|
+
export interface SessionPayload {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
startedAt: number;
|
|
7
|
+
expiresAt: number;
|
|
8
|
+
userId: string;
|
|
9
|
+
tokenVersion: number;
|
|
10
|
+
}
|
|
4
11
|
export declare const EVENT_ACTIONS: readonly ["USER_READ", "USER_CREATED", "USER_UPDATED", "USER_DELETED", "USER_SUSPENDED", "USER_BANNED", "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", "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", "PRODUCTS_LISTED", "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"];
|
|
5
12
|
export type EventAction = (typeof EVENT_ACTIONS)[number];
|
|
6
13
|
export interface EventLogAttributes {
|
|
@@ -13,6 +20,7 @@ export interface EventLogAttributes {
|
|
|
13
20
|
metadata: Record<string, any>;
|
|
14
21
|
ipAddress: string | null;
|
|
15
22
|
userAgent: string | null;
|
|
23
|
+
session: SessionPayload;
|
|
16
24
|
createdAt: Date;
|
|
17
25
|
actor?: User;
|
|
18
26
|
}
|
|
@@ -31,6 +39,7 @@ export declare class EventLog extends Model<InferAttributes<EventLog>, InferCrea
|
|
|
31
39
|
metadata: CreationOptional<Record<string, any>>;
|
|
32
40
|
ipAddress: CreationOptional<string | null>;
|
|
33
41
|
userAgent: CreationOptional<string | null>;
|
|
42
|
+
session: SessionPayload;
|
|
34
43
|
readonly createdAt: CreationOptional<Date>;
|
|
35
44
|
actor?: NonAttribute<User>;
|
|
36
45
|
static initialize(sequelize: any): void;
|
|
@@ -110,6 +110,26 @@ class EventLog extends vr_migrations_1.Model {
|
|
|
110
110
|
type: vr_migrations_1.DataTypes.TEXT,
|
|
111
111
|
allowNull: true,
|
|
112
112
|
},
|
|
113
|
+
session: {
|
|
114
|
+
type: vr_migrations_1.DataTypes.JSONB,
|
|
115
|
+
allowNull: true,
|
|
116
|
+
validate: {
|
|
117
|
+
isValidSessionObject(value) {
|
|
118
|
+
if (value === null || value === undefined)
|
|
119
|
+
return;
|
|
120
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
121
|
+
throw new Error("Sessions must be a session object");
|
|
122
|
+
}
|
|
123
|
+
if (typeof value.sessionId !== "string" ||
|
|
124
|
+
typeof value.startedAt !== "number" ||
|
|
125
|
+
typeof value.expiresAt !== "number" ||
|
|
126
|
+
typeof value.userId !== "string" ||
|
|
127
|
+
typeof value.tokenVersion !== "number") {
|
|
128
|
+
throw new Error("Invalid session object: must have a string sessionId and userId plus numeric startetAt ,expiresAt and tokenVersion");
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
113
133
|
createdAt: {
|
|
114
134
|
type: vr_migrations_1.DataTypes.DATE,
|
|
115
135
|
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
@@ -18,6 +18,7 @@ export interface SuspensionAttributes {
|
|
|
18
18
|
updatedAt?: Date;
|
|
19
19
|
admin: NonAttribute<User>;
|
|
20
20
|
user: NonAttribute<User>;
|
|
21
|
+
revokingAdmin?: User;
|
|
21
22
|
}
|
|
22
23
|
export declare class Suspension extends Model<InferAttributes<Suspension>, InferCreationAttributes<Suspension>> implements SuspensionAttributes {
|
|
23
24
|
id: CreationOptional<string>;
|
|
@@ -37,6 +38,7 @@ export declare class Suspension extends Model<InferAttributes<Suspension>, Infer
|
|
|
37
38
|
updatedAt: CreationOptional<Date | undefined>;
|
|
38
39
|
admin: NonAttribute<User>;
|
|
39
40
|
user: NonAttribute<User>;
|
|
41
|
+
revokingAdmin?: NonAttribute<User>;
|
|
40
42
|
static initialize(sequelize: any): void;
|
|
41
43
|
static associate(models: Record<string, ModelStatic<Model>>): void;
|
|
42
44
|
}
|
|
@@ -94,6 +94,12 @@ class Suspension extends vr_migrations_1.Model {
|
|
|
94
94
|
onDelete: "CASCADE",
|
|
95
95
|
onUpdate: "CASCADE",
|
|
96
96
|
});
|
|
97
|
+
this.belongsTo(models.User, {
|
|
98
|
+
foreignKey: "revokedBy",
|
|
99
|
+
as: "revokingAdmin",
|
|
100
|
+
onDelete: "CASCADE",
|
|
101
|
+
onUpdate: "CASCADE",
|
|
102
|
+
});
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
exports.Suspension = Suspension;
|
|
@@ -23,6 +23,8 @@ export interface UserAttributes {
|
|
|
23
23
|
nationalId: string;
|
|
24
24
|
isActive: boolean;
|
|
25
25
|
forgotPassword: boolean;
|
|
26
|
+
verified: boolean;
|
|
27
|
+
verifiedAt: Date | null;
|
|
26
28
|
otp: string | null;
|
|
27
29
|
otpExpiresAt: Date | null;
|
|
28
30
|
isDeactivated: boolean;
|
|
@@ -63,6 +65,8 @@ export declare class User extends Model<InferAttributes<User>, InferCreationAttr
|
|
|
63
65
|
suspendedAt: CreationOptional<Date | null>;
|
|
64
66
|
suspensionReason: CreationOptional<string | null>;
|
|
65
67
|
forgotPassword: CreationOptional<boolean>;
|
|
68
|
+
verified: CreationOptional<boolean>;
|
|
69
|
+
verifiedAt: CreationOptional<Date | null>;
|
|
66
70
|
otp: CreationOptional<string | null>;
|
|
67
71
|
otpExpiresAt: CreationOptional<Date | null>;
|
|
68
72
|
isDeactivated: CreationOptional<boolean>;
|
|
@@ -89,6 +89,15 @@ class User extends vr_migrations_1.Model {
|
|
|
89
89
|
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
90
90
|
defaultValue: false,
|
|
91
91
|
},
|
|
92
|
+
verified: {
|
|
93
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
94
|
+
allowNull: false,
|
|
95
|
+
defaultValue: false,
|
|
96
|
+
},
|
|
97
|
+
verifiedAt: {
|
|
98
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
99
|
+
allowNull: true,
|
|
100
|
+
},
|
|
92
101
|
otp: {
|
|
93
102
|
type: vr_migrations_1.DataTypes.STRING(50),
|
|
94
103
|
allowNull: true,
|