[TSVB] Remove vis_type_timeseries_enhanced plugin (#89274)
* [TSVB] get rid of vis_type_timeseries_enhanced * add search strategy should be called from setup hook * remove vis_type_timeseries_enhanced from CODEOWNERS Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d7028e1a5f
commit
9c410b81ca
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -9,7 +9,6 @@
|
||||||
/x-pack/plugins/discover_enhanced/ @elastic/kibana-app
|
/x-pack/plugins/discover_enhanced/ @elastic/kibana-app
|
||||||
/x-pack/plugins/lens/ @elastic/kibana-app
|
/x-pack/plugins/lens/ @elastic/kibana-app
|
||||||
/x-pack/plugins/graph/ @elastic/kibana-app
|
/x-pack/plugins/graph/ @elastic/kibana-app
|
||||||
/x-pack/plugins/vis_type_timeseries_enhanced/ @elastic/kibana-app
|
|
||||||
/src/plugins/advanced_settings/ @elastic/kibana-app
|
/src/plugins/advanced_settings/ @elastic/kibana-app
|
||||||
/src/plugins/charts/ @elastic/kibana-app
|
/src/plugins/charts/ @elastic/kibana-app
|
||||||
/src/plugins/discover/ @elastic/kibana-app
|
/src/plugins/discover/ @elastic/kibana-app
|
||||||
|
|
|
@ -559,10 +559,6 @@ in their infrastructure.
|
||||||
|NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to ui_actions_enhanced plugin.
|
|NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to ui_actions_enhanced plugin.
|
||||||
|
|
||||||
|
|
||||||
|{kib-repo}blob/{branch}/x-pack/plugins/vis_type_timeseries_enhanced/README.md[visTypeTimeseriesEnhanced]
|
|
||||||
|The vis_type_timeseries_enhanced plugin is the x-pack counterpart to the OSS vis_type_timeseries plugin.
|
|
||||||
|
|
||||||
|
|
||||||
|{kib-repo}blob/{branch}/x-pack/plugins/watcher/README.md[watcher]
|
|{kib-repo}blob/{branch}/x-pack/plugins/watcher/README.md[watcher]
|
||||||
|This plugins adopts some conventions in addition to or in place of conventions in Kibana (at the time of the plugin's creation):
|
|This plugins adopts some conventions in addition to or in place of conventions in Kibana (at the time of the plugin's creation):
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,6 @@ export const config: PluginConfigDescriptor<VisTypeTimeseriesConfig> = {
|
||||||
schema: configSchema,
|
schema: configSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
|
||||||
AbstractSearchStrategy,
|
|
||||||
ReqFacade,
|
|
||||||
} from './lib/search_strategies/strategies/abstract_search_strategy';
|
|
||||||
|
|
||||||
export { VisPayload } from '../common/types';
|
|
||||||
|
|
||||||
export { DefaultSearchCapabilities } from './lib/search_strategies/default_search_capabilities';
|
|
||||||
|
|
||||||
export function plugin(initializerContext: PluginInitializerContext) {
|
export function plugin(initializerContext: PluginInitializerContext) {
|
||||||
return new VisTypeTimeseriesPlugin(initializerContext);
|
return new VisTypeTimeseriesPlugin(initializerContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DefaultSearchCapabilities } from './default_search_capabilities';
|
import { DefaultSearchCapabilities } from './default_search_capabilities';
|
||||||
import { ReqFacade } from './strategies/abstract_search_strategy';
|
import type { ReqFacade } from '../strategies/abstract_search_strategy';
|
||||||
import { VisPayload } from '../../../common/types';
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
describe('DefaultSearchCapabilities', () => {
|
describe('DefaultSearchCapabilities', () => {
|
||||||
let defaultSearchCapabilities: DefaultSearchCapabilities;
|
let defaultSearchCapabilities: DefaultSearchCapabilities;
|
|
@ -11,10 +11,10 @@ import {
|
||||||
convertIntervalToUnit,
|
convertIntervalToUnit,
|
||||||
parseInterval,
|
parseInterval,
|
||||||
getSuitableUnit,
|
getSuitableUnit,
|
||||||
} from '../vis_data/helpers/unit_to_seconds';
|
} from '../../vis_data/helpers/unit_to_seconds';
|
||||||
import { RESTRICTIONS_KEYS } from '../../../common/ui_restrictions';
|
import { RESTRICTIONS_KEYS } from '../../../../common/ui_restrictions';
|
||||||
import { ReqFacade } from './strategies/abstract_search_strategy';
|
import type { ReqFacade } from '../strategies/abstract_search_strategy';
|
||||||
import { VisPayload } from '../../../common/types';
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
const getTimezoneFromRequest = (request: ReqFacade<VisPayload>) => {
|
const getTimezoneFromRequest = (request: ReqFacade<VisPayload>) => {
|
||||||
return request.payload.timerange.timezone;
|
return request.payload.timerange.timezone;
|
|
@ -1,12 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Unit } from '@elastic/datemath';
|
import { Unit } from '@elastic/datemath';
|
||||||
import { RollupSearchCapabilities } from './rollup_search_capabilities';
|
import { RollupSearchCapabilities } from './rollup_search_capabilities';
|
||||||
|
|
||||||
import { ReqFacade, VisPayload } from '../../../../../src/plugins/vis_type_timeseries/server';
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
import type { ReqFacade } from '../strategies/abstract_search_strategy';
|
||||||
|
|
||||||
describe('Rollup Search Capabilities', () => {
|
describe('Rollup Search Capabilities', () => {
|
||||||
const testTimeZone = 'time_zone';
|
const testTimeZone = 'time_zone';
|
|
@ -1,16 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
import { get, has } from 'lodash';
|
|
||||||
import { leastCommonInterval, isCalendarInterval } from './lib/interval_helper';
|
|
||||||
|
|
||||||
import {
|
import { get, has } from 'lodash';
|
||||||
ReqFacade,
|
import { leastCommonInterval, isCalendarInterval } from '../lib/interval_helper';
|
||||||
DefaultSearchCapabilities,
|
|
||||||
VisPayload,
|
import { DefaultSearchCapabilities } from './default_search_capabilities';
|
||||||
} from '../../../../../src/plugins/vis_type_timeseries/server';
|
|
||||||
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
import type { ReqFacade } from '../strategies/abstract_search_strategy';
|
||||||
|
|
||||||
export class RollupSearchCapabilities extends DefaultSearchCapabilities {
|
export class RollupSearchCapabilities extends DefaultSearchCapabilities {
|
||||||
rollupIndex: string;
|
rollupIndex: string;
|
|
@ -7,3 +7,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { SearchStrategyRegistry } from './search_strategy_registry';
|
export { SearchStrategyRegistry } from './search_strategy_registry';
|
||||||
|
export { DefaultSearchCapabilities } from './capabilities/default_search_capabilities';
|
||||||
|
|
||||||
|
export {
|
||||||
|
AbstractSearchStrategy,
|
||||||
|
ReqFacade,
|
||||||
|
RollupSearchStrategy,
|
||||||
|
DefaultSearchStrategy,
|
||||||
|
} from './strategies';
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isCalendarInterval, leastCommonInterval } from './interval_helper';
|
import { isCalendarInterval, leastCommonInterval } from './interval_helper';
|
||||||
|
|
||||||
describe('interval_helper', () => {
|
describe('interval_helper', () => {
|
|
@ -1,7 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import dateMath from '@elastic/datemath';
|
import dateMath from '@elastic/datemath';
|
|
@ -5,14 +5,13 @@
|
||||||
* compliance with, at your election, the Elastic License or the Server Side
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
* Public License, v 1.
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
import { get } from 'lodash';
|
||||||
|
import { RequestFacade, SearchStrategyRegistry } from './search_strategy_registry';
|
||||||
|
import { AbstractSearchStrategy, DefaultSearchStrategy } from './strategies';
|
||||||
|
import { DefaultSearchCapabilities } from './capabilities/default_search_capabilities';
|
||||||
|
|
||||||
import { SearchStrategyRegistry } from './search_strategy_registry';
|
const getPrivateField = <T>(registry: SearchStrategyRegistry, field: string) =>
|
||||||
// @ts-ignore
|
get(registry, field) as T;
|
||||||
import { AbstractSearchStrategy } from './strategies/abstract_search_strategy';
|
|
||||||
// @ts-ignore
|
|
||||||
import { DefaultSearchStrategy } from './strategies/default_search_strategy';
|
|
||||||
// @ts-ignore
|
|
||||||
import { DefaultSearchCapabilities } from './default_search_capabilities';
|
|
||||||
|
|
||||||
class MockSearchStrategy extends AbstractSearchStrategy {
|
class MockSearchStrategy extends AbstractSearchStrategy {
|
||||||
checkForViability() {
|
checkForViability() {
|
||||||
|
@ -28,23 +27,21 @@ describe('SearchStrategyRegister', () => {
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
registry = new SearchStrategyRegistry();
|
registry = new SearchStrategyRegistry();
|
||||||
|
registry.addStrategy(new DefaultSearchStrategy());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should init strategies register', () => {
|
test('should init strategies register', () => {
|
||||||
expect(
|
expect(getPrivateField(registry, 'strategies')).toHaveLength(1);
|
||||||
registry.addStrategy({} as AbstractSearchStrategy)[0] instanceof DefaultSearchStrategy
|
|
||||||
).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not add a strategy if it is not an instance of AbstractSearchStrategy', () => {
|
test('should not add a strategy if it is not an instance of AbstractSearchStrategy', () => {
|
||||||
const addedStrategies = registry.addStrategy({} as AbstractSearchStrategy);
|
const addedStrategies = registry.addStrategy({} as AbstractSearchStrategy);
|
||||||
|
|
||||||
expect(addedStrategies.length).toEqual(1);
|
expect(addedStrategies.length).toEqual(1);
|
||||||
expect(addedStrategies[0] instanceof DefaultSearchStrategy).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return a DefaultSearchStrategy instance', async () => {
|
test('should return a DefaultSearchStrategy instance', async () => {
|
||||||
const req = {};
|
const req = {} as RequestFacade;
|
||||||
const indexPattern = '*';
|
const indexPattern = '*';
|
||||||
|
|
||||||
const { searchStrategy, capabilities } = (await registry.getViableStrategy(req, indexPattern))!;
|
const { searchStrategy, capabilities } = (await registry.getViableStrategy(req, indexPattern))!;
|
||||||
|
@ -62,7 +59,7 @@ describe('SearchStrategyRegister', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return a MockSearchStrategy instance', async () => {
|
test('should return a MockSearchStrategy instance', async () => {
|
||||||
const req = {};
|
const req = {} as RequestFacade;
|
||||||
const indexPattern = '*';
|
const indexPattern = '*';
|
||||||
const anotherSearchStrategy = new MockSearchStrategy();
|
const anotherSearchStrategy = new MockSearchStrategy();
|
||||||
registry.addStrategy(anotherSearchStrategy);
|
registry.addStrategy(anotherSearchStrategy);
|
||||||
|
|
|
@ -6,23 +6,15 @@
|
||||||
* Public License, v 1.
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AbstractSearchStrategy } from './strategies/abstract_search_strategy';
|
|
||||||
// @ts-ignore
|
|
||||||
import { DefaultSearchStrategy } from './strategies/default_search_strategy';
|
|
||||||
// @ts-ignore
|
|
||||||
import { extractIndexPatterns } from '../../../common/extract_index_patterns';
|
import { extractIndexPatterns } from '../../../common/extract_index_patterns';
|
||||||
|
|
||||||
export type RequestFacade = any;
|
|
||||||
|
|
||||||
import { PanelSchema } from '../../../common/types';
|
import { PanelSchema } from '../../../common/types';
|
||||||
|
import { AbstractSearchStrategy, ReqFacade } from './strategies';
|
||||||
|
|
||||||
|
export type RequestFacade = ReqFacade<any>;
|
||||||
|
|
||||||
export class SearchStrategyRegistry {
|
export class SearchStrategyRegistry {
|
||||||
private strategies: AbstractSearchStrategy[] = [];
|
private strategies: AbstractSearchStrategy[] = [];
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.addStrategy(new DefaultSearchStrategy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public addStrategy(searchStrategy: AbstractSearchStrategy) {
|
public addStrategy(searchStrategy: AbstractSearchStrategy) {
|
||||||
if (searchStrategy instanceof AbstractSearchStrategy) {
|
if (searchStrategy instanceof AbstractSearchStrategy) {
|
||||||
this.strategies.unshift(searchStrategy);
|
this.strategies.unshift(searchStrategy);
|
||||||
|
|
|
@ -7,29 +7,35 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { from } from 'rxjs';
|
import { from } from 'rxjs';
|
||||||
import { AbstractSearchStrategy } from './abstract_search_strategy';
|
import { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
|
||||||
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
import type { IFieldType } from '../../../../../data/common';
|
||||||
|
|
||||||
|
class FooSearchStrategy extends AbstractSearchStrategy {}
|
||||||
|
|
||||||
describe('AbstractSearchStrategy', () => {
|
describe('AbstractSearchStrategy', () => {
|
||||||
let abstractSearchStrategy;
|
let abstractSearchStrategy: AbstractSearchStrategy;
|
||||||
let req;
|
let req: ReqFacade;
|
||||||
let mockedFields;
|
let mockedFields: IFieldType[];
|
||||||
let indexPattern;
|
let indexPattern: string;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockedFields = [];
|
mockedFields = [];
|
||||||
req = {
|
req = ({
|
||||||
payload: {},
|
payload: {},
|
||||||
pre: {
|
pre: {
|
||||||
indexPatternsFetcher: {
|
indexPatternsFetcher: {
|
||||||
getFieldsForWildcard: jest.fn().mockReturnValue(mockedFields),
|
getFieldsForWildcard: jest.fn().mockReturnValue(mockedFields),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getIndexPatternsService: jest.fn(() => ({
|
getIndexPatternsService: jest.fn(() =>
|
||||||
find: jest.fn(() => []),
|
Promise.resolve({
|
||||||
})),
|
find: jest.fn(() => []),
|
||||||
};
|
})
|
||||||
|
),
|
||||||
|
} as unknown) as ReqFacade<VisPayload>;
|
||||||
|
|
||||||
abstractSearchStrategy = new AbstractSearchStrategy();
|
abstractSearchStrategy = new FooSearchStrategy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should init an AbstractSearchStrategy instance', () => {
|
test('should init an AbstractSearchStrategy instance', () => {
|
||||||
|
@ -42,7 +48,7 @@ describe('AbstractSearchStrategy', () => {
|
||||||
const fields = await abstractSearchStrategy.getFieldsForWildcard(req, indexPattern);
|
const fields = await abstractSearchStrategy.getFieldsForWildcard(req, indexPattern);
|
||||||
|
|
||||||
expect(fields).toEqual(mockedFields);
|
expect(fields).toEqual(mockedFields);
|
||||||
expect(req.pre.indexPatternsFetcher.getFieldsForWildcard).toHaveBeenCalledWith({
|
expect(req.pre.indexPatternsFetcher!.getFieldsForWildcard).toHaveBeenCalledWith({
|
||||||
pattern: indexPattern,
|
pattern: indexPattern,
|
||||||
metaFields: [],
|
metaFields: [],
|
||||||
fieldCapsOptions: { allow_no_indices: true },
|
fieldCapsOptions: { allow_no_indices: true },
|
||||||
|
@ -54,7 +60,7 @@ describe('AbstractSearchStrategy', () => {
|
||||||
const searchFn = jest.fn().mockReturnValue(from(Promise.resolve({})));
|
const searchFn = jest.fn().mockReturnValue(from(Promise.resolve({})));
|
||||||
|
|
||||||
const responses = await abstractSearchStrategy.search(
|
const responses = await abstractSearchStrategy.search(
|
||||||
{
|
({
|
||||||
payload: {
|
payload: {
|
||||||
searchSession: {
|
searchSession: {
|
||||||
sessionId: '1',
|
sessionId: '1',
|
||||||
|
@ -65,7 +71,7 @@ describe('AbstractSearchStrategy', () => {
|
||||||
requestContext: {
|
requestContext: {
|
||||||
search: { search: searchFn },
|
search: { search: searchFn },
|
||||||
},
|
},
|
||||||
},
|
} as unknown) as ReqFacade<VisPayload>,
|
||||||
searches
|
searches
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
|
|
||||||
import type { FakeRequest, IUiSettingsClient, SavedObjectsClientContract } from 'kibana/server';
|
import type { FakeRequest, IUiSettingsClient, SavedObjectsClientContract } from 'kibana/server';
|
||||||
|
|
||||||
|
import { indexPatterns } from '../../../../../data/server';
|
||||||
|
|
||||||
import type { Framework } from '../../../plugin';
|
import type { Framework } from '../../../plugin';
|
||||||
import type { IndexPatternsFetcher, IFieldType } from '../../../../../data/server';
|
import type { IndexPatternsFetcher, IFieldType } from '../../../../../data/server';
|
||||||
import type { VisPayload } from '../../../../common/types';
|
import type { VisPayload } from '../../../../common/types';
|
||||||
import type { IndexPatternsService } from '../../../../../data/common';
|
import type { IndexPatternsService } from '../../../../../data/common';
|
||||||
import { indexPatterns } from '../../../../../data/server';
|
import type { SanitizedFieldType } from '../../../../common/types';
|
||||||
import { SanitizedFieldType } from '../../../../common/types';
|
|
||||||
import type { VisTypeTimeseriesRequestHandlerContext } from '../../../types';
|
import type { VisTypeTimeseriesRequestHandlerContext } from '../../../types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DefaultSearchStrategy } from './default_search_strategy';
|
import { DefaultSearchStrategy } from './default_search_strategy';
|
||||||
import { ReqFacade } from './abstract_search_strategy';
|
import type { ReqFacade } from './abstract_search_strategy';
|
||||||
import { VisPayload } from '../../../../common/types';
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
describe('DefaultSearchStrategy', () => {
|
describe('DefaultSearchStrategy', () => {
|
||||||
let defaultSearchStrategy: DefaultSearchStrategy;
|
let defaultSearchStrategy: DefaultSearchStrategy;
|
||||||
|
@ -20,7 +20,6 @@ describe('DefaultSearchStrategy', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should init an DefaultSearchStrategy instance', () => {
|
test('should init an DefaultSearchStrategy instance', () => {
|
||||||
expect(defaultSearchStrategy.name).toBe('default');
|
|
||||||
expect(defaultSearchStrategy.checkForViability).toBeDefined();
|
expect(defaultSearchStrategy.checkForViability).toBeDefined();
|
||||||
expect(defaultSearchStrategy.search).toBeDefined();
|
expect(defaultSearchStrategy.search).toBeDefined();
|
||||||
expect(defaultSearchStrategy.getFieldsForWildcard).toBeDefined();
|
expect(defaultSearchStrategy.getFieldsForWildcard).toBeDefined();
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
|
import { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
|
||||||
import { DefaultSearchCapabilities } from '../default_search_capabilities';
|
import { DefaultSearchCapabilities } from '../capabilities/default_search_capabilities';
|
||||||
import { VisPayload } from '../../../../common/types';
|
import { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
export class DefaultSearchStrategy extends AbstractSearchStrategy {
|
export class DefaultSearchStrategy extends AbstractSearchStrategy {
|
||||||
name = 'default';
|
|
||||||
|
|
||||||
checkForViability(req: ReqFacade<VisPayload>) {
|
checkForViability(req: ReqFacade<VisPayload>) {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
isViable: true,
|
isViable: true,
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
|
||||||
|
export { DefaultSearchStrategy } from './default_search_strategy';
|
||||||
|
export { RollupSearchStrategy } from './rollup_search_strategy';
|
|
@ -1,13 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
import { RollupSearchStrategy } from './rollup_search_strategy';
|
|
||||||
import type { ReqFacade, VisPayload } from '../../../../../src/plugins/vis_type_timeseries/server';
|
|
||||||
|
|
||||||
jest.mock('../../../../../src/plugins/vis_type_timeseries/server', () => {
|
import { RollupSearchStrategy } from './rollup_search_strategy';
|
||||||
const actual = jest.requireActual('../../../../../src/plugins/vis_type_timeseries/server');
|
|
||||||
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
import type { ReqFacade } from './abstract_search_strategy';
|
||||||
|
|
||||||
|
jest.mock('./abstract_search_strategy', () => {
|
||||||
class AbstractSearchStrategyMock {
|
class AbstractSearchStrategyMock {
|
||||||
getFieldsForWildcard() {
|
getFieldsForWildcard() {
|
||||||
return [
|
return [
|
||||||
|
@ -23,7 +27,6 @@ jest.mock('../../../../../src/plugins/vis_type_timeseries/server', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...actual,
|
|
||||||
AbstractSearchStrategy: AbstractSearchStrategyMock,
|
AbstractSearchStrategy: AbstractSearchStrategyMock,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -52,7 +55,7 @@ describe('Rollup Search Strategy', () => {
|
||||||
test('should create instance of RollupSearchRequest', () => {
|
test('should create instance of RollupSearchRequest', () => {
|
||||||
const rollupSearchStrategy = new RollupSearchStrategy();
|
const rollupSearchStrategy = new RollupSearchStrategy();
|
||||||
|
|
||||||
expect(rollupSearchStrategy.name).toBe('rollup');
|
expect(rollupSearchStrategy).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('checkForViability', () => {
|
describe('checkForViability', () => {
|
|
@ -1,17 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* and the Server Side Public License, v 1; you may not use this file except in
|
||||||
|
* compliance with, at your election, the Elastic License or the Server Side
|
||||||
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
import {
|
|
||||||
AbstractSearchStrategy,
|
|
||||||
ReqFacade,
|
|
||||||
VisPayload,
|
|
||||||
} from '../../../../../src/plugins/vis_type_timeseries/server';
|
|
||||||
|
|
||||||
import { getCapabilitiesForRollupIndices } from '../../../../../src/plugins/data/server';
|
import { ReqFacade, AbstractSearchStrategy } from './abstract_search_strategy';
|
||||||
|
import { RollupSearchCapabilities } from '../capabilities/rollup_search_capabilities';
|
||||||
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
import { RollupSearchCapabilities } from './rollup_search_capabilities';
|
import { getCapabilitiesForRollupIndices } from '../../../../../data/server';
|
||||||
|
|
||||||
const getRollupIndices = (rollupData: { [key: string]: any }) => Object.keys(rollupData);
|
const getRollupIndices = (rollupData: { [key: string]: any }) => Object.keys(rollupData);
|
||||||
const isIndexPatternContainsWildcard = (indexPattern: string) => indexPattern.includes('*');
|
const isIndexPatternContainsWildcard = (indexPattern: string) => indexPattern.includes('*');
|
||||||
|
@ -19,8 +18,6 @@ const isIndexPatternValid = (indexPattern: string) =>
|
||||||
indexPattern && typeof indexPattern === 'string' && !isIndexPatternContainsWildcard(indexPattern);
|
indexPattern && typeof indexPattern === 'string' && !isIndexPatternContainsWildcard(indexPattern);
|
||||||
|
|
||||||
export class RollupSearchStrategy extends AbstractSearchStrategy {
|
export class RollupSearchStrategy extends AbstractSearchStrategy {
|
||||||
name = 'rollup';
|
|
||||||
|
|
||||||
async search(req: ReqFacade<VisPayload>, bodies: any[]) {
|
async search(req: ReqFacade<VisPayload>, bodies: any[]) {
|
||||||
return super.search(req, bodies, 'rollup');
|
return super.search(req, bodies, 'rollup');
|
||||||
}
|
}
|
|
@ -6,7 +6,11 @@
|
||||||
* Public License, v 1.
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AbstractSearchStrategy, DefaultSearchCapabilities, ReqFacade } from '../../..';
|
import {
|
||||||
|
AbstractSearchStrategy,
|
||||||
|
DefaultSearchCapabilities,
|
||||||
|
ReqFacade,
|
||||||
|
} from '../../search_strategies';
|
||||||
|
|
||||||
export const createFieldsFetcher = (
|
export const createFieldsFetcher = (
|
||||||
req: ReqFacade,
|
req: ReqFacade,
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { getTimerange } from './get_timerange';
|
import { getTimerange } from './get_timerange';
|
||||||
import { ReqFacade, VisPayload } from '../../..';
|
import type { ReqFacade } from '../../search_strategies';
|
||||||
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
describe('getTimerange(req)', () => {
|
describe('getTimerange(req)', () => {
|
||||||
test('should return a moment object for to and from', () => {
|
test('should return a moment object for to and from', () => {
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { utc } from 'moment';
|
import { utc } from 'moment';
|
||||||
import { ReqFacade, VisPayload } from '../../..';
|
import type { ReqFacade } from '../../search_strategies';
|
||||||
|
import type { VisPayload } from '../../../../common/types';
|
||||||
|
|
||||||
export const getTimerange = (req: ReqFacade<VisPayload>) => {
|
export const getTimerange = (req: ReqFacade<VisPayload>) => {
|
||||||
const { min, max } = req.payload.timerange;
|
const { min, max } = req.payload.timerange;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Public License, v 1.
|
* Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DefaultSearchCapabilities } from '../../../search_strategies/default_search_capabilities';
|
import { DefaultSearchCapabilities } from '../../../search_strategies/capabilities/default_search_capabilities';
|
||||||
import { dateHistogram } from './date_histogram';
|
import { dateHistogram } from './date_histogram';
|
||||||
import { UI_SETTINGS } from '../../../../../../data/common';
|
import { UI_SETTINGS } from '../../../../../../data/common';
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,15 @@ import { PluginStart } from '../../data/server';
|
||||||
import { visDataRoutes } from './routes/vis';
|
import { visDataRoutes } from './routes/vis';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { fieldsRoutes } from './routes/fields';
|
import { fieldsRoutes } from './routes/fields';
|
||||||
import { SearchStrategyRegistry } from './lib/search_strategies';
|
|
||||||
import { uiSettings } from './ui_settings';
|
import { uiSettings } from './ui_settings';
|
||||||
import type { VisTypeTimeseriesRequestHandlerContext, VisTypeTimeseriesRouter } from './types';
|
import type { VisTypeTimeseriesRequestHandlerContext, VisTypeTimeseriesRouter } from './types';
|
||||||
|
|
||||||
|
import {
|
||||||
|
SearchStrategyRegistry,
|
||||||
|
DefaultSearchStrategy,
|
||||||
|
RollupSearchStrategy,
|
||||||
|
} from './lib/search_strategies';
|
||||||
|
|
||||||
export interface LegacySetup {
|
export interface LegacySetup {
|
||||||
server: Server;
|
server: Server;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +50,6 @@ export interface VisTypeTimeseriesSetup {
|
||||||
fakeRequest: FakeRequest,
|
fakeRequest: FakeRequest,
|
||||||
options: GetVisDataOptions
|
options: GetVisDataOptions
|
||||||
) => ReturnType<GetVisData>;
|
) => ReturnType<GetVisData>;
|
||||||
addSearchStrategy: SearchStrategyRegistry['addStrategy'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Framework {
|
export interface Framework {
|
||||||
|
@ -76,6 +80,9 @@ export class VisTypeTimeseriesPlugin implements Plugin<VisTypeTimeseriesSetup> {
|
||||||
|
|
||||||
const searchStrategyRegistry = new SearchStrategyRegistry();
|
const searchStrategyRegistry = new SearchStrategyRegistry();
|
||||||
|
|
||||||
|
searchStrategyRegistry.addStrategy(new DefaultSearchStrategy());
|
||||||
|
searchStrategyRegistry.addStrategy(new RollupSearchStrategy());
|
||||||
|
|
||||||
const framework: Framework = {
|
const framework: Framework = {
|
||||||
core,
|
core,
|
||||||
plugins,
|
plugins,
|
||||||
|
@ -97,7 +104,6 @@ export class VisTypeTimeseriesPlugin implements Plugin<VisTypeTimeseriesSetup> {
|
||||||
) => {
|
) => {
|
||||||
return await getVisData(requestContext, { ...fakeRequest, body: options }, framework);
|
return await getVisData(requestContext, { ...fakeRequest, body: options }, framework);
|
||||||
},
|
},
|
||||||
addSearchStrategy: searchStrategyRegistry.addStrategy.bind(searchStrategyRegistry),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
# vis_type_timeseries_enhanced
|
|
||||||
|
|
||||||
The `vis_type_timeseries_enhanced` plugin is the x-pack counterpart to the OSS `vis_type_timeseries` plugin.
|
|
||||||
|
|
||||||
It exists to provide Elastic-licensed services, or parts of services, which
|
|
||||||
enhance existing OSS functionality from `vis_type_timeseries`.
|
|
||||||
|
|
||||||
Currently the `vis_type_timeseries_enhanced` plugin doesn't return any APIs which you can
|
|
||||||
consume directly.
|
|
||||||
|
|
|
@ -1,11 +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;
|
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
preset: '@kbn/test',
|
|
||||||
rootDir: '../../..',
|
|
||||||
roots: ['<rootDir>/x-pack/plugins/vis_type_timeseries_enhanced'],
|
|
||||||
};
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"id": "visTypeTimeseriesEnhanced",
|
|
||||||
"version": "8.0.0",
|
|
||||||
"kibanaVersion": "kibana",
|
|
||||||
"server": true,
|
|
||||||
"ui": false,
|
|
||||||
"requiredPlugins": [
|
|
||||||
"visTypeTimeseries"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,11 +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;
|
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { PluginInitializerContext } from 'src/core/server';
|
|
||||||
import { VisTypeTimeseriesEnhanced } from './plugin';
|
|
||||||
|
|
||||||
export const plugin = (initializerContext: PluginInitializerContext) =>
|
|
||||||
new VisTypeTimeseriesEnhanced(initializerContext);
|
|
|
@ -1,33 +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;
|
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Plugin, PluginInitializerContext, Logger, CoreSetup } from 'src/core/server';
|
|
||||||
import { VisTypeTimeseriesSetup } from 'src/plugins/vis_type_timeseries/server';
|
|
||||||
import { RollupSearchStrategy } from './search_strategies/rollup_search_strategy';
|
|
||||||
|
|
||||||
interface VisTypeTimeseriesEnhancedSetupDependencies {
|
|
||||||
visTypeTimeseries: VisTypeTimeseriesSetup;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class VisTypeTimeseriesEnhanced
|
|
||||||
implements Plugin<void, void, VisTypeTimeseriesEnhancedSetupDependencies, any> {
|
|
||||||
private logger: Logger;
|
|
||||||
|
|
||||||
constructor(initializerContext: PluginInitializerContext) {
|
|
||||||
this.logger = initializerContext.logger.get('vis_type_timeseries_enhanced');
|
|
||||||
}
|
|
||||||
|
|
||||||
public async setup(
|
|
||||||
core: CoreSetup,
|
|
||||||
{ visTypeTimeseries }: VisTypeTimeseriesEnhancedSetupDependencies
|
|
||||||
) {
|
|
||||||
this.logger.debug('Starting plugin');
|
|
||||||
|
|
||||||
visTypeTimeseries.addSearchStrategy(new RollupSearchStrategy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public start() {}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../../../tsconfig.base.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"composite": true,
|
|
||||||
"outDir": "./target/types",
|
|
||||||
"emitDeclarationOnly": true,
|
|
||||||
"declaration": true,
|
|
||||||
"declarationMap": true
|
|
||||||
},
|
|
||||||
"include": ["*.ts", "server/**/*"],
|
|
||||||
"references": [
|
|
||||||
{ "path": "../../../src/core/tsconfig.json" },
|
|
||||||
{ "path": "../../../src/plugins/vis_type_timeseries/tsconfig.json" }
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -29,7 +29,6 @@
|
||||||
"plugins/translations/**/*",
|
"plugins/translations/**/*",
|
||||||
"plugins/triggers_actions_ui/**/*",
|
"plugins/triggers_actions_ui/**/*",
|
||||||
"plugins/ui_actions_enhanced/**/*",
|
"plugins/ui_actions_enhanced/**/*",
|
||||||
"plugins/vis_type_timeseries_enhanced/**/*",
|
|
||||||
"plugins/spaces/**/*",
|
"plugins/spaces/**/*",
|
||||||
"plugins/security/**/*",
|
"plugins/security/**/*",
|
||||||
"plugins/stack_alerts/**/*",
|
"plugins/stack_alerts/**/*",
|
||||||
|
@ -96,7 +95,6 @@
|
||||||
{ "path": "./plugins/task_manager/tsconfig.json" },
|
{ "path": "./plugins/task_manager/tsconfig.json" },
|
||||||
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" },
|
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" },
|
||||||
{ "path": "./plugins/ui_actions_enhanced/tsconfig.json" },
|
{ "path": "./plugins/ui_actions_enhanced/tsconfig.json" },
|
||||||
{ "path": "./plugins/vis_type_timeseries_enhanced/tsconfig.json" },
|
|
||||||
{ "path": "./plugins/translations/tsconfig.json" },
|
{ "path": "./plugins/translations/tsconfig.json" },
|
||||||
{ "path": "./plugins/spaces/tsconfig.json" },
|
{ "path": "./plugins/spaces/tsconfig.json" },
|
||||||
{ "path": "./plugins/security/tsconfig.json" },
|
{ "path": "./plugins/security/tsconfig.json" },
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
{ "path": "./plugins/task_manager/tsconfig.json" },
|
{ "path": "./plugins/task_manager/tsconfig.json" },
|
||||||
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" },
|
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" },
|
||||||
{ "path": "./plugins/ui_actions_enhanced/tsconfig.json" },
|
{ "path": "./plugins/ui_actions_enhanced/tsconfig.json" },
|
||||||
{ "path": "./plugins/vis_type_timeseries_enhanced/tsconfig.json" },
|
|
||||||
{ "path": "./plugins/translations/tsconfig.json" },
|
{ "path": "./plugins/translations/tsconfig.json" },
|
||||||
{ "path": "./plugins/triggers_actions_ui/tsconfig.json"},
|
{ "path": "./plugins/triggers_actions_ui/tsconfig.json"},
|
||||||
{ "path": "./plugins/spaces/tsconfig.json" },
|
{ "path": "./plugins/spaces/tsconfig.json" },
|
||||||
|
|
Loading…
Reference in a new issue