@perses-dev/loki-plugin 0.5.1 → 0.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/css/async/7354.85c2cbf6.css +1 -0
- package/__mf/font/inter-cyrillic-300-normal.432f2b21.woff +0 -0
- package/__mf/font/inter-cyrillic-300-normal.9da91009.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.372704ff.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.a6b6ef6f.woff +0 -0
- package/__mf/font/inter-cyrillic-500-normal.7c15bba8.woff2 +0 -0
- package/__mf/font/inter-cyrillic-500-normal.b9f8c929.woff +0 -0
- package/__mf/font/inter-cyrillic-600-normal.2f42892a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-600-normal.c3987adc.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.93eba3c3.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.e9e5b2dc.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.f285bd7a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.ffbd8a3a.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.95bb9038.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.cfc143a9.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.2a31c04b.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.f572b170.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.5a6bb1da.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.fe0d9b14.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.ecbdecad.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.f7b3c15b.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.4b4022a6.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.74b516d2.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.9970ddb5.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.a0d59adc.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.0d7be683.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.8f0b988e.woff +0 -0
- package/__mf/font/inter-greek-400-normal.cc58c11b.woff +0 -0
- package/__mf/font/inter-greek-400-normal.d7020e3c.woff2 +0 -0
- package/__mf/font/inter-greek-500-normal.d9a33207.woff +0 -0
- package/__mf/font/inter-greek-500-normal.f41f43db.woff2 +0 -0
- package/__mf/font/inter-greek-600-normal.4ec0c1c1.woff +0 -0
- package/__mf/font/inter-greek-600-normal.cc532937.woff2 +0 -0
- package/__mf/font/inter-greek-700-normal.5ec6c758.woff +0 -0
- package/__mf/font/inter-greek-700-normal.97f0eeeb.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.46b66369.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.9ae3a3c5.woff +0 -0
- package/__mf/font/inter-greek-ext-300-normal.10247a66.woff2 +0 -0
- package/__mf/font/inter-greek-ext-300-normal.4668e5cb.woff +0 -0
- package/__mf/font/inter-greek-ext-400-normal.4ce1df5d.woff2 +0 -0
- package/__mf/font/inter-greek-ext-400-normal.88ede1ea.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.7a4aa726.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.cbd51e2d.woff2 +0 -0
- package/__mf/font/inter-greek-ext-600-normal.089a95ee.woff +0 -0
- package/__mf/font/inter-greek-ext-600-normal.1f33d317.woff2 +0 -0
- package/__mf/font/inter-greek-ext-700-normal.31f1075d.woff +0 -0
- package/__mf/font/inter-greek-ext-700-normal.827cd618.woff2 +0 -0
- package/__mf/font/inter-greek-ext-900-normal.531bcee7.woff +0 -0
- package/__mf/font/inter-greek-ext-900-normal.8a9b36b9.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.15fb600d.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.6f95f590.woff +0 -0
- package/__mf/font/inter-latin-400-normal.2c7a775c.woff +0 -0
- package/__mf/font/inter-latin-400-normal.ef6d3f52.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.b7b43ace.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.cb4c8ceb.woff +0 -0
- package/__mf/font/inter-latin-600-normal.8fb1a964.woff2 +0 -0
- package/__mf/font/inter-latin-600-normal.ce0f5f43.woff +0 -0
- package/__mf/font/inter-latin-700-normal.953b7aa5.woff2 +0 -0
- package/__mf/font/inter-latin-700-normal.9c21d4dc.woff +0 -0
- package/__mf/font/inter-latin-900-normal.2a8028ec.woff2 +0 -0
- package/__mf/font/inter-latin-900-normal.fa252135.woff +0 -0
- package/__mf/font/inter-latin-ext-300-normal.167cc8c9.woff2 +0 -0
- package/__mf/font/inter-latin-ext-300-normal.f695be66.woff +0 -0
- package/__mf/font/inter-latin-ext-400-normal.32a25442.woff2 +0 -0
- package/__mf/font/inter-latin-ext-400-normal.4edcaace.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.a19a84a6.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.d9b491de.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.38b075d8.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.49faa47a.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.93534b50.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.b63daa1a.woff2 +0 -0
- package/__mf/font/inter-latin-ext-900-normal.0efdb307.woff +0 -0
- package/__mf/font/inter-latin-ext-900-normal.9c0fc2c7.woff2 +0 -0
- package/__mf/font/inter-vietnamese-300-normal.aad496d8.woff +0 -0
- package/__mf/font/inter-vietnamese-300-normal.ad9ef503.woff2 +0 -0
- package/__mf/font/inter-vietnamese-400-normal.a9dd2faf.woff +0 -0
- package/__mf/font/inter-vietnamese-400-normal.de4fc44f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.7c0a695f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.a3a73b95.woff +0 -0
- package/__mf/font/inter-vietnamese-600-normal.9d518599.woff2 +0 -0
- package/__mf/font/inter-vietnamese-600-normal.c5ce3fcb.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.bc68b199.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.faf12809.woff2 +0 -0
- package/__mf/font/inter-vietnamese-900-normal.2b782045.woff +0 -0
- package/__mf/font/inter-vietnamese-900-normal.e639b65a.woff2 +0 -0
- package/__mf/js/Loki.b7bb557c.js +7 -0
- package/__mf/js/async/1099.b49be119.js +1 -0
- package/__mf/js/async/155.fff99fe4.js +1 -0
- package/__mf/js/async/1616.9255be19.js +1 -0
- package/__mf/js/async/1728.c02a720c.js +1 -0
- package/__mf/js/async/1825.f02ff871.js +1 -0
- package/__mf/js/async/1969.f83e62d6.js +1 -0
- package/__mf/js/async/2043.79caea8b.js +2 -0
- package/__mf/js/async/2386.cebea91a.js +2 -0
- package/__mf/js/async/2502.943ec1cf.js +1 -0
- package/__mf/js/async/2657.5f9f9807.js +1 -0
- package/__mf/js/async/3181.b238b7b9.js +2 -0
- package/__mf/js/async/392.22b48ffa.js +2 -0
- package/__mf/js/async/4121.e547e3d4.js +2 -0
- package/__mf/js/async/4466.293eb237.js +74 -0
- package/__mf/js/async/5002.a483400c.js +1 -0
- package/__mf/js/async/5038.c6e1ac5e.js +2 -0
- package/__mf/js/async/5071.fd1136c7.js +1 -0
- package/__mf/js/async/5440.ff741d36.js +2 -0
- package/__mf/js/async/5587.e582af3f.js +1 -0
- package/__mf/js/async/6100.7d5962ad.js +1 -0
- package/__mf/js/async/6274.7255b4e9.js +2 -0
- package/__mf/js/async/6688.ad8a65bc.js +2 -0
- package/__mf/js/async/6823.7efa6882.js +2 -0
- package/__mf/js/async/{6710.a94fd362.js.LICENSE.txt → 6823.7efa6882.js.LICENSE.txt} +17 -1
- package/__mf/js/async/6898.11c8bae6.js +1 -0
- package/__mf/js/async/7095.0a8daf30.js +1 -0
- package/__mf/js/async/7177.7b6606d3.js +1 -0
- package/__mf/js/async/7192.b5444c91.js +1 -0
- package/__mf/js/async/7354.789ddba3.js +7 -0
- package/__mf/js/async/{9811.422fb6ad.js.LICENSE.txt → 7354.789ddba3.js.LICENSE.txt} +19 -1
- package/__mf/js/async/7413.972aa60d.js +1 -0
- package/__mf/js/async/7862.679d0bd3.js +2 -0
- package/__mf/js/async/7968.952aec3b.js +1 -0
- package/__mf/js/async/7978.5f20023d.js +1 -0
- package/__mf/js/async/8199.98434cf3.js +28 -0
- package/__mf/js/async/8356.6bbe764b.js +1 -0
- package/__mf/js/async/8470.6f15ddf5.js +2 -0
- package/__mf/js/async/873.f59ec7c0.js +1 -0
- package/__mf/js/async/8750.fe623c5f.js +3 -0
- package/__mf/js/async/8988.cb10cfd3.js +1 -0
- package/__mf/js/async/9235.8532a487.js +1 -0
- package/__mf/js/async/9389.a063f523.js +2 -0
- package/__mf/js/async/941.49e5f628.js +2 -0
- package/__mf/js/async/9588.688593c0.js +1 -0
- package/__mf/js/async/9754.0c807c53.js +10 -0
- package/__mf/js/async/{9754.5d7b21c2.js.LICENSE.txt → 9754.0c807c53.js.LICENSE.txt} +1 -1
- package/__mf/js/async/9836.5401a9ec.js +1 -0
- package/__mf/js/async/9877.874a39f4.js +38 -0
- package/__mf/js/async/9916.d88af7d4.js +22 -0
- package/__mf/js/async/__federation_expose_LokiDatasource.6b14cd90.js +2 -0
- package/__mf/js/async/__federation_expose_LokiLabelNamesVariable.59592351.js +1 -0
- package/__mf/js/async/__federation_expose_LokiLabelValuesVariable.6bdc7a31.js +1 -0
- package/__mf/js/async/__federation_expose_LokiLogQLVariable.914390c4.js +1 -0
- package/__mf/js/async/__federation_expose_LokiLogQuery.18f1e6d4.js +1 -0
- package/__mf/js/async/__federation_expose_LokiTimeSeriesQuery.48d9f8d9.js +1 -0
- package/__mf/js/main.c96737bf.js +7 -0
- package/lib/cjs/components/complete.js +11 -4
- package/lib/cjs/datasources/loki-datasource/LokiDatasource.js +2 -2
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/model/loki-client.js +51 -7
- package/lib/cjs/queries/loki-log-query/LokiLogQueryEditor.js +2 -6
- package/lib/cjs/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +2 -6
- package/lib/cjs/queries/loki-time-series-query/get-loki-time-series-data.js +2 -2
- package/lib/cjs/variables/LokiLabelNamesVariable.js +53 -0
- package/lib/cjs/variables/LokiLabelValuesVariable.js +58 -0
- package/lib/cjs/variables/LokiLogQLVariable.js +64 -0
- package/lib/cjs/variables/MatcherEditor.js +84 -0
- package/lib/cjs/variables/index.js +35 -0
- package/lib/cjs/variables/loki-variables.js +239 -0
- package/lib/cjs/variables/types.js +16 -0
- package/lib/components/complete.js +11 -4
- package/lib/components/complete.js.map +1 -1
- package/lib/components/logql-extension.d.ts +1 -1
- package/lib/components/logql-extension.js.map +1 -1
- package/lib/datasources/loki-datasource/LokiDatasource.d.ts.map +1 -1
- package/lib/datasources/loki-datasource/LokiDatasource.js +2 -2
- package/lib/datasources/loki-datasource/LokiDatasource.js.map +1 -1
- package/lib/datasources/loki-datasource/loki-datasource-types.d.ts +1 -1
- package/lib/datasources/loki-datasource/loki-datasource-types.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/model/loki-client-types.d.ts +1 -1
- package/lib/model/loki-client-types.js.map +1 -1
- package/lib/model/loki-client.d.ts +20 -4
- package/lib/model/loki-client.d.ts.map +1 -1
- package/lib/model/loki-client.js +48 -7
- package/lib/model/loki-client.js.map +1 -1
- package/lib/model/loki-data-types.d.ts +1 -1
- package/lib/model/loki-data-types.d.ts.map +1 -1
- package/lib/model/loki-data-types.js.map +1 -1
- package/lib/model/loki-selectors.d.ts +1 -1
- package/lib/model/loki-selectors.d.ts.map +1 -1
- package/lib/model/loki-selectors.js.map +1 -1
- package/lib/queries/loki-log-query/LokiLogQueryEditor.d.ts.map +1 -1
- package/lib/queries/loki-log-query/LokiLogQueryEditor.js +2 -6
- package/lib/queries/loki-log-query/LokiLogQueryEditor.js.map +1 -1
- package/lib/queries/loki-log-query/get-loki-log-data.d.ts.map +1 -1
- package/lib/queries/loki-log-query/get-loki-log-data.js.map +1 -1
- package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts +1 -1
- package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts.map +1 -1
- package/lib/queries/loki-log-query/log-query-plugin-interface.js.map +1 -1
- package/lib/queries/loki-log-query/loki-log-query-types.d.ts +1 -1
- package/lib/queries/loki-log-query/loki-log-query-types.js.map +1 -1
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +2 -6
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js.map +1 -1
- package/lib/queries/loki-time-series-query/get-loki-time-series-data.d.ts.map +1 -1
- package/lib/queries/loki-time-series-query/get-loki-time-series-data.js +1 -1
- package/lib/queries/loki-time-series-query/get-loki-time-series-data.js.map +1 -1
- package/lib/queries/loki-time-series-query/loki-time-series-query-types.d.ts +1 -1
- package/lib/queries/loki-time-series-query/loki-time-series-query-types.js.map +1 -1
- package/lib/variables/LokiLabelNamesVariable.d.ts +4 -0
- package/lib/variables/LokiLabelNamesVariable.d.ts.map +1 -0
- package/lib/variables/LokiLabelNamesVariable.js +45 -0
- package/lib/variables/LokiLabelNamesVariable.js.map +1 -0
- package/lib/variables/LokiLabelValuesVariable.d.ts +4 -0
- package/lib/variables/LokiLabelValuesVariable.d.ts.map +1 -0
- package/lib/variables/LokiLabelValuesVariable.js +50 -0
- package/lib/variables/LokiLabelValuesVariable.js.map +1 -0
- package/lib/variables/LokiLogQLVariable.d.ts +4 -0
- package/lib/variables/LokiLogQLVariable.d.ts.map +1 -0
- package/lib/variables/LokiLogQLVariable.js +56 -0
- package/lib/variables/LokiLogQLVariable.js.map +1 -0
- package/lib/variables/MatcherEditor.d.ts +9 -0
- package/lib/variables/MatcherEditor.d.ts.map +1 -0
- package/lib/variables/MatcherEditor.js +71 -0
- package/lib/variables/MatcherEditor.js.map +1 -0
- package/lib/variables/index.d.ts +7 -0
- package/lib/variables/index.d.ts.map +1 -0
- package/lib/variables/index.js +20 -0
- package/lib/variables/index.js.map +1 -0
- package/lib/variables/loki-variables.d.ts +13 -0
- package/lib/variables/loki-variables.d.ts.map +1 -0
- package/lib/variables/loki-variables.js +211 -0
- package/lib/variables/loki-variables.js.map +1 -0
- package/lib/variables/types.d.ts +17 -0
- package/lib/variables/types.d.ts.map +1 -0
- package/lib/variables/types.js +15 -0
- package/lib/variables/types.js.map +1 -0
- package/mf-manifest.json +313 -133
- package/mf-stats.json +345 -133
- package/package.json +33 -6
- package/__mf/css/async/3061.d3010b86.css +0 -1
- package/__mf/css/async/5442.d3010b86.css +0 -1
- package/__mf/css/async/7370.d3010b86.css +0 -1
- package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
- package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
- package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
- package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
- package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
- package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
- package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
- package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
- package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
- package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
- package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
- package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
- package/__mf/js/Loki.ca74c810.js +0 -6
- package/__mf/js/async/1616.60c9a082.js +0 -1
- package/__mf/js/async/1728.c6a9c8d6.js +0 -1
- package/__mf/js/async/1750.a7bd1384.js +0 -1
- package/__mf/js/async/1811.a291a38b.js +0 -28
- package/__mf/js/async/1825.5005b3af.js +0 -1
- package/__mf/js/async/1969.53d223ca.js +0 -1
- package/__mf/js/async/2043.eb7e1c61.js +0 -2
- package/__mf/js/async/208.55931f88.js +0 -4
- package/__mf/js/async/208.55931f88.js.LICENSE.txt +0 -15
- package/__mf/js/async/2386.a3cfef97.js +0 -2
- package/__mf/js/async/3059.cb101ca2.js +0 -1
- package/__mf/js/async/3181.d2b90b95.js +0 -2
- package/__mf/js/async/392.2c7c202d.js +0 -2
- package/__mf/js/async/4121.328a1e93.js +0 -2
- package/__mf/js/async/4466.21ddc88c.js +0 -74
- package/__mf/js/async/5002.29685f8e.js +0 -1
- package/__mf/js/async/5071.a03a64fd.js +0 -1
- package/__mf/js/async/54.f8265ee0.js +0 -22
- package/__mf/js/async/5440.995ad0c5.js +0 -2
- package/__mf/js/async/5587.55dbc663.js +0 -1
- package/__mf/js/async/6100.e2898f9c.js +0 -1
- package/__mf/js/async/6274.293b47c4.js +0 -2
- package/__mf/js/async/6283.78af4bc8.js +0 -2
- package/__mf/js/async/6710.a94fd362.js +0 -2
- package/__mf/js/async/7177.b50a1c64.js +0 -1
- package/__mf/js/async/7192.4dea1fd0.js +0 -1
- package/__mf/js/async/7370.0ddd349a.js +0 -2
- package/__mf/js/async/7968.ec040694.js +0 -1
- package/__mf/js/async/7978.38078276.js +0 -1
- package/__mf/js/async/8356.5635696c.js +0 -1
- package/__mf/js/async/8470.c67049a2.js +0 -2
- package/__mf/js/async/8482.07caae1a.js +0 -1
- package/__mf/js/async/873.02aa55af.js +0 -1
- package/__mf/js/async/8988.1c565f12.js +0 -1
- package/__mf/js/async/9071.ed72bdac.js +0 -2
- package/__mf/js/async/9235.f2e0e95c.js +0 -1
- package/__mf/js/async/9249.d90da2ad.js +0 -1
- package/__mf/js/async/9389.29616aa6.js +0 -2
- package/__mf/js/async/941.0bce16fe.js +0 -2
- package/__mf/js/async/9588.2d82f477.js +0 -1
- package/__mf/js/async/9754.5d7b21c2.js +0 -10
- package/__mf/js/async/9811.422fb6ad.js +0 -7
- package/__mf/js/async/9836.de786d07.js +0 -1
- package/__mf/js/async/9877.b76d1711.js +0 -38
- package/__mf/js/async/__federation_expose_LokiDatasource.5e30f7dd.js +0 -2
- package/__mf/js/async/__federation_expose_LokiLogQuery.c30e299e.js +0 -1
- package/__mf/js/async/__federation_expose_LokiTimeSeriesQuery.aa1ffedf.js +0 -1
- package/__mf/js/main.34b789cc.js +0 -6
- /package/__mf/js/async/{2043.eb7e1c61.js.LICENSE.txt → 2043.79caea8b.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2386.a3cfef97.js.LICENSE.txt → 2386.cebea91a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3181.d2b90b95.js.LICENSE.txt → 3181.b238b7b9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.2c7c202d.js.LICENSE.txt → 392.22b48ffa.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.328a1e93.js.LICENSE.txt → 4121.e547e3d4.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7370.0ddd349a.js.LICENSE.txt → 5038.c6e1ac5e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5440.995ad0c5.js.LICENSE.txt → 5440.ff741d36.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.293b47c4.js.LICENSE.txt → 6274.7255b4e9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9071.ed72bdac.js.LICENSE.txt → 6688.ad8a65bc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6283.78af4bc8.js.LICENSE.txt → 7862.679d0bd3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.c67049a2.js.LICENSE.txt → 8470.6f15ddf5.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9389.29616aa6.js.LICENSE.txt → 9389.a063f523.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.0bce16fe.js.LICENSE.txt → 941.49e5f628.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{54.f8265ee0.js.LICENSE.txt → 9916.d88af7d4.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_LokiDatasource.5e30f7dd.js.LICENSE.txt → __federation_expose_LokiDatasource.6b14cd90.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/complete.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Completion, CompletionContext, CompletionResult, insertCompletionText } from '@codemirror/autocomplete';\nimport { syntaxTree } from '@codemirror/language';\nimport { EditorState } from '@codemirror/state';\nimport { SyntaxNode, Tree } from '@lezer/common';\nimport {\n Selector,\n Matchers,\n Matcher,\n Identifier,\n Eq,\n Neq,\n Re,\n Nre,\n String as StringType,\n Pipe,\n} from '@grafana/lezer-logql';\nimport { EditorView } from '@uiw/react-codemirror';\nimport { toUnixSeconds } from '../model';\nimport { CompletionConfig } from './logql-extension';\n\n/** CompletionScope specifies the completion kind, e.g. whether to complete label names or values */\ntype CompletionScope =\n | { kind: 'LabelName' }\n | { kind: 'LabelValue'; label: string }\n | { kind: 'PipeFunction'; afterPipe: boolean; hasSpace: boolean; afterExclamation: boolean };\n\n/**\n * CompletionInfo specifies the identified scope and position of the completion in the current editor text.\n */\nexport interface CompletionInfo {\n scope: CompletionScope;\n from: number;\n to?: number;\n}\n\nconst quoteChars = ['\"', '`'];\nconst defaultQuoteChar = '\"';\nconst ERROR_NODE = 0; // Lezer parser creates error nodes for incomplete/malformed syntax\n\nexport async function complete(\n completionCfg: CompletionConfig,\n { state, pos }: CompletionContext\n): Promise<CompletionResult | null> {\n // First, identify the completion scope\n const completion = identifyCompletion(state, pos, syntaxTree(state));\n if (!completion) {\n // No completion scope found for current cursor position.\n return null;\n }\n\n // Then, retrieve completion options for the identified scope (from the Loki API).\n const options = await retrieveOptions(completionCfg, completion.scope);\n return { options, from: completion.from, to: completion.to };\n}\n\n/**\n * Identify completion scope (e.g. LabelName, LabelValue) and position, based on the current node in the syntax tree.\n *\n * Function is exported for tests only.\n */\nexport function identifyCompletion(state: EditorState, pos: number, tree: Tree): CompletionInfo | undefined {\n const node = tree.resolveInner(pos, -1);\n\n switch (node.type.id) {\n case Selector:\n case Matchers:\n case Matcher:\n case Identifier:\n case Eq:\n case Neq:\n case Re:\n case Nre:\n case StringType: {\n const labelCompletion = detectLabelCompletion(state, pos, node);\n if (labelCompletion) return labelCompletion;\n break;\n }\n\n case ERROR_NODE: {\n // Check for pipe context first\n const pipeCompletion = detectPipeCompletion(state, node);\n if (pipeCompletion) return pipeCompletion;\n\n // Then check for label completion in error nodes\n const labelCompletion = detectLabelCompletion(state, pos, node);\n if (labelCompletion) return labelCompletion;\n break;\n }\n\n case Pipe: {\n // Pipe operator: suggest parser functions and line filters\n // Examples: {job=\"nginx\"} |▯ or {job=\"nginx\"} | ▯\n const hasSpaceAfterPipe = state.sliceDoc(pos - 1, pos) === ' ';\n return {\n scope: { kind: 'PipeFunction', afterPipe: true, hasSpace: hasSpaceAfterPipe, afterExclamation: false },\n from: pos,\n };\n }\n }\n\n // Fallback checks for contexts not directly on a node\n const textBeforeCursor = state.sliceDoc(0, pos).trim();\n const hasSpace = state.sliceDoc(pos - 1, pos).match(/\\s/) !== null;\n\n // Check if cursor is after a pipe operator followed by whitespace\n // This enables autocomplete after: {job=\"nginx\"} | ▯\n if (textBeforeCursor.endsWith('|') && hasSpace) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: true, hasSpace: true, afterExclamation: false },\n from: pos,\n };\n }\n\n // Check if cursor is after a closing brace (stream selector) followed by whitespace\n // This enables autocomplete after: {job=\"nginx\"} ▯\n if (textBeforeCursor.endsWith('}') && hasSpace) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: false, hasSpace: true, afterExclamation: false },\n from: pos,\n };\n }\n}\n\n/**\n * Retrieve completion options based on the identified completion scope.\n */\nasync function retrieveOptions(completionCfg: CompletionConfig, completion: CompletionScope): Promise<Completion[]> {\n switch (completion.kind) {\n case 'LabelName':\n return completeLabelName(completionCfg);\n\n case 'LabelValue':\n return completeLabelValue(completionCfg, completion.label);\n\n case 'PipeFunction':\n return completePipeFunctions(completion.afterPipe, completion.hasSpace, completion.afterExclamation);\n }\n}\n\n/**\n * Detect label name or value completion contexts within selectors.\n */\nfunction detectLabelCompletion(state: EditorState, pos: number, node: SyntaxNode): CompletionInfo | undefined {\n switch (node.type.id) {\n case Selector:\n // Selector is the entire {label matchers} expression\n // Autocomplete at start: {▯ or empty: {}\n // Do not autocomplete if cursor is after closing brace: {job=\"mysql\"}▯\n if (\n (node.firstChild === null || node.firstChild?.type.id === ERROR_NODE) &&\n !state.sliceDoc(node.from, pos).includes('}')\n ) {\n return { scope: { kind: 'LabelName' }, from: pos };\n }\n break;\n\n case Matchers: {\n // Matchers node contains all label matchers inside {}\n // Autocomplete after comma: { job=\"mysql\",▯ or { job=\"mysql\", ▯\n const text = state.sliceDoc(node.from, pos);\n if (text.endsWith(',') || text.endsWith(', ')) {\n return { scope: { kind: 'LabelName' }, from: pos };\n }\n break;\n }\n\n case Matcher:\n // Single matcher like job=\"mysql\"\n // Autocomplete when cursor is after a complete matcher: { job=\"mysql\" ▯\n if (node.parent?.type.id === Matchers) {\n return { scope: { kind: 'LabelName' }, from: pos };\n }\n break;\n\n case Identifier:\n // Identifier is a label name being typed\n // Autocomplete partial label names: { jo▯ or { job=\"mysql\", na▯\n if (node.parent?.type.id === Matcher) {\n return { scope: { kind: 'LabelName' }, from: node.from };\n }\n break;\n\n case Eq:\n case Neq:\n case Re:\n case Nre:\n // Operators for label matching: =, !=, =~, !~\n // Autocomplete label values right after operator: { job=▯ or { job!=▯\n if (node.parent?.type.id === Matcher) {\n const labelNode = node.parent.firstChild;\n if (labelNode?.type.id === Identifier) {\n const label = state.sliceDoc(labelNode.from, labelNode.to);\n return { scope: { kind: 'LabelValue', label }, from: pos };\n }\n }\n break;\n\n case StringType:\n // String value in a matcher: { job=\"▯\n // Do not autocomplete if cursor is after closing quotes: { job=\"\"▯\n if (node.parent?.type.id === Matcher && !/^\".*\"$/.test(state.sliceDoc(node.from, pos))) {\n const labelNode = node.parent.firstChild;\n if (labelNode?.type.id === Identifier) {\n const label = state.sliceDoc(labelNode.from, labelNode.to);\n return { scope: { kind: 'LabelValue', label }, from: node.from + 1 }; // +1 to skip opening quote\n }\n }\n break;\n\n case ERROR_NODE:\n // Error nodes represent incomplete or malformed syntax\n // Autocomplete incomplete value after operator: { job=mys▯ or { job=\"mys▯\n if (\n (node.prevSibling?.type.id === Eq ||\n node.prevSibling?.type.id === Neq ||\n node.prevSibling?.type.id === Re ||\n node.prevSibling?.type.id === Nre) &&\n node.parent?.type.id === Matcher\n ) {\n const labelNode = node.parent.firstChild;\n if (labelNode?.type.id === Identifier) {\n const label = state.sliceDoc(labelNode.from, labelNode.to);\n // Skip leading quote if present: { name=\"HT▯\n const from = quoteChars.includes(state.sliceDoc(node.from, node.from + 1)) ? node.from + 1 : node.from;\n return { scope: { kind: 'LabelValue', label }, from };\n }\n }\n\n // Autocomplete partial label name: { j▯ or { job=\"mysql\", n▯\n if (node.parent?.type.id === Selector || node.parent?.type.id === Matchers) {\n return { scope: { kind: 'LabelName' }, from: node.from };\n }\n break;\n }\n\n return undefined;\n}\n\n/**\n * Detect pipe function completion contexts (line filters, parsers, formatters).\n */\nfunction detectPipeCompletion(state: EditorState, node: SyntaxNode): CompletionInfo | undefined {\n // Check if we're in an error node right after a pipe operator\n // This handles cases like: {job=\"nginx\"} | !▯\n if (node.prevSibling?.type.id === Pipe) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: true, hasSpace: true, afterExclamation: false },\n from: node.from,\n };\n }\n\n // Check if we're after selector with space and text starts with !\n // This handles cases like: {job=\"nginx\"} !▯\n const errorText = state.sliceDoc(node.from, node.to);\n if (errorText.startsWith('!')) {\n const textBeforeError = state.sliceDoc(0, node.from).trim();\n if (textBeforeError.endsWith('}')) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: false, hasSpace: true, afterExclamation: true },\n from: node.from,\n };\n }\n }\n\n return undefined;\n}\n\n/**\n * Complete LogQL pipe functions, line filters, and parser functions.\n * Context-aware suggestions based on LogQL syntax:\n * - After \"{} \": Show all line filters (|=, !=, |~, !~) + parsers (with | prefix)\n * - After \"{} !\": Show ONLY != and !~\n * - After \"{} |\": Show only pipe-based filters WITHOUT the | (=, ~) + parsers\n * - After \"{} | \": Show ONLY parsers, NO line filters\n */\nfunction completePipeFunctions(afterPipe: boolean, hasSpace: boolean, afterExclamation: boolean): Completion[] {\n const completions: Completion[] = [];\n\n // Line filter operators that START with pipe: |= and |~\n const pipeLineFilters = [\n { operator: '|=', detail: 'Line contains' },\n { operator: '|~', detail: 'Line matches regex' },\n ];\n\n // Line filter operators that DON'T start with pipe: != and !~\n const nonPipeLineFilters = [\n { operator: '!=', detail: 'Line does not contain' },\n { operator: '!~', detail: 'Line does not match regex' },\n ];\n\n // Context: After \"{} !\" - Show ONLY != and !~\n if (afterExclamation) {\n nonPipeLineFilters.forEach(({ operator, detail }) => {\n completions.push(createLineFilterCompletion(operator, detail));\n });\n return completions; // Don't show parsers after !\n }\n\n // Context 1: After \"{} | \" (pipe + space) - ONLY parsers, NO line filters\n if (afterPipe && hasSpace) {\n // Don't show any line filters\n }\n // Context 2: After \"{} |\" (pipe, no space) - Show = and ~ (without pipe prefix)\n else if (afterPipe && !hasSpace) {\n pipeLineFilters.forEach(({ operator, detail }) => {\n // Strip the | since user already typed it\n const strippedOp = operator.replace('|', '');\n completions.push(createLineFilterCompletion(strippedOp, detail));\n });\n }\n // Context 3: After \"{} \" (no pipe) - Show ALL line filters with full syntax\n else {\n [...pipeLineFilters, ...nonPipeLineFilters].forEach(({ operator, detail }) => {\n completions.push(createLineFilterCompletion(operator, detail));\n });\n }\n\n // Parser functions and pipe operations: always show\n // Add pipe prefix when not after pipe (e.g., \"{} \" needs \"| json\" not \" json\")\n const parserPrefix = !afterPipe ? '| ' : hasSpace ? '' : ' ';\n\n // Parsing expressions: Extract structured data\n const parsingExpressions = ['json', 'logfmt', 'pattern', 'regexp', 'unpack', 'unwrap'];\n parsingExpressions.forEach((parser) => {\n completions.push({\n label: `${parserPrefix}${parser}`,\n type: 'function',\n boost: 5,\n });\n });\n\n // Formatting and labels expressions: Format output and manipulate labels\n const formattingAndLabels = ['line_format', 'label_format', 'decolorize', 'drop', 'keep'];\n formattingAndLabels.forEach((expr) => {\n completions.push({\n label: `${parserPrefix}${expr}`,\n type: 'method',\n });\n });\n\n return completions;\n}\n\nasync function completeLabelName(completionCfg: CompletionConfig): Promise<Completion[]> {\n if (!completionCfg.client) {\n return [];\n }\n\n const start = completionCfg.timeRange?.start\n ? toUnixSeconds(new Date(completionCfg.timeRange.start).getTime())\n : undefined;\n const end = completionCfg.timeRange?.end ? toUnixSeconds(new Date(completionCfg.timeRange.end).getTime()) : undefined;\n\n try {\n const response = await completionCfg.client.labels(start, end);\n if (response.status === 'success') {\n return response.data.map((label: string) => ({ label }));\n }\n return [];\n } catch (error) {\n console.error('Error fetching label names:', error);\n return [];\n }\n}\n\nasync function completeLabelValue(completionCfg: CompletionConfig, label: string): Promise<Completion[]> {\n if (!completionCfg.client) {\n return [];\n }\n\n const start = completionCfg.timeRange?.start\n ? toUnixSeconds(new Date(completionCfg.timeRange.start).getTime())\n : undefined;\n const end = completionCfg.timeRange?.end ? toUnixSeconds(new Date(completionCfg.timeRange.end).getTime()) : undefined;\n\n try {\n const response = await completionCfg.client.labelValues(label, start, end);\n if (response.status === 'success') {\n return response.data.map((value: string) => ({\n label: value ?? '',\n displayLabel: value ?? '(empty string)',\n apply: applyQuotedCompletion,\n }));\n }\n return [];\n } catch (error) {\n console.error(`Error fetching values for label ${label}:`, error);\n return [];\n }\n}\n\n/**\n * Create a line filter completion with consistent cursor positioning.\n */\nfunction createLineFilterCompletion(operator: string, detail: string): Completion {\n return {\n label: `${operator} \"\"`,\n detail,\n apply: (view, _completion, from, to): void => {\n const insert = `${operator} \"\"`;\n view.dispatch({\n changes: { from, to, insert },\n selection: { anchor: from + insert.length - 1 },\n });\n },\n type: 'text',\n boost: 10,\n };\n}\n\nfunction escapeString(input: string, quoteChar: string): string {\n // do not escape raw strings (when using backticks)\n if (quoteChar === '`') {\n return input;\n }\n\n let escaped = input;\n // escape backslashes and quotes\n escaped = escaped.replaceAll('\\\\', '\\\\\\\\');\n escaped = escaped.replaceAll('\"', '\\\\\"');\n return escaped;\n}\n\n/**\n * Add quotes to the completion text in case quotes are not present already.\n * This handles the following cases:\n * { name=HTTP\n * { name=\"x\n * { name=\"x\" where cursor is after the 'x'\n */\nexport function applyQuotedCompletion(view: EditorView, completion: Completion, from: number, to: number): void {\n let quoteChar = defaultQuoteChar;\n if (quoteChars.includes(view.state.sliceDoc(from - 1, from))) {\n quoteChar = view.state.sliceDoc(from - 1, from);\n from--;\n }\n if (quoteChars.includes(view.state.sliceDoc(to, to + 1))) {\n quoteChar = view.state.sliceDoc(to, to + 1);\n to++;\n }\n\n // When using raw strings (`), we cannot escape a backtick.\n // Therefore, switch the quote character.\n if (completion.label.includes('`')) {\n quoteChar = '\"';\n }\n\n const insertText = `${quoteChar}${escapeString(completion.label, quoteChar)}${quoteChar}`;\n view.dispatch(insertCompletionText(view.state, insertText, from, to));\n}\n"],"names":["insertCompletionText","syntaxTree","Selector","Matchers","Matcher","Identifier","Eq","Neq","Re","Nre","String","StringType","Pipe","toUnixSeconds","quoteChars","defaultQuoteChar","ERROR_NODE","complete","completionCfg","state","pos","completion","identifyCompletion","options","retrieveOptions","scope","from","to","tree","node","resolveInner","type","id","labelCompletion","detectLabelCompletion","pipeCompletion","detectPipeCompletion","hasSpaceAfterPipe","sliceDoc","kind","afterPipe","hasSpace","afterExclamation","textBeforeCursor","trim","match","endsWith","completeLabelName","completeLabelValue","label","completePipeFunctions","firstChild","includes","text","parent","labelNode","test","prevSibling","undefined","errorText","startsWith","textBeforeError","completions","pipeLineFilters","operator","detail","nonPipeLineFilters","forEach","push","createLineFilterCompletion","strippedOp","replace","parserPrefix","parsingExpressions","parser","boost","formattingAndLabels","expr","client","start","timeRange","Date","getTime","end","response","labels","status","data","map","error","console","labelValues","value","displayLabel","apply","applyQuotedCompletion","view","_completion","insert","dispatch","changes","selection","anchor","length","escapeString","input","quoteChar","escaped","replaceAll","insertText"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA0DA,oBAAoB,QAAQ,2BAA2B;AACjH,SAASC,UAAU,QAAQ,uBAAuB;AAGlD,SACEC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,EAAE,EACFC,GAAG,EACHC,EAAE,EACFC,GAAG,EACHC,UAAUC,UAAU,EACpBC,IAAI,QACC,uBAAuB;AAE9B,SAASC,aAAa,QAAQ,WAAW;AAkBzC,MAAMC,aAAa;IAAC;IAAK;CAAI;AAC7B,MAAMC,mBAAmB;AACzB,MAAMC,aAAa,GAAG,mEAAmE;AAEzF,OAAO,eAAeC,SACpBC,aAA+B,EAC/B,EAAEC,KAAK,EAAEC,GAAG,EAAqB;IAEjC,uCAAuC;IACvC,MAAMC,aAAaC,mBAAmBH,OAAOC,KAAKnB,WAAWkB;IAC7D,IAAI,CAACE,YAAY;QACf,yDAAyD;QACzD,OAAO;IACT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"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Completion, CompletionContext, CompletionResult, insertCompletionText } from '@codemirror/autocomplete';\nimport { syntaxTree } from '@codemirror/language';\nimport { EditorState } from '@codemirror/state';\nimport { SyntaxNode, Tree } from '@lezer/common';\nimport {\n Selector,\n Matchers,\n Matcher,\n Identifier,\n Eq,\n Neq,\n Re,\n Nre,\n String as StringType,\n Pipe,\n} from '@grafana/lezer-logql';\nimport { EditorView } from '@uiw/react-codemirror';\nimport { toUnixSeconds } from '../model';\nimport { CompletionConfig } from './logql-extension';\n\n/** CompletionScope specifies the completion kind, e.g. whether to complete label names or values */\ntype CompletionScope =\n | { kind: 'LabelName' }\n | { kind: 'LabelValue'; label: string }\n | { kind: 'PipeFunction'; afterPipe: boolean; hasSpace: boolean; afterExclamation: boolean };\n\n/**\n * CompletionInfo specifies the identified scope and position of the completion in the current editor text.\n */\nexport interface CompletionInfo {\n scope: CompletionScope;\n from: number;\n to?: number;\n}\n\nconst quoteChars = ['\"', '`'];\nconst defaultQuoteChar = '\"';\nconst ERROR_NODE = 0; // Lezer parser creates error nodes for incomplete/malformed syntax\n\nexport async function complete(\n completionCfg: CompletionConfig,\n { state, pos }: CompletionContext\n): Promise<CompletionResult | null> {\n // First, identify the completion scope\n const completion = identifyCompletion(state, pos, syntaxTree(state));\n if (!completion) {\n // No completion scope found for current cursor position.\n return null;\n }\n\n // Then, retrieve completion options for the identified scope (from the Loki API).\n const options = await retrieveOptions(completionCfg, completion.scope);\n return { options, from: completion.from, to: completion.to };\n}\n\n/**\n * Identify completion scope (e.g. LabelName, LabelValue) and position, based on the current node in the syntax tree.\n *\n * Function is exported for tests only.\n */\nexport function identifyCompletion(state: EditorState, pos: number, tree: Tree): CompletionInfo | undefined {\n const node = tree.resolveInner(pos, -1);\n\n switch (node.type.id) {\n case Selector:\n case Matchers:\n case Matcher:\n case Identifier:\n case Eq:\n case Neq:\n case Re:\n case Nre:\n case StringType: {\n const labelCompletion = detectLabelCompletion(state, pos, node);\n if (labelCompletion) return labelCompletion;\n break;\n }\n\n case ERROR_NODE: {\n // Check for pipe context first\n const pipeCompletion = detectPipeCompletion(state, node);\n if (pipeCompletion) return pipeCompletion;\n\n // Then check for label completion in error nodes\n const labelCompletion = detectLabelCompletion(state, pos, node);\n if (labelCompletion) return labelCompletion;\n break;\n }\n\n case Pipe: {\n // Pipe operator: suggest parser functions and line filters\n // Examples: {job=\"nginx\"} |▯ or {job=\"nginx\"} | ▯\n const hasSpaceAfterPipe = state.sliceDoc(pos - 1, pos) === ' ';\n return {\n scope: { kind: 'PipeFunction', afterPipe: true, hasSpace: hasSpaceAfterPipe, afterExclamation: false },\n from: pos,\n };\n }\n }\n\n // Fallback checks for contexts not directly on a node\n const textBeforeCursor = state.sliceDoc(0, pos).trim();\n const hasSpace = state.sliceDoc(pos - 1, pos).match(/\\s/) !== null;\n\n // Check if cursor is after a pipe operator followed by whitespace\n // This enables autocomplete after: {job=\"nginx\"} | ▯\n if (textBeforeCursor.endsWith('|') && hasSpace) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: true, hasSpace: true, afterExclamation: false },\n from: pos,\n };\n }\n\n // Check if cursor is after a closing brace (stream selector) followed by whitespace\n // This enables autocomplete after: {job=\"nginx\"} ▯\n if (textBeforeCursor.endsWith('}') && hasSpace) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: false, hasSpace: true, afterExclamation: false },\n from: pos,\n };\n }\n}\n\n/**\n * Retrieve completion options based on the identified completion scope.\n */\nasync function retrieveOptions(completionCfg: CompletionConfig, completion: CompletionScope): Promise<Completion[]> {\n switch (completion.kind) {\n case 'LabelName':\n return completeLabelName(completionCfg);\n\n case 'LabelValue':\n return completeLabelValue(completionCfg, completion.label);\n\n case 'PipeFunction':\n return completePipeFunctions(completion.afterPipe, completion.hasSpace, completion.afterExclamation);\n }\n}\n\n/**\n * Detect label name or value completion contexts within selectors.\n */\nfunction detectLabelCompletion(state: EditorState, pos: number, node: SyntaxNode): CompletionInfo | undefined {\n switch (node.type.id) {\n case Selector:\n // Selector is the entire {label matchers} expression\n // Autocomplete at start: {▯ or empty: {}\n // Do not autocomplete if cursor is after closing brace: {job=\"mysql\"}▯\n if (\n (node.firstChild === null || node.firstChild?.type.id === ERROR_NODE) &&\n !state.sliceDoc(node.from, pos).includes('}')\n ) {\n return { scope: { kind: 'LabelName' }, from: pos };\n }\n break;\n\n case Matchers: {\n // Matchers node contains all label matchers inside {}\n // Autocomplete after comma: { job=\"mysql\",▯ or { job=\"mysql\", ▯\n const text = state.sliceDoc(node.from, pos);\n if (text.endsWith(',') || text.endsWith(', ')) {\n return { scope: { kind: 'LabelName' }, from: pos };\n }\n break;\n }\n\n case Matcher:\n // Single matcher like job=\"mysql\"\n // Autocomplete when cursor is after a complete matcher: { job=\"mysql\" ▯\n if (node.parent?.type.id === Matchers) {\n return { scope: { kind: 'LabelName' }, from: pos };\n }\n break;\n\n case Identifier:\n // Identifier is a label name being typed\n // Autocomplete partial label names: { jo▯ or { job=\"mysql\", na▯\n if (node.parent?.type.id === Matcher) {\n return { scope: { kind: 'LabelName' }, from: node.from };\n }\n break;\n\n case Eq:\n case Neq:\n case Re:\n case Nre:\n // Operators for label matching: =, !=, =~, !~\n // Autocomplete label values right after operator: { job=▯ or { job!=▯\n if (node.parent?.type.id === Matcher) {\n const labelNode = node.parent.firstChild;\n if (labelNode?.type.id === Identifier) {\n const label = state.sliceDoc(labelNode.from, labelNode.to);\n return { scope: { kind: 'LabelValue', label }, from: pos };\n }\n }\n break;\n\n case StringType:\n // String value in a matcher: { job=\"▯\n // Do not autocomplete if cursor is after closing quotes: { job=\"\"▯\n if (node.parent?.type.id === Matcher && !/^\".*\"$/.test(state.sliceDoc(node.from, pos))) {\n const labelNode = node.parent.firstChild;\n if (labelNode?.type.id === Identifier) {\n const label = state.sliceDoc(labelNode.from, labelNode.to);\n return { scope: { kind: 'LabelValue', label }, from: node.from + 1 }; // +1 to skip opening quote\n }\n }\n break;\n\n case ERROR_NODE:\n // Error nodes represent incomplete or malformed syntax\n // Autocomplete incomplete value after operator: { job=mys▯ or { job=\"mys▯\n if (\n (node.prevSibling?.type.id === Eq ||\n node.prevSibling?.type.id === Neq ||\n node.prevSibling?.type.id === Re ||\n node.prevSibling?.type.id === Nre) &&\n node.parent?.type.id === Matcher\n ) {\n const labelNode = node.parent.firstChild;\n if (labelNode?.type.id === Identifier) {\n const label = state.sliceDoc(labelNode.from, labelNode.to);\n // Skip leading quote if present: { name=\"HT▯\n const from = quoteChars.includes(state.sliceDoc(node.from, node.from + 1)) ? node.from + 1 : node.from;\n return { scope: { kind: 'LabelValue', label }, from };\n }\n }\n\n // Autocomplete partial label name: { j▯ or { job=\"mysql\", n▯\n if (node.parent?.type.id === Selector || node.parent?.type.id === Matchers) {\n return { scope: { kind: 'LabelName' }, from: node.from };\n }\n break;\n }\n\n return undefined;\n}\n\n/**\n * Detect pipe function completion contexts (line filters, parsers, formatters).\n */\nfunction detectPipeCompletion(state: EditorState, node: SyntaxNode): CompletionInfo | undefined {\n // Check if we're in an error node right after a pipe operator\n // This handles cases like: {job=\"nginx\"} | !▯\n if (node.prevSibling?.type.id === Pipe) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: true, hasSpace: true, afterExclamation: false },\n from: node.from,\n };\n }\n\n // Check if we're after selector with space and text starts with !\n // This handles cases like: {job=\"nginx\"} !▯\n const errorText = state.sliceDoc(node.from, node.to);\n if (errorText.startsWith('!')) {\n const textBeforeError = state.sliceDoc(0, node.from).trim();\n if (textBeforeError.endsWith('}')) {\n return {\n scope: { kind: 'PipeFunction', afterPipe: false, hasSpace: true, afterExclamation: true },\n from: node.from,\n };\n }\n }\n\n return undefined;\n}\n\n/**\n * Complete LogQL pipe functions, line filters, and parser functions.\n * Context-aware suggestions based on LogQL syntax:\n * - After \"{} \": Show all line filters (|=, !=, |~, !~) + parsers (with | prefix)\n * - After \"{} !\": Show ONLY != and !~\n * - After \"{} |\": Show only pipe-based filters WITHOUT the | (=, ~) + parsers\n * - After \"{} | \": Show ONLY parsers, NO line filters\n */\nfunction completePipeFunctions(afterPipe: boolean, hasSpace: boolean, afterExclamation: boolean): Completion[] {\n const completions: Completion[] = [];\n\n // Line filter operators that START with pipe: |= and |~\n const pipeLineFilters = [\n { operator: '|=', detail: 'Line contains' },\n { operator: '|~', detail: 'Line matches regex' },\n ];\n\n // Line filter operators that DON'T start with pipe: != and !~\n const nonPipeLineFilters = [\n { operator: '!=', detail: 'Line does not contain' },\n { operator: '!~', detail: 'Line does not match regex' },\n ];\n\n // Context: After \"{} !\" - Show ONLY != and !~\n if (afterExclamation) {\n nonPipeLineFilters.forEach(({ operator, detail }) => {\n completions.push(createLineFilterCompletion(operator, detail));\n });\n return completions; // Don't show parsers after !\n }\n\n // Context 1: After \"{} | \" (pipe + space) - ONLY parsers, NO line filters\n if (afterPipe && hasSpace) {\n // Don't show any line filters\n }\n // Context 2: After \"{} |\" (pipe, no space) - Show = and ~ (without pipe prefix)\n else if (afterPipe && !hasSpace) {\n pipeLineFilters.forEach(({ operator, detail }) => {\n // Strip the | since user already typed it\n const strippedOp = operator.replace('|', '');\n completions.push(createLineFilterCompletion(strippedOp, detail));\n });\n }\n // Context 3: After \"{} \" (no pipe) - Show ALL line filters with full syntax\n else {\n [...pipeLineFilters, ...nonPipeLineFilters].forEach(({ operator, detail }) => {\n completions.push(createLineFilterCompletion(operator, detail));\n });\n }\n\n // Parser functions and pipe operations: always show\n // Add pipe prefix when not after pipe (e.g., \"{} \" needs \"| json\" not \" json\")\n const parserPrefix = !afterPipe ? '| ' : hasSpace ? '' : ' ';\n\n // Parsing expressions: Extract structured data\n const parsingExpressions = ['json', 'logfmt', 'pattern', 'regexp', 'unpack', 'unwrap'];\n parsingExpressions.forEach((parser) => {\n completions.push({\n label: `${parserPrefix}${parser}`,\n type: 'function',\n boost: 5,\n });\n });\n\n // Formatting and labels expressions: Format output and manipulate labels\n const formattingAndLabels = ['line_format', 'label_format', 'decolorize', 'drop', 'keep'];\n formattingAndLabels.forEach((expr) => {\n completions.push({\n label: `${parserPrefix}${expr}`,\n type: 'method',\n });\n });\n\n return completions;\n}\n\nasync function completeLabelName(completionCfg: CompletionConfig): Promise<Completion[]> {\n if (!completionCfg.client) {\n return [];\n }\n\n const start = completionCfg.timeRange?.start\n ? toUnixSeconds(new Date(completionCfg.timeRange.start).getTime())\n : undefined;\n const end = completionCfg.timeRange?.end ? toUnixSeconds(new Date(completionCfg.timeRange.end).getTime()) : undefined;\n\n try {\n const response = await completionCfg.client.labels({ start, end });\n if (response.status === 'success' && response.data) {\n return response.data.map((label: string) => ({ label }));\n }\n return [];\n } catch (error) {\n console.error('Error fetching label names:', error);\n return [];\n }\n}\n\nasync function completeLabelValue(completionCfg: CompletionConfig, label: string): Promise<Completion[]> {\n if (!completionCfg.client) {\n return [];\n }\n\n const start = completionCfg.timeRange?.start\n ? toUnixSeconds(new Date(completionCfg.timeRange.start).getTime())\n : undefined;\n const end = completionCfg.timeRange?.end ? toUnixSeconds(new Date(completionCfg.timeRange.end).getTime()) : undefined;\n\n try {\n const response = await completionCfg.client.labelValues({ labelName: label, start, end });\n if (response.status === 'success' && response.data) {\n return response.data.map((value: string) => ({\n label: value ?? '',\n displayLabel: value ?? '(empty string)',\n apply: applyQuotedCompletion,\n }));\n }\n return [];\n } catch (error) {\n console.error(`Error fetching values for label ${label}:`, error);\n return [];\n }\n}\n\n/**\n * Create a line filter completion with consistent cursor positioning.\n */\nfunction createLineFilterCompletion(operator: string, detail: string): Completion {\n return {\n label: `${operator} \"\"`,\n detail,\n apply: (view, _completion, from, to): void => {\n const insert = `${operator} \"\"`;\n view.dispatch({\n changes: { from, to, insert },\n selection: { anchor: from + insert.length - 1 },\n });\n },\n type: 'text',\n boost: 10,\n };\n}\n\nfunction escapeString(input: string, quoteChar: string): string {\n // do not escape raw strings (when using backticks)\n if (quoteChar === '`') {\n return input;\n }\n\n let escaped = input;\n // escape backslashes and quotes\n escaped = escaped.replaceAll('\\\\', '\\\\\\\\');\n escaped = escaped.replaceAll('\"', '\\\\\"');\n return escaped;\n}\n\n/**\n * Add quotes to the completion text in case quotes are not present already.\n * This handles the following cases:\n * { name=HTTP\n * { name=\"x\n * { name=\"x\" where cursor is after the 'x'\n */\nexport function applyQuotedCompletion(view: EditorView, completion: Completion, from: number, to: number): void {\n let quoteChar = defaultQuoteChar;\n if (quoteChars.includes(view.state.sliceDoc(from - 1, from))) {\n quoteChar = view.state.sliceDoc(from - 1, from);\n from--;\n }\n if (quoteChars.includes(view.state.sliceDoc(to, to + 1))) {\n quoteChar = view.state.sliceDoc(to, to + 1);\n to++;\n }\n\n // When using raw strings (`), we cannot escape a backtick.\n // Therefore, switch the quote character.\n if (completion.label.includes('`')) {\n quoteChar = '\"';\n }\n\n const insertText = `${quoteChar}${escapeString(completion.label, quoteChar)}${quoteChar}`;\n view.dispatch(insertCompletionText(view.state, insertText, from, to));\n}\n"],"names":["insertCompletionText","syntaxTree","Selector","Matchers","Matcher","Identifier","Eq","Neq","Re","Nre","String","StringType","Pipe","toUnixSeconds","quoteChars","defaultQuoteChar","ERROR_NODE","complete","completionCfg","state","pos","completion","identifyCompletion","options","retrieveOptions","scope","from","to","tree","node","resolveInner","type","id","labelCompletion","detectLabelCompletion","pipeCompletion","detectPipeCompletion","hasSpaceAfterPipe","sliceDoc","kind","afterPipe","hasSpace","afterExclamation","textBeforeCursor","trim","match","endsWith","completeLabelName","completeLabelValue","label","completePipeFunctions","firstChild","includes","text","parent","labelNode","test","prevSibling","undefined","errorText","startsWith","textBeforeError","completions","pipeLineFilters","operator","detail","nonPipeLineFilters","forEach","push","createLineFilterCompletion","strippedOp","replace","parserPrefix","parsingExpressions","parser","boost","formattingAndLabels","expr","client","start","timeRange","Date","getTime","end","response","labels","status","data","map","error","console","labelValues","labelName","value","displayLabel","apply","applyQuotedCompletion","view","_completion","insert","dispatch","changes","selection","anchor","length","escapeString","input","quoteChar","escaped","replaceAll","insertText"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA0DA,oBAAoB,QAAQ,2BAA2B;AACjH,SAASC,UAAU,QAAQ,uBAAuB;AAGlD,SACEC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,EAAE,EACFC,GAAG,EACHC,EAAE,EACFC,GAAG,EACHC,UAAUC,UAAU,EACpBC,IAAI,QACC,uBAAuB;AAE9B,SAASC,aAAa,QAAQ,WAAW;AAkBzC,MAAMC,aAAa;IAAC;IAAK;CAAI;AAC7B,MAAMC,mBAAmB;AACzB,MAAMC,aAAa,GAAG,mEAAmE;AAEzF,OAAO,eAAeC,SACpBC,aAA+B,EAC/B,EAAEC,KAAK,EAAEC,GAAG,EAAqB;IAEjC,uCAAuC;IACvC,MAAMC,aAAaC,mBAAmBH,OAAOC,KAAKnB,WAAWkB;IAC7D,IAAI,CAACE,YAAY;QACf,yDAAyD;QACzD,OAAO;IACT;IAEA,kFAAkF;IAClF,MAAME,UAAU,MAAMC,gBAAgBN,eAAeG,WAAWI,KAAK;IACrE,OAAO;QAAEF;QAASG,MAAML,WAAWK,IAAI;QAAEC,IAAIN,WAAWM,EAAE;IAAC;AAC7D;AAEA;;;;CAIC,GACD,OAAO,SAASL,mBAAmBH,KAAkB,EAAEC,GAAW,EAAEQ,IAAU;IAC5E,MAAMC,OAAOD,KAAKE,YAAY,CAACV,KAAK,CAAC;IAErC,OAAQS,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;IACT;AACF;AAEA,SAAS8B,aAAaC,KAAa,EAAEC,SAAiB;IACpD,mDAAmD;IACnD,IAAIA,cAAc,KAAK;QACrB,OAAOD;IACT;IAEA,IAAIE,UAAUF;IACd,gCAAgC;IAChCE,UAAUA,QAAQC,UAAU,CAAC,MAAM;IACnCD,UAAUA,QAAQC,UAAU,CAAC,KAAK;IAClC,OAAOD;AACT;AAEA;;;;;;CAMC,GACD,OAAO,SAASZ,sBAAsBC,IAAgB,EAAE5E,UAAsB,EAAEK,IAAY,EAAEC,EAAU;IACtG,IAAIgF,YAAY5F;IAChB,IAAID,WAAWsC,QAAQ,CAAC6C,KAAK9E,KAAK,CAACmB,QAAQ,CAACZ,OAAO,GAAGA,QAAQ;QAC5DiF,YAAYV,KAAK9E,KAAK,CAACmB,QAAQ,CAACZ,OAAO,GAAGA;QAC1CA;IACF;IACA,IAAIZ,WAAWsC,QAAQ,CAAC6C,KAAK9E,KAAK,CAACmB,QAAQ,CAACX,IAAIA,KAAK,KAAK;QACxDgF,YAAYV,KAAK9E,KAAK,CAACmB,QAAQ,CAACX,IAAIA,KAAK;QACzCA;IACF;IAEA,2DAA2D;IAC3D,yCAAyC;IACzC,IAAIN,WAAW4B,KAAK,CAACG,QAAQ,CAAC,MAAM;QAClCuD,YAAY;IACd;IAEA,MAAMG,aAAa,GAAGH,YAAYF,aAAapF,WAAW4B,KAAK,EAAE0D,aAAaA,WAAW;IACzFV,KAAKG,QAAQ,CAACpG,qBAAqBiG,KAAK9E,KAAK,EAAE2F,YAAYpF,MAAMC;AACnE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LRLanguage } from '@codemirror/language';
|
|
2
2
|
import { Extension } from '@uiw/react-codemirror';
|
|
3
|
-
import { AbsoluteTimeRange } from '@perses-dev/
|
|
3
|
+
import { AbsoluteTimeRange } from '@perses-dev/spec';
|
|
4
4
|
import { LokiClient } from '../model';
|
|
5
5
|
export interface CompletionConfig {
|
|
6
6
|
/** a LokiClient instance, can be created with LokiDatasource.createClient() */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/logql-extension.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { LRLanguage } from '@codemirror/language';\nimport { parser } from '@grafana/lezer-logql';\nimport { CompletionContext } from '@codemirror/autocomplete';\nimport { Extension } from '@uiw/react-codemirror';\nimport { AbsoluteTimeRange } from '@perses-dev/
|
|
1
|
+
{"version":3,"sources":["../../../src/components/logql-extension.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { LRLanguage } from '@codemirror/language';\nimport { parser } from '@grafana/lezer-logql';\nimport { CompletionContext } from '@codemirror/autocomplete';\nimport { Extension } from '@uiw/react-codemirror';\nimport { AbsoluteTimeRange } from '@perses-dev/spec';\nimport { LokiClient } from '../model';\nimport { logqlHighlight } from './logql-highlight';\nimport { complete } from './complete';\n\nfunction logqlLanguage(): LRLanguage {\n return LRLanguage.define({\n parser: parser.configure({\n props: [logqlHighlight],\n }),\n languageData: {\n closeBrackets: { brackets: ['(', '[', '{', \"'\", '\"', '`'] },\n commentTokens: { line: '#' },\n },\n });\n}\n\nexport interface CompletionConfig {\n /** a LokiClient instance, can be created with LokiDatasource.createClient() */\n client?: LokiClient;\n\n /** search for label values in a given time range */\n timeRange?: AbsoluteTimeRange;\n}\n\nexport function LogQLExtension(completionCfg?: CompletionConfig): Array<LRLanguage | Extension> {\n const language = logqlLanguage();\n\n // Only add autocomplete if config is provided\n if (completionCfg) {\n const completion = language.data.of({\n autocomplete: (ctx: CompletionContext) =>\n complete(completionCfg, ctx).catch((e) => {\n console.error('error during LogQL auto-complete', e);\n return null;\n }),\n });\n return [language, completion];\n }\n\n return [language];\n}\n"],"names":["LRLanguage","parser","logqlHighlight","complete","logqlLanguage","define","configure","props","languageData","closeBrackets","brackets","commentTokens","line","LogQLExtension","completionCfg","language","completion","data","of","autocomplete","ctx","catch","e","console","error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,MAAM,QAAQ,uBAAuB;AAK9C,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,QAAQ,QAAQ,aAAa;AAEtC,SAASC;IACP,OAAOJ,WAAWK,MAAM,CAAC;QACvBJ,QAAQA,OAAOK,SAAS,CAAC;YACvBC,OAAO;gBAACL;aAAe;QACzB;QACAM,cAAc;YACZC,eAAe;gBAAEC,UAAU;oBAAC;oBAAK;oBAAK;oBAAK;oBAAK;oBAAK;iBAAI;YAAC;YAC1DC,eAAe;gBAAEC,MAAM;YAAI;QAC7B;IACF;AACF;AAUA,OAAO,SAASC,eAAeC,aAAgC;IAC7D,MAAMC,WAAWX;IAEjB,8CAA8C;IAC9C,IAAIU,eAAe;QACjB,MAAME,aAAaD,SAASE,IAAI,CAACC,EAAE,CAAC;YAClCC,cAAc,CAACC,MACbjB,SAASW,eAAeM,KAAKC,KAAK,CAAC,CAACC;oBAClCC,QAAQC,KAAK,CAAC,oCAAoCF;oBAClD,OAAO;gBACT;QACJ;QACA,OAAO;YAACP;YAAUC;SAAW;IAC/B;IAEA,OAAO;QAACD;KAAS;AACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LokiDatasource.d.ts","sourceRoot":"","sources":["../../../../src/datasources/loki-datasource/LokiDatasource.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,UAAU,EASX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"LokiDatasource.d.ts","sourceRoot":"","sources":["../../../../src/datasources/loki-datasource/LokiDatasource.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,UAAU,EASX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA+B7D,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,CAI3E,CAAC"}
|
|
@@ -32,11 +32,11 @@ const createClient = (spec, options)=>{
|
|
|
32
32
|
datasourceUrl,
|
|
33
33
|
headers: headers ?? specHeaders
|
|
34
34
|
}),
|
|
35
|
-
labels: (
|
|
35
|
+
labels: (params, headers)=>labels(params, {
|
|
36
36
|
datasourceUrl,
|
|
37
37
|
headers: headers ?? specHeaders
|
|
38
38
|
}),
|
|
39
|
-
labelValues: (
|
|
39
|
+
labelValues: (params, headers)=>labelValues(params, {
|
|
40
40
|
datasourceUrl,
|
|
41
41
|
headers: headers ?? specHeaders
|
|
42
42
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/datasources/loki-datasource/LokiDatasource.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n LokiClient,\n query,\n queryRange,\n labels,\n labelValues,\n series,\n volume,\n volumeRange,\n indexStats,\n} from '../../model/loki-client';\nimport { LokiDatasourceSpec } from './loki-datasource-types';\nimport { LokiDatasourceEditor } from './LokiDatasourceEditor';\n\nconst createClient: DatasourcePlugin<LokiDatasourceSpec, LokiClient>['createClient'] = (spec, options) => {\n const { directUrl, proxy } = spec;\n const { proxyUrl } = options;\n\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Loki client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n return {\n options: {\n datasourceUrl,\n },\n query: (params, headers) => query(params, { datasourceUrl, headers: headers ?? specHeaders }),\n queryRange: (params, headers) => queryRange(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labels: (
|
|
1
|
+
{"version":3,"sources":["../../../../src/datasources/loki-datasource/LokiDatasource.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n LokiClient,\n query,\n queryRange,\n labels,\n labelValues,\n series,\n volume,\n volumeRange,\n indexStats,\n} from '../../model/loki-client';\nimport { LokiDatasourceSpec } from './loki-datasource-types';\nimport { LokiDatasourceEditor } from './LokiDatasourceEditor';\n\nconst createClient: DatasourcePlugin<LokiDatasourceSpec, LokiClient>['createClient'] = (spec, options) => {\n const { directUrl, proxy } = spec;\n const { proxyUrl } = options;\n\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Loki client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n return {\n options: {\n datasourceUrl,\n },\n query: (params, headers) => query(params, { datasourceUrl, headers: headers ?? specHeaders }),\n queryRange: (params, headers) => queryRange(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labels: (params, headers) => labels(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labelValues: (params, headers) => labelValues(params, { datasourceUrl, headers: headers ?? specHeaders }),\n series: (match, start, end, headers) =>\n series(match, start, end, { datasourceUrl, headers: headers ?? specHeaders }),\n volume: (params, headers) => volume(params, { datasourceUrl, headers: headers ?? specHeaders }),\n volumeRange: (params, headers) => volumeRange(params, { datasourceUrl, headers: headers ?? specHeaders }),\n indexStats: (query, start, end, headers) =>\n indexStats(query, start, end, { datasourceUrl, headers: headers ?? specHeaders }),\n };\n};\n\nexport const LokiDatasource: DatasourcePlugin<LokiDatasourceSpec, LokiClient> = {\n createClient,\n OptionsEditorComponent: LokiDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["query","queryRange","labels","labelValues","series","volume","volumeRange","indexStats","LokiDatasourceEditor","createClient","spec","options","directUrl","proxy","proxyUrl","datasourceUrl","undefined","Error","specHeaders","headers","params","match","start","end","LokiDatasource","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oE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AER;gBAAeI,SAASA,WAAWD;YAAY;IACnF;AACF;AAEA,OAAO,MAAMM,iBAAmE;IAC9Ef;IACAgB,wBAAwBjB;IACxBkB,sBAAsB,IAAO,CAAA;YAAEd,WAAW;QAAG,CAAA;AAC/C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/datasources/loki-datasource/loki-datasource-types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { HTTPProxy } from '@perses-dev/
|
|
1
|
+
{"version":3,"sources":["../../../../src/datasources/loki-datasource/loki-datasource-types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { HTTPProxy } from '@perses-dev/spec';\n\nexport interface LokiDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,WAGC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -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,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;AAC9B,cAAc,aAAa,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './queries';\nexport * from './datasources';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,gBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './queries';\nexport * from './datasources';\nexport * from './variables';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,cAAc"}
|
|
@@ -25,7 +25,7 @@ export interface LokiQueryResponse {
|
|
|
25
25
|
stats?: LokiQueryStats;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
export type LokiQueryRangeResponse = LokiQueryRangeMatrixResponse
|
|
28
|
+
export type LokiQueryRangeResponse = LokiQueryRangeMatrixResponse | LokiQueryRangeStreamsResponse;
|
|
29
29
|
export interface LokiQueryRangeMatrixResponse {
|
|
30
30
|
status: 'success' | 'error';
|
|
31
31
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/loki-client-types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport type LokiResultType = 'vector' | 'matrix' | 'streams';\n\nexport interface LokiQueryStats {\n ingester?: Record<string, unknown>;\n store?: Record<string, unknown>;\n summary?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface LokiVectorResult {\n metric: Record<string, string>;\n value: [number, string];\n}\n\nexport interface LokiMatrixResult {\n metric: Record<string, string>;\n values: Array<[number, string]>;\n}\n\nexport interface LokiStreamResult {\n stream: Record<string, string>;\n values: Array<[string, string]>;\n}\n\nexport interface LokiQueryResponse {\n status: 'success' | 'error';\n data: {\n resultType: 'vector' | 'streams';\n result: LokiVectorResult[] | LokiStreamResult[];\n stats?: LokiQueryStats;\n };\n}\n\nexport type LokiQueryRangeResponse = LokiQueryRangeMatrixResponse
|
|
1
|
+
{"version":3,"sources":["../../../src/model/loki-client-types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport type LokiResultType = 'vector' | 'matrix' | 'streams';\n\nexport interface LokiQueryStats {\n ingester?: Record<string, unknown>;\n store?: Record<string, unknown>;\n summary?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface LokiVectorResult {\n metric: Record<string, string>;\n value: [number, string];\n}\n\nexport interface LokiMatrixResult {\n metric: Record<string, string>;\n values: Array<[number, string]>;\n}\n\nexport interface LokiStreamResult {\n stream: Record<string, string>;\n values: Array<[string, string]>;\n}\n\nexport interface LokiQueryResponse {\n status: 'success' | 'error';\n data: {\n resultType: 'vector' | 'streams';\n result: LokiVectorResult[] | LokiStreamResult[];\n stats?: LokiQueryStats;\n };\n}\n\nexport type LokiQueryRangeResponse = LokiQueryRangeMatrixResponse | LokiQueryRangeStreamsResponse;\n\nexport interface LokiQueryRangeMatrixResponse {\n status: 'success' | 'error';\n data: {\n resultType: 'matrix';\n result: LokiMatrixResult[];\n stats?: LokiQueryStats;\n };\n}\n\nexport interface LokiQueryRangeStreamsResponse {\n status: 'success' | 'error';\n data: {\n resultType: 'streams';\n result: LokiStreamResult[];\n stats?: LokiQueryStats;\n };\n}\nexport interface LokiLabelsResponse {\n status: 'success' | 'error';\n data: string[];\n}\n\nexport interface LokiLabelValuesResponse {\n status: 'success' | 'error';\n data: string[];\n}\n\nexport interface LokiSeriesResponse {\n status: 'success' | 'error';\n data: Array<Record<string, string>>;\n}\n\nexport interface LokiIndexStatsResponse {\n streams: number;\n chunks: number;\n entries: number;\n bytes: number;\n}\n\nexport type LokiVolumeResponse = Record<string, unknown>;\n\nexport type LokiRequestHeaders = Record<string, string>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA8EjC,WAAwD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AbsoluteTimeRange } from '@perses-dev/spec';
|
|
1
2
|
import { LokiQueryResponse, LokiQueryRangeResponse, LokiLabelsResponse, LokiLabelValuesResponse, LokiSeriesResponse, LokiIndexStatsResponse, LokiVolumeResponse, LokiRequestHeaders } from './loki-client-types';
|
|
2
3
|
export interface LokiQueryParams {
|
|
3
4
|
query: string;
|
|
@@ -14,6 +15,17 @@ export interface LokiQueryRangeParams {
|
|
|
14
15
|
direction?: 'forward' | 'backward';
|
|
15
16
|
limit?: number;
|
|
16
17
|
}
|
|
18
|
+
export interface LokiLabelsParams {
|
|
19
|
+
start?: string;
|
|
20
|
+
end?: string;
|
|
21
|
+
query?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface LokiLabelValuesParams {
|
|
24
|
+
labelName: string;
|
|
25
|
+
start?: string;
|
|
26
|
+
end?: string;
|
|
27
|
+
query?: string;
|
|
28
|
+
}
|
|
17
29
|
export interface LokiVolumeParams {
|
|
18
30
|
query: string;
|
|
19
31
|
start: string;
|
|
@@ -31,8 +43,8 @@ export interface LokiClient {
|
|
|
31
43
|
};
|
|
32
44
|
query: (params: LokiQueryParams, headers?: LokiRequestHeaders) => Promise<LokiQueryResponse>;
|
|
33
45
|
queryRange: (params: LokiQueryRangeParams, headers?: LokiRequestHeaders) => Promise<LokiQueryRangeResponse>;
|
|
34
|
-
labels: (
|
|
35
|
-
labelValues: (
|
|
46
|
+
labels: (params: LokiLabelsParams, headers?: LokiRequestHeaders) => Promise<LokiLabelsResponse>;
|
|
47
|
+
labelValues: (params: LokiLabelValuesParams, headers?: LokiRequestHeaders) => Promise<LokiLabelValuesResponse>;
|
|
36
48
|
series: (match: string[], start?: string, end?: string, headers?: LokiRequestHeaders) => Promise<LokiSeriesResponse>;
|
|
37
49
|
volume: (params: LokiVolumeParams, headers?: LokiRequestHeaders) => Promise<LokiVolumeResponse>;
|
|
38
50
|
volumeRange: (params: LokiVolumeParams, headers?: LokiRequestHeaders) => Promise<LokiVolumeResponse>;
|
|
@@ -41,10 +53,14 @@ export interface LokiClient {
|
|
|
41
53
|
export declare function query(params: LokiQueryParams, options: LokiApiOptions): Promise<LokiQueryResponse>;
|
|
42
54
|
export declare function toUnixSeconds(val: string | number | Date): string;
|
|
43
55
|
export declare function queryRange(params: LokiQueryRangeParams, options: LokiApiOptions): Promise<LokiQueryRangeResponse>;
|
|
44
|
-
export declare function labels(
|
|
45
|
-
export declare function labelValues(
|
|
56
|
+
export declare function labels(params: LokiLabelsParams, options: LokiApiOptions): Promise<LokiLabelsResponse>;
|
|
57
|
+
export declare function labelValues(params: LokiLabelValuesParams, options: LokiApiOptions): Promise<LokiLabelValuesResponse>;
|
|
46
58
|
export declare function series(match: string[], start: string | undefined, end: string | undefined, options: LokiApiOptions): Promise<LokiSeriesResponse>;
|
|
47
59
|
export declare function volume(params: LokiVolumeParams, options: LokiApiOptions): Promise<LokiVolumeResponse>;
|
|
48
60
|
export declare function volumeRange(params: LokiVolumeParams, options: LokiApiOptions): Promise<LokiVolumeResponse>;
|
|
49
61
|
export declare function indexStats(query: string, start: string | undefined, end: string | undefined, options: LokiApiOptions): Promise<LokiIndexStatsResponse>;
|
|
62
|
+
export declare function getLokiTimeRange(timeRange: AbsoluteTimeRange): {
|
|
63
|
+
start: string;
|
|
64
|
+
end: string;
|
|
65
|
+
};
|
|
50
66
|
//# sourceMappingURL=loki-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loki-client.d.ts","sourceRoot":"","sources":["../../../src/model/loki-client.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAg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S,EACzB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,kBAAkB,CAAC,CAmB7B;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqB3G;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqBhH;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,sBAAsB,CAAC,CAmBjC;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAK7F"}
|
package/lib/model/loki-client.js
CHANGED
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
+
async function handleErrorResponse(response) {
|
|
14
|
+
const contentType = response.headers?.get('content-type');
|
|
15
|
+
if (contentType && contentType.includes('application/json')) {
|
|
16
|
+
const errorJson = await response.json();
|
|
17
|
+
throw new Error(`Loki query_range error: ${response.status} ${response.statusText} - ${JSON.stringify(errorJson)}`);
|
|
18
|
+
}
|
|
19
|
+
const errorText = await response.text();
|
|
20
|
+
throw new Error(`Loki query_range error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
21
|
+
}
|
|
13
22
|
export async function query(params, options) {
|
|
14
23
|
const url = buildUrl('/loki/api/v1/query', options.datasourceUrl);
|
|
15
24
|
url.searchParams.append('query', params.query);
|
|
@@ -23,6 +32,9 @@ export async function query(params, options) {
|
|
|
23
32
|
...options.headers
|
|
24
33
|
}
|
|
25
34
|
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
await handleErrorResponse(response);
|
|
37
|
+
}
|
|
26
38
|
return response.json();
|
|
27
39
|
}
|
|
28
40
|
function buildUrl(path, datasourceUrl) {
|
|
@@ -69,12 +81,16 @@ export async function queryRange(params, options) {
|
|
|
69
81
|
...options.headers
|
|
70
82
|
}
|
|
71
83
|
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
await handleErrorResponse(response);
|
|
86
|
+
}
|
|
72
87
|
return response.json();
|
|
73
88
|
}
|
|
74
|
-
export async function labels(
|
|
89
|
+
export async function labels(params, options) {
|
|
75
90
|
const url = buildUrl('/loki/api/v1/labels', options.datasourceUrl);
|
|
76
|
-
if (start) url.searchParams.append('start', start);
|
|
77
|
-
if (end) url.searchParams.append('end', end);
|
|
91
|
+
if (params.start) url.searchParams.append('start', params.start);
|
|
92
|
+
if (params.end) url.searchParams.append('end', params.end);
|
|
93
|
+
if (params.query) url.searchParams.append('query', params.query);
|
|
78
94
|
const response = await fetch(url.toString(), {
|
|
79
95
|
method: 'GET',
|
|
80
96
|
headers: {
|
|
@@ -82,12 +98,16 @@ export async function labels(start, end, options) {
|
|
|
82
98
|
...options.headers
|
|
83
99
|
}
|
|
84
100
|
});
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
await handleErrorResponse(response);
|
|
103
|
+
}
|
|
85
104
|
return response.json();
|
|
86
105
|
}
|
|
87
|
-
export async function labelValues(
|
|
88
|
-
const url = buildUrl(`/loki/api/v1/label/${
|
|
89
|
-
if (start) url.searchParams.append('start', start);
|
|
90
|
-
if (end) url.searchParams.append('end', end);
|
|
106
|
+
export async function labelValues(params, options) {
|
|
107
|
+
const url = buildUrl(`/loki/api/v1/label/${params.labelName}/values`, options.datasourceUrl);
|
|
108
|
+
if (params.start) url.searchParams.append('start', params.start);
|
|
109
|
+
if (params.end) url.searchParams.append('end', params.end);
|
|
110
|
+
if (params.query) url.searchParams.append('query', params.query);
|
|
91
111
|
const response = await fetch(url.toString(), {
|
|
92
112
|
method: 'GET',
|
|
93
113
|
headers: {
|
|
@@ -95,6 +115,9 @@ export async function labelValues(label, start, end, options) {
|
|
|
95
115
|
...options.headers
|
|
96
116
|
}
|
|
97
117
|
});
|
|
118
|
+
if (!response.ok) {
|
|
119
|
+
await handleErrorResponse(response);
|
|
120
|
+
}
|
|
98
121
|
return response.json();
|
|
99
122
|
}
|
|
100
123
|
export async function series(match, start, end, options) {
|
|
@@ -109,6 +132,9 @@ export async function series(match, start, end, options) {
|
|
|
109
132
|
...options.headers
|
|
110
133
|
}
|
|
111
134
|
});
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
await handleErrorResponse(response);
|
|
137
|
+
}
|
|
112
138
|
return response.json();
|
|
113
139
|
}
|
|
114
140
|
export async function volume(params, options) {
|
|
@@ -125,6 +151,9 @@ export async function volume(params, options) {
|
|
|
125
151
|
...options.headers
|
|
126
152
|
}
|
|
127
153
|
});
|
|
154
|
+
if (!response.ok) {
|
|
155
|
+
await handleErrorResponse(response);
|
|
156
|
+
}
|
|
128
157
|
return response.json();
|
|
129
158
|
}
|
|
130
159
|
export async function volumeRange(params, options) {
|
|
@@ -141,6 +170,9 @@ export async function volumeRange(params, options) {
|
|
|
141
170
|
...options.headers
|
|
142
171
|
}
|
|
143
172
|
});
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
await handleErrorResponse(response);
|
|
175
|
+
}
|
|
144
176
|
return response.json();
|
|
145
177
|
}
|
|
146
178
|
export async function indexStats(query, start, end, options) {
|
|
@@ -155,7 +187,16 @@ export async function indexStats(query, start, end, options) {
|
|
|
155
187
|
...options.headers
|
|
156
188
|
}
|
|
157
189
|
});
|
|
190
|
+
if (!response.ok) {
|
|
191
|
+
await handleErrorResponse(response);
|
|
192
|
+
}
|
|
158
193
|
return response.json();
|
|
159
194
|
}
|
|
195
|
+
export function getLokiTimeRange(timeRange) {
|
|
196
|
+
return {
|
|
197
|
+
start: toUnixSeconds(timeRange.start),
|
|
198
|
+
end: toUnixSeconds(timeRange.end)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
160
201
|
|
|
161
202
|
//# sourceMappingURL=loki-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/loki-client.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n LokiQueryResponse,\n LokiQueryRangeResponse,\n LokiLabelsResponse,\n LokiLabelValuesResponse,\n LokiSeriesResponse,\n LokiIndexStatsResponse,\n LokiVolumeResponse,\n LokiRequestHeaders,\n} from './loki-client-types';\n\nexport interface LokiQueryParams {\n query: string;\n time?: string;\n direction?: 'forward' | 'backward';\n limit?: number;\n}\n\nexport interface LokiQueryRangeParams {\n query: string;\n start: string;\n end: string;\n step?: string;\n interval?: string;\n direction?: 'forward' | 'backward';\n limit?: number;\n}\n\nexport interface LokiVolumeParams {\n query: string;\n start: string;\n end: string;\n step?: string;\n limit?: number;\n}\n\nexport interface LokiApiOptions {\n datasourceUrl: string;\n headers?: LokiRequestHeaders;\n}\n\nexport interface LokiClient {\n options: {\n datasourceUrl: string;\n };\n query: (params: LokiQueryParams, headers?: LokiRequestHeaders) => Promise<LokiQueryResponse>;\n queryRange: (params: LokiQueryRangeParams, headers?: LokiRequestHeaders) => Promise<LokiQueryRangeResponse>;\n labels: (start?: string, end?: string, headers?: LokiRequestHeaders) => Promise<LokiLabelsResponse>;\n labelValues: (\n label: string,\n start?: string,\n end?: string,\n headers?: LokiRequestHeaders\n ) => Promise<LokiLabelValuesResponse>;\n series: (match: string[], start?: string, end?: string, headers?: LokiRequestHeaders) => Promise<LokiSeriesResponse>;\n volume: (params: LokiVolumeParams, headers?: LokiRequestHeaders) => Promise<LokiVolumeResponse>;\n volumeRange: (params: LokiVolumeParams, headers?: LokiRequestHeaders) => Promise<LokiVolumeResponse>;\n indexStats: (\n query: string,\n start?: string,\n end?: string,\n headers?: LokiRequestHeaders\n ) => Promise<LokiIndexStatsResponse>;\n}\n\nexport async function query(params: LokiQueryParams, options: LokiApiOptions): Promise<LokiQueryResponse> {\n const url = buildUrl('/loki/api/v1/query', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n if (params.time) url.searchParams.append('time', params.time);\n if (params.direction) url.searchParams.append('direction', params.direction);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nfunction buildUrl(path: string, datasourceUrl: string): URL {\n if (datasourceUrl.startsWith('http://') || datasourceUrl.startsWith('https://')) {\n return new URL(path, datasourceUrl);\n }\n\n let fullPath = datasourceUrl;\n // Assume relative path, ensure no double slashes\n if (datasourceUrl.endsWith('/') && path.startsWith('/')) {\n fullPath = datasourceUrl + path.slice(1);\n } else if (!datasourceUrl.endsWith('/') && !path.startsWith('/')) {\n fullPath = datasourceUrl + '/' + path;\n } else {\n fullPath = datasourceUrl + path;\n }\n\n return new URL(fullPath, window.location.origin);\n}\n\nexport function toUnixSeconds(val: string | number | Date): string {\n if (val instanceof Date) return Math.floor(val.getTime() / 1000).toString();\n if (typeof val === 'number') {\n // If it's in ms (>= 10^12), convert to s\n return Math.floor(val > 1e11 ? val / 1000 : val).toString();\n }\n if (/^\\d+$/.test(val)) {\n const num = Number(val);\n return Math.floor(num > 1e11 ? num / 1000 : num).toString();\n }\n const d = new Date(val);\n return Math.floor(d.getTime() / 1000).toString();\n}\n\nexport async function queryRange(\n params: LokiQueryRangeParams,\n options: LokiApiOptions\n): Promise<LokiQueryRangeResponse> {\n const url = buildUrl('/loki/api/v1/query_range', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n url.searchParams.append('start', toUnixSeconds(params.start));\n url.searchParams.append('end', toUnixSeconds(params.end));\n if (params.step) url.searchParams.append('step', params.step);\n if (params.interval) url.searchParams.append('interval', params.interval);\n if (params.direction) url.searchParams.append('direction', params.direction);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nexport async function labels(\n start: string | undefined,\n end: string | undefined,\n options: LokiApiOptions\n): Promise<LokiLabelsResponse> {\n const url = buildUrl('/loki/api/v1/labels', options.datasourceUrl);\n if (start) url.searchParams.append('start', start);\n if (end) url.searchParams.append('end', end);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nexport async function labelValues(\n label: string,\n start: string | undefined,\n end: string | undefined,\n options: LokiApiOptions\n): Promise<LokiLabelValuesResponse> {\n const url = buildUrl(`/loki/api/v1/label/${label}/values`, options.datasourceUrl);\n if (start) url.searchParams.append('start', start);\n if (end) url.searchParams.append('end', end);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nexport async function series(\n match: string[],\n start: string | undefined,\n end: string | undefined,\n options: LokiApiOptions\n): Promise<LokiSeriesResponse> {\n const url = buildUrl('/loki/api/v1/series', options.datasourceUrl);\n match.forEach((m) => url.searchParams.append('match[]', m));\n if (start) url.searchParams.append('start', start);\n if (end) url.searchParams.append('end', end);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nexport async function volume(params: LokiVolumeParams, options: LokiApiOptions): Promise<LokiVolumeResponse> {\n const url = buildUrl('/loki/api/v1/index/volume', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n url.searchParams.append('start', params.start);\n url.searchParams.append('end', params.end);\n if (params.step) url.searchParams.append('step', params.step);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nexport async function volumeRange(params: LokiVolumeParams, options: LokiApiOptions): Promise<LokiVolumeResponse> {\n const url = buildUrl('/loki/api/v1/index/volume_range', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n url.searchParams.append('start', params.start);\n url.searchParams.append('end', params.end);\n if (params.step) url.searchParams.append('step', params.step);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n\nexport async function indexStats(\n query: string,\n start: string | undefined,\n end: string | undefined,\n options: LokiApiOptions\n): Promise<LokiIndexStatsResponse> {\n const url = buildUrl('/loki/api/v1/index/stats', options.datasourceUrl);\n url.searchParams.append('query', query);\n if (start) url.searchParams.append('start', start);\n if (end) url.searchParams.append('end', end);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n return response.json();\n}\n"],"names":["query","params","options","url","buildUrl","datasourceUrl","searchParams","append","time","direction","limit","toString","response","fetch","method","headers","json","path","startsWith","URL","fullPath","endsWith","slice","window","location","origin","toUnixSeconds","val","Date","Math","floor","getTime","test","num","Number","d","queryRange","start","end","step","interval","labels","labelValues","label","series","match","forEach","m","volume","volumeRange","indexStats"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE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AASN,OAAOS,KAAK,CAACC,QAAQ;IAExE,MAAMC,WAAW,MAAMC,MAAMV,IAAIQ,QAAQ,IAAI;QAC3CG,QAAQ;QACRC,SAAS;YACP,gBAAgB;YAChB,GAAGb,QAAQa,OAAO;QACpB;IACF;IACA,OAAOH,SAASI,IAAI;AACtB;AAEA,OAAO,eAAekC,WACpBlD,KAAa,EACbqC,KAAyB,EACzBC,GAAuB,EACvBpC,OAAuB;IAEvB,MAAMC,MAAMC,SAAS,4BAA4BF,QAAQG,aAAa;IACtEF,IAAIG,YAAY,CAACC,MAAM,CAAC,SAASP;IACjC,IAAIqC,OAAOlC,IAAIG,YAAY,CAACC,MAAM,CAAC,SAAS8B;IAC5C,IAAIC,KAAKnC,IAAIG,YAAY,CAACC,MAAM,CAAC,OAAO+B;IAExC,MAAM1B,WAAW,MAAMC,MAAMV,IAAIQ,QAAQ,IAAI;QAC3CG,QAAQ;QACRC,SAAS;YACP,gBAAgB;YAChB,GAAGb,QAAQa,OAAO;QACpB;IACF;IACA,OAAOH,SAASI,IAAI;AACtB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/model/loki-client.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange } from '@perses-dev/spec';\nimport {\n LokiQueryResponse,\n LokiQueryRangeResponse,\n LokiLabelsResponse,\n LokiLabelValuesResponse,\n LokiSeriesResponse,\n LokiIndexStatsResponse,\n LokiVolumeResponse,\n LokiRequestHeaders,\n} from './loki-client-types';\n\nexport interface LokiQueryParams {\n query: string;\n time?: string;\n direction?: 'forward' | 'backward';\n limit?: number;\n}\n\nexport interface LokiQueryRangeParams {\n query: string;\n start: string;\n end: string;\n step?: string;\n interval?: string;\n direction?: 'forward' | 'backward';\n limit?: number;\n}\n\nexport interface LokiLabelsParams {\n start?: string;\n end?: string;\n query?: string;\n}\n\nexport interface LokiLabelValuesParams {\n labelName: string;\n start?: string;\n end?: string;\n query?: string;\n}\n\nexport interface LokiVolumeParams {\n query: string;\n start: string;\n end: string;\n step?: string;\n limit?: number;\n}\n\nexport interface LokiApiOptions {\n datasourceUrl: string;\n headers?: LokiRequestHeaders;\n}\n\nexport interface LokiClient {\n options: {\n datasourceUrl: string;\n };\n query: (params: LokiQueryParams, headers?: LokiRequestHeaders) => Promise<LokiQueryResponse>;\n queryRange: (params: LokiQueryRangeParams, headers?: LokiRequestHeaders) => Promise<LokiQueryRangeResponse>;\n labels: (params: LokiLabelsParams, headers?: LokiRequestHeaders) => Promise<LokiLabelsResponse>;\n labelValues: (params: LokiLabelValuesParams, headers?: LokiRequestHeaders) => Promise<LokiLabelValuesResponse>;\n series: (match: string[], start?: string, end?: string, headers?: LokiRequestHeaders) => Promise<LokiSeriesResponse>;\n volume: (params: LokiVolumeParams, headers?: LokiRequestHeaders) => Promise<LokiVolumeResponse>;\n volumeRange: (params: LokiVolumeParams, headers?: LokiRequestHeaders) => Promise<LokiVolumeResponse>;\n indexStats: (\n query: string,\n start?: string,\n end?: string,\n headers?: LokiRequestHeaders\n ) => Promise<LokiIndexStatsResponse>;\n}\n\nasync function handleErrorResponse(response: Response): Promise<void> {\n const contentType = response.headers?.get('content-type');\n if (contentType && contentType.includes('application/json')) {\n const errorJson = await response.json();\n throw new Error(`Loki query_range error: ${response.status} ${response.statusText} - ${JSON.stringify(errorJson)}`);\n }\n const errorText = await response.text();\n throw new Error(`Loki query_range error: ${response.status} ${response.statusText} - ${errorText}`);\n}\n\nexport async function query(params: LokiQueryParams, options: LokiApiOptions): Promise<LokiQueryResponse> {\n const url = buildUrl('/loki/api/v1/query', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n if (params.time) url.searchParams.append('time', params.time);\n if (params.direction) url.searchParams.append('direction', params.direction);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nfunction buildUrl(path: string, datasourceUrl: string): URL {\n if (datasourceUrl.startsWith('http://') || datasourceUrl.startsWith('https://')) {\n return new URL(path, datasourceUrl);\n }\n\n let fullPath = datasourceUrl;\n // Assume relative path, ensure no double slashes\n if (datasourceUrl.endsWith('/') && path.startsWith('/')) {\n fullPath = datasourceUrl + path.slice(1);\n } else if (!datasourceUrl.endsWith('/') && !path.startsWith('/')) {\n fullPath = datasourceUrl + '/' + path;\n } else {\n fullPath = datasourceUrl + path;\n }\n\n return new URL(fullPath, window.location.origin);\n}\n\nexport function toUnixSeconds(val: string | number | Date): string {\n if (val instanceof Date) return Math.floor(val.getTime() / 1000).toString();\n if (typeof val === 'number') {\n // If it's in ms (>= 10^12), convert to s\n return Math.floor(val > 1e11 ? val / 1000 : val).toString();\n }\n if (/^\\d+$/.test(val)) {\n const num = Number(val);\n return Math.floor(num > 1e11 ? num / 1000 : num).toString();\n }\n const d = new Date(val);\n return Math.floor(d.getTime() / 1000).toString();\n}\n\nexport async function queryRange(\n params: LokiQueryRangeParams,\n options: LokiApiOptions\n): Promise<LokiQueryRangeResponse> {\n const url = buildUrl('/loki/api/v1/query_range', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n url.searchParams.append('start', toUnixSeconds(params.start));\n url.searchParams.append('end', toUnixSeconds(params.end));\n if (params.step) url.searchParams.append('step', params.step);\n if (params.interval) url.searchParams.append('interval', params.interval);\n if (params.direction) url.searchParams.append('direction', params.direction);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport async function labels(params: LokiLabelsParams, options: LokiApiOptions): Promise<LokiLabelsResponse> {\n const url = buildUrl('/loki/api/v1/labels', options.datasourceUrl);\n if (params.start) url.searchParams.append('start', params.start);\n if (params.end) url.searchParams.append('end', params.end);\n if (params.query) url.searchParams.append('query', params.query);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport async function labelValues(\n params: LokiLabelValuesParams,\n options: LokiApiOptions\n): Promise<LokiLabelValuesResponse> {\n const url = buildUrl(`/loki/api/v1/label/${params.labelName}/values`, options.datasourceUrl);\n if (params.start) url.searchParams.append('start', params.start);\n if (params.end) url.searchParams.append('end', params.end);\n if (params.query) url.searchParams.append('query', params.query);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport async function series(\n match: string[],\n start: string | undefined,\n end: string | undefined,\n options: LokiApiOptions\n): Promise<LokiSeriesResponse> {\n const url = buildUrl('/loki/api/v1/series', options.datasourceUrl);\n match.forEach((m) => url.searchParams.append('match[]', m));\n if (start) url.searchParams.append('start', start);\n if (end) url.searchParams.append('end', end);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport async function volume(params: LokiVolumeParams, options: LokiApiOptions): Promise<LokiVolumeResponse> {\n const url = buildUrl('/loki/api/v1/index/volume', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n url.searchParams.append('start', params.start);\n url.searchParams.append('end', params.end);\n if (params.step) url.searchParams.append('step', params.step);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport async function volumeRange(params: LokiVolumeParams, options: LokiApiOptions): Promise<LokiVolumeResponse> {\n const url = buildUrl('/loki/api/v1/index/volume_range', options.datasourceUrl);\n url.searchParams.append('query', params.query);\n url.searchParams.append('start', params.start);\n url.searchParams.append('end', params.end);\n if (params.step) url.searchParams.append('step', params.step);\n if (params.limit) url.searchParams.append('limit', params.limit.toString());\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport async function indexStats(\n query: string,\n start: string | undefined,\n end: string | undefined,\n options: LokiApiOptions\n): Promise<LokiIndexStatsResponse> {\n const url = buildUrl('/loki/api/v1/index/stats', options.datasourceUrl);\n url.searchParams.append('query', query);\n if (start) url.searchParams.append('start', start);\n if (end) url.searchParams.append('end', end);\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n await handleErrorResponse(response);\n }\n\n return response.json();\n}\n\nexport function getLokiTimeRange(timeRange: AbsoluteTimeRange): { start: string; end: string } {\n return {\n start: toUnixSeconds(timeRange.start),\n end: toUnixSeconds(timeRange.end),\n };\n}\n"],"names":["handleErrorResponse","response","contentType","headers","get","includes","errorJson","json","Error","status","statusText","JSON","stringify","errorText","text","query","params","options","url","buildUrl","datasourceUrl","searchParams","append","time","direction","limit","toString","fetch","method","ok","path","startsWith","URL","fullPath","endsWith","slice","window","location","origin","toUnixSeconds","val","Date","Math","floor","getTime","test","num","Number","d","queryRange","start","end","step","interval","labels","labelValues","labelName","series","match","forEach","m","volume","volumeRange","ind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IAAI;IAC5D,IAAIpC,OAAOS,KAAK,EAAEP,IAAIG,YAAY,CAACC,MAAM,CAAC,SAASN,OAAOS,KAAK,CAACC,QAAQ;IAExE,MAAMzB,WAAW,MAAM0B,MAAMT,IAAIQ,QAAQ,IAAI;QAC3CE,QAAQ;QACRzB,SAAS;YACP,gBAAgB;YAChB,GAAGc,QAAQd,OAAO;QACpB;IACF;IAEA,IAAI,CAACF,SAAS4B,EAAE,EAAE;QAChB,MAAM7B,oBAAoBC;IAC5B;IAEA,OAAOA,SAASM,IAAI;AACtB;AAEA,OAAO,eAAewD,WACpBhD,KAAa,EACbmC,KAAyB,EACzBC,GAAuB,EACvBlC,OAAuB;IAEvB,MAAMC,MAAMC,SAAS,4BAA4BF,QAAQG,aAAa;IACtEF,IAAIG,YAAY,CAACC,MAAM,CAAC,SAASP;IACjC,IAAImC,OAAOhC,IAAIG,YAAY,CAACC,MAAM,CAAC,SAAS4B;IAC5C,IAAIC,KAAKjC,IAAIG,YAAY,CAACC,MAAM,CAAC,OAAO6B;IAExC,MAAMlD,WAAW,MAAM0B,MAAMT,IAAIQ,QAAQ,IAAI;QAC3CE,QAAQ;QACRzB,SAAS;YACP,gBAAgB;YAChB,GAAGc,QAAQd,OAAO;QACpB;IACF;IAEA,IAAI,CAACF,SAAS4B,EAAE,EAAE;QAChB,MAAM7B,oBAAoBC;IAC5B;IAEA,OAAOA,SAASM,IAAI;AACtB;AAEA,OAAO,SAASyD,iBAAiBC,SAA4B;IAC3D,OAAO;QACLf,OAAOX,cAAc0B,UAAUf,KAAK;QACpCC,KAAKZ,cAAc0B,UAAUd,GAAG;IAClC;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbsoluteTimeRange, LogData, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/spec';
|
|
2
2
|
export interface LokiTimeSeriesData extends TimeSeriesData {
|
|
3
3
|
logs?: LogData;
|
|
4
4
|
resultType?: 'matrix' | 'streams';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loki-data-types.d.ts","sourceRoot":"","sources":["../../../src/model/loki-data-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"loki-data-types.d.ts","sourceRoot":"","sources":["../../../src/model/loki-data-types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,OAAO,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 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 {
|
|
1
|
+
{"version":3,"sources":["../../../src/model/loki-data-types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, LogData, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/spec';\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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC,WAOC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatasourceSelector } from '@perses-dev/core';
|
|
2
1
|
import { DatasourceSelectValue } from '@perses-dev/plugin-system';
|
|
2
|
+
import { DatasourceSelector } from '@perses-dev/spec';
|
|
3
3
|
export declare const LOKI_DATASOURCE_KIND: "LokiDatasource";
|
|
4
4
|
export interface LokiDatasourceSelector extends DatasourceSelector {
|
|
5
5
|
kind: typeof LOKI_DATASOURCE_KIND;
|