@wandelbots/nova-js 3.13.0-pr.307.dd54f61 → 3.13.0-pr.307.ea0533d

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 (45) hide show
  1. package/dist/{context-ffr5Q2dc.mjs → context-CmXqEEwW.mjs} +86 -3
  2. package/dist/context-CmXqEEwW.mjs.map +1 -0
  3. package/dist/{context-BZELA2eh.cjs → context-Cu5mXcFZ.cjs} +146 -3
  4. package/dist/context-Cu5mXcFZ.cjs.map +1 -0
  5. package/dist/experimental/nats/index.cjs +15 -84
  6. package/dist/experimental/nats/index.cjs.map +1 -1
  7. package/dist/experimental/nats/index.d.cts +10 -95
  8. package/dist/experimental/nats/index.d.cts.map +1 -1
  9. package/dist/experimental/nats/index.d.mts +10 -95
  10. package/dist/experimental/nats/index.d.mts.map +1 -1
  11. package/dist/experimental/nats/index.mjs +16 -84
  12. package/dist/experimental/nats/index.mjs.map +1 -1
  13. package/dist/index.cjs +12 -13
  14. package/dist/index.mjs +2 -3
  15. package/dist/v1/index.cjs +3 -3
  16. package/dist/v1/index.cjs.map +1 -1
  17. package/dist/v1/index.mjs +2 -2
  18. package/dist/v2/index.cjs +3 -4
  19. package/dist/v2/index.cjs.map +1 -1
  20. package/dist/v2/index.d.cts +83 -5
  21. package/dist/v2/index.d.cts.map +1 -1
  22. package/dist/v2/index.d.mts +82 -4
  23. package/dist/v2/index.d.mts.map +1 -1
  24. package/dist/v2/index.mjs +1 -2
  25. package/dist/v2/index.mjs.map +1 -1
  26. package/dist/{wandelscriptUtils-DcY1aLWu.cjs → wandelscriptUtils-BdqeVDCY.cjs} +12 -13
  27. package/dist/{wandelscriptUtils-DcY1aLWu.cjs.map → wandelscriptUtils-BdqeVDCY.cjs.map} +1 -1
  28. package/dist/{wandelscriptUtils-CpUXdLVc.mjs → wandelscriptUtils-CKhiZJsB.mjs} +2 -3
  29. package/dist/{wandelscriptUtils-CpUXdLVc.mjs.map → wandelscriptUtils-CKhiZJsB.mjs.map} +1 -1
  30. package/package.json +1 -1
  31. package/src/experimental/nats/index.ts +0 -3
  32. package/src/lib/experimental/nats/NovaNatsClient.ts +13 -67
  33. package/src/lib/experimental/nats/buildSubject.ts +5 -50
  34. package/src/lib/experimental/nats/generated/operations.ts +4 -64
  35. package/dist/Nova--8gozkLR.d.mts +0 -85
  36. package/dist/Nova--8gozkLR.d.mts.map +0 -1
  37. package/dist/Nova-B1o5iTQ6.d.cts +0 -85
  38. package/dist/Nova-B1o5iTQ6.d.cts.map +0 -1
  39. package/dist/context-BZELA2eh.cjs.map +0 -1
  40. package/dist/context-ffr5Q2dc.mjs.map +0 -1
  41. package/dist/converters-DnG1fX23.mjs +0 -87
  42. package/dist/converters-DnG1fX23.mjs.map +0 -1
  43. package/dist/converters-EYS27XJE.cjs +0 -146
  44. package/dist/converters-EYS27XJE.cjs.map +0 -1
  45. package/src/lib/experimental/nats/buildNatsServerUrl.ts +0 -15
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wandelbots/nova-js",
3
3
  "type": "module",
4
- "version": "3.13.0-pr.307.dd54f61",
4
+ "version": "3.13.0-pr.307.ea0533d",
5
5
  "description": "Official JS client for the Wandelbots API",
6
6
  "sideEffects": false,
7
7
  "packageManager": "pnpm@11.9.0+sha512.bd682d5d03fe525ef7c9fd6780c6884d1e756ac4c9c9fe00c538782824310dcf90e3ddc4f53835f06dfaebd5085e41855e0bcbb3b60de2ac5bbab89e5036f03b",
@@ -4,11 +4,8 @@
4
4
  *
5
5
  * This API is experimental and may change without a major version bump.
6
6
  */
