@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
@@ -0,0 +1,178 @@
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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get CALCULATIONS_CONFIG () {
25
+ return CALCULATIONS_CONFIG;
26
+ },
27
+ get CalculationsMap () {
28
+ return CalculationsMap;
29
+ },
30
+ get DEFAULT_CALCULATION () {
31
+ return DEFAULT_CALCULATION;
32
+ },
33
+ get getCalculation () {
34
+ return getCalculation;
35
+ },
36
+ get getCalculations () {
37
+ return getCalculations;
38
+ }
39
+ });
40
+ const DEFAULT_CALCULATION = 'last'; // aligned with cue
41
+ const CalculationsMap = {
42
+ first: first,
43
+ last: last,
44
+ 'first-number': firstNumber,
45
+ 'last-number': lastNumber,
46
+ mean: mean,
47
+ sum: sum,
48
+ min: min,
49
+ max: max
50
+ };
51
+ const CALCULATIONS_CONFIG = {
52
+ first: {
53
+ label: 'First',
54
+ description: 'First value'
55
+ },
56
+ last: {
57
+ label: 'Last',
58
+ description: 'Last value'
59
+ },
60
+ 'first-number': {
61
+ label: 'First *',
62
+ description: 'First numeric value'
63
+ },
64
+ 'last-number': {
65
+ label: 'Last *',
66
+ description: 'Last numeric value'
67
+ },
68
+ mean: {
69
+ label: 'Avg',
70
+ description: 'Average value excluding nulls'
71
+ },
72
+ sum: {
73
+ label: 'Sum',
74
+ description: 'The sum of all values'
75
+ },
76
+ min: {
77
+ label: 'Min',
78
+ description: 'Minimum value'
79
+ },
80
+ max: {
81
+ label: 'Max',
82
+ description: 'Maximum value'
83
+ }
84
+ };
85
+ function getCalculations(values, includeCalculations) {
86
+ const calculations = includeCalculations.reduce((initResult, calculation)=>{
87
+ initResult[calculation] = undefined;
88
+ return initResult;
89
+ }, {});
90
+ // We save these values as separate values instead of directly setting them
91
+ // in the calculations because they are needed by multiple calculations.
92
+ let nonNullCount = 0;
93
+ let sum = 0;
94
+ // We use this large function capable of performing one or more calculations
95
+ // in a single iteration of the data to minimize the performance impact of
96
+ // generating multiple calculations for large timeseries values. This is
97
+ // less optimized for certain single calculations when done in isolation (e.g.
98
+ // `last`), but will be more performant in the more expensive cases where
99
+ // multiple values are being used (e.g. table legend).
100
+ values.forEach((tuple, i)=>{
101
+ const value = tuple[1];
102
+ if (i === 0 && 'first' in calculations) {
103
+ calculations.first = value;
104
+ }
105
+ if (i === values.length - 1 && 'last' in calculations) {
106
+ calculations.last = value;
107
+ }
108
+ // Handling specific to non-null values.
109
+ if (typeof value === 'number') {
110
+ nonNullCount += 1;
111
+ sum += value;
112
+ if ('first-number' in calculations && calculations['first-number'] === undefined) {
113
+ // Save the first number we see.
114
+ calculations['first-number'] = value;
115
+ }
116
+ if ('last-number' in calculations) {
117
+ // Keep setting the numbers we see, which will eventually be set to the
118
+ // last number when finished iterating.
119
+ calculations['last-number'] = value;
120
+ }
121
+ if ('min' in calculations) {
122
+ if (typeof calculations.min !== 'number') {
123
+ // Init the first time we see a number
124
+ calculations.min = value;
125
+ } else {
126
+ // Use lowest value once initialized
127
+ calculations.min = Math.min(calculations.min, value);
128
+ }
129
+ }
130
+ if ('max' in calculations) {
131
+ if (typeof calculations.max !== 'number') {
132
+ // Init the first time we see a number
133
+ calculations.max = value;
134
+ } else {
135
+ // Use highest value once initialized
136
+ calculations.max = Math.max(calculations.max, value);
137
+ }
138
+ }
139
+ }
140
+ });
141
+ // Set calculations that require iterating over all values.
142
+ if (nonNullCount > 0 && 'sum' in calculations) {
143
+ calculations.sum = sum;
144
+ }
145
+ if (nonNullCount > 0 && 'mean' in calculations) {
146
+ calculations.mean = sum / nonNullCount;
147
+ }
148
+ return calculations;
149
+ }
150
+ function getCalculation(values, calculation) {
151
+ return getCalculations(values, [
152
+ calculation
153
+ ])[calculation];
154
+ }
155
+ function first(values) {
156
+ return getCalculation(values, 'first');
157
+ }
158
+ function last(values) {
159
+ return getCalculation(values, 'last');
160
+ }
161
+ function firstNumber(values) {
162
+ return getCalculation(values, 'first-number');
163
+ }
164
+ function lastNumber(values) {
165
+ return getCalculation(values, 'last-number');
166
+ }
167
+ function mean(values) {
168
+ return getCalculation(values, 'mean');
169
+ }
170
+ function sum(values) {
171
+ return getCalculation(values, 'sum');
172
+ }
173
+ function min(values) {
174
+ return getCalculation(values, 'min');
175
+ }
176
+ function max(values) {
177
+ return getCalculation(values, 'max');
178
+ }
@@ -26,6 +26,9 @@ _export_star(require("./time-series-queries"), exports);
26
26
  _export_star(require("./trace-queries"), exports);
