UNPKG

cv-dialog-sdk

Version:

Catavolt Dialog Javascript API

207 lines (206 loc) 6.55 kB
import { ClientListener } from "../client/ClientListener"; import { StreamConsumer } from '../io/StreamConsumer'; import { StreamProducer } from '../io/StreamProducer'; import { ClientType, Dialog, DialogRedirection, PropertyFormatter, Redirection, Session, WorkbenchAction } from '../models'; import { LargeProperty } from '../models/LargeProperty'; import { CvLocale } from '../util/CvLocale'; import { CatavoltApi } from './CatavoltApi'; import { DialogApi } from './DialogApi'; /** * Top-level entry point into the Catavolt API */ export declare class CatavoltApiImpl implements CatavoltApi { private static _singleton; private static ONE_HOUR_IN_MILLIS; private static CHECK_SESSION_INTERVAL_MILLIS; private static SERVER_URL; private static SERVER_VERSION; readonly DEFAULT_LOCALE: CvLocale; dataLastChangedTime: Date; private _dialogApi; private _session; private _devicePropsDynamic; private _devicePropsStatic; private _locale; private _sessionTimer; private _onSessionExpiration; /** * Get the default session time * @returns {number} */ static readonly defaultTTLInMillis: number; /** * Get the singleton instance of the CatavoltApiImpl * @returns {CatavoltApiImpl} */ static readonly singleton: CatavoltApiImpl; /** * Construct an CatavoltApiImpl * This should not be called directly, instead use the 'singleton' method * @private */ private constructor(); /** * Add or replace a dynamic device property (func) * @param propName * @param propFn */ addDynamicDeviceProp(propName: string, propFn: () => string): void; /** * Add or replace a static device property * * @param propName * @param propValue */ addStaticDeviceProp(propName: string, propValue: string): void; /** * * @param {ClientListener} clientListener */ addClientListener(clientListener: ClientListener): void; /** * Get the preferred locale * @returns {CvLocale} */ locale: CvLocale; changePasswordAndLogin(tenantId: string, clientType: ClientType, userId: string, existingPassword: string, newPassword: string): Promise<Session | Redirection>; /** * Get the number of millis that the client will remain active between calls * to the server. * @returns {number} */ readonly clientTimeoutMillis: number; /** * Get the currency symbol override if defined from the server. * @returns {string} */ readonly currencySymbol: string; /** * Get the device props * @returns {{[p: string]: string}} */ readonly deviceProps: { [index: string]: string; }; /** * Get the DialogApi instance * @returns {DialogApi} */ readonly dialogApi: DialogApi; /** * Initialize a dialog service implementation for use by this CatavoltApiImpl * * @param serverVersion * @param serverUrl */ initDialogApi(serverUrl: string, serverVersion?: string): void; /** * Check for the availability of the given featureSet * @see FeatureSet * @param featureSet * @returns {boolean} */ isFeatureSetAvailable(featureSet: FeatureSet): boolean; /** * Checked logged in status * @returns {boolean} */ readonly isLoggedIn: boolean; /** * Check offline status * * @param tenantId */ isAnyUserInBriefcaseMode(tenantId: string): Promise<boolean>; /** * Check offline status * * @param userInfo * @returns {Promise<boolean>} */ isUserInBriefcaseMode(userInfo: {}): Promise<boolean>; /** * Log in and retrieve the Session * * @param tenantId * @param clientType * @param userId * @param password * * @returns {Promise<Session | Redirection>} */ login(tenantId: string, clientType: ClientType, userId: string, password: string): Promise<Session | Redirection>; loginWithToken(tenantId: string, clientType: ClientType, permissionToken: string, proofKey: string): Promise<Session | Redirection>; /** * Logout and destroy the session * @returns {{sessionId:string}} */ logout(): Promise<{ sessionId: string; }>; openDialogWithId(dialogId: string): Promise<Dialog>; openDialog(redirection: DialogRedirection): Promise<Dialog>; /** * Not yet implemented * @param {string} url * @returns {Promise<StreamProducer>} */ openStream(url: string): Promise<StreamProducer>; toDialogOrRedirection(resultPr: Promise<{}>): Promise<Dialog | Redirection>; getRedirection(redirectionId: string): Promise<Redirection>; /** * Open a {@link WorkbenchAction} * @param workbenchAction * @returns {Promise<{actionId:string} | Redirection>} */ performWorkbenchAction(workbenchAction: WorkbenchAction): Promise<Redirection>; /** * Open a {@link WorkbenchWorkbenchAction} * @param workbenchId * @param workbenchActionId * @returns {Promise<{actionId:string} | Redirection>} */ performWorkbenchActionForId(workbenchId: string, workbenchActionId: string): Promise<Redirection>; /** * Refresh the CatavoltApiImpl * * @returns {Promise<Session>} */ refreshSession(tenantId: string, sessionId: string): Promise<Session>; /** * Time remaining before this session is expired by the server * @returns {number} */ readonly remainingSessionTime: number; /** * * @param {ClientListener} clientListener */ removeClientListener(clientListener: ClientListener): void; /** * Get the Session * @returns {Session} */ readonly session: Session; /** * Return whether or not the session has expired * @returns {boolean} */ readonly sessionHasExpired: boolean; /** * Function that will be notified when the session expires * @param {() => void} onSessionExpiration */ onSessionExpiration: () => void; /** * * @param {string} contentId * @param {StreamConsumer} streamConsumer * @returns {Promise<LargeProperty>} */ streamContent(contentId: string, streamConsumer: StreamConsumer): Promise<LargeProperty>; private processLogin; } export declare type FeatureSet = 'View_Support' | 'Unified_Search'; export declare const Catavolt: CatavoltApi; export declare const propertyFormatter: PropertyFormatter;