diff --git a/.eslintrc.js b/.eslintrc.js index b303a9fefb691..75580f115f48a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -850,6 +850,10 @@ module.exports = { name: 'semver', message: 'Please use "semver/*/{function}" instead', }, + { + name: '@kbn/rule-data-utils', + message: `Import directly from @kbn/rule-data-utils/* submodules in public/common code`, + }, ], }, ], diff --git a/packages/kbn-rule-data-utils/BUILD.bazel b/packages/kbn-rule-data-utils/BUILD.bazel index bbc2d524102db..730e907aafc65 100644 --- a/packages/kbn-rule-data-utils/BUILD.bazel +++ b/packages/kbn-rule-data-utils/BUILD.bazel @@ -20,6 +20,10 @@ filegroup( NPM_MODULE_EXTRA_FILES = [ "package.json", + "alerts_as_data_rbac/package.json", + "alerts_as_data_severity/package.json", + "alerts_as_data_status/package.json", + "technical_field_names/package.json", ] RUNTIME_DEPS = [ diff --git a/packages/kbn-rule-data-utils/alerts_as_data_rbac/package.json b/packages/kbn-rule-data-utils/alerts_as_data_rbac/package.json new file mode 100644 index 0000000000000..7f06391bc9590 --- /dev/null +++ b/packages/kbn-rule-data-utils/alerts_as_data_rbac/package.json @@ -0,0 +1,4 @@ +{ + "main": "../target_node/alerts_as_data_rbac", + "types": "../target_types/alerts_as_data_rbac" +} \ No newline at end of file diff --git a/packages/kbn-rule-data-utils/alerts_as_data_severity/package.json b/packages/kbn-rule-data-utils/alerts_as_data_severity/package.json new file mode 100644 index 0000000000000..b053fc29e47c2 --- /dev/null +++ b/packages/kbn-rule-data-utils/alerts_as_data_severity/package.json @@ -0,0 +1,4 @@ +{ + "main": "../target_node/alerts_as_data_severity", + "types": "../target_types/alerts_as_data_severity" +} \ No newline at end of file diff --git a/packages/kbn-rule-data-utils/alerts_as_data_status/package.json b/packages/kbn-rule-data-utils/alerts_as_data_status/package.json new file mode 100644 index 0000000000000..4f621d252a2dc --- /dev/null +++ b/packages/kbn-rule-data-utils/alerts_as_data_status/package.json @@ -0,0 +1,4 @@ +{ + "main": "../target_node/alerts_as_data_status", + "types": "../target_types/alerts_as_data_status" +} \ No newline at end of file diff --git a/packages/kbn-rule-data-utils/technical_field_names/package.json b/packages/kbn-rule-data-utils/technical_field_names/package.json new file mode 100644 index 0000000000000..cbac9db58f5f8 --- /dev/null +++ b/packages/kbn-rule-data-utils/technical_field_names/package.json @@ -0,0 +1,4 @@ +{ + "main": "../target_node/technical_field_names", + "types": "../target_types/technical_field_names" +} \ No newline at end of file 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 3d444c1cf7a3a..20af3db34e508 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,17 +8,11 @@ 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 as ALERT_SEVERITY_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 as ALERT_SEVERITY_NON_TYPED, - // @ts-expect-error -} from '@kbn/rule-data-utils/target_node/technical_field_names'; + ALERT_EVALUATION_THRESHOLD, + ALERT_EVALUATION_VALUE, + ALERT_SEVERITY, +} from '@kbn/rule-data-utils/technical_field_names'; import type { ObservabilityRuleTypeRegistry } from '../../../../observability/public'; import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; import { @@ -34,12 +28,6 @@ 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: typeof ALERT_SEVERITY_TYPED = ALERT_SEVERITY_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 8aa132bb85595..e0e17325fa815 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 @@ -16,9 +16,7 @@ import { } from '@elastic/charts'; import { EuiTitle } from '@elastic/eui'; import React, { Suspense, useState } from 'react'; -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 { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils/technical_field_names'; import { i18n } from '@kbn/i18n'; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { APIReturnType } from '../../../../services/rest/createCallApmApi'; @@ -32,9 +30,6 @@ import { LazyAlertsFlyout } from '../../../../../../observability/public'; import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params'; import { getTimeZone } from '../../../shared/charts/helper/timezone'; -const ALERT_RULE_TYPE_ID: typeof ALERT_RULE_TYPE_ID_TYPED = - ALERT_RULE_TYPE_ID_NON_TYPED; - type ErrorDistributionAPIResponse = APIReturnType<'GET /internal/apm/services/{serviceName}/errors/distribution'>; diff --git a/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.test.tsx b/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.test.tsx index a3ab10ea6514a..9f8240f4ed3eb 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.test.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.test.tsx @@ -16,13 +16,13 @@ import { ALERT_SEVERITY, ALERT_START, ALERT_STATUS, - ALERT_STATUS_ACTIVE, ALERT_UUID, SPACE_IDS, ALERT_RULE_UUID, ALERT_RULE_NAME, ALERT_RULE_CATEGORY, -} from '@kbn/rule-data-utils'; +} from '@kbn/rule-data-utils/technical_field_names'; +import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; import { ValuesType } from 'utility-types'; import { EuiTheme } from '../../../../../../../../src/plugins/kibana_react/common'; import { ObservabilityRuleTypeRegistry } from '../../../../../../observability/public'; 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 038269d3cefdc..832d44f9ca887 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,23 +12,14 @@ import { } from '@elastic/charts'; import { EuiButtonIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import type { - ALERT_DURATION as ALERT_DURATION_TYPED, - ALERT_SEVERITY as ALERT_SEVERITY_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 as ALERT_DURATION_NON_TYPED, - ALERT_SEVERITY as ALERT_SEVERITY_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'; + ALERT_DURATION, + ALERT_SEVERITY, + ALERT_START, + ALERT_UUID, + ALERT_RULE_TYPE_ID, + ALERT_RULE_NAME, +} from '@kbn/rule-data-utils/technical_field_names'; import React, { Dispatch, SetStateAction } from 'react'; import { EuiTheme } from 'src/plugins/kibana_react/common'; import { ValuesType } from 'utility-types'; @@ -37,14 +28,6 @@ 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: typeof ALERT_SEVERITY_TYPED = ALERT_SEVERITY_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 /internal/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 e19f78006d9fe..2876febc21d1e 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,9 +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 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 { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils/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'; @@ -29,9 +27,6 @@ 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; kuery: string; diff --git a/x-pack/plugins/apm/public/components/shared/charts/latency_chart/latency_chart.stories.tsx b/x-pack/plugins/apm/public/components/shared/charts/latency_chart/latency_chart.stories.tsx index e1921aca8d9ef..5799a73b5822c 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/latency_chart/latency_chart.stories.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/latency_chart/latency_chart.stories.tsx @@ -14,7 +14,6 @@ import { ALERT_SEVERITY, ALERT_START, ALERT_STATUS, - ALERT_STATUS_ACTIVE, ALERT_UUID, TIMESTAMP, ALERT_RULE_UUID, @@ -23,7 +22,8 @@ import { ALERT_RULE_CONSUMER, ALERT_RULE_PRODUCER, SPACE_IDS, -} from '@kbn/rule-data-utils'; +} from '@kbn/rule-data-utils/technical_field_names'; +import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; import { Meta, Story } from '@storybook/react'; import React from 'react'; import { MemoryRouter } from 'react-router-dom'; 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 17beacae4b14d..723f52cb1eeda 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,17 +7,11 @@ 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, - ALERT_REASON as ALERT_REASON_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_REASON as ALERT_REASON_NON_TYPED, - // @ts-expect-error -} from '@kbn/rule-data-utils/target_node/technical_field_names'; + ALERT_EVALUATION_THRESHOLD, + ALERT_EVALUATION_VALUE, + ALERT_REASON, +} from '@kbn/rule-data-utils/technical_field_names'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { ENVIRONMENT_NOT_DEFINED, @@ -43,12 +37,6 @@ import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; import { termQuery } from '../../../../observability/server'; -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_REASON: typeof ALERT_REASON_TYPED = ALERT_REASON_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 3500dc8fee921..4e68ca6b52248 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 @@ -7,17 +7,11 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; -import type { - ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, - ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, - ALERT_REASON as ALERT_REASON_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_REASON as ALERT_REASON_NON_TYPED, - // @ts-expect-error -} from '@kbn/rule-data-utils/target_node/technical_field_names'; + ALERT_EVALUATION_THRESHOLD, + ALERT_EVALUATION_VALUE, + ALERT_REASON, +} from '@kbn/rule-data-utils/technical_field_names'; import { take } from 'rxjs/operators'; import { asDuration } from '../../../../observability/common/utils/formatters'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; @@ -49,12 +43,6 @@ 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 ALERT_REASON: typeof ALERT_REASON_TYPED = ALERT_REASON_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 ec2fbb4028b74..dead149cd7761 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,19 +9,12 @@ import { schema } from '@kbn/config-schema'; import { compact } from 'lodash'; import { ESSearchResponse } from 'src/core/types/elasticsearch'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { - ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, - ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, - ALERT_SEVERITY as ALERT_SEVERITY_TYPED, - ALERT_REASON as ALERT_REASON_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 as ALERT_SEVERITY_NON_TYPED, - ALERT_REASON as ALERT_REASON_NON_TYPED, - // @ts-expect-error -} from '@kbn/rule-data-utils/target_node/technical_field_names'; + ALERT_EVALUATION_THRESHOLD, + ALERT_EVALUATION_VALUE, + ALERT_SEVERITY, + ALERT_REASON, +} from '@kbn/rule-data-utils/technical_field_names'; import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server'; import { ProcessorEvent } from '../../../common/processor_event'; import { getSeverity } from '../../../common/anomaly_detection'; @@ -48,13 +41,6 @@ import { } from '../../../common/environment_filter_values'; import { termQuery } from '../../../../observability/server'; -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: typeof ALERT_SEVERITY_TYPED = ALERT_SEVERITY_NON_TYPED; -const ALERT_REASON: typeof ALERT_REASON_TYPED = ALERT_REASON_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 43dfbaf156f6c..cf5b45d901228 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,17 +7,11 @@ 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, - ALERT_REASON as ALERT_REASON_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_REASON as ALERT_REASON_NON_TYPED, - // @ts-expect-error -} from '@kbn/rule-data-utils/target_node/technical_field_names'; + ALERT_EVALUATION_THRESHOLD, + ALERT_EVALUATION_VALUE, + ALERT_REASON, +} from '@kbn/rule-data-utils/technical_field_names'; import { ENVIRONMENT_NOT_DEFINED, getEnvironmentEsField, @@ -50,12 +44,6 @@ import { getDocumentTypeFilterForTransactions } from '../helpers/transactions'; import { asPercent } from '../../../../observability/common/utils/formatters'; import { termQuery } from '../../../../observability/server'; -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_REASON: typeof ALERT_REASON_TYPED = ALERT_REASON_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 3b2354a54d96f..aac04fee397d4 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,9 +5,7 @@ * 2.0. */ -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 { EVENT_KIND } from '@kbn/rule-data-utils/technical_field_names'; import { IRuleDataClient } from '../../../../rule_registry/server'; import { SERVICE_NAME, @@ -16,8 +14,6 @@ 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/cases/public/components/user_action_tree/index.tsx b/x-pack/plugins/cases/public/components/user_action_tree/index.tsx index 95c4f76eae0a2..c1ba83e324ed2 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/index.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/index.tsx @@ -12,7 +12,7 @@ import { EuiCommentList, EuiCommentProps, } from '@elastic/eui'; -import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; +import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils/technical_field_names'; import classNames from 'classnames'; import { get, isEmpty } from 'lodash'; diff --git a/x-pack/plugins/infra/public/alerting/inventory/rule_data_formatters.ts b/x-pack/plugins/infra/public/alerting/inventory/rule_data_formatters.ts index ee27f1ff09925..2d4006bbc39bc 100644 --- a/x-pack/plugins/infra/public/alerting/inventory/rule_data_formatters.ts +++ b/x-pack/plugins/infra/public/alerting/inventory/rule_data_formatters.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { ALERT_REASON, ALERT_RULE_PARAMS, TIMESTAMP } from '@kbn/rule-data-utils'; +import { + ALERT_REASON, + ALERT_RULE_PARAMS, + TIMESTAMP, +} from '@kbn/rule-data-utils/technical_field_names'; import { encode } from 'rison-node'; import { stringify } from 'query-string'; import { ObservabilityRuleTypeFormatter } from '../../../../observability/public'; diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts b/x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts index c64f9b07fa33e..fcf4335b21902 100644 --- a/x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts +++ b/x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_REASON, ALERT_START } from '@kbn/rule-data-utils'; +import { ALERT_REASON, ALERT_START } from '@kbn/rule-data-utils/technical_field_names'; import { modifyUrl } from '@kbn/std'; import { ObservabilityRuleTypeFormatter } from '../../../../observability/public'; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/rule_data_formatters.ts b/x-pack/plugins/infra/public/alerting/metric_threshold/rule_data_formatters.ts index 7a0140ab05652..4dac2a00e0590 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/rule_data_formatters.ts +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/rule_data_formatters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_REASON } from '@kbn/rule-data-utils'; +import { ALERT_REASON } from '@kbn/rule-data-utils/technical_field_names'; import { ObservabilityRuleTypeFormatter } from '../../../../observability/public'; export const formatReason: ObservabilityRuleTypeFormatter = ({ fields }) => { diff --git a/x-pack/plugins/observability/public/components/shared/alert_status_indicator.tsx b/x-pack/plugins/observability/public/components/shared/alert_status_indicator.tsx index e8897ed92dc8c..ad149c186ffa6 100644 --- a/x-pack/plugins/observability/public/components/shared/alert_status_indicator.tsx +++ b/x-pack/plugins/observability/public/components/shared/alert_status_indicator.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiHealth, EuiText } from '@elastic/eui'; -import { ALERT_STATUS_ACTIVE, AlertStatus } from '@kbn/rule-data-utils'; +import { ALERT_STATUS_ACTIVE, AlertStatus } from '@kbn/rule-data-utils/alerts_as_data_status'; import { useTheme } from '../../hooks/use_theme'; interface AlertStatusIndicatorProps { diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx index a0cc697a7a510..64d495dbbc798 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_UUID } from '@kbn/rule-data-utils'; +import { ALERT_UUID } from '@kbn/rule-data-utils/technical_field_names'; import React, { ComponentType } from 'react'; import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; import { PluginContext, PluginContextValue } from '../../../context/plugin_context'; 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 bb746d0acc1cc..c5cad5f3b1c8c 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 @@ -21,24 +21,18 @@ import { EuiTitle, EuiHorizontalRule, } from '@elastic/eui'; -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_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 as ALERT_DURATION_NON_TYPED, - ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_NON_TYPED, - ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_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 { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils'; + ALERT_DURATION, + ALERT_EVALUATION_THRESHOLD, + ALERT_EVALUATION_VALUE, + ALERT_UUID, + ALERT_RULE_CATEGORY, + ALERT_RULE_NAME, +} from '@kbn/rule-data-utils/technical_field_names'; +import { + ALERT_STATUS_ACTIVE, + ALERT_STATUS_RECOVERED, +} from '@kbn/rule-data-utils/alerts_as_data_status'; import moment from 'moment-timezone'; import React, { useMemo } from 'react'; import type { TopAlert } from '../'; @@ -58,15 +52,6 @@ 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_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_t_grid.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx index 523d0f19be2be..dac2b0951ae05 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 @@ -11,23 +11,14 @@ * This way plugins can do targeted imports to reduce the final code bundle */ import { - ALERT_DURATION as ALERT_DURATION_TYPED, - ALERT_REASON as ALERT_REASON_TYPED, + ALERT_DURATION, + ALERT_REASON, ALERT_RULE_CONSUMER, ALERT_RULE_PRODUCER, - ALERT_STATUS as ALERT_STATUS_TYPED, - ALERT_WORKFLOW_STATUS as ALERT_WORKFLOW_STATUS_TYPED, -} from '@kbn/rule-data-utils'; -// @ts-expect-error importing from a place other than root because we want to limit what we import from this package -import { AlertConsumers as AlertConsumersNonTyped } from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; -import { - ALERT_DURATION as ALERT_DURATION_NON_TYPED, - ALERT_REASON as ALERT_REASON_NON_TYPED, - ALERT_STATUS as ALERT_STATUS_NON_TYPED, - ALERT_WORKFLOW_STATUS as ALERT_WORKFLOW_STATUS_NON_TYPED, + ALERT_STATUS, + ALERT_WORKFLOW_STATUS, TIMESTAMP, - // @ts-expect-error importing from a place other than root because we want to limit what we import from this package -} from '@kbn/rule-data-utils/target_node/technical_field_names'; +} from '@kbn/rule-data-utils/technical_field_names'; import { EuiButtonIcon, @@ -69,11 +60,6 @@ import { parseAlert } from './parse_alert'; import { CoreStart } from '../../../../../../src/core/public'; import { translations, paths } from '../../config'; -const ALERT_DURATION: typeof ALERT_DURATION_TYPED = ALERT_DURATION_NON_TYPED; -const ALERT_REASON: typeof ALERT_REASON_TYPED = ALERT_REASON_NON_TYPED; -const ALERT_STATUS: typeof ALERT_STATUS_TYPED = ALERT_STATUS_NON_TYPED; -const ALERT_WORKFLOW_STATUS: typeof ALERT_WORKFLOW_STATUS_TYPED = ALERT_WORKFLOW_STATUS_NON_TYPED; - interface AlertsTableTGridProps { indexNames: string[]; rangeFrom: string; diff --git a/x-pack/plugins/observability/public/pages/alerts/example_data.ts b/x-pack/plugins/observability/public/pages/alerts/example_data.ts index 1354da592f796..08af9a3575405 100644 --- a/x-pack/plugins/observability/public/pages/alerts/example_data.ts +++ b/x-pack/plugins/observability/public/pages/alerts/example_data.ts @@ -13,14 +13,16 @@ import { ALERT_RULE_TYPE_ID, ALERT_START, ALERT_STATUS, - ALERT_STATUS_ACTIVE, - ALERT_STATUS_RECOVERED, ALERT_UUID, ALERT_RULE_UUID, ALERT_RULE_NAME, ALERT_RULE_CATEGORY, ALERT_RULE_PRODUCER, -} from '@kbn/rule-data-utils'; +} from '@kbn/rule-data-utils/technical_field_names'; +import { + ALERT_STATUS_ACTIVE, + ALERT_STATUS_RECOVERED, +} from '@kbn/rule-data-utils/alerts_as_data_status'; export const apmAlertResponseExample = [ { diff --git a/x-pack/plugins/observability/public/pages/alerts/parse_alert.ts b/x-pack/plugins/observability/public/pages/alerts/parse_alert.ts index e4d3b08c00fae..7b28803084067 100644 --- a/x-pack/plugins/observability/public/pages/alerts/parse_alert.ts +++ b/x-pack/plugins/observability/public/pages/alerts/parse_alert.ts @@ -5,30 +5,18 @@ * 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_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 { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils'; + ALERT_START, + ALERT_STATUS, + ALERT_RULE_TYPE_ID, + ALERT_RULE_NAME, +} from '@kbn/rule-data-utils/technical_field_names'; +import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; import type { 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 const parseAlert = (observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry) => (alert: Record): TopAlert => { diff --git a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx b/x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx index 55333e8b7ea76..79a27faa96c69 100644 --- a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx @@ -5,9 +5,11 @@ * 2.0. */ -// @ts-expect-error importing from a place other than root because we want to limit what we import from this package -import { ALERT_STATUS } from '@kbn/rule-data-utils/target_node/technical_field_names'; -import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils'; +import { + ALERT_STATUS_ACTIVE, + ALERT_STATUS_RECOVERED, +} from '@kbn/rule-data-utils/alerts_as_data_status'; +import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import type { CellValueElementProps } from '../../../../timelines/common'; import { createObservabilityRuleTypeRegistryMock } from '../../rules/observability_rule_type_registry_mock'; import * as PluginHook from '../../hooks/use_plugin_context'; 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 f7e14545048a7..80ccd4a69b281 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 @@ -6,26 +6,17 @@ */ import { EuiLink } from '@elastic/eui'; import React from 'react'; -/** - * We need to produce types and code transpilation at different folders during the build of the package. - * We have types and code at different imports because we don't want to import the whole package in the resulting webpack bundle for the plugin. - * This way plugins can do targeted imports to reduce the final code bundle - */ -import type { - ALERT_DURATION as ALERT_DURATION_TYPED, - ALERT_SEVERITY as ALERT_SEVERITY_TYPED, - ALERT_STATUS as ALERT_STATUS_TYPED, - ALERT_REASON as ALERT_REASON_TYPED, -} from '@kbn/rule-data-utils'; import { - ALERT_DURATION as ALERT_DURATION_NON_TYPED, - ALERT_SEVERITY as ALERT_SEVERITY_NON_TYPED, - ALERT_STATUS as ALERT_STATUS_NON_TYPED, - ALERT_REASON as ALERT_REASON_NON_TYPED, + ALERT_DURATION, + ALERT_SEVERITY, + ALERT_STATUS, + ALERT_REASON, TIMESTAMP, - // @ts-expect-error importing from a place other than root because we want to limit what we import from this package -} from '@kbn/rule-data-utils/target_node/technical_field_names'; -import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils'; +} from '@kbn/rule-data-utils/technical_field_names'; +import { + ALERT_STATUS_ACTIVE, + ALERT_STATUS_RECOVERED, +} from '@kbn/rule-data-utils/alerts_as_data_status'; import type { CellValueElementProps, TimelineNonEcsData } from '../../../../timelines/common'; import { AlertStatusIndicator } from '../../components/shared/alert_status_indicator'; import { TimestampTooltip } from '../../components/shared/timestamp_tooltip'; @@ -35,11 +26,6 @@ import { TopAlert } from '.'; import { parseAlert } from './parse_alert'; import { usePluginContext } from '../../hooks/use_plugin_context'; -const ALERT_DURATION: typeof ALERT_DURATION_TYPED = ALERT_DURATION_NON_TYPED; -const ALERT_SEVERITY: typeof ALERT_SEVERITY_TYPED = ALERT_SEVERITY_NON_TYPED; -const ALERT_STATUS: typeof ALERT_STATUS_TYPED = ALERT_STATUS_NON_TYPED; -const ALERT_REASON: typeof ALERT_REASON_TYPED = ALERT_REASON_NON_TYPED; - export const getMappedNonEcsValue = ({ data, fieldName, 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 47b00fb1348eb..c17681d72477e 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,6 @@ * 2.0. */ -export * from '@kbn/rule-data-utils'; +export * from '@kbn/rule-data-utils/technical_field_names'; +export * from '@kbn/rule-data-utils/alerts_as_data_status'; +export * from '@kbn/rule-data-utils/alerts_as_data_rbac'; diff --git a/x-pack/plugins/security_solution/common/field_maps/field_names.ts b/x-pack/plugins/security_solution/common/field_maps/field_names.ts index 1cb40063202d0..f5a293b975afa 100644 --- a/x-pack/plugins/security_solution/common/field_maps/field_names.ts +++ b/x-pack/plugins/security_solution/common/field_maps/field_names.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_NAMESPACE, ALERT_RULE_NAMESPACE } from '@kbn/rule-data-utils'; +import { ALERT_NAMESPACE, ALERT_RULE_NAMESPACE } from '@kbn/rule-data-utils/technical_field_names'; export const ALERT_ANCESTORS = `${ALERT_NAMESPACE}.ancestors` as const; export const ALERT_BUILDING_BLOCK_TYPE = `${ALERT_NAMESPACE}.building_block_type` as const; diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx index aec7f255ad588..bb095d0b7faed 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx @@ -14,7 +14,11 @@ import dateMath from '@elastic/datemath'; import { FilterStateStore, Filter } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; -import { ALERT_RULE_FROM, ALERT_RULE_TYPE, ALERT_RULE_NOTE } from '@kbn/rule-data-utils'; +import { + ALERT_RULE_FROM, + ALERT_RULE_TYPE, + ALERT_RULE_NOTE, +} from '@kbn/rule-data-utils/technical_field_names'; import { ALERT_ORIGINAL_TIME, diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx index 6cc81288a7361..6c9d41b27ae25 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx @@ -15,7 +15,7 @@ import { ALERT_RULE_UUID, ALERT_RULE_NAME, ALERT_RULE_CATEGORY, -} from '@kbn/rule-data-utils'; +} from '@kbn/rule-data-utils/technical_field_names'; import { defaultColumnHeaderType } from '../../../timelines/components/timeline/body/column_headers/default_headers'; import { ColumnHeaderOptions, RowRendererId } from '../../../../common/types/timeline'; diff --git a/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/columns.ts b/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/columns.ts index ae9285f85501b..c9d317bb250e9 100644 --- a/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/columns.ts +++ b/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/columns.ts @@ -6,7 +6,7 @@ */ import { EuiDataGridColumn } from '@elastic/eui'; -import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils'; +import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import { ColumnHeaderOptions } from '../../../../../common'; import { defaultColumnHeaderType } from '../../../../timelines/components/timeline/body/column_headers/default_headers'; diff --git a/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.test.tsx b/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.test.tsx index a4826445b23cf..685bc8f42b1d8 100644 --- a/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.test.tsx @@ -9,7 +9,7 @@ import { mount } from 'enzyme'; import { cloneDeep } from 'lodash/fp'; import React from 'react'; -import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils'; +import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import { mockBrowserFields } from '../../../../common/containers/source/mock'; import { DragDropContextWrapper } from '../../../../common/components/drag_and_drop/drag_drop_context_wrapper'; diff --git a/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.tsx b/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.tsx index 12e0a5486b3a2..1b8c6fdf6487c 100644 --- a/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.tsx +++ b/x-pack/plugins/security_solution/public/detections/configurations/examples/observablity_alerts/render_cell_value.tsx @@ -9,7 +9,7 @@ import moment from 'moment'; import React from 'react'; import { EuiDataGridCellValueElementProps, EuiLink } from '@elastic/eui'; -import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils'; +import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import { TruncatableText } from '../../../../common/components/truncatable_text'; import { Severity } from '../../../components/severity'; diff --git a/x-pack/plugins/security_solution/public/helpers.tsx b/x-pack/plugins/security_solution/public/helpers.tsx index f160d293dd475..170d7175aa5f3 100644 --- a/x-pack/plugins/security_solution/public/helpers.tsx +++ b/x-pack/plugins/security_solution/public/helpers.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERT_RULE_UUID } from '@kbn/rule-data-utils'; +import { ALERT_RULE_UUID } from '@kbn/rule-data-utils/technical_field_names'; import { get, isEmpty } from 'lodash/fp'; import React from 'react'; import { matchPath, RouteProps, Redirect } from 'react-router-dom'; diff --git a/x-pack/plugins/timelines/public/components/actions/timeline/cases/add_to_case_action.test.tsx b/x-pack/plugins/timelines/public/components/actions/timeline/cases/add_to_case_action.test.tsx index fb0a5ebcbbf9e..ad588b491d06a 100644 --- a/x-pack/plugins/timelines/public/components/actions/timeline/cases/add_to_case_action.test.tsx +++ b/x-pack/plugins/timelines/public/components/actions/timeline/cases/add_to_case_action.test.tsx @@ -11,7 +11,7 @@ import { TestProviders, mockGetAllCasesSelectorModal } from '../../../../mock'; import { AddToCaseAction } from './add_to_case_action'; import { SECURITY_SOLUTION_OWNER } from '../../../../../../cases/common'; import { AddToCaseActionButton } from './add_to_case_action_button'; -import { ALERT_RULE_UUID } from '@kbn/rule-data-utils'; +import { ALERT_RULE_UUID } from '@kbn/rule-data-utils/technical_field_names'; jest.mock('react-router-dom', () => ({ useLocation: () => ({ diff --git a/x-pack/plugins/timelines/public/components/t_grid/body/helpers.tsx b/x-pack/plugins/timelines/public/components/t_grid/body/helpers.tsx index 75b991b2583a1..b4374123861ba 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/body/helpers.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/body/helpers.tsx @@ -5,7 +5,10 @@ * 2.0. */ -import { ALERT_RULE_CONSUMER, ALERT_RULE_PRODUCER } from '@kbn/rule-data-utils'; +import { + ALERT_RULE_CONSUMER, + ALERT_RULE_PRODUCER, +} from '@kbn/rule-data-utils/technical_field_names'; import { isEmpty } from 'lodash/fp'; import { EuiDataGridCellValueElementProps } from '@elastic/eui'; diff --git a/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx index fbe3be0d71182..6f4fc6217ecdf 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx @@ -32,7 +32,10 @@ import React, { import { connect, ConnectedProps, useDispatch } from 'react-redux'; import styled, { ThemeContext } from 'styled-components'; -import { ALERT_RULE_CONSUMER, ALERT_RULE_PRODUCER } from '@kbn/rule-data-utils'; +import { + ALERT_RULE_CONSUMER, + ALERT_RULE_PRODUCER, +} from '@kbn/rule-data-utils/technical_field_names'; import { TGridCellAction, BulkActionsProp, diff --git a/x-pack/plugins/timelines/public/components/t_grid/event_rendered_view/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/event_rendered_view/index.tsx index 523460bfd2d01..6267c9d3a4953 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/event_rendered_view/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/event_rendered_view/index.tsx @@ -15,7 +15,7 @@ import { EuiHorizontalRule, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { ALERT_RULE_NAME } from '@kbn/rule-data-utils'; +import { ALERT_RULE_NAME } from '@kbn/rule-data-utils/technical_field_names'; import { get } from 'lodash'; import moment from 'moment'; import React, { ComponentType, useCallback, useMemo } from 'react'; 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 4716901ee256f..b83c1570d9073 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,9 +5,7 @@ * 2.0. */ -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 { AlertConsumers } from '@kbn/rule-data-utils/alerts_as_data_rbac'; import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui'; import { isEmpty } from 'lodash/fp'; import React, { useEffect, useMemo, useRef, useState } from 'react'; @@ -50,8 +48,6 @@ import { InspectButton, InspectButtonContainer } from '../../inspect'; import { SummaryViewSelector, ViewSelection } from '../event_rendered_view/selector'; import { TGridLoading, TGridEmpty, TimelineContext } from '../shared'; -const AlertConsumers: typeof AlertConsumersTyped = AlertConsumersNonTyped; - const TitleText = styled.span` margin-right: 12px; `; diff --git a/x-pack/plugins/timelines/public/container/index.tsx b/x-pack/plugins/timelines/public/container/index.tsx index fa27b8264a38e..8a6c4ac53faa5 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'; +import type { AlertConsumers } from '@kbn/rule-data-utils/alerts_as_data_rbac'; 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/public/hooks/use_add_to_case.test.ts b/x-pack/plugins/timelines/public/hooks/use_add_to_case.test.ts index 5b654f40deea6..4a62206630644 100644 --- a/x-pack/plugins/timelines/public/hooks/use_add_to_case.test.ts +++ b/x-pack/plugins/timelines/public/hooks/use_add_to_case.test.ts @@ -6,7 +6,7 @@ */ import { normalizedEventFields } from './use_add_to_case'; -import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; +import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils/technical_field_names'; import { merge } from 'lodash'; const defaultArgs = { diff --git a/x-pack/plugins/timelines/public/hooks/use_add_to_case.ts b/x-pack/plugins/timelines/public/hooks/use_add_to_case.ts index a9804eb1277c9..c20e6e8370b50 100644 --- a/x-pack/plugins/timelines/public/hooks/use_add_to_case.ts +++ b/x-pack/plugins/timelines/public/hooks/use_add_to_case.ts @@ -8,7 +8,7 @@ import { get, isEmpty } from 'lodash/fp'; import { useState, useCallback, useMemo, SyntheticEvent } from 'react'; import { useLocation } from 'react-router-dom'; import { useDispatch } from 'react-redux'; -import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; +import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils/technical_field_names'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; import { Case, SubCase } from '../../../cases/common'; import { TimelinesStartServices } from '../types'; diff --git a/x-pack/plugins/timelines/public/mock/t_grid.tsx b/x-pack/plugins/timelines/public/mock/t_grid.tsx index c79d0f406ec62..e341803835e24 100644 --- a/x-pack/plugins/timelines/public/mock/t_grid.tsx +++ b/x-pack/plugins/timelines/public/mock/t_grid.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { ALERT_START, ALERT_STATUS } from '@kbn/rule-data-utils'; +import { ALERT_START, ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import { TGridIntegratedProps } from '../components/t_grid/integrated'; import { mockBrowserFields, mockDocValueFields, mockRuntimeMappings } from './browser_fields'; import { mockDataProviders } from './mock_data_providers'; diff --git a/x-pack/plugins/uptime/public/lib/alert_types/duration_anomaly.tsx b/x-pack/plugins/uptime/public/lib/alert_types/duration_anomaly.tsx index 3a97eaa2d8402..72501bd5bee13 100644 --- a/x-pack/plugins/uptime/public/lib/alert_types/duration_anomaly.tsx +++ b/x-pack/plugins/uptime/public/lib/alert_types/duration_anomaly.tsx @@ -8,7 +8,8 @@ import React from 'react'; import moment from 'moment'; -import { ALERT_END, ALERT_STATUS, ALERT_STATUS_ACTIVE, ALERT_REASON } from '@kbn/rule-data-utils'; +import { ALERT_END, ALERT_STATUS, ALERT_REASON } from '@kbn/rule-data-utils/technical_field_names'; +import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; import { AlertTypeInitializer } from '.'; import { getMonitorRouteFromMonitorId } from './common'; diff --git a/x-pack/plugins/uptime/public/lib/alert_types/monitor_status.tsx b/x-pack/plugins/uptime/public/lib/alert_types/monitor_status.tsx index 5b0c2f77b9f49..b71d1bab3fed8 100644 --- a/x-pack/plugins/uptime/public/lib/alert_types/monitor_status.tsx +++ b/x-pack/plugins/uptime/public/lib/alert_types/monitor_status.tsx @@ -12,9 +12,9 @@ import { ALERT_END, ALERT_START, ALERT_STATUS, - ALERT_STATUS_ACTIVE, ALERT_REASON, -} from '@kbn/rule-data-utils'; +} from '@kbn/rule-data-utils/technical_field_names'; +import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; import { AlertTypeInitializer } from '.'; import { getMonitorRouteFromMonitorId } from './common'; diff --git a/x-pack/plugins/uptime/public/lib/alert_types/tls.tsx b/x-pack/plugins/uptime/public/lib/alert_types/tls.tsx index c83743c2373f7..ca98b74943f07 100644 --- a/x-pack/plugins/uptime/public/lib/alert_types/tls.tsx +++ b/x-pack/plugins/uptime/public/lib/alert_types/tls.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { ALERT_REASON } from '@kbn/rule-data-utils'; +import { ALERT_REASON } from '@kbn/rule-data-utils/technical_field_names'; import { ObservabilityRuleTypeModel } from '../../../../observability/public'; import { CLIENT_ALERT_TYPES } from '../../../common/constants/alerts'; import { TlsTranslations } from '../../../common/translations'; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts index 559ada3f891bc..db74190052065 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { ALERT_WORKFLOW_STATUS } from '@kbn/rule-data-utils'; +import { ALERT_WORKFLOW_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/comments/post_comment.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/comments/post_comment.ts index 6c8acb3bbc3b3..9eb4a0a78ec9b 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/comments/post_comment.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/comments/post_comment.ts @@ -7,7 +7,7 @@ import { omit } from 'lodash/fp'; import expect from '@kbn/expect'; -import { ALERT_WORKFLOW_STATUS } from '@kbn/rule-data-utils'; +import { ALERT_WORKFLOW_STATUS } from '@kbn/rule-data-utils/technical_field_names'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { CASES_URL } from '../../../../../../plugins/cases/common/constants';