Skip to content

Commit aa6fe69

Browse files
chore(NA): splits types from code on @kbn/rule-data-utils (elastic#121535)
* chore(NA): splits types from code on @kbn/rule-data-utils * chore(NA): remove old style imports for this pkg * chore(NA): eslint fix Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent e8bf039 commit aa6fe69

File tree

65 files changed

+93
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+93
-161
lines changed

.eslintrc.js

-4
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,6 @@ module.exports = {
850850
name: 'semver',
851851
message: 'Please use "semver/*/{function}" instead',
852852
},
853-
{
854-
name: '@kbn/rule-data-utils',
855-
message: `Import directly from @kbn/rule-data-utils/* submodules in public/common code`,
856-
},
857853
],
858854
},
859855
],

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@
581581
"@types/kbn__plugin-generator": "link:bazel-bin/packages/kbn-plugin-generator/npm_module_types",
582582
"@types/kbn__plugin-helpers": "link:bazel-bin/packages/kbn-plugin-helpers/npm_module_types",
583583
"@types/kbn__react-field": "link:bazel-bin/packages/kbn-react-field/npm_module_types",
584+
"@types/kbn__rule-data-utils": "link:bazel-bin/packages/kbn-rule-data-utils/npm_module_types",
584585
"@types/license-checker": "15.0.0",
585586
"@types/listr": "^0.14.0",
586587
"@types/loader-utils": "^1.1.3",

packages/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ filegroup(
9999
"//packages/kbn-plugin-generator:build_types",
100100
"//packages/kbn-plugin-helpers:build_types",
101101
"//packages/kbn-react-field:build_types",
102+
"//packages/kbn-rule-data-utils:build_types",
102103
],
103104
)
104105

packages/kbn-rule-data-utils/BUILD.bazel

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
2-
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
3-
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
1+
load("@npm//@bazel/typescript:index.bzl", "ts_config")
2+
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
3+
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
44

55
PKG_BASE_NAME = "kbn-rule-data-utils"
66
PKG_REQUIRE_NAME = "@kbn/rule-data-utils"
7+
TYPES_PKG_REQUIRE_NAME = "@types/kbn__rule-data-utils"
78

