@perses-dev/loki-plugin 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/__mf/css/async/1580.d3010b86.css +1 -0
  2. package/__mf/css/async/2341.d3010b86.css +1 -0
  3. package/__mf/css/async/6759.d3010b86.css +1 -0
  4. package/__mf/js/{Loki.b0aaf34e.js → Loki.c48c56a7.js} +4 -4
  5. package/__mf/js/async/1360.2348e2a7.js +10 -0
  6. package/__mf/js/async/1398.ca579c40.js +2 -0
  7. package/__mf/js/async/1580.c7d3c3f1.js +2 -0
  8. package/__mf/js/async/2226.a056d1a3.js +1 -0
  9. package/__mf/js/async/2652.7b7038d2.js +28 -0
  10. package/__mf/js/async/282.6c4c5a94.js +1 -0
  11. package/__mf/js/async/{4075.ea5435c6.js → 4075.19dee570.js} +1 -1
  12. package/__mf/js/async/{4238.ac5f0a30.js → 4238.155e3b8a.js} +1 -1
  13. package/__mf/js/async/4310.6d2d2ce3.js +7 -0
  14. package/__mf/js/async/4421.28cc8e2d.js +1 -0
  15. package/__mf/js/async/4557.fd670526.js +2 -0
  16. package/__mf/js/async/4676.d4c41b7a.js +22 -0
  17. package/__mf/js/async/6134.f7ee513c.js +38 -0
  18. package/__mf/js/async/6329.9c3a3698.js +2 -0
  19. package/__mf/js/async/7797.822237c9.js +1 -0
  20. package/__mf/js/async/9554.728cf7b9.js +2 -0
  21. package/__mf/js/async/{__federation_expose_LokiDatasource.875ecaed.js → __federation_expose_LokiDatasource.3ce6abca.js} +2 -2
  22. package/__mf/js/async/__federation_expose_LokiLogQuery.c446c7ff.js +1 -0
  23. package/__mf/js/async/__federation_expose_LokiTimeSeriesQuery.eda99bf8.js +1 -0
  24. package/__mf/js/{main.7a86e12b.js → main.ccf461ea.js} +4 -4
  25. package/lib/cjs/index.js +0 -1
  26. package/lib/cjs/queries/loki-log-query/LokiLogQueryEditor.js +5 -16
  27. package/lib/cjs/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +5 -16
  28. package/lib/index.d.ts +0 -1
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +0 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib/model/loki-data-types.d.ts +3 -13
  33. package/lib/model/loki-data-types.d.ts.map +1 -1
  34. package/lib/model/loki-data-types.js.map +1 -1
  35. package/lib/queries/loki-log-query/LokiLogQueryEditor.d.ts.map +1 -1
  36. package/lib/queries/loki-log-query/LokiLogQueryEditor.js +4 -15
  37. package/lib/queries/loki-log-query/LokiLogQueryEditor.js.map +1 -1
  38. package/lib/queries/loki-log-query/get-loki-log-data.js.map +1 -1
  39. package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts +2 -4
  40. package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts.map +1 -1
  41. package/lib/queries/loki-log-query/log-query-plugin-interface.js.map +1 -1
  42. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.d.ts.map +1 -1
  43. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +4 -15
  44. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js.map +1 -1
  45. package/mf-manifest.json +60 -121
  46. package/mf-stats.json +60 -123
  47. package/package.json +6 -15
  48. package/__mf/css/async/1320.7ad02b85.css +0 -1
  49. package/__mf/css/async/2341.7ad02b85.css +0 -1
  50. package/__mf/css/async/9479.7ad02b85.css +0 -1
  51. package/__mf/js/async/1320.ca6d65b6.js +0 -2
  52. package/__mf/js/async/2417.993ba27f.js +0 -2
  53. package/__mf/js/async/2448.6a132c1c.js +0 -10
  54. package/__mf/js/async/2470.ba894af3.js +0 -7
  55. package/__mf/js/async/282.3d82e785.js +0 -1
  56. package/__mf/js/async/3849.c4035be2.js +0 -1
  57. package/__mf/js/async/4168.645bbaa1.js +0 -2
  58. package/__mf/js/async/4368.40ff20c1.js +0 -2
  59. package/__mf/js/async/4421.8aeb683a.js +0 -1
  60. package/__mf/js/async/4687.1af57d71.js +0 -2
  61. package/__mf/js/async/4693.ba67a5aa.js +0 -1
  62. package/__mf/js/async/5035.15709e1b.js +0 -73
  63. package/__mf/js/async/5713.3b303108.js +0 -1
  64. package/__mf/js/async/5876.5618763d.js +0 -2
  65. package/__mf/js/async/592.269748ce.js +0 -1
  66. package/__mf/js/async/6569.f33ecbef.js +0 -1
  67. package/__mf/js/async/6664.078084ff.js +0 -28
  68. package/__mf/js/async/9479.f74b4605.js +0 -1
  69. package/__mf/js/async/9654.575f5449.js +0 -37
  70. package/__mf/js/async/__federation_expose_LogsTable.0bf7a331.js +0 -2
  71. package/__mf/js/async/__federation_expose_LokiDatasource.875ecaed.js.LICENSE.txt +0 -9
  72. package/__mf/js/async/__federation_expose_LokiLogQuery.ab63332a.js +0 -1
  73. package/__mf/js/async/__federation_expose_LokiTimeSeriesQuery.9789679e.js +0 -1
  74. package/lib/cjs/panels/index.js +0 -30
  75. package/lib/cjs/panels/logstable/LogsTable.js +0 -41
  76. package/lib/cjs/panels/logstable/LogsTableComponent.js +0 -43
  77. package/lib/cjs/panels/logstable/LogsTableSettingsEditor.js +0 -70
  78. package/lib/cjs/panels/logstable/components/EmptyLogsState.js +0 -49
  79. package/lib/cjs/panels/logstable/components/LogRow/LogRow.js +0 -158
  80. package/lib/cjs/panels/logstable/components/LogRow/LogTimestamp.js +0 -44
  81. package/lib/cjs/panels/logstable/components/LogRow/LogsLabelsTable.js +0 -74
  82. package/lib/cjs/panels/logstable/components/LogRow/LogsStyles.js +0 -77
  83. package/lib/cjs/panels/logstable/components/LogRow/index.js +0 -37
  84. package/lib/cjs/panels/logstable/components/LogsList.js +0 -44
  85. package/lib/cjs/panels/logstable/components/VirtualizedLogsList.js +0 -63
  86. package/lib/cjs/panels/logstable/components/index.js +0 -23
  87. package/lib/cjs/panels/logstable/components/utils.js +0 -39
  88. package/lib/cjs/panels/logstable/hooks/useExpandedRows.js +0 -45
  89. package/lib/cjs/panels/logstable/hooks/useSeverity.js +0 -43
  90. package/lib/cjs/panels/logstable/index.js +0 -33
  91. package/lib/cjs/panels/logstable/logs-types.js +0 -16
  92. package/lib/panels/index.d.ts +0 -2
  93. package/lib/panels/index.d.ts.map +0 -1
  94. package/lib/panels/index.js +0 -15
  95. package/lib/panels/index.js.map +0 -1
  96. package/lib/panels/logstable/LogsTable.d.ts +0 -4
  97. package/lib/panels/logstable/LogsTable.d.ts.map +0 -1
  98. package/lib/panels/logstable/LogsTable.js +0 -33
  99. package/lib/panels/logstable/LogsTable.js.map +0 -1
  100. package/lib/panels/logstable/LogsTableComponent.d.ts +0 -4
  101. package/lib/panels/logstable/LogsTableComponent.d.ts.map +0 -1
  102. package/lib/panels/logstable/LogsTableComponent.js +0 -35
  103. package/lib/panels/logstable/LogsTableComponent.js.map +0 -1
  104. package/lib/panels/logstable/LogsTableSettingsEditor.d.ts +0 -7
  105. package/lib/panels/logstable/LogsTableSettingsEditor.d.ts.map +0 -1
  106. package/lib/panels/logstable/LogsTableSettingsEditor.js +0 -62
  107. package/lib/panels/logstable/LogsTableSettingsEditor.js.map +0 -1
  108. package/lib/panels/logstable/components/EmptyLogsState.d.ts +0 -7
  109. package/lib/panels/logstable/components/EmptyLogsState.d.ts.map +0 -1
  110. package/lib/panels/logstable/components/EmptyLogsState.js +0 -36
  111. package/lib/panels/logstable/components/EmptyLogsState.js.map +0 -1
  112. package/lib/panels/logstable/components/LogRow/LogRow.d.ts +0 -14
  113. package/lib/panels/logstable/components/LogRow/LogRow.d.ts.map +0 -1
  114. package/lib/panels/logstable/components/LogRow/LogRow.js +0 -104
  115. package/lib/panels/logstable/components/LogRow/LogRow.js.map +0 -1
  116. package/lib/panels/logstable/components/LogRow/LogTimestamp.d.ts +0 -7
  117. package/lib/panels/logstable/components/LogRow/LogTimestamp.d.ts.map +0 -1
  118. package/lib/panels/logstable/components/LogRow/LogTimestamp.js +0 -31
  119. package/lib/panels/logstable/components/LogRow/LogTimestamp.js.map +0 -1
  120. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.d.ts +0 -7
  121. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.d.ts.map +0 -1
  122. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.js +0 -61
  123. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.js.map +0 -1
  124. package/lib/panels/logstable/components/LogRow/LogsStyles.d.ts +0 -22
  125. package/lib/panels/logstable/components/LogRow/LogsStyles.d.ts.map +0 -1
  126. package/lib/panels/logstable/components/LogRow/LogsStyles.js +0 -55
  127. package/lib/panels/logstable/components/LogRow/LogsStyles.js.map +0 -1
  128. package/lib/panels/logstable/components/LogRow/index.d.ts +0 -3
  129. package/lib/panels/logstable/components/LogRow/index.d.ts.map +0 -1
  130. package/lib/panels/logstable/components/LogRow/index.js +0 -16
  131. package/lib/panels/logstable/components/LogRow/index.js.map +0 -1
  132. package/lib/panels/logstable/components/LogsList.d.ts +0 -10
  133. package/lib/panels/logstable/components/LogsList.d.ts.map +0 -1
  134. package/lib/panels/logstable/components/LogsList.js +0 -31
  135. package/lib/panels/logstable/components/LogsList.js.map +0 -1
  136. package/lib/panels/logstable/components/VirtualizedLogsList.d.ts +0 -12
  137. package/lib/panels/logstable/components/VirtualizedLogsList.d.ts.map +0 -1
  138. package/lib/panels/logstable/components/VirtualizedLogsList.js +0 -50
  139. package/lib/panels/logstable/components/VirtualizedLogsList.js.map +0 -1
  140. package/lib/panels/logstable/components/index.d.ts +0 -2
  141. package/lib/panels/logstable/components/index.d.ts.map +0 -1
  142. package/lib/panels/logstable/components/index.js +0 -15
  143. package/lib/panels/logstable/components/index.js.map +0 -1
  144. package/lib/panels/logstable/components/utils.d.ts +0 -3
  145. package/lib/panels/logstable/components/utils.d.ts.map +0 -1
  146. package/lib/panels/logstable/components/utils.js +0 -31
  147. package/lib/panels/logstable/components/utils.js.map +0 -1
  148. package/lib/panels/logstable/hooks/useExpandedRows.d.ts +0 -6
  149. package/lib/panels/logstable/hooks/useExpandedRows.d.ts.map +0 -1
  150. package/lib/panels/logstable/hooks/useExpandedRows.js +0 -37
  151. package/lib/panels/logstable/hooks/useExpandedRows.js.map +0 -1
  152. package/lib/panels/logstable/hooks/useSeverity.d.ts +0 -3
  153. package/lib/panels/logstable/hooks/useSeverity.d.ts.map +0 -1
  154. package/lib/panels/logstable/hooks/useSeverity.js +0 -35
  155. package/lib/panels/logstable/hooks/useSeverity.js.map +0 -1
  156. package/lib/panels/logstable/index.d.ts +0 -5
  157. package/lib/panels/logstable/index.d.ts.map +0 -1
  158. package/lib/panels/logstable/index.js +0 -18
  159. package/lib/panels/logstable/index.js.map +0 -1
  160. package/lib/panels/logstable/logs-types.d.ts +0 -11
  161. package/lib/panels/logstable/logs-types.d.ts.map +0 -1
  162. package/lib/panels/logstable/logs-types.js +0 -15
  163. package/lib/panels/logstable/logs-types.js.map +0 -1
  164. /package/__mf/js/async/{2448.6a132c1c.js.LICENSE.txt → 1360.2348e2a7.js.LICENSE.txt} +0 -0
  165. /package/__mf/js/async/{1320.ca6d65b6.js.LICENSE.txt → 1398.ca579c40.js.LICENSE.txt} +0 -0
  166. /package/__mf/js/async/{2417.993ba27f.js.LICENSE.txt → 1580.c7d3c3f1.js.LICENSE.txt} +0 -0
  167. /package/__mf/js/async/{2470.ba894af3.js.LICENSE.txt → 4310.6d2d2ce3.js.LICENSE.txt} +0 -0
  168. /package/__mf/js/async/{4368.40ff20c1.js.LICENSE.txt → 4557.fd670526.js.LICENSE.txt} +0 -0
  169. /package/__mf/js/async/{5035.15709e1b.js.LICENSE.txt → 4676.d4c41b7a.js.LICENSE.txt} +0 -0
  170. /package/__mf/js/async/{4687.1af57d71.js.LICENSE.txt → 6329.9c3a3698.js.LICENSE.txt} +0 -0
  171. /package/__mf/js/async/{5876.5618763d.js.LICENSE.txt → 9554.728cf7b9.js.LICENSE.txt} +0 -0
  172. /package/__mf/js/async/{__federation_expose_LogsTable.0bf7a331.js.LICENSE.txt → __federation_expose_LokiDatasource.3ce6abca.js.LICENSE.txt} +0 -0
