@squonk/account-server-client 0.1.26 → 0.1.27-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.
Files changed (42) hide show
  1. package/{account-server-api.schemas-078442c3.d.ts → account-server-api.schemas-e6c5f956.d.ts} +13 -0
  2. package/index.cjs.map +1 -1
  3. package/index.d.ts +1 -1
  4. package/index.js.map +1 -1
  5. package/organisation/organisation.cjs +64 -19
  6. package/organisation/organisation.cjs.map +1 -1
  7. package/organisation/organisation.d.ts +67 -18
  8. package/organisation/organisation.js +64 -19
  9. package/organisation/organisation.js.map +1 -1
  10. package/package.json +1 -1
  11. package/product/product.cjs +108 -30
  12. package/product/product.cjs.map +1 -1
  13. package/product/product.d.ts +114 -24
  14. package/product/product.js +108 -30
  15. package/product/product.js.map +1 -1
  16. package/service/service.cjs +39 -10
  17. package/service/service.cjs.map +1 -1
  18. package/service/service.d.ts +34 -8
  19. package/service/service.js +39 -10
  20. package/service/service.js.map +1 -1
  21. package/src/account-server-api.schemas.ts +13 -0
  22. package/src/organisation/organisation.ts +195 -44
  23. package/src/product/product.ts +356 -84
  24. package/src/service/service.ts +108 -16
  25. package/src/state/state.ts +64 -16
  26. package/src/unit/unit.ts +339 -74
  27. package/src/user/user.ts +340 -67
  28. package/state/state.cjs +21 -7
  29. package/state/state.cjs.map +1 -1
  30. package/state/state.d.ts +17 -6
  31. package/state/state.js +21 -7
  32. package/state/state.js.map +1 -1
  33. package/unit/unit.cjs +104 -29
  34. package/unit/unit.cjs.map +1 -1
  35. package/unit/unit.d.ts +107 -25
  36. package/unit/unit.js +104 -29
  37. package/unit/unit.js.map +1 -1
  38. package/user/user.cjs +106 -29
  39. package/user/user.cjs.map +1 -1
  40. package/user/user.d.ts +132 -20
  41. package/user/user.js +106 -29
  42. package/user/user.js.map +1 -1
@@ -8,9 +8,20 @@ A service that provides access to the Account Server, which gives *registered* u
8
8
 
9
9
  * OpenAPI spec version: 0.1
10
10
  */
