@sap-ux/preview-middleware 0.16.136 → 0.16.139

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.
Files changed (59) hide show
  1. package/dist/base/flp.d.ts +32 -0
  2. package/dist/base/flp.js +101 -18
  3. package/dist/client/adp/api-handler.js +142 -142
  4. package/dist/client/adp/command-executor.js +75 -75
  5. package/dist/client/adp/control-utils.js +44 -44
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +187 -187
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +213 -213
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
  9. package/dist/client/adp/init-dialogs.js +157 -157
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +54 -54
  11. package/dist/client/adp/quick-actions/common/create-page-action.js +49 -49
  12. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +35 -35
  13. package/dist/client/adp/quick-actions/common/op-add-header-field.js +47 -47
  14. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +100 -100
  15. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +69 -69
  16. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +95 -95
  17. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +56 -56
  18. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +67 -67
  19. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +57 -57
  20. package/dist/client/adp/quick-actions/fe-v2/registry.js +71 -71
  21. package/dist/client/adp/quick-actions/fe-v2/utils.js +75 -75
  22. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +47 -47
  23. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +45 -45
  24. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +45 -45
  25. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +55 -55
  26. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +82 -82
  27. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +52 -52
  28. package/dist/client/adp/quick-actions/fe-v4/registry.js +55 -55
  29. package/dist/client/adp/quick-actions/fe-v4/utils.js +47 -47
  30. package/dist/client/adp/quick-actions/load.js +44 -44
  31. package/dist/client/adp/utils.js +160 -160
  32. package/dist/client/cpe/changes/index.js +10 -10
  33. package/dist/client/cpe/changes/validator.js +34 -34
  34. package/dist/client/cpe/documentation.js +164 -164
  35. package/dist/client/cpe/feature-service.js +36 -36
  36. package/dist/client/cpe/logger.js +30 -30
  37. package/dist/client/cpe/outline/editable.js +37 -37
  38. package/dist/client/cpe/outline/nodes.js +217 -217
  39. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  40. package/dist/client/cpe/quick-actions/registry.js +143 -143
  41. package/dist/client/cpe/quick-actions/utils.js +92 -92
  42. package/dist/client/cpe/types.js +4 -4
  43. package/dist/client/cpe/ui5-utils.js +33 -33
  44. package/dist/client/cpe/utils.js +138 -138
  45. package/dist/client/flp/WorkspaceConnector.js +86 -86
  46. package/dist/client/flp/common.js +28 -28
  47. package/dist/client/flp/enableFakeConnector.js +83 -83
  48. package/dist/client/flp/initConnectors.js +30 -30
  49. package/dist/client/flp/initRta.js +178 -178
  50. package/dist/client/i18n.js +56 -56
  51. package/dist/client/utils/application.js +32 -32
  52. package/dist/client/utils/core.js +68 -68
  53. package/dist/client/utils/error.js +19 -19
  54. package/dist/client/utils/fe-v4.js +114 -114
  55. package/dist/client/utils/version.js +85 -85
  56. package/package.json +6 -6
  57. package/templates/flp/sandbox.html +2 -3
  58. package/templates/flp/sandbox2.html +87 -0
  59. package/dist/client/flp/bootstrap.js +0 -77
