@sap-ux/adp-tooling 0.19.11 → 1.0.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.
Files changed (147) hide show
  1. package/dist/abap/client.d.ts +1 -1
  2. package/dist/abap/client.js +8 -13
  3. package/dist/abap/config.js +5 -8
  4. package/dist/abap/index.d.ts +3 -3
  5. package/dist/abap/index.js +3 -19
  6. package/dist/abap/provider.js +5 -8
  7. package/dist/base/abap/manifest-service.d.ts +1 -1
  8. package/dist/base/abap/manifest-service.js +9 -18
  9. package/dist/base/cf.js +8 -11
  10. package/dist/base/change-utils.d.ts +1 -1
  11. package/dist/base/change-utils.js +49 -62
  12. package/dist/base/constants/index.js +12 -15
  13. package/dist/base/credentials.d.ts +2 -2
  14. package/dist/base/credentials.js +6 -9
  15. package/dist/base/helper.d.ts +1 -1
  16. package/dist/base/helper.js +40 -57
  17. package/dist/base/project-builder.js +3 -6
  18. package/dist/base/prompt.d.ts +1 -1
  19. package/dist/base/prompt.js +19 -25
  20. package/dist/btp/api.d.ts +1 -1
  21. package/dist/btp/api.js +10 -18
  22. package/dist/btp/index.d.ts +1 -1
  23. package/dist/btp/index.js +1 -17
  24. package/dist/cf/app/discovery.d.ts +1 -1
  25. package/dist/cf/app/discovery.js +11 -18
  26. package/dist/cf/app/html5-repo.d.ts +1 -1
  27. package/dist/cf/app/html5-repo.js +24 -32
  28. package/dist/cf/app/index.d.ts +2 -2
  29. package/dist/cf/app/index.js +2 -18
  30. package/dist/cf/core/auth.d.ts +1 -1
  31. package/dist/cf/core/auth.js +4 -8
  32. package/dist/cf/core/config.d.ts +1 -1
  33. package/dist/cf/core/config.js +9 -15
  34. package/dist/cf/core/index.d.ts +2 -2
  35. package/dist/cf/core/index.js +2 -18
  36. package/dist/cf/deploy.d.ts +1 -1
  37. package/dist/cf/deploy.js +33 -44
  38. package/dist/cf/index.d.ts +6 -6
  39. package/dist/cf/index.js +6 -22
  40. package/dist/cf/project/index.d.ts +3 -3
  41. package/dist/cf/project/index.js +3 -19
  42. package/dist/cf/project/mta.d.ts +1 -1
  43. package/dist/cf/project/mta.js +23 -66
  44. package/dist/cf/project/yaml-loader.d.ts +1 -1
  45. package/dist/cf/project/yaml-loader.js +8 -16
  46. package/dist/cf/project/yaml.d.ts +2 -2
  47. package/dist/cf/project/yaml.js +28 -72
  48. package/dist/cf/services/api.d.ts +1 -1
  49. package/dist/cf/services/api.js +46 -93
  50. package/dist/cf/services/cli.d.ts +1 -1
  51. package/dist/cf/services/cli.js +31 -42
  52. package/dist/cf/services/destinations.js +12 -48
  53. package/dist/cf/services/index.d.ts +5 -5
  54. package/dist/cf/services/index.js +5 -21
  55. package/dist/cf/services/manifest.d.ts +1 -1
  56. package/dist/cf/services/manifest.js +9 -13
  57. package/dist/cf/services/ssh.js +14 -22
  58. package/dist/cf/utils/index.d.ts +1 -1
  59. package/dist/cf/utils/index.js +1 -17
  60. package/dist/cf/utils/validation.d.ts +1 -1
  61. package/dist/cf/utils/validation.js +12 -18
  62. package/dist/common/flp-parameters.d.ts +1 -1
  63. package/dist/common/flp-parameters.js +1 -4
  64. package/dist/common/index.d.ts +1 -1
  65. package/dist/common/index.js +1 -17
  66. package/dist/i18n.js +8 -16
  67. package/dist/index.d.ts +23 -23
  68. package/dist/index.js +23 -46
  69. package/dist/preview/adp-preview.d.ts +1 -1
  70. package/dist/preview/adp-preview.js +41 -39
  71. package/dist/preview/change-handler.d.ts +1 -1
  72. package/dist/preview/change-handler.js +51 -59
  73. package/dist/preview/descriptor-change-handler.d.ts +1 -1
  74. package/dist/preview/descriptor-change-handler.js +18 -21
  75. package/dist/preview/ovp-routes-handler.js +11 -13
  76. package/dist/preview/routes-handler.js +36 -71
  77. package/dist/preview/utils.d.ts +1 -1
  78. package/dist/preview/utils.js +5 -8
  79. package/dist/prompts/add-annotations-to-odata/index.d.ts +1 -1
  80. package/dist/prompts/add-annotations-to-odata/index.js +24 -26
  81. package/dist/prompts/add-component-usages/index.d.ts +1 -1
  82. package/dist/prompts/add-component-usages/index.js +41 -43
  83. package/dist/prompts/add-new-model/index.d.ts +1 -1
  84. package/dist/prompts/add-new-model/index.js +75 -80
  85. package/dist/prompts/change-data-source/index.d.ts +1 -1
  86. package/dist/prompts/change-data-source/index.js +19 -22
  87. package/dist/prompts/change-inbound/index.d.ts +1 -1
  88. package/dist/prompts/change-inbound/index.js +11 -14
  89. package/dist/prompts/index.d.ts +5 -5
  90. package/dist/prompts/index.js +5 -15
  91. package/dist/source/applications.d.ts +2 -2
  92. package/dist/source/applications.js +7 -11
  93. package/dist/source/index.d.ts +3 -3
  94. package/dist/source/index.js +3 -19
  95. package/dist/source/manifest.d.ts +1 -1
  96. package/dist/source/manifest.js +15 -25
  97. package/dist/source/systems.d.ts +1 -1
  98. package/dist/source/systems.js +20 -27
  99. package/dist/types.d.ts +1 -1
  100. package/dist/types.js +64 -17
  101. package/dist/ui5/fetch.d.ts +1 -1
  102. package/dist/ui5/fetch.js +8 -12
  103. package/dist/ui5/format.d.ts +1 -1
  104. package/dist/ui5/format.js +17 -29
  105. package/dist/ui5/index.d.ts +4 -4
  106. package/dist/ui5/index.js +4 -20
  107. package/dist/ui5/network.d.ts +1 -1
  108. package/dist/ui5/network.js +1 -4
  109. package/dist/ui5/validator.js +14 -20
  110. package/dist/ui5/version-info.d.ts +1 -1
  111. package/dist/ui5/version-info.js +25 -36
  112. package/dist/writer/cf.d.ts +1 -1
  113. package/dist/writer/cf.js +35 -43
  114. package/dist/writer/changes/writer-factory.d.ts +2 -2
  115. package/dist/writer/changes/writer-factory.js +10 -13
  116. package/dist/writer/changes/writers/annotations-writer.d.ts +1 -1
  117. package/dist/writer/changes/writers/annotations-writer.js +11 -46
  118. package/dist/writer/changes/writers/component-usages-writer.d.ts +1 -1
  119. package/dist/writer/changes/writers/component-usages-writer.js +9 -12
  120. package/dist/writer/changes/writers/data-source-writer.d.ts +1 -1
  121. package/dist/writer/changes/writers/data-source-writer.js +7 -10
  122. package/dist/writer/changes/writers/inbound-writer.d.ts +1 -1
  123. package/dist/writer/changes/writers/inbound-writer.js +10 -13
  124. package/dist/writer/changes/writers/index.d.ts +5 -5
  125. package/dist/writer/changes/writers/index.js +5 -21
  126. package/dist/writer/changes/writers/new-model-writer.d.ts +1 -1
  127. package/dist/writer/changes/writers/new-model-writer.js +16 -20
  128. package/dist/writer/editors.d.ts +1 -1
  129. package/dist/writer/editors.js +6 -9
  130. package/dist/writer/i18n/index.d.ts +1 -1
  131. package/dist/writer/i18n/index.js +13 -17
  132. package/dist/writer/i18n/key-user-translations.js +9 -14
  133. package/dist/writer/inbound-navigation.d.ts +1 -1
  134. package/dist/writer/inbound-navigation.js +18 -27
  135. package/dist/writer/index.d.ts +1 -1
  136. package/dist/writer/index.js +36 -37
  137. package/dist/writer/manifest/descriptor-content.d.ts +2 -2
  138. package/dist/writer/manifest/descriptor-content.js +9 -15
  139. package/dist/writer/manifest/index.d.ts +1 -1
  140. package/dist/writer/manifest/index.js +1 -17
  141. package/dist/writer/options.d.ts +1 -1
  142. package/dist/writer/options.js +16 -27
  143. package/dist/writer/project-utils.d.ts +1 -1
  144. package/dist/writer/project-utils.js +49 -57
  145. package/dist/writer/writer-config.d.ts +2 -2
  146. package/dist/writer/writer-config.js +25 -30
  147. package/package.json +19 -17
