diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 10:36:18 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 10:36:18 +0200 |
commit | ee9e7b61f59a427208386738057c8eff48fba599 (patch) | |
tree | 9097de886128e15f21f0b5920a2076d16a087467 /server/models | |
parent | 70c065d64c330196d371941d9294a55da6e3aa37 (diff) | |
download | PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.tar.gz PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.tar.zst PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.zip |
Create types for model enums
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/job/job-interface.ts | 6 | ||||
-rw-r--r-- | server/models/job/job.ts | 3 | ||||
-rw-r--r-- | server/models/request/request-interface.ts | 3 | ||||
-rw-r--r-- | server/models/request/request-video-event-interface.ts | 6 | ||||
-rw-r--r-- | server/models/request/request-video-qadu-interface.ts | 4 | ||||
-rw-r--r-- | server/models/user/user-interface.ts | 4 | ||||
-rw-r--r-- | server/models/user/user-video-rate-interface.ts | 6 | ||||
-rw-r--r-- | server/models/user/user-video-rate.ts | 2 |
8 files changed, 22 insertions, 12 deletions
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { JobState } from '../../../shared/models/job.model' | ||
4 | |||
3 | export namespace JobMethods { | 5 | export 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 | ||
8 | export interface JobClass { | 10 | export interface JobClass { |
@@ -10,7 +12,7 @@ export interface JobClass { | |||
10 | } | 12 | } |
11 | 13 | ||
12 | export interface JobAttributes { | 14 | export 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' |
14 | import { JobState } from '../../../shared/models/job.model' | ||
14 | 15 | ||
15 | let Job: Sequelize.Model<JobInstance, JobAttributes> | 16 | let Job: Sequelize.Model<JobInstance, JobAttributes> |
16 | let listWithLimit: JobMethods.ListWithLimit | 17 | let listWithLimit: JobMethods.ListWithLimit |
@@ -48,7 +49,7 @@ export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes: Se | |||
48 | 49 | ||
49 | // --------------------------------------------------------------------------- | 50 | // --------------------------------------------------------------------------- |
50 | 51 | ||
51 | listWithLimit = function (limit: number, state: string, callback: JobMethods.ListWithLimitCallback) { | 52 | listWithLimit = 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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { PodInstance, PodAttributes } from '../pod' | 3 | import { PodInstance, PodAttributes } from '../pod' |
4 | import { RequestEndpoint } from '../../../shared/models/request-scheduler.model' | ||
4 | 5 | ||
5 | export type RequestsGrouped = { | 6 | export type RequestsGrouped = { |
6 | [ podId: number ]: { | 7 | [ podId: number ]: { |
@@ -32,7 +33,7 @@ export interface RequestClass { | |||
32 | 33 | ||
33 | export interface RequestAttributes { | 34 | export interface RequestAttributes { |
34 | request: object | 35 | request: object |
35 | endpoint: string | 36 | endpoint: RequestEndpoint |
36 | } | 37 | } |
37 | 38 | ||
38 | export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> { | 39 | export 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' | |||
3 | import { VideoInstance } from '../video' | 3 | import { VideoInstance } from '../video' |
4 | import { PodInstance } from '../pod' | 4 | import { PodInstance } from '../pod' |
5 | 5 | ||
6 | import { RequestVideoEventType } from '../../../shared/models/request-scheduler.model' | ||
7 | |||
6 | export type RequestsVideoEventGrouped = { | 8 | export 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 | ||
37 | export interface RequestVideoEventAttributes { | 39 | export 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' | |||
3 | import { VideoInstance } from '../video' | 3 | import { VideoInstance } from '../video' |
4 | import { PodInstance } from '../pod' | 4 | import { PodInstance } from '../pod' |
5 | 5 | ||
6 | import { RequestVideoQaduType } from '../../../shared/models/request-scheduler.model' | ||
7 | |||
6 | export type RequestsVideoQaduGrouped = { | 8 | export 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 | ||
35 | export interface RequestVideoQaduAttributes { | 37 | export interface RequestVideoQaduAttributes { |
36 | type: string | 38 | type: RequestVideoQaduType |
37 | } | 39 | } |
38 | 40 | ||
39 | export interface RequestVideoQaduInstance extends RequestVideoQaduClass, RequestVideoQaduAttributes, Sequelize.Instance<RequestVideoQaduAttributes> { | 41 | export 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' | |||
2 | import * as Bluebird from 'bluebird' | 2 | import * 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 |
5 | import { User as FormatedUser } from '../../../shared/models/user.model' | 5 | import { UserRole, User as FormatedUser } from '../../../shared/models/user.model' |
6 | 6 | ||
7 | export namespace UserMethods { | 7 | export 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 | ||
57 | export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> { | 57 | export 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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { VideoRateType } from '../../../shared/models/user-video-rate.model' | ||
4 | |||
3 | export namespace UserVideoRateMethods { | 5 | export 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 | ||
8 | export interface UserVideoRateClass { | 10 | export interface UserVideoRateClass { |
@@ -10,7 +12,7 @@ export interface UserVideoRateClass { | |||
10 | } | 12 | } |
11 | 13 | ||
12 | export interface UserVideoRateAttributes { | 14 | export interface UserVideoRateAttributes { |
13 | type: string | 15 | type: VideoRateType |
14 | } | 16 | } |
15 | 17 | ||
16 | export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> { | 18 | export 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 | ||
70 | load = function (userId: number, videoId: number, transaction: Sequelize.Transaction, callback: UserVideoRateMethods.LoadCallback) { | 70 | load = 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, |