@perses-dev/plugin-system 0.50.1 → 0.50.3

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.
@@ -70,18 +70,27 @@ function usePlugin(pluginType, kind, options) {
70
70
  }
71
71
  function usePlugins(pluginType, plugins) {
72
72
  const { getPlugin } = usePluginRegistry();
73
- return (0, _reactquery.useQueries)({
74
- queries: plugins.map((p)=>{
73
+ // useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()
74
+ // This resolves the following warning in the JS console: "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
75
+ // https://github.com/TanStack/query/issues/8224#issuecomment-2523554831
76
+ // https://github.com/TanStack/query/issues/4187#issuecomment-1256336901
77
+ const kinds = [
78
+ ...new Set(plugins.map((p)=>p.kind))
79
+ ];
80
+ const result = (0, _reactquery.useQueries)({
81
+ queries: kinds.map((kind)=>{
75
82
  return {
76
83
  queryKey: [
77
84
  'getPlugin',
78
85
  pluginType,
79
- p.kind
86
+ kind
80
87
  ],
81
- queryFn: ()=>getPlugin(pluginType, p.kind)
88
+ queryFn: ()=>getPlugin(pluginType, kind)
82
89
  };
83
90
  })
84
91
  });
92
+ // Re-assemble array in original order
93
+ return plugins.map((p)=>result[kinds.indexOf(p.kind)]);
85
94
  }
86
95
  function useListPluginMetadata(pluginTypes, options) {
87
96
  const { listPluginMetadata } = usePluginRegistry();
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/plugin-registry.ts"],"names":[],"mappings":";AAcA,OAAO,EAAwB,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,WAAW,yBAAyB;IACxC,SAAS,C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5C,UAAU,EAAE,CAAC,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC5B,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAYhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAC7C,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/B,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAoBhD;AAGD,KAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,EAClF,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,UAAU,EAAE,EACzB,OAAO,CAAC,EAAE,4BAA4B,GACrC,cAAc,CAAC,cAAc,EAAE,CAAC,CAOlC;AAED,wBAAgB,mCAAmC,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC,CAkBjG"}
@@ -47,18 +47,27 @@ export const PluginRegistryContext = createContext(undefined);
47
47
  * Loads a list of plugins and returns the plugin implementation, along with loading/error state.
48
48
  */ export function usePlugins(pluginType, plugins) {
49
49
  const { getPlugin } = usePluginRegistry();
50
- return useQueries({
51
- queries: plugins.map((p)=>{
50
+ // useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()
51
+ // This resolves the following warning in the JS console: "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
52
+ // https://github.com/TanStack/query/issues/8224#issuecomment-2523554831
53
+ // https://github.com/TanStack/query/issues/4187#issuecomment-1256336901
54
+ const kinds = [
55
+ ...new Set(plugins.map((p)=>p.kind))
56
+ ];
57
+ const result = useQueries({
58
+ queries: kinds.map((kind)=>{
52
59
  return {
53
60
  queryKey: [
54
61
  'getPlugin',
55
62
  pluginType,
56
- p.kind
63
+ kind
57
64
  ],
58
- queryFn: ()=>getPlugin(pluginType, p.kind)
65
+ queryFn: ()=>getPlugin(pluginType, kind)
59
66
  };
60
67
  })
61
68
  });
69
+ // Re-assemble array in original order
70
+ return plugins.map((p)=>result[kinds.indexOf(p.kind)]);
62
71
  }
63
72
  /**
64
73
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/plugin-registry.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginTypes: PluginType[]): Promise<PluginMetadata[]>;\n defaultPluginKinds?: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry(): PluginRegistryContextType {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\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>, Error, PluginImplementation<T>, [string, PluginType | undefined, 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>(\n pluginType: T | undefined,\n kind: string,\n options?: UsePluginOptions<T>\n): UseQueryResult<PluginImplementation<T>, Error> {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && pluginType !== undefined && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery({\n queryKey: ['getPlugin', pluginType, kind],\n queryFn: () => getPlugin(pluginType!, kind),\n ...options,\n });\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(\n pluginType: T,\n plugins: Array<{ kind: string }>\n): Array<UseQueryResult<PluginImplementation<T>>> {\n const { getPlugin } = usePluginRegistry();\n return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType[]]>,\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(\n pluginTypes: PluginType[],\n options?: UseListPluginMetadataOptions\n): UseQueryResult<PluginMetadata[]> {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery({\n queryKey: ['listPluginMetadata', pluginTypes],\n queryFn: () => listPluginMetadata(pluginTypes),\n ...options,\n });\n}\n\nexport function usePluginBuiltinVariableDefinitions(): UseQueryResult<BuiltinVariableDefinition[]> {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery({\n queryKey: ['usePluginBuiltinVariableDefinitions'],\n queryFn: async () => {\n const datasources = await listPluginMetadata(['Datasource']);\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n },\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","queryKey","queryFn","usePlugins","plugins","queries","map","p","useListPluginMetadata","pluginTypes","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","Set","datasource","result","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyC,wBAAwB;AAU9F,OAAO,MAAMC,wBAAwBJ,cAAqDK,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMN,WAAWG;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UACdC,UAAyB,EACzBC,IAAY,EACZC,OAA6B;QAKjBA;IAHZ,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,CAAAA,mBAAAA,oBAAAA,8BAAAA,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,IAAI,CAACD;gBAC7E;YACF;YACA,OAAOJ;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/runtime/plugin-registry.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginTypes: PluginType[]): Promise<PluginMetadata[]>;\n defaultPluginKinds?: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry(): PluginRegistryContextType {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\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>, Error, PluginImplementation<T>, [string, PluginType | undefined, 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>(\n pluginType: T | undefined,\n kind: string,\n options?: UsePluginOptions<T>\n): UseQueryResult<PluginImplementation<T>, Error> {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && pluginType !== undefined && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery({\n queryKey: ['getPlugin', pluginType, kind],\n queryFn: () => getPlugin(pluginType!, kind),\n ...options,\n });\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(\n pluginType: T,\n plugins: Array<{ kind: string }>\n): Array<UseQueryResult<PluginImplementation<T>>> {\n const { getPlugin } = usePluginRegistry();\n\n // useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()\n // This resolves the following warning in the JS console: \"[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.\"\n // https://github.com/TanStack/query/issues/8224#issuecomment-2523554831\n // https://github.com/TanStack/query/issues/4187#issuecomment-1256336901\n const kinds = [...new Set(plugins.map((p) => p.kind))];\n\n const result: Array<UseQueryResult<PluginImplementation<T>>> = useQueries({\n queries: kinds.map((kind) => {\n return {\n queryKey: ['getPlugin', pluginType, kind],\n queryFn: () => getPlugin(pluginType, kind),\n };\n }),\n });\n\n // Re-assemble array in original order\n return plugins.map((p) => result[kinds.indexOf(p.kind)]!);\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType[]]>,\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(\n pluginTypes: PluginType[],\n options?: UseListPluginMetadataOptions\n): UseQueryResult<PluginMetadata[]> {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery({\n queryKey: ['listPluginMetadata', pluginTypes],\n queryFn: () => listPluginMetadata(pluginTypes),\n ...options,\n });\n}\n\nexport function usePluginBuiltinVariableDefinitions(): UseQueryResult<BuiltinVariableDefinition[]> {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery({\n queryKey: ['usePluginBuiltinVariableDefinitions'],\n queryFn: async () => {\n const datasources = await listPluginMetadata(['Datasource']);\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n },\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","queryKey","queryFn","usePlugins","plugins","kinds","Set","map","p","result","queries","indexOf","useListPluginMetadata","pluginTypes","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","datasource","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyC,wBAAwB;AAU9F,OAAO,MAAMC,wBAAwBJ,cAAqDK,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMN,WAAWG;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UACdC,UAAyB,EACzBC,IAAY,EACZC,OAA6B;QAKjBA;IAHZ,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,CAAAA,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IAAIX,IAAIU,YAAYT,GAAG,CAAC,CAACW,aAAeA,WAAWrB,IAAI;YAC/E,MAAMY,SAAsC,EAAE;YAC9C,KAAK,MAAMZ,QAAQoB,gBAAiB;gBAClC,MAAME,SAAS,MAAMnB,UAAU,cAAcH;gBAC7C,IAAIsB,OAAOC,6BAA6B,EAAE;oBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAeb,OAAOc,IAAI,CAACD;gBAC7E;YACF;YACA,OAAOb;QACT;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.50.1",
3
+ "version": "0.50.3",
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",
@@ -28,8 +28,8 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "0.50.1",
32
- "@perses-dev/core": "0.50.1",
31
+ "@perses-dev/components": "0.50.3",
32
+ "@perses-dev/core": "0.50.3",
33
33
  "date-fns": "^2.30.0",
34
34
  "immer": "^9.0.15",
35
35
  "react-hook-form": "^7.46.1",
@@ -38,7 +38,7 @@
38
38
  "zod": "^3.22.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@perses-dev/storybook": "0.50.1"
41
+ "@perses-dev/storybook": "0.50.3"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@mui/material": "^6.1.10",