@perses-dev/plugin-system 0.7.0 → 0.8.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 (117) hide show
  1. package/dist/cjs/components/PluginLoadingBoundary/PluginLoader.js +2 -2
  2. package/dist/cjs/components/PluginLoadingBoundary/PluginLoadingBoundary.js +7 -7
  3. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +48 -35
  4. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +73 -0
  5. package/dist/cjs/components/PluginRegistry/index.js +2 -1
  6. package/dist/cjs/components/PluginRegistry/legacy/PluginRegistry.js +57 -0
  7. package/dist/cjs/components/PluginRegistry/legacy/index.js +29 -0
  8. package/dist/cjs/components/PluginRegistry/{registry-state.js → legacy/registry-state.js} +39 -39
  9. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +67 -0
  10. package/dist/cjs/components/PluginRegistry/plugin-registry-model.js +25 -0
  11. package/dist/cjs/components/PluginRegistry/test-plugins/bert/index.js +26 -0
  12. package/dist/cjs/components/PluginRegistry/test-plugins/bert/plugin.json +32 -0
  13. package/dist/cjs/components/PluginRegistry/test-plugins/ernie/index.js +23 -0
  14. package/dist/cjs/components/PluginRegistry/test-plugins/ernie/plugin.json +24 -0
  15. package/dist/cjs/components/PluginRegistry/test-plugins/index.js +63 -0
  16. package/dist/cjs/components/index.js +1 -1
  17. package/dist/cjs/model/graph-queries.js +1 -1
  18. package/dist/cjs/model/index.js +2 -1
  19. package/dist/cjs/model/panels.js +26 -10
  20. package/dist/cjs/model/plugins.js +1 -1
  21. package/dist/cjs/model/variables.js +1 -1
  22. package/dist/cjs/model/visual-editing.js +14 -0
  23. package/dist/cjs/runtime/index.js +1 -0
  24. package/dist/cjs/runtime/plugins.js +38 -0
  25. package/dist/cjs/runtime/query-string.js +28 -0
  26. package/dist/cjs/runtime/template-variables.js +20 -9
  27. package/dist/cjs/runtime/time-range.js +1 -1
  28. package/dist/cjs/test/render.js +27 -0
  29. package/dist/cjs/test/setup-tests.js +24 -0
  30. package/dist/cjs/utils/cache-keys.js +22 -0
  31. package/dist/components/PluginLoadingBoundary/PluginLoader.js +1 -1
  32. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts +2 -2
  33. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.d.ts.map +1 -1
  34. package/dist/components/PluginLoadingBoundary/PluginLoadingBoundary.js +1 -1
  35. package/dist/components/PluginRegistry/PluginRegistry.d.ts +6 -21
  36. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  37. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  38. package/dist/components/PluginRegistry/PluginRegistry.test.d.ts +2 -0
  39. package/dist/components/PluginRegistry/PluginRegistry.test.d.ts.map +1 -0
  40. package/dist/components/PluginRegistry/PluginRegistry.test.js +1 -0
  41. package/dist/components/PluginRegistry/index.d.ts +1 -0
  42. package/dist/components/PluginRegistry/index.d.ts.map +1 -1
  43. package/dist/components/PluginRegistry/index.js +1 -1
  44. package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts +29 -0
  45. package/dist/components/PluginRegistry/legacy/PluginRegistry.d.ts.map +1 -0
  46. package/dist/components/PluginRegistry/legacy/PluginRegistry.js +1 -0
  47. package/dist/components/PluginRegistry/legacy/index.d.ts +2 -0
  48. package/dist/components/PluginRegistry/legacy/index.d.ts.map +1 -0
  49. package/dist/components/PluginRegistry/legacy/index.js +1 -0
  50. package/dist/components/PluginRegistry/{registry-state.d.ts → legacy/registry-state.d.ts} +4 -4
  51. package/dist/components/PluginRegistry/legacy/registry-state.d.ts.map +1 -0
  52. package/dist/components/PluginRegistry/legacy/registry-state.js +1 -0
  53. package/dist/components/PluginRegistry/plugin-indexes.d.ts +11 -0
  54. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -0
  55. package/dist/components/PluginRegistry/plugin-indexes.js +1 -0
  56. package/dist/components/PluginRegistry/plugin-registry-model.d.ts +10 -0
  57. package/dist/components/PluginRegistry/plugin-registry-model.d.ts.map +1 -0
  58. package/dist/components/PluginRegistry/plugin-registry-model.js +1 -0
  59. package/dist/components/PluginRegistry/test-plugins/bert/index.d.ts +4 -0
  60. package/dist/components/PluginRegistry/test-plugins/bert/index.d.ts.map +1 -0
  61. package/dist/components/PluginRegistry/test-plugins/bert/index.js +1 -0
  62. package/dist/components/PluginRegistry/test-plugins/bert/plugin.json +32 -0
  63. package/dist/components/PluginRegistry/test-plugins/ernie/index.d.ts +3 -0
  64. package/dist/components/PluginRegistry/test-plugins/ernie/index.d.ts.map +1 -0
  65. package/dist/components/PluginRegistry/test-plugins/ernie/index.js +1 -0
  66. package/dist/components/PluginRegistry/test-plugins/ernie/plugin.json +24 -0
  67. package/dist/components/PluginRegistry/test-plugins/index.d.ts +6 -0
  68. package/dist/components/PluginRegistry/test-plugins/index.d.ts.map +1 -0
  69. package/dist/components/PluginRegistry/test-plugins/index.js +1 -0
  70. package/dist/components/index.d.ts +1 -1
  71. package/dist/components/index.d.ts.map +1 -1
  72. package/dist/components/index.js +1 -1
  73. package/dist/model/graph-queries.js +1 -1
  74. package/dist/model/index.d.ts +1 -0
  75. package/dist/model/index.d.ts.map +1 -1
  76. package/dist/model/index.js +1 -1
  77. package/dist/model/panels.d.ts +5 -2
  78. package/dist/model/panels.d.ts.map +1 -1
  79. package/dist/model/panels.js +1 -1
  80. package/dist/model/plugins.d.ts +20 -35
  81. package/dist/model/plugins.d.ts.map +1 -1
  82. package/dist/model/variables.d.ts +3 -3
  83. package/dist/model/variables.d.ts.map +1 -1
  84. package/dist/model/variables.js +1 -1
  85. package/dist/model/visual-editing.d.ts +18 -0
  86. package/dist/model/visual-editing.d.ts.map +1 -0
  87. package/dist/model/visual-editing.js +1 -0
  88. package/dist/runtime/index.d.ts +1 -0
  89. package/dist/runtime/index.d.ts.map +1 -1
  90. package/dist/runtime/index.js +1 -1
  91. package/dist/runtime/plugins.d.ts +23 -0
  92. package/dist/runtime/plugins.d.ts.map +1 -0
  93. package/dist/runtime/plugins.js +1 -0
  94. package/dist/runtime/query-string.d.ts +11 -0
  95. package/dist/runtime/query-string.d.ts.map +1 -0
  96. package/dist/runtime/query-string.js +1 -0
  97. package/dist/runtime/template-variables.d.ts +6 -15
  98. package/dist/runtime/template-variables.d.ts.map +1 -1
  99. package/dist/runtime/template-variables.js +1 -1
  100. package/dist/runtime/time-range.d.ts +2 -2
  101. package/dist/runtime/time-range.d.ts.map +1 -1
  102. package/dist/test/render.d.ts +7 -0
  103. package/dist/test/render.d.ts.map +1 -0
  104. package/dist/test/render.js +1 -0
  105. package/dist/test/setup-tests.d.ts +2 -0
  106. package/dist/test/setup-tests.d.ts.map +1 -0
  107. package/dist/test/setup-tests.js +1 -0
  108. package/dist/utils/cache-keys.d.ts +6 -0
  109. package/dist/utils/cache-keys.d.ts.map +1 -0
  110. package/dist/utils/cache-keys.js +1 -0
  111. package/package.json +6 -6
  112. package/dist/cjs/components/PluginRegistry/create-plugin.js +0 -118
  113. package/dist/components/PluginRegistry/create-plugin.d.ts +0 -27
  114. package/dist/components/PluginRegistry/create-plugin.d.ts.map +0 -1
  115. package/dist/components/PluginRegistry/create-plugin.js +0 -1
  116. package/dist/components/PluginRegistry/registry-state.d.ts.map +0 -1
  117. package/dist/components/PluginRegistry/registry-state.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnE,oBAAY,mBAAmB,GAAG,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;AAExE,MAAM,WAAW,aAAa;IAE5B,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAEhE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,mBAAmB,EAAE,mBAAmB,gCAoDxE"}
