@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.
Files changed (149) hide show
  1. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +43 -29
  2. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +114 -38
  3. package/dist/cjs/components/PluginRegistry/index.js +17 -18
  4. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +23 -20
  5. package/dist/cjs/components/PluginRegistry/plugin-registry-model.js +17 -7
  6. package/dist/cjs/components/PluginRegistry/test-plugins/bert/index.js +22 -12
  7. package/dist/cjs/components/PluginRegistry/test-plugins/ernie/index.js +20 -8
  8. package/dist/cjs/components/PluginRegistry/test-plugins/index.js +59 -39
  9. package/dist/cjs/components/index.js +17 -20
  10. package/dist/cjs/index.js +19 -20
  11. package/dist/cjs/model/datasource.js +16 -0
  12. package/dist/cjs/model/index.js +21 -21
  13. package/dist/cjs/model/panels.js +4 -21
  14. package/dist/cjs/model/plugins.js +4 -7
  15. package/dist/cjs/model/time-series-queries.js +16 -0
  16. package/dist/cjs/model/variables.js +5 -17
  17. package/dist/cjs/model/visual-editing.js +10 -2
  18. package/dist/cjs/runtime/datasources.js +20 -13
  19. package/dist/cjs/runtime/index.js +22 -21
  20. package/dist/cjs/runtime/plugins.js +25 -22
  21. package/dist/cjs/runtime/query-string.js +17 -10
  22. package/dist/cjs/runtime/template-variables.js +34 -16
  23. package/dist/cjs/runtime/time-range.js +17 -10
  24. package/dist/cjs/runtime/time-series-queries.js +58 -0
  25. package/dist/cjs/test/render.js +32 -13
  26. package/dist/cjs/test/setup-tests.js +4 -10
  27. package/dist/cjs/utils/cache-keys.js +8 -7
  28. package/dist/components/PluginRegistry/PluginRegistry.js +81 -1
  29. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
  30. package/dist/components/PluginRegistry/PluginRegistry.test.js +142 -1
  31. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -0
  32. package/dist/components/PluginRegistry/index.js +16 -1
  33. package/dist/components/PluginRegistry/index.js.map +1 -0
  34. package/dist/components/PluginRegistry/plugin-indexes.js +66 -1
  35. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
  36. package/dist/components/PluginRegistry/plugin-registry-model.d.ts +1 -2
  37. package/dist/components/PluginRegistry/plugin-registry-model.d.ts.map +1 -1
  38. package/dist/components/PluginRegistry/plugin-registry-model.js +23 -1
  39. package/dist/components/PluginRegistry/plugin-registry-model.js.map +1 -0
  40. package/dist/components/PluginRegistry/test-plugins/bert/index.js +25 -1
  41. package/dist/components/PluginRegistry/test-plugins/bert/index.js.map +1 -0
  42. package/dist/components/PluginRegistry/test-plugins/ernie/index.d.ts.map +1 -1
  43. package/dist/components/PluginRegistry/test-plugins/ernie/index.js +30 -1
  44. package/dist/components/PluginRegistry/test-plugins/ernie/index.js.map +1 -0
  45. package/dist/components/PluginRegistry/test-plugins/index.js +35 -1
  46. package/dist/components/PluginRegistry/test-plugins/index.js.map +1 -0
  47. package/dist/components/index.d.ts +1 -3
  48. package/dist/components/index.d.ts.map +1 -1
  49. package/dist/components/index.js +15 -1
  50. package/dist/components/index.js.map +1 -0
  51. package/dist/index.js +17 -1
  52. package/dist/index.js.map +1 -0
  53. package/dist/model/datasource.d.ts +9 -0
  54. package/dist/model/datasource.d.ts.map +1 -0
  55. package/dist/model/datasource.js +15 -0
  56. package/dist/model/datasource.js.map +1 -0
  57. package/dist/model/index.d.ts +2 -1
  58. package/dist/model/index.d.ts.map +1 -1
  59. package/dist/model/index.js +20 -1
  60. package/dist/model/index.js.map +1 -0
  61. package/dist/model/panels.d.ts +7 -11
  62. package/dist/model/panels.d.ts.map +1 -1
  63. package/dist/model/panels.js +15 -1
  64. package/dist/model/panels.js.map +1 -0
  65. package/dist/model/plugins.d.ts +16 -25
  66. package/dist/model/plugins.d.ts.map +1 -1
  67. package/dist/model/plugins.js +15 -1
  68. package/dist/model/plugins.js.map +1 -0
  69. package/dist/model/time-series-queries.d.ts +28 -0
  70. package/dist/model/time-series-queries.d.ts.map +1 -0
  71. package/dist/model/time-series-queries.js +15 -0
  72. package/dist/model/time-series-queries.js.map +1 -0
  73. package/dist/model/variables.d.ts +16 -11
  74. package/dist/model/variables.d.ts.map +1 -1
  75. package/dist/model/variables.js +15 -1
  76. package/dist/model/variables.js.map +1 -0
  77. package/dist/model/visual-editing.d.ts +5 -6
  78. package/dist/model/visual-editing.d.ts.map +1 -1
  79. package/dist/model/visual-editing.js +15 -1
  80. package/dist/model/visual-editing.js.map +1 -0
  81. package/dist/runtime/datasources.d.ts +5 -9
  82. package/dist/runtime/datasources.d.ts.map +1 -1
  83. package/dist/runtime/datasources.js +23 -1
  84. package/dist/runtime/datasources.js.map +1 -0
  85. package/dist/runtime/index.d.ts +3 -1
  86. package/dist/runtime/index.d.ts.map +1 -1
  87. package/dist/runtime/index.js +20 -1
  88. package/dist/runtime/index.js.map +1 -0
  89. package/dist/runtime/plugins.d.ts +5 -14
  90. package/dist/runtime/plugins.d.ts.map +1 -1
  91. package/dist/runtime/plugins.js +33 -1
  92. package/dist/runtime/plugins.js.map +1 -0
  93. package/dist/runtime/query-string.js +25 -1
  94. package/dist/runtime/query-string.js.map +1 -0
  95. package/dist/runtime/template-variables.d.ts +10 -1
  96. package/dist/runtime/template-variables.d.ts.map +1 -1
  97. package/dist/runtime/template-variables.js +44 -1
  98. package/dist/runtime/template-variables.js.map +1 -0
  99. package/dist/runtime/time-range.js +25 -1
  100. package/dist/runtime/time-range.js.map +1 -0
  101. package/dist/runtime/time-series-queries.d.ts +14 -0
  102. package/dist/runtime/time-series-queries.d.ts.map +1 -0
  103. package/dist/runtime/time-series-queries.js +54 -0
  104. package/dist/runtime/time-series-queries.js.map +1 -0
  105. package/dist/test/render.d.ts.map +1 -1
  106. package/dist/test/render.js +42 -1
  107. package/dist/test/render.js.map +1 -0
  108. package/dist/test/setup-tests.d.ts.map +1 -1
  109. package/dist/test/setup-tests.js +16 -1
  110. package/dist/test/setup-tests.js.map +1 -0
  111. package/dist/utils/cache-keys.js +19 -1
  112. package/dist/utils/cache-keys.js.map +1 -0
  113. package/package.json +11 -8
  114. package/dist/cjs/components/PluginBoundary.js +0 -14
  115. package/dist/cjs/components/PluginLoadingBoundary/PluginLoader.js +0 -39
  116. package/dist/cjs/components/PluginLoadingBoundary/PluginLoadingBoundary.js +0 -85
  117. package/dist/cjs/components/PluginLoadingBoundary/index.js +0 -29
  118. package/dist/cjs/components/PluginRegistry/legacy/PluginRegistry.js +0 -57
  119. package/dist/cjs/components/PluginRegistry/legacy/index.js +0 -29
  120. package/dist/cjs/components/PluginRegistry/legacy/registry-state.js +0 -97
  121. package/dist/cjs/components/PluginRegistry/test-plugins/bert/plugin.json +0 -32
  122. package/dist/cjs/components/PluginRegistry/test-plugins/ernie/plugin.json +0 -24
  123. package/dist/cjs/model/graph-queries.js +0 -28
  124. package/dist/components/PluginBoundary.d.ts +0 -13
  125. package/dist/components/PluginBoundary.d.ts.map +0 -1
  126. package/dist/components/PluginBoundary.js +0 -1
  127. package/dist/components/PluginLoadingBoundary/PluginLoader.d.ts +0 -11
  128. package/dist/components/PluginLoadingBoundary/PluginLoader.d.ts.map +0 -1
  129. package/dist/components/PluginLoadingBoundary/PluginLoader.js +0 -1
  130. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts +0 -27
  131. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts.map +0 -1
  132. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.js +0 -1
  133. package/dist/components/PluginLoadingBoundary/index.d.ts +0 -2
  134. package/dist/components/PluginLoadingBoundary/index.d.ts.map +0 -1
  135. package/dist/components/PluginLoadingBoundary/index.js +0 -1
  136. package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts +0 -29
  137. package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts.map +0 -1
  138. package/dist/components/PluginRegistry/legacy/PluginRegistry.js +0 -1
  139. package/dist/components/PluginRegistry/legacy/index.d.ts +0 -2
  140. package/dist/components/PluginRegistry/legacy/index.d.ts.map +0 -1
  141. package/dist/components/PluginRegistry/legacy/index.js +0 -1
  142. package/dist/components/PluginRegistry/legacy/registry-state.d.ts +0 -18
  143. package/dist/components/PluginRegistry/legacy/registry-state.d.ts.map +0 -1
  144. package/dist/components/PluginRegistry/legacy/registry-state.js +0 -1
  145. package/dist/components/PluginRegistry/test-plugins/bert/plugin.json +0 -32
  146. package/dist/components/PluginRegistry/test-plugins/ernie/plugin.json +0 -24
  147. package/dist/model/graph-queries.d.ts +0 -36
  148. package/dist/model/graph-queries.d.ts.map +0 -1
  149. 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
