@perses-dev/plugin-system 0.54.0-beta.0 → 0.54.0-beta.2

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 (225) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +3 -3
  2. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
  3. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -5
  4. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
  5. package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
  6. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
  7. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
  8. package/dist/cjs/components/Variables/variable-model.js +115 -29
  9. package/dist/cjs/context/ValidationProvider.js +3 -3
  10. package/dist/cjs/model/alerts-queries.js +16 -0
  11. package/dist/cjs/model/calculations.js +178 -0
  12. package/dist/cjs/model/index.js +3 -0
  13. package/dist/cjs/model/legend.js +6 -5
  14. package/dist/cjs/model/log-volume-utils.js +10 -10
  15. package/dist/cjs/model/plugin-loading.js +24 -8
  16. package/dist/cjs/model/plugins.js +10 -0
  17. package/dist/cjs/model/silences-queries.js +16 -0
  18. package/dist/cjs/model/time-series-queries.js +10 -0
  19. package/dist/cjs/remote/PluginRuntime.js +38 -9
  20. package/dist/cjs/remote/remotePluginLoader.js +28 -5
  21. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -2
  22. package/dist/cjs/runtime/DataQueriesProvider/model.js +30 -4
  23. package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
  24. package/dist/cjs/runtime/alerts-queries.js +101 -0
  25. package/dist/cjs/runtime/index.js +2 -0
  26. package/dist/cjs/runtime/item-actions.js +3 -3
  27. package/dist/cjs/runtime/log-queries.js +4 -1
  28. package/dist/cjs/runtime/plugin-registry.js +12 -3
  29. package/dist/cjs/runtime/profile-queries.js +4 -1
  30. package/dist/cjs/runtime/silences-queries.js +101 -0
  31. package/dist/cjs/runtime/time-series-queries.js +4 -1
  32. package/dist/cjs/runtime/trace-queries.js +4 -1
  33. package/dist/cjs/test/mock-data.js +51 -0
  34. package/dist/cjs/test/test-plugins/bert/index.js +9 -12
  35. package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
  36. package/dist/cjs/test/test-plugins/index.js +2 -2
  37. package/dist/cjs/test/utils.js +2 -2
  38. package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
  39. package/dist/cjs/utils/index.js +0 -1
  40. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -1
  41. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  42. package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
  43. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  44. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -1
  45. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  46. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
  47. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  48. package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
  49. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
  50. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
  51. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  52. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +1 -1
  53. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  54. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
  55. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
  56. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  57. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -3
  58. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  59. package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
  60. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
  61. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
  62. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
  63. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  64. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  65. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  66. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
  67. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  68. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  69. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  70. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  71. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  72. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +1 -1
  73. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  74. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  75. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  76. package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
  77. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  78. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.js +12 -16
  80. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  81. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
  82. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
  83. package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
  84. package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
  85. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
  86. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  87. package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
  88. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  89. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  90. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  91. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  92. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
  93. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
  94. package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
  95. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  96. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
  97. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  98. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
  99. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  100. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  101. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  102. package/dist/components/Variables/variable-model.d.ts +9 -1
  103. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  104. package/dist/components/Variables/variable-model.js +117 -31
  105. package/dist/components/Variables/variable-model.js.map +1 -1
  106. package/dist/context/ValidationProvider.d.ts +1 -1
  107. package/dist/context/ValidationProvider.d.ts.map +1 -1
  108. package/dist/context/ValidationProvider.js +2 -2
  109. package/dist/context/ValidationProvider.js.map +1 -1
  110. package/dist/model/alerts-queries.d.ts +33 -0
  111. package/dist/model/alerts-queries.d.ts.map +1 -0
  112. package/dist/{utils/action.js → model/alerts-queries.js} +2 -14
  113. package/dist/model/alerts-queries.js.map +1 -0
  114. package/dist/model/calculations.d.ts +45 -0
  115. package/dist/model/calculations.d.ts.map +1 -0
  116. package/dist/model/calculations.js +165 -0
  117. package/dist/model/calculations.js.map +1 -0
  118. package/dist/model/index.d.ts +3 -0
  119. package/dist/model/index.d.ts.map +1 -1
  120. package/dist/model/index.js +3 -0
  121. package/dist/model/index.js.map +1 -1
  122. package/dist/model/legend.d.ts +3 -2
  123. package/dist/model/legend.d.ts.map +1 -1
  124. package/dist/model/legend.js +2 -1
  125. package/dist/model/legend.js.map +1 -1
  126. package/dist/model/plugin-loading.d.ts.map +1 -1
  127. package/dist/model/plugin-loading.js +24 -8
  128. package/dist/model/plugin-loading.js.map +1 -1
  129. package/dist/model/plugins.d.ts +21 -0
  130. package/dist/model/plugins.d.ts.map +1 -1
  131. package/dist/model/plugins.js +4 -1
  132. package/dist/model/plugins.js.map +1 -1
  133. package/dist/model/silences-queries.d.ts +33 -0
  134. package/dist/model/silences-queries.d.ts.map +1 -0
  135. package/dist/model/silences-queries.js +15 -0
  136. package/dist/model/silences-queries.js.map +1 -0
  137. package/dist/model/time-series-queries.d.ts +11 -1
  138. package/dist/model/time-series-queries.d.ts.map +1 -1
  139. package/dist/model/time-series-queries.js +4 -1
  140. package/dist/model/time-series-queries.js.map +1 -1
  141. package/dist/remote/PersesPlugin.types.d.ts +2 -0
  142. package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
  143. package/dist/remote/PersesPlugin.types.js.map +1 -1
  144. package/dist/remote/PluginLoaderComponent.js +1 -1
  145. package/dist/remote/PluginLoaderComponent.js.map +1 -1
  146. package/dist/remote/PluginRuntime.d.ts +7 -1
  147. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  148. package/dist/remote/PluginRuntime.js +38 -9
  149. package/dist/remote/PluginRuntime.js.map +1 -1
  150. package/dist/remote/remotePluginLoader.d.ts.map +1 -1
  151. package/dist/remote/remotePluginLoader.js +28 -5
  152. package/dist/remote/remotePluginLoader.js.map +1 -1
  153. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  154. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +19 -3
  155. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  156. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  157. package/dist/runtime/DataQueriesProvider/model.js +30 -4
  158. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  159. package/dist/runtime/QueryCountProvider.js +1 -1
  160. package/dist/runtime/QueryCountProvider.js.map +1 -1
  161. package/dist/runtime/RouterProvider.js +1 -1
  162. package/dist/runtime/RouterProvider.js.map +1 -1
  163. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  164. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  165. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
  166. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
  167. package/dist/runtime/UsageMetricsProvider.js +2 -2
  168. package/dist/runtime/UsageMetricsProvider.js.map +1 -1
  169. package/dist/runtime/alerts-queries.d.ts +11 -0
  170. package/dist/runtime/alerts-queries.d.ts.map +1 -0
  171. package/dist/runtime/alerts-queries.js +89 -0
  172. package/dist/runtime/alerts-queries.js.map +1 -0
  173. package/dist/runtime/index.d.ts +2 -0
  174. package/dist/runtime/index.d.ts.map +1 -1
  175. package/dist/runtime/index.js +2 -0
  176. package/dist/runtime/index.js.map +1 -1
  177. package/dist/runtime/item-actions.js +1 -1
  178. package/dist/runtime/item-actions.js.map +1 -1
  179. package/dist/runtime/log-queries.js +4 -1
  180. package/dist/runtime/log-queries.js.map +1 -1
  181. package/dist/runtime/plugin-registry.d.ts +2 -1
  182. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  183. package/dist/runtime/plugin-registry.js +12 -3
  184. package/dist/runtime/plugin-registry.js.map +1 -1
  185. package/dist/runtime/profile-queries.js +4 -1
  186. package/dist/runtime/profile-queries.js.map +1 -1
  187. package/dist/runtime/silences-queries.d.ts +11 -0
  188. package/dist/runtime/silences-queries.d.ts.map +1 -0
  189. package/dist/runtime/silences-queries.js +89 -0
  190. package/dist/runtime/silences-queries.js.map +1 -0
  191. package/dist/runtime/time-series-queries.js +4 -1
  192. package/dist/runtime/time-series-queries.js.map +1 -1
  193. package/dist/runtime/trace-queries.js +4 -1
  194. package/dist/runtime/trace-queries.js.map +1 -1
  195. package/dist/test/mock-data.d.ts +3 -1
  196. package/dist/test/mock-data.d.ts.map +1 -1
  197. package/dist/test/mock-data.js +45 -0
  198. package/dist/test/mock-data.js.map +1 -1
  199. package/dist/test/render.js +1 -1
  200. package/dist/test/render.js.map +1 -1
  201. package/dist/test/test-plugins/bert/index.d.ts +12 -6
  202. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  203. package/dist/test/test-plugins/bert/index.js +6 -2
  204. package/dist/test/test-plugins/bert/index.js.map +1 -1
  205. package/dist/test/test-plugins/ernie/index.d.ts +8 -6
  206. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
  207. package/dist/test/test-plugins/ernie/index.js +6 -2
  208. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  209. package/dist/test/test-plugins/index.js +2 -2
  210. package/dist/test/test-plugins/index.js.map +1 -1
  211. package/dist/test/utils.d.ts.map +1 -1
  212. package/dist/test/utils.js +2 -2
  213. package/dist/test/utils.js.map +1 -1
  214. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  215. package/dist/test-utils/mock-plugin-registry.js +8 -2
  216. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  217. package/dist/utils/index.d.ts +0 -1
  218. package/dist/utils/index.d.ts.map +1 -1
  219. package/dist/utils/index.js +0 -1
  220. package/dist/utils/index.js.map +1 -1
  221. package/package.json +6 -5
  222. package/dist/cjs/utils/action.js +0 -43
  223. package/dist/utils/action.d.ts +0 -4
  224. package/dist/utils/action.d.ts.map +0 -1
  225. package/dist/utils/action.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './legend';\nexport * from './log-queries';\nexport * from './log-volume-utils';\nexport * from './panels';\nexport * from './plugins';\nexport * from './plugin-base';\nexport * from './plugin-loading';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './profile-queries';\nexport * from './variables';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,cAAc"}
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './legend';\nexport * from './log-queries';\nexport * from './log-volume-utils';\nexport * from './panels';\nexport * from './plugins';\nexport * from './plugin-base';\nexport * from './plugin-loading';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './profile-queries';\nexport * from './variables';\nexport * from './calculations';\nexport * from './alerts-queries';\nexport * from './silences-queries';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,mBAAmB;AACjC,cAAc,qBAAqB"}
@@ -1,4 +1,5 @@
1
- import { CalculationType, LegendMode, LegendOptionsBase, LegendPositions, LegendSize } from '@perses-dev/core';
1
+ import { LegendMode, LegendOptionsBase, LegendPositions, LegendSize } from '@perses-dev/components';
2
+ import { CalculationType } from './calculations';
2
3
  export declare const legendValues: CalculationType[];
