@sap-ux/preview-middleware 0.11.36 → 0.12.1
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 +8 -2
- package/dist/base/flp.js +28 -19
- package/dist/client/adp/api-handler.js +141 -141
- package/dist/client/adp/command-executor.js +54 -41
- package/dist/client/adp/command-executor.ts +18 -4
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +206 -203
- package/dist/client/adp/controllers/AddFragment.controller.ts +11 -5
- package/dist/client/adp/controllers/BaseDialog.controller.js +57 -57
- package/dist/client/adp/controllers/BaseDialog.controller.ts +8 -2
- package/dist/client/adp/controllers/ControllerExtension.controller.js +174 -173
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +10 -6
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +100 -100
- package/dist/client/adp/controllers/ExtensionPoint.controller.ts +8 -6
- package/dist/client/adp/init-dialogs.js +74 -73
- package/dist/client/adp/init-dialogs.ts +13 -8
- package/dist/client/adp/init.js +23 -7
- package/dist/client/adp/init.ts +14 -6
- package/dist/client/adp/ui/AddFragment.fragment.xml +69 -0
- package/dist/client/adp/ui/ControllerExtension.fragment.xml +51 -0
- package/dist/client/adp/ui/ExtensionPoint.fragment.xml +51 -0
- package/dist/client/adp/ui5-version-utils.js +63 -63
- package/dist/client/adp/utils.js +33 -33
- package/dist/client/cpe/changes/flex-change.js +51 -51
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +35 -35
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/nodes.js +84 -84
- package/dist/client/cpe/outline/utils.js +37 -37
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +49 -49
- package/dist/client/cpe/utils.js +48 -48
- package/dist/client/flp/WorkspaceConnector.js +69 -77
- package/dist/client/flp/WorkspaceConnector.ts +5 -25
- package/dist/client/flp/common.js +30 -0
- package/dist/client/flp/common.ts +26 -0
- package/dist/client/flp/enableFakeConnector.js +79 -0
- package/dist/client/flp/enableFakeConnector.ts +93 -0
- package/dist/client/flp/init.js +212 -204
- package/dist/client/flp/init.ts +27 -11
- package/dist/client/flp/initConnectors.js +35 -0
- package/dist/client/flp/initConnectors.ts +30 -0
- package/dist/client/flp/initRta.js +180 -0
- package/dist/client/flp/initRta.ts +193 -0
- package/package.json +5 -4
- package/templates/flp/sandbox.html +7 -1
- package/dist/client/adp/ui/AddFragment.view.xml +0 -68
- package/dist/client/adp/ui/ControllerExtension.view.xml +0 -49
- package/dist/client/adp/ui/ExtensionPoint.view.xml +0 -49
|
@@ -2,40 +2,20 @@ import merge from 'sap/base/util/merge';
|
|
|
2
2
|
import ObjectStorageConnector from 'sap/ui/fl/write/api/connectors/ObjectStorageConnector';
|
|
3
3
|
import Layer from 'sap/ui/fl/Layer';
|
|
4
4
|
import VersionInfo from 'sap/ui/VersionInfo';
|
|
5
|
-
|
|
6
|
-
const path = '/preview/api/changes';
|
|
7
|
-
interface Change {
|
|
8
|
-
support?: {
|
|
9
|
-
generator?: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function getFlexSettings(): {
|
|
14
|
-
generator?: string;
|
|
15
|
-
developerMode?: boolean;
|
|
16
|
-
scenario?: string;
|
|
17
|
-
} | undefined {
|
|
18
|
-
let result;
|
|
19
|
-
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
20
|
-
const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
|
|
21
|
-
if (flexSetting) {
|
|
22
|
-
result = JSON.parse(flexSetting);
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
5
|
+
import { CHANGES_API_PATH, FlexChange, getFlexSettings } from './common';
|
|
26
6
|
|
|
27
7
|
const connector = merge({}, ObjectStorageConnector, {
|
|
28
8
|
layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
|
|
29
9
|
storage: {
|
|
30
10
|
_itemsStoredAsObjects: true,
|
|
31
|
-
setItem: function (_key: string, change:
|
|
11
|
+
setItem: function (_key: string, change: FlexChange) {
|
|
32
12
|
const settings = getFlexSettings();
|
|
33
13
|
if (settings) {
|
|
34
14
|
change.support ??= {};
|
|
35
15
|
change.support.generator = settings.generator;
|
|
36
16
|
}
|
|
37
17
|
|
|
38
|
-
return fetch(
|
|
18
|
+
return fetch(CHANGES_API_PATH, {
|
|
39
19
|
method: 'POST',
|
|
40
20
|
body: JSON.stringify(change, null, 2),
|
|
41
21
|
headers: {
|
|
@@ -44,7 +24,7 @@ const connector = merge({}, ObjectStorageConnector, {
|
|
|
44
24
|
});
|
|
45
25
|
},
|
|
46
26
|
removeItem: function (key: string) {
|
|
47
|
-
return fetch(
|
|
27
|
+
return fetch(CHANGES_API_PATH, {
|
|
48
28
|
method: 'DELETE',
|
|
49
29
|
body: JSON.stringify({ fileName: key }),
|
|
50
30
|
headers: {
|
|
@@ -59,7 +39,7 @@ const connector = merge({}, ObjectStorageConnector, {
|
|
|
59
39
|
// not implemented
|
|
60
40
|
},
|
|
61
41
|
getItems: async function () {
|
|
62
|
-
const response = await fetch(
|
|
42
|
+
const response = await fetch(CHANGES_API_PATH, {
|
|
63
43
|
method: 'GET',
|
|
64
44
|
headers: {
|
|
65
45
|
'content-type': 'application/json'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define([], function () {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const CHANGES_API_PATH = '/preview/api/changes';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves Flex settings from a 'sap-ui-bootstrap' element's data attribute.
|
|
10
|
+
* Parses the 'data-open-ux-preview-flex-settings' attribute as JSON.
|
|
11
|
+
*
|
|
12
|
+
* @returns {FlexSettings | undefined} The parsed Flex settings if available, otherwise undefined.
|
|
13
|
+
*/
|
|
14
|
+
function getFlexSettings() {
|
|
15
|
+
let result;
|
|
16
|
+
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
17
|
+
const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
|
|
18
|
+
if (flexSetting) {
|
|
19
|
+
result = JSON.parse(flexSetting);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
var __exports = {
|
|
24
|
+
__esModule: true
|
|
25
|
+
};
|
|
26
|
+
__exports.CHANGES_API_PATH = CHANGES_API_PATH;
|
|
27
|
+
__exports.getFlexSettings = getFlexSettings;
|
|
28
|
+
return __exports;
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FlexSettings } from 'sap/ui/rta/RuntimeAuthoring';
|
|
2
|
+
|
|
3
|
+
export interface FlexChange {
|
|
4
|
+
[key: string]: string | object | undefined;
|
|
5
|
+
support: {
|
|
6
|
+
generator?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const CHANGES_API_PATH = '/preview/api/changes';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves Flex settings from a 'sap-ui-bootstrap' element's data attribute.
|
|
14
|
+
* Parses the 'data-open-ux-preview-flex-settings' attribute as JSON.
|
|
15
|
+
*
|
|
16
|
+
* @returns {FlexSettings | undefined} The parsed Flex settings if available, otherwise undefined.
|
|
17
|
+
*/
|
|
18
|
+
export function getFlexSettings(): FlexSettings | undefined {
|
|
19
|
+
let result;
|
|
20
|
+
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
21
|
+
const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
|
|
22
|
+
if (flexSetting) {
|
|
23
|
+
result = JSON.parse(flexSetting);
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/ui/fl/LrepConnector", "sap/ui/fl/FakeLrepConnector", "./common"], function (LrepConnector, FakeLrepConnector, ___common) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
|
|
7
|
+
const getFlexSettings = ___common["getFlexSettings"];
|
|
8
|
+
/**
|
|
9
|
+
* Processes an array of FlexChange objects.
|
|
10
|
+
* It updates each change object with settings and sends them to a API endpoint.
|
|
11
|
+
*
|
|
12
|
+
* @param {FlexChange[]} changes - Array of FlexChange objects to be processed.
|
|
13
|
+
* @returns {Promise<void>} A promise that resolves when all changes are processed.
|
|
14
|
+
*/
|
|
15
|
+
async function create(changes) {
|
|
16
|
+
const settings = getFlexSettings();
|
|
17
|
+
await Promise.all(changes.map(change => {
|
|
18
|
+
if (settings) {
|
|
19
|
+
change.support ??= {};
|
|
20
|
+
change.support.generator = settings.generator;
|
|
21
|
+
}
|
|
22
|
+
return fetch(CHANGES_API_PATH, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
body: JSON.stringify(change, null, 2),
|
|
25
|
+
headers: {
|
|
26
|
+
'content-type': 'application/json'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Loads changes from a given path and processes them using an LrepConnector instance.
|
|
34
|
+
* The changes are then formatted and returned in a specified structure.
|
|
35
|
+
*
|
|
36
|
+
* @returns {Promise<LoadChangesResult>} A promise that resolves to an object of type LoadChangesResult.
|
|
37
|
+
*/
|
|
38
|
+
async function loadChanges() {
|
|
39
|
+
const lrep = new LrepConnector();
|
|
40
|
+
const response = await fetch(CHANGES_API_PATH, {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
headers: {
|
|
43
|
+
'content-type': 'application/json'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const changes = await response.json();
|
|
47
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
|
+
args[_key] = arguments[_key];
|
|
49
|
+
}
|
|
50
|
+
return LrepConnector.prototype.loadChanges.apply(lrep, args).then(res => {
|
|
51
|
+
const flexChanges = Object.values(changes);
|
|
52
|
+
res.changes.changes = flexChanges;
|
|
53
|
+
return res;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Configures and enables the FakeLrepConnector based on the SAP UI5 version.
|
|
59
|
+
* If the minor version of the SAP UI5 is less than 72, this function extends
|
|
60
|
+
* the FakeLrepConnector's prototype with specific methods and enables the fake connector.
|
|
61
|
+
*
|
|
62
|
+
* Assumes the existence of a global 'sap' object with a 'ui.version' property,
|
|
63
|
+
* and global jQuery object with 'extend' method.
|
|
64
|
+
*
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
var __exports = function () {
|
|
68
|
+
jQuery.extend(FakeLrepConnector.prototype, {
|
|
69
|
+
create,
|
|
70
|
+
loadChanges,
|
|
71
|
+
loadSettings: () => Promise.resolve()
|
|
72
|
+
});
|
|
73
|
+
FakeLrepConnector.enableFakeConnector();
|
|
74
|
+
};
|
|
75
|
+
__exports.create = create;
|
|
76
|
+
__exports.loadChanges = loadChanges;
|
|
77
|
+
return __exports;
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=enableFakeConnector.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import LrepConnector from 'sap/ui/fl/LrepConnector';
|
|
2
|
+
import FakeLrepConnector from 'sap/ui/fl/FakeLrepConnector';
|
|
3
|
+
|
|
4
|
+
import { CHANGES_API_PATH, FlexChange, getFlexSettings } from './common';
|
|
5
|
+
|
|
6
|
+
interface FetchedChanges {
|
|
7
|
+
[key: string]: FlexChange;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface LoadChangesResult {
|
|
11
|
+
changes: {
|
|
12
|
+
loadModules: boolean;
|
|
13
|
+
changes: FlexChange[];
|
|
14
|
+
settings: {
|
|
15
|
+
[key: string]: string | boolean | undefined;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
componentClassName: string;
|
|
19
|
+
etag: string;
|
|
20
|
+
loadModules: boolean;
|
|
21
|
+
messagebundle: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Processes an array of FlexChange objects.
|
|
26
|
+
* It updates each change object with settings and sends them to a API endpoint.
|
|
27
|
+
*
|
|
28
|
+
* @param {FlexChange[]} changes - Array of FlexChange objects to be processed.
|
|
29
|
+
* @returns {Promise<void>} A promise that resolves when all changes are processed.
|
|
30
|
+
*/
|
|
31
|
+
export async function create(changes: FlexChange[]): Promise<void> {
|
|
32
|
+
const settings = getFlexSettings();
|
|
33
|
+
await Promise.all(
|
|
34
|
+
changes.map((change) => {
|
|
35
|
+
if (settings) {
|
|
36
|
+
change.support ??= {};
|
|
37
|
+
change.support.generator = settings.generator;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return fetch(CHANGES_API_PATH, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: JSON.stringify(change, null, 2),
|
|
43
|
+
headers: {
|
|
44
|
+
'content-type': 'application/json'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Loads changes from a given path and processes them using an LrepConnector instance.
|
|
53
|
+
* The changes are then formatted and returned in a specified structure.
|
|
54
|
+
*
|
|
55
|
+
* @returns {Promise<LoadChangesResult>} A promise that resolves to an object of type LoadChangesResult.
|
|
56
|
+
*/
|
|
57
|
+
export async function loadChanges(...args: []): Promise<LoadChangesResult> {
|
|
58
|
+
const lrep = new LrepConnector();
|
|
59
|
+
|
|
60
|
+
const response = await fetch(CHANGES_API_PATH, {
|
|
61
|
+
method: 'GET',
|
|
62
|
+
headers: {
|
|
63
|
+
'content-type': 'application/json'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const changes = (await response.json()) as FetchedChanges;
|
|
67
|
+
|
|
68
|
+
return LrepConnector.prototype.loadChanges.apply(lrep, args).then((res: LoadChangesResult) => {
|
|
69
|
+
const flexChanges = Object.values(changes);
|
|
70
|
+
res.changes.changes = flexChanges;
|
|
71
|
+
return res;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Configures and enables the FakeLrepConnector based on the SAP UI5 version.
|
|
77
|
+
* If the minor version of the SAP UI5 is less than 72, this function extends
|
|
78
|
+
* the FakeLrepConnector's prototype with specific methods and enables the fake connector.
|
|
79
|
+
*
|
|
80
|
+
* Assumes the existence of a global 'sap' object with a 'ui.version' property,
|
|
81
|
+
* and global jQuery object with 'extend' method.
|
|
82
|
+
*
|
|
83
|
+
* @returns {void}
|
|
84
|
+
*/
|
|
85
|
+
export default function (): void {
|
|
86
|
+
jQuery.extend(FakeLrepConnector.prototype, {
|
|
87
|
+
create,
|
|
88
|
+
loadChanges,
|
|
89
|
+
loadSettings: () => Promise.resolve()
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
FakeLrepConnector.enableFakeConnector();
|
|
93
|
+
}
|