Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NA): moving @kbn/rule-data-utils to babel transpiler #107573

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/kbn-rule-data-utils/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
22 changes: 15 additions & 7 deletions packages/kbn-rule-data-utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")

PKG_BASE_NAME = "kbn-rule-data-utils"
PKG_REQUIRE_NAME = "@kbn/rule-data-utils"
Expand All @@ -21,17 +22,23 @@ NPM_MODULE_EXTRA_FILES = [
"package.json",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"@npm//tslib",
"@npm//utility-types",
]

TYPES_DEPS = [
"@npm//tslib",
"@npm//utility-types",
"@npm//@types/jest",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
Expand All @@ -42,14 +49,15 @@ ts_config(
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
emit_declaration_only = True,
incremental = False,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
Expand All @@ -58,7 +66,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-rule-data-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kbn/rule-data-utils",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
Expand Down
11 changes: 6 additions & 5 deletions packages/kbn-rule-data-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": true,
"outDir": "./target",
"stripInternal": false,
"declaration": true,
"declarationMap": true,
"rootDir": "./src",
"emitDeclarationOnly": true,
"incremental": false,
"outDir": "./target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-rule-data-utils/src",
"stripInternal": false,
"types": [
"jest",
"node"
]
},
"include": [
"./src/**/*.ts"
"src/**/*.ts"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ALERT_EVALUATION_THRESHOLD,
ALERT_EVALUATION_VALUE,
ALERT_SEVERITY_LEVEL,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
mistic marked this conversation as resolved.
Show resolved Hide resolved
import type { ObservabilityRuleTypeRegistry } from '../../../../observability/public';
import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values';
import { AlertType } from '../../../common/alert_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { EuiTitle } from '@elastic/eui';
import d3 from 'd3';
import React, { Suspense, useState } from 'react';
import { RULE_ID } from '@kbn/rule-data-utils/target/technical_field_names';
import { RULE_ID } from '@kbn/rule-data-utils';
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
import { APIReturnType } from '../../../../services/rest/createCallApmApi';
import { asRelativeDateTimeRange } from '../../../../../common/utils/formatters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
ALERT_UUID,
RULE_ID,
RULE_NAME,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import React, { Dispatch, SetStateAction } from 'react';
import { EuiTheme } from 'src/plugins/kibana_react/common';
import { ValuesType } from 'utility-types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiSelect, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useHistory } from 'react-router-dom';
import { RULE_ID } from '@kbn/rule-data-utils/target/technical_field_names';
import { RULE_ID } from '@kbn/rule-data-utils';
import { AlertType } from '../../../../../common/alert_types';
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
import { LatencyAggregationType } from '../../../../../common/latency_aggregation_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { take } from 'rxjs/operators';
import {
ALERT_EVALUATION_THRESHOLD,
ALERT_EVALUATION_VALUE,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';
import {
ENVIRONMENT_NOT_DEFINED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types';
import {
ALERT_EVALUATION_THRESHOLD,
ALERT_EVALUATION_VALUE,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';
import {
getEnvironmentLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ALERT_EVALUATION_VALUE,
ALERT_SEVERITY_LEVEL,
ALERT_SEVERITY_VALUE,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';
import { ProcessorEvent } from '../../../common/processor_event';
import { getSeverity } from '../../../common/anomaly_detection';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { take } from 'rxjs/operators';
import {
ALERT_EVALUATION_THRESHOLD,
ALERT_EVALUATION_VALUE,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import {
ENVIRONMENT_NOT_DEFINED,
getEnvironmentEsField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { EVENT_KIND } from '@kbn/rule-data-utils/target/technical_field_names';
import { EVENT_KIND } from '@kbn/rule-data-utils';
import { RuleDataClient } from '../../../../rule_registry/server';
import {
SERVICE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
ALERT_UUID,
RULE_CATEGORY,
RULE_NAME,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import moment from 'moment-timezone';
import React, { useMemo } from 'react';
import type { TopAlert, TopAlertResponse } from '../';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import {
EuiLink,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import {
ALERT_DURATION,
ALERT_SEVERITY_LEVEL,
ALERT_UUID,
} from '@kbn/rule-data-utils/target/technical_field_names';
import { ALERT_DURATION, ALERT_SEVERITY_LEVEL, ALERT_UUID } from '@kbn/rule-data-utils';
import React, { Suspense, useMemo, useState } from 'react';
import { LazyAlertsFlyout } from '../..';
import { asDuration } from '../../../common/utils/formatters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ALERT_STATUS,
ALERT_START,
RULE_NAME,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';

import type { TimelinesUIStart } from '../../../../timelines/public';
import type { TopAlert } from './';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
EuiPopoverTitle,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { RULE_ID, RULE_NAME } from '@kbn/rule-data-utils/target/technical_field_names';
import { RULE_ID, RULE_NAME } from '@kbn/rule-data-utils';
import React, { useState } from 'react';
import { format, parse } from 'url';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
* 2.0.
*/

import {
RULE_ID,
RULE_NAME,
ALERT_STATUS,
ALERT_START,
} from '@kbn/rule-data-utils/target/technical_field_names';
import { RULE_ID, RULE_NAME, ALERT_STATUS, ALERT_START } from '@kbn/rule-data-utils';
import type { TopAlertResponse, TopAlert } from '.';
import { parseTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields';
import { asDuration, asPercent } from '../../../common/utils/formatters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ALERT_STATUS,
ALERT_START,
RULE_NAME,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';

import type { CellValueElementProps, TimelineNonEcsData } from '../../../../timelines/common';
import { TimestampTooltip } from '../../components/shared/timestamp_tooltip';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { EVENT_KIND, TIMESTAMP } from '@kbn/rule-data-utils/target/technical_field_names';
import { EVENT_KIND, TIMESTAMP } from '@kbn/rule-data-utils';
import { RuleDataClient } from '../../../../rule_registry/server';
import type { AlertStatus } from '../../../common/typings';
import { kqlQuery, rangeQuery, alertStatusQuery } from '../../utils/queries';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/server/utils/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ALERT_STATUS } from '@kbn/rule-data-utils/target/technical_field_names';
import { ALERT_STATUS } from '@kbn/rule-data-utils';
import * as queries from './queries';

describe('queries', () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/server/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { estypes } from '@elastic/elasticsearch';
import { ALERT_STATUS } from '@kbn/rule-data-utils/target/technical_field_names';
import { ALERT_STATUS } from '@kbn/rule-data-utils';
import { esKuery } from '../../../../../src/plugins/data/server';
import { AlertStatus } from '../../common/typings';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* 2.0.
*/

export * from '@kbn/rule-data-utils/target/technical_field_names';
export * from '@kbn/rule-data-utils';
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
*/
import { PublicMethodsOf } from '@kbn/utility-types';
import { decodeVersion, encodeHitVersion } from '@kbn/securitysolution-es-utils';
import {
mapConsumerToIndexName,
validFeatureIds,
isValidFeatureId,
} from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import { mapConsumerToIndexName, validFeatureIds, isValidFeatureId } from '@kbn/rule-data-utils';

import { AlertTypeParams } from '../../../alerting/server';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { IRouter } from 'kibana/server';
import { id as _id } from '@kbn/securitysolution-io-ts-list-types';
import { transformError } from '@kbn/securitysolution-es-utils';
import { validFeatureIds } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import { validFeatureIds } from '@kbn/rule-data-utils';

import { RacRequestHandlerContext } from '../types';
import { BASE_RAC_ALERTS_API_PATH } from '../../common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ApiResponse } from '@elastic/elasticsearch';
import { BulkRequest, BulkResponse } from '@elastic/elasticsearch/api/types';
import { ValidFeatureId } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import { ValidFeatureId } from '@kbn/rule-data-utils';

import { ElasticsearchClient } from 'kibana/server';
import { FieldDescriptor } from 'src/plugins/data/server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { ClusterPutComponentTemplate } from '@elastic/elasticsearch/api/requestParams';
import { estypes } from '@elastic/elasticsearch';
import { ValidFeatureId } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import { ValidFeatureId } from '@kbn/rule-data-utils';

import { ElasticsearchClient, Logger } from 'kibana/server';
import { get, isEmpty } from 'lodash';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ALERT_ID } from '@kbn/rule-data-utils/target/technical_field_names';
import { ALERT_ID } from '@kbn/rule-data-utils';
import { CreatePersistenceRuleTypeFactory } from './persistence_types';

export const createPersistenceRuleTypeFactory: CreatePersistenceRuleTypeFactory = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { ALERTS_CONSUMERS } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import type { ALERTS_CONSUMERS } from '@kbn/rule-data-utils';

import { IEsSearchRequest } from '../../../../../../src/plugins/data/common';
import { ESQuery } from '../../typed_json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* 2.0.
*/

import { ALERT_OWNER, RULE_ID, SPACE_IDS } from '@kbn/rule-data-utils';
import { map, mergeMap, catchError } from 'rxjs/operators';
import { from } from 'rxjs';
import {
ALERT_OWNER,
RULE_ID,
SPACE_IDS,
isValidFeatureId,
mapConsumerToIndexName,
ALERTS_CONSUMERS,
} from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
} from '@kbn/rule-data-utils';

import {
AlertingAuthorizationEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ALERT_SEVERITY_VALUE,
ALERT_EVALUATION_VALUE,
ALERT_EVALUATION_THRESHOLD,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';

interface MockAnomaly {
severity: AnomaliesTableRecord['severity'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ALERT_SEVERITY_VALUE,
ALERT_EVALUATION_VALUE,
ALERT_EVALUATION_THRESHOLD,
} from '@kbn/rule-data-utils/target/technical_field_names';
} from '@kbn/rule-data-utils';
import { ActionGroupIdsOf } from '../../../../alerting/common';
import { updateState, generateAlertMessage } from './common';
import { DURATION_ANOMALY } from '../../../common/constants/alerts';
Expand Down