@sap-ux/adp-tooling 1.0.58 → 1.0.60

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.
@@ -0,0 +1,29 @@
1
+ import type { KeyUserChangeContent } from '@sap-ux/axios-extension';
2
+ import type { ToolsLogger } from '@sap-ux/logger';
3
+ /**
4
+ * Options for {@link fetchKeyUserChanges}.
5
+ */
6
+ export interface FetchKeyUserChangesOptions {
7
+ system: string;
8
+ application: string;
9
+ client?: string;
10
+ username?: string;
11
+ password?: string;
12
+ logger: ToolsLogger;
13
+ }
14
+ /**
15
+ * Fetches the DEFAULT adaptation's key user changes from LREP for the given application.
16
+ *
17
+ * Mirrors the interactive `KeyUserImportPrompter` in `@sap-ux/generator-adp`:
18
+ * authenticate the ABAP provider, resolve the active flex version, list adaptations,
19
+ * locate the DEFAULT adaptation and download its key user changes.
20
+ *
21
+ * Errors propagate (strict-abort): callers should treat any rejection as a reason to
22
+ * abort the surrounding operation.
23
+ *
24
+ * @param options - System, application id, optional credentials, and a logger.
25
+ * @returns The key user changes attached to the DEFAULT adaptation. May be empty.
26
+ * @throws If the LREP API is unsupported, authentication fails, or no DEFAULT adaptation exists.
27
+ */
28
+ export declare function fetchKeyUserChanges(options: FetchKeyUserChangesOptions): Promise<KeyUserChangeContent[]>;
29
+ //# sourceMappingURL=key-user-changes.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { getConfiguredProvider } from '../../abap/provider.js';
2
+ const DEFAULT_ADAPTATION_ID = 'DEFAULT';
3
+ /**
4
+ * Picks the active flex version. The LREP response lists the draft (`versionId === '0'`)
5
+ * first when one exists; in that case the second entry is the active version. Mirrors
6
+ * the behaviour of `@sap-ux/generator-adp`'s `determineFlexVersion`.
7
+ *
8
+ * @param flexVersions - Flex versions returned by LREP, in priority order.
9
+ * @returns The version id to use, or `undefined` when no usable version exists.
10
+ */
11
+ function determineFlexVersion(flexVersions) {
12
+ if (!flexVersions?.length) {
13
+ return undefined;
14
+ }
15
+ if (flexVersions[0]?.versionId === '0') {
16
+ return flexVersions[1]?.versionId;
17
+ }
18
+ return flexVersions[0]?.versionId;
19
+ }
20
+ /**
21
+ * Fetches the DEFAULT adaptation's key user changes from LREP for the given application.
22
+ *
23
+ * Mirrors the interactive `KeyUserImportPrompter` in `@sap-ux/generator-adp`:
24
+ * authenticate the ABAP provider, resolve the active flex version, list adaptations,
25
+ * locate the DEFAULT adaptation and download its key user changes.
26
+ *
27
+ * Errors propagate (strict-abort): callers should treat any rejection as a reason to
28
+ * abort the surrounding operation.
29
+ *
30
+ * @param options - System, application id, optional credentials, and a logger.
31
+ * @returns The key user changes attached to the DEFAULT adaptation. May be empty.
32
+ * @throws If the LREP API is unsupported, authentication fails, or no DEFAULT adaptation exists.
33
+ */
34
+ export async function fetchKeyUserChanges(options) {
35
+ const { system, application, client, username, password, logger } = options;
36
+ const provider = await getConfiguredProvider({ system, client, username, password }, logger);
37
+ // Ensures auth is performed up-front for Cloud Ready systems before subsequent calls.
38
+ await provider.isAbapCloud();
39
+ const lrep = provider.getLayeredRepository();
40
+ const flexVersionsResponse = await lrep.getFlexVersions(application);
41
+ const activeVersion = determineFlexVersion(flexVersionsResponse?.versions ?? []);
42
+ const adaptationsResponse = await lrep.listAdaptations(application, activeVersion);
43
+ const adaptations = adaptationsResponse?.adaptations ?? [];
44
+ if (!adaptations.length) {
45
+ throw new Error(`No adaptations found for application '${application}' on system '${system}'.`);
46
+ }
47
+ if (!adaptations.some((a) => a.id === DEFAULT_ADAPTATION_ID)) {
48
+ const available = adaptations.map((a) => a.id).join(', ');
49
+ throw new Error(`No DEFAULT adaptation found for application '${application}'. Available adaptations: ${available}.`);
50
+ }
51
+ const keyUserDataResponse = await lrep.getKeyUserData(application, DEFAULT_ADAPTATION_ID);
52
+ const contents = keyUserDataResponse?.contents ?? [];
53
+ logger.info(`Fetched ${contents.length} key user change(s) for DEFAULT adaptation of '${application}' on '${system}'.`);
54
+ return contents;
55
+ }
56
+ //# sourceMappingURL=key-user-changes.js.map
@@ -129,4 +129,13 @@ export declare function filterAndMapInboundsToManifest(inbounds: Inbound[]): Man
129
129
  * @returns App ID (reference)
