@sap-ux/fiori-mcp-server 0.0.8 → 0.0.10

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.
@@ -1,4 +1,39 @@
1
1
  import type { ExecuteFunctionalityInput, ExecuteFunctionalityOutput } from '../../../types';
2
+ import * as z from 'zod';
3
+ declare const GeneratorConfigSchemaCAP: z.ZodObject<{
4
+ floorplan: z.ZodLiteral<"FE_FPM" | "FE_LROP" | "FE_OVP" | "FE_ALP" | "FE_FEOP" | "FE_WORKLIST" | "FF_SIMPLE">;
5
+ project: z.ZodObject<{
6
+ name: z.ZodString;
7
+ targetFolder: z.ZodString;
8
+ namespace: z.ZodOptional<z.ZodString>;
9
+ title: z.ZodOptional<z.ZodString>;
10
+ description: z.ZodString;
11
+ ui5Theme: z.ZodOptional<z.ZodString>;
12
+ ui5Version: z.ZodString;
13
+ localUI5Version: z.ZodOptional<z.ZodString>;
14
+ skipAnnotations: z.ZodOptional<z.ZodBoolean>;
15
+ enableCodeAssist: z.ZodOptional<z.ZodBoolean>;
16
+ enableEslint: z.ZodOptional<z.ZodBoolean>;
17
+ enableTypeScript: z.ZodOptional<z.ZodBoolean>;
18
+ }, z.core.$strip>;
19
+ service: z.ZodObject<{
20
+ servicePath: z.ZodString;
21
+ capService: z.ZodObject<{
22
+ projectPath: z.ZodString;
23
+ serviceName: z.ZodString;
24
+ serviceCdsPath: z.ZodString;
25
+ capType: z.ZodOptional<z.ZodLiteral<"Node.js" | "Java">>;
26
+ }, z.core.$strip>;
27
+ }, z.core.$strip>;
28
+ entityConfig: z.ZodObject<{
29
+ mainEntity: z.ZodObject<{
30
+ entityName: z.ZodString;
31
+ }, z.core.$strip>;
32
+ generateFormAnnotations: z.ZodBoolean;
33
+ generateLROPAnnotations: z.ZodBoolean;
34
+ }, z.core.$strip>;
35
+ }, z.core.$strip>;
36
+ export type GeneratorConfigCAP = z.infer<typeof GeneratorConfigSchemaCAP>;
2
37
  /**
3
38
  * Method to generate fiori app.
4
39
  *
@@ -6,4 +41,5 @@ import type { ExecuteFunctionalityInput, ExecuteFunctionalityOutput } from '../.
6
41
  * @returns Application generation execution output.
7
42
  */
8
43
  export declare function command(params: ExecuteFunctionalityInput): Promise<ExecuteFunctionalityOutput>;
44
+ export {};
9
45
  //# sourceMappingURL=command.d.ts.map
@@ -32,6 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
35
38
  Object.defineProperty(exports, "__esModule", { value: true });
36
39
  exports.command = command;
37
40
  const fs_1 = require("fs");
@@ -41,48 +44,52 @@ const path_1 = require("path");
41
44
  const constant_1 = require("../../../constant");
42
45
  const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
43
46
  const z = __importStar(require("zod"));
47
+ const package_json_1 = __importDefault(require("../../../../package.json"));
44
48
  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()
49
+ floorplan: z.literal(['FE_FPM', 'FE_LROP', 'FE_OVP', 'FE_ALP', 'FE_FEOP', 'FE_WORKLIST', 'FF_SIMPLE']),
50
+ project: z.object({
51
+ name: z.string(),
52
+ targetFolder: z.string(),
53
+ namespace: z.optional(z.string()),
54
+ title: z.optional(z.string()),
55
+ description: z.string(),
56
+ ui5Theme: z.optional(z.string()),
57
+ ui5Version: z.string(),
58
+ localUI5Version: z.optional(z.string()),
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']))
83
71
  })
72
+ }),
73
+ entityConfig: z.object({
74
+ mainEntity: z.object({
75
+ entityName: z.string()
76
+ }),
77
+ generateFormAnnotations: z.boolean(),
78
+ generateLROPAnnotations: z.boolean()
84
79
  })
85
80
  });
