@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/product/product.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,37 +8,39 @@ 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
|
-
ProductsGetTypesResponse,
|
|
22
27
|
AsError,
|
|
28
|
+
GetProductChargesParams,
|
|
29
|
+
ProductChargesGetResponse,
|
|
30
|
+
ProductPatchBodyBody,
|
|
31
|
+
ProductUnitGetResponse,
|
|
23
32
|
ProductsGetDefaultStorageCost,
|
|
24
33
|
ProductsGetResponse,
|
|
25
|
-
|
|
34
|
+
ProductsGetTypesResponse,
|
|
26
35
|
UnitProductPostBodyBody,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line
|
|
36
|
-
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
37
|
-
config: any,
|
|
38
|
-
args: infer P
|
|
39
|
-
) => any
|
|
40
|
-
? P
|
|
41
|
-
: never;
|
|
36
|
+
UnitProductPostResponse
|
|
37
|
+
} from '../account-server-api.schemas'
|
|
38
|
+
import { customInstance } from '.././custom-instance';
|
|
39
|
+
import type { ErrorType } from '.././custom-instance';
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
type SecondParameter<T extends (...args: any) => any> = Parameters<T>[1];
|
|
43
|
+
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* Gets Product Types you can purchase (subscribe to)
|
|
@@ -46,69 +48,102 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
|
46
48
|
* @summary Gets all Product Types
|
|
47
49
|
*/
|
|
48
50
|
export const getProductTypes = (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
|
|
52
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
53
|
+
) => {
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
return customInstance<ProductsGetTypesResponse>(
|
|
57
|
+
{url: `/product-type`, method: 'GET', signal
|
|
58
|
+
},
|
|
59
|
+
options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export const getGetProductTypesQueryKey = () => {
|
|
64
|
+
return ["account-server-api", `/product-type`] as const;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
export const getGetProductTypesQueryOptions = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
69
|
+
) => {
|
|
70
|
+
|
|
71
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
72
|
+
|
|
73
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductTypes>>> = ({ signal }) => getProductTypes(requestOptions, signal);
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData> & { queryKey: QueryKey }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type GetProductTypesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductTypes>>>
|
|
87
|
+
export type GetProductTypesQueryError = ErrorType<AsError | void>
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @summary Gets all Product Types
|
|
91
|
+
*/
|
|
92
|
+
export const useGetProductTypes = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>(
|
|
93
|
+
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
94
|
+
|
|
95
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
96
|
+
|
|
97
|
+
const queryOptions = getGetProductTypesQueryOptions(options)
|
|
98
|
+
|
|
99
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
100
|
+
|
|
101
|
+
query.queryKey = queryOptions.queryKey ;
|
|
102
|
+
|
|
103
|
+
return query;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export const getGetProductTypesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>( options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
51
109
|
) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export type GetProductTypesQueryResult = NonNullable<
|
|
87
|
-
Awaited<ReturnType<typeof getProductTypes>>
|
|
88
|
-
>;
|
|
89
|
-
export type GetProductTypesQueryError = ErrorType<AsError | void>;
|
|
90
|
-
|
|
91
|
-
export const useGetProductTypes = <
|
|
92
|
-
TData = Awaited<ReturnType<typeof getProductTypes>>,
|
|
93
|
-
TError = ErrorType<AsError | void>
|
|
94
|
-
>(options?: {
|
|
95
|
-
query?: UseQueryOptions<
|
|
96
|
-
Awaited<ReturnType<typeof getProductTypes>>,
|
|
97
|
-
TError,
|
|
98
|
-
TData
|
|
99
|
-
>;
|
|
100
|
-
request?: SecondParameter<typeof customInstance>;
|
|
101
|
-
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
102
|
-
const queryOptions = getGetProductTypesQueryOptions(options);
|
|
103
|
-
|
|
104
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
105
|
-
queryKey: QueryKey;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
query.queryKey = queryOptions.queryKey;
|
|
110
|
+
|
|
111
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
112
|
+
|
|
113
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductTypes>>> = ({ signal }) => getProductTypes(requestOptions, signal);
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
return { queryKey, queryFn, ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData> & { queryKey: QueryKey }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type GetProductTypesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProductTypes>>>
|
|
127
|
+
export type GetProductTypesSuspenseQueryError = ErrorType<AsError | void>
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @summary Gets all Product Types
|
|
131
|
+
*/
|
|
132
|
+
export const useGetProductTypesSuspense = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>(
|
|
133
|
+
options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
134
|
+
|
|
135
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
136
|
+
|
|
137
|
+
const queryOptions = getGetProductTypesSuspenseQueryOptions(options)
|
|
138
|
+
|
|
139
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
140
|
+
|
|
141
|
+
query.queryKey = queryOptions.queryKey ;
|
|
109
142
|
|
|
110
143
|
return query;
|
|
111
|
-
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
112
147
|
|
|
113
148
|
/**
|
|
114
149
|
* The storage cost is returned along with its measurement units, typically a Coin value based on the the peak storage that was measured on each billable day.
|
|
@@ -116,71 +151,102 @@ export const useGetProductTypes = <
|
|
|
116
151
|
* @summary Gets the default cross-product storage cost
|
|
117
152
|
*/
|
|
118
153
|
export const getProductDefaultStorageCost = (
|
|
119
|
-
|
|
120
|
-
|
|
154
|
+
|
|
155
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
156
|
+
) => {
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
return customInstance<ProductsGetDefaultStorageCost>(
|
|
160
|
+
{url: `/product-default-storage-cost`, method: 'GET', signal
|
|
161
|
+
},
|
|
162
|
+
options);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
export const getGetProductDefaultStorageCostQueryKey = () => {
|
|
167
|
+
return ["account-server-api", `/product-default-storage-cost`] as const;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
export const getGetProductDefaultStorageCostQueryOptions = <TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError = ErrorType<AsError | void>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
121
172
|
) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return { queryKey, queryFn, ...queryOptions };
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export type GetProductDefaultStorageCostQueryResult = NonNullable<
|
|
159
|
-
Awaited<ReturnType<typeof getProductDefaultStorageCost>>
|
|
160
|
-
>;
|
|
161
|
-
export type GetProductDefaultStorageCostQueryError = ErrorType<AsError | void>;
|
|
162
|
-
|
|
163
|
-
export const useGetProductDefaultStorageCost = <
|
|
164
|
-
TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
|
|
165
|
-
TError = ErrorType<AsError | void>
|
|
166
|
-
>(options?: {
|
|
167
|
-
query?: UseQueryOptions<
|
|
168
|
-
Awaited<ReturnType<typeof getProductDefaultStorageCost>>,
|
|
169
|
-
TError,
|
|
170
|
-
TData
|
|
171
|
-
>;
|
|
172
|
-
request?: SecondParameter<typeof customInstance>;
|
|
173
|
-
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
174
|
-
const queryOptions = getGetProductDefaultStorageCostQueryOptions(options);
|
|
175
|
-
|
|
176
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
177
|
-
queryKey: QueryKey;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
query.queryKey = queryOptions.queryKey;
|
|
173
|
+
|
|
174
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
175
|
+
|
|
176
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductDefaultStorageCostQueryKey();
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductDefaultStorageCost>>> = ({ signal }) => getProductDefaultStorageCost(requestOptions, signal);
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData> & { queryKey: QueryKey }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export type GetProductDefaultStorageCostQueryResult = NonNullable<Awaited<ReturnType<typeof getProductDefaultStorageCost>>>
|
|
190
|
+
export type GetProductDefaultStorageCostQueryError = ErrorType<AsError | void>
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @summary Gets the default cross-product storage cost
|
|
194
|
+
*/
|
|
195
|
+
export const useGetProductDefaultStorageCost = <TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError = ErrorType<AsError | void>>(
|
|
196
|
+
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
197
|
+
|
|
198
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
199
|
+
|
|
200
|
+
const queryOptions = getGetProductDefaultStorageCostQueryOptions(options)
|
|
201
|
+
|
|
202
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
203
|
+
|
|
204
|
+
query.queryKey = queryOptions.queryKey ;
|
|
181
205
|
|
|
182
206
|
return query;
|
|
183
|
-
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
export const getGetProductDefaultStorageCostSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError = ErrorType<AsError | void>>( options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
212
|
+
) => {
|
|
213
|
+
|
|
214
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
215
|
+
|
|
216
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductDefaultStorageCostQueryKey();
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductDefaultStorageCost>>> = ({ signal }) => getProductDefaultStorageCost(requestOptions, signal);
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
return { queryKey, queryFn, ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData> & { queryKey: QueryKey }
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type GetProductDefaultStorageCostSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProductDefaultStorageCost>>>
|
|
230
|
+
export type GetProductDefaultStorageCostSuspenseQueryError = ErrorType<AsError | void>
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @summary Gets the default cross-product storage cost
|
|
234
|
+
*/
|
|
235
|
+
export const useGetProductDefaultStorageCostSuspense = <TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError = ErrorType<AsError | void>>(
|
|
236
|
+
options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
237
|
+
|
|
238
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
239
|
+
|
|
240
|
+
const queryOptions = getGetProductDefaultStorageCostSuspenseQueryOptions(options)
|
|
241
|
+
|
|
242
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
243
|
+
|
|
244
|
+
query.queryKey = queryOptions.queryKey ;
|
|
245
|
+
|
|
246
|
+
return query;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
184
250
|
|
|
185
251
|
/**
|
|
186
252
|
* Gets Products you have access to, across all **Units** and **Organisations**
|
|
@@ -188,67 +254,102 @@ export const useGetProductDefaultStorageCost = <
|
|
|
188
254
|
* @summary Gets all Products
|
|
189
255
|
*/
|
|
190
256
|
export const getProducts = (
|
|
191
|
-
|
|
192
|
-
|
|
257
|
+
|
|
258
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
259
|
+
) => {
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
return customInstance<ProductsGetResponse>(
|
|
263
|
+
{url: `/product`, method: 'GET', signal
|
|
264
|
+
},
|
|
265
|
+
options);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
export const getGetProductsQueryKey = () => {
|
|
270
|
+
return ["account-server-api", `/product`] as const;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
export const getGetProductsQueryOptions = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
193
275
|
) => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
export type GetProductsQueryResult = NonNullable<
|
|
227
|
-
Awaited<ReturnType<typeof getProducts>>
|
|
228
|
-
>;
|
|
229
|
-
export type GetProductsQueryError = ErrorType<AsError | void>;
|
|
230
|
-
|
|
231
|
-
export const useGetProducts = <
|
|
232
|
-
TData = Awaited<ReturnType<typeof getProducts>>,
|
|
233
|
-
TError = ErrorType<AsError | void>
|
|
234
|
-
>(options?: {
|
|
235
|
-
query?: UseQueryOptions<
|
|
236
|
-
Awaited<ReturnType<typeof getProducts>>,
|
|
237
|
-
TError,
|
|
238
|
-
TData
|
|
239
|
-
>;
|
|
240
|
-
request?: SecondParameter<typeof customInstance>;
|
|
241
|
-
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
242
|
-
const queryOptions = getGetProductsQueryOptions(options);
|
|
243
|
-
|
|
244
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
245
|
-
queryKey: QueryKey;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
query.queryKey = queryOptions.queryKey;
|
|
276
|
+
|
|
277
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
278
|
+
|
|
279
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProducts>>> = ({ signal }) => getProducts(requestOptions, signal);
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData> & { queryKey: QueryKey }
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export type GetProductsQueryResult = NonNullable<Awaited<ReturnType<typeof getProducts>>>
|
|
293
|
+
export type GetProductsQueryError = ErrorType<AsError | void>
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @summary Gets all Products
|
|
297
|
+
*/
|
|
298
|
+
export const useGetProducts = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>(
|
|
299
|
+
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
300
|
+
|
|
301
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
302
|
+
|
|
303
|
+
const queryOptions = getGetProductsQueryOptions(options)
|
|
304
|
+
|
|
305
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
306
|
+
|
|
307
|
+
query.queryKey = queryOptions.queryKey ;
|
|
249
308
|
|
|
250
309
|
return query;
|
|
251
|
-
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
export const getGetProductsSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>( options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
315
|
+
) => {
|
|
316
|
+
|
|
317
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
318
|
+
|
|
319
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProducts>>> = ({ signal }) => getProducts(requestOptions, signal);
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
return { queryKey, queryFn, ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData> & { queryKey: QueryKey }
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export type GetProductsSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProducts>>>
|
|
333
|
+
export type GetProductsSuspenseQueryError = ErrorType<AsError | void>
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @summary Gets all Products
|
|
337
|
+
*/
|
|
338
|
+
export const useGetProductsSuspense = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>(
|
|
339
|
+
options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
340
|
+
|
|
341
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
342
|
+
|
|
343
|
+
const queryOptions = getGetProductsSuspenseQueryOptions(options)
|
|
344
|
+
|
|
345
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
346
|
+
|
|
347
|
+
query.queryKey = queryOptions.queryKey ;
|
|
348
|
+
|
|
349
|
+
return query;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
|
|
252
353
|
|
|
253
354
|
/**
|
|
254
355
|
* Gets Products you have access to based on an **Organisation**
|
|
@@ -256,81 +357,102 @@ export const useGetProducts = <
|
|
|
256
357
|
* @summary Gets Products for an Organisation
|
|
257
358
|
*/
|
|
258
359
|
export const getProductsForOrganisation = (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
360
|
+
orgId: string,
|
|
361
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
362
|
+
) => {
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
return customInstance<ProductsGetResponse>(
|
|
366
|
+
{url: `/product/organisation/${orgId}`, method: 'GET', signal
|
|
367
|
+
},
|
|
368
|
+
options);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
export const getGetProductsForOrganisationQueryKey = (orgId: string,) => {
|
|
373
|
+
return ["account-server-api", `/product/organisation/${orgId}`] as const;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
export const getGetProductsForOrganisationQueryOptions = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(orgId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
262
378
|
) => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
orgId:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
TData
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const queryKey
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const queryFn: QueryFunction<
|
|
296
|
-
Awaited<ReturnType<typeof getProductsForOrganisation>>
|
|
297
|
-
> = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
|
|
298
|
-
|
|
299
|
-
return { queryKey, queryFn, enabled: !!orgId, ...queryOptions };
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
export type GetProductsForOrganisationQueryResult = NonNullable<
|
|
303
|
-
Awaited<ReturnType<typeof getProductsForOrganisation>>
|
|
304
|
-
>;
|
|
305
|
-
export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>;
|
|
306
|
-
|
|
307
|
-
export const useGetProductsForOrganisation = <
|
|
308
|
-
TData = Awaited<ReturnType<typeof getProductsForOrganisation>>,
|
|
309
|
-
TError = ErrorType<void | AsError>
|
|
310
|
-
>(
|
|
311
|
-
orgId: string,
|
|
312
|
-
options?: {
|
|
313
|
-
query?: UseQueryOptions<
|
|
314
|
-
Awaited<ReturnType<typeof getProductsForOrganisation>>,
|
|
315
|
-
TError,
|
|
316
|
-
TData
|
|
317
|
-
>;
|
|
318
|
-
request?: SecondParameter<typeof customInstance>;
|
|
319
|
-
}
|
|
320
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
321
|
-
const queryOptions = getGetProductsForOrganisationQueryOptions(
|
|
322
|
-
orgId,
|
|
323
|
-
options
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
327
|
-
queryKey: QueryKey;
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
query.queryKey = queryOptions.queryKey;
|
|
379
|
+
|
|
380
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
381
|
+
|
|
382
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsForOrganisationQueryKey(orgId);
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForOrganisation>>> = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData> & { queryKey: QueryKey }
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export type GetProductsForOrganisationQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForOrganisation>>>
|
|
396
|
+
export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @summary Gets Products for an Organisation
|
|
400
|
+
*/
|
|
401
|
+
export const useGetProductsForOrganisation = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(
|
|
402
|
+
orgId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
403
|
+
|
|
404
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
405
|
+
|
|
406
|
+
const queryOptions = getGetProductsForOrganisationQueryOptions(orgId,options)
|
|
407
|
+
|
|
408
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
409
|
+
|
|
410
|
+
query.queryKey = queryOptions.queryKey ;
|
|
331
411
|
|
|
332
412
|
return query;
|
|
333
|
-
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
export const getGetProductsForOrganisationSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(orgId: string, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
418
|
+
) => {
|
|
419
|
+
|
|
420
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
421
|
+
|
|
422
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsForOrganisationQueryKey(orgId);
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForOrganisation>>> = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData> & { queryKey: QueryKey }
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export type GetProductsForOrganisationSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForOrganisation>>>
|
|
436
|
+
export type GetProductsForOrganisationSuspenseQueryError = ErrorType<void | AsError>
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* @summary Gets Products for an Organisation
|
|
440
|
+
*/
|
|
441
|
+
export const useGetProductsForOrganisationSuspense = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(
|
|
442
|
+
orgId: string, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
443
|
+
|
|
444
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
445
|
+
|
|
446
|
+
const queryOptions = getGetProductsForOrganisationSuspenseQueryOptions(orgId,options)
|
|
447
|
+
|
|
448
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
449
|
+
|
|
450
|
+
query.queryKey = queryOptions.queryKey ;
|
|
451
|
+
|
|
452
|
+
return query;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
334
456
|
|
|
335
457
|
/**
|
|
336
458
|
* Products are **Subscriptions** that you create in a Unit and use **Merchant** services like the `DATA_MANAGER`.
|
|
@@ -344,152 +466,157 @@ To do this you need to be a member of the **Unit** or the **Organisation**.
|
|
|
344
466
|
* @summary Creates a Product for an Organisational Unit
|
|
345
467
|
*/
|
|
346
468
|
export const createUnitProduct = (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
url: `/product/unit/${unitId}`,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
data: unitProductPostBodyBody,
|
|
469
|
+
unitId: string,
|
|
470
|
+
unitProductPostBodyBody: UnitProductPostBodyBody,
|
|
471
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
return customInstance<UnitProductPostResponse>(
|
|
475
|
+
{url: `/product/unit/${unitId}`, method: 'POST',
|
|
476
|
+
headers: {'Content-Type': 'application/json', },
|
|
477
|
+
data: unitProductPostBodyBody
|
|
357
478
|
},
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
>
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
Awaited<ReturnType<typeof createUnitProduct
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
export const useCreateUnitProduct = <
|
|
400
|
-
TError = ErrorType<AsError | void>,
|
|
401
|
-
TContext = unknown
|
|
402
|
-
>(options?: {
|
|
403
|
-
mutation?: UseMutationOptions<
|
|
404
|
-
Awaited<ReturnType<typeof createUnitProduct>>,
|
|
405
|
-
TError,
|
|
406
|
-
{ unitId: string; data: UnitProductPostBodyBody },
|
|
407
|
-
TContext
|
|
408
|
-
>;
|
|
409
|
-
request?: SecondParameter<typeof customInstance>;
|
|
410
|
-
}) => {
|
|
411
|
-
const mutationOptions = getCreateUnitProductMutationOptions(options);
|
|
412
|
-
|
|
413
|
-
return useMutation(mutationOptions);
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
479
|
+
options);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
export const getCreateUnitProductMutationOptions = <TError = ErrorType<AsError | void>,
|
|
485
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
486
|
+
): UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext> => {
|
|
487
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createUnitProduct>>, {unitId: string;data: UnitProductPostBodyBody}> = (props) => {
|
|
493
|
+
const {unitId,data} = props ?? {};
|
|
494
|
+
|
|
495
|
+
return createUnitProduct(unitId,data,requestOptions)
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
return { mutationFn, ...mutationOptions }}
|
|
502
|
+
|
|
503
|
+
export type CreateUnitProductMutationResult = NonNullable<Awaited<ReturnType<typeof createUnitProduct>>>
|
|
504
|
+
export type CreateUnitProductMutationBody = UnitProductPostBodyBody
|
|
505
|
+
export type CreateUnitProductMutationError = ErrorType<AsError | void>
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @summary Creates a Product for an Organisational Unit
|
|
509
|
+
*/
|
|
510
|
+
export const useCreateUnitProduct = <TError = ErrorType<AsError | void>,
|
|
511
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
512
|
+
) => {
|
|
513
|
+
|
|
514
|
+
const mutationOptions = getCreateUnitProductMutationOptions(options);
|
|
515
|
+
|
|
516
|
+
return useMutation(mutationOptions);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
416
519
|
* Gets products you have access to based on an Organisational **Unit**
|
|
417
520
|
|
|
418
521
|
* @summary Gets Products for an Organisational Unit
|
|
419
522
|
*/
|
|
420
523
|
export const getProductsForUnit = (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
signal?: AbortSignal
|
|
524
|
+
unitId: string,
|
|
525
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
424
526
|
) => {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
export const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
unitId: string,
|
|
474
|
-
options?: {
|
|
475
|
-
query?: UseQueryOptions<
|
|
476
|
-
Awaited<ReturnType<typeof getProductsForUnit>>,
|
|
477
|
-
TError,
|
|
478
|
-
TData
|
|
479
|
-
>;
|
|
480
|
-
request?: SecondParameter<typeof customInstance>;
|
|
481
|
-
}
|
|
482
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
483
|
-
const queryOptions = getGetProductsForUnitQueryOptions(unitId, options);
|
|
484
|
-
|
|
485
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
486
|
-
queryKey: QueryKey;
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
query.queryKey = queryOptions.queryKey;
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
return customInstance<ProductsGetResponse>(
|
|
530
|
+
{url: `/product/unit/${unitId}`, method: 'GET', signal
|
|
531
|
+
},
|
|
532
|
+
options);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
export const getGetProductsForUnitQueryKey = (unitId: string,) => {
|
|
537
|
+
return ["account-server-api", `/product/unit/${unitId}`] as const;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
export const getGetProductsForUnitQueryOptions = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(unitId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
542
|
+
) => {
|
|
543
|
+
|
|
544
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
545
|
+
|
|
546
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForUnit>>> = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData> & { queryKey: QueryKey }
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export type GetProductsForUnitQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForUnit>>>
|
|
560
|
+
export type GetProductsForUnitQueryError = ErrorType<void | AsError>
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* @summary Gets Products for an Organisational Unit
|
|
564
|
+
*/
|
|
565
|
+
export const useGetProductsForUnit = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(
|
|
566
|
+
unitId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
567
|
+
|
|
568
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
569
|
+
|
|
570
|
+
const queryOptions = getGetProductsForUnitQueryOptions(unitId,options)
|
|
571
|
+
|
|
572
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
573
|
+
|
|
574
|
+
query.queryKey = queryOptions.queryKey ;
|
|
490
575
|
|
|
491
576
|
return query;
|
|
492
|
-
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
export const getGetProductsForUnitSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(unitId: string, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
582
|
+
) => {
|
|
583
|
+
|
|
584
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
585
|
+
|
|
586
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForUnit>>> = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData> & { queryKey: QueryKey }
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export type GetProductsForUnitSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForUnit>>>
|
|
600
|
+
export type GetProductsForUnitSuspenseQueryError = ErrorType<void | AsError>
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* @summary Gets Products for an Organisational Unit
|
|
604
|
+
*/
|
|
605
|
+
export const useGetProductsForUnitSuspense = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(
|
|
606
|
+
unitId: string, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
607
|
+
|
|
608
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
609
|
+
|
|
610
|
+
const queryOptions = getGetProductsForUnitSuspenseQueryOptions(unitId,options)
|
|
611
|
+
|
|
612
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
613
|
+
|
|
614
|
+
query.queryKey = queryOptions.queryKey ;
|
|
615
|
+
|
|
616
|
+
return query;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
|
|
493
620
|
|
|
494
621
|
/**
|
|
495
622
|
* Gets details of a specific Product that you have access to.
|
|
@@ -497,75 +624,102 @@ export const useGetProductsForUnit = <
|
|
|
497
624
|
* @summary Gets a Product
|
|
498
625
|
*/
|
|
499
626
|
export const getProduct = (
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
627
|
+
productId: string,
|
|
628
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
629
|
+
) => {
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
return customInstance<ProductUnitGetResponse>(
|
|
633
|
+
{url: `/product/${productId}`, method: 'GET', signal
|
|
634
|
+
},
|
|
635
|
+
options);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
export const getGetProductQueryKey = (productId: string,) => {
|
|
640
|
+
return ["account-server-api", `/product/${productId}`] as const;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
export const getGetProductQueryOptions = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(productId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
503
645
|
) => {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
productId:
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
646
|
+
|
|
647
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
648
|
+
|
|
649
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductQueryKey(productId);
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({ signal }) => getProduct(productId, requestOptions, signal);
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData> & { queryKey: QueryKey }
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export type GetProductQueryResult = NonNullable<Awaited<ReturnType<typeof getProduct>>>
|
|
663
|
+
export type GetProductQueryError = ErrorType<AsError | void>
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* @summary Gets a Product
|
|
667
|
+
*/
|
|
668
|
+
export const useGetProduct = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(
|
|
669
|
+
productId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
670
|
+
|
|
671
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
672
|
+
|
|
673
|
+
const queryOptions = getGetProductQueryOptions(productId,options)
|
|
674
|
+
|
|
675
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
676
|
+
|
|
677
|
+
query.queryKey = queryOptions.queryKey ;
|
|
678
|
+
|
|
679
|
+
return query;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
export const getGetProductSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(productId: string, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
685
|
+
) => {
|
|
686
|
+
|
|
687
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
688
|
+
|
|
689
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductQueryKey(productId);
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({ signal }) => getProduct(productId, requestOptions, signal);
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData> & { queryKey: QueryKey }
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export type GetProductSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProduct>>>
|
|
703
|
+
export type GetProductSuspenseQueryError = ErrorType<AsError | void>
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* @summary Gets a Product
|
|
707
|
+
*/
|
|
708
|
+
export const useGetProductSuspense = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(
|
|
709
|
+
productId: string, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
710
|
+
|
|
711
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
712
|
+
|
|
713
|
+
const queryOptions = getGetProductSuspenseQueryOptions(productId,options)
|
|
714
|
+
|
|
715
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
716
|
+
|
|
717
|
+
query.queryKey = queryOptions.queryKey ;
|
|
566
718
|
|
|
567
719
|
return query;
|
|
568
|
-
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
|
|
569
723
|
|
|
570
724
|
/**
|
|
571
725
|
* You need access to the Product and, if the Product is *claimable* the claim must be removed before the Product can be removed. An example claimable Product is a `DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION` where the *claimable* commodity is a Data Manager **Project**. In this case you will need to delete the Data Manager **Project** before you can delete the Account Server **Product**.
|
|
@@ -573,69 +727,53 @@ export const useGetProduct = <
|
|
|
573
727
|
* @summary Deletes an existing Product
|
|
574
728
|
*/
|
|
575
729
|
export const deleteProduct = (
|
|
576
|
-
|
|
577
|
-
|
|
730
|
+
productId: string,
|
|
731
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
return customInstance<void>(
|
|
735
|
+
{url: `/product/${productId}`, method: 'DELETE'
|
|
736
|
+
},
|
|
737
|
+
options);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
export const getDeleteProductMutationOptions = <TError = ErrorType<AsError>,
|
|
743
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
744
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext> => {
|
|
745
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteProduct>>, {productId: string}> = (props) => {
|
|
751
|
+
const {productId} = props ?? {};
|
|
752
|
+
|
|
753
|
+
return deleteProduct(productId,requestOptions)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
return { mutationFn, ...mutationOptions }}
|
|
760
|
+
|
|
761
|
+
export type DeleteProductMutationResult = NonNullable<Awaited<ReturnType<typeof deleteProduct>>>
|
|
762
|
+
|
|
763
|
+
export type DeleteProductMutationError = ErrorType<AsError>
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* @summary Deletes an existing Product
|
|
767
|
+
*/
|
|
768
|
+
export const useDeleteProduct = <TError = ErrorType<AsError>,
|
|
769
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
578
770
|
) => {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
export const getDeleteProductMutationOptions = <
|
|
586
|
-
TError = ErrorType<AsError>,
|
|
587
|
-
TContext = unknown
|
|
588
|
-
>(options?: {
|
|
589
|
-
mutation?: UseMutationOptions<
|
|
590
|
-
Awaited<ReturnType<typeof deleteProduct>>,
|
|
591
|
-
TError,
|
|
592
|
-
{ productId: string },
|
|
593
|
-
TContext
|
|
594
|
-
>;
|
|
595
|
-
request?: SecondParameter<typeof customInstance>;
|
|
596
|
-
}): UseMutationOptions<
|
|
597
|
-
Awaited<ReturnType<typeof deleteProduct>>,
|
|
598
|
-
TError,
|
|
599
|
-
{ productId: string },
|
|
600
|
-
TContext
|
|
601
|
-
> => {
|
|
602
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
603
|
-
|
|
604
|
-
const mutationFn: MutationFunction<
|
|
605
|
-
Awaited<ReturnType<typeof deleteProduct>>,
|
|
606
|
-
{ productId: string }
|
|
607
|
-
> = (props) => {
|
|
608
|
-
const { productId } = props ?? {};
|
|
609
|
-
|
|
610
|
-
return deleteProduct(productId, requestOptions);
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
return { mutationFn, ...mutationOptions };
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
export type DeleteProductMutationResult = NonNullable<
|
|
617
|
-
Awaited<ReturnType<typeof deleteProduct>>
|
|
618
|
-
>;
|
|
619
|
-
|
|
620
|
-
export type DeleteProductMutationError = ErrorType<AsError>;
|
|
621
|
-
|
|
622
|
-
export const useDeleteProduct = <
|
|
623
|
-
TError = ErrorType<AsError>,
|
|
624
|
-
TContext = unknown
|
|
625
|
-
>(options?: {
|
|
626
|
-
mutation?: UseMutationOptions<
|
|
627
|
-
Awaited<ReturnType<typeof deleteProduct>>,
|
|
628
|
-
TError,
|
|
629
|
-
{ productId: string },
|
|
630
|
-
TContext
|
|
631
|
-
>;
|
|
632
|
-
request?: SecondParameter<typeof customInstance>;
|
|
633
|
-
}) => {
|
|
634
|
-
const mutationOptions = getDeleteProductMutationOptions(options);
|
|
635
|
-
|
|
636
|
-
return useMutation(mutationOptions);
|
|
637
|
-
};
|
|
638
|
-
/**
|
|
771
|
+
|
|
772
|
+
const mutationOptions = getDeleteProductMutationOptions(options);
|
|
773
|
+
|
|
774
|
+
return useMutation(mutationOptions);
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
639
777
|
* Used to update some adjustable parameters of a Product, i.e. to extend its **Allowance** or **Limit**.
|
|
640
778
|
|
|
641
779
|
At the moment we only support Products associated with the Data Manager, and these can be patched by changing the `name`, its coin `allowance` or `limit`
|
|
@@ -643,75 +781,56 @@ At the moment we only support Products associated with the Data Manager, and the
|
|
|
643
781
|
* @summary Adjust an existing Product
|
|
644
782
|
*/
|
|
645
783
|
export const patchProduct = (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
url: `/product/${productId}`,
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
data: productPatchBodyBody,
|
|
784
|
+
productId: string,
|
|
785
|
+
productPatchBodyBody: ProductPatchBodyBody,
|
|
786
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
return customInstance<void>(
|
|
790
|
+
{url: `/product/${productId}`, method: 'PATCH',
|
|
791
|
+
headers: {'Content-Type': 'application/json', },
|
|
792
|
+
data: productPatchBodyBody
|
|
656
793
|
},
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
>
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
Awaited<ReturnType<typeof patchProduct
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
export const usePatchProduct = <
|
|
699
|
-
TError = ErrorType<AsError>,
|
|
700
|
-
TContext = unknown
|
|
701
|
-
>(options?: {
|
|
702
|
-
mutation?: UseMutationOptions<
|
|
703
|
-
Awaited<ReturnType<typeof patchProduct>>,
|
|
704
|
-
TError,
|
|
705
|
-
{ productId: string; data: ProductPatchBodyBody },
|
|
706
|
-
TContext
|
|
707
|
-
>;
|
|
708
|
-
request?: SecondParameter<typeof customInstance>;
|
|
709
|
-
}) => {
|
|
710
|
-
const mutationOptions = getPatchProductMutationOptions(options);
|
|
711
|
-
|
|
712
|
-
return useMutation(mutationOptions);
|
|
713
|
-
};
|
|
714
|
-
/**
|
|
794
|
+
options);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
export const getPatchProductMutationOptions = <TError = ErrorType<AsError>,
|
|
800
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
801
|
+
): UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext> => {
|
|
802
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof patchProduct>>, {productId: string;data: ProductPatchBodyBody}> = (props) => {
|
|
808
|
+
const {productId,data} = props ?? {};
|
|
809
|
+
|
|
810
|
+
return patchProduct(productId,data,requestOptions)
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
return { mutationFn, ...mutationOptions }}
|
|
817
|
+
|
|
818
|
+
export type PatchProductMutationResult = NonNullable<Awaited<ReturnType<typeof patchProduct>>>
|
|
819
|
+
export type PatchProductMutationBody = ProductPatchBodyBody
|
|
820
|
+
export type PatchProductMutationError = ErrorType<AsError>
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* @summary Adjust an existing Product
|
|
824
|
+
*/
|
|
825
|
+
export const usePatchProduct = <TError = ErrorType<AsError>,
|
|
826
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
827
|
+
) => {
|
|
828
|
+
|
|
829
|
+
const mutationOptions = getPatchProductMutationOptions(options);
|
|
830
|
+
|
|
831
|
+
return useMutation(mutationOptions);
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
715
834
|
* Get the charges made against a Product with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.
|
|
716
835
|
|
|
717
836
|
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.
|
|
@@ -722,85 +841,107 @@ You need to be part of the **Unit** or **Organisation** to use this method
|
|
|
722
841
|
* @summary Get charges made against a Product
|
|
723
842
|
*/
|
|
724
843
|
export const getProductCharges = (
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
844
|
+
productId: string,
|
|
845
|
+
params?: GetProductChargesParams,
|
|
846
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
847
|
+
) => {
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
return customInstance<ProductChargesGetResponse>(
|
|
851
|
+
{url: `/product/${productId}/charges`, method: 'GET',
|
|
852
|
+
params, signal
|
|
853
|
+
},
|
|
854
|
+
options);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
export const getGetProductChargesQueryKey = (productId: string,
|
|
859
|
+
params?: GetProductChargesParams,) => {
|
|
860
|
+
return ["account-server-api", `/product/${productId}/charges`, ...(params ? [params]: [])] as const;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
export const getGetProductChargesQueryOptions = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(productId: string,
|
|
865
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
729
866
|
) => {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
);
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId, params);
|
|
764
|
-
|
|
765
|
-
const queryFn: QueryFunction<
|
|
766
|
-
Awaited<ReturnType<typeof getProductCharges>>
|
|
767
|
-
> = ({ signal }) =>
|
|
768
|
-
getProductCharges(productId, params, requestOptions, signal);
|
|
769
|
-
|
|
770
|
-
return { queryKey, queryFn, enabled: !!productId, ...queryOptions };
|
|
771
|
-
};
|
|
772
|
-
|
|
773
|
-
export type GetProductChargesQueryResult = NonNullable<
|
|
774
|
-
Awaited<ReturnType<typeof getProductCharges>>
|
|
775
|
-
>;
|
|
776
|
-
export type GetProductChargesQueryError = ErrorType<AsError | void>;
|
|
777
|
-
|
|
778
|
-
export const useGetProductCharges = <
|
|
779
|
-
TData = Awaited<ReturnType<typeof getProductCharges>>,
|
|
780
|
-
TError = ErrorType<AsError | void>
|
|
781
|
-
>(
|
|
782
|
-
productId: string,
|
|
783
|
-
params?: GetProductChargesParams,
|
|
784
|
-
options?: {
|
|
785
|
-
query?: UseQueryOptions<
|
|
786
|
-
Awaited<ReturnType<typeof getProductCharges>>,
|
|
787
|
-
TError,
|
|
788
|
-
TData
|
|
789
|
-
>;
|
|
790
|
-
request?: SecondParameter<typeof customInstance>;
|
|
791
|
-
}
|
|
792
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
793
|
-
const queryOptions = getGetProductChargesQueryOptions(
|
|
794
|
-
productId,
|
|
795
|
-
params,
|
|
796
|
-
options
|
|
797
|
-
);
|
|
798
|
-
|
|
799
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
800
|
-
queryKey: QueryKey;
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
query.queryKey = queryOptions.queryKey;
|
|
867
|
+
|
|
868
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
869
|
+
|
|
870
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId,params);
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductCharges>>> = ({ signal }) => getProductCharges(productId,params, requestOptions, signal);
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
export type GetProductChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductCharges>>>
|
|
884
|
+
export type GetProductChargesQueryError = ErrorType<AsError | void>
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* @summary Get charges made against a Product
|
|
888
|
+
*/
|
|
889
|
+
export const useGetProductCharges = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(
|
|
890
|
+
productId: string,
|
|
891
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
892
|
+
|
|
893
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
894
|
+
|
|
895
|
+
const queryOptions = getGetProductChargesQueryOptions(productId,params,options)
|
|
896
|
+
|
|
897
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
898
|
+
|
|
899
|
+
query.queryKey = queryOptions.queryKey ;
|
|
804
900
|
|
|
805
901
|
return query;
|
|
806
|
-
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
export const getGetProductChargesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(productId: string,
|
|
907
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
908
|
+
) => {
|
|
909
|
+
|
|
910
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
911
|
+
|
|
912
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId,params);
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductCharges>>> = ({ signal }) => getProductCharges(productId,params, requestOptions, signal);
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
export type GetProductChargesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProductCharges>>>
|
|
926
|
+
export type GetProductChargesSuspenseQueryError = ErrorType<AsError | void>
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* @summary Get charges made against a Product
|
|
930
|
+
*/
|
|
931
|
+
export const useGetProductChargesSuspense = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(
|
|
932
|
+
productId: string,
|
|
933
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
934
|
+
|
|
935
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
936
|
+
|
|
937
|
+
const queryOptions = getGetProductChargesSuspenseQueryOptions(productId,params,options)
|
|
938
|
+
|
|
939
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
940
|
+
|
|
941
|
+
query.queryKey = queryOptions.queryKey ;
|
|
942
|
+
|
|
943
|
+
return query;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|