import { AuthorResponse } from './Author'; import { PagedListResponse } from './common'; /** * This type describe the result of a list request on media * @template T The type of media requested */ export type PagedMediaResponse = { /** * The list of items requested, where T is the type of media requested */ items: T[]; /** * This property is returned when a single request is not sufficient to retrieve all items, use this param to retrieve the next set of items */ nextCursor?: string; /** * The total number of media */ total: number; }; /** * The media gallery unique id */ export type MediaGalleryId = number; /** * This type describe a media gallery information */ export type MediaGallery = { /** * The media gallery unique id */ id: MediaGalleryId; /** * The media gallery root folder (this is a generated value composed so `spaceId/aRandomToken`), it used to define the starting folder of every media gallery */ rootFolderName: string; /** * The chosen media gallery color */ color: string; /** * The chosen media gallery name */ name: string; /** * The chosen media gallery description */ description: string; /** * This is the media provider used to manage media */ provider: string; /** * The creation date of the media gallery */ createdDate: Date; /** * The update date of the media gallery */ lastModifiedDate: Date; /** * The information of the user that created the media gallery */ author: AuthorResponse; /** * The information of the user that last updated the media gallery */ latestContributor: AuthorResponse; /** * This value represent the archived status of the media gallery */ archived: boolean; /** * The archiving date of the media gallery */ archivedDate?: Date; }; /** * This is the media unique id */ export type MediaPublicId = string; /** * This type represent a media information */ export type Media = { /** * The aspect radio of the media */ aspectRatio: number; /** * The size of the media in bytes */ bytes: number; /** * The copiable public url of the media */ copyableUrl: string; /** * The creation date of the media */ createdAt: Date; /** * The height size of the media */ height: number; /** * The width size of the media */ width: number; /** * The media public id used to retrieve the media from the api */ mediaPublicId: MediaPublicId; /** * The public url of the media */ originalUrl: string; /** * The thumbnail public url of the media */ thumbnailUrl: string; /** * The type of the media */ resourceType: MediaType; /** * The tags saved with the media */ tags: string[]; /** * The tags saved with the media * e.g. -> svg, jpg, png, ... */ format: string; }; /** * This type represent all possible filters used to retrieve a list of media gallery */ export type ListMediaGalleryFilters = { /** * This filter is used to search a media gallery that contain the value inserted */ name?: string; /** * This filter is used to retrieve archived or not archived media gallery */ archived?: boolean; }; /** * This type represent the data needed to make a get media gallery API request */ export type GetMediaGalleryRequest = { /** * The media gallery unique id */ id: MediaGalleryId; }; /** * This type represent the response of the get media gallery API request */ export type GetMediaGalleryResponse = MediaGallery; /** * This type represent the data needed to make a list media gallery API request */ export type ListMediaGalleryRequest = { /** * The number of media galleries to skip */ skip: number; /** * The number of media galleries to take */ take: number; /** * The data used to filter the list of media gallery */ filters: ListMediaGalleryFilters; }; /** * This type represent the response of the list media gallery api request */ export type ListMediaGalleryResponse = PagedListResponse; /** * This type represent the data needed to make a create media gallery API request */ export type CreateMediaGalleryRequest = { /** * THe name of the media gallery */ name: string; /** * The color of the media gallery */ color?: string; /** * This description of the media gallery */ description?: string; }; /** * This type represent the response of the create media gallery API request */ export type CreateMediaGalleryResponse = MediaGallery; /** * This type represent the data needed to make a delete media gallery API request */ export type DeleteMediaGalleryRequest = { /** * The media gallery unique id */ id: MediaGalleryId; }; /** * This type represent the response of the delete media gallery API request */ export type DeleteMediaGalleryResponse = Pick>; /** * This type represent the data needed to make an update media gallery API request */ export type UpdateMediaGalleryRequest = { /** * The media gallery unique id */ id: MediaGalleryId; /** * The media gallery name */ name: string; /** * The media gallery description */ description: string; /** * The media gallery color */ color: string; /** * The media gallery root folder name */ rootFolderName: string; }; /** * This type represent the response of an update media gallery API request */ export type UpdateMediaGalleryResponse = MediaGallery; /** * This type represent the data needed to make a verify media API request */ export type VerifyMediaRequest = { /** * The media gallery unique id */ mediaGalleryId: MediaGalleryId; /** * The media type */ mediaType: MediaType; /** * The path to add at the media public id needed to locate the media in the media gallery */ parentFolder?: string; /** * The media unique public id */ mediaPublicId: string; }; /** * This type represent the response of a verify media API request */ export type VerifyMediaResponse = { valid: boolean; }; /** * This type represent the data needed to make a lit media gallery folder API request */ export type ListMediaGalleryFoldersRequest = { /** * The media gallery unique id */ mediaGalleryId: MediaGalleryId; /** * The folder path where to list the folders */ folderPath?: string; }; /** * This type represent the structure of a folder */ export type Folder = { /** * The name of the folder */ name: string; /** * The path needed to reach the folder */ path: string; }; /** * This type represent the response of a list media gallery folder API request */ export type ListMediaGalleryFoldersResponse = { /** * A list of folders */ folders: Folder[]; }; /** * This type represent the data needed to make a list media API request */ export type ListMediaRequest = { /** * The media gallery unique id */ mediaGalleryId: MediaGalleryId; /** * The number of media to take */ take: number; /** * The number of media to skip * This is used to paginate the media * e.g. -> skip = 0 -> take = 10 -> media[0-9] * skip = 10 -> take = 10 -> media[10-19] * skip = 20 -> take = 10 -> media[20-29] */ skip: number; /** * The folder path where to list the media */ folderPath?: string; /** * The type of media to retrieve */ resourceType?: MediaType; /** * The tags that the media have to contain to be searched */ tags?: string[]; }; /** * This type represent the response of a list media API request */ export type ListMediaResponse = PagedMediaResponse; /** * This type represent the data needed to make a get media API request */ export type GetMediaRequest = { /** * The media gallery unique id */ mediaGalleryId: MediaGalleryId; /** * The path needed to locate the media in the media gallery */ parentFolder?: string; /** * The media public id */ mediaPublicId: string; }; /** * This type represent the response of a get media API request */ export type GetMediaResponse = Media; /** * This type represent the data needed to make an upload media API request */ export type UploadMediaRequest = { /** * The media gallery unique id */ mediaGalleryId: MediaGalleryId; /** * The type of the media */ mediaType: MediaType; /** * The media public id */ mediaPublicId: string; /** * The media size */ size: number; /** * The path where to upload the media */ parentFolder?: string; /** * The tags saved with the media */ tags?: string[]; }; /** * This type represent the response of a upload media API request */ export type UploadMediaResponse = { /** * This property is a boolean that determines whether or not a media requires an additional step */ largeUpload: boolean; /** * The media provider signed url where to perform the upload request * * e.g. * ``` js * if (largeUpload) { * // call this url with the readUrl value * await axios.put(writeUrl, ); * const formData = new FormData(); * formData.append('file', readUrl); * await axios.post(uploadUrl, formData) * } else { * // call this url directly with the media * const formData = new FormData(); * formData.append('file', ); * await axios.post(uploadUrl, formData); * } * ``` */ uploadUrl: string; /** * The media public id */ mediaPublicId: string; /** * If the media is large (largeUpload value) this is the url where to read the file when performing a large upload */ readUrl?: string; /** * If the media is large (largeUpload value) this is the url where to write the file before to perform the real upload */ writeUrl?: string; }; /** * This type represent the data needed to make an update media API request */ export type UpdateMediaRequest = { /** * The media gallery unique id where the media is located */ mediaGalleryId: number; /** * The media public id */ mediaPublicId: string; /** * The tags to add to the media */ tags: string[]; /** * The type of the media to add */ resourceType: MediaType; }; /** * This type represent the data needed to make a list media tag API request */ export type ListMediaTagRequest = { /** * The value that the tag must contain */ tag?: string; }; /** * This type represent the response of a list media tag API request */ export type ListMediaTagResponse = { tags: string[]; }; /** * This type represent the response of a upload media API request */ export type UpdateMediaResponse = Media; /** * This type represent the possible type of media accepted */ export type MediaType = 'image' | 'video' | 'raw'; /** * Parameters needed to delete a media */ export type DeleteMediaRequest = { /** * The media gallery unique id where the media is located */ mediaGalleryId: number; /** * The media public id */ mediaPublicId: string; /** * The type of the media to add */ resourceType: MediaType; }; /** * Success or failure (boolean) of a delete media request */ export type DeleteMediaResponse = boolean;