@squonk/account-server-client 0.1.30 → 0.1.32-rc.1

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.
Files changed (59) hide show
  1. package/asset/asset.cjs +130 -0
  2. package/asset/asset.cjs.map +1 -0
  3. package/asset/asset.d.ts +126 -0
  4. package/asset/asset.js +130 -0
  5. package/asset/asset.js.map +1 -0
  6. package/asset/package.json +7 -0
  7. package/{custom-instance-13412a15.d.ts → custom-instance-6b9df5d3.d.ts} +124 -34
  8. package/index.cjs +20 -2
  9. package/index.cjs.map +1 -1
  10. package/index.d.ts +1 -1
  11. package/index.js +20 -2
  12. package/index.js.map +1 -1
  13. package/merchant/merchant.cjs +48 -0
  14. package/merchant/merchant.cjs.map +1 -0
  15. package/merchant/merchant.d.ts +39 -0
  16. package/merchant/merchant.js +48 -0
  17. package/merchant/merchant.js.map +1 -0
  18. package/merchant/package.json +7 -0
  19. package/organisation/organisation.cjs +12 -12
  20. package/organisation/organisation.cjs.map +1 -1
  21. package/organisation/organisation.d.ts +10 -9
  22. package/organisation/organisation.js +12 -12
  23. package/organisation/organisation.js.map +1 -1
  24. package/package.json +9 -9
  25. package/product/product.cjs +36 -26
  26. package/product/product.cjs.map +1 -1
  27. package/product/product.d.ts +17 -16
  28. package/product/product.js +36 -26
  29. package/product/product.js.map +1 -1
  30. package/src/account-server-api.schemas.ts +152 -46
  31. package/src/asset/asset.ts +430 -0
  32. package/src/merchant/merchant.ts +145 -0
  33. package/src/organisation/organisation.ts +37 -37
  34. package/src/product/product.ts +91 -74
  35. package/src/state/state.ts +19 -16
  36. package/src/unit/unit.ts +64 -56
  37. package/src/user/user.ts +63 -62
  38. package/state/state.cjs +6 -4
  39. package/state/state.cjs.map +1 -1
  40. package/state/state.d.ts +7 -6
  41. package/state/state.js +6 -4
  42. package/state/state.js.map +1 -1
  43. package/unit/unit.cjs +22 -18
  44. package/unit/unit.cjs.map +1 -1
  45. package/unit/unit.d.ts +14 -13
  46. package/unit/unit.js +22 -18
  47. package/unit/unit.js.map +1 -1
  48. package/user/user.cjs +22 -20
  49. package/user/user.cjs.map +1 -1
  50. package/user/user.d.ts +14 -13
  51. package/user/user.js +22 -20
  52. package/user/user.js.map +1 -1
  53. package/service/package.json +0 -7
  54. package/service/service.cjs +0 -44
  55. package/service/service.cjs.map +0 -1
  56. package/service/service.d.ts +0 -49
  57. package/service/service.js +0 -44
  58. package/service/service.js.map +0 -1
  59. package/src/service/service.ts +0 -136
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.7.1 🍺
2
+ * Generated by orval v6.8.0 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -27,12 +27,9 @@ import type {
27
27
  } from "../account-server-api.schemas";
28
28
  import { customInstance, ErrorType } from ".././custom-instance";
29
29
 
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
32
- ...args: any
33
- ) => Promise<infer R>
34
- ? R
35
- : any;
30
+ export type AwaitedInput<T> = PromiseLike<T> | T;
31
+
32
+ export type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
36
33
 
37
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
35
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -48,10 +45,11 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
48
45
  * @summary Gets Organisations
49
46
  */
50
47
  export const getOrganisations = (
51
- options?: SecondParameter<typeof customInstance>
48
+ options?: SecondParameter<typeof customInstance>,
49
+ signal?: AbortSignal
52
50
  ) => {
53
51
  return customInstance<OrganisationsGetResponse>(
54
- { url: `/organisation`, method: "get" },
52
+ { url: `/organisation`, method: "get", signal },
55
53
  options
56
54
  );
57
55
  };