@@ -0,0 +1 @@
1
+ import{useEvent}from"@perses-dev/core";import{useCallback,useRef}from"react";import{getTypeAndKindKey}from"../../utils/cache-keys";export function usePluginIndexes(e){const n=useEvent((async()=>{const n=await e(),t=new Map,o=new Map;for(const e of n)for(const n of e.spec.plugins){const{pluginType:r,kind:s}=n,u=getTypeAndKindKey(r,s);t.has(u)&&console.warn(`Got more than one ${r} plugin for kind ${s}`),t.set(u,e);let c=o.get(r);void 0===c&&(c=[],o.set(r,c)),c.push(n)}return{pluginResourcesByTypeAndKind:t,pluginMetadataByType:o}})),t=useRef(void 0);return useCallback((()=>{let e=t.current;return void 0===e&&(e=n(),t.current=e,e.catch((()=>void 0===t.current))),e}),[n])}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { JsonObject } from '@perses-dev/core';
3
+ import { PluginImplementation, PluginMetadata, PluginType } from '../../model';
4
+ export interface PluginRegistryContextType {
5
+ getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T, JsonObject>>;
6
+ listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;
7
+ }
8
+ export declare const PluginRegistryContext: import("react").Context<PluginRegistryContextType | undefined>;
9
+ export declare function usePluginRegistry(): PluginRegistryContextType;
10
+ //# sourceMappingURL=plugin-registry-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-registry-model.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-registry-model.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE/E,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3G,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CACvE;AAED,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG,wBAAgB,iBAAiB,8BAMhC"}
@@ -0,0 +1 @@
1
+ import{createContext,useContext}from"react";export const PluginRegistryContext=createContext(void 0);export function usePluginRegistry(){const t=useContext(PluginRegistryContext);if(void 0===t)throw new Error("PluginRegistryContext not found. Did you forget a provider?");return t}
@@ -0,0 +1,4 @@
1
+ import { PanelPlugin } from '../../../../model';
2
+ export declare const BertPanel1: PanelPlugin;
3
+ export declare const BertPanel2: PanelPlugin;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/PluginRegistry/test-plugins/bert/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,eAAO,MAAM,UAAU,EAAE,WAIxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAIxB,CAAC"}
@@ -0,0 +1 @@
1
+ export const BertPanel1={PanelComponent:()=>null,OptionsEditorComponent:()=>null,createInitialOptions:()=>({})};export const BertPanel2={PanelComponent:()=>null,OptionsEditorComponent:()=>null,createInitialOptions:()=>({})};
@@ -0,0 +1,32 @@
1
+ {
2
+ "kind": "PluginModule",
3
+ "metadata": { "name": "Bert" },
4
+ "spec": {
5
+ "plugins": [
6
+ {
7
+ "pluginType": "Panel",
8
+ "kind": "BertPanel1",
9
+ "display": {
10
+ "name": "Bert Panel 1",
11
+ "description": ""
12
+ }
13
+ },
14
+ {
15
+ "pluginType": "Panel",
16
+ "kind": "BertPanel2",
17
+ "display": {
18
+ "name": "Bert Panel 2",
19
+ "description": ""
20
+ }
21
+ },
22
+ {
23
+ "pluginType": "Variable",
24
+ "kind": "BertVariable",
25
+ "display": {
26
+ "name": "Bert Variable",
27
+ "description": ""
28
+ }
29
+ }
30
+ ]
31
+ }
32
+ }
@@ -0,0 +1,3 @@
1
+ import { VariablePlugin } from '../../../../model';
2
+ export declare const ErnieVariable: VariablePlugin;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/PluginRegistry/test-plugins/ernie/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,eAAO,MAAM,aAAa,EAAE,cAE3B,CAAC"}
@@ -0,0 +1 @@
1
+ const data=[{label:"Grover",value:"Grover"},{label:"Snuffleupagus",value:"Snuffleupagus"}];export const ErnieVariable={useVariableOptions:()=>({loading:!1,error:void 0,data})};
@@ -0,0 +1,24 @@
1
+ {
2
+ "kind": "PluginModule",
3
+ "metadata": { "name": "Ernie" },
4
+ "spec": {
5
+ "plugins": [
6
+ {
7
+ "pluginType": "Variable",
8
+ "kind": "ErnieVariable",
9
+ "display": {
10
+ "name": "Ernie Variable",
11
+ "description": "A variable plugin that exists in the plugin module"
12
+ }
13
+ },
14
+ {
15
+ "pluginType": "Variable",
16
+ "kind": "MissingErnieVariable",
17
+ "display": {
18
+ "name": "Ernie Variable",
19
+ "description": "A variable plugin that exists here in the metadata, but is not in the plugin module"
20
+ }
21
+ }
22
+ ]
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ import { PluginRegistryProps } from '../PluginRegistry';
2
+ /**
3
+ * Some props for testing the PluginRegistry that use the test plugins/metadata in this folder.
4
+ */
5
+ export declare const testRegistryProps: Omit<PluginRegistryProps, 'children'>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PluginRegistry/test-plugins/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAYnE,CAAC"}
@@ -0,0 +1 @@
1
+ import bertResource from"./bert/plugin.json";import ernieResource from"./ernie/plugin.json";const testPlugins=new Map;testPlugins.set(bertResource,(()=>import("./bert"))),testPlugins.set(ernieResource,(()=>import("./ernie")));export const testRegistryProps={getInstalledPlugins:()=>{const e=Array.from(testPlugins.keys());return Promise.resolve(e)},importPluginModule:e=>{const t=testPlugins.get(e);if(void 0===t)throw new Error("Plugin not found");return t()}};
@@ -1,4 +1,4 @@
1
1
  export * from './PluginBoundary';
2
2
  export * from './PluginLoadingBoundary';
3
- export * from './PluginRegistry';
3
+ export * from './PluginRegistry/legacy';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
@@ -1 +1 @@
1
- export*from"./PluginBoundary";export*from"./PluginLoadingBoundary";export*from"./PluginRegistry";
1
+ export*from"./PluginBoundary";export*from"./PluginLoadingBoundary";export*from"./PluginRegistry/legacy";
@@ -1 +1 @@
1
- import{usePlugin}from"../components/PluginLoadingBoundary";export const useGraphQuery=r=>{const u=usePlugin("GraphQuery",r);return void 0===u?{loading:!0}:u.useGraphQuery(r)};
1
+ import{usePlugin}from"../components/PluginLoadingBoundary";export const useGraphQuery=n=>{const r=usePlugin("GraphQuery",n.kind);return void 0===r?{loading:!0}:r.useGraphQuery(n)};
@@ -2,4 +2,5 @@ export * from './graph-queries';
2
2
  export * from './panels';
3
3
  export * from './plugins';
4
4
  export * from './variables';
5
+ export * from './visual-editing';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- export*from"./graph-queries";export*from"./panels";export*from"./plugins";export*from"./variables";
1
+ export*from"./graph-queries";export*from"./panels";export*from"./plugins";export*from"./variables";export*from"./visual-editing";
@@ -1,10 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { JsonObject, PanelDefinition } from '@perses-dev/core';
3
+ import { InitialOptionsCallback, OptionsEditor } from './visual-editing';
3
4
  /**
4
5
  * Plugin the provides custom visualizations inside of a Panel.
5
6
  */
6
7
  export interface PanelPlugin<Options extends JsonObject = JsonObject> {
7
8
  PanelComponent: React.ComponentType<PanelProps<Options>>;
9
+ OptionsEditorComponent: OptionsEditor<Options>;
10
+ createInitialOptions: InitialOptionsCallback<Options>;
8
11
  }
9
12
  /**
10
13
  * The props provided by Perses to a panel plugin's PanelComponent.
@@ -17,7 +20,7 @@ export interface PanelProps<Options extends JsonObject> {
17
20
  };
18
21
  }
19
22
  /**
20
- * Renders a PanelComponent from a panel plugin at runtime.
23
+ * Hook for using a panel plugin at runtime.
21
24
  */
22
- export declare const PanelComponent: PanelPlugin['PanelComponent'];
25
+ export declare function usePanelPlugin(kind: string): PanelPlugin<JsonObject>;
23
26
  //# sourceMappingURL=panels.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU;IAClE,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,OAAO,SAAS,UAAU;IACpD,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACrC,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,gBAAgB,CAOxD,CAAC"}
1
+ {"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU;IAClE,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,sBAAsB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/C,oBAAoB,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,OAAO,SAAS,UAAU;IACpD,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACrC,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAQpE"}
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{usePlugin}from"../components/PluginLoadingBoundary";export const PanelComponent=n=>{const o=usePlugin("Panel",n.definition);if(void 0===o)return null;const{PanelComponent:e}=o;return _jsx(e,{...n})};
1
+ import{usePlugin}from"../components/PluginLoadingBoundary";export function usePanelPlugin(n){const l=usePlugin("Panel",n);return void 0!==l?l:defaultPanelPlugin}const defaultPanelPlugin={PanelComponent:()=>null,OptionsEditorComponent:()=>null,createInitialOptions:()=>({})};
@@ -1,30 +1,29 @@
1
- import { JsonObject, ResourceMetadata, VariableDefinition, PanelDefinition } from '@perses-dev/core';
1
+ import { JsonObject, ResourceMetadata, ListVariableDefinition, PanelDefinition } from '@perses-dev/core';
2
2
  import { GraphQueryDefinition, GraphQueryPlugin } from './graph-queries';
3
3
  import { PanelPlugin } from './panels';
4
4
  import { VariablePlugin } from './variables';
5
- export interface PluginResource {
6
- kind: 'Plugin';
5
+ /**
6
+ * Information about a module/package that contains plugins.
7
+ */
8
+ export interface PluginModuleResource {
9
+ kind: 'PluginModule';
7
10
  metadata: ResourceMetadata;
8
11
  spec: PluginSpec;
9
12
  }
10
13
  export interface PluginSpec {
11
- supported_kinds: Record<string, PluginType>;
14
+ plugins: PluginMetadata[];
12
15
  }
13
16
  /**
14
- * A JavaScript module with Perses plugins.
17
+ * Metadata about an individual plugin that's part of a PluginModule.
15
18
  */
16
- export interface PluginModule {
17
- setup: PluginSetupFunction;
19
+ export interface PluginMetadata {
20
+ pluginType: PluginType;
21
+ kind: string;
22
+ display: {
23
+ name: string;
24
+ description?: string;
25
+ };
18
26
  }
19
- /**
20
- * When a PluginModule is loaded, this function is called to allow the module
21
- * to register plugins with Perses.
22
- */
23
- export declare type PluginSetupFunction = (registerPlugin: RegisterPlugin) => void;
24
- /**
25
- * Callback function that registers a plugin with Perses.
26
- */
27
- export declare type RegisterPlugin = <Options extends JsonObject>(config: PluginRegistrationConfig<Options>) => void;
28
27
  /**
29
28
  * All supported plugin type values as an array for use at runtime.
30
29
  */
@@ -35,7 +34,7 @@ export declare const ALL_PLUGIN_TYPES: readonly ["Variable", "Panel", "GraphQuer
35
34
  export declare type PluginType = typeof ALL_PLUGIN_TYPES[number];
36
35
  declare type SupportedPlugins<Options extends JsonObject> = {
37
36
  Variable: {
38
- Def: VariableDefinition<Options>;
37
+ Def: ListVariableDefinition<Options>;
39
38
  Impl: VariablePlugin<Options>;
40
39
  };
41
40
  Panel: {
@@ -48,28 +47,14 @@ declare type SupportedPlugins<Options extends JsonObject> = {
48
47
  };
49
48
  };
50
49
  /**
51
- * The definition handled for a given plugin type.
50
+ * Union type of all available plugin implementations.
52
51
  */
53
- export declare type PluginDefinition<Type extends PluginType, Options extends JsonObject> = SupportedPlugins<Options>[Type]['Def'];
52
+ export declare type Plugin<Options extends JsonObject> = {
53
+ [Type in PluginType]: PluginImplementation<Type, Options>;
54
+ }[PluginType];
54
55
  /**
55
56
  * The implementation for a given plugin type.
56
57
  */
57
58
  export declare type PluginImplementation<Type extends PluginType, Options extends JsonObject> = SupportedPlugins<Options>[Type]['Impl'];
58
- /**
59
- * Configuration (including the plugin implementation) that's expected when
60
- * registering a plugin with Perses.
61
- */
62
- export declare type PluginRegistrationConfig<Options extends JsonObject> = {
63
- [Type in PluginType]: PluginConfig<Type, Options>;
64
- }[PluginType];
65
- /**
66
- * Configuration expected for a particular plugin type.
67
- */
68
- export declare type PluginConfig<Type extends PluginType, Options extends JsonObject> = {
69
- pluginType: Type;
70
- kind: string;
71
- validate?: (config: PluginDefinition<Type, JsonObject>) => string[];
72
- plugin: PluginImplementation<Type, Options>;
73
- };
74
59
  export {};
75
60
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sour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AAI,SAAS,UAAU,EACvB,OAAO,SAAS,UAAU,IACxB,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { JsonObject, VariableDefinition } from '@perses-dev/core';
1
+ import { JsonObject, ListVariableDefinition, VariableOption } from '@perses-dev/core';
2
2
  /**
3
3
  * Plugin for handling custom VariableDefinitions.
4
4
  */
@@ -9,8 +9,8 @@ export interface VariablePlugin<Options extends JsonObject = JsonObject> {
9
9
  * Plugin hook responsible for getting the options of a custom variable
10
10
  * definition.
11
11
  */
12
- export declare type UseVariableOptionsHook<Options extends JsonObject> = (definition: VariableDefinition<Options>) => {
13
- data: string[];
12
+ export declare type UseVariableOptionsHook<Options extends JsonObject = JsonObject> = (definition: ListVariableDefinition<Options>) => {
13
+ data: VariableOption[];
14
14
  loading: boolean;
15
15
  error?: Error;
16
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGlE;;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,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK;IAC5G,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,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,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 +1 @@
1
- import{usePlugin}from"../components/PluginLoadingBoundary";export const useVariableOptions=n=>{const o=usePlugin("Variable",n);return void 0===o?{data:[],loading:!0}:o.useVariableOptions(n)};
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)};
@@ -0,0 +1,18 @@
1
+ import { JsonObject } from '@perses-dev/core';
2
+ import React from 'react';
3
+ /**
4
+ * A component for visual editing of a plugin's options.
5
+ */
6
+ export declare type OptionsEditor<Options extends JsonObject = JsonObject> = React.ComponentType<OptionsEditorProps<Options>>;
7
+ /**
8
+ * Common props passed to options editor components.
9
+ */
10
+ export interface OptionsEditorProps<Options extends JsonObject = JsonObject> {
11
+ value: Options;
12
+ onChange: (next: Options) => void;
13
+ }
14
+ /**
15
+ * Callback for creating initial/empty options for a plugin.
16
+ */
17
+ export declare type InitialOptionsCallback<Options extends JsonObject> = () => Options;
18
+ //# sourceMappingURL=visual-editing.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ export{};
@@ -1,4 +1,5 @@
1
1
  export * from './datasources';
2
2
  export * from './template-variables';
3
3
  export * from './time-range';
4
+ export * from './query-string';
4
5
  //# 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"}
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 +1 @@
1
- export*from"./datasources";export*from"./template-variables";export*from"./time-range";
1
+ export*from"./datasources";export*from"./template-variables";export*from"./time-range";export*from"./query-string";
@@ -0,0 +1,23 @@
1
+ import { JsonObject } from '@perses-dev/core';
2
+ import { UseQueryOptions } from 'react-query';
3
+ 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'>;
5
+ /**
6
+ * Loads a plugin and returns the plugin implementation, along with loading/error state.
7
+ */
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'>;
14
+ /**
15
+ * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
16
+ */
17
+ export declare function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions): {
18
+ pluginMetadata: PluginMetadata[] | undefined;
19
+ isLoading: boolean;
20
+ error: unknown;
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
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}}
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export interface QueryString {
3
+ queryString: URLSearchParams;
4
+ setQueryString?: (queryString: URLSearchParams) => void;
5
+ }
6
+ export declare const QueryStringContext: import("react").Context<QueryString | undefined>;
7
+ /**
8
+ * Gets the current query params at runtime.
9
+ */
10
+ export declare function useQueryString(): QueryString;
11
+ //# sourceMappingURL=query-string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-string.d.ts","sourceRoot":"","sources":["../../src/runtime/query-string.tsx"],"names":[],"mappings":";AAeA,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,eAAe,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,IAAI,CAAC;CACzD;AAED,eAAO,MAAM,kBAAkB,kDAAoD,CAAC;AAEpF;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAM5C"}
@@ -0,0 +1 @@
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,17 +1,8 @@
1
1
  /// <reference types="react" />
2
- export interface TemplateVariables {
3
- variables: Record<string, VariableState>;
4
- }
5
- /**
6
- * The value and options for a template variable.
7
- */
8
- export interface VariableState {
9
- value: string | string[];
10
- options?: string[];
11
- }
12
- export declare const TemplateVariablesContext: import("react").Context<TemplateVariables | undefined>;
13
- /**
14
- * Gets TemplateVariables at runtime.
15
- */
16
- export declare function useTemplateVariables(): TemplateVariables;
2
+ import { VariableStateMap } from '@perses-dev/core';
3
+ export declare type TemplateVariableSrv = {
4
+ state: VariableStateMap;
5
+ };
6
+ export declare const TemplateVariableContext: import("react").Context<TemplateVariableSrv | undefined>;
7
+ export declare function useTemplateVariableValues(names?: string[]): VariableStateMap;
17
8
  //# sourceMappingURL=template-variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/template-variables.ts"],"names":[],"mappings":";AAeA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,wBAAwB,wDAA0D,CAAC;AAEhG;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAMxD"}
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 +1 @@
1
- import{createContext,useContext}from"react";export const TemplateVariablesContext=createContext(void 0);export function useTemplateVariables(){const e=useContext(TemplateVariablesContext);if(void 0===e)throw new Error("No TemplateVariablesContext found. Did you forget a Provider?");return e}
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,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { AbsoluteTimeRange, DurationString } from '@perses-dev/core';
2
+ import { AbsoluteTimeRange, TimeRangeValue } from '@perses-dev/core';
3
3
  export interface TimeRange {
4
4
  timeRange: AbsoluteTimeRange;
5
- defaultDuration: DurationString;
5
+ setTimeRange: (value: TimeRangeValue) => void;
6
6
  }
7
7
  export declare const TimeRangeContext: import("react").Context<TimeRange | undefined>;
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"time-range.d.ts","sourceRoot":"","sources":["../../src/runtime/time-range.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,eAAe,EAAE,cAAc,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,gDAAkD,CAAC;AAEhF;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAMxC"}
1
+ {"version":3,"file":"time-range.d.ts","sourceRoot":"","sources":["../../src/runtime/time-range.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC/C;AAED,eAAO,MAAM,gBAAgB,gDAAkD,CAAC;AAEhF;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAMxC"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { RenderOptions } from '@testing-library/react';
3
+ /**
4
+ * Test helper to render a React component with some common app-level providers wrapped around it.
5
+ */
6
+ export declare function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
7
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
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)}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ //# sourceMappingURL=setup-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAgBA,OAAO,yCAAyC,CAAC"}
@@ -0,0 +1 @@
1
+ import{setLogger}from"react-query";import"@testing-library/jest-dom/extend-expect";setLogger({log:console.log,warn:console.warn,error:()=>{}});
@@ -0,0 +1,6 @@
1
+ import { PluginType } from '../model';
2
+ /**
3
+ * Gets a unique key for a plugin type/kind that can be used as a cache key.
4
+ */
5
+ export declare function getTypeAndKindKey(pluginType: PluginType, kind: string): string;
6
+ //# sourceMappingURL=cache-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-keys.d.ts","sourceRoot":"","sources":["../../src/utils/cache-keys.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAErE"}
@@ -0,0 +1 @@
1
+ export function getTypeAndKindKey(e,n){return`${e}:${n}`}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "The plugin feature in Pereses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -18,19 +18,19 @@
18
18
  "clean": "rimraf dist/",
19
19
  "build": "tsc --build",
20
20
  "build:cjs": "tsc --project ./tsconfig.cjs.json",
21
- "test": "echo 'no test to run' && exit 0",
21
+ "test": "TZ=UTC jest",
22
22
  "lint": "eslint src --ext .ts,.tsx",
23
23
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
24
24
  },
25
25
  "dependencies": {
26
- "@perses-dev/components": "^0.7.0",
27
- "@perses-dev/core": "^0.7.0",
26
+ "@perses-dev/components": "^0.8.0",
27
+ "@perses-dev/core": "^0.8.0",
28
28
  "immer": "^9.0.15",
29
29
  "use-immer": "^0.7.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "react": "^17.0.2",
33
- "react-dom": "^17.0.2",
32
+ "react": "^17.0.2 || ^18.0.0",
33
+ "react-dom": "^17.0.2 || ^18.0.0",
34
34
  "react-query": "^3.34.16"
35
35
  },
36
36
  "files": [