@squonk/account-server-client 0.1.23-rc.2 → 0.1.26-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 (51) hide show
  1. package/{custom-instance-86dd5ce6.d.ts → account-server-api.schemas-078442c3.d.ts} +4 -22
  2. package/{chunk-JR7F532L.js → chunk-GWBPVOL2.js} +2 -23
  3. package/chunk-GWBPVOL2.js.map +1 -0
  4. package/chunk-N3RLW53G.cjs +25 -0
  5. package/chunk-N3RLW53G.cjs.map +1 -0
  6. package/index.cjs +21 -5
  7. package/index.cjs.map +1 -1
  8. package/index.d.ts +20 -2
  9. package/index.js +21 -5
  10. package/index.js.map +1 -1
  11. package/organisation/organisation.cjs +20 -65
  12. package/organisation/organisation.cjs.map +1 -1
  13. package/organisation/organisation.d.ts +18 -58
  14. package/organisation/organisation.js +20 -65
  15. package/organisation/organisation.js.map +1 -1
  16. package/package.json +14 -14
  17. package/product/product.cjs +32 -107
  18. package/product/product.cjs.map +1 -1
  19. package/product/product.d.ts +24 -84
  20. package/product/product.js +32 -107
  21. package/product/product.js.map +1 -1
  22. package/service/service.cjs +11 -38
  23. package/service/service.cjs.map +1 -1
  24. package/service/service.d.ts +9 -31
  25. package/service/service.js +11 -38
  26. package/service/service.js.map +1 -1
  27. package/src/account-server-api.schemas.ts +3 -3
  28. package/src/organisation/organisation.ts +43 -191
  29. package/src/product/product.ts +87 -294
  30. package/src/service/service.ts +17 -101
  31. package/src/state/state.ts +17 -66
  32. package/src/unit/unit.ts +71 -315
  33. package/src/user/user.ts +68 -330
  34. package/state/state.cjs +8 -22
  35. package/state/state.cjs.map +1 -1
  36. package/state/state.d.ts +7 -16
  37. package/state/state.js +8 -22
  38. package/state/state.js.map +1 -1
  39. package/unit/unit.cjs +30 -109
  40. package/unit/unit.cjs.map +1 -1
  41. package/unit/unit.d.ts +25 -92
  42. package/unit/unit.js +30 -109
  43. package/unit/unit.js.map +1 -1
  44. package/user/user.cjs +30 -107
  45. package/user/user.cjs.map +1 -1
  46. package/user/user.d.ts +20 -118
  47. package/user/user.js +30 -107
  48. package/user/user.js.map +1 -1
  49. package/chunk-3DXYUDZH.cjs +0 -46
  50. package/chunk-3DXYUDZH.cjs.map +0 -1
  51. package/chunk-JR7F532L.js.map +0 -1
package/src/unit/unit.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.6.0 🍺
2
+ * Generated by orval v6.7.1 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -8,362 +8,118 @@ 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 {
12
- useQuery,
13
- useMutation,
14
- UseQueryOptions,
15
- UseMutationOptions,
16
- QueryFunction,
17
- MutationFunction,
18
- UseQueryResult,
19
- QueryKey,
20
- } from "react-query";
11
+ import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
21
12
  import type {
22
13
  OrganisationUnitsGetResponse,
23
- AsError,
24
14
  OrganisationUnitPostResponse,
25
15
  OrganisationUnitPostBodyBody,
26
16
  UnitGetResponse,
27
17
  UnitsGetResponse,
28
18
  PersonalUnitPutResponse,
29
19
  } from "../account-server-api.schemas";
30
- import { customInstance, ErrorType } from ".././custom-instance";
31
20
 
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- type SecondParameter<T extends (...args: any) => any> = T extends (
41
- config: any,
42
- args: infer P
43
- ) => any
44
- ? P
45
- : never;
46
-
47
- /**
21
+ export const getUnit = () => {
22
+ /**
48
23
  * Gets Organisational Units you have access to
49
24
 
50
25
  * @summary Gets Organisational Units
51
26
  */
