@ahoo-wang/fetcher 1.6.1 → 1.6.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.
@@ -18,7 +18,7 @@ export interface AttributesCapable {
18
18
  * - Consider namespacing your keys (e.g., 'mylib.retryCount' instead of 'retryCount')
19
19
  * - Be mindful of memory usage when storing large objects
20
20
  */
21
- attributes?: Record<string, any>;
21
+ attributes?: Record<string, any> | Map<string, any>;
22
22
  }
23
23
  export interface FetchExchangeInit extends AttributesCapable {
24
24
  /**
@@ -121,7 +121,7 @@ export declare class FetchExchange implements RequiredBy<FetchExchangeInit, 'att
121
121
  * - Consider namespacing your keys (e.g., 'mylib.retryCount' instead of 'retryCount')
122
122
  * - Be mindful of memory usage when storing large objects
123
123
  */
124
- attributes: Record<string, any>;
124
+ attributes: Map<string, any>;
125
125
  constructor(exchangeInit: FetchExchangeInit);
126
126
  /**
127
127
  * Ensures that request headers object exists, creating it if necessary.
@@ -183,11 +183,11 @@ export declare class FetchExchange implements RequiredBy<FetchExchangeInit, 'att
183
183
  */
184
184
  get requiredResponse(): Response;
185
185
  /**
186
- * Gets the extracted result by applying the result extractor to the exchange.
187
- * The result is cached after the first computation.
186
+ * Extracts the result by applying the result extractor to the exchange.
187
+ * The result is cached after the first computation to avoid repeated computations.
188
188
  *
189
- * @returns The extracted result or null if extraction failed
189
+ * @returns The extracted result
190
190
  */
191
- typedExtractedResult<R = any>(): R | Promise<R>;
191
+ extractResult<R>(): R | Promise<R>;
192
192
  }
193
193
  //# sourceMappingURL=fetchExchange.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchExchange.d.ts","sourceRoot":"","sources":["../src/fetchExchange.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,KAAK,SAAS,EAAE,MA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;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,aACX,YAAW,UAAU,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACtD;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;;OAGG;IACH,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC;;OAEG;IACH,OAAO,CAAC,SAAS,CAAC,CAAW;IAE7B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,qBAAqB,CAAC,CAAqB;IACnD;;;;;;;;;;;;;OAaG;IACH,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAEjB,YAAY,EAAE,iBAAiB;IAS3C;;;;;;;;OAQG;IACH,oBAAoB,IAAI,cAAc;IAOtC;;;;;;;;;;OAUG;IACH,sBAAsB,IAAI,QAAQ,CAAC,SAAS,CAAC;IAgB7C;;;;OAIG;IACH,QAAQ,IAAI,OAAO;IAInB;;;;;;OAMG;IACH,IAAI,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAG1C;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,QAAQ,GAAG,SAAS,CAEnC;IAED;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;;;OASG;IACH,IAAI,gBAAgB,IAAI,QAAQ,CAQ/B;IAED;;;;;OAKG;IACH,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAOnC"}
package/dist/fetcher.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { UrlBuilder, UrlBuilderCapable } from './urlBuilder';
2
2
  import { TimeoutCapable } from './timeout';
3
- import { FetchExchange } from './fetchExchange';
3
+ import { AttributesCapable, FetchExchange } from './fetchExchange';
4
4
  import { BaseURLCapable, FetchRequest, FetchRequestInit, RequestHeaders, RequestHeadersCapable } from './fetchRequest';
5
5
  import { InterceptorManager } from './interceptorManager';
6
6
  import { UrlTemplateStyle } from './urlTemplateResolver';
7
- import { ResultExtractor } from './resultExtractor';
7
+ import { ResultExtractorCapable } from './resultExtractor';
8
8
  /**
9
9
  * Configuration options for the Fetcher client.
10
10
  *
@@ -23,10 +23,25 @@ import { ResultExtractor } from './resultExtractor';
23
23
  * ```
24
24
  */
25
25
  export interface FetcherOptions extends BaseURLCapable, RequestHeadersCapable, TimeoutCapable {
26
+ /**
27
+ * The style of URL template to use for URL parameter interpolation.
28
+ * @default UrlTemplateStyle.Path
29
+ */
26
30
  urlTemplateStyle?: UrlTemplateStyle;
31
+ /**
32
+ * The interceptor manager to use for request/response processing.
33
+ * @default new InterceptorManager()
34
+ */
27
35
  interceptors?: InterceptorManager;
28
36
  }
