import FollowablePromise from './followable-promise'; import Representor from './representor/base'; import Resource from './resource'; import { ContentType, KettingInit } from './types'; import './utils/fetch-polyfill'; /** * The main Ketting client object. */ export default class Ketting { /** * The url from which all discovery starts. */ bookMark: string; /** * Here we store all the resources that were ever requested. This will * ensure that if the same resource is requested twice, the same object is * returned. */ resourceCache: { [url: string]: Resource; }; /** * Content-Type settings and mappings. * * See the constructor for an example of the structure. */ contentTypes: ContentType[]; /** * The helper class that calls fetch() for us */ private fetchHelper; constructor(bookMark: string, options?: KettingInit); /** * This function is a shortcut for getResource().follow(x); */ follow(rel: string, variables?: object): FollowablePromise; /** * Returns a resource by its uri. * * This function doesn't do any HTTP requests. The uri is optional. If it's * not specified, it will return the bookmark resource. * * If a relative uri is passed, it will be resolved based on the bookmark * uri. */ go(uri?: string): Resource; /** * Returns a resource by its uri. * * This function doesn't do any HTTP requests. The uri is optional. If it's * not specified, it will return the bookmark resource. */ getResource(uri?: string): Resource; /** * This function does an arbitrary request using the fetch API. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch} */ fetch(input: string | Request, init?: RequestInit): Promise; /** * This function returns a representor constructor for a mime type. * * For example, given text/html, this function might return the constructor * stored in representor/html. */ getRepresentor(contentType: string): typeof Representor; /** * Generates an accept header string, based on registered Resource Types. */ getAcceptHeader(): string; beforeRequest(request: Request): void; }