11import type {
22 Additional ,
3+ ApiOption ,
4+ BoildApiOption ,
35 ConditionalKeys ,
46 DevupApiRequestInit ,
57 DevupApiServers ,
@@ -16,9 +18,7 @@ import type {
1618 DevupPutApiStructKey ,
1719 DevupPutApiStructScope ,
1820 ExtractValue ,
19- IsCold ,
2021 Middleware ,
21- RequiredOptions ,
2222} from '@devup-api/core'
2323import { convertResponse } from './response-converter'
2424import { getApiEndpointInfo } from './url-map'
@@ -59,267 +59,157 @@ export class DevupApi<S extends ConditionalKeys<DevupApiServers>> {
5959 O extends Additional < T , DevupGetApiStructScope < S > > ,
6060 > (
6161 path : T ,
62- ...options : [ RequiredOptions < O > ] extends [ never ]
63- ? [
64- options ?: IsCold extends true
65- ? DevupApiRequestInit
66- : Omit < DevupApiRequestInit , 'params' > &
67- Omit < O , 'response' | 'error' > ,
68- ]
69- : [
70- options : Omit < DevupApiRequestInit , 'params' > &
71- Omit < O , 'response' | 'error' > ,
72- ]
62+ ...options : ApiOption < O >
7363 ) : Promise <
7464 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
7565 > {
7666 return this . request ( path , {
7767 method : 'GET' ,
7868 ...options [ 0 ] ,
79- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
69+ } as BoildApiOption < O > )
8070 }
8171
8272 GET <
8373 T extends DevupGetApiStructKey < S > ,
8474 O extends Additional < T , DevupGetApiStructScope < S > > ,
8575 > (
8676 path : T ,
87- ...options : [ RequiredOptions < O > ] extends [ never ]
88- ? [
89- options ?: IsCold extends true
90- ? DevupApiRequestInit
91- : Omit < DevupApiRequestInit , 'params' > &
92- Omit < O , 'response' | 'error' > ,
93- ]
94- : [
95- options : Omit < DevupApiRequestInit , 'params' > &
96- Omit < O , 'response' | 'error' > ,
97- ]
77+ ...options : ApiOption < O >
9878 ) : Promise <
9979 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
10080 > {
10181 return this . request ( path , {
10282 method : 'GET' ,
10383 ...options [ 0 ] ,
104- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
84+ } as BoildApiOption < O > )
10585 }
10686
10787 post <
10888 T extends DevupPostApiStructKey < S > ,
10989 O extends Additional < T , DevupPostApiStructScope < S > > ,
11090 > (
11191 path : T ,
112- ...options : [ RequiredOptions < O > ] extends [ never ]
113- ? [
114- options ?: IsCold extends true
115- ? DevupApiRequestInit
116- : Omit < DevupApiRequestInit , 'params' > &
117- Omit < O , 'response' | 'error' > ,
118- ]
119- : [
120- options : Omit < DevupApiRequestInit , 'params' > &
121- Omit < O , 'response' | 'error' > ,
122- ]
92+ ...options : ApiOption < O >
12393 ) : Promise <
12494 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
12595 > {
12696 return this . request ( path , {
12797 method : 'POST' ,
12898 ...options [ 0 ] ,
129- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
99+ } as BoildApiOption < O > )
130100 }
131101
132102 POST <
133103 T extends DevupPostApiStructKey < S > ,
134104 O extends Additional < T , DevupPostApiStructScope < S > > ,
135105 > (
136106 path : T ,
137- ...options : [ RequiredOptions < O > ] extends [ never ]
138- ? [
139- options ?: IsCold extends true
140- ? DevupApiRequestInit
141- : Omit < DevupApiRequestInit , 'params' > &
142- Omit < O , 'response' | 'error' > ,
143- ]
144- : [
145- options : Omit < DevupApiRequestInit , 'params' > &
146- Omit < O , 'response' | 'error' > ,
147- ]
107+ ...options : ApiOption < O >
148108 ) : Promise <
149109 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
150110 > {
151111 return this . request ( path , {
152112 method : 'POST' ,
153113 ...options [ 0 ] ,
154- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
114+ } as BoildApiOption < O > )
155115 }
156116
157117 put <
158118 T extends DevupPutApiStructKey < S > ,
159119 O extends Additional < T , DevupPutApiStructScope < S > > ,
160120 > (
161121 path : T ,
162- ...options : [ RequiredOptions < O > ] extends [ never ]
163- ? [
164- options ?: IsCold extends true
165- ? DevupApiRequestInit
166- : Omit < DevupApiRequestInit , 'params' > &
167- Omit < O , 'response' | 'error' > ,
168- ]
169- : [
170- options : Omit < DevupApiRequestInit , 'params' > &
171- Omit < O , 'response' | 'error' > ,
172- ]
122+ ...options : ApiOption < O >
173123 ) : Promise <
174124 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
175125 > {
176126 return this . request ( path , {
177127 method : 'PUT' ,
178128 ...options [ 0 ] ,
179- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
129+ } as BoildApiOption < O > )
180130 }
181131
182132 PUT <
183133 T extends DevupPutApiStructKey < S > ,
184134 O extends Additional < T , DevupPutApiStructScope < S > > ,
185135 > (
186136 path : T ,
187- ...options : [ RequiredOptions < O > ] extends [ never ]
188- ? [
189- options ?: IsCold extends true
190- ? DevupApiRequestInit
191- : Omit < DevupApiRequestInit , 'params' > &
192- Omit < O , 'response' | 'error' > ,
193- ]
194- : [
195- options : Omit < DevupApiRequestInit , 'params' > &
196- Omit < O , 'response' | 'error' > ,
197- ]
137+ ...options : ApiOption < O >
198138 ) : Promise <
199139 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
200140 > {
201141 return this . request ( path , {
202142 method : 'PUT' ,
203143 ...options [ 0 ] ,
204- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
144+ } as BoildApiOption < O > )
205145 }
206146
207147 delete <
208148 T extends DevupDeleteApiStructKey < S > ,
209149 O extends Additional < T , DevupDeleteApiStructScope < S > > ,
210150 > (
211151 path : T ,
212- ...options : [ RequiredOptions < O > ] extends [ never ]
213- ? [
214- options ?: IsCold extends true
215- ? DevupApiRequestInit
216- : Omit < DevupApiRequestInit , 'params' > &
217- Omit < O , 'response' | 'error' > ,
218- ]
219- : [
220- options : Omit < DevupApiRequestInit , 'params' > &
221- Omit < O , 'response' | 'error' > ,
222- ]
152+ ...options : ApiOption < O >
223153 ) : Promise <
224154 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
225155 > {
226156 return this . request ( path , {
227157 method : 'DELETE' ,
228158 ...options [ 0 ] ,
229- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
159+ } as BoildApiOption < O > )
230160 }
231161
232162 DELETE <
233163 T extends DevupDeleteApiStructKey < S > ,
234164 O extends Additional < T , DevupDeleteApiStructScope < S > > ,
235165 > (
236166 path : T ,
237- ...options : [ RequiredOptions < O > ] extends [ never ]
238- ? [
239- options ?: IsCold extends true
240- ? DevupApiRequestInit
241- : Omit < DevupApiRequestInit , 'params' > &
242- Omit < O , 'response' | 'error' > ,
243- ]
244- : [
245- options : Omit < DevupApiRequestInit , 'params' > &
246- Omit < O , 'response' | 'error' > ,
247- ]
167+ ...options : ApiOption < O >
248168 ) : Promise <
249169 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
250170 > {
251171 return this . request ( path , {
252172 method : 'DELETE' ,
253173 ...options [ 0 ] ,
254- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
174+ } as BoildApiOption < O > )
255175 }
256176
257177 patch <
258178 T extends DevupPatchApiStructKey < S > ,
259179 O extends Additional < T , DevupPatchApiStructScope < S > > ,
260180 > (
261181 path : T ,
262- ...options : [ RequiredOptions < O > ] extends [ never ]
263- ? [
264- options ?: IsCold extends true
265- ? DevupApiRequestInit
266- : Omit < DevupApiRequestInit , 'params' > &
267- Omit < O , 'response' | 'error' > ,
268- ]
269- : [
270- options : Omit < DevupApiRequestInit , 'params' > &
271- Omit < O , 'response' | 'error' > ,
272- ]
182+ ...options : ApiOption < O >
273183 ) : Promise <
274184 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
275185 > {
276186 return this . request ( path , {
277187 method : 'PATCH' ,
278188 ...options [ 0 ] ,
279- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
189+ } as BoildApiOption < O > )
280190 }
281191
282192 PATCH <
283193 T extends DevupPatchApiStructKey < S > ,
284194 O extends Additional < T , DevupPatchApiStructScope < S > > ,
285195 > (
286196 path : T ,
287- ...options : [ RequiredOptions < O > ] extends [ never ]
288- ? [
289- options ?: IsCold extends true
290- ? DevupApiRequestInit
291- : Omit < DevupApiRequestInit , 'params' > &
292- Omit < O , 'response' | 'error' > ,
293- ]
294- : [
295- options : Omit < DevupApiRequestInit , 'params' > &
296- Omit < O , 'response' | 'error' > ,
297- ]
197+ ...options : ApiOption < O >
298198 ) : Promise <
299199 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
300200 > {
301201 return this . request ( path , {
302202 method : 'PATCH' ,
303203 ...options [ 0 ] ,
304- } as DevupApiRequestInit & Omit < O , 'response' | 'error' > )
204+ } as BoildApiOption < O > )
305205 }
306206
307207 async request <
308208 T extends DevupApiStructKey < S > ,
309209 O extends Additional < T , DevupApiStructScope < S > > ,
310210 > (
311211 path : T ,
312- ...options : [ RequiredOptions < O > ] extends [ never ]
313- ? [
314- options ?: IsCold extends true
315- ? DevupApiRequestInit
316- : Omit < DevupApiRequestInit , 'params' > &
317- Omit < O , 'response' | 'error' > ,
318- ]
319- : [
320- options : Omit < DevupApiRequestInit , 'params' > &
321- Omit < O , 'response' | 'error' > ,
322- ]
212+ ...options : ApiOption < O >
323213 ) : Promise <
324214 DevupApiResponse < ExtractValue < O , 'response' > , ExtractValue < O , 'error' > >
325215 > {
0 commit comments