@@ -1,52 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.buildVcapServicesFromResources = buildVcapServicesFromResources;
37
- exports.getApprouterType = getApprouterType;
38
- exports.getModuleNames = getModuleNames;
39
- exports.getServicesForFile = getServicesForFile;
40
- exports.hasApprouter = hasApprouter;
41
- exports.getMtaServices = getMtaServices;
42
- exports.getResources = getResources;
43
- exports.readMta = readMta;
44
- const path = __importStar(require("node:path"));
45
- const i18n_1 = require("../../i18n");
46
- const api_1 = require("../services/api");
47
- const cli_1 = require("../services/cli");
48
- const yaml_1 = require("./yaml");
49
- const yaml_loader_1 = require("./yaml-loader");
1
+ import * as path from 'node:path';
2
+ import { t } from '../../i18n.js';
3
+ import { getServiceKeyCredentialsWithTags } from '../services/api.js';
4
+ import { requestCfApi } from '../services/cli.js';
5
+ import { getRouterType } from './yaml.js';
6
+ import { getYamlContent } from './yaml-loader.js';
50
7
  const EXCLUDED_SERVICES_VCAP = new Set(['html5-apps-repo', 'portal']);
51
8
  /**
52
9
  * Builds VCAP_SERVICES by resolving MTA resources to service key credentials.
@@ -56,7 +13,7 @@ const EXCLUDED_SERVICES_VCAP = new Set(['html5-apps-repo', 'portal']);
56
13
  * @param {ToolsLogger} logger - Optional logger.
57
14
  * @returns {Promise<Record<string, unknown>>} VCAP_SERVICES keyed by service name.
58
15
  */
