@gopowerteam/request 0.1.21 → 0.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.cjs CHANGED
@@ -1,344 +1,250 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => {
21
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
- return value;
23
- };
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
24
2
 
25
- // src/index.ts
26
- var src_exports = {};
27
- __export(src_exports, {
28
- PluginLifecycle: () => PluginLifecycle,
29
- RequestGenerateType: () => RequestGenerateType,
30
- RequestMethod: () => RequestMethod,
31
- RequestService: () => RequestService,
32
- setup: () => setup
33
- });
34
- module.exports = __toCommonJS(src_exports);
3
+ //#region src/interfaces/request-generate.interface.ts
4
+ let RequestGenerateType = /* @__PURE__ */ function(RequestGenerateType) {
5
+ RequestGenerateType["Request"] = "TO_REQUEST";
6
+ RequestGenerateType["URL"] = "TO_URL";
7
+ return RequestGenerateType;
8
+ }({});
35
9
 
36
- // src/interfaces/request-generate.interface.ts
37
- var RequestGenerateType = /* @__PURE__ */ ((RequestGenerateType2) => {
38
- RequestGenerateType2["Request"] = "TO_REQUEST";
39
- RequestGenerateType2["URL"] = "TO_URL";
40
- return RequestGenerateType2;
41
- })(RequestGenerateType || {});
10
+ //#endregion
11
+ //#region src/interfaces/request-plugin.interface.ts
12
+ let PluginLifecycle = /* @__PURE__ */ function(PluginLifecycle) {
13
+ PluginLifecycle["before"] = "before";
14
+ PluginLifecycle["after"] = "after";
15
+ PluginLifecycle["catch"] = "catch";
16
+ return PluginLifecycle;
17
+ }({});
42
18
 
43
- // src/interfaces/request-plugin.interface.ts
44
- var PluginLifecycle = /* @__PURE__ */ ((PluginLifecycle2) => {
45
- PluginLifecycle2["before"] = "before";
46
- PluginLifecycle2["after"] = "after";
47
- PluginLifecycle2["catch"] = "catch";
48
- return PluginLifecycle2;
49
- })(PluginLifecycle || {});
19
+ //#endregion
20
+ //#region src/interfaces/request-send.interface.ts
21
+ /**
22
+ * 请求方法类型
23
+ */
24
+ let RequestMethod = /* @__PURE__ */ function(RequestMethod) {
25
+ RequestMethod["Get"] = "GET";
26
+ RequestMethod["Post"] = "POST";
27
+ RequestMethod["Put"] = "PUT";
28
+ RequestMethod["Delete"] = "DELETE";
29
+ RequestMethod["Options"] = "OPTIONS";
30
+ RequestMethod["Head"] = "HEAD";
31
+ RequestMethod["Patch"] = "PATCH";
32
+ return RequestMethod;
33
+ }({});
50
34
 
51
- // src/interfaces/request-send.interface.ts
52
- var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
53
- RequestMethod2["Get"] = "GET";
54
- RequestMethod2["Post"] = "POST";
55
- RequestMethod2["Put"] = "PUT";
56
- RequestMethod2["Delete"] = "DELETE";
57
- RequestMethod2["Options"] = "OPTIONS";
58
- RequestMethod2["Head"] = "HEAD";
59
- RequestMethod2["Patch"] = "PATCH";
60
- return RequestMethod2;
61
- })(RequestMethod || {});
62
-
63
- // src/utils/query-string.ts
35
+ //#endregion
36
+ //#region src/utils/query-string.ts
37
+ /**
38
+ * 编码字符串
39
+ */
64
40
  function encodeValue(value, encode) {
65
- if (!encode)
66
- return value;
67
- return encodeURIComponent(value);
41
+ if (!encode) return value;
42
+ return encodeURIComponent(value);
68
43
  }
44
+ /**
45
+ * 处理嵌套对象的键名
46
+ */
69
47
  function getKeyWithDot(key, childKey, allowDots) {
70
- return allowDots ? `${key}.${childKey}` : `${key}[${childKey}]`;
48
+ return allowDots ? `${key}.${childKey}` : `${key}[${childKey}]`;
71
49
  }
