feat: add low-level Wrenn client resources

Implement WrennClient with typed resource mappings for auth, account,
API keys, users, teams, capsules, files, snapshots, hosts, and channels.
Add endpoint mapping tests plus live integration tess that authenticate
with WRENN_TEST_EMAIL/WRENN_TEST_PASS and use WRENN_API_KEY for API-key
scoped endpoints
This commit is contained in:
Tasnim Kabir Sadik
2026-05-09 18:05:53 +06:00
parent 5b3f2741a3
commit f1522eaa0b
7 changed files with 2120 additions and 183 deletions

View File

@ -29,6 +29,8 @@ export interface RequestOptions {
signal?: AbortSignal;
/** Return response text instead of parsing JSON. */
asText?: boolean;
/** Fetch redirect behavior. Defaults to the runtime fetch default. */
redirect?: RequestRedirect;
}
/** Thin `fetch` wrapper with Wrenn authentication and error mapping. */
@ -137,6 +139,29 @@ export class HttpClient {
return res.body;
}
/**
* Sends a request and returns the raw `Response` object.
*
* This is intended for endpoints that intentionally return non-JSON responses,
* such as OAuth redirects. Unlike {@link request}, this method does not map
* non-OK statuses to SDK errors.
*
* @param method - HTTP method to use.
* @param path - API path relative to the configured base URL.
* @param body - Optional JSON request body.
* @param opts - Optional query, header, auth, timeout, and redirect settings.
* @returns Raw fetch response.
* @throws TimeoutError When the configured timeout aborts the request.
*/
response(
method: string,
path: string,
body?: unknown,
opts?: RequestOptions,
): Promise<Response> {
return this.rawRequest(method, path, body, opts);
}
/**
* Sends a request and parses the response as JSON unless `asText` is set.
*
@ -188,6 +213,7 @@ export class HttpClient {
method,
headers: { ...headers, ...opts?.headers },
};
if (opts?.redirect) init.redirect = opts.redirect;
if (body !== undefined) {
init.body = JSON.stringify(body);