/**
 * @aurora-catalyst-generated
 * @source cliter/iam/user.aurora.yaml
 */
import { IamAccountModel } from '@app/iam/account';
import { Auditable } from '@aurorajs.dev/core-back';
import { DataTypes } from 'sequelize';
import { BelongsTo, Column, ForeignKey, Model, Table } from 'sequelize-typescript';

@Auditable()
@Table({
  modelName: 'IamUser',
  tableName: 'iam_user',
  freezeTableName: true,
  timestamps: false,
  indexes: [
    {
      fields: ['row_id'],
      unique: true,
    },
  ],
})
export class IamUserModel extends Model<IamUserModel> {
  @Column({
    field: 'id',
    primaryKey: true,
    allowNull: false,
    type: DataTypes.UUID,
  })
  id: string;

  @Column({
    field: 'row_id',
    autoIncrement: true,
    allowNull: false,
    type: DataTypes.BIGINT,
  })
  rowId: number;

  @ForeignKey(() => IamAccountModel)
  @Column({
    field: 'account_id',
    allowNull: false,
    type: DataTypes.UUID,
  })
  accountId: string;

  @BelongsTo(() => IamAccountModel, {
    foreignKey: 'account_id',
  })
  account: IamAccountModel;

  @Column({
    field: 'name',
    allowNull: false,
    type: DataTypes.STRING(128),
  })
  name: string;

  @Column({
    field: 'surname',
    allowNull: true,
    type: DataTypes.STRING(255),
  })
  surname: string;

  @Column({
    field: 'avatar',
    allowNull: true,
    type: DataTypes.STRING(255),
  })
  avatar: string;

  @Column({
    field: 'mobile',
    allowNull: true,
    type: DataTypes.STRING(64),
  })
  mobile: string;

  @Column({
    field: 'lang_id',
    allowNull: true,
    type: DataTypes.UUID,
  })
  langId: string;

  @Column({
    field: 'password',
    allowNull: false,
    type: DataTypes.STRING(undefined),
  })
  password: string;

  @Column({
    field: 'is_two_factor_authentication_enabled',
    allowNull: false,
    type: DataTypes.BOOLEAN,
    defaultValue: false,
  })
  isTwoFactorAuthenticationEnabled: boolean;

  @Column({
    field: 'two_factor_authentication_secret',
    allowNull: true,
    type: DataTypes.STRING(32),
  })
  twoFactorAuthenticationSecret: string;

  @Column({
    field: 'remember_token',
    allowNull: true,
    type: DataTypes.STRING(255),
  })
  rememberToken: string;

  @Column({
    field: 'meta',
    allowNull: true,
    type: DataTypes.JSONB,
  })
  meta: any;

  @Column({
    field: 'created_at',
    allowNull: true,
    type: DataTypes.DATE,
  })
  createdAt: string;

  @Column({
    field: 'updated_at',
    allowNull: true,
    type: DataTypes.DATE,
  })
  updatedAt: string;

  @Column({
    field: 'deleted_at',
    allowNull: true,
    type: DataTypes.DATE,
  })
  deletedAt: string;
}
