@sap-ux/adp-tooling 0.18.44 → 0.18.45

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,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import { type AnnotationsData, type ChangeType, type DescriptorVariant, type InboundContent, type ManifestChangeProperties, type PropertyValueType } from '../types';
2
+ import { FlexLayer, type AnnotationsData, type ChangeType, type DescriptorVariant, type InboundContent, type ManifestChangeProperties, type PropertyValueType, type AdpWriterConfig } from '../types';
3
3
  export type ChangeMetadata = Pick<DescriptorVariant, 'id' | 'layer' | 'namespace'>;
4
4
  type InboundChangeData = {
5
5
  filePath: string;
@@ -20,6 +20,23 @@ interface InboundChange extends ManifestChangeProperties {
20
20
  * @returns {Promise<void>}
21
21
  */
22
22
  export declare function writeAnnotationChange(projectPath: string, timestamp: number, annotation: AnnotationsData['annotation'], change: ManifestChangeProperties | undefined, fs: Editor, templatesPath?: string): Promise<void>;
23
+ /**
24
+ * Writes key-user change payloads to the generated adaptation project. Transforms key-user changes to a developer adaptation format.
25
+ *
26
+ * @param projectPath - Project root path.
27
+ * @param config - The writer configuration.
28
+ * @param fs - Yeoman mem-fs editor.
29
+ */
30
+ export declare function writeKeyUserChanges(projectPath: string, config: AdpWriterConfig, fs: Editor): Promise<void>;
31
+ /**
32
+ * Transforms a key-user change to a developer adaptation format.
33
+ *
34
+ * @param change - The key-user change from the backend.
35
+ * @param appId - The ID of the newly created Adaptation Project.
36
+ * @param layer - The layer of the change.
37
+ * @returns {Record<string, unknown>} The transformed change object.
38
+ */
39
+ export declare function transformKeyUserChangeForAdp(change: Record<string, unknown>, appId: string, layer: FlexLayer | undefined): Record<string, unknown>;
23
40
  /**
24
41
  * Writes a given change object to a file within a specified folder in the project's 'changes' directory.
25
42
  * If an additional subdirectory is specified, the change file is written there.
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeAnnotationChange = writeAnnotationChange;
7
+ exports.writeKeyUserChanges = writeKeyUserChanges;
8
+ exports.transformKeyUserChangeForAdp = transformKeyUserChangeForAdp;
7
9
  exports.writeChangeToFolder = writeChangeToFolder;
8
10
  exports.writeChangeToFile = writeChangeToFile;
9
11
  exports.parseStringToObject = parseStringToObject;
@@ -61,6 +63,55 @@ async function writeAnnotationChange(projectPath, timestamp, annotation, change,
61
63
  throw new Error(`Could not write annotation changes. Reason: ${e.message}`);
62
64
  }
63
65
  }
66
+ /**
67
+ * Writes key-user change payloads to the generated adaptation project. Transforms key-user changes to a developer adaptation format.
68
+ *
69
+ * @param projectPath - Project root path.
70
+ * @param config - The writer configuration.
71
+ * @param fs - Yeoman mem-fs editor.
72
+ */
73
+ async function writeKeyUserChanges(projectPath, config, fs) {
74
+ const changes = config.keyUserChanges;
75
+ if (!changes?.length) {
76
+ return;
77
+ }
78
+ for (const entry of changes) {
79
+ if (!entry?.content) {
80
+ continue;
81
+ }
82
+ const change = { ...entry.content };
83
+ if (!change['fileName']) {
84
+ continue;
85
+ }
86
+ const transformedChange = transformKeyUserChangeForAdp(change, config.app.id, config.app.layer);
87
+ await writeChangeToFolder(projectPath, transformedChange, fs);
88
+ }
89
+ }
90
+ /**
91
+ * Transforms a key-user change to a developer adaptation format.
92
+ *
93
+ * @param change - The key-user change from the backend.
94
+ * @param appId - The ID of the newly created Adaptation Project.
95
+ * @param layer - The layer of the change.
96
+ * @returns {Record<string, unknown>} The transformed change object.
97
+ */
98
+ function transformKeyUserChangeForAdp(change, appId, layer) {
99
+ const transformed = { ...change };
100
+ transformed.layer = layer ?? "CUSTOMER_BASE" /* FlexLayer.CUSTOMER_BASE */;
101
+ transformed.reference = appId;
102
+ transformed.namespace = node_path_1.default.posix.join('apps', appId, project_access_1.DirName.Changes, '/');
103
+ if (transformed.projectId) {
104
+ transformed.projectId = appId;
105
+ }
106
+ transformed.support ??= {};
107
+ const supportObject = transformed.support;
108
+ supportObject.generator = 'adp-key-user-converter';
109
+ delete transformed.adaptationId;
110
+ delete transformed.version;
111
+ delete transformed.context;
112
+ delete transformed.versionId;
113
+ return transformed;
114
+ }
64
115
  /**
65
116
  * Writes a given change object to a file within a specified folder in the project's 'changes' directory.
66
117
  * If an additional subdirectory is specified, the change file is written there.
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './base/helper';
10
10
  export * from './base/constants';
11
11
  export * from './base/project-builder';
12
12
  export * from './base/abap/manifest-service';
13
+ export { writeKeyUserChanges } from './base/change-utils';
13
14
  export { promptGeneratorInput, PromptDefaults } from './base/prompt';
14
15
  export * from './preview/adp-preview';
15
16
  export * from './writer/cf';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.generateInboundConfig = exports.generateChange = exports.migrate = exports.generate = exports.promptGeneratorInput = void 0;
17
+ exports.generateInboundConfig = exports.generateChange = exports.migrate = exports.generate = exports.promptGeneratorInput = exports.writeKeyUserChanges = void 0;
18
18
  __exportStar(require("./types"), exports);
19
19
  __exportStar(require("./prompts"), exports);
20
20
  __exportStar(require("./common"), exports);
@@ -27,6 +27,8 @@ __exportStar(require("./base/helper"), exports);
27
27
  __exportStar(require("./base/constants"), exports);
28
28
  __exportStar(require("./base/project-builder"), exports);
29
29
  __exportStar(require("./base/abap/manifest-service"), exports);
30
+ var change_utils_1 = require("./base/change-utils");
31
+ Object.defineProperty(exports, "writeKeyUserChanges", { enumerable: true, get: function () { return change_utils_1.writeKeyUserChanges; } });
30
32
  var prompt_1 = require("./base/prompt");
31
33
  Object.defineProperty(exports, "promptGeneratorInput", { enumerable: true, get: function () { return prompt_1.promptGeneratorInput; } });
32
34
  __exportStar(require("./preview/adp-preview"), exports);
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { UI5FlexLayer, ManifestNamespace, Manifest, Package } from '@sap-ux/project-access';
2
2
  import type { DestinationAbapTarget, UrlAbapTarget } from '@sap-ux/system-access';
3
3
  import type { Adp, BspApp } from '@sap-ux/ui5-config';
4
- import type { AxiosRequestConfig, OperationsType } from '@sap-ux/axios-extension';
4
+ import type { AxiosRequestConfig, KeyUserChangeContent, OperationsType } from '@sap-ux/axios-extension';
5
5
  import type { Editor } from 'mem-fs-editor';
6
6
  import type { Destination } from '@sap-ux/btp-utils';
7
7
  import type { YUIQuestion } from '@sap-ux/inquirer-common';
@@ -100,6 +100,10 @@ export interface AdpWriterConfig {
100
100
  */
101
101
  templatePathOverwrite?: string;
102
102
  };
103
+ /**
104
+ * Optional: Key-user changes to be written to the project.
105
+ */
106
+ keyUserChanges?: KeyUserChangeContent[];
103
107
  }