7
- export { buildNatsServerUrl } from "../../lib/experimental/nats/buildNatsServerUrl.ts"
8
7
  export type {
9
8
  NatsOperationParams,
10
- NatsPublishPayloads,
11
- NatsPublishSubject,
12
9
  NatsReplyPayloads,
13
10
  NatsRequestPayloads,
14
11
  NatsRequestSubject,
@@ -4,13 +4,9 @@ import {
4
4
  type NatsConnection,
5
5
  wsconnect,
6
6
  } from "@nats-io/nats-core"
7
- import type { Nova } from "../../Nova.ts"
8
- import { buildNatsServerUrl } from "./buildNatsServerUrl.ts"
9
7
  import { buildSubject } from "./buildSubject.ts"
10
8
  import type {
11
9
  NatsOperationParams,
12
- NatsPublishPayloads,
13
- NatsPublishSubject,
14
10
  NatsReplyPayloads,
15
11
  NatsRequestPayloads,
16
12
  NatsRequestSubject,
@@ -20,16 +16,6 @@ import type {
20
16
 
21
17
  export type NovaNatsClientConfig = ConnectionOptions
22
18
 
23
- type NatsMessageHandler<K extends NatsSubscribeSubject> = (
24
- payload: NatsSubscribePayloads[K],
25
- msg: Msg,
26
- ) => void
27
-
28
- type SubscribeArgs<K extends NatsSubscribeSubject> =
29
- keyof NatsOperationParams[K] extends never
30
- ? [handler: NatsMessageHandler<K>]
31
- : [params: NatsOperationParams[K], handler: NatsMessageHandler<K>]
32
-
33
19
  /**
34
20
  * Typed NATS client for the Wandelbots NOVA messaging API, generated from
35
21
  * src/asyncapi.yaml (see scripts/generate-nats-client.ts).
@@ -38,42 +24,24 @@ type SubscribeArgs<K extends NatsSubscribeSubject> =
38
24
  */
39
25
  export class NovaNatsClient {
40
26
  readonly config: NovaNatsClientConfig
41
- private connectionPromise: Promise<NatsConnection> | null = null
27
+ connection: NatsConnection | null = null
42
28
 
43
- constructor(nova: Nova, config: NovaNatsClientConfig = {}) {
44
- this.config = {
45
- servers: buildNatsServerUrl(nova.instanceUrl.href),
46
- ...config,
47
- }
29
+ constructor(config: NovaNatsClientConfig) {
30
+ this.config = config
48
31
  }
49
32
 
50
- /**
51
- * Connects to NATS if not already connected or connecting, and returns the
52
- * connection. Safe to call concurrently: all callers share the same
53
- * in-flight connection attempt instead of each starting their own.
54
- */
55
- connect(): Promise<NatsConnection> {
56
- if (!this.connectionPromise) {
57
- this.connectionPromise = wsconnect(this.config).catch((err: unknown) => {
58
- // Allow a subsequent connect() call to retry after a failed attempt.
59
- this.connectionPromise = null
60
- throw err
61
- })
33
+ /** Connects to NATS if not already connected, and returns the connection. */
34
+ async connect(): Promise<NatsConnection> {
35
+ if (!this.connection) {
36
+ this.connection = await wsconnect(this.config)
62
37
  }
63
- return this.connectionPromise
38
+ return this.connection
64
39
  }
65
40
 
66
- /** Closes the underlying NATS connection, if open or connecting. */
41
+ /** Closes the underlying NATS connection, if open. */
67
42
  async close(): Promise<void> {
68
- const connectionPromise = this.connectionPromise
69
- this.connectionPromise = null
70
- if (!connectionPromise) return
71
- try {
72
- const nc = await connectionPromise
73
- await nc.close()
74
- } catch {
75
- // Connection never succeeded; nothing to close.
76
- }
43
+ await this.connection?.close()
44
+ this.connection = null
77
45
  }
78
46
 
79
47
  /**
@@ -88,13 +56,9 @@ export class NovaNatsClient {
88
56
  */
89
57
  async subscribe<K extends NatsSubscribeSubject>(
90
58
  subject: K,
91
- ...args: SubscribeArgs<K>
59
+ params: NatsOperationParams[K],
60
+ handler: (payload: NatsSubscribePayloads[K], msg: Msg) => void,
92
61
  ): Promise<() => void> {
93
- const [params, handler] =
94
- args.length === 1
95
- ? ([{}, args[0]] as const)
96
- : ([args[0], args[1]] as const)
97
-
98
62
  const nc = await this.connect()
99
63
  const resolvedSubject = buildSubject(subject, params)
100
64
  const sub = nc.subscribe(resolvedSubject)
@@ -134,22 +98,4 @@ export class NovaNatsClient {
134
98
  })
135
99
  return msg.json<NatsReplyPayloads[K]>()
136
100
  }
137
-
138
- /**
139
- * Publishes a JSON payload to any NATS subject defined in the spec,
140
- * without waiting for a reply.
141
- *
142
- * `subject` is the subject template as it appears on the wire, e.g.
143
- * `"nova.v2.cells.{cell}.bus-ios.ios.set"`, with `{param}` placeholders
144
- * filled in from `params`.
145
- */
146
- async publish<K extends NatsPublishSubject>(
147
- subject: K,
148
- params: NatsOperationParams[K],
149
- payload: NatsPublishPayloads[K],
150
- ): Promise<void> {
151
- const nc = await this.connect()
152
- const resolvedSubject = buildSubject(subject, params)
153
- nc.publish(resolvedSubject, JSON.stringify(payload))
154
- }
155
101
  }
@@ -3,67 +3,22 @@
3
3
  * (e.g. `"{instance}.v2.cells.{cell}"`) by substituting each `{param}`
4
4
  * placeholder with the corresponding value from `params`.
5
5
  */
6
-
7
- function isValidSubjectChar(char: string): boolean {
8
- const code = char.charCodeAt(0)
9
- return (
10
- (code >= 48 && code <= 57) || // 0-9
11
- (code >= 65 && code <= 90) || // A-Z
12
- (code >= 97 && code <= 122) || // a-z
13
- char === "-" ||
14
- char === "_" ||
15
- char === "*"
16
- )
17
- }
18
-
19
- function isValidSubjectValue(value: string): boolean {
20
- if (value.length === 0) return false
21
- for (const char of value) {
22
- if (!isValidSubjectChar(char)) return false
23
- }
24
- return true
25
- }
26
-
27
6
  export function buildSubject(
28
7
  template: string,
29
8
  params: Record<string, string>,
30
9
  ): string {
31
- // Scanned manually (rather than with a regex like /\{([^}]+)\}/g) to avoid
32
- // a polynomial-time backtracking blowup on pathological input, e.g. a
33
- // template consisting of many "{" characters with no closing "}".
34
- let result = ""
35
- let cursor = 0
36
-
37
- while (cursor < template.length) {
38
- const openIndex = template.indexOf("{", cursor)
39
- if (openIndex === -1) {
40
- result += template.slice(cursor)
41
- break
42
- }
43
-
44
- const closeIndex = template.indexOf("}", openIndex + 1)
45
- if (closeIndex === -1) {
46
- result += template.slice(cursor)
47
- break
48
- }
49
-
50
- result += template.slice(cursor, openIndex)
51
- const paramName = template.slice(openIndex + 1, closeIndex)
10
+ return template.replace(/\{([^}]+)\}/g, (match, paramName: string) => {
52
11
  const value = params[paramName]
53
12
  if (value === undefined) {
54
13
  throw new Error(
55
14
  `Missing value for subject parameter "${paramName}" in template "${template}"`,
56
15
  )
57
16
  }
58
- if (!isValidSubjectValue(value)) {
17
+ if (value === "" || /[\s.>*]/.test(value)) {
59
18
  throw new Error(
60
- `Invalid value for subject parameter "${paramName}": "${value}" (must be non-empty and contain only letters, digits, "-", and "_")`,
19
+ `Invalid value for subject parameter "${paramName}": "${value}" (must be non-empty and must not contain whitespace or the NATS special characters ".", ">", "*")`,
61
20
  )
62
21
  }
63
- result += value
64
-
65
- cursor = closeIndex + 1
66
- }
67
-
68
- return result
22
+ return value
23
+ })
69
24
  }
@@ -51,7 +51,7 @@ export interface NatsOperationParams {
51
51
  /** publishCellCycle */
52
52
  "nova.v2.cells.{cell}.cycle": { cell: string }
53
53
  /** publishSystemStatus */
54
- "nova.v2.system.status": Record<never, never>
54
+ "nova.v2.system.status": Record<string, never>
55
55
  /** publishCollisionSetup */
56
56
  "nova.v2.cells.{cell}.collision.setups.{setup}": {
57
57
  cell: string
@@ -85,11 +85,11 @@ export interface NatsOperationParams {
85
85
  "motion-group": string
86
86
  }
87
87
  /** eventSystemUpdateStarted */
88
- "nova.v2.events.system.update.started": Record<never, never>
88
+ "nova.v2.events.system.update.started": Record<string, never>
89
89
  /** eventSystemUpdateCompleted */
90
- "nova.v2.events.system.update.completed": Record<never, never>
90
+ "nova.v2.events.system.update.completed": Record<string, never>
91
91
  /** eventSystemNetworkStatusChanged */
92
- "nova.v2.events.system.network.status.changed": Record<never, never>
92
+ "nova.v2.events.system.network.status.changed": Record<string, never>
93
93
  /** eventCellCreated */
94
94
  "nova.v2.events.cells.{cell}.created": { cell: string }
95
95
  /** eventCellUpdated */
@@ -201,63 +201,3 @@ export interface NatsReplyPayloads {
201
201
  }
202
202
 
203
203
  export type NatsRequestSubject = keyof NatsRequestPayloads
204
-
205
- /** Payload types for every subject defined in the spec, publishable via NovaNatsClient#publish. */
206
- export interface NatsPublishPayloads {
207
- /** publishCell */
208
- "nova.v2.cells.{cell}": Cell
209
- /** publishApp */
210
- "nova.v2.cells.{cell}.apps.{app}": App
211
- /** publishProgramStatus */
212
- "nova.v2.cells.{cell}.programs": ProgramStatus
213
- /** publishRobotController */
214
- "nova.v2.cells.{cell}.controllers.{controller}": RobotController
215
- /** publishCellStatus */
216
- "nova.v2.cells.{cell}.status": ServiceStatusList
217
- /** publishCellCycle */
218
- "nova.v2.cells.{cell}.cycle": CellCycleEvent
219
- /** publishSystemStatus */
220
- "nova.v2.system.status": ServiceStatusList
221
- /** publishCollisionSetup */
222
- "nova.v2.cells.{cell}.collision.setups.{setup}": CollisionSetup
223
- /** publishBUSIOStatus */
224
- "nova.v2.cells.{cell}.bus-ios.status": BusIOsState
225
- /** publishBUSIOsIOs */
226
- "nova.v2.cells.{cell}.bus-ios.ios": ListIOValuesResponse
227
- /** setBUSIOsIOs */
228
- "nova.v2.cells.{cell}.bus-ios.ios.set": ListIOValuesResponse
229
- /** selectRobotControllerIOs */
230
- "nova.v2.cells.{cell}.controllers.{controller}.ios.select": SelectIOs
231
- /** publishRobotControllerIOs */
232
- "nova.v2.cells.{cell}.controllers.{controller}.ios": StreamIOValuesResponse
233
- /** publishRobotControllersState */
234
- "nova.v2.cells.{cell}.controllers.{controller}.state": RobotControllerState
235
- /** publishMotionGroupDescription */
236
- "nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description": MotionGroupDescription
237
- /** eventSystemUpdateStarted */
238
- "nova.v2.events.system.update.started": SystemUpdateStartedEvent
239
- /** eventSystemUpdateCompleted */
240
- "nova.v2.events.system.update.completed": SystemUpdateCompletedEvent
241
- /** eventSystemNetworkStatusChanged */
242
- "nova.v2.events.system.network.status.changed": NetworkStatusChangedEvent
243
- /** eventCellCreated */
244
- "nova.v2.events.cells.{cell}.created": CellCreatedEvent
245
- /** eventCellUpdated */
246
- "nova.v2.events.cells.{cell}.updated": CellUpdatedEvent
247
- /** eventCellDeleted */
248
- "nova.v2.events.cells.{cell}.deleted": CellDeletedEvent
249
- /** eventAppCreated */
250
- "nova.v2.events.cells.{cell}.apps.{app}.created": AppCreatedEvent
251
- /** eventAppUpdated */
252
- "nova.v2.events.cells.{cell}.apps.{app}.updated": AppUpdatedEvent
253
- /** eventAppDeleted */
254
- "nova.v2.events.cells.{cell}.apps.{app}.deleted": AppDeletedEvent
255
- /** eventRobotControllerCreated */
256
- "nova.v2.events.cells.{cell}.controllers.{controller}.created": RobotControllerCreatedEvent
257
- /** eventRobotControllerUpdated */
258
- "nova.v2.events.cells.{cell}.controllers.{controller}.updated": RobotControllerUpdatedEvent
259
- /** eventRobotControllerDeleted */
260
- "nova.v2.events.cells.{cell}.controllers.{controller}.deleted": RobotControllerDeletedEvent
261
- }
262
-
263
- export type NatsPublishSubject = keyof NatsPublishPayloads
@@ -1,85 +0,0 @@
1
- import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "./AutoReconnectingWebsocket-1K2J1NA4.mjs";
2
- import { AxiosInstance } from "axios";
3
- import { ApplicationApi, BUSInputsOutputsApi, CellApi, Configuration, ControllerApi, ControllerInputsOutputsApi, JoggingApi, KinematicsApi, LicenseApi, MotionGroupApi, MotionGroupModelsApi, NOVACloudApi, ProgramApi, RobotConfigurationsApi, SessionApi, StoreCollisionComponentsApi, StoreCollisionSetupsApi, StoreObjectApi, SystemApi, TrajectoryCachingApi, TrajectoryExecutionApi, TrajectoryPlanningApi, VersionApi, VirtualControllerApi, VirtualControllerBehaviorApi, VirtualControllerInputsOutputsApi } from "@wandelbots/nova-api/v2";
4
-
5
- //#region src/lib/NovaAPIClient.d.ts
6
- type UnwrapAxiosResponseReturn<T> = T extends ((...a: any[]) => any) ? (...a: Parameters<T>) => Promise<Awaited<ReturnType<T>> extends {
7
- data: infer D;
8
- } ? D : never> : never;
9
- type WithUnwrappedAxiosResponse<T> = { [P in keyof T]: UnwrapAxiosResponseReturn<T[P]> };
10
- type NovaAPIClientOpts = Configuration & {
11
- axiosInstance?: AxiosInstance;
12
- mock?: boolean;
13
- };
14
- /**
15
- * API client providing type-safe access to all the endpoints of a NOVA
16
- * instance.
17
- */
18
- declare class NovaAPIClient {
19
- readonly opts: NovaAPIClientOpts;
20
- readonly application: WithUnwrappedAxiosResponse<ApplicationApi>;
21
- readonly busIOs: WithUnwrappedAxiosResponse<BUSInputsOutputsApi>;
22
- readonly cell: WithUnwrappedAxiosResponse<CellApi>;
23
- readonly controller: WithUnwrappedAxiosResponse<ControllerApi>;
24
- readonly controllerIOs: WithUnwrappedAxiosResponse<ControllerInputsOutputsApi>;
25
- readonly jogging: WithUnwrappedAxiosResponse<JoggingApi>;
26
- readonly kinematics: WithUnwrappedAxiosResponse<KinematicsApi>;
27
- readonly license: WithUnwrappedAxiosResponse<LicenseApi>;
28
- readonly motionGroup: WithUnwrappedAxiosResponse<MotionGroupApi>;
29
- readonly motionGroupModels: WithUnwrappedAxiosResponse<MotionGroupModelsApi>;
30
- readonly novaCloud: WithUnwrappedAxiosResponse<NOVACloudApi>;
31
- readonly program: WithUnwrappedAxiosResponse<ProgramApi>;
32
- readonly robotConfigurations: WithUnwrappedAxiosResponse<RobotConfigurationsApi>;
33
- readonly session: WithUnwrappedAxiosResponse<SessionApi>;
34
- readonly storeCollisionComponents: WithUnwrappedAxiosResponse<StoreCollisionComponentsApi>;
35
- readonly storeCollisionSetups: WithUnwrappedAxiosResponse<StoreCollisionSetupsApi>;
36
- readonly storeObject: WithUnwrappedAxiosResponse<StoreObjectApi>;
37
- readonly system: WithUnwrappedAxiosResponse<SystemApi>;
38
- readonly trajectoryCaching: WithUnwrappedAxiosResponse<TrajectoryCachingApi>;
39
- readonly trajectoryExecution: WithUnwrappedAxiosResponse<TrajectoryExecutionApi>;
40
- readonly trajectoryPlanning: WithUnwrappedAxiosResponse<TrajectoryPlanningApi>;
41
- readonly version: WithUnwrappedAxiosResponse<VersionApi>;
42
- readonly virtualController: WithUnwrappedAxiosResponse<VirtualControllerApi>;
43
- readonly virtualControllerBehavior: WithUnwrappedAxiosResponse<VirtualControllerBehaviorApi>;
44
- readonly virtualControllerIOs: WithUnwrappedAxiosResponse<VirtualControllerInputsOutputsApi>;
45
- constructor(opts: NovaAPIClientOpts);
46
- }
47
- //#endregion
48
- //#region src/lib/Nova.d.ts
49
- type NovaConfig = {
50
- /**
51
- * Url of the deployed NOVA instance to connect to
52
- * e.g. https://saeattii.instance.wandelbots.io
53
- */
54
- instanceUrl: string;
55
- /**
56
- * Access token for Bearer authentication.
57
- * If running on a NOVA instance, this can be automatically retrieved from
58
- * the current session when omitted.
59
- */
60
- accessToken?: string;
61
- } & Omit<Configuration, "isJsonMime" | "basePath">;
62
- /**
63
- *
64
- * Client for connecting to a NOVA instance and controlling robots.
65
- */
66
- declare class Nova {
67
- readonly api: NovaAPIClient;
68
- readonly config: NovaConfig;
69
- readonly mock?: MockNovaInstance;
70
- readonly instanceUrl: URL;
71
- authPromise: Promise<string | null> | null;
72
- accessToken: string | null;
73
- constructor(config: NovaConfig);
74
- renewAuthentication(): Promise<void>;
75
- makeWebsocketURL(path: string): string;
76
- /**
77
- * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
78
- * If you explicitly want to reconnect an existing websocket, call `reconnect`
79
- * on the returned object.
80
- */
81
- openReconnectingWebsocket(path: string): AutoReconnectingWebsocket;
82
- }
83
- //#endregion
84
- export { NovaConfig as n, NovaAPIClient as r, Nova as t };
85
- //# sourceMappingURL=Nova--8gozkLR.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Nova--8gozkLR.d.mts","names":[],"sources":["../src/lib/NovaAPIClient.ts","../src/lib/Nova.ts"],"mappings":";;;;;KAmCK,yBAAA,MAA+B,CAAA,cAAc,CAAA,uBAEzC,CAAA,EAAG,UAAA,CAAW,CAAA,MACd,OAAA,CAAQ,OAAA,CAAQ,UAAA,CAAW,CAAA;EAAc,IAAA;AAAA,IAAkB,CAAA;AAAA,KAG/D,0BAAA,oBACS,CAAA,GAAI,yBAAA,CAA0B,CAAA,CAAE,CAAA;AAAA,KAGzC,iBAAA,GAAoB,aAAA;EACvB,aAAA,GAAgB,aAAa;EAC7B,IAAA;AAAA;;;;;cAuCW,aAAA;EAAA,SACF,IAAA,EAAM,iBAAA;EAAA,SAEN,WAAA,EAAa,0BAAA,CAA2B,cAAA;EAAA,SACxC,MAAA,EAAQ,0BAAA,CAA2B,mBAAA;EAAA,SACnC,IAAA,EAAM,0BAAA,CAA2B,OAAA;EAAA,SACjC,UAAA,EAAY,0BAAA,CAA2B,aAAA;EAAA,SACvC,aAAA,EAAe,0B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AA;EACb,WAAA;cAEY,MAAA,EAAQ,UAAA;EAqId,mBAAA,IAAuB,OAAA;EA4B7B,gBAAA,CAAiB,IAAA;EDlKkD;AAAA;;;;ECmLnE,yBAAA,CAA0B,IAAA,WAAY,yBAAA;AAAA"}
@@ -1,85 +0,0 @@
1
- import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "./AutoReconnectingWebsocket-1K2J1NA4.cjs";
2
- import { ApplicationApi, BUSInputsOutputsApi, CellApi, Configuration, ControllerApi, ControllerInputsOutputsApi, JoggingApi, KinematicsApi, LicenseApi, MotionGroupApi, MotionGroupModelsApi, NOVACloudApi, ProgramApi, RobotConfigurationsApi, SessionApi, StoreCollisionComponentsApi, StoreCollisionSetupsApi, StoreObjectApi, SystemApi, TrajectoryCachingApi, TrajectoryExecutionApi, TrajectoryPlanningApi, VersionApi, VirtualControllerApi, VirtualControllerBehaviorApi, VirtualControllerInputsOutputsApi } from "@wandelbots/nova-api/v2";
3
- import { AxiosInstance } from "axios";
4
-
5
- //#region src/lib/NovaAPIClient.d.ts
6
- type UnwrapAxiosResponseReturn<T> = T extends ((...a: any[]) => any) ? (...a: Parameters<T>) => Promise<Awaited<ReturnType<T>> extends {
7
- data: infer D;
8
- } ? D : never> : never;
9
- type WithUnwrappedAxiosResponse<T> = { [P in keyof T]: UnwrapAxiosResponseReturn<T[P]> };
10
- type NovaAPIClientOpts = Configuration & {
11
- axiosInstance?: AxiosInstance;
12
- mock?: boolean;
13
- };
14
- /**
15
- * API client providing type-safe access to all the endpoints of a NOVA
16
- * instance.
17
- */
18
- declare class NovaAPIClient {
19
- readonly opts: NovaAPIClientOpts;
20
- readonly application: WithUnwrappedAxiosResponse<ApplicationApi>;
21
- readonly busIOs: WithUnwrappedAxiosResponse<BUSInputsOutputsApi>;
22
- readonly cell: WithUnwrappedAxiosResponse<CellApi>;
23
- readonly controller: WithUnwrappedAxiosResponse<ControllerApi>;
24
- readonly controllerIOs: WithUnwrappedAxiosResponse<ControllerInputsOutputsApi>;
25
- readonly jogging: WithUnwrappedAxiosResponse<JoggingApi>;
26
- readonly kinematics: WithUnwrappedAxiosResponse<KinematicsApi>;
27
- readonly license: WithUnwrappedAxiosResponse<LicenseApi>;
28
- readonly motionGroup: WithUnwrappedAxiosResponse<MotionGroupApi>;
29
- readonly motionGroupModels: WithUnwrappedAxiosResponse<MotionGroupModelsApi>;
30
- readonly novaCloud: WithUnwrappedAxiosResponse<NOVACloudApi>;
31
- readonly program: WithUnwrappedAxiosResponse<ProgramApi>;
32
- readonly robotConfigurations: WithUnwrappedAxiosResponse<RobotConfigurationsApi>;
33
- readonly session: WithUnwrappedAxiosResponse<SessionApi>;
34
- readonly storeCollisionComponents: WithUnwrappedAxiosResponse<StoreCollisionComponentsApi>;
35
- readonly storeCollisionSetups: WithUnwrappedAxiosResponse<StoreCollisionSetupsApi>;
36
- readonly storeObject: WithUnwrappedAxiosResponse<StoreObjectApi>;
37
- readonly system: WithUnwrappedAxiosResponse<SystemApi>;
38
- readonly trajectoryCaching: WithUnwrappedAxiosResponse<TrajectoryCachingApi>;
39
- readonly trajectoryExecution: WithUnwrappedAxiosResponse<TrajectoryExecutionApi>;
40
- readonly trajectoryPlanning: WithUnwrappedAxiosResponse<TrajectoryPlanningApi>;
41
- readonly version: WithUnwrappedAxiosResponse<VersionApi>;
42
- readonly virtualController: WithUnwrappedAxiosResponse<VirtualControllerApi>;
43
- readonly virtualControllerBehavior: WithUnwrappedAxiosResponse<VirtualControllerBehaviorApi>;
44
- readonly virtualControllerIOs: WithUnwrappedAxiosResponse<VirtualControllerInputsOutputsApi>;
45
- constructor(opts: NovaAPIClientOpts);
46
- }
47
- //#endregion
48
- //#region src/lib/Nova.d.ts
49
- type NovaConfig = {
50
- /**
51
- * Url of the deployed NOVA instance to connect to
52
- * e.g. https://saeattii.instance.wandelbots.io
53
- */
54
- instanceUrl: string;
55
- /**
56
- * Access token for Bearer authentication.
57
- * If running on a NOVA instance, this can be automatically retrieved from
58
- * the current session when omitted.
59
- */
60
- accessToken?: string;
61
- } & Omit<Configuration, "isJsonMime" | "basePath">;
62
- /**
63
- *
64
- * Client for connecting to a NOVA instance and controlling robots.
65
- */
66
- declare class Nova {
67
- readonly api: NovaAPIClient;
68
- readonly config: NovaConfig;
69
- readonly mock?: MockNovaInstance;
70
- readonly instanceUrl: URL;
71
- authPromise: Promise<string | null> | null;
72
- accessToken: string | null;
73
- constructor(config: NovaConfig);
74
- renewAuthentication(): Promise<void>;
75
- makeWebsocketURL(path: string): string;
76
- /**
77
- * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
78
- * If you explicitly want to reconnect an existing websocket, call `reconnect`
79
- * on the returned object.
80
- */
81
- openReconnectingWebsocket(path: string): AutoReconnectingWebsocket;
82
- }
83
- //#endregion
84
- export { NovaConfig as n, NovaAPIClient as r, Nova as t };
85
- //# sourceMappingURL=Nova-B1o5iTQ6.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Nova-B1o5iTQ6.d.cts","names":[],"sources":["../src/lib/NovaAPIClient.ts","../src/lib/Nova.ts"],"mappings":";;;;;KAmCK,yBAAA,MAA+B,CAAA,cAAc,CAAA,uBAEzC,CAAA,EAAG,UAAA,CAAW,CAAA,MACd,OAAA,CAAQ,OAAA,CAAQ,UAAA,CAAW,CAAA;EAAc,IAAA;AAAA,IAAkB,CAAA;AAAA,KAG/D,0BAAA,oBACS,CAAA,GAAI,yBAAA,CAA0B,CAAA,CAAE,CAAA;AAAA,KAGzC,iBAAA,GAAoB,aAAA;EACvB,aAAA,GAAgB,aAAa;EAC7B,IAAA;AAAA;;;;;cAuCW,aAAA;EAAA,SACF,IAAA,EAAM,iBAAA;EAAA,SAEN,WAAA,EAAa,0BAAA,CAA2B,cAAA;EAAA,SACxC,MAAA,EAAQ,0BAAA,CAA2B,mBAAA;EAAA,SACnC,IAAA,EAAM,0BAAA,CAA2B,OAAA;EAAA,SACjC,UAAA,EAAY,0BAAA,CAA2B,aAAA;EAAA,SACvC,aAAA,EA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Aa,OAAA;EACb,WAAA;cAEY,MAAA,EAAQ,UAAA;EAqId,mBAAA,IAAuB,OAAA;EA4B7B,gBAAA,CAAiB,IAAA;EDlKkD;AAAA;;;;ECmLnE,yBAAA,CAA0B,IAAA,WAAY,yBAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-BZELA2eh.cjs","names":["ReconnectingWebSocket","tryStringifyJson"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/errorHandling.ts","../src/lib/LoginWithAuth0.ts","../src/lib/context.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./deprecated/v1/mock/MockNovaInstance.ts\"\nimport type * as v2 from \"./mock/MockNovaInstance.ts\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }\n\n constructor(\n targetUrl: string,\n opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n this.opts = opts\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","import { isAxiosError } from \"axios\"\nimport { tryStringifyJson } from \"./converters.ts\"\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\n/**\n * Reloads the page with protection against loops.\n * Allows at most one reload per 10 seconds; otherwise throws\n * an error.\n */\nexport function guardedPageReload(key: string): Promise<never> {\n const RELOAD_KEY = `novajs_reload_guard:${key}`\n const RELOAD_COOLDOWN_MS = 10_000\n const lastReloadAt = Number(window.sessionStorage.getItem(RELOAD_KEY) ?? \"0\")\n\n if (Date.now() - lastReloadAt < RELOAD_COOLDOWN_MS) {\n throw new Error(\n `Unhandled error caused a reload (${key}), but a reload was already attempted recently. Aborting to prevent reload loop.`,\n )\n }\n\n window.sessionStorage.setItem(RELOAD_KEY, String(Date.now()))\n window.location.reload()\n\n return new Promise(() => {}) // never settles, the page should be reloading\n}\n","import { guardedPageReload } from \"./errorHandling.ts\"\n\n/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n return guardedPageReload(\"cloud_instance_auth\")\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n","// Some general checks about the context the nova-js code is running in\n\nexport const isBrowser = typeof window !== \"undefined\"\n\nexport const isLocalhostDev =\n isBrowser &&\n window.location.hostname === \"localhost\" &&\n process.env.NODE_ENV === \"development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,eAAe,WAAW;CAE9C,MAAM,cAAc,IAAI,YAAY;EAClC,QAAQ,YAAY;EACpB,UAAU,YAAY,YAAY;EAClC,kBAAkB;EAClB,qBAAqB;GACnB,UAAU;GACV,cAAc,OAAO,SAAS;EAChC;CACF,CAAC;CAGD,IACE,OAAO,SAAS,OAAO,SAAS,OAAO,KACvC,OAAO,SAAS,OAAO,SAAS,QAAQ,GACxC;EACA,MAAM,EAAE,aAAa,MAAM,YAAY,uBAAuB;EAE9D,OAAO,QAAQ,aACb,CAAC,GACD,SAAS,OACT,UAAU,YAAY,OAAO,SAAS,QACxC;CACF,OAEE,MAAM,YAAY,kBAAkB;CAKtC,OAAO,MADmB,YAAY,iBAAiB;AAEzD;;;ACzFA,MAAa,YAAY,OAAO,WAAW;AAE3C,MAAa,iBACX,aACA,OAAO,SAAS,aAAa,eAC7B,QAAQ,IAAI,aAAa"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-ffr5Q2dc.mjs","names":[],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/errorHandling.ts","../src/lib/LoginWithAuth0.ts","../src/lib/context.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./deprecated/v1/mock/MockNovaInstance.ts\"\nimport type * as v2 from \"./mock/MockNovaInstance.ts\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }\n\n constructor(\n targetUrl: string,\n opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n this.opts = opts\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","import { isAxiosError } from \"axios\"\nimport { tryStringifyJson } from \"./converters.ts\"\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\n/**\n * Reloads the page with protection against loops.\n * Allows at most one reload per 10 seconds; otherwise throws\n * an error.\n */\nexport function guardedPageReload(key: string): Promise<never> {\n const RELOAD_KEY = `novajs_reload_guard:${key}`\n const RELOAD_COOLDOWN_MS = 10_000\n const lastReloadAt = Number(window.sessionStorage.getItem(RELOAD_KEY) ?? \"0\")\n\n if (Date.now() - lastReloadAt < RELOAD_COOLDOWN_MS) {\n throw new Error(\n `Unhandled error caused a reload (${key}), but a reload was already attempted recently. Aborting to prevent reload loop.`,\n )\n }\n\n window.sessionStorage.setItem(RELOAD_KEY, String(Date.now()))\n window.location.reload()\n\n return new Promise(() => {}) // never settles, the page should be reloading\n}\n","import { guardedPageReload } from \"./errorHandling.ts\"\n\n/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n return guardedPageReload(\"cloud_instance_auth\")\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n","// Some general checks about the context the nova-js code is running in\n\nexport const isBrowser = typeof window !== \"undefined\"\n\nexport const isLocalhostDev =\n isBrowser &&\n window.location.hostname === \"localhost\" &&\n process.env.NODE_ENV === \"development\"\n"],"mappings":";;;;AAIA,IAAa,4BAAb,cAA+C,sBAAsB;CACnE;CACA;CACA,WAAW;CACX;CAKA,YACE,WACA,OAGI,CAAC,GACL;EACA,QAAQ,IAAI,wBAAwB,SAAS;EAE7C,YAAY,KAAK,aAAa,WAAW,KAAA,GAAW,EAClD,aAAa,KACf,CAAC;EAGD,OAAO,eAAe,MAAM,OAAO,EACjC,MAAM;GACJ,OAAO,KAAK;EACd,EACF,CAAC;EAED,KAAK,YAAY;EACjB,KAAK,OAAO;EAEZ,KAAK,iBAAiB,cAAc;GAClC,QAAQ,IAAI,gBAAgB,KAAK,IAAI,QAAQ;EAC/C,CAAC;EAED,KAAK,iBAAiB,YAAY,OAAO;GACvC,IAAI,CAAC,KAAK,sBACR,KAAK,uBAAuB;EAEhC,CAAC;EAED,KAAK,iBAAiB,eAAe;GACnC,QAAQ,IAAI,gBAAgB,KAAK,IAAI,QAAQ;EAC/C,CAAC;EAED,MAAM,gBAAgB,KAAK;EAC3B,KAAK,kBAAkB;GACrB,IAAI,KAAK,KAAK,MACZ,KAAK,KAAK,KAAK,0BAA0B,IAAI;QAE7C,cAAc,MAAM,IAAI;EAE5B;EAEA,KAAK,UAAU;CACjB;CAEA,UAAU,WAAmB;EAC3B,KAAK,uBAAuB,KAAA;EAC5B,KAAK,YAAY;EACjB,KAAK,UAAU;CACjB;CAEA,SAAS,MAAe;EACtB,IAAI,KAAK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