angular-odata
Version:
Client side OData typescript library for Angular
184 lines (183 loc) • 7.99 kB
TypeScript
import { Observable } from 'rxjs';
import { ODataActionOptions, ODataEntitySetResource, ODataFunctionOptions, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryOptionsHandler, ODataResource } from '../resources';
import { ODataStructuredType } from '../schema/structured-type';
import { ODataModel } from './model';
import { ModelFieldOptions, ODataModelEntry, ODataModelEventEmitter, ODataModelField } from './options';
import { ODataEntitiesAnnotations } from '../annotations';
export declare class ODataCollection<T, M extends ODataModel<T>> implements Iterable<M> {
static model: typeof ODataModel | null;
_parent: [
ODataModel<any> | ODataCollection<any, ODataModel<any>>,
ODataModelField<any> | null
] | null;
_resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null;
_resources: {
parent: [
ODataModel<any> | ODataCollection<any, ODataModel<any>>,
ODataModelField<any> | null
] | null;
resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null;
}[];
_annotations: ODataEntitiesAnnotations<T>;
_entries: ODataModelEntry<T, M>[];
_model: typeof ODataModel;
models(): M[];
get length(): number;
events$: ODataModelEventEmitter<T>;
constructor(entities?: Partial<T>[] | {
[name: string]: any;
}[], { parent, resource, annots, model, reset, }?: {
parent?: [ODataModel<any>, ODataModelField<any>];
resource?: ODataResource<T> | null;
annots?: ODataEntitiesAnnotations<T>;
model?: typeof ODataModel;
reset?: boolean;
});
isParentOf(child: ODataModel<any> | ODataCollection<any, ODataModel<any>>): boolean;
resource(): ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null;
pushResource(resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null): void;
popResource(): {
parent: [ODataModel<any> | ODataCollection<any, ODataModel<any>>, ODataModelField<any> | null] | null;
resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null;
} | undefined;
attach(resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T>): void;
withResource<R>(resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null, ctx: (collection: this) => R): R;
asEntitySet<R>(ctx: (collection: this) => R): R;
annots(): ODataEntitiesAnnotations<T>;
private modelFactory;
toEntities({ client_id, include_navigation, include_concurrency, include_computed, include_key, include_id, include_non_field, changes_only, field_mapping, chain, }?: {
client_id?: boolean;
include_navigation?: boolean;
include_concurrency?: boolean;
include_computed?: boolean;
include_key?: boolean;
include_id?: boolean;
include_non_field?: boolean;
changes_only?: boolean;
field_mapping?: boolean;
chain?: (ODataModel<any> | ODataCollection<any, ODataModel<any>>)[];
}): (Partial<T> | {
[name: string]: any;
})[];
toJson(): (Partial<T> | {
[name: string]: any;
})[];
hasChanged({ include_navigation }?: {
include_navigation?: boolean;
}): boolean;
clone<C extends ODataCollection<T, M>>(): C;
private _request;
fetch({ add, merge, remove, withCount, ...options }?: ODataOptions & {
add?: boolean;
merge?: boolean;
remove?: boolean;
withCount?: boolean;
}): Observable<M[]>;
fetchAll({ add, merge, remove, withCount, ...options }?: ODataOptions & {
add?: boolean;
merge?: boolean;
remove?: boolean;
withCount?: boolean;
}): Observable<M[]>;
fetchMany(top: number, { add, merge, remove, withCount, ...options }?: ODataOptions & {
add?: boolean;
merge?: boolean;
remove?: boolean;
withCount?: boolean;
}): Observable<M[]>;
fetchOne({ add, merge, remove, withCount, ...options }?: ODataOptions & {
add?: boolean;
merge?: boolean;
remove?: boolean;
withCount?: boolean;
}): Observable<M | null>;
/**
* Save all models in the collection
* @param relModel The model is relationship
* @param method The method to use
* @param options HttpOptions
*/
save({ relModel, method, ...options }?: ODataOptions & {
relModel?: boolean;
method?: 'update' | 'modify';
}): Observable<M[]>;
private _addServer;
private _addModel;
add(model: M, { silent, reparent, server, merge, position, reset, }?: {
silent?: boolean;
reparent?: boolean;
server?: boolean;
merge?: boolean;
position?: number;
reset?: boolean;
}): Observable<M>;
private _removeServer;
private _removeModel;
remove(model: M, { silent, server, reset, }?: {
silent?: boolean;
server?: boolean;
reset?: boolean;
}): Observable<M>;
private _moveModel;
create(attrs?: T, { silent, server, }?: {
silent?: boolean;
server?: boolean;
}): Observable<M>;
set(path: string | string[], value: any, {}: {} & ModelFieldOptions): any;
get(path: number): M | undefined;
get(path: string | string[]): any;
has(path: number | string | string[]): boolean;
reset({ path, silent, }?: {
path?: string | string[];
silent?: boolean;
}): void;
clear({ silent }?: {
silent?: boolean;
}): void;
assign(objects: Partial<T>[] | {
[name: string]: any;
}[] | M[], { add, merge, remove, reset, reparent, silent, }?: {
add?: boolean;
merge?: boolean;
remove?: boolean;
reset?: boolean;
reparent?: boolean;
silent?: boolean;
}): M[];
query(ctx: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', options?: ODataFunctionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', options?: ODataActionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
private _unlink;
private _link;
private _findEntry;
equals(other: ODataCollection<T, ODataModel<T>>): boolean;
get [Symbol.toStringTag](): string;
[Symbol.iterator](): Iterator<M>;
filter(predicate: (value: M, index: number, array: M[]) => unknown, thisArg?: any): M[];
map<U>(callbackfn: (value: M, index: number, array: M[]) => U, thisArg?: any): U[];
find(predicate: (value: M, index: number, obj: M[]) => unknown): M | undefined;
reduce<U>(callbackfn: (previousValue: U, currentValue: M, currentIndex: number, array: M[]) => U, initialValue: U): U;
first(): M | undefined;
last(): M | undefined;
next(model: M): M | undefined;
prev(model: M): M | undefined;
every(predicate: (m: M, index: number) => boolean): boolean;
some(predicate: (m: M, index: number) => boolean): boolean;
includes(model: M, start?: number): boolean;
indexOf(model: M): number;
forEach(predicate: (value: M, index: number, array: M[]) => void, thisArg?: any): void;
isEmpty(): boolean;
private _compare;
_sortBy: {
field: string | keyof T;
order?: 1 | -1;
}[] | null;
isSorted(): boolean;
sort(by: {
field: string | keyof T;
order?: 1 | -1;
comparator?: (a: any, b: any) => number;
}[], { silent }?: {
silent?: boolean;
}): void;
}