@opentap/runner-client
Version:
This is the web client for the OpenTAP Runner.
262 lines (261 loc) • 10.1 kB
TypeScript
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;
}
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<T>(subject: string, payload?: any, options?: BaseClientRequestOptions): Promise<T>;
/**
* 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
*/
protected 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<JetStreamOptions>, consumerOptions?: Partial<ConsumerConfig>): Promise<Consumer>;
protected encode(payload: any): Uint8Array;
/**
* Create a connection to the nats server.
* @param {ConnectionOptions} options
*/
connect(): Promise<void>;
/**
* Close the connection.
*/
close(): Promise<void>;
/**
* 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<never>) | null | undefined;
/**
* Generic success callback function.
* @returns
*/
protected success<T>(): ((value: T) => T | PromiseLike<T>) | 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<ComponentSettingsIdentifier[]>}}
*/
getComponentSettingsOverview(): Promise<ComponentSettingsIdentifier[]>;
/**
* Change componentsettings
* @param groupName
* @param name
* @param returnedSettings
* @returns {{Promise<ComponentSettingsBase>}}
*/
setComponentSettings(groupName: string, name: string, returnedSettings: ComponentSettingsBase): Promise<ComponentSettingsBase>;
/**
* Retrieve componentsettings
* @param groupName
* @param name
* @returns {{Promise<ComponentSettingsBase>}}
*/
getComponentSettings(groupName: string, name: string): Promise<ComponentSettingsBase>;
/**
* Retrieve componentsettings list item
* @param groupName
* @param name
* @param index
* @returns {{Promise<ComponentSettingsListItem>}}
*/
getComponentSettingsListItem(groupName: string, name: string, index: number): Promise<ComponentSettingsListItem>;
/**
* Set componentsettings list item settings
* @param {string} groupName
* @param {string} name
* @param {number} index
* @param {ComponentSettingsListItem} item
* @returns {Promise<ComponentSettingsListItem>}
*/
setComponentSettingsListItem(groupName: string, name: string, index: number, item: ComponentSettingsListItem): Promise<ComponentSettingsListItem>;
/**
* Get component setting data grid
* @param {string} groupName
* @param {string} name
* @param {number} index
* @param {string} propertyName
* @returns {Promise<DataGridControl>}
*/
getComponentSettingDataGrid(groupName: string, name: string, index: number, propertyName: string): Promise<DataGridControl>;
/**
* Set component setting data grid
* @param {string} groupName
* @param {string} name
* @param {number} index
* @param {string} propertyName
* @param {DataGridControl} dataGridControl
* @returns {{Promise<DataGridControl>}}
*/
setComponentSettingDataGrid(groupName: string, name: string, index: number, propertyName: string, dataGridControl: DataGridControl): Promise<DataGridControl>;
/**
* 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<DataGridControl>}
*/
addComponentSettingDataGridItemType(groupName: string, name: string, index: number, propertyName: string, typeName: string): Promise<DataGridControl>;
/**
* Add component setting item to data grid
* @param {string} groupName
* @param {string} name
* @param {number} index
* @param {string} propertyName
* @returns {Promise<DataGridControl>}
*/
addComponentSettingDataGridItem(groupName: string, name: string, index: number, propertyName: string): Promise<DataGridControl>;
/**
* Get item types available in the component setting data grid
* @param groupName
* @param name
* @param index
* @param propertyName
* @returns {Promise<ListItemType[]>}
*/
getComponentSettingDataGridTypes(groupName: string, name: string, index: number, propertyName: string): Promise<ListItemType[]>;
/**
* Change componentsettings profiles
* @param {ProfileGroup[]} returnedSettings
* @returns {Promise<ProfileGroup[]>}
*/
setComponentSettingsProfiles(returnedSettings: ProfileGroup[]): Promise<ProfileGroup[]>;
/**
* Get componentsettings profiles
* @returns {Promise<ProfileGroup[]>}
*/
getComponentSettingsProfiles(): Promise<ProfileGroup[]>;
/**
* Upload exported OpenTAP Settings files
* @param {FileParameter} file
* @returns {Promise<void>}
*/
uploadComponentSettings(file: FileParameter): Promise<string[]>;
/**
* 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<Uint8Array>} A byte array containing the downloaded .TapSettings file
*/
downloadComponentSettings(tapSettingsRequest: DownloadTapSettingsRequest): Promise<Uint8Array>;
/**
* Load a component settings TapPackage by referencing a package in a package repository
* @param {RepositoryPackageReference} packageReference
* @returns {Promise<ErrorResponse[]>}
*/
loadComponentSettingsFromRepository(packageReference: RepositoryPackageReference): Promise<ErrorResponse[]>;
/**
* Save a TapPackage containing component settings in a package repository
* @param {RepositorySettingsPackageDefinition} repositoryPackageDefinition
* @returns {Promise<void>}
*/
saveComponentSettingsToRepository(repositoryPackageDefinition: RepositorySettingsPackageDefinition): Promise<void>;
/**
* Retrieve types available to be added to specified component settings list
* @param {string} groupName
* @param {string} name
* @returns {Promise<ListItemType[]>}
*/
getComponentSettingsListAvailableTypes(groupName: string, name: string): Promise<ListItemType[]>;
/**
* Adds a new item to a component settings list
* @param {string} groupName
* @param {string} name
* @param {string} typeName
* @returns {Promise<ListItemType[]>}
*/
addComponentSettingsListItem(groupName: string, name: string, typeName: string): Promise<ComponentSettingsBase>;
/**
* Get settings package files
* @returns {Promise<string[]>}
*/
getSettingsPackageFiles(): Promise<string[]>;
/**
* Get settings package types
* @returns {Promise<string[]>}
*/
settingsPackageTypes(): Promise<string[]>;
/**
* 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<T> The response from the request
*/
dispatchRequest<T>(subject: string, payload?: any, options?: BaseClientRequestOptions): Promise<T>;
}
export {};