195 lines
2.3 KiB
JavaScript
195 lines
2.3 KiB
JavaScript
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 vendors = sequelize.define(
|
|
'vendors',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
vendor_name: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
vendor_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"ai_vendor",
|
|
|
|
|
|
"document_management",
|
|
|
|
|
|
"practice_management",
|
|
|
|
|
|
"identity_security",
|
|
|
|
|
|
"workflow_automation",
|
|
|
|
|
|
"risk_compliance",
|
|
|
|
|
|
"e_signature",
|
|
|
|
|
|
"reporting",
|
|
|
|
|
|
"other"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
primary_contact_name: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
primary_contact_email: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
website_url: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"active",
|
|
|
|
|
|
"prospect",
|
|
|
|
|
|
"inactive"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
notes: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
vendors.associate = (db) => {
|
|
|
|
db.vendors.belongsToMany(db.ai_tools, {
|
|
as: 'tools',
|
|
foreignKey: {
|
|
name: 'vendors_toolsId',
|
|
},
|
|
constraints: false,
|
|
through: 'vendorsToolsAi_tools',
|
|
});
|
|
|
|
db.vendors.belongsToMany(db.ai_tools, {
|
|
as: 'tools_filter',
|
|
foreignKey: {
|
|
name: 'vendors_toolsId',
|
|
},
|
|
constraints: false,
|
|
through: 'vendorsToolsAi_tools',
|
|
});
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.vendors.hasMany(db.vendor_risk_assessments, {
|
|
as: 'vendor_risk_assessments_vendor',
|
|
foreignKey: {
|
|
name: 'vendorId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.vendors.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.vendors.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return vendors;
|
|
};
|
|
|
|
|