"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const sequelize_1=require("sequelize");class apiKey extends sequelize_1.Model{static initModel(e){return apiKey.init({id:{type:sequelize_1.DataTypes.UUID,defaultValue:sequelize_1.DataTypes.UUIDV4,primaryKey:!0,allowNull:!1},userId:{type:sequelize_1.DataTypes.UUID,allowNull:!0,validate:{isUUID:{args:4,msg:"userId: Must be a valid UUID"}}},name:{type:sequelize_1.DataTypes.STRING(255),allowNull:!1,validate:{notEmpty:{msg:"name: API key name must not be empty"}}},key:{type:sequelize_1.DataTypes.STRING(255),allowNull:!1,validate:{notEmpty:{msg:"key: API key must not be empty"}}},permissions:{type:sequelize_1.DataTypes.JSON,allowNull:!1,defaultValue:[]},ipRestriction:{type:sequelize_1.DataTypes.BOOLEAN,allowNull:!1,defaultValue:!1},ipWhitelist:{type:sequelize_1.DataTypes.JSON,allowNull:!1,defaultValue:[]}},{sequelize:e,modelName:"apiKey",tableName:"api_key",timestamps:!0,paranoid:!0,indexes:[{name:"PRIMARY",unique:!0,using:"BTREE",fields:[{name:"id"}]}]})}static associate(e){apiKey.belongsTo(e.user,{as:"user",foreignKey:"userId",onDelete:"CASCADE",onUpdate:"CASCADE"})}}exports.default=apiKey;