Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix type conflict

Chocobozzzc7cdac440970
diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts
index e574e75a3c..1157a274e8 100644
--- a/client/src/root-helpers/plugins-manager.ts
+++ b/client/src/root-helpers/plugins-manager.ts
@@ -7,7 +7,7 @@ import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
import {
ClientHookName,
clientHookObject,
- ClientScript,
+ ClientScriptJSON,
HTMLServerConfig,
PluginClientScope,
PluginType,
@@ -18,20 +18,20 @@ import {
RegisterClientVideoFieldOptions,
RegisteredExternalAuthConfig,
ServerConfigPlugin
-} from '../../../shared/models'
+} from '@shared/models'
import { environment } from '../environments/environment'
-import { ClientScript as ClientScriptModule } from '../types/client-script.model'
+import { ClientScript } from '../types'
interface HookStructValue extends RegisterClientHookOptions {
plugin: ServerConfigPlugin
- clientScript: ClientScript
+ clientScript: ClientScriptJSON
}
type Hooks = { [ name: string ]: HookStructValue[] }
type PluginInfo = {
plugin: ServerConfigPlugin
- clientScript: ClientScript
+ clientScript: ClientScriptJSON
pluginType: PluginType
isTheme: boolean
}
@@ -248,7 +248,7 @@ class PluginsManager {
const absURL = (environment.apiUrl || window.location.origin) + clientScript.script
return dynamicImport(absURL)
- .then((script: ClientScriptModule) => {
+ .then((script: ClientScript) => {
return script.register({
registerHook,
registerVideoField,
diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts
index f2d4efb32a..60b29dc894 100644
--- a/server/helpers/custom-validators/plugins.ts
+++ b/server/helpers/custom-validators/plugins.ts
@@ -2,7 +2,7 @@ import { exists, isArray, isSafePath } from './misc'
import validator from 'validator'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
-import { PluginPackageJson } from '../../../shared/models/plugins/plugin-package-json.model'
+import { PluginPackageJSON } from '../../../shared/models/plugins/plugin-package-json.model'
import { isUrlValid } from './activitypub/misc'
const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS
@@ -84,7 +84,7 @@ function isThemeNameValid (name: string) {
return isPluginNameValid(name)
}
-function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) {
+function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType) {
let result = true
const badFields: string[] = []
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 6c2f4764e4..ff00ab9e8b 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -5,7 +5,7 @@ import { basename, join } from 'path'
import { decachePlugin } from '@server/helpers/decache'
import { MOAuthTokenUser, MUser } from '@server/types/models'
import { getCompleteLocale } from '@shared/core-utils'
-import { ClientScript, PluginPackageJson, PluginTranslation, PluginTranslationPaths, RegisterServerHookOptions } from '@shared/models'
+import { ClientScriptJSON, PluginPackageJSON, PluginTranslation, PluginTranslationPathsJSON, RegisterServerHookOptions } from '@shared/models'
import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
import { ServerHook, ServerHookName } from '../../../shared/models/plugins/server/server-hook.model'
@@ -31,7 +31,7 @@ export interface RegisteredPlugin {
path: string
staticDirs: { [name: string]: string }
- clientScripts: { [name: string]: ClientScript }
+ clientScripts: { [name: string]: ClientScriptJSON }
css: string[]
@@ -392,7 +392,7 @@ export class PluginManager implements ServerHook {
registerHelpers = result.registerStore
}
- const clientScripts: { [id: string]: ClientScript } = {}
+ const clientScripts: { [id: string]: ClientScriptJSON } = {}
for (const c of packageJSON.clientScripts) {
clientScripts[c.script] = c
}
@@ -415,7 +415,7 @@ export class PluginManager implements ServerHook {
await this.addTranslations(plugin, npmName, packageJSON.translations)
}
- private async registerPlugin (plugin: PluginModel, pluginPath: string, packageJSON: PluginPackageJson) {
+ private async registerPlugin (plugin: PluginModel, pluginPath: string, packageJSON: PluginPackageJSON) {
const npmName = PluginModel.buildNpmName(plugin.name, plugin.type)
// Delete cache if needed
@@ -442,7 +442,7 @@ export class PluginManager implements ServerHook {
// ###################### Translations ######################
- private async addTranslations (plugin: PluginModel, npmName: string, translationPaths: PluginTranslationPaths) {
+ private async addTranslations (plugin: PluginModel, npmName: string, translationPaths: PluginTranslationPathsJSON) {
for (const locale of Object.keys(translationPaths)) {
const path = translationPaths[locale]
const json = await readJSON(join(this.getPluginPath(plugin.name, plugin.type), path))
@@ -513,7 +513,7 @@ export class PluginManager implements ServerHook {
private getPackageJSON (pluginName: string, pluginType: PluginType) {
const pluginPath = join(this.getPluginPath(pluginName, pluginType), 'package.json')
- return readJSON(pluginPath) as Promise<PluginPackageJson>
+ return readJSON(pluginPath) as Promise<PluginPackageJSON>
}
private getPluginPath (pluginName: string, pluginType: PluginType) {
@@ -572,7 +572,7 @@ export class PluginManager implements ServerHook {
}
}
- private sanitizeAndCheckPackageJSONOrThrow (packageJSON: PluginPackageJson, pluginType: PluginType) {
+ private sanitizeAndCheckPackageJSONOrThrow (packageJSON: PluginPackageJSON, pluginType: PluginType) {
if (!packageJSON.staticDirs) packageJSON.staticDirs = {}
if (!packageJSON.css) packageJSON.css = []
if (!packageJSON.clientScripts) packageJSON.clientScripts = []
diff --git a/shared/models/plugins/plugin-package-json.model.ts b/shared/models/plugins/plugin-package-json.model.ts
index b2f92af80b..7ce968ff23 100644
--- a/shared/models/plugins/plugin-package-json.model.ts
+++ b/shared/models/plugins/plugin-package-json.model.ts
@@ -1,15 +1,15 @@
import { PluginClientScope } from './client/plugin-client-scope.type'
-export type PluginTranslationPaths = {
+export type PluginTranslationPathsJSON = {
[ locale: string ]: string
}
-export type ClientScript = {
+export type ClientScriptJSON = {
script: string
scopes: PluginClientScope[]
}
-export type PluginPackageJson = {
+export type PluginPackageJSON = {
name: string
version: string
description: string
@@ -23,7 +23,7 @@ export type PluginPackageJson = {
staticDirs: { [ name: string ]: string }
css: string[]
- clientScripts: ClientScript[]
+ clientScripts: ClientScriptJSON[]
- translations: PluginTranslationPaths
+ translations: PluginTranslationPathsJSON
}
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts
index 0e3b4a3d26..8c0e21621a 100644
--- a/shared/models/server/server-config.model.ts
+++ b/shared/models/server/server-config.model.ts
@@ -1,5 +1,5 @@
import { VideoPrivacy } from '../videos/video-privacy.enum'
-import { ClientScript } from '../plugins/plugin-package-json.model'
+import { ClientScriptJSON } from '../plugins/plugin-package-json.model'
import { NSFWPolicyType } from '../videos/nsfw-policy.type'
import { BroadcastMessageLevel } from './broadcast-message-level.type'
@@ -7,7 +7,7 @@ export interface ServerConfigPlugin {
name: string
version: string
description: string
- clientScripts: { [name: string]: ClientScript }
+ clientScripts: { [name: string]: ClientScriptJSON }
}
export interface ServerConfigTheme extends ServerConfigPlugin {
diff --git a/shared/server-commands/server/plugins-command.ts b/shared/server-commands/server/plugins-command.ts
index 1c44711da8..bb1277a7c0 100644
--- a/shared/server-commands/server/plugins-command.ts
+++ b/shared/server-commands/server/plugins-command.ts
@@ -8,7 +8,7 @@ import {
PeerTubePlugin,
PeerTubePluginIndex,
PeertubePluginIndexList,
- PluginPackageJson,
+ PluginPackageJSON,
PluginTranslation,
PluginType,
PublicServerSetting,
@@ -245,7 +245,7 @@ export class PluginsCommand extends AbstractCommand {
return writeJSON(path, json)
}
- getPackageJSON (npmName: string): Promise<PluginPackageJson> {
+ getPackageJSON (npmName: string): Promise<PluginPackageJSON> {
const path = this.getPackageJSONPath(npmName)
return readJSON(path)