@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.
Files changed (181) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +99 -0
  3. package/dist/constant.d.ts +5 -0
  4. package/dist/constant.js +8 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.js +7 -0
  7. package/dist/page-editor-api/api.d.ts +48 -0
  8. package/dist/page-editor-api/api.js +93 -0
  9. package/dist/page-editor-api/index.d.ts +5 -0
  10. package/dist/page-editor-api/index.js +24 -0
  11. package/dist/page-editor-api/json-helper.d.ts +11 -0
  12. package/dist/page-editor-api/json-helper.js +64 -0
  13. package/dist/page-editor-api/parser/annotations.d.ts +9 -0
  14. package/dist/page-editor-api/parser/annotations.js +13 -0
  15. package/dist/page-editor-api/parser/index.d.ts +3 -0
  16. package/dist/page-editor-api/parser/index.js +19 -0
  17. package/dist/page-editor-api/parser/model/AggregationValidator.d.ts +64 -0
  18. package/dist/page-editor-api/parser/model/AggregationValidator.js +209 -0
  19. package/dist/page-editor-api/parser/model/ArrayAggregation.d.ts +49 -0
  20. package/dist/page-editor-api/parser/model/ArrayAggregation.js +122 -0
  21. package/dist/page-editor-api/parser/model/ObjectAggregation.d.ts +374 -0
  22. package/dist/page-editor-api/parser/model/ObjectAggregation.js +802 -0
  23. package/dist/page-editor-api/parser/model/PageEditModel.d.ts +223 -0
  24. package/dist/page-editor-api/parser/model/PageEditModel.js +954 -0
  25. package/dist/page-editor-api/parser/model/PageEditProperty.d.ts +38 -0
  26. package/dist/page-editor-api/parser/model/PageEditProperty.js +49 -0
  27. package/dist/page-editor-api/parser/model/RootAggregation.d.ts +24 -0
  28. package/dist/page-editor-api/parser/model/RootAggregation.js +54 -0
  29. package/dist/page-editor-api/parser/model/actions/ActionAggregation.d.ts +34 -0
  30. package/dist/page-editor-api/parser/model/actions/ActionAggregation.js +92 -0
  31. package/dist/page-editor-api/parser/model/actions/ActionsAggregation.d.ts +96 -0
  32. package/dist/page-editor-api/parser/model/actions/ActionsAggregation.js +252 -0
  33. package/dist/page-editor-api/parser/model/actions/index.d.ts +3 -0
  34. package/dist/page-editor-api/parser/model/actions/index.js +19 -0
  35. package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectAggregation.d.ts +17 -0
  36. package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectAggregation.js +26 -0
  37. package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectsAggregation.d.ts +46 -0
  38. package/dist/page-editor-api/parser/model/additionalObjects/AdditionalObjectsAggregation.js +66 -0
  39. package/dist/page-editor-api/parser/model/additionalObjects/index.d.ts +3 -0
  40. package/dist/page-editor-api/parser/model/additionalObjects/index.js +19 -0
  41. package/dist/page-editor-api/parser/model/chart/ChartAggregation.d.ts +41 -0
  42. package/dist/page-editor-api/parser/model/chart/ChartAggregation.js +94 -0
  43. package/dist/page-editor-api/parser/model/chart/index.d.ts +2 -0
  44. package/dist/page-editor-api/parser/model/chart/index.js +18 -0
  45. package/dist/page-editor-api/parser/model/fields/ConnectedFieldsAggregation.d.ts +9 -0
  46. package/dist/page-editor-api/parser/model/fields/ConnectedFieldsAggregation.js +13 -0
  47. package/dist/page-editor-api/parser/model/fields/FieldAggregation.d.ts +25 -0
  48. package/dist/page-editor-api/parser/model/fields/FieldAggregation.js +42 -0
  49. package/dist/page-editor-api/parser/model/fields/FieldsAggregation.d.ts +22 -0
  50. package/dist/page-editor-api/parser/model/fields/FieldsAggregation.js +34 -0
  51. package/dist/page-editor-api/parser/model/fields/index.d.ts +4 -0
  52. package/dist/page-editor-api/parser/model/fields/index.js +20 -0
  53. package/dist/page-editor-api/parser/model/filter-fields/FilterFieldAggregation.d.ts +39 -0
  54. package/dist/page-editor-api/parser/model/filter-fields/FilterFieldAggregation.js +94 -0
  55. package/dist/page-editor-api/parser/model/filter-fields/FilterFieldsAggregation.d.ts +36 -0
  56. package/dist/page-editor-api/parser/model/filter-fields/FilterFieldsAggregation.js +59 -0
  57. package/dist/page-editor-api/parser/model/filter-fields/index.d.ts +3 -0
  58. package/dist/page-editor-api/parser/model/filter-fields/index.js +19 -0
  59. package/dist/page-editor-api/parser/model/index.d.ts +19 -0
  60. package/dist/page-editor-api/parser/model/index.js +35 -0
  61. package/dist/page-editor-api/parser/model/macros/MacrosRoot.d.ts +48 -0
  62. package/dist/page-editor-api/parser/model/macros/MacrosRoot.js +114 -0
  63. package/dist/page-editor-api/parser/model/macros/index.d.ts +2 -0
  64. package/dist/page-editor-api/parser/model/macros/index.js +18 -0
  65. package/dist/page-editor-api/parser/model/sections/HeaderSectionsAggregation.d.ts +31 -0
  66. package/dist/page-editor-api/parser/model/sections/HeaderSectionsAggregation.js +82 -0
  67. package/dist/page-editor-api/parser/model/sections/SectionAggregation.d.ts +78 -0
  68. package/dist/page-editor-api/parser/model/sections/SectionAggregation.js +131 -0
  69. package/dist/page-editor-api/parser/model/sections/SectionsAggregation.d.ts +135 -0
  70. package/dist/page-editor-api/parser/model/sections/SectionsAggregation.js +402 -0
  71. package/dist/page-editor-api/parser/model/sections/SectionsObjectAggregation.d.ts +50 -0
  72. package/dist/page-editor-api/parser/model/sections/SectionsObjectAggregation.js +119 -0
  73. package/dist/page-editor-api/parser/model/sections/SubSectionsAggregation.d.ts +39 -0
  74. package/dist/page-editor-api/parser/model/sections/SubSectionsAggregation.js +70 -0
  75. package/dist/page-editor-api/parser/model/sections/index.d.ts +6 -0
  76. package/dist/page-editor-api/parser/model/sections/index.js +22 -0
  77. package/dist/page-editor-api/parser/model/table/ColumnAggregation.d.ts +89 -0
  78. package/dist/page-editor-api/parser/model/table/ColumnAggregation.js +175 -0
  79. package/dist/page-editor-api/parser/model/table/ColumnsAggregation.d.ts +113 -0
  80. package/dist/page-editor-api/parser/model/table/ColumnsAggregation.js +293 -0
  81. package/dist/page-editor-api/parser/model/table/TableAggregation.d.ts +13 -0
  82. package/dist/page-editor-api/parser/model/table/TableAggregation.js +21 -0
  83. package/dist/page-editor-api/parser/model/table/ToolbarAggregation.d.ts +15 -0
  84. package/dist/page-editor-api/parser/model/table/ToolbarAggregation.js +22 -0
  85. package/dist/page-editor-api/parser/model/table/index.d.ts +5 -0
  86. package/dist/page-editor-api/parser/model/table/index.js +21 -0
  87. package/dist/page-editor-api/parser/model/table/utils.d.ts +12 -0
  88. package/dist/page-editor-api/parser/model/table/utils.js +44 -0
  89. package/dist/page-editor-api/parser/model/types/annotations.d.ts +63 -0
  90. package/dist/page-editor-api/parser/model/types/annotations.js +29 -0
  91. package/dist/page-editor-api/parser/model/types/common.d.ts +13 -0
  92. package/dist/page-editor-api/parser/model/types/common.js +3 -0
  93. package/dist/page-editor-api/parser/model/types/index.d.ts +220 -0
  94. package/dist/page-editor-api/parser/model/types/index.js +149 -0
  95. package/dist/page-editor-api/parser/model/utils/annotations.d.ts +38 -0
  96. package/dist/page-editor-api/parser/model/utils/annotations.js +120 -0
  97. package/dist/page-editor-api/parser/model/utils/i18n.d.ts +33 -0
  98. package/dist/page-editor-api/parser/model/utils/i18n.js +69 -0
  99. package/dist/page-editor-api/parser/model/utils/index.d.ts +6 -0
  100. package/dist/page-editor-api/parser/model/utils/index.js +22 -0
  101. package/dist/page-editor-api/parser/model/utils/object.d.ts +25 -0
  102. package/dist/page-editor-api/parser/model/utils/object.js +68 -0
  103. package/dist/page-editor-api/parser/model/utils/sort.d.ts +31 -0
  104. package/dist/page-editor-api/parser/model/utils/sort.js +18 -0
  105. package/dist/page-editor-api/parser/model/utils/utils.d.ts +94 -0
  106. package/dist/page-editor-api/parser/model/utils/utils.js +267 -0
  107. package/dist/page-editor-api/parser/model/views/ViewAggregation.d.ts +62 -0
  108. package/dist/page-editor-api/parser/model/views/ViewAggregation.js +112 -0
  109. package/dist/page-editor-api/parser/model/views/ViewsAggregation.d.ts +54 -0
  110. package/dist/page-editor-api/parser/model/views/ViewsAggregation.js +141 -0
  111. package/dist/page-editor-api/parser/model/views/index.d.ts +3 -0
  112. package/dist/page-editor-api/parser/model/views/index.js +19 -0
  113. package/dist/page-editor-api/parser/model/visual-filters/VisualFilterAggregation.d.ts +11 -0
  114. package/dist/page-editor-api/parser/model/visual-filters/VisualFilterAggregation.js +15 -0
  115. package/dist/page-editor-api/parser/model/visual-filters/VisualFiltersAggregation.d.ts +11 -0
  116. package/dist/page-editor-api/parser/model/visual-filters/VisualFiltersAggregation.js +15 -0
  117. package/dist/page-editor-api/parser/model/visual-filters/index.d.ts +3 -0
  118. package/dist/page-editor-api/parser/model/visual-filters/index.js +19 -0
  119. package/dist/page-editor-api/parser/tree.d.ts +135 -0
  120. package/dist/page-editor-api/parser/tree.js +464 -0
  121. package/dist/page-editor-api/project.d.ts +40 -0
  122. package/dist/page-editor-api/project.js +124 -0
  123. package/dist/page-editor-api/sapuxFtfsFileIO.d.ts +84 -0
  124. package/dist/page-editor-api/sapuxFtfsFileIO.js +195 -0
  125. package/dist/server.d.ts +35 -0
  126. package/dist/server.js +120 -0
  127. package/dist/tools/execute-functionality.d.ts +19 -0
  128. package/dist/tools/execute-functionality.js +175 -0
  129. package/dist/tools/functionalities/controller-extension/index.d.ts +4 -0
  130. package/dist/tools/functionalities/controller-extension/index.js +136 -0
  131. package/dist/tools/functionalities/functionalities.d.ts +4 -0
  132. package/dist/tools/functionalities/functionalities.js +19 -0
  133. package/dist/tools/functionalities/generate-fiori-ui-app/command.d.ts +9 -0
  134. package/dist/tools/functionalities/generate-fiori-ui-app/command.js +158 -0
  135. package/dist/tools/functionalities/generate-fiori-ui-app/generate-fiori-ui-app.d.ts +4 -0
  136. package/dist/tools/functionalities/generate-fiori-ui-app/generate-fiori-ui-app.js +240 -0
  137. package/dist/tools/functionalities/generate-fiori-ui-app/index.d.ts +2 -0
  138. package/dist/tools/functionalities/generate-fiori-ui-app/index.js +7 -0
  139. package/dist/tools/functionalities/index.d.ts +2 -0
  140. package/dist/tools/functionalities/index.js +18 -0
  141. package/dist/tools/functionalities/page/add-page.d.ts +5 -0
  142. package/dist/tools/functionalities/page/add-page.js +89 -0
  143. package/dist/tools/functionalities/page/application.d.ts +212 -0
  144. package/dist/tools/functionalities/page/application.js +616 -0
  145. package/dist/tools/functionalities/page/delete-page.d.ts +4 -0
  146. package/dist/tools/functionalities/page/delete-page.js +71 -0
  147. package/dist/tools/functionalities/page/index.d.ts +3 -0
  148. package/dist/tools/functionalities/page/index.js +10 -0
  149. package/dist/tools/functionalities/page/service.d.ts +82 -0
  150. package/dist/tools/functionalities/page/service.js +114 -0
  151. package/dist/tools/functionalities/page/serviceStore.d.ts +17 -0
  152. package/dist/tools/functionalities/page/serviceStore.js +34 -0
  153. package/dist/tools/functionalities/page/types.d.ts +42 -0
  154. package/dist/tools/functionalities/page/types.js +11 -0
  155. package/dist/tools/functionalities/page/utils.d.ts +12 -0
  156. package/dist/tools/functionalities/page/utils.js +63 -0
  157. package/dist/tools/get-functionality-details.d.ts +24 -0
  158. package/dist/tools/get-functionality-details.js +142 -0
  159. package/dist/tools/index.d.ts +7 -0
  160. package/dist/tools/index.js +55 -0
  161. package/dist/tools/input-schema/execute-functionality.json +28 -0
  162. package/dist/tools/input-schema/get-functionality-details.json +24 -0
  163. package/dist/tools/input-schema/index.d.ts +5 -0
  164. package/dist/tools/input-schema/index.js +15 -0
  165. package/dist/tools/input-schema/list-fiori-apps.json +12 -0
  166. package/dist/tools/input-schema/list-functionality.json +10 -0
  167. package/dist/tools/list-fiori-apps.d.ts +10 -0
  168. package/dist/tools/list-fiori-apps.js +33 -0
  169. package/dist/tools/list-functionalities.d.ts +10 -0
  170. package/dist/tools/list-functionalities.js +145 -0
  171. package/dist/tools/output-schema/execute-functionality.json +39 -0
  172. package/dist/tools/output-schema/get-functionality-details.json +142 -0
  173. package/dist/tools/output-schema/index.d.ts +5 -0
  174. package/dist/tools/output-schema/index.js +15 -0
  175. package/dist/tools/output-schema/list-fiori-apps.json +41 -0
  176. package/dist/tools/output-schema/list-functionality.json +37 -0
  177. package/dist/tools/utils.d.ts +16 -0
  178. package/dist/tools/utils.js +74 -0
  179. package/dist/types.d.ts +170 -0
  180. package/dist/types.js +3 -0
  181. package/package.json +63 -0
