@squonk/account-server-client 2.0.3 → 2.0.4-rc.2

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 (66) hide show
  1. package/admin/admin.cjs +8 -6
  2. package/admin/admin.cjs.map +1 -1
  3. package/admin/admin.d.ts +4 -4
  4. package/admin/admin.js +7 -5
  5. package/admin/admin.js.map +1 -1
  6. package/asset/asset.cjs +15 -13
  7. package/asset/asset.cjs.map +1 -1
  8. package/asset/asset.d.ts +20 -20
  9. package/asset/asset.js +7 -5
  10. package/asset/asset.js.map +1 -1
  11. package/{chunk-3O5KIRV4.js → chunk-3RNIDX7T.js} +1 -1
  12. package/{chunk-3O5KIRV4.js.map → chunk-3RNIDX7T.js.map} +1 -1
  13. package/chunk-7XN3IQYV.cjs +13 -0
  14. package/chunk-7XN3IQYV.cjs.map +1 -0
  15. package/{chunk-IUEU2LYC.cjs → chunk-UZTHSGDT.cjs} +1 -1
  16. package/chunk-UZTHSGDT.cjs.map +1 -0
  17. package/chunk-YEX2SGER.js +13 -0
  18. package/chunk-YEX2SGER.js.map +1 -0
  19. package/{custom-instance-dad9d28e.d.ts → custom-instance-85497958.d.ts} +110 -48
  20. package/index.cjs +2 -2
  21. package/index.cjs.map +1 -1
  22. package/index.d.ts +1 -1
  23. package/index.js +1 -1
  24. package/index.js.map +1 -1
  25. package/merchant/merchant.cjs +12 -9
  26. package/merchant/merchant.cjs.map +1 -1
  27. package/merchant/merchant.d.ts +6 -6
  28. package/merchant/merchant.js +10 -7
  29. package/merchant/merchant.js.map +1 -1
  30. package/organisation/organisation.cjs +44 -16
  31. package/organisation/organisation.cjs.map +1 -1
  32. package/organisation/organisation.d.ts +37 -16
  33. package/organisation/organisation.js +38 -10
  34. package/organisation/organisation.js.map +1 -1
  35. package/package.json +12 -12
  36. package/product/product.cjs +35 -33
  37. package/product/product.cjs.map +1 -1
  38. package/product/product.d.ts +24 -24
  39. package/product/product.js +25 -23
  40. package/product/product.js.map +1 -1
  41. package/src/account-server-api.schemas.ts +85 -17
  42. package/src/admin/admin.ts +6 -5
  43. package/src/asset/asset.ts +6 -5
  44. package/src/merchant/merchant.ts +10 -9
  45. package/src/organisation/organisation.ts +78 -19
  46. package/src/product/product.ts +30 -32
  47. package/src/queryMutator.ts +12 -0
  48. package/src/state/state.ts +6 -5
  49. package/src/unit/unit.ts +78 -19
  50. package/src/user/user.ts +14 -15
  51. package/state/state.cjs +8 -6
  52. package/state/state.cjs.map +1 -1
  53. package/state/state.d.ts +4 -4
  54. package/state/state.js +7 -5
  55. package/state/state.js.map +1 -1
  56. package/unit/unit.cjs +46 -25
  57. package/unit/unit.cjs.map +1 -1
  58. package/unit/unit.d.ts +42 -21
  59. package/unit/unit.js +38 -17
  60. package/unit/unit.js.map +1 -1
  61. package/user/user.cjs +20 -17
  62. package/user/user.cjs.map +1 -1
  63. package/user/user.d.ts +16 -16
  64. package/user/user.js +13 -10
  65. package/user/user.js.map +1 -1
  66. package/chunk-IUEU2LYC.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -29,6 +29,7 @@ import type {
29
29
  } from "../account-server-api.schemas";
30
30
  import { customInstance } from ".././custom-instance";
31
31
  import type { ErrorType } from ".././custom-instance";
32
+ import { queryMutator } from ".././queryMutator";
32
33
 
33
34
  // eslint-disable-next-line
34
35
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -86,13 +87,13 @@ export const useGetAsset = <
86
87
  signal,
87
88
  }) => getAsset(params, requestOptions, signal);
88
89
 
