Grafana Runtime: Use package.json exports for internal code (#102100)

* refactor(frontend): update runtime import paths for grafana/runtime/src -> grafana/runtime

* feat(runtime): introduce internal api entrypoint and exports property

* refactor(frontend): update runtime imports to use internal entrypoint

* chore(betterer): update results file

* refactor(bookmarks): update runtime/unstable import

* chore(betterer): update results file

* test(frontend): fix failing tests due to mocking nested runtime imports

* test(datasourcesrv): fix failing tests due to mocks

* chore(alerting): clean up redundant import

* fix(packages): fix default require export pointing to types declaration file

* docs(packages): update readme related to exports

* chore(internationalization): fix import paths

* chore(betterer): update results file
This commit is contained in:
Jack Westbrook
2025-03-27 08:59:57 +01:00
committed by GitHub
parent f005613db7
commit 6822805c32
74 changed files with 294 additions and 383 deletions
+28 -102
View File
@@ -851,11 +851,6 @@ exports[`better eslint`] = {
"packages/grafana-ui/src/utils/useAsyncDependency.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/app.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/components/PanelDataErrorView\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "\'@grafana/runtime/src/components/PanelRenderer\' import is restricted from being used by a pattern. Import from the public export instead.", "1"],
[0, 0, 0, "\'@grafana/runtime/src/components/PluginPage\' import is restricted from being used by a pattern. Import from the public export instead.", "2"]
],
"public/app/core/TableModel.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@@ -1056,12 +1051,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not re-export imported variable (\`profiler\`)", "6"],
[0, 0, 0, "Do not re-export imported variable (\`updateLegendValues\`)", "7"]
],
"public/app/core/internationalization/index.test.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/unstable\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/core/internationalization/index.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/unstable\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/core/navigation/GrafanaRouteError.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "1"]
@@ -1972,9 +1961,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "5"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "6"]
],
"public/app/features/alerting/unified/components/rule-editor/dag.test.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/components/rule-editor/labels/LabelsButtons.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
@@ -2051,9 +2037,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "7"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "8"]
],
"public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.test.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/services/__mocks__/dataSourceSrv\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/components/rule-editor/rule-types/GrafanaManagedAlert.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
@@ -2066,9 +2049,6 @@ exports[`better eslint`] = {
"public/app/features/alerting/unified/components/rule-editor/rule-types/RuleTypePicker.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
"public/app/features/alerting/unified/components/rule-editor/util.test.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/components/rule-viewer/AlertRuleMenu.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "1"],
@@ -2173,9 +2153,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"]
],
"public/app/features/alerting/unified/components/rules/MultipleDataSourcePicker.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/components/rules/ReorderRuleGroupModal.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
],
@@ -2404,9 +2381,6 @@ exports[`better eslint`] = {
"public/app/features/alerting/unified/home/PluginIntegrations.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
"public/app/features/alerting/unified/hooks/useAlertQueriesStatus.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/hooks/useAlertmanagerConfig.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@@ -2483,9 +2457,6 @@ exports[`better eslint`] = {
"public/app/features/alerting/unified/rule-list/components/RuleGroup.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
],
"public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/types/receiver-form.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@@ -2511,9 +2482,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
],
"public/app/features/alerting/unified/utils/rule-form.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/alerting/unified/utils/rules.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -2580,9 +2548,6 @@ exports[`better eslint`] = {
"public/app/features/auth-config/utils/data.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/bookmarks/BookmarksPage.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/unstable\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/browse-dashboards/api/browseDashboardsAPI.ts:5381": [
[0, 0, 0, "Do not re-export imported variable (\`@reduxjs/toolkit/query/react\`)", "0"]
],
@@ -4147,9 +4112,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/features/expressions/ExpressionDatasource.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/features/expressions/ExpressionQueryEditor.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
@@ -4196,8 +4160,7 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
],
"public/app/features/expressions/guards.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/geo/editor/GazetteerPathEditor.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
@@ -4302,18 +4265,11 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
],
"public/app/features/live/centrifuge/LiveDataStream.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/services/live\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "\'@grafana/runtime/src/utils/toDataQueryError\' import is restricted from being used by a pattern. Import from the public export instead.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/live/centrifuge/channel.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/live/centrifuge/service.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/services/backendSrv\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "\'@grafana/runtime/src/services/live\' import is restricted from being used by a pattern. Import from the public export instead.", "1"],
[0, 0, 0, "\'@grafana/runtime/src/utils/queryResponse\' import is restricted from being used by a pattern. Import from the public export instead.", "2"]
],
"public/app/features/live/centrifuge/serviceWorkerProxy.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@@ -4323,9 +4279,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"]
],
"public/app/features/live/live.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/logs/components/InfiniteScroll.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
@@ -4382,7 +4335,7 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
"public/app/features/manage-dashboards/components/ImportDashboardForm.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "1"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "2"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "3"],
@@ -4390,10 +4343,9 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "5"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "6"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "7"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "8"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "8"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "9"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "10"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "11"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "10"]
],
"public/app/features/manage-dashboards/components/ImportDashboardLibraryPanelsList.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
@@ -4577,10 +4529,9 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
],
"public/app/features/plugins/admin/components/PluginDetailsBody.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/components/PluginPage\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"]
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
],
"public/app/features/plugins/admin/components/PluginDetailsDeprecatedWarning.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
@@ -4595,8 +4546,7 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
],
"public/app/features/plugins/admin/components/PluginDetailsPanel.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/components/PluginPage\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
"public/app/features/plugins/admin/components/PluginDetailsSignature.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
@@ -4674,14 +4624,13 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
],
"public/app/features/plugins/datasource_srv.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
],
"public/app/features/plugins/extensions/logs/LogViewFilters.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
@@ -4706,10 +4655,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/features/plugins/tests/datasource_srv.test.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/features/plugins/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@@ -4926,7 +4874,7 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
],
"public/app/features/provisioning/Shared/TokenPermissionsInfo.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"],
@@ -4965,7 +4913,10 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "8"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "9"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "10"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "11"]
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "11"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "12"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "13"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "14"]
],
"public/app/features/provisioning/Wizard/FinishStep.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
@@ -4977,20 +4928,7 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "6"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "7"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "8"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "9"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "10"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "11"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "12"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "13"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "14"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "15"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "16"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "17"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "18"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "19"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "20"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "21"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "22"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "9"]
],
"public/app/features/provisioning/Wizard/MigrateStep.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
@@ -5094,19 +5032,14 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/features/query/state/PanelQueryRunner.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/features/query/state/runRequest.test.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/query/state/runRequest.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/features/query/state/runRequest.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/query/state/updateQueries.test.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
@@ -5114,11 +5047,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
],
"public/app/features/query/state/updateQueries.ts:5381": [
[0, 0, 0, "\'@grafana/runtime/src/utils/DataSourceWithBackend\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/features/sandbox/TestStuffPage.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
@@ -5363,9 +5292,6 @@ exports[`better eslint`] = {
"public/app/features/transformers/editors/EnumMappingRow.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
"public/app/features/transformers/editors/FilterByNameTransformerEditor.tsx:5381": [
[0, 0, 0, "\'@grafana/runtime/src/services\' import is restricted from being used by a pattern. Import from the public export instead.", "0"]
],
"public/app/features/transformers/editors/FormatStringTransformerEditor.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"]
],
+6 -6
View File
@@ -2,13 +2,13 @@
## Exporting code conventions
`@grafana/ui` makes use of `exports` in package.json to define three entrypoints that Grafana core and Grafana plugins can access. Before exposing anything in this package please consider the table below.
`@grafana/ui`, `@grafana/data` and `@grafana/runtime` makes use of `exports` in package.json to define three entrypoints that Grafana core and Grafana plugins can access. Before exposing anything in these packages please consider the table below to better understand the use case of each export.
| Entrypoint Name | Import Path | Description | Available to Grafana | Available to plugins |
| --------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------- |
| `./` | `@grafana/ui` | The public API entrypoint. If the code is stable and you want to share it everywhere, this is the place to export it. | ✅ | ✅ |
| `./unstable` | `@grafana/ui/unstable` | The public API entrypoint for all experimental code. If you want to iterate and test code from Grafana and plugins, this is the place to export it. | ✅ | ✅ |
| `./internal` | `@grafana/ui/internal` | The private API entrypoint for internal code shared with Grafana. If you need to import code in Grafana but don't want to expose it to plugins, this is the place to export it. | ✅ | ❌ |
| Export Name | Import Path | Description | Available to Grafana | Available to plugins |
| ------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------- |
| `./` | `@grafana/ui` | The public API entrypoint. If the code is stable and you want to share it everywhere, this is the place to export it. | ✅ | ✅ |
| `./unstable` | `@grafana/ui/unstable` | The public API entrypoint for all experimental code. If you want to iterate and test code from Grafana and plugins, this is the place to export it. | ✅ | ✅ |
| `./internal` | `@grafana/ui/internal` | The private API entrypoint for internal code shared with Grafana. If you need to import code in Grafana but don't want to expose it to plugins, this is the place to export it. | ✅ | ❌ |
## Versioning
+16
View File
@@ -16,6 +16,22 @@
},
"main": "src/index.ts",
"types": "src/index.ts",
"module": "src/index.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./src/index.ts",
"require": "./src/index.ts"
},
"./internal": {
"import": "./src/internal/index.ts",
"require": "./src/internal/index.ts"
},
"./unstable": {
"import": "./src/unstable.ts",
"require": "./src/unstable.ts"
}
},
"publishConfig": {
"main": "./dist/cjs/index.cjs",
"module": "./dist/esm/index.mjs",
@@ -3,7 +3,13 @@ import userEvent from '@testing-library/user-event';
import { DataSourcePicker } from './DataSourcePicker';
jest.mock('../services/dataSourceSrv');
jest.mock('../services/dataSourceSrv', () => ({
getDataSourceSrv: () => ({
getList: () => [],
getInstanceSettings: () => undefined,
get: () => undefined,
}),
}));
describe('DataSourcePicker', () => {
describe('onClear', () => {
@@ -0,0 +1,18 @@
/**
* This file is used to share internal grafana/runtime code with Grafana core.
* Note that these exports are also used within Enterprise.
*
* Through the exports declared in package.json we can import this code in core Grafana and the grafana/runtime
* package will continue to be able to access all code when it's published to npm as it's private to the package.
*
* During the yarn pack lifecycle the exports[./internal] property is deleted from the package.json
* preventing the code from being importable by plugins or other npm packages making it truly "internal".
*
*/
export { setPanelDataErrorView } from '../components/PanelDataErrorView';
export { setPanelRenderer } from '../components/PanelRenderer';
export { type PageInfoItem, setPluginPage } from '../components/PluginPage';
export { ExpressionDatasourceRef } from '../utils/DataSourceWithBackend';
export { standardStreamOptionsProvider, toStreamingDataResponse } from '../utils/DataSourceWithBackend';
@@ -1,23 +0,0 @@
const ds1 = {
id: 1,
uid: 'c8eceabb-0275-4108-8f03-8f74faf4bf6d',
type: 'prometheus',
name: 'gdev-prometheus',
meta: {
alerting: true,
info: {
logos: {
small: 'http://example.com/logo.png',
},
},
},
jsonData: {},
access: 'proxy',
};
export function getDataSourceSrv() {
return {
getList: () => [ds1],
getInstanceSettings: () => ds1,
};
}
+1 -3
View File
@@ -42,9 +42,7 @@ import {
setCorrelationsService,
setPluginFunctionsHook,
} from '@grafana/runtime';
import { setPanelDataErrorView } from '@grafana/runtime/src/components/PanelDataErrorView';
import { setPanelRenderer } from '@grafana/runtime/src/components/PanelRenderer';
import { setPluginPage } from '@grafana/runtime/src/components/PluginPage';
import { setPanelDataErrorView, setPanelRenderer, setPluginPage } from '@grafana/runtime/internal';
import config, { updateConfig } from 'app/core/config';
import { getStandardTransformers } from 'app/features/transformers/standardTransformers';
@@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
import { HTMLAttributes, useEffect } from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { reportExperimentView } from '@grafana/runtime/src';
import { reportExperimentView } from '@grafana/runtime';
import { Button, Icon, LinkButton, useStyles2 } from '@grafana/ui';
import { t, Trans } from 'app/core/internationalization';
@@ -2,12 +2,7 @@ import { render } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { PluginContextProvider, PluginMeta, PluginType } from '@grafana/data';
import {
Trans as PluginTrans,
setTransComponent,
setUseTranslateHook,
useTranslate,
} from '@grafana/runtime/src/unstable';
import { Trans as PluginTrans, setTransComponent, setUseTranslateHook, useTranslate } from '@grafana/runtime/unstable';
import { getI18next, Trans, useTranslateInternal } from './index';
@@ -4,7 +4,7 @@ import { ReactElement, useMemo } from 'react';
import { Trans as I18NextTrans, initReactI18next } from 'react-i18next'; // eslint-disable-line no-restricted-imports
import { usePluginContext } from '@grafana/data';
import { setTransComponent, setUseTranslateHook, TransProps } from '@grafana/runtime/src/unstable';
import { setTransComponent, setUseTranslateHook, TransProps } from '@grafana/runtime/unstable';
import { DEFAULT_LANGUAGE, NAMESPACES, VALID_LANGUAGES } from './constants';
import { loadTranslations } from './loadTranslations';
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { selectors as e2eSelectors } from '@grafana/e2e-selectors/src';
import { GrafanaBootConfig } from '@grafana/runtime/src';
import { GrafanaBootConfig } from '@grafana/runtime';
import config from 'app/core/config';
import { TestProvider } from '../../../test/helpers/TestProvider';
+1 -1
View File
@@ -1,4 +1,4 @@
import { config } from '@grafana/runtime/src';
import { config } from '@grafana/runtime';
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
export const w3cStandardEmailValidator =
@@ -1,7 +1,6 @@
import { isEmpty } from 'lodash';
import { createMonitoringLogger } from '@grafana/runtime';
import { config, reportInteraction } from '@grafana/runtime/src';
import { config, createMonitoringLogger, reportInteraction } from '@grafana/runtime';
import { contextSrv } from 'app/core/core';
import { RuleNamespace } from '../../../types/unified-alerting';
@@ -1,4 +1,4 @@
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { Graph } from 'app/core/utils/dag';
import { EvalFunction } from 'app/features/alerting/state/alertDef';
import { ExpressionQuery, ExpressionQueryType } from 'app/features/expressions/types';
@@ -1,5 +1,4 @@
import { RelativeTimeRange, getDefaultRelativeTimeRange } from '@grafana/data';
import { getDataSourceSrv } from '@grafana/runtime/src/services/__mocks__/dataSourceSrv';
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
import {
ExpressionDatasourceUID,
@@ -47,9 +46,29 @@ const thresholdExpression: AlertQuery<ExpressionQuery> = {
},
};
const ds1 = {
id: 1,
uid: 'c8eceabb-0275-4108-8f03-8f74faf4bf6d',
type: 'prometheus',
name: 'gdev-prometheus',
meta: {
alerting: true,
info: {
logos: {
small: 'http://example.com/logo.png',
},
},
},
jsonData: {},
access: 'proxy',
};
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: getDataSourceSrv,
getDataSourceSrv: () => ({
getList: () => [ds1],
getInstanceSettings: () => ds1,
}),
}));
const alertQuery: AlertQuery = {
@@ -1,4 +1,4 @@
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { ClassicCondition, ExpressionQuery } from 'app/features/expressions/types';
import { AlertQuery } from 'app/types/unified-alerting-dto';
@@ -9,7 +9,7 @@ import {
} from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { DataSourcePickerProps, DataSourcePickerState, getDataSourceSrv } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { ActionMeta, MultiSelect, PluginSignatureBadge, Stack } from '@grafana/ui';
import { isDataSourceManagingAlerts } from '../../utils/datasource';
@@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import { useMemo } from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { config } from '@grafana/runtime/src';
import { config } from '@grafana/runtime';
import { Icon, Tooltip, useStyles2 } from '@grafana/ui';
import { CombinedRule } from '../../../../../types/unified-alerting';
@@ -1,7 +1,6 @@
import { useMemo } from 'react';
import { getDataSourceSrv } from '@grafana/runtime';
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { getDataSourceSrv, isExpressionReference } from '@grafana/runtime';
import { AlertQuery } from 'app/types/unified-alerting-dto';
export function useAlertQueriesStatus(queries: AlertQuery[]) {
@@ -14,7 +14,7 @@ import {
rangeUtil,
} from '@grafana/data';
import { DataSourceSrv, DataSourceWithBackend, FetchResponse } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { DataQuery } from '@grafana/schema';
import { BackendSrv } from 'app/core/services/backend_srv';
import {
@@ -10,7 +10,7 @@ import {
} from '@grafana/data';
import { PromQuery } from '@grafana/prometheus';
import { config, getDataSourceSrv } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { VizPanel, sceneGraph } from '@grafana/scenes';
import { DataQuery, DataSourceJsonData, DataSourceRef } from '@grafana/schema';
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { GrafanaTheme2, NavModelItem } from '@grafana/data';
import { useTranslate } from '@grafana/runtime/src/unstable';
import { useTranslate } from '@grafana/runtime/unstable';
import { EmptyState, useStyles2 } from '@grafana/ui';
import { usePinnedItems } from 'app/core/components/AppChrome/MegaMenu/hooks';
import { findByUrl } from 'app/core/components/AppChrome/MegaMenu/utils';
+1 -1
View File
@@ -6,7 +6,7 @@ import { BehaviorSubject, ReplaySubject, Subject, Subscription } from 'rxjs';
import Selecto from 'selecto';
import { AppEvents, PanelData } from '@grafana/data';
import { locationService } from '@grafana/runtime/src';
import { locationService } from '@grafana/runtime';
import {
ColorDimensionConfig,
ResourceDimensionConfig,
@@ -42,8 +42,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -39,10 +39,6 @@ jest.mock('@grafana/runtime', () => ({
}),
}),
}),
}));
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -14,8 +14,8 @@ const defaultDatasource = mockDataSource({
type: 'test',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
getInstanceSettings: () => ({ ...defaultDatasource }),
}),
@@ -19,8 +19,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => defaultDatasource,
getList: () => [defaultDatasource, promDatasource],
@@ -19,8 +19,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -31,8 +31,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -12,7 +12,7 @@ import {
toDataFrame,
} from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { setRunRequest } from '@grafana/runtime/src';
import { setRunRequest } from '@grafana/runtime';
import { AdHocFiltersVariable } from '@grafana/scenes';
import { mockDataSource } from 'app/features/alerting/unified/mocks';
import { LegacyVariableQueryEditor } from 'app/features/variables/editor/LegacyVariableQueryEditor';
@@ -31,8 +31,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -21,8 +21,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -30,8 +30,8 @@ const promDatasource = mockDataSource({
type: 'prometheus',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => ({
...jest.requireActual('@grafana/runtime/src/services/dataSourceSrv'),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ({
...defaultDatasource,
@@ -1,6 +1,6 @@
import { createApi } from '@reduxjs/toolkit/query/react';
import { config, FetchError, isFetchError } from '@grafana/runtime/src';
import { config, FetchError, isFetchError } from '@grafana/runtime';
import { createBaseQuery } from 'app/api/createBaseQuery';
import { notifyApp } from 'app/core/actions';
import { createErrorNotification, createSuccessNotification } from 'app/core/copy/appNotification';
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import { BootData } from '@grafana/data';
import { setEchoSrv } from '@grafana/runtime/src';
import { setEchoSrv } from '@grafana/runtime';
import config from 'app/core/config';
import { Echo } from '../../../../core/services/echo/Echo';
@@ -1,6 +1,6 @@
import { useEffect } from 'react';
import { reportInteraction } from '@grafana/runtime/src';
import { reportInteraction } from '@grafana/runtime';
import { Trans } from 'app/core/internationalization';
import { AddLibraryPanelContents } from 'app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal';
@@ -17,23 +17,22 @@ const mockDS = mockDataSource({
type: 'mock-ds-type',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () =>
Promise.resolve(
new DataSourceWithBackend({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
backend: true,
},
})
),
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () =>
Promise.resolve(
new DataSourceWithBackend({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
backend: true,
},
})
),
}),
}));
describe('dashboardHasTemplateVariables', () => {
it('false', () => {
@@ -59,26 +59,18 @@ const setup = (partialProps: Partial<DataSourceModalProps> = {}) => {
return render(<DataSourceModal {...props} />);
};
jest.mock('@grafana/runtime', () => {
const actual = jest.requireActual('@grafana/runtime');
return {
...actual,
getTemplateSrv: () => {
return {
getVariables: () => [],
};
},
};
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
getList: getListMock,
getInstanceSettings: getInstanceSettingsMock,
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getTemplateSrv: () => {
return {
getVariables: () => [],
};
},
getDataSourceSrv: () => ({
getList: getListMock,
getInstanceSettings: getInstanceSettingsMock,
}),
}));
locationUtil.initialize({
config: { appSubUrl: '/my-sub-path' } as GrafanaConfig,
@@ -63,26 +63,18 @@ locationUtil.initialize({
getTimeRangeForUrl: jest.fn(),
});
jest.mock('@grafana/runtime', () => {
const actual = jest.requireActual('@grafana/runtime');
return {
...actual,
getTemplateSrv: () => {
return {
getVariables: () => [{ id: 'foo', type: 'datasource' }],
};
},
};
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
getList: getListMock,
getInstanceSettings: getInstanceSettingsMock,
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getTemplateSrv: () => {
return {
getVariables: () => [{ id: 'foo', type: 'datasource' }],
};
},
getDataSourceSrv: () => ({
getList: getListMock,
getInstanceSettings: getInstanceSettingsMock,
}),
}));
const pushRecentlyUsedDataSourceMock = jest.fn();
jest.mock('../../hooks', () => {
+9 -15
View File
@@ -109,16 +109,15 @@ const dummyProps: Props = {
},
changeDatasource: jest.fn(),
};
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve({}),
getList: () => [],
getInstanceSettings: () => {},
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve({}),
getList: () => [],
getInstanceSettings: () => {},
}),
usePluginLinks: jest.fn(() => ({ links: [] })),
}));
jest.mock('app/core/core', () => ({
contextSrv: {
@@ -127,11 +126,6 @@ jest.mock('app/core/core', () => ({
},
}));
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
usePluginLinks: jest.fn(() => ({ links: [] })),
}));
// for the AutoSizer component to have a width
jest.mock('react-virtualized-auto-sizer', () => {
return ({ children }: AutoSizerProps) =>
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import { CoreApp, GrafanaTheme2, LoadingState } from '@grafana/data';
import { reportInteraction } from '@grafana/runtime/src';
import { reportInteraction } from '@grafana/runtime';
import { defaultTimeZone, TimeZone } from '@grafana/schema';
import { TabbedContainer, TabConfig, useStyles2 } from '@grafana/ui';
import { requestIdGenerator } from 'app/core/utils/explore';
@@ -13,7 +13,7 @@ import {
SplitOpen,
TimeRange,
} from '@grafana/data';
import { reportInteraction } from '@grafana/runtime/src';
import { reportInteraction } from '@grafana/runtime';
import { InlineField, Select, Themeable2 } from '@grafana/ui';
import { t } from 'app/core/internationalization';
@@ -5,7 +5,7 @@ import { useWindowSize } from 'react-use';
import { VariableSizeList as List } from 'react-window';
import { DataFrame, Field as DataFrameField } from '@grafana/data';
import { reportInteraction } from '@grafana/runtime/src';
import { reportInteraction } from '@grafana/runtime';
import { Field, Switch } from '@grafana/ui';
import { ItemLabels } from './ItemLabels';
@@ -3,7 +3,7 @@ import { useCopyToClipboard } from 'react-use';
import { Field, GrafanaTheme2 } from '@grafana/data';
import { isValidLegacyName, utf8Support } from '@grafana/prometheus/src/utf8_support';
import { reportInteraction } from '@grafana/runtime/src';
import { reportInteraction } from '@grafana/runtime';
import { IconButton, useStyles2 } from '@grafana/ui';
import { t } from 'app/core/internationalization';
@@ -71,24 +71,19 @@ jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
reportInteraction: jest.fn(),
getAppEvents: () => mockEventBus,
}));
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: (ref: DataSourceRef | string) => {
const uid = typeof ref === 'string' ? ref : ref.uid;
if (!uid) {
return Promise.reject();
}
if (dsStore[uid]) {
return Promise.resolve(dsStore[uid]);
}
getDataSourceSrv: () => ({
get: (ref: DataSourceRef | string) => {
const uid = typeof ref === 'string' ? ref : ref.uid;
if (!uid) {
return Promise.reject();
},
}),
};
});
}
if (dsStore[uid]) {
return Promise.resolve(dsStore[uid]);
}
return Promise.reject();
},
}),
}));
const copyStringToClipboard = jest.fn();
jest.mock('app/core/utils/explore', () => ({
@@ -8,15 +8,14 @@ import { QueriesDrawerContextProviderMock } from './QueriesDrawer/mocks';
import { QueryLibraryContextProviderMock } from './QueryLibrary/mocks';
import { SecondaryActions } from './SecondaryActions';
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve({}),
getList: () => [],
getInstanceSettings: () => {},
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve({}),
getList: () => [],
getInstanceSettings: () => {},
}),
}));
describe('SecondaryActions', () => {
it('should render component with two buttons', () => {
@@ -9,7 +9,7 @@ import {
ScopedVars,
} from '@grafana/data';
import { DataSourceWithBackend, getDataSourceSrv, getTemplateSrv } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { ExpressionQueryEditor } from './ExpressionQueryEditor';
import { ExpressionDatasourceUID, ExpressionQuery, ExpressionQueryType } from './types';
+1 -1
View File
@@ -1,4 +1,4 @@
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { isExpressionReference } from '@grafana/runtime';
import { DataQuery } from '@grafana/schema';
import { ExpressionQuery, ExpressionQueryType, ReducerType } from './types';
@@ -1,4 +1,4 @@
import { reportInteraction } from '@grafana/runtime/src';
import { reportInteraction } from '@grafana/runtime';
export enum IRMInteractionNames {
ViewIRMMainPage = 'grafana_irm_configuration_tracker_main_page_view',
@@ -13,8 +13,7 @@ import {
StreamingDataFrame,
} from '@grafana/data';
import { getStreamingFrameOptions } from '@grafana/data/internal';
import { LiveDataStreamOptions, StreamingFrameAction, StreamingFrameOptions } from '@grafana/runtime/src/services/live';
import { toDataQueryError } from '@grafana/runtime/src/utils/toDataQueryError';
import { LiveDataStreamOptions, StreamingFrameAction, StreamingFrameOptions, toDataQueryError } from '@grafana/runtime';
import { StreamingResponseDataType } from '../data/utils';
@@ -16,16 +16,16 @@ import {
LiveChannelId,
toLiveChannelId,
} from '@grafana/data';
import { FetchResponse } from '@grafana/runtime/src/services/backendSrv';
import {
FetchResponse,
GrafanaLiveSrv,
LiveDataStreamOptions,
LivePublishOptions,
LiveQueryDataOptions,
StreamingFrameAction,
StreamingFrameOptions,
} from '@grafana/runtime/src/services/live';
import { BackendDataSourceResponse } from '@grafana/runtime/src/utils/queryResponse';
BackendDataSourceResponse,
} from '@grafana/runtime';
import { StreamingResponseData } from '../data/utils';
+1 -4
View File
@@ -2,10 +2,7 @@ import { from, map, of, switchMap } from 'rxjs';
import { DataFrame, toLiveChannelId, StreamingDataFrame } from '@grafana/data';
import { BackendSrv, GrafanaLiveSrv, toDataQueryResponse } from '@grafana/runtime';
import {
standardStreamOptionsProvider,
toStreamingDataResponse,
} from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { standardStreamOptionsProvider, toStreamingDataResponse } from '@grafana/runtime/internal';
import { CentrifugeSrv, StreamingDataQueryResponse } from './centrifuge/service';
import { isStreamingResponseData, StreamingResponseDataType } from './data/utils';
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { Controller, FieldErrors, UseFormReturn } from 'react-hook-form';
import { selectors } from '@grafana/e2e-selectors';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { Button, Field, FormFieldErrors, FormsOnSubmit, Stack, Input, Legend } from '@grafana/ui';
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
import { AppPlugin, GrafanaTheme2, PluginContextProvider, UrlQueryMap, PluginType } from '@grafana/data';
import { config } from '@grafana/runtime';
import { PageInfoItem } from '@grafana/runtime/src/components/PluginPage';
import { PageInfoItem } from '@grafana/runtime/internal';
import { CellProps, Column, InteractiveTable, Stack, useStyles2 } from '@grafana/ui';
import { Changelog } from '../components/Changelog';
@@ -3,7 +3,7 @@ import { useState } from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { reportInteraction } from '@grafana/runtime';
import { PageInfoItem } from '@grafana/runtime/src/components/PluginPage';
import { PageInfoItem } from '@grafana/runtime/internal';
import {
Stack,
Text,
@@ -17,8 +17,9 @@ import {
RuntimeDataSourceRegistration,
RuntimeDataSource,
TemplateSrv,
isExpressionReference,
} from '@grafana/runtime';
import { ExpressionDatasourceRef, isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import appEvents from 'app/core/app_events';
import config from 'app/core/config';
import {
@@ -51,7 +51,7 @@ export const sharedDependenciesMap = {
'@grafana/data': grafanaData,
'@grafana/data/unstable': () => import('@grafana/data/unstable'),
'@grafana/runtime': grafanaRuntime,
'@grafana/runtime/unstable': () => import('@grafana/runtime/src/unstable'),
'@grafana/runtime/unstable': () => import('@grafana/runtime/unstable'),
'@grafana/slate-react': () => import('slate-react'),
'@grafana/ui': grafanaUI,
'@grafana/ui/unstable': () => import('@grafana/ui/unstable'),
@@ -11,7 +11,7 @@ import {
ScopedVars,
} from '@grafana/data';
import { RuntimeDataSource, TemplateSrv } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { DatasourceSrv, getNameOrUid } from 'app/features/plugins/datasource_srv';
// Datasource variable $datasource with current value 'BBB'
@@ -13,15 +13,16 @@ const mockDS = mockDataSource({
name: 'test',
type: DataSourceType.Alertmanager,
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve(mockDS),
getList: () => {},
getInstanceSettings: () => mockDS,
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve(mockDS),
getList: () => {},
getInstanceSettings: () => mockDS,
}),
}));
// Draggable fails to render in tests, so we mock it out
jest.mock('app/core/components/QueryOperationRow/QueryOperationRow', () => ({
QueryOperationRow: (props: PropsWithChildren) => <div>{props.children}</div>,
@@ -18,15 +18,14 @@ const mockVariable = mockDataSource({
type: 'datasource',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve(mockDS),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => mockDS,
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve(mockDS),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => mockDS,
}),
}));
describe('QueryEditorRowHeader', () => {
it('Can edit title', async () => {
@@ -17,22 +17,21 @@ const mockVariable = mockDataSource({
type: 'datasource',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve({ ...mockDS, getRef: () => {} }),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => ({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
mixed: true,
},
}),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve({ ...mockDS, getRef: () => {} }),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => ({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
mixed: true,
},
}),
};
});
}),
}));
const props: Props = {
queries: [
@@ -58,15 +57,14 @@ const props: Props = {
data: createMockPanelData(),
};
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve(mockDS),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => mockDS,
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve(mockDS),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => mockDS,
}),
}));
describe('QueryEditorRows', () => {
it('Should render queries', async () => {
@@ -19,22 +19,21 @@ const mockVariable = mockDataSource({
type: 'datasource',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () => Promise.resolve({ ...mockDS, getRef: () => {} }),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => ({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
mixed: true,
},
}),
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: () => Promise.resolve({ ...mockDS, getRef: () => {} }),
getList: ({ variables }: { variables: boolean }) => (variables ? [mockDS, mockVariable] : [mockDS]),
getInstanceSettings: () => ({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
mixed: true,
},
}),
};
});
}),
}));
describe('QueryGroup', () => {
// QueryGroup relies on this being present
@@ -31,7 +31,7 @@ import {
DataTopic,
} from '@grafana/data';
import { toDataQueryError } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { isStreamingDataFrame } from 'app/features/live/data/utils';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
import { getTemplateSrv } from 'app/features/templating/template_srv';
@@ -12,7 +12,7 @@ import {
PanelData,
} from '@grafana/data';
import { setEchoSrv } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { DataQuery } from '@grafana/schema';
import { deepFreeze } from '../../../../test/core/redux/reducerTester';
@@ -18,8 +18,7 @@ import {
PanelData,
TimeRange,
} from '@grafana/data';
import { config, isMigrationHandler, migrateRequest, toDataQueryError } from '@grafana/runtime';
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { config, isMigrationHandler, migrateRequest, toDataQueryError, isExpressionReference } from '@grafana/runtime';
import { backendSrv } from 'app/core/services/backend_srv';
import { queryIsEmpty } from 'app/core/utils/query';
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
@@ -1,5 +1,5 @@
import { DataSourceApi, DataSourceWithQueryExportSupport, DataSourceWithQueryImportSupport } from '@grafana/data';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { ExpressionDatasourceRef } from '@grafana/runtime/internal';
import { DataQuery } from '@grafana/schema';
import { TestQuery } from 'app/core/utils/query.test';
import { TemplateSrv } from 'app/features/templating/template_srv';
@@ -1,6 +1,5 @@
import { CoreApp, DataSourceApi, getNextRefId, hasQueryExportSupport, hasQueryImportSupport } from '@grafana/data';
import { getTemplateSrv } from '@grafana/runtime';
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { getTemplateSrv, isExpressionReference } from '@grafana/runtime';
import { DataQuery } from '@grafana/schema';
export async function updateQueries(
@@ -12,7 +12,7 @@ import {
SelectableValue,
} from '@grafana/data';
import { FilterFieldsByNameTransformerOptions } from '@grafana/data/internal';
import { getTemplateSrv } from '@grafana/runtime/src/services';
import { getTemplateSrv } from '@grafana/runtime';
import { Input, FilterPill, InlineFieldRow, InlineField, InlineSwitch, Select } from '@grafana/ui';
import { t } from 'app/core/internationalization';
@@ -51,15 +51,14 @@ const setupTestContext = async (options: Partial<Props>) => {
return { rerender, props };
};
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: async () => ds,
getList: () => [mockDS],
getInstanceSettings: () => mockDS,
}),
};
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
get: async () => ds,
getList: () => [mockDS],
getInstanceSettings: () => mockDS,
}),
}));
const defaultIdentifier: KeyedVariableIdentifier = { type: 'query', rootStateKey: 'key', id: NEW_VARIABLE_ID };
@@ -1,5 +1,5 @@
import { DataSourceRef, LoadingState } from '@grafana/data';
import { setDataSourceSrv } from '@grafana/runtime/src';
import { setDataSourceSrv } from '@grafana/runtime';
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
import { reduxTester } from '../../../../test/core/redux/reduxTester';
@@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
import { PureComponent } from 'react';
import { GrafanaTheme2, SelectableValue } from '@grafana/data';
import { getTemplateSrv } from '@grafana/runtime/src';
import { getTemplateSrv } from '@grafana/runtime';
import {
CodeEditor,
CodeEditorSuggestionItem,
@@ -1,5 +1,5 @@
import { TypedVariableModel } from '@grafana/data';
import { getTemplateSrv } from '@grafana/runtime/src';
import { getTemplateSrv } from '@grafana/runtime';
export function getTemplateVariableOptions(wrapper: (v: TypedVariableModel) => string) {
return (
@@ -3,7 +3,7 @@ import * as React from 'react';
import { ReplaySubject, Subscription } from 'rxjs';
import { PanelProps } from '@grafana/data';
import { locationService } from '@grafana/runtime/src';
import { locationService } from '@grafana/runtime';
import { PanelContext, PanelContextRoot } from '@grafana/ui';
import { CanvasFrameOptions } from 'app/features/canvas/frame';
import { ElementState } from 'app/features/canvas/runtime/element';
@@ -5,7 +5,7 @@ import WebGLPointsLayer from 'ol/layer/WebGLPoints';
import { Subject } from 'rxjs';
import { getFrameMatchers, MapLayerHandler, MapLayerOptions, PanelData, textUtil } from '@grafana/data';
import { config } from '@grafana/runtime/src';
import { config } from '@grafana/runtime';
import { GeomapPanel } from '../GeomapPanel';
import { MARKERS_LAYER_ID } from '../layers/data/markersLayer';
+1 -1
View File
@@ -57,7 +57,7 @@ try {
},
require: {
types: cjsTypes.replace('index', aliasName),
default: cjsTypes.replace('index', aliasName),
default: cjsIndex.replace('index', aliasName),
},
},
},