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