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,372 @@
|
|
|
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 { ClearOutlined, ClockCircleOutlined, FilterOutlined, ReloadOutlined, SearchOutlined } from '@ant-design/icons';
|
|
11
|
+
import { useApp } from '@nocobase/client-v2';
|
|
12
|
+
import { Button, Card, Input, Select, Space, Tag } from 'antd';
|
|
13
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import type { AutoRefreshInterval, EsFieldCapability, ID, ReportTimeRange, TimeRangePreset } from '../../shared/types';
|
|
15
|
+
import { fetchFieldTopValues, fetchPublishedReports, fetchReportMeta, type ApiClientLike } from '../api';
|
|
16
|
+
import {
|
|
17
|
+
clearDashboardScope,
|
|
18
|
+
patchDashboardScope,
|
|
19
|
+
removeDashboardFilterAt,
|
|
20
|
+
removeDashboardFilterByField,
|
|
21
|
+
triggerDashboardRefresh,
|
|
22
|
+
upsertDashboardFilter,
|
|
23
|
+
useDashboardScope,
|
|
24
|
+
} from '../bus/DashboardFilterBus';
|
|
25
|
+
import { useT } from '../locale';
|
|
26
|
+
import { ElasticKqlInput } from './ElasticKqlInput';
|
|
27
|
+
|
|
28
|
+
export interface ElasticFilterBarProps {
|
|
29
|
+
scopeKey: string;
|
|
30
|
+
referenceReportId?: ID;
|
|
31
|
+
filterFieldsCsv?: string;
|
|
32
|
+
showGlobalKql?: boolean;
|
|
33
|
+
showGlobalTimeRange?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const ElasticFilterBar: React.FC<ElasticFilterBarProps> = ({
|
|
37
|
+
scopeKey,
|
|
38
|
+
referenceReportId,
|
|
39
|
+
filterFieldsCsv = '',
|
|
40
|
+
showGlobalKql = true,
|
|
41
|
+
showGlobalTimeRange = true,
|
|
42
|
+
}) => {
|
|
43
|
+
const t = useT();
|
|
44
|
+
const app = useApp();
|
|
45
|
+
const apiRef = useRef<ApiClientLike>(app.apiClient as unknown as ApiClientLike);
|
|
46
|
+
apiRef.current = app.apiClient as unknown as ApiClientLike;
|
|
47
|
+
|
|
48
|
+
const shared = useDashboardScope(scopeKey);
|
|
49
|
+
const [draftKql, setDraftKql] = useState<string>(shared.query ?? '');
|
|
50
|
+
const [fieldOptionsMap, setFieldOptionsMap] = useState<Record<string, Array<{ label: string; value: string }>>>({});
|
|
51
|
+
const [kqlFields, setKqlFields] = useState<EsFieldCapability[]>([]);
|
|
52
|
+
const resolvedReportIdRef = useRef<ID | undefined>(referenceReportId);
|
|
53
|
+
const loadingMetaRef = useRef(false);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
resolvedReportIdRef.current = referenceReportId;
|
|
57
|
+
setKqlFields([]);
|
|
58
|
+
}, [referenceReportId]);
|
|
59
|
+
|
|
60
|
+
const ensureFilterBarMetaLoaded = useCallback(async () => {
|
|
61
|
+
if (kqlFields.length > 0 || loadingMetaRef.current) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
loadingMetaRef.current = true;
|
|
65
|
+
try {
|
|
66
|
+
let targetId = resolvedReportIdRef.current;
|
|
67
|
+
if (targetId === undefined || targetId === null || String(targetId).trim() === '') {
|
|
68
|
+
const published = await fetchPublishedReports(apiRef.current);
|
|
69
|
+
targetId = published[0]?.id;
|
|
70
|
+
resolvedReportIdRef.current = targetId;
|
|
71
|
+
}
|
|
72
|
+
if (targetId !== undefined && targetId !== null && String(targetId).trim() !== '') {
|
|
73
|
+
const meta = await fetchReportMeta(apiRef.current, targetId);
|
|
74
|
+
setKqlFields(meta?.fields ?? []);
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
// Non-fatal: KQL input still works without schema metadata
|
|
78
|
+
} finally {
|
|
79
|
+
loadingMetaRef.current = false;
|
|
80
|
+
}
|
|
81
|
+
}, [kqlFields.length]);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
setDraftKql(shared.query ?? '');
|
|
85
|
+
}, [shared.query]);
|
|
86
|
+
|
|
87
|
+
const filterFields = useMemo(
|
|
88
|
+
() =>
|
|
89
|
+
filterFieldsCsv
|
|
90
|
+
.split(',')
|
|
91
|
+
.map((s) => s.trim())
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.slice(0, 6),
|
|
94
|
+
[filterFieldsCsv],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (filterFields.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let cancelled = false;
|
|
102
|
+
const loadTopTerms = async () => {
|
|
103
|
+
let targetReportId: ID | undefined = referenceReportId;
|
|
104
|
+
if (targetReportId === undefined || targetReportId === null || String(targetReportId).trim() === '') {
|
|
105
|
+
try {
|
|
106
|
+
const published = await fetchPublishedReports(apiRef.current);
|
|
107
|
+
targetReportId = published[0]?.id;
|
|
108
|
+
} catch {
|
|
109
|
+
targetReportId = undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (targetReportId === undefined || targetReportId === null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const entries = await Promise.all(
|
|
116
|
+
filterFields.map(async (field) => {
|
|
117
|
+
try {
|
|
118
|
+
const top = await fetchFieldTopValues(apiRef.current, {
|
|
119
|
+
reportId: targetReportId,
|
|
120
|
+
field,
|
|
121
|
+
size: 15,
|
|
122
|
+
});
|
|
123
|
+
return [
|
|
124
|
+
field,
|
|
125
|
+
top.buckets.map((b) => ({
|
|
126
|
+
label: `${b.value} (${b.count})`,
|
|
127
|
+
value: b.value,
|
|
128
|
+
})),
|
|
129
|
+
] as const;
|
|
130
|
+
} catch {
|
|
131
|
+
return [field, []] as const;
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
if (!cancelled) {
|
|
136
|
+
setFieldOptionsMap(Object.fromEntries(entries));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
loadTopTerms();
|
|
140
|
+
return () => {
|
|
141
|
+
cancelled = true;
|
|
142
|
+
};
|
|
143
|
+
}, [filterFields, referenceReportId]);
|
|
144
|
+
|
|
145
|
+
// Global Auto-Refresh timer (pauses automatically when browser tab is hidden)
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const intervalSec = shared.autoRefreshSec ?? 0;
|
|
148
|
+
if (!intervalSec || intervalSec <= 0) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const timer = setInterval(() => {
|
|
152
|
+
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
triggerDashboardRefresh(scopeKey);
|
|
156
|
+
}, intervalSec * 1000);
|
|
157
|
+
return () => {
|
|
158
|
+
clearInterval(timer);
|
|
159
|
+
};
|
|
160
|
+
}, [scopeKey, shared.autoRefreshSec]);
|
|
161
|
+
|
|
162
|
+
const timeRangeOptions: Array<{ label: string; value: TimeRangePreset }> = useMemo(
|
|
163
|
+
() => [
|
|
164
|
+
{ label: t('Last 15 minutes'), value: 'last_15m' },
|
|
165
|
+
{ label: t('Last 1 hour'), value: 'last_1h' },
|
|
166
|
+
{ label: t('Last 24 hours'), value: 'last_24h' },
|
|
167
|
+
{ label: t('Last 7 days'), value: 'last_7d' },
|
|
168
|
+
{ label: t('Last 30 days'), value: 'last_30d' },
|
|
169
|
+
{ label: t('Last 90 days'), value: 'last_90d' },
|
|
170
|
+
{ label: t('All time'), value: 'all' },
|
|
171
|
+
{ label: t('Custom range'), value: 'custom' },
|
|
172
|
+
],
|
|
173
|
+
[t],
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const autoRefreshOptions: Array<{ label: string; value: AutoRefreshInterval }> = useMemo(
|
|
177
|
+
() => [
|
|
178
|
+
{ label: `${t('Auto refresh')}: ${t('Off')}`, value: 0 },
|
|
179
|
+
{ label: '10s', value: 10 },
|
|
180
|
+
{ label: '30s', value: 30 },
|
|
181
|
+
{ label: '1m', value: 60 },
|
|
182
|
+
{ label: '5m', value: 300 },
|
|
183
|
+
],
|
|
184
|
+
[t],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const activeTimeRange = shared.timeRange;
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<Card
|
|
191
|
+
size="small"
|
|
192
|
+
style={{ width: '100%', maxWidth: '100%', minWidth: 0, boxSizing: 'border-box', overflow: 'hidden' }}
|
|
193
|
+
>
|
|
194
|
+
<Space wrap style={{ width: '100%', maxWidth: '100%', justifyContent: 'space-between' }}>
|
|
195
|
+
<Space wrap style={{ maxWidth: '100%' }}>
|
|
196
|
+
{showGlobalKql && (
|
|
197
|
+
<ElasticKqlInput
|
|
198
|
+
ariaLabel={t('KQL / Search Query')}
|
|
199
|
+
placeholder={t('Search KQL, e.g. status >= 500 AND service: "api"')}
|
|
200
|
+
value={draftKql}
|
|
201
|
+
fields={kqlFields}
|
|
202
|
+
style={{ width: 280, maxWidth: '100%' }}
|
|
203
|
+
onFocusEnsureFields={ensureFilterBarMetaLoaded}
|
|
204
|
+
onInspectTopValues={async (field) => {
|
|
205
|
+
let targetId = resolvedReportIdRef.current;
|
|
206
|
+
if (targetId === undefined || targetId === null || String(targetId).trim() === '') {
|
|
207
|
+
const published = await fetchPublishedReports(apiRef.current);
|
|
208
|
+
targetId = published[0]?.id;
|
|
209
|
+
resolvedReportIdRef.current = targetId;
|
|
210
|
+
}
|
|
211
|
+
if (targetId === undefined || targetId === null) {
|
|
212
|
+
return { field, resolvedField: field, totalDocs: 0, buckets: [] };
|
|
213
|
+
}
|
|
214
|
+
return fetchFieldTopValues(apiRef.current, {
|
|
215
|
+
reportId: targetId,
|
|
216
|
+
field,
|
|
217
|
+
size: 12,
|
|
218
|
+
});
|
|
219
|
+
}}
|
|
220
|
+
onChange={(val) => {
|
|
221
|
+
setDraftKql(val);
|
|
222
|
+
}}
|
|
223
|
+
onClear={() => {
|
|
224
|
+
setDraftKql('');
|
|
225
|
+
patchDashboardScope(scopeKey, { query: '' });
|
|
226
|
+
}}
|
|
227
|
+
onSubmit={(submittedVal) => patchDashboardScope(scopeKey, { query: submittedVal })}
|
|
228
|
+
/>
|
|
229
|
+
)}
|
|
230
|
+
|
|
231
|
+
{showGlobalTimeRange && (
|
|
232
|
+
<>
|
|
233
|
+
<Select
|
|
234
|
+
allowClear
|
|
235
|
+
aria-label={t('Time Field')}
|
|
236
|
+
placeholder={t('Time Field')}
|
|
237
|
+
value={activeTimeRange?.preset}
|
|
238
|
+
options={timeRangeOptions}
|
|
239
|
+
style={{ minWidth: 155 }}
|
|
240
|
+
onChange={(nextPreset: TimeRangePreset | undefined) => {
|
|
241
|
+
if (!nextPreset) {
|
|
242
|
+
patchDashboardScope(scopeKey, { timeRange: undefined });
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const nextRange: ReportTimeRange =
|
|
246
|
+
nextPreset === 'custom'
|
|
247
|
+
? {
|
|
248
|
+
preset: 'custom',
|
|
249
|
+
from: activeTimeRange?.from ?? 'now-24h',
|
|
250
|
+
to: activeTimeRange?.to ?? 'now',
|
|
251
|
+
}
|
|
252
|
+
: { preset: nextPreset };
|
|
253
|
+
patchDashboardScope(scopeKey, { timeRange: nextRange });
|
|
254
|
+
}}
|
|
255
|
+
/>
|
|
256
|
+
{activeTimeRange?.preset === 'custom' && (
|
|
257
|
+
<Space.Compact>
|
|
258
|
+
<Input
|
|
259
|
+
aria-label={t('From')}
|
|
260
|
+
placeholder={t('From')}
|
|
261
|
+
value={activeTimeRange.from ?? ''}
|
|
262
|
+
style={{ width: 160 }}
|
|
263
|
+
onChange={(e) =>
|
|
264
|
+
patchDashboardScope(scopeKey, {
|
|
265
|
+
timeRange: { ...activeTimeRange, preset: 'custom', from: e.target.value },
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
/>
|
|
269
|
+
<Input
|
|
270
|
+
aria-label={t('To')}
|
|
271
|
+
placeholder={t('To')}
|
|
272
|
+
value={activeTimeRange.to ?? ''}
|
|
273
|
+
style={{ width: 160 }}
|
|
274
|
+
onChange={(e) =>
|
|
275
|
+
patchDashboardScope(scopeKey, {
|
|
276
|
+
timeRange: { ...activeTimeRange, preset: 'custom', to: e.target.value },
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
/>
|
|
280
|
+
</Space.Compact>
|
|
281
|
+
)}
|
|
282
|
+
</>
|
|
283
|
+
)}
|
|
284
|
+
|
|
285
|
+
{filterFields.map((field) => {
|
|
286
|
+
const current = shared.filters.find((f) => f.field === field && f.operator === 'eq');
|
|
287
|
+
const currentVal =
|
|
288
|
+
current?.value !== undefined && !Array.isArray(current.value) ? String(current.value) : undefined;
|
|
289
|
+
return (
|
|
290
|
+
<Select
|
|
291
|
+
key={field}
|
|
292
|
+
allowClear
|
|
293
|
+
showSearch
|
|
294
|
+
aria-label={`${t('Dashboard filter')}: ${field}`}
|
|
295
|
+
placeholder={field}
|
|
296
|
+
value={currentVal}
|
|
297
|
+
options={fieldOptionsMap[field] ?? []}
|
|
298
|
+
style={{ minWidth: 150 }}
|
|
299
|
+
onChange={(val: string | undefined) => {
|
|
300
|
+
if (!val) {
|
|
301
|
+
removeDashboardFilterByField(scopeKey, field);
|
|
302
|
+
} else {
|
|
303
|
+
upsertDashboardFilter(scopeKey, {
|
|
304
|
+
field,
|
|
305
|
+
operator: 'eq',
|
|
306
|
+
value: val,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}}
|
|
310
|
+
/>
|
|
311
|
+
);
|
|
312
|
+
})}
|
|
313
|
+
</Space>
|
|
314
|
+
|
|
315
|
+
<Space wrap>
|
|
316
|
+
<Select
|
|
317
|
+
aria-label={t('Auto refresh')}
|
|
318
|
+
suffixIcon={<ClockCircleOutlined />}
|
|
319
|
+
value={shared.autoRefreshSec ?? 0}
|
|
320
|
+
options={autoRefreshOptions}
|
|
321
|
+
style={{ minWidth: 145 }}
|
|
322
|
+
onChange={(sec: AutoRefreshInterval) => patchDashboardScope(scopeKey, { autoRefreshSec: sec })}
|
|
323
|
+
/>
|
|
324
|
+
{showGlobalKql && (
|
|
325
|
+
<Button
|
|
326
|
+
type="primary"
|
|
327
|
+
icon={<SearchOutlined aria-hidden="true" />}
|
|
328
|
+
onClick={() => patchDashboardScope(scopeKey, { query: draftKql })}
|
|
329
|
+
>
|
|
330
|
+
{t('Apply')}
|
|
331
|
+
</Button>
|
|
332
|
+
)}
|
|
333
|
+
<Button
|
|
334
|
+
icon={<ReloadOutlined aria-hidden="true" />}
|
|
335
|
+
aria-label={t('Refresh')}
|
|
336
|
+
onClick={() => triggerDashboardRefresh(scopeKey)}
|
|
337
|
+
/>
|
|
338
|
+
{(shared.filters.length > 0 || Boolean(shared.query) || Boolean(shared.timeRange)) && (
|
|
339
|
+
<Button
|
|
340
|
+
icon={<ClearOutlined aria-hidden="true" />}
|
|
341
|
+
onClick={() => {
|
|
342
|
+
setDraftKql('');
|
|
343
|
+
clearDashboardScope(scopeKey);
|
|
344
|
+
}}
|
|
345
|
+
>
|
|
346
|
+
{t('Clear dashboard filters')}
|
|
347
|
+
</Button>
|
|
348
|
+
)}
|
|
349
|
+
</Space>
|
|
350
|
+
</Space>
|
|
351
|
+
|
|
352
|
+
{shared.filters.length > 0 && (
|
|
353
|
+
<div style={{ marginTop: 8, display: 'flex', flexWrap: 'wrap', gap: 6 }}>
|
|
354
|
+
{shared.filters.map((flt, idx) => (
|
|
355
|
+
<Tag
|
|
356
|
+
key={flt.id || `shared-${flt.field}-${idx}`}
|
|
357
|
+
closable
|
|
358
|
+
icon={<FilterOutlined />}
|
|
359
|
+
color="cyan"
|
|
360
|
+
onClose={(e) => {
|
|
361
|
+
e.preventDefault();
|
|
362
|
+
removeDashboardFilterAt(scopeKey, idx);
|
|
363
|
+
}}
|
|
364
|
+
>
|
|
365
|
+
{flt.field} {flt.operator} {Array.isArray(flt.value) ? flt.value.join(', ') : String(flt.value ?? '')}
|
|
366
|
+
</Tag>
|
|
367
|
+
))}
|
|
368
|
+
</div>
|
|
369
|
+
)}
|
|
370
|
+
</Card>
|
|
371
|
+
);
|
|
372
|
+
};
|