@sap/ux-specification 1.71.41 → 1.71.45

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 (187) hide show
  1. package/CHANGELOG.md +88 -22
  2. package/README.md +4 -4
  3. package/dist/documentation/runDocu-min.js +2 -0
  4. package/dist/documentation/runDocu-min.js.LICENSE.txt +24 -0
  5. package/dist/documentation/styleDocu.css +227 -0
  6. package/dist/documentation/v2/v2-AnalyticalListPage.html +49 -0
  7. package/dist/documentation/v2/v2-ApplicationV2.html +48 -0
  8. package/dist/documentation/v2/v2-ListReport.html +49 -0
  9. package/dist/documentation/v2/v2-ObjectPage.html +49 -0
  10. package/dist/documentation/v2/v2-OverviewPage.html +49 -0
  11. package/dist/index-min.js +1 -1
  12. package/dist/schemas/v2/AnalyticalListPageConfig.json +76 -6
  13. package/dist/schemas/v2/ApplicationV2.json +6 -0
  14. package/dist/schemas/v2/ListReportConfig.json +75 -5
  15. package/dist/schemas/v2/ObjectPageConfig.json +302 -42
  16. package/dist/schemas/v2/OverviewPageConfig.json +24 -41
  17. package/dist/scripts/extractDocu.js +186 -19
  18. package/dist/scripts/extractDocu.js.map +1 -1
  19. package/dist/scripts/runDocu.d.ts +1 -0
  20. package/dist/scripts/runDocu.js +561 -0
  21. package/dist/scripts/runDocu.js.map +1 -0
  22. package/dist/specification/v2/index-min.js +1 -1
  23. package/dist/src/api.js +8 -14
  24. package/dist/src/api.js.map +1 -1
  25. package/dist/src/apiTypes.d.ts +72 -65
  26. package/dist/src/extensionLogger.js +2 -2
  27. package/dist/src/extensionLogger.js.map +1 -1
  28. package/dist/src/specification/common/page.d.ts +2 -2
  29. package/dist/src/specification/common/page.js.map +1 -1
  30. package/dist/src/specification/common/types.d.ts +1 -0
  31. package/dist/src/specification/common/webapp/manifest/Manifest.d.ts +3 -1
  32. package/dist/src/specification/common/webapp/manifest/Manifest.js +1 -0
  33. package/dist/src/specification/common/webapp/manifest/Manifest.js.map +1 -1
  34. package/dist/src/specification/common/webapp/manifest/sapOvp.d.ts +2 -1
  35. package/dist/src/specification/v2/ApplicationV2.d.ts +6 -0
  36. package/dist/src/specification/v2/controls/AnalyticalListPageChart.d.ts +1 -1
  37. package/dist/src/specification/v2/controls/Card.d.ts +11 -13
  38. package/dist/src/specification/v2/controls/Card.js +0 -3
  39. package/dist/src/specification/v2/controls/Card.js.map +1 -1
  40. package/dist/src/specification/v2/controls/Facets.d.ts +2 -1
  41. package/dist/src/specification/v2/controls/Field.d.ts +10 -0
  42. package/dist/src/specification/v2/controls/Field.js +3 -0
  43. package/dist/src/specification/v2/controls/Field.js.map +1 -0
  44. package/dist/src/specification/v2/controls/FormAction.d.ts +38 -0
  45. package/dist/src/specification/v2/controls/FormAction.js +15 -0
  46. package/dist/src/specification/v2/controls/FormAction.js.map +1 -0
  47. package/dist/src/specification/v2/controls/ObjectPageFooter.d.ts +11 -0
  48. package/dist/src/specification/v2/controls/ObjectPageFooter.js +3 -0
  49. package/dist/src/specification/v2/controls/ObjectPageFooter.js.map +1 -0
  50. package/dist/src/specification/v2/controls/ObjectPageForm.d.ts +16 -0
  51. package/dist/src/specification/v2/controls/ObjectPageForm.js +3 -0
  52. package/dist/src/specification/v2/controls/ObjectPageForm.js.map +1 -0
  53. package/dist/src/specification/v2/controls/ObjectPageHeaderAction.d.ts +21 -5
  54. package/dist/src/specification/v2/controls/ObjectPageHeaderAction.js +0 -5
  55. package/dist/src/specification/v2/controls/ObjectPageHeaderAction.js.map +1 -1
  56. package/dist/src/specification/v2/controls/ObjectPageSection.d.ts +24 -7
  57. package/dist/src/specification/v2/controls/ObjectPageSection.js.map +1 -1
  58. package/dist/src/specification/v2/controls/ObjectPageTable.d.ts +4 -1
  59. package/dist/src/specification/v2/controls/Table.d.ts +4 -0
  60. package/dist/src/specification/v2/controls/Table.js.map +1 -1
  61. package/dist/src/specification/v2/controls/ToolBar.d.ts +2 -6
  62. package/dist/src/specification/v2/controls/index.d.ts +5 -0
  63. package/dist/src/specification/v2/controls/index.js +1 -1
  64. package/dist/src/specification/v2/controls/index.js.map +1 -1
  65. package/dist/src/specification/v2/pages/ListReportConfig.d.ts +2 -1
  66. package/dist/src/specification/v2/pages/ObjectPageConfig.d.ts +2 -1
  67. package/dist/src/specification/v2/webapp/manifest/sapUiPageV2.d.ts +1 -0
  68. package/dist/src/specification/v2/webapp/manifest/sapUiPageV2.js +1 -0
  69. package/dist/src/specification/v2/webapp/manifest/sapUiPageV2.js.map +1 -1
  70. package/dist/src/sync/common/decoration/control.d.ts +8 -1
  71. package/dist/src/sync/common/decoration/control.js +62 -21
  72. package/dist/src/sync/common/decoration/control.js.map +1 -1
  73. package/dist/src/sync/common/flexUtils.d.ts +2 -2
  74. package/dist/src/sync/common/flexUtils.js +10 -5
  75. package/dist/src/sync/common/flexUtils.js.map +1 -1
  76. package/dist/src/sync/common/generate/index.d.ts +1 -0
  77. package/dist/src/sync/common/generate/index.js +7 -0
  78. package/dist/src/sync/common/generate/index.js.map +1 -0
  79. package/dist/src/sync/common/generate/objectPage.d.ts +49 -0
  80. package/dist/src/sync/common/generate/objectPage.js +319 -0
  81. package/dist/src/sync/common/generate/objectPage.js.map +1 -0
  82. package/dist/src/sync/common/import/utils.d.ts +28 -0
  83. package/dist/src/sync/common/import/utils.js +75 -0
  84. package/dist/src/sync/common/import/utils.js.map +1 -0
  85. package/dist/src/sync/common/importProject.js +53 -50
  86. package/dist/src/sync/common/importProject.js.map +1 -1
  87. package/dist/src/sync/common/index.d.ts +2 -0
  88. package/dist/src/sync/common/index.js +2 -0
  89. package/dist/src/sync/common/index.js.map +1 -1
  90. package/dist/src/sync/common/types.d.ts +19 -6
  91. package/dist/src/sync/common/types.js +12 -0
  92. package/dist/src/sync/common/types.js.map +1 -1
  93. package/dist/src/sync/common/utils.d.ts +30 -9
  94. package/dist/src/sync/common/utils.js +255 -173
  95. package/dist/src/sync/common/utils.js.map +1 -1
  96. package/dist/src/sync/v2/application.d.ts +2 -0
  97. package/dist/src/sync/v2/application.js +18 -5
  98. package/dist/src/sync/v2/application.js.map +1 -1
  99. package/dist/src/sync/v2/export/controls/Card.d.ts +4 -3
  100. package/dist/src/sync/v2/export/controls/Card.js +16 -9
  101. package/dist/src/sync/v2/export/controls/Card.js.map +1 -1
  102. package/dist/src/sync/v2/export/controls/Field.d.ts +4 -0
  103. package/dist/src/sync/v2/export/controls/Field.js +32 -0
  104. package/dist/src/sync/v2/export/controls/Field.js.map +1 -0
  105. package/dist/src/sync/v2/export/controls/FormAction.d.ts +15 -0
  106. package/dist/src/sync/v2/export/controls/FormAction.js +127 -0
  107. package/dist/src/sync/v2/export/controls/FormAction.js.map +1 -0
  108. package/dist/src/sync/v2/export/controls/Fragment.d.ts +1 -1
  109. package/dist/src/sync/v2/export/controls/Fragment.js +100 -87
  110. package/dist/src/sync/v2/export/controls/Fragment.js.map +1 -1
  111. package/dist/src/sync/v2/export/controls/ObjectPageHeader.js +1 -1
  112. package/dist/src/sync/v2/export/controls/ObjectPageHeader.js.map +1 -1
  113. package/dist/src/sync/v2/export/controls/ObjectPageHeaderAction.d.ts +6 -2
  114. package/dist/src/sync/v2/export/controls/ObjectPageHeaderAction.js +43 -4
  115. package/dist/src/sync/v2/export/controls/ObjectPageHeaderAction.js.map +1 -1
  116. package/dist/src/sync/v2/export/controls/ObjectPageSectionsV2.d.ts +25 -0
  117. package/dist/src/sync/v2/export/controls/ObjectPageSectionsV2.js +113 -0
  118. package/dist/src/sync/v2/export/controls/ObjectPageSectionsV2.js.map +1 -0
  119. package/dist/src/sync/v2/export/controls/ObjectPageTable.js +4 -5
  120. package/dist/src/sync/v2/export/controls/ObjectPageTable.js.map +1 -1
  121. package/dist/src/sync/v2/export/controls/Table.d.ts +8 -1
  122. package/dist/src/sync/v2/export/controls/Table.js +88 -31
  123. package/dist/src/sync/v2/export/controls/Table.js.map +1 -1
  124. package/dist/src/sync/v2/export/controls/TableColumn.js +1 -1
  125. package/dist/src/sync/v2/export/controls/TableColumn.js.map +1 -1
  126. package/dist/src/sync/v2/export/controls/index.d.ts +3 -0
  127. package/dist/src/sync/v2/export/controls/index.js +3 -0
  128. package/dist/src/sync/v2/export/controls/index.js.map +1 -1
  129. package/dist/src/sync/v2/export/export.d.ts +24 -10
  130. package/dist/src/sync/v2/export/export.js +285 -503
  131. package/dist/src/sync/v2/export/export.js.map +1 -1
  132. package/dist/src/sync/v2/export/exportPage.d.ts +10 -0
  133. package/dist/src/sync/v2/export/exportPage.js +311 -0
  134. package/dist/src/sync/v2/export/exportPage.js.map +1 -0
  135. package/dist/src/sync/v2/export/pages/ListReport.d.ts +3 -1
  136. package/dist/src/sync/v2/export/pages/ListReport.js.map +1 -1
  137. package/dist/src/sync/v2/export/pages/OverviewPage.d.ts +3 -1
  138. package/dist/src/sync/v2/export/pages/OverviewPage.js.map +1 -1
  139. package/dist/src/sync/v2/export/view-controller-generator.js +1 -1
  140. package/dist/src/sync/v2/export/view-controller-generator.js.map +1 -1
  141. package/dist/src/sync/v2/generate/analyticalListReport.d.ts +3 -9
  142. package/dist/src/sync/v2/generate/analyticalListReport.js +13 -16
  143. package/dist/src/sync/v2/generate/analyticalListReport.js.map +1 -1
  144. package/dist/src/sync/v2/generate/generate.js +28 -6
  145. package/dist/src/sync/v2/generate/generate.js.map +1 -1
  146. package/dist/src/sync/v2/generate/listReport.d.ts +3 -9
  147. package/dist/src/sync/v2/generate/listReport.js +20 -23
  148. package/dist/src/sync/v2/generate/listReport.js.map +1 -1
  149. package/dist/src/sync/v2/generate/objectPage.d.ts +3 -10
  150. package/dist/src/sync/v2/generate/objectPage.js +226 -141
  151. package/dist/src/sync/v2/generate/objectPage.js.map +1 -1
  152. package/dist/src/sync/v2/generate/utils.d.ts +1 -2
  153. package/dist/src/sync/v2/generate/utils.js +21 -6
  154. package/dist/src/sync/v2/generate/utils.js.map +1 -1
  155. package/dist/src/sync/v2/import/app/appProvider.js +25 -3
  156. package/dist/src/sync/v2/import/app/appProvider.js.map +1 -1
  157. package/dist/src/sync/v2/import/app/ovpProvider.d.ts +2 -1
  158. package/dist/src/sync/v2/import/app/ovpProvider.js +7 -3
  159. package/dist/src/sync/v2/import/app/ovpProvider.js.map +1 -1
  160. package/dist/src/sync/v2/import/common/index.d.ts +10 -1
  161. package/dist/src/sync/v2/import/common/index.js +17 -38
  162. package/dist/src/sync/v2/import/common/index.js.map +1 -1
  163. package/dist/src/sync/v2/import/controls/table.d.ts +2 -1
  164. package/dist/src/sync/v2/import/controls/table.js +1 -1
  165. package/dist/src/sync/v2/import/controls/table.js.map +1 -1
  166. package/dist/src/sync/v2/import/pages/analyticalListPage.d.ts +3 -8
  167. package/dist/src/sync/v2/import/pages/analyticalListPage.js +23 -24
  168. package/dist/src/sync/v2/import/pages/analyticalListPage.js.map +1 -1
  169. package/dist/src/sync/v2/import/pages/listReport.d.ts +3 -7
  170. package/dist/src/sync/v2/import/pages/listReport.js +23 -24
  171. package/dist/src/sync/v2/import/pages/listReport.js.map +1 -1
  172. package/dist/src/sync/v2/import/pages/objectPage.d.ts +6 -12
  173. package/dist/src/sync/v2/import/pages/objectPage.js +293 -154
  174. package/dist/src/sync/v2/import/pages/objectPage.js.map +1 -1
  175. package/dist/src/sync/v2/import/pages/overviewPage.d.ts +9 -1
  176. package/dist/src/sync/v2/import/pages/overviewPage.js +69 -39
  177. package/dist/src/sync/v2/import/pages/overviewPage.js.map +1 -1
  178. package/dist/src/sync/v2/import/utils.d.ts +3 -3
  179. package/dist/src/sync/v2/import/utils.js +5 -5
  180. package/dist/src/sync/v2/import/utils.js.map +1 -1
  181. package/dist/src/sync/v2/types.d.ts +32 -0
  182. package/dist/src/sync/v2/types.js +15 -0
  183. package/dist/src/sync/v2/types.js.map +1 -1
  184. package/dist/src/sync/v4/utils/StableIdHelper.d.ts +4 -0
  185. package/dist/src/sync/v4/utils/StableIdHelper.js +153 -0
  186. package/dist/src/sync/v4/utils/StableIdHelper.js.map +1 -0
  187. package/package.json +15 -7
