@squonk/account-server-client 2.0.4-rc.1 → 2.0.4-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/admin/admin.cjs +10 -14
  2. package/admin/admin.cjs.map +1 -1
  3. package/admin/admin.d.ts +9 -3
  4. package/admin/admin.js +9 -13
  5. package/admin/admin.js.map +1 -1
  6. package/asset/asset.cjs +59 -28
  7. package/asset/asset.cjs.map +1 -1
  8. package/asset/asset.d.ts +71 -3
  9. package/asset/asset.js +58 -27
  10. package/asset/asset.js.map +1 -1
  11. package/{custom-instance-85497958.d.ts → custom-instance-8a11f2d1.d.ts} +1 -1
  12. package/index.cjs.map +1 -1
  13. package/index.d.ts +1 -1
  14. package/index.js.map +1 -1
  15. package/merchant/merchant.cjs +19 -16
  16. package/merchant/merchant.cjs.map +1 -1
  17. package/merchant/merchant.d.ts +16 -4
  18. package/merchant/merchant.js +18 -15
  19. package/merchant/merchant.js.map +1 -1
  20. package/organisation/organisation.cjs +64 -40
  21. package/organisation/organisation.cjs.map +1 -1
  22. package/organisation/organisation.d.ts +56 -6
  23. package/organisation/organisation.js +63 -39
  24. package/organisation/organisation.js.map +1 -1
  25. package/package.json +10 -9
  26. package/product/product.cjs +92 -55
  27. package/product/product.cjs.map +1 -1
  28. package/product/product.d.ts +79 -9
  29. package/product/product.js +91 -54
  30. package/product/product.js.map +1 -1
  31. package/src/account-server-api.schemas.ts +1 -1
  32. package/src/admin/admin.ts +34 -18
  33. package/src/asset/asset.ts +223 -88
  34. package/src/merchant/merchant.ts +60 -27
  35. package/src/organisation/organisation.ts +215 -97
  36. package/src/product/product.ts +310 -134
  37. package/src/state/state.ts +30 -15
  38. package/src/unit/unit.ts +263 -117
  39. package/src/user/user.ts +207 -88
  40. package/state/state.cjs +10 -11
  41. package/state/state.cjs.map +1 -1
  42. package/state/state.d.ts +9 -3
  43. package/state/state.js +9 -10
  44. package/state/state.js.map +1 -1
  45. package/unit/unit.cjs +74 -46
  46. package/unit/unit.cjs.map +1 -1
  47. package/unit/unit.d.ts +70 -6
  48. package/unit/unit.js +73 -45
  49. package/unit/unit.js.map +1 -1
  50. package/user/user.cjs +56 -31
  51. package/user/user.cjs.map +1 -1
  52. package/user/user.d.ts +63 -5
  53. package/user/user.js +55 -30
  54. package/user/user.js.map +1 -1
  55. package/chunk-7XN3IQYV.cjs +0 -13
  56. package/chunk-7XN3IQYV.cjs.map +0 -1
  57. package/chunk-YEX2SGER.js +0 -13
  58. package/chunk-YEX2SGER.js.map +0 -1
  59. package/src/queryMutator.ts +0 -12
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.12.1 🍺
2
+ * Generated by orval v6.15.0 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -31,7 +31,6 @@ import type {
31
31
  } from "../account-server-api.schemas";
32
32
  import { customInstance } from ".././custom-instance";
33
33
  import type { ErrorType } from ".././custom-instance";
34
- import { queryMutator } from ".././queryMutator";
35
34
 
36
35
  // eslint-disable-next-line
37
36
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -56,14 +55,9 @@ export const getProductTypes = (
56
55
  );
57
56
  };
58
57
 
59
- export const getGetProductTypesQueryKey = () => [`/product-type`];
58
+ export const getGetProductTypesQueryKey = () => ["account-server-api", `/product-type`] as const;
60
59
 
61
- export type GetProductTypesQueryResult = NonNullable<
62
- Awaited<ReturnType<typeof getProductTypes>>
63
- >;
64
- export type GetProductTypesQueryError = ErrorType<AsError | void>;
65
-
66
- export const useGetProductTypes = <
60
+ export const getGetProductTypesQueryOptions = <
67
61
  TData = Awaited<ReturnType<typeof getProductTypes>>,
68
62
  TError = ErrorType<AsError | void>
