plugin-elastic-report 0.1.1 → 0.9.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.
Files changed (80) hide show
  1. package/client-v2.d.ts +2 -2
  2. package/client-v2.js +1 -1
  3. package/client.d.ts +2 -2
  4. package/client.js +1 -1
  5. package/dist/ai/skills/elastic-report/SKILLS.md +52 -0
  6. package/dist/client/357.0dd385384cab5dbf.js +10 -0
  7. package/dist/client/index.js +1 -1
  8. package/dist/client-v2/851.35e416bfb3fb565f.js +10 -0
  9. package/dist/client-v2/857.a5bf9637d5fd4ef5.js +10 -0
  10. package/dist/client-v2/877.81b10beb7b7f4bd7.js +10 -0
  11. package/dist/client-v2/index.js +1 -1
  12. package/dist/externalVersion.js +5 -3
  13. package/dist/locale/en-US.json +213 -99
  14. package/dist/locale/vi-VN.json +213 -99
  15. package/dist/locale/zh-CN.json +213 -99
  16. package/dist/node_modules/@elastic/elasticsearch/package.json +1 -1
  17. package/dist/server/acl-guard.js +97 -25
  18. package/dist/server/collections/es-report-data-views.js +6 -0
  19. package/dist/server/collections/es-reports.js +6 -0
  20. package/dist/server/mcp/ElasticReportToolCatalog.js +238 -14
  21. package/dist/server/plugin.js +156 -22
  22. package/dist/server/report-block-tools.js +340 -0
  23. package/dist/server/services/ElasticReportService.js +137 -17
  24. package/dist/server/services/ElasticsearchConnectionService.js +274 -34
  25. package/dist/server/services/ReportExportService.js +243 -0
  26. package/dist/server/services/ReportQueryCompiler.js +532 -91
  27. package/dist/server/workflow/ElasticReportQueryInstruction.js +123 -0
  28. package/dist/shared/constants.js +26 -2
  29. package/package.json +3 -3
  30. package/server.d.ts +2 -2
  31. package/server.js +1 -1
  32. package/src/ai/skills/elastic-report/SKILLS.md +52 -0
  33. package/src/client/index.tsx +34 -19
  34. package/src/client/workflow-instructions.tsx +44 -0
  35. package/src/client-v2/__tests__/elastic-report.test.tsx +879 -311
  36. package/src/client-v2/__tests__/kql-autocomplete.test.ts +178 -0
  37. package/src/client-v2/api.ts +320 -224
  38. package/src/client-v2/bus/DashboardFilterBus.ts +212 -0
  39. package/src/client-v2/components/ElasticBasicCharts.tsx +652 -399
  40. package/src/client-v2/components/ElasticFilterBar.tsx +372 -0
  41. package/src/client-v2/components/ElasticKqlInput.tsx +421 -0
  42. package/src/client-v2/components/ElasticReportBlock.tsx +306 -160
  43. package/src/client-v2/components/ElasticReportRenderer.tsx +1257 -707
  44. package/src/client-v2/components/HighlightText.tsx +50 -50
  45. package/src/client-v2/components/ReportSelect.tsx +85 -72
  46. package/src/client-v2/index.tsx +14 -14
  47. package/src/client-v2/locale.ts +23 -23
  48. package/src/client-v2/models/ElasticFilterBarBlockModel.tsx +115 -0
  49. package/src/client-v2/models/ElasticReportBlockModel.tsx +118 -85
  50. package/src/client-v2/pages/ElasticReportManager.tsx +1453 -1047
  51. package/src/client-v2/plugin.tsx +107 -52
  52. package/src/client-v2/report-destination.tsx +126 -0
  53. package/src/client-v2/utils/kqlAutocomplete.ts +861 -0
  54. package/src/client-v2/workflow/instructions.tsx +149 -0
  55. package/src/index.ts +11 -11
  56. package/src/locale/en-US.json +213 -99
  57. package/src/locale/vi-VN.json +213 -99
  58. package/src/locale/zh-CN.json +213 -99
  59. package/src/server/__tests__/ai-blocks.integration.test.ts +292 -0
  60. package/src/server/__tests__/query-compiler.test.ts +620 -231
  61. package/src/server/__tests__/report-mcp-acl.integration.test.ts +645 -377
  62. package/src/server/acl-guard.ts +194 -103
  63. package/src/server/collections/es-report-data-views.ts +64 -58
  64. package/src/server/collections/es-reports.ts +80 -74
  65. package/src/server/index.ts +15 -15
  66. package/src/server/mcp/ElasticReportMcpServer.ts +391 -391
  67. package/src/server/mcp/ElasticReportToolCatalog.ts +667 -417
  68. package/src/server/plugin.ts +599 -431
  69. package/src/server/report-block-tools.ts +400 -0
  70. package/src/server/services/ElasticReportService.ts +494 -326
  71. package/src/server/services/ElasticsearchConnectionService.ts +728 -401
  72. package/src/server/services/ReportExportService.ts +282 -0
  73. package/src/server/services/ReportQueryCompiler.ts +1552 -1017
  74. package/src/server/workflow/ElasticReportQueryInstruction.ts +124 -0
  75. package/src/shared/constants.ts +39 -29
  76. package/src/shared/types.ts +272 -175
  77. package/ai/skills/elastic-report/SKILLS.md +0 -32
  78. package/dist/client-v2/851.488fdbf5bc5b6a36.js +0 -10
  79. package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv +0 -15
  80. package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv.cmd +0 -7
