import { FindAndCountOptions, json, QueryTypes } from 'sequelize'
import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { MPlugin, MPluginFormattable } from '@server/types/models'
-import { AttributesOnly } from '@shared/core-utils'
-import { PeerTubePlugin, PluginType, RegisterServerSettingOptions } from '../../../shared/models'
+import { AttributesOnly } from '@shared/typescript-utils'
+import { PeerTubePlugin, PluginType, RegisterServerSettingOptions, SettingEntries, SettingValue } from '../../../shared/models'
import {
isPluginDescriptionValid,
isPluginHomepage,
return PluginModel.findOne(query)
.then(p => {
- const result: { [settingName: string ]: string | boolean } = {}
+ const result: SettingEntries = {}
for (const name of settingNames) {
if (!p || !p.settings || p.settings[name] === undefined) {
})
}
- static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: string) {
+ static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: SettingValue) {
const query = {
where: {
name: pluginName,
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[]> {
}
getPublicSettings (registeredSettings: RegisterServerSettingOptions[]) {
- const result: { [ name: string ]: string } = {}
+ const result: SettingEntries = {}
const settings = this.settings || {}
for (const r of registeredSettings) {