@@ -59,30 +57,31 @@ export const getOrganisations = (
59
57
  export const getGetOrganisationsQueryKey = () => [`/organisation`];
60
58
 
61
59
  export type GetOrganisationsQueryResult = NonNullable<
62
- AsyncReturnType<typeof getOrganisations>
60
+ Awaited<ReturnType<typeof getOrganisations>>
63
61
  >;
64
62
  export type GetOrganisationsQueryError = ErrorType<void | AsError>;
65
63
 
66
64
  export const useGetOrganisations = <
67
- TData = AsyncReturnType<typeof getOrganisations>,
65
+ TData = Awaited<ReturnType<typeof getOrganisations>>,
68
66
  TError = ErrorType<void | AsError>
69
67
  >(options?: {
70
68
  query?: UseQueryOptions<
71
- AsyncReturnType<typeof getOrganisations>,
69
+ Awaited<ReturnType<typeof getOrganisations>>,
72
70
  TError,
73
71
  TData
74
72
  >;
75
73
  request?: SecondParameter<typeof customInstance>;
76
74
  }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
77
- const { query: queryOptions, request: requestOptions } = options || {};
75
+ const { query: queryOptions, request: requestOptions } = options ?? {};
78
76
 
79
77
  const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();
80
78
 
81
- const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>
82
- getOrganisations(requestOptions);
79
+ const queryFn: QueryFunction<
80
+ Awaited<ReturnType<typeof getOrganisations>>
81
+ > = ({ signal }) => getOrganisations(requestOptions, signal);
83
82
 
84
83
  const query = useQuery<
85
- AsyncReturnType<typeof getOrganisations>,
84
+ Awaited<ReturnType<typeof getOrganisations>>,
86
85
  TError,
87
86
  TData
88
87
  >(queryKey, queryFn, queryOptions);
@@ -116,7 +115,7 @@ export const createOrganisation = (
116
115
  };
117
116
 
118
117
  export type CreateOrganisationMutationResult = NonNullable<
119
- AsyncReturnType<typeof createOrganisation>
118
+ Awaited<ReturnType<typeof createOrganisation>>
120
119
  >;
121
120
  export type CreateOrganisationMutationBody = OrganisationPostBodyBody;
122
121
  export type CreateOrganisationMutationError = ErrorType<AsError | void>;
@@ -126,26 +125,26 @@ export const useCreateOrganisation = <
126
125
  TContext = unknown
127
126
  >(options?: {
128
127
  mutation?: UseMutationOptions<
129
- AsyncReturnType<typeof createOrganisation>,
128
+ Awaited<ReturnType<typeof createOrganisation>>,
130
129
  TError,
131
130
  { data: OrganisationPostBodyBody },
132
131
  TContext
133
132
  >;
134
133
  request?: SecondParameter<typeof customInstance>;
135
134
  }) => {
136
- const { mutation: mutationOptions, request: requestOptions } = options || {};
135
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
137
136
 
138
137
  const mutationFn: MutationFunction<
139
- AsyncReturnType<typeof createOrganisation>,
138
+ Awaited<ReturnType<typeof createOrganisation>>,
140
139
  { data: OrganisationPostBodyBody }
141
140
  > = (props) => {
142
- const { data } = props || {};
141
+ const { data } = props ?? {};
143
142
 
144
143
  return createOrganisation(data, requestOptions);
145
144
  };
146
145
 
147
146
  return useMutation<
148
- AsyncReturnType<typeof createOrganisation>,
147
+ Awaited<ReturnType<typeof createOrganisation>>,
149
148
  TError,
150
149
  { data: OrganisationPostBodyBody },
151
150
  TContext
@@ -169,7 +168,7 @@ export const deleteOrganisation = (
169
168
  };
170
169
 
171
170
  export type DeleteOrganisationMutationResult = NonNullable<
172
- AsyncReturnType<typeof deleteOrganisation>
171
+ Awaited<ReturnType<typeof deleteOrganisation>>
173
172
  >;
174
173
 
175
174
  export type DeleteOrganisationMutationError = ErrorType<AsError>;
@@ -179,26 +178,26 @@ export const useDeleteOrganisation = <
179
178
  TContext = unknown
180
179
  >(options?: {
181
180
  mutation?: UseMutationOptions<
182
- AsyncReturnType<typeof deleteOrganisation>,
181
+ Awaited<ReturnType<typeof deleteOrganisation>>,
183
182
  TError,
184
183
  { orgId: string },
185
184
  TContext
186
185
  >;
187
186
  request?: SecondParameter<typeof customInstance>;
188
187
  }) => {
189
- const { mutation: mutationOptions, request: requestOptions } = options || {};
188
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
190
189
 
191
190
  const mutationFn: MutationFunction<
192
- AsyncReturnType<typeof deleteOrganisation>,
191
+ Awaited<ReturnType<typeof deleteOrganisation>>,
193
192
  { orgId: string }
194
193
  > = (props) => {
195
- const { orgId } = props || {};
194
+ const { orgId } = props ?? {};
196
195
 
197
196
  return deleteOrganisation(orgId, requestOptions);
198
197
  };
199
198
 
200
199
  return useMutation<
201
- AsyncReturnType<typeof deleteOrganisation>,
200
+ Awaited<ReturnType<typeof deleteOrganisation>>,
202
201
  TError,
203
202
  { orgId: string },
204
203
  TContext
@@ -210,10 +209,11 @@ export const useDeleteOrganisation = <
210
209
  * @summary Gets the (built-in) Default Organisation
211
210
  */
212
211
  export const getDefaultOrganisation = (
213
- options?: SecondParameter<typeof customInstance>
212
+ options?: SecondParameter<typeof customInstance>,
213
+ signal?: AbortSignal
214
214
  ) => {
215
215
  return customInstance<OrganisationGetDefaultResponse>(
216
- { url: `/organisation/default`, method: "get" },
216
+ { url: `/organisation/default`, method: "get", signal },
217
217
  options
218
218
  );
219
219
  };
@@ -223,32 +223,32 @@ export const getGetDefaultOrganisationQueryKey = () => [
223
223
  ];
224
224
 
225
225
  export type GetDefaultOrganisationQueryResult = NonNullable<
226
- AsyncReturnType<typeof getDefaultOrganisation>
226
+ Awaited<ReturnType<typeof getDefaultOrganisation>>
227
227
  >;
228
228
  export type GetDefaultOrganisationQueryError = ErrorType<void | AsError>;
229
229
 
230
230
  export const useGetDefaultOrganisation = <
231
- TData = AsyncReturnType<typeof getDefaultOrganisation>,
231
+ TData = Awaited<ReturnType<typeof getDefaultOrganisation>>,
232
232
  TError = ErrorType<void | AsError>
233
233
  >(options?: {
234
234
  query?: UseQueryOptions<
235
- AsyncReturnType<typeof getDefaultOrganisation>,
235
+ Awaited<ReturnType<typeof getDefaultOrganisation>>,
236
236
  TError,
237
237
  TData
238
238
  >;
239
239
  request?: SecondParameter<typeof customInstance>;
240
240
  }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
241
- const { query: queryOptions, request: requestOptions } = options || {};
241
+ const { query: queryOptions, request: requestOptions } = options ?? {};
242
242
 
243
243
  const queryKey =
244
244
  queryOptions?.queryKey ?? getGetDefaultOrganisationQueryKey();
245
245
 
246
246
  const queryFn: QueryFunction<
247
- AsyncReturnType<typeof getDefaultOrganisation>
248
- > = () => getDefaultOrganisation(requestOptions);
247
+ Awaited<ReturnType<typeof getDefaultOrganisation>>
248
+ > = ({ signal }) => getDefaultOrganisation(requestOptions, signal);
249
249
 
250
250
  const query = useQuery<
251
- AsyncReturnType<typeof getDefaultOrganisation>,
251
+ Awaited<ReturnType<typeof getDefaultOrganisation>>,
252
252
  TError,
253
253
  TData
254
254
  >(queryKey, queryFn, queryOptions);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.7.1 🍺
2
+ * Generated by orval v6.8.0 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -29,12 +29,9 @@ import type {
29
29
  } from "../account-server-api.schemas";
30
30
  import { customInstance, ErrorType } from ".././custom-instance";
31
31
 
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
- type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
34
- ...args: any
35
- ) => Promise<infer R>
36
- ? R
37
- : any;
32
+ export type AwaitedInput<T> = PromiseLike<T> | T;
33
+
34
+ export type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
38
35
 
39
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
37
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -50,10 +47,11 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
50
47
  * @summary Gets all Product Types
51
48
  */
52
49
  export const getProductTypes = (
53
- options?: SecondParameter<typeof customInstance>
50
+ options?: SecondParameter<typeof customInstance>,
51
+ signal?: AbortSignal
54
52
  ) => {
55
53
  return customInstance<ProductsGetTypesResponse>(
56
- { url: `/product-type`, method: "get" },
54
+ { url: `/product-type`, method: "get", signal },
57
55
  options
58
56
  );
59
57
  };
@@ -61,30 +59,31 @@ export const getProductTypes = (
61
59
  export const getGetProductTypesQueryKey = () => [`/product-type`];
62
60
 
63
61
  export type GetProductTypesQueryResult = NonNullable<
64
- AsyncReturnType<typeof getProductTypes>
62
+ Awaited<ReturnType<typeof getProductTypes>>
65
63
  >;
66
64
  export type GetProductTypesQueryError = ErrorType<AsError | void>;
67
65
 
68
66
  export const useGetProductTypes = <
69
- TData = AsyncReturnType<typeof getProductTypes>,
67
+ TData = Awaited<ReturnType<typeof getProductTypes>>,
70
68
  TError = ErrorType<AsError | void>
71
69
  >(options?: {
72
70
  query?: UseQueryOptions<
73
- AsyncReturnType<typeof getProductTypes>,
71
+ Awaited<ReturnType<typeof getProductTypes>>,
74
72
  TError,
75
73
  TData
76
74
  >;
77
75
  request?: SecondParameter<typeof customInstance>;
78
76
  }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
79
- const { query: queryOptions, request: requestOptions } = options || {};
77
+ const { query: queryOptions, request: requestOptions } = options ?? {};
80
78
 
81
79
  const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
82
80
 
83
- const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>
84
- getProductTypes(requestOptions);
81
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductTypes>>> = ({
82
+ signal,
83
+ }) => getProductTypes(requestOptions, signal);
85
84
 
86
85
  const query = useQuery<
87
- AsyncReturnType<typeof getProductTypes>,
86
+ Awaited<ReturnType<typeof getProductTypes>>,
88
87
  TError,
89
88
  TData
90
89
  >(queryKey, queryFn, queryOptions);
@@ -101,10 +100,11 @@ export const useGetProductTypes = <
101
100
  * @summary Gets all Products
102
101
  */
103
102
  export const getProducts = (
104
- options?: SecondParameter<typeof customInstance>
103
+ options?: SecondParameter<typeof customInstance>,
104
+ signal?: AbortSignal
105
105
  ) => {
106
106
  return customInstance<ProductsGetResponse>(
107
- { url: `/product`, method: "get" },
107
+ { url: `/product`, method: "get", signal },
108
108
  options
109
109
  );
110
110
  };
@@ -112,29 +112,34 @@ export const getProducts = (
112
112
  export const getGetProductsQueryKey = () => [`/product`];
113
113
 
114
114
  export type GetProductsQueryResult = NonNullable<
115
- AsyncReturnType<typeof getProducts>
115
+ Awaited<ReturnType<typeof getProducts>>
116
116
  >;
117
117
  export type GetProductsQueryError = ErrorType<AsError | void>;
118
118
 
119
119
  export const useGetProducts = <
120
- TData = AsyncReturnType<typeof getProducts>,
120
+ TData = Awaited<ReturnType<typeof getProducts>>,
121
121
  TError = ErrorType<AsError | void>
122
122
  >(options?: {
123
- query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;
123
+ query?: UseQueryOptions<
124
+ Awaited<ReturnType<typeof getProducts>>,
125
+ TError,
126
+ TData
127
+ >;
124
128
  request?: SecondParameter<typeof customInstance>;
125
129
  }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
126
- const { query: queryOptions, request: requestOptions } = options || {};
130
+ const { query: queryOptions, request: requestOptions } = options ?? {};
127
131
 
128
132
  const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
129
133
 
130
- const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>
131
- getProducts(requestOptions);
134
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProducts>>> = ({
135
+ signal,
136
+ }) => getProducts(requestOptions, signal);
132
137
 
133
- const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(
134
- queryKey,
135
- queryFn,
136
- queryOptions
137
- );
138
+ const query = useQuery<
139
+ Awaited<ReturnType<typeof getProducts>>,
140
+ TError,
141
+ TData
142
+ >(queryKey, queryFn, queryOptions);
138
143
 
139
144
  return {
140
145
  queryKey,
@@ -149,10 +154,11 @@ export const useGetProducts = <
149
154
  */
150
155
  export const getProductsForOrganisation = (
151
156
  orgId: string,
152
- options?: SecondParameter<typeof customInstance>
157
+ options?: SecondParameter<typeof customInstance>,
158
+ signal?: AbortSignal
153
159
  ) => {
154
160
  return customInstance<ProductsGetResponse>(
155
- { url: `/product/organisation/${orgId}`, method: "get" },
161
+ { url: `/product/organisation/${orgId}`, method: "get", signal },
156
162
  options
157
163
  );
158
164
  };
@@ -162,35 +168,35 @@ export const getGetProductsForOrganisationQueryKey = (orgId: string) => [
162
168
  ];
163
169
 
164
170
  export type GetProductsForOrganisationQueryResult = NonNullable<
165
- AsyncReturnType<typeof getProductsForOrganisation>
171
+ Awaited<ReturnType<typeof getProductsForOrganisation>>
166
172
  >;
167
173
  export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>;
168
174
 
169
175
  export const useGetProductsForOrganisation = <
170
- TData = AsyncReturnType<typeof getProductsForOrganisation>,
176
+ TData = Awaited<ReturnType<typeof getProductsForOrganisation>>,
171
177
  TError = ErrorType<void | AsError>
172
178
  >(
173
179
  orgId: string,
174
180
  options?: {
175
181
  query?: UseQueryOptions<
176
- AsyncReturnType<typeof getProductsForOrganisation>,
182
+ Awaited<ReturnType<typeof getProductsForOrganisation>>,
177
183
  TError,
178
184
  TData
179
185
  >;
180
186
  request?: SecondParameter<typeof customInstance>;
181
187
  }
182
188
  ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
183
- const { query: queryOptions, request: requestOptions } = options || {};
189
+ const { query: queryOptions, request: requestOptions } = options ?? {};
184
190
 
185
191
  const queryKey =
186
192
  queryOptions?.queryKey ?? getGetProductsForOrganisationQueryKey(orgId);
187
193
 
188
194
  const queryFn: QueryFunction<
189
- AsyncReturnType<typeof getProductsForOrganisation>
190
- > = () => getProductsForOrganisation(orgId, requestOptions);
195
+ Awaited<ReturnType<typeof getProductsForOrganisation>>
196
+ > = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
191
197
 
192
198
  const query = useQuery<
193
- AsyncReturnType<typeof getProductsForOrganisation>,
199
+ Awaited<ReturnType<typeof getProductsForOrganisation>>,
194
200
  TError,
195
201
  TData
196
202
  >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions });
@@ -221,7 +227,7 @@ export const createUnitProduct = (
221
227
  };
222
228
 
223
229
  export type CreateUnitProductMutationResult = NonNullable<
224
- AsyncReturnType<typeof createUnitProduct>
230
+ Awaited<ReturnType<typeof createUnitProduct>>
225
231
  >;
226
232
  export type CreateUnitProductMutationBody = UnitProductPostBodyBody;
227
233
  export type CreateUnitProductMutationError = ErrorType<AsError | void>;
@@ -231,26 +237,26 @@ export const useCreateUnitProduct = <
231
237
  TContext = unknown
232
238
  >(options?: {
233
239
  mutation?: UseMutationOptions<
234
- AsyncReturnType<typeof createUnitProduct>,
240
+ Awaited<ReturnType<typeof createUnitProduct>>,
235
241
  TError,
236
242
  { unitId: string; data: UnitProductPostBodyBody },
237
243
  TContext
238
244
  >;
239
245
  request?: SecondParameter<typeof customInstance>;
240
246
  }) => {
241
- const { mutation: mutationOptions, request: requestOptions } = options || {};
247
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
242
248
 
243
249
  const mutationFn: MutationFunction<
244
- AsyncReturnType<typeof createUnitProduct>,
250
+ Awaited<ReturnType<typeof createUnitProduct>>,
245
251
  { unitId: string; data: UnitProductPostBodyBody }
246
252
  > = (props) => {
247
- const { unitId, data } = props || {};
253
+ const { unitId, data } = props ?? {};
248
254
 
249
255
  return createUnitProduct(unitId, data, requestOptions);
250
256
  };
251
257
 
252
258
  return useMutation<
253
- AsyncReturnType<typeof createUnitProduct>,
259
+ Awaited<ReturnType<typeof createUnitProduct>>,
254
260
  TError,
255
261
  { unitId: string; data: UnitProductPostBodyBody },
256
262
  TContext
@@ -263,10 +269,11 @@ export const useCreateUnitProduct = <
263
269
  */
264
270
  export const getProductsForUnit = (
265
271
  unitId: string,
266
- options?: SecondParameter<typeof customInstance>
272
+ options?: SecondParameter<typeof customInstance>,
273
+ signal?: AbortSignal
267
274
  ) => {
268
275
  return customInstance<ProductsGetResponse>(
269
- { url: `/product/unit/${unitId}`, method: "get" },
276
+ { url: `/product/unit/${unitId}`, method: "get", signal },
270
277
  options
271
278
  );
272
279
  };
@@ -276,35 +283,35 @@ export const getGetProductsForUnitQueryKey = (unitId: string) => [
276
283
  ];
277
284
 
278
285
  export type GetProductsForUnitQueryResult = NonNullable<
279
- AsyncReturnType<typeof getProductsForUnit>
286
+ Awaited<ReturnType<typeof getProductsForUnit>>
280
287
  >;
281
288
  export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
282
289
 
283
290
  export const useGetProductsForUnit = <
284
- TData = AsyncReturnType<typeof getProductsForUnit>,
291
+ TData = Awaited<ReturnType<typeof getProductsForUnit>>,
285
292
  TError = ErrorType<void | AsError>
286
293
  >(
287
294
  unitId: string,
288
295
  options?: {
289
296
  query?: UseQueryOptions<
290
- AsyncReturnType<typeof getProductsForUnit>,
297
+ Awaited<ReturnType<typeof getProductsForUnit>>,
291
298
  TError,
292
299
  TData
293
300
  >;
294
301
  request?: SecondParameter<typeof customInstance>;
295
302
  }
296
303
  ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
297
- const { query: queryOptions, request: requestOptions } = options || {};
304
+ const { query: queryOptions, request: requestOptions } = options ?? {};
298
305
 
299
306
  const queryKey =
300
307
  queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
301
308
 
302
309
  const queryFn: QueryFunction<
303
- AsyncReturnType<typeof getProductsForUnit>
304
- > = () => getProductsForUnit(unitId, requestOptions);
310
+ Awaited<ReturnType<typeof getProductsForUnit>>
311
+ > = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
305
312
 
306
313
  const query = useQuery<
307
- AsyncReturnType<typeof getProductsForUnit>,
314
+ Awaited<ReturnType<typeof getProductsForUnit>>,
308
315
  TError,
309
316
  TData
310
317
  >(queryKey, queryFn, { enabled: !!unitId, ...queryOptions });
@@ -323,10 +330,15 @@ export const useGetProductsForUnit = <
323
330
  export const getProduct = (
324
331
  unitId: string,
325
332
  productId: string,
326
- options?: SecondParameter<typeof customInstance>
333
+ options?: SecondParameter<typeof customInstance>,
334
+ signal?: AbortSignal
327
335
  ) => {
328
336
  return customInstance<ProductUnitGetResponse>(
329
- { url: `/product/unit/${unitId}/product/${productId}`, method: "get" },
337
+ {
338
+ url: `/product/unit/${unitId}/product/${productId}`,
339
+ method: "get",
340
+ signal,
341
+ },
330
342
  options
331
343
  );
332
344
  };
@@ -336,30 +348,35 @@ export const getGetProductQueryKey = (unitId: string, productId: string) => [
336
348
  ];
337
349
 
338
350
  export type GetProductQueryResult = NonNullable<
339
- AsyncReturnType<typeof getProduct>
351
+ Awaited<ReturnType<typeof getProduct>>
340
352
  >;
341
353
  export type GetProductQueryError = ErrorType<AsError | void>;
342
354
 
343
355
  export const useGetProduct = <
344
- TData = AsyncReturnType<typeof getProduct>,
356
+ TData = Awaited<ReturnType<typeof getProduct>>,
345
357
  TError = ErrorType<AsError | void>
346
358
  >(
347
359
  unitId: string,
348
360
  productId: string,
349
361
  options?: {
350
- query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;
362
+ query?: UseQueryOptions<
363
+ Awaited<ReturnType<typeof getProduct>>,
364
+ TError,
365
+ TData
366
+ >;
351
367
  request?: SecondParameter<typeof customInstance>;
352
368
  }
353
369
  ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
354
- const { query: queryOptions, request: requestOptions } = options || {};
370
+ const { query: queryOptions, request: requestOptions } = options ?? {};
355
371
 
356
372
  const queryKey =
357
373
  queryOptions?.queryKey ?? getGetProductQueryKey(unitId, productId);
358
374
 
359
- const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>
360
- getProduct(unitId, productId, requestOptions);
375
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({
376
+ signal,
377
+ }) => getProduct(unitId, productId, requestOptions, signal);
361
378
 
362
- const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(
379
+ const query = useQuery<Awaited<ReturnType<typeof getProduct>>, TError, TData>(
363
380
  queryKey,
364
381
  queryFn,
365
382
  { enabled: !!(unitId && productId), ...queryOptions }
@@ -386,7 +403,7 @@ export const deleteProduct = (
386
403
  };
387
404
 
388
405
  export type DeleteProductMutationResult = NonNullable<
389
- AsyncReturnType<typeof deleteProduct>
406
+ Awaited<ReturnType<typeof deleteProduct>>
390
407
  >;
391
408
 
392
409
  export type DeleteProductMutationError = ErrorType<AsError>;
@@ -396,26 +413,26 @@ export const useDeleteProduct = <
396
413
  TContext = unknown
397
414
  >(options?: {
398
415
  mutation?: UseMutationOptions<
399
- AsyncReturnType<typeof deleteProduct>,
416
+ Awaited<ReturnType<typeof deleteProduct>>,
400
417
  TError,
401
418
  { unitId: string; productId: string },
402
419
  TContext
403
420
  >;
404
421
  request?: SecondParameter<typeof customInstance>;
405
422
  }) => {
406
- const { mutation: mutationOptions, request: requestOptions } = options || {};
423
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
407
424
 
408
425
  const mutationFn: MutationFunction<
409
- AsyncReturnType<typeof deleteProduct>,
426
+ Awaited<ReturnType<typeof deleteProduct>>,
410
427
  { unitId: string; productId: string }
411
428
  > = (props) => {
412
- const { unitId, productId } = props || {};
429
+ const { unitId, productId } = props ?? {};
413
430
 
414
431
  return deleteProduct(unitId, productId, requestOptions);
415
432
  };
416
433
 
417
434
  return useMutation<
418
- AsyncReturnType<typeof deleteProduct>,
435
+ Awaited<ReturnType<typeof deleteProduct>>,
419
436
  TError,
420
437
  { unitId: string; productId: string },
421
438
  TContext
@@ -444,7 +461,7 @@ export const patchProduct = (
444
461
  };
445
462
 
446
463
  export type PatchProductMutationResult = NonNullable<
447
- AsyncReturnType<typeof patchProduct>
464
+ Awaited<ReturnType<typeof patchProduct>>
448
465
  >;
449
466
  export type PatchProductMutationBody = ProductPatchBodyBody;
450
467
  export type PatchProductMutationError = ErrorType<AsError>;
@@ -454,26 +471,26 @@ export const usePatchProduct = <
454
471
  TContext = unknown
455
472
  >(options?: {
456
473
  mutation?: UseMutationOptions<
457
- AsyncReturnType<typeof patchProduct>,
474
+ Awaited<ReturnType<typeof patchProduct>>,
458
475
  TError,
459
476
  { unitId: string; productId: string; data: ProductPatchBodyBody },
460
477
  TContext
461
478
  >;
462
479
  request?: SecondParameter<typeof customInstance>;
463
480
  }) => {
464
- const { mutation: mutationOptions, request: requestOptions } = options || {};
481
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
465
482
 
466
483
  const mutationFn: MutationFunction<
467
- AsyncReturnType<typeof patchProduct>,
484
+ Awaited<ReturnType<typeof patchProduct>>,
468
485
  { unitId: string; productId: string; data: ProductPatchBodyBody }
469
486
  > = (props) => {
470
- const { unitId, productId, data } = props || {};
487
+ const { unitId, productId, data } = props ?? {};
471
488
 
472
489
  return patchProduct(unitId, productId, data, requestOptions);
473
490
  };
474
491
 
475
492
  return useMutation<
476
- AsyncReturnType<typeof patchProduct>,
493
+ Awaited<ReturnType<typeof patchProduct>>,
477
494
  TError,
478
495
  { unitId: string; productId: string; data: ProductPatchBodyBody },
479
496
  TContext