@perses-dev/prometheus-plugin 0.48.0 → 0.49.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/components/PromQLEditor.js +209 -0
  2. package/dist/cjs/components/TreeNode.js +147 -0
  3. package/dist/cjs/components/index.js +1 -1
  4. package/dist/cjs/components/parse.js +42 -0
  5. package/dist/cjs/components/promql/ast.js +143 -0
  6. package/dist/cjs/components/promql/format.js +432 -0
  7. package/dist/cjs/components/promql/utils.js +109 -0
  8. package/dist/cjs/model/prometheus-client.js +10 -2
  9. package/dist/cjs/plugins/PrometheusDatasourceEditor.js +4 -0
  10. package/dist/cjs/plugins/prometheus-datasource.js +4 -0
  11. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +6 -5
  12. package/dist/cjs/plugins/prometheus-variables.js +4 -2
  13. package/dist/components/PromQLEditor.d.ts +9 -0
  14. package/dist/components/PromQLEditor.d.ts.map +1 -0
  15. package/dist/components/PromQLEditor.js +196 -0
  16. package/dist/components/PromQLEditor.js.map +1 -0
  17. package/dist/components/TreeNode.d.ts +10 -0
  18. package/dist/components/TreeNode.d.ts.map +1 -0
  19. package/dist/components/TreeNode.js +139 -0
  20. package/dist/components/TreeNode.js.map +1 -0
  21. package/dist/components/index.d.ts +1 -1
  22. package/dist/components/index.d.ts.map +1 -1
  23. package/dist/components/index.js +1 -1
  24. package/dist/components/index.js.map +1 -1
  25. package/dist/components/parse.d.ts +4 -0
  26. package/dist/components/parse.d.ts.map +1 -0
  27. package/dist/components/parse.js +34 -0
  28. package/dist/components/parse.js.map +1 -0
  29. package/dist/components/promql/ast.d.ts +161 -0
  30. package/dist/components/promql/ast.d.ts.map +1 -0
  31. package/dist/components/promql/ast.js +106 -0
  32. package/dist/components/promql/ast.js.map +1 -0
  33. package/dist/components/promql/format.d.ts +5 -0
  34. package/dist/components/promql/format.d.ts.map +1 -0
  35. package/dist/components/promql/format.js +411 -0
  36. package/dist/components/promql/format.js.map +1 -0
  37. package/dist/components/promql/utils.d.ts +5 -0
  38. package/dist/components/promql/utils.d.ts.map +1 -0
  39. package/dist/components/promql/utils.js +90 -0
  40. package/dist/components/promql/utils.js.map +1 -0
  41. package/dist/model/api-types.d.ts +5 -0
  42. package/dist/model/api-types.d.ts.map +1 -1
  43. package/dist/model/api-types.js.map +1 -1
  44. package/dist/model/prometheus-client.d.ts +6 -1
  45. package/dist/model/prometheus-client.d.ts.map +1 -1
  46. package/dist/model/prometheus-client.js +9 -2
  47. package/dist/model/prometheus-client.js.map +1 -1
  48. package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
  49. package/dist/plugins/PrometheusDatasourceEditor.js +4 -0
  50. package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -1
  51. package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
  52. package/dist/plugins/prometheus-datasource.js +5 -1
  53. package/dist/plugins/prometheus-datasource.js.map +1 -1
  54. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  55. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +6 -5
  56. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  57. package/dist/plugins/prometheus-variables.d.ts.map +1 -1
  58. package/dist/plugins/prometheus-variables.js +4 -2
  59. package/dist/plugins/prometheus-variables.js.map +1 -1
  60. package/package.json +4 -4
  61. package/dist/cjs/components/PromQL.js +0 -58
  62. package/dist/components/PromQL.d.ts +0 -7
  63. package/dist/components/PromQL.d.ts.map +0 -1
  64. package/dist/components/PromQL.js +0 -45
  65. package/dist/components/PromQL.js.map +0 -1
