@sap-ux/fiori-mcp-server 0.0.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.
- package/LICENSE +201 -0
- package/README.md +99 -0
- package/dist/constant.d.ts +5 -0
- package/dist/constant.js +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/page-editor-api/api.d.ts +48 -0
- package/dist/page-editor-api/api.js +93 -0
- package/dist/page-editor-api/index.d.ts +5 -0
- package/dist/page-editor-api/index.js +24 -0
- package/dist/page-editor-api/json-helper.d.ts +11 -0
- package/dist/page-editor-api/json-helper.js +64 -0
- package/dist/page-editor-api/parser/annotations.d.ts +9 -0
- package/dist/page-editor-api/parser/annotations.js +13 -0
- package/dist/page-editor-api/parser/index.d.ts +3 -0
- package/dist/page-editor-api/parser/index.js +19 -0
- package/dist/page-editor-api/parser/model/AggregationValidator.d.ts +64 -0
- package/dist/page-editor-api/parser/model/AggregationValidator.js +209 -0
- package/dist/page-editor-api/parser/model/ArrayAggregation.d.ts +49 -0
- package/dist/page-editor-api/parser/model/ArrayAggregation.js +122 -0
- package/dist/page-editor-api/parser/model/ObjectAggregation.d.ts +374 -0
- package/dist/page-editor-api/parser/model/ObjectAggregation.js +802 -0
- package/dist/page-editor-api/parser/model/PageEditModel.d.ts +223 -0
- package/dist/page-editor-api/parser/model/PageEditModel.js +954 -0
- package/dist/page-editor-api/parser/model/PageEditProperty.d.ts +38 -0
- package/dist/page-editor-api/parser/model/PageEditProperty.js +49 -0
- package/dist/page-editor-api/parser/model/RootAggregation.d.ts +24 -0
- package/dist/page-editor-api/parser/model/RootAggregation.js +54 -0
- package/dist/page-editor-api/parser/model/actions/ActionAggregation.d.ts +34 -0
- package/dist/page-editor-api/parser/model/actions/ActionAggregation.js +92 -0
- package/dist/page-editor-api/parser/model/actions/ActionsAggregation.d.ts +96 -0
- package/dist/page-editor-api/parser/model/actions/ActionsAggregation.js +252 -0
- package/dist/page-editor-api/parser/model/actions/index.d.ts +3 -0
- package/dist/page-editor-api/parser/model/actions/index.js +19 -0
- package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectAggregation.d.ts +17 -0
- package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectAggregation.js +26 -0
- package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectsAggregation.d.ts +46 -0
- package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectsAggregation.js +66 -0
- package/dist/page-editor-api/parser/model/additionalObjects/index.d.ts +3 -0
- package/dist/page-editor-api/parser/model/additionalObjects/index.js +19 -0
- package/dist/page-editor-api/parser/model/chart/ChartAggregation.d.ts +41 -0
- package/dist/page-editor-api/parser/model/chart/ChartAggregation.js +94 -0
- package/dist/page-editor-api/parser/model/chart/index.d.ts +2 -0
- package/dist/page-editor-api/parser/model/chart/index.js +18 -0
- package/dist/page-editor-api/parser/model/fields/ConnectedFieldsAggregation.d.ts +9 -0
- package/dist/page-editor-api/parser/model/fields/ConnectedFieldsAggregation.js +13 -0
- package/dist/page-editor-api/parser/model/fields/FieldAggregation.d.ts +25 -0
- package/dist/page-editor-api/parser/model/fields/FieldAggregation.js +42 -0
- package/dist/page-editor-api/parser/model/fields/FieldsAggregation.d.ts +22 -0
- package/dist/page-editor-api/parser/model/fields/FieldsAggregation.js +34 -0
- package/dist/page-editor-api/parser/model/fields/index.d.ts +4 -0
- package/dist/page-editor-api/parser/model/fields/index.js +20 -0
- package/dist/page-editor-api/parser/model/filter-fields/FilterFieldAggregation.d.ts +39 -0
- package/dist/page-editor-api/parser/model/filter-fields/FilterFieldAggregation.js +94 -0
- package/dist/page-editor-api/parser/model/filter-fields/FilterFieldsAggregation.d.ts +36 -0
- package/dist/page-editor-api/parser/model/filter-fields/FilterFieldsAggregation.js +59 -0
- package/dist/page-editor-api/parser/model/filter-fields/index.d.ts +3 -0
- package/dist/page-editor-api/parser/model/filter-fields/index.js +19 -0
- package/dist/page-editor-api/parser/model/index.d.ts +19 -0
- package/dist/page-editor-api/parser/model/index.js +35 -0
- package/dist/page-editor-api/parser/model/macros/MacrosRoot.d.ts +48 -0
- package/dist/page-editor-api/parser/model/macros/MacrosRoot.js +114 -0
- package/dist/page-editor-api/parser/model/macros/index.d.ts +2 -0
- package/dist/page-editor-api/parser/model/macros/index.js +18 -0
- package/dist/page-editor-api/parser/model/sections/HeaderSectionsAggregation.d.ts +31 -0
- package/dist/page-editor-api/parser/model/sections/HeaderSectionsAggregation.js +82 -0
- package/dist/page-editor-api/parser/model/sections/SectionAggregation.d.ts +78 -0
- package/dist/page-editor-api/parser/model/sections/SectionAggregation.js +131 -0
- package/dist/page-editor-api/parser/model/sections/SectionsAggregation.d.ts +135 -0
- package/dist/page-editor-api/parser/model/sections/SectionsAggregation.js +402 -0
- package/dist/page-editor-api/parser/model/sections/SectionsObjectAggregation.d.ts +50 -0
- package/dist/page-editor-api/parser/model/sections/SectionsObjectAggregation.js +119 -0
- package/dist/page-editor-api/parser/model/sections/SubSectionsAggregation.d.ts +39 -0
- package/dist/page-editor-api/parser/model/sections/SubSectionsAggregation.js +70 -0
- package/dist/page-editor-api/parser/model/sections/index.d.ts +6 -0
- package/dist/page-editor-api/parser/model/sections/index.js +22 -0
- package/dist/page-editor-api/parser/model/table/ColumnAggregation.d.ts +89 -0
- package/dist/page-editor-api/parser/model/table/ColumnAggregation.js +175 -0
- package/dist/page-editor-api/parser/model/table/ColumnsAggregation.d.ts +113 -0
- package/dist/page-editor-api/parser/model/table/ColumnsAggregation.js +293 -0
- package/dist/page-editor-api/parser/model/table/TableAggregation.d.ts +13 -0
- package/dist/page-editor-api/parser/model/table/TableAggregation.js +21 -0
- package/dist/page-editor-api/parser/model/table/ToolbarAggregation.d.ts +15 -0
- package/dist/page-editor-api/parser/model/table/ToolbarAggregation.js +22 -0
- package/dist/page-editor-api/parser/model/table/index.d.ts +5 -0
- package/dist/page-editor-api/parser/model/table/index.js +21 -0
- package/dist/page-editor-api/parser/model/table/utils.d.ts +12 -0
- package/dist/page-editor-api/parser/model/table/utils.js +44 -0
- package/dist/page-editor-api/parser/model/types/annotations.d.ts +63 -0
- package/dist/page-editor-api/parser/model/types/annotations.js +29 -0
- package/dist/page-editor-api/parser/model/types/common.d.ts +13 -0
- package/dist/page-editor-api/parser/model/types/common.js +3 -0
- package/dist/page-editor-api/parser/model/types/index.d.ts +220 -0
- package/dist/page-editor-api/parser/model/types/index.js +149 -0
- package/dist/page-editor-api/parser/model/utils/annotations.d.ts +38 -0
- package/dist/page-editor-api/parser/model/utils/annotations.js +120 -0
- package/dist/page-editor-api/parser/model/utils/i18n.d.ts +33 -0
- package/dist/page-editor-api/parser/model/utils/i18n.js +69 -0
- package/dist/page-editor-api/parser/model/utils/index.d.ts +6 -0
- package/dist/page-editor-api/parser/model/utils/index.js +22 -0
- package/dist/page-editor-api/parser/model/utils/object.d.ts +25 -0
- package/dist/page-editor-api/parser/model/utils/object.js +68 -0
- package/dist/page-editor-api/parser/model/utils/sort.d.ts +31 -0
- package/dist/page-editor-api/parser/model/utils/sort.js +18 -0
- package/dist/page-editor-api/parser/model/utils/utils.d.ts +94 -0
- package/dist/page-editor-api/parser/model/utils/utils.js +267 -0
- package/dist/page-editor-api/parser/model/views/ViewAggregation.d.ts +62 -0
- package/dist/page-editor-api/parser/model/views/ViewAggregation.js +112 -0
- package/dist/page-editor-api/parser/model/views/ViewsAggregation.d.ts +54 -0
- package/dist/page-editor-api/parser/model/views/ViewsAggregation.js +141 -0
- package/dist/page-editor-api/parser/model/views/index.d.ts +3 -0
- package/dist/page-editor-api/parser/model/views/index.js +19 -0
- package/dist/page-editor-api/parser/model/visual-filters/VisualFilterAggregation.d.ts +11 -0
- package/dist/page-editor-api/parser/model/visual-filters/VisualFilterAggregation.js +15 -0
- package/dist/page-editor-api/parser/model/visual-filters/VisualFiltersAggregation.d.ts +11 -0
- package/dist/page-editor-api/parser/model/visual-filters/VisualFiltersAggregation.js +15 -0
- package/dist/page-editor-api/parser/model/visual-filters/index.d.ts +3 -0
- package/dist/page-editor-api/parser/model/visual-filters/index.js +19 -0
- package/dist/page-editor-api/parser/tree.d.ts +135 -0
- package/dist/page-editor-api/parser/tree.js +464 -0
- package/dist/page-editor-api/project.d.ts +40 -0
- package/dist/page-editor-api/project.js +124 -0
- package/dist/page-editor-api/sapuxFtfsFileIO.d.ts +84 -0
- package/dist/page-editor-api/sapuxFtfsFileIO.js +195 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.js +120 -0
- package/dist/tools/execute-functionality.d.ts +19 -0
- package/dist/tools/execute-functionality.js +175 -0
- package/dist/tools/functionalities/controller-extension/index.d.ts +4 -0
- package/dist/tools/functionalities/controller-extension/index.js +136 -0
- package/dist/tools/functionalities/functionalities.d.ts +4 -0
- package/dist/tools/functionalities/functionalities.js +19 -0
- package/dist/tools/functionalities/generate-fiori-ui-app/command.d.ts +9 -0
- package/dist/tools/functionalities/generate-fiori-ui-app/command.js +158 -0
- package/dist/tools/functionalities/generate-fiori-ui-app/generate-fiori-ui-app.d.ts +4 -0
- package/dist/tools/functionalities/generate-fiori-ui-app/generate-fiori-ui-app.js +240 -0
- package/dist/tools/functionalities/generate-fiori-ui-app/index.d.ts +2 -0
- package/dist/tools/functionalities/generate-fiori-ui-app/index.js +7 -0
- package/dist/tools/functionalities/index.d.ts +2 -0
- package/dist/tools/functionalities/index.js +18 -0
- package/dist/tools/functionalities/page/add-page.d.ts +5 -0
- package/dist/tools/functionalities/page/add-page.js +89 -0
- package/dist/tools/functionalities/page/application.d.ts +212 -0
- package/dist/tools/functionalities/page/application.js +616 -0
- package/dist/tools/functionalities/page/delete-page.d.ts +4 -0
- package/dist/tools/functionalities/page/delete-page.js +71 -0
- package/dist/tools/functionalities/page/index.d.ts +3 -0
- package/dist/tools/functionalities/page/index.js +10 -0
- package/dist/tools/functionalities/page/service.d.ts +82 -0
- package/dist/tools/functionalities/page/service.js +114 -0
- package/dist/tools/functionalities/page/serviceStore.d.ts +17 -0
- package/dist/tools/functionalities/page/serviceStore.js +34 -0
- package/dist/tools/functionalities/page/types.d.ts +42 -0
- package/dist/tools/functionalities/page/types.js +11 -0
- package/dist/tools/functionalities/page/utils.d.ts +12 -0
- package/dist/tools/functionalities/page/utils.js +63 -0
- package/dist/tools/get-functionality-details.d.ts +24 -0
- package/dist/tools/get-functionality-details.js +142 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/input-schema/execute-functionality.json +28 -0
- package/dist/tools/input-schema/get-functionality-details.json +24 -0
- package/dist/tools/input-schema/index.d.ts +5 -0
- package/dist/tools/input-schema/index.js +15 -0
- package/dist/tools/input-schema/list-fiori-apps.json +12 -0
- package/dist/tools/input-schema/list-functionality.json +10 -0
- package/dist/tools/list-fiori-apps.d.ts +10 -0
- package/dist/tools/list-fiori-apps.js +33 -0
- package/dist/tools/list-functionalities.d.ts +10 -0
- package/dist/tools/list-functionalities.js +145 -0
- package/dist/tools/output-schema/execute-functionality.json +39 -0
- package/dist/tools/output-schema/get-functionality-details.json +142 -0
- package/dist/tools/output-schema/index.d.ts +5 -0
- package/dist/tools/output-schema/index.js +15 -0
- package/dist/tools/output-schema/list-fiori-apps.json +41 -0
- package/dist/tools/output-schema/list-functionality.json +37 -0
- package/dist/tools/utils.d.ts +16 -0
- package/dist/tools/utils.js +74 -0
- package/dist/types.d.ts +170 -0
- package/dist/types.js +3 -0
- package/package.json +63 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ObjectAggregation, AggregationVariant } from './ObjectAggregation';
|
|
2
|
+
import type { PageData, PropertyPath } from './types';
|
|
3
|
+
import { ValidationState } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Represents validator for aggregations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AggregationValidator {
|
|
8
|
+
/**
|
|
9
|
+
* Method validates states of properties and aggregation. Following states are supported:
|
|
10
|
+
* 1. Valid.
|
|
11
|
+
* 2. Invalid - when value is set for property/aggregation, but it is not valid.
|
|
12
|
+
* 3. Skipped - when property/aggregation is not relevant in current value context and value does not set.
|
|
13
|
+
*
|
|
14
|
+
* @param aggregation ObjectAggregation which state should be validated.
|
|
15
|
+
* @param data Page data.
|
|
16
|
+
*/
|
|
17
|
+
validate(aggregation: ObjectAggregation, data: PageData): void;
|
|
18
|
+
/**
|
|
19
|
+
* Method receives possible variants of variants received from schema and validates against current values.
|
|
20
|
+
*
|
|
21
|
+
* @param variants Array of variants.
|
|
22
|
+
* @param aggregation Aggregation to validate.
|
|
23
|
+
* @returns State of each property and aggregation.
|
|
24
|
+
*/
|
|
25
|
+
validateVariants(variants: Array<AggregationVariant>, aggregation: ObjectAggregation): {
|
|
26
|
+
[k: string]: ValidationState;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Method receives single variants and validates received property against variant schema.
|
|
30
|
+
*
|
|
31
|
+
* @param variant Variant to use as validation rule.
|
|
32
|
+
* @param aggregation Aggregation to validate.
|
|
33
|
+
* @param property Name of inner property or aggregation, which should be validated.
|
|
34
|
+
* @param ignoreUnexisting Do not return skip state when ignore passed and variant property does not exist.
|
|
35
|
+
* @returns Validation result.
|
|
36
|
+
*/
|
|
37
|
+
validateVariant(variant: AggregationVariant, aggregation: ObjectAggregation, property: string, ignoreUnexisting?: boolean): ValidationState;
|
|
38
|
+
/**
|
|
39
|
+
* Iterates over all aggregations contained in the given variants.
|
|
40
|
+
* Useful for replacing nested loops when traversing variant aggregations.
|
|
41
|
+
*
|
|
42
|
+
* @param variants List of variant aggregations to traverse.
|
|
43
|
+
* @yields A tuple containing:
|
|
44
|
+
* - `name`: The aggregation key within the variant.
|
|
45
|
+
* - `aggregation`: The aggregation within the variant.
|
|
46
|
+
*/
|
|
47
|
+
private iterateVariantAggregations;
|
|
48
|
+
/**
|
|
49
|
+
* Method goes through passed variants and checks for unify aggregations.
|
|
50
|
+
* If there is any aggregation for unification, then method updates unify aggregation with latest valid context paths.
|
|
51
|
+
*
|
|
52
|
+
* @param aggregation Aggregation to validate.
|
|
53
|
+
* @param variants Valid aggeregation to use as context for properties and aggregations paths.
|
|
54
|
+
*/
|
|
55
|
+
private unifyVariants;
|
|
56
|
+
/**
|
|
57
|
+
* Recursive method updates paths of all aggregations and properties using passed context path.
|
|
58
|
+
*
|
|
59
|
+
* @param aggregation Target aggregation.
|
|
60
|
+
* @param contextPath Context path.
|
|
61
|
+
*/
|
|
62
|
+
applyContextPath(aggregation: ObjectAggregation, contextPath: PropertyPath): void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=AggregationValidator.d.ts.map
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AggregationValidator = void 0;
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
/**
|
|
11
|
+
* Represents validator for aggregations.
|
|
12
|
+
*/
|
|
13
|
+
class AggregationValidator {
|
|
14
|
+
/**
|
|
15
|
+
* Method validates states of properties and aggregation. Following states are supported:
|
|
16
|
+
* 1. Valid.
|
|
17
|
+
* 2. Invalid - when value is set for property/aggregation, but it is not valid.
|
|
18
|
+
* 3. Skipped - when property/aggregation is not relevant in current value context and value does not set.
|
|
19
|
+
*
|
|
20
|
+
* @param aggregation ObjectAggregation which state should be validated.
|
|
21
|
+
* @param data Page data.
|
|
22
|
+
*/
|
|
23
|
+
validate(aggregation, data) {
|
|
24
|
+
if (aggregation.state === types_1.ValidationState.Valid && aggregation.variants.length >= 1) {
|
|
25
|
+
const properties = this.validateVariants(aggregation.variants, aggregation);
|
|
26
|
+
for (const property in properties) {
|
|
27
|
+
const entry = aggregation.properties[property] || aggregation.aggregations[property];
|
|
28
|
+
if (entry) {
|
|
29
|
+
entry.state = properties[property];
|
|
30
|
+
if (entry.state === types_1.ValidationState.Invalid) {
|
|
31
|
+
// Property is defined in source, but it is not allowed
|
|
32
|
+
(0, utils_1.addValidationMessages)(entry, [
|
|
33
|
+
{
|
|
34
|
+
text: i18next_1.default.t('PAGE_EDITOR_PROPERTIES_PROPERTY_WARNING_PROPERTY_NOT_ALLOWED', {
|
|
35
|
+
name: property
|
|
36
|
+
}),
|
|
37
|
+
deletable: true
|
|
38
|
+
}
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Go through standard aggregation with recursion
|
|
45
|
+
for (const name in aggregation.aggregations) {
|
|
46
|
+
this.validate(aggregation.aggregations[name], data ? data[name] : {});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Method receives possible variants of variants received from schema and validates against current values.
|
|
51
|
+
*
|
|
52
|
+
* @param variants Array of variants.
|
|
53
|
+
* @param aggregation Aggregation to validate.
|
|
54
|
+
* @returns State of each property and aggregation.
|
|
55
|
+
*/
|
|
56
|
+
validateVariants(variants, aggregation) {
|
|
57
|
+
const valueProperties = {};
|
|
58
|
+
// Get properties with actual values
|
|
59
|
+
for (const property in aggregation.properties) {
|
|
60
|
+
if (aggregation.properties[property].value !== undefined) {
|
|
61
|
+
valueProperties[property] = aggregation.properties[property].value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const property in aggregation.aggregations) {
|
|
65
|
+
if (aggregation.aggregations[property].value !== undefined) {
|
|
66
|
+
valueProperties[property] = aggregation.aggregations[property].value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Get valid variants
|
|
70
|
+
let validVariants = [...variants];
|
|
71
|
+
for (const property in valueProperties) {
|
|
72
|
+
validVariants = validVariants.filter((variant) => {
|
|
73
|
+
const result = this.validateVariant(variant, aggregation, property);
|
|
74
|
+
return result === types_1.ValidationState.Valid;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (validVariants.length === 0) {
|
|
78
|
+
validVariants = [...variants];
|
|
79
|
+
for (const property in valueProperties) {
|
|
80
|
+
validVariants = validVariants.filter((variant) => {
|
|
81
|
+
const result = this.validateVariant(variant, aggregation, property, true);
|
|
82
|
+
return result === types_1.ValidationState.Valid;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Unify aggregation and variants if 'unionName' is used in aggregation
|
|
87
|
+
this.unifyVariants(aggregation, validVariants);
|
|
88
|
+
// Populate property states
|
|
89
|
+
const propertyStates = {};
|
|
90
|
+
const properties = [...Object.keys(aggregation.properties), ...Object.keys(aggregation.aggregations)];
|
|
91
|
+
for (const property of properties) {
|
|
92
|
+
const valid = validVariants.some((variant) => {
|
|
93
|
+
return property in variant.properties || property in variant.aggregations;
|
|
94
|
+
});
|
|
95
|
+
if (valid) {
|
|
96
|
+
propertyStates[property] = types_1.ValidationState.Valid;
|
|
97
|
+
}
|
|
98
|
+
else if (property in valueProperties) {
|
|
99
|
+
propertyStates[property] = types_1.ValidationState.Invalid;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
propertyStates[property] = types_1.ValidationState.Skipped;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return propertyStates;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Method receives single variants and validates received property against variant schema.
|
|
109
|
+
*
|
|
110
|
+
* @param variant Variant to use as validation rule.
|
|
111
|
+
* @param aggregation Aggregation to validate.
|
|
112
|
+
* @param property Name of inner property or aggregation, which should be validated.
|
|
113
|
+
* @param ignoreUnexisting Do not return skip state when ignore passed and variant property does not exist.
|
|
114
|
+
* @returns Validation result.
|
|
115
|
+
*/
|
|
116
|
+
validateVariant(variant, aggregation, property, ignoreUnexisting = false) {
|
|
117
|
+
const variantProperty = variant.aggregations[property] || variant.properties[property];
|
|
118
|
+
if (variantProperty === undefined) {
|
|
119
|
+
return ignoreUnexisting ? types_1.ValidationState.Valid : types_1.ValidationState.Skipped;
|
|
120
|
+
}
|
|
121
|
+
// Check enum value
|
|
122
|
+
const entity = aggregation.properties[property] || aggregation.aggregations[property] || {};
|
|
123
|
+
const value = entity.value;
|
|
124
|
+
if (variantProperty.schema) {
|
|
125
|
+
if (variantProperty.schema.pattern &&
|
|
126
|
+
!new RegExp(variantProperty.schema.pattern).exec(value.toString())) {
|
|
127
|
+
return types_1.ValidationState.Skipped;
|
|
128
|
+
}
|
|
129
|
+
if (variantProperty.schema.enum &&
|
|
130
|
+
!variantProperty.schema.enum.includes(value) &&
|
|
131
|
+
!variantProperty.freeText) {
|
|
132
|
+
return types_1.ValidationState.Skipped;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return types_1.ValidationState.Valid;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Iterates over all aggregations contained in the given variants.
|
|
139
|
+
* Useful for replacing nested loops when traversing variant aggregations.
|
|
140
|
+
*
|
|
141
|
+
* @param variants List of variant aggregations to traverse.
|
|
142
|
+
* @yields A tuple containing:
|
|
143
|
+
* - `name`: The aggregation key within the variant.
|
|
144
|
+
* - `aggregation`: The aggregation within the variant.
|
|
145
|
+
*/
|
|
146
|
+
*iterateVariantAggregations(variants) {
|
|
147
|
+
for (const variant of variants) {
|
|
148
|
+
for (const [name, aggregation] of Object.entries(variant.aggregations)) {
|
|
149
|
+
yield [name, aggregation];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Method goes through passed variants and checks for unify aggregations.
|
|
155
|
+
* If there is any aggregation for unification, then method updates unify aggregation with latest valid context paths.
|
|
156
|
+
*
|
|
157
|
+
* @param aggregation Aggregation to validate.
|
|
158
|
+
* @param variants Valid aggeregation to use as context for properties and aggregations paths.
|
|
159
|
+
*/
|
|
160
|
+
unifyVariants(aggregation, variants) {
|
|
161
|
+
const handledProperties = {};
|
|
162
|
+
for (const [name, variantAggregation] of this.iterateVariantAggregations(variants)) {
|
|
163
|
+
if (variantAggregation.union && !handledProperties[name]) {
|
|
164
|
+
this.applyContextPath(aggregation.aggregations[name], variantAggregation.path);
|
|
165
|
+
// Name correction to show context
|
|
166
|
+
aggregation.aggregations[name].name =
|
|
167
|
+
variantAggregation.path[variantAggregation.path.length - 1].toString();
|
|
168
|
+
// Mark handled property
|
|
169
|
+
handledProperties[name] = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!Object.keys(handledProperties).length) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// update variant arrays
|
|
176
|
+
for (const name in handledProperties) {
|
|
177
|
+
aggregation.aggregations[name].variants = [];
|
|
178
|
+
}
|
|
179
|
+
for (const variant of variants) {
|
|
180
|
+
for (const name in handledProperties) {
|
|
181
|
+
const variantAggregation = variant.aggregations[name];
|
|
182
|
+
if (!variantAggregation) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
aggregation.aggregations[name].variants = [
|
|
186
|
+
...aggregation.aggregations[name].variants,
|
|
187
|
+
...(variantAggregation.variants.length ? variantAggregation.variants : [variantAggregation])
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Recursive method updates paths of all aggregations and properties using passed context path.
|
|
194
|
+
*
|
|
195
|
+
* @param aggregation Target aggregation.
|
|
196
|
+
* @param contextPath Context path.
|
|
197
|
+
*/
|
|
198
|
+
applyContextPath(aggregation, contextPath) {
|
|
199
|
+
aggregation.path = aggregation.path.slice();
|
|
200
|
+
for (let i = 0; i < contextPath.length; i++) {
|
|
201
|
+
aggregation.path[i] = contextPath[i];
|
|
202
|
+
}
|
|
203
|
+
for (const name in aggregation.aggregations) {
|
|
204
|
+
this.applyContextPath(aggregation.aggregations[name], contextPath);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.AggregationValidator = AggregationValidator;
|
|
209
|
+
//# sourceMappingURL=AggregationValidator.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PageData, PropertyPath } from './types';
|
|
2
|
+
import { AggregationType } from './types';
|
|
3
|
+
import type { JSONSchema4 } from 'json-schema';
|
|
4
|
+
import type { PageEditAggregationData } from './ObjectAggregation';
|
|
5
|
+
import { ObjectAggregation } from './ObjectAggregation';
|
|
6
|
+
import type { PageConfig, PageType } from '@sap/ux-specification/dist/types/src';
|
|
7
|
+
/**
|
|
8
|
+
* Represents an aggregation for array object.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ArrayAggregation extends ObjectAggregation {
|
|
11
|
+
readonly type = AggregationType.Array;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of `ArrayAggregation`.
|
|
14
|
+
*
|
|
15
|
+
* @param data Optional aggregation data object used to initialize properties.
|
|
16
|
+
* @param schema Optional JSON schema fragment associated with this aggregation.
|
|
17
|
+
*/
|
|
18
|
+
constructor(data?: PageEditAggregationData, schema?: JSONSchema4);
|
|
19
|
+
/**
|
|
20
|
+
* Method adds aggregation object.
|
|
21
|
+
* Overwritten to modify array's children.
|
|
22
|
+
*
|
|
23
|
+
* @param name Name of aggregation.
|
|
24
|
+
* @param aggregation Aggregation to add.
|
|
25
|
+
* @param path Array of path to aggregation.
|
|
26
|
+
* @param order Order index.
|
|
27
|
+
* @returns Added aggregation.
|
|
28
|
+
*/
|
|
29
|
+
addAggregation(name: string, aggregation: ObjectAggregation, path: PropertyPath, order?: number): ObjectAggregation;
|
|
30
|
+
/**
|
|
31
|
+
* Public method which recursively updates aggregation's properties with values from passed data object.
|
|
32
|
+
* Overwritten to update children aggregations depending on data.
|
|
33
|
+
*
|
|
34
|
+
* @param data Data which should be used for value population.
|
|
35
|
+
* @param page Page config data.
|
|
36
|
+
* @param pageType Page type.
|
|
37
|
+
* @param path Aggregation path.
|
|
38
|
+
*/
|
|
39
|
+
updatePropertiesValues(data: PageData | undefined, page: PageConfig, pageType: PageType, path: PropertyPath): void;
|
|
40
|
+
/**
|
|
41
|
+
* Private method resolves primary property of aggregation.
|
|
42
|
+
* Logic is that we look for certain properties like 'id', 'key', etc. If those properties do not exist, then we take first string property.
|
|
43
|
+
*
|
|
44
|
+
* @param aggregation Aggregation to add.
|
|
45
|
+
* @returns Property name.
|
|
46
|
+
*/
|
|
47
|
+
private getPrimaryKey;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ArrayAggregation.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ArrayAggregation = void 0;
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
9
|
+
const ObjectAggregation_1 = require("./ObjectAggregation");
|
|
10
|
+
/**
|
|
11
|
+
* Represents an aggregation for array object.
|
|
12
|
+
*/
|
|
13
|
+
class ArrayAggregation extends ObjectAggregation_1.ObjectAggregation {
|
|
14
|
+
type = types_1.AggregationType.Array;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of `ArrayAggregation`.
|
|
17
|
+
*
|
|
18
|
+
* @param data Optional aggregation data object used to initialize properties.
|
|
19
|
+
* @param schema Optional JSON schema fragment associated with this aggregation.
|
|
20
|
+
*/
|
|
21
|
+
constructor(data, schema) {
|
|
22
|
+
super(data, schema);
|
|
23
|
+
this.schemaCreationForms = [
|
|
24
|
+
{
|
|
25
|
+
name: types_1.AggregationCreationForm.Generic,
|
|
26
|
+
kind: types_1.SCHEMA_CREATION_FORM,
|
|
27
|
+
title: 'PAGE_EDITOR_OUTLINE_ADD_GENERIC_TITLE',
|
|
28
|
+
disabled: false
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Method adds aggregation object.
|
|
34
|
+
* Overwritten to modify array's children.
|
|
35
|
+
*
|
|
36
|
+
* @param name Name of aggregation.
|
|
37
|
+
* @param aggregation Aggregation to add.
|
|
38
|
+
* @param path Array of path to aggregation.
|
|
39
|
+
* @param order Order index.
|
|
40
|
+
* @returns Added aggregation.
|
|
41
|
+
*/
|
|
42
|
+
addAggregation(name, aggregation, path, order) {
|
|
43
|
+
super.addAggregation(name, aggregation, path, order);
|
|
44
|
+
// Array items are sortable and deletable
|
|
45
|
+
this.sortableList = true;
|
|
46
|
+
aggregation.sortableItem = types_1.SortingOptions.Enabled;
|
|
47
|
+
aggregation.actions = [types_1.AggregationActions.Delete];
|
|
48
|
+
// Set main title
|
|
49
|
+
if (aggregation.schema && !aggregation.schema.title) {
|
|
50
|
+
// Apply custom title as node label for array element
|
|
51
|
+
aggregation.schema.title = i18next_1.default.t('PAGE_EDITOR_OUTLINE_ARRAY_ITEM', {
|
|
52
|
+
name: parseInt(name, 10) + 1
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
aggregation.custom = true;
|
|
56
|
+
return aggregation;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Public method which recursively updates aggregation's properties with values from passed data object.
|
|
60
|
+
* Overwritten to update children aggregations depending on data.
|
|
61
|
+
*
|
|
62
|
+
* @param data Data which should be used for value population.
|
|
63
|
+
* @param page Page config data.
|
|
64
|
+
* @param pageType Page type.
|
|
65
|
+
* @param path Aggregation path.
|
|
66
|
+
*/
|
|
67
|
+
updatePropertiesValues(data, page, pageType, path) {
|
|
68
|
+
// Base update
|
|
69
|
+
super.updatePropertiesValues(data, page, pageType, path);
|
|
70
|
+
if (!Array.isArray(data)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Update 'additionalText' property for child aggregations
|
|
74
|
+
for (let i = 0; i < data.length; i++) {
|
|
75
|
+
const aggregation = this.aggregations[i];
|
|
76
|
+
if (!aggregation) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
let additionalText;
|
|
80
|
+
if (this.isAtomic) {
|
|
81
|
+
additionalText = data[i];
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const primaryKey = this.getPrimaryKey(aggregation);
|
|
85
|
+
additionalText = primaryKey ? data[i][primaryKey] : undefined;
|
|
86
|
+
}
|
|
87
|
+
if (typeof additionalText !== 'object') {
|
|
88
|
+
aggregation.additionalText = additionalText;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Private method resolves primary property of aggregation.
|
|
94
|
+
* Logic is that we look for certain properties like 'id', 'key', etc. If those properties do not exist, then we take first string property.
|
|
95
|
+
*
|
|
96
|
+
* @param aggregation Aggregation to add.
|
|
97
|
+
* @returns Property name.
|
|
98
|
+
*/
|
|
99
|
+
getPrimaryKey(aggregation) {
|
|
100
|
+
// Get additional text for item array
|
|
101
|
+
// Start with predefined most common properties
|
|
102
|
+
const primaryProperties = ['id', 'title', 'key', 'name'];
|
|
103
|
+
const schemaProperties = aggregation.schema ? aggregation.schema.properties || {} : {};
|
|
104
|
+
let primaryProperty;
|
|
105
|
+
for (const property of primaryProperties) {
|
|
106
|
+
if (property in schemaProperties) {
|
|
107
|
+
primaryProperty = property;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// No match, then use very first string property
|
|
112
|
+
for (const property in schemaProperties) {
|
|
113
|
+
if (schemaProperties[property].type === 'string') {
|
|
114
|
+
primaryProperty = property;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return primaryProperty;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.ArrayAggregation = ArrayAggregation;
|
|
122
|
+
//# sourceMappingURL=ArrayAggregation.js.map
|