@@ -25,12 +25,12 @@ const _pluginsystem = require("@perses-dev/plugin-system");
25
25
  const _material = require("@mui/material");
26
26
  const _react = require("react");
27
27
  const _immer = require("immer");
28
- const _logqleditor = require("../../components/logql-editor");
28
+ const _components = require("../../components");
29
29
  const _model = require("../../model");
30
30
  const _constants = require("../constants");
31
31
  const _queryeditormodel = require("../query-editor-model");
32
32
  function LokiQueryEditor(props) {
33
- const { onChange, value, queryHandlerSettings } = props;
33
+ const { onChange, value } = props;
34
34
  const { datasource } = value;
35
35
  const datasourceSelectValue = datasource ?? _constants.DEFAULT_DATASOURCE;
36
36
  const selectedDatasource = (0, _pluginsystem.useDatasourceSelectValueToSelector)(datasourceSelectValue, _model.LOKI_DATASOURCE_KIND);
@@ -40,31 +40,20 @@ function LokiQueryEditor(props) {
40
40
  onChange((0, _immer.produce)(value, (draft)=>{
41
41
  draft.datasource = newDatasourceSelection;
42
42
  }));
43
- if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
44
- ...value,
45
- datasource: newDatasourceSelection
46
- });
47
43
  return;
