@wandelbots/nova-js 3.3.1 → 3.3.2-pr.fix-local-auth0-handling.194.177ffd2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/NovaClient-CV7ooIkD.d.cts.map +1 -1
  2. package/dist/{NovaClient-D2EItmiH.cjs → NovaClient-DGYu3pLp.cjs} +313 -16
  3. package/dist/NovaClient-DGYu3pLp.cjs.map +1 -0
  4. package/dist/{NovaClient-B8XM3OPO.mjs → NovaClient-DMKIU9kQ.mjs} +239 -8
  5. package/dist/NovaClient-DMKIU9kQ.mjs.map +1 -0
  6. package/dist/NovaClient-qJnHcx2s.d.mts.map +1 -1
  7. package/dist/index.cjs +12 -41
  8. package/dist/index.d.cts +25 -1
  9. package/dist/index.d.cts.map +1 -1
  10. package/dist/index.d.mts +25 -1
  11. package/dist/index.d.mts.map +1 -1
  12. package/dist/index.mjs +3 -35
  13. package/dist/lib/v1/index.cjs +1 -2
  14. package/dist/lib/v1/index.cjs.map +1 -1
  15. package/dist/lib/v1/index.mjs +1 -2
  16. package/dist/lib/v1/index.mjs.map +1 -1
  17. package/dist/lib/v2/index.cjs +11 -14
  18. package/dist/lib/v2/index.cjs.map +1 -1
  19. package/dist/lib/v2/index.d.cts.map +1 -1
  20. package/dist/lib/v2/index.d.mts.map +1 -1
  21. package/dist/lib/v2/index.mjs +3 -6
  22. package/dist/lib/v2/index.mjs.map +1 -1
  23. package/dist/src-BF_NxIDn.mjs +35 -0
  24. package/dist/src-BF_NxIDn.mjs.map +1 -0
  25. package/dist/src-D0XlWTgy.cjs +52 -0
  26. package/dist/src-D0XlWTgy.cjs.map +1 -0
  27. package/package.json +2 -2
  28. package/src/LoginWithAuth0.ts +10 -9
  29. package/src/lib/converters.ts +43 -0
  30. package/src/lib/errorHandling.ts +2 -2
  31. package/src/lib/v1/NovaClient.ts +4 -10
  32. package/src/lib/v2/NovaClient.ts +4 -10
  33. package/dist/LoginWithAuth0-CBD9BXXz.cjs +0 -264
  34. package/dist/LoginWithAuth0-CBD9BXXz.cjs.map +0 -1
  35. package/dist/LoginWithAuth0-wQB-Sol1.mjs +0 -217
  36. package/dist/LoginWithAuth0-wQB-Sol1.mjs.map +0 -1
  37. package/dist/NovaClient-B8XM3OPO.mjs.map +0 -1
  38. package/dist/NovaClient-D2EItmiH.cjs.map +0 -1
  39. package/dist/index.cjs.map +0 -1
  40. package/dist/index.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["cellId: string","opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n }","config"],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: legacy code */\n/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type {\n BaseAPI,\n Configuration as BaseConfiguration,\n} from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n BUSInputsOutputsApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n JoggingApi,\n KinematicsApi,\n MotionGroupApi,\n MotionGroupModelsApi,\n StoreCollisionComponentsApi,\n StoreCollisionSetupsApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryCachingApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualControllerApi,\n VirtualControllerBehaviorApi,\n VirtualControllerInputsOutputsApi,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AxiosInstance } from \"axios\"\nimport axios from \"axios\"\n\ntype OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R\n ? (...args: P) => R\n : never\n\ntype UnwrapAxiosResponseReturn<T> = T extends (...a: any) => any\n ? (\n ...a: Parameters<T>\n ) => Promise<Awaited<ReturnType<T>> extends { data: infer D } ? D : never>\n : never\n\nexport type WithCellId<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>>\n}\n\nexport type WithUnwrappedAxiosResponse<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<T[P]>\n}\n\n/**\n * API client providing type-safe access to all the Nova API REST endpoints\n * associated with a specific cell id.\n */\nexport class NovaCellAPIClient {\n constructor(\n readonly cellId: string,\n readonly opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n },\n ) {}\n\n /**\n * Some TypeScript sorcery which alters the API class methods so you don't\n * have to pass the cell id to every single one, and de-encapsulates the\n * response data\n */\n private withCellId<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, [this.cellId, ...args])\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithCellId<T>\n }\n\n /**\n * As withCellId, but only does the response unwrapping\n */\n private withUnwrappedResponsesOnly<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, args)\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithUnwrappedAxiosResponse<T>\n }\n\n readonly system = this.withUnwrappedResponsesOnly(SystemApi)\n readonly cell = this.withUnwrappedResponsesOnly(CellApi)\n\n readonly motionGroup = this.withCellId(MotionGroupApi)\n readonly motionGroupModels = this.withCellId(MotionGroupModelsApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly kinematics = this.withCellId(KinematicsApi)\n\n readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)\n\n readonly virtualController = this.withCellId(VirtualControllerApi)\n readonly virtualControllerBehavior = this.withCellId(\n VirtualControllerBehaviorApi,\n )\n readonly virtualControllerIOs = this.withCellId(\n VirtualControllerInputsOutputsApi,\n )\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)\n}\n","/** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */\nimport type { MotionGroupState, RobotController } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\"\nimport { AxiosError } from \"axios\"\nimport * as pathToRegexp from \"path-to-regexp\"\nimport type { AutoReconnectingWebsocket } from \"../../AutoReconnectingWebsocket\"\n\n/**\n * Ultra-simplified mock Nova server for testing stuff\n */\nexport class MockNovaInstance {\n readonly connections: AutoReconnectingWebsocket[] = []\n\n async handleAPIRequest(\n config: InternalAxiosRequestConfig,\n ): Promise<AxiosResponse> {\n const apiHandlers = [\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId\",\n handle() {\n return {\n configuration: {\n initial_joint_position: \"[0,-1.571,-1.571,-1.571,1.571,-1.571,0]\",\n kind: \"VirtualController\",\n manufacturer: \"universalrobots\",\n type: \"universalrobots-ur5e\",\n },\n name: \"mock-ur5\",\n } satisfies RobotController\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/state\",\n handle() {\n return {\n mode: \"MODE_CONTROL\",\n last_error: [],\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n controller: \"mock-ur5e\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n velocity_override: 100,\n motion_groups: [\n {\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n motion_group: \"0@mock-ur5e\",\n controller: \"mock-ur5e\",\n joint_position: [\n 1.487959623336792, -1.8501918315887451, 1.8003005981445312,\n 6.034560203552246, 1.4921919107437134, 1.593459963798523,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_torque: [],\n joint_current: [0, 0, 0, 0, 0, 0],\n flange_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n tcp: \"Flange\",\n tcp_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n payload: \"\",\n coordinate_system: \"\",\n standstill: true,\n },\n ],\n }\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description\",\n handle() {\n return {\n motion_group_model: \"UniversalRobots_UR5e\",\n mounting: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n tcps: {\n Flange: {\n name: \"Default-Flange\",\n pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n },\n },\n payloads: {\n \"FPay-0\": {\n name: \"FPay-0\",\n payload: 0,\n center_of_mass: [0, 0, 0],\n moment_of_inertia: [0, 0, 0],\n },\n },\n cycle_time: 8,\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n d: 162.25,\n },\n {\n a: -425,\n },\n {\n a: -392.2,\n },\n {\n alpha: 1.5707963267948966,\n d: 133.3,\n },\n {\n alpha: -1.5707963267948966,\n d: 99.7,\n },\n {\n d: 99.6,\n },\n ],\n operation_limits: {\n auto_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n elbow: {\n velocity: 5000,\n },\n flange: {\n velocity: 5000,\n },\n },\n manual_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t1_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t2_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n },\n serial_number: \"WBVirtualRobot\",\n }\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/coordinate-systems\",\n handle() {\n return [\n {\n coordinate_system: \"\",\n name: \"world\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n {\n coordinate_system: \"CS-0\",\n name: \"Default-CS\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n ] //satisfies CoordinateSystems\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = `/cells${config.url?.split(\"/cells\")[1]?.split(\"?\")[0]}`\n\n for (const handler of apiHandlers) {\n const match = pathToRegexp.match(handler.path)(path || \"\")\n if (method === handler.method && match) {\n const json = handler.handle()\n return {\n status: 200,\n statusText: \"Success\",\n data: JSON.stringify(json),\n headers: {},\n config,\n request: {\n responseURL: config.url,\n },\n }\n }\n }\n\n throw new AxiosError(\n `No mock handler matched this request: ${method} ${path}`,\n \"404\",\n config,\n )\n\n // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\n // }\n }\n\n // Please note: Only very basic websocket mocking is done here, needs to be extended as needed\n handleWebsocketConnection(socket: AutoReconnectingWebsocket) {\n this.connections.push(socket)\n\n setTimeout(() => {\n socket.dispatchEvent(new Event(\"open\"))\n\n console.log(\"Websocket connection opened from\", socket.url)\n\n if (socket.url.includes(\"/state-stream\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify(defaultMotionState),\n }),\n )\n }\n\n if (socket.url.includes(\"/execution/jogging\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n message: \"string\",\n kind: \"INITIALIZE_RECEIVED\",\n },\n }),\n }),\n )\n }\n }, 10)\n }\n\n handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {\n console.log(`Received message on ${socket.url}`, message)\n }\n}\n\nconst defaultMotionState = {\n result: {\n motion_group: \"0@universalrobots-ur5e\",\n controller: \"universalrobots-ur5e\",\n timestamp: new Date().toISOString(),\n sequence_number: 1,\n joint_position: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n standstill: false,\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n } satisfies MotionGroupState,\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosRequestConfig } from \"axios\"\nimport axios, { isAxiosError } from \"axios\"\nimport urlJoin from \"url-join\"\nimport { loginWithAuth0 } from \"../../LoginWithAuth0\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { availableStorage } from \"../availableStorage\"\nimport { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nexport type NovaClientConfig = {\n /**\n * Url of the deployed Nova instance to connect to\n * e.g. https://saeattii.instance.wandelbots.io\n */\n instanceUrl: string | \"https://mock.example.com\"\n\n /**\n * Identifier of the cell on the Nova instance to connect this client to.\n * If omitted, the default identifier \"cell\" is used.\n **/\n cellId?: string\n\n /**\n * Username for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n username?: string\n\n /**\n * Password for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n password?: string\n\n /**\n * Access token for Bearer authentication.\n */\n accessToken?: string\n} & Omit<BaseConfiguration, \"isJsonMime\" | \"basePath\">\n\ntype NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }\n\nfunction permissiveInstanceUrlParse(url: string): string {\n if (!url.startsWith(\"http\")) {\n url = `http://${url}`\n }\n\n return new URL(url).toString()\n}\n\n/**\n *\n * Client for connecting to a Nova instance and controlling robots.\n */\nexport class NovaClient {\n readonly api: NovaCellAPIClient\n readonly config: NovaClientConfigWithDefaults\n readonly mock?: MockNovaInstance\n authPromise: Promise<string | null> | null = null\n accessToken: string | null = null\n\n constructor(config: NovaClientConfig) {\n const cellId = config.cellId ?? \"cell\"\n this.config = {\n cellId,\n ...config,\n }\n this.accessToken =\n config.accessToken ||\n availableStorage.getString(\"wbjs.access_token\") ||\n null\n\n if (this.config.instanceUrl === \"https://mock.example.com\") {\n this.mock = new MockNovaInstance()\n } else {\n this.config.instanceUrl = permissiveInstanceUrlParse(\n this.config.instanceUrl,\n )\n }\n\n // Set up Axios instance with interceptor for token fetching\n const axiosInstance = axios.create({\n baseURL: urlJoin(this.config.instanceUrl, \"/api/v2\"),\n // TODO - backend needs to set proper CORS headers for this\n headers:\n typeof window !== \"undefined\" &&\n window.location.origin.includes(\"localhost\")\n ? {}\n : {\n // Identify the client to the backend for logging purposes\n \"X-Wandelbots-Client\": \"Wandelbots-Nova-JS-SDK\",\n },\n })\n\n axiosInstance.interceptors.request.use(async (request) => {\n if (!request.headers.Authorization) {\n if (this.accessToken) {\n request.headers.Authorization = `Bearer ${this.accessToken}`\n } else if (this.config.username && this.config.password) {\n request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`\n }\n }\n return request\n })\n\n if (typeof window !== \"undefined\") {\n axiosInstance.interceptors.response.use(\n (r) => r,\n async (error) => {\n if (isAxiosError(error)) {\n if (error.response?.status === 401) {\n // If we hit a 401, attempt to login the user and retry with\n // a new access token\n try {\n await this.renewAuthentication()\n\n if (error.config) {\n if (this.accessToken) {\n error.config.headers.Authorization = `Bearer ${this.accessToken}`\n } else {\n delete error.config.headers.Authorization\n }\n return axiosInstance.request(error.config)\n }\n } catch (err) {\n return Promise.reject(err)\n }\n } else if (error.response?.status === 503) {\n // Check if the server as a whole is down\n const res = await fetch(window.location.href)\n if (res.status === 503) {\n // Go to 503 page\n window.location.reload()\n }\n }\n }\n\n return Promise.reject(error)\n },\n )\n }\n\n this.api = new NovaCellAPIClient(cellId, {\n ...config,\n basePath: urlJoin(this.config.instanceUrl, \"/api/v2\"),\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n baseOptions: {\n ...(this.mock\n ? ({\n adapter: (config) => {\n return this.mock!.handleAPIRequest(config)\n },\n } satisfies AxiosRequestConfig)\n : {}),\n ...config.baseOptions,\n },\n axiosInstance,\n })\n }\n\n async renewAuthentication(): Promise<void> {\n if (this.authPromise) {\n // Don't double up\n return\n }\n\n this.authPromise = loginWithAuth0(this.config.instanceUrl)\n try {\n this.accessToken = await this.authPromise\n if (this.accessToken) {\n // Cache access token so we don't need to log in every refresh\n availableStorage.setString(\"wbjs.access_token\", this.accessToken)\n } else {\n availableStorage.delete(\"wbjs.access_token\")\n }\n } finally {\n this.authPromise = null\n }\n }\n\n makeWebsocketURL(path: string): string {\n const url = new URL(\n urlJoin(\n this.config.instanceUrl,\n `/api/v2/cells/${this.config.cellId}`,\n path,\n ),\n )\n url.protocol = url.protocol.replace(\"http\", \"ws\")\n url.protocol = url.protocol.replace(\"https\", \"wss\")\n\n // If provided, add basic auth credentials to the URL\n // NOTE - basic auth is deprecated on websockets and doesn't work in Safari\n // use tokens instead\n if (this.accessToken) {\n url.searchParams.append(\"token\", this.accessToken)\n } else if (this.config.username && this.config.password) {\n url.username = this.config.username\n url.password = this.config.password\n }\n\n return url.toString()\n }\n\n /**\n * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.\n * If you explicitly want to reconnect an existing websocket, call `reconnect`\n * on the returned object.\n */\n openReconnectingWebsocket(path: string) {\n return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {\n mock: this.mock,\n })\n }\n}\n","import type { Pose } from \"@wandelbots/nova-api/v2\"\n\n/**\n * Convert a Pose object representing a motion group position\n * into a string which represents that pose in Wandelscript.\n */\nexport function poseToWandelscriptString(\n pose: Pick<Pose, \"position\" | \"orientation\">,\n) {\n const position = [\n pose.position?.[0] ?? 0,\n pose.position?.[1] ?? 0,\n pose.position?.[2] ?? 0,\n ]\n\n const orientation = [\n pose.orientation?.[0] ?? 0,\n pose.orientation?.[1] ?? 0,\n pose.orientation?.[2] ?? 0,\n ]\n\n const positionValues = position.map((v) => v.toFixed(1))\n // Rotation needs more precision since it's in radians\n const rotationValues = orientation.map((v) => v.toFixed(4))\n\n return `(${positionValues.concat(rotationValues).join(\", \")})`\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,IAAa,oBAAb,MAA+B;CAC7B,YACE,AAASA,QACT,AAASC,MAIT;EALS;EACA;gBAkFO,KAAK,2BAA2B,UA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ACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;U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C;CAExD,MAAM,iBAAiB,YAAY,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;AAE3D,QAAO,IAAI,eAAe,OAAO,eAAe,CAAC,KAAK,KAAK,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["cellId: string","opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n }","config"],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: legacy code */\n/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type {\n BaseAPI,\n Configuration as BaseConfiguration,\n} from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n BUSInputsOutputsApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n JoggingApi,\n KinematicsApi,\n MotionGroupApi,\n MotionGroupModelsApi,\n StoreCollisionComponentsApi,\n StoreCollisionSetupsApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryCachingApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualControllerApi,\n VirtualControllerBehaviorApi,\n VirtualControllerInputsOutputsApi,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AxiosInstance } from \"axios\"\nimport axios from \"axios\"\n\ntype OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R\n ? (...args: P) => R\n : never\n\ntype UnwrapAxiosResponseReturn<T> = T extends (...a: any) => any\n ? (\n ...a: Parameters<T>\n ) => Promise<Awaited<ReturnType<T>> extends { data: infer D } ? D : never>\n : never\n\nexport type WithCellId<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>>\n}\n\nexport type WithUnwrappedAxiosResponse<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<T[P]>\n}\n\n/**\n * API client providing type-safe access to all the Nova API REST endpoints\n * associated with a specific cell id.\n */\nexport class NovaCellAPIClient {\n constructor(\n readonly cellId: string,\n readonly opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n },\n ) {}\n\n /**\n * Some TypeScript sorcery which alters the API class methods so you don't\n * have to pass the cell id to every single one, and de-encapsulates the\n * response data\n */\n private withCellId<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, [this.cellId, ...args])\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithCellId<T>\n }\n\n /**\n * As withCellId, but only does the response unwrapping\n */\n private withUnwrappedResponsesOnly<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, args)\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithUnwrappedAxiosResponse<T>\n }\n\n readonly system = this.withUnwrappedResponsesOnly(SystemApi)\n readonly cell = this.withUnwrappedResponsesOnly(CellApi)\n\n readonly motionGroup = this.withCellId(MotionGroupApi)\n readonly motionGroupModels = this.withCellId(MotionGroupModelsApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly kinematics = this.withCellId(KinematicsApi)\n\n readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)\n\n readonly virtualController = this.withCellId(VirtualControllerApi)\n readonly virtualControllerBehavior = this.withCellId(\n VirtualControllerBehaviorApi,\n )\n readonly virtualControllerIOs = this.withCellId(\n VirtualControllerInputsOutputsApi,\n )\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)\n}\n","/** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */\nimport type { MotionGroupState, RobotController } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\"\nimport { AxiosError } from \"axios\"\nimport * as pathToRegexp from \"path-to-regexp\"\nimport type { AutoReconnectingWebsocket } from \"../../AutoReconnectingWebsocket\"\n\n/**\n * Ultra-simplified mock Nova server for testing stuff\n */\nexport class MockNovaInstance {\n readonly connections: AutoReconnectingWebsocket[] = []\n\n async handleAPIRequest(\n config: InternalAxiosRequestConfig,\n ): Promise<AxiosResponse> {\n const apiHandlers = [\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId\",\n handle() {\n return {\n configuration: {\n initial_joint_position: \"[0,-1.571,-1.571,-1.571,1.571,-1.571,0]\",\n kind: \"VirtualController\",\n manufacturer: \"universalrobots\",\n type: \"universalrobots-ur5e\",\n },\n name: \"mock-ur5\",\n } satisfies RobotController\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/state\",\n handle() {\n return {\n mode: \"MODE_CONTROL\",\n last_error: [],\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n controller: \"mock-ur5e\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n velocity_override: 100,\n motion_groups: [\n {\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n motion_group: \"0@mock-ur5e\",\n controller: \"mock-ur5e\",\n joint_position: [\n 1.487959623336792, -1.8501918315887451, 1.8003005981445312,\n 6.034560203552246, 1.4921919107437134, 1.593459963798523,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_torque: [],\n joint_current: [0, 0, 0, 0, 0, 0],\n flange_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n tcp: \"Flange\",\n tcp_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n payload: \"\",\n coordinate_system: \"\",\n standstill: true,\n },\n ],\n }\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description\",\n handle() {\n return {\n motion_group_model: \"UniversalRobots_UR5e\",\n mounting: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n tcps: {\n Flange: {\n name: \"Default-Flange\",\n pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n },\n },\n payloads: {\n \"FPay-0\": {\n name: \"FPay-0\",\n payload: 0,\n center_of_mass: [0, 0, 0],\n moment_of_inertia: [0, 0, 0],\n },\n },\n cycle_time: 8,\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n d: 162.25,\n },\n {\n a: -425,\n },\n {\n a: -392.2,\n },\n {\n alpha: 1.5707963267948966,\n d: 133.3,\n },\n {\n alpha: -1.5707963267948966,\n d: 99.7,\n },\n {\n d: 99.6,\n },\n ],\n operation_limits: {\n auto_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n elbow: {\n velocity: 5000,\n },\n flange: {\n velocity: 5000,\n },\n },\n manual_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t1_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t2_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n },\n serial_number: \"WBVirtualRobot\",\n }\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/coordinate-systems\",\n handle() {\n return [\n {\n coordinate_system: \"\",\n name: \"world\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n {\n coordinate_system: \"CS-0\",\n name: \"Default-CS\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n ] //satisfies CoordinateSystems\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = `/cells${config.url?.split(\"/cells\")[1]?.split(\"?\")[0]}`\n\n for (const handler of apiHandlers) {\n const match = pathToRegexp.match(handler.path)(path || \"\")\n if (method === handler.method && match) {\n const json = handler.handle()\n return {\n status: 200,\n statusText: \"Success\",\n data: JSON.stringify(json),\n headers: {},\n config,\n request: {\n responseURL: config.url,\n },\n }\n }\n }\n\n throw new AxiosError(\n `No mock handler matched this request: ${method} ${path}`,\n \"404\",\n config,\n )\n\n // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\n // }\n }\n\n // Please note: Only very basic websocket mocking is done here, needs to be extended as needed\n handleWebsocketConnection(socket: AutoReconnectingWebsocket) {\n this.connections.push(socket)\n\n setTimeout(() => {\n socket.dispatchEvent(new Event(\"open\"))\n\n console.log(\"Websocket connection opened from\", socket.url)\n\n if (socket.url.includes(\"/state-stream\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify(defaultMotionState),\n }),\n )\n }\n\n if (socket.url.includes(\"/execution/jogging\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n message: \"string\",\n kind: \"INITIALIZE_RECEIVED\",\n },\n }),\n }),\n )\n }\n }, 10)\n }\n\n handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {\n console.log(`Received message on ${socket.url}`, message)\n }\n}\n\nconst defaultMotionState = {\n result: {\n motion_group: \"0@universalrobots-ur5e\",\n controller: \"universalrobots-ur5e\",\n timestamp: new Date().toISOString(),\n sequence_number: 1,\n joint_position: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n standstill: false,\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n } satisfies MotionGroupState,\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosRequestConfig } from \"axios\"\nimport axios, { isAxiosError } from \"axios\"\nimport urlJoin from \"url-join\"\nimport { loginWithAuth0 } from \"../../LoginWithAuth0\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { availableStorage } from \"../availableStorage\"\nimport { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\nimport { parseUrl } from \"../..\"\n\nexport type NovaClientConfig = {\n /**\n * Url of the deployed Nova instance to connect to\n * e.g. https://saeattii.instance.wandelbots.io\n */\n instanceUrl: string | \"https://mock.example.com\"\n\n /**\n * Identifier of the cell on the Nova instance to connect this client to.\n * If omitted, the default identifier \"cell\" is used.\n **/\n cellId?: string\n\n /**\n * Username for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n username?: string\n\n /**\n * Password for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n password?: string\n\n /**\n * Access token for Bearer authentication.\n */\n accessToken?: string\n} & Omit<BaseConfiguration, \"isJsonMime\" | \"basePath\">\n\ntype NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }\n\n/**\n *\n * Client for connecting to a Nova instance and controlling robots.\n */\nexport class NovaClient {\n readonly api: NovaCellAPIClient\n readonly config: NovaClientConfigWithDefaults\n readonly mock?: MockNovaInstance\n authPromise: Promise<string | null> | null = null\n accessToken: string | null = null\n\n constructor(config: NovaClientConfig) {\n const cellId = config.cellId ?? \"cell\"\n this.config = {\n cellId,\n ...config,\n }\n this.accessToken =\n config.accessToken ||\n availableStorage.getString(\"wbjs.access_token\") ||\n null\n\n if (this.config.instanceUrl === \"https://mock.example.com\") {\n this.mock = new MockNovaInstance()\n } else {\n this.config.instanceUrl = parseUrl(\n this.config.instanceUrl,\n { defaultScheme: \"http\" }\n ).toString()\n }\n\n // Set up Axios instance with interceptor for token fetching\n const axiosInstance = axios.create({\n baseURL: urlJoin(this.config.instanceUrl, \"/api/v2\"),\n // TODO - backend needs to set proper CORS headers for this\n headers:\n typeof window !== \"undefined\" &&\n window.location.origin.includes(\"localhost\")\n ? {}\n : {\n // Identify the client to the backend for logging purposes\n \"X-Wandelbots-Client\": \"Wandelbots-Nova-JS-SDK\",\n },\n })\n\n axiosInstance.interceptors.request.use(async (request) => {\n if (!request.headers.Authorization) {\n if (this.accessToken) {\n request.headers.Authorization = `Bearer ${this.accessToken}`\n } else if (this.config.username && this.config.password) {\n request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`\n }\n }\n return request\n })\n\n if (typeof window !== \"undefined\") {\n axiosInstance.interceptors.response.use(\n (r) => r,\n async (error) => {\n if (isAxiosError(error)) {\n if (error.response?.status === 401) {\n // If we hit a 401, attempt to login the user and retry with\n // a new access token\n try {\n await this.renewAuthentication()\n\n if (error.config) {\n if (this.accessToken) {\n error.config.headers.Authorization = `Bearer ${this.accessToken}`\n } else {\n delete error.config.headers.Authorization\n }\n return axiosInstance.request(error.config)\n }\n } catch (err) {\n return Promise.reject(err)\n }\n } else if (error.response?.status === 503) {\n // Check if the server as a whole is down\n const res = await fetch(window.location.href)\n if (res.status === 503) {\n // Go to 503 page\n window.location.reload()\n }\n }\n }\n\n return Promise.reject(error)\n },\n )\n }\n\n this.api = new NovaCellAPIClient(cellId, {\n ...config,\n basePath: urlJoin(this.config.instanceUrl, \"/api/v2\"),\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n baseOptions: {\n ...(this.mock\n ? ({\n adapter: (config) => {\n return this.mock!.handleAPIRequest(config)\n },\n } satisfies AxiosRequestConfig)\n : {}),\n ...config.baseOptions,\n },\n axiosInstance,\n })\n }\n\n async renewAuthentication(): Promise<void> {\n if (this.authPromise) {\n // Don't double up\n return\n }\n\n this.authPromise = loginWithAuth0(this.config.instanceUrl)\n try {\n this.accessToken = await this.authPromise\n if (this.accessToken) {\n // Cache access token so we don't need to log in every refresh\n availableStorage.setString(\"wbjs.access_token\", this.accessToken)\n } else {\n availableStorage.delete(\"wbjs.access_token\")\n }\n } finally {\n this.authPromise = null\n }\n }\n\n makeWebsocketURL(path: string): string {\n const url = new URL(\n urlJoin(\n this.config.instanceUrl,\n `/api/v2/cells/${this.config.cellId}`,\n path,\n ),\n )\n url.protocol = url.protocol.replace(\"http\", \"ws\")\n url.protocol = url.protocol.replace(\"https\", \"wss\")\n\n // If provided, add basic auth credentials to the URL\n // NOTE - basic auth is deprecated on websockets and doesn't work in Safari\n // use tokens instead\n if (this.accessToken) {\n url.searchParams.append(\"token\", this.accessToken)\n } else if (this.config.username && this.config.password) {\n url.username = this.config.username\n url.password = this.config.password\n }\n\n return url.toString()\n }\n\n /**\n * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.\n * If you explicitly want to reconnect an existing websocket, call `reconnect`\n * on the returned object.\n */\n openReconnectingWebsocket(path: string) {\n return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {\n mock: this.mock,\n })\n }\n}\n","import type { Pose } from \"@wandelbots/nova-api/v2\"\n\n/**\n * Convert a Pose object representing a motion group position\n * into a string which represents that pose in Wandelscript.\n */\nexport function poseToWandelscriptString(\n pose: Pick<Pose, \"position\" | \"orientation\">,\n) {\n const position = [\n pose.position?.[0] ?? 0,\n pose.position?.[1] ?? 0,\n pose.position?.[2] ?? 0,\n ]\n\n const orientation = [\n pose.orientation?.[0] ?? 0,\n pose.orientation?.[1] ?? 0,\n pose.orientation?.[2] ?? 0,\n ]\n\n const positionValues = position.map((v) => v.toFixed(1))\n // Rotation needs more precision since it's in radians\n const rotationValues = orientation.map((v) => v.toFixed(4))\n\n return `(${positionValues.concat(rotationValues).join(\", \")})`\n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,IAAa,oBAAb,MAA+B;CAC7B,YACE,AAASA,QACT,AAASC,MAIT;EALS;EACA;gBAkFO,KAAK,2BAA2B,UAAU;cAC5C,KAAK,2BAA2B,QAAQ;qBAEjC,KAAK,WAAW,eAAe;2BACzB,KAAK,WAAW,qBAAqB;oBAE5C,KAAK,WAAW,cAAc;uBAE3B,KAAK,WAAW,2BAA2B;4BAEtC,KAAK,WAAW,sBAAsB;6BACrC,KAAK,WAAW,uBAAuB;2BACzC,KAAK,WAAW,qBAAqB;qBAE3C,K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vB;OACF,EACF;MACD,UAAU,EACR,UAAU;OACR,MAAM;OACN,SAAS;OACT,gBAAgB;QAAC;QAAG;QAAG;QAAE;OACzB,mBAAmB;QAAC;QAAG;QAAG;QAAE;OAC7B,EACF;MACD,YAAY;MACZ,eAAe;OACb;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACD,EACE,GAAG,QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACF;MACD,kBAAkB;OAChB,aAAa;QACX,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACD,OAAO,EACL,UAAU,KACX;QACD,QAAQ,EACN,UAAU,KACX;QACF;OACD,eAAe;QACb,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;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OAAI,KAAK,YAEP,kBAAiB,UAAU,qBAAqB,KAAK,YAAY;OAEjE,kBAAiB,OAAO,oBAAoB;YAEtC;AACR,QAAK,cAAc;;;CAIvB,iBAAiB,MAAsB;EACrC,MAAM,MAAM,IAAI,IACd,QACE,KAAK,OAAO,aACZ,iBAAiB,KAAK,OAAO,UAC7B,KACD,CACF;AACD,MAAI,WAAW,IAAI,SAAS,QAAQ,QAAQ,KAAK;AACjD,MAAI,WAAW,IAAI,SAAS,QAAQ,SAAS,MAAM;AAKnD,MAAI,KAAK,YACP,KAAI,aAAa,OAAO,SAAS,KAAK,YAAY;WACzC,KAAK,OAAO,YAAY,KAAK,OAAO,UAAU;AACvD,OAAI,WAAW,KAAK,OAAO;AAC3B,OAAI,WAAW,KAAK,OAAO;;AAG7B,SAAO,IAAI,UAAU;;;;;;;CAQvB,0BAA0B,MAAc;AACtC,SAAO,IAAI,0BAA0B,KAAK,iBAAiB,KAAK,EAAE,EAChE,MAAM,KAAK,MACZ,CAAC;;;;;;;;;;AC5MN,SAAgB,yBACd,MACA;CACA,MAAM,WAAW;EACf,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;EACvB;CAED,MAAM,cAAc;EAClB,KAAK,cAAc,MAAM;EACzB,KAAK,cAAc,MAAM;EACzB,KAAK,cAAc,MAAM;EAC1B;CAED,MAAM,iBAAiB,SAAS,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;CAExD,MAAM,iBAAiB,YAAY,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;AAE3D,QAAO,IAAI,eAAe,OAAO,eAAe,CAAC,KAAK,KAAK,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { _ as tryStringifyJson } from "./NovaClient-DMKIU9kQ.mjs";