81
+ // Extended type generators API use
82
+ const PREDEFINED_GENERATOR_VALUES = {
83
+ // Config schema version
84
+ version: '0.2',
85
+ telemetryData: {
86
+ 'generationSourceName': package_json_1.default.name,
87
+ 'generationSourceVersion': package_json_1.default.version
88
+ },
89
+ project: {
90
+ sapux: true
91
+ }
92
+ };
86
93
  const exec = (0, util_1.promisify)(child_process_1.exec);
87
94
  /**
88
95
  * Method to generate fiori app.
@@ -97,10 +104,19 @@ async function command(params) {
97
104
  }
98
105
  catch (error) {
99
106
  if (error instanceof z.ZodError) {
100
- throw new Error(`Missing required fields in generatorConfig. ${JSON.stringify(error.issues, null, 4)}`);
107
+ throw new Error(`Missing required fields in parameters. ${JSON.stringify(error.issues, null, 4)}`);
101
108
  }
109
+ throw new Error('Unknown error. Recheck input parameters.');
102
110
  }
103
- const generatorConfig = generatorConfigCAP?.appGenConfig;
111
+ const generatorConfig = {
112
+ ...PREDEFINED_GENERATOR_VALUES,
113
+ ...generatorConfigCAP,
114
+ project: {
115
+ ...PREDEFINED_GENERATOR_VALUES.project,
116
+ ...generatorConfigCAP.project
117
+ }
118
+ };
119
+ generatorConfig.project.sapux = generatorConfig.floorplan !== 'FF_SIMPLE';
104
120
  const projectPath = generatorConfig?.project?.targetFolder ?? params.appPath;
105
121
  if (!projectPath || typeof projectPath !== 'string') {
106
122
  throw new Error('Please provide a valid path to the CAP project folder.');
@@ -7,208 +7,154 @@ exports.GENERATE_FIORI_UI_APP = {
7
7
  functionalityId: constant_1.GENERATE_FIORI_UI_APP_ID,
8
8
  name: 'Generate SAP Fiori UI Application',
9
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.
10
+ To populate parameters, you **MUST** use the ***CDS MCP*** to search the model for service definitions, entities, associations, and UI annotations.
12
11
  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.`,
12
+ The data obtained from either method must then be formatted into a JSON object and passed as the parameters.
13
+ The configuration **MUST** be a valid JSON object corresponding to the inputSchema of the tool.
14
+ The configuration **MUST** be based on the project files in the projectPath.`,
14
15
  parameters: [
15
16
  {
16
- id: 'projectPath',
17
+ id: 'floorplan',
17
18
  type: 'string',
18
- description: 'The path to the CAP project folder. By default the currently opened project folder should be used.',
19
+ options: ['FE_LROP', 'FE_FEOP', 'FE_FPM', 'FE_OVP', 'FE_ALP', 'FE_WORKLIST', 'FF_SIMPLE'],
20
+ description: 'SAP Fiori Elements floor plan type.',
19
21
  required: true
20
22
  },
21
23
  {
22
- id: 'appGenConfig',
24
+ id: 'project',
23
25
  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
26
  parameters: [
28
27
  {
29
- id: 'version',
28
+ id: 'name',
30
29
  type: 'string',
31
- options: ['0.2'],
32
- description: 'Config schema version.',
30
+ description: "Must be lowercase with dashes, e.g., 'sales-order-management'.",
31
+ pattern: '^[a-z0-9-]+$',
33
32
  required: true
34
33
  },
35
34
  {
36
- id: 'floorplan',
35
+ id: 'title',
37
36
  type: 'string',
38
- options: ['FE_LROP', 'FE_FEOP', 'FE_FPM'],
39
- description: 'SAP Fiori Elements floor plan type.',
37
+ required: false
38
+ },
39
+ {
40
+ id: 'description',
41
+ type: 'string',
42
+ required: true
43
+ },
44
+ {
45
+ id: 'namespace',
46
+ type: 'string',
47
+ required: false
48
+ },
49
+ {
50
+ id: 'ui5Theme',
51
+ type: 'string',
52
+ required: false
53
+ },
54
+ {
55
+ id: 'targetFolder',
56
+ type: 'string',
57
+ description: 'Absolute path to the CAP project folder (projectPath).',
40
58
  required: true
41
59
  },
42
60
  {
43
- id: 'projectType',
61
+ id: 'ui5Version',
44
62
  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.',
63
+ options: [constant_1.LATEST_UI5_VERSION],
47
64
  required: true
48
65
  },
49
66
  {
50
- id: 'project',
67
+ id: 'localUI5Version',
68
+ type: 'string',
69
+ options: [constant_1.LATEST_UI5_VERSION],
70
+ required: false
71
+ }
72
+ ],
73
+ required: true
74
+ },
75
+ {
76
+ id: 'service',
77
+ type: 'object',
78
+ parameters: [
79
+ {
80
+ id: 'servicePath',
81
+ type: 'string',
82
+ examples: [
83
+ '/odata/v4/<servicename>/',
84
+ '/odata/v4/MyRiskService/',
85
+ '/odata/v2/MyOdataV2Service/',
86
+ '/odata/v4/MyOdataV4Service/',
87
+ "/odata/v4/<relative '@path' annotation from service cds file>/",
88
+ "<absolute '@path' annotation from service cds file>/",
89
+ '/myAbsolutePathFromServiceCdsFile/'
90
+ ],
91
+ 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.',
92
+ required: true
93
+ },
94
+ {
95
+ id: 'capService',
51
96
  type: 'object',
52
97
  parameters: [
53
98
  {
54
- id: 'name',
99
+ id: 'projectPath',
55
100
  type: 'string',
56
- description: "Must be lowercase with dashes, e.g., 'sales-order-management'.",
57
- pattern: '^[a-z0-9-]+$',
58
101
  required: true
59
102
  },
60
103
  {
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',
104
+ id: 'serviceName',
82
105
  type: 'string',
83
- description: 'Absolute path to the CAP project folder (projectPath).',
84
106
  required: true
85
107
  },
86
108
  {
87
- id: 'ui5Version',
109
+ id: 'serviceCdsPath',
88
110
  type: 'string',
89
- options: [constant_1.LATEST_UI5_VERSION],
111
+ examples: [
112
+ 'srv/service.cds',
113
+ 'srv/my-service.cds',
114
+ 'path/to/srv/service.cds',
115
+ 'path/to/srv/my-service.cds'
116
+ ],
117
+ description: 'The path to the service cds file',
90
118
  required: true
91
119
  },
92
120
  {
93
- id: 'localUI5Version',
121
+ id: 'capType',
94
122
  type: 'string',
95
- options: [constant_1.LATEST_UI5_VERSION],
123
+ options: ['Node.js', 'Java'],
96
124
  required: false
97
- },
98
- {
99
- id: 'sapux',
100
- type: 'boolean',
101
- defaultValue: true,
102
- required: true
103
125
  }
104
126
  ],
105
127
  required: true
106
- },
128
+ }
129
+ ],
130
+ required: true
131
+ },
132
+ {
133
+ id: 'entityConfig',
134
+ type: 'object',
135
+ parameters: [
107
136
  {
108
- id: 'service',
137
+ id: 'mainEntity',
109
138
  type: 'object',
110
139
  parameters: [
111
140
  {
112
- id: 'servicePath',
141
+ id: 'entityName',
113
142
  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
- ],
143
+ examples: ["'SalesOrder'", "'PurchaseOrderHeader'", "'MyEntity'"],
144
+ description: "The name of the main entity, e.g. 'SalesOrder'",
159
145
  required: true
160
146
  }
161
147
  ],
162
148
  required: true
163
149
  },
164
150
  {
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
- ],
151
+ id: 'generateFormAnnotations',
152
+ type: 'boolean',
193
153
  required: true
194
154
  },
195
155
  {
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
- ],
156
+ id: 'generateLROPAnnotations',
157
+ type: 'boolean',
212
158
  required: true
213
159
  }
214
160
  ],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-mcp-server",
3
3
  "description": "SAP Fiori - Model Context Protocol (MCP) server",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "keywords": [
6
6
  "SAP Fiori tools",
7
7
  "SAP Fiori elements",
@@ -44,10 +44,10 @@
44
44
  "zod": "4.1.5",
45
45
  "@sap-ux/btp-utils": "1.1.1",
46
46
  "@sap-ux/feature-toggle": "0.3.1",
47
- "@sap-ux/fiori-annotation-api": "0.6.18",
47
+ "@sap-ux/fiori-annotation-api": "0.6.19",
48
48
  "@sap-ux/nodejs-utils": "0.2.3",
49
- "@sap-ux/project-access": "1.30.13",
50
- "@sap-ux/telemetry": "0.6.19"
49
+ "@sap-ux/project-access": "1.30.14",
50
+ "@sap-ux/telemetry": "0.6.20"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=20.x"