@perses-dev/plugin-system 0.0.0-snapshot-time-range-height-80d08fc
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/LICENSE +201 -0
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +52 -0
- package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +65 -0
- package/dist/cjs/components/CalculationSelector/index.js +28 -0
- package/dist/cjs/components/DatasourceSelect.js +76 -0
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +102 -0
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +167 -0
- package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +37 -0
- package/dist/cjs/components/OptionsEditorTabs/index.js +28 -0
- package/dist/cjs/components/PluginEditor/PluginEditor.js +67 -0
- package/dist/cjs/components/PluginEditor/PluginEditor.test.js +150 -0
- package/dist/cjs/components/PluginEditor/index.js +29 -0
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +101 -0
- package/dist/cjs/components/PluginKindSelect.js +41 -0
- package/dist/cjs/components/PluginKindSelect.test.js +86 -0
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +85 -0
- package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +144 -0
- package/dist/cjs/components/PluginRegistry/index.js +28 -0
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +78 -0
- package/dist/cjs/components/PluginSpecEditor.js +43 -0
- package/dist/cjs/components/PluginSpecEditor.test.js +70 -0
- package/dist/cjs/components/TimeSeriesQueryEditor.js +42 -0
- package/dist/cjs/components/index.js +35 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/model/calculations.js +77 -0
- package/dist/cjs/model/datasource.js +16 -0
- package/dist/cjs/model/index.js +35 -0
- package/dist/cjs/model/panels.js +16 -0
- package/dist/cjs/model/plugin-base.js +22 -0
- package/dist/cjs/model/plugin-loading.js +38 -0
- package/dist/cjs/model/plugins.js +16 -0
- package/dist/cjs/model/time-series-queries.js +16 -0
- package/dist/cjs/model/variables.js +16 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +118 -0
- package/dist/cjs/runtime/TimeRangeProvider/index.js +29 -0
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +161 -0
- package/dist/cjs/runtime/datasources.js +44 -0
- package/dist/cjs/runtime/index.js +32 -0
- package/dist/cjs/runtime/plugin-registry.js +75 -0
- package/dist/cjs/runtime/template-variables.js +57 -0
- package/dist/cjs/runtime/time-series-queries.js +140 -0
- package/dist/cjs/test/index.js +28 -0
- package/dist/cjs/test/render.js +52 -0
- package/dist/cjs/test/setup-tests.js +20 -0
- package/dist/cjs/test/test-plugins/bert/index.js +77 -0
- package/dist/cjs/test/test-plugins/ernie/index.js +58 -0
- package/dist/cjs/test/test-plugins/index.js +77 -0
- package/dist/cjs/test-utils/index.js +28 -0
- package/dist/cjs/test-utils/mock-plugin-registry.js +68 -0
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +8 -0
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.js +46 -0
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.d.ts +2 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.d.ts.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.js +58 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -0
- package/dist/components/CalculationSelector/index.d.ts +2 -0
- package/dist/components/CalculationSelector/index.d.ts.map +1 -0
- package/dist/components/CalculationSelector/index.js +15 -0
- package/dist/components/CalculationSelector/index.js.map +1 -0
- package/dist/components/DatasourceSelect.d.ts +16 -0
- package/dist/components/DatasourceSelect.d.ts.map +1 -0
- package/dist/components/DatasourceSelect.js +73 -0
- package/dist/components/DatasourceSelect.js.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +34 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +96 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts +2 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +160 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -0
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts +9 -0
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/TabPanel.js +31 -0
- package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -0
- package/dist/components/OptionsEditorTabs/index.d.ts +2 -0
- package/dist/components/OptionsEditorTabs/index.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/index.js +15 -0
- package/dist/components/OptionsEditorTabs/index.js.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.d.ts +12 -0
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.js +68 -0
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.test.d.ts +2 -0
- package/dist/components/PluginEditor/PluginEditor.test.d.ts.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.test.js +143 -0
- package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -0
- package/dist/components/PluginEditor/index.d.ts +3 -0
- package/dist/components/PluginEditor/index.d.ts.map +1 -0
- package/dist/components/PluginEditor/index.js +16 -0
- package/dist/components/PluginEditor/index.js.map +1 -0
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +30 -0
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -0
- package/dist/components/PluginEditor/plugin-editor-api.js +100 -0
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -0
- package/dist/components/PluginKindSelect.d.ts +12 -0
- package/dist/components/PluginKindSelect.d.ts.map +1 -0
- package/dist/components/PluginKindSelect.js +38 -0
- package/dist/components/PluginKindSelect.js.map +1 -0
- package/dist/components/PluginKindSelect.test.d.ts +2 -0
- package/dist/components/PluginKindSelect.test.d.ts.map +1 -0
- package/dist/components/PluginKindSelect.test.js +79 -0
- package/dist/components/PluginKindSelect.test.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +13 -0
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.js +82 -0
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.d.ts +2 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.d.ts.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.js +137 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -0
- package/dist/components/PluginRegistry/index.d.ts +2 -0
- package/dist/components/PluginRegistry/index.d.ts.map +1 -0
- package/dist/components/PluginRegistry/index.js +15 -0
- package/dist/components/PluginRegistry/index.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +14 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.js +70 -0
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
- package/dist/components/PluginSpecEditor.d.ts +9 -0
- package/dist/components/PluginSpecEditor.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor.js +37 -0
- package/dist/components/PluginSpecEditor.js.map +1 -0
- package/dist/components/PluginSpecEditor.test.d.ts +2 -0
- package/dist/components/PluginSpecEditor.test.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor.test.js +63 -0
- package/dist/components/PluginSpecEditor.test.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor.d.ts +14 -0
- package/dist/components/TimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor.js +38 -0
- package/dist/components/TimeSeriesQueryEditor.js.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +22 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/model/calculations.d.ts +21 -0
- package/dist/model/calculations.d.ts.map +1 -0
- package/dist/model/calculations.js +64 -0
- package/dist/model/calculations.js.map +1 -0
- package/dist/model/datasource.d.ts +12 -0
- package/dist/model/datasource.d.ts.map +1 -0
- package/dist/model/datasource.js +15 -0
- package/dist/model/datasource.js.map +1 -0
- package/dist/model/index.d.ts +9 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +22 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/panels.d.ts +20 -0
- package/dist/model/panels.d.ts.map +1 -0
- package/dist/model/panels.js +15 -0
- package/dist/model/panels.js.map +1 -0
- package/dist/model/plugin-base.d.ts +22 -0
- package/dist/model/plugin-base.d.ts.map +1 -0
- package/dist/model/plugin-base.js +15 -0
- package/dist/model/plugin-base.js.map +1 -0
- package/dist/model/plugin-loading.d.ts +22 -0
- package/dist/model/plugin-loading.d.ts.map +1 -0
- package/dist/model/plugin-loading.js +35 -0
- package/dist/model/plugin-loading.js.map +1 -0
- package/dist/model/plugins.d.ts +54 -0
- package/dist/model/plugins.d.ts.map +1 -0
- package/dist/model/plugins.js +15 -0
- package/dist/model/plugins.js.map +1 -0
- package/dist/model/time-series-queries.d.ts +42 -0
- package/dist/model/time-series-queries.d.ts.map +1 -0
- package/dist/model/time-series-queries.js +15 -0
- package/dist/model/time-series-queries.js.map +1 -0
- package/dist/model/variables.d.ts +35 -0
- package/dist/model/variables.d.ts.map +1 -0
- package/dist/model/variables.js +15 -0
- package/dist/model/variables.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +25 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +69 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +3 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.js +16 -0
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +25 -0
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/query-params.js +153 -0
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -0
- package/dist/runtime/datasources.d.ts +25 -0
- package/dist/runtime/datasources.d.ts.map +1 -0
- package/dist/runtime/datasources.js +34 -0
- package/dist/runtime/datasources.js.map +1 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +19 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/plugin-registry.d.ts +32 -0
- package/dist/runtime/plugin-registry.d.ts.map +1 -0
- package/dist/runtime/plugin-registry.js +69 -0
- package/dist/runtime/plugin-registry.js.map +1 -0
- package/dist/runtime/template-variables.d.ts +17 -0
- package/dist/runtime/template-variables.d.ts.map +1 -0
- package/dist/runtime/template-variables.js +44 -0
- package/dist/runtime/template-variables.js.map +1 -0
- package/dist/runtime/time-series-queries.d.ts +13 -0
- package/dist/runtime/time-series-queries.d.ts.map +1 -0
- package/dist/runtime/time-series-queries.js +132 -0
- package/dist/runtime/time-series-queries.js.map +1 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +15 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/render.d.ts +13 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +49 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +18 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/test-plugins/bert/index.d.ts +8 -0
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -0
- package/dist/test/test-plugins/bert/index.js +66 -0
- package/dist/test/test-plugins/bert/index.js.map +1 -0
- package/dist/test/test-plugins/ernie/index.d.ts +5 -0
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -0
- package/dist/test/test-plugins/ernie/index.js +53 -0
- package/dist/test/test-plugins/ernie/index.js.map +1 -0
- package/dist/test/test-plugins/index.d.ts +6 -0
- package/dist/test/test-plugins/index.d.ts.map +1 -0
- package/dist/test/test-plugins/index.js +29 -0
- package/dist/test/test-plugins/index.js.map +1 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +15 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/mock-plugin-registry.d.ts +20 -0
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -0
- package/dist/test-utils/mock-plugin-registry.js +62 -0
- package/dist/test-utils/mock-plugin-registry.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Base type of all plugin implementations.
|
|
4
|
+
*/
|
|
5
|
+
export interface Plugin<Spec> {
|
|
6
|
+
/**
|
|
7
|
+
* React component for editing the plugin's options in the UI.
|
|
8
|
+
*/
|
|
9
|
+
OptionsEditorComponent: React.ComponentType<OptionsEditorProps<Spec>>;
|
|
10
|
+
/**
|
|
11
|
+
* Callback for creating the initial options for the plugin.
|
|
12
|
+
*/
|
|
13
|
+
createInitialOptions: () => Spec;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Common props passed to options editor components.
|
|
17
|
+
*/
|
|
18
|
+
export interface OptionsEditorProps<Spec> {
|
|
19
|
+
value: Spec;
|
|
20
|
+
onChange: (next: Spec) => void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=plugin-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-base.d.ts","sourceRoot":"","sources":["../../src/model/plugin-base.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI;IAC1B;;OAEG;IACH,sBAAsB,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtE;;OAEG;IACH,oBAAoB,EAAE,MAAM,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI;IAGtC,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import React from 'react';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=plugin-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/plugin-base.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\n\n/**\n * Base type of all plugin implementations.\n */\nexport interface Plugin<Spec> {\n /**\n * React component for editing the plugin's options in the UI.\n */\n OptionsEditorComponent: React.ComponentType<OptionsEditorProps<Spec>>;\n\n /**\n * Callback for creating the initial options for the plugin.\n */\n createInitialOptions: () => Spec;\n}\n\n/**\n * Common props passed to options editor components.\n */\nexport interface OptionsEditorProps<Spec> {\n // TODO: These are temporary and may not actually make sense, so replace\n // with whatever makes sense as visual editing evolves\n value: Spec;\n onChange: (next: Spec) => void;\n}\n"],"names":["React"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,KAAK,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PluginModuleResource } from './plugins';
|
|
2
|
+
/**
|
|
3
|
+
* A component capable of loading the resource/metadata for all available plugins, then loading individual plugins for
|
|
4
|
+
* those resources on-demand.
|
|
5
|
+
*/
|
|
6
|
+
export interface PluginLoader {
|
|
7
|
+
getInstalledPlugins: () => Promise<PluginModuleResource[]>;
|
|
8
|
+
importPluginModule: (resource: PluginModuleResource) => Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The dynamic import for a single plugin resource.
|
|
12
|
+
*/
|
|
13
|
+
export interface DynamicImportPlugin {
|
|
14
|
+
resource: PluginModuleResource;
|
|
15
|
+
importPlugin(): Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load
|
|
19
|
+
* the plugin itself via a dynamic `import()` statement.
|
|
20
|
+
*/
|
|
21
|
+
export declare function dynamicImportPluginLoader(plugins: DynamicImportPlugin[]): PluginLoader;
|
|
22
|
+
//# sourceMappingURL=plugin-loading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loading.d.ts","sourceRoot":"","sources":["../../src/model/plugin-loading.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,mBAAmB,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3D,kBAAkB,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,YAAY,CAiBtF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
/**
|
|
14
|
+
* A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load
|
|
15
|
+
* the plugin itself via a dynamic `import()` statement.
|
|
16
|
+
*/ export function dynamicImportPluginLoader(plugins) {
|
|
17
|
+
const importMap = new Map(plugins.map((plugin)=>[
|
|
18
|
+
plugin.resource,
|
|
19
|
+
plugin.importPlugin
|
|
20
|
+
]));
|
|
21
|
+
return {
|
|
22
|
+
async getInstalledPlugins () {
|
|
23
|
+
return Promise.resolve(Array.from(importMap.keys()));
|
|
24
|
+
},
|
|
25
|
+
importPluginModule (resource) {
|
|
26
|
+
const importFn = importMap.get(resource);
|
|
27
|
+
if (importFn === undefined) {
|
|
28
|
+
throw new Error('Plugin not found');
|
|
29
|
+
}
|
|
30
|
+
return importFn();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=plugin-loading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/plugin-loading.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginModuleResource } from './plugins';\n\n/**\n * A component capable of loading the resource/metadata for all available plugins, then loading individual plugins for\n * those resources on-demand.\n */\nexport interface PluginLoader {\n getInstalledPlugins: () => Promise<PluginModuleResource[]>;\n importPluginModule: (resource: PluginModuleResource) => Promise<unknown>;\n}\n\n/**\n * The dynamic import for a single plugin resource.\n */\nexport interface DynamicImportPlugin {\n resource: PluginModuleResource;\n importPlugin(): Promise<unknown>;\n}\n\n/**\n * A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load\n * the plugin itself via a dynamic `import()` statement.\n */\nexport function dynamicImportPluginLoader(plugins: DynamicImportPlugin[]): PluginLoader {\n const importMap: Map<PluginModuleResource, DynamicImportPlugin['importPlugin']> = new Map(\n plugins.map((plugin) => [plugin.resource, plugin.importPlugin])\n );\n\n return {\n async getInstalledPlugins() {\n return Promise.resolve(Array.from(importMap.keys()));\n },\n importPluginModule(resource) {\n const importFn = importMap.get(resource);\n if (importFn === undefined) {\n throw new Error('Plugin not found');\n }\n return importFn();\n },\n };\n}\n"],"names":["dynamicImportPluginLoader","plugins","importMap","Map","map","plugin","resource","importPlugin","getInstalledPlugins","Promise","resolve","Array","from","keys","importPluginModule","importFn","get","undefined","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqBjC;;;CAGC,GACD,OAAO,SAASA,yBAAyB,CAACC,OAA8B,EAAgB;IACtF,MAAMC,SAAS,GAAmE,IAAIC,GAAG,CACvFF,OAAO,CAACG,GAAG,CAAC,CAACC,MAAM,GAAK;YAACA,MAAM,CAACC,QAAQ;YAAED,MAAM,CAACE,YAAY;SAAC,CAAC,CAChE,AAAC;IAEF,OAAO;QACL,MAAMC,mBAAmB,IAAG;YAC1B,OAAOC,OAAO,CAACC,OAAO,CAACC,KAAK,CAACC,IAAI,CAACV,SAAS,CAACW,IAAI,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC;QACDC,kBAAkB,EAACR,QAAQ,EAAE;YAC3B,MAAMS,QAAQ,GAAGb,SAAS,CAACc,GAAG,CAACV,QAAQ,CAAC,AAAC;YACzC,IAAIS,QAAQ,KAAKE,SAAS,EAAE;gBAC1B,MAAM,IAAIC,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACtC,CAAC;YACD,OAAOH,QAAQ,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Metadata, UnknownSpec } from '@perses-dev/core';
|
|
2
|
+
import { TimeSeriesQueryPlugin } from './time-series-queries';
|
|
3
|
+
import { PanelPlugin } from './panels';
|
|
4
|
+
import { VariablePlugin } from './variables';
|
|
5
|
+
import { DatasourcePlugin } from './datasource';
|
|
6
|
+
import { Plugin } from './plugin-base';
|
|
7
|
+
/**
|
|
8
|
+
* Information about a module/package that contains plugins.
|
|
9
|
+
*/
|
|
10
|
+
export interface PluginModuleResource {
|
|
11
|
+
kind: 'PluginModule';
|
|
12
|
+
metadata: Metadata;
|
|
13
|
+
spec: PluginSpec;
|
|
14
|
+
}
|
|
15
|
+
export interface PluginSpec {
|
|
16
|
+
plugins: PluginMetadata[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Metadata about an individual plugin that's part of a PluginModule.
|
|
20
|
+
*/
|
|
21
|
+
export interface PluginMetadata {
|
|
22
|
+
pluginType: PluginType;
|
|
23
|
+
kind: string;
|
|
24
|
+
display: {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* All supported plugin types. A plugin's implementation must extend from `Plugin<UnknownSpec>` to be considered a valid
|
|
31
|
+
* `PluginType`.
|
|
32
|
+
*/
|
|
33
|
+
export declare type PluginType = {
|
|
34
|
+
[K in keyof SupportedPlugins]: SupportedPlugins[K] extends Plugin<UnknownSpec> ? K : never;
|
|
35
|
+
}[keyof SupportedPlugins];
|
|
36
|
+
/**
|
|
37
|
+
* Map of plugin type key/string -> implementation type. Use Typescript module augmentation to extend the plugin system
|
|
38
|
+
* with new plugin types.
|
|
39
|
+
*/
|
|
40
|
+
export interface SupportedPlugins {
|
|
41
|
+
Variable: VariablePlugin;
|
|
42
|
+
Panel: PanelPlugin;
|
|
43
|
+
TimeSeriesQuery: TimeSeriesQueryPlugin;
|
|
44
|
+
Datasource: DatasourcePlugin;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The implementation for a given plugin type.
|
|
48
|
+
*/
|
|
49
|
+
export declare type PluginImplementation<Type extends PluginType> = SupportedPlugins[Type];
|
|
50
|
+
/**
|
|
51
|
+
* Default plugin kinds by plugin type.
|
|
52
|
+
*/
|
|
53
|
+
export declare type DefaultPluginKinds = Partial<Record<PluginType, string>>;
|
|
54
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/model/plugins.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;GAGG;AACH,oBAAY,UAAU,GAAG;KAEtB,CAAC,IAAI,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK;CAC3F,CAAC,MAAM,gBAAgB,CAAC,CAAC;AAE1B;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED;;GAEG;AACH,oBAAY,oBAAoB,CAAC,IAAI,SAAS,UAAU,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAEnF;;GAEG;AACH,oBAAY,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata, UnknownSpec } from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin } from './time-series-queries';\nimport { PanelPlugin } from './panels';\nimport { VariablePlugin } from './variables';\nimport { DatasourcePlugin } from './datasource';\nimport { Plugin } from './plugin-base';\n\n/**\n * Information about a module/package that contains plugins.\n */\nexport interface PluginModuleResource {\n kind: 'PluginModule';\n metadata: Metadata;\n spec: PluginSpec;\n}\n\nexport interface PluginSpec {\n plugins: PluginMetadata[];\n}\n\n/**\n * Metadata about an individual plugin that's part of a PluginModule.\n */\nexport interface PluginMetadata {\n pluginType: PluginType;\n kind: string;\n display: {\n name: string;\n description?: string;\n };\n}\n\n/**\n * All supported plugin types. A plugin's implementation must extend from `Plugin<UnknownSpec>` to be considered a valid\n * `PluginType`.\n */\nexport type PluginType = {\n // Filter out implementations on SupportedPlugins that don't extend `Plugin<UnknownSpec>`\n [K in keyof SupportedPlugins]: SupportedPlugins[K] extends Plugin<UnknownSpec> ? K : never;\n}[keyof SupportedPlugins];\n\n/**\n * Map of plugin type key/string -> implementation type. Use Typescript module augmentation to extend the plugin system\n * with new plugin types.\n */\nexport interface SupportedPlugins {\n Variable: VariablePlugin;\n Panel: PanelPlugin;\n TimeSeriesQuery: TimeSeriesQueryPlugin;\n Datasource: DatasourcePlugin;\n}\n\n/**\n * The implementation for a given plugin type.\n */\nexport type PluginImplementation<Type extends PluginType> = SupportedPlugins[Type];\n\n/**\n * Default plugin kinds by plugin type.\n */\nexport type DefaultPluginKinds = Partial<Record<PluginType, string>>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WA4DqE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AbsoluteTimeRange, UnixTimeMs, UnknownSpec } from '@perses-dev/core';
|
|
2
|
+
import { DatasourceStore, VariableStateMap } from '../runtime';
|
|
3
|
+
import { Plugin } from './plugin-base';
|
|
4
|
+
/**
|
|
5
|
+
* An object containing all the dependencies of a TimeSeriesQuery.
|
|
6
|
+
*/
|
|
7
|
+
declare type TimeSeriesQueryPluginDependencies = {
|
|
8
|
+
/**
|
|
9
|
+
* Returns a list of variables name this time series query depends on.
|
|
10
|
+
*/
|
|
11
|
+
variables?: string[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A plugin for running time series queries.
|
|
15
|
+
*/
|
|
16
|
+
export interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {
|
|
17
|
+
getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;
|
|
18
|
+
dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Context available to TimeSeriesQuery plugins at runtime.
|
|
22
|
+
*/
|
|
23
|
+
export interface TimeSeriesQueryContext {
|
|
24
|
+
suggestedStepMs?: number;
|
|
25
|
+
timeRange: AbsoluteTimeRange;
|
|
26
|
+
variableState: VariableStateMap;
|
|
27
|
+
datasourceStore: DatasourceStore;
|
|
28
|
+
refreshKey: string;
|
|
29
|
+
}
|
|
30
|
+
export interface TimeSeriesData {
|
|
31
|
+
timeRange?: AbsoluteTimeRange;
|
|
32
|
+
stepMs?: number;
|
|
33
|
+
series: Iterable<TimeSeries>;
|
|
34
|
+
}
|
|
35
|
+
export interface TimeSeries {
|
|
36
|
+
name: string;
|
|
37
|
+
values: Iterable<TimeSeriesValueTuple>;
|
|
38
|
+
formattedName?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number];
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=time-series-queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,aAAK,iCAAiC,GAAG;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAExF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,iCAAiC,CAAC;CAC5F;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oBAAY,oBAAoB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=time-series-queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, UnixTimeMs, UnknownSpec } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\nexport interface TimeSeriesData {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: Iterable<TimeSeries>;\n}\n\nexport interface TimeSeries {\n name: string;\n values: Iterable<TimeSeriesValueTuple>;\n formattedName?: string;\n}\n\nexport type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number];\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WA8C0E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UnknownSpec, AbsoluteTimeRange } from '@perses-dev/core';
|
|
2
|
+
import { VariableStateMap, DatasourceStore } from '../runtime';
|
|
3
|
+
import { Plugin } from './plugin-base';
|
|
4
|
+
export declare type VariableOption = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
export interface GetVariableOptionsContext {
|
|
9
|
+
variables: VariableStateMap;
|
|
10
|
+
datasourceStore: DatasourceStore;
|
|
11
|
+
timeRange: AbsoluteTimeRange;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An object containing all the dependencies of a VariablePlugin.
|
|
15
|
+
*/
|
|
16
|
+
declare type VariablePluginDependencies = {
|
|
17
|
+
/**
|
|
18
|
+
* Returns a list of variables name this time series query depends on.
|
|
19
|
+
*/
|
|
20
|
+
variables?: string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Plugin for handling custom VariableDefinitions.
|
|
24
|
+
*/
|
|
25
|
+
export interface VariablePlugin<Spec = UnknownSpec> extends Plugin<Spec> {
|
|
26
|
+
getVariableOptions: (definition: Spec, ctx: GetVariableOptionsContext) => Promise<{
|
|
27
|
+
data: VariableOption[];
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a list of variables name this variable depends on. Used to optimize fetching
|
|
31
|
+
*/
|
|
32
|
+
dependsOn?: (definition: Spec, ctx: GetVariableOptionsContext) => VariablePluginDependencies;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,oBAAY,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;GAEG;AACH,aAAK,0BAA0B,GAAG;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACtE,kBAAkB,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,yBAAyB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC,CAAC;IAE9G;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,yBAAyB,KAAK,0BAA0B,CAAC;CAC9F"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/variables.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, AbsoluteTimeRange } from '@perses-dev/core';\nimport { VariableStateMap, DatasourceStore } from '../runtime';\nimport { Plugin } from './plugin-base';\n\nexport type VariableOption = { label: string; value: string };\n\nexport interface GetVariableOptionsContext {\n variables: VariableStateMap;\n datasourceStore: DatasourceStore;\n timeRange: AbsoluteTimeRange;\n}\n\n/**\n * An object containing all the dependencies of a VariablePlugin.\n */\ntype VariablePluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * Plugin for handling custom VariableDefinitions.\n */\nexport interface VariablePlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getVariableOptions: (definition: Spec, ctx: GetVariableOptionsContext) => Promise<{ data: VariableOption[] }>;\n\n /**\n * Returns a list of variables name this variable depends on. Used to optimize fetching\n */\n dependsOn?: (definition: Spec, ctx: GetVariableOptionsContext) => VariablePluginDependencies;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAgCC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AbsoluteTimeRange, TimeRangeValue } from '@perses-dev/core';
|
|
3
|
+
export interface TimeRangeProviderProps {
|
|
4
|
+
initialTimeRange: TimeRangeValue;
|
|
5
|
+
enabledURLParams?: boolean;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface TimeRange {
|
|
9
|
+
timeRange: TimeRangeValue;
|
|
10
|
+
absoluteTimeRange: AbsoluteTimeRange;
|
|
11
|
+
setTimeRange: (value: TimeRangeValue) => void;
|
|
12
|
+
refresh: () => void;
|
|
13
|
+
refreshKey: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const TimeRangeContext: React.Context<TimeRange | undefined>;
|
|
16
|
+
export declare function useTimeRangeContext(): TimeRange;
|
|
17
|
+
/**
|
|
18
|
+
* Get and set the current resolved time range at runtime.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useTimeRange(): TimeRange;
|
|
21
|
+
/**
|
|
22
|
+
* Provider implementation that supplies the time range state at runtime.
|
|
23
|
+
*/
|
|
24
|
+
export declare function TimeRangeProvider(props: TimeRangeProviderProps): JSX.Element;
|
|
25
|
+
//# sourceMappingURL=TimeRangeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAuB,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAG/G,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,cAAc,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,cAMlC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAGxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAuB9D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import React, { useMemo, useState, useCallback, createContext, useContext } from 'react';
|
|
15
|
+
import { isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/core';
|
|
16
|
+
import { useSetTimeRangeParams } from './query-params';
|
|
17
|
+
export const TimeRangeContext = /*#__PURE__*/ createContext(undefined);
|
|
18
|
+
export function useTimeRangeContext() {
|
|
19
|
+
const ctx = useContext(TimeRangeContext);
|
|
20
|
+
if (ctx === undefined) {
|
|
21
|
+
throw new Error('No TimeRangeContext found. Did you forget a Provider?');
|
|
22
|
+
}
|
|
23
|
+
return ctx;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get and set the current resolved time range at runtime.
|
|
27
|
+
*/ export function useTimeRange() {
|
|
28
|
+
const { timeRange , absoluteTimeRange , setTimeRange , refresh , refreshKey } = useTimeRangeContext();
|
|
29
|
+
return {
|
|
30
|
+
timeRange,
|
|
31
|
+
absoluteTimeRange,
|
|
32
|
+
setTimeRange,
|
|
33
|
+
refresh,
|
|
34
|
+
refreshKey
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Provider implementation that supplies the time range state at runtime.
|
|
39
|
+
*/ export function TimeRangeProvider(props) {
|
|
40
|
+
const { initialTimeRange , enabledURLParams , children } = props;
|
|
41
|
+
const { timeRange , setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);
|
|
42
|
+
const [refreshKey, setRefreshKey] = useState(0);
|
|
43
|
+
const refresh = useCallback(()=>{
|
|
44
|
+
setRefreshKey(refreshKey + 1);
|
|
45
|
+
}, [
|
|
46
|
+
refreshKey
|
|
47
|
+
]);
|
|
48
|
+
const ctx = useMemo(()=>{
|
|
49
|
+
const absoluteTimeRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;
|
|
50
|
+
return {
|
|
51
|
+
timeRange,
|
|
52
|
+
setTimeRange,
|
|
53
|
+
absoluteTimeRange,
|
|
54
|
+
refresh,
|
|
55
|
+
refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshKey}`
|
|
56
|
+
};
|
|
57
|
+
}, [
|
|
58
|
+
timeRange,
|
|
59
|
+
setTimeRange,
|
|
60
|
+
refresh,
|
|
61
|
+
refreshKey
|
|
62
|
+
]);
|
|
63
|
+
return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
|
|
64
|
+
value: ctx,
|
|
65
|
+
children: children
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=TimeRangeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useMemo, useState, useCallback, createContext, useContext } from 'react';\nimport { AbsoluteTimeRange, isRelativeTimeRange, TimeRangeValue, toAbsoluteTimeRange } from '@perses-dev/core';\nimport { useSetTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProviderProps {\n initialTimeRange: TimeRangeValue;\n enabledURLParams?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n const { timeRange, absoluteTimeRange, setTimeRange, refresh, refreshKey } = useTimeRangeContext();\n return { timeRange, absoluteTimeRange, setTimeRange, refresh, refreshKey };\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { initialTimeRange, enabledURLParams, children } = props;\n\n const { timeRange, setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);\n\n const [refreshKey, setRefreshKey] = useState(0);\n\n const refresh = useCallback(() => {\n setRefreshKey(refreshKey + 1);\n }, [refreshKey]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n return {\n timeRange,\n setTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshKey}`,\n };\n }, [timeRange, setTimeRange, refresh, refreshKey]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","useMemo","useState","useCallback","createContext","useContext","isRelativeTimeRange","toAbsoluteTimeRange","useSetTimeRangeParams","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","timeRange","absoluteTimeRange","setTimeRange","refresh","refreshKey","TimeRangeProvider","props","initialTimeRange","enabledURLParams","children","setRefreshKey","start","end","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AACzF,SAA4BC,mBAAmB,EAAkBC,mBAAmB,QAAQ,kBAAkB,CAAC;AAC/G,SAASC,qBAAqB,QAAQ,gBAAgB,CAAC;AAgBvD,OAAO,MAAMC,gBAAgB,iBAAGL,aAAa,CAAwBM,SAAS,CAAC,CAAC;AAEhF,OAAO,SAASC,mBAAmB,GAAG;IACpC,MAAMC,GAAG,GAAGP,UAAU,CAACI,gBAAgB,CAAC,AAAC;IACzC,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED;;CAEC,GACD,OAAO,SAASE,YAAY,GAAc;IACxC,MAAM,EAAEC,SAAS,CAAA,EAAEC,iBAAiB,CAAA,EAAEC,YAAY,CAAA,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGR,mBAAmB,EAAE,AAAC;IAClG,OAAO;QAAEI,SAAS;QAAEC,iBAAiB;QAAEC,YAAY;QAAEC,OAAO;QAAEC,UAAU;KAAE,CAAC;AAC7E,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,gBAAgB,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE/D,MAAM,EAAEN,SAAS,CAAA,EAAEE,YAAY,CAAA,EAAE,GAAGT,qBAAqB,CAACc,gBAAgB,EAAEC,gBAAgB,CAAC,AAAC;IAE9F,MAAM,CAACJ,UAAU,EAAEM,aAAa,CAAC,GAAGvB,QAAQ,CAAC,CAAC,CAAC,AAAC;IAEhD,MAAMgB,OAAO,GAAGf,WAAW,CAAC,IAAM;QAChCsB,aAAa,CAACN,UAAU,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC,EAAE;QAACA,UAAU;KAAC,CAAC,AAAC;IAEjB,MAAMP,GAAG,GAAGX,OAAO,CAAC,IAAM;QACxB,MAAMe,iBAAiB,GAAGV,mBAAmB,CAACS,SAAS,CAAC,GAAGR,mBAAmB,CAACQ,SAAS,CAAC,GAAGA,SAAS,AAAC;QACtG,OAAO;YACLA,SAAS;YACTE,YAAY;YACZD,iBAAiB;YACjBE,OAAO;YACPC,UAAU,EAAE,CAAC,EAAEH,iBAAiB,CAACU,KAAK,CAAC,CAAC,EAAEV,iBAAiB,CAACW,GAAG,CAAC,CAAC,EAAER,UAAU,CAAC,CAAC;SAChF,CAAC;IACJ,CAAC,EAAE;QAACJ,SAAS;QAAEE,YAAY;QAAEC,OAAO;QAAEC,UAAU;KAAC,CAAC,AAAC;IAEnD,qBAAO,KAACV,gBAAgB,CAACmB,QAAQ;QAACC,KAAK,EAAEjB,GAAG;kBAAGY,QAAQ;MAA6B,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './TimeRangeProvider';
|
|
14
|
+
export * from './query-params';
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './query-params';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QueryParamConfig } from 'use-query-params';
|
|
2
|
+
import { TimeRangeValue, DurationString } from '@perses-dev/core';
|
|
3
|
+
import { TimeRange } from './TimeRangeProvider';
|
|
4
|
+
export declare type TimeOptionValue = Date | DurationString | null | undefined;
|
|
5
|
+
export declare function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined;
|
|
6
|
+
export declare function decodeTimeRangeValue(input: string | Array<string | null> | null | undefined): Date | DurationString | null | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Custom TimeRangeValue param type
|
|
9
|
+
* See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types
|
|
10
|
+
*/
|
|
11
|
+
export declare const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
|
|
12
|
+
export declare const timeRangeQueryConfig: {
|
|
13
|
+
start: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
|
|
14
|
+
end: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Gets the initial time range taking into account URL params and dashboard JSON duration
|
|
18
|
+
* Sets start query param if it is empty on page load
|
|
19
|
+
*/
|
|
20
|
+
export declare function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue;
|
|
21
|
+
/**
|
|
22
|
+
* Returns time range getter and setter, set enabledURLParams to false to disable query string serialization
|
|
23
|
+
*/
|
|
24
|
+
export declare function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, enabledURLParams?: boolean): Pick<TimeRange, 'timeRange' | 'setTimeRange'>;
|
|
25
|
+
//# sourceMappingURL=query-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,cAAc,EAChC,gBAAgB,UAAO,GACtB,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAAC,CAqC/C"}
|