52
- export const getOrganisationUnits = (
53
- orgid: string,
54
- options?: SecondParameter<typeof customInstance>
55
- ) => {
56
- return customInstance<OrganisationUnitsGetResponse>(
57
- { url: `/organisation/${orgid}/unit`, method: "get" },
58
- options
59
- );
60
- };
61
-
62
- export const getGetOrganisationUnitsQueryKey = (orgid: string) => [
63
- `/organisation/${orgid}/unit`,
64
- ];
65
-
66
- export const useGetOrganisationUnits = <
67
- TData = AsyncReturnType<typeof getOrganisationUnits>,
68
- TError = ErrorType<void | AsError>
69
- >(
70
- orgid: string,
71
- options?: {
72
- query?: UseQueryOptions<
73
- AsyncReturnType<typeof getOrganisationUnits>,
74
- TError,
75
- TData
76
- >;
77
- request?: SecondParameter<typeof customInstance>;
78
- }
79
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
80
- const { query: queryOptions, request: requestOptions } = options || {};
81
-
82
- const queryKey =
83
- queryOptions?.queryKey ?? getGetOrganisationUnitsQueryKey(orgid);
84
-
85
- const queryFn: QueryFunction<
86
- AsyncReturnType<typeof getOrganisationUnits>
87
- > = () => getOrganisationUnits(orgid, requestOptions);
88
-
89
- const query = useQuery<
90
- AsyncReturnType<typeof getOrganisationUnits>,
91
- TError,
92
- TData
93
- >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });
94
-
95
- return {
96
- queryKey,
97
- ...query,
27
+ const appApiUnitGetOrgUnits = <
28
+ TData = AxiosResponse<OrganisationUnitsGetResponse>
29
+ >(
30
+ orgId: string,
31
+ options?: AxiosRequestConfig
32
+ ): Promise<TData> => {
33
+ return axios.get(`/organisation/${orgId}/unit`, options);
98
34
  };
99
- };
100
-
101
- /**
35
+ /**
102
36
  * Creates a new organisation unit. You need to be in the Organisation or an Admin user to use this endpoint
103
37
 
104
38
  * @summary Create a new Organisational Unit
105
39
  */
