@grafana/plugin-compat 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +12 -2
  3. package/dist/cjs/apps.cjs +34 -0
  4. package/dist/cjs/apps.cjs.map +1 -0
  5. package/dist/cjs/datasources/getDataSourceInstance.cjs +23 -0
  6. package/dist/cjs/datasources/getDataSourceInstance.cjs.map +1 -0
  7. package/dist/cjs/datasources/getDataSourceInstanceList.cjs +34 -0
  8. package/dist/cjs/datasources/getDataSourceInstanceList.cjs.map +1 -0
  9. package/dist/cjs/datasources/getDataSourceInstanceSettings.cjs +23 -0
  10. package/dist/cjs/datasources/getDataSourceInstanceSettings.cjs.map +1 -0
  11. package/dist/cjs/datasources/getDefaultDataSourceInstanceListItem.cjs +27 -0
  12. package/dist/cjs/datasources/getDefaultDataSourceInstanceListItem.cjs.map +1 -0
  13. package/dist/cjs/datasources/registerRuntimeDataSourceInstance.cjs +23 -0
  14. package/dist/cjs/datasources/registerRuntimeDataSourceInstance.cjs.map +1 -0
  15. package/dist/cjs/datasources/useDefaultDataSourceInstanceListItem.cjs +16 -0
  16. package/dist/cjs/datasources/useDefaultDataSourceInstanceListItem.cjs.map +1 -0
  17. package/dist/cjs/datasources.cjs +20 -0
  18. package/dist/cjs/datasources.cjs.map +1 -0
  19. package/dist/esm/datasources/getDataSourceInstance.mjs +5 -2
  20. package/dist/esm/datasources/getDataSourceInstance.mjs.map +1 -1
  21. package/dist/esm/datasources/getDataSourceInstanceList.mjs +5 -4
  22. package/dist/esm/datasources/getDataSourceInstanceList.mjs.map +1 -1
  23. package/dist/esm/datasources/getDataSourceInstanceSettings.mjs +5 -2
  24. package/dist/esm/datasources/getDataSourceInstanceSettings.mjs.map +1 -1
  25. package/dist/esm/datasources/getDefaultDataSourceInstanceListItem.mjs +11 -4
  26. package/dist/esm/datasources/getDefaultDataSourceInstanceListItem.mjs.map +1 -1
  27. package/dist/esm/datasources/registerRuntimeDataSourceInstance.mjs +19 -0
  28. package/dist/esm/datasources/registerRuntimeDataSourceInstance.mjs.map +1 -0
  29. package/dist/esm/datasources/useDefaultDataSourceInstanceListItem.mjs +6 -25
  30. package/dist/esm/datasources/useDefaultDataSourceInstanceListItem.mjs.map +1 -1
  31. package/dist/esm/datasources.mjs +1 -0
  32. package/dist/esm/datasources.mjs.map +1 -1
  33. package/dist/types/datasources/getDefaultDataSourceInstanceListItem.d.ts +2 -1
  34. package/dist/types/datasources/registerRuntimeDataSourceInstance.d.ts +2 -0
  35. package/dist/types/datasources/useDefaultDataSourceInstanceListItem.d.ts +4 -4
  36. package/dist/types/datasources.d.ts +1 -0
  37. package/package.json +14 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 0.4.0 (2026-10-09)
2
+
3
+ The data source functions now use the host's stable `@grafana/runtime` exports when available, then `@grafana/runtime/unstable`, then the legacy `getDataSourceSrv()` APIs, so they keep working on hosts that only expose the async APIs under `unstable`.
4
+
5
+ # 0.3.0 (2026-10-08)
6
+
7
+ Add `registerRuntimeDataSourceInstance` to `@grafana/plugin-compat/datasources`. It uses the host's async registry when available and falls back to `getDataSourceSrv().registerRuntimeDataSource` otherwise.
8
+
9
+ # 0.2.0 (2026-09-23)
10
+
11
+ Add a CommonJS build alongside the existing ESM build, so the package works with `require` as well as `import`.
12
+
1
13
  # 0.1.0 (2026-09-22)
2
14
 
3
- Initial release. `@grafana/plugin-compat` is in **ALPHA**; the API may change between minor versions.
15
+ Initial release. `@grafana/plugin-compat` is in **ALPHA**; the API may change between minor versions.
package/README.md CHANGED
@@ -11,13 +11,16 @@ Each function checks for the new host API at runtime and falls back to the
11
11
  legacy equivalent when it's not available, so a single call works across
12
12
  Grafana versions.
13
13
 
14
+ Ships both ESM and CommonJS builds, so it works with `import` and `require`.
15
+
14
16
  ## Domains
15
17
 
16
18
  - `@grafana/plugin-compat/datasources` — `getDataSourceInstance`,
17
19
  `getDataSourceInstanceList`, `getDataSourceInstanceSettings`,
18
20
  `getDefaultDataSourceInstanceListItem` and its
19
- `useDefaultDataSourceInstanceListItem` hook. Replacements for
20
- `getDataSourceSrv()` methods.
21
+ `useDefaultDataSourceInstanceListItem` hook, and
22
+ `registerRuntimeDataSourceInstance`. Replacements for `getDataSourceSrv()`
23
+ methods.
21
24
  - `@grafana/plugin-compat/apps` — `getPluginSettings`,
22
25
  `updateAppPluginSettings`. Replacements for the `getBackendSrv()`
23
26
  plugin-settings endpoints.
@@ -29,6 +32,7 @@ import {
29
32
  getDataSourceInstance,
30
33
  getDataSourceInstanceList,
31
34
  getDefaultDataSourceInstanceListItem,
35
+ registerRuntimeDataSourceInstance,
32
36
  useDefaultDataSourceInstanceListItem,
33
37
  } from '@grafana/plugin-compat/datasources';
34
38
  import { getPluginSettings } from '@grafana/plugin-compat/apps';
@@ -41,4 +45,10 @@ const items = await getDataSourceInstanceList({ type: 'prometheus' });
41
45
  const defaultProm = await getDefaultDataSourceInstanceListItem(items);
42
46
 
43
47
  const { isLoading, error, item } = useDefaultDataSourceInstanceListItem(items);
