Skip to content

Commit

Permalink
[data views] Move data views api from data plugin and into its own (#…
Browse files Browse the repository at this point in the history
…113497)

* initial pass at moving data views into own plugin

* require expressions plugin, fix META_FIELDS reference

* bundle limits and localization

* fix integration test

* update plugin list and jest config

* type fixes

* search fixes

* fix localization

* fix mocks

* fix mocks

* fix stub

* type fixes

* fix import on test file

* path fixes

* remove shorted dotted from data plugin

* more todo removal

* eslint fixes

* eslint fix

* simplify data views server plugin

* simplify data views server plugin

* simplify data views server plugin

* fix imports on api routes

* fix imports on api routes

* update plugin list

* ts fixes

* ts fixes

* add deprecation notice

* fix circular dependency and api integration test

* fix circular dependency and api integration test

* rename types for better clarity

* path fixes

* jest.config and tsconfig cleanup

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mattkime and kibanamachine authored Oct 4, 2021
1 parent 28702ff commit bbb2e96
Show file tree
Hide file tree
Showing 169 changed files with 996 additions and 497 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
/packages/kbn-interpreter/ @elastic/kibana-app-services
/src/plugins/bfetch/ @elastic/kibana-app-services
/src/plugins/data/ @elastic/kibana-app-services
/src/plugins/data-views/ @elastic/kibana-app-services
/src/plugins/embeddable/ @elastic/kibana-app-services
/src/plugins/expressions/ @elastic/kibana-app-services
/src/plugins/field_formats/ @elastic/kibana-app-services
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"bfetch": "src/plugins/bfetch",
"dashboard": "src/plugins/dashboard",
"data": "src/plugins/data",
"dataViews": "src/plugins/data_views",
"embeddableApi": "src/plugins/embeddable",
"embeddableExamples": "examples/embeddable_examples",
"fieldFormats": "src/plugins/field_formats",
Expand Down
6 changes: 6 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ as uiSettings within the code.
|The data plugin provides common data access services, such as search and query, for solutions and application developers.
|{kib-repo}blob/{branch}/src/plugins/data_views/README.mdx[dataViews]
|The data views API provides a consistent method of structuring and formatting documents
and field lists across the various Kibana apps. Its typically used in conjunction with
<DocLink id="kibDevTutorialDataSearchAndSessions" section="high-level-search" text="SearchSource" /> for composing queries.
|{kib-repo}blob/{branch}/src/plugins/dev_tools/README.md[devTools]
|The ui/registry/dev_tools is removed in favor of the devTools plugin which exposes a register method in the setup contract.
Registering app works mostly the same as registering apps in core.application.register.
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ pageLoadAssetSize:
expressions: 239290
securitySolution: 231753
customIntegrations: 28810
dataViews: 42000
9 changes: 0 additions & 9 deletions src/plugins/data/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ This is helpful when you want to provide a user with options, for example when c

