@squonk/account-server-client 0.1.7-rc.1 → 0.1.8-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.
Files changed (42) hide show
  1. package/{custom-instance-0d593da2.d.ts → custom-instance-cc5da68e.d.ts} +12 -5
  2. package/index.cjs +103 -2
  3. package/index.cjs.map +3 -3
  4. package/index.d.ts +1 -1
  5. package/index.js +69 -2
  6. package/index.js.map +3 -3
  7. package/organisation/organisation.cjs +111 -2
  8. package/organisation/organisation.cjs.map +3 -3
  9. package/organisation/organisation.d.ts +19 -5
  10. package/organisation/organisation.js +83 -2
  11. package/organisation/organisation.js.map +3 -3
  12. package/organisation/package.json +2 -1
  13. package/package.json +7 -7
  14. package/product/package.json +2 -1
  15. package/product/product.cjs +161 -2
  16. package/product/product.cjs.map +3 -3
  17. package/product/product.d.ts +2 -2
  18. package/product/product.js +127 -2
  19. package/product/product.js.map +3 -3
  20. package/src/account-server-api.schemas.ts +278 -0
  21. package/src/custom-instance.ts +52 -0
  22. package/src/index.ts +6 -0
  23. package/src/organisation/organisation.ts +181 -0
  24. package/src/product/product.ts +289 -0
  25. package/src/unit/unit.ts +322 -0
  26. package/src/user/user.ts +340 -0
  27. package/unit/package.json +2 -1
  28. package/unit/unit.cjs +168 -2
  29. package/unit/unit.cjs.map +3 -3
  30. package/unit/unit.d.ts +52 -3
  31. package/unit/unit.js +133 -2
  32. package/unit/unit.js.map +3 -3
  33. package/user/package.json +2 -1
  34. package/user/user.cjs +176 -2
  35. package/user/user.cjs.map +3 -3
  36. package/user/user.d.ts +7 -7
  37. package/user/user.js +141 -2
  38. package/user/user.js.map +3 -3
  39. package/chunk-33VR3IML.js +0 -2
  40. package/chunk-33VR3IML.js.map +0 -7
  41. package/chunk-3KO3PKBX.cjs +0 -2
  42. package/chunk-3KO3PKBX.cjs.map +0 -7
