ngx-hal
Version:
Angular library for supporting HAL format APIs
82 lines (81 loc) • 4.22 kB
TypeScript
import { Observable } from 'rxjs';
import { HttpResponse } from '@angular/common/http';
import { RawHalResource } from '../interfaces/raw-hal-resource.interface';
import { HalDocumentConstructor } from '../types/hal-document-construtor.type';
import { ModelProperty, HasManyModelProperty } from '../interfaces/model-property.interface';
import { DatastoreService } from '../services/datastore/datastore.service';
import { RawHalLink } from '../interfaces/raw-hal-link.interface';
import { RawHalLinks } from '../interfaces/raw-hal-links.interface';
import { HalDocument } from '../classes/hal-document';
import { NetworkConfig } from '../interfaces/network-config.interface';
import { PlainHeaders, RequestOptions } from '../types/request-options.type';
import { GeneratePayloadOptions } from '../interfaces/generate-payload-options.interface';
import { CustomOptions } from '../interfaces/custom-options.interface';
import { RelationshipRequestDescriptor } from '../types/relationship-request-descriptor.type';
import { ModelEndpoints } from '../interfaces/model-endpoints.interface';
export declare abstract class HalModel<Datastore extends DatastoreService = DatastoreService> {
protected resource: RawHalResource;
protected datastore: Datastore;
rawResponse?: HttpResponse<any>;
private config;
private temporarySelfLink;
private localModelIdentificator;
private internalHasManyDocumentIdentificators;
static readonly modelType: string;
constructor(resource: RawHalResource, datastore: Datastore, rawResponse?: HttpResponse<any>);
get uniqueModelIdentificator(): string;
protected getUniqueModelIdentificator(): string;
get id(): string;
get endpoint(): string;
get modelEndpoints(): ModelEndpoints;
get networkConfig(): NetworkConfig;
get type(): string;
getHalDocumentClass<T extends this>(): HalDocumentConstructor<T>;
getRelationshipUrl(relationshipName: string): string;
getPropertyData(propertyName: string): ModelProperty;
getEmbeddedResource(resourceName: string): RawHalResource | undefined;
save(requestOptions?: RequestOptions, options?: CustomOptions<this>): Observable<this>;
update(requestOptions?: RequestOptions, options?: CustomOptions<this>): Observable<this>;
delete(requestOptions?: RequestOptions, options?: CustomOptions<this>): Observable<void>;
refetch(includeRelationships?: Array<string | RelationshipRequestDescriptor>, requestOptions?: RequestOptions): Observable<this>;
generatePayload(options?: GeneratePayloadOptions): object;
private extractEmbeddedProperties;
private getAttributePropertiesPayload;
private generateHasOnePropertyPayload;
private generateHasManyPropertyPayload;
private generateRelationshipsPayload;
generateHeaders(): PlainHeaders;
get isSaved(): boolean;
fetchRelationships(relationships: string | RelationshipRequestDescriptor | Array<string | RelationshipRequestDescriptor>, requestOptions?: RequestOptions): Observable<this>;
getRelationship<T extends HalModel>(relationshipName: string): T | HalDocument<T>;
private get attributeProperties();
private get headerAttributeProperties();
private get hasOneProperties();
private get hasManyProperties();
private get linkProperties();
private getPropertiesMetadata;
private initializeHasOneProperties;
private initializeHasManyProperties;
private setProperty;
private parseAttributes;
private parseHeaderAttributes;
private getHasOneRelationship;
private getHasManyRelationship;
get links(): RawHalLinks | {
[relationshipName: string]: RawHalLink;
};
get selfLink(): string;
set selfLink(link: string);
private replaceRelationshipModel;
private setLocalModelIdentificator;
private isHasOneProperty;
private isHasManyProperty;
populateModelMetadata<K extends HalModel>(sourceModel: K): void;
updateHasManyDocumentIdentificator(property: HasManyModelProperty, identificator: string): void;
set hasManyDocumentIdentificators(hasManyDocumentIdentificators: {
[K: string]: string;
});
get hasManyDocumentIdentificators(): {
[K: string]: string;
};
}