@perses-dev/plugin-system 0.51.0-beta.0 → 0.51.0-beta.1
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.
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +2 -2
- package/dist/cjs/remote/PluginRuntime.js +16 -16
- package/dist/cjs/runtime/plugin-registry.js +13 -4
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.js +16 -16
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +13 -4
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -9
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +0 -34
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -101
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/index.js +0 -35
- package/dist/cjs/stories/shared-utils/index.js +0 -30
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +0 -33
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +0 -4
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +0 -26
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -95
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +0 -33
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +0 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +0 -7
- package/dist/stories/shared-utils/decorators/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/index.js +0 -20
- package/dist/stories/shared-utils/decorators/index.js.map +0 -1
- package/dist/stories/shared-utils/index.d.ts +0 -2
- package/dist/stories/shared-utils/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/index.js +0 -15
- package/dist/stories/shared-utils/index.js.map +0 -1
|
@@ -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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { useQueries, useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadataWithModule, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(kind: T, name: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginTypes: string[]): Promise<PluginMetadataWithModule[]>;\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
|
|
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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { useQueries, useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadataWithModule, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(kind: T, name: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginTypes: string[]): Promise<PluginMetadataWithModule[]>;\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<PluginMetadataWithModule[], Error, PluginMetadataWithModule[], [string, 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(\n pluginTypes: string[],\n options?: UseListPluginMetadataOptions\n): UseQueryResult<PluginMetadataWithModule[]> {\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 datasourceNames = new Set(datasources.map((datasource) => datasource.spec.name));\n const result: BuiltinVariableDefinition[] = [];\n for (const name of datasourceNames) {\n const plugin = await getPlugin('Datasource', name);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n },\n });\n}\n"],"names":["useQueries","useQuery","createContext","useContext","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","datasourceNames","datasource","spec","name","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;AAGjC,SAASA,UAAU,EAAEC,QAAQ,QAAyC,wBAAwB;AAC9F,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AASlD,OAAO,MAAMC,wBAAwBF,cAAqDG,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMJ,WAAWC;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UACdC,UAAyB,EACzBC,IAAY,EACZC,OAA6B;IAE7B,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,SAASC,WAAW,IAAG,KAAMH,eAAeL,aAAaM,SAAS;IAC9E;IACA,MAAM,EAAEG,SAAS,EAAE,GAAGR;IACtB,OAAOL,SAAS;QACdc,UAAU;YAAC;YAAaL;YAAYC;SAAK;QACzCK,SAAS,IAAMF,UAAUJ,YAAaC;QACtC,GAAGC,OAAO;IACZ;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,WACdP,UAAa,EACbQ,OAAgC;IAEhC,MAAM,EAAEJ,SAAS,EAAE,GAAGR;IAEtB,oIAAoI;IACpI,iJAAiJ;IACjJ,wEAAwE;IACxE,wEAAwE;IACxE,MAAMa,QAAQ;WAAI,IAAIC,IAAIF,QAAQG,GAAG,CAAC,CAACC,IAAMA,EAAEX,IAAI;KAAG;IAEtD,MAAMY,SAAyDvB,WAAW;QACxEwB,SAASL,MAAME,GAAG,CAAC,CAACV;YAClB,OAAO;gBACLI,UAAU;oBAAC;oBAAaL;oBAAYC;iBAAK;gBACzCK,SAAS,IAAMF,UAAUJ,YAAYC;YACvC;QACF;IACF;IAEA,sCAAsC;IACtC,OAAOO,QAAQG,GAAG,CAAC,CAACC,IAAMC,MAAM,CAACJ,MAAMM,OAAO,CAACH,EAAEX,IAAI,EAAE;AACzD;AAQA;;CAEC,GACD,OAAO,SAASe,sBACdC,WAAqB,EACrBf,OAAsC;IAEtC,MAAM,EAAEgB,kBAAkB,EAAE,GAAGtB;IAC/B,OAAOL,SAAS;QACdc,UAAU;YAAC;YAAsBY;SAAY;QAC7CX,SAAS,IAAMY,mBAAmBD;QAClC,GAAGf,OAAO;IACZ;AACF;AAEA,OAAO,SAASiB;IACd,MAAM,EAAEf,SAAS,EAAEc,kBAAkB,EAAE,GAAGtB;IAE1C,OAAOL,SAAS;QACdc,UAAU;YAAC;SAAsC;QACjDC,SAAS;YACP,MAAMc,cAAc,MAAMF,mBAAmB;gBAAC;aAAa;YAC3D,MAAMG,kBAAkB,IAAIX,IAAIU,YAAYT,GAAG,CAAC,CAACW,aAAeA,WAAWC,IAAI,CAACC,IAAI;YACpF,MAAMX,SAAsC,EAAE;YAC9C,KAAK,MAAMW,QAAQH,gBAAiB;gBAClC,MAAMI,SAAS,MAAMrB,UAAU,cAAcoB;gBAC7C,IAAIC,OAAOC,6BAA6B,EAAE;oBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAef,OAAOgB,IAAI,CAACD;gBAC7E;YACF;YACA,OAAOf;QACT;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test-utils/mock-plugin-registry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/core';\nimport { PluginRegistryProps } from '../components';\nimport { PluginModuleResource, Plugin, PluginLoader, PluginImplementation, PluginType } from '../model';\n\nexport type MockPlugin = {\n [T in PluginType]: {\n kind: T;\n spec: { name: string };\n plugin: PluginImplementation<T>;\n };\n}[PluginType];\n\n/**\n * Helper for mocking `PluginRegistry` data during tests. Returns props that can be spread on the `PluginRegistry`\n * component so that it will load the mock plugins you provide.\n */\nexport function mockPluginRegistry(...mockPlugins: MockPlugin[]): Omit<PluginRegistryProps, 'children'> {\n const mockPluginResource: PluginModuleResource = {\n kind: 'PluginModule',\n metadata: {\n name: 'Fake Plugin Module for Tests',\n version: '0',\n },\n spec: {\n // Add metadata for all mock plugins\n plugins: mockPlugins.map(({ kind, spec: { name } }) => ({\n kind,\n spec: {\n name,\n display: {\n name: getMockPluginName(kind, name),\n },\n },\n })),\n },\n };\n\n const mockPluginModule: Record<string, Plugin<UnknownSpec>> = {};\n for (const mockPlugin of mockPlugins) {\n // \"Export\" on the module under the same name as the kind the plugin handles\n mockPluginModule[mockPlugin.spec.name] = mockPlugin.plugin;\n }\n\n const pluginLoader: PluginLoader = {\n getInstalledPlugins() {\n return Promise.resolve([mockPluginResource]);\n },\n importPluginModule(/* resource */) {\n return Promise.resolve(mockPluginModule);\n },\n };\n\n return {\n pluginLoader,\n defaultPluginKinds: {\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n },\n };\n}\n\n/**\n * The function that's used to generate the display name of mocked plugins in mockPluginRegistry. Can be useful if you\n * need to interact with some UI component that's displaying it.\n */\nexport function getMockPluginName(kind: PluginType, name: string): string {\n return `${kind} Plugin for ${name}`;\n}\n"],"names":["mockPluginRegistry","mockPlugins","mockPluginResource","kind","metadata","name","version","spec","plugins","map","display","getMockPluginName","mockPluginModule","mockPlugin","plugin","pluginLoader","getInstalledPlugins","Promise","resolve","importPluginModule","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAcjC;;;CAGC,GACD,OAAO,SAASA,mBAAmB,GAAGC,WAAyB;IAC7D,MAAMC,qBAA2C;QAC/CC,MAAM;QACNC,UAAU;YACRC,MAAM;YACNC,SAAS;QACX;QACAC,MAAM;YACJ,oCAAoC;YACpCC,SAASP,YAAYQ,GAAG,CAAC,CAAC,EAAEN,IAAI,EAAEI,MAAM,EAAEF,IAAI,EAAE,EAAE,GAAM,CAAA;oBACtDF;oBACAI,MAAM;wBACJF;wBACAK,SAAS;4BACPL,MAAMM,kBAAkBR,MAAME;wBAChC;oBACF;gBACF,CAAA;QACF;IACF;IAEA,MAAMO,mBAAwD,CAAC;IAC/D,KAAK,MAAMC,cAAcZ,YAAa;QACpC,4EAA4E;QAC5EW,gBAAgB,CAACC,WAAWN,IAAI,CAACF,IAAI,CAAC,GAAGQ,WAAWC,MAAM;IAC5D;IAEA,MAAMC,eAA6B;QACjCC;YACE,OAAOC,QAAQC,OAAO,CAAC;gBAAChB;aAAmB;QAC7C;QACAiB;YACE,OAAOF,QAAQC,OAAO,CAACN;QACzB;IACF;IAEA,OAAO;QACLG;QACAK,oBAAoB;YAClBC,iBAAiB;QACnB;IACF;AACF;AAEA;;;CAGC,GACD,OAAO,SAASV,kBAAkBR,IAAgB,EAAEE,IAAY;IAC9D,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/test-utils/mock-plugin-registry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/core';\nimport { PluginRegistryProps } from '../components';\nimport { PluginModuleResource, Plugin, PluginLoader, PluginImplementation, PluginType } from '../model';\n\nexport type MockPlugin = {\n [T in PluginType]: {\n kind: T;\n spec: { name: string };\n plugin: PluginImplementation<T>;\n };\n}[PluginType];\n\n/**\n * Helper for mocking `PluginRegistry` data during tests. Returns props that can be spread on the `PluginRegistry`\n * component so that it will load the mock plugins you provide.\n */\nexport function mockPluginRegistry(...mockPlugins: MockPlugin[]): Omit<PluginRegistryProps, 'children'> {\n const mockPluginResource: PluginModuleResource = {\n kind: 'PluginModule',\n metadata: {\n name: 'Fake Plugin Module for Tests',\n version: '0',\n },\n spec: {\n // Add metadata for all mock plugins\n plugins: mockPlugins.map(({ kind, spec: { name } }) => ({\n kind,\n spec: {\n name,\n display: {\n name: getMockPluginName(kind, name),\n },\n },\n })),\n },\n };\n\n const mockPluginModule: Record<string, Plugin<UnknownSpec>> = {};\n for (const mockPlugin of mockPlugins) {\n // \"Export\" on the module under the same name as the kind the plugin handles\n mockPluginModule[mockPlugin.spec.name] = mockPlugin.plugin;\n }\n\n const pluginLoader: PluginLoader = {\n getInstalledPlugins() {\n return Promise.resolve([mockPluginResource]);\n },\n importPluginModule(/* resource */) {\n return Promise.resolve(mockPluginModule);\n },\n };\n\n return {\n pluginLoader,\n defaultPluginKinds: {\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n },\n };\n}\n\n/**\n * The function that's used to generate the display name of mocked plugins in mockPluginRegistry. Can be useful if you\n * need to interact with some UI component that's displaying it.\n */\nexport function getMockPluginName(kind: PluginType, name: string): string {\n return `${kind} Plugin for ${name}`;\n}\n"],"names":["mockPluginRegistry","mockPlugins","mockPluginResource","kind","metadata","name","version","spec","plugins","map","display","getMockPluginName","mockPluginModule","mockPlugin","plugin","pluginLoader","getInstalledPlugins","Promise","resolve","importPluginModule","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAcjC;;;CAGC,GACD,OAAO,SAASA,mBAAmB,GAAGC,WAAyB;IAC7D,MAAMC,qBAA2C;QAC/CC,MAAM;QACNC,UAAU;YACRC,MAAM;YACNC,SAAS;QACX;QACAC,MAAM;YACJ,oCAAoC;YACpCC,SAASP,YAAYQ,GAAG,CAAC,CAAC,EAAEN,IAAI,EAAEI,MAAM,EAAEF,IAAI,EAAE,EAAE,GAAM,CAAA;oBACtDF;oBACAI,MAAM;wBACJF;wBACAK,SAAS;4BACPL,MAAMM,kBAAkBR,MAAME;wBAChC;oBACF;gBACF,CAAA;QACF;IACF;IAEA,MAAMO,mBAAwD,CAAC;IAC/D,KAAK,MAAMC,cAAcZ,YAAa;QACpC,4EAA4E;QAC5EW,gBAAgB,CAACC,WAAWN,IAAI,CAACF,IAAI,CAAC,GAAGQ,WAAWC,MAAM;IAC5D;IAEA,MAAMC,eAA6B;QACjCC;YACE,OAAOC,QAAQC,OAAO,CAAC;gBAAChB;aAAmB;QAC7C;QACAiB;YACE,OAAOF,QAAQC,OAAO,CAACN;QACzB;IACF;IAEA,OAAO;QACLG;QACAK,oBAAoB;YAClBC,iBAAiB;QACnB;IACF;AACF;AAEA;;;CAGC,GACD,OAAO,SAASV,kBAAkBR,IAAgB,EAAEE,IAAY;IAC9D,OAAO,GAAGF,KAAK,YAAY,EAAEE,MAAM;AACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/plugin-system",
|
|
3
|
-
"version": "0.51.0-beta.
|
|
3
|
+
"version": "0.51.0-beta.1",
|
|
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",
|
|
@@ -29,18 +29,16 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@module-federation/enhanced": "^0.8.9",
|
|
32
|
-
"@perses-dev/components": "0.51.0-beta.
|
|
33
|
-
"@perses-dev/core": "0.51.0-beta.
|
|
34
|
-
"date-fns": "^
|
|
35
|
-
"
|
|
32
|
+
"@perses-dev/components": "0.51.0-beta.1",
|
|
33
|
+
"@perses-dev/core": "0.51.0-beta.1",
|
|
34
|
+
"date-fns": "^4.1.0",
|
|
35
|
+
"date-fns-tz": "^3.2.0",
|
|
36
|
+
"immer": "^10.1.1",
|
|
36
37
|
"react-hook-form": "^7.46.1",
|
|
37
|
-
"use-immer": "^0.
|
|
38
|
+
"use-immer": "^0.11.0",
|
|
38
39
|
"use-query-params": "^2.1.2",
|
|
39
40
|
"zod": "^3.22.2"
|
|
40
41
|
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@perses-dev/storybook": "0.51.0-beta.0"
|
|
43
|
-
},
|
|
44
42
|
"peerDependencies": {
|
|
45
43
|
"@mui/material": "^6.1.10",
|
|
46
44
|
"@tanstack/react-query": "^5.64.2",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "WithDataQueries", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithDataQueries;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
-
// Type guard because storybook types parameters as `any`
|
|
26
|
-
function isWithDataQueriesParameter(parameter) {
|
|
27
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
28
|
-
}
|
|
29
|
-
const WithDataQueries = (Story, context)=>{
|
|
30
|
-
const initParameter = context.parameters.withDataQueries;
|
|
31
|
-
const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
|
|
32
|
-
props: {
|
|
33
|
-
definitions: []
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const props = parameter?.props;
|
|
37
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
|
|
38
|
-
...props,
|
|
39
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
40
|
-
});
|
|
41
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "WithPluginRegistry", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithPluginRegistry;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
-
const WithPluginRegistry = (Story)=>{
|
|
26
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginRegistry, {
|
|
27
|
-
pluginLoader: (0, _pluginsystem.remotePluginLoader)(),
|
|
28
|
-
defaultPluginKinds: {
|
|
29
|
-
TimeSeriesQuery: 'PrometheusTimeSeriesQuery',
|
|
30
|
-
TraceQuery: 'TempoTraceQuery'
|
|
31
|
-
},
|
|
32
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
33
|
-
});
|
|
34
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "WithPluginSystemBuiltinVariables", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithPluginSystemBuiltinVariables;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _runtime = require("../../../runtime");
|
|
25
|
-
// Type guard because storybook types parameters as `any`
|
|
26
|
-
function isWithBuiltinVariableParameter(parameter) {
|
|
27
|
-
return !!parameter && Array.isArray(parameter);
|
|
28
|
-
}
|
|
29
|
-
const WithPluginSystemBuiltinVariables = (Story, context)=>{
|
|
30
|
-
const initParameter = context.parameters.withPluginSystemBuiltinVariables;
|
|
31
|
-
const defaultValue = {
|
|
32
|
-
variables: []
|
|
33
|
-
};
|
|
34
|
-
const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : {
|
|
35
|
-
props: defaultValue
|
|
36
|
-
};
|
|
37
|
-
const props = parameter?.props;
|
|
38
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.BuiltinVariableContext.Provider, {
|
|
39
|
-
value: props,
|
|
40
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
41
|
-
});
|
|
42
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "WithPluginSystemDatasourceStore", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithPluginSystemDatasourceStore;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
-
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
26
|
-
// Type guard because storybook types parameters as `any`
|
|
27
|
-
function isWithDatastoreStoreParameter(parameter) {
|
|
28
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
29
|
-
}
|
|
30
|
-
const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
31
|
-
const { getPlugin } = (0, _pluginsystem.usePluginRegistry)();
|
|
32
|
-
const initParameter = context.parameters.withPluginSystemDatasourceStore;
|
|
33
|
-
// This currently provides a very simplified default to enable use in some
|
|
34
|
-
// basic stories. It likely will need expanding in the future.
|
|
35
|
-
// In general, `plugin-system` would probably benefit from a provider wrapper
|
|
36
|
-
// for `DatasourceStoreContext` that is more generic than the one available
|
|
37
|
-
// in the `dashboard` package for non-dashboard use cases.
|
|
38
|
-
const defaultValue = {
|
|
39
|
-
getDatasource: (selector)=>{
|
|
40
|
-
if (selector.kind === 'PrometheusDatasource') {
|
|
41
|
-
return Promise.resolve({
|
|
42
|
-
default: true,
|
|
43
|
-
plugin: {
|
|
44
|
-
kind: 'PrometheusDatasource',
|
|
45
|
-
spec: {}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
50
|
-
},
|
|
51
|
-
getDatasourceClient: async (selector)=>{
|
|
52
|
-
if (selector.kind === 'PrometheusDatasource') {
|
|
53
|
-
const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
|
|
54
|
-
const client = plugin.createClient({
|
|
55
|
-
directUrl: prometheusDemoUrl
|
|
56
|
-
}, {
|
|
57
|
-
proxyUrl: prometheusDemoUrl
|
|
58
|
-
});
|
|
59
|
-
return client;
|
|
60
|
-
}
|
|
61
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
62
|
-
},
|
|
63
|
-
listDatasourceSelectItems: async (datasourcePluginName)=>{
|
|
64
|
-
if (datasourcePluginName === 'PrometheusDatasource') {
|
|
65
|
-
return Promise.resolve([
|
|
66
|
-
{
|
|
67
|
-
items: [
|
|
68
|
-
{
|
|
69
|
-
name: 'PrometheusDatasource',
|
|
70
|
-
selector: {
|
|
71
|
-
kind: 'PrometheusDatasource'
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginName}`);
|
|
79
|
-
},
|
|
80
|
-
getSavedDatasources: ()=>{
|
|
81
|
-
return {};
|
|
82
|
-
},
|
|
83
|
-
setSavedDatasources: (datasources)=>{
|
|
84
|
-
return datasources;
|
|
85
|
-
},
|
|
86
|
-
getLocalDatasources: ()=>{
|
|
87
|
-
return {};
|
|
88
|
-
},
|
|
89
|
-
setLocalDatasources: (datasources)=>{
|
|
90
|
-
return datasources;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
|
|
94
|
-
props: defaultValue
|
|
95
|
-
};
|
|
96
|
-
const props = parameter?.props;
|
|
97
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceStoreContext.Provider, {
|
|
98
|
-
value: props,
|
|
99
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
100
|
-
});
|
|
101
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "WithPluginSystemVariables", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithPluginSystemVariables;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _runtime = require("../../../runtime");
|
|
25
|
-
// Type guard because storybook types parameters as `any`
|
|
26
|
-
function isWithVariableParameter(parameter) {
|
|
27
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
28
|
-
}
|
|
29
|
-
const WithPluginSystemVariables = (Story, context)=>{
|
|
30
|
-
const initParameter = context.parameters.withPluginSystemVariables;
|
|
31
|
-
const defaultValue = {
|
|
32
|
-
state: {}
|
|
33
|
-
};
|
|
34
|
-
const parameter = isWithVariableParameter(initParameter) ? initParameter : {
|
|
35
|
-
props: defaultValue
|
|
36
|
-
};
|
|
37
|
-
const props = parameter?.props;
|
|
38
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.VariableContext.Provider, {
|
|
39
|
-
value: props,
|
|
40
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
41
|
-
});
|
|
42
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "WithTimeRange", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithTimeRange;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
-
// Type guard because storybook types parameters as `any`
|
|
26
|
-
function isWithTimeRangeParameter(parameter) {
|
|
27
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
28
|
-
}
|
|
29
|
-
const WithTimeRange = (Story, context)=>{
|
|
30
|
-
const initParameter = context.parameters.withTimeRange;
|
|
31
|
-
const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
|
|
32
|
-
const props = parameter?.props;
|
|
33
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProvider, {
|
|
34
|
-
refreshInterval: "0s",
|
|
35
|
-
timeRange: {
|
|
36
|
-
pastDuration: '1h'
|
|
37
|
-
},
|
|
38
|
-
...props,
|
|
39
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
40
|
-
});
|
|
41
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
_export_star(require("./WithDataQueries"), exports);
|
|
18
|
-
_export_star(require("./WithPluginRegistry"), exports);
|
|
19
|
-
_export_star(require("./WithPluginSystemBuiltinVariables"), exports);
|
|
20
|
-
_export_star(require("./WithPluginSystemDatasourceStore"), exports);
|
|
21
|
-
_export_star(require("./WithPluginSystemVariables"), exports);
|
|
22
|
-
_export_star(require("./WithTimeRange"), exports);
|
|
23
|
-
function _export_star(from, to) {
|
|
24
|
-
Object.keys(from).forEach(function(k) {
|
|
25
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
26
|
-
Object.defineProperty(to, k, {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function() {
|
|
29
|
-
return from[k];
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return from;
|
|
35
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
_export_star(require("./decorators"), exports);
|
|
18
|
-
function _export_star(from, to) {
|
|
19
|
-
Object.keys(from).forEach(function(k) {
|
|
20
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
-
Object.defineProperty(to, k, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function() {
|
|
24
|
-
return from[k];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return from;
|
|
30
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DataQueriesProviderProps } from '@perses-dev/plugin-system';
|
|
2
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
3
|
-
import { ReactElement } from 'react';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withDataQueries?: WithDataQueriesProvideParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithDataQueriesProvideParameter = {
|
|
10
|
-
props: DataQueriesProviderProps;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithDataQueries: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithDataQueries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithDataQueries.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAuB,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,eAAe,CAAC,EAAE,+BAA+B,CAAC;KACnD;CACF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAYhF,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { DataQueriesProvider } from '@perses-dev/plugin-system';
|
|
15
|
-
// Type guard because storybook types parameters as `any`
|
|
16
|
-
function isWithDataQueriesParameter(parameter) {
|
|
17
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
18
|
-
}
|
|
19
|
-
export const WithDataQueries = (Story, context)=>{
|
|
20
|
-
const initParameter = context.parameters.withDataQueries;
|
|
21
|
-
const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
|
|
22
|
-
props: {
|
|
23
|
-
definitions: []
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const props = parameter?.props;
|
|
27
|
-
return /*#__PURE__*/ _jsx(DataQueriesProvider, {
|
|
28
|
-
...props,
|
|
29
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=WithDataQueries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { ReactElement } from 'react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDataQueries?: WithDataQueriesProvideParameter;\n }\n}\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>): ReactElement => {\n const initParameter = context.parameters.withDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","withDataQueries","props","definitions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,mBAAmB,QAAkC,4BAA4B;AAc1F,yDAAyD;AACzD,SAASC,2BACPC,SAAoD;IAEpD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,kBAAkB,CAACC,OAAgBC;IAC9C,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,eAAe;IACxD,MAAMN,YAAYD,2BAA2BK,iBACzCA,gBACA;QAAEG,OAAO;YAAEC,aAAa,EAAE;QAAmC;IAAE;IACnE,MAAMD,QAAQP,WAAWO;IAEzB,qBACE,KAACT;QAAqB,GAAGS,KAAK;kBAC5B,cAAA,KAACL;;AAGP,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithPluginRegistry.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,eAAO,MAAM,kBAAkB,UAAW,OAAO,KAAG,YAYnD,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { PluginRegistry, remotePluginLoader } from '@perses-dev/plugin-system';
|
|
15
|
-
export const WithPluginRegistry = (Story)=>{
|
|
16
|
-
return /*#__PURE__*/ _jsx(PluginRegistry, {
|
|
17
|
-
pluginLoader: remotePluginLoader(),
|
|
18
|
-
defaultPluginKinds: {
|
|
19
|
-
TimeSeriesQuery: 'PrometheusTimeSeriesQuery',
|
|
20
|
-
TraceQuery: 'TempoTraceQuery'
|
|
21
|
-
},
|
|
22
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=WithPluginRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginRegistry, remotePluginLoader } from '@perses-dev/plugin-system';\nimport { StoryFn } from '@storybook/react';\n\nimport { ReactElement } from 'react';\n\nexport const WithPluginRegistry = (Story: StoryFn): ReactElement => {\n return (\n <PluginRegistry\n pluginLoader={remotePluginLoader()}\n defaultPluginKinds={{\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n TraceQuery: 'TempoTraceQuery',\n }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","remotePluginLoader","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery","TraceQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,4BAA4B;AAK/E,OAAO,MAAMC,qBAAqB,CAACC;IACjC,qBACE,KAACH;QACCI,cAAcH;QACdI,oBAAoB;YAClBC,iBAAiB;YACjBC,YAAY;QACd;kBAEA,cAAA,KAACJ;;AAGP,EAAE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { BuiltinVariableSrv } from '../../../runtime';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withPluginSystemBuiltinVariables?: WithPluginSystemBuiltinVariableParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithPluginSystemBuiltinVariableParameter = {
|
|
10
|
-
props: BuiltinVariableSrv;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithPluginSystemBuiltinVariables: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithPluginSystemBuiltinVariables.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithPluginSystemBuiltinVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,gCAAgC,CAAC,EAAE,wCAAwC,CAAC;KAC7E;CACF;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAcF,eAAO,MAAM,gCAAgC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAcjG,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { BuiltinVariableContext } from '../../../runtime';
|
|
15
|
-
// Type guard because storybook types parameters as `any`
|
|
16
|
-
function isWithBuiltinVariableParameter(parameter) {
|
|
17
|
-
return !!parameter && Array.isArray(parameter);
|
|
18
|
-
}
|
|
19
|
-
// This decorator is used for non-dashboards package Builtin variable needs.
|
|
20
|
-
// Use the more specific decorator in the dashboards package when working with
|
|
21
|
-
// dashboards.
|
|
22
|
-
// This decorator includes "PluginSystem" in the name to differentiate it from
|
|
23
|
-
// the datasource store decorator in the `dashboards` package.
|
|
24
|
-
export const WithPluginSystemBuiltinVariables = (Story, context)=>{
|
|
25
|
-
const initParameter = context.parameters.withPluginSystemBuiltinVariables;
|
|
26
|
-
const defaultValue = {
|
|
27
|
-
variables: []
|
|
28
|
-
};
|
|
29
|
-
const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : {
|
|
30
|
-
props: defaultValue
|
|
31
|
-
};
|
|
32
|
-
const props = parameter?.props;
|
|
33
|
-
return /*#__PURE__*/ _jsx(BuiltinVariableContext.Provider, {
|
|
34
|
-
value: props,
|
|
35
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=WithPluginSystemBuiltinVariables.js.map
|