@sap-ux/preview-middleware 0.20.0 → 0.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/client/adp/add-fragment.js +46 -46
  2. package/dist/client/adp/api-handler.js +159 -159
  3. package/dist/client/adp/command-executor.js +75 -75
  4. package/dist/client/adp/command-executor.ts +4 -4
  5. package/dist/client/adp/control-utils.js +44 -44
  6. package/dist/client/adp/controllers/AddFragment.controller.js +1 -1
  7. package/dist/client/adp/controllers/AddFragment.controller.ts +2 -2
  8. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +1 -1
  9. package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +2 -2
  10. package/dist/client/adp/controllers/BaseDialog.controller.js +2 -13
  11. package/dist/client/adp/controllers/BaseDialog.controller.ts +7 -25
  12. package/dist/client/adp/controllers/ControllerExtension.controller.js +268 -210
  13. package/dist/client/adp/controllers/ControllerExtension.controller.ts +110 -22
  14. package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
  15. package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
  16. package/dist/client/adp/dialog-factory.js +135 -135
  17. package/dist/client/adp/dialog-factory.ts +3 -1
  18. package/dist/client/adp/extend-controller.js +48 -0
  19. package/dist/client/adp/extend-controller.ts +49 -0
  20. package/dist/client/adp/init-dialogs.js +143 -163
  21. package/dist/client/adp/init-dialogs.ts +42 -20
  22. package/dist/client/adp/init.js +9 -1
  23. package/dist/client/adp/init.ts +6 -1
  24. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
  25. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +74 -60
  26. package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +25 -3
  27. package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
  28. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
  29. package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
  30. package/dist/client/adp/quick-actions/common/utils.js +18 -18
  31. package/dist/client/adp/quick-actions/control-types.js +23 -23
  32. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
  33. package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
  34. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +81 -81
  35. package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
  36. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
  37. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +107 -107
  38. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
  39. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
  40. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
  41. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
  42. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
  43. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
  44. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
  45. package/dist/client/adp/quick-actions/fe-v2/registry.js +77 -77
  46. package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
  47. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
  48. package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
  49. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
  50. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
  51. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
  52. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
  53. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
  54. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
  55. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
  56. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
  57. package/dist/client/adp/quick-actions/fe-v4/registry.js +60 -60
  58. package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
  59. package/dist/client/adp/quick-actions/load.js +44 -44
  60. package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
  61. package/dist/client/adp/ui/ControllerExtension.fragment.xml +14 -3
  62. package/dist/client/adp/utils.js +259 -218
  63. package/dist/client/adp/utils.ts +55 -7
  64. package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +75 -75
  65. package/dist/client/cpe/changes/generic-change.js +326 -326
  66. package/dist/client/cpe/changes/index.js +10 -10
  67. package/dist/client/cpe/changes/validator.js +39 -39
  68. package/dist/client/cpe/connector-service.ts +1 -0
  69. package/dist/client/cpe/documentation.js +164 -164
  70. package/dist/client/cpe/feature-service.js +36 -36
  71. package/dist/client/cpe/logger.js +30 -30
  72. package/dist/client/cpe/outline/editable.js +37 -37
  73. package/dist/client/cpe/outline/nodes.js +203 -203
  74. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  75. package/dist/client/cpe/quick-actions/registry.js +143 -143
  76. package/dist/client/cpe/quick-actions/utils.js +92 -92
  77. package/dist/client/cpe/types.js +4 -4
  78. package/dist/client/cpe/ui5-utils.js +33 -33
  79. package/dist/client/cpe/utils.js +111 -111
  80. package/dist/client/flp/WorkspaceConnector.js +92 -92
  81. package/dist/client/flp/common.js +28 -28
  82. package/dist/client/flp/enableFakeConnector.js +89 -89
  83. package/dist/client/flp/homepage/Component.js +14 -14
  84. package/dist/client/flp/initCdm.js +117 -117
  85. package/dist/client/flp/initConnectors.js +28 -28
  86. package/dist/client/flp/initRta.js +178 -178
  87. package/dist/client/i18n.js +56 -56
  88. package/dist/client/messagebundle.properties +5 -0
  89. package/dist/client/utils/additional-change-info.js +54 -54
  90. package/dist/client/utils/application.js +32 -32
  91. package/dist/client/utils/core.js +84 -84
  92. package/dist/client/utils/error.js +19 -19
  93. package/dist/client/utils/fe-v2.js +56 -56
  94. package/dist/client/utils/fe-v4.js +140 -140
  95. package/dist/client/utils/version.js +104 -104
  96. package/package.json +4 -4
