@squonk/account-server-client 1.0.2-rc.3 → 1.0.3-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/asset/asset.cjs +34 -18
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.ts +16 -16
- package/asset/asset.js +35 -19
- package/asset/asset.js.map +1 -1
- package/{custom-instance-b8075093.d.ts → custom-instance-93fb01eb.d.ts} +22 -20
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +15 -13
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.ts +1 -1
- package/merchant/merchant.js +16 -14
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +18 -6
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +7 -7
- package/organisation/organisation.js +19 -7
- package/organisation/organisation.js.map +1 -1
- package/package.json +1 -1
- package/product/product.cjs +47 -38
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +10 -10
- package/product/product.js +48 -39
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +73 -87
- package/src/asset/asset.ts +248 -345
- package/src/merchant/merchant.ts +62 -84
- package/src/organisation/organisation.ts +131 -184
- package/src/product/product.ts +279 -422
- package/src/state/state.ts +36 -42
- package/src/unit/unit.ts +218 -301
- package/src/user/user.ts +224 -327
- package/state/state.cjs +9 -9
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +1 -1
- package/state/state.js +10 -10
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +40 -25
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +10 -10
- package/unit/unit.js +41 -26
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +38 -20
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +10 -10
- package/user/user.js +39 -21
- package/user/user.js.map +1 -1
package/src/user/user.ts
CHANGED
|
@@ -8,27 +8,31 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 1.0
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useQuery,
|
|
13
|
+
useMutation
|
|
14
|
+
} from 'react-query'
|
|
12
15
|
import type {
|
|
13
16
|
UseQueryOptions,
|
|
14
17
|
UseMutationOptions,
|
|
15
18
|
QueryFunction,
|
|
16
19
|
MutationFunction,
|
|
17
20
|
UseQueryResult,
|
|
18
|
-
QueryKey
|
|
19
|
-
} from
|
|
21
|
+
QueryKey
|
|
22
|
+
} from 'react-query'
|
|
20
23
|
import type {
|
|
21
24
|
UserAccountGetResponse,
|
|
22
25
|
AsError,
|
|
23
|
-
UsersGetResponse
|
|
24
|
-
} from
|
|
25
|
-
import { customInstance } from
|
|
26
|
-
import type { ErrorType } from
|
|
26
|
+
UsersGetResponse
|
|
27
|
+
} from '../account-server-api.schemas'
|
|
28
|
+
import { customInstance } from '.././custom-instance'
|
|
29
|
+
import type { ErrorType } from '.././custom-instance'
|
|
30
|
+
|
|
27
31
|
|
|
28
32
|
// eslint-disable-next-line
|
|
29
|
-
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
33
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
30
34
|
config: any,
|
|
31
|
-
args: infer P
|
|
35
|
+
args: infer P,
|
|
32
36
|
) => any
|
|
33
37
|
? P
|
|
34
38
|
: never;
|
|
@@ -39,53 +43,41 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
|
39
43
|
* @summary Get information about your account
|
|
40
44
|
*/
|
|
41
45
|
export const getUserAccount = (
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
|
|
47
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
44
48
|
) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
49
|
+
return customInstance<UserAccountGetResponse>(
|
|
50
|
+
{url: `/user/account`, method: 'get', signal
|
|
51
|
+
},
|
|
52
|
+
options);
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
|
|
51
56
|
export const getGetUserAccountQueryKey = () => [`/user/account`];
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
TError
|
|
61
|
-
|
|
62
|
-
query
|
|
63
|
-
Awaited<ReturnType<typeof getUserAccount>>,
|
|
64
|
-
TError,
|
|
65
|
-
TData
|
|
66
|
-
>;
|
|
67
|
-
request?: SecondParameter<typeof customInstance>;
|
|
68
|
-
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
69
|
-
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
58
|
+
|
|
59
|
+
export type GetUserAccountQueryResult = NonNullable<Awaited<ReturnType<typeof getUserAccount>>>
|
|
60
|
+
export type GetUserAccountQueryError = ErrorType<void | AsError>
|
|
61
|
+
|
|
62
|
+
export const useGetUserAccount = <TData = Awaited<ReturnType<typeof getUserAccount>>, TError = ErrorType<void | AsError>>(
|
|
63
|
+
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUserAccount>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
64
|
+
|
|
65
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
66
|
+
|
|
67
|
+
const {query: queryOptions, request: requestOptions} = options ?? {}
|
|
70
68
|
|
|
71
69
|
const queryKey = queryOptions?.queryKey ?? getGetUserAccountQueryKey();
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}) => getUserAccount(requestOptions, signal);
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUserAccount>>> = ({ signal }) => getUserAccount(requestOptions, signal);
|
|
76
74
|
|
|
77
|
-
const query = useQuery<
|
|
78
|
-
Awaited<ReturnType<typeof getUserAccount>>,
|
|
79
|
-
TError,
|
|
80
|
-
TData
|
|
81
|
-
>(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
|
|
82
|
-
queryKey: QueryKey;
|
|
83
|
-
};
|
|
75
|
+
const query = useQuery<Awaited<ReturnType<typeof getUserAccount>>, TError, TData>(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
84
76
|
|
|
85
77
|
query.queryKey = queryKey;
|
|
86
78
|
|
|
87
79
|
return query;
|
|
88
|
-
}
|
|
80
|
+
}
|
|
89
81
|
|
|
90
82
|
/**
|
|
91
83
|
* Gets users in an Organisation. You have to be in the Organisation or an Admin user to use this endpoint
|
|
@@ -93,61 +85,41 @@ export const useGetUserAccount = <
|
|
|
93
85
|
* @summary Gets users in an organisation
|
|
94
86
|
*/
|
|
95
87
|
export const getOrganisationUsers = (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
signal?: AbortSignal
|
|
88
|
+
orgId: string,
|
|
89
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
99
90
|
) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
export type GetOrganisationUsersQueryResult = NonNullable<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
export
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
TData
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
129
|
-
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
130
|
-
|
|
131
|
-
const queryKey =
|
|
132
|
-
queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgId);
|
|
133
|
-
|
|
134
|
-
const queryFn: QueryFunction<
|
|
135
|
-
Awaited<ReturnType<typeof getOrganisationUsers>>
|
|
136
|
-
> = ({ signal }) => getOrganisationUsers(orgId, requestOptions, signal);
|
|
137
|
-
|
|
138
|
-
const query = useQuery<
|
|
139
|
-
Awaited<ReturnType<typeof getOrganisationUsers>>,
|
|
140
|
-
TError,
|
|
141
|
-
TData
|
|
142
|
-
>(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
|
|
143
|
-
TData,
|
|
144
|
-
TError
|
|
145
|
-
> & { queryKey: QueryKey };
|
|
91
|
+
return customInstance<UsersGetResponse>(
|
|
92
|
+
{url: `/organisation/${orgId}/user`, method: 'get', signal
|
|
93
|
+
},
|
|
94
|
+
options);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
export const getGetOrganisationUsersQueryKey = (orgId: string,) => [`/organisation/${orgId}/user`];
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
export type GetOrganisationUsersQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationUsers>>>
|
|
102
|
+
export type GetOrganisationUsersQueryError = ErrorType<AsError | void>
|
|
103
|
+
|
|
104
|
+
export const useGetOrganisationUsers = <TData = Awaited<ReturnType<typeof getOrganisationUsers>>, TError = ErrorType<AsError | void>>(
|
|
105
|
+
orgId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getOrganisationUsers>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
106
|
+
|
|
107
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
108
|
+
|
|
109
|
+
const {query: queryOptions, request: requestOptions} = options ?? {}
|
|
110
|
+
|
|
111
|
+
const queryKey = queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgId);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationUsers>>> = ({ signal }) => getOrganisationUsers(orgId, requestOptions, signal);
|
|
116
|
+
|
|
117
|
+
const query = useQuery<Awaited<ReturnType<typeof getOrganisationUsers>>, TError, TData>(queryKey, queryFn, {enabled: !!(orgId), ...queryOptions}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
146
118
|
|
|
147
119
|
query.queryKey = queryKey;
|
|
148
120
|
|
|
149
121
|
return query;
|
|
150
|
-
}
|
|
122
|
+
}
|
|
151
123
|
|
|
152
124
|
/**
|
|
153
125
|
* Adds a user to an organisation. You have to be in the Organisation or an Admin user to use this endpoint
|
|
@@ -155,165 +127,117 @@ export const useGetOrganisationUsers = <
|
|
|
155
127
|
* @summary Adds a user to an organisation
|
|
156
128
|
*/
|
|
157
129
|
export const addOrganisationUser = (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
130
|
+
orgId: string,
|
|
131
|
+
userId: string,
|
|
132
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
133
|
+
return customInstance<void>(
|
|
134
|
+
{url: `/organisation/${orgId}/user/${userId}`, method: 'put'
|
|
135
|
+
},
|
|
136
|
+
options);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
export type AddOrganisationUserMutationResult = NonNullable<Awaited<ReturnType<typeof addOrganisationUser>>>
|
|
142
|
+
|
|
143
|
+
export type AddOrganisationUserMutationError = ErrorType<AsError>
|
|
144
|
+
|
|
145
|
+
export const useAddOrganisationUser = <TError = ErrorType<AsError>,
|
|
146
|
+
|
|
147
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof addOrganisationUser>>, TError,{orgId: string;userId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
161
148
|
) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
TContext = unknown
|
|
177
|
-
>(options?: {
|
|
178
|
-
mutation?: UseMutationOptions<
|
|
179
|
-
Awaited<ReturnType<typeof addOrganisationUser>>,
|
|
180
|
-
TError,
|
|
181
|
-
{ orgId: string; userId: string },
|
|
182
|
-
TContext
|
|
183
|
-
>;
|
|
184
|
-
request?: SecondParameter<typeof customInstance>;
|
|
185
|
-
}) => {
|
|
186
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
187
|
-
|
|
188
|
-
const mutationFn: MutationFunction<
|
|
189
|
-
Awaited<ReturnType<typeof addOrganisationUser>>,
|
|
190
|
-
{ orgId: string; userId: string }
|
|
191
|
-
> = (props) => {
|
|
192
|
-
const { orgId, userId } = props ?? {};
|
|
193
|
-
|
|
194
|
-
return addOrganisationUser(orgId, userId, requestOptions);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
return useMutation<
|
|
198
|
-
Awaited<ReturnType<typeof addOrganisationUser>>,
|
|
199
|
-
TError,
|
|
200
|
-
{ orgId: string; userId: string },
|
|
201
|
-
TContext
|
|
202
|
-
>(mutationFn, mutationOptions);
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
149
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof addOrganisationUser>>, {orgId: string;userId: string}> = (props) => {
|
|
155
|
+
const {orgId,userId} = props ?? {};
|
|
156
|
+
|
|
157
|
+
return addOrganisationUser(orgId,userId,requestOptions)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return useMutation<Awaited<ReturnType<typeof addOrganisationUser>>, TError, {orgId: string;userId: string}, TContext>(mutationFn, mutationOptions)
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
205
163
|
* Removes a user from an organisation. You have to be in the Organisation or an Admin user to use this endpoint
|
|
206
164
|
|
|
207
165
|
* @summary Deletes a user from an organisation
|
|
208
166
|
*/
|
|
209
167
|
export const deleteOrganisationUser = (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
168
|
+
orgId: string,
|
|
169
|
+
userId: string,
|
|
170
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
171
|
+
return customInstance<void>(
|
|
172
|
+
{url: `/organisation/${orgId}/user/${userId}`, method: 'delete'
|
|
173
|
+
},
|
|
174
|
+
options);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
export type DeleteOrganisationUserMutationResult = NonNullable<Awaited<ReturnType<typeof deleteOrganisationUser>>>
|
|
180
|
+
|
|
181
|
+
export type DeleteOrganisationUserMutationError = ErrorType<AsError>
|
|
182
|
+
|
|
183
|
+
export const useDeleteOrganisationUser = <TError = ErrorType<AsError>,
|
|
184
|
+
|
|
185
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteOrganisationUser>>, TError,{orgId: string;userId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
213
186
|
) => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
TContext = unknown
|
|
229
|
-
>(options?: {
|
|
230
|
-
mutation?: UseMutationOptions<
|
|
231
|
-
Awaited<ReturnType<typeof deleteOrganisationUser>>,
|
|
232
|
-
TError,
|
|
233
|
-
{ orgId: string; userId: string },
|
|
234
|
-
TContext
|
|
235
|
-
>;
|
|
236
|
-
request?: SecondParameter<typeof customInstance>;
|
|
237
|
-
}) => {
|
|
238
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
239
|
-
|
|
240
|
-
const mutationFn: MutationFunction<
|
|
241
|
-
Awaited<ReturnType<typeof deleteOrganisationUser>>,
|
|
242
|
-
{ orgId: string; userId: string }
|
|
243
|
-
> = (props) => {
|
|
244
|
-
const { orgId, userId } = props ?? {};
|
|
245
|
-
|
|
246
|
-
return deleteOrganisationUser(orgId, userId, requestOptions);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
return useMutation<
|
|
250
|
-
Awaited<ReturnType<typeof deleteOrganisationUser>>,
|
|
251
|
-
TError,
|
|
252
|
-
{ orgId: string; userId: string },
|
|
253
|
-
TContext
|
|
254
|
-
>(mutationFn, mutationOptions);
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
187
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteOrganisationUser>>, {orgId: string;userId: string}> = (props) => {
|
|
193
|
+
const {orgId,userId} = props ?? {};
|
|
194
|
+
|
|
195
|
+
return deleteOrganisationUser(orgId,userId,requestOptions)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return useMutation<Awaited<ReturnType<typeof deleteOrganisationUser>>, TError, {orgId: string;userId: string}, TContext>(mutationFn, mutationOptions)
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
257
201
|
* Gets users in an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint
|
|
258
202
|
|
|
259
203
|
* @summary Gets users in an Organisational Unit
|
|
260
204
|
*/
|
|
261
205
|
export const getOrganisationUnitUsers = (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
signal?: AbortSignal
|
|
206
|
+
unitId: string,
|
|
207
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
265
208
|
) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
export type GetOrganisationUnitUsersQueryResult = NonNullable<
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
export
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
TData
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
Awaited<ReturnType<typeof getOrganisationUnitUsers>>
|
|
302
|
-
> = ({ signal }) => getOrganisationUnitUsers(unitId, requestOptions, signal);
|
|
303
|
-
|
|
304
|
-
const query = useQuery<
|
|
305
|
-
Awaited<ReturnType<typeof getOrganisationUnitUsers>>,
|
|
306
|
-
TError,
|
|
307
|
-
TData
|
|
308
|
-
>(queryKey, queryFn, {
|
|
309
|
-
enabled: !!unitId,
|
|
310
|
-
...queryOptions,
|
|
311
|
-
}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
209
|
+
return customInstance<UsersGetResponse>(
|
|
210
|
+
{url: `/unit/${unitId}/user`, method: 'get', signal
|
|
211
|
+
},
|
|
212
|
+
options);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
export const getGetOrganisationUnitUsersQueryKey = (unitId: string,) => [`/unit/${unitId}/user`];
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
export type GetOrganisationUnitUsersQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationUnitUsers>>>
|
|
220
|
+
export type GetOrganisationUnitUsersQueryError = ErrorType<AsError | void>
|
|
221
|
+
|
|
222
|
+
export const useGetOrganisationUnitUsers = <TData = Awaited<ReturnType<typeof getOrganisationUnitUsers>>, TError = ErrorType<AsError | void>>(
|
|
223
|
+
unitId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getOrganisationUnitUsers>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
224
|
+
|
|
225
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
226
|
+
|
|
227
|
+
const {query: queryOptions, request: requestOptions} = options ?? {}
|
|
228
|
+
|
|
229
|
+
const queryKey = queryOptions?.queryKey ?? getGetOrganisationUnitUsersQueryKey(unitId);
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationUnitUsers>>> = ({ signal }) => getOrganisationUnitUsers(unitId, requestOptions, signal);
|
|
234
|
+
|
|
235
|
+
const query = useQuery<Awaited<ReturnType<typeof getOrganisationUnitUsers>>, TError, TData>(queryKey, queryFn, {enabled: !!(unitId), ...queryOptions}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
312
236
|
|
|
313
237
|
query.queryKey = queryKey;
|
|
314
238
|
|
|
315
239
|
return query;
|
|
316
|
-
}
|
|
240
|
+
}
|
|
317
241
|
|
|
318
242
|
/**
|
|
319
243
|
* Adds a user to an Organisational Unit.
|
|
@@ -325,53 +249,39 @@ You have to be in the Organisation or Unit or an Admin user to use this endpoint
|
|
|
325
249
|
* @summary Adds a user to an Organisational Unit
|
|
326
250
|
*/
|
|
327
251
|
export const addOrganisationUnitUser = (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
252
|
+
unitId: string,
|
|
253
|
+
userId: string,
|
|
254
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
255
|
+
return customInstance<void>(
|
|
256
|
+
{url: `/unit/${unitId}/user/${userId}`, method: 'put'
|
|
257
|
+
},
|
|
258
|
+
options);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
export type AddOrganisationUnitUserMutationResult = NonNullable<Awaited<ReturnType<typeof addOrganisationUnitUser>>>
|
|
264
|
+
|
|
265
|
+
export type AddOrganisationUnitUserMutationError = ErrorType<AsError>
|
|
266
|
+
|
|
267
|
+
export const useAddOrganisationUnitUser = <TError = ErrorType<AsError>,
|
|
268
|
+
|
|
269
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof addOrganisationUnitUser>>, TError,{unitId: string;userId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
331
270
|
) => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
TContext = unknown
|
|
347
|
-
>(options?: {
|
|
348
|
-
mutation?: UseMutationOptions<
|
|
349
|
-
Awaited<ReturnType<typeof addOrganisationUnitUser>>,
|
|
350
|
-
TError,
|
|
351
|
-
{ unitId: string; userId: string },
|
|
352
|
-
TContext
|
|
353
|
-
>;
|
|
354
|
-
request?: SecondParameter<typeof customInstance>;
|
|
355
|
-
}) => {
|
|
356
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
357
|
-
|
|
358
|
-
const mutationFn: MutationFunction<
|
|
359
|
-
Awaited<ReturnType<typeof addOrganisationUnitUser>>,
|
|
360
|
-
{ unitId: string; userId: string }
|
|
361
|
-
> = (props) => {
|
|
362
|
-
const { unitId, userId } = props ?? {};
|
|
363
|
-
|
|
364
|
-
return addOrganisationUnitUser(unitId, userId, requestOptions);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
return useMutation<
|
|
368
|
-
Awaited<ReturnType<typeof addOrganisationUnitUser>>,
|
|
369
|
-
TError,
|
|
370
|
-
{ unitId: string; userId: string },
|
|
371
|
-
TContext
|
|
372
|
-
>(mutationFn, mutationOptions);
|
|
373
|
-
};
|
|
374
|
-
/**
|
|
271
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof addOrganisationUnitUser>>, {unitId: string;userId: string}> = (props) => {
|
|
277
|
+
const {unitId,userId} = props ?? {};
|
|
278
|
+
|
|
279
|
+
return addOrganisationUnitUser(unitId,userId,requestOptions)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return useMutation<Awaited<ReturnType<typeof addOrganisationUnitUser>>, TError, {unitId: string;userId: string}, TContext>(mutationFn, mutationOptions)
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
375
285
|
* Removes a user from an Organisational Unit.
|
|
376
286
|
|
|
377
287
|
Users cannot be removed from **Personal Units** (Units that are part of the ***Default** Organisation).
|
|
@@ -381,49 +291,36 @@ You have to be in the Organisation or Unit or an Admin user to use this endpoint
|
|
|
381
291
|
* @summary Deletes a user from an Organisational Unit
|
|
382
292
|
*/
|
|
383
293
|
export const deleteOrganisationUnitUser = (
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
294
|
+
unitId: string,
|
|
295
|
+
userId: string,
|
|
296
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
297
|
+
return customInstance<void>(
|
|
298
|
+
{url: `/unit/${unitId}/user/${userId}`, method: 'delete'
|
|
299
|
+
},
|
|
300
|
+
options);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
export type DeleteOrganisationUnitUserMutationResult = NonNullable<Awaited<ReturnType<typeof deleteOrganisationUnitUser>>>
|
|
306
|
+
|
|
307
|
+
export type DeleteOrganisationUnitUserMutationError = ErrorType<AsError>
|
|
308
|
+
|
|
309
|
+
export const useDeleteOrganisationUnitUser = <TError = ErrorType<AsError>,
|
|
310
|
+
|
|
311
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteOrganisationUnitUser>>, TError,{unitId: string;userId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
387
312
|
) => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
TContext = unknown
|
|
403
|
-
>(options?: {
|
|
404
|
-
mutation?: UseMutationOptions<
|
|
405
|
-
Awaited<ReturnType<typeof deleteOrganisationUnitUser>>,
|
|
406
|
-
TError,
|
|
407
|
-
{ unitId: string; userId: string },
|
|
408
|
-
TContext
|
|
409
|
-
>;
|
|
410
|
-
request?: SecondParameter<typeof customInstance>;
|
|
411
|
-
}) => {
|
|
412
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
413
|
-
|
|
414
|
-
const mutationFn: MutationFunction<
|
|
415
|
-
Awaited<ReturnType<typeof deleteOrganisationUnitUser>>,
|
|
416
|
-
{ unitId: string; userId: string }
|
|
417
|
-
> = (props) => {
|
|
418
|
-
const { unitId, userId } = props ?? {};
|
|
419
|
-
|
|
420
|
-
return deleteOrganisationUnitUser(unitId, userId, requestOptions);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
return useMutation<
|
|
424
|
-
Awaited<ReturnType<typeof deleteOrganisationUnitUser>>,
|
|
425
|
-
TError,
|
|
426
|
-
{ unitId: string; userId: string },
|
|
427
|
-
TContext
|
|
428
|
-
>(mutationFn, mutationOptions);
|
|
429
|
-
};
|
|
313
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {}
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteOrganisationUnitUser>>, {unitId: string;userId: string}> = (props) => {
|
|
319
|
+
const {unitId,userId} = props ?? {};
|
|
320
|
+
|
|
321
|
+
return deleteOrganisationUnitUser(unitId,userId,requestOptions)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return useMutation<Awaited<ReturnType<typeof deleteOrganisationUnitUser>>, TError, {unitId: string;userId: string}, TContext>(mutationFn, mutationOptions)
|
|
325
|
+
}
|
|
326
|
+
|
package/state/state.cjs
CHANGED
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
var _chunkIUEU2LYCcjs = require('../chunk-IUEU2LYC.cjs');
|
|
4
4
|
|
|
5
5
|
// src/state/state.ts
|
|
6
|
+
|
|
7
|
+
|
|
6
8
|
var _reactquery = require('react-query');
|
|
7
9
|
var getVersion = (options, signal) => {
|
|
8
10
|
return _chunkIUEU2LYCcjs.customInstance.call(void 0,
|
|
9
|
-
{
|
|
11
|
+
{
|
|
12
|
+
url: `/version`,
|
|
13
|
+
method: "get",
|
|
14
|
+
signal
|
|
15
|
+
},
|
|
10
16
|
options
|
|
11
17
|
);
|
|
12
18
|
};
|
|
@@ -14,14 +20,8 @@ var getGetVersionQueryKey = () => [`/version`];
|
|
|
14
20
|
var useGetVersion = (options) => {
|
|
15
21
|
const { query: queryOptions, request: requestOptions } = _nullishCoalesce(options, () => ( {}));
|
|
16
22
|
const queryKey = _nullishCoalesce((queryOptions == null ? void 0 : queryOptions.queryKey), () => ( getGetVersionQueryKey()));
|
|
17
|
-
const queryFn = ({
|
|
18
|
-
|
|
19
|
-
}) => getVersion(requestOptions, signal);
|
|
20
|
-
const query = _reactquery.useQuery.call(void 0,
|
|
21
|
-
queryKey,
|
|
22
|
-
queryFn,
|
|
23
|
-
queryOptions
|
|
24
|
-
);
|
|
23
|
+
const queryFn = ({ signal }) => getVersion(requestOptions, signal);
|
|
24
|
+
const query = _reactquery.useQuery.call(void 0, queryKey, queryFn, queryOptions);
|
|
25
25
|
query.queryKey = queryKey;
|
|
26
26
|
return query;
|
|
27
27
|
};
|