27
27
  _export_star(require("./profile-queries"), exports);
28
28
  _export_star(require("./variables"), exports);
29
+ _export_star(require("./calculations"), exports);
30
+ _export_star(require("./alerts-queries"), exports);
31
+ _export_star(require("./silences-queries"), exports);
29
32
  function _export_star(from, to) {
30
33
  Object.keys(from).forEach(function(k) {
31
34
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -43,7 +43,8 @@ _export(exports, {
43
43
  return validateLegendSpec;
44
44
  }
45
45
  });
46
- const _core = require("@perses-dev/core");
46
+ const _components = require("@perses-dev/components");
47
+ const _calculations = require("./calculations");
47
48
  const legendValues = [
48
49
  'mean',
49
50
  'first',
@@ -89,7 +90,7 @@ const LEGEND_SIZE_CONFIG = {
89
90
  }
90
91
  };
91
92
  const LEGEND_VALUE_CONFIG = legendValues.reduce((config, value)=>{
92
- config[value] = _core.CALCULATIONS_CONFIG[value];
93
+ config[value] = _calculations.CALCULATIONS_CONFIG[value];
93
94
  return config;
94
95
  }, {});
95
96
  function validateLegendSpec(legend) {
@@ -97,13 +98,13 @@ function validateLegendSpec(legend) {
97
98
  // undefined is valid since this is how legend is hidden by default
98
99
  return true;
99
100
  }
100
- if (!(0, _core.isValidLegendPosition)(legend.position)) {
101
+ if (!(0, _components.isValidLegendPosition)(legend.position)) {
101
102
  return false;
102
103
  }
103
- if (legend.mode && !(0, _core.isValidLegendMode)(legend.mode)) {
104
+ if (legend.mode && !(0, _components.isValidLegendMode)(legend.mode)) {
104
105
  return false;
105
106
  }
106
- if (legend.size && !(0, _core.isValidLegendSize)(legend.size)) {
107
+ if (legend.size && !(0, _components.isValidLegendSize)(legend.size)) {
107
108
  return false;
108
109
  }
109
110
  return true;
@@ -1,3 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "calculateVolumeInterval", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return calculateVolumeInterval;
9
+ }
10
+ });
1
11
  // Copyright The Perses Authors
2
12
  // Licensed under the Apache License, Version 2.0 (the "License");
3
13
  // you may not use this file except in compliance with the License.
@@ -11,16 +21,6 @@
11
21
  // See the License for the specific language governing permissions and
12
22
  // limitations under the License.
13
23
  // Target number of bars for log volume histogram
14
- "use strict";
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
18
- Object.defineProperty(exports, "calculateVolumeInterval", {
19
- enumerable: true,
20
- get: function() {
21
- return calculateVolumeInterval;
22
- }
23
- });
24
24
  const TARGET_HISTOGRAM_BARS = 40;
25
25
  // Standard intervals for histogram calculations (in milliseconds)
26
26
  const STANDARD_INTERVALS = [
@@ -20,21 +20,37 @@ Object.defineProperty(exports, "dynamicImportPluginLoader", {
20
20
  return dynamicImportPluginLoader;
21
21
  }
22
22
  });
23
+ const _plugins = require("./plugins");
23
24
  function dynamicImportPluginLoader(plugins) {
24
- const importMap = new Map(plugins.map((plugin)=>[
25
- plugin.resource,
26
- plugin.importPlugin
27
- ]));
25
+ const importMap = new Map();
26
+ for (const p of plugins){
27
+ const { resource, resource: { kind, metadata: { name, registry, version } }, importPlugin } = p;
28
+ importMap.set((0, _plugins.getPluginModuleCompoundKey)({
29
+ kind,
30
+ name,
31
+ registry,
32
+ version
33
+ }), {
34
+ resource,
35
+ importPlugin
36
+ });
37
+ }
28
38
  return {
29
39
  async getInstalledPlugins () {
30
- return Promise.resolve(Array.from(importMap.keys()));
40
+ return Promise.resolve(Array.from(importMap.values()).map((v)=>v.resource));
31
41
  },
32
42
  importPluginModule (resource) {
33
- const importFn = importMap.get(resource);
34
- if (importFn === undefined) {
43
+ const { kind, metadata: { name, version, registry } } = resource;
44
+ const { importPlugin } = importMap.get((0, _plugins.getPluginModuleCompoundKey)({
45
+ kind,
46
+ name,
47
+ registry,
48
+ version
49
+ })) || {};
50
+ if (importPlugin === undefined) {
35
51
  throw new Error('Plugin not found');
36
52
  }
37
- return importFn();
53
+ return importPlugin();
38
54
  }
39
55
  };
40
56
  }
@@ -14,3 +14,13 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "getPluginModuleCompoundKey", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return getPluginModuleCompoundKey;
21
+ }
22
+ });
23
+ function getPluginModuleCompoundKey(compoundKey) {
24
+ const { kind, name, registry, version } = compoundKey;
25
+ return `${kind}:${name}:${registry ?? ''}:${version ?? ''}`;
26
+ }
@@ -0,0 +1,16 @@
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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -14,3 +14,13 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "isTimeSeriesValueTuple", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return isTimeSeriesValueTuple;
21
+ }
22
+ });
23
+ function isTimeSeriesValueTuple(data) {
24
+ if (data.length !== 2) return false;
25
+ return true;
26
+ }
@@ -156,6 +156,14 @@ const getPluginRuntime = ()=>{
156
156
  requiredVersion: '^0.53.1'
157
157
  }