- const core_1 = require("@perses-dev/core");
18
- const react_1 = require("react");
19
- const cache_keys_1 = require("../../utils/cache-keys");
20
- const plugin_indexes_1 = require("./plugin-indexes");
21
- const plugin_registry_model_1 = require("./plugin-registry-model");
22
- /**
23
- * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
24
- * querying the metadata about them.
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 } = props;
28
- const getPluginIndexes = (0, plugin_indexes_1.usePluginIndexes)(getInstalledPlugins);
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, react_1.useRef)(new Map());
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, core_1.useEvent)((resource) => {
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(() => importCache.current.delete(resource));
40
+ request.catch(()=>importCache.current.delete(resource));
40
41
  }
41
42
  return request;
42
43
  });
43
- const getPlugin = (0, react_1.useCallback)(async (pluginType, kind) => {
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, cache_keys_1.getTypeAndKindKey)(pluginType, kind);
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 = (await loadPluginModule(resource));
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
- }, [getPluginIndexes, loadPluginModule]);
61
- const listPluginMetadata = (0, react_1.useCallback)(async (pluginType) => {
62
- var _a;
61
+ }, [
62
+ getPluginIndexes,
63
+ loadPluginModule
64
+ ]);
65
+ const listPluginMetadata = (0, _react.useCallback)(async (pluginType)=>{
63
66
  const pluginIndexes = await getPluginIndexes();
64
- return (_a = pluginIndexes.pluginMetadataByType.get(pluginType)) !== null && _a !== void 0 ? _a : [];
65
- }, [getPluginIndexes]);
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, react_1.useMemo)(() => ({ getPlugin, listPluginMetadata }), [getPlugin, listPluginMetadata]);
68
- return (0, jsx_runtime_1.jsx)(plugin_registry_model_1.PluginRegistryContext.Provider, { value: context, children: children });
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", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("@testing-library/react");
5
- const plugins_1 = require("../../runtime/plugins");
6
- const render_1 = require("../../test/render");
7
- const PluginRegistry_1 = require("./PluginRegistry");
8
- const test_plugins_1 = require("./test-plugins");
9
- describe('PluginRegistry', () => {
10
- const renderPluginRegistry = (children) => {
11
- (0, render_1.renderWithContext)((0, jsx_runtime_1.jsx)(PluginRegistry_1.PluginRegistry, { ...test_plugins_1.testRegistryProps, children: children }));
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, jsx_runtime_1.jsx)(PluginConsumer, { pluginType: "Variable", kind: "ErnieVariable" }));
15
- const hasPlugin = await react_1.screen.findByText('Has plugin: true', undefined, { timeout: 3000 });
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, jsx_runtime_1.jsx)(PluginConsumer, { pluginType: "GraphQuery", kind: "NotInstalled" }));
21
- const error = await react_1.screen.findByText(/error:/i);
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, jsx_runtime_1.jsx)(PluginConsumer, { pluginType: "Variable", kind: "MissingErnieVariable" }));
28
- const error = await react_1.screen.findByText(/error:/i);
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, jsx_runtime_1.jsx)(MetadataConsumer, { pluginType: "Variable" }));
35
- const table = await react_1.screen.findByRole('table');
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 = react_1.screen.getAllByRole('row');
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 GraphQuery plugins in any of the test modules
42
- renderPluginRegistry((0, jsx_runtime_1.jsx)(MetadataConsumer, { pluginType: "GraphQuery" }));
43
- const table = await react_1.screen.findByRole('table');
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 = react_1.screen.queryAllByRole('row');
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 } = (0, plugins_1.usePlugin)(props.pluginType, props.kind);
88
+ const PluginConsumer = (props)=>{
89
+ const { data: plugin , isLoading , error } = (0, _plugins.usePlugin)(props.pluginType, props.kind);
52
90
  if (error) {
53
- return (0, jsx_runtime_1.jsxs)("div", { children: ["Error: ", error.message] });
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, jsx_runtime_1.jsx)("div", { children: "Loading" });
99
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
100
+ children: "Loading"
101
+ });
57
102
  }
58
- return (0, jsx_runtime_1.jsxs)("div", { children: ["Has plugin: ", (plugin !== undefined).toString()] });
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 } = (0, plugins_1.useListPluginMetadata)(props.pluginType);
111
+ const MetadataConsumer = (props)=>{
112
+ const { data: pluginMetadata , isLoading , error } = (0, _plugins.useListPluginMetadata)(props.pluginType);
63
113
  if (error) {
64
- return (0, jsx_runtime_1.jsxs)("div", { children: ["Error: ", error.message] });
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, jsx_runtime_1.jsx)("div", { children: "Loading" });
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 ((0, jsx_runtime_1.jsx)("table", { children: (0, jsx_runtime_1.jsx)("tbody", { children: pluginMetadata.map((item) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: item.pluginType }), (0, jsx_runtime_1.jsx)("td", { children: item.kind }), (0, jsx_runtime_1.jsx)("td", { children: item.display.name }), (0, jsx_runtime_1.jsx)("td", { children: item.display.description })] }, item.kind))) }) }));
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- __exportStar(require("./plugin-registry-model"), exports);
30
- __exportStar(require("./PluginRegistry"), exports);
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.usePluginIndexes = void 0;
16
- const core_1 = require("@perses-dev/core");
17
- const react_1 = require("react");
18
- const cache_keys_1 = require("../../utils/cache-keys");
19
- /**
20
- * Returns an async callback for getting indexes of the installed plugin data.
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, core_1.useEvent)(async () => {
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 } = pluginMetadata;
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, cache_keys_1.getTypeAndKindKey)(pluginType, kind);
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, react_1.useRef)(undefined);
55
- const getPluginIndexes = (0, react_1.useCallback)(() => {
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(() => pluginIndexesCache.current === undefined);
63
+ request.catch(()=>pluginIndexesCache.current === undefined);
62
64
  }
63
65
  return request;
64
- }, [createPluginIndexes]);
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.usePluginRegistry = exports.PluginRegistryContext = void 0;
16
- const react_1 = require("react");
17
- exports.PluginRegistryContext = (0, react_1.createContext)(undefined);
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, react_1.useContext)(exports.PluginRegistryContext);
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BertPanel2 = exports.BertPanel1 = void 0;
16
- // Dummy plugins to test loading
17
- exports.BertPanel1 = {
18
- PanelComponent: () => null,
19
- OptionsEditorComponent: () => null,
20
- createInitialOptions: () => ({}),
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
- exports.BertPanel2 = {
23
- PanelComponent: () => null,
24
- OptionsEditorComponent: () => null,
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ErnieVariable = void 0;
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
- { label: 'Grover', value: 'Grover' },
18
- { label: 'Snuffleupagus', value: 'Snuffleupagus' },
22
+ {
23
+ label: 'Grover',
24
+ value: 'Grover'
25
+ },
26
+ {
27
+ label: 'Snuffleupagus',
28
+ value: 'Snuffleupagus'
29
+ }
19
30
  ];
20
- // Dummy plugin to test loading
21
- exports.ErnieVariable = {
22
- useVariableOptions: () => ({ loading: false, error: undefined, data }),
31
+ const ErnieVariable = {
32
+ getVariableOptions: async ()=>({
33
+ data
34
+ })
23
35
  };