@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.
- package/{custom-instance-0d593da2.d.ts → custom-instance-cc5da68e.d.ts} +12 -5
- package/index.cjs +103 -2
- package/index.cjs.map +3 -3
- package/index.d.ts +1 -1
- package/index.js +69 -2
- package/index.js.map +3 -3
- package/organisation/organisation.cjs +111 -2
- package/organisation/organisation.cjs.map +3 -3
- package/organisation/organisation.d.ts +19 -5
- package/organisation/organisation.js +83 -2
- package/organisation/organisation.js.map +3 -3
- package/organisation/package.json +2 -1
- package/package.json +7 -7
- package/product/package.json +2 -1
- package/product/product.cjs +161 -2
- package/product/product.cjs.map +3 -3
- package/product/product.d.ts +2 -2
- package/product/product.js +127 -2
- package/product/product.js.map +3 -3
- package/src/account-server-api.schemas.ts +278 -0
- package/src/custom-instance.ts +52 -0
- package/src/index.ts +6 -0
- package/src/organisation/organisation.ts +181 -0
- package/src/product/product.ts +289 -0
- package/src/unit/unit.ts +322 -0
- package/src/user/user.ts +340 -0
- package/unit/package.json +2 -1
- package/unit/unit.cjs +168 -2
- package/unit/unit.cjs.map +3 -3
- package/unit/unit.d.ts +52 -3
- package/unit/unit.js +133 -2
- package/unit/unit.js.map +3 -3
- package/user/package.json +2 -1
- package/user/user.cjs +176 -2
- package/user/user.cjs.map +3 -3
- package/user/user.d.ts +7 -7
- package/user/user.js +141 -2
- package/user/user.js.map +3 -3
- package/chunk-33VR3IML.js +0 -2
- package/chunk-33VR3IML.js.map +0 -7
- package/chunk-3KO3PKBX.cjs +0 -2
- package/chunk-3KO3PKBX.cjs.map +0 -7
|
@@ -0,0 +1,278 @@
|
|
|
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
|
+
/**
|
|
12
|
+
* A dummy
|
|
13
|
+
|
|
14
|
+
*/
|
|
15
|
+
export type QDummyParameter = boolean;
|
|
16
|
+
|
|
17
|
+
export type ProductPatchBodyBody = {
|
|
18
|
+
/** The name you want to give the Product */
|
|
19
|
+
name?: string;
|
|
20
|
+
/** The Product's built-in coin alloance. */
|
|
21
|
+
allowance?: number;
|
|
22
|
+
/** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used */
|
|
23
|
+
limit?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products
|
|
28
|
+
*/
|
|
29
|
+
export type UnitProductPostBodyBodyFlavour =
|
|
30
|
+
| "EVALUATION"
|
|
31
|
+
| "BRONZE"
|
|
32
|
+
| "SILVER"
|
|
33
|
+
| "GOLD";
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
36
|
+
export const UnitProductPostBodyBodyFlavour = {
|
|
37
|
+
EVALUATION: "EVALUATION" as UnitProductPostBodyBodyFlavour,
|
|
38
|
+
BRONZE: "BRONZE" as UnitProductPostBodyBodyFlavour,
|
|
39
|
+
SILVER: "SILVER" as UnitProductPostBodyBodyFlavour,
|
|
40
|
+
GOLD: "GOLD" as UnitProductPostBodyBodyFlavour,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The Type of Product. Storage subscriptions require an **Allowance** to be defined and the **Flavour** must not be providec. Project Tier subscriptions have built-in allowances and Limits so you must not provide values for these for these products
|
|
45
|
+
*/
|
|
46
|
+
export type UnitProductPostBodyBodyType =
|
|
47
|
+
| "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION"
|
|
48
|
+
| "DATA_MANAGER_STORAGE_SUBSCRIPTION";
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
51
|
+
export const UnitProductPostBodyBodyType = {
|
|
52
|
+
DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:
|
|
53
|
+
"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION" as UnitProductPostBodyBodyType,
|
|
54
|
+
DATA_MANAGER_STORAGE_SUBSCRIPTION:
|
|
55
|
+
"DATA_MANAGER_STORAGE_SUBSCRIPTION" as UnitProductPostBodyBodyType,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type UnitProductPostBodyBody = {
|
|
59
|
+
/** The name you want to give the Product */
|
|
60
|
+
name: string;
|
|
61
|
+
/** The Type of Product. Storage subscriptions require an **Allowance** to be defined and the **Flavour** must not be providec. Project Tier subscriptions have built-in allowances and Limits so you must not provide values for these for these products */
|
|
62
|
+
type: UnitProductPostBodyBodyType;
|
|
63
|
+
/** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */
|
|
64
|
+
flavour?: UnitProductPostBodyBodyFlavour;
|
|
65
|
+
/** The Product's coin alloance. You must provide this for Storage products but you must not provide a value for Project Tier Products */
|
|
66
|
+
allowance?: number;
|
|
67
|
+
/** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used. You can provide this for Storage products but you must not provide a value for Project Tier Products */
|
|
68
|
+
limit?: number;
|
|
69
|
+
/** The day you would like to be billed for the Product's subscription (a value from 1 and 28) */
|
|
70
|
+
billing_day: number;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type OrganisationUnitPostBodyBody = {
|
|
74
|
+
/** The name of the unit */
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type OrganisationPostBodyBody = {
|
|
79
|
+
/** The name of the organisaion */
|
|
80
|
+
name: string;
|
|
81
|
+
/** The name of the organisation owner. A user ID */
|
|
82
|
+
owner: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export interface UserDetail {
|
|
86
|
+
id: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface UnitDetail {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
owner_id?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface OrganisationDetail {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
owner_id?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type ProductInstanceDetailCoins = {
|
|
102
|
+
used: number;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export interface ProductInstanceDetail {
|
|
106
|
+
coins: ProductInstanceDetailCoins;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type ProductDetailFlavour = "EVALUATION" | "BRONZE" | "SILVER" | "GOLD";
|
|
110
|
+
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
112
|
+
export const ProductDetailFlavour = {
|
|
113
|
+
EVALUATION: "EVALUATION" as ProductDetailFlavour,
|
|
114
|
+
BRONZE: "BRONZE" as ProductDetailFlavour,
|
|
115
|
+
SILVER: "SILVER" as ProductDetailFlavour,
|
|
116
|
+
GOLD: "GOLD" as ProductDetailFlavour,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type ProductDetailType =
|
|
120
|
+
| "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION"
|
|
121
|
+
| "DATA_MANAGER_STORAGE_SUBSCRIPTION";
|
|
122
|
+
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
124
|
+
export const ProductDetailType = {
|
|
125
|
+
DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:
|
|
126
|
+
"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION" as ProductDetailType,
|
|
127
|
+
DATA_MANAGER_STORAGE_SUBSCRIPTION:
|
|
128
|
+
"DATA_MANAGER_STORAGE_SUBSCRIPTION" as ProductDetailType,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export interface ProductDetail {
|
|
132
|
+
/** The Product ID
|
|
133
|
+
*/
|
|
134
|
+
id: string;
|
|
135
|
+
type: ProductDetailType;
|
|
136
|
+
flavour?: ProductDetailFlavour;
|
|
137
|
+
name?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface ProductCoinsDetail {
|
|
141
|
+
/** The billing allowance. When you exceed this during the current billign period the *cost multipler* will increase */
|
|
142
|
+
allowance: number;
|
|
143
|
+
/** The limit on your billing period spend. You can exceed the allowance but you cannot exceed the spend limit. Once reached the dependent may be restricted */
|
|
144
|
+
limit: number;
|
|
145
|
+
/** The total number of coins consumed (in this billing period), exclding the coins that have been consumed for the current day */
|
|
146
|
+
used: number;
|
|
147
|
+
/** True if the product is oeprating at or beyond its coin limit. When it is authority to perform actions using the product are severly limited. */
|
|
148
|
+
at_limit: boolean;
|
|
149
|
+
/** The current burn rate, the approximate amount of coins you are currently consuming each day */
|
|
150
|
+
current_burn_rate: number;
|
|
151
|
+
/** The predicted billing period amount, if costs continue at the current burn rate until the end of the billing period */
|
|
152
|
+
billing_prediction: number;
|
|
153
|
+
/** The day of the month when the bill is due, and the end of the current billign period */
|
|
154
|
+
billing_day: number;
|
|
155
|
+
/** A multipler applied to your coin usage within yoru allowance */
|
|
156
|
+
allowance_multiplier: number;
|
|
157
|
+
/** A multipler that will be applied to coin used beyond your allowance */
|
|
158
|
+
overspend_multiplier: number;
|
|
159
|
+
/** The number of days remaining, in the current billing period */
|
|
160
|
+
remaining_days: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface ProductClaimDetail {
|
|
164
|
+
/** The service ID using this Subscription.
|
|
165
|
+
*/
|
|
166
|
+
id: string;
|
|
167
|
+
/** A name for the service
|
|
168
|
+
*/
|
|
169
|
+
name?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type ProductDmStorageDetailCoins = {
|
|
173
|
+
/** The number of coins currently committed for the current day. This is added to the acumulated coins at the start of each day */
|
|
174
|
+
used: number;
|
|
175
|
+
/** The coin cost of a 'unit' of strage or part thereof. The unit size is defined in the storage section of the response */
|
|
176
|
+
unit_cost: number;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export type ProductDmStorageDetailSize = {
|
|
180
|
+
/** The humanised size of the peak storage used for the current day. The value is reset at the start of each day */
|
|
181
|
+
peak: string;
|
|
182
|
+
/** The humanised size of the current storage used for the current day and used to calculate the 'burn rate' */
|
|
183
|
+
current: string;
|
|
184
|
+
/** The humanised storage unit. The cost of storage is based on the daily peak of the number of units (or part thereof) used */
|
|
185
|
+
unit_size: string;
|
|
186
|
+
/** The peak number of storage units used today */
|
|
187
|
+
units_used: number;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export interface ProductDmStorageDetail {
|
|
191
|
+
size: ProductDmStorageDetailSize;
|
|
192
|
+
coins: ProductDmStorageDetailCoins;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface ProductDmProjectTier {
|
|
196
|
+
product: ProductDetail;
|
|
197
|
+
organisation: OrganisationDetail;
|
|
198
|
+
unit: UnitDetail;
|
|
199
|
+
storage: ProductDmStorageDetail;
|
|
200
|
+
coins: ProductCoinsDetail;
|
|
201
|
+
instance: ProductInstanceDetail;
|
|
202
|
+
claim?: ProductClaimDetail;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface ProductDmStorage {
|
|
206
|
+
product: ProductDetail;
|
|
207
|
+
organisation: OrganisationDetail;
|
|
208
|
+
unit: UnitDetail;
|
|
209
|
+
storage: ProductDmStorageDetail;
|
|
210
|
+
coins: ProductCoinsDetail;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface UnitsGetResponse {
|
|
214
|
+
/** A list of Units
|
|
215
|
+
*/
|
|
216
|
+
units: OrganisationUnitsGetResponse[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface UnitProductPostResponse {
|
|
220
|
+
/** The products's unique ID */
|
|
221
|
+
id: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The Unit's Product
|
|
226
|
+
*/
|
|
227
|
+
export type ProductUnitGetResponseProduct =
|
|
228
|
+
| ProductDmStorage
|
|
229
|
+
| ProductDmProjectTier;
|
|
230
|
+
|
|
231
|
+
export interface ProductUnitGetResponse {
|
|
232
|
+
/** The Unit's Product */
|
|
233
|
+
product: ProductUnitGetResponseProduct;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type ProductsGetResponseProductsItem =
|
|
237
|
+
| ProductDmStorage
|
|
238
|
+
| ProductDmProjectTier;
|
|
239
|
+
|
|
240
|
+
export interface ProductsGetResponse {
|
|
241
|
+
/** All the Products you have access to */
|
|
242
|
+
products: ProductsGetResponseProductsItem[];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface OrganisationsGetResponse {
|
|
246
|
+
/** A list of Organisaions */
|
|
247
|
+
organisations: OrganisationDetail[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface OrganisationUnitsGetResponse {
|
|
251
|
+
organisation: OrganisationDetail;
|
|
252
|
+
/** A list of Units
|
|
253
|
+
*/
|
|
254
|
+
units: UnitDetail[];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface OrganisationUnitPostResponse {
|
|
258
|
+
/** The unit's unique ID */
|
|
259
|
+
id: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface UsersGetResponse {
|
|
263
|
+
organisation?: OrganisationDetail;
|
|
264
|
+
unit?: UnitDetail;
|
|
265
|
+
/** The list of Organisation Users
|
|
266
|
+
*/
|
|
267
|
+
users: UserDetail[];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface OrganisationPostResponse {
|
|
271
|
+
/** The organisation's unique ID */
|
|
272
|
+
id: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface AsError {
|
|
276
|
+
/** Brief error text that can be presented to the user */
|
|
277
|
+
error: string;
|
|
278
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Based off the example custom-instance from Orval docs
|
|
2
|
+
* https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts
|
|
3
|
+
*
|
|
4
|
+
* See https://react-query.tanstack.com/guides/query-cancellation
|
|
5
|
+
*
|
|
6
|
+
* TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be
|
|
7
|
+
* achieved without changing much using `redaxios`
|
|
8
|
+
* Or use 'ky'
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Axios, { AxiosError, AxiosRequestConfig } from 'axios';
|
|
12
|
+
|
|
13
|
+
// ? Need the baseUrl or does it default to ''?
|
|
14
|
+
export const AXIOS_INSTANCE = Axios.create({ baseURL: '' });
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Set the access token to be added as the `Authorization: Bearer 'token'` header
|
|
18
|
+
* Useful for client only apps where a proxy API route isn't involved to securely add the access token
|
|
19
|
+
* @param token access token
|
|
20
|
+
*/
|
|
21
|
+
export const setAuthToken = (token: string) => {
|
|
22
|
+
AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Set the url to which request paths are added to.
|
|
27
|
+
* @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'
|
|
28
|
+
*/
|
|
29
|
+
export const setBaseUrl = (baseUrl: string) => {
|
|
30
|
+
AXIOS_INSTANCE.defaults.baseURL = baseUrl;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const customInstance = <TReturn>(
|
|
34
|
+
config: AxiosRequestConfig,
|
|
35
|
+
options?: AxiosRequestConfig,
|
|
36
|
+
): Promise<TReturn> => {
|
|
37
|
+
const source = Axios.CancelToken.source();
|
|
38
|
+
|
|
39
|
+
const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(
|
|
40
|
+
({ data }) => data,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// Promise doesn't have a cancel method but react-query requires this method to make cancellations general.
|
|
44
|
+
// This can either be a any assertion or a @ts-ignore comment.
|
|
45
|
+
(promise as any).cancel = () => {
|
|
46
|
+
source.cancel('Query was cancelled by React Query');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return promise;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type ErrorType<TError> = AxiosError<TError>;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
OrganisationsGetResponse,
|
|
23
|
+
AsError,
|
|
24
|
+
OrganisationPostResponse,
|
|
25
|
+
OrganisationPostBodyBody,
|
|
26
|
+
} from "../account-server-api.schemas";
|
|
27
|
+
import { customInstance, ErrorType } from ".././custom-instance";
|
|
28
|
+
|
|
29
|
+
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
30
|
+
...args: any
|
|
31
|
+
) => Promise<infer R>
|
|
32
|
+
? R
|
|
33
|
+
: any;
|
|
34
|
+
|
|
35
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
36
|
+
config: any,
|
|
37
|
+
args: infer P
|
|
38
|
+
) => any
|
|
39
|
+
? P
|
|
40
|
+
: never;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets all the Organisations you are a member of. Admin users can see all Organisations
|
|
44
|
+
|
|
45
|
+
* @summary Gets Organisations
|
|
46
|
+
*/
|
|
47
|
+
export const getOrganisations = (
|
|
48
|
+
options?: SecondParameter<typeof customInstance>
|
|
49
|
+
) => {
|
|
50
|
+
return customInstance<OrganisationsGetResponse>(
|
|
51
|
+
{ url: `/organisation`, method: "get" },
|
|
52
|
+
options
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const getGetOrganisationsQueryKey = () => [`/organisation`];
|
|
57
|
+
|
|
58
|
+
export const useGetOrganisations = <
|
|
59
|
+
TData = AsyncReturnType<typeof getOrganisations>,
|
|
60
|
+
TError = ErrorType<void | AsError>
|
|
61
|
+
>(options?: {
|
|
62
|
+
query?: UseQueryOptions<
|
|
63
|
+
AsyncReturnType<typeof getOrganisations>,
|
|
64
|
+
TError,
|
|
65
|
+
TData
|
|
66
|
+
>;
|
|
67
|
+
request?: SecondParameter<typeof customInstance>;
|
|
68
|
+
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
69
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
70
|
+
|
|
71
|
+
const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();
|
|
72
|
+
|
|
73
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>
|
|
74
|
+
getOrganisations(requestOptions);
|
|
75
|
+
|
|
76
|
+
const query = useQuery<
|
|
77
|
+
AsyncReturnType<typeof getOrganisations>,
|
|
78
|
+
TError,
|
|
79
|
+
TData
|
|
80
|
+
>(queryKey, queryFn, queryOptions);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
queryKey,
|
|
84
|
+
...query,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new Organisation
|
|
90
|
+
|
|
91
|
+
You need **admin** rights to use this method
|
|
92
|
+
|
|
93
|
+
* @summary Create a new organisation
|
|
94
|
+
*/
|
|
95
|
+
export const createOrganisation = (
|
|
96
|
+
organisationPostBodyBody: OrganisationPostBodyBody,
|
|
97
|
+
options?: SecondParameter<typeof customInstance>
|
|
98
|
+
) => {
|
|
99
|
+
return customInstance<OrganisationPostResponse>(
|
|
100
|
+
{ url: `/organisation`, method: "post", data: organisationPostBodyBody },
|
|
101
|
+
options
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const useCreateOrganisation = <
|
|
106
|
+
TError = ErrorType<AsError | void>,
|
|
107
|
+
TContext = unknown
|
|
108
|
+
>(options?: {
|
|
109
|
+
mutation?: UseMutationOptions<
|
|
110
|
+
AsyncReturnType<typeof createOrganisation>,
|
|
111
|
+
TError,
|
|
112
|
+
{ data: OrganisationPostBodyBody },
|
|
113
|
+
TContext
|
|
114
|
+
>;
|
|
115
|
+
request?: SecondParameter<typeof customInstance>;
|
|
116
|
+
}) => {
|
|
117
|
+
const { mutation: mutationOptions, request: requestOptions } = options || {};
|
|
118
|
+
|
|
119
|
+
const mutationFn: MutationFunction<
|
|
120
|
+
AsyncReturnType<typeof createOrganisation>,
|
|
121
|
+
{ data: OrganisationPostBodyBody }
|
|
122
|
+
> = (props) => {
|
|
123
|
+
const { data } = props || {};
|
|
124
|
+
|
|
125
|
+
return createOrganisation(data, requestOptions);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return useMutation<
|
|
129
|
+
AsyncReturnType<typeof createOrganisation>,
|
|
130
|
+
TError,
|
|
131
|
+
{ data: OrganisationPostBodyBody },
|
|
132
|
+
TContext
|
|
133
|
+
>(mutationFn, mutationOptions);
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Units must first be deleted before an Organisation can be deleted
|
|
137
|
+
|
|
138
|
+
You need **admin** rights to use this method
|
|
139
|
+
|
|
140
|
+
* @summary Deletes an Organisation
|
|
141
|
+
*/
|
|
142
|
+
export const deleteOrganisation = (
|
|
143
|
+
orgid: string,
|
|
144
|
+
options?: SecondParameter<typeof customInstance>
|
|
145
|
+
) => {
|
|
146
|
+
return customInstance<void>(
|
|
147
|
+
{ url: `/organisation/${orgid}`, method: "delete", data: undefined },
|
|
148
|
+
options
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const useDeleteOrganisation = <
|
|
153
|
+
TError = ErrorType<AsError>,
|
|
154
|
+
TContext = unknown
|
|
155
|
+
>(options?: {
|
|
156
|
+
mutation?: UseMutationOptions<
|
|
157
|
+
AsyncReturnType<typeof deleteOrganisation>,
|
|
158
|
+
TError,
|
|
159
|
+
{ orgid: string },
|
|
160
|
+
TContext
|
|
161
|
+
>;
|
|
162
|
+
request?: SecondParameter<typeof customInstance>;
|
|
163
|
+
}) => {
|
|
164
|
+
const { mutation: mutationOptions, request: requestOptions } = options || {};
|
|
165
|
+
|
|
166
|
+
const mutationFn: MutationFunction<
|
|
167
|
+
AsyncReturnType<typeof deleteOrganisation>,
|
|
168
|
+
{ orgid: string }
|
|
169
|
+
> = (props) => {
|
|
170
|
+
const { orgid } = props || {};
|
|
171
|
+
|
|
172
|
+
return deleteOrganisation(orgid, requestOptions);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return useMutation<
|
|
176
|
+
AsyncReturnType<typeof deleteOrganisation>,
|
|
177
|
+
TError,
|
|
178
|
+
{ orgid: string },
|
|
179
|
+
TContext
|
|
180
|
+
>(mutationFn, mutationOptions);
|
|
181
|
+
};
|