@perses-dev/plugin-system 0.8.0 → 0.9.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 (149) hide show
  1. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +43 -29
  2. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +114 -38
  3. package/dist/cjs/components/PluginRegistry/index.js +17 -18
  4. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +23 -20
  5. package/dist/cjs/components/PluginRegistry/plugin-registry-model.js +17 -7
  6. package/dist/cjs/components/PluginRegistry/test-plugins/bert/index.js +22 -12
  7. package/dist/cjs/components/PluginRegistry/test-plugins/ernie/index.js +20 -8
  8. package/dist/cjs/components/PluginRegistry/test-plugins/index.js +59 -39
  9. package/dist/cjs/components/index.js +17 -20
  10. package/dist/cjs/index.js +19 -20
  11. package/dist/cjs/model/datasource.js +16 -0
  12. package/dist/cjs/model/index.js +21 -21
  13. package/dist/cjs/model/panels.js +4 -21
  14. package/dist/cjs/model/plugins.js +4 -7
  15. package/dist/cjs/model/time-series-queries.js +16 -0
  16. package/dist/cjs/model/variables.js +5 -17
  17. package/dist/cjs/model/visual-editing.js +10 -2
  18. package/dist/cjs/runtime/datasources.js +20 -13
  19. package/dist/cjs/runtime/index.js +22 -21
  20. package/dist/cjs/runtime/plugins.js +25 -22
  21. package/dist/cjs/runtime/query-string.js +17 -10
  22. package/dist/cjs/runtime/template-variables.js +34 -16
  23. package/dist/cjs/runtime/time-range.js +17 -10
  24. package/dist/cjs/runtime/time-series-queries.js +58 -0
  25. package/dist/cjs/test/render.js +32 -13
  26. package/dist/cjs/test/setup-tests.js +4 -10
  27. package/dist/cjs/utils/cache-keys.js +8 -7
  28. package/dist/components/PluginRegistry/PluginRegistry.js +81 -1
  29. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
  30. package/dist/components/PluginRegistry/PluginRegistry.test.js +142 -1
  31. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -0
  32. package/dist/components/PluginRegistry/index.js +16 -1
  33. package/dist/components/PluginRegistry/index.js.map +1 -0
  34. package/dist/components/PluginRegistry/plugin-indexes.js +66 -1
  35. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
  36. package/dist/components/PluginRegistry/plugin-registry-model.d.ts +1 -2
  37. package/dist/components/PluginRegistry/plugin-registry-model.d.ts.map +1 -1
  38. package/dist/components/PluginRegistry/plugin-registry-model.js +23 -1
  39. package/dist/components/PluginRegistry/plugin-registry-model.js.map +1 -0
  40. package/dist/components/PluginRegistry/test-plugins/bert/index.js +25 -1
  41. package/dist/components/PluginRegistry/test-plugins/bert/index.js.map +1 -0
  42. package/dist/components/PluginRegistry/test-plugins/ernie/index.d.ts.map +1 -1
  43. package/dist/components/PluginRegistry/test-plugins/ernie/index.js +30 -1
  44. package/dist/components/PluginRegistry/test-plugins/ernie/index.js.map +1 -0
  45. package/dist/components/PluginRegistry/test-plugins/index.js +35 -1
  46. package/dist/components/PluginRegistry/test-plugins/index.js.map +1 -0
  47. package/dist/components/index.d.ts +1 -3
  48. package/dist/components/index.d.ts.map +1 -1
  49. package/dist/components/index.js +15 -1
  50. package/dist/components/index.js.map +1 -0
  51. package/dist/index.js +17 -1
  52. package/dist/index.js.map +1 -0
  53. package/dist/model/datasource.d.ts +9 -0
  54. package/dist/model/datasource.d.ts.map +1 -0
  55. package/dist/model/datasource.js +15 -0
  56. package/dist/model/datasource.js.map +1 -0
  57. package/dist/model/index.d.ts +2 -1
  58. package/dist/model/index.d.ts.map +1 -1
  59. package/dist/model/index.js +20 -1
  60. package/dist/model/index.js.map +1 -0
  61. package/dist/model/panels.d.ts +7 -11
  62. package/dist/model/panels.d.ts.map +1 -1
  63. package/dist/model/panels.js +15 -1
  64. package/dist/model/panels.js.map +1 -0
  65. package/dist/model/plugins.d.ts +16 -25
  66. package/dist/model/plugins.d.ts.map +1 -1
  67. package/dist/model/plugins.js +15 -1
  68. package/dist/model/plugins.js.map +1 -0
  69. package/dist/model/time-series-queries.d.ts +28 -0
  70. package/dist/model/time-series-queries.d.ts.map +1 -0
  71. package/dist/model/time-series-queries.js +15 -0
  72. package/dist/model/time-series-queries.js.map +1 -0
  73. package/dist/model/variables.d.ts +16 -11
  74. package/dist/model/variables.d.ts.map +1 -1
  75. package/dist/model/variables.js +15 -1
  76. package/dist/model/variables.js.map +1 -0
  77. package/dist/model/visual-editing.d.ts +5 -6
  78. package/dist/model/visual-editing.d.ts.map +1 -1
  79. package/dist/model/visual-editing.js +15 -1
  80. package/dist/model/visual-editing.js.map +1 -0
  81. package/dist/runtime/datasources.d.ts +5 -9
  82. package/dist/runtime/datasources.d.ts.map +1 -1
  83. package/dist/runtime/datasources.js +23 -1
  84. package/dist/runtime/datasources.js.map +1 -0
  85. package/dist/runtime/index.d.ts +3 -1
  86. package/dist/runtime/index.d.ts.map +1 -1
  87. package/dist/runtime/index.js +20 -1
  88. package/dist/runtime/index.js.map +1 -0
  89. package/dist/runtime/plugins.d.ts +5 -14
  90. package/dist/runtime/plugins.d.ts.map +1 -1
  91. package/dist/runtime/plugins.js +33 -1
  92. package/dist/runtime/plugins.js.map +1 -0
  93. package/dist/runtime/query-string.js +25 -1
  94. package/dist/runtime/query-string.js.map +1 -0
  95. package/dist/runtime/template-variables.d.ts +10 -1
  96. package/dist/runtime/template-variables.d.ts.map +1 -1
  97. package/dist/runtime/template-variables.js +44 -1
  98. package/dist/runtime/template-variables.js.map +1 -0
  99. package/dist/runtime/time-range.js +25 -1
  100. package/dist/runtime/time-range.js.map +1 -0
  101. package/dist/runtime/time-series-queries.d.ts +14 -0
  102. package/dist/runtime/time-series-queries.d.ts.map +1 -0
  103. package/dist/runtime/time-series-queries.js +54 -0
  104. package/dist/runtime/time-series-queries.js.map +1 -0
  105. package/dist/test/render.d.ts.map +1 -1
  106. package/dist/test/render.js +42 -1
  107. package/dist/test/render.js.map +1 -0
  108. package/dist/test/setup-tests.d.ts.map +1 -1
  109. package/dist/test/setup-tests.js +16 -1
  110. package/dist/test/setup-tests.js.map +1 -0
  111. package/dist/utils/cache-keys.js +19 -1
  112. package/dist/utils/cache-keys.js.map +1 -0
  113. package/package.json +11 -8
  114. package/dist/cjs/components/PluginBoundary.js +0 -14
  115. package/dist/cjs/components/PluginLoadingBoundary/PluginLoader.js +0 -39
  116. package/dist/cjs/components/PluginLoadingBoundary/PluginLoadingBoundary.js +0 -85
  117. package/dist/cjs/components/PluginLoadingBoundary/index.js +0 -29
  118. package/dist/cjs/components/PluginRegistry/legacy/PluginRegistry.js +0 -57
  119. package/dist/cjs/components/PluginRegistry/legacy/index.js +0 -29
  120. package/dist/cjs/components/PluginRegistry/legacy/registry-state.js +0 -97
  121. package/dist/cjs/components/PluginRegistry/test-plugins/bert/plugin.json +0 -32
  122. package/dist/cjs/components/PluginRegistry/test-plugins/ernie/plugin.json +0 -24
  123. package/dist/cjs/model/graph-queries.js +0 -28
  124. package/dist/components/PluginBoundary.d.ts +0 -13
  125. package/dist/components/PluginBoundary.d.ts.map +0 -1
  126. package/dist/components/PluginBoundary.js +0 -1
  127. package/dist/components/PluginLoadingBoundary/PluginLoader.d.ts +0 -11
  128. package/dist/components/PluginLoadingBoundary/PluginLoader.d.ts.map +0 -1
  129. package/dist/components/PluginLoadingBoundary/PluginLoader.js +0 -1
  130. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts +0 -27
  131. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts.map +0 -1
  132. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.js +0 -1
  133. package/dist/components/PluginLoadingBoundary/index.d.ts +0 -2
  134. package/dist/components/PluginLoadingBoundary/index.d.ts.map +0 -1
  135. package/dist/components/PluginLoadingBoundary/index.js +0 -1
  136. package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts +0 -29
  137. package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts.map +0 -1
  138. package/dist/components/PluginRegistry/legacy/PluginRegistry.js +0 -1
  139. package/dist/components/PluginRegistry/legacy/index.d.ts +0 -2
  140. package/dist/components/PluginRegistry/legacy/index.d.ts.map +0 -1
  141. package/dist/components/PluginRegistry/legacy/index.js +0 -1
  142. package/dist/components/PluginRegistry/legacy/registry-state.d.ts +0 -18
  143. package/dist/components/PluginRegistry/legacy/registry-state.d.ts.map +0 -1
  144. package/dist/components/PluginRegistry/legacy/registry-state.js +0 -1
  145. package/dist/components/PluginRegistry/test-plugins/bert/plugin.json +0 -32
  146. package/dist/components/PluginRegistry/test-plugins/ernie/plugin.json +0 -24
  147. package/dist/model/graph-queries.d.ts +0 -36
  148. package/dist/model/graph-queries.d.ts.map +0 -1
  149. package/dist/model/graph-queries.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGtF;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU;IACrE,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,oBAAY,sBAAsB,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI,CAC5E,UAAU,EAAE,sBAAsB,CAAC,OAAO,CAAC,KACxC;IACH,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,oBAAoB,CAOnE,CAAC"}
