@perses-dev/clickhouse-plugin 0.1.0 → 0.2.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/__mf/js/{ClickHouse.99e35ca2.js → ClickHouse.f6211ab5.js} +4 -4
- package/__mf/js/async/2226.332707ca.js +1 -0
- package/__mf/js/async/282.76b8b044.js +1 -0
- package/__mf/js/async/__federation_expose_ClickHouseLogQuery.4c608fd8.js +20 -0
- package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.12307d25.js +20 -0
- package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.12307d25.js.LICENSE.txt +9 -0
- package/__mf/js/{main.b7c9a660.js → main.91d879ed.js} +3 -3
- 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/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-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 +19 -19
- package/mf-stats.json +19 -19
- package/package.json +3 -3
- package/__mf/js/async/6411.3873365b.js +0 -1
- package/__mf/js/async/8709.6d909ac5.js +0 -2
- 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/{8709.6d909ac5.js.LICENSE.txt → __federation_expose_ClickHouseLogQuery.4c608fd8.js.LICENSE.txt} +0 -0
|
@@ -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
|
+
}
|
|
@@ -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,"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"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQueryEditor.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-time-series-query/ClickHouseQueryEditor.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 { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { ClickQLEditor } from '../../components';\nimport { Stack } from '@mui/material';\nimport { queryExample } from '../../components/constants';\nimport { useQueryState } from '../query-editor-model';\n\ntype ClickHouseTimeSeriesQueryEditorProps = OptionsEditorProps<ClickHouseTimeSeriesQuerySpec>;\n\nexport function ClickHouseTimeSeriesQueryEditor(props: ClickHouseTimeSeriesQueryEditorProps): 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","ClickHouseTimeSeriesQueryEditor","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;AAEhC,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,eAAe;AACnE,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,aAAa,QAAQ,wBAAwB;AAItD,OAAO,SAASC,gCAAgCC,KAA2C;IACzF,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
2
|
+
/**
|
|
3
|
+
* Generic type for any ClickHouse query spec that has a query field
|
|
4
|
+
*/
|
|
5
|
+
type ClickHouseQuerySpec = {
|
|
6
|
+
query?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A hook for managing the `query` state in ClickHouse query specs. Returns the `query` value, along with
|
|
10
|
+
* `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those
|
|
11
|
+
* changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview
|
|
12
|
+
* every time the user types.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useQueryState<T extends ClickHouseQuerySpec>(props: OptionsEditorProps<T>): {
|
|
15
|
+
query: string;
|
|
16
|
+
handleQueryChange: (e: string) => void;
|
|
17
|
+
handleQueryBlur: () => void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=query-editor-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-editor-model.d.ts","sourceRoot":"","sources":["../../../src/queries/query-editor-model.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,mBAAmB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CA+BA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
import { useState } from 'react';
|
|
14
|
+
import { produce } from 'immer';
|
|
15
|
+
/**
|
|
16
|
+
* A hook for managing the `query` state in ClickHouse query specs. Returns the `query` value, along with
|
|
17
|
+
* `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those
|
|
18
|
+
* changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview
|
|
19
|
+
* every time the user types.
|
|
20
|
+
*/ export function useQueryState(props) {
|
|
21
|
+
const { onChange, value } = props;
|
|
22
|
+
// Local copy of the query's value
|
|
23
|
+
const [query, setQuery] = useState(value.query || '');
|
|
24
|
+
// This is basically "getDerivedStateFromProps" to make sure if spec's value changes external to this component,
|
|
25
|
+
// we render with the latest value
|
|
26
|
+
const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);
|
|
27
|
+
if (value.query !== lastSyncedQuery) {
|
|
28
|
+
setQuery(value.query || '');
|
|
29
|
+
setLastSyncedQuery(value.query);
|
|
30
|
+
}
|
|
31
|
+
// Update our local state's copy as the user types
|
|
32
|
+
const handleQueryChange = (e)=>{
|
|
33
|
+
setQuery(e);
|
|
34
|
+
};
|
|
35
|
+
// Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the
|
|
36
|
+
// PanelPreview
|
|
37
|
+
const handleQueryBlur = ()=>{
|
|
38
|
+
setLastSyncedQuery(query);
|
|
39
|
+
onChange(produce(value, (draft)=>{
|
|
40
|
+
draft.query = query;
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
query,
|
|
45
|
+
handleQueryChange,
|
|
46
|
+
handleQueryBlur
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=query-editor-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/queries/query-editor-model.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 { useState } from 'react';\nimport { produce } from 'immer';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\n/**\n * Generic type for any ClickHouse query spec that has a query field\n */\ntype ClickHouseQuerySpec = {\n query?: string;\n};\n\n/**\n * A hook for managing the `query` state in ClickHouse query specs. Returns the `query` value, along with\n * `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those\n * changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview\n * every time the user types.\n */\nexport function useQueryState<T extends ClickHouseQuerySpec>(props: OptionsEditorProps<T>): {\n query: string;\n handleQueryChange: (e: string) => void;\n handleQueryBlur: () => void;\n} {\n const { onChange, value } = props;\n\n // Local copy of the query's value\n const [query, setQuery] = useState(value.query || '');\n\n // This is basically \"getDerivedStateFromProps\" to make sure if spec's value changes external to this component,\n // we render with the latest value\n const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);\n if (value.query !== lastSyncedQuery) {\n setQuery(value.query || '');\n setLastSyncedQuery(value.query);\n }\n\n // Update our local state's copy as the user types\n const handleQueryChange = (e: string): void => {\n setQuery(e);\n };\n\n // Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the\n // PanelPreview\n const handleQueryBlur = (): void => {\n setLastSyncedQuery(query);\n onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n return { query, handleQueryChange, handleQueryBlur };\n}\n"],"names":["useState","produce","useQueryState","props","onChange","value","query","setQuery","lastSyncedQuery","setLastSyncedQuery","handleQueryChange","e","handleQueryBlur","draft"],"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,QAAQ,QAAQ,QAAQ;AACjC,SAASC,OAAO,QAAQ,QAAQ;AAUhC;;;;;CAKC,GACD,OAAO,SAASC,cAA6CC,KAA4B;IAKvF,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAE5B,kCAAkC;IAClC,MAAM,CAACG,OAAOC,SAAS,GAAGP,SAASK,MAAMC,KAAK,IAAI;IAElD,gHAAgH;IAChH,kCAAkC;IAClC,MAAM,CAACE,iBAAiBC,mBAAmB,GAAGT,SAASK,MAAMC,KAAK;IAClE,IAAID,MAAMC,KAAK,KAAKE,iBAAiB;QACnCD,SAASF,MAAMC,KAAK,IAAI;QACxBG,mBAAmBJ,MAAMC,KAAK;IAChC;IAEA,kDAAkD;IAClD,MAAMI,oBAAoB,CAACC;QACzBJ,SAASI;IACX;IAEA,iHAAiH;IACjH,eAAe;IACf,MAAMC,kBAAkB;QACtBH,mBAAmBH;QACnBF,SACEH,QAAQI,OAAO,CAACQ;YACdA,MAAMP,KAAK,GAAGA;QAChB;IAEJ;IAEA,OAAO;QAAEA;QAAOI;QAAmBE;IAAgB;AACrD"}
|
package/mf-manifest.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "ClickHouse",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.
|
|
8
|
+
"buildVersion": "0.2.0",
|
|
9
9
|
"buildName": "@perses-dev/clickhouse-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/ClickHouse.
|
|
12
|
+
"name": "__mf/js/ClickHouse.f6211ab5.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"globalName": "ClickHouse",
|
|
23
23
|
"pluginVersion": "0.19.1",
|
|
24
24
|
"prefetchInterface": false,
|
|
25
|
-
"
|
|
25
|
+
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/ClickHouse/\"; }"
|
|
26
26
|
},
|
|
27
27
|
"shared": [
|
|
28
28
|
{
|
|
@@ -343,12 +343,12 @@
|
|
|
343
343
|
"__mf/js/async/__federation_expose_ClickHouseDatasource.1ef730b1.js"
|
|
344
344
|
],
|
|
345
345
|
"async": [
|
|
346
|
-
"__mf/js/async/
|
|
346
|
+
"__mf/js/async/282.76b8b044.js",
|
|
347
347
|
"__mf/js/async/2448.e42be954.js",
|
|
348
348
|
"__mf/js/async/2114.27f707a0.js",
|
|
349
|
-
"__mf/js/async/
|
|
350
|
-
"__mf/js/async/
|
|
351
|
-
"__mf/js/async/
|
|
349
|
+
"__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.12307d25.js",
|
|
350
|
+
"__mf/js/async/__federation_expose_ClickHouseLogQuery.4c608fd8.js",
|
|
351
|
+
"__mf/js/async/2226.332707ca.js",
|
|
352
352
|
"__mf/js/async/6467.f4e5b898.js",
|
|
353
353
|
"__mf/js/async/3632.f88c5ced.js",
|
|
354
354
|
"__mf/js/async/4168.af4fa8b3.js",
|
|
@@ -382,13 +382,13 @@
|
|
|
382
382
|
"assets": {
|
|
383
383
|
"js": {
|
|
384
384
|
"sync": [
|
|
385
|
+
"__mf/js/async/282.76b8b044.js",
|
|
385
386
|
"__mf/js/async/2448.e42be954.js",
|
|
386
387
|
"__mf/js/async/2114.27f707a0.js",
|
|
387
|
-
"__mf/js/async/
|
|
388
|
-
"__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.a3f88e6b.js"
|
|
388
|
+
"__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.12307d25.js"
|
|
389
389
|
],
|
|
390
390
|
"async": [
|
|
391
|
-
"__mf/js/async/
|
|
391
|
+
"__mf/js/async/2226.332707ca.js",
|
|
392
392
|
"__mf/js/async/6467.f4e5b898.js",
|
|
393
393
|
"__mf/js/async/2448.e42be954.js",
|
|
394
394
|
"__mf/js/async/3632.f88c5ced.js",
|
|
@@ -423,13 +423,13 @@
|
|
|
423
423
|
"assets": {
|
|
424
424
|
"js": {
|
|
425
425
|
"sync": [
|
|
426
|
+
"__mf/js/async/282.76b8b044.js",
|
|
426
427
|
"__mf/js/async/2448.e42be954.js",
|
|
427
428
|
"__mf/js/async/2114.27f707a0.js",
|
|
428
|
-
"__mf/js/async/
|
|
429
|
-
"__mf/js/async/__federation_expose_ClickHouseLogQuery.3f312752.js"
|
|
429
|
+
"__mf/js/async/__federation_expose_ClickHouseLogQuery.4c608fd8.js"
|
|
430
430
|
],
|
|
431
431
|
"async": [
|
|
432
|
-
"__mf/js/async/
|
|
432
|
+
"__mf/js/async/2226.332707ca.js",
|
|
433
433
|
"__mf/js/async/6467.f4e5b898.js",
|
|
434
434
|
"__mf/js/async/2448.e42be954.js",
|
|
435
435
|
"__mf/js/async/3632.f88c5ced.js",
|
|
@@ -472,17 +472,17 @@
|
|
|
472
472
|
"__mf/js/async/__federation_expose_Logs.88d56eeb.js"
|
|
473
473
|
],
|
|
474
474
|
"async": [
|
|
475
|
-
"__mf/js/async/
|
|
475
|
+
"__mf/js/async/282.76b8b044.js",
|
|
476
|
+
"__mf/js/async/2448.e42be954.js",
|
|
477
|
+
"__mf/js/async/2114.27f707a0.js",
|
|
478
|
+
"__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.12307d25.js",
|
|
479
|
+
"__mf/js/async/__federation_expose_ClickHouseLogQuery.4c608fd8.js",
|
|
480
|
+
"__mf/js/async/2226.332707ca.js",
|
|
476
481
|
"__mf/js/async/7376.c01a7f82.js",
|
|
477
482
|
"__mf/js/async/6714.e4b5281a.js",
|
|
478
483
|
"__mf/js/async/56.9997e6f8.js",
|
|
479
484
|
"__mf/js/async/3431.54fb88df.js",
|
|
480
485
|
"__mf/js/async/9654.ab803765.js",
|
|
481
|
-
"__mf/js/async/2114.27f707a0.js",
|
|
482
|
-
"__mf/js/async/2448.e42be954.js",
|
|
483
|
-
"__mf/js/async/8709.6d909ac5.js",
|
|
484
|
-
"__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.a3f88e6b.js",
|
|
485
|
-
"__mf/js/async/__federation_expose_ClickHouseLogQuery.3f312752.js",
|
|
486
486
|
"__mf/js/async/4238.8c8282dc.js",
|
|
487
487
|
"__mf/js/async/3224.5735a223.js",
|
|
488
488
|
"__mf/js/async/2292.248bd1ea.js",
|