plugin-elastic-report 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/skills/elastic-report/SKILLS.md +32 -0
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.js +10 -0
- package/dist/client-v2/851.488fdbf5bc5b6a36.js +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/externalVersion.js +20 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +99 -0
- package/dist/locale/vi-VN.json +99 -0
- package/dist/locale/zh-CN.json +99 -0
- package/dist/node_modules/@elastic/elasticsearch/.dockerignore +11 -0
- package/dist/node_modules/@elastic/elasticsearch/LICENSE +202 -0
- package/dist/node_modules/@elastic/elasticsearch/NOTICE.txt +2 -0
- package/dist/node_modules/@elastic/elasticsearch/catalog-info.yaml +50 -0
- package/dist/node_modules/@elastic/elasticsearch/codecov.yml +14 -0
- package/dist/node_modules/@elastic/elasticsearch/index.d.ts +28 -0
- package/dist/node_modules/@elastic/elasticsearch/index.js +85525 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/async_search.d.ts +39 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/async_search.js +155 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/autoscaling.d.ts +39 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/autoscaling.js +130 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/bulk.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/bulk.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/capabilities.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/capabilities.js +43 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cat.d.ts +193 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cat.js +766 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ccr.d.ts +102 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ccr.js +395 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/clear_scroll.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/clear_scroll.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/close_point_in_time.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/close_point_in_time.js +56 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cluster.d.ts +123 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cluster.js +482 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/connector.d.ts +245 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/connector.js +1121 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/count.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/count.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/create.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/create.js +53 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/dangling_indices.d.ts +32 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/dangling_indices.js +100 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete.js +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query.js +59 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query_rethrottle.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query_rethrottle.js +45 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_script.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_script.js +45 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/enrich.d.ts +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/enrich.js +169 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/eql.d.ts +39 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/eql.js +139 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/esql.d.ts +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/esql.js +170 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists.js +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists_source.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists_source.js +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/explain.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/explain.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/features.d.ts +25 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/features.js +75 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/field_caps.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/field_caps.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/fleet.d.ts +50 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/fleet.js +211 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get.js +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script.js +45 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_context.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_context.js +43 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_languages.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_languages.js +43 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_source.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_source.js +46 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/graph.d.ts +18 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/graph.js +70 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/health_report.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/health_report.js +54 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ilm.d.ts +88 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ilm.js +329 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/index.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/index.js +61 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/indices.d.ts +494 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/indices.js +2133 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/inference.d.ts +221 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/inference.js +1167 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/info.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/info.js +43 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ingest.d.ts +95 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ingest.js +389 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/knn_search.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/knn_search.js +59 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/license.d.ts +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/license.js +194 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/logstash.d.ts +32 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/logstash.js +118 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mget.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mget.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/migration.d.ts +32 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/migration.js +107 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ml.d.ts +522 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ml.js +2468 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/monitoring.d.ts +18 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/monitoring.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch_template.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch_template.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mtermvectors.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mtermvectors.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/nodes.d.ts +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/nodes.js +290 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/open_point_in_time.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/open_point_in_time.js +59 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ping.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ping.js +43 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/profiling.d.ts +39 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/profiling.js +135 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/put_script.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/put_script.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/query_rules.d.ts +67 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/query_rules.js +260 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rank_eval.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rank_eval.js +67 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex.js +56 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex_rethrottle.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex_rethrottle.js +45 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/render_search_template.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/render_search_template.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rollup.d.ts +67 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rollup.js +263 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scripts_painless_execute.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scripts_painless_execute.js +57 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scroll.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scroll.js +59 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search.js +75 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_application.d.ts +81 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_application.js +313 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_mvt.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_mvt.js +63 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_shards.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_shards.js +54 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_template.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_template.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/searchable_snapshots.d.ts +39 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/searchable_snapshots.js +167 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/security.d.ts +459 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/security.js +1982 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/shutdown.d.ts +32 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/shutdown.js +125 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/simulate.d.ts +18 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/simulate.js +78 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/slm.d.ts +74 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/slm.js +253 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/snapshot.d.ts +102 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/snapshot.js +410 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/sql.d.ts +53 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/sql.js +205 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ssl.d.ts +18 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ssl.js +54 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/streams.d.ts +32 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/streams.js +96 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/synonyms.d.ts +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/synonyms.js +223 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/tasks.d.ts +32 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/tasks.js +109 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/terms_enum.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/terms_enum.js +59 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/termvectors.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/termvectors.js +68 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/text_structure.d.ts +39 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/text_structure.js +148 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/transform.d.ts +101 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/transform.js +386 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update.js +60 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query.js +59 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query_rethrottle.d.ts +14 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query_rethrottle.js +45 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/watcher.d.ts +102 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/watcher.js +405 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/xpack.d.ts +25 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/api/xpack.js +75 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/index.d.ts +265 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/index.js +632 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/types.d.ts +19933 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/types.js +21 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey.d.ts +20606 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey.js +21 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/client.d.ts +152 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/client.js +369 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/helpers.d.ts +184 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/helpers.js +889 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/sniffingTransport.d.ts +4 -0
- package/dist/node_modules/@elastic/elasticsearch/lib/sniffingTransport.js +56 -0
- package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv +15 -0
- package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv.cmd +7 -0
- package/dist/node_modules/@elastic/elasticsearch/package.json +1 -0
- package/dist/node_modules/@elastic/elasticsearch/tsconfig.json +38 -0
- package/dist/server/acl-guard.js +107 -0
- package/dist/server/collections/es-report-data-views.js +79 -0
- package/dist/server/collections/es-reports.js +95 -0
- package/dist/server/index.js +58 -0
- package/dist/server/mcp/ElasticReportMcpServer.js +344 -0
- package/dist/server/mcp/ElasticReportToolCatalog.js +417 -0
- package/dist/server/plugin.js +395 -0
- package/dist/server/services/ElasticReportService.js +263 -0
- package/dist/server/services/ElasticsearchConnectionService.js +332 -0
- package/dist/server/services/ReportQueryCompiler.js +858 -0
- package/dist/shared/constants.js +81 -0
- package/dist/shared/types.js +24 -0
- package/package.json +61 -4
- package/server.d.ts +2 -0
- package/server.js +1 -0
- package/src/client/index.tsx +19 -0
- package/src/client-v2/__tests__/elastic-report.test.tsx +311 -0
- package/src/client-v2/api.ts +224 -0
- package/src/client-v2/components/ElasticBasicCharts.tsx +399 -0
- package/src/client-v2/components/ElasticReportBlock.tsx +160 -0
- package/src/client-v2/components/ElasticReportRenderer.tsx +707 -0
- package/src/client-v2/components/HighlightText.tsx +50 -0
- package/src/client-v2/components/ReportSelect.tsx +72 -0
- package/src/client-v2/index.tsx +14 -0
- package/src/client-v2/locale.ts +23 -0
- package/src/client-v2/models/ElasticReportBlockModel.tsx +85 -0
- package/src/client-v2/pages/ElasticReportManager.tsx +1047 -0
- package/src/client-v2/plugin.tsx +52 -0
- package/src/index.ts +11 -0
- package/src/locale/en-US.json +99 -0
- package/src/locale/vi-VN.json +99 -0
- package/src/locale/zh-CN.json +99 -0
- package/src/server/__tests__/query-compiler.test.ts +231 -0
- package/src/server/__tests__/report-mcp-acl.integration.test.ts +377 -0
- package/src/server/acl-guard.ts +103 -0
- package/src/server/collections/es-report-data-views.ts +58 -0
- package/src/server/collections/es-reports.ts +74 -0
- package/src/server/index.ts +15 -0
- package/src/server/mcp/ElasticReportMcpServer.ts +391 -0
- package/src/server/mcp/ElasticReportToolCatalog.ts +417 -0
- package/src/server/plugin.ts +431 -0
- package/src/server/services/ElasticReportService.ts +326 -0
- package/src/server/services/ElasticsearchConnectionService.ts +401 -0
- package/src/server/services/ReportQueryCompiler.ts +1017 -0
- package/src/shared/constants.ts +29 -0
- package/src/shared/types.ts +175 -0
- package/README.md +0 -3
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var ElasticReportMcpServer_exports = {};
|
|
38
|
+
__export(ElasticReportMcpServer_exports, {
|
|
39
|
+
ElasticReportMcpServer: () => ElasticReportMcpServer
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(ElasticReportMcpServer_exports);
|
|
42
|
+
var import_constants = require("../../shared/constants");
|
|
43
|
+
let sdkModulesPromise = null;
|
|
44
|
+
function loadOptionalMcpSdk() {
|
|
45
|
+
if (!sdkModulesPromise) {
|
|
46
|
+
sdkModulesPromise = Promise.all([
|
|
47
|
+
import("@modelcontextprotocol/sdk/server/mcp.js"),
|
|
48
|
+
import("@modelcontextprotocol/sdk/server/streamableHttp.js"),
|
|
49
|
+
import("@modelcontextprotocol/sdk/types.js")
|
|
50
|
+
]).then(([mcpMod, httpMod, typesMod]) => ({
|
|
51
|
+
McpServer: mcpMod.McpServer,
|
|
52
|
+
StreamableHTTPServerTransport: httpMod.StreamableHTTPServerTransport,
|
|
53
|
+
CallToolRequestSchema: typesMod.CallToolRequestSchema,
|
|
54
|
+
ListToolsRequestSchema: typesMod.ListToolsRequestSchema
|
|
55
|
+
})).catch(() => null);
|
|
56
|
+
}
|
|
57
|
+
return sdkModulesPromise;
|
|
58
|
+
}
|
|
59
|
+
function isRecord(value) {
|
|
60
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61
|
+
}
|
|
62
|
+
function serializeToolResult(value) {
|
|
63
|
+
if (typeof value === "string") return value;
|
|
64
|
+
try {
|
|
65
|
+
return JSON.stringify(value, null, 2);
|
|
66
|
+
} catch {
|
|
67
|
+
return String(value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class ElasticReportMcpServer {
|
|
71
|
+
constructor(options) {
|
|
72
|
+
this.options = options;
|
|
73
|
+
this.toolMap = new Map(options.tools.map((tool) => [tool.name, tool]));
|
|
74
|
+
}
|
|
75
|
+
toolMap;
|
|
76
|
+
getToolsMetadata() {
|
|
77
|
+
return this.options.tools.map((tool) => ({
|
|
78
|
+
name: tool.name,
|
|
79
|
+
description: tool.description,
|
|
80
|
+
inputSchema: tool.inputSchema
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
async handleRequest(ctx) {
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
|
+
const method = (ctx.method || "POST").toUpperCase();
|
|
86
|
+
if (method === "GET") {
|
|
87
|
+
const accept2 = String(((_b = (_a = ctx.request) == null ? void 0 : _a.headers) == null ? void 0 : _b.accept) || "");
|
|
88
|
+
if (accept2.includes("text/event-stream")) {
|
|
89
|
+
ctx.withoutDataWrapping = true;
|
|
90
|
+
ctx.status = 405;
|
|
91
|
+
ctx.set("Allow", "POST");
|
|
92
|
+
ctx.body = {
|
|
93
|
+
jsonrpc: "2.0",
|
|
94
|
+
error: { code: -32e3, message: "Method not allowed: stateless Streamable HTTP MCP endpoint" },
|
|
95
|
+
id: null
|
|
96
|
+
};
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
ctx.withoutDataWrapping = true;
|
|
100
|
+
ctx.status = 200;
|
|
101
|
+
ctx.type = "application/json";
|
|
102
|
+
ctx.body = {
|
|
103
|
+
name: import_constants.MCP_SERVER_NAME,
|
|
104
|
+
version: this.options.version,
|
|
105
|
+
protocol: "mcp-streamable-http",
|
|
106
|
+
tools: this.getToolsMetadata()
|
|
107
|
+
};
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (method !== "POST") {
|
|
111
|
+
ctx.withoutDataWrapping = true;
|
|
112
|
+
ctx.status = 405;
|
|
113
|
+
ctx.set("Allow", "GET, POST");
|
|
114
|
+
ctx.body = {
|
|
115
|
+
jsonrpc: "2.0",
|
|
116
|
+
error: { code: -32e3, message: `Unsupported HTTP method: ${method}` },
|
|
117
|
+
id: null
|
|
118
|
+
};
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const accept = String(((_d = (_c = ctx.request) == null ? void 0 : _c.headers) == null ? void 0 : _d.accept) || "");
|
|
122
|
+
const prefersEventStream = accept.includes("text/event-stream") && accept.includes("application/json");
|
|
123
|
+
if (prefersEventStream) {
|
|
124
|
+
const sdk = await loadOptionalMcpSdk();
|
|
125
|
+
if (sdk && ctx.req && ctx.res && typeof ctx.res.writeHead === "function") {
|
|
126
|
+
await this.handleWithSdk(sdk, ctx);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
await this.handleStatelessJsonRpc(ctx);
|
|
131
|
+
}
|
|
132
|
+
async handleWithSdk(sdk, ctx) {
|
|
133
|
+
const server = new sdk.McpServer(
|
|
134
|
+
{ name: import_constants.MCP_SERVER_NAME, version: this.options.version },
|
|
135
|
+
{ capabilities: { tools: {} } }
|
|
136
|
+
);
|
|
137
|
+
server.server.setRequestHandler(sdk.ListToolsRequestSchema, async () => ({
|
|
138
|
+
tools: this.getToolsMetadata()
|
|
139
|
+
}));
|
|
140
|
+
server.server.setRequestHandler(sdk.CallToolRequestSchema, async (request) => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
const toolName = typeof ((_a = request.params) == null ? void 0 : _a.name) === "string" ? request.params.name : "";
|
|
143
|
+
const rawArgs = isRecord((_b = request.params) == null ? void 0 : _b.arguments) ? request.params.arguments : {};
|
|
144
|
+
const tool = this.toolMap.get(toolName);
|
|
145
|
+
if (!tool) {
|
|
146
|
+
return {
|
|
147
|
+
content: [{ type: "text", text: `Unknown tool: ${toolName}` }],
|
|
148
|
+
isError: true
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const output = await tool.execute(rawArgs, ctx);
|
|
153
|
+
return {
|
|
154
|
+
content: [{ type: "text", text: serializeToolResult(output) }],
|
|
155
|
+
isError: false
|
|
156
|
+
};
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return {
|
|
159
|
+
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
160
|
+
isError: true
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
const transport = new sdk.StreamableHTTPServerTransport({
|
|
165
|
+
sessionIdGenerator: void 0
|
|
166
|
+
});
|
|
167
|
+
transport.onerror = (err) => {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
(_b = (_a = this.options.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, "[plugin-elastic-report] MCP transport error:", err);
|
|
170
|
+
};
|
|
171
|
+
await server.connect(transport);
|
|
172
|
+
try {
|
|
173
|
+
await transport.handleRequest(ctx.req, ctx.res, ctx.request.body ?? {});
|
|
174
|
+
} finally {
|
|
175
|
+
await server.close();
|
|
176
|
+
}
|
|
177
|
+
ctx.respond = false;
|
|
178
|
+
}
|
|
179
|
+
async handleStatelessJsonRpc(ctx) {
|
|
180
|
+
var _a;
|
|
181
|
+
ctx.withoutDataWrapping = true;
|
|
182
|
+
ctx.type = "application/json";
|
|
183
|
+
const payload = (_a = ctx.request) == null ? void 0 : _a.body;
|
|
184
|
+
if (Array.isArray(payload)) {
|
|
185
|
+
if (payload.length === 0) {
|
|
186
|
+
ctx.status = 400;
|
|
187
|
+
ctx.body = {
|
|
188
|
+
jsonrpc: "2.0",
|
|
189
|
+
id: null,
|
|
190
|
+
error: { code: -32600, message: "Invalid Request: empty batch" }
|
|
191
|
+
};
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const responses = [];
|
|
195
|
+
for (const entry of payload) {
|
|
196
|
+
const res = await this.dispatchRpcMessage(entry, ctx);
|
|
197
|
+
if (res) responses.push(res);
|
|
198
|
+
}
|
|
199
|
+
if (responses.length === 0) {
|
|
200
|
+
ctx.status = 202;
|
|
201
|
+
ctx.body = "";
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
ctx.status = 200;
|
|
205
|
+
ctx.body = responses;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (!isRecord(payload)) {
|
|
209
|
+
ctx.status = 400;
|
|
210
|
+
ctx.body = {
|
|
211
|
+
jsonrpc: "2.0",
|
|
212
|
+
id: null,
|
|
213
|
+
error: { code: -32600, message: "Invalid JSON-RPC request payload" }
|
|
214
|
+
};
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const response = await this.dispatchRpcMessage(payload, ctx);
|
|
218
|
+
if (!response) {
|
|
219
|
+
ctx.status = 202;
|
|
220
|
+
ctx.body = "";
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
ctx.status = 200;
|
|
224
|
+
ctx.body = response;
|
|
225
|
+
}
|
|
226
|
+
async dispatchRpcMessage(raw, ctx) {
|
|
227
|
+
if (!isRecord(raw)) {
|
|
228
|
+
return {
|
|
229
|
+
jsonrpc: "2.0",
|
|
230
|
+
id: null,
|
|
231
|
+
error: { code: -32600, message: "Invalid Request" }
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const req = raw;
|
|
235
|
+
const hasId = Object.prototype.hasOwnProperty.call(raw, "id") && req.id !== void 0;
|
|
236
|
+
const id = typeof req.id === "string" || typeof req.id === "number" || req.id === null ? req.id : null;
|
|
237
|
+
const method = typeof req.method === "string" ? req.method : "";
|
|
238
|
+
if (!hasId && method.startsWith("notifications/")) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (!method) {
|
|
242
|
+
return {
|
|
243
|
+
jsonrpc: "2.0",
|
|
244
|
+
id,
|
|
245
|
+
error: { code: -32600, message: "Invalid Request: missing method" }
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
switch (method) {
|
|
249
|
+
case "initialize": {
|
|
250
|
+
const requestedProtocol = isRecord(req.params) && typeof req.params.protocolVersion === "string" ? req.params.protocolVersion : "2025-03-26";
|
|
251
|
+
return {
|
|
252
|
+
jsonrpc: "2.0",
|
|
253
|
+
id,
|
|
254
|
+
result: {
|
|
255
|
+
protocolVersion: requestedProtocol,
|
|
256
|
+
capabilities: {
|
|
257
|
+
tools: {}
|
|
258
|
+
},
|
|
259
|
+
serverInfo: {
|
|
260
|
+
name: import_constants.MCP_SERVER_NAME,
|
|
261
|
+
version: this.options.version
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
case "ping":
|
|
267
|
+
return {
|
|
268
|
+
jsonrpc: "2.0",
|
|
269
|
+
id,
|
|
270
|
+
result: {}
|
|
271
|
+
};
|
|
272
|
+
case "tools/list":
|
|
273
|
+
return {
|
|
274
|
+
jsonrpc: "2.0",
|
|
275
|
+
id,
|
|
276
|
+
result: {
|
|
277
|
+
tools: this.getToolsMetadata()
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
case "tools/call": {
|
|
281
|
+
const params = isRecord(req.params) ? req.params : {};
|
|
282
|
+
const toolName = typeof params.name === "string" ? params.name : "";
|
|
283
|
+
const toolArgs = isRecord(params.arguments) ? params.arguments : {};
|
|
284
|
+
const tool = this.toolMap.get(toolName);
|
|
285
|
+
if (!tool) {
|
|
286
|
+
return {
|
|
287
|
+
jsonrpc: "2.0",
|
|
288
|
+
id,
|
|
289
|
+
error: {
|
|
290
|
+
code: -32602,
|
|
291
|
+
message: `Unknown tool: ${toolName}`
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
const output = await tool.execute(toolArgs, ctx);
|
|
297
|
+
return {
|
|
298
|
+
jsonrpc: "2.0",
|
|
299
|
+
id,
|
|
300
|
+
result: {
|
|
301
|
+
content: [
|
|
302
|
+
{
|
|
303
|
+
type: "text",
|
|
304
|
+
text: serializeToolResult(output)
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
isError: false
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
} catch (error) {
|
|
311
|
+
const errStatus = error == null ? void 0 : error.status;
|
|
312
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
313
|
+
return {
|
|
314
|
+
jsonrpc: "2.0",
|
|
315
|
+
id,
|
|
316
|
+
result: {
|
|
317
|
+
content: [
|
|
318
|
+
{
|
|
319
|
+
type: "text",
|
|
320
|
+
text: errStatus ? `[${errStatus}] ${message}` : message
|
|
321
|
+
}
|
|
322
|
+
],
|
|
323
|
+
isError: true
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
default:
|
|
329
|
+
if (!hasId) return null;
|
|
330
|
+
return {
|
|
331
|
+
jsonrpc: "2.0",
|
|
332
|
+
id,
|
|
333
|
+
error: {
|
|
334
|
+
code: -32601,
|
|
335
|
+
message: `Method not found: ${method}`
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
342
|
+
0 && (module.exports = {
|
|
343
|
+
ElasticReportMcpServer
|
|
344
|
+
});
|