@squonk/account-server-client 2.0.3 → 2.0.4-rc.1
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.
- package/admin/admin.cjs +8 -6
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.ts +4 -4
- package/admin/admin.js +7 -5
- package/admin/admin.js.map +1 -1
- package/asset/asset.cjs +15 -13
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.ts +20 -20
- package/asset/asset.js +7 -5
- package/asset/asset.js.map +1 -1
- package/{chunk-3O5KIRV4.js → chunk-3RNIDX7T.js} +1 -1
- package/{chunk-3O5KIRV4.js.map → chunk-3RNIDX7T.js.map} +1 -1
- package/chunk-7XN3IQYV.cjs +13 -0
- package/chunk-7XN3IQYV.cjs.map +1 -0
- package/{chunk-IUEU2LYC.cjs → chunk-UZTHSGDT.cjs} +1 -1
- package/chunk-UZTHSGDT.cjs.map +1 -0
- package/chunk-YEX2SGER.js +13 -0
- package/chunk-YEX2SGER.js.map +1 -0
- package/{custom-instance-dad9d28e.d.ts → custom-instance-85497958.d.ts} +110 -48
- package/index.cjs +2 -2
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +12 -9
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.ts +6 -6
- package/merchant/merchant.js +10 -7
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +48 -16
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +37 -16
- package/organisation/organisation.js +42 -10
- package/organisation/organisation.js.map +1 -1
- package/package.json +12 -12
- package/product/product.cjs +35 -33
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +24 -24
- package/product/product.js +25 -23
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +85 -17
- package/src/admin/admin.ts +6 -5
- package/src/asset/asset.ts +6 -5
- package/src/merchant/merchant.ts +10 -9
- package/src/organisation/organisation.ts +83 -19
- package/src/product/product.ts +30 -32
- package/src/queryMutator.ts +12 -0
- package/src/state/state.ts +6 -5
- package/src/unit/unit.ts +83 -19
- package/src/user/user.ts +14 -15
- package/state/state.cjs +8 -6
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +4 -4
- package/state/state.js +7 -5
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +50 -25
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +42 -21
- package/unit/unit.js +42 -17
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +20 -17
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +16 -16
- package/user/user.js +13 -10
- package/user/user.js.map +1 -1
- package/chunk-IUEU2LYC.cjs.map +0 -1
package/src/asset/asset.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
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
|
-
|
|
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
|
};
|
package/src/merchant/merchant.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
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
|
-
>(
|
|
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
|
-
|
|
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.
|
|
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
|
-
>(
|
|
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,83 @@ 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
|
-
>(
|
|
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
|
+
const formData = new FormData();
|
|
228
|
+
if (organisationPatchBodyBody.name !== undefined) {
|
|
229
|
+
formData.append("name", organisationPatchBodyBody.name);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return customInstance<void>(
|
|
233
|
+
{
|
|
234
|
+
url: `/organisation/${orgId}`,
|
|
235
|
+
method: "patch",
|
|
236
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
237
|
+
data: formData,
|
|
238
|
+
},
|
|
239
|
+
options
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export type PatchOrganisationMutationResult = NonNullable<
|
|
244
|
+
Awaited<ReturnType<typeof patchOrganisation>>
|
|
245
|
+
>;
|
|
246
|
+
export type PatchOrganisationMutationBody = OrganisationPatchBodyBody;
|
|
247
|
+
export type PatchOrganisationMutationError = ErrorType<AsError>;
|
|
248
|
+
|
|
249
|
+
export const usePatchOrganisation = <
|
|
250
|
+
TError = ErrorType<AsError>,
|
|
251
|
+
TContext = unknown
|
|
252
|
+
>(options?: {
|
|
253
|
+
mutation?: UseMutationOptions<
|
|
254
|
+
Awaited<ReturnType<typeof patchOrganisation>>,
|
|
255
|
+
TError,
|
|
256
|
+
{ orgId: string; data: OrganisationPatchBodyBody },
|
|
257
|
+
TContext
|
|
258
|
+
>;
|
|
259
|
+
request?: SecondParameter<typeof customInstance>;
|
|
260
|
+
}) => {
|
|
261
|
+
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
262
|
+
|
|
263
|
+
const mutationFn: MutationFunction<
|
|
264
|
+
Awaited<ReturnType<typeof patchOrganisation>>,
|
|
265
|
+
{ orgId: string; data: OrganisationPatchBodyBody }
|
|
266
|
+
> = (props) => {
|
|
267
|
+
const { orgId, data } = props ?? {};
|
|
268
|
+
|
|
269
|
+
return patchOrganisation(orgId, data, requestOptions);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
return useMutation<
|
|
273
|
+
Awaited<ReturnType<typeof patchOrganisation>>,
|
|
274
|
+
TError,
|
|
275
|
+
{ orgId: string; data: OrganisationPatchBodyBody },
|
|
276
|
+
TContext
|
|
277
|
+
>(mutationFn, mutationOptions);
|
|
278
|
+
};
|
|
214
279
|
/**
|
|
215
280
|
* Units must first be deleted before an Organisation can be deleted
|
|
216
281
|
|
|
@@ -316,16 +381,15 @@ export const useGetOrganisationCharges = <
|
|
|
316
381
|
> = ({ signal }) =>
|
|
317
382
|
getOrganisationCharges(orgId, params, requestOptions, signal);
|
|
318
383
|
|
|
384
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
385
|
+
|
|
319
386
|
const query = useQuery<
|
|
320
387
|
Awaited<ReturnType<typeof getOrganisationCharges>>,
|
|
321
388
|
TError,
|
|
322
389
|
TData
|
|
323
|
-
>(
|
|
324
|
-
TData,
|
|
325
|
-
TError
|
|
326
|
-
> & { queryKey: QueryKey };
|
|
390
|
+
>(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
327
391
|
|
|
328
|
-
query.queryKey = queryKey;
|
|
392
|
+
query.queryKey = customOptions.queryKey;
|
|
329
393
|
|
|
330
394
|
return query;
|
|
331
395
|
};
|
|
@@ -374,15 +438,15 @@ export const useGetDefaultOrganisation = <
|
|
|
374
438
|
Awaited<ReturnType<typeof getDefaultOrganisation>>
|
|
375
439
|
> = ({ signal }) => getDefaultOrganisation(requestOptions, signal);
|
|
376
440
|
|
|
441
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
442
|
+
|
|
377
443
|
const query = useQuery<
|
|
378
444
|
Awaited<ReturnType<typeof getDefaultOrganisation>>,
|
|
379
445
|
TError,
|
|
380
446
|
TData
|
|
381
|
-
>(
|
|
382
|
-
queryKey: QueryKey;
|
|
383
|
-
};
|
|
447
|
+
>(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
384
448
|
|
|
385
|
-
query.queryKey = queryKey;
|
|
449
|
+
query.queryKey = customOptions.queryKey;
|
|
386
450
|
|
|
387
451
|
return query;
|
|
388
452
|
};
|
package/src/product/product.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
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
|
-
>(
|
|
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
|
-
>(
|
|
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
|
-
>(
|
|
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
|
-
>(
|
|
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
|
-
>(
|
|
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
|
-
|
|
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
|
-
>(
|
|
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;
|
package/src/state/state.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
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
|
-
|
|
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.
|
|
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
|
-
>(
|
|
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,81 @@ 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
|
-
|
|
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
|
+
const formData = new FormData();
|
|
228
|
+
if (unitPatchBodyBody.name !== undefined) {
|
|
229
|
+
formData.append("name", unitPatchBodyBody.name);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return customInstance<void>(
|
|
233
|
+
{
|
|
234
|
+
url: `/unit/${unitId}`,
|
|
235
|
+
method: "patch",
|
|
236
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
237
|
+
data: formData,
|
|
238
|
+
},
|
|
239
|
+
options
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export type PatchUnitMutationResult = NonNullable<
|
|
244
|
+
Awaited<ReturnType<typeof patchUnit>>
|
|
245
|
+
>;
|
|
246
|
+
export type PatchUnitMutationBody = UnitPatchBodyBody;
|
|
247
|
+
export type PatchUnitMutationError = ErrorType<AsError>;
|
|
248
|
+
|
|
249
|
+
export const usePatchUnit = <
|
|
250
|
+
TError = ErrorType<AsError>,
|
|
251
|
+
TContext = unknown
|
|
252
|
+
>(options?: {
|
|
253
|
+
mutation?: UseMutationOptions<
|
|
254
|
+
Awaited<ReturnType<typeof patchUnit>>,
|
|
255
|
+
TError,
|
|
256
|
+
{ unitId: string; data: UnitPatchBodyBody },
|
|
257
|
+
TContext
|
|
258
|
+
>;
|
|
259
|
+
request?: SecondParameter<typeof customInstance>;
|
|
260
|
+
}) => {
|
|
261
|
+
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
262
|
+
|
|
263
|
+
const mutationFn: MutationFunction<
|
|
264
|
+
Awaited<ReturnType<typeof patchUnit>>,
|
|
265
|
+
{ unitId: string; data: UnitPatchBodyBody }
|
|
266
|
+
> = (props) => {
|
|
267
|
+
const { unitId, data } = props ?? {};
|
|
268
|
+
|
|
269
|
+
return patchUnit(unitId, data, requestOptions);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
return useMutation<
|
|
273
|
+
Awaited<ReturnType<typeof patchUnit>>,
|
|
274
|
+
TError,
|
|
275
|
+
{ unitId: string; data: UnitPatchBodyBody },
|
|
276
|
+
TContext
|
|
277
|
+
>(mutationFn, mutationOptions);
|
|
278
|
+
};
|
|
214
279
|
/**
|
|
215
280
|
* 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
281
|
|
|
@@ -299,13 +364,13 @@ export const useGetUnits = <
|
|
|
299
364
|
signal,
|
|
300
365
|
}) => getUnits(requestOptions, signal);
|
|
301
366
|
|
|
367
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
368
|
+
|
|
302
369
|
const query = useQuery<Awaited<ReturnType<typeof getUnits>>, TError, TData>(
|
|
303
|
-
|
|
304
|
-
queryFn,
|
|
305
|
-
queryOptions
|
|
370
|
+
customOptions
|
|
306
371
|
) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
307
372
|
|
|
308
|
-
query.queryKey = queryKey;
|
|
373
|
+
query.queryKey = customOptions.queryKey;
|
|
309
374
|
|
|
310
375
|
return query;
|
|
311
376
|
};
|
|
@@ -468,16 +533,15 @@ export const useGetUnitCharges = <
|
|
|
468
533
|
signal,
|
|
469
534
|
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
470
535
|
|
|
536
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
537
|
+
|
|
471
538
|
const query = useQuery<
|
|
472
539
|
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
473
540
|
TError,
|
|
474
541
|
TData
|
|
475
|
-
>(
|
|
476
|
-
enabled: !!unitId,
|
|
477
|
-
...queryOptions,
|
|
478
|
-
}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
542
|
+
>(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
479
543
|
|
|
480
|
-
query.queryKey = queryKey;
|
|
544
|
+
query.queryKey = customOptions.queryKey;
|
|
481
545
|
|
|
482
546
|
return query;
|
|
483
547
|
};
|