48
44
  }
49
45
  throw new Error('Got unexpected non LokiQuery datasource selection');
50
46
  };
51
47
  // Immediate query execution on Enter or blur
52
48
  const handleQueryExecute = (query)=>{
53
- if (queryHandlerSettings?.watchQueryChanges) {
54
- queryHandlerSettings.watchQueryChanges(query);
55
- }
56
49
  onChange((0, _immer.produce)(value, (draft)=>{
57
50
  draft.query = query;
58
51
  }));
59
52
  };
60
53
  const handleLogsQueryChange = (0, _react.useCallback)((e)=>{
61
54
  handleQueryChange(e);
62
- if (queryHandlerSettings?.watchQueryChanges) {
63
- queryHandlerSettings.watchQueryChanges(e);
64
- }
65
55
  }, [
66
- handleQueryChange,
67
- queryHandlerSettings
56
+ handleQueryChange
68
57
  ]);
69
58
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
70
59
  spacing: 1.5,
@@ -99,10 +88,10 @@ function LokiQueryEditor(props) {
99
88
  },
100
89
  children: "LogQL Query"
101
90
  }),
102
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_logqleditor.LogQLEditor, {
91
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.LogQLEditor, {
103
92
  value: query,
104
93
  onChange: handleLogsQueryChange,
105
- onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
94
+ onBlur: handleQueryBlur,
106
95
  onKeyDown: (event)=>{
107
96
  if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
108
97
  event.preventDefault();
package/lib/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { getPluginModule } from './getPluginModule';
2
2
  export * from './model';
3
- export * from './panels';
4
3
  export * from './queries';
5
4
  export * from './datasources';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
package/lib/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  export { getPluginModule } from './getPluginModule';
2
2
  export * from './model';
3
- export * from './panels';
4
3
  export * from './queries';
5
4
  export * from './datasources';
6
5
 
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './panels';\nexport * from './queries';\nexport * from './datasources';\n"],"names":["getPluginModule"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,gBAAgB"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './queries';\nexport * from './datasources';\n"],"names":["getPluginModule"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,gBAAgB"}
@@ -1,23 +1,13 @@
1
- import { AbsoluteTimeRange, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/core';
2
- export interface LogEntry {
3
- timestamp: number;
4
- line: string;
5
- labels: Record<string, string>;
6
- }
7
- export interface LogsData {
8
- entries: LogEntry[];
9
- totalCount: number;
10
- hasMore?: boolean;
11
- }
1
+ import { LogData, AbsoluteTimeRange, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/core';
12
2
  export interface LokiTimeSeriesData extends TimeSeriesData {
13
- logs?: LogsData;
3
+ logs?: LogData;
14
4
  resultType?: 'matrix' | 'streams';
15
5
  }
16
6
  export interface LokiQueryResult {
17
7
  timeRange?: AbsoluteTimeRange;
18
8
  stepMs?: number;
19
9
  series: TimeSeries[];
20
- logs?: LogsData;
10
+ logs?: LogData;
21
11
  resultType: 'matrix' | 'streams';
22
12
  metadata?: TimeSeriesMetadata;
23
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loki-data-types.d.ts","sourceRoot":"","sources":["../../../src/model/loki-data-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAErG,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B"}
1
+ {"version":3,"file":"loki-data-types.d.ts","sourceRoot":"","sources":["../../../src/model/loki-data-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9G,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/loki-data-types.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/core';\n\nexport interface LogEntry {\n timestamp: number;\n line: string;\n labels: Record<string, string>;\n}\n\nexport interface LogsData {\n entries: LogEntry[];\n totalCount: number;\n hasMore?: boolean;\n}\n\nexport interface LokiTimeSeriesData extends TimeSeriesData {\n logs?: LogsData;\n resultType?: 'matrix' | 'streams';\n}\n\nexport interface LokiQueryResult {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: TimeSeries[];\n logs?: LogsData;\n resultType: 'matrix' | 'streams';\n metadata?: TimeSeriesMetadata;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqBjC,WAOC"}
1
+ {"version":3,"sources":["../../../src/model/loki-data-types.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { LogData, AbsoluteTimeRange, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/core';\n\nexport interface LokiTimeSeriesData extends TimeSeriesData {\n logs?: LogData;\n resultType?: 'matrix' | 'streams';\n}\n\nexport interface LokiQueryResult {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: TimeSeries[];\n logs?: LogData;\n resultType: 'matrix' | 'streams';\n metadata?: TimeSeriesMetadata;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC,WAOC"}
@@ -1 +1 @@
1
- {"version":3,"file":"LokiLogQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-log-query/LokiLogQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAoC,MAAM,OAAO,CAAC;AAMvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,KAAK,oBAAoB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA6H5E"}
1
+ {"version":3,"file":"LokiLogQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-log-query/LokiLogQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAOlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,KAAK,oBAAoB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAoH5E"}
@@ -16,12 +16,12 @@ import { InputLabel, Stack, ToggleButton, ToggleButtonGroup } from '@mui/materia
16
16
  import { useCallback } from 'react';
17
17
  import { produce } from 'immer';
18
18
  import { OptionsEditorControl } from '@perses-dev/components';
19
- import { LogQLEditor } from '../../components/logql-editor';
19
+ import { LogQLEditor } from '../../components';
20
20
  import { isDefaultLokiSelector, LOKI_DATASOURCE_KIND } from '../../model';
21
21
  import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';
22
22
  import { useQueryState } from '../query-editor-model';
23
23
  export function LokiLogQueryEditor(props) {
24
- const { onChange, value, queryHandlerSettings } = props;
24
+ const { onChange, value } = props;
25
25
  const { datasource } = value;
26
26
  const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;
27
27
  const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, LOKI_DATASOURCE_KIND);
@@ -33,10 +33,6 @@ export function LokiLogQueryEditor(props) {
33
33
  const nextDatasource = isDefaultLokiSelector(newDatasourceSelection) ? undefined : newDatasourceSelection;
34
34
  draft.datasource = nextDatasource;
35
35
  }));
36
- if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
37
- ...value,
38
- datasource: newDatasourceSelection
39
- });
40
36
  return;
41
37
  }
42
38
  throw new Error('Got unexpected non LokiQuery datasource selection');
@@ -46,21 +42,14 @@ export function LokiLogQueryEditor(props) {
46
42
  }));
