@@ -2,14 +2,14 @@ import type { Server } from "@hapi/hapi";
2
2
import type {
3
3
AvailablePaths ,
4
4
FetchOptions ,
5
- HasRequiredFields ,
6
5
MatchingRoute ,
7
6
RequestMethod ,
8
7
ResponseType ,
9
8
BodyType ,
10
9
Route ,
11
10
Simplify ,
12
11
StatusCode ,
12
+ OptionsArgument ,
13
13
} from "./types.ts" ;
14
14
15
15
export type * from "./types.ts" ;
@@ -21,7 +21,7 @@ export type ClientOptions = Simplify<
21
21
> ;
22
22
23
23
export class Client < T extends Route > {
24
- #url: URL ;
24
+ #url: URL | undefined ;
25
25
#server: Server | undefined ;
26
26
#headers: Headers ;
27
27
@@ -121,47 +121,47 @@ export class Client<T extends Route> {
121
121
P extends AvailablePaths < T , "DELETE" > ,
122
122
R extends MatchingRoute < T , "DELETE" , P > ,
123
123
O extends FetchOptions < R > ,
124
- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
124
+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
125
125
return await this . #fetch( "DELETE" , path , args [ 0 ] ) ;
126
126
}
127
127
128
128
async get <
129
129
P extends AvailablePaths < T , "GET" > ,
130
130
R extends MatchingRoute < T , "GET" , P > ,
131
131
O extends FetchOptions < R > ,
132
- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
132
+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
133
133
return await this . #fetch( "GET" , path , args [ 0 ] ) ;
134
134
}
135
135
136
136
async options <
137
137
P extends AvailablePaths < T , "OPTIONS" > ,
138
138
R extends MatchingRoute < T , "OPTIONS" , P > ,
139
139
O extends FetchOptions < R > ,
140
- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
140
+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
141
141
return await this . #fetch( "OPTIONS" , path , args [ 0 ] ) ;
142
142
}
143
143
144
144
async patch <
145
145
P extends AvailablePaths < T , "PATCH" > ,
146
146
R extends MatchingRoute < T , "PATCH" , P > ,
147
147
O extends FetchOptions < R > ,
148
- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
148
+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
149
149
return await this . #fetch( "PATCH" , path , args [ 0 ] ) ;
150
150
}
151
151
152
152
async post <
153
153
P extends AvailablePaths < T , "POST" > ,
154
154
R extends MatchingRoute < T , "POST" , P > ,
155
155
O extends FetchOptions < R > ,
156
- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
156
+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
157
157
return await this . #fetch( "POST" , path , args [ 0 ] ) ;
158
158
}
159
159
160
160
async put <
161
161
P extends AvailablePaths < T , "PUT" > ,
162
162
R extends MatchingRoute < T , "PUT" , P > ,
163
163
O extends FetchOptions < R > ,
164
- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
164
+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
165
165
return await this . #fetch( "PUT" , path , args [ 0 ] ) ;
166
166
}
167
167
}
0 commit comments