UNPKG

@tragedy-labs/sprite

Version:

A TypeScript driver for ArcadeDB

45 lines (44 loc) 2.73 kB
import { SpriteTransaction } from '../transaction/SpriteTransaction.js'; import { SpriteRestBody } from './SpriteBody.js'; import { Routes as DatabaseRoutes } from '../database/routes.js'; import { Routes as ServerRoutes } from '../server/routes.js'; import { Session } from '../session/Session.js'; type ApiRoutes = DatabaseRoutes | ServerRoutes | string; /** * Static methods for making RESTful API calls. */ declare class Rest { /** * Make a {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET `GET`} request. * @param route The route (key) to target in the request. * @param session The `Session` to target in the request. * @returns A promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/API/Response `Response`} object. */ static get(route: ApiRoutes, session: Session): Promise<Response>; /** * Make a {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET `GET`} request in which a JSON response is expected. * @param route The route (key) to target in the request. * @param session The `Session` to target in the request. * @returns The json response from the ArcadeDB Server. */ static getJson<T>(route: ApiRoutes, session: Session): Promise<T>; /** * Make a {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST `POST`} request. * @param session The `Session` to target in the request. * @param endpoint The relative endpoint of request. * @param body The {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/body body} to include in the request. * @param headers The {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/headers headers} to include in the request. * @returns A promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/API/Response `Response`} object. */ static post(route: ApiRoutes, body: SpriteRestBody, session: Session, transaction?: SpriteTransaction): Promise<Response>; /** * Make a {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST `POST`} request in which a JSON response is expected. * @param route The route (key) to target in the request. * @param body The {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/body body} to include in the request. * @param session The `DatabaseSession` to target in the request. * @param transaction The `SpriteTransaction` to target in the request. * @returns The json response from the ArcadeDB Server. */ static postJson<T>(route: ApiRoutes, body: SpriteRestBody, session: Session, transaction?: SpriteTransaction): Promise<T>; } export { Rest };