@@ -0,0 +1,123 @@
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 __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var ElasticReportQueryInstruction_exports = {};
28
+ __export(ElasticReportQueryInstruction_exports, {
29
+ ElasticReportQueryInstruction: () => ElasticReportQueryInstruction,
30
+ evaluateThreshold: () => evaluateThreshold
31
+ });
32
+ module.exports = __toCommonJS(ElasticReportQueryInstruction_exports);
33
+ var import_plugin_workflow = require("@nocobase/plugin-workflow");
34
+ function evaluateThreshold(actual, operator, threshold) {
35
+ if (actual === null || actual === void 0 || !Number.isFinite(actual)) return false;
36
+ if (!operator || threshold === void 0 || !Number.isFinite(threshold)) return false;
37
+ switch (operator) {
38
+ case "gt":
39
+ return actual > threshold;
40
+ case "gte":
41
+ return actual >= threshold;
42
+ case "lt":
43
+ return actual < threshold;
44
+ case "lte":
45
+ return actual <= threshold;
46
+ case "eq":
47
+ return actual === threshold;
48
+ case "ne":
49
+ return actual !== threshold;
50
+ default:
51
+ return false;
52
+ }
53
+ }
54
+ class ElasticReportQueryInstruction extends import_plugin_workflow.Instruction {
55
+ constructor(workflow, reportService) {
56
+ super(workflow);
57
+ this.reportService = reportService;
58
+ }
59
+ async run(node, _input, processor) {
60
+ const rawConfig = node.config ?? {};
61
+ const parsedConfig = processor.getParsedValue(rawConfig, node.id);
62
+ const reportId = parsedConfig == null ? void 0 : parsedConfig.reportId;
63
+ if (reportId === void 0 || reportId === null || String(reportId).trim() === "") {
64
+ return {
65
+ status: import_plugin_workflow.JOB_STATUS.ERROR,
66
+ result: {
67
+ error: "reportId is required in Elastic Report workflow node configuration"
68
+ }
69
+ };
70
+ }
71
+ try {
72
+ const overrides = {};
73
+ if (typeof parsedConfig.queryOverride === "string" && parsedConfig.queryOverride.trim()) {
74
+ overrides.query = parsedConfig.queryOverride.trim();
75
+ }
76
+ if (typeof parsedConfig.timePreset === "string" && parsedConfig.timePreset.trim()) {
77
+ overrides.timeRange = { preset: parsedConfig.timePreset };
78
+ }
79
+ const { report, result } = await this.reportService.runSavedReport({
80
+ reportId,
81
+ overrides: Object.keys(overrides).length > 0 ? overrides : void 0,
82
+ requirePublished: false,
83
+ forMcp: true
84
+ });
85
+ const targetField = parsedConfig.thresholdField ?? "total";
86
+ const comparedValue = targetField === "metricValue" ? result.metricValue ?? result.total : targetField === "deltaPercent" ? result.deltaPercent ?? null : result.total;
87
+ const breached = evaluateThreshold(
88
+ comparedValue,
89
+ parsedConfig.thresholdOperator,
90
+ typeof parsedConfig.thresholdValue === "number" ? parsedConfig.thresholdValue : parsedConfig.thresholdValue !== void 0 ? Number(parsedConfig.thresholdValue) : void 0
91
+ );
92
+ return {
93
+ status: import_plugin_workflow.JOB_STATUS.RESOLVED,
94
+ result: {
95
+ reportId: report.id,
96
+ title: report.title,
97
+ visualization: report.visualization,
98
+ total: result.total,
99
+ totalRelation: result.totalRelation,
100
+ metricValue: result.metricValue ?? result.total,
101
+ previousMetricValue: result.previousMetricValue ?? null,
102
+ deltaPercent: result.deltaPercent ?? null,
103
+ breached,
104
+ topBuckets: result.series.slice(0, 10),
105
+ sampleRows: result.rows.slice(0, 10).map((r) => r.source),
106
+ executedAt: (/* @__PURE__ */ new Date()).toISOString()
107
+ }
108
+ };
109
+ } catch (error) {
110
+ return {
111
+ status: import_plugin_workflow.JOB_STATUS.ERROR,
112
+ result: {
113
+ error: error instanceof Error ? error.message : String(error)
114
+ }
115
+ };
116
+ }
117
+ }
118
+ }
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ ElasticReportQueryInstruction,
122
+ evaluateThreshold
123
+ });
@@ -27,12 +27,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
27
  var constants_exports = {};
