186 lines
2.4 KiB
JavaScript
186 lines
2.4 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 data_classifications = sequelize.define(
|
|
'data_classifications',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
label: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
level: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"public",
|
|
|
|
|
|
"internal",
|
|
|
|
|
|
"confidential",
|
|
|
|
|
|
"privileged",
|
|
|
|
|
|
"regulated",
|
|
|
|
|
|
"client_sensitive"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
restrictions: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
risk_notes: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
required_human_review_level: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"none",
|
|
|
|
|
|
"peer_review",
|
|
|
|
|
|
"supervisor_review",
|
|
|
|
|
|
"specialist_review"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
requires_client_notice: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
data_classifications.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.data_classifications.hasMany(db.ai_use_cases, {
|
|
as: 'ai_use_cases_data_classification',
|
|
foreignKey: {
|
|
name: 'data_classificationId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.data_classifications.hasMany(db.policies, {
|
|
as: 'policies_data_classification',
|
|
foreignKey: {
|
|
name: 'data_classificationId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
db.data_classifications.hasMany(db.human_review_checklists, {
|
|
as: 'human_review_checklists_data_classification',
|
|
foreignKey: {
|
|
name: 'data_classificationId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.data_classifications.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.data_classifications.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return data_classifications;
|
|
};
|
|
|
|
|