@sap-ux/preview-middleware 0.19.29 → 0.19.31
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/flp.d.ts +2 -2
- package/dist/base/flp.js +3 -3
- package/dist/client/adp/add-fragment.js +48 -0
- package/dist/client/adp/add-fragment.ts +51 -0
- package/dist/client/adp/api-handler.js +155 -153
- package/dist/client/adp/api-handler.ts +2 -2
- package/dist/client/adp/command-executor.js +75 -75
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +26 -86
- package/dist/client/adp/controllers/AddFragment.controller.ts +29 -113
- package/dist/client/adp/controllers/ControllerExtension.controller.js +210 -210
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
- package/dist/client/adp/dialog-factory.js +135 -135
- package/dist/client/adp/dialog-factory.ts +21 -13
- package/dist/client/adp/extension-point.js +3 -3
- package/dist/client/adp/extension-point.ts +3 -3
- package/dist/client/adp/init-dialogs.js +163 -138
- package/dist/client/adp/init-dialogs.ts +13 -8
- package/dist/client/adp/init.js +2 -0
- package/dist/client/adp/init.ts +5 -0
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +60 -60
- package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
- package/dist/client/adp/quick-actions/common/utils.js +18 -18
- package/dist/client/adp/quick-actions/control-types.js +23 -23
- 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/add-new-subpage.js +81 -81
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
- 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 +107 -107
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
- 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 +59 -59
- 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 +77 -77
- package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
- 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 +56 -56
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
- 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 +60 -60
- package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
- package/dist/client/adp/quick-actions/load.js +44 -44
- package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
- package/dist/client/adp/utils.js +218 -218
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +77 -0
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +84 -0
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/service.js +5 -2
- package/dist/client/cpe/changes/service.ts +2 -0
- package/dist/client/cpe/changes/validator.js +39 -39
- package/dist/client/cpe/connector-service.js +2 -1
- package/dist/client/cpe/connector-service.ts +8 -4
- 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 +203 -203
- 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 +111 -111
- package/dist/client/flp/WorkspaceConnector.js +92 -86
- package/dist/client/flp/WorkspaceConnector.ts +10 -2
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +89 -83
- package/dist/client/flp/enableFakeConnector.ts +11 -2
- package/dist/client/flp/homepage/Component.js +14 -14
- package/dist/client/flp/initCdm.js +117 -117
- package/dist/client/flp/initConnectors.js +28 -28
- package/dist/client/flp/initRta.js +178 -178
- package/dist/client/i18n.js +56 -56
- package/dist/client/utils/additional-change-info.js +43 -0
- package/dist/client/utils/additional-change-info.ts +42 -0
- package/dist/client/utils/application.js +32 -32
- package/dist/client/utils/core.js +84 -84
- package/dist/client/utils/error.js +19 -19
- package/dist/client/utils/fe-v2.js +56 -56
- package/dist/client/utils/fe-v4.js +140 -140
- package/dist/client/utils/version.js +104 -104
- package/package.json +4 -4
package/dist/base/flp.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Request, 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 { AdpPreview, type AdpPreviewConfig, type CommonChangeProperties, type OperationType } from '@sap-ux/adp-tooling';
|
|
7
|
+
import { AdpPreview, type AdpPreviewConfig, type CommonChangeProperties, type OperationType, type CommonAdditionalChangeInfoProperties } from '@sap-ux/adp-tooling';
|
|
8
8
|
import type { FlpConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
|
|
9
9
|
import { type TemplateConfig } from './config';
|
|
10
10
|
/**
|
|
@@ -21,7 +21,7 @@ export type EnhancedRequest = Request & {
|
|
|
21
21
|
baseUrl?: string;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
type OnChangeRequestHandler = (type: OperationType, change: CommonChangeProperties, fs: MemFsEditor, logger: Logger) => Promise<void>;
|
|
24
|
+
type OnChangeRequestHandler = (type: OperationType, change: CommonChangeProperties, fs: MemFsEditor, logger: Logger, extendedChange?: CommonAdditionalChangeInfoProperties) => Promise<void>;
|
|
25
25
|
/**
|
|
26
26
|
* Class handling preview of a sandbox FLP.
|
|
27
27
|
*/
|
package/dist/base/flp.js
CHANGED
|
@@ -464,11 +464,11 @@ class FlpSandbox {
|
|
|
464
464
|
async flexPostHandler(req, res) {
|
|
465
465
|
this.fs = this.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
466
466
|
try {
|
|
467
|
-
const
|
|
467
|
+
const body = req.body;
|
|
468
468
|
if (this.onChangeRequest) {
|
|
469
|
-
await this.onChangeRequest('write', change, this.fs, this.logger);
|
|
469
|
+
await this.onChangeRequest('write', body.change, this.fs, this.logger, body.additionalChangeInfo);
|
|
470
470
|
}
|
|
471
|
-
const { success, message } = (0, flex_1.writeChange)(change, this.utils.getProject().getSourcePath(), this.fs, this.logger);
|
|
471
|
+
const { success, message } = (0, flex_1.writeChange)(body.change, this.utils.getProject().getSourcePath(), this.fs, this.logger);
|
|
472
472
|
if (success) {
|
|
473
473
|
this.fs.commit(() => this.sendResponse(res, 'text/plain', 200, message ?? ''));
|
|
474
474
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/ui/rta/command/CommandFactory", "./utils", "./dialog-factory", "sap/ui/rta/plugin/AddXMLPlugin"], function (CommandFactory, ___utils, ___dialog_factory, AddXMLPlugin) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const createDeferred = ___utils["createDeferred"];
|
|
7
|
+
const DialogFactory = ___dialog_factory["DialogFactory"];
|
|
8
|
+
const DialogNames = ___dialog_factory["DialogNames"];
|
|
9
|
+
/**
|
|
10
|
+
* Initializes the AddXMLPlugin and includes it in the Runtime Authoring (RTA) plugins.
|
|
11
|
+
*
|
|
12
|
+
* @param rta Runtime Authoring instance
|
|
13
|
+
*/
|
|
14
|
+
function initAddXMLPlugin(rta) {
|
|
15
|
+
const flexSettings = rta.getFlexSettings();
|
|
16
|
+
const commandFactory = new CommandFactory({
|
|
17
|
+
flexSettings
|
|
18
|
+
});
|
|
19
|
+
const plugin = new AddXMLPlugin({
|
|
20
|
+
commandFactory,
|
|
21
|
+
fragmentHandler: async overlay => await handleFragmentCreation(rta, overlay)
|
|
22
|
+
});
|
|
23
|
+
const plugins = rta.getPlugins();
|
|
24
|
+
plugins.addXMLPlugin = plugin;
|
|
25
|
+
rta.setPlugins(plugins);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Handles the creation of a fragment by opening a dialog and resolving the deferred data.
|
|
30
|
+
*
|
|
31
|
+
* @param rta Runtime Authoring instance
|
|
32
|
+
* @param overlay UI5 Element overlay
|
|
33
|
+
* @returns A promise that resolves with DeferredXmlFragmentData
|
|
34
|
+
*/
|
|
35
|
+
async function handleFragmentCreation(rta, overlay) {
|
|
36
|
+
const deferred = createDeferred();
|
|
37
|
+
await DialogFactory.createDialog(overlay, rta, DialogNames.ADD_FRAGMENT, {
|
|
38
|
+
deferred
|
|
39
|
+
});
|
|
40
|
+
return deferred.promise;
|
|
41
|
+
}
|
|
42
|
+
var __exports = {
|
|
43
|
+
__esModule: true
|
|
44
|
+
};
|
|
45
|
+
__exports.initAddXMLPlugin = initAddXMLPlugin;
|
|
46
|
+
return __exports;
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=add-fragment.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
2
|
+
import type UI5Element from 'sap/ui/core/Element';
|
|
3
|
+
import CommandFactory from 'sap/ui/rta/command/CommandFactory';
|
|
4
|
+
import { Deferred, createDeferred } from './utils';
|
|
5
|
+
import { DialogFactory, DialogNames } from './dialog-factory';
|
|
6
|
+
import AddXMLPlugin from 'sap/ui/rta/plugin/AddXMLPlugin';
|
|
7
|
+
|
|
8
|
+
export interface AddFragmentData {
|
|
9
|
+
deferred: Deferred<DeferredXmlFragmentData>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type DeferredXmlFragmentData = {
|
|
13
|
+
fragment: string;
|
|
14
|
+
fragmentPath: string;
|
|
15
|
+
targetAggregation: string;
|
|
16
|
+
index: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initializes the AddXMLPlugin and includes it in the Runtime Authoring (RTA) plugins.
|
|
21
|
+
*
|
|
22
|
+
* @param rta Runtime Authoring instance
|
|
23
|
+
*/
|
|
24
|
+
export function initAddXMLPlugin(rta: RuntimeAuthoring): void {
|
|
25
|
+
const flexSettings = rta.getFlexSettings();
|
|
26
|
+
const commandFactory = new CommandFactory({ flexSettings });
|
|
27
|
+
|
|
28
|
+
const plugin = new AddXMLPlugin({
|
|
29
|
+
commandFactory,
|
|
30
|
+
fragmentHandler: async (overlay: UI5Element) => await handleFragmentCreation(rta, overlay)
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const plugins = rta.getPlugins();
|
|
34
|
+
plugins.addXMLPlugin = plugin;
|
|
35
|
+
rta.setPlugins(plugins);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Handles the creation of a fragment by opening a dialog and resolving the deferred data.
|
|
40
|
+
*
|
|
41
|
+
* @param rta Runtime Authoring instance
|
|
42
|
+
* @param overlay UI5 Element overlay
|
|
43
|
+
* @returns A promise that resolves with DeferredXmlFragmentData
|
|
44
|
+
*/
|
|
45
|
+
async function handleFragmentCreation(rta: RuntimeAuthoring, overlay: UI5Element): Promise<DeferredXmlFragmentData> {
|
|
46
|
+
const deferred = createDeferred<DeferredXmlFragmentData>();
|
|
47
|
+
|
|
48
|
+
await DialogFactory.createDialog(overlay, rta, DialogNames.ADD_FRAGMENT, { deferred });
|
|
49
|
+
|
|
50
|
+
return deferred.promise;
|
|
51
|
+
}
|
|
@@ -1,155 +1,157 @@
|
|
|
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,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
__exports.
|
|
145
|
-
__exports.
|
|
146
|
-
__exports.
|
|
147
|
-
__exports.
|
|
148
|
-
__exports.
|
|
149
|
-
__exports.
|
|
150
|
-
__exports.
|
|
151
|
-
__exports.
|
|
152
|
-
__exports.
|
|
153
|
-
|
|
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, {
|
|
138
|
+
change: data
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var __exports = {
|
|
142
|
+
__esModule: true
|
|
143
|
+
};
|
|
144
|
+
__exports.ApiEndpoints = ApiEndpoints;
|
|
145
|
+
__exports.RequestMethod = RequestMethod;
|
|
146
|
+
__exports.request = request;
|
|
147
|
+
__exports.getFragments = getFragments;
|
|
148
|
+
__exports.writeFragment = writeFragment;
|
|
149
|
+
__exports.getManifestAppdescr = getManifestAppdescr;
|
|
150
|
+
__exports.readControllers = readControllers;
|
|
151
|
+
__exports.writeController = writeController;
|
|
152
|
+
__exports.getDataSourceAnnotationFileMap = getDataSourceAnnotationFileMap;
|
|
153
|
+
__exports.getExistingController = getExistingController;
|
|
154
|
+
__exports.writeChange = writeChange;
|
|
155
|
+
return __exports;
|
|
154
156
|
});
|
|
155
157
|
//# sourceMappingURL=api-handler.js.map
|
|
@@ -42,7 +42,7 @@ export interface AnnotationFileDetails {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface AnnotationDataSourceMap {
|
|
45
|
-
[key: string]: { serviceUrl: string; annotationDetails: AnnotationFileDetails
|
|
45
|
+
[key: string]: { serviceUrl: string; annotationDetails: AnnotationFileDetails; metadataReadErrorMsg: string };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface AnnotationDataSourceResponse {
|
|
@@ -181,5 +181,5 @@ export async function getExistingController(controllerName: string): Promise<Cod
|
|
|
181
181
|
* @returns Generic Promise<T>
|
|
182
182
|
*/
|
|
183
183
|
export async function writeChange<T>(data: T): Promise<T> {
|
|
184
|
-
return request<T>(ApiEndpoints.CHANGES, RequestMethod.POST, data);
|
|
184
|
+
return request<T>(ApiEndpoints.CHANGES, RequestMethod.POST, { change: data });
|
|
185
185
|
}
|
|
@@ -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
|