import { ApiAuthenticationConfig, ApiConfig, Query, RequestType, ResponseType, TupleTypes, OptionsType, ResponseTypes, AccessTokenResponse } from './types'; export declare const DEFAULT_BASE_URL = "https://rest.spinque.com/"; /** * Send queries to the Spinque Query API using fetch. */ export declare class Api { /** * URL to the Spinque Query API deployment. * * @default https://rest.spinque.com/ */ baseUrl: string; /** * Version of the Spinque Query API deployment. * * @default 4 */ version?: string | undefined; /** * Name of the Spinque workspace that should be addressed. * The Spinque Desk administrator working on your project knowns this value. */ workspace?: string; /** * Name of the API that is provided by the workspace. * The Spinque Desk administrator working on your project knowns this value. */ api?: string; /** * Name of the configuration of the Spinque workspace that should be used. * Usually, this is something like 'production', 'development' or 'default'. * The Spinque Desk administrator working on your project knowns this value. * * @default default */ config?: string | undefined; private _authentication?; private _authenticator?; private _isInitialized; constructor(apiConfig?: ApiConfig); get accessToken(): string | undefined; /** * Getter for authentication configuration */ get authentication(): ApiAuthenticationConfig | undefined; /** * Getter for authentication configuration */ get apiConfig(): ApiConfig; /** * Fetch a url directly, circumventing all {@link Api} configuration except authentication. * Useful when wanting to tap into @spinque/query-api's authentication service while also * wanting to construct your own URLs. This function does not check whether the provided URL * is a valid request to Spinque, take caution. */ fetchUrl(url: string, requestInit?: RequestInit): Promise; /** * Fetch a Query (or array of Queries). Takes optional RequestOptions and RequestType into account. * Optionally the `fetch` RequestInit can be passed (see https://developer.mozilla.org/en-US/docs/Web/API/RequestInit). */ fetch, T extends TupleTypes[] = TupleTypes[], R extends RequestType = RequestType.Results>(queries: Query | Query[], options?: O, requestType?: R, requestInit?: RequestInit): Promise>; /** * Sends an authenticated request. * * Automatically retries once on 401 for Client Credentials. Fails with * {@link UnauthorizedError} for other auth flows or if the retry also 401s. */ private _authenticatedFetch; fetchAccessToken(): Promise; /** * Handle the response of a fetch to Spinque Query API. */ private handleResponse; }