90
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
91
+
89
92
  const query = useQuery<Awaited<ReturnType<typeof getAsset>>, TError, TData>(
90
- queryKey,
91
- queryFn,
92
- queryOptions
93
+ customOptions
93
94
  ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
94
95
 
95
- query.queryKey = queryKey;
96
+ query.queryKey = customOptions.queryKey;
96
97
 
97
98
  return query;
98
99
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -22,6 +22,7 @@ import type {
22
22
  } from "../account-server-api.schemas";
23
23
  import { customInstance } from ".././custom-instance";
24
24
  import type { ErrorType } from ".././custom-instance";
25
+ import { queryMutator } from ".././queryMutator";
25
26
 
26
27
  // eslint-disable-next-line
27
28
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -72,15 +73,15 @@ export const useGetMerchants = <
72
73
  signal,
73
74
  }) => getMerchants(requestOptions, signal);
74
75
 
76
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
77
+
75
78
  const query = useQuery<
76
79
  Awaited<ReturnType<typeof getMerchants>>,
77
80
  TError,
78
81
  TData
79
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
80
- queryKey: QueryKey;
81
- };
82
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
82
83
 
83
- query.queryKey = queryKey;
84
+ query.queryKey = customOptions.queryKey;
84
85
 
85
86
  return query;
86
87
  };
@@ -130,13 +131,13 @@ export const useGetService = <
130
131
  signal,
131
132
  }) => getService(mId, requestOptions, signal);
132
133
 
134
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
135
+
133
136
  const query = useQuery<Awaited<ReturnType<typeof getService>>, TError, TData>(
134
- queryKey,
135
- queryFn,
136
- { enabled: !!mId, ...queryOptions }
137
+ customOptions
137
138
  ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
138
139
 
139
- query.queryKey = queryKey;
140
+ query.queryKey = customOptions.queryKey;
140
141
 
141
142
  return query;
142
143
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -23,12 +23,14 @@ import type {
23
23
  OrganisationPostResponse,
24
24
  OrganisationPostBodyBody,
25
25
  OrganisationGetResponse,
26
+ OrganisationPatchBodyBody,
26
27
  OrganisationChargesGetResponse,
27
28
  GetOrganisationChargesParams,
28
29
  OrganisationGetDefaultResponse,
29
30
  } from "../account-server-api.schemas";
30
31
  import { customInstance } from ".././custom-instance";
31
32
  import type { ErrorType } from ".././custom-instance";
33
+ import { queryMutator } from ".././queryMutator";
32
34
 
33
35
  // eslint-disable-next-line
34
36
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -79,15 +81,15 @@ export const useGetOrganisations = <
79
81
  Awaited<ReturnType<typeof getOrganisations>>
80
82
  > = ({ signal }) => getOrganisations(requestOptions, signal);
81
83
 
84
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
85
+
82
86
  const query = useQuery<
83
87
  Awaited<ReturnType<typeof getOrganisations>>,
84
88
  TError,
85
89
  TData
86
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
87
- queryKey: QueryKey;
88
- };
90
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
89
91
 
90
- query.queryKey = queryKey;
92
+ query.queryKey = customOptions.queryKey;
91
93
 
92
94
  return query;
93
95
  };
@@ -197,20 +199,78 @@ export const useGetOrganisation = <
197
199
  signal,
198
200
  }) => getOrganisation(orgId, requestOptions, signal);
199
201
 
202
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
203
+
200
204
  const query = useQuery<
201
205
  Awaited<ReturnType<typeof getOrganisation>>,
202
206
  TError,
203
207
  TData
204
- >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
205
- TData,
206
- TError
207
- > & { queryKey: QueryKey };
208
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
208
209
 
209
- query.queryKey = queryKey;
210
+ query.queryKey = customOptions.queryKey;
210
211
 
211
212
  return query;
212
213
  };
213
214
 
