@perses-dev/plugin-system 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +26 -55
  2. package/dist/cjs/components/DatasourceSelect.js +22 -10
  3. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +1 -0
  4. package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -1
  5. package/dist/cjs/components/ProjectSelect.js +96 -0
  6. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +14 -12
  7. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +50 -2
  8. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +11 -8
  9. package/dist/cjs/components/index.js +1 -0
  10. package/dist/cjs/context/ProjectStoreProvider.js +78 -0
  11. package/dist/cjs/context/index.js +30 -0
  12. package/dist/cjs/context/query-params.js +49 -0
  13. package/dist/cjs/index.js +1 -0
  14. package/dist/cjs/model/index.js +1 -0
  15. package/dist/cjs/model/trace-queries.js +16 -0
  16. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +17 -5
  17. package/dist/cjs/runtime/DataQueriesProvider/model.js +27 -7
  18. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +27 -18
  19. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +43 -0
  20. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -0
  21. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +7 -39
  22. package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +30 -0
  23. package/dist/cjs/runtime/datasources.js +3 -2
  24. package/dist/cjs/runtime/index.js +1 -0
  25. package/dist/cjs/runtime/trace-queries.js +59 -0
  26. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +2 -1
  27. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +12 -0
  28. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +2 -2
  29. package/dist/cjs/test/mock-data.js +26 -3
  30. package/dist/cjs/validation/role.js +85 -0
  31. package/dist/cjs/validation/rolebinding.js +55 -0
  32. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +7 -7
  33. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  34. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +26 -16
  35. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  36. package/dist/components/DatasourceSelect.d.ts +1 -0
  37. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  38. package/dist/components/DatasourceSelect.js +22 -10
  39. package/dist/components/DatasourceSelect.js.map +1 -1
  40. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -1
  41. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  42. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +1 -0
  43. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  44. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  45. package/dist/components/PluginEditor/PluginEditor.js +2 -1
  46. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  47. package/dist/components/PluginEditor/plugin-editor-api.d.ts +1 -0
  48. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  49. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  50. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +1 -0
  51. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  52. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  53. package/dist/components/ProjectSelect.d.ts +15 -0
  54. package/dist/components/ProjectSelect.d.ts.map +1 -0
  55. package/dist/components/ProjectSelect.js +91 -0
  56. package/dist/components/ProjectSelect.js.map +1 -0
  57. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
  58. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +15 -13
  59. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
  60. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -2
  61. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  62. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +50 -2
  63. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  64. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +2 -1
  65. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  66. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +11 -8
  67. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  68. package/dist/components/index.d.ts +1 -0
  69. package/dist/components/index.d.ts.map +1 -1
  70. package/dist/components/index.js +1 -0
  71. package/dist/components/index.js.map +1 -1
  72. package/dist/context/ProjectStoreProvider.d.ts +16 -0
  73. package/dist/context/ProjectStoreProvider.d.ts.map +1 -0
  74. package/dist/context/ProjectStoreProvider.js +56 -0
  75. package/dist/context/ProjectStoreProvider.js.map +1 -0
  76. package/dist/context/index.d.ts +2 -0
  77. package/dist/context/index.d.ts.map +1 -0
  78. package/dist/context/index.js +15 -0
  79. package/dist/context/index.js.map +1 -0
  80. package/dist/context/query-params.d.ts +5 -0
  81. package/dist/context/query-params.d.ts.map +1 -0
  82. package/dist/context/query-params.js +41 -0
  83. package/dist/context/query-params.js.map +1 -0
  84. package/dist/index.d.ts +1 -0
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +1 -0
  87. package/dist/index.js.map +1 -1
  88. package/dist/model/index.d.ts +1 -0
  89. package/dist/model/index.d.ts.map +1 -1
  90. package/dist/model/index.js +1 -0
  91. package/dist/model/index.js.map +1 -1
  92. package/dist/model/plugin-base.d.ts +1 -0
  93. package/dist/model/plugin-base.d.ts.map +1 -1
  94. package/dist/model/plugin-base.js.map +1 -1
  95. package/dist/model/plugins.d.ts +2 -0
  96. package/dist/model/plugins.d.ts.map +1 -1
  97. package/dist/model/plugins.js.map +1 -1
  98. package/dist/model/trace-queries.d.ts +18 -0
  99. package/dist/model/trace-queries.d.ts.map +1 -0
  100. package/dist/model/trace-queries.js +15 -0
  101. package/dist/model/trace-queries.js.map +1 -0
  102. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  103. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +17 -5
  104. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  105. package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
  106. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  107. package/dist/runtime/DataQueriesProvider/model.js +27 -7
  108. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  109. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +4 -3
  110. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  111. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +28 -19
  112. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  113. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +9 -0
  114. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -0
  115. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +30 -0
  116. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -0
  117. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  118. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  119. package/dist/runtime/TimeRangeProvider/index.js +1 -0
  120. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  121. package/dist/runtime/TimeRangeProvider/query-params.d.ts +4 -4
  122. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  123. package/dist/runtime/TimeRangeProvider/query-params.js +8 -40
  124. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  125. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +7 -0
  126. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -0
  127. package/dist/runtime/TimeRangeProvider/refresh-interval.js +25 -0
  128. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -0
  129. package/dist/runtime/datasources.d.ts +29 -2
  130. package/dist/runtime/datasources.d.ts.map +1 -1
  131. package/dist/runtime/datasources.js +3 -2
  132. package/dist/runtime/datasources.js.map +1 -1
  133. package/dist/runtime/index.d.ts +1 -0
  134. package/dist/runtime/index.d.ts.map +1 -1
  135. package/dist/runtime/index.js +1 -0
  136. package/dist/runtime/index.js.map +1 -1
  137. package/dist/runtime/trace-queries.d.ts +10 -0
  138. package/dist/runtime/trace-queries.d.ts.map +1 -0
  139. package/dist/runtime/trace-queries.js +47 -0
  140. package/dist/runtime/trace-queries.js.map +1 -0
  141. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  142. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -1
  143. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  144. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  145. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +12 -0
  146. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  147. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -2
  148. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  149. package/dist/stories/shared-utils/decorators/WithTimeRange.js +2 -2
  150. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  151. package/dist/test/mock-data.d.ts +2 -1
  152. package/dist/test/mock-data.d.ts.map +1 -1
  153. package/dist/test/mock-data.js +15 -0
  154. package/dist/test/mock-data.js.map +1 -1
  155. package/dist/utils/action.d.ts +1 -1
  156. package/dist/utils/action.d.ts.map +1 -1
  157. package/dist/utils/action.js.map +1 -1
  158. package/dist/validation/role.d.ts +228 -0
  159. package/dist/validation/role.d.ts.map +1 -0
  160. package/dist/validation/role.js +66 -0
  161. package/dist/validation/role.js.map +1 -0
  162. package/dist/validation/rolebinding.d.ts +137 -0
  163. package/dist/validation/rolebinding.d.ts.map +1 -0
  164. package/dist/validation/rolebinding.js +47 -0
  165. package/dist/validation/rolebinding.js.map +1 -0
  166. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"variable-editor-form-model.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,wBAAgB,eAAe,CAAC,yBAAyB,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;EAgC5E;AAED,oBAAY,mBAAmB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAErE,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mBAAmB,GAAG,kBAAkB,CA+B7F"}
