@sap-ux/ui5-test-writer 0.9.14 → 1.0.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/fiori-elements-opa-writer.js +52 -54
- package/dist/fiori-freestyle-opa-writer.d.ts +1 -1
- package/dist/fiori-freestyle-opa-writer.js +28 -29
- package/dist/i18n.js +9 -19
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -9
- package/dist/types.js +2 -6
- package/dist/utils/actionUtils.d.ts +4 -4
- package/dist/utils/actionUtils.js +20 -38
- package/dist/utils/flpSandboxUtils.js +3 -6
- package/dist/utils/listReportUtils.d.ts +5 -5
- package/dist/utils/listReportUtils.js +35 -55
- package/dist/utils/modelUtils.d.ts +3 -3
- package/dist/utils/modelUtils.js +21 -31
- package/dist/utils/objectPageUtils.d.ts +3 -3
- package/dist/utils/objectPageUtils.js +39 -43
- package/dist/utils/opaQUnitUtils.js +24 -34
- package/dist/utils/tableUtils.d.ts +2 -2
- package/dist/utils/tableUtils.js +7 -12
- package/package.json +11 -9
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.extractActionMethodName = extractActionMethodName;
|
|
4
|
-
exports.findOperationAvailableAnnotation = findOperationAvailableAnnotation;
|
|
5
|
-
exports.analyzeOperationAvailability = analyzeOperationAvailability;
|
|
6
|
-
exports.extractEnumMemberValue = extractEnumMemberValue;
|
|
7
|
-
exports.buildActionButtonState = buildActionButtonState;
|
|
8
|
-
exports.buildActionStateFromSpecModelKey = buildActionStateFromSpecModelKey;
|
|
9
|
-
exports.analyzeRestrictionValue = analyzeRestrictionValue;
|
|
10
|
-
exports.analyzeInsertRestrictions = analyzeInsertRestrictions;
|
|
11
|
-
exports.analyzeDeleteRestrictions = analyzeDeleteRestrictions;
|
|
12
|
-
exports.analyzeUpdateRestrictions = analyzeUpdateRestrictions;
|
|
13
|
-
exports.checkButtonVisibilityFromMetadata = checkButtonVisibilityFromMetadata;
|
|
14
|
-
exports.checkButtonVisibility = checkButtonVisibility;
|
|
15
|
-
exports.checkEditVisibility = checkEditVisibility;
|
|
16
|
-
exports.safeCheckButtonVisibilityFromMetadata = safeCheckButtonVisibilityFromMetadata;
|
|
17
|
-
exports.safeCheckButtonVisibility = safeCheckButtonVisibility;
|
|
18
|
-
exports.safeCheckEditVisibility = safeCheckEditVisibility;
|
|
19
|
-
const edmx_parser_1 = require("@sap-ux/edmx-parser");
|
|
20
|
-
const annotation_converter_1 = require("@sap-ux/annotation-converter");
|
|
1
|
+
import { parse } from '@sap-ux/edmx-parser';
|
|
2
|
+
import { convert } from '@sap-ux/annotation-converter';
|
|
21
3
|
const DATA_FIELD_FOR_ACTION = 'DataFieldForAction';
|
|
22
4
|
/**
|
|
23
5
|
* Extracts the action method name from a fully qualified action string.
|
|
@@ -25,7 +7,7 @@ const DATA_FIELD_FOR_ACTION = 'DataFieldForAction';
|
|
|
25
7
|
* @param actionName The fully qualified action name
|
|
26
8
|
* @returns The action method name
|
|
27
9
|
*/
|
|
28
|
-
function extractActionMethodName(actionName) {
|
|
10
|
+
export function extractActionMethodName(actionName) {
|
|
29
11
|
const match = /\.([^.()]+)\(/.exec(actionName);
|
|
30
12
|
if (match?.[1]) {
|
|
31
13
|
return match[1];
|
|
@@ -48,7 +30,7 @@ function extractActionMethodName(actionName) {
|
|
|
48
30
|
* @param actionMethodName The action method name
|
|
49
31
|
* @returns The OperationAvailable annotation value or undefined if not found
|
|
50
32
|
*/
|
|
51
|
-
function findOperationAvailableAnnotation(metadata, actionMethodName) {
|
|
33
|
+
export function findOperationAvailableAnnotation(metadata, actionMethodName) {
|
|
52
34
|
if (metadata.actions) {
|
|
53
35
|
const foundAction = metadata.actions.find((action) => action.name === actionMethodName || action.fullyQualifiedName?.includes(`.${actionMethodName}(`));
|
|
54
36
|
if (foundAction?.annotations?.Core?.OperationAvailable !== undefined) {
|
|
@@ -72,7 +54,7 @@ function findOperationAvailableAnnotation(metadata, actionMethodName) {
|
|
|
72
54
|
* @param isEntityBound Whether the action is bound to a single entity (requires row selection to enable)
|
|
73
55
|
* @returns Object containing enabled state and optional dynamic path
|
|
74
56
|
*/
|
|
75
|
-
function analyzeOperationAvailability(operationAvailable, isEntityBound) {
|
|
57
|
+
export function analyzeOperationAvailability(operationAvailable, isEntityBound) {
|
|
76
58
|
if (operationAvailable === undefined) {
|
|
77
59
|
return { enabled: !isEntityBound };
|
|
78
60
|
}
|
|
@@ -94,7 +76,7 @@ function analyzeOperationAvailability(operationAvailable, isEntityBound) {
|
|
|
94
76
|
* @param enumValue The enum value object
|
|
95
77
|
* @returns The extracted enum value string
|
|
96
78
|
*/
|
|
97
|
-
function extractEnumMemberValue(enumValue) {
|
|
79
|
+
export function extractEnumMemberValue(enumValue) {
|
|
98
80
|
if (typeof enumValue === 'string') {
|
|
99
81
|
return enumValue;
|
|
100
82
|
}
|
|
@@ -112,7 +94,7 @@ function extractEnumMemberValue(enumValue) {
|
|
|
112
94
|
* @param metadata The converted metadata
|
|
113
95
|
* @returns ActionButtonState for the action
|
|
114
96
|
*/
|
|
115
|
-
function buildActionButtonState(item, metadata) {
|
|
97
|
+
export function buildActionButtonState(item, metadata) {
|
|
116
98
|
const actionString = item.Action || '';
|
|
117
99
|
const actionMethod = extractActionMethodName(actionString);
|
|
118
100
|
const operationAvailable = findOperationAvailableAnnotation(metadata, actionMethod);
|
|
@@ -143,7 +125,7 @@ function buildActionButtonState(item, metadata) {
|
|
|
143
125
|
* @param schemaNamespace The OData schema namespace (used as service identifier)
|
|
144
126
|
* @returns ActionButtonState or undefined if the key is not a DataFieldForAction key
|
|
145
127
|
*/
|
|
146
|
-
function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetadata, schemaNamespace) {
|
|
128
|
+
export function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetadata, schemaNamespace) {
|
|
147
129
|
const keyParts = aggregationKey.split('::');
|
|
148
130
|
if (keyParts[0] !== DATA_FIELD_FOR_ACTION || !keyParts[1]) {
|
|
149
131
|
return undefined;
|
|
@@ -171,7 +153,7 @@ function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetada
|
|
|
171
153
|
* @param value The annotation value — boolean, path object, or undefined
|
|
172
154
|
* @returns ButtonState indicating visibility and enabled state
|
|
173
155
|
*/
|
|
174
|
-
function analyzeRestrictionValue(value) {
|
|
156
|
+
export function analyzeRestrictionValue(value) {
|
|
175
157
|
const defaultState = { visible: true, enabled: true };
|
|
176
158
|
if (value === undefined || value === null) {
|
|
177
159
|
return defaultState;
|
|
@@ -193,7 +175,7 @@ function analyzeRestrictionValue(value) {
|
|
|
193
175
|
* @param restriction The InsertRestrictions annotation for the entity set
|
|
194
176
|
* @returns ButtonState indicating visibility and enabled state based on the Insertable value
|
|
195
177
|
*/
|
|
196
|
-
function analyzeInsertRestrictions(restriction) {
|
|
178
|
+
export function analyzeInsertRestrictions(restriction) {
|
|
197
179
|
const value = restriction ? restriction['Insertable'] : undefined;
|
|
198
180
|
return analyzeRestrictionValue(value);
|
|
199
181
|
}
|
|
@@ -203,7 +185,7 @@ function analyzeInsertRestrictions(restriction) {
|
|
|
203
185
|
* @param restriction The DeleteRestrictions annotation for the entity set
|
|
204
186
|
* @returns ButtonState indicating visibility and enabled state based on the Deletable value
|
|
205
187
|
*/
|
|
206
|
-
function analyzeDeleteRestrictions(restriction) {
|
|
188
|
+
export function analyzeDeleteRestrictions(restriction) {
|
|
207
189
|
const value = restriction ? restriction['Deletable'] : undefined;
|
|
208
190
|
return analyzeRestrictionValue(value);
|
|
209
191
|
}
|
|
@@ -213,7 +195,7 @@ function analyzeDeleteRestrictions(restriction) {
|
|
|
213
195
|
* @param restriction The UpdateRestrictions annotation for the entity set
|
|
214
196
|
* @returns ButtonState indicating visibility and enabled state based on the Updatable value
|
|
215
197
|
*/
|
|
216
|
-
function analyzeUpdateRestrictions(restriction) {
|
|
198
|
+
export function analyzeUpdateRestrictions(restriction) {
|
|
217
199
|
const value = restriction ? restriction['Updatable'] : undefined;
|
|
218
200
|
return analyzeRestrictionValue(value);
|
|
219
201
|
}
|
|
@@ -226,7 +208,7 @@ function analyzeUpdateRestrictions(restriction) {
|
|
|
226
208
|
* @returns ButtonVisibilityResult containing the state of create and delete buttons
|
|
227
209
|
* @throws {Error} If entity set is not found
|
|
228
210
|
*/
|
|
229
|
-
function checkButtonVisibilityFromMetadata(convertedMetadata, entitySetName) {
|
|
211
|
+
export function checkButtonVisibilityFromMetadata(convertedMetadata, entitySetName) {
|
|
230
212
|
const entitySet = convertedMetadata.entitySets.find((es) => es.name === entitySetName);
|
|
231
213
|
if (!entitySet) {
|
|
232
214
|
throw new Error(`Entity set '${entitySetName}' not found in metadata`);
|
|
@@ -247,9 +229,9 @@ function checkButtonVisibilityFromMetadata(convertedMetadata, entitySetName) {
|
|
|
247
229
|
* @returns ButtonVisibilityResult containing the state of create and delete buttons
|
|
248
230
|
* @throws {Error} If metadata cannot be parsed or entity set is not found
|
|
249
231
|
*/
|
|
250
|
-
function checkButtonVisibility(metadataXml, entitySetName) {
|
|
232
|
+
export function checkButtonVisibility(metadataXml, entitySetName) {
|
|
251
233
|
try {
|
|
252
|
-
return checkButtonVisibilityFromMetadata(
|
|
234
|
+
return checkButtonVisibilityFromMetadata(convert(parse(metadataXml)), entitySetName);
|
|
253
235
|
}
|
|
254
236
|
catch (error) {
|
|
255
237
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -265,9 +247,9 @@ function checkButtonVisibility(metadataXml, entitySetName) {
|
|
|
265
247
|
* @returns ButtonState for the edit button
|
|
266
248
|
* @throws {Error} If metadata cannot be parsed or entity set is not found
|
|
267
249
|
*/
|
|
268
|
-
function checkEditVisibility(metadataXml, entitySetName) {
|
|
250
|
+
export function checkEditVisibility(metadataXml, entitySetName) {
|
|
269
251
|
try {
|
|
270
|
-
const convertedMetadata =
|
|
252
|
+
const convertedMetadata = convert(parse(metadataXml));
|
|
271
253
|
const entitySet = convertedMetadata.entitySets.find((es) => es.name === entitySetName);
|
|
272
254
|
if (!entitySet) {
|
|
273
255
|
throw new Error(`Entity set '${entitySetName}' not found in metadata`);
|
|
@@ -288,7 +270,7 @@ function checkEditVisibility(metadataXml, entitySetName) {
|
|
|
288
270
|
* @param log Optional logger instance
|
|
289
271
|
* @returns Button visibility result or undefined if error occurs
|
|
290
272
|
*/
|
|
291
|
-
function safeCheckButtonVisibilityFromMetadata(convertedMetadata, entitySetName, log) {
|
|
273
|
+
export function safeCheckButtonVisibilityFromMetadata(convertedMetadata, entitySetName, log) {
|
|
292
274
|
try {
|
|
293
275
|
return checkButtonVisibilityFromMetadata(convertedMetadata, entitySetName);
|
|
294
276
|
}
|
|
@@ -305,7 +287,7 @@ function safeCheckButtonVisibilityFromMetadata(convertedMetadata, entitySetName,
|
|
|
305
287
|
* @param log Optional logger instance
|
|
306
288
|
* @returns Button visibility result or undefined if error occurs
|
|
307
289
|
*/
|
|
308
|
-
function safeCheckButtonVisibility(metadata, entitySetName, log) {
|
|
290
|
+
export function safeCheckButtonVisibility(metadata, entitySetName, log) {
|
|
309
291
|
try {
|
|
310
292
|
return checkButtonVisibility(metadata, entitySetName);
|
|
311
293
|
}
|
|
@@ -322,7 +304,7 @@ function safeCheckButtonVisibility(metadata, entitySetName, log) {
|
|
|
322
304
|
* @param log Optional logger instance
|
|
323
305
|
* @returns ButtonState for the edit button, or undefined if error occurs
|
|
324
306
|
*/
|
|
325
|
-
function safeCheckEditVisibility(metadata, entitySetName, log) {
|
|
307
|
+
export function safeCheckEditVisibility(metadata, entitySetName, log) {
|
|
326
308
|
try {
|
|
327
309
|
return checkEditVisibility(metadata, entitySetName);
|
|
328
310
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Utility for reading the FLP sandbox HTML file and extracting the
|
|
4
3
|
* application hash (intent) from the sap-ushell-config applications object.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
exports.readHashFromFlpSandbox = readHashFromFlpSandbox;
|
|
8
|
-
const node_path_1 = require("node:path");
|
|
5
|
+
import { join } from 'node:path';
|
|
9
6
|
/**
|
|
10
7
|
* Regex to extract the first application key from the sap-ushell-config
|
|
11
8
|
* `applications` block. Matches patterns like:
|
|
@@ -26,9 +23,9 @@ const APPLICATIONS_KEY_REGEX = /applications\s*:\s*\{[^"]*"([^"]+)"\s*:/;
|
|
|
26
23
|
* @param fs - mem-fs-editor instance used to read the file
|
|
27
24
|
* @returns the application key (e.g. `fincashbankmanage-tile`), or undefined
|
|
28
25
|
*/
|
|
29
|
-
function readHashFromFlpSandbox(htmlRelativePath, webappPath, fs) {
|
|
26
|
+
export function readHashFromFlpSandbox(htmlRelativePath, webappPath, fs) {
|
|
30
27
|
try {
|
|
31
|
-
const filePath =
|
|
28
|
+
const filePath = join(webappPath, htmlRelativePath);
|
|
32
29
|
const content = fs.read(filePath);
|
|
33
30
|
const match = APPLICATIONS_KEY_REGEX.exec(content);
|
|
34
31
|
return match?.[1];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Logger } from '@sap-ux/logger';
|
|
2
|
-
import type { TreeAggregations, TreeModel } from '@sap/ux-specification/dist/types/src/parser';
|
|
3
|
-
import type { ActionButtonsResult, ActionButtonState, ButtonState, FEV4ManifestTarget, ListReportFeatures } from '../types';
|
|
2
|
+
import type { TreeAggregations, TreeModel } from '@sap/ux-specification/dist/types/src/parser/index.js';
|
|
3
|
+
import type { ActionButtonsResult, ActionButtonState, ButtonState, FEV4ManifestTarget, ListReportFeatures } from '../types.js';
|
|
4
4
|
import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
|
|
5
|
-
import { safeCheckButtonVisibility } from './actionUtils';
|
|
6
|
-
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application';
|
|
5
|
+
import { safeCheckButtonVisibility } from './actionUtils.js';
|
|
6
|
+
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application.js';
|
|
7
7
|
import type { Manifest } from '@sap-ux/project-access';
|
|
8
|
-
export { checkButtonVisibility, safeCheckEditVisibility } from './actionUtils';
|
|
8
|
+
export { checkButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
|
|
9
9
|
export { safeCheckButtonVisibility };
|
|
10
10
|
/**
|
|
11
11
|
* Builds a button state object from button visibility result.
|
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.isALPManifestTarget = isALPManifestTarget;
|
|
8
|
-
exports.isALPFromManifest = isALPFromManifest;
|
|
9
|
-
exports.getListReportFeatures = getListReportFeatures;
|
|
10
|
-
exports.getToolBarActions = getToolBarActions;
|
|
11
|
-
exports.getFilterFieldNames = getFilterFieldNames;
|
|
12
|
-
exports.checkActionButtonStatesFromMetadata = checkActionButtonStatesFromMetadata;
|
|
13
|
-
exports.checkActionButtonStates = checkActionButtonStates;
|
|
14
|
-
exports.getToolBarActionNames = getToolBarActionNames;
|
|
15
|
-
exports.getToolBarActionItems = getToolBarActionItems;
|
|
16
|
-
exports.isSemanticKeyInFilterBar = isSemanticKeyInFilterBar;
|
|
17
|
-
exports.getSemanticKeyPropertiesFromMetadata = getSemanticKeyPropertiesFromMetadata;
|
|
18
|
-
exports.getSemanticKeyProperties = getSemanticKeyProperties;
|
|
19
|
-
const modelUtils_1 = require("./modelUtils");
|
|
20
|
-
const edmx_parser_1 = require("@sap-ux/edmx-parser");
|
|
21
|
-
const annotation_converter_1 = require("@sap-ux/annotation-converter");
|
|
22
|
-
const actionUtils_1 = require("./actionUtils");
|
|
23
|
-
Object.defineProperty(exports, "safeCheckButtonVisibility", { enumerable: true, get: function () { return actionUtils_1.safeCheckButtonVisibility; } });
|
|
24
|
-
var actionUtils_2 = require("./actionUtils");
|
|
25
|
-
Object.defineProperty(exports, "checkButtonVisibility", { enumerable: true, get: function () { return actionUtils_2.checkButtonVisibility; } });
|
|
26
|
-
Object.defineProperty(exports, "safeCheckEditVisibility", { enumerable: true, get: function () { return actionUtils_2.safeCheckEditVisibility; } });
|
|
1
|
+
import { getFilterFields, getSelectionFieldItems, getTableColumnData, getAggregations } from './modelUtils.js';
|
|
2
|
+
import { parse } from '@sap-ux/edmx-parser';
|
|
3
|
+
import { convert } from '@sap-ux/annotation-converter';
|
|
4
|
+
import { extractActionMethodName, buildActionButtonState, safeCheckButtonVisibility, safeCheckButtonVisibilityFromMetadata } from './actionUtils.js';
|
|
5
|
+
export { checkButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
|
|
6
|
+
export { safeCheckButtonVisibility };
|
|
27
7
|
/**
|
|
28
8
|
* Builds a button state object from button visibility result.
|
|
29
9
|
*
|
|
30
10
|
* @param buttonState - The button state from visibility check
|
|
31
11
|
* @returns Button state object with visible, enabled, and optional dynamicPath properties
|
|
32
12
|
*/
|
|
33
|
-
function buildButtonState(buttonState) {
|
|
13
|
+
export function buildButtonState(buttonState) {
|
|
34
14
|
return {
|
|
35
15
|
visible: !!buttonState?.visible,
|
|
36
16
|
enabled: buttonState?.enabled,
|
|
@@ -46,7 +26,7 @@ function buildButtonState(buttonState) {
|
|
|
46
26
|
* @param log - Optional logger instance
|
|
47
27
|
* @returns Array of action button states or empty array if error occurs
|
|
48
28
|
*/
|
|
49
|
-
function safeCheckActionButtonStates(convertedMetadata, entitySetName, actionNames, log) {
|
|
29
|
+
export function safeCheckActionButtonStates(convertedMetadata, entitySetName, actionNames, log) {
|
|
50
30
|
try {
|
|
51
31
|
return checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames).actions;
|
|
52
32
|
}
|
|
@@ -63,7 +43,7 @@ function safeCheckActionButtonStates(convertedMetadata, entitySetName, actionNam
|
|
|
63
43
|
* @param log - Optional logger instance
|
|
64
44
|
* @returns Array of semantic key properties or undefined if error occurs
|
|
65
45
|
*/
|
|
66
|
-
function safeGetSemanticKeyProperties(convertedMetadata, entitySetName, log) {
|
|
46
|
+
export function safeGetSemanticKeyProperties(convertedMetadata, entitySetName, log) {
|
|
67
47
|
try {
|
|
68
48
|
return getSemanticKeyPropertiesFromMetadata(convertedMetadata, entitySetName, true);
|
|
69
49
|
}
|
|
@@ -80,7 +60,7 @@ function safeGetSemanticKeyProperties(convertedMetadata, entitySetName, log) {
|
|
|
80
60
|
* @param target - the manifest routing target to inspect
|
|
81
61
|
* @returns true if the target represents an ALP configuration
|
|
82
62
|
*/
|
|
83
|
-
function isALPManifestTarget(target) {
|
|
63
|
+
export function isALPManifestTarget(target) {
|
|
84
64
|
return (target.options?.settings?.views?.paths?.some((path) => Array.isArray(path.primary) && path.primary.length > 0) ?? false);
|
|
85
65
|
}
|
|
86
66
|
/**
|
|
@@ -90,7 +70,7 @@ function isALPManifestTarget(target) {
|
|
|
90
70
|
* @param targetKey - optional specific target key to check; if omitted all ListReport targets are checked
|
|
91
71
|
* @returns true if the target (or any ListReport target) is an ALP
|
|
92
72
|
*/
|
|
93
|
-
function isALPFromManifest(manifest, targetKey) {
|
|
73
|
+
export function isALPFromManifest(manifest, targetKey) {
|
|
94
74
|
const targets = manifest['sap.ui5']?.routing?.targets;
|
|
95
75
|
if (!targets) {
|
|
96
76
|
return false;
|
|
@@ -110,7 +90,7 @@ function isALPFromManifest(manifest, targetKey) {
|
|
|
110
90
|
* @param manifest - optional application manifest, used to detect ALP configuration
|
|
111
91
|
* @returns feature data extracted from the List Report page model
|
|
112
92
|
*/
|
|
113
|
-
function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
93
|
+
export function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
114
94
|
const toolbarActions = getToolBarActionNames(listReportPage.model, log);
|
|
115
95
|
const filterBarItems = getFilterFieldNames(listReportPage.model, log);
|
|
116
96
|
let buttonVisibility;
|
|
@@ -119,8 +99,8 @@ function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
|
119
99
|
if (metadata && listReportPage.entitySet) {
|
|
120
100
|
const entitySetName = listReportPage.entitySet;
|
|
121
101
|
try {
|
|
122
|
-
const convertedMetadata =
|
|
123
|
-
buttonVisibility =
|
|
102
|
+
const convertedMetadata = convert(parse(metadata));
|
|
103
|
+
buttonVisibility = safeCheckButtonVisibilityFromMetadata(convertedMetadata, entitySetName, log);
|
|
124
104
|
semanticKeyProperties = safeGetSemanticKeyProperties(convertedMetadata, entitySetName, log);
|
|
125
105
|
toolBarActions = safeCheckActionButtonStates(convertedMetadata, entitySetName, toolbarActions, log);
|
|
126
106
|
}
|
|
@@ -136,7 +116,7 @@ function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
|
136
116
|
createButton: buildButtonState(buttonVisibility?.create),
|
|
137
117
|
deleteButton: buildButtonState(buttonVisibility?.delete),
|
|
138
118
|
filterBarItems,
|
|
139
|
-
tableColumns:
|
|
119
|
+
tableColumns: getTableColumnData(listReportPage.model, log),
|
|
140
120
|
toolBarActions,
|
|
141
121
|
isALP: manifest ? isALPFromManifest(manifest, listReportPage.name) : false,
|
|
142
122
|
semanticKey: {
|
|
@@ -151,13 +131,13 @@ function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
|
151
131
|
* @param pageModel - The tree model containing toolbar definitions.
|
|
152
132
|
* @returns The toolbar actions aggregation object.
|
|
153
133
|
*/
|
|
154
|
-
function getToolBarActions(pageModel) {
|
|
155
|
-
const table =
|
|
156
|
-
const tableAggregations =
|
|
134
|
+
export function getToolBarActions(pageModel) {
|
|
135
|
+
const table = getAggregations(pageModel.root)['table'];
|
|
136
|
+
const tableAggregations = getAggregations(table);
|
|
157
137
|
const toolBar = tableAggregations['toolBar'];
|
|
158
|
-
const toolBarAggregations =
|
|
138
|
+
const toolBarAggregations = getAggregations(toolBar);
|
|
159
139
|
const actions = toolBarAggregations['actions'];
|
|
160
|
-
const actionAggregations =
|
|
140
|
+
const actionAggregations = getAggregations(actions);
|
|
161
141
|
return actionAggregations;
|
|
162
142
|
}
|
|
163
143
|
/**
|
|
@@ -167,11 +147,11 @@ function getToolBarActions(pageModel) {
|
|
|
167
147
|
* @param log - optional logger instance
|
|
168
148
|
* @returns - an array of filter field names
|
|
169
149
|
*/
|
|
170
|
-
function getFilterFieldNames(pageModel, log) {
|
|
150
|
+
export function getFilterFieldNames(pageModel, log) {
|
|
171
151
|
let filterBarItems = [];
|
|
172
152
|
try {
|
|
173
|
-
const filterBarAggregations =
|
|
174
|
-
filterBarItems =
|
|
153
|
+
const filterBarAggregations = getFilterFields(pageModel);
|
|
154
|
+
filterBarItems = getSelectionFieldItems(filterBarAggregations);
|
|
175
155
|
}
|
|
176
156
|
catch (error) {
|
|
177
157
|
log?.debug(error);
|
|
@@ -190,7 +170,7 @@ function getFilterFieldNames(pageModel, log) {
|
|
|
190
170
|
* @returns ActionButtonsResult containing the list of action buttons and their states
|
|
191
171
|
* @throws {Error} If entity set is not found
|
|
192
172
|
*/
|
|
193
|
-
function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames) {
|
|
173
|
+
export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames) {
|
|
194
174
|
const entitySet = convertedMetadata.entitySets.find((es) => es.name === entitySetName);
|
|
195
175
|
if (!entitySet) {
|
|
196
176
|
throw new Error(`Entity set '${entitySetName}' not found in metadata`);
|
|
@@ -218,9 +198,9 @@ function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, a
|
|
|
218
198
|
* @returns ActionButtonsResult containing the list of action buttons and their states
|
|
219
199
|
* @throws {Error} If metadata cannot be parsed or entity set is not found
|
|
220
200
|
*/
|
|
221
|
-
function checkActionButtonStates(metadataXml, entitySetName, actionNames) {
|
|
201
|
+
export function checkActionButtonStates(metadataXml, entitySetName, actionNames) {
|
|
222
202
|
try {
|
|
223
|
-
return checkActionButtonStatesFromMetadata(
|
|
203
|
+
return checkActionButtonStatesFromMetadata(convert(parse(metadataXml)), entitySetName, actionNames);
|
|
224
204
|
}
|
|
225
205
|
catch (error) {
|
|
226
206
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -239,11 +219,11 @@ function findActionStates(dataFieldForActions, actionNames, metadata) {
|
|
|
239
219
|
const actionStates = [];
|
|
240
220
|
for (const actionName of actionNames) {
|
|
241
221
|
const item = dataFieldForActions.find((dfa) => {
|
|
242
|
-
const actionMethod =
|
|
222
|
+
const actionMethod = extractActionMethodName(dfa.Action || '');
|
|
243
223
|
return actionMethod === actionName || dfa.Label === actionName;
|
|
244
224
|
});
|
|
245
225
|
if (item) {
|
|
246
|
-
actionStates.push(
|
|
226
|
+
actionStates.push(buildActionButtonState(item, metadata));
|
|
247
227
|
}
|
|
248
228
|
}
|
|
249
229
|
return actionStates;
|
|
@@ -256,7 +236,7 @@ function findActionStates(dataFieldForActions, actionNames, metadata) {
|
|
|
256
236
|
* @returns List of all action button states
|
|
257
237
|
*/
|
|
258
238
|
function extractAllActionStates(dataFieldForActions, metadata) {
|
|
259
|
-
return dataFieldForActions.map((item) =>
|
|
239
|
+
return dataFieldForActions.map((item) => buildActionButtonState(item, metadata));
|
|
260
240
|
}
|
|
261
241
|
/**
|
|
262
242
|
* Retrieves toolbar action names from the page model using ux-specification.
|
|
@@ -265,7 +245,7 @@ function extractAllActionStates(dataFieldForActions, metadata) {
|
|
|
265
245
|
* @param log - optional logger instance
|
|
266
246
|
* @returns - an array of toolbar action names
|
|
267
247
|
*/
|
|
268
|
-
function getToolBarActionNames(pageModel, log) {
|
|
248
|
+
export function getToolBarActionNames(pageModel, log) {
|
|
269
249
|
let toolBarActions = [];
|
|
270
250
|
try {
|
|
271
251
|
const toolbarActions = getToolBarActions(pageModel);
|
|
@@ -285,7 +265,7 @@ function getToolBarActionNames(pageModel, log) {
|
|
|
285
265
|
* @param toolBarActionsAgg - The toolbar actions aggregation containing action definitions.
|
|
286
266
|
* @returns An array of toolbar action descriptions.
|
|
287
267
|
*/
|
|
288
|
-
function getToolBarActionItems(toolBarActionsAgg) {
|
|
268
|
+
export function getToolBarActionItems(toolBarActionsAgg) {
|
|
289
269
|
return extractItemDescriptions(toolBarActionsAgg);
|
|
290
270
|
}
|
|
291
271
|
/**
|
|
@@ -310,7 +290,7 @@ function extractItemDescriptions(aggregations) {
|
|
|
310
290
|
* @param log - optional logger instance
|
|
311
291
|
* @returns true if every SemanticKey property appears in the filter bar, false otherwise
|
|
312
292
|
*/
|
|
313
|
-
function isSemanticKeyInFilterBar(pageModel, metadataXml, entitySetName, log) {
|
|
293
|
+
export function isSemanticKeyInFilterBar(pageModel, metadataXml, entitySetName, log) {
|
|
314
294
|
try {
|
|
315
295
|
const semanticKeys = getSemanticKeyProperties(metadataXml, entitySetName, true);
|
|
316
296
|
if (!semanticKeys.length) {
|
|
@@ -333,7 +313,7 @@ function isSemanticKeyInFilterBar(pageModel, metadataXml, entitySetName, log) {
|
|
|
333
313
|
* @returns An array of PropertyPath string values (or their labels) from the SemanticKey annotation, or an empty array if not found
|
|
334
314
|
* @throws {Error} If the entity set is not found
|
|
335
315
|
*/
|
|
336
|
-
function getSemanticKeyPropertiesFromMetadata(convertedMetadata, entitySetName, resolveLabels = false) {
|
|
316
|
+
export function getSemanticKeyPropertiesFromMetadata(convertedMetadata, entitySetName, resolveLabels = false) {
|
|
337
317
|
const entitySet = convertedMetadata.entitySets.find((es) => es.name === entitySetName);
|
|
338
318
|
if (!entitySet) {
|
|
339
319
|
throw new Error(`Entity set '${entitySetName}' not found in metadata`);
|
|
@@ -363,7 +343,7 @@ function getSemanticKeyPropertiesFromMetadata(convertedMetadata, entitySetName,
|
|
|
363
343
|
* @returns An array of PropertyPath string values (or their labels) from the SemanticKey annotation, or an empty array if not found
|
|
364
344
|
* @throws {Error} If the metadata cannot be parsed or the entity set is not found
|
|
365
345
|
*/
|
|
366
|
-
function getSemanticKeyProperties(metadataXml, entitySetName, resolveLabels = false) {
|
|
367
|
-
return getSemanticKeyPropertiesFromMetadata(
|
|
346
|
+
export function getSemanticKeyProperties(metadataXml, entitySetName, resolveLabels = false) {
|
|
347
|
+
return getSemanticKeyPropertiesFromMetadata(convert(parse(metadataXml)), entitySetName, resolveLabels);
|
|
368
348
|
}
|
|
369
349
|
//# sourceMappingURL=listReportUtils.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
2
|
import type { Manifest } from '@sap-ux/project-access';
|
|
3
3
|
import type { Logger } from '@sap-ux/logger';
|
|
4
|
-
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application';
|
|
5
|
-
import type { TreeAggregation, TreeAggregations, TreeModel, ApplicationModel } from '@sap/ux-specification/dist/types/src/parser';
|
|
6
|
-
import type { AppFeatures, FPMFeatures } from '../types';
|
|
4
|
+
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application.js';
|
|
5
|
+
import type { TreeAggregation, TreeAggregations, TreeModel, ApplicationModel } from '@sap/ux-specification/dist/types/src/parser/index.js';
|
|
6
|
+
import type { AppFeatures, FPMFeatures } from '../types.js';
|
|
7
7
|
export interface AggregationItem extends TreeAggregation {
|
|
8
8
|
description: string;
|
|
9
9
|
schema: {
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getFPMPage = getFPMPage;
|
|
7
|
-
exports.getFPMFeatures = getFPMFeatures;
|
|
8
|
-
exports.getAggregations = getAggregations;
|
|
9
|
-
exports.getSelectionFieldItems = getSelectionFieldItems;
|
|
10
|
-
exports.getFilterFields = getFilterFields;
|
|
11
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
12
|
-
const page_1 = require("@sap/ux-specification/dist/types/src/common/page");
|
|
13
|
-
const objectPageUtils_1 = require("./objectPageUtils");
|
|
14
|
-
const listReportUtils_1 = require("./listReportUtils");
|
|
15
|
-
const tableUtils_1 = require("./tableUtils");
|
|
1
|
+
import { createApplicationAccess } from '@sap-ux/project-access';
|
|
2
|
+
import { PageTypeV4 } from '@sap/ux-specification/dist/types/src/common/index.js';
|
|
3
|
+
import { getObjectPageFeatures, getObjectPages } from './objectPageUtils.js';
|
|
4
|
+
import { getFilterFieldNames, getListReportFeatures } from './listReportUtils.js';
|
|
5
|
+
import { extractTableColumnsFromNode } from './tableUtils.js';
|
|
16
6
|
/**
|
|
17
7
|
* Gets app features from the application model using ux-specification.
|
|
18
8
|
*
|
|
@@ -23,7 +13,7 @@ const tableUtils_1 = require("./tableUtils");
|
|
|
23
13
|
* @param manifest - optional application manifest, used to detect ALP configuration
|
|
24
14
|
* @returns feature data extracted from the application model
|
|
25
15
|
*/
|
|
26
|
-
async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
16
|
+
export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
27
17
|
const featureData = {};
|
|
28
18
|
let listReportPage = null;
|
|
29
19
|
let objectPages = null;
|
|
@@ -33,7 +23,7 @@ async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
33
23
|
// specification and readApp might not be available due to specification version, fail gracefully
|
|
34
24
|
try {
|
|
35
25
|
// readApp calls createApplicationAccess internally if given a path, but it uses the "live" version of project-access without fs enhancement
|
|
36
|
-
const appAccess = await
|
|
26
|
+
const appAccess = await createApplicationAccess(basePath, { fs: fs });
|
|
37
27
|
const specification = await appAccess.getSpecification();
|
|
38
28
|
const appModel = await specification.readApp({ app: appAccess, fs: fs });
|
|
39
29
|
if (!projectMetadata) {
|
|
@@ -43,7 +33,7 @@ async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
35
|
listReportPage = appModel?.applicationModel ? getListReportPage(appModel.applicationModel) : listReportPage;
|
|
46
|
-
objectPages = appModel?.applicationModel ?
|
|
36
|
+
objectPages = appModel?.applicationModel ? getObjectPages(appModel.applicationModel) : objectPages;
|
|
47
37
|
fpmPage = appModel?.applicationModel ? getFPMPage(appModel.applicationModel, log) : fpmPage;
|
|
48
38
|
}
|
|
49
39
|
catch (error) {
|
|
@@ -58,11 +48,11 @@ async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
58
48
|
// attempt to get individual feature data
|
|
59
49
|
try {
|
|
60
50
|
if (listReportPage) {
|
|
61
|
-
featureData.listReport =
|
|
51
|
+
featureData.listReport = getListReportFeatures(listReportPage, log, projectMetadata, manifest);
|
|
62
52
|
}
|
|
63
53
|
if (objectPages) {
|
|
64
54
|
log?.warn('Extracting Object Page features from application model');
|
|
65
|
-
featureData.objectPages = await
|
|
55
|
+
featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata);
|
|
66
56
|
log?.warn('objectPages features extracted: ' + JSON.stringify(featureData.objectPages));
|
|
67
57
|
}
|
|
68
58
|
if (fpmPage) {
|
|
@@ -81,10 +71,10 @@ async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
81
71
|
* @param log - optional logger instance
|
|
82
72
|
* @returns - a map of table columns
|
|
83
73
|
*/
|
|
84
|
-
function getTableColumnData(pageModel, log) {
|
|
74
|
+
export function getTableColumnData(pageModel, log) {
|
|
85
75
|
let tableColumns = {};
|
|
86
76
|
try {
|
|
87
|
-
tableColumns =
|
|
77
|
+
tableColumns = extractTableColumnsFromNode(pageModel.root);
|
|
88
78
|
}
|
|
89
79
|
catch (error) {
|
|
90
80
|
log?.debug(error);
|
|
@@ -101,10 +91,10 @@ function getTableColumnData(pageModel, log) {
|
|
|
101
91
|
* @param applicationModel - The application model containing page definitions.
|
|
102
92
|
* @returns An object containing the key and page definition of the List Report, or null if not found.
|
|
103
93
|
*/
|
|
104
|
-
function getListReportPage(applicationModel) {
|
|
94
|
+
export function getListReportPage(applicationModel) {
|
|
105
95
|
for (const pageKey in applicationModel.pages) {
|
|
106
96
|
const page = applicationModel.pages[pageKey];
|
|
107
|
-
if (page.pageType ===
|
|
97
|
+
if (page.pageType === PageTypeV4.ListReport) {
|
|
108
98
|
page.name = pageKey; // store page key as name for later identification
|
|
109
99
|
return page;
|
|
110
100
|
}
|
|
@@ -118,11 +108,11 @@ function getListReportPage(applicationModel) {
|
|
|
118
108
|
* @param log - optional logger instance
|
|
119
109
|
* @returns An array of FPM Custom Page definitions.
|
|
120
110
|
*/
|
|
121
|
-
function getFPMPage(applicationModel, log) {
|
|
111
|
+
export function getFPMPage(applicationModel, log) {
|
|
122
112
|
for (const pageKey in applicationModel.pages) {
|
|
123
113
|
const page = applicationModel.pages[pageKey];
|
|
124
114
|
log?.warn('pageType:' + page.pageType);
|
|
125
|
-
if (page.pageType ===
|
|
115
|
+
if (page.pageType === PageTypeV4.FPMCustomPage) {
|
|
126
116
|
page.name = pageKey; // store page key as name for later identification
|
|
127
117
|
return page;
|
|
128
118
|
}
|
|
@@ -136,10 +126,10 @@ function getFPMPage(applicationModel, log) {
|
|
|
136
126
|
* @param log - optional logger instance
|
|
137
127
|
* @returns feature data extracted from the FPM Custom Page model
|
|
138
128
|
*/
|
|
139
|
-
function getFPMFeatures(page, log) {
|
|
129
|
+
export function getFPMFeatures(page, log) {
|
|
140
130
|
return {
|
|
141
131
|
name: page.name,
|
|
142
|
-
filterBarItems:
|
|
132
|
+
filterBarItems: getFilterFieldNames(page.model, log),
|
|
143
133
|
tableColumns: getTableColumnData(page.model, log)
|
|
144
134
|
};
|
|
145
135
|
}
|
|
@@ -149,7 +139,7 @@ function getFPMFeatures(page, log) {
|
|
|
149
139
|
* @param node - The tree aggregations node.
|
|
150
140
|
* @returns The aggregations object.
|
|
151
141
|
*/
|
|
152
|
-
function getAggregations(node) {
|
|
142
|
+
export function getAggregations(node) {
|
|
153
143
|
if (node && typeof node === 'object' && 'aggregations' in node) {
|
|
154
144
|
return node.aggregations;
|
|
155
145
|
}
|
|
@@ -161,7 +151,7 @@ function getAggregations(node) {
|
|
|
161
151
|
* @param selectionFieldsAgg - The selection fields aggregation containing field definitions.
|
|
162
152
|
* @returns An array of selection field descriptions.
|
|
163
153
|
*/
|
|
164
|
-
function getSelectionFieldItems(selectionFieldsAgg) {
|
|
154
|
+
export function getSelectionFieldItems(selectionFieldsAgg) {
|
|
165
155
|
if (selectionFieldsAgg && typeof selectionFieldsAgg === 'object') {
|
|
166
156
|
const items = [];
|
|
167
157
|
for (const itemKey in selectionFieldsAgg) {
|
|
@@ -177,7 +167,7 @@ function getSelectionFieldItems(selectionFieldsAgg) {
|
|
|
177
167
|
* @param pageModel - The tree model containing filter bar definitions.
|
|
178
168
|
* @returns An array of filter field descriptions.
|
|
179
169
|
*/
|
|
180
|
-
function getFilterFields(pageModel) {
|
|
170
|
+
export function getFilterFields(pageModel) {
|
|
181
171
|
const filterBar = getAggregations(pageModel.root)['filterBar'];
|
|
182
172
|
const filterBarAggregations = getAggregations(filterBar);
|
|
183
173
|
const selectionFields = filterBarAggregations['selectionFields'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '@sap-ux/logger';
|
|
2
|
-
import type { ApplicationModel } from '@sap/ux-specification/dist/types/src/parser';
|
|
3
|
-
import type { ObjectPageFeatures } from '../types';
|
|
4
|
-
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application';
|
|
2
|
+
import type { ApplicationModel } from '@sap/ux-specification/dist/types/src/parser/index.js';
|
|
3
|
+
import type { ObjectPageFeatures } from '../types.js';
|
|
4
|
+
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application.js';
|
|
5
5
|
/**
|
|
6
6
|
* Extracts feature data for object pages from the application model.
|
|
7
7
|
*
|