@perses-dev/plugin-system 0.55.0-beta.3 → 0.55.0-beta.6
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/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +3 -3
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +11 -11
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +3 -3
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +6 -6
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/index.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -1
- package/dist/components/Annotations/index.js +2 -2
- package/dist/components/Annotations/index.js.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/CalculationSelector/index.js +1 -1
- package/dist/components/CalculationSelector/index.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +7 -7
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceEditorForm/index.js +1 -1
- package/dist/components/DatasourceEditorForm/index.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts +4 -4
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +7 -7
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/DatasourceSelect/index.js +1 -1
- package/dist/components/DatasourceSelect/index.js.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts +2 -2
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +4 -4
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/index.js +1 -1
- package/dist/components/DatasourceTestConnectionButton/index.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +2 -2
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +9 -9
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/index.js +1 -1
- package/dist/components/HTTPSettingsEditor/index.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +24 -24
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/index.js +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/index.js.map +1 -1
- package/dist/components/LayoutEditor/LayoutEditor.d.ts +4 -4
- package/dist/components/LayoutEditor/LayoutEditor.d.ts.map +1 -1
- package/dist/components/LayoutEditor/LayoutEditor.js +7 -7
- package/dist/components/LayoutEditor/LayoutEditor.js.map +1 -1
- package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts +1 -1
- package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts.map +1 -1
- package/dist/components/LayoutEditor/RepeatLayoutPreview.js +4 -4
- package/dist/components/LayoutEditor/RepeatLayoutPreview.js.map +1 -1
- package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts +4 -4
- package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts.map +1 -1
- package/dist/components/LayoutEditor/RepeatVariableEditor.js +3 -3
- package/dist/components/LayoutEditor/RepeatVariableEditor.js.map +1 -1
- package/dist/components/LayoutEditor/index.js +3 -3
- package/dist/components/LayoutEditor/index.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +2 -2
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +5 -5
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/index.js +1 -1
- package/dist/components/LegendOptionsEditor/index.js.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.d.ts +3 -3
- package/dist/components/LinksEditor/LinksEditor.d.ts.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.js +6 -6
- package/dist/components/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/components/LinksEditor/index.js +1 -1
- package/dist/components/LinksEditor/index.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +2 -2
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MetricLabelInput/index.js +1 -1
- package/dist/components/MetricLabelInput/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -3
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +6 -6
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -3
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +14 -14
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/MultiQueryEditor/index.js +2 -2
- package/dist/components/MultiQueryEditor/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/utils.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +4 -4
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorRadios/index.js +1 -1
- package/dist/components/OptionsEditorRadios/index.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/index.js +1 -1
- package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +4 -4
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/OptionsEditorTabs/index.js +1 -1
- package/dist/components/OptionsEditorTabs/index.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts +2 -2
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js +9 -9
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +5 -5
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +9 -9
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/index.js +1 -1
- package/dist/components/PanelSpecEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +2 -2
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +7 -7
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/index.js +2 -2
- package/dist/components/PluginEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -3
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +4 -4
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -3
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +4 -4
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginKindSelect/index.js +1 -1
- package/dist/components/PluginKindSelect/index.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +5 -5
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +2 -2
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.js +2 -2
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -1
- package/dist/components/PluginRegistry/index.js +1 -1
- package/dist/components/PluginRegistry/index.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +2 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +3 -3
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts +3 -3
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js +3 -3
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +4 -4
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +4 -4
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/PluginSpecEditor/index.js +1 -1
- package/dist/components/PluginSpecEditor/index.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.d.ts +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.d.ts.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +3 -3
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/index.js +1 -1
- package/dist/components/SelectionOptionsEditor/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +10 -10
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/index.js +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +3 -3
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +11 -11
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +7 -7
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js +3 -3
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/index.js +2 -2
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +4 -4
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +3 -3
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.js +21 -21
- package/dist/components/index.js.map +1 -1
- package/dist/constants/index.js +2 -2
- package/dist/constants/index.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +5 -5
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +5 -5
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +4 -4
- package/dist/model/alerts-queries.d.ts.map +1 -1
- package/dist/model/alerts-queries.js.map +1 -1
- package/dist/model/annotations.d.ts +3 -3
- package/dist/model/annotations.d.ts.map +1 -1
- package/dist/model/annotations.js.map +1 -1
- package/dist/model/calculations.d.ts +1 -1
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +2 -2
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/explore.d.ts +2 -2
- package/dist/model/explore.d.ts.map +1 -1
- package/dist/model/explore.js.map +1 -1
- package/dist/model/index.js +17 -17
- package/dist/model/index.js.map +1 -1
- package/dist/model/json-queries.d.ts +3 -3
- package/dist/model/json-queries.d.ts.map +1 -1
- package/dist/model/json-queries.js.map +1 -1
- package/dist/model/legend.d.ts +2 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +2 -2
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts +3 -3
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/panels.d.ts +4 -4
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +1 -1
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.d.ts +1 -1
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +14 -14
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/profile-queries.d.ts +4 -4
- package/dist/model/profile-queries.d.ts.map +1 -1
- package/dist/model/profile-queries.js.map +1 -1
- package/dist/model/silences-queries.d.ts +4 -4
- package/dist/model/silences-queries.d.ts.map +1 -1
- package/dist/model/silences-queries.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +4 -4
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +4 -4
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/model/variables.d.ts +3 -3
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.d.ts +1 -1
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +2 -2
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +2 -2
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +18 -18
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/index.js +2 -2
- package/dist/remote/index.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts +2 -2
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +3 -3
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +3 -3
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -10
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/index.js +2 -2
- package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +3 -3
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.d.ts +2 -1
- package/dist/runtime/RouterProvider.d.ts.map +1 -1
- package/dist/runtime/RouterProvider.js +3 -3
- package/dist/runtime/RouterProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +3 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -6
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +3 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +4 -4
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +2 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +3 -3
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +4 -4
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +3 -3
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +4 -4
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.js +2 -2
- package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts +3 -3
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +3 -3
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts +2 -2
- package/dist/runtime/alerts-queries.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.js +5 -5
- package/dist/runtime/alerts-queries.js.map +1 -1
- package/dist/runtime/annotations.d.ts +2 -2
- package/dist/runtime/annotations.d.ts.map +1 -1
- package/dist/runtime/annotations.js +6 -6
- package/dist/runtime/annotations.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +2 -2
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +2 -2
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +2 -2
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.js +16 -16
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.d.ts +3 -3
- package/dist/runtime/item-actions.d.ts.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/json-queries.d.ts +2 -2
- package/dist/runtime/json-queries.d.ts.map +1 -1
- package/dist/runtime/json-queries.js +4 -4
- package/dist/runtime/json-queries.js.map +1 -1
- package/dist/runtime/log-queries.d.ts +3 -3
- package/dist/runtime/log-queries.d.ts.map +1 -1
- package/dist/runtime/log-queries.js +5 -5
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +3 -3
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +2 -2
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.d.ts +2 -2
- package/dist/runtime/profile-queries.d.ts.map +1 -1
- package/dist/runtime/profile-queries.js +4 -4
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts +2 -2
- package/dist/runtime/silences-queries.d.ts.map +1 -1
- package/dist/runtime/silences-queries.js +5 -5
- package/dist/runtime/silences-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +3 -3
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +6 -6
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts +2 -2
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +6 -6
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.d.ts.map +1 -1
- package/dist/runtime/utils.js.map +1 -1
- package/dist/runtime/variables.d.ts +1 -1
- package/dist/runtime/variables.d.ts.map +1 -1
- package/dist/runtime/variables.js +4 -4
- package/dist/runtime/variables.js.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/panel.d.ts +2 -2
- package/dist/schema/panel.d.ts.map +1 -1
- package/dist/schema/panel.js +2 -2
- package/dist/schema/panel.js.map +1 -1
- package/dist/test/index.js +2 -2
- package/dist/test/index.js.map +1 -1
- package/dist/test/mock-data.d.ts +1 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render-hook.d.ts +2 -2
- package/dist/test/render-hook.d.ts.map +1 -1
- package/dist/test/render-hook.js +2 -2
- package/dist/test/render-hook.js.map +1 -1
- package/dist/test/render.d.ts +3 -3
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +3 -3
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js +1 -1
- package/dist/test/test-plugins/bert/index.d.ts +3 -3
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.d.ts +1 -1
- package/dist/test/test-plugins/index.d.ts.map +1 -1
- package/dist/test/test-plugins/index.js +5 -5
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +4 -4
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts +2 -2
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/event.js +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/variables.js +1 -1
- package/package.json +7 -7
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +0 -283
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +0 -197
- package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +0 -30
- package/dist/cjs/components/Annotations/constants.js +0 -23
- package/dist/cjs/components/Annotations/index.js +0 -31
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +0 -49
- package/dist/cjs/components/CalculationSelector/index.js +0 -30
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +0 -271
- package/dist/cjs/components/DatasourceEditorForm/index.js +0 -30
- package/dist/cjs/components/DatasourceSelect/DatasourceSelect.js +0 -266
- package/dist/cjs/components/DatasourceSelect/index.js +0 -30
- package/dist/cjs/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +0 -53
- package/dist/cjs/components/DatasourceTestConnectionButton/index.js +0 -30
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +0 -593
- package/dist/cjs/components/HTTPSettingsEditor/index.js +0 -30
- package/dist/cjs/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +0 -1175
- package/dist/cjs/components/ItemSelectionActionsOptionsEditor/index.js +0 -30
- package/dist/cjs/components/LayoutEditor/LayoutEditor.js +0 -123
- package/dist/cjs/components/LayoutEditor/RepeatLayoutPreview.js +0 -105
- package/dist/cjs/components/LayoutEditor/RepeatVariableEditor.js +0 -176
- package/dist/cjs/components/LayoutEditor/index.js +0 -32
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +0 -211
- package/dist/cjs/components/LegendOptionsEditor/index.js +0 -30
- package/dist/cjs/components/LinksEditor/LinksEditor.js +0 -162
- package/dist/cjs/components/LinksEditor/index.js +0 -30
- package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +0 -41
- package/dist/cjs/components/MetricLabelInput/index.js +0 -30
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +0 -162
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +0 -250
- package/dist/cjs/components/MultiQueryEditor/index.js +0 -31
- package/dist/cjs/components/MultiQueryEditor/utils.js +0 -36
- package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +0 -69
- package/dist/cjs/components/OptionsEditorRadios/index.js +0 -30
- package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +0 -39
- package/dist/cjs/components/OptionsEditorTabPanel/index.js +0 -30
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +0 -61
- package/dist/cjs/components/OptionsEditorTabs/index.js +0 -30
- package/dist/cjs/components/PanelSpecEditor/PanelAnnotationsEditor.js +0 -246
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +0 -144
- package/dist/cjs/components/PanelSpecEditor/index.js +0 -30
- package/dist/cjs/components/PluginEditor/PluginEditor.js +0 -99
- package/dist/cjs/components/PluginEditor/index.js +0 -31
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +0 -136
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +0 -109
- package/dist/cjs/components/PluginKindSelect/index.js +0 -30
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +0 -86
- package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +0 -92
- package/dist/cjs/components/PluginRegistry/index.js +0 -30
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +0 -88
- package/dist/cjs/components/PluginSpecEditor/DatasourceSpecEditor.js +0 -70
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +0 -69
- package/dist/cjs/components/PluginSpecEditor/index.js +0 -30
- package/dist/cjs/components/SelectionOptionsEditor/SelectionOptionsEditor.js +0 -43
- package/dist/cjs/components/SelectionOptionsEditor/index.js +0 -30
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +0 -235
- package/dist/cjs/components/TimeRangeControls/index.js +0 -30
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -613
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -193
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -32
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -143
- package/dist/cjs/components/Variables/index.js +0 -31
- package/dist/cjs/components/Variables/variable-model.js +0 -211
- package/dist/cjs/components/index.js +0 -50
- package/dist/cjs/constants/index.js +0 -31
- package/dist/cjs/constants/repeat.js +0 -32
- package/dist/cjs/constants/user-interface-text.js +0 -32
- package/dist/cjs/context/ValidationProvider.js +0 -77
- package/dist/cjs/context/index.js +0 -30
- package/dist/cjs/index.js +0 -38
- package/dist/cjs/model/alerts-queries.js +0 -16
- package/dist/cjs/model/annotations.js +0 -16
- package/dist/cjs/model/calculations.js +0 -178
- package/dist/cjs/model/datasource.js +0 -16
- package/dist/cjs/model/explore.js +0 -16
- package/dist/cjs/model/index.js +0 -46
- package/dist/cjs/model/json-queries.js +0 -16
- package/dist/cjs/model/legend.js +0 -111
- package/dist/cjs/model/log-queries.js +0 -16
- package/dist/cjs/model/log-volume-utils.js +0 -124
- package/dist/cjs/model/panels.js +0 -16
- package/dist/cjs/model/plugin-base.js +0 -16
- package/dist/cjs/model/plugin-loading.js +0 -56
- package/dist/cjs/model/plugins.js +0 -26
- package/dist/cjs/model/profile-queries.js +0 -16
- package/dist/cjs/model/silences-queries.js +0 -16
- package/dist/cjs/model/time-series-queries.js +0 -26
- package/dist/cjs/model/trace-queries.js +0 -16
- package/dist/cjs/model/variables.js +0 -16
- package/dist/cjs/remote/PersesPlugin.types.js +0 -16
- package/dist/cjs/remote/PluginLoaderComponent.js +0 -87
- package/dist/cjs/remote/PluginRuntime.js +0 -323
- package/dist/cjs/remote/index.js +0 -31
- package/dist/cjs/remote/remotePluginLoader.js +0 -101
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +0 -162
- package/dist/cjs/runtime/DataQueriesProvider/index.js +0 -31
- package/dist/cjs/runtime/DataQueriesProvider/model.js +0 -34
- package/dist/cjs/runtime/RouterProvider.js +0 -114
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +0 -215
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviders.js +0 -66
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +0 -126
- package/dist/cjs/runtime/TimeRangeProvider/index.js +0 -33
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +0 -250
- package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +0 -30
- package/dist/cjs/runtime/UsageMetricsProvider.js +0 -102
- package/dist/cjs/runtime/alerts-queries.js +0 -101
- package/dist/cjs/runtime/annotations.js +0 -148
- package/dist/cjs/runtime/builtin-variables.js +0 -81
- package/dist/cjs/runtime/datasources.js +0 -80
- package/dist/cjs/runtime/index.js +0 -45
- package/dist/cjs/runtime/item-actions.js +0 -302
- package/dist/cjs/runtime/json-queries.js +0 -70
- package/dist/cjs/runtime/log-queries.js +0 -76
- package/dist/cjs/runtime/plugin-registry.js +0 -135
- package/dist/cjs/runtime/profile-queries.js +0 -73
- package/dist/cjs/runtime/silences-queries.js +0 -101
- package/dist/cjs/runtime/time-series-queries.js +0 -165
- package/dist/cjs/runtime/trace-queries.js +0 -106
- package/dist/cjs/runtime/utils.js +0 -39
- package/dist/cjs/runtime/variables.js +0 -160
- package/dist/cjs/schema/index.js +0 -30
- package/dist/cjs/schema/panel.js +0 -56
- package/dist/cjs/test/index.js +0 -31
- package/dist/cjs/test/mock-data.js +0 -366
- package/dist/cjs/test/render-hook.js +0 -31
- package/dist/cjs/test/render.js +0 -31
- package/dist/cjs/test/setup-tests.js +0 -26
- package/dist/cjs/test/test-plugins/bert/index.js +0 -99
- package/dist/cjs/test/test-plugins/ernie/index.js +0 -149
- package/dist/cjs/test/test-plugins/index.js +0 -81
- package/dist/cjs/test/utils.js +0 -58
- package/dist/cjs/test-utils/index.js +0 -30
- package/dist/cjs/test-utils/mock-plugin-registry.js +0 -81
- package/dist/cjs/utils/csv-export.js +0 -248
- package/dist/cjs/utils/event.js +0 -30
- package/dist/cjs/utils/index.js +0 -32
- package/dist/cjs/utils/variables.js +0 -44
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { useQueries } from
|
|
14
|
-
import { useDatasourceStore } from
|
|
15
|
-
import { usePluginRegistry, usePlugins } from
|
|
16
|
-
import { filterVariableStateMap, getVariableValuesKey } from
|
|
17
|
-
import { useAllVariableValues } from
|
|
13
|
+
import { useQueries } from "@tanstack/react-query";
|
|
14
|
+
import { useDatasourceStore } from "./datasources.js";
|
|
15
|
+
import { usePluginRegistry, usePlugins } from "./plugin-registry.js";
|
|
16
|
+
import { filterVariableStateMap, getVariableValuesKey } from "./utils.js";
|
|
17
|
+
import { useAllVariableValues } from "./variables.js";
|
|
18
18
|
export const SILENCES_QUERY_KEY = 'SilencesQuery';
|
|
19
19
|
/**
|
|
20
20
|
* Run a silences query using a SilencesQuery plugin and return the results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/silences-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { SilencesData, QueryDefinition, UnknownSpec } from '@perses-dev/spec';\nimport { QueryKey,
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/silences-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { SilencesData, QueryDefinition, UnknownSpec } from '@perses-dev/spec';\nimport type { QueryKey, UseQueryResult } from '@tanstack/react-query';\nimport { useQueries } from '@tanstack/react-query';\n\nimport type { SilencesQueryContext, SilencesQueryPlugin } from '../model';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry, usePlugins } from './plugin-registry';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\nimport { useAllVariableValues } from './variables';\n\nexport type SilencesQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'SilencesQuery', PluginSpec>;\nexport const SILENCES_QUERY_KEY = 'SilencesQuery';\n\n/**\n * Run a silences query using a SilencesQuery plugin and return the results.\n * Silences represent current state and are NOT time-range dependent.\n * @param definitions: dashboard definition for a silences query\n */\nexport function useSilencesQueries(definitions: SilencesQueryDefinition[]): Array<UseQueryResult<SilencesData>> {\n const { getPlugin } = usePluginRegistry();\n const context = useSilencesQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n 'SilencesQuery',\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({ context, definition, plugin });\n const silencesQueryKind = definition?.spec?.plugin?.kind;\n return {\n enabled: queryEnabled,\n queryKey: queryKey,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n staleTime: 60_000,\n queryFn: async ({ signal }: { signal?: AbortSignal }): Promise<SilencesData> => {\n const plugin = await getPlugin({ kind: SILENCES_QUERY_KEY, name: silencesQueryKind });\n const data = await plugin.getSilencesData(definition.spec.plugin.spec, context, signal);\n return data;\n },\n };\n }),\n });\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: SilencesQueryPlugin;\n definition: SilencesQueryDefinition;\n context: SilencesQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { variableState } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n // Note: no absoluteTimeRange in query key since silences are current state\n const queryKey = ['query', SILENCES_QUERY_KEY, definition, variablesValueKey] as const;\n\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n return {\n queryKey,\n queryEnabled,\n };\n}\n\nfunction useSilencesQueryContext(): SilencesQueryContext {\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n variableState,\n datasourceStore,\n };\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","usePlugins","filterVariableStateMap","getVariableValuesKey","useAllVariableValues","SILENCES_QUERY_KEY","useSilencesQueries","definitions","getPlugin","context","useSilencesQueryContext","pluginLoaderResponse","map","d","kind","spec","plugin","queries","definition","idx","data","queryEnabled","queryKey","getQueryOptions","silencesQueryKind","enabled","refetchOnMount","refetchOnWindowFocus","refetchOnReconnect","staleTime","queryFn","signal","name","getSilencesData","variableState","dependencies","dependsOn","variableDependencies","variables","filteredVariabledState","variablesValueKey","waitToLoad","some","v","loading","undefined","datasourceStore"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,QAAQ,wBAAwB;AAGnD,SAASC,kBAAkB,QAAQ,mBAAgB;AACnD,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,uBAAoB;AAClE,SAASC,sBAAsB,EAAEC,oBAAoB,QAAQ,aAAU;AACvE,SAASC,oBAAoB,QAAQ,iBAAc;AAGnD,OAAO,MAAMC,qBAAqB,gBAAgB;AAElD;;;;CAIC,GACD,OAAO,SAASC,mBAAmBC,WAAsC;IACvE,MAAM,EAAEC,SAAS,EAAE,GAAGR;IACtB,MAAMS,UAAUC;IAEhB,MAAMC,uBAAuBV,WAC3B,iBACAM,YAAYK,GAAG,CAAC,CAACC,IAAO,CAAA;YAAEC,MAAMD,EAAEE,IAAI,CAACC,MAAM,CAACF,IAAI;QAAC,CAAA;IAGrD,OAAOhB,WAAW;QAChBmB,SAASV,YAAYK,GAAG,CAAC,CAACM,YAAYC;YACpC,MAAMH,SAASL,oBAAoB,CAACQ,IAAI,EAAEC;YAC1C,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGC,gBAAgB;gBAAEd;gBAASS;gBAAYF;YAAO;YACjF,MAAMQ,oBAAoBN,YAAYH,MAAMC,QAAQF;YACpD,OAAO;gBACLW,SAASJ;gBACTC,UAAUA;gBACVI,gBAAgB;gBAChBC,sBAAsB;gBACtBC,oBAAoB;gBACpBC,WAAW;gBACXC,SAAS,OAAO,EAAEC,MAAM,EAA4B;oBAClD,MAAMf,SAAS,MAAMR,UAAU;wBAAEM,MAAMT;wBAAoB2B,MAAMR;oBAAkB;oBACnF,MAAMJ,OAAO,MAAMJ,OAAOiB,eAAe,CAACf,WAAWH,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN,SAASsB;oBAChF,OAAOX;gBACT;YACF;QACF;IACF;AACF;AAEA,SAASG,gBAAgB,EACvBP,MAAM,EACNE,UAAU,EACVT,OAAO,EAKR;IAIC,MAAM,EAAEyB,aAAa,EAAE,GAAGzB;IAE1B,MAAM0B,eAAenB,QAAQoB,YAAYpB,OAAOoB,SAAS,CAAClB,WAAWH,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN,WAAW,CAAC;IACnG,MAAM4B,uBAAuBF,cAAcG;IAE3C,MAAMC,yBAAyBrC,uBAAuBgC,eAAeG;IACrE,MAAMG,oBAAoBrC,qBAAqBoC;IAC/C,2EAA2E;IAC3E,MAAMjB,WAAW;QAAC;QAASjB;QAAoBa;QAAYsB;KAAkB;IAE7E,IAAIC,aAAa;IACjB,IAAIJ,sBAAsB;QACxBI,aAAaJ,qBAAqBK,IAAI,CAAC,CAACC,IAAMT,aAAa,CAACS,EAAE,EAAEC;IAClE;IAEA,MAAMvB,eAAeL,WAAW6B,aAAa,CAACJ;IAC9C,OAAO;QACLnB;QACAD;IACF;AACF;AAEA,SAASX;IACP,MAAMwB,gBAAgB9B;IACtB,MAAM0C,kBAAkB/C;IAExB,OAAO;QACLmC;QACAY;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TimeSeriesData, TimeSeriesQueryDefinition } from '@perses-dev/spec';
|
|
2
|
-
import { QueryCache, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { TimeSeriesDataQuery, TimeSeriesQueryMode } from '../model';
|
|
1
|
+
import type { TimeSeriesData, TimeSeriesQueryDefinition } from '@perses-dev/spec';
|
|
2
|
+
import type { QueryCache, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import type { TimeSeriesDataQuery, TimeSeriesQueryMode } from '../model';
|
|
4
4
|
export interface UseTimeSeriesQueryOptions {
|
|
5
5
|
suggestedStepMs?: number;
|
|
6
6
|
mode?: TimeSeriesQueryMode;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAe,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAS,UAAU,EAAY,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG/G,OAAO,KAAK,EAAE,mBAAmB,EAA0B,mBAAmB,EAAyB,MAAM,UAAU,CAAC;AAOxH,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AA+CvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,yBAAyB,EACrC,UAAU,yBAAyB,EACnC,eAAe,oBAAoB,CAAC,cAAc,CAAC,KAClD,cAAc,CAAC,cAAc,CAiB/B,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,yBAAyB,EAAE,EACxC,OAAO,CAAC,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,GACpD,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAgCvC;AAiBD;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,mBAAmB,EAAE,CAIlE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,EAAE,CAWnF"}
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { useQueries, useQuery, useQueryClient } from
|
|
14
|
-
import { useDatasourceStore } from
|
|
15
|
-
import { usePlugin, usePluginRegistry, usePlugins } from
|
|
16
|
-
import { useTimeRange } from
|
|
17
|
-
import { filterVariableStateMap, getVariableValuesKey } from
|
|
18
|
-
import { useAllVariableValues } from
|
|
13
|
+
import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
14
|
+
import { useDatasourceStore } from "./datasources.js";
|
|
15
|
+
import { usePlugin, usePluginRegistry, usePlugins } from "./plugin-registry.js";
|
|
16
|
+
import { useTimeRange } from "./TimeRangeProvider/index.js";
|
|
17
|
+
import { filterVariableStateMap, getVariableValuesKey } from "./utils.js";
|
|
18
|
+
import { useAllVariableValues } from "./variables.js";
|
|
19
19
|
export const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';
|
|
20
20
|
function getQueryOptions({ plugin, definition, context }) {
|
|
21
21
|
const { timeRange, suggestedStepMs, mode, variableState } = context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TimeSeriesData, TimeSeriesQueryDefinition, UnknownSpec } from '@perses-dev/spec';\nimport {\n Query,\n QueryCache,\n QueryKey,\n QueryObserverOptions,\n useQueries,\n useQuery,\n useQueryClient,\n UseQueryResult,\n} from '@tanstack/react-query';\n\nimport { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryMode, TimeSeriesQueryPlugin } from '../model';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\nimport { useAllVariableValues } from './variables';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { timeRange, suggestedStepMs, mode, variableState } = 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\n const queryKey = [\n 'query',\n TIME_SERIES_QUERY_KEY,\n definition,\n timeRange,\n variablesValueKey,\n suggestedStepMs,\n mode,\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<TimeSeriesData>,\n): UseQueryResult<TimeSeriesData> => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: (queryOptions?.enabled ?? true) || queryEnabled,\n queryKey: queryKey,\n queryFn: ({ signal }) => {\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, signal);\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?: Omit<QueryObserverOptions, 'queryKey'>,\n): Array<UseQueryResult<TimeSeriesData>> {\n const { getPlugin } = usePluginRegistry();\n const context = {\n ...useTimeSeriesQueryContext(),\n mode: options?.mode,\n suggestedStepMs: options?.suggestedStepMs,\n };\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind })),\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 ...queryOptions,\n enabled: (queryOptions?.enabled ?? true) && queryEnabled,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n staleTime: Infinity,\n queryKey: queryKey,\n queryFn: async ({ signal }: { signal: AbortSignal }): Promise<TimeSeriesData> => {\n const plugin = await getPlugin({ kind: TIME_SERIES_QUERY_KEY, name: definition.spec.plugin.kind });\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, context, signal);\n return data;\n },\n } as QueryObserverOptions;\n }),\n }) as Array<UseQueryResult<TimeSeriesData>>;\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange } = useTimeRange();\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries(): TimeSeriesDataQuery[] {\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): TimeSeriesDataQuery[] {\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":["useQueries","useQuery","useQueryClient","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","useTimeRange","filterVariableStateMap","getVariableValuesKey","useAllVariableValues","TIME_SERIES_QUERY_KEY","getQueryOptions","plugin","definition","context","timeRange","suggestedStepMs","mode","variableState","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","v","loading","queryEnabled","undefined","useTimeSeriesQuery","options","queryOptions","data","kind","useTimeSeriesQueryContext","enabled","queryFn","signal","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","map","d","queries","idx","refetchOnMount","refetchOnWindowFocus","refetchOnReconnect","staleTime","Infinity","name","absoluteTimeRange","datasourceStore","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","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AO;gBACL,GAAGqB,YAAY;gBACfI,SAAS,AAACJ,CAAAA,cAAcI,WAAW,IAAG,KAAMR;gBAC5CsB,gBAAgB;gBAChBC,sBAAsB;gBACtBC,oBAAoB;gBACpBC,WAAWC;gBACX/B,UAAUA;gBACVc,SAAS,OAAO,EAAEC,MAAM,EAA2B;oBACjD,MAAM7B,SAAS,MAAMmC,UAAU;wBAAEV,MAAM3B;wBAAuBgD,MAAM7C,WAAWQ,IAAI,CAACT,MAAM,CAACyB,IAAI;oBAAC;oBAChG,MAAMD,OAAO,MAAMxB,OAAOgC,iBAAiB,CAAC/B,WAAWQ,IAAI,CAACT,MAAM,CAACS,IAAI,EAAEP,SAAS2B;oBAClF,OAAOL;gBACT;YACF;QACF;IACF;AACF;AAEA;;CAEC,GACD,SAASE;IACP,MAAM,EAAEqB,iBAAiB,EAAE,GAAGrD;IAC9B,MAAMY,gBAAgBT;IACtB,MAAMmD,kBAAkB1D;IAExB,OAAO;QACLa,WAAW4C;QACXzC;QACA0C;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,cAAc7D;IACpB,MAAM8D,aAAaD,YAAYE,aAAa;IAC5C,OAAOC,2BAA2BF;AACpC;AAEA;;CAEC,GACD,OAAO,SAASE,2BAA2BC,KAAiB;IAC1D,MAAMf,UAAiC,EAAE;IAEzC,KAAK,MAAMgB,SAASD,MAAME,OAAO,CAAC;QAAEC,MAAM;IAAS,GAAI;QACrD,MAAMC,YAAYH,MAAMzC,QAAQ,EAAE,CAAC,EAAE;QACrC,IAAI4C,WAAWjC,QAAQ,AAACiC,UAAUjC,IAAI,CAAYkC,UAAU,CAAC7D,wBAAwB;YACnFyC,QAAQqB,IAAI,CAACL;QACf;IACF;IAEA,OAAOhB;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { TimeSeriesData, TimeSeriesQueryDefinition, UnknownSpec } from '@perses-dev/spec';\nimport type { Query, QueryCache, QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { useQueries, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport type { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryMode, TimeSeriesQueryPlugin } from '../model';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\nimport { useAllVariableValues } from './variables';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { timeRange, suggestedStepMs, mode, variableState } = 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\n const queryKey = [\n 'query',\n TIME_SERIES_QUERY_KEY,\n definition,\n timeRange,\n variablesValueKey,\n suggestedStepMs,\n mode,\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<TimeSeriesData>,\n): UseQueryResult<TimeSeriesData> => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: (queryOptions?.enabled ?? true) || queryEnabled,\n queryKey: queryKey,\n queryFn: ({ signal }) => {\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, signal);\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?: Omit<QueryObserverOptions, 'queryKey'>,\n): Array<UseQueryResult<TimeSeriesData>> {\n const { getPlugin } = usePluginRegistry();\n const context = {\n ...useTimeSeriesQueryContext(),\n mode: options?.mode,\n suggestedStepMs: options?.suggestedStepMs,\n };\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind })),\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 ...queryOptions,\n enabled: (queryOptions?.enabled ?? true) && queryEnabled,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n staleTime: Infinity,\n queryKey: queryKey,\n queryFn: async ({ signal }: { signal: AbortSignal }): Promise<TimeSeriesData> => {\n const plugin = await getPlugin({ kind: TIME_SERIES_QUERY_KEY, name: definition.spec.plugin.kind });\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, context, signal);\n return data;\n },\n } as QueryObserverOptions;\n }),\n }) as Array<UseQueryResult<TimeSeriesData>>;\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange } = useTimeRange();\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries(): TimeSeriesDataQuery[] {\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): TimeSeriesDataQuery[] {\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":["useQueries","useQuery","useQueryClient","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","useTimeRange","filterVariableStateMap","getVariableValuesKey","useAllVariableValues","TIME_SERIES_QUERY_KEY","getQueryOptions","plugin","definition","context","timeRange","suggestedStepMs","mode","variableState","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","v","loading","queryEnabled","undefined","useTimeSeriesQuery","options","queryOptions","data","kind","useTimeSeriesQueryContext","enabled","queryFn","signal","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","map","d","queries","idx","refetchOnMount","refetchOnWindowFocus","refetchOnReconnect","staleTime","Infinity","name","absoluteTimeRange","datasourceStore","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","getActiveTimeSeriesQueries","cache","query","findAll","type","firstPart","startsWith","push"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,wBAAwB;AAG7E,SAASC,kBAAkB,QAAQ,mBAAgB;AACnD,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,uBAAoB;AAC7E,SAASC,YAAY,QAAQ,+BAAsB;AACnD,SAASC,sBAAsB,EAAEC,oBAAoB,QAAQ,aAAU;AACvE,SAASC,oBAAoB,QAAQ,iBAAc;AAOnD,OAAO,MAAMC,wBAAwB,kBAAkB;AAEvD,SAASC,gBAAgB,EACvBC,MAAM,EACNC,UAAU,EACVC,OAAO,EAKR;IAIC,MAAM,EAAEC,SAAS,EAAEC,eAAe,EAAEC,IAAI,EAAEC,aAAa,EAAE,GAAGJ;IAE5D,MAAMK,eAAeP,QAAQQ,YAAYR,OAAOQ,SAAS,CAACP,WAAWQ,IAAI,CAACT,MAAM,CAACS,IAAI,EAAEP,WAAW,CAAC;IACnG,MAAMQ,uBAAuBH,cAAcI;IAE3C,qBAAqB;IACrB,MAAMC,yBAAyBjB,uBAAuBW,eAAeI;IACrE,MAAMG,oBAAoBjB,qBAAqBgB;IAE/C,MAAME,WAAW;QACf;QACAhB;QACAG;QACAE;QACAU;QACAT;QACAC;KACD;IAED,yBAAyB;IACzB,IAAIU,aAAa;IACj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,wBAAwB;YACnFyC,QAAQqB,IAAI,CAACL;QACf;IACF;IAEA,OAAOhB;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryDefinition, UnknownSpec, TraceData } from '@perses-dev/spec';
|
|
2
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
1
|
+
import type { QueryDefinition, UnknownSpec, TraceData } from '@perses-dev/spec';
|
|
2
|
+
import type { UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
export type TraceQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TraceQuery', PluginSpec>;
|
|
4
4
|
export declare const TRACE_QUERY_KEY = "TraceQuery";
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/trace-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"trace-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/trace-queries.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAStE,MAAM,MAAM,oBAAoB,CAAC,UAAU,GAAG,WAAW,IAAI,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACvG,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CA+BrG"}
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { useQueries } from
|
|
14
|
-
import { useDatasourceStore } from
|
|
15
|
-
import { usePluginRegistry, usePlugins } from
|
|
16
|
-
import { useTimeRange } from
|
|
17
|
-
import { filterVariableStateMap, getVariableValuesKey } from
|
|
18
|
-
import { useAllVariableValues } from
|
|
13
|
+
import { useQueries } from "@tanstack/react-query";
|
|
14
|
+
import { useDatasourceStore } from "./datasources.js";
|
|
15
|
+
import { usePluginRegistry, usePlugins } from "./plugin-registry.js";
|
|
16
|
+
import { useTimeRange } from "./TimeRangeProvider/index.js";
|
|
17
|
+
import { filterVariableStateMap, getVariableValuesKey } from "./utils.js";
|
|
18
|
+
import { useAllVariableValues } from "./variables.js";
|
|
19
19
|
export const TRACE_QUERY_KEY = 'TraceQuery';
|
|
20
20
|
/**
|
|
21
21
|
* Run a trace query using a TraceQuery plugin and return the results
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/trace-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition, UnknownSpec, TraceData } from '@perses-dev/spec';\nimport { QueryKey,
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/trace-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { QueryDefinition, UnknownSpec, TraceData } from '@perses-dev/spec';\nimport type { QueryKey, UseQueryResult } from '@tanstack/react-query';\nimport { useQueries } from '@tanstack/react-query';\n\nimport type { TraceQueryContext, TraceQueryPlugin } from '../model';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry, usePlugins } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\nimport { useAllVariableValues } from './variables';\nexport type TraceQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TraceQuery', PluginSpec>;\nexport const TRACE_QUERY_KEY = 'TraceQuery';\n\n/**\n * Run a trace query using a TraceQuery plugin and return the results\n * @param definitions: dashboard defintion for a trace query, written in Trace Query Language (TraceQL)\n * Documentation for TraceQL: https://grafana.com/docs/tempo/latest/traceql/\n */\nexport function useTraceQueries(definitions: TraceQueryDefinition[]): Array<UseQueryResult<TraceData>> {\n const { getPlugin } = usePluginRegistry();\n const context = useTraceQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n 'TraceQuery',\n definitions.map((d) => ({ kind: d.spec.plugin.kind })),\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, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ context, definition, plugin });\n const traceQueryKind = definition?.spec?.plugin?.kind;\n return {\n enabled: queryEnabled,\n queryKey: queryKey,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n staleTime: Infinity,\n queryFn: async ({ signal }: { signal?: AbortSignal }): Promise<TraceData> => {\n const plugin = await getPlugin({ kind: TRACE_QUERY_KEY, name: traceQueryKind });\n const data = await plugin.getTraceData(definition.spec.plugin.spec, context, signal);\n return data;\n },\n };\n }),\n });\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TraceQueryPlugin;\n definition: TraceQueryDefinition;\n context: TraceQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { variableState, absoluteTimeRange } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = ['query', TRACE_QUERY_KEY, definition, absoluteTimeRange, variablesValueKey] as const;\n\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n return {\n queryKey,\n queryEnabled,\n };\n}\n\nfunction useTraceQueryContext(): TraceQueryContext {\n const { absoluteTimeRange } = useTimeRange();\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n variableState,\n datasourceStore,\n absoluteTimeRange,\n };\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","usePlugins","useTimeRange","filterVariableStateMap","getVariableValuesKey","useAllVariableValues","TRACE_QUERY_KEY","useTraceQueries","definitions","getPlugin","context","useTraceQueryContext","pluginLoaderResponse","map","d","kind","spec","plugin","queries","definition","idx","data","queryEnabled","queryKey","getQueryOptions","traceQueryKind","enabled","refetchOnMount","refetchOnWindowFocus","refetchOnReconnect","staleTime","Infinity","queryFn","signal","name","getTraceData","variableState","absoluteTimeRange","dependencies","dependsOn","variableDependencies","variables","filteredVariabledState","variablesValueKey","waitToLoad","some","v","loading","undefined","datasourceStore"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;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O,EAKR;IAIC,MAAM,EAAE0B,aAAa,EAAEC,iBAAiB,EAAE,GAAG3B;IAE7C,MAAM4B,eAAerB,QAAQsB,YAAYtB,OAAOsB,SAAS,CAACpB,WAAWH,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN,WAAW,CAAC;IACnG,MAAM8B,uBAAuBF,cAAcG;IAE3C,MAAMC,yBAAyBvC,uBAAuBiC,eAAeI;IACrE,MAAMG,oBAAoBvC,qBAAqBsC;IAC/C,MAAMnB,WAAW;QAAC;QAASjB;QAAiBa;QAAYkB;QAAmBM;KAAkB;IAE7F,IAAIC,aAAa;IACjB,IAAIJ,sBAAsB;QACxBI,aAAaJ,qBAAqBK,IAAI,CAAC,CAACC,IAAMV,aAAa,CAACU,EAAE,EAAEC;IAClE;IAEA,MAAMzB,eAAeL,WAAW+B,aAAa,CAACJ;IAC9C,OAAO;QACLrB;QACAD;IACF;AACF;AAEA,SAASX;IACP,MAAM,EAAE0B,iBAAiB,EAAE,GAAGnC;IAC9B,MAAMkC,gBAAgB/B;IACtB,MAAM4C,kBAAkBlD;IAExB,OAAO;QACLqC;QACAa;QACAZ;IACF;AACF"}
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VariableStateMap } from './variables';
|
|
1
|
+
import type { VariableStateMap } from './variables';
|
|
2
2
|
export declare function filterVariableStateMap(v: VariableStateMap, names?: string[]): VariableStateMap;
|
|
3
3
|
/**
|
|
4
4
|
* Returns a serialized string of the current state of variable values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/runtime/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/runtime/utils.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAK9F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAIhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/utils.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariableStateMap } from './variables';\n\nexport function filterVariableStateMap(v: VariableStateMap, names?: string[]): VariableStateMap {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\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"],"names":["filterVariableStateMap","v","names","Object","fromEntries","entries","filter","name","includes","getVariableValuesKey","values","map","JSON","stringify","value","join"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,uBAAuBC,CAAmB,EAAEC,KAAgB;IAC1E,IAAI,CAACA,OAAO;QACV,OAAOD;IACT;IACA,OAAOE,OAAOC,WAAW,CAACD,OAAOE,OAAO,CAACJ,GAAGK,MAAM,CAAC,CAAC,CAACC,KAAK,GAAKL,MAAMM,QAAQ,CAACD;AAChF;AAEA;;CAEC,GACD,OAAO,SAASE,qBAAqBR,CAAmB;IACtD,OAAOE,OAAOO,MAAM,CAACT,GAClBU,GAAG,CAAC,CAACV,IAAMW,KAAKC,SAAS,CAACZ,EAAEa,KAAK,GACjCC,IAAI,CAAC;AACV"}
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/utils.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { VariableStateMap } from './variables';\n\nexport function filterVariableStateMap(v: VariableStateMap, names?: string[]): VariableStateMap {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\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"],"names":["filterVariableStateMap","v","names","Object","fromEntries","entries","filter","name","includes","getVariableValuesKey","values","map","JSON","stringify","value","join"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,uBAAuBC,CAAmB,EAAEC,KAAgB;IAC1E,IAAI,CAACA,OAAO;QACV,OAAOD;IACT;IACA,OAAOE,OAAOC,WAAW,CAACD,OAAOE,OAAO,CAACJ,GAAGK,MAAM,CAAC,CAAC,CAACC,KAAK,GAAKL,MAAMM,QAAQ,CAACD;AAChF;AAEA;;CAEC,GACD,OAAO,SAASE,qBAAqBR,CAAmB;IACtD,OAAOE,OAAOO,MAAM,CAACT,GAClBU,GAAG,CAAC,CAACV,IAAMW,KAAKC,SAAS,CAACZ,EAAEa,KAAK,GACjCC,IAAI,CAAC;AACV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VariableOption, VariableState, VariableStateMap } from '@perses-dev/components';
|
|
1
|
+
import type { VariableOption, VariableState, VariableStateMap } from '@perses-dev/components';
|
|
2
2
|
import { immerable } from 'immer';
|
|
3
3
|
export type { VariableOption, VariableState, VariableStateMap };
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/runtime/variables.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/runtime/variables.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE9F,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMlC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;;OAGG;IACH,CAAC,SAAS,CAAC,UAAQ;IAEnB,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAM;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqD;IAE5E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,GAAG,SAAS;IAIrD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS;IAS3E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO;IAInC;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO;IAiBtC,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,oBAAoB;CAG7B;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,eAAe,kDAAoD,CAAC;AAUjF,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAmBpE;AAGD,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAOvE;AAGD,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,gBAAgB,EAChC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,MAAM,CAMR;AAGD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKvF"}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { parseVariables, replaceVariables } from
|
|
14
|
-
import { immerable } from
|
|
15
|
-
import { createContext, useContext, useMemo } from
|
|
16
|
-
import { useBuiltinVariableValues } from
|
|
13
|
+
import { parseVariables, replaceVariables } from "@perses-dev/components";
|
|
14
|
+
import { immerable } from "immer";
|
|
15
|
+
import { createContext, useContext, useMemo } from "react";
|
|
16
|
+
import { useBuiltinVariableValues } from "./builtin-variables.js";
|
|
17
17
|
/**
|
|
18
18
|
* A state map with two entry keys, materialized by {@link VariableStateKey} structure.
|
|
19
19
|
*/ export class VariableStoreStateMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/variables.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/variables.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { VariableOption, VariableState, VariableStateMap } from '@perses-dev/components';\nimport { parseVariables, replaceVariables } from '@perses-dev/components';\nimport { immerable } from 'immer';\nimport { createContext, useContext, useMemo } from 'react';\n\nimport { useBuiltinVariableValues } from './builtin-variables';\n\n// Re-export types from @perses-dev/components for backwards compatibility\nexport type { VariableOption, VariableState, VariableStateMap };\n\n/**\n * Structure used as key in the {@link VariableStoreStateMap}.\n */\nexport type VariableStateKey = {\n /**\n * name of the variable we want to access in the state.\n */\n name: string;\n /**\n * source of the variable we want to access in the state.\n * Defined only for external variables.\n */\n source?: string;\n};\n\n/**\n * A state map with two entry keys, materialized by {@link VariableStateKey} structure.\n */\nexport class VariableStoreStateMap {\n /**\n * \"Immerable\" is mandatory to be able to use this class in an immer context.\n * Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas\n */\n [immerable] = true;\n\n private readonly DEFAULT_LOCAL_SOURCE_NAME = '';\n private readonly _state: Record<string, Record<string, VariableState>> = {};\n\n /**\n * Get variable state by key.\n * @param key\n */\n get(key: VariableStateKey): VariableState | undefined {\n return this._sourceStatesOrEmpty(key.source)[key.name];\n }\n\n /**\n * Set variable state by key.\n * @param key\n * @param value\n */\n set(key: VariableStateKey, value: VariableState): VariableState | undefined {\n const sourceName = this._sourceName(key.source);\n if (!this._state[sourceName]) {\n this._state[sourceName] = {};\n }\n this._sourceStatesOrEmpty(key.source)[key.name] = value;\n return value;\n }\n\n /**\n * Check presence of variable state by key.\n * @param key\n */\n has(key: VariableStateKey): boolean {\n return this._sourceStatesOrEmpty(key.source)[key.name] !== undefined;\n }\n\n /**\n * Delete variable state by key.\n * @param key\n */\n delete(key: VariableStateKey): boolean {\n const result = this.has(key);\n const sourceName = this._sourceName(key.source);\n const sourceStates = this._state[sourceName];\n\n // Delete var from source state\n if (sourceStates) {\n delete sourceStates[key.name];\n }\n\n // Delete source state from state if empty\n if (Object.keys(sourceStates ?? {})?.length === 0) {\n delete this._state[sourceName];\n }\n return result;\n }\n\n private _sourceName(source: string | undefined): string {\n return source ?? this.DEFAULT_LOCAL_SOURCE_NAME;\n }\n\n private _sourceStatesOrEmpty(source: string | undefined): Record<string, VariableState> {\n return this._state[this._sourceName(source)] ?? {};\n }\n}\n\nexport type VariableSrv = {\n state: VariableStateMap;\n};\n\nexport const VariableContext = createContext<VariableSrv | undefined>(undefined);\n\nfunction useVariableContext(): VariableSrv {\n const ctx = useContext(VariableContext);\n if (ctx === undefined) {\n throw new Error('No VariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useVariableValues(names?: string[]): VariableStateMap {\n const { state } = useVariableContext();\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = state[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [state, names]);\n\n if (names === undefined) {\n return state;\n }\n\n return values;\n}\n\n// useAllVariableValues wraps user-defined variables with built-in variables\nexport function useAllVariableValues(names?: string[]): VariableStateMap {\n const variableValues = useVariableValues(names);\n const builtinVariableValues = useBuiltinVariableValues(names);\n\n return useMemo(() => {\n return { ...variableValues, ...builtinVariableValues } as VariableStateMap;\n }, [variableValues, builtinVariableValues]);\n}\n\n// Simple wrapper around replaceVariables() with support for extra string variables.\nexport function replaceVariablesInString(\n text: string,\n variableValues: VariableStateMap,\n extraVariables?: Record<string, string>,\n): string {\n const vars = { ...variableValues }; // shallow clone to avoid modifying the original object\n for (const [key, value] of Object.entries(extraVariables ?? {})) {\n vars[key] = { value, loading: false };\n }\n return replaceVariables(text, vars);\n}\n\n// Convenience hook for replacing variables in a string\nexport function useReplaceVariablesInString(str: string | undefined): string | undefined {\n const variablesInString = str ? parseVariables(str) : [];\n const variableValues = useAllVariableValues(variablesInString);\n if (!str) return undefined;\n return replaceVariables(str, variableValues);\n}\n"],"names":["parseVariables","replaceVariables","immerable","createContext","useContext","useMemo","useBuiltinVariableValues","VariableStoreStateMap","DEFAULT_LOCAL_SOURCE_NAME","_state","get","key","_sourceStatesOrEmpty","source","name","set","value","sourceName","_sourceName","has","undefined","delete","result","sourceStates","Object","keys","length","VariableContext","useVariableContext","ctx","Error","useVariableValues","names","state","values","forEach","s","useAllVariableValues","variableValues","builtinVariableValues","replaceVariablesInString","text","extraVariables","vars","entries","loading","useReplaceVariablesInString","str","variablesInString"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,cAAc,EAAEC,gBAAgB,QAAQ,yBAAyB;AAC1E,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ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IACA,OAAO5C,iBAAiBwC,MAAME;AAChC;AAEA,uDAAuD;AACvD,OAAO,SAASG,4BAA4BC,GAAuB;IACjE,MAAMC,oBAAoBD,MAAM/C,eAAe+C,OAAO,EAAE;IACxD,MAAMT,iBAAiBD,qBAAqBW;IAC5C,IAAI,CAACD,KAAK,OAAO3B;IACjB,OAAOnB,iBAAiB8C,KAAKT;AAC/B"}
|
package/dist/schema/index.js
CHANGED
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
export * from
|
|
13
|
+
export * from "./panel.js";
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
package/dist/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './panel';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './panel';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAU"}
|
package/dist/schema/panel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PluginSchema } from '@perses-dev/spec';
|
|
1
|
+
import type { PluginSchema } from '@perses-dev/spec';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { PanelEditorValues } from '../model';
|
|
3
|
+
import type { PanelEditorValues } from '../model';
|
|
4
4
|
export declare const panelEditorSchema: z.ZodSchema<PanelEditorValues>;
|
|
5
5
|
export declare function buildPanelEditorSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelEditorValues>;
|
|
6
6
|
//# sourceMappingURL=panel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/schema/panel.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/schema/panel.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAgBlD,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAI3D,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAMjG"}
|
package/dist/schema/panel.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { panelDefinitionSchema, buildPanelDefinitionSchema } from
|
|
14
|
-
import { z } from
|
|
13
|
+
import { panelDefinitionSchema, buildPanelDefinitionSchema } from "@perses-dev/spec";
|
|
14
|
+
import { z } from "zod";
|
|
15
15
|
const layoutDefinitionSchema = z.object({
|
|
16
16
|
width: z.number(),
|
|
17
17
|
height: z.number(),
|
package/dist/schema/panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/panel.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginSchema
|
|
1
|
+
{"version":3,"sources":["../../src/schema/panel.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { PluginSchema } from '@perses-dev/spec';\nimport { panelDefinitionSchema, buildPanelDefinitionSchema } from '@perses-dev/spec';\nimport { z } from 'zod';\n\nimport type { PanelEditorValues } from '../model';\n\nconst layoutDefinitionSchema = z\n .object({\n width: z.number(),\n height: z.number(),\n repeatVariable: z\n .object({\n value: z.string(),\n maxPer: z.number().min(1).max(12).optional(),\n alignment: z.enum(['horizontal', 'vertical']).optional(),\n })\n .optional(),\n })\n .optional();\n\nexport const panelEditorSchema: z.ZodSchema<PanelEditorValues> = z.object({\n groupId: z.number(),\n panelDefinition: panelDefinitionSchema,\n layoutDefinition: layoutDefinitionSchema,\n});\n\nexport function buildPanelEditorSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelEditorValues> {\n return z.object({\n groupId: z.number(),\n panelDefinition: buildPanelDefinitionSchema(pluginSchema),\n layoutDefinition: layoutDefinitionSchema,\n });\n}\n"],"names":["panelDefinitionSchema","buildPanelDefinitionSchema","z","layoutDefinitionSchema","object","width","number","height","repeatVariable","value","string","maxPer","min","max","optional","alignment","enum","panelEditorSchema","groupId","panelDefinition","layoutDefinition","buildPanelEditorSchema","pluginSchema"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,qBAAqB,EAAEC,0BAA0B,QAAQ,mBAAmB;AACrF,SAASC,CAAC,QAAQ,MAAM;AAIxB,MAAMC,yBAAyBD,EAC5BE,MAAM,CAAC;IACNC,OAAOH,EAAEI,MAAM;IACfC,QAAQL,EAAEI,MAAM;IAChBE,gBAAgBN,EACbE,MAAM,CAAC;QACNK,OAAOP,EAAEQ,MAAM;QACfC,QAAQT,EAAEI,MAAM,GAAGM,GAAG,CAAC,GAAGC,GAAG,CAAC,IAAIC,QAAQ;QAC1CC,WAAWb,EAAEc,IAAI,CAAC;YAAC;YAAc;SAAW,EAAEF,QAAQ;IACxD,GACCA,QAAQ;AACb,GACCA,QAAQ;AAEX,OAAO,MAAMG,oBAAoDf,EAAEE,MAAM,CAAC;IACxEc,SAAShB,EAAEI,MAAM;IACjBa,iBAAiBnB;IACjBoB,kBAAkBjB;AACpB,GAAG;AAEH,OAAO,SAASkB,uBAAuBC,YAA0B;IAC/D,OAAOpB,EAAEE,MAAM,CAAC;QACdc,SAAShB,EAAEI,MAAM;QACjBa,iBAAiBlB,2BAA2BqB;QAC5CF,kBAAkBjB;IACpB;AACF"}
|
package/dist/test/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
13
|
+
export * from "./render.js";
|
|
14
|
+
export * from "./mock-data.js";
|
|
15
15
|
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './render';\nexport * from './mock-data';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/test/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './render';\nexport * from './mock-data';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAW;AACzB,cAAc,iBAAc"}
|
package/dist/test/mock-data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlertsData, JsonData, LogData, ProfileData, SilencesData, TimeSeriesData, TraceData } from '@perses-dev/spec';
|
|
1
|
+
import type { AlertsData, JsonData, LogData, ProfileData, SilencesData, TimeSeriesData, TraceData } from '@perses-dev/spec';
|
|
2
2
|
export declare const MOCK_TIME_SERIES_DATA: TimeSeriesData;
|
|
3
3
|
export declare const MOCK_TRACE_DATA: TraceData;
|
|
4
4
|
export declare const MOCK_LOG_DATA: LogData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["../../src/test/mock-data.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["../../src/test/mock-data.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,EACZ,cAAc,EACd,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,qBAAqB,EAAE,cAsBnC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAmC7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAoB3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAmB/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,UAqB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAoBhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAK5B,CAAC;AAGF,eAAO,MAAM,0BAA0B;;;;;;;;;CAStC,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;CAS7C,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;CAatC,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;IAuB9C,CAAC;AAEF,eAAO,MAAM,yBAAyB;;yBAEnB,IAAI;oCACO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAEpD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;CAwBpC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;CAwBvC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;CASpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/mock-data.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AlertsData, JsonData, LogData, ProfileData, SilencesData, TimeSeriesData, TraceData } from '@perses-dev/spec';\n\nexport const MOCK_TIME_SERIES_DATA: TimeSeriesData = {\n timeRange: {\n start: new Date(1666625490000),\n end: new Date(1666625535000),\n },\n stepMs: 24379,\n series: [\n {\n name: 'device=\"/dev/vda1\", env=\"demo\", fstype=\"ext4\", instance=\"demo.do.prometheus.io:9100\", job=\"node\", mountpoint=\"/\"',\n values: [\n [1666479357903, 0.27700745551584494],\n [1666479382282, 0.27701284657366565],\n ],\n },\n {\n name: 'device=\"/dev/vda15\", env=\"demo\", fstype=\"vfat\", instance=\"demo.do.prometheus.io:9100\", job=\"node\", mountpoint=\"/boot/efi\"',\n values: [\n [1666479357903, 0.08486496097624885],\n [1666479382282, 0.08486496097624885],\n ],\n },\n ],\n};\n\nexport const MOCK_TRACE_DATA: TraceData = {\n searchResult: [\n {\n durationMs: 1120,\n serviceStats: {\n 'shop-backend': {\n spanCount: 4,\n errorCount: 0,\n },\n 'cart-service': {\n spanCount: 2,\n errorCount: 0,\n },\n 'article-service': {\n spanCount: 2,\n errorCount: 0,\n },\n 'auth-service': {\n spanCount: 1,\n errorCount: 0,\n },\n postgres: {\n spanCount: 1,\n errorCount: 0,\n },\n },\n startTimeUnixMs: 1699916103945861,\n traceId: '95ba9202315c29c801b5aa41452aa775',\n rootServiceName: 'shop-backend',\n rootTraceName: 'article-to-cart',\n },\n ],\n metadata: {\n executedQueryString: '{ duration > 1000ms }',\n },\n};\n\nexport const MOCK_LOG_DATA: LogData = {\n totalCount: 2,\n entries: [\n {\n timestamp: 1666479357903,\n line: 'Error: Something went wrong',\n labels: {\n level: 'error',\n service: 'backend',\n },\n },\n {\n timestamp: 1666479382282,\n line: 'Info: Request processed successfully',\n labels: {\n level: 'info',\n service: 'frontend',\n },\n },\n ],\n};\n\nexport const MOCK_PROFILE_DATA: ProfileData = {\n profile: {\n stackTrace: {\n id: 0,\n name: 'root',\n level: 0,\n start: 1699916103945861,\n end: 1699916105065861,\n total: 1000,\n self: 500,\n children: [],\n },\n },\n metadata: {\n spyName: '',\n sampleRate: 1000000000,\n units: 'samples',\n name: 'cpu',\n },\n};\n\nexport const MOCK_ALERTS_DATA: AlertsData = {\n alerts: [\n {\n id: 'abc123',\n name: 'HighErrorRate',\n state: 'firing',\n labels: {\n alertname: 'HighErrorRate',\n severity: 'critical',\n service: 'backend',\n },\n annotations: {\n summary: 'High error rate detected',\n },\n severity: 'critical',\n startsAt: '2024-01-01T00:00:00Z',\n endsAt: '2024-01-02T00:00:00Z',\n updatedAt: '2024-01-01T12:00:00Z',\n receivers: ['cluster-01'],\n },\n ],\n};\n\nexport const MOCK_SILENCES_DATA: SilencesData = {\n silences: [\n {\n id: 'silence-1',\n state: 'active',\n matchers: [\n {\n name: 'alertname',\n value: 'HighErrorRate',\n isRegex: false,\n isEqual: true,\n },\n ],\n startsAt: '2024-01-01T00:00:00Z',\n endsAt: '2024-01-02T00:00:00Z',\n createdBy: 'admin',\n comment: 'Maintenance window',\n updatedAt: '2024-01-01T00:00:00Z',\n },\n ],\n};\n\nexport const MOCK_JSON_DATA: JsonData = {\n data: {\n status: 'ok',\n value: 42,\n },\n};\n\n// Remote Plugin Loader Test Fixtures\nexport const MOCK_VALID_PLUGIN_METADATA = {\n kind: 'Panel' as const,\n spec: {\n name: 'testPlugin',\n display: {\n name: 'Test Plugin',\n description: 'A test plugin for unit testing',\n },\n },\n};\n\nexport const MOCK_VALID_PLUGIN_MODULE_RESOURCE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'test-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [MOCK_VALID_PLUGIN_METADATA],\n },\n};\n\nexport const MOCK_INVALID_PLUGIN_MODULE = {\n // Missing required fields\n metadata: {\n name: 'invalid-module',\n },\n spec: {\n plugins: [\n {\n // Missing required fields\n kind: 'Panel',\n },\n ],\n },\n};\n\nexport const MOCK_MIXED_VALIDITY_PLUGIN_MODULES = [\n MOCK_VALID_PLUGIN_MODULE_RESOURCE,\n MOCK_INVALID_PLUGIN_MODULE,\n {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'another-valid-module',\n version: '2.0.0',\n },\n spec: {\n plugins: [\n {\n kind: 'Variable' as const,\n spec: {\n name: 'anotherPlugin',\n display: {\n name: 'Another Plugin',\n },\n },\n },\n ],\n },\n },\n];\n\nexport const MOCK_REMOTE_PLUGIN_MODULE = {\n testPlugin: {\n component: (): null => null,\n createDefaultOptions: (): Record<string, unknown> => ({}),\n },\n};\n\nexport const MOCK_MULTI_PLUGIN_MODULE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'multi-plugin-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [\n {\n kind: 'Panel' as const,\n spec: {\n name: 'plugin1',\n display: { name: 'Plugin 1' },\n },\n },\n {\n kind: 'Variable' as const,\n spec: {\n name: 'plugin2',\n display: { name: 'Plugin 2' },\n },\n },\n ],\n },\n};\n\nexport const MOCK_PARTIAL_FAILURE_MODULE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'partial-failure-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [\n {\n kind: 'Panel' as const,\n spec: {\n name: 'workingPlugin',\n display: { name: 'Working Plugin' },\n },\n },\n {\n kind: 'Variable' as const,\n spec: {\n name: 'failingPlugin',\n display: { name: 'Failing Plugin' },\n },\n },\n ],\n },\n};\n\nexport const MOCK_EMPTY_PLUGIN_MODULE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'empty-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [],\n },\n};\n"],"names":["MOCK_TIME_SERIES_DATA","timeRange","start","Date","end","stepMs","series","name","values","MOCK_TRACE_DATA","searchResult","durationMs","serviceStats","spanCount","errorCount","postgres","startTimeUnixMs","traceId","rootServiceName","rootTraceName","metadata","executedQueryString","MOCK_LOG_DATA","totalCount","entries","timestamp","line","labels","level","service","MOCK_PROFILE_DATA","profile","stackTrace","id","total","self","children","spyName","sampleRate","units","MOCK_ALERTS_DATA","alerts","state","alertname","severity","annotations","summary","startsAt","endsAt","updatedAt","receivers","MOCK_SILENCES_DATA","silences","matchers","value","isRegex","isEqual","createdBy","comment","MOCK_JSON_DATA","data","status","MOCK_VALID_PLUGIN_METADATA","kind","spec","display","description","MOCK_VALID_PLUGIN_MODULE_RESOURCE","version","plugins","MOCK_INVALID_PLUGIN_MODULE","MOCK_MIXED_VALIDITY_PLUGIN_MODULES","MOCK_REMOTE_PLUGIN_MODULE","testPlugin","component","createDefaultOptions","MOCK_MULTI_PLUGIN_MODULE","MOCK_PARTIAL_FAILURE_MODULE","MOCK_EMPTY_PLUGIN_MODULE"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,wBAAwC;IACnDC,WAAW;QACTC,OAAO,IAAIC,KAAK;QAChBC,KAAK,IAAID,KAAK;IAChB;IACAE,QAAQ;IACRC,QAAQ;QACN;YACEC,MAAM;YACNC,QAAQ;gBACN;oBAAC;oBAAe;iBAAoB;gBACpC;oBAAC;oBAAe;iBAAoB;aACrC;QACH;QACA;YACED,MAAM;YACNC,QAAQ;gBACN;oBAAC;oBAAe;iBAAoB;gBACpC;oBAAC;oBAAe;iBAAoB;aACrC;QACH;KACD;AACH,EAAE;AAEF,OAAO,MAAMC,kBAA6B;IACxCC,cAAc;QACZ;YACEC,YAAY;YACZC,cAAc;gBACZ,gBAAgB;oBACdC,WAAW;oBACXC,YAAY;gBACd;gBACA,gBAAgB;oBACdD,WAAW;oBACXC,YAAY;gBACd;gBACA,mBAAmB;oBACjBD,WAAW;oBACXC,YAAY;gBACd;gBACA,gBAAgB;oBACdD,WAAW;oBACXC,YAAY;gBACd;gBACAC,UAAU;oBACRF,WAAW;oBACXC,YAAY;gBACd;YACF;YACAE,iBAAiB;YACjBC,SAAS;YACTC,iBAAiB;YACjBC,eAAe;QACjB;KACD;IACDC,UAAU;Q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gBACNC,MAAM;oBACJzD,MAAM;oBACN0D,SAAS;wBAAE1D,MAAM;oBAAiB;gBACpC;YACF;SACD;IACH;AACF,EAAE;AAEF,OAAO,MAAMuE,2BAA2B;IACtCf,MAAM;IACN3C,UAAU;QACRb,MAAM;QACN6D,SAAS;IACX;IACAJ,MAAM;QACJK,SAAS,EAAE;IACb;AACF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/test/mock-data.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {\n AlertsData,\n JsonData,\n LogData,\n ProfileData,\n SilencesData,\n TimeSeriesData,\n TraceData,\n} from '@perses-dev/spec';\n\nexport const MOCK_TIME_SERIES_DATA: TimeSeriesData = {\n timeRange: {\n start: new Date(1666625490000),\n end: new Date(1666625535000),\n },\n stepMs: 24379,\n series: [\n {\n name: 'device=\"/dev/vda1\", env=\"demo\", fstype=\"ext4\", instance=\"demo.do.prometheus.io:9100\", job=\"node\", mountpoint=\"/\"',\n values: [\n [1666479357903, 0.27700745551584494],\n [1666479382282, 0.27701284657366565],\n ],\n },\n {\n name: 'device=\"/dev/vda15\", env=\"demo\", fstype=\"vfat\", instance=\"demo.do.prometheus.io:9100\", job=\"node\", mountpoint=\"/boot/efi\"',\n values: [\n [1666479357903, 0.08486496097624885],\n [1666479382282, 0.08486496097624885],\n ],\n },\n ],\n};\n\nexport const MOCK_TRACE_DATA: TraceData = {\n searchResult: [\n {\n durationMs: 1120,\n serviceStats: {\n 'shop-backend': {\n spanCount: 4,\n errorCount: 0,\n },\n 'cart-service': {\n spanCount: 2,\n errorCount: 0,\n },\n 'article-service': {\n spanCount: 2,\n errorCount: 0,\n },\n 'auth-service': {\n spanCount: 1,\n errorCount: 0,\n },\n postgres: {\n spanCount: 1,\n errorCount: 0,\n },\n },\n startTimeUnixMs: 1699916103945861,\n traceId: '95ba9202315c29c801b5aa41452aa775',\n rootServiceName: 'shop-backend',\n rootTraceName: 'article-to-cart',\n },\n ],\n metadata: {\n executedQueryString: '{ duration > 1000ms }',\n },\n};\n\nexport const MOCK_LOG_DATA: LogData = {\n totalCount: 2,\n entries: [\n {\n timestamp: 1666479357903,\n line: 'Error: Something went wrong',\n labels: {\n level: 'error',\n service: 'backend',\n },\n },\n {\n timestamp: 1666479382282,\n line: 'Info: Request processed successfully',\n labels: {\n level: 'info',\n service: 'frontend',\n },\n },\n ],\n};\n\nexport const MOCK_PROFILE_DATA: ProfileData = {\n profile: {\n stackTrace: {\n id: 0,\n name: 'root',\n level: 0,\n start: 1699916103945861,\n end: 1699916105065861,\n total: 1000,\n self: 500,\n children: [],\n },\n },\n metadata: {\n spyName: '',\n sampleRate: 1000000000,\n units: 'samples',\n name: 'cpu',\n },\n};\n\nexport const MOCK_ALERTS_DATA: AlertsData = {\n alerts: [\n {\n id: 'abc123',\n name: 'HighErrorRate',\n state: 'firing',\n labels: {\n alertname: 'HighErrorRate',\n severity: 'critical',\n service: 'backend',\n },\n annotations: {\n summary: 'High error rate detected',\n },\n severity: 'critical',\n startsAt: '2024-01-01T00:00:00Z',\n endsAt: '2024-01-02T00:00:00Z',\n updatedAt: '2024-01-01T12:00:00Z',\n receivers: ['cluster-01'],\n },\n ],\n};\n\nexport const MOCK_SILENCES_DATA: SilencesData = {\n silences: [\n {\n id: 'silence-1',\n state: 'active',\n matchers: [\n {\n name: 'alertname',\n value: 'HighErrorRate',\n isRegex: false,\n isEqual: true,\n },\n ],\n startsAt: '2024-01-01T00:00:00Z',\n endsAt: '2024-01-02T00:00:00Z',\n createdBy: 'admin',\n comment: 'Maintenance window',\n updatedAt: '2024-01-01T00:00:00Z',\n },\n ],\n};\n\nexport const MOCK_JSON_DATA: JsonData = {\n data: {\n status: 'ok',\n value: 42,\n },\n};\n\n// Remote Plugin Loader Test Fixtures\nexport const MOCK_VALID_PLUGIN_METADATA = {\n kind: 'Panel' as const,\n spec: {\n name: 'testPlugin',\n display: {\n name: 'Test Plugin',\n description: 'A test plugin for unit testing',\n },\n },\n};\n\nexport const MOCK_VALID_PLUGIN_MODULE_RESOURCE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'test-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [MOCK_VALID_PLUGIN_METADATA],\n },\n};\n\nexport const MOCK_INVALID_PLUGIN_MODULE = {\n // Missing required fields\n metadata: {\n name: 'invalid-module',\n },\n spec: {\n plugins: [\n {\n // Missing required fields\n kind: 'Panel',\n },\n ],\n },\n};\n\nexport const MOCK_MIXED_VALIDITY_PLUGIN_MODULES = [\n MOCK_VALID_PLUGIN_MODULE_RESOURCE,\n MOCK_INVALID_PLUGIN_MODULE,\n {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'another-valid-module',\n version: '2.0.0',\n },\n spec: {\n plugins: [\n {\n kind: 'Variable' as const,\n spec: {\n name: 'anotherPlugin',\n display: {\n name: 'Another Plugin',\n },\n },\n },\n ],\n },\n },\n];\n\nexport const MOCK_REMOTE_PLUGIN_MODULE = {\n testPlugin: {\n component: (): null => null,\n createDefaultOptions: (): Record<string, unknown> => ({}),\n },\n};\n\nexport const MOCK_MULTI_PLUGIN_MODULE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'multi-plugin-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [\n {\n kind: 'Panel' as const,\n spec: {\n name: 'plugin1',\n display: { name: 'Plugin 1' },\n },\n },\n {\n kind: 'Variable' as const,\n spec: {\n name: 'plugin2',\n display: { name: 'Plugin 2' },\n },\n },\n ],\n },\n};\n\nexport const MOCK_PARTIAL_FAILURE_MODULE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'partial-failure-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [\n {\n kind: 'Panel' as const,\n spec: {\n name: 'workingPlugin',\n display: { name: 'Working Plugin' },\n },\n },\n {\n kind: 'Variable' as const,\n spec: {\n name: 'failingPlugin',\n display: { name: 'Failing Plugin' },\n },\n },\n ],\n },\n};\n\nexport const MOCK_EMPTY_PLUGIN_MODULE = {\n kind: 'PluginModule' as const,\n metadata: {\n name: 'empty-module',\n version: '1.0.0',\n },\n spec: {\n plugins: [],\n },\n};\n"],"names":["MOCK_TIME_SERIES_DATA","timeRange","start","Date","end","stepMs","series","name","values","MOCK_TRACE_DATA","searchResult","durationMs","serviceStats","spanCount","errorCount","postgres","startTimeUnixMs","traceId","rootServiceName","rootTraceName","metadata","executedQueryString","MOCK_LOG_DATA","totalCount","entries","timestamp","line","labels","level","service","MOCK_PROFILE_DATA","profile","stackTrace","id","total","self","children","spyName","sampleRate","units","MOCK_ALERTS_DATA","alerts","state","alertname","severity","annotations","summary","startsAt","endsAt","updatedAt","receivers","MOCK_SILENCES_DATA","silences","matchers","value","isRegex","isEqual","createdBy","comment","MOCK_JSON_DATA","data","status","MOCK_VALID_PLUGIN_METADATA","kind","spec","display","description","MOCK_VALID_PLUGIN_MODULE_RESOURCE","version","plugins","MOCK_INVALID_PLUGIN_MODULE","MOCK_MIXED_VALIDITY_PLUGIN_MODULES","MOCK_REMOTE_PLUGIN_MODULE","testPlugin","component","createDefaultOptions","MOCK_MULTI_PLUGIN_MODULE","MOCK_PARTIAL_FAILURE_MODULE","MOCK_EMPTY_PLUGIN_MODULE"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAYjC,OAAO,MAAMA,wBAAwC;IACnDC,WAAW;QACTC,OAAO,IAAIC,KAAK;QAChBC,KAAK,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E,4BAA4B;IACvCC,YAAY;QACVC,WAAW,IAAY;QACvBC,sBAAsB,IAAgC,CAAA,CAAC,CAAA;IACzD;AACF,EAAE;AAEF,OAAO,MAAMC,2BAA2B;IACtCb,MAAM;IACN3C,UAAU;QACRb,MAAM;QACN6D,SAAS;IACX;IACAJ,MAAM;QACJK,SAAS;YACP;gBACEN,MAAM;gBACNC,MAAM;oBACJzD,MAAM;oBACN0D,SAAS;wBAAE1D,MAAM;oBAAW;gBAC9B;YACF;YACA;gBACEwD,MAAM;gBACNC,MAAM;oBACJzD,MAAM;oBACN0D,SAAS;wBAAE1D,MAAM;oBAAW;gBAC9B;YACF;SACD;IACH;AACF,EAAE;AAEF,OAAO,MAAMsE,8BAA8B;IACzCd,MAAM;IACN3C,UAAU;QACRb,MAAM;QACN6D,SAAS;IACX;IACAJ,MAAM;QACJK,SAAS;YACP;gBACEN,MAAM;gBACNC,MAAM;oBACJzD,MAAM;oBACN0D,SAAS;wBAAE1D,MAAM;oBAAiB;gBACpC;YACF;YACA;gBACEwD,MAAM;gBACNC,MAAM;oBACJzD,MAAM;oBACN0D,SAAS;wBAAE1D,MAAM;oBAAiB;gBACpC;YACF;SACD;IACH;AACF,EAAE;AAEF,OAAO,MAAMuE,2BAA2B;IACtCf,MAAM;IACN3C,UAAU;QACRb,MAAM;QACN6D,SAAS;IACX;IACAJ,MAAM;QACJK,SAAS,EAAE;IACb;AACF,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RenderHookOptions, RenderHookResult } from '@testing-library/react';
|
|
2
|
-
import { ContextOptions } from './utils';
|
|
1
|
+
import type { RenderHookOptions, RenderHookResult } from '@testing-library/react';
|
|
2
|
+
import type { ContextOptions } from './utils';
|
|
3
3
|
/**
|
|
4
4
|
* Test helper to render a React hook with common app-level providers, including the PluginRegistry,
|
|
5
5
|
* wrapped around it. Useful for testing hooks that rely on context such as QueryClientProvider or PluginRegistry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-hook.d.ts","sourceRoot":"","sources":["../../src/test/render-hook.tsx"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"render-hook.d.ts","sourceRoot":"","sources":["../../src/test/render-hook.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGlF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,EACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EACpC,cAAc,CAAC,EAAE,cAAc,EAC/B,iBAAiB,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,GAC7D,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAGnC"}
|
package/dist/test/render-hook.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { renderHook } from
|
|
14
|
-
import { getTestContextWrapper } from
|
|
13
|
+
import { renderHook } from "@testing-library/react";
|
|
14
|
+
import { getTestContextWrapper } from "./utils.js";
|
|
15
15
|
/**
|
|
16
16
|
* Test helper to render a React hook with common app-level providers, including the PluginRegistry,
|
|
17
17
|
* wrapped around it. Useful for testing hooks that rely on context such as QueryClientProvider or PluginRegistry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/render-hook.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/test/render-hook.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { RenderHookOptions, RenderHookResult } from '@testing-library/react';\nimport { renderHook } from '@testing-library/react';\n\nimport type { ContextOptions } from './utils';\nimport { getTestContextWrapper } from './utils';\n\n/**\n * Test helper to render a React hook with common app-level providers, including the PluginRegistry,\n * wrapped around it. Useful for testing hooks that rely on context such as QueryClientProvider or PluginRegistry.\n */\nexport function renderHookWithContext<TProps, TResult>(\n callback: (props: TProps) => TResult,\n contextOptions?: ContextOptions,\n renderHookOptions?: Omit<RenderHookOptions<TProps>, 'wrapper'>,\n): RenderHookResult<TResult, TProps> {\n const wrapper = getTestContextWrapper(contextOptions);\n return renderHook(callback, { wrapper, ...renderHookOptions });\n}\n"],"names":["renderHook","getTestContextWrapper","renderHookWithContext","callback","contextOptions","renderHookOptions","wrapper"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAQ,yBAAyB;AAGpD,SAASC,qBAAqB,QAAQ,aAAU;AAEhD;;;CAGC,GACD,OAAO,SAASC,sBACdC,QAAoC,EACpCC,cAA+B,EAC/BC,iBAA8D;IAE9D,MAAMC,UAAUL,sBAAsBG;IACtC,OAAOJ,WAAWG,UAAU;QAAEG;QAAS,GAAGD,iBAAiB;IAAC;AAC9D"}
|
package/dist/test/render.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RenderOptions, RenderResult } from '@testing-library/react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { ContextOptions } from './utils';
|
|
1
|
+
import type { RenderOptions, RenderResult } from '@testing-library/react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { ContextOptions } from './utils';
|
|
4
4
|
/**
|
|
5
5
|
* Test helper to render a React component with some common app-level providers, as well as the PluginRegistry
|
|
6
6
|
* wrapped around it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,SAAS,EACb,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAC9C,cAAc,CAAC,EAAE,cAAc,GAC9B,YAAY,CAGd"}
|