69
63
  >(options?: {
@@ -73,7 +67,11 @@ export const useGetProductTypes = <
73
67
  TData
74
68
  >;
75
69
  request?: SecondParameter<typeof customInstance>;
76
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
70
+ }): UseQueryOptions<
71
+ Awaited<ReturnType<typeof getProductTypes>>,
72
+ TError,
73
+ TData
74
+ > & { queryKey: QueryKey } => {
77
75
  const { query: queryOptions, request: requestOptions } = options ?? {};
78
76
 
79
77
  const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
@@ -82,15 +80,32 @@ export const useGetProductTypes = <
82
80
  signal,
83
81
  }) => getProductTypes(requestOptions, signal);
84
82
 
85
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
83
+ return { queryKey, queryFn, ...queryOptions };
84
+ };
86
85
 
87
- const query = useQuery<
86
+ export type GetProductTypesQueryResult = NonNullable<
87
+ Awaited<ReturnType<typeof getProductTypes>>
88
+ >;
89
+ export type GetProductTypesQueryError = ErrorType<AsError | void>;
90
+
91
+ export const useGetProductTypes = <
92
+ TData = Awaited<ReturnType<typeof getProductTypes>>,
93
+ TError = ErrorType<AsError | void>
94
+ >(options?: {
95
+ query?: UseQueryOptions<
88
96
  Awaited<ReturnType<typeof getProductTypes>>,
89
97
  TError,
90
98
  TData
91
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
99
+ >;
100
+ request?: SecondParameter<typeof customInstance>;
101
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
102
+ const queryOptions = getGetProductTypesQueryOptions(options);
92
103
 
93
- query.queryKey = customOptions.queryKey;
104
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
105
+ queryKey: QueryKey;
106
+ };
107
+
108
+ query.queryKey = queryOptions.queryKey;
94
109
 
95
110
  return query;
96
111
  };
@@ -108,16 +123,10 @@ export const getProductDefaultStorageCost = (
108
123
  );
109
124
  };
110
125
 
111
- export const getGetProductDefaultStorageCostQueryKey = () => [
112
- `/product-default-storage-cost`,
113
- ];
126
+ export const getGetProductDefaultStorageCostQueryKey = () =>
127
+ ["account-server-api", `/product-default-storage-cost`] as const;
114
128
 
115
- export type GetProductDefaultStorageCostQueryResult = NonNullable<
116
- Awaited<ReturnType<typeof getProductDefaultStorageCost>>
117
- >;
118
- export type GetProductDefaultStorageCostQueryError = ErrorType<AsError | void>;
119
-
120
- export const useGetProductDefaultStorageCost = <
129
+ export const getGetProductDefaultStorageCostQueryOptions = <
121
130
  TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
122
131
  TError = ErrorType<AsError | void>
123
132
  >(options?: {
@@ -127,7 +136,11 @@ export const useGetProductDefaultStorageCost = <
127
136
  TData
128
137
  >;
129
138
  request?: SecondParameter<typeof customInstance>;
130
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
139
+ }): UseQueryOptions<
140
+ Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
141
+ TError,
142
+ TData
143
+ > & { queryKey: QueryKey } => {
131
144
  const { query: queryOptions, request: requestOptions } = options ?? {};
132
145
 
133
146
  const queryKey =
@@ -137,15 +150,32 @@ export const useGetProductDefaultStorageCost = <
137
150
  Awaited<ReturnType<typeof getProductDefaultStorageCost>>
138
151
  > = ({ signal }) => getProductDefaultStorageCost(requestOptions, signal);
139
152
 
140
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
153
+ return { queryKey, queryFn, ...queryOptions };
154
+ };
155
+
156
+ export type GetProductDefaultStorageCostQueryResult = NonNullable<
157
+ Awaited<ReturnType<typeof getProductDefaultStorageCost>>
158
+ >;
159
+ export type GetProductDefaultStorageCostQueryError = ErrorType<AsError | void>;
141
160
 
142
- const query = useQuery<
161
+ export const useGetProductDefaultStorageCost = <
162
+ TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
163
+ TError = ErrorType<AsError | void>
164
+ >(options?: {
165
+ query?: UseQueryOptions<
143
166
  Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
144
167
  TError,
145
168
  TData
146
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
169
+ >;
170
+ request?: SecondParameter<typeof customInstance>;
171
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
172
+ const queryOptions = getGetProductDefaultStorageCostQueryOptions(options);
173
+
174
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
175
+ queryKey: QueryKey;
176
+ };
147
177
 
148
- query.queryKey = customOptions.queryKey;
178
+ query.queryKey = queryOptions.queryKey;
149
179
 
150
180
  return query;
151
181
  };
