@squonk/account-server-client 2.0.6-rc.1 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/admin.cjs +14 -7
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.cts +33 -0
- package/admin/admin.d.ts +4 -1
- package/admin/admin.js +14 -7
- package/admin/admin.js.map +1 -1
- package/asset/asset.cjs +44 -19
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.cts +241 -0
- package/asset/asset.d.ts +43 -19
- package/asset/asset.js +37 -12
- package/asset/asset.js.map +1 -1
- package/{chunk-UZTHSGDT.cjs → chunk-J22A7LHX.cjs} +1 -1
- package/chunk-J22A7LHX.cjs.map +1 -0
- package/{chunk-3RNIDX7T.js → chunk-UKA7G3OB.js} +1 -1
- package/{chunk-3RNIDX7T.js.map → chunk-UKA7G3OB.js.map} +1 -1
- package/{custom-instance-f32f6506.d.ts → custom-instance-13ade7a9.d.ts} +159 -159
- package/index.cjs +10 -10
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +1 -1
- package/index.js +9 -9
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +23 -13
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.cts +57 -0
- package/merchant/merchant.d.ts +7 -1
- package/merchant/merchant.js +22 -12
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +50 -25
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.cts +203 -0
- package/organisation/organisation.d.ts +31 -10
- package/organisation/organisation.js +44 -19
- package/organisation/organisation.js.map +1 -1
- package/package.json +12 -12
- package/product/product.cjs +80 -44
- package/product/product.cjs.map +1 -1
- package/product/product.d.cts +280 -0
- package/product/product.d.ts +40 -10
- package/product/product.js +71 -35
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +268 -276
- package/src/admin/admin.ts +72 -78
- package/src/asset/asset.ts +447 -556
- package/src/merchant/merchant.ts +125 -136
- package/src/organisation/organisation.ts +394 -484
- package/src/product/product.ts +557 -682
- package/src/state/state.ts +70 -69
- package/src/unit/unit.ts +494 -593
- package/src/user/user.ts +377 -463
- package/state/state.cjs +13 -7
- package/state/state.cjs.map +1 -1
- package/state/state.d.cts +29 -0
- package/state/state.d.ts +4 -1
- package/state/state.js +13 -7
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +59 -28
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.cts +254 -0
- package/unit/unit.d.ts +43 -16
- package/unit/unit.js +52 -21
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +52 -21
- package/user/user.cjs.map +1 -1
- package/user/user.d.cts +220 -0
- package/user/user.d.ts +31 -10
- package/user/user.js +46 -15
- package/user/user.js.map +1 -1
- package/chunk-UZTHSGDT.cjs.map +0 -1
package/src/product/product.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
2
|
+
* Generated by orval v6.20.0 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Account Server API
|
|
5
5
|
* The Informatics Matters Account Server API.
|
|
@@ -8,107 +8,106 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 2.0
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useMutation,
|
|
13
|
+
useQuery
|
|
14
|
+
} from '@tanstack/react-query'
|
|
12
15
|
import type {
|
|
13
|
-
UseQueryOptions,
|
|
14
|
-
UseMutationOptions,
|
|
15
|
-
QueryFunction,
|
|
16
16
|
MutationFunction,
|
|
17
|
-
|
|
17
|
+
QueryFunction,
|
|
18
18
|
QueryKey,
|
|
19
|
-
|
|
19
|
+
UseMutationOptions,
|
|
20
|
+
UseQueryOptions,
|
|
21
|
+
UseQueryResult
|
|
22
|
+
} from '@tanstack/react-query'
|
|
20
23
|
import type {
|
|
21
|
-
ProductsGetTypesResponse,
|
|
22
24
|
AsError,
|
|
25
|
+
GetProductChargesParams,
|
|
26
|
+
ProductChargesGetResponse,
|
|
27
|
+
ProductPatchBodyBody,
|
|
28
|
+
ProductUnitGetResponse,
|
|
23
29
|
ProductsGetDefaultStorageCost,
|
|
24
30
|
ProductsGetResponse,
|
|
25
|
-
|
|
31
|
+
ProductsGetTypesResponse,
|
|
26
32
|
UnitProductPostBodyBody,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import { customInstance } from ".././custom-instance";
|
|
33
|
-
import type { ErrorType } from ".././custom-instance";
|
|
33
|
+
UnitProductPostResponse
|
|
34
|
+
} from '../account-server-api.schemas'
|
|
35
|
+
import { customInstance } from '.././custom-instance';
|
|
36
|
+
import type { ErrorType } from '.././custom-instance';
|
|
37
|
+
|
|
34
38
|
|
|
35
39
|
// eslint-disable-next-line
|
|
36
|
-
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
40
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
37
41
|
config: any,
|
|
38
|
-
args: infer P
|
|
42
|
+
args: infer P,
|
|
39
43
|
) => any
|
|
40
44
|
? P
|
|
41
45
|
: never;
|
|
42
46
|
|
|
47
|
+
|
|
43
48
|
/**
|
|
44
49
|
* Gets Product Types you can purchase (subscribe to)
|
|
45
50
|
|
|
46
51
|
* @summary Gets all Product Types
|
|
47
52
|
*/
|
|
48
53
|
export const getProductTypes = (
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
|
|
55
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
56
|
+
) => {
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
return customInstance<ProductsGetTypesResponse>(
|
|
60
|
+
{url: `/product-type`, method: 'get', signal
|
|
61
|
+
},
|
|
62
|
+
options);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export const getGetProductTypesQueryKey = () => {
|
|
67
|
+
|
|
68
|
+
return ["account-server-api", `/product-type`] as const;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
export const getGetProductTypesQueryOptions = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
51
73
|
) => {
|
|
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;
|
|
74
|
+
|
|
75
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
76
|
+
|
|
77
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductTypes>>> = ({ signal }) => getProductTypes(requestOptions, signal);
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData> & { queryKey: QueryKey }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type GetProductTypesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductTypes>>>
|
|
91
|
+
export type GetProductTypesQueryError = ErrorType<AsError | void>
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @summary Gets all Product Types
|
|
95
|
+
*/
|
|
96
|
+
export const useGetProductTypes = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>(
|
|
97
|
+
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
98
|
+
|
|
99
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
100
|
+
|
|
101
|
+
const queryOptions = getGetProductTypesQueryOptions(options)
|
|
102
|
+
|
|
103
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
104
|
+
|
|
105
|
+
query.queryKey = queryOptions.queryKey ;
|
|
109
106
|
|
|
110
107
|
return query;
|
|
111
|
-
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
112
111
|
|
|
113
112
|
/**
|
|
114
113
|
* 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 +115,63 @@ export const useGetProductTypes = <
|
|
|
116
115
|
* @summary Gets the default cross-product storage cost
|
|
117
116
|
*/
|
|
118
117
|
export const getProductDefaultStorageCost = (
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
|
|
119
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
120
|
+
) => {
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
return customInstance<ProductsGetDefaultStorageCost>(
|
|
124
|
+
{url: `/product-default-storage-cost`, method: 'get', signal
|
|
125
|
+
},
|
|
126
|
+
options);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
export const getGetProductDefaultStorageCostQueryKey = () => {
|
|
131
|
+
|
|
132
|
+
return ["account-server-api", `/product-default-storage-cost`] as const;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
export const getGetProductDefaultStorageCostQueryOptions = <TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError = ErrorType<AsError | void>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
121
137
|
) => {
|
|
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;
|
|
138
|
+
|
|
139
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
140
|
+
|
|
141
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductDefaultStorageCostQueryKey();
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductDefaultStorageCost>>> = ({ signal }) => getProductDefaultStorageCost(requestOptions, signal);
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData> & { queryKey: QueryKey }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type GetProductDefaultStorageCostQueryResult = NonNullable<Awaited<ReturnType<typeof getProductDefaultStorageCost>>>
|
|
155
|
+
export type GetProductDefaultStorageCostQueryError = ErrorType<AsError | void>
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @summary Gets the default cross-product storage cost
|
|
159
|
+
*/
|
|
160
|
+
export const useGetProductDefaultStorageCost = <TData = Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError = ErrorType<AsError | void>>(
|
|
161
|
+
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductDefaultStorageCost>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
162
|
+
|
|
163
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
164
|
+
|
|
165
|
+
const queryOptions = getGetProductDefaultStorageCostQueryOptions(options)
|
|
166
|
+
|
|
167
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
168
|
+
|
|
169
|
+
query.queryKey = queryOptions.queryKey ;
|
|
181
170
|
|
|
182
171
|
return query;
|
|
183
|
-
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
184
175
|
|
|
185
176
|
/**
|
|
186
177
|
* Gets Products you have access to, across all **Units** and **Organisations**
|
|
@@ -188,67 +179,63 @@ export const useGetProductDefaultStorageCost = <
|
|
|
188
179
|
* @summary Gets all Products
|
|
189
180
|
*/
|
|
190
181
|
export const getProducts = (
|
|
191
|
-
|
|
192
|
-
|
|
182
|
+
|
|
183
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
184
|
+
) => {
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
return customInstance<ProductsGetResponse>(
|
|
188
|
+
{url: `/product`, method: 'get', signal
|
|
189
|
+
},
|
|
190
|
+
options);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
export const getGetProductsQueryKey = () => {
|
|
195
|
+
|
|
196
|
+
return ["account-server-api", `/product`] as const;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
export const getGetProductsQueryOptions = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
193
201
|
) => {
|
|
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;
|
|
202
|
+
|
|
203
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
204
|
+
|
|
205
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProducts>>> = ({ signal }) => getProducts(requestOptions, signal);
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData> & { queryKey: QueryKey }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export type GetProductsQueryResult = NonNullable<Awaited<ReturnType<typeof getProducts>>>
|
|
219
|
+
export type GetProductsQueryError = ErrorType<AsError | void>
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @summary Gets all Products
|
|
223
|
+
*/
|
|
224
|
+
export const useGetProducts = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>(
|
|
225
|
+
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
226
|
+
|
|
227
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
228
|
+
|
|
229
|
+
const queryOptions = getGetProductsQueryOptions(options)
|
|
230
|
+
|
|
231
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
232
|
+
|
|
233
|
+
query.queryKey = queryOptions.queryKey ;
|
|
249
234
|
|
|
250
235
|
return query;
|
|
251
|
-
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
252
239
|
|
|
253
240
|
/**
|
|
254
241
|
* Gets Products you have access to based on an **Organisation**
|
|
@@ -256,81 +243,63 @@ export const useGetProducts = <
|
|
|
256
243
|
* @summary Gets Products for an Organisation
|
|
257
244
|
*/
|
|
258
245
|
export const getProductsForOrganisation = (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
signal?: AbortSignal
|
|
246
|
+
orgId: string,
|
|
247
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
262
248
|
) => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
export const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
export
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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;
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
return customInstance<ProductsGetResponse>(
|
|
252
|
+
{url: `/product/organisation/${orgId}`, method: 'get', signal
|
|
253
|
+
},
|
|
254
|
+
options);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
export const getGetProductsForOrganisationQueryKey = (orgId: string,) => {
|
|
259
|
+
|
|
260
|
+
return ["account-server-api", `/product/organisation/${orgId}`] as const;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
export const getGetProductsForOrganisationQueryOptions = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(orgId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
265
|
+
) => {
|
|
266
|
+
|
|
267
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
268
|
+
|
|
269
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsForOrganisationQueryKey(orgId);
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForOrganisation>>> = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData> & { queryKey: QueryKey }
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export type GetProductsForOrganisationQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForOrganisation>>>
|
|
283
|
+
export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @summary Gets Products for an Organisation
|
|
287
|
+
*/
|
|
288
|
+
export const useGetProductsForOrganisation = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(
|
|
289
|
+
orgId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
290
|
+
|
|
291
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
292
|
+
|
|
293
|
+
const queryOptions = getGetProductsForOrganisationQueryOptions(orgId,options)
|
|
294
|
+
|
|
295
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
296
|
+
|
|
297
|
+
query.queryKey = queryOptions.queryKey ;
|
|
331
298
|
|
|
332
299
|
return query;
|
|
333
|
-
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
334
303
|
|
|
335
304
|
/**
|
|
336
305
|
* Products are **Subscriptions** that you create in a Unit and use **Merchant** services like the `DATA_MANAGER`.
|
|
@@ -344,152 +313,120 @@ To do this you need to be a member of the **Unit** or the **Organisation**.
|
|
|
344
313
|
* @summary Creates a Product for an Organisational Unit
|
|
345
314
|
*/
|
|
346
315
|
export const createUnitProduct = (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
url: `/product/unit/${unitId}`,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
data: unitProductPostBodyBody,
|
|
316
|
+
unitId: string,
|
|
317
|
+
unitProductPostBodyBody: UnitProductPostBodyBody,
|
|
318
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
return customInstance<UnitProductPostResponse>(
|
|
322
|
+
{url: `/product/unit/${unitId}`, method: 'post',
|
|
323
|
+
headers: {'Content-Type': 'application/json', },
|
|
324
|
+
data: unitProductPostBodyBody
|
|
357
325
|
},
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
>(options?: {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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
|
-
/**
|
|
326
|
+
options);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
export const getCreateUnitProductMutationOptions = <TError = ErrorType<AsError | void>,
|
|
332
|
+
|
|
333
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
334
|
+
): UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext> => {
|
|
335
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createUnitProduct>>, {unitId: string;data: UnitProductPostBodyBody}> = (props) => {
|
|
341
|
+
const {unitId,data} = props ?? {};
|
|
342
|
+
|
|
343
|
+
return createUnitProduct(unitId,data,requestOptions)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
return { mutationFn, ...mutationOptions }}
|
|
350
|
+
|
|
351
|
+
export type CreateUnitProductMutationResult = NonNullable<Awaited<ReturnType<typeof createUnitProduct>>>
|
|
352
|
+
export type CreateUnitProductMutationBody = UnitProductPostBodyBody
|
|
353
|
+
export type CreateUnitProductMutationError = ErrorType<AsError | void>
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @summary Creates a Product for an Organisational Unit
|
|
357
|
+
*/
|
|
358
|
+
export const useCreateUnitProduct = <TError = ErrorType<AsError | void>,
|
|
359
|
+
|
|
360
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
361
|
+
) => {
|
|
362
|
+
|
|
363
|
+
const mutationOptions = getCreateUnitProductMutationOptions(options);
|
|
364
|
+
|
|
365
|
+
return useMutation(mutationOptions);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
416
368
|
* Gets products you have access to based on an Organisational **Unit**
|
|
417
369
|
|
|
418
370
|
* @summary Gets Products for an Organisational Unit
|
|
419
371
|
*/
|
|
420
372
|
export const getProductsForUnit = (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
373
|
+
unitId: string,
|
|
374
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
375
|
+
) => {
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
return customInstance<ProductsGetResponse>(
|
|
379
|
+
{url: `/product/unit/${unitId}`, method: 'get', signal
|
|
380
|
+
},
|
|
381
|
+
options);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
export const getGetProductsForUnitQueryKey = (unitId: string,) => {
|
|
386
|
+
|
|
387
|
+
return ["account-server-api", `/product/unit/${unitId}`] as const;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
export const getGetProductsForUnitQueryOptions = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(unitId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
424
392
|
) => {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
unitId:
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
TData
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const queryKey
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
const queryFn: QueryFunction<
|
|
458
|
-
Awaited<ReturnType<typeof getProductsForUnit>>
|
|
459
|
-
> = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
|
|
460
|
-
|
|
461
|
-
return { queryKey, queryFn, enabled: !!unitId, ...queryOptions };
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
export type GetProductsForUnitQueryResult = NonNullable<
|
|
465
|
-
Awaited<ReturnType<typeof getProductsForUnit>>
|
|
466
|
-
>;
|
|
467
|
-
export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
|
|
468
|
-
|
|
469
|
-
export const useGetProductsForUnit = <
|
|
470
|
-
TData = Awaited<ReturnType<typeof getProductsForUnit>>,
|
|
471
|
-
TError = ErrorType<void | AsError>
|
|
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;
|
|
393
|
+
|
|
394
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
395
|
+
|
|
396
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForUnit>>> = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData> & { queryKey: QueryKey }
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export type GetProductsForUnitQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForUnit>>>
|
|
410
|
+
export type GetProductsForUnitQueryError = ErrorType<void | AsError>
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @summary Gets Products for an Organisational Unit
|
|
414
|
+
*/
|
|
415
|
+
export const useGetProductsForUnit = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(
|
|
416
|
+
unitId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
417
|
+
|
|
418
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
419
|
+
|
|
420
|
+
const queryOptions = getGetProductsForUnitQueryOptions(unitId,options)
|
|
421
|
+
|
|
422
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
423
|
+
|
|
424
|
+
query.queryKey = queryOptions.queryKey ;
|
|
490
425
|
|
|
491
426
|
return query;
|
|
492
|
-
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
|
|
493
430
|
|
|
494
431
|
/**
|
|
495
432
|
* Gets details of a specific Product that you have access to.
|
|
@@ -497,75 +434,63 @@ export const useGetProductsForUnit = <
|
|
|
497
434
|
* @summary Gets a Product
|
|
498
435
|
*/
|
|
499
436
|
export const getProduct = (
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
437
|
+
productId: string,
|
|
438
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
439
|
+
) => {
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
return customInstance<ProductUnitGetResponse>(
|
|
443
|
+
{url: `/product/${productId}`, method: 'get', signal
|
|
444
|
+
},
|
|
445
|
+
options);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
export const getGetProductQueryKey = (productId: string,) => {
|
|
450
|
+
|
|
451
|
+
return ["account-server-api", `/product/${productId}`] as const;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
export const getGetProductQueryOptions = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(productId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
503
456
|
) => {
|
|
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 { queryKey, queryFn, enabled: !!productId, ...queryOptions };
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
export type GetProductQueryResult = NonNullable<
|
|
541
|
-
Awaited<ReturnType<typeof getProduct>>
|
|
542
|
-
>;
|
|
543
|
-
export type GetProductQueryError = ErrorType<AsError | void>;
|
|
544
|
-
|
|
545
|
-
export const useGetProduct = <
|
|
546
|
-
TData = Awaited<ReturnType<typeof getProduct>>,
|
|
547
|
-
TError = ErrorType<AsError | void>
|
|
548
|
-
>(
|
|
549
|
-
productId: string,
|
|
550
|
-
options?: {
|
|
551
|
-
query?: UseQueryOptions<
|
|
552
|
-
Awaited<ReturnType<typeof getProduct>>,
|
|
553
|
-
TError,
|
|
554
|
-
TData
|
|
555
|
-
>;
|
|
556
|
-
request?: SecondParameter<typeof customInstance>;
|
|
557
|
-
}
|
|
558
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
559
|
-
const queryOptions = getGetProductQueryOptions(productId, options);
|
|
560
|
-
|
|
561
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
562
|
-
queryKey: QueryKey;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
query.queryKey = queryOptions.queryKey;
|
|
457
|
+
|
|
458
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
459
|
+
|
|
460
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductQueryKey(productId);
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({ signal }) => getProduct(productId, requestOptions, signal);
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData> & { queryKey: QueryKey }
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export type GetProductQueryResult = NonNullable<Awaited<ReturnType<typeof getProduct>>>
|
|
474
|
+
export type GetProductQueryError = ErrorType<AsError | void>
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* @summary Gets a Product
|
|
478
|
+
*/
|
|
479
|
+
export const useGetProduct = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(
|
|
480
|
+
productId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
481
|
+
|
|
482
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
483
|
+
|
|
484
|
+
const queryOptions = getGetProductQueryOptions(productId,options)
|
|
485
|
+
|
|
486
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
487
|
+
|
|
488
|
+
query.queryKey = queryOptions.queryKey ;
|
|
566
489
|
|
|
567
490
|
return query;
|
|
568
|
-
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
|
|
569
494
|
|
|
570
495
|
/**
|
|
571
496
|
* 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 +498,55 @@ export const useGetProduct = <
|
|
|
573
498
|
* @summary Deletes an existing Product
|
|
574
499
|
*/
|
|
575
500
|
export const deleteProduct = (
|
|
576
|
-
|
|
577
|
-
|
|
501
|
+
productId: string,
|
|
502
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
return customInstance<void>(
|
|
506
|
+
{url: `/product/${productId}`, method: 'delete'
|
|
507
|
+
},
|
|
508
|
+
options);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
export const getDeleteProductMutationOptions = <TError = ErrorType<AsError>,
|
|
514
|
+
|
|
515
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
516
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext> => {
|
|
517
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteProduct>>, {productId: string}> = (props) => {
|
|
523
|
+
const {productId} = props ?? {};
|
|
524
|
+
|
|
525
|
+
return deleteProduct(productId,requestOptions)
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
return { mutationFn, ...mutationOptions }}
|
|
532
|
+
|
|
533
|
+
export type DeleteProductMutationResult = NonNullable<Awaited<ReturnType<typeof deleteProduct>>>
|
|
534
|
+
|
|
535
|
+
export type DeleteProductMutationError = ErrorType<AsError>
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* @summary Deletes an existing Product
|
|
539
|
+
*/
|
|
540
|
+
export const useDeleteProduct = <TError = ErrorType<AsError>,
|
|
541
|
+
|
|
542
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
578
543
|
) => {
|
|
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
|
-
/**
|
|
544
|
+
|
|
545
|
+
const mutationOptions = getDeleteProductMutationOptions(options);
|
|
546
|
+
|
|
547
|
+
return useMutation(mutationOptions);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
639
550
|
* Used to update some adjustable parameters of a Product, i.e. to extend its **Allowance** or **Limit**.
|
|
640
551
|
|
|
641
552
|
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 +554,58 @@ At the moment we only support Products associated with the Data Manager, and the
|
|
|
643
554
|
* @summary Adjust an existing Product
|
|
644
555
|
*/
|
|
645
556
|
export const patchProduct = (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
url: `/product/${productId}`,
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
data: productPatchBodyBody,
|
|
557
|
+
productId: string,
|
|
558
|
+
productPatchBodyBody: ProductPatchBodyBody,
|
|
559
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
return customInstance<void>(
|
|
563
|
+
{url: `/product/${productId}`, method: 'patch',
|
|
564
|
+
headers: {'Content-Type': 'application/json', },
|
|
565
|
+
data: productPatchBodyBody
|
|
656
566
|
},
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
>(options?: {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
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
|
-
/**
|
|
567
|
+
options);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
export const getPatchProductMutationOptions = <TError = ErrorType<AsError>,
|
|
573
|
+
|
|
574
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
575
|
+
): UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext> => {
|
|
576
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof patchProduct>>, {productId: string;data: ProductPatchBodyBody}> = (props) => {
|
|
582
|
+
const {productId,data} = props ?? {};
|
|
583
|
+
|
|
584
|
+
return patchProduct(productId,data,requestOptions)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
return { mutationFn, ...mutationOptions }}
|
|
591
|
+
|
|
592
|
+
export type PatchProductMutationResult = NonNullable<Awaited<ReturnType<typeof patchProduct>>>
|
|
593
|
+
export type PatchProductMutationBody = ProductPatchBodyBody
|
|
594
|
+
export type PatchProductMutationError = ErrorType<AsError>
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* @summary Adjust an existing Product
|
|
598
|
+
*/
|
|
599
|
+
export const usePatchProduct = <TError = ErrorType<AsError>,
|
|
600
|
+
|
|
601
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
602
|
+
) => {
|
|
603
|
+
|
|
604
|
+
const mutationOptions = getPatchProductMutationOptions(options);
|
|
605
|
+
|
|
606
|
+
return useMutation(mutationOptions);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
715
609
|
* 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
610
|
|
|
717
611
|
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 +616,66 @@ You need to be part of the **Unit** or **Organisation** to use this method
|
|
|
722
616
|
* @summary Get charges made against a Product
|
|
723
617
|
*/
|
|
724
618
|
export const getProductCharges = (
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
signal?: AbortSignal
|
|
619
|
+
productId: string,
|
|
620
|
+
params?: GetProductChargesParams,
|
|
621
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
729
622
|
) => {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
query?:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
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;
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
return customInstance<ProductChargesGetResponse>(
|
|
626
|
+
{url: `/product/${productId}/charges`, method: 'get',
|
|
627
|
+
params, signal
|
|
628
|
+
},
|
|
629
|
+
options);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
export const getGetProductChargesQueryKey = (productId: string,
|
|
634
|
+
params?: GetProductChargesParams,) => {
|
|
635
|
+
|
|
636
|
+
return ["account-server-api", `/product/${productId}/charges`, ...(params ? [params]: [])] as const;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
export const getGetProductChargesQueryOptions = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(productId: string,
|
|
641
|
+
params?: GetProductChargesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
642
|
+
) => {
|
|
643
|
+
|
|
644
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
645
|
+
|
|
646
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId,params);
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductCharges>>> = ({ signal }) => getProductCharges(productId,params, requestOptions, signal);
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
export type GetProductChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductCharges>>>
|
|
660
|
+
export type GetProductChargesQueryError = ErrorType<AsError | void>
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* @summary Get charges made against a Product
|
|
664
|
+
*/
|
|
665
|
+
export const useGetProductCharges = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(
|
|
666
|
+
productId: string,
|
|
667
|
+
params?: GetProductChargesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
668
|
+
|
|
669
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
670
|
+
|
|
671
|
+
const queryOptions = getGetProductChargesQueryOptions(productId,params,options)
|
|
672
|
+
|
|
673
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
674
|
+
|
|
675
|
+
query.queryKey = queryOptions.queryKey ;
|
|
804
676
|
|
|
805
677
|
return query;
|
|
806
|
-
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|