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

[Kuery] Move json utils #102058

Merged
merged 13 commits into from
Jun 16, 2021
1 change: 1 addition & 0 deletions packages/kbn-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './package_json';
export * from './path';
export * from './repo_root';
export * from './streams';
export * from './json';
9 changes: 9 additions & 0 deletions packages/kbn-utils/src/json/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * from './typed_json';
2 changes: 1 addition & 1 deletion src/plugins/data/common/es_query/kuery/ast/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* Side Public License, v 1.
*/

import { JsonObject } from '@kbn/utils';
import { nodeTypes } from '../node_types/index';
import { KQLSyntaxError } from '../kuery_syntax_error';
import { KueryNode, DslQuery, KueryParseOptions } from '../types';
import { IIndexPattern } from '../../../index_patterns/types';

// @ts-ignore
import { parse as parseKuery } from './_generated_/kuery';
import { JsonObject } from '../../../../../kibana_utils/common';

const fromExpression = (
expression: string | DslQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/

import _ from 'lodash';
import { JsonObject } from '@kbn/utils';
import * as ast from '../ast';
import { nodeTypes } from '../node_types';
import { NamedArgTypeBuildNode } from './types';
import { JsonObject } from '../../../../../kibana_utils/common';

export function buildNode(name: string, value: any): NamedArgTypeBuildNode {
const argumentNode =
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/es_query/kuery/node_types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* WARNING: these typings are incomplete
*/

import { JsonValue } from '@kbn/utils';
import { IIndexPattern } from '../../../index_patterns';
import { JsonValue } from '../../../../../kibana_utils/common';
import { KueryNode } from '..';

export type FunctionName =
Expand Down
1 change: 0 additions & 1 deletion src/plugins/kibana_utils/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export * from './field_wildcard';
export * from './of';
export * from './ui';
export * from './state_containers';
export * from './typed_json';
export * from './errors';
export { AbortError, abortSignalToPromise } from './abort_utils';
export { createGetterSetter, Get, Set } from './create_getter_setter';
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/kibana_utils/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export {
fieldWildcardFilter,
fieldWildcardMatcher,
Get,
JsonArray,
JsonObject,
JsonValue,
of,
Set,
UiComponent,
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/alerting/common/alert_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

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

import { JsonObject } from '@kbn/utils';
export interface AlertUrlNavigation {
path: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';
import { SanitizedAlert } from '../../common';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Boom from '@hapi/boom';
import { map, mapValues, fromPairs, has } from 'lodash';
import { KibanaRequest } from 'src/core/server';
import { JsonObject } from '@kbn/utils';
import { AlertTypeRegistry } from '../types';
import { SecurityPluginSetup } from '../../../security/server';
import { RegistryAlertType } from '../alert_type_registry';
Expand All @@ -19,7 +20,6 @@ import {
AlertingAuthorizationFilterOpts,
} from './alerting_authorization_kuery';
import { KueryNode } from '../../../../../src/plugins/data/server';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';

export enum AlertingAuthorizationEntity {
Rule = 'rule',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { remove } from 'lodash';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';
import { nodeBuilder, EsQueryConfig } from '../../../../../src/plugins/data/common';
import { toElasticsearchQuery } from '../../../../../src/plugins/data/common/es_query';
import { KueryNode } from '../../../../../src/plugins/data/server';
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 { JsonValue } from '../../../../../../src/plugins/kibana_utils/common';
import { JsonValue } from '@kbn/utils';

type RenameAlertToRule<K extends string> = K extends `alertTypeId`
? `ruleTypeId`
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/graph/public/types/workspace_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { JsonObject } from '@kbn/utils';
import { FontawesomeIcon } from '../helpers/style_choices';
import { WorkspaceField, AdvancedSettings } from './app_state';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/public';

export interface WorkspaceNode {
x: number;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/common/typed_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as rt from 'io-ts';
import { JsonArray, JsonObject, JsonValue } from '../../../../src/plugins/kibana_utils/common';
import { JsonArray, JsonObject, JsonValue } from '@kbn/utils';

export { JsonArray, JsonObject, JsonValue };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React, { useMemo, useCallback, useEffect } from 'react';
import { noop } from 'lodash';
import { JsonValue } from '@kbn/utils';
import { DataPublicPluginStart, esQuery, Filter } from '../../../../../../src/plugins/data/public';
import { euiStyled } from '../../../../../../src/plugins/kibana_react/common';
import { LogEntryCursor } from '../../../common/log_entry';
Expand All @@ -17,7 +18,6 @@ import { BuiltEsQuery, useLogStream } from '../../containers/logs/log_stream';

import { ScrollableLogTextStreamView } from '../logging/log_text_stream';
import { LogColumnRenderConfiguration } from '../../utils/log_column_render_configuration';
import { JsonValue } from '../../../../../../src/plugins/kibana_utils/common';
import { Query } from '../../../../../../src/plugins/data/common';
import { LogStreamErrorBoundary } from './log_stream_error_boundary';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import stringify from 'json-stable-stringify';
import React from 'react';
import { JsonArray, JsonValue } from '@kbn/utils';
import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common';
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 @@ -6,7 +6,7 @@
*/

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

import { ReactNode } from 'react';
import { JsonValue } from '../../../../../src/plugins/kibana_utils/common';
import { JsonValue } from '@kbn/utils';

/**
* Interface for common configuration properties, regardless of the column type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { GenericParams, SearchResponse } from 'elasticsearch';
import { Lifecycle } from '@hapi/hapi';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { JsonArray, JsonValue } from '@kbn/utils';
import { RouteConfig, RouteMethod } from '../../../../../../../src/core/server';
import {
PluginSetup as DataPluginSetup,
Expand All @@ -19,7 +20,6 @@ import { PluginSetupContract as FeaturesPluginSetup } from '../../../../../../pl
import { SpacesPluginSetup } from '../../../../../../plugins/spaces/server';
import { PluginSetupContract as AlertingPluginContract } from '../../../../../alerting/server';
import { MlPluginSetup } from '../../../../../ml/server';
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 { constant, identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
import * as runtimeTypes from 'io-ts';
import { compact } from 'lodash';
import { JsonArray } from '../../../../../../../src/plugins/kibana_utils/common';
import { JsonArray } from '@kbn/utils';
import type { InfraPluginRequestHandlerContext } from '../../../types';
import {
LogEntriesAdapter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import type { estypes } from '@elastic/elasticsearch';
import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';

import type { InfraPluginRequestHandlerContext } from '../../../types';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';
import {
InventoryItemType,
MetricsUIAggregation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { JsonArray, JsonValue } from '@kbn/utils';
import { LogMessagePart } from '../../../../common/log_entry';
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 @@ -5,7 +5,7 @@
* 2.0.
*/

import { JsonValue } from '../../../../../../../src/plugins/kibana_utils/common';
import { JsonValue } from '@kbn/utils';

export interface LogMessageFormattingRule {
when: LogMessageFormattingCondition;
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 @@ -5,7 +5,7 @@
* 2.0.
*/

import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';

export const parseFilterQuery = (
filterQuery: string | null | undefined
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/common/types/es_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import { estypes } from '@elastic/elasticsearch';

import { JsonObject } from '@kbn/utils';
import { buildEsQuery } from '../../../../../src/plugins/data/common/es_query/es_query';
import type { DslQuery } from '../../../../../src/plugins/data/common/es_query/kuery';
import type { JsonObject } from '../../../../../src/plugins/kibana_utils/common';

import { isPopulatedObject } from '../util/object_utils';

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/typed_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { DslQuery, Filter } from 'src/plugins/data/common';

import { JsonObject } from '../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';

export type ESQuery =
| ESRangeQuery
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/common/typed_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { DslQuery, Filter } from 'src/plugins/data/common';

import { JsonObject } from '../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';

export type ESQuery =
| ESRangeQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { isEmpty, isString, flow } from 'lodash/fp';

import { JsonObject } from '@kbn/utils';
import {
EsQueryConfig,
Query,
Expand All @@ -15,7 +16,6 @@ import {
esKuery,
IIndexPattern,
} from '../../../../../../../src/plugins/data/public';
import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public';

export const convertKueryToElasticSearchQuery = (
kueryExpression: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

import type { IScopedClusterClient } from 'kibana/server';
import { JsonObject } from '@kbn/utils';
import { parseFilterQuery } from '../../../../utils/serialized_query';
import { SafeResolverEvent } from '../../../../../common/endpoint/types';
import { PaginationBuilder } from '../utils/pagination';
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';

interface TimeRange {
from: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import type { ApiResponse, estypes } from '@elastic/elasticsearch';
import { IScopedClusterClient } from 'src/core/server';
import { JsonObject, JsonValue } from '@kbn/utils';
import { FieldsObject, ResolverSchema } from '../../../../../../common/endpoint/types';
import { JsonObject, JsonValue } from '../../../../../../../../../src/plugins/kibana_utils/common';
import { NodeID, TimeRange, docValueFields, validIDs } from '../utils/index';

interface DescendantsParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import { IScopedClusterClient } from 'src/core/server';
import { JsonObject, JsonValue } from '@kbn/utils';
import { FieldsObject, ResolverSchema } from '../../../../../../common/endpoint/types';
import { JsonObject, JsonValue } from '../../../../../../../../../src/plugins/kibana_utils/common';
import { NodeID, TimeRange, docValueFields, validIDs } from '../utils/index';

interface LifecycleParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { IScopedClusterClient } from 'src/core/server';
import { JsonObject } from '../../../../../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';
import { EventStats, ResolverSchema } from '../../../../../../common/endpoint/types';
import { NodeID, TimeRange } from '../utils/index';

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

import { JsonObject } from '@kbn/utils';
import { SafeResolverEvent } from '../../../../../common/endpoint/types';
import {
eventIDSafeVersion,
timestampSafeVersion,
} from '../../../../../common/endpoint/models/event';
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';

type SearchAfterFields = [number, string];

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 @@ -8,9 +8,9 @@
import { LoggerFactory } from 'kibana/server';

import { SearchResponse } from '@elastic/elasticsearch/api/types';
import { JsonObject } from '@kbn/utils';
import { ConfigType } from '../config';
import { EndpointAppContextService } from './endpoint_app_context_services';
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import { HostMetadata, MetadataQueryStrategyVersions } from '../../common/endpoint/types';
import { ExperimentalFeatures } from '../../common/experimental_features';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { isEmpty, isPlainObject, isString } from 'lodash/fp';

import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';

export const parseFilterQuery = (filterQuery: string): JsonObject => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TaskManagerConfig } from '../config';
import { of, Subject } from 'rxjs';
import { take, bufferCount } from 'rxjs/operators';
import { createMonitoringStatsStream, AggregatedStat } from './monitoring_stats_stream';
import { JsonValue } from 'src/plugins/kibana_utils/common';
import { JsonValue } from '@kbn/utils';

beforeEach(() => {
jest.resetAllMocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { merge, of, Observable } from 'rxjs';
import { map, scan } from 'rxjs/operators';
import { set } from '@elastic/safer-lodash-set';
import { Logger } from 'src/core/server';
import { JsonObject } from 'src/plugins/kibana_utils/common';
import { JsonObject } from '@kbn/utils';
import { TaskStore } from '../task_store';
import { TaskPollingLifecycle } from '../polling_lifecycle';
import {
Expand Down
Loading