@sap-ux/preview-middleware 1.0.19 → 1.0.22
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 +1 -1
- package/dist/base/config.d.ts +2 -1
- package/dist/base/config.js +10 -4
- package/dist/base/flp.d.ts +10 -0
- package/dist/base/flp.js +33 -8
- package/dist/base/test.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ Array of additional application configurations:
|
|
|
71
71
|
| `framework` | `string` | mandatory | `undefined` | Currently `OPA5`, `QUnit` (only QUnit 2.3.2 provided as third-party module using [OpenUI5](https://github.com/SAP/openui5/blob/master/THIRDPARTY.txt)/SAPUI5) and `Testsuite` are supported. `Testsuite` will generate a testsuite for all configured frameworks that can be be used with a test runner (such as karma) |
|
|
72
72
|
| `path` | `string` | optional | `(calculated)` | The mount point to be used for test suite. By default, `/test/opaTests.qunit.html` is used for `OPA5`, `/test/unitTests.qunit.html` is used for `QUnit`, and `/test/testsuite.qunit.html` is used for `Testsuite` |
|
|
73
73
|
| `init` | `string` | optional | `undefined` | The mount point to be used for custom test runner script |
|
|
74
|
-
| `pattern` | `string` | optional | `(calculated)` | Optional glob pattern to find the tests. By default, `/test/**/*Journey.{js,ts}` is used for `OPA5` and `/test/**/*Test.{js,ts}` is used for `QUnit` (not applicable for `Testsuite`) |
|
|
74
|
+
| `pattern` | `string` | optional | `(calculated)` | Optional glob pattern to find the tests. By default, `/test/**/*Journey{,.gen}.{js,ts}` is used for `OPA5` and `/test/**/*Test.{js,ts}` is used for `QUnit` (not applicable for `Testsuite`) |
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
## [Usage](#usage)
|
package/dist/base/config.d.ts
CHANGED
|
@@ -157,9 +157,10 @@ export declare function remapResourcesForPath(config: TemplateConfig, newPagePat
|
|
|
157
157
|
* @param config FLP configuration
|
|
158
158
|
* @param manifest application manifest
|
|
159
159
|
* @param resources additional resources
|
|
160
|
+
* @param isAdp whether this is an adaptation project
|
|
160
161
|
* @returns configuration object for the sandbox.html template
|
|
161
162
|
*/
|
|
162
|
-
export declare function createFlpTemplateConfig(config: FlpConfig, manifest: Partial<Manifest>, resources?: Record<string, string
|
|
163
|
+
export declare function createFlpTemplateConfig(config: FlpConfig, manifest: Partial<Manifest>, resources?: Record<string, string>, isAdp?: boolean): TemplateConfig;
|
|
163
164
|
/**
|
|
164
165
|
* Creates the configuration object for the test template.
|
|
165
166
|
*
|
package/dist/base/config.js
CHANGED
|
@@ -164,12 +164,13 @@ export function sanitizeRtaConfig(deprecatedRtaConfig, logger) {
|
|
|
164
164
|
/**
|
|
165
165
|
* Retrieves the configuration settings for UI5 flexibility services.
|
|
166
166
|
*
|
|
167
|
+
* @param isAdp whether this is an adaptation project - LocalStorageConnector is omitted for ADP
|
|
167
168
|
* @returns An array of flexibility service configurations, each specifying a connector
|
|
168
169
|
* and its options, such as the layers it applies to and its service URL, if applicable.
|
|
169
170
|
*/
|
|
170
|
-
function getFlexSettings() {
|
|
171
|
+
function getFlexSettings(isAdp = false) {
|
|
171
172
|
const localConnectorPath = 'open/ux/preview/client/flp/WorkspaceConnector';
|
|
172
|
-
|
|
173
|
+
const connectors = [
|
|
173
174
|
{ connector: 'LrepConnector', layers: [], url: '/sap/bc/lrep' },
|
|
174
175
|
{
|
|
175
176
|
applyConnector: localConnectorPath,
|
|
@@ -177,6 +178,10 @@ function getFlexSettings() {
|
|
|
177
178
|
custom: true
|
|
178
179
|
}
|
|
179
180
|
];
|
|
181
|
+
if (!isAdp) {
|
|
182
|
+
connectors.push({ connector: 'LocalStorageConnector', layers: ['CUSTOMER', 'USER'] });
|
|
183
|
+
}
|
|
184
|
+
return connectors;
|
|
180
185
|
}
|
|
181
186
|
/**
|
|
182
187
|
* Add an application to the local FLP preview.
|
|
@@ -278,10 +283,11 @@ export function remapResourcesForPath(config, newPagePath, appId) {
|
|
|
278
283
|
* @param config FLP configuration
|
|
279
284
|
* @param manifest application manifest
|
|
280
285
|
* @param resources additional resources
|
|
286
|
+
* @param isAdp whether this is an adaptation project
|
|
281
287
|
* @returns configuration object for the sandbox.html template
|
|
282
288
|
*/
|
|
283
|
-
export function createFlpTemplateConfig(config, manifest, resources = {}) {
|
|
284
|
-
const flex = getFlexSettings();
|
|
289
|
+
export function createFlpTemplateConfig(config, manifest, resources = {}, isAdp = false) {
|
|
290
|
+
const flex = getFlexSettings(isAdp);
|
|
285
291
|
const supportedThemes = manifest['sap.ui5']?.supportedThemes ?? [DEFAULT_THEME];
|
|
286
292
|
const ui5Theme = config.theme ?? (supportedThemes.includes(DEFAULT_THEME) ? DEFAULT_THEME : supportedThemes[0]);
|
|
287
293
|
const id = manifest['sap.app']?.id ?? '';
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -149,6 +149,16 @@ export declare class FlpSandbox {
|
|
|
149
149
|
* @private
|
|
150
150
|
*/
|
|
151
151
|
private addCardGeneratorMiddlewareRoute;
|
|
152
|
+
/**
|
|
153
|
+
* Extracts protocol and baseUrl from a request and calls getUi5Version.
|
|
154
|
+
* Handles both express Request and connect IncomingMessage (karma test runner).
|
|
155
|
+
*
|
|
156
|
+
* @param req - the incoming request
|
|
157
|
+
* @param baseUrl - the base path to include when fetching the UI5 version
|
|
158
|
+
* @returns the parsed UI5 version
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
private getUi5VersionFromRequest;
|
|
152
162
|
/**
|
|
153
163
|
* Read the UI5 version.
|
|
154
164
|
* In case of an error, the default UI5 version '1.121.0' is returned.
|
package/dist/base/flp.js
CHANGED
|
@@ -80,7 +80,7 @@ export class FlpSandbox {
|
|
|
80
80
|
this.createFlexHandler();
|
|
81
81
|
this.flpConfig.libs ??= await this.hasLocateReuseLibsScript();
|
|
82
82
|
const id = manifest['sap.app']?.id ?? '';
|
|
83
|
-
this.templateConfig = createFlpTemplateConfig(this.flpConfig, manifest, resources);
|
|
83
|
+
this.templateConfig = createFlpTemplateConfig(this.flpConfig, manifest, resources, adp !== undefined);
|
|
84
84
|
this.adp = adp;
|
|
85
85
|
this.manifest = manifest;
|
|
86
86
|
await addApp(this.templateConfig, manifest, {
|
|
@@ -226,7 +226,7 @@ export class FlpSandbox {
|
|
|
226
226
|
* @returns Promise that resolves when the application dependencies are set
|
|
227
227
|
*/
|
|
228
228
|
async setApplicationDependencies() {
|
|
229
|
-
if (this.adp) {
|
|
229
|
+
if (this.adp && !this.adp.isCloudFoundry) {
|
|
230
230
|
await this.adp.sync();
|
|
231
231
|
const appName = getAppName(this.manifest, this.flpConfig.intent);
|
|
232
232
|
this.templateConfig.apps[appName].applicationDependencies = this.adp.descriptor;
|
|
@@ -350,11 +350,7 @@ export class FlpSandbox {
|
|
|
350
350
|
else {
|
|
351
351
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
352
352
|
this.templateConfig.baseUrl = ('ui5-patched-router' in req && req['ui5-patched-router']?.baseUrl) || '';
|
|
353
|
-
const ui5Version = await this.
|
|
354
|
-
//use protocol from request header referer as fallback for connect API (karma test runner)
|
|
355
|
-
'protocol' in req
|
|
356
|
-
? req.protocol
|
|
357
|
-
: (req.headers.referer?.substring(0, req.headers.referer.indexOf(':')) ?? 'http'), req.headers.host, this.templateConfig.baseUrl);
|
|
353
|
+
const ui5Version = await this.getUi5VersionFromRequest(req, this.templateConfig.baseUrl);
|
|
358
354
|
this.checkDeleteConnectors(ui5Version.major, ui5Version.minor, ui5Version.isCdn);
|
|
359
355
|
if (ui5Version.major === 1 && ui5Version.minor < 120) {
|
|
360
356
|
this.removeFlexExtensionPointEnabled();
|
|
@@ -388,9 +384,37 @@ export class FlpSandbox {
|
|
|
388
384
|
this.logger.debug(`Add route for ${previewGeneratorPath}`);
|
|
389
385
|
this.router.get(previewGeneratorPath, async (req, res, next) => {
|
|
390
386
|
this.templateConfig.enableCardGenerator = !!this.cardGenerator?.path;
|
|
387
|
+
if (this.templateConfig.enableCardGenerator) {
|
|
388
|
+
// check for min ui5 version of card generator feature
|
|
389
|
+
const baseUrl = 'ui5-patched-router' in req ? (req['ui5-patched-router']?.baseUrl ?? '') : '';
|
|
390
|
+
const ui5Version = await this.getUi5VersionFromRequest(req, baseUrl);
|
|
391
|
+
const minMinor = this.projectType === 'CAPNodejs' || this.projectType === 'CAPJava' ? 149 : 121;
|
|
392
|
+
if ((ui5Version.major === 1 && ui5Version.minor < minMinor) ||
|
|
393
|
+
ui5Version.major >= 2 ||
|
|
394
|
+
ui5Version.label?.includes('legacy-free')) {
|
|
395
|
+
this.templateConfig.enableCardGenerator = false;
|
|
396
|
+
this.logger.warn(`Feature cardGenerator disabled: UI5 version ${ui5Version.major}.${ui5Version.minor}.${ui5Version.patch} does not meet the minimum required version 1.${minMinor}.0 for project type '${this.projectType}'.`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
391
399
|
await this.flpGetHandler(req, res, next);
|
|
392
400
|
});
|
|
393
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Extracts protocol and baseUrl from a request and calls getUi5Version.
|
|
404
|
+
* Handles both express Request and connect IncomingMessage (karma test runner).
|
|
405
|
+
*
|
|
406
|
+
* @param req - the incoming request
|
|
407
|
+
* @param baseUrl - the base path to include when fetching the UI5 version
|
|
408
|
+
* @returns the parsed UI5 version
|
|
409
|
+
* @private
|
|
410
|
+
*/
|
|
411
|
+
async getUi5VersionFromRequest(req, baseUrl = '') {
|
|
412
|
+
// use protocol from request header referer as fallback for connect API (karma test runner)
|
|
413
|
+
const protocol = 'protocol' in req
|
|
414
|
+
? req.protocol
|
|
415
|
+
: (req.headers.referer?.substring(0, req.headers.referer.indexOf(':')) ?? 'http');
|
|
416
|
+
return this.getUi5Version(protocol, req.headers.host, baseUrl);
|
|
417
|
+
}
|
|
394
418
|
/**
|
|
395
419
|
* Read the UI5 version.
|
|
396
420
|
* In case of an error, the default UI5 version '1.121.0' is returned.
|
|
@@ -425,6 +449,7 @@ export class FlpSandbox {
|
|
|
425
449
|
}
|
|
426
450
|
const [major, minor, patch] = version.split('.').map((versionPart) => Number.parseInt(versionPart, 10));
|
|
427
451
|
const label = version.split(/-(.*)/s)?.[1];
|
|
452
|
+
// check for min ui5 version of flp.enhancedHomePage feature
|
|
428
453
|
if (this.flpConfig.enhancedHomePage &&
|
|
429
454
|
((major < 2 && minor < 123) || major >= 2 || label?.includes('legacy-free'))) {
|
|
430
455
|
this.flpConfig.enhancedHomePage = this.templateConfig.enhancedHomePage = false;
|
|
@@ -929,7 +954,7 @@ export class FlpSandbox {
|
|
|
929
954
|
if ('cfBuildPath' in config) {
|
|
930
955
|
const manifest = this.setupCfBuildMode(config.cfBuildPath);
|
|
931
956
|
configureRta(this.rta, layer, variant.id, false, true);
|
|
932
|
-
await this.init(manifest, variant.reference);
|
|
957
|
+
await this.init(manifest, variant.reference, {}, adp);
|
|
933
958
|
await this.setupAdpCommonHandlers(adp);
|
|
934
959
|
return;
|
|
935
960
|
}
|
package/dist/base/test.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export type TestConfigDefaults = {
|
|
|
98
98
|
opa5: {
|
|
99
99
|
path: '/test/opaTests.qunit.html';
|
|
100
100
|
init: '/test/opaTests.qunit.js';
|
|
101
|
-
pattern: '/test/**/*Journey.{js,ts}';
|
|
101
|
+
pattern: '/test/**/*Journey{,.gen}.{js,ts}';
|
|
102
102
|
framework: 'OPA5';
|
|
103
103
|
};
|
|
104
104
|
testsuite: {
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
12
12
|
},
|
|
13
|
-
"version": "1.0.
|
|
13
|
+
"version": "1.0.22",
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"author": "@SAP/ux-tools-team",
|
|
16
16
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"mem-fs-editor": "9.4.0",
|
|
29
29
|
"qrcode": "1.5.4",
|
|
30
30
|
"@sap/bas-sdk": "3.13.7",
|
|
31
|
-
"@sap-ux/adp-tooling": "1.0.
|
|
31
|
+
"@sap-ux/adp-tooling": "1.0.16",
|
|
32
32
|
"@sap-ux/btp-utils": "2.0.2",
|
|
33
33
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@1.0.5",
|
|
34
34
|
"@sap-ux/feature-toggle": "1.0.2",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"nock": "14.0.11",
|
|
55
55
|
"npm-run-all2": "8.0.4",
|
|
56
56
|
"supertest": "7.2.2",
|
|
57
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@1.0.
|
|
57
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@1.0.22",
|
|
58
58
|
"@sap-ux-private/playwright": "1.0.2",
|
|
59
59
|
"@sap-ux/axios-extension": "2.0.3",
|
|
60
60
|
"@sap-ux/store": "2.0.1",
|