50
+ /**
51
+ * 递归处理对象值
52
+ */
72
53
  function processValue(value, options, parentKey = "") {
73
- const result = [];
74
- if (value === null || value === void 0) {
75
- if (!options.skipNulls) {
76
- result.push(`${parentKey}=`);
77
- }
78
- return result;
79
- }
80
- if (Array.isArray(value)) {
81
- if (options.arrayFormat === "comma") {
82
- const filteredValues = value.filter((item) => item !== null && item !== void 0);
83
- if (filteredValues.length > 0) {
84
- const commaValue = filteredValues.map(
85
- (item) => typeof item === "object" ? JSON.stringify(item) : item.toString()
86
- ).join(",");
87
- const shouldEncode = options.encode !== false;
88
- const encodedValue = encodeValue(commaValue, shouldEncode);
89
- result.push(`${parentKey}=${encodedValue}`);
90
- }
91
- } else {
92
- value.forEach((item, index) => {
93
- let itemKey;
94
- const shouldEncode = options.encode !== false;
95
- if (options.arrayFormat === "indices") {
96
- itemKey = parentKey ? `${parentKey}[${index}]` : `[${index}]`;
97
- } else if (options.arrayFormat === "brackets") {
98
- itemKey = parentKey ? `${parentKey}[]` : "[]";
99
- } else {
100
- itemKey = parentKey;
101
- }
102
- if (typeof item === "object" && item !== null) {
103
- result.push(...processValue(item, options, itemKey));
104
- } else {
105
- const encodedValue = encodeValue(item.toString(), shouldEncode);
106
- result.push(`${itemKey}=${encodedValue}`);
107
- }
108
- });
109
- }
110
- } else if (typeof value === "object") {
111
- Object.keys(value).forEach((childKey) => {
112
- const fullKey = parentKey ? getKeyWithDot(parentKey, childKey, options.allowDots || false) : childKey;
113
- result.push(...processValue(value[childKey], options, fullKey));
114
- });
115
- } else {
116
- const shouldEncode = options.encode !== false;
117
- const encodedValue = encodeValue(value.toString(), shouldEncode);
118
- const encodedKey = options.encodeValuesOnly ? parentKey : encodeValue(parentKey, shouldEncode);
119
- result.push(`${encodedKey}=${encodedValue}`);
120
- }
121
- return result;
54
+ const result = [];
55
+ if (value === null || value === void 0) {
56
+ if (!options.skipNulls) result.push(`${parentKey}=`);
57
+ return result;
58
+ }
59
+ if (Array.isArray(value)) if (options.arrayFormat === "comma") {
60
+ const filteredValues = value.filter((item) => item !== null && item !== void 0);
61
+ if (filteredValues.length > 0) {
62
+ const encodedValue = encodeValue(filteredValues.map((item) => typeof item === "object" ? JSON.stringify(item) : item.toString()).join(","), options.encode !== false);
63
+ result.push(`${parentKey}=${encodedValue}`);
64
+ }
65
+ } else value.forEach((item, index) => {
66
+ let itemKey;
67
+ const shouldEncode = options.encode !== false;
68
+ if (options.arrayFormat === "indices") itemKey = parentKey ? `${parentKey}[${index}]` : `[${index}]`;
69
+ else if (options.arrayFormat === "brackets") itemKey = parentKey ? `${parentKey}[]` : "[]";
70
+ else itemKey = parentKey;
71
+ if (typeof item === "object" && item !== null) result.push(...processValue(item, options, itemKey));
72
+ else {
73
+ const encodedValue = encodeValue(item.toString(), shouldEncode);
74
+ result.push(`${itemKey}=${encodedValue}`);
75
+ }
76
+ });
77
+ else if (typeof value === "object") Object.keys(value).forEach((childKey) => {
78
+ const fullKey = parentKey ? getKeyWithDot(parentKey, childKey, options.allowDots || false) : childKey;
79
+ result.push(...processValue(value[childKey], options, fullKey));
80
+ });
81
+ else {
82
+ const shouldEncode = options.encode !== false;
83
+ const encodedValue = encodeValue(value.toString(), shouldEncode);
84
+ const encodedKey = options.encodeValuesOnly ? parentKey : encodeValue(parentKey, shouldEncode);
85
+ result.push(`${encodedKey}=${encodedValue}`);
86
+ }
87
+ return result;
122
88
  }
