UNPKG

2.73 kBTypeScriptView Raw
1import { EdmTypeShared } from '../edm-types';
2import { Constructable, Entity, EntityIdentifiable, ODataVersionOf } from '../entity';
3import { FieldType } from '../selectable';
4import type { FilterFunction } from './filter-function-base';
5import type { Filterable } from './filterable';
6declare type FilterOperatorString = 'eq' | 'ne';
7declare type FilterOperatorBoolean = 'eq' | 'ne';
8declare type FilterOperatorNumber = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge';
9export declare type FilterOperator = FilterOperatorString | FilterOperatorBoolean | FilterOperatorNumber;
10export declare type FilterOperatorByType<FieldT extends FieldType> = FieldT extends string ? FilterOperatorString : FieldT extends number ? FilterOperatorNumber : FilterOperatorBoolean;
11/**
12 * Represents a filter expression to narrow the data on a [[GetAllRequestBuilder]] request for multiple entities that match the specified criteria.
13 * A filter refers to the field of an entity and restricts the request based on an operator and a value. `Entity.FIELD_NAME.operator(value)`
14 *
15 * Example: `Product.NAME.equals('cloud-sdk')` creates a filter for the entity `Product` that matches in case the field `NAME` equals 'cloud-sdk'.
16 *
17 * See also: [[Filterable]]
18 * @typeparam EntityT - Type of the entity to be filtered on
19 * @typeparam FieldT - Type of the field to be filtered by, see also: [[FieldType]]
20 */
21export declare class Filter<EntityT extends Entity, FieldT extends FieldType | FieldType[]> implements EntityIdentifiable<EntityT> {
22 field: string | FilterFunction<EntityT, FieldT>;
23 operator: FilterOperator;
24 value: FieldT;
25 edmType?: EdmTypeShared<ODataVersionOf<EntityT>> | undefined;
26 /**
27 * Constructor type of the entity to be filtered.
28 */
29 readonly _entityConstructor: Constructable<EntityT>;
30 /**
31 * Entity type of the entity tp be filtered.
32 */
33 readonly _entity: EntityT;
34 /**
35 * @deprecated Since v1.16.0. Use [[field]] instead.
36 */
37 _fieldName: string | FilterFunction<EntityT, FieldT>;
38 /**
39 * Creates an instance of Filter.
40 * @param field - Name of the field of the entity to be filtered on or a filter function
41 * @param operator - Function to be used for matching
42 * @param value - Value to be used by the operator
43 * @param edmType - EDM type of the field to filter on, needed for custom fields
44 */
45 constructor(field: string | FilterFunction<EntityT, FieldT>, operator: FilterOperator, value: FieldT, edmType?: EdmTypeShared<ODataVersionOf<EntityT>> | undefined);
46}
47export declare function isFilter<T extends Entity, FieldT extends FieldType>(filterable: Filterable<T>): filterable is Filter<T, FieldT>;
48export {};
49//# sourceMappingURL=filter.d.ts.map
\No newline at end of file