@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
49 lines • 2.73 kB
TypeScript
import { EdmTypeShared } from '../edm-types';
import { Constructable, Entity, EntityIdentifiable, ODataVersionOf } from '../entity';
import { FieldType } from '../selectable';
import type { FilterFunction } from './filter-function-base';
import type { Filterable } from './filterable';
declare type FilterOperatorString = 'eq' | 'ne';
declare type FilterOperatorBoolean = 'eq' | 'ne';
declare type FilterOperatorNumber = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge';
export declare type FilterOperator = FilterOperatorString | FilterOperatorBoolean | FilterOperatorNumber;
export declare type FilterOperatorByType<FieldT extends FieldType> = FieldT extends string ? FilterOperatorString : FieldT extends number ? FilterOperatorNumber : FilterOperatorBoolean;
/**
* Represents a filter expression to narrow the data on a [[GetAllRequestBuilder]] request for multiple entities that match the specified criteria.
* 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)`
*
* Example: `Product.NAME.equals('cloud-sdk')` creates a filter for the entity `Product` that matches in case the field `NAME` equals 'cloud-sdk'.
*
* See also: [[Filterable]]
* @typeparam EntityT - Type of the entity to be filtered on
* @typeparam FieldT - Type of the field to be filtered by, see also: [[FieldType]]
*/
export declare class Filter<EntityT extends Entity, FieldT extends FieldType | FieldType[]> implements EntityIdentifiable<EntityT> {
field: string | FilterFunction<EntityT, FieldT>;
operator: FilterOperator;
value: FieldT;
edmType?: EdmTypeShared<ODataVersionOf<EntityT>> | undefined;
/**
* Constructor type of the entity to be filtered.
*/
readonly _entityConstructor: Constructable<EntityT>;
/**
* Entity type of the entity tp be filtered.
*/
readonly _entity: EntityT;
/**
* @deprecated Since v1.16.0. Use [[field]] instead.
*/
_fieldName: string | FilterFunction<EntityT, FieldT>;
/**
* Creates an instance of Filter.
* @param field - Name of the field of the entity to be filtered on or a filter function
* @param operator - Function to be used for matching
* @param value - Value to be used by the operator
* @param edmType - EDM type of the field to filter on, needed for custom fields
*/
constructor(field: string | FilterFunction<EntityT, FieldT>, operator: FilterOperator, value: FieldT, edmType?: EdmTypeShared<ODataVersionOf<EntityT>> | undefined);
}
export declare function isFilter<T extends Entity, FieldT extends FieldType>(filterable: Filterable<T>): filterable is Filter<T, FieldT>;
export {};
//# sourceMappingURL=filter.d.ts.map