MusicAlbum.ts 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /** This file is generated based on JSON schema. Do not modify. */
  2. import * as Yup from 'yup';
  3. import { EntityCodec } from '@joystream/types/versioned-store/EntityCodec';
  4. import moment from 'moment';
  5. import { MusicGenreType } from './MusicGenre';
  6. import { MusicMoodType } from './MusicMood';
  7. import { MusicThemeType } from './MusicTheme';
  8. import { MusicTrackType } from './MusicTrack';
  9. import { LanguageType } from '../general/Language';
  10. import { PublicationStatusType } from '../general/PublicationStatus';
  11. import { CurationStatusType } from '../general/CurationStatus';
  12. import { ContentLicenseType } from '../general/ContentLicense';
  13. import { ChannelEntity } from '@polkadot/joy-media/entities/ChannelEntity';
  14. export const MusicAlbumValidationSchema = Yup.object().shape({
  15. title: Yup.string()
  16. .required('This field is required')
  17. .max(255, 'Text is too long. Maximum length is 255 chars.'),
  18. artist: Yup.string()
  19. .required('This field is required')
  20. .max(255, 'Text is too long. Maximum length is 255 chars.'),
  21. thumbnail: Yup.string()
  22. .required('This field is required')
  23. .max(255, 'Text is too long. Maximum length is 255 chars.'),
  24. description: Yup.string()
  25. .required('This field is required')
  26. .max(4000, 'Text is too long. Maximum length is 4000 chars.'),
  27. firstReleased: Yup.string()
  28. .required('This field is required')
  29. .test('valid-date', 'Invalid date. Valid date formats are yyyy-mm-dd or yyyy-mm or yyyy.', (val?: any) => {
  30. return moment(val as any).isValid();
  31. }),
  32. lyrics: Yup.string()
  33. .max(255, 'Text is too long. Maximum length is 255 chars.'),
  34. composerOrSongwriter: Yup.string()
  35. .max(255, 'Text is too long. Maximum length is 255 chars.'),
  36. attribution: Yup.string()
  37. .max(255, 'Text is too long. Maximum length is 255 chars.')
  38. });
  39. export type MusicAlbumFormValues = {
  40. title: string
  41. artist: string
  42. thumbnail: string
  43. description: string
  44. firstReleased: string
  45. genre: number
  46. mood: number
  47. theme: number
  48. tracks: number[]
  49. language: number
  50. links: string[]
  51. lyrics: string
  52. composerOrSongwriter: string
  53. reviews: string[]
  54. publicationStatus: number
  55. curationStatus: number
  56. explicit: boolean
  57. license: number
  58. attribution: string
  59. channelId: number
  60. };
  61. export type MusicAlbumType = {
  62. classId: number
  63. inClassSchemaIndexes: number[]
  64. id: number
  65. title: string
  66. artist: string
  67. thumbnail: string
  68. description: string
  69. firstReleased: number
  70. genre?: MusicGenreType
  71. mood?: MusicMoodType
  72. theme?: MusicThemeType
  73. tracks?: MusicTrackType[]
  74. language?: LanguageType
  75. links?: string[]
  76. lyrics?: string
  77. composerOrSongwriter?: string
  78. reviews?: string[]
  79. publicationStatus: PublicationStatusType
  80. curationStatus?: CurationStatusType
  81. explicit: boolean
  82. license: ContentLicenseType
  83. attribution?: string
  84. channelId?: number
  85. channel?: ChannelEntity
  86. };
  87. export class MusicAlbumCodec extends EntityCodec<MusicAlbumType> { }
  88. export function MusicAlbumToFormValues(entity?: MusicAlbumType): MusicAlbumFormValues {
  89. return {
  90. title: entity && entity.title || '',
  91. artist: entity && entity.artist || '',
  92. thumbnail: entity && entity.thumbnail || '',
  93. description: entity && entity.description || '',
  94. firstReleased: entity && moment(entity.firstReleased * 1000).format('YYYY-MM-DD') || '',
  95. genre: entity && entity.genre?.id || 0,
  96. mood: entity && entity.mood?.id || 0,
  97. theme: entity && entity.theme?.id || 0,
  98. tracks: entity && entity.tracks?.map(x => x.id) || [],
  99. language: entity && entity.language?.id || 0,
  100. links: entity && entity.links || [],
  101. lyrics: entity && entity.lyrics || '',
  102. composerOrSongwriter: entity && entity.composerOrSongwriter || '',
  103. reviews: entity && entity.reviews || [],
  104. publicationStatus: entity && entity.publicationStatus.id || 0,
  105. curationStatus: entity && entity.curationStatus?.id || 0,
  106. explicit: entity && entity.explicit || false,
  107. license: entity && entity.license?.id || 0,
  108. attribution: entity && entity.attribution || '',
  109. channelId: entity && entity.channelId || 0
  110. }
  111. }
  112. export type MusicAlbumPropId =
  113. 'title' |
  114. 'artist' |
  115. 'thumbnail' |
  116. 'description' |
  117. 'firstReleased' |
  118. 'genre' |
  119. 'mood' |
  120. 'theme' |
  121. 'tracks' |
  122. 'language' |
  123. 'links' |
  124. 'lyrics' |
  125. 'composerOrSongwriter' |
  126. 'reviews' |
  127. 'publicationStatus' |
  128. 'curationStatus' |
  129. 'explicit' |
  130. 'license' |
  131. 'attribution' |
  132. 'channelId'
  133. ;
  134. export type MusicAlbumGenericProp = {
  135. id: MusicAlbumPropId,
  136. type: string,
  137. name: string,
  138. description?: string,
  139. required?: boolean,
  140. maxItems?: number,
  141. maxTextLength?: number,
  142. classId?: any
  143. };
  144. type MusicAlbumClassType = {
  145. [id in MusicAlbumPropId]: MusicAlbumGenericProp
  146. };
  147. export const MusicAlbumClass: MusicAlbumClassType = {
  148. title: {
  149. "id": "title",
  150. "name": "Title",
  151. "description": "The title of the album",
  152. "type": "Text",
  153. "required": true,
  154. "maxTextLength": 255
  155. },
  156. artist: {
  157. "id": "artist",
  158. "name": "Artist",
  159. "description": "The artist, composer, band or group that published the album.",
  160. "type": "Text",
  161. "required": true,
  162. "maxTextLength": 255
  163. },
  164. thumbnail: {
  165. "id": "thumbnail",
  166. "name": "Thumbnail",
  167. "description": "URL to album cover art thumbnail: NOTE: Should be an https link to a square image, between 1400x1400 and 3000x3000 pixels, in JPEG or PNG format.",
  168. "required": true,
  169. "type": "Text",
  170. "maxTextLength": 255
  171. },
  172. description: {
  173. "id": "description",
  174. "name": "Description",
  175. "description": "Information about the album and artist.",
  176. "required": true,
  177. "type": "Text",
  178. "maxTextLength": 4000
  179. },
  180. firstReleased: {
  181. "id": "firstReleased",
  182. "name": "First Released",
  183. "description": "When the album was first released",
  184. "required": true,
  185. "type": "Int64"
  186. },
  187. genre: {
  188. "id": "genre",
  189. "name": "Genre",
  190. "description": "The genre of the album.",
  191. "type": "Internal",
  192. "classId": "Music Genre"
  193. },
  194. mood: {
  195. "id": "mood",
  196. "name": "Mood",
  197. "description": "The mood of the album.",
  198. "type": "Internal",
  199. "classId": "Music Mood"
  200. },
  201. theme: {
  202. "id": "theme",
  203. "name": "Theme",
  204. "description": "The theme of the album.",
  205. "type": "Internal",
  206. "classId": "Music Theme"
  207. },
  208. tracks: {
  209. "id": "tracks",
  210. "name": "Tracks",
  211. "description": "The tracks of the album.",
  212. "type": "InternalVec",
  213. "maxItems": 100,
  214. "classId": "Music Track"
  215. },
  216. language: {
  217. "id": "language",
  218. "name": "Language",
  219. "description": "The language of the song lyrics in the album.",
  220. "required": false,
  221. "type": "Internal",
  222. "classId": "Language"
  223. },
  224. links: {
  225. "id": "links",
  226. "name": "Links",
  227. "description": "Links to the artist or album site, or social media pages.",
  228. "type": "TextVec",
  229. "maxItems": 5,
  230. "maxTextLength": 255
  231. },
  232. lyrics: {
  233. "id": "lyrics",
  234. "name": "Lyrics",
  235. "description": "Link to the album tracks lyrics.",
  236. "type": "Text",
  237. "maxTextLength": 255
  238. },
  239. composerOrSongwriter: {
  240. "id": "composerOrSongwriter",
  241. "name": "Composer or songwriter",
  242. "description": "The composer(s) and/or songwriter(s) of the album.",
  243. "type": "Text",
  244. "maxTextLength": 255
  245. },
  246. reviews: {
  247. "id": "reviews",
  248. "name": "Reviews",
  249. "description": "Links to reviews of the album.",
  250. "type": "TextVec",
  251. "maxItems": 5,
  252. "maxTextLength": 255
  253. },
  254. publicationStatus: {
  255. "id": "publicationStatus",
  256. "name": "Publication Status",
  257. "description": "The publication status of the album.",
  258. "required": true,
  259. "type": "Internal",
  260. "classId": "Publication Status"
  261. },
  262. curationStatus: {
  263. "id": "curationStatus",
  264. "name": "Curation Status",
  265. "description": "The publication status of the album set by the a content curator on the platform.",
  266. "type": "Internal",
  267. "classId": "Curation Status"
  268. },
  269. explicit: {
  270. "id": "explicit",
  271. "name": "Explicit",
  272. "description": "Indicates whether the album contains explicit material.",
  273. "required": true,
  274. "type": "Bool"
  275. },
  276. license: {
  277. "id": "license",
  278. "name": "License",
  279. "description": "The license of which the album is released under.",
  280. "required": true,
  281. "type": "Internal",
  282. "classId": "Content License"
  283. },
  284. attribution: {
  285. "id": "attribution",
  286. "name": "Attribution",
  287. "description": "If the License requires attribution, add this here.",
  288. "type": "Text",
  289. "maxTextLength": 255
  290. },
  291. channelId: {
  292. "id": "channelId",
  293. "name": "Channel Id",
  294. "description": "Id of the channel this album is published under.",
  295. "type": "Uint64"
  296. }
  297. };