@sap-ux/odata-service-inquirer 2.8.13 → 2.9.1
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.
|
@@ -29,7 +29,7 @@ export type EntitySetFilter = 'filterDraftEnabled' | 'filterAggregateTransformat
|
|
|
29
29
|
* Returns the entity choice options for use in a list inquirer prompt.
|
|
30
30
|
*
|
|
31
31
|
* @param edmx metadata string
|
|
32
|
-
* @param options
|
|
32
|
+
* @param options Configuration options for entity filtering and selection
|
|
33
33
|
* @param options.entitySetFilter
|
|
34
34
|
* `filterDraftEnabled` : Only draft enabled entities wil be returned when true, useful for Form Object Page app generation.
|
|
35
35
|
* `filterAggregateTransformationsOnly` : Only return entity choices that have an aggregate annotation (Aggregation.ApplySupported) with the `Transformations` property set,
|
|
@@ -63,11 +63,12 @@ export declare function filterDraftEnabledEntities(entitySets: EntitySet[]): Ent
|
|
|
63
63
|
* @param templateType the template type of the application to be generated from the prompt answers
|
|
64
64
|
* @param metadata the metadata (edmx) string of the service
|
|
65
65
|
* @param odataVersion the OData version of the service
|
|
66
|
+
* @param isCapService whether the service is a CAP service or not
|
|
66
67
|
* @param mainEntitySetName the name of the main entity set
|
|
67
68
|
* @param currentTableType the current table type selected by the user
|
|
68
69
|
* @returns the default table type and a boolean indicating if AnalyticalTable should be set as default
|
|
69
70
|
*/
|
|
70
|
-
export declare function getDefaultTableType(templateType: TemplateType, metadata: ConvertedMetadata, odataVersion: OdataVersion, mainEntitySetName?: string, currentTableType?: TableType): {
|
|
71
|
+
export declare function getDefaultTableType(templateType: TemplateType, metadata: ConvertedMetadata, odataVersion: OdataVersion, isCapService: boolean, mainEntitySetName?: string, currentTableType?: TableType): {
|
|
71
72
|
tableType: TableType;
|
|
72
73
|
setAnalyticalTableDefault: boolean;
|
|
73
74
|
};
|
|
@@ -57,7 +57,7 @@ function getNavigationPropertyForParameterisedEntity(entitySet, entityTypes) {
|
|
|
57
57
|
* Returns the entity choice options for use in a list inquirer prompt.
|
|
58
58
|
*
|
|
59
59
|
* @param edmx metadata string
|
|
60
|
-
* @param options
|
|
60
|
+
* @param options Configuration options for entity filtering and selection
|
|
61
61
|
* @param options.entitySetFilter
|
|
62
62
|
* `filterDraftEnabled` : Only draft enabled entities wil be returned when true, useful for Form Object Page app generation.
|
|
63
63
|
* `filterAggregateTransformationsOnly` : Only return entity choices that have an aggregate annotation (Aggregation.ApplySupported) with the `Transformations` property set,
|
|
@@ -147,7 +147,7 @@ function findEntitySetName(entitySets, entityType) {
|
|
|
147
147
|
*/
|
|
148
148
|
function getNavigationEntityChoices(metadata, odataVersion, mainEntityName) {
|
|
149
149
|
const choices = [];
|
|
150
|
-
const mainEntitySet =
|
|
150
|
+
const mainEntitySet = (0, inquirer_common_1.findEntitySetByName)(metadata, mainEntityName);
|
|
151
151
|
let navProps = [];
|
|
152
152
|
if (odataVersion === odata_service_writer_1.OdataVersion.v4) {
|
|
153
153
|
navProps = mainEntitySet?.entityType.navigationProperties.filter((navProp) => navProp.isCollection) ?? [];
|
|
@@ -181,28 +181,80 @@ function filterDraftEnabledEntities(entitySets) {
|
|
|
181
181
|
return !!entitySetTypeProperties.find((property) => property.name === 'HasDraftEntity');
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Determines if AnalyticalTable should be used based on entity annotations and service type.
|
|
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.
|
|
189
|
+
*
|
|
190
|
+
* @param entitySet The entity set to check for annotations.
|
|
191
|
+
* @param isCapService Whether the service is a CAP service (affects analytical requirements).
|
|
192
|
+
* @returns True if AnalyticalTable should be used, false otherwise.
|
|
193
|
+
*/
|
|
194
|
+
function shouldUseAnalyticalTable(entitySet, isCapService) {
|
|
195
|
+
// Evaluate annotations once to avoid multiple iterations
|
|
196
|
+
const hasAnalytical = (0, inquirer_common_1.hasAggregateTransformations)(entitySet);
|
|
197
|
+
const hasHierarchy = (0, inquirer_common_1.hasRecursiveHierarchyForEntitySet)(entitySet);
|
|
198
|
+
// No analytical data means no need for AnalyticalTable
|
|
199
|
+
if (!hasAnalytical) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
// If entity has both analytical and hierarchical data, always use AnalyticalTable
|
|
203
|
+
if (hasHierarchy) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
// For CAP services, analytical annotations are sufficient
|
|
207
|
+
if (isCapService) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
// For non-CAP services, require complete analytical transformations
|
|
211
|
+
return (0, inquirer_common_1.hasAggregateTransformationsForEntitySet)(entitySet, inquirer_common_1.transformationsRequiredForAnalyticalTable);
|
|
212
|
+
}
|
|
184
213
|
/**
|
|
185
214
|
* Get the default table type based on the template type and previous answers.
|
|
186
215
|
*
|
|
187
216
|
* @param templateType the template type of the application to be generated from the prompt answers
|
|
188
217
|
* @param metadata the metadata (edmx) string of the service
|
|
189
218
|
* @param odataVersion the OData version of the service
|
|
219
|
+
* @param isCapService whether the service is a CAP service or not
|
|
190
220
|
* @param mainEntitySetName the name of the main entity set
|
|
191
221
|
* @param currentTableType the current table type selected by the user
|
|
192
222
|
* @returns the default table type and a boolean indicating if AnalyticalTable should be set as default
|
|
193
223
|
*/
|
|
194
|
-
function getDefaultTableType(templateType, metadata, odataVersion, mainEntitySetName, currentTableType) {
|
|
224
|
+
function getDefaultTableType(templateType, metadata, odataVersion, isCapService, mainEntitySetName, currentTableType) {
|
|
195
225
|
let tableType;
|
|
196
226
|
let setAnalyticalTableDefault = false;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
227
|
+
// Find the entity set once for all annotation checks
|
|
228
|
+
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;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
// Default to ResponsiveTable for other cases
|
|
253
|
+
tableType = 'ResponsiveTable';
|
|
254
|
+
}
|
|
203
255
|
}
|
|
204
256
|
else if (templateType === 'alp') {
|
|
205
|
-
// For ALP, use AnalyticalTable as default
|
|
257
|
+
// For ALP, use AnalyticalTable as default even if entity set is not found
|
|
206
258
|
tableType = 'AnalyticalTable';
|
|
207
259
|
}
|
|
208
260
|
else if (currentTableType) {
|
|
@@ -213,7 +213,7 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metad
|
|
|
213
213
|
},
|
|
214
214
|
choices: tableTypeChoices,
|
|
215
215
|
default: (prevAnswers) => {
|
|
216
|
-
const tableTypeDefault = (0, entity_helper_1.getDefaultTableType)(templateType, metadata, odataVersion, prevAnswers?.mainEntity?.entitySetName, prevAnswers?.tableType);
|
|
216
|
+
const tableTypeDefault = (0, entity_helper_1.getDefaultTableType)(templateType, metadata, odataVersion, isCapService, prevAnswers?.mainEntity?.entitySetName, prevAnswers?.tableType);
|
|
217
217
|
setAnalyticalTableDefault = tableTypeDefault.setAnalyticalTableDefault;
|
|
218
218
|
return tableTypeDefault.tableType;
|
|
219
219
|
},
|
|
@@ -236,7 +236,14 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metad
|
|
|
236
236
|
breadcrumb: true,
|
|
237
237
|
mandatory: true
|
|
238
238
|
},
|
|
239
|
-
default:
|
|
239
|
+
default: (prevAnswers) => {
|
|
240
|
+
// Auto-populate qualifier from RecursiveHierarchy annotation if available
|
|
241
|
+
if (prevAnswers?.mainEntity?.entitySetName) {
|
|
242
|
+
const entitySet = (0, inquirer_common_1.findEntitySetByName)(metadata, prevAnswers.mainEntity.entitySetName);
|
|
243
|
+
return entitySet ? (0, inquirer_common_1.getRecursiveHierarchyQualifierForEntitySet)(entitySet) : '';
|
|
244
|
+
}
|
|
245
|
+
return '';
|
|
246
|
+
},
|
|
240
247
|
validate: (input) => {
|
|
241
248
|
if (!input) {
|
|
242
249
|
return (0, i18n_1.t)('prompts.hierarchyQualifier.qualifierRequiredForV4Warning');
|
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.
|
|
4
|
+
"version": "2.9.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"os-name": "4.0.1",
|
|
32
32
|
"@sap-ux/axios-extension": "1.23.0",
|
|
33
33
|
"@sap-ux/btp-utils": "1.1.4",
|
|
34
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
34
|
+
"@sap-ux/fiori-generator-shared": "0.13.24",
|
|
35
35
|
"@sap-ux/guided-answers-helper": "0.4.0",
|
|
36
36
|
"@sap-ux/telemetry": "0.6.29",
|
|
37
|
-
"@sap-ux/inquirer-common": "0.
|
|
37
|
+
"@sap-ux/inquirer-common": "0.8.1",
|
|
38
38
|
"@sap-ux/logger": "0.7.0",
|
|
39
39
|
"@sap-ux/nodejs-utils": "0.2.7",
|
|
40
40
|
"@sap-ux/project-access": "1.32.4",
|
|
@@ -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.
|
|
52
|
-
"@sap-ux/fiori-elements-writer": "2.7.
|
|
53
|
-
"@sap-ux/fiori-freestyle-writer": "2.4.
|
|
51
|
+
"@sap-ux/fiori-generator-shared": "0.13.24",
|
|
52
|
+
"@sap-ux/fiori-elements-writer": "2.7.25",
|
|
53
|
+
"@sap-ux/fiori-freestyle-writer": "2.4.52",
|
|
54
54
|
"@sap-ux/feature-toggle": "0.3.2",
|
|
55
55
|
"@sap-ux/odata-service-writer": "0.27.25",
|
|
56
|
-
"@sap-ux/cap-config-writer": "0.12.
|
|
56
|
+
"@sap-ux/cap-config-writer": "0.12.15"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=20.x"
|