@sap-ux/preview-middleware 0.16.110 → 0.16.112
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 +9 -2
- package/dist/base/config.js +18 -10
- package/dist/base/flp.d.ts +12 -4
- package/dist/base/flp.js +26 -8
- package/package.json +4 -4
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)());
|
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.112",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"@sap-ux/logger": "0.6.0",
|
|
29
29
|
"@sap-ux/feature-toggle": "0.2.2",
|
|
30
|
-
"@sap-ux/btp-utils": "0.
|
|
31
|
-
"@sap-ux/adp-tooling": "0.12.
|
|
30
|
+
"@sap-ux/btp-utils": "0.16.0",
|
|
31
|
+
"@sap-ux/adp-tooling": "0.12.75",
|
|
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
|
},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@sap-ux-private/playwright": "0.1.0",
|
|
48
48
|
"dotenv": "16.3.1",
|
|
49
49
|
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.25",
|
|
50
|
-
"@sap-ux/axios-extension": "1.17.
|
|
50
|
+
"@sap-ux/axios-extension": "1.17.2",
|
|
51
51
|
"@sap-ux/store": "0.9.3",
|
|
52
52
|
"@sap-ux/ui5-info": "0.8.3",
|
|
53
53
|
"@sap-ux/i18n": "0.2.0"
|