@ahoo-wang/fetcher 0.9.0 → 0.9.2

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.umd.js CHANGED
@@ -1 +1 @@
1
- (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.Fetcher={}))})(this,(function(n){"use strict";function a(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function g(r,e){return a(e)?e:e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}class I{constructor(e){this.baseURL=e}build(e,t){const s=t?.path,o=t?.query,u=g(this.baseURL,e);let i=this.interpolateUrl(u,s);if(o){const h=new URLSearchParams(o).toString();h&&(i+="?"+h)}return i}resolveRequestUrl(e){return this.build(e.url,e.urlParams)}interpolateUrl(e,t){return t?e.replace(/{([^}]+)}/g,(s,o)=>{const u=t[o];if(u===void 0)throw new Error(`Missing required path parameter: ${o}`);return String(u)}):e}}function b(r,e){return typeof r<"u"?r:e}class d extends Error{constructor(e){const t=e.method||"GET",s=`Request timeout of ${e.timeout}ms exceeded for ${t} ${e.url}`;super(s),this.name="FetchTimeoutError",this.request=e,Object.setPrototypeOf(this,d.prototype)}}async function F(r){const e=r.url,t=r.timeout,s=r;if(!t)return fetch(e,s);const o=new AbortController,u={...s,signal:o.signal};let i=null;const h=new Promise((B,D)=>{i=setTimeout(()=>{i&&clearTimeout(i);const _=new d(r);o.abort(_),D(_)},t)});try{return await Promise.race([fetch(e,u),h])}finally{i&&clearTimeout(i)}}function l(r,e){return e?r.filter(e).sort((t,s)=>t.order-s.order):[...r].sort((t,s)=>t.order-s.order)}var c=(r=>(r.GET="GET",r.POST="POST",r.PUT="PUT",r.DELETE="DELETE",r.PATCH="PATCH",r.HEAD="HEAD",r.OPTIONS="OPTIONS",r))(c||{});const L="Content-Type";var m=(r=>(r.APPLICATION_JSON="application/json",r.TEXT_EVENT_STREAM="text/event-stream",r))(m||{});class R{constructor(){this.name="RequestBodyInterceptor",this.order=Number.MIN_SAFE_INTEGER+200}intercept(e){const t=e.request;if(t.body===void 0||t.body===null||typeof t.body!="object"||t.body instanceof ArrayBuffer||ArrayBuffer.isView(t.body)||t.body instanceof Blob||t.body instanceof File||t.body instanceof URLSearchParams||t.body instanceof FormData||t.body instanceof ReadableStream)return;const s={...t};s.body=JSON.stringify(t.body),s.headers||(s.headers={});const o=s.headers;o["Content-Type"]||(o["Content-Type"]=m.APPLICATION_JSON),e.request=s}}class w{constructor(){this.name="FetchInterceptor",this.order=Number.MAX_SAFE_INTEGER-100}async intercept(e){e.response=await F(e.request)}}class P{constructor(){this.name="UrlResolveInterceptor",this.order=Number.MIN_SAFE_INTEGER+100}intercept(e){const t=e.request;t.url=e.fetcher.urlBuilder.resolveRequestUrl(t)}}class f{constructor(e=[]){this.sortedInterceptors=[],this.sortedInterceptors=l(e)}get name(){return this.constructor.name}get order(){return Number.MIN_SAFE_INTEGER}use(e){return this.sortedInterceptors.some(t=>t.name===e.name)?!1:(this.sortedInterceptors=l([...this.sortedInterceptors,e]),!0)}eject(e){const t=this.sortedInterceptors;return this.sortedInterceptors=l(t,s=>s.name!==e),t.length!==this.sortedInterceptors.length}clear(){this.sortedInterceptors=[]}async intercept(e){for(const t of this.sortedInterceptors)await t.intercept(e)}}class A{constructor(){this.request=new f([new P,new R,new w]),this.response=new f,this.error=new f}}class N{constructor(e,t,s,o){this.attributes={},this.fetcher=e,this.request=t,this.response=s,this.error=o}hasError(){return!!this.error}hasResponse(){return!!this.response}}function y(r,e){if(!(r===void 0&&e===void 0))return e===void 0?r:r===void 0?e:{...r,...e}}const p={"Content-Type":m.APPLICATION_JSON},E={baseURL:"",headers:p};class S{constructor(e=E){this.headers=p,this.urlBuilder=new I(e.baseURL),this.headers=e.headers??p,this.timeout=e.timeout,this.interceptors=e.interceptors??new A}async fetch(e,t={}){const s=t;s.url=e;const o=await this.request(s);if(!o.response)throw new Error(`Request to ${s.url} failed with no response`);return o.response}async request(e){const t=y(e.headers,this.headers),s={...e,headers:t,timeout:b(e.timeout,this.timeout)},o=new N(this,s);return this.exchange(o)}async exchange(e){try{return await this.interceptors.request.intercept(e),await this.interceptors.response.intercept(e),e}catch(t){if(e.error=t,await this.interceptors.error.intercept(e),e.hasResponse())return e;throw e.error}}async methodFetch(e,t,s={}){return this.fetch(t,{...s,method:e})}async get(e,t={}){return this.methodFetch(c.GET,e,t)}async post(e,t={}){return this.methodFetch(c.POST,e,t)}async put(e,t={}){return this.methodFetch(c.PUT,e,t)}async delete(e,t={}){return this.methodFetch(c.DELETE,e,t)}async patch(e,t={}){return this.methodFetch(c.PATCH,e,t)}async head(e,t={}){return this.methodFetch(c.HEAD,e,t)}async options(e,t={}){return this.methodFetch(c.OPTIONS,e,t)}}const T="default";class q{constructor(){this.registrar=new Map}register(e,t){this.registrar.set(e,t)}unregister(e){return this.registrar.delete(e)}get(e){return this.registrar.get(e)}requiredGet(e){const t=this.get(e);if(!t)throw new Error(`Fetcher ${e} not found`);return t}get default(){return this.requiredGet(T)}set default(e){this.register(T,e)}get fetchers(){return new Map(this.registrar)}}const O=new q;function v(r,e){if(Object.keys(r).length===0)return e;if(Object.keys(e).length===0)return r;const t={path:y(r.urlParams?.path,e.urlParams?.path),query:y(r.urlParams?.query,e.urlParams?.query)},s={...r.headers,...e.headers},o=e.method??r.method,u=e.body??r.body,i=e.timeout??r.timeout,h=e.signal??r.signal;return{...r,...e,method:o,urlParams:t,headers:s,body:u,timeout:i,signal:h}}class U extends S{constructor(e,t=E){super(t),this.name=e,O.register(e,this)}}const C=new U(T);n.ContentTypeHeader=L,n.ContentTypeValues=m,n.DEFAULT_FETCHER_NAME=T,n.DEFAULT_OPTIONS=E,n.FetchExchange=N,n.FetchInterceptor=w,n.FetchTimeoutError=d,n.Fetcher=S,n.FetcherInterceptors=A,n.FetcherRegistrar=q,n.HttpMethod=c,n.InterceptorManager=f,n.NamedFetcher=U,n.RequestBodyInterceptor=R,n.UrlBuilder=I,n.UrlResolveInterceptor=P,n.combineURLs=g,n.fetcher=C,n.fetcherRegistrar=O,n.isAbsoluteURL=a,n.mergeRecords=y,n.mergeRequest=v,n.resolveTimeout=b,n.timeoutFetch=F,n.toSorted=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.Fetcher={}))})(this,(function(n){"use strict";class i extends Error{constructor(e,t){const s=e||t?.message||"An error occurred in the fetcher";super(s),this.cause=t,this.name="FetcherError",t?.stack&&(this.stack=t.stack),Object.setPrototypeOf(this,i.prototype)}}class d extends i{constructor(e){const t=e.error?.message||e.response?.statusText||`Request to ${e.request.url} failed during exchange`;super(t,e.error),this.exchange=e,this.name="ExchangeError",Object.setPrototypeOf(this,d.prototype)}}class l extends i{constructor(e,t){const s=t||e.error?.message||`Request to ${e.request.url} failed with no response`;super(s,e.error),this.exchange=e,this.name="FetchError",Object.setPrototypeOf(this,l.prototype)}}class m extends i{constructor(e){const t=e.method||"GET",s=`Request timeout of ${e.timeout}ms exceeded for ${t} ${e.url}`;super(s),this.name="FetchTimeoutError",this.request=e,Object.setPrototypeOf(this,m.prototype)}}function F(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function I(r,e){return F(e)?e:e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}class R{constructor(e){this.baseURL=e}build(e,t){const s=t?.path,o=t?.query,a=I(this.baseURL,e);let c=this.interpolateUrl(a,s);if(o){const h=new URLSearchParams(o).toString();h&&(c+="?"+h)}return c}resolveRequestUrl(e){return this.build(e.url,e.urlParams)}interpolateUrl(e,t){return t?e.replace(/{([^}]+)}/g,(s,o)=>{const a=t[o];if(a===void 0)throw new Error(`Missing required path parameter: ${o}`);return String(a)}):e}}function P(r,e){return typeof r<"u"?r:e}async function w(r){const e=r.url,t=r.timeout,s=r;if(!t)return fetch(e,s);const o=new AbortController,a={...s,signal:o.signal};let c=null;const h=new Promise((G,B)=>{c=setTimeout(()=>{c&&clearTimeout(c);const C=new m(r);o.abort(C),B(C)},t)});try{return await Promise.race([fetch(e,a),h])}finally{c&&clearTimeout(c)}}function f(r,e){return e?r.filter(e).sort((t,s)=>t.order-s.order):[...r].sort((t,s)=>t.order-s.order)}var u=(r=>(r.GET="GET",r.POST="POST",r.PUT="PUT",r.DELETE="DELETE",r.PATCH="PATCH",r.HEAD="HEAD",r.OPTIONS="OPTIONS",r))(u||{});const D="Content-Type";var y=(r=>(r.APPLICATION_JSON="application/json",r.TEXT_EVENT_STREAM="text/event-stream",r))(y||{});class A{constructor(){this.name="RequestBodyInterceptor",this.order=Number.MIN_SAFE_INTEGER+200}intercept(e){const t=e.request;if(t.body===void 0||t.body===null||typeof t.body!="object"||t.body instanceof ArrayBuffer||ArrayBuffer.isView(t.body)||t.body instanceof Blob||t.body instanceof File||t.body instanceof URLSearchParams||t.body instanceof FormData||t.body instanceof ReadableStream)return;const s={...t};s.body=JSON.stringify(t.body),s.headers||(s.headers={});const o=s.headers;o["Content-Type"]||(o["Content-Type"]=y.APPLICATION_JSON),e.request=s}}class O{constructor(){this.name="FetchInterceptor",this.order=Number.MAX_SAFE_INTEGER-100}async intercept(e){e.response=await w(e.request)}}class q{constructor(){this.name="UrlResolveInterceptor",this.order=Number.MIN_SAFE_INTEGER+100}intercept(e){const t=e.request;t.url=e.fetcher.urlBuilder.resolveRequestUrl(t)}}class p{constructor(e=[]){this.sortedInterceptors=[],this.sortedInterceptors=f(e)}get name(){return this.constructor.name}get order(){return Number.MIN_SAFE_INTEGER}use(e){return this.sortedInterceptors.some(t=>t.name===e.name)?!1:(this.sortedInterceptors=f([...this.sortedInterceptors,e]),!0)}eject(e){const t=this.sortedInterceptors;return this.sortedInterceptors=f(t,s=>s.name!==e),t.length!==this.sortedInterceptors.length}clear(){this.sortedInterceptors=[]}async intercept(e){for(const t of this.sortedInterceptors)await t.intercept(e)}}class N{constructor(){this.request=new p([new q,new A,new O]),this.response=new p,this.error=new p}}class S{constructor(e,t,s,o){this.attributes={},this.fetcher=e,this.request=t,this.response=s,this.error=o}hasError(){return!!this.error}hasResponse(){return!!this.response}}function E(r,e){if(!(r===void 0&&e===void 0))return e===void 0?r:r===void 0?e:{...r,...e}}const g={"Content-Type":y.APPLICATION_JSON},b={baseURL:"",headers:g};class U{constructor(e=b){this.headers=g,this.urlBuilder=new R(e.baseURL),this.headers=e.headers??g,this.timeout=e.timeout,this.interceptors=e.interceptors??new N}async fetch(e,t={}){const s=t;s.url=e;const o=await this.request(s);if(!o.response)throw new l(o,`Request to ${s.url} failed with no response`);return o.response}async request(e){const t=E(e.headers,this.headers),s={...e,headers:t,timeout:P(e.timeout,this.timeout)},o=new S(this,s);return this.exchange(o)}async exchange(e){try{return await this.interceptors.request.intercept(e),await this.interceptors.response.intercept(e),e}catch(t){if(e.error=t,await this.interceptors.error.intercept(e),!e.hasError())return e;throw new d(e)}}async methodFetch(e,t,s={}){return this.fetch(t,{...s,method:e})}async get(e,t={}){return this.methodFetch(u.GET,e,t)}async post(e,t={}){return this.methodFetch(u.POST,e,t)}async put(e,t={}){return this.methodFetch(u.PUT,e,t)}async delete(e,t={}){return this.methodFetch(u.DELETE,e,t)}async patch(e,t={}){return this.methodFetch(u.PATCH,e,t)}async head(e,t={}){return this.methodFetch(u.HEAD,e,t)}async options(e,t={}){return this.methodFetch(u.OPTIONS,e,t)}}const T="default";class L{constructor(){this.registrar=new Map}register(e,t){this.registrar.set(e,t)}unregister(e){return this.registrar.delete(e)}get(e){return this.registrar.get(e)}requiredGet(e){const t=this.get(e);if(!t)throw new Error(`Fetcher ${e} not found`);return t}get default(){return this.requiredGet(T)}set default(e){this.register(T,e)}get fetchers(){return new Map(this.registrar)}}const _=new L;function j(r,e){if(Object.keys(r).length===0)return e;if(Object.keys(e).length===0)return r;const t={path:E(r.urlParams?.path,e.urlParams?.path),query:E(r.urlParams?.query,e.urlParams?.query)},s={...r.headers,...e.headers},o=e.method??r.method,a=e.body??r.body,c=e.timeout??r.timeout,h=e.signal??r.signal;return{...r,...e,method:o,urlParams:t,headers:s,body:a,timeout:c,signal:h}}class v extends U{constructor(e,t=b){super(t),this.name=e,_.register(e,this)}}const M=new v(T);n.ContentTypeHeader=D,n.ContentTypeValues=y,n.DEFAULT_FETCHER_NAME=T,n.DEFAULT_OPTIONS=b,n.ExchangeError=d,n.FetchError=l,n.FetchExchange=S,n.FetchInterceptor=O,n.FetchTimeoutError=m,n.Fetcher=U,n.FetcherError=i,n.FetcherInterceptors=N,n.FetcherRegistrar=L,n.HttpMethod=u,n.InterceptorManager=p,n.NamedFetcher=v,n.RequestBodyInterceptor=A,n.UrlBuilder=R,n.UrlResolveInterceptor=q,n.combineURLs=I,n.fetcher=M,n.fetcherRegistrar=_,n.isAbsoluteURL=F,n.mergeRecords=E,n.mergeRequest=j,n.resolveTimeout=P,n.timeoutFetch=w,n.toSorted=f,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
@@ -2,14 +2,11 @@ import { NamedCapable } from './types';
2
2
  import { OrderedCapable } from './orderedCapable';
3
3
  import { FetchExchange } from './fetchExchange';
4
4
  /**
5
- * Interceptor Interface
5
+ * Interface for HTTP interceptors in the fetcher pipeline.
6
6
  *
7
- * Defines the basic structure of an interceptor. Interceptors are used to process
8
- * requests, responses, or errors at different stages of the HTTP request lifecycle.
9
- *
10
- * @remarks
11
- * Interceptors follow the Chain of Responsibility pattern, where each interceptor
12
- * can modify the exchange object and pass it to the next interceptor in the chain.
7
+ * Interceptors are middleware components that can modify requests, responses, or handle errors
8
+ * at different stages of the HTTP request lifecycle. They follow the Chain of Responsibility
9
+ * pattern, where each interceptor can process the exchange object and pass it to the next.
13
10
  *
14
11
  * @example
15
12
  * // Example of a custom request interceptor
@@ -27,21 +24,19 @@ import { FetchExchange } from './fetchExchange';
27
24
  */
28
25
  export interface Interceptor extends NamedCapable, OrderedCapable {
29
26
  /**
30
- * Interceptor name, used to identify the interceptor and must be unique
27
+ * Unique identifier for the interceptor.
31
28
  *
32
- * @remarks
33
- * The name is used by the InterceptorManager to manage interceptors,
34
- * including adding, removing, and preventing duplicates.
29
+ * Used by InterceptorManager to manage interceptors, including adding, removing,
30
+ * and preventing duplicates. Each interceptor must have a unique name.
35
31
  */
36
32
  name: string;
37
33
  /**
38
- * Intercept and process data
34
+ * Process the exchange object in the interceptor pipeline.
39
35
  *
40
- * This method is called by the InterceptorManager to process the exchange object.
41
- * The interceptor can modify the request, response, or error properties of the
42
- * exchange object directly.
36
+ * This method is called by InterceptorManager to process the exchange object.
37
+ * Interceptors can modify request, response, or error properties directly.
43
38
  *
44
- * @param exchange - The data to be processed, containing request, response, and error information
39
+ * @param exchange - The exchange object containing request, response, and error information
45
40
  *
46
41
  * @remarks
47
42
  * Interceptors should modify the exchange object directly rather than returning it.
@@ -50,11 +45,10 @@ export interface Interceptor extends NamedCapable, OrderedCapable {
50
45
  intercept(exchange: FetchExchange): void | Promise<void>;
51
46
  }
52
47
  /**
53
- * InterceptorManager Class
48
+ * Manager for a collection of interceptors of the same type.
54
49
  *
55
- * Manages multiple interceptors of the same type. Responsible for adding, removing,
56
- * and executing interceptors in the correct order. Each InterceptorManager instance
57
- * handles one type of interceptor (request, response, or error).
50
+ * Handles adding, removing, and executing interceptors in the correct order.
51
+ * Each InterceptorManager instance manages one type of interceptor (request, response, or error).
58
52
  *
59
53
  * @remarks
60
54
  * Interceptors are executed in ascending order of their `order` property.
@@ -75,23 +69,23 @@ export interface Interceptor extends NamedCapable, OrderedCapable {
75
69
  */
76
70
  export declare class InterceptorManager implements Interceptor {
77
71
  /**
78
- * Gets the name of this interceptor manager
72
+ * Gets the name of this interceptor manager.
79
73
  *
80
74
  * @returns The constructor name of this class
81
75
  */
82
76
  get name(): string;
83
77
  /**
84
- * Gets the order of this interceptor manager
78
+ * Gets the order of this interceptor manager.
85
79
  *
86
80
  * @returns Number.MIN_SAFE_INTEGER, indicating this manager should execute early
87
81
  */
88
82
  get order(): number;
89
83
  /**
90
- * Array of interceptors managed by this manager, sorted by their order property
84
+ * Array of interceptors managed by this manager, sorted by their order property.
91
85
  */
92
86
  private sortedInterceptors;
93
87
  /**
94
- * Creates a new InterceptorManager instance
88
+ * Initializes a new InterceptorManager instance.
95
89
  *
96
90
  * @param interceptors - Initial array of interceptors to manage
97
91
  *
@@ -101,7 +95,7 @@ export declare class InterceptorManager implements Interceptor {
101
95
  */
102
96
  constructor(interceptors?: Interceptor[]);
103
97
  /**
104
- * Adds an interceptor to this manager
98
+ * Adds an interceptor to this manager.
105
99
  *
106
100
  * @param interceptor - The interceptor to add
107
101
  * @returns True if the interceptor was added, false if an interceptor with the
@@ -115,7 +109,7 @@ export declare class InterceptorManager implements Interceptor {
115
109
  */
116
110
  use(interceptor: Interceptor): boolean;
117
111
  /**
118
- * Removes an interceptor by name
112
+ * Removes an interceptor by name.
119
113
  *
120
114
  * @param name - The name of the interceptor to remove
121
115
  * @returns True if an interceptor was removed, false if no interceptor with the
@@ -123,14 +117,14 @@ export declare class InterceptorManager implements Interceptor {
123
117
  */
124
118
  eject(name: string): boolean;
125
119
  /**
126
- * Removes all interceptors from this manager
120
+ * Removes all interceptors from this manager.
127
121
  */
128
122
  clear(): void;
129
123
  /**
130
- * Executes all managed interceptors on the given exchange object
124
+ * Executes all managed interceptors on the given exchange object.
131
125
  *
132
126
  * @param exchange - The exchange object to process
133
- * @returns A promise that resolves to the processed exchange object
127
+ * @returns A promise that resolves when all interceptors have been executed
134
128
  *
135
129
  * @remarks
136
130
  * Interceptors are executed in order, with each interceptor receiving the result
@@ -143,14 +137,15 @@ export declare class InterceptorManager implements Interceptor {
143
137
  intercept(exchange: FetchExchange): Promise<void>;
144
138
  }
145
139
  /**
146
- * FetcherInterceptors Class
140
+ * Collection of interceptor managers for the Fetcher client.
147
141
  *
148
- * The interceptor collection management class for Fetcher, responsible for managing three types of interceptors:
142
+ * Manages three types of interceptors:
149
143
  * 1. Request interceptors - Process requests before sending HTTP requests
150
144
  * 2. Response interceptors - Process responses after receiving HTTP responses
151
145
  * 3. Error interceptors - Handle errors when they occur during the request process
152
146
  *
153
- * Each type of interceptor is managed by an InterceptorManager instance, supporting adding, removing, and executing interceptors.
147
+ * Each type of interceptor is managed by an InterceptorManager instance, supporting
148
+ * adding, removing, and executing interceptors.
154
149
  *
155
150
  * @example
156
151
  * // Create a custom interceptor
@@ -172,44 +167,47 @@ export declare class InterceptorManager implements Interceptor {
172
167
  * fetcher.interceptors.request.use(customRequestInterceptor);
173
168
  *
174
169
  * @remarks
175
- * By default, the request interceptor manager has two built-in interceptors registered:
176
- * 1. RequestBodyInterceptor - Automatically converts object-type request bodies to JSON strings
177
- * 2. FetchInterceptor - Executes actual HTTP requests and handles timeouts
170
+ * By default, the request interceptor manager has three built-in interceptors registered:
171
+ * 1. UrlResolveInterceptor - Resolves the final URL with parameters
172
+ * 2. RequestBodyInterceptor - Automatically converts object-type request bodies to JSON strings
173
+ * 3. FetchInterceptor - Executes actual HTTP requests and handles timeouts
178
174
  */
179
175
  export declare class FetcherInterceptors {
180
176
  /**
181
- * Request Interceptor Manager
177
+ * Manager for request-phase interceptors.
182
178
  *
183
- * Responsible for managing all request-phase interceptors, executed before HTTP requests are sent.
184
- * Contains three built-in interceptors by default: UrlResolveInterceptor, RequestBodyInterceptor, and FetchInterceptor.
179
+ * Executed before HTTP requests are sent. Contains three built-in interceptors by default:
180
+ * UrlResolveInterceptor, RequestBodyInterceptor, and FetchInterceptor.
185
181
  *
186
182
  * @remarks
187
- * Request interceptors are executed in ascending order of their order values, with smaller values having higher priority.
188
- * The default interceptors are:
183
+ * Request interceptors are executed in ascending order of their order values, with smaller
184
+ * values having higher priority. The default interceptors are:
189
185
  * 1. UrlResolveInterceptor (order: Number.MIN_SAFE_INTEGER) - Resolves the final URL
190
186
  * 2. RequestBodyInterceptor (order: 0) - Converts object bodies to JSON
191
187
  * 3. FetchInterceptor (order: Number.MAX_SAFE_INTEGER) - Executes the actual HTTP request
192
188
  */
193
189
  request: InterceptorManager;
194
190
  /**
195
- * Response Interceptor Manager
191
+ * Manager for response-phase interceptors.
196
192
  *
197
- * Responsible for managing all response-phase interceptors, executed after HTTP responses are received.
198
- * Empty by default, custom response processing logic can be added as needed.
193
+ * Executed after HTTP responses are received. Empty by default, custom response processing
194
+ * logic can be added as needed.
199
195
  *
200
196
  * @remarks
201
- * Response interceptors are executed in ascending order of their order values, with smaller values having higher priority.
197
+ * Response interceptors are executed in ascending order of their order values, with smaller
198
+ * values having higher priority.
202
199
  */
203
200
  response: InterceptorManager;
204
201
  /**
205
- * Error Interceptor Manager
202
+ * Manager for error-handling phase interceptors.
206
203
  *
207
- * Responsible for managing all error-handling phase interceptors, executed when errors occur during HTTP requests.
208
- * Empty by default, custom error handling logic can be added as needed.
204
+ * Executed when errors occur during HTTP requests. Empty by default, custom error handling
205
+ * logic can be added as needed.
209
206
  *
210
207
  * @remarks
211
- * Error interceptors are executed in ascending order of their order values, with smaller values having higher priority.
212
- * Error interceptors can transform errors into normal responses, avoiding thrown exceptions.
208
+ * Error interceptors are executed in ascending order of their order values, with smaller
209
+ * values having higher priority. Error interceptors can transform errors into normal responses,
210
+ * avoiding thrown exceptions.
213
211
  */
214
212
  error: InterceptorManager;
215
213
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../src/interceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,cAAc,EAAY,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,cAAc;IAC/D;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACpD;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAqB;IAE/C;;;;;;;;OAQG;gBACS,YAAY,GAAE,WAAW,EAAO;IAI5C;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IAWtC;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAS5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;;;;;;;;OAaG;IACG,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAMxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;;;;;;;OAYG;IACH,OAAO,EAAE,kBAAkB,CAIxB;IAEH;;;;;;;;OAQG;IACH,QAAQ,EAAE,kBAAkB,CAA4B;IAExD;;;;;;;;;OASG;IACH,KAAK,EAAE,kBAAkB,CAA4B;CACtD"}
1
+ {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../src/interceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,cAAc,EAAY,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,cAAc;IAC/D;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACpD;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAqB;IAE/C;;;;;;;;OAQG;gBACS,YAAY,GAAE,WAAW,EAAO;IAI5C;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IAWtC;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAS5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;;;;;;;;OAaG;IACG,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAMxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;;;;;;;OAYG;IACH,OAAO,EAAE,kBAAkB,CAIxB;IAEH;;;;;;;;;OASG;IACH,QAAQ,EAAE,kBAAkB,CAA4B;IAExD;;;;;;;;;;OAUG;IACH,KAAK,EAAE,kBAAkB,CAA4B;CACtD"}
@@ -1,26 +1,20 @@
1
1
  import { Interceptor } from './interceptor';
2
2
  import { FetchExchange } from './fetchExchange';
3
3
  /**
4
- * RequestBodyInterceptor Class
5
- *
6
4
  * Interceptor responsible for converting plain objects to JSON strings for HTTP request bodies.
7
- * This interceptor ensures that object request bodies are properly serialized and that
8
- * the appropriate Content-Type header is set.
9
5
  *
10
- * @remarks
11
- * This interceptor runs early in the request processing chain with the lowest possible
12
- * order value (Number.MIN_SAFE_INTEGER) to ensure request bodies are properly formatted
13
- * before other interceptors process them.
6
+ * This interceptor ensures that object request bodies are properly serialized and that
7
+ * the appropriate Content-Type header is set. It runs early in the request processing chain
8
+ * to ensure request bodies are properly formatted before other interceptors process them.
14
9
  */
15
10
  export declare class RequestBodyInterceptor implements Interceptor {
16
11
  /**
17
- * Interceptor name, used for identification and management
12
+ * Interceptor name, used for identification and management.
18
13
  */
19
14
  name: string;
20
15
  /**
21
- * Interceptor execution order, set to run after UrlResolveInterceptor but before FetchInterceptor
16
+ * Interceptor execution order, set to run after UrlResolveInterceptor but before FetchInterceptor.
22
17
  *
23
- * @remarks
24
18
  * This interceptor should run after URL resolution (UrlResolveInterceptor) but before
25
19
  * the actual HTTP request is made (FetchInterceptor). The order is set to
26
20
  * Number.MIN_SAFE_INTEGER + 200 to ensure it executes in the correct position
@@ -29,7 +23,7 @@ export declare class RequestBodyInterceptor implements Interceptor {
29
23
  */
30
24
  order: number;
31
25
  /**
32
- * Attempts to convert request body to a valid fetch API body type
26
+ * Attempts to convert request body to a valid fetch API body type.
33
27
  *
34
28
  * According to the Fetch API specification, body can be multiple types, but for
35
29
  * plain objects, they need to be converted to JSON strings.
@@ -51,18 +45,19 @@ export declare class RequestBodyInterceptor implements Interceptor {
51
45
  * converted to JSON strings.
52
46
  *
53
47
  * @param exchange - The exchange object containing the request to process
54
- * @returns The processed exchange object with potentially modified request body
55
48
  *
56
49
  * @example
57
50
  * // Plain object body will be converted to JSON
58
- * const exchange = {
59
- * request: {
51
+ * const fetcher = new Fetcher();
52
+ * const exchange = new FetchExchange(
53
+ * fetcher,
54
+ * {
60
55
  * body: { name: 'John', age: 30 }
61
56
  * }
62
- * };
63
- * const result = interceptor.intercept(exchange);
64
- * // result.request.body will be '{"name":"John","age":30}'
65
- * // result.request.headers will include 'Content-Type: application/json'
57
+ * );
58
+ * interceptor.intercept(exchange);
59
+ * // exchange.request.body will be '{"name":"John","age":30}'
60
+ * // exchange.request.headers will include 'Content-Type: application/json'
66
61
  */
67
62
  intercept(exchange: FetchExchange): void;
68
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"requestBodyInterceptor.d.ts","sourceRoot":"","sources":["../src/requestBodyInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,YAAW,WAAW;IACxD;;OAEG;IACH,IAAI,SAA4B;IAEhC;;;;;;;;;OASG;IACH,KAAK,SAAiC;IAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa;CA0ClC"}
1
+ {"version":3,"file":"requestBodyInterceptor.d.ts","sourceRoot":"","sources":["../src/requestBodyInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,WAAW;IACxD;;OAEG;IACH,IAAI,SAA4B;IAEhC;;;;;;;;OAQG;IACH,KAAK,SAAiC;IAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa;CA0ClC"}
package/dist/timeout.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { FetchRequest } from './fetchRequest';
2
2
  /**
3
- * TimeoutCapable Interface
4
- *
5
3
  * Interface that defines timeout capability for HTTP requests.
4
+ *
5
+ * Objects implementing this interface can specify timeout values for HTTP requests.
6
6
  */
7
7
  export interface TimeoutCapable {
8
8
  /**
9
- * Request timeout in milliseconds
9
+ * Request timeout in milliseconds.
10
10
  *
11
11
  * When the value is 0, it indicates no timeout should be set.
12
12
  * The default value is undefined.
@@ -14,7 +14,7 @@ export interface TimeoutCapable {
14
14
  timeout?: number;
15
15
  }
16
16
  /**
17
- * Resolves request timeout settings, prioritizing request-level timeout settings
17
+ * Resolves request timeout settings, prioritizing request-level timeout settings.
18
18
  *
19
19
  * @param requestTimeout - Request-level timeout setting
20
20
  * @param optionsTimeout - Configuration-level timeout setting
@@ -26,38 +26,9 @@ export interface TimeoutCapable {
26
26
  */
27
27
  export declare function resolveTimeout(requestTimeout?: number, optionsTimeout?: number): number | undefined;
28
28
  /**
29
- * FetchTimeoutError Class
30
- *
31
- * Exception class thrown when an HTTP request times out.
32
- * This error is thrown by the timeoutFetch function when a request exceeds its timeout limit.
33
- *
34
- * @example
35
- * ```typescript
36
- * try {
37
- * const response = await timeoutFetch('https://api.example.com/users', {}, 1000);
38
- * } catch (error) {
39
- * if (error instanceof FetchTimeoutError) {
40
- * console.log(`Request timed out after ${error.timeout}ms`);
41
- * }
42
- * }
43
- * ```
44
- */
45
- export declare class FetchTimeoutError extends Error {
46
- /**
47
- * The request options that timed out
48
- */
49
- request: FetchRequest;
50
- /**
51
- * Creates a new FetchTimeoutError instance
52
- *
53
- * @param request - The request options that timed out
54
- */
55
- constructor(request: FetchRequest);
56
- }
57
- /**
58
- * HTTP request method with timeout control
29
+ * HTTP request method with timeout control.
59
30
  *
60
- * This method uses Promise.race to implement timeout control, initiating both
31
+ * Uses Promise.race to implement timeout control, initiating both
61
32
  * fetch request and timeout Promise simultaneously. When either Promise completes,
62
33
  * it returns the result or throws an exception.
63
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../src/timeout.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,cAAc,CAAC,EAAE,MAAM,EACvB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,GAAG,SAAS,CAKpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;;;OAIG;gBACS,OAAO,EAAE,YAAY;CASlC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyC3E"}
1
+ {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../src/timeout.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,cAAc,CAAC,EAAE,MAAM,EACvB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,GAAG,SAAS,CAKpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyC3E"}
@@ -1,10 +1,14 @@
1
1
  import { BaseURLCapable, FetchRequest } from './fetchRequest';
2
2
  /**
3
- * Interface for URL parameters including path and query parameters
3
+ * Container for URL parameters including path and query parameters.
4
+ *
5
+ * Used to define dynamic parts of a URL including path placeholders and query string parameters.
4
6
  */
5
7
  export interface UrlParams {
6
8
  /**
7
- * Path parameter object used to replace placeholders in the URL (e.g., {id})
9
+ * Path parameter object used to replace placeholders in the URL (e.g., {id}).
10
+ *
11
+ * These parameters are used to substitute named placeholders in the URL path.
8
12
  *
9
13
  * @example
10
14
  * ```typescript
@@ -14,7 +18,9 @@ export interface UrlParams {
14
18
  */
15
19
  path?: Record<string, any>;
16
20
  /**
17
- * Query parameter object to be added to the URL query string
21
+ * Query parameter object to be added to the URL query string.
22
+ *
23
+ * These parameters are appended to the URL as a query string.
18
24
  *
19
25
  * @example
20
26
  * ```typescript
@@ -25,33 +31,31 @@ export interface UrlParams {
25
31
  query?: Record<string, any>;
26
32
  }
27
33
  /**
28
- * URL Builder class for constructing complete URLs with path parameters and query parameters
34
+ * Utility class for constructing complete URLs with path parameters and query parameters.
29
35
  *
30
- * This class handles URL composition, path parameter interpolation, and query string generation.
31
- * It combines a base URL with a path, replaces path placeholders with actual values, and appends
36
+ * Handles URL composition, path parameter interpolation, and query string generation.
37
+ * Combines a base URL with a path, replaces path placeholders with actual values, and appends
32
38
  * query parameters to create a complete URL.
33
39
  *
34
40
  * @example
35
41
  * ```typescript
36
42
  * const urlBuilder = new UrlBuilder('https://api.example.com');
37
43
  * const url = urlBuilder.build('/users/{id}', {
38
- * urlParams: {
39
- * path: { id: 123 },
40
- * query: { filter: 'active' }
41
- * }
44
+ * path: { id: 123 },
45
+ * query: { filter: 'active' }
42
46
  * });
43
47
  * // Result: https://api.example.com/users/123?filter=active
44
48
  * ```
45
49
  */
46
50
  export declare class UrlBuilder implements BaseURLCapable {
47
51
  /**
48
- * Base URL that all constructed URLs will be based on
52
+ * Base URL that all constructed URLs will be based on.
49
53
  *
50
- * This is typically the root of your API endpoint (e.g., 'https://api.example.com')
54
+ * This is typically the root of your API endpoint (e.g., 'https://api.example.com').
51
55
  */
52
56
  baseURL: string;
53
57
  /**
54
- * Creates a UrlBuilder instance
58
+ * Initializes a new UrlBuilder instance.
55
59
  *
56
60
  * @param baseURL - Base URL that all constructed URLs will be based on
57
61
  *
@@ -62,7 +66,7 @@ export declare class UrlBuilder implements BaseURLCapable {
62
66
  */
63
67
  constructor(baseURL: string);
64
68
  /**
65
- * Builds a complete URL, including path parameter replacement and query parameter addition
69
+ * Builds a complete URL, including path parameter replacement and query parameter addition.
66
70
  *
67
71
  * @param url - URL path to build (e.g., '/users/{id}/posts')
68
72
  * @param params - URL parameters including path and query parameters
@@ -81,9 +85,9 @@ export declare class UrlBuilder implements BaseURLCapable {
81
85
  */
82
86
  build(url: string, params?: UrlParams): string;
83
87
  /**
84
- * Resolves a complete URL from a FetchRequest
88
+ * Resolves a complete URL from a FetchRequest.
85
89
  *
86
- * This method is used internally by the Fetcher to build the final URL for a request
90
+ * Used internally by the Fetcher to build the final URL for a request
87
91
  * by combining the request URL with its URL parameters using this UrlBuilder.
88
92
  *
89
93
  * @param request - The FetchRequest containing URL and URL parameters
@@ -91,7 +95,7 @@ export declare class UrlBuilder implements BaseURLCapable {
91
95
  */
92
96
  resolveRequestUrl(request: FetchRequest): string;
93
97
  /**
94
- * Replaces placeholders in the URL with path parameters
98
+ * Replaces placeholders in the URL with path parameters.
95
99
  *
96
100
  * @param url - Path string containing placeholders, e.g., "http://localhost/users/{id}/posts/{postId}"
97
101
  * @param path - Path parameter object used to replace placeholders in the URL
@@ -120,11 +124,13 @@ export declare class UrlBuilder implements BaseURLCapable {
120
124
  interpolateUrl(url: string, path?: Record<string, any> | null): string;
121
125
  }
122
126
  /**
123
- * Interface for objects that have a UrlBuilder capability
127
+ * Interface for objects that have a UrlBuilder capability.
128
+ *
129
+ * Indicates that an object has a UrlBuilder instance for URL construction.
124
130
  */
125
131
  export interface UrlBuilderCapable {
126
132
  /**
127
- * The UrlBuilder instance
133
+ * The UrlBuilder instance.
128
134
  */
129
135
  urlBuilder: UrlBuilder;
130
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"urlBuilder.d.ts","sourceRoot":"","sources":["../src/urlBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE3B;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;OASG;gBACS,OAAO,EAAE,MAAM;IAI3B;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM;IAc9C;;;;;;;;OAQG;IACH,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM;IAIhD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,MAAM;CAWvE;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB"}
1
+ {"version":3,"file":"urlBuilder.d.ts","sourceRoot":"","sources":["../src/urlBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;OASG;gBACS,OAAO,EAAE,MAAM;IAI3B;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM;IAc9C;;;;;;;;OAQG;IACH,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM;IAIhD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,MAAM;CAWvE;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB"}
@@ -1,17 +1,13 @@
1
1
  import { Interceptor } from './interceptor';
2
2
  import { FetchExchange } from './fetchExchange';
3
3
  /**
4
- * URL Resolution Interceptor
4
+ * Interceptor responsible for resolving the final URL for a request.
5
5
  *
6
- * This interceptor is responsible for resolving the final URL for a request by combining
7
- * the base URL, path parameters, and query parameters. It should be executed early in
6
+ * This interceptor combines the base URL, path parameters, and query parameters
7
+ * to create the final URL for a request. It should be executed early in
8
8
  * the interceptor chain to ensure the URL is properly resolved before other interceptors
9
9
  * process the request.
10
10
  *
11
- * @remarks
12
- * This interceptor has the lowest possible order (Number.MIN_SAFE_INTEGER) to ensure
13
- * it runs first in the request interceptor chain, before any other request processing.
14
- *
15
11
  * @example
16
12
  * // With baseURL: 'https://api.example.com'
17
13
  * // Request URL: '/users/{id}'
@@ -21,13 +17,12 @@ import { FetchExchange } from './fetchExchange';
21
17
  */
22
18
  export declare class UrlResolveInterceptor implements Interceptor {
23
19
  /**
24
- * The name of this interceptor
20
+ * The name of this interceptor.
25
21
  */
26
22
  name: string;
27
23
  /**
28
- * The order of this interceptor (executed first)
24
+ * The order of this interceptor (executed first).
29
25
  *
30
- * @remarks
31
26
  * This interceptor should run first in the request interceptor chain to ensure
32
27
  * URL resolution happens before any other request processing. The order is set to
33
28
  * Number.MIN_SAFE_INTEGER + 100 to allow for other interceptors that need to run
@@ -35,10 +30,9 @@ export declare class UrlResolveInterceptor implements Interceptor {
35
30
  */
36
31
  order: number;
37
32
  /**
38
- * Resolves the final URL by combining the base URL, path parameters, and query parameters
33
+ * Resolves the final URL by combining the base URL, path parameters, and query parameters.
39
34
  *
40
35
  * @param exchange - The fetch exchange containing the request information
41
- * @returns The modified exchange with the resolved URL
42
36
  */
43
37
  intercept(exchange: FetchExchange): void;
44
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolveInterceptor.d.ts","sourceRoot":"","sources":["../src/urlResolveInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACvD;;OAEG;IACH,IAAI,SAA2B;IAE/B;;;;;;;;OAQG;IACH,KAAK,SAAiC;IAEtC;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa;CAIlC"}
1
+ {"version":3,"file":"urlResolveInterceptor.d.ts","sourceRoot":"","sources":["../src/urlResolveInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACvD;;OAEG;IACH,IAAI,SAA2B;IAE/B;;;;;;;OAOG;IACH,KAAK,SAAiC;IAEtC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa;CAIlC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/fetcher",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Ultra-lightweight (1.9kB) HTTP client with built-in path parameters and Axios-like API",
5
5
  "keywords": [
6
6
  "fetch",