@wandelbots/nova-js 2.0.0 → 2.0.1
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.
- package/dist/LoginWithAuth0.d.ts.map +1 -1
- package/dist/chunk-6WCKJOFL.js +1030 -0
- package/dist/chunk-6WCKJOFL.js.map +1 -0
- package/dist/index.cjs +112 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/errorHandling.d.ts +11 -0
- package/dist/lib/errorHandling.d.ts.map +1 -1
- package/dist/lib/v1/index.js +3 -1022
- package/dist/lib/v1/index.js.map +1 -1
- package/package.json +9 -9
- package/src/lib/errorHandling.ts +30 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/nova-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "Official JS client for the Wandelbots API",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -47,21 +47,21 @@
|
|
|
47
47
|
"husky": "^9.1.7",
|
|
48
48
|
"nodemon": "^3.1.9",
|
|
49
49
|
"prettier-eslint": "^16.3.0",
|
|
50
|
-
"semantic-release": "^24.2.
|
|
51
|
-
"tsup": "^8.
|
|
52
|
-
"typescript": "^5.
|
|
50
|
+
"semantic-release": "^24.2.3",
|
|
51
|
+
"tsup": "^8.4.0",
|
|
52
|
+
"typescript": "^5.8.2",
|
|
53
53
|
"vitest": "^2.0.2",
|
|
54
|
-
"ws": "^8.18.
|
|
54
|
+
"ws": "^8.18.1"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@auth0/auth0-spa-js": "^2.1.3",
|
|
58
|
-
"@types/three": "^0.
|
|
58
|
+
"@types/three": "^0.174.0",
|
|
59
59
|
"@wandelbots/nova-api": "^25.3.0-dev.29",
|
|
60
|
-
"axios": "^1.
|
|
61
|
-
"mobx": "^6.13.
|
|
60
|
+
"axios": "^1.8.1",
|
|
61
|
+
"mobx": "^6.13.6",
|
|
62
62
|
"path-to-regexp": "^8.2.0",
|
|
63
63
|
"reconnecting-websocket": "^4.4.0",
|
|
64
|
-
"three": "^0.
|
|
64
|
+
"three": "^0.174.0",
|
|
65
65
|
"url-join": "^5.0.0"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/lib/errorHandling.ts
CHANGED
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
import { AxiosError } from "axios"
|
|
2
|
+
import { isObject, isString } from "lodash-es"
|
|
2
3
|
import { tryStringifyJson } from "./converters"
|
|
3
4
|
|
|
4
5
|
export function delay(ms: number) {
|
|
5
6
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
6
7
|
}
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @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
|
|
11
|
+
*/
|
|
8
12
|
export function makeShortErrorMessage(err: unknown) {
|
|
9
|
-
|
|
10
|
-
return `${err.response?.status} ${err.response?.statusText}: ${JSON.stringify(err.response?.data)}`
|
|
11
|
-
} else if (err instanceof Error) {
|
|
12
|
-
return err.message
|
|
13
|
-
} else {
|
|
14
|
-
return `Unexpected error: ${err}`
|
|
15
|
-
}
|
|
13
|
+
return makeErrorMessage(err)
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Attempts to make a helpful error message from an unknown thrown error
|
|
18
|
+
* or promise rejection.
|
|
19
|
+
*
|
|
20
|
+
* This function is mainly to aid debugging and good bug reports. For
|
|
21
|
+
* expected errors encountered by end users, it's more ideal to catch
|
|
22
|
+
* the specific error code and provide a localized app-specific error message.
|
|
23
|
+
*/
|
|
24
|
+
export function makeErrorMessage(err: unknown): string {
|
|
25
|
+
if (err instanceof AxiosError) {
|
|
26
|
+
if (err.response) {
|
|
27
|
+
return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`
|
|
28
|
+
} else if (err.config) {
|
|
29
|
+
if (err.code === "ERR_NETWORK") {
|
|
30
|
+
return `${err.message} from ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`
|
|
31
|
+
} else {
|
|
32
|
+
return `${err.message} from ${err.config.url}`
|
|
33
|
+
}
|
|
34
|
+
}
|
|
21
35
|
} else if (err instanceof Error) {
|
|
22
36
|
return err.message
|
|
23
|
-
} else {
|
|
24
|
-
return
|
|
37
|
+
} else if (isString(err)) {
|
|
38
|
+
return err
|
|
39
|
+
} else if (isObject(err)) {
|
|
40
|
+
return tryStringifyJson(err) || `Unserializable object ${err}`
|
|
25
41
|
}
|
|
42
|
+
|
|
43
|
+
return `${err}`
|
|
26
44
|
}
|