angular-odata
Version:
Client side OData typescript library for Angular
158 lines (157 loc) • 6.38 kB
TypeScript
import { Observable } from 'rxjs';
import { ODataApi } from '../../api';
import type { ModelInterface, ODataCollection, ODataModel } from '../../models';
import { QueryOption, StructuredTypeFieldConfig } from '../../types';
import { ODataPathSegments } from '../path';
import { ApplyExpression, ApplyExpressionBuilder } from '../query';
import { ODataResource } from '../resource';
import { ODataEntities, ODataEntity } from '../response';
import { ODataCountResource } from './count';
import { ODataMediaResource } from './media';
import { ODataEntitiesOptions, ODataEntityOptions, ODataOptions } from './options';
import { ODataPropertyResource } from './property';
import { ODataReferenceResource } from './reference';
import { ODataEntitiesAnnotations } from '../../annotations';
/**
* OData Navigation Property Resource
* https://www.odata.org/getting-started/advanced-tutorial/#containment
* https://www.odata.org/getting-started/advanced-tutorial/#derived
*/
export declare class ODataNavigationPropertyResource<T> extends ODataResource<T> {
static factory<N>(api: ODataApi, { path, type, segments, }: {
path: string;
type?: string;
segments: ODataPathSegments;
}): ODataNavigationPropertyResource<N>;
static fromResource<N>(resource: ODataResource<any>, path: string): ODataNavigationPropertyResource<N>;
clone(): ODataNavigationPropertyResource<T>;
transform<R>(opts: (builder: ApplyExpressionBuilder<T>, current?: ApplyExpression<T>) => ApplyExpression<T>, { type, fields, }?: {
type?: string;
fields?: {
[name: string]: StructuredTypeFieldConfig;
};
}): ODataNavigationPropertyResource<R>;
key(value: any): ODataNavigationPropertyResource<T>;
keys(values: any[]): ODataNavigationPropertyResource<T>;
media(): ODataMediaResource;
reference(): ODataReferenceResource<T>;
navigationProperty<N>(path: string): ODataNavigationPropertyResource<N>;
property<P>(path: string): ODataPropertyResource<P>;
count(): ODataCountResource<T>;
cast<C>(type: string): ODataNavigationPropertyResource<C>;
protected post(attrs: Partial<T>, options?: ODataOptions): Observable<ODataEntity<T>>;
protected put(attrs: Partial<T>, options?: ODataOptions): Observable<ODataEntity<T>>;
protected patch(attrs: Partial<T>, options?: ODataOptions): Observable<ODataEntity<T>>;
protected delete(options?: ODataOptions): Observable<any>;
protected get(options?: ODataEntityOptions & ODataEntitiesOptions & {
bodyQueryOptions?: QueryOption[];
}): Observable<any>;
/**
* Create a new entity
* @param attrs The entity attributes
* @param options Options for the request
* @returns The created entity with the annotations
*/
create(attrs: Partial<T>, options?: ODataOptions): Observable<ODataEntity<T>>;
/**
* Update an existing entity
* @param attrs The entity attributes
* @param options Options for the request
* @returns The updated entity with the annotations
*/
update(attrs: Partial<T>, options?: ODataOptions): Observable<ODataEntity<T>>;
/**
* Modify an existing entity
* @param attrs The entity attributes
* @param options Options for the request
* @returns The modified entity with the annotations
*/
modify(attrs: Partial<T>, options?: ODataOptions): Observable<ODataEntity<T>>;
/**
* Delete an existing entity
* @param options Options for the request
* @returns An observable of the destroy
*/
destroy(options?: ODataOptions): Observable<any>;
/**
* Fetch entity / entities
* @param options Options for the request
* @return An observable of the entity or entities with annotations
*/
fetch(options?: ODataEntityOptions & {
bodyQueryOptions?: QueryOption[];
}): Observable<ODataEntity<T>>;
fetch(options?: ODataEntitiesOptions & {
bodyQueryOptions?: QueryOption[];
}): Observable<ODataEntities<T>>;
/**
* Fetch the entity
* @param options Options for the request
* @returns The entity
*/
fetchEntity(options?: ODataOptions & {
bodyQueryOptions?: QueryOption[];
}): Observable<T | null>;
/**
* Fetch the entity and return as model
* @param options Options for the request
* @returns The model
*/
fetchModel(options?: ODataOptions & {
bodyQueryOptions?: QueryOption[];
ModelType?: typeof ODataModel;
}): Observable<(ODataModel<T> & ModelInterface<T>) | null>;
fetchModel<M extends ODataModel<T>>(options?: ODataOptions & {
bodyQueryOptions?: QueryOption[];
ModelType?: typeof ODataModel;
}): Observable<M | null>;
/**
* Fetch entities
* @param options Options for the request
* @returns The entities
*/
fetchEntities(options?: ODataOptions & {
bodyQueryOptions?: QueryOption[];
}): Observable<T[] | null>;
/**
* Fetch entities and return as collection
* @param options Options for the request
* @returns The collection
*/
fetchCollection(options?: ODataOptions & {
withCount?: boolean;
bodyQueryOptions?: QueryOption[];
CollectionType?: typeof ODataCollection;
}): Observable<ODataCollection<T, ODataModel<T> & ModelInterface<T>> | null>;
fetchCollection<M extends ODataModel<T>, C extends ODataCollection<T, M>>(options?: ODataOptions & {
withCount?: boolean;
bodyQueryOptions?: QueryOption[];
CollectionType?: typeof ODataCollection;
}): Observable<C | null>;
/**
* Fetch all entities
* @param options Options for the request
* @returns All entities
*/
fetchAll(options?: ODataOptions & {
withCount?: boolean;
bodyQueryOptions?: QueryOption[];
}): Observable<{
entities: T[];
annots: ODataEntitiesAnnotations<T>;
}>;
fetchMany(top: number, options?: ODataOptions & {
withCount?: boolean;
bodyQueryOptions?: QueryOption[];
}): Observable<{
entities: T[];
annots: ODataEntitiesAnnotations<T>;
}>;
fetchOne(options?: ODataOptions & {
withCount?: boolean;
bodyQueryOptions?: QueryOption[];
}): Observable<{
entity: T | null;
annots: ODataEntitiesAnnotations<T>;
}>;
}