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

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 +133 -0
  2. package/asset/asset.cjs.map +1 -0
  3. package/asset/asset.d.ts +126 -0
  4. package/asset/asset.js +133 -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-b985e1be.d.ts} +127 -40
  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 +23 -16
  28. package/product/product.js +36 -26
  29. package/product/product.js.map +1 -1
  30. package/src/account-server-api.schemas.ts +155 -52
  31. package/src/asset/asset.ts +433 -0
  32. package/src/merchant/merchant.ts +145 -0
  33. package/src/organisation/organisation.ts +37 -37
  34. package/src/product/product.ts +97 -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 +16 -15
  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 });
@@ -202,6 +208,12 @@ export const useGetProductsForOrganisation = <
202
208
  };
203
209
 
204
210
  /**
211
+ * Products are **Subscriptions** that you create in a Unit and use **Merchant** services like the `DATA_MANAGER`.
212
+
213
+ Typical subscriptions include `DATA_MANAGER_STORAGE_SUBSCRIPTION` and `DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION`.
214
+
215
+ Some subscriptions, like the `DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION` are available i various **flavours** that influence their capabilities. Flavours are typically referred to using the names `BRONZE`, `SILVER` and `GOLD`
216
+
205
217
  * @summary Creates a Product for an Organisational Unit
206
218
  */
