@sap-ux/adp-tooling 0.18.0 → 0.18.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.
@@ -1,19 +1,19 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
- import type { CfConfig, CFApp, CfCredentials } from '../../types';
2
+ import type { CfConfig, CFApp, ServiceKeys } from '../../types';
3
3
  /**
4
4
  * Get the app host ids.
5
5
  *
6
- * @param {CfCredentials[]} credentials - The credentials.
6
+ * @param {ServiceKeys[]} serviceKeys - The service keys.
7
7
  * @returns {string[]} The app host ids.
8
8
  */
9
- export declare function getAppHostIds(credentials: CfCredentials[]): string[];
9
+ export declare function getAppHostIds(serviceKeys: ServiceKeys[]): string[];
10
10
  /**
11
11
  * Discover apps from FDC API based on credentials.
12
12
  *
13
- * @param {CfCredentials[]} credentials - The credentials containing app host IDs
13
+ * @param {ServiceKeys[]} serviceKeys - The service keys containing app host IDs
14
14
  * @param {CfConfig} cfConfig - The CF configuration
15
15
  * @param {ToolsLogger} logger - The logger
16
16
  * @returns {Promise<CFApp[]>} The discovered apps
17
17
  */
18
- export declare function getCfApps(credentials: CfCredentials[], cfConfig: CfConfig, logger: ToolsLogger): Promise<CFApp[]>;
18
+ export declare function getCfApps(serviceKeys: ServiceKeys[], cfConfig: CfConfig, logger: ToolsLogger): Promise<CFApp[]>;
19
19
  //# sourceMappingURL=discovery.d.ts.map
@@ -7,13 +7,13 @@ const api_1 = require("../services/api");
7
7
  /**
8
8
  * Get the app host ids.
9
9
  *
10
- * @param {CfCredentials[]} credentials - The credentials.
10
+ * @param {ServiceKeys[]} serviceKeys - The service keys.
11
11
  * @returns {string[]} The app host ids.
12
12
  */
