diff --git a/src/plugins/data/common/search/aggs/buckets/filters.ts b/src/plugins/data/common/search/aggs/buckets/filters.ts index 4861c7248ebff..2ce6abbef543e 100644 --- a/src/plugins/data/common/search/aggs/buckets/filters.ts +++ b/src/plugins/data/common/search/aggs/buckets/filters.ts @@ -12,7 +12,6 @@ import { buildEsQuery, Query } from '@kbn/es-query'; import { QueryFilter, queryFilterToAst } from '../../expressions'; import { createFilterFilters } from './create_filter/filters'; -import { toAngularJSON } from '../utils'; import { BucketAggType } from './bucket_agg_type'; import { BUCKET_TYPES } from './bucket_agg_types'; import { aggFiltersFnName } from './filters_fn'; @@ -83,7 +82,7 @@ export const getFiltersBucketAgg = ({ getConfig }: FiltersBucketAggDependencies) matchAllLabel || (typeof filter.input.query === 'string' ? filter.input.query - : toAngularJSON(filter.input.query)); + : JSON.stringify(filter.input.query)); filters[label] = query; }, {} diff --git a/src/plugins/data/common/search/aggs/utils/index.ts b/src/plugins/data/common/search/aggs/utils/index.ts index 2edce79ca690b..d12c0ebb1cbbd 100644 --- a/src/plugins/data/common/search/aggs/utils/index.ts +++ b/src/plugins/data/common/search/aggs/utils/index.ts @@ -13,6 +13,5 @@ export * from './date_interval_utils'; export * from './get_aggs_formats'; export * from './ip_address'; export * from './prop_filter'; -export * from './to_angular_json'; export * from './infer_time_zone'; export * from './parse_time_shift'; diff --git a/src/plugins/data/common/search/aggs/utils/to_angular_json.ts b/src/plugins/data/common/search/aggs/utils/to_angular_json.ts deleted file mode 100644 index cf4050072b829..0000000000000 --- a/src/plugins/data/common/search/aggs/utils/to_angular_json.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -/** - * An inlined version of angular.toJSON(). Source: - * https://github.com/angular/angular.js/blob/master/src/Angular.js#L1312 - * - * @internal - */ -export function toAngularJSON(obj: any, pretty?: any): string { - if (obj === undefined) return ''; - if (typeof pretty === 'number') { - pretty = pretty ? 2 : null; - } - return JSON.stringify(obj, toJsonReplacer, pretty); -} - -function isWindow(obj: any) { - return obj && obj.window === obj; -} - -function isScope(obj: any) { - return obj && obj.$evalAsync && obj.$watch; -} - -function toJsonReplacer(key: any, value: any) { - let val = value; - - if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') { - val = undefined; - } else if (isWindow(value)) { - val = '$WINDOW'; - } else if (value && window.document === value) { - val = '$DOCUMENT'; - } else if (isScope(value)) { - val = '$SCOPE'; - } - - return val; -}