@@ -1,142 +1,142 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFactory", "../cpe/utils"], function (Component, ___core, CommandFactory, ___cpe_utils) {
4
- "use strict";
5
-
6
- const isA = ___core["isA"];
7
- const getOverlay = ___cpe_utils["getOverlay"];
8
- /**
9
- * Gets app component of a v4 project.
10
- *
11
- * @param control - ManagedObject.
12
- * @returns AppComponent.
13
- */
14
- function getV4AppComponent(control) {
15
- const ownerComponent = Component.getOwnerComponentFor(control);
16
- if (ownerComponent?.isA('sap.fe.core.TemplateComponent')) {
17
- return ownerComponent.getAppComponent();
18
- }
19
- return undefined;
20
- }
21
-
22
- /**
23
- * Gets reference id of the app.
24
- *
25
- * @param control - ManagedObject.
26
- * @returns string.
27
- */
28
- function getReference(control) {
29
- const manifest = getV4AppComponent(control)?.getManifest();
30
- return manifest?.['sap.app']?.id ?? '';
31
- }
32
-
33
- /**
34
- * Determines the page type of v4 app.
35
- *
36
- * @param control - ManagedObject.
37
- * @returns 'ObjectPage' | 'ListReport' | undefined.
38
- */
39
- function getV4PageType(control) {
40
- const component = Component.getOwnerComponentFor(control);
41
- if (!component?.isA('sap.fe.core.TemplateComponent')) {
42
- return undefined;
43
- }
44
- const view = component.getRootControl();
45
- const name = view.getViewName();
46
- if (name === 'sap.fe.templates.ObjectPage.ObjectPage') {
47
- return 'ObjectPage';
48
- }
49
- if (name === 'sap.fe.templates.ListReport.ListReport') {
50
- return 'ListReport';
51
- }
52
- return undefined;
53
- }
54
-
55
- /**
56
- * Get the containing page name of a control.
57
- *
58
- * @param control - UI5 control instance.
59
- * @returns Page name to which the control belongs.
60
- */
61
- function getPageName(control) {
62
- const component = Component.getOwnerComponentFor(control);
63
- if (!isA('sap.fe.core.TemplateComponent', component)) {
64
- return undefined;
65
- }
66
- const view = component.getRootControl();
67
- return view.getId().split('::').pop();
68
- }
69
- function getConfigMapControlIdMap(page, propertyPathSegments) {
70
- if (page && !propertyPathSegments.length) {
71
- return page;
72
- }
73
- if (page) {
74
- return `${page}-${propertyPathSegments.join('/')}`;
75
- }
76
- return propertyPathSegments.join('/');
77
- }
78
-
79
- /**
80
- * Get the modified value for a control.
81
- * @param modifiedControl - The modified control.
82
- * @param flexSettings - Flex Settings of the control.
83
- * @param propertyChanges - The change object
84
- * @param propertyPathExtraSegments - optional path segments which are added to the default modified control manifest path
85
- *
86
- * @returns A Promise resolving to an array of FlexCommand objects.
87
- */
88
- async function createManifestPropertyChange(modifiedControl, flexSettings, propertyChanges, propertyPathExtraSegments) {
89
- const overlay = getOverlay(modifiedControl);
90
- if (!overlay) {
91
- return undefined;
92
- }
93
- const overlayData = overlay?.getDesignTimeMetadata().getData();
94
- let manifestPropertyPath = overlayData.manifestPropertyPath(modifiedControl);
95
- if (propertyPathExtraSegments) {
96
- manifestPropertyPath += '/' + propertyPathExtraSegments.join('/');
97
- }
98
- const [manifestPropertyChange] = overlayData.manifestPropertyChange(propertyChanges, manifestPropertyPath, modifiedControl);
99
- const modifiedValue = {
100
- reference: getReference(modifiedControl),
101
- appComponent: manifestPropertyChange.appComponent,
102
- changeType: manifestPropertyChange.changeSpecificData.appDescriptorChangeType,
103
- parameters: manifestPropertyChange.changeSpecificData.content.parameters,
104
- selector: manifestPropertyChange.selector
105
- };
106
- const command = await CommandFactory.getCommandFor(modifiedControl, 'appDescriptor', modifiedValue, null, flexSettings);
107
- return command;
108
- }
109
-
110
- /**
111
- * Returns application object page definitions found in manifest
112
- *
113
- * @param manifest - manifest object
114
- * @returns array with page descriptors
115
- */
116
- function getV4ApplicationPages(manifest) {
117
- const result = [];
118
- const targets = manifest['sap.ui5'].routing?.targets ?? {};
119
- for (const target of Object.values(targets)) {
120
- if (target.name === 'sap.fe.templates.ObjectPage') {
121
- result.push({
122
- id: target.id,
123
- entitySet: target.options?.settings?.entitySet,
124
- contextPath: target.options?.settings?.contextPath
125
- });
126
- }
127
- }
128
- return result;
129
- }
130
- var __exports = {
131
- __esModule: true
132
- };
133
- __exports.getV4AppComponent = getV4AppComponent;
134
- __exports.getReference = getReference;
135
- __exports.getV4PageType = getV4PageType;
136
- __exports.getPageName = getPageName;
137
- __exports.getConfigMapControlIdMap = getConfigMapControlIdMap;
138
- __exports.createManifestPropertyChange = createManifestPropertyChange;
139
- __exports.getV4ApplicationPages = getV4ApplicationPages;
140
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFactory", "../cpe/utils"], function (Component, ___core, CommandFactory, ___cpe_utils) {
4
+ "use strict";
5
+
6
+ const isA = ___core["isA"];
7
+ const getOverlay = ___cpe_utils["getOverlay"];
8
+ /**
9
+ * Gets app component of a v4 project.
10
+ *
11
+ * @param control - ManagedObject.
12
+ * @returns AppComponent.
13
+ */
14
+ function getV4AppComponent(control) {
15
+ const ownerComponent = Component.getOwnerComponentFor(control);
16
+ if (ownerComponent?.isA('sap.fe.core.TemplateComponent')) {
17
+ return ownerComponent.getAppComponent();
18
+ }
19
+ return undefined;
20
+ }
21
+
22
+ /**
23
+ * Gets reference id of the app.
24
+ *
25
+ * @param control - ManagedObject.
26
+ * @returns string.
27
+ */
28
+ function getReference(control) {
29
+ const manifest = getV4AppComponent(control)?.getManifest();
30
+ return manifest?.['sap.app']?.id ?? '';
31
+ }
32
+
33
+ /**
34
+ * Determines the page type of v4 app.
35
+ *
36
+ * @param control - ManagedObject.
37
+ * @returns 'ObjectPage' | 'ListReport' | undefined.
38
+ */
39
+ function getV4PageType(control) {
40
+ const component = Component.getOwnerComponentFor(control);
41
+ if (!component?.isA('sap.fe.core.TemplateComponent')) {
42
+ return undefined;
43
+ }
44
+ const view = component.getRootControl();
45
+ const name = view.getViewName();
46
+ if (name === 'sap.fe.templates.ObjectPage.ObjectPage') {
47
+ return 'ObjectPage';
48
+ }
49
+ if (name === 'sap.fe.templates.ListReport.ListReport') {
50
+ return 'ListReport';
51
+ }
52
+ return undefined;
53
+ }
54
+
55
+ /**
56
+ * Get the containing page name of a control.
57
+ *
58
+ * @param control - UI5 control instance.
59
+ * @returns Page name to which the control belongs.
60
+ */
61
+ function getPageName(control) {
62
+ const component = Component.getOwnerComponentFor(control);
63
+ if (!isA('sap.fe.core.TemplateComponent', component)) {
64
+ return undefined;
65
+ }
66
+ const view = component.getRootControl();
67
+ return view.getId().split('::').pop();
68
+ }
69
+ function getConfigMapControlIdMap(page, propertyPathSegments) {
70
+ if (page && !propertyPathSegments.length) {
71
+ return page;
72
+ }
73
+ if (page) {
74
+ return `${page}-${propertyPathSegments.join('/')}`;
75
+ }
76
+ return propertyPathSegments.join('/');
77
+ }
78
+
79
+ /**
80
+ * Get the modified value for a control.
81
+ * @param modifiedControl - The modified control.
82
+ * @param flexSettings - Flex Settings of the control.
83
+ * @param propertyChanges - The change object
84
+ * @param propertyPathExtraSegments - optional path segments which are added to the default modified control manifest path
85
+ *
86
+ * @returns A Promise resolving to an array of FlexCommand objects.
87
+ */
88
+ async function createManifestPropertyChange(modifiedControl, flexSettings, propertyChanges, propertyPathExtraSegments) {
89
+ const overlay = getOverlay(modifiedControl);
90
+ if (!overlay) {
91
+ return undefined;
92
+ }
93
+ const overlayData = overlay?.getDesignTimeMetadata().getData();
94
+ let manifestPropertyPath = overlayData.manifestPropertyPath(modifiedControl);
95
+ if (propertyPathExtraSegments) {
96
+ manifestPropertyPath += '/' + propertyPathExtraSegments.join('/');
97
+ }
98
+ const [manifestPropertyChange] = overlayData.manifestPropertyChange(propertyChanges, manifestPropertyPath, modifiedControl);
99
+ const modifiedValue = {
100
+ reference: getReference(modifiedControl),
101
+ appComponent: manifestPropertyChange.appComponent,
102
+ changeType: manifestPropertyChange.changeSpecificData.appDescriptorChangeType,
103
+ parameters: manifestPropertyChange.changeSpecificData.content.parameters,
104
+ selector: manifestPropertyChange.selector
105
+ };
106
+ const command = await CommandFactory.getCommandFor(modifiedControl, 'appDescriptor', modifiedValue, null, flexSettings);
107
+ return command;
108
+ }
109
+
110
+ /**
111
+ * Returns application object page definitions found in manifest
112
+ *
113
+ * @param manifest - manifest object
114
+ * @returns array with page descriptors
115
+ */
116
+ function getV4ApplicationPages(manifest) {
117
+ const result = [];
118
+ const targets = manifest['sap.ui5'].routing?.targets ?? {};
119
+ for (const target of Object.values(targets)) {
120
+ if (target.name === 'sap.fe.templates.ObjectPage') {
121
+ result.push({
122
+ id: target.id,
123
+ entitySet: target.options?.settings?.entitySet,
124
+ contextPath: target.options?.settings?.contextPath
125
+ });
126
+ }
127
+ }
128
+ return result;
129
+ }
130
+ var __exports = {
131
+ __esModule: true
132
+ };
133
+ __exports.getV4AppComponent = getV4AppComponent;
134
+ __exports.getReference = getReference;
135
+ __exports.getV4PageType = getV4PageType;
136
+ __exports.getPageName = getPageName;
137
+ __exports.getConfigMapControlIdMap = getConfigMapControlIdMap;
138
+ __exports.createManifestPropertyChange = createManifestPropertyChange;
139
+ __exports.getV4ApplicationPages = getV4ApplicationPages;
140
+ return __exports;
141
141
  });
