@perses-dev/prometheus-plugin 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/cjs/components/PromQL.js +10 -8
  2. package/dist/cjs/components/index.js +10 -8
  3. package/dist/cjs/index.js +33 -19
  4. package/dist/cjs/model/index.js +14 -13
  5. package/dist/cjs/model/parse-sample-values.js +6 -2
  6. package/dist/cjs/model/prometheus-client.js +43 -8
  7. package/dist/cjs/model/prometheus-selectors.js +12 -4
  8. package/dist/cjs/model/time.js +15 -9
  9. package/dist/cjs/plugins/MatcherEditor.js +14 -12
  10. package/dist/cjs/plugins/PrometheusDatasourceEditor.js +610 -0
  11. package/dist/cjs/plugins/prometheus-datasource.js +59 -8
  12. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
  13. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +49 -24
  14. package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +44 -24
  15. package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
  16. package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +44 -11
  17. package/dist/cjs/plugins/prometheus-variables.js +69 -63
  18. package/dist/cjs/plugins/types.js +7 -0
  19. package/dist/cjs/plugins/variable.js +9 -7
  20. package/dist/cjs/utils/index.js +10 -8
  21. package/dist/cjs/utils/utils.js +13 -7
  22. package/dist/components/PromQL.d.ts +2 -3
  23. package/dist/components/PromQL.d.ts.map +1 -1
  24. package/dist/components/PromQL.js +1 -1
  25. package/dist/components/PromQL.js.map +1 -1
  26. package/dist/components/index.js.map +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/model/api-types.d.ts +11 -11
  29. package/dist/model/api-types.d.ts.map +1 -1
  30. package/dist/model/api-types.js.map +1 -1
  31. package/dist/model/index.d.ts +0 -1
  32. package/dist/model/index.d.ts.map +1 -1
  33. package/dist/model/index.js +0 -1
  34. package/dist/model/index.js.map +1 -1
  35. package/dist/model/parse-sample-values.d.ts +1 -1
  36. package/dist/model/parse-sample-values.d.ts.map +1 -1
  37. package/dist/model/parse-sample-values.js.map +1 -1
  38. package/dist/model/prometheus-client.d.ts +4 -0
  39. package/dist/model/prometheus-client.d.ts.map +1 -1
  40. package/dist/model/prometheus-client.js +27 -3
  41. package/dist/model/prometheus-client.js.map +1 -1
  42. package/dist/model/prometheus-selectors.js.map +1 -1
  43. package/dist/model/time.js +2 -2
  44. package/dist/model/time.js.map +1 -1
  45. package/dist/plugins/MatcherEditor.d.ts +2 -3
  46. package/dist/plugins/MatcherEditor.d.ts.map +1 -1
  47. package/dist/plugins/MatcherEditor.js +1 -1
  48. package/dist/plugins/MatcherEditor.js.map +1 -1
  49. package/dist/plugins/{PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts → PrometheusDatasourceEditor.d.ts} +1 -2
  50. package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
  51. package/dist/plugins/PrometheusDatasourceEditor.js +556 -0
  52. package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
  53. package/dist/plugins/prometheus-datasource.d.ts +2 -7
  54. package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
  55. package/dist/plugins/prometheus-datasource.js +55 -6
  56. package/dist/plugins/prometheus-datasource.js.map +1 -1
  57. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  58. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
  59. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts +1 -2
  60. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  61. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +41 -18
  62. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  63. package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  64. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +37 -19
  65. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  66. package/dist/plugins/prometheus-time-series-query/index.js.map +1 -1
  67. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +11 -2
  68. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
  69. package/dist/plugins/prometheus-time-series-query/query-editor-model.js +38 -10
  70. package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
  71. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +4 -4
  72. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
  73. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js +3 -1
  74. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
  75. package/dist/plugins/prometheus-variables.d.ts.map +1 -1
  76. package/dist/plugins/prometheus-variables.js +37 -37
  77. package/dist/plugins/prometheus-variables.js.map +1 -1
  78. package/dist/plugins/types.d.ts +12 -5
  79. package/dist/plugins/types.d.ts.map +1 -1
  80. package/dist/plugins/types.js +1 -1
  81. package/dist/plugins/types.js.map +1 -1
  82. package/dist/plugins/variable.d.ts +2 -2
  83. package/dist/plugins/variable.d.ts.map +1 -1
  84. package/dist/plugins/variable.js +2 -2
  85. package/dist/plugins/variable.js.map +1 -1
  86. package/dist/test/setup-tests.js.map +1 -1
  87. package/dist/utils/index.js.map +1 -1
  88. package/dist/utils/utils.d.ts +2 -2
  89. package/dist/utils/utils.d.ts.map +1 -1
  90. package/dist/utils/utils.js +4 -4
  91. package/dist/utils/utils.js.map +1 -1
  92. package/package.json +6 -6
  93. package/dist/cjs/model/templating.js +0 -26
  94. package/dist/cjs/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +0 -392
  95. package/dist/cjs/plugins/PrometheusDatasourceEditor/index.js +0 -29
  96. package/dist/cjs/plugins/PrometheusDatasourceEditor/types.js +0 -16
  97. package/dist/model/templating.d.ts +0 -6
  98. package/dist/model/templating.d.ts.map +0 -1
  99. package/dist/model/templating.js +0 -20
  100. package/dist/model/templating.js.map +0 -1
  101. package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts.map +0 -1
  102. package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +0 -342
  103. package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js.map +0 -1
  104. package/dist/plugins/PrometheusDatasourceEditor/index.d.ts +0 -3
  105. package/dist/plugins/PrometheusDatasourceEditor/index.d.ts.map +0 -1
  106. package/dist/plugins/PrometheusDatasourceEditor/index.js +0 -16
  107. package/dist/plugins/PrometheusDatasourceEditor/index.js.map +0 -1
  108. package/dist/plugins/PrometheusDatasourceEditor/types.d.ts +0 -20
  109. package/dist/plugins/PrometheusDatasourceEditor/types.d.ts.map +0 -1
  110. package/dist/plugins/PrometheusDatasourceEditor/types.js +0 -15
  111. package/dist/plugins/PrometheusDatasourceEditor/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/setup-tests.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 '@testing-library/jest-dom/extend-expect';\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,OAAO,yCAAyC,CAAC"}
