@sap-ux/preview-middleware 0.19.37 → 0.19.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/client/adp/add-fragment.js +46 -46
  2. package/dist/client/adp/api-handler.js +159 -159
  3. package/dist/client/adp/command-executor.js +75 -75
  4. package/dist/client/adp/control-utils.js +44 -44
  5. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +5 -10
  6. package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +3 -9
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +210 -210
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
  9. package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
  10. package/dist/client/adp/dialog-factory.js +135 -135
  11. package/dist/client/adp/init-dialogs.js +163 -163
  12. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
  13. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +60 -60
  14. package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
  15. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
  16. package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
  17. package/dist/client/adp/quick-actions/common/utils.js +18 -18
  18. package/dist/client/adp/quick-actions/control-types.js +23 -23
  19. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
  20. package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
  21. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +81 -81
  22. package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
  23. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
  24. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +107 -107
  25. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
  26. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
  27. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
  28. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
  29. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
  30. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
  31. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
  32. package/dist/client/adp/quick-actions/fe-v2/registry.js +77 -77
  33. package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
  34. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
  35. package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
  36. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
  37. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
  38. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
  39. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
  40. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
  41. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
  42. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
  43. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
  44. package/dist/client/adp/quick-actions/fe-v4/registry.js +60 -60
  45. package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
  46. package/dist/client/adp/quick-actions/load.js +44 -44
  47. package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
  48. package/dist/client/adp/utils.js +218 -218
  49. package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +75 -75
  50. package/dist/client/cpe/changes/index.js +10 -10
  51. package/dist/client/cpe/changes/validator.js +39 -39
  52. package/dist/client/cpe/documentation.js +164 -164
  53. package/dist/client/cpe/feature-service.js +36 -36
  54. package/dist/client/cpe/logger.js +30 -30
  55. package/dist/client/cpe/outline/editable.js +37 -37
  56. package/dist/client/cpe/outline/nodes.js +203 -203
  57. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  58. package/dist/client/cpe/quick-actions/registry.js +143 -143
  59. package/dist/client/cpe/quick-actions/utils.js +92 -92
  60. package/dist/client/cpe/types.js +4 -4
  61. package/dist/client/cpe/ui5-utils.js +33 -33
  62. package/dist/client/cpe/utils.js +111 -111
  63. package/dist/client/flp/WorkspaceConnector.js +92 -92
  64. package/dist/client/flp/common.js +28 -28
  65. package/dist/client/flp/enableFakeConnector.js +89 -89
  66. package/dist/client/flp/homepage/Component.js +14 -14
  67. package/dist/client/flp/initCdm.js +117 -117
  68. package/dist/client/flp/initConnectors.js +28 -28
  69. package/dist/client/flp/initRta.js +178 -178
  70. package/dist/client/i18n.js +56 -56
  71. package/dist/client/utils/additional-change-info.js +54 -41
  72. package/dist/client/utils/additional-change-info.ts +22 -8
  73. package/dist/client/utils/application.js +32 -32
  74. package/dist/client/utils/core.js +84 -84
  75. package/dist/client/utils/error.js +19 -19
  76. package/dist/client/utils/fe-v2.js +56 -56
  77. package/dist/client/utils/fe-v4.js +140 -140
  78. package/dist/client/utils/version.js +104 -104
  79. package/package.json +4 -4
