@obelisk/client
Version:
Typescript client to interact with Obelisk on a higher level than the regular ReST API calls.
53 lines (52 loc) • 2.42 kB
TypeScript
import { Observable, OperatorFunction } from "rxjs";
import { AjaxRequest, AjaxResponse } from "rxjs/ajax";
import { TPageResponse, Link } from "../api";
import { ApiVersion } from "../interfaces";
import { ObeliskClient } from "../obelisk-client";
/**
* @hidden
*/
export declare class InternalUtils {
private static regex;
static mapAjaxResponse2TPageResponse(resp: AjaxResponse, index: number): TPageResponse;
static token2header(client: ObeliskClient, cfg: AjaxRequest): AjaxRequest;
static parseLinkHeader(linkHeaderValue: string): Link;
/**
* Divide url in 2 parts: before /full/path and ?querystring as 2 item array.
* @param uri
*/
static part(uri: string): string[];
/**
* Normalize the uri to an abstract uri, using the client settings.
* @param client
* @param uri
*/
static norm(client: ObeliskClient, uri: string, apiVersion?: ApiVersion): string;
static isTPageCompatible(client: ObeliskClient, uri: string, apiVersion?: ApiVersion): boolean;
static isStreamEndpointCompatible(client: ObeliskClient, uri: string, apiVersion?: ApiVersion): boolean;
/**
* Catches the first 40x error, on 401, will redirect once and try to get a new token (refreshing too),
* then retry the caught observable or request. If that doesn't work, the error is thrown anyway.
* @param client ObeliskClient to get token from
* @param request Optional AjaxRequest to retry instead of caught Observable
*/
static catch40xAndRetry<T>(client: ObeliskClient, request?: AjaxRequest): OperatorFunction<T, T>;
/**
* Catches a 504 client and retries the original observable.
* <strong>Hint</strong> Use this to work around listening to SSE channels that don't emit data for a long time.
*/
static catch504AndRetry<T>(): OperatorFunction<T, T>;
/**
* Send an authed AjaxRequest and does RPT handling.
* 1. Get rpt, get new one if needed
* 2. Catches errors once, then throws if not succeeded authed request
* @param client
* @param request
*/
static authRequest(client: ObeliskClient, request: AjaxRequest): Observable<AjaxResponse>;
/**
* First authenticates and gets a new PAT token, then requests a new RPT token, then retries.
*/
private static authAndRetry;
static createUUID(): string;
}