@squonk/account-server-client 0.1.26 → 0.1.28

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 (51) hide show
  1. package/{chunk-GWBPVOL2.js → chunk-6EEIAH4R.js} +23 -2
  2. package/chunk-6EEIAH4R.js.map +1 -0
  3. package/chunk-NGBTCJWS.cjs +46 -0
  4. package/chunk-NGBTCJWS.cjs.map +1 -0
  5. package/{account-server-api.schemas-078442c3.d.ts → custom-instance-13412a15.d.ts} +32 -1
  6. package/index.cjs +5 -21
  7. package/index.cjs.map +1 -1
  8. package/index.d.ts +2 -20
  9. package/index.js +5 -21
  10. package/index.js.map +1 -1
  11. package/organisation/organisation.cjs +70 -20
  12. package/organisation/organisation.cjs.map +1 -1
  13. package/organisation/organisation.d.ts +68 -18
  14. package/organisation/organisation.js +70 -20
  15. package/organisation/organisation.js.map +1 -1
  16. package/package.json +1 -1
  17. package/product/product.cjs +121 -31
  18. package/product/product.cjs.map +1 -1
  19. package/product/product.d.ts +115 -24
  20. package/product/product.js +121 -31
  21. package/product/product.js.map +1 -1
  22. package/service/service.cjs +38 -11
  23. package/service/service.cjs.map +1 -1
  24. package/service/service.d.ts +35 -8
  25. package/service/service.js +38 -11
  26. package/service/service.js.map +1 -1
  27. package/src/account-server-api.schemas.ts +13 -0
  28. package/src/organisation/organisation.ts +219 -44
  29. package/src/product/product.ts +375 -84
  30. package/src/service/service.ts +110 -16
  31. package/src/state/state.ts +70 -16
  32. package/src/unit/unit.ts +354 -74
  33. package/src/user/user.ts +368 -67
  34. package/state/state.cjs +22 -8
  35. package/state/state.cjs.map +1 -1
  36. package/state/state.d.ts +18 -6
  37. package/state/state.js +22 -8
  38. package/state/state.js.map +1 -1
  39. package/unit/unit.cjs +110 -30
  40. package/unit/unit.cjs.map +1 -1
  41. package/unit/unit.d.ts +108 -25
  42. package/unit/unit.js +110 -30
  43. package/unit/unit.js.map +1 -1
  44. package/user/user.cjs +107 -30
  45. package/user/user.cjs.map +1 -1
  46. package/user/user.d.ts +133 -20
  47. package/user/user.js +107 -30
  48. package/user/user.js.map +1 -1
  49. package/chunk-GWBPVOL2.js.map +0 -1
  50. package/chunk-N3RLW53G.cjs +0 -25
  51. package/chunk-N3RLW53G.cjs.map +0 -1
package/src/user/user.ts CHANGED
@@ -8,74 +8,312 @@ 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 {
12
+ useQuery,
13
+ useMutation,
14
+ UseQueryOptions,
15
+ UseMutationOptions,
16
+ QueryFunction,
17
+ MutationFunction,
18
+ UseQueryResult,
19
+ QueryKey,
20
+ } from "react-query";
12
21
  import type {
13
22
  UserAccountGetResponse,
23
+ AsError,
14
24
  UsersGetResponse,
15
25
  } from "../account-server-api.schemas";
26
+ import { customInstance, ErrorType } from ".././custom-instance";
16
27
 
