1 import { values } from 'lodash'
2 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
4 isVideoFileInfoHashValid,
5 isVideoFileResolutionValid,
7 isVideoFPSResolutionValid
8 } from '../../helpers/custom-validators/videos'
9 import { CONSTRAINTS_FIELDS } from '../../initializers'
10 import { throwIfNotValid } from '../utils'
11 import { VideoModel } from './video'
14 tableName: 'videoFile',
20 fields: [ 'infoHash' ]
23 fields: [ 'videoId', 'resolution', 'fps' ],
28 export class VideoFileModel extends Model<VideoFileModel> {
36 @Is('VideoFileResolution', value => throwIfNotValid(value, isVideoFileResolutionValid, 'resolution'))
41 @Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileSizeValid, 'size'))
42 @Column(DataType.BIGINT)
46 @Column(DataType.ENUM(values(CONSTRAINTS_FIELDS.VIDEOS.EXTNAME)))
50 @Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileInfoHashValid, 'info hash'))
56 @Is('VideoFileFPS', value => throwIfNotValid(value, isVideoFPSResolutionValid, 'fps'))
60 @ForeignKey(() => VideoModel)
64 @BelongsTo(() => VideoModel, {