@bubblesjs/request 0.0.9 → 0.0.10
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/dist/index.d.ts +11 -13
- package/dist/index.js +3 -2
- package/package.json +19 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { AlovaGlobalCacheAdapter, AlovaRequestAdapter, GlobalCacheConfig, StatesExport, StatesHook } from "alova";
|
|
2
2
|
import { FetchRequestInit } from "alova/fetch";
|
|
3
|
-
|
|
4
3
|
//#region src/index.d.ts
|
|
5
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
5
|
type HeaderValue = string | number | boolean | null | undefined | (() => MaybePromise<string | number | boolean | null | undefined>);
|
|
7
6
|
type StatusMatcher<RE> = number | number[] | ((status: number, response: RE) => boolean);
|
|
8
7
|
type CodeMatcher = Array<number | string>;
|
|
9
|
-
interface StatusMap<RE = unknown> {
|
|
8
|
+
export interface StatusMap<RE = unknown> {
|
|
10
9
|
success?: StatusMatcher<RE>;
|
|
11
10
|
unAuthorized?: StatusMatcher<RE>;
|
|
12
11
|
}
|
|
13
|
-
interface CodeMap {
|
|
12
|
+
export interface CodeMap {
|
|
14
13
|
success?: CodeMatcher;
|
|
15
14
|
unAuthorized?: CodeMatcher;
|
|
16
15
|
}
|
|
17
|
-
interface RequestMeta {
|
|
16
|
+
export interface RequestMeta {
|
|
18
17
|
isWrapped?: boolean;
|
|
19
18
|
isTransformResponse?: boolean;
|
|
20
19
|
isShowSuccessMessage?: boolean;
|
|
21
20
|
isShowErrorMessage?: boolean;
|
|
22
21
|
}
|
|
23
|
-
interface BaseRequestOption<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> extends RequestMeta {
|
|
22
|
+
export interface BaseRequestOption<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> extends RequestMeta {
|
|
24
23
|
baseUrl?: string;
|
|
25
24
|
timeout?: number;
|
|
26
25
|
commonHeaders?: () => Record<string, HeaderValue>;
|
|
@@ -42,11 +41,10 @@ interface BaseRequestOption<RC extends object = FetchRequestInit, RE = Response,
|
|
|
42
41
|
l2Cache?: AlovaGlobalCacheAdapter;
|
|
43
42
|
storageAdapter?: AlovaGlobalCacheAdapter;
|
|
44
43
|
}
|
|
45
|
-
type baseRequestOption<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = BaseRequestOption<RC, RE, RH, SE>;
|
|
46
|
-
type RequestOption<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = BaseRequestOption<RC, RE, RH, SE>;
|
|
47
|
-
declare function createInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>>(option?: RequestOption<RC, RE, RH, SE>): import("alova").Alova<import("alova").AlovaGenerics<any, any, RC, RE, RH, AlovaGlobalCacheAdapter, AlovaGlobalCacheAdapter, SE>>;
|
|
48
|
-
type RequestInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = ReturnType<typeof createInstance<RC, RE, RH, SE>>;
|
|
49
|
-
type DualCallInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = RequestInstance<RC, RE, RH, SE> & ((option?: RequestOption<RC, RE, RH, SE>) => RequestInstance<RC, RE, RH, SE>);
|
|
50
|
-
declare function createDualCallInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>>(baseConfig: BaseRequestOption<RC, RE, RH, SE>): DualCallInstance<RC, RE, RH, SE>;
|
|
51
|
-
//#endregion
|
|
52
|
-
export { BaseRequestOption, CodeMap, DualCallInstance, RequestInstance, RequestMeta, RequestOption, StatusMap, baseRequestOption, createDualCallInstance, createInstance };
|
|
44
|
+
export type baseRequestOption<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = BaseRequestOption<RC, RE, RH, SE>;
|
|
45
|
+
export type RequestOption<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = BaseRequestOption<RC, RE, RH, SE>;
|
|
46
|
+
export declare function createInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>>(option?: RequestOption<RC, RE, RH, SE>): import("alova").Alova<import("alova").AlovaGenerics<any, any, RC, RE, RH, AlovaGlobalCacheAdapter, AlovaGlobalCacheAdapter, SE>>;
|
|
47
|
+
export type RequestInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = ReturnType<typeof createInstance<RC, RE, RH, SE>>;
|
|
48
|
+
export type DualCallInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>> = RequestInstance<RC, RE, RH, SE> & ((option?: RequestOption<RC, RE, RH, SE>) => RequestInstance<RC, RE, RH, SE>);
|
|
49
|
+
export declare function createDualCallInstance<RC extends object = FetchRequestInit, RE = Response, RH = Headers, SE extends StatesExport<any> = StatesExport<any>>(baseConfig: BaseRequestOption<RC, RE, RH, SE>): DualCallInstance<RC, RE, RH, SE>;
|
|
50
|
+
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,7 @@ function resolveConfig(option) {
|
|
|
103
103
|
}
|
|
104
104
|
function createInstance(option = {}) {
|
|
105
105
|
const config = resolveConfig(option);
|
|
106
|
-
|
|
106
|
+
const alovaOptions = {
|
|
107
107
|
baseURL: config.baseUrl,
|
|
108
108
|
timeout: config.timeout,
|
|
109
109
|
cacheFor: config.cacheFor,
|
|
@@ -156,7 +156,8 @@ function createInstance(option = {}) {
|
|
|
156
156
|
return Promise.reject(error);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
}
|
|
159
|
+
};
|
|
160
|
+
return createAlova(alovaOptions);
|
|
160
161
|
}
|
|
161
162
|
function createDualCallInstance(baseConfig) {
|
|
162
163
|
const defaultInstance = createInstance(baseConfig);
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bubblesjs/request",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.10",
|
|
5
4
|
"private": false,
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "git+https://github.com/435012357/bubblesjs/issues"
|
|
7
|
+
},
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
10
|
"url": "git+https://github.com/435012357/bubblesjs.git"
|
|
9
11
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"module": "./dist/index.js",
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
14
18
|
"exports": {
|
|
15
19
|
".": {
|
|
@@ -17,30 +21,26 @@
|
|
|
17
21
|
"import": "./dist/index.js"
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@bubblesjs/utils": "^0.0.
|
|
29
|
+
"@bubblesjs/utils": "^0.0.12"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
|
|
33
|
+
"vite-plus": "1.1.0",
|
|
34
|
+
"vitest": "^5.0.4"
|
|
26
35
|
},
|
|
27
36
|
"peerDependencies": {
|
|
28
37
|
"alova": "^3.5.1"
|
|
29
38
|
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
|
|
32
|
-
"vitest": "4.1.10",
|
|
33
|
-
"vite-plus": "0.2.4"
|
|
34
|
-
},
|
|
35
39
|
"peerDependenciesMeta": {
|
|
36
40
|
"alova": {
|
|
37
41
|
"optional": true
|
|
38
42
|
}
|
|
39
43
|
},
|
|
40
|
-
"publishConfig": {
|
|
41
|
-
"access": "public",
|
|
42
|
-
"registry": "https://registry.npmjs.org/"
|
|
43
|
-
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "vp pack",
|
|
46
46
|
"dev": "vp pack --watch",
|