@@ -43,8 +43,8 @@ export type RequestOptions<CO extends CacheOptions = CacheOptions> =
43
43
| ( (
44
44
url : string ,
45
45
response : FetcherResponse ,
46
- request : RequestOptions ,
47
- ) => Promise < CO | undefined > ) ;
46
+ request : RequestOptions < CO > ,
47
+ ) => ValueOrPromise < CO | undefined > ) ;
48
48
/**
49
49
* If provided, this is passed through as the third argument to `new
50
50
* CachePolicy()` from the `http-cache-semantics` npm package as part of the
@@ -205,7 +205,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
205
205
// won't return a cache entry whose Vary-ed header field doesn't match, new
206
206
// responses can overwrite old ones with different Vary-ed header fields if
207
207
// you don't take the header into account in the cache key.
208
- protected cacheKeyFor ( url : URL , request : RequestOptions ) : string {
208
+ protected cacheKeyFor ( url : URL , request : RequestOptions < CO > ) : string {
209
209
return request . cacheKey ?? `${ request . method ?? 'GET' } ${ url } ` ;
210
210
}
211
211
@@ -227,7 +227,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
227
227
*/
228
228
protected requestDeduplicationPolicyFor (
229
229
url : URL ,
230
- request : RequestOptions ,
230
+ request : RequestOptions < CO > ,
231
231
) : RequestDeduplicationPolicy {
232
232
const method = request . method ?? 'GET' ;
233
233
// Start with the cache key that is used for the shared header-sensitive
@@ -258,12 +258,12 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
258
258
259
259
protected willSendRequest ?(
260
260
path : string ,
261
- requestOpts : AugmentedRequest ,
261
+ requestOpts : AugmentedRequest < CO > ,
262
262
) : ValueOrPromise < void > ;
263
263
264
264
protected resolveURL (
265
265
path : string ,
266
- _request : AugmentedRequest ,
266
+ _request : AugmentedRequest < CO > ,
267
267
) : ValueOrPromise < URL > {
268
268
return new URL ( path , this . baseURL ) ;
269
269
}
@@ -276,7 +276,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
276
276
277
277
protected didEncounterError (
278
278
_error : Error ,
279
- _request : RequestOptions ,
279
+ _request : RequestOptions < CO > ,
280
280
// TODO(v7): this shouldn't be optional in a future major version
281
281
_url ?: URL ,
282
282
) {
@@ -331,7 +331,9 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
331
331
return cloneDeep ( parsedBody ) ;
332
332
}
333
333
334
- protected shouldJSONSerializeBody ( body : RequestWithBody [ 'body' ] ) : boolean {
334
+ protected shouldJSONSerializeBody (
335
+ body : RequestWithBody < CO > [ 'body' ] ,
336
+ ) : boolean {
335
337
return ! ! (
336
338
// We accept arbitrary objects and arrays as body and serialize them as JSON.
337
339
(
@@ -352,7 +354,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
352
354
353
355
protected async throwIfResponseIsError ( options : {
354
356
url : URL ;
355
- request : RequestOptions ;
357
+ request : RequestOptions < CO > ;
356
358
response : FetcherResponse ;
357
359
parsedBody : unknown ;
358
360
} ) {
@@ -367,7 +369,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
367
369
parsedBody,
368
370
} : {
369
371
url ?: URL ;
370
- request ?: RequestOptions ;
372
+ request ?: RequestOptions < CO > ;
371
373
response : FetcherResponse ;
372
374
parsedBody : unknown ;
373
375
} ) {
@@ -483,7 +485,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
483
485
} ) ;
484
486
}
485
487
486
- const augmentedRequest : AugmentedRequest = {
488
+ const augmentedRequest : AugmentedRequest < CO > = {
487
489
...incomingRequest ,
488
490
// guarantee params and headers objects before calling `willSendRequest` for convenience
489
491
params :
@@ -632,7 +634,7 @@ export abstract class RESTDataSource<CO extends CacheOptions = CacheOptions> {
632
634
633
635
protected async trace < TResult > (
634
636
url : URL ,
635
- request : RequestOptions ,
637
+ request : RequestOptions < CO > ,
636
638
fn : ( ) => Promise < TResult > ,
637
639
) : Promise < TResult > {
638
640
if ( NODE_ENV === 'development' ) {
0 commit comments