@sap-ux/preview-middleware 0.17.37 → 0.17.39
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 +26 -23
- package/dist/base/config.d.ts +9 -1
- package/dist/base/config.js +29 -5
- package/dist/base/flp.d.ts +1 -1
- package/dist/base/flp.js +16 -16
- package/dist/client/adp/api-handler.js +153 -153
- package/dist/client/adp/command-executor.js +75 -75
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/BaseDialog.controller.js +187 -187
- package/dist/client/adp/controllers/ControllerExtension.controller.js +213 -213
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
- package/dist/client/adp/dialog-factory.js +122 -122
- package/dist/client/adp/init-dialogs.js +100 -100
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +55 -55
- package/dist/client/adp/quick-actions/common/create-page-action.js +50 -50
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +36 -36
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +48 -48
- package/dist/client/adp/quick-actions/common/utils.js +18 -18
- package/dist/client/adp/quick-actions/control-types.js +21 -21
- package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
- package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +70 -70
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +96 -96
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +58 -58
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
- package/dist/client/adp/quick-actions/fe-v2/registry.js +75 -75
- package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +73 -73
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +49 -49
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +46 -46
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +55 -55
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +82 -82
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +52 -52
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
- package/dist/client/adp/quick-actions/fe-v4/registry.js +58 -58
- package/dist/client/adp/quick-actions/fe-v4/utils.js +47 -47
- package/dist/client/adp/quick-actions/load.js +44 -44
- package/dist/client/adp/quick-actions/quick-action-base.js +53 -53
- package/dist/client/adp/utils.js +160 -160
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +39 -39
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/feature-service.js +36 -36
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/editable.js +37 -37
- package/dist/client/cpe/outline/nodes.js +222 -222
- package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
- package/dist/client/cpe/quick-actions/registry.js +143 -143
- package/dist/client/cpe/quick-actions/utils.js +92 -92
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +33 -33
- package/dist/client/cpe/utils.js +138 -138
- package/dist/client/flp/WorkspaceConnector.js +86 -86
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +83 -83
- package/dist/client/flp/initConnectors.js +30 -30
- package/dist/client/flp/initRta.js +178 -178
- package/dist/client/i18n.js +56 -56
- package/dist/client/tsconfig.tsbuildinfo +1 -0
- package/dist/client/utils/application.js +32 -32
- package/dist/client/utils/core.js +68 -68
- package/dist/client/utils/error.js +19 -19
- package/dist/client/utils/fe-v4.js +118 -118
- package/dist/client/utils/version.js +102 -102
- package/dist/types/index.d.ts +13 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,27 +13,30 @@ When this middleware is used together with the `reload-middleware`, then the ord
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## [Configuration Options](#configuration-options)
|
|
16
|
-
| Option
|
|
17
|
-
|
|
18
|
-
| `flp`
|
|
19
|
-
| `flp.path`
|
|
20
|
-
| `flp.init`
|
|
21
|
-
| `flp.intent`
|
|
22
|
-
| `flp.intent.object`
|
|
23
|
-
| `flp.intent.action`
|
|
24
|
-
| `flp.apps`
|
|
25
|
-
| `flp.libs`
|
|
26
|
-
| `flp.theme` | `string`
|
|
27
|
-
| `adp.target`
|
|
28
|
-
| `adp.ignoreCertErrors`
|
|
29
|
-
| `rta`
|
|
30
|
-
| `
|
|
31
|
-
| `rta
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
16
|
+
| Option | Type | Default Value | Description |
|
|
17
|
+
|-------------------------|-----------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
18
|
+
| `flp` | | | Optional configuration object for the local Fiori launchpad |
|
|
19
|
+
| `flp.path` | `string` | `/test/flp.html` | The mount point of the local Fiori launchpad. |
|
|
20
|
+
| `flp.init` | `string` | `undefined` | Optional UI5 module/script to be executed after the standard initialization |
|
|
21
|
+
| `flp.intent` | | | Optional intent to be used for the application |
|
|
22
|
+
| `flp.intent.object` | `string` | `app` | Optional intent object |
|
|
23
|
+
| `flp.intent.action` | `string` | `preview` | Optional intent action |
|
|
24
|
+
| `flp.apps` | `array` | `undefined` | Optional additional local apps that are available in local Fiori launchpad |
|
|
25
|
+
| `flp.libs` | `boolean` | `undefined` | Optional flag to add a generic script fetching the paths of used libraries not available in UI5. To disable 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
|
+
| `flp.theme` | `string` | `undefined` | Optional flag for setting the UI5 Theme. |
|
|
27
|
+
| `adp.target` | | | Required configuration for adaptation projects defining the connected backend |
|
|
28
|
+
| `adp.ignoreCertErrors` | `boolean` | `false` | Optional setting to ignore certification validation errors when working with e.g. development systems with self signed certificates |
|
|
29
|
+
| `rta` | | | 🚫 *Deprecated: use 'editors.rta' instead* <br/> Optional configuration allowing to add mount points for runtime adaptation |
|
|
30
|
+
| `editors` | | | Optional list of configurations allowing to add mount points for additional editors |
|
|
31
|
+
| `editors.rta` | `array` | `undefined` | Optional configuration allowing to add mount points for runtime adaptation |
|
|
32
|
+
| `editors.rta.layer` | `string` | `(calculated)` | Optional property for defining the runtime adaptation layer for changes (default is `CUSTOMER_BASE` or read from the project for adaptation projects) |
|
|
33
|
+
| `editors.rta.endpoints` | `array` | `undefined` | Optional list of mount points for editing |
|
|
34
|
+
| `test` | `array` | `undefined` | Optional list of configurations for automated testing. |
|
|
35
|
+
| `debug` | `boolean` | `false` | Enables debug output |
|
|
34
36
|
|
|
35
37
|
### [`flp.apps`](#configuration-option-flpapps)
|
|
36
38
|
Array of additional application configurations:
|
|
39
|
+
|
|
37
40
|
| Option | Type | Default Value | Description |
|
|
38
41
|
| ------------------------ | -------- | -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
39
42
|
| `target` | `string` | | Target path of the additional application |
|
|
@@ -50,11 +53,11 @@ Array of additional application configurations:
|
|
|
50
53
|
| `client` | `string` optional | sap-client parameter |
|
|
51
54
|
| `scp` | `boolean` optional | If set to true the proxy will execute the required OAuth routine for the ABAP environment on SAP BTP |
|
|
52
55
|
|
|
53
|
-
### [`
|
|
54
|
-
| Option
|
|
55
|
-
|
|
56
|
-
| `path` | `string` mandatory | The mount point to be used for the editor.
|
|
57
|
-
| `developerMode` | `boolean` optional | Enables/disables the runtime adaptation developer mode (only supported for adaptation projects) |
|
|
56
|
+
### [`editors`](#configuration-option-editors)
|
|
57
|
+
| Option | Type | Description |
|
|
58
|
+
|-------------------------------|--------------------|-------------------------------------------------------------------------------------------------|
|
|
59
|
+
| `rta.endpoints.path` | `string` mandatory | The mount point to be used for the editor. |
|
|
60
|
+
| `rta.endpoints.developerMode` | `boolean` optional | Enables/disables the runtime adaptation developer mode (only supported for adaptation projects) |
|
|
58
61
|
|
|
59
62
|
### [`test`](#configuration-option-test)
|
|
60
63
|
| Option | Type | Description |
|
package/dist/base/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToolsLogger, type Logger } from '@sap-ux/logger';
|
|
2
|
-
import type { App, DefaultFlpPath, DefaultIntent, FlpConfig, Intent, InternalTestConfig, MiddlewareConfig, TestConfig } from '../types';
|
|
2
|
+
import type { App, DefaultFlpPath, DefaultIntent, FlpConfig, Intent, InternalTestConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
|
|
3
3
|
import { type Manifest, type UI5FlexLayer } from '@sap-ux/project-access';
|
|
4
4
|
import { type Editor } from 'mem-fs-editor';
|
|
5
5
|
import type { MergedAppDescriptor } from '@sap-ux/axios-extension';
|
|
@@ -95,6 +95,14 @@ export declare function getFlpConfigWithDefaults(config?: Partial<FlpConfig>): F
|
|
|
95
95
|
* @param logger logger instance
|
|
96
96
|
*/
|
|
97
97
|
export declare function sanitizeConfig(config: MiddlewareConfig, logger: ToolsLogger): void;
|
|
98
|
+
/**
|
|
99
|
+
* Sanitize the deprecated RTA configuration.
|
|
100
|
+
*
|
|
101
|
+
* @param deprecatedRtaConfig deprecated RTA configuration
|
|
102
|
+
* @param logger logger instance
|
|
103
|
+
* @returns sanitized RTA configuration
|
|
104
|
+
*/
|
|
105
|
+
export declare function sanitizeRtaConfig(deprecatedRtaConfig: MiddlewareConfig['rta'], logger: Logger): RtaConfig | undefined;
|
|
98
106
|
/**
|
|
99
107
|
* Add an application to the local FLP preview.
|
|
100
108
|
*
|
package/dist/base/config.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DEFAULT_INTENT = exports.DEFAULT_PATH = exports.DEFAULT_THEME = exports.PREVIEW_URL = void 0;
|
|
4
4
|
exports.getFlpConfigWithDefaults = getFlpConfigWithDefaults;
|
|
5
5
|
exports.sanitizeConfig = sanitizeConfig;
|
|
6
|
+
exports.sanitizeRtaConfig = sanitizeRtaConfig;
|
|
6
7
|
exports.addApp = addApp;
|
|
7
8
|
exports.getAppName = getAppName;
|
|
8
9
|
exports.createFlpTemplateConfig = createFlpTemplateConfig;
|
|
@@ -118,8 +119,14 @@ function getFlpConfigWithDefaults(config = {}) {
|
|
|
118
119
|
* @param logger logger instance
|
|
119
120
|
*/
|
|
120
121
|
function sanitizeConfig(config, logger) {
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
//prettier-ignore
|
|
123
|
+
if (config.rta) { //NOSONAR
|
|
124
|
+
config.editors ??= {};
|
|
125
|
+
config.editors.rta = sanitizeRtaConfig(config.rta, logger); //NOSONAR
|
|
126
|
+
delete config.rta; //NOSONAR
|
|
127
|
+
}
|
|
128
|
+
if (config.editors?.rta && config.adp === undefined) {
|
|
129
|
+
config.editors.rta.endpoints = config.editors.rta.endpoints.map((editor) => {
|
|
123
130
|
if (editor.developerMode) {
|
|
124
131
|
logger.error('developerMode is ONLY supported for SAP UI5 adaptation projects.');
|
|
125
132
|
logger.warn(`developerMode for ${editor.path} disabled`);
|
|
@@ -129,6 +136,23 @@ function sanitizeConfig(config, logger) {
|
|
|
129
136
|
});
|
|
130
137
|
}
|
|
131
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Sanitize the deprecated RTA configuration.
|
|
141
|
+
*
|
|
142
|
+
* @param deprecatedRtaConfig deprecated RTA configuration
|
|
143
|
+
* @param logger logger instance
|
|
144
|
+
* @returns sanitized RTA configuration
|
|
145
|
+
*/
|
|
146
|
+
//prettier-ignore
|
|
147
|
+
function sanitizeRtaConfig(deprecatedRtaConfig, logger) {
|
|
148
|
+
let rtaConfig;
|
|
149
|
+
if (deprecatedRtaConfig) {
|
|
150
|
+
const { editors, ...rta } = deprecatedRtaConfig;
|
|
151
|
+
rtaConfig = { ...rta, endpoints: [...editors] };
|
|
152
|
+
logger.warn(`The configuration option 'rta' is deprecated. Please use 'editors.rta' instead.`);
|
|
153
|
+
}
|
|
154
|
+
return rtaConfig;
|
|
155
|
+
}
|
|
132
156
|
/**
|
|
133
157
|
* Retrieves the configuration settings for UI5 flexibility services.
|
|
134
158
|
*
|
|
@@ -279,9 +303,9 @@ function getPreviewPaths(config, logger = new logger_1.ToolsLogger()) {
|
|
|
279
303
|
const flpConfig = getFlpConfigWithDefaults(config.flp);
|
|
280
304
|
urls.push({ path: `${flpConfig.path}#${flpConfig.intent.object}-${flpConfig.intent.action}`, type: 'preview' });
|
|
281
305
|
// add editor urls
|
|
282
|
-
if (config.rta
|
|
283
|
-
config.rta.
|
|
284
|
-
urls.push({ path:
|
|
306
|
+
if (config.editors?.rta) {
|
|
307
|
+
config.editors.rta.endpoints.forEach((endpoint) => {
|
|
308
|
+
urls.push({ path: endpoint.path, type: 'editor' });
|
|
285
309
|
});
|
|
286
310
|
}
|
|
287
311
|
// add test urls if configured
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class FlpSandbox {
|
|
|
25
25
|
private manifest;
|
|
26
26
|
protected onChangeRequest: OnChangeRequestHandler | undefined;
|
|
27
27
|
protected templateConfig: TemplateConfig;
|
|
28
|
-
readonly
|
|
28
|
+
readonly flpConfig: FlpConfig;
|
|
29
29
|
readonly rta?: RtaConfig;
|
|
30
30
|
readonly test?: TestConfig[];
|
|
31
31
|
readonly router: EnhancedRouter;
|
package/dist/base/flp.js
CHANGED
|
@@ -27,7 +27,7 @@ class FlpSandbox {
|
|
|
27
27
|
manifest;
|
|
28
28
|
onChangeRequest;
|
|
29
29
|
templateConfig;
|
|
30
|
-
|
|
30
|
+
flpConfig;
|
|
31
31
|
rta;
|
|
32
32
|
test;
|
|
33
33
|
router;
|
|
@@ -44,10 +44,10 @@ class FlpSandbox {
|
|
|
44
44
|
this.project = project;
|
|
45
45
|
this.utils = utils;
|
|
46
46
|
this.logger = logger;
|
|
47
|
-
this.
|
|
47
|
+
this.flpConfig = (0, config_1.getFlpConfigWithDefaults)(config.flp);
|
|
48
48
|
this.test = config.test;
|
|
49
|
-
this.rta = config.rta;
|
|
50
|
-
logger.debug(`Config: ${JSON.stringify({ flp: this.
|
|
49
|
+
this.rta = config.editors?.rta ?? (0, config_1.sanitizeRtaConfig)(config.rta, logger); //NOSONAR
|
|
50
|
+
logger.debug(`Config: ${JSON.stringify({ flp: this.flpConfig, rta: this.rta, test: this.test })}`);
|
|
51
51
|
this.router = (0, express_1.Router)();
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -68,16 +68,16 @@ class FlpSandbox {
|
|
|
68
68
|
*/
|
|
69
69
|
async init(manifest, componentId, resources = {}, adp) {
|
|
70
70
|
this.createFlexHandler();
|
|
71
|
-
this.
|
|
71
|
+
this.flpConfig.libs ??= await this.hasLocateReuseLibsScript();
|
|
72
72
|
const id = manifest['sap.app']?.id ?? '';
|
|
73
|
-
this.templateConfig = (0, config_1.createFlpTemplateConfig)(this.
|
|
73
|
+
this.templateConfig = (0, config_1.createFlpTemplateConfig)(this.flpConfig, manifest, resources);
|
|
74
74
|
this.adp = adp;
|
|
75
75
|
this.manifest = manifest;
|
|
76
76
|
await (0, config_1.addApp)(this.templateConfig, manifest, {
|
|
77
77
|
componentId,
|
|
78
78
|
target: resources[componentId ?? id] ?? this.templateConfig.basePath,
|
|
79
79
|
local: '.',
|
|
80
|
-
intent: this.
|
|
80
|
+
intent: this.flpConfig.intent
|
|
81
81
|
}, this.logger);
|
|
82
82
|
this.addStandardRoutes();
|
|
83
83
|
if (this.rta) {
|
|
@@ -171,7 +171,7 @@ class FlpSandbox {
|
|
|
171
171
|
async setApplicationDependencies() {
|
|
172
172
|
if (this.adp) {
|
|
173
173
|
await this.adp.sync();
|
|
174
|
-
const appName = (0, config_1.getAppName)(this.manifest, this.
|
|
174
|
+
const appName = (0, config_1.getAppName)(this.manifest, this.flpConfig.intent);
|
|
175
175
|
this.templateConfig.apps[appName].applicationDependencies = this.adp.descriptor;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -185,7 +185,7 @@ class FlpSandbox {
|
|
|
185
185
|
*/
|
|
186
186
|
async editorGetHandlerDeveloperMode(res, rta, previewUrl) {
|
|
187
187
|
const scenario = rta.options?.scenario;
|
|
188
|
-
let templatePreviewUrl = `${previewUrl}?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=forAdaptation&sap-ui-rta-skip-flex-validation=true&sap-ui-xx-condense-changes=true#${this.
|
|
188
|
+
let templatePreviewUrl = `${previewUrl}?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=forAdaptation&sap-ui-rta-skip-flex-validation=true&sap-ui-xx-condense-changes=true#${this.flpConfig.intent.object}-${this.flpConfig.intent.action}`;
|
|
189
189
|
if (scenario === 'ADAPTATION_PROJECT') {
|
|
190
190
|
templatePreviewUrl = templatePreviewUrl.replace('?', `?sap-ui-layer=${rta.layer}&`);
|
|
191
191
|
}
|
|
@@ -237,7 +237,7 @@ class FlpSandbox {
|
|
|
237
237
|
*/
|
|
238
238
|
addEditorRoutes(rta) {
|
|
239
239
|
const cpe = (0, path_1.dirname)(require.resolve('@sap-ux/control-property-editor-sources'));
|
|
240
|
-
for (const editor of rta.
|
|
240
|
+
for (const editor of rta.endpoints) {
|
|
241
241
|
let previewUrl = editor.path.startsWith('/') ? editor.path : `/${editor.path}`;
|
|
242
242
|
if (editor.developerMode) {
|
|
243
243
|
previewUrl = `${previewUrl}.inner.html`;
|
|
@@ -270,15 +270,15 @@ class FlpSandbox {
|
|
|
270
270
|
// Redirect to the same URL but add the necessary parameter
|
|
271
271
|
const params = structuredClone(req.query);
|
|
272
272
|
params['sap-ui-xx-viewCache'] = 'false';
|
|
273
|
-
res.redirect(302, `${this.
|
|
273
|
+
res.redirect(302, `${this.flpConfig.path}?${new URLSearchParams(params)}`);
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
276
|
await this.setApplicationDependencies();
|
|
277
277
|
// inform the user if a html file exists on the filesystem
|
|
278
278
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
279
|
-
const file = await this.project.byPath(this.
|
|
279
|
+
const file = await this.project.byPath(this.flpConfig.path);
|
|
280
280
|
if (file) {
|
|
281
|
-
this.logger.info(`HTML file returned at ${this.
|
|
281
|
+
this.logger.info(`HTML file returned at ${this.flpConfig.path} is loaded from the file system.`);
|
|
282
282
|
next();
|
|
283
283
|
}
|
|
284
284
|
else {
|
|
@@ -298,7 +298,7 @@ class FlpSandbox {
|
|
|
298
298
|
// register static client sources
|
|
299
299
|
this.router.use(config_1.PREVIEW_URL.client.path, (0, express_1.static)(config_1.PREVIEW_URL.client.local));
|
|
300
300
|
// add route for the sandbox html
|
|
301
|
-
this.router.get(this.
|
|
301
|
+
this.router.get(this.flpConfig.path, async (req, res, next) => {
|
|
302
302
|
await this.flpGetHandler(req, res, next);
|
|
303
303
|
});
|
|
304
304
|
}
|
|
@@ -372,7 +372,7 @@ class FlpSandbox {
|
|
|
372
372
|
* Add additional routes for apps also to be shown in the local FLP.
|
|
373
373
|
*/
|
|
374
374
|
async addRoutesForAdditionalApps() {
|
|
375
|
-
for (const app of this.
|
|
375
|
+
for (const app of this.flpConfig.apps) {
|
|
376
376
|
let manifest;
|
|
377
377
|
if (app.local) {
|
|
378
378
|
this.fs = this.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
@@ -700,7 +700,7 @@ async function initAdp(rootProject, config, flp, util, logger) {
|
|
|
700
700
|
projectId: variant.id,
|
|
701
701
|
scenario: 'ADAPTATION_PROJECT'
|
|
702
702
|
};
|
|
703
|
-
for (const editor of flp.rta.
|
|
703
|
+
for (const editor of flp.rta.endpoints) {
|
|
704
704
|
editor.pluginScript ??= 'open/ux/preview/client/adp/init';
|
|
705
705
|
}
|
|
706
706
|
}
|
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["../utils/error"], function (___utils_error) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
const getError = ___utils_error["getError"];
|
|
7
|
-
var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
|
|
8
|
-
ApiEndpoints["CHANGES"] = "/preview/api/changes";
|
|
9
|
-
ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
|
|
10
|
-
ApiEndpoints["CONTROLLER"] = "/adp/api/controller";
|
|
11
|
-
ApiEndpoints["CODE_EXT"] = "/adp/api/code_ext";
|
|
12
|
-
ApiEndpoints["ANNOTATION_FILE"] = "/adp/api/annotation";
|
|
13
|
-
ApiEndpoints["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
|
|
14
|
-
return ApiEndpoints;
|
|
15
|
-
}(ApiEndpoints || {});
|
|
16
|
-
var RequestMethod = /*#__PURE__*/function (RequestMethod) {
|
|
17
|
-
RequestMethod["GET"] = "GET";
|
|
18
|
-
RequestMethod["PUT"] = "PUT";
|
|
19
|
-
RequestMethod["POST"] = "POST";
|
|
20
|
-
RequestMethod["PATCH"] = "PATCH";
|
|
21
|
-
RequestMethod["DELETE"] = "DELETE";
|
|
22
|
-
return RequestMethod;
|
|
23
|
-
}(RequestMethod || {});
|
|
24
|
-
/**
|
|
25
|
-
* Requests a given endpoint
|
|
26
|
-
*
|
|
27
|
-
* @param endpoint API Endpoint
|
|
28
|
-
* @param method RequestMethod
|
|
29
|
-
* @param data Data to be sent to the server
|
|
30
|
-
* @returns Data from the server request
|
|
31
|
-
*/
|
|
32
|
-
async function request(endpoint, method, data) {
|
|
33
|
-
const config = {
|
|
34
|
-
method,
|
|
35
|
-
body: JSON.stringify(data),
|
|
36
|
-
headers: {
|
|
37
|
-
'content-type': 'application/json'
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
try {
|
|
41
|
-
const response = await fetch(endpoint, config);
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
const errorData = await response.json();
|
|
44
|
-
const message = errorData?.message ?? '';
|
|
45
|
-
throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
|
|
46
|
-
}
|
|
47
|
-
switch (method) {
|
|
48
|
-
case RequestMethod.GET:
|
|
49
|
-
return response.json();
|
|
50
|
-
case RequestMethod.POST:
|
|
51
|
-
/**
|
|
52
|
-
* Since POST usually creates something
|
|
53
|
-
* and returns nothing (or a message) we just parse the text from res.send(msg)
|
|
54
|
-
*/
|
|
55
|
-
return response.text();
|
|
56
|
-
default:
|
|
57
|
-
return response.json();
|
|
58
|
-
}
|
|
59
|
-
} catch (e) {
|
|
60
|
-
throw getError(e);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Retrieves all XML fragments from the project's workspace
|
|
66
|
-
*
|
|
67
|
-
* @returns Generic Promise<T>
|
|
68
|
-
*/
|
|
69
|
-
async function getFragments() {
|
|
70
|
-
return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Writes an XML fragment to the project's workspace
|
|
75
|
-
*
|
|
76
|
-
* @param data Data to be send to the server
|
|
77
|
-
* @returns Generic Promise<T>
|
|
78
|
-
*/
|
|
79
|
-
async function writeFragment(data) {
|
|
80
|
-
return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves manifest.appdescr_variant from the project's workspace
|
|
85
|
-
*
|
|
86
|
-
* @returns Generic Promise<T>
|
|
87
|
-
*/
|
|
88
|
-
async function getManifestAppdescr() {
|
|
89
|
-
return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves all controller extensions from the project's workspace
|
|
94
|
-
*
|
|
95
|
-
* @returns Generic Promise<T>
|
|
96
|
-
*/
|
|
97
|
-
async function readControllers() {
|
|
98
|
-
return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Writes a Controller to the project's workspace
|
|
103
|
-
*
|
|
104
|
-
* @param data Data to be send to the server
|
|
105
|
-
* @returns Generic Promise<T>
|
|
106
|
-
*/
|
|
107
|
-
async function writeController(data) {
|
|
108
|
-
return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Writes a new annotation file to the project's workspace
|
|
113
|
-
*
|
|
114
|
-
* @returns Generic Promise<DataSourceAnnotationMap>
|
|
115
|
-
*/
|
|
116
|
-
async function getDataSourceAnnotationFileMap() {
|
|
117
|
-
return request(ApiEndpoints.ANNOTATION_FILE, RequestMethod.GET);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Checks for existing controller in the project's workspace
|
|
122
|
-
*
|
|
123
|
-
* @param controllerName Name of the controller
|
|
124
|
-
* @returns {CodeExtResponse} Returns path to existing controller if found
|
|
125
|
-
*/
|
|
126
|
-
async function getExistingController(controllerName) {
|
|
127
|
-
return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Writes a change object to the project's workspace
|
|
132
|
-
*
|
|
133
|
-
* @param data Data to be send to the server
|
|
134
|
-
* @returns Generic Promise<T>
|
|
135
|
-
*/
|
|
136
|
-
async function writeChange(data) {
|
|
137
|
-
return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
|
|
138
|
-
}
|
|
139
|
-
var __exports = {
|
|
140
|
-
__esModule: true
|
|
141
|
-
};
|
|
142
|
-
__exports.ApiEndpoints = ApiEndpoints;
|
|
143
|
-
__exports.RequestMethod = RequestMethod;
|
|
144
|
-
__exports.request = request;
|
|
145
|
-
__exports.getFragments = getFragments;
|
|
146
|
-
__exports.writeFragment = writeFragment;
|
|
147
|
-
__exports.getManifestAppdescr = getManifestAppdescr;
|
|
148
|
-
__exports.readControllers = readControllers;
|
|
149
|
-
__exports.writeController = writeController;
|
|
150
|
-
__exports.getDataSourceAnnotationFileMap = getDataSourceAnnotationFileMap;
|
|
151
|
-
__exports.getExistingController = getExistingController;
|
|
152
|
-
__exports.writeChange = writeChange;
|
|
153
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["../utils/error"], function (___utils_error) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const getError = ___utils_error["getError"];
|
|
7
|
+
var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
|
|
8
|
+
ApiEndpoints["CHANGES"] = "/preview/api/changes";
|
|
9
|
+
ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
|
|
10
|
+
ApiEndpoints["CONTROLLER"] = "/adp/api/controller";
|
|
11
|
+
ApiEndpoints["CODE_EXT"] = "/adp/api/code_ext";
|
|
12
|
+
ApiEndpoints["ANNOTATION_FILE"] = "/adp/api/annotation";
|
|
13
|
+
ApiEndpoints["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
|
|
14
|
+
return ApiEndpoints;
|
|
15
|
+
}(ApiEndpoints || {});
|
|
16
|
+
var RequestMethod = /*#__PURE__*/function (RequestMethod) {
|
|
17
|
+
RequestMethod["GET"] = "GET";
|
|
18
|
+
RequestMethod["PUT"] = "PUT";
|
|
19
|
+
RequestMethod["POST"] = "POST";
|
|
20
|
+
RequestMethod["PATCH"] = "PATCH";
|
|
21
|
+
RequestMethod["DELETE"] = "DELETE";
|
|
22
|
+
return RequestMethod;
|
|
23
|
+
}(RequestMethod || {});
|
|
24
|
+
/**
|
|
25
|
+
* Requests a given endpoint
|
|
26
|
+
*
|
|
27
|
+
* @param endpoint API Endpoint
|
|
28
|
+
* @param method RequestMethod
|
|
29
|
+
* @param data Data to be sent to the server
|
|
30
|
+
* @returns Data from the server request
|
|
31
|
+
*/
|
|
32
|
+
async function request(endpoint, method, data) {
|
|
33
|
+
const config = {
|
|
34
|
+
method,
|
|
35
|
+
body: JSON.stringify(data),
|
|
36
|
+
headers: {
|
|
37
|
+
'content-type': 'application/json'
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
const response = await fetch(endpoint, config);
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const errorData = await response.json();
|
|
44
|
+
const message = errorData?.message ?? '';
|
|
45
|
+
throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
|
|
46
|
+
}
|
|
47
|
+
switch (method) {
|
|
48
|
+
case RequestMethod.GET:
|
|
49
|
+
return response.json();
|
|
50
|
+
case RequestMethod.POST:
|
|
51
|
+
/**
|
|
52
|
+
* Since POST usually creates something
|
|
53
|
+
* and returns nothing (or a message) we just parse the text from res.send(msg)
|
|
54
|
+
*/
|
|
55
|
+
return response.text();
|
|
56
|
+
default:
|
|
57
|
+
return response.json();
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
throw getError(e);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves all XML fragments from the project's workspace
|
|
66
|
+
*
|
|
67
|
+
* @returns Generic Promise<T>
|
|
68
|
+
*/
|
|
69
|
+
async function getFragments() {
|
|
70
|
+
return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Writes an XML fragment to the project's workspace
|
|
75
|
+
*
|
|
76
|
+
* @param data Data to be send to the server
|
|
77
|
+
* @returns Generic Promise<T>
|
|
78
|
+
*/
|
|
79
|
+
async function writeFragment(data) {
|
|
80
|
+
return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves manifest.appdescr_variant from the project's workspace
|
|
85
|
+
*
|
|
86
|
+
* @returns Generic Promise<T>
|
|
87
|
+
*/
|
|
88
|
+
async function getManifestAppdescr() {
|
|
89
|
+
return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves all controller extensions from the project's workspace
|
|
94
|
+
*
|
|
95
|
+
* @returns Generic Promise<T>
|
|
96
|
+
*/
|
|
97
|
+
async function readControllers() {
|
|
98
|
+
return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Writes a Controller to the project's workspace
|
|
103
|
+
*
|
|
104
|
+
* @param data Data to be send to the server
|
|
105
|
+
* @returns Generic Promise<T>
|
|
106
|
+
*/
|
|
107
|
+
async function writeController(data) {
|
|
108
|
+
return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Writes a new annotation file to the project's workspace
|
|
113
|
+
*
|
|
114
|
+
* @returns Generic Promise<DataSourceAnnotationMap>
|
|
115
|
+
*/
|
|
116
|
+
async function getDataSourceAnnotationFileMap() {
|
|
117
|
+
return request(ApiEndpoints.ANNOTATION_FILE, RequestMethod.GET);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Checks for existing controller in the project's workspace
|
|
122
|
+
*
|
|
123
|
+
* @param controllerName Name of the controller
|
|
124
|
+
* @returns {CodeExtResponse} Returns path to existing controller if found
|
|
125
|
+
*/
|
|
126
|
+
async function getExistingController(controllerName) {
|
|
127
|
+
return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Writes a change object to the project's workspace
|
|
132
|
+
*
|
|
133
|
+
* @param data Data to be send to the server
|
|
134
|
+
* @returns Generic Promise<T>
|
|
135
|
+
*/
|
|
136
|
+
async function writeChange(data) {
|
|
137
|
+
return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
|
|
138
|
+
}
|
|
139
|
+
var __exports = {
|
|
140
|
+
__esModule: true
|
|
141
|
+
};
|
|
142
|
+
__exports.ApiEndpoints = ApiEndpoints;
|
|
143
|
+
__exports.RequestMethod = RequestMethod;
|
|
144
|
+
__exports.request = request;
|
|
145
|
+
__exports.getFragments = getFragments;
|
|
146
|
+
__exports.writeFragment = writeFragment;
|
|
147
|
+
__exports.getManifestAppdescr = getManifestAppdescr;
|
|
148
|
+
__exports.readControllers = readControllers;
|
|
149
|
+
__exports.writeController = writeController;
|
|
150
|
+
__exports.getDataSourceAnnotationFileMap = getDataSourceAnnotationFileMap;
|
|
151
|
+
__exports.getExistingController = getExistingController;
|
|
152
|
+
__exports.writeChange = writeChange;
|
|
153
|
+
return __exports;
|
|
154
154
|
});
|
|
155
155
|
//# sourceMappingURL=api-handler.js.map
|