@@ -0,0 +1,209 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "PromQLEditor", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return PromQLEditor;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _reactcodemirror = /*#__PURE__*/ _interop_require_default(require("@uiw/react-codemirror"));
25
+ const _codemirrorpromql = require("@prometheus-io/codemirror-promql");
26
+ const _view = require("@codemirror/view");
27
+ const _material = require("@mui/material");
28
+ const _FileTree = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/FileTree"));
29
+ const _react = require("react");
30
+ const _components = require("@perses-dev/components");
31
+ const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
32
+ const _pluginsystem = require("@perses-dev/plugin-system");
33
+ const _parse = require("./parse");
34
+ const _TreeNode = /*#__PURE__*/ _interop_require_default(require("./TreeNode"));
35
+ function _interop_require_default(obj) {
36
+ return obj && obj.__esModule ? obj : {
37
+ default: obj
38
+ };
39
+ }
40
+ const treeViewStr = 'Tree View';
41
+ const treeViewOpenStr = 'Open ' + treeViewStr;
42
+ const treeViewCloseStr = 'Close ' + treeViewStr;
43
+ // Process the error to identify if it's a generic one & adjust the message in some cases
44
+ // TODO: This should be removed when properly tackling query error at query editor level (https://github.com/perses/perses/issues/1419)
45
+ // Here this was kinda a quick-win to do it like this with the implementation of the Tree view.
46
+ // Once #1419 will be tackled, any error reported by the query to the parse endpoint here should be treated the same (= display
47
+ // the error in the debug/tree view & always let the buttons accessible to show/hide it).
48
+ function processError(error) {
49
+ // Specific errors that user should be able to hide
50
+ const apiNotAvailableError = '404 page not found';
51
+ const apiNotAvailableErrorRephrased = `${treeViewStr} is available only for datasources whose APIs comply with Prometheus 3.0 specifications`;
52
+ const blockedByProxyError = 'forbidden access: you are not allowed to use this endpoint "/api/v1/parse_query" with the HTTP method POST';
53
+ const blockedByProxyErrorRephrased = `Your datasource configuration is blocking the ${treeViewStr} feature: the datasource should allow POST requests to "/api/v1/parse_query"`;
54
+ let errorMessage = 'An unknown error occurred';
55
+ let isGenericError = false;
56
+ if (error && error instanceof Error) {
57
+ errorMessage = error.message.trim();
58
+ if (errorMessage === apiNotAvailableError) {
59
+ errorMessage = apiNotAvailableErrorRephrased;
60
+ } else if (errorMessage === blockedByProxyError) {
61
+ errorMessage = blockedByProxyErrorRephrased;
62
+ } else {
63
+ isGenericError = true;
64
+ }
65
+ }
66
+ return {
67
+ errorMessage,
68
+ isGenericError
69
+ };
70
+ }
71
+ function PromQLEditor({ completeConfig, datasource, ...rest }) {
72
+ const theme = (0, _material.useTheme)();
73
+ const isDarkMode = theme.palette.mode === 'dark';
74
+ const [isTreeViewVisible, setTreeViewVisible] = (0, _react.useState)(false);
75
+ const promQLExtension = (0, _react.useMemo)(()=>{
76
+ return new _codemirrorpromql.PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();
77
+ }, [
78
+ completeConfig
79
+ ]);
80
+ const queryExpr = (0, _pluginsystem.useReplaceVariablesInString)(rest.value);
81
+ const { data: parseQueryResponse, isLoading, error } = (0, _parse.useParseQuery)(queryExpr !== null && queryExpr !== void 0 ? queryExpr : '', datasource);
82
+ const { errorMessage, isGenericError } = (0, _react.useMemo)(()=>processError(error), [
83
+ error
84
+ ]);
85
+ const handleShowTreeView = ()=>{
86
+ setTreeViewVisible(!isTreeViewVisible);
87
+ };
88
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
89
+ position: "relative",
90
+ children: [
91
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material // reproduce the same kind of input label that regular MUI TextFields have
92
+ .InputLabel, {
93
+ shrink: true,
94
+ sx: {
95
+ position: 'absolute',
96
+ top: '-8px',
97
+ left: '10px',
98
+ padding: '0 4px',
99
+ color: theme.palette.text.primary,
100
+ zIndex: 1
101
+ },
102
+ children: "PromQL Expression"
103
+ }),
104
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactcodemirror.default, {
105
+ ...rest,
106
+ style: {
107
+ border: `1px solid ${theme.palette.divider}`
108
+ },
109
+ theme: isDarkMode ? 'dark' : 'light',
110
+ basicSetup: {
111
+ highlightActiveLine: false,
112
+ highlightActiveLineGutter: false,
113
+ foldGutter: false
114
+ },
115
+ extensions: [
116
+ _view.EditorView.lineWrapping,
117
+ promQLExtension,
118
+ _view.EditorView.theme({
119
+ '.cm-content': {
120
+ paddingTop: '8px',
121
+ paddingBottom: '8px',
122
+ paddingRight: '40px'
123
+ }
124
+ })
125
+ ],
126
+ placeholder: "Example: sum(rate(http_requests_total[5m]))"
127
+ }),
128
+ queryExpr && /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
129
+ children: isGenericError ? // Display the error without any close button, tree view etc when it's a generic error
130
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
131
+ style: {
132
+ border: `1px solid ${theme.palette.divider}`
133
+ },
134
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
135
+ error: {
136
+ name: 'Parse query error',
137
+ message: errorMessage
138
+ }
139
+ })
140
+ }) : // Otherwise include the logic to show/hide the tree view
141
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
142
+ children: [
143
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
144
+ title: isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr,
145
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
146
+ "aria-label": isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr,
147
+ onClick: handleShowTreeView,
148
+ sx: {
149
+ position: 'absolute',
150
+ right: '5px',
151
+ top: '5px'
152
+ },
153
+ size: "small",
154
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FileTree.default, {
155
+ sx: {
156
+ fontSize: '18px'
157
+ }
158
+ })
159
+ })
160
+ }),
161
+ isTreeViewVisible && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
162
+ style: {
163
+ border: `1px solid ${theme.palette.divider}`,
164
+ position: 'relative'
165
+ },
166
+ children: [
167
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
168
+ title: treeViewCloseStr,
169
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
170
+ "aria-label": treeViewCloseStr,
171
+ onClick: ()=>setTreeViewVisible(false),
172
+ sx: {
173
+ position: 'absolute',
174
+ top: '5px',
175
+ right: '5px'
176
+ },
177
+ size: "small",
178
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {
179
+ sx: {
180
+ fontSize: '18px'
181
+ }
182
+ })
183
+ })
184
+ }),
185
+ error ? // Here the user is able to hide the error alert
186
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
187
+ error: {
188
+ name: `${treeViewStr} not available`,
189
+ message: errorMessage
190
+ }
191
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
192
+ style: {
193
+ padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`,
194
+ overflowX: 'auto',
195
+ backgroundColor: theme.palette.background.default
196
+ },
197
+ children: isLoading ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {}) : (parseQueryResponse === null || parseQueryResponse === void 0 ? void 0 : parseQueryResponse.data) ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_TreeNode.default, {
198
+ node: parseQueryResponse.data,
199
+ reverse: false
200
+ }) : null
201
+ })
202
+ ]
203
+ })
204
+ ]
205
+ })
206
+ })
207
+ ]
208
+ });
209
+ }
@@ -0,0 +1,147 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ // Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx
14
+ "use strict";
15
+ Object.defineProperty(exports, "__esModule", {
16
+ value: true
17
+ });
18
+ Object.defineProperty(exports, "default", {
19
+ enumerable: true,
20
+ get: function() {
21
+ return _default;
22
+ }
23
+ });
24
+ const _jsxruntime = require("react/jsx-runtime");
25
+ const _material = require("@mui/material");
26
+ const _react = require("react");
27
+ const _ast = require("./promql/ast");
28
+ const _utils = require("./promql/utils");
29
+ const _format = require("./promql/format");
30
+ // The indentation factor for each level of the tree.
31
+ const nodeIndent = 5;
32
+ const connectorWidth = nodeIndent * 5;
33
+ const TreeNode = ({ node, parentEl, reverse })=>{
34
+ const theme = (0, _material.useTheme)();
35
+ const children = (0, _utils.getNodeChildren)(node);
36
+ // A normal ref won't work properly here because the ref's `current` property
37
+ // going from `null` to defined won't trigger a re-render of the child
38
+ // component, since it's not a React state update. So we manually have to
39
+ // create a state update using a callback ref. See also
40
+ // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs
41
+ const [nodeEl, setNodeEl] = (0, _react.useState)(null);
42
+ const nodeRef = (0, _react.useCallback)((node)=>setNodeEl(node), []);
43
+ const [connectorStyle, setConnectorStyle] = (0, _react.useState)({
44
+ borderColor: theme.palette.grey['500'],
45
+ borderLeftStyle: 'solid',
46
+ borderLeftWidth: 2,
47
+ width: connectorWidth,
48
+ left: -connectorWidth
49
+ });
50
+ // Update the size and position of tree connector lines based on the node's and its parent's position.
51
+ (0, _react.useLayoutEffect)(()=>{
52
+ if (parentEl === undefined) {
53
+ // We're the root node.
54
+ return;
55
+ }
56
+ if (parentEl === null || nodeEl === null) {
57
+ // Either of the two connected nodes hasn't been rendered yet.
58
+ return;
59
+ }
60
+ const parentRect = parentEl.getBoundingClientRect();
61
+ const nodeRect = nodeEl.getBoundingClientRect();
62
+ if (reverse) {
63
+ setConnectorStyle((prevStyle)=>({
64
+ ...prevStyle,
65
+ top: 'calc(50% - 1px)',
66
+ bottom: nodeRect.bottom - parentRect.top,
67
+ borderTopLeftRadius: 10,
68
+ borderTopStyle: 'solid',
69
+ borderBottomLeftRadius: undefined
70
+ }));
71
+ } else {
72
+ setConnectorStyle((prevStyle)=>({
73
+ ...prevStyle,
74
+ top: parentRect.bottom - nodeRect.top,
75
+ bottom: 'calc(50% - 1px)',
76
+ borderBottomLeftRadius: 10,
77
+ borderBottomStyle: 'solid',
78
+ borderTopLeftRadius: undefined
79
+ }));
80
+ }
81
+ }, [
82
+ parentEl,
83
+ nodeEl,
84
+ reverse,
85
+ nodeRef,
86
+ setConnectorStyle
87
+ ]);
88
+ const innerNode = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
89
+ ref: nodeRef,
90
+ sx: {
91
+ position: 'relative',
92
+ display: 'inline-block',
93
+ padding: 1,
94
+ marginBottom: 1.5,
95
+ borderRadius: 2,
96
+ backgroundColor: theme.palette.background.code
97
+ },
98
+ children: [
99
+ parentEl !== undefined && // Connector line between this node and its parent.
100
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
101
+ sx: {
102
+ position: 'absolute',
103
+ display: 'inline-block',
104
+ ...connectorStyle
105
+ }
106
+ }),
107
+ (0, _format.formatNode)(node, false, 1)
108
+ ]
109
+ });
110
+ if (node.type === _ast.nodeType.binaryExpr) {
111
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
112
+ children: [
113
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
114
+ ml: nodeIndent,
115
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(TreeNode, {
116
+ node: children[0],
117
+ parentEl: nodeEl,
118
+ reverse: true
119
+ })
120
+ }),
121
+ innerNode,
122
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
123
+ ml: nodeIndent,
124
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(TreeNode, {
125
+ node: children[1],
126
+ parentEl: nodeEl,
127
+ reverse: false
128
+ })
129
+ })
130
+ ]
131
+ });
132
+ }
133
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
134
+ children: [
135
+ innerNode,
136
+ children.map((child, idx)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
137
+ ml: nodeIndent,
138
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(TreeNode, {
139
+ node: child,
140
+ parentEl: nodeEl,
141
+ reverse: false
142
+ })
143
+ }, idx))
144
+ ]
145
+ });
146
+ };
147
+ const _default = TreeNode;
@@ -14,7 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./PromQL"), exports);
17
+ _export_star(require("./PromQLEditor"), exports);
18
18
  function _export_star(from, to) {
19
19
  Object.keys(from).forEach(function(k) {
20
20
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,42 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "useParseQuery", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return useParseQuery;
21
+ }
22
+ });
23
+ const _pluginsystem = require("@perses-dev/plugin-system");
24
+ const _reactquery = require("@tanstack/react-query");
25
+ function useParseQuery(content, datasource) {
26
+ const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
27
+ return (0, _reactquery.useQuery)({
28
+ enabled: !!client,
29
+ queryKey: [
30
+ 'parseQuery',
31
+ content,
32
+ 'datasource',
33
+ datasource
34
+ ],
35
+ queryFn: async ()=>{
36
+ const params = {
37
+ query: content
38
+ };
39
+ return await client.parseQuery(params);
40
+ }
41
+ });
42
+ }
@@ -0,0 +1,143 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ // Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/ast.ts
14
+ "use strict";
15
+ Object.defineProperty(exports, "__esModule", {
16
+ value: true
17
+ });
18
+ function _export(target, all) {
19
+ for(var name in all)Object.defineProperty(target, name, {
20
+ enumerable: true,
21
+ get: all[name]
22
+ });
23
+ }
24
+ _export(exports, {
25
+ aggregationType: function() {
26
+ return aggregationType;
27
+ },
28
+ binaryOperatorType: function() {
29
+ return binaryOperatorType;
30
+ },
31
+ compOperatorTypes: function() {
32
+ return compOperatorTypes;
33
+ },
34
+ matchType: function() {
35
+ return matchType;
36
+ },
37
+ nodeType: function() {
38
+ return nodeType;
39
+ },
40
+ setOperatorTypes: function() {
41
+ return setOperatorTypes;
42
+ },
43
+ unaryOperatorType: function() {
44
+ return unaryOperatorType;
45
+ },
46
+ valueType: function() {
47
+ return valueType;
48
+ },
49
+ vectorMatchCardinality: function() {
50
+ return vectorMatchCardinality;
51
+ }
52
+ });
53
+ var nodeType;
54
+ (function(nodeType) {
55
+ nodeType["aggregation"] = "aggregation";
56
+ nodeType["binaryExpr"] = "binaryExpr";
57
+ nodeType["call"] = "call";
58
+ nodeType["matrixSelector"] = "matrixSelector";
59
+ nodeType["subquery"] = "subquery";
60
+ nodeType["numberLiteral"] = "numberLiteral";
61
+ nodeType["parenExpr"] = "parenExpr";
62
+ nodeType["stringLiteral"] = "stringLiteral";
63
+ nodeType["unaryExpr"] = "unaryExpr";
64
+ nodeType["vectorSelector"] = "vectorSelector";
65
+ nodeType["placeholder"] = "placeholder";
66
+ })(nodeType || (nodeType = {}));
67
+ var aggregationType;
68
+ (function(aggregationType) {
69
+ aggregationType["sum"] = "sum";
70
+ aggregationType["min"] = "min";
71
+ aggregationType["max"] = "max";
72
+ aggregationType["avg"] = "avg";
73
+ aggregationType["stddev"] = "stddev";
74
+ aggregationType["stdvar"] = "stdvar";
75
+ aggregationType["count"] = "count";
76
+ aggregationType["group"] = "group";
77
+ aggregationType["countValues"] = "count_values";
78
+ aggregationType["bottomk"] = "bottomk";
79
+ aggregationType["topk"] = "topk";
80
+ aggregationType["quantile"] = "quantile";
81
+ aggregationType["limitK"] = "limitk";
82
+ aggregationType["limitRatio"] = "limit_ratio";
83
+ })(aggregationType || (aggregationType = {}));
84
+ var binaryOperatorType;
85
+ (function(binaryOperatorType) {
86
+ binaryOperatorType["add"] = "+";
87
+ binaryOperatorType["sub"] = "-";
88
+ binaryOperatorType["mul"] = "*";
89
+ binaryOperatorType["div"] = "/";
90
+ binaryOperatorType["mod"] = "%";
91
+ binaryOperatorType["pow"] = "^";
92
+ binaryOperatorType["eql"] = "==";
93
+ binaryOperatorType["neq"] = "!=";
94
+ binaryOperatorType["gtr"] = ">";
95
+ binaryOperatorType["lss"] = "<";
96
+ binaryOperatorType["gte"] = ">=";
97
+ binaryOperatorType["lte"] = "<=";
98
+ binaryOperatorType["and"] = "and";
99
+ binaryOperatorType["or"] = "or";
100
+ binaryOperatorType["unless"] = "unless";
101
+ binaryOperatorType["atan2"] = "atan2";
102
+ })(binaryOperatorType || (binaryOperatorType = {}));
103
+ const compOperatorTypes = [
104
+ "==",
105
+ "!=",
106
+ ">",
107
+ "<",
108
+ ">=",
109
+ "<="
110
+ ];
111
+ const setOperatorTypes = [
112
+ "and",
113
+ "or",
114
+ "unless"
115
+ ];
116
+ var unaryOperatorType;
117
+ (function(unaryOperatorType) {
118
+ unaryOperatorType["plus"] = "+";
119
+ unaryOperatorType["minus"] = "-";
120
+ })(unaryOperatorType || (unaryOperatorType = {}));
121
+ var vectorMatchCardinality;
122
+ (function(vectorMatchCardinality) {
123
+ vectorMatchCardinality["oneToOne"] = "one-to-one";
124
+ vectorMatchCardinality["manyToOne"] = "many-to-one";
125
+ vectorMatchCardinality["oneToMany"] = "one-to-many";
126
+ vectorMatchCardinality["manyToMany"] = "many-to-many";
127
+ })(vectorMatchCardinality || (vectorMatchCardinality = {}));
128
+ var valueType;
129
+ (function(valueType) {
130
+ // TODO: 'none' should never make it out of Prometheus. Do we need this here?
131
+ valueType["none"] = "none";
132
+ valueType["vector"] = "vector";
133
+ valueType["scalar"] = "scalar";
134
+ valueType["matrix"] = "matrix";
135
+ valueType["string"] = "string";
136
+ })(valueType || (valueType = {}));
137
+ var matchType;
138
+ (function(matchType) {
139
+ matchType["equal"] = "=";
140
+ matchType["notEqual"] = "!=";
141
+ matchType["matchRegexp"] = "=~";
142
+ matchType["matchNotRegexp"] = "!~";
143
+ })(matchType || (matchType = {}));