types.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import BN from 'bn.js'
  2. import { EntityId, SchemaId, ParametrizedClassPropertyValue, ClassId } from '@joystream/types/content-directory'
  3. import { DB } from '../generated/indexer'
  4. export interface BaseJoystreamMember {
  5. memberId: BN
  6. }
  7. export interface JoystreamMember extends BaseJoystreamMember {
  8. handle: string
  9. avatarUri: string
  10. about: string
  11. registeredAtBlock: number
  12. rootAccount: Buffer
  13. controllerAccount: Buffer
  14. }
  15. export interface MemberAboutText extends BaseJoystreamMember {
  16. about: string
  17. }
  18. export interface MemberAvatarURI extends BaseJoystreamMember {
  19. avatarUri: string
  20. }
  21. export interface MemberHandle extends BaseJoystreamMember {
  22. handle: string
  23. }
  24. export interface MemberRootAccount extends BaseJoystreamMember {
  25. rootAccount: Buffer
  26. }
  27. export interface MemberControllerAccount extends BaseJoystreamMember {
  28. controllerAccount: Buffer
  29. }
  30. export interface IReference {
  31. entityId: number
  32. existing: boolean
  33. }
  34. export interface IChannel {
  35. handle: string
  36. description: string
  37. coverPhotoUrl: string
  38. avatarPhotoUrl: string
  39. isPublic: boolean
  40. isCurated?: boolean
  41. language?: IReference
  42. }
  43. export interface ICategory {
  44. name: string
  45. description: string
  46. }
  47. export interface IKnownLicense {
  48. code: string
  49. name?: string
  50. description?: string
  51. url?: string
  52. }
  53. export interface IUserDefinedLicense {
  54. content: string
  55. }
  56. export interface IJoystreamMediaLocation {
  57. dataObjectId: string
  58. }
  59. export interface IHttpMediaLocation {
  60. url: string
  61. port?: number
  62. }
  63. export interface ILanguage {
  64. name: string
  65. code: string
  66. }
  67. export interface IVideoMediaEncoding {
  68. name: string
  69. }
  70. export interface IVideoMedia {
  71. encoding?: IReference
  72. pixelWidth: number
  73. pixelHeight: number
  74. size: number
  75. location?: IReference
  76. }
  77. export interface IVideo {
  78. // referenced entity's id
  79. channel?: IReference
  80. // referenced entity's id
  81. category?: IReference
  82. title: string
  83. description: string
  84. duration: number
  85. skippableIntroDuration?: number
  86. thumbnailUrl: string
  87. language?: IReference
  88. // referenced entity's id
  89. media?: IReference
  90. hasMarketing?: boolean
  91. publishedBeforeJoystream?: number
  92. isPublic: boolean
  93. isCurated?: boolean
  94. isExplicit: boolean
  95. license?: IReference
  96. }
  97. export interface ILicense {
  98. knownLicense?: IReference
  99. userDefinedLicense?: IReference
  100. attribution?: string
  101. }
  102. export interface IMediaLocation {
  103. httpMediaLocation?: IReference
  104. joystreamMediaLocation?: IReference
  105. }
  106. export enum OperationType {
  107. CreateEntity = 'CreateEntity',
  108. AddSchemaSupportToEntity = 'AddSchemaSupportToEntity',
  109. UpdatePropertyValues = 'UpdatePropertyValues',
  110. }
  111. export interface IAddSchemaSupportToEntity {
  112. entity_id: EntityId
  113. schema_id: SchemaId
  114. parametrized_property_values: ParametrizedClassPropertyValue[]
  115. }
  116. export interface ICreateEntity {
  117. class_id: ClassId
  118. }
  119. export interface IClassEntity {
  120. entityId: number
  121. classId: number
  122. }
  123. export interface IBatchOperation {
  124. createEntityOperations: ICreateEntityOperation[]
  125. addSchemaSupportToEntityOperations: IEntity[]
  126. updatePropertyValuesOperations: IEntity[]
  127. }
  128. export interface IProperty {
  129. // PropertId: Value
  130. // [propertyId: string]: any
  131. id: string
  132. value: any
  133. // If reference.exising is false then reference.entityId is the index that entity is at
  134. // in the transaction batch operation
  135. reference?: IReference
  136. }
  137. export interface IEntity {
  138. classId?: number
  139. entityId?: number
  140. // if entity is created in the same transaction, this is the entity id which is the index of the create
  141. // entity operation
  142. indexOf?: number
  143. properties: IProperty[]
  144. }
  145. export interface IPropertyDef {
  146. name: string
  147. type: string
  148. required: boolean
  149. }
  150. export interface IPropertyWithId {
  151. [inClassIndex: string]: IPropertyDef
  152. }
  153. export interface IWhereCond {
  154. where: { id: string }
  155. }
  156. export interface ICreateEntityOperation {
  157. classId: number
  158. }
  159. // An interface to use in function signature to simplify function parameters
  160. export interface IDBBlockId {
  161. db: DB
  162. block: number
  163. // Entity id
  164. id: string
  165. }
  166. export type ClassEntityMap = Map<string, IEntity[]>
  167. export interface IFeaturedVideo {
  168. video?: IReference
  169. }
  170. export interface IKnownClass {
  171. name: string
  172. classId: number
  173. }