@grafana/plugin-ui 0.13.1 → 0.14.1-dsconfig.b962e11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2918 -364
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +553 -39
- package/dist/cjs/test-utils.cjs +2 -2
- package/dist/cjs/test-utils.cjs.map +1 -1
- package/dist/cjs/test-utils.d.cts +1 -1
- package/dist/esm/components/ConfigEditor/AdvancedSettings/AdvancedHttpSettings.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/Auth.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/auth-method/AuthMethodSettings.js +4 -4
- package/dist/esm/components/ConfigEditor/Auth/auth-method/AuthMethodSettings.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/auth-method/BasicAuth.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/custom-headers/CustomHeader.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/custom-headers/CustomHeaders.js +1 -1
- package/dist/esm/components/ConfigEditor/Auth/custom-headers/CustomHeaders.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/styles.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/tls/SelfSignedCertificate.js +1 -1
- package/dist/esm/components/ConfigEditor/Auth/tls/SelfSignedCertificate.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/tls/SkipTLSVerification.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/tls/TLSClientAuth.js +3 -3
- package/dist/esm/components/ConfigEditor/Auth/tls/TLSClientAuth.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/tls/TLSSettings.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/tls/TLSSettingsSection.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/types.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Auth/utils.js +3 -3
- package/dist/esm/components/ConfigEditor/Auth/utils.js.map +1 -1
- package/dist/esm/components/ConfigEditor/ConfigSection/ConfigDescriptionLink.js +2 -2
- package/dist/esm/components/ConfigEditor/ConfigSection/ConfigDescriptionLink.js.map +1 -1
- package/dist/esm/components/ConfigEditor/ConfigSection/ConfigSection.js.map +1 -1
- package/dist/esm/components/ConfigEditor/ConfigSection/ConfigSubSection.js.map +1 -1
- package/dist/esm/components/ConfigEditor/ConfigSection/GenericConfigSection.js.map +1 -1
- package/dist/esm/components/ConfigEditor/Connection/ConnectionSettings.js +1 -1
- package/dist/esm/components/ConfigEditor/Connection/ConnectionSettings.js.map +1 -1
- package/dist/esm/components/ConfigEditor/DataSourceDescription.js.map +1 -1
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/AuthorizationHeaderField.js +53 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/AuthorizationHeaderField.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/ComplexFieldNote.js +24 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/ComplexFieldNote.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceConfigWizard.js +229 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/DatasourceConfigWizard.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/IndexedPairEditor.js +124 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/IndexedPairEditor.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/PdcFieldNote.js +34 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/PdcFieldNote.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SchemaField.js +60 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SchemaField.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SecureFieldInput.js +61 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SecureFieldInput.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SidebarNav.js +54 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/SidebarNav.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/StringArrayInput.js +84 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/StringArrayInput.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/TabLayout.js +176 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/TabLayout.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/fieldUtils.js +88 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/fieldUtils.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/renderFieldInput.js +106 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/renderFieldInput.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/tabStyles.js +241 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/tabStyles.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/useDatasourceConfigForm.js +284 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/useDatasourceConfigForm.js.map +1 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/wizardStyles.js +124 -0
- package/dist/esm/components/ConfigEditor/DatasourceConfigWizard/wizardStyles.js.map +1 -0
- package/dist/esm/components/ConfigEditor/SecureSocksProxyToggle.js.map +1 -1
- package/dist/esm/components/CustomHeadersSettings/CustomHeadersSettings.js +11 -11
- package/dist/esm/components/CustomHeadersSettings/CustomHeadersSettings.js.map +1 -1
- package/dist/esm/components/DataLinks/DataLink.js +4 -4
- package/dist/esm/components/DataLinks/DataLink.js.map +1 -1
- package/dist/esm/components/DataLinks/DataLinks.js +3 -3
- package/dist/esm/components/DataLinks/DataLinks.js.map +1 -1
- package/dist/esm/components/DataSourcePicker/DataSourcePicker.js +8 -8
- package/dist/esm/components/DataSourcePicker/DataSourcePicker.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/DatePicker/styles.js +2 -2
- package/dist/esm/components/DatePicker/styles.js.map +1 -1
- package/dist/esm/components/DatePickerWithInput/DatePickerWithInput.js.map +1 -1
- package/dist/esm/components/DatePickerWithInput/styles.js +2 -2
- package/dist/esm/components/DatePickerWithInput/styles.js.map +1 -1
- package/dist/esm/components/DebounceInput/DebounceInput.js.map +1 -1
- package/dist/esm/components/Plugins/PluginSignatureBadge.js.map +1 -1
- package/dist/esm/components/QueryEditor/AccessoryButton.js.map +1 -1
- package/dist/esm/components/QueryEditor/CatalogSelector.js +1 -1
- package/dist/esm/components/QueryEditor/CatalogSelector.js.map +1 -1
- package/dist/esm/components/QueryEditor/ConfirmModal.js +1 -1
- package/dist/esm/components/QueryEditor/ConfirmModal.js.map +1 -1
- package/dist/esm/components/QueryEditor/DatasetSelector.js +1 -1
- package/dist/esm/components/QueryEditor/DatasetSelector.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorField.js +5 -5
- package/dist/esm/components/QueryEditor/EditorField.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorFieldGroup.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorHeader.js +2 -2
- package/dist/esm/components/QueryEditor/EditorHeader.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorList.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorRow.js +4 -4
- package/dist/esm/components/QueryEditor/EditorRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorRows.js +2 -2
- package/dist/esm/components/QueryEditor/EditorRows.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorStack.js +1 -1
- package/dist/esm/components/QueryEditor/EditorStack.js.map +1 -1
- package/dist/esm/components/QueryEditor/EditorSwitch.js +2 -2
- package/dist/esm/components/QueryEditor/EditorSwitch.js.map +1 -1
- package/dist/esm/components/QueryEditor/FlexItem.js.map +1 -1
- package/dist/esm/components/QueryEditor/InlineSelect.js +1 -1
- package/dist/esm/components/QueryEditor/InlineSelect.js.map +1 -1
- package/dist/esm/components/QueryEditor/InputGroup.js +2 -2
- package/dist/esm/components/QueryEditor/InputGroup.js.map +1 -1
- package/dist/esm/components/QueryEditor/QueryEditor.js +10 -8
- package/dist/esm/components/QueryEditor/QueryEditor.js.map +1 -1
- package/dist/esm/components/QueryEditor/QueryHeader.js +20 -20
- package/dist/esm/components/QueryEditor/QueryHeader.js.map +1 -1
- package/dist/esm/components/QueryEditor/RunQueryButton.js +1 -1
- package/dist/esm/components/QueryEditor/RunQueryButton.js.map +1 -1
- package/dist/esm/components/QueryEditor/Space.js +2 -2
- package/dist/esm/components/QueryEditor/Space.js.map +1 -1
- package/dist/esm/components/QueryEditor/TableSelector.js +0 -1
- package/dist/esm/components/QueryEditor/TableSelector.js.map +1 -1
- package/dist/esm/components/QueryEditor/defaults.js +7 -7
- package/dist/esm/components/QueryEditor/defaults.js.map +1 -1
- package/dist/esm/components/QueryEditor/expressions.js.map +1 -1
- package/dist/esm/components/QueryEditor/query-editor-raw/QueryEditorRaw.js +10 -2
- package/dist/esm/components/QueryEditor/query-editor-raw/QueryEditorRaw.js.map +1 -1
- package/dist/esm/components/QueryEditor/query-editor-raw/QueryToolbox.js +7 -2
- package/dist/esm/components/QueryEditor/query-editor-raw/QueryToolbox.js.map +1 -1
- package/dist/esm/components/QueryEditor/query-editor-raw/QueryValidator.js +4 -4
- package/dist/esm/components/QueryEditor/query-editor-raw/QueryValidator.js.map +1 -1
- package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js +14 -4
- package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js.map +1 -1
- package/dist/esm/components/QueryEditor/types.js +0 -1
- package/dist/esm/components/QueryEditor/types.js.map +1 -1
- package/dist/esm/components/QueryEditor/utils/formatSQL.js +15 -4
- package/dist/esm/components/QueryEditor/utils/formatSQL.js.map +1 -1
- package/dist/esm/components/QueryEditor/utils/sql.utils.js +8 -8
- package/dist/esm/components/QueryEditor/utils/sql.utils.js.map +1 -1
- package/dist/esm/components/QueryEditor/utils/useSqlChange.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/AwesomeQueryBuilder.js +26 -27
- package/dist/esm/components/QueryEditor/visual-query-builder/AwesomeQueryBuilder.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/EditorField.js +3 -3
- package/dist/esm/components/QueryEditor/visual-query-builder/EditorField.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/EditorRow.js +2 -2
- package/dist/esm/components/QueryEditor/visual-query-builder/EditorRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/EditorRows.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/GroupByRow.js +2 -2
- package/dist/esm/components/QueryEditor/visual-query-builder/GroupByRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/OrderByRow.js +4 -4
- package/dist/esm/components/QueryEditor/visual-query-builder/OrderByRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js +4 -4
- package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLGroupByRow.js +0 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLGroupByRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLOrderByRow.js +2 -3
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLOrderByRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLSelectRow.js +0 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLSelectRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLWhereRow.js +0 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SQLWhereRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/SelectRow.js +9 -9
- package/dist/esm/components/QueryEditor/visual-query-builder/SelectRow.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/VisualEditor.js +10 -2
- package/dist/esm/components/QueryEditor/visual-query-builder/VisualEditor.js.map +1 -1
- package/dist/esm/components/QueryEditor/visual-query-builder/WhereRow.js.map +1 -1
- package/dist/esm/components/QueryEditorRow/QueryEditorRow.js.map +1 -1
- package/dist/esm/components/SQLEditor/components/SQLEditor.js +13 -13
- package/dist/esm/components/SQLEditor/components/SQLEditor.js.map +1 -1
- package/dist/esm/components/SQLEditor/hooks/useLatestCallback.js +1 -1
- package/dist/esm/components/SQLEditor/hooks/useLatestCallback.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/Monaco.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/TextModel.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/multiLineFullQuery.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/multiLineFullQueryWithAggregation.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/multiLineMultipleColumns.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/singleLineEmptyQuery.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/singleLineFullQuery.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/singleLineFullQueryWithAggregation.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/singleLineMultipleColumns.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/singleLineTwoQueries.js.map +1 -1
- package/dist/esm/components/SQLEditor/mocks/queries/singleLineTwoQueriesWithAggregation.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/definition.js +0 -6
- package/dist/esm/components/SQLEditor/standardSql/definition.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/getStandardSuggestions.js +2 -2
- package/dist/esm/components/SQLEditor/standardSql/getStandardSuggestions.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/getStatementPosition.js +5 -4
- package/dist/esm/components/SQLEditor/standardSql/getStatementPosition.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/language.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/macros.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/standardSQLCompletionItemProvider.js +2 -2
- package/dist/esm/components/SQLEditor/standardSql/standardSQLCompletionItemProvider.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/standardSuggestionsRegistry.js +1 -1
- package/dist/esm/components/SQLEditor/standardSql/standardSuggestionsRegistry.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/statementPositionResolversRegistry.js +27 -26
- package/dist/esm/components/SQLEditor/standardSql/statementPositionResolversRegistry.js.map +1 -1
- package/dist/esm/components/SQLEditor/standardSql/suggestionsKindRegistry.js +1 -1
- package/dist/esm/components/SQLEditor/standardSql/suggestionsKindRegistry.js.map +1 -1
- package/dist/esm/components/SQLEditor/test-utils/index.js.map +1 -1
- package/dist/esm/components/SQLEditor/test-utils/statementPosition.js.map +1 -1
- package/dist/esm/components/SQLEditor/types.js +1 -17
- package/dist/esm/components/SQLEditor/types.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/LinkedToken.js +8 -8
- package/dist/esm/components/SQLEditor/utils/LinkedToken.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/commands.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/debugger.js +1 -1
- package/dist/esm/components/SQLEditor/utils/debugger.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/getSuggestionKind.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/linkedTokenBuilder.js +3 -3
- package/dist/esm/components/SQLEditor/utils/linkedTokenBuilder.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/toCompletionItem.js +1 -1
- package/dist/esm/components/SQLEditor/utils/toCompletionItem.js.map +1 -1
- package/dist/esm/components/SQLEditor/utils/tokenType.js +18 -0
- package/dist/esm/components/SQLEditor/utils/tokenType.js.map +1 -0
- package/dist/esm/components/SQLEditor/utils/tokenUtils.js +10 -10
- package/dist/esm/components/SQLEditor/utils/tokenUtils.js.map +1 -1
- package/dist/esm/components/Segment/Segment.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/QueryModellerBase.js +2 -2
- package/dist/esm/components/VisualQueryBuilder/QueryModellerBase.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/LabelFilterItem.js +11 -11
- package/dist/esm/components/VisualQueryBuilder/components/LabelFilterItem.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/LabelFilters.js +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/LabelFilters.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationEditor.js +4 -4
- package/dist/esm/components/VisualQueryBuilder/components/OperationEditor.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationEditorBody.js +3 -3
- package/dist/esm/components/VisualQueryBuilder/components/OperationEditorBody.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationExplainedBox.js +3 -3
- package/dist/esm/components/VisualQueryBuilder/components/OperationExplainedBox.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationHeader.js +2 -2
- package/dist/esm/components/VisualQueryBuilder/components/OperationHeader.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationInfoButton.js +2 -2
- package/dist/esm/components/VisualQueryBuilder/components/OperationInfoButton.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationList.js +4 -4
- package/dist/esm/components/VisualQueryBuilder/components/OperationList.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationListExplained.js +2 -2
- package/dist/esm/components/VisualQueryBuilder/components/OperationListExplained.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationParamEditor.js +6 -6
- package/dist/esm/components/VisualQueryBuilder/components/OperationParamEditor.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/OperationsEditorRow.js +3 -3
- package/dist/esm/components/VisualQueryBuilder/components/OperationsEditorRow.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/QueryBuilderHints.js +8 -8
- package/dist/esm/components/VisualQueryBuilder/components/QueryBuilderHints.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/QueryEditorModeToggle.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/QueryHeaderSwitch.js +3 -3
- package/dist/esm/components/VisualQueryBuilder/components/QueryHeaderSwitch.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/QueryOptionGroup.js +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/QueryOptionGroup.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/components/RawQuery.js +2 -2
- package/dist/esm/components/VisualQueryBuilder/components/RawQuery.js.map +1 -1
- package/dist/esm/components/VisualQueryBuilder/types.js.map +1 -1
- package/dist/esm/datasource/SqlDatasource.js +14 -14
- package/dist/esm/datasource/SqlDatasource.js.map +1 -1
- package/dist/esm/datasource/constants.js.map +1 -1
- package/dist/esm/datasource/schema/config.js +235 -0
- package/dist/esm/datasource/schema/config.js.map +1 -0
- package/dist/esm/datasource/schema/datasource.js +228 -0
- package/dist/esm/datasource/schema/datasource.js.map +1 -0
- package/dist/esm/datasource/schema/llmHints.js +54 -0
- package/dist/esm/datasource/schema/llmHints.js.map +1 -0
- package/dist/esm/datasource/schema/provisioningYaml.js +358 -0
- package/dist/esm/datasource/schema/provisioningYaml.js.map +1 -0
- package/dist/esm/hooks/useDebounce.js.map +1 -1
- package/dist/esm/index.d.ts +553 -39
- package/dist/esm/index.js +7 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/test/mocks/DataQuery.js.map +1 -1
- package/dist/esm/test/mocks/Datasource.js +1 -1
- package/dist/esm/test/mocks/Datasource.js.map +1 -1
- package/dist/esm/test/mocks/Plugin.js +1 -1
- package/dist/esm/test/mocks/Plugin.js.map +1 -1
- package/dist/esm/test/mocks/QueryEditorProps.js.map +1 -1
- package/dist/esm/test/mocks/utils.js +2 -2
- package/dist/esm/test/mocks/utils.js.map +1 -1
- package/dist/esm/test-utils.d.ts +1 -1
- package/package.json +23 -20
package/dist/cjs/index.cjs
CHANGED
|
@@ -11,23 +11,25 @@ var e2eSelectors = require('@grafana/e2e-selectors');
|
|
|
11
11
|
var runtime = require('@grafana/runtime');
|
|
12
12
|
var reactUse = require('react-use');
|
|
13
13
|
var ui$1 = require('@react-awesome-query-builder/ui');
|
|
14
|
-
var lodash = require('lodash');
|
|
15
14
|
var uuid = require('uuid');
|
|
15
|
+
var lodash = require('lodash');
|
|
16
16
|
var AutoSizer = require('react-virtualized-auto-sizer');
|
|
17
|
-
var sqlFormatter = require('sql-formatter
|
|
17
|
+
var sqlFormatter = require('sql-formatter');
|
|
18
18
|
var rxjs = require('rxjs');
|
|
19
19
|
var operators$1 = require('rxjs/operators');
|
|
20
|
+
var reactHookForm = require('react-hook-form');
|
|
20
21
|
var dnd = require('@hello-pangea/dnd');
|
|
21
22
|
var reactPopperTooltip = require('react-popper-tooltip');
|
|
22
23
|
var Prism = require('prismjs');
|
|
24
|
+
var yaml = require('js-yaml');
|
|
23
25
|
|
|
24
26
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
25
27
|
|
|
26
28
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
27
29
|
var Calendar__default = /*#__PURE__*/_interopDefaultCompat(Calendar);
|
|
28
30
|
var AutoSizer__default = /*#__PURE__*/_interopDefaultCompat(AutoSizer);
|
|
29
|
-
var sqlFormatter__default = /*#__PURE__*/_interopDefaultCompat(sqlFormatter);
|
|
30
31
|
var Prism__default = /*#__PURE__*/_interopDefaultCompat(Prism);
|
|
32
|
+
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
31
33
|
|
|
32
34
|
const QueryEditorRow = (props) => {
|
|
33
35
|
var _a, _b;
|
|
@@ -76,7 +78,7 @@ function Segment(props) {
|
|
|
76
78
|
);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
const getStyles$
|
|
81
|
+
const getStyles$v = (theme) => {
|
|
80
82
|
const containerBorder = theme.isDark ? theme.v1.palette.dark9 : theme.v1.palette.gray5;
|
|
81
83
|
return {
|
|
82
84
|
container: css.css`
|
|
@@ -226,7 +228,7 @@ const getBodyStyles = (theme) => {
|
|
|
226
228
|
|
|
227
229
|
const DatePicker = React.memo((props) => {
|
|
228
230
|
const theme = ui.useTheme2();
|
|
229
|
-
const styles = getStyles$
|
|
231
|
+
const styles = getStyles$v(theme);
|
|
230
232
|
const { isOpen, onClose } = props;
|
|
231
233
|
if (!isOpen) {
|
|
232
234
|
return null;
|
|
@@ -256,7 +258,7 @@ const Body = React.memo(({ value, onChange }) => {
|
|
|
256
258
|
});
|
|
257
259
|
Body.displayName = "Body";
|
|
258
260
|
|
|
259
|
-
function getStyles$
|
|
261
|
+
function getStyles$u() {
|
|
260
262
|
return {
|
|
261
263
|
input: css.css({
|
|
262
264
|
/* hides the native Calendar picker icon given when using type=date */
|
|
@@ -272,7 +274,7 @@ const formatDate = (date) => date.toISOString().split("T")[0];
|
|
|
272
274
|
const DatePickerWithInput = (props) => {
|
|
273
275
|
const { value, onChange, className, ...rest } = props;
|
|
274
276
|
const [open, setOpen] = React.useState(false);
|
|
275
|
-
const styles = getStyles$
|
|
277
|
+
const styles = getStyles$u();
|
|
276
278
|
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
277
279
|
ui.Input,
|
|
278
280
|
{
|
|
@@ -351,7 +353,7 @@ class DataSourcePicker extends React.PureComponent {
|
|
|
351
353
|
const dsSettings = this.dataSourceSrv.getInstanceSettings(item.value);
|
|
352
354
|
if (dsSettings) {
|
|
353
355
|
this.props.onChange(dsSettings);
|
|
354
|
-
this.setState({ error:
|
|
356
|
+
this.setState({ error: void 0 });
|
|
355
357
|
}
|
|
356
358
|
});
|
|
357
359
|
}
|
|
@@ -434,7 +436,7 @@ __publicField$3(DataSourcePicker, "defaultProps", {
|
|
|
434
436
|
});
|
|
435
437
|
|
|
436
438
|
const { FormField, Switch } = ui.LegacyForms;
|
|
437
|
-
const getStyles$
|
|
439
|
+
const getStyles$t = ui.stylesFactory(() => ({
|
|
438
440
|
firstRow: css.css`
|
|
439
441
|
display: flex;
|
|
440
442
|
`,
|
|
@@ -451,7 +453,7 @@ const getStyles$p = ui.stylesFactory(() => ({
|
|
|
451
453
|
}));
|
|
452
454
|
const DataLink = (props) => {
|
|
453
455
|
const { value, onChange, onDelete, suggestions, className } = props;
|
|
454
|
-
const styles = getStyles$
|
|
456
|
+
const styles = getStyles$t();
|
|
455
457
|
const [showInternalLink, setShowInternalLink] = useInternalLink(value.datasourceUid);
|
|
456
458
|
const handleChange = (field) => (event) => {
|
|
457
459
|
onChange({
|
|
@@ -535,7 +537,7 @@ const DataLink = (props) => {
|
|
|
535
537
|
if (showInternalLink) {
|
|
536
538
|
onChange({
|
|
537
539
|
...value,
|
|
538
|
-
datasourceUid:
|
|
540
|
+
datasourceUid: void 0
|
|
539
541
|
});
|
|
540
542
|
}
|
|
541
543
|
setShowInternalLink(!showInternalLink);
|
|
@@ -568,7 +570,7 @@ function useInternalLink(datasourceUid) {
|
|
|
568
570
|
return [showInternalLink, setShowInternalLink];
|
|
569
571
|
}
|
|
570
572
|
|
|
571
|
-
const getStyles$
|
|
573
|
+
const getStyles$s = (theme) => ({
|
|
572
574
|
infoText: css.css`
|
|
573
575
|
padding-bottom: ${theme.v1.spacing.md};
|
|
574
576
|
color: ${theme.v1.colors.textWeak};
|
|
@@ -580,7 +582,7 @@ const getStyles$o = (theme) => ({
|
|
|
580
582
|
const DataLinks = (props) => {
|
|
581
583
|
const { value, onChange } = props;
|
|
582
584
|
const theme = ui.useTheme2();
|
|
583
|
-
const styles = getStyles$
|
|
585
|
+
const styles = getStyles$s(theme);
|
|
584
586
|
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement("h3", { className: "page-heading" }, "Data links"), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.infoText }, "Add links to existing fields. Links will be shown in log row details next to the field value."), /* @__PURE__ */ React__default.default.createElement("div", { className: "gf-form-group" }, value && value.map((field, index) => {
|
|
585
587
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
586
588
|
DataLink,
|
|
@@ -641,110 +643,21 @@ var QueryEditorExpressionType = /* @__PURE__ */ ((QueryEditorExpressionType2) =>
|
|
|
641
643
|
return QueryEditorExpressionType2;
|
|
642
644
|
})(QueryEditorExpressionType || {});
|
|
643
645
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
rawQuery += `FROM ${table} `;
|
|
660
|
-
}
|
|
661
|
-
if (sql.whereString) {
|
|
662
|
-
rawQuery += `WHERE ${sql.whereString} `;
|
|
663
|
-
}
|
|
664
|
-
if ((_b = (_a = sql.groupBy) == null ? undefined : _a[0]) == null ? undefined : _b.property.name) {
|
|
665
|
-
const groupBy = sql.groupBy.map((g) => g.property.name).filter((g) => !lodash.isEmpty(g));
|
|
666
|
-
rawQuery += `GROUP BY ${groupBy.join(", ")} `;
|
|
667
|
-
}
|
|
668
|
-
if ((_c = sql.orderBy) == null ? undefined : _c.property.name) {
|
|
669
|
-
rawQuery += `ORDER BY ${sql.orderBy.property.name} `;
|
|
670
|
-
}
|
|
671
|
-
if (((_d = sql.orderBy) == null ? undefined : _d.property.name) && sql.orderByDirection) {
|
|
672
|
-
rawQuery += `${sql.orderByDirection} `;
|
|
673
|
-
}
|
|
674
|
-
if (sql.limit !== undefined && sql.limit >= 0) {
|
|
675
|
-
rawQuery += `LIMIT ${sql.limit} `;
|
|
676
|
-
}
|
|
677
|
-
return rawQuery;
|
|
678
|
-
}
|
|
679
|
-
function createSelectClause(sqlColumns) {
|
|
680
|
-
const columns = sqlColumns.map((c) => {
|
|
681
|
-
var _a, _b;
|
|
682
|
-
let rawColumn = "";
|
|
683
|
-
if (c.name) {
|
|
684
|
-
rawColumn += `${c.name}(${(_a = c.parameters) == null ? undefined : _a.map((p) => `${p.name}`)})`;
|
|
685
|
-
} else {
|
|
686
|
-
rawColumn += `${(_b = c.parameters) == null ? undefined : _b.map((p) => `${p.name}`)}`;
|
|
687
|
-
}
|
|
688
|
-
return rawColumn;
|
|
689
|
-
});
|
|
690
|
-
return `SELECT ${columns.join(", ")} `;
|
|
691
|
-
}
|
|
692
|
-
function haveColumns(columns) {
|
|
693
|
-
if (!columns) {
|
|
694
|
-
return false;
|
|
695
|
-
}
|
|
696
|
-
const haveColumn = columns.some((c) => {
|
|
697
|
-
var _a, _b;
|
|
698
|
-
return ((_a = c.parameters) == null ? undefined : _a.length) || ((_b = c.parameters) == null ? undefined : _b.some((p) => p.name));
|
|
699
|
-
});
|
|
700
|
-
const haveFunction = columns.some((c) => c.name);
|
|
701
|
-
return haveColumn || haveFunction;
|
|
702
|
-
}
|
|
703
|
-
function setGroupByField(field) {
|
|
704
|
-
return {
|
|
705
|
-
type: QueryEditorExpressionType.GroupBy,
|
|
706
|
-
property: {
|
|
707
|
-
type: QueryEditorPropertyType.String,
|
|
708
|
-
name: field
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
function setPropertyField(field) {
|
|
713
|
-
return {
|
|
714
|
-
type: QueryEditorExpressionType.Property,
|
|
715
|
-
property: {
|
|
716
|
-
type: QueryEditorPropertyType.String,
|
|
717
|
-
name: field
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
function createFunctionField(functionName) {
|
|
722
|
-
return {
|
|
723
|
-
type: QueryEditorExpressionType.Function,
|
|
724
|
-
name: functionName,
|
|
725
|
-
parameters: []
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
function applyQueryDefaults(q) {
|
|
730
|
-
let editorMode = (q == null ? undefined : q.editorMode) || EditorMode.Builder;
|
|
731
|
-
if ((q == null ? undefined : q.editorMode) === undefined && (q == null ? undefined : q.rawSql) !== undefined) {
|
|
732
|
-
editorMode = EditorMode.Code;
|
|
733
|
-
}
|
|
734
|
-
const result = {
|
|
735
|
-
...q,
|
|
736
|
-
refId: (q == null ? undefined : q.refId) || "A",
|
|
737
|
-
format: (q == null ? undefined : q.format) !== undefined ? q.format : QueryFormat.Table,
|
|
738
|
-
rawSql: (q == null ? undefined : q.rawSql) || "",
|
|
739
|
-
editorMode,
|
|
740
|
-
sql: (q == null ? undefined : q.sql) || {
|
|
741
|
-
columns: [createFunctionField()],
|
|
742
|
-
groupBy: [setGroupByField()],
|
|
743
|
-
limit: 50
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
return result;
|
|
747
|
-
}
|
|
646
|
+
var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
647
|
+
TokenType2["Parenthesis"] = "delimiter.parenthesis.sql";
|
|
648
|
+
TokenType2["Whitespace"] = "white.sql";
|
|
649
|
+
TokenType2["Keyword"] = "keyword.sql";
|
|
650
|
+
TokenType2["Delimiter"] = "delimiter.sql";
|
|
651
|
+
TokenType2["Operator"] = "operator.sql";
|
|
652
|
+
TokenType2["Identifier"] = "identifier.sql";
|
|
653
|
+
TokenType2["IdentifierQuote"] = "identifier.quote.sql";
|
|
654
|
+
TokenType2["Type"] = "type.sql";
|
|
655
|
+
TokenType2["Function"] = "predefined.sql";
|
|
656
|
+
TokenType2["Number"] = "number.sql";
|
|
657
|
+
TokenType2["String"] = "string.sql";
|
|
658
|
+
TokenType2["Variable"] = "variable.sql";
|
|
659
|
+
return TokenType2;
|
|
660
|
+
})(TokenType || {});
|
|
748
661
|
|
|
749
662
|
class LinkedToken {
|
|
750
663
|
constructor(type, value, range, previous, next) {
|
|
@@ -789,7 +702,7 @@ class LinkedToken {
|
|
|
789
702
|
}
|
|
790
703
|
is(type, value) {
|
|
791
704
|
const isType = this.type === type;
|
|
792
|
-
return value !==
|
|
705
|
+
return value !== void 0 ? isType && compareTokenWithValue(type, this, value) : isType;
|
|
793
706
|
}
|
|
794
707
|
getPreviousNonWhiteSpaceToken() {
|
|
795
708
|
let curr = this.previous;
|
|
@@ -805,7 +718,7 @@ class LinkedToken {
|
|
|
805
718
|
let curr = this.previous;
|
|
806
719
|
while (curr != null) {
|
|
807
720
|
const isType = curr.type === type;
|
|
808
|
-
if (value !==
|
|
721
|
+
if (value !== void 0 ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
809
722
|
return curr;
|
|
810
723
|
}
|
|
811
724
|
curr = curr.previous;
|
|
@@ -816,12 +729,12 @@ class LinkedToken {
|
|
|
816
729
|
let tokens = [];
|
|
817
730
|
let curr = this.previous;
|
|
818
731
|
while (curr != null) {
|
|
819
|
-
if (ignoreTypes.some((t) => t === (curr == null ?
|
|
732
|
+
if (ignoreTypes.some((t) => t === (curr == null ? void 0 : curr.type))) {
|
|
820
733
|
curr = curr.previous;
|
|
821
734
|
continue;
|
|
822
735
|
}
|
|
823
736
|
const isType = curr.type === type;
|
|
824
|
-
if (value !==
|
|
737
|
+
if (value !== void 0 ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
825
738
|
return tokens;
|
|
826
739
|
}
|
|
827
740
|
if (!curr.isWhiteSpace()) {
|
|
@@ -835,12 +748,12 @@ class LinkedToken {
|
|
|
835
748
|
let tokens = [];
|
|
836
749
|
let curr = this.next;
|
|
837
750
|
while (curr != null) {
|
|
838
|
-
if (ignoreTypes.some((t) => t === (curr == null ?
|
|
751
|
+
if (ignoreTypes.some((t) => t === (curr == null ? void 0 : curr.type))) {
|
|
839
752
|
curr = curr.next;
|
|
840
753
|
continue;
|
|
841
754
|
}
|
|
842
755
|
const isType = curr.type === type;
|
|
843
|
-
if (value !==
|
|
756
|
+
if (value !== void 0 ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
844
757
|
return tokens;
|
|
845
758
|
}
|
|
846
759
|
if (!curr.isWhiteSpace()) {
|
|
@@ -874,7 +787,7 @@ class LinkedToken {
|
|
|
874
787
|
let curr = this.next;
|
|
875
788
|
while (curr != null) {
|
|
876
789
|
const isType = curr.type === type;
|
|
877
|
-
if (value !==
|
|
790
|
+
if (value !== void 0 ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
878
791
|
return curr;
|
|
879
792
|
}
|
|
880
793
|
curr = curr.next;
|
|
@@ -899,21 +812,6 @@ var MacroType = /* @__PURE__ */ ((MacroType2) => {
|
|
|
899
812
|
MacroType2[MacroType2["Table"] = 4] = "Table";
|
|
900
813
|
return MacroType2;
|
|
901
814
|
})(MacroType || {});
|
|
902
|
-
var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
903
|
-
TokenType2["Parenthesis"] = "delimiter.parenthesis.sql";
|
|
904
|
-
TokenType2["Whitespace"] = "white.sql";
|
|
905
|
-
TokenType2["Keyword"] = "keyword.sql";
|
|
906
|
-
TokenType2["Delimiter"] = "delimiter.sql";
|
|
907
|
-
TokenType2["Operator"] = "operator.sql";
|
|
908
|
-
TokenType2["Identifier"] = "identifier.sql";
|
|
909
|
-
TokenType2["IdentifierQuote"] = "identifier.quote.sql";
|
|
910
|
-
TokenType2["Type"] = "type.sql";
|
|
911
|
-
TokenType2["Function"] = "predefined.sql";
|
|
912
|
-
TokenType2["Number"] = "number.sql";
|
|
913
|
-
TokenType2["String"] = "string.sql";
|
|
914
|
-
TokenType2["Variable"] = "variable.sql";
|
|
915
|
-
return TokenType2;
|
|
916
|
-
})(TokenType || {});
|
|
917
815
|
var StatementPosition = /* @__PURE__ */ ((StatementPosition2) => {
|
|
918
816
|
StatementPosition2["Unknown"] = "unknown";
|
|
919
817
|
StatementPosition2["SelectKeyword"] = "selectKeyword";
|
|
@@ -1023,9 +921,9 @@ var SQLEditorMode = /* @__PURE__ */ ((SQLEditorMode2) => {
|
|
|
1023
921
|
|
|
1024
922
|
function getStatementPosition(currentToken, statementPositionResolversRegistry) {
|
|
1025
923
|
var _a;
|
|
1026
|
-
const previousNonWhiteSpace = currentToken == null ?
|
|
1027
|
-
const previousKeyword = currentToken == null ?
|
|
1028
|
-
const previousIsSlash = (_a = currentToken == null ?
|
|
924
|
+
const previousNonWhiteSpace = currentToken == null ? void 0 : currentToken.getPreviousNonWhiteSpaceToken();
|
|
925
|
+
const previousKeyword = currentToken == null ? void 0 : currentToken.getPreviousKeyword();
|
|
926
|
+
const previousIsSlash = (_a = currentToken == null ? void 0 : currentToken.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _a.is(TokenType.Operator, "/");
|
|
1029
927
|
const resolvers = statementPositionResolversRegistry.list();
|
|
1030
928
|
const positions = [];
|
|
1031
929
|
for (const resolver of resolvers) {
|
|
@@ -1053,8 +951,8 @@ const toCompletionItem = (value, range, rest = {}) => {
|
|
|
1053
951
|
|
|
1054
952
|
const getStandardSuggestions = async (monaco, currentToken, suggestionKinds, positionContext, suggestionsRegistry) => {
|
|
1055
953
|
let suggestions = [];
|
|
1056
|
-
const invalidRangeToken = (currentToken == null ?
|
|
1057
|
-
const range = invalidRangeToken || !(currentToken == null ?
|
|
954
|
+
const invalidRangeToken = (currentToken == null ? void 0 : currentToken.isWhiteSpace()) || (currentToken == null ? void 0 : currentToken.isParenthesis()) || (currentToken == null ? void 0 : currentToken.isIdentifier()) && currentToken.value.endsWith(".");
|
|
955
|
+
const range = invalidRangeToken || !(currentToken == null ? void 0 : currentToken.range) ? monaco.Range.fromPositions(positionContext.position) : currentToken == null ? void 0 : currentToken.range;
|
|
1058
956
|
for (const suggestion of [...new Set(suggestionKinds)]) {
|
|
1059
957
|
const registeredSuggestions = suggestionsRegistry.getIfExists(suggestion);
|
|
1060
958
|
if (registeredSuggestions) {
|
|
@@ -1235,7 +1133,7 @@ function linkedTokenBuilder(monaco, model, position, languageId = "sql") {
|
|
|
1235
1133
|
offset: 0,
|
|
1236
1134
|
type: TokenType.Whitespace,
|
|
1237
1135
|
language: languageId,
|
|
1238
|
-
_tokenBrand:
|
|
1136
|
+
_tokenBrand: void 0
|
|
1239
1137
|
};
|
|
1240
1138
|
tokens.push(token);
|
|
1241
1139
|
}
|
|
@@ -2159,31 +2057,31 @@ var language$1 = /*#__PURE__*/Object.freeze({
|
|
|
2159
2057
|
|
|
2160
2058
|
const getSelectToken = (currentToken) => {
|
|
2161
2059
|
var _a;
|
|
2162
|
-
return (_a = currentToken == null ?
|
|
2060
|
+
return (_a = currentToken == null ? void 0 : currentToken.getPreviousOfType(TokenType.Keyword, SELECT)) != null ? _a : null;
|
|
2163
2061
|
};
|
|
2164
2062
|
const getFromKeywordToken = (currentToken) => {
|
|
2165
2063
|
const selectToken = getSelectToken(currentToken);
|
|
2166
|
-
return selectToken == null ?
|
|
2064
|
+
return selectToken == null ? void 0 : selectToken.getNextOfType(TokenType.Keyword, FROM);
|
|
2167
2065
|
};
|
|
2168
2066
|
const getTableToken = (currentToken) => {
|
|
2169
2067
|
var _a;
|
|
2170
2068
|
const fromToken = getFromKeywordToken(currentToken);
|
|
2171
|
-
const nextNonWhiteSpace = fromToken == null ?
|
|
2172
|
-
if (nextNonWhiteSpace == null ?
|
|
2069
|
+
const nextNonWhiteSpace = fromToken == null ? void 0 : fromToken.getNextNonWhiteSpaceToken();
|
|
2070
|
+
if (nextNonWhiteSpace == null ? void 0 : nextNonWhiteSpace.isVariable()) {
|
|
2173
2071
|
return null;
|
|
2174
|
-
} else if ((nextNonWhiteSpace == null ?
|
|
2072
|
+
} else if ((nextNonWhiteSpace == null ? void 0 : nextNonWhiteSpace.isKeyword()) && ((_a = nextNonWhiteSpace.next) == null ? void 0 : _a.is(TokenType.Parenthesis, "("))) {
|
|
2175
2073
|
return null;
|
|
2176
2074
|
} else {
|
|
2177
2075
|
return nextNonWhiteSpace;
|
|
2178
2076
|
}
|
|
2179
2077
|
};
|
|
2180
2078
|
const defaultTableNameParser = (token) => {
|
|
2181
|
-
const parts = token == null ?
|
|
2182
|
-
if ((parts == null ?
|
|
2079
|
+
const parts = token == null ? void 0 : token.value.split(".");
|
|
2080
|
+
if ((parts == null ? void 0 : parts.length) === 1) {
|
|
2183
2081
|
return { table: parts[0] };
|
|
2184
|
-
} else if ((parts == null ?
|
|
2082
|
+
} else if ((parts == null ? void 0 : parts.length) === 2) {
|
|
2185
2083
|
return { schema: parts[0], table: parts[1] };
|
|
2186
|
-
} else if ((parts == null ?
|
|
2084
|
+
} else if ((parts == null ? void 0 : parts.length) === 3) {
|
|
2187
2085
|
return { catalog: parts[0], schema: parts[1], table: parts[2] };
|
|
2188
2086
|
}
|
|
2189
2087
|
return null;
|
|
@@ -2558,7 +2456,7 @@ function initStatementPositionResolvers() {
|
|
|
2558
2456
|
id: StatementPosition.SelectKeyword,
|
|
2559
2457
|
name: StatementPosition.SelectKeyword,
|
|
2560
2458
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(
|
|
2561
|
-
currentToken === null || currentToken.isWhiteSpace() && currentToken.previous === null || currentToken.is(TokenType.Keyword, SELECT) || currentToken.is(TokenType.Keyword, SELECT) && currentToken.previous === null || previousIsSlash || currentToken.isIdentifier() && (previousIsSlash || (currentToken == null ?
|
|
2459
|
+
currentToken === null || currentToken.isWhiteSpace() && currentToken.previous === null || currentToken.is(TokenType.Keyword, SELECT) || currentToken.is(TokenType.Keyword, SELECT) && currentToken.previous === null || previousIsSlash || currentToken.isIdentifier() && (previousIsSlash || (currentToken == null ? void 0 : currentToken.previous) === null) || currentToken.isIdentifier() && SELECT.startsWith(currentToken.value.toLowerCase())
|
|
2562
2460
|
)
|
|
2563
2461
|
},
|
|
2564
2462
|
{
|
|
@@ -2571,13 +2469,13 @@ function initStatementPositionResolvers() {
|
|
|
2571
2469
|
{
|
|
2572
2470
|
id: StatementPosition.AfterSelectKeyword,
|
|
2573
2471
|
name: StatementPosition.AfterSelectKeyword,
|
|
2574
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousNonWhiteSpace == null ?
|
|
2472
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value.toLowerCase()) === SELECT)
|
|
2575
2473
|
},
|
|
2576
2474
|
{
|
|
2577
2475
|
id: StatementPosition.AfterSelectArguments,
|
|
2578
2476
|
name: StatementPosition.AfterSelectArguments,
|
|
2579
2477
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2580
|
-
return Boolean((previousKeyword == null ?
|
|
2478
|
+
return Boolean((previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === SELECT && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value) === ",");
|
|
2581
2479
|
}
|
|
2582
2480
|
},
|
|
2583
2481
|
{
|
|
@@ -2585,7 +2483,7 @@ function initStatementPositionResolvers() {
|
|
|
2585
2483
|
name: StatementPosition.AfterSelectFuncFirstArgument,
|
|
2586
2484
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2587
2485
|
return Boolean(
|
|
2588
|
-
((previousKeyword == null ?
|
|
2486
|
+
((previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === SELECT || (previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === AS) && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (currentToken == null ? void 0 : currentToken.is(TokenType.Parenthesis, "()")))
|
|
2589
2487
|
);
|
|
2590
2488
|
}
|
|
2591
2489
|
},
|
|
@@ -2594,7 +2492,7 @@ function initStatementPositionResolvers() {
|
|
|
2594
2492
|
name: StatementPosition.AfterWhereFunctionArgument,
|
|
2595
2493
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2596
2494
|
return Boolean(
|
|
2597
|
-
(previousKeyword == null ?
|
|
2495
|
+
(previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, WHERE)) && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (currentToken == null ? void 0 : currentToken.is(TokenType.Parenthesis, "()")))
|
|
2598
2496
|
);
|
|
2599
2497
|
}
|
|
2600
2498
|
},
|
|
@@ -2604,7 +2502,7 @@ function initStatementPositionResolvers() {
|
|
|
2604
2502
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2605
2503
|
var _a;
|
|
2606
2504
|
return Boolean(
|
|
2607
|
-
(previousKeyword == null ?
|
|
2505
|
+
(previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? void 0 : previousKeyword.getPreviousKeyword()) == null ? void 0 : _a.is(TokenType.Keyword, GROUP)) && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isIdentifier()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isDoubleQuotedString()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, ")")) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, "()")))
|
|
2608
2506
|
);
|
|
2609
2507
|
}
|
|
2610
2508
|
},
|
|
@@ -2612,7 +2510,7 @@ function initStatementPositionResolvers() {
|
|
|
2612
2510
|
id: StatementPosition.SelectAlias,
|
|
2613
2511
|
name: StatementPosition.SelectAlias,
|
|
2614
2512
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2615
|
-
if ((previousNonWhiteSpace == null ?
|
|
2513
|
+
if ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value) === "," && (previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === AS) {
|
|
2616
2514
|
return true;
|
|
2617
2515
|
}
|
|
2618
2516
|
return false;
|
|
@@ -2623,25 +2521,25 @@ function initStatementPositionResolvers() {
|
|
|
2623
2521
|
name: StatementPosition.FromKeyword,
|
|
2624
2522
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2625
2523
|
return Boolean(
|
|
2626
|
-
(previousKeyword == null ?
|
|
2524
|
+
(previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === SELECT && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value) !== "," || ((currentToken == null ? void 0 : currentToken.isKeyword()) || (currentToken == null ? void 0 : currentToken.isIdentifier())) && FROM.toLowerCase().startsWith(currentToken.value.toLowerCase())
|
|
2627
2525
|
);
|
|
2628
2526
|
}
|
|
2629
2527
|
},
|
|
2630
2528
|
{
|
|
2631
2529
|
id: StatementPosition.AfterFromKeyword,
|
|
2632
2530
|
name: StatementPosition.AfterFromKeyword,
|
|
2633
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(!(currentToken == null ?
|
|
2531
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(!(currentToken == null ? void 0 : currentToken.value.includes(".")) && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value.toLowerCase()) === FROM)
|
|
2634
2532
|
},
|
|
2635
2533
|
{
|
|
2636
2534
|
id: StatementPosition.AfterSchema,
|
|
2637
2535
|
name: StatementPosition.AfterSchema,
|
|
2638
2536
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2639
|
-
if ((currentToken == null ?
|
|
2640
|
-
currentToken = currentToken == null ?
|
|
2537
|
+
if ((currentToken == null ? void 0 : currentToken.isWhiteSpace()) && (currentToken == null ? void 0 : currentToken.next)) {
|
|
2538
|
+
currentToken = currentToken == null ? void 0 : currentToken.previous;
|
|
2641
2539
|
previousNonWhiteSpace = currentToken.getPreviousNonWhiteSpaceToken();
|
|
2642
2540
|
}
|
|
2643
2541
|
return Boolean(
|
|
2644
|
-
(currentToken == null ?
|
|
2542
|
+
(currentToken == null ? void 0 : currentToken.isIdentifier()) && (currentToken == null ? void 0 : currentToken.value.endsWith(".")) && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value.toLowerCase()) === FROM
|
|
2645
2543
|
);
|
|
2646
2544
|
}
|
|
2647
2545
|
},
|
|
@@ -2649,7 +2547,7 @@ function initStatementPositionResolvers() {
|
|
|
2649
2547
|
id: StatementPosition.AfterFrom,
|
|
2650
2548
|
name: StatementPosition.AfterFrom,
|
|
2651
2549
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(
|
|
2652
|
-
(previousKeyword == null ?
|
|
2550
|
+
(previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === FROM && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isDoubleQuotedString()) || (previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === FROM && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isIdentifier()) || (previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === FROM && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isVariable())
|
|
2653
2551
|
// cloudwatch specific
|
|
2654
2552
|
// (previousKeyword?.value === SCHEMA && previousNonWhiteSpace?.is(TokenType.Parenthesis, ')'))
|
|
2655
2553
|
)
|
|
@@ -2659,7 +2557,7 @@ function initStatementPositionResolvers() {
|
|
|
2659
2557
|
name: StatementPosition.AfterTable,
|
|
2660
2558
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2661
2559
|
return Boolean(
|
|
2662
|
-
(previousKeyword == null ?
|
|
2560
|
+
(previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === FROM && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isVariable()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value) !== "" && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.value.toLowerCase()) !== FROM)
|
|
2663
2561
|
);
|
|
2664
2562
|
}
|
|
2665
2563
|
},
|
|
@@ -2667,7 +2565,7 @@ function initStatementPositionResolvers() {
|
|
|
2667
2565
|
id: StatementPosition.WhereKeyword,
|
|
2668
2566
|
name: StatementPosition.WhereKeyword,
|
|
2669
2567
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(
|
|
2670
|
-
(previousKeyword == null ?
|
|
2568
|
+
(previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === WHERE && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isKeyword()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Operator, AND)))
|
|
2671
2569
|
)
|
|
2672
2570
|
},
|
|
2673
2571
|
{
|
|
@@ -2676,14 +2574,14 @@ function initStatementPositionResolvers() {
|
|
|
2676
2574
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2677
2575
|
var _a;
|
|
2678
2576
|
return Boolean(
|
|
2679
|
-
(previousKeyword == null ?
|
|
2577
|
+
(previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === WHERE && !((_a = previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _a.isOperator()) && !(currentToken == null ? void 0 : currentToken.is(TokenType.Delimiter, ".")) && !(currentToken == null ? void 0 : currentToken.isParenthesis()) && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isIdentifier()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isDoubleQuotedString()))
|
|
2680
2578
|
);
|
|
2681
2579
|
}
|
|
2682
2580
|
},
|
|
2683
2581
|
{
|
|
2684
2582
|
id: StatementPosition.WhereValue,
|
|
2685
2583
|
name: StatementPosition.WhereValue,
|
|
2686
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ?
|
|
2584
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === WHERE && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isOperator()))
|
|
2687
2585
|
},
|
|
2688
2586
|
{
|
|
2689
2587
|
id: StatementPosition.AfterWhereValue,
|
|
@@ -2691,7 +2589,7 @@ function initStatementPositionResolvers() {
|
|
|
2691
2589
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2692
2590
|
var _a, _b, _c;
|
|
2693
2591
|
return Boolean(
|
|
2694
|
-
(previousKeyword == null ?
|
|
2592
|
+
(previousKeyword == null ? void 0 : previousKeyword.value.toLowerCase()) === WHERE && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Operator, "and")) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Operator, "or")) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isString()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isNumber()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, ")")) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, "()")) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.isTemplateVariable()) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.IdentifierQuote)) && ((_a = previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _a.is(TokenType.Identifier)) && ((_c = (_b = previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _b.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _c.is(TokenType.IdentifierQuote)))
|
|
2695
2593
|
);
|
|
2696
2594
|
}
|
|
2697
2595
|
},
|
|
@@ -2701,7 +2599,7 @@ function initStatementPositionResolvers() {
|
|
|
2701
2599
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2702
2600
|
var _a;
|
|
2703
2601
|
return Boolean(
|
|
2704
|
-
(previousKeyword == null ?
|
|
2602
|
+
(previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? void 0 : previousKeyword.getPreviousKeyword()) == null ? void 0 : _a.is(TokenType.Keyword, GROUP)) && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Keyword, BY)) || (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Delimiter, ",")))
|
|
2705
2603
|
);
|
|
2706
2604
|
}
|
|
2707
2605
|
},
|
|
@@ -2711,7 +2609,7 @@ function initStatementPositionResolvers() {
|
|
|
2711
2609
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2712
2610
|
var _a;
|
|
2713
2611
|
return Boolean(
|
|
2714
|
-
(previousKeyword == null ?
|
|
2612
|
+
(previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? void 0 : previousKeyword.getPreviousKeyword()) == null ? void 0 : _a.is(TokenType.Keyword, GROUP)) && ((previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (currentToken == null ? void 0 : currentToken.is(TokenType.Parenthesis, "()")))
|
|
2715
2613
|
);
|
|
2716
2614
|
}
|
|
2717
2615
|
},
|
|
@@ -2721,7 +2619,7 @@ function initStatementPositionResolvers() {
|
|
|
2721
2619
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2722
2620
|
var _a;
|
|
2723
2621
|
return Boolean(
|
|
2724
|
-
(previousNonWhiteSpace == null ?
|
|
2622
|
+
(previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Keyword, BY)) && ((_a = previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.getPreviousKeyword()) == null ? void 0 : _a.is(TokenType.Keyword, ORDER))
|
|
2725
2623
|
);
|
|
2726
2624
|
}
|
|
2727
2625
|
},
|
|
@@ -2731,20 +2629,20 @@ function initStatementPositionResolvers() {
|
|
|
2731
2629
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2732
2630
|
var _a, _b;
|
|
2733
2631
|
return Boolean(
|
|
2734
|
-
(previousKeyword == null ?
|
|
2632
|
+
(previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? void 0 : previousKeyword.getPreviousKeyword()) == null ? void 0 : _a.is(TokenType.Keyword, ORDER)) && (previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Parenthesis)) && ((_b = previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _b.is(TokenType.Function))
|
|
2735
2633
|
);
|
|
2736
2634
|
}
|
|
2737
2635
|
},
|
|
2738
2636
|
{
|
|
2739
2637
|
id: StatementPosition.AfterOrderByDirection,
|
|
2740
2638
|
name: StatementPosition.AfterOrderByDirection,
|
|
2741
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ?
|
|
2639
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, DESC)) || (previousKeyword == null ? void 0 : previousKeyword.is(TokenType.Keyword, ASC)))
|
|
2742
2640
|
},
|
|
2743
2641
|
{
|
|
2744
2642
|
id: StatementPosition.AfterIsOperator,
|
|
2745
2643
|
name: StatementPosition.AfterIsOperator,
|
|
2746
2644
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2747
|
-
return Boolean(previousNonWhiteSpace == null ?
|
|
2645
|
+
return Boolean(previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Operator, "IS"));
|
|
2748
2646
|
}
|
|
2749
2647
|
},
|
|
2750
2648
|
{
|
|
@@ -2753,7 +2651,7 @@ function initStatementPositionResolvers() {
|
|
|
2753
2651
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2754
2652
|
var _a;
|
|
2755
2653
|
return Boolean(
|
|
2756
|
-
(previousNonWhiteSpace == null ?
|
|
2654
|
+
(previousNonWhiteSpace == null ? void 0 : previousNonWhiteSpace.is(TokenType.Operator, "NOT")) && ((_a = previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? void 0 : _a.is(TokenType.Operator, "IS"))
|
|
2757
2655
|
);
|
|
2758
2656
|
}
|
|
2759
2657
|
}
|
|
@@ -2767,7 +2665,7 @@ let sqlEditorLog = () => {
|
|
|
2767
2665
|
if (ui.attachDebugger && ui.createLogger) {
|
|
2768
2666
|
sqlEditorLogger = ui.createLogger("SQLEditor");
|
|
2769
2667
|
sqlEditorLog = sqlEditorLogger.logger;
|
|
2770
|
-
ui.attachDebugger("sqleditor",
|
|
2668
|
+
ui.attachDebugger("sqleditor", void 0, sqlEditorLogger);
|
|
2771
2669
|
}
|
|
2772
2670
|
|
|
2773
2671
|
const COLUMN = "column", RELATIVE_TIME_STRING = "'5m'";
|
|
@@ -2829,7 +2727,7 @@ function getStandardSQLCompletionProvider(monaco, language) {
|
|
|
2829
2727
|
provider.supportedFunctions = () => language.builtinFunctions.map((f) => ({ id: f, name: f }));
|
|
2830
2728
|
}
|
|
2831
2729
|
const operators = [];
|
|
2832
|
-
if ((_a = language == null ?
|
|
2730
|
+
if ((_a = language == null ? void 0 : language.comparisonOperators) == null ? void 0 : _a.length) {
|
|
2833
2731
|
operators.push(
|
|
2834
2732
|
...language.comparisonOperators.map((f) => ({
|
|
2835
2733
|
id: f.toLocaleLowerCase(),
|
|
@@ -2839,7 +2737,7 @@ function getStandardSQLCompletionProvider(monaco, language) {
|
|
|
2839
2737
|
);
|
|
2840
2738
|
}
|
|
2841
2739
|
language.logicalOperators = (_b = language.logicalOperators) != null ? _b : language.operators;
|
|
2842
|
-
if ((_c = language == null ?
|
|
2740
|
+
if ((_c = language == null ? void 0 : language.logicalOperators) == null ? void 0 : _c.length) {
|
|
2843
2741
|
operators.push(
|
|
2844
2742
|
...language.logicalOperators.map((f) => ({ id: f.toLocaleLowerCase(), operator: f, type: OperatorType.Logical }))
|
|
2845
2743
|
);
|
|
@@ -2865,7 +2763,7 @@ function useLatestCallback(callback) {
|
|
|
2865
2763
|
});
|
|
2866
2764
|
const hasCallback = Boolean(callback);
|
|
2867
2765
|
return React.useMemo(
|
|
2868
|
-
() => hasCallback ? ((...args) => ref.current(...args)) :
|
|
2766
|
+
() => hasCallback ? ((...args) => ref.current(...args)) : void 0,
|
|
2869
2767
|
[hasCallback]
|
|
2870
2768
|
);
|
|
2871
2769
|
}
|
|
@@ -2912,7 +2810,7 @@ const SQLEditor = ({
|
|
|
2912
2810
|
ui.CodeEditor,
|
|
2913
2811
|
{
|
|
2914
2812
|
height: height || "240px",
|
|
2915
|
-
width: width ? `${width - 2}px` :
|
|
2813
|
+
width: width ? `${width - 2}px` : void 0,
|
|
2916
2814
|
language: id,
|
|
2917
2815
|
value: query,
|
|
2918
2816
|
onBlur: onSqlBlur,
|
|
@@ -2943,12 +2841,12 @@ const SQLEditor = ({
|
|
|
2943
2841
|
), children && children({ formatQuery }));
|
|
2944
2842
|
};
|
|
2945
2843
|
const resolveLanguage = (monaco, languageDefinitionProp) => {
|
|
2946
|
-
if ((languageDefinitionProp == null ?
|
|
2947
|
-
sqlEditorLog(`Loading language '${languageDefinitionProp == null ?
|
|
2844
|
+
if ((languageDefinitionProp == null ? void 0 : languageDefinitionProp.id) !== STANDARD_SQL_LANGUAGE && !languageDefinitionProp.loader) {
|
|
2845
|
+
sqlEditorLog(`Loading language '${languageDefinitionProp == null ? void 0 : languageDefinitionProp.id}' from Monaco registry`, false);
|
|
2948
2846
|
const allLangs = monaco.languages.getLanguages();
|
|
2949
|
-
const custom = allLangs.find(({ id }) => id === (languageDefinitionProp == null ?
|
|
2847
|
+
const custom = allLangs.find(({ id }) => id === (languageDefinitionProp == null ? void 0 : languageDefinitionProp.id));
|
|
2950
2848
|
if (!custom) {
|
|
2951
|
-
throw Error(`Unknown Monaco language ${languageDefinitionProp == null ?
|
|
2849
|
+
throw Error(`Unknown Monaco language ${languageDefinitionProp == null ? void 0 : languageDefinitionProp.id}`);
|
|
2952
2850
|
}
|
|
2953
2851
|
return { completionProvider: getStandardSQLCompletionProvider, ...custom, ...languageDefinitionProp };
|
|
2954
2852
|
}
|
|
@@ -2970,7 +2868,7 @@ const registerLanguageAndSuggestions = async (monaco, l, lid) => {
|
|
|
2970
2868
|
monaco.languages.registerDocumentFormattingEditProvider(lid, {
|
|
2971
2869
|
provideDocumentFormattingEdits: (model) => {
|
|
2972
2870
|
var _a;
|
|
2973
|
-
const formatted = (_a = l.formatter) == null ?
|
|
2871
|
+
const formatted = (_a = l.formatter) == null ? void 0 : _a.call(l, model.getValue());
|
|
2974
2872
|
return [
|
|
2975
2873
|
{
|
|
2976
2874
|
range: model.getFullModelRange(),
|
|
@@ -3077,7 +2975,7 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3077
2975
|
}
|
|
3078
2976
|
if (customProvider.customSuggestionKinds) {
|
|
3079
2977
|
for (const kind of customProvider.customSuggestionKinds()) {
|
|
3080
|
-
(_a = kind.applyTo) == null ?
|
|
2978
|
+
(_a = kind.applyTo) == null ? void 0 : _a.forEach((applyTo) => {
|
|
3081
2979
|
const exists = languageRegistries.suggestionKinds.getIfExists(applyTo);
|
|
3082
2980
|
if (exists) {
|
|
3083
2981
|
if (exists.kind.indexOf(kind.id) === -1) {
|
|
@@ -3087,7 +2985,7 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3087
2985
|
});
|
|
3088
2986
|
if (kind.overrideDefault) {
|
|
3089
2987
|
const stbBehavior = instanceSuggestionsRegistry.get(kind.id);
|
|
3090
|
-
if (stbBehavior !==
|
|
2988
|
+
if (stbBehavior !== void 0) {
|
|
3091
2989
|
stbBehavior.suggestions = kind.suggestionsResolver;
|
|
3092
2990
|
continue;
|
|
3093
2991
|
}
|
|
@@ -3129,9 +3027,9 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3129
3027
|
var _a2, _b, _c, _d, _e;
|
|
3130
3028
|
const o = await s(ctx, m);
|
|
3131
3029
|
const tableToken = getTableToken(ctx.currentToken);
|
|
3132
|
-
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ?
|
|
3030
|
+
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ? void 0 : _a2.parseName) != null ? _b : defaultTableNameParser;
|
|
3133
3031
|
const tableIdentifier = tableNameParser(tableToken);
|
|
3134
|
-
const oo = ((_e = await ((_d = (_c = customProvider.tables) == null ?
|
|
3032
|
+
const oo = ((_e = await ((_d = (_c = customProvider.tables) == null ? void 0 : _c.resolve) == null ? void 0 : _d.call(_c, tableIdentifier))) != null ? _e : []).map((x) => {
|
|
3135
3033
|
var _a3;
|
|
3136
3034
|
return {
|
|
3137
3035
|
label: x.name,
|
|
@@ -3154,13 +3052,13 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3154
3052
|
const o = await s(ctx, m);
|
|
3155
3053
|
const tableToken = getTableToken(ctx.currentToken);
|
|
3156
3054
|
let tableIdentifier;
|
|
3157
|
-
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ?
|
|
3055
|
+
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ? void 0 : _a2.parseName) != null ? _b : defaultTableNameParser;
|
|
3158
3056
|
if (tableToken && tableToken.value) {
|
|
3159
3057
|
tableIdentifier = tableNameParser(tableToken);
|
|
3160
3058
|
}
|
|
3161
3059
|
let oo = [];
|
|
3162
3060
|
if (tableIdentifier) {
|
|
3163
|
-
const columns = await ((_c = customProvider.columns) == null ?
|
|
3061
|
+
const columns = await ((_c = customProvider.columns) == null ? void 0 : _c.resolve(tableIdentifier));
|
|
3164
3062
|
oo = columns ? columns.map((x) => {
|
|
3165
3063
|
var _a3;
|
|
3166
3064
|
return {
|
|
@@ -5456,9 +5354,94 @@ const QUERY_FORMAT_OPTIONS = [
|
|
|
5456
5354
|
const backWardToOption = (value) => ({ label: value, value });
|
|
5457
5355
|
const toOption = (_a = data.toOption) != null ? _a : backWardToOption;
|
|
5458
5356
|
|
|
5357
|
+
function getRawSqlFn(db) {
|
|
5358
|
+
return db.toRawSql ? db.toRawSql : (query) => toRawSql(query, Boolean(db.disableDatasets));
|
|
5359
|
+
}
|
|
5360
|
+
function toRawSql({ sql, dataset, catalog, table }, disableDatasets) {
|
|
5361
|
+
var _a, _b, _c, _d;
|
|
5362
|
+
let rawQuery = "";
|
|
5363
|
+
if (!sql || !haveColumns(sql.columns)) {
|
|
5364
|
+
return rawQuery;
|
|
5365
|
+
}
|
|
5366
|
+
rawQuery += createSelectClause(sql.columns);
|
|
5367
|
+
if (catalog && dataset && table) {
|
|
5368
|
+
rawQuery += `FROM ${catalog}.${dataset}.${table} `;
|
|
5369
|
+
} else if (!disableDatasets && dataset && table) {
|
|
5370
|
+
rawQuery += `FROM ${dataset}.${table} `;
|
|
5371
|
+
} else if (table) {
|
|
5372
|
+
rawQuery += `FROM ${table} `;
|
|
5373
|
+
}
|
|
5374
|
+
if (sql.whereString) {
|
|
5375
|
+
rawQuery += `WHERE ${sql.whereString} `;
|
|
5376
|
+
}
|
|
5377
|
+
if ((_b = (_a = sql.groupBy) == null ? void 0 : _a[0]) == null ? void 0 : _b.property.name) {
|
|
5378
|
+
const groupBy = sql.groupBy.map((g) => g.property.name).filter((g) => !lodash.isEmpty(g));
|
|
5379
|
+
rawQuery += `GROUP BY ${groupBy.join(", ")} `;
|
|
5380
|
+
}
|
|
5381
|
+
if ((_c = sql.orderBy) == null ? void 0 : _c.property.name) {
|
|
5382
|
+
rawQuery += `ORDER BY ${sql.orderBy.property.name} `;
|
|
5383
|
+
}
|
|
5384
|
+
if (((_d = sql.orderBy) == null ? void 0 : _d.property.name) && sql.orderByDirection) {
|
|
5385
|
+
rawQuery += `${sql.orderByDirection} `;
|
|
5386
|
+
}
|
|
5387
|
+
if (sql.limit !== void 0 && sql.limit >= 0) {
|
|
5388
|
+
rawQuery += `LIMIT ${sql.limit} `;
|
|
5389
|
+
}
|
|
5390
|
+
return rawQuery;
|
|
5391
|
+
}
|
|
5392
|
+
function createSelectClause(sqlColumns) {
|
|
5393
|
+
const columns = sqlColumns.map((c) => {
|
|
5394
|
+
var _a, _b;
|
|
5395
|
+
let rawColumn = "";
|
|
5396
|
+
if (c.name) {
|
|
5397
|
+
rawColumn += `${c.name}(${(_a = c.parameters) == null ? void 0 : _a.map((p) => `${p.name}`)})`;
|
|
5398
|
+
} else {
|
|
5399
|
+
rawColumn += `${(_b = c.parameters) == null ? void 0 : _b.map((p) => `${p.name}`)}`;
|
|
5400
|
+
}
|
|
5401
|
+
return rawColumn;
|
|
5402
|
+
});
|
|
5403
|
+
return `SELECT ${columns.join(", ")} `;
|
|
5404
|
+
}
|
|
5405
|
+
function haveColumns(columns) {
|
|
5406
|
+
if (!columns) {
|
|
5407
|
+
return false;
|
|
5408
|
+
}
|
|
5409
|
+
const haveColumn = columns.some((c) => {
|
|
5410
|
+
var _a, _b;
|
|
5411
|
+
return ((_a = c.parameters) == null ? void 0 : _a.length) || ((_b = c.parameters) == null ? void 0 : _b.some((p) => p.name));
|
|
5412
|
+
});
|
|
5413
|
+
const haveFunction = columns.some((c) => c.name);
|
|
5414
|
+
return haveColumn || haveFunction;
|
|
5415
|
+
}
|
|
5416
|
+
function setGroupByField(field) {
|
|
5417
|
+
return {
|
|
5418
|
+
type: QueryEditorExpressionType.GroupBy,
|
|
5419
|
+
property: {
|
|
5420
|
+
type: QueryEditorPropertyType.String,
|
|
5421
|
+
name: field
|
|
5422
|
+
}
|
|
5423
|
+
};
|
|
5424
|
+
}
|
|
5425
|
+
function setPropertyField(field) {
|
|
5426
|
+
return {
|
|
5427
|
+
type: QueryEditorExpressionType.Property,
|
|
5428
|
+
property: {
|
|
5429
|
+
type: QueryEditorPropertyType.String,
|
|
5430
|
+
name: field
|
|
5431
|
+
}
|
|
5432
|
+
};
|
|
5433
|
+
}
|
|
5434
|
+
function createFunctionField(functionName) {
|
|
5435
|
+
return {
|
|
5436
|
+
type: QueryEditorExpressionType.Function,
|
|
5437
|
+
name: functionName,
|
|
5438
|
+
parameters: []
|
|
5439
|
+
};
|
|
5440
|
+
}
|
|
5441
|
+
|
|
5459
5442
|
const EditorStack = ({ children, wrap: wrapItems = true, ...props }) => {
|
|
5460
5443
|
var _a, _b;
|
|
5461
|
-
return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { wrap: wrapItems ? "wrap" :
|
|
5444
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { wrap: wrapItems ? "wrap" : void 0, direction: (_a = props.direction) != null ? _a : "row", gap: (_b = props.gap) != null ? _b : 2, ...props }, children);
|
|
5462
5445
|
};
|
|
5463
5446
|
|
|
5464
5447
|
const EditorList = React.forwardRef(function EditorList2({ items, renderItem, onChange }, ref) {
|
|
@@ -5495,7 +5478,7 @@ const getButtonStyles = (theme) => ({
|
|
|
5495
5478
|
});
|
|
5496
5479
|
|
|
5497
5480
|
const InputGroup = ({ children }) => {
|
|
5498
|
-
const styles = ui.useStyles2(getStyles$
|
|
5481
|
+
const styles = ui.useStyles2(getStyles$r);
|
|
5499
5482
|
const modifiedChildren = React.Children.map(children, (child) => {
|
|
5500
5483
|
if (React.isValidElement(child) && child.props.invalid) {
|
|
5501
5484
|
return React.cloneElement(child, { className: css.cx(child.props.className, styles.invalidChild) });
|
|
@@ -5513,7 +5496,7 @@ const borderPriority = [
|
|
|
5513
5496
|
"focused"
|
|
5514
5497
|
// highest priority
|
|
5515
5498
|
];
|
|
5516
|
-
const getStyles$
|
|
5499
|
+
const getStyles$r = () => ({
|
|
5517
5500
|
root: css.css({
|
|
5518
5501
|
display: "flex",
|
|
5519
5502
|
// Style the direct children of the component
|
|
@@ -5556,7 +5539,7 @@ function GroupByRow({ sql, columns, onSqlChange }) {
|
|
|
5556
5539
|
(item) => {
|
|
5557
5540
|
const cleaned = item.map((v) => {
|
|
5558
5541
|
var _a;
|
|
5559
|
-
return setGroupByField((_a = v.property) == null ?
|
|
5542
|
+
return setGroupByField((_a = v.property) == null ? void 0 : _a.name);
|
|
5560
5543
|
});
|
|
5561
5544
|
const newSql = { ...sql, groupBy: cleaned };
|
|
5562
5545
|
onSqlChange(newSql);
|
|
@@ -5580,7 +5563,7 @@ function makeRenderColumn({ options }) {
|
|
|
5580
5563
|
return /* @__PURE__ */ React__default.default.createElement(InputGroup, null, /* @__PURE__ */ React__default.default.createElement(
|
|
5581
5564
|
ui.Select,
|
|
5582
5565
|
{
|
|
5583
|
-
value: ((_a = item.property) == null ?
|
|
5566
|
+
value: ((_a = item.property) == null ? void 0 : _a.name) ? data.toOption(item.property.name) : null,
|
|
5584
5567
|
"aria-label": "Group by",
|
|
5585
5568
|
options,
|
|
5586
5569
|
menuShouldPortal: true,
|
|
@@ -5596,10 +5579,10 @@ const EditorFieldGroup = ({ children }) => {
|
|
|
5596
5579
|
};
|
|
5597
5580
|
|
|
5598
5581
|
const EditorHeader = ({ children }) => {
|
|
5599
|
-
const styles = ui.useStyles2(getStyles$
|
|
5582
|
+
const styles = ui.useStyles2(getStyles$q);
|
|
5600
5583
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, children);
|
|
5601
5584
|
};
|
|
5602
|
-
const getStyles$
|
|
5585
|
+
const getStyles$q = (theme) => ({
|
|
5603
5586
|
root: css.css({
|
|
5604
5587
|
display: "flex",
|
|
5605
5588
|
flexWrap: "wrap",
|
|
@@ -5612,12 +5595,12 @@ const getStyles$m = (theme) => ({
|
|
|
5612
5595
|
const EditorField$1 = (props) => {
|
|
5613
5596
|
var _a;
|
|
5614
5597
|
const { label, optional, tooltip, tooltipInteractive, children, width, ...fieldProps } = props;
|
|
5615
|
-
const styles = ui.useStyles2(getStyles$
|
|
5616
|
-
const childInputId = (fieldProps == null ?
|
|
5598
|
+
const styles = ui.useStyles2(getStyles$p, width);
|
|
5599
|
+
const childInputId = (fieldProps == null ? void 0 : fieldProps.htmlFor) || ((_a = ui.ReactUtils) == null ? void 0 : _a.getChildId(children));
|
|
5617
5600
|
const labelEl = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label, htmlFor: childInputId }, label, optional && /* @__PURE__ */ React__default.default.createElement("span", { className: styles.optional }, " - optional"), tooltip && /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { placement: "top", content: tooltip, theme: "info", interactive: tooltipInteractive }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { tabIndex: 0, name: "info-circle", size: "sm", className: styles.icon }))), /* @__PURE__ */ React__default.default.createElement(ui.Space, { v: 0.5 }));
|
|
5618
5601
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, /* @__PURE__ */ React__default.default.createElement(ui.Field, { className: styles.field, label: labelEl, ...fieldProps }, children));
|
|
5619
5602
|
};
|
|
5620
|
-
const getStyles$
|
|
5603
|
+
const getStyles$p = (theme, width) => {
|
|
5621
5604
|
return {
|
|
5622
5605
|
root: css.css({
|
|
5623
5606
|
minWidth: theme.spacing(width != null ? width : 0)
|
|
@@ -5645,10 +5628,10 @@ const getStyles$l = (theme, width) => {
|
|
|
5645
5628
|
};
|
|
5646
5629
|
|
|
5647
5630
|
const EditorRow$1 = ({ children }) => {
|
|
5648
|
-
const styles = ui.useStyles2(getStyles$
|
|
5631
|
+
const styles = ui.useStyles2(getStyles$o);
|
|
5649
5632
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2 }, children));
|
|
5650
5633
|
};
|
|
5651
|
-
const getStyles$
|
|
5634
|
+
const getStyles$o = (theme) => {
|
|
5652
5635
|
return {
|
|
5653
5636
|
root: css.css({
|
|
5654
5637
|
padding: theme.spacing(1),
|
|
@@ -5663,10 +5646,10 @@ const EditorRows$1 = ({ children }) => {
|
|
|
5663
5646
|
};
|
|
5664
5647
|
|
|
5665
5648
|
const EditorSwitch = (props) => {
|
|
5666
|
-
const styles = getStyles$
|
|
5649
|
+
const styles = getStyles$n();
|
|
5667
5650
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.switch }, /* @__PURE__ */ React__default.default.createElement(ui.Switch, { ...props }));
|
|
5668
5651
|
};
|
|
5669
|
-
const getStyles$
|
|
5652
|
+
const getStyles$n = () => {
|
|
5670
5653
|
return {
|
|
5671
5654
|
switch: css.css({
|
|
5672
5655
|
display: "flex",
|
|
@@ -5688,7 +5671,7 @@ function InlineSelect({ label: labelProp, ...props }) {
|
|
|
5688
5671
|
ValueContainer,
|
|
5689
5672
|
SingleValue: ValueContainer
|
|
5690
5673
|
};
|
|
5691
|
-
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, labelProp && /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label, htmlFor: id }, labelProp, ":", "\xA0"), /* @__PURE__ */ React__default.default.createElement(ui.Select, {
|
|
5674
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, labelProp && /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label, htmlFor: id }, labelProp, ":", "\xA0"), /* @__PURE__ */ React__default.default.createElement(ui.Select, { inputId: id, ...props, components }));
|
|
5692
5675
|
}
|
|
5693
5676
|
const SelectContainer = (props) => {
|
|
5694
5677
|
const { children } = props;
|
|
@@ -5724,10 +5707,10 @@ const getSelectStyles = (theme) => ({
|
|
|
5724
5707
|
});
|
|
5725
5708
|
|
|
5726
5709
|
const Space = ({ v = 0, h = 0, layout = "block" }) => {
|
|
5727
|
-
const styles = ui.useStyles2(getStyles$
|
|
5710
|
+
const styles = ui.useStyles2(getStyles$m, v, h, layout);
|
|
5728
5711
|
return /* @__PURE__ */ React__default.default.createElement("span", { className: css.cx(styles.wrapper) });
|
|
5729
5712
|
};
|
|
5730
|
-
const getStyles$
|
|
5713
|
+
const getStyles$m = (theme, v, h, layout) => ({
|
|
5731
5714
|
wrapper: css.css([
|
|
5732
5715
|
{
|
|
5733
5716
|
paddingRight: theme.spacing(h != null ? h : 0),
|
|
@@ -5742,12 +5725,32 @@ const getStyles$i = (theme, v, h, layout) => ({
|
|
|
5742
5725
|
])
|
|
5743
5726
|
});
|
|
5744
5727
|
|
|
5728
|
+
function applyQueryDefaults(q) {
|
|
5729
|
+
let editorMode = (q == null ? void 0 : q.editorMode) || EditorMode.Builder;
|
|
5730
|
+
if ((q == null ? void 0 : q.editorMode) === void 0 && (q == null ? void 0 : q.rawSql) !== void 0) {
|
|
5731
|
+
editorMode = EditorMode.Code;
|
|
5732
|
+
}
|
|
5733
|
+
const result = {
|
|
5734
|
+
...q,
|
|
5735
|
+
refId: (q == null ? void 0 : q.refId) || "A",
|
|
5736
|
+
format: (q == null ? void 0 : q.format) !== void 0 ? q.format : QueryFormat.Table,
|
|
5737
|
+
rawSql: (q == null ? void 0 : q.rawSql) || "",
|
|
5738
|
+
editorMode,
|
|
5739
|
+
sql: (q == null ? void 0 : q.sql) || {
|
|
5740
|
+
columns: [createFunctionField()],
|
|
5741
|
+
groupBy: [setGroupByField()],
|
|
5742
|
+
limit: 50
|
|
5743
|
+
}
|
|
5744
|
+
};
|
|
5745
|
+
return result;
|
|
5746
|
+
}
|
|
5747
|
+
|
|
5745
5748
|
function ConfirmModal({ isOpen, onCancel, onDiscard, onCopy }) {
|
|
5746
5749
|
const buttonRef = React.useRef(null);
|
|
5747
5750
|
React.useEffect(() => {
|
|
5748
5751
|
var _a;
|
|
5749
5752
|
if (isOpen) {
|
|
5750
|
-
(_a = buttonRef.current) == null ?
|
|
5753
|
+
(_a = buttonRef.current) == null ? void 0 : _a.focus();
|
|
5751
5754
|
}
|
|
5752
5755
|
}, [isOpen]);
|
|
5753
5756
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -5793,7 +5796,7 @@ const DatasetSelector = ({
|
|
|
5793
5796
|
onChange(state.value[0]);
|
|
5794
5797
|
}
|
|
5795
5798
|
} else {
|
|
5796
|
-
if (state.value && state.value.find((v) => v.value === value) ===
|
|
5799
|
+
if (state.value && state.value.find((v) => v.value === value) === void 0) {
|
|
5797
5800
|
if (state.value.length > 0) {
|
|
5798
5801
|
onChange(state.value[0]);
|
|
5799
5802
|
}
|
|
@@ -5844,7 +5847,7 @@ const CatalogSelector = ({ db, inputId, value, onChange }) => {
|
|
|
5844
5847
|
loadCatalogs();
|
|
5845
5848
|
}, [db, loadCatalogs]);
|
|
5846
5849
|
const handleChange = (selectable) => {
|
|
5847
|
-
onChange((selectable == null ?
|
|
5850
|
+
onChange((selectable == null ? void 0 : selectable.value) || null);
|
|
5848
5851
|
};
|
|
5849
5852
|
const selectedValue = catalogs.find((catalog) => catalog.value === value) || null;
|
|
5850
5853
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -5908,7 +5911,7 @@ const RunQueryButton = ({
|
|
|
5908
5911
|
onClick,
|
|
5909
5912
|
dataTestId
|
|
5910
5913
|
}) => {
|
|
5911
|
-
let icon = queryInvalid ? "exclamation-triangle" :
|
|
5914
|
+
let icon = queryInvalid ? "exclamation-triangle" : void 0;
|
|
5912
5915
|
if (queryRunning) {
|
|
5913
5916
|
icon = "fa fa-spinner";
|
|
5914
5917
|
}
|
|
@@ -5971,35 +5974,35 @@ function QueryHeader({
|
|
|
5971
5974
|
[editorMode, onChange, query]
|
|
5972
5975
|
);
|
|
5973
5976
|
const onFormatChange = (e) => {
|
|
5974
|
-
const next = { ...query, format: e.value !==
|
|
5977
|
+
const next = { ...query, format: e.value !== void 0 ? e.value : QueryFormat.Table };
|
|
5975
5978
|
onChange(next);
|
|
5976
5979
|
};
|
|
5977
5980
|
const onDatasetChange = (e) => {
|
|
5978
|
-
const datasetValue = e.value ||
|
|
5981
|
+
const datasetValue = e.value || void 0;
|
|
5979
5982
|
if (datasetValue === query.dataset) {
|
|
5980
5983
|
return;
|
|
5981
5984
|
}
|
|
5982
5985
|
const next = {
|
|
5983
5986
|
...query,
|
|
5984
5987
|
dataset: datasetValue,
|
|
5985
|
-
table:
|
|
5986
|
-
sql:
|
|
5988
|
+
table: void 0,
|
|
5989
|
+
sql: void 0,
|
|
5987
5990
|
rawSql: ""
|
|
5988
5991
|
};
|
|
5989
5992
|
onChange(next);
|
|
5990
5993
|
};
|
|
5991
5994
|
const onCatalogChange = (catalog) => {
|
|
5992
|
-
const catalogValue = catalog ||
|
|
5995
|
+
const catalogValue = catalog || void 0;
|
|
5993
5996
|
if (catalogValue === query.catalog) {
|
|
5994
5997
|
return;
|
|
5995
5998
|
}
|
|
5996
5999
|
const next = {
|
|
5997
6000
|
...query,
|
|
5998
6001
|
catalog: catalogValue,
|
|
5999
|
-
dataset:
|
|
6002
|
+
dataset: void 0,
|
|
6000
6003
|
// Reset dataset (which acts as schema when catalog is present)
|
|
6001
|
-
table:
|
|
6002
|
-
sql:
|
|
6004
|
+
table: void 0,
|
|
6005
|
+
sql: void 0,
|
|
6003
6006
|
rawSql: ""
|
|
6004
6007
|
};
|
|
6005
6008
|
onChange(next);
|
|
@@ -6011,7 +6014,7 @@ function QueryHeader({
|
|
|
6011
6014
|
const next = {
|
|
6012
6015
|
...query,
|
|
6013
6016
|
table: e.value,
|
|
6014
|
-
sql:
|
|
6017
|
+
sql: void 0,
|
|
6015
6018
|
rawSql: ""
|
|
6016
6019
|
};
|
|
6017
6020
|
onChange(next);
|
|
@@ -6094,7 +6097,7 @@ function QueryHeader({
|
|
|
6094
6097
|
{
|
|
6095
6098
|
db,
|
|
6096
6099
|
inputId: `sql-catalog-${htmlId}`,
|
|
6097
|
-
value: query.catalog ===
|
|
6100
|
+
value: query.catalog === void 0 ? null : query.catalog,
|
|
6098
6101
|
onChange: onCatalogChange
|
|
6099
6102
|
}
|
|
6100
6103
|
)), effectiveEnableDatasets && /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -6109,10 +6112,10 @@ function QueryHeader({
|
|
|
6109
6112
|
db,
|
|
6110
6113
|
inputId: catalogsEnabled ? `sql-schema-${htmlId}` : `sql-dataset-${htmlId}`,
|
|
6111
6114
|
"data-testid": catalogsEnabled ? "schema-selector" : "dataset-selector",
|
|
6112
|
-
dataset: catalogsEnabled ?
|
|
6113
|
-
value: query.dataset ===
|
|
6115
|
+
dataset: catalogsEnabled ? void 0 : defaultDataset,
|
|
6116
|
+
value: query.dataset === void 0 ? null : query.dataset,
|
|
6114
6117
|
onChange: onDatasetChange,
|
|
6115
|
-
catalog: catalogsEnabled ? query.catalog :
|
|
6118
|
+
catalog: catalogsEnabled ? query.catalog : void 0
|
|
6116
6119
|
}
|
|
6117
6120
|
)
|
|
6118
6121
|
), /* @__PURE__ */ React__default.default.createElement(EditorField$1, { label: labels.get("table") || "Table", width: 25 }, /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -6120,10 +6123,10 @@ function QueryHeader({
|
|
|
6120
6123
|
{
|
|
6121
6124
|
db,
|
|
6122
6125
|
inputId: `sql-table-${htmlId}`,
|
|
6123
|
-
dataset: query.dataset || (catalogsEnabled ?
|
|
6124
|
-
catalog: catalogsEnabled ? query.catalog :
|
|
6126
|
+
dataset: query.dataset || (catalogsEnabled ? void 0 : defaultDataset),
|
|
6127
|
+
catalog: catalogsEnabled ? query.catalog : void 0,
|
|
6125
6128
|
query,
|
|
6126
|
-
value: query.table ===
|
|
6129
|
+
value: query.table === void 0 ? null : query.table,
|
|
6127
6130
|
onChange: onTableChange,
|
|
6128
6131
|
enableCatalogs: catalogsEnabled,
|
|
6129
6132
|
applyDefault: true
|
|
@@ -6131,13 +6134,32 @@ function QueryHeader({
|
|
|
6131
6134
|
)))));
|
|
6132
6135
|
}
|
|
6133
6136
|
|
|
6134
|
-
function formatSQL(q) {
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
+
function formatSQL(q, language = "sql") {
|
|
6138
|
+
const formatted = sqlFormatter.format(q, {
|
|
6139
|
+
language,
|
|
6140
|
+
paramTypes: {
|
|
6141
|
+
custom: [
|
|
6142
|
+
{
|
|
6143
|
+
regex: "\\$\\s*\\{[^}]*\\}|\\$\\s*__\\w+(?:\\([^)]*\\))?|\\$\\s*\\w+"
|
|
6144
|
+
}
|
|
6145
|
+
]
|
|
6146
|
+
}
|
|
6137
6147
|
});
|
|
6148
|
+
return formatted.replace(
|
|
6149
|
+
/(\$\s*\{[^}]*\})|(\$\s*__\w+(?:\([^)]*\))?)|(\$\s*\w+)/g,
|
|
6150
|
+
(m) => m.replace(/\s/g, "")
|
|
6151
|
+
);
|
|
6138
6152
|
}
|
|
6139
6153
|
|
|
6140
|
-
function QueryEditorRaw({
|
|
6154
|
+
function QueryEditorRaw({
|
|
6155
|
+
children,
|
|
6156
|
+
onChange,
|
|
6157
|
+
query,
|
|
6158
|
+
width,
|
|
6159
|
+
height,
|
|
6160
|
+
completionProvider,
|
|
6161
|
+
language = "sql"
|
|
6162
|
+
}) {
|
|
6141
6163
|
const queryRef = React.useRef(query);
|
|
6142
6164
|
React.useEffect(() => {
|
|
6143
6165
|
queryRef.current = query;
|
|
@@ -6160,7 +6182,7 @@ function QueryEditorRaw({ children, onChange, query, width, height, completionPr
|
|
|
6160
6182
|
height,
|
|
6161
6183
|
query: query.rawSql,
|
|
6162
6184
|
onChange: onRawQueryChange,
|
|
6163
|
-
language: { id: "sql", completionProvider, formatter: formatSQL }
|
|
6185
|
+
language: { id: "sql", completionProvider, formatter: (q) => formatSQL(q, language) }
|
|
6164
6186
|
},
|
|
6165
6187
|
children
|
|
6166
6188
|
);
|
|
@@ -6189,7 +6211,7 @@ function QueryValidator({ db, query, onValidate, range }) {
|
|
|
6189
6211
|
const [state, validateQuery] = reactUse.useAsyncFn(
|
|
6190
6212
|
async (q) => {
|
|
6191
6213
|
var _a2;
|
|
6192
|
-
if (((_a2 = q.rawSql) == null ?
|
|
6214
|
+
if (((_a2 = q.rawSql) == null ? void 0 : _a2.trim()) === "") {
|
|
6193
6215
|
return null;
|
|
6194
6216
|
}
|
|
6195
6217
|
return await db.validateQuery(q, range);
|
|
@@ -6208,17 +6230,17 @@ function QueryValidator({ db, query, onValidate, range }) {
|
|
|
6208
6230
|
[query, validateQuery]
|
|
6209
6231
|
);
|
|
6210
6232
|
React.useEffect(() => {
|
|
6211
|
-
if (validationResult == null ?
|
|
6233
|
+
if (validationResult == null ? void 0 : validationResult.isError) {
|
|
6212
6234
|
onValidate(false);
|
|
6213
6235
|
}
|
|
6214
|
-
if (validationResult == null ?
|
|
6236
|
+
if (validationResult == null ? void 0 : validationResult.isValid) {
|
|
6215
6237
|
onValidate(true);
|
|
6216
6238
|
}
|
|
6217
6239
|
}, [validationResult, onValidate]);
|
|
6218
6240
|
if (!state.value && !state.loading) {
|
|
6219
6241
|
return null;
|
|
6220
6242
|
}
|
|
6221
|
-
const error = ((_a = state.value) == null ?
|
|
6243
|
+
const error = ((_a = state.value) == null ? void 0 : _a.error) ? processErrorMessage(state.value.error) : "";
|
|
6222
6244
|
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, state.loading && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.info }, /* @__PURE__ */ React__default.default.createElement(ui.Spinner, { inline: true, size: 12 }), " Validating query..."), !state.loading && state.value && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, state.value.isValid && state.value.statistics && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.valid }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "check" }), " This query will process", " ", /* @__PURE__ */ React__default.default.createElement("strong", null, data.formattedValueToString(valueFormatter(state.value.statistics.TotalBytesProcessed))), " ", "when run.")), /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, state.value.isError && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.error }, error))));
|
|
6223
6245
|
}
|
|
6224
6246
|
function processErrorMessage(error) {
|
|
@@ -6262,9 +6284,13 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
|
|
|
6262
6284
|
};
|
|
6263
6285
|
}, [theme]);
|
|
6264
6286
|
let style = {};
|
|
6265
|
-
if (!showTools && validationResult ===
|
|
6287
|
+
if (!showTools && validationResult === void 0) {
|
|
6266
6288
|
style = { height: 0, padding: 0, visibility: "hidden" };
|
|
6267
6289
|
}
|
|
6290
|
+
const onFormatClick = () => {
|
|
6291
|
+
runtime.reportInteraction("grafana_sql_query_editor_format_click");
|
|
6292
|
+
onFormatCode == null ? void 0 : onFormatCode();
|
|
6293
|
+
};
|
|
6268
6294
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container, style }, /* @__PURE__ */ React__default.default.createElement("div", null, validatorProps.onValidate && /* @__PURE__ */ React__default.default.createElement(
|
|
6269
6295
|
QueryValidator,
|
|
6270
6296
|
{
|
|
@@ -6274,7 +6300,7 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
|
|
|
6274
6300
|
validatorProps.onValidate(result);
|
|
6275
6301
|
}
|
|
6276
6302
|
}
|
|
6277
|
-
)), showTools && /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(ui.HorizontalGroup, { spacing: "sm" }, onFormatCode && /* @__PURE__ */ React__default.default.createElement(ui.IconButton, { onClick:
|
|
6303
|
+
)), showTools && /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(ui.HorizontalGroup, { spacing: "sm" }, onFormatCode && /* @__PURE__ */ React__default.default.createElement(ui.IconButton, { onClick: onFormatClick, name: "brackets-curly", size: "xs", tooltip: "Format query" }), onExpand && /* @__PURE__ */ React__default.default.createElement(
|
|
6278
6304
|
ui.IconButton,
|
|
6279
6305
|
{
|
|
6280
6306
|
onClick: () => onExpand(!isExpanded),
|
|
@@ -6285,9 +6311,18 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
|
|
|
6285
6311
|
), /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: "Hit CTRL/CMD+Return to run query" }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { className: styles.hint, name: "keyboard" })))));
|
|
6286
6312
|
}
|
|
6287
6313
|
|
|
6288
|
-
function RawEditor({
|
|
6314
|
+
function RawEditor({
|
|
6315
|
+
db,
|
|
6316
|
+
query,
|
|
6317
|
+
onChange,
|
|
6318
|
+
onRunQuery,
|
|
6319
|
+
onValidate,
|
|
6320
|
+
queryToValidate,
|
|
6321
|
+
range,
|
|
6322
|
+
language = "sql"
|
|
6323
|
+
}) {
|
|
6289
6324
|
const theme = ui.useTheme2();
|
|
6290
|
-
const styles = ui.useStyles2(getStyles$
|
|
6325
|
+
const styles = ui.useStyles2(getStyles$l);
|
|
6291
6326
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
6292
6327
|
const [toolboxRef, toolboxMeasure] = reactUse.useMeasure();
|
|
6293
6328
|
const [editorRef, editorMeasure] = reactUse.useMeasure();
|
|
@@ -6299,7 +6334,8 @@ function RawEditor({ db, query, onChange, onRunQuery, onValidate, queryToValidat
|
|
|
6299
6334
|
completionProvider,
|
|
6300
6335
|
query,
|
|
6301
6336
|
width,
|
|
6302
|
-
|
|
6337
|
+
language,
|
|
6338
|
+
height: height ? height - toolboxMeasure.height : void 0,
|
|
6303
6339
|
onChange
|
|
6304
6340
|
},
|
|
6305
6341
|
({ formatQuery }) => {
|
|
@@ -6356,7 +6392,7 @@ function RawEditor({ db, query, onChange, onRunQuery, onValidate, queryToValidat
|
|
|
6356
6392
|
renderEditor(true)
|
|
6357
6393
|
));
|
|
6358
6394
|
}
|
|
6359
|
-
function getStyles$
|
|
6395
|
+
function getStyles$l(theme) {
|
|
6360
6396
|
return {
|
|
6361
6397
|
modal: css.css`
|
|
6362
6398
|
width: 95vw;
|
|
@@ -6369,23 +6405,23 @@ function getStyles$h(theme) {
|
|
|
6369
6405
|
};
|
|
6370
6406
|
}
|
|
6371
6407
|
|
|
6372
|
-
function Preview({ rawSql }) {
|
|
6408
|
+
function Preview({ rawSql, language = "sql" }) {
|
|
6373
6409
|
const [_, copyToClipboard] = reactUse.useCopyToClipboard();
|
|
6374
|
-
const styles = ui.useStyles2(getStyles$
|
|
6410
|
+
const styles = ui.useStyles2(getStyles$k);
|
|
6375
6411
|
const labelElement = /* @__PURE__ */ React__default.default.createElement("div", { className: styles.labelWrapper }, /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label }, "Preview"), /* @__PURE__ */ React__default.default.createElement(ui.IconButton, { tooltip: "Copy to clipboard", onClick: () => copyToClipboard(rawSql), name: "copy" }));
|
|
6376
6412
|
return /* @__PURE__ */ React__default.default.createElement(ui.Field, { label: labelElement, className: styles.grow }, /* @__PURE__ */ React__default.default.createElement(
|
|
6377
6413
|
ui.CodeEditor,
|
|
6378
6414
|
{
|
|
6379
6415
|
language: "sql",
|
|
6380
6416
|
height: 80,
|
|
6381
|
-
value: formatSQL(rawSql),
|
|
6417
|
+
value: formatSQL(rawSql, language),
|
|
6382
6418
|
monacoOptions: { scrollbar: { vertical: "hidden" }, scrollBeyondLastLine: false },
|
|
6383
6419
|
readOnly: true,
|
|
6384
6420
|
showMiniMap: false
|
|
6385
6421
|
}
|
|
6386
6422
|
));
|
|
6387
6423
|
}
|
|
6388
|
-
function getStyles$
|
|
6424
|
+
function getStyles$k(theme) {
|
|
6389
6425
|
return {
|
|
6390
6426
|
grow: css.css({ flexGrow: 1 }),
|
|
6391
6427
|
label: css.css({ fontSize: 12, fontWeight: theme.typography.fontWeightMedium }),
|
|
@@ -6446,9 +6482,9 @@ function OrderByRow({ sql, onSqlChange, columns, showOffset }) {
|
|
|
6446
6482
|
);
|
|
6447
6483
|
const onOrderByChange = React.useCallback(
|
|
6448
6484
|
(item) => {
|
|
6449
|
-
const newSql = { ...sql, orderBy: setPropertyField(item == null ?
|
|
6485
|
+
const newSql = { ...sql, orderBy: setPropertyField(item == null ? void 0 : item.value) };
|
|
6450
6486
|
if (item === null) {
|
|
6451
|
-
newSql.orderByDirection =
|
|
6487
|
+
newSql.orderByDirection = void 0;
|
|
6452
6488
|
}
|
|
6453
6489
|
onSqlChange(newSql);
|
|
6454
6490
|
},
|
|
@@ -6459,7 +6495,7 @@ function OrderByRow({ sql, onSqlChange, columns, showOffset }) {
|
|
|
6459
6495
|
{
|
|
6460
6496
|
"aria-label": "Order by",
|
|
6461
6497
|
options: columns,
|
|
6462
|
-
value: ((_a = sql.orderBy) == null ?
|
|
6498
|
+
value: ((_a = sql.orderBy) == null ? void 0 : _a.property.name) ? data.toOption(sql.orderBy.property.name) : null,
|
|
6463
6499
|
isClearable: true,
|
|
6464
6500
|
menuShouldPortal: true,
|
|
6465
6501
|
onChange: onOrderByChange
|
|
@@ -6468,7 +6504,7 @@ function OrderByRow({ sql, onSqlChange, columns, showOffset }) {
|
|
|
6468
6504
|
ui.RadioButtonGroup,
|
|
6469
6505
|
{
|
|
6470
6506
|
options: sortOrderOptions,
|
|
6471
|
-
disabled: !((_b = sql == null ?
|
|
6507
|
+
disabled: !((_b = sql == null ? void 0 : sql.orderBy) == null ? void 0 : _b.property.name),
|
|
6472
6508
|
value: sql.orderByDirection,
|
|
6473
6509
|
onChange: onSortOrderChange
|
|
6474
6510
|
}
|
|
@@ -6480,9 +6516,9 @@ function SQLOrderByRow({ fields, query, onQueryChange, db }) {
|
|
|
6480
6516
|
const { onSqlChange } = useSqlChange({ query, onQueryChange, db });
|
|
6481
6517
|
let columnsWithIndices = [];
|
|
6482
6518
|
if (fields) {
|
|
6483
|
-
const options = (_b = (_a = query.sql) == null ?
|
|
6519
|
+
const options = (_b = (_a = query.sql) == null ? void 0 : _a.columns) == null ? void 0 : _b.map((c, i) => {
|
|
6484
6520
|
var _a2, _b2;
|
|
6485
|
-
const value = c.name ? `${c.name}(${(_a2 = c.parameters) == null ?
|
|
6521
|
+
const value = c.name ? `${c.name}(${(_a2 = c.parameters) == null ? void 0 : _a2.map((p) => p.name)})` : (_b2 = c.parameters) == null ? void 0 : _b2.map((p) => p.name);
|
|
6486
6522
|
return {
|
|
6487
6523
|
value,
|
|
6488
6524
|
label: `${i + 1} - ${value}`
|
|
@@ -6504,13 +6540,13 @@ function SQLOrderByRow({ fields, query, onQueryChange, db }) {
|
|
|
6504
6540
|
const asteriskValue = { label: "*", value: "*" };
|
|
6505
6541
|
function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
6506
6542
|
var _a;
|
|
6507
|
-
const styles = ui.useStyles2(getStyles$
|
|
6543
|
+
const styles = ui.useStyles2(getStyles$j);
|
|
6508
6544
|
const columnsWithAsterisk = [asteriskValue, ...columns || []];
|
|
6509
6545
|
const onColumnChange = React.useCallback(
|
|
6510
6546
|
(item, index) => (column) => {
|
|
6511
6547
|
var _a2, _b;
|
|
6512
6548
|
let modifiedItem = { ...item };
|
|
6513
|
-
if (!((_a2 = item.parameters) == null ?
|
|
6549
|
+
if (!((_a2 = item.parameters) == null ? void 0 : _a2.length)) {
|
|
6514
6550
|
modifiedItem.parameters = [{ type: QueryEditorExpressionType.FunctionParameter, name: column.value }];
|
|
6515
6551
|
} else {
|
|
6516
6552
|
modifiedItem.parameters = item.parameters.map(
|
|
@@ -6519,7 +6555,7 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6519
6555
|
}
|
|
6520
6556
|
const newSql = {
|
|
6521
6557
|
...sql,
|
|
6522
|
-
columns: (_b = sql.columns) == null ?
|
|
6558
|
+
columns: (_b = sql.columns) == null ? void 0 : _b.map((c, i) => i === index ? modifiedItem : c)
|
|
6523
6559
|
};
|
|
6524
6560
|
onSqlChange(newSql);
|
|
6525
6561
|
},
|
|
@@ -6530,11 +6566,11 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6530
6566
|
var _a2;
|
|
6531
6567
|
const newItem = {
|
|
6532
6568
|
...item,
|
|
6533
|
-
name: aggregation == null ?
|
|
6569
|
+
name: aggregation == null ? void 0 : aggregation.value
|
|
6534
6570
|
};
|
|
6535
6571
|
const newSql = {
|
|
6536
6572
|
...sql,
|
|
6537
|
-
columns: (_a2 = sql.columns) == null ?
|
|
6573
|
+
columns: (_a2 = sql.columns) == null ? void 0 : _a2.map((c, i) => i === index ? newItem : c)
|
|
6538
6574
|
};
|
|
6539
6575
|
onSqlChange(newSql);
|
|
6540
6576
|
},
|
|
@@ -6556,7 +6592,7 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6556
6592
|
const newSql = { ...sql, columns: [...sql.columns, createFunctionField()] };
|
|
6557
6593
|
onSqlChange(newSql);
|
|
6558
6594
|
}, [onSqlChange, sql]);
|
|
6559
|
-
return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2, alignItems: "end", direction: "column" }, (_a = sql.columns) == null ?
|
|
6595
|
+
return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2, alignItems: "end", direction: "column" }, (_a = sql.columns) == null ? void 0 : _a.map((item, index) => /* @__PURE__ */ React__default.default.createElement("div", { key: index }, /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2, alignItems: "end" }, /* @__PURE__ */ React__default.default.createElement(EditorField$1, { label: "Column", width: 25 }, /* @__PURE__ */ React__default.default.createElement(
|
|
6560
6596
|
ui.Select,
|
|
6561
6597
|
{
|
|
6562
6598
|
value: getColumnValue(item),
|
|
@@ -6600,12 +6636,12 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6600
6636
|
}
|
|
6601
6637
|
));
|
|
6602
6638
|
}
|
|
6603
|
-
const getStyles$
|
|
6639
|
+
const getStyles$j = () => {
|
|
6604
6640
|
return { addButton: css.css({ alignSelf: "flex-start" }) };
|
|
6605
6641
|
};
|
|
6606
6642
|
function getColumnValue({ parameters }) {
|
|
6607
|
-
const column = parameters == null ?
|
|
6608
|
-
if (column == null ?
|
|
6643
|
+
const column = parameters == null ? void 0 : parameters.find((p) => p.type === QueryEditorExpressionType.FunctionParameter);
|
|
6644
|
+
if (column == null ? void 0 : column.name) {
|
|
6609
6645
|
return data.toOption(column.name);
|
|
6610
6646
|
}
|
|
6611
6647
|
return null;
|
|
@@ -6626,7 +6662,6 @@ const buttonLabels = {
|
|
|
6626
6662
|
};
|
|
6627
6663
|
({
|
|
6628
6664
|
id: ui$1.Utils.uuid(),
|
|
6629
|
-
type: "group",
|
|
6630
6665
|
children1: [
|
|
6631
6666
|
{
|
|
6632
6667
|
id: ui$1.Utils.uuid(),
|
|
@@ -6664,9 +6699,9 @@ const widgets = {
|
|
|
6664
6699
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6665
6700
|
ui.Input,
|
|
6666
6701
|
{
|
|
6667
|
-
value: (props == null ?
|
|
6668
|
-
placeholder: props == null ?
|
|
6669
|
-
onChange: (e) => props == null ?
|
|
6702
|
+
value: (props == null ? void 0 : props.value) || "",
|
|
6703
|
+
placeholder: props == null ? void 0 : props.placeholder,
|
|
6704
|
+
onChange: (e) => props == null ? void 0 : props.setValue(e.currentTarget.value)
|
|
6670
6705
|
}
|
|
6671
6706
|
);
|
|
6672
6707
|
}
|
|
@@ -6677,10 +6712,10 @@ const widgets = {
|
|
|
6677
6712
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6678
6713
|
ui.Input,
|
|
6679
6714
|
{
|
|
6680
|
-
value: props == null ?
|
|
6681
|
-
placeholder: props == null ?
|
|
6715
|
+
value: props == null ? void 0 : props.value,
|
|
6716
|
+
placeholder: props == null ? void 0 : props.placeholder,
|
|
6682
6717
|
type: "number",
|
|
6683
|
-
onChange: (e) => props == null ?
|
|
6718
|
+
onChange: (e) => props == null ? void 0 : props.setValue(Number.parseInt(e.currentTarget.value, 10))
|
|
6684
6719
|
}
|
|
6685
6720
|
);
|
|
6686
6721
|
}
|
|
@@ -6692,9 +6727,9 @@ const widgets = {
|
|
|
6692
6727
|
ui.DateTimePicker,
|
|
6693
6728
|
{
|
|
6694
6729
|
onChange: (e) => {
|
|
6695
|
-
props == null ?
|
|
6730
|
+
props == null ? void 0 : props.setValue(e == null ? void 0 : e.format(ui$1.BasicConfig.widgets.datetime.valueFormat));
|
|
6696
6731
|
},
|
|
6697
|
-
date: data.dateTime(props == null ?
|
|
6732
|
+
date: data.dateTime(props == null ? void 0 : props.value).utc()
|
|
6698
6733
|
}
|
|
6699
6734
|
);
|
|
6700
6735
|
}
|
|
@@ -6712,37 +6747,37 @@ const settings = {
|
|
|
6712
6747
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6713
6748
|
ui.Select,
|
|
6714
6749
|
{
|
|
6715
|
-
id: conjProps == null ?
|
|
6750
|
+
id: conjProps == null ? void 0 : conjProps.id,
|
|
6716
6751
|
"aria-label": "Conjunction",
|
|
6717
6752
|
menuShouldPortal: true,
|
|
6718
|
-
options: (conjProps == null ?
|
|
6719
|
-
value: conjProps == null ?
|
|
6720
|
-
onChange: (val) => conjProps == null ?
|
|
6753
|
+
options: (conjProps == null ? void 0 : conjProps.conjunctionOptions) ? Object.keys(conjProps == null ? void 0 : conjProps.conjunctionOptions).map(data.toOption) : void 0,
|
|
6754
|
+
value: conjProps == null ? void 0 : conjProps.selectedConjunction,
|
|
6755
|
+
onChange: (val) => conjProps == null ? void 0 : conjProps.setConjunction(val.value)
|
|
6721
6756
|
}
|
|
6722
6757
|
);
|
|
6723
6758
|
},
|
|
6724
6759
|
renderField: function Field(fieldProps) {
|
|
6725
6760
|
var _a;
|
|
6726
|
-
const fields = ((_a = fieldProps == null ?
|
|
6761
|
+
const fields = ((_a = fieldProps == null ? void 0 : fieldProps.config) == null ? void 0 : _a.fields) || {};
|
|
6727
6762
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6728
6763
|
ui.Select,
|
|
6729
6764
|
{
|
|
6730
|
-
id: fieldProps == null ?
|
|
6765
|
+
id: fieldProps == null ? void 0 : fieldProps.id,
|
|
6731
6766
|
width: 25,
|
|
6732
6767
|
"aria-label": "Field",
|
|
6733
6768
|
menuShouldPortal: true,
|
|
6734
|
-
options: fieldProps == null ?
|
|
6769
|
+
options: fieldProps == null ? void 0 : fieldProps.items.map((f) => {
|
|
6735
6770
|
var _a2, _b;
|
|
6736
|
-
const icon = (_b = (_a2 = fields[f.key].mainWidgetProps) == null ?
|
|
6771
|
+
const icon = (_b = (_a2 = fields[f.key].mainWidgetProps) == null ? void 0 : _a2.customProps) == null ? void 0 : _b.icon;
|
|
6737
6772
|
return {
|
|
6738
6773
|
label: f.label,
|
|
6739
6774
|
value: f.key,
|
|
6740
6775
|
icon
|
|
6741
6776
|
};
|
|
6742
6777
|
}),
|
|
6743
|
-
value: fieldProps == null ?
|
|
6778
|
+
value: fieldProps == null ? void 0 : fieldProps.selectedKey,
|
|
6744
6779
|
onChange: (val) => {
|
|
6745
|
-
fieldProps == null ?
|
|
6780
|
+
fieldProps == null ? void 0 : fieldProps.setField(val.label);
|
|
6746
6781
|
}
|
|
6747
6782
|
}
|
|
6748
6783
|
);
|
|
@@ -6752,11 +6787,11 @@ const settings = {
|
|
|
6752
6787
|
ui.Button,
|
|
6753
6788
|
{
|
|
6754
6789
|
type: "button",
|
|
6755
|
-
title: `${buttonProps == null ?
|
|
6756
|
-
onClick: buttonProps == null ?
|
|
6790
|
+
title: `${buttonProps == null ? void 0 : buttonProps.label} filter`,
|
|
6791
|
+
onClick: buttonProps == null ? void 0 : buttonProps.onClick,
|
|
6757
6792
|
variant: "secondary",
|
|
6758
6793
|
size: "md",
|
|
6759
|
-
icon: (buttonProps == null ?
|
|
6794
|
+
icon: (buttonProps == null ? void 0 : buttonProps.label) === buttonLabels.add ? "plus" : "times"
|
|
6760
6795
|
}
|
|
6761
6796
|
);
|
|
6762
6797
|
},
|
|
@@ -6764,12 +6799,12 @@ const settings = {
|
|
|
6764
6799
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6765
6800
|
ui.Select,
|
|
6766
6801
|
{
|
|
6767
|
-
options: operatorProps == null ?
|
|
6802
|
+
options: operatorProps == null ? void 0 : operatorProps.items.map((op) => ({ label: op.label, value: op.key })),
|
|
6768
6803
|
"aria-label": "Operator",
|
|
6769
6804
|
menuShouldPortal: true,
|
|
6770
|
-
value: operatorProps == null ?
|
|
6805
|
+
value: operatorProps == null ? void 0 : operatorProps.selectedKey,
|
|
6771
6806
|
onChange: (val) => {
|
|
6772
|
-
operatorProps == null ?
|
|
6807
|
+
operatorProps == null ? void 0 : operatorProps.setField(val.value || "");
|
|
6773
6808
|
}
|
|
6774
6809
|
}
|
|
6775
6810
|
);
|
|
@@ -6947,10 +6982,10 @@ function mapFieldsToTypes(columns) {
|
|
|
6947
6982
|
}
|
|
6948
6983
|
|
|
6949
6984
|
const EditorRow = ({ children }) => {
|
|
6950
|
-
const styles = ui.useStyles2(getStyles$
|
|
6985
|
+
const styles = ui.useStyles2(getStyles$i);
|
|
6951
6986
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2 }, children));
|
|
6952
6987
|
};
|
|
6953
|
-
const getStyles$
|
|
6988
|
+
const getStyles$i = (theme) => {
|
|
6954
6989
|
return {
|
|
6955
6990
|
root: css.css({
|
|
6956
6991
|
padding: theme.spacing(1),
|
|
@@ -6964,12 +6999,12 @@ const EditorField = (props) => {
|
|
|
6964
6999
|
var _a;
|
|
6965
7000
|
const { label, optional, tooltip, children, width, ...fieldProps } = props;
|
|
6966
7001
|
const theme = ui.useTheme2();
|
|
6967
|
-
const styles = getStyles$
|
|
6968
|
-
const childInputId = (fieldProps == null ?
|
|
7002
|
+
const styles = getStyles$h(theme, width);
|
|
7003
|
+
const childInputId = (fieldProps == null ? void 0 : fieldProps.htmlFor) || ((_a = ui.ReactUtils) == null ? void 0 : _a.getChildId(children));
|
|
6969
7004
|
const labelEl = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label, htmlFor: childInputId }, label, optional && /* @__PURE__ */ React__default.default.createElement("span", { className: styles.optional }, " - optional"), tooltip && /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { placement: "top", content: tooltip, theme: "info" }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "info-circle", size: "sm", className: styles.icon }))), /* @__PURE__ */ React__default.default.createElement(Space, { v: 0.5 }));
|
|
6970
7005
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, /* @__PURE__ */ React__default.default.createElement(ui.Field, { className: styles.field, label: labelEl, ...fieldProps }, children));
|
|
6971
7006
|
};
|
|
6972
|
-
const getStyles$
|
|
7007
|
+
const getStyles$h = ui.stylesFactory((theme, width) => {
|
|
6973
7008
|
return {
|
|
6974
7009
|
root: css.css({
|
|
6975
7010
|
minWidth: theme.spacing(width != null ? width : 0)
|
|
@@ -7000,12 +7035,20 @@ const EditorRows = ({ children }) => {
|
|
|
7000
7035
|
return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 0.5, direction: "column" }, children);
|
|
7001
7036
|
};
|
|
7002
7037
|
|
|
7003
|
-
const VisualEditor = ({
|
|
7038
|
+
const VisualEditor = ({
|
|
7039
|
+
query,
|
|
7040
|
+
db,
|
|
7041
|
+
queryRowFilter,
|
|
7042
|
+
onChange,
|
|
7043
|
+
onValidate,
|
|
7044
|
+
language = "sql",
|
|
7045
|
+
range
|
|
7046
|
+
}) => {
|
|
7004
7047
|
const state = reactUse.useAsync(async () => {
|
|
7005
7048
|
const fields = await db.fields(query);
|
|
7006
7049
|
return fields;
|
|
7007
7050
|
}, [db, query.dataset, query.table]);
|
|
7008
|
-
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(EditorRows, null, /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLSelectRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.filter && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Filter by column value", optional: true }, /* @__PURE__ */ React__default.default.createElement(SQLWhereRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.group && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Group by column" }, /* @__PURE__ */ React__default.default.createElement(SQLGroupByRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.order && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLOrderByRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.preview && query.rawSql && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(Preview, { rawSql: query.rawSql }))), /* @__PURE__ */ React__default.default.createElement(QueryToolbox, { db, query, onValidate, range }));
|
|
7051
|
+
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(EditorRows, null, /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLSelectRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.filter && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Filter by column value", optional: true }, /* @__PURE__ */ React__default.default.createElement(SQLWhereRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.group && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Group by column" }, /* @__PURE__ */ React__default.default.createElement(SQLGroupByRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.order && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLOrderByRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.preview && query.rawSql && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(Preview, { rawSql: query.rawSql, language }))), /* @__PURE__ */ React__default.default.createElement(QueryToolbox, { db, query, onValidate, range }));
|
|
7009
7052
|
};
|
|
7010
7053
|
|
|
7011
7054
|
const MACRO_NAMES = [
|
|
@@ -7108,7 +7151,7 @@ class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
|
7108
7151
|
return this.getResponseParser().transformMetricFindResponse(response);
|
|
7109
7152
|
}
|
|
7110
7153
|
async runSql(query, options) {
|
|
7111
|
-
const frame = await this.runMetaQuery({ rawSql: query, format: QueryFormat.Table, refId: options == null ?
|
|
7154
|
+
const frame = await this.runMetaQuery({ rawSql: query, format: QueryFormat.Table, refId: options == null ? void 0 : options.refId }, options);
|
|
7112
7155
|
return new data.DataFrameView(frame);
|
|
7113
7156
|
}
|
|
7114
7157
|
runMetaQuery(request, options) {
|
|
@@ -7120,8 +7163,8 @@ class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
|
7120
7163
|
url: "/api/ds/query",
|
|
7121
7164
|
method: "POST",
|
|
7122
7165
|
data: {
|
|
7123
|
-
from: (_a = options == null ?
|
|
7124
|
-
to: (_b = options == null ?
|
|
7166
|
+
from: (_a = options == null ? void 0 : options.range) == null ? void 0 : _a.from.valueOf().toString(),
|
|
7167
|
+
to: (_b = options == null ? void 0 : options.range) == null ? void 0 : _b.to.valueOf().toString(),
|
|
7125
7168
|
queries
|
|
7126
7169
|
},
|
|
7127
7170
|
requestId: refId
|
|
@@ -7164,7 +7207,7 @@ class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
|
7164
7207
|
targetContainsTemplate(target) {
|
|
7165
7208
|
let queryWithoutMacros = target.rawSql;
|
|
7166
7209
|
MACRO_NAMES.forEach((value) => {
|
|
7167
|
-
queryWithoutMacros = (queryWithoutMacros == null ?
|
|
7210
|
+
queryWithoutMacros = (queryWithoutMacros == null ? void 0 : queryWithoutMacros.replace(value, "")) || "";
|
|
7168
7211
|
});
|
|
7169
7212
|
return this.templateSrv.containsTemplate(queryWithoutMacros);
|
|
7170
7213
|
}
|
|
@@ -7187,29 +7230,29 @@ const getSearchFilterScopedVar = (args) => {
|
|
|
7187
7230
|
};
|
|
7188
7231
|
};
|
|
7189
7232
|
|
|
7190
|
-
function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
7233
|
+
function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range, language = "sql" }) {
|
|
7191
7234
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7192
7235
|
const [isQueryRunnable, setIsQueryRunnable] = React.useState(true);
|
|
7193
7236
|
const db = datasource.getDB();
|
|
7194
7237
|
const defaultDataset = datasource.dataset;
|
|
7195
7238
|
const { loading, error } = reactUse.useAsync(async () => {
|
|
7196
7239
|
return () => {
|
|
7197
|
-
if (datasource.getDB(datasource.id).init !==
|
|
7240
|
+
if (datasource.getDB(datasource.id).init !== void 0) {
|
|
7198
7241
|
datasource.getDB(datasource.id).init();
|
|
7199
7242
|
}
|
|
7200
7243
|
};
|
|
7201
7244
|
}, [datasource]);
|
|
7202
7245
|
const queryWithDefaults = applyQueryDefaults(query);
|
|
7203
7246
|
const [queryRowFilter, setQueryRowFilter] = React.useState({
|
|
7204
|
-
filter: !!((_a = queryWithDefaults.sql) == null ?
|
|
7205
|
-
group: !!((_d = (_c = (_b = queryWithDefaults.sql) == null ?
|
|
7206
|
-
order: !!((_f = (_e = queryWithDefaults.sql) == null ?
|
|
7247
|
+
filter: !!((_a = queryWithDefaults.sql) == null ? void 0 : _a.whereString),
|
|
7248
|
+
group: !!((_d = (_c = (_b = queryWithDefaults.sql) == null ? void 0 : _b.groupBy) == null ? void 0 : _c[0]) == null ? void 0 : _d.property.name),
|
|
7249
|
+
order: !!((_f = (_e = queryWithDefaults.sql) == null ? void 0 : _e.orderBy) == null ? void 0 : _f.property.name),
|
|
7207
7250
|
preview: true
|
|
7208
7251
|
});
|
|
7209
7252
|
const [queryToValidate, setQueryToValidate] = React.useState(queryWithDefaults);
|
|
7210
7253
|
React.useEffect(() => {
|
|
7211
7254
|
return () => {
|
|
7212
|
-
if (datasource.getDB(datasource.id).dispose !==
|
|
7255
|
+
if (datasource.getDB(datasource.id).dispose !== void 0) {
|
|
7213
7256
|
datasource.getDB(datasource.id).dispose();
|
|
7214
7257
|
}
|
|
7215
7258
|
};
|
|
@@ -7226,7 +7269,7 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
|
7226
7269
|
var _a2, _b2;
|
|
7227
7270
|
setQueryToValidate(q);
|
|
7228
7271
|
onChange(q);
|
|
7229
|
-
if (haveColumns((_a2 = q.sql) == null ?
|
|
7272
|
+
if (haveColumns((_a2 = q.sql) == null ? void 0 : _a2.columns) && ((_b2 = q.sql) == null ? void 0 : _b2.columns.some((c) => c.name)) && !queryRowFilter.group) {
|
|
7230
7273
|
setQueryRowFilter({ ...queryRowFilter, group: true });
|
|
7231
7274
|
}
|
|
7232
7275
|
if (process) {
|
|
@@ -7256,13 +7299,14 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
|
7256
7299
|
queryRowFilter,
|
|
7257
7300
|
query: queryWithDefaults,
|
|
7258
7301
|
isQueryRunnable,
|
|
7259
|
-
labels: (_g = datasource.getDB(datasource.id)) == null ?
|
|
7302
|
+
labels: (_g = datasource.getDB(datasource.id)) == null ? void 0 : _g.labels
|
|
7260
7303
|
}
|
|
7261
7304
|
), /* @__PURE__ */ React__default.default.createElement(Space, { v: 0.5 }), queryWithDefaults.editorMode !== EditorMode.Code && /* @__PURE__ */ React__default.default.createElement(
|
|
7262
7305
|
VisualEditor,
|
|
7263
7306
|
{
|
|
7264
7307
|
db,
|
|
7265
7308
|
query: queryWithDefaults,
|
|
7309
|
+
language,
|
|
7266
7310
|
onChange: (q) => onQueryChange(q, false),
|
|
7267
7311
|
queryRowFilter,
|
|
7268
7312
|
onValidate: setIsQueryRunnable,
|
|
@@ -7272,6 +7316,7 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
|
7272
7316
|
RawEditor,
|
|
7273
7317
|
{
|
|
7274
7318
|
db,
|
|
7319
|
+
language,
|
|
7275
7320
|
query: queryWithDefaults,
|
|
7276
7321
|
queryToValidate,
|
|
7277
7322
|
onChange: onQueryChange,
|
|
@@ -7409,7 +7454,7 @@ const ConfigSubSection = ({ children, ...props }) => {
|
|
|
7409
7454
|
function ConfigDescriptionLink(props) {
|
|
7410
7455
|
const { description, suffix, feature } = props;
|
|
7411
7456
|
const text = `Learn more about ${feature}`;
|
|
7412
|
-
const styles = ui.useStyles2(getStyles$
|
|
7457
|
+
const styles = ui.useStyles2(getStyles$g);
|
|
7413
7458
|
return /* @__PURE__ */ React__default.default.createElement("span", { className: styles.container }, description, /* @__PURE__ */ React__default.default.createElement(
|
|
7414
7459
|
"a",
|
|
7415
7460
|
{
|
|
@@ -7421,7 +7466,7 @@ function ConfigDescriptionLink(props) {
|
|
|
7421
7466
|
text
|
|
7422
7467
|
));
|
|
7423
7468
|
}
|
|
7424
|
-
const getStyles$
|
|
7469
|
+
const getStyles$g = (theme) => {
|
|
7425
7470
|
return {
|
|
7426
7471
|
container: css.css({
|
|
7427
7472
|
color: theme.colors.text.secondary,
|
|
@@ -7576,7 +7621,7 @@ const AuthMethodSettings = ({
|
|
|
7576
7621
|
AuthMethod.BasicAuth,
|
|
7577
7622
|
AuthMethod.OAuthForward,
|
|
7578
7623
|
AuthMethod.NoAuth,
|
|
7579
|
-
...(_a2 = customMethods == null ?
|
|
7624
|
+
...(_a2 = customMethods == null ? void 0 : customMethods.map((m) => m.id)) != null ? _a2 : []
|
|
7580
7625
|
];
|
|
7581
7626
|
},
|
|
7582
7627
|
[customMethods, visibleMethodsFromProps]
|
|
@@ -7584,7 +7629,7 @@ const AuthMethodSettings = ({
|
|
|
7584
7629
|
const hasSelect = visibleMethods.length > 1;
|
|
7585
7630
|
const preparedOptions = React.useMemo(() => {
|
|
7586
7631
|
var _a2;
|
|
7587
|
-
const customOptions = (_a2 = customMethods == null ?
|
|
7632
|
+
const customOptions = (_a2 = customMethods == null ? void 0 : customMethods.reduce((acc, method) => {
|
|
7588
7633
|
acc[method.id] = {
|
|
7589
7634
|
label: method.label,
|
|
7590
7635
|
value: method.id,
|
|
@@ -7597,7 +7642,7 @@ const AuthMethodSettings = ({
|
|
|
7597
7642
|
for (k in defaultOptions) {
|
|
7598
7643
|
preparedDefaultOptions[k] = {
|
|
7599
7644
|
...defaultOptions[k],
|
|
7600
|
-
...defaultOptionsOverrides == null ?
|
|
7645
|
+
...defaultOptionsOverrides == null ? void 0 : defaultOptionsOverrides[k]
|
|
7601
7646
|
};
|
|
7602
7647
|
}
|
|
7603
7648
|
const allOptions = {
|
|
@@ -7625,7 +7670,7 @@ const AuthMethodSettings = ({
|
|
|
7625
7670
|
if (selected === AuthMethod.BasicAuth && basicAuth) {
|
|
7626
7671
|
AuthFieldsComponent = /* @__PURE__ */ React__default.default.createElement(BasicAuth, { ...basicAuth, readOnly });
|
|
7627
7672
|
} else if (selected.startsWith("custom-")) {
|
|
7628
|
-
AuthFieldsComponent = (_b = (_a = customMethods == null ?
|
|
7673
|
+
AuthFieldsComponent = (_b = (_a = customMethods == null ? void 0 : customMethods.find((m) => m.id === selected)) == null ? void 0 : _a.component) != null ? _b : null;
|
|
7629
7674
|
}
|
|
7630
7675
|
const title = hasSelect ? "Authentication methods" : (_c = preparedOptions[0].label) != null ? _c : "";
|
|
7631
7676
|
const description = hasSelect ? "Choose an authentication method to access the data source" : (_d = preparedOptions[0].description) != null ? _d : "";
|
|
@@ -7710,7 +7755,7 @@ const SelfSignedCertificate = ({
|
|
|
7710
7755
|
{
|
|
7711
7756
|
label: "CA Certificate",
|
|
7712
7757
|
labelWidth: 24,
|
|
7713
|
-
tooltip: (_a = tooltips == null ?
|
|
7758
|
+
tooltip: (_a = tooltips == null ? void 0 : tooltips.certificateLabel) != null ? _a : "Your self-signed certificate",
|
|
7714
7759
|
required: true,
|
|
7715
7760
|
htmlFor: "self-signed-certificate-input",
|
|
7716
7761
|
interactive: true,
|
|
@@ -7765,7 +7810,7 @@ const TLSClientAuth = ({
|
|
|
7765
7810
|
{
|
|
7766
7811
|
label: "ServerName",
|
|
7767
7812
|
labelWidth: 24,
|
|
7768
|
-
tooltip: (_a = tooltips == null ?
|
|
7813
|
+
tooltip: (_a = tooltips == null ? void 0 : tooltips.serverNameLabel) != null ? _a : "A Servername is used to verify the hostname on the returned certificate",
|
|
7769
7814
|
required: true,
|
|
7770
7815
|
htmlFor: "client-auth-servername-input",
|
|
7771
7816
|
interactive: true,
|
|
@@ -7789,7 +7834,7 @@ const TLSClientAuth = ({
|
|
|
7789
7834
|
{
|
|
7790
7835
|
label: "Client Certificate",
|
|
7791
7836
|
labelWidth: 24,
|
|
7792
|
-
tooltip: (_b = tooltips == null ?
|
|
7837
|
+
tooltip: (_b = tooltips == null ? void 0 : tooltips.certificateLabel) != null ? _b : "The client certificate can be generated from a Certificate Authority or be self-signed",
|
|
7793
7838
|
required: true,
|
|
7794
7839
|
htmlFor: "client-auth-client-certificate-input",
|
|
7795
7840
|
interactive: true,
|
|
@@ -7816,7 +7861,7 @@ const TLSClientAuth = ({
|
|
|
7816
7861
|
{
|
|
7817
7862
|
label: "Client Key",
|
|
7818
7863
|
labelWidth: 24,
|
|
7819
|
-
tooltip: (_c = tooltips == null ?
|
|
7864
|
+
tooltip: (_c = tooltips == null ? void 0 : tooltips.keyLabel) != null ? _c : "The client key can be generated from a Certificate Authority or be self-signed",
|
|
7820
7865
|
required: true,
|
|
7821
7866
|
htmlFor: "client-auth-client-key-input",
|
|
7822
7867
|
interactive: true,
|
|
@@ -7972,7 +8017,7 @@ const CustomHeaders = ({ headers: headersFromProps, onChange, readOnly }) => {
|
|
|
7972
8017
|
let changed = false;
|
|
7973
8018
|
const newHeaders = headers2.map((header) => {
|
|
7974
8019
|
var _a;
|
|
7975
|
-
const configured = (_a = headersFromProps.find((h) => h.name === header.name)) == null ?
|
|
8020
|
+
const configured = (_a = headersFromProps.find((h) => h.name === header.name)) == null ? void 0 : _a.configured;
|
|
7976
8021
|
if (typeof configured !== "undefined" && header.configured !== configured) {
|
|
7977
8022
|
changed = true;
|
|
7978
8023
|
return { ...header, configured };
|
|
@@ -8150,7 +8195,7 @@ function getTLSProps(config, onChange) {
|
|
|
8150
8195
|
return {
|
|
8151
8196
|
selfSignedCertificate: {
|
|
8152
8197
|
enabled: Boolean(config.jsonData.tlsAuthWithCACert),
|
|
8153
|
-
certificateConfigured: !!((_a = config.secureJsonFields) == null ?
|
|
8198
|
+
certificateConfigured: !!((_a = config.secureJsonFields) == null ? void 0 : _a.tlsCACert),
|
|
8154
8199
|
onToggle: (enabled) => enabled ? onChange({
|
|
8155
8200
|
...config,
|
|
8156
8201
|
jsonData: { ...config.jsonData, tlsAuthWithCACert: enabled }
|
|
@@ -8173,8 +8218,8 @@ function getTLSProps(config, onChange) {
|
|
|
8173
8218
|
TLSClientAuth: {
|
|
8174
8219
|
enabled: config.jsonData.tlsAuth,
|
|
8175
8220
|
serverName: config.jsonData.serverName,
|
|
8176
|
-
clientCertificateConfigured: !!((_b = config.secureJsonFields) == null ?
|
|
8177
|
-
clientKeyConfigured: !!((_c = config.secureJsonFields) == null ?
|
|
8221
|
+
clientCertificateConfigured: !!((_b = config.secureJsonFields) == null ? void 0 : _b.tlsClientCert),
|
|
8222
|
+
clientKeyConfigured: !!((_c = config.secureJsonFields) == null ? void 0 : _c.tlsClientKey),
|
|
8178
8223
|
onToggle: (enabled) => enabled ? onChange({
|
|
8179
8224
|
...config,
|
|
8180
8225
|
jsonData: { ...config.jsonData, tlsAuth: enabled }
|
|
@@ -8282,7 +8327,7 @@ const ConnectionSettings = ({
|
|
|
8282
8327
|
urlLabel,
|
|
8283
8328
|
className
|
|
8284
8329
|
}) => {
|
|
8285
|
-
const isValidUrl = config.url !==
|
|
8330
|
+
const isValidUrl = config.url !== void 0 && /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/.test(config.url);
|
|
8286
8331
|
const styles = {
|
|
8287
8332
|
container: css.css({
|
|
8288
8333
|
maxWidth: 578
|
|
@@ -8390,16 +8435,2102 @@ const AdvancedHttpSettings = ({
|
|
|
8390
8435
|
));
|
|
8391
8436
|
};
|
|
8392
8437
|
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8438
|
+
function resolveGroups(schema) {
|
|
8439
|
+
const fieldMap = /* @__PURE__ */ new Map();
|
|
8440
|
+
for (const f of schema.fields) {
|
|
8441
|
+
fieldMap.set(f.id, f);
|
|
8442
|
+
}
|
|
8443
|
+
if (schema.groups && schema.groups.length > 0) {
|
|
8444
|
+
return schema.groups.slice().sort((a, b) => {
|
|
8445
|
+
var _a, _b;
|
|
8446
|
+
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
8447
|
+
}).map((g) => ({
|
|
8448
|
+
group: g,
|
|
8449
|
+
fields: g.fieldRefs.map((ref) => fieldMap.get(ref)).filter((f) => f != null)
|
|
8450
|
+
}));
|
|
8451
|
+
}
|
|
8452
|
+
const allFields = schema.fields.filter((f) => f.kind !== "virtual" && !f.isItemField);
|
|
8453
|
+
return [
|
|
8454
|
+
{
|
|
8455
|
+
group: { id: "default", title: "Configuration", fieldRefs: allFields.map((f) => f.id) },
|
|
8456
|
+
fields: allFields
|
|
8457
|
+
}
|
|
8458
|
+
];
|
|
8459
|
+
}
|
|
8460
|
+
function resolveRequiredFieldsGroup(schema) {
|
|
8461
|
+
var _a;
|
|
8462
|
+
const fieldMap = /* @__PURE__ */ new Map();
|
|
8463
|
+
for (const f of schema.fields) {
|
|
8464
|
+
fieldMap.set(f.id, f);
|
|
8465
|
+
}
|
|
8466
|
+
const requiredIds = /* @__PURE__ */ new Set();
|
|
8467
|
+
for (const f of schema.fields) {
|
|
8468
|
+
if (f.required) {
|
|
8469
|
+
requiredIds.add(f.id);
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
const authGroup = (_a = schema.groups) == null ? void 0 : _a.find((g) => g.id === "auth");
|
|
8473
|
+
if (authGroup) {
|
|
8474
|
+
for (const ref of authGroup.fieldRefs) {
|
|
8475
|
+
if (fieldMap.has(ref)) {
|
|
8476
|
+
requiredIds.add(ref);
|
|
8477
|
+
}
|
|
8478
|
+
}
|
|
8479
|
+
}
|
|
8480
|
+
if (requiredIds.size === 0) {
|
|
8481
|
+
return null;
|
|
8482
|
+
}
|
|
8483
|
+
const includeIds = /* @__PURE__ */ new Set();
|
|
8484
|
+
for (const id of requiredIds) {
|
|
8485
|
+
includeIds.add(id);
|
|
8486
|
+
const f = fieldMap.get(id);
|
|
8487
|
+
if (f == null ? void 0 : f.dependsOn) {
|
|
8488
|
+
const parsed = parseDependsOn(f.dependsOn);
|
|
8489
|
+
if (parsed && fieldMap.has(parsed.field)) {
|
|
8490
|
+
includeIds.add(parsed.field);
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
}
|
|
8494
|
+
for (const f of schema.fields) {
|
|
8495
|
+
if (f.dependsOn && !includeIds.has(f.id)) {
|
|
8496
|
+
const parsed = parseDependsOn(f.dependsOn);
|
|
8497
|
+
if (parsed && requiredIds.has(parsed.field)) {
|
|
8498
|
+
includeIds.add(f.id);
|
|
8499
|
+
}
|
|
8500
|
+
}
|
|
8501
|
+
}
|
|
8502
|
+
const virtualFields = schema.fields.filter((f) => includeIds.has(f.id));
|
|
8503
|
+
if (virtualFields.length === 0) {
|
|
8504
|
+
return null;
|
|
8505
|
+
}
|
|
8506
|
+
return {
|
|
8507
|
+
group: {
|
|
8508
|
+
id: "_required",
|
|
8509
|
+
title: "Required",
|
|
8510
|
+
fieldRefs: virtualFields.map((f) => f.id)
|
|
8511
|
+
},
|
|
8512
|
+
fields: virtualFields
|
|
8513
|
+
};
|
|
8514
|
+
}
|
|
8515
|
+
function formKey(field) {
|
|
8516
|
+
return field.section ? `${field.section}.${field.key}` : field.key;
|
|
8517
|
+
}
|
|
8518
|
+
function parseDependsOn(expr) {
|
|
8519
|
+
var _a, _b;
|
|
8520
|
+
const m = expr.match(/^(.+?)\s*==\s*(?:'([^']*)'|"([^"]*)"|(.+))$/);
|
|
8521
|
+
if (!m) {
|
|
8522
|
+
return null;
|
|
8523
|
+
}
|
|
8524
|
+
return { field: m[1].trim(), value: ((_b = (_a = m[2]) != null ? _a : m[3]) != null ? _b : m[4]).trim() };
|
|
8525
|
+
}
|
|
8526
|
+
function resolveActiveOverride(field, watchedValues, fieldById) {
|
|
8527
|
+
var _a;
|
|
8528
|
+
if (!field.overrides || field.overrides.length === 0) {
|
|
8529
|
+
return void 0;
|
|
8530
|
+
}
|
|
8531
|
+
for (const ov of field.overrides) {
|
|
8532
|
+
const parsed = parseDependsOn(ov.when);
|
|
8533
|
+
if (!parsed) {
|
|
8534
|
+
continue;
|
|
8535
|
+
}
|
|
8536
|
+
const depField = fieldById.get(parsed.field);
|
|
8537
|
+
const depKey = depField ? formKey(depField) : parsed.field;
|
|
8538
|
+
if (String((_a = watchedValues[depKey]) != null ? _a : "") === parsed.value) {
|
|
8539
|
+
return ov;
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
return void 0;
|
|
8543
|
+
}
|
|
8544
|
+
function resolveFieldValue(ref, values, fields) {
|
|
8545
|
+
if (ref in values) {
|
|
8546
|
+
return values[ref];
|
|
8547
|
+
}
|
|
8548
|
+
const field = fields.find((f) => f.id === ref);
|
|
8549
|
+
if (field) {
|
|
8550
|
+
const fk = formKey(field);
|
|
8551
|
+
if (fk in values) {
|
|
8552
|
+
return values[fk];
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8555
|
+
return void 0;
|
|
8556
|
+
}
|
|
8557
|
+
function evaluateComputedRead(expr, values, fields) {
|
|
8558
|
+
function evalExpr(s) {
|
|
8559
|
+
var _a;
|
|
8560
|
+
s = s.trim();
|
|
8561
|
+
if (s.startsWith("(") && findMatchingParen(s, 0) === s.length - 1) {
|
|
8562
|
+
s = s.slice(1, -1).trim();
|
|
8563
|
+
}
|
|
8564
|
+
const qIdx = findTopLevel(s, "?");
|
|
8565
|
+
if (qIdx !== -1) {
|
|
8566
|
+
const condition = s.slice(0, qIdx).trim();
|
|
8567
|
+
const rest = s.slice(qIdx + 1);
|
|
8568
|
+
const cIdx = findTopLevel(rest, ":");
|
|
8569
|
+
if (cIdx !== -1) {
|
|
8570
|
+
const trueExpr = rest.slice(0, cIdx).trim();
|
|
8571
|
+
const falseExpr = rest.slice(cIdx + 1).trim();
|
|
8572
|
+
return evalCondition(condition) ? evalExpr(trueExpr) : evalExpr(falseExpr);
|
|
8573
|
+
}
|
|
8574
|
+
}
|
|
8575
|
+
const strMatch = (_a = s.match(/^'([^']*)'$/)) != null ? _a : s.match(/^"([^"]*)"$/);
|
|
8576
|
+
if (strMatch) {
|
|
8577
|
+
return strMatch[1];
|
|
8578
|
+
}
|
|
8579
|
+
if (s === "true") {
|
|
8580
|
+
return true;
|
|
8581
|
+
}
|
|
8582
|
+
if (s === "false") {
|
|
8583
|
+
return false;
|
|
8584
|
+
}
|
|
8585
|
+
if (/^-?\d+(\.\d+)?$/.test(s)) {
|
|
8586
|
+
return Number(s);
|
|
8587
|
+
}
|
|
8588
|
+
return resolveFieldValue(s, values, fields);
|
|
8589
|
+
}
|
|
8590
|
+
function evalCondition(cond) {
|
|
8591
|
+
const eqMatch = cond.match(/^(.+?)\s*(==|!=)\s*(.+)$/);
|
|
8592
|
+
if (eqMatch) {
|
|
8593
|
+
const left = evalExpr(eqMatch[1]);
|
|
8594
|
+
const right = evalExpr(eqMatch[3]);
|
|
8595
|
+
const eq = String(left) === String(right);
|
|
8596
|
+
return eqMatch[2] === "==" ? eq : !eq;
|
|
8597
|
+
}
|
|
8598
|
+
return !!evalExpr(cond);
|
|
8599
|
+
}
|
|
8600
|
+
function findMatchingParen(s, start) {
|
|
8601
|
+
let depth = 0;
|
|
8602
|
+
for (let i = start; i < s.length; i++) {
|
|
8603
|
+
if (s[i] === "(") {
|
|
8604
|
+
depth++;
|
|
8605
|
+
} else if (s[i] === ")") {
|
|
8606
|
+
depth--;
|
|
8607
|
+
if (depth === 0) {
|
|
8608
|
+
return i;
|
|
8609
|
+
}
|
|
8610
|
+
}
|
|
8611
|
+
}
|
|
8612
|
+
return -1;
|
|
8613
|
+
}
|
|
8614
|
+
function findTopLevel(s, char) {
|
|
8615
|
+
let depth = 0;
|
|
8616
|
+
let inStr = null;
|
|
8617
|
+
for (let i = 0; i < s.length; i++) {
|
|
8618
|
+
const c = s[i];
|
|
8619
|
+
if (inStr) {
|
|
8620
|
+
if (c === inStr) {
|
|
8621
|
+
inStr = null;
|
|
8622
|
+
}
|
|
8623
|
+
continue;
|
|
8624
|
+
}
|
|
8625
|
+
if (c === "'" || c === '"') {
|
|
8626
|
+
inStr = c;
|
|
8627
|
+
continue;
|
|
8628
|
+
}
|
|
8629
|
+
if (c === "(") {
|
|
8630
|
+
depth++;
|
|
8631
|
+
continue;
|
|
8632
|
+
}
|
|
8633
|
+
if (c === ")") {
|
|
8634
|
+
depth--;
|
|
8635
|
+
continue;
|
|
8636
|
+
}
|
|
8637
|
+
if (depth === 0 && c === char) {
|
|
8638
|
+
return i;
|
|
8639
|
+
}
|
|
8640
|
+
}
|
|
8641
|
+
return -1;
|
|
8642
|
+
}
|
|
8643
|
+
try {
|
|
8644
|
+
return evalExpr(expr);
|
|
8645
|
+
} catch (e) {
|
|
8646
|
+
return void 0;
|
|
8647
|
+
}
|
|
8648
|
+
}
|
|
8649
|
+
function computeVirtualFieldValues(schema, existingValues) {
|
|
8650
|
+
var _a;
|
|
8651
|
+
const virtualValues = {};
|
|
8652
|
+
for (const field of schema.fields) {
|
|
8653
|
+
if (field.kind !== "virtual") {
|
|
8654
|
+
continue;
|
|
8655
|
+
}
|
|
8656
|
+
const fk = formKey(field);
|
|
8657
|
+
if (((_a = field.storage) == null ? void 0 : _a.type) === "computed" && field.storage.read) {
|
|
8658
|
+
const val = evaluateComputedRead(field.storage.read, existingValues, schema.fields);
|
|
8659
|
+
if (val !== void 0) {
|
|
8660
|
+
virtualValues[fk] = val;
|
|
8661
|
+
} else if (field.defaultValue !== void 0) {
|
|
8662
|
+
virtualValues[fk] = field.defaultValue;
|
|
8663
|
+
}
|
|
8664
|
+
} else if (field.defaultValue !== void 0) {
|
|
8665
|
+
virtualValues[fk] = field.defaultValue;
|
|
8666
|
+
}
|
|
8667
|
+
}
|
|
8668
|
+
return virtualValues;
|
|
8669
|
+
}
|
|
8670
|
+
|
|
8671
|
+
const SECURE_FIELD_CONFIGURED = "__CONFIGURED__";
|
|
8672
|
+
function patternToRegex(pattern) {
|
|
8673
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8674
|
+
return new RegExp("^" + escaped.replace("\\{index\\}", "(\\d+)") + "$");
|
|
8675
|
+
}
|
|
8676
|
+
function findIndicesForPattern(record, pattern) {
|
|
8677
|
+
const re = patternToRegex(pattern);
|
|
8678
|
+
const indices = [];
|
|
8679
|
+
for (const key of Object.keys(record)) {
|
|
8680
|
+
const m = key.match(re);
|
|
8681
|
+
if (m) {
|
|
8682
|
+
const n = Number(m[1]);
|
|
8683
|
+
if (!Number.isNaN(n)) {
|
|
8684
|
+
indices.push(n);
|
|
8685
|
+
}
|
|
8686
|
+
}
|
|
8687
|
+
}
|
|
8688
|
+
return indices.sort((a, b) => a - b);
|
|
8689
|
+
}
|
|
8690
|
+
function expandIndexedPair(field, ds) {
|
|
8691
|
+
var _a, _b, _c;
|
|
8692
|
+
const storage = field.storage;
|
|
8693
|
+
if ((storage == null ? void 0 : storage.type) !== "indexedPair" || !storage.key || !storage.value) {
|
|
8694
|
+
return [];
|
|
8695
|
+
}
|
|
8696
|
+
const source = storage.key.target === "jsonData" ? (_a = ds.jsonData) != null ? _a : {} : ds;
|
|
8697
|
+
const indices = findIndicesForPattern(source, storage.key.pattern);
|
|
8698
|
+
const items = [];
|
|
8699
|
+
for (const i of indices) {
|
|
8700
|
+
const nameKey = storage.key.pattern.replace("{index}", String(i));
|
|
8701
|
+
const valueKey = storage.value.pattern.replace("{index}", String(i));
|
|
8702
|
+
const nameVal = source[nameKey];
|
|
8703
|
+
if (nameVal === void 0 || nameVal === null) {
|
|
8704
|
+
continue;
|
|
8705
|
+
}
|
|
8706
|
+
const hasValue = storage.value.target === "secureJsonData" ? !!((_b = ds.secureJsonFields) == null ? void 0 : _b[valueKey]) : !!((_c = ds.jsonData) == null ? void 0 : _c[valueKey]);
|
|
8707
|
+
items.push({
|
|
8708
|
+
index: i,
|
|
8709
|
+
name: String(nameVal),
|
|
8710
|
+
value: hasValue ? SECURE_FIELD_CONFIGURED : ""
|
|
8711
|
+
});
|
|
8712
|
+
}
|
|
8713
|
+
return items;
|
|
8714
|
+
}
|
|
8715
|
+
function flattenIndexedPair(field, items, jsonData, secureJsonData, secureJsonFields) {
|
|
8716
|
+
var _a;
|
|
8717
|
+
const storage = field.storage;
|
|
8718
|
+
if ((storage == null ? void 0 : storage.type) !== "indexedPair" || !storage.key || !storage.value) {
|
|
8719
|
+
return;
|
|
8720
|
+
}
|
|
8721
|
+
const existingIndices = new Set(
|
|
8722
|
+
storage.key.target === "jsonData" ? findIndicesForPattern(jsonData, storage.key.pattern) : []
|
|
8723
|
+
);
|
|
8724
|
+
const usedIndices = /* @__PURE__ */ new Set();
|
|
8725
|
+
const startIdx = (_a = storage.startIndex) != null ? _a : 1;
|
|
8726
|
+
let nextIndex = existingIndices.size > 0 ? Math.max(...existingIndices) + 1 : startIdx;
|
|
8727
|
+
for (const item of items) {
|
|
8728
|
+
let idx = item.index;
|
|
8729
|
+
if (idx === 0) {
|
|
8730
|
+
idx = nextIndex++;
|
|
8731
|
+
}
|
|
8732
|
+
usedIndices.add(idx);
|
|
8733
|
+
const nameKey = storage.key.pattern.replace("{index}", String(idx));
|
|
8734
|
+
const valueKey = storage.value.pattern.replace("{index}", String(idx));
|
|
8735
|
+
if (storage.key.target === "jsonData") {
|
|
8736
|
+
jsonData[nameKey] = item.name;
|
|
8737
|
+
}
|
|
8738
|
+
if (storage.value.target === "secureJsonData") {
|
|
8739
|
+
if (item.value === SECURE_FIELD_CONFIGURED) {
|
|
8740
|
+
secureJsonFields[valueKey] = true;
|
|
8741
|
+
} else if (item.value) {
|
|
8742
|
+
secureJsonData[valueKey] = item.value;
|
|
8743
|
+
secureJsonFields[valueKey] = false;
|
|
8744
|
+
}
|
|
8745
|
+
} else if (storage.value.target === "jsonData") {
|
|
8746
|
+
jsonData[valueKey] = item.value;
|
|
8747
|
+
}
|
|
8748
|
+
}
|
|
8749
|
+
for (const idx of existingIndices) {
|
|
8750
|
+
if (usedIndices.has(idx)) {
|
|
8751
|
+
continue;
|
|
8752
|
+
}
|
|
8753
|
+
const nameKey = storage.key.pattern.replace("{index}", String(idx));
|
|
8754
|
+
const valueKey = storage.value.pattern.replace("{index}", String(idx));
|
|
8755
|
+
if (storage.key.target === "jsonData") {
|
|
8756
|
+
delete jsonData[nameKey];
|
|
8757
|
+
}
|
|
8758
|
+
if (storage.value.target === "secureJsonData") {
|
|
8759
|
+
delete secureJsonFields[valueKey];
|
|
8760
|
+
delete secureJsonData[valueKey];
|
|
8761
|
+
} else if (storage.value.target === "jsonData") {
|
|
8762
|
+
delete jsonData[valueKey];
|
|
8763
|
+
}
|
|
8764
|
+
}
|
|
8765
|
+
}
|
|
8766
|
+
function resolveRawPath(ref, ds) {
|
|
8767
|
+
var _a;
|
|
8768
|
+
const trimmed = ref.trim();
|
|
8769
|
+
if (trimmed.startsWith("jsonData.")) {
|
|
8770
|
+
return (_a = ds.jsonData) == null ? void 0 : _a[trimmed.slice(9)];
|
|
8771
|
+
}
|
|
8772
|
+
if (trimmed.startsWith("root.")) {
|
|
8773
|
+
return ds[trimmed.slice(5)];
|
|
8774
|
+
}
|
|
8775
|
+
return void 0;
|
|
8776
|
+
}
|
|
8777
|
+
async function fetchExistingValues(dsUid, fields) {
|
|
8778
|
+
var _a, _b, _c, _d, _e;
|
|
8779
|
+
try {
|
|
8780
|
+
const ds = await runtime.getBackendSrv().get(`/api/datasources/uid/${dsUid}`, void 0, void 0, {
|
|
8781
|
+
showErrorAlert: false
|
|
8782
|
+
});
|
|
8783
|
+
const values = {};
|
|
8784
|
+
for (const field of fields) {
|
|
8785
|
+
if (((_a = field.storage) == null ? void 0 : _a.type) === "indexedPair") {
|
|
8786
|
+
values[field.key] = expandIndexedPair(field, ds);
|
|
8787
|
+
continue;
|
|
8788
|
+
}
|
|
8789
|
+
const fk = formKey(field);
|
|
8790
|
+
switch (field.target) {
|
|
8791
|
+
case "root":
|
|
8792
|
+
if (ds[field.key] !== void 0) {
|
|
8793
|
+
values[fk] = ds[field.key];
|
|
8794
|
+
}
|
|
8795
|
+
break;
|
|
8796
|
+
case "jsonData":
|
|
8797
|
+
if (field.section) {
|
|
8798
|
+
const sectionObj = (_b = ds.jsonData) == null ? void 0 : _b[field.section];
|
|
8799
|
+
if ((sectionObj == null ? void 0 : sectionObj[field.key]) !== void 0) {
|
|
8800
|
+
values[fk] = sectionObj[field.key];
|
|
8801
|
+
}
|
|
8802
|
+
} else if (((_c = ds.jsonData) == null ? void 0 : _c[field.key]) !== void 0) {
|
|
8803
|
+
values[fk] = ds.jsonData[field.key];
|
|
8804
|
+
}
|
|
8805
|
+
break;
|
|
8806
|
+
case "secureJsonData":
|
|
8807
|
+
if ((_d = ds.secureJsonFields) == null ? void 0 : _d[field.key]) {
|
|
8808
|
+
values[fk] = SECURE_FIELD_CONFIGURED;
|
|
8809
|
+
}
|
|
8810
|
+
break;
|
|
8811
|
+
}
|
|
8812
|
+
if (values[fk] === void 0 && ((_e = field.storage) == null ? void 0 : _e.type) === "computed" && field.storage.read) {
|
|
8813
|
+
const fallback = resolveRawPath(field.storage.read, ds);
|
|
8814
|
+
if (fallback !== void 0) {
|
|
8815
|
+
values[fk] = fallback;
|
|
8816
|
+
}
|
|
8817
|
+
}
|
|
8818
|
+
}
|
|
8819
|
+
return { values, readOnly: !!ds.readOnly };
|
|
8820
|
+
} catch (err) {
|
|
8821
|
+
const message = err instanceof Error ? err.message : "Failed to load datasource configuration";
|
|
8822
|
+
return { values: {}, readOnly: false, error: message };
|
|
8823
|
+
}
|
|
8824
|
+
}
|
|
8825
|
+
function buildDatasourceConfigPayload(data, fields, existing, isFieldVisible) {
|
|
8826
|
+
var _a, _b, _c, _d;
|
|
8827
|
+
const rootFields = {};
|
|
8828
|
+
const jsonData = { ...(_a = existing.jsonData) != null ? _a : {} };
|
|
8829
|
+
const secureJsonData = {};
|
|
8830
|
+
const secureJsonFields = { ...(_b = existing.secureJsonFields) != null ? _b : {} };
|
|
8831
|
+
for (const field of fields) {
|
|
8832
|
+
if (((_c = field.storage) == null ? void 0 : _c.type) === "indexedPair") {
|
|
8833
|
+
const items = Array.isArray(data[field.key]) ? data[field.key] : [];
|
|
8834
|
+
flattenIndexedPair(field, items, jsonData, secureJsonData, secureJsonFields);
|
|
8835
|
+
continue;
|
|
8836
|
+
}
|
|
8837
|
+
const isManagedByEffect = (_d = field.tags) == null ? void 0 : _d.some((t) => t.startsWith("managed-by:"));
|
|
8838
|
+
if (!isManagedByEffect && !isFieldVisible(field)) {
|
|
8839
|
+
continue;
|
|
8840
|
+
}
|
|
8841
|
+
const fk = formKey(field);
|
|
8842
|
+
const value = data[fk];
|
|
8843
|
+
if (field.target === "secureJsonData") {
|
|
8844
|
+
if (value === SECURE_FIELD_CONFIGURED) {
|
|
8845
|
+
secureJsonFields[field.key] = true;
|
|
8846
|
+
continue;
|
|
8847
|
+
}
|
|
8848
|
+
if (value && value !== "") {
|
|
8849
|
+
secureJsonData[field.key] = String(value);
|
|
8850
|
+
secureJsonFields[field.key] = false;
|
|
8851
|
+
} else {
|
|
8852
|
+
secureJsonFields[field.key] = false;
|
|
8853
|
+
}
|
|
8854
|
+
continue;
|
|
8855
|
+
}
|
|
8856
|
+
if (value === void 0 || value === "") {
|
|
8857
|
+
continue;
|
|
8858
|
+
}
|
|
8859
|
+
switch (field.target) {
|
|
8860
|
+
case "root":
|
|
8861
|
+
rootFields[field.key] = value;
|
|
8862
|
+
break;
|
|
8863
|
+
case "jsonData":
|
|
8864
|
+
if (field.section) {
|
|
8865
|
+
if (!jsonData[field.section] || typeof jsonData[field.section] !== "object") {
|
|
8866
|
+
jsonData[field.section] = {};
|
|
8867
|
+
}
|
|
8868
|
+
jsonData[field.section][field.key] = value;
|
|
8869
|
+
} else {
|
|
8870
|
+
jsonData[field.key] = value;
|
|
8871
|
+
}
|
|
8872
|
+
break;
|
|
8873
|
+
}
|
|
8874
|
+
}
|
|
8875
|
+
return { rootFields, jsonData, secureJsonData, secureJsonFields };
|
|
8876
|
+
}
|
|
8877
|
+
async function submitDatasourceConfig(dsUid, data, fields, isFieldVisible) {
|
|
8878
|
+
const existing = await runtime.getBackendSrv().get(`/api/datasources/uid/${dsUid}`);
|
|
8879
|
+
const { rootFields, jsonData, secureJsonData, secureJsonFields } = buildDatasourceConfigPayload(
|
|
8880
|
+
data,
|
|
8881
|
+
fields,
|
|
8882
|
+
existing,
|
|
8883
|
+
isFieldVisible
|
|
8884
|
+
);
|
|
8885
|
+
await runtime.getBackendSrv().put(`/api/datasources/uid/${dsUid}`, {
|
|
8886
|
+
...existing,
|
|
8887
|
+
...rootFields,
|
|
8888
|
+
jsonData,
|
|
8889
|
+
secureJsonData,
|
|
8890
|
+
secureJsonFields
|
|
8891
|
+
});
|
|
8892
|
+
}
|
|
8893
|
+
|
|
8894
|
+
function evaluateEffectCondition(when, fieldValue) {
|
|
8895
|
+
var _a, _b;
|
|
8896
|
+
const m = when.match(/^value\s*(==|!=)\s*(?:'([^']*)'|"([^"]*)"|(.+))$/);
|
|
8897
|
+
if (!m) {
|
|
8898
|
+
return false;
|
|
8899
|
+
}
|
|
8900
|
+
const op = m[1];
|
|
8901
|
+
let target = (_b = (_a = m[2]) != null ? _a : m[3]) != null ? _b : m[4];
|
|
8902
|
+
if (target === "true") {
|
|
8903
|
+
target = true;
|
|
8904
|
+
} else if (target === "false") {
|
|
8905
|
+
target = false;
|
|
8906
|
+
} else if (typeof target === "string" && /^-?\d+(\.\d+)?$/.test(target)) {
|
|
8907
|
+
target = Number(target);
|
|
8908
|
+
}
|
|
8909
|
+
const eq = String(fieldValue) === String(target);
|
|
8910
|
+
return op === "==" ? eq : !eq;
|
|
8911
|
+
}
|
|
8912
|
+
function isFieldRequired(field, watchedValues, fieldById) {
|
|
8913
|
+
var _a;
|
|
8914
|
+
if (field.required) {
|
|
8915
|
+
return true;
|
|
8916
|
+
}
|
|
8917
|
+
if (field.requiredWhen) {
|
|
8918
|
+
const parsed = parseDependsOn(field.requiredWhen);
|
|
8919
|
+
if (parsed) {
|
|
8920
|
+
const depField = fieldById.get(parsed.field);
|
|
8921
|
+
const depKey = depField ? formKey(depField) : parsed.field;
|
|
8922
|
+
return String((_a = watchedValues[depKey]) != null ? _a : "") === parsed.value;
|
|
8923
|
+
}
|
|
8924
|
+
}
|
|
8925
|
+
return false;
|
|
8926
|
+
}
|
|
8927
|
+
function buildValidationRules(field, required) {
|
|
8928
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8929
|
+
const rules = {};
|
|
8930
|
+
const label = (_a = field.label) != null ? _a : field.key;
|
|
8931
|
+
if (required) {
|
|
8932
|
+
if (field.target === "secureJsonData") {
|
|
8933
|
+
rules.validate = (value) => {
|
|
8934
|
+
if (value === SECURE_FIELD_CONFIGURED) {
|
|
8935
|
+
return true;
|
|
8936
|
+
}
|
|
8937
|
+
if (!value || value === "") {
|
|
8938
|
+
return `${label} is required`;
|
|
8939
|
+
}
|
|
8940
|
+
return true;
|
|
8941
|
+
};
|
|
8942
|
+
} else {
|
|
8943
|
+
rules.required = `${label} is required`;
|
|
8944
|
+
}
|
|
8945
|
+
}
|
|
8946
|
+
if (field.validations) {
|
|
8947
|
+
for (const v of field.validations) {
|
|
8948
|
+
switch (v.type) {
|
|
8949
|
+
case "pattern":
|
|
8950
|
+
rules.pattern = {
|
|
8951
|
+
value: new RegExp(v.pattern),
|
|
8952
|
+
message: (_b = v.message) != null ? _b : `Invalid ${label}`
|
|
8953
|
+
};
|
|
8954
|
+
break;
|
|
8955
|
+
case "range":
|
|
8956
|
+
if (v.min !== void 0) {
|
|
8957
|
+
rules.min = { value: v.min, message: (_c = v.message) != null ? _c : `Minimum value is ${v.min}` };
|
|
8958
|
+
}
|
|
8959
|
+
if (v.max !== void 0) {
|
|
8960
|
+
rules.max = { value: v.max, message: (_d = v.message) != null ? _d : `Maximum value is ${v.max}` };
|
|
8961
|
+
}
|
|
8962
|
+
break;
|
|
8963
|
+
case "length":
|
|
8964
|
+
if (v.min !== void 0) {
|
|
8965
|
+
rules.minLength = { value: v.min, message: (_e = v.message) != null ? _e : `Minimum length is ${v.min}` };
|
|
8966
|
+
}
|
|
8967
|
+
if (v.max !== void 0) {
|
|
8968
|
+
rules.maxLength = { value: v.max, message: (_f = v.message) != null ? _f : `Maximum length is ${v.max}` };
|
|
8969
|
+
}
|
|
8970
|
+
break;
|
|
8971
|
+
}
|
|
8972
|
+
}
|
|
8973
|
+
}
|
|
8974
|
+
return rules;
|
|
8975
|
+
}
|
|
8976
|
+
|
|
8977
|
+
function PdcFieldNote({
|
|
8978
|
+
enabled,
|
|
8979
|
+
description,
|
|
8980
|
+
configUrl
|
|
8981
|
+
}) {
|
|
8982
|
+
const styles = ui.useStyles2(getStyles$f);
|
|
8983
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.wrapper }, /* @__PURE__ */ React__default.default.createElement("div", { className: styles.note }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "shield", size: "xs" }), /* @__PURE__ */ React__default.default.createElement("span", null, "Private data source connect: ", /* @__PURE__ */ React__default.default.createElement("strong", null, enabled ? "Enabled" : "Disabled")), description && /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: description }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "info-circle", size: "xs" }))), /* @__PURE__ */ React__default.default.createElement(ui.LinkButton, { variant: "secondary", size: "sm", icon: "external-link-alt", href: configUrl }, "Configure in settings"));
|
|
8984
|
+
}
|
|
8985
|
+
const getStyles$f = (theme) => ({
|
|
8986
|
+
wrapper: css.css({
|
|
8987
|
+
display: "flex",
|
|
8988
|
+
alignItems: "center",
|
|
8989
|
+
justifyContent: "space-between",
|
|
8990
|
+
gap: theme.spacing(1),
|
|
8991
|
+
padding: `${theme.spacing(0.5)} ${theme.spacing(0.75)}`,
|
|
8992
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
8993
|
+
color: theme.colors.text.secondary,
|
|
8994
|
+
backgroundColor: theme.colors.background.secondary,
|
|
8995
|
+
borderRadius: theme.shape.radius.default,
|
|
8996
|
+
border: `1px solid ${theme.colors.border.weak}`
|
|
8997
|
+
}),
|
|
8998
|
+
note: css.css({
|
|
8999
|
+
display: "inline-flex",
|
|
9000
|
+
alignItems: "center",
|
|
9001
|
+
gap: theme.spacing(0.5)
|
|
9002
|
+
})
|
|
9003
|
+
});
|
|
9004
|
+
|
|
9005
|
+
function SecureFieldInput({
|
|
9006
|
+
formField,
|
|
9007
|
+
placeholder,
|
|
9008
|
+
disabled,
|
|
9009
|
+
label
|
|
9010
|
+
}) {
|
|
9011
|
+
var _a;
|
|
9012
|
+
const isConfigured = formField.value === SECURE_FIELD_CONFIGURED;
|
|
9013
|
+
const [revealed, setRevealed] = React.useState(false);
|
|
9014
|
+
const styles = ui.useStyles2(getSecureFieldStyles);
|
|
9015
|
+
if (isConfigured) {
|
|
9016
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.configuredRow }, /* @__PURE__ */ React__default.default.createElement("span", { className: styles.configuredBadge }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "lock", size: "xs" }), label, " configured"), !disabled && /* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "secondary", fill: "text", size: "sm", onClick: () => formField.onChange(""), type: "button" }, "Reset"));
|
|
9017
|
+
}
|
|
9018
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9019
|
+
ui.Input,
|
|
9020
|
+
{
|
|
9021
|
+
...formField,
|
|
9022
|
+
value: String((_a = formField.value) != null ? _a : ""),
|
|
9023
|
+
type: revealed ? "text" : "password",
|
|
9024
|
+
placeholder,
|
|
9025
|
+
disabled,
|
|
9026
|
+
suffix: /* @__PURE__ */ React__default.default.createElement(
|
|
9027
|
+
ui.Button,
|
|
9028
|
+
{
|
|
9029
|
+
variant: "secondary",
|
|
9030
|
+
fill: "text",
|
|
9031
|
+
size: "sm",
|
|
9032
|
+
icon: revealed ? "eye-slash" : "eye",
|
|
9033
|
+
"aria-label": revealed ? "Hide" : "Reveal",
|
|
9034
|
+
onClick: () => setRevealed((r) => !r),
|
|
9035
|
+
type: "button"
|
|
9036
|
+
}
|
|
9037
|
+
)
|
|
9038
|
+
}
|
|
9039
|
+
);
|
|
9040
|
+
}
|
|
9041
|
+
const getSecureFieldStyles = (theme) => ({
|
|
9042
|
+
configuredRow: css.css({
|
|
9043
|
+
display: "flex",
|
|
9044
|
+
alignItems: "center",
|
|
9045
|
+
gap: theme.spacing(1)
|
|
9046
|
+
}),
|
|
9047
|
+
configuredBadge: css.css({
|
|
9048
|
+
display: "inline-flex",
|
|
9049
|
+
alignItems: "center",
|
|
9050
|
+
gap: theme.spacing(0.5),
|
|
9051
|
+
padding: `${theme.spacing(0.25)} ${theme.spacing(0.75)}`,
|
|
9052
|
+
borderRadius: theme.shape.radius.pill,
|
|
9053
|
+
backgroundColor: theme.colors.success.transparent,
|
|
9054
|
+
color: theme.colors.success.text,
|
|
9055
|
+
fontSize: theme.typography.bodySmall.fontSize
|
|
9056
|
+
})
|
|
9057
|
+
});
|
|
9058
|
+
|
|
9059
|
+
function StringArrayInput({
|
|
9060
|
+
value,
|
|
9061
|
+
onChange,
|
|
9062
|
+
placeholder,
|
|
9063
|
+
disabled
|
|
9064
|
+
}) {
|
|
9065
|
+
const [draft, setDraft] = React.useState("");
|
|
9066
|
+
const styles = ui.useStyles2(getStyles$e);
|
|
9067
|
+
const addTag = () => {
|
|
9068
|
+
const trimmed = draft.trim();
|
|
9069
|
+
if (trimmed && !value.includes(trimmed)) {
|
|
9070
|
+
onChange([...value, trimmed]);
|
|
9071
|
+
}
|
|
9072
|
+
setDraft("");
|
|
9073
|
+
};
|
|
9074
|
+
const removeTag = (tag) => {
|
|
9075
|
+
onChange(value.filter((v) => v !== tag));
|
|
9076
|
+
};
|
|
9077
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, value.length > 0 && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.tags }, value.map((tag) => /* @__PURE__ */ React__default.default.createElement("span", { key: tag, className: styles.tag }, tag, !disabled && /* @__PURE__ */ React__default.default.createElement(
|
|
9078
|
+
"button",
|
|
9079
|
+
{
|
|
9080
|
+
type: "button",
|
|
9081
|
+
className: styles.tagRemove,
|
|
9082
|
+
onClick: () => removeTag(tag),
|
|
9083
|
+
"aria-label": `Remove ${tag}`
|
|
9084
|
+
},
|
|
9085
|
+
/* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "times", size: "xs" })
|
|
9086
|
+
)))), /* @__PURE__ */ React__default.default.createElement(
|
|
9087
|
+
ui.Input,
|
|
9088
|
+
{
|
|
9089
|
+
value: draft,
|
|
9090
|
+
onChange: (e) => setDraft(e.currentTarget.value),
|
|
9091
|
+
onKeyDown: (e) => {
|
|
9092
|
+
if (e.key === "Enter") {
|
|
9093
|
+
e.preventDefault();
|
|
9094
|
+
addTag();
|
|
9095
|
+
}
|
|
9096
|
+
},
|
|
9097
|
+
onBlur: addTag,
|
|
9098
|
+
placeholder,
|
|
9099
|
+
disabled
|
|
9100
|
+
}
|
|
9101
|
+
));
|
|
9102
|
+
}
|
|
9103
|
+
const getStyles$e = (theme) => ({
|
|
9104
|
+
container: css.css({
|
|
9105
|
+
display: "flex",
|
|
9106
|
+
flexDirection: "column",
|
|
9107
|
+
gap: theme.spacing(0.5)
|
|
9108
|
+
}),
|
|
9109
|
+
tags: css.css({
|
|
9110
|
+
display: "flex",
|
|
9111
|
+
flexWrap: "wrap",
|
|
9112
|
+
gap: theme.spacing(0.5)
|
|
9113
|
+
}),
|
|
9114
|
+
tag: css.css({
|
|
9115
|
+
display: "inline-flex",
|
|
9116
|
+
alignItems: "center",
|
|
9117
|
+
gap: theme.spacing(0.25),
|
|
9118
|
+
padding: `${theme.spacing(0.25)} ${theme.spacing(0.75)}`,
|
|
9119
|
+
borderRadius: theme.shape.radius.pill,
|
|
9120
|
+
backgroundColor: theme.colors.background.secondary,
|
|
9121
|
+
border: `1px solid ${theme.colors.border.weak}`,
|
|
9122
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9123
|
+
color: theme.colors.text.primary
|
|
9124
|
+
}),
|
|
9125
|
+
tagRemove: css.css({
|
|
9126
|
+
display: "inline-flex",
|
|
9127
|
+
alignItems: "center",
|
|
9128
|
+
padding: 0,
|
|
9129
|
+
border: "none",
|
|
9130
|
+
backgroundColor: "transparent",
|
|
9131
|
+
cursor: "pointer",
|
|
9132
|
+
color: theme.colors.text.secondary,
|
|
9133
|
+
"&:hover": { color: theme.colors.text.primary }
|
|
9134
|
+
})
|
|
9135
|
+
});
|
|
9136
|
+
|
|
9137
|
+
function IndexedPairRow({
|
|
9138
|
+
item,
|
|
9139
|
+
index,
|
|
9140
|
+
disabled,
|
|
9141
|
+
onUpdate,
|
|
9142
|
+
onRemove,
|
|
9143
|
+
hideControls
|
|
9144
|
+
}) {
|
|
9145
|
+
const styles = ui.useStyles2(getStyles$d);
|
|
9146
|
+
const secureStyles = ui.useStyles2(getSecureFieldStyles);
|
|
9147
|
+
const isConfigured = item.value === SECURE_FIELD_CONFIGURED;
|
|
9148
|
+
const [editing, setEditing] = React.useState(false);
|
|
9149
|
+
const [revealed, setRevealed] = React.useState(false);
|
|
9150
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { direction: "row", gap: 1 }, /* @__PURE__ */ React__default.default.createElement("div", { className: styles.inputCell }, /* @__PURE__ */ React__default.default.createElement(
|
|
9151
|
+
ui.Input,
|
|
9152
|
+
{
|
|
9153
|
+
value: item.name,
|
|
9154
|
+
placeholder: "Header name",
|
|
9155
|
+
disabled: disabled || hideControls,
|
|
9156
|
+
onChange: (e) => onUpdate(index, "name", e.currentTarget.value)
|
|
9157
|
+
}
|
|
9158
|
+
)), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.inputCell }, isConfigured && !editing ? /* @__PURE__ */ React__default.default.createElement(ui.Stack, { direction: "row", gap: 1, alignItems: "center" }, /* @__PURE__ */ React__default.default.createElement("span", { className: secureStyles.configuredBadge }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "lock", size: "xs" }), "Configured"), !disabled && /* @__PURE__ */ React__default.default.createElement(
|
|
9159
|
+
ui.Button,
|
|
9160
|
+
{
|
|
9161
|
+
variant: "secondary",
|
|
9162
|
+
fill: "text",
|
|
9163
|
+
size: "sm",
|
|
9164
|
+
onClick: () => {
|
|
9165
|
+
setEditing(true);
|
|
9166
|
+
onUpdate(index, "value", "");
|
|
9167
|
+
},
|
|
9168
|
+
type: "button"
|
|
9169
|
+
},
|
|
9170
|
+
"Reset"
|
|
9171
|
+
)) : /* @__PURE__ */ React__default.default.createElement(
|
|
9172
|
+
ui.Input,
|
|
9173
|
+
{
|
|
9174
|
+
value: item.value === SECURE_FIELD_CONFIGURED ? "" : item.value,
|
|
9175
|
+
placeholder: "Header value",
|
|
9176
|
+
disabled,
|
|
9177
|
+
type: revealed ? "text" : "password",
|
|
9178
|
+
onChange: (e) => onUpdate(index, "value", e.currentTarget.value),
|
|
9179
|
+
suffix: /* @__PURE__ */ React__default.default.createElement(
|
|
9180
|
+
ui.Button,
|
|
9181
|
+
{
|
|
9182
|
+
variant: "secondary",
|
|
9183
|
+
fill: "text",
|
|
9184
|
+
size: "sm",
|
|
9185
|
+
icon: revealed ? "eye-slash" : "eye",
|
|
9186
|
+
"aria-label": revealed ? "Hide" : "Reveal",
|
|
9187
|
+
onClick: () => setRevealed((r) => !r),
|
|
9188
|
+
type: "button"
|
|
9189
|
+
}
|
|
9190
|
+
)
|
|
9191
|
+
}
|
|
9192
|
+
)), !hideControls && /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: "Remove header" }, /* @__PURE__ */ React__default.default.createElement(
|
|
9193
|
+
ui.Button,
|
|
9194
|
+
{
|
|
9195
|
+
variant: "secondary",
|
|
9196
|
+
fill: "text",
|
|
9197
|
+
size: "sm",
|
|
9198
|
+
icon: "trash-alt",
|
|
9199
|
+
"aria-label": "Remove header",
|
|
9200
|
+
disabled,
|
|
9201
|
+
onClick: () => onRemove(index),
|
|
9202
|
+
type: "button"
|
|
9203
|
+
}
|
|
9204
|
+
)));
|
|
9205
|
+
}
|
|
9206
|
+
function IndexedPairEditor({
|
|
9207
|
+
value,
|
|
9208
|
+
onChange,
|
|
9209
|
+
maxItems = 10,
|
|
9210
|
+
disabled,
|
|
9211
|
+
hideControls
|
|
9212
|
+
}) {
|
|
9213
|
+
const styles = ui.useStyles2(getStyles$d);
|
|
9214
|
+
const items = Array.isArray(value) ? value : [];
|
|
9215
|
+
const addItem = () => {
|
|
9216
|
+
if (items.length >= maxItems) {
|
|
9217
|
+
return;
|
|
9218
|
+
}
|
|
9219
|
+
onChange([...items, { index: 0, name: "", value: "" }]);
|
|
9220
|
+
};
|
|
9221
|
+
const removeItem = (index) => {
|
|
9222
|
+
onChange(items.filter((_, i) => i !== index));
|
|
9223
|
+
};
|
|
9224
|
+
const updateItem = (index, key, val) => {
|
|
9225
|
+
const updated = items.map((item, i) => i === index ? { ...item, [key]: val } : item);
|
|
9226
|
+
onChange(updated);
|
|
9227
|
+
};
|
|
9228
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { direction: "column", gap: 0.5 }, items.map((item, i) => /* @__PURE__ */ React__default.default.createElement(
|
|
9229
|
+
IndexedPairRow,
|
|
9230
|
+
{
|
|
9231
|
+
key: item.index || `new-${i}`,
|
|
9232
|
+
item,
|
|
9233
|
+
index: i,
|
|
9234
|
+
disabled,
|
|
9235
|
+
onUpdate: updateItem,
|
|
9236
|
+
onRemove: removeItem,
|
|
9237
|
+
hideControls
|
|
9238
|
+
}
|
|
9239
|
+
)), !hideControls && items.length < maxItems && /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "secondary", size: "sm", icon: "plus", disabled, onClick: addItem, type: "button" }, "Add header")), !hideControls && items.length >= maxItems && /* @__PURE__ */ React__default.default.createElement("span", { className: styles.limitNote }, "Maximum ", maxItems, " headers reached"));
|
|
9240
|
+
}
|
|
9241
|
+
const getStyles$d = (theme) => ({
|
|
9242
|
+
inputCell: css.css({
|
|
9243
|
+
flex: "1 1 0",
|
|
9244
|
+
minWidth: 0,
|
|
9245
|
+
overflow: "hidden"
|
|
9246
|
+
}),
|
|
9247
|
+
limitNote: css.css({
|
|
9248
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9249
|
+
color: theme.colors.text.secondary
|
|
9250
|
+
})
|
|
9251
|
+
});
|
|
9252
|
+
|
|
9253
|
+
function ComplexFieldNote({ count, label }) {
|
|
9254
|
+
const styles = ui.useStyles2(getStyles$c);
|
|
9255
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.note }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "info-circle", size: "xs" }), /* @__PURE__ */ React__default.default.createElement("span", null, count > 0 ? `${count} ${label.toLowerCase()} configured.` : `No ${label.toLowerCase()} configured.`, " Configure in Grafana UI."));
|
|
9256
|
+
}
|
|
9257
|
+
const getStyles$c = (theme) => ({
|
|
9258
|
+
note: css.css({
|
|
9259
|
+
display: "inline-flex",
|
|
9260
|
+
alignItems: "center",
|
|
9261
|
+
gap: theme.spacing(0.5),
|
|
9262
|
+
padding: `${theme.spacing(0.5)} ${theme.spacing(0.75)}`,
|
|
9263
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9264
|
+
color: theme.colors.text.secondary,
|
|
9265
|
+
backgroundColor: theme.colors.background.secondary,
|
|
9266
|
+
borderRadius: theme.shape.radius.default,
|
|
9267
|
+
border: `1px solid ${theme.colors.border.weak}`
|
|
9268
|
+
})
|
|
9269
|
+
});
|
|
9270
|
+
|
|
9271
|
+
function renderFieldInput(field, formField, disabled) {
|
|
9272
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
9273
|
+
const value = formField.value;
|
|
9274
|
+
const placeholder = (_a = field.ui) == null ? void 0 : _a.placeholder;
|
|
9275
|
+
const label = (_b = field.label) != null ? _b : field.key;
|
|
9276
|
+
if (field.target === "secureJsonData" || field.semanticType === "password" || field.semanticType === "token") {
|
|
9277
|
+
return /* @__PURE__ */ React__default.default.createElement(SecureFieldInput, { formField, placeholder: placeholder != null ? placeholder : label, disabled, label });
|
|
9278
|
+
}
|
|
9279
|
+
if (field.valueType === "boolean") {
|
|
9280
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Switch, { value: !!value, onChange: (e) => formField.onChange(e.currentTarget.checked), disabled });
|
|
9281
|
+
}
|
|
9282
|
+
if (field.valueType === "number") {
|
|
9283
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9284
|
+
ui.Input,
|
|
9285
|
+
{
|
|
9286
|
+
...formField,
|
|
9287
|
+
value: value !== void 0 && value !== null ? Number(value) : "",
|
|
9288
|
+
type: "number",
|
|
9289
|
+
placeholder,
|
|
9290
|
+
disabled,
|
|
9291
|
+
onChange: (e) => {
|
|
9292
|
+
const n = e.currentTarget.valueAsNumber;
|
|
9293
|
+
formField.onChange(Number.isNaN(n) ? void 0 : n);
|
|
9294
|
+
}
|
|
9295
|
+
}
|
|
9296
|
+
);
|
|
9297
|
+
}
|
|
9298
|
+
if (((_c = field.ui) == null ? void 0 : _c.component) === "radio") {
|
|
9299
|
+
const options = ((_e = (_d = field.ui) == null ? void 0 : _d.options) != null ? _e : []).map((opt) => ({
|
|
9300
|
+
label: opt.label,
|
|
9301
|
+
value: String(opt.value),
|
|
9302
|
+
description: opt.description
|
|
9303
|
+
}));
|
|
9304
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { style: { display: "flex" } }, /* @__PURE__ */ React__default.default.createElement(
|
|
9305
|
+
ui.RadioButtonGroup,
|
|
9306
|
+
{
|
|
9307
|
+
options,
|
|
9308
|
+
value: String(value != null ? value : ""),
|
|
9309
|
+
onChange: (v) => formField.onChange(v),
|
|
9310
|
+
disabled
|
|
9311
|
+
}
|
|
9312
|
+
));
|
|
9313
|
+
}
|
|
9314
|
+
if (((_f = field.ui) == null ? void 0 : _f.component) === "select") {
|
|
9315
|
+
const options = ((_h = (_g = field.ui) == null ? void 0 : _g.options) != null ? _h : []).map((opt) => ({
|
|
9316
|
+
label: opt.label,
|
|
9317
|
+
value: String(opt.value),
|
|
9318
|
+
description: opt.description
|
|
9319
|
+
}));
|
|
9320
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9321
|
+
ui.Select,
|
|
9322
|
+
{
|
|
9323
|
+
options,
|
|
9324
|
+
value: options.find((o) => o.value === String(value != null ? value : "")),
|
|
9325
|
+
onChange: (v) => formField.onChange(v == null ? void 0 : v.value),
|
|
9326
|
+
disabled
|
|
9327
|
+
}
|
|
9328
|
+
);
|
|
9329
|
+
}
|
|
9330
|
+
if (field.semanticType === "url") {
|
|
9331
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Input, { ...formField, value: String(value != null ? value : ""), type: "url", placeholder, disabled });
|
|
9332
|
+
}
|
|
9333
|
+
if (((_i = field.ui) == null ? void 0 : _i.component) === "textarea") {
|
|
9334
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9335
|
+
ui.TextArea,
|
|
9336
|
+
{
|
|
9337
|
+
...formField,
|
|
9338
|
+
value: String(value != null ? value : ""),
|
|
9339
|
+
placeholder,
|
|
9340
|
+
disabled,
|
|
9341
|
+
rows: (_k = (_j = field.ui) == null ? void 0 : _j.rows) != null ? _k : 3
|
|
9342
|
+
}
|
|
9343
|
+
);
|
|
9344
|
+
}
|
|
9345
|
+
if (field.valueType === "array" && ((_l = field.item) == null ? void 0 : _l.valueType) === "string") {
|
|
9346
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9347
|
+
StringArrayInput,
|
|
9348
|
+
{
|
|
9349
|
+
value: Array.isArray(value) ? value : [],
|
|
9350
|
+
onChange: formField.onChange,
|
|
9351
|
+
placeholder: placeholder != null ? placeholder : `Add ${label.toLowerCase()}\u2026`,
|
|
9352
|
+
disabled
|
|
9353
|
+
}
|
|
9354
|
+
);
|
|
9355
|
+
}
|
|
9356
|
+
if (((_m = field.storage) == null ? void 0 : _m.type) === "indexedPair") {
|
|
9357
|
+
const items = Array.isArray(value) ? value : [];
|
|
9358
|
+
const maxItems = (_p = (_o = (_n = field.validations) == null ? void 0 : _n.find((v) => v.type === "itemCount")) == null ? void 0 : _o.max) != null ? _p : 10;
|
|
9359
|
+
return /* @__PURE__ */ React__default.default.createElement(IndexedPairEditor, { value: items, onChange: formField.onChange, maxItems, disabled });
|
|
9360
|
+
}
|
|
9361
|
+
if (field.valueType === "object" || field.valueType === "map" || field.valueType === "array" && (((_q = field.item) == null ? void 0 : _q.valueType) === "object" || ((_r = field.item) == null ? void 0 : _r.valueType) === "map")) {
|
|
9362
|
+
const count = Array.isArray(value) ? value.length : 0;
|
|
9363
|
+
return /* @__PURE__ */ React__default.default.createElement(ComplexFieldNote, { count, label });
|
|
9364
|
+
}
|
|
9365
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Input, { ...formField, value: String(value != null ? value : ""), placeholder, disabled });
|
|
9366
|
+
}
|
|
9367
|
+
|
|
9368
|
+
const getWizardStyles = (theme) => ({
|
|
9369
|
+
container: css.css({
|
|
9370
|
+
position: "relative",
|
|
9371
|
+
display: "flex",
|
|
9372
|
+
flexDirection: "column",
|
|
9373
|
+
gap: theme.spacing(1),
|
|
9374
|
+
padding: theme.spacing(1.5),
|
|
9375
|
+
backgroundColor: theme.colors.background.secondary,
|
|
9376
|
+
borderRadius: theme.shape.radius.default,
|
|
9377
|
+
border: `1px solid ${theme.colors.border.weak}`,
|
|
9378
|
+
overflow: "hidden"
|
|
9379
|
+
}),
|
|
9380
|
+
overlay: css.css({
|
|
9381
|
+
position: "absolute",
|
|
9382
|
+
inset: 0,
|
|
9383
|
+
display: "flex",
|
|
9384
|
+
alignItems: "center",
|
|
9385
|
+
justifyContent: "center",
|
|
9386
|
+
gap: theme.spacing(1),
|
|
9387
|
+
background: theme.colors.background.secondary,
|
|
9388
|
+
borderRadius: theme.shape.radius.default,
|
|
9389
|
+
zIndex: 1,
|
|
9390
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9391
|
+
color: theme.colors.text.primary,
|
|
9392
|
+
opacity: 0.95
|
|
9393
|
+
}),
|
|
9394
|
+
readOnlyBanner: css.css({
|
|
9395
|
+
display: "inline-flex",
|
|
9396
|
+
alignItems: "center",
|
|
9397
|
+
gap: theme.spacing(0.5),
|
|
9398
|
+
padding: `${theme.spacing(0.25)} ${theme.spacing(0.75)}`,
|
|
9399
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9400
|
+
color: theme.colors.text.secondary,
|
|
9401
|
+
backgroundColor: theme.colors.background.secondary,
|
|
9402
|
+
borderRadius: theme.shape.radius.default,
|
|
9403
|
+
border: `1px solid ${theme.colors.border.weak}`
|
|
9404
|
+
}),
|
|
9405
|
+
navBar: css.css({
|
|
9406
|
+
display: "flex",
|
|
9407
|
+
alignItems: "center",
|
|
9408
|
+
justifyContent: "space-between"
|
|
9409
|
+
}),
|
|
9410
|
+
navTitle: css.css({
|
|
9411
|
+
display: "inline-flex",
|
|
9412
|
+
alignItems: "center",
|
|
9413
|
+
gap: theme.spacing(0.5),
|
|
9414
|
+
fontSize: theme.typography.body.fontSize,
|
|
9415
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
9416
|
+
color: theme.colors.text.primary
|
|
9417
|
+
}),
|
|
9418
|
+
stepCount: css.css({
|
|
9419
|
+
fontSize: "11px",
|
|
9420
|
+
fontWeight: "normal",
|
|
9421
|
+
color: theme.colors.text.secondary
|
|
9422
|
+
}),
|
|
9423
|
+
navActions: css.css({
|
|
9424
|
+
display: "flex",
|
|
9425
|
+
alignItems: "center",
|
|
9426
|
+
gap: theme.spacing(0.25)
|
|
9427
|
+
}),
|
|
9428
|
+
form: css.css({
|
|
9429
|
+
display: "flex",
|
|
9430
|
+
flexDirection: "column",
|
|
9431
|
+
gap: theme.spacing(0.75)
|
|
9432
|
+
}),
|
|
9433
|
+
buttons: css.css({
|
|
9434
|
+
display: "flex",
|
|
9435
|
+
gap: theme.spacing(1),
|
|
9436
|
+
paddingTop: theme.spacing(0.25)
|
|
9437
|
+
}),
|
|
9438
|
+
fieldRow: css.css({
|
|
9439
|
+
display: "grid",
|
|
9440
|
+
gridTemplateColumns: "minmax(80px, 1fr) minmax(0, 2fr)",
|
|
9441
|
+
gap: theme.spacing(0.75),
|
|
9442
|
+
alignItems: "start"
|
|
9443
|
+
}),
|
|
9444
|
+
fieldRowCenter: css.css({
|
|
9445
|
+
display: "grid",
|
|
9446
|
+
gridTemplateColumns: "minmax(80px, 1fr) minmax(0, 2fr)",
|
|
9447
|
+
gap: theme.spacing(0.75),
|
|
9448
|
+
alignItems: "center",
|
|
9449
|
+
padding: `${theme.spacing(0.5)} 0`
|
|
9450
|
+
}),
|
|
9451
|
+
fieldLabelRow: css.css({
|
|
9452
|
+
display: "flex",
|
|
9453
|
+
alignItems: "center",
|
|
9454
|
+
gap: theme.spacing(0.5),
|
|
9455
|
+
paddingTop: theme.spacing(0.5)
|
|
9456
|
+
}),
|
|
9457
|
+
fieldLabelRowCompact: css.css({
|
|
9458
|
+
display: "flex",
|
|
9459
|
+
alignItems: "center",
|
|
9460
|
+
gap: theme.spacing(0.5)
|
|
9461
|
+
}),
|
|
9462
|
+
fieldLabel: css.css({
|
|
9463
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9464
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
9465
|
+
color: theme.colors.text.primary
|
|
9466
|
+
}),
|
|
9467
|
+
fieldRequired: css.css({
|
|
9468
|
+
color: theme.colors.error.text,
|
|
9469
|
+
marginLeft: 2
|
|
9470
|
+
}),
|
|
9471
|
+
fieldInfoIcon: css.css({
|
|
9472
|
+
color: theme.colors.text.disabled,
|
|
9473
|
+
cursor: "help",
|
|
9474
|
+
flexShrink: 0
|
|
9475
|
+
}),
|
|
9476
|
+
fieldInputCol: css.css({
|
|
9477
|
+
display: "flex",
|
|
9478
|
+
flexDirection: "column",
|
|
9479
|
+
gap: theme.spacing(0.25),
|
|
9480
|
+
minWidth: 0
|
|
9481
|
+
}),
|
|
9482
|
+
fieldError: css.css({
|
|
9483
|
+
fontSize: "11px",
|
|
9484
|
+
color: theme.colors.error.text
|
|
9485
|
+
})
|
|
9486
|
+
});
|
|
9487
|
+
|
|
9488
|
+
function SchemaField({ field, control, errors, disabled, dsUid, watchedValues, fieldById }) {
|
|
9489
|
+
const styles = ui.useStyles2(getWizardStyles);
|
|
9490
|
+
const activeOverride = resolveActiveOverride(field, watchedValues, fieldById);
|
|
9491
|
+
const fk = formKey(field);
|
|
9492
|
+
if (field.key === "pdcInjected" && field.target === "jsonData") {
|
|
9493
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9494
|
+
reactHookForm.Controller,
|
|
9495
|
+
{
|
|
9496
|
+
name: fk,
|
|
9497
|
+
control,
|
|
9498
|
+
render: ({ field: formField }) => /* @__PURE__ */ React__default.default.createElement(
|
|
9499
|
+
PdcFieldNote,
|
|
9500
|
+
{
|
|
9501
|
+
enabled: !!formField.value,
|
|
9502
|
+
description: field.description,
|
|
9503
|
+
configUrl: `/connections/datasources/edit/${dsUid}`
|
|
9504
|
+
}
|
|
9505
|
+
)
|
|
9506
|
+
}
|
|
9507
|
+
);
|
|
9508
|
+
}
|
|
9509
|
+
const required = isFieldRequired(field, watchedValues, fieldById);
|
|
9510
|
+
const validationRules = buildValidationRules(field, required);
|
|
9511
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9512
|
+
reactHookForm.Controller,
|
|
9513
|
+
{
|
|
9514
|
+
name: fk,
|
|
9515
|
+
control,
|
|
9516
|
+
rules: validationRules,
|
|
9517
|
+
render: ({ field: formField }) => {
|
|
9518
|
+
var _a, _b, _c, _d, _e;
|
|
9519
|
+
const errorMessage = (_a = errors[fk]) == null ? void 0 : _a.message;
|
|
9520
|
+
const label = (_b = field.label) != null ? _b : field.key;
|
|
9521
|
+
const description = (_c = activeOverride == null ? void 0 : activeOverride.description) != null ? _c : field.description;
|
|
9522
|
+
const effectiveField = activeOverride ? {
|
|
9523
|
+
...field,
|
|
9524
|
+
ui: {
|
|
9525
|
+
...field.ui,
|
|
9526
|
+
placeholder: (_e = activeOverride.placeholder) != null ? _e : (_d = field.ui) == null ? void 0 : _d.placeholder
|
|
9527
|
+
}
|
|
9528
|
+
} : field;
|
|
9529
|
+
const isReadOnly = !!(activeOverride == null ? void 0 : activeOverride.readOnly);
|
|
9530
|
+
const isBool = field.valueType === "boolean";
|
|
9531
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: isBool ? styles.fieldRowCenter : styles.fieldRow }, /* @__PURE__ */ React__default.default.createElement("div", { className: isBool ? styles.fieldLabelRowCompact : styles.fieldLabelRow }, /* @__PURE__ */ React__default.default.createElement("span", { className: styles.fieldLabel }, label, required && /* @__PURE__ */ React__default.default.createElement("span", { className: styles.fieldRequired }, "*")), description && /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: description }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "info-circle", size: "xs", className: styles.fieldInfoIcon }))), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.fieldInputCol }, renderFieldInput(effectiveField, formField, disabled || isReadOnly), errorMessage && /* @__PURE__ */ React__default.default.createElement("span", { className: styles.fieldError }, errorMessage)));
|
|
9532
|
+
}
|
|
9533
|
+
}
|
|
9534
|
+
);
|
|
9535
|
+
}
|
|
9536
|
+
|
|
9537
|
+
function AuthorizationHeaderField({
|
|
9538
|
+
headersFieldKey,
|
|
9539
|
+
control,
|
|
9540
|
+
disabled,
|
|
9541
|
+
watchedValues
|
|
9542
|
+
}) {
|
|
9543
|
+
const styles = ui.useStyles2(getWizardStyles);
|
|
9544
|
+
const items = React.useMemo(
|
|
9545
|
+
() => Array.isArray(watchedValues[headersFieldKey]) ? watchedValues[headersFieldKey] : [],
|
|
9546
|
+
[watchedValues, headersFieldKey]
|
|
9547
|
+
);
|
|
9548
|
+
const authEntries = React.useMemo(() => {
|
|
9549
|
+
const entries = [];
|
|
9550
|
+
for (let i = 0; i < items.length; i++) {
|
|
9551
|
+
if (items[i].name.toLowerCase() === "authorization") {
|
|
9552
|
+
entries.push({ item: items[i], originalIdx: i });
|
|
9553
|
+
}
|
|
9554
|
+
}
|
|
9555
|
+
return entries;
|
|
9556
|
+
}, [items]);
|
|
9557
|
+
if (authEntries.length === 0) {
|
|
9558
|
+
return null;
|
|
9559
|
+
}
|
|
9560
|
+
const authItems = authEntries.map((e) => e.item);
|
|
9561
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9562
|
+
reactHookForm.Controller,
|
|
9563
|
+
{
|
|
9564
|
+
name: headersFieldKey,
|
|
9565
|
+
control,
|
|
9566
|
+
render: ({ field: formField }) => {
|
|
9567
|
+
const handleChange = (updatedAuthItems) => {
|
|
9568
|
+
const updated = [...items];
|
|
9569
|
+
for (let i = 0; i < authEntries.length; i++) {
|
|
9570
|
+
if (i < updatedAuthItems.length) {
|
|
9571
|
+
updated[authEntries[i].originalIdx] = updatedAuthItems[i];
|
|
9572
|
+
}
|
|
9573
|
+
}
|
|
9574
|
+
formField.onChange(updated);
|
|
9575
|
+
};
|
|
9576
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.fieldRow }, /* @__PURE__ */ React__default.default.createElement("div", { className: styles.fieldLabelRow }, /* @__PURE__ */ React__default.default.createElement("span", { className: styles.fieldLabel }, "Custom HTTP Headers"), /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: "Authorization HTTP header(s) sent with every request." }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "info-circle", size: "xs", className: styles.fieldInfoIcon }))), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.fieldInputCol }, /* @__PURE__ */ React__default.default.createElement(IndexedPairEditor, { value: authItems, onChange: handleChange, disabled, hideControls: true })));
|
|
9577
|
+
}
|
|
9578
|
+
}
|
|
9579
|
+
);
|
|
9580
|
+
}
|
|
9581
|
+
|
|
9582
|
+
const getTabStyles = (theme) => ({
|
|
9583
|
+
root: css.css({
|
|
9584
|
+
display: "flex",
|
|
9585
|
+
gap: theme.spacing(3),
|
|
9586
|
+
position: "relative",
|
|
9587
|
+
background: theme.colors.background.canvas,
|
|
9588
|
+
padding: theme.spacing(2)
|
|
9589
|
+
}),
|
|
9590
|
+
// Sidebar
|
|
9591
|
+
sidebar: css.css({
|
|
9592
|
+
width: 250,
|
|
9593
|
+
flexShrink: 0,
|
|
9594
|
+
position: "sticky",
|
|
9595
|
+
top: theme.spacing(2),
|
|
9596
|
+
alignSelf: "flex-start",
|
|
9597
|
+
[theme.breakpoints.down("sm")]: { display: "none" }
|
|
9598
|
+
}),
|
|
9599
|
+
sidebarTitle: css.css({
|
|
9600
|
+
fontSize: theme.typography.body.fontSize,
|
|
9601
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
9602
|
+
color: theme.colors.text.primary,
|
|
9603
|
+
padding: `${theme.spacing(1)} 0`,
|
|
9604
|
+
marginBottom: theme.spacing(1)
|
|
9605
|
+
}),
|
|
9606
|
+
navList: css.css({
|
|
9607
|
+
listStyle: "none",
|
|
9608
|
+
margin: 0,
|
|
9609
|
+
padding: 0,
|
|
9610
|
+
position: "relative"
|
|
9611
|
+
}),
|
|
9612
|
+
navItem: css.css({
|
|
9613
|
+
display: "flex",
|
|
9614
|
+
alignItems: "flex-start",
|
|
9615
|
+
gap: theme.spacing(1.5),
|
|
9616
|
+
padding: `${theme.spacing(1)} 0`,
|
|
9617
|
+
cursor: "pointer",
|
|
9618
|
+
position: "relative"
|
|
9619
|
+
}),
|
|
9620
|
+
navItemActive: css.css({}),
|
|
9621
|
+
// Dot container: positions the dot and the connector line
|
|
9622
|
+
navDotWrap: css.css({
|
|
9623
|
+
position: "relative",
|
|
9624
|
+
display: "flex",
|
|
9625
|
+
alignItems: "center",
|
|
9626
|
+
justifyContent: "center",
|
|
9627
|
+
width: 12,
|
|
9628
|
+
flexShrink: 0,
|
|
9629
|
+
alignSelf: "flex-start",
|
|
9630
|
+
paddingTop: 4
|
|
9631
|
+
}),
|
|
9632
|
+
navDot: css.css({
|
|
9633
|
+
width: 10,
|
|
9634
|
+
height: 10,
|
|
9635
|
+
borderRadius: "50%",
|
|
9636
|
+
border: `2px solid ${theme.colors.text.disabled}`,
|
|
9637
|
+
background: theme.colors.background.canvas,
|
|
9638
|
+
position: "relative",
|
|
9639
|
+
zIndex: 1
|
|
9640
|
+
}),
|
|
9641
|
+
navDotOptional: css.css({
|
|
9642
|
+
borderStyle: "dashed"
|
|
9643
|
+
}),
|
|
9644
|
+
navDotActive: css.css({
|
|
9645
|
+
background: theme.colors.primary.main,
|
|
9646
|
+
borderColor: theme.colors.primary.main,
|
|
9647
|
+
borderStyle: "solid"
|
|
9648
|
+
}),
|
|
9649
|
+
navDotValidated: css.css({
|
|
9650
|
+
background: theme.colors.success.main,
|
|
9651
|
+
borderColor: theme.colors.success.main,
|
|
9652
|
+
borderStyle: "solid"
|
|
9653
|
+
}),
|
|
9654
|
+
navDotError: css.css({
|
|
9655
|
+
background: theme.colors.error.main,
|
|
9656
|
+
borderColor: theme.colors.error.main,
|
|
9657
|
+
borderStyle: "solid"
|
|
9658
|
+
}),
|
|
9659
|
+
// Connector line running from dot center downward to next item
|
|
9660
|
+
navConnector: css.css({
|
|
9661
|
+
position: "absolute",
|
|
9662
|
+
left: 5,
|
|
9663
|
+
top: 16,
|
|
9664
|
+
bottom: -16,
|
|
9665
|
+
width: 2,
|
|
9666
|
+
background: theme.colors.border.medium,
|
|
9667
|
+
zIndex: 0
|
|
9668
|
+
}),
|
|
9669
|
+
navConnectorDashed: css.css({
|
|
9670
|
+
background: "none",
|
|
9671
|
+
borderLeft: `2px dashed ${theme.colors.border.weak}`,
|
|
9672
|
+
width: 0
|
|
9673
|
+
}),
|
|
9674
|
+
navLabel: css.css({
|
|
9675
|
+
fontSize: theme.typography.body.fontSize,
|
|
9676
|
+
color: "rgba(204, 204, 220, 0.65)",
|
|
9677
|
+
lineHeight: 1.4
|
|
9678
|
+
}),
|
|
9679
|
+
navLabelActive: css.css({
|
|
9680
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
9681
|
+
color: theme.colors.text.primary
|
|
9682
|
+
}),
|
|
9683
|
+
// Main content
|
|
9684
|
+
main: css.css({
|
|
9685
|
+
flex: 1,
|
|
9686
|
+
minWidth: 0,
|
|
9687
|
+
width: 0,
|
|
9688
|
+
// forces flex child to respect flex-grow and fill remaining space
|
|
9689
|
+
display: "flex",
|
|
9690
|
+
flexDirection: "column",
|
|
9691
|
+
gap: theme.spacing(2)
|
|
9692
|
+
}),
|
|
9693
|
+
form: css.css({
|
|
9694
|
+
display: "flex",
|
|
9695
|
+
flexDirection: "column",
|
|
9696
|
+
gap: theme.spacing(2)
|
|
9697
|
+
}),
|
|
9698
|
+
requiredNotice: css.css({
|
|
9699
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9700
|
+
color: theme.colors.text.secondary,
|
|
9701
|
+
marginBottom: theme.spacing(0.5)
|
|
9702
|
+
}),
|
|
9703
|
+
// Section wrapper — card container around CollapsableSection
|
|
9704
|
+
section: css.css({
|
|
9705
|
+
border: `1px solid ${theme.colors.border.weak}`,
|
|
9706
|
+
borderRadius: theme.shape.radius.default,
|
|
9707
|
+
background: theme.colors.background.secondary,
|
|
9708
|
+
overflow: "hidden"
|
|
9709
|
+
}),
|
|
9710
|
+
// Override Collapse component styling
|
|
9711
|
+
collapseHeader: css.css({
|
|
9712
|
+
borderRadius: theme.shape.radius.default,
|
|
9713
|
+
background: "none",
|
|
9714
|
+
border: "none",
|
|
9715
|
+
marginBottom: 0,
|
|
9716
|
+
// Collapse header button: make label fill remaining space
|
|
9717
|
+
"& > button": {
|
|
9718
|
+
padding: `${theme.spacing(1.5)} ${theme.spacing(2)}`,
|
|
9719
|
+
width: "100%",
|
|
9720
|
+
justifyContent: "flex-start"
|
|
9721
|
+
},
|
|
9722
|
+
"& > button > div": {
|
|
9723
|
+
flex: 1,
|
|
9724
|
+
fontSize: theme.typography.h4.fontSize,
|
|
9725
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
9726
|
+
textAlign: "left"
|
|
9727
|
+
}
|
|
9728
|
+
}),
|
|
9729
|
+
sectionLabel: css.css({
|
|
9730
|
+
display: "flex",
|
|
9731
|
+
alignItems: "center",
|
|
9732
|
+
flex: 1
|
|
9733
|
+
}),
|
|
9734
|
+
sectionLabelText: css.css({
|
|
9735
|
+
flex: 1
|
|
9736
|
+
}),
|
|
9737
|
+
sectionHeader: css.css({
|
|
9738
|
+
display: "flex",
|
|
9739
|
+
alignItems: "center",
|
|
9740
|
+
gap: theme.spacing(1),
|
|
9741
|
+
padding: `${theme.spacing(1.5)} ${theme.spacing(2)}`,
|
|
9742
|
+
cursor: "pointer",
|
|
9743
|
+
userSelect: "none"
|
|
9744
|
+
}),
|
|
9745
|
+
sectionChevron: css.css({
|
|
9746
|
+
transition: "transform 0.2s ease"
|
|
9747
|
+
}),
|
|
9748
|
+
sectionChevronOpen: css.css({
|
|
9749
|
+
transform: "rotate(90deg)"
|
|
9750
|
+
}),
|
|
9751
|
+
sectionTitle: css.css({
|
|
9752
|
+
fontSize: theme.typography.h4.fontSize,
|
|
9753
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
9754
|
+
flex: 1,
|
|
9755
|
+
textAlign: "left"
|
|
9756
|
+
}),
|
|
9757
|
+
sectionBadge: css.css({
|
|
9758
|
+
fontSize: "11px",
|
|
9759
|
+
fontWeight: "normal",
|
|
9760
|
+
color: theme.colors.text.disabled,
|
|
9761
|
+
border: `1px solid ${theme.colors.border.weak}`,
|
|
9762
|
+
borderRadius: theme.shape.radius.pill,
|
|
9763
|
+
padding: `1px ${theme.spacing(0.75)}`,
|
|
9764
|
+
whiteSpace: "nowrap"
|
|
9765
|
+
}),
|
|
9766
|
+
sectionDescription: css.css({
|
|
9767
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9768
|
+
color: theme.colors.text.secondary,
|
|
9769
|
+
marginBottom: theme.spacing(1.5)
|
|
9770
|
+
}),
|
|
9771
|
+
sectionBody: css.css({
|
|
9772
|
+
padding: `0 ${theme.spacing(2)} ${theme.spacing(2)}`,
|
|
9773
|
+
display: "flex",
|
|
9774
|
+
flexDirection: "column",
|
|
9775
|
+
gap: theme.spacing(0.75)
|
|
9776
|
+
}),
|
|
9777
|
+
// Form bottom
|
|
9778
|
+
formButtons: css.css({
|
|
9779
|
+
display: "flex",
|
|
9780
|
+
gap: theme.spacing(1),
|
|
9781
|
+
paddingTop: theme.spacing(0.5)
|
|
9782
|
+
}),
|
|
9783
|
+
// Loading / error states
|
|
9784
|
+
loadingContainer: css.css({
|
|
9785
|
+
display: "flex",
|
|
9786
|
+
alignItems: "center",
|
|
9787
|
+
gap: theme.spacing(1),
|
|
9788
|
+
padding: theme.spacing(3),
|
|
9789
|
+
color: theme.colors.text.secondary
|
|
9790
|
+
}),
|
|
9791
|
+
overlay: css.css({
|
|
9792
|
+
position: "absolute",
|
|
9793
|
+
inset: 0,
|
|
9794
|
+
display: "flex",
|
|
9795
|
+
alignItems: "center",
|
|
9796
|
+
justifyContent: "center",
|
|
9797
|
+
gap: theme.spacing(1),
|
|
9798
|
+
background: theme.colors.background.secondary,
|
|
9799
|
+
borderRadius: theme.shape.radius.default,
|
|
9800
|
+
zIndex: 1,
|
|
9801
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9802
|
+
color: theme.colors.text.primary,
|
|
9803
|
+
opacity: 0.95
|
|
9804
|
+
}),
|
|
9805
|
+
readOnlyBanner: css.css({
|
|
9806
|
+
display: "inline-flex",
|
|
9807
|
+
alignItems: "center",
|
|
9808
|
+
gap: theme.spacing(0.5),
|
|
9809
|
+
padding: `${theme.spacing(0.25)} ${theme.spacing(0.75)}`,
|
|
9810
|
+
fontSize: theme.typography.bodySmall.fontSize,
|
|
9811
|
+
color: theme.colors.text.secondary,
|
|
9812
|
+
backgroundColor: theme.colors.background.secondary,
|
|
9813
|
+
borderRadius: theme.shape.radius.default,
|
|
9814
|
+
border: `1px solid ${theme.colors.border.weak}`,
|
|
9815
|
+
marginBottom: theme.spacing(1)
|
|
9816
|
+
})
|
|
9817
|
+
});
|
|
9818
|
+
|
|
9819
|
+
function SidebarNav({ groups, activeIndex, sectionStates, onSelect }) {
|
|
9820
|
+
const styles = ui.useStyles2(getTabStyles);
|
|
9821
|
+
const visibleGroups = groups.filter((g) => g.group.id !== "_required");
|
|
9822
|
+
return /* @__PURE__ */ React__default.default.createElement("nav", { className: styles.sidebar }, /* @__PURE__ */ React__default.default.createElement("div", { className: styles.sidebarTitle }, "Connect data source"), /* @__PURE__ */ React__default.default.createElement("ul", { className: styles.navList }, visibleGroups.map((g, vi) => {
|
|
9823
|
+
var _a, _b;
|
|
9824
|
+
const origIndex = groups.indexOf(g);
|
|
9825
|
+
const state = (_a = sectionStates[origIndex]) != null ? _a : "draft";
|
|
9826
|
+
const isActive = origIndex === activeIndex;
|
|
9827
|
+
const isOptional = g.group.optional === true;
|
|
9828
|
+
const isLast = vi === visibleGroups.length - 1;
|
|
9829
|
+
const nextIsOptional = !isLast && ((_b = visibleGroups[vi + 1]) == null ? void 0 : _b.group.optional) === true;
|
|
9830
|
+
return /* @__PURE__ */ React__default.default.createElement("li", { key: g.group.id }, /* @__PURE__ */ React__default.default.createElement(
|
|
9831
|
+
"div",
|
|
9832
|
+
{
|
|
9833
|
+
className: css.cx(styles.navItem, isActive && styles.navItemActive),
|
|
9834
|
+
onClick: () => onSelect(origIndex),
|
|
9835
|
+
role: "button",
|
|
9836
|
+
tabIndex: 0,
|
|
9837
|
+
onKeyDown: (e) => {
|
|
9838
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9839
|
+
e.preventDefault();
|
|
9840
|
+
onSelect(origIndex);
|
|
9841
|
+
}
|
|
9842
|
+
}
|
|
9843
|
+
},
|
|
9844
|
+
/* @__PURE__ */ React__default.default.createElement("div", { className: styles.navDotWrap }, /* @__PURE__ */ React__default.default.createElement(
|
|
9845
|
+
"span",
|
|
9846
|
+
{
|
|
9847
|
+
className: css.cx(
|
|
9848
|
+
styles.navDot,
|
|
9849
|
+
isOptional && styles.navDotOptional,
|
|
9850
|
+
isActive && styles.navDotActive,
|
|
9851
|
+
state === "validated" && !isActive && styles.navDotValidated,
|
|
9852
|
+
state === "error" && !isActive && styles.navDotError
|
|
9853
|
+
)
|
|
9854
|
+
}
|
|
9855
|
+
), !isLast && /* @__PURE__ */ React__default.default.createElement(
|
|
9856
|
+
"div",
|
|
9857
|
+
{
|
|
9858
|
+
className: css.cx(styles.navConnector, (isOptional || nextIsOptional) && styles.navConnectorDashed)
|
|
9859
|
+
}
|
|
9860
|
+
)),
|
|
9861
|
+
/* @__PURE__ */ React__default.default.createElement("span", { className: css.cx(styles.navLabel, isActive && styles.navLabelActive) }, g.group.title)
|
|
9862
|
+
));
|
|
9863
|
+
})));
|
|
9864
|
+
}
|
|
9865
|
+
|
|
9866
|
+
function TabLayout({ form, schema, dsUid, dsName, onRetest, healthError, renderActions }) {
|
|
9867
|
+
const styles = ui.useStyles2(getTabStyles);
|
|
9868
|
+
const sectionRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
9869
|
+
const {
|
|
9870
|
+
resolvedGroups,
|
|
9871
|
+
fieldById,
|
|
9872
|
+
httpHeadersField,
|
|
9873
|
+
control,
|
|
9874
|
+
handleSubmit,
|
|
9875
|
+
errors,
|
|
9876
|
+
watchedValues,
|
|
9877
|
+
initializing,
|
|
9878
|
+
fetchError,
|
|
9879
|
+
submitting,
|
|
9880
|
+
submitError,
|
|
9881
|
+
readOnly,
|
|
9882
|
+
isFieldVisible,
|
|
9883
|
+
isGroupValid,
|
|
9884
|
+
groupHasData,
|
|
9885
|
+
onSubmit
|
|
9886
|
+
} = form;
|
|
9887
|
+
const displayGroups = React.useMemo(() => resolvedGroups.filter((g) => g.group.id !== "_required"), [resolvedGroups]);
|
|
9888
|
+
const [expandedSections, setExpandedSections] = React.useState(() => {
|
|
9889
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
9890
|
+
for (let i = 0; i < displayGroups.length; i++) {
|
|
9891
|
+
if (!displayGroups[i].group.optional) {
|
|
9892
|
+
expanded.add(i);
|
|
9893
|
+
}
|
|
9894
|
+
}
|
|
9895
|
+
return expanded;
|
|
9896
|
+
});
|
|
9897
|
+
const hasExpandedForData = React.useRef(false);
|
|
9898
|
+
React.useMemo(() => {
|
|
9899
|
+
if (initializing || hasExpandedForData.current) {
|
|
9900
|
+
return;
|
|
9901
|
+
}
|
|
9902
|
+
hasExpandedForData.current = true;
|
|
9903
|
+
setExpandedSections((prev) => {
|
|
9904
|
+
const next = new Set(prev);
|
|
9905
|
+
for (let i = 0; i < displayGroups.length; i++) {
|
|
9906
|
+
if (groupHasData(displayGroups[i])) {
|
|
9907
|
+
next.add(i);
|
|
9908
|
+
}
|
|
9909
|
+
}
|
|
9910
|
+
return next;
|
|
9911
|
+
});
|
|
9912
|
+
}, [initializing, displayGroups, groupHasData]);
|
|
9913
|
+
const [activeSection, setActiveSection] = React.useState(0);
|
|
9914
|
+
const toggleSection = React.useCallback((index) => {
|
|
9915
|
+
setExpandedSections((prev) => {
|
|
9916
|
+
const next = new Set(prev);
|
|
9917
|
+
if (next.has(index)) {
|
|
9918
|
+
next.delete(index);
|
|
9919
|
+
} else {
|
|
9920
|
+
next.add(index);
|
|
9921
|
+
}
|
|
9922
|
+
return next;
|
|
9923
|
+
});
|
|
9924
|
+
}, []);
|
|
9925
|
+
const scrollToSection = React.useCallback(
|
|
9926
|
+
(index) => {
|
|
9927
|
+
setActiveSection(index);
|
|
9928
|
+
if (!expandedSections.has(index)) {
|
|
9929
|
+
setExpandedSections((prev) => new Set(prev).add(index));
|
|
9930
|
+
}
|
|
9931
|
+
const el = sectionRefs.current.get(index);
|
|
9932
|
+
if (el) {
|
|
9933
|
+
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
9934
|
+
}
|
|
9935
|
+
},
|
|
9936
|
+
[expandedSections]
|
|
9937
|
+
);
|
|
9938
|
+
const sectionStates = React.useMemo(() => {
|
|
9939
|
+
return displayGroups.map((g, i) => {
|
|
9940
|
+
if (i === activeSection) {
|
|
9941
|
+
return "active";
|
|
9942
|
+
}
|
|
9943
|
+
if (!isGroupValid(g)) {
|
|
9944
|
+
return "error";
|
|
9945
|
+
}
|
|
9946
|
+
if (groupHasData(g)) {
|
|
9947
|
+
return "validated";
|
|
9948
|
+
}
|
|
9949
|
+
return "draft";
|
|
9950
|
+
});
|
|
9951
|
+
}, [displayGroups, activeSection, isGroupValid, groupHasData]);
|
|
9952
|
+
if (initializing) {
|
|
9953
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.loadingContainer }, /* @__PURE__ */ React__default.default.createElement(ui.Spinner, { size: "sm", inline: true }), " Loading configuration\u2026");
|
|
9954
|
+
}
|
|
9955
|
+
if (fetchError) {
|
|
9956
|
+
return /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(ui.Alert, { severity: "error", title: "Failed to load configuration" }, fetchError), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.formButtons }, /* @__PURE__ */ React__default.default.createElement(
|
|
9957
|
+
ui.LinkButton,
|
|
9958
|
+
{
|
|
9959
|
+
variant: "secondary",
|
|
9960
|
+
size: "sm",
|
|
9961
|
+
icon: "external-link-alt",
|
|
9962
|
+
href: `/connections/datasources/edit/${dsUid}`
|
|
9963
|
+
},
|
|
9964
|
+
"Open datasource settings"
|
|
9965
|
+
)));
|
|
9966
|
+
}
|
|
9967
|
+
const allDisabled = submitting || readOnly;
|
|
9968
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, submitting && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.overlay }, /* @__PURE__ */ React__default.default.createElement(ui.Spinner, { size: "sm" }), /* @__PURE__ */ React__default.default.createElement("span", null, "Saving & testing\u2026")), /* @__PURE__ */ React__default.default.createElement(
|
|
9969
|
+
SidebarNav,
|
|
9970
|
+
{
|
|
9971
|
+
groups: displayGroups,
|
|
9972
|
+
activeIndex: activeSection,
|
|
9973
|
+
sectionStates,
|
|
9974
|
+
onSelect: scrollToSection
|
|
9975
|
+
}
|
|
9976
|
+
), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.main }, readOnly && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.readOnlyBanner }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "lock", size: "xs" }), /* @__PURE__ */ React__default.default.createElement("span", null, "Read-only \u2014 managed externally")), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.requiredNotice }, "Fields marked with * are required"), /* @__PURE__ */ React__default.default.createElement("form", { onSubmit: handleSubmit(onSubmit), className: styles.form }, displayGroups.map((g, i) => {
|
|
9977
|
+
const visibleFields = g.fields.filter(isFieldVisible);
|
|
9978
|
+
if (visibleFields.length === 0 && !httpHeadersField) {
|
|
9979
|
+
return null;
|
|
9980
|
+
}
|
|
9981
|
+
const showHeaders = httpHeadersField && (g.group.id === "auth" || g.group.id === "url-and-auth" || g.group.id === "_required" || g.group.fieldRefs.includes("httpHeaders"));
|
|
9982
|
+
const sectionLabel = /* @__PURE__ */ React__default.default.createElement("span", { className: styles.sectionLabel }, /* @__PURE__ */ React__default.default.createElement("span", { className: styles.sectionLabelText }, g.group.title), g.group.optional && /* @__PURE__ */ React__default.default.createElement("span", { className: styles.sectionBadge }, "Optional"));
|
|
9983
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
9984
|
+
"div",
|
|
9985
|
+
{
|
|
9986
|
+
key: g.group.id,
|
|
9987
|
+
ref: (el) => {
|
|
9988
|
+
if (el) {
|
|
9989
|
+
sectionRefs.current.set(i, el);
|
|
9990
|
+
}
|
|
9991
|
+
},
|
|
9992
|
+
className: styles.section
|
|
9993
|
+
},
|
|
9994
|
+
/* @__PURE__ */ React__default.default.createElement(
|
|
9995
|
+
ui.Collapse,
|
|
9996
|
+
{
|
|
9997
|
+
label: sectionLabel,
|
|
9998
|
+
isOpen: expandedSections.has(i),
|
|
9999
|
+
collapsible: true,
|
|
10000
|
+
onToggle: () => {
|
|
10001
|
+
toggleSection(i);
|
|
10002
|
+
setActiveSection(i);
|
|
10003
|
+
},
|
|
10004
|
+
className: styles.collapseHeader
|
|
10005
|
+
},
|
|
10006
|
+
/* @__PURE__ */ React__default.default.createElement("div", { className: styles.sectionBody }, g.group.description && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.sectionDescription }, g.group.description), visibleFields.map((field) => /* @__PURE__ */ React__default.default.createElement(
|
|
10007
|
+
SchemaField,
|
|
10008
|
+
{
|
|
10009
|
+
key: formKey(field),
|
|
10010
|
+
field,
|
|
10011
|
+
control,
|
|
10012
|
+
errors,
|
|
10013
|
+
disabled: allDisabled,
|
|
10014
|
+
dsUid,
|
|
10015
|
+
watchedValues,
|
|
10016
|
+
fieldById
|
|
10017
|
+
}
|
|
10018
|
+
)), showHeaders && /* @__PURE__ */ React__default.default.createElement(
|
|
10019
|
+
AuthorizationHeaderField,
|
|
10020
|
+
{
|
|
10021
|
+
headersFieldKey: formKey(httpHeadersField),
|
|
10022
|
+
control,
|
|
10023
|
+
disabled: allDisabled,
|
|
10024
|
+
watchedValues
|
|
10025
|
+
}
|
|
10026
|
+
))
|
|
10027
|
+
)
|
|
10028
|
+
);
|
|
10029
|
+
}), submitError && /* @__PURE__ */ React__default.default.createElement(ui.Alert, { severity: "error", title: "Error" }, submitError), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.formButtons }, readOnly ? /* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "primary", size: "sm", icon: "sync", onClick: onRetest, type: "button" }, "Test") : /* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "primary", size: "sm", disabled: submitting, type: "submit" }, submitting ? "Saving\u2026" : "Save & Test"), healthError && (renderActions == null ? void 0 : renderActions({ dsUid, dsName, dsType: schema.pluginType, healthError }))))));
|
|
10030
|
+
}
|
|
10031
|
+
|
|
10032
|
+
function useDatasourceConfigForm({ schema, dsUid, onSuccess, onSaving }) {
|
|
10033
|
+
const [submitting, setSubmitting] = React.useState(false);
|
|
10034
|
+
const [submitError, setSubmitError] = React.useState(null);
|
|
10035
|
+
const [initializing, setInitializing] = React.useState(true);
|
|
10036
|
+
const [fetchError, setFetchError] = React.useState(null);
|
|
10037
|
+
const [detectedReadOnly, setDetectedReadOnly] = React.useState(false);
|
|
10038
|
+
const readOnly = detectedReadOnly;
|
|
10039
|
+
const resolvedGroups = React.useMemo(() => {
|
|
10040
|
+
const groups = resolveGroups(schema);
|
|
10041
|
+
const requiredGroup = resolveRequiredFieldsGroup(schema);
|
|
10042
|
+
if (!requiredGroup) {
|
|
10043
|
+
return groups;
|
|
10044
|
+
}
|
|
10045
|
+
return [requiredGroup, ...groups];
|
|
10046
|
+
}, [schema]);
|
|
10047
|
+
const fieldById = React.useMemo(() => {
|
|
10048
|
+
const m = /* @__PURE__ */ new Map();
|
|
10049
|
+
for (const f of schema.fields) {
|
|
10050
|
+
m.set(f.id, f);
|
|
10051
|
+
}
|
|
10052
|
+
return m;
|
|
10053
|
+
}, [schema.fields]);
|
|
10054
|
+
const httpHeadersField = React.useMemo(
|
|
10055
|
+
() => {
|
|
10056
|
+
var _a;
|
|
10057
|
+
return (_a = schema.fields.find((f) => {
|
|
10058
|
+
var _a2;
|
|
10059
|
+
return f.key === "httpHeaders" && ((_a2 = f.storage) == null ? void 0 : _a2.type) === "indexedPair";
|
|
10060
|
+
})) != null ? _a : null;
|
|
10061
|
+
},
|
|
10062
|
+
[schema.fields]
|
|
10063
|
+
);
|
|
10064
|
+
const allStorageFields = React.useMemo(
|
|
10065
|
+
() => schema.fields.filter((f) => f.kind !== "virtual" && !f.isItemField && f.target),
|
|
10066
|
+
[schema.fields]
|
|
10067
|
+
);
|
|
10068
|
+
const {
|
|
10069
|
+
control,
|
|
10070
|
+
handleSubmit,
|
|
10071
|
+
watch,
|
|
10072
|
+
reset,
|
|
10073
|
+
trigger,
|
|
10074
|
+
setValue,
|
|
10075
|
+
formState: { errors }
|
|
10076
|
+
} = reactHookForm.useForm({ mode: "onChange" });
|
|
10077
|
+
const fieldsWithEffects = React.useMemo(() => {
|
|
10078
|
+
const result = [];
|
|
10079
|
+
for (const field of schema.fields) {
|
|
10080
|
+
if (!field.effects || field.effects.length === 0) {
|
|
10081
|
+
continue;
|
|
10082
|
+
}
|
|
10083
|
+
const mapped = field.effects.map((eff) => ({
|
|
10084
|
+
when: eff.when,
|
|
10085
|
+
targets: Object.entries(eff.set).map(([targetId, val]) => {
|
|
10086
|
+
const targetField = fieldById.get(targetId);
|
|
10087
|
+
return { key: targetField ? formKey(targetField) : targetId, value: val };
|
|
10088
|
+
})
|
|
10089
|
+
}));
|
|
10090
|
+
result.push({ sourceKey: formKey(field), effects: mapped });
|
|
10091
|
+
}
|
|
10092
|
+
return result;
|
|
10093
|
+
}, [schema.fields, fieldById]);
|
|
10094
|
+
React.useEffect(() => {
|
|
10095
|
+
let cancelled = false;
|
|
10096
|
+
fetchExistingValues(dsUid, allStorageFields).then((result) => {
|
|
10097
|
+
if (cancelled) {
|
|
10098
|
+
return;
|
|
10099
|
+
}
|
|
10100
|
+
if (result.error) {
|
|
10101
|
+
setFetchError(result.error);
|
|
10102
|
+
setInitializing(false);
|
|
10103
|
+
return;
|
|
10104
|
+
}
|
|
10105
|
+
if (result.readOnly) {
|
|
10106
|
+
setDetectedReadOnly(true);
|
|
10107
|
+
}
|
|
10108
|
+
const defaults = {};
|
|
10109
|
+
for (const field of allStorageFields) {
|
|
10110
|
+
if (field.defaultValue !== void 0) {
|
|
10111
|
+
defaults[formKey(field)] = field.defaultValue;
|
|
10112
|
+
}
|
|
10113
|
+
}
|
|
10114
|
+
const merged = { ...defaults, ...result.values };
|
|
10115
|
+
const virtualValues = computeVirtualFieldValues(schema, merged);
|
|
10116
|
+
reset({ ...merged, ...virtualValues });
|
|
10117
|
+
setInitializing(false);
|
|
10118
|
+
});
|
|
10119
|
+
return () => {
|
|
10120
|
+
cancelled = true;
|
|
10121
|
+
};
|
|
10122
|
+
}, [dsUid, allStorageFields, schema, reset]);
|
|
10123
|
+
const watchedValues = watch();
|
|
10124
|
+
const prevEffectValuesRef = React.useRef({});
|
|
10125
|
+
React.useEffect(() => {
|
|
10126
|
+
if (initializing) {
|
|
10127
|
+
return;
|
|
10128
|
+
}
|
|
10129
|
+
for (const { sourceKey, effects } of fieldsWithEffects) {
|
|
10130
|
+
const currentVal = watchedValues[sourceKey];
|
|
10131
|
+
const prevVal = prevEffectValuesRef.current[sourceKey];
|
|
10132
|
+
if (currentVal === prevVal) {
|
|
10133
|
+
continue;
|
|
10134
|
+
}
|
|
10135
|
+
prevEffectValuesRef.current[sourceKey] = currentVal;
|
|
10136
|
+
for (const eff of effects) {
|
|
10137
|
+
if (evaluateEffectCondition(eff.when, currentVal)) {
|
|
10138
|
+
for (const { key, value } of eff.targets) {
|
|
10139
|
+
setValue(key, value);
|
|
10140
|
+
}
|
|
10141
|
+
break;
|
|
10142
|
+
}
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10145
|
+
}, [watchedValues, fieldsWithEffects, initializing, setValue]);
|
|
10146
|
+
const fieldsWithOverrideDefaults = React.useMemo(() => {
|
|
10147
|
+
const result = [];
|
|
10148
|
+
for (const field of schema.fields) {
|
|
10149
|
+
if (!field.overrides || field.overrides.length === 0) {
|
|
10150
|
+
continue;
|
|
10151
|
+
}
|
|
10152
|
+
const ovs = field.overrides.filter((ov) => ov.defaultValue !== void 0).map((ov) => {
|
|
10153
|
+
const parsed = parseDependsOn(ov.when);
|
|
10154
|
+
if (!parsed) {
|
|
10155
|
+
return null;
|
|
10156
|
+
}
|
|
10157
|
+
const depField = fieldById.get(parsed.field);
|
|
10158
|
+
return {
|
|
10159
|
+
depKey: depField ? formKey(depField) : parsed.field,
|
|
10160
|
+
depValue: parsed.value,
|
|
10161
|
+
defaultValue: ov.defaultValue
|
|
10162
|
+
};
|
|
10163
|
+
}).filter(Boolean);
|
|
10164
|
+
if (ovs.length > 0) {
|
|
10165
|
+
result.push({ targetKey: formKey(field), fieldDefault: field.defaultValue, overrides: ovs });
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
return result;
|
|
10169
|
+
}, [schema.fields, fieldById]);
|
|
10170
|
+
const prevOverrideDepRef = React.useRef({});
|
|
10171
|
+
React.useEffect(() => {
|
|
10172
|
+
var _a;
|
|
10173
|
+
if (initializing) {
|
|
10174
|
+
return;
|
|
10175
|
+
}
|
|
10176
|
+
for (const { targetKey, fieldDefault, overrides } of fieldsWithOverrideDefaults) {
|
|
10177
|
+
for (const ov of overrides) {
|
|
10178
|
+
const currentDepVal = String((_a = watchedValues[ov.depKey]) != null ? _a : "");
|
|
10179
|
+
const trackKey = `${targetKey}::${ov.depKey}`;
|
|
10180
|
+
const prevDepVal = prevOverrideDepRef.current[trackKey];
|
|
10181
|
+
if (currentDepVal === prevDepVal) {
|
|
10182
|
+
continue;
|
|
10183
|
+
}
|
|
10184
|
+
prevOverrideDepRef.current[trackKey] = currentDepVal;
|
|
10185
|
+
if (currentDepVal === ov.depValue) {
|
|
10186
|
+
setValue(targetKey, ov.defaultValue);
|
|
10187
|
+
} else if (prevDepVal === ov.depValue && fieldDefault !== void 0) {
|
|
10188
|
+
setValue(targetKey, fieldDefault);
|
|
10189
|
+
}
|
|
10190
|
+
}
|
|
10191
|
+
}
|
|
10192
|
+
}, [watchedValues, fieldsWithOverrideDefaults, initializing, setValue]);
|
|
10193
|
+
const isFieldVisible = React.useCallback(
|
|
10194
|
+
(field) => {
|
|
10195
|
+
var _a, _b;
|
|
10196
|
+
if (field.kind === "virtual" && !field.ui) {
|
|
10197
|
+
return false;
|
|
10198
|
+
}
|
|
10199
|
+
if ((_a = field.tags) == null ? void 0 : _a.some((t) => t.startsWith("managed-by:"))) {
|
|
10200
|
+
return false;
|
|
10201
|
+
}
|
|
10202
|
+
if (!field.dependsOn) {
|
|
10203
|
+
return true;
|
|
10204
|
+
}
|
|
10205
|
+
const parsed = parseDependsOn(field.dependsOn);
|
|
10206
|
+
if (!parsed) {
|
|
10207
|
+
return true;
|
|
10208
|
+
}
|
|
10209
|
+
const depField = fieldById.get(parsed.field);
|
|
10210
|
+
const depKey = depField ? formKey(depField) : parsed.field;
|
|
10211
|
+
return String((_b = watchedValues[depKey]) != null ? _b : "") === parsed.value;
|
|
10212
|
+
},
|
|
10213
|
+
[watchedValues, fieldById]
|
|
10214
|
+
);
|
|
10215
|
+
const onSubmit = React.useCallback(
|
|
10216
|
+
async (data) => {
|
|
10217
|
+
setSubmitting(true);
|
|
10218
|
+
setSubmitError(null);
|
|
10219
|
+
onSaving == null ? void 0 : onSaving(true);
|
|
10220
|
+
const minDelay = new Promise((r) => setTimeout(r, 2e3));
|
|
10221
|
+
try {
|
|
10222
|
+
await submitDatasourceConfig(dsUid, data, allStorageFields, isFieldVisible);
|
|
10223
|
+
const [refreshed] = await Promise.all([fetchExistingValues(dsUid, allStorageFields), minDelay]);
|
|
10224
|
+
const defaults = {};
|
|
10225
|
+
for (const field of allStorageFields) {
|
|
10226
|
+
if (field.defaultValue !== void 0) {
|
|
10227
|
+
defaults[formKey(field)] = field.defaultValue;
|
|
10228
|
+
}
|
|
10229
|
+
}
|
|
10230
|
+
const merged = { ...defaults, ...refreshed.values };
|
|
10231
|
+
const virtualValues = computeVirtualFieldValues(schema, merged);
|
|
10232
|
+
reset({ ...merged, ...virtualValues });
|
|
10233
|
+
onSuccess("UPDATED", "Configuration saved.");
|
|
10234
|
+
} catch (err) {
|
|
10235
|
+
await minDelay;
|
|
10236
|
+
setSubmitError(err instanceof Error ? err.message : "Failed to update datasource");
|
|
10237
|
+
} finally {
|
|
10238
|
+
setSubmitting(false);
|
|
10239
|
+
onSaving == null ? void 0 : onSaving(false);
|
|
10240
|
+
}
|
|
10241
|
+
},
|
|
10242
|
+
[dsUid, allStorageFields, isFieldVisible, schema, reset, onSuccess, onSaving]
|
|
10243
|
+
);
|
|
10244
|
+
const isGroupValid = React.useCallback(
|
|
10245
|
+
(group) => {
|
|
10246
|
+
for (const field of group.fields) {
|
|
10247
|
+
if (!isFieldVisible(field)) {
|
|
10248
|
+
continue;
|
|
10249
|
+
}
|
|
10250
|
+
if (errors[formKey(field)]) {
|
|
10251
|
+
return false;
|
|
10252
|
+
}
|
|
10253
|
+
if (isFieldRequired(field, watchedValues, fieldById)) {
|
|
10254
|
+
const val = watchedValues[formKey(field)];
|
|
10255
|
+
if (val === SECURE_FIELD_CONFIGURED) {
|
|
10256
|
+
continue;
|
|
10257
|
+
}
|
|
10258
|
+
if (val === void 0 || val === null || val === "") {
|
|
10259
|
+
return false;
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
}
|
|
10263
|
+
return true;
|
|
10264
|
+
},
|
|
10265
|
+
[errors, watchedValues, fieldById, isFieldVisible]
|
|
10266
|
+
);
|
|
10267
|
+
const groupHasData = React.useCallback(
|
|
10268
|
+
(group) => {
|
|
10269
|
+
for (const field of group.fields) {
|
|
10270
|
+
const val = watchedValues[formKey(field)];
|
|
10271
|
+
if (val === void 0 || val === null || val === "" || val === false) {
|
|
10272
|
+
continue;
|
|
10273
|
+
}
|
|
10274
|
+
if (val === field.defaultValue) {
|
|
10275
|
+
continue;
|
|
10276
|
+
}
|
|
10277
|
+
return true;
|
|
10278
|
+
}
|
|
10279
|
+
return false;
|
|
10280
|
+
},
|
|
10281
|
+
[watchedValues]
|
|
10282
|
+
);
|
|
10283
|
+
return {
|
|
10284
|
+
// Schema
|
|
10285
|
+
resolvedGroups,
|
|
10286
|
+
fieldById,
|
|
10287
|
+
httpHeadersField,
|
|
10288
|
+
// Form
|
|
10289
|
+
control,
|
|
10290
|
+
handleSubmit,
|
|
10291
|
+
trigger,
|
|
10292
|
+
errors,
|
|
10293
|
+
watchedValues,
|
|
10294
|
+
// State
|
|
10295
|
+
initializing,
|
|
10296
|
+
fetchError,
|
|
10297
|
+
submitting,
|
|
10298
|
+
submitError,
|
|
10299
|
+
readOnly,
|
|
10300
|
+
// Callbacks
|
|
10301
|
+
isFieldVisible,
|
|
10302
|
+
isGroupValid,
|
|
10303
|
+
groupHasData,
|
|
10304
|
+
onSubmit
|
|
10305
|
+
};
|
|
10306
|
+
}
|
|
10307
|
+
|
|
10308
|
+
function DatasourceConfigWizard(props) {
|
|
10309
|
+
const { schema, dsUid, dsName, onSuccess, onSaving, onRetest, healthError, renderActions, mode = "tab" } = props;
|
|
10310
|
+
const form = useDatasourceConfigForm({ schema, dsUid, onSuccess, onSaving });
|
|
10311
|
+
if (mode === "tab") {
|
|
10312
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
10313
|
+
TabLayout,
|
|
10314
|
+
{
|
|
10315
|
+
form,
|
|
10316
|
+
schema,
|
|
10317
|
+
dsUid,
|
|
10318
|
+
dsName,
|
|
10319
|
+
onRetest,
|
|
10320
|
+
healthError,
|
|
10321
|
+
renderActions
|
|
10322
|
+
}
|
|
10323
|
+
);
|
|
10324
|
+
}
|
|
10325
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
10326
|
+
WizardLayout,
|
|
10327
|
+
{
|
|
10328
|
+
form,
|
|
10329
|
+
schema,
|
|
10330
|
+
dsUid,
|
|
10331
|
+
dsName,
|
|
10332
|
+
onRetest,
|
|
10333
|
+
healthError,
|
|
10334
|
+
renderActions
|
|
10335
|
+
}
|
|
10336
|
+
);
|
|
10337
|
+
}
|
|
10338
|
+
function WizardLayout({ form, schema, dsUid, dsName, onRetest, healthError, renderActions }) {
|
|
10339
|
+
var _a, _b, _c;
|
|
10340
|
+
const styles = ui.useStyles2(getWizardStyles);
|
|
10341
|
+
const [currentStep, setCurrentStep] = React.useState(0);
|
|
10342
|
+
const {
|
|
10343
|
+
resolvedGroups,
|
|
10344
|
+
fieldById,
|
|
10345
|
+
httpHeadersField,
|
|
10346
|
+
control,
|
|
10347
|
+
handleSubmit,
|
|
10348
|
+
trigger,
|
|
10349
|
+
errors,
|
|
10350
|
+
watchedValues,
|
|
10351
|
+
initializing,
|
|
10352
|
+
fetchError,
|
|
10353
|
+
submitting,
|
|
10354
|
+
submitError,
|
|
10355
|
+
readOnly,
|
|
10356
|
+
isFieldVisible,
|
|
10357
|
+
onSubmit
|
|
10358
|
+
} = form;
|
|
10359
|
+
const arrowSteps = React.useMemo(() => {
|
|
10360
|
+
const requiredGroup = resolvedGroups.find((g) => g.group.id === "_required");
|
|
10361
|
+
if (!requiredGroup) {
|
|
10362
|
+
return new Set(resolvedGroups.map((_, i) => i));
|
|
10363
|
+
}
|
|
10364
|
+
const requiredFieldIds = new Set(requiredGroup.fields.map((f) => f.id));
|
|
10365
|
+
const steps = /* @__PURE__ */ new Set();
|
|
10366
|
+
for (let i = 0; i < resolvedGroups.length; i++) {
|
|
10367
|
+
const g = resolvedGroups[i];
|
|
10368
|
+
if (g.group.id === "_required" || g.fields.some((f) => !requiredFieldIds.has(f.id))) {
|
|
10369
|
+
steps.add(i);
|
|
10370
|
+
}
|
|
10371
|
+
}
|
|
10372
|
+
return steps;
|
|
10373
|
+
}, [resolvedGroups]);
|
|
10374
|
+
const currentResolved = resolvedGroups[currentStep];
|
|
10375
|
+
const isFirstStep = React.useMemo(() => {
|
|
10376
|
+
for (let i = 0; i < currentStep; i++) {
|
|
10377
|
+
if (arrowSteps.has(i)) {
|
|
10378
|
+
return false;
|
|
10379
|
+
}
|
|
10380
|
+
}
|
|
10381
|
+
return true;
|
|
10382
|
+
}, [currentStep, arrowSteps]);
|
|
10383
|
+
const isLastStep = React.useMemo(() => {
|
|
10384
|
+
for (let i = currentStep + 1; i < resolvedGroups.length; i++) {
|
|
10385
|
+
if (arrowSteps.has(i)) {
|
|
10386
|
+
return false;
|
|
10387
|
+
}
|
|
10388
|
+
}
|
|
10389
|
+
return true;
|
|
10390
|
+
}, [currentStep, arrowSteps, resolvedGroups.length]);
|
|
10391
|
+
const visibleFieldsForStep = React.useMemo(
|
|
10392
|
+
() => currentResolved ? currentResolved.fields.filter(isFieldVisible) : [],
|
|
10393
|
+
[currentResolved, isFieldVisible]
|
|
10394
|
+
);
|
|
10395
|
+
const currentGroupValid = React.useMemo(() => {
|
|
10396
|
+
if (!currentResolved) {
|
|
10397
|
+
return true;
|
|
10398
|
+
}
|
|
10399
|
+
for (const field of visibleFieldsForStep) {
|
|
10400
|
+
if (errors[formKey(field)]) {
|
|
10401
|
+
return false;
|
|
10402
|
+
}
|
|
10403
|
+
if (isFieldRequired(field, watchedValues, fieldById)) {
|
|
10404
|
+
const val = watchedValues[formKey(field)];
|
|
10405
|
+
if (val === SECURE_FIELD_CONFIGURED) {
|
|
10406
|
+
continue;
|
|
10407
|
+
}
|
|
10408
|
+
if (val === void 0 || val === null || val === "") {
|
|
10409
|
+
return false;
|
|
10410
|
+
}
|
|
10411
|
+
}
|
|
10412
|
+
}
|
|
10413
|
+
return true;
|
|
10414
|
+
}, [currentResolved, errors, visibleFieldsForStep, watchedValues, fieldById]);
|
|
10415
|
+
const goNext = React.useCallback(async () => {
|
|
10416
|
+
if (!currentResolved) {
|
|
10417
|
+
return;
|
|
10418
|
+
}
|
|
10419
|
+
if (!readOnly) {
|
|
10420
|
+
const visibleKeys = visibleFieldsForStep.map((f) => formKey(f));
|
|
10421
|
+
const valid = await trigger(visibleKeys);
|
|
10422
|
+
if (!valid) {
|
|
10423
|
+
return;
|
|
10424
|
+
}
|
|
10425
|
+
}
|
|
10426
|
+
setCurrentStep((s) => {
|
|
10427
|
+
for (let i = s + 1; i < resolvedGroups.length; i++) {
|
|
10428
|
+
if (arrowSteps.has(i)) {
|
|
10429
|
+
return i;
|
|
10430
|
+
}
|
|
10431
|
+
}
|
|
10432
|
+
return s;
|
|
10433
|
+
});
|
|
10434
|
+
}, [currentResolved, visibleFieldsForStep, trigger, resolvedGroups.length, arrowSteps, readOnly]);
|
|
10435
|
+
const goPrev = React.useCallback(() => {
|
|
10436
|
+
setCurrentStep((s) => {
|
|
10437
|
+
for (let i = s - 1; i >= 0; i--) {
|
|
10438
|
+
if (arrowSteps.has(i)) {
|
|
10439
|
+
return i;
|
|
10440
|
+
}
|
|
10441
|
+
}
|
|
10442
|
+
return s;
|
|
10443
|
+
});
|
|
10444
|
+
}, [arrowSteps]);
|
|
10445
|
+
if (initializing) {
|
|
10446
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, /* @__PURE__ */ React__default.default.createElement(ui.Spinner, { size: "sm", inline: true }), " Loading configuration...");
|
|
10447
|
+
}
|
|
10448
|
+
if (fetchError) {
|
|
10449
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, /* @__PURE__ */ React__default.default.createElement(ui.Alert, { severity: "error", title: "Failed to load configuration" }, fetchError), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.buttons }, /* @__PURE__ */ React__default.default.createElement(
|
|
10450
|
+
ui.LinkButton,
|
|
10451
|
+
{
|
|
10452
|
+
variant: "secondary",
|
|
10453
|
+
size: "sm",
|
|
10454
|
+
icon: "external-link-alt",
|
|
10455
|
+
href: `/connections/datasources/edit/${dsUid}`
|
|
10456
|
+
},
|
|
10457
|
+
"Open datasource settings"
|
|
10458
|
+
)));
|
|
10459
|
+
}
|
|
10460
|
+
const allDisabled = submitting || readOnly;
|
|
10461
|
+
if (resolvedGroups.length === 0) {
|
|
10462
|
+
return null;
|
|
10463
|
+
}
|
|
10464
|
+
const currentGroup = currentResolved == null ? void 0 : currentResolved.group;
|
|
10465
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, submitting && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.overlay }, /* @__PURE__ */ React__default.default.createElement(ui.Spinner, { size: "sm" }), /* @__PURE__ */ React__default.default.createElement("span", null, "Saving & testing\u2026")), readOnly && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.readOnlyBanner }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "lock", size: "xs" }), /* @__PURE__ */ React__default.default.createElement("span", null, "Read-only \u2014 managed externally")), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.navBar }, currentGroup && /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: (_a = currentGroup.description) != null ? _a : currentGroup.title }, /* @__PURE__ */ React__default.default.createElement("span", { className: styles.navTitle }, currentGroup.title, /* @__PURE__ */ React__default.default.createElement("span", { className: styles.stepCount }, currentStep + 1, "/", resolvedGroups.length))), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.navActions }, /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: isFirstStep ? "First step" : `Previous: ${(_b = resolvedGroups[currentStep - 1]) == null ? void 0 : _b.group.title}` }, /* @__PURE__ */ React__default.default.createElement(
|
|
10466
|
+
ui.Button,
|
|
10467
|
+
{
|
|
10468
|
+
variant: "secondary",
|
|
10469
|
+
fill: "text",
|
|
10470
|
+
size: "sm",
|
|
10471
|
+
icon: "angle-left",
|
|
10472
|
+
"aria-label": "Previous",
|
|
10473
|
+
onClick: goPrev,
|
|
10474
|
+
disabled: isFirstStep || submitting,
|
|
10475
|
+
type: "button"
|
|
10476
|
+
}
|
|
10477
|
+
)), /* @__PURE__ */ React__default.default.createElement(
|
|
10478
|
+
ui.Select,
|
|
10479
|
+
{
|
|
10480
|
+
options: resolvedGroups.map((g, i) => ({ label: g.group.title, value: i })),
|
|
10481
|
+
value: currentStep,
|
|
10482
|
+
onChange: (v) => {
|
|
10483
|
+
if (v) {
|
|
10484
|
+
setCurrentStep(v.value);
|
|
10485
|
+
}
|
|
10486
|
+
},
|
|
10487
|
+
disabled: submitting,
|
|
10488
|
+
width: 18
|
|
10489
|
+
}
|
|
10490
|
+
), /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: isLastStep ? "Last step" : `Next: ${(_c = resolvedGroups[currentStep + 1]) == null ? void 0 : _c.group.title}` }, /* @__PURE__ */ React__default.default.createElement(
|
|
10491
|
+
ui.Button,
|
|
10492
|
+
{
|
|
10493
|
+
variant: isLastStep || !readOnly && !currentGroupValid ? "secondary" : "primary",
|
|
10494
|
+
size: "sm",
|
|
10495
|
+
icon: "angle-right",
|
|
10496
|
+
"aria-label": "Next",
|
|
10497
|
+
onClick: goNext,
|
|
10498
|
+
disabled: isLastStep || submitting,
|
|
10499
|
+
type: "button"
|
|
10500
|
+
}
|
|
10501
|
+
)))), currentResolved && /* @__PURE__ */ React__default.default.createElement("form", { onSubmit: handleSubmit(onSubmit), className: styles.form }, visibleFieldsForStep.map((field) => /* @__PURE__ */ React__default.default.createElement(
|
|
10502
|
+
SchemaField,
|
|
10503
|
+
{
|
|
10504
|
+
key: formKey(field),
|
|
10505
|
+
field,
|
|
10506
|
+
control,
|
|
10507
|
+
errors,
|
|
10508
|
+
disabled: allDisabled,
|
|
10509
|
+
dsUid,
|
|
10510
|
+
watchedValues,
|
|
10511
|
+
fieldById
|
|
10512
|
+
}
|
|
10513
|
+
)), (currentResolved.group.id === "_required" || currentResolved.group.id === "auth") && httpHeadersField && /* @__PURE__ */ React__default.default.createElement(
|
|
10514
|
+
AuthorizationHeaderField,
|
|
10515
|
+
{
|
|
10516
|
+
headersFieldKey: formKey(httpHeadersField),
|
|
10517
|
+
control,
|
|
10518
|
+
disabled: allDisabled,
|
|
10519
|
+
watchedValues
|
|
10520
|
+
}
|
|
10521
|
+
), submitError && /* @__PURE__ */ React__default.default.createElement(ui.Alert, { severity: "error", title: "Error" }, submitError), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.buttons }, readOnly ? /* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "primary", size: "sm", icon: "sync", onClick: onRetest, type: "button" }, "Test") : /* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "primary", size: "sm", disabled: submitting || !currentGroupValid, type: "submit" }, submitting ? "Saving..." : "Save & Test"), healthError && (renderActions == null ? void 0 : renderActions({ dsUid, dsName, dsType: schema.pluginType, healthError })))));
|
|
10522
|
+
}
|
|
10523
|
+
|
|
10524
|
+
var __defProp$1 = Object.defineProperty;
|
|
10525
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10526
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10527
|
+
const getCustomHeaderRowStyles = ui.stylesFactory(() => {
|
|
10528
|
+
return {
|
|
10529
|
+
layout: css.css`
|
|
10530
|
+
display: flex;
|
|
10531
|
+
align-items: center;
|
|
10532
|
+
margin-bottom: 4px;
|
|
10533
|
+
> * {
|
|
8403
10534
|
margin-left: 4px;
|
|
8404
10535
|
margin-bottom: 0;
|
|
8405
10536
|
height: 100%;
|
|
@@ -8529,7 +10660,7 @@ class CustomHeadersSettings extends React.PureComponent {
|
|
|
8529
10660
|
return {
|
|
8530
10661
|
id: lodash.uniqueId(),
|
|
8531
10662
|
name: jsonData[key],
|
|
8532
|
-
value: secureJsonData !==
|
|
10663
|
+
value: secureJsonData !== void 0 ? secureJsonData[key] : "",
|
|
8533
10664
|
configured: secureJsonFields && secureJsonFields[`httpHeaderValue${index + 1}`] || false
|
|
8534
10665
|
};
|
|
8535
10666
|
})
|
|
@@ -8600,8 +10731,8 @@ class QueryModellerBase {
|
|
|
8600
10731
|
hasBinaryOp(query) {
|
|
8601
10732
|
return query.operations.find((op) => {
|
|
8602
10733
|
const def = this.getOperationDefinition(op.id);
|
|
8603
|
-
return (def == null ?
|
|
8604
|
-
}) !==
|
|
10734
|
+
return (def == null ? void 0 : def.category) === BINARY_OPERATIONS_KEY;
|
|
10735
|
+
}) !== void 0;
|
|
8605
10736
|
}
|
|
8606
10737
|
}
|
|
8607
10738
|
|
|
@@ -8624,7 +10755,7 @@ function LabelFilterItem({
|
|
|
8624
10755
|
const [labelValuesMenuOpen, setLabelValuesMenuOpen] = React.useState(false);
|
|
8625
10756
|
const isMultiSelect = (operator = item.op) => {
|
|
8626
10757
|
var _a2;
|
|
8627
|
-
return (_a2 = operators.find((op) => op.label === operator)) == null ?
|
|
10758
|
+
return (_a2 = operators.find((op) => op.label === operator)) == null ? void 0 : _a2.isMultiValue;
|
|
8628
10759
|
};
|
|
8629
10760
|
const getSelectOptionsFromString = (item2) => {
|
|
8630
10761
|
if (item2) {
|
|
@@ -8637,12 +10768,12 @@ function LabelFilterItem({
|
|
|
8637
10768
|
};
|
|
8638
10769
|
const getOptions = () => {
|
|
8639
10770
|
const labelValues = state.labelValues ? [...state.labelValues] : [];
|
|
8640
|
-
const selectedOptions = getSelectOptionsFromString(item == null ?
|
|
10771
|
+
const selectedOptions = getSelectOptionsFromString(item == null ? void 0 : item.value).map(data.toOption);
|
|
8641
10772
|
return lodash.uniqBy([...selectedOptions, ...labelValues], "value");
|
|
8642
10773
|
};
|
|
8643
10774
|
const isConflicting = isConflictingLabelFilter(item, items);
|
|
8644
10775
|
const { current: id } = React.useRef(uuid.v4());
|
|
8645
|
-
return /* @__PURE__ */ React__default.default.createElement("div", { "data-testid": "visual-query-builder-dimensions-filter-item" }, /* @__PURE__ */ React__default.default.createElement(ui.InlineField, { error: CONFLICTING_LABEL_FILTER_ERROR_MESSAGE, invalid: isConflicting ? true :
|
|
10776
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { "data-testid": "visual-query-builder-dimensions-filter-item" }, /* @__PURE__ */ React__default.default.createElement(ui.InlineField, { error: CONFLICTING_LABEL_FILTER_ERROR_MESSAGE, invalid: isConflicting ? true : void 0 }, /* @__PURE__ */ React__default.default.createElement(InputGroup, null, /* @__PURE__ */ React__default.default.createElement(
|
|
8646
10777
|
ui.Select,
|
|
8647
10778
|
{
|
|
8648
10779
|
placeholder: "Select label",
|
|
@@ -8655,7 +10786,7 @@ function LabelFilterItem({
|
|
|
8655
10786
|
setState({ isLoadingLabelNames: true });
|
|
8656
10787
|
const labelNames = await onGetLabelNames(item);
|
|
8657
10788
|
setLabelNamesMenuOpen(true);
|
|
8658
|
-
setState({ labelNames, isLoadingLabelNames:
|
|
10789
|
+
setState({ labelNames, isLoadingLabelNames: void 0 });
|
|
8659
10790
|
},
|
|
8660
10791
|
onCloseMenu: () => {
|
|
8661
10792
|
setLabelNamesMenuOpen(false);
|
|
@@ -8687,7 +10818,7 @@ function LabelFilterItem({
|
|
|
8687
10818
|
onChange({
|
|
8688
10819
|
...item,
|
|
8689
10820
|
op: change.value,
|
|
8690
|
-
value: isMultiSelect(change.value) ? item.value : getSelectOptionsFromString(item == null ?
|
|
10821
|
+
value: isMultiSelect(change.value) ? item.value : getSelectOptionsFromString(item == null ? void 0 : item.value)[0]
|
|
8691
10822
|
});
|
|
8692
10823
|
}
|
|
8693
10824
|
},
|
|
@@ -8700,7 +10831,7 @@ function LabelFilterItem({
|
|
|
8700
10831
|
"data-testid": e2eSelectors.selectors.components.QueryBuilder.valueSelect,
|
|
8701
10832
|
inputId: `visual-query-builder-dimensions-filter-item-value-${id}`,
|
|
8702
10833
|
width: "auto",
|
|
8703
|
-
value: isMultiSelect() ? getSelectOptionsFromString(item == null ?
|
|
10834
|
+
value: isMultiSelect() ? getSelectOptionsFromString(item == null ? void 0 : item.value).map(data.toOption) : getSelectOptionsFromString(item == null ? void 0 : item.value).map(data.toOption)[0],
|
|
8704
10835
|
allowCustomValue: true,
|
|
8705
10836
|
onOpenMenu: async () => {
|
|
8706
10837
|
setState({ isLoadingLabelValues: true });
|
|
@@ -8708,7 +10839,7 @@ function LabelFilterItem({
|
|
|
8708
10839
|
setState({
|
|
8709
10840
|
...state,
|
|
8710
10841
|
labelValues,
|
|
8711
|
-
isLoadingLabelValues:
|
|
10842
|
+
isLoadingLabelValues: void 0
|
|
8712
10843
|
});
|
|
8713
10844
|
setLabelValuesMenuOpen(true);
|
|
8714
10845
|
},
|
|
@@ -8732,9 +10863,9 @@ function LabelFilterItem({
|
|
|
8732
10863
|
if (change2.value) {
|
|
8733
10864
|
return change2.value;
|
|
8734
10865
|
} else {
|
|
8735
|
-
return
|
|
10866
|
+
return void 0;
|
|
8736
10867
|
}
|
|
8737
|
-
}).filter((val) => val !==
|
|
10868
|
+
}).filter((val) => val !== void 0).join(multiValueSeparator);
|
|
8738
10869
|
onChange({ ...item, value: changes, op: (_b = item.op) != null ? _b : defaultOp });
|
|
8739
10870
|
}
|
|
8740
10871
|
},
|
|
@@ -8761,10 +10892,10 @@ function isConflictingLabelFilter(newLabel, labels) {
|
|
|
8761
10892
|
);
|
|
8762
10893
|
const conflict = candidates.some((candidate) => {
|
|
8763
10894
|
var _a, _b;
|
|
8764
|
-
if (operationIsNegative && ((_a = candidate == null ?
|
|
10895
|
+
if (operationIsNegative && ((_a = candidate == null ? void 0 : candidate.op) == null ? void 0 : _a.toString().startsWith("!")) === false) {
|
|
8765
10896
|
return true;
|
|
8766
10897
|
}
|
|
8767
|
-
if (operationIsNegative === false && ((_b = candidate == null ?
|
|
10898
|
+
if (operationIsNegative === false && ((_b = candidate == null ? void 0 : candidate.op) == null ? void 0 : _b.toString().startsWith("!"))) {
|
|
8768
10899
|
return true;
|
|
8769
10900
|
}
|
|
8770
10901
|
return false;
|
|
@@ -8793,7 +10924,7 @@ function LabelFilters({
|
|
|
8793
10924
|
const onLabelsChange = (newItems) => {
|
|
8794
10925
|
setItems(newItems);
|
|
8795
10926
|
const newLabels = newItems.filter(
|
|
8796
|
-
(item) => item.label !==
|
|
10927
|
+
(item) => item.label !== void 0 && item.value !== void 0
|
|
8797
10928
|
);
|
|
8798
10929
|
if (!lodash.isEqual(newLabels, labelsFilters)) {
|
|
8799
10930
|
onChange(newLabels);
|
|
@@ -8834,7 +10965,7 @@ function LabelFilters({
|
|
|
8834
10965
|
|
|
8835
10966
|
function OperationExplainedBox({ title, stepNumber, markdown, children }) {
|
|
8836
10967
|
const styles = ui.useStyles2(getStyles$b);
|
|
8837
|
-
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.box }, stepNumber !==
|
|
10968
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.box }, stepNumber !== void 0 && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.stepNumber }, stepNumber), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.boxInner }, title && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.header }, /* @__PURE__ */ React__default.default.createElement("span", null, title)), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.body }, markdown && /* @__PURE__ */ React__default.default.createElement("div", { dangerouslySetInnerHTML: { __html: data.renderMarkdown(markdown) } }), children)));
|
|
8838
10969
|
}
|
|
8839
10970
|
const getStyles$b = (theme) => {
|
|
8840
10971
|
return {
|
|
@@ -9077,7 +11208,7 @@ function SimpleInputParamEditor(props) {
|
|
|
9077
11208
|
ui.AutoSizeInput,
|
|
9078
11209
|
{
|
|
9079
11210
|
id: getOperationParamId(props.operationId, props.index),
|
|
9080
|
-
defaultValue: (_a = props.value) == null ?
|
|
11211
|
+
defaultValue: (_a = props.value) == null ? void 0 : _a.toString(),
|
|
9081
11212
|
minWidth: props.paramDef.minWidth,
|
|
9082
11213
|
placeholder: props.paramDef.placeholder,
|
|
9083
11214
|
title: props.paramDef.description,
|
|
@@ -9111,7 +11242,7 @@ function SelectInputParamEditor({
|
|
|
9111
11242
|
var _a, _b;
|
|
9112
11243
|
const styles = ui.useStyles2(getStyles$8);
|
|
9113
11244
|
let selectOptions = paramDef.options;
|
|
9114
|
-
if (!((_a = selectOptions[0]) == null ?
|
|
11245
|
+
if (!((_a = selectOptions[0]) == null ? void 0 : _a.label)) {
|
|
9115
11246
|
selectOptions = paramDef.options.map((option) => ({
|
|
9116
11247
|
label: option.toString(),
|
|
9117
11248
|
value: option
|
|
@@ -9416,9 +11547,9 @@ function OperationEditor({
|
|
|
9416
11547
|
}
|
|
9417
11548
|
const isInvalid = (isDragging) => {
|
|
9418
11549
|
if (isDragging) {
|
|
9419
|
-
return
|
|
11550
|
+
return void 0;
|
|
9420
11551
|
}
|
|
9421
|
-
return isConflicting ? true :
|
|
11552
|
+
return isConflicting ? true : void 0;
|
|
9422
11553
|
};
|
|
9423
11554
|
return /* @__PURE__ */ React__default.default.createElement(dnd.Draggable, { draggableId: `operation-${index}`, index }, (provided, snapshot) => /* @__PURE__ */ React__default.default.createElement(
|
|
9424
11555
|
ui.InlineField,
|
|
@@ -9572,7 +11703,7 @@ function useOperationsHighlight(operations) {
|
|
|
9572
11703
|
} else {
|
|
9573
11704
|
newOps = operations.map((op, index) => {
|
|
9574
11705
|
var _a;
|
|
9575
|
-
return !isSameOp(op.id, (_a = prevOperations[index]) == null ?
|
|
11706
|
+
return !isSameOp(op.id, (_a = prevOperations[index]) == null ? void 0 : _a.id);
|
|
9576
11707
|
});
|
|
9577
11708
|
}
|
|
9578
11709
|
return newOps;
|
|
@@ -9644,8 +11775,8 @@ function OperationListExplained({
|
|
|
9644
11775
|
"div",
|
|
9645
11776
|
{
|
|
9646
11777
|
key: index,
|
|
9647
|
-
onMouseEnter: () => onMouseEnter == null ?
|
|
9648
|
-
onMouseLeave: () => onMouseLeave == null ?
|
|
11778
|
+
onMouseEnter: () => onMouseEnter == null ? void 0 : onMouseEnter(op, index),
|
|
11779
|
+
onMouseLeave: () => onMouseLeave == null ? void 0 : onMouseLeave(op, index)
|
|
9649
11780
|
},
|
|
9650
11781
|
/* @__PURE__ */ React__default.default.createElement(
|
|
9651
11782
|
OperationExplainedBox,
|
|
@@ -9687,15 +11818,15 @@ const QueryBuilderHints = ({
|
|
|
9687
11818
|
const hints = React.useMemo(() => {
|
|
9688
11819
|
var _a;
|
|
9689
11820
|
const dataQuery = buildDataQueryFromQueryString(queryModeller.renderQuery(visualQuery));
|
|
9690
|
-
const hints2 = (_a = datasource.getQueryHints) == null ?
|
|
11821
|
+
const hints2 = (_a = datasource.getQueryHints) == null ? void 0 : _a.call(datasource, dataQuery, (data == null ? void 0 : data.series) || []).filter((hint) => {
|
|
9691
11822
|
var _a2;
|
|
9692
|
-
return (_a2 = hint.fix) == null ?
|
|
11823
|
+
return (_a2 = hint.fix) == null ? void 0 : _a2.action;
|
|
9693
11824
|
});
|
|
9694
11825
|
return hints2 != null ? hints2 : [];
|
|
9695
11826
|
}, [datasource, visualQuery, data, queryModeller, buildDataQueryFromQueryString]);
|
|
9696
11827
|
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, hints.length > 0 && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, hints.map((hint) => {
|
|
9697
11828
|
var _a, _b, _c, _d;
|
|
9698
|
-
return /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: `${hint.label} ${(_a = hint.fix) == null ?
|
|
11829
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: `${hint.label} ${(_a = hint.fix) == null ? void 0 : _a.label}`, key: hint.type }, /* @__PURE__ */ React__default.default.createElement(
|
|
9699
11830
|
ui.Button,
|
|
9700
11831
|
{
|
|
9701
11832
|
onClick: () => {
|
|
@@ -9704,9 +11835,9 @@ const QueryBuilderHints = ({
|
|
|
9704
11835
|
hint: hint.type,
|
|
9705
11836
|
datasourceType: datasource.type
|
|
9706
11837
|
});
|
|
9707
|
-
if ((_a2 = hint == null ?
|
|
11838
|
+
if ((_a2 = hint == null ? void 0 : hint.fix) == null ? void 0 : _a2.action) {
|
|
9708
11839
|
const dataQuery = buildDataQueryFromQueryString(queryModeller.renderQuery(visualQuery));
|
|
9709
|
-
const newQuery = (_b2 = datasource.modifyQuery) == null ?
|
|
11840
|
+
const newQuery = (_b2 = datasource.modifyQuery) == null ? void 0 : _b2.call(datasource, dataQuery, hint.fix.action);
|
|
9710
11841
|
if (newQuery) {
|
|
9711
11842
|
const newVisualQuery = buildVisualQueryFromString(
|
|
9712
11843
|
(_c2 = buildQueryStringFromDataQuery(newQuery)) != null ? _c2 : ""
|
|
@@ -9720,7 +11851,7 @@ const QueryBuilderHints = ({
|
|
|
9720
11851
|
className: styles.hint
|
|
9721
11852
|
},
|
|
9722
11853
|
"hint: ",
|
|
9723
|
-
((_b = hint.fix) == null ?
|
|
11854
|
+
((_b = hint.fix) == null ? void 0 : _b.title) || ((_d = (_c = hint.fix) == null ? void 0 : _c.action) == null ? void 0 : _d.type.toLowerCase().replace("_", " "))
|
|
9724
11855
|
));
|
|
9725
11856
|
})));
|
|
9726
11857
|
};
|
|
@@ -9843,6 +11974,411 @@ const convertUnits = (queryStats) => {
|
|
|
9843
11974
|
return text + suffix;
|
|
9844
11975
|
};
|
|
9845
11976
|
|
|
11977
|
+
function generateLLMHint(schema) {
|
|
11978
|
+
var _a, _b, _c, _d;
|
|
11979
|
+
const hints = [];
|
|
11980
|
+
for (const field of schema.fields) {
|
|
11981
|
+
if (((_a = field.ui) == null ? void 0 : _a.component) !== "select" || field.target !== "jsonData" || field.kind === "virtual") {
|
|
11982
|
+
continue;
|
|
11983
|
+
}
|
|
11984
|
+
const options = (_c = (_b = field.ui) == null ? void 0 : _b.options) != null ? _c : [];
|
|
11985
|
+
const values = options.map((opt) => {
|
|
11986
|
+
const isDefault = field.defaultValue != null && String(opt.value) === String(field.defaultValue);
|
|
11987
|
+
return isDefault ? `"${opt.value}" (default)` : `"${opt.value}"`;
|
|
11988
|
+
}).join(", ");
|
|
11989
|
+
if (values) {
|
|
11990
|
+
hints.push(`- ${(_d = field.label) != null ? _d : field.key}: jsonData.${field.key} \u2014 values: ${values}`);
|
|
11991
|
+
}
|
|
11992
|
+
}
|
|
11993
|
+
return hints.join("\n");
|
|
11994
|
+
}
|
|
11995
|
+
function generateTroubleshootingFields(schema) {
|
|
11996
|
+
var _a, _b, _c;
|
|
11997
|
+
const result = [];
|
|
11998
|
+
for (const field of schema.fields) {
|
|
11999
|
+
if (field.kind === "virtual" || field.isItemField) {
|
|
12000
|
+
continue;
|
|
12001
|
+
}
|
|
12002
|
+
const entry = {
|
|
12003
|
+
label: (_a = field.label) != null ? _a : field.key,
|
|
12004
|
+
key: field.target === "root" ? field.key : `${field.target}.${field.key}`,
|
|
12005
|
+
target: (_b = field.target) != null ? _b : "jsonData",
|
|
12006
|
+
type: field.valueType,
|
|
12007
|
+
required: !!field.required
|
|
12008
|
+
};
|
|
12009
|
+
if (field.description) {
|
|
12010
|
+
entry.description = field.description;
|
|
12011
|
+
}
|
|
12012
|
+
if (field.defaultValue != null) {
|
|
12013
|
+
entry.defaultValue = field.defaultValue;
|
|
12014
|
+
}
|
|
12015
|
+
if (((_c = field.ui) == null ? void 0 : _c.options) && field.ui.options.length > 0) {
|
|
12016
|
+
entry.options = field.ui.options.map((o) => String(o.value));
|
|
12017
|
+
}
|
|
12018
|
+
if (field.section) {
|
|
12019
|
+
entry.section = field.section;
|
|
12020
|
+
}
|
|
12021
|
+
if (field.dependsOn) {
|
|
12022
|
+
entry.dependsOn = field.dependsOn;
|
|
12023
|
+
}
|
|
12024
|
+
result.push(entry);
|
|
12025
|
+
}
|
|
12026
|
+
return result;
|
|
12027
|
+
}
|
|
12028
|
+
|
|
12029
|
+
function yamlIndent(depth) {
|
|
12030
|
+
return " ".repeat(depth);
|
|
12031
|
+
}
|
|
12032
|
+
function yamlString(value) {
|
|
12033
|
+
if (value === null || value === void 0) {
|
|
12034
|
+
return '""';
|
|
12035
|
+
}
|
|
12036
|
+
const s = String(value);
|
|
12037
|
+
if (s === "") {
|
|
12038
|
+
return '""';
|
|
12039
|
+
}
|
|
12040
|
+
return yaml__default.default.dump(s, { lineWidth: -1 }).trimEnd();
|
|
12041
|
+
}
|
|
12042
|
+
function yamlValue(value, depth) {
|
|
12043
|
+
if (value === null || value === void 0) {
|
|
12044
|
+
return '""';
|
|
12045
|
+
}
|
|
12046
|
+
if (typeof value === "boolean") {
|
|
12047
|
+
return value ? "true" : "false";
|
|
12048
|
+
}
|
|
12049
|
+
if (typeof value === "number") {
|
|
12050
|
+
return String(value);
|
|
12051
|
+
}
|
|
12052
|
+
if (typeof value === "string") {
|
|
12053
|
+
return yamlString(value);
|
|
12054
|
+
}
|
|
12055
|
+
if (Array.isArray(value)) {
|
|
12056
|
+
if (value.length === 0) {
|
|
12057
|
+
return "[]";
|
|
12058
|
+
}
|
|
12059
|
+
const lines = value.map((item) => {
|
|
12060
|
+
if (typeof item === "object" && item !== null && !Array.isArray(item)) {
|
|
12061
|
+
const entries = Object.entries(item);
|
|
12062
|
+
if (entries.length === 0) {
|
|
12063
|
+
return `${yamlIndent(depth)}- {}`;
|
|
12064
|
+
}
|
|
12065
|
+
const [firstKey, firstVal] = entries[0];
|
|
12066
|
+
const firstLine = `${yamlIndent(depth)}- ${yamlString(firstKey)}: ${yamlValue(firstVal, depth + 2)}`;
|
|
12067
|
+
const rest = entries.slice(1).map(([k, v]) => `${yamlIndent(depth + 1)}${yamlString(k)}: ${yamlValue(v, depth + 2)}`);
|
|
12068
|
+
return [firstLine, ...rest].join("\n");
|
|
12069
|
+
}
|
|
12070
|
+
return `${yamlIndent(depth)}- ${yamlValue(item, depth + 1)}`;
|
|
12071
|
+
});
|
|
12072
|
+
return "\n" + lines.join("\n");
|
|
12073
|
+
}
|
|
12074
|
+
if (typeof value === "object") {
|
|
12075
|
+
const entries = Object.entries(value);
|
|
12076
|
+
if (entries.length === 0) {
|
|
12077
|
+
return "{}";
|
|
12078
|
+
}
|
|
12079
|
+
const lines = entries.map(([k, v]) => `${yamlIndent(depth)}${yamlString(k)}: ${yamlValue(v, depth + 1)}`);
|
|
12080
|
+
return "\n" + lines.join("\n");
|
|
12081
|
+
}
|
|
12082
|
+
return yamlString(value);
|
|
12083
|
+
}
|
|
12084
|
+
function isCertField(field) {
|
|
12085
|
+
var _a;
|
|
12086
|
+
const k = field.key.toLowerCase();
|
|
12087
|
+
return field.target === "secureJsonData" && (k.includes("cert") || k.includes("key") || ((_a = field.ui) == null ? void 0 : _a.component) === "textarea");
|
|
12088
|
+
}
|
|
12089
|
+
function isExcludedFromProvisioning(field) {
|
|
12090
|
+
var _a, _b;
|
|
12091
|
+
if (field.kind === "virtual") {
|
|
12092
|
+
return true;
|
|
12093
|
+
}
|
|
12094
|
+
if (field.isItemField) {
|
|
12095
|
+
return true;
|
|
12096
|
+
}
|
|
12097
|
+
if (((_a = field.tags) == null ? void 0 : _a.some((t) => t.startsWith("managed-by:"))) && field.target !== "root") {
|
|
12098
|
+
return true;
|
|
12099
|
+
}
|
|
12100
|
+
if (((_b = field.storage) == null ? void 0 : _b.type) === "indexedPair") {
|
|
12101
|
+
return true;
|
|
12102
|
+
}
|
|
12103
|
+
return false;
|
|
12104
|
+
}
|
|
12105
|
+
function secretPlaceholder(field) {
|
|
12106
|
+
if (isCertField(field)) {
|
|
12107
|
+
return "|\n xxxxxx";
|
|
12108
|
+
}
|
|
12109
|
+
return "xxxxxx";
|
|
12110
|
+
}
|
|
12111
|
+
function templateValue(field) {
|
|
12112
|
+
var _a;
|
|
12113
|
+
if (field.defaultValue !== void 0) {
|
|
12114
|
+
return field.defaultValue;
|
|
12115
|
+
}
|
|
12116
|
+
if (((_a = field.ui) == null ? void 0 : _a.options) && field.ui.options.length > 0) {
|
|
12117
|
+
return field.ui.options[0].value;
|
|
12118
|
+
}
|
|
12119
|
+
switch (field.valueType) {
|
|
12120
|
+
case "string":
|
|
12121
|
+
return "";
|
|
12122
|
+
case "number":
|
|
12123
|
+
return 0;
|
|
12124
|
+
case "boolean":
|
|
12125
|
+
return false;
|
|
12126
|
+
case "array":
|
|
12127
|
+
return [];
|
|
12128
|
+
case "object":
|
|
12129
|
+
case "map":
|
|
12130
|
+
return {};
|
|
12131
|
+
default:
|
|
12132
|
+
return "";
|
|
12133
|
+
}
|
|
12134
|
+
}
|
|
12135
|
+
function fieldComment(field, indent) {
|
|
12136
|
+
var _a, _b, _c;
|
|
12137
|
+
const parts = [];
|
|
12138
|
+
const label = (_a = field.label) != null ? _a : field.key;
|
|
12139
|
+
let line = label;
|
|
12140
|
+
if (field.required) {
|
|
12141
|
+
line += " (REQUIRED)";
|
|
12142
|
+
}
|
|
12143
|
+
if (field.description) {
|
|
12144
|
+
line += ` \u2014 ${field.description}`;
|
|
12145
|
+
}
|
|
12146
|
+
parts.push(`${indent}# ${line}`);
|
|
12147
|
+
const options = (_b = field.ui) == null ? void 0 : _b.options;
|
|
12148
|
+
if (options && options.length > 0) {
|
|
12149
|
+
const vals = options.map((o) => String(o.value)).join(", ");
|
|
12150
|
+
parts.push(`${indent}# Allowed values: ${vals}`);
|
|
12151
|
+
}
|
|
12152
|
+
const allowedValuesRule = (_c = field.validations) == null ? void 0 : _c.find(
|
|
12153
|
+
(v) => v.type === "allowedValues"
|
|
12154
|
+
);
|
|
12155
|
+
if (allowedValuesRule && !options) {
|
|
12156
|
+
const vals = allowedValuesRule.values.map((v) => String(v)).join(", ");
|
|
12157
|
+
parts.push(`${indent}# Allowed values: ${vals}`);
|
|
12158
|
+
}
|
|
12159
|
+
if (field.dependsOn) {
|
|
12160
|
+
parts.push(`${indent}# Only when: ${field.dependsOn}`);
|
|
12161
|
+
}
|
|
12162
|
+
return parts.join("\n");
|
|
12163
|
+
}
|
|
12164
|
+
function toProvisioningYaml(schema, values, options) {
|
|
12165
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12166
|
+
const isTemplate = !values;
|
|
12167
|
+
const showComments = (_a = options == null ? void 0 : options.comments) != null ? _a : isTemplate;
|
|
12168
|
+
const indent2 = " ";
|
|
12169
|
+
const indent3 = " ";
|
|
12170
|
+
const groups = resolveGroups(schema);
|
|
12171
|
+
const rootFields = [];
|
|
12172
|
+
const jsonDataFieldsByGroup = [];
|
|
12173
|
+
const secureJsonDataFieldsByGroup = [];
|
|
12174
|
+
const virtualFieldsWithOptions = [];
|
|
12175
|
+
for (const { group, fields } of groups) {
|
|
12176
|
+
const jd = [];
|
|
12177
|
+
const sd = [];
|
|
12178
|
+
for (const field of fields) {
|
|
12179
|
+
if (field.kind === "virtual" && ((_b = field.ui) == null ? void 0 : _b.options) && field.ui.options.length > 0) {
|
|
12180
|
+
virtualFieldsWithOptions.push(field);
|
|
12181
|
+
continue;
|
|
12182
|
+
}
|
|
12183
|
+
if (isExcludedFromProvisioning(field)) {
|
|
12184
|
+
continue;
|
|
12185
|
+
}
|
|
12186
|
+
switch (field.target) {
|
|
12187
|
+
case "root":
|
|
12188
|
+
rootFields.push(field);
|
|
12189
|
+
break;
|
|
12190
|
+
case "jsonData":
|
|
12191
|
+
jd.push(field);
|
|
12192
|
+
break;
|
|
12193
|
+
case "secureJsonData":
|
|
12194
|
+
sd.push(field);
|
|
12195
|
+
break;
|
|
12196
|
+
}
|
|
12197
|
+
}
|
|
12198
|
+
if (jd.length > 0) {
|
|
12199
|
+
jsonDataFieldsByGroup.push({ group, fields: jd });
|
|
12200
|
+
}
|
|
12201
|
+
if (sd.length > 0) {
|
|
12202
|
+
secureJsonDataFieldsByGroup.push({ group, fields: sd });
|
|
12203
|
+
}
|
|
12204
|
+
}
|
|
12205
|
+
const allSecureJsonDataFields = secureJsonDataFieldsByGroup.flatMap((g) => g.fields);
|
|
12206
|
+
const groupedFieldIds = new Set(groups.flatMap(({ group }) => group.fieldRefs));
|
|
12207
|
+
for (const field of schema.fields) {
|
|
12208
|
+
if (field.target === "root" && !groupedFieldIds.has(field.id) && !isExcludedFromProvisioning(field)) {
|
|
12209
|
+
rootFields.push(field);
|
|
12210
|
+
}
|
|
12211
|
+
}
|
|
12212
|
+
const lines = [];
|
|
12213
|
+
lines.push("apiVersion: 1");
|
|
12214
|
+
lines.push("");
|
|
12215
|
+
lines.push("datasources:");
|
|
12216
|
+
lines.push(`${indent2.slice(2)}- name: ${yamlString((_d = (_c = options == null ? void 0 : options.name) != null ? _c : values == null ? void 0 : values.name) != null ? _d : `my-${schema.pluginType}`)}`);
|
|
12217
|
+
lines.push(`${indent2}type: ${schema.pluginType}`);
|
|
12218
|
+
if (!isTemplate && (values == null ? void 0 : values.uid)) {
|
|
12219
|
+
lines.push(`${indent2}uid: ${yamlString(values.uid)}`);
|
|
12220
|
+
}
|
|
12221
|
+
const ALREADY_EMITTED_ROOT = /* @__PURE__ */ new Set(["name", "type", "uid"]);
|
|
12222
|
+
for (const field of rootFields) {
|
|
12223
|
+
if (ALREADY_EMITTED_ROOT.has(field.key)) {
|
|
12224
|
+
continue;
|
|
12225
|
+
}
|
|
12226
|
+
const val = values ? values[field.key] : templateValue(field);
|
|
12227
|
+
if (val === void 0 || val === null) {
|
|
12228
|
+
continue;
|
|
12229
|
+
}
|
|
12230
|
+
if (!isTemplate && val === false) {
|
|
12231
|
+
continue;
|
|
12232
|
+
}
|
|
12233
|
+
if (showComments) {
|
|
12234
|
+
lines.push(fieldComment(field, indent2));
|
|
12235
|
+
}
|
|
12236
|
+
lines.push(`${indent2}${field.key}: ${yamlValue(val, 3)}`);
|
|
12237
|
+
}
|
|
12238
|
+
if (showComments) {
|
|
12239
|
+
for (const vf of virtualFieldsWithOptions) {
|
|
12240
|
+
const label = (_e = vf.label) != null ? _e : vf.key;
|
|
12241
|
+
const opts = vf.ui.options.map((o) => `${String(o.value)} (${o.label})`).join(", ");
|
|
12242
|
+
lines.push(`${indent2}# ${label}: ${opts}`);
|
|
12243
|
+
if (vf.description) {
|
|
12244
|
+
lines.push(`${indent2}# ${vf.description}`);
|
|
12245
|
+
}
|
|
12246
|
+
}
|
|
12247
|
+
}
|
|
12248
|
+
const emittedJsonDataKeys = /* @__PURE__ */ new Set();
|
|
12249
|
+
const emittedSecureJsonDataKeys = /* @__PURE__ */ new Set();
|
|
12250
|
+
const jsonDataValues = values == null ? void 0 : values.jsonData;
|
|
12251
|
+
const hasJsonDataFromSchema = jsonDataFieldsByGroup.length > 0;
|
|
12252
|
+
const hasJsonDataFromValues = !isTemplate && jsonDataValues && Object.keys(jsonDataValues).length > 0;
|
|
12253
|
+
if (hasJsonDataFromSchema || hasJsonDataFromValues) {
|
|
12254
|
+
lines.push(`${indent2}jsonData:`);
|
|
12255
|
+
for (const { group, fields: groupFields } of jsonDataFieldsByGroup) {
|
|
12256
|
+
if (showComments && jsonDataFieldsByGroup.length > 1) {
|
|
12257
|
+
lines.push(`${indent3}# --- ${group.title} ---`);
|
|
12258
|
+
}
|
|
12259
|
+
for (const field of groupFields) {
|
|
12260
|
+
const val = values ? getNestedValue(values, "jsonData", field) : templateValue(field);
|
|
12261
|
+
if (val === void 0 || val === null) {
|
|
12262
|
+
continue;
|
|
12263
|
+
}
|
|
12264
|
+
if (!isTemplate && field.defaultValue !== void 0 && val === field.defaultValue) {
|
|
12265
|
+
continue;
|
|
12266
|
+
}
|
|
12267
|
+
emittedJsonDataKeys.add(field.key);
|
|
12268
|
+
if (showComments) {
|
|
12269
|
+
lines.push(fieldComment(field, indent3));
|
|
12270
|
+
}
|
|
12271
|
+
const rendered = yamlValue(val, 4);
|
|
12272
|
+
if (rendered.startsWith("\n")) {
|
|
12273
|
+
lines.push(`${indent3}${field.key}:${rendered}`);
|
|
12274
|
+
} else {
|
|
12275
|
+
lines.push(`${indent3}${field.key}: ${rendered}`);
|
|
12276
|
+
}
|
|
12277
|
+
}
|
|
12278
|
+
}
|
|
12279
|
+
if (!isTemplate && jsonDataValues) {
|
|
12280
|
+
for (const [key, val] of Object.entries(jsonDataValues)) {
|
|
12281
|
+
if (emittedJsonDataKeys.has(key)) {
|
|
12282
|
+
continue;
|
|
12283
|
+
}
|
|
12284
|
+
if (val === void 0 || val === null) {
|
|
12285
|
+
continue;
|
|
12286
|
+
}
|
|
12287
|
+
const rendered = yamlValue(val, 4);
|
|
12288
|
+
if (rendered.startsWith("\n")) {
|
|
12289
|
+
lines.push(`${indent3}${key}:${rendered}`);
|
|
12290
|
+
} else {
|
|
12291
|
+
lines.push(`${indent3}${key}: ${rendered}`);
|
|
12292
|
+
}
|
|
12293
|
+
}
|
|
12294
|
+
}
|
|
12295
|
+
}
|
|
12296
|
+
const secureJsonFields = (_f = values == null ? void 0 : values.secureJsonFields) != null ? _f : {};
|
|
12297
|
+
const inferredSecureKeys = !isTemplate ? inferSecureJsonDataKeys(jsonDataValues) : [];
|
|
12298
|
+
const activeSecureFields = isTemplate ? allSecureJsonDataFields : allSecureJsonDataFields.filter((f) => secureJsonFields[f.key] === true);
|
|
12299
|
+
if (activeSecureFields.length > 0 || inferredSecureKeys.length > 0) {
|
|
12300
|
+
lines.push(`${indent2}secureJsonData:`);
|
|
12301
|
+
for (const field of activeSecureFields) {
|
|
12302
|
+
emittedSecureJsonDataKeys.add(field.key);
|
|
12303
|
+
if (showComments) {
|
|
12304
|
+
lines.push(fieldComment(field, indent3));
|
|
12305
|
+
}
|
|
12306
|
+
lines.push(`${indent3}${field.key}: ${secretPlaceholder(field)}`);
|
|
12307
|
+
}
|
|
12308
|
+
for (const key of inferredSecureKeys) {
|
|
12309
|
+
if (emittedSecureJsonDataKeys.has(key)) {
|
|
12310
|
+
continue;
|
|
12311
|
+
}
|
|
12312
|
+
lines.push(`${indent3}${key}: xxxxxx`);
|
|
12313
|
+
}
|
|
12314
|
+
}
|
|
12315
|
+
return lines.join("\n");
|
|
12316
|
+
}
|
|
12317
|
+
function inferSecureJsonDataKeys(jsonData) {
|
|
12318
|
+
if (!jsonData) {
|
|
12319
|
+
return [];
|
|
12320
|
+
}
|
|
12321
|
+
const keys = [];
|
|
12322
|
+
for (const key of Object.keys(jsonData)) {
|
|
12323
|
+
const match = key.match(/^httpHeaderName(\d+)$/);
|
|
12324
|
+
if (match) {
|
|
12325
|
+
keys.push(`httpHeaderValue${match[1]}`);
|
|
12326
|
+
}
|
|
12327
|
+
}
|
|
12328
|
+
return keys;
|
|
12329
|
+
}
|
|
12330
|
+
function getNestedValue(values, target, field) {
|
|
12331
|
+
const nested = values[target];
|
|
12332
|
+
if (nested && typeof nested === "object") {
|
|
12333
|
+
return nested[field.key];
|
|
12334
|
+
}
|
|
12335
|
+
return void 0;
|
|
12336
|
+
}
|
|
12337
|
+
function datasourceToProvisioningYaml(ds, schema) {
|
|
12338
|
+
if (schema) {
|
|
12339
|
+
return toProvisioningYaml(schema, ds, { comments: false });
|
|
12340
|
+
}
|
|
12341
|
+
const lines = [];
|
|
12342
|
+
lines.push("apiVersion: 1");
|
|
12343
|
+
lines.push("");
|
|
12344
|
+
lines.push("datasources:");
|
|
12345
|
+
lines.push(` - name: ${yamlString(ds.name)}`);
|
|
12346
|
+
if (ds.uid) {
|
|
12347
|
+
lines.push(` uid: ${yamlString(ds.uid)}`);
|
|
12348
|
+
}
|
|
12349
|
+
lines.push(` type: ${yamlString(ds.type)}`);
|
|
12350
|
+
if (ds.url) {
|
|
12351
|
+
lines.push(` url: ${yamlString(ds.url)}`);
|
|
12352
|
+
}
|
|
12353
|
+
if (ds.database) {
|
|
12354
|
+
lines.push(` database: ${yamlString(ds.database)}`);
|
|
12355
|
+
}
|
|
12356
|
+
if (ds.isDefault) {
|
|
12357
|
+
lines.push(" isDefault: true");
|
|
12358
|
+
}
|
|
12359
|
+
if (ds.basicAuth) {
|
|
12360
|
+
lines.push(" basicAuth: true");
|
|
12361
|
+
if (ds.basicAuthUser) {
|
|
12362
|
+
lines.push(` basicAuthUser: ${yamlString(ds.basicAuthUser)}`);
|
|
12363
|
+
}
|
|
12364
|
+
}
|
|
12365
|
+
const jsonData = ds.jsonData;
|
|
12366
|
+
if (jsonData && Object.keys(jsonData).length > 0) {
|
|
12367
|
+
lines.push(" jsonData:");
|
|
12368
|
+
for (const [key, val] of Object.entries(jsonData)) {
|
|
12369
|
+
const rendered = yamlValue(val, 4);
|
|
12370
|
+
if (rendered.startsWith("\n")) {
|
|
12371
|
+
lines.push(` ${key}:${rendered}`);
|
|
12372
|
+
} else {
|
|
12373
|
+
lines.push(` ${key}: ${rendered}`);
|
|
12374
|
+
}
|
|
12375
|
+
}
|
|
12376
|
+
}
|
|
12377
|
+
lines.push(" # secureJsonData: (secrets are not exported \u2014 add manually)");
|
|
12378
|
+
lines.push(" # mySecret: xxxxxx");
|
|
12379
|
+
return lines.join("\n");
|
|
12380
|
+
}
|
|
12381
|
+
|
|
9846
12382
|
exports.AccessoryButton = AccessoryButton;
|
|
9847
12383
|
exports.AdvancedHttpSettings = AdvancedHttpSettings;
|
|
9848
12384
|
exports.Auth = Auth;
|
|
@@ -9862,6 +12398,7 @@ exports.DataLinks = DataLinks;
|
|
|
9862
12398
|
exports.DataSourceDescription = DataSourceDescription;
|
|
9863
12399
|
exports.DataSourcePicker = DataSourcePicker;
|
|
9864
12400
|
exports.DatasetSelector = DatasetSelector;
|
|
12401
|
+
exports.DatasourceConfigWizard = DatasourceConfigWizard;
|
|
9865
12402
|
exports.DatePicker = DatePicker;
|
|
9866
12403
|
exports.DatePickerWithInput = DatePickerWithInput;
|
|
9867
12404
|
exports.DebounceInput = DebounceInput;
|
|
@@ -9897,6 +12434,7 @@ exports.QueryModellerBase = QueryModellerBase;
|
|
|
9897
12434
|
exports.QueryOptionGroup = QueryOptionGroup;
|
|
9898
12435
|
exports.RawQuery = RawQuery;
|
|
9899
12436
|
exports.RunQueryButton = RunQueryButton;
|
|
12437
|
+
exports.SECURE_FIELD_CONFIGURED = SECURE_FIELD_CONFIGURED;
|
|
9900
12438
|
exports.SQLEditor = SQLEditor;
|
|
9901
12439
|
exports.SQLEditorMode = SQLEditorMode;
|
|
9902
12440
|
exports.SQLEditorTestUtils = SQLEditorTestUtils;
|
|
@@ -9910,10 +12448,26 @@ exports.SuggestionKind = SuggestionKind;
|
|
|
9910
12448
|
exports.TLSSettings = TLSSettings;
|
|
9911
12449
|
exports.TableSelector = TableSelector;
|
|
9912
12450
|
exports.TokenType = TokenType;
|
|
12451
|
+
exports.buildDatasourceConfigPayload = buildDatasourceConfigPayload;
|
|
12452
|
+
exports.computeVirtualFieldValues = computeVirtualFieldValues;
|
|
9913
12453
|
exports.convertLegacyAuthProps = convertLegacyAuthProps;
|
|
12454
|
+
exports.datasourceToProvisioningYaml = datasourceToProvisioningYaml;
|
|
12455
|
+
exports.evaluateComputedRead = evaluateComputedRead;
|
|
12456
|
+
exports.expandIndexedPair = expandIndexedPair;
|
|
12457
|
+
exports.fetchExistingValues = fetchExistingValues;
|
|
12458
|
+
exports.flattenIndexedPair = flattenIndexedPair;
|
|
12459
|
+
exports.formKey = formKey;
|
|
9914
12460
|
exports.formatDate = formatDate;
|
|
12461
|
+
exports.generateLLMHint = generateLLMHint;
|
|
12462
|
+
exports.generateTroubleshootingFields = generateTroubleshootingFields;
|
|
9915
12463
|
exports.getStandardSQLCompletionProvider = getStandardSQLCompletionProvider;
|
|
9916
12464
|
exports.grafanaStandardSQLLanguage = language;
|
|
9917
12465
|
exports.grafanaStandardSQLLanguageConf = conf;
|
|
12466
|
+
exports.parseDependsOn = parseDependsOn;
|
|
12467
|
+
exports.resolveActiveOverride = resolveActiveOverride;
|
|
12468
|
+
exports.resolveGroups = resolveGroups;
|
|
12469
|
+
exports.resolveRequiredFieldsGroup = resolveRequiredFieldsGroup;
|
|
12470
|
+
exports.submitDatasourceConfig = submitDatasourceConfig;
|
|
9918
12471
|
exports.toOption = toOption;
|
|
12472
|
+
exports.toProvisioningYaml = toProvisioningYaml;
|
|
9919
12473
|
//# sourceMappingURL=index.cjs.map
|