UNPKG

angular-odata

Version:

Client side OData typescript library for Angular

104 lines (103 loc) 3.5 kB
export type Unpacked<T> = T extends (infer U)[] ? U : T; export type Select<T> = SelectType<T> | SelectType<T>[]; export type SelectType<T> = string | keyof T; export type Filter<T> = FilterType | FilterType[]; export type FilterType = string | { [name: string]: any; }; export declare enum StandardAggregateMethods { sum = "sum", min = "min", max = "max", average = "average", countdistinct = "countdistinct" } export type AggregateType = string | { [propertyName: string]: { with: StandardAggregateMethods; as: string; }; }; export type OrderBy<T> = OrderByType<T> | OrderByType<T>[]; export type OrderByType<T> = string | OrderByObject<T>; export type OrderByObject<T> = keyof T | [keyof T | string, 'asc' | 'desc'] | NestedOrderBy<T>; export type NestedOrderBy<T> = { [P in keyof T]?: T[P] extends Array<infer E> ? OrderBy<E> : OrderBy<T[P]>; }; export type Expand<T> = ExpandType<T> | ExpandType<T>[]; export type ExpandType<T> = string | ExpandObject<T>; export type ExpandObject<T> = keyof T | NestedExpandOptions<T>; export type NestedExpandOptions<T> = { [P in keyof T]?: ExpandOptions<Unpacked<T[P]>>; }; export type ExpandOptions<T> = { select?: Select<T>; filter?: Filter<T>; orderBy?: OrderBy<T>; top?: number; skip?: number; levels?: number | 'max'; count?: boolean | Filter<T>; expand?: Expand<T>; }; export type Transform<T> = { aggregate?: AggregateType | Array<AggregateType>; filter?: Filter<T>; groupBy?: GroupByType<T>; }; export type GroupByType<T> = { properties: Array<keyof T>; transform?: Transform<T>; }; export declare enum QueryCustomTypes { Raw = 0, Alias = 1, Duration = 2, Binary = 3 } export type QueryCustomType = { type: QueryCustomTypes; value: any; name?: string; }; export type Value = string | Date | number | boolean | QueryCustomType; export declare const raw: (value: string) => QueryCustomType; export declare const alias: (value: any, name?: string) => QueryCustomType; export declare const duration: (value: string) => QueryCustomType; export declare const binary: (value: string) => QueryCustomType; export declare const isQueryCustomType: (value: any) => boolean; export declare const isRawType: (value: any) => boolean; export type QueryOptions<T> = ExpandOptions<T> & { search: string; apply: string; transform: { [name: string]: any; } | { [name: string]: any; }[]; compute: string; skip: number; skiptoken: string; key: string | number | { [name: string]: any; }; count: boolean | Filter<T>; action: string; func: string | { [functionName: string]: { [parameterName: string]: any; }; }; format: string; aliases: QueryCustomType[]; escape: boolean; }; export declare const ITEM_ROOT = ""; export default function <T>({ select, search, skiptoken, format, top, skip, filter, transform, compute, orderBy, key, count, expand, action, func, aliases, escape, }?: Partial<QueryOptions<T>>): string; export declare function buildPathAndQuery<T>({ select, search, skiptoken, format, top, skip, filter, apply, transform, compute, orderBy, key, count, expand, action, func, aliases, escape, }?: Partial<QueryOptions<T>>): [string, { [name: string]: any; }]; export declare function normalizeValue(value: Value, { aliases, escape, }?: { aliases?: QueryCustomType[]; escape?: boolean; }): any;