89
+ /**
90
+ * 将对象序列化为查询字符串
91
+ */
123
92
  function stringify(obj, options = {}) {
124
- const {
125
- arrayFormat = "indices",
126
- skipNulls = true,
127
- allowDots = true,
128
- encodeValuesOnly = false,
129
- encode = true,
130
- addQueryPrefix = false
131
- } = options;
132
- if (!obj || typeof obj !== "object") {
133
- return options.addQueryPrefix ? "?" : "";
134
- }
135
- const parts = [];
136
- Object.keys(obj).forEach((key) => {
137
- const value = obj[key];
138
- const processedValues = processValue(value, {
139
- arrayFormat,
140
- skipNulls,
141
- allowDots,
142
- encodeValuesOnly,
143
- encode,
144
- addQueryPrefix
145
- }, key);
146
- parts.push(...processedValues);
147
- });
148
- const queryString = parts.join("&");
149
- return addQueryPrefix ? queryString ? `?${queryString}` : "?" : queryString;
93
+ const { arrayFormat = "indices", skipNulls = true, allowDots = true, encodeValuesOnly = false, encode = true, addQueryPrefix = false } = options;
94
+ if (!obj || typeof obj !== "object") return options.addQueryPrefix ? "?" : "";
95
+ const parts = [];
96
+ Object.keys(obj).forEach((key) => {
97
+ const value = obj[key];
98
+ const processedValues = processValue(value, {
99
+ arrayFormat,
100
+ skipNulls,
101
+ allowDots,
102
+ encodeValuesOnly,
103
+ encode,
104
+ addQueryPrefix
105
+ }, key);
106
+ parts.push(...processedValues);
107
+ });
108
+ const queryString = parts.join("&");
109
+ return addQueryPrefix ? queryString ? `?${queryString}` : "?" : queryString;
150
110
  }
151
111
 
