npaw-plugin-nwf
Version:
NPAW's Plugin
129 lines (128 loc) • 3.66 kB
TypeScript
import CoreOptions from './CoreOptions';
import BrowserStorage from './storage/BrowserStorage';
import CoreStorage from './storage/CoreStorage';
import NpawPluginOptions from './NpawPluginOptions';
export default class FastDataService {
private options;
private npawPluginOptions?;
private readonly accountCode;
private coreStorage;
private browserStorage;
private response;
private _session;
private _fastDataHost;
private _refreshInterval?;
private _retryTimeout?;
private activeXHRs;
private pingTime?;
private beatTime?;
/**
* Session expire time in seconds
*/
private sessionExpire;
/**
* View timeout in seconds
*/
private viewTimeout;
private retries;
private readonly MAX_RETRIES;
private isUsingLegacy;
/**
* This class manages Fastdata service and view index.
*
* @constructs
*
* @param {CoreOptions} options Options from the Core
* @param {CoreStorage} coreStorage Core storage object
*/
constructor(options: CoreOptions, accountCode: string, coreStorage: CoreStorage, browserStorage: BrowserStorage, npawPluginOptions?: NpawPluginOptions);
/**
* Starts the 'FastData' fetching. This will send the initial request to NPAW in order to get
* the needed info for the rest of the requests.
*
* This is an asynchronous process.
*
* When the fetch is complete, {@link #fastDataConfig} will contain the parsed info.
* @see FastDataConfig
*/
init(): void;
updateOptions(options: object): void;
/**
* @returns Session expire time in seconds
*/
getSessionExpireTime(): number;
refreshSessionToken(): void;
/**
* Load configuration from backend
*/
loadConfiguration(): void;
/**
* Returns the current session
*
* @returns Session
*/
getSession(): string;
/**
* Sets the session
*
* @param sessionId Sets the session
*/
setSession(session: string): void;
/** Sets the host url
*
* @param host Sets the host
*/
setHost(host: string): void;
getPingTime(): number | undefined;
getBeatTime(): number | undefined;
/**
* Returns view timeout in seconds from fast data (vt parameter)
* @returns View timeout in seconds, defaults to 120
*/
getViewTimeoutTime(): number;
/**
* Returns balancer enabled flag from fast data (cb parameter)
* @returns true if cb=1, false if cb=0, undefined if not set by backend
*/
isBalancerEnabledByFastData(): boolean | undefined;
/**
* Uses given response to set fastdata response.
*
* @param {String} response Fastdata response as json string.
*/
setData(response: string): void;
/**
*
* @param response Fastdata response as json string
*/
setConfiguration(response: string): void;
getFastDataResponse(): any;
getAccountCode(): string;
getRequestNumber(): number;
/**
* Resets the data stored on the browser
* @private
*/
private reset;
private performRequestToFastData;
/**
* Create Configuration Interval
* @private
*/
private _createConfigurationInterval;
private _recreateConfigurationInterval;
/**
* Parse the response from the fastData service.
*
*/
private _receiveData;
private _receiveConfiguration;
private _failedData;
/**
* Retry only the /data request without re-fetching configuration
* @private
*/
private _retryDataRequest;
private _failedConfiguration;
destroy(): void;
}