types.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. title: 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. }
  101. export interface IMediaLocation {
  102. httpMediaLocation?: IReference
  103. joystreamMediaLocation?: IReference
  104. }
  105. export enum OperationType {
  106. CreateEntity = 'CreateEntity',
  107. AddSchemaSupportToEntity = 'AddSchemaSupportToEntity',
  108. UpdatePropertyValues = 'UpdatePropertyValues',
  109. }
  110. export interface IAddSchemaSupportToEntity {
  111. entity_id: EntityId
  112. schema_id: SchemaId
  113. parametrized_property_values: ParametrizedClassPropertyValue[]
  114. }
  115. export interface ICreateEntity {
  116. class_id: ClassId
  117. }
  118. export interface IClassEntity {
  119. entityId: number
  120. classId: number
  121. }
  122. export interface IBatchOperation {
  123. createEntityOperations: ICreateEntityOperation[]
  124. addSchemaSupportToEntityOperations: IEntity[]
  125. updatePropertyValuesOperations: IEntity[]
  126. }
  127. export interface IProperty {
  128. // PropertId: Value
  129. // [propertyId: string]: any
  130. id: string
  131. value: any
  132. // If reference.exising is false then reference.entityId is the index that entity is at
  133. // in the transaction batch operation
  134. reference?: IReference
  135. }
  136. export interface IEntity {
  137. classId?: number
  138. entityId?: number
  139. // if entity is created in the same transaction, this is the entity id which is the index of the create
  140. // entity operation
  141. indexOf?: number
  142. properties: IProperty[]
  143. }
  144. export interface IPropertyDef {
  145. name: string
  146. type: string
  147. required: boolean
  148. }
  149. export interface IPropertyWithId {
  150. [inClassIndex: string]: IPropertyDef
  151. }
  152. export interface IWhereCond {
  153. where: { id: string }
  154. }
  155. export interface ICreateEntityOperation {
  156. classId: number
  157. }
  158. // An interface to use in function signature to simplify function parameters
  159. export interface IDBBlockId {
  160. db: DB
  161. block: number
  162. // Entity id
  163. id: string
  164. }
  165. export type ClassEntityMap = Map<string, IEntity[]>