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