@perses-dev/prometheus-plugin 0.50.3 → 0.51.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +183 -183
- package/README.md +41 -0
- package/__mf/css/async/2341.dacad691.css +1 -0
- package/__mf/css/async/5263.dacad691.css +1 -0
- package/__mf/css/async/6759.dacad691.css +1 -0
- 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/622.f7592106.js +5 -0
- package/__mf/js/Prometheus.328aad7c.js +5 -0
- package/__mf/js/async/1465.3b5e12d5.js +1 -0
- package/__mf/js/async/1495.6c8b8071.js +1 -0
- package/__mf/js/async/1620.6376bd14.js +2 -0
- package/__mf/js/async/1620.6376bd14.js.LICENSE.txt +9 -0
- package/__mf/js/async/1864.df7c4beb.js +1 -0
- package/__mf/js/async/1950.704c331e.js +1 -0
- package/__mf/js/async/1964.95da06f6.js +2 -0
- package/__mf/js/async/1964.95da06f6.js.LICENSE.txt +9 -0
- package/__mf/js/async/1996.01084c88.js +2 -0
- package/__mf/js/async/1996.01084c88.js.LICENSE.txt +24 -0
- package/__mf/js/async/212.bd5d617a.js +1 -0
- package/__mf/js/async/2316.fec4907a.js +1 -0
- package/__mf/js/async/232.f3523a60.js +1 -0
- package/__mf/js/async/2569.daf868a6.js +10 -0
- package/__mf/js/async/2569.daf868a6.js.LICENSE.txt +27 -0
- package/__mf/js/async/2675.c3b73822.js +1 -0
- package/__mf/js/async/3224.23f0dccf.js +1 -0
- package/__mf/js/async/3355.a4dbcdb0.js +1 -0
- package/__mf/js/async/3436.97c926a4.js +1 -0
- package/__mf/js/async/3818.dde21d04.js +1 -0
- package/__mf/js/async/3871.6915e369.js +1 -0
- package/__mf/js/async/3960.129d5ef5.js +2 -0
- package/__mf/js/async/3960.129d5ef5.js.LICENSE.txt +8 -0
- package/__mf/js/async/4075.b77ca1c7.js +1 -0
- package/__mf/js/async/4238.8e4d29d5.js +1 -0
- package/__mf/js/async/4323.4266fd6a.js +1 -0
- package/__mf/js/async/4421.1bcc1637.js +1 -0
- package/__mf/js/async/4489.3361e7bc.js +29 -0
- package/__mf/js/async/4489.3361e7bc.js.LICENSE.txt +59 -0
- package/__mf/js/async/5214.027c4332.js +1 -0
- package/__mf/js/async/5345.8c2e4b4a.js +1 -0
- package/__mf/js/async/537.6911ea2e.js +1 -0
- package/__mf/js/async/5387.fd6e16d6.js +1 -0
- package/__mf/js/async/5654.ecb41aea.js +38 -0
- package/__mf/js/async/5724.6ee6ec51.js +1 -0
- package/__mf/js/async/5774.9b0b6be1.js +1 -0
- package/__mf/js/async/5790.2273e061.js +1 -0
- package/__mf/js/async/5913.9d30fd07.js +73 -0
- package/__mf/js/async/5913.9d30fd07.js.LICENSE.txt +19 -0
- package/__mf/js/async/5914.bd342d22.js +74 -0
- package/__mf/js/async/5981.40bed0d0.js +2 -0
- package/__mf/js/async/5981.40bed0d0.js.LICENSE.txt +8 -0
- package/__mf/js/async/6292.7b8efa78.js +1 -0
- package/__mf/js/async/6333.865a46e0.js +2 -0
- package/__mf/js/async/6333.865a46e0.js.LICENSE.txt +9 -0
- package/__mf/js/async/6377.ca974d89.js +2 -0
- package/__mf/js/async/6377.ca974d89.js.LICENSE.txt +32 -0
- package/__mf/js/async/6770.adb1c939.js +1 -0
- package/__mf/js/async/684.ca510333.js +1 -0
- package/__mf/js/async/694.f861d67c.js +1 -0
- package/__mf/js/async/7272.a763aa92.js +1 -0
- package/__mf/js/async/738.aca54e25.js +1 -0
- package/__mf/js/async/7740.0c5363fd.js +1 -0
- package/__mf/js/async/8265.b9e2c31e.js +1 -0
- package/__mf/js/async/8488.5237550f.js +1 -0
- package/__mf/js/async/8587.4891ea90.js +1 -0
- package/__mf/js/async/8610.8300df79.js +1 -0
- package/__mf/js/async/87.fdc843ac.js +1 -0
- package/__mf/js/async/8930.9fbbc975.js +1 -0
- package/__mf/js/async/8997.18901f45.js +28 -0
- package/__mf/js/async/9173.e8fbead5.js +2 -0
- package/__mf/js/async/9173.e8fbead5.js.LICENSE.txt +19 -0
- package/__mf/js/async/__federation_expose_PrometheusDatasource.f6f57299.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusExplorer.5fcf955a.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86d0ad5a.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.b2893484.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.cd16f6e8.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.eb9eefa6.js +1 -0
- package/__mf/js/main.154a5b65.js +1 -0
- package/lib/bootstrap.d.ts +2 -0
- package/lib/bootstrap.d.ts.map +1 -0
- package/lib/bootstrap.js +19 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/cjs/bootstrap.js +26 -0
- package/{dist → lib}/cjs/components/PromQLEditor.js +9 -7
- package/lib/cjs/components/TreeNode.js +492 -0
- package/{dist → lib}/cjs/components/promql/ast.js +21 -21
- package/lib/cjs/components/promql/functionSignatures.js +651 -0
- package/lib/cjs/components/promql/serialize.js +88 -0
- package/{dist → lib}/cjs/components/promql/utils.js +12 -1
- package/{dist/cjs/components/parse.js → lib/cjs/components/query.js} +37 -4
- package/lib/cjs/env.d.js +14 -0
- package/lib/cjs/explore/PrometheusExplorer.js +203 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +268 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/display/MetricChip.js +61 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/display/list/MetricList.js +179 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +231 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +97 -0
- package/{dist/cjs/plugins/prometheus-time-series-query → lib/cjs/explore/PrometheusMetricsFinder}/index.js +1 -1
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/MetricOverview.js +235 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +144 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +423 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +53 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/types.js +25 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +203 -0
- package/lib/cjs/explore/index.js +19 -0
- package/lib/cjs/getPluginModule.js +27 -0
- package/lib/cjs/index-federation.js +55 -0
- package/lib/cjs/index.js +28 -0
- package/{dist → lib}/cjs/model/api-types.js +1 -1
- package/{dist → lib}/cjs/model/prometheus-client.js +1 -1
- package/lib/cjs/plugins/PrometheusDatasourceEditor.js +109 -0
- package/lib/cjs/plugins/PrometheusLabelNamesVariable.js +34 -0
- package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +38 -0
- package/lib/cjs/plugins/PrometheusPromQLVariable.js +42 -0
- package/lib/cjs/plugins/index.js +26 -0
- package/{dist → lib}/cjs/plugins/prometheus-datasource.js +9 -9
- package/{dist → lib}/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +11 -9
- package/{dist → lib}/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +51 -29
- package/lib/cjs/plugins/prometheus-time-series-query/index.js +35 -0
- package/{dist → lib}/cjs/plugins/prometheus-variables.js +25 -101
- package/{dist → lib}/cjs/plugins/variable.js +1 -2
- package/lib/cjs/setup-tests.js +19 -0
- package/{dist → lib}/cjs/utils/utils.js +1 -2
- package/lib/components/PromQLEditor.d.ts.map +1 -0
- package/{dist → lib}/components/PromQLEditor.js +9 -7
- package/lib/components/PromQLEditor.js.map +1 -0
- package/lib/components/TreeNode.d.ts +15 -0
- package/lib/components/TreeNode.d.ts.map +1 -0
- package/lib/components/TreeNode.js +479 -0
- package/lib/components/TreeNode.js.map +1 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js.map +1 -0
- package/lib/components/promql/ast.d.ts.map +1 -0
- package/{dist → lib}/components/promql/ast.js +21 -21
- package/lib/components/promql/ast.js.map +1 -0
- package/{dist → lib}/components/promql/format.d.ts +1 -1
- package/lib/components/promql/format.d.ts.map +1 -0
- package/lib/components/promql/format.js.map +1 -0
- package/lib/components/promql/functionSignatures.d.ts +3 -0
- package/lib/components/promql/functionSignatures.d.ts.map +1 -0
- package/lib/components/promql/functionSignatures.js +643 -0
- package/lib/components/promql/functionSignatures.js.map +1 -0
- package/lib/components/promql/serialize.d.ts +4 -0
- package/lib/components/promql/serialize.d.ts.map +1 -0
- package/lib/components/promql/serialize.js +80 -0
- package/lib/components/promql/serialize.js.map +1 -0
- package/{dist → lib}/components/promql/utils.d.ts +1 -0
- package/lib/components/promql/utils.d.ts.map +1 -0
- package/{dist → lib}/components/promql/utils.js +9 -1
- package/lib/components/promql/utils.js.map +1 -0
- package/lib/components/query.d.ts +6 -0
- package/lib/components/query.d.ts.map +1 -0
- package/{dist/components/parse.js → lib/components/query.js} +27 -2
- package/lib/components/query.js.map +1 -0
- package/lib/env.d.js +15 -0
- package/lib/env.d.js.map +1 -0
- package/lib/explore/PrometheusExplorer.d.ts +3 -0
- package/lib/explore/PrometheusExplorer.d.ts.map +1 -0
- package/lib/explore/PrometheusExplorer.js +190 -0
- package/lib/explore/PrometheusExplorer.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts +31 -0
- package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +244 -0
- package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/display/MetricChip.d.ts +4 -0
- package/lib/explore/PrometheusMetricsFinder/display/MetricChip.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js +53 -0
- package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.d.ts +27 -0
- package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js +158 -0
- package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.d.ts +23 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +209 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.d.ts +13 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +84 -0
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/index.d.ts +2 -0
- package/lib/explore/PrometheusMetricsFinder/index.d.ts.map +1 -0
- package/{dist/model/api-types.js → lib/explore/PrometheusMetricsFinder/index.js} +2 -2
- package/lib/explore/PrometheusMetricsFinder/index.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.d.ts +23 -0
- package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js +214 -0
- package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts +28 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +125 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts +25 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +399 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts +12 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +45 -0
- package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/types.d.ts +22 -0
- package/lib/explore/PrometheusMetricsFinder/types.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/types.js +17 -0
- package/lib/explore/PrometheusMetricsFinder/types.js.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/utils.d.ts +22 -0
- package/lib/explore/PrometheusMetricsFinder/utils.d.ts.map +1 -0
- package/lib/explore/PrometheusMetricsFinder/utils.js +185 -0
- package/lib/explore/PrometheusMetricsFinder/utils.js.map +1 -0
- package/lib/explore/index.d.ts +3 -0
- package/lib/explore/index.d.ts.map +1 -0
- package/lib/explore/index.js +4 -0
- package/lib/explore/index.js.map +1 -0
- package/lib/getPluginModule.d.ts +6 -0
- package/lib/getPluginModule.d.ts.map +1 -0
- package/lib/getPluginModule.js +16 -0
- package/lib/getPluginModule.js.map +1 -0
- package/lib/index-federation.d.ts +1 -0
- package/lib/index-federation.d.ts.map +1 -0
- package/lib/index-federation.js +15 -0
- package/{dist/components/index.js.map → lib/index-federation.js.map} +1 -1
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/{dist → lib}/model/api-types.d.ts +18 -1
- package/lib/model/api-types.d.ts.map +1 -0
- package/{dist/plugins/prometheus-time-series-query/index.js → lib/model/api-types.js} +3 -3
- package/lib/model/api-types.js.map +1 -0
- package/lib/model/index.d.ts.map +1 -0
- package/lib/model/index.js.map +1 -0
- package/lib/model/parse-sample-values.d.ts.map +1 -0
- package/lib/model/parse-sample-values.js.map +1 -0
- package/lib/model/prometheus-client.d.ts.map +1 -0
- package/{dist → lib}/model/prometheus-client.js +1 -1
- package/lib/model/prometheus-client.js.map +1 -0
- package/lib/model/prometheus-selectors.d.ts.map +1 -0
- package/lib/model/prometheus-selectors.js.map +1 -0
- package/lib/model/time.d.ts.map +1 -0
- package/lib/model/time.js.map +1 -0
- package/lib/plugins/MatcherEditor.d.ts.map +1 -0
- package/lib/plugins/MatcherEditor.js.map +1 -0
- package/lib/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/lib/plugins/PrometheusDatasourceEditor.js +96 -0
- package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -0
- package/lib/plugins/PrometheusLabelNamesVariable.d.ts +4 -0
- package/lib/plugins/PrometheusLabelNamesVariable.d.ts.map +1 -0
- package/lib/plugins/PrometheusLabelNamesVariable.js +26 -0
- package/lib/plugins/PrometheusLabelNamesVariable.js.map +1 -0
- package/lib/plugins/PrometheusLabelValuesVariable.d.ts +4 -0
- package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -0
- package/lib/plugins/PrometheusLabelValuesVariable.js +30 -0
- package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -0
- package/lib/plugins/PrometheusPromQLVariable.d.ts +4 -0
- package/lib/plugins/PrometheusPromQLVariable.d.ts.map +1 -0
- package/lib/plugins/PrometheusPromQLVariable.js +34 -0
- package/lib/plugins/PrometheusPromQLVariable.js.map +1 -0
- package/lib/plugins/index.d.ts +10 -0
- package/lib/plugins/index.d.ts.map +1 -0
- package/lib/plugins/index.js +11 -0
- package/lib/plugins/index.js.map +1 -0
- package/lib/plugins/prometheus-datasource.d.ts.map +1 -0
- package/{dist → lib}/plugins/prometheus-datasource.js +9 -9
- package/lib/plugins/prometheus-datasource.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +1 -0
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +9 -7
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -0
- package/{dist → lib}/plugins/prometheus-time-series-query/get-time-series-data.js +51 -29
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/index.d.ts +7 -0
- package/lib/plugins/prometheus-time-series-query/index.d.ts.map +1 -0
- package/lib/plugins/prometheus-time-series-query/index.js +20 -0
- package/lib/plugins/prometheus-time-series-query/index.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -0
- package/lib/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.d.ts.map +1 -0
- package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js.map +1 -0
- package/lib/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -0
- package/lib/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -0
- package/lib/plugins/prometheus-variables.d.ts +14 -0
- package/lib/plugins/prometheus-variables.d.ts.map +1 -0
- package/{dist → lib}/plugins/prometheus-variables.js +15 -98
- package/lib/plugins/prometheus-variables.js.map +1 -0
- package/lib/plugins/types.d.ts.map +1 -0
- package/lib/plugins/types.js.map +1 -0
- package/lib/plugins/variable.d.ts.map +1 -0
- package/{dist → lib}/plugins/variable.js +1 -2
- package/lib/plugins/variable.js.map +1 -0
- package/lib/setup-tests.d.ts +2 -0
- package/lib/setup-tests.d.ts.map +1 -0
- package/lib/setup-tests.js +17 -0
- package/{dist/utils/index.js.map → lib/setup-tests.js.map} +1 -1
- package/lib/test/setup-tests.d.ts.map +1 -0
- package/lib/test/setup-tests.js.map +1 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/{dist → lib}/utils/utils.js +1 -2
- package/lib/utils/utils.js.map +1 -0
- package/mf-manifest.json +898 -0
- package/mf-stats.json +1004 -0
- package/package.json +99 -38
- package/dist/cjs/components/TreeNode.js +0 -147
- package/dist/cjs/index.js +0 -61
- package/dist/cjs/plugins/PrometheusDatasourceEditor.js +0 -626
- package/dist/components/PromQLEditor.d.ts.map +0 -1
- package/dist/components/PromQLEditor.js.map +0 -1
- package/dist/components/TreeNode.d.ts +0 -10
- package/dist/components/TreeNode.d.ts.map +0 -1
- package/dist/components/TreeNode.js +0 -139
- package/dist/components/TreeNode.js.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/parse.d.ts +0 -5
- package/dist/components/parse.d.ts.map +0 -1
- package/dist/components/parse.js.map +0 -1
- package/dist/components/promql/ast.d.ts.map +0 -1
- package/dist/components/promql/ast.js.map +0 -1
- package/dist/components/promql/format.d.ts.map +0 -1
- package/dist/components/promql/format.js.map +0 -1
- package/dist/components/promql/utils.d.ts.map +0 -1
- package/dist/components/promql/utils.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/model/api-types.d.ts.map +0 -1
- package/dist/model/api-types.js.map +0 -1
- package/dist/model/index.d.ts.map +0 -1
- package/dist/model/index.js.map +0 -1
- package/dist/model/parse-sample-values.d.ts.map +0 -1
- package/dist/model/parse-sample-values.js.map +0 -1
- package/dist/model/prometheus-client.d.ts.map +0 -1
- package/dist/model/prometheus-client.js.map +0 -1
- package/dist/model/prometheus-selectors.d.ts.map +0 -1
- package/dist/model/prometheus-selectors.js.map +0 -1
- package/dist/model/time.d.ts.map +0 -1
- package/dist/model/time.js.map +0 -1
- package/dist/plugins/MatcherEditor.d.ts.map +0 -1
- package/dist/plugins/MatcherEditor.js.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor.js +0 -572
- package/dist/plugins/PrometheusDatasourceEditor.js.map +0 -1
- package/dist/plugins/prometheus-datasource.d.ts.map +0 -1
- package/dist/plugins/prometheus-datasource.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/index.d.ts +0 -2
- package/dist/plugins/prometheus-time-series-query/index.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/index.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/replace-prom-builtin-variables.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js.map +0 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +0 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +0 -1
- package/dist/plugins/prometheus-variables.d.ts +0 -6
- package/dist/plugins/prometheus-variables.d.ts.map +0 -1
- package/dist/plugins/prometheus-variables.js.map +0 -1
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/plugins/types.js.map +0 -1
- package/dist/plugins/variable.d.ts.map +0 -1
- package/dist/plugins/variable.js.map +0 -1
- package/dist/test/setup-tests.d.ts.map +0 -1
- package/dist/test/setup-tests.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/plugin.json +0 -58
- /package/{dist → lib}/cjs/components/index.js +0 -0
- /package/{dist → lib}/cjs/components/promql/format.js +0 -0
- /package/{dist → lib}/cjs/model/index.js +0 -0
- /package/{dist → lib}/cjs/model/parse-sample-values.js +0 -0
- /package/{dist → lib}/cjs/model/prometheus-selectors.js +0 -0
- /package/{dist → lib}/cjs/model/time.js +0 -0
- /package/{dist → lib}/cjs/plugins/MatcherEditor.js +0 -0
- /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +0 -0
- /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/query-editor-model.js +0 -0
- /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +0 -0
- /package/{dist → lib}/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +0 -0
- /package/{dist → lib}/cjs/plugins/types.js +0 -0
- /package/{dist → lib}/cjs/test/setup-tests.js +0 -0
- /package/{dist → lib}/cjs/utils/index.js +0 -0
- /package/{dist → lib}/components/PromQLEditor.d.ts +0 -0
- /package/{dist → lib}/components/index.d.ts +0 -0
- /package/{dist → lib}/components/index.js +0 -0
- /package/{dist → lib}/components/promql/ast.d.ts +0 -0
- /package/{dist → lib}/components/promql/format.js +0 -0
- /package/{dist → lib}/model/index.d.ts +0 -0
- /package/{dist → lib}/model/index.js +0 -0
- /package/{dist → lib}/model/parse-sample-values.d.ts +0 -0
- /package/{dist → lib}/model/parse-sample-values.js +0 -0
- /package/{dist → lib}/model/prometheus-client.d.ts +0 -0
- /package/{dist → lib}/model/prometheus-selectors.d.ts +0 -0
- /package/{dist → lib}/model/prometheus-selectors.js +0 -0
- /package/{dist → lib}/model/time.d.ts +0 -0
- /package/{dist → lib}/model/time.js +0 -0
- /package/{dist → lib}/plugins/MatcherEditor.d.ts +0 -0
- /package/{dist → lib}/plugins/MatcherEditor.js +0 -0
- /package/{dist → lib}/plugins/PrometheusDatasourceEditor.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-datasource.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/get-time-series-data.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/query-editor-model.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/query-editor-model.js +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/replace-prom-builtin-variables.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/time-series-query-model.d.ts +0 -0
- /package/{dist → lib}/plugins/prometheus-time-series-query/time-series-query-model.js +0 -0
- /package/{dist → lib}/plugins/types.d.ts +0 -0
- /package/{dist → lib}/plugins/types.js +0 -0
- /package/{dist → lib}/plugins/variable.d.ts +0 -0
- /package/{dist → lib}/test/setup-tests.d.ts +0 -0
- /package/{dist → lib}/test/setup-tests.js +0 -0
- /package/{dist → lib}/utils/index.d.ts +0 -0
- /package/{dist → lib}/utils/index.js +0 -0
- /package/{dist → lib}/utils/utils.d.ts +0 -0
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import ASTNode from './promql/ast';
|
|
3
|
-
interface TreeNodeProps {
|
|
4
|
-
node: ASTNode;
|
|
5
|
-
parentEl?: HTMLDivElement | null;
|
|
6
|
-
reverse: boolean;
|
|
7
|
-
}
|
|
8
|
-
declare const TreeNode: React.FC<TreeNodeProps>;
|
|
9
|
-
export default TreeNode;
|
|
10
|
-
//# sourceMappingURL=TreeNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNode.d.ts","sourceRoot":"","sources":["../../src/components/TreeNode.tsx"],"names":[],"mappings":";AAiBA,OAAO,OAAqB,MAAM,cAAc,CAAC;AAQjD,UAAU,aAAa;IAErB,IAAI,EAAE,OAAO,CAAC;IAEd,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAEjC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0GrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { Box, useTheme } from '@mui/material';
|
|
16
|
-
import { useCallback, useLayoutEffect, useState } from 'react';
|
|
17
|
-
import { nodeType } from './promql/ast';
|
|
18
|
-
import { getNodeChildren } from './promql/utils';
|
|
19
|
-
import { formatNode } from './promql/format';
|
|
20
|
-
// The indentation factor for each level of the tree.
|
|
21
|
-
const nodeIndent = 5;
|
|
22
|
-
const connectorWidth = nodeIndent * 5;
|
|
23
|
-
const TreeNode = ({ node, parentEl, reverse })=>{
|
|
24
|
-
const theme = useTheme();
|
|
25
|
-
const children = getNodeChildren(node);
|
|
26
|
-
// A normal ref won't work properly here because the ref's `current` property
|
|
27
|
-
// going from `null` to defined won't trigger a re-render of the child
|
|
28
|
-
// component, since it's not a React state update. So we manually have to
|
|
29
|
-
// create a state update using a callback ref. See also
|
|
30
|
-
// https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs
|
|
31
|
-
const [nodeEl, setNodeEl] = useState(null);
|
|
32
|
-
const nodeRef = useCallback((node)=>setNodeEl(node), []);
|
|
33
|
-
const [connectorStyle, setConnectorStyle] = useState({
|
|
34
|
-
borderColor: theme.palette.grey['500'],
|
|
35
|
-
borderLeftStyle: 'solid',
|
|
36
|
-
borderLeftWidth: 2,
|
|
37
|
-
width: connectorWidth,
|
|
38
|
-
left: -connectorWidth
|
|
39
|
-
});
|
|
40
|
-
// Update the size and position of tree connector lines based on the node's and its parent's position.
|
|
41
|
-
useLayoutEffect(()=>{
|
|
42
|
-
if (parentEl === undefined) {
|
|
43
|
-
// We're the root node.
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (parentEl === null || nodeEl === null) {
|
|
47
|
-
// Either of the two connected nodes hasn't been rendered yet.
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const parentRect = parentEl.getBoundingClientRect();
|
|
51
|
-
const nodeRect = nodeEl.getBoundingClientRect();
|
|
52
|
-
if (reverse) {
|
|
53
|
-
setConnectorStyle((prevStyle)=>({
|
|
54
|
-
...prevStyle,
|
|
55
|
-
top: 'calc(50% - 1px)',
|
|
56
|
-
bottom: nodeRect.bottom - parentRect.top,
|
|
57
|
-
borderTopLeftRadius: 10,
|
|
58
|
-
borderTopStyle: 'solid',
|
|
59
|
-
borderBottomLeftRadius: undefined
|
|
60
|
-
}));
|
|
61
|
-
} else {
|
|
62
|
-
setConnectorStyle((prevStyle)=>({
|
|
63
|
-
...prevStyle,
|
|
64
|
-
top: parentRect.bottom - nodeRect.top,
|
|
65
|
-
bottom: 'calc(50% - 1px)',
|
|
66
|
-
borderBottomLeftRadius: 10,
|
|
67
|
-
borderBottomStyle: 'solid',
|
|
68
|
-
borderTopLeftRadius: undefined
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}, [
|
|
72
|
-
parentEl,
|
|
73
|
-
nodeEl,
|
|
74
|
-
reverse,
|
|
75
|
-
nodeRef,
|
|
76
|
-
setConnectorStyle
|
|
77
|
-
]);
|
|
78
|
-
const innerNode = /*#__PURE__*/ _jsxs(Box, {
|
|
79
|
-
ref: nodeRef,
|
|
80
|
-
sx: {
|
|
81
|
-
position: 'relative',
|
|
82
|
-
display: 'inline-block',
|
|
83
|
-
padding: 1,
|
|
84
|
-
marginBottom: 1.5,
|
|
85
|
-
borderRadius: 2,
|
|
86
|
-
backgroundColor: theme.palette.background.code
|
|
87
|
-
},
|
|
88
|
-
children: [
|
|
89
|
-
parentEl !== undefined && // Connector line between this node and its parent.
|
|
90
|
-
/*#__PURE__*/ _jsx(Box, {
|
|
91
|
-
sx: {
|
|
92
|
-
position: 'absolute',
|
|
93
|
-
display: 'inline-block',
|
|
94
|
-
...connectorStyle
|
|
95
|
-
}
|
|
96
|
-
}),
|
|
97
|
-
formatNode(node, false, 1)
|
|
98
|
-
]
|
|
99
|
-
});
|
|
100
|
-
if (node.type === nodeType.binaryExpr) {
|
|
101
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
102
|
-
children: [
|
|
103
|
-
/*#__PURE__*/ _jsx(Box, {
|
|
104
|
-
ml: nodeIndent,
|
|
105
|
-
children: /*#__PURE__*/ _jsx(TreeNode, {
|
|
106
|
-
node: children[0],
|
|
107
|
-
parentEl: nodeEl,
|
|
108
|
-
reverse: true
|
|
109
|
-
})
|
|
110
|
-
}),
|
|
111
|
-
innerNode,
|
|
112
|
-
/*#__PURE__*/ _jsx(Box, {
|
|
113
|
-
ml: nodeIndent,
|
|
114
|
-
children: /*#__PURE__*/ _jsx(TreeNode, {
|
|
115
|
-
node: children[1],
|
|
116
|
-
parentEl: nodeEl,
|
|
117
|
-
reverse: false
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
]
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
124
|
-
children: [
|
|
125
|
-
innerNode,
|
|
126
|
-
children.map((child, idx)=>/*#__PURE__*/ _jsx(Box, {
|
|
127
|
-
ml: nodeIndent,
|
|
128
|
-
children: /*#__PURE__*/ _jsx(TreeNode, {
|
|
129
|
-
node: child,
|
|
130
|
-
parentEl: nodeEl,
|
|
131
|
-
reverse: false
|
|
132
|
-
})
|
|
133
|
-
}, idx))
|
|
134
|
-
]
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
export default TreeNode;
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=TreeNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TreeNode.tsx"],"sourcesContent":["// Copyright 2024 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, useTheme } from '@mui/material';\nimport { useCallback, useLayoutEffect, useState } from 'react';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n}\n\nconst TreeNode: React.FC<TreeNodeProps> = ({ node, parentEl, reverse }) => {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n const innerNode = (\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode node={children[0]!} parentEl={nodeEl} reverse={true} />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode node={children[1]!} parentEl={nodeEl} reverse={false} />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode node={child} parentEl={nodeEl} reverse={false} />\n </Box>\n ))}\n </div>\n );\n};\n\nexport default TreeNode;\n"],"names":["Box","useTheme","useCallback","useLayoutEffect","useState","nodeType","getNodeChildren","formatNode","nodeIndent","connectorWidth","TreeNode","node","parentEl","reverse","theme","children","nodeEl","setNodeEl","nodeRef","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","innerNode","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","type","binaryExpr","div","ml","map","child","idx"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,oJAAoJ;;AAEpJ,SAASA,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAC9C,SAASC,WAAW,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,QAAQ;AAC/D,SAAkBC,QAAQ,QAAQ,eAAe;AACjD,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,qDAAqD;AACrD,MAAMC,aAAa;AACnB,MAAMC,iBAAiBD,aAAa;AAWpC,MAAME,WAAoC,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAE;IACpE,MAAMC,QAAQb;IACd,MAAMc,WAAWT,gBAAgBK;IAEjC,6EAA6E;IAC7E,sEAAsE;IACtE,yEAAyE;IACzE,uDAAuD;IACvD,gEAAgE;IAChE,MAAM,CAACK,QAAQC,UAAU,GAAGb,SAAgC;IAC5D,MAAMc,UAAUhB,YAAY,CAACS,OAAyBM,UAAUN,OAAO,EAAE;IAEzE,MAAM,CAACQ,gBAAgBC,kBAAkB,GAAGhB,SAAS;QACnDiB,aAAaP,MAAMQ,OAAO,CAACC,IAAI,CAAC,MAAM;QACtCC,iBAAiB;QACjBC,iBAAiB;QACjBC,OAAOjB;QACPkB,MAAM,CAAClB;IACT;IAEA,sGAAsG;IACtGN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AASC,MAAMI,QAAQ,CAAC,EAAE;wBAAGH,UAAUI;wBAAQH,SAAS;;;;;IAIjE;IAEA,qBACE,MAACuC;;YACEb;YACAxB,SAASuC,GAAG,CAAC,CAACC,OAAOC,oBACpB,KAACxD;oBAAIqD,IAAI7C;8BACP,cAAA,KAACE;wBAASC,MAAM4C;wBAAO3C,UAAUI;wBAAQH,SAAS;;mBAD1B2C;;;AAMlC;AAEA,eAAe9C,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DatasourceSelector, StatusError } from '@perses-dev/core';
|
|
2
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { ParseQueryResponse } from '../model';
|
|
4
|
-
export declare function useParseQuery(content: string, datasource: DatasourceSelector, enabled?: boolean): UseQueryResult<ParseQueryResponse, StatusError>;
|
|
5
|
-
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/components/parse.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAA+B,kBAAkB,EAAoB,MAAM,UAAU,CAAC;AAE7F,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,OAAO,GAChB,cAAc,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAYjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/parse.ts"],"sourcesContent":["// Copyright 2024 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 { useDatasourceClient } from '@perses-dev/plugin-system';\nimport { DatasourceSelector, StatusError } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { ParseQueryRequestParameters, ParseQueryResponse, PrometheusClient } from '../model';\n\nexport function useParseQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<ParseQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<ParseQueryResponse, StatusError>({\n enabled: !!client && enabled,\n queryKey: ['parseQuery', content, 'datasource', datasource],\n queryFn: async () => {\n const params: ParseQueryRequestParameters = { query: content };\n\n return await client!.parseQuery(params);\n },\n });\n}\n"],"names":["useDatasourceClient","useQuery","useParseQuery","content","datasource","enabled","data","client","queryKey","queryFn","params","query","parseQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,QAAQ,QAAwB,wBAAwB;AAGjE,OAAO,SAASC,cACdC,OAAe,EACfC,UAA8B,EAC9BC,OAAiB;IAEjB,MAAM,EAAEC,MAAMC,MAAM,EAAE,GAAGP,oBAAsCI;IAE/D,OAAOH,SAA0C;QAC/CI,SAAS,CAAC,CAACE,UAAUF;QACrBG,UAAU;YAAC;YAAcL;YAAS;YAAcC;SAAW;QAC3DK,SAAS;YACP,MAAMC,SA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M,CAAC;IACb,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAGD,KAAK,OAAO,GACR,WAAW,GACX,UAAU,GACV,IAAI,GACJ,cAAc,GACd,QAAQ,GACR,aAAa,GACb,SAAS,GACT,aAAa,GACb,SAAS,GACT,cAAc,GACd,WAAW,CAAC;AAEhB,eAAe,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/promql/ast.ts"],"sourcesContent":["// Copyright 2024 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/ast.ts\n\nexport enum nodeType {\n aggregation = 'aggregation',\n binaryExpr = 'binaryExpr',\n call = 'call',\n matrixSelector = 'matrixSelector',\n subquery = 'subquery',\n numberLiteral = 'numberLiteral',\n parenExpr = 'parenExpr',\n stringLiteral = 'stringLiteral',\n unaryExpr = 'unaryExpr',\n vectorSelector = 'vectorSelector',\n placeholder = 'placeholder',\n}\n\nexport enum aggregationType {\n sum = 'sum',\n min = 'min',\n max = 'max',\n avg = 'avg',\n stddev = 'stddev',\n stdvar = 'stdvar',\n count = 'count',\n group = 'group',\n countValues = 'count_values',\n bottomk = 'bottomk',\n topk = 'topk',\n quantile = 'quantile',\n limitK = 'limitk',\n limitRatio = 'limit_ratio',\n}\n\nexport enum binaryOperatorType {\n add = '+',\n sub = '-',\n mul = '*',\n div = '/',\n mod = '%',\n pow = '^',\n eql = '==',\n neq = '!=',\n gtr = '>',\n lss = '<',\n gte = '>=',\n lte = '<=',\n and = 'and',\n or = 'or',\n unless = 'unless',\n atan2 = 'atan2',\n}\n\nexport const compOperatorTypes: binaryOperatorType[] = [\n binaryOperatorType.eql,\n binaryOperatorType.neq,\n binaryOperatorType.gtr,\n binaryOperatorType.lss,\n binaryOperatorType.gte,\n binaryOperatorType.lte,\n];\n\nexport const setOperatorTypes: binaryOperatorType[] = [\n binaryOperatorType.and,\n binaryOperatorType.or,\n binaryOperatorType.unless,\n];\n\nexport enum unaryOperatorType {\n plus = '+',\n minus = '-',\n}\n\nexport enum vectorMatchCardinality {\n oneToOne = 'one-to-one',\n manyToOne = 'many-to-one',\n oneToMany = 'one-to-many',\n manyToMany = 'many-to-many',\n}\n\nexport enum valueType {\n // TODO: 'none' should never make it out of Prometheus. Do we need this here?\n none = 'none',\n vector = 'vector',\n scalar = 'scalar',\n matrix = 'matrix',\n string = 'string',\n}\n\nexport enum matchType {\n equal = '=',\n notEqual = '!=',\n matchRegexp = '=~',\n matchNotRegexp = '!~',\n}\n\nexport interface Func {\n name: string;\n argTypes: valueType[];\n variadic: number;\n returnType: valueType;\n}\n\nexport interface LabelMatcher {\n type: matchType;\n name: string;\n value: string;\n}\n\nexport interface VectorMatching {\n card: vectorMatchCardinality;\n labels: string[];\n on: boolean;\n include: string[];\n}\n\nexport type StartOrEnd = 'start' | 'end' | null;\n\n// AST Node Types.\n\nexport interface Aggregation {\n type: nodeType.aggregation;\n expr: ASTNode;\n op: aggregationType;\n param: ASTNode | null;\n grouping: string[];\n without: boolean;\n}\n\nexport interface BinaryExpr {\n type: nodeType.binaryExpr;\n op: binaryOperatorType;\n lhs: ASTNode;\n rhs: ASTNode;\n matching: VectorMatching | null;\n bool: boolean;\n}\n\nexport interface Call {\n type: nodeType.call;\n func: Func;\n args: ASTNode[];\n}\n\nexport interface MatrixSelector {\n type: nodeType.matrixSelector;\n name: string;\n matchers: LabelMatcher[];\n range: number;\n offset: number;\n timestamp: number | null;\n startOrEnd: StartOrEnd;\n}\n\nexport interface Subquery {\n type: nodeType.subquery;\n expr: ASTNode;\n range: number;\n offset: number;\n step: number;\n timestamp: number | null;\n startOrEnd: StartOrEnd;\n}\n\nexport interface NumberLiteral {\n type: nodeType.numberLiteral;\n val: string; // Can't be 'number' because JS doesn't support NaN/Inf/-Inf etc.\n}\n\nexport interface ParenExpr {\n type: nodeType.parenExpr;\n expr: ASTNode;\n}\n\nexport interface StringLiteral {\n type: nodeType.stringLiteral;\n val: string;\n}\n\nexport interface UnaryExpr {\n type: nodeType.unaryExpr;\n op: unaryOperatorType;\n expr: ASTNode;\n}\n\nexport interface VectorSelector {\n type: nodeType.vectorSelector;\n name: string;\n matchers: LabelMatcher[];\n offset: number;\n timestamp: number | null;\n startOrEnd: StartOrEnd;\n}\n\nexport interface Placeholder {\n type: nodeType.placeholder;\n children: ASTNode[];\n}\n\n// NB: AST stands for Abstract Syntax Tree\ntype ASTNode =\n | Aggregation\n | BinaryExpr\n | Call\n | MatrixSelector\n | Subquery\n | NumberLiteral\n | ParenExpr\n | StringLiteral\n | UnaryExpr\n | VectorSelector\n | Placeholder;\n\nexport default ASTNode;\n"],"names":["nodeType","aggregationType","binaryOperatorType","compOperatorTypes","setOperatorTypes","unaryOperatorType","vectorMatchCardinality","valueType","matchType"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,yIAAyI;;UAE7HA;;;;;;;;;;;;GAAAA,aAAAA;;UAcAC;;;;;;;;;;;;;;;GAAAA,oBAAAA;;UAiBAC;;;;;;;;;;;;;;;;;GAAAA,uBAAAA;AAmBZ,OAAO,MAAMC,oBAA0C;;;;;;;CAOtD,CAAC;AAEF,OAAO,MAAMC,mBAAyC;;;;CAIrD,CAAC;;UAEUC;;;GAAAA,sBAAAA;;UAKAC;;;;;GAAAA,2BAAAA;;UAOAC;IACV,6EAA6E;;;;;;GADnEA,cAAAA;;UASAC;;;;;GAAAA,cAAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/components/promql/format.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,OAON,MAAM,OAAO,CAAC;AA6Cf,eAAO,MAAM,aAAa,WAAY,MAAM,EAAE,KAAG,eAAe,EAS/D,CAAC;AAiPF,eAAO,MAAM,UAAU,SAAU,OAAO,gBAAgB,OAAO,aAAa,MAAM,KAAG,kBAEpF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/promql/format.tsx"],"sourcesContent":["// Copyright 2024 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/format.tsx\n\nimport React, { ReactElement, ReactNode } from 'react';\nimport { styled } from '@mui/material';\nimport { formatDuration, msToPrometheusDuration } from '@perses-dev/core';\nimport ASTNode, {\n VectorSelector,\n matchType,\n vectorMatchCardinality,\n nodeType,\n StartOrEnd,\n MatrixSelector,\n} from './ast';\nimport { maybeParenthesizeBinopChild, escapeString } from './utils';\n\n// Styled components that reproduce the theming of CodeMirror:\n\nconst PromQLCode = styled('span')(() => ({\n fontFamily: '\"DejaVu Sans Mono\", monospace',\n}));\n\nconst PromQLKeyword = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#708',\n}));\n\nconst PromQLFunction = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#61afef' : '#2a2e42',\n}));\n\nconst PromQLMetricName = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e06c75' : '#2a2e42',\n}));\n\nconst PromQLLabelName = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#61afef' : '#219',\n}));\n\nconst PromQLString = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#98c379' : '#a31515',\n}));\n\nconst PromQLEllipsis = styled('span')(() => ({\n color: '#aaaaaa', // Same color for both modes as in the original CSS\n}));\n\nconst PromQLDuration = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#09885a',\n}));\n\nconst PromQLNumber = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#164',\n}));\n\nconst PromQLOperator = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#56b6c2' : '#708',\n}));\n\nexport const labelNameList = (labels: string[]): React.ReactNode[] => {\n return labels.map((l, i) => {\n return (\n <span key={i}>\n {i !== 0 && ', '}\n <PromQLLabelName>{l}</PromQLLabelName>\n </span>\n );\n });\n};\n\nconst formatAtAndOffset = (timestamp: number | null, startOrEnd: StartOrEnd, offset: number): ReactNode => (\n <>\n {timestamp !== null ? (\n <>\n {' '}\n <PromQLOperator>@</PromQLOperator> <PromQLNumber>{(timestamp / 1000).toFixed(3)}</PromQLNumber>\n </>\n ) : startOrEnd !== null ? (\n <>\n {' '}\n <PromQLOperator>@</PromQLOperator> <PromQLKeyword>{startOrEnd}</PromQLKeyword>\n <span>(</span>\n <span>)</span>\n </>\n ) : (\n <></>\n )}\n {offset === 0 ? (\n <></>\n ) : offset > 0 ? (\n <>\n {' '}\n <PromQLKeyword>offset</PromQLKeyword>{' '}\n <PromQLDuration>{formatDuration(msToPrometheusDuration(offset))}</PromQLDuration>\n </>\n ) : (\n <>\n {' '}\n <PromQLKeyword>offset</PromQLKeyword>{' '}\n <PromQLDuration>-{formatDuration(msToPrometheusDuration(-offset))}</PromQLDuration>\n </>\n )}\n </>\n);\n\nconst formatSelector = (node: VectorSelector | MatrixSelector): ReactElement => {\n const matchLabels = node.matchers\n .filter((m) => !(m.name === '__name__' && m.type === matchType.equal && m.value === node.name))\n .map((m, i) => (\n <span key={i}>\n {i !== 0 && ','}\n <PromQLLabelName>{m.name}</PromQLLabelName>\n {m.type}\n <PromQLString>"{escapeString(m.value)}"</PromQLString>\n </span>\n ));\n\n return (\n <>\n <PromQLMetricName>{node.name}</PromQLMetricName>\n {matchLabels.length > 0 && (\n <>\n {'{'}\n <span>{matchLabels}</span>\n {'}'}\n </>\n )}\n {node.type === nodeType.matrixSelector && (\n <>\n [<PromQLDuration>{formatDuration(msToPrometheusDuration(node.range))}</PromQLDuration>]\n </>\n )}\n {formatAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}\n </>\n );\n};\n\nconst ellipsis = <PromQLEllipsis>…</PromQLEllipsis>;\n\nconst formatNodeInternal = (node: ASTNode, showChildren: boolean, maxDepth?: number): React.ReactNode => {\n if (maxDepth === 0) {\n return ellipsis;\n }\n\n const childMaxDepth = maxDepth === undefined ? undefined : maxDepth - 1;\n\n switch (node.type) {\n case nodeType.aggregation:\n return (\n <>\n <PromQLOperator>{node.op}</PromQLOperator>\n {node.without ? (\n <>\n {' '}\n <PromQLKeyword>without</PromQLKeyword>\n <span>(</span>\n {labelNameList(node.grouping)}\n <span>)</span>{' '}\n </>\n ) : (\n node.grouping.length > 0 && (\n <>\n {' '}\n <PromQLKeyword>by</PromQLKeyword>\n <span>(</span>\n {labelNameList(node.grouping)}\n <span>)</span>{' '}\n </>\n )\n )}\n {showChildren && (\n <>\n <span>(</span>\n {node.param !== null && <>{formatNode(node.param, showChildren, childMaxDepth)}, </>}\n {formatNode(node.expr, showChildren, childMaxDepth)}\n <span>)</span>\n </>\n )}\n </>\n );\n case nodeType.subquery:\n return (\n <>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}[\n <PromQLDuration>{formatDuration(msToPrometheusDuration(node.range))}</PromQLDuration>:\n {node.step !== 0 && <PromQLDuration>{formatDuration(msToPrometheusDuration(node.step))}</PromQLDuration>}]\n {formatAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}\n </>\n );\n case nodeType.parenExpr:\n return (\n <>\n <span>(</span>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}\n <span>)</span>\n </>\n );\n case nodeType.call: {\n const children =\n childMaxDepth === undefined || childMaxDepth > 0\n ? node.args.map((arg, i) => (\n <span key={i}>\n {i !== 0 && ', '}\n {formatNode(arg, showChildren)}\n </span>\n ))\n : node.args.length > 0\n ? ellipsis\n : '';\n\n return (\n <>\n <PromQLFunction>{node.func.name}</PromQLFunction>\n {showChildren && (\n <>\n <span>(</span>\n {children}\n <span>)</span>\n </>\n )}\n </>\n );\n }\n case nodeType.matrixSelector:\n return formatSelector(node);\n case nodeType.vectorSelector:\n return formatSelector(node);\n case nodeType.numberLiteral:\n return <PromQLNumber>{node.val}</PromQLNumber>;\n case nodeType.stringLiteral:\n return <PromQLString>"{escapeString(node.val)}"</PromQLString>;\n case nodeType.unaryExpr:\n return (\n <>\n <PromQLOperator>{node.op}</PromQLOperator>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}\n </>\n );\n case nodeType.binaryExpr: {\n let matching = <></>;\n let grouping = <></>;\n const vm = node.matching;\n if (vm !== null && (vm.labels.length > 0 || vm.on)) {\n if (vm.on) {\n matching = (\n <>\n {' '}\n <PromQLKeyword>on</PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.labels)}\n <span>)</span>\n </>\n );\n } else {\n matching = (\n <>\n {' '}\n <PromQLKeyword>ignoring</PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.labels)}\n <span>)</span>\n </>\n );\n }\n\n if (vm.card === vectorMatchCardinality.manyToOne || vm.card === vectorMatchCardinality.oneToMany) {\n grouping = (\n <>\n <PromQLKeyword>\n {' '}\n group_\n {vm.card === vectorMatchCardinality.manyToOne ? 'left' : 'right'}\n </PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.include)}\n <span>)</span>\n </>\n );\n }\n }\n\n return (\n <>\n {showChildren && formatNode(maybeParenthesizeBinopChild(node.op, node.lhs), showChildren, childMaxDepth)}{' '}\n {['atan2', 'and', 'or', 'unless'].includes(node.op) ? (\n <PromQLOperator>{node.op}</PromQLOperator>\n ) : (\n <PromQLOperator>{node.op}</PromQLOperator>\n )}\n {node.bool && (\n <>\n {' '}\n <PromQLKeyword>bool</PromQLKeyword>\n </>\n )}\n {matching}\n {grouping}{' '}\n {showChildren && formatNode(maybeParenthesizeBinopChild(node.op, node.rhs), showChildren, childMaxDepth)}\n </>\n );\n }\n case nodeType.placeholder:\n // TODO: Include possible children of placeholders somehow?\n return ellipsis;\n default:\n throw new Error('unsupported node type');\n }\n};\n\nexport const formatNode = (node: ASTNode, showChildren: boolean, maxDepth?: number): React.ReactElement => (\n <PromQLCode>{formatNodeInternal(node, showChildren, maxDepth)}</PromQLCode>\n);\n"],"names":["React","styled","formatDuration","msToPrometheusDuration","matchType","vectorMatchCardinality","nodeType","maybeParenthesizeBinopChild","escapeString","PromQLCode","fontFamily","PromQLKeyword","theme","color","palette","mode","PromQLFunction","PromQLMetricName","PromQLLabelName","PromQLString","PromQLEllipsis","PromQLDuration","PromQLNumber","PromQLOperator","labelNameList","labels","map","l","i","span","formatAtAndOffset","timestamp","startOrEnd","offset","toFixed","formatSelector","node","matchLabels","matchers","filter","m","name","type","equal","value","length","matrixSelector","range","ellipsis","formatNodeInternal","showChildren","maxDepth","childMaxDepth","undefined","aggregation","op","without","grouping","param","formatNode","expr","subquery","step","parenExpr","call","children","args","arg","func","vectorSelector","numberLiteral","val","stringLiteral","unaryExpr","binaryExpr","matching","vm","on","card","manyToOne","oneToMany","include","lhs","includes","bool","rhs","placeholder","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6IAA6I;;AAE7I,OAAOA,WAAwC,QAAQ;AACvD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,mBAAmB;AAC1E,SAEEC,SAAS,EACTC,sBAAsB,EACtBC,QAAQ,QAGH,QAAQ;AACf,SAASC,2BAA2B,EAAEC,YAAY,QAAQ,UAAU;AAEpE,8DAA8D;AAE9D,MAAMC,aAAaR,OAAO,QAAQ,IAAO,CAAA;QACvCS,YAAY;IACd,CAAA;AAEA,MAAMC,gBAAgBV,OAAO,QAAQ,CAAC,EAAEW,KAAK,EAAE,GAAM,CAAA;QACnDC,OAAOD,MAAME,OAAO,CAACC,IAAI,KAAK,SAAS,YAAY;IACrD,CAAA;AAEA,MAAMC,iBAAiBf,OAAO,QAAQ,CAAC,EAAEW,KAAK,EAAE,GAAM,CAAA;QACpDC,OAAOD,MAAME,OAAO,CAACC,IAAI,KAAK,SAAS,YAAY;IACrD,CAAA;AAEA,MAAME,mBAAmBhB,OAAO,QAAQ,CAAC,EAAEW,KAAK,EAAE,GAAM,CAAA;QACtDC,OAAOD,MAAME,OAAO,CAACC,IAAI,KAAK,SAAS,YAAY;IACrD,CAAA;AAEA,MAAMG,kBAAkBjB,OAAO,QAAQ,CAAC,EAAEW,KAAK,EAAE,GAAM,CAAA;QACrD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3,"sources":["../../../src/components/promql/utils.ts"],"sourcesContent":["// Copyright 2024 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/utils.ts\n\nimport ASTNode, { binaryOperatorType, nodeType } from './ast';\n\nconst binOpPrecedence = {\n [binaryOperatorType.add]: 3,\n [binaryOperatorType.sub]: 3,\n [binaryOperatorType.mul]: 2,\n [binaryOperatorType.div]: 2,\n [binaryOperatorType.mod]: 2,\n [binaryOperatorType.pow]: 1,\n [binaryOperatorType.eql]: 4,\n [binaryOperatorType.neq]: 4,\n [binaryOperatorType.gtr]: 4,\n [binaryOperatorType.lss]: 4,\n [binaryOperatorType.gte]: 4,\n [binaryOperatorType.lte]: 4,\n [binaryOperatorType.and]: 5,\n [binaryOperatorType.or]: 6,\n [binaryOperatorType.unless]: 5,\n [binaryOperatorType.atan2]: 2,\n};\n\nexport const maybeParenthesizeBinopChild = (op: binaryOperatorType, child: ASTNode): ASTNode => {\n if (child.type !== nodeType.binaryExpr) {\n return child;\n }\n\n if (binOpPrecedence[op] > binOpPrecedence[child.op]) {\n return child;\n }\n\n // TODO: Parens aren't necessary for left-associativity within same precedence,\n // or right-associativity between two power operators.\n return {\n type: nodeType.parenExpr,\n expr: child,\n };\n};\n\nexport const getNodeChildren = (node: ASTNode): ASTNode[] => {\n switch (node.type) {\n case nodeType.aggregation:\n return node.param === null ? [node.expr] : [node.param, node.expr];\n case nodeType.subquery:\n return [node.expr];\n case nodeType.parenExpr:\n return [node.expr];\n case nodeType.call:\n return node.args;\n case nodeType.matrixSelector:\n case nodeType.vectorSelector:\n case nodeType.numberLiteral:\n case nodeType.stringLiteral:\n return [];\n case nodeType.placeholder:\n return node.children;\n case nodeType.unaryExpr:\n return [node.expr];\n case nodeType.binaryExpr:\n return [node.lhs, node.rhs];\n default:\n throw new Error('unsupported node type');\n }\n};\n\nexport const escapeString = (str: string): string => {\n return str.replace(/([\\\\\"])/g, '\\\\$1');\n};\n"],"names":["binaryOperatorType","nodeType","binOpPrecedence","add","sub","mul","div","mod","pow","eql","neq","gtr","lss","gte","lte","and","or","unless","atan2","maybeParenthesizeBinopChild","op","child","type","binaryExpr","parenExpr","expr","getNodeChildren","node","aggregation","param","subquery","call","args","matrixSelector","vectorSelector","numberLiteral","stringLiteral","placeholder","children","unaryExpr","lhs","rhs","Error","escapeString","str","replace"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,2IAA2I;AAE3I,SAAkBA,kBAAkB,EAAEC,QAAQ,QAAQ,QAAQ;AAE9D,MAAMC,kBAAkB;IACtB,CAACF,mBAAmBG,GAAG,CAAC,EAAE;IAC1B,CAACH,mBAAmBI,GAAG,CAAC,EAAE;IAC1B,CAACJ,mBAAmBK,GAAG,CAAC,EAAE;IAC1B,CAACL,mBAAmBM,GAAG,CAAC,EAAE;IAC1B,CAACN,mBAAmBO,GAAG,CAAC,EAAE;IAC1B,CAACP,mBAAmBQ,GAAG,CAAC,EAAE;IAC1B,CAACR,mBAAmBS,GAAG,CAAC,EAAE;IAC1B,CAACT,mBAAmBU,GAAG,CAAC,EAAE;IAC1B,CAACV,mBAAmBW,GAAG,CAAC,EAAE;IAC1B,CAACX,mBAAmBY,GAAG,CAAC,EAAE;IAC1B,CAACZ,mBAAmBa,GAAG,CAAC,EAAE;IA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a,GAAG;gBAAEb,KAAKc,GAAG;aAAC;QAC7B;YACE,MAAM,IAAIC,MAAM;IACpB;AACF,EAAE;AAEF,OAAO,MAAMC,eAAe,CAACC;IAC3B,OAAOA,IAAIC,OAAO,CAAC,YAAY;AACjC,EAAE"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';
|
|
2
|
-
import { StaticListVariable } from './plugins/variable';
|
|
3
|
-
import { PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable } from './plugins/prometheus-variables';
|
|
4
|
-
import { PrometheusDatasource } from './plugins/prometheus-datasource';
|
|
5
|
-
export { PrometheusTimeSeriesQuery, StaticListVariable, PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable, PrometheusDatasource, };
|
|
6
|
-
export * from './model';
|
|
7
|
-
export * from './plugins/types';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,GACrB,CAAC;AAGF,cAAc,SAAS,CAAC;AAExB,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';
|
|
14
|
-
// @TODO: Move this to a more generic location;
|
|
15
|
-
import { StaticListVariable } from './plugins/variable';
|
|
16
|
-
import { PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable } from './plugins/prometheus-variables';
|
|
17
|
-
import { PrometheusDatasource } from './plugins/prometheus-datasource';
|
|
18
|
-
// Export plugins under the same name as the kinds they handle from the plugin.json
|
|
19
|
-
export { PrometheusTimeSeriesQuery, StaticListVariable, PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable, PrometheusDatasource };
|
|
20
|
-
// For consumers to leverage in DatasourceStoreProvider onCreate
|
|
21
|
-
export * from './model';
|
|
22
|
-
export * from './plugins/types';
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 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 { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';\n// @TODO: Move this to a more generic location;\nimport { StaticListVariable } from './plugins/variable';\nimport {\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n} from './plugins/prometheus-variables';\nimport { PrometheusDatasource } from './plugins/prometheus-datasource';\n\n// Export plugins under the same name as the kinds they handle from the plugin.json\nexport {\n PrometheusTimeSeriesQuery,\n StaticListVariable,\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n PrometheusDatasource,\n};\n\n// For consumers to leverage in DatasourceStoreProvider onCreate\nexport * from './model';\n\nexport * from './plugins/types';\n"],"names":["PrometheusTimeSeriesQuery","StaticListVariable","PrometheusLabelNamesVariable","PrometheusLabelValuesVariable","PrometheusPromQLVariable","PrometheusDatasource"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,yBAAyB,QAAQ,yCAAyC;AACnF,+CAA+C;AAC/C,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SACEC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,QACnB,iCAAiC;AACxC,SAASC,oBAAoB,QAAQ,kCAAkC;AAEvE,mFAAmF;AACnF,SACEL,yBAAyB,EACzBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,EACxBC,oBAAoB,GACpB;AAEF,gEAAgE;AAChE,cAAc,UAAU;AAExB,cAAc,kBAAkB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/model/api-types.ts"],"names":[],"mappings":"AAaA,O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C;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;AAGnF,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/api-types.ts"],"sourcesContent":["// Copyright 2023 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 { DurationString } from '@perses-dev/core';\nimport ASTNode from '../components/promql/ast';\n\n// Just reuse dashboard model's type and re-export\nexport type { DurationString };\n\nexport interface SuccessResponse<T> {\n status: 'success';\n data: T;\n rawResponse?: Response;\n warnings?: string[];\n}\n\nexport interface ErrorResponse<T> {\n status: 'error';\n data?: T;\n errorType: string;\n error: string;\n}\n\nexport type ApiResponse<T> = SuccessResponse<T> | ErrorResponse<T>;\n\nexport type DurationSeconds = number;\n\nexport type UnixTimestampSeconds = number;\n\nexport type ValueTuple = [unixTimeSeconds: UnixTimestampSeconds, sampleValue: string];\n\nexport type Metric = Record<string, string>;\n\nexport interface VectorData {\n resultType: 'vector';\n result: Array<{\n metric: Metric;\n value: ValueTuple;\n }>;\n}\n\nexport interface MatrixData {\n resultType: 'matrix';\n result: Array<{\n metric: Metric;\n values: ValueTuple[];\n }>;\n}\n\nexport interface ScalarData {\n resultType: 'scalar';\n result: ValueTuple;\n}\n\nexport interface InstantQueryRequestParameters {\n query: string;\n time?: UnixTimestampSeconds;\n timeout?: DurationString;\n}\n\nexport type InstantQueryResponse = ApiResponse<MatrixData | VectorData | ScalarData>;\n\nexport interface RangeQueryRequestParameters {\n query: string;\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n step: DurationSeconds;\n timeout?: DurationString;\n}\n\nexport type RangeQueryResponse = ApiResponse<MatrixData>;\n\nexport interface SeriesRequestParameters {\n 'match[]': string[];\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n limit?: number;\n}\n\nexport type SeriesResponse = ApiResponse<Metric[]>;\n\nexport interface LabelNamesRequestParameters {\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n limit?: number;\n}\n\nexport type LabelNamesResponse = ApiResponse<string[]>;\n\nexport interface LabelValuesRequestParameters {\n labelName: string;\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n limit?: number;\n}\n\nexport type LabelValuesResponse = ApiResponse<string[]>;\n\nexport interface MetricMetadata {\n type: string;\n help: string;\n unit?: string;\n}\n\nexport interface MetricMetadataRequestParameters {\n limit?: number;\n metric?: string;\n}\n\nexport type MetricMetadataResponse = ApiResponse<Record<string, MetricMetadata[]>>;\n\n// ref: https://prometheus.io/docs/prometheus/3.0/querying/api/#parsing-a-promql-expressions-into-a-abstract-syntax-tree-ast\nexport interface ParseQueryRequestParameters {\n query: string;\n}\n\nexport type ParseQueryResponse = ApiResponse<ASTNode>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqHjC,WAAsD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC"}
|
package/dist/model/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './api-types';\nexport * from './parse-sample-values';\nexport * from './prometheus-client';\nexport * from './prometheus-selectors';\nexport * from './time';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc;AAC5B,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sample-values.d.ts","sourceRoot":"","sources":["../../src/model/parse-sample-values.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAKlE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAenE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/parse-sample-values.ts"],"sourcesContent":["// Copyright 2023 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 { ValueTuple } from './api-types';\n\n/**\n * ValueTuple from the Prom server, parsed into ms and floating point number\n */\nexport type ParsedValueTuple = [unixTimeMs: number, value: number];\n\n/**\n * Parse a ValueTuple from a PromServer response into the a millisecond-based\n * unix time and a numeric sample value.\n */\nexport function parseValueTuple(data: ValueTuple): ParsedValueTuple {\n const [unixTimeSeconds, sampleValue] = data;\n\n // Prom returns unix time in seconds, so convert to ms\n return [unixTimeSeconds * 1000, parseSampleValue(sampleValue)];\n}\n\n/**\n * Parses a string sample value from Prometheus, usually included as the\n * second member of a ValueTuple.\n */\nexport function parseSampleValue(sampleValue: ValueTuple[1]): number {\n // Account for Prometheus' representation of +/- infinity, otherwise just\n // parse the sample value as a float\n let value: number;\n switch (sampleValue) {\n case '+Inf':\n value = Number.POSITIVE_INFINITY;\n break;\n case '-Inf':\n value = Number.NEGATIVE_INFINITY;\n break;\n default:\n value = parseFloat(sampleValue);\n }\n return value;\n}\n"],"names":["parseValueTuple","data","unixTimeSeconds","sampleValue","parseSampleValue","value","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","parseFloat"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,IAAgB;IAC9C,MAAM,CAACC,iBAAiBC,YAAY,GAAGF;IAEvC,sDAAsD;IACtD,OAAO;QAACC,kBAAkB;QAAME,iBAAiBD;KAAa;AAChE;AAEA;;;CAGC,GACD,OAAO,SAASC,iBAAiBD,WAA0B;IACzD,yEAAyE;IACzE,oCAAoC;IACpC,IAAIE;IACJ,OAAQF;QACN,KAAK;YACHE,QAAQC,OAAOC,iBAAiB;YAChC;QACF,KAAK;YACHF,QAAQC,OAAOE,iBAAiB;YAChC;QACF;YACEH,QAAQI,WAAWN;IACvB;IACA,OAAOE;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EAEf,MAAM,aAAa,CAAC;AAErB,UAAU,uBAAuB;IAC/B,aAAa,EAAE,MAAM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EAAE,2BAA2B,EACnC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAE7B;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,2BAA2B,EACnC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAE7B;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,4BAA4B,EACpC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAa9B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,+BAA+B,EACvC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,sBAAsB,CAAC,CAGjC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAG3G;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,2BAA2B,EACnC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAG7B;AAuED;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAI1F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/prometheus-client.ts"],"sourcesContent":["// Copyright 2023 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 { fetch, fetchJson, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n InstantQueryRequestParameters,\n InstantQueryResponse,\n LabelNamesRequestParameters,\n LabelNamesResponse,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n MetricMetadataRequestParameters,\n MetricMetadataResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n RangeQueryRequestParameters,\n RangeQueryResponse,\n SeriesRequestParameters,\n SeriesResponse,\n SuccessResponse,\n} from './api-types';\n\ninterface PrometheusClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface PrometheusClient extends DatasourceClient {\n options: PrometheusClientOptions;\n instantQuery(params: InstantQueryRequestParameters, headers?: RequestHeaders): Promise<InstantQueryResponse>;\n rangeQuery(params: RangeQueryRequestParameters, headers?: RequestHeaders): Promise<RangeQueryResponse>;\n labelNames(params: LabelNamesRequestParameters, headers?: RequestHeaders): Promise<LabelNamesResponse>;\n labelValues(params: LabelValuesRequestParameters, headers?: RequestHeaders): Promise<LabelValuesResponse>;\n metricMetadata(params: MetricMetadataRequestParameters, headers?: RequestHeaders): Promise<MetricMetadataResponse>;\n series(params: SeriesRequestParameters, headers?: RequestHeaders): Promise<SeriesResponse>;\n parseQuery(params: ParseQueryRequestParameters, headers?: RequestHeaders): Promise<ParseQueryResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\n/**\n * Calls the `/-/healthy` endpoint to check if the datasource is healthy.\n */\nexport function healthCheck(queryOptions: QueryOptions) {\n return async (): Promise<boolean> => {\n const url = `${queryOptions.datasourceUrl}/-/healthy`;\n\n try {\n const resp = await fetch(url, { headers: queryOptions.headers });\n return resp.status === 200;\n } catch {\n return false;\n }\n };\n}\n\n/**\n * Calls the `/api/v1/query` endpoint to get metrics data.\n */\nexport function instantQuery(\n params: InstantQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<InstantQueryResponse> {\n return fetchWithPost<InstantQueryRequestParameters, InstantQueryResponse>('/api/v1/query', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/query_range` endpoint to get metrics data.\n */\nexport function rangeQuery(\n params: RangeQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<RangeQueryResponse> {\n return fetchWithPost<RangeQueryRequestParameters, RangeQueryResponse>('/api/v1/query_range', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/labels` endpoint to get a list of label names.\n */\nexport function labelNames(\n params: LabelNamesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelNamesResponse> {\n return fetchWithPost<LabelNamesRequestParameters, LabelNamesResponse>('/api/v1/labels', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function labelValues(\n params: LabelValuesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelValuesResponse> {\n const { labelName, ...searchParams } = params;\n\n // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.\n // Note that an empty list is the prometheus result if the label does not exist.\n if (labelName.length === 0) {\n return new Promise((resolve) => {\n resolve({ data: [] as string[] } as SuccessResponse<string[]>);\n });\n }\n\n const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;\n return fetchWithGet<typeof searchParams, LabelValuesResponse>(apiURI, searchParams, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function metricMetadata(\n params: MetricMetadataRequestParameters,\n queryOptions: QueryOptions\n): Promise<MetricMetadataResponse> {\n const apiURI = `/api/v1/metadata`;\n return fetchWithGet<MetricMetadataRequestParameters, MetricMetadataResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/series` endpoint to finding series by label matchers.\n */\nexport function series(params: SeriesRequestParameters, queryOptions: QueryOptions): Promise<SeriesResponse> {\n const apiURI = `/api/v1/series`;\n return fetchWithPost<SeriesRequestParameters, SeriesResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/parse_query` to parse the given promQL expresion into an abstract syntax tree (AST).\n */\nexport function parseQuery(\n params: ParseQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<ParseQueryResponse> {\n const apiURI = `/api/v1/parse_query`;\n return fetchWithPost<ParseQueryRequestParameters, ParseQueryResponse>(apiURI, params, queryOptions);\n}\n\nfunction fetchWithGet<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = createSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n return fetchJson<TResponse>(url, { method: 'GET', headers });\n}\n\nfunction fetchWithPost<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers } = queryOptions;\n\n const url = `${datasourceUrl}${apiURI}`;\n const init = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...headers,\n },\n body: createSearchParams(params),\n };\n return fetchResults<TResponse>(url, init);\n}\n\n// Request parameter values we know how to serialize\ntype ParamValue = string | string[] | number | undefined;\n\n// Used to constrain the types that can be passed to createSearchParams to\n// just the ones we know how to serialize\ntype RequestParams<T> = {\n [K in keyof T]: ParamValue;\n};\n\n/**\n * Creates URLSearchParams from a request params object.\n */\nfunction createSearchParams<T extends RequestParams<T>>(params: T): URLSearchParams {\n const searchParams = new URLSearchParams();\n for (const key in params) {\n const value: ParamValue = params[key];\n if (value === undefined) continue;\n\n if (typeof value === 'string') {\n searchParams.append(key, value);\n continue;\n }\n\n if (typeof value === 'number') {\n searchParams.append(key, value.toString());\n continue;\n }\n\n for (const val of value) {\n searchParams.append(key, val);\n }\n }\n return searchParams;\n}\n\n/**\n * Fetch JSON and parse warnings for query inspector\n */\nexport async function fetchResults<T>(...args: Parameters<typeof global.fetch>): Promise<T> {\n const response = await fetch(...args);\n const json: T = await response.json();\n return { ...json, rawResponse: response };\n}\n"],"names":["fetch","fetchJson","healthCheck","queryOptions","url","datasourceUrl","resp","headers","status","instantQuery","params","fetchWithPost","rangeQuery","labelNames","labelValues","labelName","searchParams","length","Promise","resolve","data","apiURI","encodeURIComponent","fetchWithGet","metricMetadata","series","parseQuery","urlParams","createSearchParams","toString","method","init","body","fetchResults","URLSearchParams","key","value","undefined","append","val","args","response","json","rawResponse"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,SAAS,QAAwB,mBAAmB;AAyCpE;;CAEC,GACD,OAAO,SAASC,YAAYC,YAA0B;IACpD,OAAO;QACL,MAAMC,MAAM,CAAC,EAAED,aAAaE,aAAa,CAAC,UAAU,CAAC;QAErD,IAAI;YACF,MAAMC,OAAO,MAAMN,MAAMI,KAAK;gBAAEG,SAASJ,aAAaI,OAAO;YAAC;YAC9D,OAAOD,KAAKE,MAAM,KAAK;QACzB,EAAE,UAAM;YACN,OAAO;QACT;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASC,aACdC,MAAqC,EACrCP,YAA0B;IAE1B,OAAOQ,cAAmE,iBAAiBD,QAAQP;AACrG;AAEA;;CAEC,GACD,OAAO,SAASS,WACdF,MAAmC,EACnCP,YAA0B;IAE1B,OAAOQ,cAA+D,uBAAuBD,QAAQP;AACvG;AAEA;;CAEC,GACD,OAAO,SAASU,WACdH,MAAmC,EACnCP,YAA0B;IAE1B,OAAOQ,cAA+D,kBAAkBD,QAAQP;AAClG;AAEA;;CAEC,GACD,OAAO,SAASW,YACdJ,MAAoC,EACpCP,YAA0B;IAE1B,MAAM,EAAEY,SAAS,EAAE,GAAGC,cAAc,GAAGN;IAEvC,oHAAoH;IACpH,gFAAgF;IAChF,IAA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;YAChB,GAAGA,OAAO;QACZ;QACAyB,MAAMJ,mBAAmBlB;IAC3B;IACA,OAAOuB,aAAwB7B,KAAK2B;AACtC;AAWA;;CAEC,GACD,SAASH,mBAA+ClB,MAAS;IAC/D,MAAMM,eAAe,IAAIkB;IACzB,IAAK,MAAMC,OAAOzB,OAAQ;QACxB,MAAM0B,QAAoB1B,MAAM,CAACyB,IAAI;QACrC,IAAIC,UAAUC,WAAW;QAEzB,IAAI,OAAOD,UAAU,UAAU;YAC7BpB,aAAasB,MAAM,CAACH,KAAKC;YACzB;QACF;QAEA,IAAI,OAAOA,UAAU,UAAU;YAC7BpB,aAAasB,MAAM,CAACH,KAAKC,MAAMP,QAAQ;YACvC;QACF;QAEA,KAAK,MAAMU,OAAOH,MAAO;YACvBpB,aAAasB,MAAM,CAACH,KAAKI;QAC3B;IACF;IACA,OAAOvB;AACT;AAEA;;CAEC,GACD,OAAO,eAAeiB,aAAgB,GAAGO,IAAqC;IAC5E,MAAMC,WAAW,MAAMzC,SAASwC;IAChC,MAAME,OAAU,MAAMD,SAASC,IAAI;IACnC,OAAO;QAAE,GAAGA,IAAI;QAAEC,aAAaF;IAAS;AAC1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-selectors.d.ts","sourceRoot":"","sources":["../../src/model/prometheus-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,oBAAoB,wBAAkC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,IAAI,EAAE,OAAO,oBAAoB,CAAC;CACnC;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,4BAA6D,CAAC;AAEzF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,4BAA4B,GAAG,OAAO,CAErF;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,IAAI,4BAA4B,CAErH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided PrometheusDatasourceSelector is the default one.\n */\nexport function isDefaultPromSelector(selector: PrometheusDatasourceSelector): boolean {\n return selector.name === undefined;\n}\n\n/**\n * Type guard to make sure a DatasourceSelector is a Prometheus one.\n */\nexport function isPrometheusDatasourceSelector(selector: DatasourceSelector): selector is PrometheusDatasourceSelector {\n return selector.kind === PROM_DATASOURCE_KIND;\n}\n"],"names":["PROM_DATASOURCE_KIND","DEFAULT_PROM","kind","isDefaultPromSelector","selector","name","undefined","isPrometheusDatasourceSelector"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,uBAAuB,uBAAgC;AASpE;;CAEC,GACD,OAAO,MAAMC,eAA6C;IAAEC,MAAMF;AAAqB,EAAE;AAEzF;;CAEC,GACD,OAAO,SAASG,sBAAsBC,QAAsC;IAC1E,OAAOA,SAASC,IAAI,KAAKC;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASC,+BAA+BH,QAA4B;IACzE,OAAOA,SAASF,IAAI,KAAKF;AAC3B"}
|
package/dist/model/time.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,GAAG,EAAE,oBAAoB,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAMnG;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,mBAAmB,EAC9B,cAAc,SAAK,EACnB,UAAU,SAAI,EACd,eAAe,SAAI,GAClB,MAAM,CAUR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAM5F"}
|
package/dist/model/time.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/time.ts"],"sourcesContent":["// Copyright 2023 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, DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds, getUnixTime } from 'date-fns';\nimport { UnixTimestampSeconds } from './api-types';\n\nexport interface PrometheusTimeRange {\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n}\n\n/**\n * Converts an AbsoluteTimeRange to Prometheus time in Unix time (i.e. in seconds).\n */\nexport function getPrometheusTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\n// Max data points to allow returning from a Prom Query, used to calculate a\n// \"safe\" step for a range query\nconst MAX_PROM_DATA_POINTS = 10000;\n\n/**\n * Gets the step to use for a Prom range query. Tries to take into account a suggested step size (probably based on the\n * width of a visualization where the data will be graphed), any minimum step/resolution set by the user, and a \"safe\"\n * step based on the max data points we want to allow returning from a Prom query.\n */\nexport function getRangeStep(\n timeRange: PrometheusTimeRange,\n minStepSeconds = 15,\n resolution = 1,\n suggestedStepMs = 0\n): number {\n const suggestedStepSeconds = suggestedStepMs / 1000;\n const queryRangeSeconds = timeRange.end - timeRange.start;\n\n let safeStep = queryRangeSeconds / MAX_PROM_DATA_POINTS;\n if (safeStep > 1) {\n safeStep = Math.ceil(safeStep);\n }\n\n return Math.max(suggestedStepSeconds * resolution, minStepSeconds, safeStep);\n}\n\n/**\n * Converts a DurationString to seconds, rounding down.\n */\nexport function getDurationStringSeconds(durationString?: DurationString): number | undefined {\n if (!durationString) return undefined;\n\n const duration = parseDurationString(durationString);\n const ms = milliseconds(duration);\n return Math.floor(ms / 1000);\n}\n"],"names":["parseDurationString","milliseconds","getUnixTime","getPrometheusTimeRange","timeRange","start","end","Math","ceil","MAX_PROM_DATA_POINTS","getRangeStep","minStepSeconds","resolution","suggestedStepMs","suggestedStepSeconds","queryRangeSeconds","safeStep","max","getDurationStringSeconds","durationString","undefined","duration","ms","floor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA4CA,mBAAmB,QAAQ,mBAAmB;AAC1F,SAASC,YAAY,EAAEC,WAAW,QAAQ,WAAW;AAQrD;;CAEC,GACD,OAAO,SAASC,uBAAuBC,SAA4B;IACjE,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACN,YAAYG;QAC7BC,KAAKC,KAAKC,IAAI,CAACN,YAAYI;IAC7B;AACF;AAEA,4EAA4E;AAC5E,gCAAgC;AAChC,MAAMG,uBAAuB;AAE7B;;;;CAIC,GACD,OAAO,SAASC,aACdN,SAA8B,EAC9BO,iBAAiB,EAAE,EACnBC,aAAa,CAAC,EACdC,kBAAkB,CAAC;IAEnB,MAAMC,uBAAuBD,kBAAkB;IAC/C,MAAME,oBAAoBX,UAAUE,GAAG,GAAGF,UAAUC,KAAK;IAEzD,IAAIW,WAAWD,oBAAoBN;IACnC,IAAIO,WAAW,GAAG;QAChBA,WAAWT,KAAKC,IAAI,CAACQ;IACvB;IAEA,OAAOT,KAAKU,GAAG,CAACH,uBAAuBF,YAAYD,gBAAgBK;AACrE;AAEA;;CAEC,GACD,OAAO,SAASE,yBAAyBC,cAA+B;IACtE,IAAI,CAACA,gBAAgB,OAAOC;IAE5B,MAAMC,WAAWrB,oBAAoBmB;IACrC,MAAMG,KAAKrB,aAAaoB;IACxB,OAAOd,KAAKgB,KAAK,CAACD,KAAK;AACzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MatcherEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/MatcherEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,kBAAkB,GAAG,YAAY,CAkDlG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 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 { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { ReactElement } from 'react';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n isReadonly?: boolean;\n};\n\nexport function MatcherEditor({ matchers, onChange, isReadonly }: MatcherEditorProps): ReactElement {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n InputProps={{\n readOnly: isReadonly,\n }}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","isReadonly","spacing","mb","map","matcher","index","display","fullWidth","label","value","InputProps","readOnly","e","newMatchers","draft","target","onClick","splice","disabled","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAC1E,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,eAAe,2BAA2B;AASjD,OAAO,SAASC,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,EAAsB;IAClF,qBACE,MAACV;QAAMW,SAAS;QAAGC,IAAI;;YACpBJ,SAASK,GAAG,CAAC,CAACC,SAASC,sBACtB,MAACZ;oBAAgBa,SAAQ;;sCACvB,KAACf;4BACCgB,SAAS;4BACTC,OAAM;4BACNC,OAAOL;4BACPM,YAAY;gCACVC,UAAUX;4BACZ;4BACAD,UAAU,CAACa;gCACT,MAAMC,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,KAAK,CAACT,MAAM,GAAGO,EAAEG,MAAM,CAACN,KAAK;gCAC/B;gCACAV,SAASc;4BACX;;sCAEF,KAACnB;4BACCsB,SAAS;gCACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,MAAMG,MAAM,CAACZ,OAAO;gCACtB;gCACAN,SAASc;4BACX;4BACAK,UAAUlB;sCAEV,cAAA,KAACJ;;;mBAxBKS;0BA4BZ,KAACZ;0BACC,cAAA,KAACD;oBACCe,WAAW;oBACXY,OAAM;oBACNC,SAAQ;oBACRJ,SAAS;wBACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;4BACrCA,MAAMO,IAAI,CAAC;wBACb;wBACAtB,SAASc;oBACX;oBACAK,UAAUlB;8BACX;;;;;AAMT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAY,YAAY,EAAY,MAAM,OAAO,CAAC;AAKhE,OAAO,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,YAAY,CAkf/F"}
|