UNPKG

haystack-nclient

Version:

Project Haystack Network Client

159 lines (158 loc) 5.38 kB
import { HGrid, HRef, HDict, HaysonDict, HList, HaysonVal, HVal, HStr, HNum, HDate, HDateTime } from 'haystack-core'; import { ClientServiceConfig } from './ClientServiceConfig'; import { WatchService } from './watches/WatchService'; /** * The history range. */ export declare enum HisRange { Today = "today", Yesterday = "yesterday" } /** * A service used for calling standard Haystack Ops. */ export declare class OpsService { #private; /** * The watch ops service. */ readonly watch: WatchService; /** * Constructs a new record service object. * * @param serviceConfig Ops configuration. */ constructor(serviceConfig: ClientServiceConfig); /** * https://project-haystack.org/doc/Ops#about * * @returns Server about information. */ about(): Promise<HGrid>; /** * https://project-haystack.org/doc/Ops#ops * * @returns Available ops that can be invoked. */ ops(): Promise<HGrid>; /** * https://project-haystack.org/doc/Ops#formats * * @returns Available formats supported by the server. */ formats(): Promise<HGrid>; /** * A generic method used to invoke any op on the server using an HTTP POST. * * @param op The name of the op to invoke. * @param grid An optional grid argument that is encoded with the op call. * @returns The response grid. */ invokeOp(op: string, grid?: HGrid): Promise<HGrid>; /** * @returns Reads a set of records from the server by id. * * ```typescript * const result = await client.read(['@id1', '@id2', '@id3']) * ``` * * https://project-haystack.org/doc/Ops#read * * @param ids list of ids as HRef or string * @returns A grid with the resolved query. */ read(ids: string[] | HRef[]): Promise<HGrid>; /** * @returns Reads a set of records from the server by filter. * * Please note, to help build a Haystack filter you can use HFilterBuilder available in * Haystack Core. * * ```typescript * const filter = new HFilterBuilder() * .has('site') * .and() * .equals('geoCity', 'Las Vegas') * .build() * * const result = await client.read(filter) * ``` * * https://project-haystack.org/doc/Ops#read * * @param filter The required haystack filter. * @param limit Optional limit on the number of records sent back. * @returns A grid with the resolved query. */ read(filter: string, limit?: number): Promise<HGrid>; /** * Read a writable point's priority array. * * https://project-haystack.org/doc/Ops#pointWrite * * @param id The id of the point to read. * @returns The writable point's priority array. */ pointRead(id: string | HRef): Promise<HGrid>; /** * Write to a point's priority level. * * https://project-haystack.org/doc/Ops#pointWrite * * @param option.id The id of the point to write. * @param option.level The number from 1 to 17 to write too. * @param option.val Optional value to write. If not defined, the level is set to auto. * @param option.who Optional username performing the write, otherwise user 'dis' is used. * @param option.duration Optional number with duration unit if setting level 8. * @returns The writable point's priority array. */ pointWrite({ id, level, val, who, duration, }: { id: string | HRef; level: number; val?: HVal | HaysonVal; who?: string; duration?: number | HNum; }): Promise<HGrid>; /** * Read time series data from a historized point. * * https://project-haystack.org/doc/Ops#hisRead * * @param id The id of the historized point. * @param range The date range. * @returns The time series data. */ hisRead(id: string | HRef, range: string | HisRange | HDate | HDateTime | [HDate, HDate] | [HDateTime, HDateTime]): Promise<HGrid>; /** * Write the time series data to the historized point. * * https://project-haystack.org/doc/Ops#hisWrite * * @param id The id of the historized point. * @param data The data to write to the history. * @returns The history data to write. */ hisWrite(id: string | HRef, data: HDict | HaysonDict | HDict[] | HaysonDict[] | HGrid | HList<HDict>): Promise<HGrid>; /** * Invoke an action on the target record. * * https://project-haystack.org/doc/Ops#invokeAction * * @param id The id of the target record to invoke the action on. * @param action The name of the action to invoke. * @param args Optional arguments for the action. * @returns The result of the action. */ invokeAction(id: string | HRef, action: string, args?: HDict | HaysonDict): Promise<HGrid>; /** * Get the navigation hierarchy at the specified node via its `navId`. * Return the root node if none is specified. * * https://project-haystack.org/doc/Ops#nav * * @param navId Optional navId string, str, ref, dict or grid. If a dict or grid, the id * must be specified via a navId property. * @returns The navigation. */ nav(navId?: string | HStr | HRef | HaysonDict | HDict | HGrid): Promise<HGrid>; }