video.model.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import {
  2. BaseModel,
  3. BooleanField,
  4. IntField,
  5. DateTimeField,
  6. Model,
  7. ManyToOne,
  8. OneToOne,
  9. OneToOneJoin,
  10. CustomField,
  11. EnumField,
  12. StringField,
  13. } from 'warthog';
  14. import { Channel } from '../channel/channel.model';
  15. import { VideoCategory } from '../video-category/video-category.model';
  16. import { DataObject } from '../data-object/data-object.model';
  17. import { Language } from '../language/language.model';
  18. import { License } from '../license/license.model';
  19. import { VideoMediaMetadata } from '../video-media-metadata/video-media-metadata.model';
  20. import { FeaturedVideo } from '../featured-video/featured-video.model';
  21. import { AssetAvailability } from '../enums/enums';
  22. export { AssetAvailability };
  23. @Model({ api: {} })
  24. export class Video extends BaseModel {
  25. @ManyToOne(() => Channel, (param: Channel) => param.videos, { skipGraphQLField: true, cascade: ["insert", "update"] })
  26. channel!: Channel;
  27. @ManyToOne(() => VideoCategory, (param: VideoCategory) => param.videos, { skipGraphQLField: true, nullable: true, cascade: ["insert", "update"] })
  28. category?: VideoCategory;
  29. @StringField({
  30. nullable: true,
  31. description: `The title of the video`,
  32. })
  33. title?: string;
  34. @StringField({
  35. nullable: true,
  36. description: `The description of the Video`,
  37. })
  38. description?: string;
  39. @IntField({
  40. nullable: true,
  41. description: `Video duration in seconds`,
  42. })
  43. duration?: number;
  44. @ManyToOne(() => DataObject, (param: DataObject) => param.videothumbnailPhotoDataObject, {
  45. skipGraphQLField: true,
  46. nullable: true,
  47. cascade: ["insert", "update"],
  48. })
  49. thumbnailPhotoDataObject?: DataObject;
  50. @CustomField({
  51. db: { type: 'text', array: true },
  52. api: { type: 'string', description: `URLs where the asset content can be accessed (if any)` },
  53. })
  54. thumbnailPhotoUrls!: string[];
  55. @EnumField('AssetAvailability', AssetAvailability, {
  56. description: `Availability meta information`,
  57. })
  58. thumbnailPhotoAvailability!: AssetAvailability;
  59. @ManyToOne(() => Language, (param: Language) => param.videolanguage, { skipGraphQLField: true, nullable: true, cascade: ["insert", "update"] })
  60. language?: Language;
  61. @BooleanField({
  62. nullable: true,
  63. description: `Whether or not Video contains marketing`,
  64. })
  65. hasMarketing?: boolean;
  66. @DateTimeField({
  67. nullable: true,
  68. description: `If the Video was published on other platform before beeing published on Joystream - the original publication date`,
  69. })
  70. publishedBeforeJoystream?: Date;
  71. @BooleanField({
  72. nullable: true,
  73. description: `Whether the Video is supposed to be publically displayed`,
  74. })
  75. isPublic?: boolean;
  76. @BooleanField({
  77. description: `Flag signaling whether a video is censored.`,
  78. })
  79. isCensored!: boolean;
  80. @BooleanField({
  81. nullable: true,
  82. description: `Whether the Video contains explicit material.`,
  83. })
  84. isExplicit?: boolean;
  85. @ManyToOne(() => License, (param: License) => param.videolicense, { skipGraphQLField: true, nullable: true, cascade: ["insert", "update"] })
  86. license?: License;
  87. @ManyToOne(() => DataObject, (param: DataObject) => param.videomediaDataObject, {
  88. skipGraphQLField: true,
  89. nullable: true,
  90. cascade: ["insert", "update"],
  91. })
  92. mediaDataObject?: DataObject;
  93. @CustomField({
  94. db: { type: 'text', array: true },
  95. api: { type: 'string', description: `URLs where the asset content can be accessed (if any)` },
  96. })
  97. mediaUrls!: string[];
  98. @EnumField('AssetAvailability', AssetAvailability, {
  99. description: `Availability meta information`,
  100. })
  101. mediaAvailability!: AssetAvailability;
  102. @OneToOneJoin(() => VideoMediaMetadata, (param: VideoMediaMetadata) => param.video, { nullable: true, cascade: ["insert", "update"] })
  103. mediaMetadata?: VideoMediaMetadata;
  104. @IntField({})
  105. createdInBlock!: number;
  106. @BooleanField({
  107. description: `Is video featured or not`,
  108. })
  109. isFeatured!: boolean;
  110. @OneToOne(() => FeaturedVideo, (param: FeaturedVideo) => param.video, { nullable: true, cascade: ["insert", "update"] })
  111. featured?: FeaturedVideo;
  112. constructor(init?: Partial<Video>) {
  113. super();
  114. Object.assign(this, init);
  115. }
  116. }