@verii/http-client 1.2.0-pre.1777243490 → 1.2.0-pre.1777246593
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.
- package/index.d.ts +70 -0
- package/package.json +3 -2
package/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Dispatcher, cacheStores } from 'undici';
|
|
2
|
+
|
|
3
|
+
export type HttpRawBody = Dispatcher.ResponseData['body'];
|
|
4
|
+
|
|
5
|
+
export type HttpCacheStore = InstanceType<typeof cacheStores.MemoryCacheStore>;
|
|
6
|
+
|
|
7
|
+
export interface HttpClientContext {
|
|
8
|
+
traceId?: string;
|
|
9
|
+
log?: {
|
|
10
|
+
info?: (...args: any[]) => void;
|
|
11
|
+
error?: (...args: any[]) => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface HttpRequestOptions {
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
searchParams?: URLSearchParams;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HttpResponse<T = unknown> {
|
|
21
|
+
rawBody: HttpRawBody;
|
|
22
|
+
statusCode: number;
|
|
23
|
+
resHeaders: Record<string, string | string[] | undefined>;
|
|
24
|
+
json(): Promise<T>;
|
|
25
|
+
text(): Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface HttpClient {
|
|
29
|
+
get<T = unknown>(
|
|
30
|
+
url: string,
|
|
31
|
+
reqOptions?: HttpRequestOptions,
|
|
32
|
+
): Promise<HttpResponse<T>>;
|
|
33
|
+
post<TBody = unknown, TResponse = unknown>(
|
|
34
|
+
url: string,
|
|
35
|
+
payload?: TBody,
|
|
36
|
+
reqOptions?: HttpRequestOptions,
|
|
37
|
+
): Promise<HttpResponse<TResponse>>;
|
|
38
|
+
delete<T = unknown>(
|
|
39
|
+
url: string,
|
|
40
|
+
reqOptions?: HttpRequestOptions,
|
|
41
|
+
): Promise<HttpResponse<T>>;
|
|
42
|
+
responseType: 'promise';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface HttpClientInitOptions {
|
|
46
|
+
prefixUrl?: string;
|
|
47
|
+
isTest?: boolean;
|
|
48
|
+
bearerToken?: string;
|
|
49
|
+
requestTimeout?: number;
|
|
50
|
+
traceIdHeader?: string;
|
|
51
|
+
customHeaders?: Record<string, string>;
|
|
52
|
+
cache?: HttpCacheStore;
|
|
53
|
+
tokensEndpoint?: string;
|
|
54
|
+
clientId?: string;
|
|
55
|
+
clientSecret?: string;
|
|
56
|
+
scopes?: string[];
|
|
57
|
+
audience?: string;
|
|
58
|
+
tlsRejectUnauthorized?: boolean;
|
|
59
|
+
caCertificate?: string;
|
|
60
|
+
clientCertificate?: string;
|
|
61
|
+
clientKey?: string;
|
|
62
|
+
clientCertificatePassword?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function initHttpClient(options: HttpClientInitOptions): {
|
|
66
|
+
(context: HttpClientContext): HttpClient;
|
|
67
|
+
(host: string, context: HttpClientContext): HttpClient;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export function initCache(): HttpCacheStore;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verii/http-client",
|
|
3
|
-
"version": "1.2.0-pre.
|
|
3
|
+
"version": "1.2.0-pre.1777246593",
|
|
4
4
|
"description": "HTTP client for Verii network",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
7
8
|
"publishConfig": {
|
|
8
9
|
"access": "public"
|
|
9
10
|
},
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"lib"
|
|
44
45
|
]
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b28187707886028c7a0e2ba40d3f933b29d01da1"
|
|
47
48
|
}
|