@perses-dev/plugin-system 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +43 -29
- package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +114 -38
- package/dist/cjs/components/PluginRegistry/index.js +17 -18
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +23 -20
- package/dist/cjs/components/PluginRegistry/plugin-registry-model.js +17 -7
- package/dist/cjs/components/PluginRegistry/test-plugins/bert/index.js +22 -12
- package/dist/cjs/components/PluginRegistry/test-plugins/ernie/index.js +20 -8
- package/dist/cjs/components/PluginRegistry/test-plugins/index.js +59 -39
- package/dist/cjs/components/index.js +17 -20
- package/dist/cjs/index.js +19 -20
- package/dist/cjs/model/datasource.js +16 -0
- package/dist/cjs/model/index.js +21 -21
- package/dist/cjs/model/panels.js +4 -21
- package/dist/cjs/model/plugins.js +4 -7
- package/dist/cjs/model/time-series-queries.js +16 -0
- package/dist/cjs/model/variables.js +5 -17
- package/dist/cjs/model/visual-editing.js +10 -2
- package/dist/cjs/runtime/datasources.js +20 -13
- package/dist/cjs/runtime/index.js +22 -21
- package/dist/cjs/runtime/plugins.js +25 -22
- package/dist/cjs/runtime/query-string.js +17 -10
- package/dist/cjs/runtime/template-variables.js +34 -16
- package/dist/cjs/runtime/time-range.js +17 -10
- package/dist/cjs/runtime/time-series-queries.js +58 -0
- package/dist/cjs/test/render.js +32 -13
- package/dist/cjs/test/setup-tests.js +4 -10
- package/dist/cjs/utils/cache-keys.js +8 -7
- package/dist/components/PluginRegistry/PluginRegistry.js +81 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.js +142 -1
- package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -0
- package/dist/components/PluginRegistry/index.js +16 -1
- package/dist/components/PluginRegistry/index.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.js +66 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-registry-model.d.ts +1 -2
- package/dist/components/PluginRegistry/plugin-registry-model.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-registry-model.js +23 -1
- package/dist/components/PluginRegistry/plugin-registry-model.js.map +1 -0
- package/dist/components/PluginRegistry/test-plugins/bert/index.js +25 -1
- package/dist/components/PluginRegistry/test-plugins/bert/index.js.map +1 -0
- package/dist/components/PluginRegistry/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/components/PluginRegistry/test-plugins/ernie/index.js +30 -1
- package/dist/components/PluginRegistry/test-plugins/ernie/index.js.map +1 -0
- package/dist/components/PluginRegistry/test-plugins/index.js +35 -1
- package/dist/components/PluginRegistry/test-plugins/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +15 -1
- package/dist/components/index.js.map +1 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -0
- package/dist/model/datasource.d.ts +9 -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 +2 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +20 -1
- package/dist/model/index.js.map +1 -0
- package/dist/model/panels.d.ts +7 -11
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +15 -1
- package/dist/model/panels.js.map +1 -0
- package/dist/model/plugins.d.ts +16 -25
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js +15 -1
- package/dist/model/plugins.js.map +1 -0
- package/dist/model/time-series-queries.d.ts +28 -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 +16 -11
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +15 -1
- package/dist/model/variables.js.map +1 -0
- package/dist/model/visual-editing.d.ts +5 -6
- package/dist/model/visual-editing.d.ts.map +1 -1
- package/dist/model/visual-editing.js +15 -1
- package/dist/model/visual-editing.js.map +1 -0
- package/dist/runtime/datasources.d.ts +5 -9
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +23 -1
- package/dist/runtime/datasources.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +20 -1
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/plugins.d.ts +5 -14
- package/dist/runtime/plugins.d.ts.map +1 -1
- package/dist/runtime/plugins.js +33 -1
- package/dist/runtime/plugins.js.map +1 -0
- package/dist/runtime/query-string.js +25 -1
- package/dist/runtime/query-string.js.map +1 -0
- package/dist/runtime/template-variables.d.ts +10 -1
- package/dist/runtime/template-variables.d.ts.map +1 -1
- package/dist/runtime/template-variables.js +44 -1
- package/dist/runtime/template-variables.js.map +1 -0
- package/dist/runtime/time-range.js +25 -1
- package/dist/runtime/time-range.js.map +1 -0
- package/dist/runtime/time-series-queries.d.ts +14 -0
- package/dist/runtime/time-series-queries.d.ts.map +1 -0
- package/dist/runtime/time-series-queries.js +54 -0
- package/dist/runtime/time-series-queries.js.map +1 -0
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +42 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +16 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/utils/cache-keys.js +19 -1
- package/dist/utils/cache-keys.js.map +1 -0
- package/package.json +11 -8
- package/dist/cjs/components/PluginBoundary.js +0 -14
- package/dist/cjs/components/PluginLoadingBoundary/PluginLoader.js +0 -39
- package/dist/cjs/components/PluginLoadingBoundary/PluginLoadingBoundary.js +0 -85
- package/dist/cjs/components/PluginLoadingBoundary/index.js +0 -29
- package/dist/cjs/components/PluginRegistry/legacy/PluginRegistry.js +0 -57
- package/dist/cjs/components/PluginRegistry/legacy/index.js +0 -29
- package/dist/cjs/components/PluginRegistry/legacy/registry-state.js +0 -97
- package/dist/cjs/components/PluginRegistry/test-plugins/bert/plugin.json +0 -32
- package/dist/cjs/components/PluginRegistry/test-plugins/ernie/plugin.json +0 -24
- package/dist/cjs/model/graph-queries.js +0 -28
- package/dist/components/PluginBoundary.d.ts +0 -13
- package/dist/components/PluginBoundary.d.ts.map +0 -1
- package/dist/components/PluginBoundary.js +0 -1
- package/dist/components/PluginLoadingBoundary/PluginLoader.d.ts +0 -11
- package/dist/components/PluginLoadingBoundary/PluginLoader.d.ts.map +0 -1
- package/dist/components/PluginLoadingBoundary/PluginLoader.js +0 -1
- package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts +0 -27
- package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts.map +0 -1
- package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.js +0 -1
- package/dist/components/PluginLoadingBoundary/index.d.ts +0 -2
- package/dist/components/PluginLoadingBoundary/index.d.ts.map +0 -1
- package/dist/components/PluginLoadingBoundary/index.js +0 -1
- package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts +0 -29
- package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts.map +0 -1
- package/dist/components/PluginRegistry/legacy/PluginRegistry.js +0 -1
- package/dist/components/PluginRegistry/legacy/index.d.ts +0 -2
- package/dist/components/PluginRegistry/legacy/index.d.ts.map +0 -1
- package/dist/components/PluginRegistry/legacy/index.js +0 -1
- package/dist/components/PluginRegistry/legacy/registry-state.d.ts +0 -18
- package/dist/components/PluginRegistry/legacy/registry-state.d.ts.map +0 -1
- package/dist/components/PluginRegistry/legacy/registry-state.js +0 -1
- package/dist/components/PluginRegistry/test-plugins/bert/plugin.json +0 -32
- package/dist/components/PluginRegistry/test-plugins/ernie/plugin.json +0 -24
- package/dist/model/graph-queries.d.ts +0 -36
- package/dist/model/graph-queries.d.ts.map +0 -1
- package/dist/model/graph-queries.js +0 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PluginRegistry = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
1
|
// Copyright 2022 The Perses Authors
|
|
6
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -14,57 +10,75 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
11
|
// See the License for the specific language governing permissions and
|
|
16
12
|
// limitations under the License.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "PluginRegistry", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PluginRegistry
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _core = require("@perses-dev/core");
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const _cacheKeys = require("../../utils/cache-keys");
|
|
25
|
+
const _pluginIndexes = require("./plugin-indexes");
|
|
26
|
+
const _pluginRegistryModel = require("./plugin-registry-model");
|
|
26
27
|
function PluginRegistry(props) {
|
|
27
|
-
const { getInstalledPlugins, importPluginModule, children
|
|
28
|
-
const getPluginIndexes = (0,
|
|
28
|
+
const { getInstalledPlugins , importPluginModule , children } = props;
|
|
29
|
+
const getPluginIndexes = (0, _pluginIndexes.usePluginIndexes)(getInstalledPlugins);
|
|
29
30
|
// De-dupe calls to import plugin modules
|
|
30
|
-
const importCache = (0,
|
|
31
|
+
const importCache = (0, _react.useRef)(new Map());
|
|
31
32
|
// Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the
|
|
32
33
|
// callback below
|
|
33
|
-
const loadPluginModule = (0,
|
|
34
|
+
const loadPluginModule = (0, _core.useEvent)((resource)=>{
|
|
34
35
|
let request = importCache.current.get(resource);
|
|
35
36
|
if (request === undefined) {
|
|
36
37
|
request = importPluginModule(resource);
|
|
37
38
|
importCache.current.set(resource, request);
|
|
38
39
|
// Remove failed requests from the cache so they can potentially be retried
|
|
39
|
-
request.catch(()
|
|
40
|
+
request.catch(()=>importCache.current.delete(resource));
|
|
40
41
|
}
|
|
41
42
|
return request;
|
|
42
43
|
});
|
|
43
|
-
const getPlugin = (0,
|
|
44
|
+
const getPlugin = (0, _react.useCallback)(async (pluginType, kind)=>{
|
|
44
45
|
// Get the indexes of the installed plugins
|
|
45
46
|
const pluginIndexes = await getPluginIndexes();
|
|
46
47
|
// Figure out what module the plugin is in by looking in the index
|
|
47
|
-
const typeAndKindKey = (0,
|
|
48
|
+
const typeAndKindKey = (0, _cacheKeys.getTypeAndKindKey)(pluginType, kind);
|
|
48
49
|
const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);
|
|
49
50
|
if (resource === undefined) {
|
|
50
51
|
throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);
|
|
51
52
|
}
|
|
52
53
|
// Treat the plugin module as a bunch of named exports that have plugins
|
|
53
|
-
const pluginModule =
|
|
54
|
+
const pluginModule = await loadPluginModule(resource);
|
|
54
55
|
// We currently assume that plugin modules will have named exports that match the kinds they handle
|
|
55
56
|
const plugin = pluginModule[kind];
|
|
56
57
|
if (plugin === undefined) {
|
|
57
58
|
throw new Error(`The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
|
|
58
59
|
}
|
|
59
60
|
return plugin;
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
}, [
|
|
62
|
+
getPluginIndexes,
|
|
63
|
+
loadPluginModule
|
|
64
|
+
]);
|
|
65
|
+
const listPluginMetadata = (0, _react.useCallback)(async (pluginType)=>{
|
|
63
66
|
const pluginIndexes = await getPluginIndexes();
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
var ref;
|
|
68
|
+
return (ref = pluginIndexes.pluginMetadataByType.get(pluginType)) !== null && ref !== void 0 ? ref : [];
|
|
69
|
+
}, [
|
|
70
|
+
getPluginIndexes
|
|
71
|
+
]);
|
|
66
72
|
// Create the registry's context value and render
|
|
67
|
-
const context = (0,
|
|
68
|
-
|
|
73
|
+
const context = (0, _react.useMemo)(()=>({
|
|
74
|
+
getPlugin,
|
|
75
|
+
listPluginMetadata
|
|
76
|
+
}), [
|
|
77
|
+
getPlugin,
|
|
78
|
+
listPluginMetadata
|
|
79
|
+
]);
|
|
80
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginRegistryModel.PluginRegistryContext.Provider, {
|
|
81
|
+
value: context,
|
|
82
|
+
children: children
|
|
83
|
+
});
|
|
69
84
|
}
|
|
70
|
-
exports.PluginRegistry = PluginRegistry;
|
|
@@ -1,73 +1,149 @@
|
|
|
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.
|
|
1
13
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
19
|
+
const _react1 = require("@testing-library/react");
|
|
20
|
+
const _plugins = require("../../runtime/plugins");
|
|
21
|
+
const _render = require("../../test/render");
|
|
22
|
+
const _pluginRegistry = require("./PluginRegistry");
|
|
23
|
+
const _testPlugins = require("./test-plugins");
|
|
24
|
+
function _interopRequireDefault(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
describe('PluginRegistry', ()=>{
|
|
30
|
+
const renderPluginRegistry = (children)=>{
|
|
31
|
+
(0, _render.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginRegistry.PluginRegistry, {
|
|
32
|
+
..._testPlugins.testRegistryProps,
|
|
33
|
+
children: children
|
|
34
|
+
}));
|
|
12
35
|
};
|
|
13
|
-
it('can load a plugin that exists', async ()
|
|
14
|
-
renderPluginRegistry((0,
|
|
15
|
-
|
|
36
|
+
it('can load a plugin that exists', async ()=>{
|
|
37
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginConsumer, {
|
|
38
|
+
pluginType: "Variable",
|
|
39
|
+
kind: "ErnieVariable"
|
|
40
|
+
}));
|
|
41
|
+
const hasPlugin = await _react1.screen.findByText('Has plugin: true', undefined, {
|
|
42
|
+
timeout: 3000
|
|
43
|
+
});
|
|
16
44
|
expect(hasPlugin).toBeInTheDocument();
|
|
17
45
|
});
|
|
18
|
-
it('errors when plugin is not installed', async ()
|
|
46
|
+
it('errors when plugin is not installed', async ()=>{
|
|
19
47
|
// This plugin is not in the test metadata at all
|
|
20
|
-
renderPluginRegistry((0,
|
|
21
|
-
|
|
48
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginConsumer, {
|
|
49
|
+
pluginType: "TimeSeriesQuery",
|
|
50
|
+
kind: "NotInstalled"
|
|
51
|
+
}));
|
|
52
|
+
const error = await _react1.screen.findByText(/error:/i);
|
|
22
53
|
expect(error).toBeInTheDocument();
|
|
23
54
|
expect(error).toHaveTextContent(/not installed/i);
|
|
24
55
|
});
|
|
25
|
-
it('errors when plugin is missing from the module', async ()
|
|
56
|
+
it('errors when plugin is missing from the module', async ()=>{
|
|
26
57
|
// This plugin is in the test metadata, but the code is missing from the module
|
|
27
|
-
renderPluginRegistry((0,
|
|
28
|
-
|
|
58
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginConsumer, {
|
|
59
|
+
pluginType: "Variable",
|
|
60
|
+
kind: "MissingErnieVariable"
|
|
61
|
+
}));
|
|
62
|
+
const error = await _react1.screen.findByText(/error:/i);
|
|
29
63
|
expect(error).toBeInTheDocument();
|
|
30
64
|
expect(error).toHaveTextContent(/missing/i);
|
|
31
65
|
});
|
|
32
|
-
it('lists metadata for plugin metadata that exists', async ()
|
|
66
|
+
it('lists metadata for plugin metadata that exists', async ()=>{
|
|
33
67
|
// There should be 3 variable plugins across both test modules
|
|
34
|
-
renderPluginRegistry((0,
|
|
35
|
-
|
|
68
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(MetadataConsumer, {
|
|
69
|
+
pluginType: "Variable"
|
|
70
|
+
}));
|
|
71
|
+
const table = await _react1.screen.findByRole('table');
|
|
36
72
|
expect(table).toBeInTheDocument();
|
|
37
|
-
const rows =
|
|
73
|
+
const rows = _react1.screen.getAllByRole('row');
|
|
38
74
|
expect(rows).toHaveLength(3);
|
|
39
75
|
});
|
|
40
|
-
it('lists metadata for plugin types with no plugins available', async ()
|
|
41
|
-
// There are no
|
|
42
|
-
renderPluginRegistry((0,
|
|
43
|
-
|
|
76
|
+
it('lists metadata for plugin types with no plugins available', async ()=>{
|
|
77
|
+
// There are no TimeSeriesQuery plugins in any of the test modules
|
|
78
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(MetadataConsumer, {
|
|
79
|
+
pluginType: "TimeSeriesQuery"
|
|
80
|
+
}));
|
|
81
|
+
const table = await _react1.screen.findByRole('table');
|
|
44
82
|
expect(table).toBeInTheDocument();
|
|
45
|
-
const rows =
|
|
83
|
+
const rows = _react1.screen.queryAllByRole('row');
|
|
46
84
|
expect(rows).toHaveLength(0);
|
|
47
85
|
});
|
|
48
86
|
});
|
|
49
87
|
// A helper component for testing the PluginRegistry by calling usePlugin to load a plugin
|
|
50
|
-
const PluginConsumer = (props)
|
|
51
|
-
const { plugin, isLoading, error
|
|
88
|
+
const PluginConsumer = (props)=>{
|
|
89
|
+
const { data: plugin , isLoading , error } = (0, _plugins.usePlugin)(props.pluginType, props.kind);
|
|
52
90
|
if (error) {
|
|
53
|
-
return (0,
|
|
91
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
92
|
+
children: [
|
|
93
|
+
"Error: ",
|
|
94
|
+
error.message
|
|
95
|
+
]
|
|
96
|
+
});
|
|
54
97
|
}
|
|
55
98
|
if (isLoading) {
|
|
56
|
-
return (0,
|
|
99
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
100
|
+
children: "Loading"
|
|
101
|
+
});
|
|
57
102
|
}
|
|
58
|
-
return (0,
|
|
103
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
104
|
+
children: [
|
|
105
|
+
"Has plugin: ",
|
|
106
|
+
(plugin !== undefined).toString()
|
|
107
|
+
]
|
|
108
|
+
});
|
|
59
109
|
};
|
|
60
110
|
// A helper component for testing the PluginRegistry metadata APIs by calling useListPluginMetadata
|
|
61
|
-
const MetadataConsumer = (props)
|
|
62
|
-
const { pluginMetadata, isLoading, error
|
|
111
|
+
const MetadataConsumer = (props)=>{
|
|
112
|
+
const { data: pluginMetadata , isLoading , error } = (0, _plugins.useListPluginMetadata)(props.pluginType);
|
|
63
113
|
if (error) {
|
|
64
|
-
return (0,
|
|
114
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
115
|
+
children: [
|
|
116
|
+
"Error: ",
|
|
117
|
+
error.message
|
|
118
|
+
]
|
|
119
|
+
});
|
|
65
120
|
}
|
|
66
121
|
if (isLoading) {
|
|
67
|
-
return (0,
|
|
122
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
123
|
+
children: "Loading"
|
|
124
|
+
});
|
|
68
125
|
}
|
|
69
126
|
if (pluginMetadata === undefined) {
|
|
70
127
|
return null;
|
|
71
128
|
}
|
|
72
|
-
return (
|
|
129
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("table", {
|
|
130
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)("tbody", {
|
|
131
|
+
children: pluginMetadata.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsxs)("tr", {
|
|
132
|
+
children: [
|
|
133
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
134
|
+
children: item.pluginType
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
137
|
+
children: item.kind
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
140
|
+
children: item.display.name
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
143
|
+
children: item.display.description
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}, item.kind))
|
|
147
|
+
})
|
|
148
|
+
});
|
|
73
149
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,20 +10,20 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./plugin-registry-model"), exports);
|
|
18
|
+
_exportStar(require("./PluginRegistry"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,27 +10,30 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "usePluginIndexes", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>usePluginIndexes
|
|
20
|
+
});
|
|
21
|
+
const _core = require("@perses-dev/core");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _cacheKeys = require("../../utils/cache-keys");
|
|
22
24
|
function usePluginIndexes(getInstalledPlugins) {
|
|
23
25
|
// Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop
|
|
24
26
|
// and we want a stable reference for the callback below)
|
|
25
|
-
const createPluginIndexes = (0,
|
|
27
|
+
const createPluginIndexes = (0, _core.useEvent)(async ()=>{
|
|
26
28
|
const installedPlugins = await getInstalledPlugins();
|
|
27
29
|
// Create the two indexes from the installed plugins
|
|
28
30
|
const pluginResourcesByTypeAndKind = new Map();
|
|
29
31
|
const pluginMetadataByType = new Map();
|
|
30
|
-
for (const resource of installedPlugins)
|
|
31
|
-
for (const pluginMetadata of resource.spec.plugins)
|
|
32
|
-
const { pluginType, kind
|
|
32
|
+
for (const resource of installedPlugins){
|
|
33
|
+
for (const pluginMetadata of resource.spec.plugins){
|
|
34
|
+
const { pluginType , kind } = pluginMetadata;
|
|
33
35
|
// Index the plugin by type and kind to point at the module that contains it
|
|
34
|
-
const key = (0,
|
|
36
|
+
const key = (0, _cacheKeys.getTypeAndKindKey)(pluginType, kind);
|
|
35
37
|
if (pluginResourcesByTypeAndKind.has(key)) {
|
|
36
38
|
console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);
|
|
37
39
|
}
|
|
@@ -47,21 +49,22 @@ function usePluginIndexes(getInstalledPlugins) {
|
|
|
47
49
|
}
|
|
48
50
|
return {
|
|
49
51
|
pluginResourcesByTypeAndKind,
|
|
50
|
-
pluginMetadataByType
|
|
52
|
+
pluginMetadataByType
|
|
51
53
|
};
|
|
52
54
|
});
|
|
53
55
|
// De-dupe creating plugin indexes (i.e. requests to get installed plugins)
|
|
54
|
-
const pluginIndexesCache = (0,
|
|
55
|
-
const getPluginIndexes = (0,
|
|
56
|
+
const pluginIndexesCache = (0, _react.useRef)(undefined);
|
|
57
|
+
const getPluginIndexes = (0, _react.useCallback)(()=>{
|
|
56
58
|
let request = pluginIndexesCache.current;
|
|
57
59
|
if (request === undefined) {
|
|
58
60
|
request = createPluginIndexes();
|
|
59
61
|
pluginIndexesCache.current = request;
|
|
60
62
|
// Remove failed requests from the cache so they can potentially be retried
|
|
61
|
-
request.catch(()
|
|
63
|
+
request.catch(()=>pluginIndexesCache.current === undefined);
|
|
62
64
|
}
|
|
63
65
|
return request;
|
|
64
|
-
}, [
|
|
66
|
+
}, [
|
|
67
|
+
createPluginIndexes
|
|
68
|
+
]);
|
|
65
69
|
return getPluginIndexes;
|
|
66
70
|
}
|
|
67
|
-
exports.usePluginIndexes = usePluginIndexes;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,15 +10,26 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
PluginRegistryContext: ()=>PluginRegistryContext,
|
|
25
|
+
usePluginRegistry: ()=>usePluginRegistry
|
|
26
|
+
});
|
|
27
|
+
const _react = require("react");
|
|
28
|
+
const PluginRegistryContext = (0, _react.createContext)(undefined);
|
|
18
29
|
function usePluginRegistry() {
|
|
19
|
-
const ctx = (0,
|
|
30
|
+
const ctx = (0, _react.useContext)(PluginRegistryContext);
|
|
20
31
|
if (ctx === undefined) {
|
|
21
32
|
throw new Error('PluginRegistryContext not found. Did you forget a provider?');
|
|
22
33
|
}
|
|
23
34
|
return ctx;
|
|
24
35
|
}
|
|
25
|
-
exports.usePluginRegistry = usePluginRegistry;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,16 +10,27 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
BertPanel1: ()=>BertPanel1,
|
|
25
|
+
BertPanel2: ()=>BertPanel2
|
|
26
|
+
});
|
|
27
|
+
const BertPanel1 = {
|
|
28
|
+
PanelComponent: ()=>null,
|
|
29
|
+
OptionsEditorComponent: ()=>null,
|
|
30
|
+
createInitialOptions: ()=>({})
|
|
21
31
|
};
|
|
22
|
-
|
|
23
|
-
PanelComponent: ()
|
|
24
|
-
OptionsEditorComponent: ()
|
|
25
|
-
createInitialOptions: ()
|
|
32
|
+
const BertPanel2 = {
|
|
33
|
+
PanelComponent: ()=>null,
|
|
34
|
+
OptionsEditorComponent: ()=>null,
|
|
35
|
+
createInitialOptions: ()=>({})
|
|
26
36
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,13 +10,26 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "ErnieVariable", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>ErnieVariable
|
|
20
|
+
});
|
|
16
21
|
const data = [
|
|
17
|
-
{
|
|
18
|
-
|
|
22
|
+
{
|
|
23
|
+
label: 'Grover',
|
|
24
|
+
value: 'Grover'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: 'Snuffleupagus',
|
|
28
|
+
value: 'Snuffleupagus'
|
|
29
|
+
}
|
|
19
30
|
];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
const ErnieVariable = {
|
|
32
|
+
getVariableOptions: async ()=>({
|
|
33
|
+
data
|
|
34
|
+
})
|
|
23
35
|
};
|