@sap-ux/adp-tooling 0.19.11 → 1.0.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.
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,24 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVariant = getVariant;
4
- exports.updateVariant = updateVariant;
5
- exports.flpConfigurationExists = flpConfigurationExists;
6
- exports.isTypescriptSupported = isTypescriptSupported;
7
- exports.readUi5Config = readUi5Config;
8
- exports.extractAdpConfig = extractAdpConfig;
9
- exports.extractCfBuildTask = extractCfBuildTask;
10
- exports.getSpaceGuidFromUi5Yaml = getSpaceGuidFromUi5Yaml;
11
- exports.readManifestFromBuildPath = readManifestFromBuildPath;
12
- exports.loadAppVariant = loadAppVariant;
13
- exports.getAdpConfig = getAdpConfig;
14
- exports.getExistingAdpProjectType = getExistingAdpProjectType;
15
- exports.getWebappFiles = getWebappFiles;
16
- exports.filterAndMapInboundsToManifest = filterAndMapInboundsToManifest;
17
- exports.getBaseAppId = getBaseAppId;
18
- const node_fs_1 = require("node:fs");
19
- const node_path_1 = require("node:path");
20
- const axios_extension_1 = require("@sap-ux/axios-extension");
21
- const project_access_1 = require("@sap-ux/project-access");
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join, isAbsolute, relative, basename, dirname } from 'node:path';
3
+ import { AdaptationProjectType } from '@sap-ux/axios-extension';
4
+ import { getWebappPath, FileName, readUi5Yaml, getAppType } from '@sap-ux/project-access';
22
5
  const ADP_CLOUD_PROJECT_BUILD_TASK_NAME = 'app-variant-bundler-build';
23
6
  /**
24
7
  * Get the app descriptor variant.
@@ -27,12 +10,12 @@ const ADP_CLOUD_PROJECT_BUILD_TASK_NAME = 'app-variant-bundler-build';
27
10
  * @param {Editor} fs - The mem-fs editor instance.
28
11
  * @returns {Promise<DescriptorVariant>} The app descriptor variant.
29
12
  */
30
- async function getVariant(basePath, fs) {
31
- const webappPath = await (0, project_access_1.getWebappPath)(basePath);
13
+ export async function getVariant(basePath, fs) {
14
+ const webappPath = await getWebappPath(basePath);
32
15
  if (fs) {
33
- return fs.readJSON((0, node_path_1.join)(webappPath, project_access_1.FileName.ManifestAppDescrVar));
16
+ return fs.readJSON(join(webappPath, FileName.ManifestAppDescrVar));
34
17
  }
35
- return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(webappPath, project_access_1.FileName.ManifestAppDescrVar), 'utf-8'));
18
+ return JSON.parse(readFileSync(join(webappPath, FileName.ManifestAppDescrVar), 'utf-8'));
36
19
  }
37
20
  /**
38
21
  * Writes the updated variant content to the manifest.appdescr_variant file.
@@ -41,8 +24,8 @@ async function getVariant(basePath, fs) {
41
24
  * @param {DescriptorVariant} variant - The descriptor variant object.
42
25
  * @param {Editor} fs - The mem-fs editor instance.
43
26
  */
