vr-models 1.0.18 → 1.0.19
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,11 +1,11 @@
|
|
|
1
1
|
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ModelStatic } from "vr-migrations";
|
|
2
2
|
import type { User } from "./user.models";
|
|
3
|
+
import { UserRole } from "./securityClearance.models";
|
|
3
4
|
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"];
|
|
4
5
|
export type EventAction = (typeof EVENT_ACTIONS)[number];
|
|
5
|
-
export type EventActorType = "USER" | "SYSTEM" | "ADMIN";
|
|
6
6
|
export interface EventLogAttributes {
|
|
7
7
|
id: string;
|
|
8
|
-
actorType:
|
|
8
|
+
actorType: UserRole;
|
|
9
9
|
actorId: string | null;
|
|
10
10
|
action: EventAction;
|
|
11
11
|
entity: string;
|
|
@@ -19,11 +19,11 @@ export interface EventLogAttributes {
|
|
|
19
19
|
export interface EventLogCreationAttributes extends Omit<EventLogAttributes, "id" | "createdAt" | "metadata" | "actorType"> {
|
|
20
20
|
id?: string;
|
|
21
21
|
metadata?: Record<string, any>;
|
|
22
|
-
actorType?:
|
|
22
|
+
actorType?: UserRole;
|
|
23
23
|
}
|
|
24
24
|
export declare class EventLog extends Model<InferAttributes<EventLog>, InferCreationAttributes<EventLog>> implements EventLogAttributes {
|
|
25
25
|
id: CreationOptional<string>;
|
|
26
|
-
actorType: CreationOptional<
|
|
26
|
+
actorType: CreationOptional<UserRole>;
|
|
27
27
|
actorId: CreationOptional<string | null>;
|
|
28
28
|
action: EventAction;
|
|
29
29
|
entity: string;
|
|
@@ -39,7 +39,5 @@ export declare class EventLog extends Model<InferAttributes<EventLog>, InferCrea
|
|
|
39
39
|
static getUserEvents(userId: string, limit?: number): Promise<EventLog[]>;
|
|
40
40
|
static getEntityEvents(entity: string, entityId: string, limit?: number): Promise<EventLog[]>;
|
|
41
41
|
getSummary(): string;
|
|
42
|
-
isUserAction(): boolean;
|
|
43
|
-
isSystemAction(): boolean;
|
|
44
42
|
}
|
|
45
43
|
export type EventLogModel = typeof EventLog;
|
|
@@ -77,7 +77,7 @@ class EventLog extends vr_migrations_1.Model {
|
|
|
77
77
|
primaryKey: true,
|
|
78
78
|
},
|
|
79
79
|
actorType: {
|
|
80
|
-
type: vr_migrations_1.DataTypes.ENUM("
|
|
80
|
+
type: vr_migrations_1.DataTypes.ENUM("RIDER", "PASSENGER", "AGENT", "ADMIN", "SUPER_ADMIN"),
|
|
81
81
|
allowNull: false,
|
|
82
82
|
defaultValue: "SYSTEM",
|
|
83
83
|
},
|
|
@@ -151,13 +151,7 @@ class EventLog extends vr_migrations_1.Model {
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
getSummary() {
|
|
154
|
-
return `${this.actorType}:${this.actorId
|
|
155
|
-
}
|
|
156
|
-
isUserAction() {
|
|
157
|
-
return this.actorType === "USER";
|
|
158
|
-
}
|
|
159
|
-
isSystemAction() {
|
|
160
|
-
return this.actorType === "SYSTEM";
|
|
154
|
+
return `${this.actorType}:${this.actorId} performed ${this.action} on ${this.entity}${this.entityId ? `:${this.entityId}` : ""}`;
|
|
161
155
|
}
|
|
162
156
|
}
|
|
163
157
|
exports.EventLog = EventLog;
|