import ISubscription from "./subscription.js"; import INotifyItem from "./notifyitem"; import IBulkItem from "./bulkitem"; import IResult from "./result.js"; import IVariant from "./variant.js"; /** * The subscription data changed callback function signature */ type DataChangedCallback = (result: IResult, item: INotifyItem) => void; /** * The IClient interface. */ interface IClient { /** * Returns a value indicating whether the client is connected. * * @return {boolean} True if the client is connected, else false. */ isConnected(): boolean; /** * Gets the connection status. * * @return {IResult} The connection status. */ getConnectionStatus(): IResult; /** * Gets the authentication token. * * @return {string} The authentication token (JWT) as string. */ getAuthToken(): string; /** * Sets a timeout or water mark. * * @param {string} timeoutSetting - The timeout to set. * 'Idle' * Timeout to check whether the broker is still active when client is idle (milliseconds) . * Default: 30000 ms * * 'Ping' * Timeout to wait for a response of a request (milliseconds). If timeout is exceeded, the request will be aborted with DL_TIMEOUT. * Default: 3000 ms * * 'Reconnect' * Timeout a reconnect attempt will be done if client looses connection to broker (milliseconds). * Default: 1000 ms * * 'ZmqHWMSnd' * High water mark of ZMQ (Send). * Default: 1000 * * 'ZmqHWMRcv' * High water mark of ZMQ (Receive). * Default: 1000 * * @param {number} value - The value to set. * @return {IResult} The result. */ setTimeout(timeoutSetting: string, value: number): IResult; /** * Pings the remote. * * @return {Promise} The result. */ ping(): Promise; /** * Gets data of a flatbuffers by query. * * @param {Uint8Array} flatbuffersValue - The flatbuffers value (flatbuffers). * @param {Uint8Array} flatbuffersType - The flatbuffers type (flatbuffers). * @param {string} query - The query string. * @return {Promise} The result. */ getDataFromFlatbuffers(flatbuffersValue: Uint8Array, flatbuffersType: Uint8Array, query: string): Promise; /** * Browses a node. * * @param {string} address - The address of the node. * @return {Promise} The result. */ browse(address: string): Promise; /** * Browses a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @return {Promise>} The result. */ bulkBrowse(addresses: Array): Promise>; /** * Writes the value to a node. * * @param {string} address - The address of the node. * @param {any} writeValue - The value to write. * @param {string} writeValueVariantType (optional) - The variant type of the writeValue to be converted. * @return {Promise} The result. */ write(address: string, writeValue: any, writeValueVariantType?: string): Promise; /** * Writes a list of values to a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @param {Array} writeValues - The values to write. * @param {Array} writeValueVariantTypes (optional) - The variant types of the writeValues to be converted. * @return {Promise>} The result. */ bulkWrite(addresses: Array, writeValues: Array, writeValueVariantTypes?: Array): Promise>; /** * Writes a JSON value to a node. * * @param {string} address - The address of the node. * @param {string} json - The JSON value to write. * @return {Promise} The result. */ writeJson(address: string, json: string): Promise; /** * Reads a node value. * * @param {string} address - The address of the node. * @param {any} arg (optional) - The request argument. * @param {string} argVariantType (optional) - The variant type of the argument to be converted. * @return {Promise} The result. */ read(address: string, arg?: any, argVariantType?: string): Promise; /** * Reads values from a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @param {Array} args (optional)- The request arguments. * @param {Array} argVariantTypes (optional) - The variant types of the arguments to be converted. * @return {Promise>} The result. */ bulkRead(addresses: Array, args?: Array, argVariantTypes?: Array): Promise>; /** * Reads a node value as JSON. * * @param {string} address - The address of the node. * @param {number} indentStep (optional) - The indentation for the returned JSON string. * @param {string} arg (optional) - The request argument (JSON). * @return {Promise} The result. */ readJson(address: string, indentStep?: number, arg?: string): Promise; /** * Reads metadata of a node. * * @param {string} address - The address of the node. * @return {Promise} The result. */ readMetadata(address: string): Promise; /** * Reads the metadata from a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @return {Promise>} The result. */ bulkReadMetadata(addresses: Array): Promise>; /** * Creates a node. * * @param {string} address - The address of the node. * @param {any} arg - The request argument. * @param {string} argVariantType (optional) - The variant type of the argument to be converted. * @return {Promise} The result. */ create(address: string, arg: any, argVariantType?: string): Promise; /** * Creates a list of nodes with arguments. * * @param {Array} addresses - The addresses of the nodes. * @param {Array} args- The request arguments. * @param {Array} argVariantTypes (optional) - The variant types of the arguments to be converted. * @return {Promise>} The result. */ bulkCreate(addresses: Array, args: Array, argVariantTypes?: Array): Promise>; /** * Removes a node. * * @param {string} address - The address of the node. * @return {Promise} The result. */ remove(address: string): Promise; /** * Removes a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @return {Promise>} The result. */ bulkRemove(addresses: Array): Promise>; /** * Creates a subscription. * * @param {Uint8Array} subscriptionPropertiesFlatbuffers - The properties of the subscription (flatbuffers). * @param {function} callback - The callback called on data changes for all subscribed nodes. * @return {Promise} The result. */ createSubscription(subscriptionPropertiesFlatbuffers: Uint8Array, callback: DataChangedCallback): Promise; } /** * The Client. */ declare class Client implements IClient { /** * Creates an instance of Client. * * INTERNAL USAGE ONLY - NOT TO BE INSTANTIATED BY JAVASCRIPT CODE */ constructor(); /** * Returns a value indicating whether the provider is connected. * * @return {boolean} - True if the client is connected, else false. */ isConnected(): boolean; /** * Gets the connection status. * * @return {IResult} The connection status. */ getConnectionStatus(): IResult; /** * Gets the authentication token. * * @return {string} - The authentication token (JWT) as string. */ getAuthToken(): string; /** * Sets a timeout or water mark. * * @param {string} timeoutSetting - The timeout to set. * 'Idle' * Timeout to check whether the broker is still active when client is idle (milliseconds) . * Default: 30000 ms * * 'Ping' * Timeout to wait for a response of a request (milliseconds). If timeout is exceeded, the request will be aborted with DL_TIMEOUT. * Default: 3000 ms * * 'Reconnect' * Timeout a reconnect attempt will be done if client looses connection to broker (milliseconds). * Default: 1000 ms * * 'ZmqHWMSnd' * High water mark of ZMQ (Send). * Default: 1000 * * 'ZmqHWMRcv' * High water mark of ZMQ (Receive). * Default: 1000 * * @param {number} value - The value to set. * @return {IResult} The result. */ setTimeout(timeoutSetting: string, value: number): IResult; /** * Pings the remote. * * @return {Promise} The result. */ ping(): Promise; /** * Gets data of a flatbuffers by query. * * @param {Uint8Array} flatbuffersValue - The flatbuffers value (flatbuffers). * @param {Uint8Array} flatbuffersType - The flatbuffers type (flatbuffers). * @param {string} query - The query string. * @return {Promise} The result. */ getDataFromFlatbuffers(flatbuffersValue: Uint8Array, flatbuffersType: Uint8Array, query: string): Promise; /** * Browses a node. * * @param {string} address - The address of the node. * @return {Promise} The result. */ browse(address: string): Promise; /** * Browses a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @return {Promise>} The result. */ bulkBrowse(addresses: Array): Promise>; /** * Writes the value to a node. * * @param {string} address - The address of the node. * @param {any} writeValue - The value to write. * @param {string} writeValueVariantType (optional) - The variant type of the writeValue to be converted. * @return {Promise} The result. */ write(address: string, writeValue: any, writeValueVariantType?: string): Promise; /** * Writes a list of values to a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @param {Array} writeValues - The values to write. * @param {Array} writeValueVariantTypes (optional) - The variant types of the writeValues to be converted. * @return {Promise>} The result. */ bulkWrite(addresses: Array, writeValues: Array, writeValueVariantTypes?: Array): Promise>; /** * Writes a JSON value to a node. * * @param {string} address - The address of the node. * @param {string} json - The JSON value to write. * @return {Promise} The result. */ writeJson(address: string, json: string): Promise; /** * Reads a node value. * * @param {string} address - The address of the node. * @param {any} arg (optional) - The request argument. * @param {string} argVariantType (optional) - The variant type of the argument to be converted. * @return {Promise} The result. */ read(address: string, arg?: any, argVariantType?: string): Promise; /** * Reads values from a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @param {Array} args (optional)- The request arguments. * @param {Array} argVariantTypes (optional) - The variant types of the arguments to be converted. * @return {Promise>} The result. */ bulkRead(addresses: Array, args?: Array, argVariantTypes?: Array): Promise>; /** * Reads a node value as JSON. * * @param {string} address - The address of the node. * @param {number} indentStep (optional) - The indentation for the returned JSON string. * @param {string} arg (optional) - The request argument (JSON). * @return {Promise} The result. */ readJson(address: string, indentStep?: number, arg?: string): Promise; /** * Reads metadata of a node. * * @param {string} address - The address of the node. * @return {Promise} The result. */ readMetadata(address: string): Promise; /** * Reads the metadata from a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @return {Promise>} The result. */ bulkReadMetadata(addresses: Array): Promise>; /** * Creates a node. * * @param {string} address - The address of the node. * @param {any} arg - The request argument. * @param {string} argVariantType (optional) - The variant type of the argument to be converted. * @return {Promise} The result. */ create(address: string, arg: any, argVariantType?: string): Promise; /** * Creates a list of nodes with arguments. * * @param {Array} addresses - The addresses of the nodes. * @param {Array} args- The request arguments. * @param {Array} argVariantTypes (optional) - The variant types of the arguments to be converted. * @return {Promise>} The result. */ bulkCreate(addresses: Array, args: Array, argVariantTypes?: Array): Promise>; /** * Removes a node. * * @param {string} address - The address of the node. * @return {Promise} The result. */ remove(address: string): Promise; /** * Removes a list of nodes. * * @param {Array} addresses - The addresses of the nodes. * @return {Promise>} The result. */ bulkRemove(addresses: Array): Promise>; /** * Creates a subscription. * * @param {Uint8Array} subscriptionPropertiesFlatbuffers - The properties of the subscription (flatbuffers). * @param {function} callback - The callback called on data changes for all subscribed nodes. * @return {Promise} The result. */ createSubscription(subscriptionPropertiesFlatbuffers: Uint8Array, callback: DataChangedCallback): Promise; private _addonInstance; } export = Client;