@perses-dev/alert-manager-plugin 0.1.0 → 0.1.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 (61) hide show
  1. package/__mf/js/{AlertManager.f762e62c.js → AlertManager.377d377b.js} +2 -2
  2. package/__mf/js/async/{1728.83bb9a7c.js → 1728.8a326412.js} +1 -1
  3. package/__mf/js/async/2842.993baf22.js +1 -0
  4. package/__mf/js/async/3468.1679f87f.js +1 -0
  5. package/__mf/js/async/3540.96681482.js +2 -0
  6. package/__mf/js/async/3981.84d12fdc.js +4 -0
  7. package/__mf/js/async/{7790.a75199e6.js → 430.74d85c4b.js} +5 -5
  8. package/__mf/js/async/{7862.556c038f.js → 5481.cf6703fd.js} +2 -2
  9. package/__mf/js/async/5570.d4dd47e0.js +1 -0
  10. package/__mf/js/async/{2954.3ac1f636.js → 573.ce8ce2ef.js} +1 -1
  11. package/__mf/js/async/{7422.33d76364.js → 7283.8c1cb6ee.js} +2 -2
  12. package/__mf/js/async/{7984.49fa1156.js → 7984.163a6ddb.js} +5 -5
  13. package/__mf/js/async/8711.c7dc09b8.js +2 -0
  14. package/__mf/js/async/9537.36ff6f15.js +1 -0
  15. package/__mf/js/async/983.36857235.js +1 -0
  16. package/__mf/js/async/{__federation_expose_AlertManagerAlertsExplorer.d4fb76c0.js → __federation_expose_AlertManagerAlertsExplorer.47ee46dc.js} +2 -2
  17. package/__mf/js/async/__federation_expose_AlertManagerAlertsQuery.22b0e5bc.js +1 -0
  18. package/__mf/js/async/__federation_expose_AlertManagerDatasource.7ee7440a.js +2 -0
  19. package/__mf/js/async/__federation_expose_AlertManagerSilencesExplorer.35860f1b.js +2 -0
  20. package/__mf/js/async/__federation_expose_AlertManagerSilencesQuery.52a24c9e.js +2 -0
  21. package/__mf/js/async/__federation_expose_AlertTable.5d005bae.js +1 -0
  22. package/__mf/js/async/__federation_expose_SilenceTable.3fc487a4.js +2 -0
  23. package/__mf/js/async/__federation_expose_SilenceTable.3fc487a4.js.LICENSE.txt +9 -0
  24. package/__mf/js/{main.a1362788.js → main.259f5b24.js} +2 -2
  25. package/lib/cjs/model/alertmanager-client.js +3 -3
  26. package/lib/explore/AlertManagerAlertsExplorer.js.map +1 -1
  27. package/lib/explore/AlertManagerSilencesExplorer.js.map +1 -1
  28. package/lib/model/alertmanager-client.d.ts +1 -1
  29. package/lib/model/alertmanager-client.d.ts.map +1 -1
  30. package/lib/model/alertmanager-client.js +1 -1
  31. package/lib/model/alertmanager-client.js.map +1 -1
  32. package/lib/model/alertmanager-selectors.d.ts +1 -1
  33. package/lib/model/alertmanager-selectors.js.map +1 -1
  34. package/lib/plugins/types.d.ts +1 -1
  35. package/lib/plugins/types.js.map +1 -1
  36. package/mf-manifest.json +141 -109
  37. package/mf-stats.json +143 -111
  38. package/package.json +8 -7
  39. package/__mf/js/async/4397.d399eecb.js +0 -2
  40. package/__mf/js/async/4732.e866a740.js +0 -1
  41. package/__mf/js/async/573.214f2003.js +0 -2
  42. package/__mf/js/async/6593.acc8b704.js +0 -4
  43. package/__mf/js/async/733.22ab2a8a.js +0 -1
  44. package/__mf/js/async/__federation_expose_AlertManagerAlertsQuery.9ea3093c.js +0 -1
  45. package/__mf/js/async/__federation_expose_AlertManagerDatasource.2fbf067c.js +0 -2
  46. package/__mf/js/async/__federation_expose_AlertManagerSilencesExplorer.d2527c12.js +0 -2
  47. package/__mf/js/async/__federation_expose_AlertManagerSilencesQuery.7aca31d3.js +0 -2
  48. package/__mf/js/async/__federation_expose_AlertTable.4a636b80.js +0 -1
  49. package/__mf/js/async/__federation_expose_SilenceTable.11259028.js +0 -1
  50. /package/__mf/css/async/{7790.85c2cbf6.css → 430.85c2cbf6.css} +0 -0
  51. /package/__mf/js/async/{4397.d399eecb.js.LICENSE.txt → 3540.96681482.js.LICENSE.txt} +0 -0
  52. /package/__mf/js/async/{6593.acc8b704.js.LICENSE.txt → 3981.84d12fdc.js.LICENSE.txt} +0 -0
  53. /package/__mf/js/async/{7790.a75199e6.js.LICENSE.txt → 430.74d85c4b.js.LICENSE.txt} +0 -0
  54. /package/__mf/js/async/{7862.556c038f.js.LICENSE.txt → 5481.cf6703fd.js.LICENSE.txt} +0 -0
  55. /package/__mf/js/async/{573.214f2003.js.LICENSE.txt → 7283.8c1cb6ee.js.LICENSE.txt} +0 -0
  56. /package/__mf/js/async/{7984.49fa1156.js.LICENSE.txt → 7984.163a6ddb.js.LICENSE.txt} +0 -0
  57. /package/__mf/js/async/{7422.33d76364.js.LICENSE.txt → 8711.c7dc09b8.js.LICENSE.txt} +0 -0
  58. /package/__mf/js/async/{__federation_expose_AlertManagerAlertsExplorer.d4fb76c0.js.LICENSE.txt → __federation_expose_AlertManagerAlertsExplorer.47ee46dc.js.LICENSE.txt} +0 -0
  59. /package/__mf/js/async/{__federation_expose_AlertManagerDatasource.2fbf067c.js.LICENSE.txt → __federation_expose_AlertManagerDatasource.7ee7440a.js.LICENSE.txt} +0 -0
  60. /package/__mf/js/async/{__federation_expose_AlertManagerSilencesExplorer.d2527c12.js.LICENSE.txt → __federation_expose_AlertManagerSilencesExplorer.35860f1b.js.LICENSE.txt} +0 -0
  61. /package/__mf/js/async/{__federation_expose_AlertManagerSilencesQuery.7aca31d3.js.LICENSE.txt → __federation_expose_AlertManagerSilencesQuery.52a24c9e.js.LICENSE.txt} +0 -0
