@sap-ux/odata-service-inquirer 2.9.4 → 2.9.7

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.
@@ -64,6 +64,9 @@ function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidat
64
64
  if (prevAnswers?.[systemUrlPromptName]) {
65
65
  const existingBackend = (0, utils_1.isBackendSystemKeyExisting)(utils_1.PromptState.backendSystemsCache, prevAnswers[systemUrlPromptName], client);
66
66
  if (existingBackend) {
67
+ // Prevents further prompts by setting the client to invalid
68
+ // This is a temp workaround until multiple systems with the same url/client key is supported
69
+ sapClientRef.isValid = false;
67
70
  return (0, i18n_1.t)('prompts.validationMessages.backendSystemExistsWarning', {
68
71
  backendName: existingBackend.name
69
72
  });
@@ -31,7 +31,7 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
31
31
  {
32
32
  when: async () => {
33
33
  authRequired = await connectionValidator.isAuthRequired();
34
- return connectionValidator.systemAuthType === 'basic' && authRequired;
34
+ return (connectionValidator.systemAuthType === 'basic' && authRequired && (!sapClient || sapClient.isValid));
35
35
  },
36
36
  type: 'input',
37
37
  name: usernamePromptName,
@@ -43,7 +43,7 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
43
43
  validate: (user) => user?.length > 0
44
44
  },
45
45
  {
46
- when: () => !!(connectionValidator.systemAuthType === 'basic' && authRequired),
46
+ when: () => !!(connectionValidator.systemAuthType === 'basic' && authRequired && (!sapClient || sapClient.isValid)),
47
47
  type: 'password',
48
48
  guiOptions: {
49
49
  mandatory: true,
@@ -58,7 +58,7 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
58
58
  if (!(connectionValidator.validatedUrl &&
59
59
  answers?.[usernamePromptName] &&
60
60
  password &&
61
- (sapClient?.isValid || !sapClient))) {
61
+ (!sapClient || sapClient.isValid))) {
62
62
  return false;
63
63
  }
64
64
  // We may have a previously selected system
@@ -58,18 +58,14 @@ export declare function getNavigationEntityChoices(metadata: ConvertedMetadata,
58
58
  */
59
59
  export declare function filterDraftEnabledEntities(entitySets: EntitySet[]): EntitySet[] | undefined;
60
60
  /**
61
- * Get the default table type based on the template type and previous answers.
61
+ * Get the default table type based on the template type and entity capabilities.
62
62
  *
63
- * @param templateType the template type of the application to be generated from the prompt answers
63
+ * @param templateType the template type of the application to be generated
64
64
  * @param metadata the metadata (edmx) string of the service
65
65
  * @param odataVersion the OData version of the service
66
66
  * @param isCapService whether the service is a CAP service or not
67
67
  * @param mainEntitySetName the name of the main entity set
68
- * @param currentTableType the current table type selected by the user
69
- * @returns the default table type and a boolean indicating if AnalyticalTable should be set as default
68
+ * @returns the optimal table type for the given entity
70
69
  */
71
- export declare function getDefaultTableType(templateType: TemplateType, metadata: ConvertedMetadata, odataVersion: OdataVersion, isCapService: boolean, mainEntitySetName?: string, currentTableType?: TableType): {
72
- tableType: TableType;
73
- setAnalyticalTableDefault: boolean;
74
- };
70
+ export declare function getDefaultTableType(templateType: TemplateType, metadata: ConvertedMetadata, odataVersion: OdataVersion, isCapService: boolean, mainEntitySetName?: string): TableType;
75
71
  //# sourceMappingURL=entity-helper.d.ts.map
@@ -184,8 +184,8 @@ function filterDraftEnabledEntities(entitySets) {
184
184
  /**
185
185
  * Determines if AnalyticalTable should be used based on entity annotations and service type.
186
186
  *
187
- * AnalyticalTable is used when entity has hierarchical and analytical data together, for CAP services with analytical data,
188
- * or for non-CAP services with complete analytical transformations.
187
+ * AnalyticalTable is used when entity has hierarchical and analytical data together with complete transformations,
188
+ * for CAP services with analytical data, or for non-CAP services with complete analytical transformations.
189
189
  *
190
190
  * @param entitySet The entity set to check for annotations.
191
191
  * @param isCapService Whether the service is a CAP service (affects analytical requirements).
@@ -199,9 +199,14 @@ function shouldUseAnalyticalTable(entitySet, isCapService) {
199
199
  if (!hasAnalytical) {
200
200
  return false;
201
201
  }
202
- // If entity has both analytical and hierarchical data, always use AnalyticalTable
202
+ // If entity has both analytical and hierarchical data, check requirements based on service type
203
203
  if (hasHierarchy) {
204
- return true;
204
+ // For CAP services, any analytical annotations are sufficient even with hierarchy
205
+ if (isCapService) {
206
+ return true;
207
+ }
208
+ // For non-CAP services, require complete analytical transformations
209
+ return (0, inquirer_common_1.hasAggregateTransformationsForEntitySet)(entitySet, inquirer_common_1.transformationsRequiredForAnalyticalTable);
205
210
  }
206
211
  // For CAP services, analytical annotations are sufficient
207
212
  if (isCapService) {
@@ -211,63 +216,37 @@ function shouldUseAnalyticalTable(entitySet, isCapService) {
211
216
  return (0, inquirer_common_1.hasAggregateTransformationsForEntitySet)(entitySet, inquirer_common_1.transformationsRequiredForAnalyticalTable);
212
217
  }
213
218
  /**
214
- * Get the default table type based on the template type and previous answers.
219
+ * Get the default table type based on the template type and entity capabilities.
215
220
  *
216
- * @param templateType the template type of the application to be generated from the prompt answers
221
+ * @param templateType the template type of the application to be generated
217
222
  * @param metadata the metadata (edmx) string of the service
218
223
  * @param odataVersion the OData version of the service
219
224
  * @param isCapService whether the service is a CAP service or not
220
225
  * @param mainEntitySetName the name of the main entity set
221
- * @param currentTableType the current table type selected by the user
222
- * @returns the default table type and a boolean indicating if AnalyticalTable should be set as default
226
+ * @returns the optimal table type for the given entity
223
227
  */
224
- function getDefaultTableType(templateType, metadata, odataVersion, isCapService, mainEntitySetName, currentTableType) {
225
- let tableType;
226
- let setAnalyticalTableDefault = false;
228
+ function getDefaultTableType(templateType, metadata, odataVersion, isCapService, mainEntitySetName) {
227
229
  // Find the entity set once for all annotation checks
228
230
  const entitySet = mainEntitySetName ? (0, inquirer_common_1.findEntitySetByName)(metadata, mainEntitySetName) : undefined;
229
- if (entitySet) {
230
- if ((templateType === 'lrop' || templateType === 'worklist') &&
231
- odataVersion === odata_service_writer_1.OdataVersion.v4 &&
232
- shouldUseAnalyticalTable(entitySet, isCapService)) {
233
- // Use AnalyticalTable for entities with analytical data based on optimized annotation evaluation
234
- tableType = 'AnalyticalTable';
235
- setAnalyticalTableDefault = true;
236
- }
237
- else if ((templateType === 'lrop' || templateType === 'worklist') &&
238
- odataVersion === odata_service_writer_1.OdataVersion.v4 &&
239
- (0, inquirer_common_1.hasRecursiveHierarchyForEntitySet)(entitySet)) {
240
- // If the main entity type is annotated with Hierarchy.RecursiveHierarchy, use TreeTable as default
241
- tableType = 'TreeTable';
242
- }
243
- else if (templateType === 'alp') {
244
- // For ALP, use AnalyticalTable as default
245
- tableType = 'AnalyticalTable';
246
- }
247
- else if (currentTableType) {
248
- // If the user has already selected a table type use it
249
- tableType = currentTableType;
231
+ // Handle ALP template with OData v2 - always use AnalyticalTable
232
+ if (templateType === 'alp' && odataVersion === odata_service_writer_1.OdataVersion.v2) {
233
+ return 'AnalyticalTable';
234
+ }
235
+ // Handle OData v4 specific logic
236
+ if (odataVersion === odata_service_writer_1.OdataVersion.v4 && entitySet) {
237
+ const canUseAnalytical = templateType === 'lrop' || templateType === 'worklist' || templateType === 'alp';
238
+ const hasAnalyticalCapabilities = shouldUseAnalyticalTable(entitySet, isCapService);
239
+ const hasHierarchy = (0, inquirer_common_1.hasRecursiveHierarchyForEntitySet)(entitySet);
240
+ // Check for analytical data requirements
241
+ if (canUseAnalytical && hasAnalyticalCapabilities) {
242
+ return 'AnalyticalTable';
250
243
  }
251
- else {
252
- // Default to ResponsiveTable for other cases
253
- tableType = 'ResponsiveTable';
244
+ // Check for hierarchical data requirements
245
+ if ((templateType === 'lrop' || templateType === 'worklist') && hasHierarchy) {
246
+ return 'TreeTable';
254
247
  }
255
248
  }
256
- else if (templateType === 'alp') {
257
- // For ALP, use AnalyticalTable as default even if entity set is not found
258
- tableType = 'AnalyticalTable';
259
- }
260
- else if (currentTableType) {
261
- // If the user has already selected a table type use it
262
- tableType = currentTableType;
263
- }
264
- else {
265
- // Default to ResponsiveTable for other cases
266
- tableType = 'ResponsiveTable';
267
- }
268
- return {
269
- tableType,
270
- setAnalyticalTableDefault
271
- };
249
+ // Default fallback to ResponsiveTable
250
+ return 'ResponsiveTable';
272
251
  }
273
252
  //# sourceMappingURL=entity-helper.js.map
@@ -200,7 +200,9 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metad
200
200
  }
201
201
  const tableLayoutQuestions = [];
202
202
  if (templateType === 'lrop' || templateType === 'worklist' || templateType === 'alp') {
203
+ // Variables to manage analytical table defaults across prompts
203
204
  let setAnalyticalTableDefault = false;
205
+ let selectedEntity;
204
206
  tableLayoutQuestions.push({
205
207
  when: (prevAnswers) => !!prevAnswers.mainEntity,
206
208
  type: 'list',
@@ -213,12 +215,22 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metad
213
215
  },
214
216
  choices: tableTypeChoices,
215
217
  default: (prevAnswers) => {
216
- const tableTypeDefault = (0, entity_helper_1.getDefaultTableType)(templateType, metadata, odataVersion, isCapService, prevAnswers?.mainEntity?.entitySetName, prevAnswers?.tableType);
217
- setAnalyticalTableDefault = tableTypeDefault.setAnalyticalTableDefault;
218
- return tableTypeDefault.tableType;
218
+ const currentEntity = prevAnswers?.mainEntity;
219
+ // Only re-evaluate if entity has changed or no previous selection exists
220
+ if (currentEntity?.entitySetName !== selectedEntity?.entitySetName || !prevAnswers?.tableType) {
221
+ const defaultTableType = (0, entity_helper_1.getDefaultTableType)(templateType, metadata, odataVersion, isCapService, currentEntity?.entitySetName);
222
+ // Update tracking variables
223
+ selectedEntity = currentEntity;
224
+ setAnalyticalTableDefault = defaultTableType === 'AnalyticalTable';
225
+ return defaultTableType;
226
+ }
227
+ // Entity hasn't changed and user has a selection - preserve their choice
228
+ // Reset the analytical table default flag since this is user's choice, not system default
229
+ setAnalyticalTableDefault = false;
230
+ return prevAnswers.tableType;
219
231
  },
220
- additionalMessages: (tableType) => {
221
- if (tableType === 'AnalyticalTable' && setAnalyticalTableDefault) {
232
+ additionalMessages: () => {
233
+ if (setAnalyticalTableDefault) {
222
234
  return {
223
235
  message: (0, i18n_1.t)('prompts.tableType.analyticalTableDefault'),
224
236
  severity: yeoman_ui_types_1.Severity.information
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.9.4",
4
+ "version": "2.9.7",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,15 +30,15 @@
30
30
  "inquirer-autocomplete-prompt": "2.0.1",
31
31
  "os-name": "4.0.1",
32
32
  "@sap-ux/axios-extension": "1.23.0",
33
- "@sap-ux/fiori-generator-shared": "0.13.26",
34
33
  "@sap-ux/btp-utils": "1.1.4",
34
+ "@sap-ux/fiori-generator-shared": "0.13.27",
35
35
  "@sap-ux/guided-answers-helper": "0.4.0",
36
- "@sap-ux/telemetry": "0.6.31",
37
- "@sap-ux/inquirer-common": "0.8.3",
36
+ "@sap-ux/telemetry": "0.6.32",
37
+ "@sap-ux/inquirer-common": "0.8.5",
38
38
  "@sap-ux/logger": "0.7.0",
39
39
  "@sap-ux/nodejs-utils": "0.2.7",
40
- "@sap-ux/project-access": "1.32.5",
41
- "@sap-ux/project-input-validator": "0.6.27",
40
+ "@sap-ux/project-access": "1.32.6",
41
+ "@sap-ux/project-input-validator": "0.6.28",
42
42
  "@sap-ux/store": "1.2.1"
43
43
  },
44
44
  "devDependencies": {
@@ -48,12 +48,12 @@
48
48
  "@types/inquirer": "8.2.6",
49
49
  "@types/lodash": "4.14.202",
50
50
  "jest-extended": "6.0.0",
51
- "@sap-ux/fiori-generator-shared": "0.13.26",
52
- "@sap-ux/fiori-elements-writer": "2.7.27",
53
- "@sap-ux/fiori-freestyle-writer": "2.4.54",
51
+ "@sap-ux/fiori-generator-shared": "0.13.27",
52
+ "@sap-ux/fiori-elements-writer": "2.7.28",
53
+ "@sap-ux/fiori-freestyle-writer": "2.4.55",
54
54
  "@sap-ux/feature-toggle": "0.3.2",
55
- "@sap-ux/odata-service-writer": "0.27.26",
56
- "@sap-ux/cap-config-writer": "0.12.17"
55
+ "@sap-ux/odata-service-writer": "0.27.27",
56
+ "@sap-ux/cap-config-writer": "0.12.18"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20.x"