207
219
  export const createUnitProduct = (
@@ -221,7 +233,7 @@ export const createUnitProduct = (
221
233
  };
222
234
 
223
235
  export type CreateUnitProductMutationResult = NonNullable<
224
- AsyncReturnType<typeof createUnitProduct>
236
+ Awaited<ReturnType<typeof createUnitProduct>>
225
237
  >;
226
238
  export type CreateUnitProductMutationBody = UnitProductPostBodyBody;
227
239
  export type CreateUnitProductMutationError = ErrorType<AsError | void>;
@@ -231,26 +243,26 @@ export const useCreateUnitProduct = <
231
243
  TContext = unknown
232
244
  >(options?: {
233
245
  mutation?: UseMutationOptions<
234
- AsyncReturnType<typeof createUnitProduct>,
246
+ Awaited<ReturnType<typeof createUnitProduct>>,
235
247
  TError,
236
248
  { unitId: string; data: UnitProductPostBodyBody },
237
249
  TContext
238
250
  >;
239
251
  request?: SecondParameter<typeof customInstance>;
240
252
  }) => {
241
- const { mutation: mutationOptions, request: requestOptions } = options || {};
253
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
242
254
 
243
255
  const mutationFn: MutationFunction<
244
- AsyncReturnType<typeof createUnitProduct>,
256
+ Awaited<ReturnType<typeof createUnitProduct>>,
245
257
  { unitId: string; data: UnitProductPostBodyBody }
246
258
  > = (props) => {
247
- const { unitId, data } = props || {};
259
+ const { unitId, data } = props ?? {};
248
260
 
249
261
  return createUnitProduct(unitId, data, requestOptions);
250
262
  };
251
263
 
252
264
  return useMutation<
253
- AsyncReturnType<typeof createUnitProduct>,
265
+ Awaited<ReturnType<typeof createUnitProduct>>,
254
266
  TError,
255
267
  { unitId: string; data: UnitProductPostBodyBody },
256
268
  TContext
@@ -263,10 +275,11 @@ export const useCreateUnitProduct = <
263
275
  */
264
276
  export const getProductsForUnit = (
265
277
  unitId: string,
266
- options?: SecondParameter<typeof customInstance>
278
+ options?: SecondParameter<typeof customInstance>,
279
+ signal?: AbortSignal
267
280
  ) => {
268
281
  return customInstance<ProductsGetResponse>(
269
- { url: `/product/unit/${unitId}`, method: "get" },
282
+ { url: `/product/unit/${unitId}`, method: "get", signal },
270
283
  options
271
284
  );
272
285
  };
@@ -276,35 +289,35 @@ export const getGetProductsForUnitQueryKey = (unitId: string) => [
276
289
  ];
277
290
 
278
291
  export type GetProductsForUnitQueryResult = NonNullable<
279
- AsyncReturnType<typeof getProductsForUnit>
292
+ Awaited<ReturnType<typeof getProductsForUnit>>
280
293
  >;
281
294
  export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
282
295
 
283
296
  export const useGetProductsForUnit = <
284
- TData = AsyncReturnType<typeof getProductsForUnit>,
297
+ TData = Awaited<ReturnType<typeof getProductsForUnit>>,
285
298
  TError = ErrorType<void | AsError>
286
299
  >(
287
300
  unitId: string,
288
301
  options?: {
289
302
  query?: UseQueryOptions<
290
- AsyncReturnType<typeof getProductsForUnit>,
303
+ Awaited<ReturnType<typeof getProductsForUnit>>,
291
304
  TError,
292
305
  TData
293
306
  >;
294
307
  request?: SecondParameter<typeof customInstance>;
295
308
  }
296
309
  ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
297
- const { query: queryOptions, request: requestOptions } = options || {};
310
+ const { query: queryOptions, request: requestOptions } = options ?? {};
298
311
 
299
312
  const queryKey =
300
313
  queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
301
314
 
302
315
  const queryFn: QueryFunction<
303
- AsyncReturnType<typeof getProductsForUnit>
304
- > = () => getProductsForUnit(unitId, requestOptions);
316
+ Awaited<ReturnType<typeof getProductsForUnit>>
317
+ > = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
305
318
 
306
319
  const query = useQuery<
307
- AsyncReturnType<typeof getProductsForUnit>,
320
+ Awaited<ReturnType<typeof getProductsForUnit>>,
308
321
  TError,
309
322
  TData
310
323
  >(queryKey, queryFn, { enabled: !!unitId, ...queryOptions });
@@ -323,10 +336,15 @@ export const useGetProductsForUnit = <
323
336
  export const getProduct = (
324
337
  unitId: string,
325
338
  productId: string,
326
- options?: SecondParameter<typeof customInstance>
339
+ options?: SecondParameter<typeof customInstance>,
340
+ signal?: AbortSignal
327
341
  ) => {
328
342
  return customInstance<ProductUnitGetResponse>(
329
- { url: `/product/unit/${unitId}/product/${productId}`, method: "get" },
343
+ {
344
+ url: `/product/unit/${unitId}/product/${productId}`,
345
+ method: "get",
346
+ signal,
347
+ },
330
348
  options
331
349
  );
332
350
  };
@@ -336,30 +354,35 @@ export const getGetProductQueryKey = (unitId: string, productId: string) => [
336
354
  ];
337
355
 
338
356
  export type GetProductQueryResult = NonNullable<
339
- AsyncReturnType<typeof getProduct>
357
+ Awaited<ReturnType<typeof getProduct>>
340
358
  >;
341
359
  export type GetProductQueryError = ErrorType<AsError | void>;
342
360
 
343
361
  export const useGetProduct = <
344
- TData = AsyncReturnType<typeof getProduct>,
362
+ TData = Awaited<ReturnType<typeof getProduct>>,
345
363
  TError = ErrorType<AsError | void>
346
364
  >(
347
365
  unitId: string,
348
366
  productId: string,
349
367
  options?: {
350
- query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;
368
+ query?: UseQueryOptions<
369
+ Awaited<ReturnType<typeof getProduct>>,
370
+ TError,
371
+ TData
372
+ >;
351
373
  request?: SecondParameter<typeof customInstance>;
352
374
  }
353
375
  ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
354
- const { query: queryOptions, request: requestOptions } = options || {};
376
+ const { query: queryOptions, request: requestOptions } = options ?? {};
355
377
 
356
378
  const queryKey =
357
379
  queryOptions?.queryKey ?? getGetProductQueryKey(unitId, productId);
358
380
 
359
- const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>
360
- getProduct(unitId, productId, requestOptions);
381
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({
382
+ signal,
383
+ }) => getProduct(unitId, productId, requestOptions, signal);
361
384
 
362
- const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(
385
+ const query = useQuery<Awaited<ReturnType<typeof getProduct>>, TError, TData>(
363
386
  queryKey,
364
387
  queryFn,
365
388
  { enabled: !!(unitId && productId), ...queryOptions }
@@ -386,7 +409,7 @@ export const deleteProduct = (
386
409
  };
387
410
 
388
411
  export type DeleteProductMutationResult = NonNullable<
389
- AsyncReturnType<typeof deleteProduct>
412
+ Awaited<ReturnType<typeof deleteProduct>>
390
413
  >;
391
414
 
392
415
  export type DeleteProductMutationError = ErrorType<AsError>;
@@ -396,26 +419,26 @@ export const useDeleteProduct = <
396
419
  TContext = unknown
397
420
  >(options?: {
398
421
  mutation?: UseMutationOptions<
399
- AsyncReturnType<typeof deleteProduct>,
422
+ Awaited<ReturnType<typeof deleteProduct>>,
400
423
  TError,
401
424
  { unitId: string; productId: string },
402
425
  TContext
403
426
  >;
404
427
  request?: SecondParameter<typeof customInstance>;
405
428
  }) => {
406
- const { mutation: mutationOptions, request: requestOptions } = options || {};
429
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
407
430
 
408
431
  const mutationFn: MutationFunction<
409
- AsyncReturnType<typeof deleteProduct>,
432
+ Awaited<ReturnType<typeof deleteProduct>>,
410
433
  { unitId: string; productId: string }
411
434
  > = (props) => {
412
- const { unitId, productId } = props || {};
435
+ const { unitId, productId } = props ?? {};
413
436
 
414
437
  return deleteProduct(unitId, productId, requestOptions);
415
438
  };
416
439
 
417
440
  return useMutation<
418
- AsyncReturnType<typeof deleteProduct>,
441
+ Awaited<ReturnType<typeof deleteProduct>>,
419
442
  TError,
420
443
  { unitId: string; productId: string },
421
444
  TContext
@@ -444,7 +467,7 @@ export const patchProduct = (
444
467
  };
445
468
 
446
469
  export type PatchProductMutationResult = NonNullable<
447
- AsyncReturnType<typeof patchProduct>
470
+ Awaited<ReturnType<typeof patchProduct>>
448
471
  >;
449
472
  export type PatchProductMutationBody = ProductPatchBodyBody;
450
473
  export type PatchProductMutationError = ErrorType<AsError>;
@@ -454,26 +477,26 @@ export const usePatchProduct = <
454
477
  TContext = unknown
455
478
  >(options?: {
456
479
  mutation?: UseMutationOptions<
457
- AsyncReturnType<typeof patchProduct>,
480
+ Awaited<ReturnType<typeof patchProduct>>,
458
481
  TError,
459
482
  { unitId: string; productId: string; data: ProductPatchBodyBody },
460
483
  TContext
461
484
  >;
462
485
  request?: SecondParameter<typeof customInstance>;
463
486
  }) => {
464
- const { mutation: mutationOptions, request: requestOptions } = options || {};
487
+ const { mutation: mutationOptions, request: requestOptions } = options ?? {};
465
488
 
466
489
  const mutationFn: MutationFunction<
467
- AsyncReturnType<typeof patchProduct>,
490
+ Awaited<ReturnType<typeof patchProduct>>,
468
491
  { unitId: string; productId: string; data: ProductPatchBodyBody }
469
492
  > = (props) => {
470
- const { unitId, productId, data } = props || {};
493
+ const { unitId, productId, data } = props ?? {};
471
494
 
472
495
  return patchProduct(unitId, productId, data, requestOptions);
473
496
  };
474
497
 
475
498
  return useMutation<
476
- AsyncReturnType<typeof patchProduct>,
499
+ Awaited<ReturnType<typeof patchProduct>>,
477
500
  TError,
478
501
  { unitId: string; productId: string; data: ProductPatchBodyBody },
479
502
  TContext