@ui5/mcp-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +201 -0
- package/LICENSES/Apache-2.0.txt +73 -0
- package/README.md +131 -0
- package/bin/ui5mcp.js +2 -0
- package/lib/Context.d.ts +28 -0
- package/lib/Context.js +71 -0
- package/lib/Context.js.map +1 -0
- package/lib/api.d.ts +3 -0
- package/lib/api.js +3 -0
- package/lib/api.js.map +1 -0
- package/lib/cli.d.ts +1 -0
- package/lib/cli.js +12 -0
- package/lib/cli.js.map +1 -0
- package/lib/registerTools.d.ts +133 -0
- package/lib/registerTools.js +59 -0
- package/lib/registerTools.js.map +1 -0
- package/lib/resources/documentation/getDocumentation.d.ts +18 -0
- package/lib/resources/documentation/getDocumentation.js +70 -0
- package/lib/resources/documentation/getDocumentation.js.map +1 -0
- package/lib/server.d.ts +10 -0
- package/lib/server.js +113 -0
- package/lib/server.js.map +1 -0
- package/lib/tools/create_ui5_app/ODataMetadata.d.ts +55 -0
- package/lib/tools/create_ui5_app/ODataMetadata.js +99 -0
- package/lib/tools/create_ui5_app/ODataMetadata.js.map +1 -0
- package/lib/tools/create_ui5_app/createSuccessMessage.d.ts +13 -0
- package/lib/tools/create_ui5_app/createSuccessMessage.js +45 -0
- package/lib/tools/create_ui5_app/createSuccessMessage.js.map +1 -0
- package/lib/tools/create_ui5_app/create_ui5_app.d.ts +8 -0
- package/lib/tools/create_ui5_app/create_ui5_app.js +273 -0
- package/lib/tools/create_ui5_app/create_ui5_app.js.map +1 -0
- package/lib/tools/create_ui5_app/index.d.ts +3 -0
- package/lib/tools/create_ui5_app/index.js +58 -0
- package/lib/tools/create_ui5_app/index.js.map +1 -0
- package/lib/tools/create_ui5_app/isValidUrl.d.ts +16 -0
- package/lib/tools/create_ui5_app/isValidUrl.js +59 -0
- package/lib/tools/create_ui5_app/isValidUrl.js.map +1 -0
- package/lib/tools/create_ui5_app/schema.d.ts +135 -0
- package/lib/tools/create_ui5_app/schema.js +67 -0
- package/lib/tools/create_ui5_app/schema.js.map +1 -0
- package/lib/tools/create_ui5_app/templateProcessor.d.ts +67 -0
- package/lib/tools/create_ui5_app/templateProcessor.js +59 -0
- package/lib/tools/create_ui5_app/templateProcessor.js.map +1 -0
- package/lib/tools/create_ui5_app/ui5Version.d.ts +2 -0
- package/lib/tools/create_ui5_app/ui5Version.js +6 -0
- package/lib/tools/create_ui5_app/ui5Version.js.map +1 -0
- package/lib/tools/get_api_reference/createUriForSymbol.d.ts +2 -0
- package/lib/tools/get_api_reference/createUriForSymbol.js +49 -0
- package/lib/tools/get_api_reference/createUriForSymbol.js.map +1 -0
- package/lib/tools/get_api_reference/getApiReference.d.ts +10 -0
- package/lib/tools/get_api_reference/getApiReference.js +51 -0
- package/lib/tools/get_api_reference/getApiReference.js.map +1 -0
- package/lib/tools/get_api_reference/index.d.ts +3 -0
- package/lib/tools/get_api_reference/index.js +38 -0
- package/lib/tools/get_api_reference/index.js.map +1 -0
- package/lib/tools/get_api_reference/lib/ApiReferenceProvider.d.ts +85 -0
- package/lib/tools/get_api_reference/lib/ApiReferenceProvider.js +452 -0
- package/lib/tools/get_api_reference/lib/ApiReferenceProvider.js.map +1 -0
- package/lib/tools/get_api_reference/lib/apiReferenceResources.d.ts +18 -0
- package/lib/tools/get_api_reference/lib/apiReferenceResources.js +138 -0
- package/lib/tools/get_api_reference/lib/apiReferenceResources.js.map +1 -0
- package/lib/tools/get_api_reference/lib/formatSymbol.d.ts +24 -0
- package/lib/tools/get_api_reference/lib/formatSymbol.js +109 -0
- package/lib/tools/get_api_reference/lib/formatSymbol.js.map +1 -0
- package/lib/tools/get_api_reference/schema.d.ts +16 -0
- package/lib/tools/get_api_reference/schema.js +12 -0
- package/lib/tools/get_api_reference/schema.js.map +1 -0
- package/lib/tools/get_guidelines/guidelines.d.ts +1 -0
- package/lib/tools/get_guidelines/guidelines.js +6 -0
- package/lib/tools/get_guidelines/guidelines.js.map +1 -0
- package/lib/tools/get_guidelines/index.d.ts +3 -0
- package/lib/tools/get_guidelines/index.js +30 -0
- package/lib/tools/get_guidelines/index.js.map +1 -0
- package/lib/tools/get_project_info/getProjectInfo.d.ts +2 -0
- package/lib/tools/get_project_info/getProjectInfo.js +205 -0
- package/lib/tools/get_project_info/getProjectInfo.js.map +1 -0
- package/lib/tools/get_project_info/index.d.ts +3 -0
- package/lib/tools/get_project_info/index.js +28 -0
- package/lib/tools/get_project_info/index.js.map +1 -0
- package/lib/tools/get_project_info/schema.d.ts +87 -0
- package/lib/tools/get_project_info/schema.js +28 -0
- package/lib/tools/get_project_info/schema.js.map +1 -0
- package/lib/tools/get_version_info/getVersionInfo.d.ts +8 -0
- package/lib/tools/get_version_info/getVersionInfo.js +41 -0
- package/lib/tools/get_version_info/getVersionInfo.js.map +1 -0
- package/lib/tools/get_version_info/index.d.ts +9 -0
- package/lib/tools/get_version_info/index.js +33 -0
- package/lib/tools/get_version_info/index.js.map +1 -0
- package/lib/tools/get_version_info/schema.d.ts +66 -0
- package/lib/tools/get_version_info/schema.js +16 -0
- package/lib/tools/get_version_info/schema.js.map +1 -0
- package/lib/tools/get_version_info/types.d.ts +5 -0
- package/lib/tools/get_version_info/types.js +2 -0
- package/lib/tools/get_version_info/types.js.map +1 -0
- package/lib/tools/run_ui5_linter/index.d.ts +3 -0
- package/lib/tools/run_ui5_linter/index.js +86 -0
- package/lib/tools/run_ui5_linter/index.js.map +1 -0
- package/lib/tools/run_ui5_linter/migrationGuides.d.ts +6 -0
- package/lib/tools/run_ui5_linter/migrationGuides.js +88 -0
- package/lib/tools/run_ui5_linter/migrationGuides.js.map +1 -0
- package/lib/tools/run_ui5_linter/resultContext.d.ts +3 -0
- package/lib/tools/run_ui5_linter/resultContext.js +236 -0
- package/lib/tools/run_ui5_linter/resultContext.js.map +1 -0
- package/lib/tools/run_ui5_linter/runUi5Linter.d.ts +2 -0
- package/lib/tools/run_ui5_linter/runUi5Linter.js +72 -0
- package/lib/tools/run_ui5_linter/runUi5Linter.js.map +1 -0
- package/lib/tools/run_ui5_linter/schema.d.ts +340 -0
- package/lib/tools/run_ui5_linter/schema.js +55 -0
- package/lib/tools/run_ui5_linter/schema.js.map +1 -0
- package/lib/utils/cdnHelper.d.ts +9 -0
- package/lib/utils/cdnHelper.js +50 -0
- package/lib/utils/cdnHelper.js.map +1 -0
- package/lib/utils/dataStorageHelper.d.ts +2 -0
- package/lib/utils/dataStorageHelper.js +65 -0
- package/lib/utils/dataStorageHelper.js.map +1 -0
- package/lib/utils/ui5Framework.d.ts +4 -0
- package/lib/utils/ui5Framework.js +6 -0
- package/lib/utils/ui5Framework.js.map +1 -0
- package/lib/utils.d.ts +10 -0
- package/lib/utils.js +87 -0
- package/lib/utils.js.map +1 -0
- package/npm-shrinkwrap.json +7880 -0
- package/package.json +121 -0
- package/resources/docs/1.136.7/00737d6c1b864dc3ab72ef56611491c4.md +155 -0
- package/resources/docs/1.136.7/0187ea5e2eff4166b0453b9dcc8fc64f.md +164 -0
- package/resources/docs/1.136.7/032be2cb2e1d4115af20862673bedcdb.md +12 -0
- package/resources/docs/1.136.7/28fcd55b04654977b63dacbee0552712.md +317 -0
- package/resources/docs/1.136.7/676b636446c94eada183b1218a824717.md +135 -0
- package/resources/docs/1.136.7/a87ca843bcee469f82a9072927a7dcdb.md +355 -0
- package/resources/docs/1.136.7/b0fb4de7364f4bcbb053a99aa645affe.md +126 -0
- package/resources/docs/1.136.7/fe1a6dba940e479fb7c3bc753f92b28c.md +670 -0
- package/resources/docs/1.136.7/index.json +58 -0
- package/resources/guidelines.md +104 -0
- package/resources/migrationGuides/deprecated-controller-factory.md +116 -0
- package/resources/migrationGuides/deprecated-getLibraryResourceBundle.md +62 -0
- package/resources/migrationGuides/deprecated-jquery-sap-require.md +141 -0
- package/resources/migrationGuides/deprecated-messagePage.md +162 -0
- package/resources/migrationGuides/deprecated-table-table-property.md +154 -0
- package/resources/template-js/LICENSE +201 -0
- package/resources/template-js/README.md +87 -0
- package/resources/template-js/_.editorconfig +22 -0
- package/resources/template-js/_.gitignore +17 -0
- package/resources/template-js/eslint.config.js +68 -0
- package/resources/template-js/karma-ci-cov.conf.js +20 -0
- package/resources/template-js/karma-ci.conf.js +9 -0
- package/resources/template-js/karma.conf.js +9 -0
- package/resources/template-js/package.json +34 -0
- package/resources/template-js/ui5-dist.yaml +18 -0
- package/resources/template-js/ui5.yaml +24 -0
- package/resources/template-js/webapp/Component.js +41 -0
- package/resources/template-js/webapp/controller/App.controller.js +10 -0
- package/resources/template-js/webapp/controller/BaseController.js +67 -0
- package/resources/template-js/webapp/controller/Main.controller.js +14 -0
- package/resources/template-js/webapp/i18n/i18n.properties +3 -0
- package/resources/template-js/webapp/i18n/i18n_en.properties +3 -0
- package/resources/template-js/webapp/index-cdn.html +34 -0
- package/resources/template-js/webapp/index.html +34 -0
- package/resources/template-js/webapp/manifest.json +103 -0
- package/resources/template-js/webapp/model/formatter.js +9 -0
- package/resources/template-js/webapp/model/models.js +11 -0
- package/resources/template-js/webapp/test/Test.qunit.html +16 -0
- package/resources/template-js/webapp/test/integration/HelloJourney.js +85 -0
- package/resources/template-js/webapp/test/integration/opaTests.qunit.js +1 -0
- package/resources/template-js/webapp/test/integration/pages/Main.js +112 -0
- package/resources/template-js/webapp/test/testsuite.qunit.html +18 -0
- package/resources/template-js/webapp/test/testsuite.qunit.js +37 -0
- package/resources/template-js/webapp/test/unit/controller/Main.qunit.js +11 -0
- package/resources/template-js/webapp/test/unit/unitTests.qunit.js +1 -0
- package/resources/template-js/webapp/test-lt1_124/integration/HelloJourney.js +85 -0
- package/resources/template-js/webapp/test-lt1_124/integration/opaTests.qunit.html +31 -0
- package/resources/template-js/webapp/test-lt1_124/integration/opaTests.qunit.js +11 -0
- package/resources/template-js/webapp/test-lt1_124/integration/pages/Main.js +112 -0
- package/resources/template-js/webapp/test-lt1_124/testsuite.qunit.html +13 -0
- package/resources/template-js/webapp/test-lt1_124/testsuite.qunit.js +9 -0
- package/resources/template-js/webapp/test-lt1_124/unit/controller/Main.qunit.js +11 -0
- package/resources/template-js/webapp/test-lt1_124/unit/unitTests.qunit.html +30 -0
- package/resources/template-js/webapp/test-lt1_124/unit/unitTests.qunit.js +12 -0
- package/resources/template-js/webapp/view/App.view.xml +9 -0
- package/resources/template-js/webapp/view/Main.view.xml +90 -0
- package/resources/template-ts/LICENSE +201 -0
- package/resources/template-ts/README.md +101 -0
- package/resources/template-ts/_.editorconfig +23 -0
- package/resources/template-ts/_.gitignore +18 -0
- package/resources/template-ts/_.nycrc.json +7 -0
- package/resources/template-ts/_tsconfig.json +21 -0
- package/resources/template-ts/eslint.config.mjs +27 -0
- package/resources/template-ts/package.json +40 -0
- package/resources/template-ts/ui5-coverage.yaml +40 -0
- package/resources/template-ts/ui5-dist.yaml +18 -0
- package/resources/template-ts/ui5.yaml +27 -0
- package/resources/template-ts/webapp/Component.ts +49 -0
- package/resources/template-ts/webapp/controller/App.controller.ts +11 -0
- package/resources/template-ts/webapp/controller/BaseController.ts +83 -0
- package/resources/template-ts/webapp/controller/Main.controller.ts +19 -0
- package/resources/template-ts/webapp/i18n/i18n.properties +3 -0
- package/resources/template-ts/webapp/i18n/i18n_en.properties +3 -0
- package/resources/template-ts/webapp/index-cdn.html +35 -0
- package/resources/template-ts/webapp/index.html +35 -0
- package/resources/template-ts/webapp/manifest.json +105 -0
- package/resources/template-ts/webapp/model/formatter.ts +5 -0
- package/resources/template-ts/webapp/model/models.ts +15 -0
- package/resources/template-ts/webapp/test/Test.qunit.html +16 -0
- package/resources/template-ts/webapp/test/integration/HelloJourney.ts +84 -0
- package/resources/template-ts/webapp/test/integration/opaTests.qunit.ts +2 -0
- package/resources/template-ts/webapp/test/integration/pages/MainPage.ts +112 -0
- package/resources/template-ts/webapp/test/testsuite.qunit.html +18 -0
- package/resources/template-ts/webapp/test/testsuite.qunit.ts +33 -0
- package/resources/template-ts/webapp/test/unit/controller/Main.qunit.ts +8 -0
- package/resources/template-ts/webapp/test/unit/unitTests.qunit.ts +2 -0
- package/resources/template-ts/webapp/test-lt1_124/integration/HelloJourney.ts +86 -0
- package/resources/template-ts/webapp/test-lt1_124/integration/opaTests.qunit.html +34 -0
- package/resources/template-ts/webapp/test-lt1_124/integration/opaTests.qunit.ts +8 -0
- package/resources/template-ts/webapp/test-lt1_124/integration/pages/MainPage.ts +112 -0
- package/resources/template-ts/webapp/test-lt1_124/testsuite.qunit.html +13 -0
- package/resources/template-ts/webapp/test-lt1_124/testsuite.qunit.ts +9 -0
- package/resources/template-ts/webapp/test-lt1_124/unit/controller/Main.qunit.ts +8 -0
- package/resources/template-ts/webapp/test-lt1_124/unit/unitTests.qunit.html +37 -0
- package/resources/template-ts/webapp/test-lt1_124/unit/unitTests.qunit.ts +8 -0
- package/resources/template-ts/webapp/view/App.view.xml +9 -0
- package/resources/template-ts/webapp/view/Main.view.xml +90 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import Context from "./Context.js";
|
|
4
|
+
interface Options {
|
|
5
|
+
useStructuredContentInResponse: boolean;
|
|
6
|
+
useResourcesInResponse: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type RegisterTool = McpServer["registerTool"];
|
|
9
|
+
export default function (server: McpServer, context: Context, options: Options): void;
|
|
10
|
+
export declare function _processResponse({ content, structuredContent }: CallToolResult, options: Options): {
|
|
11
|
+
structuredContent: {
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
content: ({
|
|
15
|
+
[x: string]: unknown;
|
|
16
|
+
type: "text";
|
|
17
|
+
text: string;
|
|
18
|
+
_meta?: {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
type: "image";
|
|
24
|
+
data: string;
|
|
25
|
+
mimeType: string;
|
|
26
|
+
_meta?: {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
} | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
type: "audio";
|
|
32
|
+
data: string;
|
|
33
|
+
mimeType: string;
|
|
34
|
+
_meta?: {
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
} | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
name: string;
|
|
40
|
+
type: "resource_link";
|
|
41
|
+
uri: string;
|
|
42
|
+
title?: string | undefined;
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
_meta?: {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
} | undefined;
|
|
47
|
+
mimeType?: string | undefined;
|
|
48
|
+
} | {
|
|
49
|
+
[x: string]: unknown;
|
|
50
|
+
type: "resource";
|
|
51
|
+
resource: {
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
text: string;
|
|
54
|
+
uri: string;
|
|
55
|
+
_meta?: {
|
|
56
|
+
[x: string]: unknown;
|
|
57
|
+
} | undefined;
|
|
58
|
+
mimeType?: string | undefined;
|
|
59
|
+
} | {
|
|
60
|
+
[x: string]: unknown;
|
|
61
|
+
blob: string;
|
|
62
|
+
uri: string;
|
|
63
|
+
_meta?: {
|
|
64
|
+
[x: string]: unknown;
|
|
65
|
+
} | undefined;
|
|
66
|
+
mimeType?: string | undefined;
|
|
67
|
+
};
|
|
68
|
+
_meta?: {
|
|
69
|
+
[x: string]: unknown;
|
|
70
|
+
} | undefined;
|
|
71
|
+
})[];
|
|
72
|
+
} | {
|
|
73
|
+
content: ({
|
|
74
|
+
[x: string]: unknown;
|
|
75
|
+
type: "text";
|
|
76
|
+
text: string;
|
|
77
|
+
_meta?: {
|
|
78
|
+
[x: string]: unknown;
|
|
79
|
+
} | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
[x: string]: unknown;
|
|
82
|
+
type: "image";
|
|
83
|
+
data: string;
|
|
84
|
+
mimeType: string;
|
|
85
|
+
_meta?: {
|
|
86
|
+
[x: string]: unknown;
|
|
87
|
+
} | undefined;
|
|
88
|
+
} | {
|
|
89
|
+
[x: string]: unknown;
|
|
90
|
+
type: "audio";
|
|
91
|
+
data: string;
|
|
92
|
+
mimeType: string;
|
|
93
|
+
_meta?: {
|
|
94
|
+
[x: string]: unknown;
|
|
95
|
+
} | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
[x: string]: unknown;
|
|
98
|
+
name: string;
|
|
99
|
+
type: "resource_link";
|
|
100
|
+
uri: string;
|
|
101
|
+
title?: string | undefined;
|
|
102
|
+
description?: string | undefined;
|
|
103
|
+
_meta?: {
|
|
104
|
+
[x: string]: unknown;
|
|
105
|
+
} | undefined;
|
|
106
|
+
mimeType?: string | undefined;
|
|
107
|
+
} | {
|
|
108
|
+
[x: string]: unknown;
|
|
109
|
+
type: "resource";
|
|
110
|
+
resource: {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
text: string;
|
|
113
|
+
uri: string;
|
|
114
|
+
_meta?: {
|
|
115
|
+
[x: string]: unknown;
|
|
116
|
+
} | undefined;
|
|
117
|
+
mimeType?: string | undefined;
|
|
118
|
+
} | {
|
|
119
|
+
[x: string]: unknown;
|
|
120
|
+
blob: string;
|
|
121
|
+
uri: string;
|
|
122
|
+
_meta?: {
|
|
123
|
+
[x: string]: unknown;
|
|
124
|
+
} | undefined;
|
|
125
|
+
mimeType?: string | undefined;
|
|
126
|
+
};
|
|
127
|
+
_meta?: {
|
|
128
|
+
[x: string]: unknown;
|
|
129
|
+
} | undefined;
|
|
130
|
+
})[];
|
|
131
|
+
structuredContent?: undefined;
|
|
132
|
+
};
|
|
133
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { handleError } from "./utils.js";
|
|
2
|
+
import registerProjectInfoTool from "./tools/get_project_info/index.js";
|
|
3
|
+
import registerCreateUi5AppTool from "./tools/create_ui5_app/index.js";
|
|
4
|
+
import registerUi5LinterTool from "./tools/run_ui5_linter/index.js";
|
|
5
|
+
import registerApiRefTool from "./tools/get_api_reference/index.js";
|
|
6
|
+
import registerGetGuidelinesTool from "./tools/get_guidelines/index.js";
|
|
7
|
+
import registerGetVersionInfoTool from "./tools/get_version_info/index.js";
|
|
8
|
+
export default function (server, context, options) {
|
|
9
|
+
const registerTool = (name, config, callback) => {
|
|
10
|
+
if (!options.useStructuredContentInResponse) {
|
|
11
|
+
// If no structured content will be returned, we also must not provide an output schema
|
|
12
|
+
delete config.outputSchema;
|
|
13
|
+
}
|
|
14
|
+
// @ts-expect-error -- Generic type handling
|
|
15
|
+
return server.registerTool(name, config, async (...args) => {
|
|
16
|
+
try {
|
|
17
|
+
const res = await Promise.resolve(callback(...args));
|
|
18
|
+
return _processResponse(res, options);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
handleError(error);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
// The guidelines tool should be registered first to ensure it is displayed first in MCP clients.
|
|
26
|
+
registerGetGuidelinesTool(registerTool, context);
|
|
27
|
+
registerUi5LinterTool(registerTool, context);
|
|
28
|
+
registerApiRefTool(registerTool, context);
|
|
29
|
+
registerProjectInfoTool(registerTool, context);
|
|
30
|
+
registerCreateUi5AppTool(registerTool, context);
|
|
31
|
+
registerGetVersionInfoTool(registerTool, context);
|
|
32
|
+
}
|
|
33
|
+
export function _processResponse({ content, structuredContent }, options) {
|
|
34
|
+
if (!options.useResourcesInResponse) {
|
|
35
|
+
content = content.map((item) => {
|
|
36
|
+
if (item.type === "resource") {
|
|
37
|
+
let text = item.resource.text;
|
|
38
|
+
if (item.resource.title && typeof item.resource.title === "string") {
|
|
39
|
+
text = `# ${item.resource.title}\n\n${text}`;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
type: "text",
|
|
43
|
+
text,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return item;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (structuredContent && options.useStructuredContentInResponse) {
|
|
50
|
+
return {
|
|
51
|
+
structuredContent,
|
|
52
|
+
content,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
content,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=registerTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerTools.js","sourceRoot":"","sources":["../src/registerTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAEvC,OAAO,uBAAuB,MAAM,mCAAmC,CAAC;AACxE,OAAO,wBAAwB,MAAM,iCAAiC,CAAC;AACvE,OAAO,qBAAqB,MAAM,iCAAiC,CAAC;AACpE,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AACpE,OAAO,yBAAyB,MAAM,iCAAiC,CAAC;AACxE,OAAO,0BAA0B,MAAM,mCAAmC,CAAC;AAS3E,MAAM,CAAC,OAAO,WAAW,MAAiB,EAAE,OAAgB,EAAE,OAAgB;IAC7E,MAAM,YAAY,GAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;QAC7D,IAAI,CAAC,OAAO,CAAC,8BAA8B,EAAE,CAAC;YAC7C,uFAAuF;YACvF,OAAO,MAAM,CAAC,YAAY,CAAC;QAC5B,CAAC;QACD,4CAA4C;QAC5C,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;YAC1D,IAAI,CAAC;gBACJ,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBACrD,OAAO,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,WAAW,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
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum AvailableVersions {
|
|
2
|
+
"1.136.7" = "1.136.7"
|
|
3
|
+
}
|
|
4
|
+
export interface DocumentationResource {
|
|
5
|
+
title: string;
|
|
6
|
+
text: string;
|
|
7
|
+
uri: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DocumentationIndexEntry {
|
|
10
|
+
shortIdentifier: string;
|
|
11
|
+
identifier: string;
|
|
12
|
+
uri: string;
|
|
13
|
+
title: string;
|
|
14
|
+
filePath: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function getDocumentationIndex(version?: AvailableVersions): Promise<DocumentationIndexEntry[]>;
|
|
17
|
+
export declare function getDocumentationByLoio(loioIdentifier: string, version?: AvailableVersions): Promise<DocumentationResource>;
|
|
18
|
+
export declare function getDocumentationByUrl(url: string): Promise<DocumentationResource>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { fileExists, InvalidInputError, NotFoundError } from "../../utils.js";
|
|
4
|
+
import { readFile } from "fs/promises";
|
|
5
|
+
import { Mutex } from "async-mutex";
|
|
6
|
+
export var AvailableVersions;
|
|
7
|
+
(function (AvailableVersions) {
|
|
8
|
+
AvailableVersions["1.136.7"] = "1.136.7";
|
|
9
|
+
})(AvailableVersions || (AvailableVersions = {}));
|
|
10
|
+
const defaultVersion = AvailableVersions["1.136.7"];
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const docsDir = path.join(__dirname, "..", "..", "..", "resources", "docs");
|
|
13
|
+
export async function getDocumentationIndex(version = defaultVersion) {
|
|
14
|
+
return await getIndex(version);
|
|
15
|
+
}
|
|
16
|
+
export async function getDocumentationByLoio(loioIdentifier, version = defaultVersion) {
|
|
17
|
+
const index = await getIndex(version);
|
|
18
|
+
const entry = index.find((e) => e.identifier === loioIdentifier || e.shortIdentifier === loioIdentifier);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
throw new NotFoundError(`Documentation not found for LOIO identifier: ${loioIdentifier}`);
|
|
21
|
+
}
|
|
22
|
+
const filePath = path.join(docsDir, version, entry.filePath);
|
|
23
|
+
if (!await fileExists(filePath)) {
|
|
24
|
+
throw new NotFoundError(`Documentation file not found: ${filePath}`);
|
|
25
|
+
}
|
|
26
|
+
const text = await readFile(filePath, "utf-8");
|
|
27
|
+
return {
|
|
28
|
+
title: entry.title,
|
|
29
|
+
text,
|
|
30
|
+
uri: entry.uri,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const TOPIC_URL_REGEX = /https:\/\/ui5.sap.com\/(?:[0-9.]+\/)?(?:#\/)?topic\/([a-zA-Z0-9]+)/i;
|
|
34
|
+
export async function getDocumentationByUrl(url) {
|
|
35
|
+
// Check it's a topic URL
|
|
36
|
+
const match = TOPIC_URL_REGEX.exec(url);
|
|
37
|
+
if (!match) {
|
|
38
|
+
throw new InvalidInputError(`The provided URL does not point to a topic in the UI5 SDK documentation: ${url}. ` +
|
|
39
|
+
`Expected format: https://ui5.sap.com/[<version>/]topic/<loio-identifier>.`);
|
|
40
|
+
}
|
|
41
|
+
// Extract loio identifier from URL
|
|
42
|
+
const identifier = match[1].toLowerCase();
|
|
43
|
+
return await getDocumentationByLoio(identifier);
|
|
44
|
+
}
|
|
45
|
+
const indexMutex = new Mutex();
|
|
46
|
+
const indexCache = {};
|
|
47
|
+
async function getIndex(version) {
|
|
48
|
+
if (indexCache[version]) {
|
|
49
|
+
return indexCache[version];
|
|
50
|
+
}
|
|
51
|
+
const release = await indexMutex.acquire();
|
|
52
|
+
try {
|
|
53
|
+
// Check again inside the mutex
|
|
54
|
+
if (indexCache[version]) {
|
|
55
|
+
return indexCache[version];
|
|
56
|
+
}
|
|
57
|
+
const indexPath = path.join(docsDir, version, "index.json");
|
|
58
|
+
if (!await fileExists(indexPath)) {
|
|
59
|
+
throw new Error(`Documentation index not found for version ${version}: ${indexPath}`);
|
|
60
|
+
}
|
|
61
|
+
const indexContent = await readFile(indexPath, "utf-8");
|
|
62
|
+
const index = JSON.parse(indexContent);
|
|
63
|
+
indexCache[version] = index;
|
|
64
|
+
return index;
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
release();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=getDocumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDocumentation.js","sourceRoot":"","sources":["../../../src/resources/documentation/getDocumentation.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAElC,MAAM,CAAN,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC5B,wCAAqB,CAAA;AACtB,CAAC,EAFW,iBAAiB,KAAjB,iBAAiB,QAE5B;AACD,MAAM,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAgBpD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,UAA6B,cAAc;IAE3C,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,cAAsB,EACtB,UAA6B,cAAc;IAE3C,MAAM,KAA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EAAE,CAAC;AAC/B,MAAM,UAAU,GAA8C,EAAE,CAAC;AAEjE,KAAK,UAAU,QAAQ,CAAC,OAA0B;IACjD,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;IAC3C,IAAI,CAAC;QACJ,+BAA+B;QAC/B,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,6CAA6C,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAA8B,CAAC;QACpE,UAAU,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;QAC5B,OAAO,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACV,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC"}
|
package/lib/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
2
|
+
export default class Server {
|
|
3
|
+
private server;
|
|
4
|
+
private context;
|
|
5
|
+
constructor();
|
|
6
|
+
connect(transport?: Transport): Promise<void>;
|
|
7
|
+
handleServerInitialized(): Promise<void>;
|
|
8
|
+
updateRoots(): Promise<void>;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import Context from "./Context.js";
|
|
4
|
+
import { ErrorCode, McpError, RootsListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { getLogger } from "@ui5/logger";
|
|
6
|
+
import { handleError, PKG_VERSION } from "./utils.js";
|
|
7
|
+
import registerTools from "./registerTools.js";
|
|
8
|
+
const log = getLogger("server");
|
|
9
|
+
export default class Server {
|
|
10
|
+
server;
|
|
11
|
+
context;
|
|
12
|
+
constructor() {
|
|
13
|
+
let useStructuredContentInResponse = true;
|
|
14
|
+
if (process.env.UI5_MCP_SERVER_RESPONSE_NO_STRUCTURED_CONTENT) {
|
|
15
|
+
log.info("As per user configuration, responses will not use structured content");
|
|
16
|
+
useStructuredContentInResponse = false;
|
|
17
|
+
}
|
|
18
|
+
let useResourcesInResponse = true;
|
|
19
|
+
if (process.env.UI5_MCP_SERVER_RESPONSE_NO_RESOURCES) {
|
|
20
|
+
log.info("As per user configuration, responses will not use resources");
|
|
21
|
+
useResourcesInResponse = false;
|
|
22
|
+
}
|
|
23
|
+
this.context = new Context();
|
|
24
|
+
this.server = new McpServer({
|
|
25
|
+
name: "UI5",
|
|
26
|
+
version: PKG_VERSION,
|
|
27
|
+
capabilities: {
|
|
28
|
+
tools: {},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
registerTools(this.server, this.context, {
|
|
32
|
+
useStructuredContentInResponse,
|
|
33
|
+
useResourcesInResponse,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async connect(transport = new StdioServerTransport()) {
|
|
37
|
+
if (this.server.isConnected()) {
|
|
38
|
+
throw new Error("Server is already connected");
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- See comment below
|
|
41
|
+
this.server.server.oninitialized = async () => {
|
|
42
|
+
// oninitialized is typed as not returning a promise, however the current code in the SDK
|
|
43
|
+
// still seems to handle it correctly, therefore we return a promise still and will raise an issue about
|
|
44
|
+
// async initialization handling
|
|
45
|
+
log.verbose("Client initialized");
|
|
46
|
+
try {
|
|
47
|
+
await this.handleServerInitialized();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
handleError(err);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
await this.server.connect(transport);
|
|
54
|
+
}
|
|
55
|
+
async handleServerInitialized() {
|
|
56
|
+
const clientCapabilities = this.server.server.getClientCapabilities();
|
|
57
|
+
if (!clientCapabilities?.roots) {
|
|
58
|
+
log.verbose("Client does not support roots capability");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (clientCapabilities?.roots?.listChanged) {
|
|
62
|
+
// Register handler for future updates to the roots list
|
|
63
|
+
this.server.server.setNotificationHandler(RootsListChangedNotificationSchema, async (notification) => {
|
|
64
|
+
if (notification.method !== "notifications/roots/list_changed") {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
await this.updateRoots();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
// We need to handle errors here since the MCP SDK currently seems to just swallow promise
|
|
72
|
+
// rejections in response handlers
|
|
73
|
+
handleError(err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
log.verbose("Client does not support issuing notifications for changed roots");
|
|
79
|
+
}
|
|
80
|
+
// Fetch the initial list of roots
|
|
81
|
+
await this.updateRoots();
|
|
82
|
+
}
|
|
83
|
+
async updateRoots() {
|
|
84
|
+
if (!this.server.isConnected()) {
|
|
85
|
+
throw new Error("Server is not connected");
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const res = await this.server.server.listRoots();
|
|
89
|
+
log.info(`Received ${res.roots.length} roots from client`);
|
|
90
|
+
log.verbose(`Setting roots in context: ${JSON.stringify(res.roots)}`);
|
|
91
|
+
this.context.setRoots(res.roots);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
if (err instanceof McpError &&
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
96
|
+
err.code === ErrorCode.MethodNotFound) {
|
|
97
|
+
// This error is produced by listRoots() if the client doesn't handle the request
|
|
98
|
+
// This indicates that it does not support roots, and can be ignored safely
|
|
99
|
+
log.verbose("Client does not implement roots/list request handler");
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async close() {
|
|
107
|
+
if (!this.server.isConnected()) {
|
|
108
|
+
throw new Error("Server is not connected");
|
|
109
|
+
}
|
|
110
|
+
await this.server.close();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAC,MAAM,2CAA2C,CAAC;AAG/E,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,kCAAkC,EAAC,MAAM,oCAAoC,CAAC;AAE3G,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AACpD,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,MAAM;IAClB,MAAM,CAAY;IAClB,OAAO,CAAU;IAEzB;QACC,IAAI,8BAA8B,GAAG,IA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,CAAC,MAAM,oBAAoB,CAAC,CAAC;YAC3D,GAAG,CAAC,OAAO,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,GAAG,YAAY,QAAQ;gBAC1B,wEAAwE;gBACxE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc,EAAE,CAAC;gBACxC,iFAAiF;gBACjF,2EAA2E;gBAC3E,GAAG,CAAC,OAAO,CAAC,sDAAsD,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACP,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC;IACF,CAAC;IAED,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
interface PropertyRef {
|
|
2
|
+
Name: string;
|
|
3
|
+
}
|
|
4
|
+
interface Property {
|
|
5
|
+
Name: string;
|
|
6
|
+
Type: string;
|
|
7
|
+
}
|
|
8
|
+
interface EntityType {
|
|
9
|
+
Name: string;
|
|
10
|
+
Key?: {
|
|
11
|
+
PropertyRef: PropertyRef | PropertyRef[];
|
|
12
|
+
};
|
|
13
|
+
Property?: Property | Property[];
|
|
14
|
+
}
|
|
15
|
+
interface EntitySet {
|
|
16
|
+
Name: string;
|
|
17
|
+
EntityType: string;
|
|
18
|
+
}
|
|
19
|
+
interface Schema {
|
|
20
|
+
Namespace: string;
|
|
21
|
+
EntityType?: EntityType | EntityType[];
|
|
22
|
+
EntityContainer?: {
|
|
23
|
+
EntitySet?: EntitySet | EntitySet[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
interface DataServices {
|
|
27
|
+
Schema: Schema | Schema[];
|
|
28
|
+
}
|
|
29
|
+
interface Edmx {
|
|
30
|
+
DataServices: DataServices;
|
|
31
|
+
}
|
|
32
|
+
interface ServiceMetadata {
|
|
33
|
+
Edmx: Edmx;
|
|
34
|
+
}
|
|
35
|
+
export default class ODataMetadata {
|
|
36
|
+
private serviceMetadata;
|
|
37
|
+
private entityTypes;
|
|
38
|
+
private entitySets;
|
|
39
|
+
private static serviceUrl;
|
|
40
|
+
constructor(serviceMetadata: ServiceMetadata);
|
|
41
|
+
static load(serviceUrl: string): Promise<ODataMetadata | undefined>;
|
|
42
|
+
getEntitySets(): string[];
|
|
43
|
+
getEntitySet(name: string): {
|
|
44
|
+
namespace: string;
|
|
45
|
+
name: string;
|
|
46
|
+
keys: string[];
|
|
47
|
+
properties: {
|
|
48
|
+
name: string;
|
|
49
|
+
type: string;
|
|
50
|
+
}[];
|
|
51
|
+
} | undefined;
|
|
52
|
+
getKeys(entitySet: string): string[] | undefined;
|
|
53
|
+
getProperties(entitySet: string): string[] | undefined;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Taken from https://github.com/ui5-community/generator-ui5-ts-app-fcl/blob/main/generators/app/utils.js and adapted
|
|
2
|
+
import { URL } from "url";
|
|
3
|
+
import { XMLParser } from "fast-xml-parser";
|
|
4
|
+
import fetch from "make-fetch-happen";
|
|
5
|
+
import { getLogger } from "@ui5/logger";
|
|
6
|
+
const log = getLogger("tools:create_ui5_app:ODataMetadata");
|
|
7
|
+
// Utility function to ensure a value is always an array
|
|
8
|
+
function ensureArray(value) {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
return [value];
|
|
16
|
+
}
|
|
17
|
+
// Main ODataMetadata class
|
|
18
|
+
export default class ODataMetadata {
|
|
19
|
+
serviceMetadata;
|
|
20
|
+
entityTypes = {};
|
|
21
|
+
entitySets = {};
|
|
22
|
+
static serviceUrl;
|
|
23
|
+
constructor(serviceMetadata) {
|
|
24
|
+
this.serviceMetadata = serviceMetadata;
|
|
25
|
+
const schemas = ensureArray(this.serviceMetadata.Edmx.DataServices.Schema);
|
|
26
|
+
schemas?.forEach((schema) => {
|
|
27
|
+
ensureArray(schema.EntityType)?.forEach((entityType) => {
|
|
28
|
+
let keys = entityType.Key?.PropertyRef;
|
|
29
|
+
if (keys && !Array.isArray(keys)) {
|
|
30
|
+
keys = [keys];
|
|
31
|
+
}
|
|
32
|
+
this.entityTypes[`${schema.Namespace}.${entityType.Name}`] = {
|
|
33
|
+
namespace: schema.Namespace,
|
|
34
|
+
name: entityType.Name,
|
|
35
|
+
keys: ensureArray(entityType.Key?.PropertyRef)?.map((key) => key.Name) ?? [],
|
|
36
|
+
properties: ensureArray(entityType.Property)?.map((prop) => ({
|
|
37
|
+
name: prop.Name,
|
|
38
|
+
type: prop.Type,
|
|
39
|
+
})) ?? [],
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
schemas?.forEach((schema) => {
|
|
44
|
+
ensureArray(schema.EntityContainer?.EntitySet)?.forEach((entitySet) => {
|
|
45
|
+
const entityType = this.entityTypes[entitySet.EntityType];
|
|
46
|
+
if (entityType) {
|
|
47
|
+
this.entitySets[entitySet.Name] = entityType;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
static async load(serviceUrl) {
|
|
53
|
+
try {
|
|
54
|
+
this.serviceUrl = new URL(serviceUrl);
|
|
55
|
+
const url = `${this.serviceUrl.toString()}$metadata`;
|
|
56
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(10000) });
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
if (response.status === 404) {
|
|
59
|
+
log.info(`The requested resource does not exist: ${url}`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
log.info(`Unexpected response ${response.status}: ${response.statusText} for URL: ${url}`);
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const parser = new XMLParser({
|
|
67
|
+
ignoreAttributes: false,
|
|
68
|
+
attributeNamePrefix: "",
|
|
69
|
+
textNodeName: "#text",
|
|
70
|
+
parseAttributeValue: true,
|
|
71
|
+
parseTagValue: true,
|
|
72
|
+
trimValues: true,
|
|
73
|
+
removeNSPrefix: true,
|
|
74
|
+
});
|
|
75
|
+
const serviceMetadata = parser.parse(await response.text());
|
|
76
|
+
return new ODataMetadata(serviceMetadata);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
// Silently ignore metadata loading errors
|
|
80
|
+
// Many services require proxies or authentication, which is out of scope for this tool
|
|
81
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
82
|
+
log.info(`Failed to load OData metadata from '${serviceUrl}': ` +
|
|
83
|
+
`${errorMessage}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getEntitySets() {
|
|
87
|
+
return Object.keys(this.entitySets).sort();
|
|
88
|
+
}
|
|
89
|
+
getEntitySet(name) {
|
|
90
|
+
return this.entitySets[name];
|
|
91
|
+
}
|
|
92
|
+
getKeys(entitySet) {
|
|
93
|
+
return this.getEntitySet(entitySet)?.keys;
|
|
94
|
+
}
|
|
95
|
+
getProperties(entitySet) {
|
|
96
|
+
return this.getEntitySet(entitySet)?.properties.map((prop) => prop.name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=ODataMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ODataMetadata.js","sourceRoot":"","sources":["../../../src/tools/create_ui5_app/ODataMetadata.ts"],"names":[],"mappings":"AAAA,q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C,CAAC;IAED,YAAY,CAAC,IAAY;QAMxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,SAAiB;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC3C,CAAC;IAED,aAAa,CAAC,SAAiB;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function createSuccessMessage({ finalODataV4Url, oDataEntitySet, entityProperties, basePath, appNamespace, framework, frameworkVersion, runNpmInstall, finalLocation, typescript, generatedFiles, }: {
|
|
2
|
+
finalODataV4Url?: string;
|
|
3
|
+
oDataEntitySet?: string;
|
|
4
|
+
entityProperties?: string[];
|
|
5
|
+
basePath: string;
|
|
6
|
+
appNamespace: string;
|
|
7
|
+
framework: string;
|
|
8
|
+
frameworkVersion: string;
|
|
9
|
+
runNpmInstall: boolean;
|
|
10
|
+
finalLocation: string;
|
|
11
|
+
typescript: boolean;
|
|
12
|
+
generatedFiles: string[];
|
|
13
|
+
}): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Utility to build the success message for createUi5App
|
|
2
|
+
export function createSuccessMessage({ finalODataV4Url, oDataEntitySet, entityProperties, basePath, appNamespace, framework, frameworkVersion, runNpmInstall, finalLocation, typescript, generatedFiles, }) {
|
|
3
|
+
const appType = typescript ? "TypeScript" : "JavaScript";
|
|
4
|
+
let uiContent = "";
|
|
5
|
+
if (finalODataV4Url && oDataEntitySet) {
|
|
6
|
+
if (entityProperties && entityProperties.length > 0) {
|
|
7
|
+
uiContent = "The table in the Main view displays the following properties of the entity set " +
|
|
8
|
+
`'${oDataEntitySet}': ${entityProperties.join(", ")}.\n`;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
uiContent = "Note that the table in the Main view has no columns and the Form has no fields, " +
|
|
12
|
+
"as an OData service and entity " +
|
|
13
|
+
"was provided, but no properties were specified and none could be found automatically\n";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if (finalODataV4Url /* and no entity */) {
|
|
17
|
+
uiContent = "An OData model was set up, but no UI for displaying data was created, as no " +
|
|
18
|
+
"entity set was specified.\n";
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
uiContent = "";
|
|
22
|
+
}
|
|
23
|
+
const capContent = basePath.includes("/app/") || basePath.endsWith("/app") ?
|
|
24
|
+
// hints for handling CAP projects
|
|
25
|
+
"Note that in CAP projects you **MUST NOT** use 'npm start' of this UI5 app, as doing this and opening" +
|
|
26
|
+
" it on port 8080 will not allow the app to load any data. Instead, you **MUST** use 'cds watch' in the " +
|
|
27
|
+
" project root to start the server. The new app is then automatically served at" +
|
|
28
|
+
` /${appNamespace}/index.html.\n` :
|
|
29
|
+
// this is for non-CAP cases
|
|
30
|
+
"Note that 'npm start' starts the server and remains active, so you should not wait for the command" +
|
|
31
|
+
" to exit on its own.\nNote that you should not open the root of the server ('/') to launch the app" +
|
|
32
|
+
" when using the UI5 CLI tooling for serving it, but 'index.html'.";
|
|
33
|
+
const message = `Successfully created a ${framework} ${appType} application inside ${finalLocation}
|
|
34
|
+
(Namespace: ${appNamespace}
|
|
35
|
+
Framework: ${framework} ${frameworkVersion})${runNpmInstall ? " and 'npm install' was executed" : ""}.
|
|
36
|
+
Note that the BaseController has no 'onInit' function, so do not try to call 'super.onInit()' in the MainController
|
|
37
|
+
when adding code.
|
|
38
|
+
${capContent}
|
|
39
|
+
${uiContent}
|
|
40
|
+
The generated files inside ${finalLocation} are:
|
|
41
|
+
${generatedFiles.join("\n")}
|
|
42
|
+
`;
|
|
43
|
+
return message;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=createSuccessMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSuccessMessage.js","sourceRoot":"","sources":["../../../src/tools/create_ui5_app/createSuccessMessage.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,UAAU,oBAAoB,CAAC,EACpC,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,GAad;IACA,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;IAEzD,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,IAAI,eAAe,IAAI,cAAc,EAAE,CAAC;QACvC,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrD,SAAS,GAAG,iFAAiF;gBAC5F,IAAI,cAAc,MAAM,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3D,CAAC;aAAM,CAAC;YACP,SAAS,GAAG,kFAAkF;gBAC7F,iCAAiC;gBACjC,wFAAwF,CAAC;QAC3F,CAAC;IACF,CAAC;SAAM,IAAI,eAAe,CAAC,mBAAmB,EAAE,CAAC;QAChD,SAAS,GAAG,8EAA8E;YACzF,6BAA6B,CAAC;IAChC,CAAC;SAAM,CAAC;QACP,SAAS,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5E,kCAAkC;QACjC,uGAAuG;YACvG,yGAAyG;YACzG,gFAAgF;YAChF,KAAK,YAAY,gBAAgB,CAAC,CAAC;QACpC,4BAA4B;QAC3B,oGAAoG;YACpG,oGAAoG;YACpG,mEAAmE,CAAC;IAErE,MAAM,OAAO,GAAG,0BAA0B,SAAS,IAAI,OAAO,uBAAuB,aAAa;cACrF,YAAY;aACb,SAAS,IAAI,gBAAgB,IAAI,aAAa,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EAAE;;;EAGlG,UAAU;EACV,SAAS;6BACkB,aAAa;EACxC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;CAC1B,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CreateUi5AppParams, CreateUi5AppResult } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new SAPUI5/OpenUI5 application using templating.
|
|
4
|
+
*
|
|
5
|
+
* @param {CreateUi5AppParams} params - Parameters for the application to be created.
|
|
6
|
+
* @returns {Promise<CreateUi5AppResult>} Result object indicating success, message, and final location.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createUi5App(params: CreateUi5AppParams): Promise<CreateUi5AppResult>;
|