@sap-ux/axios-extension 1.14.0 → 1.14.2

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.
@@ -8,6 +8,24 @@ export interface App extends Record<string, unknown> {
8
8
  url: string;
9
9
  }
10
10
  export type AppIndex = Partial<App>[];
11
+ export type AsyncHintsLib = {
12
+ name: string;
13
+ };
14
+ export type AsyncHintsRequest = {
15
+ name: string;
16
+ reference: string;
17
+ };
18
+ export type Ui5AppInfo = Record<string, Ui5AppInfoContent>;
19
+ export interface Ui5AppInfoContent {
20
+ name: string;
21
+ url: string;
22
+ manifestUrl?: string;
23
+ manifest?: string;
24
+ asyncHints: {
25
+ libs: AsyncHintsLib[];
26
+ requests: AsyncHintsRequest[];
27
+ };
28
+ }
11
29
  /**
12
30
  * A class representing the app index service allowing to search applications deployed on an ABAP system.
13
31
  */
@@ -24,5 +42,12 @@ export declare abstract class AppIndexService extends Axios implements Service {
24
42
  search(searchParams?: {
25
43
  [property: string]: string;
26
44
  }, resultFields?: string[]): Promise<AppIndex>;
45
+ /**
46
+ * Gets the app info for the specified id.
47
+ *
48
+ * @param {string} appId - The id of the app.
49
+ * @returns {Promise<Ui5AppInfo>} App info.
50
+ */
51
+ getAppInfo(appId: string): Promise<Ui5AppInfo>;
27
52
  }
28
53
  //# sourceMappingURL=app-index-service.d.ts.map
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AppIndexService = void 0;
13
13
  const axios_1 = require("axios");
14
+ const odata_request_error_1 = require("../base/odata-request-error");
14
15
  /**
15
16
  * A class representing the app index service allowing to search applications deployed on an ABAP system.
16
17
  */
@@ -32,6 +33,30 @@ class AppIndexService extends axios_1.Axios {
32
33
  return JSON.parse(response.data).results;
33
34
  });
34
35
  }
36
+ /**
37
+ * Gets the app info for the specified id.
38
+ *
39
+ * @param {string} appId - The id of the app.
40
+ * @returns {Promise<Ui5AppInfo>} App info.
41
+ */
42
+ getAppInfo(appId) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ const response = yield this.get('/ui5_app_info_json', { params: { id: appId } });
46
+ return JSON.parse(response.data);
47
+ }
48
+ catch (error) {
49
+ if ((0, odata_request_error_1.isAxiosError)(error)) {
50
+ this.log.error(`Failed fetching ui5_app_info_json for app with id ${appId}.`);
51
+ }
52
+ else {
53
+ this.log.error(`Parsing error: ui5_app_info_json is not in expected format for app with id ${appId}.`);
54
+ }
55
+ this.log.debug(error);
56
+ throw error;
57
+ }
58
+ });
59
+ }
35
60
  }
36
61
  exports.AppIndexService = AppIndexService;
37
62
  AppIndexService.PATH = '/sap/bc/ui2/app_index';
@@ -20,6 +20,14 @@ export interface ODataServiceV2Info {
20
20
  export declare class V2CatalogService extends CatalogService {
21
21
  static readonly PATH = "/sap/opu/odata/IWFND/CATALOGSERVICE;v=2";
22
22
  protected determineEntitySet(): Promise<void>;
23
+ /**
24
+ * Returns the service path for the provided serivce URL.
25
+ *
26
+ * @param serviceUrl - service url (may be full service url or service path)
27
+ * @param baseUrl - base url for the odata service
28
+ * @returns - service path
29
+ */
30
+ private getServicePath;
23
31
  /**
24
32
  * Map the V2 service information to a version independent structure.
25
33
  *
@@ -28,6 +28,24 @@ class V2CatalogService extends base_1.CatalogService {
28
28
  : V2_CLASSIC_ENTITYSET;
29
29
  });
30
30
  }
31
+ /**
32
+ * Returns the service path for the provided serivce URL.
33
+ *
34
+ * @param serviceUrl - service url (may be full service url or service path)
35
+ * @param baseUrl - base url for the odata service
36
+ * @returns - service path
37
+ */
38
+ getServicePath(serviceUrl, baseUrl) {
39
+ let parsedUrl;
40
+ try {
41
+ parsedUrl = new URL(serviceUrl);
42
+ }
43
+ catch (_a) {
44
+ // there are cases where the service url is just the path and not the full service url
45
+ parsedUrl = new URL(serviceUrl, baseUrl);
46
+ }
47
+ return parsedUrl.pathname;
48
+ }
31
49
  /**
32
50
  * Map the V2 service information to a version independent structure.
33
51
  *
@@ -36,10 +54,11 @@ class V2CatalogService extends base_1.CatalogService {
36
54
  */
37
55
  mapServices(services) {
38
56
  return services.map((service) => {
57
+ const path = this.getServicePath(service.ServiceUrl, this.defaults.baseURL);
39
58
  return {
40
59
  id: service.ID,
41
60
  name: service.TechnicalServiceName,
42
- path: new URL(service.ServiceUrl).pathname,
61
+ path: path,
43
62
  serviceVersion: service.TechnicalServiceVersion + '',
44
63
  odataVersion: odata_service_1.ODataVersion.v2
45
64
  };
@@ -1,7 +1,7 @@
1
1
  export { AppInfo, BspConfig, DeployConfig, Ui5AbapRepositoryService, UndeployConfig } from './ui5-abap-repository-service';
2
2
  export { LayeredRepositoryService, AdaptationConfig, MergedAppDescriptor } from './lrep-service';
3
3
  export { AbapServiceProvider } from './abap-service-provider';
4
- export { AppIndex, AppIndexService } from './app-index-service';
4
+ export { AppIndex, AppIndexService, Ui5AppInfo } from './app-index-service';
5
5
  export * from './message';
6
6
  export * from './catalog';
7
7
  export * from './adt-catalog';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/axios-extension",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
4
4
  "description": "Extension of the Axios module adding convenience methods to interact with SAP systems especially with OData services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  "@types/lodash": "4.14.202",
30
30
  "nock": "13.4.0",
31
31
  "supertest": "6.3.3",
32
- "@sap-ux/project-access": "1.22.2"
32
+ "@sap-ux/project-access": "1.22.3"
33
33
  },
34
34
  "files": [
35
35
  "dist",