From dfaf54082a2baf898497b8744eeb8f7ebfa5a704 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 11 Aug 2021 15:59:21 +0100 Subject: [PATCH] chore(NA): moving @kbn/rule-data-utils to babel transpiler (#107573) * chore(NA): moving @kbn/rule-data-utils to babel transpiler * chore(NA): update imports * chore(NA): targetted imports for apm * chore(NA): fix imports Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- packages/kbn-rule-data-utils/.babelrc | 3 ++ packages/kbn-rule-data-utils/BUILD.bazel | 25 ++++++++++---- packages/kbn-rule-data-utils/package.json | 4 +-- packages/kbn-rule-data-utils/tsconfig.json | 10 +++--- .../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 +++- .../pages/alerts/alerts_flyout/index.tsx | 34 ++++++++++++++----- .../public/pages/alerts/alerts_table.tsx | 6 +--- .../pages/alerts/alerts_table_t_grid.tsx | 32 ++++++++++++----- .../alerts/alerts_table_t_grid_actions.tsx | 14 ++++++-- .../public/pages/alerts/decorate_response.ts | 22 +++++++++--- .../public/pages/alerts/render_cell_value.tsx | 26 ++++++++++---- .../server/lib/rules/get_top_alerts.ts | 2 +- .../server/utils/queries.test.ts | 2 +- .../observability/server/utils/queries.ts | 2 +- .../common/technical_rule_data_field_names.ts | 2 +- .../server/alert_data_client/alerts_client.ts | 24 +++++++++---- .../server/routes/get_alert_index.ts | 2 +- .../server/rule_data_client/types.ts | 2 +- .../server/rule_data_plugin_service/index.ts | 2 +- .../create_persistence_rule_type_factory.ts | 2 +- .../common/search_strategy/timeline/index.ts | 2 +- .../components/t_grid/integrated/index.tsx | 6 +++- .../components/t_grid/standalone/index.tsx | 2 +- .../timelines/public/container/index.tsx | 2 +- .../server/search_strategy/timeline/index.ts | 17 +++++++--- .../lib/alerts/duration_anomaly.test.ts | 2 +- .../server/lib/alerts/duration_anomaly.ts | 2 +- .../applications/timelines_test/index.tsx | 6 +++- 36 files changed, 284 insertions(+), 101 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 000000000000..7da72d177912 --- /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 1268daf54cd4..bbc2d524102d 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,19 +22,27 @@ NPM_MODULE_EXTRA_FILES = [ "package.json", ] -SRC_DEPS = [ +RUNTIME_DEPS = [ "//packages/kbn-es-query", + "@npm//@elastic/elasticsearch", "@npm//tslib", "@npm//utility-types", - "@npm//@elastic/elasticsearch", ] TYPES_DEPS = [ + "//packages/kbn-es-query", + "@npm//@elastic/elasticsearch", + "@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", @@ -45,13 +54,15 @@ ts_config( ) ts_project( - name = "tsc", + name = "tsc_types", args = ['--pretty'], srcs = SRCS, - deps = DEPS, + deps = TYPES_DEPS, declaration = True, declaration_map = True, - out_dir = "target", + emit_declaration_only = True, + incremental = False, + out_dir = "target_types", source_map = True, root_dir = "src", tsconfig = ":tsconfig", @@ -60,7 +71,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 42223e51ec2d..64bbb69d1440 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 1c568530306c..be6095d187ef 100644 --- a/packages/kbn-rule-data-utils/tsconfig.json +++ b/packages/kbn-rule-data-utils/tsconfig.json @@ -1,19 +1,21 @@ { "extends": "../../tsconfig.bazel.json", "compilerOptions": { - "outDir": "./target/types", - "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" ] } 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 bcac3ad4e126..12102a294bf9 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 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, - ALERT_EVALUATION_VALUE, - ALERT_SEVERITY_LEVEL, -} from '@kbn/rule-data-utils/target/technical_field_names'; + 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 f969b5802e8b..fa458b95d0d8 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 { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils/target/technical_field_names'; +import type { ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_TYPED } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_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 ALERT_RULE_TYPE_ID: typeof ALERT_RULE_TYPE_ID_TYPED = ALERT_RULE_TYPE_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 31a8cbf44ea2..f51494b8fa1d 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 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, + ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_TYPED, +} from '@kbn/rule-data-utils'; import { - ALERT_DURATION, - ALERT_SEVERITY_LEVEL, - ALERT_START, - ALERT_UUID, - ALERT_RULE_TYPE_ID, - ALERT_RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; + 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, + ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_NON_TYPED, + ALERT_RULE_NAME as ALERT_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 ALERT_RULE_TYPE_ID: typeof ALERT_RULE_TYPE_ID_TYPED = ALERT_RULE_TYPE_ID_NON_TYPED; +const ALERT_RULE_NAME: typeof ALERT_RULE_NAME_TYPED = ALERT_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 d2df99ba2919..ff9e46fc0552 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 { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils/target/technical_field_names'; +import type { ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_TYPED } from '@kbn/rule-data-utils'; +// @ts-expect-error +import { ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_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 ALERT_RULE_TYPE_ID: typeof ALERT_RULE_TYPE_ID_TYPED = ALERT_RULE_TYPE_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 bdd6b240c4bb..6a6a67e9fd97 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 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, - ALERT_EVALUATION_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; + 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 88394cb2c598..790e62eae66d 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 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, - ALERT_EVALUATION_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; + 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 de0657d075d7..2041f06a5a6a 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 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, - ALERT_EVALUATION_VALUE, - ALERT_SEVERITY_LEVEL, - ALERT_SEVERITY_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; + 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 a39730265953..fc63e4827e5d 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 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, - ALERT_EVALUATION_VALUE, -} from '@kbn/rule-data-utils/target/technical_field_names'; + 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 a9fe55456ad4..4cbc62d87eff 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/target/technical_field_names'; +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, 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 7c23aa8582ec..3d63f7bdaeaf 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 @@ -20,15 +20,25 @@ import { EuiTitle, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import type { + ALERT_DURATION as ALERT_DURATION_TYPED, + 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_UUID as ALERT_UUID_TYPED, + ALERT_RULE_CATEGORY as ALERT_RULE_CATEGORY_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_TYPED, +} from '@kbn/rule-data-utils'; import { - ALERT_DURATION, - ALERT_EVALUATION_THRESHOLD, - ALERT_EVALUATION_VALUE, - ALERT_SEVERITY_LEVEL, - ALERT_UUID, - ALERT_RULE_CATEGORY, - ALERT_RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; + ALERT_DURATION as ALERT_DURATION_NON_TYPED, + 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_UUID as ALERT_UUID_NON_TYPED, + ALERT_RULE_CATEGORY as ALERT_RULE_CATEGORY_NON_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import moment from 'moment-timezone'; import React, { useMemo } from 'react'; import type { TopAlert, TopAlertResponse } from '../'; @@ -46,6 +56,14 @@ type AlertsFlyoutProps = { selectedAlertId?: string; } & EuiFlyoutProps; +const ALERT_DURATION: typeof ALERT_DURATION_TYPED = ALERT_DURATION_NON_TYPED; +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_UUID: typeof ALERT_UUID_TYPED = ALERT_UUID_NON_TYPED; +const ALERT_RULE_CATEGORY: typeof ALERT_RULE_CATEGORY_TYPED = ALERT_RULE_CATEGORY_NON_TYPED; +const ALERT_RULE_NAME: typeof ALERT_RULE_NAME_TYPED = ALERT_RULE_NAME_NON_TYPED; + export function AlertsFlyout({ alert, alerts, 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 28d211766cfe..395c2a5253ec 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 798be42fce5c..f82446db2ebe 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,19 +5,28 @@ * 2.0. */ -import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { + AlertConsumers as AlertConsumersTyped, + ALERT_DURATION as ALERT_DURATION_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_TYPED, + ALERT_STATUS as ALERT_STATUS_TYPED, + ALERT_START as ALERT_START_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_TYPED, +} from '@kbn/rule-data-utils'; +import { + AlertConsumers as AlertConsumersNonTyped, + ALERT_DURATION as ALERT_DURATION_NON_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_NON_TYPED, + ALERT_STATUS as ALERT_STATUS_NON_TYPED, + ALERT_START as ALERT_START_NON_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_NON_TYPED, + // @ts-expect-error +} 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'; import React, { Suspense, useState } from 'react'; -import { - ALERT_DURATION, - ALERT_SEVERITY_LEVEL, - ALERT_STATUS, - ALERT_START, - ALERT_RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; import type { TimelinesUIStart } from '../../../../timelines/public'; import type { TopAlert } from './'; @@ -35,6 +44,13 @@ import { decorateResponse } from './decorate_response'; import { getDefaultCellActions } from './default_cell_actions'; import { LazyAlertsFlyout } from '../..'; +const AlertConsumers: typeof AlertConsumersTyped = AlertConsumersNonTyped; +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_STATUS: typeof ALERT_STATUS_TYPED = ALERT_STATUS_NON_TYPED; +const ALERT_START: typeof ALERT_START_TYPED = ALERT_START_NON_TYPED; +const ALERT_RULE_NAME: typeof ALERT_RULE_NAME_TYPED = ALERT_RULE_NAME_NON_TYPED; + interface AlertsTableTGridProps { indexName: string; rangeFrom: string; 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 2ba105113fec..3c31b8cfda87 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,10 +14,15 @@ import { EuiPopoverTitle, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import type { + ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_TYPED, +} from '@kbn/rule-data-utils'; import { - ALERT_RULE_TYPE_ID, - ALERT_RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; + ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_NON_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import React, { useState } from 'react'; import { format, parse } from 'url'; @@ -26,6 +31,9 @@ import type { ActionProps } from '../../../../timelines/common'; import { asDuration, asPercent } from '../../../common/utils/formatters'; import { usePluginContext } from '../../hooks/use_plugin_context'; +const ALERT_RULE_TYPE_ID: typeof ALERT_RULE_TYPE_ID_TYPED = ALERT_RULE_TYPE_ID_NON_TYPED; +const ALERT_RULE_NAME: typeof ALERT_RULE_NAME_TYPED = ALERT_RULE_NAME_NON_TYPED; + export function RowCellActionsRender({ data }: ActionProps) { const { core, observabilityRuleTypeRegistry } = usePluginContext(); const [isPopoverOpen, setIsPopoverOpen] = useState(false); 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 f09a735de97b..7eb6d785779b 100644 --- a/x-pack/plugins/observability/public/pages/alerts/decorate_response.ts +++ b/x-pack/plugins/observability/public/pages/alerts/decorate_response.ts @@ -5,17 +5,29 @@ * 2.0. */ +import type { + ALERT_START as ALERT_START_TYPED, + ALERT_STATUS as ALERT_STATUS_TYPED, + ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_TYPED, +} from '@kbn/rule-data-utils'; import { - ALERT_RULE_TYPE_ID, - ALERT_RULE_NAME, - ALERT_STATUS, - ALERT_START, -} from '@kbn/rule-data-utils/target/technical_field_names'; + ALERT_START as ALERT_START_NON_TYPED, + ALERT_STATUS as ALERT_STATUS_NON_TYPED, + ALERT_RULE_TYPE_ID as ALERT_RULE_TYPE_ID_NON_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import type { TopAlertResponse, TopAlert } from '.'; import { parseTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields'; import { asDuration, asPercent } from '../../../common/utils/formatters'; import { ObservabilityRuleTypeRegistry } from '../../rules/create_observability_rule_type_registry'; +const ALERT_START: typeof ALERT_START_TYPED = ALERT_START_NON_TYPED; +const ALERT_STATUS: typeof ALERT_STATUS_TYPED = ALERT_STATUS_NON_TYPED; +const ALERT_RULE_TYPE_ID: typeof ALERT_RULE_TYPE_ID_TYPED = ALERT_RULE_TYPE_ID_NON_TYPED; +const ALERT_RULE_NAME: typeof ALERT_RULE_NAME_TYPED = ALERT_RULE_NAME_NON_TYPED; + export function decorateResponse( alerts: TopAlertResponse[], observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry 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 560926bf20e8..dde10b7a3f3e 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 @@ -7,13 +7,21 @@ import { EuiIconTip, EuiLink } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useEffect } from 'react'; +import type { + ALERT_DURATION as ALERT_DURATION_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_TYPED, + ALERT_START as ALERT_START_TYPED, + ALERT_STATUS as ALERT_STATUS_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_TYPED, +} from '@kbn/rule-data-utils'; import { - ALERT_DURATION, - ALERT_SEVERITY_LEVEL, - ALERT_STATUS, - ALERT_START, - ALERT_RULE_NAME, -} from '@kbn/rule-data-utils/target/technical_field_names'; + ALERT_DURATION as ALERT_DURATION_NON_TYPED, + ALERT_SEVERITY_LEVEL as ALERT_SEVERITY_LEVEL_NON_TYPED, + ALERT_START as ALERT_START_NON_TYPED, + ALERT_STATUS as ALERT_STATUS_NON_TYPED, + ALERT_RULE_NAME as ALERT_RULE_NAME_NON_TYPED, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/technical_field_names'; import type { CellValueElementProps, TimelineNonEcsData } from '../../../../timelines/common'; import { TimestampTooltip } from '../../components/shared/timestamp_tooltip'; @@ -23,6 +31,12 @@ import { TopAlert } from '.'; import { decorateResponse } from './decorate_response'; import { usePluginContext } from '../../hooks/use_plugin_context'; +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_STATUS: typeof ALERT_STATUS_TYPED = ALERT_STATUS_NON_TYPED; +const ALERT_RULE_NAME: typeof ALERT_RULE_NAME_TYPED = ALERT_RULE_NAME_NON_TYPED; + export const getMappedNonEcsValue = ({ data, fieldName, 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 db8191136686..74e6a5bc177f 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 a0a63b73d717..dab42fa604dc 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 2ee3291e7fb6..283779c31290 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 5c954a31e79a..47b00fb1348e 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 aaceb167b2e5..a67c03abe8b3 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 @@ -8,13 +8,20 @@ import Boom from '@hapi/boom'; import { PublicMethodsOf } from '@kbn/utility-types'; import { Filter, buildEsQuery, EsQueryConfig } from '@kbn/es-query'; import { decodeVersion, encodeHitVersion } from '@kbn/securitysolution-es-utils'; -import { - mapConsumerToIndexName, - isValidFeatureId, - getSafeSortIds, +import type { + getEsQueryConfig as getEsQueryConfigTyped, + getSafeSortIds as getSafeSortIdsTyped, + isValidFeatureId as isValidFeatureIdTyped, + mapConsumerToIndexName as mapConsumerToIndexNameTyped, STATUS_VALUES, - getEsQueryConfig, -} from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +} from '@kbn/rule-data-utils'; +import { + getEsQueryConfig as getEsQueryConfigNonTyped, + getSafeSortIds as getSafeSortIdsNonTyped, + isValidFeatureId as isValidFeatureIdNonTyped, + mapConsumerToIndexName as mapConsumerToIndexNameNonTyped, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; import { InlineScript, QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; import { AlertTypeParams, AlertingAuthorizationFilterType } from '../../../alerting/server'; @@ -35,6 +42,11 @@ import { } from '../../common/technical_rule_data_field_names'; import { ParsedTechnicalFields } from '../../common/parse_technical_fields'; +const getEsQueryConfig: typeof getEsQueryConfigTyped = getEsQueryConfigNonTyped; +const getSafeSortIds: typeof getSafeSortIdsTyped = getSafeSortIdsNonTyped; +const isValidFeatureId: typeof isValidFeatureIdTyped = isValidFeatureIdNonTyped; +const mapConsumerToIndexName: typeof mapConsumerToIndexNameTyped = mapConsumerToIndexNameNonTyped; + // TODO: Fix typings https://github.com/elastic/kibana/issues/101776 type NonNullableProps = Omit & { [K in Props]-?: NonNullable }; 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 3e3bde7429fe..f3b0b9181c60 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 277121074f7f..ef09dcc7550a 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 f81340889e4b..e10b58a1c60c 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 50e5b224f01d..caf14e8ba300 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 99ee021cb680..269fc6598bea 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 { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; +import type { AlertConsumers } from '@kbn/rule-data-utils'; import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; 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 36b5537eb301..8ce842798521 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'; @@ -47,6 +49,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 df8a5897bfcd..7382d029be98 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 5fb0ed56afaa..b7345e90fdb0 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/plugins/timelines/server/search_strategy/timeline/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts index 5b60443fc6f5..a2a5a3bc8a49 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/index.ts @@ -8,11 +8,17 @@ import { ALERT_RULE_CONSUMER, ALERT_RULE_TYPE_ID, SPACE_IDS } from '@kbn/rule-data-utils'; import { map, mergeMap, catchError } from 'rxjs/operators'; import { from } from 'rxjs'; -import { - isValidFeatureId, - mapConsumerToIndexName, + +import type { AlertConsumers, -} from '@kbn/rule-data-utils/target/alerts_as_data_rbac'; + mapConsumerToIndexName as mapConsumerToIndexNameTyped, + isValidFeatureId as isValidFeatureIdTyped, +} from '@kbn/rule-data-utils'; +import { + mapConsumerToIndexName as mapConsumerToIndexNameNonTyped, + isValidFeatureId as isValidFeatureIdNonTyped, + // @ts-expect-error +} from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; import { AlertingAuthorizationEntity, @@ -38,6 +44,9 @@ import { ISearchOptions, } from '../../../../../../src/plugins/data/common'; +const mapConsumerToIndexName: typeof mapConsumerToIndexNameTyped = mapConsumerToIndexNameNonTyped; +const isValidFeatureId: typeof isValidFeatureIdTyped = isValidFeatureIdNonTyped; + export const timelineSearchStrategyProvider = ( data: PluginStart, alerting: AlertingPluginStartContract 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 ce13ae4ce6ce..a51bbc49123d 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 2388a789f3b8..100d992f5f86 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'; 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 585470aff23b..bedaca0fc183 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 }; /**