aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 10:36:18 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 10:36:18 +0200
commitee9e7b61f59a427208386738057c8eff48fba599 (patch)
tree9097de886128e15f21f0b5920a2076d16a087467
parent70c065d64c330196d371941d9294a55da6e3aa37 (diff)
downloadPeerTube-ee9e7b61f59a427208386738057c8eff48fba599.tar.gz
PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.tar.zst
PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.zip
Create types for model enums
-rw-r--r--server/controllers/api/requests.ts3
-rw-r--r--server/helpers/custom-validators/users.ts4
-rw-r--r--server/helpers/custom-validators/videos.ts3
-rw-r--r--server/initializers/constants.ts21
-rw-r--r--server/lib/friends.ts16
-rw-r--r--server/lib/request/request-scheduler.ts3
-rw-r--r--server/lib/request/request-video-event-scheduler.ts3
-rw-r--r--server/lib/request/request-video-qadu-scheduler.ts3
-rw-r--r--server/models/job/job-interface.ts6
-rw-r--r--server/models/job/job.ts3
-rw-r--r--server/models/request/request-interface.ts3
-rw-r--r--server/models/request/request-video-event-interface.ts6
-rw-r--r--server/models/request/request-video-qadu-interface.ts4
-rw-r--r--server/models/user/user-interface.ts4
-rw-r--r--server/models/user/user-video-rate-interface.ts6
-rw-r--r--server/models/user/user-video-rate.ts2
-rw-r--r--shared/models/index.ts3
-rw-r--r--shared/models/job.model.ts1
-rw-r--r--shared/models/request-scheduler.model.ts19
-rw-r--r--shared/models/user-video-rate.model.ts1
-rw-r--r--shared/models/user.model.ts4
21 files changed, 89 insertions, 29 deletions
diff --git a/server/controllers/api/requests.ts b/server/controllers/api/requests.ts
index d3f0d958c..5718b59b7 100644
--- a/server/controllers/api/requests.ts
+++ b/server/controllers/api/requests.ts
@@ -8,6 +8,7 @@ import {
8 getRequestVideoEventScheduler 8 getRequestVideoEventScheduler
9} from '../../lib' 9} from '../../lib'
10import { authenticate, ensureIsAdmin } from '../../middlewares' 10import { authenticate, ensureIsAdmin } from '../../middlewares'
11import { RequestSchedulerAttributes } from '../../../shared'
11 12
12const requestsRouter = express.Router() 13const requestsRouter = express.Router()
13 14
@@ -44,7 +45,7 @@ function buildRequestSchedulerFunction (requestScheduler: AbstractRequestSchedul
44 requestScheduler.remainingRequestsCount(function (err, count) { 45 requestScheduler.remainingRequestsCount(function (err, count) {
45 if (err) return callback(err) 46 if (err) return callback(err)
46 47
47 const result = { 48 const result: RequestSchedulerAttributes = {
48 totalRequests: count, 49 totalRequests: count,
49 requestsLimitPods: requestScheduler.limitPods, 50 requestsLimitPods: requestScheduler.limitPods,
50 requestsLimitPerPod: requestScheduler.limitPerPod, 51 requestsLimitPerPod: requestScheduler.limitPerPod,
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index 7792ffd74..750563ada 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -3,6 +3,8 @@ import * as validator from 'validator'
3 3
4import { exists } from './misc' 4import { exists } from './misc'
5import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' 5import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers'
6import { UserRole } from '../../../shared'
7
6const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS 8const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
7 9
8function isUserPasswordValid (value: string) { 10function isUserPasswordValid (value: string) {
@@ -10,7 +12,7 @@ function isUserPasswordValid (value: string) {
10} 12}
11 13
12function isUserRoleValid (value: string) { 14function isUserRoleValid (value: string) {
13 return values(USER_ROLES).indexOf(value) !== -1 15 return values(USER_ROLES).indexOf(value as UserRole) !== -1
14} 16}
15 17
16function isUserUsernameValid (value: string) { 18function isUserUsernameValid (value: string) {
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 8904975c0..72d226e81 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -11,6 +11,7 @@ import {
11} from '../../initializers' 11} from '../../initializers'
12import { isUserUsernameValid } from './users' 12import { isUserUsernameValid } from './users'
13import { isArray, exists } from './misc' 13import { isArray, exists } from './misc'
14import { VideoRateType } from '../../../shared'
14 15
15const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 16const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
16const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 17const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
@@ -105,7 +106,7 @@ function isVideoEventCountValid (value: string) {
105} 106}
106 107
107function isVideoRatingTypeValid (value: string) { 108function isVideoRatingTypeValid (value: string) {
108 return values(VIDEO_RATE_TYPES).indexOf(value) !== -1 109 return values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1
109} 110}
110 111
111function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) { 112function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) {
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index b476ef928..bf99f4df6 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -4,6 +4,15 @@ import { join } from 'path'
4// Do not use barrels, remain constants as independent as possible 4// Do not use barrels, remain constants as independent as possible
5import { root, isTestInstance } from '../helpers/core-utils' 5import { root, isTestInstance } from '../helpers/core-utils'
6 6
7import {
8 UserRole,
9 VideoRateType,
10 RequestEndpoint,
11 RequestVideoEventType,
12 RequestVideoQaduType,
13 JobState
14} from '../../shared/models'
15
7// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
8 17
9const LAST_MIGRATION_VERSION = 50 18const LAST_MIGRATION_VERSION = 50
@@ -105,7 +114,7 @@ const CONSTRAINTS_FIELDS = {
105 } 114 }
106} 115}
107 116
108const VIDEO_RATE_TYPES = { 117const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = {
109 LIKE: 'like', 118 LIKE: 'like',
110 DISLIKE: 'dislike' 119 DISLIKE: 'dislike'
111} 120}
@@ -198,7 +207,7 @@ const REQUESTS_VIDEO_EVENT_LIMIT_PER_POD = 50
198// Number of requests to retry for replay requests module 207// Number of requests to retry for replay requests module
199const RETRY_REQUESTS = 5 208const RETRY_REQUESTS = 5
200 209
201const REQUEST_ENDPOINTS = { 210const REQUEST_ENDPOINTS: { [ id: string ]: RequestEndpoint } = {
202 VIDEOS: 'videos' 211 VIDEOS: 'videos'
203} 212}
204 213
@@ -213,13 +222,13 @@ REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
213const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu' 222const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu'
214const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events' 223const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events'
215 224
216const REQUEST_VIDEO_QADU_TYPES = { 225const REQUEST_VIDEO_QADU_TYPES: { [ id: string ]: RequestVideoQaduType } = {
217 LIKES: 'likes', 226 LIKES: 'likes',
218 DISLIKES: 'dislikes', 227 DISLIKES: 'dislikes',
219 VIEWS: 'views' 228 VIEWS: 'views'
220} 229}
221 230
222const REQUEST_VIDEO_EVENT_TYPES = { 231const REQUEST_VIDEO_EVENT_TYPES: { [ id: string ]: RequestVideoEventType } = {
223 LIKES: 'likes', 232 LIKES: 'likes',
224 DISLIKES: 'dislikes', 233 DISLIKES: 'dislikes',
225 VIEWS: 'views' 234 VIEWS: 'views'
@@ -230,7 +239,7 @@ const REMOTE_SCHEME = {
230 WS: 'wss' 239 WS: 'wss'
231} 240}
232 241
233const JOB_STATES = { 242const JOB_STATES: { [ id: string ]: JobState } = {
234 PENDING: 'pending', 243 PENDING: 'pending',
235 PROCESSING: 'processing', 244 PROCESSING: 'processing',
236 ERROR: 'error', 245 ERROR: 'error',
@@ -271,7 +280,7 @@ const PREVIEWS_SIZE = '640x480'
271 280
272// --------------------------------------------------------------------------- 281// ---------------------------------------------------------------------------
273 282
274const USER_ROLES = { 283const USER_ROLES: { [ id: string ]: UserRole } = {
275 ADMIN: 'admin', 284 ADMIN: 'admin',
276 USER: 'user' 285 USER: 'user'
277} 286}
diff --git a/server/lib/friends.ts b/server/lib/friends.ts
index e097f9254..d07433a5d 100644
--- a/server/lib/friends.ts
+++ b/server/lib/friends.ts
@@ -28,10 +28,18 @@ import {
28 RequestVideoEventScheduler, 28 RequestVideoEventScheduler,
29 RequestVideoEventSchedulerOptions 29 RequestVideoEventSchedulerOptions
30} from './request' 30} from './request'
31import { PodInstance, VideoInstance } from '../models' 31import {
32 PodInstance,
33 VideoInstance
34} from '../models'
35import {
36 RequestEndpoint,
37 RequestVideoEventType,
38 RequestVideoQaduType
39} from '../../shared'
32 40
33type QaduParam = { videoId: string, type: string } 41type QaduParam = { videoId: string, type: RequestVideoQaduType }
34type EventParam = { videoId: string, type: string } 42type EventParam = { videoId: string, type: RequestVideoEventType }
35 43
36const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] 44const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS]
37 45
@@ -391,7 +399,7 @@ function makeRequestsToWinningPods (cert: string, podsList: PodInstance[], callb
391// Wrapper that populate "toIds" argument with all our friends if it is not specified 399// Wrapper that populate "toIds" argument with all our friends if it is not specified
392type CreateRequestOptions = { 400type CreateRequestOptions = {
393 type: string 401 type: string
394 endpoint: string 402 endpoint: RequestEndpoint
395 data: Object 403 data: Object
396 toIds?: number[] 404 toIds?: number[]
397 transaction: Sequelize.Transaction 405 transaction: Sequelize.Transaction
diff --git a/server/lib/request/request-scheduler.ts b/server/lib/request/request-scheduler.ts
index 38c0cca3d..575e0227c 100644
--- a/server/lib/request/request-scheduler.ts
+++ b/server/lib/request/request-scheduler.ts
@@ -7,10 +7,11 @@ import {
7 REQUESTS_LIMIT_PODS, 7 REQUESTS_LIMIT_PODS,
8 REQUESTS_LIMIT_PER_POD 8 REQUESTS_LIMIT_PER_POD
9} from '../../initializers' 9} from '../../initializers'
10import { RequestEndpoint } from '../../../shared'
10 11
11export type RequestSchedulerOptions = { 12export type RequestSchedulerOptions = {
12 type: string 13 type: string
13 endpoint: string 14 endpoint: RequestEndpoint
14 data: Object 15 data: Object
15 toIds: number[] 16 toIds: number[]
16 transaction: Sequelize.Transaction 17 transaction: Sequelize.Transaction
diff --git a/server/lib/request/request-video-event-scheduler.ts b/server/lib/request/request-video-event-scheduler.ts
index c9d165117..4bb76f4c9 100644
--- a/server/lib/request/request-video-event-scheduler.ts
+++ b/server/lib/request/request-video-event-scheduler.ts
@@ -7,9 +7,10 @@ import {
7 REQUESTS_VIDEO_EVENT_LIMIT_PER_POD, 7 REQUESTS_VIDEO_EVENT_LIMIT_PER_POD,
8 REQUEST_VIDEO_EVENT_ENDPOINT 8 REQUEST_VIDEO_EVENT_ENDPOINT
9} from '../../initializers' 9} from '../../initializers'
10import { RequestVideoEventType } from '../../../shared'
10 11
11export type RequestVideoEventSchedulerOptions = { 12export type RequestVideoEventSchedulerOptions = {
12 type: string 13 type: RequestVideoEventType
13 videoId: string 14 videoId: string
14 count?: number 15 count?: number
15 transaction?: Sequelize.Transaction 16 transaction?: Sequelize.Transaction
diff --git a/server/lib/request/request-video-qadu-scheduler.ts b/server/lib/request/request-video-qadu-scheduler.ts
index 49970a2e6..d7169cc81 100644
--- a/server/lib/request/request-video-qadu-scheduler.ts
+++ b/server/lib/request/request-video-qadu-scheduler.ts
@@ -9,9 +9,10 @@ import {
9 REQUEST_VIDEO_QADU_ENDPOINT, 9 REQUEST_VIDEO_QADU_ENDPOINT,
10 REQUEST_VIDEO_QADU_TYPES 10 REQUEST_VIDEO_QADU_TYPES
11} from '../../initializers' 11} from '../../initializers'
12import { RequestVideoQaduType } from '../../../shared'
12 13
13export type RequestVideoQaduSchedulerOptions = { 14export type RequestVideoQaduSchedulerOptions = {
14 type: string 15 type: RequestVideoQaduType
15 videoId: string 16 videoId: string
16 transaction?: Sequelize.Transaction 17 transaction?: Sequelize.Transaction
17} 18}
diff --git a/server/models/job/job-interface.ts b/server/models/job/job-interface.ts
index ab6678257..31b377367 100644
--- a/server/models/job/job-interface.ts
+++ b/server/models/job/job-interface.ts
@@ -1,8 +1,10 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { JobState } from '../../../shared/models/job.model'
4
3export namespace JobMethods { 5export namespace JobMethods {
4 export type ListWithLimitCallback = (err: Error, jobInstances: JobInstance[]) => void 6 export type ListWithLimitCallback = (err: Error, jobInstances: JobInstance[]) => void
5 export type ListWithLimit = (limit: number, state: string, callback: ListWithLimitCallback) => void 7 export type ListWithLimit = (limit: number, state: JobState, callback: ListWithLimitCallback) => void
6} 8}
7 9
8export interface JobClass { 10export interface JobClass {
@@ -10,7 +12,7 @@ export interface JobClass {
10} 12}
11 13
12export interface JobAttributes { 14export interface JobAttributes {
13 state: string 15 state: JobState
14 handlerName: string 16 handlerName: string
15 handlerInputData: object 17 handlerInputData: object
16} 18}
diff --git a/server/models/job/job.ts b/server/models/job/job.ts
index 60a6c551b..38e4e8f30 100644
--- a/server/models/job/job.ts
+++ b/server/models/job/job.ts
@@ -11,6 +11,7 @@ import {
11 11
12 JobMethods 12 JobMethods
13} from './job-interface' 13} from './job-interface'
14import { JobState } from '../../../shared/models/job.model'
14 15
15let Job: Sequelize.Model<JobInstance, JobAttributes> 16let Job: Sequelize.Model<JobInstance, JobAttributes>
16let listWithLimit: JobMethods.ListWithLimit 17let listWithLimit: JobMethods.ListWithLimit
@@ -48,7 +49,7 @@ export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes: Se
48 49
49// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
50 51
51listWithLimit = function (limit: number, state: string, callback: JobMethods.ListWithLimitCallback) { 52listWithLimit = function (limit: number, state: JobState, callback: JobMethods.ListWithLimitCallback) {
52 const query = { 53 const query = {
53 order: [ 54 order: [
54 [ 'id', 'ASC' ] 55 [ 'id', 'ASC' ]
diff --git a/server/models/request/request-interface.ts b/server/models/request/request-interface.ts
index 70fd734e1..483850633 100644
--- a/server/models/request/request-interface.ts
+++ b/server/models/request/request-interface.ts
@@ -1,6 +1,7 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { PodInstance, PodAttributes } from '../pod' 3import { PodInstance, PodAttributes } from '../pod'
4import { RequestEndpoint } from '../../../shared/models/request-scheduler.model'
4 5
5export type RequestsGrouped = { 6export type RequestsGrouped = {
6 [ podId: number ]: { 7 [ podId: number ]: {
@@ -32,7 +33,7 @@ export interface RequestClass {
32 33
33export interface RequestAttributes { 34export interface RequestAttributes {
34 request: object 35 request: object
35 endpoint: string 36 endpoint: RequestEndpoint
36} 37}
37 38
38export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> { 39export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> {
diff --git a/server/models/request/request-video-event-interface.ts b/server/models/request/request-video-event-interface.ts
index 219d8edc0..3ed03339a 100644
--- a/server/models/request/request-video-event-interface.ts
+++ b/server/models/request/request-video-event-interface.ts
@@ -3,10 +3,12 @@ import * as Sequelize from 'sequelize'
3import { VideoInstance } from '../video' 3import { VideoInstance } from '../video'
4import { PodInstance } from '../pod' 4import { PodInstance } from '../pod'
5 5
6import { RequestVideoEventType } from '../../../shared/models/request-scheduler.model'
7
6export type RequestsVideoEventGrouped = { 8export type RequestsVideoEventGrouped = {
7 [ podId: number ]: { 9 [ podId: number ]: {
8 id: number 10 id: number
9 type: string 11 type: RequestVideoEventType
10 count: number 12 count: number
11 video: VideoInstance 13 video: VideoInstance
12 pod: PodInstance 14 pod: PodInstance
@@ -35,7 +37,7 @@ export interface RequestVideoEventClass {
35} 37}
36 38
37export interface RequestVideoEventAttributes { 39export interface RequestVideoEventAttributes {
38 type: string 40 type: RequestVideoEventType
39 count: number 41 count: number
40} 42}
41 43
diff --git a/server/models/request/request-video-qadu-interface.ts b/server/models/request/request-video-qadu-interface.ts
index 625b063dc..805771cda 100644
--- a/server/models/request/request-video-qadu-interface.ts
+++ b/server/models/request/request-video-qadu-interface.ts
@@ -3,6 +3,8 @@ import * as Sequelize from 'sequelize'
3import { VideoInstance } from '../video' 3import { VideoInstance } from '../video'
4import { PodInstance } from '../pod' 4import { PodInstance } from '../pod'
5 5
6import { RequestVideoQaduType } from '../../../shared/models/request-scheduler.model'
7
6export type RequestsVideoQaduGrouped = { 8export type RequestsVideoQaduGrouped = {
7 [ podId: number ]: { 9 [ podId: number ]: {
8 request: RequestVideoQaduInstance 10 request: RequestVideoQaduInstance
@@ -33,7 +35,7 @@ export interface RequestVideoQaduClass {
33} 35}
34 36
35export interface RequestVideoQaduAttributes { 37export interface RequestVideoQaduAttributes {
36 type: string 38 type: RequestVideoQaduType
37} 39}
38 40
39export interface RequestVideoQaduInstance extends RequestVideoQaduClass, RequestVideoQaduAttributes, Sequelize.Instance<RequestVideoQaduAttributes> { 41export interface RequestVideoQaduInstance extends RequestVideoQaduClass, RequestVideoQaduAttributes, Sequelize.Instance<RequestVideoQaduAttributes> {
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts
index 6726e8ab5..fd98a042e 100644
--- a/server/models/user/user-interface.ts
+++ b/server/models/user/user-interface.ts
@@ -2,7 +2,7 @@ import * as Sequelize from 'sequelize'
2import * as Bluebird from 'bluebird' 2import * as Bluebird from 'bluebird'
3 3
4// Don't use barrel, import just what we need 4// Don't use barrel, import just what we need
5import { User as FormatedUser } from '../../../shared/models/user.model' 5import { UserRole, User as FormatedUser } from '../../../shared/models/user.model'
6 6
7export namespace UserMethods { 7export namespace UserMethods {
8 export type IsPasswordMatchCallback = (err: Error, same: boolean) => void 8 export type IsPasswordMatchCallback = (err: Error, same: boolean) => void
@@ -51,7 +51,7 @@ export interface UserAttributes {
51 username: string 51 username: string
52 email: string 52 email: string
53 displayNSFW?: boolean 53 displayNSFW?: boolean
54 role: string 54 role: UserRole
55} 55}
56 56
57export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> { 57export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> {
diff --git a/server/models/user/user-video-rate-interface.ts b/server/models/user/user-video-rate-interface.ts
index e48869fd2..a726639b1 100644
--- a/server/models/user/user-video-rate-interface.ts
+++ b/server/models/user/user-video-rate-interface.ts
@@ -1,8 +1,10 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { VideoRateType } from '../../../shared/models/user-video-rate.model'
4
3export namespace UserVideoRateMethods { 5export namespace UserVideoRateMethods {
4 export type LoadCallback = (err: Error, userVideoRateInstance: UserVideoRateInstance) => void 6 export type LoadCallback = (err: Error, userVideoRateInstance: UserVideoRateInstance) => void
5 export type Load = (userId, videoId, transaction, callback) => void 7 export type Load = (userId: number, videoId: string, transaction: Sequelize.Transaction, callback: LoadCallback) => void
6} 8}
7 9
8export interface UserVideoRateClass { 10export interface UserVideoRateClass {
@@ -10,7 +12,7 @@ export interface UserVideoRateClass {
10} 12}
11 13
12export interface UserVideoRateAttributes { 14export interface UserVideoRateAttributes {
13 type: string 15 type: VideoRateType
14} 16}
15 17
16export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> { 18export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> {
diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts
index 68be62fc2..1094eb281 100644
--- a/server/models/user/user-video-rate.ts
+++ b/server/models/user/user-video-rate.ts
@@ -67,7 +67,7 @@ function associate (models) {
67 }) 67 })
68} 68}
69 69
70load = function (userId: number, videoId: number, transaction: Sequelize.Transaction, callback: UserVideoRateMethods.LoadCallback) { 70load = function (userId: number, videoId: string, transaction: Sequelize.Transaction, callback: UserVideoRateMethods.LoadCallback) {
71 const options: Sequelize.FindOptions = { 71 const options: Sequelize.FindOptions = {
72 where: { 72 where: {
73 userId, 73 userId,
diff --git a/shared/models/index.ts b/shared/models/index.ts
index b498d620a..1ddc8545f 100644
--- a/shared/models/index.ts
+++ b/shared/models/index.ts
@@ -1,4 +1,7 @@
1export * from './job.model'
1export * from './pod.model' 2export * from './pod.model'
3export * from './request-scheduler.model'
4export * from './user-video-rate.model'
2export * from './user.model' 5export * from './user.model'
3export * from './video-abuse.model' 6export * from './video-abuse.model'
4export * from './video-blacklist.model' 7export * from './video-blacklist.model'
diff --git a/shared/models/job.model.ts b/shared/models/job.model.ts
new file mode 100644
index 000000000..411c91482
--- /dev/null
+++ b/shared/models/job.model.ts
@@ -0,0 +1 @@
export type JobState = 'pending' | 'processing' | 'error' | 'success'
diff --git a/shared/models/request-scheduler.model.ts b/shared/models/request-scheduler.model.ts
new file mode 100644
index 000000000..f94ccfcab
--- /dev/null
+++ b/shared/models/request-scheduler.model.ts
@@ -0,0 +1,19 @@
1export type RequestEndpoint = 'videos'
2
3export type RequestVideoQaduType = 'likes' | 'dislikes' | 'views'
4
5export type RequestVideoEventType = 'likes' | 'dislikes' | 'views'
6
7export type RequestSchedulerAttributes = {
8 totalRequests: number
9 requestsLimitPods: number
10 requestsLimitPerPod: number
11 remainingMilliSeconds: number
12 milliSecondsInterval: number
13}
14
15export interface RequestScheduler {
16 requestScheduler: RequestSchedulerAttributes
17 requestVideoQaduScheduler: RequestSchedulerAttributes
18 requestVideoEventScheduler: RequestSchedulerAttributes
19}
diff --git a/shared/models/user-video-rate.model.ts b/shared/models/user-video-rate.model.ts
new file mode 100644
index 000000000..d48774a4b
--- /dev/null
+++ b/shared/models/user-video-rate.model.ts
@@ -0,0 +1 @@
export type VideoRateType = 'like' | 'dislike'
diff --git a/shared/models/user.model.ts b/shared/models/user.model.ts
index a6be359d3..92dc73ec2 100644
--- a/shared/models/user.model.ts
+++ b/shared/models/user.model.ts
@@ -1,8 +1,10 @@
1export type UserRole = 'admin' | 'user'
2
1export interface User { 3export interface User {
2 id: number 4 id: number
3 username: string 5 username: string
4 email: string 6 email: string
5 displayNSFW: boolean 7 displayNSFW: boolean
6 role: string 8 role: UserRole
7 createdAt: Date 9 createdAt: Date
8} 10}