158
158
  },
159
+ '@perses-dev/client': {
160
+ version: '0.54.0-beta.1',
161
+ lib: ()=>require('@perses-dev/client'),
162
+ shareConfig: {
163
+ singleton: true,
164
+ requiredVersion: '^0.54.0-beta.1'
165
+ }
166
+ },
159
167
  '@perses-dev/components': {
160
168
  version: '0.53.1',
161
169
  lib: ()=>require('@perses-dev/components'),
@@ -268,28 +276,49 @@ const getPluginRuntime = ()=>{
268
276
  }
269
277
  return instance;
270
278
  };
271
- const registerRemote = (name, baseURL)=>{
279
+ function getModuleFederationRemoteName(name, registry, version) {
280
+ return `${name}:${registry ?? ''}:${version ?? ''}`;
281
+ }
282
+ const registerRemote = (name, registry, version, baseURL)=>{
272
283
  const pluginRuntime = getPluginRuntime();
273
- const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === name);
284
+ const registryName = getModuleFederationRemoteName(name, registry, version);
285
+ const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === registryName);
274
286
  if (!existingRemote) {
275
- const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;
287
+ const nameVersionRegistry = [
288
+ name,
289
+ version,
290
+ registry
291
+ ].filter(Boolean).join('~');
292
+ const prefix = baseURL || '/plugins';
293
+ const remoteEntryURL = `${prefix}/${nameVersionRegistry}/mf-manifest.json`;
276
294
  pluginRuntime.registerRemotes([
277
295
  {
278
- name,
296
+ name: registryName,
279
297
  entry: remoteEntryURL,
280
- alias: name
298
+ alias: registryName
281
299
  }
282
300
  ]);
283
301
  }