89
SOURCE_FILES = glob(
910
[
@@ -20,10 +21,6 @@ filegroup(
2021

2122
NPM_MODULE_EXTRA_FILES = [
2223
"package.json",
23-
"alerts_as_data_rbac/package.json",
24-
"alerts_as_data_severity/package.json",
25-
"alerts_as_data_status/package.json",
26-
"technical_field_names/package.json",
2724
]
2825

2926
RUNTIME_DEPS = [
@@ -75,7 +72,7 @@ ts_project(
7572
js_library(
7673
name = PKG_BASE_NAME,
7774
srcs = NPM_MODULE_EXTRA_FILES,
78-
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
75+
deps = RUNTIME_DEPS + [":target_node"],
7976
package_name = PKG_REQUIRE_NAME,
8077
visibility = ["//visibility:public"],
8178
)
@@ -94,3 +91,20 @@ filegroup(
9491
],
9592
visibility = ["//visibility:public"],
9693
)
94+
95+
pkg_npm_types(
96+
name = "npm_module_types",
97+
srcs = SRCS,
98+
deps = [":tsc_types"],
99+
package_name = TYPES_PKG_REQUIRE_NAME,
100+
tsconfig = ":tsconfig",
101+
visibility = ["//visibility:public"],
102+
)
103+
104+
filegroup(
105+
name = "build_types",
106+
srcs = [
107+
":npm_module_types",
108+
],
109+
visibility = ["//visibility:public"],
110+
)

packages/kbn-rule-data-utils/alerts_as_data_rbac/package.json

-4
This file was deleted.

packages/kbn-rule-data-utils/alerts_as_data_severity/package.json

-4
This file was deleted.

packages/kbn-rule-data-utils/alerts_as_data_status/package.json

-4
This file was deleted.

packages/kbn-rule-data-utils/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@kbn/rule-data-utils",
33
"main": "./target_node/index.js",
4-
"types": "./target_types/index.d.ts",
54
"version": "1.0.0",
65
"license": "SSPL-1.0 OR Elastic License 2.0",
76
"private": true

packages/kbn-rule-data-utils/technical_field_names/package.json

-4
This file was deleted.

x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ALERT_EVALUATION_THRESHOLD,
1313
ALERT_EVALUATION_VALUE,
1414
ALERT_SEVERITY,
15-
} from '@kbn/rule-data-utils/technical_field_names';
15+
} from '@kbn/rule-data-utils';
1616
import type { ObservabilityRuleTypeRegistry } from '../../../../observability/public';
1717
import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values';
1818
import {

x-pack/plugins/apm/public/components/app/error_group_details/Distribution/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '@elastic/charts';
1717
import { EuiTitle } from '@elastic/eui';
1818
import React, { Suspense, useState } from 'react';
19-
import { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils/technical_field_names';
19+
import { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils';
2020
import { i18n } from '@kbn/i18n';
2121
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
2222
import { APIReturnType } from '../../../../services/rest/createCallApmApi';

x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import {
1616
ALERT_SEVERITY,
1717
ALERT_START,
1818
ALERT_STATUS,
19+
ALERT_STATUS_ACTIVE,
1920
ALERT_UUID,
2021
SPACE_IDS,
2122
ALERT_RULE_UUID,
2223
ALERT_RULE_NAME,
2324
ALERT_RULE_CATEGORY,
24-
} from '@kbn/rule-data-utils/technical_field_names';
25-
import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status';
25+
} from '@kbn/rule-data-utils';
2626
import { ValuesType } from 'utility-types';
2727
import { EuiTheme } from '../../../../../../../../src/plugins/kibana_react/common';
2828
import { ObservabilityRuleTypeRegistry } from '../../../../../../observability/public';

x-pack/plugins/apm/public/components/shared/charts/helper/get_alert_annotations.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
ALERT_UUID,
2020
ALERT_RULE_TYPE_ID,
2121
ALERT_RULE_NAME,
22-
} from '@kbn/rule-data-utils/technical_field_names';
22+
} from '@kbn/rule-data-utils';
2323
import React, { Dispatch, SetStateAction } from 'react';
2424
import { EuiTheme } from 'src/plugins/kibana_react/common';
2525
import { ValuesType } from 'utility-types';

x-pack/plugins/apm/public/components/shared/charts/latency_chart/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiSelect, EuiTitle } from '@elastic/eui';
99
import { i18n } from '@kbn/i18n';
1010
import React from 'react';
1111
import { useHistory } from 'react-router-dom';
12-
import { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils/technical_field_names';
12+
import { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils';
1313
import { AlertType } from '../../../../../common/alert_types';
1414
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
1515
import { LatencyAggregationType } from '../../../../../common/latency_aggregation_types';

x-pack/plugins/apm/public/components/shared/charts/latency_chart/latency_chart.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ALERT_SEVERITY,
1515
ALERT_START,
1616
ALERT_STATUS,
17+
ALERT_STATUS_ACTIVE,
1718
ALERT_UUID,
1819
TIMESTAMP,
1920
ALERT_RULE_UUID,
@@ -22,8 +23,7 @@ import {
2223
ALERT_RULE_CONSUMER,
2324
ALERT_RULE_PRODUCER,
2425
SPACE_IDS,
25-
} from '@kbn/rule-data-utils/technical_field_names';
26-
import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status';
26+
} from '@kbn/rule-data-utils';
2727
import { Meta, Story } from '@storybook/react';
2828
import React from 'react';
2929
import { MemoryRouter } from 'react-router-dom';

x-pack/plugins/apm/server/routes/alerts/register_error_count_alert_type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ALERT_EVALUATION_THRESHOLD,
1212
ALERT_EVALUATION_VALUE,
1313
ALERT_REASON,
14-
} from '@kbn/rule-data-utils/technical_field_names';
14+
} from '@kbn/rule-data-utils';
1515
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';
1616
import {
1717
ENVIRONMENT_NOT_DEFINED,

x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_alert_type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ALERT_EVALUATION_THRESHOLD,
1212
ALERT_EVALUATION_VALUE,
1313
ALERT_REASON,
14-
} from '@kbn/rule-data-utils/technical_field_names';
14+
} from '@kbn/rule-data-utils';
1515
import { take } from 'rxjs/operators';
1616
import { asDuration } from '../../../../observability/common/utils/formatters';
1717
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';

x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_anomaly_alert_type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
ALERT_EVALUATION_VALUE,
1515
ALERT_SEVERITY,
1616
ALERT_REASON,
17-
} from '@kbn/rule-data-utils/technical_field_names';
17+
} from '@kbn/rule-data-utils';
1818
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';
1919
import { ProcessorEvent } from '../../../common/processor_event';
2020
import { getSeverity } from '../../../common/anomaly_detection';

