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

[Discover] Migrate DataView related imports to data_views plugin #126315

Merged
merged 11 commits into from
Mar 15, 2022
8 changes: 5 additions & 3 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './deprecated';
* Filters:
*/

export { getEsQueryConfig } from '../common';
export { getEsQueryConfig, FilterStateStore } from '../common';
export { FilterLabel, FilterItem } from './ui';
export { getDisplayValueFromFilter, generateFilters, extractTimeRange } from './query';

Expand Down Expand Up @@ -201,13 +201,13 @@ export {
SEARCH_SESSIONS_MANAGEMENT_ID,
waitUntilNextSessionCompletes$,
isEsError,
SearchSource,
SearchSessionState,
SortDirection,
handleResponse,
} from './search';

export type {
SearchSource,
// TODO: remove these when data_enhanced is merged into data
ISessionService,
SearchSessionInfoProvider,
Expand Down Expand Up @@ -294,7 +294,9 @@ export type { AggsStart } from './search/aggs';

export { getTime } from '../common';

export { isTimeRange, isQuery } from '../common';
export type { SavedObject } from '../common';

export { isTimeRange, isQuery, flattenHit, calculateBounds, tabifyAggResponse } from '../common';

export type { ApplyGlobalFilterActionContext } from './actions';
export { ACTION_GLOBAL_APPLY_FILTER } from './actions';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ConfigSchema, configSchema } from '../config';
import { DataServerPlugin, DataPluginSetup, DataPluginStart } from './plugin';

export * from './deprecated';
export { getEsQueryConfig } from '../common';
export { getEsQueryConfig, DEFAULT_QUERY_LANGUAGE } from '../common';

