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