@@ -0,0 +1,38 @@
1
+ import type { JSONSchema4 } from 'json-schema';
2
+ import type { Location, SettingOption, PropertyMessage } from './types';
3
+ import { ValidationState } from './types';
4
+ import type { ArtifactType } from '@sap/ux-specification/dist/types/src';
5
+ export interface PageProperties {
6
+ [key: string]: PageEditProperty;
7
+ }
8
+ /**
9
+ * Represents a configurable aggregation property in the page editing model.
10
+ * `PageEditProperty` wraps schema-based metadata for a property and stores
11
+ * runtime values, validation state, messages, and UI-related options.
12
+ */
13
+ export declare class PageEditProperty implements SettingOption {
14
+ schema: JSONSchema4;
15
+ value?: unknown;
16
+ pattern?: string;
17
+ freeText?: boolean;
18
+ disabled?: boolean;
19
+ state?: ValidationState;
20
+ description?: string;
21
+ required?: boolean;
22
+ isAtomic?: boolean;
23
+ i18nClassification?: string;
24
+ name: string;
25
+ displayName?: string;
26
+ artifactType?: ArtifactType;
27
+ minimum?: number;
28
+ messages?: PropertyMessage[];
29
+ locations?: Location[];
30
+ /**
31
+ * Creates an instance of `PageEditProperty`.
32
+ *
33
+ * @param schema JSON Schema fragment associated with this property.
34
+ * @param displayName Display name of the property.
35
+ */
36
+ constructor(schema: JSONSchema4, displayName: string);
37
+ }
38
+ //# sourceMappingURL=PageEditProperty.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageEditProperty = void 0;
4
+ const types_1 = require("./types");
5
+ /**
6
+ * Represents a configurable aggregation property in the page editing model.
7
+ * `PageEditProperty` wraps schema-based metadata for a property and stores
8
+ * runtime values, validation state, messages, and UI-related options.
9
+ */
10
+ class PageEditProperty {
11
+ schema;
12
+ value;
13
+ pattern;
14
+ // True if user can enter text freely. Is used to display as combobox:
15
+ // 1. Selection options from enum;
16
+ // 2. Free text to enter using input field;
17
+ freeText;
18
+ disabled;
19
+ state = types_1.ValidationState.Valid;
20
+ // Property description
21
+ description;
22
+ // Is property required for input
23
+ required;
24
+ isAtomic;
25
+ i18nClassification;
26
+ name;
27
+ displayName;
28
+ // Property's artifact type
29
+ artifactType;
30
+ // Property's minimum allowed value
31
+ minimum;
32
+ // Property messages
33
+ messages;
34
+ // Location in source file
35
+ locations;
36
+ /**
37
+ * Creates an instance of `PageEditProperty`.
38
+ *
39
+ * @param schema JSON Schema fragment associated with this property.
40
+ * @param displayName Display name of the property.
41
+ */
42
+ constructor(schema, displayName) {
43
+ // Use copy - it allows to make changes in schema if we need.
44
+ this.schema = structuredClone(schema);
45
+ this.name = displayName;
46
+ }
47
+ }
48
+ exports.PageEditProperty = PageEditProperty;
49
+ //# sourceMappingURL=PageEditProperty.js.map
@@ -0,0 +1,24 @@
1
+ import { ObjectAggregation } from './ObjectAggregation';
2
+ import { AggregationCreationForm } from './types';
3
+ import type { CreationFormOptions, PageAnnotations } from './types';
4
+ /**
5
+ * Represents an aggregation for root level object in page/application schema.
6
+ */
7
+ export declare class RootAggregation extends ObjectAggregation {
8
+ allowedAnnotationCreationForms: AggregationCreationForm[];
9
+ name: string;
10
+ /**
11
+ * Method provides creation options based on its related annotation node.
12
+ * Overwritten, return array which was calculated on annotation data refresh.
13
+ *
14
+ * @returns Array of creation forms.
15
+ */
16
+ getDefaultNativeCreationForms(): CreationFormOptions[];
17
+ /**
18
+ * Refreshes internal data based on latest annotation node data.
19
+ *
20
+ * @param annotations
21
+ */
22
+ updateAnnotationData(annotations: PageAnnotations | undefined): void;
23
+ }
24
+ //# sourceMappingURL=RootAggregation.d.ts.map
@@ -0,0 +1,54 @@
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.RootAggregation = void 0;
7
+ const ObjectAggregation_1 = require("./ObjectAggregation");
8
+ const types_1 = require("./types");
9
+ const i18next_1 = __importDefault(require("i18next"));
10
+ /**
11
+ * Represents an aggregation for root level object in page/application schema.
12
+ */
13
+ class RootAggregation extends ObjectAggregation_1.ObjectAggregation {
14
+ allowedAnnotationCreationForms = [types_1.AggregationCreationForm.AnalyticalChart];
15
+ name = 'root';
16
+ /**
17
+ * Method provides creation options based on its related annotation node.
18
+ * Overwritten, return array which was calculated on annotation data refresh.
19
+ *
20
+ * @returns Array of creation forms.
21
+ */
22
+ getDefaultNativeCreationForms() {
23
+ return this.annotationCreationForms;
24
+ }
25
+ /**
26
+ * Refreshes internal data based on latest annotation node data.
27
+ *
28
+ * @param annotations
29
+ */
30
+ updateAnnotationData(annotations) {
31
+ this.annotationCreationForms = [];
32
+ super.updateAnnotationData(annotations);
33
+ // Check annotation creations forms
34
+ const isChartAdded = !!this.aggregations['chart']?.isViewNode;
35
+ const isViewsEnabled = !!(this.aggregations['table']?.aggregations['views']?.isViewNode && !isChartAdded);
36
+ if (isViewsEnabled && annotations?.dialogsContext?.analyticalChartSupport !== undefined) {
37
+ const form = {
38
+ name: types_1.AggregationCreationForm.AnalyticalChart,
39
+ title: annotations.dialogsContext.analyticalChartSupport.creationTooltip,
40
+ disabled: !annotations.dialogsContext.analyticalChartSupport.creationEnabled,
41
+ kind: types_1.ANNOTATION_CREATION_FORM,
42
+ visualizationIcon: 'Add',
43
+ buttonText: i18next_1.default.t('ADD_CHART'),
44
+ buttonId: 'add-chart'
45
+ };
46
+ if (form.disabled) {
47
+ form.disabledTitle = form.title;
48
+ }
49
+ this.annotationCreationForms.push(form);
50
+ }
51
+ }
52
+ }
53
+ exports.RootAggregation = RootAggregation;
54
+ //# sourceMappingURL=RootAggregation.js.map
@@ -0,0 +1,34 @@
1
+ import { ObjectAggregation } from '../ObjectAggregation';
2
+ import { AggregationActions, SortingOptions } from '../types';
3
+ import type { DefaultExtensionPosition } from '../utils/sort';
4
+ /**
5
+ * Represents an aggregation for action object.
6
+ */
7
+ export declare class ActionAggregation extends ObjectAggregation {
8
+ actions: AggregationActions[];
9
+ sortableItem: SortingOptions | undefined;
10
+ isViewNode: boolean;
11
+ sortableCollection: string | undefined;
12
+ data?: DefaultExtensionPosition;
13
+ /**
14
+ * Method parses object path key and returns action name.
15
+ *
16
+ * @returns Action name.
17
+ */
18
+ getTechnicalName(): string | undefined;
19
+ /**
20
+ * Public method to mark action as custom action.
21
+ */
22
+ markAsCustomAction(): void;
23
+ /**
24
+ * Public method to mark action as standard action.
25
+ */
26
+ markAsStandardAction(): void;
27
+ /**
28
+ * Method returns action type from schema data.
29
+ *
30
+ * @returns Action type from schema.
31
+ */
32
+ getActionType(): string | undefined;
33
+ }
34
+ //# sourceMappingURL=ActionAggregation.d.ts.map
@@ -0,0 +1,92 @@
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.ActionAggregation = void 0;
7
+ const i18next_1 = __importDefault(require("i18next"));
8
+ const ObjectAggregation_1 = require("../ObjectAggregation");
9
+ const types_1 = require("../types");
10
+ const utils_1 = require("../utils");
11
+ /**
12
+ * Represents an aggregation for action object.
13
+ */
14
+ class ActionAggregation extends ObjectAggregation_1.ObjectAggregation {
15
+ actions = [types_1.AggregationActions.Delete];
16
+ sortableItem = types_1.SortingOptions.Enabled;
17
+ isViewNode = true;
18
+ sortableCollection = 'actions';
19
+ data;
20
+ /**
21
+ * Method parses object path key and returns action name.
22
+ *
23
+ * @returns Action name.
24
+ */
25
+ getTechnicalName() {
26
+ const key = this.path[this.path.length - 1];
27
+ if (key && typeof key === 'string') {
28
+ const keyParts = key.split('::');
29
+ // Primary method - check for specific key format using 'DATA_FIELD_ACTION'
30
+ let action = '';
31
+ if (keyParts[keyParts.length - 1].includes('.')) {
32
+ for (let i = 0; i < keyParts.length; i++) {
33
+ if (keyParts[i] === types_1.DATA_FIELD_ACTION && keyParts[i + 1]) {
34
+ action = keyParts[i + 1];
35
+ }
36
+ }
37
+ }
38
+ else {
39
+ action = keyParts[keyParts.length - 1];
40
+ }
41
+ if (action) {
42
+ const actionParts = action.split('.');
43
+ return actionParts[actionParts.length - 1];
44
+ }
45
+ }
46
+ return super.getTechnicalName();
47
+ }
48
+ /**
49
+ * Public method to mark action as custom action.
50
+ */
51
+ markAsCustomAction() {
52
+ this.custom = true;
53
+ this.actions = [types_1.AggregationActions.OpenSource];
54
+ this.sortableItem = types_1.SortingOptions.Enabled;
55
+ this.additionalText = i18next_1.default.t('PAGE_EDITOR_OUTLINE_NODE_DESC_CUSTOM_ACTION');
56
+ this.i18nKey = this.parent?.i18nKey;
57
+ if (this.isMacrosNode()) {
58
+ (0, utils_1.validateMacrosExtension)(this);
59
+ }
60
+ else {
61
+ this.actions.push(types_1.AggregationActions.Delete);
62
+ }
63
+ // Validate anchor
64
+ const anchor = this.aggregations.position?.properties.anchor;
65
+ if (anchor?.value) {
66
+ // Validate anchor if value exists
67
+ const validEntries = anchor.schema.oneOf || [];
68
+ if (!validEntries.some((entry) => entry.const === anchor.value)) {
69
+ (0, utils_1.validateExtension)(this, false, i18next_1.default.t('PAGE_EDITOR_CUSTOM_EXTENSION_NO_ANCHOR'));
70
+ }
71
+ }
72
+ }
73
+ /**
74
+ * Public method to mark action as standard action.
75
+ */
76
+ markAsStandardAction() {
77
+ this.sortableItem = types_1.SortingOptions.Readonly;
78
+ this.additionalText = i18next_1.default.t('PAGE_EDITOR_OUTLINE_NODE_DESC_STANDARD_ACTION');
79
+ this.i18nKey = this.parent?.i18nKey;
80
+ this.removeAction(types_1.AggregationActions.Delete);
81
+ }
82
+ /**
83
+ * Method returns action type from schema data.
84
+ *
85
+ * @returns Action type from schema.
86
+ */
87
+ getActionType() {
88
+ return typeof this.schema?.actionType === 'string' ? this.schema.actionType : undefined;
89
+ }
90
+ }
91
+ exports.ActionAggregation = ActionAggregation;
92
+ //# sourceMappingURL=ActionAggregation.js.map
@@ -0,0 +1,96 @@
1
+ import type { JSONSchema4 } from 'json-schema';
2
+ import type { PageConfig, PageType } from '@sap/ux-specification/dist/types/src';
3
+ import { ObjectAggregation } from '../ObjectAggregation';
4
+ import type { PageEditAggregationData } from '../ObjectAggregation';
5
+ import { AggregationCreationForm } from '../types';
6
+ import type { PageData, CreationFormOptions, PropertyPath, PageAnnotations, AllowedMoveRange } from '../types';
7
+ import { ActionAggregation } from './ActionAggregation';
8
+ export declare enum ActionType {
9
+ Annotation = "Annotation",
10
+ Copy = "Copy",
11
+ Criticality = "Criticality",
12
+ Custom = "Custom",
13
+ Standard = "Standard",
14
+ StandardWithoutAnnotation = "StandardWithoutAnnotation"
15
+ }
16
+ export interface ActionsContainers {
17
+ top: AllowedMoveRange;
18
+ bottom: AllowedMoveRange;
19
+ }
20
+ /**
21
+ * Represents an aggregation for actions container object.
22
+ */
23
+ export declare class ActionsAggregation extends ObjectAggregation {
24
+ sortableList: boolean;
25
+ childClass: typeof ActionAggregation;
26
+ allowedAnnotationCreationForms: AggregationCreationForm[];
27
+ sortableCollection: string | undefined;
28
+ i18nKey: string;
29
+ /**
30
+ * Creates an instance of `ActionsAggregation`.
31
+ *
32
+ * @param data Optional aggregation data object used to initialize properties.
33
+ * @param schema Optional JSON schema fragment associated with this aggregation.
34
+ */
35
+ constructor(data?: PageEditAggregationData, schema?: JSONSchema4);
36
+ /**
37
+ * Method adds aggregation object.
38
+ * Overwritten to mark standard action.
39
+ *
40
+ * @param name Name of aggregation.
41
+ * @param aggregation Aggregation to add.
42
+ * @param path Array of path to aggregation.
43
+ * @param order Order index.
44
+ * @param overwrite Overwrite existing aggregation.
45
+ * @returns Added aggregation.
46
+ */
47
+ addAggregation(name: string, aggregation: ObjectAggregation, path: PropertyPath, order?: number, overwrite?: boolean): ObjectAggregation;
48
+ /**
49
+ * Overwritten method for data update of object page actions
50
+ * Method receives current values for actions and detects custom actions.
51
+ *
52
+ * @param data Data which should be used for value population.
53
+ * @param page Page config data.
54
+ * @param pageType Page type.
55
+ * @param path Aggregation path.
56
+ * @param annotations Annotations data.
57
+ */
58
+ updatePropertiesValues(data: PageData, page: PageConfig, pageType: PageType, path: PropertyPath, annotations: PageAnnotations): void;
59
+ /**
60
+ * Method provides creation options based on its related annotation node.
61
+ *
62
+ * @param annotations Page annotations.
63
+ * @returns Array of creation forms.
64
+ */
65
+ protected getNativeNodeCreationForms(annotations: PageAnnotations | undefined): CreationFormOptions[];
66
+ /**
67
+ * Method returns action type of passed action aggregation.
68
+ *
69
+ * @param action Action aggregation.
70
+ * @returns Action type of passed action aggregation.
71
+ */
72
+ private getActionType;
73
+ /**
74
+ * Method calculates edge position for two containers - above and below standard actions.
75
+ *
76
+ * @param aggregationKeys Array of actions aggregation keys.
77
+ * @param sourceType Movable source type.
78
+ * @returns Drop range edges.
79
+ */
80
+ private calculateDropRangeEdges;
81
+ /**
82
+ * Method returns allowed drop ranges within action for passed action type.
83
+ *
84
+ * @param sourceType Action type.
85
+ * @returns Allowed drop ranges of top and bottom containers.
86
+ */
87
+ private getActionsContainers;
88
+ /**
89
+ * Method returns allowed drop ranges for passed source aggregation.
90
+ *
91
+ * @param source Source aggregation.
92
+ * @returns Allowed drop ranges for passed source aggregation.
93
+ */
94
+ getAllowedDropRange(source: ObjectAggregation): AllowedMoveRange[] | undefined;
95
+ }
96
+ //# sourceMappingURL=ActionsAggregation.d.ts.map
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionsAggregation = exports.ActionType = void 0;
4
+ const ObjectAggregation_1 = require("../ObjectAggregation");
5
+ const types_1 = require("../types");
6
+ const ActionAggregation_1 = require("./ActionAggregation");
7
+ // Remove when latest '@sap/ux-specification/dist/types/src' is released
8
+ var ActionType;
9
+ (function (ActionType) {
10
+ ActionType["Annotation"] = "Annotation";
11
+ ActionType["Copy"] = "Copy";
12
+ ActionType["Criticality"] = "Criticality";
13
+ ActionType["Custom"] = "Custom";
14
+ ActionType["Standard"] = "Standard";
15
+ ActionType["StandardWithoutAnnotation"] = "StandardWithoutAnnotation";
16
+ })(ActionType || (exports.ActionType = ActionType = {}));
17
+ /**
18
+ * Represents an aggregation for actions container object.
19
+ */
20
+ class ActionsAggregation extends ObjectAggregation_1.ObjectAggregation {
21
+ sortableList = true;
22
+ childClass = ActionAggregation_1.ActionAggregation;
23
+ allowedAnnotationCreationForms = [types_1.AggregationCreationForm.NativeAction, types_1.AggregationCreationForm.NativeNavigation];
24
+ sortableCollection = 'actions';
25
+ i18nKey = 'ACTIONS';
26
+ /**
27
+ * Creates an instance of `ActionsAggregation`.
28
+ *
29
+ * @param data Optional aggregation data object used to initialize properties.
30
+ * @param schema Optional JSON schema fragment associated with this aggregation.
31
+ */
32
+ constructor(data, schema) {
33
+ super(data, schema);
34
+ // Custom creation form - check schema if supported
35
+ if (schema?.properties && this.schema?.additionalProperties && this.schema?.metadata?.type !== 'Aggregation') {
36
+ this.schemaCreationForms = [
37
+ {
38
+ name: types_1.AggregationCreationForm.CustomAction,
39
+ kind: types_1.SCHEMA_CREATION_FORM,
40
+ title: 'PAGE_EDITOR_OUTLINE_ADD_CUSTOM_ACTIONS_TITLE',
41
+ disabled: false
42
+ }
43
+ ];
44
+ }
45
+ }
46
+ /**
47
+ * Method adds aggregation object.
48
+ * Overwritten to mark standard action.
49
+ *
50
+ * @param name Name of aggregation.
51
+ * @param aggregation Aggregation to add.
52
+ * @param path Array of path to aggregation.
53
+ * @param order Order index.
54
+ * @param overwrite Overwrite existing aggregation.
55
+ * @returns Added aggregation.
56
+ */
57
+ addAggregation(name, aggregation, path, order, overwrite) {
58
+ aggregation = super.addAggregation(name, aggregation, path, order, overwrite);
59
+ if (aggregation instanceof ActionAggregation_1.ActionAggregation && aggregation.name) {
60
+ switch (aggregation.schema?.actionType) {
61
+ case ActionType.Standard: {
62
+ aggregation.markAsStandardAction();
63
+ break;
64
+ }
65
+ case ActionType.Copy: {
66
+ aggregation.sortableItem = types_1.SortingOptions.Readonly;
67
+ break;
68
+ }
69
+ }
70
+ }
71
+ return aggregation;
72
+ }
73
+ /**
74
+ * Overwritten method for data update of object page actions
75
+ * Method receives current values for actions and detects custom actions.
76
+ *
77
+ * @param data Data which should be used for value population.
78
+ * @param page Page config data.
79
+ * @param pageType Page type.
80
+ * @param path Aggregation path.
81
+ * @param annotations Annotations data.
82
+ */
83
+ updatePropertiesValues(data, page, pageType, path, annotations) {
84
+ super.updatePropertiesValues(data, page, pageType, path, annotations);
85
+ this.formSchema = this.additionalProperties?.aggregations['actions'];
86
+ const actions = data || {};
87
+ for (const id in actions) {
88
+ const action = this.aggregations[id];
89
+ if (action?.name && action.schema?.actionType === 'Standard') {
90
+ action.markAsStandardAction();
91
+ }
92
+ else if (action?.schema && (action.schema.actionType === 'Custom' || !action.schema.annotationPath)) {
93
+ action.markAsCustomAction();
94
+ }
95
+ }
96
+ }
97
+ /**
98
+ * Method provides creation options based on its related annotation node.
99
+ *
100
+ * @param annotations Page annotations.
101
+ * @returns Array of creation forms.
102
+ */
103
+ getNativeNodeCreationForms(annotations) {
104
+ if (this.parent) {
105
+ if (this.parent.name === 'footer') {
106
+ this.allowedAnnotationCreationForms = [types_1.AggregationCreationForm.NativeAction];
107
+ }
108
+ }
109
+ return super.getNativeNodeCreationForms(annotations);
110
+ }
111
+ /**
112
+ * Method returns action type of passed action aggregation.
113
+ *
114
+ * @param action Action aggregation.
115
+ * @returns Action type of passed action aggregation.
116
+ */
117
+ getActionType(action) {
118
+ const actionType = action.schema?.actionType;
119
+ if (actionType) {
120
+ if (actionType === ActionType.Standard && !action.schema?.annotationPath) {
121
+ return ActionType.StandardWithoutAnnotation;
122
+ }
123
+ return actionType;
124
+ }
125
+ return action.custom ? ActionType.Custom : ActionType.Annotation;
126
+ }
127
+ /**
128
+ * Method calculates edge position for two containers - above and below standard actions.
129
+ *
130
+ * @param aggregationKeys Array of actions aggregation keys.
131
+ * @param sourceType Movable source type.
132
+ * @returns Drop range edges.
133
+ */
134
+ calculateDropRangeEdges(aggregationKeys, sourceType) {
135
+ const edges = {
136
+ top: -1,
137
+ bottom: -1
138
+ };
139
+ const breakConditions = {
140
+ top: [ActionType.Standard, ActionType.Copy, ActionType.Annotation],
141
+ bottom: [ActionType.Criticality, ActionType.Standard, ActionType.Copy]
142
+ };
143
+ // Get top container range. Resolve end index by finding first index of Standard, Copy, Annotation
144
+ for (let i = 0; i < aggregationKeys.length; i++) {
145
+ const key = aggregationKeys[i];
146
+ const aggregation = this.aggregations[key];
147
+ const actionType = this.getActionType(aggregation);
148
+ if (actionType && breakConditions.top.includes(actionType)) {
149
+ edges.top = i;
150
+ break;
151
+ }
152
+ }
153
+ // Get bottom container range. Resolve start index by finding last index of Criticality, Standard, Copy
154
+ if (sourceType !== ActionType.Custom) {
155
+ for (let i = 0; i < aggregationKeys.length; i++) {
156
+ const key = aggregationKeys[i];
157
+ const aggregation = this.aggregations[key];
158
+ const actionType = this.getActionType(aggregation);
159
+ if (actionType && breakConditions.bottom.includes(actionType)) {
160
+ edges.bottom = i + 1;
161
+ }
162
+ }
163
+ }
164
+ else {
165
+ edges.bottom = edges.top;
166
+ }
167
+ return edges;
168
+ }
169
+ /**
170
+ * Method returns allowed drop ranges within action for passed action type.
171
+ *
172
+ * @param sourceType Action type.
173
+ * @returns Allowed drop ranges of top and bottom containers.
174
+ */
175
+ getActionsContainers(sourceType) {
176
+ const aggregationKeys = this.getAggregationKeys(true);
177
+ // Disallowed drops at the end
178
+ let restrictedCount = 0;
179
+ for (let i = aggregationKeys.length - 1; i >= 0; i--) {
180
+ const key = aggregationKeys[i];
181
+ const aggregation = this.aggregations[key];
182
+ const actionType = this.getActionType(aggregation);
183
+ if (actionType !== ActionType.StandardWithoutAnnotation) {
184
+ break;
185
+ }
186
+ restrictedCount++;
187
+ }
188
+ if (sourceType === ActionType.Custom && restrictedCount === 0) {
189
+ // No limitation for custom actions if there is no Related Apps button(it is not supported to drop after Related Apps button)
190
+ return undefined;
191
+ }
192
+ const edges = this.calculateDropRangeEdges(aggregationKeys, sourceType);
193
+ if (edges.top === -1) {
194
+ edges.top = edges.bottom;
195
+ }
196
+ if (edges.bottom === -1) {
197
+ edges.bottom = edges.top;
198
+ }
199
+ if (edges.top === -1 || edges.bottom === -1) {
200
+ return undefined;
201
+ }
202
+ return {
203
+ top: {
204
+ from: 0,
205
+ to: edges.top
206
+ },
207
+ bottom: {
208
+ from: edges.bottom,
209
+ to: aggregationKeys.length - restrictedCount
210
+ }
211
+ };
212
+ }
213
+ /**
214
+ * Method returns allowed drop ranges for passed source aggregation.
215
+ *
216
+ * @param source Source aggregation.
217
+ * @returns Allowed drop ranges for passed source aggregation.
218
+ */
219
+ getAllowedDropRange(source) {
220
+ const sourceActionType = this.getActionType(source);
221
+ const dropContainers = this.getActionsContainers(sourceActionType);
222
+ let range;
223
+ if (dropContainers) {
224
+ switch (sourceActionType) {
225
+ case ActionType.Custom: {
226
+ // Custom actions can be moved across both groups
227
+ range = [dropContainers.top, dropContainers.bottom];
228
+ break;
229
+ }
230
+ case ActionType.Copy:
231
+ case ActionType.Standard:
232
+ case ActionType.StandardWithoutAnnotation: {
233
+ // Copy can not be moved
234
+ range = [];
235
+ break;
236
+ }
237
+ case ActionType.Criticality: {
238
+ range = [dropContainers.top];
239
+ break;
240
+ }
241
+ case ActionType.Annotation: {
242
+ // Custom actions can be moved across both groups
243
+ range = [dropContainers.bottom];
244
+ break;
245
+ }
246
+ }
247
+ }
248
+ return range;
249
+ }
250
+ }
251
+ exports.ActionsAggregation = ActionsAggregation;
252
+ //# sourceMappingURL=ActionsAggregation.js.map
@@ -0,0 +1,3 @@
1
+ export * from './ActionAggregation';
2
+ export * from './ActionsAggregation';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,19 @@
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("./ActionAggregation"), exports);
18
+ __exportStar(require("./ActionsAggregation"), exports);
19
+ //# sourceMappingURL=index.js.map