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