@perses-dev/plugin-system 0.51.0-beta.0 → 0.51.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DatasourceSelect.js +155 -71
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +2 -2
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +91 -1
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +11 -7
- package/dist/cjs/constants/user-interface-text.js +3 -1
- package/dist/cjs/remote/PluginRuntime.js +168 -162
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +13 -0
- package/dist/cjs/runtime/plugin-registry.js +13 -4
- package/dist/cjs/runtime/time-series-queries.js +3 -13
- package/dist/cjs/runtime/trace-queries.js +46 -16
- package/dist/cjs/{stories/shared-utils/index.js → runtime/utils.js} +21 -12
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.d.ts +8 -3
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +148 -72
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +94 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +11 -7
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +3 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/model/trace-queries.d.ts +13 -1
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +0 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +169 -160
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +7 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +13 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +13 -4
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +1 -11
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +47 -17
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/utils.d.ts +7 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/{stories/shared-utils/index.js → runtime/utils.js} +12 -2
- package/dist/runtime/utils.js.map +1 -0
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -9
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +0 -34
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -101
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/index.js +0 -35
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +0 -33
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +0 -4
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +0 -26
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -95
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +0 -33
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +0 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +0 -7
- package/dist/stories/shared-utils/decorators/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/index.js +0 -20
- package/dist/stories/shared-utils/decorators/index.js.map +0 -1
- package/dist/stories/shared-utils/index.d.ts +0 -2
- package/dist/stories/shared-utils/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/index.js.map +0 -1
|
@@ -24,9 +24,6 @@ _export(exports, {
|
|
|
24
24
|
loadPlugin: function() {
|
|
25
25
|
return loadPlugin;
|
|
26
26
|
},
|
|
27
|
-
pluginRuntime: function() {
|
|
28
|
-
return pluginRuntime;
|
|
29
|
-
},
|
|
30
27
|
usePluginRuntime: function() {
|
|
31
28
|
return usePluginRuntime;
|
|
32
29
|
}
|
|
@@ -35,8 +32,8 @@ const _runtime = require("@module-federation/enhanced/runtime");
|
|
|
35
32
|
const _reactquery = /*#__PURE__*/ _interop_require_wildcard(require("@tanstack/react-query"));
|
|
36
33
|
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
37
34
|
const _reactdom = /*#__PURE__*/ _interop_require_default(require("react-dom"));
|
|
38
|
-
const _reactrouterdom = /*#__PURE__*/ _interop_require_wildcard(require("react-router-dom"));
|
|
39
35
|
const _reacthookform = /*#__PURE__*/ _interop_require_wildcard(require("react-hook-form"));
|
|
36
|
+
const _reactrouterdom = /*#__PURE__*/ _interop_require_wildcard(require("react-router-dom"));
|
|
40
37
|
function _interop_require_default(obj) {
|
|
41
38
|
return obj && obj.__esModule ? obj : {
|
|
42
39
|
default: obj
|
|
@@ -83,166 +80,175 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
83
80
|
}
|
|
84
81
|
return newObj;
|
|
85
82
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
83
|
+
let instance = null;
|
|
84
|
+
const getPluginRuntime = ()=>{
|
|
85
|
+
if (instance === null) {
|
|
86
|
+
const pluginRuntime = (0, _runtime.init)({
|
|
87
|
+
name: '@perses/perses-ui-host',
|
|
88
|
+
remotes: [],
|
|
89
|
+
shared: {
|
|
90
|
+
react: {
|
|
91
|
+
version: _react.default.version,
|
|
92
|
+
lib: ()=>_react.default,
|
|
93
|
+
shareConfig: {
|
|
94
|
+
singleton: true,
|
|
95
|
+
requiredVersion: `^${_react.default.version}`
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
'react-dom': {
|
|
99
|
+
version: '18.3.1',
|
|
100
|
+
lib: ()=>_reactdom.default,
|
|
101
|
+
shareConfig: {
|
|
102
|
+
singleton: true,
|
|
103
|
+
requiredVersion: `^18.3.1`
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
'react-router-dom': {
|
|
107
|
+
version: '6.26.0',
|
|
108
|
+
lib: ()=>_reactrouterdom,
|
|
109
|
+
shareConfig: {
|
|
110
|
+
singleton: true,
|
|
111
|
+
requiredVersion: '^6.26.0'
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
'@tanstack/react-query': {
|
|
115
|
+
version: '5.64.2',
|
|
116
|
+
lib: ()=>_reactquery,
|
|
117
|
+
shareConfig: {
|
|
118
|
+
singleton: true,
|
|
119
|
+
requiredVersion: '^5.64.2'
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
'react-hook-form': {
|
|
123
|
+
version: '7.52.2',
|
|
124
|
+
lib: ()=>_reacthookform,
|
|
125
|
+
shareConfig: {
|
|
126
|
+
singleton: true,
|
|
127
|
+
requiredVersion: '^7.52.2'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
echarts: {
|
|
131
|
+
version: '5.5.0',
|
|
132
|
+
lib: ()=>require('echarts'),
|
|
133
|
+
shareConfig: {
|
|
134
|
+
singleton: true,
|
|
135
|
+
requiredVersion: '^5.5.0'
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
'@perses-dev/components': {
|
|
139
|
+
version: '0.51.0-beta.0',
|
|
140
|
+
lib: ()=>require('@perses-dev/components'),
|
|
141
|
+
shareConfig: {
|
|
142
|
+
singleton: true,
|
|
143
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
'@perses-dev/plugin-system': {
|
|
147
|
+
version: '0.51.0-beta.0',
|
|
148
|
+
lib: ()=>require('@perses-dev/plugin-system'),
|
|
149
|
+
shareConfig: {
|
|
150
|
+
singleton: true,
|
|
151
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
'@perses-dev/explore': {
|
|
155
|
+
version: '0.51.0-beta.0',
|
|
156
|
+
lib: ()=>require('@perses-dev/explore'),
|
|
157
|
+
shareConfig: {
|
|
158
|
+
singleton: true,
|
|
159
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
'@perses-dev/dashboards': {
|
|
163
|
+
version: '0.51.0-beta.0',
|
|
164
|
+
lib: ()=>require('@perses-dev/dashboards'),
|
|
165
|
+
shareConfig: {
|
|
166
|
+
singleton: true,
|
|
167
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
// Below are the shared modules that are used by the plugins, this can be part of the SDK
|
|
171
|
+
'date-fns': {
|
|
172
|
+
version: '4.1.0',
|
|
173
|
+
lib: ()=>require('date-fns'),
|
|
174
|
+
shareConfig: {
|
|
175
|
+
singleton: true,
|
|
176
|
+
requiredVersion: '^4.1.0'
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
'date-fns-tz': {
|
|
180
|
+
version: '3.2.0',
|
|
181
|
+
lib: ()=>require('date-fns-tz'),
|
|
182
|
+
shareConfig: {
|
|
183
|
+
singleton: true,
|
|
184
|
+
requiredVersion: '^3.2.0'
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
lodash: {
|
|
188
|
+
version: '4.17.21',
|
|
189
|
+
lib: ()=>require('lodash'),
|
|
190
|
+
shareConfig: {
|
|
191
|
+
singleton: true,
|
|
192
|
+
requiredVersion: '^4.17.21'
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
'@emotion/react': {
|
|
196
|
+
version: '11.11.3',
|
|
197
|
+
lib: ()=>require('@emotion/react'),
|
|
198
|
+
shareConfig: {
|
|
199
|
+
singleton: true,
|
|
200
|
+
requiredVersion: '^11.11.3'
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
'@emotion/styled': {
|
|
204
|
+
version: '11.11.0',
|
|
205
|
+
lib: ()=>require('@emotion/styled'),
|
|
206
|
+
shareConfig: {
|
|
207
|
+
singleton: true,
|
|
208
|
+
requiredVersion: '^11.11.0'
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
'@hookform/resolvers/zod': {
|
|
212
|
+
version: '3.3.4',
|
|
213
|
+
lib: ()=>require('@hookform/resolvers/zod'),
|
|
214
|
+
shareConfig: {
|
|
215
|
+
singleton: true,
|
|
216
|
+
requiredVersion: '^3.3.4'
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
'use-resize-observer': {
|
|
220
|
+
version: '9.1.0',
|
|
221
|
+
lib: ()=>require('use-resize-observer'),
|
|
222
|
+
shareConfig: {
|
|
223
|
+
singleton: true,
|
|
224
|
+
requiredVersion: '^9.1.0'
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
'mdi-material-ui': {
|
|
228
|
+
version: '7.4.0',
|
|
229
|
+
lib: ()=>require('mdi-material-ui'),
|
|
230
|
+
shareConfig: {
|
|
231
|
+
singleton: true,
|
|
232
|
+
requiredVersion: '^7.4.0'
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
immer: {
|
|
236
|
+
version: '10.1.1',
|
|
237
|
+
lib: ()=>require('immer'),
|
|
238
|
+
shareConfig: {
|
|
239
|
+
singleton: true,
|
|
240
|
+
requiredVersion: '^10.1.1'
|
|
241
|
+
}
|
|
242
|
+
}
|
|
168
243
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
version: '2.29.3',
|
|
173
|
-
lib: ()=>require('date-fns'),
|
|
174
|
-
shareConfig: {
|
|
175
|
-
singleton: true,
|
|
176
|
-
requiredVersion: '^2.29.3'
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
'date-fns-tz': {
|
|
180
|
-
version: '1.3.8',
|
|
181
|
-
lib: ()=>require('date-fns-tz'),
|
|
182
|
-
shareConfig: {
|
|
183
|
-
singleton: true,
|
|
184
|
-
requiredVersion: '^1.3.8'
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
lodash: {
|
|
188
|
-
version: '4.17.21',
|
|
189
|
-
lib: ()=>require('lodash'),
|
|
190
|
-
shareConfig: {
|
|
191
|
-
singleton: true,
|
|
192
|
-
requiredVersion: '^4.17.21'
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
'@emotion/react': {
|
|
196
|
-
version: '11.11.3',
|
|
197
|
-
lib: ()=>require('@emotion/react'),
|
|
198
|
-
shareConfig: {
|
|
199
|
-
singleton: true,
|
|
200
|
-
requiredVersion: '^11.11.3'
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
'@emotion/styled': {
|
|
204
|
-
version: '11.11.0',
|
|
205
|
-
lib: ()=>require('@emotion/styled'),
|
|
206
|
-
shareConfig: {
|
|
207
|
-
singleton: true,
|
|
208
|
-
requiredVersion: '^11.11.0'
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
'@hookform/resolvers/zod': {
|
|
212
|
-
version: '3.3.4',
|
|
213
|
-
lib: ()=>require('@hookform/resolvers/zod'),
|
|
214
|
-
shareConfig: {
|
|
215
|
-
singleton: true,
|
|
216
|
-
requiredVersion: '^3.3.4'
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
'use-resize-observer': {
|
|
220
|
-
version: '9.1.0',
|
|
221
|
-
lib: ()=>require('use-resize-observer'),
|
|
222
|
-
shareConfig: {
|
|
223
|
-
singleton: true,
|
|
224
|
-
requiredVersion: '^9.1.0'
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
'mdi-material-ui': {
|
|
228
|
-
version: '7.4.0',
|
|
229
|
-
lib: ()=>require('mdi-material-ui'),
|
|
230
|
-
shareConfig: {
|
|
231
|
-
singleton: true,
|
|
232
|
-
requiredVersion: '^7.4.0'
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
immer: {
|
|
236
|
-
version: '9.0.15',
|
|
237
|
-
lib: ()=>require('immer'),
|
|
238
|
-
shareConfig: {
|
|
239
|
-
singleton: true,
|
|
240
|
-
requiredVersion: '^9.0.15'
|
|
241
|
-
}
|
|
242
|
-
}
|
|
244
|
+
});
|
|
245
|
+
instance = pluginRuntime;
|
|
246
|
+
return instance;
|
|
243
247
|
}
|
|
244
|
-
|
|
248
|
+
return instance;
|
|
249
|
+
};
|
|
245
250
|
const registerRemote = (name, baseURL)=>{
|
|
251
|
+
const pluginRuntime = getPluginRuntime();
|
|
246
252
|
const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === name);
|
|
247
253
|
if (!existingRemote) {
|
|
248
254
|
const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;
|
|
@@ -261,7 +267,7 @@ const loadPlugin = async (moduleName, pluginName, baseURL)=>{
|
|
|
261
267
|
};
|
|
262
268
|
function usePluginRuntime({ plugin }) {
|
|
263
269
|
return {
|
|
264
|
-
pluginRuntime,
|
|
270
|
+
pluginRuntime: getPluginRuntime(),
|
|
265
271
|
loadPlugin: ()=>loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL)
|
|
266
272
|
};
|
|
267
273
|
}
|
|
@@ -30,6 +30,9 @@ _export(exports, {
|
|
|
30
30
|
useShowCustomTimeRangeSetting: function() {
|
|
31
31
|
return useShowCustomTimeRangeSetting;
|
|
32
32
|
},
|
|
33
|
+
useShowZoomRangeSetting: function() {
|
|
34
|
+
return useShowZoomRangeSetting;
|
|
35
|
+
},
|
|
33
36
|
useTimeRangeOptionsSetting: function() {
|
|
34
37
|
return useTimeRangeOptionsSetting;
|
|
35
38
|
},
|
|
@@ -56,6 +59,7 @@ const DEFAULT_OPTIONS = [
|
|
|
56
59
|
];
|
|
57
60
|
const defaultTimeRangeSettings = {
|
|
58
61
|
showCustom: true,
|
|
62
|
+
showZoomButtons: true,
|
|
59
63
|
options: DEFAULT_OPTIONS.map((duration)=>(0, _components.buildRelativeTimeOption)(duration))
|
|
60
64
|
};
|
|
61
65
|
const TimeRangeSettingsContext = /*#__PURE__*/ (0, _react.createContext)(defaultTimeRangeSettings);
|
|
@@ -76,6 +80,13 @@ function useShowCustomTimeRangeSetting(override) {
|
|
|
76
80
|
}
|
|
77
81
|
return showCustomTimeRange;
|
|
78
82
|
}
|
|
83
|
+
function useShowZoomRangeSetting(override) {
|
|
84
|
+
const showZoomTimeRange = useTimeRangeSettings().showZoomButtons;
|
|
85
|
+
if (override !== undefined) {
|
|
86
|
+
return override;
|
|
87
|
+
}
|
|
88
|
+
return showZoomTimeRange;
|
|
89
|
+
}
|
|
79
90
|
function useTimeRangeOptionsSetting(override) {
|
|
80
91
|
const showCustomTimeRange = useTimeRangeSettings().options;
|
|
81
92
|
if (override !== undefined) {
|
|
@@ -87,10 +98,12 @@ function TimeRangeSettingsProvider(props) {
|
|
|
87
98
|
const ctx = (0, _react.useMemo)(()=>{
|
|
88
99
|
return {
|
|
89
100
|
showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,
|
|
101
|
+
showZoomButtons: props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,
|
|
90
102
|
options: props.options === undefined ? defaultTimeRangeSettings.options : props.options
|
|
91
103
|
};
|
|
92
104
|
}, [
|
|
93
105
|
props.showCustom,
|
|
106
|
+
props.showZoomButtons,
|
|
94
107
|
props.options
|
|
95
108
|
]);
|
|
96
109
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(TimeRangeSettingsContext.Provider, {
|
|
@@ -69,18 +69,27 @@ function usePlugin(pluginType, kind, options) {
|
|
|
69
69
|
}
|
|
70
70
|
function usePlugins(pluginType, plugins) {
|
|
71
71
|
const { getPlugin } = usePluginRegistry();
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()
|
|
73
|
+
// This resolves the following warning in the JS console: "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
|
|
74
|
+
// https://github.com/TanStack/query/issues/8224#issuecomment-2523554831
|
|
75
|
+
// https://github.com/TanStack/query/issues/4187#issuecomment-1256336901
|
|
76
|
+
const kinds = [
|
|
77
|
+
...new Set(plugins.map((p)=>p.kind))
|
|
78
|
+
];
|
|
79
|
+
const result = (0, _reactquery.useQueries)({
|
|
80
|
+
queries: kinds.map((kind)=>{
|
|
74
81
|
return {
|
|
75
82
|
queryKey: [
|
|
76
83
|
'getPlugin',
|
|
77
84
|
pluginType,
|
|
78
|
-
|
|
85
|
+
kind
|
|
79
86
|
],
|
|
80
|
-
queryFn: ()=>getPlugin(pluginType,
|
|
87
|
+
queryFn: ()=>getPlugin(pluginType, kind)
|
|
81
88
|
};
|
|
82
89
|
})
|
|
83
90
|
});
|
|
91
|
+
// Re-assemble array in original order
|
|
92
|
+
return plugins.map((p)=>result[kinds.indexOf(p.kind)]);
|
|
84
93
|
}
|
|
85
94
|
function useListPluginMetadata(pluginTypes, options) {
|
|
86
95
|
const { listPluginMetadata } = usePluginRegistry();
|
|
@@ -42,25 +42,15 @@ const _variables = require("./variables");
|
|
|
42
42
|
const _TimeRangeProvider = require("./TimeRangeProvider");
|
|
43
43
|
const _datasources = require("./datasources");
|
|
44
44
|
const _pluginregistry = require("./plugin-registry");
|
|
45
|
+
const _utils = require("./utils");
|
|
45
46
|
const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';
|
|
46
|
-
/**
|
|
47
|
-
* Returns a serialized string of the current state of variable values.
|
|
48
|
-
*/ function getVariableValuesKey(v) {
|
|
49
|
-
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
50
|
-
}
|
|
51
|
-
function filterVariableStateMap(v, names) {
|
|
52
|
-
if (!names) {
|
|
53
|
-
return v;
|
|
54
|
-
}
|
|
55
|
-
return Object.fromEntries(Object.entries(v).filter(([name])=>names.includes(name)));
|
|
56
|
-
}
|
|
57
47
|
function getQueryOptions({ plugin, definition, context }) {
|
|
58
48
|
const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;
|
|
59
49
|
const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
|
|
60
50
|
const variableDependencies = dependencies?.variables;
|
|
61
51
|
// Determine queryKey
|
|
62
|
-
const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);
|
|
63
|
-
const variablesValueKey = getVariableValuesKey(filteredVariabledState);
|
|
52
|
+
const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
|
|
53
|
+
const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
|
|
64
54
|
const queryKey = [
|
|
65
55
|
definition,
|
|
66
56
|
timeRange,
|
|
@@ -36,6 +36,8 @@ const _reactquery = require("@tanstack/react-query");
|
|
|
36
36
|
const _datasources = require("./datasources");
|
|
37
37
|
const _pluginregistry = require("./plugin-registry");
|
|
38
38
|
const _TimeRangeProvider = require("./TimeRangeProvider");
|
|
39
|
+
const _variables = require("./variables");
|
|
40
|
+
const _utils = require("./utils");
|
|
39
41
|
const TRACE_QUERY_KEY = 'TraceQuery';
|
|
40
42
|
function getUnixTimeRange(timeRange) {
|
|
41
43
|
const { start, end } = timeRange;
|
|
@@ -46,34 +48,62 @@ function getUnixTimeRange(timeRange) {
|
|
|
46
48
|
}
|
|
47
49
|
function useTraceQueries(definitions) {
|
|
48
50
|
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
absoluteTimeRange
|
|
54
|
-
};
|
|
51
|
+
const context = useTraceQueryContext();
|
|
52
|
+
const pluginLoaderResponse = (0, _pluginregistry.usePlugins)('TraceQuery', definitions.map((d)=>({
|
|
53
|
+
kind: d.spec.plugin.kind
|
|
54
|
+
})));
|
|
55
55
|
// useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)
|
|
56
56
|
// https://tanstack.com/query/v4/docs/react/reference/useQuery
|
|
57
57
|
return (0, _reactquery.useQueries)({
|
|
58
|
-
queries: definitions.map((definition)=>{
|
|
59
|
-
const
|
|
58
|
+
queries: definitions.map((definition, idx)=>{
|
|
59
|
+
const plugin = pluginLoaderResponse[idx]?.data;
|
|
60
|
+
const { queryEnabled, queryKey } = getQueryOptions({
|
|
61
|
+
context,
|
|
60
62
|
definition,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
]; // `queryKey` watches and reruns `queryFn` if keys in the array change
|
|
63
|
+
plugin
|
|
64
|
+
});
|
|
64
65
|
const traceQueryKind = definition?.spec?.plugin?.kind;
|
|
65
66
|
return {
|
|
67
|
+
enabled: queryEnabled,
|
|
66
68
|
queryKey: queryKey,
|
|
67
69
|
queryFn: async ()=>{
|
|
68
70
|
const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);
|
|
69
71
|
const data = await plugin.getTraceData(definition.spec.plugin.spec, context);
|
|
70
72
|
return data;
|
|
71
|
-
}
|
|
72
|
-
// The data returned by getTraceData() contains circular dependencies (a span has a reference to the parent span, and the parent span has an array of child spans)
|
|
73
|
-
// Therefore structuralSharing must be turned off, otherwise the query is stuck in the 'fetching' state on re-fetch.
|
|
74
|
-
// Ref: https://github.com/TanStack/query/issues/6954#issuecomment-1962321426
|
|
75
|
-
structuralSharing: false
|
|
73
|
+
}
|
|
76
74
|
};
|
|
77
75
|
})
|
|
78
76
|
});
|
|
79
77
|
}
|
|
78
|
+
function getQueryOptions({ plugin, definition, context }) {
|
|
79
|
+
const { datasourceStore, variableState, absoluteTimeRange } = context;
|
|
80
|
+
const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
|
|
81
|
+
const variableDependencies = dependencies?.variables;
|
|
82
|
+
const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
|
|
83
|
+
const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
|
|
84
|
+
const queryKey = [
|
|
85
|
+
definition,
|
|
86
|
+
datasourceStore,
|
|
87
|
+
absoluteTimeRange,
|
|
88
|
+
variablesValueKey
|
|
89
|
+
];
|
|
90
|
+
let waitToLoad = false;
|
|
91
|
+
if (variableDependencies) {
|
|
92
|
+
waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
|
|
93
|
+
}
|
|
94
|
+
const queryEnabled = plugin !== undefined && !waitToLoad;
|
|
95
|
+
return {
|
|
96
|
+
queryKey,
|
|
97
|
+
queryEnabled
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function useTraceQueryContext() {
|
|
101
|
+
const { absoluteTimeRange } = (0, _TimeRangeProvider.useTimeRange)();
|
|
102
|
+
const variableState = (0, _variables.useAllVariableValues)();
|
|
103
|
+
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
104
|
+
return {
|
|
105
|
+
variableState,
|
|
106
|
+
datasourceStore,
|
|
107
|
+
absoluteTimeRange
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -14,17 +14,26 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(to, k, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function() {
|
|
24
|
-
return from[k];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
28
21
|
});
|
|
29
|
-
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
filterVariableStateMap: function() {
|
|
25
|
+
return filterVariableStateMap;
|
|
26
|
+
},
|
|
27
|
+
getVariableValuesKey: function() {
|
|
28
|
+
return getVariableValuesKey;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function filterVariableStateMap(v, names) {
|
|
32
|
+
if (!names) {
|
|
33
|
+
return v;
|
|
34
|
+
}
|
|
35
|
+
return Object.fromEntries(Object.entries(v).filter(([name])=>names.includes(name)));
|
|
36
|
+
}
|
|
37
|
+
function getVariableValuesKey(v) {
|
|
38
|
+
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
30
39
|
}
|