utils-lib-js 1.4.2 → 1.4.3
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 +2 -1
- package/dist/common/request.js +26 -22
- package/dist/common/types.d.ts +1 -1
- package/dist/esm/request.d.ts +2 -1
- package/dist/esm/request.js +26 -22
- package/dist/esm/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/common/request.d.ts
CHANGED
|
@@ -28,8 +28,9 @@ 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: (url
|
|
31
|
+
initDefaultParams: ({ url, method, query, headers, body, timeout, controller, type, ...others }: {
|
|
32
32
|
[x: string]: any;
|
|
33
|
+
url?: string;
|
|
33
34
|
method?: string;
|
|
34
35
|
query?: {};
|
|
35
36
|
headers?: {};
|
package/dist/common/request.js
CHANGED
|
@@ -176,36 +176,40 @@ 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 (
|
|
180
|
-
var _b = _a.
|
|
181
|
-
|
|
182
|
-
_c = _a.
|
|
183
|
-
|
|
184
|
-
_d = _a.
|
|
185
|
-
|
|
186
|
-
_e = _a.
|
|
187
|
-
|
|
188
|
-
_f = _a.
|
|
189
|
-
|
|
190
|
-
_g = _a.
|
|
191
|
-
|
|
192
|
-
_h = _a.
|
|
193
|
-
|
|
194
|
-
|
|
179
|
+
_this.initDefaultParams = function (_a) {
|
|
180
|
+
var _b = _a.url,
|
|
181
|
+
url = _b === void 0 ? "/" : _b,
|
|
182
|
+
_c = _a.method,
|
|
183
|
+
method = _c === void 0 ? "GET" : _c,
|
|
184
|
+
_d = _a.query,
|
|
185
|
+
query = _d === void 0 ? {} : _d,
|
|
186
|
+
_e = _a.headers,
|
|
187
|
+
headers = _e === void 0 ? {} : _e,
|
|
188
|
+
_f = _a.body,
|
|
189
|
+
body = _f === void 0 ? null : _f,
|
|
190
|
+
_g = _a.timeout,
|
|
191
|
+
timeout = _g === void 0 ? 30 * 1000 : _g,
|
|
192
|
+
_h = _a.controller,
|
|
193
|
+
controller = _h === void 0 ? new CustomAbortController() : _h,
|
|
194
|
+
_j = _a.type,
|
|
195
|
+
type = _j === void 0 ? "json" : _j,
|
|
196
|
+
others = __rest(_a, ["url", "method", "query", "headers", "body", "timeout", "controller", "type"]);
|
|
195
197
|
return __assign({ url: (0, index_js_1.urlJoin)(_this.fixOrigin(url), query), 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);
|
|
196
198
|
};
|
|
197
199
|
_this.initFetchParams = function (url, opts) {
|
|
198
200
|
var _a, _b;
|
|
199
|
-
var
|
|
200
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this,
|
|
201
|
-
|
|
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));
|
|
204
|
+
return _temp;
|
|
202
205
|
};
|
|
203
206
|
_this.initHttpParams = function (url, opts) {
|
|
204
207
|
var _a, _b;
|
|
205
|
-
var
|
|
206
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this,
|
|
208
|
+
var __p = __assign({ url: url }, opts);
|
|
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));
|
|
207
211
|
var options = parse(params.url, true);
|
|
208
|
-
return __assign(__assign({},
|
|
212
|
+
return __assign(__assign({}, _temp), options);
|
|
209
213
|
};
|
|
210
214
|
return _this;
|
|
211
215
|
}
|
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: (
|
|
90
|
+
initDefaultParams: (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,8 +28,9 @@ 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: (url
|
|
31
|
+
initDefaultParams: ({ url, method, query, headers, body, timeout, controller, type, ...others }: {
|
|
32
32
|
[x: string]: any;
|
|
33
|
+
url?: string;
|
|
33
34
|
method?: string;
|
|
34
35
|
query?: {};
|
|
35
36
|
headers?: {};
|
package/dist/esm/request.js
CHANGED
|
@@ -172,36 +172,40 @@ 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 (
|
|
176
|
-
var _b = _a.
|
|
177
|
-
|
|
178
|
-
_c = _a.
|
|
179
|
-
|
|
180
|
-
_d = _a.
|
|
181
|
-
|
|
182
|
-
_e = _a.
|
|
183
|
-
|
|
184
|
-
_f = _a.
|
|
185
|
-
|
|
186
|
-
_g = _a.
|
|
187
|
-
|
|
188
|
-
_h = _a.
|
|
189
|
-
|
|
190
|
-
|
|
175
|
+
_this.initDefaultParams = function (_a) {
|
|
176
|
+
var _b = _a.url,
|
|
177
|
+
url = _b === void 0 ? "/" : _b,
|
|
178
|
+
_c = _a.method,
|
|
179
|
+
method = _c === void 0 ? "GET" : _c,
|
|
180
|
+
_d = _a.query,
|
|
181
|
+
query = _d === void 0 ? {} : _d,
|
|
182
|
+
_e = _a.headers,
|
|
183
|
+
headers = _e === void 0 ? {} : _e,
|
|
184
|
+
_f = _a.body,
|
|
185
|
+
body = _f === void 0 ? null : _f,
|
|
186
|
+
_g = _a.timeout,
|
|
187
|
+
timeout = _g === void 0 ? 30 * 1000 : _g,
|
|
188
|
+
_h = _a.controller,
|
|
189
|
+
controller = _h === void 0 ? new CustomAbortController() : _h,
|
|
190
|
+
_j = _a.type,
|
|
191
|
+
type = _j === void 0 ? "json" : _j,
|
|
192
|
+
others = __rest(_a, ["url", "method", "query", "headers", "body", "timeout", "controller", "type"]);
|
|
191
193
|
return __assign({ url: urlJoin(_this.fixOrigin(url), query), 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);
|
|
192
194
|
};
|
|
193
195
|
_this.initFetchParams = function (url, opts) {
|
|
194
196
|
var _a, _b;
|
|
195
|
-
var
|
|
196
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this,
|
|
197
|
-
|
|
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));
|
|
200
|
+
return _temp;
|
|
198
201
|
};
|
|
199
202
|
_this.initHttpParams = function (url, opts) {
|
|
200
203
|
var _a, _b;
|
|
201
|
-
var
|
|
202
|
-
var params = (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this,
|
|
204
|
+
var __p = __assign({ url: url }, opts);
|
|
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));
|
|
203
207
|
var options = parse(params.url, true);
|
|
204
|
-
return __assign(__assign({},
|
|
208
|
+
return __assign(__assign({}, _temp), options);
|
|
205
209
|
};
|
|
206
210
|
return _this;
|
|
207
211
|
}
|
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: (
|
|
90
|
+
initDefaultParams: (opts: IRequestOptions) => any;
|
|
91
91
|
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
92
92
|
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
93
93
|
};
|