17
- export const getUser = () => {
18
- /**
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
30
+ ...args: any
31
+ ) => Promise<infer R>
32
+ ? R
33
+ : any;
34
+
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ type SecondParameter<T extends (...args: any) => any> = T extends (
37
+ config: any,
38
+ args: infer P
39
+ ) => any
40
+ ? P
41
+ : never;
42
+
43
+ /**
19
44
  * Returns a summary of your account
20
45
 
21
46
  * @summary Get information about your account
22
47
  */
23
- const appApiUserGetAccount = <TData = AxiosResponse<UserAccountGetResponse>>(
24
- options?: AxiosRequestConfig
25
- ): Promise<TData> => {
26
- return axios.get(`/user/account`, options);
48
+ export const getUserAccount = (
49
+ options?: SecondParameter<typeof customInstance>
50
+ ) => {
51
+ return customInstance<UserAccountGetResponse>(
52
+ { url: `/user/account`, method: "get" },
53
+ options
54
+ );
55
+ };
56
+
57
+ export const getGetUserAccountQueryKey = () => [`/user/account`];
58
+
59
+ export type GetUserAccountQueryResult = NonNullable<
60
+ AsyncReturnType<typeof getUserAccount>
61
+ >;
62
+ export type GetUserAccountQueryError = ErrorType<void | AsError>;
63
+
64
+ export const useGetUserAccount = <
65
+ TData = AsyncReturnType<typeof getUserAccount>,
66
+ TError = ErrorType<void | AsError>
67
+ >(options?: {
68
+ query?: UseQueryOptions<
69
+ AsyncReturnType<typeof getUserAccount>,
70
+ TError,
71
+ TData
72
+ >;
73
+ request?: SecondParameter<typeof customInstance>;
74
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
75
+ const { query: queryOptions, request: requestOptions } = options || {};
76
+
77
+ const queryKey = queryOptions?.queryKey ?? getGetUserAccountQueryKey();
78
+
79
+ const queryFn: QueryFunction<AsyncReturnType<typeof getUserAccount>> = () =>
80
+ getUserAccount(requestOptions);
81
+
82
+ const query = useQuery<AsyncReturnType<typeof getUserAccount>, TError, TData>(
83
+ queryKey,
84
+ queryFn,
85
+ queryOptions
86
+ );
87
+
88
+ return {
89
+ queryKey,
90
+ ...query,
27
91
  };
28
- /**
92
+ };
93
+
94
+ /**
29
95
  * Gets users in an Organisation. You have to be in the Organisation or an Admin user to use this endpoint
30
96
 
31
97
  * @summary Gets users in an organisation
32
98
  */
33
- const appApiUserOrgGetUsers = <TData = AxiosResponse<UsersGetResponse>>(
34
- orgId: string,
35
- options?: AxiosRequestConfig
36
- ): Promise<TData> => {
37
- return axios.get(`/organisation/${orgId}/user`, options);
99
+ export const getOrganisationUsers = (
100
+ orgId: string,
101
+ options?: SecondParameter<typeof customInstance>
102
+ ) => {
103
+ return customInstance<UsersGetResponse>(
104
+ { url: `/organisation/${orgId}/user`, method: "get" },
105
+ options
106
+ );
107
+ };
108
+
109
+ export const getGetOrganisationUsersQueryKey = (orgId: string) => [
110
+ `/organisation/${orgId}/user`,
111
+ ];
112
+
113
+ export type GetOrganisationUsersQueryResult = NonNullable<
114
+ AsyncReturnType<typeof getOrganisationUsers>
115
+ >;
116
+ export type GetOrganisationUsersQueryError = ErrorType<AsError | void>;
117
+
118
+ export const useGetOrganisationUsers = <
119
+ TData = AsyncReturnType<typeof getOrganisationUsers>,
120
+ TError = ErrorType<AsError | void>
121
+ >(
122
+ orgId: string,
123
+ options?: {
124
+ query?: UseQueryOptions<
125
+ AsyncReturnType<typeof getOrganisationUsers>,
126
+ TError,
127
+ TData
128
+ >;
129
+ request?: SecondParameter<typeof customInstance>;
130
+ }
131
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
132
+ const { query: queryOptions, request: requestOptions } = options || {};
133
+
134
+ const queryKey =
135
+ queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgId);
136
+
137
+ const queryFn: QueryFunction<
138
+ AsyncReturnType<typeof getOrganisationUsers>
139
+ > = () => getOrganisationUsers(orgId, requestOptions);
140
+
141
+ const query = useQuery<
142
+ AsyncReturnType<typeof getOrganisationUsers>,
143
+ TError,
144
+ TData
145
+ >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions });
146
+
147
+ return {
148
+ queryKey,
149
+ ...query,
38
150
  };
39
- /**
151
+ };
152
+
153
+ /**
40
154
  * Adds a user to an organisation. You have to be in the Organisation or an Admin user to use this endpoint
41
155
 
42
156
  * @summary Adds a user to an organisation
43
157
  */
44
- const appApiUserOrgUserPut = <TData = AxiosResponse<void>>(
45
- orgId: string,
46
- userId: string,
47
- options?: AxiosRequestConfig
48
- ): Promise<TData> => {
49
- return axios.put(
50
- `/organisation/${orgId}/user/${userId}`,
51
- undefined,
52
- options
53
- );
158
+ export const addOrganisationUser = (
159
+ orgId: string,
160
+ userId: string,
161
+ options?: SecondParameter<typeof customInstance>
162
+ ) => {
163
+ return customInstance<void>(
164
+ { url: `/organisation/${orgId}/user/${userId}`, method: "put" },
165
+ options
166
+ );
167
+ };
168
+
169
+ export type AddOrganisationUserMutationResult = NonNullable<
170
+ AsyncReturnType<typeof addOrganisationUser>
171
+ >;
172
+
173
+ export type AddOrganisationUserMutationError = ErrorType<AsError>;
174
+
175
+ export const useAddOrganisationUser = <
176
+ TError = ErrorType<AsError>,
177
+ TContext = unknown
178
+ >(options?: {
179
+ mutation?: UseMutationOptions<
180
+ AsyncReturnType<typeof addOrganisationUser>,
181
+ TError,
182
+ { orgId: string; userId: string },
183
+ TContext
184
+ >;
185
+ request?: SecondParameter<typeof customInstance>;
186
+ }) => {
187
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
188
+
189
+ const mutationFn: MutationFunction<
190
+ AsyncReturnType<typeof addOrganisationUser>,
191
+ { orgId: string; userId: string }
192
+ > = (props) => {
193
+ const { orgId, userId } = props || {};
194
+
195
+ return addOrganisationUser(orgId, userId, requestOptions);
54
196
  };
55
- /**
197
+
198
+ return useMutation<
199
+ AsyncReturnType<typeof addOrganisationUser>,
200
+ TError,
201
+ { orgId: string; userId: string },
202
+ TContext
203
+ >(mutationFn, mutationOptions);
204
+ };
205
+ /**
56
206
  * Removes a user from an organisation. You have to be in the Organisation or an Admin user to use this endpoint
57
207
 
58
208
  * @summary Deletes a user from an organisation
59
209
  */
60
- const appApiUserOrgUserDelete = <TData = AxiosResponse<void>>(
61
- orgId: string,
62
- userId: string,
63
- options?: AxiosRequestConfig
64
- ): Promise<TData> => {
65
- return axios.delete(`/organisation/${orgId}/user/${userId}`, options);
210
+ export const deleteOrganisationUser = (
211
+ orgId: string,
212
+ userId: string,
213
+ options?: SecondParameter<typeof customInstance>
214
+ ) => {
215
+ return customInstance<void>(
216
+ { url: `/organisation/${orgId}/user/${userId}`, method: "delete" },
217
+ options
218
+ );
219
+ };
220
+
221
+ export type DeleteOrganisationUserMutationResult = NonNullable<
222
+ AsyncReturnType<typeof deleteOrganisationUser>
223
+ >;
224
+
225
+ export type DeleteOrganisationUserMutationError = ErrorType<AsError>;
226
+
227
+ export const useDeleteOrganisationUser = <
228
+ TError = ErrorType<AsError>,
229
+ TContext = unknown
230
+ >(options?: {
231
+ mutation?: UseMutationOptions<
232
+ AsyncReturnType<typeof deleteOrganisationUser>,
233
+ TError,
234
+ { orgId: string; userId: string },
235
+ TContext
236
+ >;
237
+ request?: SecondParameter<typeof customInstance>;
238
+ }) => {
239
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
240
+
241
+ const mutationFn: MutationFunction<
242
+ AsyncReturnType<typeof deleteOrganisationUser>,
243
+ { orgId: string; userId: string }
244
+ > = (props) => {
245
+ const { orgId, userId } = props || {};
246
+
247
+ return deleteOrganisationUser(orgId, userId, requestOptions);
66
248
  };
67
- /**
249
+
250
+ return useMutation<
251
+ AsyncReturnType<typeof deleteOrganisationUser>,
252
+ TError,
253
+ { orgId: string; userId: string },
254
+ TContext
255
+ >(mutationFn, mutationOptions);
256
+ };
257
+ /**
68
258
  * Gets users in an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint
69
259
 
70
260
  * @summary Gets users in an Organisational Unit
71
261
  */
72
- const appApiUserGetUnitUsers = <TData = AxiosResponse<UsersGetResponse>>(
73
- unitId: string,
74
- options?: AxiosRequestConfig
75
- ): Promise<TData> => {
76
- return axios.get(`/unit/${unitId}/user`, options);
262
+ export const getOrganisationUnitUsers = (
263
+ unitId: string,
264
+ options?: SecondParameter<typeof customInstance>
265
+ ) => {
266
+ return customInstance<UsersGetResponse>(
267
+ { url: `/unit/${unitId}/user`, method: "get" },
268
+ options
269
+ );
270
+ };
271
+
272
+ export const getGetOrganisationUnitUsersQueryKey = (unitId: string) => [
273
+ `/unit/${unitId}/user`,
274
+ ];
275
+
276
+ export type GetOrganisationUnitUsersQueryResult = NonNullable<
277
+ AsyncReturnType<typeof getOrganisationUnitUsers>
278
+ >;
279
+ export type GetOrganisationUnitUsersQueryError = ErrorType<AsError | void>;
280
+
281
+ export const useGetOrganisationUnitUsers = <
282
+ TData = AsyncReturnType<typeof getOrganisationUnitUsers>,
283
+ TError = ErrorType<AsError | void>
284
+ >(
285
+ unitId: string,
286
+ options?: {
287
+ query?: UseQueryOptions<
288
+ AsyncReturnType<typeof getOrganisationUnitUsers>,
289
+ TError,
290
+ TData
291
+ >;
292
+ request?: SecondParameter<typeof customInstance>;
293
+ }
294
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
295
+ const { query: queryOptions, request: requestOptions } = options || {};
296
+
297
+ const queryKey =
298
+ queryOptions?.queryKey ?? getGetOrganisationUnitUsersQueryKey(unitId);
299
+
300
+ const queryFn: QueryFunction<
301
+ AsyncReturnType<typeof getOrganisationUnitUsers>
302
+ > = () => getOrganisationUnitUsers(unitId, requestOptions);
303
+
304
+ const query = useQuery<
305
+ AsyncReturnType<typeof getOrganisationUnitUsers>,
306
+ TError,
307
+ TData
308
+ >(queryKey, queryFn, { enabled: !!unitId, ...queryOptions });
309
+
310
+ return {
311
+ queryKey,
312
+ ...query,
77
313
  };
78
- /**
314
+ };
315
+
316
+ /**
79
317
  * Adds a user to an Organisational Unit.
80
318
 
81
319
  Users cannot be added to **Independent Units** (Units that are part of the ***Default** Organisation).
@@ -84,14 +322,54 @@ You have to be in the Organisation or Unit or an Admin user to use this endpoint
84
322
 
85
323
  * @summary Adds a user to an Organisational Unit
86
324
  */
87
- const appApiUserUnitUserPut = <TData = AxiosResponse<void>>(
88
- unitId: string,
89
- userId: string,
90
- options?: AxiosRequestConfig
91
- ): Promise<TData> => {
92
- return axios.put(`/unit/${unitId}/user/${userId}`, undefined, options);
325
+ export const addOrganisationUnitUser = (
326
+ unitId: string,
327
+ userId: string,
328
+ options?: SecondParameter<typeof customInstance>
329
+ ) => {
330
+ return customInstance<void>(
331
+ { url: `/unit/${unitId}/user/${userId}`, method: "put" },
332
+ options
333
+ );
334
+ };
335
+
336
+ export type AddOrganisationUnitUserMutationResult = NonNullable<
337
+ AsyncReturnType<typeof addOrganisationUnitUser>
338
+ >;
339
+
340
+ export type AddOrganisationUnitUserMutationError = ErrorType<AsError>;
341
+
342
+ export const useAddOrganisationUnitUser = <
343
+ TError = ErrorType<AsError>,
344
+ TContext = unknown
345
+ >(options?: {
346
+ mutation?: UseMutationOptions<
347
+ AsyncReturnType<typeof addOrganisationUnitUser>,
348
+ TError,
349
+ { unitId: string; userId: string },
350
+ TContext
351
+ >;
352
+ request?: SecondParameter<typeof customInstance>;
353
+ }) => {
354
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
355
+
356
+ const mutationFn: MutationFunction<
357
+ AsyncReturnType<typeof addOrganisationUnitUser>,
358
+ { unitId: string; userId: string }
359
+ > = (props) => {
360
+ const { unitId, userId } = props || {};
361
+
362
+ return addOrganisationUnitUser(unitId, userId, requestOptions);
93
363
  };
94
- /**
364
+
365
+ return useMutation<
366
+ AsyncReturnType<typeof addOrganisationUnitUser>,
367
+ TError,
368
+ { unitId: string; userId: string },
369
+ TContext
370
+ >(mutationFn, mutationOptions);
371
+ };
372
+ /**
95
373
  * Removes a user from an Organisational Unit.
96
374
 
97
375
  Users cannot be removed from **Independent Units** (Units that are part of the ***Default** Organisation).
@@ -100,27 +378,50 @@ You have to be in the Organisation or Unit or an Admin user to use this endpoint
100
378
 
101
379
  * @summary Deletes a user from an Organisational Unit
102
380
  */
103
- const appApiUserUnitUserDelete = <TData = AxiosResponse<void>>(
104
- unitId: string,
105
- userId: string,
106
- options?: AxiosRequestConfig
107
- ): Promise<TData> => {
108
- return axios.delete(`/unit/${unitId}/user/${userId}`, options);
109
- };
110
- return {
111
- appApiUserGetAccount,
112
- appApiUserOrgGetUsers,
113
- appApiUserOrgUserPut,
114
- appApiUserOrgUserDelete,
115
- appApiUserGetUnitUsers,
116
- appApiUserUnitUserPut,
117
- appApiUserUnitUserDelete,
381
+ export const deleteOrganisationUnitUser = (
382
+ unitId: string,
383
+ userId: string,
384
+ options?: SecondParameter<typeof customInstance>
385
+ ) => {
386
+ return customInstance<void>(
387
+ { url: `/unit/${unitId}/user/${userId}`, method: "delete" },
388
+ options
389
+ );
390
+ };
391
+
392
+ export type DeleteOrganisationUnitUserMutationResult = NonNullable<
393
+ AsyncReturnType<typeof deleteOrganisationUnitUser>
394
+ >;
395
+
396
+ export type DeleteOrganisationUnitUserMutationError = ErrorType<AsError>;
397
+
398
+ export const useDeleteOrganisationUnitUser = <
399
+ TError = ErrorType<AsError>,
400
+ TContext = unknown
401
+ >(options?: {
402
+ mutation?: UseMutationOptions<
403
+ AsyncReturnType<typeof deleteOrganisationUnitUser>,
404
+ TError,
405
+ { unitId: string; userId: string },
406
+ TContext
407
+ >;
408
+ request?: SecondParameter<typeof customInstance>;
409
+ }) => {
410
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
411
+
412
+ const mutationFn: MutationFunction<
413
+ AsyncReturnType<typeof deleteOrganisationUnitUser>,
414
+ { unitId: string; userId: string }
415
+ > = (props) => {
416
+ const { unitId, userId } = props || {};
417
+
418
+ return deleteOrganisationUnitUser(unitId, userId, requestOptions);
118
419
  };
420
+
421
+ return useMutation<
422
+ AsyncReturnType<typeof deleteOrganisationUnitUser>,
423
+ TError,
424
+ { unitId: string; userId: string },
425
+ TContext
426
+ >(mutationFn, mutationOptions);
119
427
  };
120
- export type AppApiUserGetAccountResult = AxiosResponse<UserAccountGetResponse>;
121
- export type AppApiUserOrgGetUsersResult = AxiosResponse<UsersGetResponse>;
122
- export type AppApiUserOrgUserPutResult = AxiosResponse<void>;
123
- export type AppApiUserOrgUserDeleteResult = AxiosResponse<void>;
124
- export type AppApiUserGetUnitUsersResult = AxiosResponse<UsersGetResponse>;
125
- export type AppApiUserUnitUserPutResult = AxiosResponse<void>;
126
- export type AppApiUserUnitUserDeleteResult = AxiosResponse<void>;
package/state/state.cjs CHANGED
@@ -1,14 +1,28 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('../chunk-N3RLW53G.cjs');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+ var _chunkNGBTCJWScjs = require('../chunk-NGBTCJWS.cjs');
2
5
 
3
6
  // src/state/state.ts
4
- var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
5
- var getState = () => {
6
- const appApiStateGetVersion = (options) => {
7
- return _axios2.default.get(`/version`, options);
8
- };
9
- return { appApiStateGetVersion };
7
+
8
+
9
+ var _reactquery = require('react-query');
10
+ var getVersion = (options) => {
11
+ return _chunkNGBTCJWScjs.customInstance.call(void 0, { url: `/version`, method: "get" }, options);
10
12
  };
13
+ var getGetVersionQueryKey = () => [`/version`];
14
+ var useGetVersion = (options) => {
15
+ const { query: queryOptions, request: requestOptions } = options || {};
16
+ const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetVersionQueryKey()));
17
+ const queryFn = () => getVersion(requestOptions);
18
+ const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, queryOptions);
19
+ return _chunkNGBTCJWScjs.__spreadValues.call(void 0, {
20
+ queryKey
21
+ }, query);
22
+ };
23
+
24
+
11
25
 
12
26
 
13
- exports.getState = getState;
27
+ exports.getGetVersionQueryKey = getGetVersionQueryKey; exports.getVersion = getVersion; exports.useGetVersion = useGetVersion;
14
28
  //# sourceMappingURL=state.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/state/state.ts"],"names":[],"mappings":";;;AAUA;AAGO,IAAM,WAAW,MAAM;AAI5B,QAAM,wBAAwB,CAG5B,YACmB;AACnB,WAAO,MAAM,IAAI,YAAY,OAAO;AAAA,EACtC;AACA,SAAO,EAAE,sBAAsB;AACjC","sourcesContent":["/**\n * Generated by orval v6.7.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport axios, { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport type { StateGetVersionResponse } from \"../account-server-api.schemas\";\n\nexport const getState = () => {\n /**\n * @summary Gets the Account Server version\n */\n const appApiStateGetVersion = <\n TData = AxiosResponse<StateGetVersionResponse>\n >(\n options?: AxiosRequestConfig\n ): Promise<TData> => {\n return axios.get(`/version`, options);\n };\n return { appApiStateGetVersion };\n};\nexport type AppApiStateGetVersionResult =\n AxiosResponse<StateGetVersionResponse>;\n"]}
1
+ {"version":3,"sources":["../../src/state/state.ts"],"names":[],"mappings":";;;;;;AAUA;AAAA;AAAA;AA+BO,IAAM,aAAa,CACxB,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,QAAQ,MAAM,GACjC,OACF;AACF;AAEO,IAAM,wBAAwB,MAAM,CAAC,UAAU;AAO/C,IAAM,gBAAgB,CAG3B,YAG4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW,CAAC;AAErE,QAAM,WAAW,8CAAc,aAAY,sBAAsB;AAEjE,QAAM,UAA6D,MACjE,WAAW,cAAc;AAE3B,QAAM,QAAQ,SACZ,UACA,SACA,YACF;AAEA,SAAO;AAAA,IACL;AAAA,KACG;AAEP","sourcesContent":["/**\n * Generated by orval v6.7.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n StateGetVersionResponse,\n AsError,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * @summary Gets the Account Server version\n */\nexport const getVersion = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<StateGetVersionResponse>(\n { url: `/version`, method: \"get\" },\n options\n );\n};\n\nexport const getGetVersionQueryKey = () => [`/version`];\n\nexport type GetVersionQueryResult = NonNullable<\n AsyncReturnType<typeof getVersion>\n>;\nexport type GetVersionQueryError = ErrorType<AsError | void>;\n\nexport const useGetVersion = <\n TData = AsyncReturnType<typeof getVersion>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getVersion>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getVersion>> = () =>\n getVersion(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getVersion>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n"]}
package/state/state.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
2
- import { M as StateGetVersionResponse } from '../account-server-api.schemas-078442c3.js';
1
+ import { UseQueryOptions, QueryKey, UseQueryResult } from 'react-query';
2
+ import { V as customInstance, M as StateGetVersionResponse, W as ErrorType, N as AsError } from '../custom-instance-13412a15.js';
3
+ import 'axios';
3
4
 
4
5
  /**
5
6
  * Generated by orval v6.7.1 🍺
@@ -12,9 +13,20 @@ A service that provides access to the Account Server, which gives *registered* u
12
13
  * OpenAPI spec version: 0.1
13
14
  */
14
15
 
15
- declare const getState: () => {
16
- appApiStateGetVersion: <TData = AxiosResponse<StateGetVersionResponse, any>>(options?: AxiosRequestConfig<any> | undefined) => Promise<TData>;
16
+ declare type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
17
+ declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
18
+ /**
19
+ * @summary Gets the Account Server version
20
+ */
21
+ declare const getVersion: (options?: SecondParameter<typeof customInstance>) => Promise<StateGetVersionResponse>;
22
+ declare const getGetVersionQueryKey: () => string[];
23
+ declare type GetVersionQueryResult = NonNullable<AsyncReturnType<typeof getVersion>>;
24
+ declare type GetVersionQueryError = ErrorType<AsError | void>;
25
+ declare const useGetVersion: <TData = StateGetVersionResponse, TError = ErrorType<void | AsError>>(options?: {
26
+ query?: UseQueryOptions<StateGetVersionResponse, TError, TData, QueryKey> | undefined;
27
+ request?: SecondParameter<typeof customInstance>;
28
+ } | undefined) => UseQueryResult<TData, TError> & {
29
+ queryKey: QueryKey;
17
30
  };
18
- declare type AppApiStateGetVersionResult = AxiosResponse<StateGetVersionResponse>;
19
31
 
20
- export { AppApiStateGetVersionResult, getState };
32
+ export { GetVersionQueryError, GetVersionQueryResult, getGetVersionQueryKey, getVersion, useGetVersion };
package/state/state.js CHANGED
@@ -1,14 +1,28 @@
1
- import "../chunk-GWBPVOL2.js";
1
+ import {
2
+ __spreadValues,
3
+ customInstance
4
+ } from "../chunk-6EEIAH4R.js";
2
5
 
3
6
  // src/state/state.ts
4
- import axios from "axios";
5
- var getState = () => {
6
- const appApiStateGetVersion = (options) => {
7
- return axios.get(`/version`, options);
8
- };
9
- return { appApiStateGetVersion };
7
+ import {
8
+ useQuery
9
+ } from "react-query";
10
+ var getVersion = (options) => {
11
+ return customInstance({ url: `/version`, method: "get" }, options);
12
+ };
13
+ var getGetVersionQueryKey = () => [`/version`];
14
+ var useGetVersion = (options) => {
15
+ const { query: queryOptions, request: requestOptions } = options || {};
16
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetVersionQueryKey();
17
+ const queryFn = () => getVersion(requestOptions);
18
+ const query = useQuery(queryKey, queryFn, queryOptions);
19
+ return __spreadValues({
20
+ queryKey
21
+ }, query);
10
22
  };
11
23
  export {
12
- getState
24
+ getGetVersionQueryKey,
25
+ getVersion,
26
+ useGetVersion
13
27
  };
14
28
  //# sourceMappingURL=state.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/state/state.ts"],"sourcesContent":["/**\n * Generated by orval v6.7.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport axios, { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport type { StateGetVersionResponse } from \"../account-server-api.schemas\";\n\nexport const getState = () => {\n /**\n * @summary Gets the Account Server version\n */\n const appApiStateGetVersion = <\n TData = AxiosResponse<StateGetVersionResponse>\n >(\n options?: AxiosRequestConfig\n ): Promise<TData> => {\n return axios.get(`/version`, options);\n };\n return { appApiStateGetVersion };\n};\nexport type AppApiStateGetVersionResult =\n AxiosResponse<StateGetVersionResponse>;\n"],"mappings":";;;AAUA;AAGO,IAAM,WAAW,MAAM;AAI5B,QAAM,wBAAwB,CAG5B,YACmB;AACnB,WAAO,MAAM,IAAI,YAAY,OAAO;AAAA,EACtC;AACA,SAAO,EAAE,sBAAsB;AACjC;","names":[]}
1
+ {"version":3,"sources":["../../src/state/state.ts"],"sourcesContent":["/**\n * Generated by orval v6.7.1 🍺\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n StateGetVersionResponse,\n AsError,\n} from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * @summary Gets the Account Server version\n */\nexport const getVersion = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<StateGetVersionResponse>(\n { url: `/version`, method: \"get\" },\n options\n );\n};\n\nexport const getGetVersionQueryKey = () => [`/version`];\n\nexport type GetVersionQueryResult = NonNullable<\n AsyncReturnType<typeof getVersion>\n>;\nexport type GetVersionQueryError = ErrorType<AsError | void>;\n\nexport const useGetVersion = <\n TData = AsyncReturnType<typeof getVersion>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getVersion>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getVersion>> = () =>\n getVersion(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getVersion>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n"],"mappings":";;;;;;AAUA;AAAA;AAAA;AA+BO,IAAM,aAAa,CACxB,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,QAAQ,MAAM,GACjC,OACF;AACF;AAEO,IAAM,wBAAwB,MAAM,CAAC,UAAU;AAO/C,IAAM,gBAAgB,CAG3B,YAG4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW,CAAC;AAErE,QAAM,WAAW,8CAAc,aAAY,sBAAsB;AAEjE,QAAM,UAA6D,MACjE,WAAW,cAAc;AAE3B,QAAM,QAAQ,SACZ,UACA,SACA,YACF;AAEA,SAAO;AAAA,IACL;AAAA,KACG;AAEP;","names":[]}