@perses-dev/plugin-system 0.50.1 → 0.51.0-beta.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 (176) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -71
  2. package/dist/cjs/components/DatasourceSelect.js +8 -13
  3. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +534 -0
  4. package/dist/cjs/components/HTTPSettingsEditor/index.js +30 -0
  5. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
  6. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +1 -1
  7. package/dist/cjs/components/MetricLabelInput/index.js +1 -1
  8. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
  9. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
  10. package/dist/cjs/components/PluginEditor/PluginEditor.js +10 -6
  11. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +4 -5
  12. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +7 -8
  13. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +7 -10
  14. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
  15. package/dist/cjs/components/ProjectSelect.js +2 -3
  16. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
  17. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
  18. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  19. package/dist/cjs/components/Variables/variable-model.js +4 -7
  20. package/dist/cjs/components/index.js +1 -0
  21. package/dist/cjs/index.js +1 -0
  22. package/dist/cjs/model/explore.js +16 -0
  23. package/dist/cjs/remote/PersesPlugin.types.js +16 -0
  24. package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
  25. package/dist/cjs/remote/PluginRuntime.js +267 -0
  26. package/dist/cjs/remote/index.js +31 -0
  27. package/dist/cjs/remote/remotePluginLoader.js +61 -0
  28. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
  29. package/dist/cjs/runtime/DataQueriesProvider/model.js +4 -7
  30. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
  31. package/dist/cjs/runtime/builtin-variables.js +1 -1
  32. package/dist/cjs/runtime/datasources.js +3 -3
  33. package/dist/cjs/runtime/plugin-registry.js +5 -6
  34. package/dist/cjs/runtime/time-series-queries.js +11 -18
  35. package/dist/cjs/runtime/trace-queries.js +1 -2
  36. package/dist/cjs/runtime/variables.js +10 -28
  37. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  38. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -67
  39. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  40. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  41. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
  42. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  43. package/dist/cjs/test/render.js +1 -2
  44. package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
  45. package/dist/cjs/utils/variables.js +1 -1
  46. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  47. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -30
  48. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  49. package/dist/components/DatasourceSelect.d.ts +2 -2
  50. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  51. package/dist/components/DatasourceSelect.js +8 -13
  52. package/dist/components/DatasourceSelect.js.map +1 -1
  53. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  54. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  55. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +480 -0
  56. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  57. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  58. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  59. package/dist/components/HTTPSettingsEditor/index.js +15 -0
  60. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  61. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
  62. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  63. package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
  64. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
  65. package/dist/components/MetricLabelInput/index.js +1 -1
  66. package/dist/components/MetricLabelInput/index.js.map +1 -1
  67. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  68. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
  69. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  70. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
  71. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  72. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  73. package/dist/components/PluginEditor/PluginEditor.js +10 -6
  74. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  75. package/dist/components/PluginEditor/plugin-editor-api.js +4 -5
  76. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  77. package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -8
  78. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.js +7 -10
  80. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  81. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  82. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  83. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  84. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  85. package/dist/components/ProjectSelect.js +2 -3
  86. package/dist/components/ProjectSelect.js.map +1 -1
  87. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
  88. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  89. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
  90. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  91. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  92. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  93. package/dist/components/Variables/variable-model.js +4 -7
  94. package/dist/components/Variables/variable-model.js.map +1 -1
  95. package/dist/components/index.d.ts +1 -0
  96. package/dist/components/index.d.ts.map +1 -1
  97. package/dist/components/index.js +1 -0
  98. package/dist/components/index.js.map +1 -1
  99. package/dist/index.d.ts +1 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +1 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/model/explore.d.ts +13 -0
  104. package/dist/model/explore.d.ts.map +1 -0
  105. package/dist/model/explore.js +17 -0
  106. package/dist/model/explore.js.map +1 -0
  107. package/dist/model/panels.d.ts +13 -3
  108. package/dist/model/panels.d.ts.map +1 -1
  109. package/dist/model/panels.js.map +1 -1
  110. package/dist/model/plugins.d.ts +31 -17
  111. package/dist/model/plugins.d.ts.map +1 -1
  112. package/dist/model/plugins.js.map +1 -1
  113. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  114. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  115. package/dist/remote/PersesPlugin.types.js +15 -0
  116. package/dist/remote/PersesPlugin.types.js.map +1 -0
  117. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  118. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  119. package/dist/remote/PluginLoaderComponent.js +67 -0
  120. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  121. package/dist/remote/PluginRuntime.d.ts +11 -0
  122. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  123. package/dist/remote/PluginRuntime.js +202 -0
  124. package/dist/remote/PluginRuntime.js.map +1 -0
  125. package/dist/remote/index.d.ts +3 -0
  126. package/dist/remote/index.d.ts.map +1 -0
  127. package/dist/remote/index.js +16 -0
  128. package/dist/remote/index.js.map +1 -0
  129. package/dist/remote/remotePluginLoader.d.ts +3 -0
  130. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  131. package/dist/remote/remotePluginLoader.js +53 -0
  132. package/dist/remote/remotePluginLoader.js.map +1 -0
  133. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
  134. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  135. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  136. package/dist/runtime/DataQueriesProvider/model.js +4 -7
  137. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  138. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
  139. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  140. package/dist/runtime/builtin-variables.js +1 -1
  141. package/dist/runtime/builtin-variables.js.map +1 -1
  142. package/dist/runtime/datasources.d.ts +2 -2
  143. package/dist/runtime/datasources.js +3 -3
  144. package/dist/runtime/datasources.js.map +1 -1
  145. package/dist/runtime/plugin-registry.d.ts +6 -6
  146. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  147. package/dist/runtime/plugin-registry.js +5 -6
  148. package/dist/runtime/plugin-registry.js.map +1 -1
  149. package/dist/runtime/time-series-queries.js +11 -18
  150. package/dist/runtime/time-series-queries.js.map +1 -1
  151. package/dist/runtime/trace-queries.js +1 -2
  152. package/dist/runtime/trace-queries.js.map +1 -1
  153. package/dist/runtime/variables.js +10 -28
  154. package/dist/runtime/variables.js.map +1 -1
  155. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  156. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  157. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  158. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
  159. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  160. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  161. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  162. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  163. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  164. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
  165. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -1
  166. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  167. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  168. package/dist/test/render.js +1 -2
  169. package/dist/test/render.js.map +1 -1
  170. package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
  171. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  172. package/dist/test-utils/mock-plugin-registry.js +10 -10
  173. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  174. package/dist/utils/variables.js +1 -1
  175. package/dist/utils/variables.js.map +1 -1
  176. package/package.json +6 -5
