import { ExportCsvOptions, LayoutField, ModuleProperty } from '../ModuleProperties'; import { SortDirection } from '../SimpleTypes'; import { SearchAggregation } from './SearchAggregation'; export declare type PaginatedSearchResults = { total: number; data: T[]; }; export declare type SearchFilterValuePrimitives = number | string | null | boolean; export declare enum SearchFilterType { CONTAINS = "CONTAINS", CONTAINS_LIKE_TEXT = "CONTAINS_LIKE_TEXT", CONTAINS_IN_LIST = "CONTAINS_IN_LIST", EXACT_MATCH = "EXACT_MATCH", GREATER_THAN = "GREATER_THAN", GREATER_THAN_OR_EQUAL = "GREATER_THAN_OR_EQUAL", IN_LIST = "IN_LIST", LESS_THAN = "LESS_THAN", LESS_THAN_OR_EQUAL = "LESS_THAN_OR_EQUAL", LIKE_TEXT = "LIKE_TEXT", NOT_CONTAINS_IN_LIST = "NOT_CONTAINS_IN_LIST", NOT_EQUAL = "NOT_EQUAL", NOT_IN_LIST = "NOT_IN_LIST", RANGE = "RANGE", TEMPORAL_DATE_RANGE = "TEMPORAL_DATE_RANGE", OR = "OR", JOINED = "JOINED" } export declare type SearchFilterTypeValues = 'CONTAINS' | 'CONTAINS_LIKE_TEXT' | 'CONTAINS_IN_LIST' | 'EXACT_MATCH' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'IN_LIST' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL' | 'LIKE_TEXT' | 'NOT_CONTAINS_IN_LIST' | 'NOT_EQUAL' | 'NOT_IN_LIST' | 'RANGE' | 'TEMPORAL_DATE_RANGE' | 'OR' | 'JOINED'; export declare enum SearchFilterConstraintType { META = "META", NESTED_FIELD = "NESTED_FIELD" } export declare type SearchFilterConstraintBase = { type: SearchFilterConstraintType | 'META' | 'NESTED_FIELD'; }; /** * Add meta data to a search filter */ export declare type MetaSearchFilterConstraint = SearchFilterConstraintBase & { type: SearchFilterConstraintType.META | 'META'; key: string; value: any; }; /** * Filter values by ensuring that they are in a list of elements */ export declare type NestedFieldSearchFilterConstraint = SearchFilterConstraintBase & { type: SearchFilterConstraintType.NESTED_FIELD | 'NESTED_FIELD'; /** * The name of a field on an object in an array */ key: string; }; declare type Constrained = T & { constraint?: NestedFieldSearchFilterConstraint; }; export declare type SearchFilterConstraint = MetaSearchFilterConstraint | NestedFieldSearchFilterConstraint; export declare type SearchFilterValue = { type: SearchFilterType | SearchFilterTypeValues; }; /** * Filter values by ensuring that a particiular array field contains a value */ export declare type ContainsFilterValue = Constrained; /** * Filter values by ensuring that a particiular array field matches a text value */ export declare type ContainsLikeTextFitlerValue = Constrained; /** * Filter values by ensuring that a particiular array field contains at least one * of the values in a list */ export declare type ContainsInListFilterValue = Constrained; /** * Filter values by ensuring that they exactly match a value */ export declare type ExactMatchFilterValue = SearchFilterValue & { type: SearchFilterType.EXACT_MATCH | 'EXACT_MATCH'; value: SearchFilterValuePrimitives; }; /** * Filter values by ensuring that they are greater than a value */ export declare type GreaterThanFilterValue = Constrained; /** * Filter values by ensuring that they are greater than or equal to a value */ export declare type GreaterThanOrEqualFilterValue = Constrained; /** * Filter values by ensuring that they are in a list of elements */ export declare type InListFilterValue = SearchFilterValue & { type: SearchFilterType.IN_LIST | 'IN_LIST'; values: SearchFilterValuePrimitives[]; }; /** * Filter values by ensuring that they are less than a value */ export declare type LessThanFilterValue = Constrained; /** * Filter values by ensuring that they are less than or equal to a value */ export declare type LessThanOrEqualFilterValue = Constrained; /** * Fitler values by ensuring that they are partially match a text value */ export declare type LikeTextFilterValue = SearchFilterValue & { type: SearchFilterType.LIKE_TEXT | 'LIKE_TEXT'; value: string; }; /** * Filter values by ensuring that a particiular array field does not contain any * of the values in a list */ export declare type NotContainsInListFilterValue = Constrained; /** * Filter values by ensuring that they are less than or equal to a value */ export declare type NotEqualFilterValue = SearchFilterValue & { type: SearchFilterType.NOT_EQUAL | 'NOT_EQUAL'; value: SearchFilterValuePrimitives; }; /** * Filter values by ensuring that they are not in a list of elements */ export declare type NotInListFilterValue = SearchFilterValue & { type: SearchFilterType.NOT_IN_LIST | 'NOT_IN_LIST'; values: SearchFilterValuePrimitives[]; }; /** * Filter values by ensuring that their value is between a start and a end range * * The start and end values are both required */ export declare type RangeFilterValue = Constrained; export declare type JoinedFilterValue = SearchFilterValue & { type: SearchFilterType.JOINED | 'JOINED'; values: SearchFilterValueJoinable[]; }; export declare type OrFilterValue = SearchFilterValue & { type: SearchFilterType.OR | 'OR'; values: Array>>; }; /** * Filter date values with a range and an additional constraint * * The start and end values are both required */ export declare type TemporalDateRangeFilterValue = Constrained; export declare const JoinableSearchFilters: SearchFilterType[]; export declare type SearchFilterValueJoinable = ContainsFilterValue | ContainsLikeTextFitlerValue | ContainsInListFilterValue | GreaterThanFilterValue | GreaterThanOrEqualFilterValue | LessThanFilterValue | LessThanOrEqualFilterValue | RangeFilterValue | NotContainsInListFilterValue | TemporalDateRangeFilterValue; export declare type SearchFilterValueType = ContainsFilterValue | ContainsLikeTextFitlerValue | ContainsInListFilterValue | ExactMatchFilterValue | GreaterThanFilterValue | GreaterThanOrEqualFilterValue | InListFilterValue | LessThanFilterValue | LessThanOrEqualFilterValue | LikeTextFilterValue | NotContainsInListFilterValue | NotEqualFilterValue | NotInListFilterValue | RangeFilterValue | TemporalDateRangeFilterValue | JoinedFilterValue | OrFilterValue; /** * Used to filter a list of data structures from a particular module * * Each filter is intended to be used for only one field on a data structure. */ export declare type SearchFilter = { /** * The name of the field from the associated data structure */ field_name: string; /** * An object that determines how the data structure's field will be filtered */ field_value: SearchFilterValueType; }; /** * Used to send a search query to the core search module with filters */ export declare type SearchQueryWithFilters = { /** * The name of the module associated with the search query */ module_name: string; /** * A list of filters used in the search query */ filters: SearchFilter[]; /** * A list of search aggregation stages */ aggregate?: SearchAggregation[]; /** * The maximum amount of results to be returned to the requesting party */ limit: number; /** * The amount of results to skip */ skip?: number; sort?: { field: ModuleProperty; direction: SortDirection; }; }; export declare type SearchOptions = { filters: SearchFilter[]; limit?: number; skip?: number; sort?: { field: ModuleProperty; direction: SortDirection; }; }; export declare type ExportSearchOptions = SearchQueryWithFilters & { fields: LayoutField[]; exportOptions: ExportCsvOptions; }; /************************************* * Backwards compatible type aliases * /************************************/ /** * @deprecated Use SearchFilterConstraintType instead */ export declare type ESearchFilterConstraintType = SearchFilterConstraintType; /** * @deprecated Use SearchFilterConstraintBase instead */ export declare type ISearchFilterConstraintBase = SearchFilterConstraintBase; /** * @deprecated Use MetaSearchFilterConstraint instead */ export declare type IMetaSearchFilterConstraint = MetaSearchFilterConstraint; /** * @deprecated Use NestedFieldSearchFilterConstraint instead */ export declare type INestedFieldSearchFilterConstraint = NestedFieldSearchFilterConstraint; /** * @deprecated Use SearchFilterConstraint instead */ export declare type ISearchFilterConstraint = SearchFilterConstraint; /** * @deprecated Use SearchFilterValue instead */ export declare type ISearchFilterValue = SearchFilterValue; /** * @deprecated Use ContainsFilterValue instead */ export declare type IContainsFilterValue = ContainsFilterValue; /** * @deprecated Use ContainsLikeTextFitlerValue instead */ export declare type IContainsLikeTextFitlerValue = ContainsLikeTextFitlerValue; /** * @deprecated Use ContainsInListFilterValue instead */ export declare type IContainsInListFilterValue = ContainsInListFilterValue; /** * @deprecated Use ExactMatchFilterValue instead */ export declare type IExactMatchFilterValue = ExactMatchFilterValue; /** * @deprecated Use GreaterThanFilterValue instead */ export declare type IGreaterThanFilterValue = GreaterThanFilterValue; /** * @deprecated Use GreaterThanOrEqualFilterValue instead */ export declare type IGreaterThanOrEqualFilterValue = GreaterThanOrEqualFilterValue; /** * @deprecated Use InListFilterValue instead */ export declare type IInListFilterValue = InListFilterValue; /** * @deprecated Use LessThanFilterValue instead */ export declare type ILessThanFilterValue = LessThanFilterValue; /** * @deprecated Use LessThanOrEqualFilterValue instead */ export declare type ILessThanOrEqualFilterValue = LessThanOrEqualFilterValue; /** * @deprecated Use LikeTextFilterValue instead */ export declare type ILikeTextFilterValue = LikeTextFilterValue; /** * @deprecated Use NotContainsInListFilterValue instead */ export declare type INotContainsInListFilterValue = NotContainsInListFilterValue; /** * @deprecated Use NotEqualFilterValue instead */ export declare type INotEqualFilterValue = NotEqualFilterValue; /** * @deprecated Use NotInListFilterValue instead */ export declare type INotInListFilterValue = NotInListFilterValue; /** * @deprecated Use RangeFilterValue instead */ export declare type IRangeFilterValue = RangeFilterValue; /** * @deprecated Use TemporalDateRangeFilterValue instead */ export declare type ITemporalDateRangeFilterValue = TemporalDateRangeFilterValue; /** * @deprecated Use SearchFilter instead */ export declare type ISearchFilter = SearchFilter; /** * @deprecated Use SearchQueryWithFilters instead */ export declare type ISearchQueryWithFilters = SearchQueryWithFilters; /** * @deprecated Use SearchOptions instead */ export declare type ISearchQueryWithFiltersSimple = SearchOptions; /** * @deprecated Use ExportSearchOptions instead */ export declare type IExportQueryWithFilters = ExportSearchOptions; export {};