Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data views] Move data views api from data plugin and into its own #113497

Merged
merged 35 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c0f91f7
initial pass at moving data views into own plugin
mattkime Sep 30, 2021
a5d2e0d
require expressions plugin, fix META_FIELDS reference
mattkime Sep 30, 2021
10aab14
bundle limits and localization
mattkime Sep 30, 2021
81eae52
fix integration test
mattkime Sep 30, 2021
78c639d
update plugin list and jest config
mattkime Sep 30, 2021
93ec684
type fixes
mattkime Sep 30, 2021
3487531
search fixes
mattkime Sep 30, 2021
457389b
fix localization
mattkime Sep 30, 2021
dd14e3a
fix mocks
mattkime Sep 30, 2021
7e6b177
fix mocks
mattkime Sep 30, 2021
6d27810
fix stub
mattkime Sep 30, 2021
3a23774
type fixes
mattkime Sep 30, 2021
0711f96
fix import on test file
mattkime Sep 30, 2021
8bfff12
path fixes
mattkime Sep 30, 2021
04d0e59
remove shorted dotted from data plugin
mattkime Oct 1, 2021
606383a
more todo removal
mattkime Oct 1, 2021
d675c1c
eslint fixes
mattkime Oct 1, 2021
0d933ce
eslint fix
mattkime Oct 1, 2021
429e23b
simplify data views server plugin
mattkime Oct 1, 2021
115f25c
simplify data views server plugin
mattkime Oct 1, 2021
b405d5c
simplify data views server plugin
mattkime Oct 1, 2021
cef2fd6
fix imports on api routes
mattkime Oct 1, 2021
544b5ce
fix imports on api routes
mattkime Oct 1, 2021
6587c76
update plugin list
mattkime Oct 1, 2021
ee0dad6
ts fixes
mattkime Oct 1, 2021
e2f3671
ts fixes
mattkime Oct 1, 2021
5fe349a
add deprecation notice
mattkime Oct 1, 2021
eb3c090
fix circular dependency and api integration test
mattkime Oct 2, 2021
803e818
fix circular dependency and api integration test
mattkime Oct 2, 2021
6d7d848
rename types for better clarity
mattkime Oct 3, 2021
6faa465
Merge branch 'master' into data_views_to_own_plugin
kibanamachine Oct 3, 2021
9980dbb
path fixes
mattkime Oct 3, 2021
a844127
Merge branch 'master' into data_views_to_own_plugin
kibanamachine Oct 4, 2021
2345897
jest.config and tsconfig cleanup
mattkime Oct 4, 2021
293d7dc
Merge branch 'data_views_to_own_plugin' of github.com:mattkime/kibana…
mattkime Oct 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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