@@ -40,7 +40,7 @@ _export(exports, {
40
40
  return getStatus;
41
41
  }
42
42
  });
43
- const _core = require("@perses-dev/core");
43
+ const _client = require("@perses-dev/client");
44
44
  async function throwOnError(response) {
45
45
  if (!response.ok) {
46
46
  let message = response.statusText;
@@ -54,7 +54,7 @@ async function throwOnError(response) {
54
54
  }
55
55
  }
56
56
  const executeRequest = async (...args)=>{
57
- const response = await (0, _core.fetch)(...args);
57
+ const response = await (0, _client.fetch)(...args);
58
58
  await throwOnError(response);
59
59
  try {
60
60
  return await response.json();
@@ -117,7 +117,7 @@ function createSilence(silence, queryOptions) {
117
117
  }
118
118
  async function deleteSilence(id, queryOptions) {
119
119
  const { datasourceUrl, headers = {} } = queryOptions;
120
- const response = await (0, _core.fetch)(`${datasourceUrl}/api/v2/silence/${encodeURIComponent(id)}`, {
120
+ const response = await (0, _client.fetch)(`${datasourceUrl}/api/v2/silence/${encodeURIComponent(id)}`, {
121
121
  method: 'DELETE',
122
122
  headers
123
123
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/explore/AlertManagerAlertsExplorer.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\nimport { ReactElement, useState } from 'react';\nimport { Box, Stack } from '@mui/material';\nimport { DataQueriesProvider, MultiQueryEditor } from '@perses-dev/plugin-system';\nimport { Panel } from '@perses-dev/dashboards';\nimport { useExplorerManagerContext } from '@perses-dev/explore';\nimport { QueryDefinition } from '@perses-dev/core';\n\ninterface AlertsExplorerQueryParams {\n queries?: QueryDefinition[];\n}\n\nconst PANEL_PREVIEW_HEIGHT = 600;\n\nexport function AlertManagerAlertsExplorer(): ReactElement {\n const {\n data: { queries = [] },\n setData,\n } = useExplorerManagerContext<AlertsExplorerQueryParams>();\n\n const [queryDefinitions, setQueryDefinitions] = useState<QueryDefinition[]>(queries);\n\n return (\n <Stack gap={2} sx={{ width: '100%' }}>\n <MultiQueryEditor\n queryTypes={['AlertsQuery']}\n onChange={(state) => setQueryDefinitions(state)}\n queries={queryDefinitions}\n onQueryRun={() => setData({ queries: queryDefinitions })}\n />\n <DataQueriesProvider definitions={queries}>\n <Box height={PANEL_PREVIEW_HEIGHT}>\n <Panel\n panelOptions={{ hideHeader: true }}\n definition={{\n kind: 'Panel',\n spec: {\n queries,\n display: { name: '' },\n plugin: { kind: 'AlertTable', spec: { defaultGroupBy: ['alertname'] } },\n },\n }}\n />\n </Box>\n </DataQueriesProvider>\n </Stack>\n );\n}\n"],"names":["useState","Box","Stack","DataQueriesProvider","MultiQueryEditor","Panel","useExplorerManagerContext","PANEL_PREVIEW_HEIGHT","AlertManagerAlertsExplorer","data","queries","setData","queryDefinitions","setQueryDefinitions","gap","sx","width","queryTypes","onChange","state","onQueryRun","definitions","height","panelOptions","hideHeader","definition","kind","spec","display","name","plugin","defaultGroupBy"],"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,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,GAAG,EAAEC,KAAK,QAAQ,gBAAgB;AAC3C,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,4BAA4B;AAClF,SAASC,KAAK,QAAQ,yBAAyB;AAC/C,SAASC,yBAAyB,QAAQ,sBAAsB;AAOhE,MAAMC,uBAAuB;AAE7B,OAAO,SAASC;IACd,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EAAE,EACtBC,OAAO,EACR,GAAGL;IAEJ,MAAM,CAACM,kBAAkBC,oBAAoB,GAAGb,SAA4BU;IAE5E,qBACE,MAACR;QAAMY,KAAK;QAAGC,IAAI;YAAEC,OAAO;QAAO;;0BACjC,KAACZ;gBACCa,YAAY;oBAAC;iBAAc;gBAC3BC,UAAU,CAACC,QAAUN,oBAAoBM;gBACzCT,SAASE;gBACTQ,YAAY,IAAMT,QAAQ;wBAAED,SAASE;oBAAiB;;0BAExD,KAACT;gBAAoBkB,aAAaX;0BAChC,cAAA,KAACT;oBAAIqB,QAAQf;8BACX,cAAA,KAACF;wBACCkB,cAAc;4BAAEC,YAAY;wBAAK;wBACjCC,YAAY;4BACVC,MAAM;4BACNC,MAAM;gCACJjB;gCACAkB,SAAS;oCAAEC,MAAM;gCAAG;gCACpBC,QAAQ;oCAAEJ,MAAM;oCAAcC,MAAM;wCAAEI,gBAAgB;4CAAC;yCAAY;oCAAC;gCAAE;4BACxE;wBACF;;;;;;AAMZ"}
1
+ {"version":3,"sources":["../../../src/explore/AlertManagerAlertsExplorer.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\nimport { ReactElement, useState } from 'react';\nimport { Box, Stack } from '@mui/material';\nimport { DataQueriesProvider, MultiQueryEditor } from '@perses-dev/plugin-system';\nimport { Panel } from '@perses-dev/dashboards';\nimport { useExplorerManagerContext } from '@perses-dev/explore';\nimport { QueryDefinition } from '@perses-dev/spec';\n\ninterface AlertsExplorerQueryParams {\n queries?: QueryDefinition[];\n}\n\nconst PANEL_PREVIEW_HEIGHT = 600;\n\nexport function AlertManagerAlertsExplorer(): ReactElement {\n const {\n data: { queries = [] },\n setData,\n } = useExplorerManagerContext<AlertsExplorerQueryParams>();\n\n const [queryDefinitions, setQueryDefinitions] = useState<QueryDefinition[]>(queries);\n\n return (\n <Stack gap={2} sx={{ width: '100%' }}>\n <MultiQueryEditor\n queryTypes={['AlertsQuery']}\n onChange={(state) => setQueryDefinitions(state)}\n queries={queryDefinitions}\n onQueryRun={() => setData({ queries: queryDefinitions })}\n />\n <DataQueriesProvider definitions={queries}>\n <Box height={PANEL_PREVIEW_HEIGHT}>\n <Panel\n panelOptions={{ hideHeader: true }}\n definition={{\n kind: 'Panel',\n spec: {\n queries,\n display: { name: '' },\n plugin: { kind: 'AlertTable', spec: { defaultGroupBy: ['alertname'] } },\n },\n }}\n />\n </Box>\n </DataQueriesProvider>\n </Stack>\n );\n}\n"],"names":["useState","Box","Stack","DataQueriesProvider","MultiQueryEditor","Panel","useExplorerManagerContext","PANEL_PREVIEW_HEIGHT","AlertManagerAlertsExplorer","data","queries","setData","queryDefinitions","setQueryDefinitions","gap","sx","width","queryTypes","onChange","state","onQueryRun","definitions","height","panelOptions","hideHeader","definition","kind","spec","display","name","plugin","defaultGroupBy"],"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,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,GAAG,EAAEC,KAAK,QAAQ,gBAAgB;AAC3C,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,4BAA4B;AAClF,SAASC,KAAK,QAAQ,yBAAyB;AAC/C,SAASC,yBAAyB,QAAQ,sBAAsB;AAOhE,MAAMC,uBAAuB;AAE7B,OAAO,SAASC;IACd,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EAAE,EACtBC,OAAO,EACR,GAAGL;IAEJ,MAAM,CAACM,kBAAkBC,oBAAoB,GAAGb,SAA4BU;IAE5E,qBACE,MAACR;QAAMY,KAAK;QAAGC,IAAI;YAAEC,OAAO;QAAO;;0BACjC,KAACZ;gBACCa,YAAY;oBAAC;iBAAc;gBAC3BC,UAAU,CAACC,QAAUN,oBAAoBM;gBACzCT,SAASE;gBACTQ,YAAY,IAAMT,QAAQ;wBAAED,SAASE;oBAAiB;;0BAExD,KAACT;gBAAoBkB,aAAaX;0BAChC,cAAA,KAACT;oBAAIqB,QAAQf;8BACX,cAAA,KAACF;wBACCkB,cAAc;4BAAEC,YAAY;wBAAK;wBACjCC,YAAY;4BACVC,MAAM;4BACNC,MAAM;gCACJjB;gCACAkB,SAAS;oCAAEC,MAAM;gCAAG;gCACpBC,QAAQ;oCAAEJ,MAAM;oCAAcC,MAAM;wCAAEI,gBAAgB;4CAAC;yCAAY;oCAAC;gCAAE;4BACxE;wBACF;;;;;;AAMZ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/explore/AlertManagerSilencesExplorer.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\nimport { ReactElement, useCallback, useMemo, useRef, useState } from 'react';\nimport { Box, Button, Stack } from '@mui/material';\nimport BellOffIcon from 'mdi-material-ui/BellOff';\nimport { DataQueriesProvider, MultiQueryEditor, useDatasourceClient } from '@perses-dev/plugin-system';\nimport { Panel } from '@perses-dev/dashboards';\nimport { useExplorerManagerContext } from '@perses-dev/explore';\nimport { DatasourceSelector, QueryDefinition } from '@perses-dev/core';\nimport { useSnackbar } from '@perses-dev/components';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { SilenceForm } from '../components/SilenceForm';\nimport { AlertManagerClient, DEFAULT_ALERTMANAGER, PostableSilence } from '../model';\n\ninterface SilencesExplorerQueryParams {\n queries?: QueryDefinition[];\n}\n\nconst PANEL_PREVIEW_HEIGHT = 600;\n\nfunction extractSelectorFromQueries(queries: QueryDefinition[]): DatasourceSelector {\n const spec: unknown = queries[0]?.spec?.plugin?.spec;\n if (spec && typeof spec === 'object' && 'datasource' in spec) {\n const ds = (spec as Record<string, unknown>).datasource;\n if (ds && typeof ds === 'object' && 'kind' in ds) {\n return ds as DatasourceSelector;\n }\n }\n return DEFAULT_ALERTMANAGER;\n}\n\nfunction CreateSilenceButton({ queries }: { queries: QueryDefinition[] }): ReactElement {\n const datasourceSelector = useMemo(() => extractSelectorFromQueries(queries), [queries]);\n const { data: amClient } = useDatasourceClient<AlertManagerClient>(datasourceSelector);\n const queryClient = useQueryClient();\n const { successSnackbar, exceptionSnackbar } = useSnackbar();\n\n const [open, setOpen] = useState(false);\n const formKeyRef = useRef(0);\n\n const handleOpen = useCallback(() => {\n formKeyRef.current++;\n setOpen(true);\n }, []);\n\n const handleSubmit = useCallback(\n async (silence: PostableSilence) => {\n if (!amClient) return;\n try {\n await amClient.createSilence(silence);\n setOpen(false);\n successSnackbar('Silence created successfully');\n queryClient.invalidateQueries({ queryKey: ['query', 'SilencesQuery'] });\n } catch (err) {\n exceptionSnackbar(err);\n }\n },\n [amClient, queryClient, successSnackbar, exceptionSnackbar]\n );\n\n return (\n <>\n <Button variant=\"contained\" startIcon={<BellOffIcon />} onClick={handleOpen} size=\"small\">\n Create Silence\n </Button>\n <SilenceForm key={formKeyRef.current} open={open} onClose={() => setOpen(false)} onSubmit={handleSubmit} />\n </>\n );\n}\n\nexport function AlertManagerSilencesExplorer(): ReactElement {\n const {\n data: { queries = [] },\n setData,\n } = useExplorerManagerContext<SilencesExplorerQueryParams>();\n\n const [queryDefinitions, setQueryDefinitions] = useState<QueryDefinition[]>(queries);\n\n return (\n <Stack gap={2} sx={{ width: '100%' }}>\n <Stack direction=\"row\" justifyContent=\"flex-end\">\n <CreateSilenceButton queries={queries} />\n </Stack>\n <MultiQueryEditor\n queryTypes={['SilencesQuery']}\n onChange={(state) => setQueryDefinitions(state)}\n queries={queryDefinitions}\n onQueryRun={() => setData({ queries: queryDefinitions })}\n />\n <DataQueriesProvider definitions={queries}>\n <Box height={PANEL_PREVIEW_HEIGHT}>\n <Panel\n panelOptions={{ hideHeader: true }}\n definition={{\n kind: 'Panel',\n spec: {\n queries,\n display: { name: '' },\n plugin: { kind: 'SilenceTable', spec: {} },\n },\n }}\n />\n </Box>\n </DataQueriesProvider>\n </Stack>\n );\n}\n"],"names":["useCallback","useMemo","useRef","useState","Box","Button","Stack","BellOffIcon","DataQueriesProvider","MultiQueryEditor","useDatasourceClient","Panel","useExplorerManagerContext","useSnackbar","useQueryClient","SilenceForm","DEFAULT_ALERTMANAGER","PANEL_PREVIEW_HEIGHT","extractSelectorFromQueries","queries","spec","plugin","ds","datasource","CreateSilenceButton","datasourceSelector","data","amClient","queryClient","successSnackbar","exceptionSnackbar","open","setOpen","formKeyRef","handleOpen","current","handleSubmit","silence","createSilence","invalidateQueries","queryKey","err","variant","startIcon","onClick","size","onClose","onSubmit","AlertManagerSilencesExplorer","setData","queryDefinitions","setQueryDefinitions","gap","sx","width","direction","justifyContent","queryTypes","onChange","state","onQueryRun","definitions","height","panelOptions","hideHeader","definition","kind","display","name"],"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,SAAuBA,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC7E,SAASC,GAAG,EAAEC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AACnD,OAAOC,iBAAiB,0BAA0B;AAClD,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,mBAAmB,QAAQ,4BAA4B;AACvG,SAASC,KAAK,QAAQ,yBAAyB;AAC/C,SAASC,yBAAyB,QAAQ,sBAAsB;AAEhE,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAA6BC,oBAAoB,QAAyB,WAAW;AAMrF,MAAMC,uBAAuB;AAE7B,SAASC,2BAA2BC,OAA0B;IAC5D,MAAMC,OAAgBD,OAAO,CAAC,EA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AM,CAACsC,kBAAkBC,oBAAoB,GAAGhD,SAA4BgB;IAE5E,qBACE,MAACb;QAAM8C,KAAK;QAAGC,IAAI;YAAEC,OAAO;QAAO;;0BACjC,KAAChD;gBAAMiD,WAAU;gBAAMC,gBAAe;0BACpC,cAAA,KAAChC;oBAAoBL,SAASA;;;0BAEhC,KAACV;gBACCgD,YAAY;oBAAC;iBAAgB;gBAC7BC,UAAU,CAACC,QAAUR,oBAAoBQ;gBACzCxC,SAAS+B;gBACTU,YAAY,IAAMX,QAAQ;wBAAE9B,SAAS+B;oBAAiB;;0BAExD,KAAC1C;gBAAoBqD,aAAa1C;0BAChC,cAAA,KAACf;oBAAI0D,QAAQ7C;8BACX,cAAA,KAACN;wBACCoD,cAAc;4BAAEC,YAAY;wBAAK;wBACjCC,YAAY;4BACVC,MAAM;4BACN9C,MAAM;gCACJD;gCACAgD,SAAS;oCAAEC,MAAM;gCAAG;gCACpB/C,QAAQ;oCAAE6C,MAAM;oCAAgB9C,MAAM,CAAC;gCAAE;4BAC3C;wBACF;;;;;;AAMZ"}
1
+ {"version":3,"sources":["../../../src/explore/AlertManagerSilencesExplorer.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\nimport { ReactElement, useCallback, useMemo, useRef, useState } from 'react';\nimport { Box, Button, Stack } from '@mui/material';\nimport BellOffIcon from 'mdi-material-ui/BellOff';\nimport { DataQueriesProvider, MultiQueryEditor, useDatasourceClient } from '@perses-dev/plugin-system';\nimport { Panel } from '@perses-dev/dashboards';\nimport { useExplorerManagerContext } from '@perses-dev/explore';\nimport { DatasourceSelector, QueryDefinition } from '@perses-dev/spec';\nimport { useSnackbar } from '@perses-dev/components';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { SilenceForm } from '../components/SilenceForm';\nimport { AlertManagerClient, DEFAULT_ALERTMANAGER, PostableSilence } from '../model';\n\ninterface SilencesExplorerQueryParams {\n queries?: QueryDefinition[];\n}\n\nconst PANEL_PREVIEW_HEIGHT = 600;\n\nfunction extractSelectorFromQueries(queries: QueryDefinition[]): DatasourceSelector {\n const spec: unknown = queries[0]?.spec?.plugin?.spec;\n if (spec && typeof spec === 'object' && 'datasource' in spec) {\n const ds = (spec as Record<string, unknown>).datasource;\n if (ds && typeof ds === 'object' && 'kind' in ds) {\n return ds as DatasourceSelector;\n }\n }\n return DEFAULT_ALERTMANAGER;\n}\n\nfunction CreateSilenceButton({ queries }: { queries: QueryDefinition[] }): ReactElement {\n const datasourceSelector = useMemo(() => extractSelectorFromQueries(queries), [queries]);\n const { data: amClient } = useDatasourceClient<AlertManagerClient>(datasourceSelector);\n const queryClient = useQueryClient();\n const { successSnackbar, exceptionSnackbar } = useSnackbar();\n\n const [open, setOpen] = useState(false);\n const formKeyRef = useRef(0);\n\n const handleOpen = useCallback(() => {\n formKeyRef.current++;\n setOpen(true);\n }, []);\n\n const handleSubmit = useCallback(\n async (silence: PostableSilence) => {\n if (!amClient) return;\n try {\n await amClient.createSilence(silence);\n setOpen(false);\n successSnackbar('Silence created successfully');\n queryClient.invalidateQueries({ queryKey: ['query', 'SilencesQuery'] });\n } catch (err) {\n exceptionSnackbar(err);\n }\n },\n [amClient, queryClient, successSnackbar, exceptionSnackbar]\n );\n\n return (\n <>\n <Button variant=\"contained\" startIcon={<BellOffIcon />} onClick={handleOpen} size=\"small\">\n Create Silence\n </Button>\n <SilenceForm key={formKeyRef.current} open={open} onClose={() => setOpen(false)} onSubmit={handleSubmit} />\n </>\n );\n}\n\nexport function AlertManagerSilencesExplorer(): ReactElement {\n const {\n data: { queries = [] },\n setData,\n } = useExplorerManagerContext<SilencesExplorerQueryParams>();\n\n const [queryDefinitions, setQueryDefinitions] = useState<QueryDefinition[]>(queries);\n\n return (\n <Stack gap={2} sx={{ width: '100%' }}>\n <Stack direction=\"row\" justifyContent=\"flex-end\">\n <CreateSilenceButton queries={queries} />\n </Stack>\n <MultiQueryEditor\n queryTypes={['SilencesQuery']}\n onChange={(state) => setQueryDefinitions(state)}\n queries={queryDefinitions}\n onQueryRun={() => setData({ queries: queryDefinitions })}\n />\n <DataQueriesProvider definitions={queries}>\n <Box height={PANEL_PREVIEW_HEIGHT}>\n <Panel\n panelOptions={{ hideHeader: true }}\n definition={{\n kind: 'Panel',\n spec: {\n queries,\n display: { name: '' },\n plugin: { kind: 'SilenceTable', spec: {} },\n },\n }}\n />\n </Box>\n </DataQueriesProvider>\n </Stack>\n );\n}\n"],"names":["useCallback","useMemo","useRef","useState","Box","Button","Stack","BellOffIcon","DataQueriesProvider","MultiQueryEditor","useDatasourceClient","Panel","useExplorerManagerContext","useSnackbar","useQueryClient","SilenceForm","DEFAULT_ALERTMANAGER","PANEL_PREVIEW_HEIGHT","extractSelectorFromQueries","queries","spec","plugin","ds","datasource","CreateSilenceButton","datasourceSelector","data","amClient","queryClient","successSnackbar","exceptionSnackbar","open","setOpen","formKeyRef","handleOpen","current","handleSubmit","silence","createSilence","invalidateQueries","queryKey","err","variant","startIcon","onClick","size","onClose","onSubmit","AlertManagerSilencesExplorer","setData","queryDefinitions","setQueryDefinitions","gap","sx","width","direction","justifyContent","queryTypes","onChange","state","onQueryRun","definitions","height","panelOptions","hideHeader","definition","kind","display","name"],"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,SAAuBA,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC7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C,UAAU;oBAAC;oBAAS;iBAAgB;YAAC;QACvE,EAAE,OAAOC,KAAK;YACZX,kBAAkBW;QACpB;IACF,GACA;QAACd;QAAUC;QAAaC;QAAiBC;KAAkB;IAG7D,qBACE;;0BACE,KAACzB;gBAAOqC,SAAQ;gBAAYC,yBAAW,KAACpC;gBAAgBqC,SAASV;gBAAYW,MAAK;0BAAQ;;0BAG1F,KAAC9B;gBAAqCgB,MAAMA;gBAAMe,SAAS,IAAMd,QAAQ;gBAAQe,UAAUX;eAAzEH,WAAWE,OAAO;;;AAG1C;AAEA,OAAO,SAASa;IACd,MAAM,EACJtB,MAAM,EAAEP,UAAU,EAAE,EAAE,EACtB8B,OAAO,EACR,GAAGrC;IAEJ,MAAM,CAACsC,kBAAkBC,oBAAoB,GAAGhD,SAA4BgB;IAE5E,qBACE,MAACb;QAAM8C,KAAK;QAAGC,IAAI;YAAEC,OAAO;QAAO;;0BACjC,KAAChD;gBAAMiD,WAAU;gBAAMC,gBAAe;0BACpC,cAAA,KAAChC;oBAAoBL,SAASA;;;0BAEhC,KAACV;gBACCgD,YAAY;oBAAC;iBAAgB;gBAC7BC,UAAU,CAACC,QAAUR,oBAAoBQ;gBACzCxC,SAAS+B;gBACTU,YAAY,IAAMX,QAAQ;wBAAE9B,SAAS+B;oBAAiB;;0BAExD,KAAC1C;gBAAoBqD,aAAa1C;0BAChC,cAAA,KAACf;oBAAI0D,QAAQ7C;8BACX,cAAA,KAACN;wBACCoD,cAAc;4BAAEC,YAAY;wBAAK;wBACjCC,YAAY;4BACVC,MAAM;4BACN9C,MAAM;gCACJD;gCACAgD,SAAS;oCAAEC,MAAM;gCAAG;gCACpB/C,QAAQ;oCAAE6C,MAAM;oCAAgB9C,MAAM,CAAC;gCAAE;4BAC3C;wBACF;;;;;;AAMZ"}
@@ -1,4 +1,4 @@
1
- import { RequestHeaders } from '@perses-dev/core';
1
+ import { RequestHeaders } from '@perses-dev/client';
2
2
  import { DatasourceClient } from '@perses-dev/plugin-system';
3
3
  import { AlertManagerStatus, AlertsQueryParams, GettableAlert, GettableSilence, PostableSilence, SilencesQueryParams } from './api-types';
4
4
  export interface AlertManagerQueryOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"alertmanager-client.d.ts","sourceRoot":"","sources":["../../../src/model/alertmanager-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAS,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,OAAO,EAAE,wBAAwB,CAAC;IAClC,SAAS,CAAC,MAAM,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1F,WAAW,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAChG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3E,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClG,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAk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;AAED,wBAAgB,SAAS,CAAC,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE7F"}
@@ -10,7 +10,7 @@
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 { fetch } from '@perses-dev/core';
13
+ import { fetch } from '@perses-dev/client';
14
14
  async function throwOnError(response) {
15
15
  if (!response.ok) {
16
16
  let message = response.statusText;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/alertmanager-client.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 { fetch, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n AlertManagerStatus,\n AlertsQueryParams,\n GettableAlert,\n GettableSilence,\n PostableSilence,\n SilencesQueryParams,\n} from './api-types';\n\nexport interface AlertManagerQueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface AlertManagerClient extends DatasourceClient {\n options: AlertManagerQueryOptions;\n getAlerts(params?: AlertsQueryParams, headers?: RequestHeaders): Promise<GettableAlert[]>;\n getSilences(params?: SilencesQueryParams, headers?: RequestHeaders): Promise<GettableSilence[]>;\n getSilence(id: string, headers?: RequestHeaders): Promise<GettableSilence>;\n createSilence(silence: PostableSilence, headers?: RequestHeaders): Promise<{ silenceID: string }>;\n deleteSilence(id: string, headers?: RequestHeaders): Promise<void>;\n getStatus(headers?: RequestHeaders): Promise<AlertManagerStatus>;\n}\n\nasync function throwOnError(response: Response): Promise<void> {\n if (!response.ok) {\n let message = response.statusText;\n try {\n const body = await response.json();\n if (body?.message) message = body.message;\n } catch {\n // no JSON body\n }\n throw new Error(message);\n }\n}\n\nconst executeRequest = async <T>(...args: Parameters<typeof fetch>): Promise<T> => {\n const response = await fetch(...args);\n await throwOnError(response);\n try {\n return await response.json();\n } catch (e) {\n console.error('Invalid response from server', e);\n throw new Error('Invalid response from server');\n }\n};\n\nfunction buildSearchParams(params: Record<string, unknown> | object): URLSearchParams {\n const urlSearchParams = new URLSearchParams();\n Object.entries(params).forEach(([key, value]) => {\n if (value === undefined) {\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((entry) => urlSearchParams.append(key, String(entry)));\n return;\n }\n urlSearchParams.append(key, String(value));\n });\n return urlSearchParams;\n}\n\nfunction fetchWithGet<TResponse>(\n apiURI: string,\n params: Record<string, unknown> | object,\n queryOptions: AlertManagerQueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = buildSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n\n return executeRequest<TResponse>(url, {\n method: 'GET',\n headers,\n });\n}\n\nexport function getAlerts(\n params?: AlertsQueryParams,\n queryOptions?: AlertManagerQueryOptions\n): Promise<GettableAlert[]> {\n const opts = queryOptions ?? { datasourceUrl: '' };\n return fetchWithGet<GettableAlert[]>('/api/v2/alerts', params ?? {}, opts);\n}\n\nexport function getSilences(\n params?: SilencesQueryParams,\n queryOptions?: AlertManagerQueryOptions\n): Promise<GettableSilence[]> {\n const opts = queryOptions ?? { datasourceUrl: '' };\n return fetchWithGet<GettableSilence[]>('/api/v2/silences', params ?? {}, opts);\n}\n\nexport function getSilence(id: string, queryOptions: AlertManagerQueryOptions): Promise<GettableSilence> {\n return fetchWithGet<GettableSilence>(`/api/v2/silence/${encodeURIComponent(id)}`, {}, queryOptions);\n}\n\nexport function createSilence(\n silence: PostableSilence,\n queryOptions: AlertManagerQueryOptions\n): Promise<{ silenceID: string }> {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n return executeRequest<{ silenceID: string }>(`${datasourceUrl}/api/v2/silences`, {\n method: 'POST',\n headers: { ...headers, 'Content-Type': 'application/json' },\n body: JSON.stringify(silence),\n });\n}\n\nexport async function deleteSilence(id: string, queryOptions: AlertManagerQueryOptions): Promise<void> {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n const response = await fetch(`${datasourceUrl}/api/v2/silence/${encodeURIComponent(id)}`, {\n method: 'DELETE',\n headers,\n });\n\n await throwOnError(response);\n}\n\nexport function getStatus(queryOptions: AlertManagerQueryOptions): Promise<AlertManagerStatus> {\n return fetchWithGet<AlertManagerStatus>('/api/v2/status', {}, queryOptions);\n}\n"],"names":["fetch","throwOnError","response","ok","message","statusText","body","json","Error","executeRequest","args","e","console","error","buildSearchParams","params","urlSearchParams","URLSearchParams","Object","entries","forEach","key","value","undefined","Array","isArray","entry","append","String","fetchWithGet","apiURI","queryOptions","datasourceUrl","headers","url","urlParams","toString","method","getAlerts","opts","getSilences","getSilence","id","encodeURIComponent","createSilence","silence","JSON","stringify","deleteSilence","getStatus"],"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,KAAK,QAAwB,mBAAmB;AA0BzD,eAAeC,aAAaC,QAAkB;IAC5C,IAAI,CAACA,SAASC,EAAE,EAAE;QAChB,IAAIC,UAAUF,SAASG,UAAU;QACjC,IAAI;YACF,MAAMC,OAAO,MAAMJ,SAASK,IAAI;YAChC,IAAID,MAAMF,SAASA,UAAUE,KAAKF,OAAO;QAC3C,EAAE,OAAM;QACN,eAAe;QACjB;QACA,MAAM,IAAII,MAAMJ;IAClB;AACF;AAEA,MAAMK,iBAAiB,OAAU,G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WC,EAAU,EAAEX,YAAsC;IAC3E,OAAOF,aAA8B,CAAC,gBAAgB,EAAEc,mBAAmBD,KAAK,EAAE,CAAC,GAAGX;AACxF;AAEA,OAAO,SAASa,cACdC,OAAwB,EACxBd,YAAsC;IAEtC,MAAM,EAAEC,aAAa,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGF;IAExC,OAAOtB,eAAsC,GAAGuB,cAAc,gBAAgB,CAAC,EAAE;QAC/EK,QAAQ;QACRJ,SAAS;YAAE,GAAGA,OAAO;YAAE,gBAAgB;QAAmB;QAC1D3B,MAAMwC,KAAKC,SAAS,CAACF;IACvB;AACF;AAEA,OAAO,eAAeG,cAAcN,EAAU,EAAEX,YAAsC;IACpF,MAAM,EAAEC,aAAa,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGF;IAExC,MAAM7B,WAAW,MAAMF,MAAM,GAAGgC,cAAc,gBAAgB,EAAEW,mBAAmBD,KAAK,EAAE;QACxFL,QAAQ;QACRJ;IACF;IAEA,MAAMhC,aAAaC;AACrB;AAEA,OAAO,SAAS+C,UAAUlB,YAAsC;IAC9D,OAAOF,aAAiC,kBAAkB,CAAC,GAAGE;AAChE"}
1
+ {"version":3,"sources":["../../../src/model/alertmanager-client.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 { fetch, RequestHeaders } from '@perses-dev/client';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n AlertManagerStatus,\n AlertsQueryParams,\n GettableAlert,\n GettableSilence,\n PostableSilence,\n SilencesQueryParams,\n} from './api-types';\n\nexport interface AlertManagerQueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface AlertManagerClient extends DatasourceClient {\n options: AlertManagerQueryOptions;\n getAlerts(params?: AlertsQueryParams, headers?: RequestHeaders): Promise<GettableAlert[]>;\n getSilences(params?: SilencesQueryParams, headers?: RequestHeaders): Promise<GettableSilence[]>;\n getSilence(id: string, headers?: RequestHeaders): Promise<GettableSilence>;\n createSilence(silence: PostableSilence, headers?: RequestHeaders): Promise<{ silenceID: string }>;\n deleteSilence(id: string, headers?: RequestHeaders): Promise<void>;\n getStatus(headers?: RequestHeaders): Promise<AlertManagerStatus>;\n}\n\nasync function throwOnError(response: Response): Promise<void> {\n if (!response.ok) {\n let message = response.statusText;\n try {\n const body = await response.json();\n if (body?.message) message = body.message;\n } catch {\n // no JSON body\n }\n throw new Error(message);\n }\n}\n\nconst executeRequest = async <T>(...args: Parameters<typeof fetch>): Promise<T> => {\n const response = await fetch(...args);\n await throwOnError(response);\n try {\n return await response.json();\n } catch (e) {\n console.error('Invalid response from server', e);\n throw new Error('Invalid response from server');\n }\n};\n\nfunction buildSearchParams(params: Record<string, unknown> | object): URLSearchParams {\n const urlSearchParams = new URLSearchParams();\n Object.entries(params).forEach(([key, value]) => {\n if (value === undefined) {\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((entry) => urlSearchParams.append(key, String(entry)));\n return;\n }\n urlSearchParams.append(key, String(value));\n });\n return urlSearchParams;\n}\n\nfunction fetchWithGet<TResponse>(\n apiURI: string,\n params: Record<string, unknown> | object,\n queryOptions: AlertManagerQueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = buildSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n\n return executeRequest<TResponse>(url, {\n method: 'GET',\n headers,\n });\n}\n\nexport function getAlerts(\n params?: AlertsQueryParams,\n queryOptions?: AlertManagerQueryOptions\n): Promise<GettableAlert[]> {\n const opts = queryOptions ?? { datasourceUrl: '' };\n return fetchWithGet<GettableAlert[]>('/api/v2/alerts', params ?? {}, opts);\n}\n\nexport function getSilences(\n params?: SilencesQueryParams,\n queryOptions?: AlertManagerQueryOptions\n): Promise<GettableSilence[]> {\n const opts = queryOptions ?? { datasourceUrl: '' };\n return fetchWithGet<GettableSilence[]>('/api/v2/silences', params ?? {}, opts);\n}\n\nexport function getSilence(id: string, queryOptions: AlertManagerQueryOptions): Promise<GettableSilence> {\n return fetchWithGet<GettableSilence>(`/api/v2/silence/${encodeURIComponent(id)}`, {}, queryOptions);\n}\n\nexport function createSilence(\n silence: PostableSilence,\n queryOptions: AlertManagerQueryOptions\n): Promise<{ silenceID: string }> {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n return executeRequest<{ silenceID: string }>(`${datasourceUrl}/api/v2/silences`, {\n method: 'POST',\n headers: { ...headers, 'Content-Type': 'application/json' },\n body: JSON.stringify(silence),\n });\n}\n\nexport async function deleteSilence(id: string, queryOptions: AlertManagerQueryOptions): Promise<void> {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n const response = await fetch(`${datasourceUrl}/api/v2/silence/${encodeURIComponent(id)}`, {\n method: 'DELETE',\n headers,\n });\n\n await throwOnError(response);\n}\n\nexport function getStatus(queryOptions: AlertManagerQueryOptions): Promise<AlertManagerStatus> {\n return fetchWithGet<AlertManagerStatus>('/api/v2/status', {}, queryOptions);\n}\n"],"names":["fetch","throwOnError","response","ok","message","statusText","body","json","Error","executeRequest","args","e","console","error","buildSearchParams","params","urlSearchParams","URLSearchParams","Object","entries","forEach","key","value","undefined","Array","isArray","entry","append","String","fetchWithGet","apiURI","queryOptions","datasourceUrl","headers","url","urlParams","toString","method","getAlerts","opts","getSilences","getSilence","id","encodeURIComponent","createSilence","silence","JSON","stringify","deleteSilence","getStatus"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAA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-dev/spec';
2
2
  import { DatasourceSelectValue } from '@perses-dev/plugin-system';
3
3
  export declare const ALERTMANAGER_DATASOURCE_KIND: "AlertManagerDatasource";
4
4
  export interface AlertManagerDatasourceSelector extends DatasourceSelector {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/alertmanager-selectors.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 { DatasourceSelector, QueryDefinition } from '@perses-dev/core';\nimport { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system';\n\nexport const ALERTMANAGER_DATASOURCE_KIND = 'AlertManagerDatasource' as const;\n\nexport interface AlertManagerDatasourceSelector extends DatasourceSelector {\n kind: typeof ALERTMANAGER_DATASOURCE_KIND;\n}\n\nexport const DEFAULT_ALERTMANAGER: AlertManagerDatasourceSelector = { kind: ALERTMANAGER_DATASOURCE_KIND };\n\nexport function isDefaultAlertManagerSelector(datasourceSelectValue: DatasourceSelectValue): boolean {\n return !isVariableDatasource(datasourceSelectValue) && datasourceSelectValue.name === undefined;\n}\n\nexport function isAlertManagerDatasourceSelector(\n datasourceSelectValue: DatasourceSelectValue\n): datasourceSelectValue is AlertManagerDatasourceSelector {\n return isVariableDatasource(datasourceSelectValue) || datasourceSelectValue.kind === ALERTMANAGER_DATASOURCE_KIND;\n}\n\nexport function extractDatasourceSelector(queryResults: Array<{ definition: QueryDefinition }>): DatasourceSelector {\n const defSpec: unknown = queryResults[0]?.definition?.spec;\n if (defSpec && typeof defSpec === 'object' && 'plugin' in defSpec) {\n const plugin = (defSpec as Record<string, unknown>).plugin;\n if (plugin && typeof plugin === 'object' && 'spec' in plugin) {\n const spec = (plugin as Record<string, unknown>).spec;\n if (spec && typeof spec === 'object' && 'datasource' in spec) {\n const ds = (spec as Record<string, unknown>).datasource;\n if (ds && typeof ds === 'object' && 'kind' in ds) {\n return ds as DatasourceSelector;\n }\n }\n }\n }\n return DEFAULT_ALERTMANAGER;\n}\n"],"names":["isVariableDatasource","ALERTMANAGER_DATASOURCE_KIND","DEFAULT_ALERTMANAGER","kind","isDefaultAlertManagerSelector","datasourceSelectValue","name","undefined","isAlertManagerDatasourceSelector","extractDatasourceSelector","queryResults","defSpec","definition","spec","plugin","ds","datasource"],"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;AAGjC,SAAgCA,oBAAoB,QAAQ,4BAA4B;AAExF,OAAO,MAAMC,+BAA+B,yBAAkC;AAM9E,OAAO,MAAMC,uBAAuD;IAAEC,MAAMF;AAA6B,EAAE;AAE3G,OAAO,SAASG,8BAA8BC,qBAA4C;IACxF,OAAO,CAACL,qBAAqBK,0BAA0BA,sBAAsBC,IAAI,KAAKC;AACxF;AAEA,OAAO,SAASC,iCACdH,qBAA4C;IAE5C,OAAOL,qBAAqBK,0BAA0BA,sBAAsBF,IAAI,KAAKF;AACvF;AAEA,OAAO,SAASQ,0BAA0BC,YAAoD;IAC5F,MAAMC,UAAmBD,YAAY,CAAC,EAAE,EAAEE,YAAYC;IACtD,IAAIF,WAAW,OAAOA,YAAY,YAAY,YAAYA,SAAS;QACjE,MAAMG,SAAS,AAACH,QAAoCG,MAAM;QAC1D,IAAIA,UAAU,OAAOA,WAAW,YAAY,UAAUA,QAAQ;YAC5D,MAAMD,OAAO,AAACC,OAAmCD,IAAI;YACrD,IAAIA,QAAQ,OAAOA,SAAS,YAAY,gBAAgBA,MAAM;gBAC5D,MAAME,KAAK,AAACF,KAAiCG,UAAU;gBACvD,IAAID,MAAM,OAAOA,OAAO,YAAY,UAAUA,IAAI;oBAChD,OAAOA;gBACT;YACF;QACF;IACF;IACA,OAAOb;AACT"}
1
+ {"version":3,"sources":["../../../src/model/alertmanager-selectors.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 { DatasourceSelector, QueryDefinition } from '@perses-dev/spec';\nimport { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system';\n\nexport const ALERTMANAGER_DATASOURCE_KIND = 'AlertManagerDatasource' as const;\n\nexport interface AlertManagerDatasourceSelector extends DatasourceSelector {\n kind: typeof ALERTMANAGER_DATASOURCE_KIND;\n}\n\nexport const DEFAULT_ALERTMANAGER: AlertManagerDatasourceSelector = { kind: ALERTMANAGER_DATASOURCE_KIND };\n\nexport function isDefaultAlertManagerSelector(datasourceSelectValue: DatasourceSelectValue): boolean {\n return !isVariableDatasource(datasourceSelectValue) && datasourceSelectValue.name === undefined;\n}\n\nexport function isAlertManagerDatasourceSelector(\n datasourceSelectValue: DatasourceSelectValue\n): datasourceSelectValue is AlertManagerDatasourceSelector {\n return isVariableDatasource(datasourceSelectValue) || datasourceSelectValue.kind === ALERTMANAGER_DATASOURCE_KIND;\n}\n\nexport function extractDatasourceSelector(queryResults: Array<{ definition: QueryDefinition }>): DatasourceSelector {\n const defSpec: unknown = queryResults[0]?.definition?.spec;\n if (defSpec && typeof defSpec === 'object' && 'plugin' in defSpec) {\n const plugin = (defSpec as Record<string, unknown>).plugin;\n if (plugin && typeof plugin === 'object' && 'spec' in plugin) {\n const spec = (plugin as Record<string, unknown>).spec;\n if (spec && typeof spec === 'object' && 'datasource' in spec) {\n const ds = (spec as Record<string, unknown>).datasource;\n if (ds && typeof ds === 'object' && 'kind' in ds) {\n return ds as DatasourceSelector;\n }\n }\n }\n }\n return DEFAULT_ALERTMANAGER;\n}\n"],"names":["isVariableDatasource","ALERTMANAGER_DATASOURCE_KIND","DEFAULT_ALERTMANAGER","kind","isDefaultAlertManagerSelector","datasourceSelectValue","name","undefined","isAlertManagerDatasourceSelector","extractDatasourceSelector","queryResults","defSpec","definition","spec","plugin","ds","datasource"],"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;AAGjC,SAAgCA,oBAAoB,QAAQ,4BAA4B;AAExF,OAAO,MAAMC,+BAA+B,yBAAkC;AAM9E,OAAO,MAAMC,uBAAuD;IAAEC,MAAMF;AAA6B,EAAE;AAE3G,OAAO,SAASG,8BAA8BC,qBAA4C;IACxF,OAAO,CAACL,qBAAqBK,0BAA0BA,sBAAsBC,IAAI,KAAKC;AACxF;AAEA,OAAO,SAASC,iCACdH,qBAA4C;IAE5C,OAAOL,qBAAqBK,0BAA0BA,sBAAsBF,IAAI,KAAKF;AACvF;AAEA,OAAO,SAASQ,0BAA0BC,YAAoD;IAC5F,MAAMC,UAAmBD,YAAY,CAAC,EAAE,EAAEE,YAAYC;IACtD,IAAIF,WAAW,OAAOA,YAAY,YAAY,YAAYA,SAAS;QACjE,MAAMG,SAAS,AAACH,QAAoCG,MAAM;QAC1D,IAAIA,UAAU,OAAOA,WAAW,YAAY,UAAUA,QAAQ;YAC5D,MAAMD,OAAO,AAACC,OAAmCD,IAAI;YACrD,IAAIA,QAAQ,OAAOA,SAAS,YAAY,gBAAgBA,MAAM;gBAC5D,MAAME,KAAK,AAACF,KAAiCG,UAAU;gBACvD,IAAID,MAAM,OAAOA,OAAO,YAAY,UAAUA,IAAI;oBAChD,OAAOA;gBACT;YACF;QACF;IACF;IACA,OAAOb;AACT"}
@@ -1,4 +1,4 @@
1
- import { HTTPProxy } from '@perses-dev/core';
1
+ import { HTTPProxy } from '@perses-dev/spec';
2
2
  import { DatasourceSelectValue } from '@perses-dev/plugin-system';
3
3
  import { AlertManagerDatasourceSelector } from '../model/alertmanager-selectors';
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/types.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 { HTTPProxy } from '@perses-dev/core';\nimport { DatasourceSelectValue } from '@perses-dev/plugin-system';\nimport { AlertManagerDatasourceSelector } from '../model/alertmanager-selectors';\n\n/**\n * Datasource spec for the Alert Manager datasource plugin.\n */\nexport interface AlertManagerDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\n}\n\n/**\n * Query spec for the Alert Manager alerts query plugin.\n */\nexport interface AlertManagerAlertsQuerySpec {\n datasource?: DatasourceSelectValue<AlertManagerDatasourceSelector>;\n filters?: string[];\n active?: boolean;\n silenced?: boolean;\n inhibited?: boolean;\n unprocessed?: boolean;\n receiver?: string;\n}\n\n/**\n * Query spec for the Alert Manager silences query plugin.\n */\nexport interface AlertManagerSilencesQuerySpec {\n datasource?: DatasourceSelectValue<AlertManagerDatasourceSelector>;\n filters?: string[];\n}\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;AA2BjC;;CAEC,GACD,WAGC"}
1
+ {"version":3,"sources":["../../../src/plugins/types.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 { HTTPProxy } from '@perses-dev/spec';\nimport { DatasourceSelectValue } from '@perses-dev/plugin-system';\nimport { AlertManagerDatasourceSelector } from '../model/alertmanager-selectors';\n\n/**\n * Datasource spec for the Alert Manager datasource plugin.\n */\nexport interface AlertManagerDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\n}\n\n/**\n * Query spec for the Alert Manager alerts query plugin.\n */\nexport interface AlertManagerAlertsQuerySpec {\n datasource?: DatasourceSelectValue<AlertManagerDatasourceSelector>;\n filters?: string[];\n active?: boolean;\n silenced?: boolean;\n inhibited?: boolean;\n unprocessed?: boolean;\n receiver?: string;\n}\n\n/**\n * Query spec for the Alert Manager silences query plugin.\n */\nexport interface AlertManagerSilencesQuerySpec {\n datasource?: DatasourceSelectValue<AlertManagerDatasourceSelector>;\n filters?: string[];\n}\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;AA2BjC;;CAEC,GACD,WAGC"}