```

## Data Views

The data views API provides a consistent method of structuring and formatting documents
and field lists across the various Kibana apps. Its typically used in conjunction with
<DocLink id="kibDevTutorialDataSearchAndSessions" section="high-level-search" text="SearchSource" /> for composing queries.

*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*


## Query

The query service is responsible for managing the configuration of a search query (`QueryState`): filters, time range, query string, and settings such as the auto refresh behavior and saved queries.
Expand Down
9 changes: 0 additions & 9 deletions src/plugins/data/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
export const DEFAULT_QUERY_LANGUAGE = 'kuery';
export const KIBANA_USER_QUERY_LANGUAGE_KEY = 'kibana.userQueryLanguage';

/** @public **/
export const DATA_VIEW_SAVED_OBJECT_TYPE = 'index-pattern';

/**
* @deprecated Use DATA_VIEW_SAVED_OBJECT_TYPE. All index pattern interfaces were renamed.
*/

export const INDEX_PATTERN_SAVED_OBJECT_TYPE = DATA_VIEW_SAVED_OBJECT_TYPE;

export type ValueSuggestionsMethod = 'terms_enum' | 'terms_agg';

export const UI_SETTINGS = {
Expand Down
21 changes: 0 additions & 21 deletions src/plugins/data/common/data_views/index.ts

This file was deleted.

70 changes: 60 additions & 10 deletions src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,68 @@

export * from './constants';
export * from './es_query';
export * from './data_views';
export * from './kbn_field_types';
export * from './query';
export * from './search';
export * from './types';
export * from './utils';
export * from './exports';

/**
*
* @deprecated Use data plugin interface instead
* @removeBy 8.1
*/

export { IndexPatternAttributes } from './types';
export type {
IFieldType,
IIndexPatternFieldList,
FieldFormatMap,
RuntimeType,
RuntimeField,
IIndexPattern,
DataViewAttributes,
IndexPatternAttributes,
FieldAttrs,
FieldAttrSet,
OnNotification,
OnError,
UiSettingsCommon,
SavedObjectsClientCommonFindArgs,
SavedObjectsClientCommon,
GetFieldsOptions,
GetFieldsOptionsTimePattern,
IDataViewsApiClient,
IIndexPatternsApiClient,
SavedObject,
AggregationRestrictions,
TypeMeta,
FieldSpecConflictDescriptions,
FieldSpecExportFmt,
FieldSpec,
DataViewFieldMap,
IndexPatternFieldMap,
DataViewSpec,
IndexPatternSpec,
SourceFilter,
IndexPatternExpressionType,
IndexPatternLoadStartDependencies,
IndexPatternLoadExpressionFunctionDefinition,
} from '../../data_views/common';
export {
RUNTIME_FIELD_TYPES,
FLEET_ASSETS_TO_IGNORE,
META_FIELDS,
DATA_VIEW_SAVED_OBJECT_TYPE,
INDEX_PATTERN_SAVED_OBJECT_TYPE,
isFilterable,
isNestedField,
fieldList,
DataViewField,
IndexPatternField,
DataViewType,
IndexPatternType,
IndexPatternsService,
IndexPatternsContract,
DataViewsService,
DataViewsContract,
IndexPattern,
IndexPatternListItem,
DataView,
DataViewListItem,
DuplicateDataViewError,
DataViewSavedObjectConflictError,
getIndexPatternLoadMeta,
} from '../../data_views/common';
2 changes: 1 addition & 1 deletion src/plugins/data/common/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export * from './data_views/fields/fields.mocks';
export * from '../../data_views/common/fields/fields.mocks';
2 changes: 1 addition & 1 deletion src/plugins/data/common/search/aggs/param_types/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { BaseParamType } from './base';
import { propFilter } from '../utils';
import { KBN_FIELD_TYPES } from '../../../kbn_field_types/types';
import { isNestedField, IndexPatternField } from '../../../data_views/fields';
import { isNestedField, IndexPatternField } from '../../../../../data_views/common';

const filterByType = propFilter('type');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Observable } from 'rxjs';
import type { Datatable, ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { buildExpressionFunction } from '../../../../../../plugins/expressions/common';

import { IndexPatternExpressionType } from '../../../data_views/expressions';
import { IndexPatternExpressionType } from '../../../../../data_views/common/expressions';
import { IndexPatternsContract } from '../../..';

import { AggsStart, AggExpressionType, aggCountFnName } from '../../aggs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SavedObjectReference } from 'src/core/types';
import { Filter } from '@kbn/es-query';
import { SearchSourceFields } from './types';

import { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../../constants';
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../../../data/common';

export const extractReferences = (
state: SearchSourceFields
Expand All @@ -22,7 +22,7 @@ export const extractReferences = (
const refName = 'kibanaSavedObjectMeta.searchSourceJSON.index';
references.push({
name: refName,
type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
type: DATA_VIEW_SAVED_OBJECT_TYPE,
id: indexId,
});
searchSourceFields = {
Expand All @@ -42,7 +42,7 @@ export const extractReferences = (
const refName = `kibanaSavedObjectMeta.searchSourceJSON.filter[${i}].meta.index`;
references.push({
name: refName,
type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
type: DATA_VIEW_SAVED_OBJECT_TYPE,
id: filterRow.meta.index,
});
return {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* Side Public License, v 1.
*/

export * from './data_views/field.stub';
export * from './data_views/data_view.stub';
export * from '../../data_views/common/field.stub';
export * from '../../data_views/common/data_view.stub';
export * from './es_query/stubs';
1 change: 0 additions & 1 deletion src/plugins/data/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

export * from './query/types';
export * from './kbn_field_types/types';
export * from './data_views/types';

/**
* If a service is being shared on both the client and the server, and
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats"],
"serviceFolders": ["search", "data_views", "query", "autocomplete", "ui"],
"requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats", "dataViews"],
"serviceFolders": ["search", "query", "autocomplete", "ui"],
"optionalPlugins": ["usageCollection"],
"extraPublicDirs": ["common"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"],
Expand Down
23 changes: 1 addition & 22 deletions src/plugins/data/public/data_views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,4 @@
* Side Public License, v 1.
*/

export {
ILLEGAL_CHARACTERS_KEY,
CONTAINS_SPACES_KEY,
ILLEGAL_CHARACTERS_VISIBLE,
ILLEGAL_CHARACTERS,
validateDataView,
} from '../../common/data_views/lib';
export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './data_views';

export { IndexPatternField, IIndexPatternFieldList, TypeMeta } from '../../common/data_views';

export {
IndexPatternsService,
IndexPatternsContract,
IndexPattern,
DataViewsApiClient,
DataViewsService,
DataViewsContract,
DataView,
} from './data_views';
export { UiSettingsPublicToCommon } from './ui_settings_wrapper';
export { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
export * from '../../../data_views/public';
4 changes: 1 addition & 3 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ export {
IndexPatternLoadExpressionFunctionDefinition,
fieldList,
GetFieldsOptions,
INDEX_PATTERN_SAVED_OBJECT_TYPE,
AggregationRestrictions,
IndexPatternType,
IndexPatternListItem,
DuplicateDataViewError,
} from '../common';

export { DuplicateDataViewError } from '../common/data_views/errors';

/*
* Autocomplete query suggestions:
*/
Expand Down
40 changes: 7 additions & 33 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ import { AutocompleteService } from './autocomplete';
import { SearchService } from './search/search_service';
import { QueryService } from './query';
import { createIndexPatternSelect } from './ui/index_pattern_select';
import {
DataViewsService,
onRedirectNoIndexPattern,
DataViewsApiClient,
UiSettingsPublicToCommon,
} from './data_views';
import {
setIndexPatterns,
setNotifications,
Expand All @@ -44,8 +38,6 @@ import {
createSelectRangeAction,
} from './actions';
import { APPLY_FILTER_TRIGGER, applyFilterTrigger } from './triggers';
import { SavedObjectsClientPublicToCommon } from './data_views';
import { getIndexPatternLoad } from './data_views/expressions';
import { UsageCollectionSetup } from '../../usage_collection/public';
import { getTableViewDescription } from './utils/table_inspector_view';
import { NowProvider, NowProviderInternalContract } from './now_provider';
Expand Down Expand Up @@ -89,8 +81,6 @@ export class DataPublicPlugin
): DataPublicPluginSetup {
const startServices = createStartServicesGetter(core.getStartServices);

expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));

this.usageCollection = usageCollection;

const searchService = this.searchService.setup(core, {
Expand Down Expand Up @@ -138,37 +128,21 @@ export class DataPublicPlugin

public start(
core: CoreStart,
{ uiActions, fieldFormats }: DataStartDependencies
{ uiActions, fieldFormats, dataViews }: DataStartDependencies
): DataPublicPluginStart {
const { uiSettings, http, notifications, savedObjects, overlays, application } = core;
const { uiSettings, notifications, savedObjects, overlays } = core;
setNotifications(notifications);
setOverlays(overlays);
setUiSettings(uiSettings);

const indexPatterns = new DataViewsService({
uiSettings: new UiSettingsPublicToCommon(uiSettings),
savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client),
apiClient: new DataViewsApiClient(http),
fieldFormats,
onNotification: (toastInputFields) => {
notifications.toasts.add(toastInputFields);
},
onError: notifications.toasts.addError.bind(notifications.toasts),
onRedirectNoIndexPattern: onRedirectNoIndexPattern(
application.capabilities,
application.navigateToApp,
overlays
),
});
setIndexPatterns(indexPatterns);
setIndexPatterns(dataViews);

const query = this.queryService.start({
storage: this.storage,
savedObjectsClient: savedObjects.client,
uiSettings,
});

const search = this.searchService.start(core, { fieldFormats, indexPatterns });
const search = this.searchService.start(core, { fieldFormats, indexPatterns: dataViews });
setSearchService(search);

uiActions.addTriggerAction(
Expand Down Expand Up @@ -197,8 +171,8 @@ export class DataPublicPlugin
},
autocomplete: this.autocomplete.start(),
fieldFormats,
indexPatterns,
dataViews: indexPatterns,
indexPatterns: dataViews,
dataViews,
query,
search,
nowProvider: this.nowProvider,
Expand All @@ -214,7 +188,7 @@ export class DataPublicPlugin
return {
...dataServices,
ui: {
IndexPatternSelect: createIndexPatternSelect(indexPatterns),
IndexPatternSelect: createIndexPatternSelect(dataViews),
SearchBar,
},
};
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/public/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
*/

export * from '../common/stubs';
export { createStubDataView } from './data_views/data_views/data_view.stub';
// eslint-disable-next-line
export { createStubDataView } from '../../data_views/public/data_views/data_view.stub';
Loading

0 comments on commit bbb2e96

Please sign in to comment.