@squonk/account-server-client 2.0.4-rc.2 → 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 +62 -34
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +56 -6
- package/organisation/organisation.js +61 -33
- 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 +213 -90
- package/src/product/product.ts +310 -134
- package/src/state/state.ts +30 -15
- package/src/unit/unit.ts +261 -110
- 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 +72 -40
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +70 -6
- package/unit/unit.js +71 -39
- 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) =>
|
|
213
|
+
export const getGetUnitQueryKey = (unitId: string) =>
|
|
214
|
+
["account-server-api", `/unit/${unitId}`] as const;
|
|
180
215
|
|
|
181
|
-
export
|
|
182
|
-
Awaited<ReturnType<typeof getUnit>>
|
|
183
|
-
>;
|
|
184
|
-
export type GetUnitQueryError = ErrorType<void | AsError>;
|
|
185
|
-
|
|
186
|
-
export const useGetUnit = <
|
|
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
|
+
};
|
|
205
238
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
239
|
+
export type GetUnitQueryResult = NonNullable<
|
|
240
|
+
Awaited<ReturnType<typeof getUnit>>
|
|
241
|
+
>;
|
|
242
|
+
export type GetUnitQueryError = ErrorType<void | AsError>;
|
|
209
243
|
|
|
210
|
-
|
|
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;
|
|
211
261
|
|
|
212
262
|
return query;
|
|
213
263
|
};
|
|
@@ -235,13 +285,7 @@ export const patchUnit = (
|
|
|
235
285
|
);
|
|
236
286
|
};
|
|
237
287
|
|
|
238
|
-
export
|
|
239
|
-
Awaited<ReturnType<typeof patchUnit>>
|
|
240
|
-
>;
|
|
241
|
-
export type PatchUnitMutationBody = UnitPatchBodyBody;
|
|
242
|
-
export type PatchUnitMutationError = ErrorType<AsError>;
|
|
243
|
-
|
|
244
|
-
export const usePatchUnit = <
|
|
288
|
+
export const getPatchUnitMutationOptions = <
|
|
245
289
|
TError = ErrorType<AsError>,
|
|
246
290
|
TContext = unknown
|
|
247
291
|
>(options?: {
|
|
@@ -252,7 +296,12 @@ export const usePatchUnit = <
|
|
|
252
296
|
TContext
|
|
253
297
|
>;
|
|
254
298
|
request?: SecondParameter<typeof customInstance>;
|
|
255
|
-
})
|
|
299
|
+
}): UseMutationOptions<
|
|
300
|
+
Awaited<ReturnType<typeof patchUnit>>,
|
|
301
|
+
TError,
|
|
302
|
+
{ unitId: string; data: UnitPatchBodyBody },
|
|
303
|
+
TContext
|
|
304
|
+
> => {
|
|
256
305
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
257
306
|
|
|
258
307
|
const mutationFn: MutationFunction<
|
|
@@ -264,12 +313,30 @@ export const usePatchUnit = <
|
|
|
264
313
|
return patchUnit(unitId, data, requestOptions);
|
|
265
314
|
};
|
|
266
315
|
|
|
267
|
-
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<
|
|
268
330
|
Awaited<ReturnType<typeof patchUnit>>,
|
|
269
331
|
TError,
|
|
270
332
|
{ unitId: string; data: UnitPatchBodyBody },
|
|
271
333
|
TContext
|
|
272
|
-
|
|
334
|
+
>;
|
|
335
|
+
request?: SecondParameter<typeof customInstance>;
|
|
336
|
+
}) => {
|
|
337
|
+
const mutationOptions = getPatchUnitMutationOptions(options);
|
|
338
|
+
|
|
339
|
+
return useMutation(mutationOptions);
|
|
273
340
|
};
|
|
274
341
|
/**
|
|
275
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
|
|
@@ -286,13 +353,7 @@ export const deleteOrganisationUnit = (
|
|
|
286
353
|
);
|
|
287
354
|
};
|
|
288
355
|
|
|
289
|
-
export
|
|
290
|
-
Awaited<ReturnType<typeof deleteOrganisationUnit>>
|
|
291
|
-
>;
|
|
292
|
-
|
|
293
|
-
export type DeleteOrganisationUnitMutationError = ErrorType<AsError>;
|
|
294
|
-
|
|
295
|
-
export const useDeleteOrganisationUnit = <
|
|
356
|
+
export const getDeleteOrganisationUnitMutationOptions = <
|
|
296
357
|
TError = ErrorType<AsError>,
|
|
297
358
|
TContext = unknown
|
|
298
359
|
>(options?: {
|
|
@@ -303,7 +364,12 @@ export const useDeleteOrganisationUnit = <
|
|
|
303
364
|
TContext
|
|
304
365
|
>;
|
|
305
366
|
request?: SecondParameter<typeof customInstance>;
|
|
306
|
-
})
|
|
367
|
+
}): UseMutationOptions<
|
|
368
|
+
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
369
|
+
TError,
|
|
370
|
+
{ unitId: string },
|
|
371
|
+
TContext
|
|
372
|
+
> => {
|
|
307
373
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
308
374
|
|
|
309
375
|
const mutationFn: MutationFunction<
|
|
@@ -315,12 +381,30 @@ export const useDeleteOrganisationUnit = <
|
|
|
315
381
|
return deleteOrganisationUnit(unitId, requestOptions);
|
|
316
382
|
};
|
|
317
383
|
|
|
318
|
-
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<
|
|
319
398
|
Awaited<ReturnType<typeof deleteOrganisationUnit>>,
|
|
320
399
|
TError,
|
|
321
400
|
{ unitId: string },
|
|
322
401
|
TContext
|
|
323
|
-
|
|
402
|
+
>;
|
|
403
|
+
request?: SecondParameter<typeof customInstance>;
|
|
404
|
+
}) => {
|
|
405
|
+
const mutationOptions = getDeleteOrganisationUnitMutationOptions(options);
|
|
406
|
+
|
|
407
|
+
return useMutation(mutationOptions);
|
|
324
408
|
};
|
|
325
409
|
/**
|
|
326
410
|
* Gets all the Units that are public or you are a member of. Admin users can see all Units
|
|
@@ -337,20 +421,17 @@ export const getUnits = (
|
|
|
337
421
|
);
|
|
338
422
|
};
|
|
339
423
|
|
|
340
|
-
export const getGetUnitsQueryKey = () => [`/unit`];
|
|
341
|
-
|
|
342
|
-
export type GetUnitsQueryResult = NonNullable<
|
|
343
|
-
Awaited<ReturnType<typeof getUnits>>
|
|
344
|
-
>;
|
|
345
|
-
export type GetUnitsQueryError = ErrorType<void | AsError>;
|
|
424
|
+
export const getGetUnitsQueryKey = () => ["account-server-api", `/unit`] as const;
|
|
346
425
|
|
|
347
|
-
export const
|
|
426
|
+
export const getGetUnitsQueryOptions = <
|
|
348
427
|
TData = Awaited<ReturnType<typeof getUnits>>,
|
|
349
428
|
TError = ErrorType<void | AsError>
|
|
350
429
|
>(options?: {
|
|
351
430
|
query?: UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData>;
|
|
352
431
|
request?: SecondParameter<typeof customInstance>;
|
|
353
|
-
}):
|
|
432
|
+
}): UseQueryOptions<Awaited<ReturnType<typeof getUnits>>, TError, TData> & {
|
|
433
|
+
queryKey: QueryKey;
|
|
434
|
+
} => {
|
|
354
435
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
355
436
|
|
|
356
437
|
const queryKey = queryOptions?.queryKey ?? getGetUnitsQueryKey();
|
|
@@ -359,13 +440,28 @@ export const useGetUnits = <
|
|
|
359
440
|
signal,
|
|
360
441
|
}) => getUnits(requestOptions, signal);
|
|
361
442
|
|
|
362
|
-
|
|
443
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
444
|
+
};
|
|
363
445
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
446
|
+
export type GetUnitsQueryResult = NonNullable<
|
|
447
|
+
Awaited<ReturnType<typeof getUnits>>
|
|
448
|
+
>;
|
|
449
|
+
export type GetUnitsQueryError = ErrorType<void | AsError>;
|
|
367
450
|
|
|
368
|
-
|
|
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;
|
|
369
465
|
|
|
370
466
|
return query;
|
|
371
467
|
};
|
|
@@ -390,13 +486,7 @@ export const createDefaultUnit = (
|
|
|
390
486
|
);
|
|
391
487
|
};
|
|
392
488
|
|
|
393
|
-
export
|
|
394
|
-
Awaited<ReturnType<typeof createDefaultUnit>>
|
|
395
|
-
>;
|
|
396
|
-
export type CreateDefaultUnitMutationBody = PersonalUnitPutBodyBody;
|
|
397
|
-
export type CreateDefaultUnitMutationError = ErrorType<AsError | void>;
|
|
398
|
-
|
|
399
|
-
export const useCreateDefaultUnit = <
|
|
489
|
+
export const getCreateDefaultUnitMutationOptions = <
|
|
400
490
|
TError = ErrorType<AsError | void>,
|
|
401
491
|
TContext = unknown
|
|
402
492
|
>(options?: {
|
|
@@ -407,7 +497,12 @@ export const useCreateDefaultUnit = <
|
|
|
407
497
|
TContext
|
|
408
498
|
>;
|
|
409
499
|
request?: SecondParameter<typeof customInstance>;
|
|
410
|
-
})
|
|
500
|
+
}): UseMutationOptions<
|
|
501
|
+
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
502
|
+
TError,
|
|
503
|
+
{ data: PersonalUnitPutBodyBody },
|
|
504
|
+
TContext
|
|
505
|
+
> => {
|
|
411
506
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
412
507
|
|
|
413
508
|
const mutationFn: MutationFunction<
|
|
@@ -419,12 +514,30 @@ export const useCreateDefaultUnit = <
|
|
|
419
514
|
return createDefaultUnit(data, requestOptions);
|
|
420
515
|
};
|
|
421
516
|
|
|
422
|
-
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<
|
|
423
531
|
Awaited<ReturnType<typeof createDefaultUnit>>,
|
|
424
532
|
TError,
|
|
425
533
|
{ data: PersonalUnitPutBodyBody },
|
|
426
534
|
TContext
|
|
427
|
-
|
|
535
|
+
>;
|
|
536
|
+
request?: SecondParameter<typeof customInstance>;
|
|
537
|
+
}) => {
|
|
538
|
+
const mutationOptions = getCreateDefaultUnitMutationOptions(options);
|
|
539
|
+
|
|
540
|
+
return useMutation(mutationOptions);
|
|
428
541
|
};
|
|
429
542
|
/**
|
|
430
543
|
* Deletes a 'Personal' Unit. It must be your Unit, which belongs to the Default Organisation
|
|
@@ -437,13 +550,7 @@ export const deleteDefaultUnit = (
|
|
|
437
550
|
return customInstance<void>({ url: `/unit`, method: "delete" }, options);
|
|
438
551
|
};
|
|
439
552
|
|
|
440
|
-
export
|
|
441
|
-
Awaited<ReturnType<typeof deleteDefaultUnit>>
|
|
442
|
-
>;
|
|
443
|
-
|
|
444
|
-
export type DeleteDefaultUnitMutationError = ErrorType<AsError>;
|
|
445
|
-
|
|
446
|
-
export const useDeleteDefaultUnit = <
|
|
553
|
+
export const getDeleteDefaultUnitMutationOptions = <
|
|
447
554
|
TError = ErrorType<AsError>,
|
|
448
555
|
TVariables = void,
|
|
449
556
|
TContext = unknown
|
|
@@ -455,7 +562,12 @@ export const useDeleteDefaultUnit = <
|
|
|
455
562
|
TContext
|
|
456
563
|
>;
|
|
457
564
|
request?: SecondParameter<typeof customInstance>;
|
|
458
|
-
})
|
|
565
|
+
}): UseMutationOptions<
|
|
566
|
+
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
567
|
+
TError,
|
|
568
|
+
TVariables,
|
|
569
|
+
TContext
|
|
570
|
+
> => {
|
|
459
571
|
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
460
572
|
|
|
461
573
|
const mutationFn: MutationFunction<
|
|
@@ -465,12 +577,31 @@ export const useDeleteDefaultUnit = <
|
|
|
465
577
|
return deleteDefaultUnit(requestOptions);
|
|
466
578
|
};
|
|
467
579
|
|
|
468
|
-
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<
|
|
469
595
|
Awaited<ReturnType<typeof deleteDefaultUnit>>,
|
|
470
596
|
TError,
|
|
471
597
|
TVariables,
|
|
472
598
|
TContext
|
|
473
|
-
|
|
599
|
+
>;
|
|
600
|
+
request?: SecondParameter<typeof customInstance>;
|
|
601
|
+
}) => {
|
|
602
|
+
const mutationOptions = getDeleteDefaultUnitMutationOptions(options);
|
|
603
|
+
|
|
604
|
+
return useMutation(mutationOptions);
|
|
474
605
|
};
|
|
475
606
|
/**
|
|
476
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.
|
|
@@ -497,14 +628,9 @@ export const getUnitCharges = (
|
|
|
497
628
|
export const getGetUnitChargesQueryKey = (
|
|
498
629
|
unitId: string,
|
|
499
630
|
params?: GetUnitChargesParams
|
|
500
|
-
) => [`/unit/${unitId}/charges`, ...(params ? [params] : [])];
|
|
501
|
-
|
|
502
|
-
export type GetUnitChargesQueryResult = NonNullable<
|
|
503
|
-
Awaited<ReturnType<typeof getUnitCharges>>
|
|
504
|
-
>;
|
|
505
|
-
export type GetUnitChargesQueryError = ErrorType<AsError | void>;
|
|
631
|
+
) => ["account-server-api", `/unit/${unitId}/charges`, ...(params ? [params] : [])] as const;
|
|
506
632
|
|
|
507
|
-
export const
|
|
633
|
+
export const getGetUnitChargesQueryOptions = <
|
|
508
634
|
TData = Awaited<ReturnType<typeof getUnitCharges>>,
|
|
509
635
|
TError = ErrorType<AsError | void>
|
|
510
636
|
>(
|
|
@@ -518,7 +644,11 @@ export const useGetUnitCharges = <
|
|
|
518
644
|
>;
|
|
519
645
|
request?: SecondParameter<typeof customInstance>;
|
|
520
646
|
}
|
|
521
|
-
):
|
|
647
|
+
): UseQueryOptions<
|
|
648
|
+
Awaited<ReturnType<typeof getUnitCharges>>,
|
|
649
|
+
TError,
|
|
650
|
+
TData
|
|
651
|
+
> & { queryKey: QueryKey } => {
|
|
522
652
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
523
653
|
|
|
524
654
|
const queryKey =
|
|
@@ -528,15 +658,36 @@ export const useGetUnitCharges = <
|
|
|
528
658
|
signal,
|
|
529
659
|
}) => getUnitCharges(unitId, params, requestOptions, signal);
|
|
530
660
|
|
|
531
|
-
|
|
661
|
+
return { queryKey, queryFn, enabled: !!unitId, ...queryOptions };
|
|
662
|
+
};
|
|
532
663
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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
|
+
};
|
|
538
689
|
|
|
539
|
-
query.queryKey =
|
|
690
|
+
query.queryKey = queryOptions.queryKey;
|
|
540
691
|
|
|
541
692
|
return query;
|
|
542
693
|
};
|