44
- async function updateVariant(basePath, variant, fs) {
45
- fs.writeJSON((0, node_path_1.join)(await (0, project_access_1.getWebappPath)(basePath), project_access_1.FileName.ManifestAppDescrVar), variant);
27
+ export async function updateVariant(basePath, variant, fs) {
28
+ fs.writeJSON(join(await getWebappPath(basePath), FileName.ManifestAppDescrVar), variant);
46
29
  }
47
30
  /**
48
31
  * Checks if FLP configuration changes exist in the manifest.appdescr_variant.
@@ -53,7 +36,7 @@ async function updateVariant(basePath, variant, fs) {
53
36
  * @param {DescriptorVariant} variant - The descriptor variant object to check for FLP configuration changes.
54
37
  * @returns {Promise<boolean>} Returns `true` if FLP configuration changes exist, otherwise `false`.
55
38
  */
56
- function flpConfigurationExists(variant) {
39
+ export function flpConfigurationExists(variant) {
57
40
  return variant.content?.some(({ changeType }) => changeType === 'appdescr_app_changeInbound' || changeType === 'appdescr_app_addNewInbound');
58
41
  }
59
42
  /**
@@ -63,9 +46,9 @@ function flpConfigurationExists(variant) {
63
46
  * @param fs - An optional `mem-fs-editor` instance to check for the file's existence.
64
47
  * @returns `true` if `tsconfig.json` exists, otherwise `false`.
65
48
  */
66
- function isTypescriptSupported(basePath, fs) {
67
- const path = (0, node_path_1.join)(basePath, 'tsconfig.json');
68
- return fs ? fs.exists(path) : (0, node_fs_1.existsSync)(path);
49
+ export function isTypescriptSupported(basePath, fs) {
50
+ const path = join(basePath, 'tsconfig.json');
51
+ return fs ? fs.exists(path) : existsSync(path);
69
52
  }
70
53
  /**
71
54
  * Reads the UI5 YAML configuration and returns the parsed `UI5Config` instance.
@@ -74,9 +57,9 @@ function isTypescriptSupported(basePath, fs) {
74
57
  * @param {string} yamlPath - Relative or absolute path to the ui5.yaml file
75
58
  * @returns {Promise<UI5Config>} The `UI5Config` object.
76
59
  */
77
- async function readUi5Config(basePath, yamlPath) {
78
- const ui5ConfigPath = (0, node_path_1.isAbsolute)(yamlPath) ? yamlPath : (0, node_path_1.join)(basePath, yamlPath);
79
- return (0, project_access_1.readUi5Yaml)((0, node_path_1.dirname)(ui5ConfigPath), (0, node_path_1.basename)(ui5ConfigPath));
60
+ export async function readUi5Config(basePath, yamlPath) {
61
+ const ui5ConfigPath = isAbsolute(yamlPath) ? yamlPath : join(basePath, yamlPath);
62
+ return readUi5Yaml(dirname(ui5ConfigPath), basename(ui5ConfigPath));
80
63
  }
81
64
  /**
82
65
  * Extracts the `adp` preview configuration from a UI5 YAML config (if present).
@@ -84,7 +67,7 @@ async function readUi5Config(basePath, yamlPath) {
84
67
  * @param {UI5Config} ui5Conf Parsed UI5 configuration
85
68
  * @returns The `AdpPreviewConfig` object if found, otherwise `undefined`.
86
69
  */
87
- function extractAdpConfig(ui5Conf) {
70
+ export function extractAdpConfig(ui5Conf) {
88
71
  const customMiddleware = ui5Conf.findCustomMiddleware('fiori-tools-preview') ??
89
72
  ui5Conf.findCustomMiddleware('preview-middleware');
90
73
  return customMiddleware?.configuration?.adp;
@@ -95,7 +78,7 @@ function extractAdpConfig(ui5Conf) {
95
78
  * @param {UI5Config} ui5Conf - The UI5 configuration.
96
79
  * @returns {UI5YamlCustomTaskConfiguration} The CF build task.
97
80
  */
98
- function extractCfBuildTask(ui5Conf) {
81
+ export function extractCfBuildTask(ui5Conf) {
99
82
  const buildTask = ui5Conf.findCustomTask('app-variant-bundler-build')?.configuration;
100
83
  if (!buildTask) {
101
84
  throw new Error('No CF ADP project found');
@@ -109,7 +92,7 @@ function extractCfBuildTask(ui5Conf) {
109
92
  * @param {ToolsLogger} logger - Optional logger.
110
93
  * @returns {Promise<string | undefined>} Space GUID or undefined if not found.
111
94
  */
112
- async function getSpaceGuidFromUi5Yaml(rootPath, logger) {
95
+ export async function getSpaceGuidFromUi5Yaml(rootPath, logger) {
113
96
  try {
114
97
  const ui5Config = await readUi5Config(rootPath, 'ui5.yaml');
115
98
  const buildTask = extractCfBuildTask(ui5Config);
@@ -126,10 +109,10 @@ async function getSpaceGuidFromUi5Yaml(rootPath, logger) {
126
109
  * @param {string} cfBuildPath - The path to the build output folder.
127
110
  * @returns {Manifest} The manifest.
128
111
  */
129
- function readManifestFromBuildPath(cfBuildPath) {
130
- const distPath = (0, node_path_1.join)(process.cwd(), cfBuildPath);
131
- const manifestPath = (0, node_path_1.join)(distPath, 'manifest.json');
132
- return JSON.parse((0, node_fs_1.readFileSync)(manifestPath, 'utf-8'));
112
+ export function readManifestFromBuildPath(cfBuildPath) {
113
+ const distPath = join(process.cwd(), cfBuildPath);
114
+ const manifestPath = join(distPath, 'manifest.json');
115
+ return JSON.parse(readFileSync(manifestPath, 'utf-8'));
133
116
  }
134
117
  /**
135
118
  * Load and parse the app variant descriptor.
@@ -137,7 +120,7 @@ function readManifestFromBuildPath(cfBuildPath) {
137
120
  * @param {ReaderCollection} rootProject - The root project.
138
121
  * @returns {Promise<DescriptorVariant>} The parsed descriptor variant.
139
122
  */
140
- async function loadAppVariant(rootProject) {
123
+ export async function loadAppVariant(rootProject) {
141
124
  const appVariant = await rootProject.byPath('/manifest.appdescr_variant');
142
125
  if (!appVariant) {
143
126
  throw new Error('ADP configured but no manifest.appdescr_variant found.');
@@ -161,7 +144,7 @@ async function loadAppVariant(rootProject) {
161
144
  * @param yamlPath Relative or absolute path to the ui5.yaml file
162
145
  * @returns The `AdpPreviewConfig` object if found, otherwise throws an error.
163
146
  */
164
- async function getAdpConfig(basePath, yamlPath) {
147
+ export async function getAdpConfig(basePath, yamlPath) {
165
148
  try {
166
149
  const ui5Conf = await readUi5Config(basePath, yamlPath);
167
150
  const adp = extractAdpConfig(ui5Conf);
@@ -171,8 +154,8 @@ async function getAdpConfig(basePath, yamlPath) {
171
154
  return adp;
172
155
  }
173
156
  catch (error) {
174
- const ui5ConfigPath = (0, node_path_1.isAbsolute)(yamlPath) ? yamlPath : (0, node_path_1.join)(basePath, yamlPath);
175
- throw new Error(`No system configuration found in ${(0, node_path_1.basename)(ui5ConfigPath)}`);
157
+ const ui5ConfigPath = isAbsolute(yamlPath) ? yamlPath : join(basePath, yamlPath);
158
+ throw new Error(`No system configuration found in ${basename(ui5ConfigPath)}`);
176
159
  }
177
160
  }
178
161
  /**
@@ -184,16 +167,16 @@ async function getAdpConfig(basePath, yamlPath) {
184
167
  * @returns {Promise<AdaptationProjectType | undefined>} The project type or undefined in casde the project is
185
168
  * NOT an Adaptation project or an error is thrown from reading the configuration file.
186
169
  */
187
- async function getExistingAdpProjectType(basePath) {
170
+ export async function getExistingAdpProjectType(basePath) {
188
171
  try {
189
- const appType = await (0, project_access_1.getAppType)(basePath);
172
+ const appType = await getAppType(basePath);
190
173
  if (appType !== 'Fiori Adaptation') {
191
174
  return undefined;
192
175
  }
193
- const yamlPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Ui5Yaml);
176
+ const yamlPath = join(basePath, FileName.Ui5Yaml);
194
177
  const ui5Config = await readUi5Config(basePath, yamlPath);
195
178
  const cloudProjectBuildTask = ui5Config.findCustomTask(ADP_CLOUD_PROJECT_BUILD_TASK_NAME);
196
- return cloudProjectBuildTask ? axios_extension_1.AdaptationProjectType.CLOUD_READY : axios_extension_1.AdaptationProjectType.ON_PREMISE;
179
+ return cloudProjectBuildTask ? AdaptationProjectType.CLOUD_READY : AdaptationProjectType.ON_PREMISE;
197
180
  }
198
181
  catch {
199
182
  // Expected: Project may not be an ADP project or configuration files may be missing/invalid
@@ -207,16 +190,16 @@ async function getExistingAdpProjectType(basePath) {
207
190
  * @param {string} basePath - The path to the adaptation project.
208
191
  * @returns {Promise<{ relativePath: string; content: string }[]>} The files in the webapp folder.
209
192
  */
210
- async function getWebappFiles(basePath) {
211
- const dir = await (0, project_access_1.getWebappPath)(basePath);
193
+ export async function getWebappFiles(basePath) {
194
+ const dir = await getWebappPath(basePath);
212
195
  const files = [];
213
196
  const getFilesRecursivelySync = (directory) => {
214
- const dirents = (0, node_fs_1.readdirSync)(directory, { withFileTypes: true });
197
+ const dirents = readdirSync(directory, { withFileTypes: true });
215
198
  for (const dirent of dirents) {
216
- const fullPath = (0, node_path_1.join)(directory, dirent.name);
199
+ const fullPath = join(directory, dirent.name);
217
200
  if (dirent.isFile()) {
218
- const content = (0, node_fs_1.readFileSync)(fullPath, 'utf-8');
219
- const relativePath = (0, node_path_1.relative)(dir, fullPath);
201
+ const content = readFileSync(fullPath, 'utf-8');
202
+ const relativePath = relative(dir, fullPath);
220
203
  files.push({ relativePath, content });
221
204
  }
222
205
  else if (dirent.isDirectory()) {
@@ -233,7 +216,7 @@ async function getWebappFiles(basePath) {
233
216
  * @param {Inbound[]} inbounds - The array of inbound objects to transform.
234
217
  * @returns {ManifestNamespace.Inbound | undefined} The transformed inbounds or undefined if input is empty.
235
218
  */
236
- function filterAndMapInboundsToManifest(inbounds) {
219
+ export function filterAndMapInboundsToManifest(inbounds) {
237
220
  if (!inbounds || inbounds.length === 0) {
238
221
  return undefined;
239
222
  }
@@ -257,7 +240,7 @@ function filterAndMapInboundsToManifest(inbounds) {
257
240
  * @param basePath - path to application root
258
241
  * @returns App ID (reference)
259
242
  */
260
- async function getBaseAppId(basePath) {
243
+ export async function getBaseAppId(basePath) {
261
244
  try {
262
245
  const variant = await getVariant(basePath);
263
246
  if (!variant.reference) {
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runBuild = runBuild;
4
- const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
1
+ import { CommandRunner } from '@sap-ux/nodejs-utils';
5
2
  /**
6
3
  * Executes a build command in the specified project directory.
7
4
  *
@@ -12,8 +9,8 @@ const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
12
9
  * @returns {Promise<void>} Resolves when the build process has completed successfully.
13
10
  * @throws {Error} If the build process fails or if an error occurs during cleanup.
14
11
  */
15
- async function runBuild(projectPath, env) {
16
- const commandRunner = new nodejs_utils_1.CommandRunner();
12
+ export async function runBuild(projectPath, env) {
13
+ const commandRunner = new CommandRunner();
17
14
  try {
18
15
  const opts = {
19
16
  cwd: projectPath,
@@ -1,7 +1,7 @@
1
1
  import type { Logger } from '@sap-ux/logger';
2
2
  import type { AbapTarget } from '@sap-ux/system-access';
3
3
  import type { AppIndex } from '@sap-ux/axios-extension';
4
- import { type CustomConfig, type AdpWriterConfig, FlexLayer } from '../types';
4
+ import { type CustomConfig, type AdpWriterConfig, FlexLayer } from '../types.js';
5
5
  export type PromptDefaults = {
6
6
  id?: string;
7
7
  reference?: string;
@@ -1,15 +1,9 @@
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.promptGeneratorInput = promptGeneratorInput;
7
- exports.promptTarget = promptTarget;
8
- const uuid_1 = require("uuid");
9
- const prompts_1 = __importDefault(require("prompts"));
10
- const system_access_1 = require("@sap-ux/system-access");
11
- const project_input_validator_1 = require("@sap-ux/project-input-validator");
12
- const project_utils_1 = require("../writer/project-utils");
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import prompts from 'prompts';
3
+ import { createAbapServiceProvider } from '@sap-ux/system-access';
4
+ import { validateClient, validateEmptyString } from '@sap-ux/project-input-validator';
5
+ import { getPackageJSONInfo } from '../writer/project-utils.js';
6
+ import { FlexLayer } from '../types.js';
13
7
  /**
14
8
  * Prompt the user for the required properties for an adaptation project.
15
9
  *
@@ -17,10 +11,10 @@ const project_utils_1 = require("../writer/project-utils");
17
11
  * @param logger optional logger instance
18
12
  * @returns a configuration for the adp writer
19
13
  */
20
- async function promptGeneratorInput(defaults, logger) {
14
+ export async function promptGeneratorInput(defaults, logger) {
21
15
  defaults = defaults ?? {};
22
16
  const { target, apps, layer, customConfig } = await promptTarget(defaults, logger);
23
- const app = await (0, prompts_1.default)([
17
+ const app = await prompts([
24
18
  {
25
19
  type: 'autocomplete',
26
20
  name: 'reference',
@@ -60,7 +54,7 @@ async function promptGeneratorInput(defaults, logger) {
60
54
  message: 'Application title:'
61
55
  }
62
56
  ]);
63
- const deploy = await (0, prompts_1.default)([
57
+ const deploy = await prompts([
64
58
  {
65
59
  type: 'text',
66
60
  name: 'package',
@@ -75,7 +69,7 @@ async function promptGeneratorInput(defaults, logger) {
75
69
  initial: defaults.transport
76
70
  }
77
71
  ]);
78
- const options = await (0, prompts_1.default)([
72
+ const options = await prompts([
79
73
  {
80
74
  type: 'confirm',
81
75
  name: 'fioriTools',
@@ -109,19 +103,19 @@ async function promptGeneratorInput(defaults, logger) {
109
103
  * @param logger logger instance
110
104
  * @returns apps, layer, target url and client
111
105
  */
112
- async function promptTarget(defaults, logger) {
106
+ export async function promptTarget(defaults, logger) {
113
107
  let count = 0;
114
108
  let target = { url: defaults.url, client: defaults.client };
115
109
  while (count < 3) {
116
110
  try {
117
111
  count++;
118
- target = await (0, prompts_1.default)([
112
+ target = await prompts([
119
113
  {
120
114
  type: 'text',
121
115
  name: 'url',
122
116
  message: 'Target system url:',
123
117
  initial: target.url,
124
- validate: project_input_validator_1.validateEmptyString,
118
+ validate: validateEmptyString,
125
119
  format: (input) => input.trim()
126
120
  },
127
121
  {
@@ -129,7 +123,7 @@ async function promptTarget(defaults, logger) {
129
123
  name: 'client',
130
124
  message: 'Client (optional):',
131
125
  initial: target.client,
132
- validate: project_input_validator_1.validateClient
126
+ validate: validateClient
133
127
  }
134
128
  ]);
135
129
  const systemInfo = await fetchSystemInformation(target, defaults.ignoreCertErrors, logger);
@@ -140,7 +134,7 @@ async function promptTarget(defaults, logger) {
140
134
  logger.debug(error.message);
141
135
  if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY') {
142
136
  logger.error('If you are using a self-signed certificate, please use the --ignore-cert-errors flag.');
143
- const confirm = await (0, prompts_1.default)([
137
+ const confirm = await prompts([
144
138
  {
145
139
  type: 'confirm',
146
140
  name: 'ignoreCertErrors',
@@ -162,20 +156,20 @@ async function promptTarget(defaults, logger) {
162
156
  * @returns app index and layer
163
157
  */
164
158
  async function fetchSystemInformation(target, ignoreCertErrors, logger) {
165
- const provider = await (0, system_access_1.createAbapServiceProvider)(target, {
159
+ const provider = await createAbapServiceProvider(target, {
166
160
  ignoreCertErrors
167
161
  }, true, logger);
168
162
  logger.info('Fetching system information...');
169
163
  const ato = await provider.getAtoInfo();
170
- const layer = ato.tenantType === 'SAP' ? "VENDOR" /* FlexLayer.VENDOR */ : "CUSTOMER_BASE" /* FlexLayer.CUSTOMER_BASE */;
171
- const packageJson = (0, project_utils_1.getPackageJSONInfo)();
164
+ const layer = ato.tenantType === 'SAP' ? FlexLayer.VENDOR : FlexLayer.CUSTOMER_BASE;
165
+ const packageJson = getPackageJSONInfo();
172
166
  const customConfig = {
173
167
  adp: {
174
168
  environment: ato.operationsType ?? 'P',
175
169
  support: {
176
170
  id: packageJson.name ?? '',
177
171
  version: packageJson.version ?? '',
178
- toolsId: (0, uuid_1.v4)()
172
+ toolsId: uuidv4()
179
173
  }
180
174
  }
181
175
  };
package/dist/btp/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
2
  import type { Destinations } from '@sap-ux/btp-utils';
3
- import type { Uaa, BtpDestinationConfig, CfDestinationServiceCredentials } from '../types';
3
+ import type { Uaa, BtpDestinationConfig, CfDestinationServiceCredentials } from '../types.js';
4
4
  /**
5
5
  * Obtain an OAuth2 access token using the client credentials grant.
6
6
  *
package/dist/btp/api.js CHANGED
@@ -1,13 +1,5 @@
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.getToken = getToken;
7
- exports.getBtpDestinationConfig = getBtpDestinationConfig;
8
- exports.listBtpDestinations = listBtpDestinations;
9
- const axios_1 = __importDefault(require("axios"));
10
- const i18n_1 = require("../i18n");
1
+ import axios from 'axios';
2
+ import { t } from '../i18n.js';
11
3
  /**
12
4
  * Obtain an OAuth2 access token using the client credentials grant.
13
5
  *
@@ -15,7 +7,7 @@ const i18n_1 = require("../i18n");
15
7
  * @param logger - Optional logger.
16
8
  * @returns OAuth2 access token.
17
9
  */
18
- async function getToken(uaa, logger) {
10
+ export async function getToken(uaa, logger) {
19
11
  const auth = Buffer.from(`${uaa.clientid}:${uaa.clientsecret}`);
20
12
  const options = {
21
13
  headers: {
@@ -26,13 +18,13 @@ async function getToken(uaa, logger) {
26
18
  const uri = `${uaa.url}/oauth/token`;
27
19
  logger?.debug(`Requesting OAuth token from ${uri}`);
28
20
  try {
29
- const response = await axios_1.default.post(uri, 'grant_type=client_credentials', options);
21
+ const response = await axios.post(uri, 'grant_type=client_credentials', options);
30
22
  logger?.debug('OAuth token obtained successfully');
31
23
  return response.data['access_token'];
32
24
  }
33
25
  catch (e) {
34
26
  logger?.error(`Failed to obtain OAuth token from ${uri}: ${e instanceof Error ? e.message : String(e)}`);
35
- throw new Error((0, i18n_1.t)('error.failedToGetAuthKey', { error: e instanceof Error ? e.message : String(e) }));
27
+ throw new Error(t('error.failedToGetAuthKey', { error: e instanceof Error ? e.message : String(e) }));
36
28
  }
37
29
  }
38
30
  /**
@@ -45,11 +37,11 @@ async function getToken(uaa, logger) {
45
37
  * @param logger - Optional logger.
46
38
  * @returns The destinationConfiguration object (e.g. Name, ProxyType, URL, Authentication) or undefined on failure.
47
39
  */
48
- async function getBtpDestinationConfig(uri, token, destinationName, logger) {
40
+ export async function getBtpDestinationConfig(uri, token, destinationName, logger) {
49
41
  const url = `${uri}/destination-configuration/v1/destinations/${encodeURIComponent(destinationName)}`;
50
42
  logger?.debug(`Fetching BTP destination config for "${destinationName}" from ${url}`);
51
43
  try {
52
- const response = await axios_1.default.get(url, {
44
+ const response = await axios.get(url, {
53
45
  headers: { 'Authorization': `Bearer ${token}` }
54
46
  });
55
47
  const config = response.data?.destinationConfiguration;
@@ -67,14 +59,14 @@ async function getBtpDestinationConfig(uri, token, destinationName, logger) {
67
59
  * @param {CfDestinationServiceCredentials} credentials - Destination service credentials.
68
60
  * @returns {Promise<Destinations>} Map of destination name to Destination object.
69
61
  */
70
- async function listBtpDestinations(credentials) {
62
+ export async function listBtpDestinations(credentials) {
71
63
  const uaa = 'uaa' in credentials
72
64
  ? credentials.uaa
73
65
  : { clientid: credentials.clientid, clientsecret: credentials.clientsecret, url: credentials.url };
74
66
  const token = await getToken(uaa);
75
67
  const url = `${credentials.uri}/destination-configuration/v1/subaccountDestinations`;
76
68
  try {
77
- const response = await axios_1.default.get(url, {
69
+ const response = await axios.get(url, {
78
70
  headers: { Authorization: `Bearer ${token}` }
79
71
  });
80
72
  const configs = Array.isArray(response.data) ? response.data : [];
@@ -91,7 +83,7 @@ async function listBtpDestinations(credentials) {
91
83
  }, {});
92
84
  }
93
85
  catch (e) {
94
- throw new Error((0, i18n_1.t)('error.failedToListBtpDestinations', { error: e instanceof Error ? e.message : String(e) }));
86
+ throw new Error(t('error.failedToListBtpDestinations', { error: e instanceof Error ? e.message : String(e) }));
95
87
  }
96
88
  }
97
89
  //# sourceMappingURL=api.js.map
@@ -1,2 +1,2 @@
1
- export * from './api';
1
+ export * from './api.js';
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/btp/index.js CHANGED
@@ -1,18 +1,2 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./api"), exports);
1
+ export * from './api.js';
18
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import type AdmZip from 'adm-zip';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
- import type { CfConfig, CFApp, ServiceKeys } from '../../types';
3
+ import type { CfConfig, CFApp, ServiceKeys } from '../../types.js';
4
4
  /**
5
5
  * Get the app host ids from service keys.
6
6
  *
@@ -1,20 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppHostIds = getAppHostIds;
4
- exports.getBackendUrlsFromServiceKeys = getBackendUrlsFromServiceKeys;
5
- exports.getServiceKeyDestinations = getServiceKeyDestinations;
6
- exports.getOAuthPathsFromXsApp = getOAuthPathsFromXsApp;
7
- exports.getCfApps = getCfApps;
8
- const i18n_1 = require("../../i18n");
9
- const utils_1 = require("../utils");
10
- const api_1 = require("../services/api");
1
+ import { t } from '../../i18n.js';
2
+ import { extractXSApp } from '../utils/index.js';
3
+ import { getFDCApps } from '../services/api.js';
11
4
  /**
12
5
  * Get the app host ids from service keys.
13
6
  *
14
7
  * @param {ServiceKeys[]} serviceKeys - The service keys.
15
8
  * @returns {string[]} The app host ids.
16
9
  */
17
- function getAppHostIds(serviceKeys) {
10
+ export function getAppHostIds(serviceKeys) {
18
11
  const appHostIds = [];
19
12
  for (const serviceKey of serviceKeys) {
20
13
  const appHostId = serviceKey.credentials['html5-apps-repo']?.app_host_id;
@@ -33,7 +26,7 @@ function getAppHostIds(serviceKeys) {
33
26
  * @param {ServiceKeys[]} serviceKeys - The credentials from service keys.
34
27
  * @returns {string[]} Array of backend URLs (including full paths) or empty array if none found.
35
28
  */
36
- function getBackendUrlsFromServiceKeys(serviceKeys) {
29
+ export function getBackendUrlsFromServiceKeys(serviceKeys) {
37
30
  if (!serviceKeys || serviceKeys.length === 0) {
38
31
  return [];
39
32
  }
@@ -79,7 +72,7 @@ function cleanRoutePath(source) {
79
72
  * @param {ServiceKeys[]} serviceKeys - The service keys.
80
73
  * @returns {Array<{name: string; url: string}>} Array of endpoint destinations.
81
74
  */
82
- function getServiceKeyDestinations(serviceKeys) {
75
+ export function getServiceKeyDestinations(serviceKeys) {
83
76
  const endpointDestinations = [];
84
77
  for (const key of serviceKeys) {
85
78
  const endpoints = key.credentials?.endpoints;
@@ -104,8 +97,8 @@ function getServiceKeyDestinations(serviceKeys) {
104
97
  * @param {AdmZip.IZipEntry[]} zipEntries - The zip entries containing xs-app.json.
105
98
  * @returns {string[]} Array of path patterns (from route.source) that have a source property.
106
99
  */
107
- function getOAuthPathsFromXsApp(zipEntries) {
108
- const xsApp = (0, utils_1.extractXSApp)(zipEntries);
100
+ export function getOAuthPathsFromXsApp(zipEntries) {
101
+ const xsApp = extractXSApp(zipEntries);
109
102
  if (!xsApp?.routes) {
110
103
  return [];
111
104
  }
@@ -129,13 +122,13 @@ function getOAuthPathsFromXsApp(zipEntries) {
129
122
  * @param {ToolsLogger} logger - The logger
130
123
  * @returns {Promise<CFApp[]>} The discovered apps
131
124
  */
132
- async function getCfApps(serviceKeys, cfConfig, logger) {
125
+ export async function getCfApps(serviceKeys, cfConfig, logger) {
133
126
  const appHostIds = getAppHostIds(serviceKeys);
134
127
  logger?.log(`App Host Ids: ${JSON.stringify(appHostIds)}`);
135
128
  // Validate appHostIds array length (max 100 as per API specification)
136
129
  if (appHostIds.length > 100) {
137
- throw new Error((0, i18n_1.t)('error.tooManyAppHostIds', { appHostIdsLength: appHostIds.length }));
130
+ throw new Error(t('error.tooManyAppHostIds', { appHostIdsLength: appHostIds.length }));
138
131
  }
139
- return (0, api_1.getFDCApps)(appHostIds, cfConfig, logger);
132
+ return getFDCApps(appHostIds, cfConfig, logger);
140
133
  }
141
134
  //# sourceMappingURL=discovery.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
- import type { HTML5Content, ServiceInfo, CfAppParams } from '../../types';
2
+ import type { HTML5Content, ServiceInfo, CfAppParams } from '../../types.js';
3
3
  /**
4
4
  * Download zip from HTML5 repository.
5
5
  *