1
+ {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,oBAAY,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,OAAO;IAC5C,kBAAkB,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAE7C,2FAA2F;IAC3F,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;CAC5C;AAED;;;GAGG;AACH,oBAAY,kBAAkB,CAAC,IAAI,IAAI,CACrC,UAAU,EAAE,IAAI,EAChB,GAAG,EAAE,yBAAyB,KAC3B,OAAO,CAAC;IAAE,IAAI,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,CAAC"}
@@ -1 +1,15 @@
1
- import{usePlugin}from"../components/PluginLoadingBoundary";export const useVariableOptions=n=>{const i=usePlugin("Variable",n.kind);return void 0===i?{data:[],loading:!0}:i.useVariableOptions(n)};
1
+ // Copyright 2022 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=variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/variables.ts"],"sourcesContent":["// Copyright 2022 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 { VariableStateMap } from '../runtime';\nimport { DatasourceStore } from '../runtime';\n\nexport type VariableOption = { label: string; value: string };\n\nexport interface GetVariableOptionsContext {\n variables: VariableStateMap;\n datasourceStore: DatasourceStore;\n}\n\n/**\n * Plugin for handling custom VariableDefinitions.\n */\nexport interface VariablePlugin<Spec = unknown> {\n getVariableOptions: GetVariableOptions<Spec>;\n\n /** Returns a list of variables name this variable depends on. Used to optimize fetching */\n dependsOn?: (definition: Spec) => string[];\n}\n\n/**\n * Plugin hook responsible for getting the options of a custom variable\n * definition.\n */\nexport type GetVariableOptions<Spec> = (\n definition: Spec,\n ctx: GetVariableOptionsContext\n) => Promise<{ data: VariableOption[] }>;\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,WA2ByC"}
@@ -1,18 +1,17 @@
1
- import { JsonObject } from '@perses-dev/core';
2
1
  import React from 'react';
3
2
  /**
4
3
  * A component for visual editing of a plugin's options.
5
4
  */
6
- export declare type OptionsEditor<Options extends JsonObject = JsonObject> = React.ComponentType<OptionsEditorProps<Options>>;
5
+ export declare type OptionsEditor<Spec> = React.ComponentType<OptionsEditorProps<Spec>>;
7
6
  /**
8
7
  * Common props passed to options editor components.
9
8
  */
10
- export interface OptionsEditorProps<Options extends JsonObject = JsonObject> {
11
- value: Options;
12
- onChange: (next: Options) => void;
9
+ export interface OptionsEditorProps<Spec> {
10
+ value: Spec;
11
+ onChange: (next: Spec) => void;
13
12
  }
14
13
  /**
15
14
  * Callback for creating initial/empty options for a plugin.
16
15
  */
17
- export declare type InitialOptionsCallback<Options extends JsonObject> = () => Options;
16
+ export declare type InitialOptionsCallback<Spec> = () => Spec;
18
17
  //# sourceMappingURL=visual-editing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"visual-editing.d.ts","sourceRoot":"","sources":["../../src/model/visual-editing.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,oBAAY,aAAa,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEtH;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU;IAGzE,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,oBAAY,sBAAsB,CAAC,OAAO,SAAS,UAAU,IAAI,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"visual-editing.d.ts","sourceRoot":"","sources":["../../src/model/visual-editing.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,oBAAY,aAAa,CAAC,IAAI,IAAI,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI;IAGtC,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,oBAAY,sBAAsB,CAAC,IAAI,IAAI,MAAM,IAAI,CAAC"}
@@ -1 +1,15 @@
1
- export{};
1
+ // Copyright 2022 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 React from 'react';
14
+
15
+ //# sourceMappingURL=visual-editing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/visual-editing.ts"],"sourcesContent":["// Copyright 2022 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 React from 'react';\n\n/**\n * A component for visual editing of a plugin's options.\n */\nexport type OptionsEditor<Spec> = React.ComponentType<OptionsEditorProps<Spec>>;\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}\n\n/**\n * Callback for creating initial/empty options for a plugin.\n */\nexport type InitialOptionsCallback<Spec> = () => Spec;\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;AAEjC,OAAOA,KAAK,MAAM,OAAO,CAAC"}
@@ -1,12 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { DatasourceSelector, GlobalDatasourceModel } from '@perses-dev/core';
3
- export interface Datasources {
4
- defaultDatasource: GlobalDatasourceModel;
5
- getDatasources(selector: DatasourceSelector): GlobalDatasourceModel[];
2
+ import { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';
3
+ export interface DatasourceStore {
4
+ getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;
6
5
  }
7
- export declare const DatasourcesContext: import("react").Context<Datasources | undefined>;
8
- /**
9
- * Gets the Datasources at runtime.
10
- */
11
- export declare function useDatasources(): Datasources;
6
+ export declare const DatasourceStoreContext: import("react").Context<DatasourceStore | undefined>;
7
+ export declare function useDatasourceStore(): DatasourceStore;
12
8
  //# sourceMappingURL=datasources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,MAAM,WAAW,WAAW;IAC1B,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,cAAc,CAAC,QAAQ,EAAE,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;CACvE;AAED,eAAO,MAAM,kBAAkB,kDAAoD,CAAC;AAEpF;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAM5C"}
1
+ {"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGtE,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtE;AAED,eAAO,MAAM,sBAAsB,sDAAwD,CAAC;AAE5F,wBAAgB,kBAAkB,oBAMjC"}
@@ -1 +1,23 @@
1
- import{createContext,useContext}from"react";export const DatasourcesContext=createContext(void 0);export function useDatasources(){const t=useContext(DatasourcesContext);if(void 0===t)throw new Error("No DatasourcesContext found. Did you forget a Provider?");return t}
1
+ // Copyright 2022 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 { createContext, useContext } from 'react';
14
+ export const DatasourceStoreContext = createContext(undefined);
15
+ export function useDatasourceStore() {
16
+ const ctx = useContext(DatasourceStoreContext);
17
+ if (ctx === undefined) {
18
+ throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');
19
+ }
20
+ return ctx;
21
+ }
22
+
23
+ //# sourceMappingURL=datasources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/datasources.ts"],"sourcesContent":["// Copyright 2022 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 { createContext, useContext } from 'react';\n\nexport interface DatasourceStore {\n getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;\n}\n\nexport const DatasourceStoreContext = createContext<DatasourceStore | undefined>(undefined);\n\nexport function useDatasourceStore() {\n const ctx = useContext(DatasourceStoreContext);\n if (ctx === undefined) {\n throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n"],"names":["createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","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;AAGjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAMlD,OAAO,MAAMC,sBAAsB,GAAGF,aAAa,CAA8BG,SAAS,CAAC,CAAC;AAE5F,OAAO,SAASC,kBAAkB,GAAG;IACnC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,sBAAsB,CAAC,AAAC;IAC/C,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC"}
@@ -1,5 +1,7 @@
1
1
  export * from './datasources';
2
+ export * from './time-series-queries';
3
+ export * from './plugins';
4
+ export * from './query-string';
2
5
  export * from './template-variables';
3
6
  export * from './time-range';
4
- export * from './query-string';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
@@ -1 +1,20 @@
1
- export*from"./datasources";export*from"./template-variables";export*from"./time-range";export*from"./query-string";
1
+ // Copyright 2022 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 './datasources';
14
+ export * from './time-series-queries';
15
+ export * from './plugins';
16
+ export * from './query-string';
17
+ export * from './template-variables';
18
+ export * from './time-range';
19
+
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/index.ts"],"sourcesContent":["// Copyright 2022 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 './datasources';\nexport * from './time-series-queries';\nexport * from './plugins';\nexport * from './query-string';\nexport * from './template-variables';\nexport * from './time-range';\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,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
@@ -1,23 +1,14 @@
1
- import { JsonObject } from '@perses-dev/core';
2
- import { UseQueryOptions } from 'react-query';
1
+ import { UseQueryOptions } from '@tanstack/react-query';
3
2
  import { PluginImplementation, PluginMetadata, PluginType } from '../model';
4
- declare type UsePluginOptions<T extends PluginType> = Omit<UseQueryOptions<PluginImplementation<T, JsonObject>, unknown, PluginImplementation<T, JsonObject>, string>, 'queryKey' | 'queryFn'>;
3
+ declare type UsePluginOptions<T extends PluginType> = Omit<UseQueryOptions<PluginImplementation<T>, unknown, PluginImplementation<T>, [string, string]>, 'queryKey' | 'queryFn'>;
5
4
  /**
6
5
  * Loads a plugin and returns the plugin implementation, along with loading/error state.
7
6
  */
8
- export declare function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>): {
9
- plugin: PluginImplementation<T, JsonObject> | undefined;
10
- isLoading: boolean;
11
- error: unknown;
12
- };
13
- declare type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], unknown, PluginMetadata[], string>, 'queryKey' | 'queryFn'>;
7
+ export declare function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, unknown>;
8
+ declare type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], unknown, PluginMetadata[], [string]>, 'queryKey' | 'queryFn'>;
14
9
  /**
15
10
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
16
11
  */
17
- export declare function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions): {
18
- pluginMetadata: PluginMetadata[] | undefined;
19
- isLoading: boolean;
20
- error: unknown;
21
- };
12
+ export declare function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions): import("@tanstack/react-query").UseQueryResult<PluginMetadata[], unknown>;
22
13
  export {};