@@ -165,14 +195,9 @@ export const getProducts = (
165
195
  );
166
196
  };
167
197
 
168
- export const getGetProductsQueryKey = () => [`/product`];
169
-
170
- export type GetProductsQueryResult = NonNullable<
171
- Awaited<ReturnType<typeof getProducts>>
172
- >;
173
- export type GetProductsQueryError = ErrorType<AsError | void>;
198
+ export const getGetProductsQueryKey = () => ["account-server-api", `/product`] as const;
174
199
 
175
- export const useGetProducts = <
200
+ export const getGetProductsQueryOptions = <
176
201
  TData = Awaited<ReturnType<typeof getProducts>>,
177
202
  TError = ErrorType<AsError | void>
178
203
  >(options?: {
@@ -182,7 +207,9 @@ export const useGetProducts = <
182
207
  TData
183
208
  >;
184
209
  request?: SecondParameter<typeof customInstance>;
185
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
210
+ }): UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData> & {
211
+ queryKey: QueryKey;
212
+ } => {
186
213
  const { query: queryOptions, request: requestOptions } = options ?? {};
187
214
 
188
215
  const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
@@ -191,15 +218,32 @@ export const useGetProducts = <
191
218
  signal,
192
219
  }) => getProducts(requestOptions, signal);
193
220
 
194
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
221
+ return { queryKey, queryFn, ...queryOptions };
222
+ };
195
223
 
196
- const query = useQuery<
224
+ export type GetProductsQueryResult = NonNullable<
225
+ Awaited<ReturnType<typeof getProducts>>
226
+ >;
227
+ export type GetProductsQueryError = ErrorType<AsError | void>;
228
+
229
+ export const useGetProducts = <
230
+ TData = Awaited<ReturnType<typeof getProducts>>,
231
+ TError = ErrorType<AsError | void>
232
+ >(options?: {
233
+ query?: UseQueryOptions<
197
234
  Awaited<ReturnType<typeof getProducts>>,
198
235
  TError,
199
236
  TData
200
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
237
+ >;
238
+ request?: SecondParameter<typeof customInstance>;
239
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
240
+ const queryOptions = getGetProductsQueryOptions(options);
241
+
242
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
243
+ queryKey: QueryKey;
244
+ };
201
245
 
202
- query.queryKey = customOptions.queryKey;
246
+ query.queryKey = queryOptions.queryKey;
203
247
 
204
248
  return query;
205
249
  };
@@ -220,16 +264,10 @@ export const getProductsForOrganisation = (
220
264
  );
221
265
  };
222
266
 
223
- export const getGetProductsForOrganisationQueryKey = (orgId: string) => [
224
- `/product/organisation/${orgId}`,
225
- ];
267
+ export const getGetProductsForOrganisationQueryKey = (orgId: string) =>
268
+ ["account-server-api", `/product/organisation/${orgId}`] as const;
226
269
 
227
- export type GetProductsForOrganisationQueryResult = NonNullable<
228
- Awaited<ReturnType<typeof getProductsForOrganisation>>
229
- >;
230
- export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>;
231
-
232
- export const useGetProductsForOrganisation = <
270
+ export const getGetProductsForOrganisationQueryOptions = <
233
271
  TData = Awaited<ReturnType<typeof getProductsForOrganisation>>,
234
272
  TError = ErrorType<void | AsError>
235
273
  >(
@@ -242,7 +280,11 @@ export const useGetProductsForOrganisation = <
242
280
  >;
243
281
  request?: SecondParameter<typeof customInstance>;
244
282
  }
245
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
283
+ ): UseQueryOptions<
284
+ Awaited<ReturnType<typeof getProductsForOrganisation>>,
285
+ TError,
286
+ TData
287
+ > & { queryKey: QueryKey } => {
246
288
  const { query: queryOptions, request: requestOptions } = options ?? {};
247
289
 
248
290
  const queryKey =
@@ -252,15 +294,38 @@ export const useGetProductsForOrganisation = <
252
294
  Awaited<ReturnType<typeof getProductsForOrganisation>>
253
295
  > = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
254
296
 
255
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
297
+ return { queryKey, queryFn, enabled: !!orgId, ...queryOptions };
298
+ };
256
299
 