59
- async function buildVcapServicesFromResources(resources, spaceGuid, logger) {
16
+ export async function buildVcapServicesFromResources(resources, spaceGuid, logger) {
60
17
  const vcapServices = {};
61
18
  for (const resource of resources ?? []) {
62
19
  const serviceName = resource.parameters?.service;
@@ -65,7 +22,7 @@ async function buildVcapServicesFromResources(resources, spaceGuid, logger) {
65
22
  if (!serviceName || !serviceInstanceName || EXCLUDED_SERVICES_VCAP.has(serviceName)) {
66
23
  continue;
67
24
  }
68
- const data = await (0, api_1.getServiceKeyCredentialsWithTags)(spaceGuid, serviceName, serviceInstanceName, servicePlan ?? '', logger);
25
+ const data = await getServiceKeyCredentialsWithTags(spaceGuid, serviceName, serviceInstanceName, servicePlan ?? '', logger);
69
26
  if (!data?.credentials) {
70
27
  throw new Error(`Credentials and tags for service '${serviceName}' ('${serviceInstanceName}') not found`);
71
28
  }
@@ -79,9 +36,9 @@ async function buildVcapServicesFromResources(resources, spaceGuid, logger) {
79
36
  * @param {string} mtaProjectPath - The path to the mta project.
80
37
  * @returns {AppRouterType} The approuter type.
81
38
  */
82
- function getApprouterType(mtaProjectPath) {
83
- const yamlContent = (0, yaml_loader_1.getYamlContent)(path.join(mtaProjectPath, 'mta.yaml'));
84
- return (0, yaml_1.getRouterType)(yamlContent);
39
+ export function getApprouterType(mtaProjectPath) {
40
+ const yamlContent = getYamlContent(path.join(mtaProjectPath, 'mta.yaml'));
41
+ return getRouterType(yamlContent);
85
42
  }
86
43
  /**
87
44
  * Get the module names.
@@ -89,8 +46,8 @@ function getApprouterType(mtaProjectPath) {
89
46
  * @param {string} mtaProjectPath - The path to the mta project.
90
47
  * @returns {string[]} The module names.
91
48
  */
92
- function getModuleNames(mtaProjectPath) {
93
- const yamlContent = (0, yaml_loader_1.getYamlContent)(path.join(mtaProjectPath, 'mta.yaml'));
49
+ export function getModuleNames(mtaProjectPath) {
50
+ const yamlContent = getYamlContent(path.join(mtaProjectPath, 'mta.yaml'));
94
51
  return yamlContent?.modules?.map((module) => module.name) ?? [];
95
52
  }
96
53
  /**
@@ -100,9 +57,9 @@ function getModuleNames(mtaProjectPath) {
100
57
  * @param {ToolsLogger} logger - The logger.
101
58
  * @returns {BusinessServiceResource[]} The services.
102
59
  */
103
- function getServicesForFile(mtaFilePath, logger) {
60
+ export function getServicesForFile(mtaFilePath, logger) {
104
61
  const serviceNames = [];
105
- const parsed = (0, yaml_loader_1.getYamlContent)(mtaFilePath);
62
+ const parsed = getYamlContent(mtaFilePath);
106
63
  if (parsed?.resources && Array.isArray(parsed.resources)) {
107
64
  for (const resource of parsed.resources) {
108
65
  const name = resource?.parameters?.['service-name'] ?? resource.name;
@@ -123,7 +80,7 @@ function getServicesForFile(mtaFilePath, logger) {
123
80
  * @param {string[]} moduleNames - The module names.
124
81
  * @returns {boolean} Whether the project has an approuter.
125
82
  */
126
- function hasApprouter(moduleNames) {
83
+ export function hasApprouter(moduleNames) {
127
84
  return moduleNames.some((name) => name.includes('destination-content') || name.includes('approuter'));
128
85
  }
129
86
  /**
@@ -136,10 +93,10 @@ function hasApprouter(moduleNames) {
136
93
  async function filterServices(businessServices, logger) {
137
94
  const serviceLabels = businessServices.map((service) => service.label).filter(Boolean);
138
95
  if (serviceLabels.length === 0) {
139
- throw new Error((0, i18n_1.t)('error.noBusinessServicesFound'));
96
+ throw new Error(t('error.noBusinessServicesFound'));
140
97
  }
141
98
  const url = `/v3/service_offerings?names=${serviceLabels.join(',')}`;
142
- const json = await (0, cli_1.requestCfApi)(url);
99
+ const json = await requestCfApi(url);
143
100
  logger?.log(`Filtering services. Request to: ${url}, result: ${JSON.stringify(json)}`);
144
101
  const businessServiceNames = new Set(businessServices.map((service) => service.label));
145
102
  const result = [];
@@ -155,7 +112,7 @@ async function filterServices(businessServices, logger) {
155
112
  }
156
113
  }
157
114
  if (result.length === 0) {
158
- throw new Error((0, i18n_1.t)('error.noBusinessServicesFound'));
115
+ throw new Error(t('error.noBusinessServicesFound'));
159
116
  }
160
117
  return result;
161
118
  }
@@ -166,7 +123,7 @@ async function filterServices(businessServices, logger) {
166
123
  * @param {ToolsLogger} logger - The logger.
167
124
  * @returns {Promise<string[]>} The services.
168
125
  */
169
- async function getMtaServices(projectPath, logger) {
126
+ export async function getMtaServices(projectPath, logger) {
170
127
  const services = await readMta(projectPath, logger);
171
128
  logger?.log(`Available services defined in mta.yaml: ${JSON.stringify(services)}`);
172
129
  return services;
@@ -178,7 +135,7 @@ async function getMtaServices(projectPath, logger) {
178
135
  * @param {ToolsLogger} logger - The logger.
179
136
  * @returns {Promise<string[]>} The resources.
180
137
  */
181
- async function getResources(mtaFilePath, logger) {
138
+ export async function getResources(mtaFilePath, logger) {
182
139
  const servicesList = getServicesForFile(mtaFilePath, logger);
183
140
  const oDataFilteredServices = await filterServices(servicesList, logger);
184
141
  return oDataFilteredServices;
@@ -190,9 +147,9 @@ async function getResources(mtaFilePath, logger) {
190
147
  * @param {ToolsLogger} logger - The logger.
191
148
  * @returns {Promise<string[]>} The resources.
192
149
  */
193
- async function readMta(projectPath, logger) {
150
+ export async function readMta(projectPath, logger) {
194
151
  if (!projectPath) {
195
- throw new Error((0, i18n_1.t)('error.mtaProjectPathMissing'));
152
+ throw new Error(t('error.mtaProjectPathMissing'));
196
153
  }
197
154
  const mtaFilePath = path.resolve(projectPath, 'mta.yaml');
198
155
  const resources = await getResources(mtaFilePath, logger);
@@ -1,4 +1,4 @@
1
- import type { MtaYaml } from '../../types';
1
+ import type { MtaYaml } from '../../types.js';
2
2
  /**
3
3
  * Parses the MTA file.
4
4
  *
@@ -1,27 +1,19 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getYamlContent = getYamlContent;
7
- exports.getProjectName = getProjectName;
8
- exports.getProjectNameForXsSecurity = getProjectNameForXsSecurity;
9
- const node_fs_1 = __importDefault(require("node:fs"));
10
- const js_yaml_1 = __importDefault(require("js-yaml"));
1
+ import fs from 'node:fs';
2
+ import yaml from 'js-yaml';
11
3
  /**
12
4
  * Parses the MTA file.
13
5
  *
14
6
  * @param {string} filePath - The file to parse.
15
7
  * @returns {MtaYaml} The parsed YAML content.
16
8
  */
17
- function getYamlContent(filePath) {
18
- if (!node_fs_1.default.existsSync(filePath)) {
9
+ export function getYamlContent(filePath) {
10
+ if (!fs.existsSync(filePath)) {
19
11
  throw new Error(`Could not find file ${filePath}`);
20
12
  }
21
- const content = node_fs_1.default.readFileSync(filePath, 'utf-8');
13
+ const content = fs.readFileSync(filePath, 'utf-8');
22
14
  let parsed;
23
15
  try {
24
- parsed = js_yaml_1.default.load(content);
16
+ parsed = yaml.load(content);
25
17
  return parsed;
26
18
  }
27
19
  catch (e) {
@@ -34,7 +26,7 @@ function getYamlContent(filePath) {
34
26
  * @param {MtaYaml} yamlContent - The YAML content.
35
27
  * @returns {string | null} The project name or null if not found.
36
28
  */
37
- function getProjectName(yamlContent) {
29
+ export function getProjectName(yamlContent) {
38
30
  return yamlContent?.ID || null;
39
31
  }
40
32
  /**
@@ -44,7 +36,7 @@ function getProjectName(yamlContent) {
44
36
  * @param {string} timestamp - The timestamp to append.
45
37
  * @returns {string | null} The project name for XS security or null if not available.
46
38
  */
47
- function getProjectNameForXsSecurity(yamlContent, timestamp) {
39
+ export function getProjectNameForXsSecurity(yamlContent, timestamp) {
48
40
  const projectName = getProjectName(yamlContent);
49
41
  if (!projectName || !timestamp) {
50
42
  return undefined;
@@ -1,7 +1,7 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
- import type { AppParamsExtended, MtaYaml, ServiceKeys } from '../../types';
4
- import { AppRouterType } from '../../types';
3
+ import type { AppParamsExtended, MtaYaml, ServiceKeys } from '../../types.js';
4
+ import { AppRouterType } from '../../types.js';
5
5
  interface AdjustMtaYamlParams {
6
6
  projectPath: string;
7
7
  adpProjectName: string;
@@ -1,54 +1,10 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.isMtaProject = isMtaProject;
40
- exports.addConnectivityServiceToMta = addConnectivityServiceToMta;
41
- exports.getSAPCloudService = getSAPCloudService;
42
- exports.getRouterType = getRouterType;
43
- exports.getAppParamsFromUI5Yaml = getAppParamsFromUI5Yaml;
44
- exports.adjustMtaYaml = adjustMtaYaml;
45
- const node_fs_1 = __importDefault(require("node:fs"));
46
- const path = __importStar(require("node:path"));
47
- const js_yaml_1 = __importDefault(require("js-yaml"));
48
- const types_1 = require("../../types");
49
- const api_1 = require("../services/api");
50
- const yaml_loader_1 = require("./yaml-loader");
51
- const discovery_1 = require("../app/discovery");
1
+ import fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import yaml from 'js-yaml';
4
+ import { AppRouterType } from '../../types.js';
5
+ import { createServices, createServiceInstance, getOrCreateServiceInstanceKeys } from '../services/api.js';
6
+ import { getProjectNameForXsSecurity, getYamlContent } from './yaml-loader.js';
7
+ import { getServiceKeyDestinations } from '../app/discovery.js';
52
8
  const CF_MANAGED_SERVICE = 'org.cloudfoundry.managed-service';
53
9
  const HTML5_APPS_REPO = 'html5-apps-repo';
54
10
  const SAP_APPLICATION_CONTENT = 'com.sap.application.content';
@@ -58,8 +14,8 @@ const SAP_APPLICATION_CONTENT = 'com.sap.application.content';
58
14
  * @param {string} selectedPath - The selected path.
59
15
  * @returns {boolean} True if the selected path is a MTA project, false otherwise.
60
16
  */
61
- function isMtaProject(selectedPath) {
62
- return node_fs_1.default.existsSync(path.join(selectedPath, 'mta.yaml'));
17
+ export function isMtaProject(selectedPath) {
18
+ return fs.existsSync(path.join(selectedPath, 'mta.yaml'));
63
19
  }
64
20
  /**
65
21
  * Adds a connectivity service resource to the project's mta.yaml if not already present,
@@ -71,12 +27,12 @@ function isMtaProject(selectedPath) {
71
27
  * @param {Editor} memFs - The mem-fs editor instance.
72
28
  * @param {ToolsLogger} [logger] - Optional logger.
73
29
  */
74
- async function addConnectivityServiceToMta(projectPath, memFs, logger) {
30
+ export async function addConnectivityServiceToMta(projectPath, memFs, logger) {
75
31
  if (!isMtaProject(projectPath)) {
76
32
  return;
77
33
  }
78
34
  const mtaYamlPath = path.join(projectPath, 'mta.yaml');
79
- const yamlContent = (0, yaml_loader_1.getYamlContent)(mtaYamlPath);
35
+ const yamlContent = getYamlContent(mtaYamlPath);
80
36
  if (!yamlContent) {
81
37
  return;
82
38
  }
@@ -85,8 +41,8 @@ async function addConnectivityServiceToMta(projectPath, memFs, logger) {
85
41
  if (yamlContent.resources?.some((r) => r.name === connectivityResourceName)) {
86
42
  return;
87
43
  }
88
- await (0, api_1.createServiceInstance)('lite', connectivityResourceName, 'connectivity', { logger });
89
- await (0, api_1.getOrCreateServiceInstanceKeys)({ names: [connectivityResourceName] }, logger);
44
+ await createServiceInstance('lite', connectivityResourceName, 'connectivity', { logger });
45
+ await getOrCreateServiceInstanceKeys({ names: [connectivityResourceName] }, logger);
90
46
  yamlContent.resources = yamlContent.resources ?? [];
91
47
  yamlContent.resources.push({
92
48
  name: connectivityResourceName,
@@ -97,7 +53,7 @@ async function addConnectivityServiceToMta(projectPath, memFs, logger) {
97
53
  'service-name': connectivityResourceName
98
54
  }
99
55
  });
100
- memFs.write(mtaYamlPath, js_yaml_1.default.dump(yamlContent, { lineWidth: -1 }));
56
+ memFs.write(mtaYamlPath, yaml.dump(yamlContent, { lineWidth: -1 }));
101
57
  }
102
58
  /**
103
59
  * Gets the SAP Cloud Service.
@@ -105,7 +61,7 @@ async function addConnectivityServiceToMta(projectPath, memFs, logger) {
105
61
  * @param {MtaYaml} yamlContent - The YAML content.
106
62
  * @returns {string} The SAP Cloud Service.
107
63
  */
108
- function getSAPCloudService(yamlContent) {
64
+ export function getSAPCloudService(yamlContent) {
109
65
  const modules = yamlContent?.modules?.filter((module) => module.name.includes('destination-content'));
110
66
  const destinations = modules?.[0]?.parameters?.content?.instance?.destinations;
111
67
  const mtaDestination = destinations?.find((destination) => destination.Name.includes('html_repo_host'));
@@ -118,14 +74,14 @@ function getSAPCloudService(yamlContent) {
118
74
  * @param {MtaYaml} yamlContent - The YAML content.
119
75
  * @returns {AppRouterType} The router type.
120
76
  */
121
- function getRouterType(yamlContent) {
77
+ export function getRouterType(yamlContent) {
122
78
  const filtered = yamlContent?.modules?.filter((module) => module.name.includes('destination-content') || module.name.includes('approuter'));
123
79
  const routerType = filtered?.pop();
124
80
  if (routerType?.name.includes('approuter')) {
125
- return types_1.AppRouterType.STANDALONE;
81
+ return AppRouterType.STANDALONE;
126
82
  }
127
83
  else {
128
- return types_1.AppRouterType.MANAGED;
84
+ return AppRouterType.MANAGED;
129
85
  }
130
86
  }
131
87
  /**
@@ -134,9 +90,9 @@ function getRouterType(yamlContent) {
134
90
  * @param {string} projectPath - The project path.
135
91
  * @returns {AppParamsExtended} The app params.
136
92
  */
137
- function getAppParamsFromUI5Yaml(projectPath) {
93
+ export function getAppParamsFromUI5Yaml(projectPath) {
138
94
  const ui5YamlPath = path.join(projectPath, 'ui5.yaml');
139
- const parsedYaml = (0, yaml_loader_1.getYamlContent)(ui5YamlPath);
95
+ const parsedYaml = getYamlContent(ui5YamlPath);
140
96
  const appConfiguration = parsedYaml?.builder?.customTasks?.[0]?.configuration;
141
97
  const appParams = {
142
98
  appHostId: appConfiguration?.appHostId || '',
@@ -191,12 +147,12 @@ function adjustMtaYamlStandaloneApprouter(yamlContent, projectName, businessServ
191
147
  * @param {ServiceKeys[]} serviceKeys - The service keys (optional).
192
148
  */
193
149
  function adjustMtaYamlManagedApprouter(yamlContent, projectName, businessSolution, businessService, timestamp, serviceKeys) {
194
- const projectNameForXsSecurity = (0, yaml_loader_1.getProjectNameForXsSecurity)(yamlContent, timestamp);
150
+ const projectNameForXsSecurity = getProjectNameForXsSecurity(yamlContent, timestamp);
195
151
  const appRouterName = `${projectName}-destination-content`;
196
152
  let appRouter = yamlContent.modules?.find((module) => module.name === appRouterName);
197
153
  if (appRouter == null) {
198
154
  const endpointDestinations = serviceKeys
199
- ? (0, discovery_1.getServiceKeyDestinations)(serviceKeys).map((endpoint) => ({
155
+ ? getServiceKeyDestinations(serviceKeys).map((endpoint) => ({
200
156
  Name: endpoint.name,
201
157
  URL: endpoint.url,
202
158
  Authentication: 'OAuth2UserTokenExchange',
@@ -326,7 +282,7 @@ function adjustMtaYamlUDeployer(yamlContent, mtaProjectName, adpProjectName) {
326
282
  * @param {boolean} isManagedAppRouter - Whether the approuter is managed.
327
283
  */
328
284
  function adjustMtaYamlResources(yamlContent, mtaProjectName, timestamp, isManagedAppRouter) {
329
- const projectNameForXsSecurity = (0, yaml_loader_1.getProjectNameForXsSecurity)(yamlContent, timestamp);
285
+ const projectNameForXsSecurity = getProjectNameForXsSecurity(yamlContent, timestamp);
330
286
  const resources = [
331
287
  {
332
288
  name: `${mtaProjectName}_html_repo_host`,
@@ -453,9 +409,9 @@ function adjustMtaYamlFlpModule(yamlContent, projectName, businessService) {
453
409
  * @param {ToolsLogger} logger - The logger.
454
410
  * @returns {Promise<void>} The promise.
455
411
  */
456
- async function adjustMtaYaml({ projectPath, adpProjectName, appRouterType, businessSolutionName, businessService, serviceKeys, spaceGuid }, memFs, timestamp, templatePathOverwrite, logger) {
412
+ export async function adjustMtaYaml({ projectPath, adpProjectName, appRouterType, businessSolutionName, businessService, serviceKeys, spaceGuid }, memFs, timestamp, templatePathOverwrite, logger) {
457
413
  const mtaYamlPath = path.join(projectPath, 'mta.yaml');
458
- const loadedYamlContent = (0, yaml_loader_1.getYamlContent)(mtaYamlPath);
414
+ const loadedYamlContent = getYamlContent(mtaYamlPath);
459
415
  const defaultYaml = {
460
416
  ID: projectPath.split(path.sep).pop() ?? '',
461
417
  version: '0.0.1',
@@ -469,7 +425,7 @@ async function adjustMtaYaml({ projectPath, adpProjectName, appRouterType, busin
469
425
  const yamlContent = Object.assign(defaultYaml, loadedYamlContent);
470
426
  const mtaProjectName = yamlContent.ID.toLowerCase();
471
427
  const initialServices = yamlContent.resources?.map((resource) => resource.parameters.service ?? '') ?? [];
472
- const isStandaloneApprouter = appRouterType === types_1.AppRouterType.STANDALONE;
428
+ const isStandaloneApprouter = appRouterType === AppRouterType.STANDALONE;
473
429
  if (isStandaloneApprouter) {
474
430
  adjustMtaYamlStandaloneApprouter(yamlContent, mtaProjectName, businessService);
475
431
  }
@@ -481,8 +437,8 @@ async function adjustMtaYaml({ projectPath, adpProjectName, appRouterType, busin
481
437
  adjustMtaYamlOwnModule(yamlContent, adpProjectName);
482
438
  // should go last since it sorts the modules (workaround, should be removed after fixed in deployment module)
483
439
  adjustMtaYamlFlpModule(yamlContent, mtaProjectName, businessService);
484
- await (0, api_1.createServices)(yamlContent, initialServices, timestamp, spaceGuid, templatePathOverwrite, logger);
485
- const updatedYamlContent = js_yaml_1.default.dump(yamlContent, {
440
+ await createServices(yamlContent, initialServices, timestamp, spaceGuid, templatePathOverwrite, logger);
441
+ const updatedYamlContent = yaml.dump(yamlContent, {
486
442
  lineWidth: -1 // Disable line wrapping to keep URLs on single lines
487
443
  });
488
444
  memFs.write(mtaYamlPath, updatedYamlContent);
@@ -1,6 +1,6 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
2
  import type { ManifestNamespace } from '@sap-ux/project-access';
3
- import type { CfConfig, CFApp, RequestArguments, ServiceKeys, GetServiceInstanceParams, ServiceInstance, MtaYaml, ServiceInfo, CfUi5AppInfo, ServiceKeyCredentialsWithTags } from '../../types';
3
+ import type { CfConfig, CFApp, RequestArguments, ServiceKeys, GetServiceInstanceParams, ServiceInstance, MtaYaml, ServiceInfo, CfUi5AppInfo, ServiceKeyCredentialsWithTags } from '../../types.js';
4
4
  interface CreateServiceOptions {
5
5
  xsSecurityProjectName?: string;
6
6
  templatePathOverwrite?: string;