vr-models 1.0.10 → 1.0.11

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,8 +1,8 @@
1
1
  import { Model, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ModelStatic } from "vr-migrations";
2
2
  import type { User } from "./user.models";
3
- 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", "DEVICE_ASSIGNED", "DEVICE_READ", "DEVICE_UPDATED", "DEVICES_LISTED", "DEVICE_REPOSSESSED", "DEVICE_PAYMENT_PLAN_CREATED", "DEVICE_PAYMENT_PLAN_READ", "DEVICE_PAYMENT_PLAN_UPDATED", "DEVICE_PAYMENT_DEFAULT_MARKED", "PAYMENT_CREATED", "PAYMENT_READ", "PAYMENTS_LISTED", "TRANSACTION_READ", "TRANSACTIONS_LISTED", "EVENT_LOG_READ", "EVENT_LOGS_LISTED", "SECURITY_CLEARANCE_MANAGED", "DEVICE_LOCK_OVERRIDDEN"];
3
+ 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", "PRODUCT_STOCK_UPDATED", "DEVICE_ASSIGNED", "DEVICE_READ", "DEVICE_UPDATED", "DEVICES_LISTED", "DEVICE_REPOSSESSED", "DEVICE_PAYMENT_PLAN_CREATED", "DEVICE_PAYMENT_PLAN_READ", "DEVICE_PAYMENT_PLAN_UPDATED", "DEVICE_PAYMENT_DEFAULT_MARKED", "PAYMENT_CREATED", "PAYMENT_READ", "PAYMENTS_LISTED", "TRANSACTION_READ", "TRANSACTIONS_LISTED", "EVENT_LOG_READ", "EVENT_LOGS_LISTED", "SECURITY_CLEARANCE_MANAGED", "DEVICE_LOCK_OVERRIDDEN"];
4
4
  export type EventAction = (typeof EVENT_ACTIONS)[number];
5
- export type EventActorType = "USER" | "SYSTEM";
5
+ export type EventActorType = "USER" | "SYSTEM" | "ADMIN";
6
6
  export interface EventLogAttributes {
7
7
  id: string;
8
8
  actorType: EventActorType;
@@ -29,6 +29,7 @@ exports.EVENT_ACTIONS = [
29
29
  "PRODUCT_UPDATED",
30
30
  "PRODUCT_DELETED",
31
31
  "PRODUCTS_LISTED",
32
+ "PRODUCT_STOCK_UPDATED",
32
33
  "DEVICE_ASSIGNED",
33
34
  "DEVICE_READ",
34
35
  "DEVICE_UPDATED",
@@ -58,7 +59,7 @@ class EventLog extends vr_migrations_1.Model {
58
59
  primaryKey: true,
59
60
  },
60
61
  actorType: {
61
- type: vr_migrations_1.DataTypes.ENUM("USER", "SYSTEM"),
62
+ type: vr_migrations_1.DataTypes.ENUM("USER", "SYSTEM", "ADMIN"),
62
63
  allowNull: false,
63
64
  defaultValue: "SYSTEM",
64
65
  },
@@ -9,6 +9,7 @@ export interface ProductAttributes {
9
9
  isActive: boolean;
10
10
  createdAt: Date;
11
11
  updatedAt: Date;
12
+ imageUrl: string | null;
12
13
  pricings?: Pricing[];
13
14
  devices?: Device[];
14
15
  }
@@ -24,6 +25,7 @@ export declare class Product extends Model<InferAttributes<Product>, InferCreati
24
25
  description: CreationOptional<string | null>;
25
26
  stock: CreationOptional<number>;
26
27
  isActive: CreationOptional<boolean>;
28
+ imageUrl: CreationOptional<string | null>;
27
29
  readonly createdAt: CreationOptional<Date>;
28
30
  readonly updatedAt: CreationOptional<Date>;
29
31
  pricings?: NonAttribute<Pricing[]>;
@@ -36,7 +38,6 @@ export declare class Product extends Model<InferAttributes<Product>, InferCreati
36
38
  decrementStock(amount?: number): Promise<void>;
37
39
  isInStock(): boolean;
38
40
  getActivePricings(): Pricing[];
39
- getDefaultPricing(): Pricing | null;
40
41
  static findAvailableProducts(): Promise<Product[]>;
41
42
  }
42
43
  export type ProductModel = typeof Product;
@@ -13,12 +13,13 @@ class Product extends vr_migrations_1.Model {
13
13
  },
14
14
  name: { type: vr_migrations_1.DataTypes.STRING(150), allowNull: false },
15
15
  description: { type: vr_migrations_1.DataTypes.TEXT, allowNull: true },
16
- stock: { type: vr_migrations_1.DataTypes.INTEGER, allowNull: false, defaultValue: 0 },
16
+ stock: { type: vr_migrations_1.DataTypes.INTEGER, allowNull: false, defaultValue: 1 },
17
17
  isActive: {
18
18
  type: vr_migrations_1.DataTypes.BOOLEAN,
19
19
  allowNull: false,
20
20
  defaultValue: true,
21
21
  },
22
+ imageUrl: { type: vr_migrations_1.DataTypes.STRING(500), allowNull: true }, // Cloudinary URL
22
23
  createdAt: { type: vr_migrations_1.DataTypes.DATE, defaultValue: vr_migrations_1.DataTypes.NOW },
23
24
  updatedAt: { type: vr_migrations_1.DataTypes.DATE, defaultValue: vr_migrations_1.DataTypes.NOW },
24
25
  }, {
@@ -71,11 +72,6 @@ class Product extends vr_migrations_1.Model {
71
72
  return [];
72
73
  return this.pricings.filter((pricing) => pricing.isActive);
73
74
  }
74
- getDefaultPricing() {
75
- if (!this.pricings)
76
- return null;
77
- return this.pricings.find((pricing) => pricing.isActive) || null;
78
- }
79
75
  static async findAvailableProducts() {
80
76
  return await this.findAll({
81
77
  where: { isActive: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-models",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Shared database models package for VR applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",