152
- // src/request-service.ts
153
- var _RequestService = class {
154
- /**
155
- * 获取服务请求单例
156
- */
157
- static getInstance() {
158
- if (this.instance) {
159
- return this.instance;
160
- }
161
- return new _RequestService();
162
- }
163
- /**
164
- * 获取RequestAdatper
165
- * @returns RequestAdapter
166
- */
167
- getRequestAdapter() {
168
- if (!_RequestService.config.adapter) {
169
- throw new Error("\u8BF7\u68C0\u67E5\u662F\u5426\u914D\u7F6E\u8BF7\u6C42Adatper");
170
- }
171
- return _RequestService.config.adapter;
172
- }
173
- /**
174
- * 执行前置插件逻辑
175
- * @param plugins
176
- * @param options
177
- */
178
- async execRequestPlugin(plugins = [], options) {
179
- const extraParams = {};
180
- const appendParams = (params) => {
181
- Object.assign(extraParams, params || {});
182
- };
183
- for (const plugin of _RequestService.config.plugins) {
184
- if (plugin.before) {
185
- await plugin.before(options, appendParams);
186
- }
187
- }
188
- for (const plugin of plugins) {
189
- if (plugin.before) {
190
- await plugin.before(options, appendParams);
191
- }
192
- }
193
- return extraParams;
194
- }
195
- /**
196
- * 执行前置插件逻辑
197
- */
198
- execResponsePlugin(leftcycle, plugins = [], options, response) {
199
- plugins.forEach((plugin) => {
200
- const leftcycleFn = plugin[leftcycle];
201
- if (leftcycleFn) {
202
- leftcycleFn.bind(plugin)(response, options);
203
- }
204
- });
205
- _RequestService.config.plugins.forEach((plugin) => {
206
- const leftcycleFn = plugin[leftcycle];
207
- if (leftcycleFn) {
208
- leftcycleFn.bind(plugin)(response, options);
209
- }
210
- });
211
- }
212
- /**
213
- * 转换请求路径
214
- */
215
- parseRequestPath(path, paramsPath, service) {
216
- if (service) {
217
- path = `/${service}/${path}`.replace(/\/{2,3}/g, "/");
218
- }
219
- if (paramsPath) {
220
- return Object.entries(paramsPath).reduce(
221
- (r, [key, value]) => r.replace(`{${key}}`, value.toString()),
222
- path
223
- );
224
- } else {
225
- return path;
226
- }
227
- }
228
- /**
229
- * 开始请求
230
- * @param adapter
231
- * @param options
232
- * @returns Promise
233
- */
234
- startRequest(adapter, options, extraParams) {
235
- return adapter.request({
236
- baseURL: _RequestService.config.gateway,
237
- pathURL: this.parseRequestPath(
238
- options.path,
239
- options.paramsPath,
240
- options.service
241
- ),
242
- method: options.method,
243
- headers: options.headers || {},
244
- paramsQuery: options.paramsQuery,
245
- paramsBody: options.paramsBody,
246
- extraParams
247
- });
248
- }
249
- /**
250
- * 执行拦截器
251
- * @param response 请求响应对象
252
- * @returns Promise
253
- */
254
- execInterceptors(response, hasException = false) {
255
- const interceptors = _RequestService.config?.interceptors;
256
- if (!interceptors?.status || !interceptors?.error || !interceptors?.success || !interceptors?.exception) {
257
- throw new Error("\u8BF7\u68C0\u67E5\u62E6\u622A\u5668\u914D\u7F6E");
258
- }
259
- const status = interceptors.status.exec(response) && !hasException;
260
- if (hasException) {
261
- interceptors.exception.exec(response);
262
- }
263
- if (status) {
264
- return Promise.resolve(interceptors.success.exec(response));
265
- } else {
266
- return Promise.reject(interceptors.error.exec(response));
267
- }
268
- }
269
- /**
270
- * 发送请求
271
- * @param {RequestSendOptions} options 请求选项
272
- * @param {RequestPlugin[]} requestPlugins 请求插件
273
- * @returns Promise
274
- */
275
- async send(options, requestPlugins = []) {
276
- if (!_RequestService.config) {
277
- throw new Error("\u8BF7\u68C0\u67E5\u8BF7\u6C42\u914D\u7F6E\u662F\u5426\u5B8C\u6210");
278
- }
279
- let hasException = false;
280
- const adapter = this.getRequestAdapter();
281
- const plugins = requestPlugins.filter(Boolean);
282
- const extraParams = await this.execRequestPlugin(plugins, options);
283
- const response = await this.startRequest(adapter, options, extraParams).then((response2) => adapter.transformResponse(response2)).catch((exception) => {
284
- hasException = true;
285
- return adapter.transformException(exception);
286
- });
287
- if (!hasException) {
288
- this.execResponsePlugin("after" /* after */, plugins, options, response);
289
- } else {
290
- this.execResponsePlugin("catch" /* catch */, plugins, options, response);
291
- }
292
- return this.execInterceptors(response, hasException);
293
- }
294
- /**
295
- * 生成请求路径
296
- * @param {RequestSendOptions} options 请求选项
297
- * @param {RequestPlugin[]} plugins 请求插件
298
- * @returns string
299
- */
300
- toURL(options, plugins = []) {
301
- if (!_RequestService.config) {
302
- throw new Error("\u8BF7\u68C0\u67E5\u8BF7\u6C42\u914D\u7F6E\u662F\u5426\u5B8C\u6210");
303
- }
304
- if (plugins && plugins.length) {
305
- this.execRequestPlugin(
306
- plugins.filter(Boolean),
307
- options
308
- );
309
- }
310
- const baseURL = _RequestService.config.gateway;
311
- const pathURL = this.parseRequestPath(
312
- options.path,
313
- options.paramsPath,
314
- options.service
315
- );
316
- const queryString = stringify(options.paramsQuery || {}, {
317
- arrayFormat: "repeat",
318
- skipNulls: true,
319
- allowDots: true,
320
- encodeValuesOnly: true,
321
- encode: true,
322
- addQueryPrefix: true,
323
- ..._RequestService.config.qs || {}
324
- });
325
- return `${baseURL}${pathURL}${queryString}`;
326
- }
112
+ //#endregion
113
+ //#region src/request-service.ts
114
+ var RequestService = class RequestService {
115
+ static config;
116
+ static instance;
117
+ /**
118
+ * 获取服务请求单例
119
+ */
120
+ static getInstance() {
121
+ if (this.instance) return this.instance;
122
+ return new RequestService();
123
+ }
124
+ /**
125
+ * 获取RequestAdatper
126
+ * @returns RequestAdapter
127
+ */
128
+ getRequestAdapter() {
129
+ if (!RequestService.config.adapter) throw new Error("请检查是否配置请求Adatper");
130
+ return RequestService.config.adapter;
131
+ }
132
+ /**
133
+ * 执行前置插件逻辑
134
+ * @param plugins
135
+ * @param options
136
+ */
137
+ async execRequestPlugin(plugins = [], options) {
138
+ const extraParams = {};
139
+ const appendParams = (params) => {
140
+ Object.assign(extraParams, params || {});
141
+ };
142
+ for (const plugin of RequestService.config.plugins) if (plugin.before) await plugin.before(options, appendParams);
143
+ for (const plugin of plugins) if (plugin.before) await plugin.before(options, appendParams);
144
+ return extraParams;
145
+ }
146
+ /**
147
+ * 执行前置插件逻辑
148
+ */
149
+ execResponsePlugin(leftcycle, plugins = [], options, response) {
150
+ plugins.forEach((plugin) => {
151
+ const leftcycleFn = plugin[leftcycle];
152
+ if (leftcycleFn) leftcycleFn.bind(plugin)(response, options);
153
+ });
154
+ RequestService.config.plugins.forEach((plugin) => {
155
+ const leftcycleFn = plugin[leftcycle];
156
+ if (leftcycleFn) leftcycleFn.bind(plugin)(response, options);
157
+ });
158
+ }
159
+ /**
160
+ * 转换请求路径
161
+ */
162
+ parseRequestPath(path, paramsPath, service) {
163
+ if (service) path = `/${service}/${path}`.replace(/\/{2,3}/g, "/");
164
+ if (paramsPath) return Object.entries(paramsPath).reduce((r, [key, value]) => r.replace(`{${key}}`, value.toString()), path);
165
+ else return path;
166
+ }
167
+ /**
168
+ * 开始请求
169
+ * @param adapter
170
+ * @param options
171
+ * @returns Promise
172
+ */
173
+ startRequest(adapter, options, extraParams) {
174
+ return adapter.request({
175
+ baseURL: RequestService.config.gateway,
176
+ pathURL: this.parseRequestPath(options.path, options.paramsPath, options.service),
177
+ method: options.method,
178
+ headers: options.headers || {},
179
+ paramsQuery: options.paramsQuery,
180
+ paramsBody: options.paramsBody,
181
+ extraParams
182
+ });
183
+ }
184
+ /**
185
+ * 执行拦截器
186
+ * @param response 请求响应对象
187
+ * @returns Promise
188
+ */
189
+ execInterceptors(response, hasException = false) {
190
+ const interceptors = RequestService.config?.interceptors;
191
+ if (!interceptors?.status || !interceptors?.error || !interceptors?.success || !interceptors?.exception) throw new Error("请检查拦截器配置");
192
+ const status = interceptors.status.exec(response) && !hasException;
193
+ if (hasException) interceptors.exception.exec(response);
194
+ if (status) return Promise.resolve(interceptors.success.exec(response));
195
+ else return Promise.reject(interceptors.error.exec(response));
196
+ }
197
+ /**
198
+ * 发送请求
199
+ * @param {RequestSendOptions} options 请求选项
200
+ * @param {RequestPlugin[]} requestPlugins 请求插件
201
+ * @returns Promise
202
+ */
203
+ async send(options, requestPlugins = []) {
204
+ if (!RequestService.config) throw new Error("请检查请求配置是否完成");
205
+ let hasException = false;
206
+ const adapter = this.getRequestAdapter();
207
+ const plugins = requestPlugins.filter(Boolean);
208
+ const extraParams = await this.execRequestPlugin(plugins, options);
209
+ const response = await this.startRequest(adapter, options, extraParams).then((response) => adapter.transformResponse(response)).catch((exception) => {
210
+ hasException = true;
211
+ return adapter.transformException(exception);
212
+ });
213
+ if (!hasException) this.execResponsePlugin(PluginLifecycle.after, plugins, options, response);
214
+ else this.execResponsePlugin(PluginLifecycle.catch, plugins, options, response);
215
+ return this.execInterceptors(response, hasException);
216
+ }
217
+ /**
218
+ * 生成请求路径
219
+ * @param {RequestSendOptions} options 请求选项
220
+ * @param {RequestPlugin[]} plugins 请求插件
221
+ * @returns string
222
+ */
223
+ toURL(options, plugins = []) {
224
+ if (!RequestService.config) throw new Error("请检查请求配置是否完成");
225
+ if (plugins && plugins.length) this.execRequestPlugin(plugins.filter(Boolean), options);
226
+ return `${RequestService.config.gateway}${this.parseRequestPath(options.path, options.paramsPath, options.service)}${stringify(options.paramsQuery || {}, {
227
+ arrayFormat: "repeat",
228
+ skipNulls: true,
229
+ allowDots: true,
230
+ encodeValuesOnly: true,
231
+ encode: true,
232
+ addQueryPrefix: true,
233
+ ...RequestService.config.qs || {}
234
+ })}`;
235
+ }
327
236
  };
328
- var RequestService = _RequestService;
329
- __publicField(RequestService, "config");
330
- __publicField(RequestService, "instance");
331
237
 
332
- // src/request-setup.ts
238
+ //#endregion
239
+ //#region src/request-setup.ts
333
240
  function setup(config) {
334
- RequestService.config = config;
335
- RequestService.config?.adapter?.injectConfig?.(config);
241
+ RequestService.config = config;
242
+ RequestService.config?.adapter?.injectConfig?.(config);
336
243
  }
337
- // Annotate the CommonJS export names for ESM import in node:
338
- 0 && (module.exports = {
339
- PluginLifecycle,
340
- RequestGenerateType,
341
- RequestMethod,
342
- RequestService,
343
- setup
344
- });
244
+
245
+ //#endregion
246
+ exports.PluginLifecycle = PluginLifecycle;
247
+ exports.RequestGenerateType = RequestGenerateType;
248
+ exports.RequestMethod = RequestMethod;
249
+ exports.RequestService = RequestService;
250
+ exports.setup = setup;
@@ -0,0 +1,71 @@
1
+ import { a as RequestSetupConfig, c as RequestLifecycle, d as RequestMethod, f as RequestSendOptions, i as RequestAdapterOptions, l as RequestPlugin, n as AdapterResponseHeaders, o as ResponseInterceptor, r as RequestAdapter, s as PluginLifecycle, t as AdapterResponse, u as ResponseLifecycle } from "./request-adapter.interface-Cr5s4kIp.cjs";
2
+
3
+ //#region src/interfaces/request-generate.interface.d.ts
4
+ declare enum RequestGenerateType {
5
+ Request = "TO_REQUEST",
6
+ URL = "TO_URL"
7
+ }
8
+ interface RequestGenerateOptions {
9
+ type?: RequestGenerateType;
10
+ }
11
+ //#endregion
12
+ //#region src/request-service.d.ts
13
+ declare class RequestService {
14
+ static config: RequestSetupConfig;
15
+ static instance: RequestService;
16
+ /**
17
+ * 获取服务请求单例
18
+ */
19
+ static getInstance(): RequestService;
20
+ /**
21
+ * 获取RequestAdatper
22
+ * @returns RequestAdapter
23
+ */
24
+ private getRequestAdapter;
25
+ /**
26
+ * 执行前置插件逻辑
27
+ * @param plugins
28
+ * @param options
29
+ */
30
+ private execRequestPlugin;
31
+ /**
32
+ * 执行前置插件逻辑
33
+ */
34
+ private execResponsePlugin;
35
+ /**
36
+ * 转换请求路径
37
+ */
38
+ private parseRequestPath;
39
+ /**
40
+ * 开始请求
41
+ * @param adapter
42
+ * @param options
43
+ * @returns Promise
44
+ */
45
+ private startRequest;
46
+ /**
47
+ * 执行拦截器
48
+ * @param response 请求响应对象
49
+ * @returns Promise
50
+ */
51
+ private execInterceptors;
52
+ /**
53
+ * 发送请求
54
+ * @param {RequestSendOptions} options 请求选项
55
+ * @param {RequestPlugin[]} requestPlugins 请求插件
56
+ * @returns Promise
57
+ */
58
+ send(options: RequestSendOptions, requestPlugins?: (RequestPlugin | undefined)[]): Promise<any>;
59
+ /**
60
+ * 生成请求路径
61
+ * @param {RequestSendOptions} options 请求选项
62
+ * @param {RequestPlugin[]} plugins 请求插件
63
+ * @returns string
64
+ */
65
+ toURL(options: RequestSendOptions, plugins?: (RequestPlugin | undefined)[]): string;
66
+ }
67
+ //#endregion
68
+ //#region src/request-setup.d.ts
69
+ declare function setup(config: RequestSetupConfig): void;
70
+ //#endregion
71
+ export { AdapterResponse, AdapterResponseHeaders, PluginLifecycle, RequestAdapter, RequestAdapterOptions, RequestGenerateOptions, RequestGenerateType, RequestLifecycle, RequestMethod, RequestPlugin, RequestSendOptions, RequestService, RequestSetupConfig, ResponseInterceptor, ResponseLifecycle, setup };