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 chatbot_configs = sequelize.define(
    'chatbot_configs',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

bot_name: {
        type: DataTypes.TEXT,
      
      

      },

model_provider: {
        type: DataTypes.ENUM,
      
      

        values: [

"openai",


"anthropic",


"google",


"azure_openai",


"custom"

        ],

      },

model_name: {
        type: DataTypes.TEXT,
      
      

      },

system_prompt: {
        type: DataTypes.TEXT,
      
      

      },

temperature: {
        type: DataTypes.DECIMAL,
      
      

      },

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

      },

welcome_message: {
        type: DataTypes.TEXT,
      
      

      },

handoff_mode: {
        type: DataTypes.ENUM,
      
      

        values: [

"none",


"email",


"live_chat_ticket"

        ],

      },

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

  chatbot_configs.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.chatbot_configs.belongsTo(db.stores, {
      as: 'store',
      foreignKey: {
        name: 'storeId',
      },
      constraints: false,
    });

    db.chatbot_configs.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return chatbot_configs;
};


