@mescius/dspdfviewer
Version:
Document Solutions PDF Viewer
135 lines (134 loc) • 6.44 kB
TypeScript
import { UserAccess, SharedAccessMode, SharedDocumentInfo, ModificationType, ModificationsState } from "../SharedDocuments/types";
import { AnnotationBase } from "../Annotations/AnnotationTypes";
import { ClientRequestType, ClientMessage, ClientMessageType } from "./Connection/ClientMessage";
import { ServerMessage, StartSharedModeResponse } from "./Connection/ServerMessage";
import { ProgressDialogSink } from "../Dialogs/Types";
import { OpenDocumentInfo } from "./types";
import { ISupportApiBase } from "./ISupportApiBase";
/**
* Represents the interface for the SupportApi, extending the base SupportApi functionality.
*/
export interface ISupportApi extends ISupportApiBase {
/**
* Represents the status of the SupportApi connection.
* Possible values: 'opening', 'opening-shared', 'opened-shared', 'opened', 'closed'.
*/
status: 'opening' | 'opening-shared' | 'opened-shared' | 'opened' | 'closed';
/**
* Indicates whether the viewer has a persistent connection to the server.
* Returns false or is undefined when multi-user support is not enabled.
* @type {boolean | undefined}
*/
hasPersistentConnection?: boolean;
/**
* Current user access mode. Applicable only when the document is opened in shared mode.
*/
sharedAccessMode: SharedAccessMode;
/**
* List of users who have access to the current document. Applicable only when the document is opened in shared mode.
*/
userAccessList: UserAccess[];
/**
* Returns a list of all available users.
* @returns A Promise that resolves to an array of user names.
*/
listAllUsers(): Promise<string[]>;
/**
* Load the updated list of users who have access to the current document. Applicable only if the document is opened in shared mode.
* @returns A Promise that resolves to an array of UserAccess objects.
*/
listUsersWithAccess(): Promise<UserAccess[]>;
/**
* Returns a list of all documents shared with the current user.
* @returns A Promise that resolves to an array of SharedDocumentInfo objects.
*/
listSharedDocuments(): Promise<SharedDocumentInfo[]>;
/**
* Modify a shared document. Applicable only if the document is opened in shared mode.
* @param type The type of modification.
* @param data The data for the modification.
*/
modifySharedDocument(type: ModificationType, data?: {
pageIndex: number;
annotation: AnnotationBase;
} | {
pageIndex: number;
annotationId: string;
} | {
resultStructure: number[];
structureChanges: {
pageIndex: number;
add: boolean;
checkNumPages: number;
}[];
pdfInfo: {
numPages: number;
fingerprint: string;
};
}): void;
/**
* Open a shared document on the server.
* @param documentId The ID of the document to open.
* @returns A Promise that resolves to the OpenDocumentInfo of the opened document.
*/
openSharedDocument(documentId: string): Promise<OpenDocumentInfo>;
/**
* Allow access to an active document for the user specified by the userName argument.
* @param userName The name of the user to share the document with.
* @param accessMode The access mode for the user.
* @param modificationsState The modifications state for the user.
* @param startSharedMode Flag indicating whether to start shared mode after sharing the document.
* @returns A Promise that resolves to the OpenDocumentInfo of the shared document.
*/
shareDocument(userName: string, accessMode: SharedAccessMode, modificationsState: ModificationsState, startSharedMode: boolean): Promise<OpenDocumentInfo | null>;
/**
* Start shared mode for the currently opened document.
* This method should be called after the openSharedDocument method and after the document is open by the viewer.
* @returns A Promise that resolves to a StartSharedModeResponse.
*/
startSharedMode(): Promise<StartSharedModeResponse>;
/**
* Stop shared mode for the currently opened document.
* @returns A Promise that resolves when shared mode is stopped.
*/
stopSharedMode(): Promise<void>;
/**
* Called when a new server message is received, except for request response messages, which are processed by the caller.
* @param message The received server message.
*/
onPushMessage(message: ServerMessage): void;
/**
* Disallow access to an active document for the user specified by the userName argument.
* @param userName The name of the user to unshare the document with.
* @returns A Promise that resolves when the document is successfully unshared.
*/
unshareDocument(userName: string): Promise<void>;
/**
* Send a message to the server over a persistent connection without waiting for an answer.
* @param type The type of the message.
* @param messageData The data for the message.
*/
sendMessage(type: ClientMessageType, messageData: Partial<ClientMessage>): void;
/**
* Send a request message to the server over a persistent connection and return a promise that is resolved by the server's response.
* @param type The type of the request.
* @param messageData The data for the request.
* @returns A Promise that resolves to the server's response.
*/
sendRequest<T>(type: ClientRequestType, messageData: Partial<ClientMessage>): Promise<T>;
/**
* Download modified files from shared storage.
* @param fileIds File identifiers to download.
* @param sink Progress sink for tracking the download progress.
* @returns A Promise that resolves to a boolean indicating the success of the download.
*/
downloadFiles(fileIds: string[], sink?: ProgressDialogSink): Promise<boolean>;
/**
* Get the stamp image URL.
* @param categoryId The ID of the stamp category.
* @param imageName The name of the stamp image.
* @param enableCache Flag indicating whether to enable caching for the stamp image.
* @returns The URL for the stamp image.
*/
getStampImageUrl(categoryId: string, imageName: string, enableCache: boolean): string;
}