257
- const query = useQuery<
258
- Awaited<ReturnType<typeof getProductsForOrganisation>>,
259
- TError,
260
- TData
261
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
300
+ export type GetProductsForOrganisationQueryResult = NonNullable<
301
+ Awaited<ReturnType<typeof getProductsForOrganisation>>
302
+ >;
303
+ export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>;
304
+
305
+ export const useGetProductsForOrganisation = <
306
+ TData = Awaited<ReturnType<typeof getProductsForOrganisation>>,
307
+ TError = ErrorType<void | AsError>
308
+ >(
309
+ orgId: string,
310
+ options?: {
311
+ query?: UseQueryOptions<
312
+ Awaited<ReturnType<typeof getProductsForOrganisation>>,
313
+ TError,
314
+ TData
315
+ >;
316
+ request?: SecondParameter<typeof customInstance>;
317
+ }
318
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
319
+ const queryOptions = getGetProductsForOrganisationQueryOptions(
320
+ orgId,
321
+ options
322
+ );
323
+
324
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
325
+ queryKey: QueryKey;
326
+ };
262
327
 
263
- query.queryKey = customOptions.queryKey;
328
+ query.queryKey = queryOptions.queryKey;
264
329
 
265
330
  return query;
266
331
  };
@@ -290,13 +355,7 @@ export const createUnitProduct = (
290
355
  );
291
356
  };
292
357
 
293
- export type CreateUnitProductMutationResult = NonNullable<
294
- Awaited<ReturnType<typeof createUnitProduct>>
295
- >;
296
- export type CreateUnitProductMutationBody = UnitProductPostBodyBody;
297
- export type CreateUnitProductMutationError = ErrorType<AsError | void>;
298
-
299
- export const useCreateUnitProduct = <
358
+ export const getCreateUnitProductMutationOptions = <
300
359
  TError = ErrorType<AsError | void>,
301
360
  TContext = unknown
302
361
  >(options?: {
@@ -307,7 +366,12 @@ export const useCreateUnitProduct = <
307
366
  TContext
308
367
  >;
309
368
  request?: SecondParameter<typeof customInstance>;
310
- }) => {
369
+ }): UseMutationOptions<
370
+ Awaited<ReturnType<typeof createUnitProduct>>,
371
+ TError,
372
+ { unitId: string; data: UnitProductPostBodyBody },
373
+ TContext
374
+ > => {
311
375
  const { mutation: mutationOptions, request: requestOptions } = options ?? {};
312
376
 
313
377
  const mutationFn: MutationFunction<
@@ -319,12 +383,30 @@ export const useCreateUnitProduct = <
319
383
  return createUnitProduct(unitId, data, requestOptions);
320
384
  };
321
385
 
322
- return useMutation<
386
+ return { mutationFn, ...mutationOptions };
387
+ };
388
+
389
+ export type CreateUnitProductMutationResult = NonNullable<
390
+ Awaited<ReturnType<typeof createUnitProduct>>
391
+ >;
392
+ export type CreateUnitProductMutationBody = UnitProductPostBodyBody;
393
+ export type CreateUnitProductMutationError = ErrorType<AsError | void>;
394
+
395
+ export const useCreateUnitProduct = <
396
+ TError = ErrorType<AsError | void>,
397
+ TContext = unknown
398
+ >(options?: {
399
+ mutation?: UseMutationOptions<
323
400
  Awaited<ReturnType<typeof createUnitProduct>>,
324
401
  TError,
325
402
  { unitId: string; data: UnitProductPostBodyBody },
326
403
  TContext
327
- >(mutationFn, mutationOptions);
404
+ >;
405
+ request?: SecondParameter<typeof customInstance>;
406
+ }) => {
407
+ const mutationOptions = getCreateUnitProductMutationOptions(options);
408
+
409
+ return useMutation(mutationOptions);
328
410
  };
