/* Copyright (c), CKSource Holding sp. z o.o. All rights reserved. */ import type { IRevisionHistoryConnectDetails } from './descriptors/connectdetailsdescriptor'; import { type IWebSocketGateway } from '../websocketgateway/websocketgateway'; import type { IRevisionObject } from './revision'; export declare const _SERVICE: number; interface IRevisionHistoryConnectResponse { revisions: IRevisionObject[]; requestId: number; } export interface IRevisionHistoryConnectWithDetailsResult extends IRevisionHistoryConnectResponse { /** * The last revision of `revisions`, with its `diffData`, when {@link IRevisionHistoryConnectDetails#includeLatestRevision} * was requested. It is missing when there are no revisions or when the server does not support the request. * Get it with `getRevision()` then. */ latestRevision?: IRevisionObject; /** * The users of the `creatorId` and `authorsIds` of all `revisions`, when * {@link IRevisionHistoryConnectDetails#includeUsers} was requested. It is missing when the server does not support * the request. Fetch the users with `User.getMany()` then. When the server cannot fetch the users, the connect fails. */ users?: Record[]; } declare const RevisionHistoryService_base: import("@ckeditor/ckeditor5-utils").EmitterMixinConstructor object>; declare class RevisionHistoryService extends /* #__PURE__ -- @preserve */ RevisionHistoryService_base { private readonly _documentId; private _isConnected; private _wsGateway?; private _channel?; private static readonly _SERVICE; constructor(_documentId: string); get isConnected(): boolean; /** * Connects RevisionHistoryService to CKEditor Cloud Services. * * @throws {@link CKEditorCloudServicesError} error * Thrown in the case of errors on the backend side. */ connect(wsGateway: IWebSocketGateway): Promise; /** * Connects as {@link #connect} does, and also resolves with the requested details. * * @throws {@link CKEditorCloudServicesError} error * Thrown in the case of errors on the backend side. */ connectWithDetails(wsGateway: IWebSocketGateway, details: IRevisionHistoryConnectDetails): Promise; /** * Disconnects RevisionHistoryService from CKEditor Cloud Services. * * @throws {@link CKEditorCloudServicesError} * Thrown in the case of errors on the backend side. */ disconnect(): void; /** * Reconnects RevisionHistoryService to CKEditor Cloud Services. * * @throws {@link CKEditorCloudServicesError} * Thrown when connection already exists or in the case of errors on the backend side. */ reconnect(wsGateway: IWebSocketGateway, lastRequestId: number): Promise; /** * Updates revisions. * * @throws {@link CKEditorCloudServicesError} * Thrown in the case of errors on the backend side. */ updateRevisions(revisions: IRevisionObject[], lastRequestId: number): Promise; /** * Returns revision with given id. * * @throws {@link CKEditorCloudServicesError} * Thrown in the case of errors on the backend side. */ getRevision(revisionId: string): Promise; /** * Returns the latest revision of the document, with its `diffData`, or `undefined` when the document has no revisions. * * The service does not have to be connected, so the editor can build the initial data before it connects anything. * * @throws {@link CKEditorCloudServicesError} * Thrown when the WebSocket Gateway is not connected, or in the case of errors on the backend side. */ getLatestRevision(wsGateway: IWebSocketGateway): Promise; /** * Connects or reconnects to WebSocketGateway and starts listening on channel. */ private _connect; /** * Starts to listen on a given channel. */ private _connectToChannel; /** * Processes websocket gateway state changes. */ private _onWsGatewayStateChange; /** * Sends request to RevisionHistory service. * * @throws {@link ServiceNotConnectedError} * Thrown in the case of missing service connection. */ private _sendRequest; } export default RevisionHistoryService;