2
+ import { isAxiosError } from "axios";
3
+
4
+ //#region src/lib/errorHandling.ts
5
+ function delay(ms) {
6
+ return new Promise((resolve) => setTimeout(resolve, ms));
7
+ }
8
+ /**
9
+ * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code
10
+ */
11
+ function makeShortErrorMessage(err) {
12
+ return makeErrorMessage(err);
13
+ }
14
+ /**
15
+ * Attempts to make a helpful error message from an unknown thrown error
16
+ * or promise rejection.
17
+ *
18
+ * This function is mainly to aid debugging and good bug reports. For
19
+ * expected errors encountered by end users, it's more ideal to catch
20
+ * the specific error code and provide a localized app-specific error message.
21
+ */
22
+ function makeErrorMessage(err) {
23
+ if (isAxiosError(err)) {
24
+ if (err.response) return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || "accessing"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`;
25
+ else if (err.config) if (err.code === "ERR_NETWORK") return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`;
26
+ else return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}`;
27
+ } else if (err instanceof Error) return err.message;
28
+ else if (typeof err === "string") return err;
29
+ else if (typeof err === "object") return tryStringifyJson(err) || `Unserializable object ${err}`;
30
+ return `${err}`;
31
+ }
32
+
33
+ //#endregion
34
+ export { makeErrorMessage as n, makeShortErrorMessage as r, delay as t };
35
+ //# sourceMappingURL=src-BF_NxIDn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-BF_NxIDn.mjs","names":[],"sources":["../src/lib/errorHandling.ts"],"sourcesContent":["import { isAxiosError } from \"axios\"\nimport { tryStringifyJson } from \"./converters\"\n\nexport function delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code\n */\nexport function makeShortErrorMessage(err: unknown) {\n return makeErrorMessage(err)\n}\n\n/**\n * Attempts to make a helpful error message from an unknown thrown error\n * or promise rejection.\n *\n * This function is mainly to aid debugging and good bug reports. For\n * expected errors encountered by end users, it's more ideal to catch\n * the specific error code and provide a localized app-specific error message.\n */\nexport function makeErrorMessage(err: unknown): string {\n if (isAxiosError(err)) {\n if (err.response) {\n return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || \"accessing\"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`\n } else if (err.config) {\n if (err.code === \"ERR_NETWORK\") {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`\n } else {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}`\n }\n }\n } else if (err instanceof Error) {\n return err.message\n } else if (typeof err === \"string\") {\n return err\n } else if (typeof err === \"object\") {\n return tryStringifyJson(err) || `Unserializable object ${err}`\n }\n\n return `${err}`\n}\n"],"mappings":";;;;AAGA,SAAgB,MAAM,IAAY;AAChC,QAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;AAM1D,SAAgB,sBAAsB,KAAc;AAClD,QAAO,iBAAiB,IAAI;;;;;;;;;;AAW9B,SAAgB,iBAAiB,KAAsB;AACrD,KAAI,aAAa,IAAI,EACnB;MAAI,IAAI,SACN,QAAO,GAAG,IAAI,UAAU,OAAO,GAAG,IAAI,UAAU,WAAW,QAAQ,IAAI,UAAU,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,UAAU,OAAO,IAAI,IAAI,KAAK,UAAU,IAAI,UAAU,KAAK;WACtL,IAAI,OACb,KAAI,IAAI,SAAS,cACf,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO,IAAI;MAEhG,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO;YAGvF,eAAe,MACxB,QAAO,IAAI;UACF,OAAO,QAAQ,SACxB,QAAO;UACE,OAAO,QAAQ,SACxB,QAAO,iBAAiB,IAAI,IAAI,yBAAyB;AAG3D,QAAO,GAAG"}
@@ -0,0 +1,52 @@
1
+ const require_NovaClient = require('./NovaClient-DGYu3pLp.cjs');
2
+ let axios = require("axios");
3
+
4
+ //#region src/lib/errorHandling.ts
5
+ function delay(ms) {
6
+ return new Promise((resolve) => setTimeout(resolve, ms));
7
+ }
8
+ /**
9
+ * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code
10
+ */
11
+ function makeShortErrorMessage(err) {
12
+ return makeErrorMessage(err);
13
+ }
14
+ /**
15
+ * Attempts to make a helpful error message from an unknown thrown error
16
+ * or promise rejection.
17
+ *
18
+ * This function is mainly to aid debugging and good bug reports. For
19
+ * expected errors encountered by end users, it's more ideal to catch
20
+ * the specific error code and provide a localized app-specific error message.
21
+ */
22
+ function makeErrorMessage(err) {
23
+ if ((0, axios.isAxiosError)(err)) {
24
+ if (err.response) return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || "accessing"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`;
25
+ else if (err.config) if (err.code === "ERR_NETWORK") return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`;
26
+ else return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}`;
27
+ } else if (err instanceof Error) return err.message;
28
+ else if (typeof err === "string") return err;
29
+ else if (typeof err === "object") return require_NovaClient.tryStringifyJson(err) || `Unserializable object ${err}`;
30
+ return `${err}`;
31
+ }
32
+
33
+ //#endregion
34
+ Object.defineProperty(exports, 'delay', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return delay;
38
+ }
39
+ });
40
+ Object.defineProperty(exports, 'makeErrorMessage', {
41
+ enumerable: true,
42
+ get: function () {
43
+ return makeErrorMessage;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, 'makeShortErrorMessage', {
47
+ enumerable: true,
48
+ get: function () {
49
+ return makeShortErrorMessage;
50
+ }
51
+ });
52
+ //# sourceMappingURL=src-D0XlWTgy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-D0XlWTgy.cjs","names":["tryStringifyJson"],"sources":["../src/lib/errorHandling.ts"],"sourcesContent":["import { isAxiosError } from \"axios\"\nimport { tryStringifyJson } from \"./converters\"\n\nexport function delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code\n */\nexport function makeShortErrorMessage(err: unknown) {\n return makeErrorMessage(err)\n}\n\n/**\n * Attempts to make a helpful error message from an unknown thrown error\n * or promise rejection.\n *\n * This function is mainly to aid debugging and good bug reports. For\n * expected errors encountered by end users, it's more ideal to catch\n * the specific error code and provide a localized app-specific error message.\n */\nexport function makeErrorMessage(err: unknown): string {\n if (isAxiosError(err)) {\n if (err.response) {\n return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || \"accessing\"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`\n } else if (err.config) {\n if (err.code === \"ERR_NETWORK\") {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`\n } else {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}`\n }\n }\n } else if (err instanceof Error) {\n return err.message\n } else if (typeof err === \"string\") {\n return err\n } else if (typeof err === \"object\") {\n return tryStringifyJson(err) || `Unserializable object ${err}`\n }\n\n return `${err}`\n}\n"],"mappings":";;;;AAGA,SAAgB,MAAM,IAAY;AAChC,QAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;AAM1D,SAAgB,sBAAsB,KAAc;AAClD,QAAO,iBAAiB,IAAI;;;;;;;;;;AAW9B,SAAgB,iBAAiB,KAAsB;AACrD,6BAAiB,IAAI,EACnB;MAAI,IAAI,SACN,QAAO,GAAG,IAAI,UAAU,OAAO,GAAG,IAAI,UAAU,WAAW,QAAQ,IAAI,UAAU,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,UAAU,OAAO,IAAI,IAAI,KAAK,UAAU,IAAI,UAAU,KAAK;WACtL,IAAI,OACb,KAAI,IAAI,SAAS,cACf,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO,IAAI;MAEhG,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO;YAGvF,eAAe,MACxB,QAAO,IAAI;UACF,OAAO,QAAQ,SACxB,QAAO;UACE,OAAO,QAAQ,SACxB,QAAOA,oCAAiB,IAAI,IAAI,yBAAyB;AAG3D,QAAO,GAAG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wandelbots/nova-js",
3
3
  "type": "module",
4
- "version": "3.3.1",
4
+ "version": "v3.3.2-pr.fix-local-auth0-handling.194.177ffd2",
5
5
  "description": "Official JS client for the Wandelbots API",
6
6
  "sideEffects": false,
7
7
  "packageManager": "pnpm@10.19.0",
@@ -55,7 +55,7 @@
55
55
  "semantic-release": "^24.2.7",
56
56
  "tsdown": "^0.16.0",
57
57
  "typescript": "^5.9.3",
58
- "vitest": "^4.0.6",
58
+ "vitest": "^4.0.8",
59
59
  "ws": "^8.18.1"
60
60
  },
