@squonk/account-server-client 2.0.6 → 2.0.8
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/admin/admin.cjs +14 -7
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.cts +33 -0
- package/admin/admin.d.ts +4 -1
- package/admin/admin.js +14 -7
- package/admin/admin.js.map +1 -1
- package/asset/asset.cjs +44 -19
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.cts +241 -0
- package/asset/asset.d.ts +43 -19
- package/asset/asset.js +37 -12
- package/asset/asset.js.map +1 -1
- package/{chunk-UZTHSGDT.cjs → chunk-J22A7LHX.cjs} +1 -1
- package/chunk-J22A7LHX.cjs.map +1 -0
- package/{chunk-3RNIDX7T.js → chunk-UKA7G3OB.js} +1 -1
- package/{chunk-3RNIDX7T.js.map → chunk-UKA7G3OB.js.map} +1 -1
- package/{custom-instance-f32f6506.d.ts → custom-instance-13ade7a9.d.ts} +159 -159
- package/index.cjs +10 -10
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +1 -1
- package/index.js +9 -9
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +23 -13
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.cts +57 -0
- package/merchant/merchant.d.ts +7 -1
- package/merchant/merchant.js +22 -12
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +50 -25
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.cts +203 -0
- package/organisation/organisation.d.ts +31 -10
- package/organisation/organisation.js +44 -19
- package/organisation/organisation.js.map +1 -1
- package/package.json +12 -12
- package/product/product.cjs +80 -44
- package/product/product.cjs.map +1 -1
- package/product/product.d.cts +280 -0
- package/product/product.d.ts +40 -10
- package/product/product.js +71 -35
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +268 -276
- package/src/admin/admin.ts +72 -78
- package/src/asset/asset.ts +447 -556
- package/src/merchant/merchant.ts +125 -136
- package/src/organisation/organisation.ts +394 -484
- package/src/product/product.ts +557 -682
- package/src/state/state.ts +70 -69
- package/src/unit/unit.ts +494 -593
- package/src/user/user.ts +377 -463
- package/state/state.cjs +13 -7
- package/state/state.cjs.map +1 -1
- package/state/state.d.cts +29 -0
- package/state/state.d.ts +4 -1
- package/state/state.js +13 -7
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +59 -28
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.cts +254 -0
- package/unit/unit.d.ts +43 -16
- package/unit/unit.js +52 -21
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +52 -21
- package/user/user.cjs.map +1 -1
- package/user/user.d.cts +220 -0
- package/user/user.d.ts +31 -10
- package/user/user.js +46 -15
- package/user/user.js.map +1 -1
- package/chunk-UZTHSGDT.cjs.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.20.0 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Account Server API
|
|
5
5
|
* The Informatics Matters Account Server API.
|
|
@@ -8,117 +8,107 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 2.0
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useMutation,
|
|
13
|
+
useQuery
|
|
14
|
+
} from '@tanstack/react-query'
|
|
12
15
|
import type {
|
|
13
|
-
UseQueryOptions,
|
|
14
|
-
UseMutationOptions,
|
|
15
|
-
QueryFunction,
|
|
16
16
|
MutationFunction,
|
|
17
|
-
|
|
17
|
+
QueryFunction,
|
|
18
18
|
QueryKey,
|
|
19
|
-
|
|
19
|
+
UseMutationOptions,
|
|
20
|
+
UseQueryOptions,
|
|
21
|
+
UseQueryResult
|
|
22
|
+
} from '@tanstack/react-query'
|
|
20
23
|
import type {
|
|
21
|
-
OrganisationUnitsGetResponse,
|
|
22
24
|
AsError,
|
|
23
|
-
|
|
25
|
+
GetUnitChargesParams,
|
|
24
26
|
OrganisationUnitPostBodyBody,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
UnitsGetResponse,
|
|
28
|
-
PersonalUnitPutResponse,
|
|
27
|
+
OrganisationUnitPostResponse,
|
|
28
|
+
OrganisationUnitsGetResponse,
|
|
29
29
|
PersonalUnitPutBodyBody,
|
|
30
|
+
PersonalUnitPutResponse,
|
|
30
31
|
UnitChargesGetResponse,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
UnitDetail,
|
|
33
|
+
UnitPatchBodyBody,
|
|
34
|
+
UnitsGetResponse
|
|
35
|
+
} from '../account-server-api.schemas'
|
|
36
|
+
import { customInstance } from '.././custom-instance';
|
|
37
|
+
import type { ErrorType } from '.././custom-instance';
|
|
38
|
+
|
|
35
39
|
|
|
36
40
|
// eslint-disable-next-line
|
|
37
|
-
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
41
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
38
42
|
config: any,
|
|
39
|
-
args: infer P
|
|
43
|
+
args: infer P,
|
|
40
44
|
) => any
|
|
41
45
|
? P
|
|
42
46
|
: never;
|
|
43
47
|
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* Gets Organisational Units you have access to or that are public
|
|
46
51
|
|
|
47
52
|
* @summary Gets Organisational Units
|
|
48
53
|
*/
|
|
49
54
|
export const getOrganisationUnits = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
orgId: string,
|
|
56
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
57
|
+
) => {
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
return customInstance<OrganisationUnitsGetResponse>(
|
|
61
|
+
{url: `/organisation/${orgId}/unit`, method: 'get', signal
|
|
62
|
+
},
|
|
63
|
+
options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export const getGetOrganisationUnitsQueryKey = (orgId: string,) => {
|
|
68
|
+
|
|
69
|
+
return ["account-server-api", `/organisation/${orgId}/unit`] as const;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export const getGetOrganisationUnitsQueryOptions = <TData = Awaited<ReturnType<typeof getOrganisationUnits>>, TError = ErrorType<void | AsError>>(orgId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getOrganisationUnits>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
53
74
|
) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
orgId:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
TData
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const queryKey
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const queryFn: QueryFunction<
|
|
87
|
-
Awaited<ReturnType<typeof getOrganisationUnits>>
|
|
88
|
-
> = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);
|
|
89
|
-
|
|
90
|
-
return { queryKey, queryFn, enabled: !!orgId, ...queryOptions };
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type GetOrganisationUnitsQueryResult = NonNullable<
|
|
94
|
-
Awaited<ReturnType<typeof getOrganisationUnits>>
|
|
95
|
-
>;
|
|
96
|
-
export type GetOrganisationUnitsQueryError = ErrorType<void | AsError>;
|
|
97
|
-
|
|
98
|
-
export const useGetOrganisationUnits = <
|
|
99
|
-
TData = Awaited<ReturnType<typeof getOrganisationUnits>>,
|
|
100
|
-
TError = ErrorType<void | AsError>
|
|
101
|
-
>(
|
|
102
|
-
orgId: string,
|
|
103
|
-
options?: {
|
|
104
|
-
query?: UseQueryOptions<
|
|
105
|
-
Awaited<ReturnType<typeof getOrganisationUnits>>,
|
|
106
|
-
TError,
|
|
107
|
-
TData
|
|
108
|
-
>;
|
|
109
|
-
request?: SecondParameter<typeof customInstance>;
|
|
110
|
-
}
|
|
111
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
112
|
-
const queryOptions = getGetOrganisationUnitsQueryOptions(orgId, options);
|
|
113
|
-
|
|
114
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
115
|
-
queryKey: QueryKey;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
query.queryKey = queryOptions.queryKey;
|
|
75
|
+
|
|
76
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
77
|
+
|
|
78
|
+
const queryKey = queryOptions?.queryKey ?? getGetOrganisationUnitsQueryKey(orgId);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationUnits>>> = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getOrganisationUnits>>, TError, TData> & { queryKey: QueryKey }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type GetOrganisationUnitsQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationUnits>>>
|
|
92
|
+
export type GetOrganisationUnitsQueryError = ErrorType<void | AsError>
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @summary Gets Organisational Units
|
|
96
|
+
*/
|
|
97
|
+
export const useGetOrganisationUnits = <TData = Awaited<ReturnType<typeof getOrganisationUnits>>, TError = ErrorType<void | AsError>>(
|
|
98
|
+
orgId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getOrganisationUnits>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
99
|
+
|
|
100
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
101
|
+
|
|
102
|
+
const queryOptions = getGetOrganisationUnitsQueryOptions(orgId,options)
|
|
103
|
+
|
|
104
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
105
|
+
|
|
106
|
+
query.queryKey = queryOptions.queryKey ;
|
|
119
107
|
|
|
120
108
|
return query;
|
|
121
|
-
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
122
112
|
|
|
123
113
|
/**
|
|
124
114
|
* Creates a new Organisation Unit. You need to be a member of the **Organisation** or have administration rights to use this endpoint
|
|
@@ -126,141 +116,120 @@ export const useGetOrganisationUnits = <
|
|
|
126
116
|
* @summary Create a new Organisational Unit
|
|
127
117
|
*/
|
|
128
118
|
export const createOrganisationUnit = (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
url: `/organisation/${orgId}/unit`,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
data: organisationUnitPostBodyBody,
|
|
119
|
+
orgId: string,
|
|
120
|
+
organisationUnitPostBodyBody: OrganisationUnitPostBodyBody,
|
|
121
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
return customInstance<OrganisationUnitPostResponse>(
|
|
125
|
+
{url: `/organisation/${orgId}/unit`, method: 'post',
|
|
126
|
+
headers: {'Content-Type': 'application/json', },
|
|
127
|
+
data: organisationUnitPostBodyBody
|
|
139
128
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
>(options?: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
TError = ErrorType<AsError | void>,
|
|
183
|
-
TContext = unknown
|
|
184
|
-
>(options?: {
|
|
185
|
-
mutation?: UseMutationOptions<
|
|
186
|
-
Awaited<ReturnType<typeof createOrganisationUnit>>,
|
|
187
|
-
TError,
|
|
188
|
-
{ orgId: string; data: OrganisationUnitPostBodyBody },
|
|
189
|
-
TContext
|
|
190
|
-
>;
|
|
191
|
-
request?: SecondParameter<typeof customInstance>;
|
|
192
|
-
}) => {
|
|
193
|
-
const mutationOptions = getCreateOrganisationUnitMutationOptions(options);
|
|
194
|
-
|
|
195
|
-
return useMutation(mutationOptions);
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
129
|
+
options);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
export const getCreateOrganisationUnitMutationOptions = <TError = ErrorType<AsError | void>,
|
|
135
|
+
|
|
136
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createOrganisationUnit>>, TError,{orgId: string;data: OrganisationUnitPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
137
|
+
): UseMutationOptions<Awaited<ReturnType<typeof createOrganisationUnit>>, TError,{orgId: string;data: OrganisationUnitPostBodyBody}, TContext> => {
|
|
138
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createOrganisationUnit>>, {orgId: string;data: OrganisationUnitPostBodyBody}> = (props) => {
|
|
144
|
+
const {orgId,data} = props ?? {};
|
|
145
|
+
|
|
146
|
+
return createOrganisationUnit(orgId,data,requestOptions)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
return { mutationFn, ...mutationOptions }}
|
|
153
|
+
|
|
154
|
+
export type CreateOrganisationUnitMutationResult = NonNullable<Awaited<ReturnType<typeof createOrganisationUnit>>>
|
|
155
|
+
export type CreateOrganisationUnitMutationBody = OrganisationUnitPostBodyBody
|
|
156
|
+
export type CreateOrganisationUnitMutationError = ErrorType<AsError | void>
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @summary Create a new Organisational Unit
|
|
160
|
+
*/
|
|
161
|
+
export const useCreateOrganisationUnit = <TError = ErrorType<AsError | void>,
|
|
162
|
+
|
|
163
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createOrganisationUnit>>, TError,{orgId: string;data: OrganisationUnitPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
164
|
+
) => {
|
|
165
|
+
|
|
166
|
+
const mutationOptions = getCreateOrganisationUnitMutationOptions(options);
|
|
167
|
+
|
|
168
|
+
return useMutation(mutationOptions);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
198
171
|
* Gets a Unit, assuming it is public, you are a member of it or its **Organisation**. Admin users have access to all Units
|
|
199
172
|
|
|
200
173
|
* @summary Gets an Organisational Unit
|
|
201
174
|
*/
|
|
202
175
|
export const getUnit = (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
176
|
+
unitId: string,
|
|
177
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
178
|
+
) => {
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
return customInstance<UnitDetail>(
|
|
182
|
+
{url: `/unit/${unitId}`, method: 'get', signal
|
|
183
|
+
},
|
|
184
|
+
options);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
export const getGetUnitQueryKey = (unitId: string,) => {
|
|
189
|
+
|
|
190
|
+
return ["account-server-api", `/unit/${unitId}`] as const;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
export const getGetUnitQueryOptions = <TData = Awaited<ReturnType<typeof getUnit>>, TError = ErrorType<void | AsError>>(unitId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUnit>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
206
195
|
) => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
unitId:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
export type GetUnitQueryResult = NonNullable<
|
|
240
|
-
Awaited<ReturnType<typeof getUnit>>
|
|
241
|
-
>;
|
|
242
|
-
export type GetUnitQueryError = ErrorType<void | AsError>;
|
|
243
|
-
|
|
244
|
-
export const useGetUnit = <
|
|
245
|
-
TData = Awaited<ReturnType<typeof getUnit>>,
|
|
246
|
-
TError = ErrorType<void | AsError>
|
|
247
|
-
>(
|
|
248
|
-
unitId: string,
|
|
249
|
-
options?: {
|
|
250
|
-
query?: UseQueryOptions<Awaited<ReturnType<typeof getUnit>>, TError, TData>;
|
|
251
|
-
request?: SecondParameter<typeof customInstance>;
|
|
252
|
-
}
|
|
253
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
254
|
-
const queryOptions = getGetUnitQueryOptions(unitId, options);
|
|
255
|
-
|
|
256
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
257
|
-
queryKey: QueryKey;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
query.queryKey = queryOptions.queryKey;
|
|
196
|
+
|
|
197
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
198
|
+
|
|
199
|
+
const queryKey = queryOptions?.queryKey ?? getGetUnitQueryKey(unitId);
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnit>>> = ({ signal }) => getUnit(unitId, requestOptions, signal);
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getUnit>>, TError, TData> & { queryKey: QueryKey }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type GetUnitQueryResult = NonNullable<Awaited<ReturnType<typeof getUnit>>>
|
|
213
|
+
export type GetUnitQueryError = ErrorType<void | AsError>
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @summary Gets an Organisational Unit
|
|
217
|
+
*/
|
|
218
|
+
export const useGetUnit = <TData = Awaited<ReturnType<typeof getUnit>>, TError = ErrorType<void | AsError>>(
|
|
219
|
+
unitId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUnit>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
220
|
+
|
|
221
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
222
|
+
|
|
223
|
+
const queryOptions = getGetUnitQueryOptions(unitId,options)
|
|
224
|
+
|
|
225
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
226
|
+
|
|
227
|
+
query.queryKey = queryOptions.queryKey ;
|
|
261
228
|
|
|
262
229
|
return query;
|
|
263
|
-
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
264
233
|
|
|
265
234
|
/**
|
|
266
235
|
* Used to update existing Unit.
|
|
@@ -270,75 +239,58 @@ You have to be the Unit owner, a member of its **Organisation** or an administra
|
|
|
270
239
|
* @summary Adjust an existing Unit
|
|
271
240
|
*/
|
|
272
241
|
export const patchUnit = (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
url: `/unit/${unitId}`,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
data: unitPatchBodyBody,
|
|
242
|
+
unitId: string,
|
|
243
|
+
unitPatchBodyBody: UnitPatchBodyBody,
|
|
244
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
return customInstance<void>(
|
|
248
|
+
{url: `/unit/${unitId}`, method: 'patch',
|
|
249
|
+
headers: {'Content-Type': 'application/json', },
|
|
250
|
+
data: unitPatchBodyBody
|
|
283
251
|
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
>(options?: {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
TError = ErrorType<AsError>,
|
|
327
|
-
TContext = unknown
|
|
328
|
-
>(options?: {
|
|
329
|
-
mutation?: UseMutationOptions<
|
|
330
|
-
Awaited<ReturnType<typeof patchUnit>>,
|
|
331
|
-
TError,
|
|
332
|
-
{ unitId: string; data: UnitPatchBodyBody },
|
|
333
|
-
TContext
|
|
334
|
-
>;
|
|
335
|
-
request?: SecondParameter<typeof customInstance>;
|
|
336
|
-
}) => {
|
|
337
|
-
const mutationOptions = getPatchUnitMutationOptions(options);
|
|
338
|
-
|
|
339
|
-
return useMutation(mutationOptions);
|
|
340
|
-
};
|
|
341
|
-
/**
|
|
252
|
+
options);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
export const getPatchUnitMutationOptions = <TError = ErrorType<AsError>,
|
|
258
|
+
|
|
259
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchUnit>>, TError,{unitId: string;data: UnitPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
260
|
+
): UseMutationOptions<Awaited<ReturnType<typeof patchUnit>>, TError,{unitId: string;data: UnitPatchBodyBody}, TContext> => {
|
|
261
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof patchUnit>>, {unitId: string;data: UnitPatchBodyBody}> = (props) => {
|
|
267
|
+
const {unitId,data} = props ?? {};
|
|
268
|
+
|
|
269
|
+
return patchUnit(unitId,data,requestOptions)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
return { mutationFn, ...mutationOptions }}
|
|
276
|
+
|
|
277
|
+
export type PatchUnitMutationResult = NonNullable<Awaited<ReturnType<typeof patchUnit>>>
|
|
278
|
+
export type PatchUnitMutationBody = UnitPatchBodyBody
|
|
279
|
+
export type PatchUnitMutationError = ErrorType<AsError>
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @summary Adjust an existing Unit
|
|
283
|
+
*/
|
|
284
|
+
export const usePatchUnit = <TError = ErrorType<AsError>,
|
|
285
|
+
|
|
286
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchUnit>>, TError,{unitId: string;data: UnitPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
287
|
+
) => {
|
|
288
|
+
|
|
289
|
+
const mutationOptions = getPatchUnitMutationOptions(options);
|
|
290
|
+
|
|
291
|
+
return useMutation(mutationOptions);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
342
294
|
* Deletes an Organisational Unit you have access to. Units can only be deleted by members of the Unit, its Organisation users or admin users.
|
|
343
295
|
|
|
344
296
|
You cannot delete Units in the **Default Organisation**. These Units are **Personal Units** and need to be deleted using the `DELETE /unit` endpoint.
|
|
@@ -348,127 +300,117 @@ You cannot delete a Unit that contains undeleted **Products**
|
|
|
348
300
|
* @summary Deletes an Organisational Unit
|
|
349
301
|
*/
|
|
350
302
|
export const deleteOrganisationUnit = (
|
|
351
|
-
|
|
352
|
-
|
|
303
|
+
unitId: string,
|
|
304
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
return customInstance<void>(
|
|
308
|
+
{url: `/unit/${unitId}`, method: 'delete'
|
|
309
|
+
},
|
|
310
|
+
options);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
export const getDeleteOrganisationUnitMutationOptions = <TError = ErrorType<AsError>,
|
|
316
|
+
|
|
317
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteOrganisationUnit>>, TError,{unitId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
318
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteOrganisationUnit>>, TError,{unitId: string}, TContext> => {
|
|
319
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteOrganisationUnit>>, {unitId: string}> = (props) => {
|
|
325
|
+
const {unitId} = props ?? {};
|
|
326
|
+
|
|
327
|
+
return deleteOrganisationUnit(unitId,requestOptions)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
return { mutationFn, ...mutationOptions }}
|
|
334
|
+
|
|
335
|
+
export type DeleteOrganisationUnitMutationResult = NonNullable<Awaited<ReturnType<typeof deleteOrganisationUnit>>>
|
|
336
|
+
|
|
337
|
+
export type DeleteOrganisationUnitMutationError = ErrorType<AsError>
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @summary Deletes an Organisational Unit
|
|
341
|
+
*/
|
|
342
|
+
export const useDeleteOrganisationUnit = <TError = ErrorType<AsError>,
|
|
343
|
+
|
|
344
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteOrganisationUnit>>, TError,{unitId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
353
345
|
) => {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export const getDeleteOrganisationUnitMutationOptions = <
|
|
361
|
-
TError = ErrorType<AsError>,
|
|
362
|
-
TContext = unknown
|
|
363
|
-
>(options?: {
|
|
364
|
-
mutation?: UseMutationOptions<
|
|
365
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
366
|
-
TError,
|
|
367
|
-
{ unitId: string },
|
|
368
|
-
TContext
|
|
369
|
-
>;
|
|
370
|
-
request?: SecondParameter<typeof customInstance>;
|
|
371
|
-
}): UseMutationOptions<
|
|
372
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
373
|
-
TError,
|
|
374
|
-
{ unitId: string },
|
|
375
|
-
TContext
|
|
376
|
-
> => {
|
|
377
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
378
|
-
|
|
379
|
-
const mutationFn: MutationFunction<
|
|
380
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
381
|
-
{ unitId: string }
|
|
382
|
-
> = (props) => {
|
|
383
|
-
const { unitId } = props ?? {};
|
|
384
|
-
|
|
385
|
-
return deleteOrganisationUnit(unitId, requestOptions);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
return { mutationFn, ...mutationOptions };
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
export type DeleteOrganisationUnitMutationResult = NonNullable<
|
|
392
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>
|
|
393
|
-
>;
|
|
394
|
-
|
|
395
|
-
export type DeleteOrganisationUnitMutationError = ErrorType<AsError>;
|
|
396
|
-
|
|
397
|
-
export const useDeleteOrganisationUnit = <
|
|
398
|
-
TError = ErrorType<AsError>,
|
|
399
|
-
TContext = unknown
|
|
400
|
-
>(options?: {
|
|
401
|
-
mutation?: UseMutationOptions<
|
|
402
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
403
|
-
TError,
|
|
404
|
-
{ unitId: string },
|
|
405
|
-
TContext
|
|
406
|
-
>;
|
|
407
|
-
request?: SecondParameter<typeof customInstance>;
|
|
408
|
-
}) => {
|
|
409
|
-
const mutationOptions = getDeleteOrganisationUnitMutationOptions(options);
|
|
410
|
-
|
|
411
|
-
return useMutation(mutationOptions);
|
|
412
|
-
};
|
|
413
|
-
/**
|
|
346
|
+
|
|
347
|
+
const mutationOptions = getDeleteOrganisationUnitMutationOptions(options);
|
|
348
|
+
|
|
349
|
+
return useMutation(mutationOptions);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
414
352
|
* Gets all the Units that are public or you are a member of. Admin users can see all Units.
|
|
415
353
|
|
|
416
354
|
* @summary Gets Units
|
|
417
355
|
*/
|
|
418
356
|
export const getUnits = (
|
|
419
|
-
|
|
420
|
-
|
|
357
|
+
|
|
358
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
421
359
|
) => {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
export
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
query
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
return customInstance<UnitsGetResponse>(
|
|
363
|
+
{url: `/unit`, method: 'get', signal
|
|
364
|
+
},
|
|
365
|
+
options);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
export const getGetUnitsQueryKey = () => {
|
|
370
|
+
|
|
371
|
+
return ["account-server-api", `/unit`] as const;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
export const getGetUnitsQueryOptions = <TData = Awaited<ReturnType<typeof getUnits>>, TError = ErrorType<void | AsError>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
376
|
+
) => {
|
|
377
|
+
|
|
378
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
379
|
+
|
|
380
|
+
const queryKey = queryOptions?.queryKey ?? getGetUnitsQueryKey();
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnits>>> = ({ signal }) => getUnits(requestOptions, signal);
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData> & { queryKey: QueryKey }
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export type GetUnitsQueryResult = NonNullable<Awaited<ReturnType<typeof getUnits>>>
|
|
394
|
+
export type GetUnitsQueryError = ErrorType<void | AsError>
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @summary Gets Units
|
|
398
|
+
*/
|
|
399
|
+
export const useGetUnits = <TData = Awaited<ReturnType<typeof getUnits>>, TError = ErrorType<void | AsError>>(
|
|
400
|
+
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
401
|
+
|
|
402
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
403
|
+
|
|
404
|
+
const queryOptions = getGetUnitsQueryOptions(options)
|
|
405
|
+
|
|
406
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
407
|
+
|
|
408
|
+
query.queryKey = queryOptions.queryKey ;
|
|
469
409
|
|
|
470
410
|
return query;
|
|
471
|
-
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
472
414
|
|
|
473
415
|
/**
|
|
474
416
|
* Creates a Personal Unit for a User. The unit will belong to the built-in **Default Organisation**.
|
|
@@ -478,138 +420,111 @@ Users can only create one Personal unit and you cannot add other Users to a Pers
|
|
|
478
420
|
* @summary Create a new Personal Unit
|
|
479
421
|
*/
|
|
480
422
|
export const createDefaultUnit = (
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
url: `/unit`,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
data: personalUnitPutBodyBody,
|
|
423
|
+
personalUnitPutBodyBody: PersonalUnitPutBodyBody,
|
|
424
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
return customInstance<PersonalUnitPutResponse>(
|
|
428
|
+
{url: `/unit`, method: 'put',
|
|
429
|
+
headers: {'Content-Type': 'application/json', },
|
|
430
|
+
data: personalUnitPutBodyBody
|
|
490
431
|
},
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
>(options?: {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
TError = ErrorType<AsError | void>,
|
|
534
|
-
TContext = unknown
|
|
535
|
-
>(options?: {
|
|
536
|
-
mutation?: UseMutationOptions<
|
|
537
|
-
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
538
|
-
TError,
|
|
539
|
-
{ data: PersonalUnitPutBodyBody },
|
|
540
|
-
TContext
|
|
541
|
-
>;
|
|
542
|
-
request?: SecondParameter<typeof customInstance>;
|
|
543
|
-
}) => {
|
|
544
|
-
const mutationOptions = getCreateDefaultUnitMutationOptions(options);
|
|
545
|
-
|
|
546
|
-
return useMutation(mutationOptions);
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
432
|
+
options);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
export const getCreateDefaultUnitMutationOptions = <TError = ErrorType<AsError | void>,
|
|
438
|
+
|
|
439
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createDefaultUnit>>, TError,{data: PersonalUnitPutBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
440
|
+
): UseMutationOptions<Awaited<ReturnType<typeof createDefaultUnit>>, TError,{data: PersonalUnitPutBodyBody}, TContext> => {
|
|
441
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createDefaultUnit>>, {data: PersonalUnitPutBodyBody}> = (props) => {
|
|
447
|
+
const {data} = props ?? {};
|
|
448
|
+
|
|
449
|
+
return createDefaultUnit(data,requestOptions)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
return { mutationFn, ...mutationOptions }}
|
|
456
|
+
|
|
457
|
+
export type CreateDefaultUnitMutationResult = NonNullable<Awaited<ReturnType<typeof createDefaultUnit>>>
|
|
458
|
+
export type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody
|
|
459
|
+
export type CreateDefaultUnitMutationError = ErrorType<AsError | void>
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @summary Create a new Personal Unit
|
|
463
|
+
*/
|
|
464
|
+
export const useCreateDefaultUnit = <TError = ErrorType<AsError | void>,
|
|
465
|
+
|
|
466
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createDefaultUnit>>, TError,{data: PersonalUnitPutBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
467
|
+
) => {
|
|
468
|
+
|
|
469
|
+
const mutationOptions = getCreateDefaultUnitMutationOptions(options);
|
|
470
|
+
|
|
471
|
+
return useMutation(mutationOptions);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
549
474
|
* Deletes a Personal Unit. The Unit is *your* Unit, and belongs to the **Default Organisation**
|
|
550
475
|
|
|
551
476
|
* @summary Deletes a Personal Unit
|
|
552
477
|
*/
|
|
553
478
|
export const deleteDefaultUnit = (
|
|
554
|
-
|
|
479
|
+
|
|
480
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
return customInstance<void>(
|
|
484
|
+
{url: `/unit`, method: 'delete'
|
|
485
|
+
},
|
|
486
|
+
options);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
export const getDeleteDefaultUnitMutationOptions = <TError = ErrorType<AsError>,
|
|
492
|
+
TVariables = void,
|
|
493
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteDefaultUnit>>, TError,TVariables, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
494
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteDefaultUnit>>, TError,TVariables, TContext> => {
|
|
495
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteDefaultUnit>>, TVariables> = () => {
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
return deleteDefaultUnit(requestOptions)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
return { mutationFn, ...mutationOptions }}
|
|
510
|
+
|
|
511
|
+
export type DeleteDefaultUnitMutationResult = NonNullable<Awaited<ReturnType<typeof deleteDefaultUnit>>>
|
|
512
|
+
|
|
513
|
+
export type DeleteDefaultUnitMutationError = ErrorType<AsError>
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @summary Deletes a Personal Unit
|
|
517
|
+
*/
|
|
518
|
+
export const useDeleteDefaultUnit = <TError = ErrorType<AsError>,
|
|
519
|
+
TVariables = void,
|
|
520
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteDefaultUnit>>, TError,TVariables, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
555
521
|
) => {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
TContext = unknown
|
|
563
|
-
>(options?: {
|
|
564
|
-
mutation?: UseMutationOptions<
|
|
565
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
566
|
-
TError,
|
|
567
|
-
TVariables,
|
|
568
|
-
TContext
|
|
569
|
-
>;
|
|
570
|
-
request?: SecondParameter<typeof customInstance>;
|
|
571
|
-
}): UseMutationOptions<
|
|
572
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
573
|
-
TError,
|
|
574
|
-
TVariables,
|
|
575
|
-
TContext
|
|
576
|
-
> => {
|
|
577
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
578
|
-
|
|
579
|
-
const mutationFn: MutationFunction<
|
|
580
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
581
|
-
TVariables
|
|
582
|
-
> = () => {
|
|
583
|
-
return deleteDefaultUnit(requestOptions);
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
return { mutationFn, ...mutationOptions };
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
export type DeleteDefaultUnitMutationResult = NonNullable<
|
|
590
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>
|
|
591
|
-
>;
|
|
592
|
-
|
|
593
|
-
export type DeleteDefaultUnitMutationError = ErrorType<AsError>;
|
|
594
|
-
|
|
595
|
-
export const useDeleteDefaultUnit = <
|
|
596
|
-
TError = ErrorType<AsError>,
|
|
597
|
-
TVariables = void,
|
|
598
|
-
TContext = unknown
|
|
599
|
-
>(options?: {
|
|
600
|
-
mutation?: UseMutationOptions<
|
|
601
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
602
|
-
TError,
|
|
603
|
-
TVariables,
|
|
604
|
-
TContext
|
|
605
|
-
>;
|
|
606
|
-
request?: SecondParameter<typeof customInstance>;
|
|
607
|
-
}) => {
|
|
608
|
-
const mutationOptions = getDeleteDefaultUnitMutationOptions(options);
|
|
609
|
-
|
|
610
|
-
return useMutation(mutationOptions);
|
|
611
|
-
};
|
|
612
|
-
/**
|
|
522
|
+
|
|
523
|
+
const mutationOptions = getDeleteDefaultUnitMutationOptions(options);
|
|
524
|
+
|
|
525
|
+
return useMutation(mutationOptions);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
613
528
|
* Get the charges made against a Unit with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.
|
|
614
529
|
Dates are interpreted using the Python `dateutil` parser, so the input strings are extremely flexible with, for example, `1 December 2021` as an acceptable input.
|
|
615
530
|
|
|
@@ -619,80 +534,66 @@ You need to be part of the **Unit** or **Organisation** to use this method
|
|
|
619
534
|
* @summary Get charges made against a Unit
|
|
620
535
|
*/
|
|
621
536
|
export const getUnitCharges = (
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
signal?: AbortSignal
|
|
537
|
+
unitId: string,
|
|
538
|
+
params?: GetUnitChargesParams,
|
|
539
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
626
540
|
) => {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
query?:
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
export
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
>
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
options?: {
|
|
681
|
-
query?: UseQueryOptions<
|
|
682
|
-
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
683
|
-
TError,
|
|
684
|
-
TData
|
|
685
|
-
>;
|
|
686
|
-
request?: SecondParameter<typeof customInstance>;
|
|
687
|
-
}
|
|
688
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
689
|
-
const queryOptions = getGetUnitChargesQueryOptions(unitId, params, options);
|
|
690
|
-
|
|
691
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
692
|
-
queryKey: QueryKey;
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
query.queryKey = queryOptions.queryKey;
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
return customInstance<UnitChargesGetResponse>(
|
|
544
|
+
{url: `/unit/${unitId}/charges`, method: 'get',
|
|
545
|
+
params, signal
|
|
546
|
+
},
|
|
547
|
+
options);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
export const getGetUnitChargesQueryKey = (unitId: string,
|
|
552
|
+
params?: GetUnitChargesParams,) => {
|
|
553
|
+
|
|
554
|
+
return ["account-server-api", `/unit/${unitId}/charges`, ...(params ? [params]: [])] as const;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
export const getGetUnitChargesQueryOptions = <TData = Awaited<ReturnType<typeof getUnitCharges>>, TError = ErrorType<AsError | void>>(unitId: string,
|
|
559
|
+
params?: GetUnitChargesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
560
|
+
) => {
|
|
561
|
+
|
|
562
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
563
|
+
|
|
564
|
+
const queryKey = queryOptions?.queryKey ?? getGetUnitChargesQueryKey(unitId,params);
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnitCharges>>> = ({ signal }) => getUnitCharges(unitId,params, requestOptions, signal);
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export type GetUnitChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getUnitCharges>>>
|
|
578
|
+
export type GetUnitChargesQueryError = ErrorType<AsError | void>
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @summary Get charges made against a Unit
|
|
582
|
+
*/
|
|
583
|
+
export const useGetUnitCharges = <TData = Awaited<ReturnType<typeof getUnitCharges>>, TError = ErrorType<AsError | void>>(
|
|
584
|
+
unitId: string,
|
|
585
|
+
params?: GetUnitChargesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
586
|
+
|
|
587
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
588
|
+
|
|
589
|
+
const queryOptions = getGetUnitChargesQueryOptions(unitId,params,options)
|
|
590
|
+
|
|
591
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
592
|
+
|
|
593
|
+
query.queryKey = queryOptions.queryKey ;
|
|
696
594
|
|
|
697
595
|
return query;
|
|
698
|
-
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|