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