From b4443344f7ca01bfeb73af2467d28e286c6dacda Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 3 Aug 2021 19:28:56 +0100 Subject: [PATCH 1/4] chore(NA): moving @kbn/rule-data-utils to babel transpiler --- packages/kbn-rule-data-utils/.babelrc | 3 +++ packages/kbn-rule-data-utils/BUILD.bazel | 22 +++++++++++++++------- packages/kbn-rule-data-utils/package.json | 4 ++-- packages/kbn-rule-data-utils/tsconfig.json | 11 ++++++----- 4 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 packages/kbn-rule-data-utils/.babelrc diff --git a/packages/kbn-rule-data-utils/.babelrc b/packages/kbn-rule-data-utils/.babelrc new file mode 100644 index 0000000000000..7da72d1779128 --- /dev/null +++ b/packages/kbn-rule-data-utils/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["@kbn/babel-preset/node_preset"] +} diff --git a/packages/kbn-rule-data-utils/BUILD.bazel b/packages/kbn-rule-data-utils/BUILD.bazel index ccd1793feb161..f29661f2a22ca 100644 --- a/packages/kbn-rule-data-utils/BUILD.bazel +++ b/packages/kbn-rule-data-utils/BUILD.bazel @@ -1,5 +1,6 @@ load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") +load("//src/dev/bazel:index.bzl", "jsts_transpiler") PKG_BASE_NAME = "kbn-rule-data-utils" PKG_REQUIRE_NAME = "@kbn/rule-data-utils" @@ -21,17 +22,23 @@ NPM_MODULE_EXTRA_FILES = [ "package.json", ] -SRC_DEPS = [ +RUNTIME_DEPS = [ "@npm//tslib", "@npm//utility-types", ] TYPES_DEPS = [ + "@npm//tslib", + "@npm//utility-types", "@npm//@types/jest", "@npm//@types/node", ] -DEPS = SRC_DEPS + TYPES_DEPS +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) ts_config( name = "tsconfig", @@ -42,14 +49,15 @@ ts_config( ) ts_project( - name = "tsc", + name = "tsc_types", args = ['--pretty'], srcs = SRCS, - deps = DEPS, + deps = TYPES_DEPS, declaration = True, declaration_map = True, - incremental = True, - out_dir = "target", + emit_declaration_only = True, + incremental = False, + out_dir = "target_types", source_map = True, root_dir = "src", tsconfig = ":tsconfig", @@ -58,7 +66,7 @@ ts_project( js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES, - deps = DEPS + [":tsc"], + deps = RUNTIME_DEPS + [":target_node", ":tsc_types"], package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], ) diff --git a/packages/kbn-rule-data-utils/package.json b/packages/kbn-rule-data-utils/package.json index 42223e51ec2d6..64bbb69d14403 100644 --- a/packages/kbn-rule-data-utils/package.json +++ b/packages/kbn-rule-data-utils/package.json @@ -1,7 +1,7 @@ { "name": "@kbn/rule-data-utils", - "main": "./target/index.js", - "types": "./target/index.d.ts", + "main": "./target_node/index.js", + "types": "./target_types/index.d.ts", "version": "1.0.0", "license": "SSPL-1.0 OR Elastic License 2.0", "private": true diff --git a/packages/kbn-rule-data-utils/tsconfig.json b/packages/kbn-rule-data-utils/tsconfig.json index 852393f01e594..c7d9dfe54a4ca 100644 --- a/packages/kbn-rule-data-utils/tsconfig.json +++ b/packages/kbn-rule-data-utils/tsconfig.json @@ -1,20 +1,21 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": true, - "outDir": "./target", - "stripInternal": false, "declaration": true, "declarationMap": true, - "rootDir": "./src", + "emitDeclarationOnly": true, + "incremental": false, + "outDir": "./target_types", + "rootDir": "src", "sourceMap": true, "sourceRoot": "../../../../packages/kbn-rule-data-utils/src", + "stripInternal": false, "types": [ "jest", "node" ] }, "include": [ - "./src/**/*.ts" + "src/**/*.ts" ] } From 6132373bc6507fc5ca18d781b4b67ab7ca20e53a Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 3 Aug 2021 21:17:44 +0100 Subject: [PATCH 2/4] chore(NA): update imports --- .../apm/public/components/alerting/register_apm_alerts.ts | 2 +- .../app/error_group_details/Distribution/index.tsx | 2 +- .../shared/charts/helper/get_alert_annotations.tsx | 2 +- .../components/shared/charts/latency_chart/index.tsx | 2 +- .../server/lib/alerts/register_error_count_alert_type.ts | 2 +- .../lib/alerts/register_transaction_duration_alert_type.ts | 2 +- .../register_transaction_duration_anomaly_alert_type.ts | 2 +- .../alerts/register_transaction_error_rate_alert_type.ts | 2 +- .../plugins/apm/server/lib/services/get_service_alerts.ts | 2 +- .../public/pages/alerts/alerts_flyout/index.tsx | 2 +- .../observability/public/pages/alerts/alerts_table.tsx | 6 +----- .../public/pages/alerts/alerts_table_t_grid.tsx | 2 +- .../public/pages/alerts/alerts_table_t_grid_actions.tsx | 2 +- .../observability/public/pages/alerts/decorate_response.ts | 7 +------ .../public/pages/alerts/render_cell_value.tsx | 2 +- .../observability/server/lib/rules/get_top_alerts.ts | 2 +- x-pack/plugins/observability/server/utils/queries.test.ts | 2 +- x-pack/plugins/observability/server/utils/queries.ts | 2 +- .../common/technical_rule_data_field_names.ts | 2 +- .../server/alert_data_client/alerts_client.ts | 6 +----- .../plugins/rule_registry/server/routes/get_alert_index.ts | 2 +- .../plugins/rule_registry/server/rule_data_client/types.ts | 2 +- .../rule_registry/server/rule_data_plugin_service/index.ts | 2 +- .../server/utils/create_persistence_rule_type_factory.ts | 2 +- .../timelines/common/search_strategy/timeline/index.ts | 2 +- .../timelines/server/search_strategy/timeline/index.ts | 6 ++++-- .../uptime/server/lib/alerts/duration_anomaly.test.ts | 2 +- .../plugins/uptime/server/lib/alerts/duration_anomaly.ts | 2 +- 28 files changed, 31 insertions(+), 42 deletions(-) diff --git a/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts b/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts index ff06c845ba4d3..27db09dd94a3f 100644 --- a/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts +++ b/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts @@ -12,7 +12,7 @@ import { ALERT_EVALUATION_THRESHOLD, ALERT_EVALUATION_VALUE, ALERT_SEVERITY_LEVEL, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import type { ObservabilityRuleTypeRegistry } from '../../../../observability/public'; import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; import { AlertType } from '../../../common/alert_types'; diff --git a/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx b/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx index e53aaf97cdf75..3cb77e83d4262 100644 --- a/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx +++ b/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx @@ -19,7 +19,7 @@ import { import { EuiTitle } from '@elastic/eui'; import d3 from 'd3'; import React, { Suspense, useState } from 'react'; -import { RULE_ID } from '@kbn/rule-data-utils/target/technical_field_names'; +import { RULE_ID } from '@kbn/rule-data-utils'; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { APIReturnType } from '../../../../services/rest/createCallApmApi'; import { asRelativeDateTimeRange } from '../../../../../common/utils/formatters'; diff --git a/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx b/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx index fa0725018f783..0d158b5e8170d 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx @@ -19,7 +19,7 @@ import { ALERT_UUID, RULE_ID, RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import React, { Dispatch, SetStateAction } from 'react'; import { EuiTheme } from 'src/plugins/kibana_react/common'; import { ValuesType } from 'utility-types'; diff --git a/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx index 1a89f070bb5cd..f96445597226e 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiSelect, EuiTitle } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { useHistory } from 'react-router-dom'; -import { RULE_ID } from '@kbn/rule-data-utils/target/technical_field_names'; +import { RULE_ID } from '@kbn/rule-data-utils'; import { AlertType } from '../../../../../common/alert_types'; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { LatencyAggregationType } from '../../../../../common/latency_aggregation_types'; diff --git a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts index bdd6b240c4bbc..7c625d3a4c6b2 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts @@ -10,7 +10,7 @@ import { take } from 'rxjs/operators'; import { ALERT_EVALUATION_THRESHOLD, ALERT_EVALUATION_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { ENVIRONMENT_NOT_DEFINED, diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts index c14675cb93987..5282cd793be8f 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts @@ -11,7 +11,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; import { ALERT_EVALUATION_THRESHOLD, ALERT_EVALUATION_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { getEnvironmentLabel, diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts index de0657d075d7f..bcce469370320 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts @@ -14,7 +14,7 @@ import { ALERT_EVALUATION_VALUE, ALERT_SEVERITY_LEVEL, ALERT_SEVERITY_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { ProcessorEvent } from '../../../common/processor_event'; import { getSeverity } from '../../../common/anomaly_detection'; diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts index a397302659538..5ca699ab9a84a 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts @@ -10,7 +10,7 @@ import { take } from 'rxjs/operators'; import { ALERT_EVALUATION_THRESHOLD, ALERT_EVALUATION_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import { ENVIRONMENT_NOT_DEFINED, getEnvironmentEsField, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts b/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts index a9fe55456ad4e..c9915cf9dce89 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EVENT_KIND } from '@kbn/rule-data-utils/target/technical_field_names'; +import { EVENT_KIND } from '@kbn/rule-data-utils'; import { RuleDataClient } from '../../../../rule_registry/server'; import { SERVICE_NAME, diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx index 53b5300e556c5..2bc241b19072e 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx @@ -28,7 +28,7 @@ import { ALERT_UUID, RULE_CATEGORY, RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import moment from 'moment-timezone'; import React, { useMemo } from 'react'; import type { TopAlert, TopAlertResponse } from '../'; diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_table.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_table.tsx index 28d211766cfe5..395c2a5253ec6 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_table.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts_table.tsx @@ -14,11 +14,7 @@ import { EuiLink, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { - ALERT_DURATION, - ALERT_SEVERITY_LEVEL, - ALERT_UUID, -} from '@kbn/rule-data-utils/target/technical_field_names'; +import { ALERT_DURATION, ALERT_SEVERITY_LEVEL, ALERT_UUID } from '@kbn/rule-data-utils'; import React, { Suspense, useMemo, useState } from 'react'; import { LazyAlertsFlyout } from '../..'; import { asDuration } from '../../../common/utils/formatters'; diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx index 77c2b5cbca0cf..ca41dabc054ad 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx @@ -16,7 +16,7 @@ import { ALERT_STATUS, ALERT_START, RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import type { TimelinesUIStart } from '../../../../timelines/public'; import type { TopAlert } from './'; diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid_actions.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid_actions.tsx index 1f5372c8f2fea..37755b8ec6a02 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid_actions.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid_actions.tsx @@ -14,7 +14,7 @@ import { EuiPopoverTitle, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { RULE_ID, RULE_NAME } from '@kbn/rule-data-utils/target/technical_field_names'; +import { RULE_ID, RULE_NAME } from '@kbn/rule-data-utils'; import React, { useState } from 'react'; import { format, parse } from 'url'; diff --git a/x-pack/plugins/observability/public/pages/alerts/decorate_response.ts b/x-pack/plugins/observability/public/pages/alerts/decorate_response.ts index e177bea6c6dac..2dc96135ddca9 100644 --- a/x-pack/plugins/observability/public/pages/alerts/decorate_response.ts +++ b/x-pack/plugins/observability/public/pages/alerts/decorate_response.ts @@ -5,12 +5,7 @@ * 2.0. */ -import { - RULE_ID, - RULE_NAME, - ALERT_STATUS, - ALERT_START, -} from '@kbn/rule-data-utils/target/technical_field_names'; +import { RULE_ID, RULE_NAME, ALERT_STATUS, ALERT_START } from '@kbn/rule-data-utils'; import type { TopAlertResponse, TopAlert } from '.'; import { parseTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields'; import { asDuration, asPercent } from '../../../common/utils/formatters'; diff --git a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx b/x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx index bb6d0ae6c0e40..84fd88f6b64a7 100644 --- a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx @@ -13,7 +13,7 @@ import { ALERT_STATUS, ALERT_START, RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import type { CellValueElementProps, TimelineNonEcsData } from '../../../../timelines/common'; import { TimestampTooltip } from '../../components/shared/timestamp_tooltip'; diff --git a/x-pack/plugins/observability/server/lib/rules/get_top_alerts.ts b/x-pack/plugins/observability/server/lib/rules/get_top_alerts.ts index db8191136686a..74e6a5bc177fe 100644 --- a/x-pack/plugins/observability/server/lib/rules/get_top_alerts.ts +++ b/x-pack/plugins/observability/server/lib/rules/get_top_alerts.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { EVENT_KIND, TIMESTAMP } from '@kbn/rule-data-utils/target/technical_field_names'; +import { EVENT_KIND, TIMESTAMP } from '@kbn/rule-data-utils'; import { RuleDataClient } from '../../../../rule_registry/server'; import type { AlertStatus } from '../../../common/typings'; import { kqlQuery, rangeQuery, alertStatusQuery } from '../../utils/queries'; diff --git a/x-pack/plugins/observability/server/utils/queries.test.ts b/x-pack/plugins/observability/server/utils/queries.test.ts index a0a63b73d7170..dab42fa604dc4 100644 --- a/x-pack/plugins/observability/server/utils/queries.test.ts +++ b/x-pack/plugins/observability/server/utils/queries.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_STATUS } from '@kbn/rule-data-utils/target/technical_field_names'; +import { ALERT_STATUS } from '@kbn/rule-data-utils'; import * as queries from './queries'; describe('queries', () => { diff --git a/x-pack/plugins/observability/server/utils/queries.ts b/x-pack/plugins/observability/server/utils/queries.ts index 2ee3291e7fb62..283779c312906 100644 --- a/x-pack/plugins/observability/server/utils/queries.ts +++ b/x-pack/plugins/observability/server/utils/queries.ts @@ -6,7 +6,7 @@ */ import type { estypes } from '@elastic/elasticsearch'; -import { ALERT_STATUS } from '@kbn/rule-data-utils/target/technical_field_names'; +import { ALERT_STATUS } from '@kbn/rule-data-utils'; import { esKuery } from '../../../../../src/plugins/data/server'; import { AlertStatus } from '../../common/typings'; diff --git a/x-pack/plugins/rule_registry/common/technical_rule_data_field_names.ts b/x-pack/plugins/rule_registry/common/technical_rule_data_field_names.ts index 5c954a31e79ac..47b00fb1348eb 100644 --- a/x-pack/plugins/rule_registry/common/technical_rule_data_field_names.ts +++ b/x-pack/plugins/rule_registry/common/technical_rule_data_field_names.ts @@ -5,4 +5,4 @@ * 2.0. */ -export * from '@kbn/rule-data-utils/target/technical_field_names'; +export * from '@kbn/rule-data-utils'; diff --git a/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts b/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts index 91282edf3778a..eb67698c86304 100644 --- a/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts +++ b/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts @@ -6,11 +6,7 @@ */ import { PublicMethodsOf } from '@kbn/utility-types'; import { decodeVersion, encodeHitVersion } from '@kbn/securitysolution-es-utils'; -import { - mapConsumerToIndexName, - validFeatureIds, - isValidFeatureId, -} from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import { mapConsumerToIndexName, validFeatureIds, isValidFeatureId } from '@kbn/rule-data-utils'; import { AlertTypeParams } from '../../../alerting/server'; import { diff --git a/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts b/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts index 3e3bde7429fe0..f3b0b9181c60f 100644 --- a/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts +++ b/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts @@ -8,7 +8,7 @@ import { IRouter } from 'kibana/server'; import { id as _id } from '@kbn/securitysolution-io-ts-list-types'; import { transformError } from '@kbn/securitysolution-es-utils'; -import { validFeatureIds } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import { validFeatureIds } from '@kbn/rule-data-utils'; import { RacRequestHandlerContext } from '../types'; import { BASE_RAC_ALERTS_API_PATH } from '../../common/constants'; diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts index 277121074f7f2..ef09dcc7550a0 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts @@ -7,7 +7,7 @@ import { ApiResponse } from '@elastic/elasticsearch'; import { BulkRequest, BulkResponse } from '@elastic/elasticsearch/api/types'; -import { ValidFeatureId } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import { ValidFeatureId } from '@kbn/rule-data-utils'; import { ElasticsearchClient } from 'kibana/server'; import { FieldDescriptor } from 'src/plugins/data/server'; diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index.ts index f81340889e4b5..e10b58a1c60c3 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index.ts @@ -6,7 +6,7 @@ */ import { ClusterPutComponentTemplate } from '@elastic/elasticsearch/api/requestParams'; import { estypes } from '@elastic/elasticsearch'; -import { ValidFeatureId } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import { ValidFeatureId } from '@kbn/rule-data-utils'; import { ElasticsearchClient, Logger } from 'kibana/server'; import { get, isEmpty } from 'lodash'; diff --git a/x-pack/plugins/rule_registry/server/utils/create_persistence_rule_type_factory.ts b/x-pack/plugins/rule_registry/server/utils/create_persistence_rule_type_factory.ts index 50e5b224f01d8..caf14e8ba3000 100644 --- a/x-pack/plugins/rule_registry/server/utils/create_persistence_rule_type_factory.ts +++ b/x-pack/plugins/rule_registry/server/utils/create_persistence_rule_type_factory.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_ID } from '@kbn/rule-data-utils/target/technical_field_names'; +import { ALERT_ID } from '@kbn/rule-data-utils'; import { CreatePersistenceRuleTypeFactory } from './persistence_types'; export const createPersistenceRuleTypeFactory: CreatePersistenceRuleTypeFactory = ({ diff --git a/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts b/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts index cb5e27ec84d47..da432b0e509d7 100644 --- a/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { ALERTS_CONSUMERS } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { ALERTS_CONSUMERS } from '@kbn/rule-data-utils'; import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts index 431a71faf847e..89356c178914d 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts @@ -5,14 +5,16 @@ * 2.0. */ -import { ALERT_OWNER, RULE_ID, SPACE_IDS } from '@kbn/rule-data-utils'; import { map, mergeMap, catchError } from 'rxjs/operators'; import { from } from 'rxjs'; import { + ALERT_OWNER, + RULE_ID, + SPACE_IDS, isValidFeatureId, mapConsumerToIndexName, ALERTS_CONSUMERS, -} from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +} from '@kbn/rule-data-utils'; import { AlertingAuthorizationEntity, diff --git a/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.test.ts b/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.test.ts index ce13ae4ce6cea..a51bbc49123dc 100644 --- a/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.test.ts +++ b/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.test.ts @@ -17,7 +17,7 @@ import { ALERT_SEVERITY_VALUE, ALERT_EVALUATION_VALUE, ALERT_EVALUATION_THRESHOLD, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; interface MockAnomaly { severity: AnomaliesTableRecord['severity']; diff --git a/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.ts b/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.ts index 2388a789f3b80..100d992f5f863 100644 --- a/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.ts +++ b/x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.ts @@ -13,7 +13,7 @@ import { ALERT_SEVERITY_VALUE, ALERT_EVALUATION_VALUE, ALERT_EVALUATION_THRESHOLD, -} from '@kbn/rule-data-utils/target/technical_field_names'; +} from '@kbn/rule-data-utils'; import { ActionGroupIdsOf } from '../../../../alerting/common'; import { updateState, generateAlertMessage } from './common'; import { DURATION_ANOMALY } from '../../../common/constants/alerts'; From b61fc4f255510ae1dadd3a300dea1284a6474aeb Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 4 Aug 2021 23:08:11 +0100 Subject: [PATCH 3/4] chore(NA): targetted imports for apm --- .../alerting/register_apm_alerts.ts | 18 ++++++++--- .../Distribution/index.tsx | 6 +++- .../charts/helper/get_alert_annotations.tsx | 30 ++++++++++++++----- .../shared/charts/latency_chart/index.tsx | 6 +++- .../alerts/register_error_count_alert_type.ts | 14 +++++++-- ...egister_transaction_duration_alert_type.ts | 14 +++++++-- ...transaction_duration_anomaly_alert_type.ts | 22 ++++++++++---- ...ister_transaction_error_rate_alert_type.ts | 14 +++++++-- .../server/lib/services/get_service_alerts.ts | 6 +++- 9 files changed, 102 insertions(+), 28 deletions(-) diff --git a/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts b/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts index 27db09dd94a3f..a6d8a3ec79f3d 100644 --- a/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts +++ b/x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts @@ -8,11 +8,17 @@ import { i18n } from '@kbn/i18n'; import { lazy } from 'react'; import { stringify } from 'querystring'; -import { - ALERT_EVALUATION_THRESHOLD, - ALERT_EVALUATION_VALUE, - ALERT_SEVERITY_LEVEL, +import type { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_TYPED, } from '@kbn/rule-data-utils'; +import { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_NON_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_NON_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import type { ObservabilityRuleTypeRegistry } from '../../../../observability/public'; import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; import { AlertType } from '../../../common/alert_types'; @@ -22,6 +28,10 @@ const SERVICE_ENVIRONMENT = 'service.environment'; const SERVICE_NAME = 'service.name'; const TRANSACTION_TYPE = 'transaction.type'; +const ALERT_EVALUATION_THRESHOLD: typeof ALERT_EVALUATION_THRESHOLD_TYPED = ALERT_EVALUATION_THRESHOLD_NON_TYPED; +const ALERT_EVALUATION_VALUE: typeof ALERT_EVALUATION_VALUE_TYPED = ALERT_EVALUATION_VALUE_NON_TYPED; +const ALERT_SEVERITY_LEVEL: typeof ALERT_SEVERITY_LEVEL_TYPED = ALERT_SEVERITY_LEVEL_NON_TYPED; + const format = ({ pathname, query, diff --git a/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx b/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx index 3cb77e83d4262..47b701127355b 100644 --- a/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx +++ b/x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx @@ -19,7 +19,9 @@ import { import { EuiTitle } from '@elastic/eui'; import d3 from 'd3'; import React, { Suspense, useState } from 'react'; -import { RULE_ID } from '@kbn/rule-data-utils'; +import type { RULE_ID as RULE_ID_TYPED } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { RULE_ID as RULE_ID_NON_TYPED } from '@kbn/rule-data-utils/target_node/technical_field_names'; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { APIReturnType } from '../../../../services/rest/createCallApmApi'; import { asRelativeDateTimeRange } from '../../../../../common/utils/formatters'; @@ -29,6 +31,8 @@ import { getAlertAnnotations } from '../../../shared/charts/helper/get_alert_ann import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; import { LazyAlertsFlyout } from '../../../../../../observability/public'; +const RULE_ID: typeof RULE_ID_TYPED = RULE_ID_NON_TYPED; + type ErrorDistributionAPIResponse = APIReturnType<'GET /api/apm/services/{serviceName}/errors/distribution'>; interface FormattedBucket { diff --git a/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx b/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx index 0d158b5e8170d..29063cf4e957d 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx @@ -12,14 +12,23 @@ import { } from '@elastic/charts'; import { EuiButtonIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { - ALERT_DURATION, - ALERT_SEVERITY_LEVEL, - ALERT_START, - ALERT_UUID, - RULE_ID, - RULE_NAME, +import type { + ALERT_DURATION as ALERT_DURATION_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_TYPED, + ALERT_START as ALERT_START_TYPED, + ALERT_UUID as ALERT_UUID_TYPED, + RULE_ID as RULE_ID_TYPED, + RULE_NAME as RULE_NAME_TYPED, } from '@kbn/rule-data-utils'; +import { + ALERT_DURATION as ALERT_DURATION_NON_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_NON_TYPED, + ALERT_START as ALERT_START_NON_TYPED, + ALERT_UUID as ALERT_UUID_NON_TYPED, + RULE_ID as RULE_ID_NON_TYPED, + RULE_NAME as RULE_NAME_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import React, { Dispatch, SetStateAction } from 'react'; import { EuiTheme } from 'src/plugins/kibana_react/common'; import { ValuesType } from 'utility-types'; @@ -28,6 +37,13 @@ import { parseTechnicalFields } from '../../../../../../rule_registry/common'; import { asDuration, asPercent } from '../../../../../common/utils/formatters'; import { APIReturnType } from '../../../../services/rest/createCallApmApi'; +const ALERT_DURATION: typeof ALERT_DURATION_TYPED = ALERT_DURATION_NON_TYPED; +const ALERT_SEVERITY_LEVEL: typeof ALERT_SEVERITY_LEVEL_TYPED = ALERT_SEVERITY_LEVEL_NON_TYPED; +const ALERT_START: typeof ALERT_START_TYPED = ALERT_START_NON_TYPED; +const ALERT_UUID: typeof ALERT_UUID_TYPED = ALERT_UUID_NON_TYPED; +const RULE_ID: typeof RULE_ID_TYPED = RULE_ID_NON_TYPED; +const RULE_NAME: typeof RULE_NAME_TYPED = RULE_NAME_NON_TYPED; + type Alert = ValuesType< APIReturnType<'GET /api/apm/services/{serviceName}/alerts'>['alerts'] >; diff --git a/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx index f96445597226e..b6fabbb47eea9 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx @@ -9,7 +9,9 @@ import { EuiFlexGroup, EuiFlexItem, EuiSelect, EuiTitle } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { useHistory } from 'react-router-dom'; -import { RULE_ID } from '@kbn/rule-data-utils'; +import type { RULE_ID as RULE_ID_TYPED } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { RULE_ID as RULE_ID_NON_TYPED } from '@kbn/rule-data-utils/target_node/technical_field_names'; import { AlertType } from '../../../../../common/alert_types'; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { LatencyAggregationType } from '../../../../../common/latency_aggregation_types'; @@ -27,6 +29,8 @@ import { MLHeader } from '../../../shared/charts/transaction_charts/ml_header'; import * as urlHelpers from '../../../shared/Links/url_helpers'; import { getComparisonChartTheme } from '../../time_comparison/get_time_range_comparison'; +const RULE_ID: typeof RULE_ID_TYPED = RULE_ID_NON_TYPED; + interface Props { height?: number; } diff --git a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts index 7c625d3a4c6b2..6a6a67e9fd97f 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts @@ -7,10 +7,15 @@ import { schema } from '@kbn/config-schema'; import { take } from 'rxjs/operators'; -import { - ALERT_EVALUATION_THRESHOLD, - ALERT_EVALUATION_VALUE, +import type { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, } from '@kbn/rule-data-utils'; +import { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_NON_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { ENVIRONMENT_NOT_DEFINED, @@ -34,6 +39,9 @@ import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; +const ALERT_EVALUATION_THRESHOLD: typeof ALERT_EVALUATION_THRESHOLD_TYPED = ALERT_EVALUATION_THRESHOLD_NON_TYPED; +const ALERT_EVALUATION_VALUE: typeof ALERT_EVALUATION_VALUE_TYPED = ALERT_EVALUATION_VALUE_NON_TYPED; + const paramsSchema = schema.object({ windowSize: schema.number(), windowUnit: schema.string(), diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts index 5282cd793be8f..3fa617c210791 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts @@ -8,10 +8,15 @@ import { schema } from '@kbn/config-schema'; import { take } from 'rxjs/operators'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; -import { - ALERT_EVALUATION_THRESHOLD, - ALERT_EVALUATION_VALUE, +import type { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, } from '@kbn/rule-data-utils'; +import { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_NON_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { getEnvironmentLabel, @@ -36,6 +41,9 @@ import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; +const ALERT_EVALUATION_THRESHOLD: typeof ALERT_EVALUATION_THRESHOLD_TYPED = ALERT_EVALUATION_THRESHOLD_NON_TYPED; +const ALERT_EVALUATION_VALUE: typeof ALERT_EVALUATION_VALUE_TYPED = ALERT_EVALUATION_VALUE_NON_TYPED; + const paramsSchema = schema.object({ serviceName: schema.string(), transactionType: schema.string(), diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts index bcce469370320..2041f06a5a6a8 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts @@ -9,12 +9,19 @@ import { schema } from '@kbn/config-schema'; import { compact } from 'lodash'; import { ESSearchResponse } from 'src/core/types/elasticsearch'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; -import { - ALERT_EVALUATION_THRESHOLD, - ALERT_EVALUATION_VALUE, - ALERT_SEVERITY_LEVEL, - ALERT_SEVERITY_VALUE, +import type { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_TYPED, + ALERT_SEVERITY_VALUE as ALERT_SEVERITY_VALUE_TYPED, } from '@kbn/rule-data-utils'; +import { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_NON_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_NON_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_NON_TYPED, + ALERT_SEVERITY_VALUE as ALERT_SEVERITY_VALUE_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { ProcessorEvent } from '../../../common/processor_event'; import { getSeverity } from '../../../common/anomaly_detection'; @@ -39,6 +46,11 @@ import { getEnvironmentLabel, } from '../../../common/environment_filter_values'; +const ALERT_EVALUATION_THRESHOLD: typeof ALERT_EVALUATION_THRESHOLD_TYPED = ALERT_EVALUATION_THRESHOLD_NON_TYPED; +const ALERT_EVALUATION_VALUE: typeof ALERT_EVALUATION_VALUE_TYPED = ALERT_EVALUATION_VALUE_NON_TYPED; +const ALERT_SEVERITY_LEVEL: typeof ALERT_SEVERITY_LEVEL_TYPED = ALERT_SEVERITY_LEVEL_NON_TYPED; +const ALERT_SEVERITY_VALUE: typeof ALERT_SEVERITY_VALUE_TYPED = ALERT_SEVERITY_VALUE_NON_TYPED; + const paramsSchema = schema.object({ serviceName: schema.maybe(schema.string()), transactionType: schema.maybe(schema.string()), diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts index 5ca699ab9a84a..fc63e4827e5de 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts @@ -7,10 +7,15 @@ import { schema } from '@kbn/config-schema'; import { take } from 'rxjs/operators'; -import { - ALERT_EVALUATION_THRESHOLD, - ALERT_EVALUATION_VALUE, +import type { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, } from '@kbn/rule-data-utils'; +import { + ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_NON_TYPED, + ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import { ENVIRONMENT_NOT_DEFINED, getEnvironmentEsField, @@ -38,6 +43,9 @@ import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; +const ALERT_EVALUATION_THRESHOLD: typeof ALERT_EVALUATION_THRESHOLD_TYPED = ALERT_EVALUATION_THRESHOLD_NON_TYPED; +const ALERT_EVALUATION_VALUE: typeof ALERT_EVALUATION_VALUE_TYPED = ALERT_EVALUATION_VALUE_NON_TYPED; + const paramsSchema = schema.object({ windowSize: schema.number(), windowUnit: schema.string(), diff --git a/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts b/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts index c9915cf9dce89..4cbc62d87eff6 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts @@ -5,7 +5,9 @@ * 2.0. */ -import { EVENT_KIND } from '@kbn/rule-data-utils'; +import type { EVENT_KIND as EVENT_KIND_TYPED } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { EVENT_KIND as EVENT_KIND_NON_TYPED } from '@kbn/rule-data-utils/target_node/technical_field_names'; import { RuleDataClient } from '../../../../rule_registry/server'; import { SERVICE_NAME, @@ -14,6 +16,8 @@ import { import { rangeQuery } from '../../../../observability/server'; import { environmentQuery } from '../../../common/utils/environment_query'; +const EVENT_KIND: typeof EVENT_KIND_TYPED = EVENT_KIND_NON_TYPED; + export async function getServiceAlerts({ ruleDataClient, start, From 25e3951c3b0963587eac5b06325b165fe416d6de Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 9 Aug 2021 17:07:29 +0100 Subject: [PATCH 4/4] chore(NA): fix imports --- .../public/pages/alerts/alerts_table_t_grid.tsx | 6 +++++- .../timelines/public/components/t_grid/integrated/index.tsx | 6 +++++- .../timelines/public/components/t_grid/standalone/index.tsx | 2 +- x-pack/plugins/timelines/public/container/index.tsx | 2 +- .../public/applications/timelines_test/index.tsx | 6 +++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx index be3f2bf7e34f9..312de3f024d01 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx @@ -5,7 +5,9 @@ * 2.0. */ -import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { AlertConsumers as AlertConsumersTyped } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { AlertConsumers as AlertConsumersNonTyped } from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; import { EuiButtonIcon, EuiDataGridColumn } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; @@ -35,6 +37,8 @@ import { decorateResponse } from './decorate_response'; import { getDefaultCellActions } from './default_cell_actions'; import { LazyAlertsFlyout } from '../..'; +const AlertConsumers: typeof AlertConsumersTyped = AlertConsumersNonTyped; + interface AlertsTableTGridProps { indexName: string; rangeFrom: string; diff --git a/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx index ef140924d4347..0b6487e69699d 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx @@ -5,7 +5,9 @@ * 2.0. */ -import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { AlertConsumers as AlertConsumersTyped } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { AlertConsumers as AlertConsumersNonTyped } from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui'; import { isEmpty } from 'lodash/fp'; import React, { useEffect, useMemo, useState } from 'react'; @@ -49,6 +51,8 @@ import { ExitFullScreen } from '../../exit_full_screen'; import { Sort } from '../body/sort'; import { InspectButtonContainer } from '../../inspect'; +const AlertConsumers: typeof AlertConsumersTyped = AlertConsumersNonTyped; + export const EVENTS_VIEWER_HEADER_HEIGHT = 90; // px const COMPACT_HEADER_HEIGHT = 36; // px diff --git a/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx index df8a5897bfcd1..7382d029be98e 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { AlertConsumers } from '@kbn/rule-data-utils'; import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui'; import { isEmpty } from 'lodash/fp'; import React, { useEffect, useMemo, useState } from 'react'; diff --git a/x-pack/plugins/timelines/public/container/index.tsx b/x-pack/plugins/timelines/public/container/index.tsx index 5fb0ed56afaae..b7345e90fdb02 100644 --- a/x-pack/plugins/timelines/public/container/index.tsx +++ b/x-pack/plugins/timelines/public/container/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import type { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { AlertConsumers } from '@kbn/rule-data-utils'; import deepEqual from 'fast-deep-equal'; import { isEmpty, isString, noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; diff --git a/x-pack/test/plugin_functional/plugins/timelines_test/public/applications/timelines_test/index.tsx b/x-pack/test/plugin_functional/plugins/timelines_test/public/applications/timelines_test/index.tsx index 317010aca24bd..75a3134d4bf67 100644 --- a/x-pack/test/plugin_functional/plugins/timelines_test/public/applications/timelines_test/index.tsx +++ b/x-pack/test/plugin_functional/plugins/timelines_test/public/applications/timelines_test/index.tsx @@ -5,7 +5,9 @@ * 2.0. */ -import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { AlertConsumers as AlertConsumersTyped } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { AlertConsumers as AlertConsumersNonTyped } from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; import { Router } from 'react-router-dom'; import React, { useCallback, useRef } from 'react'; import ReactDOM from 'react-dom'; @@ -15,6 +17,8 @@ import { KibanaContextProvider } from '../../../../../../../../src/plugins/kiban import { TimelinesUIStart } from '../../../../../../../plugins/timelines/public'; import { DataPublicPluginStart } from '../../../../../../../../src/plugins/data/public'; +const AlertConsumers: typeof AlertConsumersTyped = AlertConsumersNonTyped; + type CoreStartTimelines = CoreStart & { data: DataPublicPluginStart }; /**