284
302
  };
285
- const loadPlugin = async (moduleName, pluginName, baseURL)=>{
286
- registerRemote(moduleName, baseURL);
303
+ const loadPlugin = async (target)=>{
304
+ const { moduleName, pluginName, registry, version, baseURL } = target;
305
+ registerRemote(moduleName, registry, version, baseURL);
287
306
  const pluginRuntime = getPluginRuntime();
288
- return pluginRuntime.loadRemote(`${moduleName}/${pluginName}`);
307
+ const registryName = getModuleFederationRemoteName(moduleName, registry, version);
308
+ return pluginRuntime.loadRemote(`${registryName}/${pluginName}`);
289
309
  };
290
310
  function usePluginRuntime({ plugin }) {
291
311
  return {
292
312
  pluginRuntime: getPluginRuntime(),
293
- loadPlugin: ()=>loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL)
313
+ loadPlugin: ()=>{
314
+ const { moduleName, name: pluginName, registry, version, baseURL } = plugin;
315
+ return loadPlugin({
316
+ moduleName,
317
+ pluginName,
318
+ registry,
319
+ version,
320
+ baseURL
321
+ });
322
+ }
294
323
  };
295
324
  }
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "remotePluginLoader", {
20
20
  return remotePluginLoader;
21
21
  }
22
22
  });
23
+ const _pluginsystem = require("@perses-dev/plugin-system");
23
24
  const _PluginRuntime = require("./PluginRuntime");
24
25
  const isPluginMetadata = (plugin)=>{
25
26
  return typeof plugin === 'object' && plugin !== null && 'kind' in plugin && 'spec' in plugin && typeof plugin.spec === 'object' && plugin.spec !== null && 'name' in plugin.spec;
@@ -59,17 +60,39 @@ function remotePluginLoader(options) {
59
60
  return pluginModules;
60
61
  },
61
62
  importPluginModule: async (resource)=>{
62
- const pluginModuleName = resource.metadata.name;
63
+ const { name: pluginModuleName, version, registry } = resource.metadata;
63
64
  const pluginModule = {};
64
- for (const plugin of resource.spec.plugins){
65
- const remotePluginModule = await (0, _PluginRuntime.loadPlugin)(pluginModuleName, plugin.spec.name, pluginsAssetsPath);
65
+ const loadPromises = resource.spec.plugins.map(async (plugin)=>{
66
+ const remotePluginModule = await (0, _PluginRuntime.loadPlugin)({
67
+ moduleName: pluginModuleName,
68
+ pluginName: plugin.spec.name,
69
+ registry,
70
+ version,
71
+ baseURL: pluginsAssetsPath
72
+ });
66
73
  const remotePlugin = remotePluginModule?.[plugin.spec.name];
67
74
  if (remotePlugin) {
68
- pluginModule[plugin.spec.name] = remotePlugin;
75
+ return {
76
+ kind: plugin.kind,
77
+ name: plugin.spec.name,
78
+ remotePlugin
79
+ };
69
80
  } else {
70
81
  console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);
82
+ return null;
71
83
  }
72
- }
84
+ });
85
+ const loadedPlugins = await Promise.all(loadPromises);
86
+ loadedPlugins.forEach((item)=>{
87
+ if (item?.remotePlugin) {
88
+ pluginModule[(0, _pluginsystem.getPluginModuleCompoundKey)({
89
+ kind: item.kind,
90
+ name: item.name,
91
+ registry,
92
+ version
93
+ })] = item.remotePlugin;
94
+ }
95
+ });
73
96
  return pluginModule;
74
97
  }
