@sap-ux/inquirer-common 0.7.28 → 0.7.30
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Answers, Question, Validator } from 'inquirer';
|
|
2
2
|
import type { CommonPromptOptions, PromptDefaultValue, PromptSeverityMessage, YUIQuestion } from '../types';
|
|
3
|
+
import type { ConvertedMetadata, EntitySet } from '@sap-ux/vocabularies-types';
|
|
3
4
|
/**
|
|
4
5
|
* Extends an additionalMessages function.
|
|
5
6
|
*
|
|
@@ -45,4 +46,28 @@ export declare function withCondition(questions: Question[], condition: (answers
|
|
|
45
46
|
* @returns - the extended questions
|
|
46
47
|
*/
|
|
47
48
|
export declare function extendWithOptions<T extends YUIQuestion = YUIQuestion>(questions: T[], promptOptions: Record<string, Omit<CommonPromptOptions, 'hide'> & PromptDefaultValue<string | boolean>>, promptState?: Answers): YUIQuestion[];
|
|
49
|
+
/**
|
|
50
|
+
* Checks if the given entity set name has aggregate transformations in the metadata.
|
|
51
|
+
*
|
|
52
|
+
* @param metadata The metadata (edmx) of the service.
|
|
53
|
+
* @param entitySetName The entity set name to check for aggregate transformations.
|
|
54
|
+
* @returns true if the entity set has aggregate transformations, false otherwise.
|
|
55
|
+
*/
|
|
56
|
+
export declare function hasAggregateTransformationsForEntity(metadata: ConvertedMetadata, entitySetName?: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
|
|
59
|
+
* This can be found within the entity set annotations or the entity type annotations.
|
|
60
|
+
*
|
|
61
|
+
* @param entitySets the entity sets to filter
|
|
62
|
+
* @returns the filtered entity sets
|
|
63
|
+
*/
|
|
64
|
+
export declare function filterAggregateTransformations(entitySets: EntitySet[]): EntitySet[];
|
|
65
|
+
/**
|
|
66
|
+
* Converts an EDMX string to a ConvertedMetadata object.
|
|
67
|
+
*
|
|
68
|
+
* @param edmx - The EDMX string to convert.
|
|
69
|
+
* @returns The converted metadata object.
|
|
70
|
+
* @throws If the EDMX cannot be parsed or the OData version is unparseable.
|
|
71
|
+
*/
|
|
72
|
+
export declare function convertEdmxToConvertedMetadata(edmx: string): ConvertedMetadata;
|
|
48
73
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/prompts/helpers.js
CHANGED
|
@@ -8,7 +8,13 @@ exports.extendValidate = extendValidate;
|
|
|
8
8
|
exports.applyExtensionFunction = applyExtensionFunction;
|
|
9
9
|
exports.withCondition = withCondition;
|
|
10
10
|
exports.extendWithOptions = extendWithOptions;
|
|
11
|
+
exports.hasAggregateTransformationsForEntity = hasAggregateTransformationsForEntity;
|
|
12
|
+
exports.filterAggregateTransformations = filterAggregateTransformations;
|
|
13
|
+
exports.convertEdmxToConvertedMetadata = convertEdmxToConvertedMetadata;
|
|
11
14
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
15
|
+
const annotation_converter_1 = require("@sap-ux/annotation-converter");
|
|
16
|
+
const edmx_parser_1 = require("@sap-ux/edmx-parser");
|
|
17
|
+
const i18n_1 = require("../i18n");
|
|
12
18
|
/**
|
|
13
19
|
* Extends an additionalMessages function.
|
|
14
20
|
*
|
|
@@ -133,4 +139,50 @@ function extendWithOptions(questions, promptOptions, promptState) {
|
|
|
133
139
|
});
|
|
134
140
|
return questions;
|
|
135
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Checks if the given entity set name has aggregate transformations in the metadata.
|
|
144
|
+
*
|
|
145
|
+
* @param metadata The metadata (edmx) of the service.
|
|
146
|
+
* @param entitySetName The entity set name to check for aggregate transformations.
|
|
147
|
+
* @returns true if the entity set has aggregate transformations, false otherwise.
|
|
148
|
+
*/
|
|
149
|
+
function hasAggregateTransformationsForEntity(metadata, entitySetName) {
|
|
150
|
+
if (!entitySetName) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return filterAggregateTransformations(metadata.entitySets).some((entitySet) => entitySet.name === entitySetName);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
|
|
157
|
+
* This can be found within the entity set annotations or the entity type annotations.
|
|
158
|
+
*
|
|
159
|
+
* @param entitySets the entity sets to filter
|
|
160
|
+
* @returns the filtered entity sets
|
|
161
|
+
*/
|
|
162
|
+
function filterAggregateTransformations(entitySets) {
|
|
163
|
+
return entitySets.filter((entitySet) => {
|
|
164
|
+
return (!!entitySet.annotations?.Aggregation?.ApplySupported?.Transformations ||
|
|
165
|
+
!!entitySet.entityType?.annotations?.Aggregation?.ApplySupported?.Transformations);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Converts an EDMX string to a ConvertedMetadata object.
|
|
170
|
+
*
|
|
171
|
+
* @param edmx - The EDMX string to convert.
|
|
172
|
+
* @returns The converted metadata object.
|
|
173
|
+
* @throws If the EDMX cannot be parsed or the OData version is unparseable.
|
|
174
|
+
*/
|
|
175
|
+
function convertEdmxToConvertedMetadata(edmx) {
|
|
176
|
+
try {
|
|
177
|
+
const convertedMetadata = (0, annotation_converter_1.convert)((0, edmx_parser_1.parse)(edmx));
|
|
178
|
+
const parsedOdataVersion = parseInt(convertedMetadata?.version, 10);
|
|
179
|
+
if (Number.isNaN(parsedOdataVersion)) {
|
|
180
|
+
throw new Error((0, i18n_1.t)('errors.unparseableOdataVersion'));
|
|
181
|
+
}
|
|
182
|
+
return convertedMetadata;
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
throw new Error((0, i18n_1.t)('errors.unparseableMetadata', { error: error.message }));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
136
188
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -46,7 +46,9 @@
|
|
|
46
46
|
"internalServerError": "Internal server error{{-errorMsg, addMsgWithColonFormatter}}",
|
|
47
47
|
"badGateway": "Bad gateway{{- errorMsg, addMsgWithColonFormatter}}",
|
|
48
48
|
"badRequest": "Bad request{{- errorMsg, addMsgWithColonFormatter}}",
|
|
49
|
-
"cannotBeEmpty": "{{- field}} cannot be empty."
|
|
49
|
+
"cannotBeEmpty": "{{- field}} cannot be empty.",
|
|
50
|
+
"unparseableMetadata": "Unable to parse entities from the metadata document: {{-error}}.",
|
|
51
|
+
"unparseableOdataVersion": "Unable to parse the OData version from the metadata."
|
|
50
52
|
},
|
|
51
53
|
"guidedAnswers": {
|
|
52
54
|
"validationErrorHelpText": "Need help with this error?"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/inquirer-common",
|
|
3
3
|
"description": "Commonly used shared functionality and types to support inquirer modules.",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.30",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@sap/cf-tools": "3.2.2",
|
|
23
|
+
"@sap-ux/annotation-converter": "0.10.2",
|
|
24
|
+
"@sap-ux/edmx-parser": "0.9.1",
|
|
23
25
|
"axios": "1.8.2",
|
|
24
26
|
"chalk": "4.1.2",
|
|
25
27
|
"figures": "3.2.0",
|
|
@@ -30,13 +32,14 @@
|
|
|
30
32
|
"semver": "7.5.4",
|
|
31
33
|
"@sap-ux/btp-utils": "1.1.0",
|
|
32
34
|
"@sap-ux/feature-toggle": "0.3.0",
|
|
33
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
35
|
+
"@sap-ux/fiori-generator-shared": "0.13.5",
|
|
34
36
|
"@sap-ux/guided-answers-helper": "0.3.1",
|
|
35
|
-
"@sap-ux/telemetry": "0.6.
|
|
37
|
+
"@sap-ux/telemetry": "0.6.12",
|
|
36
38
|
"@sap-ux/logger": "0.7.0",
|
|
37
39
|
"@sap-ux/ui5-info": "0.12.1"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
42
|
+
"@sap-ux/vocabularies-types": "0.13.0",
|
|
40
43
|
"@sap-devx/yeoman-ui-types": "1.14.4",
|
|
41
44
|
"@types/inquirer": "8.2.6",
|
|
42
45
|
"@types/semver": "7.5.4",
|