48
+
49
+ // Throws if a data source with the same uid is already registered.
50
+ registerRuntimeDataSourceInstance({ dataSource: new MyRuntimeDataSource('my-plugin-id', 'my-uid') });
44
51
  ```
52
+
53
+ On hosts with the async APIs, a data source registered this way is not visible
54
+ to `getDataSourceSrv()`. Look it up with `getDataSourceInstance` instead.
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+
8
+ "use strict";
9
+ async function getPluginSettings(pluginId, showErrorAlert = false) {
10
+ if (typeof unstable.getPluginSettings === "function") {
11
+ return unstable.getPluginSettings(pluginId, showErrorAlert);
12
+ }
13
+ return backwardsCompatibleGetPluginSettings(pluginId, showErrorAlert);
14
+ }
15
+ async function backwardsCompatibleGetPluginSettings(pluginId, showErrorAlert = false) {
16
+ return runtime.getBackendSrv().get(`/api/plugins/${pluginId}/settings`, void 0, void 0, {
17
+ showErrorAlert,
18
+ validatePath: true
19
+ });
20
+ }
21
+ async function updateAppPluginSettings(pluginId, data) {
22
+ if (typeof unstable.updateAppPluginSettings === "function") {
23
+ return unstable.updateAppPluginSettings(pluginId, data);
24
+ }
25
+ return backwardsCompatibleUpdatePluginSettings(pluginId, data);
26
+ }
27
+ async function backwardsCompatibleUpdatePluginSettings(pluginId, data) {
28
+ await runtime.getBackendSrv().post(`/api/plugins/${pluginId}/settings`, data, { validatePath: true });
29
+ return backwardsCompatibleGetPluginSettings(pluginId);
30
+ }
31
+
32
+ exports.getPluginSettings = getPluginSettings;
33
+ exports.updateAppPluginSettings = updateAppPluginSettings;
34
+ //# sourceMappingURL=apps.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apps.cjs","sources":["../../src/apps.ts"],"sourcesContent":["import { type PluginMeta } from '@grafana/data';\nimport { getBackendSrv } from '@grafana/runtime';\nimport {\n getPluginSettings as runtimeGetPluginSettings,\n updateAppPluginSettings as runtimeUpdateAppPluginSettings,\n} from '@grafana/runtime/unstable';\n\nexport async function getPluginSettings(pluginId: string, showErrorAlert = false): Promise<PluginMeta> {\n if (typeof runtimeGetPluginSettings === 'function') {\n return runtimeGetPluginSettings(pluginId, showErrorAlert);\n }\n\n return backwardsCompatibleGetPluginSettings(pluginId, showErrorAlert);\n}\n\nasync function backwardsCompatibleGetPluginSettings(pluginId: string, showErrorAlert = false): Promise<PluginMeta> {\n return getBackendSrv().get(`/api/plugins/${pluginId}/settings`, undefined, undefined, {\n showErrorAlert,\n validatePath: true,\n });\n}\n\nexport async function updateAppPluginSettings(pluginId: string, data: Partial<PluginMeta>): Promise<PluginMeta> {\n if (typeof runtimeUpdateAppPluginSettings === 'function') {\n return runtimeUpdateAppPluginSettings(pluginId, data);\n }\n\n return backwardsCompatibleUpdatePluginSettings(pluginId, data);\n}\n\nasync function backwardsCompatibleUpdatePluginSettings(\n pluginId: string,\n data: Partial<PluginMeta>\n): Promise<PluginMeta> {\n await getBackendSrv().post(`/api/plugins/${pluginId}/settings`, data, { validatePath: true });\n return backwardsCompatibleGetPluginSettings(pluginId);\n}\n"],"names":["runtimeGetPluginSettings","getBackendSrv","runtimeUpdateAppPluginSettings"],"mappings":";;;;;;;;AAOA,eAAsB,iBAAA,CAAkB,QAAA,EAAkB,cAAA,GAAiB,KAAA,EAA4B;AACrG,EAAA,IAAI,OAAOA,+BAA6B,UAAA,EAAY;AAClD,IAAA,OAAOA,0BAAA,CAAyB,UAAU,cAAc,CAAA;AAAA,EAC1D;AAEA,EAAA,OAAO,oCAAA,CAAqC,UAAU,cAAc,CAAA;AACtE;AAEA,eAAe,oCAAA,CAAqC,QAAA,EAAkB,cAAA,GAAiB,KAAA,EAA4B;AACjH,EAAA,OAAOC,uBAAc,CAAE,GAAA,CAAI,gBAAgB,QAAQ,CAAA,SAAA,CAAA,EAAa,QAAW,KAAA,CAAA,EAAW;AAAA,IACpF,cAAA;AAAA,IACA,YAAA,EAAc;AAAA,GACf,CAAA;AACH;AAEA,eAAsB,uBAAA,CAAwB,UAAkB,IAAA,EAAgD;AAC9G,EAAA,IAAI,OAAOC,qCAAmC,UAAA,EAAY;AACxD,IAAA,OAAOA,gCAAA,CAA+B,UAAU,IAAI,CAAA;AAAA,EACtD;AAEA,EAAA,OAAO,uCAAA,CAAwC,UAAU,IAAI,CAAA;AAC/D;AAEA,eAAe,uCAAA,CACb,UACA,IAAA,EACqB;AACrB,EAAA,MAAMD,qBAAA,EAAc,CAAE,IAAA,CAAK,CAAA,aAAA,EAAgB,QAAQ,aAAa,IAAA,EAAM,EAAE,YAAA,EAAc,IAAA,EAAM,CAAA;AAC5F,EAAA,OAAO,qCAAqC,QAAQ,CAAA;AACtD;;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+
8
+ "use strict";
9
+ async function getDataSourceInstance(ref, scopedVars) {
10
+ if (typeof runtime.getDataSourceInstance === "function") {
11
+ return runtime.getDataSourceInstance(ref, scopedVars);
12
+ }
13
+ if (typeof unstable.getDataSourceInstance === "function") {
14
+ return unstable.getDataSourceInstance(ref, scopedVars);
15
+ }
16
+ return backwardsCompatibleGetDataSourceInstance(ref, scopedVars);
17
+ }
18
+ async function backwardsCompatibleGetDataSourceInstance(ref, scopedVars) {
19
+ return runtime.getDataSourceSrv().get(ref, scopedVars);
20
+ }
21
+
22
+ exports.getDataSourceInstance = getDataSourceInstance;
23
+ //# sourceMappingURL=getDataSourceInstance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDataSourceInstance.cjs","sources":["../../../src/datasources/getDataSourceInstance.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceApi, type ScopedVars } from '@grafana/data';\nimport { getDataSourceSrv, getDataSourceInstance as stableGetDataSourceInstance } from '@grafana/runtime';\nimport { getDataSourceInstance as unstableGetDataSourceInstance } from '@grafana/runtime/unstable';\n\nimport { type Ref } from './types';\n\nexport async function getDataSourceInstance(ref?: Ref, scopedVars?: ScopedVars): Promise<DataSourceApi> {\n if (typeof stableGetDataSourceInstance === 'function') {\n return stableGetDataSourceInstance(ref, scopedVars);\n }\n\n if (typeof unstableGetDataSourceInstance === 'function') {\n return unstableGetDataSourceInstance(ref, scopedVars);\n }\n\n return backwardsCompatibleGetDataSourceInstance(ref, scopedVars);\n}\n\nasync function backwardsCompatibleGetDataSourceInstance(ref?: Ref, scopedVars?: ScopedVars): Promise<DataSourceApi> {\n return getDataSourceSrv().get(ref, scopedVars);\n}\n"],"names":["stableGetDataSourceInstance","unstableGetDataSourceInstance","getDataSourceSrv"],"mappings":";;;;;;;;AAOA,eAAsB,qBAAA,CAAsB,KAAW,UAAA,EAAiD;AACtG,EAAA,IAAI,OAAOA,kCAAgC,UAAA,EAAY;AACrD,IAAA,OAAOA,6BAAA,CAA4B,KAAK,UAAU,CAAA;AAAA,EACpD;AAEA,EAAA,IAAI,OAAOC,mCAAkC,UAAA,EAAY;AACvD,IAAA,OAAOA,8BAAA,CAA8B,KAAK,UAAU,CAAA;AAAA,EACtD;AAEA,EAAA,OAAO,wCAAA,CAAyC,KAAK,UAAU,CAAA;AACjE;AAEA,eAAe,wCAAA,CAAyC,KAAW,UAAA,EAAiD;AAClH,EAAA,OAAOC,wBAAA,EAAiB,CAAE,GAAA,CAAI,GAAA,EAAK,UAAU,CAAA;AAC/C;;;;"}
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+
8
+ "use strict";
9
+ async function getDataSourceInstanceList(filters) {
10
+ if (typeof runtime.getDataSourceInstanceList === "function") {
11
+ return runtime.getDataSourceInstanceList(filters);
12
+ }
13
+ if (typeof unstable.getDataSourceInstanceList === "function") {
14
+ return unstable.getDataSourceInstanceList(filters);
15
+ }
16
+ return backwardsCompatibleGetDataSourceInstanceList(filters);
17
+ }
18
+ async function backwardsCompatibleGetDataSourceInstanceList(filters) {
19
+ const { filter, ...rest } = filters != null ? filters : {};
20
+ const legacyFilters = filter ? { ...rest, filter: (item) => filter(toDataSourceInstanceListItem(item)) } : { ...rest };
21
+ return runtime.getDataSourceSrv().getList(legacyFilters).map(toDataSourceInstanceListItem);
22
+ }
23
+ function toDataSourceInstanceListItem(item) {
24
+ return {
25
+ meta: { ...item.meta },
26
+ name: item.name,
27
+ type: item.type,
28
+ uid: item.uid,
29
+ apiVersion: item.apiVersion
30
+ };
31
+ }
32
+
33
+ exports.getDataSourceInstanceList = getDataSourceInstanceList;
34
+ //# sourceMappingURL=getDataSourceInstanceList.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDataSourceInstanceList.cjs","sources":["../../../src/datasources/getDataSourceInstanceList.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceInstanceListItem, type DataSourceInstanceSettings } from '@grafana/data';\nimport {\n type GetDataSourceListFilters,\n getDataSourceSrv,\n getDataSourceInstanceList as stableGetDataSourceInstanceList,\n} from '@grafana/runtime';\nimport {\n type GetDataSourceInstanceListFilters,\n getDataSourceInstanceList as unstableGetDataSourceInstanceList,\n} from '@grafana/runtime/unstable';\n\nexport async function getDataSourceInstanceList(\n filters?: GetDataSourceInstanceListFilters\n): Promise<DataSourceInstanceListItem[]> {\n if (typeof stableGetDataSourceInstanceList === 'function') {\n return stableGetDataSourceInstanceList(filters);\n }\n\n if (typeof unstableGetDataSourceInstanceList === 'function') {\n return unstableGetDataSourceInstanceList(filters);\n }\n\n return backwardsCompatibleGetDataSourceInstanceList(filters);\n}\n\nasync function backwardsCompatibleGetDataSourceInstanceList(\n filters?: GetDataSourceInstanceListFilters\n): Promise<DataSourceInstanceListItem[]> {\n const { filter, ...rest } = filters ?? {};\n const legacyFilters: GetDataSourceListFilters = filter\n ? { ...rest, filter: (item) => filter(toDataSourceInstanceListItem(item)) }\n : { ...rest };\n\n return getDataSourceSrv().getList(legacyFilters).map(toDataSourceInstanceListItem);\n}\n\nfunction toDataSourceInstanceListItem(item: DataSourceInstanceSettings): DataSourceInstanceListItem {\n return {\n meta: { ...item.meta },\n name: item.name,\n type: item.type,\n uid: item.uid,\n apiVersion: item.apiVersion,\n };\n}\n"],"names":["stableGetDataSourceInstanceList","unstableGetDataSourceInstanceList","getDataSourceSrv"],"mappings":";;;;;;;;AAYA,eAAsB,0BACpB,OAAA,EACuC;AACvC,EAAA,IAAI,OAAOA,sCAAoC,UAAA,EAAY;AACzD,IAAA,OAAOA,kCAAgC,OAAO,CAAA;AAAA,EAChD;AAEA,EAAA,IAAI,OAAOC,uCAAsC,UAAA,EAAY;AAC3D,IAAA,OAAOA,mCAAkC,OAAO,CAAA;AAAA,EAClD;AAEA,EAAA,OAAO,6CAA6C,OAAO,CAAA;AAC7D;AAEA,eAAe,6CACb,OAAA,EACuC;AACvC,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,IAAA,EAAK,GAAI,4BAAW,EAAC;AACxC,EAAA,MAAM,gBAA0C,MAAA,GAC5C,EAAE,GAAG,IAAA,EAAM,QAAQ,CAAC,IAAA,KAAS,MAAA,CAAO,4BAAA,CAA6B,IAAI,CAAC,CAAA,EAAE,GACxE,EAAE,GAAG,IAAA,EAAK;AAEd,EAAA,OAAOC,0BAAiB,CAAE,OAAA,CAAQ,aAAa,CAAA,CAAE,IAAI,4BAA4B,CAAA;AACnF;AAEA,SAAS,6BAA6B,IAAA,EAA8D;AAClG,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,EAAE,GAAG,IAAA,CAAK,IAAA,EAAK;AAAA,IACrB,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,KAAK,IAAA,CAAK,GAAA;AAAA,IACV,YAAY,IAAA,CAAK;AAAA,GACnB;AACF;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+
8
+ "use strict";
9
+ async function getDataSourceInstanceSettings(ref, scopedVars) {
10
+ if (typeof runtime.getDataSourceInstanceSettings === "function") {
11
+ return runtime.getDataSourceInstanceSettings(ref, scopedVars);
12
+ }
13
+ if (typeof unstable.getDataSourceInstanceSettings === "function") {
14
+ return unstable.getDataSourceInstanceSettings(ref, scopedVars);
15
+ }
16
+ return backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars);
17
+ }
18
+ async function backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars) {
19
+ return runtime.getDataSourceSrv().getInstanceSettings(ref, scopedVars);
20
+ }
21
+
22
+ exports.getDataSourceInstanceSettings = getDataSourceInstanceSettings;
23
+ //# sourceMappingURL=getDataSourceInstanceSettings.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDataSourceInstanceSettings.cjs","sources":["../../../src/datasources/getDataSourceInstanceSettings.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type ScopedVars, type DataSourceInstanceSettings } from '@grafana/data';\nimport {\n getDataSourceSrv,\n getDataSourceInstanceSettings as stableGetDataSourceInstanceSettings,\n} from '@grafana/runtime';\nimport { getDataSourceInstanceSettings as unstableGetDataSourceInstanceSettings } from '@grafana/runtime/unstable';\n\nimport { type Ref } from './types';\n\nexport async function getDataSourceInstanceSettings(\n ref?: Ref,\n scopedVars?: ScopedVars\n): Promise<DataSourceInstanceSettings | undefined> {\n if (typeof stableGetDataSourceInstanceSettings === 'function') {\n return stableGetDataSourceInstanceSettings(ref, scopedVars);\n }\n\n if (typeof unstableGetDataSourceInstanceSettings === 'function') {\n return unstableGetDataSourceInstanceSettings(ref, scopedVars);\n }\n\n return backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars);\n}\n\nasync function backwardsCompatibleDataSourceInstanceSettings(\n ref?: Ref,\n scopedVars?: ScopedVars\n): Promise<DataSourceInstanceSettings | undefined> {\n return getDataSourceSrv().getInstanceSettings(ref, scopedVars);\n}\n"],"names":["stableGetDataSourceInstanceSettings","unstableGetDataSourceInstanceSettings","getDataSourceSrv"],"mappings":";;;;;;;;AAUA,eAAsB,6BAAA,CACpB,KACA,UAAA,EACiD;AACjD,EAAA,IAAI,OAAOA,0CAAwC,UAAA,EAAY;AAC7D,IAAA,OAAOA,qCAAA,CAAoC,KAAK,UAAU,CAAA;AAAA,EAC5D;AAEA,EAAA,IAAI,OAAOC,2CAA0C,UAAA,EAAY;AAC/D,IAAA,OAAOA,sCAAA,CAAsC,KAAK,UAAU,CAAA;AAAA,EAC9D;AAEA,EAAA,OAAO,6CAAA,CAA8C,KAAK,UAAU,CAAA;AACtE;AAEA,eAAe,6CAAA,CACb,KACA,UAAA,EACiD;AACjD,EAAA,OAAOC,wBAAA,EAAiB,CAAE,mBAAA,CAAoB,GAAA,EAAK,UAAU,CAAA;AAC/D;;;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+
8
+ "use strict";
9
+ async function getDefaultDataSourceInstanceListItem(items) {
10
+ if (typeof runtime.getDefaultDataSourceInstanceListItem === "function") {
11
+ return runtime.getDefaultDataSourceInstanceListItem(items);
12
+ }
13
+ if (typeof unstable.getDefaultDataSourceInstanceListItem === "function") {
14
+ return unstable.getDefaultDataSourceInstanceListItem(items);
15
+ }
16
+ return backwardsCompatibleGetDefaultDataSourceInstanceListItem(items);
17
+ }
18
+ function backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) {
19
+ return items.find((item) => {
20
+ var _a;
21
+ return item && ((_a = runtime.getDataSourceSrv().getInstanceSettings(item.uid)) == null ? void 0 : _a.isDefault);
22
+ });
23
+ }
24
+
25
+ exports.backwardsCompatibleGetDefaultDataSourceInstanceListItem = backwardsCompatibleGetDefaultDataSourceInstanceListItem;
26
+ exports.getDefaultDataSourceInstanceListItem = getDefaultDataSourceInstanceListItem;
27
+ //# sourceMappingURL=getDefaultDataSourceInstanceListItem.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultDataSourceInstanceListItem.cjs","sources":["../../../src/datasources/getDefaultDataSourceInstanceListItem.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceInstanceListItem } from '@grafana/data';\nimport {\n getDataSourceSrv,\n getDefaultDataSourceInstanceListItem as stableGetDefaultDataSourceInstanceListItem,\n} from '@grafana/runtime';\nimport { getDefaultDataSourceInstanceListItem as unstableGetDefaultDataSourceInstanceListItem } from '@grafana/runtime/unstable';\n\n/**\n * Resolve the item whose data source is the org default, or `undefined` when the list holds none.\n *\n * At most one instance per org carries the flag, so a filtered list need not contain it.\n */\nexport async function getDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): Promise<DataSourceInstanceListItem | undefined> {\n if (typeof stableGetDefaultDataSourceInstanceListItem === 'function') {\n return stableGetDefaultDataSourceInstanceListItem(items);\n }\n\n if (typeof unstableGetDefaultDataSourceInstanceListItem === 'function') {\n return unstableGetDefaultDataSourceInstanceListItem(items);\n }\n\n return backwardsCompatibleGetDefaultDataSourceInstanceListItem(items);\n}\n\nexport function backwardsCompatibleGetDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): DataSourceInstanceListItem | undefined {\n return items.find((item) => item && getDataSourceSrv().getInstanceSettings(item.uid)?.isDefault);\n}\n"],"names":["stableGetDefaultDataSourceInstanceListItem","unstableGetDefaultDataSourceInstanceListItem"],"mappings":";;;;;;;;AAaA,eAAsB,qCACpB,KAAA,EACiD;AACjD,EAAA,IAAI,OAAOA,iDAA+C,UAAA,EAAY;AACpE,IAAA,OAAOA,6CAA2C,KAAK,CAAA;AAAA,EACzD;AAEA,EAAA,IAAI,OAAOC,kDAAiD,UAAA,EAAY;AACtE,IAAA,OAAOA,8CAA6C,KAAK,CAAA;AAAA,EAC3D;AAEA,EAAA,OAAO,wDAAwD,KAAK,CAAA;AACtE;AAEO,SAAS,wDACd,KAAA,EACwC;AACxC,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,CAAC,IAAA,KAAM;AA9B3B,IAAA,IAAA,EAAA;AA8B8B,IAAA,OAAA,IAAA,KAAA,CAAQ,+BAAiB,CAAE,mBAAA,CAAoB,IAAA,CAAK,GAAG,MAA/C,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkD,SAAA,CAAA;AAAA,EAAA,CAAS,CAAA;AACjG;;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+
8
+ "use strict";
9
+ function registerRuntimeDataSourceInstance(entry) {
10
+ if (typeof runtime.registerRuntimeDataSourceInstance === "function") {
11
+ return runtime.registerRuntimeDataSourceInstance(entry);
12
+ }
13
+ if (typeof unstable.registerRuntimeDataSourceInstance === "function") {
14
+ return unstable.registerRuntimeDataSourceInstance(entry);
15
+ }
16
+ return backwardsCompatibleRegisterRuntimeDataSourceInstance(entry);
17
+ }
18
+ function backwardsCompatibleRegisterRuntimeDataSourceInstance(entry) {
19
+ return runtime.getDataSourceSrv().registerRuntimeDataSource(entry);
20
+ }
21
+
22
+ exports.registerRuntimeDataSourceInstance = registerRuntimeDataSourceInstance;
23
+ //# sourceMappingURL=registerRuntimeDataSourceInstance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerRuntimeDataSourceInstance.cjs","sources":["../../../src/datasources/registerRuntimeDataSourceInstance.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport {\n getDataSourceSrv,\n type RuntimeDataSourceRegistration,\n registerRuntimeDataSourceInstance as stableRegisterRuntimeDataSourceInstance,\n} from '@grafana/runtime';\nimport { registerRuntimeDataSourceInstance as unstableRegisterRuntimeDataSourceInstance } from '@grafana/runtime/unstable';\n\nexport function registerRuntimeDataSourceInstance(entry: RuntimeDataSourceRegistration): void {\n if (typeof stableRegisterRuntimeDataSourceInstance === 'function') {\n return stableRegisterRuntimeDataSourceInstance(entry);\n }\n\n if (typeof unstableRegisterRuntimeDataSourceInstance === 'function') {\n return unstableRegisterRuntimeDataSourceInstance(entry);\n }\n\n return backwardsCompatibleRegisterRuntimeDataSourceInstance(entry);\n}\n\nfunction backwardsCompatibleRegisterRuntimeDataSourceInstance(entry: RuntimeDataSourceRegistration): void {\n return getDataSourceSrv().registerRuntimeDataSource(entry);\n}\n"],"names":["stableRegisterRuntimeDataSourceInstance","unstableRegisterRuntimeDataSourceInstance","getDataSourceSrv"],"mappings":";;;;;;;;AAQO,SAAS,kCAAkC,KAAA,EAA4C;AAC5F,EAAA,IAAI,OAAOA,8CAA4C,UAAA,EAAY;AACjE,IAAA,OAAOA,0CAAwC,KAAK,CAAA;AAAA,EACtD;AAEA,EAAA,IAAI,OAAOC,+CAA8C,UAAA,EAAY;AACnE,IAAA,OAAOA,2CAA0C,KAAK,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,qDAAqD,KAAK,CAAA;AACnE;AAEA,SAAS,qDAAqD,KAAA,EAA4C;AACxG,EAAA,OAAOC,wBAAA,EAAiB,CAAE,yBAAA,CAA0B,KAAK,CAAA;AAC3D;;;;"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var runtime = require('@grafana/runtime');
6
+ var unstable = require('@grafana/runtime/unstable');
7
+ var getDefaultDataSourceInstanceListItem = require('./getDefaultDataSourceInstanceListItem.cjs');
8
+
9
+ "use strict";
10
+ const useDefaultDataSourceInstanceListItem = typeof runtime.useDefaultDataSourceInstanceListItem === "function" ? runtime.useDefaultDataSourceInstanceListItem : typeof unstable.useDefaultDataSourceInstanceListItem === "function" ? unstable.useDefaultDataSourceInstanceListItem : useBackwardsCompatibleDefaultDataSourceInstanceListItem;
11
+ function useBackwardsCompatibleDefaultDataSourceInstanceListItem(items) {
12
+ return { isLoading: false, item: getDefaultDataSourceInstanceListItem.backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) };
13
+ }
14
+
15
+ exports.useDefaultDataSourceInstanceListItem = useDefaultDataSourceInstanceListItem;
16
+ //# sourceMappingURL=useDefaultDataSourceInstanceListItem.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDefaultDataSourceInstanceListItem.cjs","sources":["../../../src/datasources/useDefaultDataSourceInstanceListItem.ts"],"sourcesContent":["import { type DataSourceInstanceListItem } from '@grafana/data';\nimport { useDefaultDataSourceInstanceListItem as stableUseDefaultDataSourceInstanceListItem } from '@grafana/runtime';\nimport { useDefaultDataSourceInstanceListItem as unstableUseDefaultDataSourceInstanceListItem } from '@grafana/runtime/unstable';\n\nimport { backwardsCompatibleGetDefaultDataSourceInstanceListItem } from './getDefaultDataSourceInstanceListItem';\n\n/** Declared here because `@grafana/runtime` lacks it on older supported hosts. */\nexport interface UseDefaultDataSourceInstanceListItemResult {\n isLoading: boolean;\n error?: Error;\n item?: DataSourceInstanceListItem;\n}\n\n/**\n * Uses the host hook when available, which also re-resolves on data source cache changes; otherwise\n * resolves synchronously on every render. Picked once at load so the hook order stays stable.\n */\nexport const useDefaultDataSourceInstanceListItem: (\n items: DataSourceInstanceListItem[]\n) => UseDefaultDataSourceInstanceListItemResult =\n typeof stableUseDefaultDataSourceInstanceListItem === 'function'\n ? stableUseDefaultDataSourceInstanceListItem\n : typeof unstableUseDefaultDataSourceInstanceListItem === 'function'\n ? unstableUseDefaultDataSourceInstanceListItem\n : useBackwardsCompatibleDefaultDataSourceInstanceListItem;\n\nfunction useBackwardsCompatibleDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): UseDefaultDataSourceInstanceListItemResult {\n return { isLoading: false, item: backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) };\n}\n"],"names":["stableUseDefaultDataSourceInstanceListItem","unstableUseDefaultDataSourceInstanceListItem","backwardsCompatibleGetDefaultDataSourceInstanceListItem"],"mappings":";;;;;;;;;AAiBO,MAAM,oCAAA,GAGX,OAAOA,4CAAA,KAA+C,UAAA,GAClDA,+CACA,OAAOC,6CAAA,KAAiD,aACtDA,6CAAA,GACA;AAER,SAAS,wDACP,KAAA,EAC4C;AAC5C,EAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,IAAA,EAAMC,4FAAA,CAAwD,KAAK,CAAA,EAAE;AAClG;;;;"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getDataSourceInstance = require('./datasources/getDataSourceInstance.cjs');
6
+ var getDataSourceInstanceList = require('./datasources/getDataSourceInstanceList.cjs');
7
+ var getDataSourceInstanceSettings = require('./datasources/getDataSourceInstanceSettings.cjs');
8
+ var getDefaultDataSourceInstanceListItem = require('./datasources/getDefaultDataSourceInstanceListItem.cjs');
9
+ var registerRuntimeDataSourceInstance = require('./datasources/registerRuntimeDataSourceInstance.cjs');
10
+ var useDefaultDataSourceInstanceListItem = require('./datasources/useDefaultDataSourceInstanceListItem.cjs');
11
+
12
+ "use strict";
13
+
14
+ exports.getDataSourceInstance = getDataSourceInstance.getDataSourceInstance;
15
+ exports.getDataSourceInstanceList = getDataSourceInstanceList.getDataSourceInstanceList;
16
+ exports.getDataSourceInstanceSettings = getDataSourceInstanceSettings.getDataSourceInstanceSettings;
17
+ exports.getDefaultDataSourceInstanceListItem = getDefaultDataSourceInstanceListItem.getDefaultDataSourceInstanceListItem;
18
+ exports.registerRuntimeDataSourceInstance = registerRuntimeDataSourceInstance.registerRuntimeDataSourceInstance;
19
+ exports.useDefaultDataSourceInstanceListItem = useDefaultDataSourceInstanceListItem.useDefaultDataSourceInstanceListItem;
20
+ //# sourceMappingURL=datasources.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasources.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
@@ -1,11 +1,14 @@
1
- import { getDataSourceSrv } from '@grafana/runtime';
2
- import { getDataSourceInstance as getDataSourceInstance$1 } from '@grafana/runtime/unstable';
1
+ import { getDataSourceInstance as getDataSourceInstance$1, getDataSourceSrv } from '@grafana/runtime';
2
+ import { getDataSourceInstance as getDataSourceInstance$2 } from '@grafana/runtime/unstable';
3
3
 
4
4
  "use strict";
5
5
  async function getDataSourceInstance(ref, scopedVars) {
6
6
  if (typeof getDataSourceInstance$1 === "function") {
7
7
  return getDataSourceInstance$1(ref, scopedVars);
8
8
  }
9
+ if (typeof getDataSourceInstance$2 === "function") {
10
+ return getDataSourceInstance$2(ref, scopedVars);
11
+ }
9
12
  return backwardsCompatibleGetDataSourceInstance(ref, scopedVars);
10
13
  }
11
14
  async function backwardsCompatibleGetDataSourceInstance(ref, scopedVars) {
@@ -1 +1 @@
1
- {"version":3,"file":"getDataSourceInstance.mjs","sources":["../../../src/datasources/getDataSourceInstance.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceApi, type ScopedVars } from '@grafana/data';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { getDataSourceInstance as rtGetDataSourceInstance } from '@grafana/runtime/unstable';\n\nimport { type Ref } from './types';\n\nexport async function getDataSourceInstance(ref?: Ref, scopedVars?: ScopedVars): Promise<DataSourceApi> {\n if (typeof rtGetDataSourceInstance === 'function') {\n return rtGetDataSourceInstance(ref, scopedVars);\n }\n\n return backwardsCompatibleGetDataSourceInstance(ref, scopedVars);\n}\n\nasync function backwardsCompatibleGetDataSourceInstance(ref?: Ref, scopedVars?: ScopedVars): Promise<DataSourceApi> {\n return getDataSourceSrv().get(ref, scopedVars);\n}\n"],"names":["rtGetDataSourceInstance"],"mappings":";;;;AAOA,eAAsB,qBAAA,CAAsB,KAAW,UAAA,EAAiD;AACtG,EAAA,IAAI,OAAOA,4BAA4B,UAAA,EAAY;AACjD,IAAA,OAAOA,uBAAA,CAAwB,KAAK,UAAU,CAAA;AAAA,EAChD;AAEA,EAAA,OAAO,wCAAA,CAAyC,KAAK,UAAU,CAAA;AACjE;AAEA,eAAe,wCAAA,CAAyC,KAAW,UAAA,EAAiD;AAClH,EAAA,OAAO,gBAAA,EAAiB,CAAE,GAAA,CAAI,GAAA,EAAK,UAAU,CAAA;AAC/C;;;;"}
1
+ {"version":3,"file":"getDataSourceInstance.mjs","sources":["../../../src/datasources/getDataSourceInstance.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceApi, type ScopedVars } from '@grafana/data';\nimport { getDataSourceSrv, getDataSourceInstance as stableGetDataSourceInstance } from '@grafana/runtime';\nimport { getDataSourceInstance as unstableGetDataSourceInstance } from '@grafana/runtime/unstable';\n\nimport { type Ref } from './types';\n\nexport async function getDataSourceInstance(ref?: Ref, scopedVars?: ScopedVars): Promise<DataSourceApi> {\n if (typeof stableGetDataSourceInstance === 'function') {\n return stableGetDataSourceInstance(ref, scopedVars);\n }\n\n if (typeof unstableGetDataSourceInstance === 'function') {\n return unstableGetDataSourceInstance(ref, scopedVars);\n }\n\n return backwardsCompatibleGetDataSourceInstance(ref, scopedVars);\n}\n\nasync function backwardsCompatibleGetDataSourceInstance(ref?: Ref, scopedVars?: ScopedVars): Promise<DataSourceApi> {\n return getDataSourceSrv().get(ref, scopedVars);\n}\n"],"names":["stableGetDataSourceInstance","unstableGetDataSourceInstance"],"mappings":";;;;AAOA,eAAsB,qBAAA,CAAsB,KAAW,UAAA,EAAiD;AACtG,EAAA,IAAI,OAAOA,4BAAgC,UAAA,EAAY;AACrD,IAAA,OAAOA,uBAAA,CAA4B,KAAK,UAAU,CAAA;AAAA,EACpD;AAEA,EAAA,IAAI,OAAOC,4BAAkC,UAAA,EAAY;AACvD,IAAA,OAAOA,uBAAA,CAA8B,KAAK,UAAU,CAAA;AAAA,EACtD;AAEA,EAAA,OAAO,wCAAA,CAAyC,KAAK,UAAU,CAAA;AACjE;AAEA,eAAe,wCAAA,CAAyC,KAAW,UAAA,EAAiD;AAClH,EAAA,OAAO,gBAAA,EAAiB,CAAE,GAAA,CAAI,GAAA,EAAK,UAAU,CAAA;AAC/C;;;;"}
@@ -1,11 +1,14 @@
1
- import { getDataSourceSrv } from '@grafana/runtime';
2
- import { getDataSourceInstanceList as getDataSourceInstanceList$1 } from '@grafana/runtime/unstable';
1
+ import { getDataSourceInstanceList as getDataSourceInstanceList$1, getDataSourceSrv } from '@grafana/runtime';
2
+ import { getDataSourceInstanceList as getDataSourceInstanceList$2 } from '@grafana/runtime/unstable';
3
3
 
4
4
  "use strict";
5
5
  async function getDataSourceInstanceList(filters) {
6
6
  if (typeof getDataSourceInstanceList$1 === "function") {
7
7
  return getDataSourceInstanceList$1(filters);
8
8
  }
9
+ if (typeof getDataSourceInstanceList$2 === "function") {
10
+ return getDataSourceInstanceList$2(filters);
11
+ }
9
12
  return backwardsCompatibleGetDataSourceInstanceList(filters);
10
13
  }
11
14
  async function backwardsCompatibleGetDataSourceInstanceList(filters) {
@@ -14,9 +17,7 @@ async function backwardsCompatibleGetDataSourceInstanceList(filters) {
14
17
  return getDataSourceSrv().getList(legacyFilters).map(toDataSourceInstanceListItem);
15
18
  }
16
19
  function toDataSourceInstanceListItem(item) {
17
- var _a;
18
20
  return {
19
- isDefault: (_a = item.isDefault) != null ? _a : false,
20
21
  meta: { ...item.meta },
21
22
  name: item.name,
22
23
  type: item.type,
@@ -1 +1 @@
1
- {"version":3,"file":"getDataSourceInstanceList.mjs","sources":["../../../src/datasources/getDataSourceInstanceList.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceInstanceListItem, type DataSourceInstanceSettings } from '@grafana/data';\nimport { type GetDataSourceListFilters, getDataSourceSrv } from '@grafana/runtime';\nimport {\n type GetDataSourceInstanceListFilters,\n getDataSourceInstanceList as rtGetDataSourceInstanceList,\n} from '@grafana/runtime/unstable';\n\nexport async function getDataSourceInstanceList(\n filters?: GetDataSourceInstanceListFilters\n): Promise<DataSourceInstanceListItem[]> {\n if (typeof rtGetDataSourceInstanceList === 'function') {\n return rtGetDataSourceInstanceList(filters);\n }\n\n return backwardsCompatibleGetDataSourceInstanceList(filters);\n}\n\nasync function backwardsCompatibleGetDataSourceInstanceList(\n filters?: GetDataSourceInstanceListFilters\n): Promise<DataSourceInstanceListItem[]> {\n const { filter, ...rest } = filters ?? {};\n const legacyFilters: GetDataSourceListFilters = filter\n ? { ...rest, filter: (item) => filter(toDataSourceInstanceListItem(item)) }\n : { ...rest };\n\n return getDataSourceSrv().getList(legacyFilters).map(toDataSourceInstanceListItem);\n}\n\nfunction toDataSourceInstanceListItem(item: DataSourceInstanceSettings): DataSourceInstanceListItem {\n return {\n isDefault: item.isDefault ?? false,\n meta: { ...item.meta },\n name: item.name,\n type: item.type,\n uid: item.uid,\n apiVersion: item.apiVersion,\n };\n}\n"],"names":["rtGetDataSourceInstanceList"],"mappings":";;;;AAQA,eAAsB,0BACpB,OAAA,EACuC;AACvC,EAAA,IAAI,OAAOA,gCAAgC,UAAA,EAAY;AACrD,IAAA,OAAOA,4BAA4B,OAAO,CAAA;AAAA,EAC5C;AAEA,EAAA,OAAO,6CAA6C,OAAO,CAAA;AAC7D;AAEA,eAAe,6CACb,OAAA,EACuC;AACvC,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,IAAA,EAAK,GAAI,4BAAW,EAAC;AACxC,EAAA,MAAM,gBAA0C,MAAA,GAC5C,EAAE,GAAG,IAAA,EAAM,QAAQ,CAAC,IAAA,KAAS,MAAA,CAAO,4BAAA,CAA6B,IAAI,CAAC,CAAA,EAAE,GACxE,EAAE,GAAG,IAAA,EAAK;AAEd,EAAA,OAAO,kBAAiB,CAAE,OAAA,CAAQ,aAAa,CAAA,CAAE,IAAI,4BAA4B,CAAA;AACnF;AAEA,SAAS,6BAA6B,IAAA,EAA8D;AA7BpG,EAAA,IAAA,EAAA;AA8BE,EAAA,OAAO;AAAA,IACL,SAAA,EAAA,CAAW,EAAA,GAAA,IAAA,CAAK,SAAA,KAAL,IAAA,GAAA,EAAA,GAAkB,KAAA;AAAA,IAC7B,IAAA,EAAM,EAAE,GAAG,IAAA,CAAK,IAAA,EAAK;AAAA,IACrB,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,KAAK,IAAA,CAAK,GAAA;AAAA,IACV,YAAY,IAAA,CAAK;AAAA,GACnB;AACF;;;;"}
1
+ {"version":3,"file":"getDataSourceInstanceList.mjs","sources":["../../../src/datasources/getDataSourceInstanceList.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceInstanceListItem, type DataSourceInstanceSettings } from '@grafana/data';\nimport {\n type GetDataSourceListFilters,\n getDataSourceSrv,\n getDataSourceInstanceList as stableGetDataSourceInstanceList,\n} from '@grafana/runtime';\nimport {\n type GetDataSourceInstanceListFilters,\n getDataSourceInstanceList as unstableGetDataSourceInstanceList,\n} from '@grafana/runtime/unstable';\n\nexport async function getDataSourceInstanceList(\n filters?: GetDataSourceInstanceListFilters\n): Promise<DataSourceInstanceListItem[]> {\n if (typeof stableGetDataSourceInstanceList === 'function') {\n return stableGetDataSourceInstanceList(filters);\n }\n\n if (typeof unstableGetDataSourceInstanceList === 'function') {\n return unstableGetDataSourceInstanceList(filters);\n }\n\n return backwardsCompatibleGetDataSourceInstanceList(filters);\n}\n\nasync function backwardsCompatibleGetDataSourceInstanceList(\n filters?: GetDataSourceInstanceListFilters\n): Promise<DataSourceInstanceListItem[]> {\n const { filter, ...rest } = filters ?? {};\n const legacyFilters: GetDataSourceListFilters = filter\n ? { ...rest, filter: (item) => filter(toDataSourceInstanceListItem(item)) }\n : { ...rest };\n\n return getDataSourceSrv().getList(legacyFilters).map(toDataSourceInstanceListItem);\n}\n\nfunction toDataSourceInstanceListItem(item: DataSourceInstanceSettings): DataSourceInstanceListItem {\n return {\n meta: { ...item.meta },\n name: item.name,\n type: item.type,\n uid: item.uid,\n apiVersion: item.apiVersion,\n };\n}\n"],"names":["stableGetDataSourceInstanceList","unstableGetDataSourceInstanceList"],"mappings":";;;;AAYA,eAAsB,0BACpB,OAAA,EACuC;AACvC,EAAA,IAAI,OAAOA,gCAAoC,UAAA,EAAY;AACzD,IAAA,OAAOA,4BAAgC,OAAO,CAAA;AAAA,EAChD;AAEA,EAAA,IAAI,OAAOC,gCAAsC,UAAA,EAAY;AAC3D,IAAA,OAAOA,4BAAkC,OAAO,CAAA;AAAA,EAClD;AAEA,EAAA,OAAO,6CAA6C,OAAO,CAAA;AAC7D;AAEA,eAAe,6CACb,OAAA,EACuC;AACvC,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,IAAA,EAAK,GAAI,4BAAW,EAAC;AACxC,EAAA,MAAM,gBAA0C,MAAA,GAC5C,EAAE,GAAG,IAAA,EAAM,QAAQ,CAAC,IAAA,KAAS,MAAA,CAAO,4BAAA,CAA6B,IAAI,CAAC,CAAA,EAAE,GACxE,EAAE,GAAG,IAAA,EAAK;AAEd,EAAA,OAAO,kBAAiB,CAAE,OAAA,CAAQ,aAAa,CAAA,CAAE,IAAI,4BAA4B,CAAA;AACnF;AAEA,SAAS,6BAA6B,IAAA,EAA8D;AAClG,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,EAAE,GAAG,IAAA,CAAK,IAAA,EAAK;AAAA,IACrB,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,KAAK,IAAA,CAAK,GAAA;AAAA,IACV,YAAY,IAAA,CAAK;AAAA,GACnB;AACF;;;;"}
@@ -1,11 +1,14 @@
1
- import { getDataSourceSrv } from '@grafana/runtime';
2
- import { getDataSourceInstanceSettings as getDataSourceInstanceSettings$1 } from '@grafana/runtime/unstable';
1
+ import { getDataSourceInstanceSettings as getDataSourceInstanceSettings$1, getDataSourceSrv } from '@grafana/runtime';
2
+ import { getDataSourceInstanceSettings as getDataSourceInstanceSettings$2 } from '@grafana/runtime/unstable';
3
3
 
4
4
  "use strict";
5
5
  async function getDataSourceInstanceSettings(ref, scopedVars) {
6
6
  if (typeof getDataSourceInstanceSettings$1 === "function") {
7
7
  return getDataSourceInstanceSettings$1(ref, scopedVars);
8
8
  }
9
+ if (typeof getDataSourceInstanceSettings$2 === "function") {
10
+ return getDataSourceInstanceSettings$2(ref, scopedVars);
11
+ }
9
12
  return backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars);
10
13
  }
11
14
  async function backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars) {
@@ -1 +1 @@
1
- {"version":3,"file":"getDataSourceInstanceSettings.mjs","sources":["../../../src/datasources/getDataSourceInstanceSettings.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type ScopedVars, type DataSourceInstanceSettings } from '@grafana/data';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { getDataSourceInstanceSettings as rtGetDataSourceInstanceSettings } from '@grafana/runtime/unstable';\n\nimport { type Ref } from './types';\n\nexport async function getDataSourceInstanceSettings(\n ref?: Ref,\n scopedVars?: ScopedVars\n): Promise<DataSourceInstanceSettings | undefined> {\n if (typeof rtGetDataSourceInstanceSettings === 'function') {\n return rtGetDataSourceInstanceSettings(ref, scopedVars);\n }\n\n return backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars);\n}\n\nasync function backwardsCompatibleDataSourceInstanceSettings(\n ref?: Ref,\n scopedVars?: ScopedVars\n): Promise<DataSourceInstanceSettings | undefined> {\n return getDataSourceSrv().getInstanceSettings(ref, scopedVars);\n}\n"],"names":["rtGetDataSourceInstanceSettings"],"mappings":";;;;AAOA,eAAsB,6BAAA,CACpB,KACA,UAAA,EACiD;AACjD,EAAA,IAAI,OAAOA,oCAAoC,UAAA,EAAY;AACzD,IAAA,OAAOA,+BAAA,CAAgC,KAAK,UAAU,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,6CAAA,CAA8C,KAAK,UAAU,CAAA;AACtE;AAEA,eAAe,6CAAA,CACb,KACA,UAAA,EACiD;AACjD,EAAA,OAAO,gBAAA,EAAiB,CAAE,mBAAA,CAAoB,GAAA,EAAK,UAAU,CAAA;AAC/D;;;;"}
1
+ {"version":3,"file":"getDataSourceInstanceSettings.mjs","sources":["../../../src/datasources/getDataSourceInstanceSettings.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type ScopedVars, type DataSourceInstanceSettings } from '@grafana/data';\nimport {\n getDataSourceSrv,\n getDataSourceInstanceSettings as stableGetDataSourceInstanceSettings,\n} from '@grafana/runtime';\nimport { getDataSourceInstanceSettings as unstableGetDataSourceInstanceSettings } from '@grafana/runtime/unstable';\n\nimport { type Ref } from './types';\n\nexport async function getDataSourceInstanceSettings(\n ref?: Ref,\n scopedVars?: ScopedVars\n): Promise<DataSourceInstanceSettings | undefined> {\n if (typeof stableGetDataSourceInstanceSettings === 'function') {\n return stableGetDataSourceInstanceSettings(ref, scopedVars);\n }\n\n if (typeof unstableGetDataSourceInstanceSettings === 'function') {\n return unstableGetDataSourceInstanceSettings(ref, scopedVars);\n }\n\n return backwardsCompatibleDataSourceInstanceSettings(ref, scopedVars);\n}\n\nasync function backwardsCompatibleDataSourceInstanceSettings(\n ref?: Ref,\n scopedVars?: ScopedVars\n): Promise<DataSourceInstanceSettings | undefined> {\n return getDataSourceSrv().getInstanceSettings(ref, scopedVars);\n}\n"],"names":["stableGetDataSourceInstanceSettings","unstableGetDataSourceInstanceSettings"],"mappings":";;;;AAUA,eAAsB,6BAAA,CACpB,KACA,UAAA,EACiD;AACjD,EAAA,IAAI,OAAOA,oCAAwC,UAAA,EAAY;AAC7D,IAAA,OAAOA,+BAAA,CAAoC,KAAK,UAAU,CAAA;AAAA,EAC5D;AAEA,EAAA,IAAI,OAAOC,oCAA0C,UAAA,EAAY;AAC/D,IAAA,OAAOA,+BAAA,CAAsC,KAAK,UAAU,CAAA;AAAA,EAC9D;AAEA,EAAA,OAAO,6CAAA,CAA8C,KAAK,UAAU,CAAA;AACtE;AAEA,eAAe,6CAAA,CACb,KACA,UAAA,EACiD;AACjD,EAAA,OAAO,gBAAA,EAAiB,CAAE,mBAAA,CAAoB,GAAA,EAAK,UAAU,CAAA;AAC/D;;;;"}
@@ -1,15 +1,22 @@
1
- import { getDefaultDataSourceInstanceListItem as getDefaultDataSourceInstanceListItem$1 } from '@grafana/runtime/unstable';
1
+ import { getDefaultDataSourceInstanceListItem as getDefaultDataSourceInstanceListItem$1, getDataSourceSrv } from '@grafana/runtime';
2
+ import { getDefaultDataSourceInstanceListItem as getDefaultDataSourceInstanceListItem$2 } from '@grafana/runtime/unstable';
2
3
 
3
4
  "use strict";
4
5
  async function getDefaultDataSourceInstanceListItem(items) {
5
6
  if (typeof getDefaultDataSourceInstanceListItem$1 === "function") {
6
7
  return getDefaultDataSourceInstanceListItem$1(items);
7
8
  }
9
+ if (typeof getDefaultDataSourceInstanceListItem$2 === "function") {
10
+ return getDefaultDataSourceInstanceListItem$2(items);
11
+ }
8
12
  return backwardsCompatibleGetDefaultDataSourceInstanceListItem(items);
9
13
  }
10
- async function backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) {
11
- return items.find((item) => item == null ? void 0 : item.isDefault);
14
+ function backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) {
15
+ return items.find((item) => {
16
+ var _a;
17
+ return item && ((_a = getDataSourceSrv().getInstanceSettings(item.uid)) == null ? void 0 : _a.isDefault);
18
+ });
12
19
  }
13
20
 
14
- export { getDefaultDataSourceInstanceListItem };
21
+ export { backwardsCompatibleGetDefaultDataSourceInstanceListItem, getDefaultDataSourceInstanceListItem };
15
22
  //# sourceMappingURL=getDefaultDataSourceInstanceListItem.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultDataSourceInstanceListItem.mjs","sources":["../../../src/datasources/getDefaultDataSourceInstanceListItem.ts"],"sourcesContent":["import { type DataSourceInstanceListItem } from '@grafana/data';\nimport { getDefaultDataSourceInstanceListItem as rtGetDefaultDataSourceInstanceListItem } from '@grafana/runtime/unstable';\n\n/**\n * Resolve the item flagged as the default data source, or `undefined` when the list holds none.\n *\n * At most one instance per org carries the flag, so a filtered list need not contain it.\n */\nexport async function getDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): Promise<DataSourceInstanceListItem | undefined> {\n if (typeof rtGetDefaultDataSourceInstanceListItem === 'function') {\n return rtGetDefaultDataSourceInstanceListItem(items);\n }\n\n return backwardsCompatibleGetDefaultDataSourceInstanceListItem(items);\n}\n\nasync function backwardsCompatibleGetDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): Promise<DataSourceInstanceListItem | undefined> {\n return items.find((item) => item?.isDefault);\n}\n"],"names":["rtGetDefaultDataSourceInstanceListItem"],"mappings":";;;AAQA,eAAsB,qCACpB,KAAA,EACiD;AACjD,EAAA,IAAI,OAAOA,2CAA2C,UAAA,EAAY;AAChE,IAAA,OAAOA,uCAAuC,KAAK,CAAA;AAAA,EACrD;AAEA,EAAA,OAAO,wDAAwD,KAAK,CAAA;AACtE;AAEA,eAAe,wDACb,KAAA,EACiD;AACjD,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,CAAC,IAAA,KAAS,6BAAM,SAAS,CAAA;AAC7C;;;;"}
1
+ {"version":3,"file":"getDefaultDataSourceInstanceListItem.mjs","sources":["../../../src/datasources/getDefaultDataSourceInstanceListItem.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport { type DataSourceInstanceListItem } from '@grafana/data';\nimport {\n getDataSourceSrv,\n getDefaultDataSourceInstanceListItem as stableGetDefaultDataSourceInstanceListItem,\n} from '@grafana/runtime';\nimport { getDefaultDataSourceInstanceListItem as unstableGetDefaultDataSourceInstanceListItem } from '@grafana/runtime/unstable';\n\n/**\n * Resolve the item whose data source is the org default, or `undefined` when the list holds none.\n *\n * At most one instance per org carries the flag, so a filtered list need not contain it.\n */\nexport async function getDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): Promise<DataSourceInstanceListItem | undefined> {\n if (typeof stableGetDefaultDataSourceInstanceListItem === 'function') {\n return stableGetDefaultDataSourceInstanceListItem(items);\n }\n\n if (typeof unstableGetDefaultDataSourceInstanceListItem === 'function') {\n return unstableGetDefaultDataSourceInstanceListItem(items);\n }\n\n return backwardsCompatibleGetDefaultDataSourceInstanceListItem(items);\n}\n\nexport function backwardsCompatibleGetDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): DataSourceInstanceListItem | undefined {\n return items.find((item) => item && getDataSourceSrv().getInstanceSettings(item.uid)?.isDefault);\n}\n"],"names":["stableGetDefaultDataSourceInstanceListItem","unstableGetDefaultDataSourceInstanceListItem"],"mappings":";;;;AAaA,eAAsB,qCACpB,KAAA,EACiD;AACjD,EAAA,IAAI,OAAOA,2CAA+C,UAAA,EAAY;AACpE,IAAA,OAAOA,uCAA2C,KAAK,CAAA;AAAA,EACzD;AAEA,EAAA,IAAI,OAAOC,2CAAiD,UAAA,EAAY;AACtE,IAAA,OAAOA,uCAA6C,KAAK,CAAA;AAAA,EAC3D;AAEA,EAAA,OAAO,wDAAwD,KAAK,CAAA;AACtE;AAEO,SAAS,wDACd,KAAA,EACwC;AACxC,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,CAAC,IAAA,KAAM;AA9B3B,IAAA,IAAA,EAAA;AA8B8B,IAAA,OAAA,IAAA,KAAA,CAAQ,uBAAiB,CAAE,mBAAA,CAAoB,IAAA,CAAK,GAAG,MAA/C,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkD,SAAA,CAAA;AAAA,EAAA,CAAS,CAAA;AACjG;;;;"}
@@ -0,0 +1,19 @@
1
+ import { registerRuntimeDataSourceInstance as registerRuntimeDataSourceInstance$1, getDataSourceSrv } from '@grafana/runtime';
2
+ import { registerRuntimeDataSourceInstance as registerRuntimeDataSourceInstance$2 } from '@grafana/runtime/unstable';
3
+
4
+ "use strict";
5
+ function registerRuntimeDataSourceInstance(entry) {
6
+ if (typeof registerRuntimeDataSourceInstance$1 === "function") {
7
+ return registerRuntimeDataSourceInstance$1(entry);
8
+ }
9
+ if (typeof registerRuntimeDataSourceInstance$2 === "function") {
10
+ return registerRuntimeDataSourceInstance$2(entry);
11
+ }
12
+ return backwardsCompatibleRegisterRuntimeDataSourceInstance(entry);
13
+ }
14
+ function backwardsCompatibleRegisterRuntimeDataSourceInstance(entry) {
15
+ return getDataSourceSrv().registerRuntimeDataSource(entry);
16
+ }
17
+
18
+ export { registerRuntimeDataSourceInstance };
19
+ //# sourceMappingURL=registerRuntimeDataSourceInstance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerRuntimeDataSourceInstance.mjs","sources":["../../../src/datasources/registerRuntimeDataSourceInstance.ts"],"sourcesContent":["/* eslint-disable @grafana/no-get-data-source-srv */\nimport {\n getDataSourceSrv,\n type RuntimeDataSourceRegistration,\n registerRuntimeDataSourceInstance as stableRegisterRuntimeDataSourceInstance,\n} from '@grafana/runtime';\nimport { registerRuntimeDataSourceInstance as unstableRegisterRuntimeDataSourceInstance } from '@grafana/runtime/unstable';\n\nexport function registerRuntimeDataSourceInstance(entry: RuntimeDataSourceRegistration): void {\n if (typeof stableRegisterRuntimeDataSourceInstance === 'function') {\n return stableRegisterRuntimeDataSourceInstance(entry);\n }\n\n if (typeof unstableRegisterRuntimeDataSourceInstance === 'function') {\n return unstableRegisterRuntimeDataSourceInstance(entry);\n }\n\n return backwardsCompatibleRegisterRuntimeDataSourceInstance(entry);\n}\n\nfunction backwardsCompatibleRegisterRuntimeDataSourceInstance(entry: RuntimeDataSourceRegistration): void {\n return getDataSourceSrv().registerRuntimeDataSource(entry);\n}\n"],"names":["stableRegisterRuntimeDataSourceInstance","unstableRegisterRuntimeDataSourceInstance"],"mappings":";;;;AAQO,SAAS,kCAAkC,KAAA,EAA4C;AAC5F,EAAA,IAAI,OAAOA,wCAA4C,UAAA,EAAY;AACjE,IAAA,OAAOA,oCAAwC,KAAK,CAAA;AAAA,EACtD;AAEA,EAAA,IAAI,OAAOC,wCAA8C,UAAA,EAAY;AACnE,IAAA,OAAOA,oCAA0C,KAAK,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,qDAAqD,KAAK,CAAA;AACnE;AAEA,SAAS,qDAAqD,KAAA,EAA4C;AACxG,EAAA,OAAO,gBAAA,EAAiB,CAAE,yBAAA,CAA0B,KAAK,CAAA;AAC3D;;;;"}
@@ -1,30 +1,11 @@
1
- import { useState, useEffect } from 'react';
2
- import { getDefaultDataSourceInstanceListItem } from './getDefaultDataSourceInstanceListItem.mjs';
1
+ import { useDefaultDataSourceInstanceListItem as useDefaultDataSourceInstanceListItem$1 } from '@grafana/runtime';
2
+ import { useDefaultDataSourceInstanceListItem as useDefaultDataSourceInstanceListItem$2 } from '@grafana/runtime/unstable';
3
+ import { backwardsCompatibleGetDefaultDataSourceInstanceListItem } from './getDefaultDataSourceInstanceListItem.mjs';
3
4
 
4
5
  "use strict";
5
- function useDefaultDataSourceInstanceListItem(items) {
6
- const [result, setResult] = useState({ isLoading: true });
7
- const itemsKey = JSON.stringify(items.map((item) => [item == null ? void 0 : item.uid, item == null ? void 0 : item.isDefault]));
8
- useEffect(() => {
9
- let active = true;
10
- setResult({ isLoading: true });
11
- getDefaultDataSourceInstanceListItem(items).then(
12
- (item) => {
13
- if (active) {
14
- setResult({ isLoading: false, item });
15
- }
16
- },
17
- (err) => {
18
- if (active) {
19
- setResult({ isLoading: false, error: err instanceof Error ? err : new Error(String(err)) });
20
- }
21
- }
22
- );
23
- return () => {
24
- active = false;
25
- };
26
- }, [itemsKey]);
27
- return result;
6
+ const useDefaultDataSourceInstanceListItem = typeof useDefaultDataSourceInstanceListItem$1 === "function" ? useDefaultDataSourceInstanceListItem$1 : typeof useDefaultDataSourceInstanceListItem$2 === "function" ? useDefaultDataSourceInstanceListItem$2 : useBackwardsCompatibleDefaultDataSourceInstanceListItem;
7
+ function useBackwardsCompatibleDefaultDataSourceInstanceListItem(items) {
8
+ return { isLoading: false, item: backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) };
28
9
  }
29
10
 
30
11
  export { useDefaultDataSourceInstanceListItem };
@@ -1 +1 @@
1
- {"version":3,"file":"useDefaultDataSourceInstanceListItem.mjs","sources":["../../../src/datasources/useDefaultDataSourceInstanceListItem.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { type DataSourceInstanceListItem } from '@grafana/data';\n\nimport { getDefaultDataSourceInstanceListItem } from './getDefaultDataSourceInstanceListItem';\n\n/** Declared here because `@grafana/runtime/unstable` lacks it on older supported hosts. */\nexport interface UseDefaultDataSourceInstanceListItemResult {\n isLoading: boolean;\n error?: Error;\n item?: DataSourceInstanceListItem;\n}\n\n/**\n * React hook wrapping {@link getDefaultDataSourceInstanceListItem}. Re-resolves when the uid or\n * `isDefault` flag of any item changes, so passing an inline array is safe.\n */\nexport function useDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): UseDefaultDataSourceInstanceListItemResult {\n const [result, setResult] = useState<UseDefaultDataSourceInstanceListItemResult>({ isLoading: true });\n const itemsKey = JSON.stringify(items.map((item) => [item?.uid, item?.isDefault]));\n\n useEffect(() => {\n let active = true;\n setResult({ isLoading: true });\n\n getDefaultDataSourceInstanceListItem(items).then(\n (item) => {\n if (active) {\n setResult({ isLoading: false, item });\n }\n },\n (err: unknown) => {\n if (active) {\n setResult({ isLoading: false, error: err instanceof Error ? err : new Error(String(err)) });\n }\n }\n );\n\n return () => {\n active = false;\n };\n // Keyed by uid and flag, the only fields the resolver reads.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [itemsKey]);\n\n return result;\n}\n"],"names":[],"mappings":";;;;AAiBO,SAAS,qCACd,KAAA,EAC4C;AAC5C,EAAA,MAAM,CAAC,QAAQ,SAAS,CAAA,GAAI,SAAqD,EAAE,SAAA,EAAW,MAAM,CAAA;AACpG,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,KAAS,CAAC,IAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,IAAA,CAAM,GAAA,EAAK,IAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,IAAA,CAAM,SAAS,CAAC,CAAC,CAAA;AAEjF,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,MAAA,GAAS,IAAA;AACb,IAAA,SAAA,CAAU,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAE7B,IAAA,oCAAA,CAAqC,KAAK,CAAA,CAAE,IAAA;AAAA,MAC1C,CAAC,IAAA,KAAS;AACR,QAAA,IAAI,MAAA,EAAQ;AACV,UAAA,SAAA,CAAU,EAAE,SAAA,EAAW,KAAA,EAAO,IAAA,EAAM,CAAA;AAAA,QACtC;AAAA,MACF,CAAA;AAAA,MACA,CAAC,GAAA,KAAiB;AAChB,QAAA,IAAI,MAAA,EAAQ;AACV,UAAA,SAAA,CAAU,EAAE,SAAA,EAAW,KAAA,EAAO,KAAA,EAAO,GAAA,YAAe,KAAA,GAAQ,GAAA,GAAM,IAAI,KAAA,CAAM,MAAA,CAAO,GAAG,CAAC,GAAG,CAAA;AAAA,QAC5F;AAAA,MACF;AAAA,KACF;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,GAAS,KAAA;AAAA,IACX,CAAA;AAAA,EAGF,CAAA,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,EAAA,OAAO,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"useDefaultDataSourceInstanceListItem.mjs","sources":["../../../src/datasources/useDefaultDataSourceInstanceListItem.ts"],"sourcesContent":["import { type DataSourceInstanceListItem } from '@grafana/data';\nimport { useDefaultDataSourceInstanceListItem as stableUseDefaultDataSourceInstanceListItem } from '@grafana/runtime';\nimport { useDefaultDataSourceInstanceListItem as unstableUseDefaultDataSourceInstanceListItem } from '@grafana/runtime/unstable';\n\nimport { backwardsCompatibleGetDefaultDataSourceInstanceListItem } from './getDefaultDataSourceInstanceListItem';\n\n/** Declared here because `@grafana/runtime` lacks it on older supported hosts. */\nexport interface UseDefaultDataSourceInstanceListItemResult {\n isLoading: boolean;\n error?: Error;\n item?: DataSourceInstanceListItem;\n}\n\n/**\n * Uses the host hook when available, which also re-resolves on data source cache changes; otherwise\n * resolves synchronously on every render. Picked once at load so the hook order stays stable.\n */\nexport const useDefaultDataSourceInstanceListItem: (\n items: DataSourceInstanceListItem[]\n) => UseDefaultDataSourceInstanceListItemResult =\n typeof stableUseDefaultDataSourceInstanceListItem === 'function'\n ? stableUseDefaultDataSourceInstanceListItem\n : typeof unstableUseDefaultDataSourceInstanceListItem === 'function'\n ? unstableUseDefaultDataSourceInstanceListItem\n : useBackwardsCompatibleDefaultDataSourceInstanceListItem;\n\nfunction useBackwardsCompatibleDefaultDataSourceInstanceListItem(\n items: DataSourceInstanceListItem[]\n): UseDefaultDataSourceInstanceListItemResult {\n return { isLoading: false, item: backwardsCompatibleGetDefaultDataSourceInstanceListItem(items) };\n}\n"],"names":["stableUseDefaultDataSourceInstanceListItem","unstableUseDefaultDataSourceInstanceListItem"],"mappings":";;;;;AAiBO,MAAM,oCAAA,GAGX,OAAOA,sCAAA,KAA+C,UAAA,GAClDA,yCACA,OAAOC,sCAAA,KAAiD,aACtDA,sCAAA,GACA;AAER,SAAS,wDACP,KAAA,EAC4C;AAC5C,EAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,IAAA,EAAM,uDAAA,CAAwD,KAAK,CAAA,EAAE;AAClG;;;;"}
@@ -2,6 +2,7 @@ export { getDataSourceInstance } from './datasources/getDataSourceInstance.mjs';
2
2
  export { getDataSourceInstanceList } from './datasources/getDataSourceInstanceList.mjs';
3
3
  export { getDataSourceInstanceSettings } from './datasources/getDataSourceInstanceSettings.mjs';
4
4
  export { getDefaultDataSourceInstanceListItem } from './datasources/getDefaultDataSourceInstanceListItem.mjs';
5
+ export { registerRuntimeDataSourceInstance } from './datasources/registerRuntimeDataSourceInstance.mjs';
5
6
  export { useDefaultDataSourceInstanceListItem } from './datasources/useDefaultDataSourceInstanceListItem.mjs';
6
7
 
7
8
  "use strict";
@@ -1 +1 @@
1
- {"version":3,"file":"datasources.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"datasources.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -1,7 +1,8 @@
1
1
  import { type DataSourceInstanceListItem } from '@grafana/data';
2
2
  /**
3
- * Resolve the item flagged as the default data source, or `undefined` when the list holds none.
3
+ * Resolve the item whose data source is the org default, or `undefined` when the list holds none.
4
4
  *
5
5
  * At most one instance per org carries the flag, so a filtered list need not contain it.
6
6
  */
7
7
  export declare function getDefaultDataSourceInstanceListItem(items: DataSourceInstanceListItem[]): Promise<DataSourceInstanceListItem | undefined>;
8
+ export declare function backwardsCompatibleGetDefaultDataSourceInstanceListItem(items: DataSourceInstanceListItem[]): DataSourceInstanceListItem | undefined;
@@ -0,0 +1,2 @@
1
+ import { type RuntimeDataSourceRegistration } from '@grafana/runtime';
2
+ export declare function registerRuntimeDataSourceInstance(entry: RuntimeDataSourceRegistration): void;
@@ -1,12 +1,12 @@
1
1
  import { type DataSourceInstanceListItem } from '@grafana/data';
2
- /** Declared here because `@grafana/runtime/unstable` lacks it on older supported hosts. */
2
+ /** Declared here because `@grafana/runtime` lacks it on older supported hosts. */
3
3
  export interface UseDefaultDataSourceInstanceListItemResult {
4
4
  isLoading: boolean;
5
5
  error?: Error;
6
6
  item?: DataSourceInstanceListItem;
7
7
  }
8
8
  /**
9
- * React hook wrapping {@link getDefaultDataSourceInstanceListItem}. Re-resolves when the uid or
10
- * `isDefault` flag of any item changes, so passing an inline array is safe.
9
+ * Uses the host hook when available, which also re-resolves on data source cache changes; otherwise
10
+ * resolves synchronously on every render. Picked once at load so the hook order stays stable.
11
11
  */
12
- export declare function useDefaultDataSourceInstanceListItem(items: DataSourceInstanceListItem[]): UseDefaultDataSourceInstanceListItemResult;
12
+ export declare const useDefaultDataSourceInstanceListItem: (items: DataSourceInstanceListItem[]) => UseDefaultDataSourceInstanceListItemResult;
@@ -2,4 +2,5 @@ export { getDataSourceInstance } from './datasources/getDataSourceInstance';
2
2
  export { getDataSourceInstanceList } from './datasources/getDataSourceInstanceList';
3
3
  export { getDataSourceInstanceSettings } from './datasources/getDataSourceInstanceSettings';
4
4
  export { getDefaultDataSourceInstanceListItem } from './datasources/getDefaultDataSourceInstanceListItem';
5
+ export { registerRuntimeDataSourceInstance } from './datasources/registerRuntimeDataSourceInstance';
5
6
  export { useDefaultDataSourceInstanceListItem, type UseDefaultDataSourceInstanceListItemResult, } from './datasources/useDefaultDataSourceInstanceListItem';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Grafana Labs",
3
3
  "license": "Apache-2.0",
4
4
  "name": "@grafana/plugin-compat",
5
- "version": "0.1.0",
5
+ "version": "0.4.0",
6
6
  "description": "Compatibility shims that let Grafana plugins adopt new Grafana host APIs across a range of host versions",
7
7
  "keywords": [
8
8
  "grafana",
@@ -16,18 +16,21 @@
16
16
  "url": "http://github.com/grafana/grafana.git",
17
17
  "directory": "packages/grafana-plugin-compat"
18
18
  },
19
+ "main": "./dist/cjs/datasources.cjs",
19
20
  "module": "./dist/esm/datasources.mjs",
20
21
  "exports": {
21
22
  "./package.json": "./package.json",
22
23
  "./datasources": {
23
24
  "@grafana-app/source": "./src/datasources.ts",
24
25
  "types": "./dist/types/datasources.d.ts",
25
- "import": "./dist/esm/datasources.mjs"
26
+ "import": "./dist/esm/datasources.mjs",
27
+ "require": "./dist/cjs/datasources.cjs"
26
28
  },
27
29
  "./apps": {
28
30
  "@grafana-app/source": "./src/apps.ts",
29
31
  "types": "./dist/types/apps.d.ts",
30
- "import": "./dist/esm/apps.mjs"
32
+ "import": "./dist/esm/apps.mjs",
33
+ "require": "./dist/cjs/apps.cjs"
31
34
  }
32
35
  },
33
36
  "publishConfig": {
@@ -48,8 +51,15 @@
48
51
  "postpack": "mv package.json.bak package.json"
49
52
  },
50
53
  "devDependencies": {
54
+ "@grafana/data": "13.3.0-pre",
55
+ "@grafana/runtime": "13.3.0-pre",
56
+ "@grafana/schema": "13.3.0-pre",
57
+ "@testing-library/dom": "10.4.1",
51
58
  "@testing-library/react": "16.3.0",
59
+ "@types/react": "19.2.18",
52
60
  "@typescript/native": "npm:typescript@^7.0.2",
61
+ "react": "19.2.8",
62
+ "react-dom": "19.2.8",
53
63
  "rimraf": "^6.0.1",
54
64
  "rollup": "^4.60.1",
55
65
  "rollup-plugin-esbuild": "6.2.1",
@@ -62,5 +72,5 @@
62
72
  "@grafana/schema": ">=12.0.0",
63
73
  "react": ">=18"
64
74
  },
65
- "gitHead": "1d6edf929f5f5308e51ea482e08da15d72a2a370"
75
+ "gitHead": "891f7973f81c6e4e0a24bed3120cca3b3cc93ebc"
66
76
  }