diff options
author | Chocobozzz <me@florianbigard.com> | 2023-08-17 08:59:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-17 08:59:21 +0200 |
commit | c380e3928517eb5311b38cf257816642617d7a33 (patch) | |
tree | 2ea9b70ebca16b5d109bcce98fe7f944dad89319 /packages/models/src | |
parent | a8ca6190fb462bf6eb5685cfc1d8ae444164a487 (diff) | |
parent | 3a4992633ee62d5edfbb484d9c6bcb3cf158489d (diff) | |
download | PeerTube-c380e3928517eb5311b38cf257816642617d7a33.tar.gz PeerTube-c380e3928517eb5311b38cf257816642617d7a33.tar.zst PeerTube-c380e3928517eb5311b38cf257816642617d7a33.zip |
Merge branch 'feature/esm-and-nx' into develop
Diffstat (limited to 'packages/models/src')
266 files changed, 5527 insertions, 0 deletions
diff --git a/packages/models/src/activitypub/activity.ts b/packages/models/src/activitypub/activity.ts new file mode 100644 index 000000000..78a3ab33b --- /dev/null +++ b/packages/models/src/activitypub/activity.ts | |||
@@ -0,0 +1,135 @@ | |||
1 | import { ActivityPubActor } from './activitypub-actor.js' | ||
2 | import { ActivityPubSignature } from './activitypub-signature.js' | ||
3 | import { | ||
4 | ActivityFlagReasonObject, | ||
5 | ActivityObject, | ||
6 | APObjectId, | ||
7 | CacheFileObject, | ||
8 | PlaylistObject, | ||
9 | VideoCommentObject, | ||
10 | VideoObject, | ||
11 | WatchActionObject | ||
12 | } from './objects/index.js' | ||
13 | |||
14 | export type ActivityUpdateObject = | ||
15 | Extract<ActivityObject, VideoObject | CacheFileObject | PlaylistObject | ActivityPubActor | string> | ActivityPubActor | ||
16 | |||
17 | // Cannot Extract from Activity because of circular reference | ||
18 | export type ActivityUndoObject = | ||
19 | ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate<CacheFileObject | string> | ActivityAnnounce | ||
20 | |||
21 | export type ActivityCreateObject = | ||
22 | Extract<ActivityObject, VideoObject | CacheFileObject | WatchActionObject | VideoCommentObject | PlaylistObject | string> | ||
23 | |||
24 | export type Activity = | ||
25 | ActivityCreate<ActivityCreateObject> | | ||
26 | ActivityUpdate<ActivityUpdateObject> | | ||
27 | ActivityDelete | | ||
28 | ActivityFollow | | ||
29 | ActivityAccept | | ||
30 | ActivityAnnounce | | ||
31 | ActivityUndo<ActivityUndoObject> | | ||
32 | ActivityLike | | ||
33 | ActivityReject | | ||
34 | ActivityView | | ||
35 | ActivityDislike | | ||
36 | ActivityFlag | ||
37 | |||
38 | export type ActivityType = | ||
39 | 'Create' | | ||
40 | 'Update' | | ||
41 | 'Delete' | | ||
42 | 'Follow' | | ||
43 | 'Accept' | | ||
44 | 'Announce' | | ||
45 | 'Undo' | | ||
46 | 'Like' | | ||
47 | 'Reject' | | ||
48 | 'View' | | ||
49 | 'Dislike' | | ||
50 | 'Flag' | ||
51 | |||
52 | export interface ActivityAudience { | ||
53 | to: string[] | ||
54 | cc: string[] | ||
55 | } | ||
56 | |||
57 | export interface BaseActivity { | ||
58 | '@context'?: any[] | ||
59 | id: string | ||
60 | to?: string[] | ||
61 | cc?: string[] | ||
62 | actor: string | ActivityPubActor | ||
63 | type: ActivityType | ||
64 | signature?: ActivityPubSignature | ||
65 | } | ||
66 | |||
67 | export interface ActivityCreate <T extends ActivityCreateObject> extends BaseActivity { | ||
68 | type: 'Create' | ||
69 | object: T | ||
70 | } | ||
71 | |||
72 | export interface ActivityUpdate <T extends ActivityUpdateObject> extends BaseActivity { | ||
73 | type: 'Update' | ||
74 | object: T | ||
75 | } | ||
76 | |||
77 | export interface ActivityDelete extends BaseActivity { | ||
78 | type: 'Delete' | ||
79 | object: APObjectId | ||
80 | } | ||
81 | |||
82 | export interface ActivityFollow extends BaseActivity { | ||
83 | type: 'Follow' | ||
84 | object: string | ||
85 | } | ||
86 | |||
87 | export interface ActivityAccept extends BaseActivity { | ||
88 | type: 'Accept' | ||
89 | object: ActivityFollow | ||
90 | } | ||
91 | |||
92 | export interface ActivityReject extends BaseActivity { | ||
93 | type: 'Reject' | ||
94 | object: ActivityFollow | ||
95 | } | ||
96 | |||
97 | export interface ActivityAnnounce extends BaseActivity { | ||
98 | type: 'Announce' | ||
99 | object: APObjectId | ||
100 | } | ||
101 | |||
102 | export interface ActivityUndo <T extends ActivityUndoObject> extends BaseActivity { | ||
103 | type: 'Undo' | ||
104 | object: T | ||
105 | } | ||
106 | |||
107 | export interface ActivityLike extends BaseActivity { | ||
108 | type: 'Like' | ||
109 | object: APObjectId | ||
110 | } | ||
111 | |||
112 | export interface ActivityView extends BaseActivity { | ||
113 | type: 'View' | ||
114 | actor: string | ||
115 | object: APObjectId | ||
116 | |||
117 | // If sending a "viewer" event | ||
118 | expires?: string | ||
119 | } | ||
120 | |||
121 | export interface ActivityDislike extends BaseActivity { | ||
122 | id: string | ||
123 | type: 'Dislike' | ||
124 | actor: string | ||
125 | object: APObjectId | ||
126 | } | ||
127 | |||
128 | export interface ActivityFlag extends BaseActivity { | ||
129 | type: 'Flag' | ||
130 | content: string | ||
131 | object: APObjectId | APObjectId[] | ||
132 | tag?: ActivityFlagReasonObject[] | ||
133 | startAt?: number | ||
134 | endAt?: number | ||
135 | } | ||
diff --git a/packages/models/src/activitypub/activitypub-actor.ts b/packages/models/src/activitypub/activitypub-actor.ts new file mode 100644 index 000000000..85b37c5ad --- /dev/null +++ b/packages/models/src/activitypub/activitypub-actor.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import { ActivityIconObject, ActivityPubAttributedTo } from './objects/common-objects.js' | ||
2 | |||
3 | export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization' | ||
4 | |||
5 | export interface ActivityPubActor { | ||
6 | '@context': any[] | ||
7 | type: ActivityPubActorType | ||
8 | id: string | ||
9 | following: string | ||
10 | followers: string | ||
11 | playlists?: string | ||
12 | inbox: string | ||
13 | outbox: string | ||
14 | preferredUsername: string | ||
15 | url: string | ||
16 | name: string | ||
17 | endpoints: { | ||
18 | sharedInbox: string | ||
19 | } | ||
20 | summary: string | ||
21 | attributedTo: ActivityPubAttributedTo[] | ||
22 | |||
23 | support?: string | ||
24 | publicKey: { | ||
25 | id: string | ||
26 | owner: string | ||
27 | publicKeyPem: string | ||
28 | } | ||
29 | |||
30 | image?: ActivityIconObject | ActivityIconObject[] | ||
31 | icon?: ActivityIconObject | ActivityIconObject[] | ||
32 | |||
33 | published?: string | ||
34 | } | ||
diff --git a/packages/models/src/activitypub/activitypub-collection.ts b/packages/models/src/activitypub/activitypub-collection.ts new file mode 100644 index 000000000..b98ad37c2 --- /dev/null +++ b/packages/models/src/activitypub/activitypub-collection.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { Activity } from './activity.js' | ||
2 | |||
3 | export interface ActivityPubCollection { | ||
4 | '@context': string[] | ||
5 | type: 'Collection' | 'CollectionPage' | ||
6 | totalItems: number | ||
7 | partOf?: string | ||
8 | items: Activity[] | ||
9 | } | ||
diff --git a/packages/models/src/activitypub/activitypub-ordered-collection.ts b/packages/models/src/activitypub/activitypub-ordered-collection.ts new file mode 100644 index 000000000..3de0890bb --- /dev/null +++ b/packages/models/src/activitypub/activitypub-ordered-collection.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export interface ActivityPubOrderedCollection<T> { | ||
2 | '@context': string[] | ||
3 | type: 'OrderedCollection' | 'OrderedCollectionPage' | ||
4 | totalItems: number | ||
5 | orderedItems: T[] | ||
6 | |||
7 | partOf?: string | ||
8 | next?: string | ||
9 | first?: string | ||
10 | } | ||
diff --git a/packages/models/src/activitypub/activitypub-root.ts b/packages/models/src/activitypub/activitypub-root.ts new file mode 100644 index 000000000..2fa1970c7 --- /dev/null +++ b/packages/models/src/activitypub/activitypub-root.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { Activity } from './activity.js' | ||
2 | import { ActivityPubCollection } from './activitypub-collection.js' | ||
3 | import { ActivityPubOrderedCollection } from './activitypub-ordered-collection.js' | ||
4 | |||
5 | export type RootActivity = Activity | ActivityPubCollection | ActivityPubOrderedCollection<Activity> | ||
diff --git a/packages/models/src/activitypub/activitypub-signature.ts b/packages/models/src/activitypub/activitypub-signature.ts new file mode 100644 index 000000000..fafdc246d --- /dev/null +++ b/packages/models/src/activitypub/activitypub-signature.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface ActivityPubSignature { | ||
2 | type: string | ||
3 | created: Date | ||
4 | creator: string | ||
5 | signatureValue: string | ||
6 | } | ||
diff --git a/packages/models/src/activitypub/context.ts b/packages/models/src/activitypub/context.ts new file mode 100644 index 000000000..e9df38207 --- /dev/null +++ b/packages/models/src/activitypub/context.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | export type ContextType = | ||
2 | 'Video' | | ||
3 | 'Comment' | | ||
4 | 'Playlist' | | ||
5 | 'Follow' | | ||
6 | 'Reject' | | ||
7 | 'Accept' | | ||
8 | 'View' | | ||
9 | 'Announce' | | ||
10 | 'CacheFile' | | ||
11 | 'Delete' | | ||
12 | 'Rate' | | ||
13 | 'Flag' | | ||
14 | 'Actor' | | ||
15 | 'Collection' | | ||
16 | 'WatchAction' | ||
diff --git a/packages/models/src/activitypub/index.ts b/packages/models/src/activitypub/index.ts new file mode 100644 index 000000000..f36aa1bc5 --- /dev/null +++ b/packages/models/src/activitypub/index.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export * from './objects/index.js' | ||
2 | export * from './activity.js' | ||
3 | export * from './activitypub-actor.js' | ||
4 | export * from './activitypub-collection.js' | ||
5 | export * from './activitypub-ordered-collection.js' | ||
6 | export * from './activitypub-root.js' | ||
7 | export * from './activitypub-signature.js' | ||
8 | export * from './context.js' | ||
9 | export * from './webfinger.js' | ||
diff --git a/packages/models/src/activitypub/objects/abuse-object.ts b/packages/models/src/activitypub/objects/abuse-object.ts new file mode 100644 index 000000000..2c0f2832b --- /dev/null +++ b/packages/models/src/activitypub/objects/abuse-object.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { ActivityFlagReasonObject } from './common-objects.js' | ||
2 | |||
3 | export interface AbuseObject { | ||
4 | type: 'Flag' | ||
5 | |||
6 | content: string | ||
7 | mediaType: 'text/markdown' | ||
8 | |||
9 | object: string | string[] | ||
10 | |||
11 | tag?: ActivityFlagReasonObject[] | ||
12 | |||
13 | startAt?: number | ||
14 | endAt?: number | ||
15 | } | ||
diff --git a/packages/models/src/activitypub/objects/activitypub-object.ts b/packages/models/src/activitypub/objects/activitypub-object.ts new file mode 100644 index 000000000..93c925ae0 --- /dev/null +++ b/packages/models/src/activitypub/objects/activitypub-object.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { AbuseObject } from './abuse-object.js' | ||
2 | import { CacheFileObject } from './cache-file-object.js' | ||
3 | import { PlaylistObject } from './playlist-object.js' | ||
4 | import { VideoCommentObject } from './video-comment-object.js' | ||
5 | import { VideoObject } from './video-object.js' | ||
6 | import { WatchActionObject } from './watch-action-object.js' | ||
7 | |||
8 | export type ActivityObject = | ||
9 | VideoObject | | ||
10 | AbuseObject | | ||
11 | VideoCommentObject | | ||
12 | CacheFileObject | | ||
13 | PlaylistObject | | ||
14 | WatchActionObject | | ||
15 | string | ||
16 | |||
17 | export type APObjectId = string | { id: string } | ||
diff --git a/packages/models/src/activitypub/objects/cache-file-object.ts b/packages/models/src/activitypub/objects/cache-file-object.ts new file mode 100644 index 000000000..a40ef339c --- /dev/null +++ b/packages/models/src/activitypub/objects/cache-file-object.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-objects.js' | ||
2 | |||
3 | export interface CacheFileObject { | ||
4 | id: string | ||
5 | type: 'CacheFile' | ||
6 | object: string | ||
7 | expires: string | ||
8 | url: ActivityVideoUrlObject | ActivityPlaylistUrlObject | ||
9 | } | ||
diff --git a/packages/models/src/activitypub/objects/common-objects.ts b/packages/models/src/activitypub/objects/common-objects.ts new file mode 100644 index 000000000..a332c26f3 --- /dev/null +++ b/packages/models/src/activitypub/objects/common-objects.ts | |||
@@ -0,0 +1,130 @@ | |||
1 | import { AbusePredefinedReasonsString } from '../../moderation/abuse/abuse-reason.model.js' | ||
2 | |||
3 | export interface ActivityIdentifierObject { | ||
4 | identifier: string | ||
5 | name: string | ||
6 | url?: string | ||
7 | } | ||
8 | |||
9 | export interface ActivityIconObject { | ||
10 | type: 'Image' | ||
11 | url: string | ||
12 | mediaType: string | ||
13 | width?: number | ||
14 | height?: number | ||
15 | } | ||
16 | |||
17 | export type ActivityVideoUrlObject = { | ||
18 | type: 'Link' | ||
19 | mediaType: 'video/mp4' | 'video/webm' | 'video/ogg' | ||
20 | href: string | ||
21 | height: number | ||
22 | size: number | ||
23 | fps: number | ||
24 | } | ||
25 | |||
26 | export type ActivityPlaylistSegmentHashesObject = { | ||
27 | type: 'Link' | ||
28 | name: 'sha256' | ||
29 | mediaType: 'application/json' | ||
30 | href: string | ||
31 | } | ||
32 | |||
33 | export type ActivityVideoFileMetadataUrlObject = { | ||
34 | type: 'Link' | ||
35 | rel: [ 'metadata', any ] | ||
36 | mediaType: 'application/json' | ||
37 | height: number | ||
38 | href: string | ||
39 | fps: number | ||
40 | } | ||
41 | |||
42 | export type ActivityTrackerUrlObject = { | ||
43 | type: 'Link' | ||
44 | rel: [ 'tracker', 'websocket' | 'http' ] | ||
45 | name: string | ||
46 | href: string | ||
47 | } | ||
48 | |||
49 | export type ActivityStreamingPlaylistInfohashesObject = { | ||
50 | type: 'Infohash' | ||
51 | name: string | ||
52 | } | ||
53 | |||
54 | export type ActivityPlaylistUrlObject = { | ||
55 | type: 'Link' | ||
56 | mediaType: 'application/x-mpegURL' | ||
57 | href: string | ||
58 | tag?: ActivityTagObject[] | ||
59 | } | ||
60 | |||
61 | export type ActivityBitTorrentUrlObject = { | ||
62 | type: 'Link' | ||
63 | mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' | ||
64 | href: string | ||
65 | height: number | ||
66 | } | ||
67 | |||
68 | export type ActivityMagnetUrlObject = { | ||
69 | type: 'Link' | ||
70 | mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' | ||
71 | href: string | ||
72 | height: number | ||
73 | } | ||
74 | |||
75 | export type ActivityHtmlUrlObject = { | ||
76 | type: 'Link' | ||
77 | mediaType: 'text/html' | ||
78 | href: string | ||
79 | } | ||
80 | |||
81 | export interface ActivityHashTagObject { | ||
82 | type: 'Hashtag' | ||
83 | href?: string | ||
84 | name: string | ||
85 | } | ||
86 | |||
87 | export interface ActivityMentionObject { | ||
88 | type: 'Mention' | ||
89 | href?: string | ||
90 | name: string | ||
91 | } | ||
92 | |||
93 | export interface ActivityFlagReasonObject { | ||
94 | type: 'Hashtag' | ||
95 | name: AbusePredefinedReasonsString | ||
96 | } | ||
97 | |||
98 | export type ActivityTagObject = | ||
99 | ActivityPlaylistSegmentHashesObject | ||
100 | | ActivityStreamingPlaylistInfohashesObject | ||
101 | | ActivityVideoUrlObject | ||
102 | | ActivityHashTagObject | ||
103 | | ActivityMentionObject | ||
104 | | ActivityBitTorrentUrlObject | ||
105 | | ActivityMagnetUrlObject | ||
106 | | ActivityVideoFileMetadataUrlObject | ||
107 | |||
108 | export type ActivityUrlObject = | ||
109 | ActivityVideoUrlObject | ||
110 | | ActivityPlaylistUrlObject | ||
111 | | ActivityBitTorrentUrlObject | ||
112 | | ActivityMagnetUrlObject | ||
113 | | ActivityHtmlUrlObject | ||
114 | | ActivityVideoFileMetadataUrlObject | ||
115 | | ActivityTrackerUrlObject | ||
116 | |||
117 | export type ActivityPubAttributedTo = { type: 'Group' | 'Person', id: string } | string | ||
118 | |||
119 | export interface ActivityTombstoneObject { | ||
120 | '@context'?: any | ||
121 | id: string | ||
122 | url?: string | ||
123 | type: 'Tombstone' | ||
124 | name?: string | ||
125 | formerType?: string | ||
126 | inReplyTo?: string | ||
127 | published: string | ||
128 | updated: string | ||
129 | deleted: string | ||
130 | } | ||
diff --git a/packages/models/src/activitypub/objects/index.ts b/packages/models/src/activitypub/objects/index.ts new file mode 100644 index 000000000..510f621ea --- /dev/null +++ b/packages/models/src/activitypub/objects/index.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export * from './abuse-object.js' | ||
2 | export * from './activitypub-object.js' | ||
3 | export * from './cache-file-object.js' | ||
4 | export * from './common-objects.js' | ||
5 | export * from './playlist-element-object.js' | ||
6 | export * from './playlist-object.js' | ||
7 | export * from './video-comment-object.js' | ||
8 | export * from './video-object.js' | ||
9 | export * from './watch-action-object.js' | ||
diff --git a/packages/models/src/activitypub/objects/playlist-element-object.ts b/packages/models/src/activitypub/objects/playlist-element-object.ts new file mode 100644 index 000000000..b85e4fe19 --- /dev/null +++ b/packages/models/src/activitypub/objects/playlist-element-object.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export interface PlaylistElementObject { | ||
2 | id: string | ||
3 | type: 'PlaylistElement' | ||
4 | |||
5 | url: string | ||
6 | position: number | ||
7 | |||
8 | startTimestamp?: number | ||
9 | stopTimestamp?: number | ||
10 | } | ||
diff --git a/packages/models/src/activitypub/objects/playlist-object.ts b/packages/models/src/activitypub/objects/playlist-object.ts new file mode 100644 index 000000000..c68a28780 --- /dev/null +++ b/packages/models/src/activitypub/objects/playlist-object.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { ActivityIconObject, ActivityPubAttributedTo } from './common-objects.js' | ||
2 | |||
3 | export interface PlaylistObject { | ||
4 | id: string | ||
5 | type: 'Playlist' | ||
6 | |||
7 | name: string | ||
8 | |||
9 | content: string | ||
10 | mediaType: 'text/markdown' | ||
11 | |||
12 | uuid: string | ||
13 | |||
14 | totalItems: number | ||
15 | attributedTo: ActivityPubAttributedTo[] | ||
16 | |||
17 | icon?: ActivityIconObject | ||
18 | |||
19 | published: string | ||
20 | updated: string | ||
21 | |||
22 | orderedItems?: string[] | ||
23 | |||
24 | partOf?: string | ||
25 | next?: string | ||
26 | first?: string | ||
27 | |||
28 | to?: string[] | ||
29 | } | ||
diff --git a/packages/models/src/activitypub/objects/video-comment-object.ts b/packages/models/src/activitypub/objects/video-comment-object.ts new file mode 100644 index 000000000..880dd2ee2 --- /dev/null +++ b/packages/models/src/activitypub/objects/video-comment-object.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | import { ActivityPubAttributedTo, ActivityTagObject } from './common-objects.js' | ||
2 | |||
3 | export interface VideoCommentObject { | ||
4 | type: 'Note' | ||
5 | id: string | ||
6 | |||
7 | content: string | ||
8 | mediaType: 'text/markdown' | ||
9 | |||
10 | inReplyTo: string | ||
11 | published: string | ||
12 | updated: string | ||
13 | url: string | ||
14 | attributedTo: ActivityPubAttributedTo | ||
15 | tag: ActivityTagObject[] | ||
16 | } | ||
diff --git a/packages/models/src/activitypub/objects/video-object.ts b/packages/models/src/activitypub/objects/video-object.ts new file mode 100644 index 000000000..14afd85a2 --- /dev/null +++ b/packages/models/src/activitypub/objects/video-object.ts | |||
@@ -0,0 +1,74 @@ | |||
1 | import { LiveVideoLatencyModeType, VideoStateType } from '../../videos/index.js' | ||
2 | import { | ||
3 | ActivityIconObject, | ||
4 | ActivityIdentifierObject, | ||
5 | ActivityPubAttributedTo, | ||
6 | ActivityTagObject, | ||
7 | ActivityUrlObject | ||
8 | } from './common-objects.js' | ||
9 | |||
10 | export interface VideoObject { | ||
11 | type: 'Video' | ||
12 | id: string | ||
13 | name: string | ||
14 | duration: string | ||
15 | uuid: string | ||
16 | tag: ActivityTagObject[] | ||
17 | category: ActivityIdentifierObject | ||
18 | licence: ActivityIdentifierObject | ||
19 | language: ActivityIdentifierObject | ||
20 | subtitleLanguage: ActivityIdentifierObject[] | ||
21 | views: number | ||
22 | |||
23 | sensitive: boolean | ||
24 | |||
25 | isLiveBroadcast: boolean | ||
26 | liveSaveReplay: boolean | ||
27 | permanentLive: boolean | ||
28 | latencyMode: LiveVideoLatencyModeType | ||
29 | |||
30 | commentsEnabled: boolean | ||
31 | downloadEnabled: boolean | ||
32 | waitTranscoding: boolean | ||
33 | state: VideoStateType | ||
34 | |||
35 | published: string | ||
36 | originallyPublishedAt: string | ||
37 | updated: string | ||
38 | uploadDate: string | ||
39 | |||
40 | mediaType: 'text/markdown' | ||
41 | content: string | ||
42 | |||
43 | support: string | ||
44 | |||
45 | icon: ActivityIconObject[] | ||
46 | |||
47 | url: ActivityUrlObject[] | ||
48 | |||
49 | likes: string | ||
50 | dislikes: string | ||
51 | shares: string | ||
52 | comments: string | ||
53 | |||
54 | attributedTo: ActivityPubAttributedTo[] | ||
55 | |||
56 | preview?: ActivityPubStoryboard[] | ||
57 | |||
58 | to?: string[] | ||
59 | cc?: string[] | ||
60 | } | ||
61 | |||
62 | export interface ActivityPubStoryboard { | ||
63 | type: 'Image' | ||
64 | rel: [ 'storyboard' ] | ||
65 | url: { | ||
66 | href: string | ||
67 | mediaType: string | ||
68 | width: number | ||
69 | height: number | ||
70 | tileWidth: number | ||
71 | tileHeight: number | ||
72 | tileDuration: string | ||
73 | }[] | ||
74 | } | ||
diff --git a/packages/models/src/activitypub/objects/watch-action-object.ts b/packages/models/src/activitypub/objects/watch-action-object.ts new file mode 100644 index 000000000..ed336602f --- /dev/null +++ b/packages/models/src/activitypub/objects/watch-action-object.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | export interface WatchActionObject { | ||
2 | id: string | ||
3 | type: 'WatchAction' | ||
4 | |||
5 | startTime: string | ||
6 | endTime: string | ||
7 | |||
8 | location?: { | ||
9 | addressCountry: string | ||
10 | } | ||
11 | |||
12 | uuid: string | ||
13 | object: string | ||
14 | actionStatus: 'CompletedActionStatus' | ||
15 | |||
16 | duration: string | ||
17 | |||
18 | watchSections: { | ||
19 | startTimestamp: number | ||
20 | endTimestamp: number | ||
21 | }[] | ||
22 | } | ||
diff --git a/packages/models/src/activitypub/webfinger.ts b/packages/models/src/activitypub/webfinger.ts new file mode 100644 index 000000000..b94baf996 --- /dev/null +++ b/packages/models/src/activitypub/webfinger.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export interface WebFingerData { | ||
2 | subject: string | ||
3 | aliases: string[] | ||
4 | links: { | ||
5 | rel: 'self' | ||
6 | type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' | ||
7 | href: string | ||
8 | }[] | ||
9 | } | ||
diff --git a/packages/models/src/actors/account.model.ts b/packages/models/src/actors/account.model.ts new file mode 100644 index 000000000..370a273cf --- /dev/null +++ b/packages/models/src/actors/account.model.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { ActorImage } from './actor-image.model.js' | ||
2 | import { Actor } from './actor.model.js' | ||
3 | |||
4 | export interface Account extends Actor { | ||
5 | displayName: string | ||
6 | description: string | ||
7 | avatars: ActorImage[] | ||
8 | |||
9 | updatedAt: Date | string | ||
10 | |||
11 | userId?: number | ||
12 | } | ||
13 | |||
14 | export interface AccountSummary { | ||
15 | id: number | ||
16 | name: string | ||
17 | displayName: string | ||
18 | url: string | ||
19 | host: string | ||
20 | |||
21 | avatars: ActorImage[] | ||
22 | } | ||
diff --git a/packages/models/src/actors/actor-image.model.ts b/packages/models/src/actors/actor-image.model.ts new file mode 100644 index 000000000..cfe44ac15 --- /dev/null +++ b/packages/models/src/actors/actor-image.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export interface ActorImage { | ||
2 | width: number | ||
3 | path: string | ||
4 | |||
5 | url?: string | ||
6 | |||
7 | createdAt: Date | string | ||
8 | updatedAt: Date | string | ||
9 | } | ||
diff --git a/packages/models/src/actors/actor-image.type.ts b/packages/models/src/actors/actor-image.type.ts new file mode 100644 index 000000000..3a808b110 --- /dev/null +++ b/packages/models/src/actors/actor-image.type.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export const ActorImageType = { | ||
2 | AVATAR: 1, | ||
3 | BANNER: 2 | ||
4 | } as const | ||
5 | |||
6 | export type ActorImageType_Type = typeof ActorImageType[keyof typeof ActorImageType] | ||
diff --git a/packages/models/src/actors/actor.model.ts b/packages/models/src/actors/actor.model.ts new file mode 100644 index 000000000..d18053b4b --- /dev/null +++ b/packages/models/src/actors/actor.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { ActorImage } from './actor-image.model.js' | ||
2 | |||
3 | export interface Actor { | ||
4 | id: number | ||
5 | url: string | ||
6 | name: string | ||
7 | host: string | ||
8 | followingCount: number | ||
9 | followersCount: number | ||
10 | createdAt: Date | string | ||
11 | |||
12 | avatars: ActorImage[] | ||
13 | } | ||
diff --git a/packages/models/src/actors/custom-page.model.ts b/packages/models/src/actors/custom-page.model.ts new file mode 100644 index 000000000..1e33584c1 --- /dev/null +++ b/packages/models/src/actors/custom-page.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface CustomPage { | ||
2 | content: string | ||
3 | } | ||
diff --git a/packages/models/src/actors/follow.model.ts b/packages/models/src/actors/follow.model.ts new file mode 100644 index 000000000..7f3f52ac5 --- /dev/null +++ b/packages/models/src/actors/follow.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { Actor } from './actor.model.js' | ||
2 | |||
3 | export type FollowState = 'pending' | 'accepted' | 'rejected' | ||
4 | |||
5 | export interface ActorFollow { | ||
6 | id: number | ||
7 | follower: Actor & { hostRedundancyAllowed: boolean } | ||
8 | following: Actor & { hostRedundancyAllowed: boolean } | ||
9 | score: number | ||
10 | state: FollowState | ||
11 | createdAt: Date | ||
12 | updatedAt: Date | ||
13 | } | ||
diff --git a/packages/models/src/actors/index.ts b/packages/models/src/actors/index.ts new file mode 100644 index 000000000..c44063c81 --- /dev/null +++ b/packages/models/src/actors/index.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export * from './account.model.js' | ||
2 | export * from './actor-image.model.js' | ||
3 | export * from './actor-image.type.js' | ||
4 | export * from './actor.model.js' | ||
5 | export * from './custom-page.model.js' | ||
6 | export * from './follow.model.js' | ||
diff --git a/packages/models/src/bulk/bulk-remove-comments-of-body.model.ts b/packages/models/src/bulk/bulk-remove-comments-of-body.model.ts new file mode 100644 index 000000000..31e018c2a --- /dev/null +++ b/packages/models/src/bulk/bulk-remove-comments-of-body.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface BulkRemoveCommentsOfBody { | ||
2 | accountName: string | ||
3 | scope: 'my-videos' | 'instance' | ||
4 | } | ||
diff --git a/packages/models/src/bulk/index.ts b/packages/models/src/bulk/index.ts new file mode 100644 index 000000000..3597fda36 --- /dev/null +++ b/packages/models/src/bulk/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './bulk-remove-comments-of-body.model.js' | |||
diff --git a/packages/models/src/common/index.ts b/packages/models/src/common/index.ts new file mode 100644 index 000000000..957851ae4 --- /dev/null +++ b/packages/models/src/common/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './result-list.model.js' | |||
diff --git a/packages/models/src/common/result-list.model.ts b/packages/models/src/common/result-list.model.ts new file mode 100644 index 000000000..fcafcfb2f --- /dev/null +++ b/packages/models/src/common/result-list.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export interface ResultList<T> { | ||
2 | total: number | ||
3 | data: T[] | ||
4 | } | ||
5 | |||
6 | export interface ThreadsResultList <T> extends ResultList <T> { | ||
7 | totalNotDeletedComments: number | ||
8 | } | ||
diff --git a/packages/models/src/custom-markup/custom-markup-data.model.ts b/packages/models/src/custom-markup/custom-markup-data.model.ts new file mode 100644 index 000000000..3e396052a --- /dev/null +++ b/packages/models/src/custom-markup/custom-markup-data.model.ts | |||
@@ -0,0 +1,58 @@ | |||
1 | export type EmbedMarkupData = { | ||
2 | // Video or playlist uuid | ||
3 | uuid: string | ||
4 | } | ||
5 | |||
6 | export type VideoMiniatureMarkupData = { | ||
7 | // Video uuid | ||
8 | uuid: string | ||
9 | |||
10 | onlyDisplayTitle?: string // boolean | ||
11 | } | ||
12 | |||
13 | export type PlaylistMiniatureMarkupData = { | ||
14 | // Playlist uuid | ||
15 | uuid: string | ||
16 | } | ||
17 | |||
18 | export type ChannelMiniatureMarkupData = { | ||
19 | // Channel name (username) | ||
20 | name: string | ||
21 | |||
22 | displayLatestVideo?: string // boolean | ||
23 | displayDescription?: string // boolean | ||
24 | } | ||
25 | |||
26 | export type VideosListMarkupData = { | ||
27 | onlyDisplayTitle?: string // boolean | ||
28 | maxRows?: string // number | ||
29 | |||
30 | sort?: string | ||
31 | count?: string // number | ||
32 | |||
33 | categoryOneOf?: string // coma separated values, number[] | ||
34 | languageOneOf?: string // coma separated values | ||
35 | |||
36 | channelHandle?: string | ||
37 | accountHandle?: string | ||
38 | |||
39 | isLive?: string // number | ||
40 | |||
41 | onlyLocal?: string // boolean | ||
42 | } | ||
43 | |||
44 | export type ButtonMarkupData = { | ||
45 | theme: 'primary' | 'secondary' | ||
46 | href: string | ||
47 | label: string | ||
48 | blankTarget?: string // boolean | ||
49 | } | ||
50 | |||
51 | export type ContainerMarkupData = { | ||
52 | width?: string | ||
53 | title?: string | ||
54 | description?: string | ||
55 | layout?: 'row' | 'column' | ||
56 | |||
57 | justifyContent?: 'space-between' | 'normal' // default to 'space-between' | ||
58 | } | ||
diff --git a/packages/models/src/custom-markup/index.ts b/packages/models/src/custom-markup/index.ts new file mode 100644 index 000000000..1ce10d8e2 --- /dev/null +++ b/packages/models/src/custom-markup/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './custom-markup-data.model.js' | |||
diff --git a/packages/models/src/feeds/feed-format.enum.ts b/packages/models/src/feeds/feed-format.enum.ts new file mode 100644 index 000000000..71f2f6c15 --- /dev/null +++ b/packages/models/src/feeds/feed-format.enum.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const FeedFormat = { | ||
2 | RSS: 'xml', | ||
3 | ATOM: 'atom', | ||
4 | JSON: 'json' | ||
5 | } as const | ||
6 | |||
7 | export type FeedFormatType = typeof FeedFormat[keyof typeof FeedFormat] | ||
diff --git a/packages/models/src/feeds/index.ts b/packages/models/src/feeds/index.ts new file mode 100644 index 000000000..1eda1d6c3 --- /dev/null +++ b/packages/models/src/feeds/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './feed-format.enum.js' | |||
diff --git a/packages/models/src/http/http-methods.ts b/packages/models/src/http/http-methods.ts new file mode 100644 index 000000000..ec3c855d8 --- /dev/null +++ b/packages/models/src/http/http-methods.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | /** HTTP request method to indicate the desired action to be performed for a given resource. */ | ||
2 | export const HttpMethod = { | ||
3 | /** The CONNECT method establishes a tunnel to the server identified by the target resource. */ | ||
4 | CONNECT: 'CONNECT', | ||
5 | /** The DELETE method deletes the specified resource. */ | ||
6 | DELETE: 'DELETE', | ||
7 | /** The GET method requests a representation of the specified resource. Requests using GET should only retrieve data. */ | ||
8 | GET: 'GET', | ||
9 | /** The HEAD method asks for a response identical to that of a GET request, but without the response body. */ | ||
10 | HEAD: 'HEAD', | ||
11 | /** The OPTIONS method is used to describe the communication options for the target resource. */ | ||
12 | OPTIONS: 'OPTIONS', | ||
13 | /** The PATCH method is used to apply partial modifications to a resource. */ | ||
14 | PATCH: 'PATCH', | ||
15 | /** The POST method is used to submit an entity to the specified resource */ | ||
16 | POST: 'POST', | ||
17 | /** The PUT method replaces all current representations of the target resource with the request payload. */ | ||
18 | PUT: 'PUT', | ||
19 | /** The TRACE method performs a message loop-back test along the path to the target resource. */ | ||
20 | TRACE: 'TRACE' | ||
21 | } as const | ||
22 | |||
23 | export type HttpMethodType = typeof HttpMethod[keyof typeof HttpMethod] | ||
diff --git a/packages/models/src/http/http-status-codes.ts b/packages/models/src/http/http-status-codes.ts new file mode 100644 index 000000000..920b9a2e9 --- /dev/null +++ b/packages/models/src/http/http-status-codes.ts | |||
@@ -0,0 +1,366 @@ | |||
1 | /** | ||
2 | * Hypertext Transfer Protocol (HTTP) response status codes. | ||
3 | * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes} | ||
4 | * | ||
5 | * WebDAV and other codes useless with regards to PeerTube are not listed. | ||
6 | */ | ||
7 | export const HttpStatusCode = { | ||
8 | |||
9 | /** | ||
10 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.1 | ||
11 | * | ||
12 | * The server has received the request headers and the client should proceed to send the request body | ||
13 | * (in the case of a request for which a body needs to be sent; for example, a POST request). | ||
14 | * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient. | ||
15 | * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request | ||
16 | * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates | ||
17 | * the request should not be continued. | ||
18 | */ | ||
19 | CONTINUE_100: 100, | ||
20 | |||
21 | /** | ||
22 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.2 | ||
23 | * | ||
24 | * This code is sent in response to an Upgrade request header by the client, and indicates the protocol the server is switching too. | ||
25 | */ | ||
26 | SWITCHING_PROTOCOLS_101: 101, | ||
27 | |||
28 | /** | ||
29 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.1 | ||
30 | * | ||
31 | * Standard response for successful HTTP requests. The actual response will depend on the request method used: | ||
32 | * GET: The resource has been fetched and is transmitted in the message body. | ||
33 | * HEAD: The entity headers are in the message body. | ||
34 | * POST: The resource describing the result of the action is transmitted in the message body. | ||
35 | * TRACE: The message body contains the request message as received by the server | ||
36 | */ | ||
37 | OK_200: 200, | ||
38 | |||
39 | /** | ||
40 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.2 | ||
41 | * | ||
42 | * The request has been fulfilled, resulting in the creation of a new resource, typically after a PUT. | ||
43 | */ | ||
44 | CREATED_201: 201, | ||
45 | |||
46 | /** | ||
47 | * The request has been accepted for processing, but the processing has not been completed. | ||
48 | * The request might or might not be eventually acted upon, and may be disallowed when processing occurs. | ||
49 | */ | ||
50 | ACCEPTED_202: 202, | ||
51 | |||
52 | /** | ||
53 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.5 | ||
54 | * | ||
55 | * There is no content to send for this request, but the headers may be useful. | ||
56 | * The user-agent may update its cached headers for this resource with the new ones. | ||
57 | */ | ||
58 | NO_CONTENT_204: 204, | ||
59 | |||
60 | /** | ||
61 | * The server successfully processed the request, but is not returning any content. | ||
62 | * Unlike a 204 response, this response requires that the requester reset the document view. | ||
63 | */ | ||
64 | RESET_CONTENT_205: 205, | ||
65 | |||
66 | /** | ||
67 | * The server is delivering only part of the resource (byte serving) due to a range header sent by the client. | ||
68 | * The range header is used by HTTP clients to enable resuming of interrupted downloads, | ||
69 | * or split a download into multiple simultaneous streams. | ||
70 | */ | ||
71 | PARTIAL_CONTENT_206: 206, | ||
72 | |||
73 | /** | ||
74 | * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation). | ||
75 | * For example, this code could be used to present multiple video format options, | ||
76 | * to list files with different filename extensions, or to suggest word-sense disambiguation. | ||
77 | */ | ||
78 | MULTIPLE_CHOICES_300: 300, | ||
79 | |||
80 | /** | ||
81 | * This and all future requests should be directed to the given URI. | ||
82 | */ | ||
83 | MOVED_PERMANENTLY_301: 301, | ||
84 | |||
85 | /** | ||
86 | * This is an example of industry practice contradicting the standard. | ||
87 | * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect | ||
88 | * (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302 | ||
89 | * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307 | ||
90 | * to distinguish between the two behaviours. However, some Web applications and frameworks | ||
91 | * use the 302 status code as if it were the 303. | ||
92 | */ | ||
93 | FOUND_302: 302, | ||
94 | |||
95 | /** | ||
96 | * SINCE HTTP/1.1 | ||
97 | * The response to the request can be found under another URI using a GET method. | ||
98 | * When received in response to a POST (or PUT/DELETE), the client should presume that | ||
99 | * the server has received the data and should issue a redirect with a separate GET message. | ||
100 | */ | ||
101 | SEE_OTHER_303: 303, | ||
102 | |||
103 | /** | ||
104 | * Official Documentation @ https://tools.ietf.org/html/rfc7232#section-4.1 | ||
105 | * | ||
106 | * Indicates that the resource has not been modified since the version specified by the request headers | ||
107 | * `If-Modified-Since` or `If-None-Match`. | ||
108 | * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy. | ||
109 | */ | ||
110 | NOT_MODIFIED_304: 304, | ||
111 | |||
112 | /** | ||
113 | * SINCE HTTP/1.1 | ||
114 | * In this case, the request should be repeated with another URI; however, future requests should still use the original URI. | ||
115 | * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the | ||
116 | * original request. | ||
117 | * For example, a POST request should be repeated using another POST request. | ||
118 | */ | ||
119 | TEMPORARY_REDIRECT_307: 307, | ||
120 | |||
121 | /** | ||
122 | * The request and all future requests should be repeated using another URI. | ||
123 | * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change. | ||
124 | * So, for example, submitting a form to a permanently redirected resource may continue smoothly. | ||
125 | */ | ||
126 | PERMANENT_REDIRECT_308: 308, | ||
127 | |||
128 | /** | ||
129 | * The server cannot or will not process the request due to an apparent client error | ||
130 | * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing). | ||
131 | */ | ||
132 | BAD_REQUEST_400: 400, | ||
133 | |||
134 | /** | ||
135 | * Official Documentation @ https://tools.ietf.org/html/rfc7235#section-3.1 | ||
136 | * | ||
137 | * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet | ||
138 | * been provided. The response must include a `WWW-Authenticate` header field containing a challenge applicable to the | ||
139 | * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means | ||
140 | * "unauthenticated",i.e. the user does not have the necessary credentials. | ||
141 | */ | ||
142 | UNAUTHORIZED_401: 401, | ||
143 | |||
144 | /** | ||
145 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.2 | ||
146 | * | ||
147 | * Reserved for future use. The original intention was that this code might be used as part of some form of digital | ||
148 | * cash or micro payment scheme, but that has not happened, and this code is not usually used. | ||
149 | * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests. | ||
150 | */ | ||
151 | PAYMENT_REQUIRED_402: 402, | ||
152 | |||
153 | /** | ||
154 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.3 | ||
155 | * | ||
156 | * The client does not have access rights to the content, i.e. they are unauthorized, so server is rejecting to | ||
157 | * give proper response. Unlike 401, the client's identity is known to the server. | ||
158 | */ | ||
159 | FORBIDDEN_403: 403, | ||
160 | |||
161 | /** | ||
162 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.2 | ||
163 | * | ||
164 | * The requested resource could not be found but may be available in the future. | ||
165 | * Subsequent requests by the client are permissible. | ||
166 | */ | ||
167 | NOT_FOUND_404: 404, | ||
168 | |||
169 | /** | ||
170 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.5 | ||
171 | * | ||
172 | * A request method is not supported for the requested resource; | ||
173 | * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource. | ||
174 | */ | ||
175 | METHOD_NOT_ALLOWED_405: 405, | ||
176 | |||
177 | /** | ||
178 | * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request. | ||
179 | */ | ||
180 | NOT_ACCEPTABLE_406: 406, | ||
181 | |||
182 | /** | ||
183 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.7 | ||
184 | * | ||
185 | * This response is sent on an idle connection by some servers, even without any previous request by the client. | ||
186 | * It means that the server would like to shut down this unused connection. This response is used much more since | ||
187 | * some browsers, like Chrome, Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing. Also | ||
188 | * note that some servers merely shut down the connection without sending this message. | ||
189 | * | ||
190 | * @ | ||
191 | */ | ||
192 | REQUEST_TIMEOUT_408: 408, | ||
193 | |||
194 | /** | ||
195 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.8 | ||
196 | * | ||
197 | * Indicates that the request could not be processed because of conflict in the request, | ||
198 | * such as an edit conflict between multiple simultaneous updates. | ||
199 | * | ||
200 | * @see HttpStatusCode.UNPROCESSABLE_ENTITY_422 to denote a disabled feature | ||
201 | */ | ||
202 | CONFLICT_409: 409, | ||
203 | |||
204 | /** | ||
205 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.9 | ||
206 | * | ||
207 | * Indicates that the resource requested is no longer available and will not be available again. | ||
208 | * This should be used when a resource has been intentionally removed and the resource should be purged. | ||
209 | * Upon receiving a 410 status code, the client should not request the resource in the future. | ||
210 | * Clients such as search engines should remove the resource from their indices. | ||
211 | * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead. | ||
212 | */ | ||
213 | GONE_410: 410, | ||
214 | |||
215 | /** | ||
216 | * The request did not specify the length of its content, which is required by the requested resource. | ||
217 | */ | ||
218 | LENGTH_REQUIRED_411: 411, | ||
219 | |||
220 | /** | ||
221 | * The server does not meet one of the preconditions that the requester put on the request. | ||
222 | */ | ||
223 | PRECONDITION_FAILED_412: 412, | ||
224 | |||
225 | /** | ||
226 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.11 | ||
227 | * | ||
228 | * The request is larger than the server is willing or able to process ; the server might close the connection | ||
229 | * or return an Retry-After header field. | ||
230 | * Previously called "Request Entity Too Large". | ||
231 | */ | ||
232 | PAYLOAD_TOO_LARGE_413: 413, | ||
233 | |||
234 | /** | ||
235 | * The URI provided was too long for the server to process. Often the result of too much data being encoded as a | ||
236 | * query-string of a GET request, in which case it should be converted to a POST request. | ||
237 | * Called "Request-URI Too Long" previously. | ||
238 | */ | ||
239 | URI_TOO_LONG_414: 414, | ||
240 | |||
241 | /** | ||
242 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.13 | ||
243 | * | ||
244 | * The request entity has a media type which the server or resource does not support. | ||
245 | * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format. | ||
246 | */ | ||
247 | UNSUPPORTED_MEDIA_TYPE_415: 415, | ||
248 | |||
249 | /** | ||
250 | * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion. | ||
251 | * For example, if the client asked for a part of the file that lies beyond the end of the file. | ||
252 | * Called "Requested Range Not Satisfiable" previously. | ||
253 | */ | ||
254 | RANGE_NOT_SATISFIABLE_416: 416, | ||
255 | |||
256 | /** | ||
257 | * The server cannot meet the requirements of the `Expect` request-header field. | ||
258 | */ | ||
259 | EXPECTATION_FAILED_417: 417, | ||
260 | |||
261 | /** | ||
262 | * Official Documentation @ https://tools.ietf.org/html/rfc2324 | ||
263 | * | ||
264 | * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, | ||
265 | * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by | ||
266 | * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including PeerTube instances ;-). | ||
267 | */ | ||
268 | I_AM_A_TEAPOT_418: 418, | ||
269 | |||
270 | /** | ||
271 | * Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.3 | ||
272 | * | ||
273 | * The request was well-formed but was unable to be followed due to semantic errors. | ||
274 | * The server understands the content type of the request entity (hence a 415 (Unsupported Media Type) status code is inappropriate), | ||
275 | * and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process | ||
276 | * the contained instructions. For example, this error condition may occur if an JSON request body contains well-formed (i.e., | ||
277 | * syntactically correct), but semantically erroneous, JSON instructions. | ||
278 | * | ||
279 | * Can also be used to denote disabled features (akin to disabled syntax). | ||
280 | * | ||
281 | * @see HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 if the `Content-Type` was not supported. | ||
282 | * @see HttpStatusCode.BAD_REQUEST_400 if the request was not parsable (broken JSON, XML) | ||
283 | */ | ||
284 | UNPROCESSABLE_ENTITY_422: 422, | ||
285 | |||
286 | /** | ||
287 | * Official Documentation @ https://tools.ietf.org/html/rfc4918#section-11.3 | ||
288 | * | ||
289 | * The resource that is being accessed is locked. WebDAV-specific but used by some HTTP services. | ||
290 | * | ||
291 | * @deprecated use `If-Match` / `If-None-Match` instead | ||
292 | * @see {@link https://evertpot.com/http/423-locked} | ||
293 | */ | ||
294 | LOCKED_423: 423, | ||
295 | |||
296 | /** | ||
297 | * Official Documentation @ https://tools.ietf.org/html/rfc6585#section-4 | ||
298 | * | ||
299 | * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes. | ||
300 | */ | ||
301 | TOO_MANY_REQUESTS_429: 429, | ||
302 | |||
303 | /** | ||
304 | * Official Documentation @ https://tools.ietf.org/html/rfc6585#section-5 | ||
305 | * | ||
306 | * The server is unwilling to process the request because either an individual header field, | ||
307 | * or all the header fields collectively, are too large. | ||
308 | */ | ||
309 | REQUEST_HEADER_FIELDS_TOO_LARGE_431: 431, | ||
310 | |||
311 | /** | ||
312 | * Official Documentation @ https://tools.ietf.org/html/rfc7725 | ||
313 | * | ||
314 | * A server operator has received a legal demand to deny access to a resource or to a set of resources | ||
315 | * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451. | ||
316 | */ | ||
317 | UNAVAILABLE_FOR_LEGAL_REASONS_451: 451, | ||
318 | |||
319 | /** | ||
320 | * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable. | ||
321 | */ | ||
322 | INTERNAL_SERVER_ERROR_500: 500, | ||
323 | |||
324 | /** | ||
325 | * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.2 | ||
326 | * | ||
327 | * The server either does not recognize the request method, or it lacks the ability to fulfill the request. | ||
328 | * Usually this implies future availability (e.g., a new feature of a web-service API). | ||
329 | */ | ||
330 | NOT_IMPLEMENTED_501: 501, | ||
331 | |||
332 | /** | ||
333 | * The server was acting as a gateway or proxy and received an invalid response from the upstream server. | ||
334 | */ | ||
335 | BAD_GATEWAY_502: 502, | ||
336 | |||
337 | /** | ||
338 | * The server is currently unavailable (because it is overloaded or down for maintenance). | ||
339 | * Generally, this is a temporary state. | ||
340 | */ | ||
341 | SERVICE_UNAVAILABLE_503: 503, | ||
342 | |||
343 | /** | ||
344 | * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server. | ||
345 | */ | ||
346 | GATEWAY_TIMEOUT_504: 504, | ||
347 | |||
348 | /** | ||
349 | * The server does not support the HTTP protocol version used in the request | ||
350 | */ | ||
351 | HTTP_VERSION_NOT_SUPPORTED_505: 505, | ||
352 | |||
353 | /** | ||
354 | * Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.6 | ||
355 | * | ||
356 | * The 507 (Insufficient Storage) status code means the method could not be performed on the resource because the | ||
357 | * server is unable to store the representation needed to successfully complete the request. This condition is | ||
358 | * considered to be temporary. If the request which received this status code was the result of a user action, | ||
359 | * the request MUST NOT be repeated until it is requested by a separate user action. | ||
360 | * | ||
361 | * @see HttpStatusCode.PAYLOAD_TOO_LARGE_413 for quota errors | ||
362 | */ | ||
363 | INSUFFICIENT_STORAGE_507: 507 | ||
364 | } as const | ||
365 | |||
366 | export type HttpStatusCodeType = typeof HttpStatusCode[keyof typeof HttpStatusCode] | ||
diff --git a/packages/models/src/http/index.ts b/packages/models/src/http/index.ts new file mode 100644 index 000000000..f0ad040ed --- /dev/null +++ b/packages/models/src/http/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './http-status-codes.js' | ||
2 | export * from './http-methods.js' | ||
diff --git a/packages/models/src/index.ts b/packages/models/src/index.ts new file mode 100644 index 000000000..b76703dff --- /dev/null +++ b/packages/models/src/index.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | export * from './activitypub/index.js' | ||
2 | export * from './actors/index.js' | ||
3 | export * from './bulk/index.js' | ||
4 | export * from './common/index.js' | ||
5 | export * from './custom-markup/index.js' | ||
6 | export * from './feeds/index.js' | ||
7 | export * from './http/index.js' | ||
8 | export * from './joinpeertube/index.js' | ||
9 | export * from './metrics/index.js' | ||
10 | export * from './moderation/index.js' | ||
11 | export * from './nodeinfo/index.js' | ||
12 | export * from './overviews/index.js' | ||
13 | export * from './plugins/index.js' | ||
14 | export * from './redundancy/index.js' | ||
15 | export * from './runners/index.js' | ||
16 | export * from './search/index.js' | ||
17 | export * from './server/index.js' | ||
18 | export * from './tokens/index.js' | ||
19 | export * from './users/index.js' | ||
20 | export * from './videos/index.js' | ||
diff --git a/packages/models/src/joinpeertube/index.ts b/packages/models/src/joinpeertube/index.ts new file mode 100644 index 000000000..a51d34190 --- /dev/null +++ b/packages/models/src/joinpeertube/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './versions.model.js' | |||
diff --git a/packages/models/src/joinpeertube/versions.model.ts b/packages/models/src/joinpeertube/versions.model.ts new file mode 100644 index 000000000..60a769150 --- /dev/null +++ b/packages/models/src/joinpeertube/versions.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface JoinPeerTubeVersions { | ||
2 | peertube: { | ||
3 | latestVersion: string | ||
4 | } | ||
5 | } | ||
diff --git a/packages/models/src/metrics/index.ts b/packages/models/src/metrics/index.ts new file mode 100644 index 000000000..def6f8095 --- /dev/null +++ b/packages/models/src/metrics/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './playback-metric-create.model.js' | |||
diff --git a/packages/models/src/metrics/playback-metric-create.model.ts b/packages/models/src/metrics/playback-metric-create.model.ts new file mode 100644 index 000000000..3ae91b295 --- /dev/null +++ b/packages/models/src/metrics/playback-metric-create.model.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { VideoResolutionType } from '../videos/index.js' | ||
2 | |||
3 | export interface PlaybackMetricCreate { | ||
4 | playerMode: 'p2p-media-loader' | 'webtorrent' | 'web-video' // FIXME: remove webtorrent player mode not used anymore in PeerTube v6 | ||
5 | |||
6 | resolution?: VideoResolutionType | ||
7 | fps?: number | ||
8 | |||
9 | p2pEnabled: boolean | ||
10 | p2pPeers?: number | ||
11 | |||
12 | resolutionChanges: number | ||
13 | |||
14 | errors: number | ||
15 | |||
16 | downloadedBytesP2P: number | ||
17 | downloadedBytesHTTP: number | ||
18 | |||
19 | uploadedBytesP2P: number | ||
20 | |||
21 | videoId: number | string | ||
22 | } | ||
diff --git a/packages/models/src/moderation/abuse/abuse-create.model.ts b/packages/models/src/moderation/abuse/abuse-create.model.ts new file mode 100644 index 000000000..1c2723b1c --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-create.model.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { AbusePredefinedReasonsString } from './abuse-reason.model.js' | ||
2 | |||
3 | export interface AbuseCreate { | ||
4 | reason: string | ||
5 | |||
6 | predefinedReasons?: AbusePredefinedReasonsString[] | ||
7 | |||
8 | account?: { | ||
9 | id: number | ||
10 | } | ||
11 | |||
12 | video?: { | ||
13 | id: number | string | ||
14 | startAt?: number | ||
15 | endAt?: number | ||
16 | } | ||
17 | |||
18 | comment?: { | ||
19 | id: number | ||
20 | } | ||
21 | } | ||
diff --git a/packages/models/src/moderation/abuse/abuse-filter.type.ts b/packages/models/src/moderation/abuse/abuse-filter.type.ts new file mode 100644 index 000000000..7dafc6d77 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-filter.type.ts | |||
@@ -0,0 +1 @@ | |||
export type AbuseFilter = 'video' | 'comment' | 'account' | |||
diff --git a/packages/models/src/moderation/abuse/abuse-message.model.ts b/packages/models/src/moderation/abuse/abuse-message.model.ts new file mode 100644 index 000000000..9ba95e724 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-message.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { AccountSummary } from '../../actors/account.model.js' | ||
2 | |||
3 | export interface AbuseMessage { | ||
4 | id: number | ||
5 | message: string | ||
6 | byModerator: boolean | ||
7 | createdAt: Date | string | ||
8 | |||
9 | account: AccountSummary | ||
10 | } | ||
diff --git a/packages/models/src/moderation/abuse/abuse-reason.model.ts b/packages/models/src/moderation/abuse/abuse-reason.model.ts new file mode 100644 index 000000000..770b9d47a --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-reason.model.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | export const AbusePredefinedReasons = { | ||
2 | VIOLENT_OR_REPULSIVE: 1, | ||
3 | HATEFUL_OR_ABUSIVE: 2, | ||
4 | SPAM_OR_MISLEADING: 3, | ||
5 | PRIVACY: 4, | ||
6 | RIGHTS: 5, | ||
7 | SERVER_RULES: 6, | ||
8 | THUMBNAILS: 7, | ||
9 | CAPTIONS: 8 | ||
10 | } as const | ||
11 | |||
12 | export type AbusePredefinedReasonsType = typeof AbusePredefinedReasons[keyof typeof AbusePredefinedReasons] | ||
13 | |||
14 | export type AbusePredefinedReasonsString = | ||
15 | 'violentOrRepulsive' | | ||
16 | 'hatefulOrAbusive' | | ||
17 | 'spamOrMisleading' | | ||
18 | 'privacy' | | ||
19 | 'rights' | | ||
20 | 'serverRules' | | ||
21 | 'thumbnails' | | ||
22 | 'captions' | ||
diff --git a/packages/models/src/moderation/abuse/abuse-state.model.ts b/packages/models/src/moderation/abuse/abuse-state.model.ts new file mode 100644 index 000000000..5582d73c4 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-state.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const AbuseState = { | ||
2 | PENDING: 1, | ||
3 | REJECTED: 2, | ||
4 | ACCEPTED: 3 | ||
5 | } as const | ||
6 | |||
7 | export type AbuseStateType = typeof AbuseState[keyof typeof AbuseState] | ||
diff --git a/packages/models/src/moderation/abuse/abuse-update.model.ts b/packages/models/src/moderation/abuse/abuse-update.model.ts new file mode 100644 index 000000000..22a01be89 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-update.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { AbuseStateType } from './abuse-state.model.js' | ||
2 | |||
3 | export interface AbuseUpdate { | ||
4 | moderationComment?: string | ||
5 | |||
6 | state?: AbuseStateType | ||
7 | } | ||
diff --git a/packages/models/src/moderation/abuse/abuse-video-is.type.ts b/packages/models/src/moderation/abuse/abuse-video-is.type.ts new file mode 100644 index 000000000..74937f3b9 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-video-is.type.ts | |||
@@ -0,0 +1 @@ | |||
export type AbuseVideoIs = 'deleted' | 'blacklisted' | |||
diff --git a/packages/models/src/moderation/abuse/abuse.model.ts b/packages/models/src/moderation/abuse/abuse.model.ts new file mode 100644 index 000000000..253a3f44c --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse.model.ts | |||
@@ -0,0 +1,70 @@ | |||
1 | import { Account } from '../../actors/account.model.js' | ||
2 | import { AbuseStateType } from './abuse-state.model.js' | ||
3 | import { AbusePredefinedReasonsString } from './abuse-reason.model.js' | ||
4 | import { VideoConstant } from '../../videos/video-constant.model.js' | ||
5 | import { VideoChannel } from '../../videos/channel/video-channel.model.js' | ||
6 | |||
7 | export interface AdminVideoAbuse { | ||
8 | id: number | ||
9 | name: string | ||
10 | uuid: string | ||
11 | nsfw: boolean | ||
12 | |||
13 | deleted: boolean | ||
14 | blacklisted: boolean | ||
15 | |||
16 | startAt: number | null | ||
17 | endAt: number | null | ||
18 | |||
19 | thumbnailPath?: string | ||
20 | channel?: VideoChannel | ||
21 | |||
22 | countReports: number | ||
23 | nthReport: number | ||
24 | } | ||
25 | |||
26 | export interface AdminVideoCommentAbuse { | ||
27 | id: number | ||
28 | threadId: number | ||
29 | |||
30 | video: { | ||
31 | id: number | ||
32 | name: string | ||
33 | uuid: string | ||
34 | } | ||
35 | |||
36 | text: string | ||
37 | |||
38 | deleted: boolean | ||
39 | } | ||
40 | |||
41 | export interface AdminAbuse { | ||
42 | id: number | ||
43 | |||
44 | reason: string | ||
45 | predefinedReasons?: AbusePredefinedReasonsString[] | ||
46 | |||
47 | reporterAccount: Account | ||
48 | flaggedAccount: Account | ||
49 | |||
50 | state: VideoConstant<AbuseStateType> | ||
51 | moderationComment?: string | ||
52 | |||
53 | video?: AdminVideoAbuse | ||
54 | comment?: AdminVideoCommentAbuse | ||
55 | |||
56 | createdAt: Date | ||
57 | updatedAt: Date | ||
58 | |||
59 | countReportsForReporter?: number | ||
60 | countReportsForReportee?: number | ||
61 | |||
62 | countMessages: number | ||
63 | } | ||
64 | |||
65 | export type UserVideoAbuse = Omit<AdminVideoAbuse, 'countReports' | 'nthReport'> | ||
66 | |||
67 | export type UserVideoCommentAbuse = AdminVideoCommentAbuse | ||
68 | |||
69 | export type UserAbuse = Omit<AdminAbuse, 'reporterAccount' | 'countReportsForReportee' | 'countReportsForReporter' | 'startAt' | 'endAt' | ||
70 | | 'count' | 'nth' | 'moderationComment'> | ||
diff --git a/packages/models/src/moderation/abuse/index.ts b/packages/models/src/moderation/abuse/index.ts new file mode 100644 index 000000000..27fca7076 --- /dev/null +++ b/packages/models/src/moderation/abuse/index.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export * from './abuse-create.model.js' | ||
2 | export * from './abuse-filter.type.js' | ||
3 | export * from './abuse-message.model.js' | ||
4 | export * from './abuse-reason.model.js' | ||
5 | export * from './abuse-state.model.js' | ||
6 | export * from './abuse-update.model.js' | ||
7 | export * from './abuse-video-is.type.js' | ||
8 | export * from './abuse.model.js' | ||
diff --git a/packages/models/src/moderation/account-block.model.ts b/packages/models/src/moderation/account-block.model.ts new file mode 100644 index 000000000..2d070da62 --- /dev/null +++ b/packages/models/src/moderation/account-block.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { Account } from '../actors/index.js' | ||
2 | |||
3 | export interface AccountBlock { | ||
4 | byAccount: Account | ||
5 | blockedAccount: Account | ||
6 | createdAt: Date | string | ||
7 | } | ||
diff --git a/packages/models/src/moderation/block-status.model.ts b/packages/models/src/moderation/block-status.model.ts new file mode 100644 index 000000000..597312757 --- /dev/null +++ b/packages/models/src/moderation/block-status.model.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | export interface BlockStatus { | ||
2 | accounts: { | ||
3 | [ handle: string ]: { | ||
4 | blockedByServer: boolean | ||
5 | blockedByUser?: boolean | ||
6 | } | ||
7 | } | ||
8 | |||
9 | hosts: { | ||
10 | [ host: string ]: { | ||
11 | blockedByServer: boolean | ||
12 | blockedByUser?: boolean | ||
13 | } | ||
14 | } | ||
15 | } | ||
diff --git a/packages/models/src/moderation/index.ts b/packages/models/src/moderation/index.ts new file mode 100644 index 000000000..52e21e7b3 --- /dev/null +++ b/packages/models/src/moderation/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './abuse/index.js' | ||
2 | export * from './block-status.model.js' | ||
3 | export * from './account-block.model.js' | ||
4 | export * from './server-block.model.js' | ||
diff --git a/packages/models/src/moderation/server-block.model.ts b/packages/models/src/moderation/server-block.model.ts new file mode 100644 index 000000000..b85646fc6 --- /dev/null +++ b/packages/models/src/moderation/server-block.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { Account } from '../actors/index.js' | ||
2 | |||
3 | export interface ServerBlock { | ||
4 | byAccount: Account | ||
5 | blockedServer: { | ||
6 | host: string | ||
7 | } | ||
8 | createdAt: Date | string | ||
9 | } | ||
diff --git a/packages/models/src/nodeinfo/index.ts b/packages/models/src/nodeinfo/index.ts new file mode 100644 index 000000000..932288795 --- /dev/null +++ b/packages/models/src/nodeinfo/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './nodeinfo.model.js' | |||
diff --git a/packages/models/src/nodeinfo/nodeinfo.model.ts b/packages/models/src/nodeinfo/nodeinfo.model.ts new file mode 100644 index 000000000..336cb66d2 --- /dev/null +++ b/packages/models/src/nodeinfo/nodeinfo.model.ts | |||
@@ -0,0 +1,117 @@ | |||
1 | /** | ||
2 | * NodeInfo schema version 2.0. | ||
3 | */ | ||
4 | export interface HttpNodeinfoDiasporaSoftwareNsSchema20 { | ||
5 | /** | ||
6 | * The schema version, must be 2.0. | ||
7 | */ | ||
8 | version: '2.0' | ||
9 | /** | ||
10 | * Metadata about server software in use. | ||
11 | */ | ||
12 | software: { | ||
13 | /** | ||
14 | * The canonical name of this server software. | ||
15 | */ | ||
16 | name: string | ||
17 | /** | ||
18 | * The version of this server software. | ||
19 | */ | ||
20 | version: string | ||
21 | } | ||
22 | /** | ||
23 | * The protocols supported on this server. | ||
24 | */ | ||
25 | protocols: ( | ||
26 | | 'activitypub' | ||
27 | | 'buddycloud' | ||
28 | | 'dfrn' | ||
29 | | 'diaspora' | ||
30 | | 'libertree' | ||
31 | | 'ostatus' | ||
32 | | 'pumpio' | ||
33 | | 'tent' | ||
34 | | 'xmpp' | ||
35 | | 'zot')[] | ||
36 | /** | ||
37 | * The third party sites this server can connect to via their application API. | ||
38 | */ | ||
39 | services: { | ||
40 | /** | ||
41 | * The third party sites this server can retrieve messages from for combined display with regular traffic. | ||
42 | */ | ||
43 | inbound: ('atom1.0' | 'gnusocial' | 'imap' | 'pnut' | 'pop3' | 'pumpio' | 'rss2.0' | 'twitter')[] | ||
44 | /** | ||
45 | * The third party sites this server can publish messages to on the behalf of a user. | ||
46 | */ | ||
47 | outbound: ( | ||
48 | | 'atom1.0' | ||
49 | | 'blogger' | ||
50 | | 'buddycloud' | ||
51 | | 'diaspora' | ||
52 | | 'dreamwidth' | ||
53 | | 'drupal' | ||
54 | | 'facebook' | ||
55 | | 'friendica' | ||
56 | | 'gnusocial' | ||
57 | | 'google' | ||
58 | | 'insanejournal' | ||
59 | | 'libertree' | ||
60 | | 'linkedin' | ||
61 | | 'livejournal' | ||
62 | | 'mediagoblin' | ||
63 | | 'myspace' | ||
64 | | 'pinterest' | ||
65 | | 'pnut' | ||
66 | | 'posterous' | ||
67 | | 'pumpio' | ||
68 | | 'redmatrix' | ||
69 | | 'rss2.0' | ||
70 | | 'smtp' | ||
71 | | 'tent' | ||
72 | | 'tumblr' | ||
73 | | 'twitter' | ||
74 | | 'wordpress' | ||
75 | | 'xmpp')[] | ||
76 | } | ||
77 | /** | ||
78 | * Whether this server allows open self-registration. | ||
79 | */ | ||
80 | openRegistrations: boolean | ||
81 | /** | ||
82 | * Usage statistics for this server. | ||
83 | */ | ||
84 | usage: { | ||
85 | /** | ||
86 | * statistics about the users of this server. | ||
87 | */ | ||
88 | users: { | ||
89 | /** | ||
90 | * The total amount of on this server registered users. | ||
91 | */ | ||
92 | total?: number | ||
93 | /** | ||
94 | * The amount of users that signed in at least once in the last 180 days. | ||
95 | */ | ||
96 | activeHalfyear?: number | ||
97 | /** | ||
98 | * The amount of users that signed in at least once in the last 30 days. | ||
99 | */ | ||
100 | activeMonth?: number | ||
101 | } | ||
102 | /** | ||
103 | * The amount of posts that were made by users that are registered on this server. | ||
104 | */ | ||
105 | localPosts?: number | ||
106 | /** | ||
107 | * The amount of comments that were made by users that are registered on this server. | ||
108 | */ | ||
109 | localComments?: number | ||
110 | } | ||
111 | /** | ||
112 | * Free form key value pairs for software specific values. Clients should not rely on any specific key present. | ||
113 | */ | ||
114 | metadata: { | ||
115 | [k: string]: any | ||
116 | } | ||
117 | } | ||
diff --git a/packages/models/src/overviews/index.ts b/packages/models/src/overviews/index.ts new file mode 100644 index 000000000..20dc105e2 --- /dev/null +++ b/packages/models/src/overviews/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './videos-overview.model.js' | |||
diff --git a/packages/models/src/overviews/videos-overview.model.ts b/packages/models/src/overviews/videos-overview.model.ts new file mode 100644 index 000000000..3a1ba1760 --- /dev/null +++ b/packages/models/src/overviews/videos-overview.model.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { Video, VideoChannelSummary, VideoConstant } from '../videos/index.js' | ||
2 | |||
3 | export interface ChannelOverview { | ||
4 | channel: VideoChannelSummary | ||
5 | videos: Video[] | ||
6 | } | ||
7 | |||
8 | export interface CategoryOverview { | ||
9 | category: VideoConstant<number> | ||
10 | videos: Video[] | ||
11 | } | ||
12 | |||
13 | export interface TagOverview { | ||
14 | tag: string | ||
15 | videos: Video[] | ||
16 | } | ||
17 | |||
18 | export interface VideosOverview { | ||
19 | channels: ChannelOverview[] | ||
20 | |||
21 | categories: CategoryOverview[] | ||
22 | |||
23 | tags: TagOverview[] | ||
24 | } | ||
diff --git a/packages/models/src/plugins/client/client-hook.model.ts b/packages/models/src/plugins/client/client-hook.model.ts new file mode 100644 index 000000000..4a0818c99 --- /dev/null +++ b/packages/models/src/plugins/client/client-hook.model.ts | |||
@@ -0,0 +1,195 @@ | |||
1 | // Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target} | ||
2 | // Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target} | ||
3 | |||
4 | export const clientFilterHookObject = { | ||
5 | // Filter params/result of the function that fetch videos of the trending page | ||
6 | 'filter:api.trending-videos.videos.list.params': true, | ||
7 | 'filter:api.trending-videos.videos.list.result': true, | ||
8 | |||
9 | // Filter params/result of the function that fetch videos of the trending page | ||
10 | 'filter:api.most-liked-videos.videos.list.params': true, | ||
11 | 'filter:api.most-liked-videos.videos.list.result': true, | ||
12 | |||
13 | // Filter params/result of the function that fetch videos of the local page | ||
14 | 'filter:api.local-videos.videos.list.params': true, | ||
15 | 'filter:api.local-videos.videos.list.result': true, | ||
16 | |||
17 | // Filter params/result of the function that fetch videos of the recently-added page | ||
18 | 'filter:api.recently-added-videos.videos.list.params': true, | ||
19 | 'filter:api.recently-added-videos.videos.list.result': true, | ||
20 | |||
21 | // Filter params/result of the function that fetch videos of the user subscription page | ||
22 | 'filter:api.user-subscriptions-videos.videos.list.params': true, | ||
23 | 'filter:api.user-subscriptions-videos.videos.list.result': true, | ||
24 | |||
25 | // Filter params/result of the function that fetch the video of the video-watch page | ||
26 | 'filter:api.video-watch.video.get.params': true, | ||
27 | 'filter:api.video-watch.video.get.result': true, | ||
28 | |||
29 | // Filter params/result of the function that fetch video playlist elements of the video-watch page | ||
30 | 'filter:api.video-watch.video-playlist-elements.get.params': true, | ||
31 | 'filter:api.video-watch.video-playlist-elements.get.result': true, | ||
32 | |||
33 | // Filter params/result of the function that fetch the threads of the video-watch page | ||
34 | 'filter:api.video-watch.video-threads.list.params': true, | ||
35 | 'filter:api.video-watch.video-threads.list.result': true, | ||
36 | |||
37 | // Filter params/result of the function that fetch the replies of a thread in the video-watch page | ||
38 | 'filter:api.video-watch.video-thread-replies.list.params': true, | ||
39 | 'filter:api.video-watch.video-thread-replies.list.result': true, | ||
40 | |||
41 | // Filter params/result of the function that fetch videos according to the user search | ||
42 | 'filter:api.search.videos.list.params': true, | ||
43 | 'filter:api.search.videos.list.result': true, | ||
44 | // Filter params/result of the function that fetch video channels according to the user search | ||
45 | 'filter:api.search.video-channels.list.params': true, | ||
46 | 'filter:api.search.video-channels.list.result': true, | ||
47 | // Filter params/result of the function that fetch video playlists according to the user search | ||
48 | 'filter:api.search.video-playlists.list.params': true, | ||
49 | 'filter:api.search.video-playlists.list.result': true, | ||
50 | |||
51 | // Filter form | ||
52 | 'filter:api.signup.registration.create.params': true, | ||
53 | |||
54 | // Filter params/result of the function that fetch video playlist elements of the my-library page | ||
55 | 'filter:api.my-library.video-playlist-elements.list.params': true, | ||
56 | 'filter:api.my-library.video-playlist-elements.list.result': true, | ||
57 | |||
58 | // Filter the options to create our player | ||
59 | 'filter:internal.video-watch.player.build-options.params': true, | ||
60 | 'filter:internal.video-watch.player.build-options.result': true, | ||
61 | |||
62 | // Filter the options to load a new video in our player | ||
63 | 'filter:internal.video-watch.player.load-options.params': true, | ||
64 | 'filter:internal.video-watch.player.load-options.result': true, | ||
65 | |||
66 | // Filter our SVG icons content | ||
67 | 'filter:internal.common.svg-icons.get-content.params': true, | ||
68 | 'filter:internal.common.svg-icons.get-content.result': true, | ||
69 | |||
70 | // Filter left menu links | ||
71 | 'filter:left-menu.links.create.result': true, | ||
72 | |||
73 | // Filter upload page alert messages | ||
74 | 'filter:upload.messages.create.result': true, | ||
75 | |||
76 | 'filter:login.instance-about-plugin-panels.create.result': true, | ||
77 | 'filter:signup.instance-about-plugin-panels.create.result': true, | ||
78 | |||
79 | 'filter:share.video-embed-code.build.params': true, | ||
80 | 'filter:share.video-embed-code.build.result': true, | ||
81 | 'filter:share.video-playlist-embed-code.build.params': true, | ||
82 | 'filter:share.video-playlist-embed-code.build.result': true, | ||
83 | |||
84 | 'filter:share.video-embed-url.build.params': true, | ||
85 | 'filter:share.video-embed-url.build.result': true, | ||
86 | 'filter:share.video-playlist-embed-url.build.params': true, | ||
87 | 'filter:share.video-playlist-embed-url.build.result': true, | ||
88 | |||
89 | 'filter:share.video-url.build.params': true, | ||
90 | 'filter:share.video-url.build.result': true, | ||
91 | 'filter:share.video-playlist-url.build.params': true, | ||
92 | 'filter:share.video-playlist-url.build.result': true, | ||
93 | |||
94 | 'filter:video-watch.video-plugin-metadata.result': true, | ||
95 | |||
96 | // Filter videojs options built for PeerTube player | ||
97 | 'filter:internal.player.videojs.options.result': true, | ||
98 | |||
99 | // Filter p2p media loader options built for PeerTube player | ||
100 | 'filter:internal.player.p2p-media-loader.options.result': true | ||
101 | } | ||
102 | |||
103 | export type ClientFilterHookName = keyof typeof clientFilterHookObject | ||
104 | |||
105 | export const clientActionHookObject = { | ||
106 | // Fired when the application is being initialized | ||
107 | 'action:application.init': true, | ||
108 | |||
109 | // Fired when the video watch page is being initialized | ||
110 | 'action:video-watch.init': true, | ||
111 | // Fired when the video watch page loaded the video | ||
112 | 'action:video-watch.video.loaded': true, | ||
113 | // Fired when the player finished loading | ||
114 | 'action:video-watch.player.loaded': true, | ||
115 | // Fired when the video watch page comments(threads) are loaded and load more comments on scroll | ||
116 | 'action:video-watch.video-threads.loaded': true, | ||
117 | // Fired when a user click on 'View x replies' and they're loaded | ||
118 | 'action:video-watch.video-thread-replies.loaded': true, | ||
119 | |||
120 | // Fired when the video channel creation page is being initialized | ||
121 | 'action:video-channel-create.init': true, | ||
122 | |||
123 | // Fired when the video channel update page is being initialized | ||
124 | 'action:video-channel-update.init': true, | ||
125 | 'action:video-channel-update.video-channel.loaded': true, | ||
126 | |||
127 | // Fired when the page that list video channel videos is being initialized | ||
128 | 'action:video-channel-videos.init': true, | ||
129 | 'action:video-channel-videos.video-channel.loaded': true, | ||
130 | 'action:video-channel-videos.videos.loaded': true, | ||
131 | |||
132 | // Fired when the page that list video channel playlists is being initialized | ||
133 | 'action:video-channel-playlists.init': true, | ||
134 | 'action:video-channel-playlists.video-channel.loaded': true, | ||
135 | 'action:video-channel-playlists.playlists.loaded': true, | ||
136 | |||
137 | // Fired when the video edit page (upload, URL/torrent import, update) is being initialized | ||
138 | // Contains a `type` and `updateForm` object attributes | ||
139 | 'action:video-edit.init': true, | ||
140 | |||
141 | // Fired when values of the video edit form changed | ||
142 | 'action:video-edit.form.updated': true, | ||
143 | |||
144 | // Fired when the login page is being initialized | ||
145 | 'action:login.init': true, | ||
146 | |||
147 | // Fired when the search page is being initialized | ||
148 | 'action:search.init': true, | ||
149 | |||
150 | // Fired every time Angular URL changes | ||
151 | 'action:router.navigation-end': true, | ||
152 | |||
153 | // Fired when the registration page is being initialized | ||
154 | 'action:signup.register.init': true, | ||
155 | |||
156 | // PeerTube >= 3.2 | ||
157 | // Fired when the admin plugin settings page is being initialized | ||
158 | 'action:admin-plugin-settings.init': true, | ||
159 | |||
160 | // Fired when the video upload page is being initialized | ||
161 | 'action:video-upload.init': true, | ||
162 | // Fired when the video import by URL page is being initialized | ||
163 | 'action:video-url-import.init': true, | ||
164 | // Fired when the video import by torrent/magnet URI page is being initialized | ||
165 | 'action:video-torrent-import.init': true, | ||
166 | // Fired when the "Go Live" page is being initialized | ||
167 | 'action:go-live.init': true, | ||
168 | |||
169 | // Fired when the user explicitly logged in/logged out | ||
170 | 'action:auth-user.logged-in': true, | ||
171 | 'action:auth-user.logged-out': true, | ||
172 | // Fired when the application loaded user information (using tokens from the local storage or after a successful login) | ||
173 | 'action:auth-user.information-loaded': true, | ||
174 | |||
175 | // Fired when the modal to download a video/caption is shown | ||
176 | 'action:modal.video-download.shown': true, | ||
177 | // Fired when the modal to share a video/playlist is shown | ||
178 | 'action:modal.share.shown': true, | ||
179 | |||
180 | // ####### Embed hooks ####### | ||
181 | // /!\ In embed scope, peertube helpers are not available | ||
182 | // ########################### | ||
183 | |||
184 | // Fired when the embed loaded the player | ||
185 | 'action:embed.player.loaded': true | ||
186 | } | ||
187 | |||
188 | export type ClientActionHookName = keyof typeof clientActionHookObject | ||
189 | |||
190 | export const clientHookObject = Object.assign({}, clientFilterHookObject, clientActionHookObject) | ||
191 | export type ClientHookName = keyof typeof clientHookObject | ||
192 | |||
193 | export interface ClientHook { | ||
194 | runHook <T> (hookName: ClientHookName, result?: T, params?: any): Promise<T> | ||
195 | } | ||
diff --git a/packages/models/src/plugins/client/index.ts b/packages/models/src/plugins/client/index.ts new file mode 100644 index 000000000..04fa32d6d --- /dev/null +++ b/packages/models/src/plugins/client/index.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export * from './client-hook.model.js' | ||
2 | export * from './plugin-client-scope.type.js' | ||
3 | export * from './plugin-element-placeholder.type.js' | ||
4 | export * from './plugin-selector-id.type.js' | ||
5 | export * from './register-client-form-field.model.js' | ||
6 | export * from './register-client-hook.model.js' | ||
7 | export * from './register-client-route.model.js' | ||
8 | export * from './register-client-settings-script.model.js' | ||
diff --git a/packages/models/src/plugins/client/plugin-client-scope.type.ts b/packages/models/src/plugins/client/plugin-client-scope.type.ts new file mode 100644 index 000000000..c09a453b8 --- /dev/null +++ b/packages/models/src/plugins/client/plugin-client-scope.type.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | export type PluginClientScope = | ||
2 | 'common' | | ||
3 | 'video-watch' | | ||
4 | 'search' | | ||
5 | 'signup' | | ||
6 | 'login' | | ||
7 | 'embed' | | ||
8 | 'video-edit' | | ||
9 | 'admin-plugin' | | ||
10 | 'my-library' | | ||
11 | 'video-channel' | ||
diff --git a/packages/models/src/plugins/client/plugin-element-placeholder.type.ts b/packages/models/src/plugins/client/plugin-element-placeholder.type.ts new file mode 100644 index 000000000..7b8a2605b --- /dev/null +++ b/packages/models/src/plugins/client/plugin-element-placeholder.type.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export type PluginElementPlaceholder = | ||
2 | 'player-next' | | ||
3 | 'share-modal-playlist-settings' | | ||
4 | 'share-modal-video-settings' | ||
diff --git a/packages/models/src/plugins/client/plugin-selector-id.type.ts b/packages/models/src/plugins/client/plugin-selector-id.type.ts new file mode 100644 index 000000000..8d23314b5 --- /dev/null +++ b/packages/models/src/plugins/client/plugin-selector-id.type.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export type PluginSelectorId = | ||
2 | 'login-form' | | ||
3 | 'menu-user-dropdown-language-item' | | ||
4 | 'about-instance-features' | | ||
5 | 'about-instance-statistics' | | ||
6 | 'about-instance-moderation' | | ||
7 | 'about-menu-instance' | | ||
8 | 'about-menu-peertube' | | ||
9 | 'about-menu-network' | | ||
10 | 'about-instance-other-information' | ||
diff --git a/packages/models/src/plugins/client/register-client-form-field.model.ts b/packages/models/src/plugins/client/register-client-form-field.model.ts new file mode 100644 index 000000000..153c4a6ea --- /dev/null +++ b/packages/models/src/plugins/client/register-client-form-field.model.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | export type RegisterClientFormFieldOptions = { | ||
2 | name?: string | ||
3 | label?: string | ||
4 | type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' | 'select' | 'html' | ||
5 | |||
6 | // For select type | ||
7 | options?: { value: string, label: string }[] | ||
8 | |||
9 | // For html type | ||
10 | html?: string | ||
11 | |||
12 | descriptionHTML?: string | ||
13 | |||
14 | // Default setting value | ||
15 | default?: string | boolean | ||
16 | |||
17 | // Not supported by plugin setting registration, use registerSettingsScript instead | ||
18 | hidden?: (options: any) => boolean | ||
19 | |||
20 | // Return undefined | null if there is no error or return a string with the detailed error | ||
21 | // Not supported by plugin setting registration | ||
22 | error?: (options: any) => Promise<{ error: boolean, text?: string }> | ||
23 | } | ||
24 | |||
25 | export interface RegisterClientVideoFieldOptions { | ||
26 | type: 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live' | ||
27 | |||
28 | // Default to 'plugin-settings' | ||
29 | tab?: 'main' | 'plugin-settings' | ||
30 | } | ||
diff --git a/packages/models/src/plugins/client/register-client-hook.model.ts b/packages/models/src/plugins/client/register-client-hook.model.ts new file mode 100644 index 000000000..19159ed1e --- /dev/null +++ b/packages/models/src/plugins/client/register-client-hook.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { ClientHookName } from './client-hook.model.js' | ||
2 | |||
3 | export interface RegisterClientHookOptions { | ||
4 | target: ClientHookName | ||
5 | handler: Function | ||
6 | priority?: number | ||
7 | } | ||
diff --git a/packages/models/src/plugins/client/register-client-route.model.ts b/packages/models/src/plugins/client/register-client-route.model.ts new file mode 100644 index 000000000..271b67834 --- /dev/null +++ b/packages/models/src/plugins/client/register-client-route.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface RegisterClientRouteOptions { | ||
2 | route: string | ||
3 | |||
4 | onMount (options: { | ||
5 | rootEl: HTMLElement | ||
6 | }): void | ||
7 | } | ||
diff --git a/packages/models/src/plugins/client/register-client-settings-script.model.ts b/packages/models/src/plugins/client/register-client-settings-script.model.ts new file mode 100644 index 000000000..7de3c1c28 --- /dev/null +++ b/packages/models/src/plugins/client/register-client-settings-script.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | import { RegisterServerSettingOptions } from '../server/index.js' | ||
2 | |||
3 | export interface RegisterClientSettingsScriptOptions { | ||
4 | isSettingHidden (options: { | ||
5 | setting: RegisterServerSettingOptions | ||
6 | formValues: { [name: string]: any } | ||
7 | }): boolean | ||
8 | } | ||
diff --git a/packages/models/src/plugins/hook-type.enum.ts b/packages/models/src/plugins/hook-type.enum.ts new file mode 100644 index 000000000..7acc5f48a --- /dev/null +++ b/packages/models/src/plugins/hook-type.enum.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const HookType = { | ||
2 | STATIC: 1, | ||
3 | ACTION: 2, | ||
4 | FILTER: 3 | ||
5 | } as const | ||
6 | |||
7 | export type HookType_Type = typeof HookType[keyof typeof HookType] | ||
diff --git a/packages/models/src/plugins/index.ts b/packages/models/src/plugins/index.ts new file mode 100644 index 000000000..1117a946e --- /dev/null +++ b/packages/models/src/plugins/index.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export * from './client/index.js' | ||
2 | export * from './plugin-index/index.js' | ||
3 | export * from './server/index.js' | ||
4 | export * from './hook-type.enum.js' | ||
5 | export * from './plugin-package-json.model.js' | ||
6 | export * from './plugin.type.js' | ||
diff --git a/packages/models/src/plugins/plugin-index/index.ts b/packages/models/src/plugins/plugin-index/index.ts new file mode 100644 index 000000000..f53b88084 --- /dev/null +++ b/packages/models/src/plugins/plugin-index/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './peertube-plugin-index-list.model.js' | ||
2 | export * from './peertube-plugin-index.model.js' | ||
3 | export * from './peertube-plugin-latest-version.model.js' | ||
diff --git a/packages/models/src/plugins/plugin-index/peertube-plugin-index-list.model.ts b/packages/models/src/plugins/plugin-index/peertube-plugin-index-list.model.ts new file mode 100644 index 000000000..98301bbc1 --- /dev/null +++ b/packages/models/src/plugins/plugin-index/peertube-plugin-index-list.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { PluginType_Type } from '../plugin.type.js' | ||
2 | |||
3 | export interface PeertubePluginIndexList { | ||
4 | start: number | ||
5 | count: number | ||
6 | sort: string | ||
7 | pluginType?: PluginType_Type | ||
8 | currentPeerTubeEngine?: string | ||
9 | search?: string | ||
10 | } | ||
diff --git a/packages/models/src/plugins/plugin-index/peertube-plugin-index.model.ts b/packages/models/src/plugins/plugin-index/peertube-plugin-index.model.ts new file mode 100644 index 000000000..36dfef943 --- /dev/null +++ b/packages/models/src/plugins/plugin-index/peertube-plugin-index.model.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | export interface PeerTubePluginIndex { | ||
2 | npmName: string | ||
3 | description: string | ||
4 | homepage: string | ||
5 | createdAt: Date | ||
6 | updatedAt: Date | ||
7 | |||
8 | popularity: number | ||
9 | |||
10 | latestVersion: string | ||
11 | |||
12 | official: boolean | ||
13 | |||
14 | name?: string | ||
15 | installed?: boolean | ||
16 | } | ||
diff --git a/packages/models/src/plugins/plugin-index/peertube-plugin-latest-version.model.ts b/packages/models/src/plugins/plugin-index/peertube-plugin-latest-version.model.ts new file mode 100644 index 000000000..811a64429 --- /dev/null +++ b/packages/models/src/plugins/plugin-index/peertube-plugin-latest-version.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export interface PeertubePluginLatestVersionRequest { | ||
2 | currentPeerTubeEngine?: string | ||
3 | |||
4 | npmNames: string[] | ||
5 | } | ||
6 | |||
7 | export type PeertubePluginLatestVersionResponse = { | ||
8 | npmName: string | ||
9 | latestVersion: string | null | ||
10 | }[] | ||
diff --git a/packages/models/src/plugins/plugin-package-json.model.ts b/packages/models/src/plugins/plugin-package-json.model.ts new file mode 100644 index 000000000..5b9ccec56 --- /dev/null +++ b/packages/models/src/plugins/plugin-package-json.model.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { PluginClientScope } from './client/plugin-client-scope.type.js' | ||
2 | |||
3 | export type PluginTranslationPathsJSON = { | ||
4 | [ locale: string ]: string | ||
5 | } | ||
6 | |||
7 | export type ClientScriptJSON = { | ||
8 | script: string | ||
9 | scopes: PluginClientScope[] | ||
10 | } | ||
11 | |||
12 | export type PluginPackageJSON = { | ||
13 | name: string | ||
14 | version: string | ||
15 | description: string | ||
16 | engine: { peertube: string } | ||
17 | |||
18 | homepage: string | ||
19 | author: string | ||
20 | bugs: string | ||
21 | library: string | ||
22 | |||
23 | staticDirs: { [ name: string ]: string } | ||
24 | css: string[] | ||
25 | |||
26 | clientScripts: ClientScriptJSON[] | ||
27 | |||
28 | translations: PluginTranslationPathsJSON | ||
29 | } | ||
diff --git a/packages/models/src/plugins/plugin.type.ts b/packages/models/src/plugins/plugin.type.ts new file mode 100644 index 000000000..7d03012e6 --- /dev/null +++ b/packages/models/src/plugins/plugin.type.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export const PluginType = { | ||
2 | PLUGIN: 1, | ||
3 | THEME: 2 | ||
4 | } as const | ||
5 | |||
6 | export type PluginType_Type = typeof PluginType[keyof typeof PluginType] | ||
diff --git a/packages/models/src/plugins/server/api/index.ts b/packages/models/src/plugins/server/api/index.ts new file mode 100644 index 000000000..1e3842c46 --- /dev/null +++ b/packages/models/src/plugins/server/api/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './install-plugin.model.js' | ||
2 | export * from './manage-plugin.model.js' | ||
3 | export * from './peertube-plugin.model.js' | ||
diff --git a/packages/models/src/plugins/server/api/install-plugin.model.ts b/packages/models/src/plugins/server/api/install-plugin.model.ts new file mode 100644 index 000000000..a1d009a00 --- /dev/null +++ b/packages/models/src/plugins/server/api/install-plugin.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface InstallOrUpdatePlugin { | ||
2 | npmName?: string | ||
3 | pluginVersion?: string | ||
4 | path?: string | ||
5 | } | ||
diff --git a/packages/models/src/plugins/server/api/manage-plugin.model.ts b/packages/models/src/plugins/server/api/manage-plugin.model.ts new file mode 100644 index 000000000..612b3056c --- /dev/null +++ b/packages/models/src/plugins/server/api/manage-plugin.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface ManagePlugin { | ||
2 | npmName: string | ||
3 | } | ||
diff --git a/packages/models/src/plugins/server/api/peertube-plugin.model.ts b/packages/models/src/plugins/server/api/peertube-plugin.model.ts new file mode 100644 index 000000000..0bc1b095b --- /dev/null +++ b/packages/models/src/plugins/server/api/peertube-plugin.model.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | import { PluginType_Type } from '../../plugin.type.js' | ||
2 | |||
3 | export interface PeerTubePlugin { | ||
4 | name: string | ||
5 | type: PluginType_Type | ||
6 | latestVersion: string | ||
7 | version: string | ||
8 | enabled: boolean | ||
9 | uninstalled: boolean | ||
10 | peertubeEngine: string | ||
11 | description: string | ||
12 | homepage: string | ||
13 | settings: { [ name: string ]: string } | ||
14 | createdAt: Date | ||
15 | updatedAt: Date | ||
16 | } | ||
diff --git a/packages/models/src/plugins/server/index.ts b/packages/models/src/plugins/server/index.ts new file mode 100644 index 000000000..04412318b --- /dev/null +++ b/packages/models/src/plugins/server/index.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export * from './api/index.js' | ||
2 | export * from './managers/index.js' | ||
3 | export * from './settings/index.js' | ||
4 | export * from './plugin-constant-manager.model.js' | ||
5 | export * from './plugin-translation.model.js' | ||
6 | export * from './register-server-hook.model.js' | ||
7 | export * from './server-hook.model.js' | ||
diff --git a/packages/models/src/plugins/server/managers/index.ts b/packages/models/src/plugins/server/managers/index.ts new file mode 100644 index 000000000..2433dd9bf --- /dev/null +++ b/packages/models/src/plugins/server/managers/index.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | |||
2 | export * from './plugin-playlist-privacy-manager.model.js' | ||
3 | export * from './plugin-settings-manager.model.js' | ||
4 | export * from './plugin-storage-manager.model.js' | ||
5 | export * from './plugin-transcoding-manager.model.js' | ||
6 | export * from './plugin-video-category-manager.model.js' | ||
7 | export * from './plugin-video-language-manager.model.js' | ||
8 | export * from './plugin-video-licence-manager.model.js' | ||
9 | export * from './plugin-video-privacy-manager.model.js' | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-playlist-privacy-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-playlist-privacy-manager.model.ts new file mode 100644 index 000000000..212c910c5 --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-playlist-privacy-manager.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | import { VideoPlaylistPrivacyType } from '../../../videos/playlist/video-playlist-privacy.model.js' | ||
2 | import { ConstantManager } from '../plugin-constant-manager.model.js' | ||
3 | |||
4 | export interface PluginPlaylistPrivacyManager extends ConstantManager<VideoPlaylistPrivacyType> { | ||
5 | /** | ||
6 | * PUBLIC = 1, | ||
7 | * UNLISTED = 2, | ||
8 | * PRIVATE = 3 | ||
9 | * @deprecated use `deleteConstant` instead | ||
10 | */ | ||
11 | deletePlaylistPrivacy: (privacyKey: VideoPlaylistPrivacyType) => boolean | ||
12 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-settings-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-settings-manager.model.ts new file mode 100644 index 000000000..b628718dd --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-settings-manager.model.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | export type SettingValue = string | boolean | ||
2 | |||
3 | export interface SettingEntries { | ||
4 | [settingName: string]: SettingValue | ||
5 | } | ||
6 | |||
7 | export type SettingsChangeCallback = (settings: SettingEntries) => Promise<any> | ||
8 | |||
9 | export interface PluginSettingsManager { | ||
10 | getSetting: (name: string) => Promise<SettingValue> | ||
11 | |||
12 | getSettings: (names: string[]) => Promise<SettingEntries> | ||
13 | |||
14 | setSetting: (name: string, value: SettingValue) => Promise<any> | ||
15 | |||
16 | onSettingsChange: (cb: SettingsChangeCallback) => void | ||
17 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-storage-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-storage-manager.model.ts new file mode 100644 index 000000000..51567044a --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-storage-manager.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface PluginStorageManager { | ||
2 | getData: (key: string) => Promise<string> | ||
3 | |||
4 | storeData: (key: string, data: any) => Promise<any> | ||
5 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-transcoding-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-transcoding-manager.model.ts new file mode 100644 index 000000000..235f5c65d --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-transcoding-manager.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { EncoderOptionsBuilder } from '../../../videos/transcoding/index.js' | ||
2 | |||
3 | export interface PluginTranscodingManager { | ||
4 | addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean | ||
5 | |||
6 | addVODProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean | ||
7 | |||
8 | addLiveEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void | ||
9 | |||
10 | addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void | ||
11 | |||
12 | removeAllProfilesAndEncoderPriorities(): void | ||
13 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-video-category-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-category-manager.model.ts new file mode 100644 index 000000000..9da691e11 --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-video-category-manager.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { ConstantManager } from '../plugin-constant-manager.model.js' | ||
2 | |||
3 | export interface PluginVideoCategoryManager extends ConstantManager<number> { | ||
4 | /** | ||
5 | * @deprecated use `addConstant` instead | ||
6 | */ | ||
7 | addCategory: (categoryKey: number, categoryLabel: string) => boolean | ||
8 | |||
9 | /** | ||
10 | * @deprecated use `deleteConstant` instead | ||
11 | */ | ||
12 | deleteCategory: (categoryKey: number) => boolean | ||
13 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-video-language-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-language-manager.model.ts new file mode 100644 index 000000000..712486075 --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-video-language-manager.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { ConstantManager } from '../plugin-constant-manager.model.js' | ||
2 | |||
3 | export interface PluginVideoLanguageManager extends ConstantManager<string> { | ||
4 | /** | ||
5 | * @deprecated use `addConstant` instead | ||
6 | */ | ||
7 | addLanguage: (languageKey: string, languageLabel: string) => boolean | ||
8 | |||
9 | /** | ||
10 | * @deprecated use `deleteConstant` instead | ||
11 | */ | ||
12 | deleteLanguage: (languageKey: string) => boolean | ||
13 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-video-licence-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-licence-manager.model.ts new file mode 100644 index 000000000..cebae8d95 --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-video-licence-manager.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { ConstantManager } from '../plugin-constant-manager.model.js' | ||
2 | |||
3 | export interface PluginVideoLicenceManager extends ConstantManager<number> { | ||
4 | /** | ||
5 | * @deprecated use `addConstant` instead | ||
6 | */ | ||
7 | addLicence: (licenceKey: number, licenceLabel: string) => boolean | ||
8 | |||
9 | /** | ||
10 | * @deprecated use `deleteConstant` instead | ||
11 | */ | ||
12 | deleteLicence: (licenceKey: number) => boolean | ||
13 | } | ||
diff --git a/packages/models/src/plugins/server/managers/plugin-video-privacy-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-privacy-manager.model.ts new file mode 100644 index 000000000..260cee683 --- /dev/null +++ b/packages/models/src/plugins/server/managers/plugin-video-privacy-manager.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { VideoPrivacyType } from '../../../videos/video-privacy.enum.js' | ||
2 | import { ConstantManager } from '../plugin-constant-manager.model.js' | ||
3 | |||
4 | export interface PluginVideoPrivacyManager extends ConstantManager<VideoPrivacyType> { | ||
5 | /** | ||
6 | * PUBLIC = 1, | ||
7 | * UNLISTED = 2, | ||
8 | * PRIVATE = 3 | ||
9 | * INTERNAL = 4 | ||
10 | * @deprecated use `deleteConstant` instead | ||
11 | */ | ||
12 | deletePrivacy: (privacyKey: VideoPrivacyType) => boolean | ||
13 | } | ||
diff --git a/packages/models/src/plugins/server/plugin-constant-manager.model.ts b/packages/models/src/plugins/server/plugin-constant-manager.model.ts new file mode 100644 index 000000000..4de3ce38f --- /dev/null +++ b/packages/models/src/plugins/server/plugin-constant-manager.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface ConstantManager <K extends string | number> { | ||
2 | addConstant: (key: K, label: string) => boolean | ||
3 | deleteConstant: (key: K) => boolean | ||
4 | getConstantValue: (key: K) => string | ||
5 | getConstants: () => Record<K, string> | ||
6 | resetConstants: () => void | ||
7 | } | ||
diff --git a/packages/models/src/plugins/server/plugin-translation.model.ts b/packages/models/src/plugins/server/plugin-translation.model.ts new file mode 100644 index 000000000..a2dd8e560 --- /dev/null +++ b/packages/models/src/plugins/server/plugin-translation.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export type PluginTranslation = { | ||
2 | [ npmName: string ]: { | ||
3 | [ key: string ]: string | ||
4 | } | ||
5 | } | ||
diff --git a/packages/models/src/plugins/server/register-server-hook.model.ts b/packages/models/src/plugins/server/register-server-hook.model.ts new file mode 100644 index 000000000..05c883f1f --- /dev/null +++ b/packages/models/src/plugins/server/register-server-hook.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { ServerHookName } from './server-hook.model.js' | ||
2 | |||
3 | export interface RegisterServerHookOptions { | ||
4 | target: ServerHookName | ||
5 | handler: Function | ||
6 | priority?: number | ||
7 | } | ||
diff --git a/packages/models/src/plugins/server/server-hook.model.ts b/packages/models/src/plugins/server/server-hook.model.ts new file mode 100644 index 000000000..cf387ffd7 --- /dev/null +++ b/packages/models/src/plugins/server/server-hook.model.ts | |||
@@ -0,0 +1,221 @@ | |||
1 | // {hookType}:{root}.{location}.{subLocation?}.{actionType}.{target} | ||
2 | |||
3 | export const serverFilterHookObject = { | ||
4 | // Filter params/result used to list videos for the REST API | ||
5 | // (used by the trending page, recently-added page, local page etc) | ||
6 | 'filter:api.videos.list.params': true, | ||
7 | 'filter:api.videos.list.result': true, | ||
8 | |||
9 | // Filter params/result used to list a video playlists videos | ||
10 | // for the REST API | ||
11 | 'filter:api.video-playlist.videos.list.params': true, | ||
12 | 'filter:api.video-playlist.videos.list.result': true, | ||
13 | |||
14 | // Filter params/result used to list account videos for the REST API | ||
15 | 'filter:api.accounts.videos.list.params': true, | ||
16 | 'filter:api.accounts.videos.list.result': true, | ||
17 | |||
18 | // Filter params/result used to list channel videos for the REST API | ||
19 | 'filter:api.video-channels.videos.list.params': true, | ||
20 | 'filter:api.video-channels.videos.list.result': true, | ||
21 | |||
22 | // Filter params/result used to list my user videos for the REST API | ||
23 | 'filter:api.user.me.videos.list.params': true, | ||
24 | 'filter:api.user.me.videos.list.result': true, | ||
25 | |||
26 | // Filter params/result used to list overview videos for the REST API | ||
27 | 'filter:api.overviews.videos.list.params': true, | ||
28 | 'filter:api.overviews.videos.list.result': true, | ||
29 | |||
30 | // Filter params/result used to list subscription videos for the REST API | ||
31 | 'filter:api.user.me.subscription-videos.list.params': true, | ||
32 | 'filter:api.user.me.subscription-videos.list.result': true, | ||
33 | |||
34 | // Filter params/results to search videos/channels in the DB or on the remote index | ||
35 | 'filter:api.search.videos.local.list.params': true, | ||
36 | 'filter:api.search.videos.local.list.result': true, | ||
37 | 'filter:api.search.videos.index.list.params': true, | ||
38 | 'filter:api.search.videos.index.list.result': true, | ||
39 | 'filter:api.search.video-channels.local.list.params': true, | ||
40 | 'filter:api.search.video-channels.local.list.result': true, | ||
41 | 'filter:api.search.video-channels.index.list.params': true, | ||
42 | 'filter:api.search.video-channels.index.list.result': true, | ||
43 | 'filter:api.search.video-playlists.local.list.params': true, | ||
44 | 'filter:api.search.video-playlists.local.list.result': true, | ||
45 | 'filter:api.search.video-playlists.index.list.params': true, | ||
46 | 'filter:api.search.video-playlists.index.list.result': true, | ||
47 | |||
48 | // Filter the result of the get function | ||
49 | // Used to get detailed video information (video watch page for example) | ||
50 | 'filter:api.video.get.result': true, | ||
51 | |||
52 | // Filter params/results when listing video channels | ||
53 | 'filter:api.video-channels.list.params': true, | ||
54 | 'filter:api.video-channels.list.result': true, | ||
55 | |||
56 | // Filter the result when getting a video channel | ||
57 | 'filter:api.video-channel.get.result': true, | ||
58 | |||
59 | // Filter the result of the accept upload/live, import via torrent/url functions | ||
60 | // If this function returns false then the upload is aborted with an error | ||
61 | 'filter:api.video.upload.accept.result': true, | ||
62 | 'filter:api.live-video.create.accept.result': true, | ||
63 | 'filter:api.video.pre-import-url.accept.result': true, | ||
64 | 'filter:api.video.pre-import-torrent.accept.result': true, | ||
65 | 'filter:api.video.post-import-url.accept.result': true, | ||
66 | 'filter:api.video.post-import-torrent.accept.result': true, | ||
67 | 'filter:api.video.update-file.accept.result': true, | ||
68 | // Filter the result of the accept comment (thread or reply) functions | ||
69 | // If the functions return false then the user cannot post its comment | ||
70 | 'filter:api.video-thread.create.accept.result': true, | ||
71 | 'filter:api.video-comment-reply.create.accept.result': true, | ||
72 | |||
73 | // Filter attributes when creating video object | ||
74 | 'filter:api.video.upload.video-attribute.result': true, | ||
75 | 'filter:api.video.import-url.video-attribute.result': true, | ||
76 | 'filter:api.video.import-torrent.video-attribute.result': true, | ||
77 | 'filter:api.video.live.video-attribute.result': true, | ||
78 | |||
79 | // Filter params/result used to list threads of a specific video | ||
80 | // (used by the video watch page) | ||
81 | 'filter:api.video-threads.list.params': true, | ||
82 | 'filter:api.video-threads.list.result': true, | ||
83 | |||
84 | // Filter params/result used to list replies of a specific thread | ||
85 | // (used by the video watch page when we click on the "View replies" button) | ||
86 | 'filter:api.video-thread-comments.list.params': true, | ||
87 | 'filter:api.video-thread-comments.list.result': true, | ||
88 | |||
89 | // Filter get stats result | ||
90 | 'filter:api.server.stats.get.result': true, | ||
91 | |||
92 | // Filter result used to check if we need to auto blacklist a video | ||
93 | // (fired when a local or remote video is created or updated) | ||
94 | 'filter:video.auto-blacklist.result': true, | ||
95 | |||
96 | // Filter result used to check if a user can register on the instance | ||
97 | 'filter:api.user.signup.allowed.result': true, | ||
98 | |||
99 | // Filter result used to check if a user can send a registration request on the instance | ||
100 | // PeerTube >= 5.1 | ||
101 | 'filter:api.user.request-signup.allowed.result': true, | ||
102 | |||
103 | // Filter result used to check if video/torrent download is allowed | ||
104 | 'filter:api.download.video.allowed.result': true, | ||
105 | 'filter:api.download.torrent.allowed.result': true, | ||
106 | |||
107 | // Filter result to check if the embed is allowed for a particular request | ||
108 | 'filter:html.embed.video.allowed.result': true, | ||
109 | 'filter:html.embed.video-playlist.allowed.result': true, | ||
110 | |||
111 | // Peertube >= 5.2 | ||
112 | 'filter:html.client.json-ld.result': true, | ||
113 | |||
114 | 'filter:job-queue.process.params': true, | ||
115 | 'filter:job-queue.process.result': true, | ||
116 | |||
117 | 'filter:transcoding.manual.resolutions-to-transcode.result': true, | ||
118 | 'filter:transcoding.auto.resolutions-to-transcode.result': true, | ||
119 | |||
120 | 'filter:activity-pub.remote-video-comment.create.accept.result': true, | ||
121 | |||
122 | 'filter:activity-pub.activity.context.build.result': true, | ||
123 | |||
124 | // Filter the result of video JSON LD builder | ||
125 | // You may also need to use filter:activity-pub.activity.context.build.result to also update JSON LD context | ||
126 | 'filter:activity-pub.video.json-ld.build.result': true, | ||
127 | |||
128 | // Filter result to allow custom XMLNS definitions in podcast RSS feeds | ||
129 | // Peertube >= 5.2 | ||
130 | 'filter:feed.podcast.rss.create-custom-xmlns.result': true, | ||
131 | |||
132 | // Filter result to allow custom tags in podcast RSS feeds | ||
133 | // Peertube >= 5.2 | ||
134 | 'filter:feed.podcast.channel.create-custom-tags.result': true, | ||
135 | // Peertube >= 5.2 | ||
136 | 'filter:feed.podcast.video.create-custom-tags.result': true | ||
137 | } | ||
138 | |||
139 | export type ServerFilterHookName = keyof typeof serverFilterHookObject | ||
140 | |||
141 | export const serverActionHookObject = { | ||
142 | // Fired when the application has been loaded and is listening HTTP requests | ||
143 | 'action:application.listening': true, | ||
144 | |||
145 | // Fired when a new notification is created | ||
146 | 'action:notifier.notification.created': true, | ||
147 | |||
148 | // API actions hooks give access to the original express `req` and `res` parameters | ||
149 | |||
150 | // Fired when a local video is updated | ||
151 | 'action:api.video.updated': true, | ||
152 | // Fired when a local video is deleted | ||
153 | 'action:api.video.deleted': true, | ||
154 | // Fired when a local video is uploaded | ||
155 | 'action:api.video.uploaded': true, | ||
156 | // Fired when a local video is viewed | ||
157 | 'action:api.video.viewed': true, | ||
158 | |||
159 | // Fired when a local video file has been replaced by a new one | ||
160 | 'action:api.video.file-updated': true, | ||
161 | |||
162 | // Fired when a video channel is created | ||
163 | 'action:api.video-channel.created': true, | ||
164 | // Fired when a video channel is updated | ||
165 | 'action:api.video-channel.updated': true, | ||
166 | // Fired when a video channel is deleted | ||
167 | 'action:api.video-channel.deleted': true, | ||
168 | |||
169 | // Fired when a live video is created | ||
170 | 'action:api.live-video.created': true, | ||
171 | // Fired when a live video starts or ends | ||
172 | // Peertube >= 5.2 | ||
173 | 'action:live.video.state.updated': true, | ||
174 | |||
175 | // Fired when a thread is created | ||
176 | 'action:api.video-thread.created': true, | ||
177 | // Fired when a reply to a thread is created | ||
178 | 'action:api.video-comment-reply.created': true, | ||
179 | // Fired when a comment (thread or reply) is deleted | ||
180 | 'action:api.video-comment.deleted': true, | ||
181 | |||
182 | // Fired when a caption is created | ||
183 | 'action:api.video-caption.created': true, | ||
184 | // Fired when a caption is deleted | ||
185 | 'action:api.video-caption.deleted': true, | ||
186 | |||
187 | // Fired when a user is blocked (banned) | ||
188 | 'action:api.user.blocked': true, | ||
189 | // Fired when a user is unblocked (unbanned) | ||
190 | 'action:api.user.unblocked': true, | ||
191 | // Fired when a user registered on the instance | ||
192 | 'action:api.user.registered': true, | ||
193 | // Fired when a user requested registration on the instance | ||
194 | // PeerTube >= 5.1 | ||
195 | 'action:api.user.requested-registration': true, | ||
196 | // Fired when an admin/moderator created a user | ||
197 | 'action:api.user.created': true, | ||
198 | // Fired when a user is removed by an admin/moderator | ||
199 | 'action:api.user.deleted': true, | ||
200 | // Fired when a user is updated by an admin/moderator | ||
201 | 'action:api.user.updated': true, | ||
202 | |||
203 | // Fired when a user got a new oauth2 token | ||
204 | 'action:api.user.oauth2-got-token': true, | ||
205 | |||
206 | // Fired when a video is added to a playlist | ||
207 | 'action:api.video-playlist-element.created': true, | ||
208 | |||
209 | // Fired when a remote video has been created/updated | ||
210 | 'action:activity-pub.remote-video.created': true, | ||
211 | 'action:activity-pub.remote-video.updated': true | ||
212 | } | ||
213 | |||
214 | export type ServerActionHookName = keyof typeof serverActionHookObject | ||
215 | |||
216 | export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject) | ||
217 | export type ServerHookName = keyof typeof serverHookObject | ||
218 | |||
219 | export interface ServerHook { | ||
220 | runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> | ||
221 | } | ||
diff --git a/packages/models/src/plugins/server/settings/index.ts b/packages/models/src/plugins/server/settings/index.ts new file mode 100644 index 000000000..4bdccaa4a --- /dev/null +++ b/packages/models/src/plugins/server/settings/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './public-server.setting.js' | ||
2 | export * from './register-server-setting.model.js' | ||
diff --git a/packages/models/src/plugins/server/settings/public-server.setting.ts b/packages/models/src/plugins/server/settings/public-server.setting.ts new file mode 100644 index 000000000..0b6251aa3 --- /dev/null +++ b/packages/models/src/plugins/server/settings/public-server.setting.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { SettingEntries } from '../managers/plugin-settings-manager.model.js' | ||
2 | |||
3 | export interface PublicServerSetting { | ||
4 | publicSettings: SettingEntries | ||
5 | } | ||
diff --git a/packages/models/src/plugins/server/settings/register-server-setting.model.ts b/packages/models/src/plugins/server/settings/register-server-setting.model.ts new file mode 100644 index 000000000..8cde8eaaa --- /dev/null +++ b/packages/models/src/plugins/server/settings/register-server-setting.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | import { RegisterClientFormFieldOptions } from '../../client/index.js' | ||
2 | |||
3 | export type RegisterServerSettingOptions = RegisterClientFormFieldOptions & { | ||
4 | // If the setting is not private, anyone can view its value (client code included) | ||
5 | // If the setting is private, only server-side hooks can access it | ||
6 | // Mainly used by the PeerTube client to get admin config | ||
7 | private: boolean | ||
8 | } | ||
9 | |||
10 | export interface RegisteredServerSettings { | ||
11 | registeredSettings: RegisterServerSettingOptions[] | ||
12 | } | ||
diff --git a/packages/models/src/redundancy/index.ts b/packages/models/src/redundancy/index.ts new file mode 100644 index 000000000..89e8fe464 --- /dev/null +++ b/packages/models/src/redundancy/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './video-redundancies-filters.model.js' | ||
2 | export * from './video-redundancy-config-filter.type.js' | ||
3 | export * from './video-redundancy.model.js' | ||
4 | export * from './videos-redundancy-strategy.model.js' | ||
diff --git a/packages/models/src/redundancy/video-redundancies-filters.model.ts b/packages/models/src/redundancy/video-redundancies-filters.model.ts new file mode 100644 index 000000000..05ba7dfd3 --- /dev/null +++ b/packages/models/src/redundancy/video-redundancies-filters.model.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRedundanciesTarget = 'my-videos' | 'remote-videos' | |||
diff --git a/packages/models/src/redundancy/video-redundancy-config-filter.type.ts b/packages/models/src/redundancy/video-redundancy-config-filter.type.ts new file mode 100644 index 000000000..bb1ae701c --- /dev/null +++ b/packages/models/src/redundancy/video-redundancy-config-filter.type.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRedundancyConfigFilter = 'nobody' | 'anybody' | 'followings' | |||
diff --git a/packages/models/src/redundancy/video-redundancy.model.ts b/packages/models/src/redundancy/video-redundancy.model.ts new file mode 100644 index 000000000..fa6e05832 --- /dev/null +++ b/packages/models/src/redundancy/video-redundancy.model.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | export interface VideoRedundancy { | ||
2 | id: number | ||
3 | name: string | ||
4 | url: string | ||
5 | uuid: string | ||
6 | |||
7 | redundancies: { | ||
8 | files: FileRedundancyInformation[] | ||
9 | |||
10 | streamingPlaylists: StreamingPlaylistRedundancyInformation[] | ||
11 | } | ||
12 | } | ||
13 | |||
14 | interface RedundancyInformation { | ||
15 | id: number | ||
16 | fileUrl: string | ||
17 | strategy: string | ||
18 | |||
19 | createdAt: Date | string | ||
20 | updatedAt: Date | string | ||
21 | |||
22 | expiresOn: Date | string | ||
23 | |||
24 | size: number | ||
25 | } | ||
26 | |||
27 | // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
28 | export interface FileRedundancyInformation extends RedundancyInformation { | ||
29 | |||
30 | } | ||
31 | |||
32 | // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
33 | export interface StreamingPlaylistRedundancyInformation extends RedundancyInformation { | ||
34 | |||
35 | } | ||
diff --git a/packages/models/src/redundancy/videos-redundancy-strategy.model.ts b/packages/models/src/redundancy/videos-redundancy-strategy.model.ts new file mode 100644 index 000000000..15409abf0 --- /dev/null +++ b/packages/models/src/redundancy/videos-redundancy-strategy.model.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | export type VideoRedundancyStrategy = 'most-views' | 'trending' | 'recently-added' | ||
2 | export type VideoRedundancyStrategyWithManual = VideoRedundancyStrategy | 'manual' | ||
3 | |||
4 | export type MostViewsRedundancyStrategy = { | ||
5 | strategy: 'most-views' | ||
6 | size: number | ||
7 | minLifetime: number | ||
8 | } | ||
9 | |||
10 | export type TrendingRedundancyStrategy = { | ||
11 | strategy: 'trending' | ||
12 | size: number | ||
13 | minLifetime: number | ||
14 | } | ||
15 | |||
16 | export type RecentlyAddedStrategy = { | ||
17 | strategy: 'recently-added' | ||
18 | size: number | ||
19 | minViews: number | ||
20 | minLifetime: number | ||
21 | } | ||
22 | |||
23 | export type VideosRedundancyStrategy = MostViewsRedundancyStrategy | TrendingRedundancyStrategy | RecentlyAddedStrategy | ||
diff --git a/packages/models/src/runners/abort-runner-job-body.model.ts b/packages/models/src/runners/abort-runner-job-body.model.ts new file mode 100644 index 000000000..0b9c46c91 --- /dev/null +++ b/packages/models/src/runners/abort-runner-job-body.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface AbortRunnerJobBody { | ||
2 | runnerToken: string | ||
3 | jobToken: string | ||
4 | |||
5 | reason: string | ||
6 | } | ||
diff --git a/packages/models/src/runners/accept-runner-job-body.model.ts b/packages/models/src/runners/accept-runner-job-body.model.ts new file mode 100644 index 000000000..cb266c4e6 --- /dev/null +++ b/packages/models/src/runners/accept-runner-job-body.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface AcceptRunnerJobBody { | ||
2 | runnerToken: string | ||
3 | } | ||
diff --git a/packages/models/src/runners/accept-runner-job-result.model.ts b/packages/models/src/runners/accept-runner-job-result.model.ts new file mode 100644 index 000000000..ebb605930 --- /dev/null +++ b/packages/models/src/runners/accept-runner-job-result.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | import { RunnerJobPayload } from './runner-job-payload.model.js' | ||
2 | import { RunnerJob } from './runner-job.model.js' | ||
3 | |||
4 | export interface AcceptRunnerJobResult <T extends RunnerJobPayload = RunnerJobPayload> { | ||
5 | job: RunnerJob<T> & { jobToken: string } | ||
6 | } | ||
diff --git a/packages/models/src/runners/error-runner-job-body.model.ts b/packages/models/src/runners/error-runner-job-body.model.ts new file mode 100644 index 000000000..ac8568409 --- /dev/null +++ b/packages/models/src/runners/error-runner-job-body.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface ErrorRunnerJobBody { | ||
2 | runnerToken: string | ||
3 | jobToken: string | ||
4 | |||
5 | message: string | ||
6 | } | ||
diff --git a/packages/models/src/runners/index.ts b/packages/models/src/runners/index.ts new file mode 100644 index 000000000..cfe997b64 --- /dev/null +++ b/packages/models/src/runners/index.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | export * from './abort-runner-job-body.model.js' | ||
2 | export * from './accept-runner-job-body.model.js' | ||
3 | export * from './accept-runner-job-result.model.js' | ||
4 | export * from './error-runner-job-body.model.js' | ||
5 | export * from './list-runner-jobs-query.model.js' | ||
6 | export * from './list-runner-registration-tokens.model.js' | ||
7 | export * from './list-runners-query.model.js' | ||
8 | export * from './register-runner-body.model.js' | ||
9 | export * from './register-runner-result.model.js' | ||
10 | export * from './request-runner-job-body.model.js' | ||
11 | export * from './request-runner-job-result.model.js' | ||
12 | export * from './runner-job-payload.model.js' | ||
13 | export * from './runner-job-private-payload.model.js' | ||
14 | export * from './runner-job-state.model.js' | ||
15 | export * from './runner-job-success-body.model.js' | ||
16 | export * from './runner-job-type.type.js' | ||
17 | export * from './runner-job-update-body.model.js' | ||
18 | export * from './runner-job.model.js' | ||
19 | export * from './runner-registration-token.js' | ||
20 | export * from './runner.model.js' | ||
21 | export * from './unregister-runner-body.model.js' | ||
diff --git a/packages/models/src/runners/list-runner-jobs-query.model.ts b/packages/models/src/runners/list-runner-jobs-query.model.ts new file mode 100644 index 000000000..395fe4b92 --- /dev/null +++ b/packages/models/src/runners/list-runner-jobs-query.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { RunnerJobStateType } from './runner-job-state.model.js' | ||
2 | |||
3 | export interface ListRunnerJobsQuery { | ||
4 | start?: number | ||
5 | count?: number | ||
6 | sort?: string | ||
7 | search?: string | ||
8 | stateOneOf?: RunnerJobStateType[] | ||
9 | } | ||
diff --git a/packages/models/src/runners/list-runner-registration-tokens.model.ts b/packages/models/src/runners/list-runner-registration-tokens.model.ts new file mode 100644 index 000000000..872e059cf --- /dev/null +++ b/packages/models/src/runners/list-runner-registration-tokens.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface ListRunnerRegistrationTokensQuery { | ||
2 | start?: number | ||
3 | count?: number | ||
4 | sort?: string | ||
5 | } | ||
diff --git a/packages/models/src/runners/list-runners-query.model.ts b/packages/models/src/runners/list-runners-query.model.ts new file mode 100644 index 000000000..d4362e4c5 --- /dev/null +++ b/packages/models/src/runners/list-runners-query.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface ListRunnersQuery { | ||
2 | start?: number | ||
3 | count?: number | ||
4 | sort?: string | ||
5 | } | ||
diff --git a/packages/models/src/runners/register-runner-body.model.ts b/packages/models/src/runners/register-runner-body.model.ts new file mode 100644 index 000000000..969bb35e1 --- /dev/null +++ b/packages/models/src/runners/register-runner-body.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface RegisterRunnerBody { | ||
2 | registrationToken: string | ||
3 | |||
4 | name: string | ||
5 | description?: string | ||
6 | } | ||
diff --git a/packages/models/src/runners/register-runner-result.model.ts b/packages/models/src/runners/register-runner-result.model.ts new file mode 100644 index 000000000..e31776c6a --- /dev/null +++ b/packages/models/src/runners/register-runner-result.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface RegisterRunnerResult { | ||
2 | id: number | ||
3 | runnerToken: string | ||
4 | } | ||
diff --git a/packages/models/src/runners/request-runner-job-body.model.ts b/packages/models/src/runners/request-runner-job-body.model.ts new file mode 100644 index 000000000..0970d9007 --- /dev/null +++ b/packages/models/src/runners/request-runner-job-body.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface RequestRunnerJobBody { | ||
2 | runnerToken: string | ||
3 | } | ||
diff --git a/packages/models/src/runners/request-runner-job-result.model.ts b/packages/models/src/runners/request-runner-job-result.model.ts new file mode 100644 index 000000000..30c8c640c --- /dev/null +++ b/packages/models/src/runners/request-runner-job-result.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { RunnerJobPayload } from './runner-job-payload.model.js' | ||
2 | import { RunnerJobType } from './runner-job-type.type.js' | ||
3 | |||
4 | export interface RequestRunnerJobResult <P extends RunnerJobPayload = RunnerJobPayload> { | ||
5 | availableJobs: { | ||
6 | uuid: string | ||
7 | type: RunnerJobType | ||
8 | payload: P | ||
9 | }[] | ||
10 | } | ||
diff --git a/packages/models/src/runners/runner-job-payload.model.ts b/packages/models/src/runners/runner-job-payload.model.ts new file mode 100644 index 000000000..19b9d649b --- /dev/null +++ b/packages/models/src/runners/runner-job-payload.model.ts | |||
@@ -0,0 +1,79 @@ | |||
1 | import { VideoStudioTaskPayload } from '../server/index.js' | ||
2 | |||
3 | export type RunnerJobVODPayload = | ||
4 | RunnerJobVODWebVideoTranscodingPayload | | ||
5 | RunnerJobVODHLSTranscodingPayload | | ||
6 | RunnerJobVODAudioMergeTranscodingPayload | ||
7 | |||
8 | export type RunnerJobPayload = | ||
9 | RunnerJobVODPayload | | ||
10 | RunnerJobLiveRTMPHLSTranscodingPayload | | ||
11 | RunnerJobStudioTranscodingPayload | ||
12 | |||
13 | // --------------------------------------------------------------------------- | ||
14 | |||
15 | export interface RunnerJobVODWebVideoTranscodingPayload { | ||
16 | input: { | ||
17 | videoFileUrl: string | ||
18 | } | ||
19 | |||
20 | output: { | ||
21 | resolution: number | ||
22 | fps: number | ||
23 | } | ||
24 | } | ||
25 | |||
26 | export interface RunnerJobVODHLSTranscodingPayload { | ||
27 | input: { | ||
28 | videoFileUrl: string | ||
29 | } | ||
30 | |||
31 | output: { | ||
32 | resolution: number | ||
33 | fps: number | ||
34 | } | ||
35 | } | ||
36 | |||
37 | export interface RunnerJobVODAudioMergeTranscodingPayload { | ||
38 | input: { | ||
39 | audioFileUrl: string | ||
40 | previewFileUrl: string | ||
41 | } | ||
42 | |||
43 | output: { | ||
44 | resolution: number | ||
45 | fps: number | ||
46 | } | ||
47 | } | ||
48 | |||
49 | export interface RunnerJobStudioTranscodingPayload { | ||
50 | input: { | ||
51 | videoFileUrl: string | ||
52 | } | ||
53 | |||
54 | tasks: VideoStudioTaskPayload[] | ||
55 | } | ||
56 | |||
57 | // --------------------------------------------------------------------------- | ||
58 | |||
59 | export function isAudioMergeTranscodingPayload (payload: RunnerJobPayload): payload is RunnerJobVODAudioMergeTranscodingPayload { | ||
60 | return !!(payload as RunnerJobVODAudioMergeTranscodingPayload).input.audioFileUrl | ||
61 | } | ||
62 | |||
63 | // --------------------------------------------------------------------------- | ||
64 | |||
65 | export interface RunnerJobLiveRTMPHLSTranscodingPayload { | ||
66 | input: { | ||
67 | rtmpUrl: string | ||
68 | } | ||
69 | |||
70 | output: { | ||
71 | toTranscode: { | ||
72 | resolution: number | ||
73 | fps: number | ||
74 | }[] | ||
75 | |||
76 | segmentDuration: number | ||
77 | segmentListSize: number | ||
78 | } | ||
79 | } | ||
diff --git a/packages/models/src/runners/runner-job-private-payload.model.ts b/packages/models/src/runners/runner-job-private-payload.model.ts new file mode 100644 index 000000000..c1205984e --- /dev/null +++ b/packages/models/src/runners/runner-job-private-payload.model.ts | |||
@@ -0,0 +1,45 @@ | |||
1 | import { VideoStudioTaskPayload } from '../server/index.js' | ||
2 | |||
3 | export type RunnerJobVODPrivatePayload = | ||
4 | RunnerJobVODWebVideoTranscodingPrivatePayload | | ||
5 | RunnerJobVODAudioMergeTranscodingPrivatePayload | | ||
6 | RunnerJobVODHLSTranscodingPrivatePayload | ||
7 | |||
8 | export type RunnerJobPrivatePayload = | ||
9 | RunnerJobVODPrivatePayload | | ||
10 | RunnerJobLiveRTMPHLSTranscodingPrivatePayload | | ||
11 | RunnerJobVideoStudioTranscodingPrivatePayload | ||
12 | |||
13 | // --------------------------------------------------------------------------- | ||
14 | |||
15 | export interface RunnerJobVODWebVideoTranscodingPrivatePayload { | ||
16 | videoUUID: string | ||
17 | isNewVideo: boolean | ||
18 | } | ||
19 | |||
20 | export interface RunnerJobVODAudioMergeTranscodingPrivatePayload { | ||
21 | videoUUID: string | ||
22 | isNewVideo: boolean | ||
23 | } | ||
24 | |||
25 | export interface RunnerJobVODHLSTranscodingPrivatePayload { | ||
26 | videoUUID: string | ||
27 | isNewVideo: boolean | ||
28 | deleteWebVideoFiles: boolean | ||
29 | } | ||
30 | |||
31 | // --------------------------------------------------------------------------- | ||
32 | |||
33 | export interface RunnerJobLiveRTMPHLSTranscodingPrivatePayload { | ||
34 | videoUUID: string | ||
35 | masterPlaylistName: string | ||
36 | outputDirectory: string | ||
37 | sessionId: string | ||
38 | } | ||
39 | |||
40 | // --------------------------------------------------------------------------- | ||
41 | |||
42 | export interface RunnerJobVideoStudioTranscodingPrivatePayload { | ||
43 | videoUUID: string | ||
44 | originalTasks: VideoStudioTaskPayload[] | ||
45 | } | ||
diff --git a/packages/models/src/runners/runner-job-state.model.ts b/packages/models/src/runners/runner-job-state.model.ts new file mode 100644 index 000000000..07e135121 --- /dev/null +++ b/packages/models/src/runners/runner-job-state.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | export const RunnerJobState = { | ||
2 | PENDING: 1, | ||
3 | PROCESSING: 2, | ||
4 | COMPLETED: 3, | ||
5 | ERRORED: 4, | ||
6 | WAITING_FOR_PARENT_JOB: 5, | ||
7 | CANCELLED: 6, | ||
8 | PARENT_ERRORED: 7, | ||
9 | PARENT_CANCELLED: 8, | ||
10 | COMPLETING: 9 | ||
11 | } as const | ||
12 | |||
13 | export type RunnerJobStateType = typeof RunnerJobState[keyof typeof RunnerJobState] | ||
diff --git a/packages/models/src/runners/runner-job-success-body.model.ts b/packages/models/src/runners/runner-job-success-body.model.ts new file mode 100644 index 000000000..f45336b05 --- /dev/null +++ b/packages/models/src/runners/runner-job-success-body.model.ts | |||
@@ -0,0 +1,46 @@ | |||
1 | export interface RunnerJobSuccessBody { | ||
2 | runnerToken: string | ||
3 | jobToken: string | ||
4 | |||
5 | payload: RunnerJobSuccessPayload | ||
6 | } | ||
7 | |||
8 | // --------------------------------------------------------------------------- | ||
9 | |||
10 | export type RunnerJobSuccessPayload = | ||
11 | VODWebVideoTranscodingSuccess | | ||
12 | VODHLSTranscodingSuccess | | ||
13 | VODAudioMergeTranscodingSuccess | | ||
14 | LiveRTMPHLSTranscodingSuccess | | ||
15 | VideoStudioTranscodingSuccess | ||
16 | |||
17 | export interface VODWebVideoTranscodingSuccess { | ||
18 | videoFile: Blob | string | ||
19 | } | ||
20 | |||
21 | export interface VODHLSTranscodingSuccess { | ||
22 | videoFile: Blob | string | ||
23 | resolutionPlaylistFile: Blob | string | ||
24 | } | ||
25 | |||
26 | export interface VODAudioMergeTranscodingSuccess { | ||
27 | videoFile: Blob | string | ||
28 | } | ||
29 | |||
30 | export interface LiveRTMPHLSTranscodingSuccess { | ||
31 | |||
32 | } | ||
33 | |||
34 | export interface VideoStudioTranscodingSuccess { | ||
35 | videoFile: Blob | string | ||
36 | } | ||
37 | |||
38 | export function isWebVideoOrAudioMergeTranscodingPayloadSuccess ( | ||
39 | payload: RunnerJobSuccessPayload | ||
40 | ): payload is VODHLSTranscodingSuccess | VODAudioMergeTranscodingSuccess { | ||
41 | return !!(payload as VODHLSTranscodingSuccess | VODAudioMergeTranscodingSuccess)?.videoFile | ||
42 | } | ||
43 | |||
44 | export function isHLSTranscodingPayloadSuccess (payload: RunnerJobSuccessPayload): payload is VODHLSTranscodingSuccess { | ||
45 | return !!(payload as VODHLSTranscodingSuccess)?.resolutionPlaylistFile | ||
46 | } | ||
diff --git a/packages/models/src/runners/runner-job-type.type.ts b/packages/models/src/runners/runner-job-type.type.ts new file mode 100644 index 000000000..91b92a729 --- /dev/null +++ b/packages/models/src/runners/runner-job-type.type.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export type RunnerJobType = | ||
2 | 'vod-web-video-transcoding' | | ||
3 | 'vod-hls-transcoding' | | ||
4 | 'vod-audio-merge-transcoding' | | ||
5 | 'live-rtmp-hls-transcoding' | | ||
6 | 'video-studio-transcoding' | ||
diff --git a/packages/models/src/runners/runner-job-update-body.model.ts b/packages/models/src/runners/runner-job-update-body.model.ts new file mode 100644 index 000000000..ed94bbe63 --- /dev/null +++ b/packages/models/src/runners/runner-job-update-body.model.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | export interface RunnerJobUpdateBody { | ||
2 | runnerToken: string | ||
3 | jobToken: string | ||
4 | |||
5 | progress?: number | ||
6 | payload?: RunnerJobUpdatePayload | ||
7 | } | ||
8 | |||
9 | // --------------------------------------------------------------------------- | ||
10 | |||
11 | export type RunnerJobUpdatePayload = LiveRTMPHLSTranscodingUpdatePayload | ||
12 | |||
13 | export interface LiveRTMPHLSTranscodingUpdatePayload { | ||
14 | type: 'add-chunk' | 'remove-chunk' | ||
15 | |||
16 | masterPlaylistFile?: Blob | string | ||
17 | |||
18 | resolutionPlaylistFilename?: string | ||
19 | resolutionPlaylistFile?: Blob | string | ||
20 | |||
21 | videoChunkFilename: string | ||
22 | videoChunkFile?: Blob | string | ||
23 | } | ||
24 | |||
25 | export function isLiveRTMPHLSTranscodingUpdatePayload (value: RunnerJobUpdatePayload): value is LiveRTMPHLSTranscodingUpdatePayload { | ||
26 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
27 | return !!(value as LiveRTMPHLSTranscodingUpdatePayload)?.videoChunkFilename | ||
28 | } | ||
diff --git a/packages/models/src/runners/runner-job.model.ts b/packages/models/src/runners/runner-job.model.ts new file mode 100644 index 000000000..6d6427396 --- /dev/null +++ b/packages/models/src/runners/runner-job.model.ts | |||
@@ -0,0 +1,45 @@ | |||
1 | import { VideoConstant } from '../videos/index.js' | ||
2 | import { RunnerJobPayload } from './runner-job-payload.model.js' | ||
3 | import { RunnerJobPrivatePayload } from './runner-job-private-payload.model.js' | ||
4 | import { RunnerJobStateType } from './runner-job-state.model.js' | ||
5 | import { RunnerJobType } from './runner-job-type.type.js' | ||
6 | |||
7 | export interface RunnerJob <T extends RunnerJobPayload = RunnerJobPayload> { | ||
8 | uuid: string | ||
9 | |||
10 | type: RunnerJobType | ||
11 | |||
12 | state: VideoConstant<RunnerJobStateType> | ||
13 | |||
14 | payload: T | ||
15 | |||
16 | failures: number | ||
17 | error: string | null | ||
18 | |||
19 | progress: number | ||
20 | priority: number | ||
21 | |||
22 | startedAt: Date | string | ||
23 | createdAt: Date | string | ||
24 | updatedAt: Date | string | ||
25 | finishedAt: Date | string | ||
26 | |||
27 | parent?: { | ||
28 | type: RunnerJobType | ||
29 | state: VideoConstant<RunnerJobStateType> | ||
30 | uuid: string | ||
31 | } | ||
32 | |||
33 | // If associated to a runner | ||
34 | runner?: { | ||
35 | id: number | ||
36 | name: string | ||
37 | |||
38 | description: string | ||
39 | } | ||
40 | } | ||
41 | |||
42 | // eslint-disable-next-line max-len | ||
43 | export interface RunnerJobAdmin <T extends RunnerJobPayload = RunnerJobPayload, U extends RunnerJobPrivatePayload = RunnerJobPrivatePayload> extends RunnerJob<T> { | ||
44 | privatePayload: U | ||
45 | } | ||
diff --git a/packages/models/src/runners/runner-registration-token.ts b/packages/models/src/runners/runner-registration-token.ts new file mode 100644 index 000000000..0a157aa51 --- /dev/null +++ b/packages/models/src/runners/runner-registration-token.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export interface RunnerRegistrationToken { | ||
2 | id: number | ||
3 | |||
4 | registrationToken: string | ||
5 | |||
6 | createdAt: Date | ||
7 | updatedAt: Date | ||
8 | |||
9 | registeredRunnersCount: number | ||
10 | } | ||
diff --git a/packages/models/src/runners/runner.model.ts b/packages/models/src/runners/runner.model.ts new file mode 100644 index 000000000..3284f2992 --- /dev/null +++ b/packages/models/src/runners/runner.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | export interface Runner { | ||
2 | id: number | ||
3 | |||
4 | name: string | ||
5 | description: string | ||
6 | |||
7 | ip: string | ||
8 | lastContact: Date | string | ||
9 | |||
10 | createdAt: Date | string | ||
11 | updatedAt: Date | string | ||
12 | } | ||
diff --git a/packages/models/src/runners/unregister-runner-body.model.ts b/packages/models/src/runners/unregister-runner-body.model.ts new file mode 100644 index 000000000..d3465c5d6 --- /dev/null +++ b/packages/models/src/runners/unregister-runner-body.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface UnregisterRunnerBody { | ||
2 | runnerToken: string | ||
3 | } | ||
diff --git a/packages/models/src/search/boolean-both-query.model.ts b/packages/models/src/search/boolean-both-query.model.ts new file mode 100644 index 000000000..d6a438249 --- /dev/null +++ b/packages/models/src/search/boolean-both-query.model.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export type BooleanBothQuery = 'true' | 'false' | 'both' | ||
2 | export type BooleanQuery = 'true' | 'false' | ||
diff --git a/packages/models/src/search/index.ts b/packages/models/src/search/index.ts new file mode 100644 index 000000000..5c4de1eea --- /dev/null +++ b/packages/models/src/search/index.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export * from './boolean-both-query.model.js' | ||
2 | export * from './search-target-query.model.js' | ||
3 | export * from './videos-common-query.model.js' | ||
4 | export * from './video-channels-search-query.model.js' | ||
5 | export * from './video-playlists-search-query.model.js' | ||
6 | export * from './videos-search-query.model.js' | ||
diff --git a/packages/models/src/search/search-target-query.model.ts b/packages/models/src/search/search-target-query.model.ts new file mode 100644 index 000000000..3bb2e0d31 --- /dev/null +++ b/packages/models/src/search/search-target-query.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export type SearchTargetType = 'local' | 'search-index' | ||
2 | |||
3 | export interface SearchTargetQuery { | ||
4 | searchTarget?: SearchTargetType | ||
5 | } | ||
diff --git a/packages/models/src/search/video-channels-search-query.model.ts b/packages/models/src/search/video-channels-search-query.model.ts new file mode 100644 index 000000000..7e84359cf --- /dev/null +++ b/packages/models/src/search/video-channels-search-query.model.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { SearchTargetQuery } from './search-target-query.model.js' | ||
2 | |||
3 | export interface VideoChannelsSearchQuery extends SearchTargetQuery { | ||
4 | search?: string | ||
5 | |||
6 | start?: number | ||
7 | count?: number | ||
8 | sort?: string | ||
9 | |||
10 | host?: string | ||
11 | handles?: string[] | ||
12 | } | ||
13 | |||
14 | export interface VideoChannelsSearchQueryAfterSanitize extends VideoChannelsSearchQuery { | ||
15 | start: number | ||
16 | count: number | ||
17 | sort: string | ||
18 | } | ||
diff --git a/packages/models/src/search/video-playlists-search-query.model.ts b/packages/models/src/search/video-playlists-search-query.model.ts new file mode 100644 index 000000000..65ac7b4d7 --- /dev/null +++ b/packages/models/src/search/video-playlists-search-query.model.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import { SearchTargetQuery } from './search-target-query.model.js' | ||
2 | |||
3 | export interface VideoPlaylistsSearchQuery extends SearchTargetQuery { | ||
4 | search?: string | ||
5 | |||
6 | start?: number | ||
7 | count?: number | ||
8 | sort?: string | ||
9 | |||
10 | host?: string | ||
11 | |||
12 | // UUIDs or short UUIDs | ||
13 | uuids?: string[] | ||
14 | } | ||
15 | |||
16 | export interface VideoPlaylistsSearchQueryAfterSanitize extends VideoPlaylistsSearchQuery { | ||
17 | start: number | ||
18 | count: number | ||
19 | sort: string | ||
20 | } | ||
diff --git a/packages/models/src/search/videos-common-query.model.ts b/packages/models/src/search/videos-common-query.model.ts new file mode 100644 index 000000000..45181a739 --- /dev/null +++ b/packages/models/src/search/videos-common-query.model.ts | |||
@@ -0,0 +1,45 @@ | |||
1 | import { VideoIncludeType } from '../videos/video-include.enum.js' | ||
2 | import { VideoPrivacyType } from '../videos/video-privacy.enum.js' | ||
3 | import { BooleanBothQuery } from './boolean-both-query.model.js' | ||
4 | |||
5 | // These query parameters can be used with any endpoint that list videos | ||
6 | export interface VideosCommonQuery { | ||
7 | start?: number | ||
8 | count?: number | ||
9 | sort?: string | ||
10 | |||
11 | nsfw?: BooleanBothQuery | ||
12 | |||
13 | isLive?: boolean | ||
14 | |||
15 | isLocal?: boolean | ||
16 | include?: VideoIncludeType | ||
17 | |||
18 | categoryOneOf?: number[] | ||
19 | |||
20 | licenceOneOf?: number[] | ||
21 | |||
22 | languageOneOf?: string[] | ||
23 | |||
24 | privacyOneOf?: VideoPrivacyType[] | ||
25 | |||
26 | tagsOneOf?: string[] | ||
27 | tagsAllOf?: string[] | ||
28 | |||
29 | hasHLSFiles?: boolean | ||
30 | |||
31 | hasWebtorrentFiles?: boolean // TODO: remove in v7 | ||
32 | hasWebVideoFiles?: boolean | ||
33 | |||
34 | skipCount?: boolean | ||
35 | |||
36 | search?: string | ||
37 | |||
38 | excludeAlreadyWatched?: boolean | ||
39 | } | ||
40 | |||
41 | export interface VideosCommonQueryAfterSanitize extends VideosCommonQuery { | ||
42 | start: number | ||
43 | count: number | ||
44 | sort: string | ||
45 | } | ||
diff --git a/packages/models/src/search/videos-search-query.model.ts b/packages/models/src/search/videos-search-query.model.ts new file mode 100644 index 000000000..bbaa8d23f --- /dev/null +++ b/packages/models/src/search/videos-search-query.model.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import { SearchTargetQuery } from './search-target-query.model.js' | ||
2 | import { VideosCommonQuery } from './videos-common-query.model.js' | ||
3 | |||
4 | export interface VideosSearchQuery extends SearchTargetQuery, VideosCommonQuery { | ||
5 | search?: string | ||
6 | |||
7 | host?: string | ||
8 | |||
9 | startDate?: string // ISO 8601 | ||
10 | endDate?: string // ISO 8601 | ||
11 | |||
12 | originallyPublishedStartDate?: string // ISO 8601 | ||
13 | originallyPublishedEndDate?: string // ISO 8601 | ||
14 | |||
15 | durationMin?: number // seconds | ||
16 | durationMax?: number // seconds | ||
17 | |||
18 | // UUIDs or short UUIDs | ||
19 | uuids?: string[] | ||
20 | } | ||
21 | |||
22 | export interface VideosSearchQueryAfterSanitize extends VideosSearchQuery { | ||
23 | start: number | ||
24 | count: number | ||
25 | sort: string | ||
26 | } | ||
diff --git a/packages/models/src/server/about.model.ts b/packages/models/src/server/about.model.ts new file mode 100644 index 000000000..6d4ba63c4 --- /dev/null +++ b/packages/models/src/server/about.model.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | export interface About { | ||
2 | instance: { | ||
3 | name: string | ||
4 | shortDescription: string | ||
5 | description: string | ||
6 | terms: string | ||
7 | |||
8 | codeOfConduct: string | ||
9 | hardwareInformation: string | ||
10 | |||
11 | creationReason: string | ||
12 | moderationInformation: string | ||
13 | administrator: string | ||
14 | maintenanceLifetime: string | ||
15 | businessModel: string | ||
16 | |||
17 | languages: string[] | ||
18 | categories: number[] | ||
19 | } | ||
20 | } | ||
diff --git a/packages/models/src/server/broadcast-message-level.type.ts b/packages/models/src/server/broadcast-message-level.type.ts new file mode 100644 index 000000000..bf43e18b5 --- /dev/null +++ b/packages/models/src/server/broadcast-message-level.type.ts | |||
@@ -0,0 +1 @@ | |||
export type BroadcastMessageLevel = 'info' | 'warning' | 'error' | |||
diff --git a/packages/models/src/server/client-log-create.model.ts b/packages/models/src/server/client-log-create.model.ts new file mode 100644 index 000000000..543af0d3d --- /dev/null +++ b/packages/models/src/server/client-log-create.model.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { ClientLogLevel } from './client-log-level.type.js' | ||
2 | |||
3 | export interface ClientLogCreate { | ||
4 | message: string | ||
5 | url: string | ||
6 | level: ClientLogLevel | ||
7 | |||
8 | stackTrace?: string | ||
9 | userAgent?: string | ||
10 | meta?: string | ||
11 | } | ||
diff --git a/packages/models/src/server/client-log-level.type.ts b/packages/models/src/server/client-log-level.type.ts new file mode 100644 index 000000000..18dea2751 --- /dev/null +++ b/packages/models/src/server/client-log-level.type.ts | |||
@@ -0,0 +1 @@ | |||
export type ClientLogLevel = 'warn' | 'error' | |||
diff --git a/packages/models/src/server/contact-form.model.ts b/packages/models/src/server/contact-form.model.ts new file mode 100644 index 000000000..c23e6d1ba --- /dev/null +++ b/packages/models/src/server/contact-form.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface ContactForm { | ||
2 | fromEmail: string | ||
3 | fromName: string | ||
4 | subject: string | ||
5 | body: string | ||
6 | } | ||
diff --git a/packages/models/src/server/custom-config.model.ts b/packages/models/src/server/custom-config.model.ts new file mode 100644 index 000000000..df4176ba7 --- /dev/null +++ b/packages/models/src/server/custom-config.model.ts | |||
@@ -0,0 +1,259 @@ | |||
1 | import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' | ||
2 | import { BroadcastMessageLevel } from './broadcast-message-level.type.js' | ||
3 | |||
4 | export type ConfigResolutions = { | ||
5 | '144p': boolean | ||
6 | '240p': boolean | ||
7 | '360p': boolean | ||
8 | '480p': boolean | ||
9 | '720p': boolean | ||
10 | '1080p': boolean | ||
11 | '1440p': boolean | ||
12 | '2160p': boolean | ||
13 | } | ||
14 | |||
15 | export interface CustomConfig { | ||
16 | instance: { | ||
17 | name: string | ||
18 | shortDescription: string | ||
19 | description: string | ||
20 | terms: string | ||
21 | codeOfConduct: string | ||
22 | |||
23 | creationReason: string | ||
24 | moderationInformation: string | ||
25 | administrator: string | ||
26 | maintenanceLifetime: string | ||
27 | businessModel: string | ||
28 | hardwareInformation: string | ||
29 | |||
30 | languages: string[] | ||
31 | categories: number[] | ||
32 | |||
33 | isNSFW: boolean | ||
34 | defaultNSFWPolicy: NSFWPolicyType | ||
35 | |||
36 | defaultClientRoute: string | ||
37 | |||
38 | customizations: { | ||
39 | javascript?: string | ||
40 | css?: string | ||
41 | } | ||
42 | } | ||
43 | |||
44 | theme: { | ||
45 | default: string | ||
46 | } | ||
47 | |||
48 | services: { | ||
49 | twitter: { | ||
50 | username: string | ||
51 | whitelisted: boolean | ||
52 | } | ||
53 | } | ||
54 | |||
55 | client: { | ||
56 | videos: { | ||
57 | miniature: { | ||
58 | preferAuthorDisplayName: boolean | ||
59 | } | ||
60 | } | ||
61 | |||
62 | menu: { | ||
63 | login: { | ||
64 | redirectOnSingleExternalAuth: boolean | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | cache: { | ||
70 | previews: { | ||
71 | size: number | ||
72 | } | ||
73 | |||
74 | captions: { | ||
75 | size: number | ||
76 | } | ||
77 | |||
78 | torrents: { | ||
79 | size: number | ||
80 | } | ||
81 | |||
82 | storyboards: { | ||
83 | size: number | ||
84 | } | ||
85 | } | ||
86 | |||
87 | signup: { | ||
88 | enabled: boolean | ||
89 | limit: number | ||
90 | requiresApproval: boolean | ||
91 | requiresEmailVerification: boolean | ||
92 | minimumAge: number | ||
93 | } | ||
94 | |||
95 | admin: { | ||
96 | email: string | ||
97 | } | ||
98 | |||
99 | contactForm: { | ||
100 | enabled: boolean | ||
101 | } | ||
102 | |||
103 | user: { | ||
104 | history: { | ||
105 | videos: { | ||
106 | enabled: boolean | ||
107 | } | ||
108 | } | ||
109 | videoQuota: number | ||
110 | videoQuotaDaily: number | ||
111 | } | ||
112 | |||
113 | videoChannels: { | ||
114 | maxPerUser: number | ||
115 | } | ||
116 | |||
117 | transcoding: { | ||
118 | enabled: boolean | ||
119 | |||
120 | allowAdditionalExtensions: boolean | ||
121 | allowAudioFiles: boolean | ||
122 | |||
123 | remoteRunners: { | ||
124 | enabled: boolean | ||
125 | } | ||
126 | |||
127 | threads: number | ||
128 | concurrency: number | ||
129 | |||
130 | profile: string | ||
131 | |||
132 | resolutions: ConfigResolutions & { '0p': boolean } | ||
133 | |||
134 | alwaysTranscodeOriginalResolution: boolean | ||
135 | |||
136 | webVideos: { | ||
137 | enabled: boolean | ||
138 | } | ||
139 | |||
140 | hls: { | ||
141 | enabled: boolean | ||
142 | } | ||
143 | } | ||
144 | |||
145 | live: { | ||
146 | enabled: boolean | ||
147 | |||
148 | allowReplay: boolean | ||
149 | |||
150 | latencySetting: { | ||
151 | enabled: boolean | ||
152 | } | ||
153 | |||
154 | maxDuration: number | ||
155 | maxInstanceLives: number | ||
156 | maxUserLives: number | ||
157 | |||
158 | transcoding: { | ||
159 | enabled: boolean | ||
160 | remoteRunners: { | ||
161 | enabled: boolean | ||
162 | } | ||
163 | threads: number | ||
164 | profile: string | ||
165 | resolutions: ConfigResolutions | ||
166 | alwaysTranscodeOriginalResolution: boolean | ||
167 | } | ||
168 | } | ||
169 | |||
170 | videoStudio: { | ||
171 | enabled: boolean | ||
172 | |||
173 | remoteRunners: { | ||
174 | enabled: boolean | ||
175 | } | ||
176 | } | ||
177 | |||
178 | videoFile: { | ||
179 | update: { | ||
180 | enabled: boolean | ||
181 | } | ||
182 | } | ||
183 | |||
184 | import: { | ||
185 | videos: { | ||
186 | concurrency: number | ||
187 | |||
188 | http: { | ||
189 | enabled: boolean | ||
190 | } | ||
191 | torrent: { | ||
192 | enabled: boolean | ||
193 | } | ||
194 | } | ||
195 | videoChannelSynchronization: { | ||
196 | enabled: boolean | ||
197 | maxPerUser: number | ||
198 | } | ||
199 | } | ||
200 | |||
201 | trending: { | ||
202 | videos: { | ||
203 | algorithms: { | ||
204 | enabled: string[] | ||
205 | default: string | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | |||
210 | autoBlacklist: { | ||
211 | videos: { | ||
212 | ofUsers: { | ||
213 | enabled: boolean | ||
214 | } | ||
215 | } | ||
216 | } | ||
217 | |||
218 | followers: { | ||
219 | instance: { | ||
220 | enabled: boolean | ||
221 | manualApproval: boolean | ||
222 | } | ||
223 | } | ||
224 | |||
225 | followings: { | ||
226 | instance: { | ||
227 | autoFollowBack: { | ||
228 | enabled: boolean | ||
229 | } | ||
230 | |||
231 | autoFollowIndex: { | ||
232 | enabled: boolean | ||
233 | indexUrl: string | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | |||
238 | broadcastMessage: { | ||
239 | enabled: boolean | ||
240 | message: string | ||
241 | level: BroadcastMessageLevel | ||
242 | dismissable: boolean | ||
243 | } | ||
244 | |||
245 | search: { | ||
246 | remoteUri: { | ||
247 | users: boolean | ||
248 | anonymous: boolean | ||
249 | } | ||
250 | |||
251 | searchIndex: { | ||
252 | enabled: boolean | ||
253 | url: string | ||
254 | disableLocalSearch: boolean | ||
255 | isDefaultSearch: boolean | ||
256 | } | ||
257 | } | ||
258 | |||
259 | } | ||
diff --git a/packages/models/src/server/debug.model.ts b/packages/models/src/server/debug.model.ts new file mode 100644 index 000000000..41f2109af --- /dev/null +++ b/packages/models/src/server/debug.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | export interface Debug { | ||
2 | ip: string | ||
3 | activityPubMessagesWaiting: number | ||
4 | } | ||
5 | |||
6 | export interface SendDebugCommand { | ||
7 | command: 'remove-dandling-resumable-uploads' | ||
8 | | 'process-video-views-buffer' | ||
9 | | 'process-video-viewers' | ||
10 | | 'process-video-channel-sync-latest' | ||
11 | | 'process-update-videos-scheduler' | ||
12 | } | ||
diff --git a/packages/models/src/server/emailer.model.ts b/packages/models/src/server/emailer.model.ts new file mode 100644 index 000000000..39512d306 --- /dev/null +++ b/packages/models/src/server/emailer.model.ts | |||
@@ -0,0 +1,49 @@ | |||
1 | type From = string | { name?: string, address: string } | ||
2 | |||
3 | interface Base extends Partial<SendEmailDefaultMessageOptions> { | ||
4 | to: string[] | string | ||
5 | } | ||
6 | |||
7 | interface MailTemplate extends Base { | ||
8 | template: string | ||
9 | locals?: { [key: string]: any } | ||
10 | text?: undefined | ||
11 | } | ||
12 | |||
13 | interface MailText extends Base { | ||
14 | text: string | ||
15 | |||
16 | locals?: Partial<SendEmailDefaultLocalsOptions> & { | ||
17 | title?: string | ||
18 | action?: { | ||
19 | url: string | ||
20 | text: string | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | |||
25 | interface SendEmailDefaultLocalsOptions { | ||
26 | instanceName: string | ||
27 | text: string | ||
28 | subject: string | ||
29 | } | ||
30 | |||
31 | interface SendEmailDefaultMessageOptions { | ||
32 | to: string[] | string | ||
33 | from: From | ||
34 | subject: string | ||
35 | replyTo: string | ||
36 | } | ||
37 | |||
38 | export type SendEmailDefaultOptions = { | ||
39 | template: 'common' | ||
40 | |||
41 | message: SendEmailDefaultMessageOptions | ||
42 | |||
43 | locals: SendEmailDefaultLocalsOptions & { | ||
44 | WEBSERVER: any | ||
45 | EMAIL: any | ||
46 | } | ||
47 | } | ||
48 | |||
49 | export type SendEmailOptions = MailTemplate | MailText | ||
diff --git a/packages/models/src/server/index.ts b/packages/models/src/server/index.ts new file mode 100644 index 000000000..ba6af8f6f --- /dev/null +++ b/packages/models/src/server/index.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | export * from './about.model.js' | ||
2 | export * from './broadcast-message-level.type.js' | ||
3 | export * from './client-log-create.model.js' | ||
4 | export * from './client-log-level.type.js' | ||
5 | export * from './contact-form.model.js' | ||
6 | export * from './custom-config.model.js' | ||
7 | export * from './debug.model.js' | ||
8 | export * from './emailer.model.js' | ||
9 | export * from './job.model.js' | ||
10 | export * from './peertube-problem-document.model.js' | ||
11 | export * from './server-config.model.js' | ||
12 | export * from './server-debug.model.js' | ||
13 | export * from './server-error-code.enum.js' | ||
14 | export * from './server-follow-create.model.js' | ||
15 | export * from './server-log-level.type.js' | ||
16 | export * from './server-stats.model.js' | ||
diff --git a/packages/models/src/server/job.model.ts b/packages/models/src/server/job.model.ts new file mode 100644 index 000000000..f86a20e28 --- /dev/null +++ b/packages/models/src/server/job.model.ts | |||
@@ -0,0 +1,303 @@ | |||
1 | import { ContextType } from '../activitypub/context.js' | ||
2 | import { VideoStateType } from '../videos/index.js' | ||
3 | import { VideoStudioTaskCut } from '../videos/studio/index.js' | ||
4 | import { SendEmailOptions } from './emailer.model.js' | ||
5 | |||
6 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children' | ||
7 | |||
8 | export type JobType = | ||
9 | | 'activitypub-cleaner' | ||
10 | | 'activitypub-follow' | ||
11 | | 'activitypub-http-broadcast-parallel' | ||
12 | | 'activitypub-http-broadcast' | ||
13 | | 'activitypub-http-fetcher' | ||
14 | | 'activitypub-http-unicast' | ||
15 | | 'activitypub-refresher' | ||
16 | | 'actor-keys' | ||
17 | | 'after-video-channel-import' | ||
18 | | 'email' | ||
19 | | 'federate-video' | ||
20 | | 'transcoding-job-builder' | ||
21 | | 'manage-video-torrent' | ||
22 | | 'move-to-object-storage' | ||
23 | | 'notify' | ||
24 | | 'video-channel-import' | ||
25 | | 'video-file-import' | ||
26 | | 'video-import' | ||
27 | | 'video-live-ending' | ||
28 | | 'video-redundancy' | ||
29 | | 'video-studio-edition' | ||
30 | | 'video-transcoding' | ||
31 | | 'videos-views-stats' | ||
32 | | 'generate-video-storyboard' | ||
33 | |||
34 | export interface Job { | ||
35 | id: number | string | ||
36 | state: JobState | 'unknown' | ||
37 | type: JobType | ||
38 | data: any | ||
39 | priority: number | ||
40 | progress: number | ||
41 | error: any | ||
42 | createdAt: Date | string | ||
43 | finishedOn: Date | string | ||
44 | processedOn: Date | string | ||
45 | |||
46 | parent?: { | ||
47 | id: string | ||
48 | } | ||
49 | } | ||
50 | |||
51 | export type ActivitypubHttpBroadcastPayload = { | ||
52 | uris: string[] | ||
53 | contextType: ContextType | ||
54 | body: any | ||
55 | signatureActorId?: number | ||
56 | } | ||
57 | |||
58 | export type ActivitypubFollowPayload = { | ||
59 | followerActorId: number | ||
60 | name: string | ||
61 | host: string | ||
62 | isAutoFollow?: boolean | ||
63 | assertIsChannel?: boolean | ||
64 | } | ||
65 | |||
66 | export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists' | ||
67 | export type ActivitypubHttpFetcherPayload = { | ||
68 | uri: string | ||
69 | type: FetchType | ||
70 | videoId?: number | ||
71 | } | ||
72 | |||
73 | export type ActivitypubHttpUnicastPayload = { | ||
74 | uri: string | ||
75 | contextType: ContextType | ||
76 | signatureActorId?: number | ||
77 | body: object | ||
78 | } | ||
79 | |||
80 | export type RefreshPayload = { | ||
81 | type: 'video' | 'video-playlist' | 'actor' | ||
82 | url: string | ||
83 | } | ||
84 | |||
85 | export type EmailPayload = SendEmailOptions | ||
86 | |||
87 | export type VideoFileImportPayload = { | ||
88 | videoUUID: string | ||
89 | filePath: string | ||
90 | } | ||
91 | |||
92 | // --------------------------------------------------------------------------- | ||
93 | |||
94 | export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file' | ||
95 | export type VideoImportYoutubeDLPayloadType = 'youtube-dl' | ||
96 | |||
97 | export interface VideoImportYoutubeDLPayload { | ||
98 | type: VideoImportYoutubeDLPayloadType | ||
99 | videoImportId: number | ||
100 | |||
101 | fileExt?: string | ||
102 | } | ||
103 | |||
104 | export interface VideoImportTorrentPayload { | ||
105 | type: VideoImportTorrentPayloadType | ||
106 | videoImportId: number | ||
107 | } | ||
108 | |||
109 | export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & { | ||
110 | preventException: boolean | ||
111 | } | ||
112 | |||
113 | export interface VideoImportPreventExceptionResult { | ||
114 | resultType: 'success' | 'error' | ||
115 | } | ||
116 | |||
117 | // --------------------------------------------------------------------------- | ||
118 | |||
119 | export type VideoRedundancyPayload = { | ||
120 | videoId: number | ||
121 | } | ||
122 | |||
123 | export type ManageVideoTorrentPayload = | ||
124 | { | ||
125 | action: 'create' | ||
126 | videoId: number | ||
127 | videoFileId: number | ||
128 | } | { | ||
129 | action: 'update-metadata' | ||
130 | |||
131 | videoId?: number | ||
132 | streamingPlaylistId?: number | ||
133 | |||
134 | videoFileId: number | ||
135 | } | ||
136 | |||
137 | // Video transcoding payloads | ||
138 | |||
139 | interface BaseTranscodingPayload { | ||
140 | videoUUID: string | ||
141 | isNewVideo?: boolean | ||
142 | } | ||
143 | |||
144 | export interface HLSTranscodingPayload extends BaseTranscodingPayload { | ||
145 | type: 'new-resolution-to-hls' | ||
146 | resolution: number | ||
147 | fps: number | ||
148 | copyCodecs: boolean | ||
149 | |||
150 | deleteWebVideoFiles: boolean | ||
151 | } | ||
152 | |||
153 | export interface NewWebVideoResolutionTranscodingPayload extends BaseTranscodingPayload { | ||
154 | type: 'new-resolution-to-web-video' | ||
155 | resolution: number | ||
156 | fps: number | ||
157 | } | ||
158 | |||
159 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | ||
160 | type: 'merge-audio-to-web-video' | ||
161 | |||
162 | resolution: number | ||
163 | fps: number | ||
164 | |||
165 | hasChildren: boolean | ||
166 | } | ||
167 | |||
168 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | ||
169 | type: 'optimize-to-web-video' | ||
170 | |||
171 | quickTranscode: boolean | ||
172 | |||
173 | hasChildren: boolean | ||
174 | } | ||
175 | |||
176 | export type VideoTranscodingPayload = | ||
177 | HLSTranscodingPayload | ||
178 | | NewWebVideoResolutionTranscodingPayload | ||
179 | | OptimizeTranscodingPayload | ||
180 | | MergeAudioTranscodingPayload | ||
181 | |||
182 | export interface VideoLiveEndingPayload { | ||
183 | videoId: number | ||
184 | publishedAt: string | ||
185 | liveSessionId: number | ||
186 | streamingPlaylistId: number | ||
187 | |||
188 | replayDirectory?: string | ||
189 | } | ||
190 | |||
191 | export interface ActorKeysPayload { | ||
192 | actorId: number | ||
193 | } | ||
194 | |||
195 | export interface DeleteResumableUploadMetaFilePayload { | ||
196 | filepath: string | ||
197 | } | ||
198 | |||
199 | export interface MoveObjectStoragePayload { | ||
200 | videoUUID: string | ||
201 | isNewVideo: boolean | ||
202 | previousVideoState: VideoStateType | ||
203 | } | ||
204 | |||
205 | export type VideoStudioTaskCutPayload = VideoStudioTaskCut | ||
206 | |||
207 | export type VideoStudioTaskIntroPayload = { | ||
208 | name: 'add-intro' | ||
209 | |||
210 | options: { | ||
211 | file: string | ||
212 | } | ||
213 | } | ||
214 | |||
215 | export type VideoStudioTaskOutroPayload = { | ||
216 | name: 'add-outro' | ||
217 | |||
218 | options: { | ||
219 | file: string | ||
220 | } | ||
221 | } | ||
222 | |||
223 | export type VideoStudioTaskWatermarkPayload = { | ||
224 | name: 'add-watermark' | ||
225 | |||
226 | options: { | ||
227 | file: string | ||
228 | |||
229 | watermarkSizeRatio: number | ||
230 | horitonzalMarginRatio: number | ||
231 | verticalMarginRatio: number | ||
232 | } | ||
233 | } | ||
234 | |||
235 | export type VideoStudioTaskPayload = | ||
236 | VideoStudioTaskCutPayload | | ||
237 | VideoStudioTaskIntroPayload | | ||
238 | VideoStudioTaskOutroPayload | | ||
239 | VideoStudioTaskWatermarkPayload | ||
240 | |||
241 | export interface VideoStudioEditionPayload { | ||
242 | videoUUID: string | ||
243 | tasks: VideoStudioTaskPayload[] | ||
244 | } | ||
245 | |||
246 | // --------------------------------------------------------------------------- | ||
247 | |||
248 | export interface VideoChannelImportPayload { | ||
249 | externalChannelUrl: string | ||
250 | videoChannelId: number | ||
251 | |||
252 | partOfChannelSyncId?: number | ||
253 | } | ||
254 | |||
255 | export interface AfterVideoChannelImportPayload { | ||
256 | channelSyncId: number | ||
257 | } | ||
258 | |||
259 | // --------------------------------------------------------------------------- | ||
260 | |||
261 | export type NotifyPayload = | ||
262 | { | ||
263 | action: 'new-video' | ||
264 | videoUUID: string | ||
265 | } | ||
266 | |||
267 | // --------------------------------------------------------------------------- | ||
268 | |||
269 | export interface FederateVideoPayload { | ||
270 | videoUUID: string | ||
271 | isNewVideo: boolean | ||
272 | } | ||
273 | |||
274 | // --------------------------------------------------------------------------- | ||
275 | |||
276 | export interface TranscodingJobBuilderPayload { | ||
277 | videoUUID: string | ||
278 | |||
279 | optimizeJob?: { | ||
280 | isNewVideo: boolean | ||
281 | } | ||
282 | |||
283 | // Array of jobs to create | ||
284 | jobs?: { | ||
285 | type: 'video-transcoding' | ||
286 | payload: VideoTranscodingPayload | ||
287 | priority?: number | ||
288 | }[] | ||
289 | |||
290 | // Array of sequential jobs to create | ||
291 | sequentialJobs?: { | ||
292 | type: 'video-transcoding' | ||
293 | payload: VideoTranscodingPayload | ||
294 | priority?: number | ||
295 | }[][] | ||
296 | } | ||
297 | |||
298 | // --------------------------------------------------------------------------- | ||
299 | |||
300 | export interface GenerateStoryboardPayload { | ||
301 | videoUUID: string | ||
302 | federate: boolean | ||
303 | } | ||
diff --git a/packages/models/src/server/peertube-problem-document.model.ts b/packages/models/src/server/peertube-problem-document.model.ts new file mode 100644 index 000000000..c717fc152 --- /dev/null +++ b/packages/models/src/server/peertube-problem-document.model.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { HttpStatusCodeType } from '../http/http-status-codes.js' | ||
2 | import { OAuth2ErrorCodeType, ServerErrorCodeType } from './server-error-code.enum.js' | ||
3 | |||
4 | export interface PeerTubeProblemDocumentData { | ||
5 | 'invalid-params'?: Record<string, object> | ||
6 | |||
7 | originUrl?: string | ||
8 | |||
9 | keyId?: string | ||
10 | |||
11 | targetUrl?: string | ||
12 | |||
13 | actorUrl?: string | ||
14 | |||
15 | // Feeds | ||
16 | format?: string | ||
17 | url?: string | ||
18 | } | ||
19 | |||
20 | export interface PeerTubeProblemDocument extends PeerTubeProblemDocumentData { | ||
21 | type: string | ||
22 | title: string | ||
23 | |||
24 | detail: string | ||
25 | // FIXME: Compat PeerTube <= 3.2 | ||
26 | error: string | ||
27 | |||
28 | status: HttpStatusCodeType | ||
29 | |||
30 | docs?: string | ||
31 | code?: OAuth2ErrorCodeType | ServerErrorCodeType | ||
32 | } | ||
diff --git a/packages/models/src/server/server-config.model.ts b/packages/models/src/server/server-config.model.ts new file mode 100644 index 000000000..a2a2bd5aa --- /dev/null +++ b/packages/models/src/server/server-config.model.ts | |||
@@ -0,0 +1,305 @@ | |||
1 | import { ClientScriptJSON } from '../plugins/plugin-package-json.model.js' | ||
2 | import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' | ||
3 | import { VideoPrivacyType } from '../videos/video-privacy.enum.js' | ||
4 | import { BroadcastMessageLevel } from './broadcast-message-level.type.js' | ||
5 | |||
6 | export interface ServerConfigPlugin { | ||
7 | name: string | ||
8 | npmName: string | ||
9 | version: string | ||
10 | description: string | ||
11 | clientScripts: { [name: string]: ClientScriptJSON } | ||
12 | } | ||
13 | |||
14 | export interface ServerConfigTheme extends ServerConfigPlugin { | ||
15 | css: string[] | ||
16 | } | ||
17 | |||
18 | export interface RegisteredExternalAuthConfig { | ||
19 | npmName: string | ||
20 | name: string | ||
21 | version: string | ||
22 | authName: string | ||
23 | authDisplayName: string | ||
24 | } | ||
25 | |||
26 | export interface RegisteredIdAndPassAuthConfig { | ||
27 | npmName: string | ||
28 | name: string | ||
29 | version: string | ||
30 | authName: string | ||
31 | weight: number | ||
32 | } | ||
33 | |||
34 | export interface ServerConfig { | ||
35 | serverVersion: string | ||
36 | serverCommit?: string | ||
37 | |||
38 | client: { | ||
39 | videos: { | ||
40 | miniature: { | ||
41 | displayAuthorAvatar: boolean | ||
42 | preferAuthorDisplayName: boolean | ||
43 | } | ||
44 | resumableUpload: { | ||
45 | maxChunkSize: number | ||
46 | } | ||
47 | } | ||
48 | |||
49 | menu: { | ||
50 | login: { | ||
51 | redirectOnSingleExternalAuth: boolean | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | defaults: { | ||
57 | publish: { | ||
58 | downloadEnabled: boolean | ||
59 | commentsEnabled: boolean | ||
60 | privacy: VideoPrivacyType | ||
61 | licence: number | ||
62 | } | ||
63 | |||
64 | p2p: { | ||
65 | webapp: { | ||
66 | enabled: boolean | ||
67 | } | ||
68 | |||
69 | embed: { | ||
70 | enabled: boolean | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | webadmin: { | ||
76 | configuration: { | ||
77 | edition: { | ||
78 | allowed: boolean | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | |||
83 | instance: { | ||
84 | name: string | ||
85 | shortDescription: string | ||
86 | isNSFW: boolean | ||
87 | defaultNSFWPolicy: NSFWPolicyType | ||
88 | defaultClientRoute: string | ||
89 | customizations: { | ||
90 | javascript: string | ||
91 | css: string | ||
92 | } | ||
93 | } | ||
94 | |||
95 | search: { | ||
96 | remoteUri: { | ||
97 | users: boolean | ||
98 | anonymous: boolean | ||
99 | } | ||
100 | |||
101 | searchIndex: { | ||
102 | enabled: boolean | ||
103 | url: string | ||
104 | disableLocalSearch: boolean | ||
105 | isDefaultSearch: boolean | ||
106 | } | ||
107 | } | ||
108 | |||
109 | plugin: { | ||
110 | registered: ServerConfigPlugin[] | ||
111 | |||
112 | registeredExternalAuths: RegisteredExternalAuthConfig[] | ||
113 | |||
114 | registeredIdAndPassAuths: RegisteredIdAndPassAuthConfig[] | ||
115 | } | ||
116 | |||
117 | theme: { | ||
118 | registered: ServerConfigTheme[] | ||
119 | default: string | ||
120 | } | ||
121 | |||
122 | email: { | ||
123 | enabled: boolean | ||
124 | } | ||
125 | |||
126 | contactForm: { | ||
127 | enabled: boolean | ||
128 | } | ||
129 | |||
130 | signup: { | ||
131 | allowed: boolean | ||
132 | allowedForCurrentIP: boolean | ||
133 | requiresEmailVerification: boolean | ||
134 | requiresApproval: boolean | ||
135 | minimumAge: number | ||
136 | } | ||
137 | |||
138 | transcoding: { | ||
139 | hls: { | ||
140 | enabled: boolean | ||
141 | } | ||
142 | |||
143 | web_videos: { | ||
144 | enabled: boolean | ||
145 | } | ||
146 | |||
147 | enabledResolutions: number[] | ||
148 | |||
149 | profile: string | ||
150 | availableProfiles: string[] | ||
151 | |||
152 | remoteRunners: { | ||
153 | enabled: boolean | ||
154 | } | ||
155 | } | ||
156 | |||
157 | live: { | ||
158 | enabled: boolean | ||
159 | |||
160 | allowReplay: boolean | ||
161 | latencySetting: { | ||
162 | enabled: boolean | ||
163 | } | ||
164 | |||
165 | maxDuration: number | ||
166 | maxInstanceLives: number | ||
167 | maxUserLives: number | ||
168 | |||
169 | transcoding: { | ||
170 | enabled: boolean | ||
171 | |||
172 | remoteRunners: { | ||
173 | enabled: boolean | ||
174 | } | ||
175 | |||
176 | enabledResolutions: number[] | ||
177 | |||
178 | profile: string | ||
179 | availableProfiles: string[] | ||
180 | } | ||
181 | |||
182 | rtmp: { | ||
183 | port: number | ||
184 | } | ||
185 | } | ||
186 | |||
187 | videoStudio: { | ||
188 | enabled: boolean | ||
189 | |||
190 | remoteRunners: { | ||
191 | enabled: boolean | ||
192 | } | ||
193 | } | ||
194 | |||
195 | videoFile: { | ||
196 | update: { | ||
197 | enabled: boolean | ||
198 | } | ||
199 | } | ||
200 | |||
201 | import: { | ||
202 | videos: { | ||
203 | http: { | ||
204 | enabled: boolean | ||
205 | } | ||
206 | torrent: { | ||
207 | enabled: boolean | ||
208 | } | ||
209 | } | ||
210 | videoChannelSynchronization: { | ||
211 | enabled: boolean | ||
212 | } | ||
213 | } | ||
214 | |||
215 | autoBlacklist: { | ||
216 | videos: { | ||
217 | ofUsers: { | ||
218 | enabled: boolean | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | avatar: { | ||
224 | file: { | ||
225 | size: { | ||
226 | max: number | ||
227 | } | ||
228 | extensions: string[] | ||
229 | } | ||
230 | } | ||
231 | |||
232 | banner: { | ||
233 | file: { | ||
234 | size: { | ||
235 | max: number | ||
236 | } | ||
237 | extensions: string[] | ||
238 | } | ||
239 | } | ||
240 | |||
241 | video: { | ||
242 | image: { | ||
243 | size: { | ||
244 | max: number | ||
245 | } | ||
246 | extensions: string[] | ||
247 | } | ||
248 | file: { | ||
249 | extensions: string[] | ||
250 | } | ||
251 | } | ||
252 | |||
253 | videoCaption: { | ||
254 | file: { | ||
255 | size: { | ||
256 | max: number | ||
257 | } | ||
258 | extensions: string[] | ||
259 | } | ||
260 | } | ||
261 | |||
262 | user: { | ||
263 | videoQuota: number | ||
264 | videoQuotaDaily: number | ||
265 | } | ||
266 | |||
267 | videoChannels: { | ||
268 | maxPerUser: number | ||
269 | } | ||
270 | |||
271 | trending: { | ||
272 | videos: { | ||
273 | intervalDays: number | ||
274 | algorithms: { | ||
275 | enabled: string[] | ||
276 | default: string | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | tracker: { | ||
282 | enabled: boolean | ||
283 | } | ||
284 | |||
285 | followings: { | ||
286 | instance: { | ||
287 | autoFollowIndex: { | ||
288 | indexUrl: string | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | |||
293 | broadcastMessage: { | ||
294 | enabled: boolean | ||
295 | message: string | ||
296 | level: BroadcastMessageLevel | ||
297 | dismissable: boolean | ||
298 | } | ||
299 | |||
300 | homepage: { | ||
301 | enabled: boolean | ||
302 | } | ||
303 | } | ||
304 | |||
305 | export type HTMLServerConfig = Omit<ServerConfig, 'signup'> | ||
diff --git a/packages/models/src/server/server-debug.model.ts b/packages/models/src/server/server-debug.model.ts new file mode 100644 index 000000000..4b731bb90 --- /dev/null +++ b/packages/models/src/server/server-debug.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface ServerDebug { | ||
2 | ip: string | ||
3 | activityPubMessagesWaiting: number | ||
4 | } | ||
diff --git a/packages/models/src/server/server-error-code.enum.ts b/packages/models/src/server/server-error-code.enum.ts new file mode 100644 index 000000000..dc200c1ea --- /dev/null +++ b/packages/models/src/server/server-error-code.enum.ts | |||
@@ -0,0 +1,92 @@ | |||
1 | export const ServerErrorCode = { | ||
2 | /** | ||
3 | * The simplest form of payload too large: when the file size is over the | ||
4 | * global file size limit | ||
5 | */ | ||
6 | MAX_FILE_SIZE_REACHED:'max_file_size_reached', | ||
7 | |||
8 | /** | ||
9 | * The payload is too large for the user quota set | ||
10 | */ | ||
11 | QUOTA_REACHED:'quota_reached', | ||
12 | |||
13 | /** | ||
14 | * Error yielded upon trying to access a video that is not federated, nor can | ||
15 | * be. This may be due to: remote videos on instances that are not followed by | ||
16 | * yours, and with your instance disallowing unknown instances being accessed. | ||
17 | */ | ||
18 | DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS:'does_not_respect_follow_constraints', | ||
19 | |||
20 | LIVE_NOT_ENABLED:'live_not_enabled', | ||
21 | LIVE_NOT_ALLOWING_REPLAY:'live_not_allowing_replay', | ||
22 | LIVE_CONFLICTING_PERMANENT_AND_SAVE_REPLAY:'live_conflicting_permanent_and_save_replay', | ||
23 | /** | ||
24 | * Pretty self-explanatory: the set maximum number of simultaneous lives was | ||
25 | * reached, and this error is typically there to inform the user trying to | ||
26 | * broadcast one. | ||
27 | */ | ||
28 | MAX_INSTANCE_LIVES_LIMIT_REACHED:'max_instance_lives_limit_reached', | ||
29 | /** | ||
30 | * Pretty self-explanatory: the set maximum number of simultaneous lives FOR | ||
31 | * THIS USER was reached, and this error is typically there to inform the user | ||
32 | * trying to broadcast one. | ||
33 | */ | ||
34 | MAX_USER_LIVES_LIMIT_REACHED:'max_user_lives_limit_reached', | ||
35 | |||
36 | /** | ||
37 | * A torrent should have at most one correct video file. Any more and we will | ||
38 | * not be able to choose automatically. | ||
39 | */ | ||
40 | INCORRECT_FILES_IN_TORRENT:'incorrect_files_in_torrent', | ||
41 | |||
42 | COMMENT_NOT_ASSOCIATED_TO_VIDEO:'comment_not_associated_to_video', | ||
43 | |||
44 | MISSING_TWO_FACTOR:'missing_two_factor', | ||
45 | INVALID_TWO_FACTOR:'invalid_two_factor', | ||
46 | |||
47 | ACCOUNT_WAITING_FOR_APPROVAL:'account_waiting_for_approval', | ||
48 | ACCOUNT_APPROVAL_REJECTED:'account_approval_rejected', | ||
49 | |||
50 | RUNNER_JOB_NOT_IN_PROCESSING_STATE:'runner_job_not_in_processing_state', | ||
51 | RUNNER_JOB_NOT_IN_PENDING_STATE:'runner_job_not_in_pending_state', | ||
52 | UNKNOWN_RUNNER_TOKEN:'unknown_runner_token', | ||
53 | |||
54 | VIDEO_REQUIRES_PASSWORD:'video_requires_password', | ||
55 | INCORRECT_VIDEO_PASSWORD:'incorrect_video_password', | ||
56 | |||
57 | VIDEO_ALREADY_BEING_TRANSCODED:'video_already_being_transcoded' | ||
58 | } as const | ||
59 | |||
60 | /** | ||
61 | * oauthjs/oauth2-server error codes | ||
62 | * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 | ||
63 | **/ | ||
64 | export const OAuth2ErrorCode = { | ||
65 | /** | ||
66 | * The provided authorization grant (e.g., authorization code, resource owner | ||
67 | * credentials) or refresh token is invalid, expired, revoked, does not match | ||
68 | * the redirection URI used in the authorization request, or was issued to | ||
69 | * another client. | ||
70 | * | ||
71 | * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-grant-error.js | ||
72 | */ | ||
73 | INVALID_GRANT: 'invalid_grant', | ||
74 | |||
75 | /** | ||
76 | * Client authentication failed (e.g., unknown client, no client authentication | ||
77 | * included, or unsupported authentication method). | ||
78 | * | ||
79 | * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-client-error.js | ||
80 | */ | ||
81 | INVALID_CLIENT: 'invalid_client', | ||
82 | |||
83 | /** | ||
84 | * The access token provided is expired, revoked, malformed, or invalid for other reasons | ||
85 | * | ||
86 | * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-token-error.js | ||
87 | */ | ||
88 | INVALID_TOKEN: 'invalid_token' | ||
89 | } as const | ||
90 | |||
91 | export type OAuth2ErrorCodeType = typeof OAuth2ErrorCode[keyof typeof OAuth2ErrorCode] | ||
92 | export type ServerErrorCodeType = typeof ServerErrorCode[keyof typeof ServerErrorCode] | ||
diff --git a/packages/models/src/server/server-follow-create.model.ts b/packages/models/src/server/server-follow-create.model.ts new file mode 100644 index 000000000..3f90c7d6f --- /dev/null +++ b/packages/models/src/server/server-follow-create.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface ServerFollowCreate { | ||
2 | hosts?: string[] | ||
3 | handles?: string[] | ||
4 | } | ||
diff --git a/packages/models/src/server/server-log-level.type.ts b/packages/models/src/server/server-log-level.type.ts new file mode 100644 index 000000000..f0f31a4ae --- /dev/null +++ b/packages/models/src/server/server-log-level.type.ts | |||
@@ -0,0 +1 @@ | |||
export type ServerLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'audit' | |||
diff --git a/packages/models/src/server/server-stats.model.ts b/packages/models/src/server/server-stats.model.ts new file mode 100644 index 000000000..5870ee73d --- /dev/null +++ b/packages/models/src/server/server-stats.model.ts | |||
@@ -0,0 +1,47 @@ | |||
1 | import { ActivityType } from '../activitypub/index.js' | ||
2 | import { VideoRedundancyStrategyWithManual } from '../redundancy/index.js' | ||
3 | |||
4 | type ActivityPubMessagesSuccess = Record<`totalActivityPub${ActivityType}MessagesSuccesses`, number> | ||
5 | type ActivityPubMessagesErrors = Record<`totalActivityPub${ActivityType}MessagesErrors`, number> | ||
6 | |||
7 | export interface ServerStats extends ActivityPubMessagesSuccess, ActivityPubMessagesErrors { | ||
8 | totalUsers: number | ||
9 | totalDailyActiveUsers: number | ||
10 | totalWeeklyActiveUsers: number | ||
11 | totalMonthlyActiveUsers: number | ||
12 | |||
13 | totalLocalVideos: number | ||
14 | totalLocalVideoViews: number | ||
15 | totalLocalVideoComments: number | ||
16 | totalLocalVideoFilesSize: number | ||
17 | |||
18 | totalVideos: number | ||
19 | totalVideoComments: number | ||
20 | |||
21 | totalLocalVideoChannels: number | ||
22 | totalLocalDailyActiveVideoChannels: number | ||
23 | totalLocalWeeklyActiveVideoChannels: number | ||
24 | totalLocalMonthlyActiveVideoChannels: number | ||
25 | |||
26 | totalLocalPlaylists: number | ||
27 | |||
28 | totalInstanceFollowers: number | ||
29 | totalInstanceFollowing: number | ||
30 | |||
31 | videosRedundancy: VideosRedundancyStats[] | ||
32 | |||
33 | totalActivityPubMessagesProcessed: number | ||
34 | totalActivityPubMessagesSuccesses: number | ||
35 | totalActivityPubMessagesErrors: number | ||
36 | |||
37 | activityPubMessagesProcessedPerSecond: number | ||
38 | totalActivityPubMessagesWaiting: number | ||
39 | } | ||
40 | |||
41 | export interface VideosRedundancyStats { | ||
42 | strategy: VideoRedundancyStrategyWithManual | ||
43 | totalSize: number | ||
44 | totalUsed: number | ||
45 | totalVideoFiles: number | ||
46 | totalVideos: number | ||
47 | } | ||
diff --git a/packages/models/src/tokens/index.ts b/packages/models/src/tokens/index.ts new file mode 100644 index 000000000..db2d63d21 --- /dev/null +++ b/packages/models/src/tokens/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './oauth-client-local.model.js' | |||
diff --git a/packages/models/src/tokens/oauth-client-local.model.ts b/packages/models/src/tokens/oauth-client-local.model.ts new file mode 100644 index 000000000..0c6ce6c5d --- /dev/null +++ b/packages/models/src/tokens/oauth-client-local.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface OAuthClientLocal { | ||
2 | client_id: string | ||
3 | client_secret: string | ||
4 | } | ||
diff --git a/packages/models/src/users/index.ts b/packages/models/src/users/index.ts new file mode 100644 index 000000000..6f5218234 --- /dev/null +++ b/packages/models/src/users/index.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | export * from './registration/index.js' | ||
2 | export * from './two-factor-enable-result.model.js' | ||
3 | export * from './user-create-result.model.js' | ||
4 | export * from './user-create.model.js' | ||
5 | export * from './user-flag.model.js' | ||
6 | export * from './user-login.model.js' | ||
7 | export * from './user-notification-setting.model.js' | ||
8 | export * from './user-notification.model.js' | ||
9 | export * from './user-refresh-token.model.js' | ||
10 | export * from './user-right.enum.js' | ||
11 | export * from './user-role.js' | ||
12 | export * from './user-scoped-token.js' | ||
13 | export * from './user-update-me.model.js' | ||
14 | export * from './user-update.model.js' | ||
15 | export * from './user-video-quota.model.js' | ||
16 | export * from './user.model.js' | ||
diff --git a/packages/models/src/users/registration/index.ts b/packages/models/src/users/registration/index.ts new file mode 100644 index 000000000..dcf16ef9d --- /dev/null +++ b/packages/models/src/users/registration/index.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export * from './user-register.model.js' | ||
2 | export * from './user-registration-request.model.js' | ||
3 | export * from './user-registration-state.model.js' | ||
4 | export * from './user-registration-update-state.model.js' | ||
5 | export * from './user-registration.model.js' | ||
diff --git a/packages/models/src/users/registration/user-register.model.ts b/packages/models/src/users/registration/user-register.model.ts new file mode 100644 index 000000000..cf9a43a67 --- /dev/null +++ b/packages/models/src/users/registration/user-register.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | export interface UserRegister { | ||
2 | username: string | ||
3 | password: string | ||
4 | email: string | ||
5 | |||
6 | displayName?: string | ||
7 | |||
8 | channel?: { | ||
9 | name: string | ||
10 | displayName: string | ||
11 | } | ||
12 | } | ||
diff --git a/packages/models/src/users/registration/user-registration-request.model.ts b/packages/models/src/users/registration/user-registration-request.model.ts new file mode 100644 index 000000000..ed369f96a --- /dev/null +++ b/packages/models/src/users/registration/user-registration-request.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { UserRegister } from './user-register.model.js' | ||
2 | |||
3 | export interface UserRegistrationRequest extends UserRegister { | ||
4 | registrationReason: string | ||
5 | } | ||
diff --git a/packages/models/src/users/registration/user-registration-state.model.ts b/packages/models/src/users/registration/user-registration-state.model.ts new file mode 100644 index 000000000..7c51f3f9d --- /dev/null +++ b/packages/models/src/users/registration/user-registration-state.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const UserRegistrationState = { | ||
2 | PENDING: 1, | ||
3 | REJECTED: 2, | ||
4 | ACCEPTED: 3 | ||
5 | } | ||
6 | |||
7 | export type UserRegistrationStateType = typeof UserRegistrationState[keyof typeof UserRegistrationState] | ||
diff --git a/packages/models/src/users/registration/user-registration-update-state.model.ts b/packages/models/src/users/registration/user-registration-update-state.model.ts new file mode 100644 index 000000000..a1740dcca --- /dev/null +++ b/packages/models/src/users/registration/user-registration-update-state.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface UserRegistrationUpdateState { | ||
2 | moderationResponse: string | ||
3 | preventEmailDelivery?: boolean | ||
4 | } | ||
diff --git a/packages/models/src/users/registration/user-registration.model.ts b/packages/models/src/users/registration/user-registration.model.ts new file mode 100644 index 000000000..0d01add36 --- /dev/null +++ b/packages/models/src/users/registration/user-registration.model.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { UserRegistrationStateType } from './user-registration-state.model.js' | ||
2 | |||
3 | export interface UserRegistration { | ||
4 | id: number | ||
5 | |||
6 | state: { | ||
7 | id: UserRegistrationStateType | ||
8 | label: string | ||
9 | } | ||
10 | |||
11 | registrationReason: string | ||
12 | moderationResponse: string | ||
13 | |||
14 | username: string | ||
15 | email: string | ||
16 | emailVerified: boolean | ||
17 | |||
18 | accountDisplayName: string | ||
19 | |||
20 | channelHandle: string | ||
21 | channelDisplayName: string | ||
22 | |||
23 | createdAt: Date | ||
24 | updatedAt: Date | ||
25 | |||
26 | user?: { | ||
27 | id: number | ||
28 | } | ||
29 | } | ||
diff --git a/packages/models/src/users/two-factor-enable-result.model.ts b/packages/models/src/users/two-factor-enable-result.model.ts new file mode 100644 index 000000000..1fc801f0a --- /dev/null +++ b/packages/models/src/users/two-factor-enable-result.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface TwoFactorEnableResult { | ||
2 | otpRequest: { | ||
3 | requestToken: string | ||
4 | secret: string | ||
5 | uri: string | ||
6 | } | ||
7 | } | ||
diff --git a/packages/models/src/users/user-create-result.model.ts b/packages/models/src/users/user-create-result.model.ts new file mode 100644 index 000000000..835b241ed --- /dev/null +++ b/packages/models/src/users/user-create-result.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface UserCreateResult { | ||
2 | id: number | ||
3 | |||
4 | account: { | ||
5 | id: number | ||
6 | } | ||
7 | } | ||
diff --git a/packages/models/src/users/user-create.model.ts b/packages/models/src/users/user-create.model.ts new file mode 100644 index 000000000..b62cf692f --- /dev/null +++ b/packages/models/src/users/user-create.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { UserAdminFlagType } from './user-flag.model.js' | ||
2 | import { UserRoleType } from './user-role.js' | ||
3 | |||
4 | export interface UserCreate { | ||
5 | username: string | ||
6 | password: string | ||
7 | email: string | ||
8 | videoQuota: number | ||
9 | videoQuotaDaily: number | ||
10 | role: UserRoleType | ||
11 | adminFlags?: UserAdminFlagType | ||
12 | channelName?: string | ||
13 | } | ||
diff --git a/packages/models/src/users/user-flag.model.ts b/packages/models/src/users/user-flag.model.ts new file mode 100644 index 000000000..0ecbacecc --- /dev/null +++ b/packages/models/src/users/user-flag.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export const UserAdminFlag = { | ||
2 | NONE: 0, | ||
3 | BYPASS_VIDEO_AUTO_BLACKLIST: 1 << 0 | ||
4 | } as const | ||
5 | |||
6 | export type UserAdminFlagType = typeof UserAdminFlag[keyof typeof UserAdminFlag] | ||
diff --git a/packages/models/src/users/user-login.model.ts b/packages/models/src/users/user-login.model.ts new file mode 100644 index 000000000..1e85ab30b --- /dev/null +++ b/packages/models/src/users/user-login.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface UserLogin { | ||
2 | access_token: string | ||
3 | refresh_token: string | ||
4 | token_type: string | ||
5 | } | ||
diff --git a/packages/models/src/users/user-notification-setting.model.ts b/packages/models/src/users/user-notification-setting.model.ts new file mode 100644 index 000000000..fbd94994e --- /dev/null +++ b/packages/models/src/users/user-notification-setting.model.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | export const UserNotificationSettingValue = { | ||
2 | NONE: 0, | ||
3 | WEB: 1 << 0, | ||
4 | EMAIL: 1 << 1 | ||
5 | } as const | ||
6 | |||
7 | export type UserNotificationSettingValueType = typeof UserNotificationSettingValue[keyof typeof UserNotificationSettingValue] | ||
8 | |||
9 | export interface UserNotificationSetting { | ||
10 | abuseAsModerator: UserNotificationSettingValueType | ||
11 | videoAutoBlacklistAsModerator: UserNotificationSettingValueType | ||
12 | newUserRegistration: UserNotificationSettingValueType | ||
13 | |||
14 | newVideoFromSubscription: UserNotificationSettingValueType | ||
15 | |||
16 | blacklistOnMyVideo: UserNotificationSettingValueType | ||
17 | myVideoPublished: UserNotificationSettingValueType | ||
18 | myVideoImportFinished: UserNotificationSettingValueType | ||
19 | |||
20 | commentMention: UserNotificationSettingValueType | ||
21 | newCommentOnMyVideo: UserNotificationSettingValueType | ||
22 | |||
23 | newFollow: UserNotificationSettingValueType | ||
24 | newInstanceFollower: UserNotificationSettingValueType | ||
25 | autoInstanceFollowing: UserNotificationSettingValueType | ||
26 | |||
27 | abuseStateChange: UserNotificationSettingValueType | ||
28 | abuseNewMessage: UserNotificationSettingValueType | ||
29 | |||
30 | newPeerTubeVersion: UserNotificationSettingValueType | ||
31 | newPluginVersion: UserNotificationSettingValueType | ||
32 | |||
33 | myVideoStudioEditionFinished: UserNotificationSettingValueType | ||
34 | } | ||
diff --git a/packages/models/src/users/user-notification.model.ts b/packages/models/src/users/user-notification.model.ts new file mode 100644 index 000000000..991fe6728 --- /dev/null +++ b/packages/models/src/users/user-notification.model.ts | |||
@@ -0,0 +1,140 @@ | |||
1 | import { FollowState } from '../actors/index.js' | ||
2 | import { AbuseStateType } from '../moderation/index.js' | ||
3 | import { PluginType_Type } from '../plugins/index.js' | ||
4 | |||
5 | export const UserNotificationType = { | ||
6 | NEW_VIDEO_FROM_SUBSCRIPTION: 1, | ||
7 | NEW_COMMENT_ON_MY_VIDEO: 2, | ||
8 | NEW_ABUSE_FOR_MODERATORS: 3, | ||
9 | |||
10 | BLACKLIST_ON_MY_VIDEO: 4, | ||
11 | UNBLACKLIST_ON_MY_VIDEO: 5, | ||
12 | |||
13 | MY_VIDEO_PUBLISHED: 6, | ||
14 | |||
15 | MY_VIDEO_IMPORT_SUCCESS: 7, | ||
16 | MY_VIDEO_IMPORT_ERROR: 8, | ||
17 | |||
18 | NEW_USER_REGISTRATION: 9, | ||
19 | NEW_FOLLOW: 10, | ||
20 | COMMENT_MENTION: 11, | ||
21 | |||
22 | VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: 12, | ||
23 | |||
24 | NEW_INSTANCE_FOLLOWER: 13, | ||
25 | |||
26 | AUTO_INSTANCE_FOLLOWING: 14, | ||
27 | |||
28 | ABUSE_STATE_CHANGE: 15, | ||
29 | |||
30 | ABUSE_NEW_MESSAGE: 16, | ||
31 | |||
32 | NEW_PLUGIN_VERSION: 17, | ||
33 | NEW_PEERTUBE_VERSION: 18, | ||
34 | |||
35 | MY_VIDEO_STUDIO_EDITION_FINISHED: 19, | ||
36 | |||
37 | NEW_USER_REGISTRATION_REQUEST: 20 | ||
38 | } as const | ||
39 | |||
40 | export type UserNotificationType_Type = typeof UserNotificationType[keyof typeof UserNotificationType] | ||
41 | |||
42 | export interface VideoInfo { | ||
43 | id: number | ||
44 | uuid: string | ||
45 | shortUUID: string | ||
46 | name: string | ||
47 | } | ||
48 | |||
49 | export interface AvatarInfo { | ||
50 | width: number | ||
51 | path: string | ||
52 | } | ||
53 | |||
54 | export interface ActorInfo { | ||
55 | id: number | ||
56 | displayName: string | ||
57 | name: string | ||
58 | host: string | ||
59 | |||
60 | avatars: AvatarInfo[] | ||
61 | avatar: AvatarInfo | ||
62 | } | ||
63 | |||
64 | export interface UserNotification { | ||
65 | id: number | ||
66 | type: UserNotificationType_Type | ||
67 | read: boolean | ||
68 | |||
69 | video?: VideoInfo & { | ||
70 | channel: ActorInfo | ||
71 | } | ||
72 | |||
73 | videoImport?: { | ||
74 | id: number | ||
75 | video?: VideoInfo | ||
76 | torrentName?: string | ||
77 | magnetUri?: string | ||
78 | targetUrl?: string | ||
79 | } | ||
80 | |||
81 | comment?: { | ||
82 | id: number | ||
83 | threadId: number | ||
84 | account: ActorInfo | ||
85 | video: VideoInfo | ||
86 | } | ||
87 | |||
88 | abuse?: { | ||
89 | id: number | ||
90 | state: AbuseStateType | ||
91 | |||
92 | video?: VideoInfo | ||
93 | |||
94 | comment?: { | ||
95 | threadId: number | ||
96 | |||
97 | video: VideoInfo | ||
98 | } | ||
99 | |||
100 | account?: ActorInfo | ||
101 | } | ||
102 | |||
103 | videoBlacklist?: { | ||
104 | id: number | ||
105 | video: VideoInfo | ||
106 | } | ||
107 | |||
108 | account?: ActorInfo | ||
109 | |||
110 | actorFollow?: { | ||
111 | id: number | ||
112 | follower: ActorInfo | ||
113 | state: FollowState | ||
114 | |||
115 | following: { | ||
116 | type: 'account' | 'channel' | 'instance' | ||
117 | name: string | ||
118 | displayName: string | ||
119 | host: string | ||
120 | } | ||
121 | } | ||
122 | |||
123 | plugin?: { | ||
124 | name: string | ||
125 | type: PluginType_Type | ||
126 | latestVersion: string | ||
127 | } | ||
128 | |||
129 | peertube?: { | ||
130 | latestVersion: string | ||
131 | } | ||
132 | |||
133 | registration?: { | ||
134 | id: number | ||
135 | username: string | ||
136 | } | ||
137 | |||
138 | createdAt: string | ||
139 | updatedAt: string | ||
140 | } | ||
diff --git a/packages/models/src/users/user-refresh-token.model.ts b/packages/models/src/users/user-refresh-token.model.ts new file mode 100644 index 000000000..f528dd961 --- /dev/null +++ b/packages/models/src/users/user-refresh-token.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface UserRefreshToken { | ||
2 | access_token: string | ||
3 | refresh_token: string | ||
4 | } | ||
diff --git a/packages/models/src/users/user-right.enum.ts b/packages/models/src/users/user-right.enum.ts new file mode 100644 index 000000000..534b9feb0 --- /dev/null +++ b/packages/models/src/users/user-right.enum.ts | |||
@@ -0,0 +1,53 @@ | |||
1 | export const UserRight = { | ||
2 | ALL: 0, | ||
3 | |||
4 | MANAGE_USERS: 1, | ||
5 | |||
6 | MANAGE_SERVER_FOLLOW: 2, | ||
7 | |||
8 | MANAGE_LOGS: 3, | ||
9 | |||
10 | MANAGE_DEBUG: 4, | ||
11 | |||
12 | MANAGE_SERVER_REDUNDANCY: 5, | ||
13 | |||
14 | MANAGE_ABUSES: 6, | ||
15 | |||
16 | MANAGE_JOBS: 7, | ||
17 | |||
18 | MANAGE_CONFIGURATION: 8, | ||
19 | MANAGE_INSTANCE_CUSTOM_PAGE: 9, | ||
20 | |||
21 | MANAGE_ACCOUNTS_BLOCKLIST: 10, | ||
22 | MANAGE_SERVERS_BLOCKLIST: 11, | ||
23 | |||
24 | MANAGE_VIDEO_BLACKLIST: 12, | ||
25 | MANAGE_ANY_VIDEO_CHANNEL: 13, | ||
26 | |||
27 | REMOVE_ANY_VIDEO: 14, | ||
28 | REMOVE_ANY_VIDEO_PLAYLIST: 15, | ||
29 | REMOVE_ANY_VIDEO_COMMENT: 16, | ||
30 | |||
31 | UPDATE_ANY_VIDEO: 17, | ||
32 | UPDATE_ANY_VIDEO_PLAYLIST: 18, | ||
33 | |||
34 | GET_ANY_LIVE: 19, | ||
35 | SEE_ALL_VIDEOS: 20, | ||
36 | SEE_ALL_COMMENTS: 21, | ||
37 | CHANGE_VIDEO_OWNERSHIP: 22, | ||
38 | |||
39 | MANAGE_PLUGINS: 23, | ||
40 | |||
41 | MANAGE_VIDEOS_REDUNDANCIES: 24, | ||
42 | |||
43 | MANAGE_VIDEO_FILES: 25, | ||
44 | RUN_VIDEO_TRANSCODING: 26, | ||
45 | |||
46 | MANAGE_VIDEO_IMPORTS: 27, | ||
47 | |||
48 | MANAGE_REGISTRATIONS: 28, | ||
49 | |||
50 | MANAGE_RUNNERS: 29 | ||
51 | } as const | ||
52 | |||
53 | export type UserRightType = typeof UserRight[keyof typeof UserRight] | ||
diff --git a/packages/models/src/users/user-role.ts b/packages/models/src/users/user-role.ts new file mode 100644 index 000000000..b496f8153 --- /dev/null +++ b/packages/models/src/users/user-role.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | // Always keep this order to prevent security issue since we store these values in the database | ||
2 | export const UserRole = { | ||
3 | ADMINISTRATOR: 0, | ||
4 | MODERATOR: 1, | ||
5 | USER: 2 | ||
6 | } as const | ||
7 | |||
8 | export type UserRoleType = typeof UserRole[keyof typeof UserRole] | ||
diff --git a/packages/models/src/users/user-scoped-token.ts b/packages/models/src/users/user-scoped-token.ts new file mode 100644 index 000000000..f9d9b0a8b --- /dev/null +++ b/packages/models/src/users/user-scoped-token.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export type ScopedTokenType = 'feedToken' | ||
2 | |||
3 | export type ScopedToken = { | ||
4 | feedToken: string | ||
5 | } | ||
diff --git a/packages/models/src/users/user-update-me.model.ts b/packages/models/src/users/user-update-me.model.ts new file mode 100644 index 000000000..ba9672136 --- /dev/null +++ b/packages/models/src/users/user-update-me.model.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' | ||
2 | |||
3 | export interface UserUpdateMe { | ||
4 | displayName?: string | ||
5 | description?: string | ||
6 | nsfwPolicy?: NSFWPolicyType | ||
7 | |||
8 | p2pEnabled?: boolean | ||
9 | |||
10 | autoPlayVideo?: boolean | ||
11 | autoPlayNextVideo?: boolean | ||
12 | autoPlayNextVideoPlaylist?: boolean | ||
13 | videosHistoryEnabled?: boolean | ||
14 | videoLanguages?: string[] | ||
15 | |||
16 | email?: string | ||
17 | emailPublic?: boolean | ||
18 | currentPassword?: string | ||
19 | password?: string | ||
20 | |||
21 | theme?: string | ||
22 | |||
23 | noInstanceConfigWarningModal?: boolean | ||
24 | noWelcomeModal?: boolean | ||
25 | noAccountSetupWarningModal?: boolean | ||
26 | } | ||
diff --git a/packages/models/src/users/user-update.model.ts b/packages/models/src/users/user-update.model.ts new file mode 100644 index 000000000..283255629 --- /dev/null +++ b/packages/models/src/users/user-update.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { UserAdminFlagType } from './user-flag.model.js' | ||
2 | import { UserRoleType } from './user-role.js' | ||
3 | |||
4 | export interface UserUpdate { | ||
5 | password?: string | ||
6 | email?: string | ||
7 | emailVerified?: boolean | ||
8 | videoQuota?: number | ||
9 | videoQuotaDaily?: number | ||
10 | role?: UserRoleType | ||
11 | adminFlags?: UserAdminFlagType | ||
12 | pluginAuth?: string | ||
13 | } | ||
diff --git a/packages/models/src/users/user-video-quota.model.ts b/packages/models/src/users/user-video-quota.model.ts new file mode 100644 index 000000000..a24871d71 --- /dev/null +++ b/packages/models/src/users/user-video-quota.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface UserVideoQuota { | ||
2 | videoQuotaUsed: number | ||
3 | videoQuotaUsedDaily: number | ||
4 | } | ||
diff --git a/packages/models/src/users/user.model.ts b/packages/models/src/users/user.model.ts new file mode 100644 index 000000000..57b4c1aab --- /dev/null +++ b/packages/models/src/users/user.model.ts | |||
@@ -0,0 +1,78 @@ | |||
1 | import { Account } from '../actors/index.js' | ||
2 | import { VideoChannel } from '../videos/channel/video-channel.model.js' | ||
3 | import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' | ||
4 | import { VideoPlaylistType_Type } from '../videos/playlist/video-playlist-type.model.js' | ||
5 | import { UserAdminFlagType } from './user-flag.model.js' | ||
6 | import { UserNotificationSetting } from './user-notification-setting.model.js' | ||
7 | import { UserRoleType } from './user-role.js' | ||
8 | |||
9 | export interface User { | ||
10 | id: number | ||
11 | username: string | ||
12 | email: string | ||
13 | pendingEmail: string | null | ||
14 | |||
15 | emailVerified: boolean | ||
16 | emailPublic: boolean | ||
17 | nsfwPolicy: NSFWPolicyType | ||
18 | |||
19 | adminFlags?: UserAdminFlagType | ||
20 | |||
21 | autoPlayVideo: boolean | ||
22 | autoPlayNextVideo: boolean | ||
23 | autoPlayNextVideoPlaylist: boolean | ||
24 | |||
25 | p2pEnabled: boolean | ||
26 | |||
27 | videosHistoryEnabled: boolean | ||
28 | videoLanguages: string[] | ||
29 | |||
30 | role: { | ||
31 | id: UserRoleType | ||
32 | label: string | ||
33 | } | ||
34 | |||
35 | videoQuota: number | ||
36 | videoQuotaDaily: number | ||
37 | videoQuotaUsed?: number | ||
38 | videoQuotaUsedDaily?: number | ||
39 | |||
40 | videosCount?: number | ||
41 | |||
42 | abusesCount?: number | ||
43 | abusesAcceptedCount?: number | ||
44 | abusesCreatedCount?: number | ||
45 | |||
46 | videoCommentsCount?: number | ||
47 | |||
48 | theme: string | ||
49 | |||
50 | account: Account | ||
51 | notificationSettings?: UserNotificationSetting | ||
52 | videoChannels?: VideoChannel[] | ||
53 | |||
54 | blocked: boolean | ||
55 | blockedReason?: string | ||
56 | |||
57 | noInstanceConfigWarningModal: boolean | ||
58 | noWelcomeModal: boolean | ||
59 | noAccountSetupWarningModal: boolean | ||
60 | |||
61 | createdAt: Date | ||
62 | |||
63 | pluginAuth: string | null | ||
64 | |||
65 | lastLoginDate: Date | null | ||
66 | |||
67 | twoFactorEnabled: boolean | ||
68 | } | ||
69 | |||
70 | export interface MyUserSpecialPlaylist { | ||
71 | id: number | ||
72 | name: string | ||
73 | type: VideoPlaylistType_Type | ||
74 | } | ||
75 | |||
76 | export interface MyUser extends User { | ||
77 | specialPlaylists: MyUserSpecialPlaylist[] | ||
78 | } | ||
diff --git a/packages/models/src/videos/blacklist/index.ts b/packages/models/src/videos/blacklist/index.ts new file mode 100644 index 000000000..5eb36ad48 --- /dev/null +++ b/packages/models/src/videos/blacklist/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './video-blacklist.model.js' | ||
2 | export * from './video-blacklist-create.model.js' | ||
3 | export * from './video-blacklist-update.model.js' | ||
diff --git a/packages/models/src/videos/blacklist/video-blacklist-create.model.ts b/packages/models/src/videos/blacklist/video-blacklist-create.model.ts new file mode 100644 index 000000000..6e7d36421 --- /dev/null +++ b/packages/models/src/videos/blacklist/video-blacklist-create.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoBlacklistCreate { | ||
2 | reason?: string | ||
3 | unfederate?: boolean | ||
4 | } | ||
diff --git a/packages/models/src/videos/blacklist/video-blacklist-update.model.ts b/packages/models/src/videos/blacklist/video-blacklist-update.model.ts new file mode 100644 index 000000000..0a86cf7b0 --- /dev/null +++ b/packages/models/src/videos/blacklist/video-blacklist-update.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoBlacklistUpdate { | ||
2 | reason?: string | ||
3 | } | ||
diff --git a/packages/models/src/videos/blacklist/video-blacklist.model.ts b/packages/models/src/videos/blacklist/video-blacklist.model.ts new file mode 100644 index 000000000..1ca5bbbb7 --- /dev/null +++ b/packages/models/src/videos/blacklist/video-blacklist.model.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import { Video } from '../video.model.js' | ||
2 | |||
3 | export const VideoBlacklistType = { | ||
4 | MANUAL: 1, | ||
5 | AUTO_BEFORE_PUBLISHED: 2 | ||
6 | } as const | ||
7 | |||
8 | export type VideoBlacklistType_Type = typeof VideoBlacklistType[keyof typeof VideoBlacklistType] | ||
9 | |||
10 | export interface VideoBlacklist { | ||
11 | id: number | ||
12 | unfederated: boolean | ||
13 | reason?: string | ||
14 | type: VideoBlacklistType_Type | ||
15 | |||
16 | video: Video | ||
17 | |||
18 | createdAt: Date | ||
19 | updatedAt: Date | ||
20 | } | ||
diff --git a/packages/models/src/videos/caption/index.ts b/packages/models/src/videos/caption/index.ts new file mode 100644 index 000000000..a175768ce --- /dev/null +++ b/packages/models/src/videos/caption/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './video-caption.model.js' | ||
2 | export * from './video-caption-update.model.js' | ||
diff --git a/packages/models/src/videos/caption/video-caption-update.model.ts b/packages/models/src/videos/caption/video-caption-update.model.ts new file mode 100644 index 000000000..ff5728715 --- /dev/null +++ b/packages/models/src/videos/caption/video-caption-update.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoCaptionUpdate { | ||
2 | language: string | ||
3 | captionfile: Blob | ||
4 | } | ||
diff --git a/packages/models/src/videos/caption/video-caption.model.ts b/packages/models/src/videos/caption/video-caption.model.ts new file mode 100644 index 000000000..d6d625ff7 --- /dev/null +++ b/packages/models/src/videos/caption/video-caption.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { VideoConstant } from '../video-constant.model.js' | ||
2 | |||
3 | export interface VideoCaption { | ||
4 | language: VideoConstant<string> | ||
5 | captionPath: string | ||
6 | updatedAt: string | ||
7 | } | ||
diff --git a/packages/models/src/videos/change-ownership/index.ts b/packages/models/src/videos/change-ownership/index.ts new file mode 100644 index 000000000..6cf568f4e --- /dev/null +++ b/packages/models/src/videos/change-ownership/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './video-change-ownership-accept.model.js' | ||
2 | export * from './video-change-ownership-create.model.js' | ||
3 | export * from './video-change-ownership.model.js' | ||
diff --git a/packages/models/src/videos/change-ownership/video-change-ownership-accept.model.ts b/packages/models/src/videos/change-ownership/video-change-ownership-accept.model.ts new file mode 100644 index 000000000..f27247633 --- /dev/null +++ b/packages/models/src/videos/change-ownership/video-change-ownership-accept.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoChangeOwnershipAccept { | ||
2 | channelId: number | ||
3 | } | ||
diff --git a/packages/models/src/videos/change-ownership/video-change-ownership-create.model.ts b/packages/models/src/videos/change-ownership/video-change-ownership-create.model.ts new file mode 100644 index 000000000..40fcca285 --- /dev/null +++ b/packages/models/src/videos/change-ownership/video-change-ownership-create.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoChangeOwnershipCreate { | ||
2 | username: string | ||
3 | } | ||
diff --git a/packages/models/src/videos/change-ownership/video-change-ownership.model.ts b/packages/models/src/videos/change-ownership/video-change-ownership.model.ts new file mode 100644 index 000000000..353db37f0 --- /dev/null +++ b/packages/models/src/videos/change-ownership/video-change-ownership.model.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { Account } from '../../actors/index.js' | ||
2 | import { Video } from '../video.model.js' | ||
3 | |||
4 | export interface VideoChangeOwnership { | ||
5 | id: number | ||
6 | status: VideoChangeOwnershipStatusType | ||
7 | initiatorAccount: Account | ||
8 | nextOwnerAccount: Account | ||
9 | video: Video | ||
10 | createdAt: Date | ||
11 | } | ||
12 | |||
13 | export const VideoChangeOwnershipStatus = { | ||
14 | WAITING: 'WAITING', | ||
15 | ACCEPTED: 'ACCEPTED', | ||
16 | REFUSED: 'REFUSED' | ||
17 | } as const | ||
18 | |||
19 | export type VideoChangeOwnershipStatusType = typeof VideoChangeOwnershipStatus[keyof typeof VideoChangeOwnershipStatus] | ||
diff --git a/packages/models/src/videos/channel-sync/index.ts b/packages/models/src/videos/channel-sync/index.ts new file mode 100644 index 000000000..206cbe1b6 --- /dev/null +++ b/packages/models/src/videos/channel-sync/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './video-channel-sync-state.enum.js' | ||
2 | export * from './video-channel-sync.model.js' | ||
3 | export * from './video-channel-sync-create.model.js' | ||
diff --git a/packages/models/src/videos/channel-sync/video-channel-sync-create.model.ts b/packages/models/src/videos/channel-sync/video-channel-sync-create.model.ts new file mode 100644 index 000000000..753a8ee4c --- /dev/null +++ b/packages/models/src/videos/channel-sync/video-channel-sync-create.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoChannelSyncCreate { | ||
2 | externalChannelUrl: string | ||
3 | videoChannelId: number | ||
4 | } | ||
diff --git a/packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts b/packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts new file mode 100644 index 000000000..047444bbc --- /dev/null +++ b/packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export const VideoChannelSyncState = { | ||
2 | WAITING_FIRST_RUN: 1, | ||
3 | PROCESSING: 2, | ||
4 | SYNCED: 3, | ||
5 | FAILED: 4 | ||
6 | } as const | ||
7 | |||
8 | export type VideoChannelSyncStateType = typeof VideoChannelSyncState[keyof typeof VideoChannelSyncState] | ||
diff --git a/packages/models/src/videos/channel-sync/video-channel-sync.model.ts b/packages/models/src/videos/channel-sync/video-channel-sync.model.ts new file mode 100644 index 000000000..38ac99668 --- /dev/null +++ b/packages/models/src/videos/channel-sync/video-channel-sync.model.ts | |||
@@ -0,0 +1,14 @@ | |||
1 | import { VideoChannelSummary } from '../channel/video-channel.model.js' | ||
2 | import { VideoConstant } from '../video-constant.model.js' | ||
3 | import { VideoChannelSyncStateType } from './video-channel-sync-state.enum.js' | ||
4 | |||
5 | export interface VideoChannelSync { | ||
6 | id: number | ||
7 | |||
8 | externalChannelUrl: string | ||
9 | |||
10 | createdAt: string | ||
11 | channel: VideoChannelSummary | ||
12 | state: VideoConstant<VideoChannelSyncStateType> | ||
13 | lastSyncAt: string | ||
14 | } | ||
diff --git a/packages/models/src/videos/channel/index.ts b/packages/models/src/videos/channel/index.ts new file mode 100644 index 000000000..3c96e80f0 --- /dev/null +++ b/packages/models/src/videos/channel/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './video-channel-create-result.model.js' | ||
2 | export * from './video-channel-create.model.js' | ||
3 | export * from './video-channel-update.model.js' | ||
4 | export * from './video-channel.model.js' | ||
diff --git a/packages/models/src/videos/channel/video-channel-create-result.model.ts b/packages/models/src/videos/channel/video-channel-create-result.model.ts new file mode 100644 index 000000000..e3d7aeb4c --- /dev/null +++ b/packages/models/src/videos/channel/video-channel-create-result.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoChannelCreateResult { | ||
2 | id: number | ||
3 | } | ||
diff --git a/packages/models/src/videos/channel/video-channel-create.model.ts b/packages/models/src/videos/channel/video-channel-create.model.ts new file mode 100644 index 000000000..da8ce620c --- /dev/null +++ b/packages/models/src/videos/channel/video-channel-create.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface VideoChannelCreate { | ||
2 | name: string | ||
3 | displayName: string | ||
4 | description?: string | ||
5 | support?: string | ||
6 | } | ||
diff --git a/packages/models/src/videos/channel/video-channel-update.model.ts b/packages/models/src/videos/channel/video-channel-update.model.ts new file mode 100644 index 000000000..8dde9188b --- /dev/null +++ b/packages/models/src/videos/channel/video-channel-update.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface VideoChannelUpdate { | ||
2 | displayName?: string | ||
3 | description?: string | ||
4 | support?: string | ||
5 | |||
6 | bulkVideosSupportUpdate?: boolean | ||
7 | } | ||
diff --git a/packages/models/src/videos/channel/video-channel.model.ts b/packages/models/src/videos/channel/video-channel.model.ts new file mode 100644 index 000000000..bb10f6da5 --- /dev/null +++ b/packages/models/src/videos/channel/video-channel.model.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import { Account, ActorImage } from '../../actors/index.js' | ||
2 | import { Actor } from '../../actors/actor.model.js' | ||
3 | |||
4 | export type ViewsPerDate = { | ||
5 | date: Date | ||
6 | views: number | ||
7 | } | ||
8 | |||
9 | export interface VideoChannel extends Actor { | ||
10 | displayName: string | ||
11 | description: string | ||
12 | support: string | ||
13 | isLocal: boolean | ||
14 | |||
15 | updatedAt: Date | string | ||
16 | |||
17 | ownerAccount?: Account | ||
18 | |||
19 | videosCount?: number | ||
20 | viewsPerDay?: ViewsPerDate[] // chronologically ordered | ||
21 | totalViews?: number | ||
22 | |||
23 | banners: ActorImage[] | ||
24 | } | ||
25 | |||
26 | export interface VideoChannelSummary { | ||
27 | id: number | ||
28 | name: string | ||
29 | displayName: string | ||
30 | url: string | ||
31 | host: string | ||
32 | |||
33 | avatars: ActorImage[] | ||
34 | } | ||
diff --git a/packages/models/src/videos/comment/index.ts b/packages/models/src/videos/comment/index.ts new file mode 100644 index 000000000..bd26c652d --- /dev/null +++ b/packages/models/src/videos/comment/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './video-comment-create.model.js' | ||
2 | export * from './video-comment.model.js' | ||
diff --git a/packages/models/src/videos/comment/video-comment-create.model.ts b/packages/models/src/videos/comment/video-comment-create.model.ts new file mode 100644 index 000000000..1f0135405 --- /dev/null +++ b/packages/models/src/videos/comment/video-comment-create.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoCommentCreate { | ||
2 | text: string | ||
3 | } | ||
diff --git a/packages/models/src/videos/comment/video-comment.model.ts b/packages/models/src/videos/comment/video-comment.model.ts new file mode 100644 index 000000000..e2266545a --- /dev/null +++ b/packages/models/src/videos/comment/video-comment.model.ts | |||
@@ -0,0 +1,45 @@ | |||
1 | import { ResultList } from '../../common/index.js' | ||
2 | import { Account } from '../../actors/index.js' | ||
3 | |||
4 | export interface VideoComment { | ||
5 | id: number | ||
6 | url: string | ||
7 | text: string | ||
8 | threadId: number | ||
9 | inReplyToCommentId: number | ||
10 | videoId: number | ||
11 | createdAt: Date | string | ||
12 | updatedAt: Date | string | ||
13 | deletedAt: Date | string | ||
14 | isDeleted: boolean | ||
15 | totalRepliesFromVideoAuthor: number | ||
16 | totalReplies: number | ||
17 | account: Account | ||
18 | } | ||
19 | |||
20 | export interface VideoCommentAdmin { | ||
21 | id: number | ||
22 | url: string | ||
23 | text: string | ||
24 | |||
25 | threadId: number | ||
26 | inReplyToCommentId: number | ||
27 | |||
28 | createdAt: Date | string | ||
29 | updatedAt: Date | string | ||
30 | |||
31 | account: Account | ||
32 | |||
33 | video: { | ||
34 | id: number | ||
35 | uuid: string | ||
36 | name: string | ||
37 | } | ||
38 | } | ||
39 | |||
40 | export type VideoCommentThreads = ResultList<VideoComment> & { totalNotDeletedComments: number } | ||
41 | |||
42 | export interface VideoCommentThreadTree { | ||
43 | comment: VideoComment | ||
44 | children: VideoCommentThreadTree[] | ||
45 | } | ||
diff --git a/packages/models/src/videos/file/index.ts b/packages/models/src/videos/file/index.ts new file mode 100644 index 000000000..ee06f4e20 --- /dev/null +++ b/packages/models/src/videos/file/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './video-file-metadata.model.js' | ||
2 | export * from './video-file.model.js' | ||
3 | export * from './video-resolution.enum.js' | ||
diff --git a/packages/models/src/videos/file/video-file-metadata.model.ts b/packages/models/src/videos/file/video-file-metadata.model.ts new file mode 100644 index 000000000..8f527c0a7 --- /dev/null +++ b/packages/models/src/videos/file/video-file-metadata.model.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | export class VideoFileMetadata { | ||
2 | streams: { [x: string]: any, [x: number]: any }[] | ||
3 | format: { [x: string]: any, [x: number]: any } | ||
4 | chapters: any[] | ||
5 | |||
6 | constructor (hash: { chapters: any[], format: any, streams: any[] }) { | ||
7 | this.chapters = hash.chapters | ||
8 | this.format = hash.format | ||
9 | this.streams = hash.streams | ||
10 | |||
11 | delete this.format.filename | ||
12 | } | ||
13 | } | ||
diff --git a/packages/models/src/videos/file/video-file.model.ts b/packages/models/src/videos/file/video-file.model.ts new file mode 100644 index 000000000..2ed1ac4be --- /dev/null +++ b/packages/models/src/videos/file/video-file.model.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { VideoConstant } from '../video-constant.model.js' | ||
2 | import { VideoFileMetadata } from './video-file-metadata.model.js' | ||
3 | |||
4 | export interface VideoFile { | ||
5 | id: number | ||
6 | |||
7 | resolution: VideoConstant<number> | ||
8 | size: number // Bytes | ||
9 | |||
10 | torrentUrl: string | ||
11 | torrentDownloadUrl: string | ||
12 | |||
13 | fileUrl: string | ||
14 | fileDownloadUrl: string | ||
15 | |||
16 | fps: number | ||
17 | |||
18 | metadata?: VideoFileMetadata | ||
19 | metadataUrl?: string | ||
20 | |||
21 | magnetUri: string | null | ||
22 | } | ||
diff --git a/packages/models/src/videos/file/video-resolution.enum.ts b/packages/models/src/videos/file/video-resolution.enum.ts new file mode 100644 index 000000000..434e8c36d --- /dev/null +++ b/packages/models/src/videos/file/video-resolution.enum.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | export const VideoResolution = { | ||
2 | H_NOVIDEO: 0, | ||
3 | H_144P: 144, | ||
4 | H_240P: 240, | ||
5 | H_360P: 360, | ||
6 | H_480P: 480, | ||
7 | H_720P: 720, | ||
8 | H_1080P: 1080, | ||
9 | H_1440P: 1440, | ||
10 | H_4K: 2160 | ||
11 | } as const | ||
12 | |||
13 | export type VideoResolutionType = typeof VideoResolution[keyof typeof VideoResolution] | ||
diff --git a/packages/models/src/videos/import/index.ts b/packages/models/src/videos/import/index.ts new file mode 100644 index 000000000..6701674c5 --- /dev/null +++ b/packages/models/src/videos/import/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './video-import-create.model.js' | ||
2 | export * from './video-import-state.enum.js' | ||
3 | export * from './video-import.model.js' | ||
4 | export * from './videos-import-in-channel-create.model.js' | ||
diff --git a/packages/models/src/videos/import/video-import-create.model.ts b/packages/models/src/videos/import/video-import-create.model.ts new file mode 100644 index 000000000..3ec0d22f3 --- /dev/null +++ b/packages/models/src/videos/import/video-import-create.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { VideoUpdate } from '../video-update.model.js' | ||
2 | |||
3 | export interface VideoImportCreate extends VideoUpdate { | ||
4 | targetUrl?: string | ||
5 | magnetUri?: string | ||
6 | torrentfile?: Blob | ||
7 | |||
8 | channelId: number // Required | ||
9 | } | ||
diff --git a/packages/models/src/videos/import/video-import-state.enum.ts b/packages/models/src/videos/import/video-import-state.enum.ts new file mode 100644 index 000000000..475fdbe66 --- /dev/null +++ b/packages/models/src/videos/import/video-import-state.enum.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export const VideoImportState = { | ||
2 | PENDING: 1, | ||
3 | SUCCESS: 2, | ||
4 | FAILED: 3, | ||
5 | REJECTED: 4, | ||
6 | CANCELLED: 5, | ||
7 | PROCESSING: 6 | ||
8 | } as const | ||
9 | |||
10 | export type VideoImportStateType = typeof VideoImportState[keyof typeof VideoImportState] | ||
diff --git a/packages/models/src/videos/import/video-import.model.ts b/packages/models/src/videos/import/video-import.model.ts new file mode 100644 index 000000000..eef23f401 --- /dev/null +++ b/packages/models/src/videos/import/video-import.model.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { VideoConstant } from '../video-constant.model.js' | ||
2 | import { Video } from '../video.model.js' | ||
3 | import { VideoImportStateType } from './video-import-state.enum.js' | ||
4 | |||
5 | export interface VideoImport { | ||
6 | id: number | ||
7 | |||
8 | targetUrl: string | ||
9 | magnetUri: string | ||
10 | torrentName: string | ||
11 | |||
12 | createdAt: string | ||
13 | updatedAt: string | ||
14 | originallyPublishedAt?: string | ||
15 | state: VideoConstant<VideoImportStateType> | ||
16 | error?: string | ||
17 | |||
18 | video?: Video & { tags: string[] } | ||
19 | |||
20 | videoChannelSync?: { | ||
21 | id: number | ||
22 | externalChannelUrl: string | ||
23 | } | ||
24 | } | ||
diff --git a/packages/models/src/videos/import/videos-import-in-channel-create.model.ts b/packages/models/src/videos/import/videos-import-in-channel-create.model.ts new file mode 100644 index 000000000..fbfef63f8 --- /dev/null +++ b/packages/models/src/videos/import/videos-import-in-channel-create.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideosImportInChannelCreate { | ||
2 | externalChannelUrl: string | ||
3 | videoChannelSyncId?: number | ||
4 | } | ||
diff --git a/packages/models/src/videos/index.ts b/packages/models/src/videos/index.ts new file mode 100644 index 000000000..d131212c9 --- /dev/null +++ b/packages/models/src/videos/index.ts | |||
@@ -0,0 +1,43 @@ | |||
1 | export * from './blacklist/index.js' | ||
2 | export * from './caption/index.js' | ||
3 | export * from './change-ownership/index.js' | ||
4 | export * from './channel/index.js' | ||
5 | export * from './comment/index.js' | ||
6 | export * from './studio/index.js' | ||
7 | export * from './live/index.js' | ||
8 | export * from './file/index.js' | ||
9 | export * from './import/index.js' | ||
10 | export * from './playlist/index.js' | ||
11 | export * from './rate/index.js' | ||
12 | export * from './stats/index.js' | ||
13 | export * from './transcoding/index.js' | ||
14 | export * from './channel-sync/index.js' | ||
15 | |||
16 | export * from './nsfw-policy.type.js' | ||
17 | |||
18 | export * from './storyboard.model.js' | ||
19 | export * from './thumbnail.type.js' | ||
20 | |||
21 | export * from './video-constant.model.js' | ||
22 | export * from './video-create.model.js' | ||
23 | |||
24 | export * from './video-privacy.enum.js' | ||
25 | export * from './video-include.enum.js' | ||
26 | export * from './video-rate.type.js' | ||
27 | |||
28 | export * from './video-schedule-update.model.js' | ||
29 | export * from './video-sort-field.type.js' | ||
30 | export * from './video-state.enum.js' | ||
31 | export * from './video-storage.enum.js' | ||
32 | export * from './video-source.model.js' | ||
33 | |||
34 | export * from './video-streaming-playlist.model.js' | ||
35 | export * from './video-streaming-playlist.type.js' | ||
36 | |||
37 | export * from './video-token.model.js' | ||
38 | |||
39 | export * from './video-update.model.js' | ||
40 | export * from './video-view.model.js' | ||
41 | export * from './video.model.js' | ||
42 | export * from './video-create-result.model.js' | ||
43 | export * from './video-password.model.js' | ||
diff --git a/packages/models/src/videos/live/index.ts b/packages/models/src/videos/live/index.ts new file mode 100644 index 000000000..1763eb574 --- /dev/null +++ b/packages/models/src/videos/live/index.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export * from './live-video-create.model.js' | ||
2 | export * from './live-video-error.enum.js' | ||
3 | export * from './live-video-event-payload.model.js' | ||
4 | export * from './live-video-event.type.js' | ||
5 | export * from './live-video-latency-mode.enum.js' | ||
6 | export * from './live-video-session.model.js' | ||
7 | export * from './live-video-update.model.js' | ||
8 | export * from './live-video.model.js' | ||
diff --git a/packages/models/src/videos/live/live-video-create.model.ts b/packages/models/src/videos/live/live-video-create.model.ts new file mode 100644 index 000000000..e4e39518c --- /dev/null +++ b/packages/models/src/videos/live/live-video-create.model.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { VideoCreate } from '../video-create.model.js' | ||
2 | import { VideoPrivacyType } from '../video-privacy.enum.js' | ||
3 | import { LiveVideoLatencyModeType } from './live-video-latency-mode.enum.js' | ||
4 | |||
5 | export interface LiveVideoCreate extends VideoCreate { | ||
6 | permanentLive?: boolean | ||
7 | latencyMode?: LiveVideoLatencyModeType | ||
8 | |||
9 | saveReplay?: boolean | ||
10 | replaySettings?: { privacy: VideoPrivacyType } | ||
11 | } | ||
diff --git a/packages/models/src/videos/live/live-video-error.enum.ts b/packages/models/src/videos/live/live-video-error.enum.ts new file mode 100644 index 000000000..cd92a1cff --- /dev/null +++ b/packages/models/src/videos/live/live-video-error.enum.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | export const LiveVideoError = { | ||
2 | BAD_SOCKET_HEALTH: 1, | ||
3 | DURATION_EXCEEDED: 2, | ||
4 | QUOTA_EXCEEDED: 3, | ||
5 | FFMPEG_ERROR: 4, | ||
6 | BLACKLISTED: 5, | ||
7 | RUNNER_JOB_ERROR: 6, | ||
8 | RUNNER_JOB_CANCEL: 7 | ||
9 | } as const | ||
10 | |||
11 | export type LiveVideoErrorType = typeof LiveVideoError[keyof typeof LiveVideoError] | ||
diff --git a/packages/models/src/videos/live/live-video-event-payload.model.ts b/packages/models/src/videos/live/live-video-event-payload.model.ts new file mode 100644 index 000000000..507f8d153 --- /dev/null +++ b/packages/models/src/videos/live/live-video-event-payload.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { VideoStateType } from '../video-state.enum.js' | ||
2 | |||
3 | export interface LiveVideoEventPayload { | ||
4 | state?: VideoStateType | ||
5 | |||
6 | viewers?: number | ||
7 | } | ||
diff --git a/packages/models/src/videos/live/live-video-event.type.ts b/packages/models/src/videos/live/live-video-event.type.ts new file mode 100644 index 000000000..50f794561 --- /dev/null +++ b/packages/models/src/videos/live/live-video-event.type.ts | |||
@@ -0,0 +1 @@ | |||
export type LiveVideoEventType = 'state-change' | 'views-change' | |||
diff --git a/packages/models/src/videos/live/live-video-latency-mode.enum.ts b/packages/models/src/videos/live/live-video-latency-mode.enum.ts new file mode 100644 index 000000000..6fd8fe8e9 --- /dev/null +++ b/packages/models/src/videos/live/live-video-latency-mode.enum.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const LiveVideoLatencyMode = { | ||
2 | DEFAULT: 1, | ||
3 | HIGH_LATENCY: 2, | ||
4 | SMALL_LATENCY: 3 | ||
5 | } as const | ||
6 | |||
7 | export type LiveVideoLatencyModeType = typeof LiveVideoLatencyMode[keyof typeof LiveVideoLatencyMode] | ||
diff --git a/packages/models/src/videos/live/live-video-session.model.ts b/packages/models/src/videos/live/live-video-session.model.ts new file mode 100644 index 000000000..8d45bc86a --- /dev/null +++ b/packages/models/src/videos/live/live-video-session.model.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { VideoPrivacyType } from '../video-privacy.enum.js' | ||
2 | import { LiveVideoErrorType } from './live-video-error.enum.js' | ||
3 | |||
4 | export interface LiveVideoSession { | ||
5 | id: number | ||
6 | |||
7 | startDate: string | ||
8 | endDate: string | ||
9 | |||
10 | error: LiveVideoErrorType | ||
11 | |||
12 | saveReplay: boolean | ||
13 | endingProcessed: boolean | ||
14 | |||
15 | replaySettings?: { privacy: VideoPrivacyType } | ||
16 | |||
17 | replayVideo: { | ||
18 | id: number | ||
19 | uuid: string | ||
20 | shortUUID: string | ||
21 | } | ||
22 | } | ||
diff --git a/packages/models/src/videos/live/live-video-update.model.ts b/packages/models/src/videos/live/live-video-update.model.ts new file mode 100644 index 000000000..b4d91e447 --- /dev/null +++ b/packages/models/src/videos/live/live-video-update.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { VideoPrivacyType } from '../video-privacy.enum.js' | ||
2 | import { LiveVideoLatencyModeType } from './live-video-latency-mode.enum.js' | ||
3 | |||
4 | export interface LiveVideoUpdate { | ||
5 | permanentLive?: boolean | ||
6 | saveReplay?: boolean | ||
7 | replaySettings?: { privacy: VideoPrivacyType } | ||
8 | latencyMode?: LiveVideoLatencyModeType | ||
9 | } | ||
diff --git a/packages/models/src/videos/live/live-video.model.ts b/packages/models/src/videos/live/live-video.model.ts new file mode 100644 index 000000000..3e91f677c --- /dev/null +++ b/packages/models/src/videos/live/live-video.model.ts | |||
@@ -0,0 +1,14 @@ | |||
1 | import { VideoPrivacyType } from '../video-privacy.enum.js' | ||
2 | import { LiveVideoLatencyModeType } from './live-video-latency-mode.enum.js' | ||
3 | |||
4 | export interface LiveVideo { | ||
5 | // If owner | ||
6 | rtmpUrl?: string | ||
7 | rtmpsUrl?: string | ||
8 | streamKey?: string | ||
9 | |||
10 | saveReplay: boolean | ||
11 | replaySettings?: { privacy: VideoPrivacyType } | ||
12 | permanentLive: boolean | ||
13 | latencyMode: LiveVideoLatencyModeType | ||
14 | } | ||
diff --git a/packages/models/src/videos/nsfw-policy.type.ts b/packages/models/src/videos/nsfw-policy.type.ts new file mode 100644 index 000000000..dc0032a14 --- /dev/null +++ b/packages/models/src/videos/nsfw-policy.type.ts | |||
@@ -0,0 +1 @@ | |||
export type NSFWPolicyType = 'do_not_list' | 'blur' | 'display' | |||
diff --git a/packages/models/src/videos/playlist/index.ts b/packages/models/src/videos/playlist/index.ts new file mode 100644 index 000000000..0e139657a --- /dev/null +++ b/packages/models/src/videos/playlist/index.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | export * from './video-exist-in-playlist.model.js' | ||
2 | export * from './video-playlist-create-result.model.js' | ||
3 | export * from './video-playlist-create.model.js' | ||
4 | export * from './video-playlist-element-create-result.model.js' | ||
5 | export * from './video-playlist-element-create.model.js' | ||
6 | export * from './video-playlist-element-update.model.js' | ||
7 | export * from './video-playlist-element.model.js' | ||
8 | export * from './video-playlist-privacy.model.js' | ||
9 | export * from './video-playlist-reorder.model.js' | ||
10 | export * from './video-playlist-type.model.js' | ||
11 | export * from './video-playlist-update.model.js' | ||
12 | export * from './video-playlist.model.js' | ||
diff --git a/packages/models/src/videos/playlist/video-exist-in-playlist.model.ts b/packages/models/src/videos/playlist/video-exist-in-playlist.model.ts new file mode 100644 index 000000000..6d06c0f4d --- /dev/null +++ b/packages/models/src/videos/playlist/video-exist-in-playlist.model.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | export type VideosExistInPlaylists = { | ||
2 | [videoId: number]: VideoExistInPlaylist[] | ||
3 | } | ||
4 | export type CachedVideosExistInPlaylists = { | ||
5 | [videoId: number]: CachedVideoExistInPlaylist[] | ||
6 | } | ||
7 | |||
8 | export type CachedVideoExistInPlaylist = { | ||
9 | playlistElementId: number | ||
10 | playlistId: number | ||
11 | startTimestamp?: number | ||
12 | stopTimestamp?: number | ||
13 | } | ||
14 | |||
15 | export type VideoExistInPlaylist = CachedVideoExistInPlaylist & { | ||
16 | playlistDisplayName: string | ||
17 | playlistShortUUID: string | ||
18 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-create-result.model.ts b/packages/models/src/videos/playlist/video-playlist-create-result.model.ts new file mode 100644 index 000000000..cd9b170ae --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-create-result.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface VideoPlaylistCreateResult { | ||
2 | id: number | ||
3 | uuid: string | ||
4 | shortUUID: string | ||
5 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-create.model.ts b/packages/models/src/videos/playlist/video-playlist-create.model.ts new file mode 100644 index 000000000..f9dd1e0d1 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-create.model.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { VideoPlaylistPrivacyType } from './video-playlist-privacy.model.js' | ||
2 | |||
3 | export interface VideoPlaylistCreate { | ||
4 | displayName: string | ||
5 | privacy: VideoPlaylistPrivacyType | ||
6 | |||
7 | description?: string | ||
8 | videoChannelId?: number | ||
9 | |||
10 | thumbnailfile?: any | ||
11 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-element-create-result.model.ts b/packages/models/src/videos/playlist/video-playlist-element-create-result.model.ts new file mode 100644 index 000000000..dc475e7d8 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-element-create-result.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoPlaylistElementCreateResult { | ||
2 | id: number | ||
3 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-element-create.model.ts b/packages/models/src/videos/playlist/video-playlist-element-create.model.ts new file mode 100644 index 000000000..c31702892 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-element-create.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface VideoPlaylistElementCreate { | ||
2 | videoId: number | ||
3 | |||
4 | startTimestamp?: number | ||
5 | stopTimestamp?: number | ||
6 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-element-update.model.ts b/packages/models/src/videos/playlist/video-playlist-element-update.model.ts new file mode 100644 index 000000000..15a30fbdc --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-element-update.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoPlaylistElementUpdate { | ||
2 | startTimestamp?: number | ||
3 | stopTimestamp?: number | ||
4 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-element.model.ts b/packages/models/src/videos/playlist/video-playlist-element.model.ts new file mode 100644 index 000000000..a4711f919 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-element.model.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { Video } from '../video.model.js' | ||
2 | |||
3 | export const VideoPlaylistElementType = { | ||
4 | REGULAR: 0, | ||
5 | DELETED: 1, | ||
6 | PRIVATE: 2, | ||
7 | UNAVAILABLE: 3 // Blacklisted, blocked by the user/instance, NSFW... | ||
8 | } as const | ||
9 | |||
10 | export type VideoPlaylistElementType_Type = typeof VideoPlaylistElementType[keyof typeof VideoPlaylistElementType] | ||
11 | |||
12 | export interface VideoPlaylistElement { | ||
13 | id: number | ||
14 | position: number | ||
15 | startTimestamp: number | ||
16 | stopTimestamp: number | ||
17 | |||
18 | type: VideoPlaylistElementType_Type | ||
19 | |||
20 | video?: Video | ||
21 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-privacy.model.ts b/packages/models/src/videos/playlist/video-playlist-privacy.model.ts new file mode 100644 index 000000000..23f6a1a16 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-privacy.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const VideoPlaylistPrivacy = { | ||
2 | PUBLIC: 1, | ||
3 | UNLISTED: 2, | ||
4 | PRIVATE: 3 | ||
5 | } as const | ||
6 | |||
7 | export type VideoPlaylistPrivacyType = typeof VideoPlaylistPrivacy[keyof typeof VideoPlaylistPrivacy] | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-reorder.model.ts b/packages/models/src/videos/playlist/video-playlist-reorder.model.ts new file mode 100644 index 000000000..63ec714c5 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-reorder.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface VideoPlaylistReorder { | ||
2 | startPosition: number | ||
3 | insertAfterPosition: number | ||
4 | reorderLength?: number | ||
5 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-type.model.ts b/packages/models/src/videos/playlist/video-playlist-type.model.ts new file mode 100644 index 000000000..183439f98 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-type.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export const VideoPlaylistType = { | ||
2 | REGULAR: 1, | ||
3 | WATCH_LATER: 2 | ||
4 | } as const | ||
5 | |||
6 | export type VideoPlaylistType_Type = typeof VideoPlaylistType[keyof typeof VideoPlaylistType] | ||
diff --git a/packages/models/src/videos/playlist/video-playlist-update.model.ts b/packages/models/src/videos/playlist/video-playlist-update.model.ts new file mode 100644 index 000000000..ed536367e --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-update.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { VideoPlaylistPrivacyType } from './video-playlist-privacy.model.js' | ||
2 | |||
3 | export interface VideoPlaylistUpdate { | ||
4 | displayName?: string | ||
5 | privacy?: VideoPlaylistPrivacyType | ||
6 | |||
7 | description?: string | ||
8 | videoChannelId?: number | ||
9 | thumbnailfile?: any | ||
10 | } | ||
diff --git a/packages/models/src/videos/playlist/video-playlist.model.ts b/packages/models/src/videos/playlist/video-playlist.model.ts new file mode 100644 index 000000000..4261aac25 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist.model.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | import { AccountSummary } from '../../actors/index.js' | ||
2 | import { VideoChannelSummary } from '../channel/index.js' | ||
3 | import { VideoConstant } from '../video-constant.model.js' | ||
4 | import { VideoPlaylistPrivacyType } from './video-playlist-privacy.model.js' | ||
5 | import { VideoPlaylistType_Type } from './video-playlist-type.model.js' | ||
6 | |||
7 | export interface VideoPlaylist { | ||
8 | id: number | ||
9 | uuid: string | ||
10 | shortUUID: string | ||
11 | |||
12 | isLocal: boolean | ||
13 | |||
14 | url: string | ||
15 | |||
16 | displayName: string | ||
17 | description: string | ||
18 | privacy: VideoConstant<VideoPlaylistPrivacyType> | ||
19 | |||
20 | thumbnailPath: string | ||
21 | thumbnailUrl?: string | ||
22 | |||
23 | videosLength: number | ||
24 | |||
25 | type: VideoConstant<VideoPlaylistType_Type> | ||
26 | |||
27 | embedPath: string | ||
28 | embedUrl?: string | ||
29 | |||
30 | createdAt: Date | string | ||
31 | updatedAt: Date | string | ||
32 | |||
33 | ownerAccount: AccountSummary | ||
34 | videoChannel?: VideoChannelSummary | ||
35 | } | ||
diff --git a/packages/models/src/videos/rate/account-video-rate.model.ts b/packages/models/src/videos/rate/account-video-rate.model.ts new file mode 100644 index 000000000..d19ccdbdd --- /dev/null +++ b/packages/models/src/videos/rate/account-video-rate.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { UserVideoRateType } from './user-video-rate.type.js' | ||
2 | import { Video } from '../video.model.js' | ||
3 | |||
4 | export interface AccountVideoRate { | ||
5 | video: Video | ||
6 | rating: UserVideoRateType | ||
7 | } | ||
diff --git a/packages/models/src/videos/rate/index.ts b/packages/models/src/videos/rate/index.ts new file mode 100644 index 000000000..ecbe3523d --- /dev/null +++ b/packages/models/src/videos/rate/index.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | |||
2 | export * from './user-video-rate-update.model.js' | ||
3 | export * from './user-video-rate.model.js' | ||
4 | export * from './account-video-rate.model.js' | ||
5 | export * from './user-video-rate.type.js' | ||
diff --git a/packages/models/src/videos/rate/user-video-rate-update.model.ts b/packages/models/src/videos/rate/user-video-rate-update.model.ts new file mode 100644 index 000000000..8ee1e78ca --- /dev/null +++ b/packages/models/src/videos/rate/user-video-rate-update.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { UserVideoRateType } from './user-video-rate.type.js' | ||
2 | |||
3 | export interface UserVideoRateUpdate { | ||
4 | rating: UserVideoRateType | ||
5 | } | ||
diff --git a/packages/models/src/videos/rate/user-video-rate.model.ts b/packages/models/src/videos/rate/user-video-rate.model.ts new file mode 100644 index 000000000..344cf9a68 --- /dev/null +++ b/packages/models/src/videos/rate/user-video-rate.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | import { UserVideoRateType } from './user-video-rate.type.js' | ||
2 | |||
3 | export interface UserVideoRate { | ||
4 | videoId: number | ||
5 | rating: UserVideoRateType | ||
6 | } | ||
diff --git a/packages/models/src/videos/rate/user-video-rate.type.ts b/packages/models/src/videos/rate/user-video-rate.type.ts new file mode 100644 index 000000000..a4d9c7e39 --- /dev/null +++ b/packages/models/src/videos/rate/user-video-rate.type.ts | |||
@@ -0,0 +1 @@ | |||
export type UserVideoRateType = 'like' | 'dislike' | 'none' | |||
diff --git a/packages/models/src/videos/stats/index.ts b/packages/models/src/videos/stats/index.ts new file mode 100644 index 000000000..7187cac26 --- /dev/null +++ b/packages/models/src/videos/stats/index.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export * from './video-stats-overall-query.model.js' | ||
2 | export * from './video-stats-overall.model.js' | ||
3 | export * from './video-stats-retention.model.js' | ||
4 | export * from './video-stats-timeserie-query.model.js' | ||
5 | export * from './video-stats-timeserie-metric.type.js' | ||
6 | export * from './video-stats-timeserie.model.js' | ||
diff --git a/packages/models/src/videos/stats/video-stats-overall-query.model.ts b/packages/models/src/videos/stats/video-stats-overall-query.model.ts new file mode 100644 index 000000000..6b4c2164f --- /dev/null +++ b/packages/models/src/videos/stats/video-stats-overall-query.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoStatsOverallQuery { | ||
2 | startDate?: string | ||
3 | endDate?: string | ||
4 | } | ||
diff --git a/packages/models/src/videos/stats/video-stats-overall.model.ts b/packages/models/src/videos/stats/video-stats-overall.model.ts new file mode 100644 index 000000000..54b57798f --- /dev/null +++ b/packages/models/src/videos/stats/video-stats-overall.model.ts | |||
@@ -0,0 +1,14 @@ | |||
1 | export interface VideoStatsOverall { | ||
2 | averageWatchTime: number | ||
3 | totalWatchTime: number | ||
4 | |||
5 | totalViewers: number | ||
6 | |||
7 | viewersPeak: number | ||
8 | viewersPeakDate: string | ||
9 | |||
10 | countries: { | ||
11 | isoCode: string | ||
12 | viewers: number | ||
13 | }[] | ||
14 | } | ||
diff --git a/packages/models/src/videos/stats/video-stats-retention.model.ts b/packages/models/src/videos/stats/video-stats-retention.model.ts new file mode 100644 index 000000000..e494888ed --- /dev/null +++ b/packages/models/src/videos/stats/video-stats-retention.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface VideoStatsRetention { | ||
2 | data: { | ||
3 | second: number | ||
4 | retentionPercent: number | ||
5 | }[] | ||
6 | } | ||
diff --git a/packages/models/src/videos/stats/video-stats-timeserie-metric.type.ts b/packages/models/src/videos/stats/video-stats-timeserie-metric.type.ts new file mode 100644 index 000000000..fc268d083 --- /dev/null +++ b/packages/models/src/videos/stats/video-stats-timeserie-metric.type.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoStatsTimeserieMetric = 'viewers' | 'aggregateWatchTime' | |||
diff --git a/packages/models/src/videos/stats/video-stats-timeserie-query.model.ts b/packages/models/src/videos/stats/video-stats-timeserie-query.model.ts new file mode 100644 index 000000000..f3a8430e1 --- /dev/null +++ b/packages/models/src/videos/stats/video-stats-timeserie-query.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoStatsTimeserieQuery { | ||
2 | startDate?: string | ||
3 | endDate?: string | ||
4 | } | ||
diff --git a/packages/models/src/videos/stats/video-stats-timeserie.model.ts b/packages/models/src/videos/stats/video-stats-timeserie.model.ts new file mode 100644 index 000000000..4a0e208df --- /dev/null +++ b/packages/models/src/videos/stats/video-stats-timeserie.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export interface VideoStatsTimeserie { | ||
2 | groupInterval: string | ||
3 | |||
4 | data: { | ||
5 | date: string | ||
6 | value: number | ||
7 | }[] | ||
8 | } | ||
diff --git a/packages/models/src/videos/storyboard.model.ts b/packages/models/src/videos/storyboard.model.ts new file mode 100644 index 000000000..c92c81f09 --- /dev/null +++ b/packages/models/src/videos/storyboard.model.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | export interface Storyboard { | ||
2 | storyboardPath: string | ||
3 | |||
4 | totalHeight: number | ||
5 | totalWidth: number | ||
6 | |||
7 | spriteHeight: number | ||
8 | spriteWidth: number | ||
9 | |||
10 | spriteDuration: number | ||
11 | } | ||
diff --git a/packages/models/src/videos/studio/index.ts b/packages/models/src/videos/studio/index.ts new file mode 100644 index 000000000..0d8ad3227 --- /dev/null +++ b/packages/models/src/videos/studio/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './video-studio-create-edit.model.js' | |||
diff --git a/packages/models/src/videos/studio/video-studio-create-edit.model.ts b/packages/models/src/videos/studio/video-studio-create-edit.model.ts new file mode 100644 index 000000000..5e8296dc9 --- /dev/null +++ b/packages/models/src/videos/studio/video-studio-create-edit.model.ts | |||
@@ -0,0 +1,60 @@ | |||
1 | export interface VideoStudioCreateEdition { | ||
2 | tasks: VideoStudioTask[] | ||
3 | } | ||
4 | |||
5 | export type VideoStudioTask = | ||
6 | VideoStudioTaskCut | | ||
7 | VideoStudioTaskIntro | | ||
8 | VideoStudioTaskOutro | | ||
9 | VideoStudioTaskWatermark | ||
10 | |||
11 | export interface VideoStudioTaskCut { | ||
12 | name: 'cut' | ||
13 | |||
14 | options: { | ||
15 | start?: number | ||
16 | end?: number | ||
17 | } | ||
18 | } | ||
19 | |||
20 | export interface VideoStudioTaskIntro { | ||
21 | name: 'add-intro' | ||
22 | |||
23 | options: { | ||
24 | file: Blob | string | ||
25 | } | ||
26 | } | ||
27 | |||
28 | export interface VideoStudioTaskOutro { | ||
29 | name: 'add-outro' | ||
30 | |||
31 | options: { | ||
32 | file: Blob | string | ||
33 | } | ||
34 | } | ||
35 | |||
36 | export interface VideoStudioTaskWatermark { | ||
37 | name: 'add-watermark' | ||
38 | |||
39 | options: { | ||
40 | file: Blob | string | ||
41 | } | ||
42 | } | ||
43 | |||
44 | // --------------------------------------------------------------------------- | ||
45 | |||
46 | export function isVideoStudioTaskIntro (v: VideoStudioTask): v is VideoStudioTaskIntro { | ||
47 | return v.name === 'add-intro' | ||
48 | } | ||
49 | |||
50 | export function isVideoStudioTaskOutro (v: VideoStudioTask): v is VideoStudioTaskOutro { | ||
51 | return v.name === 'add-outro' | ||
52 | } | ||
53 | |||
54 | export function isVideoStudioTaskWatermark (v: VideoStudioTask): v is VideoStudioTaskWatermark { | ||
55 | return v.name === 'add-watermark' | ||
56 | } | ||
57 | |||
58 | export function hasVideoStudioTaskFile (v: VideoStudioTask): v is VideoStudioTaskIntro | VideoStudioTaskOutro | VideoStudioTaskWatermark { | ||
59 | return isVideoStudioTaskIntro(v) || isVideoStudioTaskOutro(v) || isVideoStudioTaskWatermark(v) | ||
60 | } | ||
diff --git a/packages/models/src/videos/thumbnail.type.ts b/packages/models/src/videos/thumbnail.type.ts new file mode 100644 index 000000000..0cb7483ec --- /dev/null +++ b/packages/models/src/videos/thumbnail.type.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export const ThumbnailType = { | ||
2 | MINIATURE: 1, | ||
3 | PREVIEW: 2 | ||
4 | } as const | ||
5 | |||
6 | export type ThumbnailType_Type = typeof ThumbnailType[keyof typeof ThumbnailType] | ||
diff --git a/packages/models/src/videos/transcoding/index.ts b/packages/models/src/videos/transcoding/index.ts new file mode 100644 index 000000000..e1d931bd5 --- /dev/null +++ b/packages/models/src/videos/transcoding/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './video-transcoding-create.model.js' | ||
2 | export * from './video-transcoding-fps.model.js' | ||
3 | export * from './video-transcoding.model.js' | ||
diff --git a/packages/models/src/videos/transcoding/video-transcoding-create.model.ts b/packages/models/src/videos/transcoding/video-transcoding-create.model.ts new file mode 100644 index 000000000..6c2dbefa6 --- /dev/null +++ b/packages/models/src/videos/transcoding/video-transcoding-create.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface VideoTranscodingCreate { | ||
2 | transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7 | ||
3 | |||
4 | forceTranscoding?: boolean // Default false | ||
5 | } | ||
diff --git a/packages/models/src/videos/transcoding/video-transcoding-fps.model.ts b/packages/models/src/videos/transcoding/video-transcoding-fps.model.ts new file mode 100644 index 000000000..9a330ac94 --- /dev/null +++ b/packages/models/src/videos/transcoding/video-transcoding-fps.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export type VideoTranscodingFPS = { | ||
2 | MIN: number | ||
3 | STANDARD: number[] | ||
4 | HD_STANDARD: number[] | ||
5 | AUDIO_MERGE: number | ||
6 | AVERAGE: number | ||
7 | MAX: number | ||
8 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number | ||
9 | } | ||
diff --git a/packages/models/src/videos/transcoding/video-transcoding.model.ts b/packages/models/src/videos/transcoding/video-transcoding.model.ts new file mode 100644 index 000000000..e2c2a56e5 --- /dev/null +++ b/packages/models/src/videos/transcoding/video-transcoding.model.ts | |||
@@ -0,0 +1,65 @@ | |||
1 | // Types used by plugins and ffmpeg-utils | ||
2 | |||
3 | export type EncoderOptionsBuilderParams = { | ||
4 | input: string | ||
5 | |||
6 | resolution: number | ||
7 | |||
8 | // If PeerTube applies a filter, transcoding profile must not copy input stream | ||
9 | canCopyAudio: boolean | ||
10 | canCopyVideo: boolean | ||
11 | |||
12 | fps: number | ||
13 | |||
14 | // Could be undefined if we could not get input bitrate (some RTMP streams for example) | ||
15 | inputBitrate: number | ||
16 | inputRatio: number | ||
17 | |||
18 | // For lives | ||
19 | streamNum?: number | ||
20 | } | ||
21 | |||
22 | export type EncoderOptionsBuilder = (params: EncoderOptionsBuilderParams) => Promise<EncoderOptions> | EncoderOptions | ||
23 | |||
24 | export interface EncoderOptions { | ||
25 | copy?: boolean // Copy stream? Default to false | ||
26 | |||
27 | scaleFilter?: { | ||
28 | name: string | ||
29 | } | ||
30 | |||
31 | inputOptions?: string[] | ||
32 | outputOptions?: string[] | ||
33 | } | ||
34 | |||
35 | // All our encoders | ||
36 | |||
37 | export interface EncoderProfile <T> { | ||
38 | [ profile: string ]: T | ||
39 | |||
40 | default: T | ||
41 | } | ||
42 | |||
43 | export type AvailableEncoders = { | ||
44 | available: { | ||
45 | live: { | ||
46 | [ encoder: string ]: EncoderProfile<EncoderOptionsBuilder> | ||
47 | } | ||
48 | |||
49 | vod: { | ||
50 | [ encoder: string ]: EncoderProfile<EncoderOptionsBuilder> | ||
51 | } | ||
52 | } | ||
53 | |||
54 | encodersToTry: { | ||
55 | vod: { | ||
56 | video: string[] | ||
57 | audio: string[] | ||
58 | } | ||
59 | |||
60 | live: { | ||
61 | video: string[] | ||
62 | audio: string[] | ||
63 | } | ||
64 | } | ||
65 | } | ||
diff --git a/packages/models/src/videos/video-constant.model.ts b/packages/models/src/videos/video-constant.model.ts new file mode 100644 index 000000000..353a29535 --- /dev/null +++ b/packages/models/src/videos/video-constant.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface VideoConstant<T> { | ||
2 | id: T | ||
3 | label: string | ||
4 | description?: string | ||
5 | } | ||
diff --git a/packages/models/src/videos/video-create-result.model.ts b/packages/models/src/videos/video-create-result.model.ts new file mode 100644 index 000000000..a9f8e25a0 --- /dev/null +++ b/packages/models/src/videos/video-create-result.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface VideoCreateResult { | ||
2 | id: number | ||
3 | uuid: string | ||
4 | shortUUID: string | ||
5 | } | ||
diff --git a/packages/models/src/videos/video-create.model.ts b/packages/models/src/videos/video-create.model.ts new file mode 100644 index 000000000..472201211 --- /dev/null +++ b/packages/models/src/videos/video-create.model.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { VideoPrivacyType } from './video-privacy.enum.js' | ||
2 | import { VideoScheduleUpdate } from './video-schedule-update.model.js' | ||
3 | |||
4 | export interface VideoCreate { | ||
5 | name: string | ||
6 | channelId: number | ||
7 | |||
8 | category?: number | ||
9 | licence?: number | ||
10 | language?: string | ||
11 | description?: string | ||
12 | support?: string | ||
13 | nsfw?: boolean | ||
14 | waitTranscoding?: boolean | ||
15 | tags?: string[] | ||
16 | commentsEnabled?: boolean | ||
17 | downloadEnabled?: boolean | ||
18 | privacy: VideoPrivacyType | ||
19 | scheduleUpdate?: VideoScheduleUpdate | ||
20 | originallyPublishedAt?: Date | string | ||
21 | videoPasswords?: string[] | ||
22 | |||
23 | thumbnailfile?: Blob | string | ||
24 | previewfile?: Blob | string | ||
25 | } | ||
diff --git a/packages/models/src/videos/video-include.enum.ts b/packages/models/src/videos/video-include.enum.ts new file mode 100644 index 000000000..7d88a6890 --- /dev/null +++ b/packages/models/src/videos/video-include.enum.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export const VideoInclude = { | ||
2 | NONE: 0, | ||
3 | NOT_PUBLISHED_STATE: 1 << 0, | ||
4 | BLACKLISTED: 1 << 1, | ||
5 | BLOCKED_OWNER: 1 << 2, | ||
6 | FILES: 1 << 3, | ||
7 | CAPTIONS: 1 << 4 | ||
8 | } as const | ||
9 | |||
10 | export type VideoIncludeType = typeof VideoInclude[keyof typeof VideoInclude] | ||
diff --git a/packages/models/src/videos/video-password.model.ts b/packages/models/src/videos/video-password.model.ts new file mode 100644 index 000000000..c0280b9b9 --- /dev/null +++ b/packages/models/src/videos/video-password.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface VideoPassword { | ||
2 | id: number | ||
3 | password: string | ||
4 | videoId: number | ||
5 | createdAt: Date | string | ||
6 | updatedAt: Date | string | ||
7 | } | ||
diff --git a/packages/models/src/videos/video-privacy.enum.ts b/packages/models/src/videos/video-privacy.enum.ts new file mode 100644 index 000000000..cbcc91b3f --- /dev/null +++ b/packages/models/src/videos/video-privacy.enum.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export const VideoPrivacy = { | ||
2 | PUBLIC: 1, | ||
3 | UNLISTED: 2, | ||
4 | PRIVATE: 3, | ||
5 | INTERNAL: 4, | ||
6 | PASSWORD_PROTECTED: 5 | ||
7 | } as const | ||
8 | |||
9 | export type VideoPrivacyType = typeof VideoPrivacy[keyof typeof VideoPrivacy] | ||
diff --git a/packages/models/src/videos/video-rate.type.ts b/packages/models/src/videos/video-rate.type.ts new file mode 100644 index 000000000..d48774a4b --- /dev/null +++ b/packages/models/src/videos/video-rate.type.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRateType = 'like' | 'dislike' | |||
diff --git a/packages/models/src/videos/video-schedule-update.model.ts b/packages/models/src/videos/video-schedule-update.model.ts new file mode 100644 index 000000000..2e6a5551d --- /dev/null +++ b/packages/models/src/videos/video-schedule-update.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { VideoPrivacy } from './video-privacy.enum.js' | ||
2 | |||
3 | export interface VideoScheduleUpdate { | ||
4 | updateAt: Date | string | ||
5 | // Cannot schedule an update to PRIVATE | ||
6 | privacy?: typeof VideoPrivacy.PUBLIC | typeof VideoPrivacy.UNLISTED | typeof VideoPrivacy.INTERNAL | ||
7 | } | ||
diff --git a/packages/models/src/videos/video-sort-field.type.ts b/packages/models/src/videos/video-sort-field.type.ts new file mode 100644 index 000000000..7fa07fa73 --- /dev/null +++ b/packages/models/src/videos/video-sort-field.type.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | export type VideoSortField = | ||
2 | 'name' | '-name' | | ||
3 | 'duration' | '-duration' | | ||
4 | 'publishedAt' | '-publishedAt' | | ||
5 | 'originallyPublishedAt' | '-originallyPublishedAt' | | ||
6 | 'createdAt' | '-createdAt' | | ||
7 | 'views' | '-views' | | ||
8 | 'likes' | '-likes' | | ||
9 | |||
10 | // trending sorts | ||
11 | 'trending' | '-trending' | | ||
12 | 'hot' | '-hot' | | ||
13 | 'best' | '-best' | ||
diff --git a/packages/models/src/videos/video-source.model.ts b/packages/models/src/videos/video-source.model.ts new file mode 100644 index 000000000..bf4ad2453 --- /dev/null +++ b/packages/models/src/videos/video-source.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface VideoSource { | ||
2 | filename: string | ||
3 | createdAt: string | Date | ||
4 | } | ||
diff --git a/packages/models/src/videos/video-state.enum.ts b/packages/models/src/videos/video-state.enum.ts new file mode 100644 index 000000000..ae7c6a0c4 --- /dev/null +++ b/packages/models/src/videos/video-state.enum.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | export const VideoState = { | ||
2 | PUBLISHED: 1, | ||
3 | TO_TRANSCODE: 2, | ||
4 | TO_IMPORT: 3, | ||
5 | WAITING_FOR_LIVE: 4, | ||
6 | LIVE_ENDED: 5, | ||
7 | TO_MOVE_TO_EXTERNAL_STORAGE: 6, | ||
8 | TRANSCODING_FAILED: 7, | ||
9 | TO_MOVE_TO_EXTERNAL_STORAGE_FAILED: 8, | ||
10 | TO_EDIT: 9 | ||
11 | } as const | ||
12 | |||
13 | export type VideoStateType = typeof VideoState[keyof typeof VideoState] | ||
diff --git a/packages/models/src/videos/video-storage.enum.ts b/packages/models/src/videos/video-storage.enum.ts new file mode 100644 index 000000000..de5c92e0d --- /dev/null +++ b/packages/models/src/videos/video-storage.enum.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export const VideoStorage = { | ||
2 | FILE_SYSTEM: 0, | ||
3 | OBJECT_STORAGE: 1 | ||
4 | } as const | ||
5 | |||
6 | export type VideoStorageType = typeof VideoStorage[keyof typeof VideoStorage] | ||
diff --git a/packages/models/src/videos/video-streaming-playlist.model.ts b/packages/models/src/videos/video-streaming-playlist.model.ts new file mode 100644 index 000000000..80aa70e3c --- /dev/null +++ b/packages/models/src/videos/video-streaming-playlist.model.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { VideoFile } from './file/index.js' | ||
2 | import { VideoStreamingPlaylistType_Type } from './video-streaming-playlist.type.js' | ||
3 | |||
4 | export interface VideoStreamingPlaylist { | ||
5 | id: number | ||
6 | type: VideoStreamingPlaylistType_Type | ||
7 | playlistUrl: string | ||
8 | segmentsSha256Url: string | ||
9 | |||
10 | redundancies: { | ||
11 | baseUrl: string | ||
12 | }[] | ||
13 | |||
14 | files: VideoFile[] | ||
15 | } | ||
diff --git a/packages/models/src/videos/video-streaming-playlist.type.ts b/packages/models/src/videos/video-streaming-playlist.type.ts new file mode 100644 index 000000000..07a2c207f --- /dev/null +++ b/packages/models/src/videos/video-streaming-playlist.type.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export const VideoStreamingPlaylistType = { | ||
2 | HLS: 1 | ||
3 | } as const | ||
4 | |||
5 | export type VideoStreamingPlaylistType_Type = typeof VideoStreamingPlaylistType[keyof typeof VideoStreamingPlaylistType] | ||
diff --git a/packages/models/src/videos/video-token.model.ts b/packages/models/src/videos/video-token.model.ts new file mode 100644 index 000000000..aefea565f --- /dev/null +++ b/packages/models/src/videos/video-token.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface VideoToken { | ||
2 | files: { | ||
3 | token: string | ||
4 | expires: string | Date | ||
5 | } | ||
6 | } | ||
diff --git a/packages/models/src/videos/video-update.model.ts b/packages/models/src/videos/video-update.model.ts new file mode 100644 index 000000000..8af298160 --- /dev/null +++ b/packages/models/src/videos/video-update.model.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { VideoPrivacyType } from './video-privacy.enum.js' | ||
2 | import { VideoScheduleUpdate } from './video-schedule-update.model.js' | ||
3 | |||
4 | export interface VideoUpdate { | ||
5 | name?: string | ||
6 | category?: number | ||
7 | licence?: number | ||
8 | language?: string | ||
9 | description?: string | ||
10 | support?: string | ||
11 | privacy?: VideoPrivacyType | ||
12 | tags?: string[] | ||
13 | commentsEnabled?: boolean | ||
14 | downloadEnabled?: boolean | ||
15 | nsfw?: boolean | ||
16 | waitTranscoding?: boolean | ||
17 | channelId?: number | ||
18 | thumbnailfile?: Blob | ||
19 | previewfile?: Blob | ||
20 | scheduleUpdate?: VideoScheduleUpdate | ||
21 | originallyPublishedAt?: Date | string | ||
22 | videoPasswords?: string[] | ||
23 | |||
24 | pluginData?: any | ||
25 | } | ||
diff --git a/packages/models/src/videos/video-view.model.ts b/packages/models/src/videos/video-view.model.ts new file mode 100644 index 000000000..f61211104 --- /dev/null +++ b/packages/models/src/videos/video-view.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export type VideoViewEvent = 'seek' | ||
2 | |||
3 | export interface VideoView { | ||
4 | currentTime: number | ||
5 | viewEvent?: VideoViewEvent | ||
6 | } | ||
diff --git a/packages/models/src/videos/video.model.ts b/packages/models/src/videos/video.model.ts new file mode 100644 index 000000000..a750e220d --- /dev/null +++ b/packages/models/src/videos/video.model.ts | |||
@@ -0,0 +1,99 @@ | |||
1 | import { Account, AccountSummary } from '../actors/index.js' | ||
2 | import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model.js' | ||
3 | import { VideoFile } from './file/index.js' | ||
4 | import { VideoConstant } from './video-constant.model.js' | ||
5 | import { VideoPrivacyType } from './video-privacy.enum.js' | ||
6 | import { VideoScheduleUpdate } from './video-schedule-update.model.js' | ||
7 | import { VideoStateType } from './video-state.enum.js' | ||
8 | import { VideoStreamingPlaylist } from './video-streaming-playlist.model.js' | ||
9 | |||
10 | export interface Video extends Partial<VideoAdditionalAttributes> { | ||
11 | id: number | ||
12 | uuid: string | ||
13 | shortUUID: string | ||
14 | |||
15 | createdAt: Date | string | ||
16 | updatedAt: Date | string | ||
17 | publishedAt: Date | string | ||
18 | originallyPublishedAt: Date | string | ||
19 | category: VideoConstant<number> | ||
20 | licence: VideoConstant<number> | ||
21 | language: VideoConstant<string> | ||
22 | privacy: VideoConstant<VideoPrivacyType> | ||
23 | |||
24 | // Deprecated in 5.0 in favour of truncatedDescription | ||
25 | description: string | ||
26 | truncatedDescription: string | ||
27 | |||
28 | duration: number | ||
29 | isLocal: boolean | ||
30 | name: string | ||
31 | |||
32 | isLive: boolean | ||
33 | |||
34 | thumbnailPath: string | ||
35 | thumbnailUrl?: string | ||
36 | |||
37 | previewPath: string | ||
38 | previewUrl?: string | ||
39 | |||
40 | embedPath: string | ||
41 | embedUrl?: string | ||
42 | |||
43 | url: string | ||
44 | |||
45 | views: number | ||
46 | viewers: number | ||
47 | |||
48 | likes: number | ||
49 | dislikes: number | ||
50 | nsfw: boolean | ||
51 | |||
52 | account: AccountSummary | ||
53 | channel: VideoChannelSummary | ||
54 | |||
55 | userHistory?: { | ||
56 | currentTime: number | ||
57 | } | ||
58 | |||
59 | pluginData?: any | ||
60 | } | ||
61 | |||
62 | // Not included by default, needs query params | ||
63 | export interface VideoAdditionalAttributes { | ||
64 | waitTranscoding: boolean | ||
65 | state: VideoConstant<VideoStateType> | ||
66 | scheduledUpdate: VideoScheduleUpdate | ||
67 | |||
68 | blacklisted: boolean | ||
69 | blacklistedReason: string | ||
70 | |||
71 | blockedOwner: boolean | ||
72 | blockedServer: boolean | ||
73 | |||
74 | files: VideoFile[] | ||
75 | streamingPlaylists: VideoStreamingPlaylist[] | ||
76 | } | ||
77 | |||
78 | export interface VideoDetails extends Video { | ||
79 | // Deprecated in 5.0 | ||
80 | descriptionPath: string | ||
81 | |||
82 | support: string | ||
83 | channel: VideoChannel | ||
84 | account: Account | ||
85 | tags: string[] | ||
86 | commentsEnabled: boolean | ||
87 | downloadEnabled: boolean | ||
88 | |||
89 | // Not optional in details (unlike in parent Video) | ||
90 | waitTranscoding: boolean | ||
91 | state: VideoConstant<VideoStateType> | ||
92 | |||
93 | trackerUrls: string[] | ||
94 | |||
95 | files: VideoFile[] | ||
96 | streamingPlaylists: VideoStreamingPlaylist[] | ||
97 | |||
98 | inputFileUpdatedAt: string | Date | ||
99 | } | ||