29
37
  export declare const DEFAULT_OPTIONS: FetcherOptions;
38
+ /**
39
+ * Options for individual requests.
40
+ */
41
+ export interface RequestOptions extends AttributesCapable, ResultExtractorCapable {
42
+ }
43
+ export declare const DEFAULT_REQUEST_OPTIONS: RequestOptions;
44
+ export declare const DEFAULT_FETCH_OPTIONS: RequestOptions;
30
45
  /**
31
46
  * HTTP client with support for interceptors, URL building, and timeout control.
32
47
  *
@@ -58,6 +73,11 @@ export declare class Fetcher implements UrlBuilderCapable, RequestHeadersCapable
58
73
  * If no interceptors are provided, a default set of interceptors will be used.
59
74
  *
60
75
  * @param options - Configuration options for the Fetcher instance
76
+ * @param options.baseURL - The base URL to prepend to all requests. Defaults to empty string.
77
+ * @param options.headers - Default headers to include in all requests. Defaults to JSON content type.
78
+ * @param options.timeout - Default timeout for requests in milliseconds. No timeout by default.
79
+ * @param options.urlTemplateStyle - Style for URL template parameter interpolation.
80
+ * @param options.interceptors - Interceptor manager for processing requests and responses.
61
81
  */
62
82
  constructor(options?: FetcherOptions);
63
83
  /**
@@ -67,48 +87,53 @@ export declare class Fetcher implements UrlBuilderCapable, RequestHeadersCapable
67
87
  * creates a FetchExchange object, and passes it through the exchange method
68
88
  * for interceptor processing.
69
89
  *
90
+ * @template R - The type of the result to be returned
70
91
  * @param request - Complete request configuration object
71
- * @param resultExtractor - Function to extract the desired result from the exchange.
72
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
73
- * @param attributes - Optional shared attributes that can be accessed by interceptors
74
- * throughout the request lifecycle. These attributes allow passing
75
- * custom data between different interceptors.
92
+ * @param options - Request options including result extractor and attributes
93
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
94
+ * Defaults to ExchangeResultExtractor which returns the entire exchange object.
95
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
96
+ * throughout the request lifecycle. These attributes allow passing
97
+ * custom data between different interceptors.
76
98
  * @returns Promise that resolves to the extracted result based on resultExtractor
77
99
  * @throws Error if an unhandled error occurs during request processing
78
100
  */
