6
6
queryOptions ,
7
7
} from '@tanstack/angular-query-experimental' ;
8
8
9
+ import { transformQueryKey } from '../../runtimeConfig' ;
9
10
import { client as _heyApiClient } from '../client.gen' ;
10
11
import {
11
12
addPet ,
@@ -57,7 +58,7 @@ import type {
57
58
UploadFileResponse ,
58
59
} from '../types.gen' ;
59
60
60
- type QueryKey < TOptions extends Options > = [
61
+ export type QueryKey < TOptions extends Options > = [
61
62
Pick < TOptions , 'baseUrl' | 'body' | 'headers' | 'path' | 'query' > & {
62
63
_id : string ;
63
64
_infinite ?: boolean ;
@@ -68,7 +69,7 @@ const createQueryKey = <TOptions extends Options>(
68
69
id : string ,
69
70
options ?: TOptions ,
70
71
infinite ?: boolean ,
71
- ) : QueryKey < TOptions > [ 0 ] => {
72
+ ) : [ QueryKey < TOptions > [ 0 ] ] => {
72
73
const params : QueryKey < TOptions > [ 0 ] = {
73
74
_id : id ,
74
75
baseUrl : ( options ?. client ?? _heyApiClient ) . getConfig ( ) . baseUrl ,
@@ -88,16 +89,16 @@ const createQueryKey = <TOptions extends Options>(
88
89
if ( options ?. query ) {
89
90
params . query = options . query ;
90
91
}
91
- return params ;
92
+ return [ params ] ;
92
93
} ;
93
94
94
- export const addPetQueryKey = ( options : Options < AddPetData > ) => [
95
- createQueryKey ( 'addPet' , options ) ,
96
- ] ;
95
+ export const addPetQueryKey = ( options : Options < AddPetData > ) =>
96
+ createQueryKey ( 'addPet' , options ) ;
97
97
98
98
export const addPetOptions = ( options : Options < AddPetData > ) =>
99
99
queryOptions ( {
100
- queryFn : async ( { queryKey, signal } ) => {
100
+ queryFn : async ( { signal } ) => {
101
+ const queryKey = addPetQueryKey ( options ) ;
101
102
const { data } = await addPet ( {
102
103
...options ,
103
104
...queryKey [ 0 ] ,
@@ -106,7 +107,7 @@ export const addPetOptions = (options: Options<AddPetData>) =>
106
107
} ) ;
107
108
return data ;
108
109
} ,
109
- queryKey : addPetQueryKey ( options ) ,
110
+ queryKey : transformQueryKey ( addPetQueryKey ( options ) ) ,
110
111
} ) ;
111
112
112
113
export const addPetMutation = ( options ?: Partial < Options < AddPetData > > ) => {
@@ -149,13 +150,14 @@ export const updatePetMutation = (
149
150
150
151
export const findPetsByStatusQueryKey = (
151
152
options ?: Options < FindPetsByStatusData > ,
152
- ) => [ createQueryKey ( 'findPetsByStatus' , options ) ] ;
153
+ ) => createQueryKey ( 'findPetsByStatus' , options ) ;
153
154
154
155
export const findPetsByStatusOptions = (
155
156
options ?: Options < FindPetsByStatusData > ,
156
157
) =>
157
158
queryOptions ( {
158
- queryFn : async ( { queryKey, signal } ) => {
159
+ queryFn : async ( { signal } ) => {
160
+ const queryKey = findPetsByStatusQueryKey ( options ) ;
159
161
const { data } = await findPetsByStatus ( {
160
162
...options ,
161
163
...queryKey [ 0 ] ,
@@ -164,16 +166,16 @@ export const findPetsByStatusOptions = (
164
166
} ) ;
165
167
return data ;
166
168
} ,
167
- queryKey : findPetsByStatusQueryKey ( options ) ,
169
+ queryKey : transformQueryKey ( findPetsByStatusQueryKey ( options ) ) ,
168
170
} ) ;
169
171
170
- export const findPetsByTagsQueryKey = (
171
- options ?: Options < FindPetsByTagsData > ,
172
- ) => [ createQueryKey ( 'findPetsByTags' , options ) ] ;
172
+ export const findPetsByTagsQueryKey = ( options ?: Options < FindPetsByTagsData > ) =>
173
+ createQueryKey ( 'findPetsByTags' , options ) ;
173
174
174
175
export const findPetsByTagsOptions = ( options ?: Options < FindPetsByTagsData > ) =>
175
176
queryOptions ( {
176
- queryFn : async ( { queryKey, signal } ) => {
177
+ queryFn : async ( { signal } ) => {
178
+ const queryKey = findPetsByTagsQueryKey ( options ) ;
177
179
const { data } = await findPetsByTags ( {
178
180
...options ,
179
181
...queryKey [ 0 ] ,
@@ -182,7 +184,7 @@ export const findPetsByTagsOptions = (options?: Options<FindPetsByTagsData>) =>
182
184
} ) ;
183
185
return data ;
184
186
} ,
185
- queryKey : findPetsByTagsQueryKey ( options ) ,
187
+ queryKey : transformQueryKey ( findPetsByTagsQueryKey ( options ) ) ,
186
188
} ) ;
187
189
188
190
export const deletePetMutation = (
@@ -205,13 +207,13 @@ export const deletePetMutation = (
205
207
return mutationOptions ;
206
208
} ;
207
209
208
- export const getPetByIdQueryKey = ( options : Options < GetPetByIdData > ) => [
209
- createQueryKey ( 'getPetById' , options ) ,
210
- ] ;
210
+ export const getPetByIdQueryKey = ( options : Options < GetPetByIdData > ) =>
211
+ createQueryKey ( 'getPetById' , options ) ;
211
212
212
213
export const getPetByIdOptions = ( options : Options < GetPetByIdData > ) =>
213
214
queryOptions ( {
214
- queryFn : async ( { queryKey, signal } ) => {
215
+ queryFn : async ( { signal } ) => {
216
+ const queryKey = getPetByIdQueryKey ( options ) ;
215
217
const { data } = await getPetById ( {
216
218
...options ,
217
219
...queryKey [ 0 ] ,
@@ -220,18 +222,19 @@ export const getPetByIdOptions = (options: Options<GetPetByIdData>) =>
220
222
} ) ;
221
223
return data ;
222
224
} ,
223
- queryKey : getPetByIdQueryKey ( options ) ,
225
+ queryKey : transformQueryKey ( getPetByIdQueryKey ( options ) ) ,
224
226
} ) ;
225
227
226
228
export const updatePetWithFormQueryKey = (
227
229
options : Options < UpdatePetWithFormData > ,
228
- ) => [ createQueryKey ( 'updatePetWithForm' , options ) ] ;
230
+ ) => createQueryKey ( 'updatePetWithForm' , options ) ;
229
231
230
232
export const updatePetWithFormOptions = (
231
233
options : Options < UpdatePetWithFormData > ,
232
234
) =>
233
235
queryOptions ( {
234
- queryFn : async ( { queryKey, signal } ) => {
236
+ queryFn : async ( { signal } ) => {
237
+ const queryKey = updatePetWithFormQueryKey ( options ) ;
235
238
const { data } = await updatePetWithForm ( {
236
239
...options ,
237
240
...queryKey [ 0 ] ,
@@ -240,7 +243,7 @@ export const updatePetWithFormOptions = (
240
243
} ) ;
241
244
return data ;
242
245
} ,
243
- queryKey : updatePetWithFormQueryKey ( options ) ,
246
+ queryKey : transformQueryKey ( updatePetWithFormQueryKey ( options ) ) ,
244
247
} ) ;
245
248
246
249
export const updatePetWithFormMutation = (
@@ -263,13 +266,13 @@ export const updatePetWithFormMutation = (
263
266
return mutationOptions ;
264
267
} ;
265
268
266
- export const uploadFileQueryKey = ( options : Options < UploadFileData > ) => [
267
- createQueryKey ( 'uploadFile' , options ) ,
268
- ] ;
269
+ export const uploadFileQueryKey = ( options : Options < UploadFileData > ) =>
270
+ createQueryKey ( 'uploadFile' , options ) ;
269
271
270
272
export const uploadFileOptions = ( options : Options < UploadFileData > ) =>
271
273
queryOptions ( {
272
- queryFn : async ( { queryKey, signal } ) => {
274
+ queryFn : async ( { signal } ) => {
275
+ const queryKey = uploadFileQueryKey ( options ) ;
273
276
const { data } = await uploadFile ( {
274
277
...options ,
275
278
...queryKey [ 0 ] ,
@@ -278,7 +281,7 @@ export const uploadFileOptions = (options: Options<UploadFileData>) =>
278
281
} ) ;
279
282
return data ;
280
283
} ,
281
- queryKey : uploadFileQueryKey ( options ) ,
284
+ queryKey : transformQueryKey ( uploadFileQueryKey ( options ) ) ,
282
285
} ) ;
283
286
284
287
export const uploadFileMutation = (
@@ -301,13 +304,13 @@ export const uploadFileMutation = (
301
304
return mutationOptions ;
302
305
} ;
303
306
304
- export const getInventoryQueryKey = ( options ?: Options < GetInventoryData > ) => [
305
- createQueryKey ( 'getInventory' , options ) ,
306
- ] ;
307
+ export const getInventoryQueryKey = ( options ?: Options < GetInventoryData > ) =>
308
+ createQueryKey ( 'getInventory' , options ) ;
307
309
308
310
export const getInventoryOptions = ( options ?: Options < GetInventoryData > ) =>
309
311
queryOptions ( {
310
- queryFn : async ( { queryKey, signal } ) => {
312
+ queryFn : async ( { signal } ) => {
313
+ const queryKey = getInventoryQueryKey ( options ) ;
311
314
const { data } = await getInventory ( {
312
315
...options ,
313
316
...queryKey [ 0 ] ,
@@ -316,16 +319,16 @@ export const getInventoryOptions = (options?: Options<GetInventoryData>) =>
316
319
} ) ;
317
320
return data ;
318
321
} ,
319
- queryKey : getInventoryQueryKey ( options ) ,
322
+ queryKey : transformQueryKey ( getInventoryQueryKey ( options ) ) ,
320
323
} ) ;
321
324
322
- export const placeOrderQueryKey = ( options ?: Options < PlaceOrderData > ) => [
323
- createQueryKey ( 'placeOrder' , options ) ,
324
- ] ;
325
+ export const placeOrderQueryKey = ( options ?: Options < PlaceOrderData > ) =>
326
+ createQueryKey ( 'placeOrder' , options ) ;
325
327
326
328
export const placeOrderOptions = ( options ?: Options < PlaceOrderData > ) =>
327
329
queryOptions ( {
328
- queryFn : async ( { queryKey, signal } ) => {
330
+ queryFn : async ( { signal } ) => {
331
+ const queryKey = placeOrderQueryKey ( options ) ;
329
332
const { data } = await placeOrder ( {
330
333
...options ,
331
334
...queryKey [ 0 ] ,
@@ -334,7 +337,7 @@ export const placeOrderOptions = (options?: Options<PlaceOrderData>) =>
334
337
} ) ;
335
338
return data ;
336
339
} ,
337
- queryKey : placeOrderQueryKey ( options ) ,
340
+ queryKey : transformQueryKey ( placeOrderQueryKey ( options ) ) ,
338
341
} ) ;
339
342
340
343
export const placeOrderMutation = (
@@ -377,13 +380,13 @@ export const deleteOrderMutation = (
377
380
return mutationOptions ;
378
381
} ;
379
382
380
- export const getOrderByIdQueryKey = ( options : Options < GetOrderByIdData > ) => [
381
- createQueryKey ( 'getOrderById' , options ) ,
382
- ] ;
383
+ export const getOrderByIdQueryKey = ( options : Options < GetOrderByIdData > ) =>
384
+ createQueryKey ( 'getOrderById' , options ) ;
383
385
384
386
export const getOrderByIdOptions = ( options : Options < GetOrderByIdData > ) =>
385
387
queryOptions ( {
386
- queryFn : async ( { queryKey, signal } ) => {
388
+ queryFn : async ( { signal } ) => {
389
+ const queryKey = getOrderByIdQueryKey ( options ) ;
387
390
const { data } = await getOrderById ( {
388
391
...options ,
389
392
...queryKey [ 0 ] ,
@@ -392,16 +395,16 @@ export const getOrderByIdOptions = (options: Options<GetOrderByIdData>) =>
392
395
} ) ;
393
396
return data ;
394
397
} ,
395
- queryKey : getOrderByIdQueryKey ( options ) ,
398
+ queryKey : transformQueryKey ( getOrderByIdQueryKey ( options ) ) ,
396
399
} ) ;
397
400
398
- export const createUserQueryKey = ( options ?: Options < CreateUserData > ) => [
399
- createQueryKey ( 'createUser' , options ) ,
400
- ] ;
401
+ export const createUserQueryKey = ( options ?: Options < CreateUserData > ) =>
402
+ createQueryKey ( 'createUser' , options ) ;
401
403
402
404
export const createUserOptions = ( options ?: Options < CreateUserData > ) =>
403
405
queryOptions ( {
404
- queryFn : async ( { queryKey, signal } ) => {
406
+ queryFn : async ( { signal } ) => {
407
+ const queryKey = createUserQueryKey ( options ) ;
405
408
const { data } = await createUser ( {
406
409
...options ,
407
410
...queryKey [ 0 ] ,
@@ -410,7 +413,7 @@ export const createUserOptions = (options?: Options<CreateUserData>) =>
410
413
} ) ;
411
414
return data ;
412
415
} ,
413
- queryKey : createUserQueryKey ( options ) ,
416
+ queryKey : transformQueryKey ( createUserQueryKey ( options ) ) ,
414
417
} ) ;
415
418
416
419
export const createUserMutation = (
@@ -435,13 +438,14 @@ export const createUserMutation = (
435
438
436
439
export const createUsersWithListInputQueryKey = (
437
440
options ?: Options < CreateUsersWithListInputData > ,
438
- ) => [ createQueryKey ( 'createUsersWithListInput' , options ) ] ;
441
+ ) => createQueryKey ( 'createUsersWithListInput' , options ) ;
439
442
440
443
export const createUsersWithListInputOptions = (
441
444
options ?: Options < CreateUsersWithListInputData > ,
442
445
) =>
443
446
queryOptions ( {
444
- queryFn : async ( { queryKey, signal } ) => {
447
+ queryFn : async ( { signal } ) => {
448
+ const queryKey = createUsersWithListInputQueryKey ( options ) ;
445
449
const { data } = await createUsersWithListInput ( {
446
450
...options ,
447
451
...queryKey [ 0 ] ,
@@ -450,7 +454,7 @@ export const createUsersWithListInputOptions = (
450
454
} ) ;
451
455
return data ;
452
456
} ,
453
- queryKey : createUsersWithListInputQueryKey ( options ) ,
457
+ queryKey : transformQueryKey ( createUsersWithListInputQueryKey ( options ) ) ,
454
458
} ) ;
455
459
456
460
export const createUsersWithListInputMutation = (
@@ -473,13 +477,13 @@ export const createUsersWithListInputMutation = (
473
477
return mutationOptions ;
474
478
} ;
475
479
476
- export const loginUserQueryKey = ( options ?: Options < LoginUserData > ) => [
477
- createQueryKey ( 'loginUser' , options ) ,
478
- ] ;
480
+ export const loginUserQueryKey = ( options ?: Options < LoginUserData > ) =>
481
+ createQueryKey ( 'loginUser' , options ) ;
479
482
480
483
export const loginUserOptions = ( options ?: Options < LoginUserData > ) =>
481
484
queryOptions ( {
482
- queryFn : async ( { queryKey, signal } ) => {
485
+ queryFn : async ( { signal } ) => {
486
+ const queryKey = loginUserQueryKey ( options ) ;
483
487
const { data } = await loginUser ( {
484
488
...options ,
485
489
...queryKey [ 0 ] ,
@@ -488,16 +492,16 @@ export const loginUserOptions = (options?: Options<LoginUserData>) =>
488
492
} ) ;
489
493
return data ;
490
494
} ,
491
- queryKey : loginUserQueryKey ( options ) ,
495
+ queryKey : transformQueryKey ( loginUserQueryKey ( options ) ) ,
492
496
} ) ;
493
497
494
- export const logoutUserQueryKey = ( options ?: Options < LogoutUserData > ) => [
495
- createQueryKey ( 'logoutUser' , options ) ,
496
- ] ;
498
+ export const logoutUserQueryKey = ( options ?: Options < LogoutUserData > ) =>
499
+ createQueryKey ( 'logoutUser' , options ) ;
497
500
498
501
export const logoutUserOptions = ( options ?: Options < LogoutUserData > ) =>
499
502
queryOptions ( {
500
- queryFn : async ( { queryKey, signal } ) => {
503
+ queryFn : async ( { signal } ) => {
504
+ const queryKey = logoutUserQueryKey ( options ) ;
501
505
const { data } = await logoutUser ( {
502
506
...options ,
503
507
...queryKey [ 0 ] ,
@@ -506,7 +510,7 @@ export const logoutUserOptions = (options?: Options<LogoutUserData>) =>
506
510
} ) ;
507
511
return data ;
508
512
} ,
509
- queryKey : logoutUserQueryKey ( options ) ,
513
+ queryKey : transformQueryKey ( logoutUserQueryKey ( options ) ) ,
510
514
} ) ;
511
515
512
516
export const deleteUserMutation = (
@@ -529,13 +533,13 @@ export const deleteUserMutation = (
529
533
return mutationOptions ;
530
534
} ;
531
535
532
- export const getUserByNameQueryKey = ( options : Options < GetUserByNameData > ) => [
533
- createQueryKey ( 'getUserByName' , options ) ,
534
- ] ;
536
+ export const getUserByNameQueryKey = ( options : Options < GetUserByNameData > ) =>
537
+ createQueryKey ( 'getUserByName' , options ) ;
535
538
536
539
export const getUserByNameOptions = ( options : Options < GetUserByNameData > ) =>
537
540
queryOptions ( {
538
- queryFn : async ( { queryKey, signal } ) => {
541
+ queryFn : async ( { signal } ) => {
542
+ const queryKey = getUserByNameQueryKey ( options ) ;
539
543
const { data } = await getUserByName ( {
540
544
...options ,
541
545
...queryKey [ 0 ] ,
@@ -544,7 +548,7 @@ export const getUserByNameOptions = (options: Options<GetUserByNameData>) =>
544
548
} ) ;
545
549
return data ;
546
550
} ,
547
- queryKey : getUserByNameQueryKey ( options ) ,
551
+ queryKey : transformQueryKey ( getUserByNameQueryKey ( options ) ) ,
548
552
} ) ;
549
553
550
554
export const updateUserMutation = (
0 commit comments