import { Adminizer } from "../Adminizer"; export interface MediaManagerItem { id: string; parent: string; variants: MediaManagerItem[]; mimeType: string; path: string; size: number; /** * size: lm | sm | any or locale: en | de | fr */ tag: string; group?: string; url: string; filename: string; meta: string[]; createdAt: number; updatedAt: number; } type NumericKeys = { [K in keyof T]: T[K] extends number ? K : never; }[keyof T]; export type SortCriteria = `${NumericKeys} ${"ASC" | "DESC"}`; export interface MediaManagerWidgetItem { id: string; } /** * This method is for receiving data in the client */ export interface MediaManagerWidgetClientItem extends MediaManagerWidgetItem { /** * need only mimeGroup like Imeage/xxx */ mimeType: string; variants: MediaManagerItem[]; filename: string; url?: string; } export interface MediaManagerWidgetJSON { mediaManagerId: string; model: string; widgetName: string; modelId: string | number; } export interface MediaManagerWidgetData { id: string; } export type UploaderFile = Express.Multer.File; export interface imageSizes { [key: string]: { width: number; height: number; }; } export type MediaFileType = "application" | "audio" | "example" | "image" | "message" | "model" | "multipart" | "text" | "video"; export declare abstract class File { abstract type: MediaFileType; urlPathPrefix: string; fileStoragePath: string; model: string; metaModel: string; /** * * @param urlPathPrefix * @param fileStoragePath */ protected constructor(urlPathPrefix: string, fileStoragePath: string); /** * Upload a file. * @param file * @param filename * @param origFileName * @param group */ abstract upload(file: UploaderFile, filename: string, origFileName: string, group?: string): Promise; /** * Get metadata for an item. * @param id */ abstract getMeta(id: string): Promise<{ key: string; value: string; }[]>; /** * Set metadata for an item. * @param id * @param data */ abstract setMeta(id: string, data: { [key: string]: string; }): Promise; /** * Get children of an item. * @param id */ abstract getVariants(id: string): Promise; /** * Upload cropped image. * @param item * @param file * @param fileName * @param group * @param localeId */ abstract uploadVariant(item: MediaManagerItem, file: UploaderFile, fileName: string, group?: string, localeId?: string): Promise; /** * Delete an item. * @param id */ abstract delete(id: string): Promise; /** * Get all items of a type. * @param limit * @param skip * @param sort * @param group */ abstract getItems(limit: number, skip: number, sort: SortCriteria, group?: string): Promise<{ data: MediaManagerItem[]; next: boolean; }>; abstract search(s: string, group?: string): Promise; abstract getOrigin(id: string): Promise; abstract getFile(id: number): Promise; } /** * * ░█████╗░██████╗░░██████╗████████╗██████╗░░█████╗░░█████╗░████████╗ * ██╔══██╗██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝ * ███████║██████╦╝╚█████╗░░░░██║░░░██████╔╝███████║██║░░╚═╝░░░██║░░░ * ██╔══██║██╔══██╗░╚═══██╗░░░██║░░░██╔══██╗██╔══██║██║░░██╗░░░██║░░░ * ██║░░██║██████╦╝██████╔╝░░░██║░░░██║░░██║██║░░██║╚█████╔╝░░░██║░░░ * ╚═╝░░╚═╝╚═════╝░╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚═╝░╚════╝░░░░╚═╝░░░ * * ███╗░░░███╗███████╗██████╗░██╗░█████╗░███╗░░░███╗░█████╗░███╗░░██╗░█████╗░░██████╗░███████╗██████╗░ * ████╗░████║██╔════╝██╔══██╗██║██╔══██╗████╗░████║██╔══██╗████╗░██║██╔══██╗██╔════╝░██╔════╝██╔══██╗ * ██╔████╔██║█████╗░░██║░░██║██║███████║██╔████╔██║███████║██╔██╗██║███████║██║░░██╗░█████╗░░██████╔╝ * ██║╚██╔╝██║██╔══╝░░██║░░██║██║██╔══██║██║╚██╔╝██║██╔══██║██║╚████║██╔══██║██║░░╚██╗██╔══╝░░██╔══██╗ * ██║░╚═╝░██║███████╗██████╔╝██║██║░░██║██║░╚═╝░██║██║░░██║██║░╚███║██║░░██║╚██████╔╝███████╗██║░░██║ * ╚═╝░░░░░╚═╝╚══════╝╚═════╝░╚═╝╚═╝░░╚═╝╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝░░╚═╝░╚═════╝░╚══════╝╚═╝░░╚═╝ */ export declare abstract class AbstractMediaManager { uploadMaxBytes: number; uloadAllowedTypes: string[]; fileStoragePath: string; urlPathPrefix: string; /** */ allowSearch: boolean; /**⚠️ above the settings that need to be implemented*/ /** * id for mediamanager instance */ abstract id: string; readonly itemTypes: File[]; /** * @protected */ protected constructor(adminizer: Adminizer); private _bindAccessRight; /** * Upload an item. * @param file * @param filename * @param origFileName * @param group */ upload(file: UploaderFile, filename: string, origFileName: string, group?: string): Promise; /** * Get item type. * @param type * @protected */ protected getItemType(type: string): File; /** * Get all items. * @param limit * @param skip * @param group * @param sort */ abstract getAll(limit: number, skip: number, sort: SortCriteria, group?: string): Promise<{ data: MediaManagerItem[]; next: boolean; }>; /** * Get items of a type. * @param type * @param limit * @param skip * @param sort * @param group */ getItems(type: string, limit: number, skip: number, sort: SortCriteria, group?: string): Promise<{ data: MediaManagerItem[]; next: boolean; }>; /** * Save Relations. * @param data * @param model model in which a mediafile connection was added * @param modelId Id in the model in which the mediafile was added * @param widgetName */ abstract setRelations(data: MediaManagerWidgetData[], /** * widget model in which a mediafile connection was added */ model: string, /** * widget Id in the model in which the mediafile was added */ modelId: number | string, widgetName: string): Promise; abstract getRelations(model: string, widgetName: string, modelId: string | number): Promise; /** * Search all items. * If not this.allowSearch = true then it will not come here * @param s * @param group */ abstract searchAll(s: string, group?: string): Promise; /** * Search items by type. * @param s * @param type * @param group */ searchItems(s: string, type: string, group?: string): Promise; /** * Get children of an item. * @param item */ getVariants(item: MediaManagerItem): Promise; /** * Upload cropped image. * @param item * @param file * @param fileName * @param group * @param localeId */ uploadVariant(item: MediaManagerItem, file: UploaderFile, fileName: string, group?: string, localeId?: string): Promise; /** * Get metadata of an item. * @param item */ getMeta(item: MediaManagerItem): Promise<{ key: string; value: string; }[]>; getOrigin(id: string): Promise; getFile(mimeType: string, id: number): Promise; /** * Set metadata of an item. * @param item * @param data */ setMeta(item: MediaManagerItem, data: { [key: string]: string; }): Promise; /** * Delete an item. * @param item */ delete(item: MediaManagerItem): Promise; } export {};