x-pack/plugins/apm/server/routes/alerts/register_transaction_error_rate_alert_type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ALERT_EVALUATION_THRESHOLD,
1212
ALERT_EVALUATION_VALUE,
1313
ALERT_REASON,
14-
} from '@kbn/rule-data-utils/technical_field_names';
14+
} from '@kbn/rule-data-utils';
1515
import {
1616
ENVIRONMENT_NOT_DEFINED,
1717
getEnvironmentEsField,

x-pack/plugins/apm/server/routes/services/get_service_alerts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import { EVENT_KIND } from '@kbn/rule-data-utils/technical_field_names';
8+
import { EVENT_KIND } from '@kbn/rule-data-utils';
99
import { IRuleDataClient } from '../../../../rule_registry/server';
1010
import {
1111
SERVICE_NAME,

x-pack/plugins/cases/public/components/user_action_tree/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
EuiCommentList,
1313
EuiCommentProps,
1414
} from '@elastic/eui';
15-
import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils/technical_field_names';
15+
import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils';
1616

1717
import classNames from 'classnames';
1818
import { get, isEmpty } from 'lodash';

x-pack/plugins/infra/public/alerting/inventory/rule_data_formatters.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
* 2.0.
66
*/
77

8-
import {
9-
ALERT_REASON,
10-
ALERT_RULE_PARAMETERS,
11-
TIMESTAMP,
12-
} from '@kbn/rule-data-utils/technical_field_names';
8+
import { ALERT_REASON, ALERT_RULE_PARAMETERS, TIMESTAMP } from '@kbn/rule-data-utils';
139
import { encode } from 'rison-node';
1410
import { stringify } from 'query-string';
1511
import { ObservabilityRuleTypeFormatter } from '../../../../observability/public';

x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import { ALERT_REASON, ALERT_START } from '@kbn/rule-data-utils/technical_field_names';
8+
import { ALERT_REASON, ALERT_START } from '@kbn/rule-data-utils';
99
import { modifyUrl } from '@kbn/std';
1010
import { ObservabilityRuleTypeFormatter } from '../../../../observability/public';
1111

x-pack/plugins/infra/public/alerting/metric_threshold/rule_data_formatters.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import { ALERT_REASON } from '@kbn/rule-data-utils/technical_field_names';
8+
import { ALERT_REASON } from '@kbn/rule-data-utils';
99
import { ObservabilityRuleTypeFormatter } from '../../../../observability/public';
1010

1111
export const formatReason: ObservabilityRuleTypeFormatter = ({ fields }) => {

x-pack/plugins/observability/common/typings.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import * as t from 'io-ts';
88

99
export type Maybe<T> = T | null | undefined;
10-
import {
11-
ALERT_STATUS_ACTIVE,
12-
ALERT_STATUS_RECOVERED,
13-
} from '@kbn/rule-data-utils/alerts_as_data_status';
10+
import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils';
1411

1512
export const alertWorkflowStatusRt = t.keyof({
1613
open: null,

x-pack/plugins/observability/public/components/shared/alert_status_indicator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React from 'react';
99
import { i18n } from '@kbn/i18n';
1010
import { EuiHealth, EuiText } from '@elastic/eui';
11-
import { ALERT_STATUS_ACTIVE, AlertStatus } from '@kbn/rule-data-utils/alerts_as_data_status';
11+
import { ALERT_STATUS_ACTIVE, AlertStatus } from '@kbn/rule-data-utils';
1212
import { useTheme } from '../../hooks/use_theme';
1313

1414
interface AlertStatusIndicatorProps {

x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import { ALERT_UUID } from '@kbn/rule-data-utils/technical_field_names';
8+
import { ALERT_UUID } from '@kbn/rule-data-utils';
99
import React, { ComponentType } from 'react';
1010
import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public';
1111
import { PluginContext, PluginContextValue } from '../../../../context/plugin_context';

x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ import {
2828
ALERT_UUID,
2929
ALERT_RULE_CATEGORY,
3030
ALERT_RULE_NAME,
31-
} from '@kbn/rule-data-utils/technical_field_names';
32-
import {
3331
ALERT_STATUS_ACTIVE,
3432
ALERT_STATUS_RECOVERED,
35-
} from '@kbn/rule-data-utils/alerts_as_data_status';
33+
} from '@kbn/rule-data-utils';
3634
import moment from 'moment-timezone';
3735
import React, { useMemo } from 'react';
3836
import type { TopAlert } from '../../containers';

x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/example_data.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import {
1818
ALERT_RULE_NAME,
1919
ALERT_RULE_CATEGORY,
2020
ALERT_RULE_PRODUCER,
21-
} from '@kbn/rule-data-utils/technical_field_names';
22-
import {
2321
ALERT_STATUS_ACTIVE,
2422
ALERT_STATUS_RECOVERED,
25-
} from '@kbn/rule-data-utils/alerts_as_data_status';
23+
} from '@kbn/rule-data-utils';
2624

2725
export const apmAlertResponseExample = [
2826
{

x-pack/plugins/observability/public/pages/alerts/components/alerts_status_filter.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
import { EuiButtonGroup, EuiButtonGroupOptionProps } from '@elastic/eui';
99
import { i18n } from '@kbn/i18n';
1010
import React from 'react';
11-
import {
12-
ALERT_STATUS_ACTIVE,
13-
ALERT_STATUS_RECOVERED,
14-
} from '@kbn/rule-data-utils/alerts_as_data_status';
15-
import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names';
11+
import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED, ALERT_STATUS } from '@kbn/rule-data-utils';
1612
import { AlertStatusFilterButton } from '../../../../common/typings';
1713
import { AlertStatusFilter } from '../../../../common/typings';
1814

x-pack/plugins/observability/public/pages/alerts/components/parse_alert.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import {
99
ALERT_START,
1010
ALERT_STATUS,
11+
ALERT_STATUS_ACTIVE,
1112
ALERT_RULE_TYPE_ID,
1213
ALERT_RULE_NAME,
13-
} from '@kbn/rule-data-utils/technical_field_names';
14-
import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status';
14+
} from '@kbn/rule-data-utils';
1515
import type { TopAlert } from '../';
1616
import { experimentalRuleFieldMap } from '../../../../../rule_registry/common/assets/field_maps/experimental_rule_field_map';
1717
import { parseTechnicalFields } from '../../../../../rule_registry/common/parse_technical_fields';

x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.test.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
* 2.0.
66
*/
77

8-
import {
9-
ALERT_STATUS_ACTIVE,
10-
ALERT_STATUS_RECOVERED,
11-
} from '@kbn/rule-data-utils/alerts_as_data_status';
12-
import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names';
8+
import { ALERT_STATUS, ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils';
139
import type { CellValueElementProps } from '../../../../../../timelines/common';
1410
import { createObservabilityRuleTypeRegistryMock } from '../../../../rules/observability_rule_type_registry_mock';
1511
import * as PluginHook from '../../../../hooks/use_plugin_context';

x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import {
1010
ALERT_DURATION,
1111
ALERT_SEVERITY,
1212
ALERT_STATUS,
13-
ALERT_REASON,
14-
TIMESTAMP,
15-
} from '@kbn/rule-data-utils/technical_field_names';
16-
import {
1713
ALERT_STATUS_ACTIVE,
1814
ALERT_STATUS_RECOVERED,
19-
} from '@kbn/rule-data-utils/alerts_as_data_status';
15+
ALERT_REASON,
16+
TIMESTAMP,
17+
} from '@kbn/rule-data-utils';
2018
import type { CellValueElementProps, TimelineNonEcsData } from '../../../../../../timelines/common';
2119
import { AlertStatusIndicator } from '../../../../components/shared/alert_status_indicator';
2220
import { TimestampTooltip } from '../../../../components/shared/timestamp_tooltip';

x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/alerts_page.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import { IndexPatternBase } from '@kbn/es-query';
1111
import { i18n } from '@kbn/i18n';
1212
import React, { useCallback, useEffect, useRef, useState } from 'react';
1313
import useAsync from 'react-use/lib/useAsync';
14-
import { AlertStatus } from '@kbn/rule-data-utils/alerts_as_data_status';
15-
import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names';
14+
import { ALERT_STATUS, AlertStatus } from '@kbn/rule-data-utils';
1615

1716
import { euiStyled } from '../../../../../../../../src/plugins/kibana_react/common';
1817
import { loadAlertAggregations as loadRuleAggregations } from '../../../../../../../plugins/triggers_actions_ui/public';

0 commit comments

Comments
 (0)