@perses-dev/plugin-system 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59

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 (425) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +7 -5
  2. package/dist/cjs/components/CalculationSelector/index.js +10 -8
  3. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +350 -0
  4. package/dist/cjs/components/DatasourceEditorForm/index.js +30 -0
  5. package/dist/cjs/components/DatasourceSelect.js +137 -25
  6. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +19 -17
  7. package/dist/cjs/components/LegendOptionsEditor/index.js +10 -8
  8. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +25 -30
  9. package/dist/cjs/components/OptionsEditorRadios/index.js +10 -8
  10. package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +7 -5
  11. package/dist/cjs/components/OptionsEditorTabPanel/index.js +10 -8
  12. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +13 -11
  13. package/dist/cjs/components/OptionsEditorTabs/index.js +10 -8
  14. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +60 -19
  15. package/dist/cjs/components/PanelSpecEditor/index.js +10 -8
  16. package/dist/cjs/components/PluginEditor/PluginEditor.js +25 -32
  17. package/dist/cjs/components/PluginEditor/index.js +11 -9
  18. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +8 -6
  19. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +25 -14
  20. package/dist/cjs/components/PluginKindSelect/index.js +10 -8
  21. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -9
  22. package/dist/cjs/components/PluginRegistry/index.js +10 -8
  23. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +7 -3
  24. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +9 -7
  25. package/dist/cjs/components/PluginSpecEditor/index.js +10 -8
  26. package/dist/cjs/components/ProjectSelect.js +96 -0
  27. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
  28. package/dist/cjs/components/TimeRangeControls/index.js +30 -0
  29. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +45 -49
  30. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +23 -21
  31. package/dist/cjs/components/TimeSeriesQueryEditor/index.js +10 -8
  32. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +143 -0
  33. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +96 -0
  34. package/dist/cjs/components/TraceQueryEditor/index.js +30 -0
  35. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +445 -230
  36. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +38 -32
  37. package/dist/cjs/components/Variables/VariableEditorForm/index.js +11 -9
  38. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +36 -37
  39. package/dist/cjs/components/Variables/index.js +11 -9
  40. package/dist/cjs/components/Variables/variable-model.js +24 -17
  41. package/dist/cjs/components/index.js +24 -19
  42. package/dist/cjs/constants/index.js +10 -8
  43. package/dist/cjs/constants/user-interface-text.js +7 -2
  44. package/dist/cjs/context/ProjectStoreProvider.js +78 -0
  45. package/dist/cjs/context/index.js +30 -0
  46. package/dist/cjs/context/query-params.js +49 -0
  47. package/dist/cjs/index.js +17 -13
  48. package/dist/cjs/model/index.js +18 -15
  49. package/dist/cjs/model/legend.js +32 -20
  50. package/dist/cjs/model/panels.js +2 -2
  51. package/dist/cjs/model/plugin-base.js +2 -2
  52. package/dist/cjs/model/plugin-loading.js +3 -1
  53. package/dist/cjs/model/trace-queries.js +16 -0
  54. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +67 -35
  55. package/dist/cjs/runtime/DataQueriesProvider/index.js +11 -9
  56. package/dist/cjs/runtime/DataQueriesProvider/model.js +81 -0
  57. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +55 -27
  58. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +43 -0
  59. package/dist/cjs/runtime/TimeRangeProvider/index.js +12 -9
  60. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +45 -59
  61. package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +30 -0
  62. package/dist/cjs/runtime/builtin-variables.js +81 -0
  63. package/dist/cjs/runtime/datasources.js +31 -12
  64. package/dist/cjs/runtime/index.js +17 -13
  65. package/dist/cjs/runtime/plugin-registry.js +44 -14
  66. package/dist/cjs/runtime/template-variables.js +51 -13
  67. package/dist/cjs/runtime/time-series-queries.js +43 -31
  68. package/dist/cjs/runtime/trace-queries.js +76 -0
  69. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +7 -5
  70. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +21 -16
  71. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +42 -0
  72. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +31 -13
  73. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +6 -4
  74. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +9 -7
  75. package/dist/cjs/stories/shared-utils/decorators/index.js +15 -12
  76. package/dist/cjs/stories/shared-utils/index.js +10 -8
  77. package/dist/cjs/test/index.js +11 -8
  78. package/dist/cjs/test/mock-data.js +80 -0
  79. package/dist/cjs/test/render.js +13 -11
  80. package/dist/cjs/test/test-plugins/bert/index.js +16 -12
  81. package/dist/cjs/test/test-plugins/ernie/index.js +15 -11
  82. package/dist/cjs/test/test-plugins/index.js +14 -10
  83. package/dist/cjs/test-utils/index.js +10 -8
  84. package/dist/cjs/test-utils/mock-plugin-registry.js +9 -5
  85. package/dist/cjs/utils/action.js +43 -0
  86. package/dist/cjs/utils/index.js +11 -8
  87. package/dist/cjs/utils/variables.js +26 -8
  88. package/dist/cjs/validation/datasource.js +30 -0
  89. package/dist/cjs/validation/duration.js +25 -0
  90. package/dist/cjs/validation/index.js +34 -0
  91. package/dist/cjs/validation/resource.js +24 -0
  92. package/dist/cjs/validation/role.js +86 -0
  93. package/dist/cjs/validation/rolebinding.js +55 -0
  94. package/dist/cjs/validation/secret.js +176 -0
  95. package/dist/cjs/validation/user.js +46 -0
  96. package/dist/cjs/validation/variable.js +48 -0
  97. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -2
  98. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  99. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  100. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  101. package/dist/components/CalculationSelector/index.js.map +1 -1
  102. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +14 -0
  103. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -0
  104. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +342 -0
  105. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -0
  106. package/dist/components/DatasourceEditorForm/index.d.ts +2 -0
  107. package/dist/components/DatasourceEditorForm/index.d.ts.map +1 -0
  108. package/dist/components/DatasourceEditorForm/index.js +15 -0
  109. package/dist/components/DatasourceEditorForm/index.js.map +1 -0
  110. package/dist/components/DatasourceSelect.d.ts +8 -3
  111. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  112. package/dist/components/DatasourceSelect.js +120 -23
  113. package/dist/components/DatasourceSelect.js.map +1 -1
  114. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +1 -2
  115. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  116. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +3 -3
  117. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  118. package/dist/components/LegendOptionsEditor/index.js.map +1 -1
  119. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +5 -5
  120. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  121. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +18 -25
  122. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  123. package/dist/components/OptionsEditorRadios/index.js.map +1 -1
  124. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
  125. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  126. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  127. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  128. package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
  129. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  130. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  131. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  132. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  133. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  134. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +2 -3
  135. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  136. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +50 -11
  137. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  138. package/dist/components/PanelSpecEditor/index.js.map +1 -1
  139. package/dist/components/PluginEditor/PluginEditor.d.ts +1 -2
  140. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  141. package/dist/components/PluginEditor/PluginEditor.js +17 -26
  142. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  143. package/dist/components/PluginEditor/index.js.map +1 -1
  144. package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -3
  145. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  146. package/dist/components/PluginEditor/plugin-editor-api.js +5 -5
  147. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  148. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -3
  149. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  150. package/dist/components/PluginKindSelect/PluginKindSelect.js +23 -14
  151. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  152. package/dist/components/PluginKindSelect/index.js.map +1 -1
  153. package/dist/components/PluginRegistry/PluginRegistry.d.ts +4 -4
  154. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  155. package/dist/components/PluginRegistry/PluginRegistry.js +3 -3
  156. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  157. package/dist/components/PluginRegistry/index.js.map +1 -1
  158. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  159. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  160. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +2 -2
  161. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  162. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  163. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  164. package/dist/components/PluginSpecEditor/index.js.map +1 -1
  165. package/dist/components/ProjectSelect.d.ts +14 -0
  166. package/dist/components/ProjectSelect.d.ts.map +1 -0
  167. package/dist/components/ProjectSelect.js +91 -0
  168. package/dist/components/ProjectSelect.js.map +1 -0
  169. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
  170. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  171. package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
  172. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  173. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  174. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  175. package/dist/components/TimeRangeControls/index.js +15 -0
  176. package/dist/components/TimeRangeControls/index.js.map +1 -0
  177. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +1 -2
  178. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
  179. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +38 -44
  180. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
  181. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +1 -2
  182. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -1
  183. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
  184. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
  185. package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -1
  186. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +8 -0
  187. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -0
  188. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +130 -0
  189. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -0
  190. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +12 -0
  191. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -0
  192. package/dist/components/TraceQueryEditor/TraceQueryInput.js +83 -0
  193. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -0
  194. package/dist/components/TraceQueryEditor/index.d.ts +2 -0
  195. package/dist/components/TraceQueryEditor/index.d.ts.map +1 -0
  196. package/dist/components/TraceQueryEditor/index.js +15 -0
  197. package/dist/components/TraceQueryEditor/index.js.map +1 -0
  198. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +10 -8
  199. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  200. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -184
  201. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  202. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -3
  203. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  204. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +4 -4
  205. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  206. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  207. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +8 -19
  208. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  209. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +30 -35
  210. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  211. package/dist/components/Variables/index.js.map +1 -1
  212. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  213. package/dist/components/Variables/variable-model.js +9 -10
  214. package/dist/components/Variables/variable-model.js.map +1 -1
  215. package/dist/components/index.d.ts +3 -0
  216. package/dist/components/index.d.ts.map +1 -1
  217. package/dist/components/index.js +3 -0
  218. package/dist/components/index.js.map +1 -1
  219. package/dist/constants/index.js.map +1 -1
  220. package/dist/constants/user-interface-text.d.ts +2 -0
  221. package/dist/constants/user-interface-text.d.ts.map +1 -1
  222. package/dist/constants/user-interface-text.js +4 -1
  223. package/dist/constants/user-interface-text.js.map +1 -1
  224. package/dist/context/ProjectStoreProvider.d.ts +16 -0
  225. package/dist/context/ProjectStoreProvider.d.ts.map +1 -0
  226. package/dist/context/ProjectStoreProvider.js +56 -0
  227. package/dist/context/ProjectStoreProvider.js.map +1 -0
  228. package/dist/context/index.d.ts +2 -0
  229. package/dist/context/index.d.ts.map +1 -0
  230. package/dist/context/index.js +15 -0
  231. package/dist/context/index.js.map +1 -0
  232. package/dist/context/query-params.d.ts +5 -0
  233. package/dist/context/query-params.d.ts.map +1 -0
  234. package/dist/context/query-params.js +41 -0
  235. package/dist/context/query-params.js.map +1 -0
  236. package/dist/index.d.ts +2 -0
  237. package/dist/index.d.ts.map +1 -1
  238. package/dist/index.js +2 -0
  239. package/dist/index.js.map +1 -1
  240. package/dist/model/datasource.d.ts +2 -1
  241. package/dist/model/datasource.d.ts.map +1 -1
  242. package/dist/model/datasource.js +3 -1
  243. package/dist/model/datasource.js.map +1 -1
  244. package/dist/model/index.d.ts +1 -0
  245. package/dist/model/index.d.ts.map +1 -1
  246. package/dist/model/index.js +1 -0
  247. package/dist/model/index.js.map +1 -1
  248. package/dist/model/legend.d.ts +3 -3
  249. package/dist/model/legend.d.ts.map +1 -1
  250. package/dist/model/legend.js +14 -14
  251. package/dist/model/legend.js.map +1 -1
  252. package/dist/model/panels.d.ts +3 -2
  253. package/dist/model/panels.d.ts.map +1 -1
  254. package/dist/model/panels.js.map +1 -1
  255. package/dist/model/plugin-base.js.map +1 -1
  256. package/dist/model/plugin-loading.js.map +1 -1
  257. package/dist/model/plugins.d.ts +6 -4
  258. package/dist/model/plugins.d.ts.map +1 -1
  259. package/dist/model/plugins.js.map +1 -1
  260. package/dist/model/time-series-queries.d.ts +2 -2
  261. package/dist/model/time-series-queries.d.ts.map +1 -1
  262. package/dist/model/time-series-queries.js.map +1 -1
  263. package/dist/model/trace-queries.d.ts +19 -0
  264. package/dist/model/trace-queries.d.ts.map +1 -0
  265. package/dist/model/trace-queries.js +15 -0
  266. package/dist/model/trace-queries.js.map +1 -0
  267. package/dist/model/variables.d.ts +2 -2
  268. package/dist/model/variables.d.ts.map +1 -1
  269. package/dist/model/variables.js +3 -1
  270. package/dist/model/variables.js.map +1 -1
  271. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +6 -6
  272. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  273. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +52 -28
  274. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  275. package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
  276. package/dist/runtime/DataQueriesProvider/model.d.ts +18 -13
  277. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  278. package/dist/runtime/DataQueriesProvider/model.js +67 -1
  279. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  280. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +9 -4
  281. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  282. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +37 -20
  283. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  284. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +9 -0
  285. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -0
  286. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +30 -0
  287. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -0
  288. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  289. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  290. package/dist/runtime/TimeRangeProvider/index.js +1 -0
  291. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  292. package/dist/runtime/TimeRangeProvider/query-params.d.ts +5 -5
  293. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  294. package/dist/runtime/TimeRangeProvider/query-params.js +13 -45
  295. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  296. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +7 -0
  297. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -0
  298. package/dist/runtime/TimeRangeProvider/refresh-interval.js +25 -0
  299. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -0
  300. package/dist/runtime/builtin-variables.d.ts +11 -0
  301. package/dist/runtime/builtin-variables.d.ts.map +1 -0
  302. package/dist/runtime/builtin-variables.js +59 -0
  303. package/dist/runtime/builtin-variables.js.map +1 -0
  304. package/dist/runtime/datasources.d.ts +42 -7
  305. package/dist/runtime/datasources.d.ts.map +1 -1
  306. package/dist/runtime/datasources.js +15 -7
  307. package/dist/runtime/datasources.js.map +1 -1
  308. package/dist/runtime/index.d.ts +2 -0
  309. package/dist/runtime/index.d.ts.map +1 -1
  310. package/dist/runtime/index.js +2 -0
  311. package/dist/runtime/index.js.map +1 -1
  312. package/dist/runtime/plugin-registry.d.ts +5 -3
  313. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  314. package/dist/runtime/plugin-registry.js +22 -5
  315. package/dist/runtime/plugin-registry.js.map +1 -1
  316. package/dist/runtime/template-variables.d.ts +6 -5
  317. package/dist/runtime/template-variables.d.ts.map +1 -1
  318. package/dist/runtime/template-variables.js +36 -9
  319. package/dist/runtime/template-variables.js.map +1 -1
  320. package/dist/runtime/time-series-queries.d.ts +3 -3
  321. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  322. package/dist/runtime/time-series-queries.js +21 -19
  323. package/dist/runtime/time-series-queries.js.map +1 -1
  324. package/dist/runtime/trace-queries.d.ts +14 -0
  325. package/dist/runtime/trace-queries.d.ts.map +1 -0
  326. package/dist/runtime/trace-queries.js +61 -0
  327. package/dist/runtime/trace-queries.js.map +1 -0
  328. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -3
  329. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  330. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  331. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +1 -2
  332. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  333. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -1
  334. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  335. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +12 -0
  336. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -0
  337. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +39 -0
  338. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -0
  339. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -3
  340. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  341. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +24 -8
  342. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  343. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +2 -3
  344. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -1
  345. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
  346. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +4 -5
  347. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  348. package/dist/stories/shared-utils/decorators/WithTimeRange.js +2 -2
  349. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  350. package/dist/stories/shared-utils/decorators/index.d.ts +1 -0
  351. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  352. package/dist/stories/shared-utils/decorators/index.js +1 -0
  353. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  354. package/dist/stories/shared-utils/index.js.map +1 -1
  355. package/dist/test/index.d.ts +1 -0
  356. package/dist/test/index.d.ts.map +1 -1
  357. package/dist/test/index.js +1 -0
  358. package/dist/test/index.js.map +1 -1
  359. package/dist/test/mock-data.d.ts +4 -0
  360. package/dist/test/mock-data.d.ts.map +1 -0
  361. package/dist/test/mock-data.js +64 -0
  362. package/dist/test/mock-data.js.map +1 -0
  363. package/dist/test/render.d.ts +1 -1
  364. package/dist/test/render.d.ts.map +1 -1
  365. package/dist/test/render.js +2 -2
  366. package/dist/test/render.js.map +1 -1
  367. package/dist/test/setup-tests.js.map +1 -1
  368. package/dist/test/test-plugins/bert/index.js +2 -2
  369. package/dist/test/test-plugins/bert/index.js.map +1 -1
  370. package/dist/test/test-plugins/ernie/index.js +2 -2
  371. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  372. package/dist/test/test-plugins/index.js.map +1 -1
  373. package/dist/test-utils/index.js.map +1 -1
  374. package/dist/test-utils/mock-plugin-registry.d.ts +1 -1
  375. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  376. package/dist/test-utils/mock-plugin-registry.js +3 -3
  377. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  378. package/dist/utils/action.d.ts +4 -0
  379. package/dist/utils/action.d.ts.map +1 -0
  380. package/dist/utils/action.js +27 -0
  381. package/dist/utils/action.js.map +1 -0
  382. package/dist/utils/index.d.ts +1 -0
  383. package/dist/utils/index.d.ts.map +1 -1
  384. package/dist/utils/index.js +1 -0
  385. package/dist/utils/index.js.map +1 -1
  386. package/dist/utils/variables.d.ts.map +1 -1
  387. package/dist/utils/variables.js +17 -5
  388. package/dist/utils/variables.js.map +1 -1
  389. package/dist/validation/datasource.d.ts +19 -0
  390. package/dist/validation/datasource.d.ts.map +1 -0
  391. package/dist/validation/datasource.js +22 -0
  392. package/dist/validation/datasource.js.map +1 -0
  393. package/dist/validation/duration.d.ts +3 -0
  394. package/dist/validation/duration.d.ts.map +1 -0
  395. package/dist/validation/duration.js +17 -0
  396. package/dist/validation/duration.js.map +1 -0
  397. package/dist/validation/index.d.ts +6 -0
  398. package/dist/validation/index.d.ts.map +1 -0
  399. package/dist/validation/index.js +19 -0
  400. package/dist/validation/index.js.map +1 -0
  401. package/dist/validation/resource.d.ts +3 -0
  402. package/dist/validation/resource.d.ts.map +1 -0
  403. package/dist/validation/resource.js +16 -0
  404. package/dist/validation/resource.js.map +1 -0
  405. package/dist/validation/role.d.ts +228 -0
  406. package/dist/validation/role.d.ts.map +1 -0
  407. package/dist/validation/role.js +67 -0
  408. package/dist/validation/role.js.map +1 -0
  409. package/dist/validation/rolebinding.d.ts +137 -0
  410. package/dist/validation/rolebinding.d.ts.map +1 -0
  411. package/dist/validation/rolebinding.js +47 -0
  412. package/dist/validation/rolebinding.js.map +1 -0
  413. package/dist/validation/secret.d.ts +964 -0
  414. package/dist/validation/secret.d.ts.map +1 -0
  415. package/dist/validation/secret.js +157 -0
  416. package/dist/validation/secret.js.map +1 -0
  417. package/dist/validation/user.d.ts +93 -0
  418. package/dist/validation/user.d.ts.map +1 -0
  419. package/dist/validation/user.js +38 -0
  420. package/dist/validation/user.js.map +1 -0
  421. package/dist/validation/variable.d.ts +96 -0
  422. package/dist/validation/variable.d.ts.map +1 -0
  423. package/dist/validation/variable.js +40 -0
  424. package/dist/validation/variable.js.map +1 -0
  425. package/package.json +9 -6
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { useQuery, useQueries, useQueryClient } from '@tanstack/react-query';
14
- import { useTemplateVariableValues } from './template-variables';
14
+ import { useVariableValues } from './template-variables';
15
15
  import { useTimeRange } from './TimeRangeProvider';
