2024-01-03 01:36:56 +01:00
|
|
|
const { DataTypes, Model, Sequelize } = require('sequelize')
|
|
|
|
|
|
|
|
class CustomMetadataProvider extends Model {
|
|
|
|
constructor(values, options) {
|
|
|
|
super(values, options)
|
|
|
|
|
|
|
|
/** @type {UUIDV4} */
|
|
|
|
this.id
|
|
|
|
/** @type {string} */
|
|
|
|
this.name
|
|
|
|
/** @type {string} */
|
|
|
|
this.url
|
|
|
|
/** @type {string} */
|
|
|
|
this.apiKey
|
|
|
|
}
|
|
|
|
|
|
|
|
getSlug() {
|
|
|
|
return `custom-${this.id}`
|
|
|
|
}
|
|
|
|
|
|
|
|
toUserJson() {
|
|
|
|
return {
|
|
|
|
name: this.name,
|
|
|
|
id: this.id,
|
|
|
|
slug: this.getSlug()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-12 21:45:03 +01:00
|
|
|
|
2024-01-03 01:36:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize model
|
|
|
|
* @param {import('../Database').sequelize} sequelize
|
|
|
|
*/
|
|
|
|
static init(sequelize) {
|
|
|
|
super.init({
|
|
|
|
id: {
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
primaryKey: true
|
|
|
|
},
|
|
|
|
name: DataTypes.STRING,
|
|
|
|
url: DataTypes.STRING,
|
2024-01-12 21:45:03 +01:00
|
|
|
apiKey: DataTypes.STRING,
|
2024-01-03 01:36:56 +01:00
|
|
|
}, {
|
|
|
|
sequelize,
|
|
|
|
modelName: 'customMetadataProvider'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = CustomMetadataProvider
|