import { ConnectionOptions, Consumer, ConsumerConfig, JetStreamOptions, NatsError, PublishOptions, Subscription, SubscriptionOptions } from 'nats.ws'; import { DownloadTapSettingsRequest } from './requestDTOs'; import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition } from './DTOs'; interface BaseClientRequestOptions { publishOptions?: PublishOptions; rawResponse?: boolean; fullSubject?: boolean; timeout?: number; headers?: { [key: string]: string; }; } export declare class BaseClient { readonly baseSubject: string; private connection; private connectionOptions; private domainAccess; private eventEmitter; private _accessToken; private _headers; private _timeout; /** Get request access token */ get accessToken(): string; /** Set request access token */ set accessToken(value: string); /** Get request headers */ get headers(): { [key: string]: string; }; /** Set request headers */ set headers(value: { [key: string]: string; }); /** Get timeout */ get timeout(): number; /** Set timeout in milliseconds. Default is 40000 milliseconds */ set timeout(value: number); constructor(baseSubject: string, options: ConnectionOptions); private withTimeout; /** * Send a request to the nats server. * @param subject The subject to request * @param payload (optional) * @param options (optional) * @returns Promise of an object */ protected request(subject: string, payload?: any, options?: BaseClientRequestOptions): Promise; /** * Handle the error * @param error * @param subject * @returns */ protected natsErrorHandler(error: NatsError, subject: string): ErrorResponse; /** * Build the headers' object. * @returns {MsgHdrs} Header object */ private buildHeaders; /** * Subscribes to given subject. * @param subject The subject to subscribe * @param options Subscription options * @returns Subscription object */ subscribe(subject: string, options?: SubscriptionOptions & { fullSubject?: boolean; }): Subscription; /** * Subscribes to given subject. * @param subject The subject to subscribe * @param jetStreamOptions Subscription options * @returns Subscription object */ protected createJetStreamConsumer(stream: string, subject: string, jetStreamOptions?: Partial, consumerOptions?: Partial): Promise; protected encode(payload: any): Uint8Array; /** * Create a connection to the nats server. * @param {ConnectionOptions} options */ connect(): Promise; /** * Close the connection. */ close(): Promise; /** * Add a domain specific access token to the dictionary. * @param {string} domain * @param {string} accessToken */ addDomainAccessToken(domain: string, accessToken: string): void; /** * Generic error callback function. * @returns */ protected error(): ((reason: any) => PromiseLike) | null | undefined; /** * Generic success callback function. * @returns */ protected success(): ((value: T) => T | PromiseLike) | null | undefined; /** * Add an error-event listener. * @param listener * @returns {EventEmitter} */ addErrorEventListener(listener: (...args: any[]) => void): void; /** * Remove an error-event listener. * @param listener */ removeErrorEventListener(listener: (...args: any[]) => void): void; /** * Retrieve component settings overview * @returns {{Promise}} */ getComponentSettingsOverview(): Promise; /** * Change componentsettings * @param groupName * @param name * @param returnedSettings * @returns {{Promise}} */ setComponentSettings(groupName: string, name: string, returnedSettings: ComponentSettingsBase): Promise; /** * Retrieve componentsettings * @param groupName * @param name * @returns {{Promise}} */ getComponentSettings(groupName: string, name: string): Promise; /** * Retrieve componentsettings list item * @param groupName * @param name * @param index * @returns {{Promise}} */ getComponentSettingsListItem(groupName: string, name: string, index: number): Promise; /** * Set componentsettings list item settings * @param {string} groupName * @param {string} name * @param {number} index * @param {ComponentSettingsListItem} item * @returns {Promise} */ setComponentSettingsListItem(groupName: string, name: string, index: number, item: ComponentSettingsListItem): Promise; /** * Get component setting data grid * @param {string} groupName * @param {string} name * @param {number} index * @param {string} propertyName * @returns {Promise} */ getComponentSettingDataGrid(groupName: string, name: string, index: number, propertyName: string): Promise; /** * Set component setting data grid * @param {string} groupName * @param {string} name * @param {number} index * @param {string} propertyName * @param {DataGridControl} dataGridControl * @returns {{Promise}} */ setComponentSettingDataGrid(groupName: string, name: string, index: number, propertyName: string, dataGridControl: DataGridControl): Promise; /** * Add component setting item type to data grid * @param {string} groupName * @param {string} name * @param {number} index * @param {string} propertyName * @param {string} typeName * @returns {Promise} */ addComponentSettingDataGridItemType(groupName: string, name: string, index: number, propertyName: string, typeName: string): Promise; /** * Add component setting item to data grid * @param {string} groupName * @param {string} name * @param {number} index * @param {string} propertyName * @returns {Promise} */ addComponentSettingDataGridItem(groupName: string, name: string, index: number, propertyName: string): Promise; /** * Get item types available in the component setting data grid * @param groupName * @param name * @param index * @param propertyName * @returns {Promise} */ getComponentSettingDataGridTypes(groupName: string, name: string, index: number, propertyName: string): Promise; /** * Change componentsettings profiles * @param {ProfileGroup[]} returnedSettings * @returns {Promise} */ setComponentSettingsProfiles(returnedSettings: ProfileGroup[]): Promise; /** * Get componentsettings profiles * @returns {Promise} */ getComponentSettingsProfiles(): Promise; /** * Upload exported OpenTAP Settings files * @param {FileParameter} file * @returns {Promise} */ uploadComponentSettings(file: FileParameter): Promise; /** * Downloads a .TapSettings file containing the settings for a given component settings group * @param {DownloadTapSettingsRequest} tapSettingsRequest The download request specifying the component settings group to download * @returns {Promise} A byte array containing the downloaded .TapSettings file */ downloadComponentSettings(tapSettingsRequest: DownloadTapSettingsRequest): Promise; /** * Load a component settings TapPackage by referencing a package in a package repository * @param {RepositoryPackageReference} packageReference * @returns {Promise} */ loadComponentSettingsFromRepository(packageReference: RepositoryPackageReference): Promise; /** * Save a TapPackage containing component settings in a package repository * @param {RepositorySettingsPackageDefinition} repositoryPackageDefinition * @returns {Promise} */ saveComponentSettingsToRepository(repositoryPackageDefinition: RepositorySettingsPackageDefinition): Promise; /** * Retrieve types available to be added to specified component settings list * @param {string} groupName * @param {string} name * @returns {Promise} */ getComponentSettingsListAvailableTypes(groupName: string, name: string): Promise; /** * Adds a new item to a component settings list * @param {string} groupName * @param {string} name * @param {string} typeName * @returns {Promise} */ addComponentSettingsListItem(groupName: string, name: string, typeName: string): Promise; /** * Get settings package files * @returns {Promise} */ getSettingsPackageFiles(): Promise; /** * Get settings package types * @returns {Promise} */ settingsPackageTypes(): Promise; /** * Dispatches a request with the given subject and returns a Promise of type T * @param subject The subject to send the request to * @returns Promise The response from the request */ dispatchRequest(subject: string, payload?: any, options?: BaseClientRequestOptions): Promise; } export {};