/* eslint-disable @typescript-eslint/lines-between-class-members */
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';

// Join table: which products unlock which entitlements (many-to-many)
// eslint-disable-next-line prettier/prettier
export class EntitlementProduct extends Model<InferAttributes<EntitlementProduct>, InferCreationAttributes<EntitlementProduct>> {
  declare entitlement_id: string;
  declare product_id: string;
  declare created_at: CreationOptional<Date>;
  declare updated_at: CreationOptional<Date>;

  public static readonly GENESIS_ATTRIBUTES = {
    entitlement_id: {
      type: DataTypes.STRING(30),
      primaryKey: true,
      allowNull: false,
    },
    product_id: {
      type: DataTypes.STRING(30),
      primaryKey: true,
      allowNull: false,
    },
    created_at: {
      type: DataTypes.DATE,
      defaultValue: DataTypes.NOW,
      allowNull: false,
    },
    updated_at: {
      type: DataTypes.DATE,
      defaultValue: DataTypes.NOW,
      allowNull: false,
    },
  };

  public static initialize(sequelize: any) {
    this.init(EntitlementProduct.GENESIS_ATTRIBUTES, {
      sequelize,
      modelName: 'EntitlementProduct',
      tableName: 'entitlement_products',
      createdAt: 'created_at',
      updatedAt: 'updated_at',
    });
  }

  public static associate() {}
}

export type TEntitlementProduct = InferAttributes<EntitlementProduct>;
