]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/video-interface.ts
Add activitypub migration script
[github/Chocobozzz/PeerTube.git] / server / models / video / video-interface.ts
CommitLineData
e4f97bab 1import * as Bluebird from 'bluebird'
7a7724e6
C
2import * as Sequelize from 'sequelize'
3import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
4import { ResultList } from '../../../shared/models/result-list.model'
5import { Video as FormattedVideo, VideoDetails as FormattedDetailsVideo } from '../../../shared/models/videos/video.model'
39445ead 6import { AccountVideoRateInstance } from '../account/account-video-rate-interface'
e02643f3 7
6fcd19ba 8import { TagAttributes, TagInstance } from './tag-interface'
72c7248b 9import { VideoChannelInstance } from './video-channel-interface'
7a7724e6 10import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
e71bcc0f 11import { VideoShareInstance } from './video-share-interface'
69818c93 12
e02643f3 13export namespace VideoMethods {
70c065d6
C
14 export type GetThumbnailName = (this: VideoInstance) => string
15 export type GetPreviewName = (this: VideoInstance) => string
70c065d6 16 export type IsOwned = (this: VideoInstance) => boolean
0aef76c4 17 export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo
72c7248b 18 export type ToFormattedDetailsJSON = (this: VideoInstance) => FormattedDetailsVideo
69818c93 19
40298b02 20 export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance
93e1258c
C
21 export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
22 export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string
23 export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
24 export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
25 export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
26 export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
27
e4f97bab 28 export type ToActivityPubObject = (this: VideoInstance) => VideoTorrentObject
69818c93 29
40298b02
C
30 export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void>
31 export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void>
32 export type GetOriginalFileHeight = (this: VideoInstance) => Promise<number>
d8755eed
C
33 export type GetEmbedPath = (this: VideoInstance) => string
34 export type GetThumbnailPath = (this: VideoInstance) => string
35 export type GetPreviewPath = (this: VideoInstance) => string
9567011b
C
36 export type GetDescriptionPath = (this: VideoInstance) => string
37 export type GetTruncatedDescription = (this: VideoInstance) => string
e4f97bab
C
38 export type GetCategoryLabel = (this: VideoInstance) => string
39 export type GetLicenceLabel = (this: VideoInstance) => string
40 export type GetLanguageLabel = (this: VideoInstance) => string
6fcd19ba 41
e4f97bab 42 export type List = () => Bluebird<VideoInstance[]>
6fcd19ba 43
e71bcc0f
C
44 export type ListAllAndSharedByAccountForOutbox = (
45 accountId: number,
46 start: number,
47 count: number
48 ) => Bluebird< ResultList<VideoInstance> >
e4f97bab
C
49 export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
50 export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
60862425 51 export type SearchAndPopulateAccountAndServerAndTags = (
6fcd19ba
C
52 value: string,
53 field: string,
54 start: number,
55 count: number,
56 sort: string
e4f97bab 57 ) => Bluebird< ResultList<VideoInstance> >
6fcd19ba 58
e4f97bab
C
59 export type Load = (id: number) => Bluebird<VideoInstance>
60 export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
d7d5611c 61 export type LoadByUrlAndPopulateAccount = (url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
60862425
C
62 export type LoadAndPopulateAccountAndServerAndTags = (id: number) => Bluebird<VideoInstance>
63 export type LoadByUUIDAndPopulateAccountAndServerAndTags = (uuid: string) => Bluebird<VideoInstance>
0d0e8dd0 64 export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
93e1258c
C
65
66 export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
67 export type RemovePreview = (this: VideoInstance) => Promise<void>
68 export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
69 export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
e02643f3
C
70}
71
72export interface VideoClass {
e02643f3 73 list: VideoMethods.List
e71bcc0f 74 listAllAndSharedByAccountForOutbox: VideoMethods.ListAllAndSharedByAccountForOutbox
e02643f3 75 listForApi: VideoMethods.ListForApi
fd45e8f4 76 listUserVideosForApi: VideoMethods.ListUserVideosForApi
e02643f3 77 load: VideoMethods.Load
60862425 78 loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags
93e1258c 79 loadByUUID: VideoMethods.LoadByUUID
d7d5611c 80 loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount
0d0e8dd0 81 loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL
60862425
C
82 loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags
83 searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags
e02643f3
C
84}
85
86export interface VideoAttributes {
556ddc31 87 id?: number
0a6658fd 88 uuid?: string
e02643f3 89 name: string
e02643f3
C
90 category: number
91 licence: number
92 language: number
93 nsfw: boolean
94 description: string
e02643f3 95 duration: number
fd45e8f4 96 privacy: number
e02643f3
C
97 views?: number
98 likes?: number
99 dislikes?: number
0a6658fd 100 remote: boolean
0d0e8dd0
C
101 url?: string
102
103 createdAt?: Date
104 updatedAt?: Date
69818c93 105
e4f97bab 106 parentId?: number
72c7248b
C
107 channelId?: number
108
109 VideoChannel?: VideoChannelInstance
6fcd19ba 110 Tags?: TagInstance[]
93e1258c 111 VideoFiles?: VideoFileInstance[]
40ff5707 112 VideoShares?: VideoShareInstance[]
16b90975 113 AccountVideoRates?: AccountVideoRateInstance[]
e02643f3
C
114}
115
116export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
93e1258c
C
117 createPreview: VideoMethods.CreatePreview
118 createThumbnail: VideoMethods.CreateThumbnail
119 createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
40298b02 120 getOriginalFile: VideoMethods.GetOriginalFile
154898b0 121 getPreviewName: VideoMethods.GetPreviewName
d8755eed 122 getPreviewPath: VideoMethods.GetPreviewPath
93e1258c 123 getThumbnailName: VideoMethods.GetThumbnailName
d8755eed 124 getThumbnailPath: VideoMethods.GetThumbnailPath
93e1258c
C
125 getTorrentFileName: VideoMethods.GetTorrentFileName
126 getVideoFilename: VideoMethods.GetVideoFilename
127 getVideoFilePath: VideoMethods.GetVideoFilePath
154898b0 128 isOwned: VideoMethods.IsOwned
93e1258c
C
129 removeFile: VideoMethods.RemoveFile
130 removePreview: VideoMethods.RemovePreview
131 removeThumbnail: VideoMethods.RemoveThumbnail
132 removeTorrent: VideoMethods.RemoveTorrent
e4f97bab 133 toActivityPubObject: VideoMethods.ToActivityPubObject
0aef76c4 134 toFormattedJSON: VideoMethods.ToFormattedJSON
72c7248b 135 toFormattedDetailsJSON: VideoMethods.ToFormattedDetailsJSON
40298b02
C
136 optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile
137 transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile
138 getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
d8755eed 139 getEmbedPath: VideoMethods.GetEmbedPath
9567011b 140 getDescriptionPath: VideoMethods.GetDescriptionPath
2de96f4d 141 getTruncatedDescription: VideoMethods.GetTruncatedDescription
e4f97bab
C
142 getCategoryLabel: VideoMethods.GetCategoryLabel
143 getLicenceLabel: VideoMethods.GetLicenceLabel
144 getLanguageLabel: VideoMethods.GetLanguageLabel
6fcd19ba
C
145
146 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
40298b02 147 addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string>
93e1258c 148 setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string>
e02643f3
C
149}
150
151export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}