Move constants into @kbn/discover-utils (#162360)

## Summary

Moves constants from the Discover plugin into the `@kbn/discover-utils`
package.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Lukas Olson 2023-07-26 14:11:30 -07:00 committed by GitHub
parent 028457b219
commit 6440075a8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 142 additions and 115 deletions

View file

@ -7,6 +7,27 @@
*/
export {
CONTEXT_DEFAULT_SIZE_SETTING,
CONTEXT_STEP_SETTING,
CONTEXT_TIE_BREAKER_FIELDS_SETTING,
DEFAULT_COLUMNS_SETTING,
DOC_HIDE_TIME_COLUMN_SETTING,
DOC_TABLE_LEGACY,
ENABLE_SQL,
FIELDS_LIMIT_SETTING,
HIDE_ANNOUNCEMENTS,
MAX_DOC_FIELDS_DISPLAYED,
MODIFY_COLUMNS_ON_SWITCH,
ROW_HEIGHT_OPTION,
SAMPLE_ROWS_PER_PAGE_SETTING,
SAMPLE_SIZE_SETTING,
SEARCH_EMBEDDABLE_TYPE,
SEARCH_FIELDS_FROM_SOURCE,
SEARCH_ON_PAGE_LOAD_SETTING,
SHOW_FIELD_STATISTICS,
SHOW_MULTIFIELDS,
SORT_DEFAULT_ORDER_SETTING,
TRUNCATE_MAX_HEIGHT,
IgnoredReason,
buildDataTableRecord,
buildDataTableRecordList,

View file

@ -2,5 +2,6 @@
"name": "@kbn/discover-utils",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
"license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": false
}

View file

@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export const CONTEXT_DEFAULT_SIZE_SETTING = 'context:defaultSize';
export const CONTEXT_STEP_SETTING = 'context:step';
export const CONTEXT_TIE_BREAKER_FIELDS_SETTING = 'context:tieBreakerFields';
export const DEFAULT_COLUMNS_SETTING = 'defaultColumns';
export const DOC_HIDE_TIME_COLUMN_SETTING = 'doc_table:hideTimeColumn';
export const DOC_TABLE_LEGACY = 'doc_table:legacy';
export const ENABLE_SQL = 'discover:enableSql';
export const FIELDS_LIMIT_SETTING = 'fields:popularLimit';
export const HIDE_ANNOUNCEMENTS = 'hideAnnouncements';
export const MAX_DOC_FIELDS_DISPLAYED = 'discover:maxDocFieldsDisplayed';
export const MODIFY_COLUMNS_ON_SWITCH = 'discover:modifyColumnsOnSwitch';
export const ROW_HEIGHT_OPTION = 'discover:rowHeightOption';
export const SAMPLE_ROWS_PER_PAGE_SETTING = 'discover:sampleRowsPerPage';
export const SAMPLE_SIZE_SETTING = 'discover:sampleSize';
export const SEARCH_EMBEDDABLE_TYPE = 'search';
export const SEARCH_FIELDS_FROM_SOURCE = 'discover:searchFieldsFromSource';
export const SEARCH_ON_PAGE_LOAD_SETTING = 'discover:searchOnPageLoad';
export const SHOW_FIELD_STATISTICS = 'discover:showFieldStatistics';
export const SHOW_MULTIFIELDS = 'discover:showMultiFields';
export const SORT_DEFAULT_ORDER_SETTING = 'discover:sort:defaultOrder';
export const TRUNCATE_MAX_HEIGHT = 'truncate:maxHeight';

View file

@ -6,5 +6,6 @@
* Side Public License, v 1.
*/
export * from './constants';
export * from './hooks';
export * from './utils';

View file

@ -12,6 +12,7 @@ import { i18n } from '@kbn/i18n';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiPageSidebar } from '@elastic/eui';
import { type DataViewField } from '@kbn/data-views-plugin/public';
import { getDataViewFieldSubtypeMulti } from '@kbn/es-query/src/utils';
import { FIELDS_LIMIT_SETTING, SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils';
import { FieldList } from '../../components/field_list';
import { FieldListFilters } from '../../components/field_list_filters';
import { FieldListGrouped, type FieldListGroupedProps } from '../../components/field_list_grouped';
@ -25,9 +26,6 @@ import {
INITIAL_SELECTED_FIELDS_RESULT,
} from './group_fields';
const FIELDS_LIMIT_SETTING = 'fields:popularLimit';
const SEARCH_FIELDS_FROM_SOURCE = 'discover:searchFieldsFromSource';
export type UnifiedFieldListSidebarCustomizableProps = Pick<
UnifiedFieldListItemProps,
| 'services'

View file

@ -27,6 +27,7 @@
"@kbn/data-view-field-editor-plugin",
"@kbn/dom-drag-drop",
"@kbn/shared-ux-utility",
"@kbn/discover-utils",
],
"exclude": ["target/**/*"]
}

View file