16
16
  import { useDatasourceStore } from './datasources';
17
17
  import { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';
@@ -27,8 +27,8 @@ function filterVariableStateMap(v, names) {
27
27
  }
28
28
  return Object.fromEntries(Object.entries(v).filter(([name])=>names.includes(name)));
29
29
  }
30
- function getQueryOptions({ plugin , definition , context }) {
31
- const { timeRange , datasourceStore , suggestedStepMs , variableState , refreshKey } = context;
30
+ function getQueryOptions({ plugin, definition, context }) {
31
+ const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;
32
32
  const dependencies = (plugin === null || plugin === void 0 ? void 0 : plugin.dependsOn) ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
33
33
  const variableDependencies = dependencies === null || dependencies === void 0 ? void 0 : dependencies.variables;
34
34
  // Determine queryKey
@@ -46,8 +46,8 @@ function getQueryOptions({ plugin , definition , context }) {
46
46
  let waitToLoad = false;
47
47
  if (variableDependencies) {
48
48
  waitToLoad = variableDependencies.some((v)=>{
49
- var ref;
50
- return (ref = variableState[v]) === null || ref === void 0 ? void 0 : ref.loading;
49
+ var _variableState_v;
50
+ return (_variableState_v = variableState[v]) === null || _variableState_v === void 0 ? void 0 : _variableState_v.loading;
51
51
  });
52
52
  }
53
53
  const queryEnabled = plugin !== undefined && !waitToLoad;
@@ -58,16 +58,17 @@ function getQueryOptions({ plugin , definition , context }) {
58
58
  }
59
59
  /**
60
60
  * Runs a time series query using a plugin and returns the results.
61
- */ export const useTimeSeriesQuery = (definition, options)=>{
62
- const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
61
+ */ export const useTimeSeriesQuery = (definition, options, queryOptions)=>{
62
+ const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
63
63
  const context = useTimeSeriesQueryContext();
64
- const { queryEnabled , queryKey } = getQueryOptions({
64
+ const { queryEnabled, queryKey } = getQueryOptions({
65
65
  plugin,
66
66
  definition,
67
67
  context
68
68
  });
69
+ var _queryOptions_enabled;
69
70
  return useQuery({
70
- enabled: queryEnabled,
71
+ enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) || queryEnabled,
71
72
  queryKey: queryKey,
72
73
  refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : false,
73
74
  queryFn: ()=>{
@@ -86,23 +87,24 @@ function getQueryOptions({ plugin , definition , context }) {
86
87
  };
87
88
  /**
88
89
  * Runs multiple time series queries using plugins and returns the results.
89
- */ export function useTimeSeriesQueries(definitions, options) {
90
- const { getPlugin } = usePluginRegistry();
90
+ */ export function useTimeSeriesQueries(definitions, options, queryOptions) {
91
+ const { getPlugin } = usePluginRegistry();
91
92
  const context = useTimeSeriesQueryContext();
92
93
  const pluginLoaderResponse = usePlugins(TIME_SERIES_QUERY_KEY, definitions.map((d)=>({
93
94
  kind: d.spec.plugin.kind
94
95
  })));
95
96
  return useQueries({
96
97
  queries: definitions.map((definition, idx)=>{
97
- var ref;
98
- const plugin = (ref = pluginLoaderResponse[idx]) === null || ref === void 0 ? void 0 : ref.data;
99
- const { queryEnabled , queryKey } = getQueryOptions({
98
+ var _pluginLoaderResponse_idx;
99
+ const plugin = (_pluginLoaderResponse_idx = pluginLoaderResponse[idx]) === null || _pluginLoaderResponse_idx === void 0 ? void 0 : _pluginLoaderResponse_idx.data;
100
+ const { queryEnabled, queryKey } = getQueryOptions({
100
101
  plugin,
101
102
  definition,
102
103
  context
103
104
  });
105
+ var _queryOptions_enabled;
104
106
  return {
105
- enabled: queryEnabled,
107
+ enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) && queryEnabled,
106
108
  queryKey: queryKey,
107
109
  refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : undefined,
108
110
  queryFn: async ()=>{
@@ -122,8 +124,8 @@ function getQueryOptions({ plugin , definition , context }) {
122
124
  /**
123
125
  * Build the time series query context object from data available at runtime
124
126
  */ function useTimeSeriesQueryContext() {
125
- const { absoluteTimeRange , refreshKey , refreshIntervalInMs } = useTimeRange();
126
- const variableState = useTemplateVariableValues();
127
+ const { absoluteTimeRange, refreshKey, refreshIntervalInMs } = useTimeRange();
128
+ const variableState = useVariableValues();
127
129
  const datasourceStore = useDatasourceStore();
128
130
  return {
129
131
  timeRange: absoluteTimeRange,
@@ -147,8 +149,8 @@ function getQueryOptions({ plugin , definition , context }) {
147
149
  for (const query of cache.findAll({
148
150
  type: 'active'
149
151
  })){
150
- var ref;
151
- const firstPart = (ref = query.queryKey) === null || ref === void 0 ? void 0 : ref[0];
152
+ var _query_queryKey;
153
+ const firstPart = (_query_queryKey = query.queryKey) === null || _query_queryKey === void 0 ? void 0 : _query_queryKey[0];
152
154
  if ((firstPart === null || firstPart === void 0 ? void 0 : firstPart.kind) && firstPart.kind.startsWith(TIME_SERIES_QUERY_KEY)) {
153
155
  queries.push(query);
154
156
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useQuery, useQueries, useQueryClient, Query, QueryCache, QueryKey } from '@tanstack/react-query';\nimport { TimeSeriesQueryDefinition, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryPlugin } from '../model';\nimport { VariableStateMap, useTemplateVariableValues } from './template-variables';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction filterVariableStateMap(v: VariableStateMap, names?: string[]) {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}) {\n const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n // Determine queryKey\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = [definition, timeRange, datasourceStore, suggestedStepMs, variablesValueKey, refreshKey] as const;\n\n // Determine queryEnabled\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n\n return {\n queryKey,\n queryEnabled,\n };\n}\n\n/**\n * Runs a time series query using a plugin and returns the results.\n */\nexport const useTimeSeriesQuery = (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions) => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: queryEnabled,\n queryKey: queryKey,\n refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : false,\n queryFn: () => {\n // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking\n if (plugin === undefined) {\n throw new Error('Expected plugin to be loaded');\n }\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n },\n });\n};\n\n/**\n * Runs multiple time series queries using plugins and returns the results.\n */\nexport function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions) {\n const { getPlugin } = usePluginRegistry();\n const context = useTimeSeriesQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return {\n enabled: queryEnabled,\n queryKey: queryKey,\n refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : undefined,\n queryFn: async () => {\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n return data;\n },\n };\n }),\n });\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange, refreshKey, refreshIntervalInMs } = useTimeRange();\n const variableState = useTemplateVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n refreshKey,\n refreshIntervalInMs: refreshIntervalInMs,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries() {\n const queryClient = useQueryClient();\n const queryCache = queryClient.getQueryCache();\n return getActiveTimeSeriesQueries(queryCache);\n}\n\n/**\n * Filter all cached queries down to only active time series queries\n */\nexport function getActiveTimeSeriesQueries(cache: QueryCache) {\n const queries: TimeSeriesDataQuery[] = [];\n\n for (const query of cache.findAll({ type: 'active' })) {\n const firstPart = query.queryKey?.[0] as UnknownSpec;\n if (firstPart?.kind && (firstPart.kind as string).startsWith(TIME_SERIES_QUERY_KEY)) {\n queries.push(query as Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>);\n }\n }\n\n return queries;\n}\n"],"names":["useQuery","useQueries","useQueryClient","useTemplateVariableValues","useTimeRange","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","TIME_SERIES_QUERY_KEY","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","filterVariableStateMap","names","fromEntries","entries","filter","name","includes","getQueryOptions","plugin","definition","context","timeRange","datasourceStore","suggestedStepMs","variableState","refreshKey","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","loading","queryEnabled","undefined","useTimeSeriesQuery","options","data","kind","useTimeSeriesQueryContext","enabled","refetchInterval","refreshIntervalInMs","queryFn","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","d","queries","idx","absoluteTimeRange","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","getActiveTimeSeriesQueries","cache","query","findAll","type","firstPart","startsWith","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,EAAEC,UAAU,EAAEC,cAAc,QAAqC,uBAAuB,CAAC;AAG1G,SAA2BC,yBAAyB,QAAQ,sBAAsB,CAAC;AACnF,SAASC,YAAY,QAAQ,qBAAqB,CAAC;AACnD,SAASC,kBAAkB,QAAQ,eAAe,CAAC;AACnD,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,mBAAmB,CAAC;AAM7E,OAAO,MAAMC,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD;;CAEC,GACD,SAASC,oBAAoB,CAACC,CAAmB,EAAE;IACjD,OAAOC,MAAM,CAACC,MAAM,CAACF,CAAC,CAAC,CACpBG,GAAG,CAAC,CAACH,CAAC,GAAKI,IAAI,CAACC,SAAS,CAACL,CAAC,CAACM,KAAK,CAAC,CAAC,CACnCC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAASC,sBAAsB,CAACR,CAAmB,EAAES,KAAgB,EAAE;IACrE,IAAI,CAACA,KAAK,EAAE;QACV,OAAO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AAQ;KAAE,CAAC,CAAE;YACnCF,GAAc;QAAhC,MAAMG,SAAS,GAAGH,CAAAA,GAAc,GAAdA,KAAK,CAAChC,QAAQ,cAAdgC,GAAc,WAAK,GAAnBA,KAAAA,CAAmB,GAAnBA,GAAc,AAAE,CAAC,CAAC,CAAC,AAAe,AAAC;QACrD,IAAIG,CAAAA,SAAS,aAATA,SAAS,WAAM,GAAfA,KAAAA,CAAe,GAAfA,SAAS,CAAE1B,IAAI,CAAA,IAAI,AAAC0B,SAAS,CAAC1B,IAAI,CAAY2B,UAAU,CAACrE,qBAAqB,CAAC,EAAE;YACnFwD,OAAO,CAACc,IAAI,CAACL,KAAK,CAA6D,CAAC;QAClF,CAAC;IACH,CAAC;IAED,OAAOT,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n useQuery,\n useQueries,\n useQueryClient,\n Query,\n QueryCache,\n QueryKey,\n QueryObserverOptions,\n} from '@tanstack/react-query';\nimport { TimeSeriesQueryDefinition, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryPlugin } from '../model';\nimport { VariableStateMap, useVariableValues } from './template-variables';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction filterVariableStateMap(v: VariableStateMap, names?: string[]) {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}) {\n const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n // Determine queryKey\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = [definition, timeRange, datasourceStore, suggestedStepMs, variablesValueKey, refreshKey] as const;\n\n // Determine queryEnabled\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n\n return {\n queryKey,\n queryEnabled,\n };\n}\n\n/**\n * Runs a time series query using a plugin and returns the results.\n */\nexport const useTimeSeriesQuery = (\n definition: TimeSeriesQueryDefinition,\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions\n) => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: (queryOptions?.enabled ?? true) || queryEnabled,\n queryKey: queryKey,\n refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : false,\n queryFn: () => {\n // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking\n if (plugin === undefined) {\n throw new Error('Expected plugin to be loaded');\n }\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n },\n });\n};\n\n/**\n * Runs multiple time series queries using plugins and returns the results.\n */\nexport function useTimeSeriesQueries(\n definitions: TimeSeriesQueryDefinition[],\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions\n) {\n const { getPlugin } = usePluginRegistry();\n const context = useTimeSeriesQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return {\n enabled: (queryOptions?.enabled ?? true) && queryEnabled,\n queryKey: queryKey,\n refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : undefined,\n queryFn: async () => {\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n return data;\n },\n };\n }),\n });\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange, refreshKey, refreshIntervalInMs } = useTimeRange();\n const variableState = useVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n refreshKey,\n refreshIntervalInMs: refreshIntervalInMs,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries() {\n const queryClient = useQueryClient();\n const queryCache = queryClient.getQueryCache();\n return getActiveTimeSeriesQueries(queryCache);\n}\n\n/**\n * Filter all cached queries down to only active time series queries\n */\nexport function getActiveTimeSeriesQueries(cache: QueryCache) {\n const queries: TimeSeriesDataQuery[] = [];\n\n for (const query of cache.findAll({ type: 'active' })) {\n const firstPart = query.queryKey?.[0] as UnknownSpec;\n if (firstPart?.kind && (firstPart.kind as string).startsWith(TIME_SERIES_QUERY_KEY)) {\n queries.push(query as Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>);\n }\n }\n\n return queries;\n}\n"],"names":["useQuery","useQueries","useQueryClient","useVariableValues","useTimeRange","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","TIME_SERIES_QUERY_KEY","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","filterVariableStateMap","names","fromEntries","entries","filter","name","includes","getQueryOptions","plugin","definition","context","timeRange","datasourceStore","suggestedStepMs","variableState","refreshKey","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","loading","queryEnabled","undefined","useTimeSeriesQuery","options","queryOptions","data","kind","useTimeSeriesQueryContext","enabled","refetchInterval","refreshIntervalInMs","queryFn","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","d","queries","idx","absoluteTimeRange","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","getActiveTimeSeriesQueries","cache","query","findAll","type","firstPart","startsWith","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SACEA,QAAQ,EACRC,UAAU,EACVC,cAAc,QAKT,wBAAwB;AAG/B,SAA2BC,iBAAiB,QAAQ,uBAAuB;AAC3E,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,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G,aAAYH,kBAAAA,MAAMjC,QAAQ,cAAdiC,sCAAAA,eAAgB,CAAC,EAAE;QACrC,IAAIG,CAAAA,sBAAAA,gCAAAA,UAAW1B,IAAI,KAAI,AAAC0B,UAAU1B,IAAI,CAAY2B,UAAU,CAACtE,wBAAwB;YACnFyD,QAAQc,IAAI,CAACL;QACf;IACF;IAEA,OAAOT;AACT"}
@@ -0,0 +1,14 @@
1
+ import { QueryDefinition, UnknownSpec, AbsoluteTimeRange } from '@perses-dev/core';
2
+ export type TraceQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TraceQuery', PluginSpec>;
3
+ export declare const TRACE_QUERY_KEY = "TraceQuery";
4
+ export declare function getUnixTimeRange(timeRange: AbsoluteTimeRange): {
5
+ start: number;
6
+ end: number;
7
+ };
8
+ /**
9
+ * Run a trace query using a TraceQuery plugin and return the results
10
+ * @param definition: dashboard defintion for a trace query, written in Trace Query Language (TraceQL)
11
+ * Documentation for TraceQL: https://grafana.com/docs/tempo/latest/traceql/
12
+ */
13
+ export declare function useTraceQueries(definitions: TraceQueryDefinition[]): import("@tanstack/react-query").UseQueryResult<import("@perses-dev/core").TraceData, unknown>[];
14
+ //# sourceMappingURL=trace-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/trace-queries.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKnF,MAAM,MAAM,oBAAoB,CAAC,UAAU,GAAG,WAAW,IAAI,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACvG,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB;;;EAM5D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,oBAAoB,EAAE,mGA0BlE"}
@@ -0,0 +1,61 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { getUnixTime } from 'date-fns';
14
+ import { useQueries } from '@tanstack/react-query';
15
+ import { useDatasourceStore } from './datasources';
16
+ import { usePluginRegistry } from './plugin-registry';
17
+ import { useTimeRange } from './TimeRangeProvider';
18
+ export const TRACE_QUERY_KEY = 'TraceQuery';
19
+ export function getUnixTimeRange(timeRange) {
20
+ const { start, end } = timeRange;
21
+ return {
22
+ start: Math.ceil(getUnixTime(start)),
23
+ end: Math.ceil(getUnixTime(end))
24
+ };
25
+ }
26
+ /**
27
+ * Run a trace query using a TraceQuery plugin and return the results
28
+ * @param definition: dashboard defintion for a trace query, written in Trace Query Language (TraceQL)
29
+ * Documentation for TraceQL: https://grafana.com/docs/tempo/latest/traceql/
30
+ */ export function useTraceQueries(definitions) {
31
+ const { getPlugin } = usePluginRegistry();
32
+ const datasourceStore = useDatasourceStore();
33
+ const { absoluteTimeRange } = useTimeRange();
34
+ const context = {
35
+ datasourceStore,
36
+ absoluteTimeRange
37
+ };
38
+ // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)
39
+ // https://tanstack.com/query/v4/docs/react/reference/useQuery
40
+ return useQueries({
41
+ queries: definitions.map((definition)=>{
42
+ var _definition_spec_plugin, _definition_spec;
43
+ const queryKey = [
44
+ definition,
45
+ datasourceStore,
46
+ absoluteTimeRange
47
+ ]; // `queryKey` watches and reruns `queryFn` if keys in the array change
48
+ const traceQueryKind = definition === null || definition === void 0 ? void 0 : (_definition_spec = definition.spec) === null || _definition_spec === void 0 ? void 0 : (_definition_spec_plugin = _definition_spec.plugin) === null || _definition_spec_plugin === void 0 ? void 0 : _definition_spec_plugin.kind;
49
+ return {
50
+ queryKey: queryKey,
51
+ queryFn: async ()=>{
52
+ const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);
53
+ const data = await plugin.getTraceData(definition.spec.plugin.spec, context);
54
+ return data;
55
+ }
56
+ };
57
+ })
58
+ });
59
+ }
60
+
61
+ //# sourceMappingURL=trace-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/trace-queries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getUnixTime } from 'date-fns';\nimport { QueryDefinition, UnknownSpec, AbsoluteTimeRange } from '@perses-dev/core';\nimport { useQueries } from '@tanstack/react-query';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nexport type TraceQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TraceQuery', PluginSpec>;\nexport const TRACE_QUERY_KEY = 'TraceQuery';\n\nexport function getUnixTimeRange(timeRange: AbsoluteTimeRange) {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\n/**\n * Run a trace query using a TraceQuery plugin and return the results\n * @param definition: dashboard defintion for a trace query, written in Trace Query Language (TraceQL)\n * Documentation for TraceQL: https://grafana.com/docs/tempo/latest/traceql/\n */\nexport function useTraceQueries(definitions: TraceQueryDefinition[]) {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n\n const context = {\n datasourceStore,\n absoluteTimeRange,\n };\n\n // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)\n // https://tanstack.com/query/v4/docs/react/reference/useQuery\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = [definition, datasourceStore, absoluteTimeRange] as const; // `queryKey` watches and reruns `queryFn` if keys in the array change\n const traceQueryKind = definition?.spec?.plugin?.kind;\n return {\n queryKey: queryKey,\n queryFn: async () => {\n const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);\n const data = await plugin.getTraceData(definition.spec.plugin.spec, context);\n return data;\n },\n };\n }),\n });\n}\n"],"names":["getUnixTime","useQueries","useDatasourceStore","usePluginRegistry","useTimeRange","TRACE_QUERY_KEY","getUnixTimeRange","timeRange","start","end","Math","ceil","useTraceQueries","definitions","getPlugin","datasourceStore","absoluteTimeRange","context","queries","map","definition","queryKey","traceQueryKind","spec","plugin","kind","queryFn","data","getTraceData"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,WAAW;AAEvC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,sBAAsB;AAEnD,OAAO,MAAMC,kBAAkB,aAAa;AAE5C,OAAO,SAASC,iBAAiBC,SAA4B;IAC3D,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACX,YAAYQ;QAC7BC,KAAKC,KAAKC,IAAI,CAACX,YAAYS;IAC7B;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASG,gBAAgBC,WAAmC;IACjE,MAAM,EAAEC,SAAS,EAAE,GAAGX;IACtB,MAAMY,kBAAkBb;IACxB,MAAM,EAAEc,iBAAiB,EAAE,GAAGZ;IAE9B,MAAMa,UAAU;QACdF;QACAC;IACF;IAEA,+FAA+F;IAC/F,8DAA8D;IAC9D,OAAOf,WAAW;QAChBiB,SAASL,YAAYM,GAAG,CAAC,CAACC;gBAEDA,yBAAAA;YADvB,MAAMC,WAAW;gBAACD;gBAAYL;gBAAiBC;aAAkB,EAAW,sEAAsE;YAClJ,MAAMM,iBAAiBF,uBAAAA,kCAAAA,mBAAAA,WAAYG,IAAI,cAAhBH,wCAAAA,0BAAAA,iBAAkBI,MAAM,cAAxBJ,8CAAAA,wBAA0BK,IAAI;YACrD,OAAO;gBACLJ,UAAUA;gBACVK,SAAS;oBACP,MAAMF,SAAS,MAAMV,UAAUT,iBAAiBiB;oBAChD,MAAMK,OAAO,MAAMH,OAAOI,YAAY,CAACR,WAAWG,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN;oBACpE,OAAOU;gBACT;YACF;QACF;IACF;AACF"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { DataQueriesProviderProps } from '@perses-dev/plugin-system';
3
2
  import { StoryFn, StoryContext } from '@storybook/react';
4
3
  declare module '@storybook/react' {
@@ -6,8 +5,8 @@ declare module '@storybook/react' {
6
5
  withDataQueries?: WithDataQueriesProvideParameter;
7
6
  }
8
7
  }
9
- export declare type WithDataQueriesProvideParameter = {
8
+ export type WithDataQueriesProvideParameter = {
10
9
  props: DataQueriesProviderProps;
11
10
  };
12
- export declare const WithDataQueries: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
11
+ export declare const WithDataQueries: (Story: StoryFn, context: StoryContext<unknown>) => import("react/jsx-runtime").JSX.Element;
13
12
  //# sourceMappingURL=WithDataQueries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WithDataQueries.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAuB,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,eAAe,CAAC,EAAE,+BAA+B,CAAC;KACnD;CACF;AAED,oBAAY,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAY7E,CAAC"}
1
+ {"version":3,"file":"WithDataQueries.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAuB,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,eAAe,CAAC,EAAE,+BAA+B,CAAC;KACnD;CACF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,4CAY7E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDataQueries?: WithDataQueriesProvideParameter;\n }\n}\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","withDataQueries","props","definitions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,mBAAmB,QAAkC,2BAA2B,CAAC;AAa1F,yDAAyD;AACzD,SAASC,0BAA0B,CACjCC,SAAoD,EACN;IAC9C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,eAAe,AAAC;IACzD,MAAMN,SAAS,GAAGD,0BAA0B,CAACK,aAAa,CAAC,GACvDA,aAAa,GACb;QAAEG,KAAK,EAAE;YAAEC,WAAW,EAAE,EAAE;SAAoC;KAAE,AAAC;IACrE,MAAMD,KAAK,GAAGP,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEO,KAAK,AAAC;IAE/B,qBACE,KAACT,mBAAmB;QAAE,GAAGS,KAAK;kBAC5B,cAAA,KAACL,KAAK,KAAG;MACW,CACtB;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDataQueries?: WithDataQueriesProvideParameter;\n }\n}\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","withDataQueries","props","definitions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,mBAAmB,QAAkC,4BAA4B;AAa1F,yDAAyD;AACzD,SAASC,2BACPC,SAAoD;IAEpD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,kBAAkB,CAACC,OAAgBC;IAC9C,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,eAAe;IACxD,MAAMN,YAAYD,2BAA2BK,iBACzCA,gBACA;QAAEG,OAAO;YAAEC,aAAa,EAAE;QAAmC;IAAE;IACnE,MAAMD,QAAQP,sBAAAA,gCAAAA,UAAWO,KAAK;IAE9B,qBACE,KAACT;QAAqB,GAAGS,KAAK;kBAC5B,cAAA,KAACL;;AAGP,EAAE"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryFn } from '@storybook/react';
3
- export declare const WithPluginRegistry: (Story: StoryFn) => JSX.Element;
2
+ export declare const WithPluginRegistry: (Story: StoryFn) => import("react/jsx-runtime").JSX.Element;
4
3
  //# sourceMappingURL=WithPluginRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WithPluginRegistry.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA8B3C,eAAO,MAAM,kBAAkB,UAAW,OAAO,gBAShD,CAAC"}
1
+ {"version":3,"file":"WithPluginRegistry.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA8B3C,eAAO,MAAM,kBAAkB,UAAW,OAAO,4CAYhD,CAAC"}
@@ -36,7 +36,8 @@ export const WithPluginRegistry = (Story)=>{
36
36
  return /*#__PURE__*/ _jsx(PluginRegistry, {
37
37
  pluginLoader: bundledPluginLoader,
38
38
  defaultPluginKinds: {
39
- TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
39
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery',
40
+ TraceQuery: 'TempoTraceQuery'
40
41
  },
41
42
  children: /*#__PURE__*/ _jsx(Story, {})
42
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn } from '@storybook/react';\nimport {\n PluginRegistry,\n PluginLoader,\n PluginModuleResource,\n dynamicImportPluginLoader,\n} from '@perses-dev/plugin-system';\n\nimport prometheusResource from '@perses-dev/prometheus-plugin/plugin.json';\nimport panelsResource from '@perses-dev/panels-plugin/plugin.json';\n\nconst bundledPluginLoader: PluginLoader = dynamicImportPluginLoader([\n {\n resource: prometheusResource as PluginModuleResource,\n // This throws an error in CI (but not locally for some reason), likely because\n // this package isn't a dependency for dashboards. We probably do not want to\n // make it one solely for type-checking in storybook.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/prometheus-plugin'),\n },\n {\n resource: panelsResource as PluginModuleResource,\n // Same comment as above.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/panels-plugin'),\n },\n]);\n\nexport const WithPluginRegistry = (Story: StoryFn) => {\n return (\n <PluginRegistry\n pluginLoader={bundledPluginLoader}\n defaultPluginKinds={{ TimeSeriesQuery: 'PrometheusTimeSeriesQuery' }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","dynamicImportPluginLoader","prometheusResource","panelsResource","bundledPluginLoader","resource","importPlugin","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SACEA,cAAc,EAGdC,yBAAyB,QACpB,2BAA2B,CAAC;AAEnC,OAAOC,kBAAkB,MAAM,2CAA2C,CAAC;AAC3E,OAAOC,cAAc,MAAM,uCAAuC,CAAC;AAEnE,MAAMC,mBAAmB,GAAiBH,yBAAyB,CAAC;IAClE;QACEI,QAAQ,EAAEH,kBAAkB;QAC5B,+EAA+E;QAC/E,6EAA6E;QAC7E,qDAAqD;QACrD,6DAA6D;QAC7D,aAAa;QACbI,YAAY,EAAE,IAAM,MAAM,CAAC,+BAA+B,CAAC;KAC5D;IACD;QACED,QAAQ,EAAEF,cAAc;QACxB,yBAAyB;QACzB,6DAA6D;QAC7D,aAAa;QACbG,YAAY,EAAE,IAAM,MAAM,CAAC,2BAA2B,CAAC;KACxD;CACF,CAAC,AAAC;AAEH,OAAO,MAAMC,kBAAkB,GAAG,CAACC,KAAc,GAAK;IACpD,qBACE,KAACR,cAAc;QACbS,YAAY,EAAEL,mBAAmB;QACjCM,kBAAkB,EAAE;YAAEC,eAAe,EAAE,2BAA2B;SAAE;kBAEpE,cAAA,KAACH,KAAK,KAAG;MACM,CACjB;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn } from '@storybook/react';\nimport {\n PluginRegistry,\n PluginLoader,\n PluginModuleResource,\n dynamicImportPluginLoader,\n} from '@perses-dev/plugin-system';\n\nimport prometheusResource from '@perses-dev/prometheus-plugin/plugin.json';\nimport panelsResource from '@perses-dev/panels-plugin/plugin.json';\n\nconst bundledPluginLoader: PluginLoader = dynamicImportPluginLoader([\n {\n resource: prometheusResource as PluginModuleResource,\n // This throws an error in CI (but not locally for some reason), likely because\n // this package isn't a dependency for dashboards. We probably do not want to\n // make it one solely for type-checking in storybook.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/prometheus-plugin'),\n },\n {\n resource: panelsResource as PluginModuleResource,\n // Same comment as above.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/panels-plugin'),\n },\n]);\n\nexport const WithPluginRegistry = (Story: StoryFn) => {\n return (\n <PluginRegistry\n pluginLoader={bundledPluginLoader}\n defaultPluginKinds={{\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n TraceQuery: 'TempoTraceQuery',\n }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","dynamicImportPluginLoader","prometheusResource","panelsResource","bundledPluginLoader","resource","importPlugin","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery","TraceQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SACEA,cAAc,EAGdC,yBAAyB,QACpB,4BAA4B;AAEnC,OAAOC,wBAAwB,4CAA4C;AAC3E,OAAOC,oBAAoB,wCAAwC;AAEnE,MAAMC,sBAAoCH,0BAA0B;IAClE;QACEI,UAAUH;QACV,+EAA+E;QAC/E,6EAA6E;QAC7E,qDAAqD;QACrD,6DAA6D;QAC7D,aAAa;QACbI,cAAc,IAAM,MAAM,CAAC;IAC7B;IACA;QACED,UAAUF;QACV,yBAAyB;QACzB,6DAA6D;QAC7D,aAAa;QACbG,cAAc,IAAM,MAAM,CAAC;IAC7B;CACD;AAED,OAAO,MAAMC,qBAAqB,CAACC;IACjC,qBACE,KAACR;QACCS,cAAcL;QACdM,oBAAoB;YAClBC,iBAAiB;YACjBC,YAAY;QACd;kBAEA,cAAA,KAACJ;;AAGP,EAAE"}
@@ -0,0 +1,12 @@
1
+ import { StoryFn, StoryContext } from '@storybook/react';
2
+ import { BuiltinVariableSrv } from '../../../runtime';
3
+ declare module '@storybook/react' {
4
+ interface Parameters {
5
+ withPluginSystemBuiltinVariables?: WithPluginSystemBuiltinVariableParameter;
6
+ }
7
+ }
8
+ export type WithPluginSystemBuiltinVariableParameter = {
9
+ props: BuiltinVariableSrv;
10
+ };
11
+ export declare const WithPluginSystemBuiltinVariables: (Story: StoryFn, context: StoryContext<unknown>) => import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=WithPluginSystemBuiltinVariables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithPluginSystemBuiltinVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,gCAAgC,CAAC,EAAE,wCAAwC,CAAC;KAC7E;CACF;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAcF,eAAO,MAAM,gCAAgC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,4CAc9F,CAAC"}
@@ -0,0 +1,39 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { BuiltinVariableContext } from '../../../runtime';
15
+ // Type guard because storybook types parameters as `any`
16
+ function isWithBuiltinVariableParameter(parameter) {
17
+ return !!parameter && Array.isArray(parameter);
18
+ }
19
+ // This decorator is used for non-dashboards package Builtin variable needs.
20
+ // Use the more specific decorator in the dashboards package when working with
21
+ // dashboards.
22
+ // This decorator includes "PluginSystem" in the name to differentiate it from
23
+ // the datasource store decorator in the `dashboards` package.
24
+ export const WithPluginSystemBuiltinVariables = (Story, context)=>{
25
+ const initParameter = context.parameters.withPluginSystemBuiltinVariables;
26
+ const defaultValue = {
27
+ variables: []
28
+ };
29
+ const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : {
30
+ props: defaultValue
31
+ };
32
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
33
+ return /*#__PURE__*/ _jsx(BuiltinVariableContext.Provider, {
34
+ value: props,
35
+ children: /*#__PURE__*/ _jsx(Story, {})
36
+ });
37
+ };
38
+
39
+ //# sourceMappingURL=WithPluginSystemBuiltinVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { BuiltinVariableContext, BuiltinVariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemBuiltinVariables?: WithPluginSystemBuiltinVariableParameter;\n }\n}\n\nexport type WithPluginSystemBuiltinVariableParameter = {\n props: BuiltinVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithBuiltinVariableParameter(\n parameter: unknown | WithPluginSystemBuiltinVariableParameter\n): parameter is WithPluginSystemBuiltinVariableParameter {\n return !!parameter && Array.isArray(parameter);\n}\n\n// This decorator is used for non-dashboards package Builtin variable needs.\n// Use the more specific decorator in the dashboards package when working with\n// dashboards.\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemBuiltinVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withPluginSystemBuiltinVariables;\n const defaultValue: BuiltinVariableSrv = {\n variables: [],\n };\n const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <BuiltinVariableContext.Provider value={props}>\n <Story />\n </BuiltinVariableContext.Provider>\n );\n};\n"],"names":["BuiltinVariableContext","isWithBuiltinVariableParameter","parameter","Array","isArray","WithPluginSystemBuiltinVariables","Story","context","initParameter","parameters","withPluginSystemBuiltinVariables","defaultValue","variables","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,sBAAsB,QAA4B,mBAAmB;AAY9E,yDAAyD;AACzD,SAASC,+BACPC,SAA6D;IAE7D,OAAO,CAAC,CAACA,aAAaC,MAAMC,OAAO,CAACF;AACtC;AAEA,4EAA4E;AAC5E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMG,mCAAmC,CAACC,OAAgBC;IAC/D,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,gCAAgC;IACzE,MAAMC,eAAmC;QACvCC,WAAW,EAAE;IACf;IACA,MAAMV,YAAYD,+BAA+BO,iBAAiBA,gBAAgB;QAAEK,OAAOF;IAAa;IAExG,MAAME,QAAQX,sBAAAA,gCAAAA,UAAWW,KAAK;IAE9B,qBACE,KAACb,uBAAuBc,QAAQ;QAACC,OAAOF;kBACtC,cAAA,KAACP;;AAGP,EAAE"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { DatasourceStore } from '@perses-dev/plugin-system';
3
2
  import { StoryFn, StoryContext } from '@storybook/react';
4
3
  declare module '@storybook/react' {
@@ -6,8 +5,8 @@ declare module '@storybook/react' {
6
5
  withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;
7
6
  }
8
7
  }
9
- export declare type WithPluginSystemDatasourceStoreParameter = {
8
+ export type WithPluginSystemDatasourceStoreParameter = {
10
9
  props: DatasourceStore;
11
10
  };
12
- export declare const WithPluginSystemDatasourceStore: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
11
+ export declare const WithPluginSystemDatasourceStore: (Story: StoryFn, context: StoryContext<unknown>) => import("react/jsx-runtime").JSX.Element;
13
12
  //# sourceMappingURL=WithPluginSystemDatasourceStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WithPluginSystemDatasourceStore.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"names":[],"mappings":";AAcA,OAAO,EAA0B,eAAe,EAAqB,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,+BAA+B,CAAC,EAAE,wCAAwC,CAAC;KAC5E;CACF;AAED,oBAAY,wCAAwC,GAAG;IACrD,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAaF,eAAO,MAAM,+BAA+B,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAuD7F,CAAC"}
1
+ {"version":3,"file":"WithPluginSystemDatasourceStore.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"names":[],"mappings":"AAcA,OAAO,EAEL,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,+BAA+B,CAAC,EAAE,wCAAwC,CAAC;KAC5E;CACF;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAaF,eAAO,MAAM,+BAA+B,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,4CAoE7F,CAAC"}
@@ -20,13 +20,13 @@ function isWithDatastoreStoreParameter(parameter) {
20
20
  // This decorator includes "PluginSystem" in the name to differentiate it from
21
21
  // the datasource store decorator in the `dashboards` package.
22
22
  export const WithPluginSystemDatasourceStore = (Story, context)=>{
23
- const { getPlugin } = usePluginRegistry();
23
+ const { getPlugin } = usePluginRegistry();
24
24
  const initParameter = context.parameters.withPluginSystemDatasourceStore;
25
25
  // This currently provides a very simplified default to enable use in some
26
26
  // basic stories. It likely will need expanding in the future.
27
27
  // In general, `plugin-system` would probably benefit from a provider wrapper
28
28
  // for `DatasourceStoreContext` that is more generic than the one available
29
- // in in the `dashboard` package for non-dashboard use cases.
29
+ // in the `dashboard` package for non-dashboard use cases.
30
30
  const defaultValue = {
31
31
  getDatasource: (selector)=>{
32
32
  if (selector.kind === 'PrometheusDatasource') {
@@ -44,7 +44,7 @@ export const WithPluginSystemDatasourceStore = (Story, context)=>{
44
44
  if (selector.kind === 'PrometheusDatasource') {
45
45
  const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
46
46
  const client = plugin.createClient({
47
- direct_url: prometheusDemoUrl
47
+ directUrl: prometheusDemoUrl
48
48
  }, {
49
49
  proxyUrl: prometheusDemoUrl
50
50
  });
@@ -52,18 +52,34 @@ export const WithPluginSystemDatasourceStore = (Story, context)=>{
52
52
  }
53
53
  throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
54
54
  },
55
- listDatasourceMetadata: async (datasourcePluginKind)=>{
55
+ listDatasourceSelectItems: async (datasourcePluginKind)=>{
56
56
  if (datasourcePluginKind === 'PrometheusDatasource') {
57
57
  return Promise.resolve([
58
58
  {
59
- name: 'PrometheusDatasource',
60
- selector: {
61
- kind: 'PrometheusDatasource'
62
- }
59
+ items: [
60
+ {
61
+ name: 'PrometheusDatasource',
62
+ selector: {
63
+ kind: 'PrometheusDatasource'
64
+ }
65
+ }
66
+ ]
63
67
  }
64
68
  ]);
65
69
  }
66
70
  throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);
71
+ },
72
+ getSavedDatasources: ()=>{
73
+ return {};
74
+ },
75
+ setSavedDatasources: (datasources)=>{
76
+ return datasources;
77
+ },
78
+ getLocalDatasources: ()=>{
79
+ return {};
80
+ },
81
+ setLocalDatasources: (datasources)=>{
82
+ return datasources;
67
83
  }
68
84
  };
69
85
  const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceStoreContext, DatasourceStore, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;\n }\n}\n\nexport type WithPluginSystemDatasourceStoreParameter = {\n props: DatasourceStore;\n};\n\nconst prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatastoreStoreParameter(\n parameter: unknown | WithPluginSystemDatasourceStoreParameter\n): parameter is WithPluginSystemDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const { getPlugin } = usePluginRegistry();\n\n const initParameter = context.parameters.withPluginSystemDatasourceStore;\n\n // This currently provides a very simplified default to enable use in some\n // basic stories. It likely will need expanding in the future.\n // In general, `plugin-system` would probably benefit from a provider wrapper\n // for `DatasourceStoreContext` that is more generic than the one available\n // in in the `dashboard` package for non-dashboard use cases.\n const defaultValue: DatasourceStore = {\n getDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve({\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: {},\n },\n });\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n getDatasourceClient: async <Client,>(selector: DatasourceSelector) => {\n if (selector.kind === 'PrometheusDatasource') {\n const plugin = await getPlugin('Datasource', 'PrometheusDatasource');\n const client = plugin.createClient(\n { direct_url: prometheusDemoUrl },\n { proxyUrl: prometheusDemoUrl }\n ) as Client;\n return client;\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n listDatasourceMetadata: async (datasourcePluginKind) => {\n if (datasourcePluginKind === 'PrometheusDatasource') {\n return Promise.resolve([\n {\n name: 'PrometheusDatasource',\n selector: { kind: 'PrometheusDatasource' },\n },\n ]);\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);\n },\n };\n\n const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : { props: defaultValue };\n const props = parameter?.props;\n\n return (\n <DatasourceStoreContext.Provider value={props}>\n <Story />\n </DatasourceStoreContext.Provider>\n );\n};\n"],"names":["DatasourceStoreContext","usePluginRegistry","prometheusDemoUrl","isWithDatastoreStoreParameter","parameter","WithPluginSystemDatasourceStore","Story","context","getPlugin","initParameter","parameters","withPluginSystemDatasourceStore","defaultValue","getDatasource","selector","kind","Promise","resolve","default","plugin","spec","Error","getDatasourceClient","client","createClient","direct_url","proxyUrl","listDatasourceMetadata","datasourcePluginKind","name","props","Provider","value"],"mappings":"A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AAsB,EAAE;gBAC5C,MAAMI,MAAM,GAAG,MAAMX,SAAS,CAAC,YAAY,EAAE,sBAAsB,CAAC,AAAC;gBACrE,MAAMe,MAAM,GAAGJ,MAAM,CAACK,YAAY,CAChC;oBAAEC,UAAU,EAAEvB,iBAAiB;iBAAE,EACjC;oBAAEwB,QAAQ,EAAExB,iBAAiB;iBAAE,CAChC,AAAU,AAAC;gBACZ,OAAOqB,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,IAAIF,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDY,sBAAsB,EAAE,OAAOC,oBAAoB,GAAK;YACtD,IAAIA,oBAAoB,KAAK,sBAAsB,EAAE;gBACnD,OAAOZ,OAAO,CAACC,OAAO,CAAC;oBACrB;wBACEY,IAAI,EAAE,sBAAsB;wBAC5Bf,QAAQ,EAAE;4BAAEC,IAAI,EAAE,sBAAsB;yBAAE;qBAC3C;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIM,KAAK,CAAC,CAAC,uDAAuD,EAAEO,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACpG,CAAC;KACF,AAAC;IAEF,MAAMxB,SAAS,GAAGD,6BAA6B,CAACM,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEqB,KAAK,EAAElB,YAAY;KAAE,AAAC;IACzG,MAAMkB,KAAK,GAAG1B,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAE0B,KAAK,AAAC;IAE/B,qBACE,KAAC9B,sBAAsB,CAAC+B,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC3C,cAAA,KAACxB,KAAK,KAAG;MACuB,CAClC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';\nimport {\n DatasourceStoreContext,\n DatasourceStore,\n usePluginRegistry,\n DatasourceSelectItemGroup,\n} from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;\n }\n}\n\nexport type WithPluginSystemDatasourceStoreParameter = {\n props: DatasourceStore;\n};\n\nconst prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatastoreStoreParameter(\n parameter: unknown | WithPluginSystemDatasourceStoreParameter\n): parameter is WithPluginSystemDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const { getPlugin } = usePluginRegistry();\n\n const initParameter = context.parameters.withPluginSystemDatasourceStore;\n\n // This currently provides a very simplified default to enable use in some\n // basic stories. It likely will need expanding in the future.\n // In general, `plugin-system` would probably benefit from a provider wrapper\n // for `DatasourceStoreContext` that is more generic than the one available\n // in the `dashboard` package for non-dashboard use cases.\n const defaultValue: DatasourceStore = {\n getDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve({\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: {},\n },\n });\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n getDatasourceClient: async <Client,>(selector: DatasourceSelector) => {\n if (selector.kind === 'PrometheusDatasource') {\n const plugin = await getPlugin('Datasource', 'PrometheusDatasource');\n const client = plugin.createClient({ directUrl: prometheusDemoUrl }, { proxyUrl: prometheusDemoUrl }) as Client;\n return client;\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n listDatasourceSelectItems: async (datasourcePluginKind): Promise<DatasourceSelectItemGroup[]> => {\n if (datasourcePluginKind === 'PrometheusDatasource') {\n return Promise.resolve([\n {\n items: [\n {\n name: 'PrometheusDatasource',\n selector: { kind: 'PrometheusDatasource' },\n },\n ],\n },\n ]);\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);\n },\n getSavedDatasources: (): Record<string, DatasourceSpec> => {\n return {};\n },\n setSavedDatasources: (datasources: Record<string, DatasourceSpec>) => {\n return datasources;\n },\n getLocalDatasources: (): Record<string, DatasourceSpec> => {\n return {};\n },\n setLocalDatasources: (datasources: Record<string, DatasourceSpec>) => {\n return datasources;\n },\n };\n\n const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : { props: defaultValue };\n const props = parameter?.props;\n\n return (\n <DatasourceStoreContext.Provider value={props}>\n <Story />\n </DatasourceStoreContext.Provider>\n );\n};\n"],"names":["DatasourceStoreContext","usePluginRegistry","prometheusDemoUrl","isWithDatastoreStoreParameter","parameter","WithPluginSystemDatasourceStore","Story","context","getPlugin","initParameter","parameters","withPluginSystemDatasourceStore","defaultValue","getDatasource","selector","kind","Promise","resolve","default","plugin","spec","Error","getDatasourceClient","client","createClient","directUrl","proxyUrl","listDatasourceSelectItems","datasourcePluginKind","items","name","getSavedDatasources","setSavedDatasources","datasources","getLocalDatasources","setLocalDatasources","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oE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iBACD;YACH;YACA,MAAM,IAAIM,MAAM,CAAC,uDAAuD,EAAEO,qBAAqB,CAAC;QAClG;QACAG,qBAAqB;YACnB,OAAO,CAAC;QACV;QACAC,qBAAqB,CAACC;YACpB,OAAOA;QACT;QACAC,qBAAqB;YACnB,OAAO,CAAC;QACV;QACAC,qBAAqB,CAACF;YACpB,OAAOA;QACT;IACF;IAEA,MAAM7B,YAAYD,8BAA8BM,iBAAiBA,gBAAgB;QAAE2B,OAAOxB;IAAa;IACvG,MAAMwB,QAAQhC,sBAAAA,gCAAAA,UAAWgC,KAAK;IAE9B,qBACE,KAACpC,uBAAuBqC,QAAQ;QAACC,OAAOF;kBACtC,cAAA,KAAC9B;;AAGP,EAAE"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryFn, StoryContext } from '@storybook/react';
3
2
  import { TemplateVariableSrv } from '../../../runtime';
4
3
  declare module '@storybook/react' {
@@ -6,8 +5,8 @@ declare module '@storybook/react' {
6
5
  withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;
7
6
  }
8
7
  }
9
- export declare type WithPluginSystemTemplateVariableParameter = {
8
+ export type WithPluginSystemTemplateVariableParameter = {
10
9
  props: TemplateVariableSrv;
11
10
  };
12
- export declare const WithPluginSystemTemplateVariables: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
11
+ export declare const WithPluginSystemTemplateVariables: (Story: StoryFn, context: StoryContext<unknown>) => import("react/jsx-runtime").JSX.Element;
13
12
  //# sourceMappingURL=WithPluginSystemTemplateVariables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WithPluginSystemTemplateVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,iCAAiC,CAAC,EAAE,yCAAyC,CAAC;KAC/E;CACF;AAED,oBAAY,yCAAyC,GAAG;IACtD,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAcF,eAAO,MAAM,iCAAiC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAc/F,CAAC"}
1
+ {"version":3,"file":"WithPluginSystemTemplateVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,iCAAiC,CAAC,EAAE,yCAAyC,CAAC;KAC/E;CACF;AAED,MAAM,MAAM,yCAAyC,GAAG;IACtD,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAcF,eAAO,MAAM,iCAAiC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,4CAc/F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableContext, TemplateVariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;\n }\n}\n\nexport type WithPluginSystemTemplateVariableParameter = {\n props: TemplateVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithPluginSystemTemplateVariableParameter\n): parameter is WithPluginSystemTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator is used for non-dashboards package template variable needs.\n// Use the more specific decorator in the dashboards package when working with\n// dashboards.\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withPluginSystemTemplateVariables;\n const defaultValue: TemplateVariableSrv = {\n state: {},\n };\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <TemplateVariableContext.Provider value={props}>\n <Story />\n </TemplateVariableContext.Provider>\n );\n};\n"],"names":["TemplateVariableContext","isWithTemplateVariableParameter","parameter","WithPluginSystemTemplateVariables","Story","context","initParameter","parameters","withPluginSystemTemplateVariables","defaultValue","state","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,uBAAuB,QAA6B,kBAAkB,CAAC;AAYhF,yDAAyD;AACzD,SAASC,+BAA+B,CACtCC,SAA8D,EACN;IACxD,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,6EAA6E;AAC7E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,iCAAiC,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACnG,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,iCAAiC,AAAC;IAC3E,MAAMC,YAAY,GAAwB;QACxCC,KAAK,EAAE,EAAE;KACV,AAAC;IACF,MAAMR,SAAS,GAAGD,+BAA+B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEK,KAAK,EAAEF,YAAY;KAAE,AAAC;IAE3G,MAAME,KAAK,GAAGT,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAES,KAAK,AAAC;IAE/B,qBACE,KAACX,uBAAuB,CAACY,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC5C,cAAA,KAACP,KAAK,KAAG;MACwB,CACnC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableContext, TemplateVariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;\n }\n}\n\nexport type WithPluginSystemTemplateVariableParameter = {\n props: TemplateVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithPluginSystemTemplateVariableParameter\n): parameter is WithPluginSystemTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator is used for non-dashboards package template variable needs.\n// Use the more specific decorator in the dashboards package when working with\n// dashboards.\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withPluginSystemTemplateVariables;\n const defaultValue: TemplateVariableSrv = {\n state: {},\n };\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <TemplateVariableContext.Provider value={props}>\n <Story />\n </TemplateVariableContext.Provider>\n );\n};\n"],"names":["TemplateVariableContext","isWithTemplateVariableParameter","parameter","WithPluginSystemTemplateVariables","Story","context","initParameter","parameters","withPluginSystemTemplateVariables","defaultValue","state","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,uBAAuB,QAA6B,mBAAmB;AAYhF,yDAAyD;AACzD,SAASC,gCACPC,SAA8D;IAE9D,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,6EAA6E;AAC7E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,oCAAoC,CAACC,OAAgBC;IAChE,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,iCAAiC;IAC1E,MAAMC,eAAoC;QACxCC,OAAO,CAAC;IACV;IACA,MAAMR,YAAYD,gCAAgCK,iBAAiBA,gBAAgB;QAAEK,OAAOF;IAAa;IAEzG,MAAME,QAAQT,sBAAAA,gCAAAA,UAAWS,KAAK;IAE9B,qBACE,KAACX,wBAAwBY,QAAQ;QAACC,OAAOF;kBACvC,cAAA,KAACP;;AAGP,EAAE"}