130
130
  */
131
131
  export declare function getBaseAppId(basePath: string): Promise<string>;
132
+ /**
133
+ * Returns a non-colliding project directory name under `basePath`.
134
+ * Follows the `generator-adp` convention: `app.variant` → `app.variant2` → `app.variant3` …
135
+ *
136
+ * @param basePath Base directory to check for existing project folders.
137
+ * @param dirName Base name prefix; defaults to `"app.variant"`.
138
+ * @returns The first name in the sequence that does not yet exist on disk.
139
+ */
140
+ export declare function getDefaultProjectName(basePath: string, dirName?: string): string;
132
141
  //# sourceMappingURL=helper.d.ts.map
@@ -257,4 +257,23 @@ export async function getBaseAppId(basePath) {
257
257
  throw new Error(`Failed to get app ID: ${error.message}`);
258
258
  }
259
259
  }
260
+ /** Default prefix used when no `dirName` is passed to {@link getDefaultProjectName}. */
261
+ const DEFAULT_PROJECT_PREFIX = 'app.variant';
262
+ /**
263
+ * Returns a non-colliding project directory name under `basePath`.
264
+ * Follows the `generator-adp` convention: `app.variant` → `app.variant2` → `app.variant3` …
265
+ *
266
+ * @param basePath Base directory to check for existing project folders.
267
+ * @param dirName Base name prefix; defaults to `"app.variant"`.
268
+ * @returns The first name in the sequence that does not yet exist on disk.
269
+ */
270
+ export function getDefaultProjectName(basePath, dirName = DEFAULT_PROJECT_PREFIX) {
271
+ let newDir = dirName;
272
+ let index = 1;
273
+ while (existsSync(join(basePath, newDir))) {
274
+ index++;
275
+ newDir = `${dirName}${index}`;
276
+ }
277
+ return newDir;
278
+ }
260
279
  //# sourceMappingURL=helper.js.map
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './base/credentials.js';
12
12
  export * from './base/constants/index.js';
13
13
  export * from './base/project-builder.js';
14
14
  export * from './base/abap/manifest-service.js';
15
+ export * from './base/abap/key-user-changes.js';
15
16
  export { writeKeyUserChanges } from './base/change-utils.js';
16
17
  export { promptGeneratorInput, type PromptDefaults } from './base/prompt.js';
17
18
  export * from './preview/adp-preview.js';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export * from './base/credentials.js';
12
12
  export * from './base/constants/index.js';
13
13
  export * from './base/project-builder.js';
14
14
  export * from './base/abap/manifest-service.js';
15
+ export * from './base/abap/key-user-changes.js';
15
16
  export { writeKeyUserChanges } from './base/change-utils.js';
16
17
  export { promptGeneratorInput } from './base/prompt.js';
17
18
  export * from './preview/adp-preview.js';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
12
12
  },
13
- "version": "1.0.58",
13
+ "version": "1.0.60",
14
14
  "license": "Apache-2.0",
15
15
  "author": "@SAP/ux-tools-team",
16
16
  "main": "dist/index.js",
@@ -46,7 +46,7 @@
46
46
  "@sap-ux/nodejs-utils": "1.0.10",
47
47
  "@sap-ux/odata-service-writer": "1.0.23",
48
48
  "@sap-ux/project-access": "2.2.1",
49
- "@sap-ux/project-input-validator": "1.0.20",
49
+ "@sap-ux/project-input-validator": "1.0.21",
50
50
  "@sap-ux/store": "2.0.7",
51
51
  "@sap-ux/system-access": "1.0.14",
52
52
  "@sap-ux/ui5-config": "1.0.9",