diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-10 19:43:21 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-10 19:43:21 +0200 |
commit | 4771e0008dd26eadbb7eaff64255a6ec914fdadb (patch) | |
tree | 4fd58f8a3f3c2d674b936c99817b4f5fb958c5d8 /shared | |
parent | 7a214f746bf420defbf17fa218d90d6233551bf8 (diff) | |
download | PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.tar.gz PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.tar.zst PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.zip |
Better typescript typing for a better world
Diffstat (limited to 'shared')
29 files changed, 173 insertions, 14 deletions
diff --git a/shared/models/index.ts b/shared/models/index.ts index cd885af89..02665a3e6 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -1,11 +1,8 @@ | |||
1 | export * from './pods' | ||
2 | export * from './users' | ||
3 | export * from './videos' | ||
1 | export * from './job.model' | 4 | export * from './job.model' |
2 | export * from './oauth-client-local.model' | 5 | export * from './oauth-client-local.model' |
3 | export * from './pod.model' | ||
4 | export * from './result-list.model' | 6 | export * from './result-list.model' |
5 | export * from './request-scheduler.model' | 7 | export * from './request-scheduler.model' |
6 | export * from './user-video-rate.model' | ||
7 | export * from './user.model' | ||
8 | export * from './video-abuse.model' | ||
9 | export * from './video-blacklist.model' | ||
10 | export * from './video.model' | ||
11 | export * from './server-config.model' | 8 | export * from './server-config.model' |
diff --git a/shared/models/pods/index.ts b/shared/models/pods/index.ts new file mode 100644 index 000000000..f59d01540 --- /dev/null +++ b/shared/models/pods/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './pod-signature.model' | ||
2 | export * from './pod.model' | ||
3 | export * from './remote-video' | ||
diff --git a/shared/models/pods/pod-signature.model.ts b/shared/models/pods/pod-signature.model.ts new file mode 100644 index 000000000..b7988a40c --- /dev/null +++ b/shared/models/pods/pod-signature.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface PodSignature { | ||
2 | host: string | ||
3 | signature: string | ||
4 | } | ||
diff --git a/shared/models/pod.model.ts b/shared/models/pods/pod.model.ts index d25421936..d25421936 100644 --- a/shared/models/pod.model.ts +++ b/shared/models/pods/pod.model.ts | |||
diff --git a/shared/models/pods/remote-video/index.ts b/shared/models/pods/remote-video/index.ts new file mode 100644 index 000000000..c88116849 --- /dev/null +++ b/shared/models/pods/remote-video/index.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export * from './remote-qadu-video-request.model' | ||
2 | export * from './remote-video-event-request.model' | ||
3 | export * from './remote-video-request.model' | ||
4 | export * from './remote-video-create-request.model' | ||
5 | export * from './remote-video-update-request.model' | ||
6 | export * from './remote-video-remove-request.model' | ||
7 | export * from './remote-video-report-abuse-request.model' | ||
diff --git a/shared/models/pods/remote-video/remote-qadu-video-request.model.ts b/shared/models/pods/remote-video/remote-qadu-video-request.model.ts new file mode 100644 index 000000000..0f84e3f13 --- /dev/null +++ b/shared/models/pods/remote-video/remote-qadu-video-request.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export interface RemoteQaduVideoData { | ||
2 | remoteId: string | ||
3 | views?: number | ||
4 | likes?: number | ||
5 | dislikes?: number | ||
6 | } | ||
7 | |||
8 | export interface RemoteQaduVideoRequest { | ||
9 | data: RemoteQaduVideoData | ||
10 | } | ||
diff --git a/shared/models/pods/remote-video/remote-video-create-request.model.ts b/shared/models/pods/remote-video/remote-video-create-request.model.ts new file mode 100644 index 000000000..6babb0083 --- /dev/null +++ b/shared/models/pods/remote-video/remote-video-create-request.model.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import { RemoteVideoRequest } from './remote-video-request.model' | ||
2 | |||
3 | export interface RemoteVideoCreateData { | ||
4 | remoteId: string | ||
5 | author: string | ||
6 | tags: string[] | ||
7 | name: string | ||
8 | extname: string | ||
9 | infoHash: string | ||
10 | category: number | ||
11 | licence: number | ||
12 | language: number | ||
13 | nsfw: boolean | ||
14 | description: string | ||
15 | duration: number | ||
16 | createdAt: Date | ||
17 | updatedAt: Date | ||
18 | views: number | ||
19 | likes: number | ||
20 | dislikes: number | ||
21 | thumbnailData: string | ||
22 | } | ||
23 | |||
24 | export interface RemoteVideoCreateRequest extends RemoteVideoRequest { | ||
25 | type: 'add' | ||
26 | data: RemoteVideoCreateData | ||
27 | } | ||
diff --git a/shared/models/pods/remote-video/remote-video-event-request.model.ts b/shared/models/pods/remote-video/remote-video-event-request.model.ts new file mode 100644 index 000000000..84df1ca2f --- /dev/null +++ b/shared/models/pods/remote-video/remote-video-event-request.model.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | export type RemoteVideoEventType = 'views' | 'likes' | 'dislikes' | ||
2 | |||
3 | export interface RemoteVideoEventData { | ||
4 | remoteId: string | ||
5 | eventType: RemoteVideoEventType | ||
6 | count: number | ||
7 | } | ||
8 | |||
9 | export interface RemoteVideoEventRequest { | ||
10 | data: RemoteVideoEventData | ||
11 | } | ||
diff --git a/shared/models/pods/remote-video/remote-video-remove-request.model.ts b/shared/models/pods/remote-video/remote-video-remove-request.model.ts new file mode 100644 index 000000000..95ee38661 --- /dev/null +++ b/shared/models/pods/remote-video/remote-video-remove-request.model.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { RemoteVideoRequest } from './remote-video-request.model' | ||
2 | |||
3 | export interface RemoteVideoRemoveData { | ||
4 | remoteId: string | ||
5 | } | ||
6 | |||
7 | export interface RemoteVideoRemoveRequest extends RemoteVideoRequest { | ||
8 | type: 'remove' | ||
9 | data: RemoteVideoRemoveData | ||
10 | } | ||
diff --git a/shared/models/pods/remote-video/remote-video-report-abuse-request.model.ts b/shared/models/pods/remote-video/remote-video-report-abuse-request.model.ts new file mode 100644 index 000000000..9059c92e0 --- /dev/null +++ b/shared/models/pods/remote-video/remote-video-report-abuse-request.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | import { RemoteVideoRequest } from './remote-video-request.model' | ||
2 | |||
3 | export interface RemoteVideoReportAbuseData { | ||
4 | videoRemoteId: string | ||
5 | reporterUsername: string | ||
6 | reportReason: string | ||
7 | } | ||
8 | |||
9 | export interface RemoteVideoReportAbuseRequest extends RemoteVideoRequest { | ||
10 | type: 'report-abuse' | ||
11 | data: RemoteVideoReportAbuseData | ||
12 | } | ||
diff --git a/shared/models/pods/remote-video/remote-video-request.model.ts b/shared/models/pods/remote-video/remote-video-request.model.ts new file mode 100644 index 000000000..e5052a23d --- /dev/null +++ b/shared/models/pods/remote-video/remote-video-request.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface RemoteVideoRequest { | ||
2 | type: 'add' | 'update' | 'remove' | 'report-abuse' | ||
3 | data: any | ||
4 | } | ||
diff --git a/shared/models/pods/remote-video/remote-video-update-request.model.ts b/shared/models/pods/remote-video/remote-video-update-request.model.ts new file mode 100644 index 000000000..67ddbc1e4 --- /dev/null +++ b/shared/models/pods/remote-video/remote-video-update-request.model.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | export interface RemoteVideoUpdateData { | ||
2 | remoteId: string | ||
3 | tags: string[] | ||
4 | name: string | ||
5 | extname: string | ||
6 | infoHash: string | ||
7 | category: number | ||
8 | licence: number | ||
9 | language: number | ||
10 | nsfw: boolean | ||
11 | description: string | ||
12 | duration: number | ||
13 | createdAt: Date | ||
14 | updatedAt: Date | ||
15 | views: number | ||
16 | likes: number | ||
17 | dislikes: number | ||
18 | } | ||
19 | |||
20 | export interface RemoteVideoUpdateRequest { | ||
21 | type: 'update' | ||
22 | data: RemoteVideoUpdateData | ||
23 | } | ||
diff --git a/shared/models/user-video-rate.model.ts b/shared/models/user-video-rate.model.ts deleted file mode 100644 index b770f4073..000000000 --- a/shared/models/user-video-rate.model.ts +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | export type VideoRateType = 'like' | 'dislike' | ||
2 | export type UserVideoRateType = 'like' | 'dislike' | 'none' | ||
3 | |||
4 | export interface UserVideoRate { | ||
5 | videoId: string | ||
6 | rating: UserVideoRateType | ||
7 | } | ||
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts new file mode 100644 index 000000000..414aaab08 --- /dev/null +++ b/shared/models/users/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './user.model' | ||
2 | export * from './user-create.model' | ||
3 | export * from './user-update.model' | ||
4 | export * from './user-role.type' | ||
diff --git a/shared/models/users/user-create.model.ts b/shared/models/users/user-create.model.ts new file mode 100644 index 000000000..2cddcdcb0 --- /dev/null +++ b/shared/models/users/user-create.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface UserCreate { | ||
2 | username: string | ||
3 | password: string | ||
4 | email: string | ||
5 | } | ||
diff --git a/shared/models/users/user-role.type.ts b/shared/models/users/user-role.type.ts new file mode 100644 index 000000000..b38c4c8c3 --- /dev/null +++ b/shared/models/users/user-role.type.ts | |||
@@ -0,0 +1 @@ | |||
export type UserRole = 'admin' | 'user' | |||
diff --git a/shared/models/users/user-update.model.ts b/shared/models/users/user-update.model.ts new file mode 100644 index 000000000..8b9abfb15 --- /dev/null +++ b/shared/models/users/user-update.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface UserUpdate { | ||
2 | displayNSFW?: boolean | ||
3 | password?: string | ||
4 | } | ||
diff --git a/shared/models/user.model.ts b/shared/models/users/user.model.ts index 92dc73ec2..5c48a17b2 100644 --- a/shared/models/user.model.ts +++ b/shared/models/users/user.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | export type UserRole = 'admin' | 'user' | 1 | import { UserRole } from './user-role.type' |
2 | 2 | ||
3 | export interface User { | 3 | export interface User { |
4 | id: number | 4 | id: number |
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts new file mode 100644 index 000000000..64d1676c5 --- /dev/null +++ b/shared/models/videos/index.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export * from './user-video-rate-update.model' | ||
2 | export * from './user-video-rate.model' | ||
3 | export * from './user-video-rate.type' | ||
4 | export * from './video-abuse-create.model' | ||
5 | export * from './video-abuse.model' | ||
6 | export * from './video-blacklist.model' | ||
7 | export * from './video-create.model' | ||
8 | export * from './video-rate.type' | ||
9 | export * from './video-update.model' | ||
10 | export * from './video.model' | ||
diff --git a/shared/models/videos/user-video-rate-update.model.ts b/shared/models/videos/user-video-rate-update.model.ts new file mode 100644 index 000000000..85e89271a --- /dev/null +++ b/shared/models/videos/user-video-rate-update.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { UserVideoRateType } from './user-video-rate.type' | ||
2 | |||
3 | export interface UserVideoRateUpdate { | ||
4 | rating: UserVideoRateType | ||
5 | } | ||
diff --git a/shared/models/videos/user-video-rate.model.ts b/shared/models/videos/user-video-rate.model.ts new file mode 100644 index 000000000..4b9c574d8 --- /dev/null +++ b/shared/models/videos/user-video-rate.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | import { UserVideoRateType } from './user-video-rate.type' | ||
2 | |||
3 | export interface UserVideoRate { | ||
4 | videoId: string | ||
5 | rating: UserVideoRateType | ||
6 | } | ||
diff --git a/shared/models/videos/user-video-rate.type.ts b/shared/models/videos/user-video-rate.type.ts new file mode 100644 index 000000000..a4d9c7e39 --- /dev/null +++ b/shared/models/videos/user-video-rate.type.ts | |||
@@ -0,0 +1 @@ | |||
export type UserVideoRateType = 'like' | 'dislike' | 'none' | |||
diff --git a/shared/models/videos/video-abuse-create.model.ts b/shared/models/videos/video-abuse-create.model.ts new file mode 100644 index 000000000..db6458275 --- /dev/null +++ b/shared/models/videos/video-abuse-create.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface VideoAbuseCreate { | ||
2 | reason: string | ||
3 | } | ||
diff --git a/shared/models/video-abuse.model.ts b/shared/models/videos/video-abuse.model.ts index 72e32cbc7..72e32cbc7 100644 --- a/shared/models/video-abuse.model.ts +++ b/shared/models/videos/video-abuse.model.ts | |||
diff --git a/shared/models/video-blacklist.model.ts b/shared/models/videos/video-blacklist.model.ts index f894bb065..f894bb065 100644 --- a/shared/models/video-blacklist.model.ts +++ b/shared/models/videos/video-blacklist.model.ts | |||
diff --git a/shared/models/videos/video-create.model.ts b/shared/models/videos/video-create.model.ts new file mode 100644 index 000000000..5c0b498ce --- /dev/null +++ b/shared/models/videos/video-create.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export interface VideoCreate { | ||
2 | category: number | ||
3 | licence: number | ||
4 | language: number | ||
5 | description: string | ||
6 | nsfw: boolean | ||
7 | name: string | ||
8 | tags: string[] | ||
9 | } | ||
diff --git a/shared/models/videos/video-rate.type.ts b/shared/models/videos/video-rate.type.ts new file mode 100644 index 000000000..d48774a4b --- /dev/null +++ b/shared/models/videos/video-rate.type.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRateType = 'like' | 'dislike' | |||
diff --git a/shared/models/videos/video-update.model.ts b/shared/models/videos/video-update.model.ts new file mode 100644 index 000000000..29a82621b --- /dev/null +++ b/shared/models/videos/video-update.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | export interface VideoUpdate { | ||
2 | name?: string | ||
3 | category?: number | ||
4 | licence?: number | ||
5 | language?: number | ||
6 | description?: string | ||
7 | tags?: string[] | ||
8 | nsfw?: boolean | ||
9 | } | ||
diff --git a/shared/models/video.model.ts b/shared/models/videos/video.model.ts index 2e35f005c..2e35f005c 100644 --- a/shared/models/video.model.ts +++ b/shared/models/videos/video.model.ts | |||