1
+ {"version":3,"file":"variable-editor-form-model.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,wBAAgB,eAAe,CAAC,yBAAyB,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;EAkC5E;AAED,oBAAY,mBAAmB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAErE,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mBAAmB,GAAG,kBAAkB,CAgC7F"}
@@ -20,21 +20,23 @@ export function getInitialState(initialVariableDefinition) {
20
20
  const listVariableFields = {
21
21
  allowMultiple: false,
22
22
  allowAll: false,
23
+ customAllValue: undefined,
23
24
  capturingRegexp: undefined,
25
+ sort: undefined,
24
26
  plugin: {
25
27
  kind: '',
26
28
  spec: {}
27
- },
28
- customAllValue: undefined
29
+ }
29
30
  };
30
31
  if (initialVariableDefinition.kind === 'ListVariable') {
32
+ var _initialVariableDefinition_spec_allowMultiple;
33
+ listVariableFields.allowMultiple = (_initialVariableDefinition_spec_allowMultiple = initialVariableDefinition.spec.allowMultiple) !== null && _initialVariableDefinition_spec_allowMultiple !== void 0 ? _initialVariableDefinition_spec_allowMultiple : false;
31
34
  var _initialVariableDefinition_spec_allowAllValue;
32
- listVariableFields.allowMultiple = (_initialVariableDefinition_spec_allowAllValue = initialVariableDefinition.spec.allowAllValue) !== null && _initialVariableDefinition_spec_allowAllValue !== void 0 ? _initialVariableDefinition_spec_allowAllValue : false;
33
- var _initialVariableDefinition_spec_allowAllValue1;
34
- listVariableFields.allowAll = (_initialVariableDefinition_spec_allowAllValue1 = initialVariableDefinition.spec.allowAllValue) !== null && _initialVariableDefinition_spec_allowAllValue1 !== void 0 ? _initialVariableDefinition_spec_allowAllValue1 : false;
35
+ listVariableFields.allowAll = (_initialVariableDefinition_spec_allowAllValue = initialVariableDefinition.spec.allowAllValue) !== null && _initialVariableDefinition_spec_allowAllValue !== void 0 ? _initialVariableDefinition_spec_allowAllValue : false;
36
+ listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;
35
37
  listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;
38
+ listVariableFields.sort = initialVariableDefinition.spec.sort;
36
39
  listVariableFields.plugin = initialVariableDefinition.spec.plugin;
37
- listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;
38
40
  }
39
41
  var _initialVariableDefinition_spec_display_name, _initialVariableDefinition_spec_display_description;
40
42
  return {
@@ -70,9 +72,10 @@ export function getVariableDefinitionFromState(state) {
70
72
  display,
71
73
  allowMultiple: state.listVariableFields.allowMultiple,
72
74
  allowAllValue: state.listVariableFields.allowAll,
75
+ customAllValue: state.listVariableFields.customAllValue,
73
76
  capturingRegexp: state.listVariableFields.capturingRegexp,
74
- plugin: state.listVariableFields.plugin,
75
- customAllValue: state.listVariableFields.customAllValue
77
+ sort: state.listVariableFields.sort,
78
+ plugin: state.listVariableFields.plugin
76
79
  }
77
80
  };