3
4
  export type LegendValue = (typeof legendValues)[number];
4
5
  export type ComparisonValues = 'abs' | 'relative';
@@ -13,6 +14,6 @@ export type LegendSingleSelectConfig = {
13
14
  export declare const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>>;
14
15
  export declare const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>>;
15
16
  export declare const LEGEND_SIZE_CONFIG: Readonly<Record<LegendSize, LegendSingleSelectConfig>>;
16
- export declare const LEGEND_VALUE_CONFIG: Partial<Record<"first" | "last" | "first-number" | "last-number" | "mean" | "sum" | "min" | "max", LegendSingleSelectConfig>>;
17
+ export declare const LEGEND_VALUE_CONFIG: Partial<Record<"max" | "min" | "first" | "last" | "first-number" | "last-number" | "mean" | "sum", LegendSingleSelectConfig>>;
17
18
  export declare function validateLegendSpec(legend?: LegendOptionsBase): boolean;
18
19
  //# sourceMappingURL=legend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,eAAe,EAGf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAU1B,eAAO,MAAM,YAAY,EAAE,eAAe,EASzC,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,UAAU,CAAC;AAElD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,wBAAwB,CAGhF,CAAC;AAKF,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,MAAM,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAG/F,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAGrF,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAGrF,CAAC;AAEF,eAAO,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@@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { CALCULATIONS_CONFIG, isValidLegendMode, isValidLegendPosition, isValidLegendSize } from '@perses-dev/core'; // TODO, maybe this should come from the future utils package
13
+ import { isValidLegendMode, isValidLegendPosition, isValidLegendSize } from '@perses-dev/components';
14
+ import { CALCULATIONS_CONFIG } from './calculations';
14
15
  // This file contains legend-related model code specific to panel plugin specs.
15
16
  // See the `core` package for common/shared legend model code and the
16
17
  // `components` package for legend model code specific to the Legend component.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/legend.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n CALCULATIONS_CONFIG,\n CalculationType,\n LegendMode,\n LegendOptionsBase,\n LegendPositions,\n isValidLegendMode,\n isValidLegendPosition,\n LegendSize,\n isValidLegendSize,\n} from '@perses-dev/core'; // TODO, maybe this should come from the future utils package\n\n// This file contains legend-related model code specific to panel plugin specs.\n// See the `core` package for common/shared legend model code and the\n// `components` package for legend model code specific to the Legend component.\n\n// Explicity listing the calculations we intend to use for legend values because\n// we want them ordered in a specific way, and it may be possible in the future\n// that we only use a subset of calculations for the legend because the calculations\n// are also used by other features.\nexport const legendValues: CalculationType[] = [\n 'mean',\n 'first',\n 'first-number',\n 'last',\n 'last-number',\n 'min',\n 'max',\n 'sum',\n];\nexport type LegendValue = (typeof legendValues)[number];\n\nexport type ComparisonValues = 'abs' | 'relative';\n\nexport const comparisonLegends: Record<ComparisonValues, LegendSingleSelectConfig> = {\n abs: { label: 'Absolute', description: 'Absolute value' },\n relative: { label: 'Relative', description: 'Relative value' },\n};\n\n// Note: explicitly defining different options for the legend spec and\n// legend component that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport interface LegendSpecOptions extends LegendOptionsBase {\n values?: Array<LegendValue | ComparisonValues>;\n}\n\nexport type LegendSingleSelectConfig = {\n label: string;\n description?: string;\n};\n\nexport const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>> = {\n bottom: { label: 'Bottom' },\n right: { label: 'Right' },\n};\n\nexport const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>> = {\n list: { label: 'List' },\n table: { label: 'Table' },\n};\n\nexport const LEGEND_SIZE_CONFIG: Readonly<Record<LegendSize, LegendSingleSelectConfig>> = {\n small: { label: 'Small' },\n medium: { label: 'Medium' },\n};\n\nexport const LEGEND_VALUE_CONFIG = legendValues.reduce(\n (config, value) => {\n config[value] = CALCULATIONS_CONFIG[value];\n\n return config;\n },\n {} as Partial<Record<LegendValue, LegendSingleSelectConfig>>\n);\n\nexport function validateLegendSpec(legend?: LegendOptionsBase): boolean {\n if (legend === undefined) {\n // undefined is valid since this is how legend is hidden by default\n return true;\n }\n if (!isValidLegendPosition(legend.position)) {\n return false;\n }\n if (legend.mode && !isValidLegendMode(legend.mode)) {\n return false;\n }\n if (legend.size && !isValidLegendSize(legend.size)) {\n return false;\n }\n\n return true;\n}\n"],"names":["CALCULATIONS_CONFIG","isValidLegendMode","isValidLegendPosition","isValidLegendSize","legendValues","comparisonLegends","abs","label","description","relative","LEGEND_POSITIONS_CONFIG","bottom","right","LEGEND_MODE_CONFIG","list","table","LEGEND_SIZE_CONFIG","small","medium","LEGEND_VALUE_CONFIG","reduce","config","value","validateLegendSpec","legend","undefined","position","mode","size"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,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;IACA,IAAIH,OAAOI,IAAI,IAAI,CAACzB,kBAAkBqB,OAAOI,IAAI,GAAG;QAClD,OAAO;IACT;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../src/model/legend.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n isValidLegendMode,\n isValidLegendPosition,\n isValidLegendSize,\n LegendMode,\n LegendOptionsBase,\n LegendPositions,\n LegendSize,\n} from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationType } from './calculations';\n\n// This file contains legend-related model code specific to panel plugin specs.\n// See the `core` package for common/shared legend model code and the\n// `components` package for legend model code specific to the Legend component.\n\n// Explicity listing the calculations we intend to use for legend values because\n// we want them ordered in a specific way, and it may be possible in the future\n// that we only use a subset of calculations for the legend because the calculations\n// are also used by other features.\nexport const legendValues: CalculationType[] = [\n 'mean',\n 'first',\n 'first-number',\n 'last',\n 'last-number',\n 'min',\n 'max',\n 'sum',\n];\nexport type LegendValue = (typeof legendValues)[number];\n\nexport type ComparisonValues = 'abs' | 'relative';\n\nexport const comparisonLegends: Record<ComparisonValues, LegendSingleSelectConfig> = {\n abs: { label: 'Absolute', description: 'Absolute value' },\n relative: { label: 'Relative', description: 'Relative value' },\n};\n\n// Note: explicitly defining different options for the legend spec and\n// legend component that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport interface LegendSpecOptions extends LegendOptionsBase {\n values?: Array<LegendValue | ComparisonValues>;\n}\n\nexport type LegendSingleSelectConfig = {\n label: string;\n description?: string;\n};\n\nexport const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>> = {\n bottom: { label: 'Bottom' },\n right: { label: 'Right' },\n};\n\nexport const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>> = {\n list: { label: 'List' },\n table: { label: 'Table' },\n};\n\nexport const LEGEND_SIZE_CONFIG: Readonly<Record<LegendSize, LegendSingleSelectConfig>> = {\n small: { label: 'Small' },\n medium: { label: 'Medium' },\n};\n\nexport const LEGEND_VALUE_CONFIG = legendValues.reduce(\n (config, value) => {\n config[value] = CALCULATIONS_CONFIG[value];\n\n return config;\n },\n {} as Partial<Record<LegendValue, LegendSingleSelectConfig>>\n);\n\nexport function validateLegendSpec(legend?: LegendOptionsBase): boolean {\n if (legend === undefined) {\n // undefined is valid since this is how legend is hidden by default\n return true;\n }\n if (!isValidLegendPosition(legend.position)) {\n return false;\n }\n if (legend.mode && !isValidLegendMode(legend.mode)) {\n return false;\n }\n if (legend.size && !isValidLegendSize(legend.size)) {\n return false;\n }\n\n return true;\n}\n"],"names":["isValidLegendMode","isValidLegendPosition","isValidLegendSize","CALCULATIONS_CONFIG","legendValues","comparisonLegends","abs","label","description","relative","LEGEND_POSITIONS_CONFIG","bottom","right","LEGEND_MODE_CONFIG","list","table","LEGEND_SIZE_CONFIG","small","medium","LEGEND_VALUE_CONFIG","reduce","config","value","validateLegendSpec","legend","undefined","position","mode","size"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SACEA,iBAAiB,EACjBC,qBAAqB,EACrBC,iBAAiB,QAKZ,yBAAyB;AAChC,SAASC,mBAAmB,QAAyB,iBAAiB;AAEtE,+EAA+E;AAC/E,qEAAqE;AACrE,+EAA+E;AAE/E,gFAAgF;AAChF,+EAA+E;AAC/E,oFAAoF;AACpF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Y;IAC3B,mBAAmB,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3D,kBAAkB,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,YAAY,CAiBtF"}
1
+ {"version":3,"file":"plugin-loading.d.ts","sourceRoot":"","sources":["../../src/model/plugin-loading.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAA8B,MAAM,WAAW,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,mBAAmB,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3D,kBAAkB,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,YAAY,CA8BtF"}
@@ -10,24 +10,40 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ import { getPluginModuleCompoundKey } from './plugins';
13
14
  /**
14
15
  * A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load
15
16
  * the plugin itself via a dynamic `import()` statement.
16
17
  */ export function dynamicImportPluginLoader(plugins) {
17
- const importMap = new Map(plugins.map((plugin)=>[
18
- plugin.resource,
19
- plugin.importPlugin
20
- ]));
18
+ const importMap = new Map();
19
+ for (const p of plugins){
20
+ const { resource, resource: { kind, metadata: { name, registry, version } }, importPlugin } = p;
21
+ importMap.set(getPluginModuleCompoundKey({
22
+ kind,
23
+ name,
24
+ registry,
25
+ version
26
+ }), {
27
+ resource,
28
+ importPlugin
29
+ });
30
+ }
21
31
  return {
22
32
  async getInstalledPlugins () {
23
- return Promise.resolve(Array.from(importMap.keys()));
33
+ return Promise.resolve(Array.from(importMap.values()).map((v)=>v.resource));
24
34
  },
25
35
  importPluginModule (resource) {
26
- const importFn = importMap.get(resource);
27
- if (importFn === undefined) {
36
+ const { kind, metadata: { name, version, registry } } = resource;
37
+ const { importPlugin } = importMap.get(getPluginModuleCompoundKey({
38
+ kind,
39
+ name,
40
+ registry,
41
+ version
42
+ })) || {};
43
+ if (importPlugin === undefined) {
28
44
  throw new Error('Plugin not found');
29
45
  }
30
- return importFn();
46
+ return importPlugin();
31
47
  }
32
48
  };
33
49
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/plugin-loading.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginModuleResource } from './plugins';\n\n/**\n * A component capable of loading the resource/metadata for all available plugins, then loading individual plugins for\n * those resources on-demand.\n */\nexport interface PluginLoader {\n getInstalledPlugins: () => Promise<PluginModuleResource[]>;\n importPluginModule: (resource: PluginModuleResource) => Promise<unknown>;\n}\n\n/**\n * The dynamic import for a single plugin resource.\n */\nexport interface DynamicImportPlugin {\n resource: PluginModuleResource;\n importPlugin(): Promise<unknown>;\n}\n\n/**\n * A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load\n * the plugin itself via a dynamic `import()` statement.\n */\nexport function dynamicImportPluginLoader(plugins: DynamicImportPlugin[]): PluginLoader {\n const importMap: Map<PluginModuleResource, DynamicImportPlugin['importPlugin']> = new Map(\n plugins.map((plugin) => [plugin.resource, plugin.importPlugin])\n );\n\n return {\n async getInstalledPlugins(): Promise<PluginModuleResource[]> {\n return Promise.resolve(Array.from(importMap.keys()));\n },\n importPluginModule(resource): Promise<unknown> {\n const importFn = importMap.get(resource);\n if (importFn === undefined) {\n throw new Error('Plugin not found');\n }\n return importFn();\n },\n };\n}\n"],"names":["dynamicImportPluginLoader","plugins","importMap","Map","map","plugin","resource","importPlugin","getInstalledPlugins","Promise","resolve","Array","from","keys","importPluginModule","importFn","get","undefined","Error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqBjC;;;CAGC,GACD,OAAO,SAASA,0BAA0BC,OAA8B;IACtE,MAAMC,YAA4E,IAAIC,IACpFF,QAAQG,GAAG,CAAC,CAACC,SAAW;YAACA,OAAOC,QAAQ;YAAED,OAAOE,YAAY;SAAC;IAGhE,OAAO;QACL,MAAMC;YACJ,OAAOC,QAAQC,OAAO,CAACC,MAAMC,IAAI,CAACV,UAAUW,IAAI;QAClD;QACAC,oBAAmBR,QAAQ;YACzB,MAAMS,WAAWb,UAAUc,GAAG,CAACV;YAC/B,IAAIS,aAAaE,WAAW;gBAC1B,MAAM,IAAIC,MAAM;YAClB;YACA,OAAOH;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/model/plugin-loading.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginModuleResource, getPluginModuleCompoundKey } from './plugins';\n\n/**\n * A component capable of loading the resource/metadata for all available plugins, then loading individual plugins for\n * those resources on-demand.\n */\nexport interface PluginLoader {\n getInstalledPlugins: () => Promise<PluginModuleResource[]>;\n importPluginModule: (resource: PluginModuleResource) => Promise<unknown>;\n}\n\n/**\n * The dynamic import for a single plugin resource.\n */\nexport interface DynamicImportPlugin {\n resource: PluginModuleResource;\n importPlugin(): Promise<unknown>;\n}\n\n/**\n * A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load\n * the plugin itself via a dynamic `import()` statement.\n */\nexport function dynamicImportPluginLoader(plugins: DynamicImportPlugin[]): PluginLoader {\n const importMap: Map<string, { resource: PluginModuleResource; importPlugin: DynamicImportPlugin['importPlugin'] }> =\n new Map();\n for (const p of plugins) {\n const {\n resource,\n resource: {\n kind,\n metadata: { name, registry, version },\n },\n importPlugin,\n } = p;\n importMap.set(getPluginModuleCompoundKey({ kind, name, registry, version }), { resource, importPlugin });\n }\n return {\n async getInstalledPlugins(): Promise<PluginModuleResource[]> {\n return Promise.resolve(Array.from(importMap.values()).map((v) => v.resource));\n },\n importPluginModule(resource): Promise<unknown> {\n const {\n kind,\n metadata: { name, version, registry },\n } = resource;\n const { importPlugin } = importMap.get(getPluginModuleCompoundKey({ kind, name, registry, version })) || {};\n if (importPlugin === undefined) {\n throw new Error('Plugin not found');\n }\n return importPlugin();\n },\n };\n}\n"],"names":["getPluginModuleCompoundKey","dynamicImportPluginLoader","plugins","importMap","Map","p","resource","kind","metadata","name","registry","version","importPlugin","set","getInstalledPlugins","Promise","resolve","Array","from","values","map","v","importPluginModule","get","undefined","Error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA+BA,0BAA0B,QAAQ,YAAY;AAmB7E;;;CAGC,GACD,OAAO,SAASC,0BAA0BC,OAA8B;IACtE,MAAMC,YACJ,IAAIC;IACN,KAAK,MAAMC,KAAKH,QAAS;QACvB,MAAM,EACJI,QAAQ,EACRA,UAAU,EACRC,IAAI,EACJC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAE,EACtC,EACDC,YAAY,EACb,GAAGP;QACJF,UAAUU,GAAG,CAACb,2BAA2B;YAAEO;YAAME;YAAMC;YAAUC;QAAQ,IAAI;YAAEL;YAAUM;QAAa;IACxG;IACA,OAAO;QACL,MAAME;YACJ,OAAOC,QAAQC,OAAO,CAACC,MAAMC,IAAI,CAACf,UAAUgB,MAAM,IAAIC,GAAG,CAAC,CAACC,IAAMA,EAAEf,QAAQ;QAC7E;QACAgB,oBAAmBhB,QAAQ;YACzB,MAAM,EACJC,IAAI,EACJC,UAAU,EAAEC,IAAI,EAAEE,OAAO,EAAED,QAAQ,EAAE,EACtC,GAAGJ;YACJ,MAAM,EAAEM,YAAY,EAAE,GAAGT,UAAUoB,GAAG,CAACvB,2BAA2B;gBAAEO;gBAAME;gBAAMC;gBAAUC;YAAQ,OAAO,CAAC;YAC1G,IAAIC,iBAAiBY,WAAW;gBAC9B,MAAM,IAAIC,MAAM;YAClB;YACA,OAAOb;QACT;IACF;AACF"}
@@ -8,6 +8,8 @@ import { ProfileQueryPlugin } from './profile-queries';
8
8
  import { VariablePlugin } from './variables';
9
9
  import { ExplorePlugin } from './explore';
10
10
  import { LogQueryPlugin } from './log-queries';
11
+ import { AlertsQueryPlugin } from './alerts-queries';
12
+ import { SilencesQueryPlugin } from './silences-queries';
11
13
  export interface PluginModuleSpec {
12
14
  plugins: PluginMetadata[];
13
15
  }
@@ -19,6 +21,10 @@ export interface PluginMetadataWithModule extends PluginMetadata {
19
21
  */
20
22
  export interface PluginMetadata {
21
23
  kind: PluginType;
24
+ metadata?: {
25
+ version?: string;
26
+ registry?: string;
27
+ };
22
28
  spec: {
23
29
  name: string;
24
30
  display: {
@@ -33,6 +39,7 @@ export interface PluginMetadata {
33
39
  export interface PluginModuleMetadata {
34
40
  name: string;
35
41
  version: string;
42
+ registry?: string;
36
43
  }
37
44
  /**
38
45
  * Information about a module/package that contains plugins.
@@ -60,6 +67,8 @@ export interface SupportedPlugins {
60
67
  TraceQuery: TraceQueryPlugin;
61
68
  ProfileQuery: ProfileQueryPlugin;
62
69
  LogQuery: LogQueryPlugin;
70
+ AlertsQuery: AlertsQueryPlugin;
71
+ SilencesQuery: SilencesQueryPlugin;
63
72
  Datasource: DatasourcePlugin;
64
73
  Explore: ExplorePlugin;
65
74
  }
@@ -72,5 +81,17 @@ export type PluginImplementation<Type extends PluginType> = SupportedPlugins[Typ
72
81
  */
73
82
  type PluginKinds = Partial<Record<PluginType, string>>;
74
83
  export type DefaultPluginKinds = Required<Pick<PluginKinds, 'TimeSeriesQuery'>> & Omit<PluginKinds, 'TimeSeriesQuery'>;
84
+ export type PluginCompoundKey<T extends PluginType> = {
85
+ kind: T;
86
+ name: string;
87
+ registry?: string;
88
+ version?: string;
89
+ };
90
+ export declare function getPluginModuleCompoundKey(compoundKey: {
91
+ kind: string;
92
+ name: string;
93
+ registry?: string;
94
+ version?: string;
95
+ }): string;
75
96
  export {};
76
97
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/model/plugins.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,O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,kBAAkB,CAAC;IACjC,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,EAAE,mBAAmB,CAAC;IACnC,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;AAEvH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,UAAU,IAAI;IACpD,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,WAAW,EAAE;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAGT"}
@@ -10,6 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export { };
13
+ export function getPluginModuleCompoundKey(compoundKey) {
14
+ const { kind, name, registry, version } = compoundKey;
15
+ return `${kind}:${name}:${registry ?? ''}:${version ?? ''}`;
16
+ }
14
17
 
15
18
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/spec';\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 { ProfileQueryPlugin } from './profile-queries';\nimport { VariablePlugin } from './variables';\nimport { ExplorePlugin } from './explore';\nimport { LogQueryPlugin } from './log-queries';\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 ProfileQuery: ProfileQueryPlugin;\n LogQuery: LogQueryPlugin;\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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqFjC,WAAuH"}
1
+ {"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/spec';\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 { ProfileQueryPlugin } from './profile-queries';\nimport { VariablePlugin } from './variables';\nimport { ExplorePlugin } from './explore';\nimport { LogQueryPlugin } from './log-queries';\nimport { AlertsQueryPlugin } from './alerts-queries';\nimport { SilencesQueryPlugin } from './silences-queries';\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 metadata?: {\n version?: string;\n registry?: string;\n };\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 registry?: 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 ProfileQuery: ProfileQueryPlugin;\n LogQuery: LogQueryPlugin;\n AlertsQuery: AlertsQueryPlugin;\n SilencesQuery: SilencesQueryPlugin;\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\nexport type PluginCompoundKey<T extends PluginType> = {\n kind: T;\n name: string;\n registry?: string;\n version?: string;\n};\n\nexport function getPluginModuleCompoundKey(compoundKey: {\n kind: string;\n name: string;\n registry?: string;\n version?: string;\n}): string {\n const { kind, name, registry, version } = compoundKey;\n return `${kind}:${name}:${registry ?? ''}:${version ?? ''}`;\n}\n"],"names":["getPluginModuleCompoundKey","compoundKey","kind","name","registry","version"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAuGjC,OAAO,SAASA,2BAA2BC,WAK1C;IACC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAE,GAAGJ;IAC1C,OAAO,GAAGC,KAAK,CAAC,EAAEC,KAAK,CAAC,EAAEC,YAAY,GAAG,CAAC,EAAEC,WAAW,IAAI;AAC7D"}
@@ -0,0 +1,33 @@
1
+ import { Query, QueryKey } from '@tanstack/react-query';
2
+ import { SilencesData, UnknownSpec } from '@perses-dev/spec';
3
+ import { DatasourceStore, VariableStateMap } from '../runtime';
4
+ import { Plugin } from './plugin-base';
5
+ /**
6
+ * An object containing all the dependencies of a SilencesQuery.
7
+ */
8
+ type SilencesQueryPluginDependencies = {
9
+ /**
10
+ * Returns a list of variables name this silences query depends on.
11
+ */
12
+ variables?: string[];
13
+ };
14
+ /**
15
+ * A plugin for running silences queries.
16
+ * Silences represent current state, not historical data, so the context
17
+ * does NOT include absoluteTimeRange.
18
+ */
19
+ export interface SilencesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {
20
+ getSilencesData: (spec: Spec, ctx: SilencesQueryContext, abortSignal?: AbortSignal) => Promise<SilencesData>;
21
+ dependsOn?: (spec: Spec, ctx: SilencesQueryContext) => SilencesQueryPluginDependencies;
22
+ }
23
+ /**
24
+ * Context available to SilencesQuery plugins at runtime.
25
+ * Note: No absoluteTimeRange since silences represent current state.
26
+ */
27
+ export interface SilencesQueryContext {
28
+ datasourceStore: DatasourceStore;
29
+ variableState: VariableStateMap;
30
+ }
31
+ export type SilencesDataQuery = Query<SilencesData, unknown, SilencesData, QueryKey>;
32
+ export {};
33
+ //# sourceMappingURL=silences-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"silences-queries.d.ts","sourceRoot":"","sources":["../../src/model/silences-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,KAAK,+BAA+B,GAAG;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,mBAAmB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IAC3E,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,oBAAoB,EAAE,WAAW,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7G,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,oBAAoB,KAAK,+BAA+B,CAAC;CACxF;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,aAAa,EAAE,gBAAgB,CAAC;CACjC;AAED,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 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=silences-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/silences-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { SilencesData, UnknownSpec } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a SilencesQuery.\n */\ntype SilencesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this silences query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running silences queries.\n * Silences represent current state, not historical data, so the context\n * does NOT include absoluteTimeRange.\n */\nexport interface SilencesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getSilencesData: (spec: Spec, ctx: SilencesQueryContext, abortSignal?: AbortSignal) => Promise<SilencesData>;\n dependsOn?: (spec: Spec, ctx: SilencesQueryContext) => SilencesQueryPluginDependencies;\n}\n\n/**\n * Context available to SilencesQuery plugins at runtime.\n * Note: No absoluteTimeRange since silences represent current state.\n */\nexport interface SilencesQueryContext {\n datasourceStore: DatasourceStore;\n variableState: VariableStateMap;\n}\n\nexport type SilencesDataQuery = Query<SilencesData, unknown, SilencesData, QueryKey>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAoCjC,WAAqF"}
@@ -1,5 +1,5 @@
1
1
  import { Query, QueryKey } from '@tanstack/react-query';
2
- import { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/spec';
2
+ import { AbsoluteTimeRange, UnknownSpec, TimeSeriesData, UnixTimeMs } from '@perses-dev/spec';
3
3
  import { DatasourceStore, VariableStateMap } from '../runtime';
4
4
  import { Plugin } from './plugin-base';
5
5
  /**
@@ -30,5 +30,15 @@ export interface TimeSeriesQueryContext {
30
30
  datasourceStore: DatasourceStore;
31
31
  }
32
32
  export type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;
33
+ export type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number | null];
34
+ export type BucketTuple = [number, string, string, string];
35
+ export type HistogramValue = {
36
+ count: number;
37
+ sum: string;
38
+ buckets?: BucketTuple[];
39
+ };
40
+ export type TimeSeriesHistogramTuple = [unixTimeSeconds: UnixTimeMs, value: HistogramValue];
41
+ export declare function isTimeSeriesValueTuple(data: TimeSeriesValueTuple): data is TimeSeriesValueTuple;
42
+ export type Labels = Record<string, string>;
33
43
  export {};
34
44
  //# sourceMappingURL=time-series-queries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAA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AC;IAAC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,wBAAwB,GAAG,CAAC,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;AAE5F,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,IAAI,oBAAoB,CAG/F;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -10,6 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export { };
13
+ export function isTimeSeriesValueTuple(data) {
14
+ if (data.length !== 2) return false;
15
+ return true;
16
+ }
14
17
 
15
18
  //# sourceMappingURL=time-series-queries.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext, abortSignal?: AbortSignal) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\nexport type TimeSeriesQueryMode = 'instant' | 'range';\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAuCjC,WAA2F"}
1
+ {"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData, UnixTimeMs } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext, abortSignal?: AbortSignal) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\nexport type TimeSeriesQueryMode = 'instant' | 'range';\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\n\nexport type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number | null];\n\nexport type BucketTuple = [number, string, string, string]; // [bucket, upperBound, lowerBound, count]\n\nexport type HistogramValue = { count: number; sum: string; buckets?: BucketTuple[] };\n\nexport type TimeSeriesHistogramTuple = [unixTimeSeconds: UnixTimeMs, value: HistogramValue];\n\nexport function isTimeSeriesValueTuple(data: TimeSeriesValueTuple): data is TimeSeriesValueTuple {\n if (data.length !== 2) return false;\n return true;\n}\n\nexport type Labels = Record<string, string>;\n"],"names":["isTimeSeriesValueTuple","data","length"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiDjC,OAAO,SAASA,uBAAuBC,IAA0B;IAC/D,IAAIA,KAAKC,MAAM,KAAK,GAAG,OAAO;IAC9B,OAAO;AACT"}
@@ -1,5 +1,7 @@
1
1
  export interface PersesPlugin {
2
2
  name: string;
3
+ version?: string;
4
+ registry?: string;
3
5
  moduleName: string;
4
6
  baseURL?: string;
5
7
  }
@@ -1 +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"}
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,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/remote/PersesPlugin.types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface PersesPlugin {\n name: string;\n moduleName: string;\n baseURL?: string;\n}\n\nexport type RemotePluginModule = Record<string, unknown>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAQjC,WAAyD"}
1
+ {"version":3,"sources":["../../src/remote/PersesPlugin.types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface PersesPlugin {\n name: string;\n version?: string;\n registry?: string;\n moduleName: string;\n baseURL?: string;\n}\n\nexport type RemotePluginModule = Record<string, unknown>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAUjC,WAAyD"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the \"License\");
3
4
  // you may not use this file except in compliance with the License.
@@ -22,7 +23,6 @@
22
23
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
24
  // See the License for the specific language governing permissions and
24
25
  // limitations under the License.
25
- import { jsx as _jsx } from "react/jsx-runtime";
26
26
  import { useEffect, useRef, useState } from 'react';
27
27
  import { usePluginRuntime } from './PluginRuntime';
28
28
  function PluginContainer({ pluginFn, props }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/remote/PluginLoaderComponent.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,oDAAoD,GACpD,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEpD,SAASC,gBAAgB,QAAQ,kBAAkB;AAQnD,SAASC,gBAAmB,EAC1BC,QAAQ,EACRC,KAAK,EAIN;IACC,OAAOD,SAASC;AAClB;AAEA,OAAO,SAASC,sBAAyB,EAAEC,MAAM,EAAEF,KAAK,EAAEG,KAA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BC,OAAO,KAAKH,MAAM;QACvC,OAAO;IACT;IAEA,qBACE,KAACX;QAA2BC,UAAUmB;QAAyDlB,OAAOA;OAAhFS;AAE1B"}
1
+ {"version":3,"sources":["../../src/remote/PluginLoaderComponent.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,oDAAoD,GACpD,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAo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AI,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"}
@@ -1,6 +1,12 @@
1
1
  import { ModuleFederation } from '@module-federation/enhanced/runtime';
2
2
  import { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';
3
- export declare const loadPlugin: (moduleName: string, pluginName: string, baseURL?: string) => Promise<RemotePluginModule | null>;
3
+ export declare const loadPlugin: (target: {
4
+ moduleName: string;
5
+ pluginName: string;
6
+ registry?: string;
7
+ version?: string;
8
+ baseURL?: string;
9
+ }) => Promise<RemotePluginModule | null>;
4
10
  export declare function usePluginRuntime({ plugin }: {
5
11
  plugin: PersesPlugin;
6
12
  }): {
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRuntime.d.ts","sourceRoot":"","sources":["../../src/remote/PluginRuntime.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAOvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAqMxE,eAAO,MAAM,UAAU,eACT,MAAM,cACN,MAAM,YACR,MAAM,KACf,QAAQ,kBAAkB,GAAG,IAAI,CAMnC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG;IACtE,aAAa,EAAE,gBAAgB,CAAC;IAChC,UAAU,EAAE,MAAM,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CACtD,CAKA"}
1
+ {"version":3,"file":"PluginRuntime.d.ts","sourceRoot":"","sources":["../../src/remote/PluginRuntime.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAOvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAsNxE,eAAO,MAAM,UAAU,WAAkB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,QAAQ,kBAAkB,GAAG,IAAI,CAOpC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG;IACtE,aAAa,EAAE,gBAAgB,CAAC;IAChC,UAAU,EAAE,MAAM,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CACtD,CAQA"}
@@ -92,6 +92,14 @@ const getPluginRuntime = ()=>{
92
92
  requiredVersion: '^0.53.1'
93
93
  }
94
94
  },
95
+ '@perses-dev/client': {
96
+ version: '0.54.0-beta.1',
97
+ lib: ()=>require('@perses-dev/client'),
98
+ shareConfig: {
99
+ singleton: true,
100
+ requiredVersion: '^0.54.0-beta.1'
101
+ }
102
+ },
95
103
  '@perses-dev/components': {
96
104
  version: '0.53.1',
97
105
  lib: ()=>require('@perses-dev/components'),
@@ -204,29 +212,50 @@ const getPluginRuntime = ()=>{
204
212
  }
205
213
  return instance;
206
214
  };
207
- const registerRemote = (name, baseURL)=>{
215
+ function getModuleFederationRemoteName(name, registry, version) {
216
+ return `${name}:${registry ?? ''}:${version ?? ''}`;
217
+ }
218
+ const registerRemote = (name, registry, version, baseURL)=>{
208
219
  const pluginRuntime = getPluginRuntime();
209
- const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === name);
220
+ const registryName = getModuleFederationRemoteName(name, registry, version);
221
+ const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === registryName);
210
222
  if (!existingRemote) {
211
- const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;
223
+ const nameVersionRegistry = [
224
+ name,
225
+ version,
226
+ registry
227
+ ].filter(Boolean).join('~');
228
+ const prefix = baseURL || '/plugins';
229
+ const remoteEntryURL = `${prefix}/${nameVersionRegistry}/mf-manifest.json`;
212
230
  pluginRuntime.registerRemotes([
213
231
  {
214
- name,
232
+ name: registryName,
215
233
  entry: remoteEntryURL,
216
- alias: name
234
+ alias: registryName
217
235
  }
218
236
  ]);
219
237
  }
220
238
  };
221
- export const loadPlugin = async (moduleName, pluginName, baseURL)=>{
222
- registerRemote(moduleName, baseURL);
239
+ export const loadPlugin = async (target)=>{
240
+ const { moduleName, pluginName, registry, version, baseURL } = target;
241
+ registerRemote(moduleName, registry, version, baseURL);
223
242
  const pluginRuntime = getPluginRuntime();
224
- return pluginRuntime.loadRemote(`${moduleName}/${pluginName}`);
243
+ const registryName = getModuleFederationRemoteName(moduleName, registry, version);
244
+ return pluginRuntime.loadRemote(`${registryName}/${pluginName}`);
225
245
  };
226
246
  export function usePluginRuntime({ plugin }) {
227
247
  return {
228
248
  pluginRuntime: getPluginRuntime(),
229
- loadPlugin: ()=>loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL)
249
+ loadPlugin: ()=>{
250
+ const { moduleName, name: pluginName, registry, version, baseURL } = plugin;
251
+ return loadPlugin({
252
+ moduleName,
253
+ pluginName,
254
+ registry,
255
+ version,
256
+ baseURL
257
+ });
258
+ }
230
259
  };
231
260
  }
232
261