@perses-dev/clickhouse-plugin 0.6.0 → 0.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/__mf/js/{ClickHouse.4e6199f7.js → ClickHouse.d554fc35.js} +4 -4
  2. package/__mf/js/async/1522.d8e80570.js +22 -0
  3. package/__mf/js/async/1616.8ee37fc2.js +1 -0
  4. package/__mf/js/async/2043.33c976ff.js +2 -0
  5. package/__mf/js/async/2650.27d5a53e.js +3 -0
  6. package/__mf/js/async/2901.98424a07.js +1 -0
  7. package/__mf/js/async/3181.7b46b8e9.js +2 -0
  8. package/__mf/js/async/392.54a0693e.js +2 -0
  9. package/__mf/js/async/3944.f70c2037.js +10 -0
  10. package/__mf/js/async/4077.5b0edb67.js +1 -0
  11. package/__mf/js/async/4121.0b653ee5.js +2 -0
  12. package/__mf/js/async/4496.23de7e47.js +1 -0
  13. package/__mf/js/async/4569.ffd2c654.js +7 -0
  14. package/__mf/js/async/{6155.1398a410.js.LICENSE.txt → 4569.ffd2c654.js.LICENSE.txt} +41 -1
  15. package/__mf/js/async/5002.2cee2f35.js +1 -0
  16. package/__mf/js/async/5071.fe3eb282.js +1 -0
  17. package/__mf/js/async/5440.6cfd6f26.js +2 -0
  18. package/__mf/js/async/5562.c5ce26e1.js +2 -0
  19. package/__mf/js/async/5587.9797bc5a.js +1 -0
  20. package/__mf/js/async/560.acc0c2d1.js +37 -0
  21. package/__mf/js/async/6045.93765a0a.js +1 -0
  22. package/__mf/js/async/6274.35dc924b.js +2 -0
  23. package/__mf/js/async/7192.f4e0055e.js +1 -0
  24. package/__mf/js/async/7862.306edb3f.js +2 -0
  25. package/__mf/js/async/7943.a43cb4a7.js +2 -0
  26. package/__mf/js/async/7968.a73d7acd.js +1 -0
  27. package/__mf/js/async/7978.e22f59c6.js +1 -0
  28. package/__mf/js/async/8356.d102e817.js +1 -0
  29. package/__mf/js/async/8470.4652ca18.js +2 -0
  30. package/__mf/js/async/873.cae3f07a.js +1 -0
  31. package/__mf/js/async/9001.0b1d67e2.js +102 -0
  32. package/__mf/js/async/9207.b184be58.js +1 -0
  33. package/__mf/js/async/9235.0aff6249.js +1 -0
  34. package/__mf/js/async/941.26e4a6ef.js +2 -0
  35. package/__mf/js/async/9588.a36eacf5.js +1 -0
  36. package/__mf/js/async/__federation_expose_ClickHouseDatasource.1eba91f6.js +2 -0
  37. package/__mf/js/async/__federation_expose_ClickHouseLogQuery.27676311.js +20 -0
  38. package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.3d225a5d.js +20 -0
  39. package/__mf/js/{main.39993ad6.js → main.5353a8fc.js} +2 -2
  40. package/lib/bootstrap.js +2 -2
  41. package/lib/components/ClickQLEditor.d.ts +2 -2
  42. package/lib/components/ClickQLEditor.d.ts.map +1 -1
  43. package/lib/components/ClickQLEditor.js +3 -3
  44. package/lib/components/ClickQLEditor.js.map +1 -1
  45. package/lib/components/index.js +1 -1
  46. package/lib/components/index.js.map +1 -1
  47. package/lib/datasources/click-house-datasource/ClickHouseDatasource.d.ts +2 -2
  48. package/lib/datasources/click-house-datasource/ClickHouseDatasource.d.ts.map +1 -1
  49. package/lib/datasources/click-house-datasource/ClickHouseDatasource.js +2 -2
  50. package/lib/datasources/click-house-datasource/ClickHouseDatasource.js.map +1 -1
  51. package/lib/datasources/click-house-datasource/ClickHouseDatasourceEditor.d.ts +2 -2
  52. package/lib/datasources/click-house-datasource/ClickHouseDatasourceEditor.d.ts.map +1 -1
  53. package/lib/datasources/click-house-datasource/ClickHouseDatasourceEditor.js +1 -1
  54. package/lib/datasources/click-house-datasource/ClickHouseDatasourceEditor.js.map +1 -1
  55. package/lib/datasources/click-house-datasource/click-house-datasource-types.d.ts +3 -3
  56. package/lib/datasources/click-house-datasource/click-house-datasource-types.d.ts.map +1 -1
  57. package/lib/datasources/click-house-datasource/click-house-datasource-types.js.map +1 -1
  58. package/lib/datasources/click-house-datasource/index.js +3 -3
  59. package/lib/datasources/click-house-datasource/index.js.map +1 -1
  60. package/lib/datasources/index.js +1 -1
  61. package/lib/datasources/index.js.map +1 -1
  62. package/lib/getPluginModule.d.ts +1 -1
  63. package/lib/getPluginModule.d.ts.map +1 -1
  64. package/lib/getPluginModule.js +3 -1
  65. package/lib/getPluginModule.js.map +1 -1
  66. package/lib/index-federation.js +1 -1
  67. package/lib/index.js +3 -3
  68. package/lib/index.js.map +1 -1
  69. package/lib/model/click-house-client.d.ts +1 -1
  70. package/lib/model/click-house-client.d.ts.map +1 -1
  71. package/lib/model/click-house-client.js +3 -1
  72. package/lib/model/click-house-client.js.map +1 -1
  73. package/lib/model/click-house-data-types.d.ts +1 -1
  74. package/lib/model/click-house-data-types.d.ts.map +1 -1
  75. package/lib/model/click-house-data-types.js.map +1 -1
  76. package/lib/queries/click-house-log-query/ClickHouseLogQuery.d.ts +2 -2
  77. package/lib/queries/click-house-log-query/ClickHouseLogQuery.d.ts.map +1 -1
  78. package/lib/queries/click-house-log-query/ClickHouseLogQuery.js +4 -6
  79. package/lib/queries/click-house-log-query/ClickHouseLogQuery.js.map +1 -1
  80. package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.d.ts +3 -3
  81. package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.d.ts.map +1 -1
  82. package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.js +9 -9
  83. package/lib/queries/click-house-log-query/ClickHouseLogQueryEditor.js.map +1 -1
  84. package/lib/queries/click-house-log-query/click-house-log-query-types.d.ts +1 -1
  85. package/lib/queries/click-house-log-query/click-house-log-query-types.d.ts.map +1 -1
  86. package/lib/queries/click-house-log-query/click-house-log-query-types.js.map +1 -1
  87. package/lib/queries/click-house-log-query/get-click-house-log-data.d.ts +2 -2
  88. package/lib/queries/click-house-log-query/get-click-house-log-data.d.ts.map +1 -1
  89. package/lib/queries/click-house-log-query/get-click-house-log-data.js +4 -4
  90. package/lib/queries/click-house-log-query/get-click-house-log-data.js.map +1 -1
  91. package/lib/queries/click-house-log-query/index.js +4 -4
  92. package/lib/queries/click-house-log-query/index.js.map +1 -1
  93. package/lib/queries/click-house-time-series-query/ClickHouseQuery.d.ts +2 -2
  94. package/lib/queries/click-house-time-series-query/ClickHouseQuery.d.ts.map +1 -1
  95. package/lib/queries/click-house-time-series-query/ClickHouseQuery.js +4 -6
  96. package/lib/queries/click-house-time-series-query/ClickHouseQuery.js.map +1 -1
  97. package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.d.ts +3 -3
  98. package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.d.ts.map +1 -1
  99. package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.js +9 -9
  100. package/lib/queries/click-house-time-series-query/ClickHouseQueryEditor.js.map +1 -1
  101. package/lib/queries/click-house-time-series-query/click-house-query-types.d.ts +1 -1
  102. package/lib/queries/click-house-time-series-query/click-house-query-types.d.ts.map +1 -1
  103. package/lib/queries/click-house-time-series-query/click-house-query-types.js.map +1 -1
  104. package/lib/queries/click-house-time-series-query/get-click-house-data.d.ts +2 -2
  105. package/lib/queries/click-house-time-series-query/get-click-house-data.d.ts.map +1 -1
  106. package/lib/queries/click-house-time-series-query/get-click-house-data.js +5 -5
  107. package/lib/queries/click-house-time-series-query/get-click-house-data.js.map +1 -1
  108. package/lib/queries/click-house-time-series-query/index.js +4 -4
  109. package/lib/queries/click-house-time-series-query/index.js.map +1 -1
  110. package/lib/queries/index.js +2 -2
  111. package/lib/queries/index.js.map +1 -1
  112. package/lib/queries/query-editor-model.d.ts +1 -1
  113. package/lib/queries/query-editor-model.d.ts.map +1 -1
  114. package/lib/queries/query-editor-model.js +2 -2
  115. package/lib/queries/query-editor-model.js.map +1 -1
  116. package/lib/setup-tests.d.ts +1 -1
  117. package/lib/setup-tests.d.ts.map +1 -1
  118. package/lib/setup-tests.js +2 -2
  119. package/lib/setup-tests.js.map +1 -1
  120. package/mf-manifest.json +69 -98
  121. package/mf-stats.json +69 -102
  122. package/package.json +21 -13
  123. package/__mf/js/async/1616.c86fdd40.js +0 -1
  124. package/__mf/js/async/1728.a4ac7d54.js +0 -1
  125. package/__mf/js/async/1811.29b51780.js +0 -101
  126. package/__mf/js/async/1825.299edaf9.js +0 -1
  127. package/__mf/js/async/1969.ea0bd5b9.js +0 -1
  128. package/__mf/js/async/2043.13379b9d.js +0 -2
  129. package/__mf/js/async/2386.56de292b.js +0 -2
  130. package/__mf/js/async/3059.3d9dad23.js +0 -1
  131. package/__mf/js/async/3181.f3124eab.js +0 -2
  132. package/__mf/js/async/392.c8af2244.js +0 -2
  133. package/__mf/js/async/3981.9bd5679b.js +0 -3
  134. package/__mf/js/async/4121.b6afa425.js +0 -2
  135. package/__mf/js/async/4233.abbba3f6.js +0 -7
  136. package/__mf/js/async/4233.abbba3f6.js.LICENSE.txt +0 -39
  137. package/__mf/js/async/5002.9167d87e.js +0 -1
  138. package/__mf/js/async/5071.a039a221.js +0 -1
  139. package/__mf/js/async/5440.898ddc2f.js +0 -2
  140. package/__mf/js/async/5481.223427f5.js +0 -2
  141. package/__mf/js/async/5562.d4359565.js +0 -2
  142. package/__mf/js/async/5587.72383e00.js +0 -1
  143. package/__mf/js/async/599.e213c21c.js +0 -1
  144. package/__mf/js/async/6045.9b807b97.js +0 -1
  145. package/__mf/js/async/6155.1398a410.js +0 -2
  146. package/__mf/js/async/6274.22bd6f34.js +0 -2
  147. package/__mf/js/async/6688.abdc25f6.js +0 -2
  148. package/__mf/js/async/7177.96ff5c4d.js +0 -1
  149. package/__mf/js/async/7192.c1f998d2.js +0 -1
  150. package/__mf/js/async/7968.ae66f60b.js +0 -1
  151. package/__mf/js/async/7978.a58ed5ff.js +0 -1
  152. package/__mf/js/async/7984.549ad1a9.js +0 -22
  153. package/__mf/js/async/8356.eda63865.js +0 -1
  154. package/__mf/js/async/8470.3ae4fba1.js +0 -2
  155. package/__mf/js/async/873.e4ddcabf.js +0 -1
  156. package/__mf/js/async/9235.aeb9d818.js +0 -1
  157. package/__mf/js/async/941.11ea3ddf.js +0 -2
  158. package/__mf/js/async/9588.d09a1141.js +0 -1
  159. package/__mf/js/async/9754.9ea7778b.js +0 -10
  160. package/__mf/js/async/9836.75f99110.js +0 -1
  161. package/__mf/js/async/9877.8f08e12a.js +0 -38
  162. package/__mf/js/async/__federation_expose_ClickHouseDatasource.0e124aef.js +0 -2
  163. package/__mf/js/async/__federation_expose_ClickHouseLogQuery.605ad0d2.js +0 -20
  164. package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.a7927056.js +0 -20
  165. package/__mf/js/async/__federation_expose_ClickHouseTimeSeriesQuery.a7927056.js.LICENSE.txt +0 -9
  166. package/lib/cjs/bootstrap.js +0 -26
  167. package/lib/cjs/components/ClickQLEditor.js +0 -72
  168. package/lib/cjs/components/constants.js +0 -41
  169. package/lib/cjs/components/index.js +0 -30
  170. package/lib/cjs/datasources/click-house-datasource/ClickHouseDatasource.js +0 -49
  171. package/lib/cjs/datasources/click-house-datasource/ClickHouseDatasourceEditor.js +0 -51
  172. package/lib/cjs/datasources/click-house-datasource/click-house-datasource-types.js +0 -16
  173. package/lib/cjs/datasources/click-house-datasource/index.js +0 -32
  174. package/lib/cjs/datasources/index.js +0 -30
  175. package/lib/cjs/env.d.js +0 -14
  176. package/lib/cjs/getPluginModule.js +0 -39
  177. package/lib/cjs/index-federation.js +0 -55
  178. package/lib/cjs/index.js +0 -38
  179. package/lib/cjs/model/click-house-client.js +0 -83
  180. package/lib/cjs/model/click-house-data-types.js +0 -16
  181. package/lib/cjs/queries/click-house-log-query/ClickHouseLogQuery.js +0 -45
  182. package/lib/cjs/queries/click-house-log-query/ClickHouseLogQueryEditor.js +0 -104
  183. package/lib/cjs/queries/click-house-log-query/click-house-log-query-types.js +0 -16
  184. package/lib/cjs/queries/click-house-log-query/get-click-house-log-data.js +0 -93
  185. package/lib/cjs/queries/click-house-log-query/index.js +0 -33
  186. package/lib/cjs/queries/click-house-time-series-query/ClickHouseQuery.js +0 -43
  187. package/lib/cjs/queries/click-house-time-series-query/ClickHouseQueryEditor.js +0 -104
  188. package/lib/cjs/queries/click-house-time-series-query/click-house-query-types.js +0 -16
  189. package/lib/cjs/queries/click-house-time-series-query/get-click-house-data.js +0 -116
  190. package/lib/cjs/queries/click-house-time-series-query/index.js +0 -33
  191. package/lib/cjs/queries/constants.js +0 -34
  192. package/lib/cjs/queries/index.js +0 -31
  193. package/lib/cjs/queries/query-editor-model.js +0 -53
  194. package/lib/cjs/setup-tests.js +0 -19
  195. /package/__mf/css/async/{4233.85c2cbf6.css → 4569.85c2cbf6.css} +0 -0
  196. /package/__mf/js/async/{7984.549ad1a9.js.LICENSE.txt → 1522.d8e80570.js.LICENSE.txt} +0 -0
  197. /package/__mf/js/async/{2043.13379b9d.js.LICENSE.txt → 2043.33c976ff.js.LICENSE.txt} +0 -0
  198. /package/__mf/js/async/{2386.56de292b.js.LICENSE.txt → 3181.7b46b8e9.js.LICENSE.txt} +0 -0
  199. /package/__mf/js/async/{392.c8af2244.js.LICENSE.txt → 392.54a0693e.js.LICENSE.txt} +0 -0
  200. /package/__mf/js/async/{9754.9ea7778b.js.LICENSE.txt → 3944.f70c2037.js.LICENSE.txt} +0 -0
  201. /package/__mf/js/async/{4121.b6afa425.js.LICENSE.txt → 4121.0b653ee5.js.LICENSE.txt} +0 -0
  202. /package/__mf/js/async/{5440.898ddc2f.js.LICENSE.txt → 5440.6cfd6f26.js.LICENSE.txt} +0 -0
  203. /package/__mf/js/async/{3181.f3124eab.js.LICENSE.txt → 5562.c5ce26e1.js.LICENSE.txt} +0 -0
  204. /package/__mf/js/async/{6274.22bd6f34.js.LICENSE.txt → 6274.35dc924b.js.LICENSE.txt} +0 -0
  205. /package/__mf/js/async/{5481.223427f5.js.LICENSE.txt → 7862.306edb3f.js.LICENSE.txt} +0 -0
  206. /package/__mf/js/async/{5562.d4359565.js.LICENSE.txt → 7943.a43cb4a7.js.LICENSE.txt} +0 -0
  207. /package/__mf/js/async/{8470.3ae4fba1.js.LICENSE.txt → 8470.4652ca18.js.LICENSE.txt} +0 -0
  208. /package/__mf/js/async/{6688.abdc25f6.js.LICENSE.txt → 941.26e4a6ef.js.LICENSE.txt} +0 -0
  209. /package/__mf/js/async/{941.11ea3ddf.js.LICENSE.txt → __federation_expose_ClickHouseDatasource.1eba91f6.js.LICENSE.txt} +0 -0
  210. /package/__mf/js/async/{__federation_expose_ClickHouseDatasource.0e124aef.js.LICENSE.txt → __federation_expose_ClickHouseLogQuery.27676311.js.LICENSE.txt} +0 -0
  211. /package/__mf/js/async/{__federation_expose_ClickHouseLogQuery.605ad0d2.js.LICENSE.txt → __federation_expose_ClickHouseTimeSeriesQuery.3d225a5d.js.LICENSE.txt} +0 -0