1
+ {"version":3,"sources":["../../src/test/setup-tests.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 '@testing-library/jest-dom/extend-expect';\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,OAAO,0CAA0C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/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 './utils';\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,SAAS,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/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 './utils';\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,UAAU"}
@@ -1,8 +1,8 @@
1
1
  import { Metric } from '../model/api-types';
2
2
  /**
3
- * Types for metric labels, used in series_name_format implementation
3
+ * Types for metric labels, used in seriesNameFormat implementation
4
4
  */
5
- export declare type SeriesLabels = Record<string, string>;
5
+ export type SeriesLabels = Record<string, string>;
6
6
  export declare function formatSeriesName(inputFormat: string, seriesLabels: SeriesLabels): string;
7
7
  export declare function getUniqueKeyForPrometheusResult(metricLabels: {
8
8
  [key: string]: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AACH,oBAAY,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAOlD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,CAMxF;AAyBD,wBAAgB,+BAA+B,CAC7C,YAAY,EAAE;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,EACD,EAAE,cAAc,EAAE,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,UAqBtD;AAKD,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;;;EAYjG"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAOlD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,CAMxF;AAyBD,wBAAgB,+BAA+B,CAC7C,YAAY,EAAE;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,EACD,EAAE,cAAc,EAAE,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,UAqBtD;AAKD,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;;;EAYjG"}
@@ -18,8 +18,8 @@ import { isEmptyObject } from '@perses-dev/core';
18
18
  */ export function formatSeriesName(inputFormat, seriesLabels) {
19
19
  const resolveLabelsRegex = /\{\{\s*(.+?)\s*\}\}/g;
20
20
  return inputFormat.replace(resolveLabelsRegex, (_match, token)=>{
21
- var _token;
22
- const resolvedValue = (_token = seriesLabels[token]) !== null && _token !== void 0 ? _token : '';
21
+ var _seriesLabels_token;
22
+ const resolvedValue = (_seriesLabels_token = seriesLabels[token]) !== null && _seriesLabels_token !== void 0 ? _seriesLabels_token : '';
23
23
  return resolvedValue;
24
24
  });
25
25
  }
@@ -41,7 +41,7 @@ import { isEmptyObject } from '@perses-dev/core';
41
41
  }
42
42
  /*
43
43
  * Metric labels formattter which checks for __name__ and outputs valid PromQL for series name
44
- */ export function getUniqueKeyForPrometheusResult(metricLabels, { removeExprWrap } = {}) {
44
+ */ export function getUniqueKeyForPrometheusResult(metricLabels, { removeExprWrap } = {}) {
45
45
  const metricNameKey = '__name__';
46
46
  if (metricLabels) {
47
47
  if (Object.prototype.hasOwnProperty.call(metricLabels, metricNameKey)) {
@@ -68,7 +68,7 @@ import { isEmptyObject } from '@perses-dev/core';
68
68
  if (name === '' || isEmptyObject(metric)) {
69
69
  name = query;
70
70
  }
71
- // Query editor allows you to define an optional series_name_format property.
71
+ // Query editor allows you to define an optional seriesNameFormat property.
72
72
  // This controls the regex used to customize legend and tooltip display.
73
73
  const formattedName = formatter ? formatSeriesName(formatter, metric) : name;
74
74
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/utils.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 { isEmptyObject } from '@perses-dev/core';\nimport { Metric } from '../model/api-types';\n\n/**\n * Types for metric labels, used in series_name_format implementation\n */\nexport type SeriesLabels = Record<string, string>;\n\n/*\n * Formatter used for series name display in legends and tooltips.\n * Regex replaces label {{ name }} with resolved label value.\n * If no resolved value, return empty string instead of the token inside double curly braces.\n */\nexport function formatSeriesName(inputFormat: string, seriesLabels: SeriesLabels): string {\n const resolveLabelsRegex = /\\{\\{\\s*(.+?)\\s*\\}\\}/g;\n return inputFormat.replace(resolveLabelsRegex, (_match, token) => {\n const resolvedValue = seriesLabels[token] ?? '';\n return resolvedValue;\n });\n}\n\n/*\n * Stringifies object of labels into valid PromQL for querying metric by label\n */\nfunction stringifyPrometheusMetricLabels(labels: { [key: string]: unknown }, removeExprWrap?: boolean) {\n const labelStrings: string[] = [];\n Object.keys(labels)\n .sort()\n .forEach((labelName) => {\n const labelValue = labels[labelName];\n if (labelValue !== undefined) {\n if (removeExprWrap) {\n labelStrings.push(`\"${labelName}\":\"${labelValue}\"`);\n } else {\n labelStrings.push(`${labelName}=\"${labelValue}\"`);\n }\n }\n });\n return `{${labelStrings.join(',')}}`;\n}\n\n/*\n * Metric labels formattter which checks for __name__ and outputs valid PromQL for series name\n */\nexport function getUniqueKeyForPrometheusResult(\n metricLabels: {\n [key: string]: string;\n },\n { removeExprWrap }: { removeExprWrap?: boolean } = {}\n) {\n const metricNameKey = '__name__';\n if (metricLabels) {\n if (Object.prototype.hasOwnProperty.call(metricLabels, metricNameKey)) {\n const stringifiedLabels = stringifyPrometheusMetricLabels(\n {\n ...metricLabels,\n [metricNameKey]: undefined,\n },\n removeExprWrap\n );\n if (removeExprWrap === true) {\n return `${stringifiedLabels}`;\n } else {\n return `${metricLabels[metricNameKey]}${stringifiedLabels}`;\n }\n }\n return stringifyPrometheusMetricLabels(metricLabels, removeExprWrap);\n }\n return '';\n}\n\n/*\n * Determine human-readable series name to be used in legend and tooltip\n */\nexport function getFormattedPrometheusSeriesName(query: string, metric: Metric, formatter?: string) {\n // Name the series after the metric labels by default.\n // Use the query if no metric or metric labels are empty.\n let name = getUniqueKeyForPrometheusResult(metric);\n if (name === '' || isEmptyObject(metric)) {\n name = query;\n }\n\n // Query editor allows you to define an optional series_name_format property.\n // This controls the regex used to customize legend and tooltip display.\n const formattedName = formatter ? formatSeriesName(formatter, metric) : name;\n return { name, formattedName };\n}\n"],"names":["isEmptyObject","formatSeriesName","inputFormat","seriesLabels","resolveLabelsRegex","replace","_match","token","resolvedValue","stringifyPrometheusMetricLabels","labels","removeExprWrap","labelStrings","Object","keys","sort","forEach","labelName","labelValue","undefined","push","join","getUniqueKeyForPrometheusResult","metricLabels","metricNameKey","prototype","hasOwnProperty","call","stringifiedLabels","get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AC,GAAGE,IAAI,AAAC;IAC7E,OAAO;QAAEA,IAAI;QAAEC,aAAa;KAAE,CAAC;AACjC,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/utils.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 { isEmptyObject } from '@perses-dev/core';\nimport { Metric } from '../model/api-types';\n\n/**\n * Types for metric labels, used in seriesNameFormat implementation\n */\nexport type SeriesLabels = Record<string, string>;\n\n/*\n * Formatter used for series name display in legends and tooltips.\n * Regex replaces label {{ name }} with resolved label value.\n * If no resolved value, return empty string instead of the token inside double curly braces.\n */\nexport function formatSeriesName(inputFormat: string, seriesLabels: SeriesLabels): string {\n const resolveLabelsRegex = /\\{\\{\\s*(.+?)\\s*\\}\\}/g;\n return inputFormat.replace(resolveLabelsRegex, (_match, token) => {\n const resolvedValue = seriesLabels[token] ?? '';\n return resolvedValue;\n });\n}\n\n/*\n * Stringifies object of labels into valid PromQL for querying metric by label\n */\nfunction stringifyPrometheusMetricLabels(labels: { [key: string]: unknown }, removeExprWrap?: boolean) {\n const labelStrings: string[] = [];\n Object.keys(labels)\n .sort()\n .forEach((labelName) => {\n const labelValue = labels[labelName];\n if (labelValue !== undefined) {\n if (removeExprWrap) {\n labelStrings.push(`\"${labelName}\":\"${labelValue}\"`);\n } else {\n labelStrings.push(`${labelName}=\"${labelValue}\"`);\n }\n }\n });\n return `{${labelStrings.join(',')}}`;\n}\n\n/*\n * Metric labels formattter which checks for __name__ and outputs valid PromQL for series name\n */\nexport function getUniqueKeyForPrometheusResult(\n metricLabels: {\n [key: string]: string;\n },\n { removeExprWrap }: { removeExprWrap?: boolean } = {}\n) {\n const metricNameKey = '__name__';\n if (metricLabels) {\n if (Object.prototype.hasOwnProperty.call(metricLabels, metricNameKey)) {\n const stringifiedLabels = stringifyPrometheusMetricLabels(\n {\n ...metricLabels,\n [metricNameKey]: undefined,\n },\n removeExprWrap\n );\n if (removeExprWrap === true) {\n return `${stringifiedLabels}`;\n } else {\n return `${metricLabels[metricNameKey]}${stringifiedLabels}`;\n }\n }\n return stringifyPrometheusMetricLabels(metricLabels, removeExprWrap);\n }\n return '';\n}\n\n/*\n * Determine human-readable series name to be used in legend and tooltip\n */\nexport function getFormattedPrometheusSeriesName(query: string, metric: Metric, formatter?: string) {\n // Name the series after the metric labels by default.\n // Use the query if no metric or metric labels are empty.\n let name = getUniqueKeyForPrometheusResult(metric);\n if (name === '' || isEmptyObject(metric)) {\n name = query;\n }\n\n // Query editor allows you to define an optional seriesNameFormat property.\n // This controls the regex used to customize legend and tooltip display.\n const formattedName = formatter ? formatSeriesName(formatter, metric) : name;\n return { name, formattedName };\n}\n"],"names":["isEmptyObject","formatSeriesName","inputFormat","seriesLabels","resolveLabelsRegex","replace","_match","token","resolvedValue","stringifyPrometheusMetricLabels","labels","removeExprWrap","labelStrings","Object","keys","sort","forEach","labelName","labelValue","undefined","push","join","getUniqueKeyForPrometheusResult","metricLabels","metricNameKey","prototype","hasOwnProperty","call","stringifiedLabels","getFormattedPrometheusSeriesName","query","metric","formatter","name","formattedName"],"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,aAAa,QAAQ,mBAAmB;AAQjD;;;;CAIC,GACD,OAAO,SAASC,iBAAiBC,WAAmB,EAAEC,YAA0B;IAC9E,MAAMC,qBAAqB;IAC3B,OAAOF,YAAYG,OAA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,sDAAsD;IACtD,yDAAyD;IACzD,IAAIC,OAAOX,gCAAgCS;IAC3C,IAAIE,SAAS,MAAMjC,cAAc+B,SAAS;QACxCE,OAAOH;IACT;IAEA,2EAA2E;IAC3E,wEAAwE;IACxE,MAAMI,gBAAgBF,YAAY/B,iBAAiB+B,WAAWD,UAAUE;IACxE,OAAO;QAAEA;QAAMC;IAAc;AAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/prometheus-plugin",
3
- "version": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
3
+ "version": "0.0.0-snapshot-scatterplot-fix-imports-95e1b59",
4
4
  "description": "Prometheus plugin for Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -23,17 +23,17 @@
23
23
  "build:types": "tsc --project tsconfig.build.json",
24
24
  "type-check": "tsc --noEmit",
25
25
  "start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
26
- "test": "TZ=UTC jest",
27
- "test:watch": "TZ=UTC jest --watch",
26
+ "test": "cross-env TZ=UTC jest",
27
+ "test:watch": "cross-env TZ=UTC jest --watch",
28
28
  "lint": "eslint src --ext .ts,.tsx",
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
31
31
  "dependencies": {
32
32
  "@lezer/highlight": "^1.0.0",
33
33
  "@lezer/lr": "^1.2.0",
34
- "@perses-dev/components": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
35
- "@perses-dev/core": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
36
- "@perses-dev/plugin-system": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
34
+ "@perses-dev/components": "0.0.0-snapshot-scatterplot-fix-imports-95e1b59",
35
+ "@perses-dev/core": "0.0.0-snapshot-scatterplot-fix-imports-95e1b59",
36
+ "@perses-dev/plugin-system": "0.0.0-snapshot-scatterplot-fix-imports-95e1b59",
37
37
  "@prometheus-io/codemirror-promql": "^0.43.0",
38
38
  "@uiw/react-codemirror": "^4.19.1",
39
39
  "date-fns": "^2.28.0",
@@ -1,26 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "useReplaceTemplateString", {
18
- enumerable: true,
19
- get: ()=>useReplaceTemplateString
20
- });
21
- const _pluginSystem = require("@perses-dev/plugin-system");
22
- function useReplaceTemplateString(templateString) {
23
- const templateVariablesInTemplate = (0, _pluginSystem.parseTemplateVariables)(templateString || '');
24
- const variables = (0, _pluginSystem.useTemplateVariableValues)(templateVariablesInTemplate);
25
- return (0, _pluginSystem.replaceTemplateVariables)(templateString || '', variables);
26
- }
@@ -1,392 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "PrometheusDatasourceEditor", {
18
- enumerable: true,
19
- get: ()=>PrometheusDatasourceEditor
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
23
- const _material = require("@mui/material");
24
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
25
- const _minus = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Minus"));
26
- const _plus = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Plus"));
27
- function _interopRequireDefault(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
32
- function _getRequireWildcardCache(nodeInterop) {
33
- if (typeof WeakMap !== "function") return null;
34
- var cacheBabelInterop = new WeakMap();
35
- var cacheNodeInterop = new WeakMap();
36
- return (_getRequireWildcardCache = function(nodeInterop) {
37
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
38
- })(nodeInterop);
39
- }
40
- function _interopRequireWildcard(obj, nodeInterop) {
41
- if (!nodeInterop && obj && obj.__esModule) {
42
- return obj;
43
- }
44
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
45
- return {
46
- default: obj
47
- };
48
- }
49
- var cache = _getRequireWildcardCache(nodeInterop);
50
- if (cache && cache.has(obj)) {
51
- return cache.get(obj);
52
- }
53
- var newObj = {};
54
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
- for(var key in obj){
56
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
- if (desc && (desc.get || desc.set)) {
59
- Object.defineProperty(newObj, key, desc);
60
- } else {
61
- newObj[key] = obj[key];
62
- }
63
- }
64
- }
65
- newObj.default = obj;
66
- if (cache) {
67
- cache.set(obj, newObj);
68
- }
69
- return newObj;
70
- }
71
- function PrometheusDatasourceEditor(props) {
72
- var ref, ref1, ref2, ref3;
73
- const { value , onChange , isReadonly } = props;
74
- const strDirect = 'Direct access';
75
- const strProxy = 'Proxy';
76
- // TODO refactor with useImmer to avoid doing so much destructuring? feasibility & performances to be checked
77
- // utilitary function used for headers when renaming a property
78
- // -> TODO it would be cleaner to manipulate headers as a list instead, to avoid doing this.
79
- // This could be a pure frontend trick, but change in the backend datamodel should also be considered
80
- const buildNewHeaders = (oldHeaders, oldName, newName)=>{
81
- if (oldHeaders === undefined) return oldHeaders;
82
- const keys = Object.keys(oldHeaders);
83
- const newHeaders = keys.reduce((acc, val)=>{
84
- if (val === oldName) {
85
- acc[newName] = oldHeaders[oldName] || '';
86
- } else {
87
- acc[val] = oldHeaders[val] || '';
88
- }
89
- return acc;
90
- }, {});
91
- return {
92
- ...newHeaders
93
- };
94
- };
95
- const tabs = [
96
- {
97
- label: strDirect,
98
- content: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
99
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
100
- fullWidth: true,
101
- label: "URL",
102
- value: value.direct_url || '',
103
- InputProps: {
104
- readOnly: isReadonly
105
- },
106
- onChange: (e)=>onChange({
107
- ...value,
108
- direct_url: e.target.value
109
- })
110
- })
111
- })
112
- },
113
- {
114
- label: strProxy,
115
- content: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
116
- children: [
117
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
118
- fullWidth: true,
119
- label: "URL",
120
- value: ((ref = value.proxy) === null || ref === void 0 ? void 0 : ref.spec.url) || '',
121
- InputProps: {
122
- readOnly: isReadonly
123
- },
124
- onChange: (e)=>onChange({
125
- ...value,
126
- ...value.proxy && {
127
- proxy: {
128
- ...value.proxy,
129
- spec: {
130
- ...value.proxy.spec,
131
- url: e.target.value
132
- }
133
- }
134
- }
135
- })
136
- }),
137
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
138
- py: 2,
139
- variant: "h4",
140
- children: "Allowed endpoints"
141
- }),
142
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
143
- container: true,
144
- spacing: 2,
145
- mb: 2,
146
- children: ((ref1 = value.proxy) === null || ref1 === void 0 ? void 0 : ref1.spec.allowed_endpoints) && value.proxy.spec.allowed_endpoints.map(({ endpoint_pattern , method }, i)=>{
147
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_react.default.Fragment, {
148
- children: [
149
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
150
- item: true,
151
- xs: 8,
152
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
153
- disabled: true,
154
- fullWidth: true,
155
- label: "Endpoint pattern",
156
- value: endpoint_pattern,
157
- InputProps: {
158
- readOnly: isReadonly
159
- }
160
- })
161
- }),
162
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
163
- item: true,
164
- xs: 4,
165
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
166
- disabled: true,
167
- fullWidth: true,
168
- label: "URL",
169
- value: method,
170
- InputProps: {
171
- readOnly: isReadonly
172
- }
173
- })
174
- })
175
- ]
176
- }, i);
177
- })
178
- }),
179
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
180
- pb: 2,
181
- variant: "h4",
182
- children: "Request Headers"
183
- }),
184
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
185
- container: true,
186
- spacing: 2,
187
- mb: 2,
188
- children: [
189
- ((ref2 = value.proxy) === null || ref2 === void 0 ? void 0 : ref2.spec.headers) !== undefined && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
190
- var ref, ref1;
191
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_react.default.Fragment, {
192
- children: [
193
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
194
- item: true,
195
- xs: 4,
196
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
197
- fullWidth: true,
198
- label: "Header name",
199
- value: headerName,
200
- InputProps: {
201
- readOnly: isReadonly
202
- },
203
- onChange: (e)=>onChange({
204
- ...value,
205
- ...value.proxy && {
206
- proxy: {
207
- ...value.proxy,
208
- spec: {
209
- ...value.proxy.spec,
210
- headers: buildNewHeaders(value.proxy.spec.headers, headerName, e.target.value)
211
- }
212
- }
213
- }
214
- })
215
- })
216
- }),
217
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
218
- item: true,
219
- xs: 7,
220
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
221
- fullWidth: true,
222
- label: "Header value",
223
- value: (ref1 = (ref = value.proxy) === null || ref === void 0 ? void 0 : ref.spec.headers) === null || ref1 === void 0 ? void 0 : ref1[headerName],
224
- InputProps: {
225
- readOnly: isReadonly
226
- },
227
- onChange: (e)=>onChange({
228
- ...value,
229
- ...value.proxy && {
230
- proxy: {
231
- ...value.proxy,
232
- spec: {
233
- ...value.proxy.spec,
234
- headers: {
235
- ...value.proxy.spec.headers,
236
- [headerName]: e.target.value
237
- }
238
- }
239
- }
240
- }
241
- })
242
- })
243
- }),
244
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
245
- item: true,
246
- xs: 1,
247
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
248
- disabled: isReadonly,
249
- onClick: ()=>{
250
- var ref;
251
- const newHeaders = {
252
- ...(ref = value.proxy) === null || ref === void 0 ? void 0 : ref.spec.headers
253
- };
254
- delete newHeaders[headerName];
255
- onChange({
256
- ...value,
257
- ...value.proxy && {
258
- proxy: {
259
- ...value.proxy,
260
- spec: {
261
- ...value.proxy.spec,
262
- headers: newHeaders
263
- }
264
- }
265
- }
266
- });
267
- },
268
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_minus.default, {})
269
- })
270
- })
271
- ]
272
- }, i);
273
- }),
274
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
275
- item: true,
276
- xs: 12,
277
- sx: {
278
- paddingTop: '5px !important'
279
- },
280
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
281
- disabled: isReadonly,
282
- onClick: ()=>onChange({
283
- ...value,
284
- ...value.proxy && {
285
- proxy: {
286
- ...value.proxy,
287
- spec: {
288
- ...value.proxy.spec,
289
- headers: {
290
- ...value.proxy.spec.headers,
291
- '': ''
292
- }
293
- }
294
- }
295
- }
296
- }),
297
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plus.default, {})
298
- })
299
- })
300
- ]
301
- }),
302
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
303
- fullWidth: true,
304
- label: "Secret",
305
- value: ((ref3 = value.proxy) === null || ref3 === void 0 ? void 0 : ref3.spec.secret) || '',
306
- InputProps: {
307
- readOnly: isReadonly
308
- },
309
- onChange: (e)=>onChange({
310
- ...value,
311
- ...value.proxy && {
312
- proxy: {
313
- ...value.proxy,
314
- spec: {
315
- ...value.proxy.spec,
316
- secret: e.target.value
317
- }
318
- }
319
- }
320
- })
321
- })
322
- ]
323
- })
324
- }
325
- ];
326
- // Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or
327
- // bug in case the tabs get eventually swapped in the future.
328
- const directModeId = tabs.findIndex((tab)=>tab.label == strDirect);
329
- const proxyModeId = tabs.findIndex((tab)=>tab.label == strProxy);
330
- // In "update datasource" case, set defaultTab to the mode that this datasource is currently relying on.
331
- // Otherwise (create datasource), set defaultTab to Direct access.
332
- const defaultTab = value.proxy ? proxyModeId : directModeId;
333
- const initialSpecDirect = {
334
- direct_url: ''
335
- };
336
- const initialSpecProxy = {
337
- proxy: {
338
- kind: 'HTTPProxy',
339
- spec: {
340
- allowed_endpoints: [
341
- // hardcoded list of allowed endpoints for now since those are enforced by the backend
342
- {
343
- endpoint_pattern: '/api/v1/labels',
344
- method: 'POST'
345
- },
346
- {
347
- endpoint_pattern: '/api/v1/series',
348
- method: 'POST'
349
- },
350
- {
351
- endpoint_pattern: '/api/v1/metadata',
352
- method: 'GET'
353
- },
354
- {
355
- endpoint_pattern: '/api/v1/query',
356
- method: 'POST'
357
- },
358
- {
359
- endpoint_pattern: '/api/v1/query_range',
360
- method: 'POST'
361
- },
362
- {
363
- endpoint_pattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',
364
- method: 'GET'
365
- }
366
- ],
367
- url: ''
368
- }
369
- }
370
- };
371
- // For better user experience, save previous states in mind for both mode.
372
- // This avoids losing everything when the user changes their mind back.
373
- const [previousSpecDirect, setPreviousSpecDirect] = (0, _react.useState)(initialSpecDirect);
374
- const [previousSpecProxy, setPreviousSpecProxy] = (0, _react.useState)(initialSpecProxy);
375
- // When changing mode, remove previous mode's config + append default values for the new mode.
376
- const handleModeChange = (v)=>{
377
- var ref, ref1;
378
- if (((ref = tabs[v]) === null || ref === void 0 ? void 0 : ref.label) == strDirect) {
379
- setPreviousSpecProxy(value);
380
- onChange(previousSpecDirect);
381
- } else if (((ref1 = tabs[v]) === null || ref1 === void 0 ? void 0 : ref1.label) == strProxy) {
382
- setPreviousSpecDirect(value);
383
- onChange(previousSpecProxy);
384
- }
385
- };
386
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.OptionsEditorRadios, {
387
- isReadonly: isReadonly,
388
- tabs: tabs,
389
- defaultTab: defaultTab,
390
- onModeChange: handleModeChange
391
- });
392
- }
@@ -1,29 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _exportStar(require("./PrometheusDatasourceEditor"), exports);
18
- _exportStar(require("./types"), exports);
19
- function _exportStar(from, to) {
20
- Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- });
28
- return from;
29
- }
@@ -1,16 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
@@ -1,6 +0,0 @@
1
- /**
2
- * Type alias to indicate what parts of the API support template variables.
3
- */
4
- export declare type TemplateString = string;
5
- export declare function useReplaceTemplateString(templateString?: TemplateString): string;
6
- //# sourceMappingURL=templating.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templating.d.ts","sourceRoot":"","sources":["../../src/model/templating.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,oBAAY,cAAc,GAAG,MAAM,CAAC;AAEpC,wBAAgB,wBAAwB,CAAC,cAAc,CAAC,EAAE,cAAc,UAIvE"}
@@ -1,20 +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 { useTemplateVariableValues, replaceTemplateVariables, parseTemplateVariables } from '@perses-dev/plugin-system';
14
- export function useReplaceTemplateString(templateString) {
15
- const templateVariablesInTemplate = parseTemplateVariables(templateString || '');
16
- const variables = useTemplateVariableValues(templateVariablesInTemplate);
17
- return replaceTemplateVariables(templateString || '', variables);
18
- }
19
-
20
- //# sourceMappingURL=templating.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/model/templating.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 { useTemplateVariableValues, replaceTemplateVariables, parseTemplateVariables } from '@perses-dev/plugin-system';\n\n/**\n * Type alias to indicate what parts of the API support template variables.\n */\nexport type TemplateString = string;\n\nexport function useReplaceTemplateString(templateString?: TemplateString) {\n const templateVariablesInTemplate = parseTemplateVariables(templateString || '');\n const variables = useTemplateVariableValues(templateVariablesInTemplate);\n return replaceTemplateVariables(templateString || '', variables);\n}\n"],"names":["useTemplateVariableValues","replaceTemplateVariables","parseTemplateVariables","useReplaceTemplateString","templateString","templateVariablesInTemplate","variables"],"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,EAAEC,wBAAwB,EAAEC,sBAAsB,QAAQ,2BAA2B,CAAC;AAOxH,OAAO,SAASC,wBAAwB,CAACC,cAA+B,EAAE;IACxE,MAAMC,2BAA2B,GAAGH,sBAAsB,CAACE,cAAc,IAAI,EAAE,CAAC,AAAC;IACjF,MAAME,SAAS,GAAGN,yBAAyB,CAACK,2BAA2B,CAAC,AAAC;IACzE,OAAOJ,wBAAwB,CAACG,cAAc,IAAI,EAAE,EAAEE,SAAS,CAAC,CAAC;AACnE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,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,eA6ShF"}