215
+ /**
216
+ * Used to update existing **Organisation**.
217
+
218
+ You have to be the Organisation owner (or an administrator) to patch an Organisation.
219
+
220
+ * @summary Adjust an existing Organisation
221
+ */
222
+ export const patchOrganisation = (
223
+ orgId: string,
224
+ organisationPatchBodyBody: OrganisationPatchBodyBody,
225
+ options?: SecondParameter<typeof customInstance>
226
+ ) => {
227
+ return customInstance<void>(
228
+ {
229
+ url: `/organisation/${orgId}`,
230
+ method: "patch",
231
+ headers: { "Content-Type": "application/json" },
232
+ data: organisationPatchBodyBody,
233
+ },
234
+ options
235
+ );
236
+ };
237
+
238
+ export type PatchOrganisationMutationResult = NonNullable<
239
+ Awaited<ReturnType<typeof patchOrganisation>>
240
+ >;
241
+ export type PatchOrganisationMutationBody = OrganisationPatchBodyBody;
242
+ export type PatchOrganisationMutationError = ErrorType<AsError>;
243
+
244
+ export const usePatchOrganisation = <
245
+ TError = ErrorType<AsError>,
246
+ TContext = unknown
247
+ >(options?: {
248
+ mutation?: UseMutationOptions<
249
+ Awaited<ReturnType<typeof patchOrganisation>>,
250
+ TError,
251
+ { orgId: string; data: OrganisationPatchBodyBody },
252
+ TContext
253
+ >;
254
+ request?: SecondParameter<typeof customInstance>;
255
+ }) => {
256
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
257
+
258
+ const mutationFn: MutationFunction<
259
+ Awaited<ReturnType<typeof patchOrganisation>>,
260
+ { orgId: string; data: OrganisationPatchBodyBody }
261
+ > = (props) => {
262
+ const { orgId, data } = props ?? {};
263
+
264
+ return patchOrganisation(orgId, data, requestOptions);
265
+ };
266
+
267
+ return useMutation<
268
+ Awaited<ReturnType<typeof patchOrganisation>>,
269
+ TError,
270
+ { orgId: string; data: OrganisationPatchBodyBody },
271
+ TContext
272
+ >(mutationFn, mutationOptions);
273
+ };
214
274
  /**
215
275
  * Units must first be deleted before an Organisation can be deleted
216
276
 
@@ -316,16 +376,15 @@ export const useGetOrganisationCharges = <
316
376
  > = ({ signal }) =>
317
377
  getOrganisationCharges(orgId, params, requestOptions, signal);
318
378
 
379
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
380
+
319
381
  const query = useQuery<
320
382
  Awaited<ReturnType<typeof getOrganisationCharges>>,
321
383
  TError,
322
384
  TData
323
- >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
324
- TData,
325
- TError
326
- > & { queryKey: QueryKey };
385
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
327
386
 
328
- query.queryKey = queryKey;
387
+ query.queryKey = customOptions.queryKey;
329
388
 
330
389
  return query;
331
390
  };
@@ -374,15 +433,15 @@ export const useGetDefaultOrganisation = <
374
433
  Awaited<ReturnType<typeof getDefaultOrganisation>>
375
434
  > = ({ signal }) => getDefaultOrganisation(requestOptions, signal);
376
435
 
436
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
437
+
377
438
  const query = useQuery<
378
439
  Awaited<ReturnType<typeof getDefaultOrganisation>>,
379
440
  TError,
380
441
  TData
381
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
382
- queryKey: QueryKey;
383
- };
442
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
384
443
 
385
- query.queryKey = queryKey;
444
+ query.queryKey = customOptions.queryKey;
386
445
 
387
446
  return query;
388
447
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -31,6 +31,7 @@ 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";
34
35
 
35
36
  // eslint-disable-next-line
36
37
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -81,15 +82,15 @@ export const useGetProductTypes = <
81
82
  signal,
82
83
  }) => getProductTypes(requestOptions, signal);
83
84
 
85
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
86
+
84
87
  const query = useQuery<
85
88
  Awaited<ReturnType<typeof getProductTypes>>,
86
89
  TError,
87
90
  TData
88
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
89
- queryKey: QueryKey;
90
- };
91
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
91
92
 
92
- query.queryKey = queryKey;
93
+ query.queryKey = customOptions.queryKey;
93
94
 
94
95
  return query;
95
96
  };
@@ -136,15 +137,15 @@ export const useGetProductDefaultStorageCost = <
136
137
  Awaited<ReturnType<typeof getProductDefaultStorageCost>>
137
138
  > = ({ signal }) => getProductDefaultStorageCost(requestOptions, signal);
138
139
 
140
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
141
+
139
142
  const query = useQuery<
140
143
  Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
141
144
  TError,
142
145
  TData
143
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
144
- queryKey: QueryKey;
145
- };
146
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
146
147
 
147
- query.queryKey = queryKey;
148
+ query.queryKey = customOptions.queryKey;
148
149
 
149
150
  return query;
150
151
  };
@@ -190,15 +191,15 @@ export const useGetProducts = <
190
191
  signal,
191
192
  }) => getProducts(requestOptions, signal);
192
193
 
194
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
195
+
193
196
  const query = useQuery<
194
197
  Awaited<ReturnType<typeof getProducts>>,
195
198
  TError,
196
199
  TData
197
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
198
- queryKey: QueryKey;
199
- };
200
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
200
201
 
201
- query.queryKey = queryKey;
202
+ query.queryKey = customOptions.queryKey;
202
203
 
203
204
  return query;
204
205
  };
@@ -251,16 +252,15 @@ export const useGetProductsForOrganisation = <
251
252
  Awaited<ReturnType<typeof getProductsForOrganisation>>
252
253
  > = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
253
254
 
255
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
256
+
254
257
  const query = useQuery<
255
258
  Awaited<ReturnType<typeof getProductsForOrganisation>>,
256
259
  TError,
257
260
  TData
258
- >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
259
- TData,
260
- TError
261
- > & { queryKey: QueryKey };
261
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
262
262
 
263
- query.queryKey = queryKey;
263
+ query.queryKey = customOptions.queryKey;
264
264
 
265
265
  return query;
266
266
  };
@@ -374,16 +374,15 @@ export const useGetProductsForUnit = <
374
374
  Awaited<ReturnType<typeof getProductsForUnit>>
375
375
  > = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
376
376
 
377
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
378
+
377
379
  const query = useQuery<
378
380
  Awaited<ReturnType<typeof getProductsForUnit>>,
379
381
  TError,
380
382
  TData
381
- >(queryKey, queryFn, {
382
- enabled: !!unitId,
383
- ...queryOptions,
384
- }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
383
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
385
384
 
386
- query.queryKey = queryKey;
385
+ query.queryKey = customOptions.queryKey;
387
386
 
388
387
  return query;
389
388
  };
@@ -435,13 +434,13 @@ export const useGetProduct = <
435
434
  signal,
436
435
  }) => getProduct(productId, requestOptions, signal);
437
436
 
437
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
438
+
438
439
  const query = useQuery<Awaited<ReturnType<typeof getProduct>>, TError, TData>(
439
- queryKey,
440
- queryFn,
441
- { enabled: !!productId, ...queryOptions }
440
+ customOptions
442
441
  ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
443
442
 
444
- query.queryKey = queryKey;
443
+ query.queryKey = customOptions.queryKey;
445
444
 
446
445
  return query;
447
446
  };
@@ -609,16 +608,15 @@ export const useGetProductCharges = <
609
608
  > = ({ signal }) =>
610
609
  getProductCharges(productId, params, requestOptions, signal);
611
610
 
611
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
612
+
612
613
  const query = useQuery<
613
614
  Awaited<ReturnType<typeof getProductCharges>>,
614
615
  TError,
615
616
  TData
616
- >(queryKey, queryFn, {
617
- enabled: !!productId,
618
- ...queryOptions,
619
- }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
617
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
620
618
 
621
- query.queryKey = queryKey;
619
+ query.queryKey = customOptions.queryKey;
622
620
 
623
621
  return query;
624
622
  };
@@ -0,0 +1,12 @@
1
+ import { UseQueryOptions } from '@tanstack/react-query';
2
+
3
+ export const queryMutator = <T>(args: T): T => {
4
+ if ((args as UseQueryOptions).queryKey) {
5
+ (args as any).queryKey.unshift('"account-server-api"');
6
+ return args;
7
+ }
8
+
9
+ return args;
10
+ };
11
+
12
+ export default queryMutator;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -21,6 +21,7 @@ import type {
21
21
  } from "../account-server-api.schemas";
22
22
  import { customInstance } from ".././custom-instance";
23
23
  import type { ErrorType } from ".././custom-instance";
24
+ import { queryMutator } from ".././queryMutator";
24
25
 
25
26
  // eslint-disable-next-line
26
27
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -69,13 +70,13 @@ export const useGetVersion = <
69
70
  signal,
70
71
  }) => getVersion(requestOptions, signal);
71
72
 
73
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
74
+
72
75
  const query = useQuery<Awaited<ReturnType<typeof getVersion>>, TError, TData>(
73
- queryKey,
74
- queryFn,
75
- queryOptions
76
+ customOptions
76
77
  ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
77
78
 
78
- query.queryKey = queryKey;
79
+ query.queryKey = customOptions.queryKey;
79
80
 
80
81
  return query;
81
82
  };
package/src/unit/unit.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -23,6 +23,7 @@ import type {
23
23
  OrganisationUnitPostResponse,
24
24
  OrganisationUnitPostBodyBody,
25
25
  UnitGetResponse,
26
+ UnitPatchBodyBody,
26
27
  UnitsGetResponse,
27
28
  PersonalUnitPutResponse,
28
29
  PersonalUnitPutBodyBody,
@@ -31,6 +32,7 @@ import type {
31
32
  } from "../account-server-api.schemas";
32
33
  import { customInstance } from ".././custom-instance";
33
34
  import type { ErrorType } from ".././custom-instance";
35
+ import { queryMutator } from ".././queryMutator";
34
36
 
35
37
  // eslint-disable-next-line
36
38
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -88,16 +90,15 @@ export const useGetOrganisationUnits = <
88
90
  Awaited<ReturnType<typeof getOrganisationUnits>>
89
91
  > = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);
90
92
 
93
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
94
+
91
95
  const query = useQuery<
92
96
  Awaited<ReturnType<typeof getOrganisationUnits>>,
93
97
  TError,
94
98
  TData
95
- >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
96
- TData,
97
- TError
98
- > & { queryKey: QueryKey };
99
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
99
100
 
100
- query.queryKey = queryKey;
101
+ query.queryKey = customOptions.queryKey;
101
102
 
102
103
  return query;
103
104
  };
@@ -200,17 +201,76 @@ export const useGetUnit = <
200
201
  signal,
201
202
  }) => getUnit(unitId, requestOptions, signal);
202
203
 
204
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
205
+
203
206
  const query = useQuery<Awaited<ReturnType<typeof getUnit>>, TError, TData>(
204
- queryKey,
205
- queryFn,
206
- { enabled: !!unitId, ...queryOptions }
207
+ customOptions
207
208
  ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
208
209
 
209
- query.queryKey = queryKey;
210
+ query.queryKey = customOptions.queryKey;
210
211
 
211
212
  return query;
212
213
  };
213
214
 
215
+ /**
216
+ * Used to update existing **Unit**.
217
+
218
+ You have to be the Unit owner (or an administrator) to patch a Unit.
219
+
220
+ * @summary Adjust an existing Unit
221
+ */
222
+ export const patchUnit = (
223
+ unitId: string,
224
+ unitPatchBodyBody: UnitPatchBodyBody,
225
+ options?: SecondParameter<typeof customInstance>
226
+ ) => {
227
+ return customInstance<void>(
228
+ {
229
+ url: `/unit/${unitId}`,
230
+ method: "patch",
231
+ headers: { "Content-Type": "application/json" },
232
+ data: unitPatchBodyBody,
233
+ },
234
+ options
235
+ );
236
+ };
237
+
238
+ export type PatchUnitMutationResult = NonNullable<
239
+ Awaited<ReturnType<typeof patchUnit>>
240
+ >;
241
+ export type PatchUnitMutationBody = UnitPatchBodyBody;
242
+ export type PatchUnitMutationError = ErrorType<AsError>;
243
+
244
+ export const usePatchUnit = <
245
+ TError = ErrorType<AsError>,
246
+ TContext = unknown
247
+ >(options?: {
248
+ mutation?: UseMutationOptions<
249
+ Awaited<ReturnType<typeof patchUnit>>,
250
+ TError,
251
+ { unitId: string; data: UnitPatchBodyBody },
252
+ TContext
253
+ >;
254
+ request?: SecondParameter<typeof customInstance>;
255
+ }) => {
256
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
257
+
258
+ const mutationFn: MutationFunction<
259
+ Awaited<ReturnType<typeof patchUnit>>,
260
+ { unitId: string; data: UnitPatchBodyBody }
261
+ > = (props) => {
262
+ const { unitId, data } = props ?? {};
263
+
264
+ return patchUnit(unitId, data, requestOptions);
265
+ };
266
+
267
+ return useMutation<
268
+ Awaited<ReturnType<typeof patchUnit>>,
269
+ TError,
270
+ { unitId: string; data: UnitPatchBodyBody },
271
+ TContext
272
+ >(mutationFn, mutationOptions);
273
+ };
214
274
  /**
215
275
  * Deletes an Organisational Unit you have access to. Units can only be deleted by Organisation users or Admin users. You cannot delete a Unit that contains Products
216
276
 
@@ -299,13 +359,13 @@ export const useGetUnits = <
299
359
  signal,
300
360
  }) => getUnits(requestOptions, signal);
301
361
 
362
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
363
+
302
364
  const query = useQuery<Awaited<ReturnType<typeof getUnits>>, TError, TData>(
303
- queryKey,
304
- queryFn,
305
- queryOptions
365
+ customOptions
306
366
  ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
307
367
 
308
- query.queryKey = queryKey;
368
+ query.queryKey = customOptions.queryKey;
309
369
 
310
370
  return query;
311
371
  };
@@ -468,16 +528,15 @@ export const useGetUnitCharges = <
468
528
  signal,
469
529
  }) => getUnitCharges(unitId, params, requestOptions, signal);
470
530
 
531
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
532
+
471
533
  const query = useQuery<
472
534
  Awaited<ReturnType<typeof getUnitCharges>>,
473
535
  TError,
474
536
  TData
475
- >(queryKey, queryFn, {
476
- enabled: !!unitId,
477
- ...queryOptions,
478
- }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
537
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
479
538
 
480
- query.queryKey = queryKey;
539
+ query.queryKey = customOptions.queryKey;
481
540
 
482
541
  return query;
483
542
  };
package/src/user/user.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.10.0 🍺
2
+ * Generated by orval v6.12.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -24,6 +24,7 @@ import type {
24
24
  } from "../account-server-api.schemas";
25
25
  import { customInstance } from ".././custom-instance";
26
26
  import type { ErrorType } from ".././custom-instance";
27
+ import { queryMutator } from ".././queryMutator";
27
28
 
28
29
  // eslint-disable-next-line
29
30
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -74,15 +75,15 @@ export const useGetUserAccount = <
74
75
  signal,
75
76
  }) => getUserAccount(requestOptions, signal);
76
77
 
78
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
79
+
77
80
  const query = useQuery<
78
81
  Awaited<ReturnType<typeof getUserAccount>>,
79
82
  TError,
80
83
  TData
81
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
82
- queryKey: QueryKey;
83
- };
84
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
84
85
 
85
- query.queryKey = queryKey;
86
+ query.queryKey = customOptions.queryKey;
86
87
 
87
88
  return query;
88
89
  };
@@ -135,16 +136,15 @@ export const useGetOrganisationUsers = <
135
136
  Awaited<ReturnType<typeof getOrganisationUsers>>
136
137
  > = ({ signal }) => getOrganisationUsers(orgId, requestOptions, signal);
137
138
 
139
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
140
+
138
141
  const query = useQuery<
139
142
  Awaited<ReturnType<typeof getOrganisationUsers>>,
140
143
  TError,
141
144
  TData
142
- >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
143
- TData,
144
- TError
145
- > & { queryKey: QueryKey };
145
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
146
146
 
147
- query.queryKey = queryKey;
147
+ query.queryKey = customOptions.queryKey;
148
148
 
149
149
  return query;
150
150
  };
@@ -301,16 +301,15 @@ export const useGetOrganisationUnitUsers = <
301
301
  Awaited<ReturnType<typeof getOrganisationUnitUsers>>
302
302
  > = ({ signal }) => getOrganisationUnitUsers(unitId, requestOptions, signal);
303
303
 
304
+ const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
305
+
304
306
  const query = useQuery<
305
307
  Awaited<ReturnType<typeof getOrganisationUnitUsers>>,
306
308
  TError,
307
309
  TData
308
- >(queryKey, queryFn, {
309
- enabled: !!unitId,
310
- ...queryOptions,
311
- }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
310
+ >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
312
311
 
313
- query.queryKey = queryKey;
312
+ query.queryKey = customOptions.queryKey;
314
313
 
315
314
  return query;
316
315
  };