@sap-ux/preview-middleware 0.16.109 → 0.16.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base/config.d.ts
CHANGED
|
@@ -98,9 +98,16 @@ export declare function sanitizeConfig(config: MiddlewareConfig, logger: ToolsLo
|
|
|
98
98
|
* @param manifest manifest of the additional target app
|
|
99
99
|
* @param app configuration for the preview
|
|
100
100
|
* @param logger logger instance
|
|
101
|
-
* @param descriptor descriptor of the additional target app
|
|
102
101
|
*/
|
|
103
|
-
export declare function addApp(templateConfig: TemplateConfig, manifest: Partial<Manifest>, app: App, logger: Logger
|
|
102
|
+
export declare function addApp(templateConfig: TemplateConfig, manifest: Partial<Manifest>, app: App, logger: Logger): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Get the application name based on the manifest and app configuration.
|
|
105
|
+
*
|
|
106
|
+
* @param manifest - The application manifest.
|
|
107
|
+
* @param intent - The app configuration.
|
|
108
|
+
* @returns The application name.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getAppName(manifest: Partial<Manifest>, intent?: Intent): string;
|
|
104
111
|
/**
|
|
105
112
|
* Creates the configuration object for the sandbox.html template.
|
|
106
113
|
*
|
package/dist/base/config.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.DEFAULT_INTENT = exports.DEFAULT_PATH = exports.DEFAULT_THEME = exports.
|
|
|
4
4
|
exports.getFlpConfigWithDefaults = getFlpConfigWithDefaults;
|
|
5
5
|
exports.sanitizeConfig = sanitizeConfig;
|
|
6
6
|
exports.addApp = addApp;
|
|
7
|
+
exports.getAppName = getAppName;
|
|
7
8
|
exports.createFlpTemplateConfig = createFlpTemplateConfig;
|
|
8
9
|
exports.createTestTemplateConfig = createTestTemplateConfig;
|
|
9
10
|
exports.getPreviewPaths = getPreviewPaths;
|
|
@@ -156,15 +157,10 @@ function getFlexSettings() {
|
|
|
156
157
|
* @param manifest manifest of the additional target app
|
|
157
158
|
* @param app configuration for the preview
|
|
158
159
|
* @param logger logger instance
|
|
159
|
-
* @param descriptor descriptor of the additional target app
|
|
160
160
|
*/
|
|
161
|
-
async function addApp(templateConfig, manifest, app, logger
|
|
161
|
+
async function addApp(templateConfig, manifest, app, logger) {
|
|
162
162
|
const id = manifest['sap.app']?.id ?? '';
|
|
163
|
-
app.intent
|
|
164
|
-
object: id.replace(/\./g, ''),
|
|
165
|
-
action: 'preview'
|
|
166
|
-
};
|
|
167
|
-
const appName = `${app.intent?.object}-${app.intent?.action}`;
|
|
163
|
+
const appName = getAppName(manifest, app.intent);
|
|
168
164
|
templateConfig.ui5.resources[id] = app.target;
|
|
169
165
|
templateConfig.apps[appName] = {
|
|
170
166
|
title: (await getI18nTextFromProperty(app.local, manifest['sap.app']?.title, logger)) ?? id,
|
|
@@ -173,9 +169,21 @@ async function addApp(templateConfig, manifest, app, logger, descriptor) {
|
|
|
173
169
|
applicationType: 'URL',
|
|
174
170
|
url: app.target
|
|
175
171
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get the application name based on the manifest and app configuration.
|
|
175
|
+
*
|
|
176
|
+
* @param manifest - The application manifest.
|
|
177
|
+
* @param intent - The app configuration.
|
|
178
|
+
* @returns The application name.
|
|
179
|
+
*/
|
|
180
|
+
function getAppName(manifest, intent) {
|
|
181
|
+
const id = manifest['sap.app']?.id ?? '';
|
|
182
|
+
intent ??= {
|
|
183
|
+
object: id.replace(/\./g, ''),
|
|
184
|
+
action: 'preview'
|
|
185
|
+
};
|
|
186
|
+
return `${intent?.object}-${intent?.action}`;
|
|
179
187
|
}
|
|
180
188
|
/**
|
|
181
189
|
* Get the i18n text of the given property.
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type { Router } from 'express';
|
|
|
4
4
|
import type { Logger, ToolsLogger } from '@sap-ux/logger';
|
|
5
5
|
import type { MiddlewareUtils } from '@ui5/server';
|
|
6
6
|
import type { Manifest } from '@sap-ux/project-access';
|
|
7
|
-
import { type AdpPreviewConfig, type CommonChangeProperties, type OperationType } from '@sap-ux/adp-tooling';
|
|
8
|
-
import type { MergedAppDescriptor } from '@sap-ux/axios-extension';
|
|
7
|
+
import { AdpPreview, type AdpPreviewConfig, type CommonChangeProperties, type OperationType } from '@sap-ux/adp-tooling';
|
|
9
8
|
import type { FlpConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
|
|
10
9
|
import { type TemplateConfig } from './config';
|
|
11
10
|
/**
|
|
@@ -22,6 +21,8 @@ export declare class FlpSandbox {
|
|
|
22
21
|
private readonly project;
|
|
23
22
|
private readonly utils;
|
|
24
23
|
private readonly logger;
|
|
24
|
+
private adp?;
|
|
25
|
+
private manifest;
|
|
25
26
|
protected onChangeRequest: OnChangeRequestHandler | undefined;
|
|
26
27
|
protected templateConfig: TemplateConfig;
|
|
27
28
|
readonly config: FlpConfig;
|
|
@@ -49,9 +50,9 @@ export declare class FlpSandbox {
|
|
|
49
50
|
* @param manifest application manifest
|
|
50
51
|
* @param componentId optional componentId e.g. for adaptation projects
|
|
51
52
|
* @param resources optional additional resource mappings
|
|
52
|
-
* @param
|
|
53
|
+
* @param adp optional reference to the ADP tooling
|
|
53
54
|
*/
|
|
54
|
-
init(manifest: Manifest, componentId?: string, resources?: Record<string, string>,
|
|
55
|
+
init(manifest: Manifest, componentId?: string, resources?: Record<string, string>, adp?: AdpPreview): Promise<void>;
|
|
55
56
|
/**
|
|
56
57
|
* Generates the FLP sandbox for an editor.
|
|
57
58
|
*
|
|
@@ -60,6 +61,13 @@ export declare class FlpSandbox {
|
|
|
60
61
|
* @returns FLP sandbox html
|
|
61
62
|
*/
|
|
62
63
|
private generateSandboxForEditor;
|
|
64
|
+
/**
|
|
65
|
+
* Sets application dependencies in the template configuration.
|
|
66
|
+
* The descriptor is refreshed if the global flag is set.
|
|
67
|
+
*
|
|
68
|
+
* @returns Promise that resolves when the application dependencies are set
|
|
69
|
+
*/
|
|
70
|
+
private setApplicationDependencies;
|
|
63
71
|
/**
|
|
64
72
|
* Add additional routes for configured editors.
|
|
65
73
|
*
|
package/dist/base/flp.js
CHANGED
|
@@ -31,6 +31,8 @@ class FlpSandbox {
|
|
|
31
31
|
project;
|
|
32
32
|
utils;
|
|
33
33
|
logger;
|
|
34
|
+
adp;
|
|
35
|
+
manifest;
|
|
34
36
|
onChangeRequest;
|
|
35
37
|
templateConfig;
|
|
36
38
|
config;
|
|
@@ -69,19 +71,21 @@ class FlpSandbox {
|
|
|
69
71
|
* @param manifest application manifest
|
|
70
72
|
* @param componentId optional componentId e.g. for adaptation projects
|
|
71
73
|
* @param resources optional additional resource mappings
|
|
72
|
-
* @param
|
|
74
|
+
* @param adp optional reference to the ADP tooling
|
|
73
75
|
*/
|
|
74
|
-
async init(manifest, componentId, resources = {},
|
|
76
|
+
async init(manifest, componentId, resources = {}, adp) {
|
|
75
77
|
this.createFlexHandler();
|
|
76
78
|
this.config.libs ??= await this.hasLocateReuseLibsScript();
|
|
77
|
-
const id = manifest['sap.app']
|
|
79
|
+
const id = manifest['sap.app']?.id ?? '';
|
|
78
80
|
this.templateConfig = (0, config_1.createFlpTemplateConfig)(this.config, manifest, resources);
|
|
81
|
+
this.adp = adp;
|
|
82
|
+
this.manifest = manifest;
|
|
79
83
|
await (0, config_1.addApp)(this.templateConfig, manifest, {
|
|
80
84
|
componentId,
|
|
81
85
|
target: resources[componentId ?? id] ?? this.templateConfig.basePath,
|
|
82
86
|
local: '.',
|
|
83
87
|
intent: this.config.intent
|
|
84
|
-
}, this.logger
|
|
88
|
+
}, this.logger);
|
|
85
89
|
this.addStandardRoutes();
|
|
86
90
|
if (this.rta) {
|
|
87
91
|
this.rta.options ??= {};
|
|
@@ -104,10 +108,11 @@ class FlpSandbox {
|
|
|
104
108
|
* @param editor editor configuration
|
|
105
109
|
* @returns FLP sandbox html
|
|
106
110
|
*/
|
|
107
|
-
generateSandboxForEditor(rta, editor) {
|
|
111
|
+
async generateSandboxForEditor(rta, editor) {
|
|
108
112
|
const defaultGenerator = editor.developerMode
|
|
109
113
|
? '@sap-ux/control-property-editor'
|
|
110
114
|
: '@sap-ux/preview-middleware';
|
|
115
|
+
await this.setApplicationDependencies();
|
|
111
116
|
const config = { ...this.templateConfig };
|
|
112
117
|
/* sap.ui.rta needs to be added to the list of preload libs for variants management and adaptation projects */
|
|
113
118
|
if (!config.ui5.libs.includes('sap.ui.rta')) {
|
|
@@ -129,6 +134,19 @@ class FlpSandbox {
|
|
|
129
134
|
const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandbox.html'), 'utf-8');
|
|
130
135
|
return (0, ejs_1.render)(template, config);
|
|
131
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Sets application dependencies in the template configuration.
|
|
139
|
+
* The descriptor is refreshed if the global flag is set.
|
|
140
|
+
*
|
|
141
|
+
* @returns Promise that resolves when the application dependencies are set
|
|
142
|
+
*/
|
|
143
|
+
async setApplicationDependencies() {
|
|
144
|
+
if (this.adp) {
|
|
145
|
+
await this.adp.sync();
|
|
146
|
+
const appName = (0, config_1.getAppName)(this.manifest, this.config.intent);
|
|
147
|
+
this.templateConfig.apps[appName].applicationDependencies = this.adp.descriptor;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
132
150
|
/**
|
|
133
151
|
* Add additional routes for configured editors.
|
|
134
152
|
*
|
|
@@ -170,7 +188,7 @@ class FlpSandbox {
|
|
|
170
188
|
}
|
|
171
189
|
this.router.use(`${path}editor`, (0, express_1.static)(cpe));
|
|
172
190
|
}
|
|
173
|
-
this.router.get(previewUrl, (req, res) => {
|
|
191
|
+
this.router.get(previewUrl, async (req, res) => {
|
|
174
192
|
if (!req.query['fiori-tools-rta-mode']) {
|
|
175
193
|
// Redirect to the same URL but add the necessary parameter
|
|
176
194
|
const params = JSON.parse(JSON.stringify(req.query));
|
|
@@ -180,7 +198,7 @@ class FlpSandbox {
|
|
|
180
198
|
res.redirect(302, `${previewUrl}?${new URLSearchParams(params)}`);
|
|
181
199
|
return;
|
|
182
200
|
}
|
|
183
|
-
const html = this.generateSandboxForEditor(rta, editor).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
|
|
201
|
+
const html = (await this.generateSandboxForEditor(rta, editor)).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
|
|
184
202
|
this.sendResponse(res, 'text/html', 200, html);
|
|
185
203
|
});
|
|
186
204
|
}
|
|
@@ -470,7 +488,7 @@ async function initAdp(rootProject, config, flp, util, logger) {
|
|
|
470
488
|
}
|
|
471
489
|
const descriptor = adp.descriptor;
|
|
472
490
|
const { name, manifest } = descriptor;
|
|
473
|
-
await flp.init(manifest, name, adp.resources,
|
|
491
|
+
await flp.init(manifest, name, adp.resources, adp);
|
|
474
492
|
flp.router.use(adp.descriptor.url, adp.proxy.bind(adp));
|
|
475
493
|
flp.addOnChangeRequestHandler(adp.onChangeRequest.bind(adp));
|
|
476
494
|
flp.router.use((0, express_1.json)());
|
|
@@ -250,8 +250,8 @@ sap.ui.define([
|
|
|
250
250
|
async prepareChangeType(command, inactiveCommandCount, index) {
|
|
251
251
|
let result;
|
|
252
252
|
let value = '';
|
|
253
|
-
const change = command
|
|
254
|
-
const selectorId = typeof change
|
|
253
|
+
const change = command?.getPreparedChange?.();
|
|
254
|
+
const selectorId = typeof change?.getSelector === 'function' ? await this.getControlIdByChange(change) : this.getCommandSelectorId(command);
|
|
255
255
|
const changeType = this.getCommandChangeType(command);
|
|
256
256
|
if (!changeType) {
|
|
257
257
|
return undefined;
|
|
@@ -304,10 +304,10 @@ sap.ui.define([
|
|
|
304
304
|
}
|
|
305
305
|
return result;
|
|
306
306
|
} catch (error) {
|
|
307
|
-
Log.error('Retry operation failed:', getError(error));
|
|
308
307
|
continue;
|
|
309
308
|
}
|
|
310
309
|
}
|
|
310
|
+
Log.error('All retry operations failed');
|
|
311
311
|
return undefined;
|
|
312
312
|
}
|
|
313
313
|
getCommandChangeType(command) {
|
|
@@ -338,6 +338,9 @@ sap.ui.define([
|
|
|
338
338
|
return selector.id;
|
|
339
339
|
}
|
|
340
340
|
const changeHandlerAPI = (await __ui5_require_async('sap/ui/fl/write/api/ChangesWriteAPI')).default;
|
|
341
|
+
if (typeof changeHandlerAPI?.getChangeHandler !== 'function') {
|
|
342
|
+
return selector.id;
|
|
343
|
+
}
|
|
341
344
|
const changeHandler = await changeHandlerAPI.getChangeHandler({
|
|
342
345
|
changeType,
|
|
343
346
|
element: control,
|
|
@@ -397,10 +397,10 @@ export class ChangeService {
|
|
|
397
397
|
let result: PendingChange;
|
|
398
398
|
let value = '';
|
|
399
399
|
|
|
400
|
-
const change = command
|
|
400
|
+
const change = command?.getPreparedChange?.();
|
|
401
401
|
|
|
402
402
|
const selectorId =
|
|
403
|
-
typeof change
|
|
403
|
+
typeof change?.getSelector === 'function'
|
|
404
404
|
? await this.getControlIdByChange(change)
|
|
405
405
|
: this.getCommandSelectorId(command);
|
|
406
406
|
|
|
@@ -468,10 +468,10 @@ export class ChangeService {
|
|
|
468
468
|
}
|
|
469
469
|
return result;
|
|
470
470
|
} catch (error) {
|
|
471
|
-
Log.error('Retry operation failed:', getError(error));
|
|
472
471
|
continue;
|
|
473
472
|
}
|
|
474
473
|
}
|
|
474
|
+
Log.error('All retry operations failed');
|
|
475
475
|
return undefined;
|
|
476
476
|
}
|
|
477
477
|
|
|
@@ -528,6 +528,10 @@ export class ChangeService {
|
|
|
528
528
|
|
|
529
529
|
const changeHandlerAPI = (await import('sap/ui/fl/write/api/ChangesWriteAPI')).default;
|
|
530
530
|
|
|
531
|
+
if (typeof changeHandlerAPI?.getChangeHandler !== 'function') {
|
|
532
|
+
return selector.id;
|
|
533
|
+
}
|
|
534
|
+
|
|
531
535
|
const changeHandler = await changeHandlerAPI.getChangeHandler({
|
|
532
536
|
changeType,
|
|
533
537
|
element: control,
|
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.16.
|
|
12
|
+
"version": "0.16.111",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@sap-ux/logger": "0.6.0",
|
|
29
29
|
"@sap-ux/feature-toggle": "0.2.2",
|
|
30
30
|
"@sap-ux/btp-utils": "0.15.2",
|
|
31
|
-
"@sap-ux/adp-tooling": "0.12.
|
|
31
|
+
"@sap-ux/adp-tooling": "0.12.74",
|
|
32
32
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.24",
|
|
33
33
|
"@sap-ux/project-access": "1.28.6"
|
|
34
34
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"supertest": "6.3.3",
|
|
47
47
|
"@sap-ux-private/playwright": "0.1.0",
|
|
48
48
|
"dotenv": "16.3.1",
|
|
49
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.
|
|
49
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.25",
|
|
50
50
|
"@sap-ux/axios-extension": "1.17.1",
|
|
51
51
|
"@sap-ux/store": "0.9.3",
|
|
52
52
|
"@sap-ux/ui5-info": "0.8.3",
|