diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js index 9078bfe784aab..f56386a2cbf43 100644 --- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js +++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js @@ -445,16 +445,10 @@ export const npStart = { aggs: { calculateAutoTimeExpression: sinon.fake(), createAggConfigs: (indexPattern, configStates = []) => { - return new AggConfigs( - indexPattern, - configStates, - { - typesRegistry: aggTypesRegistry.start(), - }, - { - fieldFormats: getFieldFormatsRegistry(mockCoreStart), - } - ); + return new AggConfigs(indexPattern, configStates, { + typesRegistry: aggTypesRegistry.start(), + fieldFormats: getFieldFormatsRegistry(mockCoreStart), + }); }, types: aggTypesRegistry.start(), }, diff --git a/src/plugins/data/public/search/aggs/agg_config.test.ts b/src/plugins/data/public/search/aggs/agg_config.test.ts index 9fdd7f2736676..2813e3b9c5373 100644 --- a/src/plugins/data/public/search/aggs/agg_config.test.ts +++ b/src/plugins/data/public/search/aggs/agg_config.test.ts @@ -20,7 +20,7 @@ import { identity } from 'lodash'; import { AggConfig, IAggConfig } from './agg_config'; -import { AggConfigs, CreateAggConfigParams, AggConfigsDependencies } from './agg_configs'; +import { AggConfigs, CreateAggConfigParams } from './agg_configs'; import { AggType } from './agg_type'; import { AggTypesRegistryStart } from './agg_types_registry'; import { mockDataServices, mockAggTypesRegistry } from './test_helpers'; @@ -31,9 +31,7 @@ import { fieldFormatsServiceMock } from '../../field_formats/mocks'; describe('AggConfig', () => { let indexPattern: IndexPattern; let typesRegistry: AggTypesRegistryStart; - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); beforeEach(() => { jest.restoreAllMocks(); @@ -44,7 +42,7 @@ describe('AggConfig', () => { describe('#toDsl', () => { it('calls #write()', () => { - const ac = new AggConfigs(indexPattern, [], { typesRegistry }, aggConfigsDependencies); + const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats }); const configStates = { enabled: true, type: 'date_histogram', @@ -59,7 +57,7 @@ describe('AggConfig', () => { }); it('uses the type name as the agg name', () => { - const ac = new AggConfigs(indexPattern, [], { typesRegistry }, aggConfigsDependencies); + const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats }); const configStates = { enabled: true, type: 'date_histogram', @@ -74,7 +72,7 @@ describe('AggConfig', () => { }); it('uses the params from #write() output as the agg params', () => { - const ac = new AggConfigs(indexPattern, [], { typesRegistry }, aggConfigsDependencies); + const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats }); const configStates = { enabled: true, type: 'date_histogram', @@ -104,12 +102,7 @@ describe('AggConfig', () => { params: {}, }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const histoConfig = ac.byName('date_histogram')[0]; const avgConfig = ac.byName('avg')[0]; @@ -219,18 +212,8 @@ describe('AggConfig', () => { testsIdentical.forEach((configState, index) => { it(`identical aggregations (${index})`, () => { - const ac1 = new AggConfigs( - indexPattern, - configState, - { typesRegistry }, - aggConfigsDependencies - ); - const ac2 = new AggConfigs( - indexPattern, - configState, - { typesRegistry }, - aggConfigsDependencies - ); + const ac1 = new AggConfigs(indexPattern, configState, { typesRegistry, fieldFormats }); + const ac2 = new AggConfigs(indexPattern, configState, { typesRegistry, fieldFormats }); expect(ac1.jsonDataEquals(ac2.aggs)).toBe(true); }); }); @@ -270,18 +253,8 @@ describe('AggConfig', () => { testsIdenticalDifferentOrder.forEach((test, index) => { it(`identical aggregations (${index}) - init json is in different order`, () => { - const ac1 = new AggConfigs( - indexPattern, - test.config1, - { typesRegistry }, - aggConfigsDependencies - ); - const ac2 = new AggConfigs( - indexPattern, - test.config2, - { typesRegistry }, - aggConfigsDependencies - ); + const ac1 = new AggConfigs(indexPattern, test.config1, { typesRegistry, fieldFormats }); + const ac2 = new AggConfigs(indexPattern, test.config2, { typesRegistry, fieldFormats }); expect(ac1.jsonDataEquals(ac2.aggs)).toBe(true); }); }); @@ -345,18 +318,8 @@ describe('AggConfig', () => { testsDifferent.forEach((test, index) => { it(`different aggregations (${index})`, () => { - const ac1 = new AggConfigs( - indexPattern, - test.config1, - { typesRegistry }, - aggConfigsDependencies - ); - const ac2 = new AggConfigs( - indexPattern, - test.config2, - { typesRegistry }, - aggConfigsDependencies - ); + const ac1 = new AggConfigs(indexPattern, test.config1, { typesRegistry, fieldFormats }); + const ac2 = new AggConfigs(indexPattern, test.config2, { typesRegistry, fieldFormats }); expect(ac1.jsonDataEquals(ac2.aggs)).toBe(false); }); }); @@ -364,7 +327,7 @@ describe('AggConfig', () => { describe('#toJSON', () => { it('includes the aggs id, params, type and schema', () => { - const ac = new AggConfigs(indexPattern, [], { typesRegistry }, aggConfigsDependencies); + const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats }); const configStates = { enabled: true, type: 'date_histogram', @@ -395,18 +358,8 @@ describe('AggConfig', () => { params: {}, }, ]; - const ac1 = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); - const ac2 = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac1 = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); + const ac2 = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); // this relies on the assumption that js-engines consistently loop over properties in insertion order. // most likely the case, but strictly speaking not guaranteed by the JS and JSON specifications. @@ -418,7 +371,7 @@ describe('AggConfig', () => { let aggConfig: AggConfig; beforeEach(() => { - const ac = new AggConfigs(indexPattern, [], { typesRegistry }, aggConfigsDependencies); + const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats }); aggConfig = ac.createAggConfig({ type: 'count' } as CreateAggConfigParams); }); @@ -447,7 +400,7 @@ describe('AggConfig', () => { describe('#fieldFormatter - custom getFormat handler', () => { it('returns formatter from getFormat handler', () => { - const ac = new AggConfigs(indexPattern, [], { typesRegistry }, aggConfigsDependencies); + const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats }); const configStates = { enabled: true, type: 'count', @@ -488,12 +441,7 @@ describe('AggConfig', () => { }, }, }; - const ac = new AggConfigs( - indexPattern, - [configStates], - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, [configStates], { typesRegistry, fieldFormats }); aggConfig = ac.createAggConfig(configStates); }); diff --git a/src/plugins/data/public/search/aggs/agg_configs.test.ts b/src/plugins/data/public/search/aggs/agg_configs.test.ts index 72e8ee4af4778..653bf6a266df6 100644 --- a/src/plugins/data/public/search/aggs/agg_configs.test.ts +++ b/src/plugins/data/public/search/aggs/agg_configs.test.ts @@ -19,7 +19,7 @@ import { indexBy } from 'lodash'; import { AggConfig } from './agg_config'; -import { AggConfigs, AggConfigsDependencies } from './agg_configs'; +import { AggConfigs } from './agg_configs'; import { AggTypesRegistryStart } from './agg_types_registry'; import { mockDataServices, mockAggTypesRegistry } from './test_helpers'; import { Field as IndexPatternField, IndexPattern } from '../../index_patterns'; @@ -29,9 +29,7 @@ import { fieldFormatsServiceMock } from '../../field_formats/mocks'; describe('AggConfigs', () => { let indexPattern: IndexPattern; let typesRegistry: AggTypesRegistryStart; - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); beforeEach(() => { mockDataServices(); @@ -49,12 +47,7 @@ describe('AggConfigs', () => { }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); expect(ac.aggs).toHaveLength(1); }); @@ -79,7 +72,7 @@ describe('AggConfigs', () => { ]; const spy = jest.spyOn(AggConfig, 'ensureIds'); - new AggConfigs(indexPattern, configStates, { typesRegistry }, aggConfigsDependencies); + new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); expect(spy).toHaveBeenCalledTimes(1); expect(spy.mock.calls[0]).toEqual([configStates]); spy.mockRestore(); @@ -101,12 +94,7 @@ describe('AggConfigs', () => { }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); expect(ac.aggs).toHaveLength(2); ac.createAggConfig( @@ -118,7 +106,7 @@ describe('AggConfigs', () => { params: {}, schema: 'split', }, - aggConfigsDependencies + { fieldFormats } ) ); expect(ac.aggs).toHaveLength(3); @@ -133,12 +121,7 @@ describe('AggConfigs', () => { }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); expect(ac.aggs).toHaveLength(1); ac.createAggConfig({ @@ -159,12 +142,7 @@ describe('AggConfigs', () => { }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); expect(ac.aggs).toHaveLength(1); ac.createAggConfig( @@ -192,12 +170,7 @@ describe('AggConfigs', () => { { type: 'percentiles', enabled: true, params: {}, schema: 'metric' }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const sorted = ac.getRequestAggs(); const aggs = indexBy(ac.aggs, agg => agg.type.name); @@ -220,12 +193,7 @@ describe('AggConfigs', () => { { type: 'count', enabled: true, params: {}, schema: 'metric' }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const sorted = ac.getResponseAggs(); const aggs = indexBy(ac.aggs, agg => agg.type.name); @@ -242,12 +210,7 @@ describe('AggConfigs', () => { { type: 'percentiles', enabled: true, params: { percents: [1, 2, 3] }, schema: 'metric' }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const sorted = ac.getResponseAggs(); const aggs = indexBy(ac.aggs, agg => agg.type.name); @@ -268,12 +231,7 @@ describe('AggConfigs', () => { it('uses the sorted aggs', () => { const configStates = [{ enabled: true, type: 'avg', params: { field: 'bytes' } }]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const spy = jest.spyOn(AggConfigs.prototype, 'getRequestAggs'); ac.toDsl(); expect(spy).toHaveBeenCalledTimes(1); @@ -287,14 +245,10 @@ describe('AggConfigs', () => { { enabled: true, type: 'count', params: {} }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { - typesRegistry, - }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { + typesRegistry, + fieldFormats, + }); const aggInfos = ac.aggs.map(aggConfig => { const football = {}; @@ -337,12 +291,7 @@ describe('AggConfigs', () => { }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const dsl = ac.toDsl(); const histo = ac.byName('date_histogram')[0]; const count = ac.byName('count')[0]; @@ -367,14 +316,10 @@ describe('AggConfigs', () => { { enabled: true, type: 'max', schema: 'metric', params: { field: 'bytes' } }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { - typesRegistry, - }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { + typesRegistry, + fieldFormats, + }); const dsl = ac.toDsl(); const histo = ac.byName('date_histogram')[0]; const metrics = ac.bySchemaName('metrics'); @@ -399,12 +344,7 @@ describe('AggConfigs', () => { { enabled: true, type: 'max', schema: 'metric', params: { field: 'bytes' } }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const topLevelDsl = ac.toDsl(true); const buckets = ac.bySchemaName('buckets'); const metrics = ac.bySchemaName('metrics'); @@ -474,12 +414,7 @@ describe('AggConfigs', () => { }, ]; - const ac = new AggConfigs( - indexPattern, - configStates, - { typesRegistry }, - aggConfigsDependencies - ); + const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats }); const topLevelDsl = ac.toDsl(true)['2']; expect(Object.keys(topLevelDsl.aggs)).toContain('1'); diff --git a/src/plugins/data/public/search/aggs/agg_configs.ts b/src/plugins/data/public/search/aggs/agg_configs.ts index 7c6cacd3bb7e9..16af9d850b98f 100644 --- a/src/plugins/data/public/search/aggs/agg_configs.ts +++ b/src/plugins/data/public/search/aggs/agg_configs.ts @@ -48,9 +48,6 @@ function parseParentAggs(dslLvlCursor: any, dsl: any) { export interface AggConfigsOptions { typesRegistry: AggTypesRegistryStart; -} - -export interface AggConfigsDependencies { fieldFormats: FieldFormatsStart; } @@ -81,8 +78,7 @@ export class AggConfigs { constructor( indexPattern: IndexPattern, configStates: CreateAggConfigParams[] = [], - opts: AggConfigsOptions, - { fieldFormats }: AggConfigsDependencies + opts: AggConfigsOptions ) { this.typesRegistry = opts.typesRegistry; @@ -90,7 +86,7 @@ export class AggConfigs { this.aggs = []; this.indexPattern = indexPattern; - this.fieldFormats = fieldFormats; + this.fieldFormats = opts.fieldFormats; configStates.forEach((params: any) => this.createAggConfig(params)); } @@ -119,16 +115,10 @@ export class AggConfigs { return agg.enabled; }; - const aggConfigs = new AggConfigs( - this.indexPattern, - this.aggs.filter(filterAggs), - { - typesRegistry: this.typesRegistry, - }, - { - fieldFormats: this.fieldFormats, - } - ); + const aggConfigs = new AggConfigs(this.indexPattern, this.aggs.filter(filterAggs), { + typesRegistry: this.typesRegistry, + fieldFormats: this.fieldFormats, + }); return aggConfigs; } diff --git a/src/plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.test.ts b/src/plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.test.ts index 59922bfd91ed3..44d99375bbd30 100644 --- a/src/plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.test.ts @@ -22,7 +22,7 @@ import { mergeOtherBucketAggResponse, updateMissingBucket, } from './_terms_other_bucket_helper'; -import { AggConfigs, CreateAggConfigParams, AggConfigsDependencies } from '../agg_configs'; +import { AggConfigs, CreateAggConfigParams } from '../agg_configs'; import { BUCKET_TYPES } from './bucket_agg_types'; import { IBucketAggConfig } from './bucket_agg_type'; import { mockAggTypesRegistry } from '../test_helpers'; @@ -220,11 +220,10 @@ const nestedOtherResponse = { describe('Terms Agg Other bucket helper', () => { const typesRegistry = mockAggTypesRegistry(); - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); + const getAggConfigs = (aggs: CreateAggConfigParams[] = []) => { - return new AggConfigs(indexPattern, [...aggs], { typesRegistry }, aggConfigsDependencies); + return new AggConfigs(indexPattern, [...aggs], { typesRegistry, fieldFormats }); }; describe('buildOtherBucketAgg', () => { diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts index 85016795d8f4f..7778fcb36bcd6 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts @@ -78,8 +78,10 @@ describe('AggConfig Filters', () => { params: { field: field.name, interval, customInterval: '5d' }, }, ], - { typesRegistry: mockAggTypesRegistry([getDateHistogramBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getDateHistogramBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); const bucketKey = 1422579600000; diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts index e187340fecea6..4207fa92736f8 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts @@ -72,8 +72,10 @@ describe('AggConfig Filters', () => { }, }, ], - { typesRegistry: mockAggTypesRegistry([getDateRangeBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getDateRangeBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/filters.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/filters.test.ts index 26bf71651d000..bf05f7463db6c 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/filters.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/filters.test.ts @@ -69,8 +69,10 @@ describe('AggConfig Filters', () => { }, }, ], - { typesRegistry: mockAggTypesRegistry([getFiltersBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getFiltersBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts index 845412035e28c..396d515f3b580 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts @@ -18,7 +18,7 @@ */ import { createFilterHistogram } from './histogram'; -import { AggConfigs, AggConfigsDependencies } from '../../agg_configs'; +import { AggConfigs } from '../../agg_configs'; import { mockAggTypesRegistry } from '../../test_helpers'; import { BUCKET_TYPES } from '../bucket_agg_types'; import { IBucketAggConfig } from '../bucket_agg_type'; @@ -28,9 +28,7 @@ import { fieldFormatsServiceMock } from '../../../../field_formats/mocks'; describe('AggConfig Filters', () => { describe('histogram', () => { const getConfig = (() => {}) as FieldFormatsGetConfigFn; - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const getAggConfigs = () => { const field = { name: 'bytes', @@ -59,8 +57,7 @@ describe('AggConfig Filters', () => { }, }, ], - { typesRegistry: mockAggTypesRegistry() }, - aggConfigsDependencies + { typesRegistry: mockAggTypesRegistry(), fieldFormats } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts index 0466536c057b1..d85576a0ccb14 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts @@ -19,7 +19,7 @@ import { getIpRangeBucketAgg } from '../ip_range'; import { createFilterIpRange } from './ip_range'; -import { AggConfigs, CreateAggConfigParams, AggConfigsDependencies } from '../../agg_configs'; +import { AggConfigs, CreateAggConfigParams } from '../../agg_configs'; import { mockAggTypesRegistry } from '../../test_helpers'; import { IpFormat } from '../../../../../common'; import { BUCKET_TYPES } from '../bucket_agg_types'; @@ -29,13 +29,11 @@ import { notificationServiceMock } from '../../../../../../../core/public/mocks' describe('AggConfig Filters', () => { describe('IP range', () => { - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const typesRegistry = mockAggTypesRegistry([ getIpRangeBucketAgg({ getInternalStartServices: () => ({ - fieldFormats: aggConfigsDependencies.fieldFormats, + fieldFormats, notifications: notificationServiceMock.createStartContract(), }), }), @@ -55,7 +53,7 @@ describe('AggConfig Filters', () => { }, } as any; - return new AggConfigs(indexPattern, aggs, { typesRegistry }, aggConfigsDependencies); + return new AggConfigs(indexPattern, aggs, { typesRegistry, fieldFormats }); }; test('should return a range filter for ip_range agg', () => { diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/range.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/range.test.ts index 7605ff7d98d32..cadd8e9fe13ed 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/range.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/range.test.ts @@ -71,8 +71,10 @@ describe('AggConfig Filters', () => { }, }, ], - { typesRegistry: mockAggTypesRegistry([getRangeBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getRangeBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts b/src/plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts index 7871c5d339084..d9ff63613b640 100644 --- a/src/plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts @@ -56,14 +56,10 @@ describe('AggConfig Filters', () => { indexPattern, }; - return new AggConfigs( - indexPattern, - aggs, - { - typesRegistry: mockAggTypesRegistry([getTermsBucketAgg(aggTypesDependencies)]), - }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } - ); + return new AggConfigs(indexPattern, aggs, { + typesRegistry: mockAggTypesRegistry([getTermsBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + }); }; test('should return a match_phrase filter for terms', () => { diff --git a/src/plugins/data/public/search/aggs/buckets/date_range.test.ts b/src/plugins/data/public/search/aggs/buckets/date_range.test.ts index 3ec48189d0795..f78f0cce732e7 100644 --- a/src/plugins/data/public/search/aggs/buckets/date_range.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/date_range.test.ts @@ -74,8 +74,10 @@ describe('date_range params', () => { params, }, ], - { typesRegistry: mockAggTypesRegistry([getDateRangeBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getDateRangeBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/geo_hash.test.ts b/src/plugins/data/public/search/aggs/buckets/geo_hash.test.ts index 226fdcc1fb85b..226faefe43482 100644 --- a/src/plugins/data/public/search/aggs/buckets/geo_hash.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/geo_hash.test.ts @@ -77,8 +77,10 @@ describe('Geohash Agg', () => { }, }, ], - { typesRegistry: mockAggTypesRegistry() }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry(), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/histogram.test.ts b/src/plugins/data/public/search/aggs/buckets/histogram.test.ts index 7a84293499ae4..a55c32951232a 100644 --- a/src/plugins/data/public/search/aggs/buckets/histogram.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/histogram.test.ts @@ -70,8 +70,10 @@ describe('Histogram Agg', () => { params, }, ], - { typesRegistry: mockAggTypesRegistry([getHistogramBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getHistogramBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/range.test.ts b/src/plugins/data/public/search/aggs/buckets/range.test.ts index 70adb75328971..144d2b779e950 100644 --- a/src/plugins/data/public/search/aggs/buckets/range.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/range.test.ts @@ -95,8 +95,10 @@ describe('Range Agg', () => { }, }, ], - { typesRegistry: mockAggTypesRegistry([getRangeBucketAgg(aggTypesDependencies)]) }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry: mockAggTypesRegistry([getRangeBucketAgg(aggTypesDependencies)]), + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/significant_terms.test.ts b/src/plugins/data/public/search/aggs/buckets/significant_terms.test.ts index 64e3f1bfb1814..d0ace5a50c28d 100644 --- a/src/plugins/data/public/search/aggs/buckets/significant_terms.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/significant_terms.test.ts @@ -70,8 +70,8 @@ describe('Significant Terms Agg', () => { typesRegistry: mockAggTypesRegistry([ getSignificantTermsBucketAgg(aggTypesDependencies), ]), - }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }; diff --git a/src/plugins/data/public/search/aggs/buckets/terms.test.ts b/src/plugins/data/public/search/aggs/buckets/terms.test.ts index 5eaae663f80a2..0dc052bd1fdf6 100644 --- a/src/plugins/data/public/search/aggs/buckets/terms.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/terms.test.ts @@ -17,16 +17,14 @@ * under the License. */ -import { AggConfigs, AggConfigsDependencies } from '../agg_configs'; +import { AggConfigs } from '../agg_configs'; import { mockAggTypesRegistry } from '../test_helpers'; import { BUCKET_TYPES } from './bucket_agg_types'; import { fieldFormatsServiceMock } from '../../../field_formats/mocks'; describe('Terms Agg', () => { describe('order agg editor UI', () => { - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const getAggConfigs = (params: Record = {}) => { const indexPattern = { id: '1234', @@ -51,8 +49,7 @@ describe('Terms Agg', () => { type: BUCKET_TYPES.TERMS, }, ], - { typesRegistry: mockAggTypesRegistry() }, - aggConfigsDependencies + { typesRegistry: mockAggTypesRegistry(), fieldFormats } ); }; diff --git a/src/plugins/data/public/search/aggs/metrics/median.test.ts b/src/plugins/data/public/search/aggs/metrics/median.test.ts index c5787b9d4b833..de3ca646ead9e 100644 --- a/src/plugins/data/public/search/aggs/metrics/median.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/median.test.ts @@ -59,8 +59,10 @@ describe('AggTypeMetricMedianProvider class', () => { }, }, ], - { typesRegistry }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { + typesRegistry, + fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats, + } ); }); diff --git a/src/plugins/data/public/search/aggs/metrics/parent_pipeline.test.ts b/src/plugins/data/public/search/aggs/metrics/parent_pipeline.test.ts index 46005535610b2..3beb92a2fa000 100644 --- a/src/plugins/data/public/search/aggs/metrics/parent_pipeline.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/parent_pipeline.test.ts @@ -110,8 +110,7 @@ describe('parent pipeline aggs', function() { schema: 'metric', }, ], - { typesRegistry }, - { fieldFormats: getInternalStartServices().fieldFormats } + { typesRegistry, fieldFormats: getInternalStartServices().fieldFormats } ); // Grab the aggConfig off the vis (we don't actually use the vis for anything else) diff --git a/src/plugins/data/public/search/aggs/metrics/percentile_ranks.test.ts b/src/plugins/data/public/search/aggs/metrics/percentile_ranks.test.ts index dd292dbc2781e..1b94ecd602075 100644 --- a/src/plugins/data/public/search/aggs/metrics/percentile_ranks.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/percentile_ranks.test.ts @@ -70,8 +70,7 @@ describe('AggTypesMetricsPercentileRanksProvider class', function() { }, }, ], - { typesRegistry }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { typesRegistry, fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } ); }); diff --git a/src/plugins/data/public/search/aggs/metrics/percentiles.test.ts b/src/plugins/data/public/search/aggs/metrics/percentiles.test.ts index 7a132b5c21fd2..76da2fe3eb62c 100644 --- a/src/plugins/data/public/search/aggs/metrics/percentiles.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/percentiles.test.ts @@ -70,8 +70,7 @@ describe('AggTypesMetricsPercentilesProvider class', () => { }, }, ], - { typesRegistry }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { typesRegistry, fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } ); }); diff --git a/src/plugins/data/public/search/aggs/metrics/sibling_pipeline.test.ts b/src/plugins/data/public/search/aggs/metrics/sibling_pipeline.test.ts index 282a2cc4a1527..a47aa2c677ade 100644 --- a/src/plugins/data/public/search/aggs/metrics/sibling_pipeline.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/sibling_pipeline.test.ts @@ -111,8 +111,7 @@ describe('sibling pipeline aggs', () => { }, }, ], - { typesRegistry }, - { fieldFormats: getInternalStartServices().fieldFormats } + { typesRegistry, fieldFormats: getInternalStartServices().fieldFormats } ); // Grab the aggConfig off the vis (we don't actually use the vis for anything else) diff --git a/src/plugins/data/public/search/aggs/metrics/std_deviation.test.ts b/src/plugins/data/public/search/aggs/metrics/std_deviation.test.ts index c19965d40e83d..d2370e1fed02c 100644 --- a/src/plugins/data/public/search/aggs/metrics/std_deviation.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/std_deviation.test.ts @@ -64,8 +64,7 @@ describe('AggTypeMetricStandardDeviationProvider class', () => { }, }, ], - { typesRegistry }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { typesRegistry, fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } ); }; diff --git a/src/plugins/data/public/search/aggs/metrics/top_hit.test.ts b/src/plugins/data/public/search/aggs/metrics/top_hit.test.ts index f685c45d5001a..142b8e4c83301 100644 --- a/src/plugins/data/public/search/aggs/metrics/top_hit.test.ts +++ b/src/plugins/data/public/search/aggs/metrics/top_hit.test.ts @@ -89,8 +89,7 @@ describe('Top hit metric', () => { params, }, ], - { typesRegistry }, - { fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } + { typesRegistry, fieldFormats: aggTypesDependencies.getInternalStartServices().fieldFormats } ); // Grab the aggConfig off the vis (we don't actually use the vis for anything else) diff --git a/src/plugins/data/public/search/aggs/mocks.ts b/src/plugins/data/public/search/aggs/mocks.ts index c78a486855dad..16544fd8f46b0 100644 --- a/src/plugins/data/public/search/aggs/mocks.ts +++ b/src/plugins/data/public/search/aggs/mocks.ts @@ -71,16 +71,10 @@ export const searchAggsSetupMock = (): SearchAggsSetup => ({ export const searchAggsStartMock = (): SearchAggsStart => ({ calculateAutoTimeExpression: getCalculateAutoTimeExpression(coreMock.createStart().uiSettings), createAggConfigs: jest.fn().mockImplementation((indexPattern, configStates = [], schemas) => { - return new AggConfigs( - indexPattern, - configStates, - { - typesRegistry: mockAggTypesRegistry(), - }, - { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - } - ); + return new AggConfigs(indexPattern, configStates, { + typesRegistry: mockAggTypesRegistry(), + fieldFormats: fieldFormatsServiceMock.createStartContract(), + }); }), types: mockAggTypesRegistry(), }); diff --git a/src/plugins/data/public/search/expressions/create_filter.test.ts b/src/plugins/data/public/search/expressions/create_filter.test.ts index 37a045b3fa60b..51b5e175761bd 100644 --- a/src/plugins/data/public/search/expressions/create_filter.test.ts +++ b/src/plugins/data/public/search/expressions/create_filter.test.ts @@ -18,7 +18,7 @@ */ import { createFilter } from './create_filter'; -import { AggConfigs, IAggConfig, AggConfigsDependencies } from '../aggs'; +import { AggConfigs, IAggConfig } from '../aggs'; import { TabbedTable } from '../tabify'; import { isRangeFilter, BytesFormat, FieldFormatsGetConfigFn } from '../../../common'; import { mockDataServices, mockAggTypesRegistry } from '../aggs/test_helpers'; @@ -27,9 +27,7 @@ import { fieldFormatsServiceMock } from '../../field_formats/mocks'; describe('createFilter', () => { let table: TabbedTable; let aggConfig: IAggConfig; - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const typesRegistry = mockAggTypesRegistry(); @@ -62,8 +60,7 @@ describe('createFilter', () => { params, }, ], - { typesRegistry }, - aggConfigsDependencies + { typesRegistry, fieldFormats } ); }; diff --git a/src/plugins/data/public/search/search_service.ts b/src/plugins/data/public/search/search_service.ts index 716f557f84de3..a539736991adb 100644 --- a/src/plugins/data/public/search/search_service.ts +++ b/src/plugins/data/public/search/search_service.ts @@ -139,14 +139,10 @@ export class SearchService implements Plugin { aggs: { calculateAutoTimeExpression: getCalculateAutoTimeExpression(core.uiSettings), createAggConfigs: (indexPattern, configStates = [], schemas) => { - return new AggConfigs( - indexPattern, - configStates, - { - typesRegistry: aggTypesStart, - }, - { fieldFormats } - ); + return new AggConfigs(indexPattern, configStates, { + typesRegistry: aggTypesStart, + fieldFormats, + }); }, types: aggTypesStart, }, diff --git a/src/plugins/data/public/search/tabify/get_columns.test.ts b/src/plugins/data/public/search/tabify/get_columns.test.ts index c30f3183511d3..1072e9318b40e 100644 --- a/src/plugins/data/public/search/tabify/get_columns.test.ts +++ b/src/plugins/data/public/search/tabify/get_columns.test.ts @@ -19,7 +19,7 @@ import { tabifyGetColumns } from './get_columns'; import { TabbedAggColumn } from './types'; -import { AggConfigs, AggConfigsDependencies } from '../aggs'; +import { AggConfigs } from '../aggs'; import { mockAggTypesRegistry, mockDataServices } from '../aggs/test_helpers'; import { fieldFormatsServiceMock } from '../../field_formats/mocks'; @@ -29,9 +29,7 @@ describe('get columns', () => { }); const typesRegistry = mockAggTypesRegistry(); - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const createAggConfigs = (aggs: any[] = []) => { const field = { @@ -47,14 +45,10 @@ describe('get columns', () => { }, } as any; - return new AggConfigs( - indexPattern, - aggs, - { - typesRegistry, - }, - aggConfigsDependencies - ); + return new AggConfigs(indexPattern, aggs, { + typesRegistry, + fieldFormats, + }); }; test('should inject the metric after each bucket if the vis is hierarchical', () => { diff --git a/src/plugins/data/public/search/tabify/response_writer.test.ts b/src/plugins/data/public/search/tabify/response_writer.test.ts index 1766f4ab72de5..3334d858ce54e 100644 --- a/src/plugins/data/public/search/tabify/response_writer.test.ts +++ b/src/plugins/data/public/search/tabify/response_writer.test.ts @@ -18,7 +18,7 @@ */ import { TabbedAggResponseWriter } from './response_writer'; -import { AggConfigs, BUCKET_TYPES, AggConfigsDependencies } from '../aggs'; +import { AggConfigs, BUCKET_TYPES } from '../aggs'; import { mockDataServices, mockAggTypesRegistry } from '../aggs/test_helpers'; import { TabbedResponseWriterOptions } from './types'; import { fieldFormatsServiceMock } from '../../field_formats/mocks'; @@ -31,9 +31,7 @@ describe('TabbedAggResponseWriter class', () => { let responseWriter: TabbedAggResponseWriter; const typesRegistry = mockAggTypesRegistry(); - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const splitAggConfig = [ { @@ -76,14 +74,10 @@ describe('TabbedAggResponseWriter class', () => { } as any; return new TabbedAggResponseWriter( - new AggConfigs( - indexPattern, - aggs, - { - typesRegistry, - }, - aggConfigsDependencies - ), + new AggConfigs(indexPattern, aggs, { + typesRegistry, + fieldFormats, + }), { metricsAtAllLevels: false, partialRows: false, diff --git a/src/plugins/data/public/search/tabify/tabify.test.ts b/src/plugins/data/public/search/tabify/tabify.test.ts index 7c9002bd5aa67..63685cc87f5cf 100644 --- a/src/plugins/data/public/search/tabify/tabify.test.ts +++ b/src/plugins/data/public/search/tabify/tabify.test.ts @@ -19,16 +19,14 @@ import { tabifyAggResponse } from './tabify'; import { IndexPattern } from '../../index_patterns'; -import { AggConfigs, IAggConfig, IAggConfigs, AggConfigsDependencies } from '../aggs'; +import { AggConfigs, IAggConfig, IAggConfigs } from '../aggs'; import { mockAggTypesRegistry } from '../aggs/test_helpers'; import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data'; import { fieldFormatsServiceMock } from '../../field_formats/mocks'; describe('tabifyAggResponse Integration', () => { const typesRegistry = mockAggTypesRegistry(); - const aggConfigsDependencies: AggConfigsDependencies = { - fieldFormats: fieldFormatsServiceMock.createStartContract(), - }; + const fieldFormats = fieldFormatsServiceMock.createStartContract(); const createAggConfigs = (aggs: IAggConfig[] = []) => { const field = { @@ -44,14 +42,10 @@ describe('tabifyAggResponse Integration', () => { }, } as unknown) as IndexPattern; - return new AggConfigs( - indexPattern, - aggs, - { - typesRegistry, - }, - aggConfigsDependencies - ); + return new AggConfigs(indexPattern, aggs, { + typesRegistry, + fieldFormats, + }); }; const mockAggConfig = (agg: any): IAggConfig => (agg as unknown) as IAggConfig;