@sap-ux/adp-tooling 0.13.21 → 0.13.24
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/abap/client.d.ts +18 -0
- package/dist/abap/client.js +43 -0
- package/dist/abap/config.d.ts +19 -0
- package/dist/abap/config.js +50 -0
- package/dist/abap/index.d.ts +4 -0
- package/dist/{client → abap}/index.js +3 -3
- package/dist/abap/provider.d.ts +22 -0
- package/dist/abap/provider.js +33 -0
- package/dist/base/constants/index.d.ts +8 -0
- package/dist/base/constants/index.js +9 -1
- package/dist/base/prompt.js +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/preview/routes-handler.js +17 -7
- package/dist/source/applications.d.ts +41 -0
- package/dist/source/applications.js +94 -0
- package/dist/source/index.d.ts +4 -0
- package/dist/source/index.js +20 -0
- package/dist/source/manifest.d.ts +70 -0
- package/dist/source/manifest.js +123 -0
- package/dist/{client/target-systems.d.ts → source/systems.d.ts} +2 -2
- package/dist/{client/target-systems.js → source/systems.js} +4 -4
- package/dist/translations/adp-tooling.i18n.json +2 -1
- package/dist/types.d.ts +15 -2
- package/dist/ui5/fetch.d.ts +16 -0
- package/dist/ui5/fetch.js +34 -0
- package/dist/ui5/format.d.ts +80 -0
- package/dist/ui5/format.js +135 -0
- package/dist/ui5/index.d.ts +4 -0
- package/dist/ui5/index.js +20 -0
- package/dist/ui5/version-info.d.ts +106 -0
- package/dist/ui5/version-info.js +193 -0
- package/dist/writer/changes/writers/annotations-writer.js +17 -7
- package/dist/writer/project-utils.d.ts +10 -11
- package/dist/writer/project-utils.js +10 -8
- package/dist/writer/writer-config.d.ts +45 -21
- package/dist/writer/writer-config.js +44 -46
- package/package.json +1 -1
- package/dist/client/abap-provider.d.ts +0 -53
- package/dist/client/abap-provider.js +0 -106
- package/dist/client/index.d.ts +0 -4
- package/dist/client/target-applications.d.ts +0 -56
- package/dist/client/target-applications.js +0 -112
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SourceManifest = void 0;
|
|
4
|
+
exports.isV4Application = isV4Application;
|
|
5
|
+
exports.isSyncLoadedView = isSyncLoadedView;
|
|
6
|
+
const i18n_1 = require("../i18n");
|
|
7
|
+
/**
|
|
8
|
+
* Evaluates whether the application described by the manifest is a SAP Fiori Elements version 4 application.
|
|
9
|
+
*
|
|
10
|
+
* @param {Manifest} manifest - The application manifest to evaluate.
|
|
11
|
+
* @returns {boolean} True if the application uses SAP Fiori Elements version 4 libraries.
|
|
12
|
+
*/
|
|
13
|
+
function isV4Application(manifest) {
|
|
14
|
+
return !!manifest?.['sap.ui5']?.dependencies?.libs?.['sap.fe.templates'];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Checks if views are loaded synchronously or asynchronously in the UI5 settings of the manifest.
|
|
18
|
+
* Sets the isAppSync property based on the loading method.
|
|
19
|
+
*
|
|
20
|
+
* @param {Manifest['sap.ui5']} ui5Settings - The UI5 settings part of the manifest.
|
|
21
|
+
* @returns {boolean} Boolean if views are loaded synchronously or asynchronously.
|
|
22
|
+
*/
|
|
23
|
+
function isSyncLoadedView(ui5Settings) {
|
|
24
|
+
if (ui5Settings?.rootView) {
|
|
25
|
+
const rootView = ui5Settings?.rootView;
|
|
26
|
+
return !rootView.async;
|
|
27
|
+
}
|
|
28
|
+
if (ui5Settings?.routing && ui5Settings['routing']['config']) {
|
|
29
|
+
return !ui5Settings['routing']['config']['async'];
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Service class for handling operations related to application manifests.
|
|
35
|
+
* Manifest and URL are lazily loaded and stored internally.
|
|
36
|
+
*/
|
|
37
|
+
class SourceManifest {
|
|
38
|
+
provider;
|
|
39
|
+
appId;
|
|
40
|
+
logger;
|
|
41
|
+
/**
|
|
42
|
+
* The parsed manifest object, loaded once and cached internally.
|
|
43
|
+
*/
|
|
44
|
+
manifest;
|
|
45
|
+
/**
|
|
46
|
+
* The manifest URL for the specified application, loaded once and cached internally.
|
|
47
|
+
*/
|
|
48
|
+
manifestUrl;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an instance of SourceManifest.
|
|
51
|
+
*
|
|
52
|
+
* @param {AbapServiceProvider} provider - The ABAP service provider for communicating with the system.
|
|
53
|
+
* @param {string} appId - The ID of the application whose manifest should be managed.
|
|
54
|
+
* @param {ToolsLogger} logger - Optional logger for debugging purposes.
|
|
55
|
+
*/
|
|
56
|
+
constructor(provider, appId, logger) {
|
|
57
|
+
this.provider = provider;
|
|
58
|
+
this.appId = appId;
|
|
59
|
+
this.logger = logger;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the manifest URL, loading it if not already available.
|
|
63
|
+
*
|
|
64
|
+
* @returns {Promise<string>} A promise resolving to the manifest URL string.
|
|
65
|
+
*/
|
|
66
|
+
async getManifestUrl() {
|
|
67
|
+
if (!this.manifestUrl) {
|
|
68
|
+
this.manifestUrl = await this.loadManifestUrl();
|
|
69
|
+
}
|
|
70
|
+
return this.manifestUrl;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the parsed manifest, loading it if not already available.
|
|
74
|
+
*
|
|
75
|
+
* @returns A promise resolving to the parsed manifest object.
|
|
76
|
+
*/
|
|
77
|
+
async getManifest() {
|
|
78
|
+
if (!this.manifest) {
|
|
79
|
+
this.manifest = await this.loadManifest();
|
|
80
|
+
}
|
|
81
|
+
return this.manifest;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Loads the manifest URL from the system using the application ID.
|
|
85
|
+
* The result is stored internally for future access.
|
|
86
|
+
*
|
|
87
|
+
* @returns {Promise<string>} A promise that resolves once the URL has been fetched and set.
|
|
88
|
+
*/
|
|
89
|
+
async loadManifestUrl() {
|
|
90
|
+
const appIndex = this.provider.getAppIndex();
|
|
91
|
+
const data = await appIndex.getAppInfo(this.appId);
|
|
92
|
+
const appInfo = data ? Object.values(data)[0] : undefined;
|
|
93
|
+
const url = appInfo?.manifestUrl ?? appInfo?.manifest ?? '';
|
|
94
|
+
if (!url) {
|
|
95
|
+
this.logger?.debug(`Manifest URL for app '${this.appId}' was not found!`);
|
|
96
|
+
throw new Error((0, i18n_1.t)('validators.appDoesNotSupportManifest'));
|
|
97
|
+
}
|
|
98
|
+
return url;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Loads the manifest from the system and stores it internally.
|
|
102
|
+
* Requires a manifest URL to be available (loads it if necessary).
|
|
103
|
+
*
|
|
104
|
+
* @returns {Promise<Manifest>} A promise that resolves once the manifest has been fetched and parsed.
|
|
105
|
+
*/
|
|
106
|
+
async loadManifest() {
|
|
107
|
+
const url = this.manifestUrl ?? (await this.loadManifestUrl());
|
|
108
|
+
try {
|
|
109
|
+
const response = await this.provider.request({ url });
|
|
110
|
+
const manifest = JSON.parse(response.data);
|
|
111
|
+
if (typeof manifest !== 'object' || manifest === null) {
|
|
112
|
+
throw new Error('Manifest parsing error. Manifest is not in expected format.');
|
|
113
|
+
}
|
|
114
|
+
return manifest;
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
this.logger?.debug(`Failed to load manifest for '${this.appId}', error: ${e.message}`);
|
|
118
|
+
throw new Error(`Failed to load manifest from URL: ${e.message}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.SourceManifest = SourceManifest;
|
|
123
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -19,7 +19,7 @@ export declare const transformBackendSystem: (system: BackendSystem) => Endpoint
|
|
|
19
19
|
* Service class to manage and retrieve information about system systems,
|
|
20
20
|
* including their names, authentication requirements, and specific details.
|
|
21
21
|
*/
|
|
22
|
-
export declare class
|
|
22
|
+
export declare class SystemLookup {
|
|
23
23
|
private readonly logger;
|
|
24
24
|
private systems;
|
|
25
25
|
/**
|
|
@@ -56,4 +56,4 @@ export declare class TargetSystems {
|
|
|
56
56
|
*/
|
|
57
57
|
getSystemRequiresAuth(system: string): Promise<boolean>;
|
|
58
58
|
}
|
|
59
|
-
//# sourceMappingURL=
|
|
59
|
+
//# sourceMappingURL=systems.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SystemLookup = exports.transformBackendSystem = void 0;
|
|
4
4
|
exports.getEndpointNames = getEndpointNames;
|
|
5
5
|
const store_1 = require("@sap-ux/store");
|
|
6
6
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
@@ -38,7 +38,7 @@ exports.transformBackendSystem = transformBackendSystem;
|
|
|
38
38
|
* Service class to manage and retrieve information about system systems,
|
|
39
39
|
* including their names, authentication requirements, and specific details.
|
|
40
40
|
*/
|
|
41
|
-
class
|
|
41
|
+
class SystemLookup {
|
|
42
42
|
logger;
|
|
43
43
|
systems;
|
|
44
44
|
/**
|
|
@@ -120,5 +120,5 @@ class TargetSystems {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
exports.
|
|
124
|
-
//# sourceMappingURL=
|
|
123
|
+
exports.SystemLookup = SystemLookup;
|
|
124
|
+
//# sourceMappingURL=systems.js.map
|
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
"errorDuplicateNamesOData": "OData Service Name must be different from OData Annotation Data Source Name",
|
|
68
68
|
"errorInputInvalidValuePrefix": "{{value}} should start with '{{prefix}}'",
|
|
69
69
|
"errorCustomerEmptyValue": "{{value}} should contain at least one character in addition to '{{prefix}}'",
|
|
70
|
-
"errorInvalidDataSourceURI": "Invalid URI.
|
|
70
|
+
"errorInvalidDataSourceURI": "Invalid URI. The URI must start and end with '/' and contain no spaces.",
|
|
71
|
+
"appDoesNotSupportManifest": "The selected application is not supported by the adaptation project. Select a different application. For more information, see SAPUI5 Adaptation Project documentation."
|
|
71
72
|
},
|
|
72
73
|
"choices": {
|
|
73
74
|
"true": "true",
|
package/dist/types.d.ts
CHANGED
|
@@ -90,9 +90,9 @@ export interface ConfigAnswers {
|
|
|
90
90
|
system: string;
|
|
91
91
|
username: string;
|
|
92
92
|
password: string;
|
|
93
|
-
application:
|
|
93
|
+
application: SourceApplication;
|
|
94
94
|
}
|
|
95
|
-
export interface
|
|
95
|
+
export interface SourceApplication {
|
|
96
96
|
id: string;
|
|
97
97
|
title: string;
|
|
98
98
|
ach: string;
|
|
@@ -101,6 +101,19 @@ export interface TargetApplication {
|
|
|
101
101
|
bspUrl: string;
|
|
102
102
|
bspName: string;
|
|
103
103
|
}
|
|
104
|
+
export interface FlexUISupportedSystem {
|
|
105
|
+
isUIFlex: boolean;
|
|
106
|
+
isOnPremise: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface UI5Version {
|
|
109
|
+
latest: VersionDetail;
|
|
110
|
+
[key: string]: VersionDetail;
|
|
111
|
+
}
|
|
112
|
+
export interface VersionDetail {
|
|
113
|
+
version: string;
|
|
114
|
+
support: string;
|
|
115
|
+
lts: boolean;
|
|
116
|
+
}
|
|
104
117
|
export interface Endpoint extends Partial<Destination> {
|
|
105
118
|
Name: string;
|
|
106
119
|
Url?: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UI5Version } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches public UI5 version data from the SAP CDN.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Promise<UI5Version>} A promise that resolves to the UI5 version data object.
|
|
6
|
+
* @throws Will throw an error if the fetch fails.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchPublicVersions(): Promise<UI5Version>;
|
|
9
|
+
/**
|
|
10
|
+
* Fetches internal UI5 versions from the Neo CDN and maps them to formatted version strings.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} latestVersion - The latest public UI5 version.
|
|
13
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of formatted internal version strings.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchInternalVersions(latestVersion: string): Promise<string[]>;
|
|
16
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchPublicVersions = fetchPublicVersions;
|
|
4
|
+
exports.fetchInternalVersions = fetchInternalVersions;
|
|
5
|
+
const constants_1 = require("../base/constants");
|
|
6
|
+
/**
|
|
7
|
+
* Fetches public UI5 version data from the SAP CDN.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<UI5Version>} A promise that resolves to the UI5 version data object.
|
|
10
|
+
* @throws Will throw an error if the fetch fails.
|
|
11
|
+
*/
|
|
12
|
+
async function fetchPublicVersions() {
|
|
13
|
+
const response = await fetch(constants_1.UI5_VERSIONS_CDN_URL);
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`Failed to fetch public UI5 versions. Status: ${response.status}`);
|
|
16
|
+
}
|
|
17
|
+
return response.json();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetches internal UI5 versions from the Neo CDN and maps them to formatted version strings.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} latestVersion - The latest public UI5 version.
|
|
23
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of formatted internal version strings.
|
|
24
|
+
*/
|
|
25
|
+
async function fetchInternalVersions(latestVersion) {
|
|
26
|
+
const response = await fetch(constants_1.UI5_VERSIONS_NEO_CDN_URL);
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
return data?.routes?.map((route) => {
|
|
29
|
+
return route.target.version === latestVersion
|
|
30
|
+
? `${route.target.version} ${constants_1.LATEST_VERSION}`
|
|
31
|
+
: route.target.version;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the official base URL for SAP UI5 resources based on the version information.
|
|
3
|
+
* If the version includes 'snapshot', it returns a preview URL; otherwise, it returns the main SAP UI5 CDN URL.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} version - The UI5 version string, which may include qualifiers like 'snapshot'.
|
|
6
|
+
* @returns {string} The base URL for UI5 resources appropriate to the specified version.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getOfficialBaseUI5VersionUrl(version: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Formats a UI5 version string by removing extraneous information and adjusting the format of snapshot versions.
|
|
11
|
+
* Snapshot versions are reformatted from '1.96.0-snapshot' to 'snapshot-1.96'.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} version - The original version string which may include additional descriptors like 'snapshot'.
|
|
14
|
+
* @returns {string} A cleaned-up and, if applicable, restructured version string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getFormattedVersion(version: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a string representing the current system version with appropriate labels.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} formattedVersion - The version string with timestamps removed.
|
|
21
|
+
* @param {string} snapshotLabel - The snapshot label computed for the version.
|
|
22
|
+
* @param {string} latestLabel - The label for the latest version if applicable.
|
|
23
|
+
* @returns {string} The constructed version string.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildSystemVersionLabel(formattedVersion: string, snapshotLabel: string, latestLabel: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Removes parenthetical information from a version string, typically used to clean up annotations such as "(latest)".
|
|
28
|
+
*
|
|
29
|
+
* @param {string} version - The version string which may include parenthetical information.
|
|
30
|
+
* @returns {string} The version string without the parenthetical content.
|
|
31
|
+
*/
|
|
32
|
+
export declare function removeBracketsFromVersion(version: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Removes the micro part of a version string, simplifying it to include only the major and minor version numbers.
|
|
35
|
+
* For example, it transforms a version string from '1.87.3' to '1.87'.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} version - The full version string that may include major, minor, and micro version numbers.
|
|
38
|
+
* @returns {string} The version string consisting of only the major and minor version numbers.
|
|
39
|
+
*/
|
|
40
|
+
export declare function removeMicroPart(version: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Removes the timestamp part from a version string, typically used to clean up snapshot versions that include a timestamp.
|
|
43
|
+
* Converts a version string like '1.95.0.34566363464' to '1.95.0'.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} version - The version string that may include a timestamp as part of a snapshot version.
|
|
46
|
+
* @returns {string} The version string without the timestamp, including only the major, minor, and micro version numbers.
|
|
47
|
+
*/
|
|
48
|
+
export declare function removeTimestampFromVersion(version: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Conditionally appends a '-snapshot' suffix to a version string if certain criteria are met.
|
|
51
|
+
* The suffix is added only if the version string includes an unreleased snapshot version.
|
|
52
|
+
* For example, it adds '-snapshot' if the version from the system includes a timestamp and differs from the latest released version.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} version - The original version string that may include a timestamp.
|
|
55
|
+
* @param {string} latestVersion - The most recently released version string, used for comparison.
|
|
56
|
+
* @returns {string} The '-snapshot' suffix if applicable; otherwise, an empty string.
|
|
57
|
+
*/
|
|
58
|
+
export declare function addSnapshot(version: string, latestVersion: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Function that parse the UI5 version. Returns NaN for snapshot or snapshot-untested. eturns x.xx for snapshot-x.xx.xx.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} version the UI5 version to parse
|
|
63
|
+
* @returns The major, the minor and the patch version, e.g. 1.86.11
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseUI5Version(version: string): {
|
|
66
|
+
major: number;
|
|
67
|
+
minor: number;
|
|
68
|
+
patch: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Determines if a specific feature, introduced in a given version, is supported in the current or specified version.
|
|
72
|
+
* This function checks if the provided version is greater than or equal to the feature introduction version.
|
|
73
|
+
* It also handles edge cases where versions might include 'snapshot' or 'snapshot-untested' strings.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} featureVersion - The version string from which the feature is available (e.g., "1.125.3").
|
|
76
|
+
* @param {string} [version] - The current version string of the application; if not provided, the feature is assumed unsupported.
|
|
77
|
+
* @returns {boolean} - Returns true if the current version supports the feature, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isFeatureSupportedVersion(featureVersion: string, version?: string): boolean;
|
|
80
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOfficialBaseUI5VersionUrl = getOfficialBaseUI5VersionUrl;
|
|
4
|
+
exports.getFormattedVersion = getFormattedVersion;
|
|
5
|
+
exports.buildSystemVersionLabel = buildSystemVersionLabel;
|
|
6
|
+
exports.removeBracketsFromVersion = removeBracketsFromVersion;
|
|
7
|
+
exports.removeMicroPart = removeMicroPart;
|
|
8
|
+
exports.removeTimestampFromVersion = removeTimestampFromVersion;
|
|
9
|
+
exports.addSnapshot = addSnapshot;
|
|
10
|
+
exports.parseUI5Version = parseUI5Version;
|
|
11
|
+
exports.isFeatureSupportedVersion = isFeatureSupportedVersion;
|
|
12
|
+
const constants_1 = require("../base/constants");
|
|
13
|
+
/**
|
|
14
|
+
* Gets the official base URL for SAP UI5 resources based on the version information.
|
|
15
|
+
* If the version includes 'snapshot', it returns a preview URL; otherwise, it returns the main SAP UI5 CDN URL.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} version - The UI5 version string, which may include qualifiers like 'snapshot'.
|
|
18
|
+
* @returns {string} The base URL for UI5 resources appropriate to the specified version.
|
|
19
|
+
*/
|
|
20
|
+
function getOfficialBaseUI5VersionUrl(version) {
|
|
21
|
+
if (version.toLowerCase().includes('snapshot')) {
|
|
22
|
+
return constants_1.SNAPSHOT_CDN_URL;
|
|
23
|
+
}
|
|
24
|
+
return constants_1.UI5_CDN_URL;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Formats a UI5 version string by removing extraneous information and adjusting the format of snapshot versions.
|
|
28
|
+
* Snapshot versions are reformatted from '1.96.0-snapshot' to 'snapshot-1.96'.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} version - The original version string which may include additional descriptors like 'snapshot'.
|
|
31
|
+
* @returns {string} A cleaned-up and, if applicable, restructured version string.
|
|
32
|
+
*/
|
|
33
|
+
function getFormattedVersion(version) {
|
|
34
|
+
version = removeBracketsFromVersion(version);
|
|
35
|
+
return version.toLowerCase().includes('-snapshot') ? `snapshot-${removeMicroPart(version)}` : version;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a string representing the current system version with appropriate labels.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} formattedVersion - The version string with timestamps removed.
|
|
41
|
+
* @param {string} snapshotLabel - The snapshot label computed for the version.
|
|
42
|
+
* @param {string} latestLabel - The label for the latest version if applicable.
|
|
43
|
+
* @returns {string} The constructed version string.
|
|
44
|
+
*/
|
|
45
|
+
function buildSystemVersionLabel(formattedVersion, snapshotLabel, latestLabel) {
|
|
46
|
+
return `${formattedVersion}${snapshotLabel} ${constants_1.CURRENT_SYSTEM_VERSION}${latestLabel}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Removes parenthetical information from a version string, typically used to clean up annotations such as "(latest)".
|
|
50
|
+
*
|
|
51
|
+
* @param {string} version - The version string which may include parenthetical information.
|
|
52
|
+
* @returns {string} The version string without the parenthetical content.
|
|
53
|
+
*/
|
|
54
|
+
function removeBracketsFromVersion(version) {
|
|
55
|
+
if (version.indexOf('(') !== -1) {
|
|
56
|
+
const versionParts = version.split('(');
|
|
57
|
+
return versionParts[0].trim();
|
|
58
|
+
}
|
|
59
|
+
return version;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Removes the micro part of a version string, simplifying it to include only the major and minor version numbers.
|
|
63
|
+
* For example, it transforms a version string from '1.87.3' to '1.87'.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} version - The full version string that may include major, minor, and micro version numbers.
|
|
66
|
+
* @returns {string} The version string consisting of only the major and minor version numbers.
|
|
67
|
+
*/
|
|
68
|
+
function removeMicroPart(version) {
|
|
69
|
+
const versionParts = version.split('.');
|
|
70
|
+
return `${versionParts[0]}.${versionParts[1]}`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Removes the timestamp part from a version string, typically used to clean up snapshot versions that include a timestamp.
|
|
74
|
+
* Converts a version string like '1.95.0.34566363464' to '1.95.0'.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} version - The version string that may include a timestamp as part of a snapshot version.
|
|
77
|
+
* @returns {string} The version string without the timestamp, including only the major, minor, and micro version numbers.
|
|
78
|
+
*/
|
|
79
|
+
function removeTimestampFromVersion(version) {
|
|
80
|
+
const versionParts = version.split('.');
|
|
81
|
+
return `${versionParts[0]}.${versionParts[1]}.${versionParts[2]}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Conditionally appends a '-snapshot' suffix to a version string if certain criteria are met.
|
|
85
|
+
* The suffix is added only if the version string includes an unreleased snapshot version.
|
|
86
|
+
* For example, it adds '-snapshot' if the version from the system includes a timestamp and differs from the latest released version.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} version - The original version string that may include a timestamp.
|
|
89
|
+
* @param {string} latestVersion - The most recently released version string, used for comparison.
|
|
90
|
+
* @returns {string} The '-snapshot' suffix if applicable; otherwise, an empty string.
|
|
91
|
+
*/
|
|
92
|
+
function addSnapshot(version, latestVersion) {
|
|
93
|
+
const versionParts = version.split('.');
|
|
94
|
+
return versionParts[3] && removeTimestampFromVersion(version) != latestVersion ? '-snapshot' : '';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Function that parse the UI5 version. Returns NaN for snapshot or snapshot-untested. eturns x.xx for snapshot-x.xx.xx.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} version the UI5 version to parse
|
|
100
|
+
* @returns The major, the minor and the patch version, e.g. 1.86.11
|
|
101
|
+
*/
|
|
102
|
+
function parseUI5Version(version) {
|
|
103
|
+
const versionParts = version ? version.replace(/snapshot-untested|snapshot-|snapshot/, '').split('.') : [];
|
|
104
|
+
const major = parseInt(versionParts[0], 10);
|
|
105
|
+
const minor = parseInt(versionParts[1], 10);
|
|
106
|
+
const patch = parseInt(versionParts[2], 10);
|
|
107
|
+
return { major, minor, patch };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Determines if a specific feature, introduced in a given version, is supported in the current or specified version.
|
|
111
|
+
* This function checks if the provided version is greater than or equal to the feature introduction version.
|
|
112
|
+
* It also handles edge cases where versions might include 'snapshot' or 'snapshot-untested' strings.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} featureVersion - The version string from which the feature is available (e.g., "1.125.3").
|
|
115
|
+
* @param {string} [version] - The current version string of the application; if not provided, the feature is assumed unsupported.
|
|
116
|
+
* @returns {boolean} - Returns true if the current version supports the feature, false otherwise.
|
|
117
|
+
*/
|
|
118
|
+
function isFeatureSupportedVersion(featureVersion, version) {
|
|
119
|
+
if (!version || !featureVersion) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const { major: featMajorVersion, minor: featMinorVersion, patch: featPatchVersion } = parseUI5Version(featureVersion);
|
|
123
|
+
const { major, minor, patch } = parseUI5Version(version);
|
|
124
|
+
if (isNaN(major) && isNaN(minor) && isNaN(patch)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
if (major > featMajorVersion) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
else if (minor < featMinorVersion) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return patch >= featPatchVersion;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./version-info"), exports);
|
|
18
|
+
__exportStar(require("./format"), exports);
|
|
19
|
+
__exportStar(require("./fetch"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { FlexLayer } from '../types';
|
|
2
|
+
import type { UI5Version } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Service class for handling SAP UI5 version information.
|
|
5
|
+
* This class provides methods to fetch and validate UI5 versions, retrieve public and internal versions,
|
|
6
|
+
* and format or modify version strings as per specific requirements like snapshots.
|
|
7
|
+
*
|
|
8
|
+
* @class UI5VersionInfo
|
|
9
|
+
*/
|
|
10
|
+
export declare class UI5VersionInfo {
|
|
11
|
+
/** Singleton instance */
|
|
12
|
+
private static instance;
|
|
13
|
+
/** Public UI5 version data fetched from CDN */
|
|
14
|
+
private publicVersions;
|
|
15
|
+
/** All available internal UI5 versions (fetched once and cached) */
|
|
16
|
+
private releasedVersions;
|
|
17
|
+
/** Indicates if a valid UI5 version was detected on the system */
|
|
18
|
+
isVersionDetected: boolean;
|
|
19
|
+
/** System-detected UI5 version */
|
|
20
|
+
systemVersion?: string;
|
|
21
|
+
/** Whether the project is CUSTOMER_BASE layer */
|
|
22
|
+
private readonly isCustomerBase;
|
|
23
|
+
/**
|
|
24
|
+
* Private constructor to enforce singleton pattern.
|
|
25
|
+
*
|
|
26
|
+
* @param {FlexLayer} layer - Flex layer (used once to configure instance).
|
|
27
|
+
*/
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Returns the singleton instance of UI5VersionManager.
|
|
31
|
+
*
|
|
32
|
+
* @param {FlexLayer} layer - Used only during first initialization.
|
|
33
|
+
* @returns {UI5VersionManager} Instance.
|
|
34
|
+
*/
|
|
35
|
+
static getInstance(layer: FlexLayer): UI5VersionInfo;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the latest version from the available public versions.
|
|
38
|
+
*
|
|
39
|
+
* @returns The latest available version.
|
|
40
|
+
*/
|
|
41
|
+
getLatestVersion(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Fetches public versions from the UI5 CDN.
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<UI5Version>} An object containing version details fetched from the UI5 CDN.
|
|
46
|
+
*/
|
|
47
|
+
getPublicVersions(): Promise<UI5Version>;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves and filters internal UI5 versions.
|
|
50
|
+
*
|
|
51
|
+
* If the versions have not been cached, it calls fetchInternalVersions() to retrieve and cache them.
|
|
52
|
+
* It then filters the versions based on the minimum supported version.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} latestVersion - The latest available version.
|
|
55
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of supported internal UI5 version strings.
|
|
56
|
+
*/
|
|
57
|
+
private getInternalVersions;
|
|
58
|
+
/**
|
|
59
|
+
* Determines the appropriate UI5 version to use based on the provided version string and customer base status.
|
|
60
|
+
* This function handles scenarios where a 'snapshot' version might be in use while in external mode,
|
|
61
|
+
* or when the environment specifically requires using the latest public version, such as for S4HANA Cloud.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} version - The current version string, which may include qualifiers like 'snapshot'.
|
|
64
|
+
* @param {boolean} isCustomerBase - Flag indicating whether the current mode is based on a customer base.
|
|
65
|
+
* @returns {string} The version string to be used.
|
|
66
|
+
* @example
|
|
67
|
+
* // returns '1.80.2'
|
|
68
|
+
* getVersionToBeUsed('1.80.2', false);
|
|
69
|
+
* @example
|
|
70
|
+
* // returns 'latestVersion' property value from class if 'version' contains 'snapshot'
|
|
71
|
+
* getVersionToBeUsed('1.84.6 snapshot', true);
|
|
72
|
+
*/
|
|
73
|
+
getVersionToBeUsed(version: string, isCustomerBase: boolean): string;
|
|
74
|
+
/**
|
|
75
|
+
* Computes version labels based on the provided version.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} version - The original version string.
|
|
78
|
+
* @returns {VersionLabels} An object with the formatted version, snapshot label, and latest label.
|
|
79
|
+
*/
|
|
80
|
+
private getVersionLabels;
|
|
81
|
+
/**
|
|
82
|
+
* Determines if the provided version follows the standard version format.
|
|
83
|
+
*
|
|
84
|
+
* @param {string | undefined} version - The version string to be checked.
|
|
85
|
+
* @returns {string | undefined} A system version or undefined.
|
|
86
|
+
*/
|
|
87
|
+
private checkSystemVersionPattern;
|
|
88
|
+
/**
|
|
89
|
+
* Gets versions relevant based on the system or user type.
|
|
90
|
+
* For internal users, all available versions are returned.
|
|
91
|
+
* For external users, only versions higher than the current system version are shown.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} [systemVersion] - The current system version.
|
|
94
|
+
* @returns {Promise<string[]>} An array of relevant version strings.
|
|
95
|
+
* If the version is not detected, returns the latest released version.
|
|
96
|
+
*/
|
|
97
|
+
getRelevantVersions(systemVersion?: string): Promise<string[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Fetches versions that are higher than a specified version.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} version - The baseline version to compare against.
|
|
102
|
+
* @returns {Promise<string[]>} An array of versions higher than the specified version.
|
|
103
|
+
*/
|
|
104
|
+
private getHigherVersions;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=version-info.d.ts.map
|