@perses-dev/plugin-system 0.45.0 → 0.46.0-rc0
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.
- package/dist/cjs/runtime/time-series-queries.js +8 -3
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/model/panels.d.ts +7 -0
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +2 -0
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +3 -4
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +2 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +8 -3
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/package.json +4 -4
|
@@ -55,7 +55,7 @@ function filterVariableStateMap(v, names) {
|
|
|
55
55
|
return Object.fromEntries(Object.entries(v).filter(([name])=>names.includes(name)));
|
|
56
56
|
}
|
|
57
57
|
function getQueryOptions({ plugin, definition, context }) {
|
|
58
|
-
const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;
|
|
58
|
+
const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;
|
|
59
59
|
const dependencies = (plugin === null || plugin === void 0 ? void 0 : plugin.dependsOn) ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
|
|
60
60
|
const variableDependencies = dependencies === null || dependencies === void 0 ? void 0 : dependencies.variables;
|
|
61
61
|
// Determine queryKey
|
|
@@ -66,6 +66,7 @@ function getQueryOptions({ plugin, definition, context }) {
|
|
|
66
66
|
timeRange,
|
|
67
67
|
datasourceStore,
|
|
68
68
|
suggestedStepMs,
|
|
69
|
+
mode,
|
|
69
70
|
variablesValueKey,
|
|
70
71
|
refreshKey
|
|
71
72
|
];
|
|
@@ -111,7 +112,11 @@ const useTimeSeriesQuery = (definition, options, queryOptions)=>{
|
|
|
111
112
|
};
|
|
112
113
|
function useTimeSeriesQueries(definitions, options, queryOptions) {
|
|
113
114
|
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
114
|
-
const context =
|
|
115
|
+
const context = {
|
|
116
|
+
...useTimeSeriesQueryContext(),
|
|
117
|
+
// We need mode to be part query key because this drives the type of query done (instant VS range query)
|
|
118
|
+
mode: options === null || options === void 0 ? void 0 : options.mode
|
|
119
|
+
};
|
|
115
120
|
const pluginLoaderResponse = (0, _pluginregistry.usePlugins)(TIME_SERIES_QUERY_KEY, definitions.map((d)=>({
|
|
116
121
|
kind: d.spec.plugin.kind
|
|
117
122
|
})));
|
|
@@ -129,9 +134,9 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
|
|
|
129
134
|
enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) && queryEnabled,
|
|
130
135
|
queryKey: queryKey,
|
|
131
136
|
queryFn: async ()=>{
|
|
132
|
-
// Keep options out of query key so we don't re-run queries because suggested step changes
|
|
133
137
|
const ctx = {
|
|
134
138
|
...context,
|
|
139
|
+
// Keep suggested step changes out of the query key, so we don´t have to run again query when it changes
|
|
135
140
|
suggestedStepMs: options === null || options === void 0 ? void 0 : options.suggestedStepMs
|
|
136
141
|
};
|
|
137
142
|
const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,
|
|
1
|
+
{"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIpE,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAChD;AA6BD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,OAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CA8E7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { QueryEditorContainer } from './QueryEditorContainer';\n\nexport interface MultiQueryEditorProps {\n queryTypes: QueryPluginType[];\n queries?: QueryDefinition[];\n onChange: (queries: QueryDefinition[]) => void;\n}\n\nfunction useDefaultQueryDefinition(queryTypes: QueryPluginType[]): QueryDefinition {\n // Build the default query plugin\n // This will be used only if the queries are empty, to open a starting query\n\n // Firs the default query type\n const defaultQueryType = queryTypes[0]!;\n\n // Then the default plugin kind\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { data: queryPlugins } = useListPluginMetadata(queryTypes);\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.kind ?? '';\n\n const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n return {\n kind: defaultQueryType,\n spec: {\n plugin: { kind: defaultQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n };\n}\n\n/**\n * A component render a list of {@link QueryEditor} for the given query definitions.\n * It allows adding, removing and editing queries.\n * @param queryTypes The list of query types that the underlying editor will propose\n * @param queries The list of query definitions to render\n * @param onChange The callback to call when the queries are modified\n * @constructor\n */\nexport function MultiQueryEditor({ queryTypes, queries = [], onChange }: MultiQueryEditorProps) {\n const defaultInitialQueryDefinition = useDefaultQueryDefinition(queryTypes);\n\n // State for which queries are collapsed\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: QueryDefinition) => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n })\n );\n };\n\n const handleQueryAdd = () => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number) => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number) => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n const queryDefinitions: QueryDefinition[] = queries.length ? queries : [defaultInitialQueryDefinition];\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: QueryDefinition, i: number) => (\n <QueryEditorContainer\n queryTypes={queryTypes}\n key={i}\n index={i}\n query={query}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n}\n"],"names":["useState","produce","Button","Stack","AddIcon","useListPluginMetadata","usePlugin","usePluginRegistry","QueryEditorContainer","useDefaultQueryDefinition","queryTypes","queryPlugins","defaultQueryType","data","defaultPluginKinds","defaultQueryKind","kind","defaultQueryPlugin","useErrorBoundary","enabled","spec","plugin","createInitialOptions","MultiQueryEditor","queries","onChange","defaultInitialQueryDefinition","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","length","spacing","query","i","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAC9C,OAAOC,aAAa,uBAAuB;AAE3C,SAASC,qBAAqB,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpF,SAASC,oBAAoB,QAAQ,yBAAyB;AAQ9D,SAASC,0BAA0BC,UAA6B;QAWKC;IAVnE,iCAAiC;IACjC,4EAA4E;IAE5E,8BAA8B;IAC9B,MAAMC,mBAAmBF,UAAU,CAAC,EAAE;IAEtC,+BAA+B;IAC/B,oFAAoF;IACpF,MAAM,EAAEG,MAAMF,YAAY,EAAE,GAAGN,sBAAsBK;IACrD,MAAM,EAAEI,kBAAkB,EAAE,GAAGP;QACNO,sCAAAA;IAAzB,MAAMC,mBAAmBD,CAAAA,OAAAA,CAAAA,uCAAAA,+BAAAA,yCAAAA,kBAAoB,CAACF,iBAAiB,cAAtCE,kDAAAA,uCAA0CH,yBAAAA,oCAAAA,iBAAAA,YAAc,CAAC,EAAE,cAAjBA,qCAAAA,eAAmBK,IAAI,cAAjEF,kBAAAA,OAAqE;IAE9F,MAAM,EAAED,MAAMI,kBAAkB,EAAE,GAAGX,UAAUM,kBAAkBG,kBAAkB;QACjFG,kBAAkB;QAClBC,SAAS;IACX;IAEA,qGAAqG;IACrG,OAAO;QACLH,MAAMJ;QAC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A8B;IAEtG,qBACE;;0BACE,KAACvB;gBAAMsC,SAAS;0BACbF,iBAAiBV,GAAG,CAAC,CAACa,OAAwBC,kBAC7C,KAACnC;wBACCE,YAAYA;wBAEZqB,OAAOY;wBACPD,OAAOA;wBACPE,aAAa,CAAC,CAACjB,gBAAgB,CAACgB,EAAE;wBAClClB,UAAUK;wBACVe,UAAUrB,QAAQgB,MAAM,GAAG,IAAIJ,oBAAoBU;wBACnDC,kBAAkBT;uBANbK;;0BAUX,KAACzC;gBAAO8C,SAAQ;gBAAYC,yBAAW,KAAC7C;gBAAY8C,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASlB;0BAAgB;;;;AAKzG"}
|
package/dist/model/panels.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UnknownSpec, PanelDefinition, QueryPluginType } from '@perses-dev/core';
|
|
3
3
|
import { OptionsEditorTab } from '../components';
|
|
4
|
+
import { QueryOptions } from '../runtime';
|
|
4
5
|
import { OptionsEditorProps, Plugin } from './plugin-base';
|
|
5
6
|
export type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {
|
|
6
7
|
content: React.ComponentType<OptionsEditorProps<T>>;
|
|
@@ -19,6 +20,12 @@ export interface PanelPlugin<Spec = UnknownSpec> extends Plugin<Spec> {
|
|
|
19
20
|
* @default [] (no query types supported) only relevant if hideQueryEditor is true
|
|
20
21
|
*/
|
|
21
22
|
supportedQueryTypes?: QueryPluginType[];
|
|
23
|
+
/**
|
|
24
|
+
* Static options for the queries that will be executed.
|
|
25
|
+
* Each {@link QueryPluginType} implementation can have its own options.
|
|
26
|
+
* For example see {@link UseTimeSeriesQueryOptions} for time series queries.
|
|
27
|
+
*/
|
|
28
|
+
queryOptions?: QueryOptions;
|
|
22
29
|
/**
|
|
23
30
|
* If true, query editor will be hidden for panel plugin
|
|
24
31
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IAC7E,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACnE,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD;;OAEG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE;;;OAGG;IACH,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC;IACxC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B"}
|
|
1
|
+
{"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IAC7E,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACnE,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD;;OAEG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE;;;OAGG;IACH,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B"}
|
package/dist/model/panels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/panels.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport { UnknownSpec, PanelDefinition, QueryPluginType } from '@perses-dev/core';\nimport { OptionsEditorTab } from '../components';\nimport { OptionsEditorProps, Plugin } from './plugin-base';\n\nexport type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {\n content: React.ComponentType<OptionsEditorProps<T>>;\n};\n\n/**\n * Plugin the provides custom visualizations inside a Panel.\n */\nexport interface PanelPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n PanelComponent: React.ComponentType<PanelProps<Spec>>;\n /**\n * React components for custom tabs\n */\n panelOptionsEditorComponents?: Array<PanelOptionsEditorComponent<Spec>>;\n /**\n * List of query types supported by this panel.\n * @default [] (no query types supported) only relevant if hideQueryEditor is true\n */\n supportedQueryTypes?: QueryPluginType[];\n /**\n * If true, query editor will be hidden for panel plugin\n * @default false\n */\n hideQueryEditor?: boolean;\n}\n\n/**\n * The props provided by Perses to a panel plugin's PanelComponent.\n */\nexport interface PanelProps<Spec> {\n spec: Spec;\n contentDimensions?: {\n width: number;\n height: number;\n };\n definition?: PanelDefinition;\n}\n"],"names":["React"],"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,OAAOA,WAAW,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../../src/model/panels.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport { UnknownSpec, PanelDefinition, QueryPluginType } from '@perses-dev/core';\nimport { OptionsEditorTab } from '../components';\nimport { QueryOptions } from '../runtime';\nimport { OptionsEditorProps, Plugin } from './plugin-base';\n\nexport type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {\n content: React.ComponentType<OptionsEditorProps<T>>;\n};\n\n/**\n * Plugin the provides custom visualizations inside a Panel.\n */\nexport interface PanelPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n PanelComponent: React.ComponentType<PanelProps<Spec>>;\n /**\n * React components for custom tabs\n */\n panelOptionsEditorComponents?: Array<PanelOptionsEditorComponent<Spec>>;\n /**\n * List of query types supported by this panel.\n * @default [] (no query types supported) only relevant if hideQueryEditor is true\n */\n supportedQueryTypes?: QueryPluginType[];\n /**\n * Static options for the queries that will be executed.\n * Each {@link QueryPluginType} implementation can have its own options.\n * For example see {@link UseTimeSeriesQueryOptions} for time series queries.\n */\n queryOptions?: QueryOptions;\n /**\n * If true, query editor will be hidden for panel plugin\n * @default false\n */\n hideQueryEditor?: boolean;\n}\n\n/**\n * The props provided by Perses to a panel plugin's PanelComponent.\n */\nexport interface PanelProps<Spec> {\n spec: Spec;\n contentDimensions?: {\n width: number;\n height: number;\n };\n definition?: PanelDefinition;\n}\n"],"names":["React"],"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,OAAOA,WAAW,QAAQ"}
|
|
@@ -18,11 +18,13 @@ export interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec>
|
|
|
18
18
|
getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;
|
|
19
19
|
dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;
|
|
20
20
|
}
|
|
21
|
+
export type TimeSeriesQueryMode = 'instant' | 'range';
|
|
21
22
|
/**
|
|
22
23
|
* Context available to TimeSeriesQuery plugins at runtime.
|
|
23
24
|
*/
|
|
24
25
|
export interface TimeSeriesQueryContext {
|
|
25
26
|
suggestedStepMs?: number;
|
|
27
|
+
mode?: TimeSeriesQueryMode;
|
|
26
28
|
timeRange: AbsoluteTimeRange;
|
|
27
29
|
variableState: VariableStateMap;
|
|
28
30
|
datasourceStore: DatasourceStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,KAAK,iCAAiC,GAAG;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAExF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,i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,EAAE,mBAAmB,CAAC;IAC3B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\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;
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\nexport type TimeSeriesQueryMode = 'instant' | 'range';\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\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;AAwCjC,WAA2F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataQueriesProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,SAAS,EAA6B,MAAM,kBAAkB,CAAC;AAIxE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EAEnB,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,kBAAkB,6DAA+D,CAAC;AAE/F,wBAAgB,qBAAqB,2BAMpC;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAqBzG;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"DataQueriesProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,SAAS,EAA6B,MAAM,kBAAkB,CAAC;AAIxE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EAEnB,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,kBAAkB,6DAA+D,CAAC;AAE/F,wBAAgB,qBAAqB,2BAMpC;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAqBzG;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CA+ClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\n\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext() {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult?.definition?.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition?.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps) {\n const { definitions, options, children, queryOptions } = props;\n\n // Returns a query kind, for example \"TimeSeriesQuery\" = getQueryType(\"PrometheusTimeSeriesQuery\")\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\n\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext() {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult?.definition?.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition?.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps) {\n const { definitions, options, children, queryOptions } = props;\n\n // Returns a query kind, for example \"TimeSeriesQuery\" = getQueryType(\"PrometheusTimeSeriesQuery\")\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n const traceQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TraceQuery'\n ) as TraceQueryDefinition[];\n const traceResults = useTraceQueries(traceQueries);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n traceResults.forEach((result) => result.refetch());\n }, [timeSeriesResults, traceResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [\n ...transformQueryResults(timeSeriesResults, timeSeriesQueries),\n ...transformQueryResults(traceResults, traceQueries),\n ];\n\n return {\n queryResults: mergedQueryResults,\n isFetching: mergedQueryResults.some((result) => result.isFetching),\n isLoading: mergedQueryResults.some((result) => result.isLoading),\n refetchAll,\n errors: mergedQueryResults.map((result) => result.error),\n };\n }, [timeSeriesQueries, timeSeriesResults, traceQueries, traceResults, refetchAll]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useTraceQueries","transformQueryResults","useQueryType","DataQueriesContext","undefined","useDataQueriesContext","ctx","Error","useDataQueries","queryType","filteredQueryResults","queryResults","filter","queryResult","definition","kind","filteredErrors","errors","index","filteredCtx","isFetching","some","result","isLoading","refetchAll","DataQueriesProvider","props","definitions","options","children","queryOptions","getQueryType","queryDefinitions","map","type","spec","plugin","timeSeriesQueries","timeSeriesResults","traceQueries","traceResults","forEach","refetch","mergedQueryResults","error","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAExE,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,eAAe,QAA8B,mBAAmB;AAEzE,SAGEC,qBAAqB,EAGrBC,YAAY,QACP,UAAU;AAEjB,OAAO,MAAMC,mCAAqBR,cAAkDS,WAAW;AAE/F,OAAO,SAASC;IACd,MAAMC,MAAMT,WAAWM;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,eAA0CC,SAAY;IACpE,MAAMH,MAAMD;IAEZ,6DAA6D;IAC7D,MAAMK,uBAAuBJ,IAAIK,YAAY,CAACC,MAAM,CAClD,CAACC;YAAgBA;eAAAA,CAAAA,wBAAAA,mCA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AACnB,SAAWA,OAAOoB,OAAO;IACjD,GAAG;QAACJ;QAAmBE;KAAa;IAEpC,MAAMlC,MAAMR,QAAQ;QAClB,MAAM6C,qBAAqB;eACtB1C,sBAAsBqC,mBAAmBD;eACzCpC,sBAAsBuC,cAAcD;SACxC;QAED,OAAO;YACL5B,cAAcgC;YACdvB,YAAYuB,mBAAmBtB,IAAI,CAAC,CAACC,SAAWA,OAAOF,UAAU;YACjEG,WAAWoB,mBAAmBtB,IAAI,CAAC,CAACC,SAAWA,OAAOC,SAAS;YAC/DC;YACAP,QAAQ0B,mBAAmBV,GAAG,CAAC,CAACX,SAAWA,OAAOsB,KAAK;QACzD;IACF,GAAG;QAACP;QAAmBC;QAAmBC;QAAcC;QAAchB;KAAW;IAEjF,qBAAO,KAACrB,mBAAmB0C,QAAQ;QAACC,OAAOxC;kBAAMuB;;AACnD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';
|
|
3
2
|
import { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
|
|
4
|
-
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export type QueryOptions = Record<string, unknown>;
|
|
5
5
|
export interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {
|
|
6
6
|
definitions: Array<Definition<QueryPluginSpec>>;
|
|
7
|
-
children?:
|
|
7
|
+
children?: ReactNode;
|
|
8
8
|
options?: QueryOptions;
|
|
9
9
|
queryOptions?: QueryObserverOptions;
|
|
10
10
|
}
|
|
@@ -28,5 +28,4 @@ export type QueryData<T = QueryDataType> = {
|
|
|
28
28
|
};
|
|
29
29
|
export declare function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData<QueryDataType>[];
|
|
30
30
|
export declare function useQueryType(): (pluginKind: string) => string | undefined;
|
|
31
|
-
export {};
|
|
32
31
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AAGxD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,MAAM,WAAW,wBAAwB,CAAC,eAAe,GAAG,WAAW;IACrE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,sBAAsB,EAAE,cAAc,CAAC;IAC1F,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,aAAa,IAAI;IACzC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,8BAW9F;AAED,wBAAgB,YAAY,IAAI,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAuDzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\nexport type QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: ReactNode;\n options?: QueryOptions;\n queryOptions?: QueryObserverOptions;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]) {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string) => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n }\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [queryTypeMap, isTimeSeriesQueryLoading, isTraceQueryPluginLoading]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","forEach","plugin","pluginType","push","kind","getQueryType","pluginKind","Error","undefined","queryType","includes"],"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;AAIjC,SAAoBA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AACxD,SAASC,qBAAqB,QAAQ,qBAAqB;AA+B3D,OAAO,SAASC,sBAAsBC,OAAyB,EAAEC,WAA8B;IAC7F,OAAOD,QAAQE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAAE,EAAEC;QACnE,OAAO;YACLC,YAAYR,WAAW,CAACO,EAAE;YAC1BL;YACAC;YACAC;YACAC;YACAC;QACF;IACF;AACF;AAEA,OAAO,SAASG;IACd,MAAM,EAAEP,MAAMQ,sBAAsB,EAAEN,W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verOptions } from '@tanstack/react-query';
|
|
2
2
|
import { TimeSeriesQueryDefinition, TimeSeriesData } from '@perses-dev/core';
|
|
3
|
-
import { TimeSeriesDataQuery } from '../model';
|
|
3
|
+
import { TimeSeriesDataQuery, TimeSeriesQueryMode } from '../model';
|
|
4
4
|
export interface UseTimeSeriesQueryOptions {
|
|
5
5
|
suggestedStepMs?: number;
|
|
6
|
+
mode?: TimeSeriesQueryMode;
|
|
6
7
|
}
|
|
7
8
|
export declare const TIME_SERIES_QUERY_KEY = "TimeSeriesQuery";
|
|
8
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,UAAU,EAEV,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,UAAU,EAEV,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAA0B,mBAAmB,EAAyB,MAAM,UAAU,CAAC;AAMnH,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AA2DvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,eACjB,yBAAyB,YAC3B,yBAAyB,iBACpB,oBAAoB,4EAmBpC,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,yBAAyB,EAAE,EACxC,OAAO,CAAC,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE,oBAAoB,6EAkCpC;AAkBD;;GAEG;AACH,wBAAgB,0BAA0B,0BAIzC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,yBAW3D"}
|
|
@@ -28,7 +28,7 @@ function filterVariableStateMap(v, names) {
|
|
|
28
28
|
return Object.fromEntries(Object.entries(v).filter(([name])=>names.includes(name)));
|
|
29
29
|
}
|
|
30
30
|
function getQueryOptions({ plugin, definition, context }) {
|
|
31
|
-
const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;
|
|
31
|
+
const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;
|
|
32
32
|
const dependencies = (plugin === null || plugin === void 0 ? void 0 : plugin.dependsOn) ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
|
|
33
33
|
const variableDependencies = dependencies === null || dependencies === void 0 ? void 0 : dependencies.variables;
|
|
34
34
|
// Determine queryKey
|
|
@@ -39,6 +39,7 @@ function getQueryOptions({ plugin, definition, context }) {
|
|
|
39
39
|
timeRange,
|
|
40
40
|
datasourceStore,
|
|
41
41
|
suggestedStepMs,
|
|
42
|
+
mode,
|
|
42
43
|
variablesValueKey,
|
|
43
44
|
refreshKey
|
|
44
45
|
];
|
|
@@ -88,7 +89,11 @@ function getQueryOptions({ plugin, definition, context }) {
|
|
|
88
89
|
* Runs multiple time series queries using plugins and returns the results.
|
|
89
90
|
*/ export function useTimeSeriesQueries(definitions, options, queryOptions) {
|
|
90
91
|
const { getPlugin } = usePluginRegistry();
|
|
91
|
-
const context =
|
|
92
|
+
const context = {
|
|
93
|
+
...useTimeSeriesQueryContext(),
|
|
94
|
+
// We need mode to be part query key because this drives the type of query done (instant VS range query)
|
|
95
|
+
mode: options === null || options === void 0 ? void 0 : options.mode
|
|
96
|
+
};
|
|
92
97
|
const pluginLoaderResponse = usePlugins(TIME_SERIES_QUERY_KEY, definitions.map((d)=>({
|
|
93
98
|
kind: d.spec.plugin.kind
|
|
94
99
|
})));
|
|
@@ -106,9 +111,9 @@ function getQueryOptions({ plugin, definition, context }) {
|
|
|
106
111
|
enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) && queryEnabled,
|
|
107
112
|
queryKey: queryKey,
|
|
108
113
|
queryFn: async ()=>{
|
|
109
|
-
// Keep options out of query key so we don't re-run queries because suggested step changes
|
|
110
114
|
const ctx = {
|
|
111
115
|
...context,
|
|
116
|
+
// Keep suggested step changes out of the query key, so we don´t have to run again query when it changes
|
|
112
117
|
suggestedStepMs: options === null || options === void 0 ? void 0 : options.suggestedStepMs
|
|
113
118
|
};
|
|
114
119
|
const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n useQuery,\n useQueries,\n useQueryClient,\n Query,\n QueryCache,\n QueryKey,\n QueryObserverOptions,\n} from '@tanstack/react-query';\nimport { TimeSeriesQueryDefinition, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryPlugin } from '../model';\nimport { VariableStateMap, useVariableValues } from './template-variables';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction filterVariableStateMap(v: VariableStateMap, names?: string[]) {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}) {\n const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n // Determine queryKey\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = [definition, timeRange, datasourceStore, suggestedStepMs, variablesValueKey, refreshKey] as const;\n\n // Determine queryEnabled\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n\n return {\n queryKey,\n queryEnabled,\n };\n}\n\n/**\n * Runs a time series query using a plugin and returns the results.\n */\nexport const useTimeSeriesQuery = (\n definition: TimeSeriesQueryDefinition,\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions\n) => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: (queryOptions?.enabled ?? true) || queryEnabled,\n queryKey: queryKey,\n queryFn: () => {\n // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking\n if (plugin === undefined) {\n throw new Error('Expected plugin to be loaded');\n }\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n },\n });\n};\n\n/**\n * Runs multiple time series queries using plugins and returns the results.\n */\nexport function useTimeSeriesQueries(\n definitions: TimeSeriesQueryDefinition[],\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions\n) {\n const { getPlugin } = usePluginRegistry();\n const context = useTimeSeriesQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return {\n enabled: (queryOptions?.enabled ?? true) && queryEnabled,\n queryKey: queryKey,\n queryFn: async () => {\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n return data;\n },\n };\n }),\n });\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange, refreshKey } = useTimeRange();\n const variableState = useVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n refreshKey,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries() {\n const queryClient = useQueryClient();\n const queryCache = queryClient.getQueryCache();\n return getActiveTimeSeriesQueries(queryCache);\n}\n\n/**\n * Filter all cached queries down to only active time series queries\n */\nexport function getActiveTimeSeriesQueries(cache: QueryCache) {\n const queries: TimeSeriesDataQuery[] = [];\n\n for (const query of cache.findAll({ type: 'active' })) {\n const firstPart = query.queryKey?.[0] as UnknownSpec;\n if (firstPart?.kind && (firstPart.kind as string).startsWith(TIME_SERIES_QUERY_KEY)) {\n queries.push(query as Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>);\n }\n }\n\n return queries;\n}\n"],"names":["useQuery","useQueries","useQueryClient","useVariableValues","useTimeRange","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","TIME_SERIES_QUERY_KEY","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","filterVariableStateMap","names","fromEntries","entries","filter","name","includes","getQueryOptions","plugin","definition","context","timeRange","datasourceStore","suggestedStepMs","variableState","refreshKey","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","loading","queryEnabled","undefined","useTimeSeriesQuery","options","queryOptions","data","kind","useTimeSeriesQueryContext","enabled","queryFn","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","d","queries","idx","absoluteTimeRange","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","getActiveTimeSeriesQueries","cache","query","findAll","type","firstPart","startsWith","push"],"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,QAAQ,EACRC,UAAU,EACVC,cAAc,QAKT,wBAAwB;AAG/B,SAA2BC,iBAAiB,QAAQ,uBAAuB;AAC3E,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAoB;AAM7E,OAAO,MA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sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n useQuery,\n useQueries,\n useQueryClient,\n Query,\n QueryCache,\n QueryKey,\n QueryObserverOptions,\n} from '@tanstack/react-query';\nimport { TimeSeriesQueryDefinition, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryMode, TimeSeriesQueryPlugin } from '../model';\nimport { VariableStateMap, useVariableValues } from './template-variables';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction filterVariableStateMap(v: VariableStateMap, names?: string[]) {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}) {\n const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n // Determine queryKey\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = [\n definition,\n timeRange,\n datasourceStore,\n suggestedStepMs,\n mode,\n variablesValueKey,\n refreshKey,\n ] as const;\n\n // Determine queryEnabled\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n\n return {\n queryKey,\n queryEnabled,\n };\n}\n\n/**\n * Runs a time series query using a plugin and returns the results.\n */\nexport const useTimeSeriesQuery = (\n definition: TimeSeriesQueryDefinition,\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions\n) => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: (queryOptions?.enabled ?? true) || queryEnabled,\n queryKey: queryKey,\n queryFn: () => {\n // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking\n if (plugin === undefined) {\n throw new Error('Expected plugin to be loaded');\n }\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n },\n });\n};\n\n/**\n * Runs multiple time series queries using plugins and returns the results.\n */\nexport function useTimeSeriesQueries(\n definitions: TimeSeriesQueryDefinition[],\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions\n) {\n const { getPlugin } = usePluginRegistry();\n const context = {\n ...useTimeSeriesQueryContext(),\n // We need mode to be part query key because this drives the type of query done (instant VS range query)\n mode: options?.mode,\n };\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return {\n enabled: (queryOptions?.enabled ?? true) && queryEnabled,\n queryKey: queryKey,\n queryFn: async () => {\n const ctx: TimeSeriesQueryContext = {\n ...context,\n // Keep suggested step changes out of the query key, so we don´t have to run again query when it changes\n suggestedStepMs: options?.suggestedStepMs,\n };\n const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n return data;\n },\n };\n }),\n });\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange, refreshKey } = useTimeRange();\n const variableState = useVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n refreshKey,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries() {\n const queryClient = useQueryClient();\n const queryCache = queryClient.getQueryCache();\n return getActiveTimeSeriesQueries(queryCache);\n}\n\n/**\n * Filter all cached queries down to only active time series queries\n */\nexport function getActiveTimeSeriesQueries(cache: QueryCache) {\n const queries: TimeSeriesDataQuery[] = [];\n\n for (const query of cache.findAll({ type: 'active' })) {\n const firstPart = query.queryKey?.[0] as UnknownSpec;\n if (firstPart?.kind && (firstPart.kind as string).startsWith(TIME_SERIES_QUERY_KEY)) {\n queries.push(query as Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>);\n }\n }\n\n return queries;\n}\n"],"names":["useQuery","useQueries","useQueryClient","useVariableValues","useTimeRange","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","TIME_SERIES_QUERY_KEY","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","filterVariableStateMap","names","fromEntries","entries","filter","name","includes","getQueryOptions","plugin","definition","context","timeRange","datasourceStore","suggestedStepMs","mode","variableState","refreshKey","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","loading","queryEnabled","undefined","useTimeSeriesQuery","options","queryOptions","data","kind","useTimeSeriesQueryContext","enabled","queryFn","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","d","queries","idx","absoluteTimeRange","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","getActiveTimeSeriesQueries","cache","query","findAll","type","firstPart","startsWith","push"],"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,QAAQ,EACRC,UAAU,EACVC,cAAc,QAKT,wBAAwB;AAG/B,SAA2BC,iBAAiB,QAAQ,uBAAuB;AAC3E,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAoB;AAO7E,OAAO,MAAMC,wBAAwB,kBAAkB;AAEvD;;CAEC,GACD,SAASC,qBAAqBC,CAAmB;IAC/C,OAAOC,OAAOC,MAAM,CAACF,GAClBG,GAAG,CAAC,CAACH,IAAMI,KAAKC,SAAS,CAACL,EAAEM,KAAK,GACjCC,IAAI,CAAC;AACV;AAEA,SAASC,uBAAuBR,CAAmB,EAAES,KAAgB;IACnE,IAAI,CAACA,OAAO;QACV,OAAOT;IACT;IACA,OAAOC,OAAOS,WAAW,CAACT,OAAOU,OAAO,CAACX,GAAGY,MAAM,CAAC,CAAC,CAACC,KAAK,GAAKJ,MAAMK,QAAQ,CAACD;AAChF;AAEA,SAASE,gBAAgB,EACvBC,MAAM,EACNC,UAAU,EACVC,OAAO,EA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CAAC0B,IAAI;oBACjF,MAAMD,OAAO,MAAMzB,OAAOgC,iBAAiB,CAAC/B,WAAWU,IAAI,CAACX,MAAM,CAACW,IAAI,EAAEoB;oBACzE,OAAON;gBACT;YACF;QACF;IACF;AACF;AAEA;;CAEC,GACD,SAASE;IACP,MAAM,EAAEa,iBAAiB,EAAEhC,UAAU,EAAE,GAAG/B;IAC1C,MAAM8B,gBAAgB/B;IACtB,MAAM4B,kBAAkB1B;IAExB,OAAO;QACLyB,WAAWqC;QACXjC;QACAH;QACAI;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASiC;IACd,MAAMC,cAAcnE;IACpB,MAAMoE,aAAaD,YAAYE,aAAa;IAC5C,OAAOC,2BAA2BF;AACpC;AAEA;;CAEC,GACD,OAAO,SAASE,2BAA2BC,KAAiB;IAC1D,MAAMR,UAAiC,EAAE;IAEzC,KAAK,MAAMS,SAASD,MAAME,OAAO,CAAC;QAAEC,MAAM;IAAS,GAAI;YACnCF;QAAlB,MAAMG,aAAYH,kBAAAA,MAAM/B,QAAQ,cAAd+B,sCAAAA,eAAgB,CAAC,EAAE;QACrC,IAAIG,CAAAA,sBAAAA,gCAAAA,UAAWxB,IAAI,KAAI,AAACwB,UAAUxB,IAAI,CAAYyB,UAAU,CAACrE,wBAAwB;YACnFwD,QAAQc,IAAI,CAACL;QACf;IACF;IAEA,OAAOT;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/plugin-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0-rc0",
|
|
4
4
|
"description": "The plugin feature in Pereses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@perses-dev/components": "0.
|
|
32
|
-
"@perses-dev/core": "0.
|
|
31
|
+
"@perses-dev/components": "0.46.0-rc0",
|
|
32
|
+
"@perses-dev/core": "0.46.0-rc0",
|
|
33
33
|
"date-fns": "^2.30.0",
|
|
34
34
|
"immer": "^9.0.15",
|
|
35
35
|
"react-hook-form": "^7.46.1",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"zod": "^3.22.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@perses-dev/storybook": "0.
|
|
41
|
+
"@perses-dev/storybook": "0.46.0-rc0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@mui/material": "^5.10.0",
|