28
28
  __export(constants_exports, {
29
29
  ACL_SNIPPET: () => ACL_SNIPPET,
30
+ BLOCK_ADDED_EVENT: () => BLOCK_ADDED_EVENT,
31
+ BLOCK_SETTINGS_EVENT: () => BLOCK_SETTINGS_EVENT,
30
32
  DATA_VIEWS_COLLECTION: () => DATA_VIEWS_COLLECTION,
33
+ DEFAULT_MAX_EXPORT_ROWS: () => DEFAULT_MAX_EXPORT_ROWS,
31
34
  DEFAULT_PAGE_SIZE: () => DEFAULT_PAGE_SIZE,
35
+ EXPORT_BATCH_SIZE: () => EXPORT_BATCH_SIZE,
32
36
  HIGHLIGHT_POST_TAG: () => HIGHLIGHT_POST_TAG,
33
37
  HIGHLIGHT_PRE_TAG: () => HIGHLIGHT_PRE_TAG,
34
38
  MAX_MCP_PREVIEW_SIZE: () => MAX_MCP_PREVIEW_SIZE,
35
39
  MAX_RESULT_WINDOW: () => MAX_RESULT_WINDOW,
40
+ MAX_SPLIT_SERIES: () => MAX_SPLIT_SERIES,
36
41
  MAX_TERMS_BUCKETS: () => MAX_TERMS_BUCKETS,
37
42
  MAX_UI_PAGE_SIZE: () => MAX_UI_PAGE_SIZE,
38
43
  MCP_RELATIVE_PATH: () => MCP_RELATIVE_PATH,
@@ -40,12 +45,18 @@ __export(constants_exports, {
40
45
  MCP_SERVER_NAME: () => MCP_SERVER_NAME,
41
46
  PLUGIN_NAME: () => PLUGIN_NAME,
42
47
  REPORTS_COLLECTION: () => REPORTS_COLLECTION,
48
+ REPORT_DESTINATION_CONTEXT: () => REPORT_DESTINATION_CONTEXT,
43
49
  SERVICE_RESOURCE: () => SERVICE_RESOURCE,
44
- SETTINGS_MENU_KEY: () => SETTINGS_MENU_KEY
50
+ SETTINGS_MENU_KEY: () => SETTINGS_MENU_KEY,
51
+ WORKFLOW_GROUP_KEY: () => WORKFLOW_GROUP_KEY,
52
+ WORKFLOW_INSTRUCTION_TYPE: () => WORKFLOW_INSTRUCTION_TYPE
45
53
  });
46
54
  module.exports = __toCommonJS(constants_exports);
47
55
  const PLUGIN_NAME = "plugin-elastic-report";
48
56
  const SETTINGS_MENU_KEY = "elastic-report";
57
+ const BLOCK_SETTINGS_EVENT = "elastic-report:block-settings";
58
+ const BLOCK_ADDED_EVENT = "elastic-report:block-added";
59
+ const REPORT_DESTINATION_CONTEXT = "elastic-report-destination";
49
60
  const ACL_SNIPPET = "pm.elastic-report";
50
61
  const DATA_VIEWS_COLLECTION = "esReportDataViews";
51
62
  const REPORTS_COLLECTION = "esReports";
@@ -60,15 +71,25 @@ const MAX_UI_PAGE_SIZE = 200;
60
71
  const MAX_MCP_PREVIEW_SIZE = 20;
61
72
  const MAX_RESULT_WINDOW = 1e4;
62
73
  const MAX_TERMS_BUCKETS = 50;
74
+ const MAX_SPLIT_SERIES = 10;
75
+ const DEFAULT_MAX_EXPORT_ROWS = 5e4;
76
+ const EXPORT_BATCH_SIZE = 500;
77
+ const WORKFLOW_GROUP_KEY = "elastic-report";
78
+ const WORKFLOW_INSTRUCTION_TYPE = "elastic-report-query";
63
79
  // Annotate the CommonJS export names for ESM import in node:
64
80
  0 && (module.exports = {
65
81
  ACL_SNIPPET,
82
+ BLOCK_ADDED_EVENT,
83
+ BLOCK_SETTINGS_EVENT,
66
84
  DATA_VIEWS_COLLECTION,
85
+ DEFAULT_MAX_EXPORT_ROWS,
67
86
  DEFAULT_PAGE_SIZE,
87
+ EXPORT_BATCH_SIZE,
68
88
  HIGHLIGHT_POST_TAG,
69
89
  HIGHLIGHT_PRE_TAG,
70
90
  MAX_MCP_PREVIEW_SIZE,
71
91
  MAX_RESULT_WINDOW,
92
+ MAX_SPLIT_SERIES,
72
93
  MAX_TERMS_BUCKETS,
73
94
  MAX_UI_PAGE_SIZE,
74
95
  MCP_RELATIVE_PATH,
@@ -76,6 +97,9 @@ const MAX_TERMS_BUCKETS = 50;
76
97
  MCP_SERVER_NAME,
77
98
  PLUGIN_NAME,
78
99
  REPORTS_COLLECTION,
100
+ REPORT_DESTINATION_CONTEXT,
79
101
  SERVICE_RESOURCE,
80
- SETTINGS_MENU_KEY
102
+ SETTINGS_MENU_KEY,
103
+ WORKFLOW_GROUP_KEY,
104
+ WORKFLOW_INSTRUCTION_TYPE
81
105
  });
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Kibana-style Elasticsearch Discover & Visualization reports with reusable blocks and a dedicated MCP server for AI Employees.",
7
7
  "description.vi-VN": "Tạo báo cáo bảng và biểu đồ từ dữ liệu Elasticsearch theo phong cách Kibana, gắn dưới dạng Block và cung cấp MCP riêng cho AI Employee.",
8
8
  "description.zh-CN": "连接 Elasticsearch 构建类 Kibana 的检索、筛选、排序与基础图表报表区块,并提供专属 MCP 服务供 AI 员工调用。",
9
- "version": "0.1.1",
9
+ "version": "0.9.0",
10
10
  "license": "Apache-2.0",
11
11
  "main": "dist/server/index.js",
12
12
  "keywords": [
@@ -20,7 +20,6 @@
20
20
  ],
21
21
  "files": [
22
22
  "dist",
23
- "ai",
24
23
  "src",
25
24
  "client.js",
26
25
  "client.d.ts",
@@ -48,6 +47,7 @@
48
47
  "@nocobase/flow-engine": "2.x",
49
48
  "@nocobase/plugin-ai": "2.x",
50
49
  "@nocobase/plugin-data-source-manager": "2.x",
50
+ "@nocobase/plugin-workflow": "2.x",
51
51
  "@nocobase/server": "2.x"
52
52
  },
53
53
  "repository": {
@@ -55,7 +55,7 @@
55
55
  "url": "git+https://github.com/OrgGem/nocobase-beta.git",
56
56
  "directory": "packages/plugins/plugin-elastic-report"
57
57
  },
58
- "gitHead": "321fce51621d4b8d6b5995e448fc66ce4cb67f58",
58
+ "gitHead": "04dbff450450c00a7c4d8eb70ee3e53d2ec41154",
59
59
  "publishConfig": {
60
60
  "access": "public",
61
61
  "registry": "https://registry.npmjs.org/"
package/server.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './dist/server';
2
- export { default } from './dist/server';
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/server/index.js');
1
+ module.exports = require('./dist/server/index.js');
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: elastic-report-builder
3
+ scope: CUSTOM
4
+ introduction:
5
+ title: Elastic Report Builder
6
+ title: Elasticsearch Kibana Report Builder
7
+ description: Discover Elasticsearch data views, inspect field capabilities, preview KQL/filter/sort/aggregation queries, and create Saved Elasticsearch Reports for NocoBase blocks.
8
+ tools:
9
+ - elastic-report-es_list_connections
10
+ - elastic-report-es_list_data_views
11
+ - elastic-report-es_upsert_data_view
12
+ - elastic-report-es_inspect_fields
13
+ - elastic-report-es_preview_report
14
+ - elastic-report-es_save_report
15
+ - elastic-report-es_list_reports
16
+ - elastic-report-es_analyze_report
17
+ - elastic-report-es_create_dashboard_bundle
18
+ - elastic-report-es_describe_block
19
+ - elastic-report-es_configure_block
20
+ - elastic-report-es_add_report_block
21
+ ---
22
+
23
+ # Elasticsearch Report Builder Guide
24
+
25
+ Use these tools (or their `mcp-elastic-report-*` equivalents) whenever a user asks to explore Elasticsearch logs/metrics/documents or build a Kibana-style Table or Chart report in NocoBase.
26
+
27
+ ## Reports in Settings
28
+
29
+ Save drafts with `published: false`. For edits, fetch the existing report by ID and preserve its full spec, including locked filters and role restrictions. Return the saved report ID and actual publication status.
30
+
31
+ 1. **Locate or Create a Data View**:
32
+ - Call `es_list_data_views` first.
33
+ - If no matching Data View exists yet, call `es_list_connections` to check available Elasticsearch connections and index names, then call `es_upsert_data_view` with `dataSourceKey` and `indexPattern` (for example `logs-*`).
34
+ 2. **Inspect Field Capabilities (`_field_caps`)**:
35
+ - Always call `es_inspect_fields` for the chosen `dataViewId` before writing filters, sorts, or chart buckets.
36
+ - Never guess field names. When sorting or grouping (`terms` bucket) on a `text` field, prefer its `keywordSubfield` (for example `service.keyword`) or a field marked `aggregatable: true`.
37
+ 3. **Preview Before Saving**:
38
+ - Call `es_preview_report` with your proposed `spec` (`visualization`: `'table' | 'bar' | 'line' | 'area' | 'pie' | 'metric'`, `query` in KQL, `filters`, `sort`, `timeRange`, `columns` or `chart`).
39
+ - Verify `total` hits and sample rows/series look accurate; adjust filters or field names if `total` is unexpectedly 0 or an error occurs.
40
+ 4. **Save Single Reports, Dashboard Bundles, or Analyze Existing Reports**:
41
+ - Call `es_save_report` for a single report, or `es_create_dashboard_bundle` to generate a coordinated multi-panel dashboard (KPI with `comparePreviousPeriod`, `p95`/`p99` line chart, stacked `splitSeriesField` breakdown, and Discover table) with optional `allowedRoles` and `lockedFilters` (supports server tokens `{{$user.id}}`, `{{$user.username}}`, `{{$role}}`).
42
+ - When a user asks to analyze or explain data from an already published report, call `es_analyze_report` (respects the caller's role and `lockedFilters`).
43
+
44
+ ## Edit the selected block
45
+
46
+ Use Pick block to attach exactly one Elastic Report block to the request. Call the native `es_describe_block` with its UID. To change that instance, call `es_configure_block` with the returned page UID, block UID, requested fields and their current values in `expected`. A display-only change requires no report save. If a value conflicts, describe again and show the user what changed before retrying.
47
+
48
+ For a combined create-and-bind request, describe the block and check `canConfigure` first. Preview and save the report once, then bind its published ID. If binding fails, return that ID and retry only the block change.
49
+
50
+ ## Add a report block to a tab
51
+
52
+ On a page without a report block, ask the user to attach **Work context → Report block destination**. They select the page/tab and a published report, then send the request. Call `elastic-report-es_add_report_block` with the exact `pageUid`, `tabUid` and `reportId` from that attachment. The user approves the tool in chat. Report the returned block UID and whether it was added or already present. The block appears at the end of the tab. If needed, reopen the tab or reload it. To use a draft, have the user publish it and select it first.
@@ -1,19 +1,34 @@
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 { Plugin } from '@nocobase/client';
11
- import { ElasticReportBlockModel } from '../client-v2/models/ElasticReportBlockModel';
12
-
13
- export class PluginElasticReportLegacyClient extends Plugin {
14
- async load() {
15
- this.flowEngine?.registerModels?.({ ElasticReportBlockModel });
16
- }
17
- }
18
-
19
- export default PluginElasticReportLegacyClient;
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 { Plugin } from '@nocobase/client';
11
+ import { ElasticFilterBarBlockModel } from '../client-v2/models/ElasticFilterBarBlockModel';
12
+ import { ElasticReportBlockModel } from '../client-v2/models/ElasticReportBlockModel';
13
+ import type { WorkflowClientRegistry } from '../client-v2/workflow/instructions';
14
+
15
+ export class PluginElasticReportLegacyClient extends Plugin {
16
+ async load() {
17
+ this.flowEngine?.registerModels?.({
18
+ ElasticReportBlockModel,
19
+ ElasticFilterBarBlockModel,
20
+ });
21
+
22
+ const workflow = (
23
+ this.app as unknown as {
24
+ pm?: { get?: (name: string) => WorkflowClientRegistry | undefined };
25
+ }
26
+ ).pm?.get?.('workflow');
27
+ if (workflow && typeof workflow.registerInstruction === 'function') {
28
+ const { registerLegacyWorkflowInstructions } = await import('./workflow-instructions');
29
+ registerLegacyWorkflowInstructions(workflow);
30
+ }
31
+ }
32
+ }
33
+
34
+ export default PluginElasticReportLegacyClient;
@@ -0,0 +1,44 @@
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 { BarChartOutlined } from '@ant-design/icons';
11
+ import { Instruction, type VariableOption } from '@nocobase/plugin-workflow/client';
12
+ import React from 'react';
13
+ import {
14
+ ElasticReportQueryFieldset,
15
+ buildElasticReportWorkflowVariables,
16
+ type WorkflowClientRegistry,
17
+ } from '../client-v2/workflow/instructions';
18
+ import { tExpr } from '../client-v2/locale';
19
+ import { WORKFLOW_GROUP_KEY, WORKFLOW_INSTRUCTION_TYPE } from '../shared/constants';
20
+
21
+ export function registerLegacyWorkflowInstructions(workflow: WorkflowClientRegistry): void {
22
+ workflow.registerInstructionGroup(WORKFLOW_GROUP_KEY, {
23
+ key: WORKFLOW_GROUP_KEY,
24
+ label: tExpr('Elastic Report'),
25
+ });
26
+
27
+ workflow.registerInstruction(
28
+ WORKFLOW_INSTRUCTION_TYPE,
29
+ class extends Instruction {
30
+ type = WORKFLOW_INSTRUCTION_TYPE;
31
+ title = tExpr('Query Elasticsearch Report');
32
+ description = tExpr(
33
+ 'Execute a Saved Elasticsearch Report and evaluate threshold conditions for scheduled alerts or reports.',
34
+ );
35
+ group = WORKFLOW_GROUP_KEY;
36
+ icon = (<BarChartOutlined />);
37
+ FieldsetLoader = async () => ({ default: ElasticReportQueryFieldset });
38
+
39
+ useVariables(node: { key: string; title: string }): VariableOption {
40
+ return buildElasticReportWorkflowVariables(node);
41
+ }
42
+ },
43
+ );
44
+ }