@done-coding/request-ofetch 1.2.0 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/request-ofetch",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "请求ofetch配置 支持nuxt",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "es/index.mjs",
@@ -59,12 +59,12 @@
59
59
  },
60
60
  "sideEffects": [],
61
61
  "dependencies": {
62
- "@done-coding/request-base": "^1.2.0",
62
+ "@done-coding/request-base": "^1.2.1",
63
63
  "lodash.get": "^4.4.2",
64
64
  "lodash.omit": "^4.5.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "ofetch": "^1.3.4"
68
68
  },
69
- "gitHead": "56a2c5c34bdb49db2bb6dea755c3b4df51138a5e"
69
+ "gitHead": "3a53f2267b8c6b57132200a076a2570f74872fb5"
70
70
  }
package/types/index.d.ts CHANGED
@@ -1 +1,59 @@
1
- export * from "./main";
1
+ import type { $Fetch } from 'ofetch';
2
+ import { ApiConfig } from '@done-coding/request-base';
3
+ import { Options } from '@done-coding/request-base';
4
+ import { RequestResult } from '@done-coding/request-base';
5
+
6
+ export declare const createRequest: <S>({ basePath, timeout, beforeRequest, networkSuccessCodeList, isSuccessNetworkCode, Fetch, instanceCreateConfig, ...otherOpt }: Omit<Options<XFetchOptions, S>, "issue"> & {
7
+ beforeRequest?: ((config: XFetchOptions) => XFetchOptions | Promise<XFetchOptions>) | undefined;
8
+ /** 实例创建选项 */
9
+ instanceCreateConfig?: Omit<FetchOptions, "timeout" | "baseURL" | "onRequest" | "onRequestError" | "onResponse" | "onResponseError"> | undefined;
10
+ /** 兼容nuxt 故构造函数外部传入 */
11
+ Fetch: $Fetch;
12
+ }) => <D>(apiConfig: ApiConfig<XFetchOptions>, debug?: boolean | undefined) => Promise<RequestResult<D>>;
13
+
14
+ /** fetch选项 */
15
+ declare interface FetchOptions {
16
+ baseURL?: string;
17
+ body?: RequestInit["body"] | Record<string, any>;
18
+ headers?: HeadersInit;
19
+ ignoreResponseError?: boolean;
20
+ params?: Record<string, any>;
21
+ query?: Record<string, any>;
22
+ parseResponse?: (responseText: string) => any;
23
+ responseType?: ResponseType_2;
24
+ /**
25
+ * @experimental Set to "half" to enable duplex streaming.
26
+ * Will be automatically set to "half" when using a ReadableStream as body.
27
+ * https://fetch.spec.whatwg.org/#enumdef-requestduplex
28
+ */
29
+ duplex?: "half" | undefined;
30
+ /** timeout in milliseconds */
31
+ timeout?: number;
32
+ retry?: number | false;
33
+ /** Delay between retries in milliseconds. */
34
+ retryDelay?: number;
35
+ /** Default is [408, 409, 425, 429, 500, 502, 503, 504] */
36
+ retryStatusCodes?: number[];
37
+ method?: string;
38
+ }
39
+
40
+ /**
41
+ * TODO: ofetch有导出类型 FetchOptions & FetchResponse,此处最后编译时报移植相关问题 此处类型复制其类型
42
+ */
43
+ declare interface ResponseMap {
44
+ blob: Blob;
45
+ text: string;
46
+ arrayBuffer: ArrayBuffer;
47
+ stream: ReadableStream<Uint8Array>;
48
+ }
49
+
50
+ declare type ResponseType_2 = keyof ResponseMap | "json";
51
+
52
+ export declare interface XFetchOptions extends FetchOptions {
53
+ url: string;
54
+ }
55
+
56
+
57
+ export * from "@done-coding/request-base";
58
+
59
+ export { }
package/types/main.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { Options } from "@done-coding/request-base";
2
- import type { $Fetch } from "ofetch";
3
- import type { FetchOptions } from "./types";
4
- export * from "@done-coding/request-base";
5
- export interface XFetchOptions extends FetchOptions {
6
- url: string;
7
- }
8
- export declare const createRequest: <S>({ basePath, timeout, beforeRequest, networkSuccessCodeList, isSuccessNetworkCode, Fetch, instanceCreateConfig, ...otherOpt }: Omit<Options<XFetchOptions, S>, "issue"> & {
9
- beforeRequest?: ((config: XFetchOptions) => XFetchOptions | Promise<XFetchOptions>) | undefined;
10
- /** 实例创建选项 */
11
- instanceCreateConfig?: Omit<FetchOptions, "timeout" | "baseURL" | "onRequest" | "onRequestError" | "onResponse" | "onResponseError"> | undefined;
12
- /** 兼容nuxt 故构造函数外部传入 */
13
- Fetch: $Fetch;
14
- }) => <D>(apiConfig: import("@done-coding/request-base").ApiConfig<XFetchOptions>, debug?: boolean | undefined) => Promise<import("@done-coding/request-base").RequestResult<D>>;
package/types/types.d.ts DELETED
@@ -1,36 +0,0 @@
1
- /**
2
- * TODO: ofetch有导出类型 FetchOptions & FetchResponse,此处最后编译时报移植相关问题 此处类型复制其类型
3
- */
4
- interface ResponseMap {
5
- blob: Blob;
6
- text: string;
7
- arrayBuffer: ArrayBuffer;
8
- stream: ReadableStream<Uint8Array>;
9
- }
10
- type ResponseType = keyof ResponseMap | "json";
11
- /** fetch选项 */
12
- export interface FetchOptions {
13
- baseURL?: string;
14
- body?: RequestInit["body"] | Record<string, any>;
15
- headers?: HeadersInit;
16
- ignoreResponseError?: boolean;
17
- params?: Record<string, any>;
18
- query?: Record<string, any>;
19
- parseResponse?: (responseText: string) => any;
20
- responseType?: ResponseType;
21
- /**
22
- * @experimental Set to "half" to enable duplex streaming.
23
- * Will be automatically set to "half" when using a ReadableStream as body.
24
- * https://fetch.spec.whatwg.org/#enumdef-requestduplex
25
- */
26
- duplex?: "half" | undefined;
27
- /** timeout in milliseconds */
28
- timeout?: number;
29
- retry?: number | false;
30
- /** Delay between retries in milliseconds. */
31
- retryDelay?: number;
32
- /** Default is [408, 409, 425, 429, 500, 502, 503, 504] */
33
- retryStatusCodes?: number[];
34
- method?: string;
35
- }
36
- export {};