UNPKG

ketting

Version:

Opiniated HATEAOS / Rest client.

49 lines (48 loc) 1.34 kB
import { BaseState } from './base-state'; /** * Represents a resource state in the HAL format */ export declare class JsonApiState<T = any> extends BaseState<T> { serializeBody(): string; clone(): JsonApiState<T>; } /** * Turns a HTTP response into a JsonApiState */ export declare const factory: (uri: string, response: Response) => Promise<JsonApiState<JsonApiTopLevelObject>>; /** * A JSON:API link can either be a string, or an object with at least a href * property. */ declare type JsonApiLink = string | { href: string; }; /** * This type is a full 'links' object, which might appear on the top level * or on resource objects. */ declare type JsonApiLinksObject = { self?: JsonApiLink; profile?: JsonApiLink; [rel: string]: JsonApiLink | JsonApiLink[] | undefined; }; /** * This is a single JSON:API resource. Its type contains just the properties * we care about. */ declare type JsonApiResource = { type: string; id: string; links?: JsonApiLinksObject; }; /** * This type represents a valid JSON:API response. We're only interested * in the links object at the moment, so everything else is (for now) * untyped. */ declare type JsonApiTopLevelObject = { links?: JsonApiLinksObject; data: JsonApiResource | JsonApiResource[] | null; [s: string]: any; }; export {};