@sap-ux/inquirer-common 0.8.9 → 0.9.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/metadata/index.d.ts +2 -0
- package/dist/metadata/index.js +18 -0
- package/dist/metadata/metadataHelpers.d.ts +101 -0
- package/dist/metadata/metadataHelpers.js +215 -0
- package/dist/prompts/helpers.d.ts +0 -90
- package/dist/prompts/helpers.js +0 -194
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from './error-handler/error-handler';
|
|
|
5
5
|
export * from './prompts/cf-helper';
|
|
6
6
|
export * from './telemetry/telemetry';
|
|
7
7
|
export * from './prompts/credentials';
|
|
8
|
+
export * from './metadata';
|
|
8
9
|
export { addi18nResourceBundle } from './i18n';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./error-handler/error-handler"), exports);
|
|
|
22
22
|
__exportStar(require("./prompts/cf-helper"), exports);
|
|
23
23
|
__exportStar(require("./telemetry/telemetry"), exports);
|
|
24
24
|
__exportStar(require("./prompts/credentials"), exports);
|
|
25
|
+
__exportStar(require("./metadata"), exports);
|
|
25
26
|
var i18n_1 = require("./i18n");
|
|
26
27
|
Object.defineProperty(exports, "addi18nResourceBundle", { enumerable: true, get: function () { return i18n_1.addi18nResourceBundle; } });
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./metadataHelpers"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ConvertedMetadata, EntitySet } from '@sap-ux/vocabularies-types';
|
|
2
|
+
/**
|
|
3
|
+
* Required transformations for analytical table support.
|
|
4
|
+
* NOTE: This constant is primarily used by odata-service-inquirer but is exported
|
|
5
|
+
* here to maintain backward compatibility with external packages that import it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const transformationsRequiredForAnalyticalTable: readonly ["filter", "identity", "orderby", "skip", "top", "groupby", "aggregate", "concat"];
|
|
8
|
+
/**
|
|
9
|
+
* Finds an entity set by name in the metadata.
|
|
10
|
+
*
|
|
11
|
+
* @param metadata The metadata (edmx) of the service.
|
|
12
|
+
* @param entitySetName The name of the entity set to find.
|
|
13
|
+
* @returns The entity set if found, undefined otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findEntitySetByName(metadata: ConvertedMetadata, entitySetName: string): EntitySet | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the given entity set has aggregate transformations.
|
|
18
|
+
* Returns true if ANY transformations are present in either entity set or entity type annotations.
|
|
19
|
+
*
|
|
20
|
+
* @param entitySet The entity set to check for aggregate transformations.
|
|
21
|
+
* @returns true if the entity set has any aggregate transformations, false otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export declare function hasAggregateTransformations(entitySet: EntitySet): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
|
|
26
|
+
* This can be found within the entity set annotations or the entity type annotations.
|
|
27
|
+
*
|
|
28
|
+
* @param entitySets the entity sets to filter
|
|
29
|
+
* @returns the filtered entity sets
|
|
30
|
+
*/
|
|
31
|
+
export declare function filterAggregateTransformations(entitySets: EntitySet[]): EntitySet[];
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the given entity set has aggregate transformations.
|
|
34
|
+
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
35
|
+
* If no transformations are specified, returns true if ANY transformations are present.
|
|
36
|
+
*
|
|
37
|
+
* @param entitySet The entity set to check for aggregate transformations.
|
|
38
|
+
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
39
|
+
* @returns true if the entity set has the required transformations, false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export declare function hasAggregateTransformationsForEntitySet(entitySet: EntitySet, requiredTransformations?: readonly string[]): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if the given entity set name has aggregate transformations in the metadata.
|
|
44
|
+
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
45
|
+
* If no transformations are specified, returns true if ANY transformations are present.
|
|
46
|
+
*
|
|
47
|
+
* @param metadata The metadata (edmx) of the service.
|
|
48
|
+
* @param entitySetName The entity set name to check for aggregate transformations.
|
|
49
|
+
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
50
|
+
* @returns true if the entity set has the required transformations, false otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export declare function hasAggregateTransformationsForEntity(metadata: ConvertedMetadata, entitySetName: string, requiredTransformations?: readonly string[]): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Checks if the given entity set has a Hierarchy.RecursiveHierarchy annotation.
|
|
55
|
+
*
|
|
56
|
+
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
57
|
+
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
58
|
+
*/
|
|
59
|
+
export declare function hasRecursiveHierarchyForEntitySet(entitySet: EntitySet): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
62
|
+
*
|
|
63
|
+
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
64
|
+
* @returns The qualifier string if found, undefined otherwise.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getRecursiveHierarchyQualifierForEntitySet(entitySet: EntitySet): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if the given entity set name has a Hierarchy.RecursiveHierarchy annotation in the metadata.
|
|
69
|
+
*
|
|
70
|
+
* @param metadata The metadata (edmx) of the service.
|
|
71
|
+
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
72
|
+
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export declare function hasRecursiveHierarchyForEntity(metadata: ConvertedMetadata, entitySetName: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
77
|
+
*
|
|
78
|
+
* @param metadata The metadata (edmx) of the service.
|
|
79
|
+
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
80
|
+
* @returns The qualifier string if found, undefined otherwise.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getRecursiveHierarchyQualifier(metadata: ConvertedMetadata, entitySetName: string): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Determines if AnalyticalTable should be used based on entity annotations and transformation requirements.
|
|
85
|
+
*
|
|
86
|
+
* AnalyticalTable is used when entity has analytical data and meets the specified transformation requirements.
|
|
87
|
+
*
|
|
88
|
+
* @param entitySet The entity set to check for annotations.
|
|
89
|
+
* @param requireCompleteTransformations Whether to require all analytical transformations or accept any analytical annotations.
|
|
90
|
+
* @returns True if AnalyticalTable should be used, false otherwise.
|
|
91
|
+
*/
|
|
92
|
+
export declare function shouldUseAnalyticalTable(entitySet: EntitySet, requireCompleteTransformations: boolean): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Converts an EDMX string to a ConvertedMetadata object.
|
|
95
|
+
*
|
|
96
|
+
* @param edmx - The EDMX string to convert.
|
|
97
|
+
* @returns The converted metadata object.
|
|
98
|
+
* @throws If the EDMX cannot be parsed or the OData version is unparseable.
|
|
99
|
+
*/
|
|
100
|
+
export declare function convertEdmxToConvertedMetadata(edmx: string): ConvertedMetadata;
|
|
101
|
+
//# sourceMappingURL=metadataHelpers.d.ts.map
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformationsRequiredForAnalyticalTable = void 0;
|
|
4
|
+
exports.findEntitySetByName = findEntitySetByName;
|
|
5
|
+
exports.hasAggregateTransformations = hasAggregateTransformations;
|
|
6
|
+
exports.filterAggregateTransformations = filterAggregateTransformations;
|
|
7
|
+
exports.hasAggregateTransformationsForEntitySet = hasAggregateTransformationsForEntitySet;
|
|
8
|
+
exports.hasAggregateTransformationsForEntity = hasAggregateTransformationsForEntity;
|
|
9
|
+
exports.hasRecursiveHierarchyForEntitySet = hasRecursiveHierarchyForEntitySet;
|
|
10
|
+
exports.getRecursiveHierarchyQualifierForEntitySet = getRecursiveHierarchyQualifierForEntitySet;
|
|
11
|
+
exports.hasRecursiveHierarchyForEntity = hasRecursiveHierarchyForEntity;
|
|
12
|
+
exports.getRecursiveHierarchyQualifier = getRecursiveHierarchyQualifier;
|
|
13
|
+
exports.shouldUseAnalyticalTable = shouldUseAnalyticalTable;
|
|
14
|
+
exports.convertEdmxToConvertedMetadata = convertEdmxToConvertedMetadata;
|
|
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");
|
|
18
|
+
/**
|
|
19
|
+
* Required transformations for analytical table support.
|
|
20
|
+
* NOTE: This constant is primarily used by odata-service-inquirer but is exported
|
|
21
|
+
* here to maintain backward compatibility with external packages that import it.
|
|
22
|
+
*/
|
|
23
|
+
exports.transformationsRequiredForAnalyticalTable = [
|
|
24
|
+
'filter',
|
|
25
|
+
'identity',
|
|
26
|
+
'orderby',
|
|
27
|
+
'skip',
|
|
28
|
+
'top',
|
|
29
|
+
'groupby',
|
|
30
|
+
'aggregate',
|
|
31
|
+
'concat'
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Annotation pattern for RecursiveHierarchy.
|
|
35
|
+
*/
|
|
36
|
+
const RECURSIVE_HIERARCHY_ANNOTATION = 'RecursiveHierarchy';
|
|
37
|
+
/**
|
|
38
|
+
* Finds an entity set by name in the metadata.
|
|
39
|
+
*
|
|
40
|
+
* @param metadata The metadata (edmx) of the service.
|
|
41
|
+
* @param entitySetName The name of the entity set to find.
|
|
42
|
+
* @returns The entity set if found, undefined otherwise.
|
|
43
|
+
*/
|
|
44
|
+
function findEntitySetByName(metadata, entitySetName) {
|
|
45
|
+
return metadata.entitySets.find((entitySet) => entitySet.name === entitySetName);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the given entity set has aggregate transformations.
|
|
49
|
+
* Returns true if ANY transformations are present in either entity set or entity type annotations.
|
|
50
|
+
*
|
|
51
|
+
* @param entitySet The entity set to check for aggregate transformations.
|
|
52
|
+
* @returns true if the entity set has any aggregate transformations, false otherwise.
|
|
53
|
+
*/
|
|
54
|
+
function hasAggregateTransformations(entitySet) {
|
|
55
|
+
const transformations = entitySet.annotations?.Aggregation?.ApplySupported?.Transformations ||
|
|
56
|
+
entitySet.entityType?.annotations?.Aggregation?.ApplySupported?.Transformations;
|
|
57
|
+
return Array.isArray(transformations) && transformations.length > 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
|
|
61
|
+
* This can be found within the entity set annotations or the entity type annotations.
|
|
62
|
+
*
|
|
63
|
+
* @param entitySets the entity sets to filter
|
|
64
|
+
* @returns the filtered entity sets
|
|
65
|
+
*/
|
|
66
|
+
function filterAggregateTransformations(entitySets) {
|
|
67
|
+
return entitySets.filter(hasAggregateTransformations);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if the given entity set has aggregate transformations.
|
|
71
|
+
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
72
|
+
* If no transformations are specified, returns true if ANY transformations are present.
|
|
73
|
+
*
|
|
74
|
+
* @param entitySet The entity set to check for aggregate transformations.
|
|
75
|
+
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
76
|
+
* @returns true if the entity set has the required transformations, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
function hasAggregateTransformationsForEntitySet(entitySet, requiredTransformations) {
|
|
79
|
+
const transformations = entitySet.annotations?.Aggregation?.ApplySupported?.Transformations ||
|
|
80
|
+
entitySet.entityType?.annotations?.Aggregation?.ApplySupported?.Transformations;
|
|
81
|
+
if (!Array.isArray(transformations)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
// If no specific transformations required, return true if any transformations exist
|
|
85
|
+
if (!requiredTransformations || requiredTransformations.length === 0) {
|
|
86
|
+
return transformations.length > 0;
|
|
87
|
+
}
|
|
88
|
+
// Check if all required transformations are present
|
|
89
|
+
return requiredTransformations.every((transformation) => transformations.includes(transformation));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Checks if the given entity set name has aggregate transformations in the metadata.
|
|
93
|
+
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
94
|
+
* If no transformations are specified, returns true if ANY transformations are present.
|
|
95
|
+
*
|
|
96
|
+
* @param metadata The metadata (edmx) of the service.
|
|
97
|
+
* @param entitySetName The entity set name to check for aggregate transformations.
|
|
98
|
+
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
99
|
+
* @returns true if the entity set has the required transformations, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
function hasAggregateTransformationsForEntity(metadata, entitySetName, requiredTransformations) {
|
|
102
|
+
const entitySet = findEntitySetByName(metadata, entitySetName);
|
|
103
|
+
if (!entitySet) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return hasAggregateTransformationsForEntitySet(entitySet, requiredTransformations);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Finds the RecursiveHierarchy annotation key for the given entity set.
|
|
110
|
+
* This is a helper function that both existence check and qualifier extraction can use.
|
|
111
|
+
*
|
|
112
|
+
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
113
|
+
* @returns The RecursiveHierarchy key if found, undefined otherwise.
|
|
114
|
+
*/
|
|
115
|
+
function findRecursiveHierarchyKey(entitySet) {
|
|
116
|
+
const hierarchyAnnotations = entitySet?.entityType?.annotations?.Hierarchy;
|
|
117
|
+
if (!hierarchyAnnotations) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
// First try exact match for the most common case
|
|
121
|
+
if (hierarchyAnnotations[RECURSIVE_HIERARCHY_ANNOTATION]) {
|
|
122
|
+
return RECURSIVE_HIERARCHY_ANNOTATION;
|
|
123
|
+
}
|
|
124
|
+
// Then check for qualified versions (RecursiveHierarchy#qualifier)
|
|
125
|
+
return Object.keys(hierarchyAnnotations).find((key) => key.startsWith(RECURSIVE_HIERARCHY_ANNOTATION));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Checks if the given entity set has a Hierarchy.RecursiveHierarchy annotation.
|
|
129
|
+
*
|
|
130
|
+
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
131
|
+
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
132
|
+
*/
|
|
133
|
+
function hasRecursiveHierarchyForEntitySet(entitySet) {
|
|
134
|
+
return !!findRecursiveHierarchyKey(entitySet);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
138
|
+
*
|
|
139
|
+
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
140
|
+
* @returns The qualifier string if found, undefined otherwise.
|
|
141
|
+
*/
|
|
142
|
+
function getRecursiveHierarchyQualifierForEntitySet(entitySet) {
|
|
143
|
+
return findRecursiveHierarchyKey(entitySet)?.split('#')[1];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Checks if the given entity set name has a Hierarchy.RecursiveHierarchy annotation in the metadata.
|
|
147
|
+
*
|
|
148
|
+
* @param metadata The metadata (edmx) of the service.
|
|
149
|
+
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
150
|
+
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
151
|
+
*/
|
|
152
|
+
function hasRecursiveHierarchyForEntity(metadata, entitySetName) {
|
|
153
|
+
const entitySet = findEntitySetByName(metadata, entitySetName);
|
|
154
|
+
if (!entitySet) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return hasRecursiveHierarchyForEntitySet(entitySet);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
161
|
+
*
|
|
162
|
+
* @param metadata The metadata (edmx) of the service.
|
|
163
|
+
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
164
|
+
* @returns The qualifier string if found, undefined otherwise.
|
|
165
|
+
*/
|
|
166
|
+
function getRecursiveHierarchyQualifier(metadata, entitySetName) {
|
|
167
|
+
const entitySet = findEntitySetByName(metadata, entitySetName);
|
|
168
|
+
if (!entitySet) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return getRecursiveHierarchyQualifierForEntitySet(entitySet);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Determines if AnalyticalTable should be used based on entity annotations and transformation requirements.
|
|
175
|
+
*
|
|
176
|
+
* AnalyticalTable is used when entity has analytical data and meets the specified transformation requirements.
|
|
177
|
+
*
|
|
178
|
+
* @param entitySet The entity set to check for annotations.
|
|
179
|
+
* @param requireCompleteTransformations Whether to require all analytical transformations or accept any analytical annotations.
|
|
180
|
+
* @returns True if AnalyticalTable should be used, false otherwise.
|
|
181
|
+
*/
|
|
182
|
+
function shouldUseAnalyticalTable(entitySet, requireCompleteTransformations) {
|
|
183
|
+
// No analytical data means no need for AnalyticalTable
|
|
184
|
+
if (!hasAggregateTransformations(entitySet)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
// If complete transformations are not required, any analytical annotations are sufficient
|
|
188
|
+
if (!requireCompleteTransformations) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
// Require complete analytical transformations
|
|
192
|
+
return hasAggregateTransformationsForEntitySet(entitySet, exports.transformationsRequiredForAnalyticalTable);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Converts an EDMX string to a ConvertedMetadata object.
|
|
196
|
+
*
|
|
197
|
+
* @param edmx - The EDMX string to convert.
|
|
198
|
+
* @returns The converted metadata object.
|
|
199
|
+
* @throws If the EDMX cannot be parsed or the OData version is unparseable.
|
|
200
|
+
*/
|
|
201
|
+
function convertEdmxToConvertedMetadata(edmx) {
|
|
202
|
+
try {
|
|
203
|
+
const convertedMetadata = (0, annotation_converter_1.convert)((0, edmx_parser_1.parse)(edmx));
|
|
204
|
+
const parsedOdataVersion = Number.parseInt(convertedMetadata?.version, 10);
|
|
205
|
+
if (Number.isNaN(parsedOdataVersion)) {
|
|
206
|
+
throw new TypeError((0, i18n_1.t)('errors.unparseableOdataVersion'));
|
|
207
|
+
}
|
|
208
|
+
return convertedMetadata;
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
212
|
+
throw new Error((0, i18n_1.t)('errors.unparseableMetadata', { error: errorMessage }));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=metadataHelpers.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
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';
|
|
4
3
|
/**
|
|
5
4
|
* Extends an additionalMessages function.
|
|
6
5
|
*
|
|
@@ -46,93 +45,4 @@ export declare function withCondition(questions: Question[], condition: (answers
|
|
|
46
45
|
* @returns - the extended questions
|
|
47
46
|
*/
|
|
48
47
|
export declare function extendWithOptions<T extends YUIQuestion = YUIQuestion>(questions: T[], promptOptions: Record<string, Omit<CommonPromptOptions, 'hide'> & PromptDefaultValue<string | boolean>>, promptState?: Answers): YUIQuestion[];
|
|
49
|
-
/**
|
|
50
|
-
* Required transformations for analytical table support.
|
|
51
|
-
* NOTE: This constant is primarily used by odata-service-inquirer but is exported
|
|
52
|
-
* here to maintain backward compatibility with external packages that import it.
|
|
53
|
-
*/
|
|
54
|
-
export declare const transformationsRequiredForAnalyticalTable: readonly ["filter", "identity", "orderby", "skip", "top", "groupby", "aggregate", "concat"];
|
|
55
|
-
/**
|
|
56
|
-
* Checks if the given entity set has aggregate transformations.
|
|
57
|
-
* Returns true if ANY transformations are present in either entity set or entity type annotations.
|
|
58
|
-
*
|
|
59
|
-
* @param entitySet The entity set to check for aggregate transformations.
|
|
60
|
-
* @returns true if the entity set has any aggregate transformations, false otherwise.
|
|
61
|
-
*/
|
|
62
|
-
export declare function hasAggregateTransformations(entitySet: EntitySet): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
|
|
65
|
-
* This can be found within the entity set annotations or the entity type annotations.
|
|
66
|
-
*
|
|
67
|
-
* @param entitySets the entity sets to filter
|
|
68
|
-
* @returns the filtered entity sets
|
|
69
|
-
*/
|
|
70
|
-
export declare function filterAggregateTransformations(entitySets: EntitySet[]): EntitySet[];
|
|
71
|
-
/**
|
|
72
|
-
* Checks if the given entity set name has aggregate transformations in the metadata.
|
|
73
|
-
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
74
|
-
* If no transformations are specified, returns true if ANY transformations are present.
|
|
75
|
-
*
|
|
76
|
-
* @param metadata The metadata (edmx) of the service.
|
|
77
|
-
* @param entitySetName The entity set name to check for aggregate transformations.
|
|
78
|
-
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
79
|
-
* @returns true if the entity set has the required transformations, false otherwise.
|
|
80
|
-
*/
|
|
81
|
-
export declare function hasAggregateTransformationsForEntity(metadata: ConvertedMetadata, entitySetName: string, requiredTransformations?: readonly string[]): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Checks if the given entity set name has a Hierarchy.RecursiveHierarchy annotation in the metadata.
|
|
84
|
-
*
|
|
85
|
-
* @param metadata The metadata (edmx) of the service.
|
|
86
|
-
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
87
|
-
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
88
|
-
*/
|
|
89
|
-
export declare function hasRecursiveHierarchyForEntity(metadata: ConvertedMetadata, entitySetName: string): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
92
|
-
*
|
|
93
|
-
* @param metadata The metadata (edmx) of the service.
|
|
94
|
-
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
95
|
-
* @returns The qualifier string if found, undefined otherwise.
|
|
96
|
-
*/
|
|
97
|
-
export declare function getRecursiveHierarchyQualifier(metadata: ConvertedMetadata, entitySetName: string): string | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the given entity set has aggregate transformations.
|
|
100
|
-
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
101
|
-
* If no transformations are specified, returns true if ANY transformations are present.
|
|
102
|
-
*
|
|
103
|
-
* @param entitySet The entity set to check for aggregate transformations.
|
|
104
|
-
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
105
|
-
* @returns true if the entity set has the required transformations, false otherwise.
|
|
106
|
-
*/
|
|
107
|
-
export declare function hasAggregateTransformationsForEntitySet(entitySet: EntitySet, requiredTransformations?: readonly string[]): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Checks if the given entity set has a Hierarchy.RecursiveHierarchy annotation.
|
|
110
|
-
*
|
|
111
|
-
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
112
|
-
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
113
|
-
*/
|
|
114
|
-
export declare function hasRecursiveHierarchyForEntitySet(entitySet: EntitySet): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
117
|
-
*
|
|
118
|
-
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
119
|
-
* @returns The qualifier string if found, undefined otherwise.
|
|
120
|
-
*/
|
|
121
|
-
export declare function getRecursiveHierarchyQualifierForEntitySet(entitySet: EntitySet): string | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Finds an entity set by name in the metadata.
|
|
124
|
-
*
|
|
125
|
-
* @param metadata The metadata (edmx) of the service.
|
|
126
|
-
* @param entitySetName The name of the entity set to find.
|
|
127
|
-
* @returns The entity set if found, undefined otherwise.
|
|
128
|
-
*/
|
|
129
|
-
export declare function findEntitySetByName(metadata: ConvertedMetadata, entitySetName: string): EntitySet | undefined;
|
|
130
|
-
/**
|
|
131
|
-
* Converts an EDMX string to a ConvertedMetadata object.
|
|
132
|
-
*
|
|
133
|
-
* @param edmx - The EDMX string to convert.
|
|
134
|
-
* @returns The converted metadata object.
|
|
135
|
-
* @throws If the EDMX cannot be parsed or the OData version is unparseable.
|
|
136
|
-
*/
|
|
137
|
-
export declare function convertEdmxToConvertedMetadata(edmx: string): ConvertedMetadata;
|
|
138
48
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/prompts/helpers.js
CHANGED
|
@@ -3,26 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.transformationsRequiredForAnalyticalTable = void 0;
|
|
7
6
|
exports.extendAdditionalMessages = extendAdditionalMessages;
|
|
8
7
|
exports.extendValidate = extendValidate;
|
|
9
8
|
exports.applyExtensionFunction = applyExtensionFunction;
|
|
10
9
|
exports.withCondition = withCondition;
|
|
11
10
|
exports.extendWithOptions = extendWithOptions;
|
|
12
|
-
exports.hasAggregateTransformations = hasAggregateTransformations;
|
|
13
|
-
exports.filterAggregateTransformations = filterAggregateTransformations;
|
|
14
|
-
exports.hasAggregateTransformationsForEntity = hasAggregateTransformationsForEntity;
|
|
15
|
-
exports.hasRecursiveHierarchyForEntity = hasRecursiveHierarchyForEntity;
|
|
16
|
-
exports.getRecursiveHierarchyQualifier = getRecursiveHierarchyQualifier;
|
|
17
|
-
exports.hasAggregateTransformationsForEntitySet = hasAggregateTransformationsForEntitySet;
|
|
18
|
-
exports.hasRecursiveHierarchyForEntitySet = hasRecursiveHierarchyForEntitySet;
|
|
19
|
-
exports.getRecursiveHierarchyQualifierForEntitySet = getRecursiveHierarchyQualifierForEntitySet;
|
|
20
|
-
exports.findEntitySetByName = findEntitySetByName;
|
|
21
|
-
exports.convertEdmxToConvertedMetadata = convertEdmxToConvertedMetadata;
|
|
22
11
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
23
|
-
const annotation_converter_1 = require("@sap-ux/annotation-converter");
|
|
24
|
-
const edmx_parser_1 = require("@sap-ux/edmx-parser");
|
|
25
|
-
const i18n_1 = require("../i18n");
|
|
26
12
|
/**
|
|
27
13
|
* Extends an additionalMessages function.
|
|
28
14
|
*
|
|
@@ -147,184 +133,4 @@ function extendWithOptions(questions, promptOptions, promptState) {
|
|
|
147
133
|
});
|
|
148
134
|
return questions;
|
|
149
135
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Required transformations for analytical table support.
|
|
152
|
-
* NOTE: This constant is primarily used by odata-service-inquirer but is exported
|
|
153
|
-
* here to maintain backward compatibility with external packages that import it.
|
|
154
|
-
*/
|
|
155
|
-
exports.transformationsRequiredForAnalyticalTable = [
|
|
156
|
-
'filter',
|
|
157
|
-
'identity',
|
|
158
|
-
'orderby',
|
|
159
|
-
'skip',
|
|
160
|
-
'top',
|
|
161
|
-
'groupby',
|
|
162
|
-
'aggregate',
|
|
163
|
-
'concat'
|
|
164
|
-
];
|
|
165
|
-
/**
|
|
166
|
-
* Annotation pattern for RecursiveHierarchy.
|
|
167
|
-
*/
|
|
168
|
-
const RECURSIVE_HIERARCHY_ANNOTATION = 'RecursiveHierarchy';
|
|
169
|
-
/**
|
|
170
|
-
* Checks if the given entity set has aggregate transformations.
|
|
171
|
-
* Returns true if ANY transformations are present in either entity set or entity type annotations.
|
|
172
|
-
*
|
|
173
|
-
* @param entitySet The entity set to check for aggregate transformations.
|
|
174
|
-
* @returns true if the entity set has any aggregate transformations, false otherwise.
|
|
175
|
-
*/
|
|
176
|
-
function hasAggregateTransformations(entitySet) {
|
|
177
|
-
const transformations = entitySet.annotations?.Aggregation?.ApplySupported?.Transformations ||
|
|
178
|
-
entitySet.entityType?.annotations?.Aggregation?.ApplySupported?.Transformations;
|
|
179
|
-
return !!transformations && Array.isArray(transformations) && transformations.length > 0;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Returns only entity sets that have the `Aggregation.ApplySupported` annotation term with the `Transformations` property.
|
|
183
|
-
* This can be found within the entity set annotations or the entity type annotations.
|
|
184
|
-
*
|
|
185
|
-
* @param entitySets the entity sets to filter
|
|
186
|
-
* @returns the filtered entity sets
|
|
187
|
-
*/
|
|
188
|
-
function filterAggregateTransformations(entitySets) {
|
|
189
|
-
return entitySets.filter(hasAggregateTransformations);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Checks if the given entity set name has aggregate transformations in the metadata.
|
|
193
|
-
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
194
|
-
* If no transformations are specified, returns true if ANY transformations are present.
|
|
195
|
-
*
|
|
196
|
-
* @param metadata The metadata (edmx) of the service.
|
|
197
|
-
* @param entitySetName The entity set name to check for aggregate transformations.
|
|
198
|
-
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
199
|
-
* @returns true if the entity set has the required transformations, false otherwise.
|
|
200
|
-
*/
|
|
201
|
-
function hasAggregateTransformationsForEntity(metadata, entitySetName, requiredTransformations) {
|
|
202
|
-
const entitySet = findEntitySetByName(metadata, entitySetName);
|
|
203
|
-
if (!entitySet) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
return hasAggregateTransformationsForEntitySet(entitySet, requiredTransformations);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Checks if the given entity set name has a Hierarchy.RecursiveHierarchy annotation in the metadata.
|
|
210
|
-
*
|
|
211
|
-
* @param metadata The metadata (edmx) of the service.
|
|
212
|
-
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
213
|
-
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
214
|
-
*/
|
|
215
|
-
function hasRecursiveHierarchyForEntity(metadata, entitySetName) {
|
|
216
|
-
const entitySet = findEntitySetByName(metadata, entitySetName);
|
|
217
|
-
if (!entitySet) {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
return hasRecursiveHierarchyForEntitySet(entitySet);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
224
|
-
*
|
|
225
|
-
* @param metadata The metadata (edmx) of the service.
|
|
226
|
-
* @param entitySetName The entity set name to check for recursive hierarchy annotation.
|
|
227
|
-
* @returns The qualifier string if found, undefined otherwise.
|
|
228
|
-
*/
|
|
229
|
-
function getRecursiveHierarchyQualifier(metadata, entitySetName) {
|
|
230
|
-
const entitySet = findEntitySetByName(metadata, entitySetName);
|
|
231
|
-
if (!entitySet) {
|
|
232
|
-
return undefined;
|
|
233
|
-
}
|
|
234
|
-
return getRecursiveHierarchyQualifierForEntitySet(entitySet);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Checks if the given entity set has aggregate transformations.
|
|
238
|
-
* If specific transformations are provided, checks if ALL of those transformations are present.
|
|
239
|
-
* If no transformations are specified, returns true if ANY transformations are present.
|
|
240
|
-
*
|
|
241
|
-
* @param entitySet The entity set to check for aggregate transformations.
|
|
242
|
-
* @param requiredTransformations Optional array of specific transformations to check for. If not provided, checks for any transformations.
|
|
243
|
-
* @returns true if the entity set has the required transformations, false otherwise.
|
|
244
|
-
*/
|
|
245
|
-
function hasAggregateTransformationsForEntitySet(entitySet, requiredTransformations) {
|
|
246
|
-
const transformations = entitySet.annotations?.Aggregation?.ApplySupported?.Transformations ||
|
|
247
|
-
entitySet.entityType?.annotations?.Aggregation?.ApplySupported?.Transformations;
|
|
248
|
-
if (!transformations || !Array.isArray(transformations)) {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
// If no specific transformations required, return true if any transformations exist
|
|
252
|
-
if (!requiredTransformations || requiredTransformations.length === 0) {
|
|
253
|
-
return transformations.length > 0;
|
|
254
|
-
}
|
|
255
|
-
// Check if all required transformations are present
|
|
256
|
-
return requiredTransformations.every((transformation) => transformations.includes(transformation));
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Finds the RecursiveHierarchy annotation key for the given entity set.
|
|
260
|
-
* This is a helper function that both existence check and qualifier extraction can use.
|
|
261
|
-
*
|
|
262
|
-
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
263
|
-
* @returns The RecursiveHierarchy key if found, undefined otherwise.
|
|
264
|
-
*/
|
|
265
|
-
function findRecursiveHierarchyKey(entitySet) {
|
|
266
|
-
const hierarchyAnnotations = entitySet?.entityType?.annotations?.Hierarchy;
|
|
267
|
-
if (!hierarchyAnnotations) {
|
|
268
|
-
return undefined;
|
|
269
|
-
}
|
|
270
|
-
// First try exact match for the most common case
|
|
271
|
-
if (hierarchyAnnotations[RECURSIVE_HIERARCHY_ANNOTATION]) {
|
|
272
|
-
return RECURSIVE_HIERARCHY_ANNOTATION;
|
|
273
|
-
}
|
|
274
|
-
// Then check for qualified versions (RecursiveHierarchy#qualifier)
|
|
275
|
-
return Object.keys(hierarchyAnnotations).find((key) => key.startsWith(RECURSIVE_HIERARCHY_ANNOTATION));
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Checks if the given entity set has a Hierarchy.RecursiveHierarchy annotation.
|
|
279
|
-
*
|
|
280
|
-
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
281
|
-
* @returns true if the entity set has Hierarchy.RecursiveHierarchy annotation, false otherwise.
|
|
282
|
-
*/
|
|
283
|
-
function hasRecursiveHierarchyForEntitySet(entitySet) {
|
|
284
|
-
return !!findRecursiveHierarchyKey(entitySet);
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Gets the qualifier from a Hierarchy.RecursiveHierarchy annotation for the given entity set.
|
|
288
|
-
*
|
|
289
|
-
* @param entitySet The entity set to check for recursive hierarchy annotation.
|
|
290
|
-
* @returns The qualifier string if found, undefined otherwise.
|
|
291
|
-
*/
|
|
292
|
-
function getRecursiveHierarchyQualifierForEntitySet(entitySet) {
|
|
293
|
-
const recursiveHierarchyKey = findRecursiveHierarchyKey(entitySet);
|
|
294
|
-
if (!recursiveHierarchyKey) {
|
|
295
|
-
return undefined;
|
|
296
|
-
}
|
|
297
|
-
// Extract qualifier if present (format: "RecursiveHierarchy#qualifier" or just "RecursiveHierarchy")
|
|
298
|
-
return recursiveHierarchyKey.includes('#') ? recursiveHierarchyKey.split('#')[1] : undefined;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Finds an entity set by name in the metadata.
|
|
302
|
-
*
|
|
303
|
-
* @param metadata The metadata (edmx) of the service.
|
|
304
|
-
* @param entitySetName The name of the entity set to find.
|
|
305
|
-
* @returns The entity set if found, undefined otherwise.
|
|
306
|
-
*/
|
|
307
|
-
function findEntitySetByName(metadata, entitySetName) {
|
|
308
|
-
return metadata.entitySets.find((entitySet) => entitySet.name === entitySetName);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Converts an EDMX string to a ConvertedMetadata object.
|
|
312
|
-
*
|
|
313
|
-
* @param edmx - The EDMX string to convert.
|
|
314
|
-
* @returns The converted metadata object.
|
|
315
|
-
* @throws If the EDMX cannot be parsed or the OData version is unparseable.
|
|
316
|
-
*/
|
|
317
|
-
function convertEdmxToConvertedMetadata(edmx) {
|
|
318
|
-
try {
|
|
319
|
-
const convertedMetadata = (0, annotation_converter_1.convert)((0, edmx_parser_1.parse)(edmx));
|
|
320
|
-
const parsedOdataVersion = Number.parseInt(convertedMetadata?.version, 10);
|
|
321
|
-
if (Number.isNaN(parsedOdataVersion)) {
|
|
322
|
-
throw new Error((0, i18n_1.t)('errors.unparseableOdataVersion'));
|
|
323
|
-
}
|
|
324
|
-
return convertedMetadata;
|
|
325
|
-
}
|
|
326
|
-
catch (error) {
|
|
327
|
-
throw new Error((0, i18n_1.t)('errors.unparseableMetadata', { error: error.message }));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
136
|
//# sourceMappingURL=helpers.js.map
|
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.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
"semver": "7.5.4",
|
|
33
33
|
"@sap-ux/btp-utils": "1.1.4",
|
|
34
34
|
"@sap-ux/feature-toggle": "0.3.3",
|
|
35
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
35
|
+
"@sap-ux/fiori-generator-shared": "0.13.31",
|
|
36
36
|
"@sap-ux/guided-answers-helper": "0.4.0",
|
|
37
|
-
"@sap-ux/telemetry": "0.6.
|
|
37
|
+
"@sap-ux/telemetry": "0.6.36",
|
|
38
38
|
"@sap-ux/logger": "0.7.0",
|
|
39
|
+
"@sap-ux/odata-service-writer": "0.27.28",
|
|
39
40
|
"@sap-ux/ui5-info": "0.13.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|