import { FileDescriptor, FileStorageType } from '../../models/common/fileDescriptor'; import { BubbleRB } from '../../models/bubble.model'; import { FileViewer } from '../../models/common/fileViewer'; import { BehaviorSubject, Subject, Subscription } from "rxjs"; import { FilePublicDownload } from '../../models/common/filePublicDownload'; import { LoggerService } from '../../services/core/logger.service'; import { ContactService } from '../../services/core/contact.service'; import { ErrorHelperService } from '../../services/utilities/errorHelper.service'; import { BubbleConferenceRecap, BubbleConferenceRecapFile } from '../../models/bubbleConferenceRecap.model'; import { Service } from '../../services/service'; import { ConversationRB } from '../../models/conversation.model'; import { MessageID } from '../../models'; export declare const FILE_STORAGE_SVC = "FileStorageService"; export interface GetFilesResultInterface { fileDescriptors: FileDescriptor[]; allReceived: boolean; } /** * The user's quota and the consumption of its storage space. */ export interface ConsumptionData { /** * The current consumption (in bytes). If there is no limit, this data is set to undefined. */ currentValue: number; /** * The quota (in bytes) associated with the offer available to the user. */ maxValue: number; /** * The offer available to the user. */ feature: string; /** * The unit of measurement for consumption and quota information. */ unit: string; /** * Details about the current consumption (in bytes) of its storage space. */ details: { /** * Consumption of files belonging to the user, whether these files are shared or not. */ others: number; /** * Consumption of recording files belonging to the user, whether these files are shared or not. */ recordings: number; }; } export interface TranscriptionData { fileId: string; transcriptionMessage: string; action: string; error: string; } export declare class FileStorageExternalStorage { /** * The external fileserver endpoint */ endPoint: string; /** * Set to true when the temporary token must be renewed, or not exists. */ authenticationNeeded: boolean; /** * Human readable string to identify the external storage */ name: string; /** * Human readable string to identify the external storage */ description: string; /** * Human readable string to identify the external storage */ type: FileStorageType; } export declare enum FileStorageServiceEvents { /** * @event RAINBOW_FILESTORAGE_NEED_POPUP * @description * This RB Event is send when the fileStorageService needs to open a window popup and that user has blocked the popup usage. * This event is gnerally used to display an information message. */ RAINBOW_FILESTORAGE_NEEDS_POPUP = "RAINBOW_FILESTORAGE_NEED_POPUP", ON_FILE_REMOVED_FROM_STORE_EVENT = "ON_FILE_REMOVED_FROM_STORE_EVENT", ON_FILE_DESCRIPTOR_RECEIVED_EVENT = "ON_FILE_DESCRIPTOR_RECEIVED_EVENT", ON_CONSUMPTION_DATA_UPDATED_EVENT = "ON_CONSUMPTION_DATA_UPDATED_EVENT", ON_CONSUMPTION_DATA_WARNING_EVENT = "ON_CONSUMPTION_DATA_WARNING_EVENT", ON_TRANSCRIPTION_CREATED = "ON_TRANSCRIPTION_CREATED", ON_TRANSCRIPTION_SUBMITTED = "ON_TRANSCRIPTION_SUBMITTED", ON_TRANSCRIPTION_ABORTED = "ON_TRANSCRIPTION_ABORTED", ON_ARCHIVE_AVAILABLE = "ON_ARCHIVE_AVAILABLE" } export declare enum FileStorageCapabilities { THUMBNAILS = "THUMBNAILS", SAVE = "SAVE", TRANSFERT = "TRANSFERT" } export declare class FileStorageService extends Service { protected started: boolean; protected listeners: any[]; protected portalURL: string; protected consumptionData: ConsumptionData; protected currentOrder: string; protected voiceMessageFileDescriptors: FileDescriptor[]; protected fileDescriptors: FileDescriptor[]; protected receivedFileDescriptors: FileDescriptor[]; protected mergedFileDescriptors: FileDescriptor[]; protected uploadingFileDescriptors: FileDescriptor[]; protected externalFileDescriptors: FileDescriptor[]; protected contactService: ContactService; protected logger: LoggerService; protected errorHelperService: ErrorHelperService; private eventService; private mainService; private profileService; private xmppManagementHandler; deleteFileWoConfirm: boolean; fileDescriptorsSubject: Subject; uploadingFileDescriptorsSubject: Subject; protected conferenceRecordingFiles: BubbleConferenceRecap[]; private conferenceRecordingFileDescriptors; conferenceRecordingFilesSubject: Subject; sharedWithMeConferenceRecordingFiles: FileDescriptor[]; sharedWithMeConferenceRecordingFilesSubject: Subject; allSentFilesLoaded: boolean; allReceivedFilesLoaded: boolean; private externalStorageFileDescriptors?; private externalStoragePath; externalStorage?: FileStorageExternalStorage; private xmppService; protected publicFileDownload: FilePublicDownload[]; publicFileDownloadSubject: Subject; startedSubject: BehaviorSubject; private retrieveFileDescriptorPromises; private authService; private fileDescriptorsForConversationResult; private searchForFileDescriptorsCache; private allFilesLoaded; private rxSubject; static getInstance(): FileStorageService; static build(): FileStorageService; protected constructor(); start(fileStorageServiceConfig?: any): Promise; stop(): Promise; reinit(): Promise; private attachHandlers; private removeHandlers; /** * @public * @function subscribe * @instance * @description Subscribe to updates from the fileStorageService (all events are of RBEvent type {name: string, data:any}); * @param {any} handler The call-back function that will be subscribed to the RxJS subject * @param {string[]} eventNames (optional) array of event to listen * @returns {Subscription} Returns RxJS Subscription */ subscribe(handler: any, eventNames?: string | string[]): Subscription; sendEvent(name: FileStorageServiceEvents, data?: any): void; getLatestFilesFromServer(): Promise; private retrieveFilesAtStartUp; removeRoomFileViewer(room: BubbleRB): void; /** * Method request for the list of files received by a user from a given peer (i.e. inside a given conversation) * @param {string} peerId [optional] dbId of contact in the P2P conversation * @param {string} roomId [required] dbId of the room * @returns {Promise} : list of received files descriptors * @memberof FileStorageService */ private retrieveFilesInConversation; /** * Method used to search for files from the cached files based on different criteria * @param {string} fileSet [optional] fileSet, could be "all", "mine", "received"; By default it's all * @param {string} fileName [optional] to search by filename * @param {string} typeMIME [optional] to filter by typeMIME (values allowd: image, audio-video, pdf, presentation, document, spreadsheet) * @param {string} sortField [optional] sortField, could be fileName, uploadedDate or size; By default it's uploadedDate * @param {number} sortOrder [optional] sortOrder, could be 1 (normal order) or -1 (reverse order); By default, it's -1 * @returns {Promise} Object containing the { fileDescriptors: FileDescriptor[], limit: number, offset: number } * @memberof FileStorageService */ private searchForFilesInCache; getFileDescriptorById(id: string): FileDescriptor; removeFileDescriptorById(id: string): any; /** * Method retrieve the data usage of a given user * @returns {Promise} : object data with the following properties: * - feature {String} : The feature key belonging to the user's profile * - maxValue {number} : The quota associated to this offer [octet] * - currentValue {number} : The user's current consumption [octet] * - unit {String} : The unit of this counters */ retrieveUserConsumption(): Promise; /** * Method request to get the files shared in a given bubble. * @param bubbleId -Id of the room * @returns list of received files descriptors */ retrieveReceivedFilesForNewRoom(bubbleId: string): Promise; /** * Method to load more files inside a given conversation (shared or received) * @param {ConversationRB} conversation the conversation where we want to get the latest 1000 files * @returns {Promise} : object {fileDescriptors:FileDescriptor[], allReceived:boolean } * list of files descriptors; And allReceived flag to indicate if we can "load" more files for the same conversation * @memberof FileStorageService */ loadMoreDescriptorsForConversation(conversation: ConversationRB): Promise; /** * Method get the list of files inside a given conversation (shared or received) Limited to the first 1000 files; * If you need more files, you should use the loadMoreDescriptorsForConversation API; * @param {ConversationRB} conversation the conversation where we want to get the latest 1000 files * @returns {Promise} : object {fileDescriptors:FileDescriptor[], allReceived:boolean } * list of received files descriptors, limited to 1000 files; And allReceived flag to indicate if we can "load" more files for the same conversation * @memberof FileStorageService */ getFileDescriptorsInConversation(conversation: ConversationRB): Promise; /** * Method used to search for files on the server based on different criteria * @param {string} fileSet [optional] fileSet, could be "all", "mine", "received"; By default it's all * @param {string} fileName [optional] to search by filename * @param {string} typeMIME [optional] to filter by typeMIME (values allowd: image, audio-video, pdf, presentation, document, spreadsheet) * @param {string} sortField [optional] sortField, could be fileName, uploadedDate or size; By default it's uploadedDate * @param {number} sortOrder [optional] sortOrder, could be 1 (normal order) or -1 (reverse order); By default, it's -1 * @param {number} offset offset, in case of paginated result * @returns {Promise} Object containing the { fileDescriptors: FileDescriptor[], limit: number, offset: number } * @memberof FileStorageService */ searchForFilesOnServer(fileSet?: string, fileName?: string, typeMIME?: string, sortField?: string, sortOrder?: number, offset?: number, force?: boolean, onlyInternal?: boolean): Promise; /** * Method used to search for files on the server based on different criteria * @param {string} fileSet [optional] fileSet, could be "all", "mine", "received"; By default it's all * @returns {GetFilesResultInterface} Object containing the { fileDescriptors: FileDescriptor[], allReceived: boolean } * @memberof FileStorageService */ getConsumptionData(): ConsumptionData; getVoiceMessageFileDescriptorByMsgId(msgId: string): FileDescriptor; /** * Method requests server to create a file descriptor this will be saved to local file descriptor list (i.e. this.fileDescriptors) * @param {File} file [required] file for which file descriptor has to be created * @param {FileViewer[]} viewers [required] list of viewers having access to the file (a viewer could be either be a user or a room) * @returns {Promise} file descriptor created by server or error * @memberof FileStorageService */ createFileDescriptor(file: File, viewers?: FileViewer[], voiceMessageData?: any, ccarelogs?: boolean, ccareclientlogs?: boolean): Promise; private createFileDescriptorInternal; private createFileDescriptorFromData; /** * Method to delete a given File Descriptor from the server. Only usable for the FD owned by the user; * @param {string} id [required] fthe File Descriptor id to be deleted from the server * @returns {Promise} Resovle once done * @memberof FileStorageService */ deleteFileDescriptor(id: string): Promise; private deleteAllFilesDescriptorsFromCache; /** * Method to delete all File Descriptor that belong to the user from the server. * @returns {Promise} Resolve once done * @memberof FileStorageService */ deleteAllFileDescriptor(): Promise; /** * Method retrieve full list of files belonging to user making the request * @returns {Promise} return * @memberof FileStorageService */ retrieveVoiceMessageFileDescriptorsListPerOwner(): Promise; /** * Method deletes a viewer from the list of viewer of a given file * @param {string} viewerId [required] Identifier of viewer to be removed. Could be either a user or a room * @param {string} fileId [required] Identifier of the fileDescriptor from which the viewer will be removed * @returns {Promise} return * @memberof FileStorageService */ deleteFileViewer(viewerId: string, fileId: string): Promise; /** * Method adds a viewer to a given file on server if it is not already one * @param {string} fileId [required] Identifier of file * @param {string} viewerId [required] Identifier of viewer to be added * @param {string} type [required] type of viewer to be added (user or room) * @returns {Promise} file descriptor with newly added viewer * @memberof FileStorageService */ addFileViewer(fileId: string, viewerId: string, type: string): Promise; /** * This method is used to copy the file to user personal storage * @param {string} fileId [required] Identifier of file descriptor to copy * @returns {Promise} file descriptor retrieved * @memberof FileStorageService */ copyFileToUserCloudStorage(fileId: string): Promise; /** * Method retrieve a specific file descriptor from server * @param {string} fileId [required] Identifier of file descriptor to retrieve * @returns {Promise} file descriptor retrieved * @memberof FileStorageService */ retrieveOneFileDescriptor(fileId: string): Promise; /** * Method retrieve a specific file descriptor from server and stores it in local fileDescriptors (replace existing and add if new) * @param {string} fileId [required] Identifier of file descriptor to retrieve * @returns {Promise} file descriptor retrieved or null if none found * @memberof FileStorageService */ retrieveAndStoreOneFileDescriptor(fileId: string, forceRetrieve?: boolean): Promise; /**********************************************************/ /** Utilities */ /**********************************************************/ deleteFileDescriptorFromCache(id: string): void; extractFileIdFromUrl(url: string): string; retrieveAndStoreOneVoiceMessageFileDescriptor(fileId: string): void; deleteVoiceMessageFileDescriptor(fileId: any): void; updateAFileDescriptorLocally(fileDesc: FileDescriptor): void; removeRecordFromRecordingFile(deletedFileId: string, recordingFileId: string): void; getPublicFileDownloads(): FilePublicDownload[]; clearPublicFileDownloads(): void; findPublicFileDownload(fileUrl: string): FilePublicDownload; updatePublicFileDownloadArray(filesPublicDownload: [], fileSystem: any): void; getUploadingFilesSize(): number; removeUploadingFileFromId(fileId: string): void; removeUploadingFileDescriptor(fileDesc: FileDescriptor): void; isEnoughAvailableSpaceForFiles(filesToSend: any[]): boolean; isEnoughAvailableSpaceForFileDescriptor(fileId: string, fileViewers: any): boolean; stopAllFileTransfer(): void; getMimeInfo(mimeType: string): any; removePublicFileDownload(file: FilePublicDownload): void; getRecordingFileAvatar(recordingFileId: string): Promise; getRecordingFiles(): BubbleConferenceRecap[]; getRecordingFilesFromServer(): Promise; refreshConferenceRecapFromServcer(recap: BubbleConferenceRecap): Promise; getSharedWithMeConferenceRecordingFiles(): FileDescriptor[]; getConferenceRecordingFileById(fileId: string): FileDescriptor; getSharedWithMeConferenceRecordingFilesFromServer(): Promise; deleteConferenceRecordingFile(conferenceRecordingFileId: string): Promise; /** * * For a meeting a transcription may be wanted beside or not a meeting recording. For green washing need or other needs, the meeting organiser car choose whether the transcription is permanent or ephemeral. When ephemeral, the transcription is available during 15 days. * The aim of this API is to change the status of the recording via the boolean isEphemeral false : A meeting record and eventually its transcription and its summary are always available until the recording is deleted. true : After 15 days after the end of the conference, the meeting record is deleted. That is to say only the transcription and the summary will remain. The date timeToLiveDate is taken in account to schedule a cleaning task. */ changeConferenceRecapEphemeral(conferenceRecordingFile: BubbleConferenceRecap, isEphemeral: boolean): Promise; getConferenceRecordingAssociatedFiles(conferenceRecordingFile: BubbleConferenceRecap): Promise; authenticateExternalStorage(): Promise; logoutExternalStorage(): Promise; /** * @function searchForFilesOnExternalStorage * @description Method used to search for files on the external storage server based on different criteria * Note that this method only returns my own files * @param {string} path define the directory to search from * @returns {Promise} Object containing the { fileDescriptors: FileDescriptor[], limit: number, offset: number } * @memberof FileStorageService */ searchForFilesOnExternalStorage(path?: string, sortedBy?: string, sortDirection?: string, filterBy?: string, filterValue?: string, force?: boolean): Promise; shareExternalStorageFiles(path: string, basename: string, fileId: string, viewerId: string, type: string): Promise; createExternalStorageSharingSpace(bubble: BubbleRB): Promise; getExternalStorageSharingSpaceUrl(bubble: BubbleRB): Promise; createZipFromFiles(archiveName: string, files?: FileDescriptor[] | BubbleConferenceRecapFile[]): Promise; getAudioFileTranscription(messageFileId: string, messageId?: MessageID, conversation?: ConversationRB): Promise; addViewerToConferenceRecording(recap: BubbleConferenceRecap, dbId: string, type: string): Promise; removeViewerToConferenceRecording(recap: BubbleConferenceRecap, dbId: string): Promise; /** * This method is used to translate the file * @param {string} fileId [required] Identifier of file descriptor to translate * @param {string} lang [required] translation language * @returns {Promise} file descriptor retrieved * @memberof FileStorageService */ translateFile(fileId: string, lang: string): Promise; /** * Management of XMPP management message * @param stanza - The received stanza. */ private onManagementMessageReceived; } //# sourceMappingURL=fileStorage.service.d.ts.map