@ -8,27 +8,6 @@
export const PLUGIN_ID = 'discover';
export const APP_ICON = 'discoverApp';
export const DEFAULT_COLUMNS_SETTING = 'defaultColumns';
export const SAMPLE_SIZE_SETTING = 'discover:sampleSize';
export const SAMPLE_ROWS_PER_PAGE_SETTING = 'discover:sampleRowsPerPage';
export const SORT_DEFAULT_ORDER_SETTING = 'discover:sort:defaultOrder';
export const SEARCH_ON_PAGE_LOAD_SETTING = 'discover:searchOnPageLoad';
export const DOC_HIDE_TIME_COLUMN_SETTING = 'doc_table:hideTimeColumn';
export const FIELDS_LIMIT_SETTING = 'fields:popularLimit';
export const CONTEXT_DEFAULT_SIZE_SETTING = 'context:defaultSize';
export const CONTEXT_STEP_SETTING = 'context:step';
export const CONTEXT_TIE_BREAKER_FIELDS_SETTING = 'context:tieBreakerFields';
export const DOC_TABLE_LEGACY = 'doc_table:legacy';
export const MODIFY_COLUMNS_ON_SWITCH = 'discover:modifyColumnsOnSwitch';
export const SEARCH_FIELDS_FROM_SOURCE = 'discover:searchFieldsFromSource';
export const MAX_DOC_FIELDS_DISPLAYED = 'discover:maxDocFieldsDisplayed';
export const SHOW_FIELD_STATISTICS = 'discover:showFieldStatistics';
export const SHOW_MULTIFIELDS = 'discover:showMultiFields';
export const TRUNCATE_MAX_HEIGHT = 'truncate:maxHeight';
export const ROW_HEIGHT_OPTION = 'discover:rowHeightOption';
export const SEARCH_EMBEDDABLE_TYPE = 'search';
export const HIDE_ANNOUNCEMENTS = 'hideAnnouncements';
export const ENABLE_SQL = 'discover:enableSql';
export { DISCOVER_APP_LOCATOR, DiscoverAppLocatorDefinition } from './locator';
export type { DiscoverAppLocator, DiscoverAppLocatorParams } from './locator';

View file

@ -20,7 +20,7 @@ import {
SAMPLE_SIZE_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SHOW_MULTIFIELDS,
} from '../../../common';
} from '@kbn/discover-utils';
import { SIDEBAR_CLOSED_KEY } from '../../application/main/components/layout/discover_layout';
import { LocalStorageMock } from '../local_storage_mock';
import { DiscoverServices } from '../../build_services';

View file