106
- export const createOrganisationUnit = (
107
- orgid: string,
108
- organisationUnitPostBodyBody: OrganisationUnitPostBodyBody,
109
- options?: SecondParameter<typeof customInstance>
110
- ) => {
111
- return customInstance<OrganisationUnitPostResponse>(
112
- {
113
- url: `/organisation/${orgid}/unit`,
114
- method: "post",
115
- data: organisationUnitPostBodyBody,
116
- },
117
- options
118
- );
119
- };
120
-
121
- export const useCreateOrganisationUnit = <
122
- TError = ErrorType<AsError | void>,
123
- TContext = unknown
124
- >(options?: {
125
- mutation?: UseMutationOptions<
126
- AsyncReturnType<typeof createOrganisationUnit>,
127
- TError,
128
- { orgid: string; data: OrganisationUnitPostBodyBody },
129
- TContext
130
- >;
131
- request?: SecondParameter<typeof customInstance>;
132
- }) => {
133
- const { mutation: mutationOptions, request: requestOptions } = options || {};
134
-
135
- const mutationFn: MutationFunction<
136
- AsyncReturnType<typeof createOrganisationUnit>,
137
- { orgid: string; data: OrganisationUnitPostBodyBody }
138
- > = (props) => {
139
- const { orgid, data } = props || {};
140
-
141
- return createOrganisationUnit(orgid, data, requestOptions);
40
+ const appApiUnitPost = <TData = AxiosResponse<OrganisationUnitPostResponse>>(
41
+ orgId: string,
42
+ organisationUnitPostBodyBody: OrganisationUnitPostBodyBody,
43
+ options?: AxiosRequestConfig
44
+ ): Promise<TData> => {
45
+ return axios.post(
46
+ `/organisation/${orgId}/unit`,
47
+ organisationUnitPostBodyBody,
48
+ options
49
+ );
142
50
  };
143
-
144
- return useMutation<
145
- AsyncReturnType<typeof createOrganisationUnit>,
146
- TError,
147
- { orgid: string; data: OrganisationUnitPostBodyBody },
148
- TContext
149
- >(mutationFn, mutationOptions);
150
- };
151
- /**
51
+ /**
152
52
  * Gets the Unit, assuming you are a member of it. Admin users can see all Units
153
53
 
154
54
  * @summary Gets a Unit
155
55
  */
156
- export const getUnit = (
157
- orgid: string,
158
- unitid: string,
159
- options?: SecondParameter<typeof customInstance>
160
- ) => {
161
- return customInstance<UnitGetResponse>(
162
- { url: `/organisation/${orgid}/unit/${unitid}`, method: "get" },
163
- options
164
- );
165
- };
166
-
167
- export const getGetUnitQueryKey = (orgid: string, unitid: string) => [
168
- `/organisation/${orgid}/unit/${unitid}`,
169
- ];
170
-
171
- export const useGetUnit = <
172
- TData = AsyncReturnType<typeof getUnit>,
173
- TError = ErrorType<void | AsError>
174
- >(
175
- orgid: string,
176
- unitid: string,
177
- options?: {
178
- query?: UseQueryOptions<AsyncReturnType<typeof getUnit>, TError, TData>;
179
- request?: SecondParameter<typeof customInstance>;
180
- }
181
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
182
- const { query: queryOptions, request: requestOptions } = options || {};
183
-
184
- const queryKey = queryOptions?.queryKey ?? getGetUnitQueryKey(orgid, unitid);
185
-
186
- const queryFn: QueryFunction<AsyncReturnType<typeof getUnit>> = () =>
187
- getUnit(orgid, unitid, requestOptions);
188
-
189
- const query = useQuery<AsyncReturnType<typeof getUnit>, TError, TData>(
190
- queryKey,
191
- queryFn,
192
- { enabled: !!(orgid && unitid), ...queryOptions }
193
- );
194
-
195
- return {
196
- queryKey,
197
- ...query,
56
+ const appApiUnitGetUnit = <TData = AxiosResponse<UnitGetResponse>>(
57
+ orgId: string,
58
+ unitId: string,
59
+ options?: AxiosRequestConfig
60
+ ): Promise<TData> => {
61
+ return axios.get(`/organisation/${orgId}/unit/${unitId}`, options);
198
62
  };
199
- };
200
-
201
- /**
63
+ /**
202
64
  * 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
203
65
 
204
66
  * @summary Deletes an Organisational Unit
205
67
  */
206
- export const deleteOrganisationUnit = (
207
- orgid: string,
208
- unitid: string,
209
- options?: SecondParameter<typeof customInstance>
210
- ) => {
211
- return customInstance<void>(
212
- { url: `/organisation/${orgid}/unit/${unitid}`, method: "delete" },
213
- options
214
- );
215
- };
216
-
217
- export const useDeleteOrganisationUnit = <
218
- TError = ErrorType<AsError>,
219
- TContext = unknown
220
- >(options?: {
221
- mutation?: UseMutationOptions<
222
- AsyncReturnType<typeof deleteOrganisationUnit>,
223
- TError,
224
- { orgid: string; unitid: string },
225
- TContext
226
- >;
227
- request?: SecondParameter<typeof customInstance>;
228
- }) => {
229
- const { mutation: mutationOptions, request: requestOptions } = options || {};
230
-
231
- const mutationFn: MutationFunction<
232
- AsyncReturnType<typeof deleteOrganisationUnit>,
233
- { orgid: string; unitid: string }
234
- > = (props) => {
235
- const { orgid, unitid } = props || {};
236
-
237
- return deleteOrganisationUnit(orgid, unitid, requestOptions);
68
+ const appApiUnitDelete = <TData = AxiosResponse<void>>(
69
+ orgId: string,
70
+ unitId: string,
71
+ options?: AxiosRequestConfig
72
+ ): Promise<TData> => {
73
+ return axios.delete(`/organisation/${orgId}/unit/${unitId}`, options);
238
74
  };
239
-
240
- return useMutation<
241
- AsyncReturnType<typeof deleteOrganisationUnit>,
242
- TError,
243
- { orgid: string; unitid: string },
244
- TContext
245
- >(mutationFn, mutationOptions);
246
- };
247
- /**
75
+ /**
248
76
  * Gets all the Units you are a member of. Admin users can see all Units
249
77
 
250
78
  * @summary Gets Units a User has access to
251
79
  */
252
- export const getUnits = (options?: SecondParameter<typeof customInstance>) => {
253
- return customInstance<UnitsGetResponse>(
254
- { url: `/unit`, method: "get" },
255
- options
256
- );
257
- };
258
-
259
- export const getGetUnitsQueryKey = () => [`/unit`];
260
-
261
- export const useGetUnits = <
262
- TData = AsyncReturnType<typeof getUnits>,
263
- TError = ErrorType<void | AsError>
264
- >(options?: {
265
- query?: UseQueryOptions<AsyncReturnType<typeof getUnits>, TError, TData>;
266
- request?: SecondParameter<typeof customInstance>;
267
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
268
- const { query: queryOptions, request: requestOptions } = options || {};
269
-
270
- const queryKey = queryOptions?.queryKey ?? getGetUnitsQueryKey();
271
-
272
- const queryFn: QueryFunction<AsyncReturnType<typeof getUnits>> = () =>
273
- getUnits(requestOptions);
274
-
275
- const query = useQuery<AsyncReturnType<typeof getUnits>, TError, TData>(
276
- queryKey,
277
- queryFn,
278
- queryOptions
279
- );
280
-
281
- return {
282
- queryKey,
283
- ...query,
80
+ const appApiUnitGet = <TData = AxiosResponse<UnitsGetResponse>>(
81
+ options?: AxiosRequestConfig
82
+ ): Promise<TData> => {
83
+ return axios.get(`/unit`, options);
284
84
  };
285
- };
286
-
287
- /**
85
+ /**
288
86
  * Creates a 'Personal' Unit for a User. The unit will belong to the built-in **Default** Organisation. Users can only have one Personal Unit and Personal Units cannot have other Users
289
87
 
290
88
  * @summary Create a new Independent User Unit
291
89
  */
292
- export const createDefaultUnit = (
293
- options?: SecondParameter<typeof customInstance>
294
- ) => {
295
- return customInstance<PersonalUnitPutResponse>(
296
- { url: `/unit`, method: "put" },
297
- options
298
- );
299
- };
300
-
301
- export const useCreateDefaultUnit = <
302
- TError = ErrorType<AsError | void>,
303
- TVariables = void,
304
- TContext = unknown
305
- >(options?: {
306
- mutation?: UseMutationOptions<
307
- AsyncReturnType<typeof createDefaultUnit>,
308
- TError,
309
- TVariables,
310
- TContext
311
- >;
312
- request?: SecondParameter<typeof customInstance>;
313
- }) => {
314
- const { mutation: mutationOptions, request: requestOptions } = options || {};
315
-
316
- const mutationFn: MutationFunction<
317
- AsyncReturnType<typeof createDefaultUnit>,
318
- TVariables
319
- > = () => {
320
- return createDefaultUnit(requestOptions);
90
+ const appApiUnitPersonalPut = <
91
+ TData = AxiosResponse<PersonalUnitPutResponse>
92
+ >(
93
+ options?: AxiosRequestConfig
94
+ ): Promise<TData> => {
95
+ return axios.put(`/unit`, undefined, options);
321
96
  };
322
-
323
- return useMutation<
324
- AsyncReturnType<typeof createDefaultUnit>,
325
- TError,
326
- TVariables,
327
- TContext
328
- >(mutationFn, mutationOptions);
329
- };
330
- /**
97
+ /**
331
98
  * Deletes a 'Personal' Unit. It must be your Unit, which belongs to the Default Organisation
332
99
 
333
100
  * @summary Deletes an Independent Unit
334
101
  */
335
- export const deleteDefaultUnit = (
336
- options?: SecondParameter<typeof customInstance>
337
- ) => {
338
- return customInstance<void>({ url: `/unit`, method: "delete" }, options);
339
- };
340
-
341
- export const useDeleteDefaultUnit = <
342
- TError = ErrorType<AsError>,
343
- TVariables = void,
344
- TContext = unknown
345
- >(options?: {
346
- mutation?: UseMutationOptions<
347
- AsyncReturnType<typeof deleteDefaultUnit>,
348
- TError,
349
- TVariables,
350
- TContext
351
- >;
352
- request?: SecondParameter<typeof customInstance>;
353
- }) => {
354
- const { mutation: mutationOptions, request: requestOptions } = options || {};
355
-
356
- const mutationFn: MutationFunction<
357
- AsyncReturnType<typeof deleteDefaultUnit>,
358
- TVariables
359
- > = () => {
360
- return deleteDefaultUnit(requestOptions);
102
+ const appApiUnitPersonalDelete = <TData = AxiosResponse<void>>(
103
+ options?: AxiosRequestConfig
104
+ ): Promise<TData> => {
105
+ return axios.delete(`/unit`, options);
106
+ };
107
+ return {
108
+ appApiUnitGetOrgUnits,
109
+ appApiUnitPost,
110
+ appApiUnitGetUnit,
111
+ appApiUnitDelete,
112
+ appApiUnitGet,
113
+ appApiUnitPersonalPut,
114
+ appApiUnitPersonalDelete,
361
115
  };
362
-
363
- return useMutation<
364
- AsyncReturnType<typeof deleteDefaultUnit>,
365
- TError,
366
- TVariables,
367
- TContext
368
- >(mutationFn, mutationOptions);
369
116
  };
117
+ export type AppApiUnitGetOrgUnitsResult =
118
+ AxiosResponse<OrganisationUnitsGetResponse>;
119
+ export type AppApiUnitPostResult = AxiosResponse<OrganisationUnitPostResponse>;
120
+ export type AppApiUnitGetUnitResult = AxiosResponse<UnitGetResponse>;
121
+ export type AppApiUnitDeleteResult = AxiosResponse<void>;
122
+ export type AppApiUnitGetResult = AxiosResponse<UnitsGetResponse>;
123
+ export type AppApiUnitPersonalPutResult =
124
+ AxiosResponse<PersonalUnitPutResponse>;
125
+ export type AppApiUnitPersonalDeleteResult = AxiosResponse<void>;