@grafana/plugin-ui 0.14.0-dev.1 → 0.14.1-dsconfig.0d5c985

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 (111) hide show
  1. package/dist/cjs/index.cjs +2932 -377
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +564 -38
  4. package/dist/esm/components/ConfigEditor/ConfigSection/ConfigDescriptionLink.js +2 -2
  5. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/AuthorizationHeaderField.js +53 -0
  6. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/AuthorizationHeaderField.js.map +1 -0
  7. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/ComplexFieldNote.js +24 -0
  8. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/ComplexFieldNote.js.map +1 -0
  9. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceConfigWizard.js +229 -0
  10. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceConfigWizard.js.map +1 -0
  11. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/IndexedPairEditor.js +124 -0
  12. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/IndexedPairEditor.js.map +1 -0
  13. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/PdcFieldNote.js +34 -0
  14. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/PdcFieldNote.js.map +1 -0
  15. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SchemaField.js +60 -0
  16. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SchemaField.js.map +1 -0
  17. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SecureFieldInput.js +61 -0
  18. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SecureFieldInput.js.map +1 -0
  19. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SidebarNav.js +54 -0
  20. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SidebarNav.js.map +1 -0
  21. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/StringArrayInput.js +84 -0
  22. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/StringArrayInput.js.map +1 -0
  23. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/TabLayout.js +176 -0
  24. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/TabLayout.js.map +1 -0
  25. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/fieldUtils.js +88 -0
  26. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/fieldUtils.js.map +1 -0
  27. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/renderFieldInput.js +106 -0
  28. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/renderFieldInput.js.map +1 -0
  29. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/tabStyles.js +241 -0
  30. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/tabStyles.js.map +1 -0
  31. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/useDatasourceConfigForm.js +284 -0
  32. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/useDatasourceConfigForm.js.map +1 -0
  33. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/wizardStyles.js +124 -0
  34. package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/wizardStyles.js.map +1 -0
  35. package/dist/esm/components/DataLinks/DataLink.js +2 -2
  36. package/dist/esm/components/DataLinks/DataLinks.js +2 -2
  37. package/dist/esm/components/DatePicker/styles.js +2 -2
  38. package/dist/esm/components/DatePickerWithInput/styles.js +2 -2
  39. package/dist/esm/components/QueryEditor/EditorField.js +2 -2
  40. package/dist/esm/components/QueryEditor/EditorHeader.js +2 -2
  41. package/dist/esm/components/QueryEditor/EditorRow.js +2 -2
  42. package/dist/esm/components/QueryEditor/EditorSwitch.js +2 -2
  43. package/dist/esm/components/QueryEditor/InlineSelect.js +1 -1
  44. package/dist/esm/components/QueryEditor/InlineSelect.js.map +1 -1
  45. package/dist/esm/components/QueryEditor/InputGroup.js +2 -2
  46. package/dist/esm/components/QueryEditor/QueryEditor.js +3 -1
  47. package/dist/esm/components/QueryEditor/QueryEditor.js.map +1 -1
  48. package/dist/esm/components/QueryEditor/QueryHeader.js +2 -2
  49. package/dist/esm/components/QueryEditor/QueryHeader.js.map +1 -1
  50. package/dist/esm/components/QueryEditor/Space.js +2 -2
  51. package/dist/esm/components/QueryEditor/TableSelector.js +0 -1
  52. package/dist/esm/components/QueryEditor/TableSelector.js.map +1 -1
  53. package/dist/esm/components/QueryEditor/defaults.js.map +1 -1
  54. package/dist/esm/components/QueryEditor/query-editor-raw/QueryEditorRaw.js +10 -2
  55. package/dist/esm/components/QueryEditor/query-editor-raw/QueryEditorRaw.js.map +1 -1
  56. package/dist/esm/components/QueryEditor/query-editor-raw/QueryToolbox.js +6 -1
  57. package/dist/esm/components/QueryEditor/query-editor-raw/QueryToolbox.js.map +1 -1
  58. package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js +13 -3
  59. package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js.map +1 -1
  60. package/dist/esm/components/QueryEditor/types.js +0 -1
  61. package/dist/esm/components/QueryEditor/types.js.map +1 -1
  62. package/dist/esm/components/QueryEditor/utils/formatSQL.js +15 -4
  63. package/dist/esm/components/QueryEditor/utils/formatSQL.js.map +1 -1
  64. package/dist/esm/components/QueryEditor/visual-query-builder/EditorField.js +2 -2
  65. package/dist/esm/components/QueryEditor/visual-query-builder/EditorRow.js +2 -2
  66. package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js +4 -4
  67. package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js.map +1 -1
  68. package/dist/esm/components/QueryEditor/visual-query-builder/SQLGroupByRow.js +0 -1
  69. package/dist/esm/components/QueryEditor/visual-query-builder/SQLGroupByRow.js.map +1 -1
  70. package/dist/esm/components/QueryEditor/visual-query-builder/SQLOrderByRow.js +0 -1
  71. package/dist/esm/components/QueryEditor/visual-query-builder/SQLOrderByRow.js.map +1 -1
  72. package/dist/esm/components/QueryEditor/visual-query-builder/SQLSelectRow.js +0 -1
  73. package/dist/esm/components/QueryEditor/visual-query-builder/SQLSelectRow.js.map +1 -1
  74. package/dist/esm/components/QueryEditor/visual-query-builder/SQLWhereRow.js +0 -1
  75. package/dist/esm/components/QueryEditor/visual-query-builder/SQLWhereRow.js.map +1 -1
  76. package/dist/esm/components/QueryEditor/visual-query-builder/SelectRow.js +2 -2
  77. package/dist/esm/components/QueryEditor/visual-query-builder/VisualEditor.js +10 -2
  78. package/dist/esm/components/QueryEditor/visual-query-builder/VisualEditor.js.map +1 -1
  79. package/dist/esm/components/SQLEditor/components/SQLEditor.js.map +1 -1
  80. package/dist/esm/components/SQLEditor/standardSql/definition.js +0 -6
  81. package/dist/esm/components/SQLEditor/standardSql/definition.js.map +1 -1
  82. package/dist/esm/components/SQLEditor/standardSql/getStatementPosition.js +2 -1
  83. package/dist/esm/components/SQLEditor/standardSql/getStatementPosition.js.map +1 -1
  84. package/dist/esm/components/SQLEditor/standardSql/statementPositionResolversRegistry.js +2 -1
  85. package/dist/esm/components/SQLEditor/standardSql/statementPositionResolversRegistry.js.map +1 -1
  86. package/dist/esm/components/SQLEditor/types.js +1 -17
  87. package/dist/esm/components/SQLEditor/types.js.map +1 -1
  88. package/dist/esm/components/SQLEditor/utils/LinkedToken.js +1 -1
  89. package/dist/esm/components/SQLEditor/utils/LinkedToken.js.map +1 -1
  90. package/dist/esm/components/SQLEditor/utils/linkedTokenBuilder.js +2 -2
  91. package/dist/esm/components/SQLEditor/utils/tokenType.js +18 -0
  92. package/dist/esm/components/SQLEditor/utils/tokenType.js.map +1 -0
  93. package/dist/esm/components/SQLEditor/utils/tokenUtils.js +1 -1
  94. package/dist/esm/components/VisualQueryBuilder/components/OperationEditorBody.js +1 -1
  95. package/dist/esm/components/VisualQueryBuilder/components/OperationList.js +1 -1
  96. package/dist/esm/components/VisualQueryBuilder/components/OperationParamEditor.js +1 -1
  97. package/dist/esm/components/VisualQueryBuilder/components/OperationsEditorRow.js +1 -1
  98. package/dist/esm/components/VisualQueryBuilder/components/QueryHeaderSwitch.js +1 -1
  99. package/dist/esm/components/VisualQueryBuilder/components/QueryOptionGroup.js +1 -1
  100. package/dist/esm/datasource/schema/config.js +235 -0
  101. package/dist/esm/datasource/schema/config.js.map +1 -0
  102. package/dist/esm/datasource/schema/datasource.js +228 -0
  103. package/dist/esm/datasource/schema/datasource.js.map +1 -0
  104. package/dist/esm/datasource/schema/llmHints.js +54 -0
  105. package/dist/esm/datasource/schema/llmHints.js.map +1 -0
  106. package/dist/esm/datasource/schema/provisioningYaml.js +358 -0
  107. package/dist/esm/datasource/schema/provisioningYaml.js.map +1 -0
  108. package/dist/esm/index.d.ts +564 -38
  109. package/dist/esm/index.js +7 -1
  110. package/dist/esm/index.js.map +1 -1
  111. package/package.json +30 -11
