utils-lib-js 1.4.3 → 1.4.4
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/common/request.d.ts +1 -2
- package/dist/common/request.js +24 -28
- package/dist/common/types.d.ts +1 -1
- package/dist/esm/request.d.ts +1 -2
- package/dist/esm/request.js +24 -28
- package/dist/esm/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/common/request.d.ts
CHANGED
|
@@ -28,9 +28,8 @@ declare abstract class RequestInit extends RequestBase implements IRequestInit {
|
|
|
28
28
|
constructor(origin: any);
|
|
29
29
|
abstract fetch(url: any, opts: any): Promise<void>;
|
|
30
30
|
abstract http(url: any, opts: any): Promise<void>;
|
|
31
|
-
initDefaultParams: (
|
|
31
|
+
initDefaultParams: (url: IUrl, { method, query, headers, body, timeout, controller, type, ...others }: {
|
|
32
32
|
[x: string]: any;
|
|
33
|
-
url?: string;
|
|
34
33
|
method?: string;
|
|
35
34
|
query?: {};
|
|
36
35
|
headers?: {};
|
package/dist/common/request.js
CHANGED
|
@@ -176,39 +176,35 @@ var RequestInit = function (_super) {
|
|
|
176
176
|
__extends(RequestInit, _super);
|
|
177
177
|
function RequestInit(origin) {
|
|
178
178
|
var _this = _super.call(this, origin) || this;
|
|
179
|
-
_this.initDefaultParams = function (_a) {
|
|
180
|
-
var _b
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
179
|
+
_this.initDefaultParams = function (url, _a) {
|
|
180
|
+
var _b, _c;
|
|
181
|
+
var _d = _a.method,
|
|
182
|
+
method = _d === void 0 ? "GET" : _d,
|
|
183
|
+
_e = _a.query,
|
|
184
|
+
query = _e === void 0 ? {} : _e,
|
|
185
|
+
_f = _a.headers,
|
|
186
|
+
headers = _f === void 0 ? {} : _f,
|
|
187
|
+
_g = _a.body,
|
|
188
|
+
body = _g === void 0 ? null : _g,
|
|
189
|
+
_h = _a.timeout,
|
|
190
|
+
timeout = _h === void 0 ? 30 * 1000 : _h,
|
|
191
|
+
_j = _a.controller,
|
|
192
|
+
controller = _j === void 0 ? new CustomAbortController() : _j,
|
|
193
|
+
_k = _a.type,
|
|
194
|
+
type = _k === void 0 ? "json" : _k,
|
|
195
|
+
others = __rest(_a, ["method", "query", "headers", "body", "timeout", "controller", "type"]);
|
|
196
|
+
var __params = __assign({ url: url, method: method, headers: headers, body: method === "GET" ? null : (0, index_js_1.jsonToString)(body), timeout: timeout, signal: controller === null || controller === void 0 ? void 0 : controller.signal, controller: controller, type: type, timer: null }, others);
|
|
197
|
+
var params = (_c = (_b = _this.reqFn) === null || _b === void 0 ? void 0 : _b.call(_this, __params)) !== null && _c !== void 0 ? _c : __params;
|
|
198
|
+
params.url = (0, index_js_1.urlJoin)(_this.fixOrigin(url), query);
|
|
199
|
+
return params;
|
|
198
200
|
};
|
|
199
201
|
_this.initFetchParams = function (url, opts) {
|
|
200
|
-
var
|
|
201
|
-
var __p = __assign({ url: url }, opts);
|
|
202
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __p)) !== null && _b !== void 0 ? _b : __p;
|
|
203
|
-
var _temp = _this.initAbort(_this.initDefaultParams(params));
|
|
202
|
+
var _temp = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
204
203
|
return _temp;
|
|
205
204
|
};
|
|
206
205
|
_this.initHttpParams = function (url, opts) {
|
|
207
|
-
var
|
|
208
|
-
var
|
|
209
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __p)) !== null && _b !== void 0 ? _b : __p;
|
|
210
|
-
var _temp = _this.initAbort(_this.initDefaultParams(params));
|
|
211
|
-
var options = parse(params.url, true);
|
|
206
|
+
var _temp = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
207
|
+
var options = parse(_temp.url, true);
|
|
212
208
|
return __assign(__assign({}, _temp), options);
|
|
213
209
|
};
|
|
214
210
|
return _this;
|
package/dist/common/types.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export declare type IRequestBase = {
|
|
|
87
87
|
formatBodyString: (bodyString: string) => IObject<Function>;
|
|
88
88
|
};
|
|
89
89
|
export declare type IRequestInit = {
|
|
90
|
-
initDefaultParams: (opts: IRequestOptions) => any;
|
|
90
|
+
initDefaultParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
91
91
|
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
92
92
|
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
93
93
|
};
|
package/dist/esm/request.d.ts
CHANGED
|
@@ -28,9 +28,8 @@ declare abstract class RequestInit extends RequestBase implements IRequestInit {
|
|
|
28
28
|
constructor(origin: any);
|
|
29
29
|
abstract fetch(url: any, opts: any): Promise<void>;
|
|
30
30
|
abstract http(url: any, opts: any): Promise<void>;
|
|
31
|
-
initDefaultParams: (
|
|
31
|
+
initDefaultParams: (url: IUrl, { method, query, headers, body, timeout, controller, type, ...others }: {
|
|
32
32
|
[x: string]: any;
|
|
33
|
-
url?: string;
|
|
34
33
|
method?: string;
|
|
35
34
|
query?: {};
|
|
36
35
|
headers?: {};
|
package/dist/esm/request.js
CHANGED
|
@@ -172,39 +172,35 @@ var RequestInit = function (_super) {
|
|
|
172
172
|
__extends(RequestInit, _super);
|
|
173
173
|
function RequestInit(origin) {
|
|
174
174
|
var _this = _super.call(this, origin) || this;
|
|
175
|
-
_this.initDefaultParams = function (_a) {
|
|
176
|
-
var _b
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
175
|
+
_this.initDefaultParams = function (url, _a) {
|
|
176
|
+
var _b, _c;
|
|
177
|
+
var _d = _a.method,
|
|
178
|
+
method = _d === void 0 ? "GET" : _d,
|
|
179
|
+
_e = _a.query,
|
|
180
|
+
query = _e === void 0 ? {} : _e,
|
|
181
|
+
_f = _a.headers,
|
|
182
|
+
headers = _f === void 0 ? {} : _f,
|
|
183
|
+
_g = _a.body,
|
|
184
|
+
body = _g === void 0 ? null : _g,
|
|
185
|
+
_h = _a.timeout,
|
|
186
|
+
timeout = _h === void 0 ? 30 * 1000 : _h,
|
|
187
|
+
_j = _a.controller,
|
|
188
|
+
controller = _j === void 0 ? new CustomAbortController() : _j,
|
|
189
|
+
_k = _a.type,
|
|
190
|
+
type = _k === void 0 ? "json" : _k,
|
|
191
|
+
others = __rest(_a, ["method", "query", "headers", "body", "timeout", "controller", "type"]);
|
|
192
|
+
var __params = __assign({ url: url, method: method, headers: headers, body: method === "GET" ? null : jsonToString(body), timeout: timeout, signal: controller === null || controller === void 0 ? void 0 : controller.signal, controller: controller, type: type, timer: null }, others);
|
|
193
|
+
var params = (_c = (_b = _this.reqFn) === null || _b === void 0 ? void 0 : _b.call(_this, __params)) !== null && _c !== void 0 ? _c : __params;
|
|
194
|
+
params.url = urlJoin(_this.fixOrigin(url), query);
|
|
195
|
+
return params;
|
|
194
196
|
};
|
|
195
197
|
_this.initFetchParams = function (url, opts) {
|
|
196
|
-
var
|
|
197
|
-
var __p = __assign({ url: url }, opts);
|
|
198
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __p)) !== null && _b !== void 0 ? _b : __p;
|
|
199
|
-
var _temp = _this.initAbort(_this.initDefaultParams(params));
|
|
198
|
+
var _temp = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
200
199
|
return _temp;
|
|
201
200
|
};
|
|
202
201
|
_this.initHttpParams = function (url, opts) {
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __p)) !== null && _b !== void 0 ? _b : __p;
|
|
206
|
-
var _temp = _this.initAbort(_this.initDefaultParams(params));
|
|
207
|
-
var options = parse(params.url, true);
|
|
202
|
+
var _temp = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
203
|
+
var options = parse(_temp.url, true);
|
|
208
204
|
return __assign(__assign({}, _temp), options);
|
|
209
205
|
};
|
|
210
206
|
return _this;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export declare type IRequestBase = {
|
|
|
87
87
|
formatBodyString: (bodyString: string) => IObject<Function>;
|
|
88
88
|
};
|
|
89
89
|
export declare type IRequestInit = {
|
|
90
|
-
initDefaultParams: (opts: IRequestOptions) => any;
|
|
90
|
+
initDefaultParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
91
91
|
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
92
92
|
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
93
93
|
};
|