@@ -53,9 +53,18 @@ export declare class FlpSandbox {
53
53
  * @param adp optional reference to the ADP tooling
54
54
  */
55
55
  init(manifest: Manifest, componentId?: string, resources?: Record<string, string>, adp?: AdpPreview): Promise<void>;
56
+ /**
57
+ * Get the configuration for the developer mode.
58
+ *
59
+ * @param ui5MajorVersion - the major version of UI5
60
+ * @returns the configuration for the developer mode
61
+ * @private
62
+ */
63
+ private getDeveloperModeConfig;
56
64
  /**
57
65
  * Generates the FLP sandbox for an editor.
58
66
  *
67
+ * @param req the request
59
68
  * @param rta runtime authoring configuration
60
69
  * @param editor editor configuration
61
70
  * @returns FLP sandbox html
@@ -78,6 +87,29 @@ export declare class FlpSandbox {
78
87
  * Add routes for html and scripts required for a local FLP.
79
88
  */
80
89
  private addStandardRoutes;
90
+ /**
91
+ * Read the UI5 version.
92
+ * In case of an error, the default UI5 version '1.121.0' is returned.
93
+ *
94
+ * @param protocol - the protocol that should be used to request the UI5 version ('http' or 'https')
95
+ * @param host - the host that should be used to request the UI5 version
96
+ * @param baseUrl - the base path of the request that should be added to the host
97
+ * @returns the template for the sandbox HTML file
98
+ * @private
99
+ */
100
+ private getUi5Version;
101
+ /**
102
+ * Read the sandbox template file based on the given UI5 version.
103
+ *
104
+ * @param ui5MajorVersion - the major version of UI5
105
+ * @returns the template for the sandbox HTML file
106
+ */
107
+ private getSandboxTemplate;
108
+ /**
109
+ * For UI5 version 1.71 and below, the asyncHints.requests need to be removed from the template configuration
110
+ * to load the changes in an Adaptation project.
111
+ */
112
+ private removeAsyncHintsRequests;
81
113
  /**
82
114
  * Try finding a locate-reuse-libs script in the project.
83
115
  *
package/dist/base/flp.js CHANGED
@@ -14,15 +14,6 @@ const feature_toggle_1 = require("@sap-ux/feature-toggle");
14
14
  const flex_1 = require("./flex");
15
15
  const test_1 = require("./test");
16
16
  const config_1 = require("./config");
17
- const DEVELOPER_MODE_CONFIG = new Map([
18
- // Run application in design time mode
19
- // Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
20
- ['xx-designMode', 'true'],
21
- // In design mode, the controller code will not be executed by default, which is not desired in our case, so we suppress the deactivation
22
- ['xx-suppressDeactivationOfControllerCode', 'true'],
23
- // Make sure that XML preprocessing results are correctly invalidated
24
- ['xx-viewCache', 'false']
25
- ]);
26
17
  const DEFAULT_LIVERELOAD_PORT = 35729;
27
18
  /**
28
19
  * Class handling preview of a sandbox FLP.
@@ -101,14 +92,46 @@ class FlpSandbox {
101
92
  this.logger.info(`Initialized for app ${id}`);
102
93
  this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
103
94
  }
95
+ /**
96
+ * Get the configuration for the developer mode.
97
+ *
98
+ * @param ui5MajorVersion - the major version of UI5
99
+ * @returns the configuration for the developer mode
100
+ * @private
101
+ */
102
+ getDeveloperModeConfig(ui5MajorVersion) {
103
+ if (ui5MajorVersion < 2) {
104
+ return new Map([
105
+ // Run application in design time mode
106
+ // Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
107
+ ['xx-designMode', 'true'],
108
+ // In design mode, the controller code will not be executed by default, which is not desired in our case, so we suppress the deactivation
109
+ ['xx-suppressDeactivationOfControllerCode', 'true'],
110
+ // Make sure that XML preprocessing results are correctly invalidated
111
+ ['xx-viewCache', 'false']
112
+ ]);
113
+ }
114
+ else {
115
+ return new Map([
116
+ // Run application in design time mode
117
+ // Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
118
+ ['xx-design-mode', 'true'],
119
+ // In design mode, the controller code will not be executed by default, which is not desired in our case, so we suppress the deactivation
120
+ ['xx-suppress-deactivation-of-controller-code', 'true'],
121
+ // Make sure that XML preprocessing results are correctly invalidated
122
+ ['xx-view-cache', 'false']
123
+ ]);
124
+ }
125
+ }
104
126
  /**
105
127
  * Generates the FLP sandbox for an editor.
106
128
  *
129
+ * @param req the request
107
130
  * @param rta runtime authoring configuration
108
131
  * @param editor editor configuration
109
132
  * @returns FLP sandbox html
110
133
  */
111
- async generateSandboxForEditor(rta, editor) {
134
+ async generateSandboxForEditor(req, rta, editor) {
112
135
  const defaultGenerator = editor.developerMode
113
136
  ? '@sap-ux/control-property-editor'
114
137
  : '@sap-ux/preview-middleware';
@@ -128,11 +151,14 @@ class FlpSandbox {
128
151
  pluginScript: editor.pluginScript
129
152
  };
130
153
  config.features = feature_toggle_1.FeatureToggleAccess.getAllFeatureToggles();
154
+ const ui5Version = await this.getUi5Version(req.protocol, req.headers.host, req['ui5-patched-router']?.baseUrl);
131
155
  if (editor.developerMode === true) {
132
- config.ui5.bootstrapOptions = serializeUi5Configuration(DEVELOPER_MODE_CONFIG);
156
+ config.ui5.bootstrapOptions = serializeUi5Configuration(this.getDeveloperModeConfig(ui5Version.major));
157
+ }
158
+ if (ui5Version.major === 1 && ui5Version.minor <= 71) {
159
+ this.removeAsyncHintsRequests();
133
160
  }
134
- const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandbox.html'), 'utf-8');
135
- return (0, ejs_1.render)(template, config);
161
+ return (0, ejs_1.render)(this.getSandboxTemplate(ui5Version.major), config);
136
162
  }
137
163
  /**
138
164
  * Sets application dependencies in the template configuration.
@@ -198,7 +224,7 @@ class FlpSandbox {
198
224
  res.redirect(302, `${previewUrl}?${new URLSearchParams(params)}`);
199
225
  return;
200
226
  }
201
- const html = (await this.generateSandboxForEditor(rta, editor)).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
227
+ const html = (await this.generateSandboxForEditor(req, rta, editor)).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
202
228
  this.sendResponse(res, 'text/html', 200, html);
203
229
  });
204
230
  }
@@ -209,8 +235,8 @@ class FlpSandbox {
209
235
  addStandardRoutes() {
210
236
  // register static client sources
211
237
  this.router.use(config_1.PREVIEW_URL.client.path, (0, express_1.static)(config_1.PREVIEW_URL.client.local));
212
- // add route for the sandbox.html
213
- this.router.get(this.config.path, (async (_req, res, next) => {
238
+ // add route for the sandbox html
239
+ this.router.get(this.config.path, (async (req, res, next) => {
214
240
  // inform the user if a html file exists on the filesystem
215
241
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
216
242
  const file = await this.project.byPath(this.config.path);
@@ -219,12 +245,69 @@ class FlpSandbox {
219
245
  next();
220
246
  }
221
247
  else {
222
- const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandbox.html'), 'utf-8');
223
- const html = (0, ejs_1.render)(template, this.templateConfig);
248
+ const ui5Version = await this.getUi5Version(req.protocol, req.headers.host, req['ui5-patched-router']?.baseUrl);
249
+ const html = (0, ejs_1.render)(this.getSandboxTemplate(ui5Version.major), this.templateConfig);
224
250
  this.sendResponse(res, 'text/html', 200, html);
225
251
  }
226
252
  }));
227
253
  }
254
+ /**
255
+ * Read the UI5 version.
256
+ * In case of an error, the default UI5 version '1.121.0' is returned.
257
+ *
258
+ * @param protocol - the protocol that should be used to request the UI5 version ('http' or 'https')
259
+ * @param host - the host that should be used to request the UI5 version
260
+ * @param baseUrl - the base path of the request that should be added to the host
261
+ * @returns the template for the sandbox HTML file
262
+ * @private
263
+ */
264
+ async getUi5Version(protocol, host, baseUrl = '') {
265
+ let version;
266
+ if (!host) {
267
+ this.logger.error('Unable to fetch UI5 version: No host found in request header.');
268
+ }
269
+ else {
270
+ try {
271
+ const versionUrl = `${protocol}://${host}${baseUrl}/resources/sap-ui-version.json`;
272
+ const responseJson = (await fetch(versionUrl).then((res) => res.json()));
273
+ version = responseJson?.libraries?.find((lib) => lib.name === 'sap.ui.core')?.version;
274
+ }
275
+ catch (error) {
276
+ this.logger.error(error);
277
+ }
278
+ }
279
+ if (!version) {
280
+ this.logger.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
281
+ version = '1.121.0';
282
+ }
283
+ const [major, minor] = version.split('.').map((versionPart) => parseInt(versionPart, 10));
284
+ return {
285
+ major,
286
+ minor
287
+ };
288
+ }
289
+ /**
290
+ * Read the sandbox template file based on the given UI5 version.
291
+ *
292
+ * @param ui5MajorVersion - the major version of UI5
293
+ * @returns the template for the sandbox HTML file
294
+ */
295
+ getSandboxTemplate(ui5MajorVersion) {
296
+ this.logger.info(`Using sandbox template for UI5 major version ${ui5MajorVersion}.`);
297
+ return (0, fs_1.readFileSync)((0, path_1.join)(__dirname, `../../templates/flp/sandbox${ui5MajorVersion === 1 ? '' : ui5MajorVersion}.html`), 'utf-8');
298
+ }
299
+ /**
300
+ * For UI5 version 1.71 and below, the asyncHints.requests need to be removed from the template configuration
301
+ * to load the changes in an Adaptation project.
302
+ */
303
+ removeAsyncHintsRequests() {
304
+ for (const app in this.templateConfig.apps) {
305
+ const appDependencies = this.templateConfig.apps[app].applicationDependencies;
306
+ if (appDependencies?.asyncHints.requests) {
307
+ appDependencies.asyncHints.requests = [];
308
+ }
309
+ }
310
+ }
228
311
  /**
229
312
  * Try finding a locate-reuse-libs script in the project.
230
313
  *
@@ -1,144 +1,144 @@
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["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
13
- return ApiEndpoints;
14
- }(ApiEndpoints || {});
15
- var RequestMethod = /*#__PURE__*/function (RequestMethod) {
16
- RequestMethod["GET"] = "GET";
17
- RequestMethod["PUT"] = "PUT";
18
- RequestMethod["POST"] = "POST";
19
- RequestMethod["PATCH"] = "PATCH";
20
- RequestMethod["DELETE"] = "DELETE";
21
- return RequestMethod;
22
- }(RequestMethod || {});
23
- /**
24
- * Requests a given endpoint
25
- *
26
- * @param endpoint API Endpoint
27
- * @param method RequestMethod
28
- * @param data Data to be sent to the server
29
- * @returns Data from the server request
30
- */
31
- async function request(endpoint, method, data) {
32
- const config = {
33
- method,
34
- body: JSON.stringify(data),
35
- headers: {
36
- 'content-type': 'application/json'
37
- }
38
- };
39
- try {
40
- const response = await fetch(endpoint, config);
41
- if (!response.ok) {
42
- const errorData = await response.json();
43
- const message = errorData?.message ?? '';
44
- throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
45
- }
46
- switch (method) {
47
- case RequestMethod.GET:
48
- return response.json();
49
- case RequestMethod.POST:
50
- /**
51
- * Since POST usually creates something
52
- * and returns nothing (or a message) we just parse the text from res.send(msg)
53
- */
54
- return response.text();
55
- default:
56
- return response.json();
57
- }
58
- } catch (e) {
59
- throw getError(e);
60
- }
61
- }
62
-
63
- /**
64
- * Retrieves all XML fragments from the project's workspace
65
- *
66
- * @returns Generic Promise<T>
67
- */
68
- async function getFragments() {
69
- return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
70
- }
71
-
72
- /**
73
- * Writes an XML fragment to the project's workspace
74
- *
75
- * @param data Data to be send to the server
76
- * @returns Generic Promise<T>
77
- */
78
- async function writeFragment(data) {
79
- return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
80
- }
81
-
82
- /**
83
- * Retrieves manifest.appdescr_variant from the project's workspace
84
- *
85
- * @returns Generic Promise<T>
86
- */
87
- async function getManifestAppdescr() {
88
- return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
89
- }
90
-
91
- /**
92
- * Retrieves all controller extensions from the project's workspace
93
- *
94
- * @returns Generic Promise<T>
95
- */
96
- async function readControllers() {
97
- return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
98
- }
99
-
100
- /**
101
- * Writes a Controller to the project's workspace
102
- *
103
- * @param data Data to be send to the server
104
- * @returns Generic Promise<T>
105
- */
106
- async function writeController(data) {
107
- return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
108
- }
109
-
110
- /**
111
- * Checks for existing controller in the project's workspace
112
- *
113
- * @param controllerName Name of the controller
114
- * @returns {CodeExtResponse} Returns path to existing controller if found
115
- */
116
- async function getExistingController(controllerName) {
117
- return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
118
- }
119
-
120
- /**
121
- * Writes a change object to the project's workspace
122
- *
123
- * @param data Data to be send to the server
124
- * @returns Generic Promise<T>
125
- */
126
- async function writeChange(data) {
127
- return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
128
- }
129
- var __exports = {
130
- __esModule: true
131
- };
132
- __exports.ApiEndpoints = ApiEndpoints;
133
- __exports.RequestMethod = RequestMethod;
134
- __exports.request = request;
135
- __exports.getFragments = getFragments;
136
- __exports.writeFragment = writeFragment;
137
- __exports.getManifestAppdescr = getManifestAppdescr;
138
- __exports.readControllers = readControllers;
139
- __exports.writeController = writeController;
140
- __exports.getExistingController = getExistingController;
141
- __exports.writeChange = writeChange;
142
- 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["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
13
+ return ApiEndpoints;
14
+ }(ApiEndpoints || {});
15
+ var RequestMethod = /*#__PURE__*/function (RequestMethod) {
16
+ RequestMethod["GET"] = "GET";
17
+ RequestMethod["PUT"] = "PUT";
18
+ RequestMethod["POST"] = "POST";
19
+ RequestMethod["PATCH"] = "PATCH";
20
+ RequestMethod["DELETE"] = "DELETE";
21
+ return RequestMethod;
22
+ }(RequestMethod || {});
23
+ /**
24
+ * Requests a given endpoint
25
+ *
26
+ * @param endpoint API Endpoint
27
+ * @param method RequestMethod
28
+ * @param data Data to be sent to the server
29
+ * @returns Data from the server request
30
+ */
31
+ async function request(endpoint, method, data) {
32
+ const config = {
33
+ method,
34
+ body: JSON.stringify(data),
35
+ headers: {
36
+ 'content-type': 'application/json'
37
+ }
38
+ };
39
+ try {
40
+ const response = await fetch(endpoint, config);
41
+ if (!response.ok) {
42
+ const errorData = await response.json();
43
+ const message = errorData?.message ?? '';
44
+ throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
45
+ }
46
+ switch (method) {
47
+ case RequestMethod.GET:
48
+ return response.json();
49
+ case RequestMethod.POST:
50
+ /**
51
+ * Since POST usually creates something
52
+ * and returns nothing (or a message) we just parse the text from res.send(msg)
53
+ */
54
+ return response.text();
55
+ default:
56
+ return response.json();
57
+ }
58
+ } catch (e) {
59
+ throw getError(e);
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Retrieves all XML fragments from the project's workspace
65
+ *
66
+ * @returns Generic Promise<T>
67
+ */
68
+ async function getFragments() {
69
+ return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
70
+ }
71
+
72
+ /**
73
+ * Writes an XML fragment to the project's workspace
74
+ *
75
+ * @param data Data to be send to the server
76
+ * @returns Generic Promise<T>
77
+ */
78
+ async function writeFragment(data) {
79
+ return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
80
+ }
81
+
82
+ /**
83
+ * Retrieves manifest.appdescr_variant from the project's workspace
84
+ *
85
+ * @returns Generic Promise<T>
86
+ */
87
+ async function getManifestAppdescr() {
88
+ return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
89
+ }
90
+
91
+ /**
92
+ * Retrieves all controller extensions from the project's workspace
93
+ *
94
+ * @returns Generic Promise<T>
95
+ */
96
+ async function readControllers() {
97
+ return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
98
+ }
99
+
100
+ /**
101
+ * Writes a Controller to the project's workspace
102
+ *
103
+ * @param data Data to be send to the server
104
+ * @returns Generic Promise<T>
105
+ */
106
+ async function writeController(data) {
107
+ return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
108
+ }
109
+
110
+ /**
111
+ * Checks for existing controller in the project's workspace
112
+ *
113
+ * @param controllerName Name of the controller
114
+ * @returns {CodeExtResponse} Returns path to existing controller if found
115
+ */
116
+ async function getExistingController(controllerName) {
117
+ return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
118
+ }
119
+
120
+ /**
121
+ * Writes a change object to the project's workspace
122
+ *
123
+ * @param data Data to be send to the server
124
+ * @returns Generic Promise<T>
125
+ */
126
+ async function writeChange(data) {
127
+ return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
128
+ }
129
+ var __exports = {
130
+ __esModule: true
131
+ };
132
+ __exports.ApiEndpoints = ApiEndpoints;
133
+ __exports.RequestMethod = RequestMethod;
134
+ __exports.request = request;
135
+ __exports.getFragments = getFragments;
136
+ __exports.writeFragment = writeFragment;
137
+ __exports.getManifestAppdescr = getManifestAppdescr;
138
+ __exports.readControllers = readControllers;
139
+ __exports.writeController = writeController;
140
+ __exports.getExistingController = getExistingController;
141
+ __exports.writeChange = writeChange;
142
+ return __exports;
143
143
  });
144
144
  //# sourceMappingURL=api-handler.js.map
@@ -1,77 +1,77 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../utils/error"], function (MessageToast, CommandFactory, ___utils_error) {
4
- "use strict";
5
-
6
- const getError = ___utils_error["getError"];
7
- /**
8
- * Class responsible for handling rta calls
9
- */
10
- class CommandExecutor {
11
- /**
12
- *
13
- * @param rta Runtime Authoring
14
- */
15
- constructor(rta) {
16
- this.rta = rta;
17
- }
18
-
19
- /**
20
- * Generates command based on given values
21
- *
22
- * @param runtimeControl Managed object
23
- * @param commandName Command name
24
- * @param modifiedValue Modified value/s
25
- * @param designMetadata Design time metadata
26
- * @param flexSettings Additional flex settings
27
- */
28
- async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
29
- try {
30
- return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
31
- } catch (e) {
32
- const error = getError(e);
33
- const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
34
- error.message = msgToastErrorMsg;
35
- MessageToast.show(msgToastErrorMsg);
36
- throw error;
37
- }
38
- }
39
-
40
- /**
41
- * Creates composite command without nested commands
42
- *
43
- * @param runtimeControl Managed object
44
- */
45
- async createCompositeCommand(runtimeControl) {
46
- try {
47
- return await CommandFactory.getCommandFor(runtimeControl, 'composite');
48
- } catch (e) {
49
- const error = getError(e);
50
- const msgToastErrorMsg = `Could not get composite command'. ${error.message}`;
51
- error.message = msgToastErrorMsg;
52
- MessageToast.show(msgToastErrorMsg);
53
- throw error;
54
- }
55
- }
56
-
57
- /**
58
- * Pushed and executes the provided command
59
- *
60
- * @param command Command
61
- */
62
- async pushAndExecuteCommand(command) {
63
- try {
64
- /**
65
- * The change will have pending state and will only be saved to the workspace when the user clicks save icon
66
- */
67
- await this.rta.getCommandStack().pushAndExecute(command);
68
- } catch (e) {
69
- const error = getError(e);
70
- MessageToast.show(error.message);
71
- throw error;
72
- }
73
- }
74
- }
75
- return CommandExecutor;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../utils/error"], function (MessageToast, CommandFactory, ___utils_error) {
4
+ "use strict";
5
+
6
+ const getError = ___utils_error["getError"];
7
+ /**
8
+ * Class responsible for handling rta calls
9
+ */
10
+ class CommandExecutor {
11
+ /**
12
+ *
13
+ * @param rta Runtime Authoring
14
+ */
15
+ constructor(rta) {
16
+ this.rta = rta;
17
+ }
18
+
19
+ /**
20
+ * Generates command based on given values
21
+ *
22
+ * @param runtimeControl Managed object
23
+ * @param commandName Command name
24
+ * @param modifiedValue Modified value/s
25
+ * @param designMetadata Design time metadata
26
+ * @param flexSettings Additional flex settings
27
+ */
28
+ async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
29
+ try {
30
+ return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
31
+ } catch (e) {
32
+ const error = getError(e);
33
+ const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
34
+ error.message = msgToastErrorMsg;
35
+ MessageToast.show(msgToastErrorMsg);
36
+ throw error;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Creates composite command without nested commands
42
+ *
43
+ * @param runtimeControl Managed object
44
+ */
45
+ async createCompositeCommand(runtimeControl) {
46
+ try {
47
+ return await CommandFactory.getCommandFor(runtimeControl, 'composite');
48
+ } catch (e) {
49
+ const error = getError(e);
50
+ const msgToastErrorMsg = `Could not get composite command'. ${error.message}`;
51
+ error.message = msgToastErrorMsg;
52
+ MessageToast.show(msgToastErrorMsg);
53
+ throw error;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Pushed and executes the provided command
59
+ *
60
+ * @param command Command
61
+ */
62
+ async pushAndExecuteCommand(command) {
63
+ try {
64
+ /**
65
+ * The change will have pending state and will only be saved to the workspace when the user clicks save icon
66
+ */
67
+ await this.rta.getCommandStack().pushAndExecute(command);
68
+ } catch (e) {
69
+ const error = getError(e);
70
+ MessageToast.show(error.message);
71
+ throw error;
72
+ }
73
+ }
74
+ }
75
+ return CommandExecutor;
76
76
  });
77
77
  //# sourceMappingURL=command-executor.js.map