@sap-ux/preview-middleware 0.6.2 → 0.7.0

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 (41) hide show
  1. package/dist/base/flp.d.ts +1 -0
  2. package/dist/base/flp.js +49 -8
  3. package/dist/client/adp/controllers/AddFragment.controller.js +1 -27
  4. package/dist/client/adp/controllers/AddFragment.controller.ts +2 -24
  5. package/dist/client/cpe/changes/flex-change.js +46 -0
  6. package/dist/client/cpe/changes/flex-change.ts +49 -0
  7. package/dist/client/cpe/changes/index.js +12 -0
  8. package/dist/client/cpe/changes/index.ts +1 -0
  9. package/dist/client/cpe/changes/service.js +164 -0
  10. package/dist/client/cpe/changes/service.ts +264 -0
  11. package/dist/client/cpe/control-data.js +201 -0
  12. package/dist/client/cpe/control-data.ts +304 -0
  13. package/dist/client/cpe/documentation.js +166 -0
  14. package/dist/client/cpe/documentation.ts +166 -0
  15. package/dist/client/cpe/facade.js +95 -0
  16. package/dist/client/cpe/facade.ts +95 -0
  17. package/dist/client/cpe/init.js +62 -12
  18. package/dist/client/cpe/init.ts +70 -5
  19. package/dist/client/cpe/logger.js +32 -0
  20. package/dist/client/cpe/logger.ts +26 -0
  21. package/dist/client/cpe/outline/index.js +26 -0
  22. package/dist/client/cpe/outline/index.ts +34 -0
  23. package/dist/client/cpe/outline/nodes.js +58 -0
  24. package/dist/client/cpe/outline/nodes.ts +52 -0
  25. package/dist/client/cpe/outline/utils.js +38 -0
  26. package/dist/client/cpe/outline/utils.ts +29 -0
  27. package/dist/client/cpe/selection.js +169 -0
  28. package/dist/client/cpe/selection.ts +237 -0
  29. package/dist/client/cpe/types.js +6 -0
  30. package/dist/client/cpe/types.ts +53 -0
  31. package/dist/client/cpe/utils.js +50 -0
  32. package/dist/client/cpe/utils.ts +62 -0
  33. package/dist/client/flp/WorkspaceConnector.js +65 -0
  34. package/dist/client/flp/WorkspaceConnector.ts +66 -0
  35. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +272 -0
  36. package/dist/types/index.d.ts +4 -0
  37. package/dist/ui5/middleware.js +20 -1
  38. package/package.json +4 -3
  39. package/templates/flp/editor.html +11 -15
  40. package/templates/flp/sandbox.html +2 -1
  41. package/templates/flp/workspaceConnector.js +0 -76