13
- function getAppHostIds(credentials) {
13
+ function getAppHostIds(serviceKeys) {
14
14
  const appHostIds = [];
15
- for (const credential of credentials) {
16
- const appHostId = credential['html5-apps-repo']?.app_host_id;
15
+ for (const serviceKey of serviceKeys) {
16
+ const appHostId = serviceKey.credentials['html5-apps-repo']?.app_host_id;
17
17
  if (appHostId) {
18
18
  // There might be multiple appHostIds separated by comma
19
19
  const ids = appHostId.split(',').map((item) => item.trim());
@@ -25,13 +25,13 @@ function getAppHostIds(credentials) {
25
25
  /**
26
26
  * Discover apps from FDC API based on credentials.
27
27
  *
28
- * @param {CfCredentials[]} credentials - The credentials containing app host IDs
28
+ * @param {ServiceKeys[]} serviceKeys - The service keys containing app host IDs
29
29
  * @param {CfConfig} cfConfig - The CF configuration
30
30
  * @param {ToolsLogger} logger - The logger
31
31
  * @returns {Promise<CFApp[]>} The discovered apps
32
32
  */
33
- async function getCfApps(credentials, cfConfig, logger) {
34
- const appHostIds = getAppHostIds(credentials);
33
+ async function getCfApps(serviceKeys, cfConfig, logger) {
34
+ const appHostIds = getAppHostIds(serviceKeys);
35
35
  logger?.log(`App Host Ids: ${JSON.stringify(appHostIds)}`);
36
36
  // Validate appHostIds array length (max 100 as per API specification)
37
37
  if (appHostIds.length > 100) {
@@ -1,5 +1,5 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
- import type { HTML5Content, ServiceKeys, Uaa, CfAppParams } from '../../types';
2
+ import type { HTML5Content, ServiceInfo, Uaa, CfAppParams } from '../../types';
3
3
  /**
4
4
  * Get the OAuth token from HTML5 repository.
5
5
  *
@@ -21,9 +21,9 @@ export declare function downloadZip(token: string, appHostId: string, uri: strin
21
21
  *
22
22
  * @param {string} spaceGuid space guid
23
23
  * @param {ToolsLogger} logger logger to log messages
24
- * @returns {Promise<ServiceKeys>} credentials json object
24
+ * @returns {Promise<ServiceInfo>} credentials json object
25
25
  */
26
- export declare function getHtml5RepoCredentials(spaceGuid: string, logger: ToolsLogger): Promise<ServiceKeys>;
26
+ export declare function getHtml5RepoCredentials(spaceGuid: string, logger: ToolsLogger): Promise<ServiceInfo>;
27
27
  /**
28
28
  * Download base app manifest.json and xs-app.json from HTML5 repository.
29
29
  *
@@ -64,27 +64,27 @@ async function downloadZip(token, appHostId, uri) {
64
64
  *
65
65
  * @param {string} spaceGuid space guid
66
66
  * @param {ToolsLogger} logger logger to log messages
67
- * @returns {Promise<ServiceKeys>} credentials json object
67
+ * @returns {Promise<ServiceInfo>} credentials json object
68
68
  */
69
69
  async function getHtml5RepoCredentials(spaceGuid, logger) {
70
70
  try {
71
- let serviceKeys = await (0, api_1.getServiceInstanceKeys)({
71
+ let serviceInfo = await (0, api_1.getServiceInstanceKeys)({
72
72
  spaceGuids: [spaceGuid],
73
73
  planNames: ['app-runtime'],
74
74
  names: [HTML5_APPS_REPO_RUNTIME]
75
75
  }, logger);
76
- if (!serviceKeys?.credentials?.length) {
76
+ if (!serviceInfo?.serviceKeys?.length) {
77
77
  const serviceName = await (0, api_1.getServiceNameByTags)(spaceGuid, ['html5-apps-repo-rt']);
78
78
  await (0, api_1.createServiceInstance)('app-runtime', HTML5_APPS_REPO_RUNTIME, serviceName, {
79
79
  logger
80
80
  });
81
- serviceKeys = await (0, api_1.getServiceInstanceKeys)({ names: [HTML5_APPS_REPO_RUNTIME] }, logger);
82
- if (!serviceKeys?.credentials?.length) {
81
+ serviceInfo = await (0, api_1.getServiceInstanceKeys)({ names: [HTML5_APPS_REPO_RUNTIME] }, logger);
82
+ if (!serviceInfo?.serviceKeys?.length) {
83
83
  logger.debug((0, i18n_1.t)('error.noUaaCredentialsFoundForHtml5Repo'));
84
84
  throw new Error((0, i18n_1.t)('error.cannotFindHtml5RepoRuntime'));
85
85
  }
86
86
  }
87
- return serviceKeys;
87
+ return serviceInfo;
88
88
  }
89
89
  catch (e) {
90
90
  throw new Error((0, i18n_1.t)('error.failedToGetCredentialsFromHtml5Repo', { error: e.message }));
@@ -102,9 +102,9 @@ async function downloadAppContent(spaceGuid, parameters, logger) {
102
102
  const { appHostId, appName, appVersion } = parameters;
103
103
  const appNameVersion = `${appName}-${appVersion}`;
104
104
  try {
105
- const htmlRepoCredentials = await getHtml5RepoCredentials(spaceGuid, logger);
106
- const token = await getToken(htmlRepoCredentials?.credentials[0]?.uaa);
107
- const uri = `${htmlRepoCredentials?.credentials[0]?.uri}/applications/content/${appNameVersion}?pathSuffixFilter=manifest.json,xs-app.json`;
105
+ const { serviceKeys, serviceInstance } = await getHtml5RepoCredentials(spaceGuid, logger);
106
+ const token = await getToken(serviceKeys[0]?.credentials.uaa);
107
+ const uri = `${serviceKeys[0]?.credentials.uri}/applications/content/${appNameVersion}?pathSuffixFilter=manifest.json,xs-app.json`;
108
108
  const zip = await downloadZip(token, appHostId, uri);
109
109
  let admZip;
110
110
  try {
@@ -124,7 +124,7 @@ async function downloadAppContent(spaceGuid, parameters, logger) {
124
124
  const manifest = JSON.parse(zipEntry.getData().toString('utf8'));
125
125
  return {
126
126
  entries: admZip.getEntries(),
127
- serviceInstanceGuid: htmlRepoCredentials.serviceInstance.guid,
127
+ serviceInstanceGuid: serviceInstance.guid,
128
128
  manifest: manifest
129
129
  };
130
130
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isExternalLoginEnabled = isExternalLoginEnabled;
4
4
  exports.isLoggedInCf = isLoggedInCf;
5
- const CFLocal = require("@sap/cf-tools/out/src/cf-local");
5
+ const cf_tools_1 = require("@sap/cf-tools");
6
6
  /**
7
7
  * Check if the external login is enabled.
8
8
  *
@@ -26,7 +26,7 @@ async function isLoggedInCf(cfConfig, logger) {
26
26
  return false;
27
27
  }
28
28
  try {
29
- const orgs = (await CFLocal.cfGetAvailableOrgs());
29
+ const orgs = await (0, cf_tools_1.cfGetAvailableOrgs)();
30
30
  logger?.log(`Available organizations: ${JSON.stringify(orgs)}`);
31
31
  return true;
32
32
  }
@@ -1,19 +1,19 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
- import type { CfConfig, CFApp, RequestArguments, ServiceKeys, GetServiceInstanceParams, MtaYaml } from '../../types';
2
+ import type { CfConfig, CFApp, RequestArguments, GetServiceInstanceParams, MtaYaml, ServiceInfo } from '../../types';
3
3
  interface CreateServiceOptions {
4
4
  xsSecurityProjectName?: string;
5
5
  templatePathOverwrite?: string;
6
6
  logger?: ToolsLogger;
7
7
  }
8
8
  /**
9
- * Get the business service keys.
9
+ * Get the business service info.
10
10
  *
11
11
  * @param {string} businessService - The business service.
12
12
  * @param {CfConfig} config - The CF config.
13
13
  * @param {ToolsLogger} logger - The logger.
14
- * @returns {Promise<ServiceKeys | null>} The service keys.
14
+ * @returns {Promise<ServiceInfo | null>} The service info.
15
15
  */
16
- export declare function getBusinessServiceKeys(businessService: string, config: CfConfig, logger: ToolsLogger): Promise<ServiceKeys | null>;
16
+ export declare function getBusinessServiceInfo(businessService: string, config: CfConfig, logger: ToolsLogger): Promise<ServiceInfo | null>;
17
17
  /**
18
18
  * Get the FDC request arguments.
19
19
  *
@@ -64,8 +64,8 @@ export declare function createServices(yamlContent: MtaYaml, initialServices: st
64
64
  *
65
65
  * @param {GetServiceInstanceParams} serviceInstanceQuery - The service instance query.
66
66
  * @param {ToolsLogger} logger - The logger.
67
- * @returns {Promise<ServiceKeys | null>} The service instance keys.
67
+ * @returns {Promise<ServiceInfo | null>} The service instance keys.
68
68
  */
69
- export declare function getServiceInstanceKeys(serviceInstanceQuery: GetServiceInstanceParams, logger: ToolsLogger): Promise<ServiceKeys | null>;
69
+ export declare function getServiceInstanceKeys(serviceInstanceQuery: GetServiceInstanceParams, logger: ToolsLogger): Promise<ServiceInfo | null>;
70
70
  export {};
71
71
  //# sourceMappingURL=api.d.ts.map
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getBusinessServiceKeys = getBusinessServiceKeys;
39
+ exports.getBusinessServiceInfo = getBusinessServiceInfo;
40
40
  exports.getFDCRequestArguments = getFDCRequestArguments;
41
41
  exports.getFDCApps = getFDCApps;
42
42
  exports.createServiceInstance = createServiceInstance;
@@ -46,7 +46,7 @@ exports.getServiceInstanceKeys = getServiceInstanceKeys;
46
46
  const fs = __importStar(require("node:fs"));
47
47
  const axios_1 = __importDefault(require("axios"));
48
48
  const path = __importStar(require("node:path"));
49
- const CFToolsCli = require("@sap/cf-tools/out/src/cli");
49
+ const cf_tools_1 = require("@sap/cf-tools");
50
50
  const btp_utils_1 = require("@sap-ux/btp-utils");
51
51
  const i18n_1 = require("../../i18n");
52
52
  const project_1 = require("../project");
@@ -57,14 +57,14 @@ const PARAM_MAP = new Map([
57
57
  ['names', 'names']
58
58
  ]);
59
59
  /**
60
- * Get the business service keys.
60
+ * Get the business service info.
61
61
  *
62
62
  * @param {string} businessService - The business service.
63
63
  * @param {CfConfig} config - The CF config.
64
64
  * @param {ToolsLogger} logger - The logger.
65
- * @returns {Promise<ServiceKeys | null>} The service keys.
65
+ * @returns {Promise<ServiceInfo | null>} The service info.
66
66
  */
67
- async function getBusinessServiceKeys(businessService, config, logger) {
67
+ async function getBusinessServiceInfo(businessService, config, logger) {
68
68
  const serviceKeys = await getServiceInstanceKeys({
69
69
  spaceGuids: [config.space.GUID],
70
70
  names: [businessService]
@@ -171,7 +171,7 @@ async function createServiceInstance(plan, serviceInstanceName, serviceName, opt
171
171
  }
172
172
  commandParameters.push('-c', JSON.stringify(xsSecurity));
173
173
  }
174
- await CFToolsCli.Cli.execute(commandParameters);
174
+ await cf_tools_1.Cli.execute(commandParameters);
175
175
  logger?.log(`Service instance '${serviceInstanceName}' created successfully`);
176
176
  }
177
177
  catch (e) {
@@ -227,7 +227,7 @@ async function createServices(yamlContent, initialServices, timestamp, templateP
227
227
  *
228
228
  * @param {GetServiceInstanceParams} serviceInstanceQuery - The service instance query.
229
229
  * @param {ToolsLogger} logger - The logger.
230
- * @returns {Promise<ServiceKeys | null>} The service instance keys.
230
+ * @returns {Promise<ServiceInfo | null>} The service instance keys.
231
231
  */
232
232
  async function getServiceInstanceKeys(serviceInstanceQuery, logger) {
233
233
  try {
@@ -236,7 +236,7 @@ async function getServiceInstanceKeys(serviceInstanceQuery, logger) {
236
236
  // We can use any instance in the list to connect to HTML5 Repo
237
237
  logger?.log(`Use '${serviceInstances[0].name}' HTML5 Repo instance`);
238
238
  return {
239
- credentials: await getOrCreateServiceKeys(serviceInstances[0], logger),
239
+ serviceKeys: await getOrCreateServiceKeys(serviceInstances[0], logger),
240
240
  serviceInstance: serviceInstances[0]
241
241
  };
242
242
  }
@@ -279,7 +279,7 @@ async function getServiceInstance(params) {
279
279
  *
280
280
  * @param {ServiceInstance} serviceInstance - The service instance.
281
281
  * @param {ToolsLogger} logger - The logger.
282
- * @returns {Promise<ServiceKeys | null>} The service instance keys.
282
+ * @returns {Promise<ServiceKeys[]>} The service instance keys.
283
283
  */
284
284
  async function getOrCreateServiceKeys(serviceInstance, logger) {
285
285
  const serviceInstanceName = serviceInstance.name;
@@ -1,5 +1,5 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
- import type { CfCredentials } from '../../types';
2
+ import type { ServiceKeys } from '../../types';
3
3
  /**
4
4
  * Checks if Cloud Foundry is installed.
5
5
  *
@@ -11,9 +11,9 @@ export declare function isCfInstalled(logger: ToolsLogger): Promise<boolean>;
11
11
  * Gets the service instance credentials.
12
12
  *
13
13
  * @param {string} serviceInstanceGuid - The service instance GUID.
14
- * @returns {Promise<CfCredentials[]>} The service instance credentials.
14
+ * @returns {Promise<ServiceKeys[]>} The service instance credentials.
15
15
  */
16
- export declare function getServiceKeys(serviceInstanceGuid: string): Promise<CfCredentials[]>;
16
+ export declare function getServiceKeys(serviceInstanceGuid: string): Promise<ServiceKeys[]>;
17
17
  /**
18
18
  * Creates a service key.
19
19
  *
@@ -4,9 +4,7 @@ exports.isCfInstalled = isCfInstalled;
4
4
  exports.getServiceKeys = getServiceKeys;
5
5
  exports.createServiceKey = createServiceKey;
6
6
  exports.requestCfApi = requestCfApi;
7
- const CFLocal = require("@sap/cf-tools/out/src/cf-local");
8
- const CFToolsCli = require("@sap/cf-tools/out/src/cli");
9
- const types_1 = require("@sap/cf-tools/out/src/types");
7
+ const cf_tools_1 = require("@sap/cf-tools");
10
8
  const i18n_1 = require("../../i18n");
11
9
  const ENV = { env: { 'CF_COLOR': 'false' } };
12
10
  /**
@@ -17,7 +15,7 @@ const ENV = { env: { 'CF_COLOR': 'false' } };
17
15
  */
18
16
  async function isCfInstalled(logger) {
19
17
  try {
20
- const response = await CFToolsCli.Cli.execute(['version'], ENV);
18
+ const response = await cf_tools_1.Cli.execute(['version'], ENV);
21
19
  if (response.exitCode !== 0) {
22
20
  throw new Error(response.stderr);
23
21
  }
@@ -32,16 +30,15 @@ async function isCfInstalled(logger) {
32
30
  * Gets the service instance credentials.
33
31
  *
34
32
  * @param {string} serviceInstanceGuid - The service instance GUID.
35
- * @returns {Promise<CfCredentials[]>} The service instance credentials.
33
+ * @returns {Promise<ServiceKeys[]>} The service instance credentials.
36
34
  */
37
35
  async function getServiceKeys(serviceInstanceGuid) {
38
36
  try {
39
- return await CFLocal.cfGetInstanceCredentials({
37
+ return await (0, cf_tools_1.cfGetInstanceCredentials)({
40
38
  filters: [
41
39
  {
42
40
  value: serviceInstanceGuid,
43
- // key: eFilters.service_instance_guid
44
- key: types_1.eFilters.service_instance_guid
41
+ key: cf_tools_1.eFilters.service_instance_guids
45
42
  }
46
43
  ]
47
44
  });
@@ -58,7 +55,7 @@ async function getServiceKeys(serviceInstanceGuid) {
58
55
  */
59
56
  async function createServiceKey(serviceInstanceName, serviceKeyName) {
60
57
  try {
61
- const cliResult = await CFToolsCli.Cli.execute(['create-service-key', serviceInstanceName, serviceKeyName], ENV);
58
+ const cliResult = await cf_tools_1.Cli.execute(['create-service-key', serviceInstanceName, serviceKeyName], ENV);
62
59
  if (cliResult.exitCode !== 0) {
63
60
  throw new Error(cliResult.stderr);
64
61
  }
@@ -75,7 +72,7 @@ async function createServiceKey(serviceInstanceName, serviceKeyName) {
75
72
  */
76
73
  async function requestCfApi(url) {
77
74
  try {
78
- const response = await CFToolsCli.Cli.execute(['curl', url], ENV);
75
+ const response = await cf_tools_1.Cli.execute(['curl', url], ENV);
79
76
  if (response.exitCode === 0) {
80
77
  try {
81
78
  return JSON.parse(response.stdout);
@@ -1,7 +1,7 @@
1
1
  import type AdmZip from 'adm-zip';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
3
  import type { Manifest } from '@sap-ux/project-access';
4
- import type { CfCredentials, XsApp } from '../../types';
4
+ import type { ServiceKeys, XsApp } from '../../types';
5
5
  /**
6
6
  * Validate the smart template application.
7
7
  *
@@ -29,9 +29,9 @@ export declare function extractXSApp(zipEntries: AdmZip.IZipEntry[]): XsApp | un
29
29
  * Validate the OData endpoints, data sources and routes.
30
30
  *
31
31
  * @param {AdmZip.IZipEntry[]} zipEntries - The zip entries.
32
- * @param {CfCredentials[]} credentials - The credentials.
32
+ * @param {ServiceKeys[]} serviceKeys - The service keys.
33
33
  * @param {ToolsLogger} logger - The logger.
34
34
  * @returns {Promise<string[]>} The messages.
35
35
  */
36
- export declare function validateODataEndpoints(zipEntries: AdmZip.IZipEntry[], credentials: CfCredentials[], logger: ToolsLogger): Promise<void>;
36
+ export declare function validateODataEndpoints(zipEntries: AdmZip.IZipEntry[], serviceKeys: ServiceKeys[], logger: ToolsLogger): Promise<void>;
37
37
  //# sourceMappingURL=validation.d.ts.map
@@ -91,11 +91,11 @@ function matchRoutesAndDatasources(dataSources, routes, serviceKeyEndpoints) {
91
91
  * Validate the OData endpoints, data sources and routes.
92
92
  *
93
93
  * @param {AdmZip.IZipEntry[]} zipEntries - The zip entries.
94
- * @param {CfCredentials[]} credentials - The credentials.
94
+ * @param {ServiceKeys[]} serviceKeys - The service keys.
95
95
  * @param {ToolsLogger} logger - The logger.
96
96
  * @returns {Promise<string[]>} The messages.
97
97
  */
98
- async function validateODataEndpoints(zipEntries, credentials, logger) {
98
+ async function validateODataEndpoints(zipEntries, serviceKeys, logger) {
99
99
  const messages = [];
100
100
  let xsApp;
101
101
  try {
@@ -116,7 +116,7 @@ async function validateODataEndpoints(zipEntries, credentials, logger) {
116
116
  const dataSources = manifest?.['sap.app']?.dataSources;
117
117
  const routes = xsApp?.routes;
118
118
  if (dataSources && routes) {
119
- const serviceKeyEndpoints = [].concat(...credentials.map((item) => (item.endpoints ? Object.keys(item.endpoints) : [])));
119
+ const serviceKeyEndpoints = [].concat(...serviceKeys.map(({ credentials }) => (credentials.endpoints ? Object.keys(credentials.endpoints) : [])));
120
120
  messages.push(...matchRoutesAndDatasources(dataSources, routes, serviceKeyEndpoints));
121
121
  }
122
122
  else if (routes && !dataSources) {
package/dist/types.d.ts CHANGED
@@ -740,14 +740,16 @@ export interface CfAppParams {
740
740
  export interface AppParamsExtended extends CfAppParams {
741
741
  spaceGuid: string;
742
742
  }
743
- export interface CfCredentials {
744
- [key: string]: any;
745
- uaa: Uaa;
746
- uri: string;
747
- endpoints: any;
748
- }
749
743
  export interface ServiceKeys {
750
- credentials: CfCredentials[];
744
+ credentials: {
745
+ [key: string]: any;
746
+ uaa: Uaa;
747
+ uri: string;
748
+ endpoints: any;
749
+ };
750
+ }
751
+ export interface ServiceInfo {
752
+ serviceKeys: ServiceKeys[];
751
753
  serviceInstance: ServiceInstance;
752
754
  }
753
755
  export interface HTML5Content {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.18.0",
12
+ "version": "0.18.1",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@sap-devx/yeoman-ui-types": "1.16.9",
27
- "@sap/cf-tools": "0.8.1",
27
+ "@sap/cf-tools": "3.2.2",
28
28
  "adm-zip": "0.5.10",
29
29
  "axios": "1.12.2",
30
30
  "ejs": "3.1.10",