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