@grafana/plugin-ui 0.17.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/index.cjs +13105 -7657
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +852 -542
  4. package/dist/esm/components/ConfigEditor/Auth/auth-method/AuthMethodSettings.js +3 -3
  5. package/dist/esm/components/ConfigEditor/Auth/auth-method/AuthMethodSettings.js.map +1 -1
  6. package/dist/esm/components/ConfigEditor/ConfigSection/ConfigDescriptionLink.js +2 -2
  7. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceConfigWizard.js +23 -0
  8. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceConfigWizard.js.map +1 -0
  9. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceErrorBoundary.js +27 -0
  10. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceErrorBoundary.js.map +1 -0
  11. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SchemaField.js +61 -0
  12. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SchemaField.js.map +1 -0
  13. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/WizardLayout.js +89 -0
  14. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/WizardLayout.js.map +1 -0
  15. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/cel.js +75 -0
  16. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/cel.js.map +1 -0
  17. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/config.js +262 -0
  18. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/config.js.map +1 -0
  19. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/datasource.js +354 -0
  20. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/datasource.js.map +1 -0
  21. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/hooks/formInterpreter.js +93 -0
  22. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/hooks/formInterpreter.js.map +1 -0
  23. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/hooks/useDatasourceConfigForm.js +254 -0
  24. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/hooks/useDatasourceConfigForm.js.map +1 -0
  25. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/hooks/useHealthChecks.js +106 -0
  26. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/hooks/useHealthChecks.js.map +1 -0
  27. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/AuthorizationHeaderField.js +52 -0
  28. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/AuthorizationHeaderField.js.map +1 -0
  29. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/ComplexFieldNote.js +32 -0
  30. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/ComplexFieldNote.js.map +1 -0
  31. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/FieldInput.js +110 -0
  32. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/FieldInput.js.map +1 -0
  33. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/FileUploadField.js +112 -0
  34. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/FileUploadField.js.map +1 -0
  35. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/IndexedPairEditor.js +140 -0
  36. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/IndexedPairEditor.js.map +1 -0
  37. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/ObjectArrayEditor.js +201 -0
  38. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/ObjectArrayEditor.js.map +1 -0
  39. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/PrimitiveInputs.js +103 -0
  40. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/PrimitiveInputs.js.map +1 -0
  41. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/SecureFieldInput.js +72 -0
  42. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/SecureFieldInput.js.map +1 -0
  43. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/StringArrayInput.js +94 -0
  44. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/StringArrayInput.js.map +1 -0
  45. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/fieldUtils.js +138 -0
  46. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/inputs/fieldUtils.js.map +1 -0
  47. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/layoutParts.js +82 -0
  48. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/layoutParts.js.map +1 -0
  49. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/resolvePluginName.js +30 -0
  50. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/resolvePluginName.js.map +1 -0
  51. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/styles.js +128 -0
  52. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/styles.js.map +1 -0
  53. package/dist/esm/components/DataLinks/DataLink.js +2 -2
  54. package/dist/esm/components/DataLinks/DataLinks.js +2 -2
  55. package/dist/esm/components/DataSourcePicker/DataSourcePicker.js +7 -7
  56. package/dist/esm/components/DatePicker/styles.js +2 -2
  57. package/dist/esm/components/DatePickerWithInput/styles.js +2 -2
  58. package/dist/esm/components/QueryEditor/EditorField.js +2 -2
  59. package/dist/esm/components/QueryEditor/EditorHeader.js +2 -2
  60. package/dist/esm/components/QueryEditor/EditorRow.js +2 -2
  61. package/dist/esm/components/QueryEditor/EditorSwitch.js +2 -2
  62. package/dist/esm/components/QueryEditor/InputGroup.js +2 -2
  63. package/dist/esm/components/QueryEditor/Space.js +2 -2
  64. package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js +2 -2
  65. package/dist/esm/components/QueryEditor/visual-query-builder/EditorField.js +2 -2
  66. package/dist/esm/components/QueryEditor/visual-query-builder/EditorRow.js +2 -2
  67. package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js +2 -2
  68. package/dist/esm/components/QueryEditor/visual-query-builder/SelectRow.js +2 -2
  69. package/dist/esm/components/SQLEditor/utils/LinkedToken.js +8 -8
  70. package/dist/esm/datasource/SqlDatasource.js +11 -11
  71. package/dist/esm/index.d.ts +852 -542
  72. package/dist/esm/index.js +9 -1
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/node_modules/immutable/dist/immutable.es.js +11 -11
  75. package/dist/esm/node_modules/immutable/dist/immutable.es.js.map +1 -1
  76. package/dist/esm/node_modules/react-hook-form/dist/index.esm.js +2798 -0
  77. package/dist/esm/node_modules/react-hook-form/dist/index.esm.js.map +1 -0
  78. package/dist/esm/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +2 -2
  79. package/dist/esm/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +1 -1
  80. package/dist/esm/schema/utils/dsconfig.js +97 -0
  81. package/dist/esm/schema/utils/dsconfig.js.map +1 -0
  82. package/dist/esm/schema/utils/llm.js +54 -0
  83. package/dist/esm/schema/utils/llm.js.map +1 -0
  84. package/dist/esm/schema/utils/provisioning.js +2 -2
  85. package/dist/esm/schema/utils/provisioning.js.map +1 -1
  86. package/package.json +2 -1
@@ -1,4 +1,4 @@
1
- import React, { ComponentProps, PureComponent, ReactElement, ReactNode, FunctionComponent, HTMLProps } from 'react';
1
+ import React, { ComponentProps, PureComponent, ReactElement, ReactNode, Component, ErrorInfo, FunctionComponent, HTMLProps } from 'react';
2
2
  import { Input, Segment as Segment$1, monacoTypes, Monaco, ButtonProps, Field, PopoverContent, Switch, SelectCommonProps, InlineLabel } from '@grafana/ui';
3
3
  import { DataSourceInstanceSettings, SelectableValue, DataSourceJsonData, VariableSuggestion, TimeRange, DataFrame, MetricFindValue, ThemeSpacingTokens, ScopedVars, VariableModel, DataFrameView, QueryEditorProps as QueryEditorProps$1, DataSourceSettings, RegistryItem, DataSourceApi, Registry, DataQuery as DataQuery$1, PanelData, DataQueryRequest, DataQueryResponse, LoadingState } from '@grafana/data';
4
4
  import { DataSourceSrv, DataSourceWithBackend, TemplateSrv } from '@grafana/runtime';
@@ -1024,287 +1024,6 @@ type Props$a<C extends Config = Config> = {
1024
1024
  };
1025
1025
  declare const AdvancedHttpSettings: <C extends Config = Config>(props: Props$a<C>) => JSX.Element;
1026
1026
 