@@ -4,6 +4,7 @@ import { DataSourceInstanceSettings, SelectableValue, DataSourceJsonData, Variab
4
4
  import { DataSourceSrv, DataSourceWithBackend, TemplateSrv } from '@grafana/runtime';
5
5
  import { JsonTree } from '@react-awesome-query-builder/ui';
6
6
  import { DataQuery } from '@grafana/schema';
7
+ import { SqlLanguage } from 'sql-formatter';
7
8
  import { Grammar } from 'prismjs';
8
9
 
9
10
  interface QueryEditorRowProps {
@@ -99,9 +100,6 @@ type Props$q = {
99
100
  };
100
101
  declare const DataLink: (props: Props$q) => React.JSX.Element;
101
102
 
102
- declare function applyQueryDefaults(q?: SQLQuery): SQLQuery;
103
- type QueryWithDefaults = ReturnType<typeof applyQueryDefaults>;
104
-
105
103
  declare enum QueryEditorPropertyType {
106
104
  String = "string"
107
105
  }
@@ -136,6 +134,21 @@ interface QueryEditorFunctionParameterExpression {
136
134
  name?: string;
137
135
  }
138
136
 
137
+ declare enum TokenType {
138
+ Parenthesis = "delimiter.parenthesis.sql",
139
+ Whitespace = "white.sql",
140
+ Keyword = "keyword.sql",
141
+ Delimiter = "delimiter.sql",
142
+ Operator = "operator.sql",
143
+ Identifier = "identifier.sql",
144
+ IdentifierQuote = "identifier.quote.sql",
145
+ Type = "type.sql",
146
+ Function = "predefined.sql",
147
+ Number = "number.sql",
148
+ String = "string.sql",
149
+ Variable = "variable.sql"
150
+ }
151
+
139
152
  declare class LinkedToken {
140
153
  type: string;
141
154
  value: string;
@@ -164,17 +177,6 @@ declare class LinkedToken {
164
177
  getNextOfType(type: TokenType, value?: string): LinkedToken | null;
165
178
  }
166
179
 
167
- type StatementPositionResolver = (currentToken: LinkedToken | null, previousKeyword: LinkedToken | null, previousNonWhiteSpace: LinkedToken | null, previousIsSlash: Boolean) => Boolean;
168
- type SuggestionsResolver = <T extends PositionContext = PositionContext>(positionContext: T) => Promise<CustomSuggestion[]>;
169
- interface SQLMonarchLanguage extends monacoTypes.languages.IMonarchLanguage {
170
- keywords?: string[];
171
- builtinFunctions?: string[];
172
- logicalOperators?: string[];
173
- comparisonOperators?: string[];
174
- /** Used by basic languages in the monaco registry **/
175
- operators?: string[];
176
- }
177
-
178
180
  /**
179
181
  * Provides a context for suggestions resolver
180
182
  * @alpha
@@ -290,7 +292,25 @@ interface SQLCompletionItemProvider extends Omit<monacoTypes.languages.Completio
290
292
  */
291
293
  provideCompletionItems?: (model: monacoTypes.editor.ITextModel, position: monacoTypes.Position, context: monacoTypes.languages.CompletionContext, token: monacoTypes.CancellationToken, positionContext: PositionContext) => monacoTypes.languages.CompletionList;
292
294
  }
295
+ interface SQLMonarchLanguage extends monacoTypes.languages.IMonarchLanguage {
296
+ keywords?: string[];
297
+ builtinFunctions?: string[];
298
+ logicalOperators?: string[];
299
+ comparisonOperators?: string[];
300
+ /** Used by basic languages in the monaco registry **/
301
+ operators?: string[];
302
+ }
303
+ type StatementPositionResolver = (currentToken: LinkedToken | null, previousKeyword: LinkedToken | null, previousNonWhiteSpace: LinkedToken | null, previousIsSlash: Boolean) => Boolean;
304
+ type SuggestionsResolver = <T extends PositionContext = PositionContext>(positionContext: T) => Promise<CustomSuggestion[]>;
293
305
  type LanguageCompletionProvider = (m: Monaco, l?: SQLMonarchLanguage) => SQLCompletionItemProvider;
306
+ interface LanguageDefinition extends monacoTypes.languages.ILanguageExtensionPoint {
307
+ loader?: (module: any) => Promise<{
308
+ language: SQLMonarchLanguage;
309
+ conf: monacoTypes.languages.LanguageConfiguration;
310
+ }>;
311
+ completionProvider?: (m: Monaco, language: SQLMonarchLanguage) => SQLCompletionItemProvider;
312
+ formatter?: (q: string) => string;
313
+ }
294
314
  declare enum OperatorType {
295
315
  Comparison = 0,
296
316
  Logical = 1
@@ -302,20 +322,7 @@ declare enum MacroType {
302
322
  Column = 3,
303
323
  Table = 4
304
324
  }
305
- declare enum TokenType {
306
- Parenthesis = "delimiter.parenthesis.sql",
307
- Whitespace = "white.sql",
308
- Keyword = "keyword.sql",
309
- Delimiter = "delimiter.sql",
310
- Operator = "operator.sql",
311
- Identifier = "identifier.sql",
312
- IdentifierQuote = "identifier.quote.sql",
313
- Type = "type.sql",
314
- Function = "predefined.sql",
315
- Number = "number.sql",
316
- String = "string.sql",
317
- Variable = "variable.sql"
318
- }
325
+
319
326
  declare enum StatementPosition {
320
327
  Unknown = "unknown",
321
328
  SelectKeyword = "selectKeyword",
@@ -417,14 +424,6 @@ declare enum SQLEditorMode {
417
424
  Code = "code"
418
425
  }
419
426
 
420
- interface LanguageDefinition extends monacoTypes.languages.ILanguageExtensionPoint {
421
- loader?: (module: any) => Promise<{
422
- language: SQLMonarchLanguage;
423
- conf: monacoTypes.languages.LanguageConfiguration;
424
- }>;
425
- completionProvider?: (m: Monaco, language: SQLMonarchLanguage) => SQLCompletionItemProvider;
426
- formatter?: (q: string) => string;
427
- }
428
427
  interface SQLEditorProps {
429
428
  query: string;
430
429
  /**
@@ -640,6 +639,11 @@ interface MetaDefinition {
640
639
  completion?: string;
641
640
  kind: CompletionItemKind;
642
641
  }
642
+ /**
643
+ * Represents a query with all default values applied.
644
+ * This is equivalent to SQLQuery since applyQueryDefaults returns SQLQuery.
645
+ */
646
+ type QueryWithDefaults = SQLQuery;
643
647
 
644
648
  interface GroupByRowProps {
645
649
  sql: SQLExpression;
@@ -781,8 +785,9 @@ interface MetricFindQueryOptions extends SearchFilterOptions {
781
785
  }
782
786
 
783
787
  interface Props$p extends QueryEditorProps$1<SqlDatasource, SQLQuery, SQLOptions> {
788
+ language?: SqlLanguage;
784
789
  }
785
- declare function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }: Props$p): React.JSX.Element | null;
790
+ declare function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range, language }: Props$p): React.JSX.Element | null;
786
791
 
787
792
  type RunQueryButtonProps = {
788
793
  ariaLabel?: string;
@@ -1008,6 +1013,373 @@ type Props$a<C extends Config = Config> = {
1008
1013
  };
1009
1014
  declare const AdvancedHttpSettings: <C extends Config = Config>(props: Props$a<C>) => JSX.Element;
1010
1015
 
1016
+ interface DatasourceConfigSchema {
1017
+ /**
1018
+ * Schema version (required)
1019
+ * Used for compatibility and migrations
1020
+ *
1021
+ * Example: "v2"
1022
+ */
1023
+ schemaVersion: string;
1024
+ /**
1025
+ * Unique datasource plugin identifier
1026
+ * Example: "prometheus"
1027
+ */
1028
+ pluginType: string;
1029
+ /**
1030
+ * Human-readable name
1031
+ */
1032
+ pluginName: string;
1033
+ /**
1034
+ * Optional documentation URL
1035
+ */
1036
+ docURL?: string;
1037
+ /**
1038
+ * Source of truth for configuration
1039
+ */
1040
+ fields: ConfigField[];
1041
+ /**
1042
+ * Optional UI grouping
1043
+ */
1044
+ groups?: ConfigGroup[];
1045
+ /**
1046
+ * Relationships between fields
1047
+ */
1048
+ relationships?: FieldRelationship[];
1049
+ }
1050
+ interface ConfigField {
1051
+ /**
1052
+ * Globally unique identifier
1053
+ * Recommended format: dot-separated path
1054
+ * Example: "auth.method", "httpHeaders.item.key"
1055
+ */
1056
+ id: string;
1057
+ /**
1058
+ * Local key used in storage or object
1059
+ */
1060
+ key: string;
1061
+ /**
1062
+ * UI metadata
1063
+ */
1064
+ label?: string;
1065
+ description?: string;
1066
+ docURL?: string;
1067
+ /**
1068
+ * Core type of the field
1069
+ */
1070
+ valueType: ValueType;
1071
+ /**
1072
+ * Semantic meaning (optional)
1073
+ */
1074
+ semanticType?: SemanticType;
1075
+ /**
1076
+ * Storage location (required for storage fields)
1077
+ */
1078
+ target?: TargetLocation;
1079
+ /**
1080
+ * Dotted path prefix within the target for nested objects.
1081
+ * Example: for jsonData.tracesToLogs.datasourceUid,
1082
+ * target="jsonData", section="tracesToLogs", key="datasourceUid".
1083
+ */
1084
+ section?: string;
1085
+ /**
1086
+ * Field kind.
1087
+ * @default "storage"
1088
+ */
1089
+ kind?: FieldKind;
1090
+ /**
1091
+ * True if field belongs to array item schema
1092
+ */
1093
+ isItemField?: boolean;
1094
+ /**
1095
+ * Lifecycle state
1096
+ */
1097
+ lifecycle?: Lifecycle;
1098
+ /**
1099
+ * UI rendering hints
1100
+ */
1101
+ ui?: FieldUI;
1102
+ /**
1103
+ * Validations rules
1104
+ */
1105
+ validations?: FieldValidationRule[];
1106
+ /**
1107
+ * Visibility condition (CEL expression)
1108
+ */
1109
+ dependsOn?: Expression;
1110
+ /**
1111
+ * Always required
1112
+ */
1113
+ required?: boolean;
1114
+ /**
1115
+ * Conditionally required
1116
+ */
1117
+ requiredWhen?: Expression;
1118
+ /**
1119
+ * Disabled condition
1120
+ */
1121
+ disabledWhen?: Expression;
1122
+ /**
1123
+ * Dynamic overrides
1124
+ */
1125
+ overrides?: FieldOverride[];
1126
+ /**
1127
+ * Declarative multi-field write side-effects.
1128
+ * When this field's value matches a condition, the listed target
1129
+ * fields are set to specified values. Typically used on virtual
1130
+ * selector fields (e.g. auth method dropdown).
1131
+ */
1132
+ effects?: FieldEffect[];
1133
+ /**
1134
+ * Item schema for array elements or map values.
1135
+ * Required if valueType === "array" or "map".
1136
+ */
1137
+ item?: FieldItemSchema;
1138
+ /**
1139
+ * Legacy indexed fields (deprecated)
1140
+ */
1141
+ repeatable?: boolean;
1142
+ pattern?: string;
1143
+ /**
1144
+ * Storage mapping
1145
+ */
1146
+ storage?: StorageMapping;
1147
+ /**
1148
+ * Metadata
1149
+ */
1150
+ tags?: string[];
1151
+ examples?: unknown[];
1152
+ defaultValue?: unknown;
1153
+ }
1154
+ interface FieldItemSchema {
1155
+ /**
1156
+ * Type of array items or map values.
1157
+ * For arrays, describes each element.
1158
+ * For maps, describes each value (keys are always strings).
1159
+ */
1160
+ valueType: ValueType;
1161
+ /**
1162
+ * Sub-fields for object items. Optional even when valueType = "object"
1163
+ * (omitting allows an unconstrained object).
1164
+ */
1165
+ fields?: ConfigField[];
1166
+ }
1167
+ /**
1168
+ * CEL expression string
1169
+ */
1170
+ type Expression = string;
1171
+ type ValueType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'map' | 'any';
1172
+ type SemanticType = 'url' | 'password' | 'token' | 'hostname' | 'duration' | 'datasourceUid' | 'query';
1173
+ type FieldKind = 'storage' | 'virtual';
1174
+ type Lifecycle = 'stable' | 'deprecated' | 'experimental';
1175
+ type TargetLocation = 'root' | 'jsonData' | 'secureJsonData';
1176
+ type UIComponent = 'input' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'checkbox' | 'switch' | 'code' | 'keyvalue' | 'list';
1177
+ type UIWidth = 'full' | 'half';
1178
+ /**
1179
+ * UI configuration
1180
+ */
1181
+ interface FieldUI {
1182
+ component: UIComponent;
1183
+ multiline?: boolean;
1184
+ rows?: number;
1185
+ options?: FieldOption[];
1186
+ allowCustom?: boolean;
1187
+ width?: UIWidth;
1188
+ placeholder?: string;
1189
+ /**
1190
+ * Language hint for code editor components.
1191
+ * Example: "promql", "logql", "traceql", "sql", "json"
1192
+ */
1193
+ language?: string;
1194
+ }
1195
+ type FieldValidationRule = PatternValidationRule | RangeValidationRule | LengthValidationRule | ItemCountValidationRule | AllowedValuesValidationRule | CustomValidationRule;
1196
+ interface BaseValidationRule {
1197
+ /**
1198
+ * Optional stable ID for the validation rule.
1199
+ * Useful for docs, localization, and test snapshots.
1200
+ */
1201
+ id?: string;
1202
+ /**
1203
+ * Human-readable validation error message.
1204
+ */
1205
+ message?: string;
1206
+ }
1207
+ interface PatternValidationRule extends BaseValidationRule {
1208
+ type: 'pattern';
1209
+ pattern: string;
1210
+ }
1211
+ interface RangeValidationRule extends BaseValidationRule {
1212
+ type: 'range';
1213
+ min?: number;
1214
+ max?: number;
1215
+ }
1216
+ interface LengthValidationRule extends BaseValidationRule {
1217
+ type: 'length';
1218
+ min?: number;
1219
+ max?: number;
1220
+ }
1221
+ interface ItemCountValidationRule extends BaseValidationRule {
1222
+ type: 'itemCount';
1223
+ min?: number;
1224
+ max?: number;
1225
+ }
1226
+ interface AllowedValuesValidationRule extends BaseValidationRule {
1227
+ type: 'allowedValues';
1228
+ values: unknown[];
1229
+ }
1230
+ interface CustomValidationRule extends BaseValidationRule {
1231
+ type: 'custom';
1232
+ /**
1233
+ * CEL expression.
1234
+ *
1235
+ * Should evaluate to true when the field value is valid.
1236
+ */
1237
+ expression: Expression;
1238
+ }
1239
+ interface FieldOverride {
1240
+ /**
1241
+ * CEL condition
1242
+ */
1243
+ when: Expression;
1244
+ defaultValue?: unknown;
1245
+ /**
1246
+ * When true, the field is disabled/read-only while this override is active.
1247
+ */
1248
+ readOnly?: boolean;
1249
+ description?: string;
1250
+ placeholder?: string;
1251
+ tooltip?: string;
1252
+ validations?: FieldValidationRule[];
1253
+ options?: FieldOption[];
1254
+ }
1255
+ /**
1256
+ * Declares that when a field's value matches a condition,
1257
+ * listed target fields should be set to specified values.
1258
+ *
1259
+ * Use "value" in the `when` expression to refer to the field's value.
1260
+ */
1261
+ interface FieldEffect {
1262
+ /**
1263
+ * CEL expression. Example: "value == 'basic-auth'"
1264
+ */
1265
+ when: Expression;
1266
+ /**
1267
+ * Maps field IDs to the values they should be set to.
1268
+ * Must contain at least one entry.
1269
+ */
1270
+ set: Record<string, unknown> & {
1271
+ [k: string]: unknown;
1272
+ };
1273
+ }
1274
+ type StorageMapping = DirectMapping | IndexedPairMapping | ComputedMapping;
1275
+ /**
1276
+ * Direct mapping
1277
+ */
1278
+ interface DirectMapping {
1279
+ type: 'direct';
1280
+ }
1281
+ /**
1282
+ * Indexed pair mapping (headers)
1283
+ */
1284
+ interface IndexedPairMapping {
1285
+ type: 'indexedPair';
1286
+ key: MappingField;
1287
+ value: MappingField;
1288
+ startIndex?: number;
1289
+ }
1290
+ /**
1291
+ * Computed mapping (virtual fields).
1292
+ * At least one of `read` or `write` must be provided.
1293
+ */
1294
+ type ComputedMapping = {
1295
+ type: 'computed';
1296
+ read: Expression;
1297
+ write?: Expression;
1298
+ } | {
1299
+ type: 'computed';
1300
+ read?: Expression;
1301
+ write: Expression;
1302
+ };
1303
+ /**
1304
+ * Mapping field
1305
+ */
1306
+ interface MappingField {
1307
+ target: TargetLocation;
1308
+ pattern: string;
1309
+ }
1310
+ interface FieldOption {
1311
+ label: string;
1312
+ /**
1313
+ * Must match parent field valueType.
1314
+ * Must not be null.
1315
+ */
1316
+ value: NonNullable<unknown>;
1317
+ /**
1318
+ * Optional human-readable description of the option.
1319
+ */
1320
+ description?: string;
1321
+ }
1322
+ interface ConfigGroup {
1323
+ id: string;
1324
+ title: string;
1325
+ description?: string;
1326
+ order?: number;
1327
+ /**
1328
+ * When true, the group is optional and can be collapsed/hidden by default.
1329
+ */
1330
+ optional?: boolean;
1331
+ /**
1332
+ * References field IDs (not keys)
1333
+ */
1334
+ fieldRefs: string[];
1335
+ }
1336
+ type RelationshipType = 'pair' | 'group' | 'datasourceReference';
1337
+ interface FieldRelationship {
1338
+ type: RelationshipType;
1339
+ /**
1340
+ * References field IDs
1341
+ */
1342
+ fields: string[];
1343
+ description?: string;
1344
+ /**
1345
+ * Constrains the datasource UID to a specific plugin type.
1346
+ * Only applicable when type is "datasourceReference".
1347
+ */
1348
+ targetPluginType?: string;
1349
+ }
1350
+ type SecureFieldState = {
1351
+ type: 'unset';
1352
+ } | {
1353
+ type: 'configured';
1354
+ } | {
1355
+ type: 'updated';
1356
+ value: string;
1357
+ };
1358
+ interface FormState {
1359
+ values: Record<string, unknown>;
1360
+ secure: Record<string, SecureFieldState>;
1361
+ }
1362
+
1363
+ type DatasourceConfigWizardProps = {
1364
+ schema: DatasourceConfigSchema;
1365
+ dsUid: string;
1366
+ dsName: string;
1367
+ onSuccess: (status: string, message?: string) => void;
1368
+ onSaving?: (saving: boolean) => void;
1369
+ onRetest?: () => void;
1370
+ onFollowup?: (intent: string) => void;
1371
+ healthError?: string;
1372
+ mode?: 'tab' | 'wizard';
1373
+ /** Optional render prop for custom action buttons (e.g. analyze/troubleshoot). */
1374
+ renderActions?: (props: {
1375
+ dsUid: string;
1376
+ dsName: string;
1377
+ dsType: string;
1378
+ healthError?: string;
1379
+ }) => ReactNode;
1380
+ };
1381
+ declare function DatasourceConfigWizard(props: DatasourceConfigWizardProps): React.JSX.Element;
1382
+
1011
1383
  interface CustomHeader {
1012
1384
  id: string;
1013
1385
  name: string;
@@ -1232,4 +1604,158 @@ interface Props {
1232
1604
  }
1233
1605
  declare function RawQuery({ query, language, className }: Props): React.JSX.Element;
1234
1606
 
1235
- export { AccessoryButton, AdvancedHttpSettings, type Aggregate, Auth, AuthMethod, type Props$c as AuthProps, BINARY_OPERATIONS_KEY, CatalogSelector, type ColumnDefinition, CompletionItemInsertTextRule, CompletionItemKind, CompletionItemPriority, ConfigDescriptionLink, ConfigSection, ConfigSubSection, ConnectionSettings, CustomHeadersSettings, type DB, DataLink, type DataLinkConfig, DataLinks, DataSourceDescription, DataSourcePicker, DatasetSelector, DatePicker, type DatePickerProps, DatePickerWithInput, type DatePickerWithInputProps, DebounceInput, type DebounceInputProps, EditorField, EditorFieldGroup, EditorHeader, EditorList, EditorMode, EditorRow, EditorRows, EditorStack, EditorSwitch, FlexItem, GroupByRow, InlineSelect, InputGroup, LabelFilters, type LanguageCompletionProvider, type LanguageDefinition, LinkedToken, MacroType, type MetaDefinition, type NameValue, OperationExplainedBox, OperationList, OperationListExplained, OperationsEditorRow, OperatorType, type PositionContext, type Props$s as Props, QUERY_FORMAT_OPTIONS, QueryBuilderHints, type QueryBuilderLabelFilter, type QueryBuilderOperation, type QueryBuilderOperationDefinition, type QueryBuilderOperationParamDef, type QueryBuilderOperationParamEditorProps, type QueryBuilderOperationParamValue, QueryEditorMode, QueryEditorModeToggle, type QueryEditorProps, QueryEditorRow, QueryFormat, QueryHeaderSwitch, QueryModellerBase, QueryOptionGroup, type QueryRowFilter, type QueryStats, type RAQBFieldTypes, RawQuery, type ResourceSelectorProps, type ResponseParser, RunQueryButton, type SQLConnectionLimits, SQLEditor, SQLEditorMode, SQLEditorTestUtils, type SQLExpression, type SQLFilters, type SQLMonarchLanguage, type SQLOptions, type SQLQuery, type SQLSelectableValue, type SchemaDefinition, SecureSocksProxyToggle, Segment, type SegmentProps, Space, SqlDatasource, SqlQueryEditor, type SqlQueryForInterpolation, type SqlQueryModel, type State$1 as State, type StatementPlacementProvider, StatementPosition, SuggestionKind, type SuggestionKindProvider, TLSSettings, type Props$f as TLSSettingsProps, type TableDefinition, type TableFieldSchema, type TableIdentifier, type TableSchema, TableSelector, type TestQueryModel, TokenType, type ValidationResults, type VisualQuery, type VisualQueryBinary, type VisualQueryModeller, convertLegacyAuthProps, formatDate, getStandardSQLCompletionProvider, language as grafanaStandardSQLLanguage, conf as grafanaStandardSQLLanguageConf, toOption };
1607
+ /**
1608
+ * Pure helper functions for working with DatasourceConfigSchema.
1609
+ *
1610
+ * Types are defined in schema.ts — import them from there directly.
1611
+ */
1612
+
1613
+ /**
1614
+ * Resolve a schema's groups into arrays of ConfigField objects.
1615
+ * If the schema has no groups, returns a single group containing all non-virtual fields.
1616
+ */
1617
+ declare function resolveGroups(schema: DatasourceConfigSchema): Array<{
1618
+ group: ConfigGroup;
1619
+ fields: ConfigField[];
1620
+ }>;
1621
+ /**
1622
+ * Build a virtual "Required" group containing all required fields, any parent
1623
+ * fields they depend on (via `dependsOn`), and any child fields that depend on
1624
+ * required fields. When the schema contains an "auth" group, its fields are
1625
+ * also pulled in (auth is effectively required for Prometheus/Loki/Tempo style
1626
+ * datasources). Fields are returned in schema order and de-duplicated.
1627
+ * Returns `null` when the virtual group would be empty.
1628
+ */
1629
+ declare function resolveRequiredFieldsGroup(schema: DatasourceConfigSchema): {
1630
+ group: ConfigGroup;
1631
+ fields: ConfigField[];
1632
+ } | null;
1633
+ /**
1634
+ * Unique form key for a field. Section-scoped fields (e.g. section:"logs", key:"defaultTable")
1635
+ * get a prefixed key ("logs.defaultTable") so they don't collide with top-level fields that
1636
+ * share the same key name.
1637
+ */
1638
+ declare function formKey(field: ConfigField): string;
1639
+ /**
1640
+ * Parse a simple CEL-like dependsOn expression: "fieldId == 'value'" or "fieldId == true".
1641
+ * Returns { field, value } or null if unparseable.
1642
+ */
1643
+ declare function parseDependsOn(expr: string): {
1644
+ field: string;
1645
+ value: string;
1646
+ } | null;
1647
+ /**
1648
+ * Resolve the first matching override for a field given current form values.
1649
+ * Override `when` uses the same "fieldId == 'value'" syntax as dependsOn.
1650
+ * Returns the matching override or undefined if none match.
1651
+ */
1652
+ declare function resolveActiveOverride(field: ConfigField, watchedValues: Record<string, unknown>, fieldById: Map<string, ConfigField>): FieldOverride | undefined;
1653
+ /**
1654
+ * Evaluate a simple computed.read expression against form values.
1655
+ * Supports patterns used in dsconfig schemas:
1656
+ * - "fieldRef == true ? 'a' : (fieldRef == true ? 'b' : 'c')"
1657
+ * - Simple ternary chains with equality checks
1658
+ * Falls back to the field's defaultValue if the expression can't be evaluated.
1659
+ */
1660
+ declare function evaluateComputedRead(expr: string, values: Record<string, unknown>, fields: ConfigField[]): unknown;
1661
+ /**
1662
+ * Compute initial values for all virtual fields that have storage.computed.read expressions.
1663
+ * Call after loading existing storage field values.
1664
+ */
1665
+ declare function computeVirtualFieldValues(schema: DatasourceConfigSchema, existingValues: Record<string, unknown>): Record<string, unknown>;
1666
+
1667
+ type DatasourceResponse = Record<string, unknown> & {
1668
+ name: string;
1669
+ id: number;
1670
+ uid: string;
1671
+ access?: 'proxy' | 'direct';
1672
+ type?: string;
1673
+ typeLogoUrl?: string;
1674
+ url?: string;
1675
+ withCredentials?: boolean;
1676
+ basicAuth?: boolean;
1677
+ basicAuthUser?: string;
1678
+ user?: string;
1679
+ database?: string;
1680
+ jsonData?: Record<string, unknown>;
1681
+ secureJsonFields?: Record<string, boolean>;
1682
+ readOnly?: boolean;
1683
+ };
1684
+ type DatasourceConfigPayload = {
1685
+ rootFields: Record<string, unknown>;
1686
+ jsonData: Record<string, unknown>;
1687
+ secureJsonData: Record<string, string>;
1688
+ secureJsonFields: Record<string, boolean>;
1689
+ };
1690
+ type FormValues = Record<string, unknown>;
1691
+
1692
+ declare const SECURE_FIELD_CONFIGURED = "__CONFIGURED__";
1693
+ type FetchExistingResult = {
1694
+ values: FormValues;
1695
+ readOnly: boolean;
1696
+ error?: string;
1697
+ };
1698
+ /** Indexed pair item as stored in form values. Each item tracks its original storage index. */
1699
+ type IndexedPairItem = {
1700
+ /** Original storage index (e.g. 1 for httpHeaderName1). 0 = new item, not yet persisted. */
1701
+ index: number;
1702
+ name: string;
1703
+ value: string;
1704
+ };
1705
+ /**
1706
+ * Expand indexed pair storage (e.g. httpHeaderName1..N / httpHeaderValue1..N)
1707
+ * into an array of {index, name, value} items for the form.
1708
+ * Each item's `index` tracks its storage position so deletes don't shift others.
1709
+ * Scans all keys in the source record to find matching indices — no gap heuristics.
1710
+ */
1711
+ declare function expandIndexedPair(field: ConfigField, ds: DatasourceResponse): IndexedPairItem[];
1712
+ /**
1713
+ * Flatten an array of indexed pair items back into individual indexed keys
1714
+ * for jsonData and secureJsonData.
1715
+ */
1716
+ declare function flattenIndexedPair(field: ConfigField, items: IndexedPairItem[], jsonData: Record<string, unknown>, secureJsonData: Record<string, string>, secureJsonFields: Record<string, boolean>): void;
1717
+ declare function fetchExistingValues(dsUid: string, fields: ConfigField[]): Promise<FetchExistingResult>;
1718
+ declare function buildDatasourceConfigPayload(data: FormValues, fields: ConfigField[], existing: DatasourceResponse, isFieldVisible: (field: ConfigField) => boolean): DatasourceConfigPayload;
1719
+ declare function submitDatasourceConfig(dsUid: string, data: FormValues, fields: ConfigField[], isFieldVisible: (field: ConfigField) => boolean): Promise<void>;
1720
+
1721
+ /**
1722
+ * Generate LLM hints for select fields (used when creating datasources).
1723
+ */
1724
+ declare function generateLLMHint(schema: DatasourceConfigSchema): string;
1725
+ /**
1726
+ * Generate comprehensive structured field data for troubleshooting context.
1727
+ * Returns an array of field descriptors the LLM can use to render rich tables.
1728
+ */
1729
+ declare function generateTroubleshootingFields(schema: DatasourceConfigSchema): Array<{
1730
+ label: string;
1731
+ key: string;
1732
+ target: string;
1733
+ type: string;
1734
+ required: boolean;
1735
+ description?: string;
1736
+ defaultValue?: unknown;
1737
+ options?: string[];
1738
+ section?: string;
1739
+ dependsOn?: string;
1740
+ }>;
1741
+
1742
+ type ProvisioningYamlOptions = {
1743
+ /** Include comments with field descriptions. Default: true for template, false for export. */
1744
+ comments?: boolean;
1745
+ /** Name override (used in template mode). */
1746
+ name?: string;
1747
+ };
1748
+ /**
1749
+ * Generate a Grafana provisioning YAML from a dsconfig schema.
1750
+ * In template mode (no values), emits all fields with defaults and comments.
1751
+ * When values are provided, emits actual values — used for existing datasource export.
1752
+ */
1753
+ declare function toProvisioningYaml(schema: DatasourceConfigSchema, values?: Record<string, unknown>, options?: ProvisioningYamlOptions): string;
1754
+ /**
1755
+ * Generate provisioning YAML from an existing Grafana datasource API response.
1756
+ * If a dsconfig schema is available, uses it for field ordering and comments.
1757
+ * If not, generates basic YAML from the raw API response.
1758
+ */
1759
+ declare function datasourceToProvisioningYaml(ds: Record<string, unknown>, schema: DatasourceConfigSchema | null): string;
1760
+
1761
+ export { AccessoryButton, AdvancedHttpSettings, type Aggregate, type AllowedValuesValidationRule, Auth, AuthMethod, type Props$c as AuthProps, BINARY_OPERATIONS_KEY, type BaseValidationRule, CatalogSelector, type ColumnDefinition, CompletionItemInsertTextRule, CompletionItemKind, CompletionItemPriority, type ComputedMapping, ConfigDescriptionLink, type ConfigField, type ConfigGroup, ConfigSection, ConfigSubSection, ConnectionSettings, CustomHeadersSettings, type CustomValidationRule, type DB, DataLink, type DataLinkConfig, DataLinks, DataSourceDescription, DataSourcePicker, DatasetSelector, type DatasourceConfigPayload, type DatasourceConfigSchema, DatasourceConfigWizard, type DatasourceConfigWizardProps, type DatasourceResponse, DatePicker, type DatePickerProps, DatePickerWithInput, type DatePickerWithInputProps, DebounceInput, type DebounceInputProps, type DirectMapping, EditorField, EditorFieldGroup, EditorHeader, EditorList, EditorMode, EditorRow, EditorRows, EditorStack, EditorSwitch, type Expression, type FetchExistingResult, type FieldEffect, type FieldItemSchema, type FieldKind, type FieldOption, type FieldOverride, type FieldRelationship, type FieldUI, type FieldValidationRule, FlexItem, type FormState, type FormValues, GroupByRow, type IndexedPairItem, type IndexedPairMapping, InlineSelect, InputGroup, type ItemCountValidationRule, LabelFilters, type LanguageCompletionProvider, type LanguageDefinition, type LengthValidationRule, type Lifecycle, LinkedToken, MacroType, type MappingField, type MetaDefinition, type NameValue, OperationExplainedBox, OperationList, OperationListExplained, OperationsEditorRow, OperatorType, type PatternValidationRule, type PositionContext, type Props$s as Props, type ProvisioningYamlOptions, QUERY_FORMAT_OPTIONS, QueryBuilderHints, type QueryBuilderLabelFilter, type QueryBuilderOperation, type QueryBuilderOperationDefinition, type QueryBuilderOperationParamDef, type QueryBuilderOperationParamEditorProps, type QueryBuilderOperationParamValue, QueryEditorMode, QueryEditorModeToggle, type QueryEditorProps, QueryEditorRow, QueryFormat, QueryHeaderSwitch, QueryModellerBase, QueryOptionGroup, type QueryRowFilter, type QueryStats, type QueryWithDefaults, type RAQBFieldTypes, type RangeValidationRule, RawQuery, type RelationshipType, type ResourceSelectorProps, type ResponseParser, RunQueryButton, SECURE_FIELD_CONFIGURED, type SQLConnectionLimits, SQLEditor, SQLEditorMode, SQLEditorTestUtils, type SQLExpression, type SQLFilters, type SQLMonarchLanguage, type SQLOptions, type SQLQuery, type SQLSelectableValue, type SchemaDefinition, type SecureFieldState, SecureSocksProxyToggle, Segment, type SegmentProps, type SemanticType, Space, SqlDatasource, SqlQueryEditor, type SqlQueryForInterpolation, type SqlQueryModel, type State$1 as State, type StatementPlacementProvider, StatementPosition, type StorageMapping, SuggestionKind, type SuggestionKindProvider, TLSSettings, type Props$f as TLSSettingsProps, type TableDefinition, type TableFieldSchema, type TableIdentifier, type TableSchema, TableSelector, type TargetLocation, type TestQueryModel, TokenType, type UIComponent, type UIWidth, type ValidationResults, type ValueType, type VisualQuery, type VisualQueryBinary, type VisualQueryModeller, buildDatasourceConfigPayload, computeVirtualFieldValues, convertLegacyAuthProps, datasourceToProvisioningYaml, evaluateComputedRead, expandIndexedPair, fetchExistingValues, flattenIndexedPair, formKey, formatDate, generateLLMHint, generateTroubleshootingFields, getStandardSQLCompletionProvider, language as grafanaStandardSQLLanguage, conf as grafanaStandardSQLLanguageConf, parseDependsOn, resolveActiveOverride, resolveGroups, resolveRequiredFieldsGroup, submitDatasourceConfig, toOption, toProvisioningYaml };
@@ -6,7 +6,7 @@ import { useStyles2 } from '@grafana/ui';
6
6
  function ConfigDescriptionLink(props) {
7
7
  const { description, suffix, feature } = props;
8
8
  const text = `Learn more about ${feature}`;
9
- const styles = useStyles2(getStyles$c);
9
+ const styles = useStyles2(getStyles$g);
10
10
  return /* @__PURE__ */ React.createElement("span", { className: styles.container }, description, /* @__PURE__ */ React.createElement(
11
11
  "a",
12
12
  {
@@ -18,7 +18,7 @@ function ConfigDescriptionLink(props) {
18
18
  text
19
19
  ));
20
20
  }
21
- const getStyles$c = (theme) => {
21
+ const getStyles$g = (theme) => {
22
22
  return {
23
23
  container: css({
24
24
  color: theme.colors.text.secondary,