/**
* Exporters (CSV)
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/data_views/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ export {
export { onRedirectNoIndexPattern } from './data_views';

export type { IIndexPatternFieldList, TypeMeta, RuntimeType } from '../common';
export type { DataViewSpec } from '../common';
export type { DataViewSpec, FieldSpec, DataViewAttributes } from '../common';
export {
IndexPatternField,
DataViewField,
DataViewType,
DataViewSavedObjectConflictError,
META_FIELDS,
DATA_VIEW_SAVED_OBJECT_TYPE,
getFieldSubtypeMulti,
getFieldSubtypeNested,
} from '../common';

export type { IndexPatternsContract } from './data_views';
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/discover/public/__mocks__/index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import { IIndexPatternFieldList } from '../../../data/common';
import { DataView } from '../../../data/common';
import { IIndexPatternFieldList, DataView } from '../../../data_views/public';

const fields = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import { IIndexPatternFieldList } from '../../../data/common';
import { DataView } from '../../../data/common';
import { IIndexPatternFieldList, DataView } from '../../../data_views/public';

const fields = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SAMPLE_SIZE_SETTING,
SORT_DEFAULT_ORDER_SETTING,
} from '../../common';
import { UI_SETTINGS } from '../../../data/common';
import { UI_SETTINGS } from '../../../data/public';
import { TopNavMenu } from '../../../navigation/public';
import { FORMATS_UI_SETTINGS } from 'src/plugins/field_formats/common';
import { LocalStorageMock } from './local_storage_mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EuiText, EuiPageContent, EuiPage, EuiSpacer } from '@elastic/eui';
import { cloneDeep } from 'lodash';
import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '../../../common';
import { ContextErrorMessage } from './components/context_error_message';
import { DataView, DataViewField } from '../../../../data/common';
import { DataView, DataViewField } from '../../../../data_views/public';
import { LoadingStatus } from './services/context_query_state';
import { AppState, isEqualFilters } from './services/context_state';
import { useColumns } from '../../utils/use_data_grid_columns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { mountWithIntl } from '@kbn/test-jest-helpers';
import { findTestSubject } from '@elastic/eui/lib/test';
import { ActionBar } from './components/action_bar/action_bar';
import { GetStateReturn } from './services/context_state';
import { SortDirection } from 'src/plugins/data/common';
import { SortDirection } from 'src/plugins/data/public';
import { ContextAppContent, ContextAppContentProps } from './context_app_content';
import { LoadingStatus } from './services/context_query_state';
import { indexPatternMock } from '../../__mocks__/index_pattern';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import React, { useState, Fragment, useMemo, useCallback } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiHorizontalRule, EuiText } from '@elastic/eui';
import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '../../../common';
import { DataView, SortDirection } from '../../../../data/common';
import type { DataView } from '../../../../data_views/public';
import { SortDirection } from '../../../../data/public';
import { LoadingStatus } from './services/context_query_state';
import { ActionBar } from './components/action_bar/action_bar';
import { DiscoverGrid } from '../../components/discover_grid/discover_grid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { DataView, SortDirection } from '../../../../../data/common';
import { DataView } from '../../../../../data_views/public';
import { SortDirection } from '../../../../../data/public';
import { createSearchSourceStub } from './_stubs';
import { fetchAnchor, updateSearchSource } from './anchor';
import { indexPatternMock } from '../../../__mocks__/index_pattern';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { i18n } from '@kbn/i18n';

import { ISearchSource, EsQuerySortValue, DataView } from '../../../../../data/common';
import { ISearchSource, EsQuerySortValue } from '../../../../../data/public';
import { DataView } from '../../../../../data_views/public';
import { EsHitRecord } from '../../types';

export async function fetchAnchor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import moment from 'moment';
import { get, last } from 'lodash';
import { DataView, SortDirection } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/public';
import { SortDirection } from 'src/plugins/data/public';
import { createContextSearchSourceStub } from './_stubs';
import { fetchSurroundingDocs, SurrDocType } from './context';
import { DataPublicPluginStart, Query } from '../../../../../data/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import moment from 'moment';
import { get, last } from 'lodash';
import { DataView, SortDirection } from 'src/plugins/data/common';
import { SortDirection } from 'src/plugins/data/public';
import type { DataView } from 'src/plugins/data_views/public';
import { createContextSearchSourceStub } from './_stubs';
import { DataPublicPluginStart, Query } from '../../../../../data/public';
import { fetchSurroundingDocs, SurrDocType } from './context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/
import type { Filter } from '@kbn/es-query';
import { DataView, ISearchSource } from 'src/plugins/data/common';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { DataView } from 'src/plugins/data_views/public';
import { DataPublicPluginStart, ISearchSource } from 'src/plugins/data/public';
import { reverseSortDir, SortDirection } from '../utils/sorting';
import { convertIsoToMillis, extractNanos } from '../utils/date_conversion';
import { fetchHitsInInterval } from '../utils/fetch_hits_in_interval';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { EsQuerySortValue, SortDirection } from 'src/plugins/data/common';
import type { EsQuerySortValue, SortDirection } from 'src/plugins/data/public';

/**
* Returns `EsQuerySort` which is used to sort records in the ES query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { DataView } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/public';

export enum SortDirection {
asc = 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '../__mocks__/use_context_app_fetch';
import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
import { createContextSearchSourceStub } from '../services/_stubs';
import { DataView } from '../../../../../data_views/common';
import { DataView } from '../../../../../data_views/public';
import { themeServiceMock } from '../../../../../../core/public/mocks';
import { KibanaContextProvider } from '../../../../../kibana_react/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../common';
import { fetchAnchor } from '../services/anchor';
import { fetchSurroundingDocs, SurrDocType } from '../services/context';
import { MarkdownSimple, toMountPoint, wrapWithTheme } from '../../../../../kibana_react/public';
import { DataView, SortDirection } from '../../../../../data/common';
import type { DataView } from '../../../../../data_views/public';
import { SortDirection } from '../../../../../data/public';
import {
ContextFetchState,
FailureReason,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiCallOut, EuiLink, EuiLoadingSpinner, EuiPageContent, EuiPage } from '@elastic/eui';
import { DataView } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/public';
import { DocViewer } from '../../../services/doc_views/components/doc_viewer';
import { ElasticRequestState } from '../types';
import { useEsDocSearch } from '../../../utils/use_es_doc_search';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { Subject, BehaviorSubject } from 'rxjs';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import type { DataView } from '../../../../../../data/common';
import type { DataView } from '../../../../../../data_views/public';
import { setHeaderActionMenuMounter, setUiActions } from '../../../../kibana_services';
import { esHits } from '../../../../__mocks__/es_hits';
import { savedSearchMock } from '../../../../__mocks__/saved_search';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { DataView } from '../../../../../../data/common';
import type { DataView } from '../../../../../../data_views/public';
import { HitsCounter } from '../hits_counter';
import { SavedSearch } from '../../../../services/saved_searches';
import { GetStateReturn } from '../../services/discover_state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import type { Filter } from '@kbn/es-query';
import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics';
import { useDiscoverServices } from '../../../../utils/use_discover_services';
import { DataViewField, DataView, Query } from '../../../../../../data/common';
import type { Query } from '../../../../../../data/public';
import type { DataViewField, DataView } from '../../../../../../data_views/public';
import {
EmbeddableInput,
EmbeddableOutput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
SEARCH_FIELDS_FROM_SOURCE,
} from '../../../../../common';
import { useColumns } from '../../../../utils/use_data_grid_columns';
import { DataView } from '../../../../../../data/common';
import { DataView } from '../../../../../../data_views/public';
import { SavedSearch } from '../../../../services/saved_searches';
import { DataDocumentsMsg, DataDocuments$ } from '../../utils/use_saved_search';
import { AppState, GetStateReturn } from '../../services/discover_state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { esHits } from '../../../../__mocks__/es_hits';
import { indexPatternMock } from '../../../../__mocks__/index_pattern';
import { savedSearchMock } from '../../../../__mocks__/saved_search';
import { createSearchSourceMock } from '../../../../../../data/common/search/search_source/mocks';
import { DataView, IndexPatternAttributes } from '../../../../../../data/common';
import type { DataView, DataViewAttributes } from '../../../../../../data_views/public';
import { SavedObject } from '../../../../../../../core/types';
import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
import { GetStateReturn } from '../../services/discover_state';
Expand Down Expand Up @@ -57,7 +57,7 @@ function mountComponent(indexPattern: DataView, prevSidebarClosed?: boolean) {

const indexPatternList = [indexPattern].map((ip) => {
return { ...ip, ...{ attributes: { title: ip.title } } };
}) as unknown as Array<SavedObject<IndexPatternAttributes>>;
}) as unknown as Array<SavedObject<DataViewAttributes>>;

const main$ = new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useDiscoverServices } from '../../../../utils/use_discover_services';
import { DiscoverNoResults } from '../no_results';
import { LoadingSpinner } from '../loading_spinner/loading_spinner';
import { generateFilters } from '../../../../../../data/public';
import { DataViewField } from '../../../../../../data/common';
import { DataViewField } from '../../../../../../data_views/public';
import { DiscoverSidebarResponsive } from '../sidebar';
import { DiscoverLayoutProps } from './types';
import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '../../../../../common';
Expand All @@ -48,7 +48,7 @@ import {
import { FieldStatisticsTable } from '../field_stats_table';
import { VIEW_MODE } from '../../../../components/view_mode_toggle';
import { DOCUMENTS_VIEW_CLICK, FIELD_STATISTICS_VIEW_CLICK } from '../field_stats_table/constants';
import { DataViewType, DataView } from '../../../../../../data_views/common';
import { DataViewType, DataView } from '../../../../../../data_views/public';

/**
* Local storage key for sidebar persistence state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
* Side Public License, v 1.
*/