104
108
  /**
105
109
  * Interface representing the answers collected from the configuration prompts of Adaptation Project generator.
@@ -122,6 +126,7 @@ export interface AttributesAnswers {
122
126
  enableTypeScript: boolean;
123
127
  addDeployConfig?: boolean;
124
128
  addFlpConfig?: boolean;
129
+ importKeyUserChanges?: boolean;
125
130
  }
126
131
  export interface SourceApplication {
127
132
  id: string;
@@ -9,6 +9,7 @@ const manifest_1 = require("./manifest");
9
9
  const i18n_1 = require("./i18n");
10
10
  const project_utils_1 = require("./project-utils");
11
11
  const source_1 = require("../source");
12
+ const change_utils_1 = require("../base/change-utils");
12
13
  const baseTmplPath = (0, node_path_1.join)(__dirname, '../../templates');
13
14
  /**
14
15
  * Set default values for optional properties.
@@ -23,7 +24,8 @@ function setDefaults(config) {
23
24
  ui5: { ...config.ui5 },
24
25
  deploy: config.deploy ? { ...config.deploy } : undefined,
25
26
  options: { ...config.options },
26
- customConfig: config.customConfig ? { ...config.customConfig } : undefined
27
+ customConfig: config.customConfig ? { ...config.customConfig } : undefined,
28
+ keyUserChanges: config.keyUserChanges
27
29
  };
28
30
  configWithDefaults.app.title ??= `Adaptation of ${config.app.reference}`;
29
31
  configWithDefaults.app.layer ??= "CUSTOMER_BASE" /* FlexLayer.CUSTOMER_BASE */;
