Skip to content

Commit

Permalink
Remove dependency between alerts and infra (#88342) (#88473)
Browse files Browse the repository at this point in the history
The alerts plugin was importing `JsonObject` from the infra plugin. The infra plugin imported `JsonObject`, `JsonValue`, and `JsonArray` from kibanaUtils and then re-exported them.

Remove the re-export from the infra plugin and instead always import these types from kibanaUtils.
  • Loading branch information
smith authored Jan 15, 2021
1 parent dd20886 commit eba5539
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 21 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/alerts/common/alert_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { JsonObject } from '../../infra/common/typed_json';
import { JsonObject } from '../../../../src/plugins/kibana_utils/common';

export interface AlertUrlNavigation {
path: string;
}
Expand Down
10 changes: 9 additions & 1 deletion x-pack/plugins/alerts/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["xpack", "alerts"],
"requiredPlugins": ["licensing", "taskManager", "encryptedSavedObjects", "actions", "eventLog", "features"],
"requiredPlugins": [
"actions",
"encryptedSavedObjects",
"eventLog",
"features",
"kibanaUtils",
"licensing",
"taskManager"
],
"optionalPlugins": ["usageCollection", "spaces", "security"],
"extraPublicDirs": ["common", "common/parse_duration"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { JsonObject } from '../../../infra/common/typed_json';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import { AlertType, SanitizedAlert } from '../../common';

export type AlertNavigationHandler = (
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/infra/common/typed_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export const jsonArrayRT: rt.Type<JsonArray> = rt.recursion('JsonArray', () =>
export const jsonObjectRT: rt.Type<JsonObject> = rt.recursion('JsonObject', () =>
rt.record(rt.string, jsonValueRT)
);

export { JsonValue, JsonArray, JsonObject };
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useLogStream } from '../../containers/logs/log_stream';

import { ScrollableLogTextStreamView } from '../logging/log_text_stream';
import { LogColumnRenderConfiguration } from '../../utils/log_column_render_configuration';
import { JsonValue } from '../../../common/typed_json';
import { JsonValue } from '../../../../../../src/plugins/kibana_utils/common';

const PAGE_THRESHOLD = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import stringify from 'json-stable-stringify';
import React from 'react';
import { euiStyled } from '../../../../../observability/public';
import { JsonArray, JsonValue } from '../../../../common/typed_json';
import { JsonArray, JsonValue } from '../../../../../../../src/plugins/kibana_utils/common';
import { ActiveHighlightMarker, highlightFieldValue, HighlightMarker } from './highlighting';

export const FieldValue: React.FC<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React from 'react';
import { JsonValue } from '../../../../common/typed_json';
import { JsonValue } from '../../../../../../../src/plugins/kibana_utils/common';
import { euiStyled } from '../../../../../observability/public';
import { LogColumn } from '../../../../common/http_api';
import { isFieldColumn, isHighlightFieldColumn } from '../../../utils/log_entry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { ReactNode } from 'react';
import { JsonValue } from '../../common/typed_json';
import { JsonValue } from '../../../../../src/plugins/kibana_utils/common';

/**
* Interface for common configuration properties, regardless of the column type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { PluginSetupContract as FeaturesPluginSetup } from '../../../../../../pl
import { SpacesPluginSetup } from '../../../../../../plugins/spaces/server';
import { PluginSetupContract as AlertingPluginContract } from '../../../../../alerts/server';
import { MlPluginSetup } from '../../../../../ml/server';
import { JsonArray, JsonValue } from '../../../../common/typed_json';
import { JsonArray, JsonValue } from '../../../../../../../src/plugins/kibana_utils/common';

export interface InfraServerPluginSetupDeps {
data: DataPluginSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import * as runtimeTypes from 'io-ts';
import { compact } from 'lodash';
import { RequestHandlerContext } from 'src/core/server';
import { JsonArray } from '../../../../common/typed_json';
import { JsonArray } from '../../../../../../../src/plugins/kibana_utils/common';
import {
LogEntriesAdapter,
LogEntriesParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { RequestHandlerContext } from 'src/core/server';
import { JsonObject } from '../../../../common/typed_json';
import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/common';
import {
LogEntriesSummaryBucket,
LogEntriesSummaryHighlightsBucket,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { LogMessagePart } from '../../../../common/http_api/log_entries';
import { JsonArray, JsonValue } from '../../../../common/typed_json';
import { JsonArray, JsonValue } from '../../../../../../../src/plugins/kibana_utils/common';
import {
LogMessageFormattingCondition,
LogMessageFormattingFieldValueConditionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { JsonValue } from '../../../../common/typed_json';
import { JsonValue } from '../../../../../../../src/plugins/kibana_utils/common';

export interface LogMessageFormattingRule {
when: LogMessageFormattingCondition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { JsonObject } from '../../../../common/typed_json';
import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/common';
import {
InventoryItemType,
MetricsUIAggregation,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/server/utils/serialized_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { UserInputError } from 'apollo-server-errors';

import { JsonObject } from '../../common/typed_json';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';

export const parseFilterQuery = (
filterQuery: string | null | undefined
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/infra/server/utils/typed_search_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import * as rt from 'io-ts';
import stringify from 'json-stable-stringify';
import { JsonValue, jsonValueRT } from '../../common/typed_json';
import { JsonValue } from '../../../../../src/plugins/kibana_utils/common';
import { jsonValueRT } from '../../common/typed_json';
import { SearchStrategyError } from '../../common/search_strategies/common/errors';
import { ShardFailure } from './elasticsearch_runtime_types';

Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/infra/types/eui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

import { IconType, ToolTipPositions } from '@elastic/eui';
import { CommonProps } from '@elastic/eui/src/components/common';
import moment from 'moment';
import { MouseEventHandler, ReactType, Ref } from 'react';
import { JsonObject } from '../common/typed_json';

declare module '@elastic/eui' {
interface EuiFormControlLayoutIconProps {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/server/endpoint/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LoggerFactory } from 'kibana/server';
import { SearchResponse } from 'elasticsearch';
import { ConfigType } from '../config';
import { EndpointAppContextService } from './endpoint_app_context_services';
import { JsonObject } from '../../../infra/common/typed_json';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import {
HostMetadata,
HostMetadataDetails,
Expand Down

0 comments on commit eba5539

Please sign in to comment.