plugin-elastic-report 0.0.0-stage → 0.7.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/ai/skills/elastic-report/SKILLS.md +34 -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/357.0dd385384cab5dbf.js +10 -0
- package/dist/client/index.js +10 -0
- package/dist/client-v2/851.142c93fc6d666b28.js +10 -0
- package/dist/client-v2/857.a5bf9637d5fd4ef5.js +10 -0
- package/dist/client-v2/877.f4095a3dbcadf98f.js +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/externalVersion.js +21 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +198 -0
- package/dist/locale/vi-VN.json +198 -0
- package/dist/locale/zh-CN.json +198 -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 +179 -0
- package/dist/server/collections/es-report-data-views.js +85 -0
- package/dist/server/collections/es-reports.js +101 -0
- package/dist/server/index.js +58 -0
- package/dist/server/mcp/ElasticReportMcpServer.js +344 -0
- package/dist/server/mcp/ElasticReportToolCatalog.js +639 -0
- package/dist/server/plugin.js +529 -0
- package/dist/server/services/ElasticReportService.js +377 -0
- package/dist/server/services/ElasticsearchConnectionService.js +572 -0
- package/dist/server/services/ReportExportService.js +243 -0
- package/dist/server/services/ReportQueryCompiler.js +1299 -0
- package/dist/server/workflow/ElasticReportQueryInstruction.js +123 -0
- package/dist/shared/constants.js +96 -0
- package/dist/shared/types.js +24 -0
- package/package.json +62 -4
- package/server.d.ts +2 -0
- package/server.js +1 -0
- package/src/client/index.tsx +34 -0
- package/src/client/workflow-instructions.tsx +44 -0
- package/src/client-v2/__tests__/elastic-report.test.tsx +791 -0
- package/src/client-v2/__tests__/kql-autocomplete.test.ts +178 -0
- package/src/client-v2/api.ts +320 -0
- package/src/client-v2/bus/DashboardFilterBus.ts +212 -0
- package/src/client-v2/components/ElasticBasicCharts.tsx +652 -0
- package/src/client-v2/components/ElasticFilterBar.tsx +372 -0
- package/src/client-v2/components/ElasticKqlInput.tsx +421 -0
- package/src/client-v2/components/ElasticReportBlock.tsx +306 -0
- package/src/client-v2/components/ElasticReportRenderer.tsx +1257 -0
- package/src/client-v2/components/HighlightText.tsx +50 -0
- package/src/client-v2/components/ReportSelect.tsx +85 -0
- package/src/client-v2/index.tsx +14 -0
- package/src/client-v2/locale.ts +23 -0
- package/src/client-v2/models/ElasticFilterBarBlockModel.tsx +115 -0
- package/src/client-v2/models/ElasticReportBlockModel.tsx +118 -0
- package/src/client-v2/pages/ElasticReportManager.tsx +1453 -0
- package/src/client-v2/plugin.tsx +72 -0
- package/src/client-v2/utils/kqlAutocomplete.ts +861 -0
- package/src/client-v2/workflow/instructions.tsx +149 -0
- package/src/index.ts +11 -0
- package/src/locale/en-US.json +198 -0
- package/src/locale/vi-VN.json +198 -0
- package/src/locale/zh-CN.json +198 -0
- package/src/server/__tests__/query-compiler.test.ts +620 -0
- package/src/server/__tests__/report-mcp-acl.integration.test.ts +645 -0
- package/src/server/acl-guard.ts +194 -0
- package/src/server/collections/es-report-data-views.ts +64 -0
- package/src/server/collections/es-reports.ts +80 -0
- package/src/server/index.ts +15 -0
- package/src/server/mcp/ElasticReportMcpServer.ts +391 -0
- package/src/server/mcp/ElasticReportToolCatalog.ts +663 -0
- package/src/server/plugin.ts +599 -0
- package/src/server/services/ElasticReportService.ts +486 -0
- package/src/server/services/ElasticsearchConnectionService.ts +728 -0
- package/src/server/services/ReportExportService.ts +282 -0
- package/src/server/services/ReportQueryCompiler.ts +1552 -0
- package/src/server/workflow/ElasticReportQueryInstruction.ts +124 -0
- package/src/shared/constants.ts +36 -0
- package/src/shared/types.ts +272 -0
- package/README.md +0 -3
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
import type { Context } from '@nocobase/actions';
|
|
11
|
+
import type { Application } from '@nocobase/server';
|
|
12
|
+
import { REPORTS_COLLECTION, SERVICE_RESOURCE } from '../shared/constants';
|
|
13
|
+
import type { EsDataViewRecord, EsReportRecord } from '../shared/types';
|
|
14
|
+
import { extractCurrentUserId } from './services/ElasticReportService';
|
|
15
|
+
|
|
16
|
+
export function normalizeRoleList(raw: unknown): string[] {
|
|
17
|
+
if (!Array.isArray(raw)) return [];
|
|
18
|
+
const seen = new Set<string>();
|
|
19
|
+
for (const item of raw) {
|
|
20
|
+
if (typeof item === 'string' && item.trim()) {
|
|
21
|
+
seen.add(item.trim());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return Array.from(seen);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Return ONLY the authenticated effective role(s) validated by NocoBase's auth/ACL
|
|
29
|
+
* middleware (`ctx.state.currentRole` / `ctx.state.currentRoles`).
|
|
30
|
+
* Never merge `currentUser.roles` or unvalidated `x-role` headers, so role-scoped
|
|
31
|
+
* requests and API keys cannot escalate to dormant roles on the same user account.
|
|
32
|
+
*/
|
|
33
|
+
export function getEffectiveRoles(ctx?: Partial<Context>): string[] {
|
|
34
|
+
const roles = new Set<string>();
|
|
35
|
+
const state = ctx?.state as
|
|
36
|
+
| {
|
|
37
|
+
currentRole?: unknown;
|
|
38
|
+
currentRoles?: unknown;
|
|
39
|
+
}
|
|
40
|
+
| undefined;
|
|
41
|
+
|
|
42
|
+
if (typeof state?.currentRole === 'string' && state.currentRole.trim()) {
|
|
43
|
+
roles.add(state.currentRole.trim());
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(state?.currentRoles)) {
|
|
46
|
+
for (const r of state.currentRoles) {
|
|
47
|
+
if (typeof r === 'string' && r.trim()) {
|
|
48
|
+
roles.add(r.trim());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return Array.from(roles);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function assertAuthenticated(ctx?: Partial<Context>): void {
|
|
56
|
+
const userId = extractCurrentUserId(ctx);
|
|
57
|
+
if (userId === undefined || userId === null || String(userId).trim() === '') {
|
|
58
|
+
const err = new Error('Authentication required') as Error & { status?: number };
|
|
59
|
+
err.status = 401;
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function canManageReports(app: Application, ctx?: Partial<Context>): boolean {
|
|
65
|
+
const userId = extractCurrentUserId(ctx);
|
|
66
|
+
if (userId === undefined || userId === null || String(userId).trim() === '') {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const roles = getEffectiveRoles(ctx);
|
|
71
|
+
if (roles.includes('root') || roles.includes('admin')) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const aclLike = app.acl as unknown as {
|
|
76
|
+
can?: (opts: { role: string; resource: string; action: string }) => unknown;
|
|
77
|
+
};
|
|
78
|
+
if (typeof aclLike?.can !== 'function') {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (roles.length === 0) {
|
|
83
|
+
return Boolean(aclLike.can({ role: 'member', resource: SERVICE_RESOURCE, action: 'saveReport' }));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return roles.some(
|
|
87
|
+
(role) =>
|
|
88
|
+
Boolean(aclLike.can({ role, resource: SERVICE_RESOURCE, action: 'saveReport' })) ||
|
|
89
|
+
Boolean(aclLike.can({ role, resource: REPORTS_COLLECTION, action: 'create' })),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function assertCanManageReports(app: Application, ctx?: Partial<Context>): void {
|
|
94
|
+
assertAuthenticated(ctx);
|
|
95
|
+
if (!canManageReports(app, ctx)) {
|
|
96
|
+
const err = new Error('Permission denied: Elastic Report management access is required') as Error & {
|
|
97
|
+
status?: number;
|
|
98
|
+
};
|
|
99
|
+
err.status = 403;
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function matchesAllowedRoles(effectiveRoles: string[], allowedRoles?: string[] | null): boolean {
|
|
105
|
+
const normalized = normalizeRoleList(allowedRoles);
|
|
106
|
+
if (normalized.length === 0) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (effectiveRoles.length === 0) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return effectiveRoles.some((role) => normalized.includes(role));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function canAccessDataView(
|
|
116
|
+
app: Application,
|
|
117
|
+
ctx: Partial<Context> | undefined,
|
|
118
|
+
dataView: Pick<EsDataViewRecord, 'allowedRoles'>,
|
|
119
|
+
): boolean {
|
|
120
|
+
const userId = extractCurrentUserId(ctx);
|
|
121
|
+
if (userId === undefined || userId === null || String(userId).trim() === '') {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (canManageReports(app, ctx)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return matchesAllowedRoles(getEffectiveRoles(ctx), dataView.allowedRoles);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function assertCanAccessDataView(
|
|
131
|
+
app: Application,
|
|
132
|
+
ctx: Partial<Context> | undefined,
|
|
133
|
+
dataView: Pick<EsDataViewRecord, 'allowedRoles'>,
|
|
134
|
+
): void {
|
|
135
|
+
assertAuthenticated(ctx);
|
|
136
|
+
if (!canAccessDataView(app, ctx, dataView)) {
|
|
137
|
+
const err = new Error('Permission denied: current role does not have access to this Data View') as Error & {
|
|
138
|
+
status?: number;
|
|
139
|
+
};
|
|
140
|
+
err.status = 403;
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function canAccessReport(
|
|
146
|
+
app: Application,
|
|
147
|
+
ctx: Partial<Context> | undefined,
|
|
148
|
+
report: Pick<EsReportRecord, 'published' | 'allowedRoles' | 'dataView'>,
|
|
149
|
+
dataView?: Pick<EsDataViewRecord, 'allowedRoles'> | null,
|
|
150
|
+
): boolean {
|
|
151
|
+
const userId = extractCurrentUserId(ctx);
|
|
152
|
+
if (userId === undefined || userId === null || String(userId).trim() === '') {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
if (canManageReports(app, ctx)) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (!report.published) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
const effectiveRoles = getEffectiveRoles(ctx);
|
|
162
|
+
if (!matchesAllowedRoles(effectiveRoles, report.allowedRoles)) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
const targetDv = dataView ?? report.dataView;
|
|
166
|
+
if (targetDv && !matchesAllowedRoles(effectiveRoles, targetDv.allowedRoles)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function assertCanAccessReport(
|
|
173
|
+
app: Application,
|
|
174
|
+
ctx: Partial<Context> | undefined,
|
|
175
|
+
report: Pick<EsReportRecord, 'published' | 'allowedRoles' | 'dataView'>,
|
|
176
|
+
dataView?: Pick<EsDataViewRecord, 'allowedRoles'> | null,
|
|
177
|
+
): void {
|
|
178
|
+
assertAuthenticated(ctx);
|
|
179
|
+
if (canManageReports(app, ctx)) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!report.published) {
|
|
183
|
+
const notFound = new Error('Report not found') as Error & { status?: number };
|
|
184
|
+
notFound.status = 404;
|
|
185
|
+
throw notFound;
|
|
186
|
+
}
|
|
187
|
+
if (!canAccessReport(app, ctx, report, dataView)) {
|
|
188
|
+
const err = new Error('Permission denied: current role does not have access to this report') as Error & {
|
|
189
|
+
status?: number;
|
|
190
|
+
};
|
|
191
|
+
err.status = 403;
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
import { defineCollection } from '@nocobase/database';
|
|
11
|
+
import { DATA_VIEWS_COLLECTION } from '../../shared/constants';
|
|
12
|
+
|
|
13
|
+
export default defineCollection({
|
|
14
|
+
name: DATA_VIEWS_COLLECTION,
|
|
15
|
+
title: 'Elasticsearch Report Data Views',
|
|
16
|
+
filterTargetKey: 'id',
|
|
17
|
+
autoGenId: true,
|
|
18
|
+
timestamps: true,
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
type: 'string',
|
|
22
|
+
name: 'title',
|
|
23
|
+
allowNull: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'string',
|
|
27
|
+
name: 'dataSourceKey',
|
|
28
|
+
allowNull: false,
|
|
29
|
+
index: true,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'string',
|
|
33
|
+
name: 'indexPattern',
|
|
34
|
+
allowNull: false,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'string',
|
|
38
|
+
name: 'timeField',
|
|
39
|
+
allowNull: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
name: 'description',
|
|
44
|
+
allowNull: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'json',
|
|
48
|
+
name: 'cachedFields',
|
|
49
|
+
allowNull: true,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: 'json',
|
|
53
|
+
name: 'allowedRoles',
|
|
54
|
+
allowNull: true,
|
|
55
|
+
defaultValue: [],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'context',
|
|
59
|
+
name: 'createdById',
|
|
60
|
+
dataIndex: 'state.currentUser.id',
|
|
61
|
+
createOnly: true,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
import { defineCollection } from '@nocobase/database';
|
|
11
|
+
import { DATA_VIEWS_COLLECTION, REPORTS_COLLECTION } from '../../shared/constants';
|
|
12
|
+
|
|
13
|
+
export default defineCollection({
|
|
14
|
+
name: REPORTS_COLLECTION,
|
|
15
|
+
title: 'Elasticsearch Reports',
|
|
16
|
+
filterTargetKey: 'id',
|
|
17
|
+
autoGenId: true,
|
|
18
|
+
timestamps: true,
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
type: 'string',
|
|
22
|
+
name: 'title',
|
|
23
|
+
allowNull: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'text',
|
|
27
|
+
name: 'description',
|
|
28
|
+
allowNull: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'bigInt',
|
|
32
|
+
name: 'dataViewId',
|
|
33
|
+
allowNull: false,
|
|
34
|
+
index: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'belongsTo',
|
|
38
|
+
name: 'dataView',
|
|
39
|
+
target: DATA_VIEWS_COLLECTION,
|
|
40
|
+
foreignKey: 'dataViewId',
|
|
41
|
+
targetKey: 'id',
|
|
42
|
+
constraints: false,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'string',
|
|
46
|
+
name: 'visualization',
|
|
47
|
+
allowNull: false,
|
|
48
|
+
defaultValue: 'table',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'json',
|
|
52
|
+
name: 'spec',
|
|
53
|
+
allowNull: false,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
name: 'published',
|
|
58
|
+
allowNull: false,
|
|
59
|
+
defaultValue: true,
|
|
60
|
+
index: true,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'json',
|
|
64
|
+
name: 'allowedRoles',
|
|
65
|
+
allowNull: true,
|
|
66
|
+
defaultValue: [],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'context',
|
|
70
|
+
name: 'createdById',
|
|
71
|
+
dataIndex: 'state.currentUser.id',
|
|
72
|
+
createOnly: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: 'context',
|
|
76
|
+
name: 'updatedById',
|
|
77
|
+
dataIndex: 'state.currentUser.id',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export { PluginElasticReportServer, default } from './plugin';
|
|
11
|
+
export * from './services/ReportQueryCompiler';
|
|
12
|
+
export * from './services/ElasticsearchConnectionService';
|
|
13
|
+
export * from './services/ElasticReportService';
|
|
14
|
+
export * from './mcp/ElasticReportMcpServer';
|
|
15
|
+
export * from './mcp/ElasticReportToolCatalog';
|