329
411
  /**
330
412
  * Gets products you have access to based on an Organisational Unit
@@ -342,16 +424,10 @@ export const getProductsForUnit = (
342
424
  );
343
425
  };
344
426
 
345
- export const getGetProductsForUnitQueryKey = (unitId: string) => [
346
- `/product/unit/${unitId}`,
347
- ];
427
+ export const getGetProductsForUnitQueryKey = (unitId: string) =>
428
+ ["account-server-api", `/product/unit/${unitId}`] as const;
348
429
 
349
- export type GetProductsForUnitQueryResult = NonNullable<
350
- Awaited<ReturnType<typeof getProductsForUnit>>
351
- >;
352
- export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
353
-
354
- export const useGetProductsForUnit = <
430
+ export const getGetProductsForUnitQueryOptions = <
355
431
  TData = Awaited<ReturnType<typeof getProductsForUnit>>,
356
432
  TError = ErrorType<void | AsError>
357
433
  >(
@@ -364,7 +440,11 @@ export const useGetProductsForUnit = <
364
440
  >;
365
441
  request?: SecondParameter<typeof customInstance>;
366
442
  }
367
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
443
+ ): UseQueryOptions<
444
+ Awaited<ReturnType<typeof getProductsForUnit>>,
445
+ TError,
446
+ TData
447
+ > & { queryKey: QueryKey } => {
368
448
  const { query: queryOptions, request: requestOptions } = options ?? {};
369
449
 
370
450
  const queryKey =
@@ -374,15 +454,35 @@ export const useGetProductsForUnit = <
374
454
  Awaited<ReturnType<typeof getProductsForUnit>>
375
455
  > = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
376
456
 
377
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
457
+ return { queryKey, queryFn, enabled: !!unitId, ...queryOptions };
458
+ };
378
459
 
379
- const query = useQuery<
380
- Awaited<ReturnType<typeof getProductsForUnit>>,
381
- TError,
382
- TData
383
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
460
+ export type GetProductsForUnitQueryResult = NonNullable<
461
+ Awaited<ReturnType<typeof getProductsForUnit>>
462
+ >;
463
+ export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
464
+
465
+ export const useGetProductsForUnit = <
466
+ TData = Awaited<ReturnType<typeof getProductsForUnit>>,
467
+ TError = ErrorType<void | AsError>
468
+ >(
469
+ unitId: string,
470
+ options?: {
471
+ query?: UseQueryOptions<
472
+ Awaited<ReturnType<typeof getProductsForUnit>>,
473
+ TError,
474
+ TData
475
+ >;
476
+ request?: SecondParameter<typeof customInstance>;
477
+ }
478
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
479
+ const queryOptions = getGetProductsForUnitQueryOptions(unitId, options);
480
+
481
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
482
+ queryKey: QueryKey;
483
+ };
384
484
 
385
- query.queryKey = customOptions.queryKey;
485
+ query.queryKey = queryOptions.queryKey;
386
486
 
387
487
  return query;
388
488
  };
@@ -403,16 +503,10 @@ export const getProduct = (
403
503
  );
404
504
  };
405
505
 
406
- export const getGetProductQueryKey = (productId: string) => [
407
- `/product/${productId}`,
408
- ];
506
+ export const getGetProductQueryKey = (productId: string) =>
507
+ ["account-server-api", `/product/${productId}`] as const;
409
508
 
410
- export type GetProductQueryResult = NonNullable<
411
- Awaited<ReturnType<typeof getProduct>>
412
- >;
413
- export type GetProductQueryError = ErrorType<AsError | void>;
414
-
415
- export const useGetProduct = <
509
+ export const getGetProductQueryOptions = <
416
510
  TData = Awaited<ReturnType<typeof getProduct>>,
417
511
  TError = ErrorType<AsError | void>
418
512
  >(
@@ -425,7 +519,9 @@ export const useGetProduct = <
425
519
  >;
426
520
  request?: SecondParameter<typeof customInstance>;
427
521
  }
428
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
522
+ ): UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData> & {
523
+ queryKey: QueryKey;
524
+ } => {
429
525
  const { query: queryOptions, request: requestOptions } = options ?? {};
430
526
 
431
527
  const queryKey = queryOptions?.queryKey ?? getGetProductQueryKey(productId);
@@ -434,13 +530,35 @@ export const useGetProduct = <
434
530
  signal,
435
531
  }) => getProduct(productId, requestOptions, signal);
436
532
 
437
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
533
+ return { queryKey, queryFn, enabled: !!productId, ...queryOptions };
534
+ };
535
+
536
+ export type GetProductQueryResult = NonNullable<
537
+ Awaited<ReturnType<typeof getProduct>>
538
+ >;
539
+ export type GetProductQueryError = ErrorType<AsError | void>;
540
+
541
+ export const useGetProduct = <
542
+ TData = Awaited<ReturnType<typeof getProduct>>,
543
+ TError = ErrorType<AsError | void>
544
+ >(
545
+ productId: string,
546
+ options?: {
547
+ query?: UseQueryOptions<
548
+ Awaited<ReturnType<typeof getProduct>>,
549
+ TError,
550
+ TData
551
+ >;
552
+ request?: SecondParameter<typeof customInstance>;
553
+ }
554
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
555
+ const queryOptions = getGetProductQueryOptions(productId, options);
438
556
 
439
- const query = useQuery<Awaited<ReturnType<typeof getProduct>>, TError, TData>(
440
- customOptions
441
- ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
557
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
558
+ queryKey: QueryKey;
559
+ };
442
560
 
443
- query.queryKey = customOptions.queryKey;
561
+ query.queryKey = queryOptions.queryKey;
444
562
 
445
563
  return query;
446
564
  };
@@ -458,13 +576,7 @@ export const deleteProduct = (
458
576
  );
459
577
  };
460
578
 
461
- export type DeleteProductMutationResult = NonNullable<
462
- Awaited<ReturnType<typeof deleteProduct>>
463
- >;
464
-
465
- export type DeleteProductMutationError = ErrorType<AsError>;
466
-
467
- export const useDeleteProduct = <
579
+ export const getDeleteProductMutationOptions = <
468
580
  TError = ErrorType<AsError>,
469
581
  TContext = unknown
470
582
  >(options?: {
@@ -475,7 +587,12 @@ export const useDeleteProduct = <
475
587
  TContext
476
588
  >;
477
589
  request?: SecondParameter<typeof customInstance>;
478
- }) => {
590
+ }): UseMutationOptions<
591
+ Awaited<ReturnType<typeof deleteProduct>>,
592
+ TError,
593
+ { productId: string },
594
+ TContext
595
+ > => {
479
596
  const { mutation: mutationOptions, request: requestOptions } = options ?? {};
480
597
 
481
598
  const mutationFn: MutationFunction<
@@ -487,12 +604,30 @@ export const useDeleteProduct = <
487
604
  return deleteProduct(productId, requestOptions);
488
605
  };
489
606
 
490
- return useMutation<
607
+ return { mutationFn, ...mutationOptions };
608
+ };
609
+
610
+ export type DeleteProductMutationResult = NonNullable<
611
+ Awaited<ReturnType<typeof deleteProduct>>
612
+ >;
613
+
614
+ export type DeleteProductMutationError = ErrorType<AsError>;
615
+
616
+ export const useDeleteProduct = <
617
+ TError = ErrorType<AsError>,
618
+ TContext = unknown
619
+ >(options?: {
620
+ mutation?: UseMutationOptions<
491
621
  Awaited<ReturnType<typeof deleteProduct>>,
492
622
  TError,
493
623
  { productId: string },
494
624
  TContext
495
- >(mutationFn, mutationOptions);
625
+ >;
626
+ request?: SecondParameter<typeof customInstance>;
627
+ }) => {
628
+ const mutationOptions = getDeleteProductMutationOptions(options);
629
+
630
+ return useMutation(mutationOptions);
496
631
  };
497
632
  /**
498
633
  * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. At the moment Data Manager products can be patched by changing the `name`, it's coin `allowance` or `limit`
@@ -515,13 +650,7 @@ export const patchProduct = (
515
650
  );
516
651
  };
517
652
 
518
- export type PatchProductMutationResult = NonNullable<
519
- Awaited<ReturnType<typeof patchProduct>>
520
- >;
521
- export type PatchProductMutationBody = ProductPatchBodyBody;
522
- export type PatchProductMutationError = ErrorType<AsError>;
523
-
524
- export const usePatchProduct = <
653
+ export const getPatchProductMutationOptions = <
525
654
  TError = ErrorType<AsError>,
526
655
  TContext = unknown
527
656
  >(options?: {
@@ -532,7 +661,12 @@ export const usePatchProduct = <
532
661
  TContext
533
662
  >;
534
663
  request?: SecondParameter<typeof customInstance>;
535
- }) => {
664
+ }): UseMutationOptions<
665
+ Awaited<ReturnType<typeof patchProduct>>,
666
+ TError,
667
+ { productId: string; data: ProductPatchBodyBody },
668
+ TContext
669
+ > => {
536
670
  const { mutation: mutationOptions, request: requestOptions } = options ?? {};
537
671
 
538
672
  const mutationFn: MutationFunction<
@@ -544,12 +678,30 @@ export const usePatchProduct = <
544
678
  return patchProduct(productId, data, requestOptions);
545
679
  };
546
680
 
547
- return useMutation<
681
+ return { mutationFn, ...mutationOptions };
682
+ };
683
+
684
+ export type PatchProductMutationResult = NonNullable<
685
+ Awaited<ReturnType<typeof patchProduct>>
686
+ >;
687
+ export type PatchProductMutationBody = ProductPatchBodyBody;
688
+ export type PatchProductMutationError = ErrorType<AsError>;
689
+
690
+ export const usePatchProduct = <
691
+ TError = ErrorType<AsError>,
692
+ TContext = unknown
693
+ >(options?: {
694
+ mutation?: UseMutationOptions<
548
695
  Awaited<ReturnType<typeof patchProduct>>,
549
696
  TError,
550
697
  { productId: string; data: ProductPatchBodyBody },
551
698
  TContext
552
- >(mutationFn, mutationOptions);
699
+ >;
700
+ request?: SecondParameter<typeof customInstance>;
701
+ }) => {
702
+ const mutationOptions = getPatchProductMutationOptions(options);
703
+
704
+ return useMutation(mutationOptions);
553
705
  };
554
706
  /**
555
707
  * Get the charges made against a product with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.
@@ -576,14 +728,9 @@ export const getProductCharges = (
576
728
  export const getGetProductChargesQueryKey = (
577
729
  productId: string,
578
730
  params?: GetProductChargesParams
579
- ) => [`/product/${productId}/charges`, ...(params ? [params] : [])];
731
+ ) => ["account-server-api", `/product/${productId}/charges`, ...(params ? [params] : [])] as const;
580
732
 
581
- export type GetProductChargesQueryResult = NonNullable<
582
- Awaited<ReturnType<typeof getProductCharges>>
583
- >;
584
- export type GetProductChargesQueryError = ErrorType<AsError | void>;
585
-
586
- export const useGetProductCharges = <
733
+ export const getGetProductChargesQueryOptions = <
587
734
  TData = Awaited<ReturnType<typeof getProductCharges>>,
588
735
  TError = ErrorType<AsError | void>
589
736
  >(
@@ -597,7 +744,11 @@ export const useGetProductCharges = <
597
744
  >;
598
745
  request?: SecondParameter<typeof customInstance>;
599
746
  }
600
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
747
+ ): UseQueryOptions<
748
+ Awaited<ReturnType<typeof getProductCharges>>,
749
+ TError,
750
+ TData
751
+ > & { queryKey: QueryKey } => {
601
752
  const { query: queryOptions, request: requestOptions } = options ?? {};
602
753
 
603
754
  const queryKey =
@@ -608,15 +759,40 @@ export const useGetProductCharges = <
608
759
  > = ({ signal }) =>
609
760
  getProductCharges(productId, params, requestOptions, signal);
610
761
 
611
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
762
+ return { queryKey, queryFn, enabled: !!productId, ...queryOptions };
763
+ };
612
764
 
613
- const query = useQuery<
614
- Awaited<ReturnType<typeof getProductCharges>>,
615
- TError,
616
- TData
617
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
765
+ export type GetProductChargesQueryResult = NonNullable<
766
+ Awaited<ReturnType<typeof getProductCharges>>
767
+ >;
768
+ export type GetProductChargesQueryError = ErrorType<AsError | void>;
769
+
770
+ export const useGetProductCharges = <
771
+ TData = Awaited<ReturnType<typeof getProductCharges>>,
772
+ TError = ErrorType<AsError | void>
773
+ >(
774
+ productId: string,
775
+ params?: GetProductChargesParams,
776
+ options?: {
777
+ query?: UseQueryOptions<
778
+ Awaited<ReturnType<typeof getProductCharges>>,
779
+ TError,
780
+ TData
781
+ >;
782
+ request?: SecondParameter<typeof customInstance>;
783
+ }
784
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
785
+ const queryOptions = getGetProductChargesQueryOptions(
786
+ productId,
787
+ params,
788
+ options
789
+ );
790
+
791
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
792
+ queryKey: QueryKey;
793
+ };
618
794
 
619
- query.queryKey = customOptions.queryKey;
795
+ query.queryKey = queryOptions.queryKey;
620
796
 
621
797
  return query;
622
798
  };