aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/core-utils/index.ts3
-rw-r--r--shared/core-utils/logs/index.ts1
-rw-r--r--shared/core-utils/miscs/index.ts3
-rw-r--r--shared/core-utils/miscs/types.ts41
-rw-r--r--shared/core-utils/plugins/index.ts1
-rw-r--r--shared/extra-utils/server/config.ts2
-rw-r--r--shared/models/actors/index.ts1
-rw-r--r--shared/models/index.ts3
-rw-r--r--shared/models/plugins/index.ts24
-rw-r--r--shared/models/plugins/plugin-playlist-privacy-manager.model.ts2
-rw-r--r--shared/models/plugins/plugin-video-privacy-manager.model.ts2
-rw-r--r--shared/models/plugins/register-server-auth.model.ts52
-rw-r--r--shared/models/search/index.ts1
-rw-r--r--shared/models/server/index.ts1
-rw-r--r--shared/models/users/index.ts10
-rw-r--r--shared/models/videos/abuse/index.ts5
-rw-r--r--shared/models/videos/blacklist/index.ts3
-rw-r--r--shared/models/videos/caption/index.ts2
-rw-r--r--shared/models/videos/channel/index.ts3
-rw-r--r--shared/models/videos/import/index.ts3
-rw-r--r--shared/models/videos/index.ts63
-rw-r--r--shared/models/videos/playlist/index.ts10
-rw-r--r--shared/models/videos/rate/index.ts5
-rw-r--r--shared/models/videos/video-file-metadata.ts4
-rw-r--r--shared/models/videos/video-sort-field.type.ts8
25 files changed, 158 insertions, 95 deletions
diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.ts
new file mode 100644
index 000000000..54e233522
--- /dev/null
+++ b/shared/core-utils/index.ts
@@ -0,0 +1,3 @@
1export * from './logs'
2export * from './miscs'
3export * from './plugins'
diff --git a/shared/core-utils/logs/index.ts b/shared/core-utils/logs/index.ts
new file mode 100644
index 000000000..ceb5d7a7f
--- /dev/null
+++ b/shared/core-utils/logs/index.ts
@@ -0,0 +1 @@
export * from './logs'
diff --git a/shared/core-utils/miscs/index.ts b/shared/core-utils/miscs/index.ts
new file mode 100644
index 000000000..afd147f24
--- /dev/null
+++ b/shared/core-utils/miscs/index.ts
@@ -0,0 +1,3 @@
1export * from './date'
2export * from './miscs'
3export * from './types'
diff --git a/shared/core-utils/miscs/types.ts b/shared/core-utils/miscs/types.ts
new file mode 100644
index 000000000..bb64dc830
--- /dev/null
+++ b/shared/core-utils/miscs/types.ts
@@ -0,0 +1,41 @@
1/* eslint-disable @typescript-eslint/array-type */
2
3export type FunctionPropertyNames<T> = {
4 [K in keyof T]: T[K] extends Function ? K : never
5}[keyof T]
6
7export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>
8
9export type PickWith<T, KT extends keyof T, V> = {
10 [P in KT]: T[P] extends V ? V : never
11}
12
13export type PickWithOpt<T, KT extends keyof T, V> = {
14 [P in KT]?: T[P] extends V ? V : never
15}
16
17// https://github.com/krzkaczor/ts-essentials Rocks!
18export type DeepPartial<T> = {
19 [P in keyof T]?: T[P] extends Array<infer U>
20 ? Array<DeepPartial<U>>
21 : T[P] extends ReadonlyArray<infer U>
22 ? ReadonlyArray<DeepPartial<U>>
23 : DeepPartial<T[P]>
24}
25
26type Primitive = string | Function | number | boolean | Symbol | undefined | null
27export type DeepOmitHelper<T, K extends keyof T> = {
28 [P in K]: // extra level of indirection needed to trigger homomorhic behavior
29 T[P] extends infer TP // distribute over unions
30 ? TP extends Primitive
31 ? TP // leave primitives and functions alone
32 : TP extends any[]
33 ? DeepOmitArray<TP, K> // Array special handling
34 : DeepOmit<TP, K>
35 : never
36}
37export type DeepOmit<T, K> = T extends Primitive ? T : DeepOmitHelper<T, Exclude<keyof T, K>>
38
39export type DeepOmitArray<T extends any[], K> = {
40 [P in keyof T]: DeepOmit<T[P], K>
41}
diff --git a/shared/core-utils/plugins/index.ts b/shared/core-utils/plugins/index.ts
new file mode 100644
index 000000000..fc78d3512
--- /dev/null
+++ b/shared/core-utils/plugins/index.ts
@@ -0,0 +1 @@
export * from './hooks'
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts
index 2b04a0396..3ae1c6e67 100644
--- a/shared/extra-utils/server/config.ts
+++ b/shared/extra-utils/server/config.ts
@@ -1,6 +1,6 @@
1import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' 1import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
2import { CustomConfig } from '../../models/server/custom-config.model' 2import { CustomConfig } from '../../models/server/custom-config.model'
3import { DeepPartial } from '@server/types/utils' 3import { DeepPartial } from '@shared/core-utils'
4import { merge } from 'lodash' 4import { merge } from 'lodash'
5 5
6function getConfig (url: string) { 6function getConfig (url: string) {
diff --git a/shared/models/actors/index.ts b/shared/models/actors/index.ts
index 8fe437b81..c7a92399d 100644
--- a/shared/models/actors/index.ts
+++ b/shared/models/actors/index.ts
@@ -1,2 +1,3 @@
1export * from './account.model' 1export * from './account.model'
2export * from './actor.model'
2export * from './follow.model' 3export * from './follow.model'
diff --git a/shared/models/index.ts b/shared/models/index.ts
index b562e04a3..3d4bdedde 100644
--- a/shared/models/index.ts
+++ b/shared/models/index.ts
@@ -9,8 +9,9 @@ export * from './videos'
9export * from './feeds' 9export * from './feeds'
10export * from './i18n' 10export * from './i18n'
11export * from './overviews' 11export * from './overviews'
12export * from './plugins'
12export * from './search' 13export * from './search'
13export * from './server/job.model' 14export * from './server'
14export * from './oauth-client-local.model' 15export * from './oauth-client-local.model'
15export * from './result-list.model' 16export * from './result-list.model'
16export * from './server/server-config.model' 17export * from './server/server-config.model'
diff --git a/shared/models/plugins/index.ts b/shared/models/plugins/index.ts
new file mode 100644
index 000000000..209fca791
--- /dev/null
+++ b/shared/models/plugins/index.ts
@@ -0,0 +1,24 @@
1export * from './client-hook.model'
2export * 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-package-json.model'
11export * from './plugin-playlist-privacy-manager.model'
12export * from './plugin-settings-manager.model'
13export * from './plugin-storage-manager.model'
14export * from './plugin-translation.model'
15export * from './plugin-video-category-manager.model'
16export * from './plugin-video-language-manager.model'
17export * from './plugin-video-licence-manager.model'
18export * from './plugin-video-privacy-manager.model'
19export * from './plugin.type'
20export * from './public-server.setting'
21export * from './register-client-hook.model'
22export * from './register-server-hook.model'
23export * from './register-server-setting.model'
24export * from './server-hook.model'
diff --git a/shared/models/plugins/plugin-playlist-privacy-manager.model.ts b/shared/models/plugins/plugin-playlist-privacy-manager.model.ts
index f9630c77f..d1823ef4e 100644
--- a/shared/models/plugins/plugin-playlist-privacy-manager.model.ts
+++ b/shared/models/plugins/plugin-playlist-privacy-manager.model.ts
@@ -1,4 +1,4 @@
1import { VideoPlaylistPrivacy } from '@shared/models' 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-video-privacy-manager.model.ts b/shared/models/plugins/plugin-video-privacy-manager.model.ts
index d602ba297..c0e8117b5 100644
--- a/shared/models/plugins/plugin-video-privacy-manager.model.ts
+++ b/shared/models/plugins/plugin-video-privacy-manager.model.ts
@@ -1,4 +1,4 @@
1import { VideoPrivacy } from '@shared/models' 1import { VideoPrivacy } from '@shared/models/videos/video-privacy.enum'
2 2
3export interface PluginVideoPrivacyManager { 3export interface PluginVideoPrivacyManager {
4 // PUBLIC = 1 4 // PUBLIC = 1
diff --git a/shared/models/plugins/register-server-auth.model.ts b/shared/models/plugins/register-server-auth.model.ts
deleted file mode 100644
index fc6f0f258..000000000
--- a/shared/models/plugins/register-server-auth.model.ts
+++ /dev/null
@@ -1,52 +0,0 @@
1import { UserRole } from '@shared/models'
2import { MOAuthToken, MUser } from '@server/types/models'
3import * as express from 'express'
4
5export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions
6
7export interface RegisterServerAuthenticatedResult {
8 username: string
9 email: string
10 role?: UserRole
11 displayName?: string
12}
13
14export interface RegisterServerExternalAuthenticatedResult extends RegisterServerAuthenticatedResult {
15 req: express.Request
16 res: express.Response
17}
18
19interface RegisterServerAuthBase {
20 // Authentication name (a plugin can register multiple auth strategies)
21 authName: string
22
23 // Called by PeerTube when a user from your plugin logged out
24 onLogout?(user: MUser): void
25
26 // Your plugin can hook PeerTube access/refresh token validity
27 // So you can control for your plugin the user session lifetime
28 hookTokenValidity?(options: { token: MOAuthToken, type: 'access' | 'refresh' }): Promise<{ valid: boolean }>
29}
30
31export interface RegisterServerAuthPassOptions extends RegisterServerAuthBase {
32 // Weight of this authentication so PeerTube tries the auth methods in DESC weight order
33 getWeight(): number
34
35 // Used by PeerTube to login a user
36 // Returns null if the login failed, or { username, email } on success
37 login(body: {
38 id: string
39 password: string
40 }): Promise<RegisterServerAuthenticatedResult | null>
41}
42
43export interface RegisterServerAuthExternalOptions extends RegisterServerAuthBase {
44 // Will be displayed in a block next to the login form
45 authDisplayName: () => string
46
47 onAuthRequest: (req: express.Request, res: express.Response) => void
48}
49
50export interface RegisterServerAuthExternalResult {
51 userAuthenticated (options: RegisterServerExternalAuthenticatedResult): void
52}
diff --git a/shared/models/search/index.ts b/shared/models/search/index.ts
index 28dd95443..e2d0ab620 100644
--- a/shared/models/search/index.ts
+++ b/shared/models/search/index.ts
@@ -1,3 +1,4 @@
1export * from './nsfw-query.model' 1export * from './nsfw-query.model'
2export * from './search-target-query.model'
2export * from './videos-search-query.model' 3export * from './videos-search-query.model'
3export * from './video-channels-search-query.model' 4export * from './video-channels-search-query.model'
diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts
index 2bb443d46..b079bc9a0 100644
--- a/shared/models/server/index.ts
+++ b/shared/models/server/index.ts
@@ -5,5 +5,6 @@ export * from './custom-config.model'
5export * from './debug.model' 5export * from './debug.model'
6export * from './emailer.model' 6export * from './emailer.model'
7export * from './job.model' 7export * from './job.model'
8export * from './log-level.type'
8export * from './server-config.model' 9export * from './server-config.model'
9export * from './server-stats.model' 10export * from './server-stats.model'
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts
index cd07cf320..a9d578054 100644
--- a/shared/models/users/index.ts
+++ b/shared/models/users/index.ts
@@ -1,12 +1,14 @@
1export * from './user.model'
2export * from './user-create.model' 1export * from './user-create.model'
2export * from './user-flag.model'
3export * from './user-login.model' 3export * from './user-login.model'
4export * from './user-notification.model'
5export * from './user-notification-setting.model' 4export * from './user-notification-setting.model'
5export * from './user-notification.model'
6export * from './user-refresh-token.model' 6export * from './user-refresh-token.model'
7export * from './user-update.model' 7export * from './user-register.model'
8export * from './user-update-me.model'
9export * from './user-right.enum' 8export * from './user-right.enum'
10export * from './user-role' 9export * from './user-role'
10export * from './user-update-me.model'
11export * from './user-update.model'
11export * from './user-video-quota.model' 12export * from './user-video-quota.model'
12export * from './user-watching-video.model' 13export * from './user-watching-video.model'
14export * from './user.model'
diff --git a/shared/models/videos/abuse/index.ts b/shared/models/videos/abuse/index.ts
new file mode 100644
index 000000000..bdeef1dad
--- /dev/null
+++ b/shared/models/videos/abuse/index.ts
@@ -0,0 +1,5 @@
1export * from './video-abuse-create.model'
2export * from './video-abuse-state.model'
3export * from './video-abuse-update.model'
4export * from './video-abuse-video-is.type'
5export * from './video-abuse.model'
diff --git a/shared/models/videos/blacklist/index.ts b/shared/models/videos/blacklist/index.ts
new file mode 100644
index 000000000..66082be34
--- /dev/null
+++ b/shared/models/videos/blacklist/index.ts
@@ -0,0 +1,3 @@
1export * from './video-blacklist.model'
2export * from './video-blacklist-create.model'
3export * from './video-blacklist-update.model'
diff --git a/shared/models/videos/caption/index.ts b/shared/models/videos/caption/index.ts
new file mode 100644
index 000000000..2a5ff512d
--- /dev/null
+++ b/shared/models/videos/caption/index.ts
@@ -0,0 +1,2 @@
1export * from './video-caption.model'
2export * from './video-caption-update.model'
diff --git a/shared/models/videos/channel/index.ts b/shared/models/videos/channel/index.ts
new file mode 100644
index 000000000..9dbaa42da
--- /dev/null
+++ b/shared/models/videos/channel/index.ts
@@ -0,0 +1,3 @@
1export * from './video-channel-create.model'
2export * from './video-channel-update.model'
3export * from './video-channel.model'
diff --git a/shared/models/videos/import/index.ts b/shared/models/videos/import/index.ts
new file mode 100644
index 000000000..8884ee8f2
--- /dev/null
+++ b/shared/models/videos/import/index.ts
@@ -0,0 +1,3 @@
1export * from './video-import-create.model'
2export * from './video-import-state.enum'
3export * from './video-import.model'
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts
index 58bd1ebd7..e1d96b40a 100644
--- a/shared/models/videos/index.ts
+++ b/shared/models/videos/index.ts
@@ -1,41 +1,38 @@
1export * from './rate/user-video-rate-update.model' 1export * from './abuse'
2export * from './rate/user-video-rate.model' 2export * from './blacklist'
3export * from './rate/account-video-rate.model' 3export * from './caption'
4export * from './rate/user-video-rate.type' 4export * from './channel'
5export * from './abuse/video-abuse-state.model' 5export * from './import'
6export * from './abuse/video-abuse-create.model' 6export * from './playlist'
7export * from './abuse/video-abuse-reason.model' 7export * from './rate'
8export * from './abuse/video-abuse.model' 8
9export * from './abuse/video-abuse-update.model' 9export * from './nsfw-policy.type'
10export * from './blacklist/video-blacklist.model' 10
11export * from './blacklist/video-blacklist-create.model' 11export * from './thumbnail.type'
12export * from './blacklist/video-blacklist-update.model' 12
13export * from './channel/video-channel-create.model' 13export * from './video-change-ownership-accept.model'
14export * from './channel/video-channel-update.model'
15export * from './channel/video-channel.model'
16export * from './playlist/video-playlist-create.model'
17export * from './playlist/video-playlist-element-create.model'
18export * from './playlist/video-playlist-element-update.model'
19export * from './playlist/video-playlist-privacy.model'
20export * from './playlist/video-playlist-type.model'
21export * from './playlist/video-playlist-update.model'
22export * from './playlist/video-playlist.model'
23export * from './playlist/video-playlist-element.model'
24export * from './video-change-ownership.model'
25export * from './video-change-ownership-create.model' 14export * from './video-change-ownership-create.model'
15export * from './video-change-ownership.model'
16
17export * from './video-comment.model'
18export * from './video-constant.model'
26export * from './video-create.model' 19export * from './video-create.model'
20export * from './video-file-metadata'
27export * from './video-file.model' 21export * from './video-file.model'
22
28export * from './video-privacy.enum' 23export * from './video-privacy.enum'
24export * from './video-query.type'
29export * from './video-rate.type' 25export * from './video-rate.type'
30export * from './video-resolution.enum' 26export * from './video-resolution.enum'
31export * from './video-update.model' 27
32export * from './video.model' 28export * from './video-schedule-update.model'
33export * from './video-query.type' 29export * from './video-sort-field.type'
34export * from './video-state.enum' 30export * from './video-state.enum'
31
32export * from './video-streaming-playlist.model'
33export * from './video-streaming-playlist.type'
34
35export * from './video-transcoding-fps.model' 35export * from './video-transcoding-fps.model'
36export * from './caption/video-caption.model' 36
37export * from './caption/video-caption-update.model' 37export * from './video-update.model'
38export * from './import/video-import-create.model' 38export * from './video.model'
39export * from './import/video-import-state.enum'
40export * from './import/video-import.model'
41export * from './video-constant.model'
diff --git a/shared/models/videos/playlist/index.ts b/shared/models/videos/playlist/index.ts
new file mode 100644
index 000000000..99f7e9bab
--- /dev/null
+++ b/shared/models/videos/playlist/index.ts
@@ -0,0 +1,10 @@
1export * from './video-exist-in-playlist.model'
2export * from './video-playlist-create.model'
3export * from './video-playlist-element-create.model'
4export * from './video-playlist-element-update.model'
5export * from './video-playlist-element.model'
6export * from './video-playlist-privacy.model'
7export * from './video-playlist-reorder.model'
8export * from './video-playlist-type.model'
9export * from './video-playlist-update.model'
10export * from './video-playlist.model'
diff --git a/shared/models/videos/rate/index.ts b/shared/models/videos/rate/index.ts
new file mode 100644
index 000000000..06aa691bd
--- /dev/null
+++ b/shared/models/videos/rate/index.ts
@@ -0,0 +1,5 @@
1
2export * from './user-video-rate-update.model'
3export * from './user-video-rate.model'
4export * from './account-video-rate.model'
5export * from './user-video-rate.type'
diff --git a/shared/models/videos/video-file-metadata.ts b/shared/models/videos/video-file-metadata.ts
index 15683cacf..010bf7cf5 100644
--- a/shared/models/videos/video-file-metadata.ts
+++ b/shared/models/videos/video-file-metadata.ts
@@ -1,5 +1,5 @@
1import { FfprobeData } from "fluent-ffmpeg" 1import { FfprobeData } from 'fluent-ffmpeg'
2import { DeepOmit } from "@server/models/utils" 2import { DeepOmit } from '../../core-utils'
3 3
4export type VideoFileMetadataModel = DeepOmit<FfprobeData, 'filename'> 4export type VideoFileMetadataModel = DeepOmit<FfprobeData, 'filename'>
5 5
diff --git a/shared/models/videos/video-sort-field.type.ts b/shared/models/videos/video-sort-field.type.ts
new file mode 100644
index 000000000..f2e70f5fa
--- /dev/null
+++ b/shared/models/videos/video-sort-field.type.ts
@@ -0,0 +1,8 @@
1export type VideoSortField =
2 'name' | '-name' |
3 'duration' | '-duration' |
4 'publishedAt' | '-publishedAt' |
5 'createdAt' | '-createdAt' |
6 'views' | '-views' |
7 'likes' | '-likes' |
8 'trending' | '-trending'