@ahoo-wang/fetcher 1.8.8 → 1.9.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/fetchRequest.d.ts +2 -1
- package/dist/fetchRequest.d.ts.map +1 -1
- package/dist/fetcher.d.ts +16 -0
- package/dist/fetcher.d.ts.map +1 -1
- package/dist/index.es.js +62 -44
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -3
package/dist/fetchRequest.d.ts
CHANGED
|
@@ -26,7 +26,8 @@ export declare enum HttpMethod {
|
|
|
26
26
|
DELETE = "DELETE",
|
|
27
27
|
PATCH = "PATCH",
|
|
28
28
|
HEAD = "HEAD",
|
|
29
|
-
OPTIONS = "OPTIONS"
|
|
29
|
+
OPTIONS = "OPTIONS",
|
|
30
|
+
TRACE = "TRACE"
|
|
30
31
|
}
|
|
31
32
|
export declare const CONTENT_TYPE_HEADER = "Content-Type";
|
|
32
33
|
export declare class ContentTypeValues {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRequest.d.ts","sourceRoot":"","sources":["../src/fetchRequest.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"fetchRequest.d.ts","sourceRoot":"","sources":["../src/fetchRequest.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,cAAc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C;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb"}
|
package/dist/fetcher.d.ts
CHANGED
|
@@ -270,5 +270,21 @@ export declare class Fetcher implements UrlBuilderCapable, RequestHeadersCapable
|
|
|
270
270
|
* @returns Promise that resolves to the HTTP response
|
|
271
271
|
*/
|
|
272
272
|
options<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, options?: RequestOptions): Promise<R>;
|
|
273
|
+
/**
|
|
274
|
+
* Sends an HTTP TRACE request to the specified URL and returns the response.
|
|
275
|
+
*
|
|
276
|
+
* The TRACE method is used to echo the received request for debugging purposes.
|
|
277
|
+
* This method automatically sets the HTTP method to TRACE and omits the request body
|
|
278
|
+
* since TRACE requests must not have a body according to the HTTP specification.
|
|
279
|
+
*
|
|
280
|
+
* @param url - The target URL for the TRACE request. Must be a valid absolute or relative URL.
|
|
281
|
+
* @param request - Request configuration options excluding 'method' and 'body' properties.
|
|
282
|
+
* Defaults to an empty object. Common properties include headers, cache settings, etc.
|
|
283
|
+
* @param options - Optional additional request parameters for extended functionality.
|
|
284
|
+
* May include custom handling logic or metadata for the request pipeline.
|
|
285
|
+
* @returns A Promise resolving to the response object of type R (defaults to Response).
|
|
286
|
+
* The response contains status, headers, and body data from the TRACE request.
|
|
287
|
+
*/
|
|
288
|
+
trace<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, options?: RequestOptions): Promise<R>;
|
|
273
289
|
}
|
|
274
290
|
//# sourceMappingURL=fetcher.d.ts.map
|
package/dist/fetcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAkB,KAAK,cAAc,E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G,OAAO,CAAC,CAAC,GAAG,QAAQ,EACxB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAM,EACvD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAIb;;;;;;;;;;;;;;OAcG;IACG,KAAK,CAAC,CAAC,GAAG,QAAQ,EACtB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAM,EACvD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;CAGd"}
|
package/dist/index.es.js
CHANGED
|
@@ -209,12 +209,12 @@ class $ {
|
|
|
209
209
|
*/
|
|
210
210
|
build(t, r) {
|
|
211
211
|
const s = r?.path, o = r?.query, n = M(this.baseURL, t);
|
|
212
|
-
let
|
|
212
|
+
let u = this.urlTemplateResolver.resolve(n, s);
|
|
213
213
|
if (o) {
|
|
214
|
-
const
|
|
215
|
-
|
|
214
|
+
const c = new URLSearchParams(o).toString();
|
|
215
|
+
c && (u += "?" + c);
|
|
216
216
|
}
|
|
217
|
-
return
|
|
217
|
+
return u;
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
220
|
* Resolves a complete URL from a FetchRequest.
|
|
@@ -264,7 +264,7 @@ async function V(e) {
|
|
|
264
264
|
const o = e.abortController ?? new AbortController();
|
|
265
265
|
e.abortController = o, s.signal = o.signal;
|
|
266
266
|
let n = null;
|
|
267
|
-
const
|
|
267
|
+
const u = new Promise((c, T) => {
|
|
268
268
|
n = setTimeout(() => {
|
|
269
269
|
n && clearTimeout(n);
|
|
270
270
|
const w = new I(e);
|
|
@@ -272,7 +272,7 @@ async function V(e) {
|
|
|
272
272
|
}, r);
|
|
273
273
|
});
|
|
274
274
|
try {
|
|
275
|
-
return await Promise.race([fetch(t, s),
|
|
275
|
+
return await Promise.race([fetch(t, s), u]);
|
|
276
276
|
} finally {
|
|
277
277
|
n && clearTimeout(n);
|
|
278
278
|
}
|
|
@@ -292,11 +292,11 @@ class J {
|
|
|
292
292
|
r.url = t.fetcher.urlBuilder.resolveRequestUrl(r);
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
var
|
|
296
|
-
const
|
|
295
|
+
var i = /* @__PURE__ */ ((e) => (e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.DELETE = "DELETE", e.PATCH = "PATCH", e.HEAD = "HEAD", e.OPTIONS = "OPTIONS", e.TRACE = "TRACE", e))(i || {});
|
|
296
|
+
const a = "Content-Type", R = class R {
|
|
297
297
|
};
|
|
298
|
-
|
|
299
|
-
let d =
|
|
298
|
+
R.APPLICATION_JSON = "application/json", R.TEXT_EVENT_STREAM = "text/event-stream";
|
|
299
|
+
let d = R;
|
|
300
300
|
const Q = "RequestBodyInterceptor", Y = C + 1e3;
|
|
301
301
|
class z {
|
|
302
302
|
constructor() {
|
|
@@ -367,10 +367,10 @@ class z {
|
|
|
367
367
|
return;
|
|
368
368
|
const s = t.ensureRequestHeaders();
|
|
369
369
|
if (this.isAutoAppendContentType(r.body)) {
|
|
370
|
-
s[
|
|
370
|
+
s[a] && delete s[a];
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
|
-
this.isSupportedComplexBodyType(r.body) || (t.request.body = JSON.stringify(r.body), s[
|
|
373
|
+
this.isSupportedComplexBodyType(r.body) || (t.request.body = JSON.stringify(r.body), s[a] || (s[a] = d.APPLICATION_JSON));
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
const K = "FetchInterceptor", W = Number.MAX_SAFE_INTEGER - 1e3;
|
|
@@ -557,7 +557,7 @@ class st {
|
|
|
557
557
|
throw new q(t);
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
class
|
|
560
|
+
class p extends E {
|
|
561
561
|
/**
|
|
562
562
|
* Creates a new ExchangeError instance.
|
|
563
563
|
*
|
|
@@ -566,7 +566,7 @@ class R extends E {
|
|
|
566
566
|
*/
|
|
567
567
|
constructor(t, r) {
|
|
568
568
|
const s = r || t.error?.message || t.response?.statusText || `Request to ${t.request.url} failed during exchange`;
|
|
569
|
-
super(s, t.error), this.exchange = t, this.name = "ExchangeError", Object.setPrototypeOf(this,
|
|
569
|
+
super(s, t.error), this.exchange = t, this.name = "ExchangeError", Object.setPrototypeOf(this, p.prototype);
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
572
|
class ot {
|
|
@@ -671,21 +671,21 @@ class ot {
|
|
|
671
671
|
} catch (r) {
|
|
672
672
|
if (t.error = r, await this.error.intercept(t), !t.hasError())
|
|
673
673
|
return t;
|
|
674
|
-
throw new
|
|
674
|
+
throw new p(t);
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
|
-
const nt = (e) => e, it = (e) => e.requiredResponse, ut = (e) => e.requiredResponse.json(),
|
|
678
|
+
const nt = (e) => e, it = (e) => e.requiredResponse, ut = (e) => e.requiredResponse.json(), ct = (e) => e.requiredResponse.text(), b = {
|
|
679
679
|
Exchange: nt,
|
|
680
680
|
Response: it,
|
|
681
681
|
Json: ut,
|
|
682
|
-
Text:
|
|
682
|
+
Text: ct
|
|
683
683
|
};
|
|
684
684
|
function S(e, t) {
|
|
685
685
|
if (!(e === void 0 && t === void 0))
|
|
686
686
|
return t === void 0 ? e : e === void 0 ? t : { ...e, ...t };
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function at(e, t) {
|
|
689
689
|
if (t ??= /* @__PURE__ */ new Map(), !e)
|
|
690
690
|
return t;
|
|
691
691
|
if (e instanceof Map) {
|
|
@@ -699,7 +699,7 @@ function ct(e, t) {
|
|
|
699
699
|
}
|
|
700
700
|
class ht {
|
|
701
701
|
constructor(t) {
|
|
702
|
-
this.fetcher = t.fetcher, this.request = t.request, this.resultExtractor = t.resultExtractor ?? b.Exchange, this.attributes =
|
|
702
|
+
this.fetcher = t.fetcher, this.request = t.request, this.resultExtractor = t.resultExtractor ?? b.Exchange, this.attributes = at(t.attributes), this._response = t.response, this.error = t.error;
|
|
703
703
|
}
|
|
704
704
|
/**
|
|
705
705
|
* Ensures that request headers object exists, creating it if necessary.
|
|
@@ -776,7 +776,7 @@ class ht {
|
|
|
776
776
|
*/
|
|
777
777
|
get requiredResponse() {
|
|
778
778
|
if (!this.response)
|
|
779
|
-
throw new
|
|
779
|
+
throw new p(
|
|
780
780
|
this,
|
|
781
781
|
`Request to ${this.request.url} failed with no response`
|
|
782
782
|
);
|
|
@@ -803,7 +803,7 @@ function dt(e, t) {
|
|
|
803
803
|
}, s = {
|
|
804
804
|
...e.headers,
|
|
805
805
|
...t.headers
|
|
806
|
-
}, o = t.method ?? e.method, n = t.body ?? e.body,
|
|
806
|
+
}, o = t.method ?? e.method, n = t.body ?? e.body, u = t.timeout ?? e.timeout, c = t.signal ?? e.signal, T = t.abortController ?? e.abortController;
|
|
807
807
|
return {
|
|
808
808
|
...e,
|
|
809
809
|
...t,
|
|
@@ -811,8 +811,8 @@ function dt(e, t) {
|
|
|
811
811
|
urlParams: r,
|
|
812
812
|
headers: s,
|
|
813
813
|
body: n,
|
|
814
|
-
timeout:
|
|
815
|
-
signal:
|
|
814
|
+
timeout: u,
|
|
815
|
+
signal: c,
|
|
816
816
|
abortController: T
|
|
817
817
|
};
|
|
818
818
|
}
|
|
@@ -823,7 +823,7 @@ function A(e, t) {
|
|
|
823
823
|
};
|
|
824
824
|
}
|
|
825
825
|
const y = {
|
|
826
|
-
[
|
|
826
|
+
[a]: d.APPLICATION_JSON
|
|
827
827
|
}, U = {
|
|
828
828
|
baseURL: "",
|
|
829
829
|
headers: y
|
|
@@ -867,14 +867,14 @@ class D {
|
|
|
867
867
|
timeout: X(t.timeout, this.timeout)
|
|
868
868
|
}, {
|
|
869
869
|
resultExtractor: n,
|
|
870
|
-
attributes:
|
|
871
|
-
} = A(v, r),
|
|
870
|
+
attributes: u
|
|
871
|
+
} = A(v, r), c = new ht({
|
|
872
872
|
fetcher: this,
|
|
873
873
|
request: o,
|
|
874
874
|
resultExtractor: n,
|
|
875
|
-
attributes:
|
|
875
|
+
attributes: u
|
|
876
876
|
});
|
|
877
|
-
return this.interceptors.exchange(
|
|
877
|
+
return this.interceptors.exchange(c);
|
|
878
878
|
}
|
|
879
879
|
/**
|
|
880
880
|
* Processes an HTTP request through the Fetcher's internal workflow.
|
|
@@ -966,7 +966,7 @@ class D {
|
|
|
966
966
|
* @returns Promise that resolves to the HTTP response
|
|
967
967
|
*/
|
|
968
968
|
async get(t, r = {}, s) {
|
|
969
|
-
return this.methodFetch(
|
|
969
|
+
return this.methodFetch(i.GET, t, r, s);
|
|
970
970
|
}
|
|
971
971
|
/**
|
|
972
972
|
* Makes a PUT HTTP request.
|
|
@@ -985,7 +985,7 @@ class D {
|
|
|
985
985
|
* @returns Promise that resolves to the HTTP response
|
|
986
986
|
*/
|
|
987
987
|
async put(t, r = {}, s) {
|
|
988
|
-
return this.methodFetch(
|
|
988
|
+
return this.methodFetch(i.PUT, t, r, s);
|
|
989
989
|
}
|
|
990
990
|
/**
|
|
991
991
|
* Makes a POST HTTP request.
|
|
@@ -1004,7 +1004,7 @@ class D {
|
|
|
1004
1004
|
* @returns Promise that resolves to the HTTP response
|
|
1005
1005
|
*/
|
|
1006
1006
|
async post(t, r = {}, s) {
|
|
1007
|
-
return this.methodFetch(
|
|
1007
|
+
return this.methodFetch(i.POST, t, r, s);
|
|
1008
1008
|
}
|
|
1009
1009
|
/**
|
|
1010
1010
|
* Makes a PATCH HTTP request.
|
|
@@ -1023,7 +1023,7 @@ class D {
|
|
|
1023
1023
|
* @returns Promise that resolves to the HTTP response
|
|
1024
1024
|
*/
|
|
1025
1025
|
async patch(t, r = {}, s) {
|
|
1026
|
-
return this.methodFetch(
|
|
1026
|
+
return this.methodFetch(i.PATCH, t, r, s);
|
|
1027
1027
|
}
|
|
1028
1028
|
/**
|
|
1029
1029
|
* Makes a DELETE HTTP request.
|
|
@@ -1042,7 +1042,7 @@ class D {
|
|
|
1042
1042
|
* @returns Promise that resolves to the HTTP response
|
|
1043
1043
|
*/
|
|
1044
1044
|
async delete(t, r = {}, s) {
|
|
1045
|
-
return this.methodFetch(
|
|
1045
|
+
return this.methodFetch(i.DELETE, t, r, s);
|
|
1046
1046
|
}
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Makes a HEAD HTTP request.
|
|
@@ -1062,7 +1062,7 @@ class D {
|
|
|
1062
1062
|
* @returns Promise that resolves to the HTTP response
|
|
1063
1063
|
*/
|
|
1064
1064
|
async head(t, r = {}, s) {
|
|
1065
|
-
return this.methodFetch(
|
|
1065
|
+
return this.methodFetch(i.HEAD, t, r, s);
|
|
1066
1066
|
}
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Makes an OPTIONS HTTP request.
|
|
@@ -1082,7 +1082,25 @@ class D {
|
|
|
1082
1082
|
* @returns Promise that resolves to the HTTP response
|
|
1083
1083
|
*/
|
|
1084
1084
|
async options(t, r = {}, s) {
|
|
1085
|
-
return this.methodFetch(
|
|
1085
|
+
return this.methodFetch(i.OPTIONS, t, r, s);
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Sends an HTTP TRACE request to the specified URL and returns the response.
|
|
1089
|
+
*
|
|
1090
|
+
* The TRACE method is used to echo the received request for debugging purposes.
|
|
1091
|
+
* This method automatically sets the HTTP method to TRACE and omits the request body
|
|
1092
|
+
* since TRACE requests must not have a body according to the HTTP specification.
|
|
1093
|
+
*
|
|
1094
|
+
* @param url - The target URL for the TRACE request. Must be a valid absolute or relative URL.
|
|
1095
|
+
* @param request - Request configuration options excluding 'method' and 'body' properties.
|
|
1096
|
+
* Defaults to an empty object. Common properties include headers, cache settings, etc.
|
|
1097
|
+
* @param options - Optional additional request parameters for extended functionality.
|
|
1098
|
+
* May include custom handling logic or metadata for the request pipeline.
|
|
1099
|
+
* @returns A Promise resolving to the response object of type R (defaults to Response).
|
|
1100
|
+
* The response contains status, headers, and body data from the TRACE request.
|
|
1101
|
+
*/
|
|
1102
|
+
async trace(t, r = {}, s) {
|
|
1103
|
+
return this.methodFetch(i.TRACE, t, r, s);
|
|
1086
1104
|
}
|
|
1087
1105
|
}
|
|
1088
1106
|
const _ = "default";
|
|
@@ -1187,7 +1205,7 @@ class lt {
|
|
|
1187
1205
|
}
|
|
1188
1206
|
}
|
|
1189
1207
|
const O = new lt();
|
|
1190
|
-
function
|
|
1208
|
+
function Rt(e, t) {
|
|
1191
1209
|
return e ? e instanceof D ? e : O.requiredGet(e) : t ?? O.default;
|
|
1192
1210
|
}
|
|
1193
1211
|
class Et extends D {
|
|
@@ -1212,15 +1230,15 @@ class Et extends D {
|
|
|
1212
1230
|
super(r), this.name = t, O.register(t, this);
|
|
1213
1231
|
}
|
|
1214
1232
|
}
|
|
1215
|
-
const
|
|
1233
|
+
const pt = new Et(_);
|
|
1216
1234
|
export {
|
|
1217
|
-
|
|
1235
|
+
a as CONTENT_TYPE_HEADER,
|
|
1218
1236
|
d as ContentTypeValues,
|
|
1219
1237
|
_ as DEFAULT_FETCHER_NAME,
|
|
1220
1238
|
N as DEFAULT_FETCH_OPTIONS,
|
|
1221
1239
|
U as DEFAULT_OPTIONS,
|
|
1222
1240
|
v as DEFAULT_REQUEST_OPTIONS,
|
|
1223
|
-
|
|
1241
|
+
p as ExchangeError,
|
|
1224
1242
|
nt as ExchangeResultExtractor,
|
|
1225
1243
|
g as ExpressUrlTemplateResolver,
|
|
1226
1244
|
K as FETCH_INTERCEPTOR_NAME,
|
|
@@ -1231,7 +1249,7 @@ export {
|
|
|
1231
1249
|
D as Fetcher,
|
|
1232
1250
|
E as FetcherError,
|
|
1233
1251
|
lt as FetcherRegistrar,
|
|
1234
|
-
|
|
1252
|
+
i as HttpMethod,
|
|
1235
1253
|
q as HttpStatusValidationError,
|
|
1236
1254
|
ot as InterceptorManager,
|
|
1237
1255
|
f as InterceptorRegistry,
|
|
@@ -1242,7 +1260,7 @@ export {
|
|
|
1242
1260
|
z as RequestBodyInterceptor,
|
|
1243
1261
|
it as ResponseResultExtractor,
|
|
1244
1262
|
b as ResultExtractors,
|
|
1245
|
-
|
|
1263
|
+
ct as TextResultExtractor,
|
|
1246
1264
|
k as URL_RESOLVE_INTERCEPTOR_NAME,
|
|
1247
1265
|
C as URL_RESOLVE_INTERCEPTOR_ORDER,
|
|
1248
1266
|
P as UriTemplateResolver,
|
|
@@ -1254,12 +1272,12 @@ export {
|
|
|
1254
1272
|
st as ValidateStatusInterceptor,
|
|
1255
1273
|
M as combineURLs,
|
|
1256
1274
|
j as expressUrlTemplateResolver,
|
|
1257
|
-
|
|
1275
|
+
pt as fetcher,
|
|
1258
1276
|
O as fetcherRegistrar,
|
|
1259
|
-
|
|
1277
|
+
Rt as getFetcher,
|
|
1260
1278
|
H as getUrlTemplateResolver,
|
|
1261
1279
|
L as isAbsoluteURL,
|
|
1262
|
-
|
|
1280
|
+
at as mergeRecordToMap,
|
|
1263
1281
|
S as mergeRecords,
|
|
1264
1282
|
dt as mergeRequest,
|
|
1265
1283
|
A as mergeRequestOptions,
|