@perses-dev/clickhouse-plugin 0.1.0 → 0.3.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/LICENSE +201 -0
- package/README.md +1 -1
- package/__mf/css/async/1580.d3010b86.css +1 -0
- package/__mf/css/async/2341.d3010b86.css +1 -0
- package/__mf/js/{ClickHouse.99e35ca2.js → ClickHouse.8f89cb2c.js} +4 -4
- package/__mf/js/async/1360.33f7e672.js +10 -0
- package/__mf/js/async/2178.16cf2da3.js +2 -0
- package/__mf/js/async/2226.1d4436dc.js +1 -0
- package/__mf/js/async/2472.9f5fd5cf.js +22 -0
- package/__mf/js/async/2652.fd27ec3f.js +101 -0
- package/__mf/js/async/2708.7448dd5c.js +1 -0
- package/__mf/js/async/282.76b8b044.js +1 -0
- package/__mf/js/async/{4075.598f1ee5.js → 4075.b85e5581.js} +1 -1
- package/__mf/js/async/{4238.8c8282dc.js → 4238.a8170f41.js} +1 -1
- package/__mf/js/async/4421.750852d0.js +1 -0
- package/__mf/js/async/6134.a0f2d3c5.js +38 -0
- package/__mf/js/async/6620.1d8e42fd.js +2 -0
- package/__mf/js/async/7991.64a1aaaf.js +7 -0
- package/__mf/js/async/9563.6903fd59.js +2 -0
- package/__mf/js/async/{__federation_expose_ClickHouseDatasource.1ef730b1.js → __federation_expose_ClickHouseDatasource.e3722d39.js} +2 -2
- package/__mf/js/async/__federation_expose_ClickHouseLogQuery.63888cb7.js +20 -0
- package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.6a30813e.js +20 -0
- package/__mf/js/{main.b7c9a660.js → main.3bc5d901.js} +3 -3
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/queries/click-house-log-query/ClickHouseLogQueryEditor.js +28 -22
- package/lib/cjs/queries/click-house-time-series-query/ClickHouseQueryEditor.js +28 -22
- package/lib/cjs/queries/query-editor-model.js +53 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/model/click-house-data-types.d.ts +2 -15
- package/lib/model/click-house-data-types.d.ts.map +1 -1
- package/lib/model/click-house-data-types.js.map +1 -1
- package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.d.ts.map +1 -1
- package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.js +29 -23
- package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.js.map +1 -1
- package/lib/queries/click-house-log-query/get-click-house-log-data.js.map +1 -1
- package/lib/queries/click-house-log-query/log-query-plugin-interface.d.ts +2 -2
- package/lib/queries/click-house-log-query/log-query-plugin-interface.d.ts.map +1 -1
- package/lib/queries/click-house-log-query/log-query-plugin-interface.js.map +1 -1
- package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.d.ts.map +1 -1
- package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.js +29 -23
- package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.js.map +1 -1
- package/lib/queries/query-editor-model.d.ts +20 -0
- package/lib/queries/query-editor-model.d.ts.map +1 -0
- package/lib/queries/query-editor-model.js +50 -0
- package/lib/queries/query-editor-model.js.map +1 -0
- package/mf-manifest.json +48 -108
- package/mf-stats.json +48 -110
- package/package.json +8 -17
- package/__mf/css/async/1580.6b2b0c71.css +0 -1
- package/__mf/css/async/2341.6b2b0c71.css +0 -1
- package/__mf/css/async/6759.6b2b0c71.css +0 -1
- package/__mf/js/async/2417.1f135170.js +0 -2
- package/__mf/js/async/2448.e42be954.js +0 -10
- package/__mf/js/async/3632.f88c5ced.js +0 -101
- package/__mf/js/async/4168.af4fa8b3.js +0 -2
- package/__mf/js/async/4368.8468ec0a.js +0 -2
- package/__mf/js/async/4421.de18bb66.js +0 -1
- package/__mf/js/async/5035.8a983cd3.js +0 -73
- package/__mf/js/async/56.9997e6f8.js +0 -1
- package/__mf/js/async/5713.92805154.js +0 -1
- package/__mf/js/async/6411.3873365b.js +0 -1
- package/__mf/js/async/6467.f4e5b898.js +0 -1
- package/__mf/js/async/6569.f8ee50db.js +0 -1
- package/__mf/js/async/6714.e4b5281a.js +0 -2
- package/__mf/js/async/8465.f4c53fef.js +0 -7
- package/__mf/js/async/8709.6d909ac5.js +0 -2
- package/__mf/js/async/9654.ab803765.js +0 -37
- package/__mf/js/async/__federation_expose_ClickHouseLogQuery.3f312752.js +0 -19
- package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.a3f88e6b.js +0 -19
- package/__mf/js/async/__federation_expose_Logs.88d56eeb.js +0 -2
- package/lib/cjs/panels/index.js +0 -30
- package/lib/cjs/panels/logs/Logs.js +0 -37
- package/lib/cjs/panels/logs/LogsComponent.js +0 -47
- package/lib/cjs/panels/logs/LogsSettingsEditor.js +0 -57
- package/lib/cjs/panels/logs/components/EmptyLogsState.js +0 -49
- package/lib/cjs/panels/logs/components/LogRow/LogDetailsTable.js +0 -71
- package/lib/cjs/panels/logs/components/LogRow/LogRow.js +0 -163
- package/lib/cjs/panels/logs/components/LogRow/LogTimestamp.js +0 -45
- package/lib/cjs/panels/logs/components/LogRow/LogsStyles.js +0 -77
- package/lib/cjs/panels/logs/components/LogRow/index.js +0 -37
- package/lib/cjs/panels/logs/components/LogsList.js +0 -44
- package/lib/cjs/panels/logs/components/VirtualizedLogsList.js +0 -60
- package/lib/cjs/panels/logs/components/hooks/useExpandedRows.js +0 -45
- package/lib/cjs/panels/logs/index.js +0 -33
- package/lib/cjs/panels/logs/logs-types.js +0 -16
- package/lib/panels/index.d.ts +0 -2
- package/lib/panels/index.d.ts.map +0 -1
- package/lib/panels/index.js +0 -15
- package/lib/panels/index.js.map +0 -1
- package/lib/panels/logs/Logs.d.ts +0 -4
- package/lib/panels/logs/Logs.d.ts.map +0 -1
- package/lib/panels/logs/Logs.js +0 -29
- package/lib/panels/logs/Logs.js.map +0 -1
- package/lib/panels/logs/LogsComponent.d.ts +0 -4
- package/lib/panels/logs/LogsComponent.d.ts.map +0 -1
- package/lib/panels/logs/LogsComponent.js +0 -34
- package/lib/panels/logs/LogsComponent.js.map +0 -1
- package/lib/panels/logs/LogsSettingsEditor.d.ts +0 -7
- package/lib/panels/logs/LogsSettingsEditor.d.ts.map +0 -1
- package/lib/panels/logs/LogsSettingsEditor.js +0 -49
- package/lib/panels/logs/LogsSettingsEditor.js.map +0 -1
- package/lib/panels/logs/components/EmptyLogsState.d.ts +0 -7
- package/lib/panels/logs/components/EmptyLogsState.d.ts.map +0 -1
- package/lib/panels/logs/components/EmptyLogsState.js +0 -36
- package/lib/panels/logs/components/EmptyLogsState.js.map +0 -1
- package/lib/panels/logs/components/LogRow/LogDetailsTable.d.ts +0 -8
- package/lib/panels/logs/components/LogRow/LogDetailsTable.d.ts.map +0 -1
- package/lib/panels/logs/components/LogRow/LogDetailsTable.js +0 -58
- package/lib/panels/logs/components/LogRow/LogDetailsTable.js.map +0 -1
- package/lib/panels/logs/components/LogRow/LogRow.d.ts +0 -14
- package/lib/panels/logs/components/LogRow/LogRow.d.ts.map +0 -1
- package/lib/panels/logs/components/LogRow/LogRow.js +0 -109
- package/lib/panels/logs/components/LogRow/LogRow.js.map +0 -1
- package/lib/panels/logs/components/LogRow/LogTimestamp.d.ts +0 -7
- package/lib/panels/logs/components/LogRow/LogTimestamp.d.ts.map +0 -1
- package/lib/panels/logs/components/LogRow/LogTimestamp.js +0 -32
- package/lib/panels/logs/components/LogRow/LogTimestamp.js.map +0 -1
- package/lib/panels/logs/components/LogRow/LogsStyles.d.ts +0 -22
- package/lib/panels/logs/components/LogRow/LogsStyles.d.ts.map +0 -1
- package/lib/panels/logs/components/LogRow/LogsStyles.js +0 -55
- package/lib/panels/logs/components/LogRow/LogsStyles.js.map +0 -1
- package/lib/panels/logs/components/LogRow/index.d.ts +0 -3
- package/lib/panels/logs/components/LogRow/index.d.ts.map +0 -1
- package/lib/panels/logs/components/LogRow/index.js +0 -16
- package/lib/panels/logs/components/LogRow/index.js.map +0 -1
- package/lib/panels/logs/components/LogsList.d.ts +0 -8
- package/lib/panels/logs/components/LogsList.d.ts.map +0 -1
- package/lib/panels/logs/components/LogsList.js +0 -31
- package/lib/panels/logs/components/LogsList.js.map +0 -1
- package/lib/panels/logs/components/VirtualizedLogsList.d.ts +0 -10
- package/lib/panels/logs/components/VirtualizedLogsList.d.ts.map +0 -1
- package/lib/panels/logs/components/VirtualizedLogsList.js +0 -47
- package/lib/panels/logs/components/VirtualizedLogsList.js.map +0 -1
- package/lib/panels/logs/components/hooks/useExpandedRows.d.ts +0 -6
- package/lib/panels/logs/components/hooks/useExpandedRows.d.ts.map +0 -1
- package/lib/panels/logs/components/hooks/useExpandedRows.js +0 -37
- package/lib/panels/logs/components/hooks/useExpandedRows.js.map +0 -1
- package/lib/panels/logs/index.d.ts +0 -5
- package/lib/panels/logs/index.d.ts.map +0 -1
- package/lib/panels/logs/index.js +0 -18
- package/lib/panels/logs/index.js.map +0 -1
- package/lib/panels/logs/logs-types.d.ts +0 -16
- package/lib/panels/logs/logs-types.d.ts.map +0 -1
- package/lib/panels/logs/logs-types.js +0 -15
- package/lib/panels/logs/logs-types.js.map +0 -1
- /package/__mf/js/async/{2448.e42be954.js.LICENSE.txt → 1360.33f7e672.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4368.8468ec0a.js.LICENSE.txt → 2178.16cf2da3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5035.8a983cd3.js.LICENSE.txt → 2472.9f5fd5cf.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6714.e4b5281a.js.LICENSE.txt → 6620.1d8e42fd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8465.f4c53fef.js.LICENSE.txt → 7991.64a1aaaf.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2417.1f135170.js.LICENSE.txt → 9563.6903fd59.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8709.6d909ac5.js.LICENSE.txt → __federation_expose_ClickHouseDatasource.e3722d39.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseDatasource.1ef730b1.js.LICENSE.txt → __federation_expose_ClickHouseLogQuery.63888cb7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_Logs.88d56eeb.js.LICENSE.txt → __federation_expose_ClickHouseTimeSeriesQuery.6a30813e.js.LICENSE.txt} +0 -0
|
@@ -23,18 +23,23 @@ Object.defineProperty(exports, "ClickHouseLogQueryEditor", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
25
|
const _react = require("react");
|
|
26
|
+
const _immer = require("immer");
|
|
26
27
|
const _constants = require("../constants");
|
|
27
28
|
const _components = require("../../components");
|
|
28
29
|
const _material = require("@mui/material");
|
|
29
30
|
const _constants1 = require("../../components/constants");
|
|
31
|
+
const _queryeditormodel = require("../query-editor-model");
|
|
30
32
|
function ClickHouseLogQueryEditor(props) {
|
|
31
|
-
const { onChange, value } = props;
|
|
33
|
+
const { onChange, value, queryHandlerSettings } = props;
|
|
32
34
|
const { datasource } = value;
|
|
33
35
|
const selectedDatasource = datasource ?? _constants.DEFAULT_DATASOURCE;
|
|
34
|
-
const
|
|
36
|
+
const { query, handleQueryChange, handleQueryBlur } = (0, _queryeditormodel.useQueryState)(props);
|
|
35
37
|
const handleDatasourceChange = (newDatasourceSelection)=>{
|
|
36
38
|
if (!(0, _pluginsystem.isVariableDatasource)(newDatasourceSelection) && newDatasourceSelection.kind === _constants.DATASOURCE_KIND) {
|
|
37
|
-
onChange({
|
|
39
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
40
|
+
draft.datasource = newDatasourceSelection;
|
|
41
|
+
}));
|
|
42
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
38
43
|
...value,
|
|
39
44
|
datasource: newDatasourceSelection
|
|
40
45
|
});
|
|
@@ -42,22 +47,23 @@ function ClickHouseLogQueryEditor(props) {
|
|
|
42
47
|
}
|
|
43
48
|
throw new Error('Got unexpected non ClickHouse datasource selection');
|
|
44
49
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
query
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
// Immediate query execution on Enter or blur
|
|
51
|
+
const handleQueryExecute = (query)=>{
|
|
52
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
53
|
+
queryHandlerSettings.watchQueryChanges(query);
|
|
54
|
+
}
|
|
55
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
56
|
+
draft.query = query;
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
const handleClickHouseQueryChange = (0, _react.useCallback)((e)=>{
|
|
60
|
+
handleQueryChange(e);
|
|
61
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
62
|
+
queryHandlerSettings.watchQueryChanges(e);
|
|
63
|
+
}
|
|
59
64
|
}, [
|
|
60
|
-
|
|
65
|
+
handleQueryChange,
|
|
66
|
+
queryHandlerSettings
|
|
61
67
|
]);
|
|
62
68
|
const examplesStyle = {
|
|
63
69
|
fontSize: '11px',
|
|
@@ -80,13 +86,13 @@ function ClickHouseLogQueryEditor(props) {
|
|
|
80
86
|
notched: true
|
|
81
87
|
}),
|
|
82
88
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ClickQLEditor, {
|
|
83
|
-
value:
|
|
84
|
-
onChange:
|
|
85
|
-
onBlur:
|
|
89
|
+
value: query,
|
|
90
|
+
onChange: handleClickHouseQueryChange,
|
|
91
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
|
|
86
92
|
onKeyDown: (event)=>{
|
|
87
93
|
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
88
94
|
event.preventDefault();
|
|
89
|
-
handleQueryExecute(
|
|
95
|
+
handleQueryExecute(query);
|
|
90
96
|
}
|
|
91
97
|
},
|
|
92
98
|
placeholder: "Enter ClickHouse SQL query"
|
|
@@ -23,18 +23,23 @@ Object.defineProperty(exports, "ClickHouseTimeSeriesQueryEditor", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
25
|
const _react = require("react");
|
|
26
|
+
const _immer = require("immer");
|
|
26
27
|
const _constants = require("../constants");
|
|
27
28
|
const _components = require("../../components");
|
|
28
29
|
const _material = require("@mui/material");
|
|
29
30
|
const _constants1 = require("../../components/constants");
|
|
31
|
+
const _queryeditormodel = require("../query-editor-model");
|
|
30
32
|
function ClickHouseTimeSeriesQueryEditor(props) {
|
|
31
|
-
const { onChange, value } = props;
|
|
33
|
+
const { onChange, value, queryHandlerSettings } = props;
|
|
32
34
|
const { datasource } = value;
|
|
33
35
|
const selectedDatasource = datasource ?? _constants.DEFAULT_DATASOURCE;
|
|
34
|
-
const
|
|
36
|
+
const { query, handleQueryChange, handleQueryBlur } = (0, _queryeditormodel.useQueryState)(props);
|
|
35
37
|
const handleDatasourceChange = (newDatasourceSelection)=>{
|
|
36
38
|
if (!(0, _pluginsystem.isVariableDatasource)(newDatasourceSelection) && newDatasourceSelection.kind === _constants.DATASOURCE_KIND) {
|
|
37
|
-
onChange({
|
|
39
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
40
|
+
draft.datasource = newDatasourceSelection;
|
|
41
|
+
}));
|
|
42
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
38
43
|
...value,
|
|
39
44
|
datasource: newDatasourceSelection
|
|
40
45
|
});
|
|
@@ -42,22 +47,23 @@ function ClickHouseTimeSeriesQueryEditor(props) {
|
|
|
42
47
|
}
|
|
43
48
|
throw new Error('Got unexpected non ClickHouse datasource selection');
|
|
44
49
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
query
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
// Immediate query execution on Enter or blur
|
|
51
|
+
const handleQueryExecute = (query)=>{
|
|
52
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
53
|
+
queryHandlerSettings.watchQueryChanges(query);
|
|
54
|
+
}
|
|
55
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
56
|
+
draft.query = query;
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
const handleClickHouseQueryChange = (0, _react.useCallback)((e)=>{
|
|
60
|
+
handleQueryChange(e);
|
|
61
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
62
|
+
queryHandlerSettings.watchQueryChanges(e);
|
|
63
|
+
}
|
|
59
64
|
}, [
|
|
60
|
-
|
|
65
|
+
handleQueryChange,
|
|
66
|
+
queryHandlerSettings
|
|
61
67
|
]);
|
|
62
68
|
const examplesStyle = {
|
|
63
69
|
fontSize: '11px',
|
|
@@ -80,13 +86,13 @@ function ClickHouseTimeSeriesQueryEditor(props) {
|
|
|
80
86
|
notched: true
|
|
81
87
|
}),
|
|
82
88
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ClickQLEditor, {
|
|
83
|
-
value:
|
|
84
|
-
onChange:
|
|
85
|
-
onBlur:
|
|
89
|
+
value: query,
|
|
90
|
+
onChange: handleClickHouseQueryChange,
|
|
91
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
|
|
86
92
|
onKeyDown: (event)=>{
|
|
87
93
|
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
88
94
|
event.preventDefault();
|
|
89
|
-
handleQueryExecute(
|
|
95
|
+
handleQueryExecute(query);
|
|
90
96
|
}
|
|
91
97
|
},
|
|
92
98
|
placeholder: "Enter ClickHouse SQL query"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useQueryState", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return useQueryState;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const _immer = require("immer");
|
|
25
|
+
function useQueryState(props) {
|
|
26
|
+
const { onChange, value } = props;
|
|
27
|
+
// Local copy of the query's value
|
|
28
|
+
const [query, setQuery] = (0, _react.useState)(value.query || '');
|
|
29
|
+
// This is basically "getDerivedStateFromProps" to make sure if spec's value changes external to this component,
|
|
30
|
+
// we render with the latest value
|
|
31
|
+
const [lastSyncedQuery, setLastSyncedQuery] = (0, _react.useState)(value.query);
|
|
32
|
+
if (value.query !== lastSyncedQuery) {
|
|
33
|
+
setQuery(value.query || '');
|
|
34
|
+
setLastSyncedQuery(value.query);
|
|
35
|
+
}
|
|
36
|
+
// Update our local state's copy as the user types
|
|
37
|
+
const handleQueryChange = (e)=>{
|
|
38
|
+
setQuery(e);
|
|
39
|
+
};
|
|
40
|
+
// Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the
|
|
41
|
+
// PanelPreview
|
|
42
|
+
const handleQueryBlur = ()=>{
|
|
43
|
+
setLastSyncedQuery(query);
|
|
44
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
45
|
+
draft.query = query;
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
query,
|
|
50
|
+
handleQueryChange,
|
|
51
|
+
handleQueryBlur
|
|
52
|
+
};
|
|
53
|
+
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export { getPluginModule } from './getPluginModule';
|
|
14
|
-
export * from './panels';
|
|
15
14
|
export * from './queries';
|
|
16
15
|
export * from './datasources';
|
|
17
16
|
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport { getPluginModule } from './getPluginModule';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport { getPluginModule } from './getPluginModule';\nexport * from './queries';\nexport * from './datasources';\n"],"names":["getPluginModule"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,YAAY;AAC1B,cAAc,gBAAgB"}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import { TimeSeriesData } from '@perses-dev/core';
|
|
2
|
-
export interface LogLabels {
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}
|
|
5
|
-
export interface LogEntry {
|
|
6
|
-
timestamp: number;
|
|
7
|
-
labels: LogLabels;
|
|
8
|
-
line?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface LogsData {
|
|
11
|
-
entries: LogEntry[];
|
|
12
|
-
totalCount: number;
|
|
13
|
-
hasMore?: boolean;
|
|
14
|
-
}
|
|
1
|
+
import { LogData, TimeSeriesData } from '@perses-dev/core';
|
|
15
2
|
export interface ClickHouseTimeSeriesData extends TimeSeriesData {
|
|
16
|
-
logs?:
|
|
3
|
+
logs?: LogData;
|
|
17
4
|
}
|
|
18
5
|
export interface TimeSeriesEntry {
|
|
19
6
|
time: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click-house-data-types.d.ts","sourceRoot":"","sources":["../../../src/model/click-house-data-types.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"click-house-data-types.d.ts","sourceRoot":"","sources":["../../../src/model/click-house-data-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAY,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/click-house-data-types.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TimeSeriesData } from '@perses-dev/core';\n\nexport interface
|
|
1
|
+
{"version":3,"sources":["../../../src/model/click-house-data-types.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { LogEntry, LogData, TimeSeriesData } from '@perses-dev/core';\n\nexport interface ClickHouseTimeSeriesData extends TimeSeriesData {\n logs?: LogData;\n}\n\nexport interface TimeSeriesEntry {\n time: string;\n log_count: number | string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAQjC,WAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickHouseLogQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"ClickHouseLogQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAMlD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,KAAK,0BAA0B,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;AAE7E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,0BAA0B,GAAG,YAAY,CAoFxF"}
|
|
@@ -12,19 +12,24 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system';
|
|
15
|
-
import { useCallback
|
|
15
|
+
import { useCallback } from 'react';
|
|
16
|
+
import { produce } from 'immer';
|
|
16
17
|
import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';
|
|
17
18
|
import { ClickQLEditor } from '../../components';
|
|
18
19
|
import { Stack } from '@mui/material';
|
|
19
20
|
import { queryExample } from '../../components/constants';
|
|
21
|
+
import { useQueryState } from '../query-editor-model';
|
|
20
22
|
export function ClickHouseLogQueryEditor(props) {
|
|
21
|
-
const { onChange, value } = props;
|
|
23
|
+
const { onChange, value, queryHandlerSettings } = props;
|
|
22
24
|
const { datasource } = value;
|
|
23
25
|
const selectedDatasource = datasource ?? DEFAULT_DATASOURCE;
|
|
24
|
-
const
|
|
26
|
+
const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);
|
|
25
27
|
const handleDatasourceChange = (newDatasourceSelection)=>{
|
|
26
28
|
if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {
|
|
27
|
-
onChange({
|
|
29
|
+
onChange(produce(value, (draft)=>{
|
|
30
|
+
draft.datasource = newDatasourceSelection;
|
|
31
|
+
}));
|
|
32
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
28
33
|
...value,
|
|
29
34
|
datasource: newDatasourceSelection
|
|
30
35
|
});
|
|
@@ -32,22 +37,23 @@ export function ClickHouseLogQueryEditor(props) {
|
|
|
32
37
|
}
|
|
33
38
|
throw new Error('Got unexpected non ClickHouse datasource selection');
|
|
34
39
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
query
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
// Immediate query execution on Enter or blur
|
|
41
|
+
const handleQueryExecute = (query)=>{
|
|
42
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
43
|
+
queryHandlerSettings.watchQueryChanges(query);
|
|
44
|
+
}
|
|
45
|
+
onChange(produce(value, (draft)=>{
|
|
46
|
+
draft.query = query;
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
const handleClickHouseQueryChange = useCallback((e)=>{
|
|
50
|
+
handleQueryChange(e);
|
|
51
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
52
|
+
queryHandlerSettings.watchQueryChanges(e);
|
|
53
|
+
}
|
|
49
54
|
}, [
|
|
50
|
-
|
|
55
|
+
handleQueryChange,
|
|
56
|
+
queryHandlerSettings
|
|
51
57
|
]);
|
|
52
58
|
const examplesStyle = {
|
|
53
59
|
fontSize: '11px',
|
|
@@ -70,13 +76,13 @@ export function ClickHouseLogQueryEditor(props) {
|
|
|
70
76
|
notched: true
|
|
71
77
|
}),
|
|
72
78
|
/*#__PURE__*/ _jsx(ClickQLEditor, {
|
|
73
|
-
value:
|
|
74
|
-
onChange:
|
|
75
|
-
onBlur:
|
|
79
|
+
value: query,
|
|
80
|
+
onChange: handleClickHouseQueryChange,
|
|
81
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
|
|
76
82
|
onKeyDown: (event)=>{
|
|
77
83
|
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
78
84
|
event.preventDefault();
|
|
79
|
-
handleQueryExecute(
|
|
85
|
+
handleQueryExecute(query);
|
|
80
86
|
}
|
|
81
87
|
},
|
|
82
88
|
placeholder: "Enter ClickHouse SQL query"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n isVariableDatasource,\n OptionsEditorProps,\n} from '@perses-dev/plugin-system';\nimport { ReactElement, useCallback
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n isVariableDatasource,\n OptionsEditorProps,\n} from '@perses-dev/plugin-system';\nimport { ReactElement, useCallback } from 'react';\nimport { produce } from 'immer';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { ClickQLEditor } from '../../components';\nimport { Stack } from '@mui/material';\nimport { queryExample } from '../../components/constants';\nimport { ClickHouseLogQuerySpec } from './click-house-log-query-types';\nimport { useQueryState } from '../query-editor-model';\n\ntype ClickHouseQueryEditorProps = OptionsEditorProps<ClickHouseLogQuerySpec>;\n\nexport function ClickHouseLogQueryEditor(props: ClickHouseQueryEditorProps): ReactElement {\n const { onChange, value, queryHandlerSettings } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_DATASOURCE;\n const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (newDatasourceSelection) => {\n if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {\n onChange(\n produce(value, (draft) => {\n draft.datasource = newDatasourceSelection;\n })\n );\n\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: newDatasourceSelection });\n return;\n }\n throw new Error('Got unexpected non ClickHouse datasource selection');\n };\n\n // Immediate query execution on Enter or blur\n const handleQueryExecute = (query: string) => {\n if (queryHandlerSettings?.watchQueryChanges) {\n queryHandlerSettings.watchQueryChanges(query);\n }\n onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n const handleClickHouseQueryChange = useCallback(\n (e: string) => {\n handleQueryChange(e);\n if (queryHandlerSettings?.watchQueryChanges) {\n queryHandlerSettings.watchQueryChanges(e);\n }\n },\n [handleQueryChange, queryHandlerSettings]\n );\n\n const examplesStyle: React.CSSProperties = {\n fontSize: '11px',\n color: '#777',\n backgroundColor: '#f5f5f5',\n padding: '8px',\n borderRadius: '4px',\n fontFamily: 'Monaco, Menlo, \"Ubuntu Mono\", monospace',\n whiteSpace: 'pre-wrap',\n lineHeight: '1.3',\n };\n\n return (\n <Stack spacing={1.5}>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"ClickHouse Datasource\"\n notched\n />\n <ClickQLEditor\n value={query}\n onChange={handleClickHouseQueryChange}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {\n event.preventDefault();\n handleQueryExecute(query);\n }\n }}\n placeholder=\"Enter ClickHouse SQL query\"\n />\n\n <details>\n <summary style={{ cursor: 'pointer', fontSize: '12px', color: '#666', marginBottom: '8px' }}>\n Query Examples\n </summary>\n <div style={examplesStyle}>{queryExample}</div>\n </details>\n </Stack>\n );\n}\n"],"names":["DatasourceSelect","isVariableDatasource","useCallback","produce","DATASOURCE_KIND","DEFAULT_DATASOURCE","ClickQLEditor","Stack","queryExample","useQueryState","ClickHouseLogQueryEditor","props","onChange","value","queryHandlerSettings","datasource","selectedDatasource","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","newDatasourceSelection","kind","draft","setWatchOtherSpecs","Error","handleQueryExecute","watchQueryChanges","handleClickHouseQueryChange","e","examplesStyle","fontSize","color","backgroundColor","padding","borderRadius","fontFamily","whiteSpace","lineHeight","spacing","datasourcePluginKind","label","notched","onBlur","runWithOnBlur","undefined","onKeyDown","event","key","ctrlKey","metaKey","preventDefault","placeholder","details","summary","style","cursor","marginBottom","div"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SACEA,gBAAgB,EAEhBC,oBAAoB,QAEf,4BAA4B;AACnC,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,eAAe;AACnE,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,YAAY,QAAQ,6BAA6B;AAE1D,SAASC,aAAa,QAAQ,wBAAwB;AAItD,OAAO,SAASC,yBAAyBC,KAAiC;IACxE,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,oBAAoB,EAAE,GAAGH;IAClD,MAAM,EAAEI,UAAU,EAAE,GAAGF;IACvB,MAAMG,qBAAqBD,cAAcV;IACzC,MAAM,EAAEY,KAAK,EAAEC,iBAAiB,EAAEC,eAAe,EAAE,GAAGV,cAAcE;IAEpE,MAAMS,yBAA4D,CAACC;QACjE,IAAI,CAACpB,qBAAqBoB,2BAA2BA,uBAAuBC,IAAI,KAAKlB,iBAAiB;YACpGQ,SACET,QAAQU,OAAO,CAACU;gBACdA,MAAMR,UAAU,GAAGM;YACrB;YAGF,IAAIP,sBAAsBU,oBACxBV,qBAAqBU,kBAAkB,CAAC;gBAAE,GAAGX,KAAK;gBAAEE,YAAYM;YAAuB;YACzF;QACF;QACA,MAAM,IAAII,MAAM;IAClB;IAEA,6CAA6C;IAC7C,MAAMC,qBAAqB,CAACT;QAC1B,IAAIH,sBAAsBa,mBAAmB;YAC3Cb,qBAAqBa,iBAAiB,CAACV;QACzC;QACAL,SACET,QAAQU,OAAO,CAACU;YACdA,MAAMN,KAAK,GAAGA;QAChB;IAEJ;IAEA,MAAMW,8BAA8B1B,YAClC,CAAC2B;QACCX,kBAAkBW;QAClB,IAAIf,sBAAsBa,mBAAmB;YAC3Cb,qBAAqBa,iBAAiB,CAACE;QACzC;IACF,GACA;QAACX;QAAmBJ;KAAqB;IAG3C,MAAMgB,gBAAqC;QACzCC,UAAU;QACVC,OAAO;QACPC,iBAAiB;QACjBC,SAAS;QACTC,cAAc;QACdC,YAAY;QACZC,YAAY;QACZC,YAAY;IACd;IAEA,qBACE,MAAC/B;QAAMgC,SAAS;;0BACd,KAACvC;gBACCwC,sBAAsBpC;gBACtBS,OAAOG;gBACPJ,UAAUQ;gBACVqB,OAAM;gBACNC,OAAO;;0BAET,KAACpC;gBACCO,OAAOI;gBACPL,UAAUgB;gBACVe,QAAQ7B,sBAAsB8B,gBAAgBzB,kBAAkB0B;gBAChEC,WAAW,CAACC;oBACV,IAAIA,MAAMC,GAAG,KAAK,WAAYD,CAAAA,MAAME,OAAO,IAAIF,MAAMG,OAAO,AAAD,GAAI;wBAC7DH,MAAMI,cAAc;wBACpBzB,mBAAmBT;oBACrB;gBACF;gBACAmC,aAAY;;0BAGd,MAACC;;kCACC,KAACC;wBAAQC,OAAO;4BAAEC,QAAQ;4BAAWzB,UAAU;4BAAQC,OAAO;4BAAQyB,cAAc;wBAAM;kCAAG;;kCAG7F,KAACC;wBAAIH,OAAOzB;kCAAgBtB;;;;;;AAIpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-log-query/get-click-house-log-data.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { replaceVariables } from '@perses-dev/plugin-system';\nimport { LogEntry,
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-log-query/get-click-house-log-data.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { replaceVariables } from '@perses-dev/plugin-system';\nimport { LogEntry, LogData } from '@perses-dev/core';\nimport { ClickHouseClient, ClickHouseQueryResponse } from '../../model/click-house-client';\nimport { ClickHouseLogQuerySpec } from './click-house-log-query-types';\nimport { DEFAULT_DATASOURCE } from '../constants';\nimport { LogQueryPlugin } from './log-query-plugin-interface';\n\nfunction flattenObject(\n obj: Record<string, any>,\n parentKey = '',\n result: Record<string, any> = {}\n): Record<string, any> {\n for (const [key, value] of Object.entries(obj)) {\n const newKey = parentKey ? `${parentKey}.${key}` : key;\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n flattenObject(value, newKey, result);\n } else {\n result[newKey] = value;\n }\n }\n\n return result;\n}\n\nfunction convertStreamsToLogs(streams: LogEntry[]): LogData {\n const entries: LogEntry[] = streams.map((entry) => {\n const flattened = flattenObject(entry);\n\n if (!flattened.Timestamp && flattened.log_time) {\n flattened.Timestamp = flattened.log_time;\n }\n\n const sortedEntry: Record<string, any> = {};\n Object.keys(flattened)\n .sort((a, b) => a.localeCompare(b))\n .forEach((key) => {\n sortedEntry[key] = flattened[key];\n });\n\n const line = Object.entries(sortedEntry)\n .filter(([key]) => key !== 'Timestamp')\n .map(([key, value]) => `<${key}> ${value === '' || value === null || value === undefined ? '--' : value}`)\n .join(' ');\n\n return {\n timestamp: sortedEntry?.Timestamp,\n labels: sortedEntry,\n line,\n } as LogEntry;\n });\n\n return {\n entries,\n totalCount: entries.length,\n };\n}\n\nexport const getClickHouseLogData: LogQueryPlugin<ClickHouseLogQuerySpec>['getLogData'] = async (spec, context) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n return {\n logs: { entries: [], totalCount: 0 },\n timeRange: { start: context.timeRange.start, end: context.timeRange.end },\n };\n }\n\n const query = replaceVariables(spec.query, context.variableState);\n\n const client = (await context.datasourceStore.getDatasourceClient(\n spec.datasource ?? DEFAULT_DATASOURCE\n )) as ClickHouseClient;\n\n const { start, end } = context.timeRange;\n\n const response: ClickHouseQueryResponse = await client.query({\n start: start.getTime().toString(),\n end: end.getTime().toString(),\n query,\n });\n\n return {\n timeRange: { start, end },\n logs: convertStreamsToLogs(response.data),\n metadata: {\n executedQueryString: query,\n },\n };\n};\n"],"names":["replaceVariables","DEFAULT_DATASOURCE","flattenObject","obj","parentKey","result","key","value","Object","entries","newKey","Array","isArray","convertStreamsToLogs","streams","map","entry","flattened","Timestamp","log_time","sortedEntry","keys","sort","a","b","localeCompare","forEach","line","filter","undefined","join","timestamp","labels","totalCount","length","getClickHouseLogData","spec","context","query","logs","timeRange","start","end","variableState","client","datasourceStore","getDatasourceClient","datasource","response","getTime","toString","data","metadata","executedQueryString"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,gBAAgB,QAAQ,4BAA4B;AAI7D,SAASC,kBAAkB,QAAQ,eAAe;AAGlD,SAASC,cACPC,GAAwB,EACxBC,YAAY,EAAE,EACdC,SAA8B,CAAC,CAAC;IAEhC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACN,KAAM;QAC9C,MAAMO,SAASN,YAAY,GAAGA,UAAU,CAAC,EAAEE,KAAK,GAAGA;QACnD,IAAIC,SAAS,OAAOA,UAAU,YAAY,CAACI,MAAMC,OAAO,CAACL,QAAQ;YAC/DL,cAAcK,OAAOG,QAAQL;QAC/B,OAAO;YACLA,MAAM,CAACK,OAAO,GAAGH;QACnB;IACF;IAEA,OAAOF;AACT;AAEA,SAASQ,qBAAqBC,OAAmB;IAC/C,MAAML,UAAsBK,QAAQC,GAAG,CAAC,CAACC;QACvC,MAAMC,YAAYf,cAAcc;QAEhC,IAAI,CAACC,UAAUC,SAAS,IAAID,UAAUE,QAAQ,EAAE;YAC9CF,UAAUC,SAAS,GAAGD,UAAUE,QAAQ;QAC1C;QAEA,MAAMC,cAAmC,CAAC;QAC1CZ,OAAOa,IAAI,CAACJ,WACTK,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEE,aAAa,CAACD,IAC/BE,OAAO,CAAC,CAACpB;YACRc,WAAW,CAACd,IAAI,GAAGW,SAAS,CAACX,IAAI;QACnC;QAEF,MAAMqB,OAAOnB,OAAOC,OAAO,CAACW,aACzBQ,MAAM,CAAC,CAAC,CAACtB,IAAI,GAAKA,QAAQ,aAC1BS,GAAG,CAAC,CAAC,CAACT,KAAKC,MAAM,GAAK,CAAC,CAAC,EAAED,IAAI,EAAE,EAAEC,UAAU,MAAMA,UAAU,QAAQA,UAAUsB,YAAY,OAAOtB,OAAO,EACxGuB,IAAI,CAAC;QAER,OAAO;YACLC,WAAWX,aAAaF;YACxBc,QAAQZ;YACRO;QACF;IACF;IAEA,OAAO;QACLlB;QACAwB,YAAYxB,QAAQyB,MAAM;IAC5B;AACF;AAEA,OAAO,MAAMC,uBAA6E,OAAOC,MAAMC;IACrG,IAAID,KAAKE,KAAK,KAAKT,aAAaO,KAAKE,KAAK,KAAK,QAAQF,KAAKE,KAAK,KAAK,IAAI;QACxE,OAAO;YACLC,MAAM;gBAAE9B,SAAS,EAAE;gBAAEwB,YAAY;YAAE;YACnCO,WAAW;gBAAEC,OAAOJ,QAAQG,SAAS,CAACC,KAAK;gBAAEC,KAAKL,QAAQG,SAAS,CAACE,GAAG;YAAC;QAC1E;IACF;IAEA,MAAMJ,QAAQtC,iBAAiBoC,KAAKE,KAAK,EAAED,QAAQM,aAAa;IAEhE,MAAMC,SAAU,MAAMP,QAAQQ,eAAe,CAACC,mBAAmB,CAC/DV,KAAKW,UAAU,IAAI9C;IAGrB,MAAM,EAAEwC,KAAK,EAAEC,GAAG,EAAE,GAAGL,QAAQG,SAAS;IAExC,MAAMQ,WAAoC,MAAMJ,OAAON,KAAK,CAAC;QAC3DG,OAAOA,MAAMQ,OAAO,GAAGC,QAAQ;QAC/BR,KAAKA,IAAIO,OAAO,GAAGC,QAAQ;QAC3BZ;IACF;IAEA,OAAO;QACLE,WAAW;YAAEC;YAAOC;QAAI;QACxBH,MAAM1B,qBAAqBmC,SAASG,IAAI;QACxCC,UAAU;YACRC,qBAAqBf;QACvB;IACF;AACF,EAAE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AbsoluteTimeRange, UnknownSpec } from '@perses-dev/core';
|
|
2
2
|
import { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';
|
|
3
|
-
import {
|
|
3
|
+
import { LogData } from '@perses-dev/core';
|
|
4
4
|
export interface LogQueryResult {
|
|
5
|
-
logs:
|
|
5
|
+
logs: LogData;
|
|
6
6
|
timeRange: AbsoluteTimeRange;
|
|
7
7
|
metadata?: {
|
|
8
8
|
executedQueryString: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-query-plugin-interface.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-log-query/log-query-plugin-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"log-query-plugin-interface.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-log-query/log-query-plugin-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACtE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACjF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,0BAA0B,CAAC;CACrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-log-query/log-query-plugin-interface.ts"],"sourcesContent":["import { AbsoluteTimeRange, UnknownSpec } from '@perses-dev/core';\nimport { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-log-query/log-query-plugin-interface.ts"],"sourcesContent":["import { AbsoluteTimeRange, UnknownSpec } from '@perses-dev/core';\nimport { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';\nimport { LogData } from '@perses-dev/core';\n\nexport interface LogQueryResult {\n logs: LogData;\n timeRange: AbsoluteTimeRange;\n metadata?: {\n executedQueryString: string;\n };\n}\n\nexport interface ClickHouseQueryContext {\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\ntype LogQueryPluginDependencies = {\n variables?: string[];\n};\n\nexport interface LogQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getLogData: (spec: Spec, ctx: ClickHouseQueryContext) => Promise<LogQueryResult>;\n dependsOn?: (spec: Spec, ctx: ClickHouseQueryContext) => LogQueryPluginDependencies;\n}\n"],"names":[],"mappings":"AAuBA,WAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickHouseQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"ClickHouseQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAO1E,KAAK,oCAAoC,GAAG,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;AAE9F,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CAoFzG"}
|
|
@@ -12,19 +12,24 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system';
|
|
15
|
-
import { useCallback
|
|
15
|
+
import { useCallback } from 'react';
|
|
16
|
+
import { produce } from 'immer';
|
|
16
17
|
import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';
|
|
17
18
|
import { ClickQLEditor } from '../../components';
|
|
18
19
|
import { Stack } from '@mui/material';
|
|
19
20
|
import { queryExample } from '../../components/constants';
|
|
21
|
+
import { useQueryState } from '../query-editor-model';
|
|
20
22
|
export function ClickHouseTimeSeriesQueryEditor(props) {
|
|
21
|
-
const { onChange, value } = props;
|
|
23
|
+
const { onChange, value, queryHandlerSettings } = props;
|
|
22
24
|
const { datasource } = value;
|
|
23
25
|
const selectedDatasource = datasource ?? DEFAULT_DATASOURCE;
|
|
24
|
-
const
|
|
26
|
+
const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);
|
|
25
27
|
const handleDatasourceChange = (newDatasourceSelection)=>{
|
|
26
28
|
if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {
|
|
27
|
-
onChange({
|
|
29
|
+
onChange(produce(value, (draft)=>{
|
|
30
|
+
draft.datasource = newDatasourceSelection;
|
|
31
|
+
}));
|
|
32
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
28
33
|
...value,
|
|
29
34
|
datasource: newDatasourceSelection
|
|
30
35
|
});
|
|
@@ -32,22 +37,23 @@ export function ClickHouseTimeSeriesQueryEditor(props) {
|
|
|
32
37
|
}
|
|
33
38
|
throw new Error('Got unexpected non ClickHouse datasource selection');
|
|
34
39
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
query
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
// Immediate query execution on Enter or blur
|
|
41
|
+
const handleQueryExecute = (query)=>{
|
|
42
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
43
|
+
queryHandlerSettings.watchQueryChanges(query);
|
|
44
|
+
}
|
|
45
|
+
onChange(produce(value, (draft)=>{
|
|
46
|
+
draft.query = query;
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
const handleClickHouseQueryChange = useCallback((e)=>{
|
|
50
|
+
handleQueryChange(e);
|
|
51
|
+
if (queryHandlerSettings?.watchQueryChanges) {
|
|
52
|
+
queryHandlerSettings.watchQueryChanges(e);
|
|
53
|
+
}
|
|
49
54
|
}, [
|
|
50
|
-
|
|
55
|
+
handleQueryChange,
|
|
56
|
+
queryHandlerSettings
|
|
51
57
|
]);
|
|
52
58
|
const examplesStyle = {
|
|
53
59
|
fontSize: '11px',
|
|
@@ -70,13 +76,13 @@ export function ClickHouseTimeSeriesQueryEditor(props) {
|
|
|
70
76
|
notched: true
|
|
71
77
|
}),
|
|
72
78
|
/*#__PURE__*/ _jsx(ClickQLEditor, {
|
|
73
|
-
value:
|
|
74
|
-
onChange:
|
|
75
|
-
onBlur:
|
|
79
|
+
value: query,
|
|
80
|
+
onChange: handleClickHouseQueryChange,
|
|
81
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
|
|
76
82
|
onKeyDown: (event)=>{
|
|
77
83
|
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
78
84
|
event.preventDefault();
|
|
79
|
-
handleQueryExecute(
|
|
85
|
+
handleQueryExecute(query);
|
|
80
86
|
}
|
|
81
87
|
},
|
|
82
88
|
placeholder: "Enter ClickHouse SQL query"
|