@shapediver/sdk.platform-api-sdk-v1 2.18.12 → 2.23.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdPlatformSdkErrorMapping.d.ts","sourceRoot":"","sources":["../../src/api/SdPlatformSdkErrorMapping.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAiB,MAAM,OAAO,CAAA;AACxD,OACA,EACI,eAAe,EAelB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"SdPlatformSdkErrorMapping.d.ts","sourceRoot":"","sources":["../../src/api/SdPlatformSdkErrorMapping.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAiB,MAAM,OAAO,CAAA;AACxD,OACA,EACI,eAAe,EAelB,MAAM,qBAAqB,CAAA;AA4E5B;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,GAAG,eAAe,CA+JxE"}
|
|
@@ -18,6 +18,9 @@ function isValidationError(response) {
|
|
|
18
18
|
function isGeometryBackendResponseError(response) {
|
|
19
19
|
return ("error" in response) && ("desc" in response);
|
|
20
20
|
}
|
|
21
|
+
function period(message) {
|
|
22
|
+
return message.endsWith(".") ? message : message + ".";
|
|
23
|
+
}
|
|
21
24
|
/**
|
|
22
25
|
* Maps the given error into a ShapeDiver API response error object.
|
|
23
26
|
*/
|
|
@@ -36,35 +39,41 @@ function mapToApiError(error) {
|
|
|
36
39
|
}
|
|
37
40
|
else if (data && isOAuthResponseError(data)) {
|
|
38
41
|
if (data.error == "invalid_client") {
|
|
39
|
-
return new SdPlatformErrors_1.SdPlatformInvalidClientOAuthResponseError(`${data.error}
|
|
42
|
+
return new SdPlatformErrors_1.SdPlatformInvalidClientOAuthResponseError(`${period(data.error)} ${period(data.error_description)}`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
40
43
|
}
|
|
41
44
|
else if (data.error == "invalid_request") {
|
|
42
|
-
return new SdPlatformErrors_1.SdPlatformInvalidRequestOAuthResponseError(`${data.error}
|
|
45
|
+
return new SdPlatformErrors_1.SdPlatformInvalidRequestOAuthResponseError(`${period(data.error)} ${period(data.error_description)}`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
43
46
|
}
|
|
44
47
|
else if (data.error == "invalid_grant") {
|
|
45
|
-
return new SdPlatformErrors_1.SdPlatformInvalidGrantOAuthResponseError(`${data.error}
|
|
48
|
+
return new SdPlatformErrors_1.SdPlatformInvalidGrantOAuthResponseError(`${period(data.error)} ${period(data.error_description)}`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
46
49
|
}
|
|
47
50
|
else if (data.error == "unauthorized_client") {
|
|
48
|
-
return new SdPlatformErrors_1.SdPlatformUnauthorizedClientOAuthResponseError(`${data.error}
|
|
51
|
+
return new SdPlatformErrors_1.SdPlatformUnauthorizedClientOAuthResponseError(`${period(data.error)} ${period(data.error_description)}`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
49
52
|
}
|
|
50
53
|
else if (data.error == "unsupported_grant_type") {
|
|
51
|
-
return new SdPlatformErrors_1.SdPlatformUnsupportedGrantTypeClientOAuthResponseError(`${data.error}
|
|
54
|
+
return new SdPlatformErrors_1.SdPlatformUnsupportedGrantTypeClientOAuthResponseError(`${period(data.error)} ${period(data.error_description)}`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
52
55
|
}
|
|
53
|
-
return new SdPlatformErrors_1.SdPlatformOAuthResponseError(`${data.error}
|
|
56
|
+
return new SdPlatformErrors_1.SdPlatformOAuthResponseError(`${period(data.error)} ${period(data.error_description)}`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
54
57
|
}
|
|
55
58
|
else if (data && isResourceResponseError(data)) {
|
|
56
59
|
if (isValidationError(data)) {
|
|
57
|
-
|
|
60
|
+
const fields = Object.entries(data.error.fields).reduce((acc, [key, value]) => {
|
|
61
|
+
acc[key] = Array.isArray(value) ? value : [value];
|
|
62
|
+
return acc;
|
|
63
|
+
}, {});
|
|
64
|
+
const fieldsMessage = Object.values(fields).map((msgs) => msgs.map(m => period(m)).join(" ")).join(" ");
|
|
65
|
+
const message = `${period(data.error.message)} ${period(data.error.description)}`;
|
|
66
|
+
return new SdPlatformErrors_1.SdPlatformValidationResponseError(fieldsMessage ? `${message} ${fieldsMessage}` : message, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code, fields);
|
|
58
67
|
}
|
|
59
68
|
switch (axiosError.response.status) {
|
|
60
69
|
case 404:
|
|
61
|
-
return new SdPlatformErrors_1.SdPlatformNotFoundResponseError(`${data.error.message}
|
|
70
|
+
return new SdPlatformErrors_1.SdPlatformNotFoundResponseError(`${period(data.error.message)} ${period(data.error.description)}`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
62
71
|
case 403:
|
|
63
|
-
return new SdPlatformErrors_1.SdPlatformForbiddenResponseError(`${data.error.message}
|
|
72
|
+
return new SdPlatformErrors_1.SdPlatformForbiddenResponseError(`${period(data.error.message)} ${period(data.error.description)}`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
64
73
|
case 401:
|
|
65
|
-
return new SdPlatformErrors_1.SdPlatformUnauthorizedResponseError(`${data.error.message}
|
|
74
|
+
return new SdPlatformErrors_1.SdPlatformUnauthorizedResponseError(`${period(data.error.message)} ${period(data.error.description)}`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
66
75
|
default:
|
|
67
|
-
return new SdPlatformErrors_1.SdPlatformResourceResponseError(`${data.error.message}
|
|
76
|
+
return new SdPlatformErrors_1.SdPlatformResourceResponseError(`${period(data.error.message)} ${period(data.error.description)}`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
else if (data && isGeometryBackendResponseError(data)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdPlatformSdkErrorMapping.js","sourceRoot":"","sources":["../../src/api/SdPlatformSdkErrorMapping.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAwD;AACxD,0DAiB4B;AAmD5B,SAAS,oBAAoB,CAAC,QAAa;IAEvC,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,mBAAmB,IAAI,QAAQ,CAAC,CAAA;AACrE,CAAC;AAED,SAAS,uBAAuB,CAAC,QAAa;IAE1C,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAE,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC1G,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAa;IAEpC,OAAO,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,8BAA8B,CAAC,QAAa;IAEjD,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAA;AACxD,CAAC;
|
|
1
|
+
{"version":3,"file":"SdPlatformSdkErrorMapping.js","sourceRoot":"","sources":["../../src/api/SdPlatformSdkErrorMapping.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAwD;AACxD,0DAiB4B;AAmD5B,SAAS,oBAAoB,CAAC,QAAa;IAEvC,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,mBAAmB,IAAI,QAAQ,CAAC,CAAA;AACrE,CAAC;AAED,SAAS,uBAAuB,CAAC,QAAa;IAE1C,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAE,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC1G,CAAC;AAED,SAAS,i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CAAC;AA/JD,sCA+JC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/sdk.platform-api-sdk-v1",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "SDK to communicate with the Platform API version 1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapediver",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"post-publish": "bash ../../scripts/post-publish.sh"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@shapediver/api.platform-api-dto-v1": "~2.
|
|
41
|
+
"@shapediver/api.platform-api-dto-v1": "~2.23.0",
|
|
42
42
|
"@shapediver/api.geometry-api-dto-v2": "~1.11.0",
|
|
43
43
|
"axios": "^0.26.1",
|
|
44
44
|
"jwt-decode": "~3.1.2"
|