@sap-ux/adp-tooling 0.12.93 → 0.12.95
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.
- package/dist/base/abap/manifest-service.d.ts +21 -18
- package/dist/base/abap/manifest-service.js +26 -24
- package/dist/base/helper.d.ts +20 -0
- package/dist/base/helper.js +31 -0
- package/dist/common/flp-parameters.d.ts +9 -0
- package/dist/common/flp-parameters.js +169 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/types.d.ts +60 -3
- package/dist/writer/inbound-navigation.d.ts +31 -0
- package/dist/writer/inbound-navigation.js +67 -0
- package/dist/writer/options.js +5 -1
- package/package.json +4 -3
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import type { Manifest, ManifestNamespace } from '@sap-ux/project-access';
|
|
2
1
|
import type { ToolsLogger } from '@sap-ux/logger';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
2
|
+
import type { Manifest, ManifestNamespace } from '@sap-ux/project-access';
|
|
3
|
+
import { type AbapServiceProvider } from '@sap-ux/axios-extension';
|
|
4
|
+
import type { DescriptorVariant } from '../../types';
|
|
5
5
|
type DataSources = Record<string, ManifestNamespace.DataSource>;
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves the inbound navigation configurations from the project's manifest.
|
|
8
|
+
*
|
|
9
|
+
* @param {Manifest} manifest - The manifest file object adhering to the SAP JSON schema for web application manifest files.
|
|
10
|
+
* @returns {ManifestNamespace.Inbound | undefined} The inbound navigation configurations, or `undefined` if no configurations are present.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getInboundsFromManifest(manifest: Manifest): ManifestNamespace.Inbound | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the registration ID from the manifest file.
|
|
15
|
+
*
|
|
16
|
+
* @param {Manifest} manifest - The manifest file object adhering to the SAP JSON schema for web application manifest files.
|
|
17
|
+
* @returns {string | undefined} The first registration ID if available, otherwise `undefined`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getRegistrationIdFromManifest(manifest: Manifest): string | undefined;
|
|
6
20
|
/**
|
|
7
21
|
* Service class for handling operations related to the manifest of a UI5 application.
|
|
8
22
|
* The class supports operations for both base and merged manifests.
|
|
@@ -21,36 +35,25 @@ export declare class ManifestService {
|
|
|
21
35
|
* @param logger - The logger instance.
|
|
22
36
|
*/
|
|
23
37
|
private constructor();
|
|
24
|
-
/**
|
|
25
|
-
* Initializes the ManifestService with the given ADP configuration and logger.
|
|
26
|
-
*
|
|
27
|
-
* @param adpConfig - The ADP preview configuration.
|
|
28
|
-
* @param logger - The logger instance.
|
|
29
|
-
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
|
|
30
|
-
* @returns A promise that resolves to an instance of ManifestService.
|
|
31
|
-
*/
|
|
32
|
-
private static init;
|
|
33
38
|
/**
|
|
34
39
|
* Creates an instance of the ManifestService and fetches the base manifest of the application.
|
|
35
40
|
*
|
|
41
|
+
* @param provider - The ABAP service provider instance.
|
|
36
42
|
* @param appId - The application ID.
|
|
37
|
-
* @param adpConfig - The ADP preview configuration.
|
|
38
43
|
* @param logger - The logger instance.
|
|
39
|
-
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
|
|
40
44
|
* @returns A promise that resolves to an instance of ManifestService.
|
|
41
45
|
*/
|
|
42
|
-
static initBaseManifest(
|
|
46
|
+
static initBaseManifest(provider: AbapServiceProvider, appId: string, logger: ToolsLogger): Promise<ManifestService>;
|
|
43
47
|
/**
|
|
44
48
|
* Creates an instance of the ManifestService and fetches the merged manifest of the application.
|
|
45
49
|
*
|
|
50
|
+
* @param provider - The ABAP service provider instance.
|
|
46
51
|
* @param basePath - The base path of the application.
|
|
47
52
|
* @param variant - The descriptor variant.
|
|
48
|
-
* @param adpConfig - The ADP preview configuration.
|
|
49
53
|
* @param logger - The logger instance.
|
|
50
|
-
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
|
|
51
54
|
* @returns A promise that resolves to an instance of ManifestService.
|
|
52
55
|
*/
|
|
53
|
-
static initMergedManifest(basePath: string, variant: DescriptorVariant,
|
|
56
|
+
static initMergedManifest(provider: AbapServiceProvider, basePath: string, variant: DescriptorVariant, logger: ToolsLogger): Promise<ManifestService>;
|
|
54
57
|
/**
|
|
55
58
|
* Fetches the base manifest for a given application ID.
|
|
56
59
|
*
|
|
@@ -4,10 +4,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ManifestService = void 0;
|
|
7
|
+
exports.getInboundsFromManifest = getInboundsFromManifest;
|
|
8
|
+
exports.getRegistrationIdFromManifest = getRegistrationIdFromManifest;
|
|
7
9
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
8
10
|
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
9
|
-
const system_access_1 = require("@sap-ux/system-access");
|
|
10
11
|
const helper_1 = require("../helper");
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the inbound navigation configurations from the project's manifest.
|
|
14
|
+
*
|
|
15
|
+
* @param {Manifest} manifest - The manifest file object adhering to the SAP JSON schema for web application manifest files.
|
|
16
|
+
* @returns {ManifestNamespace.Inbound | undefined} The inbound navigation configurations, or `undefined` if no configurations are present.
|
|
17
|
+
*/
|
|
18
|
+
function getInboundsFromManifest(manifest) {
|
|
19
|
+
return manifest?.['sap.app']?.crossNavigation?.inbounds;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the registration ID from the manifest file.
|
|
23
|
+
*
|
|
24
|
+
* @param {Manifest} manifest - The manifest file object adhering to the SAP JSON schema for web application manifest files.
|
|
25
|
+
* @returns {string | undefined} The first registration ID if available, otherwise `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
function getRegistrationIdFromManifest(manifest) {
|
|
28
|
+
return manifest?.['sap.fiori']?.registrationIds?.[0];
|
|
29
|
+
}
|
|
11
30
|
/**
|
|
12
31
|
* Service class for handling operations related to the manifest of a UI5 application.
|
|
13
32
|
* The class supports operations for both base and merged manifests.
|
|
@@ -29,47 +48,30 @@ class ManifestService {
|
|
|
29
48
|
this.provider = provider;
|
|
30
49
|
this.logger = logger;
|
|
31
50
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Initializes the ManifestService with the given ADP configuration and logger.
|
|
34
|
-
*
|
|
35
|
-
* @param adpConfig - The ADP preview configuration.
|
|
36
|
-
* @param logger - The logger instance.
|
|
37
|
-
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
|
|
38
|
-
* @returns A promise that resolves to an instance of ManifestService.
|
|
39
|
-
*/
|
|
40
|
-
static async init(adpConfig, logger, requestOptions) {
|
|
41
|
-
const provider = await (0, system_access_1.createAbapServiceProvider)(adpConfig.target, {
|
|
42
|
-
...requestOptions,
|
|
43
|
-
ignoreCertErrors: adpConfig.ignoreCertErrors ?? false
|
|
44
|
-
}, true, logger);
|
|
45
|
-
return new ManifestService(provider, logger);
|
|
46
|
-
}
|
|
47
51
|
/**
|
|
48
52
|
* Creates an instance of the ManifestService and fetches the base manifest of the application.
|
|
49
53
|
*
|
|
54
|
+
* @param provider - The ABAP service provider instance.
|
|
50
55
|
* @param appId - The application ID.
|
|
51
|
-
* @param adpConfig - The ADP preview configuration.
|
|
52
56
|
* @param logger - The logger instance.
|
|
53
|
-
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
|
|
54
57
|
* @returns A promise that resolves to an instance of ManifestService.
|
|
55
58
|
*/
|
|
56
|
-
static async initBaseManifest(
|
|
57
|
-
const manifestService =
|
|
59
|
+
static async initBaseManifest(provider, appId, logger) {
|
|
60
|
+
const manifestService = new ManifestService(provider, logger);
|
|
58
61
|
await manifestService.fetchBaseManifest(appId);
|
|
59
62
|
return manifestService;
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* Creates an instance of the ManifestService and fetches the merged manifest of the application.
|
|
63
66
|
*
|
|
67
|
+
* @param provider - The ABAP service provider instance.
|
|
64
68
|
* @param basePath - The base path of the application.
|
|
65
69
|
* @param variant - The descriptor variant.
|
|
66
|
-
* @param adpConfig - The ADP preview configuration.
|
|
67
70
|
* @param logger - The logger instance.
|
|
68
|
-
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
|
|
69
71
|
* @returns A promise that resolves to an instance of ManifestService.
|
|
70
72
|
*/
|
|
71
|
-
static async initMergedManifest(basePath, variant,
|
|
72
|
-
const manifestService =
|
|
73
|
+
static async initMergedManifest(provider, basePath, variant, logger) {
|
|
74
|
+
const manifestService = new ManifestService(provider, logger);
|
|
73
75
|
await manifestService.fetchMergedManifest(basePath, variant.id);
|
|
74
76
|
await manifestService.fetchAppInfo(variant.reference);
|
|
75
77
|
return manifestService;
|
package/dist/base/helper.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
1
2
|
import type { DescriptorVariant, AdpPreviewConfig } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Get the app descriptor variant.
|
|
@@ -6,6 +7,25 @@ import type { DescriptorVariant, AdpPreviewConfig } from '../types';
|
|
|
6
7
|
* @returns {DescriptorVariant} The app descriptor variant.
|
|
7
8
|
*/
|
|
8
9
|
export declare function getVariant(basePath: string): DescriptorVariant;
|
|
10
|
+
/**
|
|
11
|
+
* Writes the updated variant content to the manifest.appdescr_variant file.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} basePath - The base path of the project.
|
|
14
|
+
* @param {DescriptorVariant} variant - The descriptor variant object.
|
|
15
|
+
* @param {Editor} fs - The mem-fs editor instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function updateVariant(basePath: string, variant: DescriptorVariant, fs: Editor): void;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if FLP configuration changes exist in the manifest.appdescr_variant.
|
|
20
|
+
*
|
|
21
|
+
* This function determines whether there are changes of type `appdescr_app_changeInbound`
|
|
22
|
+
* or `appdescr_app_addNewInbound` present in the content of the descriptor variant.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} basePath - The base path of the project where the manifest.appdescr_variant is located.
|
|
25
|
+
* @returns {boolean} Returns `true` if FLP configuration changes exist, otherwise `false`.
|
|
26
|
+
* @throws {Error} Throws an error if the variant could not be retrieved.
|
|
27
|
+
*/
|
|
28
|
+
export declare function flpConfigurationExists(basePath: string): boolean;
|
|
9
29
|
/**
|
|
10
30
|
* Returns the adaptation project configuration, throws an error if not found.
|
|
11
31
|
*
|
package/dist/base/helper.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVariant = getVariant;
|
|
4
|
+
exports.updateVariant = updateVariant;
|
|
5
|
+
exports.flpConfigurationExists = flpConfigurationExists;
|
|
4
6
|
exports.getAdpConfig = getAdpConfig;
|
|
5
7
|
exports.getWebappFiles = getWebappFiles;
|
|
6
8
|
const fs_1 = require("fs");
|
|
@@ -15,6 +17,35 @@ const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
|
15
17
|
function getVariant(basePath) {
|
|
16
18
|
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(basePath, 'webapp', 'manifest.appdescr_variant'), 'utf-8'));
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Writes the updated variant content to the manifest.appdescr_variant file.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} basePath - The base path of the project.
|
|
24
|
+
* @param {DescriptorVariant} variant - The descriptor variant object.
|
|
25
|
+
* @param {Editor} fs - The mem-fs editor instance.
|
|
26
|
+
*/
|
|
27
|
+
function updateVariant(basePath, variant, fs) {
|
|
28
|
+
fs.writeJSON((0, path_1.join)(basePath, 'webapp', 'manifest.appdescr_variant'), variant);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks if FLP configuration changes exist in the manifest.appdescr_variant.
|
|
32
|
+
*
|
|
33
|
+
* This function determines whether there are changes of type `appdescr_app_changeInbound`
|
|
34
|
+
* or `appdescr_app_addNewInbound` present in the content of the descriptor variant.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} basePath - The base path of the project where the manifest.appdescr_variant is located.
|
|
37
|
+
* @returns {boolean} Returns `true` if FLP configuration changes exist, otherwise `false`.
|
|
38
|
+
* @throws {Error} Throws an error if the variant could not be retrieved.
|
|
39
|
+
*/
|
|
40
|
+
function flpConfigurationExists(basePath) {
|
|
41
|
+
try {
|
|
42
|
+
const variant = getVariant(basePath);
|
|
43
|
+
return variant.content?.some(({ changeType }) => changeType === 'appdescr_app_changeInbound' || changeType === 'appdescr_app_addNewInbound');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new Error(`Failed to check if FLP configuration exists: ${error.message}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
18
49
|
/**
|
|
19
50
|
* Returns the adaptation project configuration, throws an error if not found.
|
|
20
51
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Parameter } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse parameters string into parameters object.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} paramString - parameters string
|
|
6
|
+
* @returns {Parameter} parsed parameters string object
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseParameters(paramString: string): Parameter;
|
|
9
|
+
//# sourceMappingURL=flp-parameters.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseParameters = parseParameters;
|
|
4
|
+
const defaultParamCheck = { shouldApply: false, value: undefined };
|
|
5
|
+
const rules = {
|
|
6
|
+
isEmptyParam: (paramString) => {
|
|
7
|
+
if (/^.+=\s*$/g.test(paramString)) {
|
|
8
|
+
return {
|
|
9
|
+
shouldApply: true,
|
|
10
|
+
value: paramString.replaceAll('=', '').trim()
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return defaultParamCheck;
|
|
14
|
+
},
|
|
15
|
+
isMandatoryParam: (paramString) => {
|
|
16
|
+
return !(paramString.trim().startsWith('(') && paramString.trim().endsWith(')'));
|
|
17
|
+
},
|
|
18
|
+
shouldHavеFilteredValue: (paramString) => {
|
|
19
|
+
if (paramString.startsWith('<') && paramString.endsWith('>')) {
|
|
20
|
+
return {
|
|
21
|
+
shouldApply: true,
|
|
22
|
+
value: paramString.replace(/[<>]/g, '')
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return defaultParamCheck;
|
|
26
|
+
},
|
|
27
|
+
shouldRenameTo: (paramString) => {
|
|
28
|
+
if (paramString.trim().startsWith('>')) {
|
|
29
|
+
return {
|
|
30
|
+
shouldApply: true,
|
|
31
|
+
value: paramString.trim().replace(/>/g, '')
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return defaultParamCheck;
|
|
35
|
+
},
|
|
36
|
+
isReference: (paramString) => {
|
|
37
|
+
if (paramString.startsWith('%%') && paramString.endsWith('%%')) {
|
|
38
|
+
return {
|
|
39
|
+
shouldApply: true,
|
|
40
|
+
value: paramString.replace(/%/g, '')
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return defaultParamCheck;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const genericErrorMessage = (error) => `Value cannot be parsed: ${error}! Please check the entered value and if needed create ticket for the application component in order to get the proper value.`;
|
|
47
|
+
/**
|
|
48
|
+
* Parse parameters string into parameters object.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} paramString - parameters string
|
|
51
|
+
* @returns {Parameter} parsed parameters string object
|
|
52
|
+
*/
|
|
53
|
+
function parseParameters(paramString) {
|
|
54
|
+
let result = {};
|
|
55
|
+
const modifiedParamString = addMissingAmpersands(paramString);
|
|
56
|
+
const params = modifiedParamString
|
|
57
|
+
.split('&')
|
|
58
|
+
.map((el) => el.trim())
|
|
59
|
+
.filter((el) => el !== '');
|
|
60
|
+
params.forEach((param) => {
|
|
61
|
+
const isMandatory = rules.isMandatoryParam(param);
|
|
62
|
+
if (!isMandatory) {
|
|
63
|
+
param = param.replace(/[()]/g, '');
|
|
64
|
+
}
|
|
65
|
+
const isEmptyParamCheck = rules.isEmptyParam(param);
|
|
66
|
+
if (isEmptyParamCheck.shouldApply && isEmptyParamCheck.value) {
|
|
67
|
+
checkForDuplicatedKeys(result, isEmptyParamCheck.value);
|
|
68
|
+
result = Object.assign(result, { [isEmptyParamCheck.value]: {} });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const paramParts = param
|
|
72
|
+
.split('=')
|
|
73
|
+
.map((el) => el.trim())
|
|
74
|
+
.filter((el) => el !== '');
|
|
75
|
+
if (paramParts.length <= 1 || paramParts.length > 3) {
|
|
76
|
+
throw new SyntaxError(genericErrorMessage('Invalid parameters string'));
|
|
77
|
+
}
|
|
78
|
+
result = Object.assign(result, construct(paramParts, isMandatory, result));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Fuction that adds missing & between parameters if needed.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} value - parameters string
|
|
87
|
+
* @returns {string} modified value
|
|
88
|
+
*/
|
|
89
|
+
function addMissingAmpersands(value) {
|
|
90
|
+
return value.replace(/\)\s*\(/gm, ')&(');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Fuction that checks of there are duplicated properties in Parameter object while constructing.
|
|
94
|
+
*
|
|
95
|
+
* @param {Parameter} parameters - parsed parameters
|
|
96
|
+
* @param {string} key - property for check
|
|
97
|
+
* @throws if there are duplicated properties
|
|
98
|
+
*/
|
|
99
|
+
function checkForDuplicatedKeys(parameters, key) {
|
|
100
|
+
Object.keys(parameters).forEach((existingKey) => {
|
|
101
|
+
if (existingKey === key) {
|
|
102
|
+
throw new Error(genericErrorMessage(`Duplicated parameter: '${key}'`));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Fuction that construct parameters object applying parameters rules.
|
|
108
|
+
*
|
|
109
|
+
* @param {string[]} paramParts - current parameter parts
|
|
110
|
+
* @param {boolean} isMandatory - whether param is mandatory
|
|
111
|
+
* @param {Parameter} parameters - constructed parameters
|
|
112
|
+
* @returns {Parameter} constucted parameters
|
|
113
|
+
*/
|
|
114
|
+
function construct(paramParts, isMandatory, parameters) {
|
|
115
|
+
const constructedParams = {};
|
|
116
|
+
const paramName = paramParts[0];
|
|
117
|
+
checkForDuplicatedKeys(parameters, paramName);
|
|
118
|
+
constructedParams[paramName] = {
|
|
119
|
+
required: isMandatory
|
|
120
|
+
};
|
|
121
|
+
if (paramParts.length === 2) {
|
|
122
|
+
const shouldRenameCheck = rules.shouldRenameTo(paramParts[1]);
|
|
123
|
+
if (shouldRenameCheck.shouldApply) {
|
|
124
|
+
constructedParams[paramName].renameTo = shouldRenameCheck.value;
|
|
125
|
+
return constructedParams;
|
|
126
|
+
}
|
|
127
|
+
applyRules(constructedParams[paramName], paramParts[1]);
|
|
128
|
+
return constructedParams;
|
|
129
|
+
}
|
|
130
|
+
const secondParamPart = paramParts[1];
|
|
131
|
+
const thirdParamPart = paramParts[2];
|
|
132
|
+
applyRules(constructedParams[paramName], secondParamPart);
|
|
133
|
+
const shouldRenameCheck = rules.shouldRenameTo(thirdParamPart);
|
|
134
|
+
if (shouldRenameCheck.shouldApply) {
|
|
135
|
+
constructedParams[paramName].renameTo = shouldRenameCheck.value;
|
|
136
|
+
}
|
|
137
|
+
return constructedParams;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Function that applies parameter rules.
|
|
141
|
+
*
|
|
142
|
+
* @param {ParameterOptions} options - parameter options
|
|
143
|
+
* @param {string} paramValue - parameter value
|
|
144
|
+
*/
|
|
145
|
+
function applyRules(options, paramValue) {
|
|
146
|
+
const shouldFilterDefaultValueCheck = rules.shouldHavеFilteredValue(paramValue);
|
|
147
|
+
const isReferenceCheck = rules.isReference(paramValue);
|
|
148
|
+
if (shouldFilterDefaultValueCheck.shouldApply &&
|
|
149
|
+
!isReferenceCheck.shouldApply &&
|
|
150
|
+
shouldFilterDefaultValueCheck.value) {
|
|
151
|
+
options.filter = {
|
|
152
|
+
value: shouldFilterDefaultValueCheck.value,
|
|
153
|
+
format: 'plain'
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
else if (!shouldFilterDefaultValueCheck.shouldApply && !isReferenceCheck.shouldApply) {
|
|
157
|
+
options.defaultValue = {
|
|
158
|
+
value: paramValue,
|
|
159
|
+
format: 'plain'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else if (isReferenceCheck.shouldApply && isReferenceCheck.value) {
|
|
163
|
+
options.defaultValue = {
|
|
164
|
+
value: isReferenceCheck.value,
|
|
165
|
+
format: 'reference'
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=flp-parameters.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./flp-parameters"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './prompts';
|
|
3
|
+
export * from './common';
|
|
3
4
|
export * from './base/cf';
|
|
4
5
|
export * from './base/abap/manifest-service';
|
|
5
6
|
export * from './base/helper';
|
|
6
7
|
export * from './preview/adp-preview';
|
|
7
8
|
export { generate, migrate } from './writer';
|
|
8
9
|
export { generateChange } from './writer/editors';
|
|
10
|
+
export { generateInboundConfig } from './writer/inbound-navigation';
|
|
9
11
|
export { promptGeneratorInput, PromptDefaults } from './base/prompt';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,10 @@ 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.promptGeneratorInput = exports.generateChange = exports.migrate = exports.generate = void 0;
|
|
17
|
+
exports.promptGeneratorInput = exports.generateInboundConfig = exports.generateChange = exports.migrate = exports.generate = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
__exportStar(require("./prompts"), exports);
|
|
20
|
+
__exportStar(require("./common"), exports);
|
|
20
21
|
__exportStar(require("./base/cf"), exports);
|
|
21
22
|
__exportStar(require("./base/abap/manifest-service"), exports);
|
|
22
23
|
__exportStar(require("./base/helper"), exports);
|
|
@@ -26,6 +27,8 @@ Object.defineProperty(exports, "generate", { enumerable: true, get: function ()
|
|
|
26
27
|
Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return writer_1.migrate; } });
|
|
27
28
|
var editors_1 = require("./writer/editors");
|
|
28
29
|
Object.defineProperty(exports, "generateChange", { enumerable: true, get: function () { return editors_1.generateChange; } });
|
|
30
|
+
var inbound_navigation_1 = require("./writer/inbound-navigation");
|
|
31
|
+
Object.defineProperty(exports, "generateInboundConfig", { enumerable: true, get: function () { return inbound_navigation_1.generateInboundConfig; } });
|
|
29
32
|
var prompt_1 = require("./base/prompt");
|
|
30
33
|
Object.defineProperty(exports, "promptGeneratorInput", { enumerable: true, get: function () { return prompt_1.promptGeneratorInput; } });
|
|
31
34
|
//# sourceMappingURL=index.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export interface DescriptorVariant {
|
|
|
13
13
|
export interface DescriptorVariantContent {
|
|
14
14
|
changeType: string;
|
|
15
15
|
content: Record<string, unknown>;
|
|
16
|
-
texts?: string
|
|
16
|
+
texts?: string | {
|
|
17
|
+
i18n?: string;
|
|
18
|
+
};
|
|
17
19
|
}
|
|
18
20
|
export interface ToolsSupport {
|
|
19
21
|
id: string;
|
|
@@ -89,7 +91,8 @@ export interface NewInboundNavigation {
|
|
|
89
91
|
semanticObject: string;
|
|
90
92
|
/** Operations which can be performed on a semantic object. */
|
|
91
93
|
action: string;
|
|
92
|
-
|
|
94
|
+
/** Defined instance of the semantic object (e.g. by specifying the employee ID). */
|
|
95
|
+
additionalParameters?: string;
|
|
93
96
|
/** Title associated with the inbound navigation. */
|
|
94
97
|
title: string;
|
|
95
98
|
/** Optional: Subtitle associated with the inbound navigation. */
|
|
@@ -99,7 +102,7 @@ export interface InternalInboundNavigation extends NewInboundNavigation {
|
|
|
99
102
|
/** Identifier for the inbound navigation. */
|
|
100
103
|
inboundId: string;
|
|
101
104
|
/** Flag indicating if the new inbound navigation should be added. */
|
|
102
|
-
addInboundId
|
|
105
|
+
addInboundId?: boolean;
|
|
103
106
|
}
|
|
104
107
|
export type FlpConfig = ChangeInboundNavigation | NewInboundNavigation;
|
|
105
108
|
export interface Language {
|
|
@@ -178,6 +181,60 @@ export interface CodeExtChange extends CommonChangeProperties {
|
|
|
178
181
|
controllerName: string;
|
|
179
182
|
};
|
|
180
183
|
}
|
|
184
|
+
export interface ParamCheck {
|
|
185
|
+
shouldApply: boolean;
|
|
186
|
+
value: string | undefined;
|
|
187
|
+
}
|
|
188
|
+
export interface ParameterOptions {
|
|
189
|
+
required: boolean;
|
|
190
|
+
filter?: Value;
|
|
191
|
+
defaultValue?: Value;
|
|
192
|
+
renameTo?: string;
|
|
193
|
+
}
|
|
194
|
+
export interface Value {
|
|
195
|
+
value: string;
|
|
196
|
+
format: string;
|
|
197
|
+
}
|
|
198
|
+
export interface Parameter {
|
|
199
|
+
[key: string]: ParameterOptions;
|
|
200
|
+
}
|
|
201
|
+
export type ParameterRules = {
|
|
202
|
+
/**
|
|
203
|
+
* Function that checks whether param has empty value, e.g parameter defined in the following format has empty value: param1=
|
|
204
|
+
*
|
|
205
|
+
* @param {string} param - param string
|
|
206
|
+
* @returns {ParamCheck} object which indicates if this rule should be applied and the parameter value
|
|
207
|
+
*/
|
|
208
|
+
isEmptyParam(param: string): ParamCheck;
|
|
209
|
+
/**
|
|
210
|
+
* Function that define whether param is mandatory, param which is placed inside () is not mandatory
|
|
211
|
+
*
|
|
212
|
+
* @param {string} param - param string
|
|
213
|
+
* @returns {boolean} whether param string is mandatory or not
|
|
214
|
+
*/
|
|
215
|
+
isMandatoryParam(param: string): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Function that checks whehter param has filter value, e.g parameter value placed inside <> indicates for filter value: param1=<value>
|
|
218
|
+
*
|
|
219
|
+
* @param {string} param - param string
|
|
220
|
+
* @returns {ParamCheck} object which indicates if this rule should be applied and the parameter value
|
|
221
|
+
*/
|
|
222
|
+
shouldHavеFilteredValue(param: string): ParamCheck;
|
|
223
|
+
/**
|
|
224
|
+
* Function that checks whether parameter has rename to value, e.g param1=>value
|
|
225
|
+
*
|
|
226
|
+
* @param {string} param - param string
|
|
227
|
+
* @returns {ParamCheck} object which indicates if this rule should be applied and the parameter value
|
|
228
|
+
*/
|
|
229
|
+
shouldRenameTo(param: string): ParamCheck;
|
|
230
|
+
/**
|
|
231
|
+
* Function thath checks whether parameter value should have reference as format value, e.g param1=%%value%%
|
|
232
|
+
*
|
|
233
|
+
* @param {string} param - param string
|
|
234
|
+
* @returns {ParamCheck} object which indicates if this rule should be applied and the parameter value
|
|
235
|
+
*/
|
|
236
|
+
isReference(param: string): ParamCheck;
|
|
237
|
+
};
|
|
181
238
|
export declare const enum TemplateFileName {
|
|
182
239
|
Fragment = "fragment.xml",
|
|
183
240
|
Controller = "controller.ejs",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Editor } from 'mem-fs-editor';
|
|
2
|
+
import { type NewI18nEntry } from '@sap-ux/i18n';
|
|
3
|
+
import type { InternalInboundNavigation } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Generates and writes the inbound configuration to the manifest.appdescr_variant file.
|
|
6
|
+
*
|
|
7
|
+
* @param basePath - The base path of the project.
|
|
8
|
+
* @param config - The inbound configuration properties.
|
|
9
|
+
* @param fs - Optional mem-fs editor instance.
|
|
10
|
+
* @returns The mem-fs editor instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateInboundConfig(basePath: string, config: InternalInboundNavigation, fs?: Editor): Promise<Editor>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates i18n entries for FLP configuration based on the provided configuration and application ID.
|
|
15
|
+
*
|
|
16
|
+
* @param {InternalInboundNavigation} config - The inbound configuration properties.
|
|
17
|
+
* @param {string} appId - The application ID for creating unique i18n keys.
|
|
18
|
+
* @returns {NewI18nEntry[]} An array of new i18n entries to be added or updated.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getFlpI18nKeys(config: InternalInboundNavigation, appId: string): NewI18nEntry[];
|
|
21
|
+
/**
|
|
22
|
+
* Updates the i18n.properties file with new FLP configuration entries.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} basePath - The base path of the project.
|
|
25
|
+
* @param {string} appId - The application ID used to generate i18n keys.
|
|
26
|
+
* @param {InternalInboundNavigation} config - The inbound configuration properties.
|
|
27
|
+
* @param {Editor} fs - The mem-fs editor instance for file operations.
|
|
28
|
+
* @returns {Promise<void>} A promise that resolves when the i18n file is updated.
|
|
29
|
+
*/
|
|
30
|
+
export declare function updateI18n(basePath: string, appId: string, config: InternalInboundNavigation, fs: Editor): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=inbound-navigation.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
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.generateInboundConfig = generateInboundConfig;
|
|
7
|
+
exports.getFlpI18nKeys = getFlpI18nKeys;
|
|
8
|
+
exports.updateI18n = updateI18n;
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const mem_fs_1 = require("mem-fs");
|
|
11
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
12
|
+
const i18n_1 = require("@sap-ux/i18n");
|
|
13
|
+
const __1 = require("../");
|
|
14
|
+
const options_1 = require("./options");
|
|
15
|
+
/**
|
|
16
|
+
* Generates and writes the inbound configuration to the manifest.appdescr_variant file.
|
|
17
|
+
*
|
|
18
|
+
* @param basePath - The base path of the project.
|
|
19
|
+
* @param config - The inbound configuration properties.
|
|
20
|
+
* @param fs - Optional mem-fs editor instance.
|
|
21
|
+
* @returns The mem-fs editor instance.
|
|
22
|
+
*/
|
|
23
|
+
async function generateInboundConfig(basePath, config, fs) {
|
|
24
|
+
if (!fs) {
|
|
25
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
26
|
+
}
|
|
27
|
+
const variant = (0, __1.getVariant)(basePath);
|
|
28
|
+
if (!config?.inboundId) {
|
|
29
|
+
config.addInboundId = true;
|
|
30
|
+
config.inboundId = `${variant.id}.InboundID`;
|
|
31
|
+
}
|
|
32
|
+
(0, options_1.enhanceManifestChangeContentWithFlpConfig)(config, variant.id, variant.content);
|
|
33
|
+
(0, __1.updateVariant)(basePath, variant, fs);
|
|
34
|
+
await updateI18n(basePath, variant.id, config, fs);
|
|
35
|
+
return fs;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates i18n entries for FLP configuration based on the provided configuration and application ID.
|
|
39
|
+
*
|
|
40
|
+
* @param {InternalInboundNavigation} config - The inbound configuration properties.
|
|
41
|
+
* @param {string} appId - The application ID for creating unique i18n keys.
|
|
42
|
+
* @returns {NewI18nEntry[]} An array of new i18n entries to be added or updated.
|
|
43
|
+
*/
|
|
44
|
+
function getFlpI18nKeys(config, appId) {
|
|
45
|
+
const newEntries = [];
|
|
46
|
+
const baseKey = `${appId}_sap.app.crossNavigation.inbounds.${config.inboundId}`;
|
|
47
|
+
newEntries.push({ key: `${baseKey}.title`, value: config.title });
|
|
48
|
+
if (config?.subTitle) {
|
|
49
|
+
newEntries.push({ key: `${baseKey}.subTitle`, value: config.title });
|
|
50
|
+
}
|
|
51
|
+
return newEntries;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Updates the i18n.properties file with new FLP configuration entries.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} basePath - The base path of the project.
|
|
57
|
+
* @param {string} appId - The application ID used to generate i18n keys.
|
|
58
|
+
* @param {InternalInboundNavigation} config - The inbound configuration properties.
|
|
59
|
+
* @param {Editor} fs - The mem-fs editor instance for file operations.
|
|
60
|
+
* @returns {Promise<void>} A promise that resolves when the i18n file is updated.
|
|
61
|
+
*/
|
|
62
|
+
async function updateI18n(basePath, appId, config, fs) {
|
|
63
|
+
const newEntries = getFlpI18nKeys(config, appId);
|
|
64
|
+
const i18nPath = path_1.default.join(basePath, 'webapp', 'i18n', 'i18n.properties');
|
|
65
|
+
await (0, i18n_1.createPropertiesI18nEntries)(i18nPath, newEntries, basePath, fs);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=inbound-navigation.js.map
|
package/dist/writer/options.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.enhanceUI5YamlWithCustomConfig = enhanceUI5YamlWithCustomConfig;
|
|
|
6
6
|
exports.hasDeployConfig = hasDeployConfig;
|
|
7
7
|
exports.enhanceUI5DeployYaml = enhanceUI5DeployYaml;
|
|
8
8
|
exports.enhanceManifestChangeContentWithFlpConfig = enhanceManifestChangeContentWithFlpConfig;
|
|
9
|
+
const common_1 = require("../common");
|
|
9
10
|
const VSCODE_URL = 'https://REQUIRED_FOR_VSCODE.example';
|
|
10
11
|
/**
|
|
11
12
|
* Generate the configuration for the middlewares required for the ui5.yaml.
|
|
@@ -235,6 +236,9 @@ function getInboundChangeContentWithExistingInboundId(flpConfiguration, appId) {
|
|
|
235
236
|
* @returns Inbound change content.
|
|
236
237
|
*/
|
|
237
238
|
function getInboundChangeContentWithNewInboundID(flpConfiguration, appId) {
|
|
239
|
+
const parameters = flpConfiguration?.additionalParameters
|
|
240
|
+
? (0, common_1.parseParameters)(flpConfiguration?.additionalParameters)
|
|
241
|
+
: {};
|
|
238
242
|
const content = {
|
|
239
243
|
inbound: {
|
|
240
244
|
[flpConfiguration.inboundId]: {
|
|
@@ -243,7 +247,7 @@ function getInboundChangeContentWithNewInboundID(flpConfiguration, appId) {
|
|
|
243
247
|
title: `{{${appId}_sap.app.crossNavigation.inbounds.${flpConfiguration.inboundId}.title}}`,
|
|
244
248
|
signature: {
|
|
245
249
|
additionalParameters: 'allowed',
|
|
246
|
-
parameters
|
|
250
|
+
parameters
|
|
247
251
|
}
|
|
248
252
|
}
|
|
249
253
|
}
|
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.12.
|
|
12
|
+
"version": "0.12.95",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -34,12 +34,13 @@
|
|
|
34
34
|
"uuid": "10.0.0",
|
|
35
35
|
"@sap-ux/axios-extension": "1.17.7",
|
|
36
36
|
"@sap-ux/btp-utils": "0.17.1",
|
|
37
|
-
"@sap-ux/inquirer-common": "0.5.
|
|
37
|
+
"@sap-ux/inquirer-common": "0.5.11",
|
|
38
38
|
"@sap-ux/logger": "0.6.0",
|
|
39
39
|
"@sap-ux/project-access": "1.28.9",
|
|
40
40
|
"@sap-ux/project-input-validator": "0.3.4",
|
|
41
41
|
"@sap-ux/system-access": "0.5.22",
|
|
42
|
-
"@sap-ux/ui5-config": "0.26.0"
|
|
42
|
+
"@sap-ux/ui5-config": "0.26.0",
|
|
43
|
+
"@sap-ux/i18n": "0.2.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@types/adm-zip": "0.5.5",
|