diff options
Diffstat (limited to 'server/types')
32 files changed, 175 insertions, 50 deletions
diff --git a/server/types/index.ts b/server/types/index.ts new file mode 100644 index 000000000..18d3827a5 --- /dev/null +++ b/server/types/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './plugins' | ||
2 | export * from './activitypub-processor.model' | ||
3 | export * from './sequelize' | ||
diff --git a/server/types/models/account/account-blocklist.ts b/server/types/models/account/account-blocklist.ts index 0d8bf11bd..3126fd0ab 100644 --- a/server/types/models/account/account-blocklist.ts +++ b/server/types/models/account/account-blocklist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' | 1 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MAccountDefault, MAccountFormattable } from './account' | 3 | import { MAccountDefault, MAccountFormattable } from './account' |
4 | 4 | ||
5 | type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> | 5 | type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> |
diff --git a/server/types/models/account/account.ts b/server/types/models/account/account.ts index 7b826ee04..d2add9810 100644 --- a/server/types/models/account/account.ts +++ b/server/types/models/account/account.ts | |||
@@ -13,7 +13,7 @@ import { | |||
13 | MActorSummaryFormattable, | 13 | MActorSummaryFormattable, |
14 | MActorUrl | 14 | MActorUrl |
15 | } from './actor' | 15 | } from './actor' |
16 | import { FunctionProperties, PickWith } from '../../utils' | 16 | import { FunctionProperties, PickWith } from '@shared/core-utils' |
17 | import { MAccountBlocklistId } from './account-blocklist' | 17 | import { MAccountBlocklistId } from './account-blocklist' |
18 | import { MChannelDefault } from '../video/video-channels' | 18 | import { MChannelDefault } from '../video/video-channels' |
19 | 19 | ||
diff --git a/server/types/models/account/actor-follow.ts b/server/types/models/account/actor-follow.ts index 5d0c03c8d..8c213d09c 100644 --- a/server/types/models/account/actor-follow.ts +++ b/server/types/models/account/actor-follow.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | MActorHost, | 8 | MActorHost, |
9 | MActorUsername | 9 | MActorUsername |
10 | } from './actor' | 10 | } from './actor' |
11 | import { PickWith } from '../../utils' | 11 | import { PickWith } from '@shared/core-utils' |
12 | import { ActorModel } from '@server/models/activitypub/actor' | 12 | import { ActorModel } from '@server/models/activitypub/actor' |
13 | import { MChannelDefault } from '../video/video-channels' | 13 | import { MChannelDefault } from '../video/video-channels' |
14 | 14 | ||
diff --git a/server/types/models/account/actor.ts b/server/types/models/account/actor.ts index 1160e84cb..ee0d05f4e 100644 --- a/server/types/models/account/actor.ts +++ b/server/types/models/account/actor.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ActorModel } from '../../../models/activitypub/actor' | 1 | import { ActorModel } from '../../../models/activitypub/actor' |
2 | import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' | 2 | import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' | 3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' |
4 | import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' | 4 | import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' |
5 | import { MAvatar, MAvatarFormattable } from './avatar' | 5 | import { MAvatar, MAvatarFormattable } from './avatar' |
diff --git a/server/types/models/account/avatar.ts b/server/types/models/account/avatar.ts index 6eba59ee4..0489a8599 100644 --- a/server/types/models/account/avatar.ts +++ b/server/types/models/account/avatar.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { AvatarModel } from '../../../models/avatar/avatar' | 1 | import { AvatarModel } from '../../../models/avatar/avatar' |
2 | import { FunctionProperties } from '@server/types/utils' | 2 | import { FunctionProperties } from '@shared/core-utils' |
3 | 3 | ||
4 | export type MAvatar = AvatarModel | 4 | export type MAvatar = AvatarModel |
5 | 5 | ||
diff --git a/server/types/models/oauth/oauth-token.ts b/server/types/models/oauth/oauth-token.ts index 396cf6429..8399af8f1 100644 --- a/server/types/models/oauth/oauth-token.ts +++ b/server/types/models/oauth/oauth-token.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' | 1 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MUserAccountUrl } from '../user/user' | 3 | import { MUserAccountUrl } from '../user/user' |
4 | 4 | ||
5 | type Use<K extends keyof OAuthTokenModel, M> = PickWith<OAuthTokenModel, K, M> | 5 | type Use<K extends keyof OAuthTokenModel, M> = PickWith<OAuthTokenModel, K, M> |
diff --git a/server/types/models/server/server-blocklist.ts b/server/types/models/server/server-blocklist.ts index cfbf3b73a..801f179fd 100644 --- a/server/types/models/server/server-blocklist.ts +++ b/server/types/models/server/server-blocklist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' | 1 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MAccountDefault, MAccountFormattable } from '../account/account' | 3 | import { MAccountDefault, MAccountFormattable } from '../account/account' |
4 | import { MServer, MServerFormattable } from './server' | 4 | import { MServer, MServerFormattable } from './server' |
5 | 5 | ||
diff --git a/server/types/models/server/server.ts b/server/types/models/server/server.ts index b35e55aeb..f8b053e3b 100644 --- a/server/types/models/server/server.ts +++ b/server/types/models/server/server.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ServerModel } from '../../../models/server/server' | 1 | import { ServerModel } from '../../../models/server/server' |
2 | import { FunctionProperties, PickWith } from '../../utils' | 2 | import { FunctionProperties, PickWith } from '@shared/core-utils' |
3 | import { MAccountBlocklistId } from '../account' | 3 | import { MAccountBlocklistId } from '../account' |
4 | 4 | ||
5 | type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M> | 5 | type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M> |
diff --git a/server/types/models/user/user-notification.ts b/server/types/models/user/user-notification.ts index 2080360e1..dd3de423b 100644 --- a/server/types/models/user/user-notification.ts +++ b/server/types/models/user/user-notification.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { UserNotificationModel } from '../../../models/account/user-notification' | 1 | import { UserNotificationModel } from '../../../models/account/user-notification' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { VideoModel } from '../../../models/video/video' | 3 | import { VideoModel } from '../../../models/video/video' |
4 | import { ActorModel } from '../../../models/activitypub/actor' | 4 | import { ActorModel } from '../../../models/activitypub/actor' |
5 | import { ServerModel } from '../../../models/server/server' | 5 | import { ServerModel } from '../../../models/server/server' |
diff --git a/server/types/models/user/user.ts b/server/types/models/user/user.ts index 7938ea288..12a68accf 100644 --- a/server/types/models/user/user.ts +++ b/server/types/models/user/user.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { UserModel } from '../../../models/account/user' | 1 | import { UserModel } from '../../../models/account/user' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { | 3 | import { |
4 | MAccount, | 4 | MAccount, |
5 | MAccountDefault, | 5 | MAccountDefault, |
diff --git a/server/types/models/video/schedule-video-update.ts b/server/types/models/video/schedule-video-update.ts index 6336fdabe..5d2936000 100644 --- a/server/types/models/video/schedule-video-update.ts +++ b/server/types/models/video/schedule-video-update.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | 1 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MVideoAPWithoutCaption, MVideoWithBlacklistLight } from './video' | 3 | import { MVideoAPWithoutCaption, MVideoWithBlacklistLight } from './video' |
4 | 4 | ||
5 | type Use<K extends keyof ScheduleVideoUpdateModel, M> = PickWith<ScheduleVideoUpdateModel, K, M> | 5 | type Use<K extends keyof ScheduleVideoUpdateModel, M> = PickWith<ScheduleVideoUpdateModel, K, M> |
diff --git a/server/types/models/video/video-abuse.ts b/server/types/models/video/video-abuse.ts index d60f05e4c..279a87cf3 100644 --- a/server/types/models/video/video-abuse.ts +++ b/server/types/models/video/video-abuse.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | 1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MVideoAccountLightBlacklistAllFiles, MVideo } from './video' | 3 | import { MVideoAccountLightBlacklistAllFiles, MVideo } from './video' |
4 | import { MAccountDefault, MAccountFormattable } from '../account' | 4 | import { MAccountDefault, MAccountFormattable } from '../account' |
5 | 5 | ||
diff --git a/server/types/models/video/video-blacklist.ts b/server/types/models/video/video-blacklist.ts index 08e59284a..2ac912405 100644 --- a/server/types/models/video/video-blacklist.ts +++ b/server/types/models/video/video-blacklist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | 1 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MVideo, MVideoFormattable } from './video' | 3 | import { MVideo, MVideoFormattable } from './video' |
4 | 4 | ||
5 | type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M> | 5 | type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M> |
diff --git a/server/types/models/video/video-caption.ts b/server/types/models/video/video-caption.ts index 9bb067001..ab80ff830 100644 --- a/server/types/models/video/video-caption.ts +++ b/server/types/models/video/video-caption.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 1 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
2 | import { FunctionProperties, PickWith } from '@server/types/utils' | 2 | import { FunctionProperties, PickWith } from '@shared/core-utils' |
3 | import { MVideo, MVideoUUID } from './video' | 3 | import { MVideo, MVideoUUID } from './video' |
4 | 4 | ||
5 | type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M> | 5 | type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M> |
diff --git a/server/types/models/video/video-change-ownership.ts b/server/types/models/video/video-change-ownership.ts index 7421e081e..244d1a671 100644 --- a/server/types/models/video/video-change-ownership.ts +++ b/server/types/models/video/video-change-ownership.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' | 1 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MAccountDefault, MAccountFormattable } from '../account/account' | 3 | import { MAccountDefault, MAccountFormattable } from '../account/account' |
4 | import { MVideo, MVideoWithAllFiles } from './video' | 4 | import { MVideo, MVideoWithAllFiles } from './video' |
5 | 5 | ||
diff --git a/server/types/models/video/video-channels.ts b/server/types/models/video/video-channels.ts index 50f7c2d8a..2e05d8753 100644 --- a/server/types/models/video/video-channels.ts +++ b/server/types/models/video/video-channels.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' | 1 | import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils' |
2 | import { VideoChannelModel } from '../../../models/video/video-channel' | 2 | import { VideoChannelModel } from '../../../models/video/video-channel' |
3 | import { | 3 | import { |
4 | MAccountActor, | 4 | MAccountActor, |
diff --git a/server/types/models/video/video-comment.ts b/server/types/models/video/video-comment.ts index d6e0b66f5..f1c50c753 100644 --- a/server/types/models/video/video-comment.ts +++ b/server/types/models/video/video-comment.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoCommentModel } from '../../../models/video/video-comment' | 1 | import { VideoCommentModel } from '../../../models/video/video-comment' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account' | 3 | import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account' |
4 | import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' | 4 | import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' |
5 | 5 | ||
diff --git a/server/types/models/video/video-file.ts b/server/types/models/video/video-file.ts index 3fcaca78f..327a148ce 100644 --- a/server/types/models/video/video-file.ts +++ b/server/types/models/video/video-file.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoFileModel } from '../../../models/video/video-file' | 1 | import { VideoFileModel } from '../../../models/video/video-file' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { MVideo, MVideoUUID } from './video' | 3 | import { MVideo, MVideoUUID } from './video' |
4 | import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy' | 4 | import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy' |
5 | import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist' | 5 | import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist' |
diff --git a/server/types/models/video/video-import.ts b/server/types/models/video/video-import.ts index f1385877e..759b13c6e 100644 --- a/server/types/models/video/video-import.ts +++ b/server/types/models/video/video-import.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoImportModel } from '@server/models/video/video-import' | 1 | import { VideoImportModel } from '@server/models/video/video-import' |
2 | import { PickWith, PickWithOpt } from '@server/types/utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video' | 3 | import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video' |
4 | import { MUser } from '../user/user' | 4 | import { MUser } from '../user/user' |
5 | 5 | ||
diff --git a/server/types/models/video/video-playlist-element.ts b/server/types/models/video/video-playlist-element.ts index c50992da7..f46ff4d49 100644 --- a/server/types/models/video/video-playlist-element.ts +++ b/server/types/models/video/video-playlist-element.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' | 1 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video' | 3 | import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video' |
4 | import { MVideoPlaylistPrivacy } from './video-playlist' | 4 | import { MVideoPlaylistPrivacy } from './video-playlist' |
5 | 5 | ||
diff --git a/server/types/models/video/video-playlist.ts b/server/types/models/video/video-playlist.ts index b504d1664..79e2daebf 100644 --- a/server/types/models/video/video-playlist.ts +++ b/server/types/models/video/video-playlist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | 1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' | 3 | import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' |
4 | import { MThumbnail } from './thumbnail' | 4 | import { MThumbnail } from './thumbnail' |
5 | import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels' | 5 | import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels' |
diff --git a/server/types/models/video/video-rate.ts b/server/types/models/video/video-rate.ts index a7682ef31..7bd54f7b0 100644 --- a/server/types/models/video/video-rate.ts +++ b/server/types/models/video/video-rate.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { AccountVideoRateModel } from '@server/models/account/account-video-rate' | 1 | import { AccountVideoRateModel } from '@server/models/account/account-video-rate' |
2 | import { PickWith } from '@server/types/utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MAccountAudience, MAccountUrl } from '../account/account' | 3 | import { MAccountAudience, MAccountUrl } from '../account/account' |
4 | import { MVideo, MVideoFormattable } from './video' | 4 | import { MVideo, MVideoFormattable } from './video' |
5 | 5 | ||
diff --git a/server/types/models/video/video-redundancy.ts b/server/types/models/video/video-redundancy.ts index 7c7d52035..411375c81 100644 --- a/server/types/models/video/video-redundancy.ts +++ b/server/types/models/video/video-redundancy.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | 1 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' |
2 | import { PickWith, PickWithOpt } from '@server/types/utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 3 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
4 | import { VideoFileModel } from '@server/models/video/video-file' | 4 | import { VideoFileModel } from '@server/models/video/video-file' |
5 | import { MVideoFile, MVideoFileVideo } from './video-file' | 5 | import { MVideoFile, MVideoFileVideo } from './video-file' |
diff --git a/server/types/models/video/video-share.ts b/server/types/models/video/video-share.ts index 50ca75d26..b7a783bb6 100644 --- a/server/types/models/video/video-share.ts +++ b/server/types/models/video/video-share.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoShareModel } from '../../../models/video/video-share' | 1 | import { VideoShareModel } from '../../../models/video/video-share' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '@shared/core-utils' |
3 | import { MActorDefault } from '../account' | 3 | import { MActorDefault } from '../account' |
4 | import { MVideo } from './video' | 4 | import { MVideo } from './video' |
5 | 5 | ||
diff --git a/server/types/models/video/video-streaming-playlist.ts b/server/types/models/video/video-streaming-playlist.ts index 3f54aa560..8b3ef51fc 100644 --- a/server/types/models/video/video-streaming-playlist.ts +++ b/server/types/models/video/video-streaming-playlist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' | 1 | import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { MVideoRedundancyFileUrl, MVideoRedundancy } from './video-redundancy' | 3 | import { MVideoRedundancyFileUrl, MVideoRedundancy } from './video-redundancy' |
4 | import { MVideo } from './video' | 4 | import { MVideo } from './video' |
5 | import { MVideoFile } from './video-file' | 5 | import { MVideoFile } from './video-file' |
diff --git a/server/types/models/video/video.ts b/server/types/models/video/video.ts index 022a9566d..3d8f85b3d 100644 --- a/server/types/models/video/video.ts +++ b/server/types/models/video/video.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { VideoModel } from '../../../models/video/video' | 1 | import { VideoModel } from '../../../models/video/video' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '@shared/core-utils' |
3 | import { | 3 | import { |
4 | MChannelAccountDefault, | 4 | MChannelAccountDefault, |
5 | MChannelAccountLight, | 5 | MChannelAccountLight, |
diff --git a/server/types/plugins/index.ts b/server/types/plugins/index.ts new file mode 100644 index 000000000..de30ff2ab --- /dev/null +++ b/server/types/plugins/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './plugin-library.model' | ||
2 | export * from './register-server-auth.model' | ||
3 | export * from './register-server-option.model' | ||
diff --git a/server/types/plugins/plugin-library.model.ts b/server/types/plugins/plugin-library.model.ts new file mode 100644 index 000000000..5b517ee9f --- /dev/null +++ b/server/types/plugins/plugin-library.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { RegisterServerOptions } from './register-server-option.model' | ||
2 | |||
3 | export interface PluginLibrary { | ||
4 | register: (options: RegisterServerOptions) => Promise<any> | ||
5 | |||
6 | unregister: () => Promise<any> | ||
7 | } | ||
diff --git a/server/types/plugins/register-server-auth.model.ts b/server/types/plugins/register-server-auth.model.ts new file mode 100644 index 000000000..31c71b0d0 --- /dev/null +++ b/server/types/plugins/register-server-auth.model.ts | |||
@@ -0,0 +1,52 @@ | |||
1 | import * as express from 'express' | ||
2 | import { UserRole } from '@shared/models' | ||
3 | import { MOAuthToken, MUser } from '../models' | ||
4 | |||
5 | export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions | ||
6 | |||
7 | export interface RegisterServerAuthenticatedResult { | ||
8 | username: string | ||
9 | email: string | ||
10 | role?: UserRole | ||
11 | displayName?: string | ||
12 | } | ||
13 | |||
14 | export interface RegisterServerExternalAuthenticatedResult extends RegisterServerAuthenticatedResult { | ||
15 | req: express.Request | ||
16 | res: express.Response | ||
17 | } | ||
18 | |||
19 | interface 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 | |||
31 | export 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 | |||
43 | export 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 | |||
50 | export interface RegisterServerAuthExternalResult { | ||
51 | userAuthenticated (options: RegisterServerExternalAuthenticatedResult): void | ||
52 | } | ||
diff --git a/server/types/plugins/register-server-option.model.ts b/server/types/plugins/register-server-option.model.ts new file mode 100644 index 000000000..74303d383 --- /dev/null +++ b/server/types/plugins/register-server-option.model.ts | |||
@@ -0,0 +1,84 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { Router } from 'express' | ||
3 | import { Logger } from 'winston' | ||
4 | import { ActorModel } from '@server/models/activitypub/actor' | ||
5 | import { | ||
6 | PluginPlaylistPrivacyManager, | ||
7 | PluginSettingsManager, | ||
8 | PluginStorageManager, | ||
9 | PluginVideoCategoryManager, | ||
10 | PluginVideoLanguageManager, | ||
11 | PluginVideoLicenceManager, | ||
12 | PluginVideoPrivacyManager, | ||
13 | RegisterServerHookOptions, | ||
14 | RegisterServerSettingOptions, | ||
15 | VideoBlacklistCreate | ||
16 | } from '@shared/models' | ||
17 | import { MVideoThumbnail } from '../models' | ||
18 | import { | ||
19 | RegisterServerAuthExternalOptions, | ||
20 | RegisterServerAuthExternalResult, | ||
21 | RegisterServerAuthPassOptions | ||
22 | } from './register-server-auth.model' | ||
23 | |||
24 | export type PeerTubeHelpers = { | ||
25 | logger: Logger | ||
26 | |||
27 | database: { | ||
28 | query: Function | ||
29 | } | ||
30 | |||
31 | videos: { | ||
32 | loadByUrl: (url: string) => Bluebird<MVideoThumbnail> | ||
33 | |||
34 | removeVideo: (videoId: number) => Promise<void> | ||
35 | } | ||
36 | |||
37 | config: { | ||
38 | getWebserverUrl: () => string | ||
39 | } | ||
40 | |||
41 | moderation: { | ||
42 | blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void> | ||
43 | unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void> | ||
44 | blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void> | ||
45 | unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void> | ||
46 | |||
47 | blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void> | ||
48 | unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void> | ||
49 | } | ||
50 | |||
51 | server: { | ||
52 | getServerActor: () => Promise<ActorModel> | ||
53 | } | ||
54 | } | ||
55 | |||
56 | export type RegisterServerOptions = { | ||
57 | registerHook: (options: RegisterServerHookOptions) => void | ||
58 | |||
59 | registerSetting: (options: RegisterServerSettingOptions) => void | ||
60 | |||
61 | settingsManager: PluginSettingsManager | ||
62 | |||
63 | storageManager: PluginStorageManager | ||
64 | |||
65 | videoCategoryManager: PluginVideoCategoryManager | ||
66 | videoLanguageManager: PluginVideoLanguageManager | ||
67 | videoLicenceManager: PluginVideoLicenceManager | ||
68 | |||
69 | videoPrivacyManager: PluginVideoPrivacyManager | ||
70 | playlistPrivacyManager: PluginPlaylistPrivacyManager | ||
71 | |||
72 | registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void | ||
73 | registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult | ||
74 | unregisterIdAndPassAuth: (authName: string) => void | ||
75 | unregisterExternalAuth: (authName: string) => void | ||
76 | |||
77 | // Get plugin router to create custom routes | ||
78 | // Base routes of this router are | ||
79 | // * /plugins/:pluginName/:pluginVersion/router/... | ||
80 | // * /plugins/:pluginName/router/... | ||
81 | getRouter(): Router | ||
82 | |||
83 | peertubeHelpers: PeerTubeHelpers | ||
84 | } | ||
diff --git a/server/types/utils.ts b/server/types/utils.ts deleted file mode 100644 index 55500d8c4..000000000 --- a/server/types/utils.ts +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/array-type */ | ||
2 | |||
3 | export type FunctionPropertyNames<T> = { | ||
4 | [K in keyof T]: T[K] extends Function ? K : never | ||
5 | }[keyof T] | ||
6 | |||
7 | export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>> | ||
8 | |||
9 | export type PickWith<T, KT extends keyof T, V> = { | ||
10 | [P in KT]: T[P] extends V ? V : never | ||
11 | } | ||
12 | |||
13 | export 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! | ||
18 | export 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 | } | ||