@perses-dev/prometheus-plugin 0.57.0-beta.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/__mf/js/{Prometheus.2bb892ab.js → Prometheus.9877d89e.js} +3 -3
  2. package/__mf/js/async/1728.531c96f9.js +1 -0
  3. package/__mf/js/async/3499.bef2e2e5.js +1 -0
  4. package/__mf/js/async/3652.6b591718.js +7 -0
  5. package/__mf/js/async/392.f1b4a590.js +2 -0
  6. package/__mf/js/async/425.1ec8867f.js +1 -0
  7. package/__mf/js/async/4657.f0c3ccd6.js +2 -0
  8. package/__mf/js/async/54.e6002704.js +22 -0
  9. package/__mf/js/async/5440.8ced5513.js +2 -0
  10. package/__mf/js/async/{5440.c13c3533.js.LICENSE.txt → 5440.8ced5513.js.LICENSE.txt} +3 -3
  11. package/__mf/js/async/9010.ca50fa9e.js +2 -0
  12. package/__mf/js/async/{9020.c19782f1.js → 9020.ebc1cad3.js} +1 -1
  13. package/__mf/js/async/{__federation_expose_PrometheusDatasource.6f63e147.js → __federation_expose_PrometheusDatasource.b97f9012.js} +1 -1
  14. package/__mf/js/async/{__federation_expose_PrometheusExplorer.584a073d.js → __federation_expose_PrometheusExplorer.eba3b416.js} +1 -1
  15. package/__mf/js/async/{__federation_expose_PrometheusLabelNamesVariable.40984a4d.js → __federation_expose_PrometheusLabelNamesVariable.bd38a89c.js} +1 -1
  16. package/__mf/js/async/{__federation_expose_PrometheusLabelValuesVariable.bd3eb00c.js → __federation_expose_PrometheusLabelValuesVariable.eb12e168.js} +1 -1
  17. package/__mf/js/async/{__federation_expose_PrometheusPromQLVariable.5cca8417.js → __federation_expose_PrometheusPromQLVariable.7ccb0601.js} +1 -1
  18. package/__mf/js/async/{__federation_expose_PrometheusTimeSeriesQuery.f59141f4.js → __federation_expose_PrometheusTimeSeriesQuery.08f11ea9.js} +1 -1
  19. package/__mf/js/{main.9617b605.js → main.78fc6444.js} +5 -5
  20. package/lib/bootstrap.js +1 -1
  21. package/lib/bootstrap.js.map +1 -1
  22. package/lib/cjs/bootstrap.js +1 -1
  23. package/lib/cjs/components/PromQLEditor.js +1 -1
  24. package/lib/cjs/components/TreeNode.js +1 -1
  25. package/lib/cjs/components/index.js +1 -1
  26. package/lib/cjs/components/promql/ast.js +1 -1
  27. package/lib/cjs/components/promql/format.js +1 -1
  28. package/lib/cjs/components/promql/functionSignatures.js +1 -1
  29. package/lib/cjs/components/promql/serialize.js +1 -1
  30. package/lib/cjs/components/promql/utils.js +1 -1
  31. package/lib/cjs/components/query.js +1 -1
  32. package/lib/cjs/env.d.js +1 -1
  33. package/lib/cjs/explore/PrometheusExplorer.js +1 -1
  34. package/lib/cjs/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +1 -1
  35. package/lib/cjs/explore/PrometheusMetricsFinder/display/MetricChip.js +1 -1
  36. package/lib/cjs/explore/PrometheusMetricsFinder/display/list/MetricList.js +1 -1
  37. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +1 -1
  38. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
  39. package/lib/cjs/explore/PrometheusMetricsFinder/index.js +1 -1
  40. package/lib/cjs/explore/PrometheusMetricsFinder/overview/MetricOverview.js +1 -1
  41. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +1 -1
  42. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +1 -1
  43. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +1 -1
  44. package/lib/cjs/explore/PrometheusMetricsFinder/types.js +1 -1
  45. package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +1 -1
  46. package/lib/cjs/explore/index.js +12 -0
  47. package/lib/cjs/getPluginModule.js +12 -0
  48. package/lib/cjs/index-federation.js +1 -1
  49. package/lib/cjs/index.js +12 -0
  50. package/lib/cjs/model/api-types.js +1 -1
  51. package/lib/cjs/model/index.js +1 -1
  52. package/lib/cjs/model/parse-sample-values.js +1 -1
  53. package/lib/cjs/model/prometheus-client.js +1 -1
  54. package/lib/cjs/model/prometheus-selectors.js +1 -1
  55. package/lib/cjs/model/time.js +1 -1
  56. package/lib/cjs/plugins/MatcherEditor.js +1 -1
  57. package/lib/cjs/plugins/PrometheusDatasourceEditor.js +1 -1
  58. package/lib/cjs/plugins/PrometheusLabelNamesVariable.js +12 -0
  59. package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +12 -0
  60. package/lib/cjs/plugins/PrometheusPromQLVariable.js +12 -0
  61. package/lib/cjs/plugins/index.js +12 -0
  62. package/lib/cjs/plugins/prometheus-datasource.js +1 -1
  63. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  64. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +1 -1
  65. package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +1 -1
  66. package/lib/cjs/plugins/prometheus-time-series-query/index.js +1 -1
  67. package/lib/cjs/plugins/prometheus-time-series-query/query-editor-model.js +1 -1
  68. package/lib/cjs/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +1 -1
  69. package/lib/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +1 -1
  70. package/lib/cjs/plugins/prometheus-variables.js +1 -1
  71. package/lib/cjs/plugins/test/setup-tests.js +1 -1
  72. package/lib/cjs/plugins/types.js +1 -1
  73. package/lib/cjs/plugins/variable.js +1 -1
  74. package/lib/cjs/setup-tests.js +1 -1
  75. package/lib/cjs/utils/index.js +1 -1
  76. package/lib/cjs/utils/utils.js +1 -1
  77. package/lib/components/PromQLEditor.js +1 -1
  78. package/lib/components/PromQLEditor.js.map +1 -1
  79. package/lib/components/TreeNode.js +1 -1
  80. package/lib/components/TreeNode.js.map +1 -1
  81. package/lib/components/index.js +1 -1
  82. package/lib/components/index.js.map +1 -1
  83. package/lib/components/promql/ast.js +1 -1
  84. package/lib/components/promql/ast.js.map +1 -1
  85. package/lib/components/promql/format.js +1 -1
  86. package/lib/components/promql/format.js.map +1 -1
  87. package/lib/components/promql/functionSignatures.js +1 -1
  88. package/lib/components/promql/functionSignatures.js.map +1 -1
  89. package/lib/components/promql/serialize.js +1 -1
  90. package/lib/components/promql/serialize.js.map +1 -1
  91. package/lib/components/promql/utils.js +1 -1
  92. package/lib/components/promql/utils.js.map +1 -1
  93. package/lib/components/query.js +1 -1
  94. package/lib/components/query.js.map +1 -1
  95. package/lib/env.d.js +1 -1
  96. package/lib/env.d.js.map +1 -1
  97. package/lib/explore/PrometheusExplorer.js +1 -1
  98. package/lib/explore/PrometheusExplorer.js.map +1 -1
  99. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +1 -1
  100. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -1
  101. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js +1 -1
  102. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js.map +1 -1
  103. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js +1 -1
  104. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -1
  105. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +1 -1
  106. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -1
  107. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
  108. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -1
  109. package/lib/explore/PrometheusMetricsFinder/index.js +1 -1
  110. package/lib/explore/PrometheusMetricsFinder/index.js.map +1 -1
  111. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js +1 -1
  112. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -1
  113. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +1 -1
  114. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js.map +1 -1
  115. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +1 -1
  116. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js.map +1 -1
  117. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +1 -1
  118. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js.map +1 -1
  119. package/lib/explore/PrometheusMetricsFinder/types.js +1 -1
  120. package/lib/explore/PrometheusMetricsFinder/types.js.map +1 -1
  121. package/lib/explore/PrometheusMetricsFinder/utils.js +1 -1
  122. package/lib/explore/PrometheusMetricsFinder/utils.js.map +1 -1
  123. package/lib/explore/index.d.ts.map +1 -1
  124. package/lib/explore/index.js +12 -0
  125. package/lib/explore/index.js.map +1 -1
  126. package/lib/getPluginModule.d.ts.map +1 -1
  127. package/lib/getPluginModule.js +12 -0
  128. package/lib/getPluginModule.js.map +1 -1
  129. package/lib/index-federation.js +1 -1
  130. package/lib/index-federation.js.map +1 -1
  131. package/lib/index.d.ts.map +1 -1
  132. package/lib/index.js +12 -0
  133. package/lib/index.js.map +1 -1
  134. package/lib/model/api-types.js +1 -1
  135. package/lib/model/api-types.js.map +1 -1
  136. package/lib/model/index.js +1 -1
  137. package/lib/model/index.js.map +1 -1
  138. package/lib/model/parse-sample-values.js +1 -1
  139. package/lib/model/parse-sample-values.js.map +1 -1
  140. package/lib/model/prometheus-client.js +1 -1
  141. package/lib/model/prometheus-client.js.map +1 -1
  142. package/lib/model/prometheus-selectors.js +1 -1
  143. package/lib/model/prometheus-selectors.js.map +1 -1
  144. package/lib/model/time.js +1 -1
  145. package/lib/model/time.js.map +1 -1
  146. package/lib/plugins/MatcherEditor.js +1 -1
  147. package/lib/plugins/MatcherEditor.js.map +1 -1
  148. package/lib/plugins/PrometheusDatasourceEditor.js +1 -1
  149. package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -1
  150. package/lib/plugins/PrometheusLabelNamesVariable.d.ts.map +1 -1
  151. package/lib/plugins/PrometheusLabelNamesVariable.js +12 -0
  152. package/lib/plugins/PrometheusLabelNamesVariable.js.map +1 -1
  153. package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -1
  154. package/lib/plugins/PrometheusLabelValuesVariable.js +12 -0
  155. package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -1
  156. package/lib/plugins/PrometheusPromQLVariable.d.ts.map +1 -1
  157. package/lib/plugins/PrometheusPromQLVariable.js +12 -0
  158. package/lib/plugins/PrometheusPromQLVariable.js.map +1 -1
  159. package/lib/plugins/index.d.ts.map +1 -1
  160. package/lib/plugins/index.js +12 -0
  161. package/lib/plugins/index.js.map +1 -1
  162. package/lib/plugins/prometheus-datasource.js +1 -1
  163. package/lib/plugins/prometheus-datasource.js.map +1 -1
  164. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  165. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
  166. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +1 -1
  167. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  168. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +1 -1
  169. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  170. package/lib/plugins/prometheus-time-series-query/index.js +1 -1
  171. package/lib/plugins/prometheus-time-series-query/index.js.map +1 -1
  172. package/lib/plugins/prometheus-time-series-query/query-editor-model.js +1 -1
  173. package/lib/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
  174. package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +1 -1
  175. package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js.map +1 -1
  176. package/lib/plugins/prometheus-time-series-query/time-series-query-model.js +1 -1
  177. package/lib/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
  178. package/lib/plugins/prometheus-variables.js +1 -1
  179. package/lib/plugins/prometheus-variables.js.map +1 -1
  180. package/lib/plugins/test/setup-tests.js +1 -1
  181. package/lib/plugins/test/setup-tests.js.map +1 -1
  182. package/lib/plugins/types.js +1 -1
  183. package/lib/plugins/types.js.map +1 -1
  184. package/lib/plugins/variable.js +1 -1
  185. package/lib/plugins/variable.js.map +1 -1
  186. package/lib/setup-tests.js +1 -1
  187. package/lib/setup-tests.js.map +1 -1
  188. package/lib/utils/index.js +1 -1
  189. package/lib/utils/index.js.map +1 -1
  190. package/lib/utils/utils.js +1 -1
  191. package/lib/utils/utils.js.map +1 -1
  192. package/mf-manifest.json +73 -73
  193. package/mf-stats.json +73 -73
  194. package/package.json +6 -6
  195. package/__mf/js/async/1490.7e5068f1.js +0 -22
  196. package/__mf/js/async/1728.af16c4ec.js +0 -1
  197. package/__mf/js/async/2984.7182c2f5.js +0 -1
  198. package/__mf/js/async/2999.1d8347df.js +0 -1
  199. package/__mf/js/async/3664.ba8b26b6.js +0 -2
  200. package/__mf/js/async/392.7cda691a.js +0 -2
  201. package/__mf/js/async/5440.c13c3533.js +0 -2
  202. package/__mf/js/async/5501.6166367c.js +0 -2
  203. package/__mf/js/async/6149.19799c37.js +0 -7
  204. /package/__mf/js/async/{6149.19799c37.js.LICENSE.txt → 3652.6b591718.js.LICENSE.txt} +0 -0
  205. /package/__mf/js/async/{392.7cda691a.js.LICENSE.txt → 392.f1b4a590.js.LICENSE.txt} +0 -0
  206. /package/__mf/js/async/{3664.ba8b26b6.js.LICENSE.txt → 4657.f0c3ccd6.js.LICENSE.txt} +0 -0
  207. /package/__mf/js/async/{1490.7e5068f1.js.LICENSE.txt → 54.e6002704.js.LICENSE.txt} +0 -0
  208. /package/__mf/js/async/{5501.6166367c.js.LICENSE.txt → 9010.ca50fa9e.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TreeNode.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\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 // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\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 [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\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 const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\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 // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\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 {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\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\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n &nbsp;&nbsp;–&nbsp;&nbsp;\n {responseTime ? `${Math.round(responseTime)}ms` : '? ms'}\n {resultStats.sortedLabelCards.length > 0 && <>&nbsp;&nbsp;–</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n flexGrow: 1,\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n whiteSpace: 'nowrap',\n flexShrink: 0,\n }}\n >\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","Math","round","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","whiteSpace","overflow","textOverflow","flexGrow","flexShrink","arrow","span","style","cursor","success","size"],"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,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,gBAAgB;AAC5G,OAAOC,gBAAgB,yBAAyB;AAChD,SAAuBC,WAAW,EAAEC,SAAS,EA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["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\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 // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\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 [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\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 const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\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 // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\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 {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\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\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n &nbsp;&nbsp;–&nbsp;&nbsp;\n {responseTime ? `${Math.round(responseTime)}ms` : '? ms'}\n {resultStats.sortedLabelCards.length > 0 && <>&nbsp;&nbsp;–</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n flexGrow: 1,\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n whiteSpace: 'nowrap',\n flexShrink: 0,\n }}\n >\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","Math","round","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","whiteSpace","overflow","textOverflow","flexGrow","flexShrink","arrow","span","style","cursor","success","size"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,oJAAoJ;AAEpJ,SAASA,GAAG,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,g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C/BF;oBAAK;;;;;AAId"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/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 './PromQLEditor';\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,iBAAiB"}
1
+ {"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './PromQLEditor';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
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;AAEzI,OAAO,IAAA,AAAKA,kCAAAA;;;;;;;;;;;;WAAAA;MAYX;AAED,OAAO,IAAA,AAAKC,yCAAAA;;;;;;;;;;;;;;;WAAAA;MAeX;AAED,OAAO,IAAA,AAAKC,4CAAAA;;;;;;;;;;;;;;;;;WAAAA;MAiBX;AAED,OAAO,MAAMC,oBAA0C;;;;;;;CAOtD,CAAC;AAEF,OAAO,MAAMC,mBAAyC;;;;CAIrD,CAAC;AAEF,OAAO,IAAA,AAAKC,2CAAAA;;;WAAAA;MAGX;AAED,OAAO,IAAA,AAAKC,gDAAAA;;;;;WAAAA;MAKX;AAED,OAAO,IAAA,AAAKC,mCAAAA;IACV,6EAA6E;;;;;;WADnEA;MAOX;AAED,OAAO,IAAA,AAAKC,mCAAAA;;;;;WAAAA;MAKX"}
1
+ {"version":3,"sources":["../../../../src/components/promql/ast.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,yIAAyI;AAEzI,OAAO,IAAA,AAAKA,kCAAAA;;;;;;;;;;;;WAAAA;MAYX;AAED,OAAO,IAAA,AAAKC,yCAAAA;;;;;;;;;;;;;;;WAAAA;MAeX;AAED,OAAO,IAAA,AAAKC,4CAAAA;;;;;;;;;;;;;;;;;WAAAA;MAiBX;AAED,OAAO,MAAMC,oBAA0C;;;;;;;CAOtD,CAAC;AAEF,OAAO,MAAMC,mBAAyC;;;;CAIrD,CAAC;AAEF,OAAO,IAAA,AAAKC,2CAAAA;;;WAAAA;MAGX;AAED,OAAO,IAAA,AAAKC,gDAAAA;;;;;WAAAA;MAKX;AAED,OAAO,IAAA,AAAKC,mCAAAA;IACV,6EAA6E;;;;;;WADnEA;MAOX;AAED,OAAO,IAAA,AAAKC,mCAAAA;;;;;WAAAA;MAKX"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- // Copyright 2024 The Perses Authors
2
+ // Copyright The Perses Authors
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
5
5
  // You may obtain a copy of the License at
@@ -1 +1 @@
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>&quot;{escapeString(m.value)}&quot;</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>&quot;{escapeString(node.val)}&quot;</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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AAS;4BAAO;4BAAM;yBAAS,CAAC+B,QAAQ,CAAC/C,KAAKmB,EAAE,kBAChD,KAAChC;sCAAgBa,KAAKmB,EAAE;2CAExB,KAAChC;sCAAgBa,KAAKmB,EAAE;;wBAEzBnB,KAAKgD,IAAI,kBACR;;gCACG;8CACD,KAACzE;8CAAc;;;;wBAGlBgE;wBACAlB;wBAAU;wBACVP,gBAAgBS,WAAWpD,4BAA4B6B,KAAKmB,EAAE,EAAEnB,KAAKiD,GAAG,GAAGnC,cAAcE;;;YAGhG;QACA,KAAK9C,SAASgF,WAAW;YACvB,2DAA2D;YAC3D,OAAOtC;QACT;YACE,MAAM,IAAIuC,MAAM;IACpB;AACF;AAEA,OAAO,MAAM5B,aAAa,CAACvB,MAAec,cAAuBC,yBAC/D,KAAC1C;kBAAYwC,mBAAmBb,MAAMc,cAAcC;OACpD"}
1
+ {"version":3,"sources":["../../../../src/components/promql/format.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\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>&quot;{escapeString(m.value)}&quot;</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>&quot;{escapeString(node.val)}&quot;</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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,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;QACrDC,OAAOD,MAAME,OAAO,CAACC,IAAI,KAAK,SAAS,YAAY;IACrD,CAAA;AAEA,MAAMI,eAAelB,OAAO,QAAQ,CAAC,EAAEW,KAAK,EAAE,GAAM,CAAA;QAClDC,OAA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;oBAGZ;gBACF;gBAEA,qBACE;;wBACGqB,gBAAgBS,WAAWpD,4BAA4B6B,KAAKmB,EAAE,EAAEnB,KAAK8C,GAAG,GAAGhC,cAAcE;wBAAgB;wBACzG;4BAAC;4BAAS;4BAAO;4BAAM;yBAAS,CAAC+B,QAAQ,CAAC/C,KAAKmB,EAAE,kBAChD,KAAChC;sCAAgBa,KAAKmB,EAAE;2CAExB,KAAChC;sCAAgBa,KAAKmB,EAAE;;wBAEzBnB,KAAKgD,IAAI,kBACR;;gCACG;8CACD,KAACzE;8CAAc;;;;wBAGlBgE;wBACAlB;wBAAU;wBACVP,gBAAgBS,WAAWpD,4BAA4B6B,KAAKmB,EAAE,EAAEnB,KAAKiD,GAAG,GAAGnC,cAAcE;;;YAGhG;QACA,KAAK9C,SAASgF,WAAW;YACvB,2DAA2D;YAC3D,OAAOtC;QACT;YACE,MAAM,IAAIuC,MAAM;IACpB;AACF;AAEA,OAAO,MAAM5B,aAAa,CAACvB,MAAec,cAAuBC,yBAC/D,KAAC1C;kBAAYwC,mBAAmBb,MAAMc,cAAcC;OACpD"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/promql/functionSignatures.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/functionSignatures.ts\n\nimport { valueType, Func } from './ast';\n\nexport const functionSignatures: Record<string, Func> = {\n abs: { name: 'abs', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n absent: { name: 'absent', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n absent_over_time: {\n name: 'absent_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n acos: { name: 'acos', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n acosh: { name: 'acosh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n asin: { name: 'asin', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n asinh: { name: 'asinh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n atan: { name: 'atan', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n atanh: { name: 'atanh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n avg_over_time: { name: 'avg_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n ceil: { name: 'ceil', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n changes: { name: 'changes', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n clamp: {\n name: 'clamp',\n argTypes: [valueType.vector, valueType.scalar, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n clamp_max: {\n name: 'clamp_max',\n argTypes: [valueType.vector, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n clamp_min: {\n name: 'clamp_min',\n argTypes: [valueType.vector, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n cos: { name: 'cos', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n cosh: { name: 'cosh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n count_over_time: { name: 'count_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n day_of_month: { name: 'day_of_month', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n day_of_week: { name: 'day_of_week', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n day_of_year: { name: 'day_of_year', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n days_in_month: { name: 'days_in_month', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n deg: { name: 'deg', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n delta: { name: 'delta', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n deriv: { name: 'deriv', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n exp: { name: 'exp', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n floor: { name: 'floor', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n histogram_avg: { name: 'histogram_avg', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n histogram_count: { name: 'histogram_count', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n histogram_fraction: {\n name: 'histogram_fraction',\n argTypes: [valueType.scalar, valueType.scalar, valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_quantile: {\n name: 'histogram_quantile',\n argTypes: [valueType.scalar, valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_stddev: {\n name: 'histogram_stddev',\n argTypes: [valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_stdvar: {\n name: 'histogram_stdvar',\n argTypes: [valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_sum: { name: 'histogram_sum', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n double_exponential_smoothing: {\n name: 'double_exponential_smoothing',\n argTypes: [valueType.matrix, valueType.scalar, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n hour: { name: 'hour', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n idelta: { name: 'idelta', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n increase: { name: 'increase', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n irate: { name: 'irate', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n label_join: {\n name: 'label_join',\n argTypes: [valueType.vector, valueType.string, valueType.string, valueType.string],\n variadic: -1,\n returnType: valueType.vector,\n },\n label_replace: {\n name: 'label_replace',\n argTypes: [valueType.vector, valueType.string, valueType.string, valueType.string, valueType.string],\n variadic: 0,\n returnType: valueType.vector,\n },\n last_over_time: { name: 'last_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n ln: { name: 'ln', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n log10: { name: 'log10', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n log2: { name: 'log2', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n mad_over_time: { name: 'mad_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n max_over_time: { name: 'max_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n min_over_time: { name: 'min_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n minute: { name: 'minute', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n month: { name: 'month', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n pi: { name: 'pi', argTypes: [], variadic: 0, returnType: valueType.scalar },\n predict_linear: {\n name: 'predict_linear',\n argTypes: [valueType.matrix, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n present_over_time: {\n name: 'present_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n quantile_over_time: {\n name: 'quantile_over_time',\n argTypes: [valueType.scalar, valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n rad: { name: 'rad', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n rate: { name: 'rate', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n resets: { name: 'resets', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n round: { name: 'round', argTypes: [valueType.vector, valueType.scalar], variadic: 1, returnType: valueType.vector },\n scalar: { name: 'scalar', argTypes: [valueType.vector], variadic: 0, returnType: valueType.scalar },\n sgn: { name: 'sgn', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sin: { name: 'sin', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sinh: { name: 'sinh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sort: { name: 'sort', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sort_by_label: {\n name: 'sort_by_label',\n argTypes: [valueType.vector, valueType.string],\n variadic: -1,\n returnType: valueType.vector,\n },\n sort_by_label_desc: {\n name: 'sort_by_label_desc',\n argTypes: [valueType.vector, valueType.string],\n variadic: -1,\n returnType: valueType.vector,\n },\n sort_desc: { name: 'sort_desc', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sqrt: { name: 'sqrt', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n stddev_over_time: {\n name: 'stddev_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n stdvar_over_time: {\n name: 'stdvar_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n sum_over_time: { name: 'sum_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n tan: { name: 'tan', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n tanh: { name: 'tanh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n time: { name: 'time', argTypes: [], variadic: 0, returnType: valueType.scalar },\n timestamp: { name: 'timestamp', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n vector: { name: 'vector', argTypes: [valueType.scalar], variadic: 0, returnType: valueType.vector },\n year: { name: 'year', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n};\n"],"names":["valueType","functionSignatures","abs","name","argTypes","vector","variadic","returnType","absent","absent_over_time","matrix","acos","acosh","asin","asinh","atan","atanh","avg_over_time","ceil","changes","clamp","scalar","clamp_max","clamp_min","cos","cosh","count_over_time","day_of_month","day_of_week","day_of_year","days_in_month","deg","delta","deriv","exp","floor","histogram_avg","histogram_count","histogram_fraction","histogram_quantile","histogram_stddev","histogram_stdvar","histogram_sum","double_exponential_smoothing","hour","idelta","increase","irate","label_join","string","label_replace","last_over_time","ln","log10","log2","mad_over_time","max_over_time","min_over_time","minute","month","pi","predict_linear","present_over_time","quantile_over_time","rad","rate","resets","round","sgn","sin","sinh","sort","sort_by_label","sort_by_label_desc","sort_desc","sqrt","stddev_over_time","stdvar_over_time","sum_over_time","tan","tanh","time","timestamp","year"],"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,wJAAwJ;AAExJ,SAASA,SAAS,QAAc,QAAQ;AAExC,OAAO,MAAMC,qBAA2C;IACtDC,KAAK;QAAEC,MAAM;QAAOC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;IAC5FG,QAAQ;QAAEL,MAAM;QAAUC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;IAClGI,kBAAkB;QAChBN,MAAM;QACNC,UAAU;YAACJ,UAAUU,MAAM;SAAC;QAC5BJ,UAAU;QACVC,YAAYP,UAAUK,MAAM;IAC9B;IACAM,MAAM;QAAER,MAAM;QAAQC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;IAC9FO,OAAO;QAAET,MAAM;QAASC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC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AM;QAAQC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;AAChG,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/promql/functionSignatures.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/functionSignatures.ts\n\nimport { valueType, Func } from './ast';\n\nexport const functionSignatures: Record<string, Func> = {\n abs: { name: 'abs', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n absent: { name: 'absent', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n absent_over_time: {\n name: 'absent_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n acos: { name: 'acos', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n acosh: { name: 'acosh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n asin: { name: 'asin', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n asinh: { name: 'asinh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n atan: { name: 'atan', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n atanh: { name: 'atanh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n avg_over_time: { name: 'avg_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n ceil: { name: 'ceil', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n changes: { name: 'changes', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n clamp: {\n name: 'clamp',\n argTypes: [valueType.vector, valueType.scalar, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n clamp_max: {\n name: 'clamp_max',\n argTypes: [valueType.vector, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n clamp_min: {\n name: 'clamp_min',\n argTypes: [valueType.vector, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n cos: { name: 'cos', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n cosh: { name: 'cosh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n count_over_time: { name: 'count_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n day_of_month: { name: 'day_of_month', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n day_of_week: { name: 'day_of_week', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n day_of_year: { name: 'day_of_year', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n days_in_month: { name: 'days_in_month', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n deg: { name: 'deg', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n delta: { name: 'delta', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n deriv: { name: 'deriv', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n exp: { name: 'exp', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n floor: { name: 'floor', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n histogram_avg: { name: 'histogram_avg', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n histogram_count: { name: 'histogram_count', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n histogram_fraction: {\n name: 'histogram_fraction',\n argTypes: [valueType.scalar, valueType.scalar, valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_quantile: {\n name: 'histogram_quantile',\n argTypes: [valueType.scalar, valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_stddev: {\n name: 'histogram_stddev',\n argTypes: [valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_stdvar: {\n name: 'histogram_stdvar',\n argTypes: [valueType.vector],\n variadic: 0,\n returnType: valueType.vector,\n },\n histogram_sum: { name: 'histogram_sum', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n double_exponential_smoothing: {\n name: 'double_exponential_smoothing',\n argTypes: [valueType.matrix, valueType.scalar, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n hour: { name: 'hour', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n idelta: { name: 'idelta', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n increase: { name: 'increase', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n irate: { name: 'irate', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n label_join: {\n name: 'label_join',\n argTypes: [valueType.vector, valueType.string, valueType.string, valueType.string],\n variadic: -1,\n returnType: valueType.vector,\n },\n label_replace: {\n name: 'label_replace',\n argTypes: [valueType.vector, valueType.string, valueType.string, valueType.string, valueType.string],\n variadic: 0,\n returnType: valueType.vector,\n },\n last_over_time: { name: 'last_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n ln: { name: 'ln', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n log10: { name: 'log10', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n log2: { name: 'log2', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n mad_over_time: { name: 'mad_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n max_over_time: { name: 'max_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n min_over_time: { name: 'min_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n minute: { name: 'minute', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n month: { name: 'month', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n pi: { name: 'pi', argTypes: [], variadic: 0, returnType: valueType.scalar },\n predict_linear: {\n name: 'predict_linear',\n argTypes: [valueType.matrix, valueType.scalar],\n variadic: 0,\n returnType: valueType.vector,\n },\n present_over_time: {\n name: 'present_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n quantile_over_time: {\n name: 'quantile_over_time',\n argTypes: [valueType.scalar, valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n rad: { name: 'rad', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n rate: { name: 'rate', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n resets: { name: 'resets', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n round: { name: 'round', argTypes: [valueType.vector, valueType.scalar], variadic: 1, returnType: valueType.vector },\n scalar: { name: 'scalar', argTypes: [valueType.vector], variadic: 0, returnType: valueType.scalar },\n sgn: { name: 'sgn', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sin: { name: 'sin', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sinh: { name: 'sinh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sort: { name: 'sort', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sort_by_label: {\n name: 'sort_by_label',\n argTypes: [valueType.vector, valueType.string],\n variadic: -1,\n returnType: valueType.vector,\n },\n sort_by_label_desc: {\n name: 'sort_by_label_desc',\n argTypes: [valueType.vector, valueType.string],\n variadic: -1,\n returnType: valueType.vector,\n },\n sort_desc: { name: 'sort_desc', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n sqrt: { name: 'sqrt', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n stddev_over_time: {\n name: 'stddev_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n stdvar_over_time: {\n name: 'stdvar_over_time',\n argTypes: [valueType.matrix],\n variadic: 0,\n returnType: valueType.vector,\n },\n sum_over_time: { name: 'sum_over_time', argTypes: [valueType.matrix], variadic: 0, returnType: valueType.vector },\n tan: { name: 'tan', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n tanh: { name: 'tanh', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n time: { name: 'time', argTypes: [], variadic: 0, returnType: valueType.scalar },\n timestamp: { name: 'timestamp', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },\n vector: { name: 'vector', argTypes: [valueType.scalar], variadic: 0, returnType: valueType.vector },\n year: { name: 'year', argTypes: [valueType.vector], variadic: 1, returnType: valueType.vector },\n};\n"],"names":["valueType","functionSignatures","abs","name","argTypes","vector","variadic","returnType","absent","absent_over_time","matrix","acos","acosh","asin","asinh","atan","atanh","avg_over_time","ceil","changes","clamp","scalar","clamp_max","clamp_min","cos","cosh","count_over_time","day_of_month","day_of_week","day_of_year","days_in_month","deg","delta","deriv","exp","floor","histogram_avg","histogram_count","histogram_fraction","histogram_quantile","histogram_stddev","histogram_stdvar","histogram_sum","double_exponential_smoothing","hour","idelta","increase","irate","label_join","string","label_replace","last_over_time","ln","log10","log2","mad_over_time","max_over_time","min_over_time","minute","month","pi","predict_linear","present_over_time","quantile_over_time","rad","rate","resets","round","sgn","sin","sinh","sort","sort_by_label","sort_by_label_desc","sort_desc","sqrt","stddev_over_time","stdvar_over_time","sum_over_time","tan","tanh","time","timestamp","year"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,wJAAwJ;AAExJ,SAASA,SAAS,QAAc,QAAQ;AAExC,OAAO,MAAMC,qBAA2C;IACtDC,KAAK;QAAEC,MAAM;QAAOC,UAAU;YAACJ,UAA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AAUK,MAAM;IAAC;IAC5F2E,MAAM;QAAE7E,MAAM;QAAQC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;IAC9F4E,MAAM;QAAE9E,MAAM;QAAQC,UAAU,EAAE;QAAEE,UAAU;QAAGC,YAAYP,UAAUqB,MAAM;IAAC;IAC9E6D,WAAW;QAAE/E,MAAM;QAAaC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;IACxGA,QAAQ;QAAEF,MAAM;QAAUC,UAAU;YAACJ,UAAUqB,MAAM;SAAC;QAAEf,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;IAClG8E,MAAM;QAAEhF,MAAM;QAAQC,UAAU;YAACJ,UAAUK,MAAM;SAAC;QAAEC,UAAU;QAAGC,YAAYP,UAAUK,MAAM;IAAC;AAChG,EAAE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/promql/serialize.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/serialize.ts\n\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 { aggregatorsWithParam, maybeParenthesizeBinopChild, escapeString } from './utils';\n\nconst serializeAtAndOffset = (timestamp: number | null, startOrEnd: StartOrEnd, offset: number): string =>\n `${timestamp !== null ? ` @ ${(timestamp / 1000).toFixed(3)}` : startOrEnd !== null ? ` @ ${startOrEnd}()` : ''}${\n offset === 0\n ? ''\n : offset > 0\n ? ` offset ${formatDuration(msToPrometheusDuration(offset))}`\n : ` offset -${formatDuration(msToPrometheusDuration(-offset))}`\n }`;\n\nconst serializeSelector = (node: VectorSelector | MatrixSelector): string => {\n const matchers = node.matchers\n .filter((m) => !(m.name === '__name__' && m.type === matchType.equal && m.value === node.name))\n .map((m) => `${m.name}${m.type}\"${escapeString(m.value)}\"`);\n\n const range = node.type === nodeType.matrixSelector ? `[${formatDuration(msToPrometheusDuration(node.range))}]` : '';\n const atAndOffset = serializeAtAndOffset(node.timestamp, node.startOrEnd, node.offset);\n\n return `${node.name}${matchers.length > 0 ? `{${matchers.join(',')}}` : ''}${range}${atAndOffset}`;\n};\n\nconst serializeNode = (node: ASTNode, indent = 0, pretty = false, initialIndent = true): string => {\n const childListSeparator = pretty ? '\\n' : '';\n const childSeparator = pretty ? '\\n' : ' ';\n const childIndent = indent + 2;\n const ind = pretty ? ' '.repeat(indent) : '';\n // Needed for unary operators.\n const initialInd = initialIndent ? ind : '';\n\n switch (node.type) {\n case nodeType.aggregation:\n return `${initialInd}${node.op}${\n node.without\n ? ` without(${node.grouping.join(', ')}) `\n : node.grouping.length > 0\n ? ` by(${node.grouping.join(', ')}) `\n : ''\n }(${childListSeparator}${\n aggregatorsWithParam.includes(node.op) && node.param !== null\n ? `${serializeNode(node.param, childIndent, pretty)},${childSeparator}`\n : ''\n }${serializeNode(node.expr, childIndent, pretty)}${childListSeparator}${ind})`;\n\n case nodeType.subquery:\n return `${initialInd}${serializeNode(node.expr, indent, pretty)}[${formatDuration(msToPrometheusDuration(node.range))}:${\n node.step !== 0 ? formatDuration(msToPrometheusDuration(node.step)) : ''\n }]${serializeAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}`;\n\n case nodeType.parenExpr:\n return `${initialInd}(${childListSeparator}${serializeNode(\n node.expr,\n childIndent,\n pretty\n )}${childListSeparator}${ind})`;\n\n case nodeType.call: {\n const sep = node.args.length > 0 ? childListSeparator : '';\n\n return `${initialInd}${node.func.name}(${sep}${node.args\n .map((arg) => serializeNode(arg, childIndent, pretty))\n .join(',' + childSeparator)}${sep}${node.args.length > 0 ? ind : ''})`;\n }\n\n case nodeType.matrixSelector:\n return `${initialInd}${serializeSelector(node)}`;\n\n case nodeType.vectorSelector:\n return `${initialInd}${serializeSelector(node)}`;\n\n case nodeType.numberLiteral:\n return `${initialInd}${node.val}`;\n\n case nodeType.stringLiteral:\n return `${initialInd}\"${escapeString(node.val)}\"`;\n\n case nodeType.unaryExpr:\n return `${initialInd}${node.op}${serializeNode(node.expr, indent, pretty, false)}`;\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 = ` on(${vm.labels.join(', ')})`;\n } else {\n matching = ` ignoring(${vm.labels.join(', ')})`;\n }\n\n if (vm.card === vectorMatchCardinality.manyToOne || vm.card === vectorMatchCardinality.oneToMany) {\n grouping = ` group_${vm.card === vectorMatchCardinality.manyToOne ? 'left' : 'right'}(${vm.include.join(',')})`;\n }\n }\n\n return `${serializeNode(maybeParenthesizeBinopChild(node.op, node.lhs), childIndent, pretty)}${childSeparator}${ind}${\n node.op\n }${node.bool ? ' bool' : ''}${matching}${grouping}${childSeparator}${serializeNode(\n maybeParenthesizeBinopChild(node.op, node.rhs),\n childIndent,\n pretty\n )}`;\n }\n\n case nodeType.placeholder:\n // TODO: Should we just throw an error when trying to serialize an AST containing a placeholder node?\n // (that would currently break editing-as-text of ASTs that contain placeholders)\n return `${initialInd}…${\n node.children.length > 0\n ? `(${childListSeparator}${node.children\n .map((child) => serializeNode(child, childIndent, pretty))\n .join(',' + childSeparator)}${childListSeparator}${ind})`\n : ''\n }`;\n\n default:\n throw new Error('unsupported node type');\n }\n};\n\nexport default serializeNode;\n"],"names":["formatDuration","msToPrometheusDuration","matchType","vectorMatchCardinality","nodeType","aggregatorsWithParam","maybeParenthesizeBinopChild","escapeString","serializeAtAndOffset","timestamp","startOrEnd","offset","toFixed","serializeSelector","node","matchers","filter","m","name","type","equal","value","map","range","matrixSelector","atAndOffset","length","join","serializeNode","indent","pretty","initialIndent","childListSeparator","childSeparator","childIndent","ind","repeat","initialInd","aggregation","op","without","grouping","includes","param","expr","subquery","step","parenExpr","call","sep","args","func","arg","vectorSelector","numberLiteral","val","stringLiteral","unaryExpr","binaryExpr","matching","vm","labels","on","card","manyToOne","oneToMany","include","lhs","bool","rhs","placeholder","children","child","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,+IAA+I;AAE/I,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,mBAAmB;AAC1E,SAEEC,SAAS,EACTC,sBAAsB,EACtBC,QAAQ,QAGH,QAAQ;AACf,SAASC,oBAAoB,EAAEC,2BAA2B,EAAEC,YAAY,QAAQ,UAAU;AAE1F,MAAMC,uBAAuB,CAACC,WAA0BC,YAAwBC,SAC9E,GAAGF,cAAc,OAAO,CAAC,GAAG,EAAE,AAACA,CAAAA,YAAY,IAAG,EAAGG,OAAO,CAAC,IAAI,GAAGF,eAAe,OAAO,CAAC,GAAG,EAAEA,WAAW,EAAE,CAAC,GAAG,KAC3GC,WAAW,IACP,KACAA,SAAS,IACP,CAAC,QAAQ,EAAEX,eAAeC,uBAAuBU,UAAU,GAC3D,CA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cAActB,4BAA4BQ,KAAKyB,EAAE,EAAEzB,KAAKqD,GAAG,GAAGjC,aAAaJ,UAAUG,iBAAiBE,MAC9GrB,KAAKyB,EAAE,GACNzB,KAAKsD,IAAI,GAAG,UAAU,KAAKT,WAAWlB,WAAWR,iBAAiBL,cACnEtB,4BAA4BQ,KAAKyB,EAAE,EAAEzB,KAAKuD,GAAG,GAC7CnC,aACAJ,SACC;YACL;QAEA,KAAK1B,SAASkE,WAAW;YACvB,qGAAqG;YACrG,iFAAiF;YACjF,OAAO,GAAGjC,WAAW,CAAC,EACpBvB,KAAKyD,QAAQ,CAAC7C,MAAM,GAAG,IACnB,CAAC,CAAC,EAAEM,qBAAqBlB,KAAKyD,QAAQ,CACnCjD,GAAG,CAAC,CAACkD,QAAU5C,cAAc4C,OAAOtC,aAAaJ,SACjDH,IAAI,CAAC,MAAMM,kBAAkBD,qBAAqBG,IAAI,CAAC,CAAC,GAC3D,IACJ;QAEJ;YACE,MAAM,IAAIsC,MAAM;IACpB;AACF;AAEA,eAAe7C,cAAc"}
1
+ {"version":3,"sources":["../../../../src/components/promql/serialize.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/serialize.ts\n\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 { aggregatorsWithParam, maybeParenthesizeBinopChild, escapeString } from './utils';\n\nconst serializeAtAndOffset = (timestamp: number | null, startOrEnd: StartOrEnd, offset: number): string =>\n `${timestamp !== null ? ` @ ${(timestamp / 1000).toFixed(3)}` : startOrEnd !== null ? ` @ ${startOrEnd}()` : ''}${\n offset === 0\n ? ''\n : offset > 0\n ? ` offset ${formatDuration(msToPrometheusDuration(offset))}`\n : ` offset -${formatDuration(msToPrometheusDuration(-offset))}`\n }`;\n\nconst serializeSelector = (node: VectorSelector | MatrixSelector): string => {\n const matchers = node.matchers\n .filter((m) => !(m.name === '__name__' && m.type === matchType.equal && m.value === node.name))\n .map((m) => `${m.name}${m.type}\"${escapeString(m.value)}\"`);\n\n const range = node.type === nodeType.matrixSelector ? `[${formatDuration(msToPrometheusDuration(node.range))}]` : '';\n const atAndOffset = serializeAtAndOffset(node.timestamp, node.startOrEnd, node.offset);\n\n return `${node.name}${matchers.length > 0 ? `{${matchers.join(',')}}` : ''}${range}${atAndOffset}`;\n};\n\nconst serializeNode = (node: ASTNode, indent = 0, pretty = false, initialIndent = true): string => {\n const childListSeparator = pretty ? '\\n' : '';\n const childSeparator = pretty ? '\\n' : ' ';\n const childIndent = indent + 2;\n const ind = pretty ? ' '.repeat(indent) : '';\n // Needed for unary operators.\n const initialInd = initialIndent ? ind : '';\n\n switch (node.type) {\n case nodeType.aggregation:\n return `${initialInd}${node.op}${\n node.without\n ? ` without(${node.grouping.join(', ')}) `\n : node.grouping.length > 0\n ? ` by(${node.grouping.join(', ')}) `\n : ''\n }(${childListSeparator}${\n aggregatorsWithParam.includes(node.op) && node.param !== null\n ? `${serializeNode(node.param, childIndent, pretty)},${childSeparator}`\n : ''\n }${serializeNode(node.expr, childIndent, pretty)}${childListSeparator}${ind})`;\n\n case nodeType.subquery:\n return `${initialInd}${serializeNode(node.expr, indent, pretty)}[${formatDuration(msToPrometheusDuration(node.range))}:${\n node.step !== 0 ? formatDuration(msToPrometheusDuration(node.step)) : ''\n }]${serializeAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}`;\n\n case nodeType.parenExpr:\n return `${initialInd}(${childListSeparator}${serializeNode(\n node.expr,\n childIndent,\n pretty\n )}${childListSeparator}${ind})`;\n\n case nodeType.call: {\n const sep = node.args.length > 0 ? childListSeparator : '';\n\n return `${initialInd}${node.func.name}(${sep}${node.args\n .map((arg) => serializeNode(arg, childIndent, pretty))\n .join(',' + childSeparator)}${sep}${node.args.length > 0 ? ind : ''})`;\n }\n\n case nodeType.matrixSelector:\n return `${initialInd}${serializeSelector(node)}`;\n\n case nodeType.vectorSelector:\n return `${initialInd}${serializeSelector(node)}`;\n\n case nodeType.numberLiteral:\n return `${initialInd}${node.val}`;\n\n case nodeType.stringLiteral:\n return `${initialInd}\"${escapeString(node.val)}\"`;\n\n case nodeType.unaryExpr:\n return `${initialInd}${node.op}${serializeNode(node.expr, indent, pretty, false)}`;\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 = ` on(${vm.labels.join(', ')})`;\n } else {\n matching = ` ignoring(${vm.labels.join(', ')})`;\n }\n\n if (vm.card === vectorMatchCardinality.manyToOne || vm.card === vectorMatchCardinality.oneToMany) {\n grouping = ` group_${vm.card === vectorMatchCardinality.manyToOne ? 'left' : 'right'}(${vm.include.join(',')})`;\n }\n }\n\n return `${serializeNode(maybeParenthesizeBinopChild(node.op, node.lhs), childIndent, pretty)}${childSeparator}${ind}${\n node.op\n }${node.bool ? ' bool' : ''}${matching}${grouping}${childSeparator}${serializeNode(\n maybeParenthesizeBinopChild(node.op, node.rhs),\n childIndent,\n pretty\n )}`;\n }\n\n case nodeType.placeholder:\n // TODO: Should we just throw an error when trying to serialize an AST containing a placeholder node?\n // (that would currently break editing-as-text of ASTs that contain placeholders)\n return `${initialInd}…${\n node.children.length > 0\n ? `(${childListSeparator}${node.children\n .map((child) => serializeNode(child, childIndent, pretty))\n .join(',' + childSeparator)}${childListSeparator}${ind})`\n : ''\n }`;\n\n default:\n throw new Error('unsupported node type');\n }\n};\n\nexport default serializeNode;\n"],"names":["formatDuration","msToPrometheusDuration","matchType","vectorMatchCardinality","nodeType","aggregatorsWithParam","maybeParenthesizeBinopChild","escapeString","serializeAtAndOffset","timestamp","startOrEnd","offset","toFixed","serializeSelector","node","matchers","filter","m","name","type","equal","value","map","range","matrixSelector","atAndOffset","length","join","serializeNode","indent","pretty","initialIndent","childListSeparator","childSeparator","childIndent","ind","repeat","initialInd","aggregation","op","without","grouping","includes","param","expr","subquery","step","parenExpr","call","sep","args","func","arg","vectorSelector","numberLiteral","val","stringLiteral","unaryExpr","binaryExpr","matching","vm","labels","on","card","manyToOne","oneToMany","include","lhs","bool","rhs","placeholder","children","child","Error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,+IAA+I;AAE/I,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,mBAAmB;AAC1E,SAEEC,SAAS,EACTC,sBAAsB,EACtBC,QAAQ,QAGH,QAAQ;AACf,SAASC,oBAAoB,EAAEC,2BAA2B,EAAEC,YAAY,QAAQ,UAAU;AAE1F,MAAMC,uBAAuB,CAACC,WAA0BC,YAAwBC,SAC9E,GAAGF,cAAc,OAAO,CAAC,GAAG,EAAE,AAACA,CAAAA,YAAY,IAAG,EAAGG,OAAO,CAAC,IAAI,GAAGF,eAAe,OAAO,CAAC,GAAG,EAAEA,WAAW,EAAE,CAAC,GAAG,KAC3GC,WAAW,IACP,KACAA,SAAS,IACP,CAAC,QAAQ,EAAEX,eAAeC,uBAAuBU,UAAU,GAC3D,CAAC,SAAS,EAAEX,eAAeC,uBAAuB,CAACU,UAAU,EACnE;AAEJ,MAAME,oBAAoB,CAACC;IACzB,MAAMC,WAAWD,KAAKC,QAA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E,GACNzB,KAAKsD,IAAI,GAAG,UAAU,KAAKT,WAAWlB,WAAWR,iBAAiBL,cACnEtB,4BAA4BQ,KAAKyB,EAAE,EAAEzB,KAAKuD,GAAG,GAC7CnC,aACAJ,SACC;YACL;QAEA,KAAK1B,SAASkE,WAAW;YACvB,qGAAqG;YACrG,iFAAiF;YACjF,OAAO,GAAGjC,WAAW,CAAC,EACpBvB,KAAKyD,QAAQ,CAAC7C,MAAM,GAAG,IACnB,CAAC,CAAC,EAAEM,qBAAqBlB,KAAKyD,QAAQ,CACnCjD,GAAG,CAAC,CAACkD,QAAU5C,cAAc4C,OAAOtC,aAAaJ,SACjDH,IAAI,CAAC,MAAMM,kBAAkBD,qBAAqBG,IAAI,CAAC,CAAC,GAC3D,IACJ;QAEJ;YACE,MAAM,IAAIsC,MAAM;IACpB;AACF;AAEA,eAAe7C,cAAc"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/promql/utils.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\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 aggregatorsWithParam = ['topk', 'bottomk', 'quantile', 'count_values', 'limitk', 'limit_ratio'];\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","aggregatorsWithParam","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;IAC1B,CAACb,mBAAmBc,GAAG,CAAC,EAAE;IAC1B,CAACd,mBAAmBe,GAAG,CAAC,EAAE;IAC1B,CAACf,mBAAmBgB,EAAE,CAAC,EAAE;IACzB,CAAChB,mBAAmBiB,MAAM,CAAC,EAAE;IAC7B,CAACjB,mBAAmBkB,KAAK,CAAC,EAAE;AAC9B;AAEA,OAAO,MAAMC,8BAA8B,CAACC,IAAwBC;IAClE,IAAIA,MAAMC,IAAI,KAAKrB,SAASsB,UAAU,EAAE;QACtC,OAAOF;IACT;IAEA,IAAInB,eAAe,CAACkB,GAAG,GAAGlB,eAAe,CAACmB,MAAMD,EAAE,CAAC,EAAE;QACnD,OAAOC;IACT;IAEA,+EAA+E;IAC/E,sDAAsD;IACtD,OAAO;QACLC,MAAMrB,SAASuB,SAAS;QACxBC,MAAMJ;IACR;AACF,EAAE;AAEF,OAAO,MAAMK,kBAAkB,CAACC;IAC9B,OAAQA,KAAKL,IAAI;QACf,KAAKrB,SAAS2B,WAAW;YACvB,OAAOD,KAAKE,KAAK,KAAK,OAAO;gBAACF,KAAKF,IAAI;aAAC,GAAG;gBAACE,KAAKE,KAAK;gBAAEF,KAAKF,IAAI;aAAC;QACpE,KAAKxB,SAAS6B,QAAQ;YACpB,OAAO;gBAACH,KAAKF,IAAI;aAAC;QACpB,KAAKxB,SAASuB,SAAS;YACrB,OAAO;gBAACG,KAAKF,IAAI;aAAC;QACpB,KAAKxB,SAAS8B,IAAI;YAChB,OAAOJ,KAAKK,IAAI;QAClB,KAAK/B,SAASgC,cAAc;QAC5B,KAAKhC,SAASiC,cAAc;QAC5B,KAAKjC,SAASkC,aAAa;QAC3B,KAAKlC,SAASmC,aAAa;YACzB,OAAO,EAAE;QACX,KAAKnC,SAASoC,WAAW;YACvB,OAAOV,KAAKW,QAAQ;QACtB,KAAKrC,SAASsC,SAAS;YACrB,OAAO;gBAACZ,KAAKF,IAAI;aAAC;QACpB,KAAKxB,SAASsB,UAAU;YACtB,OAAO;gBAACI,KAAKa,GAAG;gBAAEb,KAAKc,GAAG;aAAC;QAC7B;YACE,MAAM,IAAIC,MAAM;IACpB;AACF,EAAE;AAEF,OAAO,MAAMC,uBAAuB;IAAC;IAAQ;IAAW;IAAY;IAAgB;IAAU;CAAc,CAAC;AAE7G,OAAO,MAAMC,eAAe,CAACC;IAC3B,OAAOA,IAAIC,OAAO,CAAC,YAAY;AACjC,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/promql/utils.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\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 aggregatorsWithParam = ['topk', 'bottomk', 'quantile', 'count_values', 'limitk', 'limit_ratio'];\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","aggregatorsWithParam","escapeString","str","replace"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,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;IAC1B,CAACb,mBAAmBc,GAAG,CAAC,EAAE;IAC1B,CAACd,mBAAmBe,GAAG,CAAC,EAAE;IAC1B,CAACf,mB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,MAAMC,uBAAuB;IAAC;IAAQ;IAAW;IAAY;IAAgB;IAAU;CAAc,CAAC;AAE7G,OAAO,MAAMC,eAAe,CAACC;IAC3B,OAAOA,IAAIC,OAAO,CAAC,YAAY;AACjC,EAAE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/query.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useDatasourceClient } from '@perses-dev/plugin-system';\nimport { DatasourceSelector, StatusError } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport {\n InstantQueryRequestParameters,\n MonitoredInstantQueryResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n PrometheusClient,\n} 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\nexport function useInstantQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<MonitoredInstantQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<MonitoredInstantQueryResponse, StatusError>({\n enabled: !!client && enabled,\n // TODO: for some reason the caching is not working: identical nodes still fire their requests after each change made to the promQL\n queryKey: ['instantQuery', content, 'datasource', datasource.kind],\n queryFn: async () => {\n const params: InstantQueryRequestParameters = { query: content };\n const startTime = performance.now();\n const response = await client!.instantQuery(params);\n const responseTime = performance.now() - startTime;\n\n return { ...response, responseTime };\n },\n });\n}\n"],"names":["useDatasourceClient","useQuery","useParseQuery","content","datasource","enabled","data","client","queryKey","queryFn","params","query","parseQuery","useInstantQuery","kind","startTime","performance","now","response","instantQuery","responseTime"],"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;AASjE,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,SAAsC;gBAAEC,OAAOR;YAAQ;YAE7D,OAAO,MAAMI,OAAQK,UAAU,CAACF;QAClC;IACF;AACF;AAEA,OAAO,SAASG,gBACdV,OAAe,EACfC,UAA8B,EAC9BC,OAAiB;IAEjB,MAAM,EAAEC,MAAMC,MAAM,EAAE,GAAGP,oBAAsCI;IAE/D,OAAOH,SAAqD;QAC1DI,SAAS,CAAC,CAACE,UAAUF;QACrB,mIAAmI;QACnIG,UAAU;YAAC;YAAgBL;YAAS;YAAcC,WAAWU,IAAI;SAAC;QAClEL,SAAS;YACP,MAAMC,SAAwC;gBAAEC,OAAOR;YAAQ;YAC/D,MAAMY,YAAYC,YAAYC,GAAG;YACjC,MAAMC,WAAW,MAAMX,OAAQY,YAAY,CAACT;YAC5C,MAAMU,eAAeJ,YAAYC,GAAG,KAAKF;YAEzC,OAAO;gBAAE,GAAGG,QAAQ;gBAAEE;YAAa;QACrC;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/components/query.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useDatasourceClient } from '@perses-dev/plugin-system';\nimport { DatasourceSelector, StatusError } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport {\n InstantQueryRequestParameters,\n MonitoredInstantQueryResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n PrometheusClient,\n} 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\nexport function useInstantQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<MonitoredInstantQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<MonitoredInstantQueryResponse, StatusError>({\n enabled: !!client && enabled,\n // TODO: for some reason the caching is not working: identical nodes still fire their requests after each change made to the promQL\n queryKey: ['instantQuery', content, 'datasource', datasource.kind],\n queryFn: async () => {\n const params: InstantQueryRequestParameters = { query: content };\n const startTime = performance.now();\n const response = await client!.instantQuery(params);\n const responseTime = performance.now() - startTime;\n\n return { ...response, responseTime };\n },\n });\n}\n"],"names":["useDatasourceClient","useQuery","useParseQuery","content","datasource","enabled","data","client","queryKey","queryFn","params","query","parseQuery","useInstantQuery","kind","startTime","performance","now","response","instantQuery","responseTime"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,QAAQ,QAAwB,wBAAwB;AASjE,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,SAAsC;gBAAEC,OAAOR;YAAQ;YAE7D,OAAO,MAAMI,OAAQK,UAAU,CAACF;QAClC;IACF;AACF;AAEA,OAAO,SAASG,gBACdV,OAAe,EACfC,UAA8B,EAC9BC,OAAiB;IAEjB,MAAM,EAAEC,MAAMC,MAAM,EAAE,GAAGP,oBAAsCI;IAE/D,OAAOH,SAAqD;QAC1DI,SAAS,CAAC,CAACE,UAAUF;QACrB,mIAAmI;QACnIG,UAAU;YAAC;YAAgBL;YAAS;YAAcC,WAAWU,IAAI;SAAC;QAClEL,SAAS;YACP,MAAMC,SAAwC;gBAAEC,OAAOR;YAAQ;YAC/D,MAAMY,YAAYC,YAAYC,GAAG;YACjC,MAAMC,WAAW,MAAMX,OAAQY,YAAY,CAACT;YAC5C,MAAMU,eAAeJ,YAAYC,GAAG,KAAKF;YAEzC,OAAO;gBAAE,GAAGG,QAAQ;gBAAEE;YAAa;QACrC;IACF;AACF"}
package/lib/env.d.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/env.d.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/env.d.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/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
1
+ {"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at