UNPKG

@wandelbots/nova-js

Version:

Official JS client for the Wandelbots API

118 lines (117 loc) 5.14 kB
import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket-dHe-kceU.mjs"; import { AxiosInstance } from "axios"; import { ApplicationApi, BUSInputsOutputsApi, CellApi, Configuration, ControllerApi, ControllerInputsOutputsApi, JoggingApi, KinematicsApi, MotionGroupApi, MotionGroupModelsApi, Pose, StoreCollisionComponentsApi, StoreCollisionSetupsApi, StoreObjectApi, SystemApi, TrajectoryCachingApi, TrajectoryExecutionApi, TrajectoryPlanningApi, VirtualControllerApi, VirtualControllerBehaviorApi, VirtualControllerInputsOutputsApi } from "@wandelbots/nova-api/v2"; export * from "@wandelbots/nova-api/v2"; //#region src/lib/v2/NovaCellAPIClient.d.ts type OmitFirstArg<F> = F extends ((x: any, ...args: infer P) => infer R) ? (...args: P) => R : never; type UnwrapAxiosResponseReturn<T> = T extends ((...a: any) => any) ? (...a: Parameters<T>) => Promise<Awaited<ReturnType<T>> extends { data: infer D; } ? D : never> : never; type WithCellId<T> = { [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>> }; type WithUnwrappedAxiosResponse<T> = { [P in keyof T]: UnwrapAxiosResponseReturn<T[P]> }; /** * API client providing type-safe access to all the Nova API REST endpoints * associated with a specific cell id. */ declare class NovaCellAPIClient { readonly cellId: string; readonly opts: Configuration & { axiosInstance?: AxiosInstance; mock?: boolean; }; constructor(cellId: string, opts: Configuration & { axiosInstance?: AxiosInstance; mock?: boolean; }); /** * Some TypeScript sorcery which alters the API class methods so you don't * have to pass the cell id to every single one, and de-encapsulates the * response data */ private withCellId; /** * As withCellId, but only does the response unwrapping */ private withUnwrappedResponsesOnly; readonly system: WithUnwrappedAxiosResponse<SystemApi>; readonly cell: WithUnwrappedAxiosResponse<CellApi>; readonly motionGroup: WithCellId<MotionGroupApi>; readonly motionGroupModels: WithCellId<MotionGroupModelsApi>; readonly controller: WithCellId<ControllerApi>; readonly controllerIOs: WithCellId<ControllerInputsOutputsApi>; readonly trajectoryPlanning: WithCellId<TrajectoryPlanningApi>; readonly trajectoryExecution: WithCellId<TrajectoryExecutionApi>; readonly trajectoryCaching: WithCellId<TrajectoryCachingApi>; readonly application: WithCellId<ApplicationApi>; readonly applicationGlobal: WithUnwrappedAxiosResponse<ApplicationApi>; readonly jogging: WithCellId<JoggingApi>; readonly kinematics: WithCellId<KinematicsApi>; readonly busInputsOutputs: WithCellId<BUSInputsOutputsApi>; readonly virtualController: WithCellId<VirtualControllerApi>; readonly virtualControllerBehavior: WithCellId<VirtualControllerBehaviorApi>; readonly virtualControllerIOs: WithCellId<VirtualControllerInputsOutputsApi>; readonly storeObject: WithCellId<StoreObjectApi>; readonly storeCollisionComponents: WithCellId<StoreCollisionComponentsApi>; readonly storeCollisionSetups: WithCellId<StoreCollisionSetupsApi>; } //#endregion //#region src/lib/v2/NovaClient.d.ts type NovaClientConfig = { /** * Url of the deployed Nova instance to connect to * e.g. https://saeattii.instance.wandelbots.io */ instanceUrl: string | "https://mock.example.com"; /** * Identifier of the cell on the Nova instance to connect this client to. * If omitted, the default identifier "cell" is used. **/ cellId?: string; /** * Username for basic auth to the Nova instance. * @deprecated use accessToken instead */ username?: string; /** * Password for basic auth to the Nova instance. * @deprecated use accessToken instead */ password?: string; /** * Access token for Bearer authentication. */ accessToken?: string; } & Omit<Configuration, "isJsonMime" | "basePath">; type NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string; }; /** * * Client for connecting to a Nova instance and controlling robots. */ declare class NovaClient { readonly api: NovaCellAPIClient; readonly config: NovaClientConfigWithDefaults; readonly mock?: MockNovaInstance; authPromise: Promise<string | null> | null; accessToken: string | null; constructor(config: NovaClientConfig); renewAuthentication(): Promise<void>; makeWebsocketURL(path: string): string; /** * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance. * If you explicitly want to reconnect an existing websocket, call `reconnect` * on the returned object. */ openReconnectingWebsocket(path: string): AutoReconnectingWebsocket; } //#endregion //#region src/lib/v2/wandelscriptUtils.d.ts /** * Convert a Pose object representing a motion group position * into a string which represents that pose in Wandelscript. */ declare function poseToWandelscriptString(pose: Pick<Pose, "position" | "orientation">): string; //#endregion export { NovaCellAPIClient, NovaClient, NovaClientConfig, WithCellId, WithUnwrappedAxiosResponse, poseToWandelscriptString }; //# sourceMappingURL=index.d.mts.map