@squonk/account-server-client 2.0.4-rc.1 → 2.0.4-rc.3
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 +10 -14
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.ts +9 -3
- package/admin/admin.js +9 -13
- package/admin/admin.js.map +1 -1
- package/asset/asset.cjs +59 -28
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.ts +71 -3
- package/asset/asset.js +58 -27
- package/asset/asset.js.map +1 -1
- package/{custom-instance-85497958.d.ts → custom-instance-8a11f2d1.d.ts} +1 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +19 -16
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.ts +16 -4
- package/merchant/merchant.js +18 -15
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +64 -40
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +56 -6
- package/organisation/organisation.js +63 -39
- package/organisation/organisation.js.map +1 -1
- package/package.json +10 -9
- package/product/product.cjs +92 -55
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +79 -9
- package/product/product.js +91 -54
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +1 -1
- package/src/admin/admin.ts +34 -18
- package/src/asset/asset.ts +223 -88
- package/src/merchant/merchant.ts +60 -27
- package/src/organisation/organisation.ts +215 -97
- package/src/product/product.ts +310 -134
- package/src/state/state.ts +30 -15
- package/src/unit/unit.ts +263 -117
- package/src/user/user.ts +207 -88
- package/state/state.cjs +10 -11
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +9 -3
- package/state/state.js +9 -10
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +74 -46
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +70 -6
- package/unit/unit.js +73 -45
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +56 -31
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +63 -5
- package/user/user.js +55 -30
- package/user/user.js.map +1 -1
- package/chunk-7XN3IQYV.cjs +0 -13
- package/chunk-7XN3IQYV.cjs.map +0 -1
- package/chunk-YEX2SGER.js +0 -13
- package/chunk-YEX2SGER.js.map +0 -1
- package/src/queryMutator.ts +0 -12
package/src/state/state.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
2
|
+
* Generated by orval v6.15.0 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Account Server API
|
|
5
5
|
* The Informatics Matters Account Server API.
|
|
@@ -21,7 +21,6 @@ import type {
|
|
|
21
21
|
} from "../account-server-api.schemas";
|
|
22
22
|
import { customInstance } from ".././custom-instance";
|
|
23
23
|
import type { ErrorType } from ".././custom-instance";
|
|
24
|
-
import { queryMutator } from ".././queryMutator";
|
|
25
24
|
|
|
26
25
|
// eslint-disable-next-line
|
|
27
26
|
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
@@ -44,14 +43,9 @@ export const getVersion = (
|
|
|
44
43
|
);
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
export const getGetVersionQueryKey = () => [`/version`];
|
|
46
|
+
export const getGetVersionQueryKey = () => ["account-server-api", `/version`] as const;
|
|
48
47
|
|
|
49
|
-
export
|
|
50
|
-
Awaited<ReturnType<typeof getVersion>>
|
|
51
|
-
>;
|
|
52
|
-
export type GetVersionQueryError = ErrorType<AsError | void>;
|
|
53
|
-
|
|
54
|
-
export const useGetVersion = <
|
|
48
|
+
export const getGetVersionQueryOptions = <
|
|
55
49
|
TData = Awaited<ReturnType<typeof getVersion>>,
|
|
56
50
|
TError = ErrorType<AsError | void>
|
|
57
51
|
>(options?: {
|
|
@@ -61,7 +55,9 @@ export const useGetVersion = <
|
|
|
61
55
|
TData
|
|
62
56
|
>;
|
|
63
57
|
request?: SecondParameter<typeof customInstance>;
|
|
64
|
-
}):
|
|
58
|
+
}): UseQueryOptions<Awaited<ReturnType<typeof getVersion>>, TError, TData> & {
|
|
59
|
+
queryKey: QueryKey;
|
|
60
|
+
} => {
|
|
65
61
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
66
62
|
|
|
67
63
|
const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();
|
|
@@ -70,13 +66,32 @@ export const useGetVersion = <
|
|
|
70
66
|
signal,
|
|
71
67
|
}) => getVersion(requestOptions, signal);
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type GetVersionQueryResult = NonNullable<
|
|
73
|
+
Awaited<ReturnType<typeof getVersion>>
|
|
74
|
+
>;
|
|
75
|
+
export type GetVersionQueryError = ErrorType<AsError | void>;
|
|
76
|
+
|
|
77
|
+
export const useGetVersion = <
|
|
78
|
+
TData = Awaited<ReturnType<typeof getVersion>>,
|
|
79
|
+
TError = ErrorType<AsError | void>
|
|
80
|
+
>(options?: {
|
|
81
|
+
query?: UseQueryOptions<
|
|
82
|
+
Awaited<ReturnType<typeof getVersion>>,
|
|
83
|
+
TError,
|
|
84
|
+
TData
|
|
85
|
+
>;
|
|
86
|
+
request?: SecondParameter<typeof customInstance>;
|
|
87
|
+
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
88
|
+
const queryOptions = getGetVersionQueryOptions(options);
|
|
74
89
|
|
|
75
|
-
const query = useQuery
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
91
|
+
queryKey: QueryKey;
|
|
92
|
+
};
|
|
78
93
|
|
|
79
|
-
query.queryKey =
|
|
94
|
+
query.queryKey = queryOptions.queryKey;
|
|
80
95
|
|
|
81
96
|
return query;
|
|
82
97
|
};
|
package/src/unit/unit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
2
|
+
* Generated by orval v6.15.0 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Account Server API
|
|
5
5
|
* The Informatics Matters Account Server API.
|
|
@@ -32,7 +32,6 @@ import type {
|
|
|
32
32
|
} from "../account-server-api.schemas";
|
|
33
33
|
import { customInstance } from ".././custom-instance";
|
|
34
34
|
import type { ErrorType } from ".././custom-instance";
|
|
35
|
-
import { queryMutator } from ".././queryMutator";
|
|
36
35
|
|
|
37
36
|
// eslint-disable-next-line
|
|
38
37
|
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
@@ -58,16 +57,10 @@ export const getOrganisationUnits = (
|
|
|
58
57
|
);
|
|
59
58
|
};
|
|
60
59
|
|
|
61
|
-
export const getGetOrganisationUnitsQueryKey = (orgId: string) =>
|
|
62
|
-
`/organisation/${orgId}/unit
|
|
63
|
-
];
|
|
60
|
+
export const getGetOrganisationUnitsQueryKey = (orgId: string) =>
|
|
61
|
+
["account-server-api", `/organisation/${orgId}/unit`] as const;
|
|
64
62
|
|
|
65
|
-
export
|
|
66
|
-
Awaited<ReturnType<typeof getOrganisationUnits>>
|
|
67
|
-
>;
|
|
68
|
-
export type GetOrganisationUnitsQueryError = ErrorType<void | AsError>;
|
|
69
|
-
|
|
70
|
-
export const useGetOrganisationUnits = <
|
|
63
|
+
export const getGetOrganisationUnitsQueryOptions = <
|
|
71
64
|
TData = Awaited<ReturnType<typeof getOrganisationUnits>>,
|
|
72
65
|
TError = ErrorType<void | AsError>
|
|
73
66
|
>(
|
|
@@ -80,7 +73,11 @@ export const useGetOrganisationUnits = <
|
|
|
80
73
|
>;
|
|
81
74
|
request?: SecondParameter<typeof customInstance>;
|
|
82
75
|
}
|
|
83
|
-
):
|
|
76
|
+
): UseQueryOptions<
|
|
77
|
+
Awaited<ReturnType<typeof getOrganisationUnits>>,
|
|
78
|
+
TError,
|
|
79
|
+
TData
|
|
80
|
+
> & { queryKey: QueryKey } => {
|
|
84
81
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
85
82
|
|
|
86
83
|
const queryKey =
|
|
@@ -90,15 +87,35 @@ export const useGetOrganisationUnits = <
|
|
|
90
87
|
Awaited<ReturnType<typeof getOrganisationUnits>>
|
|
91
88
|
> = ({ signal }) => getOrganisationUnits(orgId, requestOptions, signal);
|
|
92
89
|
|
|
93
|
-
|
|
90
|
+
return { queryKey, queryFn, enabled: !!orgId, ...queryOptions };
|
|
91
|
+
};
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
+
};
|
|
100
117
|
|
|
101
|
-
query.queryKey =
|
|
118
|
+
query.queryKey = queryOptions.queryKey;
|
|
102
119
|
|
|
103
120
|
return query;
|
|
104
121
|
};
|
|
@@ -124,13 +141,7 @@ export const createOrganisationUnit = (
|
|
|
124
141
|
);
|
|
125
142
|
};
|
|
126
143
|
|
|
127
|
-
export
|
|
128
|
-
Awaited<ReturnType<typeof createOrganisationUnit>>
|
|
129
|
-
>;
|
|
130
|
-
export type CreateOrganisationUnitMutationBody = OrganisationUnitPostBodyBody;
|
|
131
|
-
export type CreateOrganisationUnitMutationError = ErrorType<AsError | void>;
|
|
132
|
-
|
|
133
|
-
export const useCreateOrganisationUnit = <
|
|
144
|
+
export const getCreateOrganisationUnitMutationOptions = <
|
|
134
145
|
TError = ErrorType<AsError | void>,
|
|
135
146
|
TContext = unknown
|
|
136
147
|
>(options?: {
|
|
@@ -141,7 +152,12 @@ export const useCreateOrganisationUnit = <
|
|
|
141
152
|
TContext
|
|
142
153
|
>;
|
|
143
154
|
request?: SecondParameter<typeof customInstance>;
|
|
144
|
-
})
|
|
155
|
+
}): UseMutationOptions<
|
|
156
|
+
Awaited<ReturnType<typeof createOrganisationUnit>>,
|
|
157
|
+
TError,
|
|
158
|
+
{ orgId: string; data: OrganisationUnitPostBodyBody },
|
|
159
|
+
TContext
|
|
160
|
+
> => {
|
|
145
161
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
146
162
|
|
|
147
163
|
const mutationFn: MutationFunction<
|
|
@@ -153,12 +169,30 @@ export const useCreateOrganisationUnit = <
|
|
|
153
169
|
return createOrganisationUnit(orgId, data, requestOptions);
|
|
154
170
|
};
|
|
155
171
|
|
|
156
|
-
return
|
|
172
|
+
return { mutationFn, ...mutationOptions };
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type CreateOrganisationUnitMutationResult = NonNullable<
|
|
176
|
+
Awaited<ReturnType<typeof createOrganisationUnit>>
|
|
177
|
+
>;
|
|
178
|
+
export type CreateOrganisationUnitMutationBody = OrganisationUnitPostBodyBody;
|
|
179
|
+
export type CreateOrganisationUnitMutationError = ErrorType<AsError | void>;
|
|
180
|
+
|
|
181
|
+
export const useCreateOrganisationUnit = <
|
|
182
|
+
TError = ErrorType<AsError | void>,
|
|
183
|
+
TContext = unknown
|
|
184
|
+
>(options?: {
|
|
185
|
+
mutation?: UseMutationOptions<
|
|
157
186
|
Awaited<ReturnType<typeof createOrganisationUnit>>,
|
|
158
187
|
TError,
|
|
159
188
|
{ orgId: string; data: OrganisationUnitPostBodyBody },
|
|
160
189
|
TContext
|
|
161
|
-
|
|
190
|
+
>;
|
|
191
|
+
request?: SecondParameter<typeof customInstance>;
|
|
192
|
+
}) => {
|
|
193
|
+
const mutationOptions = getCreateOrganisationUnitMutationOptions(options);
|
|
194
|
+
|
|
195
|
+
return useMutation(mutationOptions);
|
|
162
196
|
};
|
|
163
197
|
/**
|
|
164
198
|
* Gets the Unit, assuming you are a member of it or it is public. Admin users can see all Units
|
|
@@ -176,14 +210,10 @@ export const getUnit = (
|
|
|
176
210
|
);
|
|
177
211
|
};
|
|
178
212
|
|
|
179
|
-
export const getGetUnitQueryKey = (unitId: string) =>
|
|
180
|
-
|
|
181
|
-
export type GetUnitQueryResult = NonNullable<
|
|
182
|
-
Awaited<ReturnType<typeof getUnit>>
|
|
183
|
-
>;
|
|
184
|
-
export type GetUnitQueryError = ErrorType<void | AsError>;
|
|
213
|
+
export const getGetUnitQueryKey = (unitId: string) =>
|
|
214
|
+
["account-server-api", `/unit/${unitId}`] as const;
|
|
185
215
|
|
|
186
|
-
export const
|
|
216
|
+
export const getGetUnitQueryOptions = <
|
|
187
217
|
TData = Awaited<ReturnType<typeof getUnit>>,
|
|
188
218
|
TError = ErrorType<void | AsError>
|
|
189
219
|
>(
|
|
@@ -192,7 +222,9 @@ export const useGetUnit = <
|
|
|
192
222
|
query?: UseQueryOptions<Awaited<ReturnType<typeof getUnit>>, TError, TData>;
|
|
193
223
|
request?: SecondParameter<typeof customInstance>;
|
|
194
224
|
}
|
|
195
|
-
):
|
|
225
|
+
): UseQueryOptions<Awaited<ReturnType<typeof getUnit>>, TError, TData> & {
|
|
226
|
+
queryKey: QueryKey;
|
|
227
|
+
} => {
|
|
196
228
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
197
229
|
|
|
198
230
|
const queryKey = queryOptions?.queryKey ?? getGetUnitQueryKey(unitId);
|
|
@@ -201,13 +233,31 @@ export const useGetUnit = <
|
|
|
201
233
|
signal,
|
|
202
234
|
}) => getUnit(unitId, requestOptions, signal);
|
|
203
235
|
|
|
204
|
-
|
|
236
|
+
return { queryKey, queryFn, enabled: !!unitId, ...queryOptions };
|
|
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);
|
|
205
255
|
|
|
206
|
-
const query = useQuery
|
|
207
|
-
|
|
208
|
-
|
|
256
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
257
|
+
queryKey: QueryKey;
|
|
258
|
+
};
|
|
209
259
|
|
|
210
|
-
query.queryKey =
|
|
260
|
+
query.queryKey = queryOptions.queryKey;
|
|
211
261
|
|
|
212
262
|
return query;
|
|
213
263
|
};
|
|
@@ -224,29 +274,18 @@ export const patchUnit = (
|
|
|
224
274
|
unitPatchBodyBody: UnitPatchBodyBody,
|
|
225
275
|
options?: SecondParameter<typeof customInstance>
|
|
226
276
|
) => {
|
|
227
|
-
const formData = new FormData();
|
|
228
|
-
if (unitPatchBodyBody.name !== undefined) {
|
|
229
|
-
formData.append("name", unitPatchBodyBody.name);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
277
|
return customInstance<void>(
|
|
233
278
|
{
|
|
234
279
|
url: `/unit/${unitId}`,
|
|
235
280
|
method: "patch",
|
|
236
|
-
headers: { "Content-Type": "
|
|
237
|
-
data:
|
|
281
|
+
headers: { "Content-Type": "application/json" },
|
|
282
|
+
data: unitPatchBodyBody,
|
|
238
283
|
},
|
|
239
284
|
options
|
|
240
285
|
);
|
|
241
286
|
};
|
|
242
287
|
|
|
243
|
-
export
|
|
244
|
-
Awaited<ReturnType<typeof patchUnit>>
|
|
245
|
-
>;
|
|
246
|
-
export type PatchUnitMutationBody = UnitPatchBodyBody;
|
|
247
|
-
export type PatchUnitMutationError = ErrorType<AsError>;
|
|
248
|
-
|
|
249
|
-
export const usePatchUnit = <
|
|
288
|
+
export const getPatchUnitMutationOptions = <
|
|
250
289
|
TError = ErrorType<AsError>,
|
|
251
290
|
TContext = unknown
|
|
252
291
|
>(options?: {
|
|
@@ -257,7 +296,12 @@ export const usePatchUnit = <
|
|
|
257
296
|
TContext
|
|
258
297
|
>;
|
|
259
298
|
request?: SecondParameter<typeof customInstance>;
|
|
260
|
-
})
|
|
299
|
+
}): UseMutationOptions<
|
|
300
|
+
Awaited<ReturnType<typeof patchUnit>>,
|
|
301
|
+
TError,
|
|
302
|
+
{ unitId: string; data: UnitPatchBodyBody },
|
|
303
|
+
TContext
|
|
304
|
+
> => {
|
|
261
305
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
262
306
|
|
|
263
307
|
const mutationFn: MutationFunction<
|
|
@@ -269,12 +313,30 @@ export const usePatchUnit = <
|
|
|
269
313
|
return patchUnit(unitId, data, requestOptions);
|
|
270
314
|
};
|
|
271
315
|
|
|
272
|
-
return
|
|
316
|
+
return { mutationFn, ...mutationOptions };
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export type PatchUnitMutationResult = NonNullable<
|
|
320
|
+
Awaited<ReturnType<typeof patchUnit>>
|
|
321
|
+
>;
|
|
322
|
+
export type PatchUnitMutationBody = UnitPatchBodyBody;
|
|
323
|
+
export type PatchUnitMutationError = ErrorType<AsError>;
|
|
324
|
+
|
|
325
|
+
export const usePatchUnit = <
|
|
326
|
+
TError = ErrorType<AsError>,
|
|
327
|
+
TContext = unknown
|
|
328
|
+
>(options?: {
|
|
329
|
+
mutation?: UseMutationOptions<
|
|
273
330
|
Awaited<ReturnType<typeof patchUnit>>,
|
|
274
331
|
TError,
|
|
275
332
|
{ unitId: string; data: UnitPatchBodyBody },
|
|
276
333
|
TContext
|
|
277
|
-
|
|
334
|
+
>;
|
|
335
|
+
request?: SecondParameter<typeof customInstance>;
|
|
336
|
+
}) => {
|
|
337
|
+
const mutationOptions = getPatchUnitMutationOptions(options);
|
|
338
|
+
|
|
339
|
+
return useMutation(mutationOptions);
|
|
278
340
|
};
|
|
279
341
|
/**
|
|
280
342
|
* Deletes an Organisational Unit you have access to. Units can only be deleted by Organisation users or Admin users. You cannot delete a Unit that contains Products
|
|
@@ -291,13 +353,7 @@ export const deleteOrganisationUnit = (
|
|
|
291
353
|
);
|
|
292
354
|
};
|
|
293
355
|
|
|
294
|
-
export
|
|
295
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>
|
|
296
|
-
>;
|
|
297
|
-
|
|
298
|
-
export type DeleteOrganisationUnitMutationError = ErrorType<AsError>;
|
|
299
|
-
|
|
300
|
-
export const useDeleteOrganisationUnit = <
|
|
356
|
+
export const getDeleteOrganisationUnitMutationOptions = <
|
|
301
357
|
TError = ErrorType<AsError>,
|
|
302
358
|
TContext = unknown
|
|
303
359
|
>(options?: {
|
|
@@ -308,7 +364,12 @@ export const useDeleteOrganisationUnit = <
|
|
|
308
364
|
TContext
|
|
309
365
|
>;
|
|
310
366
|
request?: SecondParameter<typeof customInstance>;
|
|
311
|
-
})
|
|
367
|
+
}): UseMutationOptions<
|
|
368
|
+
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
369
|
+
TError,
|
|
370
|
+
{ unitId: string },
|
|
371
|
+
TContext
|
|
372
|
+
> => {
|
|
312
373
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
313
374
|
|
|
314
375
|
const mutationFn: MutationFunction<
|
|
@@ -320,12 +381,30 @@ export const useDeleteOrganisationUnit = <
|
|
|
320
381
|
return deleteOrganisationUnit(unitId, requestOptions);
|
|
321
382
|
};
|
|
322
383
|
|
|
323
|
-
return
|
|
384
|
+
return { mutationFn, ...mutationOptions };
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export type DeleteOrganisationUnitMutationResult = NonNullable<
|
|
388
|
+
Awaited<ReturnType<typeof deleteOrganisationUnit>>
|
|
389
|
+
>;
|
|
390
|
+
|
|
391
|
+
export type DeleteOrganisationUnitMutationError = ErrorType<AsError>;
|
|
392
|
+
|
|
393
|
+
export const useDeleteOrganisationUnit = <
|
|
394
|
+
TError = ErrorType<AsError>,
|
|
395
|
+
TContext = unknown
|
|
396
|
+
>(options?: {
|
|
397
|
+
mutation?: UseMutationOptions<
|
|
324
398
|
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
325
399
|
TError,
|
|
326
400
|
{ unitId: string },
|
|
327
401
|
TContext
|
|
328
|
-
|
|
402
|
+
>;
|
|
403
|
+
request?: SecondParameter<typeof customInstance>;
|
|
404
|
+
}) => {
|
|
405
|
+
const mutationOptions = getDeleteOrganisationUnitMutationOptions(options);
|
|
406
|
+
|
|
407
|
+
return useMutation(mutationOptions);
|
|
329
408
|
};
|
|
330
409
|
/**
|
|
331
410
|
* Gets all the Units that are public or you are a member of. Admin users can see all Units
|
|
@@ -342,20 +421,17 @@ export const getUnits = (
|
|
|
342
421
|
);
|
|
343
422
|
};
|
|
344
423
|
|
|
345
|
-
export const getGetUnitsQueryKey = () => [`/unit`];
|
|
346
|
-
|
|
347
|
-
export type GetUnitsQueryResult = NonNullable<
|
|
348
|
-
Awaited<ReturnType<typeof getUnits>>
|
|
349
|
-
>;
|
|
350
|
-
export type GetUnitsQueryError = ErrorType<void | AsError>;
|
|
424
|
+
export const getGetUnitsQueryKey = () => ["account-server-api", `/unit`] as const;
|
|
351
425
|
|
|
352
|
-
export const
|
|
426
|
+
export const getGetUnitsQueryOptions = <
|
|
353
427
|
TData = Awaited<ReturnType<typeof getUnits>>,
|
|
354
428
|
TError = ErrorType<void | AsError>
|
|
355
429
|
>(options?: {
|
|
356
430
|
query?: UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData>;
|
|
357
431
|
request?: SecondParameter<typeof customInstance>;
|
|
358
|
-
}):
|
|
432
|
+
}): UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData> & {
|
|
433
|
+
queryKey: QueryKey;
|
|
434
|
+
} => {
|
|
359
435
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
360
436
|
|
|
361
437
|
const queryKey = queryOptions?.queryKey ?? getGetUnitsQueryKey();
|
|
@@ -364,13 +440,28 @@ export const useGetUnits = <
|
|
|
364
440
|
signal,
|
|
365
441
|
}) => getUnits(requestOptions, signal);
|
|
366
442
|
|
|
367
|
-
|
|
443
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
444
|
+
};
|
|
368
445
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
446
|
+
export type GetUnitsQueryResult = NonNullable<
|
|
447
|
+
Awaited<ReturnType<typeof getUnits>>
|
|
448
|
+
>;
|
|
449
|
+
export type GetUnitsQueryError = ErrorType<void | AsError>;
|
|
372
450
|
|
|
373
|
-
|
|
451
|
+
export const useGetUnits = <
|
|
452
|
+
TData = Awaited<ReturnType<typeof getUnits>>,
|
|
453
|
+
TError = ErrorType<void | AsError>
|
|
454
|
+
>(options?: {
|
|
455
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData>;
|
|
456
|
+
request?: SecondParameter<typeof customInstance>;
|
|
457
|
+
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
458
|
+
const queryOptions = getGetUnitsQueryOptions(options);
|
|
459
|
+
|
|
460
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
461
|
+
queryKey: QueryKey;
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
query.queryKey = queryOptions.queryKey;
|
|
374
465
|
|
|
375
466
|
return query;
|
|
376
467
|
};
|
|
@@ -395,13 +486,7 @@ export const createDefaultUnit = (
|
|
|
395
486
|
);
|
|
396
487
|
};
|
|
397
488
|
|
|
398
|
-
export
|
|
399
|
-
Awaited<ReturnType<typeof createDefaultUnit>>
|
|
400
|
-
>;
|
|
401
|
-
export type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;
|
|
402
|
-
export type CreateDefaultUnitMutationError = ErrorType<AsError | void>;
|
|
403
|
-
|
|
404
|
-
export const useCreateDefaultUnit = <
|
|
489
|
+
export const getCreateDefaultUnitMutationOptions = <
|
|
405
490
|
TError = ErrorType<AsError | void>,
|
|
406
491
|
TContext = unknown
|
|
407
492
|
>(options?: {
|
|
@@ -412,7 +497,12 @@ export const useCreateDefaultUnit = <
|
|
|
412
497
|
TContext
|
|
413
498
|
>;
|
|
414
499
|
request?: SecondParameter<typeof customInstance>;
|
|
415
|
-
})
|
|
500
|
+
}): UseMutationOptions<
|
|
501
|
+
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
502
|
+
TError,
|
|
503
|
+
{ data: PersonalUnitPutBodyBody },
|
|
504
|
+
TContext
|
|
505
|
+
> => {
|
|
416
506
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
417
507
|
|
|
418
508
|
const mutationFn: MutationFunction<
|
|
@@ -424,12 +514,30 @@ export const useCreateDefaultUnit = <
|
|
|
424
514
|
return createDefaultUnit(data, requestOptions);
|
|
425
515
|
};
|
|
426
516
|
|
|
427
|
-
return
|
|
517
|
+
return { mutationFn, ...mutationOptions };
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
export type CreateDefaultUnitMutationResult = NonNullable<
|
|
521
|
+
Awaited<ReturnType<typeof createDefaultUnit>>
|
|
522
|
+
>;
|
|
523
|
+
export type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;
|
|
524
|
+
export type CreateDefaultUnitMutationError = ErrorType<AsError | void>;
|
|
525
|
+
|
|
526
|
+
export const useCreateDefaultUnit = <
|
|
527
|
+
TError = ErrorType<AsError | void>,
|
|
528
|
+
TContext = unknown
|
|
529
|
+
>(options?: {
|
|
530
|
+
mutation?: UseMutationOptions<
|
|
428
531
|
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
429
532
|
TError,
|
|
430
533
|
{ data: PersonalUnitPutBodyBody },
|
|
431
534
|
TContext
|
|
432
|
-
|
|
535
|
+
>;
|
|
536
|
+
request?: SecondParameter<typeof customInstance>;
|
|
537
|
+
}) => {
|
|
538
|
+
const mutationOptions = getCreateDefaultUnitMutationOptions(options);
|
|
539
|
+
|
|
540
|
+
return useMutation(mutationOptions);
|
|
433
541
|
};
|
|
434
542
|
/**
|
|
435
543
|
* Deletes a 'Personal' Unit. It must be your Unit, which belongs to the Default Organisation
|
|
@@ -442,13 +550,7 @@ export const deleteDefaultUnit = (
|
|
|
442
550
|
return customInstance<void>({ url: `/unit`, method: "delete" }, options);
|
|
443
551
|
};
|
|
444
552
|
|
|
445
|
-
export
|
|
446
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>
|
|
447
|
-
>;
|
|
448
|
-
|
|
449
|
-
export type DeleteDefaultUnitMutationError = ErrorType<AsError>;
|
|
450
|
-
|
|
451
|
-
export const useDeleteDefaultUnit = <
|
|
553
|
+
export const getDeleteDefaultUnitMutationOptions = <
|
|
452
554
|
TError = ErrorType<AsError>,
|
|
453
555
|
TVariables = void,
|
|
454
556
|
TContext = unknown
|
|
@@ -460,7 +562,12 @@ export const useDeleteDefaultUnit = <
|
|
|
460
562
|
TContext
|
|
461
563
|
>;
|
|
462
564
|
request?: SecondParameter<typeof customInstance>;
|
|
463
|
-
})
|
|
565
|
+
}): UseMutationOptions<
|
|
566
|
+
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
567
|
+
TError,
|
|
568
|
+
TVariables,
|
|
569
|
+
TContext
|
|
570
|
+
> => {
|
|
464
571
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
465
572
|
|
|
466
573
|
const mutationFn: MutationFunction<
|
|
@@ -470,12 +577,31 @@ export const useDeleteDefaultUnit = <
|
|
|
470
577
|
return deleteDefaultUnit(requestOptions);
|
|
471
578
|
};
|
|
472
579
|
|
|
473
|
-
return
|
|
580
|
+
return { mutationFn, ...mutationOptions };
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
export type DeleteDefaultUnitMutationResult = NonNullable<
|
|
584
|
+
Awaited<ReturnType<typeof deleteDefaultUnit>>
|
|
585
|
+
>;
|
|
586
|
+
|
|
587
|
+
export type DeleteDefaultUnitMutationError = ErrorType<AsError>;
|
|
588
|
+
|
|
589
|
+
export const useDeleteDefaultUnit = <
|
|
590
|
+
TError = ErrorType<AsError>,
|
|
591
|
+
TVariables = void,
|
|
592
|
+
TContext = unknown
|
|
593
|
+
>(options?: {
|
|
594
|
+
mutation?: UseMutationOptions<
|
|
474
595
|
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
475
596
|
TError,
|
|
476
597
|
TVariables,
|
|
477
598
|
TContext
|
|
478
|
-
|
|
599
|
+
>;
|
|
600
|
+
request?: SecondParameter<typeof customInstance>;
|
|
601
|
+
}) => {
|
|
602
|
+
const mutationOptions = getDeleteDefaultUnitMutationOptions(options);
|
|
603
|
+
|
|
604
|
+
return useMutation(mutationOptions);
|
|
479
605
|
};
|
|
480
606
|
/**
|
|
481
607
|
* 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.
|
|
@@ -502,14 +628,9 @@ export const getUnitCharges = (
|
|
|
502
628
|
export const getGetUnitChargesQueryKey = (
|
|
503
629
|
unitId: string,
|
|
504
630
|
params?: GetUnitChargesParams
|
|
505
|
-
) => [`/unit/${unitId}/charges`, ...(params ? [params] : [])];
|
|
631
|
+
) => ["account-server-api", `/unit/${unitId}/charges`, ...(params ? [params] : [])] as const;
|
|
506
632
|
|
|
507
|
-
export
|
|
508
|
-
Awaited<ReturnType<typeof getUnitCharges>>
|
|
509
|
-
>;
|
|
510
|
-
export type GetUnitChargesQueryError = ErrorType<AsError | void>;
|
|
511
|
-
|
|
512
|
-
export const useGetUnitCharges = <
|
|
633
|
+
export const getGetUnitChargesQueryOptions = <
|
|
513
634
|
TData = Awaited<ReturnType<typeof getUnitCharges>>,
|
|
514
635
|
TError = ErrorType<AsError | void>
|
|
515
636
|
>(
|
|
@@ -523,7 +644,11 @@ export const useGetUnitCharges = <
|
|
|
523
644
|
>;
|
|
524
645
|
request?: SecondParameter<typeof customInstance>;
|
|
525
646
|
}
|
|
526
|
-
):
|
|
647
|
+
): UseQueryOptions<
|
|
648
|
+
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
649
|
+
TError,
|
|
650
|
+
TData
|
|
651
|
+
> & { queryKey: QueryKey } => {
|
|
527
652
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
528
653
|
|
|
529
654
|
const queryKey =
|
|
@@ -533,15 +658,36 @@ export const useGetUnitCharges = <
|
|
|
533
658
|
signal,
|
|
534
659
|
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
535
660
|
|
|
536
|
-
|
|
661
|
+
return { queryKey, queryFn, enabled: !!unitId, ...queryOptions };
|
|
662
|
+
};
|
|
537
663
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
664
|
+
export type GetUnitChargesQueryResult = NonNullable<
|
|
665
|
+
Awaited<ReturnType<typeof getUnitCharges>>
|
|
666
|
+
>;
|
|
667
|
+
export type GetUnitChargesQueryError = ErrorType<AsError | void>;
|
|
668
|
+
|
|
669
|
+
export const useGetUnitCharges = <
|
|
670
|
+
TData = Awaited<ReturnType<typeof getUnitCharges>>,
|
|
671
|
+
TError = ErrorType<AsError | void>
|
|
672
|
+
>(
|
|
673
|
+
unitId: string,
|
|
674
|
+
params?: GetUnitChargesParams,
|
|
675
|
+
options?: {
|
|
676
|
+
query?: UseQueryOptions<
|
|
677
|
+
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
678
|
+
TError,
|
|
679
|
+
TData
|
|
680
|
+
>;
|
|
681
|
+
request?: SecondParameter<typeof customInstance>;
|
|
682
|
+
}
|
|
683
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
684
|
+
const queryOptions = getGetUnitChargesQueryOptions(unitId, params, options);
|
|
685
|
+
|
|
686
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
687
|
+
queryKey: QueryKey;
|
|
688
|
+
};
|
|
543
689
|
|
|
544
|
-
query.queryKey =
|
|
690
|
+
query.queryKey = queryOptions.queryKey;
|
|
545
691
|
|
|
546
692
|
return query;
|
|
547
693
|
};
|