@sap-ux/axios-extension 0.9.0 → 0.9.3

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.
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.V2CatalogService = void 0;
13
13
  const base_1 = require("./base");
14
14
  const odata_service_1 = require("../../base/odata-service");
15
+ const odata_request_error_1 = require("../../base/odata-request-error");
15
16
  const V2_CLASSIC_ENTITYSET = 'ServiceCollection';
16
17
  const V2_RECOMMENDED_ENTITYSET = 'RecommendedServiceCollection';
17
18
  const V2_S4CLOUD_FILTER = '((IsSapService%20eq%20true)and(ReleaseStatus%20eq%20%27RELEASED%27))or((IsSapService%20eq%20false))';
@@ -61,7 +62,12 @@ class V2CatalogService extends base_1.CatalogService {
61
62
  params['$filter'] = V2_S4CLOUD_FILTER;
62
63
  }
63
64
  const response = yield this.get(`/${this.entitySet}`, { params });
64
- return this.mapServices(response.odata());
65
+ const data = response.odata();
66
+ // check if the service responded with an odata error
67
+ if (odata_request_error_1.ODataRequestError.containsError(data)) {
68
+ throw new odata_request_error_1.ODataRequestError(data);
69
+ }
70
+ return this.mapServices(data);
65
71
  });
66
72
  }
67
73
  /**
@@ -82,7 +88,7 @@ class V2CatalogService extends base_1.CatalogService {
82
88
  }
83
89
  const params = {
84
90
  $format: 'json',
85
- $filter: `Title%20eq%20%27${title}%27`
91
+ $filter: `Title eq '${title}'`
86
92
  };
87
93
  const response = yield this.get(`/${this.entitySet}`, { params });
88
94
  const services = response.odata();
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.V4CatalogService = void 0;
13
13
  const base_1 = require("./base");
14
14
  const odata_service_1 = require("../../base/odata-service");
15
+ const odata_request_error_1 = require("../../base/odata-request-error");
15
16
  const V4_RECOMMENDED_ENTITYSET = 'RecommendedServices';
16
17
  const V4_CLASSIC_ENTITYSET = 'Services';
17
18
  /**
@@ -71,6 +72,10 @@ class V4CatalogService extends base_1.CatalogService {
71
72
  response = yield _super.get.call(this, '/ServiceGroups', { params: Object.assign(Object.assign({}, params), nextLink.searchParams) });
72
73
  serviceGroups.push(...response.odata());
73
74
  }
75
+ // check if the service responded with an odata error
76
+ if (odata_request_error_1.ODataRequestError.containsError(serviceGroups)) {
77
+ throw new odata_request_error_1.ODataRequestError(serviceGroups);
78
+ }
74
79
  return this.mapServices(serviceGroups, this.entitySet);
75
80
  });
76
81
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Interface describing the structure of an odata error.
3
+ */
4
+ export interface ODataError {
5
+ '@SAP__common.ExceptionCategory'?: string;
6
+ code: string;
7
+ message: string;
8
+ }
9
+ /**
10
+ * Error object that is to be thrown if an OData service responds with an error
11
+ */
12
+ export declare class ODataRequestError extends Error {
13
+ static containsError(odata: unknown): boolean;
14
+ constructor(responseData: unknown);
15
+ }
16
+ //# sourceMappingURL=odata-request-error.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ODataRequestError = void 0;
4
+ /**
5
+ * Error object that is to be thrown if an OData service responds with an error
6
+ */
7
+ class ODataRequestError extends Error {
8
+ static containsError(odata) {
9
+ if (odata === null || odata === void 0 ? void 0 : odata['error']) {
10
+ return true;
11
+ }
12
+ else {
13
+ return false;
14
+ }
15
+ }
16
+ constructor(responseData) {
17
+ const error = responseData['error'];
18
+ super(`${error.message} (${error.code})`);
19
+ }
20
+ }
21
+ exports.ODataRequestError = ODataRequestError;
22
+ //# sourceMappingURL=odata-request-error.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/axios-extension",
3
- "version": "0.9.0",
3
+ "version": "0.9.3",
4
4
  "description": "Extension of the Axios module adding convinience methods to interact with SAP systems especially with OData services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "private": false,
15
15
  "main": "dist/index.js",
16
16
  "dependencies": {
17
- "@sap-ux/btp-utils": "0.10.3",
17
+ "@sap-ux/btp-utils": "0.10.4",
18
18
  "@sap-ux/logger": "0.2.2",
19
19
  "axios": "0.24.0",
20
20
  "detect-content-type": "1.2.0",