1 import { AllowNull, Column, CreatedAt, DataType, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { throwIfNotValid } from '../utils'
4 isPluginDescriptionValid,
8 } from '../../helpers/custom-validators/plugins'
19 export class PluginModel extends Model<PluginModel> {
22 @Is('PluginName', value => throwIfNotValid(value, isPluginNameValid, 'name'))
27 @Is('PluginType', value => throwIfNotValid(value, isPluginTypeValid, 'type'))
32 @Is('PluginVersion', value => throwIfNotValid(value, isPluginVersionValid, 'version'))
46 peertubeEngine: string
49 @Is('PluginDescription', value => throwIfNotValid(value, isPluginDescriptionValid, 'description'))
54 @Column(DataType.JSONB)
58 @Column(DataType.JSONB)
67 static listEnabledPluginsAndThemes () {
75 return PluginModel.findAll(query)
78 static load (pluginName: string) {
85 return PluginModel.findOne(query)
88 static uninstall (pluginName: string) {
95 return PluginModel.update({ enabled: false, uninstalled: true }, query)