75
98
  };
@@ -39,6 +39,8 @@ const _react = require("react");
39
39
  const _timeseriesqueries = require("../time-series-queries");
40
40
  const _tracequeries = require("../trace-queries");
41
41
  const _profilequeries = require("../profile-queries");
42
+ const _alertsqueries = require("../alerts-queries");
43
+ const _silencesqueries = require("../silences-queries");
42
44
  const _UsageMetricsProvider = require("../UsageMetricsProvider");
43
45
  const _logqueries = require("../log-queries");
44
46
  const _model = require("./model");
@@ -89,23 +91,33 @@ function DataQueriesProvider(props) {
89
91
  const profileResults = (0, _profilequeries.useProfileQueries)(profileQueries);
90
92
  const logQueries = queryDefinitions.filter((definition)=>definition.kind === 'LogQuery');
91
93
  const logResults = (0, _logqueries.useLogQueries)(logQueries);
94
+ const alertsQueries = queryDefinitions.filter((definition)=>definition.kind === 'AlertsQuery');
95
+ const alertsResults = (0, _alertsqueries.useAlertsQueries)(alertsQueries);
96
+ const silencesQueries = queryDefinitions.filter((definition)=>definition.kind === 'SilencesQuery');
97
+ const silencesResults = (0, _silencesqueries.useSilencesQueries)(silencesQueries);
92
98
  const refetchAll = (0, _react.useCallback)(()=>{
93
99
  timeSeriesResults.forEach((result)=>result.refetch());
94
100
  traceResults.forEach((result)=>result.refetch());
95
101
  profileResults.forEach((result)=>result.refetch());
96
102
  logResults.forEach((result)=>result.refetch());
103
+ alertsResults.forEach((result)=>result.refetch());
104
+ silencesResults.forEach((result)=>result.refetch());
97
105
  }, [
98
106
  timeSeriesResults,
99
107
  traceResults,
100
108
  profileResults,
101
- logResults
109
+ logResults,
110
+ alertsResults,
111
+ silencesResults
102
112
  ]);
103
113
  const ctx = (0, _react.useMemo)(()=>{
104
114
  const mergedQueryResults = [
105
115
  ...(0, _model.transformQueryResults)(timeSeriesResults, timeSeriesQueries),
106
116
  ...(0, _model.transformQueryResults)(traceResults, traceQueries),
107
117
  ...(0, _model.transformQueryResults)(profileResults, profileQueries),
108
- ...(0, _model.transformQueryResults)(logResults, logQueries)
118
+ ...(0, _model.transformQueryResults)(logResults, logQueries),
119
+ ...(0, _model.transformQueryResults)(alertsResults, alertsQueries),
120
+ ...(0, _model.transformQueryResults)(silencesResults, silencesQueries)
109
121
  ];
110
122
  if (queryOptions?.enabled) {
111
123
  for (const result of mergedQueryResults){
@@ -134,6 +146,10 @@ function DataQueriesProvider(props) {
134
146
  profileResults,
135
147
  logQueries,
136
148
  logResults,
149
+ alertsQueries,
150
+ alertsResults,
151
+ silencesQueries,
152
+ silencesResults,
137
153
  refetchAll,
138
154
  queryOptions?.enabled,
139
155
  usageMetrics
@@ -55,13 +55,21 @@ function useQueryType() {
55
55
  const { data: logQueries, isLoading: isLogQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
56
56
  'LogQuery'
57
57
  ]);
58
+ const { data: alertsQueryPlugins, isLoading: isAlertsQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
59
+ 'AlertsQuery'
60
+ ]);
61
+ const { data: silencesQueryPlugins, isLoading: isSilencesQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
62
+ 'SilencesQuery'
63
+ ]);
58
64
  // For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
59
65
  const queryTypeMap = (0, _react.useMemo)(()=>{
60
66
  const map = {
61
67
  TimeSeriesQuery: [],
62
68
  TraceQuery: [],
63
69
  ProfileQuery: [],
64
- LogQuery: []
70
+ LogQuery: [],
71
+ AlertsQuery: [],
72
+ SilencesQuery: []
65
73
  };
66
74
  if (timeSeriesQueryPlugins) {
67
75
  timeSeriesQueryPlugins.forEach((plugin)=>{
@@ -83,12 +91,24 @@ function useQueryType() {
83
91
  map[plugin.kind]?.push(plugin.spec.name);
84
92
  });
85
93
  }
94
+ if (alertsQueryPlugins) {
95
+ alertsQueryPlugins.forEach((plugin)=>{
96
+ map[plugin.kind]?.push(plugin.spec.name);
97
+ });
98
+ }
99
+ if (silencesQueryPlugins) {
100
+ silencesQueryPlugins.forEach((plugin)=>{
101
+ map[plugin.kind]?.push(plugin.spec.name);
102
+ });
103
+ }
86
104
  return map;
87
105
  }, [
88
106
  timeSeriesQueryPlugins,
89
107
  traceQueryPlugins,
90
108
  profileQueryPlugins,
91
- logQueries
109
+ logQueries,
110
+ alertsQueryPlugins,
111
+ silencesQueryPlugins
92
112
  ]);
93
113
  const getQueryType = (0, _react.useCallback)((pluginKind)=>{
94
114
  const isLoading = (pluginKind)=>{
@@ -101,8 +121,12 @@ function useQueryType() {
101
121
  return isProfileQueryPluginLoading;
102
122
  case 'LokiLogQuery':
103
123
  return isLogQueryPluginLoading;
124
+ case 'AlertmanagerAlertsQuery':
125
+ return isAlertsQueryPluginLoading;
126
+ case 'AlertmanagerSilencesQuery':
127
+ return isSilencesQueryPluginLoading;
104
128
  }
105
- return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading || isLogQueryPluginLoading;
129
+ return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading || isLogQueryPluginLoading || isAlertsQueryPluginLoading || isSilencesQueryPluginLoading;
106
130
  };
107
131
  if (isLoading(pluginKind)) {
108
132
  return undefined;
@@ -118,7 +142,9 @@ function useQueryType() {
118
142
  isTimeSeriesQueryLoading,
119
143
  isTraceQueryPluginLoading,
120
144
  isProfileQueryPluginLoading,
121
- isLogQueryPluginLoading
145
+ isLogQueryPluginLoading,
146
+ isAlertsQueryPluginLoading,
147
+ isSilencesQueryPluginLoading
122
148
  ]);
123
149
  return getQueryType;
124
150
  }
@@ -35,7 +35,7 @@ _export(exports, {
35
35
  }
36
36
  });
37
37
  const _jsxruntime = require("react/jsx-runtime");
38
- const _core = require("@perses-dev/core");
38
+ const _client = require("@perses-dev/client");
39
39
  const _react = require("react");
40
40
  const UsageMetricsContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
41
41
  const useUsageMetricsContext = ()=>{
@@ -70,7 +70,7 @@ const useUsageMetrics = ()=>{
70
70
  };
71
71
  };
72
72
  const submitMetrics = async (stats)=>{
73
- await (0, _core.fetch)(`${stats.apiPrefix ?? ''}/api/v1/view`, {
73
+ await (0, _client.fetch)(`${stats.apiPrefix ?? ''}/api/v1/view`, {
74
74
  method: 'POST',
75
75
  headers: {
76
76
  'Content-Type': 'application/json'