@perses-dev/clickhouse-plugin 0.4.0 → 0.5.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/__mf/js/ClickHouse.dccd3adc.js +6 -0
- package/__mf/js/async/1616.d273c2a4.js +1 -0
- package/__mf/js/async/1728.c2466af2.js +1 -0
- package/__mf/js/async/1811.e34f9555.js +101 -0
- package/__mf/js/async/1825.3b06cbc6.js +1 -0
- package/__mf/js/async/1969.41d665ea.js +1 -0
- package/__mf/js/async/2043.827fc525.js +2 -0
- package/__mf/js/async/2386.9589aa86.js +2 -0
- package/__mf/js/async/3059.33197202.js +1 -0
- package/__mf/js/async/3181.b9a8c5ee.js +2 -0
- package/__mf/js/async/392.a87802dc.js +2 -0
- package/__mf/js/async/{1964.dccce52b.js → 4121.437b34db.js} +2 -2
- package/__mf/js/async/{2651.3bdd6b21.js → 5002.5959f718.js} +1 -1
- package/__mf/js/async/5071.c665fc3d.js +1 -0
- package/__mf/js/async/54.0abd57b9.js +22 -0
- package/__mf/js/async/5440.79b13afe.js +2 -0
- package/__mf/js/async/{6377.6c8c4e15.js.LICENSE.txt → 5440.79b13afe.js.LICENSE.txt} +3 -3
- package/__mf/js/async/{5214.d1943ccc.js → 5587.caa53d74.js} +1 -1
- package/__mf/js/async/6045.424732f1.js +1 -0
- package/__mf/js/async/6274.0299ceca.js +2 -0
- package/__mf/js/async/6283.18a07ff0.js +2 -0
- package/__mf/js/async/6796.c1c2e96e.js +7 -0
- package/__mf/js/async/{8488.16a69ea5.js → 7177.661c72fd.js} +1 -1
- package/__mf/js/async/7192.738bb7d0.js +1 -0
- package/__mf/js/async/7370.aa412eb8.js +2 -0
- package/__mf/js/async/7576.d8b258ff.js +2 -0
- package/__mf/js/async/7968.d7870d30.js +1 -0
- package/__mf/js/async/7978.a9ba54ff.js +1 -0
- package/__mf/js/async/8356.1990f800.js +1 -0
- package/__mf/js/async/8470.12101f38.js +2 -0
- package/__mf/js/async/8482.f99a0f22.js +1 -0
- package/__mf/js/async/873.0b522a3c.js +1 -0
- package/__mf/js/async/9010.7167d3a9.js +2 -0
- package/__mf/js/async/9071.8c641d07.js +2 -0
- package/__mf/js/async/9235.239f5888.js +1 -0
- package/__mf/js/async/9249.f40b0225.js +1 -0
- package/__mf/js/async/941.62a2fd61.js +2 -0
- package/__mf/js/async/9588.643512c3.js +1 -0
- package/__mf/js/async/9754.9efd83f1.js +10 -0
- package/__mf/js/async/9836.4cd749fe.js +1 -0
- package/__mf/js/async/9877.c85206cb.js +38 -0
- package/__mf/js/async/__federation_expose_ClickHouseDatasource.0bdc8df0.js +2 -0
- package/__mf/js/async/__federation_expose_ClickHouseLogQuery.1e3e609a.js +20 -0
- package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.e60dd445.js +20 -0
- package/__mf/js/main.eadf8672.js +6 -0
- package/lib/bootstrap.js +2 -2
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/bootstrap.js +1 -1
- package/lib/cjs/components/ClickQLEditor.js +1 -1
- package/lib/cjs/components/constants.js +1 -1
- package/lib/cjs/components/index.js +1 -1
- package/lib/cjs/datasources/click-house-datasource/ClickHouseDatasource.js +2 -2
- package/lib/cjs/datasources/click-house-datasource/ClickHouseDatasourceEditor.js +1 -1
- package/lib/cjs/datasources/click-house-datasource/click-house-datasource-types.js +1 -1
- package/lib/cjs/datasources/click-house-datasource/index.js +1 -1
- package/lib/cjs/datasources/index.js +1 -1
- package/lib/cjs/env.d.js +1 -1
- package/lib/cjs/getPluginModule.js +1 -1
- package/lib/cjs/index-federation.js +12 -12
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/model/click-house-client.js +1 -1
- package/lib/cjs/model/click-house-data-types.js +1 -1
- package/lib/cjs/queries/click-house-log-query/ClickHouseLogQuery.js +1 -1
- package/lib/cjs/queries/click-house-log-query/ClickHouseLogQueryEditor.js +1 -1
- package/lib/cjs/queries/click-house-log-query/click-house-log-query-types.js +1 -1
- package/lib/cjs/queries/click-house-log-query/get-click-house-log-data.js +4 -4
- package/lib/cjs/queries/click-house-log-query/index.js +1 -1
- package/lib/cjs/queries/click-house-log-query/log-query-plugin-interface.js +12 -0
- package/lib/cjs/queries/click-house-time-series-query/ClickHouseQuery.js +1 -1
- package/lib/cjs/queries/click-house-time-series-query/ClickHouseQueryEditor.js +1 -1
- package/lib/cjs/queries/click-house-time-series-query/click-house-query-types.js +1 -1
- package/lib/cjs/queries/click-house-time-series-query/get-click-house-data.js +4 -3
- package/lib/cjs/queries/click-house-time-series-query/index.js +1 -1
- package/lib/cjs/queries/constants.js +4 -4
- package/lib/cjs/queries/index.js +1 -1
- package/lib/cjs/queries/query-editor-model.js +1 -1
- package/lib/cjs/setup-tests.js +1 -1
- package/lib/components/ClickQLEditor.js +2 -2
- package/lib/components/ClickQLEditor.js.map +1 -1
- package/lib/components/constants.js +1 -1
- package/lib/components/constants.js.map +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/index.js.map +1 -1
- package/lib/datasources/click-house-datasource/ClickHouseDatasource.d.ts.map +1 -1
- package/lib/datasources/click-house-datasource/ClickHouseDatasource.js +2 -2
- package/lib/datasources/click-house-datasource/ClickHouseDatasource.js.map +1 -1
- package/lib/datasources/click-house-datasource/ClickHouseDatasourceEditor.js +2 -2
- package/lib/datasources/click-house-datasource/ClickHouseDatasourceEditor.js.map +1 -1
- package/lib/datasources/click-house-datasource/click-house-datasource-types.d.ts +1 -1
- package/lib/datasources/click-house-datasource/click-house-datasource-types.d.ts.map +1 -1
- package/lib/datasources/click-house-datasource/click-house-datasource-types.js +1 -1
- package/lib/datasources/click-house-datasource/click-house-datasource-types.js.map +1 -1
- package/lib/datasources/click-house-datasource/index.js +1 -1
- package/lib/datasources/click-house-datasource/index.js.map +1 -1
- package/lib/datasources/index.js +1 -1
- package/lib/datasources/index.js.map +1 -1
- package/lib/env.d.js +1 -1
- package/lib/env.d.js.map +1 -1
- package/lib/getPluginModule.js +1 -1
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index-federation.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/model/click-house-client.d.ts +1 -1
- package/lib/model/click-house-client.d.ts.map +1 -1
- package/lib/model/click-house-client.js +1 -1
- package/lib/model/click-house-client.js.map +1 -1
- package/lib/model/click-house-data-types.d.ts.map +1 -1
- package/lib/model/click-house-data-types.js +1 -1
- package/lib/model/click-house-data-types.js.map +1 -1
- package/lib/queries/click-house-log-query/ClickHouseLogQuery.js +1 -1
- package/lib/queries/click-house-log-query/ClickHouseLogQuery.js.map +1 -1
- package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.js +2 -2
- package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.js.map +1 -1
- package/lib/queries/click-house-log-query/click-house-log-query-types.js +1 -1
- package/lib/queries/click-house-log-query/click-house-log-query-types.js.map +1 -1
- package/lib/queries/click-house-log-query/get-click-house-log-data.d.ts.map +1 -1
- package/lib/queries/click-house-log-query/get-click-house-log-data.js +4 -4
- package/lib/queries/click-house-log-query/get-click-house-log-data.js.map +1 -1
- package/lib/queries/click-house-log-query/index.js +1 -1
- package/lib/queries/click-house-log-query/index.js.map +1 -1
- 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 +12 -0
- package/lib/queries/click-house-log-query/log-query-plugin-interface.js.map +1 -1
- package/lib/queries/click-house-time-series-query/ClickHouseQuery.js +1 -1
- package/lib/queries/click-house-time-series-query/ClickHouseQuery.js.map +1 -1
- package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.js +2 -2
- package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.js.map +1 -1
- package/lib/queries/click-house-time-series-query/click-house-query-types.d.ts +1 -1
- package/lib/queries/click-house-time-series-query/click-house-query-types.d.ts.map +1 -1
- package/lib/queries/click-house-time-series-query/click-house-query-types.js +1 -1
- package/lib/queries/click-house-time-series-query/click-house-query-types.js.map +1 -1
- package/lib/queries/click-house-time-series-query/get-click-house-data.d.ts.map +1 -1
- package/lib/queries/click-house-time-series-query/get-click-house-data.js +4 -3
- package/lib/queries/click-house-time-series-query/get-click-house-data.js.map +1 -1
- package/lib/queries/click-house-time-series-query/index.js +1 -1
- package/lib/queries/click-house-time-series-query/index.js.map +1 -1
- package/lib/queries/constants.js +1 -1
- package/lib/queries/constants.js.map +1 -1
- package/lib/queries/index.js +1 -1
- package/lib/queries/index.js.map +1 -1
- package/lib/queries/query-editor-model.d.ts.map +1 -1
- package/lib/queries/query-editor-model.js +1 -1
- package/lib/queries/query-editor-model.js.map +1 -1
- package/lib/setup-tests.js +1 -1
- package/lib/setup-tests.js.map +1 -1
- package/mf-manifest.json +86 -86
- package/mf-stats.json +86 -86
- package/package.json +7 -6
- package/__mf/js/ClickHouse.fef0738b.js +0 -5
- package/__mf/js/async/1360.33f7e672.js +0 -10
- package/__mf/js/async/1398.f2193c83.js +0 -2
- package/__mf/js/async/1580.5bd6ed40.js +0 -2
- package/__mf/js/async/2114.27f707a0.js +0 -1
- package/__mf/js/async/2226.1d4436dc.js +0 -1
- package/__mf/js/async/2292.248bd1ea.js +0 -2
- package/__mf/js/async/2652.fd27ec3f.js +0 -101
- package/__mf/js/async/282.76b8b044.js +0 -1
- package/__mf/js/async/3224.5735a223.js +0 -1
- package/__mf/js/async/3431.54fb88df.js +0 -1
- package/__mf/js/async/3863.70d46fa8.js +0 -2
- package/__mf/js/async/3960.e0eb27f3.js +0 -2
- package/__mf/js/async/3980.2a6bea70.js +0 -2
- package/__mf/js/async/4075.b85e5581.js +0 -1
- package/__mf/js/async/4238.a8170f41.js +0 -1
- package/__mf/js/async/4269.a389e8c6.js +0 -2
- package/__mf/js/async/4421.d9d48d4f.js +0 -1
- package/__mf/js/async/4557.aa037aea.js +0 -2
- package/__mf/js/async/4676.cae72135.js +0 -22
- package/__mf/js/async/5409.c4876520.js +0 -1
- package/__mf/js/async/58.c1431e49.js +0 -2
- package/__mf/js/async/5981.f3abf3c8.js +0 -2
- package/__mf/js/async/6134.a0f2d3c5.js +0 -38
- package/__mf/js/async/6292.4311054b.js +0 -1
- package/__mf/js/async/6333.dfeaf029.js +0 -2
- package/__mf/js/async/6377.6c8c4e15.js +0 -2
- package/__mf/js/async/6770.e50c0d08.js +0 -1
- package/__mf/js/async/694.c93f9cdf.js +0 -1
- package/__mf/js/async/7376.c01a7f82.js +0 -1
- package/__mf/js/async/738.0cdf47b4.js +0 -1
- package/__mf/js/async/7740.b3df297f.js +0 -1
- package/__mf/js/async/7797.36d938e5.js +0 -1
- package/__mf/js/async/7991.11320a4d.js +0 -7
- package/__mf/js/async/8216.44c6334e.js +0 -1
- package/__mf/js/async/9173.90ba4f20.js +0 -2
- package/__mf/js/async/__federation_expose_ClickHouseDatasource.b909c7ef.js +0 -2
- package/__mf/js/async/__federation_expose_ClickHouseLogQuery.8e9aa83b.js +0 -20
- package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.b3723b8b.js +0 -20
- package/__mf/js/main.56f92cce.js +0 -5
- /package/__mf/css/async/{1580.d3010b86.css → 3061.d3010b86.css} +0 -0
- /package/__mf/css/async/{2341.d3010b86.css → 7370.d3010b86.css} +0 -0
- /package/__mf/js/async/{2292.248bd1ea.js.LICENSE.txt → 2043.827fc525.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1398.f2193c83.js.LICENSE.txt → 2386.9589aa86.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1580.5bd6ed40.js.LICENSE.txt → 3181.b9a8c5ee.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5981.f3abf3c8.js.LICENSE.txt → 392.a87802dc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1964.dccce52b.js.LICENSE.txt → 4121.437b34db.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4676.cae72135.js.LICENSE.txt → 54.0abd57b9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3960.e0eb27f3.js.LICENSE.txt → 6274.0299ceca.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3980.2a6bea70.js.LICENSE.txt → 6283.18a07ff0.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7991.11320a4d.js.LICENSE.txt → 6796.c1c2e96e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3863.70d46fa8.js.LICENSE.txt → 7370.aa412eb8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{58.c1431e49.js.LICENSE.txt → 7576.d8b258ff.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9173.90ba4f20.js.LICENSE.txt → 8470.12101f38.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4557.aa037aea.js.LICENSE.txt → 9010.7167d3a9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4269.a389e8c6.js.LICENSE.txt → 9071.8c641d07.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6333.dfeaf029.js.LICENSE.txt → 941.62a2fd61.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1360.33f7e672.js.LICENSE.txt → 9754.9efd83f1.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseDatasource.b909c7ef.js.LICENSE.txt → __federation_expose_ClickHouseDatasource.0bdc8df0.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseLogQuery.8e9aa83b.js.LICENSE.txt → __federation_expose_ClickHouseLogQuery.1e3e609a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseTimeSeriesQuery.b3723b8b.js.LICENSE.txt → __federation_expose_ClickHouseTimeSeriesQuery.e60dd445.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-log-query/log-query-plugin-interface.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-log-query/log-query-plugin-interface.ts"],"sourcesContent":["// Copyright 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 { AbsoluteTimeRange, UnknownSpec, LogData } from '@perses-dev/core';\nimport { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';\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}\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":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAuBjC,WAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQuery.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQuery.tsx"],"sourcesContent":["// Copyright 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 { TimeSeriesQueryPlugin, parseVariables } from '@perses-dev/plugin-system';\nimport { getTimeSeriesData } from './get-click-house-data';\nimport { ClickHouseTimeSeriesQueryEditor } from './ClickHouseQueryEditor';\nimport { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types';\n\nexport const ClickHouseTimeSeriesQuery: TimeSeriesQueryPlugin<ClickHouseTimeSeriesQuerySpec> = {\n getTimeSeriesData,\n OptionsEditorComponent: ClickHouseTimeSeriesQueryEditor,\n createInitialOptions: () => ({ query: '' }),\n dependsOn: (spec) => {\n const queryVariables = parseVariables(spec.query);\n const allVariables = [...new Set([...queryVariables])];\n return {\n variables: allVariables,\n };\n },\n};\n"],"names":["parseVariables","getTimeSeriesData","ClickHouseTimeSeriesQueryEditor","ClickHouseTimeSeriesQuery","OptionsEditorComponent","createInitialOptions","query","dependsOn","spec","queryVariables","allVariables","Set","variables"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAgCA,cAAc,QAAQ,4BAA4B;AAClF,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,+BAA+B,QAAQ,0BAA0B;AAG1E,OAAO,MAAMC,4BAAkF;IAC7FF;IACAG,wBAAwBF;IACxBG,sBAAsB,IAAO,CAAA;YAAEC,OAAO;QAAG,CAAA;IACzCC,WAAW,CAACC;QACV,MAAMC,iBAAiBT,eAAeQ,KAAKF,KAAK;QAChD,MAAMI,eAAe;eAAI,IAAIC,IAAI;mBAAIF;aAAe;SAAE;QACtD,OAAO;YACLG,WAAWF;QACb;IACF;AACF,EAAE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
4
5
|
// You may obtain a copy of the License at
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system';
|
|
15
15
|
import { useCallback } from 'react';
|
|
16
16
|
import { produce } from 'immer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx"],"sourcesContent":["// Copyright 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 { Stack } from '@mui/material';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { ClickQLEditor } from '../../components';\nimport { queryExample } from '../../components/constants';\nimport { useQueryState } from '../query-editor-model';\nimport { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types';\n\ntype ClickHouseTimeSeriesQueryEditorProps = OptionsEditorProps<ClickHouseTimeSeriesQuerySpec>;\n\nexport function ClickHouseTimeSeriesQueryEditor(props: ClickHouseTimeSeriesQueryEditorProps): ReactElement {\n const { onChange, value } = 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 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 onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n const handleClickHouseQueryChange = useCallback(\n (e: string) => {\n handleQueryChange(e);\n },\n [handleQueryChange]\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={handleQueryBlur}\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","Stack","DATASOURCE_KIND","DEFAULT_DATASOURCE","ClickQLEditor","queryExample","useQueryState","ClickHouseTimeSeriesQueryEditor","props","onChange","value","datasource","selectedDatasource","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","newDatasourceSelection","kind","draft","Error","handleQueryExecute","handleClickHouseQueryChange","e","examplesStyle","fontSize","color","backgroundColor","padding","borderRadius","fontFamily","whiteSpace","lineHeight","spacing","datasourcePluginKind","label","notched","onBlur","onKeyDown","event","key","ctrlKey","metaKey","preventDefault","placeholder","details","summary","style","cursor","marginBottom","div"],"mappings":";AAAA,+BAA+B;AAC/B,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,KAAK,QAAQ,gBAAgB;AACtC,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,eAAe;AACnE,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,aAAa,QAAQ,wBAAwB;AAKtD,OAAO,SAASC,gCAAgCC,KAA2C;IACzF,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAC5B,MAAM,EAAEG,UAAU,EAAE,GAAGD;IACvB,MAAME,qBAAqBD,cAAcR;IACzC,MAAM,EAAEU,KAAK,EAAEC,iBAAiB,EAAEC,eAAe,EAAE,GAAGT,cAAcE;IAEpE,MAAMQ,yBAA4D,CAACC;QACjE,IAAI,CAACnB,qBAAqBmB,2BAA2BA,uBAAuBC,IAAI,KAAKhB,iBAAiB;YACpGO,SACET,QAAQU,OAAO,CAACS;gBACdA,MAAMR,UAAU,GAAGM;YACrB;YAEF;QACF;QACA,MAAM,IAAIG,MAAM;IAClB;IAEA,6CAA6C;IAC7C,MAAMC,qBAAqB,CAACR;QAC1BJ,SACET,QAAQU,OAAO,CAACS;YACdA,MAAMN,KAAK,GAAGA;QAChB;IAEJ;IAEA,MAAMS,8BAA8BvB,YAClC,CAACwB;QACCT,kBAAkBS;IACpB,GACA;QAACT;KAAkB;IAGrB,MAAMU,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,KAACpC;gBACCqC,sBAAsBhC;gBACtBQ,OAAOE;gBACPH,UAAUO;gBACVmB,OAAM;gBACNC,OAAO;;0BAET,KAAChC;gBACCM,OAAOG;gBACPJ,UAAUa;gBACVe,QAAQtB;gBACRuB,WAAW,CAACC;oBACV,IAAIA,MAAMC,GAAG,KAAK,WAAYD,CAAAA,MAAME,OAAO,IAAIF,MAAMG,OAAO,AAAD,GAAI;wBAC7DH,MAAMI,cAAc;wBACpBtB,mBAAmBR;oBACrB;gBACF;gBACA+B,aAAY;;0BAGd,MAACC;;kCACC,KAACC;wBAAQC,OAAO;4BAAEC,QAAQ;4BAAWvB,UAAU;4BAAQC,OAAO;4BAAQuB,cAAc;wBAAM;kCAAG;;kCAG7F,KAACC;wBAAIH,OAAOvB;kCAAgBnB;;;;;;AAIpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click-house-query-types.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-time-series-query/click-house-query-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC;AAGD,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"click-house-query-types.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-time-series-query/click-house-query-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC;AAGD,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/click-house-query-types.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/click-house-query-types.ts"],"sourcesContent":["// Copyright 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 { DatasourceSelector } from '@perses-dev/core';\n\nexport interface ClickHouseTimeSeriesQuerySpec {\n query: string;\n datasource?: DatasourceSelector;\n}\n\n// TODO: import this type from your datasource or an existing datasource plugin\nexport type DatasourceQueryResponse = {\n status: string;\n data: unknown;\n warnings?: string[];\n};\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC,+EAA+E;AAC/E,WAIE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-click-house-data.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-time-series-query/get-click-house-data.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"get-click-house-data.d.ts","sourceRoot":"","sources":["../../../../src/queries/click-house-time-series-query/get-click-house-data.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,2BAA2B,CAAC;AAIpF,OAAO,EAAE,6BAA6B,EAA2B,MAAM,2BAA2B,CAAC;AAsBnG,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CA8BvG,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
import { replaceVariables } from '@perses-dev/plugin-system';
|
|
14
14
|
import { DEFAULT_DATASOURCE } from '../constants';
|
|
15
15
|
function buildTimeSeries(response) {
|
|
16
|
-
|
|
16
|
+
const data = response?.data;
|
|
17
|
+
if (!response || !data || data.length === 0) {
|
|
17
18
|
return [];
|
|
18
19
|
}
|
|
19
|
-
const values =
|
|
20
|
+
const values = data.map((row)=>{
|
|
20
21
|
const timestamp = new Date(row.time).getTime();
|
|
21
22
|
const value = Number(row.log_count);
|
|
22
23
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/get-click-house-data.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/get-click-house-data.ts"],"sourcesContent":["// Copyright 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 { TimeSeries } from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system';\nimport { DEFAULT_DATASOURCE } from '../constants';\nimport { TimeSeriesEntry } from '../../model/click-house-data-types';\nimport { ClickHouseClient, ClickHouseQueryResponse } from '../../model/click-house-client';\nimport { ClickHouseTimeSeriesQuerySpec, DatasourceQueryResponse } from './click-house-query-types';\n\nfunction buildTimeSeries(response?: DatasourceQueryResponse): TimeSeries[] {\n const data = response?.data as TimeSeriesEntry[];\n if (!response || !data || data.length === 0) {\n return [];\n }\n\n const values: Array<[number, number]> = data.map((row: TimeSeriesEntry) => {\n const timestamp = new Date(row.time).getTime();\n const value = Number(row.log_count);\n return [timestamp, value];\n });\n\n return [\n {\n name: 'log_count',\n values,\n },\n ];\n}\n\nexport const getTimeSeriesData: TimeSeriesQueryPlugin<ClickHouseTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context\n) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n return { series: [] };\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 series: buildTimeSeries(response),\n timeRange: { start, end },\n stepMs: 30 * 1000,\n metadata: {\n executedQueryString: query,\n },\n };\n};\n"],"names":["replaceVariables","DEFAULT_DATASOURCE","buildTimeSeries","response","data","length","values","map","row","timestamp","Date","time","getTime","value","Number","log_count","name","getTimeSeriesData","spec","context","query","undefined","series","variableState","client","datasourceStore","getDatasourceClient","datasource","start","end","timeRange","toString","stepMs","metadata","executedQueryString"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAAgCA,gBAAgB,QAAQ,4BAA4B;AACpF,SAASC,kBAAkB,QAAQ,eAAe;AAKlD,SAASC,gBAAgBC,QAAkC;IACzD,MAAMC,OAAOD,UAAUC;IACvB,IAAI,CAACD,YAAY,CAACC,QAAQA,KAAKC,MAAM,KAAK,GAAG;QAC3C,OAAO,EAAE;IACX;IAEA,MAAMC,SAAkCF,KAAKG,GAAG,CAAC,CAACC;QAChD,MAAMC,YAAY,IAAIC,KAAKF,IAAIG,IAAI,EAAEC,OAAO;QAC5C,MAAMC,QAAQC,OAAON,IAAIO,SAAS;QAClC,OAAO;YAACN;YAAWI;SAAM;IAC3B;IAEA,OAAO;QACL;YACEG,MAAM;YACNV;QACF;KACD;AACH;AAEA,OAAO,MAAMW,oBAA+F,OAC1GC,MACAC;IAEA,IAAID,KAAKE,KAAK,KAAKC,aAAaH,KAAKE,KAAK,KAAK,QAAQF,KAAKE,KAAK,KAAK,IAAI;QACxE,OAAO;YAAEE,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMF,QAAQpB,iBAAiBkB,KAAKE,KAAK,EAAED,QAAQI,aAAa;IAEhE,MAAMC,SAAU,MAAML,QAAQM,eAAe,CAACC,mBAAmB,CAC/DR,KAAKS,UAAU,IAAI1B;IAGrB,MAAM,EAAE2B,KAAK,EAAEC,GAAG,EAAE,GAAGV,QAAQW,SAAS;IAExC,MAAM3B,WAAoC,MAAMqB,OAAOJ,KAAK,CAAC;QAC3DQ,OAAOA,MAAMhB,OAAO,GAAGmB,QAAQ;QAC/BF,KAAKA,IAAIjB,OAAO,GAAGmB,QAAQ;QAC3BX;IACF;IAEA,OAAO;QACLE,QAAQpB,gBAAgBC;QACxB2B,WAAW;YAAEF;YAAOC;QAAI;QACxBG,QAAQ,KAAK;QACbC,UAAU;YACRC,qBAAqBd;QACvB;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/index.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/click-house-time-series-query/index.ts"],"sourcesContent":["// Copyright 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 * from './get-click-house-data';\nexport * from './ClickHouseQuery';\nexport * from './ClickHouseQueryEditor';\nexport * from './click-house-query-types';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,4BAA4B"}
|
package/lib/queries/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/queries/constants.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/queries/constants.ts"],"sourcesContent":["// Copyright 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 const DATASOURCE_KIND = 'ClickHouseDatasource';\nexport const DEFAULT_DATASOURCE = { kind: DATASOURCE_KIND };\n"],"names":["DATASOURCE_KIND","DEFAULT_DATASOURCE","kind"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,kBAAkB,uBAAuB;AACtD,OAAO,MAAMC,qBAAqB;IAAEC,MAAMF;AAAgB,EAAE"}
|
package/lib/queries/index.js
CHANGED
package/lib/queries/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/queries/index.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/queries/index.ts"],"sourcesContent":["// Copyright 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 * from './click-house-time-series-query';\nexport * from './click-house-log-query';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kCAAkC;AAChD,cAAc,0BAA0B"}
|
|
@@ -1 +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,
|
|
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,EACzD,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CA+BA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/queries/query-editor-model.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/queries/query-editor-model.ts"],"sourcesContent":["// Copyright 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>(\n props: OptionsEditorProps<T>\n): {\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,+BAA+B;AAC/B,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,cACdC,KAA4B;IAM5B,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/lib/setup-tests.js
CHANGED
package/lib/setup-tests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
|