@be-link/http 1.1.0 → 1.2.0

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 CHANGED
@@ -3,11 +3,12 @@
3
3
  *
4
4
  * 共比邻 HTTP 请求库
5
5
  * 提供简洁的 HTTP 请求封装,支持时间同步和 Token 加密
6
+ * 支持 Axios 和 Taro.request 两种请求引擎
6
7
  *
7
8
  * @packageDocumentation
8
9
  * @module @be-link/http
9
10
  *
10
- * @example 基本用法
11
+ * @example 基本用法(Axios 模式)
11
12
  * ```ts
12
13
  * import { beLinkHttp } from '@be-link/http';
13
14
  *
@@ -20,6 +21,23 @@
20
21
  * const data = await beLinkHttp.get('/api/users');
21
22
  * ```
22
23
  *
24
+ * @example Taro 小程序用法
25
+ * ```ts
26
+ * import { beLinkHttp } from '@be-link/http';
27
+ * import Taro from '@tarojs/taro';
28
+ *
29
+ * // 初始化
30
+ * beLinkHttp.init({
31
+ * adapter: 'taro',
32
+ * taroRequest: Taro.request,
33
+ * baseURL: 'https://api.example.com',
34
+ * getToken: () => Taro.getStorageSync('token'),
35
+ * });
36
+ *
37
+ * // 发起请求(使用方式完全一致)
38
+ * const data = await beLinkHttp.get('/api/users');
39
+ * ```
40
+ *
23
41
  * @example 完整配置
24
42
  * ```ts
25
43
  * import { beLinkHttp } from '@be-link/http';
@@ -54,6 +72,8 @@
54
72
  * @see {@link BeLinkHttp}
55
73
  */
56
74
  export { beLinkHttp, BeLinkHttp } from './BeLinkHttp';
75
+ export { AxiosAdapter } from './adapters/AxiosAdapter';
76
+ export { TaroAdapter, createTaroFetch } from './adapters/TaroAdapter';
57
77
  export type {
58
78
  /** 请求配置选项 */
59
79
  RequestOptions,
@@ -65,6 +85,20 @@ EncryptionConfig,
65
85
  ApiResponse,
66
86
  /** 标准化 API 响应结构(带泛型 data) */
67
87
  IApiResponse, } from './types';
88
+ export type {
89
+ /** 适配器请求配置 */
90
+ AdapterRequestConfig,
91
+ /** 适配器响应结构 */
92
+ AdapterResponse,
93
+ /** HTTP 适配器接口 */
94
+ HttpAdapter,
95
+ /** 适配器构造配置 */
96
+ AdapterConfig,
97
+ /** Taro 适配器构造配置 */
98
+ TaroAdapterConfig,
99
+ /** Taro.request 函数类型 */
100
+ TaroRequestFunction, } from './adapters/types';
101
+ export type { FetchFunction } from './services/TimeSyncService';
68
102
  /**
69
103
  * 默认导出 beLinkHttp 单例
70
104
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAMH;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAMtD,YAAY;AACV,aAAa;AACb,cAAc;AACd,aAAa;AACb,cAAc;AACd,WAAW;AACX,gBAAgB;AAChB,eAAe;AACf,WAAW;AACX,6BAA6B;AAC7B,YAAY,GACb,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAMH;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAMtE,YAAY;AACV,aAAa;AACb,cAAc;AACd,aAAa;AACb,cAAc;AACd,WAAW;AACX,gBAAgB;AAChB,eAAe;AACf,WAAW;AACX,6BAA6B;AAC7B,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,YAAY;AACV,cAAc;AACd,oBAAoB;AACpB,cAAc;AACd,eAAe;AACf,iBAAiB;AACjB,WAAW;AACX,cAAc;AACd,aAAa;AACb,mBAAmB;AACnB,iBAAiB;AACjB,wBAAwB;AACxB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAMhE;;GAEG;AACH,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}