@perses-dev/loki-plugin 0.1.0 → 0.1.1

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 (346) hide show
  1. package/LICENSE +201 -0
  2. package/__mf/css/async/1320.7ad02b85.css +1 -0
  3. package/__mf/css/async/2341.7ad02b85.css +1 -0
  4. package/__mf/css/async/9479.7ad02b85.css +1 -0
  5. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  6. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  7. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  8. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  9. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  10. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  11. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  12. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  13. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  17. package/__mf/js/Loki.e3bb11f6.js +6 -0
  18. package/__mf/js/async/1320.ca6d65b6.js +2 -0
  19. package/__mf/js/async/1320.ca6d65b6.js.LICENSE.txt +9 -0
  20. package/__mf/js/async/1540.6b797827.js +74 -0
  21. package/__mf/js/async/1964.7b2e7223.js +2 -0
  22. package/__mf/js/async/1964.7b2e7223.js.LICENSE.txt +9 -0
  23. package/__mf/js/async/2292.35c2eeec.js +2 -0
  24. package/__mf/js/async/2292.35c2eeec.js.LICENSE.txt +24 -0
  25. package/__mf/js/async/2448.6a132c1c.js +10 -0
  26. package/__mf/js/async/2448.6a132c1c.js.LICENSE.txt +17 -0
  27. package/__mf/js/async/2470.32c642b9.js +7 -0
  28. package/__mf/js/async/2470.32c642b9.js.LICENSE.txt +21 -0
  29. package/__mf/js/async/2651.ef335482.js +1 -0
  30. package/__mf/js/async/282.3d82e785.js +1 -0
  31. package/__mf/js/async/3224.b1170acc.js +1 -0
  32. package/__mf/js/async/3246.240e9404.js +1 -0
  33. package/__mf/js/async/3413.6dd92cfd.js +1 -0
  34. package/__mf/js/async/3431.2270637c.js +1 -0
  35. package/__mf/js/async/3849.c4035be2.js +1 -0
  36. package/__mf/js/async/3863.16343b76.js +2 -0
  37. package/__mf/js/async/3863.16343b76.js.LICENSE.txt +9 -0
  38. package/__mf/js/async/3869.4e06bfcb.js +2 -0
  39. package/__mf/js/async/3869.4e06bfcb.js.LICENSE.txt +9 -0
  40. package/__mf/js/async/3960.6091bb00.js +2 -0
  41. package/__mf/js/async/3960.6091bb00.js.LICENSE.txt +8 -0
  42. package/__mf/js/async/3980.08ab4aef.js +2 -0
  43. package/__mf/js/async/3980.08ab4aef.js.LICENSE.txt +9 -0
  44. package/__mf/js/async/4075.ea5435c6.js +1 -0
  45. package/__mf/js/async/4168.645bbaa1.js +2 -0
  46. package/__mf/js/async/4238.ac5f0a30.js +1 -0
  47. package/__mf/js/async/4269.b4d0f49d.js +2 -0
  48. package/__mf/js/async/4269.b4d0f49d.js.LICENSE.txt +9 -0
  49. package/__mf/js/async/4368.438b431f.js +2 -0
  50. package/__mf/js/async/4368.438b431f.js.LICENSE.txt +15 -0
  51. package/__mf/js/async/4421.fef63995.js +1 -0
  52. package/__mf/js/async/4687.1af57d71.js +2 -0
  53. package/__mf/js/async/4687.1af57d71.js.LICENSE.txt +9 -0
  54. package/__mf/js/async/4693.ba67a5aa.js +1 -0
  55. package/__mf/js/async/5214.fee648bb.js +1 -0
  56. package/__mf/js/async/5409.ff95cf63.js +1 -0
  57. package/__mf/js/async/5780.d837c3cd.js +1 -0
  58. package/__mf/js/async/5876.5618763d.js +2 -0
  59. package/__mf/js/async/5876.5618763d.js.LICENSE.txt +21 -0
  60. package/__mf/js/async/592.269748ce.js +1 -0
  61. package/__mf/js/async/5981.a46c5157.js +2 -0
  62. package/__mf/js/async/5981.a46c5157.js.LICENSE.txt +8 -0
  63. package/__mf/js/async/6292.9997ca36.js +1 -0
  64. package/__mf/js/async/6333.01fb6457.js +2 -0
  65. package/__mf/js/async/6333.01fb6457.js.LICENSE.txt +9 -0
  66. package/__mf/js/async/6377.9f308c7f.js +2 -0
  67. package/__mf/js/async/6377.9f308c7f.js.LICENSE.txt +32 -0
  68. package/__mf/js/async/6569.f33ecbef.js +1 -0
  69. package/__mf/js/async/6664.078084ff.js +28 -0
  70. package/__mf/js/async/6770.ba5a38f3.js +1 -0
  71. package/__mf/js/async/694.c25a1f84.js +1 -0
  72. package/__mf/js/async/7152.e8100fb6.js +73 -0
  73. package/__mf/js/async/7152.e8100fb6.js.LICENSE.txt +19 -0
  74. package/__mf/js/async/7376.0459aaf7.js +1 -0
  75. package/__mf/js/async/738.a16c93b6.js +1 -0
  76. package/__mf/js/async/7740.6f193fac.js +1 -0
  77. package/__mf/js/async/8216.d9cc6234.js +1 -0
  78. package/__mf/js/async/8488.5b4b7170.js +1 -0
  79. package/__mf/js/async/8537.dc791586.js +1 -0
  80. package/__mf/js/async/9173.75bbe78a.js +2 -0
  81. package/__mf/js/async/9173.75bbe78a.js.LICENSE.txt +19 -0
  82. package/__mf/js/async/9479.f74b4605.js +1 -0
  83. package/__mf/js/async/9654.575f5449.js +37 -0
  84. package/__mf/js/async/__federation_expose_LogsTable.3952e904.js +2 -0
  85. package/__mf/js/async/__federation_expose_LogsTable.3952e904.js.LICENSE.txt +9 -0
  86. package/__mf/js/async/__federation_expose_LokiDatasource.5fbd8f68.js +2 -0
  87. package/__mf/js/async/__federation_expose_LokiDatasource.5fbd8f68.js.LICENSE.txt +9 -0
  88. package/__mf/js/async/__federation_expose_LokiLogQuery.0720038a.js +1 -0
  89. package/__mf/js/async/__federation_expose_LokiTimeSeriesQuery.8c7f7602.js +1 -0
  90. package/__mf/js/main.a5b9ede8.js +6 -0
  91. package/lib/bootstrap.d.ts +2 -0
  92. package/lib/bootstrap.d.ts.map +1 -0
  93. package/lib/bootstrap.js +7 -0
  94. package/lib/bootstrap.js.map +1 -0
  95. package/lib/cjs/bootstrap.js +14 -0
  96. package/lib/cjs/components/index.js +23 -0
  97. package/lib/cjs/components/logql-editor.js +110 -0
  98. package/lib/cjs/components/logql-extension.js +55 -0
  99. package/lib/cjs/components/logql-highlight.js +40 -0
  100. package/lib/cjs/datasources/index.js +30 -0
  101. package/lib/cjs/datasources/loki-datasource/LokiDatasource.js +77 -0
  102. package/lib/cjs/datasources/loki-datasource/LokiDatasourceEditor.js +83 -0
  103. package/lib/cjs/datasources/loki-datasource/index.js +32 -0
  104. package/lib/cjs/datasources/loki-datasource/loki-datasource-types.js +16 -0
  105. package/lib/cjs/env.d.js +2 -0
  106. package/lib/cjs/getPluginModule.js +27 -0
  107. package/lib/cjs/index-federation.js +43 -0
  108. package/lib/cjs/index.js +28 -0
  109. package/lib/cjs/model/index.js +31 -0
  110. package/lib/cjs/model/loki-client-types.js +16 -0
  111. package/lib/cjs/model/loki-client.js +198 -0
  112. package/lib/cjs/model/loki-data-types.js +16 -0
  113. package/lib/cjs/model/loki-selectors.js +47 -0
  114. package/lib/cjs/panels/index.js +30 -0
  115. package/lib/cjs/panels/logstable/LogsTable.js +41 -0
  116. package/lib/cjs/panels/logstable/LogsTableComponent.js +43 -0
  117. package/lib/cjs/panels/logstable/LogsTableSettingsEditor.js +70 -0
  118. package/lib/cjs/panels/logstable/components/EmptyLogsState.js +49 -0
  119. package/lib/cjs/panels/logstable/components/LogRow/LogRow.js +158 -0
  120. package/lib/cjs/panels/logstable/components/LogRow/LogTimestamp.js +44 -0
  121. package/lib/cjs/panels/logstable/components/LogRow/LogsLabelsTable.js +74 -0
  122. package/lib/cjs/panels/logstable/components/LogRow/LogsStyles.js +77 -0
  123. package/lib/cjs/panels/logstable/components/LogRow/index.js +37 -0
  124. package/lib/cjs/panels/logstable/components/LogsList.js +44 -0
  125. package/lib/cjs/panels/logstable/components/VirtualizedLogsList.js +63 -0
  126. package/lib/cjs/panels/logstable/components/index.js +23 -0
  127. package/lib/cjs/panels/logstable/components/utils.js +39 -0
  128. package/lib/cjs/panels/logstable/hooks/useExpandedRows.js +45 -0
  129. package/lib/cjs/panels/logstable/hooks/useSeverity.js +43 -0
  130. package/lib/cjs/panels/logstable/index.js +33 -0
  131. package/lib/cjs/panels/logstable/logs-types.js +16 -0
  132. package/lib/cjs/queries/constants.js +22 -0
  133. package/lib/cjs/queries/index.js +31 -0
  134. package/lib/cjs/queries/loki-log-query/LokiLogQuery.js +31 -0
  135. package/lib/cjs/queries/loki-log-query/LokiLogQueryEditor.js +157 -0
  136. package/lib/cjs/queries/loki-log-query/get-loki-log-data.js +74 -0
  137. package/lib/cjs/queries/loki-log-query/index.js +21 -0
  138. package/lib/cjs/queries/loki-log-query/log-query-plugin-interface.js +4 -0
  139. package/lib/cjs/queries/loki-log-query/loki-log-query-types.js +4 -0
  140. package/lib/cjs/queries/loki-time-series-query/LokiTimeSeriesQuery.js +43 -0
  141. package/lib/cjs/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +118 -0
  142. package/lib/cjs/queries/loki-time-series-query/get-loki-time-series-data.js +120 -0
  143. package/lib/cjs/queries/loki-time-series-query/index.js +33 -0
  144. package/lib/cjs/queries/loki-time-series-query/loki-time-series-query-types.js +16 -0
  145. package/lib/cjs/setup-tests.js +7 -0
  146. package/lib/components/index.d.ts +3 -0
  147. package/lib/components/index.d.ts.map +1 -0
  148. package/lib/components/index.js +15 -0
  149. package/lib/components/index.js.map +1 -0
  150. package/lib/components/logql-editor.d.ts +5 -0
  151. package/lib/components/logql-editor.d.ts.map +1 -0
  152. package/lib/components/logql-editor.js +61 -0
  153. package/lib/components/logql-editor.js.map +1 -0
  154. package/lib/components/logql-extension.d.ts +4 -0
  155. package/lib/components/logql-extension.d.ts.map +1 -0
  156. package/lib/components/logql-extension.js +47 -0
  157. package/lib/components/logql-extension.js.map +1 -0
  158. package/lib/components/logql-highlight.d.ts +2 -0
  159. package/lib/components/logql-highlight.d.ts.map +1 -0
  160. package/lib/components/logql-highlight.js +32 -0
  161. package/lib/components/logql-highlight.js.map +1 -0
  162. package/lib/datasources/index.d.ts +2 -0
  163. package/lib/datasources/index.d.ts.map +1 -0
  164. package/lib/datasources/index.js +15 -0
  165. package/lib/datasources/index.js.map +1 -0
  166. package/lib/datasources/loki-datasource/LokiDatasource.d.ts +5 -0
  167. package/lib/datasources/loki-datasource/LokiDatasource.d.ts.map +1 -0
  168. package/lib/datasources/loki-datasource/LokiDatasource.js +69 -0
  169. package/lib/datasources/loki-datasource/LokiDatasource.js.map +1 -0
  170. package/lib/datasources/loki-datasource/LokiDatasourceEditor.d.ts +9 -0
  171. package/lib/datasources/loki-datasource/LokiDatasourceEditor.d.ts.map +1 -0
  172. package/lib/datasources/loki-datasource/LokiDatasourceEditor.js +75 -0
  173. package/lib/datasources/loki-datasource/LokiDatasourceEditor.js.map +1 -0
  174. package/lib/datasources/loki-datasource/index.d.ts +4 -0
  175. package/lib/datasources/loki-datasource/index.d.ts.map +1 -0
  176. package/lib/datasources/loki-datasource/index.js +17 -0
  177. package/lib/datasources/loki-datasource/index.js.map +1 -0
  178. package/lib/datasources/loki-datasource/loki-datasource-types.d.ts +6 -0
  179. package/lib/datasources/loki-datasource/loki-datasource-types.d.ts.map +1 -0
  180. package/lib/datasources/loki-datasource/loki-datasource-types.js +15 -0
  181. package/lib/datasources/loki-datasource/loki-datasource-types.js.map +1 -0
  182. package/lib/env.d.js +3 -0
  183. package/lib/env.d.js.map +1 -0
  184. package/lib/getPluginModule.d.ts +6 -0
  185. package/lib/getPluginModule.d.ts.map +1 -0
  186. package/lib/getPluginModule.js +16 -0
  187. package/lib/getPluginModule.js.map +1 -0
  188. package/lib/index-federation.d.ts +1 -0
  189. package/lib/index-federation.d.ts.map +1 -0
  190. package/lib/index-federation.js +3 -0
  191. package/lib/index-federation.js.map +1 -0
  192. package/lib/index.d.ts +6 -0
  193. package/lib/index.d.ts.map +1 -0
  194. package/lib/index.js +7 -0
  195. package/lib/index.js.map +1 -0
  196. package/lib/model/index.d.ts +3 -0
  197. package/lib/model/index.d.ts.map +1 -0
  198. package/lib/model/index.js +16 -0
  199. package/lib/model/index.js.map +1 -0
  200. package/lib/model/loki-client-types.d.ts +65 -0
  201. package/lib/model/loki-client-types.d.ts.map +1 -0
  202. package/lib/model/loki-client-types.js +15 -0
  203. package/lib/model/loki-client-types.js.map +1 -0
  204. package/lib/model/loki-client.d.ts +50 -0
  205. package/lib/model/loki-client.d.ts.map +1 -0
  206. package/lib/model/loki-client.js +161 -0
  207. package/lib/model/loki-client.js.map +1 -0
  208. package/lib/model/loki-data-types.d.ts +24 -0
  209. package/lib/model/loki-data-types.d.ts.map +1 -0
  210. package/lib/model/loki-data-types.js +15 -0
  211. package/lib/model/loki-data-types.js.map +1 -0
  212. package/lib/model/loki-selectors.d.ts +10 -0
  213. package/lib/model/loki-selectors.d.ts.map +1 -0
  214. package/lib/model/loki-selectors.js +25 -0
  215. package/lib/model/loki-selectors.js.map +1 -0
  216. package/lib/panels/index.d.ts +2 -0
  217. package/lib/panels/index.d.ts.map +1 -0
  218. package/lib/panels/index.js +15 -0
  219. package/lib/panels/index.js.map +1 -0
  220. package/lib/panels/logstable/LogsTable.d.ts +4 -0
  221. package/lib/panels/logstable/LogsTable.d.ts.map +1 -0
  222. package/lib/panels/logstable/LogsTable.js +33 -0
  223. package/lib/panels/logstable/LogsTable.js.map +1 -0
  224. package/lib/panels/logstable/LogsTableComponent.d.ts +4 -0
  225. package/lib/panels/logstable/LogsTableComponent.d.ts.map +1 -0
  226. package/lib/panels/logstable/LogsTableComponent.js +35 -0
  227. package/lib/panels/logstable/LogsTableComponent.js.map +1 -0
  228. package/lib/panels/logstable/LogsTableSettingsEditor.d.ts +7 -0
  229. package/lib/panels/logstable/LogsTableSettingsEditor.d.ts.map +1 -0
  230. package/lib/panels/logstable/LogsTableSettingsEditor.js +62 -0
  231. package/lib/panels/logstable/LogsTableSettingsEditor.js.map +1 -0
  232. package/lib/panels/logstable/components/EmptyLogsState.d.ts +7 -0
  233. package/lib/panels/logstable/components/EmptyLogsState.d.ts.map +1 -0
  234. package/lib/panels/logstable/components/EmptyLogsState.js +36 -0
  235. package/lib/panels/logstable/components/EmptyLogsState.js.map +1 -0
  236. package/lib/panels/logstable/components/LogRow/LogRow.d.ts +14 -0
  237. package/lib/panels/logstable/components/LogRow/LogRow.d.ts.map +1 -0
  238. package/lib/panels/logstable/components/LogRow/LogRow.js +104 -0
  239. package/lib/panels/logstable/components/LogRow/LogRow.js.map +1 -0
  240. package/lib/panels/logstable/components/LogRow/LogTimestamp.d.ts +7 -0
  241. package/lib/panels/logstable/components/LogRow/LogTimestamp.d.ts.map +1 -0
  242. package/lib/panels/logstable/components/LogRow/LogTimestamp.js +31 -0
  243. package/lib/panels/logstable/components/LogRow/LogTimestamp.js.map +1 -0
  244. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.d.ts +7 -0
  245. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.d.ts.map +1 -0
  246. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.js +61 -0
  247. package/lib/panels/logstable/components/LogRow/LogsLabelsTable.js.map +1 -0
  248. package/lib/panels/logstable/components/LogRow/LogsStyles.d.ts +22 -0
  249. package/lib/panels/logstable/components/LogRow/LogsStyles.d.ts.map +1 -0
  250. package/lib/panels/logstable/components/LogRow/LogsStyles.js +55 -0
  251. package/lib/panels/logstable/components/LogRow/LogsStyles.js.map +1 -0
  252. package/lib/panels/logstable/components/LogRow/index.d.ts +3 -0
  253. package/lib/panels/logstable/components/LogRow/index.d.ts.map +1 -0
  254. package/lib/panels/logstable/components/LogRow/index.js +16 -0
  255. package/lib/panels/logstable/components/LogRow/index.js.map +1 -0
  256. package/lib/panels/logstable/components/LogsList.d.ts +10 -0
  257. package/lib/panels/logstable/components/LogsList.d.ts.map +1 -0
  258. package/lib/panels/logstable/components/LogsList.js +31 -0
  259. package/lib/panels/logstable/components/LogsList.js.map +1 -0
  260. package/lib/panels/logstable/components/VirtualizedLogsList.d.ts +12 -0
  261. package/lib/panels/logstable/components/VirtualizedLogsList.d.ts.map +1 -0
  262. package/lib/panels/logstable/components/VirtualizedLogsList.js +50 -0
  263. package/lib/panels/logstable/components/VirtualizedLogsList.js.map +1 -0
  264. package/lib/panels/logstable/components/index.d.ts +2 -0
  265. package/lib/panels/logstable/components/index.d.ts.map +1 -0
  266. package/lib/panels/logstable/components/index.js +15 -0
  267. package/lib/panels/logstable/components/index.js.map +1 -0
  268. package/lib/panels/logstable/components/utils.d.ts +3 -0
  269. package/lib/panels/logstable/components/utils.d.ts.map +1 -0
  270. package/lib/panels/logstable/components/utils.js +31 -0
  271. package/lib/panels/logstable/components/utils.js.map +1 -0
  272. package/lib/panels/logstable/hooks/useExpandedRows.d.ts +6 -0
  273. package/lib/panels/logstable/hooks/useExpandedRows.d.ts.map +1 -0
  274. package/lib/panels/logstable/hooks/useExpandedRows.js +37 -0
  275. package/lib/panels/logstable/hooks/useExpandedRows.js.map +1 -0
  276. package/lib/panels/logstable/hooks/useSeverity.d.ts +3 -0
  277. package/lib/panels/logstable/hooks/useSeverity.d.ts.map +1 -0
  278. package/lib/panels/logstable/hooks/useSeverity.js +35 -0
  279. package/lib/panels/logstable/hooks/useSeverity.js.map +1 -0
  280. package/lib/panels/logstable/index.d.ts +5 -0
  281. package/lib/panels/logstable/index.d.ts.map +1 -0
  282. package/lib/panels/logstable/index.js +18 -0
  283. package/lib/panels/logstable/index.js.map +1 -0
  284. package/lib/panels/logstable/logs-types.d.ts +11 -0
  285. package/lib/panels/logstable/logs-types.d.ts.map +1 -0
  286. package/lib/panels/logstable/logs-types.js +15 -0
  287. package/lib/panels/logstable/logs-types.js.map +1 -0
  288. package/lib/queries/constants.d.ts +5 -0
  289. package/lib/queries/constants.d.ts.map +1 -0
  290. package/lib/queries/constants.js +6 -0
  291. package/lib/queries/constants.js.map +1 -0
  292. package/lib/queries/index.d.ts +3 -0
  293. package/lib/queries/index.d.ts.map +1 -0
  294. package/lib/queries/index.js +16 -0
  295. package/lib/queries/index.js.map +1 -0
  296. package/lib/queries/loki-log-query/LokiLogQuery.d.ts +4 -0
  297. package/lib/queries/loki-log-query/LokiLogQuery.d.ts.map +1 -0
  298. package/lib/queries/loki-log-query/LokiLogQuery.js +23 -0
  299. package/lib/queries/loki-log-query/LokiLogQuery.js.map +1 -0
  300. package/lib/queries/loki-log-query/LokiLogQueryEditor.d.ts +7 -0
  301. package/lib/queries/loki-log-query/LokiLogQueryEditor.d.ts.map +1 -0
  302. package/lib/queries/loki-log-query/LokiLogQueryEditor.js +149 -0
  303. package/lib/queries/loki-log-query/LokiLogQueryEditor.js.map +1 -0
  304. package/lib/queries/loki-log-query/get-loki-log-data.d.ts +4 -0
  305. package/lib/queries/loki-log-query/get-loki-log-data.d.ts.map +1 -0
  306. package/lib/queries/loki-log-query/get-loki-log-data.js +66 -0
  307. package/lib/queries/loki-log-query/get-loki-log-data.js.map +1 -0
  308. package/lib/queries/loki-log-query/index.d.ts +5 -0
  309. package/lib/queries/loki-log-query/index.d.ts.map +1 -0
  310. package/lib/queries/loki-log-query/index.js +6 -0
  311. package/lib/queries/loki-log-query/index.js.map +1 -0
  312. package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts +25 -0
  313. package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts.map +1 -0
  314. package/lib/queries/loki-log-query/log-query-plugin-interface.js +3 -0
  315. package/lib/queries/loki-log-query/log-query-plugin-interface.js.map +1 -0
  316. package/lib/queries/loki-log-query/loki-log-query-types.d.ts +9 -0
  317. package/lib/queries/loki-log-query/loki-log-query-types.d.ts.map +1 -0
  318. package/lib/queries/loki-log-query/loki-log-query-types.js +3 -0
  319. package/lib/queries/loki-log-query/loki-log-query-types.js.map +1 -0
  320. package/lib/queries/loki-time-series-query/LokiTimeSeriesQuery.d.ts +4 -0
  321. package/lib/queries/loki-time-series-query/LokiTimeSeriesQuery.d.ts.map +1 -0
  322. package/lib/queries/loki-time-series-query/LokiTimeSeriesQuery.js +35 -0
  323. package/lib/queries/loki-time-series-query/LokiTimeSeriesQuery.js.map +1 -0
  324. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.d.ts +7 -0
  325. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.d.ts.map +1 -0
  326. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +110 -0
  327. package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js.map +1 -0
  328. package/lib/queries/loki-time-series-query/get-loki-time-series-data.d.ts +12 -0
  329. package/lib/queries/loki-time-series-query/get-loki-time-series-data.d.ts.map +1 -0
  330. package/lib/queries/loki-time-series-query/get-loki-time-series-data.js +112 -0
  331. package/lib/queries/loki-time-series-query/get-loki-time-series-data.js.map +1 -0
  332. package/lib/queries/loki-time-series-query/index.d.ts +5 -0
  333. package/lib/queries/loki-time-series-query/index.d.ts.map +1 -0
  334. package/lib/queries/loki-time-series-query/index.js +18 -0
  335. package/lib/queries/loki-time-series-query/index.js.map +1 -0
  336. package/lib/queries/loki-time-series-query/loki-time-series-query-types.d.ts +9 -0
  337. package/lib/queries/loki-time-series-query/loki-time-series-query-types.d.ts.map +1 -0
  338. package/lib/queries/loki-time-series-query/loki-time-series-query-types.js +15 -0
  339. package/lib/queries/loki-time-series-query/loki-time-series-query-types.js.map +1 -0
  340. package/lib/setup-tests.d.ts +2 -0
  341. package/lib/setup-tests.d.ts.map +1 -0
  342. package/lib/setup-tests.js +5 -0
  343. package/lib/setup-tests.js.map +1 -0
  344. package/mf-manifest.json +528 -0
  345. package/mf-stats.json +584 -0
  346. package/package.json +1 -1
