@squonk/account-server-client 4.2.5 → 4.4.0-4-4.2174353771
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/actions/actions.cjs +53 -0
- package/actions/actions.cjs.map +1 -0
- package/actions/actions.d.cts +72 -0
- package/actions/actions.d.ts +72 -0
- package/actions/actions.js +53 -0
- package/actions/actions.js.map +1 -0
- package/actions/package.json +7 -0
- package/asset/asset.cjs +99 -126
- package/asset/asset.cjs.map +1 -1
- package/asset/asset.d.cts +99 -99
- package/asset/asset.d.ts +99 -99
- package/asset/asset.js +107 -134
- package/asset/asset.js.map +1 -1
- package/charges/charges.cjs +73 -85
- package/charges/charges.cjs.map +1 -1
- package/charges/charges.d.cts +47 -47
- package/charges/charges.d.ts +47 -47
- package/charges/charges.js +78 -90
- package/charges/charges.js.map +1 -1
- package/chunk-76ADQBHZ.js +25 -0
- package/chunk-76ADQBHZ.js.map +1 -0
- package/chunk-KHB5TJT7.cjs +25 -0
- package/chunk-KHB5TJT7.cjs.map +1 -0
- package/{chunk-TKLTUR4R.cjs → chunk-RB2KVIEK.cjs} +1 -1
- package/chunk-RB2KVIEK.cjs.map +1 -0
- package/{chunk-EBOQPVLG.js → chunk-XYDLYMQ2.js} +1 -1
- package/chunk-XYDLYMQ2.js.map +1 -0
- package/event-stream/event-stream.cjs +53 -61
- package/event-stream/event-stream.cjs.map +1 -1
- package/event-stream/event-stream.d.cts +44 -44
- package/event-stream/event-stream.d.ts +44 -44
- package/event-stream/event-stream.js +58 -66
- package/event-stream/event-stream.js.map +1 -1
- package/index.cjs +56 -58
- package/index.cjs.map +1 -1
- package/index.d.cts +867 -777
- package/index.d.ts +867 -777
- package/index.js +55 -57
- package/index.js.map +1 -1
- package/merchant/merchant.cjs +38 -45
- package/merchant/merchant.cjs.map +1 -1
- package/merchant/merchant.d.cts +25 -25
- package/merchant/merchant.d.ts +25 -25
- package/merchant/merchant.js +42 -49
- package/merchant/merchant.js.map +1 -1
- package/organisation/organisation.cjs +77 -87
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.cts +72 -70
- package/organisation/organisation.d.ts +72 -70
- package/organisation/organisation.js +83 -93
- package/organisation/organisation.js.map +1 -1
- package/package.json +15 -18
- package/product/product.cjs +143 -153
- package/product/product.cjs.map +1 -1
- package/product/product.d.cts +100 -100
- package/product/product.d.ts +100 -100
- package/product/product.js +153 -163
- package/product/product.js.map +1 -1
- package/src/{account-server-api.schemas.ts → API_TARGET_NAME.schemas.ts} +931 -849
- package/src/actions/actions.ts +249 -0
- package/src/asset/asset.ts +899 -634
- package/src/charges/charges.ts +822 -498
- package/src/custom-instance.ts +3 -3
- package/src/event-stream/event-stream.ts +530 -344
- package/src/index.ts +3 -3
- package/src/merchant/merchant.ts +355 -234
- package/src/options-mutator.ts +27 -0
- package/src/organisation/organisation.ts +812 -504
- package/src/product/product.ts +1373 -841
- package/src/state/state.ts +174 -127
- package/src/unit/unit.ts +1273 -603
- package/src/user/user.ts +895 -564
- package/state/state.cjs +22 -24
- package/state/state.cjs.map +1 -1
- package/state/state.d.cts +14 -14
- package/state/state.d.ts +14 -14
- package/state/state.js +24 -26
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +171 -106
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.cts +200 -90
- package/unit/unit.d.ts +200 -90
- package/unit/unit.js +179 -114
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +94 -110
- package/user/user.cjs.map +1 -1
- package/user/user.d.cts +77 -77
- package/user/user.d.ts +77 -77
- package/user/user.js +101 -117
- package/user/user.js.map +1 -1
- package/chunk-EBOQPVLG.js.map +0 -1
- package/chunk-TKLTUR4R.cjs.map +0 -1
package/src/asset/asset.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
|
-
* Generated by orval v7.
|
|
2
|
+
* Generated by orval v7.10.0 🍺
|
|
4
3
|
* Do not edit manually.
|
|
5
4
|
* Account Server API
|
|
6
5
|
* The Informatics Matters Account Server API.
|
|
7
6
|
|
|
8
7
|
A service that provides access to the Account Server, which gives *registered* users access to and management of **Organisations**, **Units**, **Products**, **Users**, and **Assets**.
|
|
9
8
|
|
|
10
|
-
* OpenAPI spec version: 4.
|
|
9
|
+
* OpenAPI spec version: 4.4
|
|
11
10
|
*/
|
|
12
|
-
import {
|
|
13
|
-
useMutation,
|
|
14
|
-
useQuery,
|
|
15
|
-
useSuspenseQuery
|
|
16
|
-
} from '@tanstack/react-query'
|
|
11
|
+
import { useMutation, useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
17
12
|
import type {
|
|
18
13
|
DataTag,
|
|
19
14
|
DefinedInitialDataOptions,
|
|
20
15
|
DefinedUseQueryResult,
|
|
21
16
|
MutationFunction,
|
|
17
|
+
QueryClient,
|
|
22
18
|
QueryFunction,
|
|
23
19
|
QueryKey,
|
|
24
20
|
UndefinedInitialDataOptions,
|
|
@@ -27,8 +23,9 @@ import type {
|
|
|
27
23
|
UseQueryOptions,
|
|
28
24
|
UseQueryResult,
|
|
29
25
|
UseSuspenseQueryOptions,
|
|
30
|
-
UseSuspenseQueryResult
|
|
31
|
-
} from
|
|
26
|
+
UseSuspenseQueryResult,
|
|
27
|
+
} from "@tanstack/react-query";
|
|
28
|
+
|
|
32
29
|
import type {
|
|
33
30
|
AsError,
|
|
34
31
|
AssetDetail,
|
|
@@ -38,14 +35,15 @@ import type {
|
|
|
38
35
|
AssetPostResponse,
|
|
39
36
|
AttachAssetParams,
|
|
40
37
|
DetachAssetParams,
|
|
41
|
-
GetAssetParams
|
|
42
|
-
} from
|
|
43
|
-
import { customInstance } from '.././custom-instance';
|
|
44
|
-
import type { ErrorType } from '.././custom-instance';
|
|
45
|
-
|
|
38
|
+
GetAssetParams,
|
|
39
|
+
} from "../API_TARGET_NAME.schemas";
|
|
46
40
|
|
|
47
|
-
|
|
41
|
+
import { customInstance } from ".././custom-instance";
|
|
42
|
+
import type { ErrorType } from ".././custom-instance";
|
|
43
|
+
import { queryMutator } from ".././options-mutator";
|
|
44
|
+
import { mutationMutator } from ".././options-mutator";
|
|
48
45
|
|
|
46
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
49
|
* Gets Assets you have access to.
|
|
@@ -53,144 +51,211 @@ type SecondParameter<T extends (...args: any) => any> = Parameters<T>[1];
|
|
|
53
51
|
* @summary Gets Assets
|
|
54
52
|
*/
|
|
55
53
|
export const getAsset = (
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
params?: GetAssetParams,
|
|
55
|
+
options?: SecondParameter<typeof customInstance>,
|
|
56
|
+
signal?: AbortSignal,
|
|
58
57
|
) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
return customInstance<AssetGetResponse>(
|
|
59
|
+
{ url: `/asset`, method: "GET", params, signal },
|
|
60
|
+
options,
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const getGetAssetQueryKey = (params?: GetAssetParams) => {
|
|
65
|
+
return [`/asset`, ...(params ? [params] : [])] as const;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const useGetAssetQueryOptions = <
|
|
69
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
70
|
+
TError = ErrorType<AsError | void>,
|
|
71
|
+
>(
|
|
72
|
+
params?: GetAssetParams,
|
|
73
|
+
options?: {
|
|
74
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
75
|
+
request?: SecondParameter<typeof customInstance>;
|
|
76
|
+
},
|
|
75
77
|
) => {
|
|
78
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
76
79
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const queryKey = queryOptions?.queryKey ?? getGetAssetQueryKey(params);
|
|
80
|
+
const queryKey = queryOptions?.queryKey ?? getGetAssetQueryKey(params);
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getAsset>>> = ({ signal }) =>
|
|
83
|
+
getAsset(params, requestOptions, signal);
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
return customOptions as UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData> & {
|
|
88
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
export type GetAssetQueryResult = NonNullable<Awaited<ReturnType<typeof getAsset>>>;
|
|
93
|
+
export type GetAssetQueryError = ErrorType<AsError | void>;
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
params: undefined | GetAssetParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>> & Pick<
|
|
95
|
+
export function useGetAsset<
|
|
96
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
97
|
+
TError = ErrorType<AsError | void>,
|
|
98
|
+
>(
|
|
99
|
+
params: undefined | GetAssetParams,
|
|
100
|
+
options: {
|
|
101
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>> &
|
|
102
|
+
Pick<
|
|
98
103
|
DefinedInitialDataOptions<
|
|
99
104
|
Awaited<ReturnType<typeof getAsset>>,
|
|
100
105
|
TError,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
Awaited<ReturnType<typeof getAsset>>
|
|
107
|
+
>,
|
|
108
|
+
"initialData"
|
|
109
|
+
>;
|
|
110
|
+
request?: SecondParameter<typeof customInstance>;
|
|
111
|
+
},
|
|
112
|
+
queryClient?: QueryClient,
|
|
113
|
+
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
114
|
+
export function useGetAsset<
|
|
115
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
116
|
+
TError = ErrorType<AsError | void>,
|
|
117
|
+
>(
|
|
118
|
+
params?: GetAssetParams,
|
|
119
|
+
options?: {
|
|
120
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>> &
|
|
121
|
+
Pick<
|
|
108
122
|
UndefinedInitialDataOptions<
|
|
109
123
|
Awaited<ReturnType<typeof getAsset>>,
|
|
110
124
|
TError,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
Awaited<ReturnType<typeof getAsset>>
|
|
126
|
+
>,
|
|
127
|
+
"initialData"
|
|
128
|
+
>;
|
|
129
|
+
request?: SecondParameter<typeof customInstance>;
|
|
130
|
+
},
|
|
131
|
+
queryClient?: QueryClient,
|
|
132
|
+
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
133
|
+
export function useGetAsset<
|
|
134
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
135
|
+
TError = ErrorType<AsError | void>,
|
|
136
|
+
>(
|
|
137
|
+
params?: GetAssetParams,
|
|
138
|
+
options?: {
|
|
139
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
140
|
+
request?: SecondParameter<typeof customInstance>;
|
|
141
|
+
},
|
|
142
|
+
queryClient?: QueryClient,
|
|
143
|
+
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
120
144
|
/**
|
|
121
145
|
* @summary Gets Assets
|
|
122
146
|
*/
|
|
123
147
|
|
|
124
|
-
export function useGetAsset<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
148
|
+
export function useGetAsset<
|
|
149
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
150
|
+
TError = ErrorType<AsError | void>,
|
|
151
|
+
>(
|
|
152
|
+
params?: GetAssetParams,
|
|
153
|
+
options?: {
|
|
154
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
155
|
+
request?: SecondParameter<typeof customInstance>;
|
|
156
|
+
},
|
|
157
|
+
queryClient?: QueryClient,
|
|
158
|
+
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
159
|
+
const queryOptions = useGetAssetQueryOptions(params, options);
|
|
160
|
+
|
|
161
|
+
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
|
|
162
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
query.queryKey = queryOptions.queryKey;
|
|
134
166
|
|
|
135
167
|
return query;
|
|
136
168
|
}
|
|
137
169
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
170
|
+
export const useGetAssetSuspenseQueryOptions = <
|
|
171
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
172
|
+
TError = ErrorType<AsError | void>,
|
|
173
|
+
>(
|
|
174
|
+
params?: GetAssetParams,
|
|
175
|
+
options?: {
|
|
176
|
+
query?: Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
177
|
+
request?: SecondParameter<typeof customInstance>;
|
|
178
|
+
},
|
|
141
179
|
) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export type GetAssetSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getAsset
|
|
159
|
-
export type GetAssetSuspenseQueryError = ErrorType<AsError | void
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
181
|
+
|
|
182
|
+
const queryKey = queryOptions?.queryKey ?? getGetAssetQueryKey(params);
|
|
183
|
+
|
|
184
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getAsset>>> = ({ signal }) =>
|
|
185
|
+
getAsset(params, requestOptions, signal);
|
|
186
|
+
|
|
187
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
188
|
+
|
|
189
|
+
return customOptions as UseSuspenseQueryOptions<
|
|
190
|
+
Awaited<ReturnType<typeof getAsset>>,
|
|
191
|
+
TError,
|
|
192
|
+
TData
|
|
193
|
+
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type GetAssetSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getAsset>>>;
|
|
197
|
+
export type GetAssetSuspenseQueryError = ErrorType<AsError | void>;
|
|
198
|
+
|
|
199
|
+
export function useGetAssetSuspense<
|
|
200
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
201
|
+
TError = ErrorType<AsError | void>,
|
|
202
|
+
>(
|
|
203
|
+
params: undefined | GetAssetParams,
|
|
204
|
+
options: {
|
|
205
|
+
query: Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
206
|
+
request?: SecondParameter<typeof customInstance>;
|
|
207
|
+
},
|
|
208
|
+
queryClient?: QueryClient,
|
|
209
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
210
|
+
export function useGetAssetSuspense<
|
|
211
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
212
|
+
TError = ErrorType<AsError | void>,
|
|
213
|
+
>(
|
|
214
|
+
params?: GetAssetParams,
|
|
215
|
+
options?: {
|
|
216
|
+
query?: Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
217
|
+
request?: SecondParameter<typeof customInstance>;
|
|
218
|
+
},
|
|
219
|
+
queryClient?: QueryClient,
|
|
220
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
221
|
+
export function useGetAssetSuspense<
|
|
222
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
223
|
+
TError = ErrorType<AsError | void>,
|
|
224
|
+
>(
|
|
225
|
+
params?: GetAssetParams,
|
|
226
|
+
options?: {
|
|
227
|
+
query?: Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
228
|
+
request?: SecondParameter<typeof customInstance>;
|
|
229
|
+
},
|
|
230
|
+
queryClient?: QueryClient,
|
|
231
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
174
232
|
/**
|
|
175
233
|
* @summary Gets Assets
|
|
176
234
|
*/
|
|
177
235
|
|
|
178
|
-
export function useGetAssetSuspense<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
236
|
+
export function useGetAssetSuspense<
|
|
237
|
+
TData = Awaited<ReturnType<typeof getAsset>>,
|
|
238
|
+
TError = ErrorType<AsError | void>,
|
|
239
|
+
>(
|
|
240
|
+
params?: GetAssetParams,
|
|
241
|
+
options?: {
|
|
242
|
+
query?: Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getAsset>>, TError, TData>>;
|
|
243
|
+
request?: SecondParameter<typeof customInstance>;
|
|
244
|
+
},
|
|
245
|
+
queryClient?: QueryClient,
|
|
246
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
247
|
+
const queryOptions = useGetAssetSuspenseQueryOptions(params, options);
|
|
248
|
+
|
|
249
|
+
const query = useSuspenseQuery(queryOptions, queryClient) as UseSuspenseQueryResult<
|
|
250
|
+
TData,
|
|
251
|
+
TError
|
|
252
|
+
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
253
|
+
|
|
254
|
+
query.queryKey = queryOptions.queryKey;
|
|
188
255
|
|
|
189
256
|
return query;
|
|
190
257
|
}
|
|
191
258
|
|
|
192
|
-
|
|
193
|
-
|
|
194
259
|
/**
|
|
195
260
|
* Creates an Asset, which can be attached to a **User** account, a **Product**, **Unit**, **Organisation** or can be made **Global**
|
|
196
261
|
|
|
@@ -203,224 +268,327 @@ They must also be *attached* to a **Merchant** before the **Merchant** can ue th
|
|
|
203
268
|
* @summary Create an Asset
|
|
204
269
|
*/
|
|
205
270
|
export const createAsset = (
|
|
206
|
-
|
|
207
|
-
|
|
271
|
+
assetPostBodyBody: AssetPostBodyBody,
|
|
272
|
+
options?: SecondParameter<typeof customInstance>,
|
|
273
|
+
signal?: AbortSignal,
|
|
208
274
|
) => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
275
|
+
const formData = new FormData();
|
|
276
|
+
formData.append(`name`, assetPostBodyBody.name);
|
|
277
|
+
if (assetPostBodyBody.content_file !== undefined) {
|
|
278
|
+
formData.append(`content_file`, assetPostBodyBody.content_file);
|
|
279
|
+
}
|
|
280
|
+
if (assetPostBodyBody.content_string !== undefined) {
|
|
281
|
+
formData.append(`content_string`, assetPostBodyBody.content_string);
|
|
282
|
+
}
|
|
283
|
+
formData.append(`scope`, assetPostBodyBody.scope);
|
|
284
|
+
if (assetPostBodyBody.scope_id !== undefined) {
|
|
285
|
+
formData.append(`scope_id`, assetPostBodyBody.scope_id);
|
|
286
|
+
}
|
|
287
|
+
formData.append(`secret`, assetPostBodyBody.secret.toString());
|
|
288
|
+
if (assetPostBodyBody.description !== undefined) {
|
|
289
|
+
formData.append(`description`, assetPostBodyBody.description);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return customInstance<AssetPostResponse>(
|
|
293
|
+
{
|
|
294
|
+
url: `/asset`,
|
|
295
|
+
method: "POST",
|
|
296
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
297
|
+
data: formData,
|
|
298
|
+
signal,
|
|
231
299
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
300
|
+
options,
|
|
301
|
+
);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export const useCreateAssetMutationOptions = <
|
|
305
|
+
TError = ErrorType<AsError | void>,
|
|
306
|
+
TContext = unknown,
|
|
307
|
+
>(options?: {
|
|
308
|
+
mutation?: UseMutationOptions<
|
|
309
|
+
Awaited<ReturnType<typeof createAsset>>,
|
|
310
|
+
TError,
|
|
311
|
+
{ data: AssetPostBodyBody },
|
|
312
|
+
TContext
|
|
313
|
+
>;
|
|
314
|
+
request?: SecondParameter<typeof customInstance>;
|
|
315
|
+
}): UseMutationOptions<
|
|
316
|
+
Awaited<ReturnType<typeof createAsset>>,
|
|
317
|
+
TError,
|
|
318
|
+
{ data: AssetPostBodyBody },
|
|
319
|
+
TContext
|
|
320
|
+
> => {
|
|
321
|
+
const mutationKey = ["createAsset"];
|
|
322
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
323
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
324
|
+
? options
|
|
325
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
326
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
327
|
+
|
|
328
|
+
const mutationFn: MutationFunction<
|
|
329
|
+
Awaited<ReturnType<typeof createAsset>>,
|
|
330
|
+
{ data: AssetPostBodyBody }
|
|
331
|
+
> = (props) => {
|
|
332
|
+
const { data } = props ?? {};
|
|
333
|
+
|
|
334
|
+
return createAsset(data, requestOptions);
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
338
|
+
|
|
339
|
+
return customOptions;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export type CreateAssetMutationResult = NonNullable<Awaited<ReturnType<typeof createAsset>>>;
|
|
343
|
+
export type CreateAssetMutationBody = AssetPostBodyBody;
|
|
344
|
+
export type CreateAssetMutationError = ErrorType<AsError | void>;
|
|
255
345
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{data: AssetPostBodyBody}, TContext>}
|
|
260
|
-
|
|
261
|
-
export type CreateAssetMutationResult = NonNullable<Awaited<ReturnType<typeof createAsset>>>
|
|
262
|
-
export type CreateAssetMutationBody = AssetPostBodyBody
|
|
263
|
-
export type CreateAssetMutationError = ErrorType<AsError | void>
|
|
264
|
-
|
|
265
|
-
/**
|
|
346
|
+
/**
|
|
266
347
|
* @summary Create an Asset
|
|
267
348
|
*/
|
|
268
|
-
export const useCreateAsset = <
|
|
269
|
-
|
|
349
|
+
export const useCreateAsset = <TError = ErrorType<AsError | void>, TContext = unknown>(
|
|
350
|
+
options?: {
|
|
351
|
+
mutation?: UseMutationOptions<
|
|
352
|
+
Awaited<ReturnType<typeof createAsset>>,
|
|
353
|
+
TError,
|
|
354
|
+
{ data: AssetPostBodyBody },
|
|
355
|
+
TContext
|
|
356
|
+
>;
|
|
357
|
+
request?: SecondParameter<typeof customInstance>;
|
|
358
|
+
},
|
|
359
|
+
queryClient?: QueryClient,
|
|
270
360
|
): UseMutationResult<
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
/**
|
|
361
|
+
Awaited<ReturnType<typeof createAsset>>,
|
|
362
|
+
TError,
|
|
363
|
+
{ data: AssetPostBodyBody },
|
|
364
|
+
TContext
|
|
365
|
+
> => {
|
|
366
|
+
const mutationOptions = useCreateAssetMutationOptions(options);
|
|
367
|
+
|
|
368
|
+
return useMutation(mutationOptions, queryClient);
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
282
371
|
* Gets a known Asset
|
|
283
372
|
|
|
284
373
|
* @summary Gets an Asset
|
|
285
374
|
*/
|
|
286
375
|
export const getSpecificAsset = (
|
|
287
|
-
|
|
288
|
-
|
|
376
|
+
assetId: string,
|
|
377
|
+
options?: SecondParameter<typeof customInstance>,
|
|
378
|
+
signal?: AbortSignal,
|
|
289
379
|
) => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
380
|
+
return customInstance<AssetDetail>({ url: `/asset/${assetId}`, method: "GET", signal }, options);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export const getGetSpecificAssetQueryKey = (assetId: string) => {
|
|
384
|
+
return [`/asset/${assetId}`] as const;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export const useGetSpecificAssetQueryOptions = <
|
|
388
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
389
|
+
TError = ErrorType<AsError | void>,
|
|
390
|
+
>(
|
|
391
|
+
assetId: string,
|
|
392
|
+
options?: {
|
|
393
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>>;
|
|
394
|
+
request?: SecondParameter<typeof customInstance>;
|
|
395
|
+
},
|
|
305
396
|
) => {
|
|
397
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
306
398
|
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
const queryKey = queryOptions?.queryKey ?? getGetSpecificAssetQueryKey(assetId);
|
|
399
|
+
const queryKey = queryOptions?.queryKey ?? getGetSpecificAssetQueryKey(assetId);
|
|
310
400
|
|
|
311
|
-
|
|
401
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getSpecificAsset>>> = ({ signal }) =>
|
|
402
|
+
getSpecificAsset(assetId, requestOptions, signal);
|
|
312
403
|
|
|
313
|
-
|
|
404
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
314
405
|
|
|
315
|
-
|
|
406
|
+
return customOptions as UseQueryOptions<
|
|
407
|
+
Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
408
|
+
TError,
|
|
409
|
+
TData
|
|
410
|
+
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
411
|
+
};
|
|
316
412
|
|
|
317
|
-
|
|
413
|
+
export type GetSpecificAssetQueryResult = NonNullable<Awaited<ReturnType<typeof getSpecificAsset>>>;
|
|
414
|
+
export type GetSpecificAssetQueryError = ErrorType<AsError | void>;
|
|
318
415
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
assetId: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>> & Pick<
|
|
416
|
+
export function useGetSpecificAsset<
|
|
417
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
418
|
+
TError = ErrorType<AsError | void>,
|
|
419
|
+
>(
|
|
420
|
+
assetId: string,
|
|
421
|
+
options: {
|
|
422
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>> &
|
|
423
|
+
Pick<
|
|
328
424
|
DefinedInitialDataOptions<
|
|
329
425
|
Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
330
426
|
TError,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
427
|
+
Awaited<ReturnType<typeof getSpecificAsset>>
|
|
428
|
+
>,
|
|
429
|
+
"initialData"
|
|
430
|
+
>;
|
|
431
|
+
request?: SecondParameter<typeof customInstance>;
|
|
432
|
+
},
|
|
433
|
+
queryClient?: QueryClient,
|
|
434
|
+
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
435
|
+
export function useGetSpecificAsset<
|
|
436
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
437
|
+
TError = ErrorType<AsError | void>,
|
|
438
|
+
>(
|
|
439
|
+
assetId: string,
|
|
440
|
+
options?: {
|
|
441
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>> &
|
|
442
|
+
Pick<
|
|
338
443
|
UndefinedInitialDataOptions<
|
|
339
444
|
Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
340
445
|
TError,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
446
|
+
Awaited<ReturnType<typeof getSpecificAsset>>
|
|
447
|
+
>,
|
|
448
|
+
"initialData"
|
|
449
|
+
>;
|
|
450
|
+
request?: SecondParameter<typeof customInstance>;
|
|
451
|
+
},
|
|
452
|
+
queryClient?: QueryClient,
|
|
453
|
+
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
454
|
+
export function useGetSpecificAsset<
|
|
455
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
456
|
+
TError = ErrorType<AsError | void>,
|
|
457
|
+
>(
|
|
458
|
+
assetId: string,
|
|
459
|
+
options?: {
|
|
460
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>>;
|
|
461
|
+
request?: SecondParameter<typeof customInstance>;
|
|
462
|
+
},
|
|
463
|
+
queryClient?: QueryClient,
|
|
464
|
+
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
350
465
|
/**
|
|
351
466
|
* @summary Gets an Asset
|
|
352
467
|
*/
|
|
353
468
|
|
|
354
|
-
export function useGetSpecificAsset<
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
469
|
+
export function useGetSpecificAsset<
|
|
470
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
471
|
+
TError = ErrorType<AsError | void>,
|
|
472
|
+
>(
|
|
473
|
+
assetId: string,
|
|
474
|
+
options?: {
|
|
475
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>>;
|
|
476
|
+
request?: SecondParameter<typeof customInstance>;
|
|
477
|
+
},
|
|
478
|
+
queryClient?: QueryClient,
|
|
479
|
+
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
480
|
+
const queryOptions = useGetSpecificAssetQueryOptions(assetId, options);
|
|
481
|
+
|
|
482
|
+
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
|
|
483
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
query.queryKey = queryOptions.queryKey;
|
|
364
487
|
|
|
365
488
|
return query;
|
|
366
489
|
}
|
|
367
490
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
491
|
+
export const useGetSpecificAssetSuspenseQueryOptions = <
|
|
492
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
493
|
+
TError = ErrorType<AsError | void>,
|
|
494
|
+
>(
|
|
495
|
+
assetId: string,
|
|
496
|
+
options?: {
|
|
497
|
+
query?: Partial<
|
|
498
|
+
UseSuspenseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>
|
|
499
|
+
>;
|
|
500
|
+
request?: SecondParameter<typeof customInstance>;
|
|
501
|
+
},
|
|
371
502
|
) => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export type GetSpecificAssetSuspenseQueryResult = NonNullable<
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
503
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
504
|
+
|
|
505
|
+
const queryKey = queryOptions?.queryKey ?? getGetSpecificAssetQueryKey(assetId);
|
|
506
|
+
|
|
507
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getSpecificAsset>>> = ({ signal }) =>
|
|
508
|
+
getSpecificAsset(assetId, requestOptions, signal);
|
|
509
|
+
|
|
510
|
+
const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
|
|
511
|
+
|
|
512
|
+
return customOptions as UseSuspenseQueryOptions<
|
|
513
|
+
Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
514
|
+
TError,
|
|
515
|
+
TData
|
|
516
|
+
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
export type GetSpecificAssetSuspenseQueryResult = NonNullable<
|
|
520
|
+
Awaited<ReturnType<typeof getSpecificAsset>>
|
|
521
|
+
>;
|
|
522
|
+
export type GetSpecificAssetSuspenseQueryError = ErrorType<AsError | void>;
|
|
523
|
+
|
|
524
|
+
export function useGetSpecificAssetSuspense<
|
|
525
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
526
|
+
TError = ErrorType<AsError | void>,
|
|
527
|
+
>(
|
|
528
|
+
assetId: string,
|
|
529
|
+
options: {
|
|
530
|
+
query: Partial<
|
|
531
|
+
UseSuspenseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>
|
|
532
|
+
>;
|
|
533
|
+
request?: SecondParameter<typeof customInstance>;
|
|
534
|
+
},
|
|
535
|
+
queryClient?: QueryClient,
|
|
536
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
537
|
+
export function useGetSpecificAssetSuspense<
|
|
538
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
539
|
+
TError = ErrorType<AsError | void>,
|
|
540
|
+
>(
|
|
541
|
+
assetId: string,
|
|
542
|
+
options?: {
|
|
543
|
+
query?: Partial<
|
|
544
|
+
UseSuspenseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>
|
|
545
|
+
>;
|
|
546
|
+
request?: SecondParameter<typeof customInstance>;
|
|
547
|
+
},
|
|
548
|
+
queryClient?: QueryClient,
|
|
549
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
550
|
+
export function useGetSpecificAssetSuspense<
|
|
551
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
552
|
+
TError = ErrorType<AsError | void>,
|
|
553
|
+
>(
|
|
554
|
+
assetId: string,
|
|
555
|
+
options?: {
|
|
556
|
+
query?: Partial<
|
|
557
|
+
UseSuspenseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>
|
|
558
|
+
>;
|
|
559
|
+
request?: SecondParameter<typeof customInstance>;
|
|
560
|
+
},
|
|
561
|
+
queryClient?: QueryClient,
|
|
562
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
404
563
|
/**
|
|
405
564
|
* @summary Gets an Asset
|
|
406
565
|
*/
|
|
407
566
|
|
|
408
|
-
export function useGetSpecificAssetSuspense<
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
567
|
+
export function useGetSpecificAssetSuspense<
|
|
568
|
+
TData = Awaited<ReturnType<typeof getSpecificAsset>>,
|
|
569
|
+
TError = ErrorType<AsError | void>,
|
|
570
|
+
>(
|
|
571
|
+
assetId: string,
|
|
572
|
+
options?: {
|
|
573
|
+
query?: Partial<
|
|
574
|
+
UseSuspenseQueryOptions<Awaited<ReturnType<typeof getSpecificAsset>>, TError, TData>
|
|
575
|
+
>;
|
|
576
|
+
request?: SecondParameter<typeof customInstance>;
|
|
577
|
+
},
|
|
578
|
+
queryClient?: QueryClient,
|
|
579
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
580
|
+
const queryOptions = useGetSpecificAssetSuspenseQueryOptions(assetId, options);
|
|
581
|
+
|
|
582
|
+
const query = useSuspenseQuery(queryOptions, queryClient) as UseSuspenseQueryResult<
|
|
583
|
+
TData,
|
|
584
|
+
TError
|
|
585
|
+
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
586
|
+
|
|
587
|
+
query.queryKey = queryOptions.queryKey;
|
|
418
588
|
|
|
419
589
|
return query;
|
|
420
590
|
}
|
|
421
591
|
|
|
422
|
-
|
|
423
|
-
|
|
424
592
|
/**
|
|
425
593
|
* Used to update or replace Asset *Content* or *Description*.
|
|
426
594
|
|
|
@@ -431,268 +599,330 @@ Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the us
|
|
|
431
599
|
* @summary Adjust an existing Asset
|
|
432
600
|
*/
|
|
433
601
|
export const patchAsset = (
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const formData = new FormData();
|
|
439
|
-
if(assetPatchBodyBody.content_file !== undefined) {
|
|
440
|
-
formData.append('content_file', assetPatchBodyBody.content_file)
|
|
441
|
-
}
|
|
442
|
-
if(assetPatchBodyBody.content_string !== undefined) {
|
|
443
|
-
formData.append('content_string', assetPatchBodyBody.content_string)
|
|
444
|
-
}
|
|
445
|
-
if(assetPatchBodyBody.description !== undefined) {
|
|
446
|
-
formData.append('description', assetPatchBodyBody.description)
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return customInstance<void>(
|
|
450
|
-
{url: `/asset/${assetId}`, method: 'PATCH',
|
|
451
|
-
headers: {'Content-Type': 'multipart/form-data', },
|
|
452
|
-
data: formData
|
|
453
|
-
},
|
|
454
|
-
options);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
export const getPatchAssetMutationOptions = <TData = Awaited<ReturnType<typeof patchAsset>>, TError = ErrorType<void | AsError>,
|
|
460
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{assetId: string;data: AssetPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
602
|
+
assetId: string,
|
|
603
|
+
assetPatchBodyBody: AssetPatchBodyBody,
|
|
604
|
+
options?: SecondParameter<typeof customInstance>,
|
|
461
605
|
) => {
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
606
|
+
const formData = new FormData();
|
|
607
|
+
if (assetPatchBodyBody.content_file !== undefined) {
|
|
608
|
+
formData.append(`content_file`, assetPatchBodyBody.content_file);
|
|
609
|
+
}
|
|
610
|
+
if (assetPatchBodyBody.content_string !== undefined) {
|
|
611
|
+
formData.append(`content_string`, assetPatchBodyBody.content_string);
|
|
612
|
+
}
|
|
613
|
+
if (assetPatchBodyBody.description !== undefined) {
|
|
614
|
+
formData.append(`description`, assetPatchBodyBody.description);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return customInstance<void>(
|
|
618
|
+
{
|
|
619
|
+
url: `/asset/${assetId}`,
|
|
620
|
+
method: "PATCH",
|
|
621
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
622
|
+
data: formData,
|
|
623
|
+
},
|
|
624
|
+
options,
|
|
625
|
+
);
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
export const usePatchAssetMutationOptions = <
|
|
629
|
+
TError = ErrorType<void | AsError>,
|
|
630
|
+
TContext = unknown,
|
|
631
|
+
>(options?: {
|
|
632
|
+
mutation?: UseMutationOptions<
|
|
633
|
+
Awaited<ReturnType<typeof patchAsset>>,
|
|
634
|
+
TError,
|
|
635
|
+
{ assetId: string; data: AssetPatchBodyBody },
|
|
636
|
+
TContext
|
|
637
|
+
>;
|
|
638
|
+
request?: SecondParameter<typeof customInstance>;
|
|
639
|
+
}): UseMutationOptions<
|
|
640
|
+
Awaited<ReturnType<typeof patchAsset>>,
|
|
641
|
+
TError,
|
|
642
|
+
{ assetId: string; data: AssetPatchBodyBody },
|
|
643
|
+
TContext
|
|
644
|
+
> => {
|
|
645
|
+
const mutationKey = ["patchAsset"];
|
|
646
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
647
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
648
|
+
? options
|
|
649
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
650
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
651
|
+
|
|
652
|
+
const mutationFn: MutationFunction<
|
|
653
|
+
Awaited<ReturnType<typeof patchAsset>>,
|
|
654
|
+
{ assetId: string; data: AssetPatchBodyBody }
|
|
655
|
+
> = (props) => {
|
|
656
|
+
const { assetId, data } = props ?? {};
|
|
657
|
+
|
|
658
|
+
return patchAsset(assetId, data, requestOptions);
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
662
|
+
|
|
663
|
+
return customOptions;
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
export type PatchAssetMutationResult = NonNullable<Awaited<ReturnType<typeof patchAsset>>>;
|
|
667
|
+
export type PatchAssetMutationBody = AssetPatchBodyBody;
|
|
668
|
+
export type PatchAssetMutationError = ErrorType<void | AsError>;
|
|
486
669
|
|
|
487
|
-
|
|
670
|
+
/**
|
|
488
671
|
* @summary Adjust an existing Asset
|
|
489
672
|
*/
|
|
490
|
-
export const usePatchAsset = <
|
|
491
|
-
|
|
673
|
+
export const usePatchAsset = <TError = ErrorType<void | AsError>, TContext = unknown>(
|
|
674
|
+
options?: {
|
|
675
|
+
mutation?: UseMutationOptions<
|
|
676
|
+
Awaited<ReturnType<typeof patchAsset>>,
|
|
677
|
+
TError,
|
|
678
|
+
{ assetId: string; data: AssetPatchBodyBody },
|
|
679
|
+
TContext
|
|
680
|
+
>;
|
|
681
|
+
request?: SecondParameter<typeof customInstance>;
|
|
682
|
+
},
|
|
683
|
+
queryClient?: QueryClient,
|
|
492
684
|
): UseMutationResult<
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
/**
|
|
685
|
+
Awaited<ReturnType<typeof patchAsset>>,
|
|
686
|
+
TError,
|
|
687
|
+
{ assetId: string; data: AssetPatchBodyBody },
|
|
688
|
+
TContext
|
|
689
|
+
> => {
|
|
690
|
+
const mutationOptions = usePatchAssetMutationOptions(options);
|
|
691
|
+
|
|
692
|
+
return useMutation(mutationOptions, queryClient);
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
504
695
|
* Deletes a known Asset. Assets that are attached to **Merchants** cannot be deleted
|
|
505
696
|
|
|
506
697
|
Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the user for `USER` scoped assets, a member of the **Unit** for `UNIT` and `PRODUCT` scoped assets, or a member of the **Organisation** for `ORGANISATION` scoped assets. Administrators can patch any asset.
|
|
507
698
|
|
|
508
699
|
* @summary Deletes an Asset
|
|
509
700
|
*/
|
|
510
|
-
export const deleteAsset = (
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
)
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
701
|
+
export const deleteAsset = (assetId: string, options?: SecondParameter<typeof customInstance>) => {
|
|
702
|
+
return customInstance<void>({ url: `/asset/${assetId}`, method: "DELETE" }, options);
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
export const useDeleteAssetMutationOptions = <
|
|
706
|
+
TError = ErrorType<AsError | void>,
|
|
707
|
+
TContext = unknown,
|
|
708
|
+
>(options?: {
|
|
709
|
+
mutation?: UseMutationOptions<
|
|
710
|
+
Awaited<ReturnType<typeof deleteAsset>>,
|
|
711
|
+
TError,
|
|
712
|
+
{ assetId: string },
|
|
713
|
+
TContext
|
|
714
|
+
>;
|
|
715
|
+
request?: SecondParameter<typeof customInstance>;
|
|
716
|
+
}): UseMutationOptions<
|
|
717
|
+
Awaited<ReturnType<typeof deleteAsset>>,
|
|
718
|
+
TError,
|
|
719
|
+
{ assetId: string },
|
|
720
|
+
TContext
|
|
721
|
+
> => {
|
|
722
|
+
const mutationKey = ["deleteAsset"];
|
|
723
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
724
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
725
|
+
? options
|
|
726
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
727
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
728
|
+
|
|
729
|
+
const mutationFn: MutationFunction<
|
|
730
|
+
Awaited<ReturnType<typeof deleteAsset>>,
|
|
731
|
+
{ assetId: string }
|
|
732
|
+
> = (props) => {
|
|
733
|
+
const { assetId } = props ?? {};
|
|
734
|
+
|
|
735
|
+
return deleteAsset(assetId, requestOptions);
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
739
|
+
|
|
740
|
+
return customOptions;
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
export type DeleteAssetMutationResult = NonNullable<Awaited<ReturnType<typeof deleteAsset>>>;
|
|
744
|
+
|
|
745
|
+
export type DeleteAssetMutationError = ErrorType<AsError | void>;
|
|
541
746
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{assetId: string}, TContext>}
|
|
546
|
-
|
|
547
|
-
export type DeleteAssetMutationResult = NonNullable<Awaited<ReturnType<typeof deleteAsset>>>
|
|
548
|
-
|
|
549
|
-
export type DeleteAssetMutationError = ErrorType<AsError | void>
|
|
550
|
-
|
|
551
|
-
/**
|
|
747
|
+
/**
|
|
552
748
|
* @summary Deletes an Asset
|
|
553
749
|
*/
|
|
554
|
-
export const useDeleteAsset = <
|
|
555
|
-
|
|
750
|
+
export const useDeleteAsset = <TError = ErrorType<AsError | void>, TContext = unknown>(
|
|
751
|
+
options?: {
|
|
752
|
+
mutation?: UseMutationOptions<
|
|
753
|
+
Awaited<ReturnType<typeof deleteAsset>>,
|
|
754
|
+
TError,
|
|
755
|
+
{ assetId: string },
|
|
756
|
+
TContext
|
|
757
|
+
>;
|
|
758
|
+
request?: SecondParameter<typeof customInstance>;
|
|
759
|
+
},
|
|
760
|
+
queryClient?: QueryClient,
|
|
556
761
|
): UseMutationResult<
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
/**
|
|
762
|
+
Awaited<ReturnType<typeof deleteAsset>>,
|
|
763
|
+
TError,
|
|
764
|
+
{ assetId: string },
|
|
765
|
+
TContext
|
|
766
|
+
> => {
|
|
767
|
+
const mutationOptions = useDeleteAssetMutationOptions(options);
|
|
768
|
+
|
|
769
|
+
return useMutation(mutationOptions, queryClient);
|
|
770
|
+
};
|
|
771
|
+
/**
|
|
568
772
|
* Disables a known Asset
|
|
569
773
|
|
|
570
774
|
Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the user for `USER` scoped assets, a member of the **Unit** for `UNIT` and `PRODUCT` scoped assets, or a member of the **Organisation** for `ORGANISATION` scoped assets. Administrators can patch any asset.
|
|
571
775
|
|
|
572
776
|
* @summary Disables an Asset
|
|
573
777
|
*/
|
|
574
|
-
export const disableAsset = (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
)
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
778
|
+
export const disableAsset = (assetId: string, options?: SecondParameter<typeof customInstance>) => {
|
|
779
|
+
return customInstance<void>({ url: `/asset/${assetId}/disable`, method: "PATCH" }, options);
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
export const useDisableAssetMutationOptions = <
|
|
783
|
+
TError = ErrorType<AsError | void>,
|
|
784
|
+
TContext = unknown,
|
|
785
|
+
>(options?: {
|
|
786
|
+
mutation?: UseMutationOptions<
|
|
787
|
+
Awaited<ReturnType<typeof disableAsset>>,
|
|
788
|
+
TError,
|
|
789
|
+
{ assetId: string },
|
|
790
|
+
TContext
|
|
791
|
+
>;
|
|
792
|
+
request?: SecondParameter<typeof customInstance>;
|
|
793
|
+
}): UseMutationOptions<
|
|
794
|
+
Awaited<ReturnType<typeof disableAsset>>,
|
|
795
|
+
TError,
|
|
796
|
+
{ assetId: string },
|
|
797
|
+
TContext
|
|
798
|
+
> => {
|
|
799
|
+
const mutationKey = ["disableAsset"];
|
|
800
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
801
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
802
|
+
? options
|
|
803
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
804
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
805
|
+
|
|
806
|
+
const mutationFn: MutationFunction<
|
|
807
|
+
Awaited<ReturnType<typeof disableAsset>>,
|
|
808
|
+
{ assetId: string }
|
|
809
|
+
> = (props) => {
|
|
810
|
+
const { assetId } = props ?? {};
|
|
811
|
+
|
|
812
|
+
return disableAsset(assetId, requestOptions);
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
816
|
+
|
|
817
|
+
return customOptions;
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
export type DisableAssetMutationResult = NonNullable<Awaited<ReturnType<typeof disableAsset>>>;
|
|
821
|
+
|
|
822
|
+
export type DisableAssetMutationError = ErrorType<AsError | void>;
|
|
596
823
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
const mutationFn: MutationFunction<Awaited<ReturnType<typeof disableAsset>>, {assetId: string}> = (props) => {
|
|
601
|
-
const {assetId} = props ?? {};
|
|
602
|
-
|
|
603
|
-
return disableAsset(assetId,requestOptions)
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{assetId: string}, TContext>}
|
|
610
|
-
|
|
611
|
-
export type DisableAssetMutationResult = NonNullable<Awaited<ReturnType<typeof disableAsset>>>
|
|
612
|
-
|
|
613
|
-
export type DisableAssetMutationError = ErrorType<AsError | void>
|
|
614
|
-
|
|
615
|
-
/**
|
|
824
|
+
/**
|
|
616
825
|
* @summary Disables an Asset
|
|
617
826
|
*/
|
|
618
|
-
export const useDisableAsset = <
|
|
619
|
-
|
|
827
|
+
export const useDisableAsset = <TError = ErrorType<AsError | void>, TContext = unknown>(
|
|
828
|
+
options?: {
|
|
829
|
+
mutation?: UseMutationOptions<
|
|
830
|
+
Awaited<ReturnType<typeof disableAsset>>,
|
|
831
|
+
TError,
|
|
832
|
+
{ assetId: string },
|
|
833
|
+
TContext
|
|
834
|
+
>;
|
|
835
|
+
request?: SecondParameter<typeof customInstance>;
|
|
836
|
+
},
|
|
837
|
+
queryClient?: QueryClient,
|
|
620
838
|
): UseMutationResult<
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
/**
|
|
839
|
+
Awaited<ReturnType<typeof disableAsset>>,
|
|
840
|
+
TError,
|
|
841
|
+
{ assetId: string },
|
|
842
|
+
TContext
|
|
843
|
+
> => {
|
|
844
|
+
const mutationOptions = useDisableAssetMutationOptions(options);
|
|
845
|
+
|
|
846
|
+
return useMutation(mutationOptions, queryClient);
|
|
847
|
+
};
|
|
848
|
+
/**
|
|
632
849
|
* Enables a known Asset
|
|
633
850
|
|
|
634
851
|
Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the user for `USER` scoped assets, a member of the **Unit** for `UNIT` and `PRODUCT` scoped assets, or a member of the **Organisation** for `ORGANISATION` scoped assets. Administrators can patch any asset.
|
|
635
852
|
|
|
636
853
|
* @summary Enables an Asset
|
|
637
854
|
*/
|
|
638
|
-
export const enableAsset = (
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
)
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
855
|
+
export const enableAsset = (assetId: string, options?: SecondParameter<typeof customInstance>) => {
|
|
856
|
+
return customInstance<void>({ url: `/asset/${assetId}/enable`, method: "PATCH" }, options);
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
export const useEnableAssetMutationOptions = <
|
|
860
|
+
TError = ErrorType<AsError | void>,
|
|
861
|
+
TContext = unknown,
|
|
862
|
+
>(options?: {
|
|
863
|
+
mutation?: UseMutationOptions<
|
|
864
|
+
Awaited<ReturnType<typeof enableAsset>>,
|
|
865
|
+
TError,
|
|
866
|
+
{ assetId: string },
|
|
867
|
+
TContext
|
|
868
|
+
>;
|
|
869
|
+
request?: SecondParameter<typeof customInstance>;
|
|
870
|
+
}): UseMutationOptions<
|
|
871
|
+
Awaited<ReturnType<typeof enableAsset>>,
|
|
872
|
+
TError,
|
|
873
|
+
{ assetId: string },
|
|
874
|
+
TContext
|
|
875
|
+
> => {
|
|
876
|
+
const mutationKey = ["enableAsset"];
|
|
877
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
878
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
879
|
+
? options
|
|
880
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
881
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
882
|
+
|
|
883
|
+
const mutationFn: MutationFunction<
|
|
884
|
+
Awaited<ReturnType<typeof enableAsset>>,
|
|
885
|
+
{ assetId: string }
|
|
886
|
+
> = (props) => {
|
|
887
|
+
const { assetId } = props ?? {};
|
|
888
|
+
|
|
889
|
+
return enableAsset(assetId, requestOptions);
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
893
|
+
|
|
894
|
+
return customOptions;
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
export type EnableAssetMutationResult = NonNullable<Awaited<ReturnType<typeof enableAsset>>>;
|
|
898
|
+
|
|
899
|
+
export type EnableAssetMutationError = ErrorType<AsError | void>;
|
|
674
900
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
export type EnableAssetMutationError = ErrorType<AsError | void>
|
|
678
|
-
|
|
679
|
-
/**
|
|
901
|
+
/**
|
|
680
902
|
* @summary Enables an Asset
|
|
681
903
|
*/
|
|
682
|
-
export const useEnableAsset = <
|
|
683
|
-
|
|
904
|
+
export const useEnableAsset = <TError = ErrorType<AsError | void>, TContext = unknown>(
|
|
905
|
+
options?: {
|
|
906
|
+
mutation?: UseMutationOptions<
|
|
907
|
+
Awaited<ReturnType<typeof enableAsset>>,
|
|
908
|
+
TError,
|
|
909
|
+
{ assetId: string },
|
|
910
|
+
TContext
|
|
911
|
+
>;
|
|
912
|
+
request?: SecondParameter<typeof customInstance>;
|
|
913
|
+
},
|
|
914
|
+
queryClient?: QueryClient,
|
|
684
915
|
): UseMutationResult<
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
/**
|
|
916
|
+
Awaited<ReturnType<typeof enableAsset>>,
|
|
917
|
+
TError,
|
|
918
|
+
{ assetId: string },
|
|
919
|
+
TContext
|
|
920
|
+
> => {
|
|
921
|
+
const mutationOptions = useEnableAssetMutationOptions(options);
|
|
922
|
+
|
|
923
|
+
return useMutation(mutationOptions, queryClient);
|
|
924
|
+
};
|
|
925
|
+
/**
|
|
696
926
|
* Attaches an Asset to a **Merchant**. This allows the **Merchant** to query the Asset. **Merchants** cannot obtain Assets that are not attached to them.
|
|
697
927
|
|
|
698
928
|
Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the user for `USER` scoped assets, a member of the **Unit** for `UNIT` and `PRODUCT` scoped assets, or a member of the **Organisation** for `ORGANISATION` scoped assets. Administrators can patch any asset.
|
|
@@ -700,65 +930,83 @@ Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the us
|
|
|
700
930
|
* @summary Attaches an Asset to a Merchant
|
|
701
931
|
*/
|
|
702
932
|
export const attachAsset = (
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
return customInstance<void>(
|
|
709
|
-
{url: `/asset/${assetId}/attach`, method: 'PATCH',
|
|
710
|
-
params
|
|
711
|
-
},
|
|
712
|
-
options);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
export const getAttachAssetMutationOptions = <TData = Awaited<ReturnType<typeof attachAsset>>, TError = ErrorType<AsError | void>,
|
|
718
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{assetId: string;params?: AttachAssetParams}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
933
|
+
assetId: string,
|
|
934
|
+
params?: AttachAssetParams,
|
|
935
|
+
options?: SecondParameter<typeof customInstance>,
|
|
719
936
|
) => {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
937
|
+
return customInstance<void>(
|
|
938
|
+
{ url: `/asset/${assetId}/attach`, method: "PATCH", params },
|
|
939
|
+
options,
|
|
940
|
+
);
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
export const useAttachAssetMutationOptions = <
|
|
944
|
+
TError = ErrorType<AsError | void>,
|
|
945
|
+
TContext = unknown,
|
|
946
|
+
>(options?: {
|
|
947
|
+
mutation?: UseMutationOptions<
|
|
948
|
+
Awaited<ReturnType<typeof attachAsset>>,
|
|
949
|
+
TError,
|
|
950
|
+
{ assetId: string; params?: AttachAssetParams },
|
|
951
|
+
TContext
|
|
952
|
+
>;
|
|
953
|
+
request?: SecondParameter<typeof customInstance>;
|
|
954
|
+
}): UseMutationOptions<
|
|
955
|
+
Awaited<ReturnType<typeof attachAsset>>,
|
|
956
|
+
TError,
|
|
957
|
+
{ assetId: string; params?: AttachAssetParams },
|
|
958
|
+
TContext
|
|
959
|
+
> => {
|
|
960
|
+
const mutationKey = ["attachAsset"];
|
|
961
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
962
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
963
|
+
? options
|
|
964
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
965
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
966
|
+
|
|
967
|
+
const mutationFn: MutationFunction<
|
|
968
|
+
Awaited<ReturnType<typeof attachAsset>>,
|
|
969
|
+
{ assetId: string; params?: AttachAssetParams }
|
|
970
|
+
> = (props) => {
|
|
971
|
+
const { assetId, params } = props ?? {};
|
|
972
|
+
|
|
973
|
+
return attachAsset(assetId, params, requestOptions);
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
977
|
+
|
|
978
|
+
return customOptions;
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
export type AttachAssetMutationResult = NonNullable<Awaited<ReturnType<typeof attachAsset>>>;
|
|
982
|
+
|
|
983
|
+
export type AttachAssetMutationError = ErrorType<AsError | void>;
|
|
732
984
|
|
|
733
|
-
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{assetId: string;params?: AttachAssetParams}, TContext>}
|
|
740
|
-
|
|
741
|
-
export type AttachAssetMutationResult = NonNullable<Awaited<ReturnType<typeof attachAsset>>>
|
|
742
|
-
|
|
743
|
-
export type AttachAssetMutationError = ErrorType<AsError | void>
|
|
744
|
-
|
|
745
|
-
/**
|
|
985
|
+
/**
|
|
746
986
|
* @summary Attaches an Asset to a Merchant
|
|
747
987
|
*/
|
|
748
|
-
export const useAttachAsset = <
|
|
749
|
-
|
|
988
|
+
export const useAttachAsset = <TError = ErrorType<AsError | void>, TContext = unknown>(
|
|
989
|
+
options?: {
|
|
990
|
+
mutation?: UseMutationOptions<
|
|
991
|
+
Awaited<ReturnType<typeof attachAsset>>,
|
|
992
|
+
TError,
|
|
993
|
+
{ assetId: string; params?: AttachAssetParams },
|
|
994
|
+
TContext
|
|
995
|
+
>;
|
|
996
|
+
request?: SecondParameter<typeof customInstance>;
|
|
997
|
+
},
|
|
998
|
+
queryClient?: QueryClient,
|
|
750
999
|
): UseMutationResult<
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
/**
|
|
1000
|
+
Awaited<ReturnType<typeof attachAsset>>,
|
|
1001
|
+
TError,
|
|
1002
|
+
{ assetId: string; params?: AttachAssetParams },
|
|
1003
|
+
TContext
|
|
1004
|
+
> => {
|
|
1005
|
+
const mutationOptions = useAttachAssetMutationOptions(options);
|
|
1006
|
+
|
|
1007
|
+
return useMutation(mutationOptions, queryClient);
|
|
1008
|
+
};
|
|
1009
|
+
/**
|
|
762
1010
|
* Detaches an Asset from a **Merchant**
|
|
763
1011
|
|
|
764
1012
|
Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the user for `USER` scoped assets, a member of the **Unit** for `UNIT` and `PRODUCT` scoped assets, or a member of the **Organisation** for `ORGANISATION` scoped assets. Administrators can patch any asset.
|
|
@@ -766,62 +1014,79 @@ Anyone can alter a `GLOBAL` asset. For other *scopes* you will need to be the us
|
|
|
766
1014
|
* @summary Detaches an Asset from a Merchant
|
|
767
1015
|
*/
|
|
768
1016
|
export const detachAsset = (
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
return customInstance<void>(
|
|
775
|
-
{url: `/asset/${assetId}/detach`, method: 'PATCH',
|
|
776
|
-
params
|
|
777
|
-
},
|
|
778
|
-
options);
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
export const getDetachAssetMutationOptions = <TData = Awaited<ReturnType<typeof detachAsset>>, TError = ErrorType<AsError | void>,
|
|
784
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{assetId: string;params?: DetachAssetParams}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
1017
|
+
assetId: string,
|
|
1018
|
+
params?: DetachAssetParams,
|
|
1019
|
+
options?: SecondParameter<typeof customInstance>,
|
|
785
1020
|
) => {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1021
|
+
return customInstance<void>(
|
|
1022
|
+
{ url: `/asset/${assetId}/detach`, method: "PATCH", params },
|
|
1023
|
+
options,
|
|
1024
|
+
);
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
export const useDetachAssetMutationOptions = <
|
|
1028
|
+
TError = ErrorType<AsError | void>,
|
|
1029
|
+
TContext = unknown,
|
|
1030
|
+
>(options?: {
|
|
1031
|
+
mutation?: UseMutationOptions<
|
|
1032
|
+
Awaited<ReturnType<typeof detachAsset>>,
|
|
1033
|
+
TError,
|
|
1034
|
+
{ assetId: string; params?: DetachAssetParams },
|
|
1035
|
+
TContext
|
|
1036
|
+
>;
|
|
1037
|
+
request?: SecondParameter<typeof customInstance>;
|
|
1038
|
+
}): UseMutationOptions<
|
|
1039
|
+
Awaited<ReturnType<typeof detachAsset>>,
|
|
1040
|
+
TError,
|
|
1041
|
+
{ assetId: string; params?: DetachAssetParams },
|
|
1042
|
+
TContext
|
|
1043
|
+
> => {
|
|
1044
|
+
const mutationKey = ["detachAsset"];
|
|
1045
|
+
const { mutation: mutationOptions, request: requestOptions } = options
|
|
1046
|
+
? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey
|
|
1047
|
+
? options
|
|
1048
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
1049
|
+
: { mutation: { mutationKey }, request: undefined };
|
|
1050
|
+
|
|
1051
|
+
const mutationFn: MutationFunction<
|
|
1052
|
+
Awaited<ReturnType<typeof detachAsset>>,
|
|
1053
|
+
{ assetId: string; params?: DetachAssetParams }
|
|
1054
|
+
> = (props) => {
|
|
1055
|
+
const { assetId, params } = props ?? {};
|
|
1056
|
+
|
|
1057
|
+
return detachAsset(assetId, params, requestOptions);
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
const customOptions = mutationMutator({ ...mutationOptions, mutationFn });
|
|
1061
|
+
|
|
1062
|
+
return customOptions;
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
export type DetachAssetMutationResult = NonNullable<Awaited<ReturnType<typeof detachAsset>>>;
|
|
1066
|
+
|
|
1067
|
+
export type DetachAssetMutationError = ErrorType<AsError | void>;
|
|
792
1068
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
const mutationFn: MutationFunction<Awaited<ReturnType<typeof detachAsset>>, {assetId: string;params?: DetachAssetParams}> = (props) => {
|
|
797
|
-
const {assetId,params} = props ?? {};
|
|
798
|
-
|
|
799
|
-
return detachAsset(assetId,params,requestOptions)
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{assetId: string;params?: DetachAssetParams}, TContext>}
|
|
806
|
-
|
|
807
|
-
export type DetachAssetMutationResult = NonNullable<Awaited<ReturnType<typeof detachAsset>>>
|
|
808
|
-
|
|
809
|
-
export type DetachAssetMutationError = ErrorType<AsError | void>
|
|
810
|
-
|
|
811
|
-
/**
|
|
1069
|
+
/**
|
|
812
1070
|
* @summary Detaches an Asset from a Merchant
|
|
813
1071
|
*/
|
|
814
|
-
export const useDetachAsset = <
|
|
815
|
-
|
|
1072
|
+
export const useDetachAsset = <TError = ErrorType<AsError | void>, TContext = unknown>(
|
|
1073
|
+
options?: {
|
|
1074
|
+
mutation?: UseMutationOptions<
|
|
1075
|
+
Awaited<ReturnType<typeof detachAsset>>,
|
|
1076
|
+
TError,
|
|
1077
|
+
{ assetId: string; params?: DetachAssetParams },
|
|
1078
|
+
TContext
|
|
1079
|
+
>;
|
|
1080
|
+
request?: SecondParameter<typeof customInstance>;
|
|
1081
|
+
},
|
|
1082
|
+
queryClient?: QueryClient,
|
|
816
1083
|
): UseMutationResult<
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
}
|
|
827
|
-
|
|
1084
|
+
Awaited<ReturnType<typeof detachAsset>>,
|
|
1085
|
+
TError,
|
|
1086
|
+
{ assetId: string; params?: DetachAssetParams },
|
|
1087
|
+
TContext
|
|
1088
|
+
> => {
|
|
1089
|
+
const mutationOptions = useDetachAssetMutationOptions(options);
|
|
1090
|
+
|
|
1091
|
+
return useMutation(mutationOptions, queryClient);
|
|
1092
|
+
};
|