79
- request<R = FetchExchange>(request: FetchRequest, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
101
+ request<R = FetchExchange>(request: FetchRequest, options?: RequestOptions): Promise<R>;
80
102
  /**
81
103
  * Executes an HTTP request with the specified URL and options.
82
104
  *
83
105
  * This is the primary method for making HTTP requests. It processes the request
84
106
  * through the interceptor chain and returns the resulting Response.
85
107
  *
108
+ * @template R - The type of the result to be returned
86
109
  * @param url - The URL path for the request (relative to baseURL if set)
87
110
  * @param request - Request configuration including headers, body, parameters, etc.
88
- * @param resultExtractor - Function to extract the desired result from the exchange.
89
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
90
- * @param attributes - Optional shared attributes that can be accessed by interceptors
91
- * throughout the request lifecycle. These attributes allow passing
92
- * custom data between different interceptors.
93
-
111
+ * @param options - Request options including result extractor and attributes
112
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
113
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
114
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
115
+ * throughout the request lifecycle. These attributes allow passing
116
+ * custom data between different interceptors.
94
117
  * @returns Promise that resolves to the HTTP response
95
118
  * @throws FetchError if the request fails and no response is generated
96
119
  */
97
- fetch<R = Response>(url: string, request?: FetchRequestInit, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
120
+ fetch<R = Response>(url: string, request?: FetchRequestInit, options?: RequestOptions): Promise<R>;
98
121
  /**
99
122
  * Internal helper method for making HTTP requests with a specific method.
100
123
  *
101
124
  * This private method is used by the public HTTP method methods (get, post, etc.)
102
125
  * to execute requests with the appropriate HTTP verb.
103
126
  *
127
+ * @template R - The type of the result to be returned
104
128
  * @param method - The HTTP method to use for the request
105
129
  * @param url - The URL path for the request
106
130
  * @param request - Additional request options
107
- * @param resultExtractor - Function to extract the desired result from the exchange.
108
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
109
- * @param attributes - Optional shared attributes that can be accessed by interceptors
110
- * throughout the request lifecycle. These attributes allow passing
111
- * custom data between different interceptors.
131
+ * @param options - Request options including result extractor and attributes
132
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
133
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
134
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
135
+ * throughout the request lifecycle. These attributes allow passing
136
+ * custom data between different interceptors.
112
137
  * @returns Promise that resolves to the HTTP response
113
138
  */
114
139
  private methodFetch;
@@ -118,107 +143,121 @@ export declare class Fetcher implements UrlBuilderCapable, RequestHeadersCapable
118
143
  * Convenience method for making GET requests. The request body is omitted
119
144
  * as GET requests should not contain a body according to HTTP specification.
120
145
  *
146
+ * @template R - The type of the result to be returned
121
147
  * @param url - The URL path for the request
122
148
  * @param request - Request options excluding method and body
123
- * @param resultExtractor - Function to extract the desired result from the exchange.
124
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
125
- * @param attributes - Optional shared attributes that can be accessed by interceptors
126
- * throughout the request lifecycle. These attributes allow passing
127
- * custom data between different interceptors.
149
+ * @param options - Request options including result extractor and attributes
150
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
151
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
152
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
153
+ * throughout the request lifecycle. These attributes allow passing
154
+ * custom data between different interceptors.
128
155
  * @returns Promise that resolves to the HTTP response
129
156
  */
130
- get<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
157
+ get<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, options?: RequestOptions): Promise<R>;
131
158
  /**
132
- * Makes a POST HTTP request.
159
+ * Makes a PUT HTTP request.
133
160
  *
134
- * Convenience method for making POST requests, commonly used for creating resources.
161
+ * Convenience method for making PUT requests, commonly used for updating resources.
135
162
  *
163
+ * @template R - The type of the result to be returned
136
164
  * @param url - The URL path for the request
137
165
  * @param request - Request options including body and other parameters
138
- * @param resultExtractor - Function to extract the desired result from the exchange.
139
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
140
- * @param attributes - Optional shared attributes that can be accessed by interceptors
141
- * throughout the request lifecycle. These attributes allow passing
142
- * custom data between different interceptors.
166
+ * @param options - Request options including result extractor and attributes
167
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
168
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
169
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
170
+ * throughout the request lifecycle. These attributes allow passing
171
+ * custom data between different interceptors.
143
172
  * @returns Promise that resolves to the HTTP response
144
173
  */
145
- post<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
174
+ put<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, options?: RequestOptions): Promise<R>;
146
175
  /**
147
- * Makes a PUT HTTP request.
176
+ * Makes a POST HTTP request.
148
177
  *
149
- * Convenience method for making PUT requests, commonly used for updating resources.
178
+ * Convenience method for making POST requests, commonly used for creating resources.
150
179
  *
180
+ * @template R - The type of the result to be returned
151
181
  * @param url - The URL path for the request
152
182
  * @param request - Request options including body and other parameters
153
- * @param resultExtractor - Function to extract the desired result from the exchange.
154
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
155
- * @param attributes - Optional shared attributes that can be accessed by interceptors
156
- * throughout the request lifecycle. These attributes allow passing
157
- * custom data between different interceptors.
183
+ * @param options - Request options including result extractor and attributes
184
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
185
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
186
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
187
+ * throughout the request lifecycle. These attributes allow passing
188
+ * custom data between different interceptors.
158
189
  * @returns Promise that resolves to the HTTP response
159
190
  */