@@ -1,32 +1,45 @@
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';
1
+ import { UnknownSpec } from '@perses-dev/core';
5
2
  import { DatasourcePlugin } from './datasource';
3
+ import { PanelPlugin } from './panels';
6
4
  import { Plugin } from './plugin-base';
5
+ import { TimeSeriesQueryPlugin } from './time-series-queries';
7
6
  import { TraceQueryPlugin } from './trace-queries';
8
- /**
9
- * Information about a module/package that contains plugins.
10
- */
11
- export interface PluginModuleResource {
12
- kind: 'PluginModule';
13
- metadata: Metadata;
14
- spec: PluginSpec;
15
- }
16
- export interface PluginSpec {
7
+ import { VariablePlugin } from './variables';
8
+ import { ExplorePlugin } from './explore';
9
+ export interface PluginModuleSpec {
17
10
  plugins: PluginMetadata[];
18
11
  }
12
+ export interface PluginMetadataWithModule extends PluginMetadata {
13
+ module: PluginModuleMetadata;
14
+ }
19
15
  /**
20
16
  * Metadata about an individual plugin that's part of a PluginModule.
21
17
  */
22
18
  export interface PluginMetadata {
23
- pluginType: PluginType;
24
- kind: string;
25
- display: {
19
+ kind: PluginType;
20
+ spec: {
26
21
  name: string;
27
- description?: string;
22
+ display: {
23
+ name: string;
24
+ description?: string;
25
+ };
28
26
  };
29
27
  }
28
+ /**
29
+ * Metadata about a module/package that contains plugins.
30
+ */
31
+ export interface PluginModuleMetadata {
32
+ name: string;
33
+ version: string;
34
+ }
35
+ /**
36
+ * Information about a module/package that contains plugins.
37
+ */
38
+ export interface PluginModuleResource {
39
+ kind: 'PluginModule';
40
+ metadata: PluginModuleMetadata;
41
+ spec: PluginModuleSpec;
42
+ }
30
43
  /**
31
44
  * All supported plugin types. A plugin's implementation must extend from `Plugin<UnknownSpec>` to be considered a valid
32
45
  * `PluginType`.
@@ -44,6 +57,7 @@ export interface SupportedPlugins {
44
57
  TimeSeriesQuery: TimeSeriesQueryPlugin;
45
58
  TraceQuery: TraceQueryPlugin;
46
59
  Datasource: DatasourcePlugin;
60
+ Explore: ExplorePlugin;
47
61
  }
48
62
  /**
49
63
  * The implementation for a given plugin type.
@@ -1 +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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,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;IAC7B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,IAAI,SAAS,UAAU,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAEnF;;GAEG;AACH,KAAK,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AACvD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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';\nimport { TraceQueryPlugin } from './trace-queries';\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 TraceQuery: TraceQueryPlugin;\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 */\ntype PluginKinds = Partial<Record<PluginType, string>>;\nexport type DefaultPluginKinds = Required<Pick<PluginKinds, 'TimeSeriesQuery'>> & Omit<PluginKinds, 'TimeSeriesQuery'>;\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;AAiEjC,WAAuH"}
1
+ {"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/core';\nimport { DatasourcePlugin } from './datasource';\nimport { PanelPlugin } from './panels';\nimport { Plugin } from './plugin-base';\nimport { TimeSeriesQueryPlugin } from './time-series-queries';\nimport { TraceQueryPlugin } from './trace-queries';\nimport { VariablePlugin } from './variables';\nimport { ExplorePlugin } from './explore';\n\nexport interface PluginModuleSpec {\n plugins: PluginMetadata[];\n}\n\nexport interface PluginMetadataWithModule extends PluginMetadata {\n module: PluginModuleMetadata;\n}\n\n/**\n * Metadata about an individual plugin that's part of a PluginModule.\n */\nexport interface PluginMetadata {\n kind: PluginType;\n spec: {\n name: string;\n display: {\n name: string;\n description?: string;\n };\n };\n}\n\n/**\n * Metadata about a module/package that contains plugins.\n */\nexport interface PluginModuleMetadata {\n name: string;\n version: string;\n}\n\n/**\n * Information about a module/package that contains plugins.\n */\nexport interface PluginModuleResource {\n kind: 'PluginModule';\n metadata: PluginModuleMetadata;\n spec: PluginModuleSpec;\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 TraceQuery: TraceQueryPlugin;\n Datasource: DatasourcePlugin;\n Explore: ExplorePlugin;\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 */\ntype PluginKinds = Partial<Record<PluginType, string>>;\nexport type DefaultPluginKinds = Required<Pick<PluginKinds, 'TimeSeriesQuery'>> & Omit<PluginKinds, 'TimeSeriesQuery'>;\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;AAiFjC,WAAuH"}
@@ -0,0 +1,7 @@
1
+ export interface PersesPlugin {
2
+ name: string;
3
+ moduleName: string;
4
+ baseURL?: string;
5
+ }
6
+ export type RemotePluginModule = Record<string, unknown>;
7
+ //# sourceMappingURL=PersesPlugin.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersesPlugin.types.d.ts","sourceRoot":"","sources":["../../src/remote/PersesPlugin.types.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 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=PersesPlugin.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/remote/PersesPlugin.types.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface PersesPlugin {\n name: string;\n moduleName: string;\n baseURL?: string;\n}\n\nexport type RemotePluginModule = Record<string, unknown>;\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;AAQjC,WAAyD"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { PersesPlugin } from './PersesPlugin.types';
3
+ interface PluginLoaderProps<P> {
4
+ plugin: PersesPlugin;
5
+ props?: P;
6
+ field?: string;
7
+ }
8
+ export declare function PluginLoaderComponent<P>({ plugin, props, field }: PluginLoaderProps<P>): JSX.Element | null;
9
+ export {};
10
+ //# sourceMappingURL=PluginLoaderComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginLoaderComponent.d.ts","sourceRoot":"","sources":["../../src/remote/PluginLoaderComponent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAsB,MAAM,sBAAsB,CAAC;AAGxE,UAAU,iBAAiB,CAAC,CAAC;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAYD,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CA2D3G"}
@@ -0,0 +1,67 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */ // Copyright 2024 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 { useEffect, useRef, useState } from 'react';
15
+ import { usePluginRuntime } from './PluginRuntime';
16
+ function PluginContainer({ pluginFn, props }) {
17
+ return pluginFn(props);
18
+ }
19
+ export function PluginLoaderComponent({ plugin, props, field }) {
20
+ const { loadPlugin } = usePluginRuntime({
21
+ plugin
22
+ });
23
+ const [pluginModule, setPluginModule] = useState(null);
24
+ const [error, setError] = useState(null);
25
+ const name = `${plugin.moduleName}-${plugin.name}`;
26
+ const previousPluginName = useRef(name);
27
+ useEffect(()=>{
28
+ previousPluginName.current = name;
29
+ setError(null);
30
+ loadPlugin().then((module)=>{
31
+ setPluginModule(module);
32
+ }).catch((error)=>{
33
+ setPluginModule(null);
34
+ console.error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}:`, error);
35
+ setError(new Error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}`));
36
+ });
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ }, [
39
+ name
40
+ ]);
41
+ if (error) {
42
+ throw error;
43
+ }
44
+ if (!pluginModule) {
45
+ return null;
46
+ }
47
+ let pluginFunction = pluginModule[plugin.name];
48
+ if (field && pluginFunction && typeof pluginFunction === 'object' && field in pluginFunction) {
49
+ pluginFunction = pluginFunction[field];
50
+ }
51
+ if (!pluginFunction) {
52
+ throw new Error(`PluginLoaderComponent: Plugin module ${plugin.moduleName} does not have a ${plugin.name} export`);
53
+ }
54
+ if (typeof pluginFunction !== 'function') {
55
+ throw new Error(`PluginLoaderComponent: Plugin ${plugin.name} export is not a function`);
56
+ }
57
+ // make sure to re mount the plugin when changes, to avoid mismatch in hooks ordering when re rendering
58
+ if (previousPluginName.current !== name) {
59
+ return null;
60
+ }
61
+ return /*#__PURE__*/ _jsx(PluginContainer, {
62
+ pluginFn: pluginFunction,
63
+ props: props
64
+ }, name);
65
+ }
66
+
67
+ //# sourceMappingURL=PluginLoaderComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/remote/PluginLoaderComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useEffect, useRef, useState } from 'react';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\nimport { usePluginRuntime } from './PluginRuntime';\n\ninterface PluginLoaderProps<P> {\n plugin: PersesPlugin;\n props?: P;\n field?: string;\n}\n\nfunction PluginContainer<P>({\n pluginFn,\n props,\n}: {\n pluginFn: (props: P | undefined) => JSX.Element;\n props: P | undefined;\n}): JSX.Element {\n return pluginFn(props);\n}\n\nexport function PluginLoaderComponent<P>({ plugin, props, field }: PluginLoaderProps<P>): JSX.Element | null {\n const { loadPlugin } = usePluginRuntime({ plugin });\n const [pluginModule, setPluginModule] = useState<RemotePluginModule | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n const name = `${plugin.moduleName}-${plugin.name}`;\n const previousPluginName = useRef<string>(name);\n\n useEffect(() => {\n previousPluginName.current = name;\n setError(null);\n\n loadPlugin()\n .then((module) => {\n setPluginModule(module);\n })\n .catch((error) => {\n setPluginModule(null);\n console.error(\n `PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}:`,\n error\n );\n setError(\n new Error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}`)\n );\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [name]);\n\n if (error) {\n throw error;\n }\n\n if (!pluginModule) {\n return null;\n }\n\n let pluginFunction = pluginModule[plugin.name];\n\n if (field && pluginFunction && typeof pluginFunction === 'object' && field in pluginFunction) {\n pluginFunction = (pluginFunction as Record<string, unknown>)[field];\n }\n\n if (!pluginFunction) {\n throw new Error(`PluginLoaderComponent: Plugin module ${plugin.moduleName} does not have a ${plugin.name} export`);\n }\n\n if (typeof pluginFunction !== 'function') {\n throw new Error(`PluginLoaderComponent: Plugin ${plugin.name} export is not a function`);\n }\n\n // make sure to re mount the plugin when changes, to avoid mismatch in hooks ordering when re rendering\n if (previousPluginName.current !== name) {\n return null;\n }\n\n return (\n <PluginContainer key={name} pluginFn={pluginFunction as (props: P | undefined) => JSX.Element} props={props} />\n );\n}\n"],"names":["useEffect","useRef","useState","usePluginRuntime","PluginContainer","pluginFn","props","PluginLoaderComponent","plugin","field","loadPlugin","pluginModule","setPluginModule","error","setError","name","moduleName","previousPluginName","current","then","module","catch","console","Error","pluginFunction"],"mappings":"AAAA,oDAAoD,GACpD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E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CAACe,gBAAgB;QACnB,MAAM,IAAID,MAAM,CAAC,qCAAqC,EAAEf,OAAOQ,UAAU,CAAC,iBAAiB,EAAER,OAAOO,IAAI,CAAC,OAAO,CAAC;IACnH;IAEA,IAAI,OAAOS,mBAAmB,YAAY;QACxC,MAAM,IAAID,MAAM,CAAC,8BAA8B,EAAEf,OAAOO,IAAI,CAAC,yBAAyB,CAAC;IACzF;IAEA,uGAAuG;IACvG,IAAIE,mBAAmBC,OAAO,KAAKH,MAAM;QACvC,OAAO;IACT;IAEA,qBACE,KAACX;QAA2BC,UAAUmB;QAAyDlB,OAAOA;OAAhFS;AAE1B"}
@@ -0,0 +1,11 @@
1
+ import { FederationHost } from '@module-federation/enhanced/runtime';
2
+ import { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';
3
+ export declare const pluginRuntime: FederationHost;
4
+ export declare const loadPlugin: (moduleName: string, pluginName: string, baseURL?: string) => Promise<RemotePluginModule | null>;
5
+ export declare function usePluginRuntime({ plugin }: {
6
+ plugin: PersesPlugin;
7
+ }): {
8
+ pluginRuntime: FederationHost;
9
+ loadPlugin: () => Promise<RemotePluginModule | null>;
10
+ };
11
+ //# sourceMappingURL=PluginRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginRuntime.d.ts","sourceRoot":"","sources":["../../src/remote/PluginRuntime.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAoB,MAAM,qCAAqC,CAAC;AAMvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAExE,eAAO,MAAM,aAAa,gBA8JxB,CAAC;AAgBH,eAAO,MAAM,UAAU,eACT,MAAM,cACN,MAAM,YACR,MAAM,KACf,QAAQ,kBAAkB,GAAG,IAAI,CAInC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG;IACtE,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,EAAE,MAAM,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CACtD,CAKA"}
@@ -0,0 +1,202 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */ // Copyright 2024 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 { init, loadRemote } from '@module-federation/enhanced/runtime';
14
+ import * as ReactQuery from '@tanstack/react-query';
15
+ import React from 'react';
16
+ import ReactDOM from 'react-dom';
17
+ import * as ReactRouterDOM from 'react-router-dom';
18
+ import * as ReactHookForm from 'react-hook-form';
19
+ export const pluginRuntime = init({
20
+ name: '@perses/perses-ui-host',
21
+ remotes: [],
22
+ shared: {
23
+ react: {
24
+ version: React.version,
25
+ lib: ()=>React,
26
+ shareConfig: {
27
+ singleton: true,
28
+ requiredVersion: `^${React.version}`
29
+ }
30
+ },
31
+ 'react-dom': {
32
+ version: '18.3.1',
33
+ lib: ()=>ReactDOM,
34
+ shareConfig: {
35
+ singleton: true,
36
+ requiredVersion: `^18.3.1`
37
+ }
38
+ },
39
+ 'react-router-dom': {
40
+ version: '6.26.0',
41
+ lib: ()=>ReactRouterDOM,
42
+ shareConfig: {
43
+ singleton: true,
44
+ requiredVersion: '^6.26.0'
45
+ }
46
+ },
47
+ '@tanstack/react-query': {
48
+ version: '4.36.1',
49
+ lib: ()=>ReactQuery,
50
+ shareConfig: {
51
+ singleton: true,
52
+ requiredVersion: '^4.36.1'
53
+ }
54
+ },
55
+ 'react-hook-form': {
56
+ version: '7.52.2',
57
+ lib: ()=>ReactHookForm,
58
+ shareConfig: {
59
+ singleton: true,
60
+ requiredVersion: '^7.52.2'
61
+ }
62
+ },
63
+ echarts: {
64
+ version: '5.5.0',
65
+ lib: ()=>require('echarts'),
66
+ shareConfig: {
67
+ singleton: true,
68
+ requiredVersion: '^5.5.0'
69
+ }
70
+ },
71
+ '@perses-dev/components': {
72
+ version: '0.50.0',
73
+ lib: ()=>require('@perses-dev/components'),
74
+ shareConfig: {
75
+ singleton: true,
76
+ requiredVersion: '^0.50.0'
77
+ }
78
+ },
79
+ '@perses-dev/plugin-system': {
80
+ version: '0.50.0',
81
+ lib: ()=>require('@perses-dev/plugin-system'),
82
+ shareConfig: {
83
+ singleton: true,
84
+ requiredVersion: '^0.50.0'
85
+ }
86
+ },
87
+ '@perses-dev/explore': {
88
+ version: '0.50.0',
89
+ lib: ()=>require('@perses-dev/explore'),
90
+ shareConfig: {
91
+ singleton: true,
92
+ requiredVersion: '^0.50.0'
93
+ }
94
+ },
95
+ '@perses-dev/dashboards': {
96
+ version: '0.50.0',
97
+ lib: ()=>require('@perses-dev/dashboards'),
98
+ shareConfig: {
99
+ singleton: true,
100
+ requiredVersion: '^0.50.0'
101
+ }
102
+ },
103
+ // Below are the shared modules that are used by the plugins, this can be part of the SDK
104
+ 'date-fns': {
105
+ version: '2.29.3',
106
+ lib: ()=>require('date-fns'),
107
+ shareConfig: {
108
+ singleton: true,
109
+ requiredVersion: '^2.29.3'
110
+ }
111
+ },
112
+ 'date-fns-tz': {
113
+ version: '1.3.8',
114
+ lib: ()=>require('date-fns-tz'),
115
+ shareConfig: {
116
+ singleton: true,
117
+ requiredVersion: '^1.3.8'
118
+ }
119
+ },
120
+ lodash: {
121
+ version: '4.17.21',
122
+ lib: ()=>require('lodash'),
123
+ shareConfig: {
124
+ singleton: true,
125
+ requiredVersion: '^4.17.21'
126
+ }
127
+ },
128
+ '@emotion/react': {
129
+ version: '11.11.3',
130
+ lib: ()=>require('@emotion/react'),
131
+ shareConfig: {
132
+ singleton: true,
133
+ requiredVersion: '^11.11.3'
134
+ }
135
+ },
136
+ '@emotion/styled': {
137
+ version: '11.11.0',
138
+ lib: ()=>require('@emotion/styled'),
139
+ shareConfig: {
140
+ singleton: true,
141
+ requiredVersion: '^11.11.0'
142
+ }
143
+ },
144
+ '@hookform/resolvers/zod': {
145
+ version: '3.3.4',
146
+ lib: ()=>require('@hookform/resolvers/zod'),
147
+ shareConfig: {
148
+ singleton: true,
149
+ requiredVersion: '^3.3.4'
150
+ }
151
+ },
152
+ 'use-resize-observer': {
153
+ version: '9.1.0',
154
+ lib: ()=>require('use-resize-observer'),
155
+ shareConfig: {
156
+ singleton: true,
157
+ requiredVersion: '^9.1.0'
158
+ }
159
+ },
160
+ 'mdi-material-ui': {
161
+ version: '7.4.0',
162
+ lib: ()=>require('mdi-material-ui'),
163
+ shareConfig: {
164
+ singleton: true,
165
+ requiredVersion: '^7.4.0'
166
+ }
167
+ },
168
+ immer: {
169
+ version: '9.0.15',
170
+ lib: ()=>require('immer'),
171
+ shareConfig: {
172
+ singleton: true,
173
+ requiredVersion: '^9.0.15'
174
+ }
175
+ }
176
+ }
177
+ });
178
+ const registerRemote = (name, baseURL)=>{
179
+ const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === name);
180
+ if (!existingRemote) {
181
+ const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;
182
+ pluginRuntime.registerRemotes([
183
+ {
184
+ name,
185
+ entry: remoteEntryURL,
186
+ alias: name
187
+ }
188
+ ]);
189
+ }
190
+ };
191
+ export const loadPlugin = async (moduleName, pluginName, baseURL)=>{
192
+ registerRemote(moduleName, baseURL);
193
+ return loadRemote(`${moduleName}/${pluginName}`);
194
+ };
195
+ export function usePluginRuntime({ plugin }) {
196
+ return {
197
+ pluginRuntime,
198
+ loadPlugin: ()=>loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL)
199
+ };
200
+ }
201
+
202
+ //# sourceMappingURL=PluginRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/remote/PluginRuntime.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FederationHost, init, loadRemote } from '@module-federation/enhanced/runtime';\nimport * as ReactQuery from '@tanstack/react-query';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport * as ReactRouterDOM from 'react-router-dom';\nimport * as ReactHookForm from 'react-hook-form';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\n\nexport const pluginRuntime = init({\n name: '@perses/perses-ui-host',\n remotes: [], // all remotes are loaded dynamically\n shared: {\n react: {\n version: React.version,\n lib: () => React,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n version: '18.3.1',\n lib: () => ReactDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: `^18.3.1`,\n },\n },\n 'react-router-dom': {\n version: '6.26.0',\n lib: () => ReactRouterDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: '^6.26.0',\n },\n },\n '@tanstack/react-query': {\n version: '4.36.1',\n lib: () => ReactQuery,\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.36.1',\n },\n },\n 'react-hook-form': {\n version: '7.52.2',\n lib: () => ReactHookForm,\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.52.2',\n },\n },\n echarts: {\n version: '5.5.0',\n lib: () => require('echarts'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^5.5.0',\n },\n },\n '@perses-dev/components': {\n version: '0.50.0',\n lib: () => require('@perses-dev/components'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.50.0',\n },\n },\n '@perses-dev/plugin-system': {\n version: '0.50.0',\n lib: () => require('@perses-dev/plugin-system'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.50.0',\n },\n },\n '@perses-dev/explore': {\n version: '0.50.0',\n lib: () => require('@perses-dev/explore'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.50.0',\n },\n },\n '@perses-dev/dashboards': {\n version: '0.50.0',\n lib: () => require('@perses-dev/dashboards'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.50.0',\n },\n },\n // Below are the shared modules that are used by the plugins, this can be part of the SDK\n 'date-fns': {\n version: '2.29.3',\n lib: () => require('date-fns'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^2.29.3',\n },\n },\n 'date-fns-tz': {\n version: '1.3.8',\n lib: () => require('date-fns-tz'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^1.3.8',\n },\n },\n lodash: {\n version: '4.17.21',\n lib: () => require('lodash'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.17.21',\n },\n },\n '@emotion/react': {\n version: '11.11.3',\n lib: () => require('@emotion/react'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.3',\n },\n },\n '@emotion/styled': {\n version: '11.11.0',\n lib: () => require('@emotion/styled'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.0',\n },\n },\n '@hookform/resolvers/zod': {\n version: '3.3.4',\n lib: () => require('@hookform/resolvers/zod'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.3.4',\n },\n },\n 'use-resize-observer': {\n version: '9.1.0',\n lib: () => require('use-resize-observer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^9.1.0',\n },\n },\n 'mdi-material-ui': {\n version: '7.4.0',\n lib: () => require('mdi-material-ui'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.4.0',\n },\n },\n immer: {\n version: '9.0.15',\n lib: () => require('immer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^9.0.15',\n },\n },\n },\n});\n\nconst registerRemote = (name: string, baseURL?: string): void => {\n const existingRemote = pluginRuntime.options.remotes.find((remote) => remote.name === name);\n if (!existingRemote) {\n const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;\n pluginRuntime.registerRemotes([\n {\n name,\n entry: remoteEntryURL,\n alias: name,\n },\n ]);\n }\n};\n\nexport const loadPlugin = async (\n moduleName: string,\n pluginName: string,\n baseURL?: string\n): Promise<RemotePluginModule | null> => {\n registerRemote(moduleName, baseURL);\n\n return loadRemote<RemotePluginModule>(`${moduleName}/${pluginName}`);\n};\n\nexport function usePluginRuntime({ plugin }: { plugin: PersesPlugin }): {\n pluginRuntime: FederationHost;\n loadPlugin: () => Promise<RemotePluginModule | null>;\n} {\n return {\n pluginRuntime,\n loadPlugin: () => loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL),\n };\n}\n"],"names":["init","loadRemote","ReactQuery","React","ReactDOM","ReactRouterDOM","ReactHookForm","pluginRuntime","name","remotes","shared","react","version","lib","shareConfig","singleton","requiredVersion","echarts","require","lodash","immer","registerRemote","baseURL","existingRemote","options","find","remote","remoteEntryURL","registerRemotes","entry","alias","loadPlugin","moduleName","pluginName","usePluginRuntime","plugin"],"mappings":"AAAA,wDAAwD,GACxD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAyBA,IAAI,EAAEC,UAAU,QAAQ,sCAAsC;AACvF,YAAYC,gBAAgB,wBAAwB;AACpD,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,cAAc,YAAY;AACjC,YAAYC,oBAAoB,mBAAmB;AACnD,YAAYC,mBAAmB,kBAAkB;AAGjD,OAAO,MAAMC,gBA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AAe,CAAC;YAC5B;gBACEpB;gBACAqB,OAAOF;gBACPG,OAAOtB;YACT;SACD;IACH;AACF;AAEA,OAAO,MAAMuB,aAAa,OACxBC,YACAC,YACAX;IAEAD,eAAeW,YAAYV;IAE3B,OAAOrB,WAA+B,CAAC,EAAE+B,WAAW,CAAC,EAAEC,WAAW,CAAC;AACrE,EAAE;AAEF,OAAO,SAASC,iBAAiB,EAAEC,MAAM,EAA4B;IAInE,OAAO;QACL5B;QACAwB,YAAY,IAAMA,WAAWI,OAAOH,UAAU,EAAEG,OAAO3B,IAAI,EAAE2B,OAAOb,OAAO;IAC7E;AACF"}
@@ -0,0 +1,3 @@
1
+ export * from './PluginLoaderComponent';
2
+ export * from './remotePluginLoader';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/remote/index.ts"],"names":[],"mappings":"AAaA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,16 @@
1
+ // Copyright 2023 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 './PluginLoaderComponent';
14
+ export * from './remotePluginLoader';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/remote/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './PluginLoaderComponent';\nexport * from './remotePluginLoader';\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,0BAA0B;AACxC,cAAc,uBAAuB"}
@@ -0,0 +1,3 @@
1
+ import { PluginLoader } from '@perses-dev/plugin-system';
2
+ export declare const remotePluginLoader: (baseURL?: string) => PluginLoader;
3
+ //# sourceMappingURL=remotePluginLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remotePluginLoader.d.ts","sourceRoot":"","sources":["../../src/remote/remotePluginLoader.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAwC,MAAM,2BAA2B,CAAC;AA8B/F,eAAO,MAAM,kBAAkB,aAAc,MAAM,KAAG,YAwCrD,CAAC"}
@@ -0,0 +1,53 @@
1
+ // Copyright 2024 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 { loadPlugin } from './PluginRuntime';
14
+ const isPluginMetadata = (plugin)=>{
15
+ return typeof plugin === 'object' && plugin !== null && 'kind' in plugin && 'spec' in plugin && typeof plugin.spec === 'object' && plugin.spec !== null && 'name' in plugin.spec;
16
+ };
17
+ const isPluginModuleResource = (pluginModule)=>{
18
+ return typeof pluginModule === 'object' && pluginModule !== null && 'metadata' in pluginModule && 'spec' in pluginModule && typeof pluginModule.spec === 'object' && pluginModule.spec !== null && 'plugins' in pluginModule.spec && Array.isArray(pluginModule.spec.plugins) && pluginModule.spec.plugins.every(isPluginMetadata);
19
+ };
20
+ export const remotePluginLoader = (baseURL)=>{
21
+ return {
22
+ getInstalledPlugins: async ()=>{
23
+ const pluginsResponse = await fetch(`${baseURL ? baseURL : ''}/api/v1/plugins`);
24
+ const plugins = await pluginsResponse.json();
25
+ let pluginModules = [];
26
+ if (Array.isArray(plugins)) {
27
+ pluginModules = plugins.filter(isPluginModuleResource);
28
+ } else {
29
+ console.error('RemotePluginLoader: Error loading plugins, response is not an array');
30
+ }
31
+ if (!pluginModules.length) {
32
+ console.error('RemotePluginLoader: No valid plugins found');
33
+ }
34
+ return pluginModules;
35
+ },
36
+ importPluginModule: async (resource)=>{
37
+ const pluginModuleName = resource.metadata.name;
38
+ const pluginModule = {};
39
+ for (const plugin of resource.spec.plugins){
40
+ const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name);
41
+ const remotePlugin = remotePluginModule?.[plugin.spec.name];
42
+ if (remotePlugin) {
43
+ pluginModule[plugin.spec.name] = remotePlugin;
44
+ } else {
45
+ console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);
46
+ }
47
+ }
48
+ return pluginModule;
49
+ }
50
+ };
51
+ };
52
+
53
+ //# sourceMappingURL=remotePluginLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/remote/remotePluginLoader.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginLoader, PluginMetadata, PluginModuleResource } from '@perses-dev/plugin-system';\nimport { RemotePluginModule } from './PersesPlugin.types';\nimport { loadPlugin } from './PluginRuntime';\n\nconst isPluginMetadata = (plugin: unknown): plugin is PluginMetadata => {\n return (\n typeof plugin === 'object' &&\n plugin !== null &&\n 'kind' in plugin &&\n 'spec' in plugin &&\n typeof plugin.spec === 'object' &&\n plugin.spec !== null &&\n 'name' in plugin.spec\n );\n};\n\nconst isPluginModuleResource = (pluginModule: unknown): pluginModule is PluginModuleResource => {\n return (\n typeof pluginModule === 'object' &&\n pluginModule !== null &&\n 'metadata' in pluginModule &&\n 'spec' in pluginModule &&\n typeof pluginModule.spec === 'object' &&\n pluginModule.spec !== null &&\n 'plugins' in pluginModule.spec &&\n Array.isArray(pluginModule.spec.plugins) &&\n pluginModule.spec.plugins.every(isPluginMetadata)\n );\n};\n\nexport const remotePluginLoader = (baseURL?: string): PluginLoader => {\n return {\n getInstalledPlugins: async (): Promise<PluginModuleResource[]> => {\n const pluginsResponse = await fetch(`${baseURL ? baseURL : ''}/api/v1/plugins`);\n\n const plugins = await pluginsResponse.json();\n\n let pluginModules: PluginModuleResource[] = [];\n\n if (Array.isArray(plugins)) {\n pluginModules = plugins.filter(isPluginModuleResource);\n } else {\n console.error('RemotePluginLoader: Error loading plugins, response is not an array');\n }\n\n if (!pluginModules.length) {\n console.error('RemotePluginLoader: No valid plugins found');\n }\n\n return pluginModules;\n },\n importPluginModule: async (resource): Promise<RemotePluginModule> => {\n const pluginModuleName = resource.metadata.name;\n\n const pluginModule: RemotePluginModule = {};\n\n for (const plugin of resource.spec.plugins) {\n const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name);\n\n const remotePlugin = remotePluginModule?.[plugin.spec.name];\n if (remotePlugin) {\n pluginModule[plugin.spec.name] = remotePlugin;\n } else {\n console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);\n }\n }\n\n return pluginModule;\n },\n };\n};\n"],"names":["loadPlugin","isPluginMetadata","plugin","spec","isPluginModuleResource","pluginModule","Array","isArray","plugins","every","remotePluginLoader","baseURL","getInstalledPlugins","pluginsResponse","fetch","json","pluginModules","filter","console","error","length","importPluginModule","resource","pluginModuleName","metadata","name","remotePluginModule","remotePlugin"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,CAACC;IACxB,OACE,OAAOA,WAAW,YAClBA,WAAW,QACX,UAAUA,UACV,UAAUA,UACV,OAAOA,OAAOC,IAAI,KAAK,YACvBD,OAAOC,IAAI,KAAK,QAChB,UAAUD,OAAOC,IAAI;AAEzB;AAEA,MAAMC,yBAAyB,CAACC;IAC9B,OACE,OAAOA,iBAAiB,YACxBA,iBAAiB,QACjB,cAAcA,gBACd,UAAUA,gBACV,OAAOA,aAAaF,IAAI,KAAK,YAC7BE,aAAaF,IAAI,KAAK,QACtB,aAAaE,aAAaF,IAAI,IAC9BG,MAAMC,OAAO,CAACF,aAAaF,IAAI,CAACK,OAAO,KACvCH,aAAaF,IAAI,CAACK,OAAO,CAACC,KAAK,CAACR;AAEpC;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,OAAO;QACLC,qBAAqB;YACnB,MAAMC,kBAAkB,MAAMC,MAAM,CAAC,EAAEH,UAAUA,UAAU,GAAG,eAAe,CAAC;YAE9E,MAAMH,UAAU,MAAMK,gBAAgBE,IAAI;YAE1C,IAAIC,gBAAwC,EAAE;YAE9C,IAAIV,MAAMC,OAAO,CAACC,UAAU;gBAC1BQ,gBAAgBR,QAAQS,MAAM,CAACb;YACjC,OAAO;gBACLc,QAAQC,KAAK,CAAC;YAChB;YAEA,IAAI,CAACH,cAAcI,MAAM,EAAE;gBACzBF,QAAQC,KAAK,CAAC;YAChB;YAEA,OAAOH;QACT;QACAK,oBAAoB,OAAOC;YACzB,MAAMC,mBAAmBD,SAASE,QAAQ,CAACC,IAAI;YAE/C,MAAMpB,eAAmC,CAAC;YAE1C,KAAK,MAAMH,UAAUoB,SAASnB,IAAI,CAACK,OAAO,CAAE;gBAC1C,MAAMkB,qBAAqB,MAAM1B,WAAWuB,kBAAkBrB,OAAOC,IAAI,CAACsB,IAAI;gBAE9E,MAAME,eAAeD,oBAAoB,CAACxB,OAAOC,IAAI,CAACsB,IAAI,CAAC;gBAC3D,IAAIE,cAAc;oBAChBtB,YAAY,CAACH,OAAOC,IAAI,CAACsB,IAAI,CAAC,GAAGE;gBACnC,OAAO;oBACLT,QAAQC,KAAK,CAAC,CAAC,yCAAyC,EAAEjB,OAAOC,IAAI,CAACsB,IAAI,CAAC,CAAC;gBAC9E;YACF;YAEA,OAAOpB;QACT;IACF;AACF,EAAE"}
@@ -27,15 +27,9 @@ export function useDataQueriesContext() {
27
27
  export function useDataQueries(queryType) {
28
28
  const ctx = useDataQueriesContext();
29
29
  // Filter the query results based on the specified query type
30
- const filteredQueryResults = ctx.queryResults.filter((queryResult)=>{
31
- var _queryResult_definition;
32
- return (queryResult === null || queryResult === void 0 ? void 0 : (_queryResult_definition = queryResult.definition) === null || _queryResult_definition === void 0 ? void 0 : _queryResult_definition.kind) === queryType;
33
- });
30
+ const filteredQueryResults = ctx.queryResults.filter((queryResult)=>queryResult?.definition?.kind === queryType);
34
31
  // Filter the errors based on the specified query type
35
- const filteredErrors = ctx.errors.filter((errors, index)=>{
36
- var _ctx_queryResults_index_definition, _ctx_queryResults_index;
37
- return ((_ctx_queryResults_index = ctx.queryResults[index]) === null || _ctx_queryResults_index === void 0 ? void 0 : (_ctx_queryResults_index_definition = _ctx_queryResults_index.definition) === null || _ctx_queryResults_index_definition === void 0 ? void 0 : _ctx_queryResults_index_definition.kind) === queryType;
38
- });
32
+ const filteredErrors = ctx.errors.filter((errors, index)=>ctx.queryResults[index]?.definition?.kind === queryType);
39
33
  // Create a new context object with the filtered results and errors
40
34
  const filteredCtx = {
41
35
  queryResults: filteredQueryResults,
@@ -77,7 +71,7 @@ export function DataQueriesProvider(props) {
77
71
  ...transformQueryResults(timeSeriesResults, timeSeriesQueries),
78
72
  ...transformQueryResults(traceResults, traceQueries)
79
73
  ];
80
- if (queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) {
74
+ if (queryOptions?.enabled) {
81
75
  for (const result of mergedQueryResults){
82
76
  if (!result.isLoading && !result.isFetching && !result.error) {
83
77
  usageMetrics.markQuery(result.definition, 'success');
@@ -101,7 +95,7 @@ export function DataQueriesProvider(props) {
101
95
  traceQueries,
102
96
  traceResults,
103
97
  refetchAll,
104
- queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled,
98
+ queryOptions?.enabled,
105
99
  usageMetrics
106
100
  ]);
107
101
  return /*#__PURE__*/ _jsx(DataQueriesContext.Provider, {