@skylinedynamics/sd-angular-jsonapi
Version:
Skyline Dynamics Angular 5+, fluent Implementation for JSONAPI conform requests
78 lines (77 loc) • 3.36 kB
TypeScript
import { EventEmitter } from '@angular/core';
import { Relationship } from '../interfaces/relationship';
import { Observable } from 'rxjs/Observable';
import { Collection } from './sd-angular-jsonapi-collection';
import { EntityManager } from '../services/sd-angular-jsonapi-entity-manager';
import { JSONAPIErrorBag } from './sd-angular-jsonapi-error';
import { HttpErrorResponse } from '@angular/common/http';
import { ResourceLinks } from '../interfaces/resource-links';
import { IJSONAPIResource } from '../interfaces/jsonapi-resource';
import { OrderType } from '../interfaces/sort-query';
export declare abstract class JSONAPIResource implements IJSONAPIResource {
private _limit;
private _paginate;
private _doPaginate;
private _related;
private _filters;
private _sortBy;
private _fields;
private _isLoaded;
private _isNew;
private _hasUpdate;
private _forInitialization;
private _initialized;
private _loadRelationships;
private _loadedRelationships;
private _liveRelationships;
private _links;
manager: EntityManager;
resource: string;
id: string | number;
attributes: string[];
onUpdated: EventEmitter<boolean>;
onDeleted: EventEmitter<boolean>;
onCreated: EventEmitter<boolean>;
onRefreshed: EventEmitter<this | boolean>;
constructor(data?: any, manager?: EntityManager);
initialize(): void;
setData(data?: any): void;
refresh(): void;
private hasSelfLink();
private hasRelatedLink();
reload(): void;
addRelationship(resource: string, links: ResourceLinks, data: any): this;
addRelationships(resources: Relationship[]): this;
hasLoadedRelationship(name: string): this;
associateRelationshipData(name: string, data: any, callback?: any): void;
findRelationshipData(name: string, data: any): any;
private emitLiveRelationship(name);
all(fields?: string[]): Observable<Collection | JSONAPIErrorBag | HttpErrorResponse>;
get(id?: number | string, fields?: string[]): Observable<Collection | JSONAPIErrorBag | HttpErrorResponse>;
find(id: number | string): Observable<Collection | JSONAPIErrorBag | HttpErrorResponse>;
update(): Observable<Collection | JSONAPIResource | JSONAPIErrorBag>;
private canUpdate();
delete(): Observable<Collection | JSONAPIErrorBag | HttpErrorResponse>;
private canDelete();
create(data: any, autoSave?: boolean): this | Observable<Collection | JSONAPIResource | JSONAPIErrorBag>;
new(data: any): this | any;
save(): Observable<Collection | JSONAPIResource | any>;
load(relationships: string | string[]): void;
paginate(pageSize?: number, startAtPage?: number): this;
limit(limit?: number): this;
take(amount?: number): this;
with(related: string | string[]): this;
only(fields: string[]): this;
fields(fields: string[]): this;
filter(attribute: string, value: string | boolean | number): this;
filters(filters: [string, string | boolean | number][]): this;
private isSortQuery(element);
sortBy(direction: OrderType, attribute: string): this;
private constructFilters();
private constructRelationships();
private constructFieldsFilter();
private constructLimitQuery();
private constructPaginationQuery();
private constructSortFilter();
private getURLAppendix();
}