@@ -217,27 +217,27 @@ export abstract class APIClient {
217
217
return `stainless-node-retry-${ uuid4 ( ) } ` ;
218
218
}
219
219
220
- get < Req extends { } , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
220
+ get < Req , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
221
221
return this . methodRequest ( 'get' , path , opts ) ;
222
222
}
223
223
224
- post < Req extends { } , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
224
+ post < Req , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
225
225
return this . methodRequest ( 'post' , path , opts ) ;
226
226
}
227
227
228
- patch < Req extends { } , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
228
+ patch < Req , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
229
229
return this . methodRequest ( 'patch' , path , opts ) ;
230
230
}
231
231
232
- put < Req extends { } , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
232
+ put < Req , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
233
233
return this . methodRequest ( 'put' , path , opts ) ;
234
234
}
235
235
236
- delete < Req extends { } , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
236
+ delete < Req , Rsp > ( path : string , opts ?: PromiseOrValue < RequestOptions < Req > > ) : APIPromise < Rsp > {
237
237
return this . methodRequest ( 'delete' , path , opts ) ;
238
238
}
239
239
240
- private methodRequest < Req extends { } , Rsp > (
240
+ private methodRequest < Req , Rsp > (
241
241
method : HTTPMethod ,
242
242
path : string ,
243
243
opts ?: PromiseOrValue < RequestOptions < Req > > ,
@@ -269,9 +269,7 @@ export abstract class APIClient {
269
269
return null ;
270
270
}
271
271
272
- buildRequest < Req extends { } > (
273
- options : FinalRequestOptions < Req > ,
274
- ) : { req : RequestInit ; url : string ; timeout : number } {
272
+ buildRequest < Req > ( options : FinalRequestOptions < Req > ) : { req : RequestInit ; url : string ; timeout : number } {
275
273
const { method, path, query, headers : headers = { } } = options ;
276
274
277
275
const body =
@@ -373,15 +371,15 @@ export abstract class APIClient {
373
371
return APIError . generate ( status , error , message , headers ) ;
374
372
}
375
373
376
- request < Req extends { } , Rsp > (
374
+ request < Req , Rsp > (
377
375
options : PromiseOrValue < FinalRequestOptions < Req > > ,
378
376
remainingRetries : number | null = null ,
379
377
) : APIPromise < Rsp > {
380
378
return new APIPromise ( this . makeRequest ( options , remainingRetries ) ) ;
381
379
}
382
380
383
- private async makeRequest (
384
- optionsInput : PromiseOrValue < FinalRequestOptions > ,
381
+ private async makeRequest < Req > (
382
+ optionsInput : PromiseOrValue < FinalRequestOptions < Req > > ,
385
383
retriesRemaining : number | null ,
386
384
) : Promise < APIResponseProps > {
387
385
const options = await optionsInput ;
@@ -443,7 +441,7 @@ export abstract class APIClient {
443
441
return new PagePromise < PageClass , Item > ( this , request , Page ) ;
444
442
}
445
443
446
- buildURL < Req extends Record < string , unknown > > ( path : string , query : Req | null | undefined ) : string {
444
+ buildURL < Req > ( path : string , query : Req | null | undefined ) : string {
447
445
const url =
448
446
isAbsoluteURL ( path ) ?
449
447
new URL ( path )
@@ -617,7 +615,7 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
617
615
) ;
618
616
}
619
617
const nextOptions = { ...this . options } ;
620
- if ( 'params' in nextInfo ) {
618
+ if ( 'params' in nextInfo && typeof nextOptions . query === 'object' ) {
621
619
nextOptions . query = { ...nextOptions . query , ...nextInfo . params } ;
622
620
} else if ( 'url' in nextInfo ) {
623
621
const params = [ ...Object . entries ( nextOptions . query || { } ) , ...nextInfo . url . searchParams . entries ( ) ] ;
@@ -715,7 +713,7 @@ export type Headers = Record<string, string | null | undefined>;
715
713
export type DefaultQuery = Record < string , string | undefined > ;
716
714
export type KeysEnum < T > = { [ P in keyof Required < T > ] : true } ;
717
715
718
- export type RequestOptions < Req extends { } = Record < string , unknown > | Readable > = {
716
+ export type RequestOptions < Req = unknown | Record < string , unknown > | Readable > = {
719
717
method ?: HTTPMethod ;
720
718
path ?: string ;
721
719
query ?: Req | undefined ;
@@ -752,7 +750,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
752
750
__binaryResponse : true ,
753
751
} ;
754
752
755
- export const isRequestOptions = ( obj : unknown ) : obj is RequestOptions < Record < string , unknown > | Readable > => {
753
+ export const isRequestOptions = ( obj : unknown ) : obj is RequestOptions => {
756
754
return (
757
755
typeof obj === 'object' &&
758
756
obj !== null &&
@@ -761,7 +759,7 @@ export const isRequestOptions = (obj: unknown): obj is RequestOptions<Record<str
761
759
) ;
762
760
} ;
763
761
764
- export type FinalRequestOptions < Req extends { } = Record < string , unknown > | Readable > = RequestOptions < Req > & {
762
+ export type FinalRequestOptions < Req = unknown | Record < string , unknown > | Readable > = RequestOptions < Req > & {
765
763
method : HTTPMethod ;
766
764
path : string ;
767
765
} ;
0 commit comments