78
81
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.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 { TextVariableDefinition, VariableDefinition } from '@perses-dev/core';\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition) {\n const textVariableFields = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields = {\n allowMultiple: false,\n allowAll: false,\n capturingRegexp: undefined as string | undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n customAllValue: undefined as string | undefined,\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.allowAll = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport type VariableEditorState = ReturnType<typeof getInitialState>;\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAll,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n plugin: state.listVariableFields.plugin,\n customAllValue: state.listVariableFields.customAllValue,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAll","capturingRegexp","undefined","plugin","kind","customAllValue","allowAllValue","name","title","display","description","getVariableDefinitionFromState","state","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,gBAAgBC,yBAA6C;QA0BlEA,yCAEMA;QA1BN,uCACG;IAFZ,MAAMC,qBAAqB;QACzBC,OAAO,CAAA,wCAAA,AAACF,0BAAqDG,KAAKD,mBAA3D,mDAAA,wCAAoE;QAC3EE,UAAU,CAAA,2CAAA,AAACJ,0BAAqDG,KAAKC,sBAA3D,sDAAA,2CAAuE;IACnF;IAEA,MAAMC,qBAAqB;QACzBC,eAAe;QACfC,UAAU;QACVC,iBAAiBC;QACjBC,QAAQ;YACNC,MAAM;YACNR,MAAM,CAAC;QACT;QACAS,gBAAgBH;IAClB;IACA,IAAIT,0BAA0BW,SAAS,g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O;YAC3C;QACF;IACF;IACA,MAAM,IAAIQ,MAAM,CAAC,uBAAuB,EAAET,KAAK,CAAC;AAClD"}
1
+ {"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.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 { TextVariableDefinition, VariableDefinition } from '@perses-dev/core';\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition) {\n const textVariableFields = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields = {\n allowMultiple: false,\n allowAll: false,\n customAllValue: undefined as string | undefined,\n capturingRegexp: undefined as string | undefined,\n sort: undefined as string | undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;\n listVariableFields.allowAll = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.sort = initialVariableDefinition.spec.sort;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport type VariableEditorState = ReturnType<typeof getInitialState>;\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAll,\n customAllValue: state.listVariableFields.customAllValue,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n sort: state.listVariableFields.sort,\n plugin: state.listVariableFields.plugin,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAll","customAllValue","undefined","capturingRegexp","sort","plugin","kind","allowAllValue","name","title","display","description","getVariableDefinitionFromState","state","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,gBAAgBC,yBAA6C;QA4BlEA,yCAEMA;QA5BN,uCACG;IAFZ,MAAMC,qBAAqB;QACzBC,OAAO,CAAA,wCAAA,AAACF,0BAAqDG,KAAKD,mBAA3D,mDAAA,wCAAoE;QAC3EE,UAAU,CAAA,2CAAA,AAACJ,0BAAqDG,KAAKC,sBAA3D,sDAAA,2CAAuE;IACnF;IAEA,MAAMC,qBAAqB;QACzBC,eAAe;QACfC,UAAU;QACVC,gBAAgBC;QAChBC,iBAAiBD;QACjBE,MAAMF;QACNG,QAAQ;YACNC,MAAM;YACNV,MAAM,CAAC;QACT;IACF;IACA,IAAIH,0BAA0Ba,SAAS,gBAAgB;YAClBb;QAAnCK,mBAAmBC,gBAAgBN,CAAAA,gDAAAA,0BAA0BG,KAAKG,2BAA/BN,2DAAAA,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F;IACA,MAAM,IAAIS,MAAM,CAAC,uBAAuB,EAAER,KAAK,CAAC;AAClD"}
@@ -11,4 +11,5 @@ export * from './PluginRegistry';
11
11
  export * from './PluginSpecEditor';
12
12
  export * from './TimeSeriesQueryEditor';
13
13
  export * from './Variables';
14
+ export * from './ProjectSelect';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -23,5 +23,6 @@ export * from './PluginRegistry';
23
23
  export * from './PluginSpecEditor';
24
24
  export * from './TimeSeriesQueryEditor';
25
25
  export * from './Variables';
26
+ export * from './ProjectSelect';
26
27
 
27
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './CalculationSelector';\nexport * from './DatasourceEditorForm';\nexport * from './DatasourceSelect';\nexport * from './LegendOptionsEditor';\nexport * from './OptionsEditorRadios';\nexport * from './OptionsEditorTabs';\nexport * from './PanelSpecEditor';\nexport * from './PluginEditor';\nexport * from './PluginKindSelect';\nexport * from './PluginRegistry';\nexport * from './PluginSpecEditor';\nexport * from './TimeSeriesQueryEditor';\nexport * from './Variables';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,0BAA0B;AACxC,cAAc,cAAc"}
1
+ {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './CalculationSelector';\nexport * from './DatasourceEditorForm';\nexport * from './DatasourceSelect';\nexport * from './LegendOptionsEditor';\nexport * from './OptionsEditorRadios';\nexport * from './OptionsEditorTabs';\nexport * from './PanelSpecEditor';\nexport * from './PluginEditor';\nexport * from './PluginKindSelect';\nexport * from './PluginRegistry';\nexport * from './PluginSpecEditor';\nexport * from './TimeSeriesQueryEditor';\nexport * from './Variables';\nexport * from './ProjectSelect';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,0BAA0B;AACxC,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
@@ -0,0 +1,16 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ import { ReactNode } from 'react';
3
+ import { ProjectResource } from '@perses-dev/core';
4
+ export interface ProjectStore {
5
+ setProject: (project: ProjectResource) => void;
6
+ project: ProjectResource;
7
+ }
8
+ export interface ProjectStoreProviderProps {
9
+ children?: ReactNode;
10
+ enabledURLParams?: boolean;
11
+ }
12
+ export declare const ProjectStoreContext: import("react").Context<ProjectStore | undefined>;
13
+ export declare function useProjectList(): UseQueryResult<ProjectResource[], Error>;
14
+ export declare function useProjectStore(): ProjectStore;
15
+ export declare function ProjectStoreProvider(props: ProjectStoreProviderProps): JSX.Element;
16
+ //# sourceMappingURL=ProjectStoreProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectStoreProvider.d.ts","sourceRoot":"","sources":["../../src/context/ProjectStoreProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAC;AACtE,OAAO,EAAa,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG9D,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,mDAAqD,CAAC;AAEtF,wBAAgB,cAAc,IAAI,cAAc,CAAC,eAAe,EAAE,EAAE,KAAK,CAAC,CAIzE;AAED,wBAAgB,eAAe,iBAM9B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,eAoBpE"}
@@ -0,0 +1,56 @@
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 { useQuery } from '@tanstack/react-query';
15
+ import { createContext, useContext, useMemo } from 'react';
16
+ import { fetchJson } from '@perses-dev/core';
17
+ import { useSetProjectParams } from './query-params';
18
+ export const ProjectStoreContext = /*#__PURE__*/ createContext(undefined);
19
+ export function useProjectList() {
20
+ return useQuery([
21
+ 'projects'
22
+ ], ()=>{
23
+ return fetchJson('/api/v1/projects');
24
+ });
25
+ }
26
+ export function useProjectStore() {
27
+ const ctx = useContext(ProjectStoreContext);
28
+ if (ctx === undefined) {
29
+ throw new Error('No ProjectStoreContext found. Did you forget a Provider?');
30
+ }
31
+ return ctx;
32
+ }
33
+ export function ProjectStoreProvider(props) {
34
+ const { children , enabledURLParams } = props;
35
+ const { project , setProject } = useSetProjectParams(enabledURLParams);
36
+ const contextValue = useMemo(()=>({
37
+ project: {
38
+ kind: 'Project',
39
+ metadata: {
40
+ name: project
41
+ }
42
+ },
43
+ setProject: (project)=>{
44
+ setProject(project.metadata.name);
45
+ }
46
+ }), [
47
+ project,
48
+ setProject
49
+ ]);
50
+ return /*#__PURE__*/ _jsx(ProjectStoreContext.Provider, {
51
+ value: contextValue,
52
+ children: children
53
+ });
54
+ }
55
+
56
+ //# sourceMappingURL=ProjectStoreProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/ProjectStoreProvider.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 { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, createContext, useContext, useMemo } from 'react';\nimport { fetchJson, ProjectResource } from '@perses-dev/core';\nimport { useSetProjectParams } from './query-params';\n\nexport interface ProjectStore {\n setProject: (project: ProjectResource) => void;\n project: ProjectResource;\n}\n\nexport interface ProjectStoreProviderProps {\n children?: ReactNode;\n enabledURLParams?: boolean;\n}\n\nexport const ProjectStoreContext = createContext<ProjectStore | undefined>(undefined);\n\nexport function useProjectList(): UseQueryResult<ProjectResource[], Error> {\n return useQuery<ProjectResource[], Error>(['projects'], () => {\n return fetchJson<ProjectResource[]>('/api/v1/projects');\n });\n}\n\nexport function useProjectStore() {\n const ctx = useContext(ProjectStoreContext);\n if (ctx === undefined) {\n throw new Error('No ProjectStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function ProjectStoreProvider(props: ProjectStoreProviderProps) {\n const { children, enabledURLParams } = props;\n const { project, setProject } = useSetProjectParams(enabledURLParams);\n\n const contextValue = useMemo(\n () => ({\n project: {\n kind: 'Project',\n metadata: {\n name: project,\n },\n } as ProjectResource,\n setProject: (project: ProjectResource) => {\n setProject(project.metadata.name);\n },\n }),\n [project, setProject]\n );\n\n return <ProjectStoreContext.Provider value={contextValue}>{children}</ProjectStoreContext.Provider>;\n}\n"],"names":["useQuery","createContext","useContext","useMemo","fetchJson","useSetProjectParams","ProjectStoreContext","undefined","useProjectList","useProjectStore","ctx","Error","ProjectStoreProvider","props","children","enabledURLParams","project","setProject","contextValue","kind","metadata","name","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,SAASA,QAAQ,QAAwB,wBAAwB;AACjE,SAAoBC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACtE,SAASC,SAAS,QAAyB,mBAAmB;AAC9D,SAASC,mBAAmB,QAAQ,iBAAiB;AAYrD,OAAO,MAAMC,oCAAsBL,cAAwCM,WAAW;AAEtF,OAAO,SAASC;IACd,OAAOR,SAAmC;QAAC;KAAW,EAAE;QACtD,OAAOI,UAA6B;IACtC;AACF;AAEA,OAAO,SAASK;IACd,MAAMC,MAAMR,WAAWI;IACvB,IAAII,QAAQH,WAAW;QACrB,MAAM,IAAII,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,qBAAqBC,KAAgC;IACnE,MAAM,EAAEC,SAAQ,EAAEC,iBAAgB,EAAE,GAAGF;IACvC,MAAM,EAAEG,QAAO,EAAEC,WAAU,EAAE,GAAGZ,oBAAoBU;IAEpD,MAAMG,eAAef,QACnB,IAAO,CAAA;YACLa,SAAS;gBACPG,MAAM;gBACNC,UAAU;oBACRC,MAAML;gBACR;YACF;YACAC,YAAY,CAACD;gBACXC,WAAWD,QAAQI,SAASC;YAC9B;QACF,CAAA,GACA;QAACL;QAASC;KAAW;IAGvB,qBAAO,KAACX,oBAAoBgB;QAASC,OAAOL;kBAAeJ;;AAC7D"}
@@ -0,0 +1,2 @@
1
+ export * from './ProjectStoreProvider';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './ProjectStoreProvider';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ProjectStoreProvider';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,yBAAyB"}
@@ -0,0 +1,5 @@
1
+ export declare function useSetProjectParams(enabledURLParams?: boolean): {
2
+ project: string;
3
+ setProject: (project: string) => void;
4
+ };
5
+ //# sourceMappingURL=query-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../src/context/query-params.ts"],"names":[],"mappings":"AAgBA,wBAAgB,mBAAmB,CAAC,gBAAgB,UAAO;;0BAM7C,MAAM;EAiBnB"}
@@ -0,0 +1,41 @@
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 { useCallback, useState } from 'react';
14
+ import { useQueryParams } from 'use-query-params';
15
+ export function useSetProjectParams(enabledURLParams = true) {
16
+ const [query, setQuery] = useQueryParams({
17
+ project: ''
18
+ }, {
19
+ updateType: 'replaceIn'
20
+ });
21
+ const [projectState, setProjectState] = useState('none');
22
+ const setProject = useCallback((project)=>{
23
+ return setQuery({
24
+ project
25
+ });
26
+ }, [
27
+ setQuery
28
+ ]);
29
+ if (enabledURLParams) {
30
+ return {
31
+ project: query.project || 'none',
32
+ setProject
33
+ };
34
+ }
35
+ return {
36
+ project: projectState,
37
+ setProject: setProjectState
38
+ };
39
+ }
40
+
41
+ //# sourceMappingURL=query-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/query-params.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 { useCallback, useState } from 'react';\nimport { useQueryParams } from 'use-query-params';\n\nexport function useSetProjectParams(enabledURLParams = true) {\n const [query, setQuery] = useQueryParams({ project: '' }, { updateType: 'replaceIn' });\n\n const [projectState, setProjectState] = useState<string>('none');\n\n const setProject = useCallback(\n (project: string) => {\n return setQuery({ project });\n },\n [setQuery]\n );\n\n if (enabledURLParams) {\n return {\n project: query.project || 'none',\n setProject,\n };\n }\n\n return {\n project: projectState,\n setProject: setProjectState,\n };\n}\n"],"names":["useCallback","useState","useQueryParams","useSetProjectParams","enabledURLParams","query","setQuery","project","updateType","projectState","setProjectState","setProject"],"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,EAAEC,QAAQ,QAAQ,QAAQ;AAC9C,SAASC,cAAc,QAAQ,mBAAmB;AAElD,OAAO,SAASC,oBAAoBC,mBAAmB,IAAI;IACzD,MAAM,CAACC,OAAOC,SAAS,GAAGJ,eAAe;QAAEK,SAAS;IAAG,GAAG;QAAEC,YAAY;IAAY;IAEpF,MAAM,CAACC,cAAcC,gBAAgB,GAAGT,SAAiB;IAEzD,MAAMU,aAAaX,YACjB,CAACO;QACC,OAAOD,SAAS;YAAEC;QAAQ;IAC5B,GACA;QAACD;KAAS;IAGZ,IAAIF,kBAAkB;QACpB,OAAO;YACLG,SAASF,MAAME,WAAW;YAC1BI;QACF;IACF;IAEA,OAAO;QACLJ,SAASE;QACTE,YAAYD;IACd;AACF"}
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './runtime';
5
5
  export * from './test-utils';
6
6
  export * from './utils';
7
7
  export * from './validation';
8
+ export * from './context';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -17,5 +17,6 @@ export * from './runtime';
17
17
  export * from './test-utils';
18
18
  export * from './utils';
19
19
  export * from './validation';
20
+ export * from './context';
20
21
 
21
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './components';\nexport * from './constants';\nexport * from './model';\nexport * from './runtime';\nexport * from './test-utils';\nexport * from './utils';\nexport * from './validation';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,eAAe"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './components';\nexport * from './constants';\nexport * from './model';\nexport * from './runtime';\nexport * from './test-utils';\nexport * from './utils';\nexport * from './validation';\nexport * from './context';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,YAAY"}
@@ -5,5 +5,6 @@ export * from './plugins';
5
5
  export * from './plugin-base';
6
6
  export * from './plugin-loading';
7
7
  export * from './time-series-queries';
8
+ export * from './trace-queries';
8
9
  export * from './variables';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
@@ -17,6 +17,7 @@ export * from './plugins';
17
17
  export * from './plugin-base';
18
18
  export * from './plugin-loading';
19
19
  export * from './time-series-queries';
20
+ export * from './trace-queries';
20
21
  export * from './variables';
21
22
 
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './legend';\nexport * from './panels';\nexport * from './plugins';\nexport * from './plugin-base';\nexport * from './plugin-loading';\nexport * from './time-series-queries';\nexport * from './variables';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,wBAAwB;AACtC,cAAc,cAAc"}
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './legend';\nexport * from './panels';\nexport * from './plugins';\nexport * from './plugin-base';\nexport * from './plugin-loading';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './variables';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,cAAc"}
@@ -20,6 +20,7 @@ export interface OptionsEditorProps<Spec> {
20
20
  value: Spec;
21
21
  onChange: (next: Spec) => void;
22
22
  isReadonly?: boolean;
23
+ isExplore?: boolean;
23
24
  }
24
25
  /**
25
26
  * Common props passed to query editor component
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-base.d.ts","sourceRoot":"","sources":["../../src/model/plugin-base.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI;IAC1B;;OAEG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvE;;OAEG;IACH,oBAAoB,EAAE,MAAM,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI;IAGtC,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,CAAE,SAAQ,kBAAkB,CAAC,IAAI,CAAC;IACtE,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
1
+ {"version":3,"file":"plugin-base.d.ts","sourceRoot":"","sources":["../../src/model/plugin-base.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI;IAC1B;;OAEG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvE;;OAEG;IACH,oBAAoB,EAAE,MAAM,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI;IAGtC,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,CAAE,SAAQ,kBAAkB,CAAC,IAAI,CAAC;IACtE,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/plugin-base.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 { QueryDefinition } from '@perses-dev/core';\nimport React from 'react';\n\n/**\n * Base type of all plugin implementations.\n */\nexport interface Plugin<Spec> {\n /**\n * React component for editing the plugin's options in the UI.\n */\n OptionsEditorComponent?: React.ComponentType<OptionsEditorProps<Spec>>;\n\n /**\n * Callback for creating the initial options for the plugin.\n */\n createInitialOptions: () => Spec;\n}\n\n/**\n * Common props passed to options editor components.\n */\nexport interface OptionsEditorProps<Spec> {\n // TODO: These are temporary and may not actually make sense, so replace\n // with whatever makes sense as visual editing evolves\n value: Spec;\n onChange: (next: Spec) => void;\n isReadonly?: boolean;\n}\n\n/**\n * Common props passed to query editor component\n */\nexport interface QueryEditorProps<Spec> extends OptionsEditorProps<Spec> {\n queries: QueryDefinition[];\n}\n"],"names":["React"],"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,OAAOA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../../src/model/plugin-base.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 { QueryDefinition } from '@perses-dev/core';\nimport React from 'react';\n\n/**\n * Base type of all plugin implementations.\n */\nexport interface Plugin<Spec> {\n /**\n * React component for editing the plugin's options in the UI.\n */\n OptionsEditorComponent?: React.ComponentType<OptionsEditorProps<Spec>>;\n\n /**\n * Callback for creating the initial options for the plugin.\n */\n createInitialOptions: () => Spec;\n}\n\n/**\n * Common props passed to options editor components.\n */\nexport interface OptionsEditorProps<Spec> {\n // TODO: These are temporary and may not actually make sense, so replace\n // with whatever makes sense as visual editing evolves\n value: Spec;\n onChange: (next: Spec) => void;\n isReadonly?: boolean;\n isExplore?: boolean;\n}\n\n/**\n * Common props passed to query editor component\n */\nexport interface QueryEditorProps<Spec> extends OptionsEditorProps<Spec> {\n queries: QueryDefinition[];\n}\n"],"names":["React"],"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,OAAOA,WAAW,QAAQ"}
@@ -4,6 +4,7 @@ import { PanelPlugin } from './panels';
4
4
  import { VariablePlugin } from './variables';
5
5
  import { DatasourcePlugin } from './datasource';
6
6
  import { Plugin } from './plugin-base';
7
+ import { TraceQueryPlugin } from './trace-queries';
7
8
  /**
8
9
  * Information about a module/package that contains plugins.
9
10
  */
@@ -41,6 +42,7 @@ export interface SupportedPlugins {
41
42
  Variable: VariablePlugin;
42
43
  Panel: PanelPlugin;
43
44
  TimeSeriesQuery: TimeSeriesQueryPlugin;
45
+ TraceQuery: TraceQueryPlugin;
44
46
  Datasource: DatasourcePlugin;
45
47
  }
46
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/model/plugins.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED;;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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata, UnknownSpec } from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin } from './time-series-queries';\nimport { PanelPlugin } from './panels';\nimport { VariablePlugin } from './variables';\nimport { DatasourcePlugin } from './datasource';\nimport { Plugin } from './plugin-base';\n\n/**\n * Information about a module/package that contains plugins.\n */\nexport interface PluginModuleResource {\n kind: 'PluginModule';\n metadata: Metadata;\n spec: PluginSpec;\n}\n\nexport interface PluginSpec {\n plugins: PluginMetadata[];\n}\n\n/**\n * Metadata about an individual plugin that's part of a PluginModule.\n */\nexport interface PluginMetadata {\n pluginType: PluginType;\n kind: string;\n display: {\n name: string;\n description?: string;\n };\n}\n\n/**\n * All supported plugin types. A plugin's implementation must extend from `Plugin<UnknownSpec>` to be considered a valid\n * `PluginType`.\n */\nexport type PluginType = {\n // Filter out implementations on SupportedPlugins that don't extend `Plugin<UnknownSpec>`\n [K in keyof SupportedPlugins]: SupportedPlugins[K] extends Plugin<UnknownSpec> ? K : never;\n}[keyof SupportedPlugins];\n\n/**\n * Map of plugin type key/string -> implementation type. Use Typescript module augmentation to extend the plugin system\n * with new plugin types.\n */\nexport interface SupportedPlugins {\n Variable: VariablePlugin;\n Panel: PanelPlugin;\n TimeSeriesQuery: TimeSeriesQueryPlugin;\n Datasource: DatasourcePlugin;\n}\n\n/**\n * The implementation for a given plugin type.\n */\nexport type PluginImplementation<Type extends PluginType> = SupportedPlugins[Type];\n\n/**\n * Default plugin kinds by plugin type.\n */\ntype PluginKinds = Partial<Record<PluginType, string>>;\nexport type DefaultPluginKinds = Required<Pick<PluginKinds, 'TimeSeriesQuery'>> & Omit<PluginKinds, 'TimeSeriesQuery'>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WA6DuH"}
1
+ {"version":3,"sources":["../../src/model/plugins.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata, UnknownSpec } from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin } from './time-series-queries';\nimport { PanelPlugin } from './panels';\nimport { VariablePlugin } from './variables';\nimport { DatasourcePlugin } from './datasource';\nimport { Plugin } from './plugin-base';\nimport { TraceQueryPlugin } from './trace-queries';\n\n/**\n * Information about a module/package that contains plugins.\n */\nexport interface PluginModuleResource {\n kind: 'PluginModule';\n metadata: Metadata;\n spec: PluginSpec;\n}\n\nexport interface PluginSpec {\n plugins: PluginMetadata[];\n}\n\n/**\n * Metadata about an individual plugin that's part of a PluginModule.\n */\nexport interface PluginMetadata {\n pluginType: PluginType;\n kind: string;\n display: {\n name: string;\n description?: string;\n };\n}\n\n/**\n * All supported plugin types. A plugin's implementation must extend from `Plugin<UnknownSpec>` to be considered a valid\n * `PluginType`.\n */\nexport type PluginType = {\n // Filter out implementations on SupportedPlugins that don't extend `Plugin<UnknownSpec>`\n [K in keyof SupportedPlugins]: SupportedPlugins[K] extends Plugin<UnknownSpec> ? K : never;\n}[keyof SupportedPlugins];\n\n/**\n * Map of plugin type key/string -> implementation type. Use Typescript module augmentation to extend the plugin system\n * with new plugin types.\n */\nexport interface SupportedPlugins {\n Variable: VariablePlugin;\n Panel: PanelPlugin;\n TimeSeriesQuery: TimeSeriesQueryPlugin;\n TraceQuery: TraceQueryPlugin;\n Datasource: DatasourcePlugin;\n}\n\n/**\n * The implementation for a given plugin type.\n */\nexport type PluginImplementation<Type extends PluginType> = SupportedPlugins[Type];\n\n/**\n * Default plugin kinds by plugin type.\n */\ntype PluginKinds = Partial<Record<PluginType, string>>;\nexport type DefaultPluginKinds = Required<Pick<PluginKinds, 'TimeSeriesQuery'>> & Omit<PluginKinds, 'TimeSeriesQuery'>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WA+DuH"}
@@ -0,0 +1,18 @@
1
+ import { Query, QueryKey } from '@tanstack/react-query';
2
+ import { UnknownSpec, TraceData } from '@perses-dev/core';
3
+ import { DatasourceStore } from '../runtime';
4
+ import { Plugin } from './plugin-base';
5
+ /**
6
+ * A plugin for running trace queries.
7
+ */
8
+ export interface TraceQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {
9
+ getTraceData: (spec: Spec, ctx: TraceQueryContext) => Promise<TraceData>;
10
+ }
11
+ /**
12
+ * Context available to TraceQuery plugins at runtime.
13
+ */
14
+ export interface TraceQueryContext {
15
+ datasourceStore: DatasourceStore;
16
+ }
17
+ export declare type TraceDataQuery = Query<TraceData, unknown, TraceData, QueryKey>;
18
+ //# sourceMappingURL=trace-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-queries.d.ts","sourceRoot":"","sources":["../../src/model/trace-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACxE,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,oBAAY,cAAc,GAAG,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export { };
14
+
15
+ //# sourceMappingURL=trace-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/trace-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 { Query, QueryKey } from '@tanstack/react-query';\nimport { UnknownSpec, TraceData } from '@perses-dev/core';\nimport { DatasourceStore } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * A plugin for running trace queries.\n */\nexport interface TraceQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTraceData: (spec: Spec, ctx: TraceQueryContext) => Promise<TraceData>;\n}\n\n/**\n * Context available to TraceQuery plugins at runtime.\n */\nexport interface TraceQueryContext {\n datasourceStore: DatasourceStore;\n}\n\nexport type TraceDataQuery = Query<TraceData, unknown, TraceData, QueryKey>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAmB4E"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataQueriesProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,SAAS,EAA6B,MAAM,kBAAkB,CAAC;AAExE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EAEnB,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,kBAAkB,6DAA+D,CAAC;AAE/F,wBAAgB,qBAAqB,2BAMpC;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAqBzG;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAsClE"}
1
+ {"version":3,"file":"DataQueriesProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,SAAS,EAA6B,MAAM,kBAAkB,CAAC;AAIxE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EAEnB,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,kBAAkB,6DAA+D,CAAC;AAE/F,wBAAgB,qBAAqB,2BAMpC;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAqBzG;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAgDlE"}
@@ -13,6 +13,7 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { createContext, useCallback, useContext, useMemo } from 'react';
15
15
  import { useTimeSeriesQueries } from '../time-series-queries';
16
+ import { useTraceQueries } from '../trace-queries';
16
17
  import { transformQueryResults, useQueryType } from './model';
17
18
  export const DataQueriesContext = /*#__PURE__*/ createContext(undefined);
18
19
  export function useDataQueriesContext() {
@@ -25,11 +26,14 @@ export function useDataQueriesContext() {
25
26
  export function useDataQueries(queryType) {
26
27
  const ctx = useDataQueriesContext();
27
28
  // Filter the query results based on the specified query type
28
- const filteredQueryResults = ctx.queryResults.filter((queryResult)=>queryResult.definition.kind === queryType);
29
+ const filteredQueryResults = ctx.queryResults.filter((queryResult)=>{
30
+ var _queryResult_definition;
31
+ return (queryResult === null || queryResult === void 0 ? void 0 : (_queryResult_definition = queryResult.definition) === null || _queryResult_definition === void 0 ? void 0 : _queryResult_definition.kind) === queryType;
32
+ });
29
33
  // Filter the errors based on the specified query type
30
34
  const filteredErrors = ctx.errors.filter((errors, index)=>{
31
- var _ctx_queryResults_index;
32
- return ((_ctx_queryResults_index = ctx.queryResults[index]) === null || _ctx_queryResults_index === void 0 ? void 0 : _ctx_queryResults_index.definition.kind) === queryType;
35
+ var _ctx_queryResults_index, _ctx_queryResults_index_definition;
36
+ return ((_ctx_queryResults_index = ctx.queryResults[index]) === null || _ctx_queryResults_index === void 0 ? void 0 : (_ctx_queryResults_index_definition = _ctx_queryResults_index.definition) === null || _ctx_queryResults_index_definition === void 0 ? void 0 : _ctx_queryResults_index_definition.kind) === queryType;
33
37
  });
34
38
  // Create a new context object with the filtered results and errors
35
39
  const filteredCtx = {
@@ -43,6 +47,7 @@ export function useDataQueries(queryType) {
43
47
  }
44
48
  export function DataQueriesProvider(props) {
45
49
  const { definitions , options , children , queryOptions } = props;
50
+ // Returns a query kind, for example "TimeSeriesQuery" = getQueryType("PrometheusTimeSeriesQuery")
46
51
  const getQueryType = useQueryType();
47
52
  const queryDefinitions = definitions.map((definition)=>{
48
53
  const type = getQueryType(definition.kind);
@@ -56,14 +61,19 @@ export function DataQueriesProvider(props) {
56
61
  // Filter definitions for time series query and other future query plugins
57
62
  const timeSeriesQueries = queryDefinitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
58
63
  const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);
64
+ const traceQueries = queryDefinitions.filter((definition)=>definition.kind === 'TraceQuery');
65
+ const traceResults = useTraceQueries(traceQueries);
59
66
  const refetchAll = useCallback(()=>{
60
67
  timeSeriesResults.forEach((result)=>result.refetch());
68
+ traceResults.forEach((result)=>result.refetch());
61
69
  }, [
62
- timeSeriesResults
70
+ timeSeriesResults,
71
+ traceResults
63
72
  ]);
64
73
  const ctx = useMemo(()=>{
65
74
  const mergedQueryResults = [
66
- ...transformQueryResults(timeSeriesResults, timeSeriesQueries)
75
+ ...transformQueryResults(timeSeriesResults, timeSeriesQueries),
76
+ ...transformQueryResults(traceResults, traceQueries)
67
77
  ];
68
78
  return {
69
79
  queryResults: mergedQueryResults,
@@ -75,6 +85,8 @@ export function DataQueriesProvider(props) {
75
85
  }, [
76
86
  timeSeriesQueries,
77
87
  timeSeriesResults,
88
+ traceQueries,
89
+ traceResults,
78
90
  refetchAll
79
91
  ]);
80
92
  return /*#__PURE__*/ _jsx(DataQueriesContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.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 { createContext, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext() {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult.definition.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps) {\n const { definitions, options, children, queryOptions } = props;\n\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n }, [timeSeriesResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [...transformQueryResults(timeSeriesResults, timeSeriesQueries)];\n\n return {\n queryResults: mergedQueryResults,\n isFetching: mergedQueryResults.some((result) => result.isFetching),\n isLoading: mergedQueryResults.some((result) => result.isLoading),\n refetchAll,\n errors: mergedQueryResults.map((result) => result.error),\n };\n }, [timeSeriesQueries, timeSeriesResults, refetchAll]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","transformQueryResults","useQueryType","DataQueriesContext","undefined","useDataQueriesContext","ctx","Error","useDataQueries","queryType","filteredQueryResults","queryResults","filter","queryResult","definition","kind","filteredErrors","errors","index","filteredCtx","isFetching","some","result","isLoading","refetchAll","DataQueriesProvider","props","definitions","options","children","queryOptions","getQueryType","queryDefinitions","map","type","spec","plugin","timeSeriesQueries","timeSeriesResults","forEach","refetch","mergedQueryResults","error","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,SAASA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AAWC,SAAS;IAEtC,MAAMuB,oBAAoBtC,qBAAqBqC,mBAAmBT,SAASE;IAE3E,MAAMN,aAAa3B,YAAY;QAC7ByC,kBAAkBC,QAAQ,CAACjB,SAAWA,OAAOkB;IAC/C,GAAG;QAACF;KAAkB;IAEtB,MAAMhC,MAAMP,QAAQ;QAClB,MAAM0C,qBAAqB;eAAIxC,sBAAsBqC,mBAAmBD;SAAmB;QAE3F,OAAO;YACL1B,cAAc8B;YACdrB,YAAYqB,mBAAmBpB,KAAK,CAACC,SAAWA,OAAOF;YACvDG,WAAWkB,mBAAmBpB,KAAK,CAACC,SAAWA,OAAOC;YACtDC;YACAP,QAAQwB,mBAAmBR,IAAI,CAACX,SAAWA,OAAOoB;QACpD;IACF,GAAG;QAACL;QAAmBC;QAAmBd;KAAW;IAErD,qBAAO,KAACrB,mBAAmBwC;QAASC,OAAOtC;kBAAMuB;;AACnD"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.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 { createContext, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\n\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext() {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult?.definition?.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition?.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps) {\n const { definitions, options, children, queryOptions } = props;\n\n // Returns a query kind, for example \"TimeSeriesQuery\" = getQueryType(\"PrometheusTimeSeriesQuery\")\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n\n const traceQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TraceQuery'\n ) as TraceQueryDefinition[];\n const traceResults = useTraceQueries(traceQueries);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n traceResults.forEach((result) => result.refetch());\n }, [timeSeriesResults, traceResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [\n ...transformQueryResults(timeSeriesResults, timeSeriesQueries),\n ...transformQueryResults(traceResults, traceQueries),\n ];\n\n return {\n queryResults: mergedQueryResults,\n isFetching: mergedQueryResults.some((result) => result.isFetching),\n isLoading: mergedQueryResults.some((result) => result.isLoading),\n refetchAll,\n errors: mergedQueryResults.map((result) => result.error),\n };\n }, [timeSeriesQueries, timeSeriesResults, traceQueries, traceResults, refetchAll]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useTraceQueries","transformQueryResults","useQueryType","DataQueriesContext","undefined","useDataQueriesContext","ctx","Error","useDataQueries","queryType","filteredQueryResults","queryResults","filter","queryResult","definition","kind","filteredErrors","errors","index","filteredCtx","isFetching","some","result","isLoading","refetchAll","DataQueriesProvider","props","definitions","options","children","queryOptions","getQueryType","queryDefinitions","map","type","spec","plugin","timeSeriesQueries","timeSeriesResults","traceQueries","traceResults","forEach","refetch","mergedQueryResults","error","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,SAASA,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAExE,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,eAAe,QAA8B,mBAAmB;AAEzE,SAGEC,qBAAqB,EAGrBC,YAAY,QACP,UAAU;AAEjB,OAAO,MAAMC,mCAAqBR,cAAkDS,WAAW;AAE/F,OAAO,SAASC;IACd,MAAMC,MAAMT,WAAWM;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,eAA0CC,SAAY;IACpE,MAAMH,MAAMD;IAEZ,6DAA6D;IAC7D,MAAMK,uBAAuBJ,IAAIK,aAAaC,OAC5C,CAACC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AAWA,OAAOoB;IAC1C,GAAG;QAACJ;QAAmBE;KAAa;IAEpC,MAAMlC,MAAMR,QAAQ;QAClB,MAAM6C,qBAAqB;eACtB1C,sBAAsBqC,mBAAmBD;eACzCpC,sBAAsBuC,cAAcD;SACxC;QAED,OAAO;YACL5B,cAAcgC;YACdvB,YAAYuB,mBAAmBtB,KAAK,CAACC,SAAWA,OAAOF;YACvDG,WAAWoB,mBAAmBtB,KAAK,CAACC,SAAWA,OAAOC;YACtDC;YACAP,QAAQ0B,mBAAmBV,IAAI,CAACX,SAAWA,OAAOsB;QACpD;IACF,GAAG;QAACP;QAAmBC;QAAmBC;QAAcC;QAAchB;KAAW;IAEjF,qBAAO,KAACrB,mBAAmB0C;QAASC,OAAOxC;kBAAMuB;;AACnD"}
@@ -26,7 +26,7 @@ export declare type QueryData<T = QueryDataType> = {
26
26
  isLoading: boolean;
27
27
  refetch?: () => void;
28
28
  };
29
- export declare function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData<import("@perses-dev/core").TimeSeriesData>[];
29
+ export declare function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData<QueryDataType>[];
30
30
  export declare function useQueryType(): (pluginKind: string) => string | undefined;
31
31
  export {};
32
32
  //# sourceMappingURL=model.d.ts.map