@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
42 lines (41 loc) • 2.13 kB
TypeScript
import { Filter } from './filter';
import type moment from 'moment';
import type { EdmTypeShared } from '../edm-types';
import type { EntityBase, ODataVersionOf } from '../entity-base';
import type { Field } from '../selectable';
/**
* Data structure to represent OData filter functions.
* Use the factory function {@link filterFunction} to create instances of `FilterFunction`.
*/
export declare abstract class FilterFunction<EntityT extends EntityBase, ReturnT> {
readonly functionName: string;
readonly parameters: FilterFunctionParameterType<EntityT>[];
readonly edmType: EdmTypeShared<ODataVersionOf<EntityT>>;
/**
* Creates an instance of FilterFunction.
* @param functionName - Name of the function.
* @param parameters - Representation of the parameters passed to the filter function.
* @param edmType - EDM type of the return type of the filter function.
*/
constructor(functionName: string, parameters: FilterFunctionParameterType<EntityT>[], edmType: EdmTypeShared<ODataVersionOf<EntityT>>);
/**
* Creates an instance of Filter for this filter function and the given value using the operator 'eq', i.e. `==`.
* @param value - Value to be used in the filter.
* @returns The resulting filter.
*/
equals(value: ReturnT): Filter<EntityT, any, ReturnT>;
/**
* Creates an instance of Filter for this filter function and the given value using the operator 'ne', i.e. `!=`.
* @param value - Value to be used in the filter.
* @returns The resulting filter.
*/
notEquals(value: ReturnT): Filter<EntityT, any, ReturnT>;
}
/**
* Primitive type of a parameter of a filter function.
*/
export type FilterFunctionPrimitiveParameterType = number | string | moment.Moment;
/**
* Type of a parameter of a filter function. This can either be a primitive type, a reference to a field or another filter function.
*/
export type FilterFunctionParameterType<EntityT extends EntityBase> = FilterFunctionPrimitiveParameterType | Field<EntityT, boolean, boolean> | FilterFunction<EntityT, any> | FilterFunctionPrimitiveParameterType[];