160
- put<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
191
+ post<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, options?: RequestOptions): Promise<R>;
161
192
  /**
162
- * Makes a DELETE HTTP request.
193
+ * Makes a PATCH HTTP request.
163
194
  *
164
- * Convenience method for making DELETE requests, commonly used for deleting resources.
195
+ * Convenience method for making PATCH requests, commonly used for partial updates.
165
196
  *
197
+ * @template R - The type of the result to be returned
166
198
  * @param url - The URL path for the request
167
- * @param request - Request options excluding method and body
168
- * @param resultExtractor - Function to extract the desired result from the exchange.
169
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
170
- * @param attributes - Optional shared attributes that can be accessed by interceptors
171
- * throughout the request lifecycle. These attributes allow passing
172
- * custom data between different interceptors.
199
+ * @param request - Request options including body and other parameters
200
+ * @param options - Request options including result extractor and attributes
201
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
202
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
203
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
204
+ * throughout the request lifecycle. These attributes allow passing
205
+ * custom data between different interceptors.
173
206
  * @returns Promise that resolves to the HTTP response
174
207
  */
175
- delete<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
208
+ patch<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, options?: RequestOptions): Promise<R>;
176
209
  /**
177
- * Makes a PATCH HTTP request.
210
+ * Makes a DELETE HTTP request.
178
211
  *
179
- * Convenience method for making PATCH requests, commonly used for partial updates.
212
+ * Convenience method for making DELETE requests, commonly used for deleting resources.
180
213
  *
214
+ * @template R - The type of the result to be returned
181
215
  * @param url - The URL path for the request
182
- * @param request - Request options including body and other parameters
183
- * @param resultExtractor - Function to extract the desired result from the exchange.
184
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
185
- * @param attributes - Optional shared attributes that can be accessed by interceptors
186
- * throughout the request lifecycle. These attributes allow passing
187
- * custom data between different interceptors.
216
+ * @param request - Request options excluding method and body
217
+ * @param options - Request options including result extractor and attributes
218
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
219
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
220
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
221
+ * throughout the request lifecycle. These attributes allow passing
222
+ * custom data between different interceptors.
188
223
  * @returns Promise that resolves to the HTTP response
189
224
  */
190
- patch<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
225
+ delete<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method'>, options?: RequestOptions): Promise<R>;
191
226
  /**
192
227
  * Makes a HEAD HTTP request.
193
228
  *
194
229
  * Convenience method for making HEAD requests, which retrieve headers only.
195
230
  * The request body is omitted as HEAD requests should not contain a body.
196
231
  *
232
+ * @template R - The type of the result to be returned
197
233
  * @param url - The URL path for the request
198
234
  * @param request - Request options excluding method and body
199
- * @param resultExtractor - Function to extract the desired result from the exchange.
200
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
201
- * @param attributes - Optional shared attributes that can be accessed by interceptors
202
- * throughout the request lifecycle. These attributes allow passing
203
- * custom data between different interceptors.
235
+ * @param options - Request options including result extractor and attributes
236
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
237
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
238
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
239
+ * throughout the request lifecycle. These attributes allow passing
240
+ * custom data between different interceptors.
204
241
  * @returns Promise that resolves to the HTTP response
205
242
  */
206
- head<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
243
+ head<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, options?: RequestOptions): Promise<R>;
207
244
  /**
208
245
  * Makes an OPTIONS HTTP request.
209
246
  *
210
247
  * Convenience method for making OPTIONS requests, commonly used for CORS preflight.
211
248
  * The request body is omitted as OPTIONS requests typically don't contain a body.
212
249
  *
250
+ * @template R - The type of the result to be returned
213
251
  * @param url - The URL path for the request
214
252
  * @param request - Request options excluding method and body
215
- * @param resultExtractor - Function to extract the desired result from the exchange.
216
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
217
- * @param attributes - Optional shared attributes that can be accessed by interceptors
218
- * throughout the request lifecycle. These attributes allow passing
219
- * custom data between different interceptors.
253
+ * @param options - Request options including result extractor and attributes
254
+ * @param options.resultExtractor - Function to extract the desired result from the exchange.
255
+ * Defaults to ResponseResultExtractor which returns the entire exchange object.
256
+ * @param options.attributes - Optional shared attributes that can be accessed by interceptors
257
+ * throughout the request lifecycle. These attributes allow passing
258
+ * custom data between different interceptors.
220
259
  * @returns Promise that resolves to the HTTP response
221
260
  */
222
- options<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, resultExtractor?: ResultExtractor<any>, attributes?: Record<string, any>): Promise<R>;
261
+ options<R = Response>(url: string, request?: Omit<FetchRequestInit, 'method' | 'body'>, options?: RequestOptions): Promise<R>;
223
262
  }
224
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