@oino-ts/types 0.17.4 → 0.18.1
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.
|
@@ -23,7 +23,7 @@ export interface OINOHttpRequestInit extends OINORequestInit {
|
|
|
23
23
|
url?: URL;
|
|
24
24
|
method?: string;
|
|
25
25
|
headers?: OINOHeadersInit;
|
|
26
|
-
|
|
26
|
+
body?: string | Buffer | Uint8Array | object | null | undefined;
|
|
27
27
|
requestType?: OINOContentType;
|
|
28
28
|
responseType?: OINOContentType;
|
|
29
29
|
multipartBoundary?: string;
|
|
@@ -36,7 +36,7 @@ export declare class OINOHttpRequest extends OINORequest {
|
|
|
36
36
|
readonly url?: URL;
|
|
37
37
|
readonly method: string;
|
|
38
38
|
readonly headers: OINOHeaders;
|
|
39
|
-
readonly
|
|
39
|
+
readonly body: string | Buffer | Uint8Array | object | null | undefined;
|
|
40
40
|
readonly requestType: OINOContentType;
|
|
41
41
|
readonly responseType: OINOContentType;
|
|
42
42
|
readonly multipartBoundary?: string;
|
|
@@ -49,9 +49,31 @@ export declare class OINOHttpRequest extends OINORequest {
|
|
|
49
49
|
*
|
|
50
50
|
*/
|
|
51
51
|
constructor(init: OINOHttpRequestInit);
|
|
52
|
+
/**
|
|
53
|
+
* Creates a `OINOHttpRequest` from a Fetch API `Request` object.
|
|
54
|
+
*
|
|
55
|
+
* @param request Fetch request
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
52
58
|
static fromFetchRequest(request: Request): Promise<OINOHttpRequest>;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Returns the request data as a text string.
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
bodyAsText(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the request data parsed as JSON object.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
bodyAsParsedJson(): any;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the request data as URLSearchParams (form data).
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
bodyAsFormData(): URLSearchParams;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the request data as Buffer.
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
bodyAsBuffer(): Buffer;
|
|
57
79
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { OINOHeaders, OINOHeadersInit } from ".";
|
|
2
3
|
export interface OINOResultInit {
|
|
3
4
|
success?: boolean;
|
|
@@ -88,7 +89,7 @@ export declare class OINOResult {
|
|
|
88
89
|
printLog(): string;
|
|
89
90
|
}
|
|
90
91
|
export interface OINOHttpResultInit extends OINOResultInit {
|
|
91
|
-
body?: string;
|
|
92
|
+
body?: string | Buffer;
|
|
92
93
|
headers?: OINOHeadersInit;
|
|
93
94
|
expires?: number;
|
|
94
95
|
lastModified?: number;
|
|
@@ -99,7 +100,7 @@ export interface OINOHttpResultInit extends OINOResultInit {
|
|
|
99
100
|
export declare class OINOHttpResult extends OINOResult {
|
|
100
101
|
private _etag;
|
|
101
102
|
/** HTTP body data */
|
|
102
|
-
readonly body: string;
|
|
103
|
+
readonly body: string | Buffer;
|
|
103
104
|
/** HTTP headers */
|
|
104
105
|
readonly headers: OINOHeaders;
|
|
105
106
|
/** HTTP cache expiration value
|
|
@@ -126,4 +127,31 @@ export declare class OINOHttpResult extends OINOResult {
|
|
|
126
127
|
* @param headers HTTP headers (overrides existing values)
|
|
127
128
|
*/
|
|
128
129
|
getFetchResponse(headers?: OINOHeadersInit): Response;
|
|
130
|
+
/**
|
|
131
|
+
* Create from a Response object from the result values.
|
|
132
|
+
*
|
|
133
|
+
* @param response fetch Response object
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
static fromFetchResponse(response: Response): Promise<OINOHttpResult>;
|
|
137
|
+
/**
|
|
138
|
+
* Returns the request body as a text string.
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
bodyAsText(): string;
|
|
142
|
+
/**
|
|
143
|
+
* Returns the request body parsed as JSON object.
|
|
144
|
+
*
|
|
145
|
+
*/
|
|
146
|
+
bodyAsParsedJson(): any;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the request body as URLSearchParams (form body).
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
bodyAsFormData(): URLSearchParams;
|
|
152
|
+
/**
|
|
153
|
+
* Returns the request body as Buffer.
|
|
154
|
+
*
|
|
155
|
+
*/
|
|
156
|
+
bodyAsBuffer(): Buffer;
|
|
129
157
|
}
|