1027
- interface CustomHeader {
1028
- id: string;
1029
- name: string;
1030
- value: string;
1031
- configured: boolean;
1032
- }
1033
- type CustomHeaders = CustomHeader[];
1034
- interface Props$9 {
1035
- dataSourceConfig: DataSourceSettings<any, any>;
1036
- onChange: (config: DataSourceSettings) => void;
1037
- }
1038
- interface State {
1039
- headers: CustomHeaders;
1040
- }
1041
- declare class CustomHeadersSettings extends PureComponent<Props$9, State> {
1042
- state: State;
1043
- constructor(props: Props$9);
1044
- updateSettings: () => void;
1045
- onHeaderAdd: () => void;
1046
- onHeaderChange: (headerIndex: number, value: CustomHeader) => void;
1047
- onHeaderReset: (headerId: string) => void;
1048
- onHeaderRemove: (headerId: string) => void;
1049
- render(): React.JSX.Element;
1050
- }
1051
-
1052
- interface QueryBuilderLabelFilter {
1053
- label: string;
1054
- op: string;
1055
- value: string;
1056
- }
1057
- interface QueryBuilderOperation {
1058
- id: string;
1059
- params: QueryBuilderOperationParamValue[];
1060
- disabled?: boolean;
1061
- }
1062
- interface QueryBuilderOperationDefinition<T = any> extends RegistryItem {
1063
- documentation?: string;
1064
- params: QueryBuilderOperationParamDef[];
1065
- defaultParams: QueryBuilderOperationParamValue[];
1066
- category: string;
1067
- hideFromList?: boolean;
1068
- alternativesKey?: string;
1069
- /** Can be used to control operation placement when adding a new operations, lower are placed first */
1070
- orderRank?: number;
1071
- renderer: QueryBuilderOperationRenderer;
1072
- addOperationHandler: QueryBuilderAddOperationHandler<T>;
1073
- paramChangedHandler?: QueryBuilderOnParamChangedHandler;
1074
- explainHandler?: QueryBuilderExplainOperationHandler;
1075
- changeTypeHandler?: (op: QueryBuilderOperation, newDef: QueryBuilderOperationDefinition<T>) => QueryBuilderOperation;
1076
- toggleable?: boolean;
1077
- }
1078
- type QueryBuilderAddOperationHandler<T> = (def: QueryBuilderOperationDefinition, query: T, modeller: VisualQueryModeller) => T;
1079
- type QueryBuilderExplainOperationHandler = (op: QueryBuilderOperation, def?: QueryBuilderOperationDefinition) => string;
1080
- type QueryBuilderOnParamChangedHandler = (index: number, operation: QueryBuilderOperation, operationDef: QueryBuilderOperationDefinition) => QueryBuilderOperation;
1081
- type QueryBuilderOperationRenderer = (model: QueryBuilderOperation, def: QueryBuilderOperationDefinition, innerQuery: string) => string;
1082
- type QueryBuilderOperationParamValue = string | number | boolean;
1083
- interface QueryBuilderOperationParamDef {
1084
- name: string;
1085
- type: 'string' | 'number' | 'boolean';
1086
- options?: string[] | number[] | Array<SelectableValue<string>>;
1087
- hideName?: boolean;
1088
- restParam?: boolean;
1089
- optional?: boolean;
1090
- placeholder?: string;
1091
- description?: string;
1092
- minWidth?: number;
1093
- editor?: FunctionComponent<QueryBuilderOperationParamEditorProps>;
1094
- runQueryOnEnter?: boolean;
1095
- }
1096
- interface QueryBuilderOperationParamEditorProps {
1097
- value?: QueryBuilderOperationParamValue;
1098
- paramDef: QueryBuilderOperationParamDef;
1099
- /** Parameter index */
1100
- index: number;
1101
- operation: QueryBuilderOperation;
1102
- operationId: string;
1103
- query: any;
1104
- datasource: DataSourceApi;
1105
- timeRange?: TimeRange;
1106
- onChange: (index: number, value: QueryBuilderOperationParamValue) => void;
1107
- onRunQuery: () => void;
1108
- queryModeller: VisualQueryModeller;
1109
- }
1110
- declare enum QueryEditorMode {
1111
- Code = "code",
1112
- Builder = "builder"
1113
- }
1114
- type QueryStats = {
1115
- bytes: number;
1116
- message?: string;
1117
- };
1118
- interface VisualQueryModeller {
1119
- getOperationsForCategory(category: string): QueryBuilderOperationDefinition[];
1120
- getAlternativeOperations(key: string): QueryBuilderOperationDefinition[];
1121
- getCategories(): string[];
1122
- getOperationDefinition(id: string): QueryBuilderOperationDefinition | undefined;
1123
- renderQuery(query: VisualQuery, nested?: boolean): string;
1124
- renderLabels(labels: QueryBuilderLabelFilter[]): string;
1125
- innerQueryPlaceholder: string;
1126
- }
1127
- interface VisualQueryBinary<T> {
1128
- operator: string;
1129
- vectorMatchesType?: 'on' | 'ignoring';
1130
- vectorMatches?: string;
1131
- query: T;
1132
- }
1133
- declare const BINARY_OPERATIONS_KEY = "Binary operations";
1134
- interface VisualQuery {
1135
- metric?: string;
1136
- labels: QueryBuilderLabelFilter[];
1137
- operations: QueryBuilderOperation[];
1138
- binaryQueries?: Array<VisualQueryBinary<VisualQuery>>;
1139
- }
1140
-
1141
- declare abstract class QueryModellerBase implements VisualQueryModeller {
1142
- protected operationsRegistry: Registry<QueryBuilderOperationDefinition>;
1143
- private categories;
1144
- innerQueryPlaceholder: string;
1145
- constructor(operationDefinitions: QueryBuilderOperationDefinition[], innerQueryPlaceholder?: string);
1146
- protected setOperationCategories(categories: string[]): void;
1147
- abstract renderOperations(queryString: string, operations: QueryBuilderOperation[]): string;
1148
- abstract renderBinaryQueries(queryString: string, binaryQueries?: Array<VisualQueryBinary<VisualQuery>>): string;
1149
- abstract renderLabels(labels: QueryBuilderLabelFilter[]): string;
1150
- abstract renderQuery(query: VisualQuery, nested?: boolean): string;
1151
- getOperationsForCategory(category: string): QueryBuilderOperationDefinition<any>[];
1152
- getAlternativeOperations(key: string): QueryBuilderOperationDefinition<any>[];
1153
- getCategories(): string[];
1154
- getOperationDefinition(id: string): QueryBuilderOperationDefinition | undefined;
1155
- hasBinaryOp(query: VisualQuery): boolean;
1156
- }
1157
-
1158
- interface Props$8 {
1159
- labelsFilters: QueryBuilderLabelFilter[];
1160
- onChange: (labelFilters: QueryBuilderLabelFilter[]) => void;
1161
- onGetLabelNames: (forLabel: Partial<QueryBuilderLabelFilter>) => Promise<SelectableValue[]>;
1162
- onGetLabelValues: (forLabel: Partial<QueryBuilderLabelFilter>) => Promise<SelectableValue[]>;
1163
- /** If set to true, component will show error message until at least 1 filter is selected */
1164
- labelFilterRequired?: boolean;
1165
- multiValueSeparator?: string;
1166
- }
1167
- declare function LabelFilters({ labelsFilters, onChange, onGetLabelNames, onGetLabelValues, labelFilterRequired, multiValueSeparator, }: Props$8): React.JSX.Element;
1168
-
1169
- interface Props$7 {
1170
- title?: React.ReactNode;
1171
- markdown?: string;
1172
- stepNumber?: number;
1173
- }
1174
- declare function OperationExplainedBox({ title, stepNumber, markdown, children }: React.PropsWithChildren<Props$7>): React.JSX.Element;
1175
-
1176
- interface Props$6<T extends VisualQuery> {
1177
- query: T;
1178
- datasource: DataSourceApi;
1179
- onChange: (query: T) => void;
1180
- onRunQuery: () => void;
1181
- queryModeller: VisualQueryModeller;
1182
- explainMode?: boolean;
1183
- highlightedOp?: QueryBuilderOperation;
1184
- timeRange?: TimeRange;
1185
- isConflictingOperation?: (operation: QueryBuilderOperation, otherOperations: QueryBuilderOperation[]) => boolean;
1186
- }
1187
- declare function OperationList<T extends VisualQuery>({ query, datasource, queryModeller, onChange, onRunQuery, highlightedOp, timeRange, isConflictingOperation, }: Props$6<T>): React.JSX.Element;
1188
-
1189
- interface Props$5<T extends VisualQuery> {
1190
- query: T;
1191
- queryModeller: VisualQueryModeller;
1192
- explainMode?: boolean;
1193
- stepNumber: number;
1194
- language: {
1195
- grammar: Grammar;
1196
- name: string;
1197
- };
1198
- onMouseEnter?: (op: QueryBuilderOperation, index: number) => void;
1199
- onMouseLeave?: (op: QueryBuilderOperation, index: number) => void;
1200
- }
1201
- declare function OperationListExplained<T extends VisualQuery>({ query, queryModeller, stepNumber, language, onMouseEnter, onMouseLeave, }: Props$5<T>): React.JSX.Element;
1202
-
1203
- declare function OperationsEditorRow({ children }: React.PropsWithChildren<{}>): React.JSX.Element;
1204
-
1205
- interface Props$4<TVisualQuery extends VisualQuery, TDataQuery extends DataQuery$1> {
1206
- query: TVisualQuery;
1207
- datasource: DataSourceApi<TDataQuery>;
1208
- queryModeller: VisualQueryModeller;
1209
- buildVisualQueryFromString: (queryString: string) => {
1210
- query: TVisualQuery;
1211
- };
1212
- buildDataQueryFromQueryString: (queryString: string) => TDataQuery;
1213
- buildQueryStringFromDataQuery: (dataQuery: TDataQuery) => string;
1214
- onChange: (update: TVisualQuery) => void;
1215
- data?: PanelData;
1216
- }
1217
- declare const QueryBuilderHints: {
1218
- <TVisualQuery extends VisualQuery, TDataQuery extends DataQuery$1>({ datasource, query: visualQuery, onChange, data, queryModeller, buildVisualQueryFromString, buildDataQueryFromQueryString, buildQueryStringFromDataQuery, }: Props$4<TVisualQuery, TDataQuery>): React.JSX.Element;
1219
- displayName: string;
1220
- };
1221
-
1222
- interface Props$3 {
1223
- mode: QueryEditorMode;
1224
- onChange: (mode: QueryEditorMode) => void;
1225
- }
1226
- declare function QueryEditorModeToggle({ mode, onChange }: Props$3): React.JSX.Element;
1227
-
1228
- interface Props$2 extends Omit<HTMLProps<HTMLInputElement>, 'value' | 'ref'> {
1229
- value?: boolean;
1230
- label: string;
1231
- }
1232
- declare function QueryHeaderSwitch({ label, ...inputProps }: Props$2): React.JSX.Element;
1233
-
1234
- interface Props$1 {
1235
- title: string;
1236
- collapsedInfo: string[];
1237
- queryStats?: QueryStats | null;
1238
- }
1239
- declare function QueryOptionGroup({ title, children, collapsedInfo, queryStats }: React.PropsWithChildren<Props$1>): React.JSX.Element;
1240
-
1241
- interface Props {
1242
- query: string;
1243
- language: {
1244
- grammar: Grammar;
1245
- name: string;
1246
- };
1247
- className?: string;
1248
- }
1249
- declare function RawQuery({ query, language, className }: Props): React.JSX.Element;
1250
-
1251
- interface CustomMeta {
1252
- queryID: string;
1253
- status: string;
1254
- }
1255
- interface RunningQueryInfo {
1256
- queryID?: string;
1257
- shouldCancel?: boolean;
1258
- }
1259
- declare class DatasourceWithAsyncBackend<TQuery extends DataQuery$1 = DataQuery$1, TOptions extends DataSourceJsonData = DataSourceJsonData> extends DataSourceWithBackend<TQuery, TOptions> {
1260
- private runningQueries;
1261
- private requestCounter;
1262
- private requestIdPrefix;
1263
- constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);
1264
- query(request: DataQueryRequest<TQuery>): Observable<DataQueryResponse>;
1265
- storeQuery(target: TQuery, queryInfo: RunningQueryInfo): void;
1266
- getQuery(target: TQuery): RunningQueryInfo;
1267
- removeQuery(target: TQuery): void;
1268
- doSingle(target: TQuery, request: DataQueryRequest<TQuery>): Observable<DataQueryResponse>;
1269
- cancel: (target: TQuery) => void;
1270
- }
1271
-
1272
- interface RunQueryButtonsProps<TQuery extends DataQuery$1> {
1273
- enableRun?: boolean;
1274
- onRunQuery: () => void;
1275
- onCancelQuery: (query: TQuery) => void;
1276
- query: TQuery;
1277
- state?: LoadingState;
1278
- }
1279
- declare const RunQueryButtons: <TQuery extends DataQuery$1>(props: RunQueryButtonsProps<TQuery>) => React.JSX.Element;
1280
-
1281
- interface RequestLoopOptions<TQuery extends DataQuery$1 = DataQuery$1> {
1282
- /**
1283
- * If the response needs an additional request to execute, return it here
1284
- */
1285
- getNextQuery: (rsp: DataQueryResponse) => TQuery | undefined;
1286
- /**
1287
- * The datasource execute method
1288
- */
1289
- query: (req: DataQueryRequest<TQuery>) => Observable<DataQueryResponse>;
1290
- /**
1291
- * Process the results
1292
- */
1293
- process: (data: DataFrame[]) => DataFrame[];
1294
- /**
1295
- * Check if the query should be cancelled
1296
- */
1297
- shouldCancel: () => boolean;
1298
- /**
1299
- * Callback that gets executed when unsubscribed
1300
- */
1301
- onCancel: () => void;
1302
- }
1303
- /**
1304
- * Continue executing requests as long as `getNextQuery` returns a query
1305
- */
1306
- declare function getRequestLooper<T extends DataQuery$1 = DataQuery$1>(req: DataQueryRequest<T>, options: RequestLoopOptions<T>): Observable<DataQueryResponse>;
1307
-
1308
1027
  interface DatasourceConfigSchema {
1309
1028
  /**
1310
1029
  * Schema version (required)
@@ -1326,6 +1045,13 @@ interface DatasourceConfigSchema {
1326
1045
  * Optional documentation URL
1327
1046
  */
1328
1047
  docURL?: string;
1048
+ /**
1049
+ * SDK field packs to merge into this schema before validation.
1050
+ * Pack fields are prepended to `fields` in declaration order.
1051
+ * Plugin-declared fields with a matching ID take precedence over pack fields.
1052
+ * Call `resolveBaseFields()` before consuming the schema.
1053
+ */
1054
+ baseFields?: BaseFieldRef[];
1329
1055
  /**
1330
1056
  * Source of truth for configuration
1331
1057
  */
@@ -1334,11 +1060,62 @@ interface DatasourceConfigSchema {
1334
1060
  * Optional UI grouping
1335
1061
  */
1336
1062
  groups?: ConfigGroup[];
1063
+ /**
1064
+ * Optional instructions rendered alongside the config form.
1065
+ */
1066
+ instructions?: Instruction[];
1337
1067
  /**
1338
1068
  * Relationships between fields
1339
1069
  */
1340
1070
  relationships?: FieldRelationship[];
1341
1071
  }
1072
+ interface Instruction {
1073
+ msg: string;
1074
+ tags?: string[];
1075
+ }
1076
+ /**
1077
+ * Identifier of a built-in field pack defined by grafana/dsconfig.
1078
+ * Convention: `<sdk_name>_settings`.
1079
+ */
1080
+ type FieldPackID = 'plugin_sdk_settings' | 'aws_sdk_settings' | 'azure_sdk_settings' | 'google_sdk_settings' | 'sqleng_settings';
1081
+ /**
1082
+ * Declares a single field pack to compose into the schema.
1083
+ */
1084
+ interface BaseFieldRef {
1085
+ /** Identifier of a built-in field pack. */
1086
+ from: FieldPackID;
1087
+ /**
1088
+ * Field IDs from the pack to omit entirely.
1089
+ * Each ID must exist in the pack (else resolution fails).
1090
+ */
1091
+ exclude?: string[];
1092
+ /**
1093
+ * Presentation-only overrides keyed by pack field ID.
1094
+ * Structural properties (id, key, valueType, target, role) cannot be patched.
1095
+ */
1096
+ patch?: Record<string, FieldPatch>;
1097
+ }
1098
+ /**
1099
+ * Safe-to-override presentation properties for a pack field.
1100
+ * Only non-undefined values are applied.
1101
+ */
1102
+ interface FieldPatch {
1103
+ label?: string;
1104
+ description?: string;
1105
+ placeholder?: string;
1106
+ defaultValue?: unknown;
1107
+ required?: boolean;
1108
+ /** When true, the field is dropped from the resolved schema. */
1109
+ hidden?: boolean;
1110
+ }
1111
+ /**
1112
+ * Named set of ConfigField definitions provided by an SDK.
1113
+ * Pack field IDs are namespaced with the pack ID, e.g. `plugin_sdk_settings.url`.
1114
+ */
1115
+ interface FieldPack {
1116
+ id: FieldPackID;
1117
+ fields: ConfigField[];
1118
+ }
1342
1119
  interface ConfigField {
1343
1120
  /**
1344
1121
  * Globally unique identifier
@@ -1364,6 +1141,11 @@ interface ConfigField {
1364
1141
  * Storage location (required for storage fields)
1365
1142
  */
1366
1143
  target?: TargetLocation;
1144
+ /**
1145
+ * Semantic role identifying what a field represents to the SDK.
1146
+ * Field packs annotate their fields with roles (e.g. `endpoint.baseUrl`).
1147
+ */
1148
+ role?: Role;
1367
1149
  /**
1368
1150
  * Dotted path prefix within the target for nested objects.
1369
1151
  * Example: for jsonData.tracesToLogs.datasourceUid,
@@ -1374,329 +1156,857 @@ interface ConfigField {
1374
1156
  * Field kind.
1375
1157
  * @default "storage"
1376
1158
  */
1377
- kind?: FieldKind;
1159
+ kind?: FieldKind;
1160
+ /**
1161
+ * True if field belongs to array item schema
1162
+ */
1163
+ isItemField?: boolean;
1164
+ /**
1165
+ * UI rendering hints
1166
+ */
1167
+ ui?: FieldUI;
1168
+ /**
1169
+ * Validations rules
1170
+ */
1171
+ validations?: FieldValidationRule[];
1172
+ /**
1173
+ * Visibility condition (CEL expression)
1174
+ */
1175
+ dependsOn?: Expression;
1176
+ /**
1177
+ * Always required
1178
+ */
1179
+ required?: boolean;
1180
+ /**
1181
+ * Conditionally required
1182
+ */
1183
+ requiredWhen?: Expression;
1184
+ /**
1185
+ * Disabled condition
1186
+ */
1187
+ disabledWhen?: Expression;
1188
+ /**
1189
+ * Dynamic overrides
1190
+ */
1191
+ overrides?: FieldOverride[];
1192
+ /**
1193
+ * Declarative multi-field write side-effects.
1194
+ * When this field's value matches a condition, the listed target
1195
+ * fields are set to specified values. Typically used on virtual
1196
+ * selector fields (e.g. auth method dropdown).
1197
+ */
1198
+ effects?: FieldEffect[];
1199
+ /**
1200
+ * Item schema for array elements or map values.
1201
+ * Required if valueType === "array" or "map".
1202
+ */
1203
+ item?: FieldItemSchema;
1204
+ /**
1205
+ * Legacy indexed fields (deprecated)
1206
+ */
1207
+ repeatable?: boolean;
1208
+ pattern?: string;
1209
+ /**
1210
+ * Storage mapping
1211
+ */
1212
+ storage?: StorageMapping;
1213
+ /**
1214
+ * Metadata
1215
+ */
1216
+ tags?: string[];
1217
+ examples?: unknown[];
1218
+ defaultValue?: unknown;
1219
+ }
1220
+ interface FieldItemSchema {
1221
+ /**
1222
+ * Type of array items or map values.
1223
+ * For arrays, describes each element.
1224
+ * For maps, describes each value (keys are always strings).
1225
+ */
1226
+ valueType: ValueType;
1227
+ /**
1228
+ * Sub-fields for object items. Optional even when valueType = "object"
1229
+ * (omitting allows an unconstrained object).
1230
+ */
1231
+ fields?: ConfigField[];
1232
+ }
1233
+ /**
1234
+ * CEL expression string
1235
+ */
1236
+ type Expression = string;
1237
+ type ValueType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'map' | 'any';
1238
+ type FieldKind = 'storage' | 'virtual';
1239
+ type TargetLocation = 'root' | 'jsonData' | 'secureJsonData';
1240
+ /**
1241
+ * Semantic role identifying what a field represents to the SDK.
1242
+ * Kept as `string` for forward compatibility with newer packs from
1243
+ * grafana/dsconfig; see that repo for the canonical role list.
1244
+ */
1245
+ type Role = string;
1246
+ type UIComponent = 'input' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'checkbox' | 'switch' | 'code' | 'keyvalue' | 'list' | 'fileUpload';
1247
+ type UIWidth = 'full' | 'half';
1248
+ /**
1249
+ * UI configuration
1250
+ */
1251
+ interface FieldUI {
1252
+ component: UIComponent;
1253
+ multiline?: boolean;
1254
+ rows?: number;
1255
+ options?: FieldOption[];
1256
+ allowCustom?: boolean;
1257
+ width?: UIWidth;
1258
+ placeholder?: string;
1259
+ /**
1260
+ * Language hint for code editor components.
1261
+ * Example: "promql", "logql", "traceql", "sql", "json"
1262
+ */
1263
+ language?: string;
1264
+ /**
1265
+ * Layout row index for item fields inside object arrays.
1266
+ * Fields with the same row number are rendered horizontally.
1267
+ * Fields without a row number use auto-layout:
1268
+ * - ≤3 fields: all on one row
1269
+ * - >3 fields: each on its own row
1270
+ */
1271
+ row?: number;
1272
+ /**
1273
+ * Accepted file types for fileUpload component.
1274
+ * Uses HTML accept attribute format with leading dot.
1275
+ * Example: [".json"]
1276
+ */
1277
+ accept?: string[];
1378
1278
  /**
1379
- * True if field belongs to array item schema
1279
+ * Maps keys in an uploaded JSON file to target field IDs.
1280
+ * Used by fileUpload to distribute parsed values to other form fields.
1281
+ * Example: { "private_key": "secureJsonData.privateKey", "client_email": "jsonData.clientEmail" }
1380
1282
  */
1381
- isItemField?: boolean;
1283
+ fileMapping?: Record<string, string>;
1284
+ }
1285
+ type FieldValidationRule = PatternValidationRule | RangeValidationRule | LengthValidationRule | ItemCountValidationRule | AllowedValuesValidationRule | CustomValidationRule;
1286
+ interface BaseValidationRule {
1382
1287
  /**
1383
- * UI rendering hints
1288
+ * Optional stable ID for the validation rule.
1289
+ * Useful for docs, localization, and test snapshots.
1384
1290
  */
1385
- ui?: FieldUI;
1291
+ id?: string;
1386
1292
  /**
1387
- * Validations rules
1293
+ * Human-readable validation error message.
1388
1294
  */
1389
- validations?: FieldValidationRule[];
1295
+ message?: string;
1296
+ }
1297
+ interface PatternValidationRule extends BaseValidationRule {
1298
+ type: 'pattern';
1299
+ pattern: string;
1300
+ }
1301
+ interface RangeValidationRule extends BaseValidationRule {
1302
+ type: 'range';
1303
+ min?: number;
1304
+ max?: number;
1305
+ }
1306
+ interface LengthValidationRule extends BaseValidationRule {
1307
+ type: 'length';
1308
+ min?: number;
1309
+ max?: number;
1310
+ }
1311
+ interface ItemCountValidationRule extends BaseValidationRule {
1312
+ type: 'itemCount';
1313
+ min?: number;
1314
+ max?: number;
1315
+ }
1316
+ interface AllowedValuesValidationRule extends BaseValidationRule {
1317
+ type: 'allowedValues';
1318
+ values: unknown[];
1319
+ }
1320
+ interface CustomValidationRule extends BaseValidationRule {
1321
+ type: 'custom';
1390
1322
  /**
1391
- * Visibility condition (CEL expression)
1323
+ * CEL expression.
1324
+ *
1325
+ * Should evaluate to true when the field value is valid.
1392
1326
  */
1393
- dependsOn?: Expression;
1327
+ expression: Expression;
1328
+ }
1329
+ interface FieldOverride {
1394
1330
  /**
1395
- * Always required
1331
+ * CEL condition
1396
1332
  */
1397
- required?: boolean;
1333
+ when: Expression;
1334
+ defaultValue?: unknown;
1398
1335
  /**
1399
- * Conditionally required
1336
+ * When true, the field is disabled/read-only while this override is active.
1400
1337
  */
1401
- requiredWhen?: Expression;
1338
+ readOnly?: boolean;
1339
+ description?: string;
1340
+ placeholder?: string;
1341
+ tooltip?: string;
1342
+ validations?: FieldValidationRule[];
1343
+ options?: FieldOption[];
1402
1344
  /**
1403
- * Disabled condition
1345
+ * When present on an `isItemField` field, the value is routed to
1346
+ * `secureJsonData` under the resolved key instead of being stored
1347
+ * inline in the parent array.
1348
+ *
1349
+ * The template string supports placeholders:
1350
+ * - `{index}` — 0-based array position
1351
+ * - `{index1}` — 1-based array position
1352
+ * - `{item.KEY}` — value of sibling item field `KEY`
1353
+ *
1354
+ * Examples:
1355
+ * - `"secureHttpHeaders.{item.name}"` (ClickHouse)
1356
+ * - `"httpHeaderValue{index1}"` (Grafana core headers)
1404
1357
  */
1405
- disabledWhen?: Expression;
1358
+ secureKey?: string;
1359
+ }
1360
+ /**
1361
+ * Declares that when a field's value matches a condition,
1362
+ * listed target fields should be set to specified values.
1363
+ *
1364
+ * Use "value" in the `when` expression to refer to the field's value.
1365
+ */
1366
+ interface FieldEffect {
1406
1367
  /**
1407
- * Dynamic overrides
1368
+ * CEL expression. Example: "value == 'basic-auth'"
1408
1369
  */
1409
- overrides?: FieldOverride[];
1370
+ when: Expression;
1410
1371
  /**
1411
- * Declarative multi-field write side-effects.
1412
- * When this field's value matches a condition, the listed target
1413
- * fields are set to specified values. Typically used on virtual
1414
- * selector fields (e.g. auth method dropdown).
1372
+ * Maps field IDs to the values they should be set to.
1373
+ * Must contain at least one entry.
1415
1374
  */
1416
- effects?: FieldEffect[];
1375
+ set: Record<string, unknown> & {
1376
+ [k: string]: unknown;
1377
+ };
1378
+ }
1379
+ type StorageMapping = DirectMapping | IndexedPairMapping | ComputedMapping;
1380
+ /**
1381
+ * Direct mapping
1382
+ */
1383
+ interface DirectMapping {
1384
+ type: 'direct';
1385
+ }
1386
+ /**
1387
+ * Indexed pair mapping (headers)
1388
+ */
1389
+ interface IndexedPairMapping {
1390
+ type: 'indexedPair';
1391
+ key: MappingField;
1392
+ value: MappingField;
1393
+ startIndex?: number;
1394
+ }
1395
+ /**
1396
+ * Computed mapping (virtual fields).
1397
+ * At least one of `read` or `write` must be provided.
1398
+ */
1399
+ type ComputedMapping = {
1400
+ type: 'computed';
1401
+ read: Expression;
1402
+ write?: Expression;
1403
+ } | {
1404
+ type: 'computed';
1405
+ read?: Expression;
1406
+ write: Expression;
1407
+ };
1408
+ /**
1409
+ * Mapping field
1410
+ */
1411
+ interface MappingField {
1412
+ target: TargetLocation;
1413
+ pattern: string;
1414
+ }
1415
+ interface FieldOption {
1416
+ label: string;
1417
1417
  /**
1418
- * Item schema for array elements or map values.
1419
- * Required if valueType === "array" or "map".
1418
+ * Must match parent field valueType.
1419
+ * Must not be null.
1420
1420
  */
1421
- item?: FieldItemSchema;
1421
+ value: NonNullable<unknown>;
1422
1422
  /**
1423
- * Legacy indexed fields (deprecated)
1423
+ * Optional human-readable description of the option.
1424
1424
  */
1425
- repeatable?: boolean;
1426
- pattern?: string;
1425
+ description?: string;
1426
+ }
1427
+ interface ConfigGroup {
1428
+ id: string;
1429
+ title: string;
1430
+ description?: string;
1431
+ order?: number;
1427
1432
  /**
1428
- * Storage mapping
1433
+ * When true, the group is optional and can be collapsed/hidden by default.
1429
1434
  */
1430
- storage?: StorageMapping;
1435
+ optional?: boolean;
1431
1436
  /**
1432
- * Metadata
1437
+ * References field IDs (not keys)
1433
1438
  */
1434
- tags?: string[];
1435
- examples?: unknown[];
1436
- defaultValue?: unknown;
1439
+ fieldRefs: string[];
1437
1440
  }
1438
- interface FieldItemSchema {
1441
+ type RelationshipType = 'pair' | 'group' | 'datasourceReference';
1442
+ interface FieldRelationship {
1443
+ type: RelationshipType;
1439
1444
  /**
1440
- * Type of array items or map values.
1441
- * For arrays, describes each element.
1442
- * For maps, describes each value (keys are always strings).
1445
+ * References field IDs
1443
1446
  */
1444
- valueType: ValueType;
1447
+ fields: string[];
1448
+ description?: string;
1445
1449
  /**
1446
- * Sub-fields for object items. Optional even when valueType = "object"
1447
- * (omitting allows an unconstrained object).
1450
+ * Constrains the datasource UID to a specific plugin type.
1451
+ * Only applicable when type is "datasourceReference".
1448
1452
  */
1449
- fields?: ConfigField[];
1453
+ targetPluginType?: string;
1454
+ }
1455
+ type SecureFieldState = {
1456
+ type: 'unset';
1457
+ } | {
1458
+ type: 'configured';
1459
+ } | {
1460
+ type: 'updated';
1461
+ value: string;
1462
+ };
1463
+ interface FormState {
1464
+ values: Record<string, unknown>;
1465
+ secure: Record<string, SecureFieldState>;
1466
+ }
1467
+
1468
+ type DatasourceConfigWizardProps = {
1469
+ schema: DatasourceConfigSchema;
1470
+ dsUid: string;
1471
+ dsName: string;
1472
+ onSuccess: (status: string, message?: string) => void;
1473
+ onSaving?: (saving: boolean) => void;
1474
+ onRetest?: () => void;
1475
+ onFollowup?: (intent: string) => void;
1476
+ healthError?: string;
1477
+ /** Optional render prop for custom action buttons (e.g. analyze/troubleshoot). */
1478
+ renderActions?: (props: {
1479
+ dsUid: string;
1480
+ dsName: string;
1481
+ dsType: string;
1482
+ healthError?: string;
1483
+ }) => ReactNode;
1484
+ };
1485
+ declare function DatasourceConfigWizard(props: DatasourceConfigWizardProps): React.JSX.Element;
1486
+
1487
+ /** Lightweight error boundary scoped to datasource config widgets — won't crash the host UI. */
1488
+ declare class DatasourceErrorBoundary extends Component<{
1489
+ children: ReactNode;
1490
+ dsName?: string;
1491
+ }, {
1492
+ error: Error | null;
1493
+ }> {
1494
+ state: {
1495
+ error: Error | null;
1496
+ };
1497
+ static getDerivedStateFromError(error: Error): {
1498
+ error: Error;
1499
+ };
1500
+ componentDidCatch(error: Error, info: ErrorInfo): void;
1501
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
1502
+ }
1503
+
1504
+ type HealthState = 'pending' | 'checking' | 'done';
1505
+ interface DatasourceHealth {
1506
+ state: HealthState;
1507
+ status?: string;
1508
+ message?: string;
1450
1509
  }
1451
1510
  /**
1452
- * CEL expression string
1511
+ * Health check hook — on-demand only.
1512
+ * Call `checkUids(uids)` to trigger checks for specific UIDs.
1513
+ * Call `retry(uid)` to force re-check a single UID.
1514
+ * UIDs that have already been checked (or are in-flight) are automatically skipped.
1515
+ */
1516
+ declare function useHealthChecks(): {
1517
+ healthMap: Record<string, DatasourceHealth>;
1518
+ checkUids: (uids: string[]) => void;
1519
+ retry: (uid: string) => void;
1520
+ };
1521
+
1522
+ declare function resolvePluginName(pluginType: string): string;
1523
+
1524
+ /**
1525
+ * CEL (Common Expression Language) expression evaluator for schema conditions.
1526
+ *
1527
+ * Used by `dependsOn`, `requiredWhen`, `disabledWhen`, and `overrides[].when`.
1528
+ * Wraps @marcbachmann/cel-js with field-ID-aware context building.
1529
+ *
1530
+ * Go equivalent: github.com/google/cel-go
1531
+ */
1532
+ /**
1533
+ * Build a nested context object from flat form values keyed by field IDs.
1534
+ *
1535
+ * CEL interprets dots as property access, so `jsonData.auth_method == 'oauth2'`
1536
+ * requires `{ jsonData: { auth_method: 'oauth2' } }`.
1537
+ *
1538
+ * This function takes flat key-value pairs (from react-hook-form `watch()`)
1539
+ * and builds the nested structure CEL expects.
1540
+ *
1541
+ * @param values - Flat map of form keys to values (e.g. `{ "auth_method": "oauth2", "oauth2.oauth2_type": "jwt" }`)
1542
+ * @param fieldIdToFormKey - Optional map from field ID to form key for translation
1543
+ */
1544
+ declare function buildCelContext(values: Record<string, unknown>): Record<string, unknown>;
1545
+ /**
1546
+ * Evaluate a CEL expression against a context of field values.
1547
+ * Returns the boolean result, or `defaultValue` if the expression is invalid.
1548
+ *
1549
+ * @example
1550
+ * ```ts
1551
+ * evaluateCelExpression("jsonData.auth_method == 'oauth2'", { jsonData: { auth_method: 'oauth2' } })
1552
+ * // => true
1553
+ *
1554
+ * evaluateCelExpression("auth_method == 'oauth2' && oauth2_type == 'jwt'", { auth_method: 'oauth2', oauth2_type: 'jwt' })
1555
+ * // => true
1556
+ * ```
1557
+ */
1558
+ declare function evaluateCelExpression(expr: string, context: Record<string, unknown>, defaultValue?: boolean): boolean;
1559
+ /**
1560
+ * Evaluate a CEL expression directly using `evaluate` (no caching).
1561
+ * Useful for one-off evaluations or testing.
1562
+ */
1563
+ declare function evaluateCelDirect(expr: string, context: Record<string, unknown>): unknown;
1564
+ /**
1565
+ * Validate that a CEL expression can be parsed without errors.
1566
+ * Returns true if valid, false otherwise.
1567
+ */
1568
+ declare function isValidCelExpression(expr: string): boolean;
1569
+ /**
1570
+ * Extract all field ID references from a simple expression.
1571
+ * Used by `resolveRequiredFieldsGroup` to find dependency relationships.
1572
+ *
1573
+ * For simple expressions like `fieldA == 'x'`, returns `['fieldA']`.
1574
+ * For compound expressions like `fieldA == 'x' && fieldB == 'y'`, returns `['fieldA', 'fieldB']`.
1575
+ *
1576
+ * This uses regex extraction (not AST walking) for simplicity and speed.
1577
+ */
1578
+ declare function extractFieldRefs(expr: string): string[];
1579
+ /**
1580
+ * Clear the expression cache. Useful for testing.
1581
+ */
1582
+ declare function clearExpressionCache(): void;
1583
+
1584
+ type TroubleShootingContext = {
1585
+ label: string;
1586
+ key: string;
1587
+ target: string;
1588
+ type: string;
1589
+ required: boolean;
1590
+ description?: string;
1591
+ defaultValue?: unknown;
1592
+ options?: string[];
1593
+ section?: string;
1594
+ dependsOn?: string;
1595
+ };
1596
+ /**
1597
+ * Generate LLM hints for select fields (used when creating datasources).
1598
+ */
1599
+ declare function generateLLMHint(schema: DatasourceConfigSchema): string;
1600
+ /**
1601
+ * Generate comprehensive structured field data for troubleshooting context.
1602
+ * Returns an array of field descriptors the LLM can use to render rich tables.
1603
+ */
1604
+ declare function generateTroubleshootingFields(schema: DatasourceConfigSchema): TroubleShootingContext[];
1605
+
1606
+ type ProvisioningYamlOptions = {
1607
+ /** Include comments with field descriptions. Default: true for template, false for export. */
1608
+ comments?: boolean;
1609
+ /** Override the emitted datasource name. */
1610
+ name?: string;
1611
+ };
1612
+ /**
1613
+ * Generate a Grafana provisioning YAML template from a dsconfig schema.
1614
+ * Emits every schema field with sensible defaults and (by default) explanatory comments.
1453
1615
  */
1454
- type Expression = string;
1455
- type ValueType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'map' | 'any';
1456
- type FieldKind = 'storage' | 'virtual';
1457
- type TargetLocation = 'root' | 'jsonData' | 'secureJsonData';
1458
- type UIComponent = 'input' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'checkbox' | 'switch' | 'code' | 'keyvalue' | 'list' | 'fileUpload';
1459
- type UIWidth = 'full' | 'half';
1616
+ declare function generateProvisioningTemplate(schema: DatasourceConfigSchema, options?: ProvisioningYamlOptions): string;
1460
1617
  /**
1461
- * UI configuration
1618
+ * Generate provisioning YAML from an existing Grafana datasource API response.
1619
+ * If a dsconfig schema is available, uses it for field ordering and comments.
1620
+ * If not, generates basic YAML from the raw API response.
1462
1621
  */
1463
- interface FieldUI {
1464
- component: UIComponent;
1465
- multiline?: boolean;
1466
- rows?: number;
1467
- options?: FieldOption[];
1468
- allowCustom?: boolean;
1469
- width?: UIWidth;
1622
+ declare function datasourceToProvisioningYaml(ds: Record<string, unknown>, schema: DatasourceConfigSchema | null): string;
1623
+ declare const formatYamlDiff: (existing: Record<string, unknown>, body: Record<string, unknown>) => string;
1624
+
1625
+ declare const ROOT_CONFIG_FIELDS: readonly ["name", "type", "id", "uid", "access", "url", "basicAuth", "basicAuthUser", "user", "isDefault", "database", "withCredentials"];
1626
+ type DatasourceConfig = Record<any, any>;
1627
+ declare const buildCreateDatasourcePayload: (input: DatasourceConfig) => DatasourceConfig;
1628
+ declare const buildCloneDatasourcePayload: (source: DatasourceConfig, name: string) => DatasourceConfig;
1629
+ declare const buildUpdateDatasourcePayload: (existing: DatasourceConfig, input: DatasourceConfig) => {
1630
+ body: DatasourceConfig;
1631
+ hasChanges: boolean;
1632
+ };
1633
+
1634
+ declare function getConfigSchema(pluginType: string): Promise<DatasourceConfigSchema | null>;
1635
+
1636
+ /**
1637
+ * Pure helper functions for working with DatasourceConfigSchema.
1638
+ *
1639
+ * Types are defined in schema.ts — import them from there directly.
1640
+ */
1641
+
1642
+ /** A group paired with its resolved ConfigField objects (in fieldRefs order). */
1643
+ type ResolvedGroup = {
1644
+ group: ConfigGroup;
1645
+ fields: ConfigField[];
1646
+ };
1647
+ /**
1648
+ * Group ids that denote the authentication section. Registry schemas use the
1649
+ * full form `authentication`; `auth` is accepted for backwards compatibility
1650
+ * with older/short-form schemas.
1651
+ */
1652
+ declare const AUTH_GROUP_IDS: readonly string[];
1653
+ /** Whether a group id denotes the authentication group. */
1654
+ declare function isAuthGroupId(id: string): boolean;
1655
+ /**
1656
+ * Resolve a schema's groups into arrays of ConfigField objects.
1657
+ * If the schema has no groups, returns a single group containing all non-virtual fields.
1658
+ */
1659
+ declare function resolveGroups(schema: DatasourceConfigSchema): ResolvedGroup[];
1660
+ /**
1661
+ * Build a virtual "Required" group containing all required fields, any parent
1662
+ * fields they depend on (via `dependsOn`), and any child fields that depend on
1663
+ * required fields. When the schema contains an authentication group (id
1664
+ * `authentication` or `auth`), its fields are also pulled in (auth is
1665
+ * effectively required for Prometheus/Loki/Tempo style datasources). Fields
1666
+ * are returned in schema order and de-duplicated.
1667
+ * Returns `null` when the virtual group would be empty.
1668
+ */
1669
+ declare function resolveRequiredFieldsGroup(schema: DatasourceConfigSchema): ResolvedGroup | null;
1670
+ /**
1671
+ * Unique form key for a field. Section-scoped fields (e.g. section:"logs", key:"defaultTable")
1672
+ * get a prefixed key ("logs.defaultTable") so they don't collide with top-level fields that
1673
+ * share the same key name.
1674
+ */
1675
+ declare function formKey(field: ConfigField): string;
1676
+ /**
1677
+ * Resolve a possibly-dotted key against watchedValues from react-hook-form.
1678
+ * RHF's `watch()` returns nested objects for dotted Controller names
1679
+ * (e.g. "logs.otelEnabled" → { logs: { otelEnabled: true } }),
1680
+ * so a flat `obj["logs.otelEnabled"]` lookup misses.
1681
+ *
1682
+ * For dotted keys we must try the nested path **first**: react-hook-form's
1683
+ * Controller `onChange` writes nested objects via its internal `set()`, but
1684
+ * `reset()` may have created a flat dotted key with the same name. After user
1685
+ * interaction the nested value is authoritative; the stale flat key must not
1686
+ * shadow it. This mirrors RHF's own `get()` semantics (nested-first, flat
1687
+ * fallback).
1688
+ */
1689
+ declare function getWatchedValue(watchedValues: Record<string, unknown>, key: string): unknown;
1690
+ /**
1691
+ * Parse a simple CEL-like dependsOn expression: "fieldId == 'value'" or "fieldId != 'value'".
1692
+ * Only single comparisons are supported — no &&, ||, or parentheses.
1693
+ * Field IDs may contain dots and underscores (e.g. "jsonData.oauth2.oauth2_type").
1694
+ * Values may be single-quoted, double-quoted, or unquoted literals (true/false/numbers).
1695
+ * Returns { field, value, negate } or null if unparseable.
1696
+ */
1697
+ declare function parseDependsOn(expr: string): {
1698
+ field: string;
1699
+ value: string;
1700
+ negate: boolean;
1701
+ } | null;
1702
+ /**
1703
+ * Evaluate a parsed dependsOn condition against a value.
1704
+ * Handles both == and != operators.
1705
+ */
1706
+ declare function evaluateDependsOn(parsed: {
1707
+ value: string;
1708
+ negate: boolean;
1709
+ }, currentValue: unknown): boolean;
1710
+ /**
1711
+ * Resolve the first matching override for a field given current form values.
1712
+ * Override `when` uses the same "fieldId == 'value'" syntax as dependsOn.
1713
+ * Returns the matching override or undefined if none match.
1714
+ */
1715
+ declare function resolveActiveOverride(field: ConfigField, watchedValues: Record<string, unknown>, fieldById: Map<string, ConfigField>): FieldOverride | undefined;
1716
+ /**
1717
+ * Evaluate a simple computed.read expression against form values.
1718
+ * Supports patterns used in dsconfig schemas:
1719
+ * - "fieldRef == true ? 'a' : (fieldRef == true ? 'b' : 'c')"
1720
+ * - Simple ternary chains with equality checks
1721
+ * Falls back to the field's defaultValue if the expression can't be evaluated.
1722
+ */
1723
+ declare function evaluateComputedRead(expr: string, values: Record<string, unknown>, fields: ConfigField[]): unknown;
1724
+ /**
1725
+ * Compute initial values for all virtual fields that have storage.computed.read expressions.
1726
+ * Call after loading existing storage field values.
1727
+ */
1728
+ declare function computeVirtualFieldValues(schema: DatasourceConfigSchema, existingValues: Record<string, unknown>): Record<string, unknown>;
1729
+
1730
+ interface CustomHeader {
1731
+ id: string;
1732
+ name: string;
1733
+ value: string;
1734
+ configured: boolean;
1735
+ }
1736
+ type CustomHeaders = CustomHeader[];
1737
+ interface Props$9 {
1738
+ dataSourceConfig: DataSourceSettings<any, any>;
1739
+ onChange: (config: DataSourceSettings) => void;
1740
+ }
1741
+ interface State {
1742
+ headers: CustomHeaders;
1743
+ }
1744
+ declare class CustomHeadersSettings extends PureComponent<Props$9, State> {
1745
+ state: State;
1746
+ constructor(props: Props$9);
1747
+ updateSettings: () => void;
1748
+ onHeaderAdd: () => void;
1749
+ onHeaderChange: (headerIndex: number, value: CustomHeader) => void;
1750
+ onHeaderReset: (headerId: string) => void;
1751
+ onHeaderRemove: (headerId: string) => void;
1752
+ render(): React.JSX.Element;
1753
+ }
1754
+
1755
+ interface QueryBuilderLabelFilter {
1756
+ label: string;
1757
+ op: string;
1758
+ value: string;
1759
+ }
1760
+ interface QueryBuilderOperation {
1761
+ id: string;
1762
+ params: QueryBuilderOperationParamValue[];
1763
+ disabled?: boolean;
1764
+ }
1765
+ interface QueryBuilderOperationDefinition<T = any> extends RegistryItem {
1766
+ documentation?: string;
1767
+ params: QueryBuilderOperationParamDef[];
1768
+ defaultParams: QueryBuilderOperationParamValue[];
1769
+ category: string;
1770
+ hideFromList?: boolean;
1771
+ alternativesKey?: string;
1772
+ /** Can be used to control operation placement when adding a new operations, lower are placed first */
1773
+ orderRank?: number;
1774
+ renderer: QueryBuilderOperationRenderer;
1775
+ addOperationHandler: QueryBuilderAddOperationHandler<T>;
1776
+ paramChangedHandler?: QueryBuilderOnParamChangedHandler;
1777
+ explainHandler?: QueryBuilderExplainOperationHandler;
1778
+ changeTypeHandler?: (op: QueryBuilderOperation, newDef: QueryBuilderOperationDefinition<T>) => QueryBuilderOperation;
1779
+ toggleable?: boolean;
1780
+ }
1781
+ type QueryBuilderAddOperationHandler<T> = (def: QueryBuilderOperationDefinition, query: T, modeller: VisualQueryModeller) => T;
1782
+ type QueryBuilderExplainOperationHandler = (op: QueryBuilderOperation, def?: QueryBuilderOperationDefinition) => string;
1783
+ type QueryBuilderOnParamChangedHandler = (index: number, operation: QueryBuilderOperation, operationDef: QueryBuilderOperationDefinition) => QueryBuilderOperation;
1784
+ type QueryBuilderOperationRenderer = (model: QueryBuilderOperation, def: QueryBuilderOperationDefinition, innerQuery: string) => string;
1785
+ type QueryBuilderOperationParamValue = string | number | boolean;
1786
+ interface QueryBuilderOperationParamDef {
1787
+ name: string;
1788
+ type: 'string' | 'number' | 'boolean';
1789
+ options?: string[] | number[] | Array<SelectableValue<string>>;
1790
+ hideName?: boolean;
1791
+ restParam?: boolean;
1792
+ optional?: boolean;
1470
1793
  placeholder?: string;
1471
- /**
1472
- * Language hint for code editor components.
1473
- * Example: "promql", "logql", "traceql", "sql", "json"
1474
- */
1475
- language?: string;
1476
- /**
1477
- * Layout row index for item fields inside object arrays.
1478
- * Fields with the same row number are rendered horizontally.
1479
- * Fields without a row number use auto-layout:
1480
- * - ≤3 fields: all on one row
1481
- * - >3 fields: each on its own row
1482
- */
1483
- row?: number;
1484
- /**
1485
- * Accepted file types for fileUpload component.
1486
- * Uses HTML accept attribute format with leading dot.
1487
- * Example: [".json"]
1488
- */
1489
- accept?: string[];
1490
- /**
1491
- * Maps keys in an uploaded JSON file to target field IDs.
1492
- * Used by fileUpload to distribute parsed values to other form fields.
1493
- * Example: { "private_key": "secureJsonData.privateKey", "client_email": "jsonData.clientEmail" }
1494
- */
1495
- fileMapping?: Record<string, string>;
1794
+ description?: string;
1795
+ minWidth?: number;
1796
+ editor?: FunctionComponent<QueryBuilderOperationParamEditorProps>;
1797
+ runQueryOnEnter?: boolean;
1496
1798
  }
1497
- type FieldValidationRule = PatternValidationRule | RangeValidationRule | LengthValidationRule | ItemCountValidationRule | AllowedValuesValidationRule | CustomValidationRule;
1498
- interface BaseValidationRule {
1499
- /**
1500
- * Optional stable ID for the validation rule.
1501
- * Useful for docs, localization, and test snapshots.
1502
- */
1503
- id?: string;
1504
- /**
1505
- * Human-readable validation error message.
1506
- */
1799
+ interface QueryBuilderOperationParamEditorProps {
1800
+ value?: QueryBuilderOperationParamValue;
1801
+ paramDef: QueryBuilderOperationParamDef;
1802
+ /** Parameter index */
1803
+ index: number;
1804
+ operation: QueryBuilderOperation;
1805
+ operationId: string;
1806
+ query: any;
1807
+ datasource: DataSourceApi;
1808
+ timeRange?: TimeRange;
1809
+ onChange: (index: number, value: QueryBuilderOperationParamValue) => void;
1810
+ onRunQuery: () => void;
1811
+ queryModeller: VisualQueryModeller;
1812
+ }
1813
+ declare enum QueryEditorMode {
1814
+ Code = "code",
1815
+ Builder = "builder"
1816
+ }
1817
+ type QueryStats = {
1818
+ bytes: number;
1507
1819
  message?: string;
1820
+ };
1821
+ interface VisualQueryModeller {
1822
+ getOperationsForCategory(category: string): QueryBuilderOperationDefinition[];
1823
+ getAlternativeOperations(key: string): QueryBuilderOperationDefinition[];
1824
+ getCategories(): string[];
1825
+ getOperationDefinition(id: string): QueryBuilderOperationDefinition | undefined;
1826
+ renderQuery(query: VisualQuery, nested?: boolean): string;
1827
+ renderLabels(labels: QueryBuilderLabelFilter[]): string;
1828
+ innerQueryPlaceholder: string;
1508
1829
  }
1509
- interface PatternValidationRule extends BaseValidationRule {
1510
- type: 'pattern';
1511
- pattern: string;
1830
+ interface VisualQueryBinary<T> {
1831
+ operator: string;
1832
+ vectorMatchesType?: 'on' | 'ignoring';
1833
+ vectorMatches?: string;
1834
+ query: T;
1512
1835
  }
1513
- interface RangeValidationRule extends BaseValidationRule {
1514
- type: 'range';
1515
- min?: number;
1516
- max?: number;
1836
+ declare const BINARY_OPERATIONS_KEY = "Binary operations";
1837
+ interface VisualQuery {
1838
+ metric?: string;
1839
+ labels: QueryBuilderLabelFilter[];
1840
+ operations: QueryBuilderOperation[];
1841
+ binaryQueries?: Array<VisualQueryBinary<VisualQuery>>;
1842
+ }
1843
+
1844
+ declare abstract class QueryModellerBase implements VisualQueryModeller {
1845
+ protected operationsRegistry: Registry<QueryBuilderOperationDefinition>;
1846
+ private categories;
1847
+ innerQueryPlaceholder: string;
1848
+ constructor(operationDefinitions: QueryBuilderOperationDefinition[], innerQueryPlaceholder?: string);
1849
+ protected setOperationCategories(categories: string[]): void;
1850
+ abstract renderOperations(queryString: string, operations: QueryBuilderOperation[]): string;
1851
+ abstract renderBinaryQueries(queryString: string, binaryQueries?: Array<VisualQueryBinary<VisualQuery>>): string;
1852
+ abstract renderLabels(labels: QueryBuilderLabelFilter[]): string;
1853
+ abstract renderQuery(query: VisualQuery, nested?: boolean): string;
1854
+ getOperationsForCategory(category: string): QueryBuilderOperationDefinition<any>[];
1855
+ getAlternativeOperations(key: string): QueryBuilderOperationDefinition<any>[];
1856
+ getCategories(): string[];
1857
+ getOperationDefinition(id: string): QueryBuilderOperationDefinition | undefined;
1858
+ hasBinaryOp(query: VisualQuery): boolean;
1859
+ }
1860
+
1861
+ interface Props$8 {
1862
+ labelsFilters: QueryBuilderLabelFilter[];
1863
+ onChange: (labelFilters: QueryBuilderLabelFilter[]) => void;
1864
+ onGetLabelNames: (forLabel: Partial<QueryBuilderLabelFilter>) => Promise<SelectableValue[]>;
1865
+ onGetLabelValues: (forLabel: Partial<QueryBuilderLabelFilter>) => Promise<SelectableValue[]>;
1866
+ /** If set to true, component will show error message until at least 1 filter is selected */
1867
+ labelFilterRequired?: boolean;
1868
+ multiValueSeparator?: string;
1869
+ }
1870
+ declare function LabelFilters({ labelsFilters, onChange, onGetLabelNames, onGetLabelValues, labelFilterRequired, multiValueSeparator, }: Props$8): React.JSX.Element;
1871
+
1872
+ interface Props$7 {
1873
+ title?: React.ReactNode;
1874
+ markdown?: string;
1875
+ stepNumber?: number;
1876
+ }
1877
+ declare function OperationExplainedBox({ title, stepNumber, markdown, children }: React.PropsWithChildren<Props$7>): React.JSX.Element;
1878
+
1879
+ interface Props$6<T extends VisualQuery> {
1880
+ query: T;
1881
+ datasource: DataSourceApi;
1882
+ onChange: (query: T) => void;
1883
+ onRunQuery: () => void;
1884
+ queryModeller: VisualQueryModeller;
1885
+ explainMode?: boolean;
1886
+ highlightedOp?: QueryBuilderOperation;
1887
+ timeRange?: TimeRange;
1888
+ isConflictingOperation?: (operation: QueryBuilderOperation, otherOperations: QueryBuilderOperation[]) => boolean;
1517
1889
  }
1518
- interface LengthValidationRule extends BaseValidationRule {
1519
- type: 'length';
1520
- min?: number;
1521
- max?: number;
1890
+ declare function OperationList<T extends VisualQuery>({ query, datasource, queryModeller, onChange, onRunQuery, highlightedOp, timeRange, isConflictingOperation, }: Props$6<T>): React.JSX.Element;
1891
+
1892
+ interface Props$5<T extends VisualQuery> {
1893
+ query: T;
1894
+ queryModeller: VisualQueryModeller;
1895
+ explainMode?: boolean;
1896
+ stepNumber: number;
1897
+ language: {
1898
+ grammar: Grammar;
1899
+ name: string;
1900
+ };
1901
+ onMouseEnter?: (op: QueryBuilderOperation, index: number) => void;
1902
+ onMouseLeave?: (op: QueryBuilderOperation, index: number) => void;
1522
1903
  }
1523
- interface ItemCountValidationRule extends BaseValidationRule {
1524
- type: 'itemCount';
1525
- min?: number;
1526
- max?: number;
1904
+ declare function OperationListExplained<T extends VisualQuery>({ query, queryModeller, stepNumber, language, onMouseEnter, onMouseLeave, }: Props$5<T>): React.JSX.Element;
1905
+
1906
+ declare function OperationsEditorRow({ children }: React.PropsWithChildren<{}>): React.JSX.Element;
1907
+
1908
+ interface Props$4<TVisualQuery extends VisualQuery, TDataQuery extends DataQuery$1> {
1909
+ query: TVisualQuery;
1910
+ datasource: DataSourceApi<TDataQuery>;
1911
+ queryModeller: VisualQueryModeller;
1912
+ buildVisualQueryFromString: (queryString: string) => {
1913
+ query: TVisualQuery;
1914
+ };
1915
+ buildDataQueryFromQueryString: (queryString: string) => TDataQuery;
1916
+ buildQueryStringFromDataQuery: (dataQuery: TDataQuery) => string;
1917
+ onChange: (update: TVisualQuery) => void;
1918
+ data?: PanelData;
1527
1919
  }
1528
- interface AllowedValuesValidationRule extends BaseValidationRule {
1529
- type: 'allowedValues';
1530
- values: unknown[];
1920
+ declare const QueryBuilderHints: {
1921
+ <TVisualQuery extends VisualQuery, TDataQuery extends DataQuery$1>({ datasource, query: visualQuery, onChange, data, queryModeller, buildVisualQueryFromString, buildDataQueryFromQueryString, buildQueryStringFromDataQuery, }: Props$4<TVisualQuery, TDataQuery>): React.JSX.Element;
1922
+ displayName: string;
1923
+ };
1924
+
1925
+ interface Props$3 {
1926
+ mode: QueryEditorMode;
1927
+ onChange: (mode: QueryEditorMode) => void;
1531
1928
  }
1532
- interface CustomValidationRule extends BaseValidationRule {
1533
- type: 'custom';
1534
- /**
1535
- * CEL expression.
1536
- *
1537
- * Should evaluate to true when the field value is valid.
1538
- */
1539
- expression: Expression;
1929
+ declare function QueryEditorModeToggle({ mode, onChange }: Props$3): React.JSX.Element;
1930
+
1931
+ interface Props$2 extends Omit<HTMLProps<HTMLInputElement>, 'value' | 'ref'> {
1932
+ value?: boolean;
1933
+ label: string;
1540
1934
  }
1541
- interface FieldOverride {
1542
- /**
1543
- * CEL condition
1544
- */
1545
- when: Expression;
1546
- defaultValue?: unknown;
1547
- /**
1548
- * When true, the field is disabled/read-only while this override is active.
1549
- */
1550
- readOnly?: boolean;
1551
- description?: string;
1552
- placeholder?: string;
1553
- tooltip?: string;
1554
- validations?: FieldValidationRule[];
1555
- options?: FieldOption[];
1556
- /**
1557
- * When present on an `isItemField` field, the value is routed to
1558
- * `secureJsonData` under the resolved key instead of being stored
1559
- * inline in the parent array.
1560
- *
1561
- * The template string supports placeholders:
1562
- * - `{index}` — 0-based array position
1563
- * - `{index1}` — 1-based array position
1564
- * - `{item.KEY}` — value of sibling item field `KEY`
1565
- *
1566
- * Examples:
1567
- * - `"secureHttpHeaders.{item.name}"` (ClickHouse)
1568
- * - `"httpHeaderValue{index1}"` (Grafana core headers)
1569
- */
1570
- secureKey?: string;
1935
+ declare function QueryHeaderSwitch({ label, ...inputProps }: Props$2): React.JSX.Element;
1936
+
1937
+ interface Props$1 {
1938
+ title: string;
1939
+ collapsedInfo: string[];
1940
+ queryStats?: QueryStats | null;
1571
1941
  }
1572
- /**
1573
- * Declares that when a field's value matches a condition,
1574
- * listed target fields should be set to specified values.
1575
- *
1576
- * Use "value" in the `when` expression to refer to the field's value.
1577
- */
1578
- interface FieldEffect {
1579
- /**
1580
- * CEL expression. Example: "value == 'basic-auth'"
1581
- */
1582
- when: Expression;
1583
- /**
1584
- * Maps field IDs to the values they should be set to.
1585
- * Must contain at least one entry.
1586
- */
1587
- set: Record<string, unknown> & {
1588
- [k: string]: unknown;
1942
+ declare function QueryOptionGroup({ title, children, collapsedInfo, queryStats }: React.PropsWithChildren<Props$1>): React.JSX.Element;
1943
+
1944
+ interface Props {
1945
+ query: string;
1946
+ language: {
1947
+ grammar: Grammar;
1948
+ name: string;
1589
1949
  };
1950
+ className?: string;
1590
1951
  }
1591
- type StorageMapping = DirectMapping | IndexedPairMapping | ComputedMapping;
1592
- /**
1593
- * Direct mapping
1594
- */
1595
- interface DirectMapping {
1596
- type: 'direct';
1952
+ declare function RawQuery({ query, language, className }: Props): React.JSX.Element;
1953
+
1954
+ interface CustomMeta {
1955
+ queryID: string;
1956
+ status: string;
1597
1957
  }
1598
- /**
1599
- * Indexed pair mapping (headers)
1600
- */
1601
- interface IndexedPairMapping {
1602
- type: 'indexedPair';
1603
- key: MappingField;
1604
- value: MappingField;
1605
- startIndex?: number;
1958
+ interface RunningQueryInfo {
1959
+ queryID?: string;
1960
+ shouldCancel?: boolean;
1606
1961
  }
1607
- /**
1608
- * Computed mapping (virtual fields).
1609
- * At least one of `read` or `write` must be provided.
1610
- */
1611
- type ComputedMapping = {
1612
- type: 'computed';
1613
- read: Expression;
1614
- write?: Expression;
1615
- } | {
1616
- type: 'computed';
1617
- read?: Expression;
1618
- write: Expression;
1619
- };
1620
- /**
1621
- * Mapping field
1622
- */
1623
- interface MappingField {
1624
- target: TargetLocation;
1625
- pattern: string;
1962
+ declare class DatasourceWithAsyncBackend<TQuery extends DataQuery$1 = DataQuery$1, TOptions extends DataSourceJsonData = DataSourceJsonData> extends DataSourceWithBackend<TQuery, TOptions> {
1963
+ private runningQueries;
1964
+ private requestCounter;
1965
+ private requestIdPrefix;
1966
+ constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);
1967
+ query(request: DataQueryRequest<TQuery>): Observable<DataQueryResponse>;
1968
+ storeQuery(target: TQuery, queryInfo: RunningQueryInfo): void;
1969
+ getQuery(target: TQuery): RunningQueryInfo;
1970
+ removeQuery(target: TQuery): void;
1971
+ doSingle(target: TQuery, request: DataQueryRequest<TQuery>): Observable<DataQueryResponse>;
1972
+ cancel: (target: TQuery) => void;
1626
1973
  }
1627
- interface FieldOption {
1628
- label: string;
1629
- /**
1630
- * Must match parent field valueType.
1631
- * Must not be null.
1632
- */
1633
- value: NonNullable<unknown>;
1974
+
1975
+ interface RunQueryButtonsProps<TQuery extends DataQuery$1> {
1976
+ enableRun?: boolean;
1977
+ onRunQuery: () => void;
1978
+ onCancelQuery: (query: TQuery) => void;
1979
+ query: TQuery;
1980
+ state?: LoadingState;
1981
+ }
1982
+ declare const RunQueryButtons: <TQuery extends DataQuery$1>(props: RunQueryButtonsProps<TQuery>) => React.JSX.Element;
1983
+
1984
+ interface RequestLoopOptions<TQuery extends DataQuery$1 = DataQuery$1> {
1634
1985
  /**
1635
- * Optional human-readable description of the option.
1986
+ * If the response needs an additional request to execute, return it here
1636
1987
  */
1637
- description?: string;
1638
- }
1639
- interface ConfigGroup {
1640
- id: string;
1641
- title: string;
1642
- description?: string;
1643
- order?: number;
1988
+ getNextQuery: (rsp: DataQueryResponse) => TQuery | undefined;
1644
1989
  /**
1645
- * When true, the group is optional and can be collapsed/hidden by default.
1990
+ * The datasource execute method
1646
1991
  */
1647
- optional?: boolean;
1992
+ query: (req: DataQueryRequest<TQuery>) => Observable<DataQueryResponse>;
1648
1993
  /**
1649
- * References field IDs (not keys)
1994
+ * Process the results
1650
1995
  */
1651
- fieldRefs: string[];
1652
- }
1653
- type RelationshipType = 'pair' | 'group' | 'datasourceReference';
1654
- interface FieldRelationship {
1655
- type: RelationshipType;
1996
+ process: (data: DataFrame[]) => DataFrame[];
1656
1997
  /**
1657
- * References field IDs
1998
+ * Check if the query should be cancelled
1658
1999
  */
1659
- fields: string[];
1660
- description?: string;
2000
+ shouldCancel: () => boolean;
1661
2001
  /**
1662
- * Constrains the datasource UID to a specific plugin type.
1663
- * Only applicable when type is "datasourceReference".
2002
+ * Callback that gets executed when unsubscribed
1664
2003
  */
1665
- targetPluginType?: string;
1666
- }
1667
- type SecureFieldState = {
1668
- type: 'unset';
1669
- } | {
1670
- type: 'configured';
1671
- } | {
1672
- type: 'updated';
1673
- value: string;
1674
- };
1675
- interface FormState {
1676
- values: Record<string, unknown>;
1677
- secure: Record<string, SecureFieldState>;
2004
+ onCancel: () => void;
1678
2005
  }
1679
-
1680
- declare function getConfigSchema(pluginType: string): Promise<DatasourceConfigSchema | null>;
1681
-
1682
- type ProvisioningYamlOptions = {
1683
- /** Include comments with field descriptions. Default: true for template, false for export. */
1684
- comments?: boolean;
1685
- /** Override the emitted datasource name. */
1686
- name?: string;
1687
- };
1688
- /**
1689
- * Generate a Grafana provisioning YAML template from a dsconfig schema.
1690
- * Emits every schema field with sensible defaults and (by default) explanatory comments.
1691
- */
1692
- declare function generateProvisioningTemplate(schema: DatasourceConfigSchema, options?: ProvisioningYamlOptions): string;
1693
2006
  /**
1694
- * Generate provisioning YAML from an existing Grafana datasource API response.
1695
- * If a dsconfig schema is available, uses it for field ordering and comments.
1696
- * If not, generates basic YAML from the raw API response.
2007
+ * Continue executing requests as long as `getNextQuery` returns a query
1697
2008
  */
1698
- declare function datasourceToProvisioningYaml(ds: Record<string, unknown>, schema: DatasourceConfigSchema | null): string;
1699
- declare const formatYamlDiff: (existing: Record<string, unknown>, body: Record<string, unknown>) => string;
2009
+ declare function getRequestLooper<T extends DataQuery$1 = DataQuery$1>(req: DataQueryRequest<T>, options: RequestLoopOptions<T>): Observable<DataQueryResponse>;
1700
2010
 
1701
- export { AccessoryButton, AdvancedHttpSettings, Auth, AuthMethod, BINARY_OPERATIONS_KEY, CatalogSelector, CompletionItemInsertTextRule, CompletionItemKind, CompletionItemPriority, ConfigDescriptionLink, ConfigSection, ConfigSubSection, ConnectionSettings, CustomHeadersSettings, DataLink, DataLinks, DataSourceDescription, DataSourcePicker, DatasetSelector, DatasourceWithAsyncBackend, DatePicker, DatePickerWithInput, DebounceInput, EditorField, EditorFieldGroup, EditorHeader, EditorList, EditorMode, EditorRow, EditorRows, EditorStack, EditorSwitch, FlexItem, GroupByRow, InlineSelect, InputGroup, LabelFilters, LinkedToken, MacroType, OperationExplainedBox, OperationList, OperationListExplained, OperationsEditorRow, OperatorType, QUERY_FORMAT_OPTIONS, QueryBuilderHints, QueryEditorMode, QueryEditorModeToggle, QueryEditorRow, QueryFormat, QueryHeaderSwitch, QueryModellerBase, QueryOptionGroup, RawQuery, RunQueryButton, RunQueryButtons, SQLEditor, SQLEditorMode, SQLEditorTestUtils, SecureSocksProxyToggle, Segment, Space, SqlDatasource, SqlQueryEditor, StatementPosition, SuggestionKind, TLSSettings, TableSelector, TokenType, convertLegacyAuthProps, datasourceToProvisioningYaml, formatDate, formatYamlDiff, generateProvisioningTemplate, getConfigSchema, getRequestLooper, getStandardSQLCompletionProvider, language as grafanaStandardSQLLanguage, conf as grafanaStandardSQLLanguageConf, toOption };
1702
- export type { Aggregate, AllowedValuesValidationRule, Props$c as AuthProps, BaseValidationRule, ColumnDefinition, ComputedMapping, ConfigField, ConfigGroup, CustomMeta, CustomValidationRule, DB, DataLinkConfig, DatasourceConfigSchema, DatePickerProps, DatePickerWithInputProps, DebounceInputProps, DirectMapping, Expression, FieldEffect, FieldItemSchema, FieldKind, FieldOption, FieldOverride, FieldRelationship, FieldUI, FieldValidationRule, FormState, IndexedPairMapping, ItemCountValidationRule, LanguageCompletionProvider, LanguageDefinition, LengthValidationRule, MappingField, MetaDefinition, NameValue, PatternValidationRule, PositionContext, Props$s as Props, QueryBuilderLabelFilter, QueryBuilderOperation, QueryBuilderOperationDefinition, QueryBuilderOperationParamDef, QueryBuilderOperationParamEditorProps, QueryBuilderOperationParamValue, QueryEditorProps, QueryRowFilter, QueryStats, QueryWithDefaults, RAQBFieldTypes, RangeValidationRule, RelationshipType, RequestLoopOptions, ResourceSelectorProps, ResponseParser, RunQueryButtonsProps, RunningQueryInfo, SQLConnectionLimits, SQLExpression, SQLFilters, SQLMonarchLanguage, SQLOptions, SQLQuery, SQLSelectableValue, SchemaDefinition, SecureFieldState, SegmentProps, SqlQueryForInterpolation, SqlQueryModel, State$1 as State, StatementPlacementProvider, StorageMapping, SuggestionKindProvider, Props$f as TLSSettingsProps, TableDefinition, TableFieldSchema, TableIdentifier, TableSchema, TargetLocation, TestQueryModel, UIComponent, UIWidth, ValidationResults, ValueType, VisualQuery, VisualQueryBinary, VisualQueryModeller };
2011
+ export { AUTH_GROUP_IDS, AccessoryButton, AdvancedHttpSettings, Auth, AuthMethod, BINARY_OPERATIONS_KEY, CatalogSelector, CompletionItemInsertTextRule, CompletionItemKind, CompletionItemPriority, ConfigDescriptionLink, ConfigSection, ConfigSubSection, ConnectionSettings, CustomHeadersSettings, DataLink, DataLinks, DataSourceDescription, DataSourcePicker, DatasetSelector, DatasourceConfigWizard, DatasourceErrorBoundary, DatasourceWithAsyncBackend, DatePicker, DatePickerWithInput, DebounceInput, EditorField, EditorFieldGroup, EditorHeader, EditorList, EditorMode, EditorRow, EditorRows, EditorStack, EditorSwitch, FlexItem, GroupByRow, InlineSelect, InputGroup, LabelFilters, LinkedToken, MacroType, OperationExplainedBox, OperationList, OperationListExplained, OperationsEditorRow, OperatorType, QUERY_FORMAT_OPTIONS, QueryBuilderHints, QueryEditorMode, QueryEditorModeToggle, QueryEditorRow, QueryFormat, QueryHeaderSwitch, QueryModellerBase, QueryOptionGroup, ROOT_CONFIG_FIELDS, RawQuery, RunQueryButton, RunQueryButtons, SQLEditor, SQLEditorMode, SQLEditorTestUtils, SecureSocksProxyToggle, Segment, Space, SqlDatasource, SqlQueryEditor, StatementPosition, SuggestionKind, TLSSettings, TableSelector, TokenType, buildCelContext, buildCloneDatasourcePayload, buildCreateDatasourcePayload, buildUpdateDatasourcePayload, clearExpressionCache, computeVirtualFieldValues, convertLegacyAuthProps, datasourceToProvisioningYaml, evaluateCelDirect, evaluateCelExpression, evaluateComputedRead, evaluateDependsOn, extractFieldRefs, formKey, formatDate, formatYamlDiff, generateLLMHint, generateProvisioningTemplate, generateTroubleshootingFields, getConfigSchema, getRequestLooper, getStandardSQLCompletionProvider, getWatchedValue, language as grafanaStandardSQLLanguage, conf as grafanaStandardSQLLanguageConf, isAuthGroupId, isValidCelExpression, parseDependsOn, resolveActiveOverride, resolveGroups, resolvePluginName, resolveRequiredFieldsGroup, toOption, useHealthChecks };
2012
+ export type { Aggregate, AllowedValuesValidationRule, Props$c as AuthProps, BaseFieldRef, BaseValidationRule, ColumnDefinition, ComputedMapping, ConfigField, ConfigGroup, CustomMeta, CustomValidationRule, DB, DataLinkConfig, DatasourceConfigSchema, DatasourceConfigWizardProps, DatasourceHealth, DatePickerProps, DatePickerWithInputProps, DebounceInputProps, DirectMapping, Expression, FieldEffect, FieldItemSchema, FieldKind, FieldOption, FieldOverride, FieldPack, FieldPackID, FieldPatch, FieldRelationship, FieldUI, FieldValidationRule, FormState, HealthState, IndexedPairMapping, Instruction, ItemCountValidationRule, LanguageCompletionProvider, LanguageDefinition, LengthValidationRule, MappingField, MetaDefinition, NameValue, PatternValidationRule, PositionContext, Props$s as Props, QueryBuilderLabelFilter, QueryBuilderOperation, QueryBuilderOperationDefinition, QueryBuilderOperationParamDef, QueryBuilderOperationParamEditorProps, QueryBuilderOperationParamValue, QueryEditorProps, QueryRowFilter, QueryStats, QueryWithDefaults, RAQBFieldTypes, RangeValidationRule, RelationshipType, RequestLoopOptions, ResolvedGroup, ResourceSelectorProps, ResponseParser, Role, RunQueryButtonsProps, RunningQueryInfo, SQLConnectionLimits, SQLExpression, SQLFilters, SQLMonarchLanguage, SQLOptions, SQLQuery, SQLSelectableValue, SchemaDefinition, SecureFieldState, SegmentProps, SqlQueryForInterpolation, SqlQueryModel, State$1 as State, StatementPlacementProvider, StorageMapping, SuggestionKindProvider, Props$f as TLSSettingsProps, TableDefinition, TableFieldSchema, TableIdentifier, TableSchema, TargetLocation, TestQueryModel, UIComponent, UIWidth, ValidationResults, ValueType, VisualQuery, VisualQueryBinary, VisualQueryModeller };