import { MimeType, IMimeType } from "../MimeType"; import { Settings } from "../ProviderState/Settings"; /** * Represents a version of a file stored in IndexedDB. */ export type IDBFileVersion = Omit & { data: Blob; mimeType: MimeType; videos: IDBVideo[]; }; export type IDBVideo = { id: string; name: string; created: number; size: number; duration: number; type: string; mediaType: string; blob: Blob; }; export type IDBFile = { id: string; name: string; url?: string; size?: number; created?: number; lastModified?: number; type: string; mediaType: string; children?: IDBFile[]; }; /** * Represents a file stored in IndexedDB. */ export type IDBProjectFile = { versions: Record; name: string; url?: string; }; export type Version = IDBFile & { version: number; }; export type Versions = Version[]; export type ProjectValue = { mimeType: MimeType; blob: Blob; versions: Versions; version: number; videos: IDBVideo[]; }; /** * Properties required to initialize a LocalDbStore. */ export interface LocalDbStoreProps { name: string; type: `${string}/${string}`; } /** * Properties required to initialize the LocalDb. */ export interface LocalDbProps { type: `${string}/${string}`; dbName: string; stores: { name: string; type: string; }[]; initializeStores: string[]; disabled: boolean; } export interface ISaveFileData { id: string; name: string; version: number; created: number; lastModified: number; metadata: Settings; description: string; author: string; url?: string; } export interface FileSaveRequest { name: string; version: number; meta: ISaveFileData; blob: Blob; mime: IMimeType; url?: string; } export interface VideoSaveRequest { storeName: string; projectName: string; name: string; version: number; blob: Blob; duration: number; created: number; size?: number; } export type FileLoadRequest = FileLoadRequestByName | FileLoadRequestByUrl; export interface FileLoadRequestByName { name: string; version?: number; store: string; } export interface FileLoadRequestByUrl { url: string; version?: number; store: string; } export declare function getRecordVersions(record: IDBProjectFile): Versions; export declare function getVideos(record: IDBProjectFile): any[]; export declare function createFolder(name: string, children?: IDBFile[], created?: number, options?: { id?: string; expanded?: boolean; selected?: boolean; }): { expanded?: boolean; selected?: boolean; id: string; name: string; created: number | undefined; type: string; mediaType: string; children: IDBFile[]; }; /** * Class representing the local database. */ export default class LocalDb { static dbName: string; static stores: { [storeName: string]: LocalDbStore; }; static version: number; private static disabled; static initialized: boolean; /** * Initializes the local database with the given properties. * @param props - The properties required to initialize the database. */ static init({ dbName, stores, initializeStores, disabled }: LocalDbProps): Promise; /** * Opens the local database. * @returns A promise that resolves to the opened database. */ static open(): Promise>; /** * Loads a file by its ID from the specified store. * @param store - The name of the store. * @param id - The ID of the file. * @param version - The version requested from idb. * @returns A promise that resolves to the file data. */ static loadByName({ store, name, version }: FileLoadRequestByName): Promise; static getVersions({ store, name }: { store: string; name: string; }): Promise; /** * Loads a file by its ID from the specified store. * @param store - The name of the store. * @param id - The ID of the file. * @param version - The version requested from idb. * @returns A promise that resolves to the file data. */ static loadByUrl({ store, url }: FileLoadRequestByUrl): Promise; /** * Retrieves the keys from the specified store. * @param store - The name of the store. * @returns A promise that resolves to the keys. */ static getKeys(store: string): Promise>; /** * Saves a file to the local database. * @param file - The file to be saved. * @returns A promise that resolves to the ID of the saved file. */ static saveFile(fileData: FileSaveRequest): Promise; static saveVideo(videoRequest: VideoSaveRequest): Promise; } /** * Class representing a store in the local database. */ declare class LocalDbStore { name: string; type: `${string}/${string}`; private _keys; private _files; initialized: boolean; /** * Creates an instance of LocalDbStore. * @param props - The properties required to initialize the store. */ constructor(props: LocalDbStoreProps); /** * Loads a file by its ID and version from the store. * @param name - The name of the file. * @param version - The version of the file (default is -1 used for the latest version). Version * is 1 based so 0 is invalid. * @returns A promise that resolves to the file data. */ loadByName(name: string, version?: number): Promise; /** * Loads a file by its URL from the store. * @param url - The URL of the file. * @returns A promise that resolves to the file data. */ loadByUrl(url: string): Promise; getKeyValue(key: string): Promise; /** * Saves a file to the store. * @param key - The file data to be saved. * @param value - The file data to be saved. * @returns A promise indicating whether the save was successful. */ setKeyValue(key: any, value: any): Promise; saveVideo(request: VideoSaveRequest): Promise; /** * Saves a file to the store. * @param fileData - The file data to be saved. * @returns A promise indicating whether the save was successful. */ saveFile(fileData: FileSaveRequest): Promise; /** * Gets a transaction for the store. * @param mode - The mode of the transaction (default is "readonly"). * @returns A promise that resolves to the transaction. */ getTransaction(mode?: "readonly" | "readwrite"): Promise>; /** * Initializes the store by retrieving keys. */ init(): Promise; /** * Retrieves the keys from the store. * @returns A promise that resolves when the keys are retrieved. */ retrieveKeys(): Promise; /** * Gets the keys from the store. * @returns A promise that resolves to the keys. */ getKeys(): Promise>; get keys(): Set; get files(): IDBFile[]; } export {};