@@ -1,77 +1,77 @@
1
- "use strict";
2
-
3
- sap.ui.define(["../../utils/core", "../../adp/quick-actions/control-types"], function (____utils_core, ____adp_quick_actions_control_types) {
4
- "use strict";
5
-
6
- const getControlById = ____utils_core["getControlById"];
7
- const ANALYTICAL_TABLE_TYPE = ____adp_quick_actions_control_types["ANALYTICAL_TABLE_TYPE"];
8
- const GRID_TABLE_TYPE = ____adp_quick_actions_control_types["GRID_TABLE_TYPE"];
9
- const MDC_TABLE_TYPE = ____adp_quick_actions_control_types["MDC_TABLE_TYPE"];
10
- const TREE_TABLE_TYPE = ____adp_quick_actions_control_types["TREE_TABLE_TYPE"];
11
- function getAddXMLAdditionalInfo(change) {
12
- const selectorId = change.getSelector()?.id ?? '';
13
- const targetAggregation = change.getContent()?.targetAggregation ?? '';
14
- const templateName = getFragmentTemplateName(selectorId, targetAggregation);
15
- if (templateName) {
16
- return {
17
- templateName
18
- };
19
- }
20
- return undefined;
21
- }
22
- function getFragmentTemplateName(selectorId, targetAggregation) {
23
- const control = getControlById(selectorId);
24
- if (!control) {
25
- return '';
26
- }
27
- const controlName = control.getMetadata().getName();
28
- if (controlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
29
- return 'OBJECT_PAGE_CUSTOM_SECTION';
30
- } else if (isCustomAction(controlName, targetAggregation)) {
31
- return 'CUSTOM_ACTION';
32
- } else if (isObjectPageHeaderField(control, controlName, targetAggregation)) {
33
- return 'OBJECT_PAGE_HEADER_FIELD';
34
- } else if (targetAggregation === 'columns') {
35
- switch (controlName) {
36
- case MDC_TABLE_TYPE:
37
- return 'V4_MDC_TABLE_COLUMN';
38
- case TREE_TABLE_TYPE:
39
- case GRID_TABLE_TYPE:
40
- return 'GRID_TREE_TABLE_COLUMN';
41
- case ANALYTICAL_TABLE_TYPE:
42
- return 'ANALYTICAL_TABLE_COLUMN';
43
- default:
44
- return '';
45
- }
46
- } else if (controlName === 'sap.ui.mdc.Table' && targetAggregation === 'actions') {
47
- return 'TABLE_ACTION';
48
- }
49
- return '';
50
- }
51
- function isCustomAction(controlName, targetAggregation) {
52
- if (['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'].includes(controlName)) {
53
- return targetAggregation === 'actions';
54
- } else if (controlName === 'sap.m.OverflowToolbar' || controlName === 'sap.m.Toolbar') {
55
- return targetAggregation === 'content';
56
- }
57
- return false;
58
- }
59
- function isObjectPageHeaderField(control, controlName, targetAggregation) {
60
- if (controlName === 'sap.uxap.ObjectPageLayout') {
61
- return targetAggregation === 'headerContent';
62
- } else if (controlName === 'sap.m.FlexBox') {
63
- const parentName = control.getParent()?.getMetadata().getName();
64
- if (parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' || parentName === 'sap.uxap.ObjectPageLayout') {
65
- return targetAggregation === 'items';
66
- }
67
- }
68
- return false;
69
- }
70
- var __exports = {
71
- __esModule: true
72
- };
73
- __exports.getAddXMLAdditionalInfo = getAddXMLAdditionalInfo;
74
- __exports.getFragmentTemplateName = getFragmentTemplateName;
75
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["../../utils/core", "../../adp/quick-actions/control-types"], function (____utils_core, ____adp_quick_actions_control_types) {
4
+ "use strict";
5
+
6
+ const getControlById = ____utils_core["getControlById"];
7
+ const ANALYTICAL_TABLE_TYPE = ____adp_quick_actions_control_types["ANALYTICAL_TABLE_TYPE"];
8
+ const GRID_TABLE_TYPE = ____adp_quick_actions_control_types["GRID_TABLE_TYPE"];
9
+ const MDC_TABLE_TYPE = ____adp_quick_actions_control_types["MDC_TABLE_TYPE"];
10
+ const TREE_TABLE_TYPE = ____adp_quick_actions_control_types["TREE_TABLE_TYPE"];
11
+ function getAddXMLAdditionalInfo(change) {
12
+ const selectorId = change.getSelector()?.id ?? '';
13
+ const targetAggregation = change.getContent()?.targetAggregation ?? '';
14
+ const templateName = getFragmentTemplateName(selectorId, targetAggregation);
15
+ if (templateName) {
16
+ return {
17
+ templateName
18
+ };
19
+ }
20
+ return undefined;
21
+ }
22
+ function getFragmentTemplateName(selectorId, targetAggregation) {
23
+ const control = getControlById(selectorId);
24
+ if (!control) {
25
+ return '';
26
+ }
27
+ const controlName = control.getMetadata().getName();
28
+ if (controlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
29
+ return 'OBJECT_PAGE_CUSTOM_SECTION';
30
+ } else if (isCustomAction(controlName, targetAggregation)) {
31
+ return 'CUSTOM_ACTION';
32
+ } else if (isObjectPageHeaderField(control, controlName, targetAggregation)) {
33
+ return 'OBJECT_PAGE_HEADER_FIELD';
34
+ } else if (targetAggregation === 'columns') {
35
+ switch (controlName) {
36
+ case MDC_TABLE_TYPE:
37
+ return 'V4_MDC_TABLE_COLUMN';
38
+ case TREE_TABLE_TYPE:
39
+ case GRID_TABLE_TYPE:
40
+ return 'GRID_TREE_TABLE_COLUMN';
41
+ case ANALYTICAL_TABLE_TYPE:
42
+ return 'ANALYTICAL_TABLE_COLUMN';
43
+ default:
44
+ return '';
45
+ }
46
+ } else if (controlName === 'sap.ui.mdc.Table' && targetAggregation === 'actions') {
47
+ return 'TABLE_ACTION';
48
+ }
49
+ return '';
50
+ }
51
+ function isCustomAction(controlName, targetAggregation) {
52
+ if (['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'].includes(controlName)) {
53
+ return targetAggregation === 'actions';
54
+ } else if (controlName === 'sap.m.OverflowToolbar' || controlName === 'sap.m.Toolbar') {
55
+ return targetAggregation === 'content';
56
+ }
57
+ return false;
58
+ }
59
+ function isObjectPageHeaderField(control, controlName, targetAggregation) {
60
+ if (controlName === 'sap.uxap.ObjectPageLayout') {
61
+ return targetAggregation === 'headerContent';
62
+ } else if (controlName === 'sap.m.FlexBox') {
63
+ const parentName = control.getParent()?.getMetadata().getName();
64
+ if (parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' || parentName === 'sap.uxap.ObjectPageLayout') {
65
+ return targetAggregation === 'items';
66
+ }
67
+ }
68
+ return false;
69
+ }
70
+ var __exports = {
71
+ __esModule: true
72
+ };
73
+ __exports.getAddXMLAdditionalInfo = getAddXMLAdditionalInfo;
74
+ __exports.getFragmentTemplateName = getFragmentTemplateName;
75
+ return __exports;
76
76
  });
77
77
  //# sourceMappingURL=add-xml-additional-info.js.map
@@ -1,12 +1,12 @@
1
- "use strict";
2
-
3
- sap.ui.define(["./service"], function (___service) {
4
- "use strict";
5
-
6
- var __exports = {
7
- __esModule: true
8
- };
9
- __exports.ChangeService = ___service.ChangeService;
10
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["./service"], function (___service) {
4
+ "use strict";
5
+
6
+ var __exports = {
7
+ __esModule: true
8
+ };
9
+ __exports.ChangeService = ___service.ChangeService;
10
+ return __exports;
11
11
  });
12
12
  //# sourceMappingURL=index.js.map
@@ -1,41 +1,41 @@
1
- "use strict";
2
-
3
- sap.ui.define(["../../i18n"], function (____i18n) {
4
- "use strict";
5
-
6
- const getTextBundle = ____i18n["getTextBundle"];
7
- /**
8
- * Function to validate if a given value is a valid binding model.
9
- *
10
- * @param modifiedControl control to be modified.
11
- * @param value value to be checked.
12
- */
13
- async function validateBindingModel(modifiedControl, value) {
14
- const textBundle = await getTextBundle();
15
- const bindingValue = value.replace(/[{}]/gi, '').trim();
16
- const bindingParts = bindingValue.split('>').filter(el => el !== '');
17
- if (!bindingParts.length) {
18
- throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING'));
19
- }
20
- if (bindingParts.length === 2) {
21
- const bindingModel = bindingParts[0];
22
- const resourceKey = bindingParts[1].trim();
23
- const resourceModel = modifiedControl.getModel(bindingModel);
24
- if (!resourceModel) {
25
- throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL'));
26
- }
27
- const resourceBundle = resourceModel.getResourceBundle();
28
- if (!resourceBundle.getText(resourceKey, undefined, true)) {
29
- throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL_KEY'));
30
- }
31
- } else {
32
- throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING_FORMAT'));
33
- }
34
- }
35
- var __exports = {
36
- __esModule: true
37
- };
38
- __exports.validateBindingModel = validateBindingModel;
39
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["../../i18n"], function (____i18n) {
4
+ "use strict";
5
+
6
+ const getTextBundle = ____i18n["getTextBundle"];
7
+ /**
8
+ * Function to validate if a given value is a valid binding model.
9
+ *
10
+ * @param modifiedControl control to be modified.
11
+ * @param value value to be checked.
12
+ */
13
+ async function validateBindingModel(modifiedControl, value) {
14
+ const textBundle = await getTextBundle();
15
+ const bindingValue = value.replace(/[{}]/gi, '').trim();
16
+ const bindingParts = bindingValue.split('>').filter(el => el !== '');
17
+ if (!bindingParts.length) {
18
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING'));
19
+ }
20
+ if (bindingParts.length === 2) {
21
+ const bindingModel = bindingParts[0];
22
+ const resourceKey = bindingParts[1].trim();
23
+ const resourceModel = modifiedControl.getModel(bindingModel);
24
+ if (!resourceModel) {
25
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL'));
26
+ }
27
+ const resourceBundle = resourceModel.getResourceBundle();
28
+ if (!resourceBundle.getText(resourceKey, undefined, true)) {
29
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL_KEY'));
30
+ }
31
+ } else {
32
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING_FORMAT'));
33
+ }
34
+ }
35
+ var __exports = {
36
+ __esModule: true
37
+ };
38
+ __exports.validateBindingModel = validateBindingModel;
39
+ return __exports;
40
40
  });
41
41
  //# sourceMappingURL=validator.js.map
@@ -1,166 +1,166 @@
1
- "use strict";
2
-
3
- sap.ui.define(["./utils", "sap/base/Log"], function (___utils, Log) {
4
- "use strict";
5
-
6
- const getLibrary = ___utils["getLibrary"];
7
- /**
8
- * Get ui5 metadata of given library name.
9
- *
10
- * @param libName library name for eg: sap.m
11
- * @returns Promise<SchemaForApiJsonFiles>
12
- */
13
- async function getUi5ApiDtMetadata(libName) {
14
- const libUrl = '/test-resources/' + libName.split('.').join('/') + '/designtime/api.json';
15
- return fetch(libUrl).then(res => res.json());
16
- }
17
-
18
- /**
19
- * load ui5 controls design time metadata api.json for following libraries
20
- * sap.m, sap.ui.comp, sap.f, sap.ui.core
21
- * loading libraries(more in file size) in parallel during initialization.
22
- * Others (less in file size) are loaded dynamically in getControlMetadata method
23
- */
24
- const ui5ApiDtMetadata = new Map();
25
- function loadDefaultLibraries() {
26
- const allData = Promise.all([getUi5ApiDtMetadata('sap.m'), getUi5ApiDtMetadata('sap.ui.comp'), getUi5ApiDtMetadata('sap.ui.core'), getUi5ApiDtMetadata('sap.f')]);
27
- allData.then(res => {
28
- res.forEach(api => {
29
- if (api.library) {
30
- ui5ApiDtMetadata.set(api.library, api);
31
- }
32
- });
33
- }).catch(reason => Log.error('Loading Library Failed: ' + reason));
34
- }
35
-
36
- /**
37
- * Format html text.
38
- *
39
- * @param sHtml - html string
40
- * @returns string
41
- */
42
- function formatHtmlText(sHtml) {
43
- // replaced "sHtml.replace(new RegExp('<[^>]*>', 'g')" due to regex runtime vulnerability
44
- const parts = (sHtml || '').split('<');
45
- let result = '';
46
- for (const part of parts) {
47
- if (!result) {
48
- result = part;
49
- } else {
50
- const indexClosingBracket = part.indexOf('>');
51
- result += indexClosingBracket >= 0 ? part.substring(indexClosingBracket + 1) : `<${part}`;
52
- }
53
- }
54
- return result;
55
- }
56
-
57
- /**
58
- * Method to parse ui5 control metadata.
59
- *
60
- * @param controlLibMetadata control library metadata
61
- * @param controlName name of the control
62
- * @returns ControlMetadata
63
- */
64
- function parseControlMetaModel(controlLibMetadata, controlName) {
65
- const controlInfo = {
66
- baseType: '',
67
- doc: '',
68
- properties: {}
69
- };
70
- const selectedControlMetadata = (controlLibMetadata.symbols ?? []).find(control => control.name === controlName);
71
- if (selectedControlMetadata) {
72
- // base type info of control is available on property 'extends'
73
- controlInfo.baseType = selectedControlMetadata.extends;
74
- controlInfo.doc = selectedControlMetadata.description ?? '';
75
- const properties = selectedControlMetadata['ui5-metadata'].properties;
76
- if (properties) {
77
- properties.forEach(prop => {
78
- prop.description = formatHtmlText(prop.description || '');
79
- prop.propertyName = prop.name;
80
- prop.propertyType = prop.type;
81
- if (prop.defaultValue === null || prop.defaultValue === '') {
82
- prop.defaultValue = '-';
83
- }
84
- controlInfo.properties[prop.name] = {
85
- ...prop
86
- };
87
- });
88
- }
89
- }
90
- return controlInfo;
91
- }
92
-
93
- /**
94
- * Get control metadata for a given control.
95
- *
96
- * @param controlName name of the control
97
- * @param contLibName library name of the control
98
- * @returns Promise<ControlMetadata | undefined>
99
- */
100
- async function getControlMetadata(controlName, contLibName) {
101
- let result;
102
- let controlLibMetadata = ui5ApiDtMetadata.get(contLibName);
103
- if (controlLibMetadata) {
104
- result = parseControlMetaModel(controlLibMetadata, controlName);
105
- } else {
106
- controlLibMetadata = await getUi5ApiDtMetadata(contLibName);
107
- ui5ApiDtMetadata.set(contLibName, controlLibMetadata);
108
- result = parseControlMetaModel(controlLibMetadata, controlName);
109
- }
110
- return result;
111
- }
112
-
113
- /**
114
- * Get Control Property Documentation for a give control name and control library.
115
- *
116
- * @param controlName name of the control
117
- * @param contLibName library name of the control
118
- * @returns Promise<Properties | undefined>
119
- */
120
- async function getControlPropertyDocumentation(controlName, contLibName) {
121
- const doc = await getControlMetadata(controlName, contLibName);
122
- if (doc) {
123
- const baseControlType = doc.baseType;
124
- if (baseControlType) {
125
- const baseContLibName = await getLibrary(baseControlType);
126
- if (baseContLibName) {
127
- const baseControlProps = await getControlPropertyDocumentation(baseControlType, baseContLibName);
128
- return {
129
- ...baseControlProps,
130
- ...doc.properties
131
- };
132
- }
133
- }
134
- return {
135
- ...doc.properties
136
- };
137
- } else {
138
- return undefined;
139
- }
140
- }
141
-
142
- /**
143
- * Get documentation of a given control of a ui5 library.
144
- *
145
- * @param controlName name of the control.
146
- * @param contLibName library name of the control
147
- * @returns Promise<Properties | undefined>
148
- */
149
- async function getDocumentation(controlName, contLibName) {
150
- let doc;
151
- try {
152
- doc = await getControlPropertyDocumentation(controlName, contLibName);
153
- } catch (err) {
154
- Log.error(`Error in getting documentation for ${contLibName}`);
155
- }
156
- return doc;
157
- }
158
- var __exports = {
159
- __esModule: true
160
- };
161
- __exports.getUi5ApiDtMetadata = getUi5ApiDtMetadata;
162
- __exports.loadDefaultLibraries = loadDefaultLibraries;
163
- __exports.getDocumentation = getDocumentation;
164
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["./utils", "sap/base/Log"], function (___utils, Log) {
4
+ "use strict";
5
+
6
+ const getLibrary = ___utils["getLibrary"];
7
+ /**
8
+ * Get ui5 metadata of given library name.
9
+ *
10
+ * @param libName library name for eg: sap.m
11
+ * @returns Promise<SchemaForApiJsonFiles>
12
+ */
13
+ async function getUi5ApiDtMetadata(libName) {
14
+ const libUrl = '/test-resources/' + libName.split('.').join('/') + '/designtime/api.json';
15
+ return fetch(libUrl).then(res => res.json());
16
+ }
17
+
18
+ /**
19
+ * load ui5 controls design time metadata api.json for following libraries
20
+ * sap.m, sap.ui.comp, sap.f, sap.ui.core
21
+ * loading libraries(more in file size) in parallel during initialization.
22
+ * Others (less in file size) are loaded dynamically in getControlMetadata method
23
+ */
24
+ const ui5ApiDtMetadata = new Map();
25
+ function loadDefaultLibraries() {
26
+ const allData = Promise.all([getUi5ApiDtMetadata('sap.m'), getUi5ApiDtMetadata('sap.ui.comp'), getUi5ApiDtMetadata('sap.ui.core'), getUi5ApiDtMetadata('sap.f')]);
27
+ allData.then(res => {
28
+ res.forEach(api => {
29
+ if (api.library) {
30
+ ui5ApiDtMetadata.set(api.library, api);
31
+ }
32
+ });
33
+ }).catch(reason => Log.error('Loading Library Failed: ' + reason));
34
+ }
35
+
36
+ /**
37
+ * Format html text.
38
+ *
39
+ * @param sHtml - html string
40
+ * @returns string
41
+ */
42
+ function formatHtmlText(sHtml) {
43
+ // replaced "sHtml.replace(new RegExp('<[^>]*>', 'g')" due to regex runtime vulnerability
44
+ const parts = (sHtml || '').split('<');
45
+ let result = '';
46
+ for (const part of parts) {
47
+ if (!result) {
48
+ result = part;
49
+ } else {
50
+ const indexClosingBracket = part.indexOf('>');
51
+ result += indexClosingBracket >= 0 ? part.substring(indexClosingBracket + 1) : `<${part}`;
52
+ }
53
+ }
54
+ return result;
55
+ }
56
+
57
+ /**
58
+ * Method to parse ui5 control metadata.
59
+ *
60
+ * @param controlLibMetadata control library metadata
61
+ * @param controlName name of the control
62
+ * @returns ControlMetadata
63
+ */
64
+ function parseControlMetaModel(controlLibMetadata, controlName) {
65
+ const controlInfo = {
66
+ baseType: '',
67
+ doc: '',
68
+ properties: {}
69
+ };
70
+ const selectedControlMetadata = (controlLibMetadata.symbols ?? []).find(control => control.name === controlName);
71
+ if (selectedControlMetadata) {
72
+ // base type info of control is available on property 'extends'
73
+ controlInfo.baseType = selectedControlMetadata.extends;
74
+ controlInfo.doc = selectedControlMetadata.description ?? '';
75
+ const properties = selectedControlMetadata['ui5-metadata'].properties;
76
+ if (properties) {
77
+ properties.forEach(prop => {
78
+ prop.description = formatHtmlText(prop.description || '');
79
+ prop.propertyName = prop.name;
80
+ prop.propertyType = prop.type;
81
+ if (prop.defaultValue === null || prop.defaultValue === '') {
82
+ prop.defaultValue = '-';
83
+ }
84
+ controlInfo.properties[prop.name] = {
85
+ ...prop
86
+ };
87
+ });
88
+ }
89
+ }
90
+ return controlInfo;
91
+ }
92
+
93
+ /**
94
+ * Get control metadata for a given control.
95
+ *
96
+ * @param controlName name of the control
97
+ * @param contLibName library name of the control
98
+ * @returns Promise<ControlMetadata | undefined>
99
+ */
100
+ async function getControlMetadata(controlName, contLibName) {
101
+ let result;
102
+ let controlLibMetadata = ui5ApiDtMetadata.get(contLibName);
103
+ if (controlLibMetadata) {
104
+ result = parseControlMetaModel(controlLibMetadata, controlName);
105
+ } else {
106
+ controlLibMetadata = await getUi5ApiDtMetadata(contLibName);
107
+ ui5ApiDtMetadata.set(contLibName, controlLibMetadata);
108
+ result = parseControlMetaModel(controlLibMetadata, controlName);
109
+ }
110
+ return result;
111
+ }
112
+
113
+ /**
114
+ * Get Control Property Documentation for a give control name and control library.
115
+ *
116
+ * @param controlName name of the control
117
+ * @param contLibName library name of the control
118
+ * @returns Promise<Properties | undefined>
119
+ */
120
+ async function getControlPropertyDocumentation(controlName, contLibName) {
121
+ const doc = await getControlMetadata(controlName, contLibName);
122
+ if (doc) {
123
+ const baseControlType = doc.baseType;
124
+ if (baseControlType) {
125
+ const baseContLibName = await getLibrary(baseControlType);
126
+ if (baseContLibName) {
127
+ const baseControlProps = await getControlPropertyDocumentation(baseControlType, baseContLibName);
128
+ return {
129
+ ...baseControlProps,
130
+ ...doc.properties
131
+ };
132
+ }
133
+ }
134
+ return {
135
+ ...doc.properties
136
+ };
137
+ } else {
138
+ return undefined;
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Get documentation of a given control of a ui5 library.
144
+ *
145
+ * @param controlName name of the control.
146
+ * @param contLibName library name of the control
147
+ * @returns Promise<Properties | undefined>
148
+ */
149
+ async function getDocumentation(controlName, contLibName) {
150
+ let doc;
151
+ try {
152
+ doc = await getControlPropertyDocumentation(controlName, contLibName);
153
+ } catch (err) {
154
+ Log.error(`Error in getting documentation for ${contLibName}`);
155
+ }
156
+ return doc;
157
+ }
158
+ var __exports = {
159
+ __esModule: true
160
+ };
161
+ __exports.getUi5ApiDtMetadata = getUi5ApiDtMetadata;
162
+ __exports.loadDefaultLibraries = loadDefaultLibraries;
163
+ __exports.getDocumentation = getDocumentation;
164
+ return __exports;
165
165
  });
166
166
  //# sourceMappingURL=documentation.js.map
@@ -1,38 +1,38 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- class FeatureService {
7
- static features = {};
8
- static #_ = (() => {
9
- // eslint-disable-next-line fiori-custom/sap-no-dom-access, fiori-custom/sap-browser-api-warning
10
- const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
11
- const features = bootstrapConfig?.getAttribute('data-open-ux-preview-features');
12
- if (features) {
13
- const featureToggles = JSON.parse(features);
14
- for (const {
15
- feature,
16
- isEnabled
17
- } of featureToggles) {
18
- this.features[feature] = isEnabled;
19
- }
20
- }
21
- })();
22
- /**
23
- * Checks if given feature is enabled.
24
- *
25
- * @param featureId - Id of the feature.
26
- * @returns true if feature is enabled.
27
- */
28
- static isFeatureEnabled(featureId) {
29
- return this.features[featureId] ?? false;
30
- }
31
- }
32
- var __exports = {
33
- __esModule: true
34
- };
35
- __exports.FeatureService = FeatureService;
36
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ class FeatureService {
7
+ static features = {};
8
+ static #_ = (() => {
9
+ // eslint-disable-next-line fiori-custom/sap-no-dom-access, fiori-custom/sap-browser-api-warning
10
+ const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
11
+ const features = bootstrapConfig?.getAttribute('data-open-ux-preview-features');
12
+ if (features) {
13
+ const featureToggles = JSON.parse(features);
14
+ for (const {
15
+ feature,
16
+ isEnabled
17
+ } of featureToggles) {
18
+ this.features[feature] = isEnabled;
19
+ }
20
+ }
21
+ })();
22
+ /**
23
+ * Checks if given feature is enabled.
24
+ *
25
+ * @param featureId - Id of the feature.
26
+ * @returns true if feature is enabled.
27
+ */
28
+ static isFeatureEnabled(featureId) {
29
+ return this.features[featureId] ?? false;
30
+ }
31
+ }
32
+ var __exports = {
33
+ __esModule: true
34
+ };
35
+ __exports.FeatureService = FeatureService;
36
+ return __exports;
37
37
  });
38
38
  //# sourceMappingURL=feature-service.js.map