61
61
  "dependencies": {
@@ -1,4 +1,4 @@
1
- const DOMAIN_SUFFIX = "wandelbots.io"
1
+ import { tryParseUrl } from "./lib/converters"
2
2
 
3
3
  /**
4
4
  * Mapping of stages to Auth0 configurations.
@@ -8,26 +8,27 @@ const DOMAIN_SUFFIX = "wandelbots.io"
8
8
  */
9
9
  const auth0ConfigMap = {
10
10
  dev: {
11
- domain: `https://auth.portal.dev.${DOMAIN_SUFFIX}`,
11
+ domain: `https://auth.portal.dev.wandelbots.io`,
12
12
  clientId: "fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha",
13
13
  },
14
14
  stg: {
15
- domain: `https://auth.portal.stg.${DOMAIN_SUFFIX}`,
15
+ domain: `https://auth.portal.stg.wandelbots.io`,
16
16
  clientId: "joVDeD9e786WzFNSGCqoVq7HNkWt5j6s",
17
17
  },
18
18
  prod: {
19
- domain: `https://auth.portal.${DOMAIN_SUFFIX}`,
19
+ domain: `https://auth.portal.wandelbots.io`,
20
20
  clientId: "J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2",
21
21
  },
22
22
  }
23
23
 
24
24
  /** Determine which Auth0 configuration to use based on instance URL */
25
- const getAuth0Config = (instanceUrl: string) => {
26
- if (instanceUrl.endsWith(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev
27
- if (instanceUrl.endsWith(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg
28
- if (instanceUrl.endsWith(DOMAIN_SUFFIX)) return auth0ConfigMap.prod
25
+ export const getAuth0Config = (instanceUrl: string) => {
26
+ const url = tryParseUrl(instanceUrl)
27
+ if (url?.host.endsWith("dev.wandelbots.io")) return auth0ConfigMap.dev
28
+ if (url?.host.endsWith("stg.wandelbots.io")) return auth0ConfigMap.stg
29
+ if (url?.host.endsWith("wandelbots.io")) return auth0ConfigMap.prod
29
30
  throw new Error(
30
- "Unsupported instance URL. Cannot determine Auth0 configuration.",
31
+ `Unsupported instance URL "${instanceUrl}". Auth0 login is only supported for urls of the form "https://*.wandelbots.io".`,
31
32
  )
32
33
  }
33
34
 
@@ -1,3 +1,46 @@
1
+ export type URLParseOptions = {
2
+ /**
3
+ * Ignore any scheme in the input string and force this scheme instead.
4
+ */
5
+ scheme?: "http" | "https"
6
+ /**
7
+ * If the input string does not include a scheme, use this as the default
8
+ * scheme.
9
+ */
10
+ defaultScheme?: "http" | "https"
11
+ }
12
+
13
+ /**
14
+ * Parse a string as a URL, with options to enforce or default the scheme.
15
+ */
16
+ export function parseUrl(url: string, options: URLParseOptions = {}): URL {
17
+ const { scheme, defaultScheme } = options
18
+
19
+ const schemeRegex = /^[a-zA-Z]+:\/\//
20
+
21
+ if (scheme) {
22
+ // Force the scheme by removing any existing scheme and prepending the desired one
23
+ url = url.replace(schemeRegex, "")
24
+ url = `${scheme}://${url}`
25
+ } else if (defaultScheme && !schemeRegex.test(url)) {
26
+ // No scheme is present, add the default one
27
+ url = `${defaultScheme}://${url}`
28
+ }
29
+
30
+ return new URL(url)
31
+ }
32
+
33
+ /**
34
+ * Attempt to parse a string as a URL; return undefined if we can't
35
+ */
36
+ export function tryParseUrl(url: string, options: URLParseOptions = {}): URL | undefined {
37
+ try {
38
+ return parseUrl(url, options)
39
+ } catch {
40
+ return undefined
41
+ }
42
+ }
43
+
1
44
  /** Try to parse something as JSON; return undefined if we can't */
2
45
  // biome-ignore lint/suspicious/noExplicitAny: it's json
3
46
  export function tryParseJson(json: unknown): any {
@@ -1,4 +1,4 @@
1
- import { AxiosError } from "axios"
1
+ import { isAxiosError } from "axios"
2
2
  import { tryStringifyJson } from "./converters"
3
3
 
4
4
  export function delay(ms: number) {
@@ -21,7 +21,7 @@ export function makeShortErrorMessage(err: unknown) {
21
21
  * the specific error code and provide a localized app-specific error message.
22
22
  */
23
23
  export function makeErrorMessage(err: unknown): string {
24
- if (err instanceof AxiosError) {
24
+ if (isAxiosError(err)) {
25
25
  if (err.response) {
26
26
  return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || "accessing"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`
27
27
  } else if (err.config) {
@@ -15,6 +15,7 @@ import { JoggerConnection } from "./JoggerConnection.js"
15
15
  import { MotionStreamConnection } from "./MotionStreamConnection.js"
16
16
  import { NovaCellAPIClient } from "./NovaCellAPIClient.js"
17
17
  import { MockNovaInstance } from "./mock/MockNovaInstance.js"
18
+ import { parseUrl } from "../converters.js"
18
19
 
19
20
  export type NovaClientConfig = {
20
21
  /**
@@ -49,14 +50,6 @@ export type NovaClientConfig = {
49
50
 
50
51
  type NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }
51
52
 
52
- function permissiveInstanceUrlParse(url: string): string {
53
- if (!url.startsWith("http")) {
54
- url = `http://${url}`
55
- }
56
-
57
- return new URL(url).toString()
58
- }
59
-
60
53
  /**
61
54
  * Client for connecting to a Nova instance and controlling robots.
62
55
  * @deprecated The nova v1 client is deprecated. Please use the v2 client from `@wandelbots/nova-js/v2` instead.
@@ -82,9 +75,10 @@ export class NovaClient {
82
75
  if (this.config.instanceUrl === "https://mock.example.com") {
83
76
  this.mock = new MockNovaInstance()
84
77
  } else {
85
- this.config.instanceUrl = permissiveInstanceUrlParse(
78
+ this.config.instanceUrl = parseUrl(
86
79
  this.config.instanceUrl,
87
- )
80
+ { defaultScheme: "http" }
81
+ ).toString()
88
82
  }
89
83
 
90
84
  // Set up Axios instance with interceptor for token fetching
@@ -8,6 +8,7 @@ import { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket"
8
8
  import { availableStorage } from "../availableStorage"
9
9
  import { MockNovaInstance } from "./mock/MockNovaInstance"
10
10
  import { NovaCellAPIClient } from "./NovaCellAPIClient"
11
+ import { parseUrl } from "../.."
11
12
 
12
13
  export type NovaClientConfig = {
13
14
  /**
@@ -42,14 +43,6 @@ export type NovaClientConfig = {
42
43
 
43
44
  type NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }
44
45
 
45
- function permissiveInstanceUrlParse(url: string): string {
46
- if (!url.startsWith("http")) {
47
- url = `http://${url}`
48
- }
49
-
50
- return new URL(url).toString()
51
- }
52
-
53
46
  /**
54
47
  *
55
48
  * Client for connecting to a Nova instance and controlling robots.
@@ -75,9 +68,10 @@ export class NovaClient {
75
68
  if (this.config.instanceUrl === "https://mock.example.com") {
76
69
  this.mock = new MockNovaInstance()
77
70
  } else {
78
- this.config.instanceUrl = permissiveInstanceUrlParse(
71
+ this.config.instanceUrl = parseUrl(
79
72
  this.config.instanceUrl,
80
- )
73
+ { defaultScheme: "http" }
74
+ ).toString()
81
75
  }
82
76
 
83
77
  // Set up Axios instance with interceptor for token fetching