isPluginDescriptionValid,
isPluginHomepage,
isPluginNameValid,
- isPluginTypeValid,
- isPluginVersionValid
+ isPluginStableOrUnstableVersionValid,
+ isPluginStableVersionValid,
+ isPluginTypeValid
} from '../../helpers/custom-validators/plugins'
import { getSort, throwIfNotValid } from '../utils'
type: number
@AllowNull(false)
- @Is('PluginVersion', value => throwIfNotValid(value, isPluginVersionValid, 'version'))
+ @Is('PluginVersion', value => throwIfNotValid(value, isPluginStableOrUnstableVersionValid, 'version'))
@Column
version: string
@AllowNull(true)
- @Is('PluginLatestVersion', value => throwIfNotValid(value, isPluginVersionValid, 'version'))
+ @Is('PluginLatestVersion', value => throwIfNotValid(value, isPluginStableVersionValid, 'version'))
@Column
latestVersion: string
return PluginModel.findOne(query)
.then(p => {
- if (!p || !p.settings || p.settings === undefined) {
+ if (!p?.settings || p.settings === undefined) {
const registered = registeredSettings.find(s => s.name === settingName)
if (!registered || registered.default === undefined) return undefined
const result: SettingEntries = {}
for (const name of settingNames) {
- if (!p || !p.settings || p.settings[name] === undefined) {
+ if (!p?.settings || p.settings[name] === undefined) {
const registered = registeredSettings.find(s => s.name === name)
if (registered?.default !== undefined) {
if (options.pluginType) query.where['type'] = options.pluginType
- return PluginModel
- .findAndCountAll<MPlugin>(query)
- .then(({ rows, count }) => {
- return { total: count, data: rows }
- })
+ return Promise.all([
+ PluginModel.count(query),
+ PluginModel.findAll<MPlugin>(query)
+ ]).then(([ total, data ]) => ({ total, data }))
}
static listInstalled (): Promise<MPlugin[]> {