@sap-ux/preview-middleware 0.23.19 → 0.23.20
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/README.md +9 -6
- package/dist/base/flp.d.ts +2 -0
- package/dist/base/flp.js +17 -8
- package/dist/client/cpe/connector-service.js +9 -4
- package/dist/client/cpe/connector-service.ts +9 -4
- package/dist/client/flp/initConnectors.js +6 -5
- package/dist/client/flp/initConnectors.ts +4 -3
- package/dist/client/utils/version.js +5 -2
- package/dist/client/utils/version.ts +10 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -16,12 +16,12 @@ When this middleware is used together with the `reload-middleware`, then the ord
|
|
|
16
16
|
| Option | Value Type | Requirement Type | Default Value | Description |
|
|
17
17
|
|-------------------------|------------|------------------------------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
18
18
|
| `flp` | --- | optional | --- | Configuration object for the local SAP Fiori launchpad |
|
|
19
|
-
| `flp.path` | `string` | optional | `/test/flp.html` | The mount point of the local SAP Fiori launchpad.
|
|
19
|
+
| `flp.path` | `string` | optional | `/test/flp.html` | The mount point of the local SAP Fiori launchpad. In case no file is found at the given path, a virtual endpoint will be instantiated. |
|
|
20
20
|
| `flp.init` | `string` | optional | `undefined` | UI5 module/script to be executed after the standard initialization |
|
|
21
21
|
| `flp.intent` | --- | optional | --- | Intent object to be used for the application |
|
|
22
22
|
| `flp.intent.object` | `string` | optional | `app` | Name of the semantic object |
|
|
23
23
|
| `flp.intent.action` | `string` | optional | `preview` | Name of the action |
|
|
24
|
-
| `flp.apps` | `array` | optional | `undefined` | Additional local apps that are available in the local SAP Fiori launchpad
|
|
24
|
+
| `flp.apps` | `array` | optional | `undefined` | Additional local apps that are available in the local SAP Fiori launchpad |
|
|
25
25
|
| `flp.libs` | `boolean` | optional | `false` | Flag to add a generic script fetching the paths of used libraries not available in UI5. To disable it, set it to `false`. If not set, then the project is checked for a `load-reuse-libs` script and, if available, the libraries are fetched as well |
|
|
26
26
|
| `flp.theme` | `string` | optional | `(calculated)` | Name of the UI5 theme to be used (default is `sap_horizon` or the first entry in the sap.ui.supportedThemes list provided in the manifest.json file if `sap_horizon` is not contained in the list) |
|
|
27
27
|
| `flp.enhancedHomePage` | `boolean` | optional | `false` | Flag for enabling enhanced FLP homepage, available only from UI5 version 1.123.0 onwards |
|
|
@@ -31,9 +31,9 @@ When this middleware is used together with the `reload-middleware`, then the ord
|
|
|
31
31
|
| `editors` | `array` | optional | `undefined` | List of configurations allowing to add mount points for additional editors |
|
|
32
32
|
| `editors.rta` | `array` | optional | `undefined` | Configuration allowing to add mount points for runtime adaptation |
|
|
33
33
|
| `editors.rta.layer` | `string` | optional | `(calculated)` | Property for defining the runtime adaptation layer for changes (default is `CUSTOMER_BASE` or read from the project for adaptation projects) |
|
|
34
|
-
| `editors.rta.endpoints` | `array` | optional | `undefined` | List of mount points for editing
|
|
35
|
-
| `editors.cardGenerator` | --- | optional | `undefined` | Configuration object to enable card generation for an application (only supported for non-CAP apps).
|
|
36
|
-
| `editors.cardGenerator.path` | `string` | optional | `test/flpGeneratorSandbox.html` | The mount point of the local SAP Fiori launchpad which will be considered for card generation.
|
|
34
|
+
| `editors.rta.endpoints` | `array` | optional | `undefined` | List of mount points for editing |
|
|
35
|
+
| `editors.cardGenerator` | --- | optional | `undefined` | Configuration object to enable card generation for an application (only supported for non-CAP apps). |
|
|
36
|
+
| `editors.cardGenerator.path` | `string` | optional | `test/flpGeneratorSandbox.html` | The mount point of the local SAP Fiori launchpad which will be considered for card generation. |
|
|
37
37
|
| `test` | `array` | optional | `undefined` | List of configurations for automated testing. |
|
|
38
38
|
| `debug` | `boolean` | optional | `false` | Enables the debug output |
|
|
39
39
|
|
|
@@ -232,4 +232,7 @@ server:
|
|
|
232
232
|
configuration:
|
|
233
233
|
flp:
|
|
234
234
|
init: /test/init # <-- path to your custom init script
|
|
235
|
-
```
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## [Limitations](#limitations)
|
|
238
|
+
- When serving the UI5 sources from npmjs, flex changes for virtual endpoints are only supported for UI5 versions >= `1.84.x`.
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -76,9 +76,11 @@ export declare class FlpSandbox {
|
|
|
76
76
|
* Deletes the Fiori Tools local connector (WorkspaceConnector) in case of a not supported UI5 versions.
|
|
77
77
|
* As an alternative the Fiori Tools fake connector (FakeLrepConnector) will be used as defined in preview-middleware-client/src/flp/initConnectors.ts.
|
|
78
78
|
* Also deletes the ABAP connector in case of a CAP project.
|
|
79
|
+
* Deletes all connectors if UI5 version is < 1.84 and served from npmjs.
|
|
79
80
|
*
|
|
80
81
|
* @param ui5VersionMajor - the major version of UI5
|
|
81
82
|
* @param ui5VersionMinor - the minor version of UI5
|
|
83
|
+
* @param isCDN - whether the UI5 sources are served from CDN
|
|
82
84
|
* @private
|
|
83
85
|
*/
|
|
84
86
|
private checkDeleteConnectors;
|
package/dist/base/flp.js
CHANGED
|
@@ -180,21 +180,26 @@ class FlpSandbox {
|
|
|
180
180
|
* Deletes the Fiori Tools local connector (WorkspaceConnector) in case of a not supported UI5 versions.
|
|
181
181
|
* As an alternative the Fiori Tools fake connector (FakeLrepConnector) will be used as defined in preview-middleware-client/src/flp/initConnectors.ts.
|
|
182
182
|
* Also deletes the ABAP connector in case of a CAP project.
|
|
183
|
+
* Deletes all connectors if UI5 version is < 1.84 and served from npmjs.
|
|
183
184
|
*
|
|
184
185
|
* @param ui5VersionMajor - the major version of UI5
|
|
185
186
|
* @param ui5VersionMinor - the minor version of UI5
|
|
187
|
+
* @param isCDN - whether the UI5 sources are served from CDN
|
|
186
188
|
* @private
|
|
187
189
|
*/
|
|
188
|
-
checkDeleteConnectors(ui5VersionMajor, ui5VersionMinor) {
|
|
189
|
-
if (ui5VersionMajor === 1 && ui5VersionMinor <
|
|
190
|
-
this.templateConfig.ui5.flex = this.templateConfig.ui5
|
|
191
|
-
this.logger.debug(`The Fiori Tools local connector (WorkspaceConnector) is not being used because the current UI5 version does not support it
|
|
190
|
+
checkDeleteConnectors(ui5VersionMajor, ui5VersionMinor, isCDN) {
|
|
191
|
+
if (ui5VersionMajor === 1 && ui5VersionMinor < 84) {
|
|
192
|
+
this.templateConfig.ui5.flex = this.templateConfig.ui5?.flex?.filter((connector) => (0, config_1.isFlexConnector)(connector));
|
|
193
|
+
this.logger.debug(`The Fiori Tools local connector (WorkspaceConnector) is not being used because the current UI5 version does not support it.${isCDN ? 'The Fiori Tools fake connector (FakeLrepConnector) will be used instead.' : ''} `);
|
|
194
|
+
if (!isCDN) {
|
|
195
|
+
this.logger.warn(`The preview with virtual endpoints does not support flex changes for the current UI5 version ${ui5VersionMajor}.${ui5VersionMinor} from npmjs. Consider using a proxy to load UI5 resources from the CDN (e.g., https://ui5.sap.com), or upgrade the UI5 version in the yaml configuration to at least 1.84.`);
|
|
196
|
+
}
|
|
192
197
|
}
|
|
193
198
|
else {
|
|
194
199
|
this.logger.debug(`The Fiori Tools local connector (WorkspaceConnector) is being used.`);
|
|
195
200
|
}
|
|
196
201
|
if (this.projectType === 'CAPJava' || this.projectType === 'CAPNodejs') {
|
|
197
|
-
this.templateConfig.ui5.flex = this.templateConfig.ui5
|
|
202
|
+
this.templateConfig.ui5.flex = this.templateConfig.ui5?.flex?.filter((connector) => !(0, config_1.isFlexConnector)(connector) ||
|
|
198
203
|
((0, config_1.isFlexConnector)(connector) && !connector.url?.startsWith('/sap/bc/lrep')));
|
|
199
204
|
this.logger.debug(`The ABAP connector is not being used because the current project type is '${this.projectType}'.`);
|
|
200
205
|
}
|
|
@@ -231,7 +236,7 @@ class FlpSandbox {
|
|
|
231
236
|
};
|
|
232
237
|
config.features = feature_toggle_1.FeatureToggleAccess.getAllFeatureToggles();
|
|
233
238
|
const ui5Version = await this.getUi5Version(req.protocol, req.headers.host, req['ui5-patched-router']?.baseUrl);
|
|
234
|
-
this.checkDeleteConnectors(ui5Version.major, ui5Version.minor);
|
|
239
|
+
this.checkDeleteConnectors(ui5Version.major, ui5Version.minor, ui5Version.isCdn);
|
|
235
240
|
if (editor.developerMode === true) {
|
|
236
241
|
config.ui5.bootstrapOptions = serializeUi5Configuration(this.getDeveloperModeConfig(ui5Version.major));
|
|
237
242
|
}
|
|
@@ -368,7 +373,7 @@ class FlpSandbox {
|
|
|
368
373
|
'protocol' in req
|
|
369
374
|
? req.protocol
|
|
370
375
|
: req.headers.referer?.substring(0, req.headers.referer.indexOf(':')) ?? 'http', req.headers.host, 'ui5-patched-router' in req ? req['ui5-patched-router']?.baseUrl : undefined);
|
|
371
|
-
this.checkDeleteConnectors(ui5Version.major, ui5Version.minor);
|
|
376
|
+
this.checkDeleteConnectors(ui5Version.major, ui5Version.minor, ui5Version.isCdn);
|
|
372
377
|
const html = (0, ejs_1.render)(this.getSandboxTemplate(ui5Version), this.templateConfig);
|
|
373
378
|
this.sendResponse(res, 'text/html', 200, html);
|
|
374
379
|
}
|
|
@@ -418,6 +423,7 @@ class FlpSandbox {
|
|
|
418
423
|
*/
|
|
419
424
|
async getUi5Version(protocol, host, baseUrl = '') {
|
|
420
425
|
let version;
|
|
426
|
+
let isCdn = false;
|
|
421
427
|
if (!host) {
|
|
422
428
|
this.logger.error('Unable to fetch UI5 version: No host found in request header.');
|
|
423
429
|
}
|
|
@@ -426,6 +432,7 @@ class FlpSandbox {
|
|
|
426
432
|
const versionUrl = `${protocol}://${host}${baseUrl}/resources/sap-ui-version.json`;
|
|
427
433
|
const responseJson = (await fetch(versionUrl).then((res) => res.json()));
|
|
428
434
|
version = responseJson?.libraries?.find((lib) => lib.name === 'sap.ui.core')?.version;
|
|
435
|
+
isCdn = responseJson?.name === 'SAPUI5 Distribution';
|
|
429
436
|
}
|
|
430
437
|
catch (error) {
|
|
431
438
|
this.logger.error(error);
|
|
@@ -434,6 +441,7 @@ class FlpSandbox {
|
|
|
434
441
|
if (!version) {
|
|
435
442
|
this.logger.error('Could not get UI5 version of application. Using version: 1.130.0 as fallback.');
|
|
436
443
|
version = '1.130.0';
|
|
444
|
+
isCdn = false;
|
|
437
445
|
}
|
|
438
446
|
const [major, minor, patch] = version.split('.').map((versionPart) => Number.parseInt(versionPart, 10));
|
|
439
447
|
const label = version.split(/-(.*)/s)?.[1];
|
|
@@ -446,7 +454,8 @@ class FlpSandbox {
|
|
|
446
454
|
major,
|
|
447
455
|
minor,
|
|
448
456
|
patch,
|
|
449
|
-
label
|
|
457
|
+
label,
|
|
458
|
+
isCdn
|
|
450
459
|
};
|
|
451
460
|
}
|
|
452
461
|
/**
|
|
@@ -30,12 +30,17 @@ sap.ui.define([
|
|
|
30
30
|
this.isReloadPending = true;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
const ui5Version = await getUi5Version();
|
|
34
|
+
if (isLowerThanMinimalUi5Version(ui5Version, {
|
|
34
35
|
major: 1,
|
|
35
|
-
minor:
|
|
36
|
+
minor: 84
|
|
36
37
|
})) {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
if (ui5Version.isCdn) {
|
|
39
|
+
const FakeLrepConnector = (await __ui5_require_async('sap/ui/fl/FakeLrepConnector')).default;
|
|
40
|
+
FakeLrepConnector.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
|
|
41
|
+
} else {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
39
44
|
} else {
|
|
40
45
|
const connector = (await __ui5_require_async('open/ux/preview/client/flp/WorkspaceConnector')).default;
|
|
41
46
|
connector.storage.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
|
|
@@ -24,10 +24,15 @@ export class WorkspaceConnectorService {
|
|
|
24
24
|
this.isReloadPending = true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
if (isLowerThanMinimalUi5Version(
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const ui5Version = await getUi5Version();
|
|
28
|
+
if (isLowerThanMinimalUi5Version(ui5Version, { major: 1, minor: 84 })) {
|
|
29
|
+
if (ui5Version.isCdn) {
|
|
30
|
+
const FakeLrepConnector = (await import('sap/ui/fl/FakeLrepConnector')).default;
|
|
31
|
+
FakeLrepConnector.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
|
|
32
|
+
} else {
|
|
33
|
+
// For UI5 versions below 1.84 served from npmjs, we do not support any connector service
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
31
36
|
} else {
|
|
32
37
|
const connector = (await import('open/ux/preview/client/flp/WorkspaceConnector')).default;
|
|
33
38
|
// hook the file deletion listener to the UI5 workspace connector
|
|
@@ -8,18 +8,19 @@ sap.ui.define(["../utils/version"], function (___utils_version) {
|
|
|
8
8
|
/**
|
|
9
9
|
* Initializes UI5 connectors based on the current UI5 version.
|
|
10
10
|
*
|
|
11
|
-
* For UI5 versions below 1.
|
|
12
|
-
* For UI5 versions 1.
|
|
11
|
+
* For UI5 versions below 1.84, this function dynamically requires and executes a FakeLrepConnector.
|
|
12
|
+
* For UI5 versions 1.84 and above, a local connector that reuses the WorkspaceConnector is being defined in preview-middleware/src/base/config.ts.
|
|
13
13
|
* This setup allows for flexibility in using different connectors based on the UI5 version.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* intiConnectors(); // Simply call the function without any arguments.
|
|
17
17
|
*/
|
|
18
18
|
async function initConnectors() {
|
|
19
|
-
|
|
19
|
+
const ui5Version = await getUi5Version();
|
|
20
|
+
if (isLowerThanMinimalUi5Version(ui5Version, {
|
|
20
21
|
major: 1,
|
|
21
|
-
minor:
|
|
22
|
-
})) {
|
|
22
|
+
minor: 84
|
|
23
|
+
}) && ui5Version.isCdn) {
|
|
23
24
|
sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
|
|
24
25
|
enableFakeConnector();
|
|
25
26
|
});
|
|
@@ -3,15 +3,16 @@ import { getUi5Version, isLowerThanMinimalUi5Version } from '../utils/version';
|
|
|
3
3
|
/**
|
|
4
4
|
* Initializes UI5 connectors based on the current UI5 version.
|
|
5
5
|
*
|
|
6
|
-
* For UI5 versions below 1.
|
|
7
|
-
* For UI5 versions 1.
|
|
6
|
+
* For UI5 versions below 1.84, this function dynamically requires and executes a FakeLrepConnector.
|
|
7
|
+
* For UI5 versions 1.84 and above, a local connector that reuses the WorkspaceConnector is being defined in preview-middleware/src/base/config.ts.
|
|
8
8
|
* This setup allows for flexibility in using different connectors based on the UI5 version.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* intiConnectors(); // Simply call the function without any arguments.
|
|
12
12
|
*/
|
|
13
13
|
export default async function initConnectors(): Promise<void> {
|
|
14
|
-
|
|
14
|
+
const ui5Version = await getUi5Version();
|
|
15
|
+
if (isLowerThanMinimalUi5Version(ui5Version, { major: 1, minor: 84 }) && ui5Version.isCdn) {
|
|
15
16
|
sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector: () => void) {
|
|
16
17
|
enableFakeConnector();
|
|
17
18
|
});
|
|
@@ -24,7 +24,9 @@ sap.ui.define([
|
|
|
24
24
|
}
|
|
25
25
|
async function getUi5Version() {
|
|
26
26
|
let library = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'sap.ui.core';
|
|
27
|
-
|
|
27
|
+
const versionInfo = await VersionInfo.load();
|
|
28
|
+
let version = versionInfo?.libraries?.find(lib => lib.name === library)?.version;
|
|
29
|
+
const isCdn = versionInfo?.name === 'SAPUI5 Distribution';
|
|
28
30
|
if (!version) {
|
|
29
31
|
Log.error('Could not get UI5 version of application. Using version: 1.130.0 as fallback.');
|
|
30
32
|
version = '1.130.0';
|
|
@@ -43,7 +45,8 @@ sap.ui.define([
|
|
|
43
45
|
major,
|
|
44
46
|
minor,
|
|
45
47
|
patch,
|
|
46
|
-
label
|
|
48
|
+
label,
|
|
49
|
+
isCdn
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
function isLowerThanMinimalUi5Version(ui5VersionInfo) {
|
|
@@ -7,14 +7,17 @@ type SingleVersionInfo =
|
|
|
7
7
|
| {
|
|
8
8
|
name: string;
|
|
9
9
|
version: string;
|
|
10
|
-
}
|
|
11
|
-
| undefined;
|
|
10
|
+
};
|
|
12
11
|
|
|
13
12
|
export type Ui5VersionInfo = {
|
|
14
13
|
major: number;
|
|
15
14
|
minor: number;
|
|
16
15
|
patch?: number;
|
|
17
16
|
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Indicates if the UI5 version is served from CDN.
|
|
19
|
+
*/
|
|
20
|
+
isCdn?: boolean;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -51,7 +54,9 @@ function checkVersionInfo(versionInfo: Ui5VersionInfo): void {
|
|
|
51
54
|
* @returns Ui5VersionInfo
|
|
52
55
|
*/
|
|
53
56
|
export async function getUi5Version(library: string = 'sap.ui.core'): Promise<Ui5VersionInfo> {
|
|
54
|
-
|
|
57
|
+
const versionInfo = await VersionInfo.load() as { name: string; libraries: SingleVersionInfo[] } | undefined;
|
|
58
|
+
let version = versionInfo?.libraries?.find((lib) => lib.name === library)?.version;
|
|
59
|
+
const isCdn = versionInfo?.name === 'SAPUI5 Distribution';
|
|
55
60
|
if (!version) {
|
|
56
61
|
Log.error('Could not get UI5 version of application. Using version: 1.130.0 as fallback.');
|
|
57
62
|
version = '1.130.0';
|
|
@@ -68,7 +73,8 @@ export async function getUi5Version(library: string = 'sap.ui.core'): Promise<Ui
|
|
|
68
73
|
major,
|
|
69
74
|
minor,
|
|
70
75
|
patch,
|
|
71
|
-
label
|
|
76
|
+
label,
|
|
77
|
+
isCdn
|
|
72
78
|
} satisfies Ui5VersionInfo;
|
|
73
79
|
}
|
|
74
80
|
|
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.23.
|
|
12
|
+
"version": "0.23.20",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"qrcode": "1.5.4",
|
|
29
29
|
"@sap/bas-sdk": "3.12.0",
|
|
30
|
-
"@sap-ux/adp-tooling": "0.15.
|
|
30
|
+
"@sap-ux/adp-tooling": "0.15.36",
|
|
31
31
|
"@sap-ux/btp-utils": "1.1.4",
|
|
32
32
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.0",
|
|
33
33
|
"@sap-ux/feature-toggle": "0.3.1",
|
|
34
34
|
"@sap-ux/logger": "0.7.0",
|
|
35
|
-
"@sap-ux/project-access": "1.32.
|
|
35
|
+
"@sap-ux/project-access": "1.32.4",
|
|
36
36
|
"@sap-ux/system-access": "0.6.19",
|
|
37
37
|
"@sap-ux/i18n": "0.3.4"
|
|
38
38
|
},
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"nock": "13.4.0",
|
|
54
54
|
"npm-run-all2": "6.2.0",
|
|
55
55
|
"supertest": "7.1.4",
|
|
56
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.17.
|
|
56
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.17.3",
|
|
57
57
|
"@sap-ux/axios-extension": "1.22.10",
|
|
58
58
|
"@sap-ux/store": "1.1.5",
|
|
59
59
|
"@sap-ux/ui5-info": "0.12.4"
|