@@ -1,104 +0,0 @@
1
- // Copyright 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, "ClickHouseLogQueryEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return ClickHouseLogQueryEditor;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _pluginsystem = require("@perses-dev/plugin-system");
25
- const _react = require("react");
26
- const _immer = require("immer");
27
- const _material = require("@mui/material");
28
- const _dashboards = require("@perses-dev/dashboards");
29
- const _constants = require("../constants");
30
- const _components = require("../../components");
31
- const _constants1 = require("../../components/constants");
32
- const _queryeditormodel = require("../query-editor-model");
33
- function ClickHouseLogQueryEditor(props) {
34
- const { onChange, value } = props;
35
- const { datasource } = value;
36
- const selectedDatasource = datasource ?? _constants.DEFAULT_DATASOURCE;
37
- const { query, handleQueryChange, handleQueryBlur } = (0, _queryeditormodel.useQueryState)(props);
38
- const handleDatasourceChange = (newDatasourceSelection)=>{
39
- if (!(0, _pluginsystem.isVariableDatasource)(newDatasourceSelection) && newDatasourceSelection.kind === _constants.DATASOURCE_KIND) {
40
- onChange((0, _immer.produce)(value, (draft)=>{
41
- draft.datasource = newDatasourceSelection;
42
- }));
43
- return;
44
- }
45
- throw new Error('Got unexpected non ClickHouse datasource selection');
46
- };
47
- // Immediate query execution on Enter or blur
48
- const handleQueryExecute = (query)=>{
49
- onChange((0, _immer.produce)(value, (draft)=>{
50
- draft.query = query;
51
- }));
52
- };
53
- const handleClickHouseQueryChange = (0, _react.useCallback)((e)=>{
54
- handleQueryChange(e);
55
- }, [
56
- handleQueryChange
57
- ]);
58
- const examplesStyle = {
59
- fontSize: '11px',
60
- color: '#777',
61
- backgroundColor: '#f5f5f5',
62
- padding: '8px',
63
- borderRadius: '4px',
64
- fontFamily: 'Monaco, Menlo, "Ubuntu Mono", monospace',
65
- whiteSpace: 'pre-wrap',
66
- lineHeight: '1.3'
67
- };
68
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
69
- spacing: 1.5,
70
- children: [
71
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
72
- datasourcePluginKind: _constants.DATASOURCE_KIND,
73
- value: selectedDatasource,
74
- onChange: handleDatasourceChange,
75
- label: "ClickHouse Datasource",
76
- notched: true
77
- }),
78
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ClickQLEditor, {
79
- value: query,
80
- onChange: handleClickHouseQueryChange,
81
- onBlur: handleQueryBlur,
82
- onKeyDown: (0, _dashboards.createModEnterHandler)(()=>handleQueryExecute(query)),
83
- placeholder: "Enter ClickHouse SQL query"
84
- }),
85
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("details", {
86
- children: [
87
- /*#__PURE__*/ (0, _jsxruntime.jsx)("summary", {
88
- style: {
89
- cursor: 'pointer',
90
- fontSize: '12px',
91
- color: '#666',
92
- marginBottom: '8px'
93
- },
94
- children: "Query Examples"
95
- }),
96
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
97
- style: examplesStyle,
98
- children: _constants1.queryExample
99
- })
100
- ]
101
- })
102
- ]
103
- });
104
- }
@@ -1,16 +0,0 @@
1
- // Copyright 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
- });
@@ -1,93 +0,0 @@
1
- // Copyright 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, "getClickHouseLogData", {
18
- enumerable: true,
19
- get: function() {
20
- return getClickHouseLogData;
21
- }
22
- });
23
- const _pluginsystem = require("@perses-dev/plugin-system");
24
- const _clickhouseclient = require("../../model/click-house-client");
25
- const _constants = require("../constants");
26
- function flattenObject(obj, parentKey = '', result = {}) {
27
- for (const [key, value] of Object.entries(obj)){
28
- const newKey = parentKey ? `${parentKey}.${key}` : key;
29
- if (value && typeof value === 'object' && !Array.isArray(value)) {
30
- flattenObject(value, newKey, result);
31
- } else {
32
- result[newKey] = value;
33
- }
34
- }
35
- return result;
36
- }
37
- function convertStreamsToLogs(streams) {
38
- const entries = streams.map((entry)=>{
39
- const flattened = flattenObject(entry);
40
- if (!flattened['Timestamp'] && flattened['log_time']) {
41
- flattened['Timestamp'] = flattened['log_time'];
42
- }
43
- const sortedEntry = {};
44
- Object.keys(flattened).sort((a, b)=>a.localeCompare(b)).forEach((key)=>{
45
- sortedEntry[key] = flattened[key];
46
- });
47
- const line = Object.entries(sortedEntry).filter(([key])=>key !== 'Timestamp').map(([key, value])=>`<${key}> ${value === '' || value === null || value === undefined ? '--' : value}`).join(' ');
48
- return {
49
- timestamp: sortedEntry?.['Timestamp'],
50
- labels: sortedEntry,
51
- line
52
- };
53
- });
54
- return {
55
- entries,
56
- totalCount: entries.length
57
- };
58
- }
59
- const getClickHouseLogData = async (spec, context)=>{
60
- if (spec.query === undefined || spec.query === null || spec.query === '') {
61
- return {
62
- logs: {
63
- entries: [],
64
- totalCount: 0
65
- },
66
- timeRange: {
67
- start: context.timeRange.start,
68
- end: context.timeRange.end
69
- }
70
- };
71
- }
72
- const query = (0, _pluginsystem.replaceVariables)(spec.query, context.variableState);
73
- const client = await context.datasourceStore.getDatasourceClient(spec.datasource ?? _constants.DEFAULT_DATASOURCE);
74
- const { start, end } = context.timeRange;
75
- const startTime = (0, _clickhouseclient.formatClickHouseDateTime)(start);
76
- const endTime = (0, _clickhouseclient.formatClickHouseDateTime)(end);
77
- const executedQueryString = (0, _clickhouseclient.replaceTimeRangePlaceholders)(query, startTime, endTime);
78
- const response = await client.query({
79
- start: startTime,
80
- end: endTime,
81
- query: executedQueryString
82
- });
83
- return {
84
- timeRange: {
85
- start,
86
- end
87
- },
88
- logs: convertStreamsToLogs(response.data),
89
- metadata: {
90
- executedQueryString
91
- }
92
- };
93
- };
@@ -1,33 +0,0 @@
1
- // Copyright 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
- _export_star(require("./ClickHouseLogQuery"), exports);
18
- _export_star(require("./ClickHouseLogQueryEditor"), exports);
19
- _export_star(require("./get-click-house-log-data"), exports);
20
- _export_star(require("./click-house-log-query-types"), exports);
21
- function _export_star(from, to) {
22
- Object.keys(from).forEach(function(k) {
23
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
24
- Object.defineProperty(to, k, {
25
- enumerable: true,
26
- get: function() {
27
- return from[k];
28
- }
29
- });
30
- }
31
- });
32
- return from;
33
- }
@@ -1,43 +0,0 @@
1
- // Copyright 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, "ClickHouseTimeSeriesQuery", {
18
- enumerable: true,
19
- get: function() {
20
- return ClickHouseTimeSeriesQuery;
21
- }
22
- });
23
- const _pluginsystem = require("@perses-dev/plugin-system");
24
- const _getclickhousedata = require("./get-click-house-data");
25
- const _ClickHouseQueryEditor = require("./ClickHouseQueryEditor");
26
- const ClickHouseTimeSeriesQuery = {
27
- getTimeSeriesData: _getclickhousedata.getTimeSeriesData,
28
- OptionsEditorComponent: _ClickHouseQueryEditor.ClickHouseTimeSeriesQueryEditor,
29
- createInitialOptions: ()=>({
30
- query: ''
31
- }),
32
- dependsOn: (spec)=>{
33
- const queryVariables = (0, _pluginsystem.parseVariables)(spec.query);
34
- const allVariables = [
35
- ...new Set([
36
- ...queryVariables
37
- ])
38
- ];
39
- return {
40
- variables: allVariables
41
- };
42
- }
43
- };
@@ -1,104 +0,0 @@
1
- // Copyright 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, "ClickHouseTimeSeriesQueryEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return ClickHouseTimeSeriesQueryEditor;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _pluginsystem = require("@perses-dev/plugin-system");
25
- const _react = require("react");
26
- const _immer = require("immer");
27
- const _material = require("@mui/material");
28
- const _dashboards = require("@perses-dev/dashboards");
29
- const _constants = require("../constants");
30
- const _components = require("../../components");
31
- const _constants1 = require("../../components/constants");
32
- const _queryeditormodel = require("../query-editor-model");
33
- function ClickHouseTimeSeriesQueryEditor(props) {
34
- const { onChange, value } = props;
35
- const { datasource } = value;
36
- const selectedDatasource = datasource ?? _constants.DEFAULT_DATASOURCE;
37
- const { query, handleQueryChange, handleQueryBlur } = (0, _queryeditormodel.useQueryState)(props);
38
- const handleDatasourceChange = (newDatasourceSelection)=>{
39
- if (!(0, _pluginsystem.isVariableDatasource)(newDatasourceSelection) && newDatasourceSelection.kind === _constants.DATASOURCE_KIND) {
40
- onChange((0, _immer.produce)(value, (draft)=>{
41
- draft.datasource = newDatasourceSelection;
42
- }));
43
- return;
44
- }
45
- throw new Error('Got unexpected non ClickHouse datasource selection');
46
- };
47
- // Immediate query execution on Enter or blur
48
- const handleQueryExecute = (query)=>{
49
- onChange((0, _immer.produce)(value, (draft)=>{
50
- draft.query = query;
51
- }));
52
- };
53
- const handleClickHouseQueryChange = (0, _react.useCallback)((e)=>{
54
- handleQueryChange(e);
55
- }, [
56
- handleQueryChange
57
- ]);
58
- const examplesStyle = {
59
- fontSize: '11px',
60
- color: '#777',
61
- backgroundColor: '#f5f5f5',
62
- padding: '8px',
63
- borderRadius: '4px',
64
- fontFamily: 'Monaco, Menlo, "Ubuntu Mono", monospace',
65
- whiteSpace: 'pre-wrap',
66
- lineHeight: '1.3'
67
- };
68
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
69
- spacing: 1.5,
70
- children: [
71
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
72
- datasourcePluginKind: _constants.DATASOURCE_KIND,
73
- value: selectedDatasource,
74
- onChange: handleDatasourceChange,
75
- label: "ClickHouse Datasource",
76
- notched: true
77
- }),
78
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ClickQLEditor, {
79
- value: query,
80
- onChange: handleClickHouseQueryChange,
81
- onBlur: handleQueryBlur,
82
- onKeyDown: (0, _dashboards.createModEnterHandler)(()=>handleQueryExecute(query)),
83
- placeholder: "Enter ClickHouse SQL query"
84
- }),
85
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("details", {
86
- children: [
87
- /*#__PURE__*/ (0, _jsxruntime.jsx)("summary", {
88
- style: {
89
- cursor: 'pointer',
90
- fontSize: '12px',
91
- color: '#666',
92
- marginBottom: '8px'
93
- },
94
- children: "Query Examples"
95
- }),
96
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
97
- style: examplesStyle,
98
- children: _constants1.queryExample
99
- })
100
- ]
101
- })
102
- ]
103
- });
104
- }
@@ -1,16 +0,0 @@
1
- // Copyright 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
- });
@@ -1,116 +0,0 @@
1
- // Copyright 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, "getTimeSeriesData", {
18
- enumerable: true,
19
- get: function() {
20
- return getTimeSeriesData;
21
- }
22
- });
23
- const _pluginsystem = require("@perses-dev/plugin-system");
24
- const _constants = require("../constants");
25
- const _clickhouseclient = require("../../model/click-house-client");
26
- const DEFAULT_STEP_MS = 30 * 1000;
27
- function buildTimeSeries(response) {
28
- const data = response?.data;
29
- if (!response || !data || data.length === 0) {
30
- return [];
31
- }
32
- const metricNames = Object.keys(data[0] ?? {}).filter((key)=>key !== 'time');
33
- return metricNames.map((metricName)=>{
34
- const values = data.map((row)=>{
35
- const timestamp = new Date(row.time).getTime();
36
- const value = toTimeSeriesValue(row[metricName]);
37
- return [
38
- timestamp,
39
- value
40
- ];
41
- });
42
- return {
43
- name: metricName,
44
- values
45
- };
46
- }).filter((series)=>series.values.some(([, value])=>value !== null));
47
- }
48
- function toTimeSeriesValue(value) {
49
- if (value === null || value === undefined || value === '') {
50
- return null;
51
- }
52
- const numericValue = Number(value);
53
- return Number.isFinite(numericValue) ? numericValue : null;
54
- }
55
- function inferStepMs(response) {
56
- const data = response?.data;
57
- if (!response || !data || data.length < 2) {
58
- return DEFAULT_STEP_MS;
59
- }
60
- const timestamps = data.map((row)=>new Date(row.time).getTime()).filter(Number.isFinite).sort((a, b)=>a - b);
61
- if (timestamps.length < 2) {
62
- return DEFAULT_STEP_MS;
63
- }
64
- const deltas = [];
65
- for(let i = 1; i < timestamps.length; i++){
66
- const previous = timestamps[i - 1];
67
- const current = timestamps[i];
68
- if (previous === undefined || current === undefined || current <= previous) {
69
- continue;
70
- }
71
- deltas.push(current - previous);
72
- }
73
- if (deltas.length === 0) {
74
- return DEFAULT_STEP_MS;
75
- }
76
- const deltaCounts = new Map();
77
- for (const delta of deltas){
78
- deltaCounts.set(delta, (deltaCounts.get(delta) ?? 0) + 1);
79
- }
80
- const inferredStep = Array.from(deltaCounts.entries()).sort(([deltaA, countA], [deltaB, countB])=>{
81
- if (countA !== countB) {
82
- return countB - countA;
83
- }
84
- return deltaB - deltaA;
85
- })[0]?.[0];
86
- return inferredStep ?? DEFAULT_STEP_MS;
87
- }
88
- const getTimeSeriesData = async (spec, context)=>{
89
- if (spec.query === undefined || spec.query === null || spec.query === '') {
90
- return {
91
- series: []
92
- };
93
- }
94
- const query = (0, _pluginsystem.replaceVariables)(spec.query, context.variableState);
95
- const client = await context.datasourceStore.getDatasourceClient(spec.datasource ?? _constants.DEFAULT_DATASOURCE);
96
- const { start, end } = context.timeRange;
97
- const startTime = (0, _clickhouseclient.formatClickHouseDateTime)(start);
98
- const endTime = (0, _clickhouseclient.formatClickHouseDateTime)(end);
99
- const executedQueryString = (0, _clickhouseclient.replaceTimeRangePlaceholders)(query, startTime, endTime);
100
- const response = await client.query({
101
- start: startTime,
102
- end: endTime,
103
- query: executedQueryString
104
- });
105
- return {
106
- series: buildTimeSeries(response),
107
- timeRange: {
108
- start,
109
- end
110
- },
111
- stepMs: inferStepMs(response),
112
- metadata: {
113
- executedQueryString
114
- }
115
- };
116
- };
@@ -1,33 +0,0 @@
1
- // Copyright 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
- _export_star(require("./get-click-house-data"), exports);
18
- _export_star(require("./ClickHouseQuery"), exports);
19
- _export_star(require("./ClickHouseQueryEditor"), exports);
20
- _export_star(require("./click-house-query-types"), exports);
21
- function _export_star(from, to) {
22
- Object.keys(from).forEach(function(k) {
23
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
24
- Object.defineProperty(to, k, {
25
- enumerable: true,
26
- get: function() {
27
- return from[k];
28
- }
29
- });
30
- }
31
- });
32
- return from;
33
- }
@@ -1,34 +0,0 @@
1
- // Copyright 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
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get DATASOURCE_KIND () {
25
- return DATASOURCE_KIND;
26
- },
27
- get DEFAULT_DATASOURCE () {
28
- return DEFAULT_DATASOURCE;
29
- }
30
- });
31
- const DATASOURCE_KIND = 'ClickHouseDatasource';
32
- const DEFAULT_DATASOURCE = {
33
- kind: DATASOURCE_KIND
34
- };
@@ -1,31 +0,0 @@
1
- // Copyright 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
- _export_star(require("./click-house-time-series-query"), exports);
18
- _export_star(require("./click-house-log-query"), exports);
19
- function _export_star(from, to) {
20
- Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
22
- Object.defineProperty(to, k, {
23
- enumerable: true,
24
- get: function() {
25
- return from[k];
26
- }
27
- });
28
- }
29
- });
30
- return from;
31
- }