@perses-dev/plugin-system 0.53.0-beta.1 → 0.53.0-beta.3
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/components/MultiQueryEditor/MultiQueryEditor.js +8 -3
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +74 -29
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +10 -1
- package/dist/cjs/components/PluginEditor/PluginEditor.js +11 -45
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +27 -10
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/cjs/components/Variables/variable-model.js +3 -3
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +70 -33
- package/dist/cjs/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js} +23 -5
- package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
- package/dist/cjs/runtime/log-queries.js +2 -1
- package/dist/cjs/runtime/profile-queries.js +2 -1
- package/dist/cjs/runtime/time-series-queries.js +10 -16
- package/dist/cjs/runtime/trace-queries.js +3 -2
- package/dist/cjs/test/utils.js +4 -4
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -0
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +8 -3
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -0
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +75 -30
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +11 -2
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +3 -3
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +12 -46
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +28 -11
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.js +3 -3
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/model/plugin-base.d.ts +1 -6
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +0 -1
- 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/model.d.ts +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +2 -3
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +70 -33
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +10 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js} +13 -3
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +1 -1
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/log-queries.js +2 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/profile-queries.js +2 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +10 -16
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +3 -2
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/test/utils.js +5 -5
- package/dist/test/utils.js.map +1 -1
- package/package.json +4 -4
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +0 -9
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +0 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n\n let dependsOnVariables: string[] = Object.keys(allVariables); // Default to all variables\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;\n }\n // Exclude self variable to avoid circular dependency\n dependsOnVariables = dependsOnVariables.filter((v) => v !== definition.spec.name);\n\n const variables = useAllVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery({\n queryKey: ['variable', definition, timeRange, variablesValueKey],\n queryFn: async ({ signal }) => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange }, signal);\n if (!resp?.data?.length) {\n return [];\n }\n if (!capturingRegexp) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n enabled: !!variablePlugin || waitToLoad,\n });\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQuery","useDatasourceStore","usePlugin","useTimeRange","useAllVariableValues","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","variablePluginCtx","variables","capturingRegexp","RegExp","dependsOnVariables","Object","keys","dependsOn","dependencies","filter","v","name","waitToLoad","some","loading","variablesValueKey","getVariableValuesKey","queryKey","queryFn","signal","resp","getVariableOptions","enabled","values","map","JSON","stringify","join","VARIABLE_TYPES"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAwB,wBAAwB;AAEjE,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAA0B,gBAAgB;AAEpH,OAAO,SAASC,mBAAmBC,IAAsB,EAAEC,cAAsB;IAC/E,MAAMC,SAA2B,EAAE;IACnC,MAAMC,cAAc,IAAIC;IACxB,KAAK,MAAMC,iBAAiBL,KAAM;QAChC,MAAMM,UAAUD,cAAcE,KAAK,CAACC,QAAQ,CAACP;QAC7C,IAAIQ,SAAS;QACb,KAAK,MAAMC,SAASJ,QAAS;YAC3B,IAAK,IAAIK,IAAI,GAAGA,IAAID,MAAME,MAAM,EAAED,IAAK;gBACrC,MAAME,IAAIH,KAAK,CAACC,EAAE;gBAClB,IAAIE,MAAMC,WAAW;oBACnBL,SAAS,GAAGA,SAASI,GAAG;gBAC1B;YACF;QACF;QACA,IAAIJ,WAAW,MAAM,CAACN,YAAYY,GAAG,CAACN,SAAS;Y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,OAAO,MAAM5B,gBAAgB6B,mBAAmB5B,MAAM;gBAAEG;gBAAiBK;gBAAWF;YAAU,GAAGoB;YACvG,IAAI,CAACC,MAAMjD,MAAMY,QAAQ;gBACvB,OAAO,EAAE;YACX;YACA,IAAI,CAACmB,iBAAiB;gBACpB,OAAOkB,KAAKjD,IAAI;YAClB;YACA,OAAOD,mBAAmBkD,KAAKjD,IAAI,EAAE+B;QACvC;QACAoB,SAAS,CAAC,CAAC9B,kBAAkBoB;IAC/B;AACF;AAEA;;CAEC,GACD,OAAO,SAASI,qBAAqBN,CAAmB;IACtD,OAAOL,OAAOkB,MAAM,CAACb,GAClBc,GAAG,CAAC,CAACd,IAAMe,KAAKC,SAAS,CAAChB,EAAEhC,KAAK,GACjCiD,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAEvC,OAAO;QAAQM,MAAM;IAAe;IACtC;QAAEN,OAAO;QAAQM,MAAM;IAAe;CACvC,CAAU"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueryDefinition
|
|
1
|
+
import { QueryDefinition } from '@perses-dev/core';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Base type of all plugin implementations.
|
|
@@ -20,11 +20,6 @@ export interface OptionsEditorProps<Spec> {
|
|
|
20
20
|
value: Spec;
|
|
21
21
|
onChange: (next: Spec) => void;
|
|
22
22
|
isReadonly?: boolean;
|
|
23
|
-
queryHandlerSettings?: {
|
|
24
|
-
runWithOnBlur: boolean;
|
|
25
|
-
watchQueryChanges: (query: string) => void;
|
|
26
|
-
setWatchOtherSpecs: (otherSpecs: UnknownSpec) => void;
|
|
27
|
-
};
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* Common props passed to query editor component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-base.d.ts","sourceRoot":"","sources":["../../src/model/plugin-base.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin-base.d.ts","sourceRoot":"","sources":["../../src/model/plugin-base.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI;IAC1B;;OAEG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvE;;OAEG;IACH,oBAAoB,EAAE,MAAM,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI;IAGtC,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,CAAE,SAAQ,kBAAkB,CAAC,IAAI,CAAC;IACtE,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/plugin-base.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 { QueryDefinition
|
|
1
|
+
{"version":3,"sources":["../../src/model/plugin-base.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 { QueryDefinition } from '@perses-dev/core';\nimport React from 'react';\n\n/**\n * Base type of all plugin implementations.\n */\nexport interface Plugin<Spec> {\n /**\n * React component for editing the plugin's options in the UI.\n */\n OptionsEditorComponent?: React.ComponentType<OptionsEditorProps<Spec>>;\n\n /**\n * Callback for creating the initial options for the plugin.\n */\n createInitialOptions: () => Spec;\n}\n\n/**\n * Common props passed to options editor components.\n */\nexport interface OptionsEditorProps<Spec> {\n // TODO: These are temporary and may not actually make sense, so replace\n // with whatever makes sense as visual editing evolves\n value: Spec;\n onChange: (next: Spec) => void;\n isReadonly?: boolean;\n}\n\n/**\n * Common props passed to query editor component\n */\nexport interface QueryEditorProps<Spec> extends OptionsEditorProps<Spec> {\n queries: QueryDefinition[];\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;AAGjC,OAAOA,WAAW,QAAQ"}
|
|
@@ -28,7 +28,6 @@ export interface TimeSeriesQueryContext {
|
|
|
28
28
|
timeRange: AbsoluteTimeRange;
|
|
29
29
|
variableState: VariableStateMap;
|
|
30
30
|
datasourceStore: DatasourceStore;
|
|
31
|
-
refreshKey: string;
|
|
32
31
|
}
|
|
33
32
|
export type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;
|
|
34
33
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"A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B,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,EAAE,WAAW,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAEnH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,iCAAiC,CAAC;CAC5F;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;CAClC;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, abortSignal?: AbortSignal) => 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
|
|
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, abortSignal?: AbortSignal) => 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}\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;AAuCjC,WAA2F"}
|
|
@@ -21,7 +21,7 @@ export interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'qu
|
|
|
21
21
|
export type QueryData<T = QueryDataType> = {
|
|
22
22
|
data?: T;
|
|
23
23
|
definition: QueryDefinition;
|
|
24
|
-
error:
|
|
24
|
+
error: Error;
|
|
25
25
|
isFetching: boolean;
|
|
26
26
|
isLoading: boolean;
|
|
27
27
|
refetch?: () => void;
|
|
@@ -1 +1 @@
|
|
|
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,O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Provider/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?: Omit<QueryObserverOptions, 'queryKey'>;\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:
|
|
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?: Omit<QueryObserverOptions, 'queryKey'>;\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: Error;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData[] {\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 const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = useListPluginMetadata(['ProfileQuery']);\n const { data: logQueries, isLoading: isLogQueryPluginLoading } = useListPluginMetadata(['LogQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n ProfileQuery: [],\n LogQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (profileQueryPlugins) {\n profileQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (logQueries) {\n logQueries.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins, profileQueryPlugins, logQueries]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string): boolean => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n case 'PyroscopeProfileQuery':\n return isProfileQueryPluginLoading;\n case 'LokiLogQuery':\n return isLogQueryPluginLoading;\n }\n\n return (\n isTraceQueryPluginLoading ||\n isTimeSeriesQueryLoading ||\n isProfileQueryPluginLoading ||\n isLogQueryPluginLoading\n );\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 [\n queryTypeMap,\n isTimeSeriesQueryLoading,\n isTraceQueryPluginLoading,\n isProfileQueryPluginLoading,\n isLogQueryPluginLoading,\n ]\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","profileQueryPlugins","isProfileQueryPluginLoading","logQueries","isLogQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","ProfileQuery","LogQuery","forEach","plugin","kind","push","spec","name","getQueryType","pluginKind","undefined","queryType","includes","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;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,WAAWO,wBAAwB,EAAE,GAAGd,sBAAsB;QAClG;KACD;IACD,MAAM,EAAEK,MAAMU,iBAAiB,EAAER,WAAWS,yBAAyB,EAAE,GAAGhB,sBAAsB;QAAC;KAAa;IAC9G,MAAM,EAAEK,MAAMY,mBAAmB,EAAEV,WAAWW,2BAA2B,EAAE,GAAGlB,sBAAsB;QAAC;KAAe;IACpH,MAAM,EAAEK,MAAMc,UAAU,EAAEZ,WAAWa,uBAAuB,EAAE,GAAGpB,sBAAsB;QAAC;KAAW;IAEnG,yGAAyG;IACzG,MAAMqB,eAAetB,QAAQ;QAC3B,MAAMK,MAAgC;YACpCkB,iBAAiB,EAAE;YACnBC,YAAY,EAAE;YACdC,cAAc,EAAE;YAChBC,UAAU,EAAE;QACd;QAEA,IAAIZ,wBAAwB;YAC1BA,uBAAuBa,OAAO,CAAC,CAACC;gBAC9BvB,GAAG,CAACuB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QAEA,IAAIhB,mBAAmB;YACrBA,kBAAkBW,OAAO,CAAC,CAACC;gBACzBvB,GAAG,CAACuB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QAEA,IAAId,qBAAqB;YACvBA,oBAAoBS,OAAO,CAAC,CAACC;gBAC3BvB,GAAG,CAACuB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QAEA,IAAIZ,YAAY;YACdA,WAAWO,OAAO,CAAC,CAACC;gBAClBvB,GAAG,CAACuB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QAEA,OAAO3B;IACT,GAAG;QAACS;QAAwBE;QAAmBE;QAAqBE;KAAW;IAE/E,MAAMa,eAAelC,YACnB,CAACmC;QACC,MAAM1B,YAAY,CAAC0B;YACjB,OAAQA;gBACN,KAAK;oBACH,OAAOnB;gBACT,KAAK;oBACH,OAAOE;gBACT,KAAK;oBACH,OAAOE;gBACT,KAAK;oBACH,OAAOE;YACX;YAEA,OACEJ,6BACAF,4BACAI,+BACAE;QAEJ;QAEA,IAAIb,UAAU0B,aAAa;YACzB,OAAOC;QACT;QAEA,IAAK,MAAMC,aAAad,aAAc;YACpC,IAAIA,YAAY,CAACc,UAAU,EAAEC,SAASH,aAAa;gBACjD,OAAOE;YACT;QACF;QAEA,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAEJ,YAAY;IACrE,GACA;QACEZ;QACAP;QACAE;QACAE;QACAE;KACD;IAGH,OAAOY;AACT"}
|
|
@@ -3,8 +3,8 @@ import { AbsoluteTimeRange, DurationString, TimeRangeValue } from '@perses-dev/c
|
|
|
3
3
|
export interface TimeRangeProviderProps {
|
|
4
4
|
timeRange: TimeRangeValue;
|
|
5
5
|
refreshInterval?: DurationString;
|
|
6
|
-
setTimeRange
|
|
7
|
-
setRefreshInterval
|
|
6
|
+
setTimeRange: (value: TimeRangeValue) => void;
|
|
7
|
+
setRefreshInterval: (value: DurationString) => void;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
export interface TimeRange {
|
|
@@ -12,7 +12,6 @@ export interface TimeRange {
|
|
|
12
12
|
absoluteTimeRange: AbsoluteTimeRange;
|
|
13
13
|
setTimeRange: (value: TimeRangeValue) => void;
|
|
14
14
|
refresh: () => void;
|
|
15
|
-
refreshKey: string;
|
|
16
15
|
refreshInterval?: DurationString;
|
|
17
16
|
refreshIntervalInMs: number;
|
|
18
17
|
setRefreshInterval: (value: DurationString) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAiB,YAAY,EAAyD,MAAM,OAAO,CAAC;AAClH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EAIf,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAiB,YAAY,EAAyD,MAAM,OAAO,CAAC;AAClH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EAIf,MAAM,kBAAkB,CAAC;AAI1B,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,cAAc,CAAC;IAC1B,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,IAAI,SAAS,CAM/C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CAoE7E"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
15
15
|
import { isRelativeTimeRange, toAbsoluteTimeRange, getSuggestedStepMs } from '@perses-dev/core';
|
|
16
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
16
17
|
import { getRefreshIntervalInMs } from './refresh-interval';
|
|
17
18
|
export const TimeRangeContext = /*#__PURE__*/ createContext(undefined);
|
|
18
19
|
export function useTimeRangeContext() {
|
|
@@ -38,62 +39,98 @@ export function useTimeRangeContext() {
|
|
|
38
39
|
* Provider implementation that supplies the time range state at runtime.
|
|
39
40
|
*/ export function TimeRangeProvider(props) {
|
|
40
41
|
const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/ const [localTimeRange, setLocalTimeRange] = useState(timeRange);
|
|
47
|
-
const [localRefreshInterval, setLocalRefreshInterval] = useState(refreshInterval);
|
|
48
|
-
const [refreshCounter, setRefreshCounter] = useState(0);
|
|
49
|
-
useEffect(()=>{
|
|
50
|
-
setLocalTimeRange(timeRange);
|
|
42
|
+
const queryClient = useQueryClient();
|
|
43
|
+
const [absoluteTimeRange, setAbsoluteTimeRange] = useState(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);
|
|
44
|
+
const handleSetTimeRange = useCallback((value)=>{
|
|
45
|
+
setTimeRange(value);
|
|
46
|
+
setAbsoluteTimeRange(isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value);
|
|
51
47
|
}, [
|
|
52
|
-
|
|
53
|
-
refreshCounter
|
|
48
|
+
setTimeRange
|
|
54
49
|
]);
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
// Refresh is called when clicking on the refresh button, it refreshes all queries including variables
|
|
51
|
+
const refresh = useCallback(()=>{
|
|
52
|
+
setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);
|
|
53
|
+
queryClient.invalidateQueries({
|
|
54
|
+
queryKey: [
|
|
55
|
+
'query'
|
|
56
|
+
]
|
|
57
|
+
}).finally(()=>queryClient.removeQueries({
|
|
58
|
+
queryKey: [
|
|
59
|
+
'query'
|
|
60
|
+
],
|
|
61
|
+
type: 'inactive'
|
|
62
|
+
}));
|
|
63
|
+
queryClient.invalidateQueries({
|
|
64
|
+
queryKey: [
|
|
65
|
+
'variable'
|
|
66
|
+
]
|
|
67
|
+
}).finally(()=>queryClient.removeQueries({
|
|
68
|
+
queryKey: [
|
|
69
|
+
'variable'
|
|
70
|
+
],
|
|
71
|
+
type: 'inactive'
|
|
72
|
+
}));
|
|
57
73
|
}, [
|
|
58
|
-
|
|
74
|
+
queryClient,
|
|
75
|
+
timeRange
|
|
59
76
|
]);
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
// Auto refresh is only refreshing queries of panels
|
|
78
|
+
const autoRefresh = useCallback(()=>{
|
|
79
|
+
setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);
|
|
80
|
+
queryClient.invalidateQueries({
|
|
81
|
+
queryKey: [
|
|
82
|
+
'query'
|
|
83
|
+
]
|
|
84
|
+
}).finally(()=>{
|
|
85
|
+
queryClient.removeQueries({
|
|
86
|
+
queryKey: [
|
|
87
|
+
'query'
|
|
88
|
+
],
|
|
89
|
+
type: 'inactive'
|
|
90
|
+
});
|
|
91
|
+
queryClient.removeQueries({
|
|
92
|
+
queryKey: [
|
|
93
|
+
'variable'
|
|
94
|
+
],
|
|
95
|
+
type: 'inactive'
|
|
96
|
+
}); // Timerange is in queryKey, can lead to memory leak when using relative timerange
|
|
97
|
+
});
|
|
62
98
|
}, [
|
|
63
|
-
|
|
99
|
+
queryClient,
|
|
100
|
+
timeRange
|
|
101
|
+
]);
|
|
102
|
+
const refreshIntervalInMs = useMemo(()=>getRefreshIntervalInMs(refreshInterval), [
|
|
103
|
+
refreshInterval
|
|
64
104
|
]);
|
|
65
|
-
const refreshIntervalInMs = getRefreshIntervalInMs(localRefreshInterval);
|
|
66
105
|
useEffect(()=>{
|
|
67
106
|
if (refreshIntervalInMs > 0) {
|
|
68
107
|
const interval = setInterval(()=>{
|
|
69
|
-
|
|
108
|
+
autoRefresh();
|
|
70
109
|
}, refreshIntervalInMs);
|
|
71
110
|
return ()=>clearInterval(interval);
|
|
72
111
|
}
|
|
73
112
|
}, [
|
|
74
|
-
|
|
113
|
+
autoRefresh,
|
|
75
114
|
refreshIntervalInMs
|
|
76
115
|
]);
|
|
77
116
|
const ctx = useMemo(()=>{
|
|
78
|
-
const absoluteTimeRange = isRelativeTimeRange(localTimeRange) ? toAbsoluteTimeRange(localTimeRange) : localTimeRange;
|
|
79
117
|
return {
|
|
80
|
-
timeRange:
|
|
81
|
-
setTimeRange:
|
|
82
|
-
absoluteTimeRange,
|
|
118
|
+
timeRange: timeRange,
|
|
119
|
+
setTimeRange: handleSetTimeRange,
|
|
120
|
+
absoluteTimeRange: absoluteTimeRange,
|
|
83
121
|
refresh,
|
|
84
|
-
|
|
85
|
-
refreshInterval: localRefreshInterval,
|
|
122
|
+
refreshInterval: refreshInterval,
|
|
86
123
|
refreshIntervalInMs: refreshIntervalInMs,
|
|
87
|
-
setRefreshInterval: setRefreshInterval
|
|
124
|
+
setRefreshInterval: setRefreshInterval
|
|
88
125
|
};
|
|
89
126
|
}, [
|
|
90
|
-
|
|
91
|
-
|
|
127
|
+
absoluteTimeRange,
|
|
128
|
+
handleSetTimeRange,
|
|
92
129
|
refresh,
|
|
93
|
-
|
|
94
|
-
refreshCounter,
|
|
130
|
+
refreshInterval,
|
|
95
131
|
refreshIntervalInMs,
|
|
96
|
-
setRefreshInterval
|
|
132
|
+
setRefreshInterval,
|
|
133
|
+
timeRange
|
|
97
134
|
]);
|
|
98
135
|
return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
|
|
99
136
|
value: ctx,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange: (value: TimeRangeValue) => void;\n setRefreshInterval: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const queryClient = useQueryClient();\n const [absoluteTimeRange, setAbsoluteTimeRange] = useState<AbsoluteTimeRange>(\n isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange\n );\n\n const handleSetTimeRange = useCallback(\n (value: TimeRangeValue) => {\n setTimeRange(value);\n setAbsoluteTimeRange(isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value);\n },\n [setTimeRange]\n );\n\n // Refresh is called when clicking on the refresh button, it refreshes all queries including variables\n const refresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient\n .invalidateQueries({ queryKey: ['query'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' }));\n queryClient\n .invalidateQueries({ queryKey: ['variable'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }));\n }, [queryClient, timeRange]);\n\n // Auto refresh is only refreshing queries of panels\n const autoRefresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient.invalidateQueries({ queryKey: ['query'] }).finally(() => {\n queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' });\n queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }); // Timerange is in queryKey, can lead to memory leak when using relative timerange\n });\n }, [queryClient, timeRange]);\n\n const refreshIntervalInMs = useMemo(() => getRefreshIntervalInMs(refreshInterval), [refreshInterval]);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n autoRefresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [autoRefresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n return {\n timeRange: timeRange,\n setTimeRange: handleSetTimeRange,\n absoluteTimeRange: absoluteTimeRange,\n refresh,\n refreshInterval: refreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval,\n };\n }, [\n absoluteTimeRange,\n handleSetTimeRange,\n refresh,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n timeRange,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","useQueryClient","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","queryClient","setAbsoluteTimeRange","handleSetTimeRange","value","refresh","invalidateQueries","queryKey","finally","removeQueries","type","autoRefresh","refreshIntervalInMs","interval","setInterval","clearInterval","Provider"],"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,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAmB;AAC1B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAoB5D,OAAO,MAAMC,iCAAmBX,cAAqCY,WAAW;AA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af,oBAAoBe,aAAaA;QACvFK,YAAYK,iBAAiB,CAAC;YAAEC,UAAU;gBAAC;aAAQ;QAAC,GAAGC,OAAO,CAAC;YAC7DP,YAAYQ,aAAa,CAAC;gBAAEF,UAAU;oBAAC;iBAAQ;gBAAEG,MAAM;YAAW;YAClET,YAAYQ,aAAa,CAAC;gBAAEF,UAAU;oBAAC;iBAAW;gBAAEG,MAAM;YAAW,IAAI,kFAAkF;QAC7J;IACF,GAAG;QAACT;QAAaL;KAAU;IAE3B,MAAMgB,sBAAsBlC,QAAQ,IAAMM,uBAAuBa,kBAAkB;QAACA;KAAgB;IACpGpB,UAAU;QACR,IAAImC,sBAAsB,GAAG;YAC3B,MAAMC,WAAWC,YAAY;gBAC3BH;YACF,GAAGC;YAEH,OAAO,IAAYG,cAAcF;QACnC;IACF,GAAG;QAACF;QAAaC;KAAoB;IAErC,MAAMxB,MAAMV,QAAQ;QAClB,OAAO;YACLkB,WAAWA;YACXG,cAAcI;YACdV,mBAAmBA;YACnBY;YACAR,iBAAiBA;YACjBe,qBAAqBA;YACrBZ,oBAAoBA;QACtB;IACF,GAAG;QACDP;QACAU;QACAE;QACAR;QACAe;QACAZ;QACAJ;KACD;IAED,qBAAO,KAACX,iBAAiB+B,QAAQ;QAACZ,OAAOhB;kBAAMU;;AACjD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DurationString, TimeRangeValue } from '@perses-dev/core';
|
|
2
|
+
import React, { ReactElement } from 'react';
|
|
3
|
+
export interface TimeRangeProvidersProps {
|
|
4
|
+
initialTimeRange: TimeRangeValue;
|
|
5
|
+
initialRefreshInterval?: DurationString;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function TimeRangeProviderWithQueryParams({ initialTimeRange, initialRefreshInterval, children, }: TimeRangeProvidersProps): ReactElement;
|
|
9
|
+
export declare function TimeRangeProviderBasic({ initialTimeRange, initialRefreshInterval, children, }: TimeRangeProvidersProps): ReactElement;
|
|
10
|
+
//# sourceMappingURL=TimeRangeProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeRangeProviders.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviders.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI5C,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,gCAAgC,CAAC,EAC/C,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAcxC;AAED,wBAAgB,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAcxC"}
|
package/dist/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js}
RENAMED
|
@@ -14,8 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import { TimeRangeProvider } from './TimeRangeProvider';
|
|
16
16
|
import { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';
|
|
17
|
-
export function TimeRangeProviderWithQueryParams(
|
|
18
|
-
const { initialTimeRange, initialRefreshInterval, children } = props;
|
|
17
|
+
export function TimeRangeProviderWithQueryParams({ initialTimeRange, initialRefreshInterval, children }) {
|
|
19
18
|
const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);
|
|
20
19
|
const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);
|
|
21
20
|
return /*#__PURE__*/ _jsx(TimeRangeProvider, {
|
|
@@ -26,5 +25,16 @@ export function TimeRangeProviderWithQueryParams(props) {
|
|
|
26
25
|
children: children
|
|
27
26
|
});
|
|
28
27
|
}
|
|
28
|
+
export function TimeRangeProviderBasic({ initialTimeRange, initialRefreshInterval, children }) {
|
|
29
|
+
const [timeRange, setTimeRange] = React.useState(initialTimeRange);
|
|
30
|
+
const [refreshInterval, setRefreshInterval] = React.useState(initialRefreshInterval);
|
|
31
|
+
return /*#__PURE__*/ _jsx(TimeRangeProvider, {
|
|
32
|
+
timeRange: timeRange,
|
|
33
|
+
refreshInterval: refreshInterval,
|
|
34
|
+
setTimeRange: setTimeRange,
|
|
35
|
+
setRefreshInterval: setRefreshInterval,
|
|
36
|
+
children: children
|
|
37
|
+
});
|
|
38
|
+
}
|
|
29
39
|
|
|
30
|
-
//# sourceMappingURL=
|
|
40
|
+
//# sourceMappingURL=TimeRangeProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviders.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 { DurationString, TimeRangeValue } from '@perses-dev/core';\nimport React, { ReactElement } from 'react';\nimport { TimeRangeProvider } from './TimeRangeProvider';\nimport { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProvidersProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n children?: React.ReactNode;\n}\n\nexport function TimeRangeProviderWithQueryParams({\n initialTimeRange,\n initialRefreshInterval,\n children,\n}: TimeRangeProvidersProps): ReactElement {\n const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);\n const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n\nexport function TimeRangeProviderBasic({\n initialTimeRange,\n initialRefreshInterval,\n children,\n}: TimeRangeProvidersProps): ReactElement {\n const [timeRange, setTimeRange] = React.useState<TimeRangeValue>(initialTimeRange);\n const [refreshInterval, setRefreshInterval] = React.useState<DurationString | undefined>(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n"],"names":["React","TimeRangeProvider","useSetRefreshIntervalParams","useTimeRangeParams","TimeRangeProviderWithQueryParams","initialTimeRange","initialRefreshInterval","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval","TimeRangeProviderBasic","useState"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,OAAOA,WAA6B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,kBAAkB,QAAQ,iBAAiB;AAQjF,OAAO,SAASC,iCAAiC,EAC/CC,gBAAgB,EAChBC,sBAAsB,EACtBC,QAAQ,EACgB;IACxB,MAAM,EAAEC,SAAS,EAAEC,YAAY,EAAE,GAAGN,mBAAmBE;IACvD,MAAM,EAAEK,eAAe,EAAEC,kBAAkB,EAAE,GAAGT,4BAA4BI;IAE5E,qBACE,KAACL;QACCO,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP;AAEA,OAAO,SAASK,uBAAuB,EACrCP,gBAAgB,EAChBC,sBAAsB,EACtBC,QAAQ,EACgB;IACxB,MAAM,CAACC,WAAWC,aAAa,GAAGT,MAAMa,QAAQ,CAAiBR;IACjE,MAAM,CAACK,iBAAiBC,mBAAmB,GAAGX,MAAMa,QAAQ,CAA6BP;IAEzF,qBACE,KAACL;QACCO,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export * from './TimeRangeProvider';
|
|
14
|
-
export * from './
|
|
14
|
+
export * from './TimeRangeProviders';
|
|
15
15
|
export * from './TimeRangeSettingsProvider';
|
|
16
16
|
export * from './query-params';
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './TimeRangeProviders';\nexport * from './TimeRangeSettingsProvider';\nexport * from './query-params';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAC5C,cAAc,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/log-queries.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { LogQueryResult } from '../model/log-queries';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useVariableValues } from './variables';\n\nexport type LogQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'LogQuery', PluginSpec>;\nexport const LOG_QUERY_KEY = 'LogQuery';\n\nexport function useLogQueries(definitions: LogQueryDefinition[]): Array<UseQueryResult<LogQueryResult>> {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n const variableValues = useVariableValues();\n\n const context = {\n timeRange: absoluteTimeRange,\n variableState: variableValues,\n datasourceStore,\n refreshKey: '',\n };\n\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = [
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/log-queries.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { LogQueryResult } from '../model/log-queries';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useVariableValues } from './variables';\n\nexport type LogQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'LogQuery', PluginSpec>;\nexport const LOG_QUERY_KEY = 'LogQuery';\n\nexport function useLogQueries(definitions: LogQueryDefinition[]): Array<UseQueryResult<LogQueryResult>> {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n const variableValues = useVariableValues();\n\n const context = {\n timeRange: absoluteTimeRange,\n variableState: variableValues,\n datasourceStore,\n refreshKey: '',\n };\n\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = ['query', LOG_QUERY_KEY, definition, absoluteTimeRange, variableValues] as const;\n const logQueryKind = definition?.spec?.plugin?.kind;\n return {\n queryKey: queryKey,\n queryFn: async (): Promise<LogQueryResult> => {\n const plugin = await getPlugin(LOG_QUERY_KEY, logQueryKind);\n const data = await plugin.getLogData(definition.spec.plugin.spec, context);\n return data;\n },\n\n structuralSharing: false,\n };\n }),\n });\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","useTimeRange","useVariableValues","LOG_QUERY_KEY","useLogQueries","definitions","getPlugin","datasourceStore","absoluteTimeRange","variableValues","context","timeRange","variableState","refreshKey","queries","map","definition","queryKey","logQueryKind","spec","plugin","kind","queryFn","data","getLogData","structuralSharing"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAwB,wBAAwB;AAEnE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,iBAAiB,QAAQ,cAAc;AAGhD,OAAO,MAAMC,gBAAgB,WAAW;AAExC,OAAO,SAASC,cAAcC,WAAiC;IAC7D,MAAM,EAAEC,SAAS,EAAE,GAAGN;IACtB,MAAMO,kBAAkBR;IACxB,MAAM,EAAES,iBAAiB,EAAE,GAAGP;IAC9B,MAAMQ,iBAAiBP;IAEvB,MAAMQ,UAAU;QACdC,WAAWH;QACXI,eAAeH;QACfF;QACAM,YAAY;IACd;IAEA,OAAOf,WAAW;QAChBgB,SAAST,YAAYU,GAAG,CAAC,CAACC;YACxB,MAAMC,WAAW;gBAAC;gBAASd;gBAAea;gBAAYR;gBAAmBC;aAAe;YACxF,MAAMS,eAAeF,YAAYG,MAAMC,QAAQC;YAC/C,OAAO;gBACLJ,UAAUA;gBACVK,SAAS;oBACP,MAAMF,SAAS,MAAMd,UAAUH,eAAee;oBAC9C,MAAMK,OAAO,MAAMH,OAAOI,UAAU,CAACR,WAAWG,IAAI,CAACC,MAAM,CAACD,IAAI,EAAET;oBAClE,OAAOa;gBACT;gBAEAE,mBAAmB;YACrB;QACF;IACF;AACF"}
|
|
@@ -31,8 +31,9 @@ export const PROFILE_QUERY_KEY = 'ProfileQuery';
|
|
|
31
31
|
return useQueries({
|
|
32
32
|
queries: definitions.map((definition)=>{
|
|
33
33
|
const queryKey = [
|
|
34
|
+
'query',
|
|
35
|
+
PROFILE_QUERY_KEY,
|
|
34
36
|
definition,
|
|
35
|
-
datasourceStore,
|
|
36
37
|
absoluteTimeRange
|
|
37
38
|
]; // `queryKey` watches and reruns `queryFn` if keys in the array change
|
|
38
39
|
const profileQueryKind = definition?.spec?.plugin?.kind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/profile-queries.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition, UnknownSpec, ProfileData } from '@perses-dev/core';\nimport { useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nexport type ProfileQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'ProfileQuery', PluginSpec>;\nexport const PROFILE_QUERY_KEY = 'ProfileQuery';\n\n/**\n * Run a profile query using a ProfileQuery plugin and return the results\n * @param definitions: dashboard defintion for a profile query\n */\nexport function useProfileQueries(definitions: ProfileQueryDefinition[]): Array<UseQueryResult<ProfileData>> {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n\n const context = {\n datasourceStore,\n absoluteTimeRange,\n };\n\n // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)\n // https://tanstack.com/query/v4/docs/react/reference/useQuery\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = [
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/profile-queries.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition, UnknownSpec, ProfileData } from '@perses-dev/core';\nimport { useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nexport type ProfileQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'ProfileQuery', PluginSpec>;\nexport const PROFILE_QUERY_KEY = 'ProfileQuery';\n\n/**\n * Run a profile query using a ProfileQuery plugin and return the results\n * @param definitions: dashboard defintion for a profile query\n */\nexport function useProfileQueries(definitions: ProfileQueryDefinition[]): Array<UseQueryResult<ProfileData>> {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n\n const context = {\n datasourceStore,\n absoluteTimeRange,\n };\n\n // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)\n // https://tanstack.com/query/v4/docs/react/reference/useQuery\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = ['query', PROFILE_QUERY_KEY, definition, absoluteTimeRange] as const; // `queryKey` watches and reruns `queryFn` if keys in the array change\n const profileQueryKind = definition?.spec?.plugin?.kind;\n return {\n queryKey: queryKey,\n queryFn: async (): Promise<ProfileData> => {\n const plugin = await getPlugin(PROFILE_QUERY_KEY, profileQueryKind);\n const data = await plugin.getProfileData(definition.spec.plugin.spec, context);\n return data;\n },\n\n structuralSharing: false,\n };\n }),\n });\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","useTimeRange","PROFILE_QUERY_KEY","useProfileQueries","definitions","getPlugin","datasourceStore","absoluteTimeRange","context","queries","map","definition","queryKey","profileQueryKind","spec","plugin","kind","queryFn","data","getProfileData","structuralSharing"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAwB,wBAAwB;AACnE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,sBAAsB;AAEnD,OAAO,MAAMC,oBAAoB,eAAe;AAEhD;;;CAGC,GACD,OAAO,SAASC,kBAAkBC,WAAqC;IACrE,MAAM,EAAEC,SAAS,EAAE,GAAGL;IACtB,MAAMM,kBAAkBP;IACxB,MAAM,EAAEQ,iBAAiB,EAAE,GAAGN;IAE9B,MAAMO,UAAU;QACdF;QACAC;IACF;IAEA,+FAA+F;IAC/F,8DAA8D;IAC9D,OAAOT,WAAW;QAChBW,SAASL,YAAYM,GAAG,CAAC,CAACC;YACxB,MAAMC,WAAW;gBAAC;gBAASV;gBAAmBS;gBAAYJ;aAAkB,EAAW,sEAAsE;YAC7J,MAAMM,mBAAmBF,YAAYG,MAAMC,QAAQC;YACnD,OAAO;gBACLJ,UAAUA;gBACVK,SAAS;oBACP,MAAMF,SAAS,MAAMV,UAAUH,mBAAmBW;oBAClD,MAAMK,OAAO,MAAMH,OAAOI,cAAc,CAACR,WAAWG,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN;oBACtE,OAAOU;gBACT;gBAEAE,mBAAmB;YACrB;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAe,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAEL,UAAU,EAEV,oBAAoB,EAIpB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAA0B,mBAAmB,EAAyB,MAAM,UAAU,CAAC;AAOnH,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAe,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAEL,UAAU,EAEV,oBAAoB,EAIpB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAA0B,mBAAmB,EAAyB,MAAM,UAAU,CAAC;AAOnH,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB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