@sap-ux/odata-service-inquirer 2.5.20 → 2.5.22

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.
@@ -49,6 +49,14 @@ export declare function getEntityChoices(edmx: string, { entitySetFilter, defaul
49
49
  * @returns the navigation entity choices
50
50
  */
51
51
  export declare function getNavigationEntityChoices(metadata: ConvertedMetadata, odataVersion: OdataVersion, mainEntityName: string): ListChoiceOptions<NavigationEntityAnswer>[];
52
+ /**
53
+ * Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
54
+ * This can be found within the entity set annotations or the entity type annotations.
55
+ *
56
+ * @param entitySets the entity sets to filter
57
+ * @returns the filtered entity sets
58
+ */
59
+ export declare function filterAggregateTransformations(entitySets: EntitySet[]): EntitySet[];
52
60
  /**
53
61
  * Returns only entities that have a type property of 'HasDraftEnabled'.
54
62
  *
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getEntityChoices = getEntityChoices;
7
7
  exports.getNavigationEntityChoices = getNavigationEntityChoices;
8
+ exports.filterAggregateTransformations = filterAggregateTransformations;
8
9
  exports.filterDraftEnabledEntities = filterDraftEnabledEntities;
9
10
  const annotation_converter_1 = require("@sap-ux/annotation-converter");
10
11
  const edmx_parser_1 = require("@sap-ux/edmx-parser");
@@ -131,7 +131,7 @@ function getEntitySelectionQuestions(metadata, templateType, isCapService = fals
131
131
  }
132
132
  entityQuestions.push(...getAddAnnotationQuestions(metadata, templateType, odataVersion, isCapService));
133
133
  if (!promptOptions?.hideTableLayoutPrompts) {
134
- entityQuestions.push(...getTableLayoutQuestions(templateType, odataVersion, isCapService));
134
+ entityQuestions.push(...getTableLayoutQuestions(templateType, odataVersion, isCapService, convertedMetadata));
135
135
  }
136
136
  if (templateType === 'alp') {
137
137
  entityQuestions.push(...(0, alp_questions_1.getAnalyticListPageQuestions)(odataVersion, annotations, promptOptions?.hideTableLayoutPrompts));
@@ -144,9 +144,10 @@ function getEntitySelectionQuestions(metadata, templateType, isCapService = fals
144
144
  * @param templateType used to determine if the tree table option should be included
145
145
  * @param odataVersion used to determine if the hierarchy qualifier is required when the selected table type is TreeTable
146
146
  * @param isCapService used to determine if the tree table option should be included
147
+ * @param metadata the metadata (edmx) string of the service
147
148
  * @returns the table layout questions
148
149
  */
149
- function getTableLayoutQuestions(templateType, odataVersion, isCapService) {
150
+ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metadata) {
150
151
  const tableTypeChoices = [
151
152
  { name: (0, i18n_1.t)('prompts.tableType.choiceAnalytical'), value: 'AnalyticalTable' },
152
153
  { name: (0, i18n_1.t)('prompts.tableType.choiceGrid'), value: 'GridTable' },
@@ -157,7 +158,7 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService) {
157
158
  }
158
159
  const tableLayoutQuestions = [];
159
160
  if (templateType === 'lrop' || templateType === 'worklist' || templateType === 'alp') {
160
- const tableTypeDefault = templateType === 'alp' ? 'AnalyticalTable' : 'ResponsiveTable';
161
+ let setAnalyticalTableDefault = false;
161
162
  tableLayoutQuestions.push({
162
163
  when: (prevAnswers) => !!prevAnswers.mainEntity,
163
164
  type: 'list',
@@ -165,10 +166,23 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService) {
165
166
  message: (0, i18n_1.t)('prompts.tableType.message'),
166
167
  guiOptions: {
167
168
  hint: (0, i18n_1.t)('prompts.tableType.hint'),
168
- breadcrumb: true
169
+ breadcrumb: true,
170
+ applyDefaultWhenDirty: true // set table type on entity selection change
169
171
  },
170
172
  choices: tableTypeChoices,
171
- default: tableTypeDefault
173
+ default: (prevAnswers) => {
174
+ const tableTypeDefault = getDefaultTableType(templateType, metadata, odataVersion, prevAnswers?.mainEntity?.entitySetName, prevAnswers?.tableType);
175
+ setAnalyticalTableDefault = tableTypeDefault.setAnalyticalTableDefault;
176
+ return tableTypeDefault.tableType;
177
+ },
178
+ additionalMessages: (tableType) => {
179
+ if (tableType === 'AnalyticalTable' && setAnalyticalTableDefault) {
180
+ return {
181
+ message: (0, i18n_1.t)('prompts.tableType.analyticalTableDefault'),
182
+ severity: yeoman_ui_types_1.Severity.information
183
+ };
184
+ }
185
+ }
172
186
  });
173
187
  tableLayoutQuestions.push({
174
188
  when: (prevAnswers) => prevAnswers?.tableType === 'TreeTable' && odataVersion === odata_service_writer_1.OdataVersion.v4,
@@ -204,6 +218,56 @@ function getEdmxSizeInKb(edmx) {
204
218
  }
205
219
  return 0;
206
220
  }
221
+ /**
222
+ * Get the default table type based on the template type and previous answers.
223
+ *
224
+ * @param templateType the template type of the application to be generated from the prompt answers
225
+ * @param metadata the metadata (edmx) string of the service
226
+ * @param odataVersion the OData version of the service
227
+ * @param mainEntitySetName the name of the main entity set
228
+ * @param currentTableType the current table type selected by the user
229
+ * @returns the default table type and a boolean indicating if AnalyticalTable should be set as default
230
+ */
231
+ function getDefaultTableType(templateType, metadata, odataVersion, mainEntitySetName, currentTableType) {
232
+ let tableType;
233
+ let setAnalyticalTableDefault = false;
234
+ if ((templateType === 'lrop' || templateType === 'worklist') &&
235
+ odataVersion === odata_service_writer_1.OdataVersion.v4 &&
236
+ hasAggregateTransformationsForEntity(metadata, mainEntitySetName)) {
237
+ // For V4, if the selected entity has aggregate transformations, use AnalyticalTable as default
238
+ tableType = 'AnalyticalTable';
239
+ setAnalyticalTableDefault = true;
240
+ }
241
+ else if (templateType === 'alp') {
242
+ // For ALP, use AnalyticalTable as default
243
+ tableType = 'AnalyticalTable';
244
+ }
245
+ else if (currentTableType) {
246
+ // If the user has already selected a table type use it
247
+ tableType = currentTableType;
248
+ }
249
+ else {
250
+ // Default to ResponsiveTable for other cases
251
+ tableType = 'ResponsiveTable';
252
+ }
253
+ return {
254
+ tableType,
255
+ setAnalyticalTableDefault
256
+ };
257
+ }
258
+ /**
259
+ * Checks if the given entity set name has aggregate transformations in the metadata.
260
+ *
261
+ * @param metadata The metadata (edmx) string of the service.
262
+ * @param entitySetName The entity set name to check for aggregate transformations.
263
+ * @returns true if the entity set has aggregate transformations, false otherwise.
264
+ */
265
+ function hasAggregateTransformationsForEntity(metadata, entitySetName) {
266
+ if (!entitySetName) {
267
+ return false;
268
+ }
269
+ return (0, entity_helper_1.filterAggregateTransformations)(metadata.entitySets).some((entitySet) => entitySet.name === entitySetName);
270
+ }
207
271
  /**
208
272
  * Get the questions that may be used to prompt for adding annotations. Only a subset of the questions will be returned based on the template type and OData version.
209
273
  *
@@ -151,7 +151,8 @@
151
151
  "choiceGrid": "Grid",
152
152
  "choiceAnalytical": "Analytical",
153
153
  "choiceResponsive": "Responsive",
154
- "choiceTree": "Tree"
154
+ "choiceTree": "Tree",
155
+ "analyticalTableDefault": "The 'Analytical' table type is chosen by default because the selected entity supports it."
155
156
  },
156
157
  "hierarchyQualifier": {
157
158
  "message": "Hierarchy Qualifier",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/odata-service-inquirer",
3
3
  "description": "Prompts module that can prompt users for inputs required for odata service writing",
4
- "version": "2.5.20",
4
+ "version": "2.5.22",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,10 +30,10 @@
30
30
  "os-name": "4.0.1",
31
31
  "@sap-ux/axios-extension": "1.22.3",
32
32
  "@sap-ux/btp-utils": "1.1.0",
33
- "@sap-ux/fiori-generator-shared": "0.13.2",
33
+ "@sap-ux/fiori-generator-shared": "0.13.3",
34
34
  "@sap-ux/guided-answers-helper": "0.3.1",
35
35
  "@sap-ux/telemetry": "0.6.10",
36
- "@sap-ux/inquirer-common": "0.7.26",
36
+ "@sap-ux/inquirer-common": "0.7.27",
37
37
  "@sap-ux/logger": "0.7.0",
38
38
  "@sap-ux/nodejs-utils": "0.2.2",
39
39
  "@sap-ux/project-access": "1.30.7",
@@ -47,12 +47,12 @@
47
47
  "@types/inquirer": "8.2.6",
48
48
  "@types/lodash": "4.14.202",
49
49
  "jest-extended": "3.2.4",
50
- "@sap-ux/fiori-generator-shared": "0.13.2",
51
- "@sap-ux/fiori-elements-writer": "2.5.13",
52
- "@sap-ux/fiori-freestyle-writer": "2.4.24",
50
+ "@sap-ux/fiori-generator-shared": "0.13.3",
51
+ "@sap-ux/fiori-elements-writer": "2.5.14",
52
+ "@sap-ux/fiori-freestyle-writer": "2.4.25",
53
53
  "@sap-ux/feature-toggle": "0.3.0",
54
54
  "@sap-ux/odata-service-writer": "0.27.12",
55
- "@sap-ux/cap-config-writer": "0.10.20"
55
+ "@sap-ux/cap-config-writer": "0.10.21"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=20.x"