@perses-dev/prometheus-plugin 0.10.0 → 0.12.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.
@@ -0,0 +1,81 @@
1
+ // Copyright 2022 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, "MatcherEditor", {
18
+ enumerable: true,
19
+ get: ()=>MatcherEditor
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _trashCan = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/TrashCan"));
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ function MatcherEditor(props) {
31
+ var _initialMatchers;
32
+ const [matchers, setMatchers] = (0, _react.useState)((_initialMatchers = props.initialMatchers) !== null && _initialMatchers !== void 0 ? _initialMatchers : []);
33
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
34
+ spacing: 1,
35
+ children: [
36
+ matchers.map((matcher, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
37
+ display: "flex",
38
+ children: [
39
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
40
+ fullWidth: true,
41
+ onBlur: ()=>{
42
+ props.onChange(matchers);
43
+ },
44
+ label: "Series Selector",
45
+ value: matcher,
46
+ onChange: (e)=>{
47
+ const newMatchers = [
48
+ ...matchers
49
+ ];
50
+ newMatchers[index] = e.target.value;
51
+ setMatchers(newMatchers);
52
+ }
53
+ }),
54
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
55
+ onClick: ()=>{
56
+ const newMatchers = [
57
+ ...matchers
58
+ ];
59
+ newMatchers.splice(index, 1);
60
+ setMatchers(newMatchers);
61
+ },
62
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_trashCan.default, {})
63
+ })
64
+ ]
65
+ }, index)),
66
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
67
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
68
+ fullWidth: false,
69
+ variant: "outlined",
70
+ onClick: ()=>{
71
+ setMatchers([
72
+ ...matchers,
73
+ ''
74
+ ]);
75
+ },
76
+ children: "Add Series Selector"
77
+ })
78
+ })
79
+ ]
80
+ });
81
+ }
@@ -50,6 +50,7 @@ function PrometheusTimeSeriesQueryEditor(props) {
50
50
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
51
51
  children: [
52
52
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
53
+ fullWidth: true,
53
54
  label: "Query",
54
55
  value: query,
55
56
  onChange: handleQueryChange,
@@ -24,8 +24,53 @@ _export(exports, {
24
24
  PrometheusLabelNamesVariable: ()=>PrometheusLabelNamesVariable,
25
25
  PrometheusLabelValuesVariable: ()=>PrometheusLabelValuesVariable
26
26
  });
27
+ const _jsxRuntime = require("react/jsx-runtime");
28
+ const _material = require("@mui/material");
27
29
  const _model = require("../model");
28
- const _jsonspecEditor = require("./JSONSpecEditor");
30
+ const _matcherEditor = require("./MatcherEditor");
31
+ function PrometheusLabelValuesVariableEditor(props) {
32
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
33
+ spacing: 1,
34
+ children: [
35
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
36
+ sx: {
37
+ mb: 1
38
+ },
39
+ label: "Label Name",
40
+ value: props.value.label_name,
41
+ onChange: (e)=>{
42
+ props.onChange({
43
+ ...props.value,
44
+ label_name: e.target.value
45
+ });
46
+ }
47
+ }),
48
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
49
+ initialMatchers: props.value.matchers,
50
+ onChange: (e)=>{
51
+ props.onChange({
52
+ ...props.value,
53
+ matchers: e
54
+ });
55
+ }
56
+ })
57
+ ]
58
+ });
59
+ }
60
+ function PrometheusLabelNamesVariableEditor(props) {
61
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
62
+ spacing: 1,
63
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
64
+ initialMatchers: props.value.matchers,
65
+ onChange: (e)=>{
66
+ props.onChange({
67
+ ...props.value,
68
+ matchers: e
69
+ });
70
+ }
71
+ })
72
+ });
73
+ }
29
74
  /**
30
75
  * Takes a list of strings and returns a list of VariableOptions
31
76
  */ const stringArrayToVariableOptions = (values)=>{
@@ -48,7 +93,7 @@ const PrometheusLabelNamesVariable = {
48
93
  };
49
94
  },
50
95
  dependsOn: ()=>[],
51
- OptionsEditorComponent: _jsonspecEditor.JSONSpecEditor,
96
+ OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
52
97
  createInitialOptions: ()=>({})
53
98
  };
54
99
  const PrometheusLabelValuesVariable = {
@@ -69,7 +114,7 @@ const PrometheusLabelValuesVariable = {
69
114
  var ref;
70
115
  return ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>(0, _model.parseTemplateVariables)(m)).flat()) || [];
71
116
  },
72
- OptionsEditorComponent: _jsonspecEditor.JSONSpecEditor,
117
+ OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
73
118
  createInitialOptions: ()=>({
74
119
  label_name: ''
75
120
  })
@@ -0,0 +1,16 @@
1
+ // Copyright 2022 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
+ });
@@ -18,7 +18,41 @@ Object.defineProperty(exports, "StaticListVariable", {
18
18
  enumerable: true,
19
19
  get: ()=>StaticListVariable
20
20
  });
