vr-models 1.0.17 → 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.
|
@@ -3,6 +3,8 @@ import type { Product } from "./product.models";
|
|
|
3
3
|
import type { DevicePaymentPlan } from "./devicePaymentPlan.models";
|
|
4
4
|
export type DeviceStatus = "locked" | "unlocked" | "disabled";
|
|
5
5
|
export type DeviceDedication = "PASSENGER" | "RIDER" | "N/A";
|
|
6
|
+
export declare const DEVICE_STATUS: readonly ["locked", "unlocked", "disabled"];
|
|
7
|
+
export declare const DEVICE_DEDICATION: readonly ["PASSENGER", "RIDER", "N/A"];
|
|
6
8
|
export interface DeviceAttributes {
|
|
7
9
|
id: string;
|
|
8
10
|
serialNumber: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Device = void 0;
|
|
3
|
+
exports.Device = exports.DEVICE_DEDICATION = exports.DEVICE_STATUS = void 0;
|
|
4
4
|
// src/models/device.models.ts
|
|
5
5
|
const vr_migrations_1 = require("vr-migrations");
|
|
6
|
+
// for validations and other use
|
|
7
|
+
exports.DEVICE_STATUS = ["locked", "unlocked", "disabled"];
|
|
8
|
+
exports.DEVICE_DEDICATION = ["PASSENGER", "RIDER", "N/A"];
|
|
6
9
|
class Device extends vr_migrations_1.Model {
|
|
7
10
|
// Static initialization method
|
|
8
11
|
static initialize(sequelize) {
|
|
@@ -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
|
-
|
|
3
|
+
import { UserRole } from "./securityClearance.models";
|
|
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;
|
|
@@ -56,6 +56,7 @@ exports.EVENT_ACTIONS = [
|
|
|
56
56
|
"DEVICE_PAYMENT_PLAN_UPDATED",
|
|
57
57
|
"DEVICE_PAYMENT_PLAN_MARKED_DEFAULTED",
|
|
58
58
|
"DEVICE_PAYMENT_PLAN_SOFT_DELETED",
|
|
59
|
+
"DEVICE_PAYMENT_PLAN_DELETED_PERMANENTLY",
|
|
59
60
|
"PAYMENT_RECORDED",
|
|
60
61
|
"PAYMENT_READ",
|
|
61
62
|
"PAYMENTS_LISTED",
|
|
@@ -76,7 +77,7 @@ class EventLog extends vr_migrations_1.Model {
|
|
|
76
77
|
primaryKey: true,
|
|
77
78
|
},
|
|
78
79
|
actorType: {
|
|
79
|
-
type: vr_migrations_1.DataTypes.ENUM("
|
|
80
|
+
type: vr_migrations_1.DataTypes.ENUM("RIDER", "PASSENGER", "AGENT", "ADMIN", "SUPER_ADMIN"),
|
|
80
81
|
allowNull: false,
|
|
81
82
|
defaultValue: "SYSTEM",
|
|
82
83
|
},
|
|
@@ -150,13 +151,7 @@ class EventLog extends vr_migrations_1.Model {
|
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
153
|
getSummary() {
|
|
153
|
-
return `${this.actorType}:${this.actorId
|
|
154
|
-
}
|
|
155
|
-
isUserAction() {
|
|
156
|
-
return this.actorType === "USER";
|
|
157
|
-
}
|
|
158
|
-
isSystemAction() {
|
|
159
|
-
return this.actorType === "SYSTEM";
|
|
154
|
+
return `${this.actorType}:${this.actorId} performed ${this.action} on ${this.entity}${this.entityId ? `:${this.entityId}` : ""}`;
|
|
160
155
|
}
|
|
161
156
|
}
|
|
162
157
|
exports.EventLog = EventLog;
|