Cleanup models
[oweals/peertube.git] / server / models / video / video-channel-interface.ts
1 import * as Promise from 'bluebird'
2 import * as Sequelize from 'sequelize'
3
4 import { ResultList } from '../../../shared'
5 import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object'
6 import { VideoChannel as FormattedVideoChannel } from '../../../shared/models/videos/video-channel.model'
7 import { AccountInstance } from '../account/account-interface'
8 import { VideoInstance } from './video-interface'
9
10 export namespace VideoChannelMethods {
11   export type ToFormattedJSON = (this: VideoChannelInstance) => FormattedVideoChannel
12   export type ToActivityPubObject = (this: VideoChannelInstance) => VideoChannelObject
13   export type IsOwned = (this: VideoChannelInstance) => boolean
14
15   export type CountByAccount = (accountId: number) => Promise<number>
16   export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoChannelInstance> >
17   export type LoadByIdAndAccount = (id: number, accountId: number) => Promise<VideoChannelInstance>
18   export type ListByAccount = (accountId: number) => Promise< ResultList<VideoChannelInstance> >
19   export type LoadAndPopulateAccount = (id: number) => Promise<VideoChannelInstance>
20   export type LoadByUUIDAndPopulateAccount = (uuid: string) => Promise<VideoChannelInstance>
21   export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
22   export type LoadByHostAndUUID = (uuid: string, serverHost: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
23   export type LoadAndPopulateAccountAndVideos = (id: number) => Promise<VideoChannelInstance>
24   export type LoadByUrl = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
25   export type LoadByUUIDOrUrl = (uuid: string, url: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
26 }
27
28 export interface VideoChannelClass {
29   countByAccount: VideoChannelMethods.CountByAccount
30   listForApi: VideoChannelMethods.ListForApi
31   listByAccount: VideoChannelMethods.ListByAccount
32   loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount
33   loadAndPopulateAccount: VideoChannelMethods.LoadAndPopulateAccount
34   loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount
35   loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos
36   loadByUrl: VideoChannelMethods.LoadByUrl
37   loadByUUIDOrUrl: VideoChannelMethods.LoadByUUIDOrUrl
38 }
39
40 export interface VideoChannelAttributes {
41   id?: number
42   uuid?: string
43   name: string
44   description: string
45   remote: boolean
46   url?: string
47
48   Account?: AccountInstance
49   Videos?: VideoInstance[]
50 }
51
52 export interface VideoChannelInstance extends VideoChannelClass, VideoChannelAttributes, Sequelize.Instance<VideoChannelAttributes> {
53   id: number
54   createdAt: Date
55   updatedAt: Date
56
57   isOwned: VideoChannelMethods.IsOwned
58   toFormattedJSON: VideoChannelMethods.ToFormattedJSON
59   toActivityPubObject: VideoChannelMethods.ToActivityPubObject
60 }
61
62 export interface VideoChannelModel extends VideoChannelClass, Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> {}