From 3a4992633ee62d5edfbb484d9c6bcb3cf158489d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 31 Jul 2023 14:34:36 +0200 Subject: Migrate server to ESM Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports) --- shared/models/plugins/client/client-hook.model.ts | 195 ------------------ shared/models/plugins/client/index.ts | 8 - .../plugins/client/plugin-client-scope.type.ts | 11 - .../client/plugin-element-placeholder.type.ts | 4 - .../plugins/client/plugin-selector-id.type.ts | 10 - .../client/register-client-form-field.model.ts | 30 --- .../plugins/client/register-client-hook.model.ts | 7 - .../plugins/client/register-client-route.model.ts | 7 - .../register-client-settings-script.model.ts | 8 - shared/models/plugins/hook-type.enum.ts | 5 - shared/models/plugins/index.ts | 6 - shared/models/plugins/plugin-index/index.ts | 3 - .../peertube-plugin-index-list.model.ts | 10 - .../plugin-index/peertube-plugin-index.model.ts | 16 -- .../peertube-plugin-latest-version.model.ts | 10 - shared/models/plugins/plugin-package-json.model.ts | 29 --- shared/models/plugins/plugin.type.ts | 4 - shared/models/plugins/server/api/index.ts | 3 - .../plugins/server/api/install-plugin.model.ts | 5 - .../plugins/server/api/manage-plugin.model.ts | 3 - .../plugins/server/api/peertube-plugin.model.ts | 16 -- shared/models/plugins/server/index.ts | 6 - shared/models/plugins/server/managers/index.ts | 9 - .../plugin-playlist-privacy-manager.model.ts | 12 -- .../managers/plugin-settings-manager.model.ts | 17 -- .../managers/plugin-storage-manager.model.ts | 5 - .../managers/plugin-transcoding-manager.model.ts | 13 -- .../plugin-video-category-manager.model.ts | 13 -- .../plugin-video-language-manager.model.ts | 13 -- .../managers/plugin-video-licence-manager.model.ts | 13 -- .../managers/plugin-video-privacy-manager.model.ts | 13 -- .../server/plugin-constant-manager.model.ts | 7 - .../plugins/server/plugin-translation.model.ts | 5 - .../plugins/server/register-server-hook.model.ts | 7 - shared/models/plugins/server/server-hook.model.ts | 221 --------------------- shared/models/plugins/server/settings/index.ts | 2 - .../server/settings/public-server.setting.ts | 5 - .../settings/register-server-setting.model.ts | 12 -- 38 files changed, 763 deletions(-) delete mode 100644 shared/models/plugins/client/client-hook.model.ts delete mode 100644 shared/models/plugins/client/index.ts delete mode 100644 shared/models/plugins/client/plugin-client-scope.type.ts delete mode 100644 shared/models/plugins/client/plugin-element-placeholder.type.ts delete mode 100644 shared/models/plugins/client/plugin-selector-id.type.ts delete mode 100644 shared/models/plugins/client/register-client-form-field.model.ts delete mode 100644 shared/models/plugins/client/register-client-hook.model.ts delete mode 100644 shared/models/plugins/client/register-client-route.model.ts delete mode 100644 shared/models/plugins/client/register-client-settings-script.model.ts delete mode 100644 shared/models/plugins/hook-type.enum.ts delete mode 100644 shared/models/plugins/index.ts delete mode 100644 shared/models/plugins/plugin-index/index.ts delete mode 100644 shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts delete mode 100644 shared/models/plugins/plugin-index/peertube-plugin-index.model.ts delete mode 100644 shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts delete mode 100644 shared/models/plugins/plugin-package-json.model.ts delete mode 100644 shared/models/plugins/plugin.type.ts delete mode 100644 shared/models/plugins/server/api/index.ts delete mode 100644 shared/models/plugins/server/api/install-plugin.model.ts delete mode 100644 shared/models/plugins/server/api/manage-plugin.model.ts delete mode 100644 shared/models/plugins/server/api/peertube-plugin.model.ts delete mode 100644 shared/models/plugins/server/index.ts delete mode 100644 shared/models/plugins/server/managers/index.ts delete mode 100644 shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-settings-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-storage-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-video-category-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-video-language-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts delete mode 100644 shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts delete mode 100644 shared/models/plugins/server/plugin-constant-manager.model.ts delete mode 100644 shared/models/plugins/server/plugin-translation.model.ts delete mode 100644 shared/models/plugins/server/register-server-hook.model.ts delete mode 100644 shared/models/plugins/server/server-hook.model.ts delete mode 100644 shared/models/plugins/server/settings/index.ts delete mode 100644 shared/models/plugins/server/settings/public-server.setting.ts delete mode 100644 shared/models/plugins/server/settings/register-server-setting.model.ts (limited to 'shared/models/plugins') diff --git a/shared/models/plugins/client/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts deleted file mode 100644 index 4a0818c99..000000000 --- a/shared/models/plugins/client/client-hook.model.ts +++ /dev/null @@ -1,195 +0,0 @@ -// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target} -// Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target} - -export const clientFilterHookObject = { - // Filter params/result of the function that fetch videos of the trending page - 'filter:api.trending-videos.videos.list.params': true, - 'filter:api.trending-videos.videos.list.result': true, - - // Filter params/result of the function that fetch videos of the trending page - 'filter:api.most-liked-videos.videos.list.params': true, - 'filter:api.most-liked-videos.videos.list.result': true, - - // Filter params/result of the function that fetch videos of the local page - 'filter:api.local-videos.videos.list.params': true, - 'filter:api.local-videos.videos.list.result': true, - - // Filter params/result of the function that fetch videos of the recently-added page - 'filter:api.recently-added-videos.videos.list.params': true, - 'filter:api.recently-added-videos.videos.list.result': true, - - // Filter params/result of the function that fetch videos of the user subscription page - 'filter:api.user-subscriptions-videos.videos.list.params': true, - 'filter:api.user-subscriptions-videos.videos.list.result': true, - - // Filter params/result of the function that fetch the video of the video-watch page - 'filter:api.video-watch.video.get.params': true, - 'filter:api.video-watch.video.get.result': true, - - // Filter params/result of the function that fetch video playlist elements of the video-watch page - 'filter:api.video-watch.video-playlist-elements.get.params': true, - 'filter:api.video-watch.video-playlist-elements.get.result': true, - - // Filter params/result of the function that fetch the threads of the video-watch page - 'filter:api.video-watch.video-threads.list.params': true, - 'filter:api.video-watch.video-threads.list.result': true, - - // Filter params/result of the function that fetch the replies of a thread in the video-watch page - 'filter:api.video-watch.video-thread-replies.list.params': true, - 'filter:api.video-watch.video-thread-replies.list.result': true, - - // Filter params/result of the function that fetch videos according to the user search - 'filter:api.search.videos.list.params': true, - 'filter:api.search.videos.list.result': true, - // Filter params/result of the function that fetch video channels according to the user search - 'filter:api.search.video-channels.list.params': true, - 'filter:api.search.video-channels.list.result': true, - // Filter params/result of the function that fetch video playlists according to the user search - 'filter:api.search.video-playlists.list.params': true, - 'filter:api.search.video-playlists.list.result': true, - - // Filter form - 'filter:api.signup.registration.create.params': true, - - // Filter params/result of the function that fetch video playlist elements of the my-library page - 'filter:api.my-library.video-playlist-elements.list.params': true, - 'filter:api.my-library.video-playlist-elements.list.result': true, - - // Filter the options to create our player - 'filter:internal.video-watch.player.build-options.params': true, - 'filter:internal.video-watch.player.build-options.result': true, - - // Filter the options to load a new video in our player - 'filter:internal.video-watch.player.load-options.params': true, - 'filter:internal.video-watch.player.load-options.result': true, - - // Filter our SVG icons content - 'filter:internal.common.svg-icons.get-content.params': true, - 'filter:internal.common.svg-icons.get-content.result': true, - - // Filter left menu links - 'filter:left-menu.links.create.result': true, - - // Filter upload page alert messages - 'filter:upload.messages.create.result': true, - - 'filter:login.instance-about-plugin-panels.create.result': true, - 'filter:signup.instance-about-plugin-panels.create.result': true, - - 'filter:share.video-embed-code.build.params': true, - 'filter:share.video-embed-code.build.result': true, - 'filter:share.video-playlist-embed-code.build.params': true, - 'filter:share.video-playlist-embed-code.build.result': true, - - 'filter:share.video-embed-url.build.params': true, - 'filter:share.video-embed-url.build.result': true, - 'filter:share.video-playlist-embed-url.build.params': true, - 'filter:share.video-playlist-embed-url.build.result': true, - - 'filter:share.video-url.build.params': true, - 'filter:share.video-url.build.result': true, - 'filter:share.video-playlist-url.build.params': true, - 'filter:share.video-playlist-url.build.result': true, - - 'filter:video-watch.video-plugin-metadata.result': true, - - // Filter videojs options built for PeerTube player - 'filter:internal.player.videojs.options.result': true, - - // Filter p2p media loader options built for PeerTube player - 'filter:internal.player.p2p-media-loader.options.result': true -} - -export type ClientFilterHookName = keyof typeof clientFilterHookObject - -export const clientActionHookObject = { - // Fired when the application is being initialized - 'action:application.init': true, - - // Fired when the video watch page is being initialized - 'action:video-watch.init': true, - // Fired when the video watch page loaded the video - 'action:video-watch.video.loaded': true, - // Fired when the player finished loading - 'action:video-watch.player.loaded': true, - // Fired when the video watch page comments(threads) are loaded and load more comments on scroll - 'action:video-watch.video-threads.loaded': true, - // Fired when a user click on 'View x replies' and they're loaded - 'action:video-watch.video-thread-replies.loaded': true, - - // Fired when the video channel creation page is being initialized - 'action:video-channel-create.init': true, - - // Fired when the video channel update page is being initialized - 'action:video-channel-update.init': true, - 'action:video-channel-update.video-channel.loaded': true, - - // Fired when the page that list video channel videos is being initialized - 'action:video-channel-videos.init': true, - 'action:video-channel-videos.video-channel.loaded': true, - 'action:video-channel-videos.videos.loaded': true, - - // Fired when the page that list video channel playlists is being initialized - 'action:video-channel-playlists.init': true, - 'action:video-channel-playlists.video-channel.loaded': true, - 'action:video-channel-playlists.playlists.loaded': true, - - // Fired when the video edit page (upload, URL/torrent import, update) is being initialized - // Contains a `type` and `updateForm` object attributes - 'action:video-edit.init': true, - - // Fired when values of the video edit form changed - 'action:video-edit.form.updated': true, - - // Fired when the login page is being initialized - 'action:login.init': true, - - // Fired when the search page is being initialized - 'action:search.init': true, - - // Fired every time Angular URL changes - 'action:router.navigation-end': true, - - // Fired when the registration page is being initialized - 'action:signup.register.init': true, - - // PeerTube >= 3.2 - // Fired when the admin plugin settings page is being initialized - 'action:admin-plugin-settings.init': true, - - // Fired when the video upload page is being initialized - 'action:video-upload.init': true, - // Fired when the video import by URL page is being initialized - 'action:video-url-import.init': true, - // Fired when the video import by torrent/magnet URI page is being initialized - 'action:video-torrent-import.init': true, - // Fired when the "Go Live" page is being initialized - 'action:go-live.init': true, - - // Fired when the user explicitly logged in/logged out - 'action:auth-user.logged-in': true, - 'action:auth-user.logged-out': true, - // Fired when the application loaded user information (using tokens from the local storage or after a successful login) - 'action:auth-user.information-loaded': true, - - // Fired when the modal to download a video/caption is shown - 'action:modal.video-download.shown': true, - // Fired when the modal to share a video/playlist is shown - 'action:modal.share.shown': true, - - // ####### Embed hooks ####### - // /!\ In embed scope, peertube helpers are not available - // ########################### - - // Fired when the embed loaded the player - 'action:embed.player.loaded': true -} - -export type ClientActionHookName = keyof typeof clientActionHookObject - -export const clientHookObject = Object.assign({}, clientFilterHookObject, clientActionHookObject) -export type ClientHookName = keyof typeof clientHookObject - -export interface ClientHook { - runHook (hookName: ClientHookName, result?: T, params?: any): Promise -} diff --git a/shared/models/plugins/client/index.ts b/shared/models/plugins/client/index.ts deleted file mode 100644 index f3e3fcbcf..000000000 --- a/shared/models/plugins/client/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './client-hook.model' -export * from './plugin-client-scope.type' -export * from './plugin-element-placeholder.type' -export * from './plugin-selector-id.type' -export * from './register-client-form-field.model' -export * from './register-client-hook.model' -export * from './register-client-route.model' -export * from './register-client-settings-script.model' diff --git a/shared/models/plugins/client/plugin-client-scope.type.ts b/shared/models/plugins/client/plugin-client-scope.type.ts deleted file mode 100644 index c09a453b8..000000000 --- a/shared/models/plugins/client/plugin-client-scope.type.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type PluginClientScope = - 'common' | - 'video-watch' | - 'search' | - 'signup' | - 'login' | - 'embed' | - 'video-edit' | - 'admin-plugin' | - 'my-library' | - 'video-channel' diff --git a/shared/models/plugins/client/plugin-element-placeholder.type.ts b/shared/models/plugins/client/plugin-element-placeholder.type.ts deleted file mode 100644 index 7b8a2605b..000000000 --- a/shared/models/plugins/client/plugin-element-placeholder.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type PluginElementPlaceholder = - 'player-next' | - 'share-modal-playlist-settings' | - 'share-modal-video-settings' diff --git a/shared/models/plugins/client/plugin-selector-id.type.ts b/shared/models/plugins/client/plugin-selector-id.type.ts deleted file mode 100644 index 8d23314b5..000000000 --- a/shared/models/plugins/client/plugin-selector-id.type.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type PluginSelectorId = - 'login-form' | - 'menu-user-dropdown-language-item' | - 'about-instance-features' | - 'about-instance-statistics' | - 'about-instance-moderation' | - 'about-menu-instance' | - 'about-menu-peertube' | - 'about-menu-network' | - 'about-instance-other-information' diff --git a/shared/models/plugins/client/register-client-form-field.model.ts b/shared/models/plugins/client/register-client-form-field.model.ts deleted file mode 100644 index 153c4a6ea..000000000 --- a/shared/models/plugins/client/register-client-form-field.model.ts +++ /dev/null @@ -1,30 +0,0 @@ -export type RegisterClientFormFieldOptions = { - name?: string - label?: string - type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' | 'select' | 'html' - - // For select type - options?: { value: string, label: string }[] - - // For html type - html?: string - - descriptionHTML?: string - - // Default setting value - default?: string | boolean - - // Not supported by plugin setting registration, use registerSettingsScript instead - hidden?: (options: any) => boolean - - // Return undefined | null if there is no error or return a string with the detailed error - // Not supported by plugin setting registration - error?: (options: any) => Promise<{ error: boolean, text?: string }> -} - -export interface RegisterClientVideoFieldOptions { - type: 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live' - - // Default to 'plugin-settings' - tab?: 'main' | 'plugin-settings' -} diff --git a/shared/models/plugins/client/register-client-hook.model.ts b/shared/models/plugins/client/register-client-hook.model.ts deleted file mode 100644 index 81047b21d..000000000 --- a/shared/models/plugins/client/register-client-hook.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ClientHookName } from './client-hook.model' - -export interface RegisterClientHookOptions { - target: ClientHookName - handler: Function - priority?: number -} diff --git a/shared/models/plugins/client/register-client-route.model.ts b/shared/models/plugins/client/register-client-route.model.ts deleted file mode 100644 index 271b67834..000000000 --- a/shared/models/plugins/client/register-client-route.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface RegisterClientRouteOptions { - route: string - - onMount (options: { - rootEl: HTMLElement - }): void -} diff --git a/shared/models/plugins/client/register-client-settings-script.model.ts b/shared/models/plugins/client/register-client-settings-script.model.ts deleted file mode 100644 index 117ca4739..000000000 --- a/shared/models/plugins/client/register-client-settings-script.model.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { RegisterServerSettingOptions } from '../server' - -export interface RegisterClientSettingsScriptOptions { - isSettingHidden (options: { - setting: RegisterServerSettingOptions - formValues: { [name: string]: any } - }): boolean -} diff --git a/shared/models/plugins/hook-type.enum.ts b/shared/models/plugins/hook-type.enum.ts deleted file mode 100644 index a96c943f1..000000000 --- a/shared/models/plugins/hook-type.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum HookType { - STATIC = 1, - ACTION = 2, - FILTER = 3 -} diff --git a/shared/models/plugins/index.ts b/shared/models/plugins/index.ts deleted file mode 100644 index cbbe4916e..000000000 --- a/shared/models/plugins/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './client' -export * from './plugin-index' -export * from './server' -export * from './hook-type.enum' -export * from './plugin-package-json.model' -export * from './plugin.type' diff --git a/shared/models/plugins/plugin-index/index.ts b/shared/models/plugins/plugin-index/index.ts deleted file mode 100644 index 913846638..000000000 --- a/shared/models/plugins/plugin-index/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './peertube-plugin-index-list.model' -export * from './peertube-plugin-index.model' -export * from './peertube-plugin-latest-version.model' diff --git a/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts b/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts deleted file mode 100644 index ecb46482e..000000000 --- a/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PluginType } from '../plugin.type' - -export interface PeertubePluginIndexList { - start: number - count: number - sort: string - pluginType?: PluginType - currentPeerTubeEngine?: string - search?: string -} diff --git a/shared/models/plugins/plugin-index/peertube-plugin-index.model.ts b/shared/models/plugins/plugin-index/peertube-plugin-index.model.ts deleted file mode 100644 index 36dfef943..000000000 --- a/shared/models/plugins/plugin-index/peertube-plugin-index.model.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface PeerTubePluginIndex { - npmName: string - description: string - homepage: string - createdAt: Date - updatedAt: Date - - popularity: number - - latestVersion: string - - official: boolean - - name?: string - installed?: boolean -} diff --git a/shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts b/shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts deleted file mode 100644 index 811a64429..000000000 --- a/shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface PeertubePluginLatestVersionRequest { - currentPeerTubeEngine?: string - - npmNames: string[] -} - -export type PeertubePluginLatestVersionResponse = { - npmName: string - latestVersion: string | null -}[] diff --git a/shared/models/plugins/plugin-package-json.model.ts b/shared/models/plugins/plugin-package-json.model.ts deleted file mode 100644 index 7ce968ff2..000000000 --- a/shared/models/plugins/plugin-package-json.model.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { PluginClientScope } from './client/plugin-client-scope.type' - -export type PluginTranslationPathsJSON = { - [ locale: string ]: string -} - -export type ClientScriptJSON = { - script: string - scopes: PluginClientScope[] -} - -export type PluginPackageJSON = { - name: string - version: string - description: string - engine: { peertube: string } - - homepage: string - author: string - bugs: string - library: string - - staticDirs: { [ name: string ]: string } - css: string[] - - clientScripts: ClientScriptJSON[] - - translations: PluginTranslationPathsJSON -} diff --git a/shared/models/plugins/plugin.type.ts b/shared/models/plugins/plugin.type.ts deleted file mode 100644 index 016219ceb..000000000 --- a/shared/models/plugins/plugin.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum PluginType { - PLUGIN = 1, - THEME = 2 -} diff --git a/shared/models/plugins/server/api/index.ts b/shared/models/plugins/server/api/index.ts deleted file mode 100644 index eb59a03f0..000000000 --- a/shared/models/plugins/server/api/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './install-plugin.model' -export * from './manage-plugin.model' -export * from './peertube-plugin.model' diff --git a/shared/models/plugins/server/api/install-plugin.model.ts b/shared/models/plugins/server/api/install-plugin.model.ts deleted file mode 100644 index a1d009a00..000000000 --- a/shared/models/plugins/server/api/install-plugin.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface InstallOrUpdatePlugin { - npmName?: string - pluginVersion?: string - path?: string -} diff --git a/shared/models/plugins/server/api/manage-plugin.model.ts b/shared/models/plugins/server/api/manage-plugin.model.ts deleted file mode 100644 index 612b3056c..000000000 --- a/shared/models/plugins/server/api/manage-plugin.model.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface ManagePlugin { - npmName: string -} diff --git a/shared/models/plugins/server/api/peertube-plugin.model.ts b/shared/models/plugins/server/api/peertube-plugin.model.ts deleted file mode 100644 index 54c383f57..000000000 --- a/shared/models/plugins/server/api/peertube-plugin.model.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PluginType } from '../../plugin.type' - -export interface PeerTubePlugin { - name: string - type: PluginType - latestVersion: string - version: string - enabled: boolean - uninstalled: boolean - peertubeEngine: string - description: string - homepage: string - settings: { [ name: string ]: string } - createdAt: Date - updatedAt: Date -} diff --git a/shared/models/plugins/server/index.ts b/shared/models/plugins/server/index.ts deleted file mode 100644 index d3ff49d3b..000000000 --- a/shared/models/plugins/server/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './api' -export * from './managers' -export * from './settings' -export * from './plugin-translation.model' -export * from './register-server-hook.model' -export * from './server-hook.model' diff --git a/shared/models/plugins/server/managers/index.ts b/shared/models/plugins/server/managers/index.ts deleted file mode 100644 index 49365a854..000000000 --- a/shared/models/plugins/server/managers/index.ts +++ /dev/null @@ -1,9 +0,0 @@ - -export * from './plugin-playlist-privacy-manager.model' -export * from './plugin-settings-manager.model' -export * from './plugin-storage-manager.model' -export * from './plugin-transcoding-manager.model' -export * from './plugin-video-category-manager.model' -export * from './plugin-video-language-manager.model' -export * from './plugin-video-licence-manager.model' -export * from './plugin-video-privacy-manager.model' diff --git a/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts b/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts deleted file mode 100644 index 35247c1e3..000000000 --- a/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { VideoPlaylistPrivacy } from '../../../videos/playlist/video-playlist-privacy.model' -import { ConstantManager } from '../plugin-constant-manager.model' - -export interface PluginPlaylistPrivacyManager extends ConstantManager { - /** - * PUBLIC = 1, - * UNLISTED = 2, - * PRIVATE = 3 - * @deprecated use `deleteConstant` instead - */ - deletePlaylistPrivacy: (privacyKey: VideoPlaylistPrivacy) => boolean -} diff --git a/shared/models/plugins/server/managers/plugin-settings-manager.model.ts b/shared/models/plugins/server/managers/plugin-settings-manager.model.ts deleted file mode 100644 index b628718dd..000000000 --- a/shared/models/plugins/server/managers/plugin-settings-manager.model.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type SettingValue = string | boolean - -export interface SettingEntries { - [settingName: string]: SettingValue -} - -export type SettingsChangeCallback = (settings: SettingEntries) => Promise - -export interface PluginSettingsManager { - getSetting: (name: string) => Promise - - getSettings: (names: string[]) => Promise - - setSetting: (name: string, value: SettingValue) => Promise - - onSettingsChange: (cb: SettingsChangeCallback) => void -} diff --git a/shared/models/plugins/server/managers/plugin-storage-manager.model.ts b/shared/models/plugins/server/managers/plugin-storage-manager.model.ts deleted file mode 100644 index 51567044a..000000000 --- a/shared/models/plugins/server/managers/plugin-storage-manager.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface PluginStorageManager { - getData: (key: string) => Promise - - storeData: (key: string, data: any) => Promise -} diff --git a/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts b/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts deleted file mode 100644 index b6fb46ba0..000000000 --- a/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { EncoderOptionsBuilder } from '../../../videos/transcoding' - -export interface PluginTranscodingManager { - addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean - - addVODProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean - - addLiveEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void - - addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void - - removeAllProfilesAndEncoderPriorities(): void -} diff --git a/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts deleted file mode 100644 index cf3d828fe..000000000 --- a/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ConstantManager } from '../plugin-constant-manager.model' - -export interface PluginVideoCategoryManager extends ConstantManager { - /** - * @deprecated use `addConstant` instead - */ - addCategory: (categoryKey: number, categoryLabel: string) => boolean - - /** - * @deprecated use `deleteConstant` instead - */ - deleteCategory: (categoryKey: number) => boolean -} diff --git a/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts deleted file mode 100644 index 69fc8e503..000000000 --- a/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ConstantManager } from '../plugin-constant-manager.model' - -export interface PluginVideoLanguageManager extends ConstantManager { - /** - * @deprecated use `addConstant` instead - */ - addLanguage: (languageKey: string, languageLabel: string) => boolean - - /** - * @deprecated use `deleteConstant` instead - */ - deleteLanguage: (languageKey: string) => boolean -} diff --git a/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts deleted file mode 100644 index 21b422270..000000000 --- a/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ConstantManager } from '../plugin-constant-manager.model' - -export interface PluginVideoLicenceManager extends ConstantManager { - /** - * @deprecated use `addConstant` instead - */ - addLicence: (licenceKey: number, licenceLabel: string) => boolean - - /** - * @deprecated use `deleteConstant` instead - */ - deleteLicence: (licenceKey: number) => boolean -} diff --git a/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts b/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts deleted file mode 100644 index a237037db..000000000 --- a/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { VideoPrivacy } from '../../../videos/video-privacy.enum' -import { ConstantManager } from '../plugin-constant-manager.model' - -export interface PluginVideoPrivacyManager extends ConstantManager { - /** - * PUBLIC = 1, - * UNLISTED = 2, - * PRIVATE = 3 - * INTERNAL = 4 - * @deprecated use `deleteConstant` instead - */ - deletePrivacy: (privacyKey: VideoPrivacy) => boolean -} diff --git a/shared/models/plugins/server/plugin-constant-manager.model.ts b/shared/models/plugins/server/plugin-constant-manager.model.ts deleted file mode 100644 index 4de3ce38f..000000000 --- a/shared/models/plugins/server/plugin-constant-manager.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface ConstantManager { - addConstant: (key: K, label: string) => boolean - deleteConstant: (key: K) => boolean - getConstantValue: (key: K) => string - getConstants: () => Record - resetConstants: () => void -} diff --git a/shared/models/plugins/server/plugin-translation.model.ts b/shared/models/plugins/server/plugin-translation.model.ts deleted file mode 100644 index a2dd8e560..000000000 --- a/shared/models/plugins/server/plugin-translation.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type PluginTranslation = { - [ npmName: string ]: { - [ key: string ]: string - } -} diff --git a/shared/models/plugins/server/register-server-hook.model.ts b/shared/models/plugins/server/register-server-hook.model.ts deleted file mode 100644 index 746fdc329..000000000 --- a/shared/models/plugins/server/register-server-hook.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ServerHookName } from './server-hook.model' - -export interface RegisterServerHookOptions { - target: ServerHookName - handler: Function - priority?: number -} diff --git a/shared/models/plugins/server/server-hook.model.ts b/shared/models/plugins/server/server-hook.model.ts deleted file mode 100644 index cf387ffd7..000000000 --- a/shared/models/plugins/server/server-hook.model.ts +++ /dev/null @@ -1,221 +0,0 @@ -// {hookType}:{root}.{location}.{subLocation?}.{actionType}.{target} - -export const serverFilterHookObject = { - // Filter params/result used to list videos for the REST API - // (used by the trending page, recently-added page, local page etc) - 'filter:api.videos.list.params': true, - 'filter:api.videos.list.result': true, - - // Filter params/result used to list a video playlists videos - // for the REST API - 'filter:api.video-playlist.videos.list.params': true, - 'filter:api.video-playlist.videos.list.result': true, - - // Filter params/result used to list account videos for the REST API - 'filter:api.accounts.videos.list.params': true, - 'filter:api.accounts.videos.list.result': true, - - // Filter params/result used to list channel videos for the REST API - 'filter:api.video-channels.videos.list.params': true, - 'filter:api.video-channels.videos.list.result': true, - - // Filter params/result used to list my user videos for the REST API - 'filter:api.user.me.videos.list.params': true, - 'filter:api.user.me.videos.list.result': true, - - // Filter params/result used to list overview videos for the REST API - 'filter:api.overviews.videos.list.params': true, - 'filter:api.overviews.videos.list.result': true, - - // Filter params/result used to list subscription videos for the REST API - 'filter:api.user.me.subscription-videos.list.params': true, - 'filter:api.user.me.subscription-videos.list.result': true, - - // Filter params/results to search videos/channels in the DB or on the remote index - 'filter:api.search.videos.local.list.params': true, - 'filter:api.search.videos.local.list.result': true, - 'filter:api.search.videos.index.list.params': true, - 'filter:api.search.videos.index.list.result': true, - 'filter:api.search.video-channels.local.list.params': true, - 'filter:api.search.video-channels.local.list.result': true, - 'filter:api.search.video-channels.index.list.params': true, - 'filter:api.search.video-channels.index.list.result': true, - 'filter:api.search.video-playlists.local.list.params': true, - 'filter:api.search.video-playlists.local.list.result': true, - 'filter:api.search.video-playlists.index.list.params': true, - 'filter:api.search.video-playlists.index.list.result': true, - - // Filter the result of the get function - // Used to get detailed video information (video watch page for example) - 'filter:api.video.get.result': true, - - // Filter params/results when listing video channels - 'filter:api.video-channels.list.params': true, - 'filter:api.video-channels.list.result': true, - - // Filter the result when getting a video channel - 'filter:api.video-channel.get.result': true, - - // Filter the result of the accept upload/live, import via torrent/url functions - // If this function returns false then the upload is aborted with an error - 'filter:api.video.upload.accept.result': true, - 'filter:api.live-video.create.accept.result': true, - 'filter:api.video.pre-import-url.accept.result': true, - 'filter:api.video.pre-import-torrent.accept.result': true, - 'filter:api.video.post-import-url.accept.result': true, - 'filter:api.video.post-import-torrent.accept.result': true, - 'filter:api.video.update-file.accept.result': true, - // Filter the result of the accept comment (thread or reply) functions - // If the functions return false then the user cannot post its comment - 'filter:api.video-thread.create.accept.result': true, - 'filter:api.video-comment-reply.create.accept.result': true, - - // Filter attributes when creating video object - 'filter:api.video.upload.video-attribute.result': true, - 'filter:api.video.import-url.video-attribute.result': true, - 'filter:api.video.import-torrent.video-attribute.result': true, - 'filter:api.video.live.video-attribute.result': true, - - // Filter params/result used to list threads of a specific video - // (used by the video watch page) - 'filter:api.video-threads.list.params': true, - 'filter:api.video-threads.list.result': true, - - // Filter params/result used to list replies of a specific thread - // (used by the video watch page when we click on the "View replies" button) - 'filter:api.video-thread-comments.list.params': true, - 'filter:api.video-thread-comments.list.result': true, - - // Filter get stats result - 'filter:api.server.stats.get.result': true, - - // Filter result used to check if we need to auto blacklist a video - // (fired when a local or remote video is created or updated) - 'filter:video.auto-blacklist.result': true, - - // Filter result used to check if a user can register on the instance - 'filter:api.user.signup.allowed.result': true, - - // Filter result used to check if a user can send a registration request on the instance - // PeerTube >= 5.1 - 'filter:api.user.request-signup.allowed.result': true, - - // Filter result used to check if video/torrent download is allowed - 'filter:api.download.video.allowed.result': true, - 'filter:api.download.torrent.allowed.result': true, - - // Filter result to check if the embed is allowed for a particular request - 'filter:html.embed.video.allowed.result': true, - 'filter:html.embed.video-playlist.allowed.result': true, - - // Peertube >= 5.2 - 'filter:html.client.json-ld.result': true, - - 'filter:job-queue.process.params': true, - 'filter:job-queue.process.result': true, - - 'filter:transcoding.manual.resolutions-to-transcode.result': true, - 'filter:transcoding.auto.resolutions-to-transcode.result': true, - - 'filter:activity-pub.remote-video-comment.create.accept.result': true, - - 'filter:activity-pub.activity.context.build.result': true, - - // Filter the result of video JSON LD builder - // You may also need to use filter:activity-pub.activity.context.build.result to also update JSON LD context - 'filter:activity-pub.video.json-ld.build.result': true, - - // Filter result to allow custom XMLNS definitions in podcast RSS feeds - // Peertube >= 5.2 - 'filter:feed.podcast.rss.create-custom-xmlns.result': true, - - // Filter result to allow custom tags in podcast RSS feeds - // Peertube >= 5.2 - 'filter:feed.podcast.channel.create-custom-tags.result': true, - // Peertube >= 5.2 - 'filter:feed.podcast.video.create-custom-tags.result': true -} - -export type ServerFilterHookName = keyof typeof serverFilterHookObject - -export const serverActionHookObject = { - // Fired when the application has been loaded and is listening HTTP requests - 'action:application.listening': true, - - // Fired when a new notification is created - 'action:notifier.notification.created': true, - - // API actions hooks give access to the original express `req` and `res` parameters - - // Fired when a local video is updated - 'action:api.video.updated': true, - // Fired when a local video is deleted - 'action:api.video.deleted': true, - // Fired when a local video is uploaded - 'action:api.video.uploaded': true, - // Fired when a local video is viewed - 'action:api.video.viewed': true, - - // Fired when a local video file has been replaced by a new one - 'action:api.video.file-updated': true, - - // Fired when a video channel is created - 'action:api.video-channel.created': true, - // Fired when a video channel is updated - 'action:api.video-channel.updated': true, - // Fired when a video channel is deleted - 'action:api.video-channel.deleted': true, - - // Fired when a live video is created - 'action:api.live-video.created': true, - // Fired when a live video starts or ends - // Peertube >= 5.2 - 'action:live.video.state.updated': true, - - // Fired when a thread is created - 'action:api.video-thread.created': true, - // Fired when a reply to a thread is created - 'action:api.video-comment-reply.created': true, - // Fired when a comment (thread or reply) is deleted - 'action:api.video-comment.deleted': true, - - // Fired when a caption is created - 'action:api.video-caption.created': true, - // Fired when a caption is deleted - 'action:api.video-caption.deleted': true, - - // Fired when a user is blocked (banned) - 'action:api.user.blocked': true, - // Fired when a user is unblocked (unbanned) - 'action:api.user.unblocked': true, - // Fired when a user registered on the instance - 'action:api.user.registered': true, - // Fired when a user requested registration on the instance - // PeerTube >= 5.1 - 'action:api.user.requested-registration': true, - // Fired when an admin/moderator created a user - 'action:api.user.created': true, - // Fired when a user is removed by an admin/moderator - 'action:api.user.deleted': true, - // Fired when a user is updated by an admin/moderator - 'action:api.user.updated': true, - - // Fired when a user got a new oauth2 token - 'action:api.user.oauth2-got-token': true, - - // Fired when a video is added to a playlist - 'action:api.video-playlist-element.created': true, - - // Fired when a remote video has been created/updated - 'action:activity-pub.remote-video.created': true, - 'action:activity-pub.remote-video.updated': true -} - -export type ServerActionHookName = keyof typeof serverActionHookObject - -export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject) -export type ServerHookName = keyof typeof serverHookObject - -export interface ServerHook { - runHook (hookName: ServerHookName, result?: T, params?: any): Promise -} diff --git a/shared/models/plugins/server/settings/index.ts b/shared/models/plugins/server/settings/index.ts deleted file mode 100644 index b456de019..000000000 --- a/shared/models/plugins/server/settings/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './public-server.setting' -export * from './register-server-setting.model' diff --git a/shared/models/plugins/server/settings/public-server.setting.ts b/shared/models/plugins/server/settings/public-server.setting.ts deleted file mode 100644 index d38e5424a..000000000 --- a/shared/models/plugins/server/settings/public-server.setting.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SettingEntries } from '../managers/plugin-settings-manager.model' - -export interface PublicServerSetting { - publicSettings: SettingEntries -} diff --git a/shared/models/plugins/server/settings/register-server-setting.model.ts b/shared/models/plugins/server/settings/register-server-setting.model.ts deleted file mode 100644 index d9a798cac..000000000 --- a/shared/models/plugins/server/settings/register-server-setting.model.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { RegisterClientFormFieldOptions } from '../../client' - -export type RegisterServerSettingOptions = RegisterClientFormFieldOptions & { - // If the setting is not private, anyone can view its value (client code included) - // If the setting is private, only server-side hooks can access it - // Mainly used by the PeerTube client to get admin config - private: boolean -} - -export interface RegisteredServerSettings { - registeredSettings: RegisterServerSettingOptions[] -} -- cgit v1.2.3