import {
DataView,
IndexPatternAttributes,
Query,
SavedObject,
TimeRange,
} from '../../../../../../data/common';
import type { Query, TimeRange, SavedObject } from '../../../../../../data/public';
import type { DataView, DataViewAttributes } from '../../../../../../data_views/public';
import { ISearchSource } from '../../../../../../data/public';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { DataRefetch$, SavedSearchData } from '../../utils/use_saved_search';
Expand All @@ -22,7 +17,7 @@ import { ElasticSearchHit } from '../../../../types';

export interface DiscoverLayoutProps {
indexPattern: DataView;
indexPatternList: Array<SavedObject<IndexPatternAttributes>>;
indexPatternList: Array<SavedObject<DataViewAttributes>>;
inspectorAdapters: { requests: RequestAdapter };
navigateTo: (url: string) => void;
onChangeIndexPattern: (id: string) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { storiesOf } from '@storybook/react';
import React from 'react';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { DiscoverFieldDetails } from '../discover_field_details';
import { DataView, IndexPatternField } from '../../../../../../../data_views/common';
import { DataView, IndexPatternField } from '../../../../../../../data_views/public';
import { fieldSpecMap } from './fields';
import { numericField as field } from './fields';
import { Bucket } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { FieldSpec, IndexPatternField } from '../../../../../../../data_views/common';
import { DataViewField, FieldSpec } from '../../../../../../../data_views/public';

export const fieldSpecMap: Record<string, FieldSpec> = {
'machine.os': {
Expand Down Expand Up @@ -39,7 +39,7 @@ export const fieldSpecMap: Record<string, FieldSpec> = {
},
};

export const numericField = new IndexPatternField({
export const numericField = new DataViewField({
name: 'bytes',
type: 'number',
esTypes: ['long'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test-jest-helpers';

import { DiscoverField } from './discover_field';
import { DataViewField } from '../../../../../../data/common';
import { stubIndexPattern } from '../../../../../../data/common/stubs';
import { DataViewField } from '../../../../../../data_views/public';
import { KibanaContextProvider } from '../../../../../../kibana_react/public';
import { stubDataView } from '../../../../../../data_views/common/data_view.stub';

jest.mock('../../../../kibana_services', () => ({
getUiActions: jest.fn(() => {
Expand Down Expand Up @@ -46,7 +46,7 @@ function getComponent({
});

const props = {
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field: finalField,
getDetails: jest.fn(() => ({ buckets: [], error: '', exists: 1, total: 2, columns: [] })),
onAddFilter: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import classNames from 'classnames';
import { FieldButton, FieldIcon } from '@kbn/react-field';
import { DiscoverFieldDetails } from './discover_field_details';
import { FieldDetails } from './types';
import { DataViewField, DataView } from '../../../../../../data/common';
import type { DataViewField, DataView } from '../../../../../../data_views/public';
import { getFieldTypeName } from './lib/get_field_type_name';
import { DiscoverFieldVisualize } from './discover_field_visualize';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EuiText, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@e
import { i18n } from '@kbn/i18n';
import { StringFieldProgressBar } from './string_progress_bar';
import { Bucket } from './types';
import { DataViewField } from '../../../../../../data/common';
import { DataViewField } from '../../../../../../data_views/public';
import './discover_field_bucket.scss';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test-jest-helpers';

import { DiscoverFieldDetails } from './discover_field_details';
import { DataViewField } from '../../../../../../data/common';
import { stubIndexPattern } from '../../../../../../data/common/stubs';
import { DataViewField } from '../../../../../../data_views/public';
import { stubDataView } from '../../../../../../data_views/common/data_view.stub';

describe('discover sidebar field details', function () {
const onAddFilter = jest.fn();
const defaultProps = {
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
details: { buckets: [], error: '', exists: 1, total: 2, columns: [] },
onAddFilter,
};
Expand Down
Loading