@@ -54,6 +56,7 @@ async function generate(basePath, config, fs) {
54
56
  (0, project_utils_1.writeTemplateToFolder)(templatePath, (0, node_path_1.join)(basePath), fullConfig, fs);
55
57
  await (0, project_utils_1.writeUI5DeployYaml)(basePath, fullConfig, fs);
56
58
  await (0, project_utils_1.writeUI5Yaml)(basePath, fullConfig, fs);
59
+ await (0, change_utils_1.writeKeyUserChanges)(basePath, fullConfig, fs);
57
60
  return fs;
58
61
  }
59
62
  /**
@@ -1,6 +1,6 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
2
  import type { Manifest, Package } from '@sap-ux/project-access';
3
- import type { AbapServiceProvider } from '@sap-ux/axios-extension';
3
+ import type { AbapServiceProvider, KeyUserChangeContent } from '@sap-ux/axios-extension';
4
4
  import type { AdpWriterConfig, AttributesAnswers, CfAdpWriterConfig, ConfigAnswers, CreateCfConfigParams, UI5Version } from '../types';
5
5
  import { FlexLayer } from '../types';
6
6
  export interface ConfigOptions {
@@ -44,6 +44,10 @@ export interface ConfigOptions {
44
44
  * The tools ID.
45
45
  */
46
46
  toolsId: string;
47
+ /**
48
+ * Optional: Key-user changes to be written to the project.
49
+ */
50
+ keyUserChanges?: KeyUserChangeContent[];
47
51
  }
48
52
  /**
49
53
  * Generates the configuration object for the Adaptation Project.
@@ -22,7 +22,7 @@ const i18n_1 = require("../i18n");
22
22
  * @returns {Promise<AdpWriterConfig>} A promise that resolves to the generated ADP writer configuration.
23
23
  */
24
24
  async function getConfig(options) {
25
- const { configAnswers, attributeAnswers, layer, logger, packageJson, provider, publicVersions, systemVersion, manifest, toolsId } = options;
25
+ const { configAnswers, attributeAnswers, layer, logger, packageJson, provider, publicVersions, systemVersion, manifest, toolsId, keyUserChanges } = options;
26
26
  const ato = await provider.getAtoInfo();
27
27
  const operationsType = ato.operationsType ?? 'P';
28
28
  const target = await (0, abap_1.getProviderConfig)(configAnswers.system, logger);
@@ -68,7 +68,8 @@ async function getConfig(options) {
68
68
  options: {
69
69
  fioriTools: true,
70
70
  enableTypeScript
71
- }
71
+ },
72
+ keyUserChanges
72
73
  };
73
74
  }
74
75
  /**
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.44",
12
+ "version": "0.18.45",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "prompts": "2.4.2",
37
37
  "sanitize-filename": "1.6.3",
38
38
  "uuid": "10.0.0",
39
- "@sap-ux/axios-extension": "1.25.6",
39
+ "@sap-ux/axios-extension": "1.25.7",
40
40
  "@sap-ux/btp-utils": "1.1.6",
41
41
  "@sap-ux/i18n": "0.3.7",
42
42
  "@sap-ux/inquirer-common": "0.10.17",
@@ -46,7 +46,7 @@
46
46
  "@sap-ux/project-access": "1.34.2",
47
47
  "@sap-ux/project-input-validator": "0.6.46",
48
48
  "@sap-ux/store": "1.5.1",
49
- "@sap-ux/system-access": "0.6.42",
49
+ "@sap-ux/system-access": "0.6.43",
50
50
  "@sap-ux/ui5-config": "0.29.13",
51
51
  "@sap-ux/ui5-info": "0.13.8"
52
52
  },