@@ -0,0 +1,289 @@
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
+ ProductsGetResponse,
23
+ AsError,
24
+ UnitProductPostResponse,
25
+ UnitProductPostBodyBody,
26
+ ProductUnitGetResponse,
27
+ ProductPatchBodyBody,
28
+ } from "../account-server-api.schemas";
29
+ import { customInstance, ErrorType } from ".././custom-instance";
30
+
31
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
32
+ ...args: any
33
+ ) => Promise<infer R>
34
+ ? R
35
+ : any;
36
+
37
+ type SecondParameter<T extends (...args: any) => any> = T extends (
38
+ config: any,
39
+ args: infer P
40
+ ) => any
41
+ ? P
42
+ : never;
43
+
44
+ /**
45
+ * Gets products you have access to, across all Units and Organisations
46
+
47
+ * @summary Gets all Products
48
+ */
49
+ export const getProducts = (
50
+ options?: SecondParameter<typeof customInstance>
51
+ ) => {
52
+ return customInstance<ProductsGetResponse>(
53
+ { url: `/product`, method: "get" },
54
+ options
55
+ );
56
+ };
57
+
58
+ export const getGetProductsQueryKey = () => [`/product`];
59
+
60
+ export const useGetProducts = <
61
+ TData = AsyncReturnType<typeof getProducts>,
62
+ TError = ErrorType<AsError | void>
63
+ >(options?: {
64
+ query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;
65
+ request?: SecondParameter<typeof customInstance>;
66
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
67
+ const { query: queryOptions, request: requestOptions } = options || {};
68
+
69
+ const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
70
+
71
+ const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>
72
+ getProducts(requestOptions);
73
+
74
+ const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(
75
+ queryKey,
76
+ queryFn,
77
+ queryOptions
78
+ );
79
+
80
+ return {
81
+ queryKey,
82
+ ...query,
83
+ };
84
+ };
85
+
86
+ /**
87
+ * @summary Creates a Product for an Organisational Unit
88
+ */
89
+ export const createUnitProduct = (
90
+ unitid: string,
91
+ unitProductPostBodyBody: UnitProductPostBodyBody,
92
+ options?: SecondParameter<typeof customInstance>
93
+ ) => {
94
+ return customInstance<UnitProductPostResponse>(
95
+ {
96
+ url: `/product/unit/${unitid}`,
97
+ method: "post",
98
+ data: unitProductPostBodyBody,
99
+ },
100
+ options
101
+ );
102
+ };
103
+
104
+ export const useCreateUnitProduct = <
105
+ TError = ErrorType<AsError | void>,
106
+ TContext = unknown
107
+ >(options?: {
108
+ mutation?: UseMutationOptions<
109
+ AsyncReturnType<typeof createUnitProduct>,
110
+ TError,
111
+ { unitid: string; data: UnitProductPostBodyBody },
112
+ TContext
113
+ >;
114
+ request?: SecondParameter<typeof customInstance>;
115
+ }) => {
116
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
117
+
118
+ const mutationFn: MutationFunction<
119
+ AsyncReturnType<typeof createUnitProduct>,
120
+ { unitid: string; data: UnitProductPostBodyBody }
121
+ > = (props) => {
122
+ const { unitid, data } = props || {};
123
+
124
+ return createUnitProduct(unitid, data, requestOptions);
125
+ };
126
+
127
+ return useMutation<
128
+ AsyncReturnType<typeof createUnitProduct>,
129
+ TError,
130
+ { unitid: string; data: UnitProductPostBodyBody },
131
+ TContext
132
+ >(mutationFn, mutationOptions);
133
+ };
134
+ /**
135
+ * Gets products you have access to based on an Organisational Unit
136
+
137
+ * @summary Gets Products for an Organisational Unit
138
+ */
139
+ export const getProductsForUnit = (
140
+ unitid: string,
141
+ options?: SecondParameter<typeof customInstance>
142
+ ) => {
143
+ return customInstance<ProductsGetResponse>(
144
+ { url: `/product/unit/${unitid}`, method: "get" },
145
+ options
146
+ );
147
+ };
148
+
149
+ export const getGetProductsForUnitQueryKey = (unitid: string) => [
150
+ `/product/unit/${unitid}`,
151
+ ];
152
+
153
+ export const useGetProductsForUnit = <
154
+ TData = AsyncReturnType<typeof getProductsForUnit>,
155
+ TError = ErrorType<void | AsError>
156
+ >(
157
+ unitid: string,
158
+ options?: {
159
+ query?: UseQueryOptions<
160
+ AsyncReturnType<typeof getProductsForUnit>,
161
+ TError,
162
+ TData
163
+ >;
164
+ request?: SecondParameter<typeof customInstance>;
165
+ }
166
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
167
+ const { query: queryOptions, request: requestOptions } = options || {};
168
+
169
+ const queryKey =
170
+ queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitid);
171
+
172
+ const queryFn: QueryFunction<
173
+ AsyncReturnType<typeof getProductsForUnit>
174
+ > = () => getProductsForUnit(unitid, requestOptions);
175
+
176
+ const query = useQuery<
177
+ AsyncReturnType<typeof getProductsForUnit>,
178
+ TError,
179
+ TData
180
+ >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });
181
+
182
+ return {
183
+ queryKey,
184
+ ...query,
185
+ };
186
+ };
187
+
188
+ /**
189
+ * Gets a Unit's Product
190
+
191
+ * @summary Gets a Unit's Product
192
+ */
193
+ export const getProduct = (
194
+ unitid: string,
195
+ productid: string,
196
+ options?: SecondParameter<typeof customInstance>
197
+ ) => {
198
+ return customInstance<ProductUnitGetResponse>(
199
+ { url: `/product/unit/${unitid}/product/${productid}`, method: "get" },
200
+ options
201
+ );
202
+ };
203
+
204
+ export const getGetProductQueryKey = (unitid: string, productid: string) => [
205
+ `/product/unit/${unitid}/product/${productid}`,
206
+ ];
207
+
208
+ export const useGetProduct = <
209
+ TData = AsyncReturnType<typeof getProduct>,
210
+ TError = ErrorType<AsError | void>
211
+ >(
212
+ unitid: string,
213
+ productid: string,
214
+ options?: {
215
+ query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;
216
+ request?: SecondParameter<typeof customInstance>;
217
+ }
218
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
219
+ const { query: queryOptions, request: requestOptions } = options || {};
220
+
221
+ const queryKey =
222
+ queryOptions?.queryKey ?? getGetProductQueryKey(unitid, productid);
223
+
224
+ const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>
225
+ getProduct(unitid, productid, requestOptions);
226
+
227
+ const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(
228
+ queryKey,
229
+ queryFn,
230
+ { enabled: !!(unitid && productid), ...queryOptions }
231
+ );
232
+
233
+ return {
234
+ queryKey,
235
+ ...query,
236
+ };
237
+ };
238
+
239
+ /**
240
+ * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. Curently you can only patch storage Products
241
+
242
+ * @summary Adjust an existing Product
243
+ */
244
+ export const patchProduct = (
245
+ unitid: string,
246
+ productid: string,
247
+ productPatchBodyBody: ProductPatchBodyBody,
248
+ options?: SecondParameter<typeof customInstance>
249
+ ) => {
250
+ return customInstance<void>(
251
+ {
252
+ url: `/product/unit/${unitid}/product/${productid}`,
253
+ method: "patch",
254
+ data: productPatchBodyBody,
255
+ },
256
+ options
257
+ );
258
+ };
259
+
260
+ export const usePatchProduct = <
261
+ TError = ErrorType<AsError>,
262
+ TContext = unknown
263
+ >(options?: {
264
+ mutation?: UseMutationOptions<
265
+ AsyncReturnType<typeof patchProduct>,
266
+ TError,
267
+ { unitid: string; productid: string; data: ProductPatchBodyBody },
268
+ TContext
269
+ >;
270
+ request?: SecondParameter<typeof customInstance>;
271
+ }) => {
272
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
273
+
274
+ const mutationFn: MutationFunction<
275
+ AsyncReturnType<typeof patchProduct>,
276
+ { unitid: string; productid: string; data: ProductPatchBodyBody }
277
+ > = (props) => {
278
+ const { unitid, productid, data } = props || {};
279
+
280
+ return patchProduct(unitid, productid, data, requestOptions);
281
+ };
282
+
283
+ return useMutation<
284
+ AsyncReturnType<typeof patchProduct>,
285
+ TError,
286
+ { unitid: string; productid: string; data: ProductPatchBodyBody },
287
+ TContext
288
+ >(mutationFn, mutationOptions);
289
+ };
@@ -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
+ };