@perses-dev/plugin-system 0.0.0-snapshot-time-range-height-80d08fc → 0.0.0-snapshot-embed-import-errors-8906900
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/model/calculations.js +11 -4
- package/dist/cjs/runtime/datasources.js +9 -1
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js +3 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/runtime/datasources.d.ts +4 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +9 -0
- package/dist/runtime/datasources.js.map +1 -1
- package/package.json +3 -3
|
@@ -25,7 +25,14 @@ _export(exports, {
|
|
|
25
25
|
CALCULATIONS_CONFIG: ()=>CALCULATIONS_CONFIG,
|
|
26
26
|
DEFAULT_CALCULATION: ()=>DEFAULT_CALCULATION
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const _findLast = /*#__PURE__*/ _interopRequireDefault(require("lodash/findLast"));
|
|
29
|
+
const _meanBy = /*#__PURE__*/ _interopRequireDefault(require("lodash/meanBy"));
|
|
30
|
+
const _sumBy = /*#__PURE__*/ _interopRequireDefault(require("lodash/sumBy"));
|
|
31
|
+
function _interopRequireDefault(obj) {
|
|
32
|
+
return obj && obj.__esModule ? obj : {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
29
36
|
const CalculationsMap = {
|
|
30
37
|
First: first,
|
|
31
38
|
Last: last,
|
|
@@ -61,16 +68,16 @@ function last(values) {
|
|
|
61
68
|
return tuple === undefined ? undefined : getValue(tuple);
|
|
62
69
|
}
|
|
63
70
|
function lastNumber(values) {
|
|
64
|
-
const tuple = (0,
|
|
71
|
+
const tuple = (0, _findLast.default)(values, (tuple)=>isNaN(getValue(tuple)) === false);
|
|
65
72
|
return tuple === undefined ? undefined : getValue(tuple);
|
|
66
73
|
}
|
|
67
74
|
function mean(values) {
|
|
68
75
|
if (values.length <= 0) return undefined;
|
|
69
|
-
return (0,
|
|
76
|
+
return (0, _meanBy.default)(values, getValue);
|
|
70
77
|
}
|
|
71
78
|
function sum(values) {
|
|
72
79
|
if (values.length <= 0) return undefined;
|
|
73
|
-
return (0,
|
|
80
|
+
return (0, _sumBy.default)(values, getValue);
|
|
74
81
|
}
|
|
75
82
|
function getValue(valueTuple) {
|
|
76
83
|
return valueTuple[1];
|
|
@@ -23,7 +23,8 @@ function _export(target, all) {
|
|
|
23
23
|
_export(exports, {
|
|
24
24
|
DatasourceStoreContext: ()=>DatasourceStoreContext,
|
|
25
25
|
useDatasourceStore: ()=>useDatasourceStore,
|
|
26
|
-
useListDatasources: ()=>useListDatasources
|
|
26
|
+
useListDatasources: ()=>useListDatasources,
|
|
27
|
+
useDatasourceClient: ()=>useDatasourceClient
|
|
27
28
|
});
|
|
28
29
|
const _reactQuery = require("@tanstack/react-query");
|
|
29
30
|
const _react = require("react");
|
|
@@ -42,3 +43,10 @@ function useListDatasources(datasourcePluginKind) {
|
|
|
42
43
|
datasourcePluginKind
|
|
43
44
|
], ()=>listDatasourceMetadata(datasourcePluginKind));
|
|
44
45
|
}
|
|
46
|
+
function useDatasourceClient(selector) {
|
|
47
|
+
const store = useDatasourceStore();
|
|
48
|
+
return (0, _reactQuery.useQuery)([
|
|
49
|
+
'getDatasourceClient',
|
|
50
|
+
selector
|
|
51
|
+
], ()=>store.getDatasourceClient(selector));
|
|
52
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/model/calculations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/model/calculations.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,eAAO,MAAM,eAAe;;;;;;CAM3B,CAAC;AAEF,oBAAY,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AACF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAgB3E,CAAC;AAEX,eAAO,MAAM,mBAAmB,EAAE,eAAuB,CAAC;AAE1D,iBAAS,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAKhE;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGtE;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGhE;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAG/D"}
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import
|
|
13
|
+
import findLast from 'lodash/findLast';
|
|
14
|
+
import meanBy from 'lodash/meanBy';
|
|
15
|
+
import sumBy from 'lodash/sumBy';
|
|
14
16
|
export const CalculationsMap = {
|
|
15
17
|
First: first,
|
|
16
18
|
Last: last,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/calculations.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/model/calculations.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport findLast from 'lodash/findLast';\nimport meanBy from 'lodash/meanBy';\nimport sumBy from 'lodash/sumBy';\nimport { TimeSeriesValueTuple } from './time-series-queries';\n\nexport const CalculationsMap = {\n First: first,\n Last: last,\n LastNumber: lastNumber,\n Mean: mean,\n Sum: sum,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n};\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n First: {\n label: 'First',\n },\n Last: {\n label: 'Last',\n },\n LastNumber: {\n label: 'Last number',\n },\n Mean: {\n label: 'Mean',\n },\n Sum: {\n label: 'Sum',\n },\n} as const;\n\nexport const DEFAULT_CALCULATION: CalculationType = 'Sum';\n\nfunction first(values: TimeSeriesValueTuple[]): number | undefined {\n const tuple = values[0];\n return tuple === undefined ? undefined : getValue(tuple);\n}\n\nfunction last(values: TimeSeriesValueTuple[]): number | undefined {\n if (values.length <= 0) return undefined;\n\n const tuple = values[values.length - 1];\n return tuple === undefined ? undefined : getValue(tuple);\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): number | undefined {\n const tuple = findLast(values, (tuple) => isNaN(getValue(tuple)) === false);\n return tuple === undefined ? undefined : getValue(tuple);\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): number | undefined {\n if (values.length <= 0) return undefined;\n return meanBy(values, getValue);\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): number | undefined {\n if (values.length <= 0) return undefined;\n return sumBy(values, getValue);\n}\n\nfunction getValue(valueTuple: TimeSeriesValueTuple) {\n return valueTuple[1];\n}\n"],"names":["findLast","meanBy","sumBy","CalculationsMap","First","first","Last","last","LastNumber","lastNumber","Mean","mean","Sum","sum","CALCULATIONS_CONFIG","label","DEFAULT_CALCULATION","values","tuple","undefined","getValue","length","isNaN","valueTuple"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAOC,MAAM,MAAM,eAAe,CAAC;AACnC,OAAOC,KAAK,MAAM,cAAc,CAAC;AAGjC,OAAO,MAAMC,eAAe,GAAG;IAC7BC,KAAK,EAAEC,KAAK;IACZC,IAAI,EAAEC,IAAI;IACVC,UAAU,EAAEC,UAAU;IACtBC,IAAI,EAAEC,IAAI;IACVC,GAAG,EAAEC,GAAG;CACT,CAAC;AAOF,OAAO,MAAMC,mBAAmB,GAAyD;IACvFV,KAAK,EAAE;QACLW,KAAK,EAAE,OAAO;KACf;IACDT,IAAI,EAAE;QACJS,KAAK,EAAE,MAAM;KACd;IACDP,UAAU,EAAE;QACVO,KAAK,EAAE,aAAa;KACrB;IACDL,IAAI,EAAE;QACJK,KAAK,EAAE,MAAM;KACd;IACDH,GAAG,EAAE;QACHG,KAAK,EAAE,KAAK;KACb;CACF,AAAS,CAAC;AAEX,OAAO,MAAMC,mBAAmB,GAAoB,KAAK,CAAC;AAE1D,SAASX,KAAK,CAACY,MAA8B,EAAsB;IACjE,MAAMC,KAAK,GAAGD,MAAM,CAAC,CAAC,CAAC,AAAC;IACxB,OAAOC,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAASX,IAAI,CAACU,MAA8B,EAAsB;IAChE,IAAIA,MAAM,CAACI,MAAM,IAAI,CAAC,EAAE,OAAOF,SAAS,CAAC;IAEzC,MAAMD,KAAK,GAAGD,MAAM,CAACA,MAAM,CAACI,MAAM,GAAG,CAAC,CAAC,AAAC;IACxC,OAAOH,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAAST,UAAU,CAACQ,MAA8B,EAAsB;IACtE,MAAMC,KAAK,GAAGlB,QAAQ,CAACiB,MAAM,EAAE,CAACC,KAAK,GAAKI,KAAK,CAACF,QAAQ,CAACF,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,AAAC;IAC5E,OAAOA,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAASP,IAAI,CAACM,MAA8B,EAAsB;IAChE,IAAIA,MAAM,CAACI,MAAM,IAAI,CAAC,EAAE,OAAOF,SAAS,CAAC;IACzC,OAAOlB,MAAM,CAACgB,MAAM,EAAEG,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,SAASP,GAAG,CAACI,MAA8B,EAAsB;IAC/D,IAAIA,MAAM,CAACI,MAAM,IAAI,CAAC,EAAE,OAAOF,SAAS,CAAC;IACzC,OAAOjB,KAAK,CAACe,MAAM,EAAEG,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,SAASA,QAAQ,CAACG,UAAgC,EAAE;IAClD,OAAOA,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -22,4 +22,8 @@ export declare function useDatasourceStore(): DatasourceStore;
|
|
|
22
22
|
* instance, as well as its DatasourceSelector for referencing it.
|
|
23
23
|
*/
|
|
24
24
|
export declare function useListDatasources(datasourcePluginKind: string): import("@tanstack/react-query").UseQueryResult<DatasourceMetadata[], unknown>;
|
|
25
|
+
/**
|
|
26
|
+
* Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useDatasourceClient<Client>(selector: DatasourceSelector): import("@tanstack/react-query").UseQueryResult<Client, unknown>;
|
|
25
29
|
//# sourceMappingURL=datasources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAItE,MAAM,WAAW,eAAe;IAE9B,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAErE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3E;;OAEG;IACH,sBAAsB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,sDAAwD,CAAC;AAE5F,wBAAgB,kBAAkB,oBAMjC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,oBAAoB,EAAE,MAAM,iFAG9D"}
|
|
1
|
+
{"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAItE,MAAM,WAAW,eAAe;IAE9B,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAErE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3E;;OAEG;IACH,sBAAsB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,sDAAwD,CAAC;AAE5F,wBAAgB,kBAAkB,oBAMjC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,oBAAoB,EAAE,MAAM,iFAG9D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,mEAGvE"}
|
|
@@ -30,5 +30,14 @@ export function useDatasourceStore() {
|
|
|
30
30
|
datasourcePluginKind
|
|
31
31
|
], ()=>listDatasourceMetadata(datasourcePluginKind));
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.
|
|
35
|
+
*/ export function useDatasourceClient(selector) {
|
|
36
|
+
const store = useDatasourceStore();
|
|
37
|
+
return useQuery([
|
|
38
|
+
'getDatasourceClient',
|
|
39
|
+
selector
|
|
40
|
+
], ()=>store.getDatasourceClient(selector));
|
|
41
|
+
}
|
|
33
42
|
|
|
34
43
|
//# sourceMappingURL=datasources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/datasources.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\n\nexport interface DatasourceStore {\n // TODO: Do we even need this method?\n getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;\n\n /**\n * Given a DatasourceSelector, gets a `Client` object from the corresponding Datasource plugin.\n */\n getDatasourceClient<Client>(selector: DatasourceSelector): Promise<Client>;\n\n /**\n * Gets a list of datasource metadata for a plugin kind.\n */\n listDatasourceMetadata(datasourcePluginKind: string): Promise<DatasourceMetadata[]>;\n}\n\nexport interface DatasourceMetadata {\n name: string;\n selector: DatasourceSelector;\n}\n\nexport const DatasourceStoreContext = createContext<DatasourceStore | undefined>(undefined);\n\nexport function useDatasourceStore() {\n const ctx = useContext(DatasourceStoreContext);\n if (ctx === undefined) {\n throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Lists all available Datasource instances for a given datasource plugin kind. Returns a list with the name of that\n * instance, as well as its DatasourceSelector for referencing it.\n */\nexport function useListDatasources(datasourcePluginKind: string) {\n const { listDatasourceMetadata } = useDatasourceStore();\n return useQuery(['listDatasourceMetadata', datasourcePluginKind], () => listDatasourceMetadata(datasourcePluginKind));\n}\n"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasources","datasourcePluginKind","listDatasourceMetadata"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAQ,uBAAuB,CAAC;AACjD,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAsBlD,OAAO,MAAMC,sBAAsB,GAAGF,aAAa,CAA8BG,SAAS,CAAC,CAAC;AAE5F,OAAO,SAASC,kBAAkB,GAAG;IACnC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,sBAAsB,CAAC,AAAC;IAC/C,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED;;;CAGC,GACD,OAAO,SAASE,kBAAkB,CAACC,oBAA4B,EAAE;IAC/D,MAAM,EAAEC,sBAAsB,CAAA,EAAE,GAAGL,kBAAkB,EAAE,AAAC;IACxD,OAAOL,QAAQ,CAAC;QAAC,wBAAwB;QAAES,oBAAoB;KAAC,EAAE,IAAMC,sBAAsB,CAACD,oBAAoB,CAAC,CAAC,CAAC;AACxH,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/datasources.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\n\nexport interface DatasourceStore {\n // TODO: Do we even need this method?\n getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;\n\n /**\n * Given a DatasourceSelector, gets a `Client` object from the corresponding Datasource plugin.\n */\n getDatasourceClient<Client>(selector: DatasourceSelector): Promise<Client>;\n\n /**\n * Gets a list of datasource metadata for a plugin kind.\n */\n listDatasourceMetadata(datasourcePluginKind: string): Promise<DatasourceMetadata[]>;\n}\n\nexport interface DatasourceMetadata {\n name: string;\n selector: DatasourceSelector;\n}\n\nexport const DatasourceStoreContext = createContext<DatasourceStore | undefined>(undefined);\n\nexport function useDatasourceStore() {\n const ctx = useContext(DatasourceStoreContext);\n if (ctx === undefined) {\n throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Lists all available Datasource instances for a given datasource plugin kind. Returns a list with the name of that\n * instance, as well as its DatasourceSelector for referencing it.\n */\nexport function useListDatasources(datasourcePluginKind: string) {\n const { listDatasourceMetadata } = useDatasourceStore();\n return useQuery(['listDatasourceMetadata', datasourcePluginKind], () => listDatasourceMetadata(datasourcePluginKind));\n}\n\n/**\n * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.\n */\nexport function useDatasourceClient<Client>(selector: DatasourceSelector) {\n const store = useDatasourceStore();\n return useQuery<Client>(['getDatasourceClient', selector], () => store.getDatasourceClient<Client>(selector));\n}\n"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasources","datasourcePluginKind","listDatasourceMetadata","useDatasourceClient","selector","store","getDatasourceClient"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAQ,uBAAuB,CAAC;AACjD,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAsBlD,OAAO,MAAMC,sBAAsB,GAAGF,aAAa,CAA8BG,SAAS,CAAC,CAAC;AAE5F,OAAO,SAASC,kBAAkB,GAAG;IACnC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,sBAAsB,CAAC,AAAC;IAC/C,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED;;;CAGC,GACD,OAAO,SAASE,kBAAkB,CAACC,oBAA4B,EAAE;IAC/D,MAAM,EAAEC,sBAAsB,CAAA,EAAE,GAAGL,kBAAkB,EAAE,AAAC;IACxD,OAAOL,QAAQ,CAAC;QAAC,wBAAwB;QAAES,oBAAoB;KAAC,EAAE,IAAMC,sBAAsB,CAACD,oBAAoB,CAAC,CAAC,CAAC;AACxH,CAAC;AAED;;CAEC,GACD,OAAO,SAASE,mBAAmB,CAASC,QAA4B,EAAE;IACxE,MAAMC,KAAK,GAAGR,kBAAkB,EAAE,AAAC;IACnC,OAAOL,QAAQ,CAAS;QAAC,qBAAqB;QAAEY,QAAQ;KAAC,EAAE,IAAMC,KAAK,CAACC,mBAAmB,CAASF,QAAQ,CAAC,CAAC,CAAC;AAChH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/plugin-system",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-embed-import-errors-8906900",
|
|
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",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@perses-dev/components": "0.0.0-snapshot-
|
|
31
|
-
"@perses-dev/core": "0.0.0-snapshot-
|
|
30
|
+
"@perses-dev/components": "0.0.0-snapshot-embed-import-errors-8906900",
|
|
31
|
+
"@perses-dev/core": "0.0.0-snapshot-embed-import-errors-8906900",
|
|
32
32
|
"immer": "^9.0.15",
|
|
33
33
|
"use-immer": "^0.7.0",
|
|
34
34
|
"use-query-params": "^2.1.2"
|