11
- import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
11
+ import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
12
+ import {
13
+ useQuery,
14
+ useMutation,
15
+ UseQueryOptions,
16
+ UseMutationOptions,
17
+ QueryFunction,
18
+ MutationFunction,
19
+ UseQueryResult,
20
+ QueryKey,
21
+ } from "react-query";
12
22
  import type {
13
23
  ProductsGetTypesResponse,
24
+ AsError,
14
25
  ProductsGetResponse,
15
26
  UnitProductPostResponse,
16
27
  UnitProductPostBodyBody,
@@ -18,114 +29,375 @@ import type {
18
29
  ProductPatchBodyBody,
19
30
  } from "../account-server-api.schemas";
20
31
 
21
- export const getProduct = () => {
22
- /**
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
34
+ ...args: any
35
+ ) => Promise<infer R>
36
+ ? R
37
+ : any;
38
+
39
+ /**
23
40
  * Gets product types you can purchase
24
41
 
25
42
  * @summary Gets all Product Types
26
43
  */
27
- const appApiProductGetTypes = <
28
- TData = AxiosResponse<ProductsGetTypesResponse>
29
- >(
30
- options?: AxiosRequestConfig
31
- ): Promise<TData> => {
32
- return axios.get(`/product-type`, options);
44
+ export const appApiProductGetTypes = (
45
+ options?: AxiosRequestConfig
46
+ ): Promise<AxiosResponse<ProductsGetTypesResponse>> => {
47
+ return axios.get(`/product-type`, options);
48
+ };
49
+
50
+ export const getAppApiProductGetTypesQueryKey = () => [`/product-type`];
51
+
52
+ export type AppApiProductGetTypesQueryResult = NonNullable<
53
+ AsyncReturnType<typeof appApiProductGetTypes>
54
+ >;
55
+ export type AppApiProductGetTypesQueryError = AxiosError<AsError | void>;
56
+
57
+ export const useAppApiProductGetTypes = <
58
+ TData = AsyncReturnType<typeof appApiProductGetTypes>,
59
+ TError = AxiosError<AsError | void>
60
+ >(options?: {
61
+ query?: UseQueryOptions<
62
+ AsyncReturnType<typeof appApiProductGetTypes>,
63
+ TError,
64
+ TData
65
+ >;
66
+ axios?: AxiosRequestConfig;
67
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
68
+ const { query: queryOptions, axios: axiosOptions } = options || {};
69
+
70
+ const queryKey = queryOptions?.queryKey ?? getAppApiProductGetTypesQueryKey();
71
+
72
+ const queryFn: QueryFunction<
73
+ AsyncReturnType<typeof appApiProductGetTypes>
74
+ > = () => appApiProductGetTypes(axiosOptions);
75
+
76
+ const query = useQuery<
77
+ AsyncReturnType<typeof appApiProductGetTypes>,
78
+ TError,
79
+ TData
80
+ >(queryKey, queryFn, queryOptions);
81
+
82
+ return {
83
+ queryKey,
84
+ ...query,
33
85
  };
34
- /**
86
+ };
87
+
88
+ /**
35
89
  * Gets products you have access to, across all Units and Organisations
36
90
 
37
91
  * @summary Gets all Products
38
92
  */
39
- const appApiProductGet = <TData = AxiosResponse<ProductsGetResponse>>(
40
- options?: AxiosRequestConfig
41
- ): Promise<TData> => {
42
- return axios.get(`/product`, options);
93
+ export const appApiProductGet = (
94
+ options?: AxiosRequestConfig
95
+ ): Promise<AxiosResponse<ProductsGetResponse>> => {
96
+ return axios.get(`/product`, options);
97
+ };
98
+
99
+ export const getAppApiProductGetQueryKey = () => [`/product`];
100
+
101
+ export type AppApiProductGetQueryResult = NonNullable<
102
+ AsyncReturnType<typeof appApiProductGet>
103
+ >;
104
+ export type AppApiProductGetQueryError = AxiosError<AsError | void>;
105
+
106
+ export const useAppApiProductGet = <
107
+ TData = AsyncReturnType<typeof appApiProductGet>,
108
+ TError = AxiosError<AsError | void>
109
+ >(options?: {
110
+ query?: UseQueryOptions<
111
+ AsyncReturnType<typeof appApiProductGet>,
112
+ TError,
113
+ TData
114
+ >;
115
+ axios?: AxiosRequestConfig;
116
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
117
+ const { query: queryOptions, axios: axiosOptions } = options || {};
118
+
119
+ const queryKey = queryOptions?.queryKey ?? getAppApiProductGetQueryKey();
120
+
121
+ const queryFn: QueryFunction<AsyncReturnType<typeof appApiProductGet>> = () =>
122
+ appApiProductGet(axiosOptions);
123
+
124
+ const query = useQuery<
125
+ AsyncReturnType<typeof appApiProductGet>,
126
+ TError,
127
+ TData
128
+ >(queryKey, queryFn, queryOptions);
129
+
130
+ return {
131
+ queryKey,
132
+ ...query,
43
133
  };
44
- /**
45
- * @summary Creates a Product for an Organisational Unit
46
- */
47
- const appApiProductPost = <TData = AxiosResponse<UnitProductPostResponse>>(
48
- unitId: string,
49
- unitProductPostBodyBody: UnitProductPostBodyBody,
50
- options?: AxiosRequestConfig
51
- ): Promise<TData> => {
52
- return axios.post(
53
- `/product/unit/${unitId}`,
54
- unitProductPostBodyBody,
55
- options
56
- );
134
+ };
135
+
136
+ /**
137
+ * @summary Creates a Product for an Organisational Unit
138
+ */
139
+ export const appApiProductPost = (
140
+ unitId: string,
141
+ unitProductPostBodyBody: UnitProductPostBodyBody,
142
+ options?: AxiosRequestConfig
143
+ ): Promise<AxiosResponse<UnitProductPostResponse>> => {
144
+ return axios.post(
145
+ `/product/unit/${unitId}`,
146
+ unitProductPostBodyBody,
147
+ options
148
+ );
149
+ };
150
+
151
+ export type AppApiProductPostMutationResult = NonNullable<
152
+ AsyncReturnType<typeof appApiProductPost>
153
+ >;
154
+ export type AppApiProductPostMutationBody = UnitProductPostBodyBody;
155
+ export type AppApiProductPostMutationError = AxiosError<AsError | void>;
156
+
157
+ export const useAppApiProductPost = <
158
+ TError = AxiosError<AsError | void>,
159
+ TContext = unknown
160
+ >(options?: {
161
+ mutation?: UseMutationOptions<
162
+ AsyncReturnType<typeof appApiProductPost>,
163
+ TError,
164
+ { unitId: string; data: UnitProductPostBodyBody },
165
+ TContext
166
+ >;
167
+ axios?: AxiosRequestConfig;
168
+ }) => {
169
+ const { mutation: mutationOptions, axios: axiosOptions } = options || {};
170
+
171
+ const mutationFn: MutationFunction<
172
+ AsyncReturnType<typeof appApiProductPost>,
173
+ { unitId: string; data: UnitProductPostBodyBody }
174
+ > = (props) => {
175
+ const { unitId, data } = props || {};
176
+
177
+ return appApiProductPost(unitId, data, axiosOptions);
57
178
  };
58
- /**
179
+
180
+ return useMutation<
181
+ AsyncReturnType<typeof appApiProductPost>,
182
+ TError,
183
+ { unitId: string; data: UnitProductPostBodyBody },
184
+ TContext
185
+ >(mutationFn, mutationOptions);
186
+ };
187
+ /**
59
188
  * Gets products you have access to based on an Organisational Unit
60
189
 
61
190
  * @summary Gets Products for an Organisational Unit
62
191
  */
63
- const appApiProductGetForUnit = <TData = AxiosResponse<ProductsGetResponse>>(
64
- unitId: string,
65
- options?: AxiosRequestConfig
66
- ): Promise<TData> => {
67
- return axios.get(`/product/unit/${unitId}`, options);
192
+ export const appApiProductGetForUnit = (
193
+ unitId: string,
194
+ options?: AxiosRequestConfig
195
+ ): Promise<AxiosResponse<ProductsGetResponse>> => {
196
+ return axios.get(`/product/unit/${unitId}`, options);
197
+ };
198
+
199
+ export const getAppApiProductGetForUnitQueryKey = (unitId: string) => [
200
+ `/product/unit/${unitId}`,
201
+ ];
202
+
203
+ export type AppApiProductGetForUnitQueryResult = NonNullable<
204
+ AsyncReturnType<typeof appApiProductGetForUnit>
205
+ >;
206
+ export type AppApiProductGetForUnitQueryError = AxiosError<void | AsError>;
207
+
208
+ export const useAppApiProductGetForUnit = <
209
+ TData = AsyncReturnType<typeof appApiProductGetForUnit>,
210
+ TError = AxiosError<void | AsError>
211
+ >(
212
+ unitId: string,
213
+ options?: {
214
+ query?: UseQueryOptions<
215
+ AsyncReturnType<typeof appApiProductGetForUnit>,
216
+ TError,
217
+ TData
218
+ >;
219
+ axios?: AxiosRequestConfig;
220
+ }
221
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
222
+ const { query: queryOptions, axios: axiosOptions } = options || {};
223
+
224
+ const queryKey =
225
+ queryOptions?.queryKey ?? getAppApiProductGetForUnitQueryKey(unitId);
226
+
227
+ const queryFn: QueryFunction<
228
+ AsyncReturnType<typeof appApiProductGetForUnit>
229
+ > = () => appApiProductGetForUnit(unitId, axiosOptions);
230
+
231
+ const query = useQuery<
232
+ AsyncReturnType<typeof appApiProductGetForUnit>,
233
+ TError,
234
+ TData
235
+ >(queryKey, queryFn, { enabled: !!unitId, ...queryOptions });
236
+
237
+ return {
238
+ queryKey,
239
+ ...query,
68
240
  };
69
- /**
241
+ };
242
+
243
+ /**
70
244
  * Gets a Unit's Product
71
245
 
72
246
  * @summary Gets a Unit's Product
73
247
  */
74
- const appApiProductGetUnitProduct = <
75
- TData = AxiosResponse<ProductUnitGetResponse>
76
- >(
77
- unitId: string,
78
- productId: string,
79
- options?: AxiosRequestConfig
80
- ): Promise<TData> => {
81
- return axios.get(`/product/unit/${unitId}/product/${productId}`, options);
248
+ export const appApiProductGetUnitProduct = (
249
+ unitId: string,
250
+ productId: string,
251
+ options?: AxiosRequestConfig
252
+ ): Promise<AxiosResponse<ProductUnitGetResponse>> => {
253
+ return axios.get(`/product/unit/${unitId}/product/${productId}`, options);
254
+ };
255
+
256
+ export const getAppApiProductGetUnitProductQueryKey = (
257
+ unitId: string,
258
+ productId: string
259
+ ) => [`/product/unit/${unitId}/product/${productId}`];
260
+
261
+ export type AppApiProductGetUnitProductQueryResult = NonNullable<
262
+ AsyncReturnType<typeof appApiProductGetUnitProduct>
263
+ >;
264
+ export type AppApiProductGetUnitProductQueryError = AxiosError<AsError | void>;
265
+
266
+ export const useAppApiProductGetUnitProduct = <
267
+ TData = AsyncReturnType<typeof appApiProductGetUnitProduct>,
268
+ TError = AxiosError<AsError | void>
269
+ >(
270
+ unitId: string,
271
+ productId: string,
272
+ options?: {
273
+ query?: UseQueryOptions<
274
+ AsyncReturnType<typeof appApiProductGetUnitProduct>,
275
+ TError,
276
+ TData
277
+ >;
278
+ axios?: AxiosRequestConfig;
279
+ }
280
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
281
+ const { query: queryOptions, axios: axiosOptions } = options || {};
282
+
283
+ const queryKey =
284
+ queryOptions?.queryKey ??
285
+ getAppApiProductGetUnitProductQueryKey(unitId, productId);
286
+
287
+ const queryFn: QueryFunction<
288
+ AsyncReturnType<typeof appApiProductGetUnitProduct>
289
+ > = () => appApiProductGetUnitProduct(unitId, productId, axiosOptions);
290
+
291
+ const query = useQuery<
292
+ AsyncReturnType<typeof appApiProductGetUnitProduct>,
293
+ TError,
294
+ TData
295
+ >(queryKey, queryFn, { enabled: !!(unitId && productId), ...queryOptions });
296
+
297
+ return {
298
+ queryKey,
299
+ ...query,
82
300
  };
83
- /**
84
- * @summary Deletes an existing Product
85
- */
86
- const appApiProductDelete = <TData = AxiosResponse<void>>(
87
- unitId: string,
88
- productId: string,
89
- options?: AxiosRequestConfig
90
- ): Promise<TData> => {
91
- return axios.delete(
92
- `/product/unit/${unitId}/product/${productId}`,
93
- options
94
- );
301
+ };
302
+
303
+ /**
304
+ * @summary Deletes an existing Product
305
+ */
306
+ export const appApiProductDelete = (
307
+ unitId: string,
308
+ productId: string,
309
+ options?: AxiosRequestConfig
310
+ ): Promise<AxiosResponse<void>> => {
311
+ return axios.delete(`/product/unit/${unitId}/product/${productId}`, options);
312
+ };
313
+
314
+ export type AppApiProductDeleteMutationResult = NonNullable<
315
+ AsyncReturnType<typeof appApiProductDelete>
316
+ >;
317
+
318
+ export type AppApiProductDeleteMutationError = AxiosError<AsError>;
319
+
320
+ export const useAppApiProductDelete = <
321
+ TError = AxiosError<AsError>,
322
+ TContext = unknown
323
+ >(options?: {
324
+ mutation?: UseMutationOptions<
325
+ AsyncReturnType<typeof appApiProductDelete>,
326
+ TError,
327
+ { unitId: string; productId: string },
328
+ TContext
329
+ >;
330
+ axios?: AxiosRequestConfig;
331
+ }) => {
332
+ const { mutation: mutationOptions, axios: axiosOptions } = options || {};
333
+
334
+ const mutationFn: MutationFunction<
335
+ AsyncReturnType<typeof appApiProductDelete>,
336
+ { unitId: string; productId: string }
337
+ > = (props) => {
338
+ const { unitId, productId } = props || {};
339
+
340
+ return appApiProductDelete(unitId, productId, axiosOptions);
95
341
  };
96
- /**
342
+
343
+ return useMutation<
344
+ AsyncReturnType<typeof appApiProductDelete>,
345
+ TError,
346
+ { unitId: string; productId: string },
347
+ TContext
348
+ >(mutationFn, mutationOptions);
349
+ };
350
+ /**
97
351
  * 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`
98
352
 
99
353
  * @summary Adjust an existing Product
100
354
  */
101
- const appApiProductPatch = <TData = AxiosResponse<void>>(
102
- unitId: string,
103
- productId: string,
104
- productPatchBodyBody: ProductPatchBodyBody,
105
- options?: AxiosRequestConfig
106
- ): Promise<TData> => {
107
- return axios.patch(
108
- `/product/unit/${unitId}/product/${productId}`,
109
- productPatchBodyBody,
110
- options
111
- );
112
- };
113
- return {
114
- appApiProductGetTypes,
115
- appApiProductGet,
116
- appApiProductPost,
117
- appApiProductGetForUnit,
118
- appApiProductGetUnitProduct,
119
- appApiProductDelete,
120
- appApiProductPatch,
355
+ export const appApiProductPatch = (
356
+ unitId: string,
357
+ productId: string,
358
+ productPatchBodyBody: ProductPatchBodyBody,
359
+ options?: AxiosRequestConfig
360
+ ): Promise<AxiosResponse<void>> => {
361
+ return axios.patch(
362
+ `/product/unit/${unitId}/product/${productId}`,
363
+ productPatchBodyBody,
364
+ options
365
+ );
366
+ };
367
+
368
+ export type AppApiProductPatchMutationResult = NonNullable<
369
+ AsyncReturnType<typeof appApiProductPatch>
370
+ >;
371
+ export type AppApiProductPatchMutationBody = ProductPatchBodyBody;
372
+ export type AppApiProductPatchMutationError = AxiosError<AsError>;
373
+
374
+ export const useAppApiProductPatch = <
375
+ TError = AxiosError<AsError>,
376
+ TContext = unknown
377
+ >(options?: {
378
+ mutation?: UseMutationOptions<
379
+ AsyncReturnType<typeof appApiProductPatch>,
380
+ TError,
381
+ { unitId: string; productId: string; data: ProductPatchBodyBody },
382
+ TContext
383
+ >;
384
+ axios?: AxiosRequestConfig;
385
+ }) => {
386
+ const { mutation: mutationOptions, axios: axiosOptions } = options || {};
387
+
388
+ const mutationFn: MutationFunction<
389
+ AsyncReturnType<typeof appApiProductPatch>,
390
+ { unitId: string; productId: string; data: ProductPatchBodyBody }
391
+ > = (props) => {
392
+ const { unitId, productId, data } = props || {};
393
+
394
+ return appApiProductPatch(unitId, productId, data, axiosOptions);
121
395
  };
396
+
397
+ return useMutation<
398
+ AsyncReturnType<typeof appApiProductPatch>,
399
+ TError,
400
+ { unitId: string; productId: string; data: ProductPatchBodyBody },
401
+ TContext
402
+ >(mutationFn, mutationOptions);
122
403
  };
123
- export type AppApiProductGetTypesResult =
124
- AxiosResponse<ProductsGetTypesResponse>;
125
- export type AppApiProductGetResult = AxiosResponse<ProductsGetResponse>;
126
- export type AppApiProductPostResult = AxiosResponse<UnitProductPostResponse>;
127
- export type AppApiProductGetForUnitResult = AxiosResponse<ProductsGetResponse>;
128
- export type AppApiProductGetUnitProductResult =
129
- AxiosResponse<ProductUnitGetResponse>;
130
- export type AppApiProductDeleteResult = AxiosResponse<void>;
131
- export type AppApiProductPatchResult = AxiosResponse<void>;
@@ -8,35 +8,127 @@ A service that provides access to the Account Server, which gives *registered* u
8
8
 
9
9
  * OpenAPI spec version: 0.1
10
10
  */
11
- import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
11
+ import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
12
+ import {
13
+ useQuery,
14
+ UseQueryOptions,
15
+ QueryFunction,
16
+ UseQueryResult,
17
+ QueryKey,
18
+ } from "react-query";
12
19
  import type {
13
20
  ServicesGetResponse,
21
+ AsError,
14
22
  ServiceGetResponse,
15
23
  } from "../account-server-api.schemas";
16
24
 
17
- export const getService = () => {
18
- /**
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
27
+ ...args: any
28
+ ) => Promise<infer R>
29
+ ? R
30
+ : any;
31
+
32
+ /**
19
33
  * Gets services known to the Account Server
20
34
 
21
35
  * @summary Gets all Services
22
36
  */
23
- const appApiServiceGet = <TData = AxiosResponse<ServicesGetResponse>>(
24
- options?: AxiosRequestConfig
25
- ): Promise<TData> => {
26
- return axios.get(`/service`, options);
37
+ export const appApiServiceGet = (
38
+ options?: AxiosRequestConfig
39
+ ): Promise<AxiosResponse<ServicesGetResponse>> => {
40
+ return axios.get(`/service`, options);
41
+ };
42
+
43
+ export const getAppApiServiceGetQueryKey = () => [`/service`];
44
+
45
+ export type AppApiServiceGetQueryResult = NonNullable<
46
+ AsyncReturnType<typeof appApiServiceGet>
47
+ >;
48
+ export type AppApiServiceGetQueryError = AxiosError<AsError | void>;
49
+
50
+ export const useAppApiServiceGet = <
51
+ TData = AsyncReturnType<typeof appApiServiceGet>,
52
+ TError = AxiosError<AsError | void>
53
+ >(options?: {
54
+ query?: UseQueryOptions<
55
+ AsyncReturnType<typeof appApiServiceGet>,
56
+ TError,
57
+ TData
58
+ >;
59
+ axios?: AxiosRequestConfig;
60
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
61
+ const { query: queryOptions, axios: axiosOptions } = options || {};
62
+
63
+ const queryKey = queryOptions?.queryKey ?? getAppApiServiceGetQueryKey();
64
+
65
+ const queryFn: QueryFunction<AsyncReturnType<typeof appApiServiceGet>> = () =>
66
+ appApiServiceGet(axiosOptions);
67
+
68
+ const query = useQuery<
69
+ AsyncReturnType<typeof appApiServiceGet>,
70
+ TError,
71
+ TData
72
+ >(queryKey, queryFn, queryOptions);
73
+
74
+ return {
75
+ queryKey,
76
+ ...query,
27
77
  };
28
- /**
78
+ };
79
+
80
+ /**
29
81
  * Gets a known service
30
82
 
31
83
  * @summary Gets a specific Service
32
84
  */
33
- const appApiServiceGetId = <TData = AxiosResponse<ServiceGetResponse>>(
34
- svcId: number,
35
- options?: AxiosRequestConfig
36
- ): Promise<TData> => {
37
- return axios.get(`/service/${svcId}`, options);
85
+ export const appApiServiceGetId = (
86
+ svcId: number,
87
+ options?: AxiosRequestConfig
88
+ ): Promise<AxiosResponse<ServiceGetResponse>> => {
89
+ return axios.get(`/service/${svcId}`, options);
90
+ };
91
+
92
+ export const getAppApiServiceGetIdQueryKey = (svcId: number) => [
93
+ `/service/${svcId}`,
94
+ ];
95
+
96
+ export type AppApiServiceGetIdQueryResult = NonNullable<
97
+ AsyncReturnType<typeof appApiServiceGetId>
98
+ >;
99
+ export type AppApiServiceGetIdQueryError = AxiosError<AsError | void>;
100
+
101
+ export const useAppApiServiceGetId = <
102
+ TData = AsyncReturnType<typeof appApiServiceGetId>,
103
+ TError = AxiosError<AsError | void>
104
+ >(
105
+ svcId: number,
106
+ options?: {
107
+ query?: UseQueryOptions<
108
+ AsyncReturnType<typeof appApiServiceGetId>,
109
+ TError,
110
+ TData
111
+ >;
112
+ axios?: AxiosRequestConfig;
113
+ }
114
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
115
+ const { query: queryOptions, axios: axiosOptions } = options || {};
116
+
117
+ const queryKey =
118
+ queryOptions?.queryKey ?? getAppApiServiceGetIdQueryKey(svcId);
119
+
120
+ const queryFn: QueryFunction<
121
+ AsyncReturnType<typeof appApiServiceGetId>
122
+ > = () => appApiServiceGetId(svcId, axiosOptions);
123
+
124
+ const query = useQuery<
125
+ AsyncReturnType<typeof appApiServiceGetId>,
126
+ TError,
127
+ TData
128
+ >(queryKey, queryFn, { enabled: !!svcId, ...queryOptions });
129
+
130
+ return {
131
+ queryKey,
132
+ ...query,
38
133
  };
39
- return { appApiServiceGet, appApiServiceGetId };
40
134
  };
41
- export type AppApiServiceGetResult = AxiosResponse<ServicesGetResponse>;
42
- export type AppApiServiceGetIdResult = AxiosResponse<ServiceGetResponse>;