video.model.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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(
  26. () => Channel,
  27. (param: Channel) => param.videos,
  28. { skipGraphQLField: true }
  29. )
  30. channel!: Channel;
  31. @ManyToOne(
  32. () => VideoCategory,
  33. (param: VideoCategory) => param.videos,
  34. { skipGraphQLField: true, nullable: true }
  35. )
  36. category?: VideoCategory;
  37. @StringField({
  38. nullable: true,
  39. description: `The title of the video`
  40. })
  41. title?: string;
  42. @StringField({
  43. nullable: true,
  44. description: `The description of the Video`
  45. })
  46. description?: string;
  47. @IntField({
  48. nullable: true,
  49. description: `Video duration in seconds`
  50. })
  51. duration?: number;
  52. @ManyToOne(
  53. () => DataObject,
  54. (param: DataObject) => param.videothumbnailDataObject,
  55. { skipGraphQLField: true, nullable: true }
  56. )
  57. thumbnailDataObject?: DataObject;
  58. @CustomField({
  59. db: { type: 'text', array: true },
  60. api: { type: 'string', description: `URLs where the asset content can be accessed (if any)` }
  61. })
  62. thumbnailUrls!: string[];
  63. @EnumField('AssetAvailability', AssetAvailability, {
  64. description: `Availability meta information`
  65. })
  66. thumbnailAvailability!: AssetAvailability;
  67. @ManyToOne(
  68. () => Language,
  69. (param: Language) => param.videolanguage,
  70. { skipGraphQLField: true, nullable: true }
  71. )
  72. language?: Language;
  73. @BooleanField({
  74. nullable: true,
  75. description: `Whether or not Video contains marketing`
  76. })
  77. hasMarketing?: boolean;
  78. @DateTimeField({
  79. nullable: true,
  80. description: `If the Video was published on other platform before beeing published on Joystream - the original publication date`
  81. })
  82. publishedBeforeJoystream?: Date;
  83. @BooleanField({
  84. nullable: true,
  85. description: `Whether the Video is supposed to be publically displayed`
  86. })
  87. isPublic?: boolean;
  88. @BooleanField({
  89. description: `Flag signaling whether a video is censored.`
  90. })
  91. isCensored!: boolean;
  92. @BooleanField({
  93. nullable: true,
  94. description: `Whether the Video contains explicit material.`
  95. })
  96. isExplicit?: boolean;
  97. @ManyToOne(
  98. () => License,
  99. (param: License) => param.videolicense,
  100. { skipGraphQLField: true, nullable: true }
  101. )
  102. license?: License;
  103. @ManyToOne(
  104. () => DataObject,
  105. (param: DataObject) => param.videomediaDataObject,
  106. { skipGraphQLField: true, nullable: true }
  107. )
  108. mediaDataObject?: DataObject;
  109. @CustomField({
  110. db: { type: 'text', array: true },
  111. api: { type: 'string', description: `URLs where the asset content can be accessed (if any)` }
  112. })
  113. mediaUrls!: string[];
  114. @EnumField('AssetAvailability', AssetAvailability, {
  115. description: `Availability meta information`
  116. })
  117. mediaAvailability!: AssetAvailability;
  118. @OneToOneJoin(
  119. () => VideoMediaMetadata,
  120. (param: VideoMediaMetadata) => param.video,
  121. { nullable: true }
  122. )
  123. mediaMetadata?: VideoMediaMetadata;
  124. @IntField({})
  125. happenedIn!: number;
  126. @BooleanField({
  127. description: `Is video featured or not`
  128. })
  129. isFeatured!: boolean;
  130. @OneToOne(
  131. () => FeaturedVideo,
  132. (param: FeaturedVideo) => param.video,
  133. { nullable: true }
  134. )
  135. featured?: FeaturedVideo;
  136. constructor(init?: Partial<Video>) {
  137. super();
  138. Object.assign(this, init);
  139. }
  140. }