@done-coding/request-ofetch 0.0.1-alpha.1 → 0.0.1-alpha.2
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/package.json +1 -1
- package/types/types.d.ts +30 -2
- package/types/main.d.ts +0 -17
package/package.json
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -8,15 +8,43 @@ interface ResponseMap {
|
|
|
8
8
|
stream: ReadableStream<Uint8Array>;
|
|
9
9
|
}
|
|
10
10
|
type ResponseType = keyof ResponseMap | "json";
|
|
11
|
+
interface RequestInit {
|
|
12
|
+
/** A BodyInit object or null to set request's body. */
|
|
13
|
+
body?: BodyInit | null;
|
|
14
|
+
/** A string indicating how the request will interact with the browser's cache to set request's cache. */
|
|
15
|
+
cache?: RequestCache;
|
|
16
|
+
/** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
|
|
17
|
+
credentials?: RequestCredentials;
|
|
18
|
+
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
|
|
19
|
+
headers?: HeadersInit;
|
|
20
|
+
/** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
|
|
21
|
+
integrity?: string;
|
|
22
|
+
/** A boolean to set request's keepalive. */
|
|
23
|
+
keepalive?: boolean;
|
|
24
|
+
/** A string to set request's method. */
|
|
25
|
+
method?: string;
|
|
26
|
+
/** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
|
|
27
|
+
mode?: RequestMode;
|
|
28
|
+
/** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
|
|
29
|
+
redirect?: RequestRedirect;
|
|
30
|
+
/** A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. */
|
|
31
|
+
referrer?: string;
|
|
32
|
+
/** A referrer policy to set request's referrerPolicy. */
|
|
33
|
+
referrerPolicy?: ReferrerPolicy;
|
|
34
|
+
/** An AbortSignal to set request's signal. */
|
|
35
|
+
signal?: AbortSignal | null;
|
|
36
|
+
/** Can only be null. Used to disassociate request from any Window. */
|
|
37
|
+
window?: null;
|
|
38
|
+
}
|
|
11
39
|
/** fetch选项 */
|
|
12
|
-
export interface FetchOptions {
|
|
40
|
+
export interface FetchOptions<R extends ResponseType = ResponseType> extends Omit<RequestInit, "body"> {
|
|
13
41
|
baseURL?: string;
|
|
14
42
|
body?: RequestInit["body"] | Record<string, any>;
|
|
15
43
|
ignoreResponseError?: boolean;
|
|
16
44
|
params?: Record<string, any>;
|
|
17
45
|
query?: Record<string, any>;
|
|
18
46
|
parseResponse?: (responseText: string) => any;
|
|
19
|
-
responseType?:
|
|
47
|
+
responseType?: R;
|
|
20
48
|
/**
|
|
21
49
|
* @experimental Set to "half" to enable duplex streaming.
|
|
22
50
|
* Will be automatically set to "half" when using a ReadableStream as body.
|
package/types/main.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Options } from "@done-coding/request-base";
|
|
2
|
-
import type { $Fetch } from "ofetch";
|
|
3
|
-
import type { FetchOptions, FetchResponse } from "./types";
|
|
4
|
-
export * from "@done-coding/request-base";
|
|
5
|
-
export interface XFetchOptions extends FetchOptions {
|
|
6
|
-
url: string;
|
|
7
|
-
}
|
|
8
|
-
export interface XFetchResponse<S> extends FetchResponse<S> {
|
|
9
|
-
data: S;
|
|
10
|
-
}
|
|
11
|
-
export declare const createRequest: <S>({ basePath, timeout, beforeRequest, networkSuccessCodeList, isSuccessNetworkCode, Fetch, instanceCreateConfig, ...otherOpt }: Omit<Options<XFetchOptions, XFetchResponse<S>>, "issue"> & {
|
|
12
|
-
beforeRequest?: ((config: XFetchOptions) => XFetchOptions | Promise<XFetchOptions>) | undefined;
|
|
13
|
-
/** 实例创建选项 */
|
|
14
|
-
instanceCreateConfig?: Omit<FetchOptions, "timeout" | "baseURL" | "onRequest" | "onRequestError" | "onResponse" | "onResponseError"> | undefined;
|
|
15
|
-
/** 兼容nuxt 故构造函数外部传入 */
|
|
16
|
-
Fetch: $Fetch;
|
|
17
|
-
}) => <D>(apiConfig: import("@done-coding/request-base").ApiConfig<XFetchOptions>, debug?: boolean | undefined) => Promise<import("@done-coding/request-base").RequestResult<D>>;
|