aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-11 12:04:47 +0200
committerChocobozzz <me@florianbigard.com>2021-05-11 13:33:11 +0200
commit428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba (patch)
treeb75329b64f5e201abdfb39961f2db09a08292b77
parent2b02c520e66ea452687cab39401b371711caa9ed (diff)
downloadPeerTube-428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba.tar.gz
PeerTube-428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba.tar.zst
PeerTube-428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba.zip
Reorganize plugin models
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts3
-rw-r--r--client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts3
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts11
-rw-r--r--client/src/root-helpers/plugins.ts7
-rw-r--r--server/controllers/api/plugins.ts33
-rw-r--r--server/lib/plugins/hooks.ts6
-rw-r--r--server/lib/plugins/plugin-index.ts20
-rw-r--r--server/lib/plugins/plugin-manager.ts14
-rw-r--r--server/lib/plugins/register-helpers.ts4
-rw-r--r--server/middlewares/validators/plugins.ts14
-rw-r--r--server/models/server/plugin.ts4
-rw-r--r--server/tests/api/check-params/plugins.ts12
-rw-r--r--server/tests/api/server/plugins.ts10
-rw-r--r--server/tools/peertube-plugins.ts3
-rw-r--r--shared/extra-utils/server/plugins.ts4
-rw-r--r--shared/models/plugins/client/client-hook.model.ts (renamed from shared/models/plugins/client-hook.model.ts)0
-rw-r--r--shared/models/plugins/client/index.ts6
-rw-r--r--shared/models/plugins/client/plugin-client-scope.type.ts (renamed from shared/models/plugins/plugin-client-scope.type.ts)0
-rw-r--r--shared/models/plugins/client/plugin-element-placeholder.type.ts (renamed from shared/models/plugins/plugin-element-placeholder.type.ts)0
-rw-r--r--shared/models/plugins/client/register-client-form-field.model.ts (renamed from shared/models/plugins/register-client-form-field.model.ts)0
-rw-r--r--shared/models/plugins/client/register-client-hook.model.ts (renamed from shared/models/plugins/register-client-hook.model.ts)0
-rw-r--r--shared/models/plugins/client/register-client-settings-script.model.ts (renamed from shared/models/plugins/register-client-settings-script.model.ts)2
-rw-r--r--shared/models/plugins/index.ts28
-rw-r--r--shared/models/plugins/plugin-index/index.ts3
-rw-r--r--shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts (renamed from shared/models/plugins/peertube-plugin-index-list.model.ts)2
-rw-r--r--shared/models/plugins/plugin-index/peertube-plugin-index.model.ts (renamed from shared/models/plugins/peertube-plugin-index.model.ts)0
-rw-r--r--shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts (renamed from shared/models/plugins/peertube-plugin-latest-version.model.ts)0
-rw-r--r--shared/models/plugins/plugin-package-json.model.ts2
-rw-r--r--shared/models/plugins/server/api/index.ts3
-rw-r--r--shared/models/plugins/server/api/install-plugin.model.ts (renamed from shared/models/plugins/install-plugin.model.ts)0
-rw-r--r--shared/models/plugins/server/api/manage-plugin.model.ts (renamed from shared/models/plugins/manage-plugin.model.ts)0
-rw-r--r--shared/models/plugins/server/api/peertube-plugin.model.ts (renamed from shared/models/plugins/peertube-plugin.model.ts)2
-rw-r--r--shared/models/plugins/server/index.ts6
-rw-r--r--shared/models/plugins/server/managers/index.ts9
-rw-r--r--shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts (renamed from shared/models/plugins/plugin-playlist-privacy-manager.model.ts)2
-rw-r--r--shared/models/plugins/server/managers/plugin-settings-manager.model.ts (renamed from shared/models/plugins/plugin-settings-manager.model.ts)0
-rw-r--r--shared/models/plugins/server/managers/plugin-storage-manager.model.ts (renamed from shared/models/plugins/plugin-storage-manager.model.ts)0
-rw-r--r--shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts (renamed from shared/models/plugins/plugin-transcoding-manager.model.ts)2
-rw-r--r--shared/models/plugins/server/managers/plugin-video-category-manager.model.ts (renamed from shared/models/plugins/plugin-video-category-manager.model.ts)0
-rw-r--r--shared/models/plugins/server/managers/plugin-video-language-manager.model.ts (renamed from shared/models/plugins/plugin-video-language-manager.model.ts)0
-rw-r--r--shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts (renamed from shared/models/plugins/plugin-video-licence-manager.model.ts)0
-rw-r--r--shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts (renamed from shared/models/plugins/plugin-video-privacy-manager.model.ts)2
-rw-r--r--shared/models/plugins/server/plugin-translation.model.ts (renamed from shared/models/plugins/plugin-translation.model.ts)0
-rw-r--r--shared/models/plugins/server/register-server-hook.model.ts (renamed from shared/models/plugins/register-server-hook.model.ts)0
-rw-r--r--shared/models/plugins/server/server-hook.model.ts (renamed from shared/models/plugins/server-hook.model.ts)0
-rw-r--r--shared/models/plugins/server/settings/index.ts2
-rw-r--r--shared/models/plugins/server/settings/public-server.setting.ts (renamed from shared/models/plugins/public-server.setting.ts)0
-rw-r--r--shared/models/plugins/server/settings/register-server-setting.model.ts (renamed from shared/models/plugins/register-server-setting.model.ts)2
48 files changed, 111 insertions, 110 deletions
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
index 1a95980ae..6af224920 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
@@ -5,8 +5,7 @@ import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
5import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core' 5import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core'
6import { PluginService } from '@app/core/plugins/plugin.service' 6import { PluginService } from '@app/core/plugins/plugin.service'
7import { compareSemVer } from '@shared/core-utils/miscs/miscs' 7import { compareSemVer } from '@shared/core-utils/miscs/miscs'
8import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model' 8import { PeerTubePlugin, PluginType } from '@shared/models'
9import { PluginType } from '@shared/models/plugins/plugin.type'
10 9
11@Component({ 10@Component({
12 selector: 'my-plugin-list-installed', 11 selector: 'my-plugin-list-installed',
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
index d2c179aba..0a6e57904 100644
--- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
+++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
@@ -4,8 +4,7 @@ import { Component, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' 5import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
6import { ComponentPagination, ConfirmService, hasMoreItems, Notifier, PluginService } from '@app/core' 6import { ComponentPagination, ConfirmService, hasMoreItems, Notifier, PluginService } from '@app/core'
7import { PeerTubePluginIndex } from '@shared/models/plugins/peertube-plugin-index.model' 7import { PeerTubePluginIndex, PluginType } from '@shared/models'
8import { PluginType } from '@shared/models/plugins/plugin.type'
9 8
10@Component({ 9@Component({
11 selector: 'my-plugin-search', 10 selector: 'my-plugin-search',
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index 34119f7ab..3d916dbce 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -21,8 +21,15 @@ import {
21import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms' 21import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms'
22import { InstanceService } from '@app/shared/shared-instance' 22import { InstanceService } from '@app/shared/shared-instance'
23import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' 23import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
24import { LiveVideo, ServerConfig, VideoConstant, VideoDetails, VideoPrivacy } from '@shared/models' 24import {
25import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model' 25 LiveVideo,
26 RegisterClientFormFieldOptions,
27 RegisterClientVideoFieldOptions,
28 ServerConfig,
29 VideoConstant,
30 VideoDetails,
31 VideoPrivacy
32} from '@shared/models'
26import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' 33import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
27import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' 34import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
28import { VideoEditType } from './video-edit.type' 35import { VideoEditType } from './video-edit.type'
diff --git a/client/src/root-helpers/plugins.ts b/client/src/root-helpers/plugins.ts
index 5344c0468..8c1c858b7 100644
--- a/client/src/root-helpers/plugins.ts
+++ b/client/src/root-helpers/plugins.ts
@@ -1,14 +1,15 @@
1import { RegisterClientHelpers } from 'src/types/register-client-option.model' 1import { RegisterClientHelpers } from 'src/types/register-client-option.model'
2import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' 2import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
3import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model'
4import { 3import {
5 ClientHookName, 4 ClientHookName,
6 clientHookObject, 5 clientHookObject,
7 ClientScript, 6 ClientScript,
8 PluginType, 7 PluginType,
8 RegisterClientFormFieldOptions,
9 RegisterClientHookOptions, 9 RegisterClientHookOptions,
10 ServerConfigPlugin, 10 RegisterClientSettingsScript,
11 RegisterClientSettingsScript 11 RegisterClientVideoFieldOptions,
12 ServerConfigPlugin
12} from '../../../shared/models' 13} from '../../../shared/models'
13import { ClientScript as ClientScriptModule } from '../types/client-script.model' 14import { ClientScript as ClientScriptModule } from '../types/client-script.model'
14import { importModule } from './utils' 15import { importModule } from './utils'
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index a186de010..e18eed332 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -1,16 +1,18 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getFormattedObjects } from '../../helpers/utils' 2import { logger } from '@server/helpers/logger'
3import { getFormattedObjects } from '@server/helpers/utils'
4import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index'
5import { PluginManager } from '@server/lib/plugins/plugin-manager'
3import { 6import {
4 asyncMiddleware, 7 asyncMiddleware,
5 authenticate, 8 authenticate,
9 availablePluginsSortValidator,
6 ensureUserHasRight, 10 ensureUserHasRight,
7 paginationValidator, 11 paginationValidator,
12 pluginsSortValidator,
8 setDefaultPagination, 13 setDefaultPagination,
9 setDefaultSort 14 setDefaultSort
10} from '../../middlewares' 15} from '@server/middlewares'
11import { availablePluginsSortValidator, pluginsSortValidator } from '../../middlewares/validators'
12import { PluginModel } from '../../models/server/plugin'
13import { UserRight } from '../../../shared/models/users'
14import { 16import {
15 existingPluginValidator, 17 existingPluginValidator,
16 installOrUpdatePluginValidator, 18 installOrUpdatePluginValidator,
@@ -18,16 +20,17 @@ import {
18 listPluginsValidator, 20 listPluginsValidator,
19 uninstallPluginValidator, 21 uninstallPluginValidator,
20 updatePluginSettingsValidator 22 updatePluginSettingsValidator
21} from '../../middlewares/validators/plugins' 23} from '@server/middlewares/validators/plugins'
22import { PluginManager } from '../../lib/plugins/plugin-manager' 24import { PluginModel } from '@server/models/server/plugin'
23import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' 25import { HttpStatusCode } from '@shared/core-utils'
24import { ManagePlugin } from '../../../shared/models/plugins/manage-plugin.model' 26import {
25import { logger } from '../../helpers/logger' 27 InstallOrUpdatePlugin,
26import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index' 28 ManagePlugin,
27import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' 29 PeertubePluginIndexList,
28import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model' 30 PublicServerSetting,
29import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting' 31 RegisteredServerSettings,
30import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 32 UserRight
33} from '@shared/models'
31 34
32const pluginRouter = express.Router() 35const pluginRouter = express.Router()
33 36
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts
index aa92f03cc..5e97b52a0 100644
--- a/server/lib/plugins/hooks.ts
+++ b/server/lib/plugins/hooks.ts
@@ -1,7 +1,7 @@
1import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models/plugins/server-hook.model'
2import { PluginManager } from './plugin-manager'
3import { logger } from '../../helpers/logger'
4import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models'
3import { logger } from '../../helpers/logger'
4import { PluginManager } from './plugin-manager'
5 5
6type PromiseFunction <U, T> = (params: U) => Promise<T> | Bluebird<T> 6type PromiseFunction <U, T> = (params: U) => Promise<T> | Bluebird<T>
7type RawFunction <U, T> = (params: U) => T 7type RawFunction <U, T> = (params: U) => T
diff --git a/server/lib/plugins/plugin-index.ts b/server/lib/plugins/plugin-index.ts
index 165bc91b3..119cee8e0 100644
--- a/server/lib/plugins/plugin-index.ts
+++ b/server/lib/plugins/plugin-index.ts
@@ -1,16 +1,16 @@
1import { sanitizeUrl } from '@server/helpers/core-utils' 1import { sanitizeUrl } from '@server/helpers/core-utils'
2import { ResultList } from '../../../shared/models' 2import { logger } from '@server/helpers/logger'
3import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' 3import { doJSONRequest } from '@server/helpers/requests'
4import { PeerTubePluginIndex } from '../../../shared/models/plugins/peertube-plugin-index.model' 4import { CONFIG } from '@server/initializers/config'
5import { PEERTUBE_VERSION } from '@server/initializers/constants'
6import { PluginModel } from '@server/models/server/plugin'
5import { 7import {
8 PeerTubePluginIndex,
9 PeertubePluginIndexList,
6 PeertubePluginLatestVersionRequest, 10 PeertubePluginLatestVersionRequest,
7 PeertubePluginLatestVersionResponse 11 PeertubePluginLatestVersionResponse,
8} from '../../../shared/models/plugins/peertube-plugin-latest-version.model' 12 ResultList
9import { logger } from '../../helpers/logger' 13} from '@shared/models'
10import { doJSONRequest } from '../../helpers/requests'
11import { CONFIG } from '../../initializers/config'
12import { PEERTUBE_VERSION } from '../../initializers/constants'
13import { PluginModel } from '../../models/server/plugin'
14import { PluginManager } from './plugin-manager' 14import { PluginManager } from './plugin-manager'
15 15
16async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList) { 16async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList) {
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index ba9814383..6b9a255a4 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -4,16 +4,11 @@ import { createReadStream, createWriteStream } from 'fs'
4import { ensureDir, outputFile, readJSON } from 'fs-extra' 4import { ensureDir, outputFile, readJSON } from 'fs-extra'
5import { basename, join } from 'path' 5import { basename, join } from 'path'
6import { MOAuthTokenUser, MUser } from '@server/types/models' 6import { MOAuthTokenUser, MUser } from '@server/types/models'
7import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model' 7import { getCompleteLocale } from '@shared/core-utils'
8import { ClientScript, PluginPackageJson, PluginTranslation, PluginTranslationPaths, RegisterServerHookOptions } from '@shared/models'
8import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks' 9import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks'
9import {
10 ClientScript,
11 PluginPackageJson,
12 PluginTranslationPaths as PackagePluginTranslations
13} from '../../../shared/models/plugins/plugin-package-json.model'
14import { PluginTranslation } from '../../../shared/models/plugins/plugin-translation.model'
15import { PluginType } from '../../../shared/models/plugins/plugin.type' 10import { PluginType } from '../../../shared/models/plugins/plugin.type'
16import { ServerHook, ServerHookName } from '../../../shared/models/plugins/server-hook.model' 11import { ServerHook, ServerHookName } from '../../../shared/models/plugins/server/server-hook.model'
17import { isLibraryCodeValid, isPackageJSONValid } from '../../helpers/custom-validators/plugins' 12import { isLibraryCodeValid, isPackageJSONValid } from '../../helpers/custom-validators/plugins'
18import { logger } from '../../helpers/logger' 13import { logger } from '../../helpers/logger'
19import { CONFIG } from '../../initializers/config' 14import { CONFIG } from '../../initializers/config'
@@ -23,7 +18,6 @@ import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPas
23import { ClientHtml } from '../client-html' 18import { ClientHtml } from '../client-html'
24import { RegisterHelpers } from './register-helpers' 19import { RegisterHelpers } from './register-helpers'
25import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' 20import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
26import { getCompleteLocale } from '@shared/core-utils'
27 21
28export interface RegisteredPlugin { 22export interface RegisteredPlugin {
29 npmName: string 23 npmName: string
@@ -443,7 +437,7 @@ export class PluginManager implements ServerHook {
443 437
444 // ###################### Translations ###################### 438 // ###################### Translations ######################
445 439
446 private async addTranslations (plugin: PluginModel, npmName: string, translationPaths: PackagePluginTranslations) { 440 private async addTranslations (plugin: PluginModel, npmName: string, translationPaths: PluginTranslationPaths) {
447 for (const locale of Object.keys(translationPaths)) { 441 for (const locale of Object.keys(translationPaths)) {
448 const path = translationPaths[locale] 442 const path = translationPaths[locale]
449 const json = await readJSON(join(this.getPluginPath(plugin.name, plugin.type), path)) 443 const json = await readJSON(join(this.getPluginPath(plugin.name, plugin.type), path))
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index 203217b70..f5b573370 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -26,9 +26,9 @@ import {
26 PluginVideoLicenceManager, 26 PluginVideoLicenceManager,
27 PluginVideoPrivacyManager, 27 PluginVideoPrivacyManager,
28 RegisterServerHookOptions, 28 RegisterServerHookOptions,
29 RegisterServerSettingOptions 29 RegisterServerSettingOptions,
30 serverHookObject
30} from '@shared/models' 31} from '@shared/models'
31import { serverHookObject } from '@shared/models/plugins/server-hook.model'
32import { VideoTranscodingProfilesManager } from '../transcoding/video-transcoding-profiles' 32import { VideoTranscodingProfilesManager } from '../transcoding/video-transcoding-profiles'
33import { buildPluginHelpers } from './plugin-helpers-builder' 33import { buildPluginHelpers } from './plugin-helpers-builder'
34 34
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index ab87fe720..2c47ec5bb 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -1,15 +1,15 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query, ValidationChain } from 'express-validator' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4import { areValidationErrors } from './utils' 4import { PluginType } from '../../../shared/models/plugins/plugin.type'
5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model'
6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
5import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 7import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
8import { logger } from '../../helpers/logger'
9import { CONFIG } from '../../initializers/config'
6import { PluginManager } from '../../lib/plugins/plugin-manager' 10import { PluginManager } from '../../lib/plugins/plugin-manager'
7import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } from '../../helpers/custom-validators/misc'
8import { PluginModel } from '../../models/server/plugin' 11import { PluginModel } from '../../models/server/plugin'
9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' 12import { areValidationErrors } from './utils'
10import { PluginType } from '../../../shared/models/plugins/plugin.type'
11import { CONFIG } from '../../initializers/config'
12import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
13 13
14const getPluginValidator = (pluginType: PluginType, withVersion = true) => { 14const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
15 const validators: (ValidationChain | express.Handler)[] = [ 15 const validators: (ValidationChain | express.Handler)[] = [
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
index 82387af6a..94c9b04bf 100644
--- a/server/models/server/plugin.ts
+++ b/server/models/server/plugin.ts
@@ -1,9 +1,7 @@
1import { FindAndCountOptions, json, QueryTypes } from 'sequelize' 1import { FindAndCountOptions, json, QueryTypes } from 'sequelize'
2import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' 2import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
3import { MPlugin, MPluginFormattable } from '@server/types/models' 3import { MPlugin, MPluginFormattable } from '@server/types/models'
4import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model' 4import { PeerTubePlugin, PluginType, RegisterServerSettingOptions } from '../../../shared/models'
5import { PluginType } from '../../../shared/models/plugins/plugin.type'
6import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model'
7import { 5import {
8 isPluginDescriptionValid, 6 isPluginDescriptionValid,
9 isPluginHomepage, 7 isPluginHomepage,
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 6e540bcbb..a833fe6ff 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4 4import { HttpStatusCode } from '@shared/core-utils'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -11,14 +11,14 @@ import {
11 flushAndRunServer, 11 flushAndRunServer,
12 immutableAssign, 12 immutableAssign,
13 installPlugin, 13 installPlugin,
14 makeGetRequest, makePostBodyRequest, makePutBodyRequest, 14 makeGetRequest,
15 makePostBodyRequest,
16 makePutBodyRequest,
15 ServerInfo, 17 ServerInfo,
16 setAccessTokensToServers, 18 setAccessTokensToServers,
17 userLogin 19 userLogin
18} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
19import { PluginType } from '../../../../shared/models/plugins/plugin.type' 21import { PeerTubePlugin, PluginType } from '@shared/models'
20import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model'
21import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
22 22
23describe('Test server plugins API validators', function () { 23describe('Test server plugins API validators', function () {
24 let server: ServerInfo 24 let server: ServerInfo
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index 1c6eabe6d..3c09acc9a 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -28,14 +28,8 @@ import {
28 updatePluginSettings, 28 updatePluginSettings,
29 wait, 29 wait,
30 waitUntilLog 30 waitUntilLog
31} from '../../../../shared/extra-utils' 31} from '@shared/extra-utils'
32import { PeerTubePluginIndex } from '../../../../shared/models/plugins/peertube-plugin-index.model' 32import { PeerTubePlugin, PeerTubePluginIndex, PluginPackageJson, PluginType, PublicServerSetting, ServerConfig, User } from '@shared/models'
33import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model'
34import { PluginPackageJson } from '../../../../shared/models/plugins/plugin-package-json.model'
35import { PluginType } from '../../../../shared/models/plugins/plugin.type'
36import { PublicServerSetting } from '../../../../shared/models/plugins/public-server.setting'
37import { ServerConfig } from '../../../../shared/models/server'
38import { User } from '../../../../shared/models/users'
39 33
40const expect = chai.expect 34const expect = chai.expect
41 35
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts
index c8a576844..cb591377b 100644
--- a/server/tools/peertube-plugins.ts
+++ b/server/tools/peertube-plugins.ts
@@ -4,10 +4,9 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
4registerTSPaths() 4registerTSPaths()
5 5
6import * as program from 'commander' 6import * as program from 'commander'
7import { PluginType } from '../../shared/models/plugins/plugin.type'
8import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins' 7import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins'
9import { getAdminTokenOrDie, getServerCredentials } from './cli' 8import { getAdminTokenOrDie, getServerCredentials } from './cli'
10import { PeerTubePlugin } from '../../shared/models/plugins/peertube-plugin.model' 9import { PeerTubePlugin, PluginType } from '../../shared/models'
11import { isAbsolute } from 'path' 10import { isAbsolute } from 'path'
12import * as CliTable3 from 'cli-table3' 11import * as CliTable3 from 'cli-table3'
13import commander = require('commander') 12import commander = require('commander')
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index 864954ee7..d53e5b382 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -4,12 +4,12 @@ import { expect } from 'chai'
4import { readJSON, writeJSON } from 'fs-extra' 4import { readJSON, writeJSON } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { RegisteredServerSettings } from '@shared/models' 6import { RegisteredServerSettings } from '@shared/models'
7import { PeertubePluginIndexList } from '../../models/plugins/peertube-plugin-index-list.model' 7import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
8import { PeertubePluginIndexList } from '../../models/plugins/plugin-index/peertube-plugin-index-list.model'
8import { PluginType } from '../../models/plugins/plugin.type' 9import { PluginType } from '../../models/plugins/plugin.type'
9import { buildServerDirectory, root } from '../miscs/miscs' 10import { buildServerDirectory, root } from '../miscs/miscs'
10import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' 11import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
11import { ServerInfo } from './servers' 12import { ServerInfo } from './servers'
12import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
13 13
14function listPlugins (parameters: { 14function listPlugins (parameters: {
15 url: string 15 url: string
diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts
index 620651051..620651051 100644
--- a/shared/models/plugins/client-hook.model.ts
+++ b/shared/models/plugins/client/client-hook.model.ts
diff --git a/shared/models/plugins/client/index.ts b/shared/models/plugins/client/index.ts
new file mode 100644
index 000000000..6dfc6351f
--- /dev/null
+++ b/shared/models/plugins/client/index.ts
@@ -0,0 +1,6 @@
1export * from './client-hook.model'
2export * from './plugin-client-scope.type'
3export * from './plugin-element-placeholder.type'
4export * from './register-client-form-field.model'
5export * from './register-client-hook.model'
6export * from './register-client-settings-script.model'
diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/client/plugin-client-scope.type.ts
index 8cc234ff2..8cc234ff2 100644
--- a/shared/models/plugins/plugin-client-scope.type.ts
+++ b/shared/models/plugins/client/plugin-client-scope.type.ts
diff --git a/shared/models/plugins/plugin-element-placeholder.type.ts b/shared/models/plugins/client/plugin-element-placeholder.type.ts
index 129099c62..129099c62 100644
--- a/shared/models/plugins/plugin-element-placeholder.type.ts
+++ b/shared/models/plugins/client/plugin-element-placeholder.type.ts
diff --git a/shared/models/plugins/register-client-form-field.model.ts b/shared/models/plugins/client/register-client-form-field.model.ts
index 2df071337..2df071337 100644
--- a/shared/models/plugins/register-client-form-field.model.ts
+++ b/shared/models/plugins/client/register-client-form-field.model.ts
diff --git a/shared/models/plugins/register-client-hook.model.ts b/shared/models/plugins/client/register-client-hook.model.ts
index 81047b21d..81047b21d 100644
--- a/shared/models/plugins/register-client-hook.model.ts
+++ b/shared/models/plugins/client/register-client-hook.model.ts
diff --git a/shared/models/plugins/register-client-settings-script.model.ts b/shared/models/plugins/client/register-client-settings-script.model.ts
index ac16af366..481ceef96 100644
--- a/shared/models/plugins/register-client-settings-script.model.ts
+++ b/shared/models/plugins/client/register-client-settings-script.model.ts
@@ -1,4 +1,4 @@
1import { RegisterServerSettingOptions } from "./register-server-setting.model" 1import { RegisterServerSettingOptions } from '../server'
2 2
3export interface RegisterClientSettingsScript { 3export interface RegisterClientSettingsScript {
4 isSettingHidden (options: { 4 isSettingHidden (options: {
diff --git a/shared/models/plugins/index.ts b/shared/models/plugins/index.ts
index 03b27f907..cbbe4916e 100644
--- a/shared/models/plugins/index.ts
+++ b/shared/models/plugins/index.ts
@@ -1,28 +1,6 @@
1export * from './client-hook.model' 1export * from './client'
2export * from './plugin-index'
3export * from './server'
2export * from './hook-type.enum' 4export * from './hook-type.enum'
3export * from './install-plugin.model'
4export * from './manage-plugin.model'
5export * from './peertube-plugin-index-list.model'
6export * from './peertube-plugin-index.model'
7export * from './peertube-plugin-latest-version.model'
8export * from './peertube-plugin.model'
9export * from './plugin-client-scope.type'
10export * from './plugin-element-placeholder.type'
11export * from './plugin-package-json.model' 5export * from './plugin-package-json.model'
12export * from './plugin-playlist-privacy-manager.model'
13export * from './plugin-settings-manager.model'
14export * from './plugin-storage-manager.model'
15export * from './plugin-transcoding-manager.model'
16export * from './plugin-translation.model'
17export * from './plugin-video-category-manager.model'
18export * from './plugin-video-language-manager.model'
19export * from './plugin-video-licence-manager.model'
20export * from './plugin-video-privacy-manager.model'
21export * from './plugin.type' 6export * from './plugin.type'
22export * from './public-server.setting'
23export * from './register-client-hook.model'
24export * from './register-client-settings-script.model'
25export * from './register-client-form-field.model'
26export * from './register-server-hook.model'
27export * from './register-server-setting.model'
28export * from './server-hook.model'
diff --git a/shared/models/plugins/plugin-index/index.ts b/shared/models/plugins/plugin-index/index.ts
new file mode 100644
index 000000000..913846638
--- /dev/null
+++ b/shared/models/plugins/plugin-index/index.ts
@@ -0,0 +1,3 @@
1export * from './peertube-plugin-index-list.model'
2export * from './peertube-plugin-index.model'
3export * from './peertube-plugin-latest-version.model'
diff --git a/shared/models/plugins/peertube-plugin-index-list.model.ts b/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts
index 817bac31e..ecb46482e 100644
--- a/shared/models/plugins/peertube-plugin-index-list.model.ts
+++ b/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts
@@ -1,4 +1,4 @@
1import { PluginType } from './plugin.type' 1import { PluginType } from '../plugin.type'
2 2
3export interface PeertubePluginIndexList { 3export interface PeertubePluginIndexList {
4 start: number 4 start: number
diff --git a/shared/models/plugins/peertube-plugin-index.model.ts b/shared/models/plugins/plugin-index/peertube-plugin-index.model.ts
index e91c8b4dc..e91c8b4dc 100644
--- a/shared/models/plugins/peertube-plugin-index.model.ts
+++ b/shared/models/plugins/plugin-index/peertube-plugin-index.model.ts
diff --git a/shared/models/plugins/peertube-plugin-latest-version.model.ts b/shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts
index 811a64429..811a64429 100644
--- a/shared/models/plugins/peertube-plugin-latest-version.model.ts
+++ b/shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts
diff --git a/shared/models/plugins/plugin-package-json.model.ts b/shared/models/plugins/plugin-package-json.model.ts
index c26e9ae5b..b2f92af80 100644
--- a/shared/models/plugins/plugin-package-json.model.ts
+++ b/shared/models/plugins/plugin-package-json.model.ts
@@ -1,4 +1,4 @@
1import { PluginClientScope } from './plugin-client-scope.type' 1import { PluginClientScope } from './client/plugin-client-scope.type'
2 2
3export type PluginTranslationPaths = { 3export type PluginTranslationPaths = {
4 [ locale: string ]: string 4 [ locale: string ]: string
diff --git a/shared/models/plugins/server/api/index.ts b/shared/models/plugins/server/api/index.ts
new file mode 100644
index 000000000..eb59a03f0
--- /dev/null
+++ b/shared/models/plugins/server/api/index.ts
@@ -0,0 +1,3 @@
1export * from './install-plugin.model'
2export * from './manage-plugin.model'
3export * from './peertube-plugin.model'
diff --git a/shared/models/plugins/install-plugin.model.ts b/shared/models/plugins/server/api/install-plugin.model.ts
index 5a268ebe1..5a268ebe1 100644
--- a/shared/models/plugins/install-plugin.model.ts
+++ b/shared/models/plugins/server/api/install-plugin.model.ts
diff --git a/shared/models/plugins/manage-plugin.model.ts b/shared/models/plugins/server/api/manage-plugin.model.ts
index 612b3056c..612b3056c 100644
--- a/shared/models/plugins/manage-plugin.model.ts
+++ b/shared/models/plugins/server/api/manage-plugin.model.ts
diff --git a/shared/models/plugins/peertube-plugin.model.ts b/shared/models/plugins/server/api/peertube-plugin.model.ts
index 2b0bb8cfa..54c383f57 100644
--- a/shared/models/plugins/peertube-plugin.model.ts
+++ b/shared/models/plugins/server/api/peertube-plugin.model.ts
@@ -1,4 +1,4 @@
1import { PluginType } from './plugin.type' 1import { PluginType } from '../../plugin.type'
2 2
3export interface PeerTubePlugin { 3export interface PeerTubePlugin {
4 name: string 4 name: string
diff --git a/shared/models/plugins/server/index.ts b/shared/models/plugins/server/index.ts
new file mode 100644
index 000000000..d3ff49d3b
--- /dev/null
+++ b/shared/models/plugins/server/index.ts
@@ -0,0 +1,6 @@
1export * from './api'
2export * from './managers'
3export * from './settings'
4export * from './plugin-translation.model'
5export * from './register-server-hook.model'
6export * from './server-hook.model'
diff --git a/shared/models/plugins/server/managers/index.ts b/shared/models/plugins/server/managers/index.ts
new file mode 100644
index 000000000..49365a854
--- /dev/null
+++ b/shared/models/plugins/server/managers/index.ts
@@ -0,0 +1,9 @@
1
2export * from './plugin-playlist-privacy-manager.model'
3export * from './plugin-settings-manager.model'
4export * from './plugin-storage-manager.model'
5export * from './plugin-transcoding-manager.model'
6export * from './plugin-video-category-manager.model'
7export * from './plugin-video-language-manager.model'
8export * from './plugin-video-licence-manager.model'
9export * from './plugin-video-privacy-manager.model'
diff --git a/shared/models/plugins/plugin-playlist-privacy-manager.model.ts b/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts
index d1823ef4e..4703c0a8b 100644
--- a/shared/models/plugins/plugin-playlist-privacy-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts
@@ -1,4 +1,4 @@
1import { VideoPlaylistPrivacy } from '../videos/playlist/video-playlist-privacy.model' 1import { VideoPlaylistPrivacy } from '../../../videos/playlist/video-playlist-privacy.model'
2 2
3export interface PluginPlaylistPrivacyManager { 3export interface PluginPlaylistPrivacyManager {
4 // PUBLIC = 1, 4 // PUBLIC = 1,
diff --git a/shared/models/plugins/plugin-settings-manager.model.ts b/shared/models/plugins/server/managers/plugin-settings-manager.model.ts
index 3c28c0565..3c28c0565 100644
--- a/shared/models/plugins/plugin-settings-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-settings-manager.model.ts
diff --git a/shared/models/plugins/plugin-storage-manager.model.ts b/shared/models/plugins/server/managers/plugin-storage-manager.model.ts
index 51567044a..51567044a 100644
--- a/shared/models/plugins/plugin-storage-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-storage-manager.model.ts
diff --git a/shared/models/plugins/plugin-transcoding-manager.model.ts b/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts
index 8babccd4e..a0422a460 100644
--- a/shared/models/plugins/plugin-transcoding-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts
@@ -1,4 +1,4 @@
1import { EncoderOptionsBuilder } from '../videos/video-transcoding.model' 1import { EncoderOptionsBuilder } from '../../../videos/video-transcoding.model'
2 2
3export interface PluginTranscodingManager { 3export interface PluginTranscodingManager {
4 addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean 4 addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean
diff --git a/shared/models/plugins/plugin-video-category-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts
index 201bfa979..201bfa979 100644
--- a/shared/models/plugins/plugin-video-category-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts
diff --git a/shared/models/plugins/plugin-video-language-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts
index 3fd577a79..3fd577a79 100644
--- a/shared/models/plugins/plugin-video-language-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts
diff --git a/shared/models/plugins/plugin-video-licence-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts
index 82a634d3a..82a634d3a 100644
--- a/shared/models/plugins/plugin-video-licence-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts
diff --git a/shared/models/plugins/plugin-video-privacy-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts
index 3ada99608..7717115e3 100644
--- a/shared/models/plugins/plugin-video-privacy-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts
@@ -1,4 +1,4 @@
1import { VideoPrivacy } from '../videos/video-privacy.enum' 1import { VideoPrivacy } from '../../../videos/video-privacy.enum'
2 2
3export interface PluginVideoPrivacyManager { 3export interface PluginVideoPrivacyManager {
4 // PUBLIC = 1 4 // PUBLIC = 1
diff --git a/shared/models/plugins/plugin-translation.model.ts b/shared/models/plugins/server/plugin-translation.model.ts
index a2dd8e560..a2dd8e560 100644
--- a/shared/models/plugins/plugin-translation.model.ts
+++ b/shared/models/plugins/server/plugin-translation.model.ts
diff --git a/shared/models/plugins/register-server-hook.model.ts b/shared/models/plugins/server/register-server-hook.model.ts
index 746fdc329..746fdc329 100644
--- a/shared/models/plugins/register-server-hook.model.ts
+++ b/shared/models/plugins/server/register-server-hook.model.ts
diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server/server-hook.model.ts
index 88277af5a..88277af5a 100644
--- a/shared/models/plugins/server-hook.model.ts
+++ b/shared/models/plugins/server/server-hook.model.ts
diff --git a/shared/models/plugins/server/settings/index.ts b/shared/models/plugins/server/settings/index.ts
new file mode 100644
index 000000000..b456de019
--- /dev/null
+++ b/shared/models/plugins/server/settings/index.ts
@@ -0,0 +1,2 @@
1export * from './public-server.setting'
2export * from './register-server-setting.model'
diff --git a/shared/models/plugins/public-server.setting.ts b/shared/models/plugins/server/settings/public-server.setting.ts
index 9802c4d7d..9802c4d7d 100644
--- a/shared/models/plugins/public-server.setting.ts
+++ b/shared/models/plugins/server/settings/public-server.setting.ts
diff --git a/shared/models/plugins/register-server-setting.model.ts b/shared/models/plugins/server/settings/register-server-setting.model.ts
index 9f45c3c37..d9a798cac 100644
--- a/shared/models/plugins/register-server-setting.model.ts
+++ b/shared/models/plugins/server/settings/register-server-setting.model.ts
@@ -1,4 +1,4 @@
1import { RegisterClientFormFieldOptions } from './register-client-form-field.model' 1import { RegisterClientFormFieldOptions } from '../../client'
2 2
3export type RegisterServerSettingOptions = RegisterClientFormFieldOptions & { 3export type RegisterServerSettingOptions = RegisterClientFormFieldOptions & {
4 // If the setting is not private, anyone can view its value (client code included) 4 // If the setting is not private, anyone can view its value (client code included)