@grafana/plugin-ui 0.14.0-dev.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/cjs/index.cjs +3382 -353
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +102 -39
- package/dist/cjs/test-utils.cjs +7881 -62
- package/dist/cjs/test-utils.cjs.map +1 -1
- package/dist/cjs/test-utils.d.cts +24 -24
- package/dist/esm/_virtual/chance.js +6 -0
- package/dist/esm/_virtual/chance.js.map +1 -0
- package/dist/esm/_virtual/chance2.js +4 -0
- package/dist/esm/_virtual/chance2.js.map +1 -0
- package/dist/esm/_virtual/index.js +6 -0
- package/dist/esm/_virtual/index.js.map +1 -0
- package/dist/esm/_virtual/re.js +4 -0
- package/dist/esm/_virtual/re.js.map +1 -0
- package/dist/esm/async-query-data/DatasourceWithAsyncBackend.js +155 -0
- package/dist/esm/async-query-data/DatasourceWithAsyncBackend.js.map +1 -0
- package/dist/esm/async-query-data/RunQueryButtons.js +52 -0
- package/dist/esm/async-query-data/RunQueryButtons.js.map +1 -0
- package/dist/esm/async-query-data/requestLooper.js +74 -0
- package/dist/esm/async-query-data/requestLooper.js.map +1 -0
- 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/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 +27 -26
- 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/hooks/useDebounce.js.map +1 -1
- package/dist/esm/index.d.ts +102 -39
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node_modules/chance/chance.js +7820 -0
- package/dist/esm/node_modules/chance/chance.js.map +1 -0
- package/dist/esm/node_modules/semver/classes/comparator.js +160 -0
- package/dist/esm/node_modules/semver/classes/comparator.js.map +1 -0
- package/dist/esm/node_modules/semver/classes/range.js +575 -0
- package/dist/esm/node_modules/semver/classes/range.js.map +1 -0
- package/dist/esm/node_modules/semver/classes/semver.js +349 -0
- package/dist/esm/node_modules/semver/classes/semver.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/clean.js +20 -0
- package/dist/esm/node_modules/semver/functions/clean.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/cmp.js +71 -0
- package/dist/esm/node_modules/semver/functions/cmp.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/coerce.js +76 -0
- package/dist/esm/node_modules/semver/functions/coerce.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/compare-build.js +21 -0
- package/dist/esm/node_modules/semver/functions/compare-build.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/compare-loose.js +17 -0
- package/dist/esm/node_modules/semver/functions/compare-loose.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/compare.js +19 -0
- package/dist/esm/node_modules/semver/functions/compare.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/diff.js +72 -0
- package/dist/esm/node_modules/semver/functions/diff.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/eq.js +17 -0
- package/dist/esm/node_modules/semver/functions/eq.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/gt.js +17 -0
- package/dist/esm/node_modules/semver/functions/gt.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/gte.js +17 -0
- package/dist/esm/node_modules/semver/functions/gte.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/inc.js +33 -0
- package/dist/esm/node_modules/semver/functions/inc.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/lt.js +17 -0
- package/dist/esm/node_modules/semver/functions/lt.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/lte.js +17 -0
- package/dist/esm/node_modules/semver/functions/lte.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/major.js +17 -0
- package/dist/esm/node_modules/semver/functions/major.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/minor.js +17 -0
- package/dist/esm/node_modules/semver/functions/minor.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/neq.js +17 -0
- package/dist/esm/node_modules/semver/functions/neq.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/parse.js +30 -0
- package/dist/esm/node_modules/semver/functions/parse.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/patch.js +17 -0
- package/dist/esm/node_modules/semver/functions/patch.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/prerelease.js +20 -0
- package/dist/esm/node_modules/semver/functions/prerelease.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/rcompare.js +17 -0
- package/dist/esm/node_modules/semver/functions/rcompare.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/rsort.js +17 -0
- package/dist/esm/node_modules/semver/functions/rsort.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/satisfies.js +24 -0
- package/dist/esm/node_modules/semver/functions/satisfies.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/sort.js +17 -0
- package/dist/esm/node_modules/semver/functions/sort.js.map +1 -0
- package/dist/esm/node_modules/semver/functions/valid.js +20 -0
- package/dist/esm/node_modules/semver/functions/valid.js.map +1 -0
- package/dist/esm/node_modules/semver/index.js +143 -0
- package/dist/esm/node_modules/semver/index.js.map +1 -0
- package/dist/esm/node_modules/semver/internal/constants.js +47 -0
- package/dist/esm/node_modules/semver/internal/constants.js.map +1 -0
- package/dist/esm/node_modules/semver/internal/debug.js +21 -0
- package/dist/esm/node_modules/semver/internal/debug.js.map +1 -0
- package/dist/esm/node_modules/semver/internal/identifiers.js +39 -0
- package/dist/esm/node_modules/semver/internal/identifiers.js.map +1 -0
- package/dist/esm/node_modules/semver/internal/lrucache.js +52 -0
- package/dist/esm/node_modules/semver/internal/lrucache.js.map +1 -0
- package/dist/esm/node_modules/semver/internal/parse-options.js +27 -0
- package/dist/esm/node_modules/semver/internal/parse-options.js.map +1 -0
- package/dist/esm/node_modules/semver/internal/re.js +238 -0
- package/dist/esm/node_modules/semver/internal/re.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/gtr.js +18 -0
- package/dist/esm/node_modules/semver/ranges/gtr.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/intersects.js +21 -0
- package/dist/esm/node_modules/semver/ranges/intersects.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/ltr.js +18 -0
- package/dist/esm/node_modules/semver/ranges/ltr.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/max-satisfying.js +40 -0
- package/dist/esm/node_modules/semver/ranges/max-satisfying.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/min-satisfying.js +39 -0
- package/dist/esm/node_modules/semver/ranges/min-satisfying.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/min-version.js +77 -0
- package/dist/esm/node_modules/semver/ranges/min-version.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/outside.js +101 -0
- package/dist/esm/node_modules/semver/ranges/outside.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/simplify.js +62 -0
- package/dist/esm/node_modules/semver/ranges/simplify.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/subset.js +264 -0
- package/dist/esm/node_modules/semver/ranges/subset.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/to-comparators.js +22 -0
- package/dist/esm/node_modules/semver/ranges/to-comparators.js.map +1 -0
- package/dist/esm/node_modules/semver/ranges/valid.js +25 -0
- package/dist/esm/node_modules/semver/ranges/valid.js.map +1 -0
- package/dist/esm/test/mocks/DataQuery.js +5 -5
- package/dist/esm/test/mocks/DataQuery.js.map +1 -1
- package/dist/esm/test/mocks/Datasource.js +22 -22
- package/dist/esm/test/mocks/Datasource.js.map +1 -1
- package/dist/esm/test/mocks/Plugin.js +30 -30
- package/dist/esm/test/mocks/Plugin.js.map +1 -1
- package/dist/esm/test/mocks/QueryEditorProps.js +6 -6
- package/dist/esm/test/mocks/QueryEditorProps.js.map +1 -1
- package/dist/esm/test/mocks/utils.js +5 -5
- package/dist/esm/test/mocks/utils.js.map +1 -1
- package/dist/esm/test-utils.d.ts +24 -24
- package/package.json +77 -68
package/dist/cjs/index.cjs
CHANGED
|
@@ -11,10 +11,10 @@ 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
20
|
var dnd = require('@hello-pangea/dnd');
|
|
@@ -26,7 +26,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
26
26
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
27
27
|
var Calendar__default = /*#__PURE__*/_interopDefaultCompat(Calendar);
|
|
28
28
|
var AutoSizer__default = /*#__PURE__*/_interopDefaultCompat(AutoSizer);
|
|
29
|
-
var sqlFormatter__default = /*#__PURE__*/_interopDefaultCompat(sqlFormatter);
|
|
30
29
|
var Prism__default = /*#__PURE__*/_interopDefaultCompat(Prism);
|
|
31
30
|
|
|
32
31
|
const QueryEditorRow = (props) => {
|
|
@@ -339,19 +338,19 @@ function getSignatureDisplayModel(signature) {
|
|
|
339
338
|
}
|
|
340
339
|
PluginSignatureBadge.displayName = "PluginSignatureBadge";
|
|
341
340
|
|
|
342
|
-
var __defProp$
|
|
343
|
-
var __defNormalProp$
|
|
344
|
-
var __publicField$
|
|
341
|
+
var __defProp$4 = Object.defineProperty;
|
|
342
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
343
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
345
344
|
class DataSourcePicker extends React.PureComponent {
|
|
346
345
|
constructor(props) {
|
|
347
346
|
super(props);
|
|
348
|
-
__publicField$
|
|
349
|
-
__publicField$
|
|
350
|
-
__publicField$
|
|
347
|
+
__publicField$4(this, "dataSourceSrv", runtime.getDataSourceSrv());
|
|
348
|
+
__publicField$4(this, "state", {});
|
|
349
|
+
__publicField$4(this, "onChange", (item) => {
|
|
351
350
|
const dsSettings = this.dataSourceSrv.getInstanceSettings(item.value);
|
|
352
351
|
if (dsSettings) {
|
|
353
352
|
this.props.onChange(dsSettings);
|
|
354
|
-
this.setState({ error:
|
|
353
|
+
this.setState({ error: undefined });
|
|
355
354
|
}
|
|
356
355
|
});
|
|
357
356
|
}
|
|
@@ -427,7 +426,7 @@ class DataSourcePicker extends React.PureComponent {
|
|
|
427
426
|
));
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
|
-
__publicField$
|
|
429
|
+
__publicField$4(DataSourcePicker, "defaultProps", {
|
|
431
430
|
autoFocus: false,
|
|
432
431
|
openMenuOnFocus: false,
|
|
433
432
|
placeholder: "Select datasource"
|
|
@@ -535,7 +534,7 @@ const DataLink = (props) => {
|
|
|
535
534
|
if (showInternalLink) {
|
|
536
535
|
onChange({
|
|
537
536
|
...value,
|
|
538
|
-
datasourceUid:
|
|
537
|
+
datasourceUid: undefined
|
|
539
538
|
});
|
|
540
539
|
}
|
|
541
540
|
setShowInternalLink(!showInternalLink);
|
|
@@ -641,110 +640,21 @@ var QueryEditorExpressionType = /* @__PURE__ */ ((QueryEditorExpressionType2) =>
|
|
|
641
640
|
return QueryEditorExpressionType2;
|
|
642
641
|
})(QueryEditorExpressionType || {});
|
|
643
642
|
|
|
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 ? void 0 : _a[0]) == null ? void 0 : _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 ? void 0 : _c.property.name) {
|
|
669
|
-
rawQuery += `ORDER BY ${sql.orderBy.property.name} `;
|
|
670
|
-
}
|
|
671
|
-
if (((_d = sql.orderBy) == null ? void 0 : _d.property.name) && sql.orderByDirection) {
|
|
672
|
-
rawQuery += `${sql.orderByDirection} `;
|
|
673
|
-
}
|
|
674
|
-
if (sql.limit !== void 0 && 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 ? void 0 : _a.map((p) => `${p.name}`)})`;
|
|
685
|
-
} else {
|
|
686
|
-
rawColumn += `${(_b = c.parameters) == null ? void 0 : _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 ? void 0 : _a.length) || ((_b = c.parameters) == null ? void 0 : _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 ? void 0 : q.editorMode) || EditorMode.Builder;
|
|
731
|
-
if ((q == null ? void 0 : q.editorMode) === void 0 && (q == null ? void 0 : q.rawSql) !== void 0) {
|
|
732
|
-
editorMode = EditorMode.Code;
|
|
733
|
-
}
|
|
734
|
-
const result = {
|
|
735
|
-
...q,
|
|
736
|
-
refId: (q == null ? void 0 : q.refId) || "A",
|
|
737
|
-
format: (q == null ? void 0 : q.format) !== void 0 ? q.format : QueryFormat.Table,
|
|
738
|
-
rawSql: (q == null ? void 0 : q.rawSql) || "",
|
|
739
|
-
editorMode,
|
|
740
|
-
sql: (q == null ? void 0 : q.sql) || {
|
|
741
|
-
columns: [createFunctionField()],
|
|
742
|
-
groupBy: [setGroupByField()],
|
|
743
|
-
limit: 50
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
return result;
|
|
747
|
-
}
|
|
643
|
+
var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
644
|
+
TokenType2["Parenthesis"] = "delimiter.parenthesis.sql";
|
|
645
|
+
TokenType2["Whitespace"] = "white.sql";
|
|
646
|
+
TokenType2["Keyword"] = "keyword.sql";
|
|
647
|
+
TokenType2["Delimiter"] = "delimiter.sql";
|
|
648
|
+
TokenType2["Operator"] = "operator.sql";
|
|
649
|
+
TokenType2["Identifier"] = "identifier.sql";
|
|
650
|
+
TokenType2["IdentifierQuote"] = "identifier.quote.sql";
|
|
651
|
+
TokenType2["Type"] = "type.sql";
|
|
652
|
+
TokenType2["Function"] = "predefined.sql";
|
|
653
|
+
TokenType2["Number"] = "number.sql";
|
|
654
|
+
TokenType2["String"] = "string.sql";
|
|
655
|
+
TokenType2["Variable"] = "variable.sql";
|
|
656
|
+
return TokenType2;
|
|
657
|
+
})(TokenType || {});
|
|
748
658
|
|
|
749
659
|
class LinkedToken {
|
|
750
660
|
constructor(type, value, range, previous, next) {
|
|
@@ -789,7 +699,7 @@ class LinkedToken {
|
|
|
789
699
|
}
|
|
790
700
|
is(type, value) {
|
|
791
701
|
const isType = this.type === type;
|
|
792
|
-
return value !==
|
|
702
|
+
return value !== undefined ? isType && compareTokenWithValue(type, this, value) : isType;
|
|
793
703
|
}
|
|
794
704
|
getPreviousNonWhiteSpaceToken() {
|
|
795
705
|
let curr = this.previous;
|
|
@@ -805,7 +715,7 @@ class LinkedToken {
|
|
|
805
715
|
let curr = this.previous;
|
|
806
716
|
while (curr != null) {
|
|
807
717
|
const isType = curr.type === type;
|
|
808
|
-
if (value !==
|
|
718
|
+
if (value !== undefined ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
809
719
|
return curr;
|
|
810
720
|
}
|
|
811
721
|
curr = curr.previous;
|
|
@@ -816,12 +726,12 @@ class LinkedToken {
|
|
|
816
726
|
let tokens = [];
|
|
817
727
|
let curr = this.previous;
|
|
818
728
|
while (curr != null) {
|
|
819
|
-
if (ignoreTypes.some((t) => t === (curr == null ?
|
|
729
|
+
if (ignoreTypes.some((t) => t === (curr == null ? undefined : curr.type))) {
|
|
820
730
|
curr = curr.previous;
|
|
821
731
|
continue;
|
|
822
732
|
}
|
|
823
733
|
const isType = curr.type === type;
|
|
824
|
-
if (value !==
|
|
734
|
+
if (value !== undefined ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
825
735
|
return tokens;
|
|
826
736
|
}
|
|
827
737
|
if (!curr.isWhiteSpace()) {
|
|
@@ -835,12 +745,12 @@ class LinkedToken {
|
|
|
835
745
|
let tokens = [];
|
|
836
746
|
let curr = this.next;
|
|
837
747
|
while (curr != null) {
|
|
838
|
-
if (ignoreTypes.some((t) => t === (curr == null ?
|
|
748
|
+
if (ignoreTypes.some((t) => t === (curr == null ? undefined : curr.type))) {
|
|
839
749
|
curr = curr.next;
|
|
840
750
|
continue;
|
|
841
751
|
}
|
|
842
752
|
const isType = curr.type === type;
|
|
843
|
-
if (value !==
|
|
753
|
+
if (value !== undefined ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
844
754
|
return tokens;
|
|
845
755
|
}
|
|
846
756
|
if (!curr.isWhiteSpace()) {
|
|
@@ -874,7 +784,7 @@ class LinkedToken {
|
|
|
874
784
|
let curr = this.next;
|
|
875
785
|
while (curr != null) {
|
|
876
786
|
const isType = curr.type === type;
|
|
877
|
-
if (value !==
|
|
787
|
+
if (value !== undefined ? isType && compareTokenWithValue(type, curr, value) : isType) {
|
|
878
788
|
return curr;
|
|
879
789
|
}
|
|
880
790
|
curr = curr.next;
|
|
@@ -899,21 +809,6 @@ var MacroType = /* @__PURE__ */ ((MacroType2) => {
|
|
|
899
809
|
MacroType2[MacroType2["Table"] = 4] = "Table";
|
|
900
810
|
return MacroType2;
|
|
901
811
|
})(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
812
|
var StatementPosition = /* @__PURE__ */ ((StatementPosition2) => {
|
|
918
813
|
StatementPosition2["Unknown"] = "unknown";
|
|
919
814
|
StatementPosition2["SelectKeyword"] = "selectKeyword";
|
|
@@ -1023,9 +918,9 @@ var SQLEditorMode = /* @__PURE__ */ ((SQLEditorMode2) => {
|
|
|
1023
918
|
|
|
1024
919
|
function getStatementPosition(currentToken, statementPositionResolversRegistry) {
|
|
1025
920
|
var _a;
|
|
1026
|
-
const previousNonWhiteSpace = currentToken == null ?
|
|
1027
|
-
const previousKeyword = currentToken == null ?
|
|
1028
|
-
const previousIsSlash = (_a = currentToken == null ?
|
|
921
|
+
const previousNonWhiteSpace = currentToken == null ? undefined : currentToken.getPreviousNonWhiteSpaceToken();
|
|
922
|
+
const previousKeyword = currentToken == null ? undefined : currentToken.getPreviousKeyword();
|
|
923
|
+
const previousIsSlash = (_a = currentToken == null ? undefined : currentToken.getPreviousNonWhiteSpaceToken()) == null ? undefined : _a.is(TokenType.Operator, "/");
|
|
1029
924
|
const resolvers = statementPositionResolversRegistry.list();
|
|
1030
925
|
const positions = [];
|
|
1031
926
|
for (const resolver of resolvers) {
|
|
@@ -1053,8 +948,8 @@ const toCompletionItem = (value, range, rest = {}) => {
|
|
|
1053
948
|
|
|
1054
949
|
const getStandardSuggestions = async (monaco, currentToken, suggestionKinds, positionContext, suggestionsRegistry) => {
|
|
1055
950
|
let suggestions = [];
|
|
1056
|
-
const invalidRangeToken = (currentToken == null ?
|
|
1057
|
-
const range = invalidRangeToken || !(currentToken == null ?
|
|
951
|
+
const invalidRangeToken = (currentToken == null ? undefined : currentToken.isWhiteSpace()) || (currentToken == null ? undefined : currentToken.isParenthesis()) || (currentToken == null ? undefined : currentToken.isIdentifier()) && currentToken.value.endsWith(".");
|
|
952
|
+
const range = invalidRangeToken || !(currentToken == null ? undefined : currentToken.range) ? monaco.Range.fromPositions(positionContext.position) : currentToken == null ? undefined : currentToken.range;
|
|
1058
953
|
for (const suggestion of [...new Set(suggestionKinds)]) {
|
|
1059
954
|
const registeredSuggestions = suggestionsRegistry.getIfExists(suggestion);
|
|
1060
955
|
if (registeredSuggestions) {
|
|
@@ -1235,7 +1130,7 @@ function linkedTokenBuilder(monaco, model, position, languageId = "sql") {
|
|
|
1235
1130
|
offset: 0,
|
|
1236
1131
|
type: TokenType.Whitespace,
|
|
1237
1132
|
language: languageId,
|
|
1238
|
-
_tokenBrand:
|
|
1133
|
+
_tokenBrand: undefined
|
|
1239
1134
|
};
|
|
1240
1135
|
tokens.push(token);
|
|
1241
1136
|
}
|
|
@@ -2159,31 +2054,31 @@ var language$1 = /*#__PURE__*/Object.freeze({
|
|
|
2159
2054
|
|
|
2160
2055
|
const getSelectToken = (currentToken) => {
|
|
2161
2056
|
var _a;
|
|
2162
|
-
return (_a = currentToken == null ?
|
|
2057
|
+
return (_a = currentToken == null ? undefined : currentToken.getPreviousOfType(TokenType.Keyword, SELECT)) != null ? _a : null;
|
|
2163
2058
|
};
|
|
2164
2059
|
const getFromKeywordToken = (currentToken) => {
|
|
2165
2060
|
const selectToken = getSelectToken(currentToken);
|
|
2166
|
-
return selectToken == null ?
|
|
2061
|
+
return selectToken == null ? undefined : selectToken.getNextOfType(TokenType.Keyword, FROM);
|
|
2167
2062
|
};
|
|
2168
2063
|
const getTableToken = (currentToken) => {
|
|
2169
2064
|
var _a;
|
|
2170
2065
|
const fromToken = getFromKeywordToken(currentToken);
|
|
2171
|
-
const nextNonWhiteSpace = fromToken == null ?
|
|
2172
|
-
if (nextNonWhiteSpace == null ?
|
|
2066
|
+
const nextNonWhiteSpace = fromToken == null ? undefined : fromToken.getNextNonWhiteSpaceToken();
|
|
2067
|
+
if (nextNonWhiteSpace == null ? undefined : nextNonWhiteSpace.isVariable()) {
|
|
2173
2068
|
return null;
|
|
2174
|
-
} else if ((nextNonWhiteSpace == null ?
|
|
2069
|
+
} else if ((nextNonWhiteSpace == null ? undefined : nextNonWhiteSpace.isKeyword()) && ((_a = nextNonWhiteSpace.next) == null ? undefined : _a.is(TokenType.Parenthesis, "("))) {
|
|
2175
2070
|
return null;
|
|
2176
2071
|
} else {
|
|
2177
2072
|
return nextNonWhiteSpace;
|
|
2178
2073
|
}
|
|
2179
2074
|
};
|
|
2180
2075
|
const defaultTableNameParser = (token) => {
|
|
2181
|
-
const parts = token == null ?
|
|
2182
|
-
if ((parts == null ?
|
|
2076
|
+
const parts = token == null ? undefined : token.value.split(".");
|
|
2077
|
+
if ((parts == null ? undefined : parts.length) === 1) {
|
|
2183
2078
|
return { table: parts[0] };
|
|
2184
|
-
} else if ((parts == null ?
|
|
2079
|
+
} else if ((parts == null ? undefined : parts.length) === 2) {
|
|
2185
2080
|
return { schema: parts[0], table: parts[1] };
|
|
2186
|
-
} else if ((parts == null ?
|
|
2081
|
+
} else if ((parts == null ? undefined : parts.length) === 3) {
|
|
2187
2082
|
return { catalog: parts[0], schema: parts[1], table: parts[2] };
|
|
2188
2083
|
}
|
|
2189
2084
|
return null;
|
|
@@ -2558,7 +2453,7 @@ function initStatementPositionResolvers() {
|
|
|
2558
2453
|
id: StatementPosition.SelectKeyword,
|
|
2559
2454
|
name: StatementPosition.SelectKeyword,
|
|
2560
2455
|
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 ?
|
|
2456
|
+
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 ? undefined : currentToken.previous) === null) || currentToken.isIdentifier() && SELECT.startsWith(currentToken.value.toLowerCase())
|
|
2562
2457
|
)
|
|
2563
2458
|
},
|
|
2564
2459
|
{
|
|
@@ -2571,13 +2466,13 @@ function initStatementPositionResolvers() {
|
|
|
2571
2466
|
{
|
|
2572
2467
|
id: StatementPosition.AfterSelectKeyword,
|
|
2573
2468
|
name: StatementPosition.AfterSelectKeyword,
|
|
2574
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousNonWhiteSpace == null ?
|
|
2469
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value.toLowerCase()) === SELECT)
|
|
2575
2470
|
},
|
|
2576
2471
|
{
|
|
2577
2472
|
id: StatementPosition.AfterSelectArguments,
|
|
2578
2473
|
name: StatementPosition.AfterSelectArguments,
|
|
2579
2474
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2580
|
-
return Boolean((previousKeyword == null ?
|
|
2475
|
+
return Boolean((previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === SELECT && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value) === ",");
|
|
2581
2476
|
}
|
|
2582
2477
|
},
|
|
2583
2478
|
{
|
|
@@ -2585,7 +2480,7 @@ function initStatementPositionResolvers() {
|
|
|
2585
2480
|
name: StatementPosition.AfterSelectFuncFirstArgument,
|
|
2586
2481
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2587
2482
|
return Boolean(
|
|
2588
|
-
((previousKeyword == null ?
|
|
2483
|
+
((previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === SELECT || (previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === AS) && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (currentToken == null ? undefined : currentToken.is(TokenType.Parenthesis, "()")))
|
|
2589
2484
|
);
|
|
2590
2485
|
}
|
|
2591
2486
|
},
|
|
@@ -2594,7 +2489,7 @@ function initStatementPositionResolvers() {
|
|
|
2594
2489
|
name: StatementPosition.AfterWhereFunctionArgument,
|
|
2595
2490
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2596
2491
|
return Boolean(
|
|
2597
|
-
(previousKeyword == null ?
|
|
2492
|
+
(previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, WHERE)) && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (currentToken == null ? undefined : currentToken.is(TokenType.Parenthesis, "()")))
|
|
2598
2493
|
);
|
|
2599
2494
|
}
|
|
2600
2495
|
},
|
|
@@ -2604,7 +2499,7 @@ function initStatementPositionResolvers() {
|
|
|
2604
2499
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2605
2500
|
var _a;
|
|
2606
2501
|
return Boolean(
|
|
2607
|
-
(previousKeyword == null ?
|
|
2502
|
+
(previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? undefined : previousKeyword.getPreviousKeyword()) == null ? undefined : _a.is(TokenType.Keyword, GROUP)) && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isIdentifier()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isDoubleQuotedString()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, ")")) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, "()")))
|
|
2608
2503
|
);
|
|
2609
2504
|
}
|
|
2610
2505
|
},
|
|
@@ -2612,7 +2507,7 @@ function initStatementPositionResolvers() {
|
|
|
2612
2507
|
id: StatementPosition.SelectAlias,
|
|
2613
2508
|
name: StatementPosition.SelectAlias,
|
|
2614
2509
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2615
|
-
if ((previousNonWhiteSpace == null ?
|
|
2510
|
+
if ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value) === "," && (previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === AS) {
|
|
2616
2511
|
return true;
|
|
2617
2512
|
}
|
|
2618
2513
|
return false;
|
|
@@ -2623,25 +2518,25 @@ function initStatementPositionResolvers() {
|
|
|
2623
2518
|
name: StatementPosition.FromKeyword,
|
|
2624
2519
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2625
2520
|
return Boolean(
|
|
2626
|
-
(previousKeyword == null ?
|
|
2521
|
+
(previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === SELECT && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value) !== "," || ((currentToken == null ? undefined : currentToken.isKeyword()) || (currentToken == null ? undefined : currentToken.isIdentifier())) && FROM.toLowerCase().startsWith(currentToken.value.toLowerCase())
|
|
2627
2522
|
);
|
|
2628
2523
|
}
|
|
2629
2524
|
},
|
|
2630
2525
|
{
|
|
2631
2526
|
id: StatementPosition.AfterFromKeyword,
|
|
2632
2527
|
name: StatementPosition.AfterFromKeyword,
|
|
2633
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(!(currentToken == null ?
|
|
2528
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(!(currentToken == null ? undefined : currentToken.value.includes(".")) && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value.toLowerCase()) === FROM)
|
|
2634
2529
|
},
|
|
2635
2530
|
{
|
|
2636
2531
|
id: StatementPosition.AfterSchema,
|
|
2637
2532
|
name: StatementPosition.AfterSchema,
|
|
2638
2533
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2639
|
-
if ((currentToken == null ?
|
|
2640
|
-
currentToken = currentToken == null ?
|
|
2534
|
+
if ((currentToken == null ? undefined : currentToken.isWhiteSpace()) && (currentToken == null ? undefined : currentToken.next)) {
|
|
2535
|
+
currentToken = currentToken == null ? undefined : currentToken.previous;
|
|
2641
2536
|
previousNonWhiteSpace = currentToken.getPreviousNonWhiteSpaceToken();
|
|
2642
2537
|
}
|
|
2643
2538
|
return Boolean(
|
|
2644
|
-
(currentToken == null ?
|
|
2539
|
+
(currentToken == null ? undefined : currentToken.isIdentifier()) && (currentToken == null ? undefined : currentToken.value.endsWith(".")) && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value.toLowerCase()) === FROM
|
|
2645
2540
|
);
|
|
2646
2541
|
}
|
|
2647
2542
|
},
|
|
@@ -2649,7 +2544,7 @@ function initStatementPositionResolvers() {
|
|
|
2649
2544
|
id: StatementPosition.AfterFrom,
|
|
2650
2545
|
name: StatementPosition.AfterFrom,
|
|
2651
2546
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(
|
|
2652
|
-
(previousKeyword == null ?
|
|
2547
|
+
(previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === FROM && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isDoubleQuotedString()) || (previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === FROM && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isIdentifier()) || (previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === FROM && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isVariable())
|
|
2653
2548
|
// cloudwatch specific
|
|
2654
2549
|
// (previousKeyword?.value === SCHEMA && previousNonWhiteSpace?.is(TokenType.Parenthesis, ')'))
|
|
2655
2550
|
)
|
|
@@ -2659,7 +2554,7 @@ function initStatementPositionResolvers() {
|
|
|
2659
2554
|
name: StatementPosition.AfterTable,
|
|
2660
2555
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2661
2556
|
return Boolean(
|
|
2662
|
-
(previousKeyword == null ?
|
|
2557
|
+
(previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === FROM && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isVariable()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value) !== "" && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.value.toLowerCase()) !== FROM)
|
|
2663
2558
|
);
|
|
2664
2559
|
}
|
|
2665
2560
|
},
|
|
@@ -2667,7 +2562,7 @@ function initStatementPositionResolvers() {
|
|
|
2667
2562
|
id: StatementPosition.WhereKeyword,
|
|
2668
2563
|
name: StatementPosition.WhereKeyword,
|
|
2669
2564
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean(
|
|
2670
|
-
(previousKeyword == null ?
|
|
2565
|
+
(previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === WHERE && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isKeyword()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Operator, AND)))
|
|
2671
2566
|
)
|
|
2672
2567
|
},
|
|
2673
2568
|
{
|
|
@@ -2676,14 +2571,14 @@ function initStatementPositionResolvers() {
|
|
|
2676
2571
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2677
2572
|
var _a;
|
|
2678
2573
|
return Boolean(
|
|
2679
|
-
(previousKeyword == null ?
|
|
2574
|
+
(previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === WHERE && !((_a = previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? undefined : _a.isOperator()) && !(currentToken == null ? undefined : currentToken.is(TokenType.Delimiter, ".")) && !(currentToken == null ? undefined : currentToken.isParenthesis()) && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isIdentifier()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isDoubleQuotedString()))
|
|
2680
2575
|
);
|
|
2681
2576
|
}
|
|
2682
2577
|
},
|
|
2683
2578
|
{
|
|
2684
2579
|
id: StatementPosition.WhereValue,
|
|
2685
2580
|
name: StatementPosition.WhereValue,
|
|
2686
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ?
|
|
2581
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === WHERE && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isOperator()))
|
|
2687
2582
|
},
|
|
2688
2583
|
{
|
|
2689
2584
|
id: StatementPosition.AfterWhereValue,
|
|
@@ -2691,7 +2586,7 @@ function initStatementPositionResolvers() {
|
|
|
2691
2586
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2692
2587
|
var _a, _b, _c;
|
|
2693
2588
|
return Boolean(
|
|
2694
|
-
(previousKeyword == null ?
|
|
2589
|
+
(previousKeyword == null ? undefined : previousKeyword.value.toLowerCase()) === WHERE && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Operator, "and")) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Operator, "or")) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isString()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isNumber()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, ")")) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, "()")) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.isTemplateVariable()) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.IdentifierQuote)) && ((_a = previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? undefined : _a.is(TokenType.Identifier)) && ((_c = (_b = previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? undefined : _b.getPreviousNonWhiteSpaceToken()) == null ? undefined : _c.is(TokenType.IdentifierQuote)))
|
|
2695
2590
|
);
|
|
2696
2591
|
}
|
|
2697
2592
|
},
|
|
@@ -2701,7 +2596,7 @@ function initStatementPositionResolvers() {
|
|
|
2701
2596
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2702
2597
|
var _a;
|
|
2703
2598
|
return Boolean(
|
|
2704
|
-
(previousKeyword == null ?
|
|
2599
|
+
(previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? undefined : previousKeyword.getPreviousKeyword()) == null ? undefined : _a.is(TokenType.Keyword, GROUP)) && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Keyword, BY)) || (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Delimiter, ",")))
|
|
2705
2600
|
);
|
|
2706
2601
|
}
|
|
2707
2602
|
},
|
|
@@ -2711,7 +2606,7 @@ function initStatementPositionResolvers() {
|
|
|
2711
2606
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2712
2607
|
var _a;
|
|
2713
2608
|
return Boolean(
|
|
2714
|
-
(previousKeyword == null ?
|
|
2609
|
+
(previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? undefined : previousKeyword.getPreviousKeyword()) == null ? undefined : _a.is(TokenType.Keyword, GROUP)) && ((previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis, "(")) || (currentToken == null ? undefined : currentToken.is(TokenType.Parenthesis, "()")))
|
|
2715
2610
|
);
|
|
2716
2611
|
}
|
|
2717
2612
|
},
|
|
@@ -2721,7 +2616,7 @@ function initStatementPositionResolvers() {
|
|
|
2721
2616
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2722
2617
|
var _a;
|
|
2723
2618
|
return Boolean(
|
|
2724
|
-
(previousNonWhiteSpace == null ?
|
|
2619
|
+
(previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Keyword, BY)) && ((_a = previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.getPreviousKeyword()) == null ? undefined : _a.is(TokenType.Keyword, ORDER))
|
|
2725
2620
|
);
|
|
2726
2621
|
}
|
|
2727
2622
|
},
|
|
@@ -2731,20 +2626,20 @@ function initStatementPositionResolvers() {
|
|
|
2731
2626
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2732
2627
|
var _a, _b;
|
|
2733
2628
|
return Boolean(
|
|
2734
|
-
(previousKeyword == null ?
|
|
2629
|
+
(previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, BY)) && ((_a = previousKeyword == null ? undefined : previousKeyword.getPreviousKeyword()) == null ? undefined : _a.is(TokenType.Keyword, ORDER)) && (previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Parenthesis)) && ((_b = previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? undefined : _b.is(TokenType.Function))
|
|
2735
2630
|
);
|
|
2736
2631
|
}
|
|
2737
2632
|
},
|
|
2738
2633
|
{
|
|
2739
2634
|
id: StatementPosition.AfterOrderByDirection,
|
|
2740
2635
|
name: StatementPosition.AfterOrderByDirection,
|
|
2741
|
-
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ?
|
|
2636
|
+
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => Boolean((previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, DESC)) || (previousKeyword == null ? undefined : previousKeyword.is(TokenType.Keyword, ASC)))
|
|
2742
2637
|
},
|
|
2743
2638
|
{
|
|
2744
2639
|
id: StatementPosition.AfterIsOperator,
|
|
2745
2640
|
name: StatementPosition.AfterIsOperator,
|
|
2746
2641
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2747
|
-
return Boolean(previousNonWhiteSpace == null ?
|
|
2642
|
+
return Boolean(previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Operator, "IS"));
|
|
2748
2643
|
}
|
|
2749
2644
|
},
|
|
2750
2645
|
{
|
|
@@ -2753,7 +2648,7 @@ function initStatementPositionResolvers() {
|
|
|
2753
2648
|
resolve: (currentToken, previousKeyword, previousNonWhiteSpace, previousIsSlash) => {
|
|
2754
2649
|
var _a;
|
|
2755
2650
|
return Boolean(
|
|
2756
|
-
(previousNonWhiteSpace == null ?
|
|
2651
|
+
(previousNonWhiteSpace == null ? undefined : previousNonWhiteSpace.is(TokenType.Operator, "NOT")) && ((_a = previousNonWhiteSpace.getPreviousNonWhiteSpaceToken()) == null ? undefined : _a.is(TokenType.Operator, "IS"))
|
|
2757
2652
|
);
|
|
2758
2653
|
}
|
|
2759
2654
|
}
|
|
@@ -2767,7 +2662,7 @@ let sqlEditorLog = () => {
|
|
|
2767
2662
|
if (ui.attachDebugger && ui.createLogger) {
|
|
2768
2663
|
sqlEditorLogger = ui.createLogger("SQLEditor");
|
|
2769
2664
|
sqlEditorLog = sqlEditorLogger.logger;
|
|
2770
|
-
ui.attachDebugger("sqleditor",
|
|
2665
|
+
ui.attachDebugger("sqleditor", undefined, sqlEditorLogger);
|
|
2771
2666
|
}
|
|
2772
2667
|
|
|
2773
2668
|
const COLUMN = "column", RELATIVE_TIME_STRING = "'5m'";
|
|
@@ -2829,7 +2724,7 @@ function getStandardSQLCompletionProvider(monaco, language) {
|
|
|
2829
2724
|
provider.supportedFunctions = () => language.builtinFunctions.map((f) => ({ id: f, name: f }));
|
|
2830
2725
|
}
|
|
2831
2726
|
const operators = [];
|
|
2832
|
-
if ((_a = language == null ?
|
|
2727
|
+
if ((_a = language == null ? undefined : language.comparisonOperators) == null ? undefined : _a.length) {
|
|
2833
2728
|
operators.push(
|
|
2834
2729
|
...language.comparisonOperators.map((f) => ({
|
|
2835
2730
|
id: f.toLocaleLowerCase(),
|
|
@@ -2839,7 +2734,7 @@ function getStandardSQLCompletionProvider(monaco, language) {
|
|
|
2839
2734
|
);
|
|
2840
2735
|
}
|
|
2841
2736
|
language.logicalOperators = (_b = language.logicalOperators) != null ? _b : language.operators;
|
|
2842
|
-
if ((_c = language == null ?
|
|
2737
|
+
if ((_c = language == null ? undefined : language.logicalOperators) == null ? undefined : _c.length) {
|
|
2843
2738
|
operators.push(
|
|
2844
2739
|
...language.logicalOperators.map((f) => ({ id: f.toLocaleLowerCase(), operator: f, type: OperatorType.Logical }))
|
|
2845
2740
|
);
|
|
@@ -2865,7 +2760,7 @@ function useLatestCallback(callback) {
|
|
|
2865
2760
|
});
|
|
2866
2761
|
const hasCallback = Boolean(callback);
|
|
2867
2762
|
return React.useMemo(
|
|
2868
|
-
() => hasCallback ? (
|
|
2763
|
+
() => hasCallback ? (...args) => ref.current(...args) : undefined,
|
|
2869
2764
|
[hasCallback]
|
|
2870
2765
|
);
|
|
2871
2766
|
}
|
|
@@ -2912,7 +2807,7 @@ const SQLEditor = ({
|
|
|
2912
2807
|
ui.CodeEditor,
|
|
2913
2808
|
{
|
|
2914
2809
|
height: height || "240px",
|
|
2915
|
-
width: width ? `${width - 2}px` :
|
|
2810
|
+
width: width ? `${width - 2}px` : undefined,
|
|
2916
2811
|
language: id,
|
|
2917
2812
|
value: query,
|
|
2918
2813
|
onBlur: onSqlBlur,
|
|
@@ -2943,12 +2838,12 @@ const SQLEditor = ({
|
|
|
2943
2838
|
), children && children({ formatQuery }));
|
|
2944
2839
|
};
|
|
2945
2840
|
const resolveLanguage = (monaco, languageDefinitionProp) => {
|
|
2946
|
-
if ((languageDefinitionProp == null ?
|
|
2947
|
-
sqlEditorLog(`Loading language '${languageDefinitionProp == null ?
|
|
2841
|
+
if ((languageDefinitionProp == null ? undefined : languageDefinitionProp.id) !== STANDARD_SQL_LANGUAGE && !languageDefinitionProp.loader) {
|
|
2842
|
+
sqlEditorLog(`Loading language '${languageDefinitionProp == null ? undefined : languageDefinitionProp.id}' from Monaco registry`, false);
|
|
2948
2843
|
const allLangs = monaco.languages.getLanguages();
|
|
2949
|
-
const custom = allLangs.find(({ id }) => id === (languageDefinitionProp == null ?
|
|
2844
|
+
const custom = allLangs.find(({ id }) => id === (languageDefinitionProp == null ? undefined : languageDefinitionProp.id));
|
|
2950
2845
|
if (!custom) {
|
|
2951
|
-
throw Error(`Unknown Monaco language ${languageDefinitionProp == null ?
|
|
2846
|
+
throw Error(`Unknown Monaco language ${languageDefinitionProp == null ? undefined : languageDefinitionProp.id}`);
|
|
2952
2847
|
}
|
|
2953
2848
|
return { completionProvider: getStandardSQLCompletionProvider, ...custom, ...languageDefinitionProp };
|
|
2954
2849
|
}
|
|
@@ -2970,7 +2865,7 @@ const registerLanguageAndSuggestions = async (monaco, l, lid) => {
|
|
|
2970
2865
|
monaco.languages.registerDocumentFormattingEditProvider(lid, {
|
|
2971
2866
|
provideDocumentFormattingEdits: (model) => {
|
|
2972
2867
|
var _a;
|
|
2973
|
-
const formatted = (_a = l.formatter) == null ?
|
|
2868
|
+
const formatted = (_a = l.formatter) == null ? undefined : _a.call(l, model.getValue());
|
|
2974
2869
|
return [
|
|
2975
2870
|
{
|
|
2976
2871
|
range: model.getFullModelRange(),
|
|
@@ -3077,7 +2972,7 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3077
2972
|
}
|
|
3078
2973
|
if (customProvider.customSuggestionKinds) {
|
|
3079
2974
|
for (const kind of customProvider.customSuggestionKinds()) {
|
|
3080
|
-
(_a = kind.applyTo) == null ?
|
|
2975
|
+
(_a = kind.applyTo) == null ? undefined : _a.forEach((applyTo) => {
|
|
3081
2976
|
const exists = languageRegistries.suggestionKinds.getIfExists(applyTo);
|
|
3082
2977
|
if (exists) {
|
|
3083
2978
|
if (exists.kind.indexOf(kind.id) === -1) {
|
|
@@ -3087,7 +2982,7 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3087
2982
|
});
|
|
3088
2983
|
if (kind.overrideDefault) {
|
|
3089
2984
|
const stbBehavior = instanceSuggestionsRegistry.get(kind.id);
|
|
3090
|
-
if (stbBehavior !==
|
|
2985
|
+
if (stbBehavior !== undefined) {
|
|
3091
2986
|
stbBehavior.suggestions = kind.suggestionsResolver;
|
|
3092
2987
|
continue;
|
|
3093
2988
|
}
|
|
@@ -3129,9 +3024,9 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3129
3024
|
var _a2, _b, _c, _d, _e;
|
|
3130
3025
|
const o = await s(ctx, m);
|
|
3131
3026
|
const tableToken = getTableToken(ctx.currentToken);
|
|
3132
|
-
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ?
|
|
3027
|
+
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ? undefined : _a2.parseName) != null ? _b : defaultTableNameParser;
|
|
3133
3028
|
const tableIdentifier = tableNameParser(tableToken);
|
|
3134
|
-
const oo = ((_e = await ((_d = (_c = customProvider.tables) == null ?
|
|
3029
|
+
const oo = ((_e = await ((_d = (_c = customProvider.tables) == null ? undefined : _c.resolve) == null ? undefined : _d.call(_c, tableIdentifier))) != null ? _e : []).map((x) => {
|
|
3135
3030
|
var _a3;
|
|
3136
3031
|
return {
|
|
3137
3032
|
label: x.name,
|
|
@@ -3154,13 +3049,13 @@ function extendStandardRegistries(id, lid, customProvider) {
|
|
|
3154
3049
|
const o = await s(ctx, m);
|
|
3155
3050
|
const tableToken = getTableToken(ctx.currentToken);
|
|
3156
3051
|
let tableIdentifier;
|
|
3157
|
-
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ?
|
|
3052
|
+
const tableNameParser = (_b = (_a2 = customProvider.tables) == null ? undefined : _a2.parseName) != null ? _b : defaultTableNameParser;
|
|
3158
3053
|
if (tableToken && tableToken.value) {
|
|
3159
3054
|
tableIdentifier = tableNameParser(tableToken);
|
|
3160
3055
|
}
|
|
3161
3056
|
let oo = [];
|
|
3162
3057
|
if (tableIdentifier) {
|
|
3163
|
-
const columns = await ((_c = customProvider.columns) == null ?
|
|
3058
|
+
const columns = await ((_c = customProvider.columns) == null ? undefined : _c.resolve(tableIdentifier));
|
|
3164
3059
|
oo = columns ? columns.map((x) => {
|
|
3165
3060
|
var _a3;
|
|
3166
3061
|
return {
|
|
@@ -5456,9 +5351,94 @@ const QUERY_FORMAT_OPTIONS = [
|
|
|
5456
5351
|
const backWardToOption = (value) => ({ label: value, value });
|
|
5457
5352
|
const toOption = (_a = data.toOption) != null ? _a : backWardToOption;
|
|
5458
5353
|
|
|
5354
|
+
function getRawSqlFn(db) {
|
|
5355
|
+
return db.toRawSql ? db.toRawSql : (query) => toRawSql(query, Boolean(db.disableDatasets));
|
|
5356
|
+
}
|
|
5357
|
+
function toRawSql({ sql, dataset, catalog, table }, disableDatasets) {
|
|
5358
|
+
var _a, _b, _c, _d;
|
|
5359
|
+
let rawQuery = "";
|
|
5360
|
+
if (!sql || !haveColumns(sql.columns)) {
|
|
5361
|
+
return rawQuery;
|
|
5362
|
+
}
|
|
5363
|
+
rawQuery += createSelectClause(sql.columns);
|
|
5364
|
+
if (catalog && dataset && table) {
|
|
5365
|
+
rawQuery += `FROM ${catalog}.${dataset}.${table} `;
|
|
5366
|
+
} else if (!disableDatasets && dataset && table) {
|
|
5367
|
+
rawQuery += `FROM ${dataset}.${table} `;
|
|
5368
|
+
} else if (table) {
|
|
5369
|
+
rawQuery += `FROM ${table} `;
|
|
5370
|
+
}
|
|
5371
|
+
if (sql.whereString) {
|
|
5372
|
+
rawQuery += `WHERE ${sql.whereString} `;
|
|
5373
|
+
}
|
|
5374
|
+
if ((_b = (_a = sql.groupBy) == null ? undefined : _a[0]) == null ? undefined : _b.property.name) {
|
|
5375
|
+
const groupBy = sql.groupBy.map((g) => g.property.name).filter((g) => !lodash.isEmpty(g));
|
|
5376
|
+
rawQuery += `GROUP BY ${groupBy.join(", ")} `;
|
|
5377
|
+
}
|
|
5378
|
+
if ((_c = sql.orderBy) == null ? undefined : _c.property.name) {
|
|
5379
|
+
rawQuery += `ORDER BY ${sql.orderBy.property.name} `;
|
|
5380
|
+
}
|
|
5381
|
+
if (((_d = sql.orderBy) == null ? undefined : _d.property.name) && sql.orderByDirection) {
|
|
5382
|
+
rawQuery += `${sql.orderByDirection} `;
|
|
5383
|
+
}
|
|
5384
|
+
if (sql.limit !== undefined && sql.limit >= 0) {
|
|
5385
|
+
rawQuery += `LIMIT ${sql.limit} `;
|
|
5386
|
+
}
|
|
5387
|
+
return rawQuery;
|
|
5388
|
+
}
|
|
5389
|
+
function createSelectClause(sqlColumns) {
|
|
5390
|
+
const columns = sqlColumns.map((c) => {
|
|
5391
|
+
var _a, _b;
|
|
5392
|
+
let rawColumn = "";
|
|
5393
|
+
if (c.name) {
|
|
5394
|
+
rawColumn += `${c.name}(${(_a = c.parameters) == null ? undefined : _a.map((p) => `${p.name}`)})`;
|
|
5395
|
+
} else {
|
|
5396
|
+
rawColumn += `${(_b = c.parameters) == null ? undefined : _b.map((p) => `${p.name}`)}`;
|
|
5397
|
+
}
|
|
5398
|
+
return rawColumn;
|
|
5399
|
+
});
|
|
5400
|
+
return `SELECT ${columns.join(", ")} `;
|
|
5401
|
+
}
|
|
5402
|
+
function haveColumns(columns) {
|
|
5403
|
+
if (!columns) {
|
|
5404
|
+
return false;
|
|
5405
|
+
}
|
|
5406
|
+
const haveColumn = columns.some((c) => {
|
|
5407
|
+
var _a, _b;
|
|
5408
|
+
return ((_a = c.parameters) == null ? undefined : _a.length) || ((_b = c.parameters) == null ? undefined : _b.some((p) => p.name));
|
|
5409
|
+
});
|
|
5410
|
+
const haveFunction = columns.some((c) => c.name);
|
|
5411
|
+
return haveColumn || haveFunction;
|
|
5412
|
+
}
|
|
5413
|
+
function setGroupByField(field) {
|
|
5414
|
+
return {
|
|
5415
|
+
type: QueryEditorExpressionType.GroupBy,
|
|
5416
|
+
property: {
|
|
5417
|
+
type: QueryEditorPropertyType.String,
|
|
5418
|
+
name: field
|
|
5419
|
+
}
|
|
5420
|
+
};
|
|
5421
|
+
}
|
|
5422
|
+
function setPropertyField(field) {
|
|
5423
|
+
return {
|
|
5424
|
+
type: QueryEditorExpressionType.Property,
|
|
5425
|
+
property: {
|
|
5426
|
+
type: QueryEditorPropertyType.String,
|
|
5427
|
+
name: field
|
|
5428
|
+
}
|
|
5429
|
+
};
|
|
5430
|
+
}
|
|
5431
|
+
function createFunctionField(functionName) {
|
|
5432
|
+
return {
|
|
5433
|
+
type: QueryEditorExpressionType.Function,
|
|
5434
|
+
name: functionName,
|
|
5435
|
+
parameters: []
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
5438
|
+
|
|
5459
5439
|
const EditorStack = ({ children, wrap: wrapItems = true, ...props }) => {
|
|
5460
5440
|
var _a, _b;
|
|
5461
|
-
return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { wrap: wrapItems ? "wrap" :
|
|
5441
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { wrap: wrapItems ? "wrap" : undefined, direction: (_a = props.direction) != null ? _a : "row", gap: (_b = props.gap) != null ? _b : 2, ...props }, children);
|
|
5462
5442
|
};
|
|
5463
5443
|
|
|
5464
5444
|
const EditorList = React.forwardRef(function EditorList2({ items, renderItem, onChange }, ref) {
|
|
@@ -5556,7 +5536,7 @@ function GroupByRow({ sql, columns, onSqlChange }) {
|
|
|
5556
5536
|
(item) => {
|
|
5557
5537
|
const cleaned = item.map((v) => {
|
|
5558
5538
|
var _a;
|
|
5559
|
-
return setGroupByField((_a = v.property) == null ?
|
|
5539
|
+
return setGroupByField((_a = v.property) == null ? undefined : _a.name);
|
|
5560
5540
|
});
|
|
5561
5541
|
const newSql = { ...sql, groupBy: cleaned };
|
|
5562
5542
|
onSqlChange(newSql);
|
|
@@ -5580,7 +5560,7 @@ function makeRenderColumn({ options }) {
|
|
|
5580
5560
|
return /* @__PURE__ */ React__default.default.createElement(InputGroup, null, /* @__PURE__ */ React__default.default.createElement(
|
|
5581
5561
|
ui.Select,
|
|
5582
5562
|
{
|
|
5583
|
-
value: ((_a = item.property) == null ?
|
|
5563
|
+
value: ((_a = item.property) == null ? undefined : _a.name) ? data.toOption(item.property.name) : null,
|
|
5584
5564
|
"aria-label": "Group by",
|
|
5585
5565
|
options,
|
|
5586
5566
|
menuShouldPortal: true,
|
|
@@ -5613,7 +5593,7 @@ const EditorField$1 = (props) => {
|
|
|
5613
5593
|
var _a;
|
|
5614
5594
|
const { label, optional, tooltip, tooltipInteractive, children, width, ...fieldProps } = props;
|
|
5615
5595
|
const styles = ui.useStyles2(getStyles$l, width);
|
|
5616
|
-
const childInputId = (fieldProps == null ?
|
|
5596
|
+
const childInputId = (fieldProps == null ? undefined : fieldProps.htmlFor) || ((_a = ui.ReactUtils) == null ? undefined : _a.getChildId(children));
|
|
5617
5597
|
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
5598
|
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
5599
|
};
|
|
@@ -5688,7 +5668,7 @@ function InlineSelect({ label: labelProp, ...props }) {
|
|
|
5688
5668
|
ValueContainer,
|
|
5689
5669
|
SingleValue: ValueContainer
|
|
5690
5670
|
};
|
|
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, {
|
|
5671
|
+
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
5672
|
}
|
|
5693
5673
|
const SelectContainer = (props) => {
|
|
5694
5674
|
const { children } = props;
|
|
@@ -5742,12 +5722,32 @@ const getStyles$i = (theme, v, h, layout) => ({
|
|
|
5742
5722
|
])
|
|
5743
5723
|
});
|
|
5744
5724
|
|
|
5725
|
+
function applyQueryDefaults(q) {
|
|
5726
|
+
let editorMode = (q == null ? undefined : q.editorMode) || EditorMode.Builder;
|
|
5727
|
+
if ((q == null ? undefined : q.editorMode) === undefined && (q == null ? undefined : q.rawSql) !== undefined) {
|
|
5728
|
+
editorMode = EditorMode.Code;
|
|
5729
|
+
}
|
|
5730
|
+
const result = {
|
|
5731
|
+
...q,
|
|
5732
|
+
refId: (q == null ? undefined : q.refId) || "A",
|
|
5733
|
+
format: (q == null ? undefined : q.format) !== undefined ? q.format : QueryFormat.Table,
|
|
5734
|
+
rawSql: (q == null ? undefined : q.rawSql) || "",
|
|
5735
|
+
editorMode,
|
|
5736
|
+
sql: (q == null ? undefined : q.sql) || {
|
|
5737
|
+
columns: [createFunctionField()],
|
|
5738
|
+
groupBy: [setGroupByField()],
|
|
5739
|
+
limit: 50
|
|
5740
|
+
}
|
|
5741
|
+
};
|
|
5742
|
+
return result;
|
|
5743
|
+
}
|
|
5744
|
+
|
|
5745
5745
|
function ConfirmModal({ isOpen, onCancel, onDiscard, onCopy }) {
|
|
5746
5746
|
const buttonRef = React.useRef(null);
|
|
5747
5747
|
React.useEffect(() => {
|
|
5748
5748
|
var _a;
|
|
5749
5749
|
if (isOpen) {
|
|
5750
|
-
(_a = buttonRef.current) == null ?
|
|
5750
|
+
(_a = buttonRef.current) == null ? undefined : _a.focus();
|
|
5751
5751
|
}
|
|
5752
5752
|
}, [isOpen]);
|
|
5753
5753
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -5793,7 +5793,7 @@ const DatasetSelector = ({
|
|
|
5793
5793
|
onChange(state.value[0]);
|
|
5794
5794
|
}
|
|
5795
5795
|
} else {
|
|
5796
|
-
if (state.value && state.value.find((v) => v.value === value) ===
|
|
5796
|
+
if (state.value && state.value.find((v) => v.value === value) === undefined) {
|
|
5797
5797
|
if (state.value.length > 0) {
|
|
5798
5798
|
onChange(state.value[0]);
|
|
5799
5799
|
}
|
|
@@ -5844,7 +5844,7 @@ const CatalogSelector = ({ db, inputId, value, onChange }) => {
|
|
|
5844
5844
|
loadCatalogs();
|
|
5845
5845
|
}, [db, loadCatalogs]);
|
|
5846
5846
|
const handleChange = (selectable) => {
|
|
5847
|
-
onChange((selectable == null ?
|
|
5847
|
+
onChange((selectable == null ? undefined : selectable.value) || null);
|
|
5848
5848
|
};
|
|
5849
5849
|
const selectedValue = catalogs.find((catalog) => catalog.value === value) || null;
|
|
5850
5850
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -5908,7 +5908,7 @@ const RunQueryButton = ({
|
|
|
5908
5908
|
onClick,
|
|
5909
5909
|
dataTestId
|
|
5910
5910
|
}) => {
|
|
5911
|
-
let icon = queryInvalid ? "exclamation-triangle" :
|
|
5911
|
+
let icon = queryInvalid ? "exclamation-triangle" : undefined;
|
|
5912
5912
|
if (queryRunning) {
|
|
5913
5913
|
icon = "fa fa-spinner";
|
|
5914
5914
|
}
|
|
@@ -5971,35 +5971,35 @@ function QueryHeader({
|
|
|
5971
5971
|
[editorMode, onChange, query]
|
|
5972
5972
|
);
|
|
5973
5973
|
const onFormatChange = (e) => {
|
|
5974
|
-
const next = { ...query, format: e.value !==
|
|
5974
|
+
const next = { ...query, format: e.value !== undefined ? e.value : QueryFormat.Table };
|
|
5975
5975
|
onChange(next);
|
|
5976
5976
|
};
|
|
5977
5977
|
const onDatasetChange = (e) => {
|
|
5978
|
-
const datasetValue = e.value ||
|
|
5978
|
+
const datasetValue = e.value || undefined;
|
|
5979
5979
|
if (datasetValue === query.dataset) {
|
|
5980
5980
|
return;
|
|
5981
5981
|
}
|
|
5982
5982
|
const next = {
|
|
5983
5983
|
...query,
|
|
5984
5984
|
dataset: datasetValue,
|
|
5985
|
-
table:
|
|
5986
|
-
sql:
|
|
5985
|
+
table: undefined,
|
|
5986
|
+
sql: undefined,
|
|
5987
5987
|
rawSql: ""
|
|
5988
5988
|
};
|
|
5989
5989
|
onChange(next);
|
|
5990
5990
|
};
|
|
5991
5991
|
const onCatalogChange = (catalog) => {
|
|
5992
|
-
const catalogValue = catalog ||
|
|
5992
|
+
const catalogValue = catalog || undefined;
|
|
5993
5993
|
if (catalogValue === query.catalog) {
|
|
5994
5994
|
return;
|
|
5995
5995
|
}
|
|
5996
5996
|
const next = {
|
|
5997
5997
|
...query,
|
|
5998
5998
|
catalog: catalogValue,
|
|
5999
|
-
dataset:
|
|
5999
|
+
dataset: undefined,
|
|
6000
6000
|
// Reset dataset (which acts as schema when catalog is present)
|
|
6001
|
-
table:
|
|
6002
|
-
sql:
|
|
6001
|
+
table: undefined,
|
|
6002
|
+
sql: undefined,
|
|
6003
6003
|
rawSql: ""
|
|
6004
6004
|
};
|
|
6005
6005
|
onChange(next);
|
|
@@ -6011,7 +6011,7 @@ function QueryHeader({
|
|
|
6011
6011
|
const next = {
|
|
6012
6012
|
...query,
|
|
6013
6013
|
table: e.value,
|
|
6014
|
-
sql:
|
|
6014
|
+
sql: undefined,
|
|
6015
6015
|
rawSql: ""
|
|
6016
6016
|
};
|
|
6017
6017
|
onChange(next);
|
|
@@ -6094,7 +6094,7 @@ function QueryHeader({
|
|
|
6094
6094
|
{
|
|
6095
6095
|
db,
|
|
6096
6096
|
inputId: `sql-catalog-${htmlId}`,
|
|
6097
|
-
value: query.catalog ===
|
|
6097
|
+
value: query.catalog === undefined ? null : query.catalog,
|
|
6098
6098
|
onChange: onCatalogChange
|
|
6099
6099
|
}
|
|
6100
6100
|
)), effectiveEnableDatasets && /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -6109,10 +6109,10 @@ function QueryHeader({
|
|
|
6109
6109
|
db,
|
|
6110
6110
|
inputId: catalogsEnabled ? `sql-schema-${htmlId}` : `sql-dataset-${htmlId}`,
|
|
6111
6111
|
"data-testid": catalogsEnabled ? "schema-selector" : "dataset-selector",
|
|
6112
|
-
dataset: catalogsEnabled ?
|
|
6113
|
-
value: query.dataset ===
|
|
6112
|
+
dataset: catalogsEnabled ? undefined : defaultDataset,
|
|
6113
|
+
value: query.dataset === undefined ? null : query.dataset,
|
|
6114
6114
|
onChange: onDatasetChange,
|
|
6115
|
-
catalog: catalogsEnabled ? query.catalog :
|
|
6115
|
+
catalog: catalogsEnabled ? query.catalog : undefined
|
|
6116
6116
|
}
|
|
6117
6117
|
)
|
|
6118
6118
|
), /* @__PURE__ */ React__default.default.createElement(EditorField$1, { label: labels.get("table") || "Table", width: 25 }, /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -6120,10 +6120,10 @@ function QueryHeader({
|
|
|
6120
6120
|
{
|
|
6121
6121
|
db,
|
|
6122
6122
|
inputId: `sql-table-${htmlId}`,
|
|
6123
|
-
dataset: query.dataset || (catalogsEnabled ?
|
|
6124
|
-
catalog: catalogsEnabled ? query.catalog :
|
|
6123
|
+
dataset: query.dataset || (catalogsEnabled ? undefined : defaultDataset),
|
|
6124
|
+
catalog: catalogsEnabled ? query.catalog : undefined,
|
|
6125
6125
|
query,
|
|
6126
|
-
value: query.table ===
|
|
6126
|
+
value: query.table === undefined ? null : query.table,
|
|
6127
6127
|
onChange: onTableChange,
|
|
6128
6128
|
enableCatalogs: catalogsEnabled,
|
|
6129
6129
|
applyDefault: true
|
|
@@ -6131,13 +6131,32 @@ function QueryHeader({
|
|
|
6131
6131
|
)))));
|
|
6132
6132
|
}
|
|
6133
6133
|
|
|
6134
|
-
function formatSQL(q) {
|
|
6135
|
-
|
|
6136
|
-
|
|
6134
|
+
function formatSQL(q, language = "sql") {
|
|
6135
|
+
const formatted = sqlFormatter.format(q, {
|
|
6136
|
+
language,
|
|
6137
|
+
paramTypes: {
|
|
6138
|
+
custom: [
|
|
6139
|
+
{
|
|
6140
|
+
regex: "\\$\\s*\\{[^}]*\\}|\\$\\s*__\\w+(?:\\([^)]*\\))?|\\$\\s*\\w+"
|
|
6141
|
+
}
|
|
6142
|
+
]
|
|
6143
|
+
}
|
|
6137
6144
|
});
|
|
6145
|
+
return formatted.replace(
|
|
6146
|
+
/(\$\s*\{[^}]*\})|(\$\s*__\w+(?:\([^)]*\))?)|(\$\s*\w+)/g,
|
|
6147
|
+
(m) => m.replace(/\s/g, "")
|
|
6148
|
+
);
|
|
6138
6149
|
}
|
|
6139
6150
|
|
|
6140
|
-
function QueryEditorRaw({
|
|
6151
|
+
function QueryEditorRaw({
|
|
6152
|
+
children,
|
|
6153
|
+
onChange,
|
|
6154
|
+
query,
|
|
6155
|
+
width,
|
|
6156
|
+
height,
|
|
6157
|
+
completionProvider,
|
|
6158
|
+
language = "sql"
|
|
6159
|
+
}) {
|
|
6141
6160
|
const queryRef = React.useRef(query);
|
|
6142
6161
|
React.useEffect(() => {
|
|
6143
6162
|
queryRef.current = query;
|
|
@@ -6160,7 +6179,7 @@ function QueryEditorRaw({ children, onChange, query, width, height, completionPr
|
|
|
6160
6179
|
height,
|
|
6161
6180
|
query: query.rawSql,
|
|
6162
6181
|
onChange: onRawQueryChange,
|
|
6163
|
-
language: { id: "sql", completionProvider, formatter: formatSQL }
|
|
6182
|
+
language: { id: "sql", completionProvider, formatter: (q) => formatSQL(q, language) }
|
|
6164
6183
|
},
|
|
6165
6184
|
children
|
|
6166
6185
|
);
|
|
@@ -6189,7 +6208,7 @@ function QueryValidator({ db, query, onValidate, range }) {
|
|
|
6189
6208
|
const [state, validateQuery] = reactUse.useAsyncFn(
|
|
6190
6209
|
async (q) => {
|
|
6191
6210
|
var _a2;
|
|
6192
|
-
if (((_a2 = q.rawSql) == null ?
|
|
6211
|
+
if (((_a2 = q.rawSql) == null ? undefined : _a2.trim()) === "") {
|
|
6193
6212
|
return null;
|
|
6194
6213
|
}
|
|
6195
6214
|
return await db.validateQuery(q, range);
|
|
@@ -6208,17 +6227,17 @@ function QueryValidator({ db, query, onValidate, range }) {
|
|
|
6208
6227
|
[query, validateQuery]
|
|
6209
6228
|
);
|
|
6210
6229
|
React.useEffect(() => {
|
|
6211
|
-
if (validationResult == null ?
|
|
6230
|
+
if (validationResult == null ? undefined : validationResult.isError) {
|
|
6212
6231
|
onValidate(false);
|
|
6213
6232
|
}
|
|
6214
|
-
if (validationResult == null ?
|
|
6233
|
+
if (validationResult == null ? undefined : validationResult.isValid) {
|
|
6215
6234
|
onValidate(true);
|
|
6216
6235
|
}
|
|
6217
6236
|
}, [validationResult, onValidate]);
|
|
6218
6237
|
if (!state.value && !state.loading) {
|
|
6219
6238
|
return null;
|
|
6220
6239
|
}
|
|
6221
|
-
const error = ((_a = state.value) == null ?
|
|
6240
|
+
const error = ((_a = state.value) == null ? undefined : _a.error) ? processErrorMessage(state.value.error) : "";
|
|
6222
6241
|
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
6242
|
}
|
|
6224
6243
|
function processErrorMessage(error) {
|
|
@@ -6262,9 +6281,13 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
|
|
|
6262
6281
|
};
|
|
6263
6282
|
}, [theme]);
|
|
6264
6283
|
let style = {};
|
|
6265
|
-
if (!showTools && validationResult ===
|
|
6284
|
+
if (!showTools && validationResult === undefined) {
|
|
6266
6285
|
style = { height: 0, padding: 0, visibility: "hidden" };
|
|
6267
6286
|
}
|
|
6287
|
+
const onFormatClick = () => {
|
|
6288
|
+
runtime.reportInteraction("grafana_sql_query_editor_format_click");
|
|
6289
|
+
onFormatCode == null ? undefined : onFormatCode();
|
|
6290
|
+
};
|
|
6268
6291
|
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
6292
|
QueryValidator,
|
|
6270
6293
|
{
|
|
@@ -6274,7 +6297,7 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
|
|
|
6274
6297
|
validatorProps.onValidate(result);
|
|
6275
6298
|
}
|
|
6276
6299
|
}
|
|
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:
|
|
6300
|
+
)), 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
6301
|
ui.IconButton,
|
|
6279
6302
|
{
|
|
6280
6303
|
onClick: () => onExpand(!isExpanded),
|
|
@@ -6285,7 +6308,16 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
|
|
|
6285
6308
|
), /* @__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
6309
|
}
|
|
6287
6310
|
|
|
6288
|
-
function RawEditor({
|
|
6311
|
+
function RawEditor({
|
|
6312
|
+
db,
|
|
6313
|
+
query,
|
|
6314
|
+
onChange,
|
|
6315
|
+
onRunQuery,
|
|
6316
|
+
onValidate,
|
|
6317
|
+
queryToValidate,
|
|
6318
|
+
range,
|
|
6319
|
+
language = "sql"
|
|
6320
|
+
}) {
|
|
6289
6321
|
const theme = ui.useTheme2();
|
|
6290
6322
|
const styles = ui.useStyles2(getStyles$h);
|
|
6291
6323
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
@@ -6299,7 +6331,8 @@ function RawEditor({ db, query, onChange, onRunQuery, onValidate, queryToValidat
|
|
|
6299
6331
|
completionProvider,
|
|
6300
6332
|
query,
|
|
6301
6333
|
width,
|
|
6302
|
-
|
|
6334
|
+
language,
|
|
6335
|
+
height: height ? height - toolboxMeasure.height : undefined,
|
|
6303
6336
|
onChange
|
|
6304
6337
|
},
|
|
6305
6338
|
({ formatQuery }) => {
|
|
@@ -6369,7 +6402,7 @@ function getStyles$h(theme) {
|
|
|
6369
6402
|
};
|
|
6370
6403
|
}
|
|
6371
6404
|
|
|
6372
|
-
function Preview({ rawSql }) {
|
|
6405
|
+
function Preview({ rawSql, language = "sql" }) {
|
|
6373
6406
|
const [_, copyToClipboard] = reactUse.useCopyToClipboard();
|
|
6374
6407
|
const styles = ui.useStyles2(getStyles$g);
|
|
6375
6408
|
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" }));
|
|
@@ -6378,7 +6411,7 @@ function Preview({ rawSql }) {
|
|
|
6378
6411
|
{
|
|
6379
6412
|
language: "sql",
|
|
6380
6413
|
height: 80,
|
|
6381
|
-
value: formatSQL(rawSql),
|
|
6414
|
+
value: formatSQL(rawSql, language),
|
|
6382
6415
|
monacoOptions: { scrollbar: { vertical: "hidden" }, scrollBeyondLastLine: false },
|
|
6383
6416
|
readOnly: true,
|
|
6384
6417
|
showMiniMap: false
|
|
@@ -6446,9 +6479,9 @@ function OrderByRow({ sql, onSqlChange, columns, showOffset }) {
|
|
|
6446
6479
|
);
|
|
6447
6480
|
const onOrderByChange = React.useCallback(
|
|
6448
6481
|
(item) => {
|
|
6449
|
-
const newSql = { ...sql, orderBy: setPropertyField(item == null ?
|
|
6482
|
+
const newSql = { ...sql, orderBy: setPropertyField(item == null ? undefined : item.value) };
|
|
6450
6483
|
if (item === null) {
|
|
6451
|
-
newSql.orderByDirection =
|
|
6484
|
+
newSql.orderByDirection = undefined;
|
|
6452
6485
|
}
|
|
6453
6486
|
onSqlChange(newSql);
|
|
6454
6487
|
},
|
|
@@ -6459,7 +6492,7 @@ function OrderByRow({ sql, onSqlChange, columns, showOffset }) {
|
|
|
6459
6492
|
{
|
|
6460
6493
|
"aria-label": "Order by",
|
|
6461
6494
|
options: columns,
|
|
6462
|
-
value: ((_a = sql.orderBy) == null ?
|
|
6495
|
+
value: ((_a = sql.orderBy) == null ? undefined : _a.property.name) ? data.toOption(sql.orderBy.property.name) : null,
|
|
6463
6496
|
isClearable: true,
|
|
6464
6497
|
menuShouldPortal: true,
|
|
6465
6498
|
onChange: onOrderByChange
|
|
@@ -6468,7 +6501,7 @@ function OrderByRow({ sql, onSqlChange, columns, showOffset }) {
|
|
|
6468
6501
|
ui.RadioButtonGroup,
|
|
6469
6502
|
{
|
|
6470
6503
|
options: sortOrderOptions,
|
|
6471
|
-
disabled: !((_b = sql == null ?
|
|
6504
|
+
disabled: !((_b = sql == null ? undefined : sql.orderBy) == null ? undefined : _b.property.name),
|
|
6472
6505
|
value: sql.orderByDirection,
|
|
6473
6506
|
onChange: onSortOrderChange
|
|
6474
6507
|
}
|
|
@@ -6480,9 +6513,9 @@ function SQLOrderByRow({ fields, query, onQueryChange, db }) {
|
|
|
6480
6513
|
const { onSqlChange } = useSqlChange({ query, onQueryChange, db });
|
|
6481
6514
|
let columnsWithIndices = [];
|
|
6482
6515
|
if (fields) {
|
|
6483
|
-
const options = (_b = (_a = query.sql) == null ?
|
|
6516
|
+
const options = (_b = (_a = query.sql) == null ? undefined : _a.columns) == null ? undefined : _b.map((c, i) => {
|
|
6484
6517
|
var _a2, _b2;
|
|
6485
|
-
const value = c.name ? `${c.name}(${(_a2 = c.parameters) == null ?
|
|
6518
|
+
const value = c.name ? `${c.name}(${(_a2 = c.parameters) == null ? undefined : _a2.map((p) => p.name)})` : (_b2 = c.parameters) == null ? undefined : _b2.map((p) => p.name);
|
|
6486
6519
|
return {
|
|
6487
6520
|
value,
|
|
6488
6521
|
label: `${i + 1} - ${value}`
|
|
@@ -6510,7 +6543,7 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6510
6543
|
(item, index) => (column) => {
|
|
6511
6544
|
var _a2, _b;
|
|
6512
6545
|
let modifiedItem = { ...item };
|
|
6513
|
-
if (!((_a2 = item.parameters) == null ?
|
|
6546
|
+
if (!((_a2 = item.parameters) == null ? undefined : _a2.length)) {
|
|
6514
6547
|
modifiedItem.parameters = [{ type: QueryEditorExpressionType.FunctionParameter, name: column.value }];
|
|
6515
6548
|
} else {
|
|
6516
6549
|
modifiedItem.parameters = item.parameters.map(
|
|
@@ -6519,7 +6552,7 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6519
6552
|
}
|
|
6520
6553
|
const newSql = {
|
|
6521
6554
|
...sql,
|
|
6522
|
-
columns: (_b = sql.columns) == null ?
|
|
6555
|
+
columns: (_b = sql.columns) == null ? undefined : _b.map((c, i) => i === index ? modifiedItem : c)
|
|
6523
6556
|
};
|
|
6524
6557
|
onSqlChange(newSql);
|
|
6525
6558
|
},
|
|
@@ -6530,11 +6563,11 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6530
6563
|
var _a2;
|
|
6531
6564
|
const newItem = {
|
|
6532
6565
|
...item,
|
|
6533
|
-
name: aggregation == null ?
|
|
6566
|
+
name: aggregation == null ? undefined : aggregation.value
|
|
6534
6567
|
};
|
|
6535
6568
|
const newSql = {
|
|
6536
6569
|
...sql,
|
|
6537
|
-
columns: (_a2 = sql.columns) == null ?
|
|
6570
|
+
columns: (_a2 = sql.columns) == null ? undefined : _a2.map((c, i) => i === index ? newItem : c)
|
|
6538
6571
|
};
|
|
6539
6572
|
onSqlChange(newSql);
|
|
6540
6573
|
},
|
|
@@ -6556,7 +6589,7 @@ function SelectRow({ sql, columns, onSqlChange, functions }) {
|
|
|
6556
6589
|
const newSql = { ...sql, columns: [...sql.columns, createFunctionField()] };
|
|
6557
6590
|
onSqlChange(newSql);
|
|
6558
6591
|
}, [onSqlChange, sql]);
|
|
6559
|
-
return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2, alignItems: "end", direction: "column" }, (_a = sql.columns) == null ?
|
|
6592
|
+
return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 2, alignItems: "end", direction: "column" }, (_a = sql.columns) == null ? undefined : _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
6593
|
ui.Select,
|
|
6561
6594
|
{
|
|
6562
6595
|
value: getColumnValue(item),
|
|
@@ -6604,8 +6637,8 @@ const getStyles$f = () => {
|
|
|
6604
6637
|
return { addButton: css.css({ alignSelf: "flex-start" }) };
|
|
6605
6638
|
};
|
|
6606
6639
|
function getColumnValue({ parameters }) {
|
|
6607
|
-
const column = parameters == null ?
|
|
6608
|
-
if (column == null ?
|
|
6640
|
+
const column = parameters == null ? undefined : parameters.find((p) => p.type === QueryEditorExpressionType.FunctionParameter);
|
|
6641
|
+
if (column == null ? undefined : column.name) {
|
|
6609
6642
|
return data.toOption(column.name);
|
|
6610
6643
|
}
|
|
6611
6644
|
return null;
|
|
@@ -6626,6 +6659,7 @@ const buttonLabels = {
|
|
|
6626
6659
|
};
|
|
6627
6660
|
({
|
|
6628
6661
|
id: ui$1.Utils.uuid(),
|
|
6662
|
+
type: "group",
|
|
6629
6663
|
children1: [
|
|
6630
6664
|
{
|
|
6631
6665
|
id: ui$1.Utils.uuid(),
|
|
@@ -6663,9 +6697,9 @@ const widgets = {
|
|
|
6663
6697
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6664
6698
|
ui.Input,
|
|
6665
6699
|
{
|
|
6666
|
-
value: (props == null ?
|
|
6667
|
-
placeholder: props == null ?
|
|
6668
|
-
onChange: (e) => props == null ?
|
|
6700
|
+
value: (props == null ? undefined : props.value) || "",
|
|
6701
|
+
placeholder: props == null ? undefined : props.placeholder,
|
|
6702
|
+
onChange: (e) => props == null ? undefined : props.setValue(e.currentTarget.value)
|
|
6669
6703
|
}
|
|
6670
6704
|
);
|
|
6671
6705
|
}
|
|
@@ -6676,10 +6710,10 @@ const widgets = {
|
|
|
6676
6710
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6677
6711
|
ui.Input,
|
|
6678
6712
|
{
|
|
6679
|
-
value: props == null ?
|
|
6680
|
-
placeholder: props == null ?
|
|
6713
|
+
value: props == null ? undefined : props.value,
|
|
6714
|
+
placeholder: props == null ? undefined : props.placeholder,
|
|
6681
6715
|
type: "number",
|
|
6682
|
-
onChange: (e) => props == null ?
|
|
6716
|
+
onChange: (e) => props == null ? undefined : props.setValue(Number.parseInt(e.currentTarget.value, 10))
|
|
6683
6717
|
}
|
|
6684
6718
|
);
|
|
6685
6719
|
}
|
|
@@ -6691,9 +6725,9 @@ const widgets = {
|
|
|
6691
6725
|
ui.DateTimePicker,
|
|
6692
6726
|
{
|
|
6693
6727
|
onChange: (e) => {
|
|
6694
|
-
props == null ?
|
|
6728
|
+
props == null ? undefined : props.setValue(e == null ? undefined : e.format(ui$1.BasicConfig.widgets.datetime.valueFormat));
|
|
6695
6729
|
},
|
|
6696
|
-
date: data.dateTime(props == null ?
|
|
6730
|
+
date: data.dateTime(props == null ? undefined : props.value).utc()
|
|
6697
6731
|
}
|
|
6698
6732
|
);
|
|
6699
6733
|
}
|
|
@@ -6711,37 +6745,37 @@ const settings = {
|
|
|
6711
6745
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6712
6746
|
ui.Select,
|
|
6713
6747
|
{
|
|
6714
|
-
id: conjProps == null ?
|
|
6748
|
+
id: conjProps == null ? undefined : conjProps.id,
|
|
6715
6749
|
"aria-label": "Conjunction",
|
|
6716
6750
|
menuShouldPortal: true,
|
|
6717
|
-
options: (conjProps == null ?
|
|
6718
|
-
value: conjProps == null ?
|
|
6719
|
-
onChange: (val) => conjProps == null ?
|
|
6751
|
+
options: (conjProps == null ? undefined : conjProps.conjunctionOptions) ? Object.keys(conjProps == null ? undefined : conjProps.conjunctionOptions).map(data.toOption) : undefined,
|
|
6752
|
+
value: conjProps == null ? undefined : conjProps.selectedConjunction,
|
|
6753
|
+
onChange: (val) => conjProps == null ? undefined : conjProps.setConjunction(val.value)
|
|
6720
6754
|
}
|
|
6721
6755
|
);
|
|
6722
6756
|
},
|
|
6723
6757
|
renderField: function Field(fieldProps) {
|
|
6724
6758
|
var _a;
|
|
6725
|
-
const fields = ((_a = fieldProps == null ?
|
|
6759
|
+
const fields = ((_a = fieldProps == null ? undefined : fieldProps.config) == null ? undefined : _a.fields) || {};
|
|
6726
6760
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6727
6761
|
ui.Select,
|
|
6728
6762
|
{
|
|
6729
|
-
id: fieldProps == null ?
|
|
6763
|
+
id: fieldProps == null ? undefined : fieldProps.id,
|
|
6730
6764
|
width: 25,
|
|
6731
6765
|
"aria-label": "Field",
|
|
6732
6766
|
menuShouldPortal: true,
|
|
6733
|
-
options: fieldProps == null ?
|
|
6767
|
+
options: fieldProps == null ? undefined : fieldProps.items.map((f) => {
|
|
6734
6768
|
var _a2, _b;
|
|
6735
|
-
const icon = (_b = (_a2 = fields[f.key].mainWidgetProps) == null ?
|
|
6769
|
+
const icon = (_b = (_a2 = fields[f.key].mainWidgetProps) == null ? undefined : _a2.customProps) == null ? undefined : _b.icon;
|
|
6736
6770
|
return {
|
|
6737
6771
|
label: f.label,
|
|
6738
6772
|
value: f.key,
|
|
6739
6773
|
icon
|
|
6740
6774
|
};
|
|
6741
6775
|
}),
|
|
6742
|
-
value: fieldProps == null ?
|
|
6776
|
+
value: fieldProps == null ? undefined : fieldProps.selectedKey,
|
|
6743
6777
|
onChange: (val) => {
|
|
6744
|
-
fieldProps == null ?
|
|
6778
|
+
fieldProps == null ? undefined : fieldProps.setField(val.label);
|
|
6745
6779
|
}
|
|
6746
6780
|
}
|
|
6747
6781
|
);
|
|
@@ -6751,11 +6785,11 @@ const settings = {
|
|
|
6751
6785
|
ui.Button,
|
|
6752
6786
|
{
|
|
6753
6787
|
type: "button",
|
|
6754
|
-
title: `${buttonProps == null ?
|
|
6755
|
-
onClick: buttonProps == null ?
|
|
6788
|
+
title: `${buttonProps == null ? undefined : buttonProps.label} filter`,
|
|
6789
|
+
onClick: buttonProps == null ? undefined : buttonProps.onClick,
|
|
6756
6790
|
variant: "secondary",
|
|
6757
6791
|
size: "md",
|
|
6758
|
-
icon: (buttonProps == null ?
|
|
6792
|
+
icon: (buttonProps == null ? undefined : buttonProps.label) === buttonLabels.add ? "plus" : "times"
|
|
6759
6793
|
}
|
|
6760
6794
|
);
|
|
6761
6795
|
},
|
|
@@ -6763,12 +6797,12 @@ const settings = {
|
|
|
6763
6797
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
6764
6798
|
ui.Select,
|
|
6765
6799
|
{
|
|
6766
|
-
options: operatorProps == null ?
|
|
6800
|
+
options: operatorProps == null ? undefined : operatorProps.items.map((op) => ({ label: op.label, value: op.key })),
|
|
6767
6801
|
"aria-label": "Operator",
|
|
6768
6802
|
menuShouldPortal: true,
|
|
6769
|
-
value: operatorProps == null ?
|
|
6803
|
+
value: operatorProps == null ? undefined : operatorProps.selectedKey,
|
|
6770
6804
|
onChange: (val) => {
|
|
6771
|
-
operatorProps == null ?
|
|
6805
|
+
operatorProps == null ? undefined : operatorProps.setField(val.value || "");
|
|
6772
6806
|
}
|
|
6773
6807
|
}
|
|
6774
6808
|
);
|
|
@@ -6964,7 +6998,7 @@ const EditorField = (props) => {
|
|
|
6964
6998
|
const { label, optional, tooltip, children, width, ...fieldProps } = props;
|
|
6965
6999
|
const theme = ui.useTheme2();
|
|
6966
7000
|
const styles = getStyles$d(theme, width);
|
|
6967
|
-
const childInputId = (fieldProps == null ?
|
|
7001
|
+
const childInputId = (fieldProps == null ? undefined : fieldProps.htmlFor) || ((_a = ui.ReactUtils) == null ? undefined : _a.getChildId(children));
|
|
6968
7002
|
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 }));
|
|
6969
7003
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, /* @__PURE__ */ React__default.default.createElement(ui.Field, { className: styles.field, label: labelEl, ...fieldProps }, children));
|
|
6970
7004
|
};
|
|
@@ -6999,12 +7033,20 @@ const EditorRows = ({ children }) => {
|
|
|
6999
7033
|
return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 0.5, direction: "column" }, children);
|
|
7000
7034
|
};
|
|
7001
7035
|
|
|
7002
|
-
const VisualEditor = ({
|
|
7036
|
+
const VisualEditor = ({
|
|
7037
|
+
query,
|
|
7038
|
+
db,
|
|
7039
|
+
queryRowFilter,
|
|
7040
|
+
onChange,
|
|
7041
|
+
onValidate,
|
|
7042
|
+
language = "sql",
|
|
7043
|
+
range
|
|
7044
|
+
}) => {
|
|
7003
7045
|
const state = reactUse.useAsync(async () => {
|
|
7004
7046
|
const fields = await db.fields(query);
|
|
7005
7047
|
return fields;
|
|
7006
7048
|
}, [db, query.dataset, query.table]);
|
|
7007
|
-
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 }));
|
|
7049
|
+
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 }));
|
|
7008
7050
|
};
|
|
7009
7051
|
|
|
7010
7052
|
const MACRO_NAMES = [
|
|
@@ -7023,20 +7065,20 @@ const MACRO_NAMES = [
|
|
|
7023
7065
|
"$__unixEpochGroupAlias"
|
|
7024
7066
|
];
|
|
7025
7067
|
|
|
7026
|
-
var __defProp$
|
|
7027
|
-
var __defNormalProp$
|
|
7028
|
-
var __publicField$
|
|
7068
|
+
var __defProp$3 = Object.defineProperty;
|
|
7069
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7070
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7029
7071
|
class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
7030
7072
|
constructor(instanceSettings, templateSrv = runtime.getTemplateSrv()) {
|
|
7031
7073
|
super(instanceSettings);
|
|
7032
7074
|
this.templateSrv = templateSrv;
|
|
7033
|
-
__publicField$
|
|
7034
|
-
__publicField$
|
|
7035
|
-
__publicField$
|
|
7036
|
-
__publicField$
|
|
7037
|
-
__publicField$
|
|
7038
|
-
__publicField$
|
|
7039
|
-
__publicField$
|
|
7075
|
+
__publicField$3(this, "id");
|
|
7076
|
+
__publicField$3(this, "name");
|
|
7077
|
+
__publicField$3(this, "interval");
|
|
7078
|
+
__publicField$3(this, "db");
|
|
7079
|
+
__publicField$3(this, "dataset");
|
|
7080
|
+
__publicField$3(this, "annotations", {});
|
|
7081
|
+
__publicField$3(this, "interpolateVariable", (value, variable) => {
|
|
7040
7082
|
if (typeof value === "string") {
|
|
7041
7083
|
if (variable.multi || variable.includeAll) {
|
|
7042
7084
|
const result = this.getQueryModel().quoteLiteral(value);
|
|
@@ -7107,7 +7149,7 @@ class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
|
7107
7149
|
return this.getResponseParser().transformMetricFindResponse(response);
|
|
7108
7150
|
}
|
|
7109
7151
|
async runSql(query, options) {
|
|
7110
|
-
const frame = await this.runMetaQuery({ rawSql: query, format: QueryFormat.Table, refId: options == null ?
|
|
7152
|
+
const frame = await this.runMetaQuery({ rawSql: query, format: QueryFormat.Table, refId: options == null ? undefined : options.refId }, options);
|
|
7111
7153
|
return new data.DataFrameView(frame);
|
|
7112
7154
|
}
|
|
7113
7155
|
runMetaQuery(request, options) {
|
|
@@ -7119,8 +7161,8 @@ class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
|
7119
7161
|
url: "/api/ds/query",
|
|
7120
7162
|
method: "POST",
|
|
7121
7163
|
data: {
|
|
7122
|
-
from: (_a = options == null ?
|
|
7123
|
-
to: (_b = options == null ?
|
|
7164
|
+
from: (_a = options == null ? undefined : options.range) == null ? undefined : _a.from.valueOf().toString(),
|
|
7165
|
+
to: (_b = options == null ? undefined : options.range) == null ? undefined : _b.to.valueOf().toString(),
|
|
7124
7166
|
queries
|
|
7125
7167
|
},
|
|
7126
7168
|
requestId: refId
|
|
@@ -7163,7 +7205,7 @@ class SqlDatasource extends runtime.DataSourceWithBackend {
|
|
|
7163
7205
|
targetContainsTemplate(target) {
|
|
7164
7206
|
let queryWithoutMacros = target.rawSql;
|
|
7165
7207
|
MACRO_NAMES.forEach((value) => {
|
|
7166
|
-
queryWithoutMacros = (queryWithoutMacros == null ?
|
|
7208
|
+
queryWithoutMacros = (queryWithoutMacros == null ? undefined : queryWithoutMacros.replace(value, "")) || "";
|
|
7167
7209
|
});
|
|
7168
7210
|
return this.templateSrv.containsTemplate(queryWithoutMacros);
|
|
7169
7211
|
}
|
|
@@ -7186,29 +7228,29 @@ const getSearchFilterScopedVar = (args) => {
|
|
|
7186
7228
|
};
|
|
7187
7229
|
};
|
|
7188
7230
|
|
|
7189
|
-
function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
7231
|
+
function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range, language = "sql" }) {
|
|
7190
7232
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7191
7233
|
const [isQueryRunnable, setIsQueryRunnable] = React.useState(true);
|
|
7192
7234
|
const db = datasource.getDB();
|
|
7193
7235
|
const defaultDataset = datasource.dataset;
|
|
7194
7236
|
const { loading, error } = reactUse.useAsync(async () => {
|
|
7195
7237
|
return () => {
|
|
7196
|
-
if (datasource.getDB(datasource.id).init !==
|
|
7238
|
+
if (datasource.getDB(datasource.id).init !== undefined) {
|
|
7197
7239
|
datasource.getDB(datasource.id).init();
|
|
7198
7240
|
}
|
|
7199
7241
|
};
|
|
7200
7242
|
}, [datasource]);
|
|
7201
7243
|
const queryWithDefaults = applyQueryDefaults(query);
|
|
7202
7244
|
const [queryRowFilter, setQueryRowFilter] = React.useState({
|
|
7203
|
-
filter: !!((_a = queryWithDefaults.sql) == null ?
|
|
7204
|
-
group: !!((_d = (_c = (_b = queryWithDefaults.sql) == null ?
|
|
7205
|
-
order: !!((_f = (_e = queryWithDefaults.sql) == null ?
|
|
7245
|
+
filter: !!((_a = queryWithDefaults.sql) == null ? undefined : _a.whereString),
|
|
7246
|
+
group: !!((_d = (_c = (_b = queryWithDefaults.sql) == null ? undefined : _b.groupBy) == null ? undefined : _c[0]) == null ? undefined : _d.property.name),
|
|
7247
|
+
order: !!((_f = (_e = queryWithDefaults.sql) == null ? undefined : _e.orderBy) == null ? undefined : _f.property.name),
|
|
7206
7248
|
preview: true
|
|
7207
7249
|
});
|
|
7208
7250
|
const [queryToValidate, setQueryToValidate] = React.useState(queryWithDefaults);
|
|
7209
7251
|
React.useEffect(() => {
|
|
7210
7252
|
return () => {
|
|
7211
|
-
if (datasource.getDB(datasource.id).dispose !==
|
|
7253
|
+
if (datasource.getDB(datasource.id).dispose !== undefined) {
|
|
7212
7254
|
datasource.getDB(datasource.id).dispose();
|
|
7213
7255
|
}
|
|
7214
7256
|
};
|
|
@@ -7225,7 +7267,7 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
|
7225
7267
|
var _a2, _b2;
|
|
7226
7268
|
setQueryToValidate(q);
|
|
7227
7269
|
onChange(q);
|
|
7228
|
-
if (haveColumns((_a2 = q.sql) == null ?
|
|
7270
|
+
if (haveColumns((_a2 = q.sql) == null ? undefined : _a2.columns) && ((_b2 = q.sql) == null ? undefined : _b2.columns.some((c) => c.name)) && !queryRowFilter.group) {
|
|
7229
7271
|
setQueryRowFilter({ ...queryRowFilter, group: true });
|
|
7230
7272
|
}
|
|
7231
7273
|
if (process) {
|
|
@@ -7255,13 +7297,14 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
|
7255
7297
|
queryRowFilter,
|
|
7256
7298
|
query: queryWithDefaults,
|
|
7257
7299
|
isQueryRunnable,
|
|
7258
|
-
labels: (_g = datasource.getDB(datasource.id)) == null ?
|
|
7300
|
+
labels: (_g = datasource.getDB(datasource.id)) == null ? undefined : _g.labels
|
|
7259
7301
|
}
|
|
7260
7302
|
), /* @__PURE__ */ React__default.default.createElement(Space, { v: 0.5 }), queryWithDefaults.editorMode !== EditorMode.Code && /* @__PURE__ */ React__default.default.createElement(
|
|
7261
7303
|
VisualEditor,
|
|
7262
7304
|
{
|
|
7263
7305
|
db,
|
|
7264
7306
|
query: queryWithDefaults,
|
|
7307
|
+
language,
|
|
7265
7308
|
onChange: (q) => onQueryChange(q, false),
|
|
7266
7309
|
queryRowFilter,
|
|
7267
7310
|
onValidate: setIsQueryRunnable,
|
|
@@ -7271,6 +7314,7 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
|
|
|
7271
7314
|
RawEditor,
|
|
7272
7315
|
{
|
|
7273
7316
|
db,
|
|
7317
|
+
language,
|
|
7274
7318
|
query: queryWithDefaults,
|
|
7275
7319
|
queryToValidate,
|
|
7276
7320
|
onChange: onQueryChange,
|
|
@@ -7575,7 +7619,7 @@ const AuthMethodSettings = ({
|
|
|
7575
7619
|
AuthMethod.BasicAuth,
|
|
7576
7620
|
AuthMethod.OAuthForward,
|
|
7577
7621
|
AuthMethod.NoAuth,
|
|
7578
|
-
...(_a2 = customMethods == null ?
|
|
7622
|
+
...(_a2 = customMethods == null ? undefined : customMethods.map((m) => m.id)) != null ? _a2 : []
|
|
7579
7623
|
];
|
|
7580
7624
|
},
|
|
7581
7625
|
[customMethods, visibleMethodsFromProps]
|
|
@@ -7583,7 +7627,7 @@ const AuthMethodSettings = ({
|
|
|
7583
7627
|
const hasSelect = visibleMethods.length > 1;
|
|
7584
7628
|
const preparedOptions = React.useMemo(() => {
|
|
7585
7629
|
var _a2;
|
|
7586
|
-
const customOptions = (_a2 = customMethods == null ?
|
|
7630
|
+
const customOptions = (_a2 = customMethods == null ? undefined : customMethods.reduce((acc, method) => {
|
|
7587
7631
|
acc[method.id] = {
|
|
7588
7632
|
label: method.label,
|
|
7589
7633
|
value: method.id,
|
|
@@ -7596,7 +7640,7 @@ const AuthMethodSettings = ({
|
|
|
7596
7640
|
for (k in defaultOptions) {
|
|
7597
7641
|
preparedDefaultOptions[k] = {
|
|
7598
7642
|
...defaultOptions[k],
|
|
7599
|
-
...defaultOptionsOverrides == null ?
|
|
7643
|
+
...defaultOptionsOverrides == null ? undefined : defaultOptionsOverrides[k]
|
|
7600
7644
|
};
|
|
7601
7645
|
}
|
|
7602
7646
|
const allOptions = {
|
|
@@ -7624,7 +7668,7 @@ const AuthMethodSettings = ({
|
|
|
7624
7668
|
if (selected === AuthMethod.BasicAuth && basicAuth) {
|
|
7625
7669
|
AuthFieldsComponent = /* @__PURE__ */ React__default.default.createElement(BasicAuth, { ...basicAuth, readOnly });
|
|
7626
7670
|
} else if (selected.startsWith("custom-")) {
|
|
7627
|
-
AuthFieldsComponent = (_b = (_a = customMethods == null ?
|
|
7671
|
+
AuthFieldsComponent = (_b = (_a = customMethods == null ? undefined : customMethods.find((m) => m.id === selected)) == null ? undefined : _a.component) != null ? _b : null;
|
|
7628
7672
|
}
|
|
7629
7673
|
const title = hasSelect ? "Authentication methods" : (_c = preparedOptions[0].label) != null ? _c : "";
|
|
7630
7674
|
const description = hasSelect ? "Choose an authentication method to access the data source" : (_d = preparedOptions[0].description) != null ? _d : "";
|
|
@@ -7709,7 +7753,7 @@ const SelfSignedCertificate = ({
|
|
|
7709
7753
|
{
|
|
7710
7754
|
label: "CA Certificate",
|
|
7711
7755
|
labelWidth: 24,
|
|
7712
|
-
tooltip: (_a = tooltips == null ?
|
|
7756
|
+
tooltip: (_a = tooltips == null ? undefined : tooltips.certificateLabel) != null ? _a : "Your self-signed certificate",
|
|
7713
7757
|
required: true,
|
|
7714
7758
|
htmlFor: "self-signed-certificate-input",
|
|
7715
7759
|
interactive: true,
|
|
@@ -7764,7 +7808,7 @@ const TLSClientAuth = ({
|
|
|
7764
7808
|
{
|
|
7765
7809
|
label: "ServerName",
|
|
7766
7810
|
labelWidth: 24,
|
|
7767
|
-
tooltip: (_a = tooltips == null ?
|
|
7811
|
+
tooltip: (_a = tooltips == null ? undefined : tooltips.serverNameLabel) != null ? _a : "A Servername is used to verify the hostname on the returned certificate",
|
|
7768
7812
|
required: true,
|
|
7769
7813
|
htmlFor: "client-auth-servername-input",
|
|
7770
7814
|
interactive: true,
|
|
@@ -7788,7 +7832,7 @@ const TLSClientAuth = ({
|
|
|
7788
7832
|
{
|
|
7789
7833
|
label: "Client Certificate",
|
|
7790
7834
|
labelWidth: 24,
|
|
7791
|
-
tooltip: (_b = tooltips == null ?
|
|
7835
|
+
tooltip: (_b = tooltips == null ? undefined : tooltips.certificateLabel) != null ? _b : "The client certificate can be generated from a Certificate Authority or be self-signed",
|
|
7792
7836
|
required: true,
|
|
7793
7837
|
htmlFor: "client-auth-client-certificate-input",
|
|
7794
7838
|
interactive: true,
|
|
@@ -7815,7 +7859,7 @@ const TLSClientAuth = ({
|
|
|
7815
7859
|
{
|
|
7816
7860
|
label: "Client Key",
|
|
7817
7861
|
labelWidth: 24,
|
|
7818
|
-
tooltip: (_c = tooltips == null ?
|
|
7862
|
+
tooltip: (_c = tooltips == null ? undefined : tooltips.keyLabel) != null ? _c : "The client key can be generated from a Certificate Authority or be self-signed",
|
|
7819
7863
|
required: true,
|
|
7820
7864
|
htmlFor: "client-auth-client-key-input",
|
|
7821
7865
|
interactive: true,
|
|
@@ -7971,7 +8015,7 @@ const CustomHeaders = ({ headers: headersFromProps, onChange, readOnly }) => {
|
|
|
7971
8015
|
let changed = false;
|
|
7972
8016
|
const newHeaders = headers2.map((header) => {
|
|
7973
8017
|
var _a;
|
|
7974
|
-
const configured = (_a = headersFromProps.find((h) => h.name === header.name)) == null ?
|
|
8018
|
+
const configured = (_a = headersFromProps.find((h) => h.name === header.name)) == null ? undefined : _a.configured;
|
|
7975
8019
|
if (typeof configured !== "undefined" && header.configured !== configured) {
|
|
7976
8020
|
changed = true;
|
|
7977
8021
|
return { ...header, configured };
|
|
@@ -8149,7 +8193,7 @@ function getTLSProps(config, onChange) {
|
|
|
8149
8193
|
return {
|
|
8150
8194
|
selfSignedCertificate: {
|
|
8151
8195
|
enabled: Boolean(config.jsonData.tlsAuthWithCACert),
|
|
8152
|
-
certificateConfigured: !!((_a = config.secureJsonFields) == null ?
|
|
8196
|
+
certificateConfigured: !!((_a = config.secureJsonFields) == null ? undefined : _a.tlsCACert),
|
|
8153
8197
|
onToggle: (enabled) => enabled ? onChange({
|
|
8154
8198
|
...config,
|
|
8155
8199
|
jsonData: { ...config.jsonData, tlsAuthWithCACert: enabled }
|
|
@@ -8172,8 +8216,8 @@ function getTLSProps(config, onChange) {
|
|
|
8172
8216
|
TLSClientAuth: {
|
|
8173
8217
|
enabled: config.jsonData.tlsAuth,
|
|
8174
8218
|
serverName: config.jsonData.serverName,
|
|
8175
|
-
clientCertificateConfigured: !!((_b = config.secureJsonFields) == null ?
|
|
8176
|
-
clientKeyConfigured: !!((_c = config.secureJsonFields) == null ?
|
|
8219
|
+
clientCertificateConfigured: !!((_b = config.secureJsonFields) == null ? undefined : _b.tlsClientCert),
|
|
8220
|
+
clientKeyConfigured: !!((_c = config.secureJsonFields) == null ? undefined : _c.tlsClientKey),
|
|
8177
8221
|
onToggle: (enabled) => enabled ? onChange({
|
|
8178
8222
|
...config,
|
|
8179
8223
|
jsonData: { ...config.jsonData, tlsAuth: enabled }
|
|
@@ -8281,7 +8325,7 @@ const ConnectionSettings = ({
|
|
|
8281
8325
|
urlLabel,
|
|
8282
8326
|
className
|
|
8283
8327
|
}) => {
|
|
8284
|
-
const isValidUrl = config.url !==
|
|
8328
|
+
const isValidUrl = config.url !== undefined && /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/.test(config.url);
|
|
8285
8329
|
const styles = {
|
|
8286
8330
|
container: css.css({
|
|
8287
8331
|
maxWidth: 578
|
|
@@ -8389,9 +8433,9 @@ const AdvancedHttpSettings = ({
|
|
|
8389
8433
|
));
|
|
8390
8434
|
};
|
|
8391
8435
|
|
|
8392
|
-
var __defProp$
|
|
8393
|
-
var __defNormalProp$
|
|
8394
|
-
var __publicField$
|
|
8436
|
+
var __defProp$2 = Object.defineProperty;
|
|
8437
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8438
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8395
8439
|
const getCustomHeaderRowStyles = ui.stylesFactory(() => {
|
|
8396
8440
|
return {
|
|
8397
8441
|
layout: css.css`
|
|
@@ -8454,10 +8498,10 @@ CustomHeaderRow.displayName = "CustomHeaderRow";
|
|
|
8454
8498
|
class CustomHeadersSettings extends React.PureComponent {
|
|
8455
8499
|
constructor(props) {
|
|
8456
8500
|
super(props);
|
|
8457
|
-
__publicField$
|
|
8501
|
+
__publicField$2(this, "state", {
|
|
8458
8502
|
headers: []
|
|
8459
8503
|
});
|
|
8460
|
-
__publicField$
|
|
8504
|
+
__publicField$2(this, "updateSettings", () => {
|
|
8461
8505
|
const { headers } = this.state;
|
|
8462
8506
|
const newJsonData = Object.fromEntries(
|
|
8463
8507
|
Object.entries(this.props.dataSourceConfig.jsonData).filter(([key, val]) => !key.startsWith("httpHeaderName"))
|
|
@@ -8479,14 +8523,14 @@ class CustomHeadersSettings extends React.PureComponent {
|
|
|
8479
8523
|
secureJsonData: newSecureJsonData
|
|
8480
8524
|
});
|
|
8481
8525
|
});
|
|
8482
|
-
__publicField$
|
|
8526
|
+
__publicField$2(this, "onHeaderAdd", () => {
|
|
8483
8527
|
this.setState((prevState) => {
|
|
8484
8528
|
return {
|
|
8485
8529
|
headers: [...prevState.headers, { id: lodash.uniqueId(), name: "", value: "", configured: false }]
|
|
8486
8530
|
};
|
|
8487
8531
|
});
|
|
8488
8532
|
});
|
|
8489
|
-
__publicField$
|
|
8533
|
+
__publicField$2(this, "onHeaderChange", (headerIndex, value) => {
|
|
8490
8534
|
this.setState(({ headers }) => {
|
|
8491
8535
|
return {
|
|
8492
8536
|
headers: headers.map((item, index) => {
|
|
@@ -8498,7 +8542,7 @@ class CustomHeadersSettings extends React.PureComponent {
|
|
|
8498
8542
|
};
|
|
8499
8543
|
});
|
|
8500
8544
|
});
|
|
8501
|
-
__publicField$
|
|
8545
|
+
__publicField$2(this, "onHeaderReset", (headerId) => {
|
|
8502
8546
|
this.setState(({ headers }) => {
|
|
8503
8547
|
return {
|
|
8504
8548
|
headers: headers.map((h, i) => {
|
|
@@ -8514,7 +8558,7 @@ class CustomHeadersSettings extends React.PureComponent {
|
|
|
8514
8558
|
};
|
|
8515
8559
|
});
|
|
8516
8560
|
});
|
|
8517
|
-
__publicField$
|
|
8561
|
+
__publicField$2(this, "onHeaderRemove", (headerId) => {
|
|
8518
8562
|
this.setState(
|
|
8519
8563
|
({ headers }) => ({
|
|
8520
8564
|
headers: headers.filter((h) => h.id !== headerId)
|
|
@@ -8528,7 +8572,7 @@ class CustomHeadersSettings extends React.PureComponent {
|
|
|
8528
8572
|
return {
|
|
8529
8573
|
id: lodash.uniqueId(),
|
|
8530
8574
|
name: jsonData[key],
|
|
8531
|
-
value: secureJsonData !==
|
|
8575
|
+
value: secureJsonData !== undefined ? secureJsonData[key] : "",
|
|
8532
8576
|
configured: secureJsonFields && secureJsonFields[`httpHeaderValue${index + 1}`] || false
|
|
8533
8577
|
};
|
|
8534
8578
|
})
|
|
@@ -8570,14 +8614,14 @@ var QueryEditorMode = /* @__PURE__ */ ((QueryEditorMode2) => {
|
|
|
8570
8614
|
})(QueryEditorMode || {});
|
|
8571
8615
|
const BINARY_OPERATIONS_KEY = "Binary operations";
|
|
8572
8616
|
|
|
8573
|
-
var __defProp = Object.defineProperty;
|
|
8574
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8575
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8617
|
+
var __defProp$1 = Object.defineProperty;
|
|
8618
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8619
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8576
8620
|
class QueryModellerBase {
|
|
8577
8621
|
constructor(operationDefinitions, innerQueryPlaceholder) {
|
|
8578
|
-
__publicField(this, "operationsRegistry");
|
|
8579
|
-
__publicField(this, "categories", []);
|
|
8580
|
-
__publicField(this, "innerQueryPlaceholder");
|
|
8622
|
+
__publicField$1(this, "operationsRegistry");
|
|
8623
|
+
__publicField$1(this, "categories", []);
|
|
8624
|
+
__publicField$1(this, "innerQueryPlaceholder");
|
|
8581
8625
|
this.operationsRegistry = new data.Registry(() => operationDefinitions);
|
|
8582
8626
|
this.innerQueryPlaceholder = innerQueryPlaceholder || "<query>";
|
|
8583
8627
|
}
|
|
@@ -8599,8 +8643,8 @@ class QueryModellerBase {
|
|
|
8599
8643
|
hasBinaryOp(query) {
|
|
8600
8644
|
return query.operations.find((op) => {
|
|
8601
8645
|
const def = this.getOperationDefinition(op.id);
|
|
8602
|
-
return (def == null ?
|
|
8603
|
-
}) !==
|
|
8646
|
+
return (def == null ? undefined : def.category) === BINARY_OPERATIONS_KEY;
|
|
8647
|
+
}) !== undefined;
|
|
8604
8648
|
}
|
|
8605
8649
|
}
|
|
8606
8650
|
|
|
@@ -8623,7 +8667,7 @@ function LabelFilterItem({
|
|
|
8623
8667
|
const [labelValuesMenuOpen, setLabelValuesMenuOpen] = React.useState(false);
|
|
8624
8668
|
const isMultiSelect = (operator = item.op) => {
|
|
8625
8669
|
var _a2;
|
|
8626
|
-
return (_a2 = operators.find((op) => op.label === operator)) == null ?
|
|
8670
|
+
return (_a2 = operators.find((op) => op.label === operator)) == null ? undefined : _a2.isMultiValue;
|
|
8627
8671
|
};
|
|
8628
8672
|
const getSelectOptionsFromString = (item2) => {
|
|
8629
8673
|
if (item2) {
|
|
@@ -8636,12 +8680,12 @@ function LabelFilterItem({
|
|
|
8636
8680
|
};
|
|
8637
8681
|
const getOptions = () => {
|
|
8638
8682
|
const labelValues = state.labelValues ? [...state.labelValues] : [];
|
|
8639
|
-
const selectedOptions = getSelectOptionsFromString(item == null ?
|
|
8683
|
+
const selectedOptions = getSelectOptionsFromString(item == null ? undefined : item.value).map(data.toOption);
|
|
8640
8684
|
return lodash.uniqBy([...selectedOptions, ...labelValues], "value");
|
|
8641
8685
|
};
|
|
8642
8686
|
const isConflicting = isConflictingLabelFilter(item, items);
|
|
8643
8687
|
const { current: id } = React.useRef(uuid.v4());
|
|
8644
|
-
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 :
|
|
8688
|
+
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 : undefined }, /* @__PURE__ */ React__default.default.createElement(InputGroup, null, /* @__PURE__ */ React__default.default.createElement(
|
|
8645
8689
|
ui.Select,
|
|
8646
8690
|
{
|
|
8647
8691
|
placeholder: "Select label",
|
|
@@ -8654,7 +8698,7 @@ function LabelFilterItem({
|
|
|
8654
8698
|
setState({ isLoadingLabelNames: true });
|
|
8655
8699
|
const labelNames = await onGetLabelNames(item);
|
|
8656
8700
|
setLabelNamesMenuOpen(true);
|
|
8657
|
-
setState({ labelNames, isLoadingLabelNames:
|
|
8701
|
+
setState({ labelNames, isLoadingLabelNames: undefined });
|
|
8658
8702
|
},
|
|
8659
8703
|
onCloseMenu: () => {
|
|
8660
8704
|
setLabelNamesMenuOpen(false);
|
|
@@ -8686,7 +8730,7 @@ function LabelFilterItem({
|
|
|
8686
8730
|
onChange({
|
|
8687
8731
|
...item,
|
|
8688
8732
|
op: change.value,
|
|
8689
|
-
value: isMultiSelect(change.value) ? item.value : getSelectOptionsFromString(item == null ?
|
|
8733
|
+
value: isMultiSelect(change.value) ? item.value : getSelectOptionsFromString(item == null ? undefined : item.value)[0]
|
|
8690
8734
|
});
|
|
8691
8735
|
}
|
|
8692
8736
|
},
|
|
@@ -8699,7 +8743,7 @@ function LabelFilterItem({
|
|
|
8699
8743
|
"data-testid": e2eSelectors.selectors.components.QueryBuilder.valueSelect,
|
|
8700
8744
|
inputId: `visual-query-builder-dimensions-filter-item-value-${id}`,
|
|
8701
8745
|
width: "auto",
|
|
8702
|
-
value: isMultiSelect() ? getSelectOptionsFromString(item == null ?
|
|
8746
|
+
value: isMultiSelect() ? getSelectOptionsFromString(item == null ? undefined : item.value).map(data.toOption) : getSelectOptionsFromString(item == null ? undefined : item.value).map(data.toOption)[0],
|
|
8703
8747
|
allowCustomValue: true,
|
|
8704
8748
|
onOpenMenu: async () => {
|
|
8705
8749
|
setState({ isLoadingLabelValues: true });
|
|
@@ -8707,7 +8751,7 @@ function LabelFilterItem({
|
|
|
8707
8751
|
setState({
|
|
8708
8752
|
...state,
|
|
8709
8753
|
labelValues,
|
|
8710
|
-
isLoadingLabelValues:
|
|
8754
|
+
isLoadingLabelValues: undefined
|
|
8711
8755
|
});
|
|
8712
8756
|
setLabelValuesMenuOpen(true);
|
|
8713
8757
|
},
|
|
@@ -8731,9 +8775,9 @@ function LabelFilterItem({
|
|
|
8731
8775
|
if (change2.value) {
|
|
8732
8776
|
return change2.value;
|
|
8733
8777
|
} else {
|
|
8734
|
-
return
|
|
8778
|
+
return undefined;
|
|
8735
8779
|
}
|
|
8736
|
-
}).filter((val) => val !==
|
|
8780
|
+
}).filter((val) => val !== undefined).join(multiValueSeparator);
|
|
8737
8781
|
onChange({ ...item, value: changes, op: (_b = item.op) != null ? _b : defaultOp });
|
|
8738
8782
|
}
|
|
8739
8783
|
},
|
|
@@ -8760,10 +8804,10 @@ function isConflictingLabelFilter(newLabel, labels) {
|
|
|
8760
8804
|
);
|
|
8761
8805
|
const conflict = candidates.some((candidate) => {
|
|
8762
8806
|
var _a, _b;
|
|
8763
|
-
if (operationIsNegative && ((_a = candidate == null ?
|
|
8807
|
+
if (operationIsNegative && ((_a = candidate == null ? undefined : candidate.op) == null ? undefined : _a.toString().startsWith("!")) === false) {
|
|
8764
8808
|
return true;
|
|
8765
8809
|
}
|
|
8766
|
-
if (operationIsNegative === false && ((_b = candidate == null ?
|
|
8810
|
+
if (operationIsNegative === false && ((_b = candidate == null ? undefined : candidate.op) == null ? undefined : _b.toString().startsWith("!"))) {
|
|
8767
8811
|
return true;
|
|
8768
8812
|
}
|
|
8769
8813
|
return false;
|
|
@@ -8792,7 +8836,7 @@ function LabelFilters({
|
|
|
8792
8836
|
const onLabelsChange = (newItems) => {
|
|
8793
8837
|
setItems(newItems);
|
|
8794
8838
|
const newLabels = newItems.filter(
|
|
8795
|
-
(item) => item.label !==
|
|
8839
|
+
(item) => item.label !== undefined && item.value !== undefined
|
|
8796
8840
|
);
|
|
8797
8841
|
if (!lodash.isEqual(newLabels, labelsFilters)) {
|
|
8798
8842
|
onChange(newLabels);
|
|
@@ -8833,7 +8877,7 @@ function LabelFilters({
|
|
|
8833
8877
|
|
|
8834
8878
|
function OperationExplainedBox({ title, stepNumber, markdown, children }) {
|
|
8835
8879
|
const styles = ui.useStyles2(getStyles$b);
|
|
8836
|
-
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.box }, stepNumber !==
|
|
8880
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.box }, stepNumber !== undefined && /* @__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)));
|
|
8837
8881
|
}
|
|
8838
8882
|
const getStyles$b = (theme) => {
|
|
8839
8883
|
return {
|
|
@@ -9076,7 +9120,7 @@ function SimpleInputParamEditor(props) {
|
|
|
9076
9120
|
ui.AutoSizeInput,
|
|
9077
9121
|
{
|
|
9078
9122
|
id: getOperationParamId(props.operationId, props.index),
|
|
9079
|
-
defaultValue: (_a = props.value) == null ?
|
|
9123
|
+
defaultValue: (_a = props.value) == null ? undefined : _a.toString(),
|
|
9080
9124
|
minWidth: props.paramDef.minWidth,
|
|
9081
9125
|
placeholder: props.paramDef.placeholder,
|
|
9082
9126
|
title: props.paramDef.description,
|
|
@@ -9110,7 +9154,7 @@ function SelectInputParamEditor({
|
|
|
9110
9154
|
var _a, _b;
|
|
9111
9155
|
const styles = ui.useStyles2(getStyles$8);
|
|
9112
9156
|
let selectOptions = paramDef.options;
|
|
9113
|
-
if (!((_a = selectOptions[0]) == null ?
|
|
9157
|
+
if (!((_a = selectOptions[0]) == null ? undefined : _a.label)) {
|
|
9114
9158
|
selectOptions = paramDef.options.map((option) => ({
|
|
9115
9159
|
label: option.toString(),
|
|
9116
9160
|
value: option
|
|
@@ -9415,9 +9459,9 @@ function OperationEditor({
|
|
|
9415
9459
|
}
|
|
9416
9460
|
const isInvalid = (isDragging) => {
|
|
9417
9461
|
if (isDragging) {
|
|
9418
|
-
return
|
|
9462
|
+
return undefined;
|
|
9419
9463
|
}
|
|
9420
|
-
return isConflicting ? true :
|
|
9464
|
+
return isConflicting ? true : undefined;
|
|
9421
9465
|
};
|
|
9422
9466
|
return /* @__PURE__ */ React__default.default.createElement(dnd.Draggable, { draggableId: `operation-${index}`, index }, (provided, snapshot) => /* @__PURE__ */ React__default.default.createElement(
|
|
9423
9467
|
ui.InlineField,
|
|
@@ -9571,7 +9615,7 @@ function useOperationsHighlight(operations) {
|
|
|
9571
9615
|
} else {
|
|
9572
9616
|
newOps = operations.map((op, index) => {
|
|
9573
9617
|
var _a;
|
|
9574
|
-
return !isSameOp(op.id, (_a = prevOperations[index]) == null ?
|
|
9618
|
+
return !isSameOp(op.id, (_a = prevOperations[index]) == null ? undefined : _a.id);
|
|
9575
9619
|
});
|
|
9576
9620
|
}
|
|
9577
9621
|
return newOps;
|
|
@@ -9643,8 +9687,8 @@ function OperationListExplained({
|
|
|
9643
9687
|
"div",
|
|
9644
9688
|
{
|
|
9645
9689
|
key: index,
|
|
9646
|
-
onMouseEnter: () => onMouseEnter == null ?
|
|
9647
|
-
onMouseLeave: () => onMouseLeave == null ?
|
|
9690
|
+
onMouseEnter: () => onMouseEnter == null ? undefined : onMouseEnter(op, index),
|
|
9691
|
+
onMouseLeave: () => onMouseLeave == null ? undefined : onMouseLeave(op, index)
|
|
9648
9692
|
},
|
|
9649
9693
|
/* @__PURE__ */ React__default.default.createElement(
|
|
9650
9694
|
OperationExplainedBox,
|
|
@@ -9686,15 +9730,15 @@ const QueryBuilderHints = ({
|
|
|
9686
9730
|
const hints = React.useMemo(() => {
|
|
9687
9731
|
var _a;
|
|
9688
9732
|
const dataQuery = buildDataQueryFromQueryString(queryModeller.renderQuery(visualQuery));
|
|
9689
|
-
const hints2 = (_a = datasource.getQueryHints) == null ?
|
|
9733
|
+
const hints2 = (_a = datasource.getQueryHints) == null ? undefined : _a.call(datasource, dataQuery, (data == null ? undefined : data.series) || []).filter((hint) => {
|
|
9690
9734
|
var _a2;
|
|
9691
|
-
return (_a2 = hint.fix) == null ?
|
|
9735
|
+
return (_a2 = hint.fix) == null ? undefined : _a2.action;
|
|
9692
9736
|
});
|
|
9693
9737
|
return hints2 != null ? hints2 : [];
|
|
9694
9738
|
}, [datasource, visualQuery, data, queryModeller, buildDataQueryFromQueryString]);
|
|
9695
9739
|
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) => {
|
|
9696
9740
|
var _a, _b, _c, _d;
|
|
9697
|
-
return /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: `${hint.label} ${(_a = hint.fix) == null ?
|
|
9741
|
+
return /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: `${hint.label} ${(_a = hint.fix) == null ? undefined : _a.label}`, key: hint.type }, /* @__PURE__ */ React__default.default.createElement(
|
|
9698
9742
|
ui.Button,
|
|
9699
9743
|
{
|
|
9700
9744
|
onClick: () => {
|
|
@@ -9703,9 +9747,9 @@ const QueryBuilderHints = ({
|
|
|
9703
9747
|
hint: hint.type,
|
|
9704
9748
|
datasourceType: datasource.type
|
|
9705
9749
|
});
|
|
9706
|
-
if ((_a2 = hint == null ?
|
|
9750
|
+
if ((_a2 = hint == null ? undefined : hint.fix) == null ? undefined : _a2.action) {
|
|
9707
9751
|
const dataQuery = buildDataQueryFromQueryString(queryModeller.renderQuery(visualQuery));
|
|
9708
|
-
const newQuery = (_b2 = datasource.modifyQuery) == null ?
|
|
9752
|
+
const newQuery = (_b2 = datasource.modifyQuery) == null ? undefined : _b2.call(datasource, dataQuery, hint.fix.action);
|
|
9709
9753
|
if (newQuery) {
|
|
9710
9754
|
const newVisualQuery = buildVisualQueryFromString(
|
|
9711
9755
|
(_c2 = buildQueryStringFromDataQuery(newQuery)) != null ? _c2 : ""
|
|
@@ -9719,7 +9763,7 @@ const QueryBuilderHints = ({
|
|
|
9719
9763
|
className: styles.hint
|
|
9720
9764
|
},
|
|
9721
9765
|
"hint: ",
|
|
9722
|
-
((_b = hint.fix) == null ?
|
|
9766
|
+
((_b = hint.fix) == null ? undefined : _b.title) || ((_d = (_c = hint.fix) == null ? undefined : _c.action) == null ? undefined : _d.type.toLowerCase().replace("_", " "))
|
|
9723
9767
|
));
|
|
9724
9768
|
})));
|
|
9725
9769
|
};
|
|
@@ -9842,6 +9886,2988 @@ const convertUnits = (queryStats) => {
|
|
|
9842
9886
|
return text + suffix;
|
|
9843
9887
|
};
|
|
9844
9888
|
|
|
9889
|
+
var re = {exports: {}};
|
|
9890
|
+
|
|
9891
|
+
var constants;
|
|
9892
|
+
var hasRequiredConstants;
|
|
9893
|
+
|
|
9894
|
+
function requireConstants () {
|
|
9895
|
+
if (hasRequiredConstants) return constants;
|
|
9896
|
+
hasRequiredConstants = 1;
|
|
9897
|
+
|
|
9898
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
9899
|
+
// Not necessarily the package version of this code.
|
|
9900
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
|
9901
|
+
|
|
9902
|
+
const MAX_LENGTH = 256;
|
|
9903
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
9904
|
+
/* istanbul ignore next */ 9007199254740991;
|
|
9905
|
+
|
|
9906
|
+
// Max safe segment length for coercion.
|
|
9907
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
9908
|
+
|
|
9909
|
+
// Max safe length for a build identifier. The max length minus 6 characters for
|
|
9910
|
+
// the shortest version with a build 0.0.0+BUILD.
|
|
9911
|
+
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
9912
|
+
|
|
9913
|
+
const RELEASE_TYPES = [
|
|
9914
|
+
'major',
|
|
9915
|
+
'premajor',
|
|
9916
|
+
'minor',
|
|
9917
|
+
'preminor',
|
|
9918
|
+
'patch',
|
|
9919
|
+
'prepatch',
|
|
9920
|
+
'prerelease',
|
|
9921
|
+
];
|
|
9922
|
+
|
|
9923
|
+
constants = {
|
|
9924
|
+
MAX_LENGTH,
|
|
9925
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
9926
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
9927
|
+
MAX_SAFE_INTEGER,
|
|
9928
|
+
RELEASE_TYPES,
|
|
9929
|
+
SEMVER_SPEC_VERSION,
|
|
9930
|
+
FLAG_INCLUDE_PRERELEASE: 0b001,
|
|
9931
|
+
FLAG_LOOSE: 0b010,
|
|
9932
|
+
};
|
|
9933
|
+
return constants;
|
|
9934
|
+
}
|
|
9935
|
+
|
|
9936
|
+
var debug_1;
|
|
9937
|
+
var hasRequiredDebug;
|
|
9938
|
+
|
|
9939
|
+
function requireDebug () {
|
|
9940
|
+
if (hasRequiredDebug) return debug_1;
|
|
9941
|
+
hasRequiredDebug = 1;
|
|
9942
|
+
|
|
9943
|
+
const debug = (
|
|
9944
|
+
typeof process === 'object' &&
|
|
9945
|
+
process.env &&
|
|
9946
|
+
process.env.NODE_DEBUG &&
|
|
9947
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
|
9948
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
|
9949
|
+
: () => {};
|
|
9950
|
+
|
|
9951
|
+
debug_1 = debug;
|
|
9952
|
+
return debug_1;
|
|
9953
|
+
}
|
|
9954
|
+
|
|
9955
|
+
var hasRequiredRe;
|
|
9956
|
+
|
|
9957
|
+
function requireRe () {
|
|
9958
|
+
if (hasRequiredRe) return re.exports;
|
|
9959
|
+
hasRequiredRe = 1;
|
|
9960
|
+
(function (module, exports) {
|
|
9961
|
+
|
|
9962
|
+
const {
|
|
9963
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
9964
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
9965
|
+
MAX_LENGTH,
|
|
9966
|
+
} = requireConstants();
|
|
9967
|
+
const debug = requireDebug();
|
|
9968
|
+
exports = module.exports = {};
|
|
9969
|
+
|
|
9970
|
+
// The actual regexps go on exports.re
|
|
9971
|
+
const re = exports.re = [];
|
|
9972
|
+
const safeRe = exports.safeRe = [];
|
|
9973
|
+
const src = exports.src = [];
|
|
9974
|
+
const safeSrc = exports.safeSrc = [];
|
|
9975
|
+
const t = exports.t = {};
|
|
9976
|
+
let R = 0;
|
|
9977
|
+
|
|
9978
|
+
const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
|
|
9979
|
+
|
|
9980
|
+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
|
9981
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
9982
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
9983
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
9984
|
+
// future breaking change could export the safer regex only with a note that
|
|
9985
|
+
// all input should have extra whitespace removed.
|
|
9986
|
+
const safeRegexReplacements = [
|
|
9987
|
+
['\\s', 1],
|
|
9988
|
+
['\\d', MAX_LENGTH],
|
|
9989
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
|
|
9990
|
+
];
|
|
9991
|
+
|
|
9992
|
+
const makeSafeRegex = (value) => {
|
|
9993
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
9994
|
+
value = value
|
|
9995
|
+
.split(`${token}*`).join(`${token}{0,${max}}`)
|
|
9996
|
+
.split(`${token}+`).join(`${token}{1,${max}}`);
|
|
9997
|
+
}
|
|
9998
|
+
return value
|
|
9999
|
+
};
|
|
10000
|
+
|
|
10001
|
+
const createToken = (name, value, isGlobal) => {
|
|
10002
|
+
const safe = makeSafeRegex(value);
|
|
10003
|
+
const index = R++;
|
|
10004
|
+
debug(name, index, value);
|
|
10005
|
+
t[name] = index;
|
|
10006
|
+
src[index] = value;
|
|
10007
|
+
safeSrc[index] = safe;
|
|
10008
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
10009
|
+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
|
|
10010
|
+
};
|
|
10011
|
+
|
|
10012
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
10013
|
+
// validating, and parsing SemVer version strings.
|
|
10014
|
+
|
|
10015
|
+
// ## Numeric Identifier
|
|
10016
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
10017
|
+
|
|
10018
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
|
10019
|
+
createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
|
|
10020
|
+
|
|
10021
|
+
// ## Non-numeric Identifier
|
|
10022
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
10023
|
+
// more letters, digits, or hyphens.
|
|
10024
|
+
|
|
10025
|
+
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
10026
|
+
|
|
10027
|
+
// ## Main Version
|
|
10028
|
+
// Three dot-separated numeric identifiers.
|
|
10029
|
+
|
|
10030
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
10031
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
10032
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
|
10033
|
+
|
|
10034
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
10035
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
10036
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
10037
|
+
|
|
10038
|
+
// ## Pre-release Version Identifier
|
|
10039
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
10040
|
+
// Non-numberic identifiers include numberic identifiers but can be longer.
|
|
10041
|
+
// Therefore non-numberic identifiers must go first.
|
|
10042
|
+
|
|
10043
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
|
|
10044
|
+
}|${src[t.NUMERICIDENTIFIER]})`);
|
|
10045
|
+
|
|
10046
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
|
|
10047
|
+
}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
10048
|
+
|
|
10049
|
+
// ## Pre-release Version
|
|
10050
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
10051
|
+
// identifiers.
|
|
10052
|
+
|
|
10053
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
|
10054
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
10055
|
+
|
|
10056
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
10057
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
10058
|
+
|
|
10059
|
+
// ## Build Metadata Identifier
|
|
10060
|
+
// Any combination of digits, letters, or hyphens.
|
|
10061
|
+
|
|
10062
|
+
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
|
|
10063
|
+
|
|
10064
|
+
// ## Build Metadata
|
|
10065
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
10066
|
+
// identifiers.
|
|
10067
|
+
|
|
10068
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
|
10069
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
10070
|
+
|
|
10071
|
+
// ## Full Version String
|
|
10072
|
+
// A main version, followed optionally by a pre-release version and
|
|
10073
|
+
// build metadata.
|
|
10074
|
+
|
|
10075
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
10076
|
+
// the version string are capturing groups. The build metadata is not a
|
|
10077
|
+
// capturing group, because it should not ever be used in version
|
|
10078
|
+
// comparison.
|
|
10079
|
+
|
|
10080
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
|
10081
|
+
}${src[t.PRERELEASE]}?${
|
|
10082
|
+
src[t.BUILD]}?`);
|
|
10083
|
+
|
|
10084
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
|
10085
|
+
|
|
10086
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
10087
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
10088
|
+
// common in the npm registry.
|
|
10089
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
|
10090
|
+
}${src[t.PRERELEASELOOSE]}?${
|
|
10091
|
+
src[t.BUILD]}?`);
|
|
10092
|
+
|
|
10093
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
|
10094
|
+
|
|
10095
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
|
10096
|
+
|
|
10097
|
+
// Something like "2.*" or "1.2.x".
|
|
10098
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
10099
|
+
// Only the first item is strictly required.
|
|
10100
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
10101
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
10102
|
+
|
|
10103
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
|
10104
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
10105
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
10106
|
+
`(?:${src[t.PRERELEASE]})?${
|
|
10107
|
+
src[t.BUILD]}?` +
|
|
10108
|
+
`)?)?`);
|
|
10109
|
+
|
|
10110
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
10111
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
10112
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
10113
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
|
10114
|
+
src[t.BUILD]}?` +
|
|
10115
|
+
`)?)?`);
|
|
10116
|
+
|
|
10117
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
10118
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
10119
|
+
|
|
10120
|
+
// Coercion.
|
|
10121
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
10122
|
+
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
|
|
10123
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
10124
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
10125
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
10126
|
+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
10127
|
+
createToken('COERCEFULL', src[t.COERCEPLAIN] +
|
|
10128
|
+
`(?:${src[t.PRERELEASE]})?` +
|
|
10129
|
+
`(?:${src[t.BUILD]})?` +
|
|
10130
|
+
`(?:$|[^\\d])`);
|
|
10131
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
|
10132
|
+
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
|
10133
|
+
|
|
10134
|
+
// Tilde ranges.
|
|
10135
|
+
// Meaning is "reasonably at or greater than"
|
|
10136
|
+
createToken('LONETILDE', '(?:~>?)');
|
|
10137
|
+
|
|
10138
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
10139
|
+
exports.tildeTrimReplace = '$1~';
|
|
10140
|
+
|
|
10141
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
10142
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
10143
|
+
|
|
10144
|
+
// Caret ranges.
|
|
10145
|
+
// Meaning is "at least and backwards compatible with"
|
|
10146
|
+
createToken('LONECARET', '(?:\\^)');
|
|
10147
|
+
|
|
10148
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
10149
|
+
exports.caretTrimReplace = '$1^';
|
|
10150
|
+
|
|
10151
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
10152
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
10153
|
+
|
|
10154
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
10155
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
10156
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
10157
|
+
|
|
10158
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
10159
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
10160
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
|
10161
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
10162
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
|
10163
|
+
|
|
10164
|
+
// Something like `1.2.3 - 1.2.4`
|
|
10165
|
+
// Note that these all use the loose form, because they'll be
|
|
10166
|
+
// checked against either the strict or loose comparator form
|
|
10167
|
+
// later.
|
|
10168
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
|
10169
|
+
`\\s+-\\s+` +
|
|
10170
|
+
`(${src[t.XRANGEPLAIN]})` +
|
|
10171
|
+
`\\s*$`);
|
|
10172
|
+
|
|
10173
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
|
10174
|
+
`\\s+-\\s+` +
|
|
10175
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
|
10176
|
+
`\\s*$`);
|
|
10177
|
+
|
|
10178
|
+
// Star ranges basically just allow anything at all.
|
|
10179
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
|
10180
|
+
// >=0.0.0 is like a star
|
|
10181
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
|
10182
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
|
10183
|
+
} (re, re.exports));
|
|
10184
|
+
return re.exports;
|
|
10185
|
+
}
|
|
10186
|
+
|
|
10187
|
+
var parseOptions_1;
|
|
10188
|
+
var hasRequiredParseOptions;
|
|
10189
|
+
|
|
10190
|
+
function requireParseOptions () {
|
|
10191
|
+
if (hasRequiredParseOptions) return parseOptions_1;
|
|
10192
|
+
hasRequiredParseOptions = 1;
|
|
10193
|
+
|
|
10194
|
+
// parse out just the options we care about
|
|
10195
|
+
const looseOption = Object.freeze({ loose: true });
|
|
10196
|
+
const emptyOpts = Object.freeze({ });
|
|
10197
|
+
const parseOptions = options => {
|
|
10198
|
+
if (!options) {
|
|
10199
|
+
return emptyOpts
|
|
10200
|
+
}
|
|
10201
|
+
|
|
10202
|
+
if (typeof options !== 'object') {
|
|
10203
|
+
return looseOption
|
|
10204
|
+
}
|
|
10205
|
+
|
|
10206
|
+
return options
|
|
10207
|
+
};
|
|
10208
|
+
parseOptions_1 = parseOptions;
|
|
10209
|
+
return parseOptions_1;
|
|
10210
|
+
}
|
|
10211
|
+
|
|
10212
|
+
var identifiers;
|
|
10213
|
+
var hasRequiredIdentifiers;
|
|
10214
|
+
|
|
10215
|
+
function requireIdentifiers () {
|
|
10216
|
+
if (hasRequiredIdentifiers) return identifiers;
|
|
10217
|
+
hasRequiredIdentifiers = 1;
|
|
10218
|
+
|
|
10219
|
+
const numeric = /^[0-9]+$/;
|
|
10220
|
+
const compareIdentifiers = (a, b) => {
|
|
10221
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
10222
|
+
return a === b ? 0 : a < b ? -1 : 1
|
|
10223
|
+
}
|
|
10224
|
+
|
|
10225
|
+
const anum = numeric.test(a);
|
|
10226
|
+
const bnum = numeric.test(b);
|
|
10227
|
+
|
|
10228
|
+
if (anum && bnum) {
|
|
10229
|
+
a = +a;
|
|
10230
|
+
b = +b;
|
|
10231
|
+
}
|
|
10232
|
+
|
|
10233
|
+
return a === b ? 0
|
|
10234
|
+
: (anum && !bnum) ? -1
|
|
10235
|
+
: (bnum && !anum) ? 1
|
|
10236
|
+
: a < b ? -1
|
|
10237
|
+
: 1
|
|
10238
|
+
};
|
|
10239
|
+
|
|
10240
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
10241
|
+
|
|
10242
|
+
identifiers = {
|
|
10243
|
+
compareIdentifiers,
|
|
10244
|
+
rcompareIdentifiers,
|
|
10245
|
+
};
|
|
10246
|
+
return identifiers;
|
|
10247
|
+
}
|
|
10248
|
+
|
|
10249
|
+
var semver$1;
|
|
10250
|
+
var hasRequiredSemver$1;
|
|
10251
|
+
|
|
10252
|
+
function requireSemver$1 () {
|
|
10253
|
+
if (hasRequiredSemver$1) return semver$1;
|
|
10254
|
+
hasRequiredSemver$1 = 1;
|
|
10255
|
+
|
|
10256
|
+
const debug = requireDebug();
|
|
10257
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = requireConstants();
|
|
10258
|
+
const { safeRe: re, t } = requireRe();
|
|
10259
|
+
|
|
10260
|
+
const parseOptions = requireParseOptions();
|
|
10261
|
+
const { compareIdentifiers } = requireIdentifiers();
|
|
10262
|
+
class SemVer {
|
|
10263
|
+
constructor (version, options) {
|
|
10264
|
+
options = parseOptions(options);
|
|
10265
|
+
|
|
10266
|
+
if (version instanceof SemVer) {
|
|
10267
|
+
if (version.loose === !!options.loose &&
|
|
10268
|
+
version.includePrerelease === !!options.includePrerelease) {
|
|
10269
|
+
return version
|
|
10270
|
+
} else {
|
|
10271
|
+
version = version.version;
|
|
10272
|
+
}
|
|
10273
|
+
} else if (typeof version !== 'string') {
|
|
10274
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
|
|
10275
|
+
}
|
|
10276
|
+
|
|
10277
|
+
if (version.length > MAX_LENGTH) {
|
|
10278
|
+
throw new TypeError(
|
|
10279
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
10280
|
+
)
|
|
10281
|
+
}
|
|
10282
|
+
|
|
10283
|
+
debug('SemVer', version, options);
|
|
10284
|
+
this.options = options;
|
|
10285
|
+
this.loose = !!options.loose;
|
|
10286
|
+
// this isn't actually relevant for versions, but keep it so that we
|
|
10287
|
+
// don't run into trouble passing this.options around.
|
|
10288
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
10289
|
+
|
|
10290
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
10291
|
+
|
|
10292
|
+
if (!m) {
|
|
10293
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
|
10294
|
+
}
|
|
10295
|
+
|
|
10296
|
+
this.raw = version;
|
|
10297
|
+
|
|
10298
|
+
// these are actually numbers
|
|
10299
|
+
this.major = +m[1];
|
|
10300
|
+
this.minor = +m[2];
|
|
10301
|
+
this.patch = +m[3];
|
|
10302
|
+
|
|
10303
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
10304
|
+
throw new TypeError('Invalid major version')
|
|
10305
|
+
}
|
|
10306
|
+
|
|
10307
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
10308
|
+
throw new TypeError('Invalid minor version')
|
|
10309
|
+
}
|
|
10310
|
+
|
|
10311
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
10312
|
+
throw new TypeError('Invalid patch version')
|
|
10313
|
+
}
|
|
10314
|
+
|
|
10315
|
+
// numberify any prerelease numeric ids
|
|
10316
|
+
if (!m[4]) {
|
|
10317
|
+
this.prerelease = [];
|
|
10318
|
+
} else {
|
|
10319
|
+
this.prerelease = m[4].split('.').map((id) => {
|
|
10320
|
+
if (/^[0-9]+$/.test(id)) {
|
|
10321
|
+
const num = +id;
|
|
10322
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
10323
|
+
return num
|
|
10324
|
+
}
|
|
10325
|
+
}
|
|
10326
|
+
return id
|
|
10327
|
+
});
|
|
10328
|
+
}
|
|
10329
|
+
|
|
10330
|
+
this.build = m[5] ? m[5].split('.') : [];
|
|
10331
|
+
this.format();
|
|
10332
|
+
}
|
|
10333
|
+
|
|
10334
|
+
format () {
|
|
10335
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
10336
|
+
if (this.prerelease.length) {
|
|
10337
|
+
this.version += `-${this.prerelease.join('.')}`;
|
|
10338
|
+
}
|
|
10339
|
+
return this.version
|
|
10340
|
+
}
|
|
10341
|
+
|
|
10342
|
+
toString () {
|
|
10343
|
+
return this.version
|
|
10344
|
+
}
|
|
10345
|
+
|
|
10346
|
+
compare (other) {
|
|
10347
|
+
debug('SemVer.compare', this.version, this.options, other);
|
|
10348
|
+
if (!(other instanceof SemVer)) {
|
|
10349
|
+
if (typeof other === 'string' && other === this.version) {
|
|
10350
|
+
return 0
|
|
10351
|
+
}
|
|
10352
|
+
other = new SemVer(other, this.options);
|
|
10353
|
+
}
|
|
10354
|
+
|
|
10355
|
+
if (other.version === this.version) {
|
|
10356
|
+
return 0
|
|
10357
|
+
}
|
|
10358
|
+
|
|
10359
|
+
return this.compareMain(other) || this.comparePre(other)
|
|
10360
|
+
}
|
|
10361
|
+
|
|
10362
|
+
compareMain (other) {
|
|
10363
|
+
if (!(other instanceof SemVer)) {
|
|
10364
|
+
other = new SemVer(other, this.options);
|
|
10365
|
+
}
|
|
10366
|
+
|
|
10367
|
+
if (this.major < other.major) {
|
|
10368
|
+
return -1
|
|
10369
|
+
}
|
|
10370
|
+
if (this.major > other.major) {
|
|
10371
|
+
return 1
|
|
10372
|
+
}
|
|
10373
|
+
if (this.minor < other.minor) {
|
|
10374
|
+
return -1
|
|
10375
|
+
}
|
|
10376
|
+
if (this.minor > other.minor) {
|
|
10377
|
+
return 1
|
|
10378
|
+
}
|
|
10379
|
+
if (this.patch < other.patch) {
|
|
10380
|
+
return -1
|
|
10381
|
+
}
|
|
10382
|
+
if (this.patch > other.patch) {
|
|
10383
|
+
return 1
|
|
10384
|
+
}
|
|
10385
|
+
return 0
|
|
10386
|
+
}
|
|
10387
|
+
|
|
10388
|
+
comparePre (other) {
|
|
10389
|
+
if (!(other instanceof SemVer)) {
|
|
10390
|
+
other = new SemVer(other, this.options);
|
|
10391
|
+
}
|
|
10392
|
+
|
|
10393
|
+
// NOT having a prerelease is > having one
|
|
10394
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
10395
|
+
return -1
|
|
10396
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
10397
|
+
return 1
|
|
10398
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
10399
|
+
return 0
|
|
10400
|
+
}
|
|
10401
|
+
|
|
10402
|
+
let i = 0;
|
|
10403
|
+
do {
|
|
10404
|
+
const a = this.prerelease[i];
|
|
10405
|
+
const b = other.prerelease[i];
|
|
10406
|
+
debug('prerelease compare', i, a, b);
|
|
10407
|
+
if (a === undefined && b === undefined) {
|
|
10408
|
+
return 0
|
|
10409
|
+
} else if (b === undefined) {
|
|
10410
|
+
return 1
|
|
10411
|
+
} else if (a === undefined) {
|
|
10412
|
+
return -1
|
|
10413
|
+
} else if (a === b) {
|
|
10414
|
+
continue
|
|
10415
|
+
} else {
|
|
10416
|
+
return compareIdentifiers(a, b)
|
|
10417
|
+
}
|
|
10418
|
+
} while (++i)
|
|
10419
|
+
}
|
|
10420
|
+
|
|
10421
|
+
compareBuild (other) {
|
|
10422
|
+
if (!(other instanceof SemVer)) {
|
|
10423
|
+
other = new SemVer(other, this.options);
|
|
10424
|
+
}
|
|
10425
|
+
|
|
10426
|
+
let i = 0;
|
|
10427
|
+
do {
|
|
10428
|
+
const a = this.build[i];
|
|
10429
|
+
const b = other.build[i];
|
|
10430
|
+
debug('build compare', i, a, b);
|
|
10431
|
+
if (a === undefined && b === undefined) {
|
|
10432
|
+
return 0
|
|
10433
|
+
} else if (b === undefined) {
|
|
10434
|
+
return 1
|
|
10435
|
+
} else if (a === undefined) {
|
|
10436
|
+
return -1
|
|
10437
|
+
} else if (a === b) {
|
|
10438
|
+
continue
|
|
10439
|
+
} else {
|
|
10440
|
+
return compareIdentifiers(a, b)
|
|
10441
|
+
}
|
|
10442
|
+
} while (++i)
|
|
10443
|
+
}
|
|
10444
|
+
|
|
10445
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
10446
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
10447
|
+
inc (release, identifier, identifierBase) {
|
|
10448
|
+
if (release.startsWith('pre')) {
|
|
10449
|
+
if (!identifier && identifierBase === false) {
|
|
10450
|
+
throw new Error('invalid increment argument: identifier is empty')
|
|
10451
|
+
}
|
|
10452
|
+
// Avoid an invalid semver results
|
|
10453
|
+
if (identifier) {
|
|
10454
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
10455
|
+
if (!match || match[1] !== identifier) {
|
|
10456
|
+
throw new Error(`invalid identifier: ${identifier}`)
|
|
10457
|
+
}
|
|
10458
|
+
}
|
|
10459
|
+
}
|
|
10460
|
+
|
|
10461
|
+
switch (release) {
|
|
10462
|
+
case 'premajor':
|
|
10463
|
+
this.prerelease.length = 0;
|
|
10464
|
+
this.patch = 0;
|
|
10465
|
+
this.minor = 0;
|
|
10466
|
+
this.major++;
|
|
10467
|
+
this.inc('pre', identifier, identifierBase);
|
|
10468
|
+
break
|
|
10469
|
+
case 'preminor':
|
|
10470
|
+
this.prerelease.length = 0;
|
|
10471
|
+
this.patch = 0;
|
|
10472
|
+
this.minor++;
|
|
10473
|
+
this.inc('pre', identifier, identifierBase);
|
|
10474
|
+
break
|
|
10475
|
+
case 'prepatch':
|
|
10476
|
+
// If this is already a prerelease, it will bump to the next version
|
|
10477
|
+
// drop any prereleases that might already exist, since they are not
|
|
10478
|
+
// relevant at this point.
|
|
10479
|
+
this.prerelease.length = 0;
|
|
10480
|
+
this.inc('patch', identifier, identifierBase);
|
|
10481
|
+
this.inc('pre', identifier, identifierBase);
|
|
10482
|
+
break
|
|
10483
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
10484
|
+
// prepatch.
|
|
10485
|
+
case 'prerelease':
|
|
10486
|
+
if (this.prerelease.length === 0) {
|
|
10487
|
+
this.inc('patch', identifier, identifierBase);
|
|
10488
|
+
}
|
|
10489
|
+
this.inc('pre', identifier, identifierBase);
|
|
10490
|
+
break
|
|
10491
|
+
case 'release':
|
|
10492
|
+
if (this.prerelease.length === 0) {
|
|
10493
|
+
throw new Error(`version ${this.raw} is not a prerelease`)
|
|
10494
|
+
}
|
|
10495
|
+
this.prerelease.length = 0;
|
|
10496
|
+
break
|
|
10497
|
+
|
|
10498
|
+
case 'major':
|
|
10499
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
10500
|
+
// Otherwise increment major.
|
|
10501
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
10502
|
+
// 1.1.0 bumps to 2.0.0
|
|
10503
|
+
if (
|
|
10504
|
+
this.minor !== 0 ||
|
|
10505
|
+
this.patch !== 0 ||
|
|
10506
|
+
this.prerelease.length === 0
|
|
10507
|
+
) {
|
|
10508
|
+
this.major++;
|
|
10509
|
+
}
|
|
10510
|
+
this.minor = 0;
|
|
10511
|
+
this.patch = 0;
|
|
10512
|
+
this.prerelease = [];
|
|
10513
|
+
break
|
|
10514
|
+
case 'minor':
|
|
10515
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
10516
|
+
// Otherwise increment minor.
|
|
10517
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
10518
|
+
// 1.2.1 bumps to 1.3.0
|
|
10519
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
10520
|
+
this.minor++;
|
|
10521
|
+
}
|
|
10522
|
+
this.patch = 0;
|
|
10523
|
+
this.prerelease = [];
|
|
10524
|
+
break
|
|
10525
|
+
case 'patch':
|
|
10526
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
10527
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
10528
|
+
// 1.2.0-5 patches to 1.2.0
|
|
10529
|
+
// 1.2.0 patches to 1.2.1
|
|
10530
|
+
if (this.prerelease.length === 0) {
|
|
10531
|
+
this.patch++;
|
|
10532
|
+
}
|
|
10533
|
+
this.prerelease = [];
|
|
10534
|
+
break
|
|
10535
|
+
// This probably shouldn't be used publicly.
|
|
10536
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
10537
|
+
case 'pre': {
|
|
10538
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
10539
|
+
|
|
10540
|
+
if (this.prerelease.length === 0) {
|
|
10541
|
+
this.prerelease = [base];
|
|
10542
|
+
} else {
|
|
10543
|
+
let i = this.prerelease.length;
|
|
10544
|
+
while (--i >= 0) {
|
|
10545
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
10546
|
+
this.prerelease[i]++;
|
|
10547
|
+
i = -2;
|
|
10548
|
+
}
|
|
10549
|
+
}
|
|
10550
|
+
if (i === -1) {
|
|
10551
|
+
// didn't increment anything
|
|
10552
|
+
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
|
10553
|
+
throw new Error('invalid increment argument: identifier already exists')
|
|
10554
|
+
}
|
|
10555
|
+
this.prerelease.push(base);
|
|
10556
|
+
}
|
|
10557
|
+
}
|
|
10558
|
+
if (identifier) {
|
|
10559
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
10560
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
10561
|
+
let prerelease = [identifier, base];
|
|
10562
|
+
if (identifierBase === false) {
|
|
10563
|
+
prerelease = [identifier];
|
|
10564
|
+
}
|
|
10565
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
10566
|
+
if (isNaN(this.prerelease[1])) {
|
|
10567
|
+
this.prerelease = prerelease;
|
|
10568
|
+
}
|
|
10569
|
+
} else {
|
|
10570
|
+
this.prerelease = prerelease;
|
|
10571
|
+
}
|
|
10572
|
+
}
|
|
10573
|
+
break
|
|
10574
|
+
}
|
|
10575
|
+
default:
|
|
10576
|
+
throw new Error(`invalid increment argument: ${release}`)
|
|
10577
|
+
}
|
|
10578
|
+
this.raw = this.format();
|
|
10579
|
+
if (this.build.length) {
|
|
10580
|
+
this.raw += `+${this.build.join('.')}`;
|
|
10581
|
+
}
|
|
10582
|
+
return this
|
|
10583
|
+
}
|
|
10584
|
+
}
|
|
10585
|
+
|
|
10586
|
+
semver$1 = SemVer;
|
|
10587
|
+
return semver$1;
|
|
10588
|
+
}
|
|
10589
|
+
|
|
10590
|
+
var parse_1;
|
|
10591
|
+
var hasRequiredParse;
|
|
10592
|
+
|
|
10593
|
+
function requireParse () {
|
|
10594
|
+
if (hasRequiredParse) return parse_1;
|
|
10595
|
+
hasRequiredParse = 1;
|
|
10596
|
+
|
|
10597
|
+
const SemVer = requireSemver$1();
|
|
10598
|
+
const parse = (version, options, throwErrors = false) => {
|
|
10599
|
+
if (version instanceof SemVer) {
|
|
10600
|
+
return version
|
|
10601
|
+
}
|
|
10602
|
+
try {
|
|
10603
|
+
return new SemVer(version, options)
|
|
10604
|
+
} catch (er) {
|
|
10605
|
+
if (!throwErrors) {
|
|
10606
|
+
return null
|
|
10607
|
+
}
|
|
10608
|
+
throw er
|
|
10609
|
+
}
|
|
10610
|
+
};
|
|
10611
|
+
|
|
10612
|
+
parse_1 = parse;
|
|
10613
|
+
return parse_1;
|
|
10614
|
+
}
|
|
10615
|
+
|
|
10616
|
+
var valid_1;
|
|
10617
|
+
var hasRequiredValid$1;
|
|
10618
|
+
|
|
10619
|
+
function requireValid$1 () {
|
|
10620
|
+
if (hasRequiredValid$1) return valid_1;
|
|
10621
|
+
hasRequiredValid$1 = 1;
|
|
10622
|
+
|
|
10623
|
+
const parse = requireParse();
|
|
10624
|
+
const valid = (version, options) => {
|
|
10625
|
+
const v = parse(version, options);
|
|
10626
|
+
return v ? v.version : null
|
|
10627
|
+
};
|
|
10628
|
+
valid_1 = valid;
|
|
10629
|
+
return valid_1;
|
|
10630
|
+
}
|
|
10631
|
+
|
|
10632
|
+
var clean_1;
|
|
10633
|
+
var hasRequiredClean;
|
|
10634
|
+
|
|
10635
|
+
function requireClean () {
|
|
10636
|
+
if (hasRequiredClean) return clean_1;
|
|
10637
|
+
hasRequiredClean = 1;
|
|
10638
|
+
|
|
10639
|
+
const parse = requireParse();
|
|
10640
|
+
const clean = (version, options) => {
|
|
10641
|
+
const s = parse(version.trim().replace(/^[=v]+/, ''), options);
|
|
10642
|
+
return s ? s.version : null
|
|
10643
|
+
};
|
|
10644
|
+
clean_1 = clean;
|
|
10645
|
+
return clean_1;
|
|
10646
|
+
}
|
|
10647
|
+
|
|
10648
|
+
var inc_1;
|
|
10649
|
+
var hasRequiredInc;
|
|
10650
|
+
|
|
10651
|
+
function requireInc () {
|
|
10652
|
+
if (hasRequiredInc) return inc_1;
|
|
10653
|
+
hasRequiredInc = 1;
|
|
10654
|
+
|
|
10655
|
+
const SemVer = requireSemver$1();
|
|
10656
|
+
|
|
10657
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
10658
|
+
if (typeof (options) === 'string') {
|
|
10659
|
+
identifierBase = identifier;
|
|
10660
|
+
identifier = options;
|
|
10661
|
+
options = undefined;
|
|
10662
|
+
}
|
|
10663
|
+
|
|
10664
|
+
try {
|
|
10665
|
+
return new SemVer(
|
|
10666
|
+
version instanceof SemVer ? version.version : version,
|
|
10667
|
+
options
|
|
10668
|
+
).inc(release, identifier, identifierBase).version
|
|
10669
|
+
} catch (er) {
|
|
10670
|
+
return null
|
|
10671
|
+
}
|
|
10672
|
+
};
|
|
10673
|
+
inc_1 = inc;
|
|
10674
|
+
return inc_1;
|
|
10675
|
+
}
|
|
10676
|
+
|
|
10677
|
+
var diff_1;
|
|
10678
|
+
var hasRequiredDiff;
|
|
10679
|
+
|
|
10680
|
+
function requireDiff () {
|
|
10681
|
+
if (hasRequiredDiff) return diff_1;
|
|
10682
|
+
hasRequiredDiff = 1;
|
|
10683
|
+
|
|
10684
|
+
const parse = requireParse();
|
|
10685
|
+
|
|
10686
|
+
const diff = (version1, version2) => {
|
|
10687
|
+
const v1 = parse(version1, null, true);
|
|
10688
|
+
const v2 = parse(version2, null, true);
|
|
10689
|
+
const comparison = v1.compare(v2);
|
|
10690
|
+
|
|
10691
|
+
if (comparison === 0) {
|
|
10692
|
+
return null
|
|
10693
|
+
}
|
|
10694
|
+
|
|
10695
|
+
const v1Higher = comparison > 0;
|
|
10696
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
10697
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
10698
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
10699
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
10700
|
+
|
|
10701
|
+
if (lowHasPre && !highHasPre) {
|
|
10702
|
+
// Going from prerelease -> no prerelease requires some special casing
|
|
10703
|
+
|
|
10704
|
+
// If the low version has only a major, then it will always be a major
|
|
10705
|
+
// Some examples:
|
|
10706
|
+
// 1.0.0-1 -> 1.0.0
|
|
10707
|
+
// 1.0.0-1 -> 1.1.1
|
|
10708
|
+
// 1.0.0-1 -> 2.0.0
|
|
10709
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
10710
|
+
return 'major'
|
|
10711
|
+
}
|
|
10712
|
+
|
|
10713
|
+
// If the main part has no difference
|
|
10714
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
10715
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
10716
|
+
return 'minor'
|
|
10717
|
+
}
|
|
10718
|
+
return 'patch'
|
|
10719
|
+
}
|
|
10720
|
+
}
|
|
10721
|
+
|
|
10722
|
+
// add the `pre` prefix if we are going to a prerelease version
|
|
10723
|
+
const prefix = highHasPre ? 'pre' : '';
|
|
10724
|
+
|
|
10725
|
+
if (v1.major !== v2.major) {
|
|
10726
|
+
return prefix + 'major'
|
|
10727
|
+
}
|
|
10728
|
+
|
|
10729
|
+
if (v1.minor !== v2.minor) {
|
|
10730
|
+
return prefix + 'minor'
|
|
10731
|
+
}
|
|
10732
|
+
|
|
10733
|
+
if (v1.patch !== v2.patch) {
|
|
10734
|
+
return prefix + 'patch'
|
|
10735
|
+
}
|
|
10736
|
+
|
|
10737
|
+
// high and low are preleases
|
|
10738
|
+
return 'prerelease'
|
|
10739
|
+
};
|
|
10740
|
+
|
|
10741
|
+
diff_1 = diff;
|
|
10742
|
+
return diff_1;
|
|
10743
|
+
}
|
|
10744
|
+
|
|
10745
|
+
var major_1;
|
|
10746
|
+
var hasRequiredMajor;
|
|
10747
|
+
|
|
10748
|
+
function requireMajor () {
|
|
10749
|
+
if (hasRequiredMajor) return major_1;
|
|
10750
|
+
hasRequiredMajor = 1;
|
|
10751
|
+
|
|
10752
|
+
const SemVer = requireSemver$1();
|
|
10753
|
+
const major = (a, loose) => new SemVer(a, loose).major;
|
|
10754
|
+
major_1 = major;
|
|
10755
|
+
return major_1;
|
|
10756
|
+
}
|
|
10757
|
+
|
|
10758
|
+
var minor_1;
|
|
10759
|
+
var hasRequiredMinor;
|
|
10760
|
+
|
|
10761
|
+
function requireMinor () {
|
|
10762
|
+
if (hasRequiredMinor) return minor_1;
|
|
10763
|
+
hasRequiredMinor = 1;
|
|
10764
|
+
|
|
10765
|
+
const SemVer = requireSemver$1();
|
|
10766
|
+
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
10767
|
+
minor_1 = minor;
|
|
10768
|
+
return minor_1;
|
|
10769
|
+
}
|
|
10770
|
+
|
|
10771
|
+
var patch_1;
|
|
10772
|
+
var hasRequiredPatch;
|
|
10773
|
+
|
|
10774
|
+
function requirePatch () {
|
|
10775
|
+
if (hasRequiredPatch) return patch_1;
|
|
10776
|
+
hasRequiredPatch = 1;
|
|
10777
|
+
|
|
10778
|
+
const SemVer = requireSemver$1();
|
|
10779
|
+
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
10780
|
+
patch_1 = patch;
|
|
10781
|
+
return patch_1;
|
|
10782
|
+
}
|
|
10783
|
+
|
|
10784
|
+
var prerelease_1;
|
|
10785
|
+
var hasRequiredPrerelease;
|
|
10786
|
+
|
|
10787
|
+
function requirePrerelease () {
|
|
10788
|
+
if (hasRequiredPrerelease) return prerelease_1;
|
|
10789
|
+
hasRequiredPrerelease = 1;
|
|
10790
|
+
|
|
10791
|
+
const parse = requireParse();
|
|
10792
|
+
const prerelease = (version, options) => {
|
|
10793
|
+
const parsed = parse(version, options);
|
|
10794
|
+
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
10795
|
+
};
|
|
10796
|
+
prerelease_1 = prerelease;
|
|
10797
|
+
return prerelease_1;
|
|
10798
|
+
}
|
|
10799
|
+
|
|
10800
|
+
var compare_1;
|
|
10801
|
+
var hasRequiredCompare;
|
|
10802
|
+
|
|
10803
|
+
function requireCompare () {
|
|
10804
|
+
if (hasRequiredCompare) return compare_1;
|
|
10805
|
+
hasRequiredCompare = 1;
|
|
10806
|
+
|
|
10807
|
+
const SemVer = requireSemver$1();
|
|
10808
|
+
const compare = (a, b, loose) =>
|
|
10809
|
+
new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
10810
|
+
|
|
10811
|
+
compare_1 = compare;
|
|
10812
|
+
return compare_1;
|
|
10813
|
+
}
|
|
10814
|
+
|
|
10815
|
+
var rcompare_1;
|
|
10816
|
+
var hasRequiredRcompare;
|
|
10817
|
+
|
|
10818
|
+
function requireRcompare () {
|
|
10819
|
+
if (hasRequiredRcompare) return rcompare_1;
|
|
10820
|
+
hasRequiredRcompare = 1;
|
|
10821
|
+
|
|
10822
|
+
const compare = requireCompare();
|
|
10823
|
+
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
10824
|
+
rcompare_1 = rcompare;
|
|
10825
|
+
return rcompare_1;
|
|
10826
|
+
}
|
|
10827
|
+
|
|
10828
|
+
var compareLoose_1;
|
|
10829
|
+
var hasRequiredCompareLoose;
|
|
10830
|
+
|
|
10831
|
+
function requireCompareLoose () {
|
|
10832
|
+
if (hasRequiredCompareLoose) return compareLoose_1;
|
|
10833
|
+
hasRequiredCompareLoose = 1;
|
|
10834
|
+
|
|
10835
|
+
const compare = requireCompare();
|
|
10836
|
+
const compareLoose = (a, b) => compare(a, b, true);
|
|
10837
|
+
compareLoose_1 = compareLoose;
|
|
10838
|
+
return compareLoose_1;
|
|
10839
|
+
}
|
|
10840
|
+
|
|
10841
|
+
var compareBuild_1;
|
|
10842
|
+
var hasRequiredCompareBuild;
|
|
10843
|
+
|
|
10844
|
+
function requireCompareBuild () {
|
|
10845
|
+
if (hasRequiredCompareBuild) return compareBuild_1;
|
|
10846
|
+
hasRequiredCompareBuild = 1;
|
|
10847
|
+
|
|
10848
|
+
const SemVer = requireSemver$1();
|
|
10849
|
+
const compareBuild = (a, b, loose) => {
|
|
10850
|
+
const versionA = new SemVer(a, loose);
|
|
10851
|
+
const versionB = new SemVer(b, loose);
|
|
10852
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
10853
|
+
};
|
|
10854
|
+
compareBuild_1 = compareBuild;
|
|
10855
|
+
return compareBuild_1;
|
|
10856
|
+
}
|
|
10857
|
+
|
|
10858
|
+
var sort_1;
|
|
10859
|
+
var hasRequiredSort;
|
|
10860
|
+
|
|
10861
|
+
function requireSort () {
|
|
10862
|
+
if (hasRequiredSort) return sort_1;
|
|
10863
|
+
hasRequiredSort = 1;
|
|
10864
|
+
|
|
10865
|
+
const compareBuild = requireCompareBuild();
|
|
10866
|
+
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
10867
|
+
sort_1 = sort;
|
|
10868
|
+
return sort_1;
|
|
10869
|
+
}
|
|
10870
|
+
|
|
10871
|
+
var rsort_1;
|
|
10872
|
+
var hasRequiredRsort;
|
|
10873
|
+
|
|
10874
|
+
function requireRsort () {
|
|
10875
|
+
if (hasRequiredRsort) return rsort_1;
|
|
10876
|
+
hasRequiredRsort = 1;
|
|
10877
|
+
|
|
10878
|
+
const compareBuild = requireCompareBuild();
|
|
10879
|
+
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
10880
|
+
rsort_1 = rsort;
|
|
10881
|
+
return rsort_1;
|
|
10882
|
+
}
|
|
10883
|
+
|
|
10884
|
+
var gt_1;
|
|
10885
|
+
var hasRequiredGt;
|
|
10886
|
+
|
|
10887
|
+
function requireGt () {
|
|
10888
|
+
if (hasRequiredGt) return gt_1;
|
|
10889
|
+
hasRequiredGt = 1;
|
|
10890
|
+
|
|
10891
|
+
const compare = requireCompare();
|
|
10892
|
+
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
10893
|
+
gt_1 = gt;
|
|
10894
|
+
return gt_1;
|
|
10895
|
+
}
|
|
10896
|
+
|
|
10897
|
+
var lt_1;
|
|
10898
|
+
var hasRequiredLt;
|
|
10899
|
+
|
|
10900
|
+
function requireLt () {
|
|
10901
|
+
if (hasRequiredLt) return lt_1;
|
|
10902
|
+
hasRequiredLt = 1;
|
|
10903
|
+
|
|
10904
|
+
const compare = requireCompare();
|
|
10905
|
+
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
10906
|
+
lt_1 = lt;
|
|
10907
|
+
return lt_1;
|
|
10908
|
+
}
|
|
10909
|
+
|
|
10910
|
+
var eq_1;
|
|
10911
|
+
var hasRequiredEq;
|
|
10912
|
+
|
|
10913
|
+
function requireEq () {
|
|
10914
|
+
if (hasRequiredEq) return eq_1;
|
|
10915
|
+
hasRequiredEq = 1;
|
|
10916
|
+
|
|
10917
|
+
const compare = requireCompare();
|
|
10918
|
+
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
10919
|
+
eq_1 = eq;
|
|
10920
|
+
return eq_1;
|
|
10921
|
+
}
|
|
10922
|
+
|
|
10923
|
+
var neq_1;
|
|
10924
|
+
var hasRequiredNeq;
|
|
10925
|
+
|
|
10926
|
+
function requireNeq () {
|
|
10927
|
+
if (hasRequiredNeq) return neq_1;
|
|
10928
|
+
hasRequiredNeq = 1;
|
|
10929
|
+
|
|
10930
|
+
const compare = requireCompare();
|
|
10931
|
+
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
10932
|
+
neq_1 = neq;
|
|
10933
|
+
return neq_1;
|
|
10934
|
+
}
|
|
10935
|
+
|
|
10936
|
+
var gte_1;
|
|
10937
|
+
var hasRequiredGte;
|
|
10938
|
+
|
|
10939
|
+
function requireGte () {
|
|
10940
|
+
if (hasRequiredGte) return gte_1;
|
|
10941
|
+
hasRequiredGte = 1;
|
|
10942
|
+
|
|
10943
|
+
const compare = requireCompare();
|
|
10944
|
+
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
10945
|
+
gte_1 = gte;
|
|
10946
|
+
return gte_1;
|
|
10947
|
+
}
|
|
10948
|
+
|
|
10949
|
+
var lte_1;
|
|
10950
|
+
var hasRequiredLte;
|
|
10951
|
+
|
|
10952
|
+
function requireLte () {
|
|
10953
|
+
if (hasRequiredLte) return lte_1;
|
|
10954
|
+
hasRequiredLte = 1;
|
|
10955
|
+
|
|
10956
|
+
const compare = requireCompare();
|
|
10957
|
+
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
10958
|
+
lte_1 = lte;
|
|
10959
|
+
return lte_1;
|
|
10960
|
+
}
|
|
10961
|
+
|
|
10962
|
+
var cmp_1;
|
|
10963
|
+
var hasRequiredCmp;
|
|
10964
|
+
|
|
10965
|
+
function requireCmp () {
|
|
10966
|
+
if (hasRequiredCmp) return cmp_1;
|
|
10967
|
+
hasRequiredCmp = 1;
|
|
10968
|
+
|
|
10969
|
+
const eq = requireEq();
|
|
10970
|
+
const neq = requireNeq();
|
|
10971
|
+
const gt = requireGt();
|
|
10972
|
+
const gte = requireGte();
|
|
10973
|
+
const lt = requireLt();
|
|
10974
|
+
const lte = requireLte();
|
|
10975
|
+
|
|
10976
|
+
const cmp = (a, op, b, loose) => {
|
|
10977
|
+
switch (op) {
|
|
10978
|
+
case '===':
|
|
10979
|
+
if (typeof a === 'object') {
|
|
10980
|
+
a = a.version;
|
|
10981
|
+
}
|
|
10982
|
+
if (typeof b === 'object') {
|
|
10983
|
+
b = b.version;
|
|
10984
|
+
}
|
|
10985
|
+
return a === b
|
|
10986
|
+
|
|
10987
|
+
case '!==':
|
|
10988
|
+
if (typeof a === 'object') {
|
|
10989
|
+
a = a.version;
|
|
10990
|
+
}
|
|
10991
|
+
if (typeof b === 'object') {
|
|
10992
|
+
b = b.version;
|
|
10993
|
+
}
|
|
10994
|
+
return a !== b
|
|
10995
|
+
|
|
10996
|
+
case '':
|
|
10997
|
+
case '=':
|
|
10998
|
+
case '==':
|
|
10999
|
+
return eq(a, b, loose)
|
|
11000
|
+
|
|
11001
|
+
case '!=':
|
|
11002
|
+
return neq(a, b, loose)
|
|
11003
|
+
|
|
11004
|
+
case '>':
|
|
11005
|
+
return gt(a, b, loose)
|
|
11006
|
+
|
|
11007
|
+
case '>=':
|
|
11008
|
+
return gte(a, b, loose)
|
|
11009
|
+
|
|
11010
|
+
case '<':
|
|
11011
|
+
return lt(a, b, loose)
|
|
11012
|
+
|
|
11013
|
+
case '<=':
|
|
11014
|
+
return lte(a, b, loose)
|
|
11015
|
+
|
|
11016
|
+
default:
|
|
11017
|
+
throw new TypeError(`Invalid operator: ${op}`)
|
|
11018
|
+
}
|
|
11019
|
+
};
|
|
11020
|
+
cmp_1 = cmp;
|
|
11021
|
+
return cmp_1;
|
|
11022
|
+
}
|
|
11023
|
+
|
|
11024
|
+
var coerce_1;
|
|
11025
|
+
var hasRequiredCoerce;
|
|
11026
|
+
|
|
11027
|
+
function requireCoerce () {
|
|
11028
|
+
if (hasRequiredCoerce) return coerce_1;
|
|
11029
|
+
hasRequiredCoerce = 1;
|
|
11030
|
+
|
|
11031
|
+
const SemVer = requireSemver$1();
|
|
11032
|
+
const parse = requireParse();
|
|
11033
|
+
const { safeRe: re, t } = requireRe();
|
|
11034
|
+
|
|
11035
|
+
const coerce = (version, options) => {
|
|
11036
|
+
if (version instanceof SemVer) {
|
|
11037
|
+
return version
|
|
11038
|
+
}
|
|
11039
|
+
|
|
11040
|
+
if (typeof version === 'number') {
|
|
11041
|
+
version = String(version);
|
|
11042
|
+
}
|
|
11043
|
+
|
|
11044
|
+
if (typeof version !== 'string') {
|
|
11045
|
+
return null
|
|
11046
|
+
}
|
|
11047
|
+
|
|
11048
|
+
options = options || {};
|
|
11049
|
+
|
|
11050
|
+
let match = null;
|
|
11051
|
+
if (!options.rtl) {
|
|
11052
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
11053
|
+
} else {
|
|
11054
|
+
// Find the right-most coercible string that does not share
|
|
11055
|
+
// a terminus with a more left-ward coercible string.
|
|
11056
|
+
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
11057
|
+
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
|
|
11058
|
+
//
|
|
11059
|
+
// Walk through the string checking with a /g regexp
|
|
11060
|
+
// Manually set the index so as to pick up overlapping matches.
|
|
11061
|
+
// Stop when we get a match that ends at the string end, since no
|
|
11062
|
+
// coercible string can be more right-ward without the same terminus.
|
|
11063
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
11064
|
+
let next;
|
|
11065
|
+
while ((next = coerceRtlRegex.exec(version)) &&
|
|
11066
|
+
(!match || match.index + match[0].length !== version.length)
|
|
11067
|
+
) {
|
|
11068
|
+
if (!match ||
|
|
11069
|
+
next.index + next[0].length !== match.index + match[0].length) {
|
|
11070
|
+
match = next;
|
|
11071
|
+
}
|
|
11072
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
11073
|
+
}
|
|
11074
|
+
// leave it in a clean state
|
|
11075
|
+
coerceRtlRegex.lastIndex = -1;
|
|
11076
|
+
}
|
|
11077
|
+
|
|
11078
|
+
if (match === null) {
|
|
11079
|
+
return null
|
|
11080
|
+
}
|
|
11081
|
+
|
|
11082
|
+
const major = match[2];
|
|
11083
|
+
const minor = match[3] || '0';
|
|
11084
|
+
const patch = match[4] || '0';
|
|
11085
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
|
|
11086
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
|
|
11087
|
+
|
|
11088
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
|
|
11089
|
+
};
|
|
11090
|
+
coerce_1 = coerce;
|
|
11091
|
+
return coerce_1;
|
|
11092
|
+
}
|
|
11093
|
+
|
|
11094
|
+
var lrucache;
|
|
11095
|
+
var hasRequiredLrucache;
|
|
11096
|
+
|
|
11097
|
+
function requireLrucache () {
|
|
11098
|
+
if (hasRequiredLrucache) return lrucache;
|
|
11099
|
+
hasRequiredLrucache = 1;
|
|
11100
|
+
|
|
11101
|
+
class LRUCache {
|
|
11102
|
+
constructor () {
|
|
11103
|
+
this.max = 1000;
|
|
11104
|
+
this.map = new Map();
|
|
11105
|
+
}
|
|
11106
|
+
|
|
11107
|
+
get (key) {
|
|
11108
|
+
const value = this.map.get(key);
|
|
11109
|
+
if (value === undefined) {
|
|
11110
|
+
return undefined
|
|
11111
|
+
} else {
|
|
11112
|
+
// Remove the key from the map and add it to the end
|
|
11113
|
+
this.map.delete(key);
|
|
11114
|
+
this.map.set(key, value);
|
|
11115
|
+
return value
|
|
11116
|
+
}
|
|
11117
|
+
}
|
|
11118
|
+
|
|
11119
|
+
delete (key) {
|
|
11120
|
+
return this.map.delete(key)
|
|
11121
|
+
}
|
|
11122
|
+
|
|
11123
|
+
set (key, value) {
|
|
11124
|
+
const deleted = this.delete(key);
|
|
11125
|
+
|
|
11126
|
+
if (!deleted && value !== undefined) {
|
|
11127
|
+
// If cache is full, delete the least recently used item
|
|
11128
|
+
if (this.map.size >= this.max) {
|
|
11129
|
+
const firstKey = this.map.keys().next().value;
|
|
11130
|
+
this.delete(firstKey);
|
|
11131
|
+
}
|
|
11132
|
+
|
|
11133
|
+
this.map.set(key, value);
|
|
11134
|
+
}
|
|
11135
|
+
|
|
11136
|
+
return this
|
|
11137
|
+
}
|
|
11138
|
+
}
|
|
11139
|
+
|
|
11140
|
+
lrucache = LRUCache;
|
|
11141
|
+
return lrucache;
|
|
11142
|
+
}
|
|
11143
|
+
|
|
11144
|
+
var range;
|
|
11145
|
+
var hasRequiredRange;
|
|
11146
|
+
|
|
11147
|
+
function requireRange () {
|
|
11148
|
+
if (hasRequiredRange) return range;
|
|
11149
|
+
hasRequiredRange = 1;
|
|
11150
|
+
|
|
11151
|
+
const SPACE_CHARACTERS = /\s+/g;
|
|
11152
|
+
|
|
11153
|
+
// hoisted class for cyclic dependency
|
|
11154
|
+
class Range {
|
|
11155
|
+
constructor (range, options) {
|
|
11156
|
+
options = parseOptions(options);
|
|
11157
|
+
|
|
11158
|
+
if (range instanceof Range) {
|
|
11159
|
+
if (
|
|
11160
|
+
range.loose === !!options.loose &&
|
|
11161
|
+
range.includePrerelease === !!options.includePrerelease
|
|
11162
|
+
) {
|
|
11163
|
+
return range
|
|
11164
|
+
} else {
|
|
11165
|
+
return new Range(range.raw, options)
|
|
11166
|
+
}
|
|
11167
|
+
}
|
|
11168
|
+
|
|
11169
|
+
if (range instanceof Comparator) {
|
|
11170
|
+
// just put it in the set and return
|
|
11171
|
+
this.raw = range.value;
|
|
11172
|
+
this.set = [[range]];
|
|
11173
|
+
this.formatted = undefined;
|
|
11174
|
+
return this
|
|
11175
|
+
}
|
|
11176
|
+
|
|
11177
|
+
this.options = options;
|
|
11178
|
+
this.loose = !!options.loose;
|
|
11179
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
11180
|
+
|
|
11181
|
+
// First reduce all whitespace as much as possible so we do not have to rely
|
|
11182
|
+
// on potentially slow regexes like \s*. This is then stored and used for
|
|
11183
|
+
// future error messages as well.
|
|
11184
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, ' ');
|
|
11185
|
+
|
|
11186
|
+
// First, split on ||
|
|
11187
|
+
this.set = this.raw
|
|
11188
|
+
.split('||')
|
|
11189
|
+
// map the range to a 2d array of comparators
|
|
11190
|
+
.map(r => this.parseRange(r.trim()))
|
|
11191
|
+
// throw out any comparator lists that are empty
|
|
11192
|
+
// this generally means that it was not a valid range, which is allowed
|
|
11193
|
+
// in loose mode, but will still throw if the WHOLE range is invalid.
|
|
11194
|
+
.filter(c => c.length);
|
|
11195
|
+
|
|
11196
|
+
if (!this.set.length) {
|
|
11197
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
|
|
11198
|
+
}
|
|
11199
|
+
|
|
11200
|
+
// if we have any that are not the null set, throw out null sets.
|
|
11201
|
+
if (this.set.length > 1) {
|
|
11202
|
+
// keep the first one, in case they're all null sets
|
|
11203
|
+
const first = this.set[0];
|
|
11204
|
+
this.set = this.set.filter(c => !isNullSet(c[0]));
|
|
11205
|
+
if (this.set.length === 0) {
|
|
11206
|
+
this.set = [first];
|
|
11207
|
+
} else if (this.set.length > 1) {
|
|
11208
|
+
// if we have any that are *, then the range is just *
|
|
11209
|
+
for (const c of this.set) {
|
|
11210
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
11211
|
+
this.set = [c];
|
|
11212
|
+
break
|
|
11213
|
+
}
|
|
11214
|
+
}
|
|
11215
|
+
}
|
|
11216
|
+
}
|
|
11217
|
+
|
|
11218
|
+
this.formatted = undefined;
|
|
11219
|
+
}
|
|
11220
|
+
|
|
11221
|
+
get range () {
|
|
11222
|
+
if (this.formatted === undefined) {
|
|
11223
|
+
this.formatted = '';
|
|
11224
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
11225
|
+
if (i > 0) {
|
|
11226
|
+
this.formatted += '||';
|
|
11227
|
+
}
|
|
11228
|
+
const comps = this.set[i];
|
|
11229
|
+
for (let k = 0; k < comps.length; k++) {
|
|
11230
|
+
if (k > 0) {
|
|
11231
|
+
this.formatted += ' ';
|
|
11232
|
+
}
|
|
11233
|
+
this.formatted += comps[k].toString().trim();
|
|
11234
|
+
}
|
|
11235
|
+
}
|
|
11236
|
+
}
|
|
11237
|
+
return this.formatted
|
|
11238
|
+
}
|
|
11239
|
+
|
|
11240
|
+
format () {
|
|
11241
|
+
return this.range
|
|
11242
|
+
}
|
|
11243
|
+
|
|
11244
|
+
toString () {
|
|
11245
|
+
return this.range
|
|
11246
|
+
}
|
|
11247
|
+
|
|
11248
|
+
parseRange (range) {
|
|
11249
|
+
// memoize range parsing for performance.
|
|
11250
|
+
// this is a very hot path, and fully deterministic.
|
|
11251
|
+
const memoOpts =
|
|
11252
|
+
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
|
11253
|
+
(this.options.loose && FLAG_LOOSE);
|
|
11254
|
+
const memoKey = memoOpts + ':' + range;
|
|
11255
|
+
const cached = cache.get(memoKey);
|
|
11256
|
+
if (cached) {
|
|
11257
|
+
return cached
|
|
11258
|
+
}
|
|
11259
|
+
|
|
11260
|
+
const loose = this.options.loose;
|
|
11261
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
11262
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
11263
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
11264
|
+
debug('hyphen replace', range);
|
|
11265
|
+
|
|
11266
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
11267
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
11268
|
+
debug('comparator trim', range);
|
|
11269
|
+
|
|
11270
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
11271
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
11272
|
+
debug('tilde trim', range);
|
|
11273
|
+
|
|
11274
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
11275
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
11276
|
+
debug('caret trim', range);
|
|
11277
|
+
|
|
11278
|
+
// At this point, the range is completely trimmed and
|
|
11279
|
+
// ready to be split into comparators.
|
|
11280
|
+
|
|
11281
|
+
let rangeList = range
|
|
11282
|
+
.split(' ')
|
|
11283
|
+
.map(comp => parseComparator(comp, this.options))
|
|
11284
|
+
.join(' ')
|
|
11285
|
+
.split(/\s+/)
|
|
11286
|
+
// >=0.0.0 is equivalent to *
|
|
11287
|
+
.map(comp => replaceGTE0(comp, this.options));
|
|
11288
|
+
|
|
11289
|
+
if (loose) {
|
|
11290
|
+
// in loose mode, throw out any that are not valid comparators
|
|
11291
|
+
rangeList = rangeList.filter(comp => {
|
|
11292
|
+
debug('loose invalid filter', comp, this.options);
|
|
11293
|
+
return !!comp.match(re[t.COMPARATORLOOSE])
|
|
11294
|
+
});
|
|
11295
|
+
}
|
|
11296
|
+
debug('range list', rangeList);
|
|
11297
|
+
|
|
11298
|
+
// if any comparators are the null set, then replace with JUST null set
|
|
11299
|
+
// if more than one comparator, remove any * comparators
|
|
11300
|
+
// also, don't include the same comparator more than once
|
|
11301
|
+
const rangeMap = new Map();
|
|
11302
|
+
const comparators = rangeList.map(comp => new Comparator(comp, this.options));
|
|
11303
|
+
for (const comp of comparators) {
|
|
11304
|
+
if (isNullSet(comp)) {
|
|
11305
|
+
return [comp]
|
|
11306
|
+
}
|
|
11307
|
+
rangeMap.set(comp.value, comp);
|
|
11308
|
+
}
|
|
11309
|
+
if (rangeMap.size > 1 && rangeMap.has('')) {
|
|
11310
|
+
rangeMap.delete('');
|
|
11311
|
+
}
|
|
11312
|
+
|
|
11313
|
+
const result = [...rangeMap.values()];
|
|
11314
|
+
cache.set(memoKey, result);
|
|
11315
|
+
return result
|
|
11316
|
+
}
|
|
11317
|
+
|
|
11318
|
+
intersects (range, options) {
|
|
11319
|
+
if (!(range instanceof Range)) {
|
|
11320
|
+
throw new TypeError('a Range is required')
|
|
11321
|
+
}
|
|
11322
|
+
|
|
11323
|
+
return this.set.some((thisComparators) => {
|
|
11324
|
+
return (
|
|
11325
|
+
isSatisfiable(thisComparators, options) &&
|
|
11326
|
+
range.set.some((rangeComparators) => {
|
|
11327
|
+
return (
|
|
11328
|
+
isSatisfiable(rangeComparators, options) &&
|
|
11329
|
+
thisComparators.every((thisComparator) => {
|
|
11330
|
+
return rangeComparators.every((rangeComparator) => {
|
|
11331
|
+
return thisComparator.intersects(rangeComparator, options)
|
|
11332
|
+
})
|
|
11333
|
+
})
|
|
11334
|
+
)
|
|
11335
|
+
})
|
|
11336
|
+
)
|
|
11337
|
+
})
|
|
11338
|
+
}
|
|
11339
|
+
|
|
11340
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
11341
|
+
test (version) {
|
|
11342
|
+
if (!version) {
|
|
11343
|
+
return false
|
|
11344
|
+
}
|
|
11345
|
+
|
|
11346
|
+
if (typeof version === 'string') {
|
|
11347
|
+
try {
|
|
11348
|
+
version = new SemVer(version, this.options);
|
|
11349
|
+
} catch (er) {
|
|
11350
|
+
return false
|
|
11351
|
+
}
|
|
11352
|
+
}
|
|
11353
|
+
|
|
11354
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
11355
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
11356
|
+
return true
|
|
11357
|
+
}
|
|
11358
|
+
}
|
|
11359
|
+
return false
|
|
11360
|
+
}
|
|
11361
|
+
}
|
|
11362
|
+
|
|
11363
|
+
range = Range;
|
|
11364
|
+
|
|
11365
|
+
const LRU = requireLrucache();
|
|
11366
|
+
const cache = new LRU();
|
|
11367
|
+
|
|
11368
|
+
const parseOptions = requireParseOptions();
|
|
11369
|
+
const Comparator = requireComparator();
|
|
11370
|
+
const debug = requireDebug();
|
|
11371
|
+
const SemVer = requireSemver$1();
|
|
11372
|
+
const {
|
|
11373
|
+
safeRe: re,
|
|
11374
|
+
t,
|
|
11375
|
+
comparatorTrimReplace,
|
|
11376
|
+
tildeTrimReplace,
|
|
11377
|
+
caretTrimReplace,
|
|
11378
|
+
} = requireRe();
|
|
11379
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = requireConstants();
|
|
11380
|
+
|
|
11381
|
+
const isNullSet = c => c.value === '<0.0.0-0';
|
|
11382
|
+
const isAny = c => c.value === '';
|
|
11383
|
+
|
|
11384
|
+
// take a set of comparators and determine whether there
|
|
11385
|
+
// exists a version which can satisfy it
|
|
11386
|
+
const isSatisfiable = (comparators, options) => {
|
|
11387
|
+
let result = true;
|
|
11388
|
+
const remainingComparators = comparators.slice();
|
|
11389
|
+
let testComparator = remainingComparators.pop();
|
|
11390
|
+
|
|
11391
|
+
while (result && remainingComparators.length) {
|
|
11392
|
+
result = remainingComparators.every((otherComparator) => {
|
|
11393
|
+
return testComparator.intersects(otherComparator, options)
|
|
11394
|
+
});
|
|
11395
|
+
|
|
11396
|
+
testComparator = remainingComparators.pop();
|
|
11397
|
+
}
|
|
11398
|
+
|
|
11399
|
+
return result
|
|
11400
|
+
};
|
|
11401
|
+
|
|
11402
|
+
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
11403
|
+
// already replaced the hyphen ranges
|
|
11404
|
+
// turn into a set of JUST comparators.
|
|
11405
|
+
const parseComparator = (comp, options) => {
|
|
11406
|
+
comp = comp.replace(re[t.BUILD], '');
|
|
11407
|
+
debug('comp', comp, options);
|
|
11408
|
+
comp = replaceCarets(comp, options);
|
|
11409
|
+
debug('caret', comp);
|
|
11410
|
+
comp = replaceTildes(comp, options);
|
|
11411
|
+
debug('tildes', comp);
|
|
11412
|
+
comp = replaceXRanges(comp, options);
|
|
11413
|
+
debug('xrange', comp);
|
|
11414
|
+
comp = replaceStars(comp, options);
|
|
11415
|
+
debug('stars', comp);
|
|
11416
|
+
return comp
|
|
11417
|
+
};
|
|
11418
|
+
|
|
11419
|
+
const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
|
|
11420
|
+
|
|
11421
|
+
// ~, ~> --> * (any, kinda silly)
|
|
11422
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
11423
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
11424
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
11425
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
11426
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
11427
|
+
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
|
11428
|
+
const replaceTildes = (comp, options) => {
|
|
11429
|
+
return comp
|
|
11430
|
+
.trim()
|
|
11431
|
+
.split(/\s+/)
|
|
11432
|
+
.map((c) => replaceTilde(c, options))
|
|
11433
|
+
.join(' ')
|
|
11434
|
+
};
|
|
11435
|
+
|
|
11436
|
+
const replaceTilde = (comp, options) => {
|
|
11437
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
11438
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
11439
|
+
debug('tilde', comp, _, M, m, p, pr);
|
|
11440
|
+
let ret;
|
|
11441
|
+
|
|
11442
|
+
if (isX(M)) {
|
|
11443
|
+
ret = '';
|
|
11444
|
+
} else if (isX(m)) {
|
|
11445
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
11446
|
+
} else if (isX(p)) {
|
|
11447
|
+
// ~1.2 == >=1.2.0 <1.3.0-0
|
|
11448
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
11449
|
+
} else if (pr) {
|
|
11450
|
+
debug('replaceTilde pr', pr);
|
|
11451
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
11452
|
+
} <${M}.${+m + 1}.0-0`;
|
|
11453
|
+
} else {
|
|
11454
|
+
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
|
11455
|
+
ret = `>=${M}.${m}.${p
|
|
11456
|
+
} <${M}.${+m + 1}.0-0`;
|
|
11457
|
+
}
|
|
11458
|
+
|
|
11459
|
+
debug('tilde return', ret);
|
|
11460
|
+
return ret
|
|
11461
|
+
})
|
|
11462
|
+
};
|
|
11463
|
+
|
|
11464
|
+
// ^ --> * (any, kinda silly)
|
|
11465
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
|
11466
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
|
11467
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
11468
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
11469
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
11470
|
+
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
|
11471
|
+
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
|
11472
|
+
const replaceCarets = (comp, options) => {
|
|
11473
|
+
return comp
|
|
11474
|
+
.trim()
|
|
11475
|
+
.split(/\s+/)
|
|
11476
|
+
.map((c) => replaceCaret(c, options))
|
|
11477
|
+
.join(' ')
|
|
11478
|
+
};
|
|
11479
|
+
|
|
11480
|
+
const replaceCaret = (comp, options) => {
|
|
11481
|
+
debug('caret', comp, options);
|
|
11482
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
11483
|
+
const z = options.includePrerelease ? '-0' : '';
|
|
11484
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
11485
|
+
debug('caret', comp, _, M, m, p, pr);
|
|
11486
|
+
let ret;
|
|
11487
|
+
|
|
11488
|
+
if (isX(M)) {
|
|
11489
|
+
ret = '';
|
|
11490
|
+
} else if (isX(m)) {
|
|
11491
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
11492
|
+
} else if (isX(p)) {
|
|
11493
|
+
if (M === '0') {
|
|
11494
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
11495
|
+
} else {
|
|
11496
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
11497
|
+
}
|
|
11498
|
+
} else if (pr) {
|
|
11499
|
+
debug('replaceCaret pr', pr);
|
|
11500
|
+
if (M === '0') {
|
|
11501
|
+
if (m === '0') {
|
|
11502
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
11503
|
+
} <${M}.${m}.${+p + 1}-0`;
|
|
11504
|
+
} else {
|
|
11505
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
11506
|
+
} <${M}.${+m + 1}.0-0`;
|
|
11507
|
+
}
|
|
11508
|
+
} else {
|
|
11509
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
11510
|
+
} <${+M + 1}.0.0-0`;
|
|
11511
|
+
}
|
|
11512
|
+
} else {
|
|
11513
|
+
debug('no pr');
|
|
11514
|
+
if (M === '0') {
|
|
11515
|
+
if (m === '0') {
|
|
11516
|
+
ret = `>=${M}.${m}.${p
|
|
11517
|
+
}${z} <${M}.${m}.${+p + 1}-0`;
|
|
11518
|
+
} else {
|
|
11519
|
+
ret = `>=${M}.${m}.${p
|
|
11520
|
+
}${z} <${M}.${+m + 1}.0-0`;
|
|
11521
|
+
}
|
|
11522
|
+
} else {
|
|
11523
|
+
ret = `>=${M}.${m}.${p
|
|
11524
|
+
} <${+M + 1}.0.0-0`;
|
|
11525
|
+
}
|
|
11526
|
+
}
|
|
11527
|
+
|
|
11528
|
+
debug('caret return', ret);
|
|
11529
|
+
return ret
|
|
11530
|
+
})
|
|
11531
|
+
};
|
|
11532
|
+
|
|
11533
|
+
const replaceXRanges = (comp, options) => {
|
|
11534
|
+
debug('replaceXRanges', comp, options);
|
|
11535
|
+
return comp
|
|
11536
|
+
.split(/\s+/)
|
|
11537
|
+
.map((c) => replaceXRange(c, options))
|
|
11538
|
+
.join(' ')
|
|
11539
|
+
};
|
|
11540
|
+
|
|
11541
|
+
const replaceXRange = (comp, options) => {
|
|
11542
|
+
comp = comp.trim();
|
|
11543
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
11544
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
11545
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr);
|
|
11546
|
+
const xM = isX(M);
|
|
11547
|
+
const xm = xM || isX(m);
|
|
11548
|
+
const xp = xm || isX(p);
|
|
11549
|
+
const anyX = xp;
|
|
11550
|
+
|
|
11551
|
+
if (gtlt === '=' && anyX) {
|
|
11552
|
+
gtlt = '';
|
|
11553
|
+
}
|
|
11554
|
+
|
|
11555
|
+
// if we're including prereleases in the match, then we need
|
|
11556
|
+
// to fix this to -0, the lowest possible prerelease value
|
|
11557
|
+
pr = options.includePrerelease ? '-0' : '';
|
|
11558
|
+
|
|
11559
|
+
if (xM) {
|
|
11560
|
+
if (gtlt === '>' || gtlt === '<') {
|
|
11561
|
+
// nothing is allowed
|
|
11562
|
+
ret = '<0.0.0-0';
|
|
11563
|
+
} else {
|
|
11564
|
+
// nothing is forbidden
|
|
11565
|
+
ret = '*';
|
|
11566
|
+
}
|
|
11567
|
+
} else if (gtlt && anyX) {
|
|
11568
|
+
// we know patch is an x, because we have any x at all.
|
|
11569
|
+
// replace X with 0
|
|
11570
|
+
if (xm) {
|
|
11571
|
+
m = 0;
|
|
11572
|
+
}
|
|
11573
|
+
p = 0;
|
|
11574
|
+
|
|
11575
|
+
if (gtlt === '>') {
|
|
11576
|
+
// >1 => >=2.0.0
|
|
11577
|
+
// >1.2 => >=1.3.0
|
|
11578
|
+
gtlt = '>=';
|
|
11579
|
+
if (xm) {
|
|
11580
|
+
M = +M + 1;
|
|
11581
|
+
m = 0;
|
|
11582
|
+
p = 0;
|
|
11583
|
+
} else {
|
|
11584
|
+
m = +m + 1;
|
|
11585
|
+
p = 0;
|
|
11586
|
+
}
|
|
11587
|
+
} else if (gtlt === '<=') {
|
|
11588
|
+
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
11589
|
+
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
11590
|
+
gtlt = '<';
|
|
11591
|
+
if (xm) {
|
|
11592
|
+
M = +M + 1;
|
|
11593
|
+
} else {
|
|
11594
|
+
m = +m + 1;
|
|
11595
|
+
}
|
|
11596
|
+
}
|
|
11597
|
+
|
|
11598
|
+
if (gtlt === '<') {
|
|
11599
|
+
pr = '-0';
|
|
11600
|
+
}
|
|
11601
|
+
|
|
11602
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
11603
|
+
} else if (xm) {
|
|
11604
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
11605
|
+
} else if (xp) {
|
|
11606
|
+
ret = `>=${M}.${m}.0${pr
|
|
11607
|
+
} <${M}.${+m + 1}.0-0`;
|
|
11608
|
+
}
|
|
11609
|
+
|
|
11610
|
+
debug('xRange return', ret);
|
|
11611
|
+
|
|
11612
|
+
return ret
|
|
11613
|
+
})
|
|
11614
|
+
};
|
|
11615
|
+
|
|
11616
|
+
// Because * is AND-ed with everything else in the comparator,
|
|
11617
|
+
// and '' means "any version", just remove the *s entirely.
|
|
11618
|
+
const replaceStars = (comp, options) => {
|
|
11619
|
+
debug('replaceStars', comp, options);
|
|
11620
|
+
// Looseness is ignored here. star is always as loose as it gets!
|
|
11621
|
+
return comp
|
|
11622
|
+
.trim()
|
|
11623
|
+
.replace(re[t.STAR], '')
|
|
11624
|
+
};
|
|
11625
|
+
|
|
11626
|
+
const replaceGTE0 = (comp, options) => {
|
|
11627
|
+
debug('replaceGTE0', comp, options);
|
|
11628
|
+
return comp
|
|
11629
|
+
.trim()
|
|
11630
|
+
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
|
11631
|
+
};
|
|
11632
|
+
|
|
11633
|
+
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
|
11634
|
+
// M, m, patch, prerelease, build
|
|
11635
|
+
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
11636
|
+
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
|
11637
|
+
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
|
11638
|
+
// TODO build?
|
|
11639
|
+
const hyphenReplace = incPr => ($0,
|
|
11640
|
+
from, fM, fm, fp, fpr, fb,
|
|
11641
|
+
to, tM, tm, tp, tpr) => {
|
|
11642
|
+
if (isX(fM)) {
|
|
11643
|
+
from = '';
|
|
11644
|
+
} else if (isX(fm)) {
|
|
11645
|
+
from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
|
|
11646
|
+
} else if (isX(fp)) {
|
|
11647
|
+
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
|
|
11648
|
+
} else if (fpr) {
|
|
11649
|
+
from = `>=${from}`;
|
|
11650
|
+
} else {
|
|
11651
|
+
from = `>=${from}${incPr ? '-0' : ''}`;
|
|
11652
|
+
}
|
|
11653
|
+
|
|
11654
|
+
if (isX(tM)) {
|
|
11655
|
+
to = '';
|
|
11656
|
+
} else if (isX(tm)) {
|
|
11657
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
11658
|
+
} else if (isX(tp)) {
|
|
11659
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
11660
|
+
} else if (tpr) {
|
|
11661
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
11662
|
+
} else if (incPr) {
|
|
11663
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
11664
|
+
} else {
|
|
11665
|
+
to = `<=${to}`;
|
|
11666
|
+
}
|
|
11667
|
+
|
|
11668
|
+
return `${from} ${to}`.trim()
|
|
11669
|
+
};
|
|
11670
|
+
|
|
11671
|
+
const testSet = (set, version, options) => {
|
|
11672
|
+
for (let i = 0; i < set.length; i++) {
|
|
11673
|
+
if (!set[i].test(version)) {
|
|
11674
|
+
return false
|
|
11675
|
+
}
|
|
11676
|
+
}
|
|
11677
|
+
|
|
11678
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
11679
|
+
// Find the set of versions that are allowed to have prereleases
|
|
11680
|
+
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
11681
|
+
// That should allow `1.2.3-pr.2` to pass.
|
|
11682
|
+
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
11683
|
+
// even though it's within the range set by the comparators.
|
|
11684
|
+
for (let i = 0; i < set.length; i++) {
|
|
11685
|
+
debug(set[i].semver);
|
|
11686
|
+
if (set[i].semver === Comparator.ANY) {
|
|
11687
|
+
continue
|
|
11688
|
+
}
|
|
11689
|
+
|
|
11690
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
11691
|
+
const allowed = set[i].semver;
|
|
11692
|
+
if (allowed.major === version.major &&
|
|
11693
|
+
allowed.minor === version.minor &&
|
|
11694
|
+
allowed.patch === version.patch) {
|
|
11695
|
+
return true
|
|
11696
|
+
}
|
|
11697
|
+
}
|
|
11698
|
+
}
|
|
11699
|
+
|
|
11700
|
+
// Version has a -pre, but it's not one of the ones we like.
|
|
11701
|
+
return false
|
|
11702
|
+
}
|
|
11703
|
+
|
|
11704
|
+
return true
|
|
11705
|
+
};
|
|
11706
|
+
return range;
|
|
11707
|
+
}
|
|
11708
|
+
|
|
11709
|
+
var comparator;
|
|
11710
|
+
var hasRequiredComparator;
|
|
11711
|
+
|
|
11712
|
+
function requireComparator () {
|
|
11713
|
+
if (hasRequiredComparator) return comparator;
|
|
11714
|
+
hasRequiredComparator = 1;
|
|
11715
|
+
|
|
11716
|
+
const ANY = Symbol('SemVer ANY');
|
|
11717
|
+
// hoisted class for cyclic dependency
|
|
11718
|
+
class Comparator {
|
|
11719
|
+
static get ANY () {
|
|
11720
|
+
return ANY
|
|
11721
|
+
}
|
|
11722
|
+
|
|
11723
|
+
constructor (comp, options) {
|
|
11724
|
+
options = parseOptions(options);
|
|
11725
|
+
|
|
11726
|
+
if (comp instanceof Comparator) {
|
|
11727
|
+
if (comp.loose === !!options.loose) {
|
|
11728
|
+
return comp
|
|
11729
|
+
} else {
|
|
11730
|
+
comp = comp.value;
|
|
11731
|
+
}
|
|
11732
|
+
}
|
|
11733
|
+
|
|
11734
|
+
comp = comp.trim().split(/\s+/).join(' ');
|
|
11735
|
+
debug('comparator', comp, options);
|
|
11736
|
+
this.options = options;
|
|
11737
|
+
this.loose = !!options.loose;
|
|
11738
|
+
this.parse(comp);
|
|
11739
|
+
|
|
11740
|
+
if (this.semver === ANY) {
|
|
11741
|
+
this.value = '';
|
|
11742
|
+
} else {
|
|
11743
|
+
this.value = this.operator + this.semver.version;
|
|
11744
|
+
}
|
|
11745
|
+
|
|
11746
|
+
debug('comp', this);
|
|
11747
|
+
}
|
|
11748
|
+
|
|
11749
|
+
parse (comp) {
|
|
11750
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
11751
|
+
const m = comp.match(r);
|
|
11752
|
+
|
|
11753
|
+
if (!m) {
|
|
11754
|
+
throw new TypeError(`Invalid comparator: ${comp}`)
|
|
11755
|
+
}
|
|
11756
|
+
|
|
11757
|
+
this.operator = m[1] !== undefined ? m[1] : '';
|
|
11758
|
+
if (this.operator === '=') {
|
|
11759
|
+
this.operator = '';
|
|
11760
|
+
}
|
|
11761
|
+
|
|
11762
|
+
// if it literally is just '>' or '' then allow anything.
|
|
11763
|
+
if (!m[2]) {
|
|
11764
|
+
this.semver = ANY;
|
|
11765
|
+
} else {
|
|
11766
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
11767
|
+
}
|
|
11768
|
+
}
|
|
11769
|
+
|
|
11770
|
+
toString () {
|
|
11771
|
+
return this.value
|
|
11772
|
+
}
|
|
11773
|
+
|
|
11774
|
+
test (version) {
|
|
11775
|
+
debug('Comparator.test', version, this.options.loose);
|
|
11776
|
+
|
|
11777
|
+
if (this.semver === ANY || version === ANY) {
|
|
11778
|
+
return true
|
|
11779
|
+
}
|
|
11780
|
+
|
|
11781
|
+
if (typeof version === 'string') {
|
|
11782
|
+
try {
|
|
11783
|
+
version = new SemVer(version, this.options);
|
|
11784
|
+
} catch (er) {
|
|
11785
|
+
return false
|
|
11786
|
+
}
|
|
11787
|
+
}
|
|
11788
|
+
|
|
11789
|
+
return cmp(version, this.operator, this.semver, this.options)
|
|
11790
|
+
}
|
|
11791
|
+
|
|
11792
|
+
intersects (comp, options) {
|
|
11793
|
+
if (!(comp instanceof Comparator)) {
|
|
11794
|
+
throw new TypeError('a Comparator is required')
|
|
11795
|
+
}
|
|
11796
|
+
|
|
11797
|
+
if (this.operator === '') {
|
|
11798
|
+
if (this.value === '') {
|
|
11799
|
+
return true
|
|
11800
|
+
}
|
|
11801
|
+
return new Range(comp.value, options).test(this.value)
|
|
11802
|
+
} else if (comp.operator === '') {
|
|
11803
|
+
if (comp.value === '') {
|
|
11804
|
+
return true
|
|
11805
|
+
}
|
|
11806
|
+
return new Range(this.value, options).test(comp.semver)
|
|
11807
|
+
}
|
|
11808
|
+
|
|
11809
|
+
options = parseOptions(options);
|
|
11810
|
+
|
|
11811
|
+
// Special cases where nothing can possibly be lower
|
|
11812
|
+
if (options.includePrerelease &&
|
|
11813
|
+
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
|
11814
|
+
return false
|
|
11815
|
+
}
|
|
11816
|
+
if (!options.includePrerelease &&
|
|
11817
|
+
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
|
11818
|
+
return false
|
|
11819
|
+
}
|
|
11820
|
+
|
|
11821
|
+
// Same direction increasing (> or >=)
|
|
11822
|
+
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
|
11823
|
+
return true
|
|
11824
|
+
}
|
|
11825
|
+
// Same direction decreasing (< or <=)
|
|
11826
|
+
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
|
11827
|
+
return true
|
|
11828
|
+
}
|
|
11829
|
+
// same SemVer and both sides are inclusive (<= or >=)
|
|
11830
|
+
if (
|
|
11831
|
+
(this.semver.version === comp.semver.version) &&
|
|
11832
|
+
this.operator.includes('=') && comp.operator.includes('=')) {
|
|
11833
|
+
return true
|
|
11834
|
+
}
|
|
11835
|
+
// opposite directions less than
|
|
11836
|
+
if (cmp(this.semver, '<', comp.semver, options) &&
|
|
11837
|
+
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
|
11838
|
+
return true
|
|
11839
|
+
}
|
|
11840
|
+
// opposite directions greater than
|
|
11841
|
+
if (cmp(this.semver, '>', comp.semver, options) &&
|
|
11842
|
+
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
|
11843
|
+
return true
|
|
11844
|
+
}
|
|
11845
|
+
return false
|
|
11846
|
+
}
|
|
11847
|
+
}
|
|
11848
|
+
|
|
11849
|
+
comparator = Comparator;
|
|
11850
|
+
|
|
11851
|
+
const parseOptions = requireParseOptions();
|
|
11852
|
+
const { safeRe: re, t } = requireRe();
|
|
11853
|
+
const cmp = requireCmp();
|
|
11854
|
+
const debug = requireDebug();
|
|
11855
|
+
const SemVer = requireSemver$1();
|
|
11856
|
+
const Range = requireRange();
|
|
11857
|
+
return comparator;
|
|
11858
|
+
}
|
|
11859
|
+
|
|
11860
|
+
var satisfies_1;
|
|
11861
|
+
var hasRequiredSatisfies;
|
|
11862
|
+
|
|
11863
|
+
function requireSatisfies () {
|
|
11864
|
+
if (hasRequiredSatisfies) return satisfies_1;
|
|
11865
|
+
hasRequiredSatisfies = 1;
|
|
11866
|
+
|
|
11867
|
+
const Range = requireRange();
|
|
11868
|
+
const satisfies = (version, range, options) => {
|
|
11869
|
+
try {
|
|
11870
|
+
range = new Range(range, options);
|
|
11871
|
+
} catch (er) {
|
|
11872
|
+
return false
|
|
11873
|
+
}
|
|
11874
|
+
return range.test(version)
|
|
11875
|
+
};
|
|
11876
|
+
satisfies_1 = satisfies;
|
|
11877
|
+
return satisfies_1;
|
|
11878
|
+
}
|
|
11879
|
+
|
|
11880
|
+
var toComparators_1;
|
|
11881
|
+
var hasRequiredToComparators;
|
|
11882
|
+
|
|
11883
|
+
function requireToComparators () {
|
|
11884
|
+
if (hasRequiredToComparators) return toComparators_1;
|
|
11885
|
+
hasRequiredToComparators = 1;
|
|
11886
|
+
|
|
11887
|
+
const Range = requireRange();
|
|
11888
|
+
|
|
11889
|
+
// Mostly just for testing and legacy API reasons
|
|
11890
|
+
const toComparators = (range, options) =>
|
|
11891
|
+
new Range(range, options).set
|
|
11892
|
+
.map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
|
|
11893
|
+
|
|
11894
|
+
toComparators_1 = toComparators;
|
|
11895
|
+
return toComparators_1;
|
|
11896
|
+
}
|
|
11897
|
+
|
|
11898
|
+
var maxSatisfying_1;
|
|
11899
|
+
var hasRequiredMaxSatisfying;
|
|
11900
|
+
|
|
11901
|
+
function requireMaxSatisfying () {
|
|
11902
|
+
if (hasRequiredMaxSatisfying) return maxSatisfying_1;
|
|
11903
|
+
hasRequiredMaxSatisfying = 1;
|
|
11904
|
+
|
|
11905
|
+
const SemVer = requireSemver$1();
|
|
11906
|
+
const Range = requireRange();
|
|
11907
|
+
|
|
11908
|
+
const maxSatisfying = (versions, range, options) => {
|
|
11909
|
+
let max = null;
|
|
11910
|
+
let maxSV = null;
|
|
11911
|
+
let rangeObj = null;
|
|
11912
|
+
try {
|
|
11913
|
+
rangeObj = new Range(range, options);
|
|
11914
|
+
} catch (er) {
|
|
11915
|
+
return null
|
|
11916
|
+
}
|
|
11917
|
+
versions.forEach((v) => {
|
|
11918
|
+
if (rangeObj.test(v)) {
|
|
11919
|
+
// satisfies(v, range, options)
|
|
11920
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
11921
|
+
// compare(max, v, true)
|
|
11922
|
+
max = v;
|
|
11923
|
+
maxSV = new SemVer(max, options);
|
|
11924
|
+
}
|
|
11925
|
+
}
|
|
11926
|
+
});
|
|
11927
|
+
return max
|
|
11928
|
+
};
|
|
11929
|
+
maxSatisfying_1 = maxSatisfying;
|
|
11930
|
+
return maxSatisfying_1;
|
|
11931
|
+
}
|
|
11932
|
+
|
|
11933
|
+
var minSatisfying_1;
|
|
11934
|
+
var hasRequiredMinSatisfying;
|
|
11935
|
+
|
|
11936
|
+
function requireMinSatisfying () {
|
|
11937
|
+
if (hasRequiredMinSatisfying) return minSatisfying_1;
|
|
11938
|
+
hasRequiredMinSatisfying = 1;
|
|
11939
|
+
|
|
11940
|
+
const SemVer = requireSemver$1();
|
|
11941
|
+
const Range = requireRange();
|
|
11942
|
+
const minSatisfying = (versions, range, options) => {
|
|
11943
|
+
let min = null;
|
|
11944
|
+
let minSV = null;
|
|
11945
|
+
let rangeObj = null;
|
|
11946
|
+
try {
|
|
11947
|
+
rangeObj = new Range(range, options);
|
|
11948
|
+
} catch (er) {
|
|
11949
|
+
return null
|
|
11950
|
+
}
|
|
11951
|
+
versions.forEach((v) => {
|
|
11952
|
+
if (rangeObj.test(v)) {
|
|
11953
|
+
// satisfies(v, range, options)
|
|
11954
|
+
if (!min || minSV.compare(v) === 1) {
|
|
11955
|
+
// compare(min, v, true)
|
|
11956
|
+
min = v;
|
|
11957
|
+
minSV = new SemVer(min, options);
|
|
11958
|
+
}
|
|
11959
|
+
}
|
|
11960
|
+
});
|
|
11961
|
+
return min
|
|
11962
|
+
};
|
|
11963
|
+
minSatisfying_1 = minSatisfying;
|
|
11964
|
+
return minSatisfying_1;
|
|
11965
|
+
}
|
|
11966
|
+
|
|
11967
|
+
var minVersion_1;
|
|
11968
|
+
var hasRequiredMinVersion;
|
|
11969
|
+
|
|
11970
|
+
function requireMinVersion () {
|
|
11971
|
+
if (hasRequiredMinVersion) return minVersion_1;
|
|
11972
|
+
hasRequiredMinVersion = 1;
|
|
11973
|
+
|
|
11974
|
+
const SemVer = requireSemver$1();
|
|
11975
|
+
const Range = requireRange();
|
|
11976
|
+
const gt = requireGt();
|
|
11977
|
+
|
|
11978
|
+
const minVersion = (range, loose) => {
|
|
11979
|
+
range = new Range(range, loose);
|
|
11980
|
+
|
|
11981
|
+
let minver = new SemVer('0.0.0');
|
|
11982
|
+
if (range.test(minver)) {
|
|
11983
|
+
return minver
|
|
11984
|
+
}
|
|
11985
|
+
|
|
11986
|
+
minver = new SemVer('0.0.0-0');
|
|
11987
|
+
if (range.test(minver)) {
|
|
11988
|
+
return minver
|
|
11989
|
+
}
|
|
11990
|
+
|
|
11991
|
+
minver = null;
|
|
11992
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
11993
|
+
const comparators = range.set[i];
|
|
11994
|
+
|
|
11995
|
+
let setMin = null;
|
|
11996
|
+
comparators.forEach((comparator) => {
|
|
11997
|
+
// Clone to avoid manipulating the comparator's semver object.
|
|
11998
|
+
const compver = new SemVer(comparator.semver.version);
|
|
11999
|
+
switch (comparator.operator) {
|
|
12000
|
+
case '>':
|
|
12001
|
+
if (compver.prerelease.length === 0) {
|
|
12002
|
+
compver.patch++;
|
|
12003
|
+
} else {
|
|
12004
|
+
compver.prerelease.push(0);
|
|
12005
|
+
}
|
|
12006
|
+
compver.raw = compver.format();
|
|
12007
|
+
/* fallthrough */
|
|
12008
|
+
case '':
|
|
12009
|
+
case '>=':
|
|
12010
|
+
if (!setMin || gt(compver, setMin)) {
|
|
12011
|
+
setMin = compver;
|
|
12012
|
+
}
|
|
12013
|
+
break
|
|
12014
|
+
case '<':
|
|
12015
|
+
case '<=':
|
|
12016
|
+
/* Ignore maximum versions */
|
|
12017
|
+
break
|
|
12018
|
+
/* istanbul ignore next */
|
|
12019
|
+
default:
|
|
12020
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`)
|
|
12021
|
+
}
|
|
12022
|
+
});
|
|
12023
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
12024
|
+
minver = setMin;
|
|
12025
|
+
}
|
|
12026
|
+
}
|
|
12027
|
+
|
|
12028
|
+
if (minver && range.test(minver)) {
|
|
12029
|
+
return minver
|
|
12030
|
+
}
|
|
12031
|
+
|
|
12032
|
+
return null
|
|
12033
|
+
};
|
|
12034
|
+
minVersion_1 = minVersion;
|
|
12035
|
+
return minVersion_1;
|
|
12036
|
+
}
|
|
12037
|
+
|
|
12038
|
+
var valid;
|
|
12039
|
+
var hasRequiredValid;
|
|
12040
|
+
|
|
12041
|
+
function requireValid () {
|
|
12042
|
+
if (hasRequiredValid) return valid;
|
|
12043
|
+
hasRequiredValid = 1;
|
|
12044
|
+
|
|
12045
|
+
const Range = requireRange();
|
|
12046
|
+
const validRange = (range, options) => {
|
|
12047
|
+
try {
|
|
12048
|
+
// Return '*' instead of '' so that truthiness works.
|
|
12049
|
+
// This will throw if it's invalid anyway
|
|
12050
|
+
return new Range(range, options).range || '*'
|
|
12051
|
+
} catch (er) {
|
|
12052
|
+
return null
|
|
12053
|
+
}
|
|
12054
|
+
};
|
|
12055
|
+
valid = validRange;
|
|
12056
|
+
return valid;
|
|
12057
|
+
}
|
|
12058
|
+
|
|
12059
|
+
var outside_1;
|
|
12060
|
+
var hasRequiredOutside;
|
|
12061
|
+
|
|
12062
|
+
function requireOutside () {
|
|
12063
|
+
if (hasRequiredOutside) return outside_1;
|
|
12064
|
+
hasRequiredOutside = 1;
|
|
12065
|
+
|
|
12066
|
+
const SemVer = requireSemver$1();
|
|
12067
|
+
const Comparator = requireComparator();
|
|
12068
|
+
const { ANY } = Comparator;
|
|
12069
|
+
const Range = requireRange();
|
|
12070
|
+
const satisfies = requireSatisfies();
|
|
12071
|
+
const gt = requireGt();
|
|
12072
|
+
const lt = requireLt();
|
|
12073
|
+
const lte = requireLte();
|
|
12074
|
+
const gte = requireGte();
|
|
12075
|
+
|
|
12076
|
+
const outside = (version, range, hilo, options) => {
|
|
12077
|
+
version = new SemVer(version, options);
|
|
12078
|
+
range = new Range(range, options);
|
|
12079
|
+
|
|
12080
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
12081
|
+
switch (hilo) {
|
|
12082
|
+
case '>':
|
|
12083
|
+
gtfn = gt;
|
|
12084
|
+
ltefn = lte;
|
|
12085
|
+
ltfn = lt;
|
|
12086
|
+
comp = '>';
|
|
12087
|
+
ecomp = '>=';
|
|
12088
|
+
break
|
|
12089
|
+
case '<':
|
|
12090
|
+
gtfn = lt;
|
|
12091
|
+
ltefn = gte;
|
|
12092
|
+
ltfn = gt;
|
|
12093
|
+
comp = '<';
|
|
12094
|
+
ecomp = '<=';
|
|
12095
|
+
break
|
|
12096
|
+
default:
|
|
12097
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
12098
|
+
}
|
|
12099
|
+
|
|
12100
|
+
// If it satisfies the range it is not outside
|
|
12101
|
+
if (satisfies(version, range, options)) {
|
|
12102
|
+
return false
|
|
12103
|
+
}
|
|
12104
|
+
|
|
12105
|
+
// From now on, variable terms are as if we're in "gtr" mode.
|
|
12106
|
+
// but note that everything is flipped for the "ltr" function.
|
|
12107
|
+
|
|
12108
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
12109
|
+
const comparators = range.set[i];
|
|
12110
|
+
|
|
12111
|
+
let high = null;
|
|
12112
|
+
let low = null;
|
|
12113
|
+
|
|
12114
|
+
comparators.forEach((comparator) => {
|
|
12115
|
+
if (comparator.semver === ANY) {
|
|
12116
|
+
comparator = new Comparator('>=0.0.0');
|
|
12117
|
+
}
|
|
12118
|
+
high = high || comparator;
|
|
12119
|
+
low = low || comparator;
|
|
12120
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
12121
|
+
high = comparator;
|
|
12122
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
12123
|
+
low = comparator;
|
|
12124
|
+
}
|
|
12125
|
+
});
|
|
12126
|
+
|
|
12127
|
+
// If the edge version comparator has a operator then our version
|
|
12128
|
+
// isn't outside it
|
|
12129
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
12130
|
+
return false
|
|
12131
|
+
}
|
|
12132
|
+
|
|
12133
|
+
// If the lowest version comparator has an operator and our version
|
|
12134
|
+
// is less than it then it isn't higher than the range
|
|
12135
|
+
if ((!low.operator || low.operator === comp) &&
|
|
12136
|
+
ltefn(version, low.semver)) {
|
|
12137
|
+
return false
|
|
12138
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
12139
|
+
return false
|
|
12140
|
+
}
|
|
12141
|
+
}
|
|
12142
|
+
return true
|
|
12143
|
+
};
|
|
12144
|
+
|
|
12145
|
+
outside_1 = outside;
|
|
12146
|
+
return outside_1;
|
|
12147
|
+
}
|
|
12148
|
+
|
|
12149
|
+
var gtr_1;
|
|
12150
|
+
var hasRequiredGtr;
|
|
12151
|
+
|
|
12152
|
+
function requireGtr () {
|
|
12153
|
+
if (hasRequiredGtr) return gtr_1;
|
|
12154
|
+
hasRequiredGtr = 1;
|
|
12155
|
+
|
|
12156
|
+
// Determine if version is greater than all the versions possible in the range.
|
|
12157
|
+
const outside = requireOutside();
|
|
12158
|
+
const gtr = (version, range, options) => outside(version, range, '>', options);
|
|
12159
|
+
gtr_1 = gtr;
|
|
12160
|
+
return gtr_1;
|
|
12161
|
+
}
|
|
12162
|
+
|
|
12163
|
+
var ltr_1;
|
|
12164
|
+
var hasRequiredLtr;
|
|
12165
|
+
|
|
12166
|
+
function requireLtr () {
|
|
12167
|
+
if (hasRequiredLtr) return ltr_1;
|
|
12168
|
+
hasRequiredLtr = 1;
|
|
12169
|
+
|
|
12170
|
+
const outside = requireOutside();
|
|
12171
|
+
// Determine if version is less than all the versions possible in the range
|
|
12172
|
+
const ltr = (version, range, options) => outside(version, range, '<', options);
|
|
12173
|
+
ltr_1 = ltr;
|
|
12174
|
+
return ltr_1;
|
|
12175
|
+
}
|
|
12176
|
+
|
|
12177
|
+
var intersects_1;
|
|
12178
|
+
var hasRequiredIntersects;
|
|
12179
|
+
|
|
12180
|
+
function requireIntersects () {
|
|
12181
|
+
if (hasRequiredIntersects) return intersects_1;
|
|
12182
|
+
hasRequiredIntersects = 1;
|
|
12183
|
+
|
|
12184
|
+
const Range = requireRange();
|
|
12185
|
+
const intersects = (r1, r2, options) => {
|
|
12186
|
+
r1 = new Range(r1, options);
|
|
12187
|
+
r2 = new Range(r2, options);
|
|
12188
|
+
return r1.intersects(r2, options)
|
|
12189
|
+
};
|
|
12190
|
+
intersects_1 = intersects;
|
|
12191
|
+
return intersects_1;
|
|
12192
|
+
}
|
|
12193
|
+
|
|
12194
|
+
var simplify;
|
|
12195
|
+
var hasRequiredSimplify;
|
|
12196
|
+
|
|
12197
|
+
function requireSimplify () {
|
|
12198
|
+
if (hasRequiredSimplify) return simplify;
|
|
12199
|
+
hasRequiredSimplify = 1;
|
|
12200
|
+
|
|
12201
|
+
// given a set of versions and a range, create a "simplified" range
|
|
12202
|
+
// that includes the same versions that the original range does
|
|
12203
|
+
// If the original range is shorter than the simplified one, return that.
|
|
12204
|
+
const satisfies = requireSatisfies();
|
|
12205
|
+
const compare = requireCompare();
|
|
12206
|
+
simplify = (versions, range, options) => {
|
|
12207
|
+
const set = [];
|
|
12208
|
+
let first = null;
|
|
12209
|
+
let prev = null;
|
|
12210
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
12211
|
+
for (const version of v) {
|
|
12212
|
+
const included = satisfies(version, range, options);
|
|
12213
|
+
if (included) {
|
|
12214
|
+
prev = version;
|
|
12215
|
+
if (!first) {
|
|
12216
|
+
first = version;
|
|
12217
|
+
}
|
|
12218
|
+
} else {
|
|
12219
|
+
if (prev) {
|
|
12220
|
+
set.push([first, prev]);
|
|
12221
|
+
}
|
|
12222
|
+
prev = null;
|
|
12223
|
+
first = null;
|
|
12224
|
+
}
|
|
12225
|
+
}
|
|
12226
|
+
if (first) {
|
|
12227
|
+
set.push([first, null]);
|
|
12228
|
+
}
|
|
12229
|
+
|
|
12230
|
+
const ranges = [];
|
|
12231
|
+
for (const [min, max] of set) {
|
|
12232
|
+
if (min === max) {
|
|
12233
|
+
ranges.push(min);
|
|
12234
|
+
} else if (!max && min === v[0]) {
|
|
12235
|
+
ranges.push('*');
|
|
12236
|
+
} else if (!max) {
|
|
12237
|
+
ranges.push(`>=${min}`);
|
|
12238
|
+
} else if (min === v[0]) {
|
|
12239
|
+
ranges.push(`<=${max}`);
|
|
12240
|
+
} else {
|
|
12241
|
+
ranges.push(`${min} - ${max}`);
|
|
12242
|
+
}
|
|
12243
|
+
}
|
|
12244
|
+
const simplified = ranges.join(' || ');
|
|
12245
|
+
const original = typeof range.raw === 'string' ? range.raw : String(range);
|
|
12246
|
+
return simplified.length < original.length ? simplified : range
|
|
12247
|
+
};
|
|
12248
|
+
return simplify;
|
|
12249
|
+
}
|
|
12250
|
+
|
|
12251
|
+
var subset_1;
|
|
12252
|
+
var hasRequiredSubset;
|
|
12253
|
+
|
|
12254
|
+
function requireSubset () {
|
|
12255
|
+
if (hasRequiredSubset) return subset_1;
|
|
12256
|
+
hasRequiredSubset = 1;
|
|
12257
|
+
|
|
12258
|
+
const Range = requireRange();
|
|
12259
|
+
const Comparator = requireComparator();
|
|
12260
|
+
const { ANY } = Comparator;
|
|
12261
|
+
const satisfies = requireSatisfies();
|
|
12262
|
+
const compare = requireCompare();
|
|
12263
|
+
|
|
12264
|
+
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
|
|
12265
|
+
// - Every simple range `r1, r2, ...` is a null set, OR
|
|
12266
|
+
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
|
|
12267
|
+
// some `R1, R2, ...`
|
|
12268
|
+
//
|
|
12269
|
+
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
|
|
12270
|
+
// - If c is only the ANY comparator
|
|
12271
|
+
// - If C is only the ANY comparator, return true
|
|
12272
|
+
// - Else if in prerelease mode, return false
|
|
12273
|
+
// - else replace c with `[>=0.0.0]`
|
|
12274
|
+
// - If C is only the ANY comparator
|
|
12275
|
+
// - if in prerelease mode, return true
|
|
12276
|
+
// - else replace C with `[>=0.0.0]`
|
|
12277
|
+
// - Let EQ be the set of = comparators in c
|
|
12278
|
+
// - If EQ is more than one, return true (null set)
|
|
12279
|
+
// - Let GT be the highest > or >= comparator in c
|
|
12280
|
+
// - Let LT be the lowest < or <= comparator in c
|
|
12281
|
+
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
|
|
12282
|
+
// - If any C is a = range, and GT or LT are set, return false
|
|
12283
|
+
// - If EQ
|
|
12284
|
+
// - If GT, and EQ does not satisfy GT, return true (null set)
|
|
12285
|
+
// - If LT, and EQ does not satisfy LT, return true (null set)
|
|
12286
|
+
// - If EQ satisfies every C, return true
|
|
12287
|
+
// - Else return false
|
|
12288
|
+
// - If GT
|
|
12289
|
+
// - If GT.semver is lower than any > or >= comp in C, return false
|
|
12290
|
+
// - If GT is >=, and GT.semver does not satisfy every C, return false
|
|
12291
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
12292
|
+
// - If no C has a prerelease and the GT.semver tuple, return false
|
|
12293
|
+
// - If LT
|
|
12294
|
+
// - If LT.semver is greater than any < or <= comp in C, return false
|
|
12295
|
+
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
|
12296
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
12297
|
+
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
12298
|
+
// - Else return true
|
|
12299
|
+
|
|
12300
|
+
const subset = (sub, dom, options = {}) => {
|
|
12301
|
+
if (sub === dom) {
|
|
12302
|
+
return true
|
|
12303
|
+
}
|
|
12304
|
+
|
|
12305
|
+
sub = new Range(sub, options);
|
|
12306
|
+
dom = new Range(dom, options);
|
|
12307
|
+
let sawNonNull = false;
|
|
12308
|
+
|
|
12309
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
12310
|
+
for (const simpleDom of dom.set) {
|
|
12311
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
12312
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
12313
|
+
if (isSub) {
|
|
12314
|
+
continue OUTER
|
|
12315
|
+
}
|
|
12316
|
+
}
|
|
12317
|
+
// the null set is a subset of everything, but null simple ranges in
|
|
12318
|
+
// a complex range should be ignored. so if we saw a non-null range,
|
|
12319
|
+
// then we know this isn't a subset, but if EVERY simple range was null,
|
|
12320
|
+
// then it is a subset.
|
|
12321
|
+
if (sawNonNull) {
|
|
12322
|
+
return false
|
|
12323
|
+
}
|
|
12324
|
+
}
|
|
12325
|
+
return true
|
|
12326
|
+
};
|
|
12327
|
+
|
|
12328
|
+
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')];
|
|
12329
|
+
const minimumVersion = [new Comparator('>=0.0.0')];
|
|
12330
|
+
|
|
12331
|
+
const simpleSubset = (sub, dom, options) => {
|
|
12332
|
+
if (sub === dom) {
|
|
12333
|
+
return true
|
|
12334
|
+
}
|
|
12335
|
+
|
|
12336
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
12337
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
12338
|
+
return true
|
|
12339
|
+
} else if (options.includePrerelease) {
|
|
12340
|
+
sub = minimumVersionWithPreRelease;
|
|
12341
|
+
} else {
|
|
12342
|
+
sub = minimumVersion;
|
|
12343
|
+
}
|
|
12344
|
+
}
|
|
12345
|
+
|
|
12346
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
12347
|
+
if (options.includePrerelease) {
|
|
12348
|
+
return true
|
|
12349
|
+
} else {
|
|
12350
|
+
dom = minimumVersion;
|
|
12351
|
+
}
|
|
12352
|
+
}
|
|
12353
|
+
|
|
12354
|
+
const eqSet = new Set();
|
|
12355
|
+
let gt, lt;
|
|
12356
|
+
for (const c of sub) {
|
|
12357
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
12358
|
+
gt = higherGT(gt, c, options);
|
|
12359
|
+
} else if (c.operator === '<' || c.operator === '<=') {
|
|
12360
|
+
lt = lowerLT(lt, c, options);
|
|
12361
|
+
} else {
|
|
12362
|
+
eqSet.add(c.semver);
|
|
12363
|
+
}
|
|
12364
|
+
}
|
|
12365
|
+
|
|
12366
|
+
if (eqSet.size > 1) {
|
|
12367
|
+
return null
|
|
12368
|
+
}
|
|
12369
|
+
|
|
12370
|
+
let gtltComp;
|
|
12371
|
+
if (gt && lt) {
|
|
12372
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
12373
|
+
if (gtltComp > 0) {
|
|
12374
|
+
return null
|
|
12375
|
+
} else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
|
|
12376
|
+
return null
|
|
12377
|
+
}
|
|
12378
|
+
}
|
|
12379
|
+
|
|
12380
|
+
// will iterate one or zero times
|
|
12381
|
+
for (const eq of eqSet) {
|
|
12382
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
12383
|
+
return null
|
|
12384
|
+
}
|
|
12385
|
+
|
|
12386
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
12387
|
+
return null
|
|
12388
|
+
}
|
|
12389
|
+
|
|
12390
|
+
for (const c of dom) {
|
|
12391
|
+
if (!satisfies(eq, String(c), options)) {
|
|
12392
|
+
return false
|
|
12393
|
+
}
|
|
12394
|
+
}
|
|
12395
|
+
|
|
12396
|
+
return true
|
|
12397
|
+
}
|
|
12398
|
+
|
|
12399
|
+
let higher, lower;
|
|
12400
|
+
let hasDomLT, hasDomGT;
|
|
12401
|
+
// if the subset has a prerelease, we need a comparator in the superset
|
|
12402
|
+
// with the same tuple and a prerelease, or it's not a subset
|
|
12403
|
+
let needDomLTPre = lt &&
|
|
12404
|
+
!options.includePrerelease &&
|
|
12405
|
+
lt.semver.prerelease.length ? lt.semver : false;
|
|
12406
|
+
let needDomGTPre = gt &&
|
|
12407
|
+
!options.includePrerelease &&
|
|
12408
|
+
gt.semver.prerelease.length ? gt.semver : false;
|
|
12409
|
+
// exception: <1.2.3-0 is the same as <1.2.3
|
|
12410
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
|
|
12411
|
+
lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
|
|
12412
|
+
needDomLTPre = false;
|
|
12413
|
+
}
|
|
12414
|
+
|
|
12415
|
+
for (const c of dom) {
|
|
12416
|
+
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
|
|
12417
|
+
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
|
|
12418
|
+
if (gt) {
|
|
12419
|
+
if (needDomGTPre) {
|
|
12420
|
+
if (c.semver.prerelease && c.semver.prerelease.length &&
|
|
12421
|
+
c.semver.major === needDomGTPre.major &&
|
|
12422
|
+
c.semver.minor === needDomGTPre.minor &&
|
|
12423
|
+
c.semver.patch === needDomGTPre.patch) {
|
|
12424
|
+
needDomGTPre = false;
|
|
12425
|
+
}
|
|
12426
|
+
}
|
|
12427
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
12428
|
+
higher = higherGT(gt, c, options);
|
|
12429
|
+
if (higher === c && higher !== gt) {
|
|
12430
|
+
return false
|
|
12431
|
+
}
|
|
12432
|
+
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
|
|
12433
|
+
return false
|
|
12434
|
+
}
|
|
12435
|
+
}
|
|
12436
|
+
if (lt) {
|
|
12437
|
+
if (needDomLTPre) {
|
|
12438
|
+
if (c.semver.prerelease && c.semver.prerelease.length &&
|
|
12439
|
+
c.semver.major === needDomLTPre.major &&
|
|
12440
|
+
c.semver.minor === needDomLTPre.minor &&
|
|
12441
|
+
c.semver.patch === needDomLTPre.patch) {
|
|
12442
|
+
needDomLTPre = false;
|
|
12443
|
+
}
|
|
12444
|
+
}
|
|
12445
|
+
if (c.operator === '<' || c.operator === '<=') {
|
|
12446
|
+
lower = lowerLT(lt, c, options);
|
|
12447
|
+
if (lower === c && lower !== lt) {
|
|
12448
|
+
return false
|
|
12449
|
+
}
|
|
12450
|
+
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
|
|
12451
|
+
return false
|
|
12452
|
+
}
|
|
12453
|
+
}
|
|
12454
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
12455
|
+
return false
|
|
12456
|
+
}
|
|
12457
|
+
}
|
|
12458
|
+
|
|
12459
|
+
// if there was a < or >, and nothing in the dom, then must be false
|
|
12460
|
+
// UNLESS it was limited by another range in the other direction.
|
|
12461
|
+
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
|
|
12462
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
12463
|
+
return false
|
|
12464
|
+
}
|
|
12465
|
+
|
|
12466
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
12467
|
+
return false
|
|
12468
|
+
}
|
|
12469
|
+
|
|
12470
|
+
// we needed a prerelease range in a specific tuple, but didn't get one
|
|
12471
|
+
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
|
|
12472
|
+
// because it includes prereleases in the 1.2.3 tuple
|
|
12473
|
+
if (needDomGTPre || needDomLTPre) {
|
|
12474
|
+
return false
|
|
12475
|
+
}
|
|
12476
|
+
|
|
12477
|
+
return true
|
|
12478
|
+
};
|
|
12479
|
+
|
|
12480
|
+
// >=1.2.3 is lower than >1.2.3
|
|
12481
|
+
const higherGT = (a, b, options) => {
|
|
12482
|
+
if (!a) {
|
|
12483
|
+
return b
|
|
12484
|
+
}
|
|
12485
|
+
const comp = compare(a.semver, b.semver, options);
|
|
12486
|
+
return comp > 0 ? a
|
|
12487
|
+
: comp < 0 ? b
|
|
12488
|
+
: b.operator === '>' && a.operator === '>=' ? b
|
|
12489
|
+
: a
|
|
12490
|
+
};
|
|
12491
|
+
|
|
12492
|
+
// <=1.2.3 is higher than <1.2.3
|
|
12493
|
+
const lowerLT = (a, b, options) => {
|
|
12494
|
+
if (!a) {
|
|
12495
|
+
return b
|
|
12496
|
+
}
|
|
12497
|
+
const comp = compare(a.semver, b.semver, options);
|
|
12498
|
+
return comp < 0 ? a
|
|
12499
|
+
: comp > 0 ? b
|
|
12500
|
+
: b.operator === '<' && a.operator === '<=' ? b
|
|
12501
|
+
: a
|
|
12502
|
+
};
|
|
12503
|
+
|
|
12504
|
+
subset_1 = subset;
|
|
12505
|
+
return subset_1;
|
|
12506
|
+
}
|
|
12507
|
+
|
|
12508
|
+
var semver;
|
|
12509
|
+
var hasRequiredSemver;
|
|
12510
|
+
|
|
12511
|
+
function requireSemver () {
|
|
12512
|
+
if (hasRequiredSemver) return semver;
|
|
12513
|
+
hasRequiredSemver = 1;
|
|
12514
|
+
|
|
12515
|
+
// just pre-load all the stuff that index.js lazily exports
|
|
12516
|
+
const internalRe = requireRe();
|
|
12517
|
+
const constants = requireConstants();
|
|
12518
|
+
const SemVer = requireSemver$1();
|
|
12519
|
+
const identifiers = requireIdentifiers();
|
|
12520
|
+
const parse = requireParse();
|
|
12521
|
+
const valid = requireValid$1();
|
|
12522
|
+
const clean = requireClean();
|
|
12523
|
+
const inc = requireInc();
|
|
12524
|
+
const diff = requireDiff();
|
|
12525
|
+
const major = requireMajor();
|
|
12526
|
+
const minor = requireMinor();
|
|
12527
|
+
const patch = requirePatch();
|
|
12528
|
+
const prerelease = requirePrerelease();
|
|
12529
|
+
const compare = requireCompare();
|
|
12530
|
+
const rcompare = requireRcompare();
|
|
12531
|
+
const compareLoose = requireCompareLoose();
|
|
12532
|
+
const compareBuild = requireCompareBuild();
|
|
12533
|
+
const sort = requireSort();
|
|
12534
|
+
const rsort = requireRsort();
|
|
12535
|
+
const gt = requireGt();
|
|
12536
|
+
const lt = requireLt();
|
|
12537
|
+
const eq = requireEq();
|
|
12538
|
+
const neq = requireNeq();
|
|
12539
|
+
const gte = requireGte();
|
|
12540
|
+
const lte = requireLte();
|
|
12541
|
+
const cmp = requireCmp();
|
|
12542
|
+
const coerce = requireCoerce();
|
|
12543
|
+
const Comparator = requireComparator();
|
|
12544
|
+
const Range = requireRange();
|
|
12545
|
+
const satisfies = requireSatisfies();
|
|
12546
|
+
const toComparators = requireToComparators();
|
|
12547
|
+
const maxSatisfying = requireMaxSatisfying();
|
|
12548
|
+
const minSatisfying = requireMinSatisfying();
|
|
12549
|
+
const minVersion = requireMinVersion();
|
|
12550
|
+
const validRange = requireValid();
|
|
12551
|
+
const outside = requireOutside();
|
|
12552
|
+
const gtr = requireGtr();
|
|
12553
|
+
const ltr = requireLtr();
|
|
12554
|
+
const intersects = requireIntersects();
|
|
12555
|
+
const simplifyRange = requireSimplify();
|
|
12556
|
+
const subset = requireSubset();
|
|
12557
|
+
semver = {
|
|
12558
|
+
parse,
|
|
12559
|
+
valid,
|
|
12560
|
+
clean,
|
|
12561
|
+
inc,
|
|
12562
|
+
diff,
|
|
12563
|
+
major,
|
|
12564
|
+
minor,
|
|
12565
|
+
patch,
|
|
12566
|
+
prerelease,
|
|
12567
|
+
compare,
|
|
12568
|
+
rcompare,
|
|
12569
|
+
compareLoose,
|
|
12570
|
+
compareBuild,
|
|
12571
|
+
sort,
|
|
12572
|
+
rsort,
|
|
12573
|
+
gt,
|
|
12574
|
+
lt,
|
|
12575
|
+
eq,
|
|
12576
|
+
neq,
|
|
12577
|
+
gte,
|
|
12578
|
+
lte,
|
|
12579
|
+
cmp,
|
|
12580
|
+
coerce,
|
|
12581
|
+
Comparator,
|
|
12582
|
+
Range,
|
|
12583
|
+
satisfies,
|
|
12584
|
+
toComparators,
|
|
12585
|
+
maxSatisfying,
|
|
12586
|
+
minSatisfying,
|
|
12587
|
+
minVersion,
|
|
12588
|
+
validRange,
|
|
12589
|
+
outside,
|
|
12590
|
+
gtr,
|
|
12591
|
+
ltr,
|
|
12592
|
+
intersects,
|
|
12593
|
+
simplifyRange,
|
|
12594
|
+
subset,
|
|
12595
|
+
SemVer,
|
|
12596
|
+
re: internalRe.re,
|
|
12597
|
+
src: internalRe.src,
|
|
12598
|
+
tokens: internalRe.t,
|
|
12599
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
12600
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
12601
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
12602
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers,
|
|
12603
|
+
};
|
|
12604
|
+
return semver;
|
|
12605
|
+
}
|
|
12606
|
+
|
|
12607
|
+
var semverExports = requireSemver();
|
|
12608
|
+
|
|
12609
|
+
const DELAY_INTERVAL_MS = 10;
|
|
12610
|
+
const MAX_NEXT_REQUEST_DELAY = 1e4 / DELAY_INTERVAL_MS;
|
|
12611
|
+
function getRequestLooper(req, options) {
|
|
12612
|
+
return new rxjs.Observable((subscriber) => {
|
|
12613
|
+
let nextQuery = undefined;
|
|
12614
|
+
let subscription = undefined;
|
|
12615
|
+
let loadingState = data.LoadingState.Loading;
|
|
12616
|
+
let nextRequestDelay = 1;
|
|
12617
|
+
let count = 1;
|
|
12618
|
+
let shouldCancel = false;
|
|
12619
|
+
const observer = {
|
|
12620
|
+
next: (rsp) => {
|
|
12621
|
+
loadingState = rsp.state;
|
|
12622
|
+
let checkstate = false;
|
|
12623
|
+
if (loadingState !== data.LoadingState.Error) {
|
|
12624
|
+
nextQuery = options.getNextQuery(rsp);
|
|
12625
|
+
const _shouldCancel = options.shouldCancel();
|
|
12626
|
+
if (nextQuery && _shouldCancel) {
|
|
12627
|
+
shouldCancel = _shouldCancel;
|
|
12628
|
+
nextQuery = undefined;
|
|
12629
|
+
}
|
|
12630
|
+
checkstate = true;
|
|
12631
|
+
}
|
|
12632
|
+
const data$1 = options.process(rsp.data);
|
|
12633
|
+
if (checkstate) {
|
|
12634
|
+
if (nextQuery) {
|
|
12635
|
+
if (data$1.length && data$1[0].length) {
|
|
12636
|
+
loadingState = data.LoadingState.Streaming;
|
|
12637
|
+
} else {
|
|
12638
|
+
loadingState = data.LoadingState.Loading;
|
|
12639
|
+
}
|
|
12640
|
+
nextRequestDelay = nextRequestDelay * 2 > MAX_NEXT_REQUEST_DELAY ? MAX_NEXT_REQUEST_DELAY : nextRequestDelay * 2;
|
|
12641
|
+
} else {
|
|
12642
|
+
loadingState = data.LoadingState.Done;
|
|
12643
|
+
nextRequestDelay = 0;
|
|
12644
|
+
}
|
|
12645
|
+
}
|
|
12646
|
+
subscriber.next({ ...rsp, data: data$1, state: loadingState, key: req.requestId });
|
|
12647
|
+
},
|
|
12648
|
+
error: (err) => {
|
|
12649
|
+
subscriber.error(err);
|
|
12650
|
+
},
|
|
12651
|
+
complete: () => {
|
|
12652
|
+
if (subscription) {
|
|
12653
|
+
subscription.unsubscribe();
|
|
12654
|
+
subscription = undefined;
|
|
12655
|
+
}
|
|
12656
|
+
if (nextQuery) {
|
|
12657
|
+
const next = nextQuery;
|
|
12658
|
+
setTimeout(() => {
|
|
12659
|
+
subscription = options.query({ ...req, requestId: `${req.requestId}.${++count}`, targets: [next] }).subscribe(observer);
|
|
12660
|
+
nextQuery = undefined;
|
|
12661
|
+
}, nextRequestDelay * DELAY_INTERVAL_MS);
|
|
12662
|
+
} else {
|
|
12663
|
+
subscriber.complete();
|
|
12664
|
+
}
|
|
12665
|
+
}
|
|
12666
|
+
};
|
|
12667
|
+
subscription = options.query(req).subscribe(observer);
|
|
12668
|
+
return function unsubscribe() {
|
|
12669
|
+
observer.complete();
|
|
12670
|
+
if (nextQuery || shouldCancel) {
|
|
12671
|
+
options.onCancel();
|
|
12672
|
+
}
|
|
12673
|
+
nextQuery = undefined;
|
|
12674
|
+
};
|
|
12675
|
+
});
|
|
12676
|
+
}
|
|
12677
|
+
|
|
12678
|
+
var __defProp = Object.defineProperty;
|
|
12679
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12680
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
12681
|
+
const RUNNING_STATUSES = ["started", "submitted", "running"];
|
|
12682
|
+
const isRunning = (status = "") => RUNNING_STATUSES.includes(status);
|
|
12683
|
+
const isCustomMeta = (meta) => {
|
|
12684
|
+
return !!(typeof meta === "object" && (meta == null ? undefined : meta.hasOwnProperty("queryID")) && (meta == null ? undefined : meta.hasOwnProperty("status")));
|
|
12685
|
+
};
|
|
12686
|
+
class DatasourceWithAsyncBackend extends runtime.DataSourceWithBackend {
|
|
12687
|
+
constructor(instanceSettings) {
|
|
12688
|
+
var _a;
|
|
12689
|
+
super(instanceSettings);
|
|
12690
|
+
__publicField(this, "runningQueries", {});
|
|
12691
|
+
__publicField(this, "requestCounter", 100);
|
|
12692
|
+
__publicField(this, "requestIdPrefix");
|
|
12693
|
+
// cancel sets shouldCancel to tell requestLooper to cancel the query
|
|
12694
|
+
__publicField(this, "cancel", (target) => {
|
|
12695
|
+
this.storeQuery(target, { shouldCancel: true });
|
|
12696
|
+
});
|
|
12697
|
+
this.requestIdPrefix = (_a = instanceSettings.uid) != null ? _a : instanceSettings.id;
|
|
12698
|
+
}
|
|
12699
|
+
query(request) {
|
|
12700
|
+
const targets = this.filterQuery ? request.targets.filter(this.filterQuery) : request.targets;
|
|
12701
|
+
if (!targets.length) {
|
|
12702
|
+
return rxjs.of({ data: [] });
|
|
12703
|
+
}
|
|
12704
|
+
const all = [];
|
|
12705
|
+
for (let target of targets) {
|
|
12706
|
+
if (target.hide) {
|
|
12707
|
+
continue;
|
|
12708
|
+
}
|
|
12709
|
+
all.push(this.doSingle(target, request));
|
|
12710
|
+
}
|
|
12711
|
+
return rxjs.merge(...all);
|
|
12712
|
+
}
|
|
12713
|
+
storeQuery(target, queryInfo) {
|
|
12714
|
+
const key = JSON.stringify(target);
|
|
12715
|
+
const existingQueryInfo = this.runningQueries[key] || {};
|
|
12716
|
+
this.runningQueries[key] = { ...existingQueryInfo, ...queryInfo };
|
|
12717
|
+
}
|
|
12718
|
+
getQuery(target) {
|
|
12719
|
+
const key = JSON.stringify(target);
|
|
12720
|
+
return this.runningQueries[key] || {};
|
|
12721
|
+
}
|
|
12722
|
+
removeQuery(target) {
|
|
12723
|
+
const key = JSON.stringify(target);
|
|
12724
|
+
delete this.runningQueries[key];
|
|
12725
|
+
}
|
|
12726
|
+
doSingle(target, request) {
|
|
12727
|
+
let queryID = undefined;
|
|
12728
|
+
let status = undefined;
|
|
12729
|
+
let allData = [];
|
|
12730
|
+
return getRequestLooper(
|
|
12731
|
+
{ ...request, targets: [target], requestId: `${this.requestIdPrefix}_${this.requestCounter++}` },
|
|
12732
|
+
{
|
|
12733
|
+
/**
|
|
12734
|
+
* Additional query to execute if the current query is still in a running state
|
|
12735
|
+
*/
|
|
12736
|
+
getNextQuery: (rsp) => {
|
|
12737
|
+
var _a, _b;
|
|
12738
|
+
if ((_a = rsp.data) == null ? undefined : _a.length) {
|
|
12739
|
+
const first = rsp.data[0];
|
|
12740
|
+
const meta = (_b = first.meta) == null ? undefined : _b.custom;
|
|
12741
|
+
if (isCustomMeta(meta) && isRunning(meta.status)) {
|
|
12742
|
+
queryID = meta.queryID;
|
|
12743
|
+
status = meta.status;
|
|
12744
|
+
this.storeQuery(target, { queryID });
|
|
12745
|
+
return { ...target, queryID };
|
|
12746
|
+
}
|
|
12747
|
+
}
|
|
12748
|
+
this.removeQuery(target);
|
|
12749
|
+
return undefined;
|
|
12750
|
+
},
|
|
12751
|
+
/**
|
|
12752
|
+
* The original request
|
|
12753
|
+
*/
|
|
12754
|
+
query: (request2) => {
|
|
12755
|
+
const { range, targets, requestId, intervalMs, maxDataPoints } = request2;
|
|
12756
|
+
const [_query] = targets;
|
|
12757
|
+
const query = {
|
|
12758
|
+
..._query,
|
|
12759
|
+
meta: { queryFlow: "async" },
|
|
12760
|
+
intervalMs,
|
|
12761
|
+
maxDataPoints,
|
|
12762
|
+
// getRef optionally chained to support < v8.3.x of Grafana
|
|
12763
|
+
datasource: this == null ? undefined : this.getRef(),
|
|
12764
|
+
datasourceId: this.id,
|
|
12765
|
+
...this.applyTemplateVariables(_query, request2.scopedVars)
|
|
12766
|
+
};
|
|
12767
|
+
const cachingDisabled = !runtime.config.featureToggles.awsAsyncQueryCaching;
|
|
12768
|
+
if (cachingDisabled && isRunning(status)) {
|
|
12769
|
+
const requestSkipQueryCacheUnsupported = semverExports.lt(runtime.config.buildInfo.version, "10.2.3");
|
|
12770
|
+
if (requestSkipQueryCacheUnsupported) {
|
|
12771
|
+
return runtime.getBackendSrv().fetch({
|
|
12772
|
+
method: "POST",
|
|
12773
|
+
url: "/api/ds/query",
|
|
12774
|
+
headers: { "X-Cache-Skip": true },
|
|
12775
|
+
requestId,
|
|
12776
|
+
data: {
|
|
12777
|
+
queries: [query],
|
|
12778
|
+
range,
|
|
12779
|
+
from: range.from.valueOf().toString(),
|
|
12780
|
+
to: range.to.valueOf().toString()
|
|
12781
|
+
}
|
|
12782
|
+
}).pipe(
|
|
12783
|
+
operators$1.map((result) => ({ data: runtime.toDataQueryResponse(result).data })),
|
|
12784
|
+
operators$1.catchError((err) => rxjs.of(runtime.toDataQueryResponse(err)))
|
|
12785
|
+
);
|
|
12786
|
+
}
|
|
12787
|
+
return super.query({ ...request2, targets: [query], skipQueryCache: true });
|
|
12788
|
+
}
|
|
12789
|
+
return super.query({ ...request2, targets: [query] });
|
|
12790
|
+
},
|
|
12791
|
+
/**
|
|
12792
|
+
* Process the results
|
|
12793
|
+
*/
|
|
12794
|
+
process: (data) => {
|
|
12795
|
+
for (const frame of data) {
|
|
12796
|
+
if (frame.fields.length > 0) {
|
|
12797
|
+
allData.push(frame);
|
|
12798
|
+
}
|
|
12799
|
+
}
|
|
12800
|
+
return allData;
|
|
12801
|
+
},
|
|
12802
|
+
shouldCancel: () => {
|
|
12803
|
+
const { shouldCancel } = this.getQuery(target);
|
|
12804
|
+
return !!shouldCancel;
|
|
12805
|
+
},
|
|
12806
|
+
/**
|
|
12807
|
+
* Callback that gets executed when unsubscribed
|
|
12808
|
+
*/
|
|
12809
|
+
onCancel: () => {
|
|
12810
|
+
if (queryID) {
|
|
12811
|
+
this.removeQuery(target);
|
|
12812
|
+
this.postResource("cancel", {
|
|
12813
|
+
queryId: queryID
|
|
12814
|
+
}).catch((err) => {
|
|
12815
|
+
err.isHandled = true;
|
|
12816
|
+
console.error(`error cancelling query ID: ${queryID}`, err);
|
|
12817
|
+
});
|
|
12818
|
+
}
|
|
12819
|
+
}
|
|
12820
|
+
}
|
|
12821
|
+
);
|
|
12822
|
+
}
|
|
12823
|
+
}
|
|
12824
|
+
|
|
12825
|
+
const RunQueryButtons = (props) => {
|
|
12826
|
+
const { state } = props;
|
|
12827
|
+
const [running, setRunning] = React.useState(false);
|
|
12828
|
+
const [stopping, setStopping] = React.useState(false);
|
|
12829
|
+
const [prevState, setPrevState] = React.useState(state);
|
|
12830
|
+
const [lastQuery, setLastQuery] = React.useState(props.query);
|
|
12831
|
+
if (state !== prevState) {
|
|
12832
|
+
setPrevState(state);
|
|
12833
|
+
if (state && state !== data.LoadingState.Loading) {
|
|
12834
|
+
setRunning(false);
|
|
12835
|
+
setStopping(false);
|
|
12836
|
+
}
|
|
12837
|
+
}
|
|
12838
|
+
const onRunQuery = () => {
|
|
12839
|
+
setRunning(true);
|
|
12840
|
+
setLastQuery(props.query);
|
|
12841
|
+
props.onRunQuery();
|
|
12842
|
+
};
|
|
12843
|
+
const onCancelQuery = props.onCancelQuery ? () => {
|
|
12844
|
+
var _a;
|
|
12845
|
+
(_a = props.onCancelQuery) == null ? undefined : _a.call(props, lastQuery);
|
|
12846
|
+
setStopping(true);
|
|
12847
|
+
} : undefined;
|
|
12848
|
+
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
12849
|
+
ui.Button,
|
|
12850
|
+
{
|
|
12851
|
+
variant: props.enableRun ? "primary" : "secondary",
|
|
12852
|
+
size: "sm",
|
|
12853
|
+
onClick: onRunQuery,
|
|
12854
|
+
icon: running && !stopping ? "fa fa-spinner" : undefined,
|
|
12855
|
+
disabled: state === data.LoadingState.Loading || !props.enableRun
|
|
12856
|
+
},
|
|
12857
|
+
"Run query"
|
|
12858
|
+
), /* @__PURE__ */ React__default.default.createElement(
|
|
12859
|
+
ui.Button,
|
|
12860
|
+
{
|
|
12861
|
+
variant: running && !stopping ? "primary" : "secondary",
|
|
12862
|
+
size: "sm",
|
|
12863
|
+
disabled: !running || stopping,
|
|
12864
|
+
icon: stopping ? "fa fa-spinner" : undefined,
|
|
12865
|
+
onClick: onCancelQuery
|
|
12866
|
+
},
|
|
12867
|
+
"Stop query"
|
|
12868
|
+
));
|
|
12869
|
+
};
|
|
12870
|
+
|
|
9845
12871
|
exports.AccessoryButton = AccessoryButton;
|
|
9846
12872
|
exports.AdvancedHttpSettings = AdvancedHttpSettings;
|
|
9847
12873
|
exports.Auth = Auth;
|
|
@@ -9861,6 +12887,7 @@ exports.DataLinks = DataLinks;
|
|
|
9861
12887
|
exports.DataSourceDescription = DataSourceDescription;
|
|
9862
12888
|
exports.DataSourcePicker = DataSourcePicker;
|
|
9863
12889
|
exports.DatasetSelector = DatasetSelector;
|
|
12890
|
+
exports.DatasourceWithAsyncBackend = DatasourceWithAsyncBackend;
|
|
9864
12891
|
exports.DatePicker = DatePicker;
|
|
9865
12892
|
exports.DatePickerWithInput = DatePickerWithInput;
|
|
9866
12893
|
exports.DebounceInput = DebounceInput;
|
|
@@ -9896,6 +12923,7 @@ exports.QueryModellerBase = QueryModellerBase;
|
|
|
9896
12923
|
exports.QueryOptionGroup = QueryOptionGroup;
|
|
9897
12924
|
exports.RawQuery = RawQuery;
|
|
9898
12925
|
exports.RunQueryButton = RunQueryButton;
|
|
12926
|
+
exports.RunQueryButtons = RunQueryButtons;
|
|
9899
12927
|
exports.SQLEditor = SQLEditor;
|
|
9900
12928
|
exports.SQLEditorMode = SQLEditorMode;
|
|
9901
12929
|
exports.SQLEditorTestUtils = SQLEditorTestUtils;
|
|
@@ -9911,6 +12939,7 @@ exports.TableSelector = TableSelector;
|
|
|
9911
12939
|
exports.TokenType = TokenType;
|
|
9912
12940
|
exports.convertLegacyAuthProps = convertLegacyAuthProps;
|
|
9913
12941
|
exports.formatDate = formatDate;
|
|
12942
|
+
exports.getRequestLooper = getRequestLooper;
|
|
9914
12943
|
exports.getStandardSQLCompletionProvider = getStandardSQLCompletionProvider;
|
|
9915
12944
|
exports.grafanaStandardSQLLanguage = language;
|
|
9916
12945
|
exports.grafanaStandardSQLLanguageConf = conf;
|