/** * @module FileDocuments */ import { Service } from '../../services/service'; import { Bubble, Conversation, RBEvent, User } from '../../models'; import { ConsumptionData } from '../files/fileStorage.service'; import { FileDescriptor } from '../../models/common'; import { Subscription } from 'rxjs'; import { FileDocument, FileDocumentRB, FileDocumentSearchOptions } from '../../models/fileDocument.model'; /** * @internal */ export declare const FILEDOCUMENT_SVC = "FileDocumentService"; /** * @eventProperty * Events fired by the DocumentsService */ export declare enum FileDocumentServiceEvents { /** * @eventProperty * This event is fired when a fileDocument is added in the storage */ ON_FILE_DOCUMENT_UPLOADED = "ON_FILE_DOCUMENT_UPLOADED", /** * @eventProperty * This event is fired when a fileDocument is updated (state change or viewer added/removed) in the storage */ ON_FILE_DOCUMENT_UPDATED = "ON_FILE_DOCUMENT_UPDATED", /** * @eventProperty * This event is fired when a fileDocument is removed from the storage */ ON_FILE_DOCUMENT_REMOVED = "ON_FILE_DOCUMENT_REMOVED", /** * @eventProperty * This event is fired when fileDocument storage consumption is updated */ ON_CONSUMPTION_UPDATED = "ON_CONSUMPTION_UPDATED", /** * @eventProperty * This event is fired when fileDocument storage usage exceeds 90%. */ ON_CONSUMPTION_WARNING = "ON_CONSUMPTION_WARNING", /** * @eventProperty * This event is fired when the content of the document is modified */ ON_FILE_DOCUMENT_CONTENT_MODIFIED = "ON_FILE_DOCUMENT_CONTENT_MODIFIED" } export interface FileDocumentConsumptionData extends ConsumptionData { /** @internal */ option?: any; } export interface FileDocumentService { /** * This property contains the current usage status of your fileDocument storage. */ consumption?: FileDocumentConsumptionData; /** * Subscribe to updates from the service (all events are of RBEvent); * @param handler - The call-back function that will be subscribed to the RxJS subject * @param eventNames - array of event to listen */ subscribe(handler: (event: RBEvent) => any, eventNames?: FileDocumentServiceEvents | FileDocumentServiceEvents[]): Subscription; /** * This factory allows to create Document instance from a JavaScript File * @param file - the JavaScript file to manage * @throws an RBError (ex: RBErrorCode.STORAGE_NOT_ENOUGH_SPACE_AVAILABLE) */ createFileDocument(file: File): Promise; /** * This method allows to replace the document content. * @param document - The file descriptor object. * @param data - the content blob */ replaceFileDocumentContent(document: FileDocument, data: Blob): void; /** * This method allows you to search for fileDocuments in your fileDocument storage. * The main search criterion is by name, but you can also leave this field empty * and use the criteria contained in search options * @param options - Search options */ searchFileDocuments(options?: FileDocumentSearchOptions): Promise; /** * This method retrieves the fileDocuments shared in a conversation. * For obvious performance reasons, it does not return the full list of fileDocuments, but a page of 1000 fileDocuments. * To retrieve the next page, simply call it up again. * @param conversation - the conversation */ getConversationFileDocuments(conversation: Conversation): Promise<{ documents: FileDocument[]; complete: boolean; }>; /** * This method retrieves the fileDocuments shared in a conversation. * For obvious performance reasons, it does not return the full list of fileDocuments, but a page of 1000 fileDocuments. * To retrieve the next page, simply call it up again. * @param conversation - the conversation */ /** * This method will create an archive (zip) will all fileDocuments; Once generated, the zip will be available in the user storage; * ATTENTION: In return you'll get the FileDocument that can be used to download the archive, but it will remain in the user storage; So consider removing it from the storage in order to save space; * ATTENTION2: Each call of this API will generate a new zip that will be storred in the storage of the user. * NB: This process might take a while, up to several minutes (depending on the files size, etc) * @param zipName - the name of the zip [Optional] * @param documents - the list of documents to zip */ createZipFromDocuments(zipName: string, documents: FileDocument[]): Promise; /** * Retrieves a {@link FileDocument} instance from the local cache by its identifier. * * **Legacy compatibility** — This method exists to address legacy behaviours where a * `FileDocument` object could not be obtained through the standard asynchronous APIs * (e.g. {@link searchFileDocuments}, {@link getConversationFileDocuments}). * It performs a **synchronous** lookup against the in-memory document registry and * should therefore only be used when the document is already known to be cached locally. * Prefer the async APIs for any new development. * * @param fileDocumentId - The unique identifier of the file document to retrieve. * @returns The matching {@link FileDocument}, or `undefined` if not found in the local cache. */ getFileDocumentById(fileDocumentId: string): FileDocument; } /** @internal */ export declare class FileDocumentServiceRB extends Service implements FileDocumentService { private logger; private fileStorage; private fileServer; private eventSubject; private subscriptions?; private documents; static getInstance(): FileDocumentServiceRB; static build(): FileDocumentServiceRB; private constructor(); start(): Promise; reconnect(): Promise; stop(): Promise; private attachEventHandler; subscribe(handler: (event: RBEvent) => any, eventNames?: FileDocumentServiceEvents | FileDocumentServiceEvents[]): Subscription; sendEvent(name: FileDocumentServiceEvents, data?: any): void; createFileDocument(file: File): Promise; replaceFileDocumentContent(document: FileDocument, data: Blob): void; createFileDocumentFromExisitingFileDescriptor(fd: FileDescriptor, file: File): Promise; hasEnoughSpace(document: FileDocument): boolean; uploadDocument(document: FileDocument): Promise; downloadDocument(document: FileDocument): Promise; abortDocumentTransfert(document: FileDocument): Promise; copyDocument(document: FileDocument): Promise; deleteDocument(document: FileDocument): Promise; get consumption(): FileDocumentConsumptionData; addDocumentViewer(document: FileDocument, viewer: User | Bubble): Promise; deleteDocumentViewer(document: FileDocument, viewer: User | Bubble): Promise; searchFileDocuments(searchOptions?: FileDocumentSearchOptions): Promise; createZipFromDocuments(zipName: string, documents: FileDocument[]): Promise; getConversationFileDocuments(conversation: Conversation): Promise<{ documents: FileDocument[]; complete: boolean; }>; getLocalUrl(fileDocument: FileDocument): Promise; getPublicUrl(fileDocument: FileDocument): Promise; getTextContent(fileDocument: FileDocument, noCache?: boolean): Promise; getJsonContent(fileDocument: FileDocument): Promise; getFileDescriptorUrl(fd: FileDescriptor): Promise; getFileDocumentById(fileDocumentId: string): FileDocument; createDocumentFromFileDescriptor(fd: FileDescriptor): FileDocumentRB; } //# sourceMappingURL=fileDocument.service.d.ts.map