@ -7,7 +7,7 @@
*/
import { IUiSettingsClient } from '@kbn/core/public';
import { SORT_DEFAULT_ORDER_SETTING } from '../../common';
import { SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
export const configMock = {
get: (key: string) => {

View file

@ -22,7 +22,7 @@ import {
SORT_DEFAULT_ORDER_SETTING,
HIDE_ANNOUNCEMENTS,
SEARCH_ON_PAGE_LOAD_SETTING,
} from '../../common';
} from '@kbn/discover-utils';
import {
UI_SETTINGS,
calculateBounds,

View file

@ -16,7 +16,7 @@ import {
SHOW_MULTIFIELDS,
SEARCH_FIELDS_FROM_SOURCE,
ROW_HEIGHT_OPTION,
} from '../../common';
} from '@kbn/discover-utils';
export const uiSettingsMock = {
get: (key: string) => {

View file

@ -17,7 +17,7 @@ import { useExecutionContext } from '@kbn/kibana-react-plugin/public';
import { generateFilters } from '@kbn/data-plugin/public';
import { i18n } from '@kbn/i18n';
import { reportPerformanceMetricEvent } from '@kbn/ebt-tools';
import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '../../../common';
import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils';
import { ContextErrorMessage } from './components/context_error_message';
import { LoadingStatus } from './services/context_query_state';
import { AppState, GlobalState, isEqualFilters } from './services/context_state';

View file

@ -14,7 +14,7 @@ import { SortDirection } from '@kbn/data-plugin/public';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { CellActionsProvider } from '@kbn/cell-actions';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '../../../common';
import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils';
import { LoadingStatus } from './services/context_query_state';
import { ActionBar } from './components/action_bar/action_bar';
import { DiscoverGrid } from '../../components/discover_grid/discover_grid';

View file

@ -9,7 +9,7 @@
import React from 'react';
import { act, renderHook } from '@testing-library/react-hooks';
import { createFilterManagerMock } from '@kbn/data-plugin/public/query/filter_manager/filter_manager.mock';
import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../common';
import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '@kbn/discover-utils';
import { DiscoverServices } from '../../../build_services';
import { FailureReason, LoadingStatus } from '../services/context_query_state';
import { ContextAppFetchProps, useContextAppFetch } from './use_context_app_fetch';

View file

@ -11,7 +11,7 @@ import { MarkdownSimple, toMountPoint, wrapWithTheme } from '@kbn/kibana-react-p
import type { DataView } from '@kbn/data-views-plugin/public';
import { SortDirection } from '@kbn/data-plugin/public';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../common';
import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '@kbn/discover-utils';
import { fetchAnchor } from '../services/anchor';
import { fetchSurroundingDocs, SurrDocType } from '../services/context';
import {

View file

@ -8,7 +8,7 @@
import { DataView } from '@kbn/data-views-plugin/common';
import { useEffect, useMemo, useState } from 'react';
import { CONTEXT_DEFAULT_SIZE_SETTING } from '../../../../common';
import { CONTEXT_DEFAULT_SIZE_SETTING } from '@kbn/discover-utils';
import { DiscoverServices } from '../../../build_services';
import { AppState, getState, GlobalState } from '../services/context_state';

View file

@ -12,7 +12,7 @@ import { getState } from './context_state';
import { createBrowserHistory, History } from 'history';
import { FilterManager } from '@kbn/data-plugin/public';
import { coreMock } from '@kbn/core/public/mocks';
import { SEARCH_FIELDS_FROM_SOURCE } from '../../../../common';
import { SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils';
import { discoverServiceMock } from '../../../__mocks__/services';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';

View file

@ -13,7 +13,7 @@ import { mountWithIntl } from '@kbn/test-jest-helpers';
import { ReactWrapper } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
import { Doc, DocProps } from './doc';
import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource } from '../../../../common';
import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource } from '@kbn/discover-utils';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';

View file

@ -21,8 +21,8 @@ import {
} from '@elastic/eui';
import { css } from '@emotion/react';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { DOC_TABLE_LEGACY } from '@kbn/discover-utils';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { DOC_TABLE_LEGACY } from '../../../../../common';
export const CALLOUT_STATE_KEY = 'discover:docExplorerCalloutClosed';

View file

@ -20,19 +20,19 @@ import { DataView } from '@kbn/data-views-plugin/public';
import { SortOrder } from '@kbn/saved-search-plugin/public';
import { CellActionsProvider } from '@kbn/cell-actions';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { useInternalStateSelector } from '../../services/discover_internal_state_container';
import { useAppStateSelector } from '../../services/discover_app_state_container';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types';
import { DiscoverGrid } from '../../../../components/discover_grid/discover_grid';
import { FetchStatus } from '../../../types';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
DOC_TABLE_LEGACY,
SAMPLE_SIZE_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
HIDE_ANNOUNCEMENTS,
} from '../../../../../common';
} from '@kbn/discover-utils';
import { useInternalStateSelector } from '../../services/discover_internal_state_container';
import { useAppStateSelector } from '../../services/discover_app_state_container';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types';
import { DiscoverGrid } from '../../../../components/discover_grid/discover_grid';
import { FetchStatus } from '../../../types';
import { useColumns } from '../../../../hooks/use_data_grid_columns';
import { RecordRawType } from '../../services/discover_data_state_container';
import { DiscoverStateContainer } from '../../services/discover_state';

View file

@ -23,6 +23,7 @@ import classNames from 'classnames';
import { generateFilters } from '@kbn/data-plugin/public';
import { useDragDropContext } from '@kbn/dom-drag-drop';
import { DataViewField, DataViewType } from '@kbn/data-views-plugin/public';
import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '@kbn/discover-utils';
import { useSavedSearchInitial } from '../../services/discover_state_provider';
import { DiscoverStateContainer } from '../../services/discover_state';
import { VIEW_MODE } from '../../../../../common/constants';
@ -33,7 +34,6 @@ import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { DiscoverNoResults } from '../no_results';
import { LoadingSpinner } from '../loading_spinner/loading_spinner';
import { DiscoverSidebarResponsive } from '../sidebar';
import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '../../../../../common';
import { popularizeField } from '../../../../utils/popularize_field';
import { DiscoverTopNav } from '../top_nav/discover_topnav';
import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types';

View file

@ -9,9 +9,9 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import type { Query, TimeRange, AggregateQuery } from '@kbn/es-query';
import { DataViewType, type DataView } from '@kbn/data-views-plugin/public';
import type { DataViewPickerProps } from '@kbn/unified-search-plugin/public';
import { ENABLE_SQL } from '@kbn/discover-utils';
import { useSavedSearchInitial } from '../../services/discover_state_provider';
import { useInternalStateSelector } from '../../services/discover_internal_state_container';
import { ENABLE_SQL } from '../../../../../common';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { getTopNavLinks } from './get_top_nav_links';
import { getHeaderActionMenuMounter } from '../../../../kibana_services';

View file

@ -12,9 +12,9 @@ import { EuiFormRow, EuiSwitch } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { SavedObjectSaveModal, showSaveModal, OnSaveProps } from '@kbn/saved-objects-plugin/public';
import { SavedSearch, SaveSavedSearchOptions } from '@kbn/saved-search-plugin/public';
import { DOC_TABLE_LEGACY } from '@kbn/discover-utils';
import { DiscoverServices } from '../../../../build_services';
import { DiscoverStateContainer } from '../../services/discover_state';
import { DOC_TABLE_LEGACY } from '../../../../../common';
async function saveDataSource({
savedSearch,

View file

@ -8,12 +8,12 @@
import { SortOrder } from '@kbn/saved-search-plugin/public';
import { DataView } from '@kbn/data-views-plugin/common';
import { MODIFY_COLUMNS_ON_SWITCH, SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
import { DiscoverInternalStateContainer } from '../../services/discover_internal_state_container';
import { DiscoverAppStateContainer } from '../../services/discover_app_state_container';
import { addLog } from '../../../../utils/add_log';
import { DiscoverServices } from '../../../../build_services';
import { getDataViewAppState } from '../../utils/get_switch_data_view_app_state';
import { MODIFY_COLUMNS_ON_SWITCH, SORT_DEFAULT_ORDER_SETTING } from '../../../../../common';
/**
* Function executed when switching data view in the UI

View file

@ -15,13 +15,13 @@ import type { SearchResponse } from '@elastic/elasticsearch/lib/api/types';
import { DataView } from '@kbn/data-views-plugin/common';
import { reportPerformanceMetricEvent } from '@kbn/ebt-tools';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { SEARCH_FIELDS_FROM_SOURCE, SEARCH_ON_PAGE_LOAD_SETTING } from '@kbn/discover-utils';
import { getDataViewByTextBasedQueryLang } from '../utils/get_data_view_by_text_based_query_lang';
import { isTextBasedQuery } from '../utils/is_text_based_query';
import { getRawRecordType } from '../utils/get_raw_record_type';
import { DiscoverAppState } from './discover_app_state_container';
import { DiscoverServices } from '../../../build_services';
import { DiscoverSearchSessionManager } from './discover_search_session';
import { SEARCH_FIELDS_FROM_SOURCE, SEARCH_ON_PAGE_LOAD_SETTING } from '../../../../common';
import { FetchStatus } from '../../types';
import { validateTimeRange } from '../utils/validate_time_range';
import { fetchAll } from '../utils/fetch_all';

View file

@ -9,10 +9,9 @@ import { i18n } from '@kbn/i18n';
import { filter, map } from 'rxjs/operators';
import { lastValueFrom } from 'rxjs';
import { isCompleteResponse, ISearchSource } from '@kbn/data-plugin/public';
import { buildDataTableRecordList } from '@kbn/discover-utils';
import { SAMPLE_SIZE_SETTING, buildDataTableRecordList } from '@kbn/discover-utils';
import type { EsHitRecord } from '@kbn/discover-utils/types';
import type { RecordsFetchResponse } from '../../../types';
import { SAMPLE_SIZE_SETTING } from '../../../../common';
import { FetchDeps } from './fetch_all';
/**

View file

@ -10,15 +10,15 @@ import { cloneDeep, isEqual } from 'lodash';
import { IUiSettingsClient } from '@kbn/core/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { getChartHidden } from '@kbn/unified-histogram-plugin/public';
import { DiscoverAppState } from '../services/discover_app_state_container';
import { DiscoverServices } from '../../../build_services';
import { getDefaultSort, getSortArray } from '../../../utils/sorting';
import {
DEFAULT_COLUMNS_SETTING,
DOC_HIDE_TIME_COLUMN_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
} from '../../../../common';
} from '@kbn/discover-utils';
import { DiscoverAppState } from '../services/discover_app_state_container';
import { DiscoverServices } from '../../../build_services';
import { getDefaultSort, getSortArray } from '../../../utils/sorting';
import { isTextBasedQuery } from './is_text_based_query';
import { getValidViewMode } from './get_valid_view_mode';

View file

@ -9,7 +9,7 @@
import { ISearchSource } from '@kbn/data-plugin/public';
import { DataViewType, DataView } from '@kbn/data-views-plugin/public';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { SEARCH_FIELDS_FROM_SOURCE, SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
import { SEARCH_FIELDS_FROM_SOURCE, SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
import { DiscoverServices } from '../../../build_services';
import { getSortForSearchSource } from '../../../utils/sorting';

View file

@ -37,6 +37,11 @@ import { DataViewFieldEditorStart } from '@kbn/data-view-field-editor-plugin/pub
import { Serializable } from '@kbn/utility-types';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { getShouldShowFieldHandler } from '@kbn/discover-utils';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
MAX_DOC_FIELDS_DISPLAYED,
SHOW_MULTIFIELDS,
} from '@kbn/discover-utils';
import { DocViewFilterFn } from '../../services/doc_views/doc_views_types';
import { getSchemaDetectors } from './discover_grid_schema';
import { DiscoverGridFlyout } from './discover_grid_flyout';
@ -50,11 +55,6 @@ import {
} from './discover_grid_columns';
import { GRID_STYLE, toolbarVisibility as toolbarVisibilityDefaults } from './constants';
import { getDisplayedColumns } from '../../utils/columns';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
MAX_DOC_FIELDS_DISPLAYED,
SHOW_MULTIFIELDS,
} from '../../../common';
import { DiscoverGridDocumentToolbarBtn } from './discover_grid_document_selection';
import type { ValueToStringConverter } from '../../types';
import { useRowHeightsOptions } from '../../hooks/use_row_heights_options';

View file

@ -26,12 +26,11 @@ import type {
EsHitRecord,
ShouldShowFieldInTableHandler,
} from '@kbn/discover-utils/types';
import { formatFieldValue, formatHit } from '@kbn/discover-utils';
import { MAX_DOC_FIELDS_DISPLAYED, formatFieldValue, formatHit } from '@kbn/discover-utils';
import { DiscoverGridContext } from './discover_grid_context';
import { JsonCodeEditor } from '../json_code_editor/json_code_editor';
import { defaultMonacoEditorWidth } from './constants';
import { useDiscoverServices } from '../../hooks/use_discover_services';
import { MAX_DOC_FIELDS_DISPLAYED } from '../../../common';
const CELL_CLASS = 'dscDiscoverGrid__cellValue';

View file

@ -8,8 +8,8 @@
import { Capabilities, IUiSettingsClient } from '@kbn/core/public';
import { DataViewsContract } from '@kbn/data-plugin/public';
import { DataView } from '@kbn/data-views-plugin/public';
import { SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
import { DiscoverAppStateContainer } from '../../../application/main/services/discover_app_state_container';
import { SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
import { GetStateReturn as ContextGetStateReturn } from '../../../application/context/services/context_state';
import { popularizeField } from '../../../utils/popularize_field';

View file

@ -13,7 +13,7 @@ import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { TableHeader } from './table_header';
import { findTestSubject } from '@elastic/eui/lib/test';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { DOC_HIDE_TIME_COLUMN_SETTING } from '../../../../../common';
import { DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils';
import { FORMATS_UI_SETTINGS } from '@kbn/field-formats-plugin/common';
const defaultUiSettings = {

View file

@ -10,11 +10,11 @@ import React, { useMemo } from 'react';
import type { DataView } from '@kbn/data-views-plugin/public';
import { FORMATS_UI_SETTINGS } from '@kbn/field-formats-plugin/common';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
import { TableHeaderColumn } from './table_header_column';
import { getDisplayedColumns } from './helpers';
import { getDefaultSort } from '../../../../utils/sorting';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../../../common';
interface Props {
columns: string[];

View file

@ -17,7 +17,7 @@ import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { discoverServiceMock } from '../../../__mocks__/services';
import { DocViewer } from '../../../services/doc_views/components/doc_viewer';
import { DOC_HIDE_TIME_COLUMN_SETTING, MAX_DOC_FIELDS_DISPLAYED } from '../../../../common';
import { DOC_HIDE_TIME_COLUMN_SETTING, MAX_DOC_FIELDS_DISPLAYED } from '@kbn/discover-utils';
import { buildDataTableRecord } from '@kbn/discover-utils';
import type { EsHitRecord } from '@kbn/discover-utils/types';

View file

@ -18,13 +18,13 @@ import type {
ShouldShowFieldInTableHandler,
} from '@kbn/discover-utils/types';
import { formatFieldValue } from '@kbn/discover-utils';
import { DOC_HIDE_TIME_COLUMN_SETTING, MAX_DOC_FIELDS_DISPLAYED } from '@kbn/discover-utils';
import { DocViewRenderProps } from '../../../services/doc_views/doc_views_types';
import { TableCell } from './table_row/table_cell';
import { formatRow, formatTopLevelObject } from '../utils/row_formatter';
import { DocViewFilterFn } from '../../../services/doc_views/doc_views_types';
import { TableRowDetails } from './table_row_details';
import { useDiscoverServices } from '../../../hooks/use_discover_services';
import { DOC_HIDE_TIME_COLUMN_SETTING, MAX_DOC_FIELDS_DISPLAYED } from '../../../../common';
export type DocTableRow = EsHitRecord & {
isAnchor?: boolean;

View file

@ -10,8 +10,7 @@ import React, { memo, useCallback, useMemo, useRef } from 'react';
import './index.scss';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiText } from '@elastic/eui';
import { usePager } from '@kbn/discover-utils';
import { SAMPLE_SIZE_SETTING } from '../../../common';
import { SAMPLE_SIZE_SETTING, usePager } from '@kbn/discover-utils';
import {
ToolBarPagination,
MAX_ROWS_PER_PAGE_OPTION,

View file

@ -11,7 +11,7 @@ import './index.scss';
import { FormattedMessage } from '@kbn/i18n-react';
import { debounce } from 'lodash';
import { EuiButtonEmpty } from '@elastic/eui';
import { SAMPLE_SIZE_SETTING } from '../../../common';
import { SAMPLE_SIZE_SETTING } from '@kbn/discover-utils';
import { DocTableProps, DocTableRenderProps, DocTableWrapper } from './doc_table_wrapper';
import { SkipBottomButton } from '../../application/main/components/skip_bottom_button';
import { shouldLoadNextDocPatch } from './utils/should_load_next_doc_patch';

View file

@ -13,9 +13,8 @@ import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { Filter } from '@kbn/es-query';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { getShouldShowFieldHandler } from '@kbn/discover-utils';
import { SHOW_MULTIFIELDS, getShouldShowFieldHandler } from '@kbn/discover-utils';
import { TableHeader } from './components/table_header/table_header';
import { SHOW_MULTIFIELDS } from '../../../common';
import { TableRow } from './components/table_row';
import { DocViewFilterFn, DocViewRenderProps } from '../../services/doc_views/doc_views_types';
import { useDiscoverServices } from '../../hooks/use_discover_services';

View file

@ -11,8 +11,8 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import { euiThemeVars } from '@kbn/ui-theme';
import { SHOW_FIELD_STATISTICS } from '@kbn/discover-utils';
import { VIEW_MODE } from '../../../common/constants';
import { SHOW_FIELD_STATISTICS } from '../../../common';
import { useDiscoverServices } from '../../hooks/use_discover_services';
export const DocumentViewModeToggle = ({

View file

@ -8,7 +8,7 @@
import type { Trigger } from '@kbn/ui-actions-plugin/public';
export { SEARCH_EMBEDDABLE_TYPE } from '../../common';
export { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils';
export const SEARCH_EMBEDDABLE_CELL_ACTIONS_TRIGGER_ID =
'SEARCH_EMBEDDABLE_CELL_ACTIONS_TRIGGER_ID';

View file

@ -18,7 +18,7 @@ import { render } from 'react-dom';
import { createSearchSourceMock } from '@kbn/data-plugin/public/mocks';
import { Observable, of, throwError } from 'rxjs';
import { ReactWrapper } from 'enzyme';
import { SHOW_FIELD_STATISTICS } from '../../common';
import { SHOW_FIELD_STATISTICS } from '@kbn/discover-utils';
import { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { SavedSearchEmbeddableComponent } from './saved_search_embeddable_component';
import { VIEW_MODE } from '../../common/constants';

View file

@ -36,14 +36,7 @@ import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-pl
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { METRIC_TYPE } from '@kbn/analytics';
import { CellActionsProvider } from '@kbn/cell-actions';
import { buildDataTableRecord } from '@kbn/discover-utils';
import type { DataTableRecord, EsHitRecord } from '@kbn/discover-utils/types';
import { VIEW_MODE } from '../../common/constants';
import { getSortForEmbeddable, SortPair } from '../utils/sorting';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
import { SEARCH_EMBEDDABLE_TYPE, SEARCH_EMBEDDABLE_CELL_ACTIONS_TRIGGER_ID } from './constants';
import { DiscoverServices } from '../build_services';
import { SavedSearchEmbeddableComponent } from './saved_search_embeddable_component';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
DOC_TABLE_LEGACY,
@ -51,7 +44,14 @@ import {
SEARCH_FIELDS_FROM_SOURCE,
SHOW_FIELD_STATISTICS,
SORT_DEFAULT_ORDER_SETTING,
} from '../../common';
buildDataTableRecord,
} from '@kbn/discover-utils';
import { VIEW_MODE } from '../../common/constants';
import { getSortForEmbeddable, SortPair } from '../utils/sorting';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
import { SEARCH_EMBEDDABLE_TYPE, SEARCH_EMBEDDABLE_CELL_ACTIONS_TRIGGER_ID } from './constants';
import { DiscoverServices } from '../build_services';
import { SavedSearchEmbeddableComponent } from './saved_search_embeddable_component';
import * as columnActions from '../components/doc_table/actions/columns';
import { handleSourceColumnState } from '../utils/state_helpers';
import { DiscoverGridProps } from '../components/discover_grid/discover_grid';

View file

@ -11,8 +11,8 @@ import { i18n } from '@kbn/i18n';
import { IEmbeddable, ViewMode } from '@kbn/embeddable-plugin/public';
import { Action } from '@kbn/ui-actions-plugin/public';
import { getSavedSearchUrl } from '@kbn/saved-search-plugin/public';
import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils';
import { SavedSearchEmbeddable } from './saved_search_embeddable';
import { SEARCH_EMBEDDABLE_TYPE } from '../../common';
export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH';

View file

@ -12,10 +12,12 @@ import { Subject } from 'rxjs';
import { DataView } from '@kbn/data-views-plugin/public';
import { DocProps } from '../application/doc/components/doc';
import { ElasticRequestState } from '../application/doc/types';
import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource } from '../../common';
import {
SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource,
buildDataTableRecord,
} from '@kbn/discover-utils';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import React from 'react';
import { buildDataTableRecord } from '@kbn/discover-utils';
const index = 'test-index';
const mockSearchResult = new Subject();

View file

@ -11,11 +11,10 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { lastValueFrom } from 'rxjs';
import { DataView } from '@kbn/data-views-plugin/public';
import { reportPerformanceMetricEvent } from '@kbn/ebt-tools';
import { buildDataTableRecord } from '@kbn/discover-utils';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { SEARCH_FIELDS_FROM_SOURCE, buildDataTableRecord } from '@kbn/discover-utils';
import { DocProps } from '../application/doc/components/doc';
import { ElasticRequestState } from '../application/doc/types';
import { SEARCH_FIELDS_FROM_SOURCE } from '../../common';
import { useDiscoverServices } from './use_discover_services';
type RequestBody = Pick<estypes.SearchRequest, 'body'>;

View file

@ -8,7 +8,7 @@
import type { EuiDataGridRowHeightOption, EuiDataGridRowHeightsOptions } from '@elastic/eui';
import { useMemo } from 'react';
import { ROW_HEIGHT_OPTION } from '../../common';
import { ROW_HEIGHT_OPTION } from '@kbn/discover-utils';
import { isValidRowHeight } from '../utils/validate_row_height';
import { useDiscoverServices } from './use_discover_services';
import {

View file

@ -43,6 +43,7 @@ import type { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/publ
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public';
import type { LensPublicStart } from '@kbn/lens-plugin/public';
import { DOC_TABLE_LEGACY, TRUNCATE_MAX_HEIGHT } from '@kbn/discover-utils';
import { PLUGIN_ID } from '../common';
import { DocViewInput, DocViewInputFn } from './services/doc_views/doc_views_types';
import { DocViewsRegistry } from './services/doc_views/doc_views_registry';
@ -60,7 +61,6 @@ import { SearchEmbeddableFactory } from './embeddable';
import { DeferredSpinner } from './components';
import { ViewSavedSearchAction } from './embeddable/view_saved_search_action';
import { injectTruncateStyles } from './utils/truncate_styles';
import { DOC_TABLE_LEGACY, TRUNCATE_MAX_HEIGHT } from '../common';
import { useDiscoverServices } from './hooks/use_discover_services';
import { initializeKbnUrlTracking } from './utils/initialize_kbn_url_tracking';
import {

View file

@ -14,9 +14,9 @@ import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner, EuiSpacer, EuiText } from
import { i18n } from '@kbn/i18n';
import { DataView } from '@kbn/data-views-plugin/public';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { JSONCodeEditorCommonMemoized } from '../../../../components/json_code_editor/json_code_editor_common';
import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '../../../../../common';
import { useEsDocSearch } from '../../../../hooks/use_es_doc_search';
import { ElasticRequestState } from '../../../../application/doc/types';
import { getHeight } from './get_height';

View file

@ -11,13 +11,13 @@ import React, { useCallback, useMemo } from 'react';
import { EuiInMemoryTable } from '@elastic/eui';
import { getFieldIconType } from '@kbn/unified-field-list/src/utils/field_types/get_field_icon_type';
import {
SHOW_MULTIFIELDS,
formatFieldValue,
getIgnoredReason,
getShouldShowFieldHandler,
isNestedFieldParent,
} from '@kbn/discover-utils';
import { useDiscoverServices } from '../../../../../hooks/use_discover_services';
import { SHOW_MULTIFIELDS } from '../../../../../../common';
import { DocViewRenderProps, FieldRecordLegacy } from '../../../doc_views_types';
import { ACTIONS_COLUMN, MAIN_COLUMNS } from './table_columns';

View file

@ -31,6 +31,7 @@ import { debounce } from 'lodash';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { getFieldIconType } from '@kbn/unified-field-list/src/utils/field_types/get_field_icon_type';
import {
SHOW_MULTIFIELDS,
formatFieldValue,
getIgnoredReason,
getShouldShowFieldHandler,
@ -39,7 +40,6 @@ import {
} from '@kbn/discover-utils';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { FieldName } from '../../../../components/field_name/field_name';
import { SHOW_MULTIFIELDS } from '../../../../../common';
import { DocViewRenderProps, FieldRecordLegacy } from '../../doc_views_types';
import { TableFieldValue } from './table_cell_value';
import { TableActions } from './table_cell_actions';

View file

@ -15,7 +15,7 @@ import {
DOC_HIDE_TIME_COLUMN_SETTING,
SORT_DEFAULT_ORDER_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
} from '../../common';
} from '@kbn/discover-utils';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { getSharingData, showPublicUrlSwitch } from './get_sharing_data';

View file

@ -15,16 +15,16 @@ import type {
} from '@kbn/data-plugin/public';
import type { Filter } from '@kbn/es-query';
import type { SavedSearch, SortOrder } from '@kbn/saved-search-plugin/public';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
} from '@kbn/discover-utils';
import {
DiscoverAppState,
isEqualFilters,
} from '../application/main/services/discover_app_state_container';
import { getSortForSearchSource } from './sorting';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
} from '../../common';
/**
* Preparing data to share the current state as link or CSV/Report

View file

@ -7,7 +7,7 @@
*/
import { discoverServiceMock } from '../__mocks__/services';
import { SAMPLE_ROWS_PER_PAGE_SETTING } from '../../common';
import { SAMPLE_ROWS_PER_PAGE_SETTING } from '@kbn/discover-utils';
import { getRowsPerPageOptions, getDefaultRowsPerPage } from './rows_per_page';
const SORTED_OPTIONS = [10, 25, 50, 100, 250, 500];

View file

@ -7,8 +7,8 @@
*/
import { sortBy, uniq } from 'lodash';
import { SAMPLE_ROWS_PER_PAGE_SETTING } from '@kbn/discover-utils';
import { DEFAULT_ROWS_PER_PAGE, ROWS_PER_PAGE_OPTIONS } from '../../common/constants';
import { SAMPLE_ROWS_PER_PAGE_SETTING } from '../../common';
import { DiscoverServices } from '../build_services';
export const getRowsPerPageOptions = (currentRowsPerPage?: number): number[] => {

View file

@ -9,7 +9,7 @@
import { DataView } from '@kbn/data-views-plugin/common';
import { IUiSettingsClient } from '@kbn/core/public';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../common';
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
import { getDefaultSort, getSortArray, SortInput } from '../../../common/utils/sorting';
/**

View file

@ -8,7 +8,7 @@
import { IUiSettingsClient } from '@kbn/core/public';
import { isEqual } from 'lodash';
import { SEARCH_FIELDS_FROM_SOURCE, DEFAULT_COLUMNS_SETTING } from '../../common';
import { SEARCH_FIELDS_FROM_SOURCE, DEFAULT_COLUMNS_SETTING } from '@kbn/discover-utils';
/**
* Makes sure the current state is not referencing the source column when using the fields api

View file

@ -15,7 +15,8 @@ import { DataView } from '@kbn/data-views-plugin/common';
import { createStubDataView } from '@kbn/data-views-plugin/common/stubs';
import { SavedSearchAttributes } from '@kbn/saved-search-plugin/common';
import { LocatorServicesDeps as Services } from '.';
import { DiscoverAppLocatorParams, DOC_HIDE_TIME_COLUMN_SETTING } from '../../common';
import { DiscoverAppLocatorParams } from '../../common';
import { DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils';
import { columnsFromLocatorFactory } from './columns_from_locator';
const mockSavedSearchId = 'abc-test-123';

View file

@ -9,12 +9,9 @@
import { DataView } from '@kbn/data-views-plugin/common';
import { SavedSearch } from '@kbn/saved-search-plugin/common';
import { getSavedSearch } from '@kbn/saved-search-plugin/server';
import { DOC_HIDE_TIME_COLUMN_SETTING, SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils';
import { LocatorServicesDeps } from '.';
import {
DiscoverAppLocatorParams,
DOC_HIDE_TIME_COLUMN_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
} from '../../common';
import { DiscoverAppLocatorParams } from '../../common';
function isStringArray(arr: unknown | string[]): arr is string[] {
return Array.isArray(arr) && arr.every((p) => typeof p === 'string');

View file

@ -15,7 +15,8 @@ import { DataView } from '@kbn/data-views-plugin/common';
import { createStubDataView } from '@kbn/data-views-plugin/common/stubs';
import { SavedSearchAttributes } from '@kbn/saved-search-plugin/common';
import { LocatorServicesDeps as Services } from '.';
import { DiscoverAppLocatorParams, DOC_HIDE_TIME_COLUMN_SETTING } from '../../common';
import { DiscoverAppLocatorParams } from '../../common';
import { DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils';
import { searchSourceFromLocatorFactory } from './searchsource_from_locator';
const mockSavedSearchId = 'abc-test-123';

View file

@ -12,7 +12,8 @@ import { ISearchStartSearchSource } from '@kbn/data-plugin/common';
import { dataPluginMock } from '@kbn/data-plugin/server/mocks';
import { SavedSearchAttributes } from '@kbn/saved-search-plugin/common';
import { LocatorServicesDeps as Services } from '.';
import { DiscoverAppLocatorParams, DOC_HIDE_TIME_COLUMN_SETTING } from '../../common';
import { DiscoverAppLocatorParams } from '../../common';
import { DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils';
import { titleFromLocatorFactory } from './title_from_locator';
const mockSavedSearchId = 'abc-test-123';

View file

@ -31,7 +31,7 @@ import {
SHOW_FIELD_STATISTICS,
ROW_HEIGHT_OPTION,
ENABLE_SQL,
} from '../common';
} from '@kbn/discover-utils';
import { DEFAULT_ROWS_PER_PAGE, ROWS_PER_PAGE_OPTIONS } from '../common/constants';
const technicalPreviewLabel = i18n.translate('discover.advancedSettings.technicalPreviewLabel', {

View file

@ -8,7 +8,7 @@
import { MAP_SAVED_OBJECT_TYPE } from '@kbn/maps-plugin/common';
import { VISUALIZE_EMBEDDABLE_TYPE } from '@kbn/visualizations-plugin/common/constants';
import { LENS_EMBEDDABLE_TYPE } from '@kbn/lens-plugin/common/constants';
import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-plugin/common';
import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils';
export const EmbeddableTypes: {
lens: string;

View file

@ -41,7 +41,6 @@
"savedObjects",
],
"requiredBundles": [
"discover",
"kibanaReact",
"kibanaUtils",
"lens",

View file

@ -81,6 +81,7 @@
"@kbn/saved-objects-finder-plugin",
"@kbn/saved-objects-management-plugin",
"@kbn/core-saved-objects-server",
"@kbn/discover-utils",
],
"exclude": [
"target/**/*",