Skip to content

Commit

Permalink
Convert filter_manager/lib to TypeScript / Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Sep 18, 2019
1 parent dc774b3 commit 18137c3
Show file tree
Hide file tree
Showing 41 changed files with 829 additions and 678 deletions.
5 changes: 5 additions & 0 deletions packages/kbn-es-query/src/filters/lib/exists_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import { Filter, FilterMeta } from './meta_filter';

export type ExistsFilterMeta = FilterMeta;

export interface FilterExistsProperty {
field: any;
}

export type ExistsFilter = Filter & {
meta: ExistsFilterMeta;
exists?: FilterExistsProperty;
};
9 changes: 8 additions & 1 deletion packages/kbn-es-query/src/filters/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import { PhraseFilter } from './phrase_filter';
import { PhrasesFilter } from './phrases_filter';
import { QueryStringFilter } from './query_string_filter';
import { RangeFilter } from './range_filter';
import { MatchAllFilter } from './match_all_filter';
import { MissingFilter } from './missing_filter';

export {
CustomFilter,
ExistsFilter,
Expand All @@ -38,6 +41,8 @@ export {
PhrasesFilter,
QueryStringFilter,
RangeFilter,
MatchAllFilter,
MissingFilter,
};

// Any filter associated with a field (used in the filter bar/editor)
Expand All @@ -47,4 +52,6 @@ export type FieldFilter =
| GeoPolygonFilter
| PhraseFilter
| PhrasesFilter
| RangeFilter;
| RangeFilter
| MatchAllFilter
| MissingFilter;
30 changes: 30 additions & 0 deletions packages/kbn-es-query/src/filters/lib/match_all_filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Filter, FilterMeta } from './meta_filter';

export interface MatchAllFilterMeta extends FilterMeta {
field: any;
formattedValue: string;
}

export type MatchAllFilter = Filter & {
meta: MatchAllFilterMeta;
match_all?: any;
};
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/filters/lib/meta_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface FilterMeta {
export interface Filter {
$state?: FilterState;
meta: FilterMeta;
query?: object;
query?: any;
}

export interface LatLon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
* under the License.
*/

export async function mapExists(filter) {
if (filter.exists) {
const type = 'exists';
const key = filter.exists.field;
const value = type;
return { type, key, value };
}
throw filter;
}
import { Filter, FilterMeta } from './meta_filter';

export type MissingFilterMeta = FilterMeta;

export type MissingFilter = Filter & {
meta: MissingFilterMeta;
missing?: any;
};
5 changes: 5 additions & 0 deletions packages/kbn-es-query/src/filters/lib/query_string_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ export type QueryStringFilterMeta = FilterMeta;

export type QueryStringFilter = Filter & {
meta: QueryStringFilterMeta;
query?: {
query_string: {
query: string;
};
};
};
16 changes: 14 additions & 2 deletions packages/kbn-es-query/src/filters/lib/range_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,29 @@

import { Filter, FilterMeta } from './meta_filter';

export interface RangeFilterParams {
interface FilterRange {
from?: number | string;
to?: number | string;
}

interface FilterRangeGt {
gt?: number | string;
lt?: number | string;
}

interface FilterRangeGte {
gte?: number | string;
lte?: number | string;
lt?: number | string;
}

export type RangeFilterParams = FilterRange & FilterRangeGt & FilterRangeGte;

export type RangeFilterMeta = FilterMeta & {
params: RangeFilterParams;
field?: any;
};

export type RangeFilter = Filter & {
meta: RangeFilterMeta;
range?: { [key: string]: RangeFilterParams };
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@ import _ from 'lodash';
import { Subject } from 'rxjs';

import { UiSettingsClientContract } from 'src/core/public';
// @ts-ignore

import { compareFilters } from './lib/compare_filters';
// @ts-ignore
import { mapAndFlattenFilters } from './lib/map_and_flatten_filters';
// @ts-ignore
import { changeTimeFilter } from './lib/change_time_filter';
import { onlyDisabledFiltersChanged } from './lib/only_disabled';
import { uniqFilters } from './lib/uniq_filters';

// @ts-ignore
import { extractTimeFilter } from './lib/extract_time_filter';
// @ts-ignore
import { changeTimeFilter } from './lib/change_time_filter';

import { onlyDisabledFiltersChanged } from './lib/only_disabled';
import { mapAndFlattenFilters } from './lib/map_and_flatten_filters';

import { PartitionedFilters } from './partitioned_filters';

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 18137c3

Please sign in to comment.