@@ -23,6 +23,15 @@ export type ApplyDefaults<Defaults, Target> = {
2323 [ K in keyof Target as K extends keyof Defaults ? K : never ] : Target [ K ]
2424} ;
2525
26+ declare global {
27+ interface RequestInit {
28+ next ?: {
29+ revalidate ?: boolean | number ;
30+ tags ?: string [ ] ;
31+ } ;
32+ }
33+ }
34+
2635export type RouteOptions = {
2736 headers ?: HeadersInit ;
2837 params ?: unknown ;
@@ -37,6 +46,8 @@ export type DefaultRouteOptions = {
3746 payload ?: never ;
3847 query ?: never ;
3948 response ?: unknown ;
49+ cache ?: RequestInit [ "cache" ] ;
50+ next ?: RequestInit [ "next" ] ;
4051} ;
4152
4253export type RouteDefinition = Record < string , RouteOptions > ;
@@ -114,7 +125,7 @@ export class Client<T extends RouteTable> {
114125 }
115126 }
116127
117- async #fetch< O extends RouteOptions = RouteOptions > ( method : RequestMethod , path : string , options ?: WithoutResponse < O > ) : Promise < ClientResponse < O [ "response" ] > > {
128+ async #fetch< O extends DefaultRouteOptions = DefaultRouteOptions > ( method : RequestMethod , path : string , options ?: WithoutResponse < O > ) : Promise < ClientResponse < O [ "response" ] > > {
118129 const realPath = options && "params" in options
119130 ? replaceParams ( path , options . params as Record < string , string > )
120131 : path ;
@@ -167,6 +178,8 @@ export class Client<T extends RouteTable> {
167178 method,
168179 headers,
169180 body : options && "payload" in options ? JSON . stringify ( options . payload ) : undefined ,
181+ cache : options ?. cache ,
182+ next : options ?. next ,
170183 } ) ;
171184
172185 const isJsonResponse = fetchResponse . headers . get ( "content-type" ) ?. startsWith ( "application/json" ) ;
0 commit comments