@sap-ux/odata-service-inquirer 2.15.0 → 2.16.0

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.
@@ -82,20 +82,34 @@ function getEntitySelectionQuestions(metadata, templateType, isCapService = fals
82
82
  name: types_1.EntityPromptNames.mainEntity,
83
83
  message: (0, i18n_1.t)('prompts.mainEntitySelection.message'),
84
84
  guiOptions: {
85
- breadcrumb: true
85
+ breadcrumb: true,
86
+ mandatory: true
86
87
  },
87
88
  choices: entityChoices.choices,
88
89
  source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, entityChoices.choices),
89
90
  default: entityChoices.defaultMainEntityIndex ?? entityChoices.draftRootIndex ?? 0,
90
- validate: () => validateEntityChoices(entityChoices.choices, templateType, odataVersion, isCapService),
91
- additionalMessages: (answers) => {
91
+ // Workaround for YUI bug: Despite mandatory=true, YUI allows users to clear/delete list selections.
92
+ validate: (value) => {
93
+ // First check if there are valid entity choices (handles edge case of no entities in service)
94
+ const entityChoicesValidation = validateEntityChoices(entityChoices.choices, templateType, odataVersion, isCapService);
95
+ if (entityChoicesValidation !== true) {
96
+ return entityChoicesValidation;
97
+ }
98
+ // Then check if a value is selected (user hasn't deleted/cleared the field)
99
+ if (!value) {
100
+ return (0, i18n_1.t)('prompts.mainEntitySelection.requiredError');
101
+ }
102
+ return true;
103
+ },
104
+ additionalMessages: (mainEntityValue) => {
92
105
  if (promptOptions?.defaultMainEntityName && entityChoices.defaultMainEntityIndex === undefined) {
93
106
  return {
94
107
  message: (0, i18n_1.t)('prompts.mainEntitySelection.defaultEntityNameNotFoundWarning'),
95
108
  severity: yeoman_ui_types_1.Severity.warning
96
109
  };
97
110
  }
98
- if (answers.mainEntity?.mainEntityParameterName) {
111
+ // Only check mainEntityValue properties if it exists (handle null/undefined from user deleting the field)
112
+ if (mainEntityValue?.mainEntityParameterName) {
99
113
  // display a warning if the main entity has a mainEntityParameterName
100
114
  return {
101
115
  message: (0, i18n_1.t)('prompts.mainEntitySelection.mainEntityParameterFoundInfo'),
@@ -211,8 +225,16 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metad
211
225
  guiOptions: {
212
226
  hint: (0, i18n_1.t)('prompts.tableType.hint'),
213
227
  breadcrumb: true,
228
+ mandatory: true,
214
229
  applyDefaultWhenDirty: true // set table type on entity selection change
215
230
  },
231
+ // Workaround for YUI bug: Despite mandatory=true, YUI allows clearing mandatory list selections
232
+ validate: (value) => {
233
+ if (!value) {
234
+ return (0, i18n_1.t)('prompts.tableType.requiredError');
235
+ }
236
+ return true;
237
+ },
216
238
  choices: tableTypeChoices,
217
239
  default: (prevAnswers) => {
218
240
  const currentEntity = prevAnswers?.mainEntity;
@@ -140,7 +140,8 @@
140
140
  "noDraftEnabledEntitiesError": "The CAP service you have chosen does not have any entities that are draft enabled. To generate an OData V4 SAP Fiori application using this floorplan for a CAP project, the entity selected must be draft enabled.",
141
141
  "mainEntityParameterFoundInfo": "The selected entity '{{entityName}}' requires a parameter which is set by the application filters. Navigation entities are not supported.",
142
142
  "noEntitiesError": "$t(errors.noRelevantEntities)",
143
- "noEntitiesAlpV4Error": "The OData V4 service you have provided is not suitable for use in an analytical list page application. The service must contain aggregate-based entities for this template."
143
+ "noEntitiesAlpV4Error": "The OData V4 service you have provided is not suitable for use in an analytical list page application. The service must contain aggregate-based entities for this template.",
144
+ "requiredError": "Please select a main entity to continue."
144
145
  },
145
146
  "navigationEntitySelection": {
146
147
  "message": "Navigation Entity",
@@ -159,6 +160,7 @@
159
160
  "tableType": {
160
161
  "message": "Table Type",
161
162
  "hint": "Defines the table type for the list report page.",
163
+ "requiredError": "Please select a table type to continue.",
162
164
  "choiceNone": "$t(texts.choiceNameNone)",
163
165
  "choiceGrid": "Grid",
164
166
  "choiceAnalytical": "Analytical",
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.15.0",
4
+ "version": "2.16.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -51,8 +51,8 @@
51
51
  "@sap-ux/fiori-elements-writer": "2.8.48",
52
52
  "@sap-ux/fiori-freestyle-writer": "2.5.34",
53
53
  "@sap-ux/feature-toggle": "0.3.5",
54
- "@sap-ux/cap-config-writer": "0.12.49",
55
- "@sap-ux/odata-service-writer": "0.29.9"
54
+ "@sap-ux/odata-service-writer": "0.29.9",
55
+ "@sap-ux/cap-config-writer": "0.12.49"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=20.x"