142
142
  //# sourceMappingURL=fe-v4.js.map
@@ -1,106 +1,106 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log) {
4
- "use strict";
5
-
6
- /**
7
- * Default minimal supported UI5 version
8
- */
9
- const minVersionInfo = {
10
- major: 1,
11
- minor: 71
12
- };
13
-
14
- /**
15
- * Check if the given version info is valid.
16
- * @param versionInfo to check
17
- * @throws Error if the version info is invalid
18
- */
19
- function checkVersionInfo(versionInfo) {
20
- if (isNaN(versionInfo.major) || isNaN(versionInfo.minor) || isNaN(versionInfo.patch ?? 0)) {
21
- throw new Error('Invalid version info');
22
- }
23
- }
24
-
25
- /**
26
- * Retrieve the UI5 version.
27
- * If no library is given, the version from 'sap.ui.core' will be retrieved.
28
- * Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
29
- * For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
30
- *
31
- * @param library - (optional) specific library name to get the version from, e.g. 'sap.m'
32
- * @returns Ui5VersionInfo
33
- */
34
- async function getUi5Version() {
35
- let library = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'sap.ui.core';
36
- let version = (await VersionInfo.load({
37
- library
38
- }))?.version;
39
- if (!version) {
40
- Log.error('Could not get UI5 version of application. Using 1.130.0 as fallback.');
41
- version = '1.130.0';
42
- }
43
- const [major, minor, patch] = version.split('.').map(versionPart => parseInt(versionPart, 10));
44
- const label = version.split(/-(.*)/s)?.[1];
45
- return {
46
- major,
47
- minor,
48
- patch,
49
- label
50
- };
51
- }
52
-
53
- /**
54
- * Checks if the given version is lower than the required minimal version.
55
- * Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
56
- * For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
57
- *
58
- * @param ui5VersionInfo to check
59
- * @param minUi5VersionInfo to check against (default is 1.71)
60
- * @throws Error if the version info is invalid
61
- *
62
- * @returns boolean
63
- */
64
- function isLowerThanMinimalUi5Version(ui5VersionInfo) {
65
- let minUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
66
- checkVersionInfo(ui5VersionInfo);
67
- checkVersionInfo(minUi5VersionInfo);
68
- return ui5VersionInfo.major < minUi5VersionInfo.major || ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor || ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor === minUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) < (minUi5VersionInfo?.patch ?? 0);
69
- }
70
-
71
- /**
72
- * Checks if the given version is equal to the specified version.
73
- * Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
74
- * For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
75
- *
76
- * @param ui5VersionInfo to check
77
- * @param targetUi5VersionInfo to check against (default is 1.71)
78
- * @throws Error if the version info is invalid
79
- *
80
- * @returns boolean
81
- */
82
- function isVersionEqualOrHasNewerPatch(ui5VersionInfo) {
83
- let targetUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
84
- checkVersionInfo(ui5VersionInfo);
85
- checkVersionInfo(targetUi5VersionInfo);
86
- return ui5VersionInfo.major === targetUi5VersionInfo.major && ui5VersionInfo.minor === targetUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) >= (targetUi5VersionInfo?.patch ?? 0);
87
- }
88
-
89
- /**
90
- * Get UI5 version validation message.
91
- * @param ui5VersionInfo to be mentioned in the message
92
- * @returns string with validation message.
93
- */
94
- function getUI5VersionValidationMessage(ui5VersionInfo) {
95
- return `The current SAPUI5 version set for this Adaptation project is ${ui5VersionInfo.major}.${ui5VersionInfo.minor}. The minimum version to use for SAPUI5 Adaptation Project and its SAPUI5 Visual Editor is ${minVersionInfo.major}.${minVersionInfo.minor}`;
96
- }
97
- var __exports = {
98
- __esModule: true
99
- };
100
- __exports.getUi5Version = getUi5Version;
101
- __exports.isLowerThanMinimalUi5Version = isLowerThanMinimalUi5Version;
102
- __exports.isVersionEqualOrHasNewerPatch = isVersionEqualOrHasNewerPatch;
103
- __exports.getUI5VersionValidationMessage = getUI5VersionValidationMessage;
104
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log) {
4
+ "use strict";
5
+
6
+ /**
7
+ * Default minimal supported UI5 version
8
+ */
9
+ const minVersionInfo = {
10
+ major: 1,
11
+ minor: 71
12
+ };
13
+
14
+ /**
15
+ * Check if the given version info is valid.
16
+ * @param versionInfo to check
17
+ * @throws Error if the version info is invalid
18
+ */
19
+ function checkVersionInfo(versionInfo) {
20
+ if (isNaN(versionInfo.major) || isNaN(versionInfo.minor) || isNaN(versionInfo.patch ?? 0)) {
21
+ throw new Error('Invalid version info');
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Retrieve the UI5 version.
27
+ * If no library is given, the version from 'sap.ui.core' will be retrieved.
28
+ * Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
29
+ * For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
30
+ *
31
+ * @param library - (optional) specific library name to get the version from, e.g. 'sap.m'
32
+ * @returns Ui5VersionInfo
33
+ */
34
+ async function getUi5Version() {
35
+ let library = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'sap.ui.core';
36
+ let version = (await VersionInfo.load({
37
+ library
38
+ }))?.version;
39
+ if (!version) {
40
+ Log.error('Could not get UI5 version of application. Using 1.130.0 as fallback.');
41
+ version = '1.130.0';
42
+ }
43
+ const [major, minor, patch] = version.split('.').map(versionPart => parseInt(versionPart, 10));
44
+ const label = version.split(/-(.*)/s)?.[1];
45
+ return {
46
+ major,
47
+ minor,
48
+ patch,
49
+ label
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Checks if the given version is lower than the required minimal version.
55
+ * Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
56
+ * For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
57
+ *
58
+ * @param ui5VersionInfo to check
59
+ * @param minUi5VersionInfo to check against (default is 1.71)
60
+ * @throws Error if the version info is invalid
61
+ *
62
+ * @returns boolean
63
+ */
64
+ function isLowerThanMinimalUi5Version(ui5VersionInfo) {
65
+ let minUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
66
+ checkVersionInfo(ui5VersionInfo);
67
+ checkVersionInfo(minUi5VersionInfo);
68
+ return ui5VersionInfo.major < minUi5VersionInfo.major || ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor || ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor === minUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) < (minUi5VersionInfo?.patch ?? 0);
69
+ }
70
+
71
+ /**
72
+ * Checks if the given version is equal to the specified version.
73
+ * Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
74
+ * For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
75
+ *
76
+ * @param ui5VersionInfo to check
77
+ * @param targetUi5VersionInfo to check against (default is 1.71)
78
+ * @throws Error if the version info is invalid
79
+ *
80
+ * @returns boolean
81
+ */
82
+ function isVersionEqualOrHasNewerPatch(ui5VersionInfo) {
83
+ let targetUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
84
+ checkVersionInfo(ui5VersionInfo);
85
+ checkVersionInfo(targetUi5VersionInfo);
86
+ return ui5VersionInfo.major === targetUi5VersionInfo.major && ui5VersionInfo.minor === targetUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) >= (targetUi5VersionInfo?.patch ?? 0);
87
+ }
88
+
89
+ /**
90
+ * Get UI5 version validation message.
91
+ * @param ui5VersionInfo to be mentioned in the message
92
+ * @returns string with validation message.
93
+ */
94
+ function getUI5VersionValidationMessage(ui5VersionInfo) {
95
+ return `The current SAPUI5 version set for this Adaptation project is ${ui5VersionInfo.major}.${ui5VersionInfo.minor}. The minimum version to use for SAPUI5 Adaptation Project and its SAPUI5 Visual Editor is ${minVersionInfo.major}.${minVersionInfo.minor}`;
96
+ }
97
+ var __exports = {
98
+ __esModule: true
99
+ };
100
+ __exports.getUi5Version = getUi5Version;
101
+ __exports.isLowerThanMinimalUi5Version = isLowerThanMinimalUi5Version;
102
+ __exports.isVersionEqualOrHasNewerPatch = isVersionEqualOrHasNewerPatch;
103
+ __exports.getUI5VersionValidationMessage = getUI5VersionValidationMessage;
104
+ return __exports;
105
105
  });
106
106
  //# sourceMappingURL=version.js.map
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%3Apreview-middleware"
11
11
  },
12
- "version": "0.20.0",
12
+ "version": "0.20.2",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -25,12 +25,12 @@
25
25
  "ejs": "3.1.10",
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
- "@sap-ux/adp-tooling": "0.14.0",
28
+ "@sap-ux/adp-tooling": "0.14.2",
29
29
  "@sap-ux/btp-utils": "1.1.0",
30
30
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.5",
31
31
  "@sap-ux/feature-toggle": "0.3.0",
32
32
  "@sap-ux/logger": "0.7.0",
33
- "@sap-ux/project-access": "1.30.0",
33
+ "@sap-ux/project-access": "1.30.1",
34
34
  "@sap-ux/system-access": "0.6.0"
35
35
  },
36
36
  "devDependencies": {
@@ -49,7 +49,7 @@
49
49
  "nock": "13.4.0",
50
50
  "npm-run-all2": "6.2.0",
51
51
  "supertest": "6.3.3",
52
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.14.0",
52
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.14.1",
53
53
  "@sap-ux/axios-extension": "1.21.0",
54
54
  "@sap-ux/i18n": "0.3.0",
55
55
  "@sap-ux/store": "1.1.0",