UNPKG

angular-odata

Version:

Client side OData typescript library for Angular

259 lines (258 loc) 10.4 kB
import { Parser, QueryOption } from '../../types'; import { Expand, Filter, OrderBy, Select, Transform } from './builder'; import { ComputeExpression, ComputeExpressionBuilder, FilterExpression, FilterExpressionBuilder, OrderByExpression, OrderByExpressionBuilder, SearchExpression, SearchExpressionBuilder, ExpandExpression, ExpandExpressionBuilder, SelectExpression, SelectExpressionBuilder, ApplyExpression, ApplyExpressionBuilder } from './expressions'; import { ODataQueryArguments, ODataQueryOptions } from './options'; export declare class ODataQueryOptionHandler<T> { private o; private n; constructor(o: Map<QueryOption, any>, n: QueryOption); /** * The name of the managed odata query option. */ get name(): QueryOption; /** * Converts the managed odata query option to a json object. * @returns {any} */ toJson(): any; /** * Returns a boolean indicating if the managed odata query option is empty. * @returns True if the managed odata query option is empty. */ empty(): boolean; /** * Get or Set the value of the managed odata query option. * @param v The value to set. * @returns */ value(v?: any): any; private assertArray; /** * Push value to the managed odata query option. * @param value Value to push */ push(value: any): void; /** * Remove value from the managed odata query option. * @param value Value to remove */ remove(value: any): void; /** * Return value at index of the managed odata query option. * @param index Index of the value * @returns The value */ at(index: number): any; some(predicate: (value: any) => boolean): boolean; every(predicate: (value: any) => boolean): boolean; find(predicate: (value: any) => boolean): any; private assertObject; /** * Set the value for path in the managed odata query option. * @param path Path for set the value * @param value Value to set */ set(path: string, value: any): void; /** * Get the value for path from the managed odata query option. * @param path The path from get the value * @param def Default if not found * @returns */ get(path: string, def?: any): any; /** * Unset the value for path in the managed odata query option. * @param path */ unset(path: string): void; /** * Test if the managed odata query option has the value. * @param path The path fot test if the value is set * @returns Boolean indicating if the value is set */ has(path: string): boolean; /** * Merge values from object into the managed odata query option. * @param values Object to merge * @returns */ assign(values: { [attr: string]: any; }): { [attr: string]: any; }; /** * Clear the managed odata query option. */ clear(): void; toString({ escape, parser, }?: { escape?: boolean; parser?: Parser<T>; }): string; } export declare class ODataQueryOptionsHandler<T> { protected options: ODataQueryOptions<T>; constructor(options: ODataQueryOptions<T>); /** * Create a raw odata value * @param value The value to raw * @returns The raw value */ raw(value: any): import("./builder").QueryCustomType; /** * Create a new odata alias parameter * @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_ParameterAliases * @param value The value of the alias * @param name The name of the alias * @returns The alias */ alias(value: any, name?: string): import("./builder").QueryCustomType; /** * Create a duration odata value * @param value The value to duration * @returns The duration value */ duration(value: any): import("./builder").QueryCustomType; /** * Create a binary odata value * @param value The value to binary * @returns The binary value */ binary(value: any): import("./builder").QueryCustomType; /** * Normalize the given value to a valid odata value * @param value The value to normalize * @returns The normalized value */ normalize(value: any): any; /** * Build and return a handler for modifying the $select option. * If opts is given then set te value as new value for $select. * @param opts Select<T> value or builder function for SelectExpression<T> */ select(opts: (builder: SelectExpressionBuilder<T>, current?: SelectExpression<T>) => SelectExpression<T>): SelectExpression<T>; select(opts: Select<T>): ODataQueryOptionHandler<T>; select(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $expand option. * If opts is given then set te value as new value for $expand. * @param opts Expand<T> value or builder function for ExpandExpression<T> */ expand(opts: (builder: ExpandExpressionBuilder<T>, current?: ExpandExpression<T>) => ExpandExpression<T>): ExpandExpression<T>; expand(opts: Expand<T>): ODataQueryOptionHandler<T>; expand(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $compute option. * If opts is given then set te value as new value for $compute. * @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_SystemQueryOptioncompute * @param opts string value or builder function for ComputeExpression<T> */ compute(opts: (builder: ComputeExpressionBuilder<T>, current?: ComputeExpression<T>) => ComputeExpression<T>): ComputeExpression<T>; compute(opts: string): ODataQueryOptionHandler<T>; compute(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $apply option. * If opts is given then set te value as new value for $compute. * @link http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs02/odata-data-aggregation-ext-v4.0-cs02.html * @param opts string value or builder function for ApplyExpression<T> */ apply(opts: (builder: ApplyExpressionBuilder<T>, current?: ApplyExpression<T>) => ApplyExpression<T>): ApplyExpression<T>; apply(opts: string): ODataQueryOptionHandler<T>; apply(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $format option. * If opts is given then set te value as new value for $format. * @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_SystemQueryOptionformat * @param opts string value for format */ format(opts: string): ODataQueryOptionHandler<T>; format(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $transform option. * If opts is given then set te value as new value for $transform. * @param opts string value for transform */ transform(opts: Transform<T>): ODataQueryOptionHandler<T>; transform(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $search option. * If opts is given then set te value as new value for $search. * @param opts string value or builder function for SearchExpression<T> */ search(opts: (builder: SearchExpressionBuilder<T>, current?: SearchExpression<T>) => SearchExpression<T>): SearchExpression<T>; search(opts: string): ODataQueryOptionHandler<T>; search(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $filter option. * If opts is given then set te value as new value for $filter. * @param opts Filter<T> value or builder function for FilterExpression<T> */ filter(opts: (builder: FilterExpressionBuilder<T>, current?: FilterExpression<T>) => FilterExpression<T>): FilterExpression<T>; filter(opts: Filter<T>): ODataQueryOptionHandler<T>; filter(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $orderby option. * If opts is given then set te value as new value for $orderby. * @param opts OrderBy<T> value or builder function for OrderByExpression<T> */ orderBy(opts: (builder: OrderByExpressionBuilder<T>, current?: OrderByExpression<T>) => OrderByExpression<T>): OrderByExpression<T>; orderBy(opts: OrderBy<T>): ODataQueryOptionHandler<T>; orderBy(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $top option. * If opts is given then set te value as new value for $top. * @param opts number value */ top(opts: number): ODataQueryOptionHandler<T>; top(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $skip option. * If opts is given then set te value as new value for $skip. * @param opts number value */ skip(opts: number): ODataQueryOptionHandler<T>; skip(): ODataQueryOptionHandler<T>; /** * Build and return a handler for modifying the $skiptoken option. * If opts is given then set te value as new value for $skiptoken. * @param opts string value */ skiptoken(opts: string): ODataQueryOptionHandler<T>; skiptoken(): ODataQueryOptionHandler<T>; remove(...keys: QueryOption[]): void; keep(...keys: QueryOption[]): void; /** * Shortcut for set $top, $skip, $skiptoken. * @param param0 skip or top or skiptoken */ paging({ skip, skiptoken, top, }?: { skip?: number | null; skiptoken?: string | null; top?: number | null; }): void; /** * Shortcut for clear pagination by unset $top, $skip, $skiptoken. */ removePaging(): void; /** * Shortcut for clear query. */ clear(): void; /** * Store the query options from the current query. */ store(): ODataQueryArguments<T>; /** * Restore the given query options to the current query. * @param options The query to be applied. */ restore(options: ODataQueryArguments<T>): void; toJson(): {}; fromJson(json: { [name: string]: any; }): void; toString({ escape, parser, }?: { escape?: boolean; parser?: Parser<T>; }): string; }