@chzky/reqwest 0.1.1 → 0.1.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/esm/lib/core/mod.d.ts +1 -1
- package/esm/lib/core/mod.d.ts.map +1 -1
- package/esm/lib/helper/response/output.d.ts +11 -0
- package/esm/lib/helper/response/output.d.ts.map +1 -1
- package/esm/lib/helper/response/output.js +13 -0
- package/package.json +1 -1
- package/script/lib/core/mod.d.ts +1 -1
- package/script/lib/core/mod.d.ts.map +1 -1
- package/script/lib/helper/response/output.d.ts +11 -0
- package/script/lib/helper/response/output.d.ts.map +1 -1
- package/script/lib/helper/response/output.js +14 -0
package/esm/lib/core/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @module core */
|
|
2
|
-
export type { RequestInterceptor, ReqwestInterceptor, ResponseInterceptor, } from './interface.js';
|
|
2
|
+
export type { RequestInterceptor, ReqwestInterceptor, ReqwestInterface, ResponseInterceptor, } from './interface.js';
|
|
3
3
|
export * from './class.js';
|
|
4
4
|
export * from './factor.js';
|
|
5
5
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/lib/core/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/lib/core/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -7,6 +7,17 @@ import { CheckingError } from '@chzky/core';
|
|
|
7
7
|
@category Helper
|
|
8
8
|
*/
|
|
9
9
|
export declare function output_validate<T>(schema: zod.Schema<T>): ResponseInterceptor<unknown, zod.infer<typeof schema>, CheckingError>;
|
|
10
|
+
/** ### `output_infer` : 对输出类型进行类型推断
|
|
11
|
+
+ 适用于懒得写返回值类型推断的场景
|
|
12
|
+
@example
|
|
13
|
+
```ts
|
|
14
|
+
const response = await reqwest.response( output_infer<{name:string}> ).dispatch()
|
|
15
|
+
assert.type<typeof response>().equal<{name:string}>()
|
|
16
|
+
```
|
|
17
|
+
@type `Interceptor` - `Response`
|
|
18
|
+
@category Helper
|
|
19
|
+
*/
|
|
20
|
+
export declare function output_infer<T>(): ResponseInterceptor<unknown, T, never>;
|
|
10
21
|
/** ## `response_map` : 对返回类型进行`map`操作
|
|
11
22
|
+ 用于`AxiosResponse`的业务场景映射
|
|
12
23
|
+ 用于返回数据映射
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,aAAa,EAAM,MAAM,aAAa,CAAA;AAE/C;;;;EAIE;AACF,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GACnB,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,aAAa,CAAC,CAQvE;AAED;;;;EAIE;AACF,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAE3F"}
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,aAAa,EAAM,MAAM,aAAa,CAAA;AAE/C;;;;EAIE;AACF,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GACnB,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,aAAa,CAAC,CAQvE;AAED;;;;;;;;;EASE;AACF,wBAAgB,YAAY,CAAC,CAAC,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAExE;AAED;;;;EAIE;AACF,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAE3F"}
|
|
@@ -14,6 +14,19 @@ export function output_validate(schema) {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
/** ### `output_infer` : 对输出类型进行类型推断
|
|
18
|
+
+ 适用于懒得写返回值类型推断的场景
|
|
19
|
+
@example
|
|
20
|
+
```ts
|
|
21
|
+
const response = await reqwest.response( output_infer<{name:string}> ).dispatch()
|
|
22
|
+
assert.type<typeof response>().equal<{name:string}>()
|
|
23
|
+
```
|
|
24
|
+
@type `Interceptor` - `Response`
|
|
25
|
+
@category Helper
|
|
26
|
+
*/
|
|
27
|
+
export function output_infer() {
|
|
28
|
+
return response => Ok(response);
|
|
29
|
+
}
|
|
17
30
|
/** ## `response_map` : 对返回类型进行`map`操作
|
|
18
31
|
+ 用于`AxiosResponse`的业务场景映射
|
|
19
32
|
+ 用于返回数据映射
|
package/package.json
CHANGED
package/script/lib/core/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @module core */
|
|
2
|
-
export type { RequestInterceptor, ReqwestInterceptor, ResponseInterceptor, } from './interface.js';
|
|
2
|
+
export type { RequestInterceptor, ReqwestInterceptor, ReqwestInterface, ResponseInterceptor, } from './interface.js';
|
|
3
3
|
export * from './class.js';
|
|
4
4
|
export * from './factor.js';
|
|
5
5
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/lib/core/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/lib/core/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -7,6 +7,17 @@ import { CheckingError } from '@chzky/core';
|
|
|
7
7
|
@category Helper
|
|
8
8
|
*/
|
|
9
9
|
export declare function output_validate<T>(schema: zod.Schema<T>): ResponseInterceptor<unknown, zod.infer<typeof schema>, CheckingError>;
|
|
10
|
+
/** ### `output_infer` : 对输出类型进行类型推断
|
|
11
|
+
+ 适用于懒得写返回值类型推断的场景
|
|
12
|
+
@example
|
|
13
|
+
```ts
|
|
14
|
+
const response = await reqwest.response( output_infer<{name:string}> ).dispatch()
|
|
15
|
+
assert.type<typeof response>().equal<{name:string}>()
|
|
16
|
+
```
|
|
17
|
+
@type `Interceptor` - `Response`
|
|
18
|
+
@category Helper
|
|
19
|
+
*/
|
|
20
|
+
export declare function output_infer<T>(): ResponseInterceptor<unknown, T, never>;
|
|
10
21
|
/** ## `response_map` : 对返回类型进行`map`操作
|
|
11
22
|
+ 用于`AxiosResponse`的业务场景映射
|
|
12
23
|
+ 用于返回数据映射
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,aAAa,EAAM,MAAM,aAAa,CAAA;AAE/C;;;;EAIE;AACF,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GACnB,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,aAAa,CAAC,CAQvE;AAED;;;;EAIE;AACF,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAE3F"}
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,aAAa,EAAM,MAAM,aAAa,CAAA;AAE/C;;;;EAIE;AACF,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GACnB,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,aAAa,CAAC,CAQvE;AAED;;;;;;;;;EASE;AACF,wBAAgB,YAAY,CAAC,CAAC,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAExE;AAED;;;;EAIE;AACF,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAE3F"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.output_validate = output_validate;
|
|
4
|
+
exports.output_infer = output_infer;
|
|
4
5
|
exports.response_map = response_map;
|
|
5
6
|
const core_1 = require("@chzky/core");
|
|
6
7
|
/** ### `output_validate` : 对输出类型进行类型校验
|
|
@@ -18,6 +19,19 @@ function output_validate(schema) {
|
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
}
|
|
22
|
+
/** ### `output_infer` : 对输出类型进行类型推断
|
|
23
|
+
+ 适用于懒得写返回值类型推断的场景
|
|
24
|
+
@example
|
|
25
|
+
```ts
|
|
26
|
+
const response = await reqwest.response( output_infer<{name:string}> ).dispatch()
|
|
27
|
+
assert.type<typeof response>().equal<{name:string}>()
|
|
28
|
+
```
|
|
29
|
+
@type `Interceptor` - `Response`
|
|
30
|
+
@category Helper
|
|
31
|
+
*/
|
|
32
|
+
function output_infer() {
|
|
33
|
+
return response => (0, core_1.Ok)(response);
|
|
34
|
+
}
|
|
21
35
|
/** ## `response_map` : 对返回类型进行`map`操作
|
|
22
36
|
+ 用于`AxiosResponse`的业务场景映射
|
|
23
37
|
+ 用于返回数据映射
|