@@ -0,0 +1,110 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';
15
+ import { InputLabel, Stack } from '@mui/material';
16
+ import { useCallback, useState, useEffect } from 'react';
17
+ import { LogQLEditor } from '../../components/logql-editor';
18
+ import { LOKI_DATASOURCE_KIND } from '../../model';
19
+ import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';
20
+ export function LokiQueryEditor(props) {
21
+ const { onChange, value } = props;
22
+ const { datasource } = value;
23
+ const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;
24
+ const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, LOKI_DATASOURCE_KIND);
25
+ // const { data: client } = useDatasourceClient<LokiClient>(selectedDatasource);
26
+ // const lokiURL = client?.options.datasourceUrl;
27
+ // Local state for editor value to prevent query_range calls on every keystroke
28
+ const [localQuery, setLocalQuery] = useState(value.query);
29
+ // Update local state when prop changes
30
+ useEffect(()=>{
31
+ setLocalQuery(value.query);
32
+ }, [
33
+ value.query
34
+ ]);
35
+ const handleDatasourceChange = (newDatasourceSelection)=>{
36
+ if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {
37
+ onChange({
38
+ ...value,
39
+ datasource: newDatasourceSelection
40
+ });
41
+ return;
42
+ }
43
+ throw new Error('Got unexpected non LokiQuery datasource selection');
44
+ };
45
+ // Debounced query change handler to prevent excessive query_range calls
46
+ const handleQueryChange = useCallback((newQuery)=>{
47
+ setLocalQuery(newQuery);
48
+ }, []);
49
+ // Immediate query execution on Enter or blur
50
+ const handleQueryExecute = useCallback((query)=>{
51
+ onChange({
52
+ ...value,
53
+ query
54
+ });
55
+ }, [
56
+ onChange,
57
+ value
58
+ ]);
59
+ return /*#__PURE__*/ _jsxs(Stack, {
60
+ spacing: 1.5,
61
+ paddingBottom: 1,
62
+ children: [
63
+ /*#__PURE__*/ _jsxs("div", {
64
+ children: [
65
+ /*#__PURE__*/ _jsx(InputLabel, {
66
+ sx: {
67
+ display: 'block',
68
+ marginBottom: '4px',
69
+ fontWeight: 500
70
+ },
71
+ children: "Datasource"
72
+ }),
73
+ /*#__PURE__*/ _jsx(DatasourceSelect, {
74
+ datasourcePluginKind: DATASOURCE_KIND,
75
+ value: selectedDatasource,
76
+ onChange: handleDatasourceChange,
77
+ label: "Loki Datasource",
78
+ notched: true
79
+ })
80
+ ]
81
+ }),
82
+ /*#__PURE__*/ _jsxs("div", {
83
+ children: [
84
+ /*#__PURE__*/ _jsx(InputLabel, {
85
+ sx: {
86
+ display: 'block',
87
+ marginBottom: '4px',
88
+ fontWeight: 500
89
+ },
90
+ children: "LogQL Query"
91
+ }),
92
+ /*#__PURE__*/ _jsx(LogQLEditor, {
93
+ value: localQuery,
94
+ onChange: handleQueryChange,
95
+ onBlur: ()=>handleQueryExecute(localQuery),
96
+ onKeyDown: (event)=>{
97
+ if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
98
+ event.preventDefault();
99
+ handleQueryExecute(localQuery);
100
+ }
101
+ },
102
+ placeholder: 'Enter LogQL query (e.g. {job="mysql"} |= "error")'
103
+ })
104
+ ]
105
+ })
106
+ ]
107
+ });
108
+ }
109
+
110
+ //# sourceMappingURL=LokiTimeSeriesQueryEditor.js.map
@@ -0,0 +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, useState, useEffect } from 'react';\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';\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\n // const { data: client } = useDatasourceClient<LokiClient>(selectedDatasource);\n // const lokiURL = client?.options.datasourceUrl;\n\n // Local state for editor value to prevent query_range calls on every keystroke\n const [localQuery, setLocalQuery] = useState(value.query);\n\n // Update local state when prop changes\n useEffect(() => {\n setLocalQuery(value.query);\n }, [value.query]);\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (newDatasourceSelection) => {\n if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {\n onChange({ ...value, datasource: newDatasourceSelection });\n return;\n }\n\n throw new Error('Got unexpected non LokiQuery datasource selection');\n };\n\n // Debounced query change handler to prevent excessive query_range calls\n const handleQueryChange = useCallback((newQuery: string) => {\n setLocalQuery(newQuery);\n }, []);\n\n // Immediate query execution on Enter or blur\n const handleQueryExecute = useCallback(\n (query: string) => {\n onChange({ ...value, query });\n },\n [onChange, value]\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={localQuery}\n onChange={handleQueryChange}\n onBlur={() => handleQueryExecute(localQuery)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {\n event.preventDefault();\n handleQueryExecute(localQuery);\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","useState","useEffect","LogQLEditor","LOKI_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","LokiQueryEditor","props","onChange","value","datasource","datasourceSelectValue","selectedDatasource","localQuery","setLocalQuery","query","handleDatasourceChange","newDatasourceSelection","kind","Error","handleQueryChange","newQuery","handleQueryExecute","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,gBAAg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GD,KAACnC;wBACCoC,sBAAsB1B;wBACtBK,OAAOG;wBACPJ,UAAUQ;wBACVe,OAAM;wBACNC,OAAO;;;;0BAIX,MAACP;;kCACC,KAAC5B;wBACC6B,IAAI;4BACFC,SAAS;4BACTC,cAAc;4BACdC,YAAY;wBACd;kCACD;;kCAGD,KAAC3B;wBACCO,OAAOI;wBACPL,UAAUY;wBACVa,QAAQ,IAAMX,mBAAmBT;wBACjCqB,WAAW,CAACC;4BACV,IAAIA,MAAMC,GAAG,KAAK,WAAYD,CAAAA,MAAME,OAAO,IAAIF,MAAMG,OAAO,AAAD,GAAI;gCAC7DH,MAAMI,cAAc;gCACpBjB,mBAAmBT;4BACrB;wBACF;wBACA2B,aAAY;;;;;;AAMtB"}
@@ -0,0 +1,12 @@
1
+ import { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system';
2
+ import { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types';
3
+ export type LokiMatrixResult = {
4
+ metric: Record<string, string>;
5
+ values: Array<[number, string]>;
6
+ };
7
+ export type LokiMatrixResponse = {
8
+ resultType: 'matrix';
9
+ result: LokiMatrixResult[];
10
+ };
11
+ export declare const getLokiTimeSeriesData: TimeSeriesQueryPlugin<LokiTimeSeriesQuerySpec>['getTimeSeriesData'];
12
+ //# sourceMappingURL=get-loki-time-series-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-loki-time-series-data.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-time-series-query/get-loki-time-series-data.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,2BAA2B,CAAC;AAIpF,OAAO,EAAE,uBAAuB,EAA+B,MAAM,gCAAgC,CAAC;AAEtG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,QAAQ,CAAC;IACrB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAkEF,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,uBAAuB,CAAC,CAAC,mBAAmB,CAoDrG,CAAC"}
@@ -0,0 +1,112 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { parseDurationString } from '@perses-dev/core';
14
+ import { replaceVariables } from '@perses-dev/plugin-system';
15
+ import { milliseconds } from 'date-fns';
16
+ import { DEFAULT_DATASOURCE } from '../constants';
17
+ // Constants for Loki step calculation
18
+ const MAX_LOKI_DATA_POINTS = 10000; // Similar to Prometheus
19
+ const DEFAULT_MIN_STEP_SECONDS = 15; // 15 seconds default minimum
20
+ /**
21
+ * Converts a duration string (like "15s", "1m") to seconds
22
+ */ function getDurationStringSeconds(durationString) {
23
+ if (!durationString) return undefined;
24
+ const duration = parseDurationString(durationString);
25
+ const ms = milliseconds(duration);
26
+ return Math.floor(ms / 1000);
27
+ }
28
+ /**
29
+ * Calculates appropriate step for Loki range queries
30
+ */ function getLokiRangeStep(startMs, endMs, minStepSeconds = DEFAULT_MIN_STEP_SECONDS, suggestedStepMs = 0) {
31
+ const suggestedStepSeconds = suggestedStepMs / 1000;
32
+ const queryRangeSeconds = (endMs - startMs) / 1000;
33
+ let safeStep = queryRangeSeconds / MAX_LOKI_DATA_POINTS;
34
+ if (safeStep > 1) {
35
+ safeStep = Math.ceil(safeStep);
36
+ }
37
+ return Math.max(suggestedStepSeconds, minStepSeconds, safeStep);
38
+ }
39
+ /**
40
+ * Formats step in seconds as a duration string for Loki API
41
+ */ function formatStepForLoki(stepSeconds) {
42
+ if (stepSeconds < 60) {
43
+ return `${Math.round(stepSeconds)}s`;
44
+ } else if (stepSeconds < 3600) {
45
+ return `${Math.round(stepSeconds / 60)}m`;
46
+ } else {
47
+ return `${Math.round(stepSeconds / 3600)}h`;
48
+ }
49
+ }
50
+ function convertMatrixToTimeSeries(matrix) {
51
+ return matrix.map((series)=>{
52
+ const name = Object.entries(series.metric).map(([k, v])=>`${k}=${v}`).join(', ');
53
+ return {
54
+ name,
55
+ values: series.values.map(([timestamp, value])=>[
56
+ Number(timestamp) * 1000,
57
+ Number(value)
58
+ ]),
59
+ labels: series.metric
60
+ };
61
+ });
62
+ }
63
+ export const getLokiTimeSeriesData = async (spec, context)=>{
64
+ if (!spec.query) {
65
+ return {
66
+ series: [],
67
+ timeRange: {
68
+ start: context.timeRange.start,
69
+ end: context.timeRange.end
70
+ },
71
+ stepMs: DEFAULT_MIN_STEP_SECONDS * 1000
72
+ };
73
+ }
74
+ const query = replaceVariables(spec.query, context.variableState);
75
+ const client = await context.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_DATASOURCE);
76
+ const { start, end } = context.timeRange;
77
+ // Calculate proper step using similar logic to Prometheus
78
+ const minStepSeconds = spec.step ? getDurationStringSeconds(spec.step) ?? DEFAULT_MIN_STEP_SECONDS : DEFAULT_MIN_STEP_SECONDS;
79
+ const stepSeconds = getLokiRangeStep(start.getTime(), end.getTime(), minStepSeconds, context.suggestedStepMs);
80
+ const stepString = formatStepForLoki(stepSeconds);
81
+ const stepMs = stepSeconds * 1000;
82
+ const response = await client.queryRange({
83
+ query,
84
+ start: start.getTime().toString(),
85
+ end: end.getTime().toString(),
86
+ step: stepString
87
+ });
88
+ if (response.data.resultType === 'matrix') {
89
+ const convertedSeries = convertMatrixToTimeSeries(response.data.result);
90
+ return {
91
+ series: convertedSeries,
92
+ timeRange: {
93
+ start,
94
+ end
95
+ },
96
+ stepMs,
97
+ metadata: {
98
+ executedQueryString: query
99
+ }
100
+ };
101
+ }
102
+ return {
103
+ series: [],
104
+ timeRange: {
105
+ start,
106
+ end
107
+ },
108
+ stepMs
109
+ };
110
+ };
111
+
112
+ //# sourceMappingURL=get-loki-time-series-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queries/loki-time-series-query/get-loki-time-series-data.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TimeSeries, DurationString, parseDurationString } from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system';\nimport { milliseconds } from 'date-fns';\nimport { LokiClient } from '../../model/loki-client';\nimport { DEFAULT_DATASOURCE } from '../constants';\nimport { LokiTimeSeriesQuerySpec, LokiTimeSeriesQueryResponse } from './loki-time-series-query-types';\n\nexport type LokiMatrixResult = {\n metric: Record<string, string>;\n values: Array<[number, string]>;\n};\n\nexport type LokiMatrixResponse = {\n resultType: 'matrix';\n result: LokiMatrixResult[];\n};\n\n// Constants for Loki step calculation\nconst MAX_LOKI_DATA_POINTS = 10000; // Similar to Prometheus\nconst DEFAULT_MIN_STEP_SECONDS = 15; // 15 seconds default minimum\n\n/**\n * Converts a duration string (like \"15s\", \"1m\") to seconds\n */\nfunction getDurationStringSeconds(durationString?: DurationString): number | undefined {\n if (!durationString) return undefined;\n\n const duration = parseDurationString(durationString);\n const ms = milliseconds(duration);\n return Math.floor(ms / 1000);\n}\n\n/**\n * Calculates appropriate step for Loki range queries\n */\nfunction getLokiRangeStep(\n startMs: number,\n endMs: number,\n minStepSeconds = DEFAULT_MIN_STEP_SECONDS,\n suggestedStepMs = 0\n): number {\n const suggestedStepSeconds = suggestedStepMs / 1000;\n const queryRangeSeconds = (endMs - startMs) / 1000;\n\n let safeStep = queryRangeSeconds / MAX_LOKI_DATA_POINTS;\n if (safeStep > 1) {\n safeStep = Math.ceil(safeStep);\n }\n\n return Math.max(suggestedStepSeconds, minStepSeconds, safeStep);\n}\n\n/**\n * Formats step in seconds as a duration string for Loki API\n */\nfunction formatStepForLoki(stepSeconds: number): string {\n if (stepSeconds < 60) {\n return `${Math.round(stepSeconds)}s`;\n } else if (stepSeconds < 3600) {\n return `${Math.round(stepSeconds / 60)}m`;\n } else {\n return `${Math.round(stepSeconds / 3600)}h`;\n }\n}\n\nfunction convertMatrixToTimeSeries(matrix: LokiMatrixResult[]): TimeSeries[] {\n return matrix.map((series) => {\n const name = Object.entries(series.metric)\n .map(([k, v]) => `${k}=${v}`)\n .join(', ');\n return {\n name,\n values: series.values.map(([timestamp, value]) => [\n Number(timestamp) * 1000, // Convert seconds to milliseconds\n Number(value),\n ]),\n labels: series.metric,\n };\n });\n}\n\nexport const getLokiTimeSeriesData: TimeSeriesQueryPlugin<LokiTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context\n) => {\n if (!spec.query) {\n return {\n series: [],\n timeRange: { start: context.timeRange.start, end: context.timeRange.end },\n stepMs: DEFAULT_MIN_STEP_SECONDS * 1000,\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 // Calculate proper step using similar logic to Prometheus\n const minStepSeconds = spec.step\n ? (getDurationStringSeconds(spec.step as DurationString) ?? DEFAULT_MIN_STEP_SECONDS)\n : DEFAULT_MIN_STEP_SECONDS;\n const stepSeconds = getLokiRangeStep(start.getTime(), end.getTime(), minStepSeconds, context.suggestedStepMs);\n const stepString = formatStepForLoki(stepSeconds);\n const stepMs = stepSeconds * 1000;\n\n const response: LokiTimeSeriesQueryResponse = await client.queryRange({\n query,\n start: start.getTime().toString(),\n end: end.getTime().toString(),\n step: stepString,\n });\n\n if (response.data.resultType === 'matrix') {\n const convertedSeries = convertMatrixToTimeSeries(response.data.result as LokiMatrixResult[]);\n\n return {\n series: convertedSeries,\n timeRange: { start, end },\n stepMs,\n metadata: {\n executedQueryString: query,\n },\n };\n }\n\n return {\n series: [],\n timeRange: { start, end },\n stepMs,\n };\n};\n"],"names":["parseDurationString","replaceVariables","milliseconds","DEFAULT_DATASOURCE","MAX_LOKI_DATA_POINTS","DEFAULT_MIN_STEP_SECONDS","getDurationStringSeconds","durationString","undefined","duration","ms","Math","floor","getLokiRangeStep","startMs","endMs","minStepSeconds","suggestedStepMs","suggestedStepSeconds","queryRangeSeconds","safeStep","ceil","max","formatStepForLoki","stepSeconds","round","convertMatrixToTimeSeries","matrix","map","series","name","Object","entries","metric","k","v","join","values","timestamp","value","Number","labels","getLokiTimeSeriesData","spec","context","query","timeRange","start","end","stepMs","variableState","client","datasourceStore","getDatasourceClient","datasource","step","getTime","stepString","response","queryRange","toString","data","resultType","convertedSeries","result","metadata","executedQueryString"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAqCA,mBAAmB,QAAQ,mBAAmB;AACnF,SAAgCC,gBAAgB,QAAQ,4BAA4B;AACpF,SAASC,YAAY,QAAQ,WAAW;AAExC,SAASC,kBAAkB,QAAQ,eAAe;AAalD,sCAAsC;AACtC,MAAMC,uBAAuB,OAAO,wBAAwB;AAC5D,MAAMC,2BAA2B,IAAI,6BAA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5 @@
1
+ export * from './get-loki-time-series-data';
2
+ export * from './LokiTimeSeriesQuery';
3
+ export * from './LokiTimeSeriesQueryEditor';
4
+ export * from './loki-time-series-query-types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-time-series-query/index.ts"],"names":[],"mappings":"AAaA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,18 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './get-loki-time-series-data';
14
+ export * from './LokiTimeSeriesQuery';
15
+ export * from './LokiTimeSeriesQueryEditor';
16
+ export * from './loki-time-series-query-types';
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queries/loki-time-series-query/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './get-loki-time-series-data';\nexport * from './LokiTimeSeriesQuery';\nexport * from './LokiTimeSeriesQueryEditor';\nexport * from './loki-time-series-query-types';\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;AAEjC,cAAc,8BAA8B;AAC5C,cAAc,wBAAwB;AACtC,cAAc,8BAA8B;AAC5C,cAAc,iCAAiC"}
@@ -0,0 +1,9 @@
1
+ import { DatasourceSelector } from '@perses-dev/core';
2
+ import { LokiQueryRangeMatrixResponse } from '../../model/loki-client-types';
3
+ export interface LokiTimeSeriesQuerySpec {
4
+ query: string;
5
+ datasource?: DatasourceSelector;
6
+ step?: string;
7
+ }
8
+ export type LokiTimeSeriesQueryResponse = LokiQueryRangeMatrixResponse;
9
+ //# sourceMappingURL=loki-time-series-query-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loki-time-series-query-types.d.ts","sourceRoot":"","sources":["../../../../src/queries/loki-time-series-query/loki-time-series-query-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,2BAA2B,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export { };
14
+
15
+ //# sourceMappingURL=loki-time-series-query-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queries/loki-time-series-query/loki-time-series-query-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 { DatasourceSelector } from '@perses-dev/core';\nimport { LokiQueryRangeMatrixResponse } from '../../model/loki-client-types';\n\nexport interface LokiTimeSeriesQuerySpec {\n query: string;\n datasource?: DatasourceSelector;\n step?: string;\n}\n\nexport type LokiTimeSeriesQueryResponse = LokiQueryRangeMatrixResponse;\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;AAWjC,WAAuE"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=setup-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import '@testing-library/jest-dom';
2
+ // Always mock e-charts during tests since we don't have a proper canvas in jsdom
3
+ jest.mock('echarts/core');
4
+
5
+ //# sourceMappingURL=setup-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["import '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}