47
43
  // Immediate query execution on Enter or blur
48
44
  const handleQueryExecute = (query)=>{
49
- if (queryHandlerSettings?.watchQueryChanges) {
50
- queryHandlerSettings.watchQueryChanges(query);
51
- }
52
45
  onChange(produce(value, (draft)=>{
53
46
  draft.query = query;
54
47
  }));
55
48
  };
56
49
  const handleLogsQueryChange = useCallback((e)=>{
57
50
  handleQueryChange(e);
58
- if (queryHandlerSettings?.watchQueryChanges) {
59
- queryHandlerSettings.watchQueryChanges(e);
60
- }
61
51
  }, [
62
- handleQueryChange,
63
- queryHandlerSettings
52
+ handleQueryChange
64
53
  ]);
65
54
  return /*#__PURE__*/ _jsxs(Stack, {
66
55
  spacing: 1.5,
@@ -98,7 +87,7 @@ export function LokiLogQueryEditor(props) {
98
87
  /*#__PURE__*/ _jsx(LogQLEditor, {
99
88
  value: query,
100
89
  onChange: handleLogsQueryChange,
101
- onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
90
+ onBlur: handleQueryBlur,
102
91
  onKeyDown: (event)=>{
103
92
  if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
104
93
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/queries/loki-log-query/LokiLogQueryEditor.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 useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { InputLabel, Stack, ToggleButton, ToggleButtonGroup } from '@mui/material';\nimport { ReactElement, useCallback, useState, useEffect } from 'react';\nimport { produce } from 'immer';\nimport { OptionsEditorControl } from '@perses-dev/components';\nimport { LogQLEditor } from '../../components/logql-editor';\nimport { isDefaultLokiSelector, LOKI_DATASOURCE_KIND, LokiDatasourceSelector } from '../../model';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { LokiLogQuerySpec } from './loki-log-query-types';\nimport { useQueryState } from '../query-editor-model';\n\ntype LokiQueryEditorProps = OptionsEditorProps<LokiLogQuerySpec>;\n\nexport function LokiLogQueryEditor(props: LokiQueryEditorProps): ReactElement {\n const { onChange, value, queryHandlerSettings } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n LOKI_DATASOURCE_KIND\n ) as LokiDatasourceSelector;\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 // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultLokiSelector(newDatasourceSelection) ? undefined : newDatasourceSelection;\n draft.datasource = nextDatasource;\n })\n );\n\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: newDatasourceSelection });\n return;\n }\n\n throw new Error('Got unexpected non LokiQuery datasource selection');\n };\n\n const handleLogsDirection = (_: React.MouseEvent, v: 'backward' | 'forward') =>\n onChange(\n produce(value, (draft: LokiLogQuerySpec) => {\n draft.direction = v;\n })\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 handleLogsQueryChange = useCallback(\n (e: string) => {\n handleQueryChange(e);\n if (queryHandlerSettings?.watchQueryChanges) {\n queryHandlerSettings.watchQueryChanges(e);\n }\n },\n [handleQueryChange, queryHandlerSettings]\n );\n\n return (\n <Stack spacing={1.5} paddingBottom={1}>\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"Loki Datasource\"\n notched\n />\n </div>\n\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n LogQL Query\n </InputLabel>\n <LogQLEditor\n value={query}\n onChange={handleLogsQueryChange}\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 LogQL query (e.g. {job=\"mysql\"} |= \"error\")'\n // height=\"120px\"\n />\n </div>\n <div>\n <OptionsEditorControl\n label=\"Order\"\n // description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n value={value?.direction ?? 'backward'}\n onChange={handleLogsDirection}\n sx={{ height: '36px', marginLeft: '10px', width: 'max-content' }}\n >\n <ToggleButton aria-label=\"backward\" value=\"backward\" sx={{ fontWeight: 500 }}>\n Newest first\n </ToggleButton>\n <ToggleButton aria-label=\"forward\" value=\"forward\" sx={{ fontWeight: 500 }}>\n Oldest first\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n </div>\n </Stack>\n );\n}\n"],"names":["DatasourceSelect","isVariableDatasource","useDatasourceSelectValueToSelector","InputLabel","Stack","ToggleButton","ToggleButtonGroup","useCallback","produce","OptionsEditorControl","LogQLEditor","isDefaultLokiSelector","LOKI_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","useQueryState","LokiLogQueryEditor","props","onChange","value","queryHandlerSettings","datasource","datasourceSelectValue","selectedDatasource","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","newDatasourceSelection","kind","draft","nextDatasource","undefined","setWatchOtherSpecs","Error","handleLogsDirection","_","v","direction","handleQueryExecute","watchQueryChanges","handleLogsQueryChange","e","spacing","paddingBottom","div","sx","display","marginBottom","fontWeight","datasourcePluginKind","label","notched","onBlur","runWithOnBlur","onKeyDown","event","key","ctrlKey","metaKey","preventDefault","placeholder","control","exclusive","height","marginLeft","width","aria-label"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AA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AAEkB,QAAQ;4BAAQC,YAAY;4BAAQC,OAAO;wBAAc;;0CAE/D,KAAC7D;gCAAa8D,cAAW;gCAAWhD,OAAM;gCAAW2B,IAAI;oCAAEG,YAAY;gCAAI;0CAAG;;0CAG9E,KAAC5C;gCAAa8D,cAAW;gCAAUhD,OAAM;gCAAU2B,IAAI;oCAAEG,YAAY;gCAAI;0CAAG;;;;;;;;AAS1F"}
1
+ {"version":3,"sources":["../../../../src/queries/loki-log-query/LokiLogQueryEditor.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 useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { InputLabel, Stack, ToggleButton, ToggleButtonGroup } from '@mui/material';\nimport { ReactElement, useCallback } from 'react';\nimport { produce } from 'immer';\nimport { OptionsEditorControl } from '@perses-dev/components';\nimport { LogQLEditor } from '../../components';\nimport { isDefaultLokiSelector, LOKI_DATASOURCE_KIND, LokiDatasourceSelector } from '../../model';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { useQueryState } from '../query-editor-model';\nimport { LokiLogQuerySpec } from './loki-log-query-types';\n\ntype LokiQueryEditorProps = OptionsEditorProps<LokiLogQuerySpec>;\n\nexport function LokiLogQueryEditor(props: LokiQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n LOKI_DATASOURCE_KIND\n ) as LokiDatasourceSelector;\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 // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultLokiSelector(newDatasourceSelection) ? undefined : newDatasourceSelection;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non LokiQuery datasource selection');\n };\n\n const handleLogsDirection = (_: React.MouseEvent, v: 'backward' | 'forward') =>\n onChange(\n produce(value, (draft: LokiLogQuerySpec) => {\n draft.direction = v;\n })\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 handleLogsQueryChange = useCallback(\n (e: string) => {\n handleQueryChange(e);\n },\n [handleQueryChange]\n );\n\n return (\n <Stack spacing={1.5} paddingBottom={1}>\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"Loki Datasource\"\n notched\n />\n </div>\n\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n LogQL Query\n </InputLabel>\n <LogQLEditor\n value={query}\n onChange={handleLogsQueryChange}\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 LogQL query (e.g. {job=\"mysql\"} |= \"error\")'\n // height=\"120px\"\n />\n </div>\n <div>\n <OptionsEditorControl\n label=\"Order\"\n // description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n value={value?.direction ?? 'backward'}\n onChange={handleLogsDirection}\n sx={{ height: '36px', marginLeft: '10px', width: 'max-content' }}\n >\n <ToggleButton aria-label=\"backward\" value=\"backward\" sx={{ fontWeight: 500 }}>\n Newest first\n </ToggleButton>\n <ToggleButton aria-label=\"forward\" value=\"forward\" sx={{ fontWeight: 500 }}>\n Oldest first\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n </div>\n </Stack>\n );\n}\n"],"names":["DatasourceSelect","isVariableDatasource","useDatasourceSelectValueToSelector","InputLabel","Stack","ToggleButton","ToggleButtonGroup","useCallback","produce","OptionsEditorControl","LogQLEditor","isDefaultLokiSelector","LOKI_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","useQueryState","LokiLogQueryEditor","props","onChange","value","datasource","datasourceSelectValue","selectedDatasource","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","newDatasourceSelection","kind","draft","nextDatasource","undefined","Error","handleLogsDirection","_","v","direction","handleQueryExecute","handleLogsQueryChange","e","spacing","paddingBottom","div","sx","display","marginBottom","fontWeight","datasourcePluginKind","label","notched","onBlur","onKeyDown","event","key","ctrlKey","metaKey","preventDefault","placeholder","control","exclusive","height","marginLeft","width","aria-label"],"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,EAEpBC,kCAAkC,QAC7B,4BAA4B;AACnC,SAASC,UAAU,EAAEC,KAAK,EAAEC,YAAY,EAAEC,iBAAiB,QAAQ,gBAAgB;AACnF,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,oBAAoB,QAA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,UAAUQ;wBACVsB,OAAM;wBACNC,OAAO;;;;0BAIX,MAACP;;kCACC,KAACvC;wBACCwC,IAAI;4BACFC,SAAS;4BACTC,cAAc;4BACdC,YAAY;wBACd;kCACD;;kCAGD,KAACpC;wBACCS,OAAOI;wBACPL,UAAUoB;wBACVY,QAAQzB;wBACR0B,WAAW,CAACC;4BACV,IAAIA,MAAMC,GAAG,KAAK,WAAYD,CAAAA,MAAME,OAAO,IAAIF,MAAMG,OAAO,AAAD,GAAI;gCAC7DH,MAAMI,cAAc;gCACpBnB,mBAAmBd;4BACrB;wBACF;wBACAkC,aAAY;;;;0BAIhB,KAACf;0BACC,cAAA,KAACjC;oBACCuC,OAAM;oBACN,kEAAkE;oBAClEU,uBACE,MAACpD;wBACCqD,SAAS;wBACTxC,OAAOA,OAAOiB,aAAa;wBAC3BlB,UAAUe;wBACVU,IAAI;4BAAEiB,QAAQ;4BAAQC,YAAY;4BAAQC,OAAO;wBAAc;;0CAE/D,KAACzD;gCAAa0D,cAAW;gCAAW5C,OAAM;gCAAWwB,IAAI;oCAAEG,YAAY;gCAAI;0CAAG;;0CAG9E,KAACzC;gCAAa0D,cAAW;gCAAU5C,OAAM;gCAAUwB,IAAI;oCAAEG,YAAY;gCAAI;0CAAG;;;;;;;;AAS1F"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/queries/loki-log-query/get-loki-log-data.ts"],"sourcesContent":["import { replaceVariables } from '@perses-dev/plugin-system';\nimport { LokiStreamResult } from '../../model/loki-client-types';\nimport { LokiClient } from '../../model/loki-client';\nimport { LogEntry, LogsData } from '../../model/loki-data-types';\nimport { DEFAULT_DATASOURCE } from '../constants';\nimport { LokiLogQuerySpec, LokiLogQueryResponse } from './loki-log-query-types';\nimport { LogQueryPlugin, LogQueryContext } from './log-query-plugin-interface';\n\nfunction convertStreamsToLogs(streams: LokiStreamResult[]): LogsData {\n const entries: LogEntry[] = [];\n\n streams.forEach((stream) => {\n stream.values.forEach(([timestamp, logLine]: [string, string]) => {\n entries.push({\n timestamp: Number(timestamp) / 1000000000,\n line: logLine,\n labels: stream.stream,\n });\n });\n });\n\n return {\n entries,\n totalCount: entries.length,\n };\n}\n\nexport const getLokiLogData: LogQueryPlugin<LokiLogQuerySpec>['getLogData'] = async (\n spec: LokiLogQuerySpec,\n context: LogQueryContext\n) => {\n if (!spec.query) {\n return {\n logs: { entries: [], totalCount: 0 },\n timeRange: { start: context.timeRange.start, end: context.timeRange.end },\n };\n }\n\n const query = replaceVariables(spec.query, context.variableState);\n const client = (await context.datasourceStore.getDatasourceClient<LokiClient>(\n spec.datasource ?? DEFAULT_DATASOURCE\n )) as LokiClient;\n\n const { start, end } = context.timeRange;\n\n const response: LokiLogQueryResponse = await client.queryRange({\n query,\n start: start.getTime().toString(),\n end: end.getTime().toString(),\n direction: spec.direction,\n });\n\n if (response.data.resultType === 'streams') {\n const logs = convertStreamsToLogs(response.data.result);\n return {\n logs,\n timeRange: { start, end },\n metadata: {\n executedQueryString: query,\n },\n };\n }\n\n return {\n logs: { entries: [], totalCount: 0 },\n timeRange: { start, end },\n };\n};\n"],"names":["replaceVariables","DEFAULT_DATASOURCE","convertStreamsToLogs","streams","entries","forEach","stream","values","timestamp","logLine","push","Number","line","labels","totalCount","length","getLokiLogData","spec","context","query","logs","timeRange","start","end","variableState","client","datasourceStore","getDatasourceClient","datasource","response","queryRange","getTime","toString","direction","data","resultType","result","metadata","executedQueryString"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAI7D,SAASC,kBAAkB,QAAQ,eAAe;AAIlD,SAASC,qBAAqBC,OAA2B;IACvD,MAAMC,UAAsB,EAAE;IAE9BD,QAAQE,OAAO,CAAC,CAACC;QACfA,OAAOC,MAAM,CAACF,OAAO,CAAC,CAAC,CAACG,WAAWC,QAA0B;YAC3DL,QAAQM,IAAI,CAAC;gBACXF,WAAWG,OAAOH,aAAa;gBAC/BI,MAAMH;gBACNI,QAAQP,OAAOA,MAAM;YACvB;QACF;IACF;IAEA,OAAO;QACLF;QACAU,YAAYV,QAAQW,MAAM;IAC5B;AACF;AAEA,OAAO,MAAMC,iBAAiE,OAC5EC,MACAC;IAEA,IAAI,CAACD,KAAKE,KAAK,EAAE;QACf,OAAO;YACLC,MAAM;gBAAEhB,SAAS,EAAE;gBAAEU,YAAY;YAAE;YACnCO,WAAW;gBAAEC,OAAOJ,QAAQG,SAAS,CAACC,KAAK;gBAAEC,KAAKL,QAAQG,SAAS,CAACE,GAAG;YAAC;QAC1E;IACF;IAEA,MAAMJ,QAAQnB,iBAAiBiB,KAAKE,KAAK,EAAED,QAAQM,aAAa;IAChE,MAAMC,SAAU,MAAMP,QAAQQ,eAAe,CAACC,mBAAmB,CAC/DV,KAAKW,UAAU,IAAI3B;IAGrB,MAAM,EAAEqB,KAAK,EAAEC,GAAG,EAAE,GAAGL,QAAQG,SAAS;IAExC,MAAMQ,WAAiC,MAAMJ,OAAOK,UAAU,CAAC;QAC7DX;QACAG,OAAOA,MAAMS,OAAO,GAAGC,QAAQ;QAC/BT,KAAKA,IAAIQ,OAAO,GAAGC,QAAQ;QAC3BC,WAAWhB,KAAKgB,SAAS;IAC3B;IAEA,IAAIJ,SAASK,IAAI,CAACC,UAAU,KAAK,WAAW;QAC1C,MAAMf,OAAOlB,qBAAqB2B,SAASK,IAAI,CAACE,MAAM;QACtD,OAAO;YACLhB;YACAC,WAAW;gBAAEC;gBAAOC;YAAI;YACxBc,UAAU;gBACRC,qBAAqBnB;YACvB;QACF;IACF;IAEA,OAAO;QACLC,MAAM;YAAEhB,SAAS,EAAE;YAAEU,YAAY;QAAE;QACnCO,WAAW;YAAEC;YAAOC;QAAI;IAC1B;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/queries/loki-log-query/get-loki-log-data.ts"],"sourcesContent":["import { replaceVariables } from '@perses-dev/plugin-system';\nimport { LokiStreamResult } from '../../model/loki-client-types';\nimport { LokiClient } from '../../model/loki-client';\nimport { LogEntry, LogData } from '@perses-dev/core';\nimport { DEFAULT_DATASOURCE } from '../constants';\nimport { LokiLogQuerySpec, LokiLogQueryResponse } from './loki-log-query-types';\nimport { LogQueryPlugin, LogQueryContext } from './log-query-plugin-interface';\n\nfunction convertStreamsToLogs(streams: LokiStreamResult[]): LogData {\n const entries: LogEntry[] = [];\n\n streams.forEach((stream) => {\n stream.values.forEach(([timestamp, logLine]: [string, string]) => {\n entries.push({\n timestamp: Number(timestamp) / 1000000000,\n line: logLine,\n labels: stream.stream,\n });\n });\n });\n\n return {\n entries,\n totalCount: entries.length,\n };\n}\n\nexport const getLokiLogData: LogQueryPlugin<LokiLogQuerySpec>['getLogData'] = async (\n spec: LokiLogQuerySpec,\n context: LogQueryContext\n) => {\n if (!spec.query) {\n return {\n logs: { entries: [], totalCount: 0 },\n timeRange: { start: context.timeRange.start, end: context.timeRange.end },\n };\n }\n\n const query = replaceVariables(spec.query, context.variableState);\n const client = (await context.datasourceStore.getDatasourceClient<LokiClient>(\n spec.datasource ?? DEFAULT_DATASOURCE\n )) as LokiClient;\n\n const { start, end } = context.timeRange;\n\n const response: LokiLogQueryResponse = await client.queryRange({\n query,\n start: start.getTime().toString(),\n end: end.getTime().toString(),\n direction: spec.direction,\n });\n\n if (response.data.resultType === 'streams') {\n const logs = convertStreamsToLogs(response.data.result);\n return {\n logs,\n timeRange: { start, end },\n metadata: {\n executedQueryString: query,\n },\n };\n }\n\n return {\n logs: { entries: [], totalCount: 0 },\n timeRange: { start, end },\n };\n};\n"],"names":["replaceVariables","DEFAULT_DATASOURCE","convertStreamsToLogs","streams","entries","forEach","stream","values","timestamp","logLine","push","Number","line","labels","totalCount","length","getLokiLogData","spec","context","query","logs","timeRange","start","end","variableState","client","datasourceStore","getDatasourceClient","datasource","response","queryRange","getTime","toString","direction","data","resultType","result","metadata","executedQueryString"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAI7D,SAASC,kBAAkB,QAAQ,eAAe;AAIlD,SAASC,qBAAqBC,OAA2B;IACvD,MAAMC,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EC;YAAOC;QAAI;IAC1B;AACF,EAAE"}
@@ -1,8 +1,7 @@
1
- import { AbsoluteTimeRange, UnknownSpec } from '@perses-dev/core';
1
+ import { LogData, AbsoluteTimeRange, UnknownSpec } from '@perses-dev/core';
2
2
  import { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';
3
- import { LogsData } from '../../model/loki-data-types';
4
3
  export interface LogQueryResult {
5
- logs: LogsData;
4
+ logs: LogData;
6
5
  timeRange: AbsoluteTimeRange;
7
6
  metadata?: {
8
7
  executedQueryString: string;
@@ -12,7 +11,6 @@ export interface LogQueryContext {
12
11
  timeRange: AbsoluteTimeRange;
13
12
  variableState: VariableStateMap;
14
13
  datasourceStore: DatasourceStore;
15
- refreshKey: string;
16
14
  }
17
15
  type LogQueryPluginDependencies = {
18
16
  variables?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"log-query-plugin-interface.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-log-query/log-query-plugin-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACtE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC1E,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,0BAA0B,CAAC;CAC9E"}
1
+ {"version":3,"file":"log-query-plugin-interface.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-log-query/log-query-plugin-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACtE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC1E,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,0BAA0B,CAAC;CAC9E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/queries/loki-log-query/log-query-plugin-interface.ts"],"sourcesContent":["import { AbsoluteTimeRange, UnknownSpec } from '@perses-dev/core';\nimport { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';\nimport { LogsData } from '../../model/loki-data-types';\n\nexport interface LogQueryResult {\n logs: LogsData;\n timeRange: AbsoluteTimeRange;\n metadata?: {\n executedQueryString: string;\n };\n}\n\nexport interface LogQueryContext {\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\ntype LogQueryPluginDependencies = {\n variables?: string[];\n};\n\nexport interface LogQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getLogData: (spec: Spec, ctx: LogQueryContext) => Promise<LogQueryResult>;\n dependsOn?: (spec: Spec, ctx: LogQueryContext) => LogQueryPluginDependencies;\n}\n"],"names":[],"mappings":"AAuBA,WAGC"}
1
+ {"version":3,"sources":["../../../../src/queries/loki-log-query/log-query-plugin-interface.ts"],"sourcesContent":["import { LogData, AbsoluteTimeRange, UnknownSpec } 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 LogQueryContext {\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: LogQueryContext) => Promise<LogQueryResult>;\n dependsOn?: (spec: Spec, ctx: LogQueryContext) => LogQueryPluginDependencies;\n}\n"],"names":[],"mappings":"AAqBA,WAGC"}
@@ -1 +1 @@
1
- {"version":3,"file":"LokiTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAKlD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,KAAK,oBAAoB,GAAG,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;AAExE,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA+FzE"}
1
+ {"version":3,"file":"LokiTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAMlD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,KAAK,oBAAoB,GAAG,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;AAExE,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAsFzE"}
@@ -15,12 +15,12 @@ import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelec
15
15
  import { InputLabel, Stack } from '@mui/material';
16
16
  import { useCallback } from 'react';
17
17
  import { produce } from 'immer';
18
- import { LogQLEditor } from '../../components/logql-editor';
18
+ import { LogQLEditor } from '../../components';
19
19
  import { LOKI_DATASOURCE_KIND } from '../../model';
20
20
  import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';
21
21
  import { useQueryState } from '../query-editor-model';
22
22
  export function LokiQueryEditor(props) {
23
- const { onChange, value, queryHandlerSettings } = props;
23
+ const { onChange, value } = props;
24
24
  const { datasource } = value;
25
25
  const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;
26
26
  const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, LOKI_DATASOURCE_KIND);
@@ -30,31 +30,20 @@ export function LokiQueryEditor(props) {
30
30
  onChange(produce(value, (draft)=>{
31
31
  draft.datasource = newDatasourceSelection;
32
32
  }));
33
- if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
34
- ...value,
35
- datasource: newDatasourceSelection
36
- });
37
33
  return;
38
34
  }
39
35
  throw new Error('Got unexpected non LokiQuery datasource selection');
40
36
  };
41
37
  // Immediate query execution on Enter or blur
42
38
  const handleQueryExecute = (query)=>{
43
- if (queryHandlerSettings?.watchQueryChanges) {
44
- queryHandlerSettings.watchQueryChanges(query);
45
- }
46
39
  onChange(produce(value, (draft)=>{
47
40
  draft.query = query;
48
41
  }));
49
42
  };
50
43
  const handleLogsQueryChange = useCallback((e)=>{
51
44
  handleQueryChange(e);
52
- if (queryHandlerSettings?.watchQueryChanges) {
53
- queryHandlerSettings.watchQueryChanges(e);
54
- }
55
45
  }, [
56
- handleQueryChange,
57
- queryHandlerSettings
46
+ handleQueryChange
58
47
  ]);
59
48
  return /*#__PURE__*/ _jsxs(Stack, {
60
49
  spacing: 1.5,
@@ -92,7 +81,7 @@ export function LokiQueryEditor(props) {
92
81
  /*#__PURE__*/ _jsx(LogQLEditor, {
93
82
  value: query,
94
83
  onChange: handleLogsQueryChange,
95
- onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
84
+ onBlur: handleQueryBlur,
96
85
  onKeyDown: (event)=>{
97
86
  if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
98
87
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.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 useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { InputLabel, Stack } from '@mui/material';\nimport { ReactElement, useCallback } from 'react';\nimport { produce } from 'immer';\nimport { LogQLEditor } from '../../components/logql-editor';\nimport { LOKI_DATASOURCE_KIND, LokiDatasourceSelector } from '../../model';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types';\nimport { useQueryState } from '../query-editor-model';\n\ntype LokiQueryEditorProps = OptionsEditorProps<LokiTimeSeriesQuerySpec>;\n\nexport function LokiQueryEditor(props: LokiQueryEditorProps): ReactElement {\n const { onChange, value, queryHandlerSettings } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n LOKI_DATASOURCE_KIND\n ) as LokiDatasourceSelector;\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\n throw new Error('Got unexpected non LokiQuery 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 handleLogsQueryChange = useCallback(\n (e: string) => {\n handleQueryChange(e);\n if (queryHandlerSettings?.watchQueryChanges) {\n queryHandlerSettings.watchQueryChanges(e);\n }\n },\n [handleQueryChange, queryHandlerSettings]\n );\n\n return (\n <Stack spacing={1.5} paddingBottom={1}>\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"Loki Datasource\"\n notched\n />\n </div>\n\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n LogQL Query\n </InputLabel>\n <LogQLEditor\n value={query}\n onChange={handleLogsQueryChange}\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 LogQL query (e.g. {job=\"mysql\"} |= \"error\")'\n // height=\"120px\"\n />\n </div>\n </Stack>\n );\n}\n"],"names":["DatasourceSelect","isVariableDatasource","useDatasourceSelectValueToSelector","InputLabel","Stack","useCallback","produce","LogQLEditor","LOKI_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","useQueryState","LokiQueryEditor","props","onChange","value","queryHandlerSettings","datasource","datasourceSelectValue","selectedDatasource","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","newDatasourceSelection","kind","draft","setWatchOtherSpecs","Error","handleQueryExecute","watchQueryChanges","handleLogsQueryChange","e","spacing","paddingBottom","div","sx","display","marginBottom","fontWeight","datasourcePluginKind","label","notched","onBlur","runWithOnBlur","undefined","onKeyDown","event","key","ctrlKey","metaKey","preventDefault","placeholder"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC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A,MAAMW,wBAAwB1B,YAC5B,CAAC2B;QACCX,kBAAkBW;QAClB,IAAIhB,sBAAsBc,mBAAmB;YAC3Cd,qBAAqBc,iBAAiB,CAACE;QACzC;IACF,GACA;QAACX;QAAmBL;KAAqB;IAG3C,qBACE,MAACZ;QAAM6B,SAAS;QAAKC,eAAe;;0BAClC,MAACC;;kCACC,KAAChC;wBACCiC,IAAI;4BACFC,SAAS;4BACTC,cAAc;4BACdC,YAAY;wBACd;kCACD;;kCAGD,KAACvC;wBACCwC,sBAAsB/B;wBACtBM,OAAOI;wBACPL,UAAUS;wBACVkB,OAAM;wBACNC,OAAO;;;;0BAIX,MAACP;;kCACC,KAAChC;wBACCiC,IAAI;4BACFC,SAAS;4BACTC,cAAc;4BACdC,YAAY;wBACd;kCACD;;kCAGD,KAAChC;wBACCQ,OAAOK;wBACPN,UAAUiB;wBACVY,QAAQ3B,sBAAsB4B,gBAAgBtB,kBAAkBuB;wBAChEC,WAAW,CAACC;4BACV,IAAIA,MAAMC,GAAG,KAAK,WAAYD,CAAAA,MAAME,OAAO,IAAIF,MAAMG,OAAO,AAAD,GAAI;gCAC7DH,MAAMI,cAAc;gCACpBtB,mBAAmBT;4BACrB;wBACF;wBACAgC,aAAY;;;;;;AAMtB"}
1
+ {"version":3,"sources":["../../../../src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.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 useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { InputLabel, Stack } from '@mui/material';\nimport { ReactElement, useCallback } from 'react';\nimport { produce } from 'immer';\nimport { LogQLEditor } from '../../components';\nimport { LOKI_DATASOURCE_KIND, LokiDatasourceSelector } from '../../model';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport { useQueryState } from '../query-editor-model';\nimport { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types';\n\ntype LokiQueryEditorProps = OptionsEditorProps<LokiTimeSeriesQuerySpec>;\n\nexport function LokiQueryEditor(props: LokiQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n LOKI_DATASOURCE_KIND\n ) as LokiDatasourceSelector;\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\n throw new Error('Got unexpected non LokiQuery 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 handleLogsQueryChange = useCallback(\n (e: string) => {\n handleQueryChange(e);\n },\n [handleQueryChange]\n );\n\n return (\n <Stack spacing={1.5} paddingBottom={1}>\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"Loki Datasource\"\n notched\n />\n </div>\n\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n LogQL Query\n </InputLabel>\n <LogQLEditor\n value={query}\n onChange={handleLogsQueryChange}\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 LogQL query (e.g. {job=\"mysql\"} |= \"error\")'\n // height=\"120px\"\n />\n </div>\n </Stack>\n );\n}\n"],"names":["DatasourceSelect","isVariableDatasource","useDatasourceSelectValueToSelector","InputLabel","Stack","useCallback","produce","LogQLEditor","LOKI_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","useQueryState","LokiQueryEditor","props","onChange","value","datasource","datasourceSelectValue","selectedDatasource","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","newDatasourceSelection","kind","draft","Error","handleQueryExecute","handleLogsQueryChange","e","spacing","paddingBottom","div","sx","display","marginBottom","fontWeight","datasourcePluginKind","label","notched","onBlur","onKeyDown","event","key","ctrlKey","metaKey","preventDefault","placeholder"],"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,EAEpBC,kCAAkC,QAC7B,4BAA4B;AACnC,SAASC,UAAU,EAAEC,KAAK,QAAQ,gBAAgB;AAClD,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,oBAAoB,QAAgC,cAAc;AAC3E,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,eAAe;AACnE,SAASC,aAAa,QAAQ,wBAAwB;AAKtD,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAA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