@@ -0,0 +1,66 @@
1
+ import merge from 'sap/base/util/merge';
2
+ import ObjectStorageConnector from 'sap/ui/fl/write/api/connectors/ObjectStorageConnector';
3
+ import Layer from 'sap/ui/fl/Layer';
4
+ import VersionInfo from 'sap/ui/VersionInfo';
5
+
6
+ const path = '/preview/api/changes';
7
+
8
+ const connector = merge({}, ObjectStorageConnector, {
9
+ layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
10
+ storage: {
11
+ _itemsStoredAsObjects: true,
12
+ setItem: function (_key: string, change: unknown) {
13
+ return fetch(path, {
14
+ method: 'POST',
15
+ body: JSON.stringify(change, null, 2),
16
+ headers: {
17
+ 'content-type': 'application/json'
18
+ }
19
+ });
20
+ },
21
+ removeItem: function (key: string) {
22
+ return fetch(path, {
23
+ method: 'DELETE',
24
+ body: JSON.stringify({ fileName: key }),
25
+ headers: {
26
+ 'content-type': 'application/json'
27
+ }
28
+ });
29
+ },
30
+ clear: function () {
31
+ // not implemented
32
+ },
33
+ getItem: function (_key: string) {
34
+ // not implemented
35
+ },
36
+ getItems: async function () {
37
+ const response = await fetch(path, {
38
+ method: 'GET',
39
+ headers: {
40
+ 'content-type': 'application/json'
41
+ }
42
+ });
43
+ const changes = await response.json();
44
+ return changes;
45
+ }
46
+ },
47
+ loadFeatures: async function () {
48
+ const features = await ObjectStorageConnector.loadFeatures();
49
+
50
+ const ui5Version = (await VersionInfo.load()) as { version: string };
51
+ const [majorVersion, minorVersion] = ui5Version.version.split('.').map((v: string) => parseInt(v, 10));
52
+ features.isVariantAdaptationEnabled = majorVersion >= 1 && minorVersion >= 90;
53
+
54
+ const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
55
+ if (bootstrapConfig) {
56
+ const settings = bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings');
57
+ if (settings && JSON.parse(settings).developerMode) {
58
+ features.isVariantAdaptationEnabled = false;
59
+ }
60
+ }
61
+
62
+ return features;
63
+ }
64
+ }) as typeof ObjectStorageConnector;
65
+
66
+ export default connector;
@@ -0,0 +1,272 @@
1
+ sap.ui.define((function () { 'use strict';
2
+
3
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
+
5
+ var dist = {};
6
+
7
+ var api = {};
8
+
9
+ (function (exports) {
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
12
+ exports.BOOLEAN_VALUE_TYPE = 'boolean';
13
+ exports.INTEGER_VALUE_TYPE = 'integer';
14
+ exports.FLOAT_VALUE_TYPE = 'float';
15
+ exports.STRING_VALUE_TYPE = 'string';
16
+ exports.INPUT_EDITOR_TYPE = 'input';
17
+ exports.DROPDOWN_EDITOR_TYPE = 'dropdown';
18
+ exports.CHECKBOX_EDITOR_TYPE = 'checkbox';
19
+ /**
20
+ * Create matcher.
21
+ *
22
+ * @param type action type
23
+ * @returns (value: { type: unknown } | undefined) => value is Y
24
+ */
25
+ function createMatcher(type) {
26
+ return function match(value) {
27
+ return (value === null || value === void 0 ? void 0 : value.type) === type;
28
+ };
29
+ }
30
+ /**
31
+ * Create action factory.
32
+ *
33
+ * @param prefix to determine ext action
34
+ * @returns Function
35
+ */
36
+ function createActionFactory(prefix) {
37
+ return function createAction(name) {
38
+ const actionType = [prefix, name].join(' ');
39
+ /**
40
+ *
41
+ * @param payload action payload
42
+ * @returns PayloadAction<typeof actionType, T>
43
+ */
44
+ function action(payload) {
45
+ return {
46
+ type: actionType,
47
+ payload
48
+ };
49
+ }
50
+ action.type = actionType;
51
+ action.match = createMatcher(actionType);
52
+ return action;
53
+ };
54
+ }
55
+ exports.EXTERNAL_ACTION_PREFIX = '[ext]';
56
+ const createExternalAction = createActionFactory(exports.EXTERNAL_ACTION_PREFIX);
57
+ exports.iconsLoaded = createExternalAction('icons-loaded');
58
+ exports.controlSelected = createExternalAction('control-selected');
59
+ exports.selectControl = createExternalAction('select-control');
60
+ exports.deletePropertyChanges = createExternalAction('delete-property-changes');
61
+ exports.outlineChanged = createExternalAction('outline-changed');
62
+ exports.changeProperty = createExternalAction('change-property');
63
+ exports.propertyChanged = createExternalAction('property-changed');
64
+ exports.propertyChangeFailed = createExternalAction('change-property-failed');
65
+ exports.changeStackModified = createExternalAction('change-stack-modified');
66
+
67
+ } (api));
68
+
69
+ var debounce$1 = {};
70
+
71
+ Object.defineProperty(debounce$1, "__esModule", { value: true });
72
+ debounce$1.debounce = void 0;
73
+ /**
74
+ * Returns a function which calls the callback function only after the specified idle time
75
+ * Works similar to the Debounce operator from rxjs https://reactivex.io/documentation/operators/debounce.html link.
76
+ *
77
+ * @param callback Function to execute
78
+ * @param delay Idle period in milliseconds after which the callback will be executed
79
+ * @returns A wrapper function that should be called to invoke the callback function after delay
80
+ */
81
+ function debounce(callback, delay) {
82
+ let timerId;
83
+ return (...args) => {
84
+ clearTimeout(timerId);
85
+ timerId = setTimeout(() => {
86
+ callback(...args);
87
+ }, delay);
88
+ };
89
+ }
90
+ debounce$1.debounce = debounce;
91
+
92
+ var postMessage = {};
93
+
94
+ Object.defineProperty(postMessage, "__esModule", { value: true });
95
+ postMessage.startPostMessageCommunication = void 0;
96
+ const POST_MESSAGE_ACTION_TYPE = 'post-message-action';
97
+ /**
98
+ * Check if data isPostMessageAction.
99
+ *
100
+ * @param data - post message action
101
+ * @returns data is PostMessageAction<T>
102
+ */
103
+ function isPostMessageAction(data) {
104
+ return (data === null || data === void 0 ? void 0 : data.type) === POST_MESSAGE_ACTION_TYPE && typeof (data === null || data === void 0 ? void 0 : data.action) === 'object';
105
+ }
106
+ /**
107
+ * Method to start post message communication.
108
+ *
109
+ * @param target target window
110
+ * @param onActionHandler action handler
111
+ * @param logger to log info, default: browser console.
112
+ * @returns PostMessageCommunication<T>
113
+ */
114
+ function startPostMessageCommunication(target, onActionHandler, logger = console) {
115
+ /**
116
+ * Returns target windows or undefined.
117
+ *
118
+ * @returns Window | undefined
119
+ */
120
+ function getTarget() {
121
+ if (typeof target === 'function') {
122
+ return target();
123
+ }
124
+ return target;
125
+ }
126
+ /**
127
+ * Invoke action on post message.
128
+ *
129
+ * @param event event
130
+ */
131
+ function postMessageListener(event) {
132
+ const target = getTarget();
133
+ if (!target || event.origin !== target.origin || event.source !== target) {
134
+ // Ignore messages from unknown sources
135
+ return;
136
+ }
137
+ if (isPostMessageAction(event.data)) {
138
+ onActionHandler(event.data.action).catch((error) => logger.error(error));
139
+ }
140
+ else {
141
+ logger.warn(`Unknown message received ${event.data}`);
142
+ }
143
+ }
144
+ function dispose() {
145
+ window.removeEventListener('message', postMessageListener);
146
+ }
147
+ /**
148
+ * Post message to a give window.
149
+ *
150
+ * @param action action payload
151
+ */
152
+ function sendAction(action) {
153
+ const target = getTarget();
154
+ if (!target) {
155
+ return;
156
+ }
157
+ const message = {
158
+ type: POST_MESSAGE_ACTION_TYPE,
159
+ action
160
+ };
161
+ target.postMessage(message, target.origin);
162
+ }
163
+ window.addEventListener('message', postMessageListener);
164
+ return {
165
+ dispose,
166
+ sendAction
167
+ };
168
+ }
169
+ postMessage.startPostMessageCommunication = startPostMessageCommunication;
170
+
171
+ var telemetry = {};
172
+
173
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
174
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
175
+ return new (P || (P = Promise))(function (resolve, reject) {
176
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
177
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
178
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
179
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
180
+ });
181
+ };
182
+ Object.defineProperty(telemetry, "__esModule", { value: true });
183
+ telemetry.reportTelemetry = telemetry.disableTelemetry = telemetry.enableTelemetry = void 0;
184
+ let enabled = false;
185
+ function enableTelemetry() {
186
+ enabled = true;
187
+ }
188
+ telemetry.enableTelemetry = enableTelemetry;
189
+ function disableTelemetry() {
190
+ enabled = false;
191
+ }
192
+ telemetry.disableTelemetry = disableTelemetry;
193
+ /**
194
+ * Reports telemetry data from Control Property Editor.
195
+ *
196
+ * @param data The TelemetryData object, that needs to be reported
197
+ * @returns {Promise<void>}
198
+ */
199
+ function reportTelemetry(data) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ try {
202
+ if (enabled) {
203
+ const requestOptions = {
204
+ method: 'POST',
205
+ headers: {
206
+ Accept: 'application/json',
207
+ 'Content-Type': 'application/json'
208
+ },
209
+ body: JSON.stringify(data)
210
+ };
211
+ yield fetch('/preview/api/telemetry', requestOptions);
212
+ }
213
+ }
214
+ catch (_error) {
215
+ // something is wrong with the telemetry service
216
+ disableTelemetry();
217
+ }
218
+ });
219
+ }
220
+ telemetry.reportTelemetry = reportTelemetry;
221
+
222
+ var utils = {};
223
+
224
+ (function (exports) {
225
+ Object.defineProperty(exports, "__esModule", { value: true });
226
+ exports.FlexChangesEndPoints = exports.convertCamelCaseToPascalCase = void 0;
227
+ const convertCamelCaseToPascalCase = (text) => {
228
+ const string = text.replace(/([A-Z])/g, ' $1');
229
+ return string.charAt(0).toUpperCase() + string.slice(1);
230
+ };
231
+ exports.convertCamelCaseToPascalCase = convertCamelCaseToPascalCase;
232
+ (function (FlexChangesEndPoints) {
233
+ FlexChangesEndPoints["changes"] = "/preview/api/changes";
234
+ })(exports.FlexChangesEndPoints || (exports.FlexChangesEndPoints = {}));
235
+
236
+ } (utils));
237
+
238
+ (function (exports) {
239
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
240
+ if (k2 === undefined) k2 = k;
241
+ var desc = Object.getOwnPropertyDescriptor(m, k);
242
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
243
+ desc = { enumerable: true, get: function() { return m[k]; } };
244
+ }
245
+ Object.defineProperty(o, k2, desc);
246
+ }) : (function(o, m, k, k2) {
247
+ if (k2 === undefined) k2 = k;
248
+ o[k2] = m[k];
249
+ }));
250
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
251
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
252
+ };
253
+ Object.defineProperty(exports, "__esModule", { value: true });
254
+ exports.disableTelemetry = exports.enableTelemetry = exports.reportTelemetry = exports.startPostMessageCommunication = exports.debounce = void 0;
255
+ __exportStar(api, exports);
256
+ var debounce_1 = debounce$1;
257
+ Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return debounce_1.debounce; } });
258
+ var post_message_1 = postMessage;
259
+ Object.defineProperty(exports, "startPostMessageCommunication", { enumerable: true, get: function () { return post_message_1.startPostMessageCommunication; } });
260
+ var telemetry_1 = telemetry;
261
+ Object.defineProperty(exports, "reportTelemetry", { enumerable: true, get: function () { return telemetry_1.reportTelemetry; } });
262
+ Object.defineProperty(exports, "enableTelemetry", { enumerable: true, get: function () { return telemetry_1.enableTelemetry; } });
263
+ Object.defineProperty(exports, "disableTelemetry", { enumerable: true, get: function () { return telemetry_1.disableTelemetry; } });
264
+ __exportStar(utils, exports);
265
+
266
+ } (dist));
267
+
268
+ Object.defineProperty(dist, "__" + "esModule", { value: true });
269
+
270
+ return dist;
271
+
272
+ }));
@@ -23,6 +23,10 @@ export interface RtaConfig {
23
23
  layer: UI5FlexLayer;
24
24
  options?: {
25
25
  [key: string]: unknown;
26
+ baseId?: string;
27
+ projectId?: string;
28
+ generator?: string;
29
+ scenario?: string;
26
30
  };
27
31
  editors: {
28
32
  path: string;
@@ -32,7 +32,8 @@ function initAdp(rootProject, config, flp, util, logger) {
32
32
  if (flp.rta) {
33
33
  flp.rta.layer = layer;
34
34
  flp.rta.options = {
35
- projectId: variant.id
35
+ projectId: variant.id,
36
+ scenario: 'ADAPTATION_PROJECT'
36
37
  };
37
38
  for (const editor of flp.rta.editors) {
38
39
  (_a = editor.pluginScript) !== null && _a !== void 0 ? _a : (editor.pluginScript = 'open/ux/preview/client/adp/init');
@@ -47,6 +48,23 @@ function initAdp(rootProject, config, flp, util, logger) {
47
48
  }
48
49
  });
49
50
  }
51
+ /**
52
+ * The developer mode is only supported for adaptation projects, therefore, notify the user if it is wrongly configured and then disable it.
53
+ *
54
+ * @param config configurations from the ui5.yaml
55
+ * @param logger logger instance
56
+ */
57
+ function sanitizeConfig(config, logger) {
58
+ if (config.rta && config.adp === undefined) {
59
+ config.rta.editors = config.rta.editors.filter((editor) => {
60
+ if (editor.developerMode) {
61
+ logger.error('developerMode is ONLY supported for SAP UI5 adaptation projects.');
62
+ logger.warn(`developerMode for ${editor.path} disabled`);
63
+ }
64
+ return !editor.developerMode;
65
+ });
66
+ }
67
+ }
50
68
  /**
51
69
  * Create the router that is to be exposed as UI5 middleware.
52
70
  *
@@ -63,6 +81,7 @@ function createRouter({ resources, options, middlewareUtil }, logger) {
63
81
  // setting defaults
64
82
  const config = (_a = options.configuration) !== null && _a !== void 0 ? _a : {};
65
83
  (_b = config.flp) !== null && _b !== void 0 ? _b : (config.flp = {});
84
+ sanitizeConfig(config, logger);
66
85
  // configure the FLP sandbox based on information from the manifest
67
86
  const flp = new flp_1.FlpSandbox(config, resources.rootProject, middlewareUtil, logger);
68
87
  if (config.adp) {
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.6.2",
12
+ "version": "0.7.0",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -24,7 +24,8 @@
24
24
  "dependencies": {
25
25
  "ejs": "3.1.9",
26
26
  "@sap-ux/logger": "0.3.8",
27
- "@sap-ux/adp-tooling": "0.3.1"
27
+ "@sap-ux/adp-tooling": "0.3.1",
28
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.2.0"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/ejs": "3.1.2",
@@ -36,7 +37,7 @@
36
37
  "express": "4.18.2",
37
38
  "nock": "13.2.1",
38
39
  "supertest": "6.3.3",
39
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.2.1",
40
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.3.0",
40
41
  "@sap-ux/project-access": "1.13.6",
41
42
  "@sap-ux/store": "0.3.14"
42
43
  },
@@ -4,25 +4,21 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <meta name="theme-color" content="#000000" />
7
- <meta name="description" content="Web page for rendering Open UX Tools Control Property Editor" />
7
+ <meta name="description" content="Web page for rendering SAP Fiori Tools Control Property Editor" />
8
8
  <link rel="shortcut icon" type="image/x-icon" href="./editor/favicon.ico" />
9
9
  <link rel="stylesheet" type="text/css" href="./editor/app.css" />
10
10
  <title>Control Property Editor</title>
11
- <style>
12
- body, html {
13
- margin: 0;
14
- padding: 0;
15
- height: 100%;
16
- overflow: hidden;
17
- }
18
- iframe {
19
- width: 100%;
20
- height: 100%;
21
- border: none;
22
- }
23
- </style>
24
11
  </head>
25
12
  <body>
26
- <iframe src="<%- previewUrl %>"></iframe>
13
+ <noscript>You need to enable JavaScript to run this app.</noscript>
14
+ <div id="root"></div>
15
+ <script type="module">
16
+ import { start } from './editor/app.js';
17
+ start({
18
+ previewUrl: '<%- previewUrl %>',
19
+ telemetry: <%- telemetry %>,
20
+ rootElementId: 'root'
21
+ });
22
+ </script>
27
23
  </body>
28
24
  </html>
@@ -50,10 +50,11 @@
50
50
  data-sap-ui-theme="<%- ui5.theme %>"
51
51
  data-sap-ui-compatVersion="edge"
52
52
  data-sap-ui-language="en"
53
+ data-sap-ui-bindingSyntax="complex"
53
54
  data-sap-ui-flexibilityServices='<%- JSON.stringify(ui5.flex) %>'
54
55
  data-sap-ui-resourceroots='<%- JSON.stringify(ui5.resources) %>'
55
56
  data-sap-ui-frameOptions="allow"
56
- data-sap-ui-xx-componentPreload="off"
57
+ data-sap-ui-xx-componentPreload="off"<%- ui5.bootstrapOptions %>
57
58
  data-sap-ui-oninit="module:open/ux/preview/client/flp/init"<% if (locals.flex) { %>
58
59
  data-open-ux-preview-flex-settings='<%- JSON.stringify(flex) %>'<% } if (locals.locateReuseLibsScript) { %>
59
60
  data-open-ux-preview-libs-manifests='<%- JSON.stringify(Object.values(apps).map(app => app.url)) %>'<% } %>>
@@ -1,76 +0,0 @@
1
- sap.ui.define(
2
- [
3
- 'sap/base/util/merge',
4
- 'sap/ui/fl/write/api/connectors/ObjectStorageConnector',
5
- 'sap/ui/fl/Layer',
6
- 'sap/base/util/UriParameters'
7
- ],
8
- function (merge, ObjectStorageConnector, Layer, UriParameters) {
9
- 'use strict';
10
- var url = new URL(window.location.toString());
11
- var uriParameters = UriParameters.fromURL(url.href);
12
- var rtaMode = uriParameters.get('fiori-tools-rta-mode');
13
- var generator =
14
- rtaMode === 'forAdaptation'
15
- ? 'changeUtils: SAPFioriTools-propertyEditor'
16
- : 'changeUtils: SAPFioriTools-variants';
17
- var path = '/preview/api/changes';
18
- var WorkspaceConnector = merge({}, ObjectStorageConnector, {
19
- layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
20
- storage: {
21
- _itemsStoredAsObjects: true,
22
- setItem: function (_sKey, vValue) {
23
- // update generator
24
- if (vValue && vValue.support) {
25
- vValue.support.generator = generator;
26
- }
27
- $.ajax({
28
- type: 'POST',
29
- url: path,
30
- data: JSON.stringify(vValue, null, 2),
31
- contentType: 'application/json'
32
- });
33
- },
34
- removeItem: function (sKey) {
35
- $.ajax({
36
- type: 'DELETE',
37
- url: path,
38
- data: JSON.stringify({ fileName: sKey }),
39
- contentType: 'application/json'
40
- });
41
- },
42
- clear: function () {
43
- // not implemented
44
- },
45
- getItem: function (_sKey) {
46
- // not implemented
47
- },
48
- getItems: async function () {
49
- const changes = await $.ajax({
50
- url: path,
51
- type: 'GET',
52
- cache: false,
53
- dataType: 'json'
54
- });
55
- return changes;
56
- }
57
- },
58
- loadFeatures: function () {
59
- return ObjectStorageConnector.loadFeatures().then(function (settings) {
60
- const [majorVersion, minorVersion] = sap.ui.version.split('.').map((v) => parseInt(v, 10));
61
- if (majorVersion >= 1 && minorVersion >= 90) {
62
- settings.isVariantAdaptationEnabled = true;
63
- }
64
-
65
- if (rtaMode === 'forAdaptation') {
66
- settings.isVariantAdaptationEnabled = false;
67
- }
68
- return settings;
69
- });
70
- }
71
- });
72
-
73
- return WorkspaceConnector;
74
- },
75
- true
76
- );