const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const ai_monitoring_rules = sequelize.define(
    'ai_monitoring_rules',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

rule_name: {
        type: DataTypes.TEXT,
      
      

      },

rule_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"brute_force",


"anomaly_login",


"mass_download",


"suspicious_ip",


"face_mismatch",


"policy_violation"

        ],

      },

severity: {
        type: DataTypes.ENUM,
      
      

        values: [

"low",


"medium",


"high",


"critical"

        ],

      },

enabled: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

rule_description: {
        type: DataTypes.TEXT,
      
      

      },

threshold_value: {
        type: DataTypes.DECIMAL,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  ai_monitoring_rules.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity































//end loop



    db.ai_monitoring_rules.belongsTo(db.schools, {
      as: 'schools',
      foreignKey: {
        name: 'schoolsId',
      },
      constraints: false,
    });




    db.ai_monitoring_rules.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.ai_monitoring_rules.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return ai_monitoring_rules;
};