@@ -9,6 +9,7 @@ const edmx_parser_1 = require("@sap-ux/edmx-parser");
9
9
  const common_1 = require("../../specification/common");
10
10
  const schemaAccess_1 = require("../../specification/schemaAccess");
11
11
  const i18next_1 = __importDefault(require("i18next"));
12
+ const v2_1 = require("../../specification/v2");
12
13
  const extensionLogger_1 = require("../../extensionLogger");
13
14
  const deepmerge_1 = __importDefault(require("deepmerge"));
14
15
  var TemplateType;
@@ -48,8 +49,7 @@ function parseAndMergeAndConvert(annotationFiles, logger) {
48
49
  }
49
50
  const converterOutput = annotation_converter_1.convertTypes(edmx_parser_1.merge(parseResult));
50
51
  if (logger && converterOutput.diagnostics) {
51
- for (let index = 0; index < converterOutput.diagnostics.length; index++) {
52
- const converterMessage = converterOutput.diagnostics[index];
52
+ for (const converterMessage of converterOutput.diagnostics) {
53
53
  extensionLogger_1.log(logger, {
54
54
  severity: "error" /* Error */,
55
55
  message: converterMessage.message
@@ -81,11 +81,12 @@ function evaluateCommonLabel(annotations, entityType, label) {
81
81
  }
82
82
  else if (annotations.Common.Label['type'] === 'Path') {
83
83
  const targetProperty = entityType.resolvePath(annotations.Common.Label['path']);
84
- label = targetProperty.value
85
- ? targetProperty.value
86
- : typeof ((_b = targetProperty.Common) === null || _b === void 0 ? void 0 : _b.Label) === 'string'
87
- ? targetProperty.annotations.Common.Label
88
- : label;
84
+ if (targetProperty.value) {
85
+ label = targetProperty.value;
86
+ }
87
+ else if (typeof ((_b = targetProperty.Common) === null || _b === void 0 ? void 0 : _b.Label) === 'string') {
88
+ label = targetProperty.annotations.Common.Label;
89
+ }
89
90
  }
90
91
  else if (typeof ((_d = (_c = annotations.Common) === null || _c === void 0 ? void 0 : _c.Label) === null || _d === void 0 ? void 0 : _d.toString()) === 'string') {
91
92
  label = annotations.Common.Label.toString();
@@ -102,7 +103,9 @@ exports.evaluateCommonLabel = evaluateCommonLabel;
102
103
  */
103
104
  function getLabelForPropertyPath(propertyPath, entityType) {
104
105
  let label = propertyPath.value;
105
- label = evaluateCommonLabel(propertyPath.$target.annotations, entityType, label);
106
+ if (propertyPath.$target) {
107
+ label = evaluateCommonLabel(propertyPath.$target.annotations, entityType, label);
108
+ }
106
109
  return label;
107
110
  }
108
111
  exports.getLabelForPropertyPath = getLabelForPropertyPath;
@@ -163,6 +166,12 @@ function getLabel(dataFieldLabel, entityType) {
163
166
  return undefined;
164
167
  }
165
168
  }
169
+ function getTitleForDataField(dataField, entityType, dataFieldLabel) {
170
+ const propertyCommonLabel = getLabelForDataField(dataField, entityType);
171
+ return (dataFieldLabel ||
172
+ propertyCommonLabel ||
173
+ (dataField.Value.$target ? dataField.Value.$target.name : dataField.Value.value || dataField.Value.path));
174
+ }
166
175
  /**
167
176
  * Determines the description of a data field, e.g. for the column header
168
177
  * @param dataFieldAbstract - the given record of the line item annotation
@@ -174,13 +183,7 @@ function getDatafieldDescription(dataFieldAbstract, entityType) {
174
183
  switch (dataFieldAbstract.$Type) {
175
184
  case "com.sap.vocabularies.UI.v1.DataField" /* DataField */:
176
185
  dataField = dataFieldAbstract;
177
- propertyCommonLabel = getLabelForDataField(dataFieldAbstract, entityType);
178
- title =
179
- dataFieldLabel ||
180
- propertyCommonLabel ||
181
- (dataField.Value.$target
182
- ? dataField.Value.$target.name
183
- : dataField.Value.value || dataField.Value.path);
186
+ title = getTitleForDataField(dataField, entityType, dataFieldLabel);
184
187
  break;
185
188
  case "com.sap.vocabularies.UI.v1.DataFieldWithUrl" /* DataFieldWithUrl */:
186
189
  dataField = dataFieldAbstract;
@@ -212,13 +215,7 @@ function getDatafieldDescription(dataFieldAbstract, entityType) {
212
215
  break;
213
216
  case "com.sap.vocabularies.UI.v1.DataFieldWithNavigationPath" /* DataFieldWithNavigationPath */:
214
217
  dataField = dataFieldAbstract;
215
- propertyCommonLabel = getLabelForDataField(dataFieldAbstract, entityType);
216
- title =
217
- dataFieldLabel ||
218
- propertyCommonLabel ||
219
- (dataField.Value.$target
220
- ? dataField.Value.$target.name
221
- : dataField.Value.value || dataField.Value.path);
218
+ title = getTitleForDataField(dataField, entityType, dataFieldLabel);
222
219
  break;
223
220
  default:
224
221
  break;
@@ -232,7 +229,8 @@ exports.getDatafieldDescription = getDatafieldDescription;
232
229
  */
233
230
  function getPageTypeV2(name) {
234
231
  if (name) {
235
- return name.split('sap.suite.ui.generic.template.')[1];
232
+ const templatePart = `${v2_1.FE_TEMPLATE_V2}.`;
233
+ return name.split(templatePart)[1];
236
234
  }
237
235
  }
238
236
  exports.getPageTypeV2 = getPageTypeV2;
@@ -263,6 +261,38 @@ function findAlias(namespace, oDataServiceAVT) {
263
261
  return aliasReference === null || aliasReference === void 0 ? void 0 : aliasReference.alias;
264
262
  }
265
263
  exports.findAlias = findAlias;
264
+ /**
265
+ * Determines the target annotation
266
+ * @param navigationParts - parts of the target annotation path
267
+ * @param entityType - entity type
268
+ * @param {ConverterOutput} oDataServiceAVT - complete service information, as returned by annotation vocabularies tool
269
+ * @returns the target annotation
270
+ */
271
+ function determineTargetAnnotation(navigationParts, entityType, oDataServiceAVT) {
272
+ var _a;
273
+ const lastNavigationPart = navigationParts[navigationParts.length - 1];
274
+ const annotation = lastNavigationPart.substring(lastNavigationPart.lastIndexOf('.') + 1, lastNavigationPart.length);
275
+ const alias = findAlias(lastNavigationPart.substring(0, lastNavigationPart.lastIndexOf('.')).replace('@', ''), oDataServiceAVT);
276
+ return (_a = entityType === null || entityType === void 0 ? void 0 : entityType.annotations[alias]) === null || _a === void 0 ? void 0 : _a[annotation];
277
+ }
278
+ /**
279
+ * Adjust key by considering navigation
280
+ * @param key - given key
281
+ * @param keyForRelatedFacetKeys - construct key for 'keyForRelatedFacetKeys' property(used to define custom sections) - we should not add '@' symbol there.
282
+ * @param navigationParts - parts of the target annotation path
283
+ */
284
+ function adjustKey(key, navigationParts, keyForRelatedFacetKeys) {
285
+ const uiParts = (navigationParts[1] || navigationParts[0]).split('#');
286
+ const uiClass = uiParts[0];
287
+ if (uiClass.includes('.LineItem')) {
288
+ const pathParts = key.split('::');
289
+ pathParts[pathParts.length - 1] = `${!keyForRelatedFacetKeys ? '@' : ''}${"com.sap.vocabularies.UI.v1.LineItem" /* LineItem */}`;
290
+ key = pathParts.join('::');
291
+ }
292
+ else {
293
+ key = uiClass.replace('@UI', `${!keyForRelatedFacetKeys ? '@' : ''}com.sap.vocabularies.UI.v1`);
294
+ }
295
+ }
266
296
  /**
267
297
  * Resolve page section(get key and label->description).
268
298
  * @param facetDefinition - the actual annotation record
@@ -272,14 +302,14 @@ exports.findAlias = findAlias;
272
302
  * @param {ExtensionLogger} logger - Logger class for logging messages
273
303
  * @returns {FacetSection} - object comprising the relevant facet information
274
304
  */
275
- function getSectionFacet(facetDefinition, keyForRelatedFacetKeys = false, oDataVersion = common_1.FioriElementsVersion.v2, sourceEntityType, oDataServiceAVT, logger) {
276
- var _a, _b;
277
- let entityType = sourceEntityType; //default
278
- const facetName = facetDefinition.fullyQualifiedName.substr(facetDefinition.fullyQualifiedName.lastIndexOf('@'));
305
+ function getSectionFacet(facetDefinition, sourceEntityType, oDataServiceAVT, logger, oDataVersion = common_1.FioriElementsVersion.v2, keyForRelatedFacetKeys = false) {
306
+ var _a;
279
307
  //Take facet ID as fallback
308
+ const facetName = facetDefinition.fullyQualifiedName.substr(facetDefinition.fullyQualifiedName.lastIndexOf('@'));
280
309
  let key = facetDefinition.ID ? facetDefinition.ID.toString() : facetName;
310
+ let entityType = sourceEntityType; //default
281
311
  //If reference facet: overwrite with target annotation if present
282
- if (facetDefinition.$Type !== 'com.sap.vocabularies.UI.v1.CollectionFacet' && 'Target' in facetDefinition) {
312
+ if (facetDefinition.$Type !== "com.sap.vocabularies.UI.v1.CollectionFacet" /* CollectionFacet */ && 'Target' in facetDefinition) {
283
313
  const propertyValue = exports.getAnnotationPropertyValue(facetDefinition.Target);
284
314
  if (!propertyValue) {
285
315
  extensionLogger_1.log(logger, {
@@ -288,34 +318,22 @@ function getSectionFacet(facetDefinition, keyForRelatedFacetKeys = false, oDataV
288
318
  });
289
319
  return;
290
320
  }
291
- const navSeparator = oDataVersion === common_1.FioriElementsVersion.v2 ? '::' : '/';
292
- const separator = oDataVersion === common_1.FioriElementsVersion.v2 ? '::' : '#';
293
321
  const navigationParts = propertyValue.split('/');
294
322
  const navigation = navigationParts.length > 1 ? navigationParts[0] : '';
295
323
  if (navigation) {
296
324
  entityType = (_a = sourceEntityType.resolvePath(navigation)) === null || _a === void 0 ? void 0 : _a.targetType;
297
325
  }
298
- const uiParts = (navigationParts[1] || navigationParts[0]).split('#');
299
- const uiClass = uiParts[0];
300
- if (uiClass.includes('.LineItem')) {
301
- const pathParts = key.split('::');
302
- pathParts[pathParts.length - 1] = `${!keyForRelatedFacetKeys ? '@' : ''}com.sap.vocabularies.UI.v1.LineItem`;
303
- key = pathParts.join('::');
304
- }
305
- else {
306
- key = uiClass.replace('@UI', `${!keyForRelatedFacetKeys ? '@' : ''}com.sap.vocabularies.UI.v1`);
307
- }
308
- const lastNavigationPart = navigationParts[navigationParts.length - 1];
309
- const annotation = lastNavigationPart.substring(lastNavigationPart.lastIndexOf('.') + 1, lastNavigationPart.length);
310
- const alias = findAlias(lastNavigationPart.substring(0, lastNavigationPart.lastIndexOf('.')).replace('@', ''), oDataServiceAVT);
311
- const targetAnnotation = (_b = entityType === null || entityType === void 0 ? void 0 : entityType.annotations[alias]) === null || _b === void 0 ? void 0 : _b[annotation];
326
+ adjustKey(key, navigationParts, keyForRelatedFacetKeys);
327
+ const targetAnnotation = determineTargetAnnotation(navigationParts, entityType, oDataServiceAVT);
312
328
  if (targetAnnotation) {
329
+ const separator = oDataVersion === common_1.FioriElementsVersion.v2 ? '::' : '#';
313
330
  key = getTargetAnnotationName(targetAnnotation, keyForRelatedFacetKeys).replace('#', separator);
314
331
  }
315
332
  else {
316
333
  return undefined;
317
334
  }
318
335
  if (navigation) {
336
+ const navSeparator = oDataVersion === common_1.FioriElementsVersion.v2 ? '::' : '/';
319
337
  key = `${navigation}${navSeparator}${key}`;
320
338
  }
321
339
  }
@@ -412,69 +430,59 @@ exports.getSchemaKeyOfLineItemRecord = getSchemaKeyOfLineItemRecord;
412
430
  * @param {FioriElementsVersion} oDataVersion - OData version
413
431
  * @param {ExtensionLogger} logger - Logger class for logging messages
414
432
  */
415
- function evaluateTargetAnnotation(annotationRecord, facets, entityType, oDataServiceAVT, oDataVersion = common_1.FioriElementsVersion.v2, logger) {
416
- var _a, _b, _c, _d, _e;
417
- const alias = findAlias('com.sap.vocabularies.UI.v1', oDataServiceAVT);
418
- const section = getSectionFacet(annotationRecord, false, oDataVersion, entityType, oDataServiceAVT, logger);
419
- if (!section) {
420
- return;
421
- }
433
+ function evaluateTargetAnnotation(section, annotationRecord, facets, entityType, oDataServiceAVT, oDataVersion = common_1.FioriElementsVersion.v2, logger) {
434
+ var _a, _b, _c, _d, _e, _f;
435
+ const alias = findAlias(types_1.UIVOCABULARY, oDataServiceAVT);
422
436
  let path = section ? section.key : '';
423
437
  const targetEntityType = section.entityType;
424
- let version, annotation, targetAnnotation;
425
- let scope = alias;
426
- if (path.includes('com.sap.vocabularies.UI.v1.Chart') || path.includes(alias + '.Chart')) {
438
+ let annotation, targetAnnotation;
439
+ if (path.includes("com.sap.vocabularies.UI.v1.Chart" /* Chart */) || path.includes(alias + '.Chart')) {
427
440
  facets[path] = { base: types_1.FacetBase.Chart };
428
- facets[path]['entityType'] = targetEntityType;
441
+ facets[path].entityType = targetEntityType;
429
442
  }
430
- else if (path.includes('com.sap.vocabularies.UI.v1.Identification') || path.includes(alias + '.Identification')) {
443
+ else if (path.includes("com.sap.vocabularies.UI.v1.Identification" /* Identification */) || path.includes(alias + '.Identification')) {
431
444
  annotation = path.split('.')[path.split('.').length - 1];
432
- targetAnnotation = targetEntityType.annotations[scope][annotation];
445
+ targetAnnotation = targetEntityType.annotations[alias][annotation];
433
446
  facets[path] = { base: types_1.FacetBase.Identification };
434
- facets[path]['entityType'] = targetEntityType;
435
- facets[path]['target'] = targetAnnotation;
447
+ facets[path].entityType = targetEntityType;
448
+ facets[path].target = targetAnnotation;
436
449
  }
437
- else if (path.includes('com.sap.vocabularies.UI.v1.LineItem') || path.includes(alias + '.LineItem')) {
438
- if (entityType) {
439
- if (path.includes('com.sap.vocabularies.UI.v1.LineItem')) {
440
- [scope, version, annotation] = path.split('com.sap.vocabularies.')[1].split('.');
441
- }
442
- else if (path.includes('.LineItem')) {
443
- annotation = 'LineItem';
444
- const pathParts = path.split('::');
445
- pathParts[pathParts.length - 1] = '@com.sap.vocabularies.UI.v1.LineItem';
446
- path = pathParts.join('::');
447
- }
448
- facets[path] = { base: types_1.FacetBase.LineItem };
449
- facets[path]['lineItem'] = (_a = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _a === void 0 ? void 0 : _a.$target;
450
- facets[path]['entityType'] = targetEntityType;
450
+ else if (entityType && (path.includes("com.sap.vocabularies.UI.v1.LineItem" /* LineItem */) || path.includes(alias + '.LineItem'))) {
451
+ if (!path.includes("com.sap.vocabularies.UI.v1.LineItem" /* LineItem */) && path.includes('.LineItem')) {
452
+ const pathParts = path.split('::');
453
+ pathParts[pathParts.length - 1] = `@${"com.sap.vocabularies.UI.v1.LineItem" /* LineItem */}`;
454
+ path = pathParts.join('::');
451
455
  }
456
+ facets[path] = { base: types_1.FacetBase.LineItem };
457
+ facets[path].target = (_a = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _a === void 0 ? void 0 : _a.$target;
458
+ facets[path].entityType = targetEntityType;
452
459
  }
453
- else if (path.includes('com.sap.vocabularies.UI.v1.FieldGroup') || path.includes(alias + '.FieldGroup')) {
460
+ else if (path.includes("com.sap.vocabularies.UI.v1.FieldGroup" /* FieldGroup */) || path.includes(alias + '.FieldGroup')) {
454
461
  facets[path] = { base: types_1.FacetBase.Form };
455
- facets[path]['target'] = (_b = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _b === void 0 ? void 0 : _b.$target;
456
- facets[path]['entityType'] = targetEntityType;
462
+ facets[path].target = (_b = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _b === void 0 ? void 0 : _b.$target;
463
+ facets[path].entityType = targetEntityType;
457
464
  }
458
- else if (path.includes('com.sap.vocabularies.UI.v1.DataPoint') || path.includes(alias + '.DataPoint')) {
465
+ else if (path.includes("com.sap.vocabularies.UI.v1.DataPoint" /* DataPoint */) || path.includes(alias + '.DataPoint')) {
459
466
  facets[path] = { base: types_1.FacetBase.DataPoint };
460
467
  facets[path].target = (_c = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _c === void 0 ? void 0 : _c.$target;
461
- facets[path]['entityType'] = targetEntityType;
468
+ facets[path].entityType = targetEntityType;
469
+ facets[path].Label = (_d = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _d === void 0 ? void 0 : _d.$target['Title'];
462
470
  }
463
471
  else if (path.includes('com.sap.vocabularies.Communication.v1.Contact') || path.includes(alias + '.Contact')) {
464
472
  facets[path] = { base: types_1.FacetBase.Contact };
465
- facets[path].target = (_d = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _d === void 0 ? void 0 : _d.$target;
466
- facets[path]['entityType'] = targetEntityType;
473
+ facets[path].target = (_e = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _e === void 0 ? void 0 : _e.$target;
474
+ facets[path].entityType = targetEntityType;
467
475
  }
468
476
  else if (path.includes('com.sap.vocabularies.Communication.v1.Address') || path.includes(alias + '.Address')) {
469
477
  facets[path] = { base: types_1.FacetBase.Address };
470
- facets[path].target = (_e = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _e === void 0 ? void 0 : _e.$target;
471
- facets[path]['entityType'] = targetEntityType;
478
+ facets[path].target = (_f = annotationRecord === null || annotationRecord === void 0 ? void 0 : annotationRecord.Target) === null || _f === void 0 ? void 0 : _f.$target;
479
+ facets[path].entityType = targetEntityType;
472
480
  }
473
481
  else {
474
482
  facets[path] = { base: types_1.FacetBase.Unknown };
475
483
  }
476
484
  if (facets[path]) {
477
- facets[path].annotationPath = `/${annotationRecord.fullyQualifiedName.replace('@com.sap.vocabularies', '/@com.sap.vocabularies')}`;
485
+ facets[path].annotationPath = `/${annotationRecord.fullyQualifiedName.replace('@com.sap.vocabularies', types_1.VOCWITHSLASH)}`;
478
486
  if (annotationRecord.Label) {
479
487
  facets[path].Label = annotationRecord.Label;
480
488
  }
@@ -505,14 +513,14 @@ function evaluateTargetAnnotation(annotationRecord, facets, entityType, oDataSer
505
513
  */
506
514
  function addFacetToConfig(annotationRecord, oDataServiceAVT, serviceName, entityType, facets, oDataVersion = common_1.FioriElementsVersion.v2, logger) {
507
515
  var _a;
508
- switch (annotationRecord.$Type) {
509
- case "com.sap.vocabularies.UI.v1.ReferenceFacet" /* ReferenceFacet */: {
510
- evaluateTargetAnnotation(annotationRecord, facets, entityType, oDataServiceAVT, oDataVersion, logger);
511
- break;
512
- }
513
- case "com.sap.vocabularies.UI.v1.CollectionFacet" /* CollectionFacet */: {
514
- const section = getSectionFacet(annotationRecord, false, oDataVersion, entityType, oDataServiceAVT, logger);
515
- if (section) {
516
+ const section = getSectionFacet(annotationRecord, entityType, oDataServiceAVT, logger, oDataVersion, false);
517
+ if (section) {
518
+ switch (annotationRecord.$Type) {
519
+ case "com.sap.vocabularies.UI.v1.ReferenceFacet" /* ReferenceFacet */: {
520
+ evaluateTargetAnnotation(section, annotationRecord, facets, entityType, oDataServiceAVT, oDataVersion, logger);
521
+ break;
522
+ }
523
+ case "com.sap.vocabularies.UI.v1.CollectionFacet" /* CollectionFacet */: {
516
524
  const annotationPath = `/${entityType.fullyQualifiedName}/${annotationRecord.fullyQualifiedName.split(entityType.fullyQualifiedName)[1]}`;
517
525
  const facet = (facets[section.key] = {
518
526
  base: types_1.FacetBase.CollectionFacet,
@@ -524,8 +532,8 @@ function addFacetToConfig(annotationRecord, oDataServiceAVT, serviceName, entity
524
532
  (_a = annotationRecord.Facets) === null || _a === void 0 ? void 0 : _a.forEach((collectionItem) => {
525
533
  addFacetToConfig(collectionItem, oDataServiceAVT, serviceName, entityType, facet.facets, oDataVersion, logger);
526
534
  });
535
+ break;
527
536
  }
528
- break;
529
537
  }
530
538
  }
531
539
  }
@@ -541,7 +549,7 @@ function getObjectPageHeaderFacets(entityType, oDataServiceAVT, oDataVersion = c
541
549
  if (!entityType || !entityType.annotations) {
542
550
  return;
543
551
  }
544
- const alias = findAlias('com.sap.vocabularies.UI.v1', oDataServiceAVT);
552
+ const alias = findAlias(types_1.UIVOCABULARY, oDataServiceAVT);
545
553
  const facetAnnotation = alias && entityType.annotations[alias] && entityType.annotations[alias].HeaderFacets;
546
554
  if (facetAnnotation) {
547
555
  const lastDot = entityType.fullyQualifiedName.lastIndexOf('.');
@@ -566,7 +574,7 @@ function getObjectPageFacets(entityType, oDataServiceAVT, oDataVersion = common_
566
574
  if (!entityType || !entityType.annotations) {
567
575
  return;
568
576
  }
569
- const alias = findAlias('com.sap.vocabularies.UI.v1', oDataServiceAVT);
577
+ const alias = findAlias(types_1.UIVOCABULARY, oDataServiceAVT);
570
578
  const facetAnnotation = alias && entityType.annotations[alias] && entityType.annotations[alias].Facets;
571
579
  if (facetAnnotation) {
572
580
  const lastDot = entityType.fullyQualifiedName.lastIndexOf('.');
@@ -592,62 +600,106 @@ function getVersionFromManifest(manifest) {
592
600
  }
593
601
  }
594
602
  exports.getVersionFromManifest = getVersionFromManifest;
595
- function getTemplateTypeFromManifest(manifest, fioriElementsVersion, logger) {
603
+ /**
604
+ * Determines the template type of a V2 app
605
+ * @param manifest - the manifest.json file
606
+ * @param {ExtensionLogger} logger - Logger class for logging messages
607
+ * @returns {TemplateType} the template type
608
+ */
609
+ function determineV2Template(manifest, logger) {
596
610
  let templateType;
597
- if (manifest[common_1.ManifestSection.ovp]) {
598
- templateType = TemplateType.OverviewPageV2;
599
- }
600
- else if (fioriElementsVersion === common_1.FioriElementsVersion.v2) {
601
- if (manifest[common_1.ManifestSection.generic]) {
602
- const v2Pages = manifest[common_1.ManifestSection.generic].pages;
603
- if (!v2Pages) {
604
- extensionLogger_1.log(logger, {
605
- severity: "error" /* Error */,
606
- message: i18next_1.default.t('NOPAGES', { appId: manifest['sap.app']['id'] }),
607
- location: {
608
- path: types_1.MANIFESTPATH,
609
- range: [common_1.ManifestSection.generic]
610
- }
611
- });
612
- return;
613
- }
614
- for (const pageKey in v2Pages) {
615
- const v2Page = v2Pages[pageKey];
616
- if (getPageTypeV2(v2Page.component.name) === common_1.PageType.AnalyticalListPage) {
617
- templateType = TemplateType.AnalyticalListPageV2;
618
- break;
619
- }
620
- else if (getPageTypeV2(v2Page.component.name) === common_1.PageType.ListReport) {
621
- templateType = TemplateType.ListReportObjectPageV2;
622
- break;
611
+ if (manifest[common_1.ManifestSection.generic]) {
612
+ const v2Pages = manifest[common_1.ManifestSection.generic].pages;
613
+ if (!v2Pages) {
614
+ extensionLogger_1.log(logger, {
615
+ severity: "error" /* Error */,
616
+ message: i18next_1.default.t('NOPAGES', { appId: manifest['sap.app']['id'] }),
617
+ location: {
618
+ path: types_1.MANIFESTPATH,
619
+ range: [common_1.ManifestSection.generic]
623
620
  }
624
- }
621
+ });
622
+ return;
625
623
  }
626
- else {
627
- if (!templateType) {
628
- extensionLogger_1.log(logger, {
629
- severity: "error" /* Error */,
630
- message: i18next_1.default.t('NOTEMPLATE', { section: common_1.ManifestSection.generic }),
631
- location: {
632
- path: types_1.MANIFESTPATH,
633
- range: [common_1.ManifestSection.generic]
634
- }
635
- });
624
+ for (const pageKey in v2Pages) {
625
+ const v2Page = v2Pages[pageKey];
626
+ if (getPageTypeV2(v2Page.component.name) === common_1.PageType.AnalyticalListPage) {
627
+ templateType = TemplateType.AnalyticalListPageV2;
628
+ break;
629
+ }
630
+ else if (getPageTypeV2(v2Page.component.name) === common_1.PageType.ListReport) {
631
+ templateType = TemplateType.ListReportObjectPageV2;
632
+ break;
636
633
  }
637
634
  }
638
635
  }
639
636
  else {
640
- templateType = TemplateType.ListReportObjectPageV4;
637
+ if (!templateType) {
638
+ extensionLogger_1.log(logger, {
639
+ severity: "error" /* Error */,
640
+ message: i18next_1.default.t('NOTEMPLATE', { section: common_1.ManifestSection.generic }),
641
+ location: {
642
+ path: types_1.MANIFESTPATH,
643
+ range: [common_1.ManifestSection.generic]
644
+ }
645
+ });
646
+ }
647
+ }
648
+ return templateType;
649
+ }
650
+ exports.determineV2Template = determineV2Template;
651
+ /**
652
+ * Determines the template type, based on the given manifest entries of the app
653
+ * @param manifest - the manifest.json file
654
+ * @param {FioriElementsVersion} fioriElementsVersion - OData or FE version
655
+ * @param {ExtensionLogger} logger - Logger class for logging messages
656
+ * @returns {TemplateType} the template type
657
+ */
658
+ function getTemplateTypeFromManifest(manifest, fioriElementsVersion, logger) {
659
+ let templateType;
660
+ if (manifest[common_1.ManifestSection.ovp]) {
661
+ templateType = TemplateType.OverviewPageV2;
662
+ }
663
+ else if (fioriElementsVersion === common_1.FioriElementsVersion.v2) {
664
+ templateType = determineV2Template(manifest, logger);
641
665
  }
642
666
  return templateType;
643
667
  }
644
668
  exports.getTemplateTypeFromManifest = getTemplateTypeFromManifest;
669
+ /**
670
+ * Adds title and description to a section or header section in an app schema
671
+ * @param facet - intermediate facet structure comprising annotation information
672
+ * @param section - section in the app schema
673
+ * @param facetKey - key of the facet
674
+ */
675
+ function addSectionTitleAndDescription(facet, section, facetKey) {
676
+ if (facet === null || facet === void 0 ? void 0 : facet.ID) {
677
+ section['title'] = types_1.FacetTitlePrefix + facet.ID;
678
+ }
679
+ else {
680
+ section['title'] = facetKey.substr(facetKey.lastIndexOf('.') + 1);
681
+ }
682
+ // Description
683
+ if (facet === null || facet === void 0 ? void 0 : facet.Label) {
684
+ section['description'] = facet.Label;
685
+ }
686
+ else if (facet === null || facet === void 0 ? void 0 : facet.ID) {
687
+ section['description'] = facet.ID;
688
+ }
689
+ else {
690
+ section['description'] = facetKey.substr(facetKey.lastIndexOf('.') + 1);
691
+ }
692
+ }
693
+ exports.addSectionTitleAndDescription = addSectionTitleAndDescription;
645
694
  /**
646
695
  * Creates a default object for a new section or subsection, and adds the ID as title if present.
647
696
  * @param facet Facet configuration, to be analyzed
648
697
  * @returns the new section object
649
698
  */
650
- function createSectionWithoutProperties(facet) {
699
+ function createSectionWithoutProperties(facet, facetKey) {
700
+ if (!facet) {
701
+ return undefined;
702
+ }
651
703
  const section = {
652
704
  type: 'object',
653
705
  properties: {},
@@ -655,12 +707,7 @@ function createSectionWithoutProperties(facet) {
655
707
  annotationPath: facet.annotationPath,
656
708
  isViewNode: true
657
709
  };
658
- if (facet && facet.ID) {
659
- section['title'] = types_1.FacetTitlePrefix + facet.ID;
660
- }
661
- if (facet && facet.Label) {
662
- section['description'] = facet.Label;
663
- }
710
+ addSectionTitleAndDescription(facet, section, facetKey);
664
711
  return section;
665
712
  }
666
713
  exports.createSectionWithoutProperties = createSectionWithoutProperties;
@@ -674,22 +721,23 @@ exports.createSectionWithoutProperties = createSectionWithoutProperties;
674
721
  * @returns {FacetSection[]} - Array of facets or sections
675
722
  */
676
723
  function getObjectPageFacetSection(entityType, oDataServiceAVT, logger, oDataVersion = common_1.FioriElementsVersion.v2, checkUnresolvableFacets = false) {
677
- const alias = findAlias('com.sap.vocabularies.UI.v1', oDataServiceAVT);
724
+ const alias = findAlias(types_1.UIVOCABULARY, oDataServiceAVT);
725
+ let sections = [];
678
726
  if (entityType) {
679
727
  const facetAnnotation = alias && entityType.annotations && entityType.annotations[alias] && entityType.annotations[alias].Facets;
680
- if (!facetAnnotation) {
681
- return [];
682
- }
683
- return facetAnnotation.reduce(function (result, item) {
684
- if (checkUnresolvableFacets && !item['ID'] && !('Target' in item && item['Target'])) {
728
+ if (facetAnnotation) {
729
+ sections = facetAnnotation.reduce(function (result, item) {
730
+ if (checkUnresolvableFacets && !item['ID'] && !('Target' in item && item['Target'])) {
731
+ return result;
732
+ }
733
+ const section = getSectionFacet(item, entityType, oDataServiceAVT, logger, oDataVersion, true);
734
+ if (section) {
735
+ result.push(section);
736
+ }
685
737
  return result;
686
- }
687
- const section = getSectionFacet(item, true, oDataVersion, entityType, oDataServiceAVT, logger);
688
- if (section) {
689
- result.push(section);
690
- }
691
- return result;
692
- }, []);
738
+ }, sections);
739
+ }
740
+ return sections;
693
741
  }
694
742
  }
695
743
  exports.getObjectPageFacetSection = getObjectPageFacetSection;
@@ -795,27 +843,16 @@ function generatePageId(appVersion, pageType, entitySet, navigationProperty, vie
795
843
  }
796
844
  exports.generatePageId = generatePageId;
797
845
  /**
798
- * Recursive function to determine the next config part, next definition in the app schema and the title
799
- * @param appSchema - app schema
800
- * @param title - default title
801
- * @param currentConfigObject - current part of the configuration that gets traversed
802
- * @param propertyDefinition - definition of a given property in the app schema
803
- * @param key - actual key
804
- * @param factory - factory for creating metadata instances
805
- * @param pageType - page type
846
+ * Fills an array of next definitions from given references in the JSON schema
847
+ * @param propertyDefinition - Definition of the current property in schema
848
+ * @param currentConfigObject - Current object in the config JSON. Evaluated to get the right value of a cntrolling property,
849
+ * for making the right choice in case of multiple options (anyOf)
850
+ * @param appSchema - app-spcific JSON schema
851
+ * @returns an array of definitions to proceed with
806
852
  */
807
- function getNextTargetDefinition(appSchema, title, currentConfigObject, propertyDefinition, key, factory, pageType) {
808
- let nextDefinition = {
809
- configObject: undefined,
810
- targetDefinition: {},
811
- title: ''
812
- };
853
+ function fillArrayFromPropertyDefinition(propertyDefinition, currentConfigObject, appSchema) {
813
854
  const definitionArray = [];
814
- if (propertyDefinition['type'] === 'array') {
815
- nextDefinition = getNextTargetDefinition(appSchema, title, currentConfigObject, propertyDefinition['items'], key, factory, pageType);
816
- return nextDefinition;
817
- }
818
- else if (propertyDefinition['$ref']) {
855
+ if (propertyDefinition['$ref']) {
819
856
  definitionArray.push(propertyDefinition['$ref'].split(exports.DEFINITION_LINK_PREFIX)[1]);
820
857
  }
821
858
  else if (propertyDefinition['anyOf']) {
@@ -836,16 +873,38 @@ function getNextTargetDefinition(appSchema, title, currentConfigObject, property
836
873
  return undefined;
837
874
  }
838
875
  }
876
+ return definitionArray;
877
+ }
878
+ /**
879
+ * Determines the next definition to be handled, based on the definition array.
880
+ * It also creates the Metadata instance for the next definition, to subsequently access metadata like the syncRule
881
+ * @param definitionArray - Array of definitions, as determined by fillArrayFromNextDefinition
882
+ * @param appSchema - app-spcific JSON schema
883
+ * @param title - default title
884
+ * @param currentConfigObject - Current object in the config JSON.
885
+ * @param key - actual key
886
+ * @param {MetadataInstanceInterface} factory - factory for creating metadata instances
887
+ * @param pageType - page type
888
+ * @param propertyDefinition - Definition of the current property in schema
889
+ * @returns {NextDefinition} - Next target definition to process
890
+ */
891
+ function determineNextDefinitionFromDefinitionArray(definitionArray, appSchema, title, currentConfigObject, key, factory, pageType, propertyDefinition) {
892
+ let nextDefinition = {
893
+ configObject: undefined,
894
+ targetDefinition: {},
895
+ title: ''
896
+ };
839
897
  if (definitionArray.length) {
840
898
  const lastDefinition = definitionArray[definitionArray.length - 1];
841
899
  nextDefinition.targetDefinition = appSchema['definitions'][lastDefinition];
842
900
  if (nextDefinition.targetDefinition['$ref'] || nextDefinition.targetDefinition['type'] === 'array') {
901
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
843
902
  nextDefinition = getNextTargetDefinition(appSchema, title, currentConfigObject, nextDefinition.targetDefinition, key, factory, pageType);
844
903
  return nextDefinition;
845
904
  }
846
905
  if (definitionArray.length > 1) {
847
906
  definitionArray.forEach((element) => {
848
- if (element != '') {
907
+ if (element !== '') {
849
908
  nextDefinition.targetDefinition['properties'] = Object.assign(Object.assign({}, nextDefinition.targetDefinition['properties']), appSchema['definitions'][element]['properties']);
850
909
  }
851
910
  });
@@ -867,6 +926,29 @@ function getNextTargetDefinition(appSchema, title, currentConfigObject, property
867
926
  }
868
927
  return nextDefinition;
869
928
  }
929
+ /**
930
+ * Recursive function to determine the next config part, next definition in the app schema and the title
931
+ * @param appSchema - app-spcific JSON schema
932
+ * @param title - default title
933
+ * @param currentConfigObject - current part of the configuration that gets traversed
934
+ * @param propertyDefinition - definition of a given property in the app schema
935
+ * @param key - actual key
936
+ * @param {MetadataInstanceInterface} factory - factory for creating metadata instances
937
+ * @param pageType - page type
938
+ */
939
+ function getNextTargetDefinition(appSchema, title, currentConfigObject, propertyDefinition, key, factory, pageType) {
940
+ let nextDefinition;
941
+ if (propertyDefinition['type'] === 'array') {
942
+ nextDefinition = getNextTargetDefinition(appSchema, title, currentConfigObject, propertyDefinition['items'], key, factory, pageType);
943
+ return nextDefinition;
944
+ }
945
+ const definitionArray = fillArrayFromPropertyDefinition(propertyDefinition, currentConfigObject, appSchema);
946
+ if (!definitionArray) {
947
+ return undefined;
948
+ }
949
+ nextDefinition = determineNextDefinitionFromDefinitionArray(definitionArray, appSchema, title, currentConfigObject, key, factory, pageType, propertyDefinition);
950
+ return nextDefinition;
951
+ }
870
952
  exports.getNextTargetDefinition = getNextTargetDefinition;
871
953
  /**
872
954
  * Functions used both by V2 and V4 to add the common definitions for a line item to the app schema