21
- const _jsonspecEditor = require("./JSONSpecEditor");
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ function StaticListVariableOptionEditor(props) {
24
+ const value = props.value.values.map((v)=>{
25
+ if (typeof v === 'string') {
26
+ return v;
27
+ } else {
28
+ return v.value;
29
+ }
30
+ });
31
+ const onChange = (__, value)=>{
32
+ props.onChange({
33
+ values: value.map((v)=>{
34
+ return {
35
+ value: v,
36
+ label: v
37
+ };
38
+ })
39
+ });
40
+ };
41
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
42
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
43
+ multiple: true,
44
+ value: value,
45
+ onChange: onChange,
46
+ options: [],
47
+ freeSolo: true,
48
+ renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
49
+ ...params,
50
+ label: "Values",
51
+ placeholder: "Values"
52
+ })
53
+ })
54
+ });
55
+ }
22
56
  const StaticListVariable = {
23
57
  getVariableOptions: async (spec)=>{
24
58
  var ref;
@@ -36,7 +70,7 @@ const StaticListVariable = {
36
70
  };
37
71
  },
38
72
  dependsOn: ()=>[],
39
- OptionsEditorComponent: _jsonspecEditor.JSONSpecEditor,
73
+ OptionsEditorComponent: StaticListVariableOptionEditor,
40
74
  createInitialOptions: ()=>({
41
75
  values: []
42
76
  })
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare function MatcherEditor(props: {
3
+ initialMatchers?: string[];
4
+ onChange: (matchers: string[]) => void;
5
+ }): JSX.Element;
6
+ //# sourceMappingURL=MatcherEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MatcherEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/MatcherEditor.tsx"],"names":[],"mappings":";AAiBA,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;CAAE,eA2C1G"}
@@ -0,0 +1,70 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { useState } from 'react';
15
+ import { Stack, TextField, Button, Box, IconButton } from '@mui/material';
16
+ import TrashIcon from 'mdi-material-ui/TrashCan';
17
+ export function MatcherEditor(props) {
18
+ var _initialMatchers;
19
+ const [matchers, setMatchers] = useState((_initialMatchers = props.initialMatchers) !== null && _initialMatchers !== void 0 ? _initialMatchers : []);
20
+ return /*#__PURE__*/ _jsxs(Stack, {
21
+ spacing: 1,
22
+ children: [
23
+ matchers.map((matcher, index)=>/*#__PURE__*/ _jsxs(Box, {
24
+ display: "flex",
25
+ children: [
26
+ /*#__PURE__*/ _jsx(TextField, {
27
+ fullWidth: true,
28
+ onBlur: ()=>{
29
+ props.onChange(matchers);
30
+ },
31
+ label: "Series Selector",
32
+ value: matcher,
33
+ onChange: (e)=>{
34
+ const newMatchers = [
35
+ ...matchers
36
+ ];
37
+ newMatchers[index] = e.target.value;
38
+ setMatchers(newMatchers);
39
+ }
40
+ }),
41
+ /*#__PURE__*/ _jsx(IconButton, {
42
+ onClick: ()=>{
43
+ const newMatchers = [
44
+ ...matchers
45
+ ];
46
+ newMatchers.splice(index, 1);
47
+ setMatchers(newMatchers);
48
+ },
49
+ children: /*#__PURE__*/ _jsx(TrashIcon, {})
50
+ })
51
+ ]
52
+ }, index)),
53
+ /*#__PURE__*/ _jsx(Box, {
54
+ children: /*#__PURE__*/ _jsx(Button, {
55
+ fullWidth: false,
56
+ variant: "outlined",
57
+ onClick: ()=>{
58
+ setMatchers([
59
+ ...matchers,
60
+ ''
61
+ ]);
62
+ },
63
+ children: "Add Series Selector"
64
+ })
65
+ })
66
+ ]
67
+ });
68
+ }
69
+
70
+ //# sourceMappingURL=MatcherEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { useState } from 'react';\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\n\nexport function MatcherEditor(props: { initialMatchers?: string[]; onChange: (matchers: string[]) => void }) {\n const [matchers, setMatchers] = useState<string[]>(props.initialMatchers ?? []);\n return (\n <Stack spacing={1}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n onBlur={() => {\n props.onChange(matchers);\n }}\n label=\"Series Selector\"\n value={matcher}\n onChange={(e) => {\n const newMatchers = [...matchers];\n newMatchers[index] = e.target.value;\n setMatchers(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = [...matchers];\n newMatchers.splice(index, 1);\n setMatchers(newMatchers);\n }}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n variant=\"outlined\"\n onClick={() => {\n setMatchers([...matchers, '']);\n }}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["useState","Stack","TextField","Button","Box","IconButton","TrashIcon","MatcherEditor","props","matchers","setMatchers","initialMatchers","spacing","map","matcher","index","display","fullWidth","onBlur","onChange","label","value","e","newMatchers","target","onClick","splice","variant"],"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;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,OAAOC,SAAS,MAAM,0BAA0B,CAAC;AAEjD,OAAO,SAASC,aAAa,CAACC,KAA6E,EAAE;QACxDA,gBAAqB;IAAxE,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGV,QAAQ,CAAWQ,CAAAA,gBAAqB,GAArBA,KAAK,CAACG,eAAe,cAArBH,gBAAqB,cAArBA,gBAAqB,GAAI,EAAE,CAAC,AAAC;IAChF,qBACE,MAACP,KAAK;QAACW,OAAO,EAAE,CAAC;;YACdH,QAAQ,CAACI,GAAG,CAAC,CAACC,OAAO,EAAEC,KAAK,iBAC3B,MAACX,GAAG;oBAAaY,OAAO,EAAC,MAAM;;sCAC7B,KAACd,SAAS;4BACRe,SAAS;4BACTC,MAAM,EAAE,IAAM;gCACZV,KAAK,CAACW,QAAQ,CAACV,QAAQ,CAAC,CAAC;4BAC3B,CAAC;4BACDW,KAAK,EAAC,iBAAiB;4BACvBC,KAAK,EAAEP,OAAO;4BACdK,QAAQ,EAAE,CAACG,CAAC,GAAK;gCACf,MAAMC,WAAW,GAAG;uCAAId,QAAQ;iCAAC,AAAC;gCAClCc,WAAW,CAACR,KAAK,CAAC,GAAGO,CAAC,CAACE,MAAM,CAACH,KAAK,CAAC;gCACpCX,WAAW,CAACa,WAAW,CAAC,CAAC;4BAC3B,CAAC;0BACD;sCACF,KAAClB,UAAU;4BACToB,OAAO,EAAE,IAAM;gCACb,MAAMF,WAAW,GAAG;uCAAId,QAAQ;iCAAC,AAAC;gCAClCc,WAAW,CAACG,MAAM,CAACX,KAAK,EAAE,CAAC,CAAC,CAAC;gCAC7BL,WAAW,CAACa,WAAW,CAAC,CAAC;4BAC3B,CAAC;sCAED,cAAA,KAACjB,SAAS,KAAG;0BACF;;mBAtBLS,KAAK,CAuBT,AACP,CAAC;0BACF,KAACX,GAAG;0BACF,cAAA,KAACD,MAAM;oBACLc,SAAS,EAAE,KAAK;oBAChBU,OAAO,EAAC,UAAU;oBAClBF,OAAO,EAAE,IAAM;wBACbf,WAAW,CAAC;+BAAID,QAAQ;4BAAE,EAAE;yBAAC,CAAC,CAAC;oBACjC,CAAC;8BACF,qBAED;kBAAS;cACL;;MACA,CACR;AACJ,CAAC"}
@@ -37,6 +37,7 @@ export function PrometheusTimeSeriesQueryEditor(props) {
37
37
  return /*#__PURE__*/ _jsxs(Box, {
38
38
  children: [
39
39
  /*#__PURE__*/ _jsx(TextField, {
40
+ fullWidth: true,
40
41
  label: "Query",
41
42
  value: query,
42
43
  onChange: handleQueryChange,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { ChangeEvent } from 'react';\nimport produce from 'immer';\nimport { Box, TextField, FormControl, InputLabel } from '@mui/material';\nimport { OptionsEditorProps, DatasourceSelect, DatasourceSelectProps } from '@perses-dev/plugin-system';\nimport { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector } from '../model';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query';\n\nexport type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;\n\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n const { query, datasource } = value;\n\n const handleQueryChange = (e: ChangeEvent<HTMLInputElement>) => {\n onChange(\n produce(value, (draft) => {\n draft.query = e.target.value;\n })\n );\n };\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Box>\n <TextField label=\"Query\" value={query} onChange={handleQueryChange} margin=\"dense\" />\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={datasource ?? DEFAULT_PROM}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n </Box>\n );\n}\n"],"names":["produce","Box","TextField","FormControl","InputLabel","DatasourceSelect","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PrometheusTimeSeriesQueryEditor","props","onChange","value","query","datasource","handleQueryChange","e","draft","target","handleDatasourceChange","next","nextDatasource","undefined","Error","label","margin","fullWidth","id","datasourcePluginKind","labelId"],"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;AACA,OAAOA,OAAO,MAAM,OAAO,CAAC;AAC5B,SAASC,GAAG,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACxE,SAA6BC,gBAAgB,QAA+B,2BAA2B,CAAC;AACxG,SAASC,YAAY,EAAEC,qBAAqB,EAAEC,8BAA8B,QAAQ,UAAU,CAAC;AAK/F,OAAO,SAASC,+BAA+B,CAACC,KAA2C,EAAE;IAC3F,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAClC,MAAM,EAAEG,KAAK,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAEpC,MAAMG,iBAAiB,GAAG,CAACC,CAAgC,GAAK;QAC9DL,QAAQ,CACNX,OAAO,CAACY,KAAK,EAAE,CAACK,KAAK,GAAK;YACxBA,KAAK,CAACJ,KAAK,GAAGG,CAAC,CAACE,MAAM,CAACN,KAAK,CAAC;QAC/B,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMO,sBAAsB,GAAsC,CAACC,IAAI,GAAK;QAC1E,IAAIZ,8BAA8B,CAACY,IAAI,CAAC,EAAE;YACxCT,QAAQ,CACNX,OAAO,CAACY,KAAK,EAAE,CAACK,KAAK,GAAK;gBACxB,sFAAsF;gBACtF,MAAMI,cAAc,GAAGd,qBAAqB,CAACa,IAAI,CAAC,GAAGE,SAAS,GAAGF,IAAI,AAAC;gBACtEH,KAAK,CAACH,UAAU,GAAGO,cAAc,CAAC;YACpC,CAAC,CAAC,CACH,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,IAAIE,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC,AAAC;IAEF,qBACE,MAACtB,GAAG;;0BACF,KAACC,SAAS;gBAACsB,KAAK,EAAC,OAAO;gBAACZ,KAAK,EAAEC,KAAK;gBAAEF,QAAQ,EAAEI,iBAAiB;gBAAEU,MAAM,EAAC,OAAO;cAAG;0BACrF,MAACtB,WAAW;gBAACsB,MAAM,EAAC,OAAO;gBAACC,SAAS,EAAE,KAAK;;kCAG1C,KAACtB,UAAU;wBAACuB,EAAE,EAAC,uBAAuB;kCAAC,uBAAqB;sBAAa;kCACzE,KAACtB,gBAAgB;wBACfuB,oBAAoB,EAAC,sBAAsB;wBAC3ChB,KAAK,EAAEE,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIR,YAAY;wBACjCK,QAAQ,EAAEQ,sBAAsB;wBAChCU,OAAO,EAAC,uBAAuB;wBAC/BL,KAAK,EAAC,uBAAuB;sBAC7B;;cACU;;MACV,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/plugins/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { ChangeEvent } from 'react';\nimport produce from 'immer';\nimport { Box, TextField, FormControl, InputLabel } from '@mui/material';\nimport { OptionsEditorProps, DatasourceSelect, DatasourceSelectProps } from '@perses-dev/plugin-system';\nimport { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector } from '../model';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query';\n\nexport type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;\n\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n const { query, datasource } = value;\n\n const handleQueryChange = (e: ChangeEvent<HTMLInputElement>) => {\n onChange(\n produce(value, (draft) => {\n draft.query = e.target.value;\n })\n );\n };\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Box>\n <TextField fullWidth label=\"Query\" value={query} onChange={handleQueryChange} margin=\"dense\" />\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={datasource ?? DEFAULT_PROM}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n </Box>\n );\n}\n"],"names":["produce","Box","TextField","FormControl","InputLabel","DatasourceSelect","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PrometheusTimeSeriesQueryEditor","props","onChange","value","query","datasource","handleQueryChange","e","draft","target","handleDatasourceChange","next","nextDatasource","undefined","Error","fullWidth","label","margin","id","datasourcePluginKind","labelId"],"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;AACA,OAAOA,OAAO,MAAM,OAAO,CAAC;AAC5B,SAASC,GAAG,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACxE,SAA6BC,gBAAgB,QAA+B,2BAA2B,CAAC;AACxG,SAASC,YAAY,EAAEC,qBAAqB,EAAEC,8BAA8B,QAAQ,UAAU,CAAC;AAK/F,OAAO,SAASC,+BAA+B,CAACC,KAA2C,EAAE;IAC3F,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAClC,MAAM,EAAEG,KAAK,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAEpC,MAAMG,iBAAiB,GAAG,CAACC,CAAgC,GAAK;QAC9DL,QAAQ,CACNX,OAAO,CAACY,KAAK,EAAE,CAACK,KAAK,GAAK;YACxBA,KAAK,CAACJ,KAAK,GAAGG,CAAC,CAACE,MAAM,CAACN,KAAK,CAAC;QAC/B,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMO,sBAAsB,GAAsC,CAACC,IAAI,GAAK;QAC1E,IAAIZ,8BAA8B,CAACY,IAAI,CAAC,EAAE;YACxCT,QAAQ,CACNX,OAAO,CAACY,KAAK,EAAE,CAACK,KAAK,GAAK;gBACxB,sFAAsF;gBACtF,MAAMI,cAAc,GAAGd,qBAAqB,CAACa,IAAI,CAAC,GAAGE,SAAS,GAAGF,IAAI,AAAC;gBACtEH,KAAK,CAACH,UAAU,GAAGO,cAAc,CAAC;YACpC,CAAC,CAAC,CACH,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,IAAIE,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC,AAAC;IAEF,qBACE,MAACtB,GAAG;;0BACF,KAACC,SAAS;gBAACsB,SAAS;gBAACC,KAAK,EAAC,OAAO;gBAACb,KAAK,EAAEC,KAAK;gBAAEF,QAAQ,EAAEI,iBAAiB;gBAAEW,MAAM,EAAC,OAAO;cAAG;0BAC/F,MAACvB,WAAW;gBAACuB,MAAM,EAAC,OAAO;gBAACF,SAAS,EAAE,KAAK;;kCAG1C,KAACpB,UAAU;wBAACuB,EAAE,EAAC,uBAAuB;kCAAC,uBAAqB;sBAAa;kCACzE,KAACtB,gBAAgB;wBACfuB,oBAAoB,EAAC,sBAAsB;wBAC3ChB,KAAK,EAAEE,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIR,YAAY;wBACjCK,QAAQ,EAAEQ,sBAAsB;wBAChCU,OAAO,EAAC,uBAAuB;wBAC/BJ,KAAK,EAAC,uBAAuB;sBAC7B;;cACU;;MACV,CACN;AACJ,CAAC"}
@@ -1,16 +1,5 @@
1
1
  import { VariablePlugin } from '@perses-dev/plugin-system';
2
- import { PrometheusDatasourceSelector } from '../model';
3
- interface PrometheusVariableOptionsBase {
4
- datasource?: PrometheusDatasourceSelector;
5
- }
6
- declare type PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {
7
- matchers?: [string];
8
- };
9
- declare type PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {
10
- label_name: string;
11
- matchers?: [string];
12
- };
2
+ import { PrometheusLabelNamesVariableOptions, PrometheusLabelValuesVariableOptions } from './types';
13
3
  export declare const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions>;
14
4
  export declare const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions>;
15
- export {};
16
5
  //# sourceMappingURL=prometheus-variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAKL,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAGlB,UAAU,6BAA6B;IACrC,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC3C;AAED,aAAK,mCAAmC,GAAG,6BAA6B,GAAG;IACzE,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACrB,CAAC;AAEF,aAAK,oCAAoC,GAAG,6BAA6B,GAAG;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACrB,CAAC;AAaF,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAY5F,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CAiB9F,CAAC"}
1
+ {"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAsC,MAAM,2BAA2B,CAAC;AAG/F,OAAO,EAAE,mCAAmC,EAAE,oCAAoC,EAAE,MAAM,SAAS,CAAC;AAgDpG,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAY5F,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CAiB9F,CAAC"}
@@ -10,8 +10,53 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Stack, TextField } from '@mui/material';
13
15
  import { replaceTemplateVariables, parseTemplateVariables, DEFAULT_PROM } from '../model';
14
- import { JSONSpecEditor } from './JSONSpecEditor';
16
+ import { MatcherEditor } from './MatcherEditor';
17
+ function PrometheusLabelValuesVariableEditor(props) {
18
+ return /*#__PURE__*/ _jsxs(Stack, {
19
+ spacing: 1,
20
+ children: [
21
+ /*#__PURE__*/ _jsx(TextField, {
22
+ sx: {
23
+ mb: 1
24
+ },
25
+ label: "Label Name",
26
+ value: props.value.label_name,
27
+ onChange: (e)=>{
28
+ props.onChange({
29
+ ...props.value,
30
+ label_name: e.target.value
31
+ });
32
+ }
33
+ }),
34
+ /*#__PURE__*/ _jsx(MatcherEditor, {
35
+ initialMatchers: props.value.matchers,
36
+ onChange: (e)=>{
37
+ props.onChange({
38
+ ...props.value,
39
+ matchers: e
40
+ });
41
+ }
42
+ })
43
+ ]
44
+ });
45
+ }
46
+ function PrometheusLabelNamesVariableEditor(props) {
47
+ return /*#__PURE__*/ _jsx(Stack, {
48
+ spacing: 1,
49
+ children: /*#__PURE__*/ _jsx(MatcherEditor, {
50
+ initialMatchers: props.value.matchers,
51
+ onChange: (e)=>{
52
+ props.onChange({
53
+ ...props.value,
54
+ matchers: e
55
+ });
56
+ }
57
+ })
58
+ });
59
+ }
15
60
  /**
16
61
  * Takes a list of strings and returns a list of VariableOptions
17
62
  */ const stringArrayToVariableOptions = (values)=>{
@@ -34,7 +79,7 @@ export const PrometheusLabelNamesVariable = {
34
79
  };
35
80
  },
36
81
  dependsOn: ()=>[],
37
- OptionsEditorComponent: JSONSpecEditor,
82
+ OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
38
83
  createInitialOptions: ()=>({})
39
84
  };
40
85
  export const PrometheusLabelValuesVariable = {
@@ -55,7 +100,7 @@ export const PrometheusLabelValuesVariable = {
55
100
  var ref;
56
101
  return ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>parseTemplateVariables(m)).flat()) || [];
57
102
  },
58
- OptionsEditorComponent: JSONSpecEditor,
103
+ OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
59
104
  createInitialOptions: ()=>({
60
105
  label_name: ''
61
106
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/prometheus-variables.tsx"],"sourcesContent":["// Copyright 2022 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.\nimport { VariablePlugin, VariableOption } from '@perses-dev/plugin-system';\nimport {\n replaceTemplateVariables,\n parseTemplateVariables,\n PrometheusClient,\n DEFAULT_PROM,\n PrometheusDatasourceSelector,\n} from '../model';\nimport { JSONSpecEditor } from './JSONSpecEditor';\n\ninterface PrometheusVariableOptionsBase {\n datasource?: PrometheusDatasourceSelector;\n}\n\ntype PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {\n matchers?: [string];\n};\n\ntype PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {\n label_name: string;\n matchers?: [string];\n};\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nconst stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceTemplateVariables(m, ctx.variables)) : undefined;\n const { data: options } = await client.labelNames({ 'match[]': match });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: () => [],\n OptionsEditorComponent: JSONSpecEditor,\n createInitialOptions: () => ({}),\n};\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers\n ? pluginDef.matchers.map((m) => replaceTemplateVariables(m, ctx.variables))\n : undefined;\n const { data: options } = await client.labelValues({ labelName: pluginDef.label_name, 'match[]': match });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return spec.matchers?.map((m) => parseTemplateVariables(m)).flat() || [];\n },\n OptionsEditorComponent: JSONSpecEditor,\n createInitialOptions: () => ({ label_name: '' }),\n};\n"],"names":["replaceTemplateVariables","parseTemplateVariables","DEFAULT_PROM","JSONSpecEditor","stringArrayToVariableOptions","values","map","value","label","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","match","matchers","m","variables","undefined","data","options","labelNames","dependsOn","OptionsEditorComponent","createInitialOptions","PrometheusLabelValuesVariable","pluginDef","labelValues","labelName","label_name","flat"],"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,SACEA,wBAAwB,EACxBC,sBAAsB,EAEtBC,YAAY,QAEP,UAAU,CAAC;AAClB,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAelD;;CAEC,GACD,MAAMC,4BAA4B,GAAG,CAACC,MAAiB,GAAuB;IAC5E,IAAI,CAACA,MAAM,EAAE,OAAO,EAAE,CAAC;IACvB,OAAOA,MAAM,CAACC,GAAG,CAAC,CAACC,KAAK,GAA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CAACX,QAAQ,GAC5BW,SAAS,CAACX,QAAQ,CAACZ,GAAG,CAAC,CAACa,CAAC,GAAKnB,wBAAwB,CAACmB,CAAC,EAAEP,GAAG,CAACQ,SAAS,CAAC,CAAC,GACzEC,SAAS,AAAC;QACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,CAAA,EAAE,GAAG,MAAMV,MAAM,CAACiB,WAAW,CAAC;YAAEC,SAAS,EAAEF,SAAS,CAACG,UAAU;YAAE,SAAS,EAAEf,KAAK;SAAE,CAAC,AAAC;QAC1G,OAAO;YACLK,IAAI,EAAElB,4BAA4B,CAACmB,OAAO,CAAC;SAC5C,CAAC;IACJ,CAAC;IACDE,SAAS,EAAE,CAACd,IAAI,GAAK;YACZA,GAAa;QAApB,OAAOA,CAAAA,CAAAA,GAAa,GAAbA,IAAI,CAACO,QAAQ,cAAbP,GAAa,WAAK,GAAlBA,KAAAA,CAAkB,GAAlBA,GAAa,CAAEL,GAAG,CAAC,CAACa,CAAC,GAAKlB,sBAAsB,CAACkB,CAAC,CAAC,CAAC,CAACc,IAAI,EAAE,CAAA,IAAI,EAAE,CAAC;IAC3E,CAAC;IACDP,sBAAsB,EAAEvB,cAAc;IACtCwB,oBAAoB,EAAE,IAAO,CAAA;YAAEK,UAAU,EAAE,EAAE;SAAE,CAAA,AAAC;CACjD,CAAC"}
1
+ {"version":3,"sources":["../../src/plugins/prometheus-variables.tsx"],"sourcesContent":["// Copyright 2022 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.\nimport { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Stack, TextField } from '@mui/material';\nimport { replaceTemplateVariables, parseTemplateVariables, PrometheusClient, DEFAULT_PROM } from '../model';\nimport { PrometheusLabelNamesVariableOptions, PrometheusLabelValuesVariableOptions } from './types';\nimport { MatcherEditor } from './MatcherEditor';\n\nfunction PrometheusLabelValuesVariableEditor(props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>) {\n return (\n <Stack spacing={1}>\n <TextField\n sx={{ mb: 1 }}\n label=\"Label Name\"\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n <MatcherEditor\n initialMatchers={props.value.matchers}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusLabelNamesVariableEditor(props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>) {\n return (\n <Stack spacing={1}>\n <MatcherEditor\n initialMatchers={props.value.matchers}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nconst stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceTemplateVariables(m, ctx.variables)) : undefined;\n const { data: options } = await client.labelNames({ 'match[]': match });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: () => [],\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers\n ? pluginDef.matchers.map((m) => replaceTemplateVariables(m, ctx.variables))\n : undefined;\n const { data: options } = await client.labelValues({ labelName: pluginDef.label_name, 'match[]': match });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return spec.matchers?.map((m) => parseTemplateVariables(m)).flat() || [];\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ label_name: '' }),\n};\n"],"names":["Stack","TextField","replaceTemplateVariables","parseTemplateVariables","DEFAULT_PROM","MatcherEditor","PrometheusLabelValuesVariableEditor","props","spacing","sx","mb","label","value","label_name","onChange","e","target","initialMatchers","matchers","PrometheusLabelNamesVariableEditor","stringArrayToVariableOptions","values","map","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","match","m","variables","undefined","data","options","labelNames","dependsOn","OptionsEditorComponent","createInitialOptions","PrometheusLabelValuesVariable","pluginDef","labelValues","labelName","flat"],"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;AACjC;AACA,SAASA,KAAK,EAAEC,SAAS,QAAQ,eAAe,CAAC;AACjD,SAASC,wBAAwB,EAAEC,sBAAsB,EAAoBC,YAAY,QAAQ,UAAU,CAAC;AAE5G,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAEhD,SAASC,mCAAmC,CAACC,KAA+D,EAAE;IAC5G,qBACE,MAACP,KAAK;QAACQ,OAAO,EAAE,CAAC;;0BACf,KAACP,SAAS;gBACRQ,EAAE,EAAE;oBAAEC,EAAE,EAAE,CAAC;iBAAE;gBACbC,KAAK,EAAC,YAAY;gBAClBC,KAAK,EAAEL,KAAK,CAACK,KAAK,CAACC,UA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AW,CAAC;YAAEC,SAAS,EAAEF,SAAS,CAAC7B,UAAU;YAAE,SAAS,EAAEkB,KAAK;SAAE,CAAC,AAAC;QAC1G,OAAO;YACLI,IAAI,EAAEf,4BAA4B,CAACgB,OAAO,CAAC;SAC5C,CAAC;IACJ,CAAC;IACDE,SAAS,EAAE,CAACb,IAAI,GAAK;YACZA,GAAa;QAApB,OAAOA,CAAAA,CAAAA,GAAa,GAAbA,IAAI,CAACP,QAAQ,cAAbO,GAAa,WAAK,GAAlBA,KAAAA,CAAkB,GAAlBA,GAAa,CAAEH,GAAG,CAAC,CAACU,CAAC,GAAK7B,sBAAsB,CAAC6B,CAAC,CAAC,CAAC,CAACa,IAAI,EAAE,CAAA,IAAI,EAAE,CAAC;IAC3E,CAAC;IACDN,sBAAsB,EAAEjC,mCAAmC;IAC3DkC,oBAAoB,EAAE,IAAO,CAAA;YAAE3B,UAAU,EAAE,EAAE;SAAE,CAAA,AAAC;CACjD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { PrometheusDatasourceSelector } from '../model';
2
+ export interface PrometheusVariableOptionsBase {
3
+ datasource?: PrometheusDatasourceSelector;
4
+ }
5
+ export declare type PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {
6
+ matchers?: string[];
7
+ };
8
+ export declare type PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {
9
+ label_name: string;
10
+ matchers?: string[];
11
+ };
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC3C;AAED,oBAAY,mCAAmC,GAAG,6BAA6B,GAAG;IAChF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,oBAAY,oCAAoC,GAAG,6BAA6B,GAAG;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 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
+ export { };
14
+
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/types.ts"],"sourcesContent":["// Copyright 2022 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 { PrometheusDatasourceSelector } from '../model';\n\nexport interface PrometheusVariableOptionsBase {\n datasource?: PrometheusDatasourceSelector;\n}\n\nexport type PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {\n matchers?: string[];\n};\n\nexport type PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {\n label_name: string;\n matchers?: string[];\n};\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,WAaE"}
@@ -1 +1 @@
1
- {"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/plugins/variable.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3E,aAAK,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEhD,aAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAexE,CAAC"}
1
+ {"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/plugins/variable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAG/F,aAAK,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEhD,aAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAiCF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAexE,CAAC"}
@@ -10,7 +10,41 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { JSONSpecEditor } from './JSONSpecEditor';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Autocomplete, TextField } from '@mui/material';
15
+ function StaticListVariableOptionEditor(props) {
16
+ const value = props.value.values.map((v)=>{
17
+ if (typeof v === 'string') {
18
+ return v;
19
+ } else {
20
+ return v.value;
21
+ }
22
+ });
23
+ const onChange = (__, value)=>{
24
+ props.onChange({
25
+ values: value.map((v)=>{
26
+ return {
27
+ value: v,
28
+ label: v
29
+ };
30
+ })
31
+ });
32
+ };
33
+ return /*#__PURE__*/ _jsx("div", {
34
+ children: /*#__PURE__*/ _jsx(Autocomplete, {
35
+ multiple: true,
36
+ value: value,
37
+ onChange: onChange,
38
+ options: [],
39
+ freeSolo: true,
40
+ renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
41
+ ...params,
42
+ label: "Values",
43
+ placeholder: "Values"
44
+ })
45
+ })
46
+ });
47
+ }
14
48
  export const StaticListVariable = {
15
49
  getVariableOptions: async (spec)=>{
16
50
  var ref;
@@ -28,7 +62,7 @@ export const StaticListVariable = {
28
62
  };
29
63
  },
30
64
  dependsOn: ()=>[],
31
- OptionsEditorComponent: JSONSpecEditor,
65
+ OptionsEditorComponent: StaticListVariableOptionEditor,
32
66
  createInitialOptions: ()=>({
33
67
  values: []
34
68
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/variable.ts"],"sourcesContent":["// Copyright 2022 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 { VariablePlugin, VariableOption } from '@perses-dev/plugin-system';\nimport { JSONSpecEditor } from './JSONSpecEditor';\n\ntype StaticListOption = string | VariableOption;\n\ntype StaticListVariableOptions = {\n values: StaticListOption[];\n};\n\nexport const StaticListVariable: VariablePlugin<StaticListVariableOptions> = {\n getVariableOptions: async (spec) => {\n const values = spec.values?.map((v) => {\n if (typeof v === 'string') {\n return { label: v, value: v };\n }\n return v;\n });\n return {\n data: values,\n };\n },\n dependsOn: () => [],\n OptionsEditorComponent: JSONSpecEditor,\n createInitialOptions: () => ({ values: [] }),\n};\n"],"names":["JSONSpecEditor","StaticListVariable","getVariableOptions","spec","values","map","v","label","value","data","dependsOn","OptionsEditorComponent","createInitialOptions"],"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;AAGjC,SAASA,cAAc,QAAQ,kBAAkB,CAAC;AAQlD,OAAO,MAAMC,kBAAkB,GAA8C;IAC3EC,kBAAkB,EAAE,OAAOC,IAAI,GAAK;YACnBA,GAAW;QAA1B,MAAMC,MAAM,GAAGD,CAAAA,GAAW,GAAXA,IAAI,CAACC,MAAM,cAAXD,GAAW,WAAK,GAAhBA,KAAAA,CAAgB,GAAhBA,GAAW,CAAEE,GAAG,CAAC,CAACC,CAAC,GAAK;YACrC,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;gBACzB,OAAO;oBAAEC,KAAK,EAAED,CAAC;oBAAEE,KAAK,EAAEF,CAAC;iBAAE,CAAC;YAChC,CAAC;YACD,OAAOA,CAAC,CAAC;QACX,CAAC,CAAC,AAAC;QACH,OAAO;YACLG,IAAI,EAAEL,MAAM;SACb,CAAC;IACJ,CAAC;IACDM,SAAS,EAAE,IAAM,EAAE;IACnBC,sBAAsB,EAAEX,cAAc;IACtCY,oBAAoB,EAAE,IAAO,CAAA;YAAER,MAAM,EAAE,EAAE;SAAE,CAAA,AAAC;CAC7C,CAAC"}
1
+ {"version":3,"sources":["../../src/plugins/variable.tsx"],"sourcesContent":["// Copyright 2022 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 { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Autocomplete, TextField } from '@mui/material';\n\ntype StaticListOption = string | VariableOption;\n\ntype StaticListVariableOptions = {\n values: StaticListOption[];\n};\n\nfunction StaticListVariableOptionEditor(props: OptionsEditorProps<StaticListVariableOptions>) {\n const value = props.value.values.map((v) => {\n if (typeof v === 'string') {\n return v;\n } else {\n return v.value;\n }\n });\n\n const onChange = (__: unknown, value: string[]) => {\n props.onChange({\n values: value.map((v) => {\n return { value: v, label: v };\n }),\n });\n };\n\n return (\n <div>\n <Autocomplete\n multiple\n value={value}\n onChange={onChange}\n options={[]}\n freeSolo\n renderInput={(params) => <TextField {...params} label=\"Values\" placeholder=\"Values\" />}\n />\n </div>\n );\n}\n\nexport const StaticListVariable: VariablePlugin<StaticListVariableOptions> = {\n getVariableOptions: async (spec) => {\n const values = spec.values?.map((v) => {\n if (typeof v === 'string') {\n return { label: v, value: v };\n }\n return v;\n });\n return {\n data: values,\n };\n },\n dependsOn: () => [],\n OptionsEditorComponent: StaticListVariableOptionEditor,\n createInitialOptions: () => ({ values: [] }),\n};\n"],"names":["Autocomplete","TextField","StaticListVariableOptionEditor","props","value","values","map","v","onChange","__","label","div","multiple","options","freeSolo","renderInput","params","placeholder","StaticListVariable","getVariableOptions","spec","data","dependsOn","OptionsEditorComponent","createInitialOptions"],"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;AACA,SAASA,YAAY,EAAEC,SAAS,QAAQ,eAAe,CAAC;AAQxD,SAASC,8BAA8B,CAACC,KAAoD,EAAE;IAC5F,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAK,CAACC,MAAM,CAACC,GAAG,CAAC,CAACC,CAAC,GAAK;QAC1C,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;YACzB,OAAOA,CAAC,CAAC;QACX,OAAO;YACL,OAAOA,CAAC,CAACH,KAAK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AEnB,MAAM,EAAE,EAAE;SAAE,CAAA,AAAC;CAC7C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/prometheus-plugin",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Prometheus plugin for Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,8 +29,8 @@
29
29
  "dependencies": {
30
30
  "@lezer/highlight": "^1.0.0",
31
31
  "@lezer/lr": "^1.2.0",
32
- "@perses-dev/core": "^0.10.0",
33
- "@perses-dev/plugin-system": "^0.10.0",
32
+ "@perses-dev/core": "^0.12.0",
33
+ "@perses-dev/plugin-system": "^0.12.0",
34
34
  "@prometheus-io/lezer-promql": "^0.37.0",
35
35
  "date-fns": "^2.28.0",
36
36
  "immer": "^9.0.15"
@@ -1,54 +0,0 @@
1
- // Copyright 2022 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, "JSONSpecEditor", {
18
- enumerable: true,
19
- get: ()=>JSONSpecEditor
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _react = require("react");
23
- const _material = require("@mui/material");
24
- function JSONSpecEditor(props) {
25
- const ref = (0, _react.useRef)(null);
26
- const [value, setValue] = (0, _react.useState)(JSON.stringify(props.value, null, 2));
27
- const [invalidJSON, setInvalidJSON] = (0, _react.useState)(false);
28
- (0, _react.useEffect)(()=>{
29
- setValue(JSON.stringify(props.value, null, 2));
30
- setInvalidJSON(false);
31
- }, [
32
- props.value
33
- ]);
34
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
35
- label: "JSON",
36
- error: invalidJSON,
37
- helperText: invalidJSON ? 'Invalid JSON' : '',
38
- multiline: true,
39
- inputRef: ref,
40
- value: value,
41
- onChange: (event)=>{
42
- setValue(event.target.value);
43
- },
44
- onBlur: ()=>{
45
- try {
46
- const json = JSON.parse(value !== null && value !== void 0 ? value : '{}');
47
- setInvalidJSON(false);
48
- props.onChange(json);
49
- } catch (e) {
50
- setInvalidJSON(true);
51
- }
52
- }
53
- });
54
- }
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { OptionsEditorProps } from '@perses-dev/plugin-system';
3
- export declare function JSONSpecEditor<T>(props: OptionsEditorProps<T>): JSX.Element;
4
- //# sourceMappingURL=JSONSpecEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSONSpecEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/JSONSpecEditor.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,eAgC7D"}
@@ -1,48 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { useEffect, useRef, useState } from 'react';
15
- import { TextField } from '@mui/material';
16
- export function JSONSpecEditor(props) {
17
- const ref = useRef(null);
18
- const [value, setValue] = useState(JSON.stringify(props.value, null, 2));
19
- const [invalidJSON, setInvalidJSON] = useState(false);
20
- useEffect(()=>{
21
- setValue(JSON.stringify(props.value, null, 2));
22
- setInvalidJSON(false);
23
- }, [
24
- props.value
25
- ]);
26
- return /*#__PURE__*/ _jsx(TextField, {
27
- label: "JSON",
28
- error: invalidJSON,
29
- helperText: invalidJSON ? 'Invalid JSON' : '',
30
- multiline: true,
31
- inputRef: ref,
32
- value: value,
33
- onChange: (event)=>{
34
- setValue(event.target.value);
35
- },
36
- onBlur: ()=>{
37
- try {
38
- const json = JSON.parse(value !== null && value !== void 0 ? value : '{}');
39
- setInvalidJSON(false);
40
- props.onChange(json);
41
- } catch (e) {
42
- setInvalidJSON(true);
43
- }
44
- }
45
- });
46
- }
47
-
48
- //# sourceMappingURL=JSONSpecEditor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/plugins/JSONSpecEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { useEffect, useRef, useState } from 'react';\nimport { TextField } from '@mui/material';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport function JSONSpecEditor<T>(props: OptionsEditorProps<T>) {\n const ref = useRef<HTMLInputElement>(null);\n const [value, setValue] = useState(JSON.stringify(props.value, null, 2));\n const [invalidJSON, setInvalidJSON] = useState(false);\n\n useEffect(() => {\n setValue(JSON.stringify(props.value, null, 2));\n setInvalidJSON(false);\n }, [props.value]);\n\n return (\n <TextField\n label=\"JSON\"\n error={invalidJSON}\n helperText={invalidJSON ? 'Invalid JSON' : ''}\n multiline\n inputRef={ref}\n value={value}\n onChange={(event) => {\n setValue(event.target.value);\n }}\n onBlur={() => {\n try {\n const json = JSON.parse(value ?? '{}');\n setInvalidJSON(false);\n props.onChange(json);\n } catch (e) {\n setInvalidJSON(true);\n }\n }}\n />\n );\n}\n"],"names":["useEffect","useRef","useState","TextField","JSONSpecEditor","props","ref","value","setValue","JSON","stringify","invalidJSON","setInvalidJSON","label","error","helperText","multiline","inputRef","onChange","event","target","onBlur","json","parse","e"],"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;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACpD,SAASC,SAAS,QAAQ,eAAe,CAAC;AAG1C,OAAO,SAASC,cAAc,CAAIC,KAA4B,EAAE;IAC9D,MAAMC,GAAG,GAAGL,MAAM,CAAmB,IAAI,CAAC,AAAC;IAC3C,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGN,QAAQ,CAACO,IAAI,CAACC,SAAS,CAACL,KAAK,CAACE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,AAAC;IACzE,MAAM,CAACI,WAAW,EAAEC,cAAc,CAAC,GAAGV,QAAQ,CAAC,KAAK,CAAC,AAAC;IAEtDF,SAAS,CAAC,IAAM;QACdQ,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACL,KAAK,CAACE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/CK,cAAc,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,EAAE;QAACP,KAAK,CAACE,KAAK;KAAC,CAAC,CAAC;IAElB,qBACE,KAACJ,SAAS;QACRU,KAAK,EAAC,MAAM;QACZC,KA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