Skip to content

Commit

Permalink
[Data Plugin]: Remove export * for common code from public/server i…
Browse files Browse the repository at this point in the history
…ndex files (#52821) (#52894)
  • Loading branch information
lukeelmers authored Dec 12, 2019
1 parent a0a749e commit e447134
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 49 deletions.
2 changes: 0 additions & 2 deletions src/plugins/data/common/es_query/es_query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
export { buildEsQuery, EsQueryConfig } from './build_es_query';
export { buildQueryFromFilters } from './from_filters';
export { luceneStringToDsl } from './lucene_string_to_dsl';
export { migrateFilter } from './migrate_filter';
export { decorateQuery } from './decorate_query';
export { filterMatchesIndex } from './filter_matches_index';
export { getEsQueryConfig } from './get_es_query_config';
7 changes: 4 additions & 3 deletions src/plugins/data/common/es_query/filters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import { omit, get } from 'lodash';
import { Filter } from './meta_filter';

export * from './build_filters';
export * from './get_filter_params';
export * from './get_filter_field';

export * from './custom_filter';
export * from './exists_filter';
export * from './geo_bounding_box_filter';
export * from './geo_polygon_filter';
export * from './get_display_value';
export * from './get_filter_field';
export * from './get_filter_params';
export * from './get_index_pattern_from_filter';
export * from './match_all_filter';
export * from './meta_filter';
export * from './missing_filter';
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/common/es_query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
import * as esQuery from './es_query';
import * as esFilters from './filters';
import * as esKuery from './kuery';
import * as utils from './utils';

export { esFilters, esQuery, utils, esKuery };
export { esFilters, esQuery, esKuery };
2 changes: 1 addition & 1 deletion src/plugins/data/common/es_query/kuery/functions/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { get, isUndefined } from 'lodash';
import { getPhraseScript } from '../../filters';
import { getFields } from './utils/get_fields';
import { getTimeZoneFromSettings } from '../../utils/get_time_zone_from_settings';
import { getTimeZoneFromSettings } from '../../utils';
import { getFullFieldNameNode } from './utils/get_full_field_name_node';

import * as ast from '../ast';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/es_query/kuery/functions/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { nodeTypes } from '../node_types';
import * as ast from '../ast';
import { getRangeScript } from '../../filters';
import { getFields } from './utils/get_fields';
import { getTimeZoneFromSettings } from '../../utils/get_time_zone_from_settings';
import { getTimeZoneFromSettings } from '../../utils';
import { getFullFieldNameNode } from './utils/get_full_field_name_node';

export function buildNodeParams(fieldName, params) {
Expand Down
File renamed without changes.
22 changes: 0 additions & 22 deletions src/plugins/data/common/es_query/utils/index.ts

This file was deleted.

68 changes: 62 additions & 6 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,75 @@ export function plugin(initializerContext: PluginInitializerContext) {
return new DataPublicPlugin(initializerContext);
}

export * from '../common';
/**
* Types to be shared externally
* @public
*/
export { IRequestTypesMap, IResponseTypesMap } from './search';
export * from './types';
export {
// field formats
ContentType, // only used in agg_type
FIELD_FORMAT_IDS,
IFieldFormat,
IFieldFormatId,
IFieldFormatType,
// index patterns
IIndexPattern,
IFieldType,
IFieldSubType,
// kbn field types
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
// query
Query,
// timefilter
RefreshInterval,
TimeRange,
} from '../common';

/**
* Static code to be shared externally
* @public
*/
export * from './autocomplete_provider';
export * from './field_formats_provider';
export * from './index_patterns';

export * from './types';

export { IRequestTypesMap, IResponseTypesMap } from './search';
export * from './search';
export * from './query';

export * from './ui';
export {
// es query
esFilters,
esKuery,
esQuery,
// field formats
BoolFormat,
BytesFormat,
ColorFormat,
DateFormat,
DateNanosFormat,
DEFAULT_CONVERTER_COLOR,
DurationFormat,
FieldFormat,
getHighlightRequest, // only used in search source
IpFormat,
NumberFormat,
PercentFormat,
RelativeDateFormat,
SourceFormat,
StaticLookupFormat,
StringFormat,
TEXT_CONTEXT_TYPE, // only used in agg_types
TruncateFormat,
UrlFormat,
// index patterns
isFilterable,
// kbn field types
castEsToKbnFieldTypeName,
getKbnFieldType,
getKbnTypeNames,
} from '../common';

// Export plugin after all other imports
import { DataPublicPlugin } from './plugin';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component } from 'react';
import { mapAndFlattenFilters, esFilters, utils, IIndexPattern } from '../..';
import { mapAndFlattenFilters, esFilters, IIndexPattern } from '../..';
import { FilterLabel } from '../filter_bar';

interface Props {
Expand All @@ -56,7 +56,7 @@ export class ApplyFiltersPopoverContent extends Component<Props, State> {
};
}
private getLabel(filter: esFilters.Filter) {
const valueLabel = utils.getDisplayValueFromFilter(filter, this.props.indexPatterns);
const valueLabel = esFilters.getDisplayValueFromFilter(filter, this.props.indexPatterns);
return <FilterLabel filter={filter} valueLabel={valueLabel} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { Operator } from './lib/filter_operators';
import { PhraseValueInput } from './phrase_value_input';
import { PhrasesValuesInput } from './phrases_values_input';
import { RangeValueInput } from './range_value_input';
import { esFilters, utils, IIndexPattern, IFieldType } from '../../..';
import { esFilters, IIndexPattern, IFieldType } from '../../..';

interface Props {
filter: esFilters.Filter;
Expand Down Expand Up @@ -371,7 +371,7 @@ class FilterEditorUI extends Component<Props, State> {
}

private getIndexPatternFromFilter() {
return utils.getIndexPatternFromFilter(this.props.filter, this.props.indexPatterns);
return esFilters.getIndexPatternFromFilter(this.props.filter, this.props.indexPatterns);
}

private getFieldFromFilter() {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/public/ui/filter_bar/filter_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import React, { Component } from 'react';
import { IUiSettingsClient } from 'src/core/public';
import { FilterEditor } from './filter_editor';
import { FilterView } from './filter_view';
import { esFilters, utils, IIndexPattern } from '../..';
import { esFilters, IIndexPattern } from '../..';

interface Props {
id: string;
Expand Down Expand Up @@ -60,7 +60,7 @@ class FilterItemUI extends Component<Props, State> {
this.props.className
);

const valueLabel = utils.getDisplayValueFromFilter(filter, this.props.indexPatterns);
const valueLabel = esFilters.getDisplayValueFromFilter(filter, this.props.indexPatterns);
const dataTestSubjKey = filter.meta.key ? `filter-key-${filter.meta.key}` : '';
const dataTestSubjValue = filter.meta.value ? `filter-value-${valueLabel}` : '';
const dataTestSubjDisabled = `filter-${
Expand Down
64 changes: 60 additions & 4 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,70 @@ export function plugin(initializerContext: PluginInitializerContext) {
return new DataServerPlugin(initializerContext);
}

export { DataServerPlugin as Plugin };
/**
* Types to be shared externally
* @public
*/
export { IRequestTypesMap, IResponseTypesMap } from './search';
export {
// field formats
FIELD_FORMAT_IDS,
IFieldFormat,
IFieldFormatId,
IFieldFormatType,
// index patterns
IIndexPattern,
IFieldType,
IFieldSubType,
// kbn field types
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
// query
Query,
// timefilter
RefreshInterval,
TimeRange,
} from '../common';

/**
* Static code to be shared externally
* @public
*/
export {
IndexPatternsFetcher,
FieldDescriptor,
shouldReadFieldFromDocValues,
} from './index_patterns';

export * from './search';
export * from '../common';
export {
// es query
esFilters,
esKuery,
esQuery,
// field formats
BoolFormat,
BytesFormat,
ColorFormat,
DateFormat,
DateNanosFormat,
DEFAULT_CONVERTER_COLOR,
DurationFormat,
FieldFormat,
IpFormat,
NumberFormat,
PercentFormat,
RelativeDateFormat,
SourceFormat,
StaticLookupFormat,
StringFormat,
TruncateFormat,
UrlFormat,
// index patterns
isFilterable,
// kbn field types
castEsToKbnFieldTypeName,
getKbnFieldType,
getKbnTypeNames,
} from '../common';

export { IRequestTypesMap, IResponseTypesMap } from './search';
export { DataServerPlugin as Plugin };
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
IIndexPattern,
esFilters,
Query,
utils,
} from '../../../../../../../../../../src/plugins/data/public';

import { FilterLabel } from './filter_label';
Expand Down Expand Up @@ -126,7 +125,7 @@ const getDescriptionItem = (
<EuiBadgeWrap color="hollow">
<FilterLabel
filter={filter}
valueLabel={utils.getDisplayValueFromFilter(filter, [indexPatterns])}
valueLabel={esFilters.getDisplayValueFromFilter(filter, [indexPatterns])}
/>
</EuiBadgeWrap>
</EuiFlexItem>
Expand Down

0 comments on commit e447134

Please sign in to comment.