chore: switch package manager to bun and create docs for codebase

This commit is contained in:
Tasnim Kabir Sadik
2026-05-16 17:27:47 +06:00
parent b35df41f08
commit a69118aa2d
16 changed files with 1008 additions and 2360 deletions

View File

@ -1,5 +1,6 @@
import { TimeoutError, throwErrorFromResponse } from "../exceptions.js";
/** Configuration for the low-level HTTP client. */
export interface HttpClientConfig {
/** API origin used for all relative request paths. */
baseUrl: string;
@ -60,27 +61,70 @@ export class HttpClient {
}
}
/** Sends a GET request and parses the JSON response. */
/**
* Sends a GET request and parses the JSON response.
*
* @param path - API path relative to the configured base URL.
* @param opts - Optional query, header, auth, timeout, and cancellation settings.
* @returns Parsed JSON response.
* @throws TimeoutError when the configured timeout aborts the request.
* @throws WrennError subclasses for unsuccessful responses.
*/
get<T>(path: string, opts?: RequestOptions): Promise<T> {
return this.request<T>("GET", path, undefined, opts);
}
/** Sends a POST request with an optional JSON body. */
/**
* Sends a POST request with an optional JSON body.
*
* @param path - API path relative to the configured base URL.
* @param body - Optional JSON request body.
* @param opts - Optional query, header, auth, timeout, and cancellation settings.
* @returns Parsed JSON response.
* @throws TimeoutError when the configured timeout aborts the request.
* @throws WrennError subclasses for unsuccessful responses.
*/
post<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<T> {
return this.request<T>("POST", path, body, opts);
}
/** Sends a PATCH request with an optional JSON body. */
/**
* Sends a PATCH request with an optional JSON body.
*
* @param path - API path relative to the configured base URL.
* @param body - Optional JSON request body.
* @param opts - Optional query, header, auth, timeout, and cancellation settings.
* @returns Parsed JSON response.
* @throws TimeoutError when the configured timeout aborts the request.
* @throws WrennError subclasses for unsuccessful responses.
*/
patch<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<T> {
return this.request<T>("PATCH", path, body, opts);
}
/** Sends a PUT request with an optional JSON body. */
/**
* Sends a PUT request with an optional JSON body.
*
* @param path - API path relative to the configured base URL.
* @param body - Optional JSON request body.
* @param opts - Optional query, header, auth, timeout, and cancellation settings.
* @returns Parsed JSON response.
* @throws TimeoutError when the configured timeout aborts the request.
* @throws WrennError subclasses for unsuccessful responses.
*/
put<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<T> {
return this.request<T>("PUT", path, body, opts);
}
/** Sends a DELETE request and expects no response body. */
/**
* Sends a DELETE request and expects no response body.
*
* @param path - API path relative to the configured base URL.
* @param opts - Optional query, header, auth, timeout, and cancellation settings.
* @returns Resolves when the response succeeds.
* @throws TimeoutError when the configured timeout aborts the request.
* @throws WrennError subclasses for unsuccessful responses.
*/
delete(path: string, opts?: RequestOptions): Promise<void> {
return this.request<void>("DELETE", path, undefined, opts);
}