@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,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createControllerExtensionHandlers = exports.CREATE_CONTROLLER_EXTENSION_FUNCTIONALITY = void 0;
4
+ const src_1 = require("@sap/ux-specification/dist/types/src");
5
+ const page_editor_api_1 = require("../../../page-editor-api");
6
+ const utils_1 = require("../../utils");
7
+ const path_1 = require("path");
8
+ /**
9
+ * Retrieves the parameter definitions for creating a controller extension.
10
+ *
11
+ * @returns An object containing parameter definitions for pageType, pageId, and controllerName.
12
+ */
13
+ function getParameters() {
14
+ return {
15
+ pageType: {
16
+ id: 'pageType',
17
+ type: 'string',
18
+ description: 'Type of page',
19
+ options: ['ListReport', 'ObjectPage'],
20
+ defaultValue: 'ListReport',
21
+ required: true
22
+ },
23
+ pageId: {
24
+ id: 'pageId',
25
+ type: 'string',
26
+ description: 'If controller extenison should be assigned for specific page, then pageId should be provided'
27
+ },
28
+ controllerName: {
29
+ id: 'controllerName',
30
+ type: 'string',
31
+ description: 'Name of new controller extension file',
32
+ required: true
33
+ }
34
+ };
35
+ }
36
+ exports.CREATE_CONTROLLER_EXTENSION_FUNCTIONALITY = {
37
+ functionalityId: 'create-controller-extension',
38
+ name: 'Add new controller extension by creating javascript or typescript file and updates manifest.json with entry',
39
+ description: 'Add new controller extension by creating javascript or typescript file and updates manifest.json with entry. Controller extensions allow users to extensiate default behaviour with custom controllers code.',
40
+ parameters: Object.values(getParameters())
41
+ };
42
+ /**
43
+ * Retrieves the details of the create controller extension functionality.
44
+ *
45
+ * @param input - The input parameters for getting functionality details.
46
+ * @returns A promise that resolves to the functionality details output.
47
+ */
48
+ async function getFunctionalityDetails(input) {
49
+ const defaultParameters = getParameters();
50
+ // Populate options for pageId
51
+ const project = await (0, utils_1.resolveApplication)(input.appPath);
52
+ let pageIds = [];
53
+ if (project?.applicationAccess) {
54
+ const ftfsFileIo = new page_editor_api_1.SapuxFtfsFileIO(project.applicationAccess);
55
+ const appData = await ftfsFileIo.readApp();
56
+ pageIds = Object.keys(appData.config.pages ?? {});
57
+ }
58
+ const parameters = [defaultParameters.pageType, defaultParameters.controllerName];
59
+ if (pageIds.length) {
60
+ parameters.push({
61
+ ...defaultParameters.pageId,
62
+ options: pageIds
63
+ });
64
+ }
65
+ return {
66
+ ...exports.CREATE_CONTROLLER_EXTENSION_FUNCTIONALITY,
67
+ parameters
68
+ };
69
+ }
70
+ /**
71
+ * Executes the create controller extension functionality.
72
+ *
73
+ * @param input - The input parameters for executing the functionality.
74
+ * @returns A promise that resolves to the execution output.
75
+ */
76
+ async function executeFunctionality(input) {
77
+ const { parameters, appPath } = input;
78
+ const { pageId, controllerName, pageType } = parameters;
79
+ const project = await (0, utils_1.resolveApplication)(appPath);
80
+ let changes = [];
81
+ if (!controllerName || typeof controllerName !== 'string') {
82
+ throw new Error('Missing or invalid parameter "controllerName"');
83
+ }
84
+ if (project?.applicationAccess) {
85
+ const { appId, root } = project;
86
+ const ftfsFileIo = new page_editor_api_1.SapuxFtfsFileIO(project.applicationAccess);
87
+ const exensionPageType = await retrieveControllerExtensionPageType(ftfsFileIo, pageType, pageId);
88
+ if (exensionPageType && typeof exensionPageType === 'string') {
89
+ const extension = {
90
+ pageId: typeof pageId === 'string' ? pageId : undefined,
91
+ pageType: exensionPageType
92
+ };
93
+ changes = await ftfsFileIo.writeFPM({
94
+ customExtension: src_1.CustomExtensionType.ControllerExtension,
95
+ basePath: (0, path_1.join)(root, appId),
96
+ data: {
97
+ extension,
98
+ folder: (0, utils_1.getDefaultExtensionFolder)(src_1.DirName.Controller),
99
+ name: controllerName
100
+ }
101
+ });
102
+ }
103
+ }
104
+ return {
105
+ functionalityId: input.functionalityId,
106
+ status: changes.length ? 'success' : 'skipped',
107
+ message: changes.length ? 'Controller extension is created' : 'Controller extension is not created',
108
+ parameters: parameters,
109
+ appPath: appPath,
110
+ changes,
111
+ timestamp: new Date().toISOString()
112
+ };
113
+ }
114
+ /**
115
+ * Retrieves the controller extension page type for a given page or pageType.
116
+ *
117
+ * @param appReader - File I/O handler used to read the SAP Fiori application data.
118
+ * @param pageType - Optional page type value..
119
+ * @param pageId - Optional page identifier used to look up the page type if `pageType` is not explicitly provided.
120
+ * @returns A promise resolving to the controller extension page type, or `undefined` if it cannot be determined.
121
+ */
122
+ async function retrieveControllerExtensionPageType(appReader, pageType, pageId) {
123
+ if (!pageType && typeof pageId === 'string') {
124
+ // Find pageType for passed page id
125
+ const appData = await appReader.readApp();
126
+ pageType = appData.config.pages?.[pageId]?.pageType;
127
+ }
128
+ if (pageType && typeof pageType === 'string') {
129
+ return pageType;
130
+ }
131
+ }
132
+ exports.createControllerExtensionHandlers = {
133
+ getFunctionalityDetails,
134
+ executeFunctionality
135
+ };
136
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import type { FunctionalityHandlers } from '../../types';
2
+ export declare const FUNCTIONALITIES_DETAILS: import("../../types").GetFunctionalityDetailsOutput[];
3
+ export declare const FUNCTIONALITIES_HANDLERS: Map<string, FunctionalityHandlers>;
4
+ //# sourceMappingURL=functionalities.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FUNCTIONALITIES_HANDLERS = exports.FUNCTIONALITIES_DETAILS = void 0;
4
+ const page_1 = require("./page");
5
+ const controller_extension_1 = require("./controller-extension");
6
+ const generate_fiori_ui_app_1 = require("./generate-fiori-ui-app");
7
+ exports.FUNCTIONALITIES_DETAILS = [
8
+ page_1.ADD_PAGE_FUNCTIONALITY,
9
+ generate_fiori_ui_app_1.GENERATE_FIORI_UI_APP,
10
+ page_1.DELETE_PAGE_FUNCTIONALITY,
11
+ controller_extension_1.CREATE_CONTROLLER_EXTENSION_FUNCTIONALITY
12
+ ];
13
+ exports.FUNCTIONALITIES_HANDLERS = new Map([
14
+ [page_1.ADD_PAGE_FUNCTIONALITY.functionalityId, page_1.addPageHandlers],
15
+ [page_1.DELETE_PAGE_FUNCTIONALITY.functionalityId, page_1.deletePageHandlers],
16
+ [generate_fiori_ui_app_1.GENERATE_FIORI_UI_APP.functionalityId, generate_fiori_ui_app_1.generateFioriUIAppHandlers],
17
+ [controller_extension_1.CREATE_CONTROLLER_EXTENSION_FUNCTIONALITY.functionalityId, controller_extension_1.createControllerExtensionHandlers]
18
+ ]);
19
+ //# sourceMappingURL=functionalities.js.map
@@ -0,0 +1,9 @@
1
+ import type { ExecuteFunctionalitiesInput, ExecuteFunctionalityOutput } from '../../../types';
2
+ /**
3
+ * Method to generate fiori app.
4
+ *
5
+ * @param params Input parameters for application generation.
6
+ * @returns Application generation execution output.
7
+ */
8
+ export declare function command(params: ExecuteFunctionalitiesInput): Promise<ExecuteFunctionalityOutput>;
9
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1,158 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.command = command;
37
+ const fs_1 = require("fs");
38
+ const util_1 = require("util");
39
+ const child_process_1 = require("child_process");
40
+ const path_1 = require("path");
41
+ const constant_1 = require("../../../constant");
42
+ const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
43
+ const z = __importStar(require("zod"));
44
+ const GeneratorConfigSchemaCAP = z.object({
45
+ projectPath: z.optional(z.string()),
46
+ appGenConfig: z.object({
47
+ version: z.string(),
48
+ floorplan: z.literal(['FE_FPM', 'FE_LROP', 'FE_OVP', 'FE_ALP', 'FE_FEOP', 'FE_WORKLIST', 'FF_SIMPLE']),
49
+ project: z.object({
50
+ name: z.string(),
51
+ targetFolder: z.string(),
52
+ namespace: z.optional(z.string()),
53
+ title: z.optional(z.string()),
54
+ description: z.string(),
55
+ ui5Theme: z.optional(z.string()),
56
+ ui5Version: z.string(),
57
+ localUI5Version: z.optional(z.string()),
58
+ sapux: z.boolean(),
59
+ skipAnnotations: z.optional(z.boolean()),
60
+ enableCodeAssist: z.optional(z.boolean()),
61
+ enableEslint: z.optional(z.boolean()),
62
+ enableTypeScript: z.optional(z.boolean())
63
+ }),
64
+ service: z.object({
65
+ servicePath: z.string(),
66
+ capService: z.object({
67
+ projectPath: z.string(),
68
+ serviceName: z.string(),
69
+ serviceCdsPath: z.string(),
70
+ capType: z.optional(z.literal(['Node.js', 'Java']))
71
+ })
72
+ }),
73
+ entityConfig: z.object({
74
+ mainEntity: z.object({
75
+ entityName: z.string()
76
+ }),
77
+ generateFormAnnotations: z.boolean(),
78
+ generateLROPAnnotations: z.boolean()
79
+ }),
80
+ telemetryData: z.object({
81
+ generationSourceName: z.string(),
82
+ generationSourceVersion: z.string()
83
+ })
84
+ })
85
+ });
86
+ const exec = (0, util_1.promisify)(child_process_1.exec);
87
+ /**
88
+ * Method to generate fiori app.
89
+ *
90
+ * @param params Input parameters for application generation.
91
+ * @returns Application generation execution output.
92
+ */
93
+ async function command(params) {
94
+ let generatorConfigCAP;
95
+ try {
96
+ generatorConfigCAP = GeneratorConfigSchemaCAP.parse(params.parameters);
97
+ }
98
+ catch (error) {
99
+ if (error instanceof z.ZodError) {
100
+ throw new Error(`Missing required fields in generatorConfig. ${JSON.stringify(error.issues, null, 4)}`);
101
+ }
102
+ }
103
+ const generatorConfig = generatorConfigCAP?.appGenConfig;
104
+ const projectPath = generatorConfig?.project?.targetFolder ?? params.appPath;
105
+ if (!projectPath || typeof projectPath !== 'string') {
106
+ throw new Error('Please provide a valid path to the CAP project folder.');
107
+ }
108
+ const appName = generatorConfig?.project.name ?? 'default';
109
+ const appPath = (0, path_1.join)(projectPath, 'app', appName);
110
+ const targetDir = projectPath;
111
+ const configPath = `${appName}-generator-config.json`;
112
+ const outputPath = (0, path_1.join)(targetDir, configPath);
113
+ const generatorName = '@sap/generator-fiori';
114
+ const generatorVersion = '1.18.5';
115
+ const packages = await (0, nodejs_utils_1.findInstalledPackages)(generatorName, { minVersion: generatorVersion });
116
+ if (packages?.length < 1) {
117
+ throw new Error(`Fiori generator not found. Please install the Fiori generator >=${generatorVersion} with 'npm install -g ${generatorName}' and retry this call`);
118
+ }
119
+ try {
120
+ const content = JSON.stringify(generatorConfig, null, 4);
121
+ await fs_1.promises.mkdir((0, path_1.dirname)(outputPath), { recursive: true });
122
+ await fs_1.promises.writeFile(outputPath, content, { encoding: 'utf8' });
123
+ const command = `npx -y yo@4 @sap/fiori:headless ${configPath} --force --skipInstall`.trim();
124
+ const { stdout, stderr } = await exec(command, { cwd: targetDir });
125
+ console.log(stdout);
126
+ if (stderr) {
127
+ console.error(stderr);
128
+ }
129
+ }
130
+ catch (error) {
131
+ console.error('Error generating application:', error);
132
+ return {
133
+ functionalityId: constant_1.GENERATE_FIORI_UI_APP_ID,
134
+ status: 'Error',
135
+ message: 'Error generating application: ' + error.message,
136
+ parameters: params.parameters,
137
+ appPath,
138
+ changes: [],
139
+ timestamp: new Date().toISOString()
140
+ };
141
+ }
142
+ finally {
143
+ //clean up temp config file used for the headless generator
144
+ if ((0, fs_1.existsSync)(outputPath)) {
145
+ await fs_1.promises.unlink(outputPath);
146
+ }
147
+ }
148
+ return {
149
+ functionalityId: constant_1.GENERATE_FIORI_UI_APP_ID,
150
+ status: 'Success',
151
+ message: 'Generation completed successfully: ' + appPath,
152
+ parameters: params.parameters,
153
+ appPath,
154
+ changes: [],
155
+ timestamp: new Date().toISOString()
156
+ };
157
+ }
158
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1,4 @@
1
+ import type { FunctionalityHandlers, GetFunctionalityDetailsOutput } from '../../../types';
2
+ export declare const GENERATE_FIORI_UI_APP: GetFunctionalityDetailsOutput;
3
+ export declare const generateFioriUIAppHandlers: FunctionalityHandlers;
4
+ //# sourceMappingURL=generate-fiori-ui-app.d.ts.map
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateFioriUIAppHandlers = exports.GENERATE_FIORI_UI_APP = void 0;
4
+ const command_1 = require("./command");
5
+ const constant_1 = require("../../../constant");
6
+ exports.GENERATE_FIORI_UI_APP = {
7
+ functionalityId: constant_1.GENERATE_FIORI_UI_APP_ID,
8
+ name: 'Generate SAP Fiori UI Application',
9
+ description: `Creates (generates) a new SAP Fiori UI application within an existing CAP project.
10
+ Crucially, you must first construct the appGenConfig JSON argument.
11
+ To do this, you **MUST** use the ***CDS MCP*** to search the model for service definitions, entities, associations, and UI annotations.
12
+ As a fallback, only if no such tool is available, you should manually read and parse all .cds files in the projectPath to extract this information.
13
+ The data obtained from either method must then be formatted into a JSON object and passed as the appGenConfig parameter.`,
14
+ parameters: [
15
+ {
16
+ id: 'projectPath',
17
+ type: 'string',
18
+ description: 'The path to the CAP project folder. By default the currently opened project folder should be used.',
19
+ required: true
20
+ },
21
+ {
22
+ id: 'appGenConfig',
23
+ type: 'object',
24
+ description: `The configuration that will be used for the Application UI generation.
25
+ The configuration **MUST** be a valid JSON object corresponding to the inputSchema of the tool.
26
+ The configuration **MUST** be based on the project files in the projectPath.`,
27
+ parameters: [
28
+ {
29
+ id: 'version',
30
+ type: 'string',
31
+ options: ['0.2'],
32
+ description: 'Config schema version.',
33
+ required: true
34
+ },
35
+ {
36
+ id: 'floorplan',
37
+ type: 'string',
38
+ options: ['FE_LROP', 'FE_FEOP', 'FE_FPM'],
39
+ description: 'SAP Fiori Elements floor plan type.',
40
+ required: true
41
+ },
42
+ {
43
+ id: 'projectType',
44
+ type: 'string',
45
+ options: ['LIST_REPORT_OBJECT_PAGE', 'FORM_ENTRY_OBJECT_PAGE', 'FLEXIBLE_PROGRAMMING_MODEL'],
46
+ description: 'Corresponds to the SAP Fiori Elements floor plan.',
47
+ required: true
48
+ },
49
+ {
50
+ id: 'project',
51
+ type: 'object',
52
+ parameters: [
53
+ {
54
+ id: 'name',
55
+ type: 'string',
56
+ description: "Must be lowercase with dashes, e.g., 'sales-order-management'.",
57
+ pattern: '^[a-z0-9-]+$',
58
+ required: true
59
+ },
60
+ {
61
+ id: 'title',
62
+ type: 'string',
63
+ required: false
64
+ },
65
+ {
66
+ id: 'description',
67
+ type: 'string',
68
+ required: true
69
+ },
70
+ {
71
+ id: 'namespace',
72
+ type: 'string',
73
+ required: false
74
+ },
75
+ {
76
+ id: 'ui5Theme',
77
+ type: 'string',
78
+ required: false
79
+ },
80
+ {
81
+ id: 'targetFolder',
82
+ type: 'string',
83
+ description: 'Absolute path to the CAP project folder (projectPath).',
84
+ required: true
85
+ },
86
+ {
87
+ id: 'ui5Version',
88
+ type: 'string',
89
+ options: [constant_1.LATEST_UI5_VERSION],
90
+ required: true
91
+ },
92
+ {
93
+ id: 'localUI5Version',
94
+ type: 'string',
95
+ options: [constant_1.LATEST_UI5_VERSION],
96
+ required: false
97
+ },
98
+ {
99
+ id: 'sapux',
100
+ type: 'boolean',
101
+ defaultValue: true,
102
+ required: true
103
+ }
104
+ ],
105
+ required: true
106
+ },
107
+ {
108
+ id: 'service',
109
+ type: 'object',
110
+ parameters: [
111
+ {
112
+ id: 'servicePath',
113
+ type: 'string',
114
+ examples: [
115
+ 'odata/v4/<servicename>/',
116
+ 'odata/v4/MyRiskService/',
117
+ 'odata/v2/MyOdataV2Service/',
118
+ 'odata/v4/MyOdataV4Service/',
119
+ "odata/v4/<relative '@path' annotation from service cds file>/",
120
+ "<absolute '@path' annotation from service cds file>/",
121
+ 'myAbsolutePathFromServiceCdsFile/'
122
+ ],
123
+ description: 'The odata endpoint as provided by the cds mcp or as fallback in case that tool is not available from the service cds file.',
124
+ required: true
125
+ },
126
+ {
127
+ id: 'capService',
128
+ type: 'object',
129
+ parameters: [
130
+ {
131
+ id: 'projectPath',
132
+ type: 'string',
133
+ required: true
134
+ },
135
+ {
136
+ id: 'serviceName',
137
+ type: 'string',
138
+ required: true
139
+ },
140
+ {
141
+ id: 'serviceCdsPath',
142
+ type: 'string',
143
+ examples: [
144
+ 'srv/service.cds',
145
+ 'srv/my-service.cds',
146
+ 'path/to/srv/service.cds',
147
+ 'path/to/srv/my-service.cds'
148
+ ],
149
+ description: 'The path to the service cds file',
150
+ required: true
151
+ },
152
+ {
153
+ id: 'capType',
154
+ type: 'string',
155
+ options: ['Node.js', 'Java'],
156
+ required: false
157
+ }
158
+ ],
159
+ required: true
160
+ }
161
+ ],
162
+ required: true
163
+ },
164
+ {
165
+ id: 'entityConfig',
166
+ type: 'object',
167
+ parameters: [
168
+ {
169
+ id: 'mainEntity',
170
+ type: 'object',
171
+ parameters: [
172
+ {
173
+ id: 'entityName',
174
+ type: 'string',
175
+ examples: ["'SalesOrder'", "'PurchaseOrderHeader'", "'MyEntity'"],
176
+ description: "The name of the main entity, e.g. 'SalesOrder'",
177
+ required: true
178
+ }
179
+ ],
180
+ required: true
181
+ },
182
+ {
183
+ id: 'generateFormAnnotations',
184
+ type: 'boolean',
185
+ required: true
186
+ },
187
+ {
188
+ id: 'generateLROPAnnotations',
189
+ type: 'boolean',
190
+ required: true
191
+ }
192
+ ],
193
+ required: true
194
+ },
195
+ {
196
+ id: 'telemetryData',
197
+ type: 'object',
198
+ parameters: [
199
+ {
200
+ id: 'generationSourceName',
201
+ type: 'string',
202
+ options: ['AI Headless MCP'],
203
+ required: true
204
+ },
205
+ {
206
+ id: 'generationSourceVersion',
207
+ type: 'string',
208
+ options: ['1.0.0'],
209
+ required: true
210
+ }
211
+ ],
212
+ required: true
213
+ }
214
+ ],
215
+ required: true
216
+ }
217
+ ]
218
+ };
219
+ /**
220
+ * Retrieves the details of the Generate SAP Fiori UI Application functionality.
221
+ *
222
+ * @returns A promise that resolves to the functionality details output.
223
+ */
224
+ async function getFunctionalityDetails() {
225
+ return exports.GENERATE_FIORI_UI_APP;
226
+ }
227
+ /**
228
+ * Executes the Generate SAP Fiori UI Application functionality.
229
+ *
230
+ * @param params - The input parameters for executing the functionality.
231
+ * @returns A promise that resolves to the execution output.
232
+ */
233
+ async function executeFunctionality(params) {
234
+ return (0, command_1.command)(params);
235
+ }
236
+ exports.generateFioriUIAppHandlers = {
237
+ getFunctionalityDetails,
238
+ executeFunctionality
239
+ };
240
+ //# sourceMappingURL=generate-fiori-ui-app.js.map
@@ -0,0 +1,2 @@
1
+ export { GENERATE_FIORI_UI_APP, generateFioriUIAppHandlers } from './generate-fiori-ui-app';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateFioriUIAppHandlers = exports.GENERATE_FIORI_UI_APP = void 0;
4
+ var generate_fiori_ui_app_1 = require("./generate-fiori-ui-app");
5
+ Object.defineProperty(exports, "GENERATE_FIORI_UI_APP", { enumerable: true, get: function () { return generate_fiori_ui_app_1.GENERATE_FIORI_UI_APP; } });
6
+ Object.defineProperty(exports, "generateFioriUIAppHandlers", { enumerable: true, get: function () { return generate_fiori_ui_app_1.generateFioriUIAppHandlers; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export * from './functionalities';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./functionalities"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ import type { FunctionalityHandlers } from '../../../types';
2
+ import { ADD_PAGE_FUNCTIONALITY } from './application';
3
+ export declare const addPageHandlers: FunctionalityHandlers;
4
+ export { ADD_PAGE_FUNCTIONALITY };
5
+ //# sourceMappingURL=add-page.d.ts.map