[kbn/rule-data-utils] add submodules and require public use them (#117963)

* [kbn/rule-data-utils] add submodules and require public use them

* fix lint errors

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Spencer 2021-11-15 14:23:52 -08:00 committed by GitHub
parent 7c8b6b6f9e
commit 0f68fcf5af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 146 additions and 253 deletions

View file

@ -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`,
},
],
},
],

View file

@ -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 = [

View file

@ -0,0 +1,4 @@
{
"main": "../target_node/alerts_as_data_rbac",
"types": "../target_types/alerts_as_data_rbac"
}

View file

@ -0,0 +1,4 @@
{
"main": "../target_node/alerts_as_data_severity",
"types": "../target_types/alerts_as_data_severity"
}

View file

@ -0,0 +1,4 @@
{
"main": "../target_node/alerts_as_data_status",
"types": "../target_types/alerts_as_data_status"
}

View file

@ -0,0 +1,4 @@
{
"main": "../target_node/technical_field_names",
"types": "../target_types/technical_field_names"
}

View file

@ -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,

View file

@ -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'>;

View file

@ -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';

View file

@ -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']
>;

View file

@ -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;

View file

@ -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';

View file

@ -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(),

View file

@ -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(),

View file

@ -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()),

View file

@ -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(),

View file

@ -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,

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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 }) => {

View file

@ -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 {

View file

@ -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';

View file

@ -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,

View file

@ -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;

View file

@ -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 = [
{

View file

@ -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<string, unknown>): TopAlert => {

View file

@ -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';

View file

@ -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,

View file

@ -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';

View file

@ -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;

View file

@ -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,

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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: () => ({

View file

@ -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';

View file

@ -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,

View file

@ -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';

View file

@ -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;
`;

View file

@ -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';

View file

@ -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 = {

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';