@inversealtruism/cairn-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ type FetchLike = typeof fetch;
2
+ interface HttpOptions {
3
+ /** Base URL with no trailing slash, e.g. "https://cairn-substrate.com". */
4
+ baseUrl: string;
5
+ /** Custom fetch (defaults to global fetch). */
6
+ fetch?: FetchLike;
7
+ /** Per-request timeout in ms (default 15000). */
8
+ timeoutMs?: number;
9
+ /** Extra headers sent on every request. */
10
+ headers?: Record<string, string>;
11
+ }
12
+ declare class Http {
13
+ readonly baseUrl: string;
14
+ private readonly _fetch;
15
+ private readonly timeoutMs;
16
+ private readonly headers;
17
+ constructor(opts: HttpOptions);
18
+ /** Build an absolute URL from a path + optional query params. */
19
+ url(path: string, query?: Record<string, string | number | boolean | undefined>): string;
20
+ private raw;
21
+ getJson<T = unknown>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
22
+ postJson<T = unknown>(path: string, body: unknown, headers?: Record<string, string>): Promise<T>;
23
+ /** GET raw bytes (for content retrieval). Returns null on 404. */
24
+ getBytes(path: string): Promise<{
25
+ bytes: Uint8Array;
26
+ headers: Headers;
27
+ } | null>;
28
+ }
29
+
30
+ export { type FetchLike as F, Http as H, type HttpOptions as a };