23
14
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/runtime/plugins.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAY,eAAe,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI5E,aAAK,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,IAAI,CAChD,eAAe,CAAC,oBAAoB,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,EAC1G,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;;;;EAKzG;AAGD,aAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,MAAM,CAAC,EACpE,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,4BAA4B;;;;EAKnG"}
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/runtime/plugins.ts"],"names":[],"mappings":"AAaA,OAAO,EAAY,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG5E,aAAK,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,IAAI,CAChD,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC5F,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,oFAGzG;AAGD,aAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EACtE,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,4BAA4B,6EAGnG"}
@@ -1 +1,33 @@
1
- import{useQuery}from"react-query";import{usePluginRegistry}from"../components/PluginRegistry";import{getTypeAndKindKey}from"../utils/cache-keys";export function usePlugin(e,r,i){const{getPlugin:t}=usePluginRegistry(),n=getTypeAndKindKey(e,r),{data:u,isLoading:s,error:o}=useQuery(n,(()=>t(e,r)),i);return{plugin:u,isLoading:s,error:o}}export function useListPluginMetadata(e,r){const{listPluginMetadata:i}=usePluginRegistry(),t=e,{data:n,isLoading:u,error:s}=useQuery(t,(()=>i(e)),r);return{pluginMetadata:n,isLoading:u,error:s}}
1
+ // Copyright 2022 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 { useQuery } from '@tanstack/react-query';
14
+ import { usePluginRegistry } from '../components/PluginRegistry';
15
+ /**
16
+ * Loads a plugin and returns the plugin implementation, along with loading/error state.
17
+ */ export function usePlugin(pluginType, kind, options) {
18
+ const { getPlugin } = usePluginRegistry();
19
+ return useQuery([
20
+ pluginType,
21
+ kind
22
+ ], ()=>getPlugin(pluginType, kind), options);
23
+ }
24
+ /**
25
+ * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
26
+ */ export function useListPluginMetadata(pluginType, options) {
27
+ const { listPluginMetadata } = usePluginRegistry();
28
+ return useQuery([
29
+ pluginType
30
+ ], ()=>listPluginMetadata(pluginType), options);
31
+ }
32
+
33
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/plugins.ts"],"sourcesContent":["// Copyright 2022 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, UseQueryOptions } from '@tanstack/react-query';\nimport { usePluginRegistry } from '../components/PluginRegistry';\nimport { PluginImplementation, PluginMetadata, PluginType } from '../model';\n\n// Allows consumers to pass useQuery options from react-query when loading a plugin\ntype UsePluginOptions<T extends PluginType> = Omit<\n UseQueryOptions<PluginImplementation<T>, unknown, PluginImplementation<T>, [string, string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Loads a plugin and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>) {\n const { getPlugin } = usePluginRegistry();\n return useQuery([pluginType, kind], () => getPlugin(pluginType, kind), options);\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], unknown, PluginMetadata[], [string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.\n */\nexport function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions) {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery([pluginType], () => listPluginMetadata(pluginType), options);\n}\n"],"names":["useQuery","usePluginRegistry","usePlugin","pluginType","kind","options","getPlugin","useListPluginMetadata","listPluginMetadata"],"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,QAAyB,uBAAuB,CAAC;AAClE,SAASC,iBAAiB,QAAQ,8BAA8B,CAAC;AASjE;;CAEC,GACD,OAAO,SAASC,SAAS,CAAuBC,UAAa,EAAEC,IAAY,EAAEC,OAA6B,EAAE;IAC1G,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGL,iBAAiB,EAAE,AAAC;IAC1C,OAAOD,QAAQ,CAAC;QAACG,UAAU;QAAEC,IAAI;KAAC,EAAE,IAAME,SAAS,CAACH,UAAU,EAAEC,IAAI,CAAC,EAAEC,OAAO,CAAC,CAAC;AAClF,CAAC;AAQD;;CAEC,GACD,OAAO,SAASE,qBAAqB,CAACJ,UAAsB,EAAEE,OAAsC,EAAE;IACpG,MAAM,EAAEG,kBAAkB,CAAA,EAAE,GAAGP,iBAAiB,EAAE,AAAC;IACnD,OAAOD,QAAQ,CAAC;QAACG,UAAU;KAAC,EAAE,IAAMK,kBAAkB,CAACL,UAAU,CAAC,EAAEE,OAAO,CAAC,CAAC;AAC/E,CAAC"}
@@ -1 +1,25 @@
1
- import{createContext,useContext}from"react";export const QueryStringContext=createContext(void 0);export function useQueryString(){const t=useContext(QueryStringContext);if(void 0===t)throw new Error("No QueryStringContext found. Did you forget a Provider?");return t}
1
+ // Copyright 2022 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 { createContext, useContext } from 'react';
14
+ export const QueryStringContext = /*#__PURE__*/ createContext(undefined);
15
+ /**
16
+ * Gets the current query params at runtime.
17
+ */ export function useQueryString() {
18
+ const ctx = useContext(QueryStringContext);
19
+ if (ctx === undefined) {
20
+ throw new Error('No QueryStringContext found. Did you forget a Provider?');
21
+ }
22
+ return ctx;
23
+ }
24
+
25
+ //# sourceMappingURL=query-string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/query-string.tsx"],"sourcesContent":["// Copyright 2022 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, useContext } from 'react';\n\nexport interface QueryString {\n queryString: URLSearchParams;\n setQueryString?: (queryString: URLSearchParams) => void;\n}\n\nexport const QueryStringContext = createContext<QueryString | undefined>(undefined);\n\n/**\n * Gets the current query params at runtime.\n */\nexport function useQueryString(): QueryString {\n const ctx = useContext(QueryStringContext);\n if (ctx === undefined) {\n throw new Error('No QueryStringContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n"],"names":["createContext","useContext","QueryStringContext","undefined","useQueryString","ctx","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;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAOlD,OAAO,MAAMC,kBAAkB,iBAAGF,aAAa,CAA0BG,SAAS,CAAC,CAAC;AAEpF;;CAEC,GACD,OAAO,SAASC,cAAc,GAAgB;IAC5C,MAAMC,GAAG,GAAGJ,UAAU,CAACC,kBAAkB,CAAC,AAAC;IAC3C,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC"}
@@ -1,5 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { VariableStateMap } from '@perses-dev/core';
2
+ import { VariableName, VariableValue } from '@perses-dev/core';
3
+ import { VariableOption } from '../model';
4
+ export declare const DEFAULT_ALL_VALUE: "$__all";
5
+ export declare type VariableState = {
6
+ value: VariableValue;
7
+ options?: VariableOption[];
8
+ loading: boolean;
9
+ error?: Error;
10
+ };
11
+ export declare type VariableStateMap = Record<VariableName, VariableState>;
3
12
  export declare type TemplateVariableSrv = {
4
13
  state: VariableStateMap;
5
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"template-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/template-variables.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,oBAAY,mBAAmB,GAAG;IAChC,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,uBAAuB,0DAA4D,CAAC;AAUjG,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,oBAgBzD"}
1
+ {"version":3,"file":"template-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/template-variables.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,iBAAiB,UAAoB,CAAC;AAEnD,oBAAY,aAAa,GAAG;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,oBAAY,gBAAgB,GAAG,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEnE,oBAAY,mBAAmB,GAAG;IAChC,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,uBAAuB,0DAA4D,CAAC;AAUjG,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,oBAmBzD"}
@@ -1 +1,44 @@
1
- import{createContext,useContext}from"react";export const TemplateVariableContext=createContext(void 0);function useTemplateVariableContext(){const e=useContext(TemplateVariableContext);if(void 0===e)throw new Error("No TemplateVariableContext found. Did you forget a Provider?");return e}export function useTemplateVariableValues(e){const{state:t}=useTemplateVariableContext();if(void 0===e)return t;const o={};return e.forEach((e=>{const r=t[e];r&&(o[e]=r)})),o}
1
+ // Copyright 2022 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 { createContext, useContext, useMemo } from 'react';
14
+ export const DEFAULT_ALL_VALUE = '$__all';
15
+ export const TemplateVariableContext = createContext(undefined);
16
+ function useTemplateVariableContext() {
17
+ const ctx = useContext(TemplateVariableContext);
18
+ if (ctx === undefined) {
19
+ throw new Error('No TemplateVariableContext found. Did you forget a Provider?');
20
+ }
21
+ return ctx;
22
+ }
23
+ export function useTemplateVariableValues(names) {
24
+ const { state } = useTemplateVariableContext();
25
+ const values = useMemo(()=>{
26
+ const values = {};
27
+ names === null || names === void 0 ? void 0 : names.forEach((name)=>{
28
+ const s = state[name];
29
+ if (s) {
30
+ values[name] = s;
31
+ }
32
+ });
33
+ return values;
34
+ }, [
35
+ state,
36
+ names
37
+ ]);
38
+ if (names === undefined) {
39
+ return state;
40
+ }
41
+ return values;
42
+ }
43
+
44
+ //# sourceMappingURL=template-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/template-variables.ts"],"sourcesContent":["// Copyright 2022 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, useContext, useMemo } from 'react';\nimport { VariableName, VariableValue } from '@perses-dev/core';\nimport { VariableOption } from '../model';\n\nexport const DEFAULT_ALL_VALUE = '$__all' as const;\n\nexport type VariableState = {\n value: VariableValue;\n options?: VariableOption[];\n loading: boolean;\n error?: Error;\n};\n\nexport type VariableStateMap = Record<VariableName, VariableState>;\n\nexport type TemplateVariableSrv = {\n state: VariableStateMap;\n};\n\nexport const TemplateVariableContext = createContext<TemplateVariableSrv | undefined>(undefined);\n\nfunction useTemplateVariableContext() {\n const ctx = useContext(TemplateVariableContext);\n if (ctx === undefined) {\n throw new Error('No TemplateVariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useTemplateVariableValues(names?: string[]) {\n const { state } = useTemplateVariableContext();\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = state[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [state, names]);\n\n if (names === undefined) {\n return state;\n }\n\n return values;\n}\n"],"names":["createContext","useContext","useMemo","DEFAULT_ALL_VALUE","TemplateVariableContext","undefined","useTemplateVariableContext","ctx","Error","useTemplateVariableValues","names","state","values","forEach","name","s"],"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,UAAU,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAI3D,OAAO,MAAMC,iBAAiB,GAAG,QAAQ,AAAS,CAAC;AAenD,OAAO,MAAMC,uBAAuB,GAAGJ,aAAa,CAAkCK,SAAS,CAAC,CAAC;AAEjG,SAASC,0BAA0B,GAAG;IACpC,MAAMC,GAAG,GAAGN,UAAU,CAACG,uBAAuB,CAAC,AAAC;IAChD,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED,OAAO,SAASE,yBAAyB,CAACC,KAAgB,EAAE;IAC1D,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGL,0BAA0B,EAAE,AAAC;IAE/C,MAAMM,MAAM,GAAGV,OAAO,CAAC,IAAM;QAC3B,MAAMU,MAAM,GAAqB,EAAE,AAAC;QACpCF,KAAK,aAALA,KAAK,WAAS,GAAdA,KAAAA,CAAc,GAAdA,KAAK,CAAEG,OAAO,CAAC,CAACC,IAAI,GAAK;YACvB,MAAMC,CAAC,GAAGJ,KAAK,CAACG,IAAI,CAAC,AAAC;YACtB,IAAIC,CAAC,EAAE;gBACLH,MAAM,CAACE,IAAI,CAAC,GAAGC,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAOH,MAAM,CAAC;IAChB,CAAC,EAAE;QAACD,KAAK;QAAED,KAAK;KAAC,CAAC,AAAC;IAEnB,IAAIA,KAAK,KAAKL,SAAS,EAAE;QACvB,OAAOM,KAAK,CAAC;IACf,CAAC;IAED,OAAOC,MAAM,CAAC;AAChB,CAAC"}
@@ -1 +1,25 @@
1
- import{createContext,useContext}from"react";export const TimeRangeContext=createContext(void 0);export function useTimeRange(){const e=useContext(TimeRangeContext);if(void 0===e)throw new Error("No TimeRangeContext found. Did you forget a Provider?");return e}
1
+ // Copyright 2022 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 { createContext, useContext } from 'react';
14
+ export const TimeRangeContext = createContext(undefined);
15
+ /**
16
+ * Gets the current TimeRange at runtime.
17
+ */ export function useTimeRange() {
18
+ const ctx = useContext(TimeRangeContext);
19
+ if (ctx === undefined) {
20
+ throw new Error('No TimeRangeContext found. Did you forget a Provider?');
21
+ }
22
+ return ctx;
23
+ }
24
+
25
+ //# sourceMappingURL=time-range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/time-range.ts"],"sourcesContent":["// Copyright 2022 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, useContext } from 'react';\nimport { AbsoluteTimeRange, TimeRangeValue } from '@perses-dev/core';\n\nexport interface TimeRange {\n timeRange: AbsoluteTimeRange;\n setTimeRange: (value: TimeRangeValue) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\n/**\n * Gets the current TimeRange at runtime.\n */\nexport function useTimeRange(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n"],"names":["createContext","useContext","TimeRangeContext","undefined","useTimeRange","ctx","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;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAQlD,OAAO,MAAMC,gBAAgB,GAAGF,aAAa,CAAwBG,SAAS,CAAC,CAAC;AAEhF;;CAEC,GACD,OAAO,SAASC,YAAY,GAAc;IACxC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,gBAAgB,CAAC,AAAC;IACzC,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TimeSeriesQueryDefinition } from '@perses-dev/core';
2
+ declare type UseTimeSeriesQueryOptions = {
3
+ suggestedStepMs?: number;
4
+ };
5
+ /**
6
+ * Runs a Graph Query using a plugin and returns the results.
7
+ */
8
+ export declare const useTimeSeriesQueryData: (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions) => {
9
+ data: import("../model").TimeSeriesData | undefined;
10
+ loading: boolean;
11
+ error: unknown;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=time-series-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAQ7D,aAAK,yBAAyB,GAAG;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,eAAgB,yBAAyB,YAAY,yBAAyB;;;;CA+BhH,CAAC"}
@@ -0,0 +1,54 @@
1
+ // Copyright 2022 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 { useQuery } from '@tanstack/react-query';
14
+ import { useTemplateVariableValues } from './template-variables';
15
+ import { useTimeRange } from './time-range';
16
+ import { usePlugin } from './plugins';
17
+ import { useDatasourceStore } from './datasources';
18
+ /**
19
+ * Runs a Graph Query using a plugin and returns the results.
20
+ */ export const useTimeSeriesQueryData = (definition, options)=>{
21
+ const { data: plugin } = usePlugin('TimeSeriesQuery', definition.spec.plugin.kind);
22
+ // Build the context object from data available at runtime
23
+ const { timeRange } = useTimeRange();
24
+ const variableState = useTemplateVariableValues();
25
+ const datasourceStore = useDatasourceStore();
26
+ const context = {
27
+ suggestedStepMs: options === null || options === void 0 ? void 0 : options.suggestedStepMs,
28
+ timeRange,
29
+ variableState,
30
+ datasourceStore
31
+ };
32
+ const key = [
33
+ definition,
34
+ context
35
+ ];
36
+ const { data , isLoading , error } = useQuery(key, ({ queryKey })=>{
37
+ // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking
38
+ if (plugin === undefined) {
39
+ throw new Error('Expected plugin to be loaded');
40
+ }
41
+ const [definition, context] = queryKey;
42
+ return plugin.getTimeSeriesData(definition.spec.plugin.spec, context);
43
+ }, {
44
+ enabled: plugin !== undefined
45
+ });
46
+ // TODO: Stop aliasing fields, just return the hook results directly once we clean up query running in panels
47
+ return {
48
+ data,
49
+ loading: isLoading,
50
+ error: error !== null && error !== void 0 ? error : undefined
51
+ };
52
+ };
53
+
54
+ //# sourceMappingURL=time-series-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright 2022 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 { TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { TimeSeriesQueryContext } from '../model';\nimport { useTemplateVariableValues } from './template-variables';\nimport { useTimeRange } from './time-range';\nimport { usePlugin } from './plugins';\nimport { useDatasourceStore } from './datasources';\n\ntype UseTimeSeriesQueryOptions = {\n suggestedStepMs?: number;\n};\n\n/**\n * Runs a Graph Query using a plugin and returns the results.\n */\nexport const useTimeSeriesQueryData = (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions) => {\n const { data: plugin } = usePlugin('TimeSeriesQuery', definition.spec.plugin.kind);\n\n // Build the context object from data available at runtime\n const { timeRange } = useTimeRange();\n const variableState = useTemplateVariableValues();\n const datasourceStore = useDatasourceStore();\n\n const context: TimeSeriesQueryContext = {\n suggestedStepMs: options?.suggestedStepMs,\n timeRange,\n variableState,\n datasourceStore,\n };\n\n const key = [definition, context] as const;\n const { data, isLoading, error } = useQuery(\n key,\n ({ queryKey }) => {\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 const [definition, context] = queryKey;\n return plugin.getTimeSeriesData(definition.spec.plugin.spec, context);\n },\n { enabled: plugin !== undefined }\n );\n\n // TODO: Stop aliasing fields, just return the hook results directly once we clean up query running in panels\n return { data, loading: isLoading, error: error ?? undefined };\n};\n"],"names":["useQuery","useTemplateVariableValues","useTimeRange","usePlugin","useDatasourceStore","useTimeSeriesQueryData","definition","options","data","plugin","spec","kind","timeRange","variableState","datasourceStore","context","suggestedStepMs","key","isLoading","error","queryKey","undefined","Error","getTimeSeriesData","enabled","loading"],"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,QAAQ,QAAQ,uBAAuB,CAAC;AAEjD,SAASC,yBAAyB,QAAQ,sBAAsB,CAAC;AACjE,SAASC,YAAY,QAAQ,cAAc,CAAC;AAC5C,SAASC,SAAS,QAAQ,WAAW,CAAC;AACtC,SAASC,kBAAkB,QAAQ,eAAe,CAAC;AAMnD;;CAEC,GACD,OAAO,MAAMC,sBAAsB,GAAG,CAACC,UAAqC,EAAEC,OAAmC,GAAK;IACpH,MAAM,EAAEC,IAAI,EAAEC,MAAM,CAAA,EAAE,GAAGN,SAAS,CAAC,iBAAiB,EAAEG,UAAU,CAACI,IAAI,CAACD,MAAM,CAACE,IAAI,CAAC,AAAC;IAEnF,0DAA0D;IAC1D,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGV,YAAY,EAAE,AAAC;IACrC,MAAMW,aAAa,GAAGZ,yBAAyB,EAAE,AAAC;IAClD,MAAMa,eAAe,GAAGV,kBAAkB,EAAE,AAAC;IAE7C,MAAMW,OAAO,GAA2B;QACtCC,eAAe,EAAET,OAAO,aAAPA,OAAO,WAAiB,GAAxBA,KAAAA,CAAwB,GAAxBA,OAAO,CAAES,eAAe;QACzCJ,SAAS;QACTC,aAAa;QACbC,eAAe;KAChB,AAAC;IAEF,MAAMG,GAAG,GAAG;QAACX,UAAU;QAAES,OAAO;KAAC,AAAS,AAAC;IAC3C,MAAM,EAAEP,IAAI,CAAA,EAAEU,SAAS,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGnB,QAAQ,CACzCiB,GAAG,EACH,CAAC,EAAEG,QAAQ,CAAA,EAAE,GAAK;QAChB,iGAAiG;QACjG,IAAIX,MAAM,KAAKY,SAAS,EAAE;YACxB,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,CAAChB,UAAU,EAAES,OAAO,CAAC,GAAGK,QAAQ,AAAC;QACvC,OAAOX,MAAM,CAACc,iBAAiB,CAACjB,UAAU,CAACI,IAAI,CAACD,MAAM,CAACC,IAAI,EAAEK,OAAO,CAAC,CAAC;IACxE,CAAC,EACD;QAAES,OAAO,EAAEf,MAAM,KAAKY,SAAS;KAAE,CAClC,AAAC;IAEF,6GAA6G;IAC7G,OAAO;QAAEb,IAAI;QAAEiB,OAAO,EAAEP,SAAS;QAAEC,KAAK,EAAEA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAIE,SAAS;KAAE,CAAC;AACjE,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAM/D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,gIAEjG"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW/D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,gIAOjG"}
@@ -1 +1,42 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{render}from"@testing-library/react";import{QueryClient,QueryClientProvider}from"react-query";const queryClient=new QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:!1}}});export function renderWithContext(e,r){return render(_jsx(QueryClientProvider,{client:queryClient,children:e}),r)}
1
+ // Copyright 2022 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 { render } from '@testing-library/react';
15
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
16
+ const testLogger = {
17
+ log: console.log,
18
+ warn: console.warn,
19
+ error: ()=>{
20
+ // Don't log network errors in tests to the console
21
+ }
22
+ };
23
+ /**
24
+ * Test helper to render a React component with some common app-level providers wrapped around it.
25
+ */ export function renderWithContext(ui, options) {
26
+ // Create a new QueryClient for each test to avoid caching issues
27
+ const queryClient = new QueryClient({
28
+ defaultOptions: {
29
+ queries: {
30
+ refetchOnWindowFocus: false,
31
+ retry: false
32
+ }
33
+ },
34
+ logger: testLogger
35
+ });
36
+ return render(/*#__PURE__*/ _jsx(QueryClientProvider, {
37
+ client: queryClient,
38
+ children: ui
39
+ }), options);
40
+ }
41
+
42
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2022 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 { render, RenderOptions } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n\nconst testLogger = {\n log: console.log,\n warn: console.warn,\n error: () => {\n // Don't log network errors in tests to the console\n },\n};\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({\n defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } },\n logger: testLogger,\n });\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","testLogger","log","console","warn","error","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","logger","client"],"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;AAAA,SAASA,MAAM,QAAuB,wBAAwB,CAAC;AAC/D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AAEzE,MAAMC,UAAU,GAAG;IACjBC,GAAG,EAAEC,OAAO,CAACD,GAAG;IAChBE,IAAI,EAAED,OAAO,CAACC,IAAI;IAClBC,KAAK,EAAE,IAAM;IACX,mDAAmD;IACrD,CAAC;CACF,AAAC;AAEF;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,EAAsB,EAAEC,OAAwC,EAAE;IAClG,iEAAiE;IACjE,MAAMC,WAAW,GAAG,IAAIV,WAAW,CAAC;QAClCW,cAAc,EAAE;YAAEC,OAAO,EAAE;gBAAEC,oBAAoB,EAAE,KAAK;gBAAEC,KAAK,EAAE,KAAK;aAAE;SAAE;QAC1EC,MAAM,EAAEb,UAAU;KACnB,CAAC,AAAC;IACH,OAAOH,MAAM,eAAC,KAACE,mBAAmB;QAACe,MAAM,EAAEN,WAAW;kBAAGF,EAAE;MAAuB,EAAEC,OAAO,CAAC,CAAC;AAC/F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAgBA,OAAO,yCAAyC,CAAC"}
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAcA,OAAO,yCAAyC,CAAC"}
@@ -1 +1,16 @@
1
- import{setLogger}from"react-query";import"@testing-library/jest-dom/extend-expect";setLogger({log:console.log,warn:console.warn,error:()=>{}});
1
+ // Copyright 2022 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
+ // Add testing library assertions
14
+ import '@testing-library/jest-dom/extend-expect';
15
+
16
+ //# sourceMappingURL=setup-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\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,iCAAiC;AACjC,OAAO,yCAAyC,CAAC"}