@squonk/account-server-client 2.0.4-rc.2 → 2.0.4-rc.3

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/admin/admin.cjs +10 -14
  2. package/admin/admin.cjs.map +1 -1
  3. package/admin/admin.d.ts +9 -3
  4. package/admin/admin.js +9 -13
  5. package/admin/admin.js.map +1 -1
  6. package/asset/asset.cjs +59 -28
  7. package/asset/asset.cjs.map +1 -1
  8. package/asset/asset.d.ts +71 -3
  9. package/asset/asset.js +58 -27
  10. package/asset/asset.js.map +1 -1
  11. package/{custom-instance-85497958.d.ts → custom-instance-8a11f2d1.d.ts} +1 -1
  12. package/index.cjs.map +1 -1
  13. package/index.d.ts +1 -1
  14. package/index.js.map +1 -1
  15. package/merchant/merchant.cjs +19 -16
  16. package/merchant/merchant.cjs.map +1 -1
  17. package/merchant/merchant.d.ts +16 -4
  18. package/merchant/merchant.js +18 -15
  19. package/merchant/merchant.js.map +1 -1
  20. package/organisation/organisation.cjs +62 -34
  21. package/organisation/organisation.cjs.map +1 -1
  22. package/organisation/organisation.d.ts +56 -6
  23. package/organisation/organisation.js +61 -33
  24. package/organisation/organisation.js.map +1 -1
  25. package/package.json +10 -9
  26. package/product/product.cjs +92 -55
  27. package/product/product.cjs.map +1 -1
  28. package/product/product.d.ts +79 -9
  29. package/product/product.js +91 -54
  30. package/product/product.js.map +1 -1
  31. package/src/account-server-api.schemas.ts +1 -1
  32. package/src/admin/admin.ts +34 -18
  33. package/src/asset/asset.ts +223 -88
  34. package/src/merchant/merchant.ts +60 -27
  35. package/src/organisation/organisation.ts +213 -90
  36. package/src/product/product.ts +310 -134
  37. package/src/state/state.ts +30 -15
  38. package/src/unit/unit.ts +261 -110
  39. package/src/user/user.ts +207 -88
  40. package/state/state.cjs +10 -11
  41. package/state/state.cjs.map +1 -1
  42. package/state/state.d.ts +9 -3
  43. package/state/state.js +9 -10
  44. package/state/state.js.map +1 -1
  45. package/unit/unit.cjs +72 -40
  46. package/unit/unit.cjs.map +1 -1
  47. package/unit/unit.d.ts +70 -6
  48. package/unit/unit.js +71 -39
  49. package/unit/unit.js.map +1 -1
  50. package/user/user.cjs +56 -31
  51. package/user/user.cjs.map +1 -1
  52. package/user/user.d.ts +63 -5
  53. package/user/user.js +55 -30
  54. package/user/user.js.map +1 -1
  55. package/chunk-7XN3IQYV.cjs +0 -13
  56. package/chunk-7XN3IQYV.cjs.map +0 -1
  57. package/chunk-YEX2SGER.js +0 -13
  58. package/chunk-YEX2SGER.js.map +0 -1
  59. package/src/queryMutator.ts +0 -12
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated by orval v6.12.1 🍺
2
+ * Generated by orval v6.15.0 🍺
3
3
  * Do not edit manually.
4
4
  * Account Server API
5
5
  * The Informatics Matters Account Server API.
@@ -30,7 +30,6 @@ import type {
30
30
  } from "../account-server-api.schemas";
31
31
  import { customInstance } from ".././custom-instance";
32
32
  import type { ErrorType } from ".././custom-instance";
33
- import { queryMutator } from ".././queryMutator";
34
33
 
35
34
  // eslint-disable-next-line
36
35
  type SecondParameter<T extends (...args: any) => any> = T extends (
@@ -55,14 +54,9 @@ export const getOrganisations = (
55
54
  );
56
55
  };
57
56
 
58
- export const getGetOrganisationsQueryKey = () => [`/organisation`];
57
+ export const getGetOrganisationsQueryKey = () => ["account-server-api", `/organisation`] as const;
59
58
 
60
- export type GetOrganisationsQueryResult = NonNullable<
61
- Awaited<ReturnType<typeof getOrganisations>>
62
- >;
63
- export type GetOrganisationsQueryError = ErrorType<void | AsError>;
64
-
65
- export const useGetOrganisations = <
59
+ export const getGetOrganisationsQueryOptions = <
66
60
  TData = Awaited<ReturnType<typeof getOrganisations>>,
67
61
  TError = ErrorType<void | AsError>
68
62
  >(options?: {
@@ -72,7 +66,11 @@ export const useGetOrganisations = <
72
66
  TData
73
67
  >;
74
68
  request?: SecondParameter<typeof customInstance>;
75
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
69
+ }): UseQueryOptions<
70
+ Awaited<ReturnType<typeof getOrganisations>>,
71
+ TError,
72
+ TData
73
+ > & { queryKey: QueryKey } => {
76
74
  const { query: queryOptions, request: requestOptions } = options ?? {};
77
75
 
78
76
  const queryKey = queryOptions?.queryKey ?? getGetOrganisationsQueryKey();
@@ -81,15 +79,32 @@ export const useGetOrganisations = <
81
79
  Awaited<ReturnType<typeof getOrganisations>>
82
80
  > = ({ signal }) => getOrganisations(requestOptions, signal);
83
81
 
84
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
82
+ return { queryKey, queryFn, ...queryOptions };
83
+ };
84
+
85
+ export type GetOrganisationsQueryResult = NonNullable<
86
+ Awaited<ReturnType<typeof getOrganisations>>
87
+ >;
88
+ export type GetOrganisationsQueryError = ErrorType<void | AsError>;
85
89
 
86
- const query = useQuery<
90
+ export const useGetOrganisations = <
91
+ TData = Awaited<ReturnType<typeof getOrganisations>>,
92
+ TError = ErrorType<void | AsError>
93
+ >(options?: {
94
+ query?: UseQueryOptions<
87
95
  Awaited<ReturnType<typeof getOrganisations>>,
88
96
  TError,
89
97
  TData
90
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
98
+ >;
99
+ request?: SecondParameter<typeof customInstance>;
100
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
101
+ const queryOptions = getGetOrganisationsQueryOptions(options);
91
102
 
92
- query.queryKey = customOptions.queryKey;
103
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
104
+ queryKey: QueryKey;
105
+ };
106
+
107
+ query.queryKey = queryOptions.queryKey;
93
108
 
94
109
  return query;
95
110
  };
@@ -116,13 +131,7 @@ export const createOrganisation = (
116
131
  );
117
132
  };
118
133
 
119
- export type CreateOrganisationMutationResult = NonNullable<
120
- Awaited<ReturnType<typeof createOrganisation>>
121
- >;
122
- export type CreateOrganisationMutationBody = OrganisationPostBodyBody;
123
- export type CreateOrganisationMutationError = ErrorType<AsError | void>;
124
-
125
- export const useCreateOrganisation = <
134
+ export const getCreateOrganisationMutationOptions = <
126
135
  TError = ErrorType<AsError | void>,
127
136
  TContext = unknown
128
137
  >(options?: {
@@ -133,7 +142,12 @@ export const useCreateOrganisation = <
133
142
  TContext
134
143
  >;
135
144
  request?: SecondParameter<typeof customInstance>;
136
- }) => {
145
+ }): UseMutationOptions<
146
+ Awaited<ReturnType<typeof createOrganisation>>,
147
+ TError,
148
+ { data: OrganisationPostBodyBody },
149
+ TContext
150
+ > => {
137
151
  const { mutation: mutationOptions, request: requestOptions } = options ?? {};
138
152
 
139
153
  const mutationFn: MutationFunction<
@@ -145,12 +159,30 @@ export const useCreateOrganisation = <
145
159
  return createOrganisation(data, requestOptions);
146
160
  };
147
161
 
148
- return useMutation<
162
+ return { mutationFn, ...mutationOptions };
163
+ };
164
+
165
+ export type CreateOrganisationMutationResult = NonNullable<
166
+ Awaited<ReturnType<typeof createOrganisation>>
167
+ >;
168
+ export type CreateOrganisationMutationBody = OrganisationPostBodyBody;
169
+ export type CreateOrganisationMutationError = ErrorType<AsError | void>;
170
+
171
+ export const useCreateOrganisation = <
172
+ TError = ErrorType<AsError | void>,
173
+ TContext = unknown
174
+ >(options?: {
175
+ mutation?: UseMutationOptions<
149
176
  Awaited<ReturnType<typeof createOrganisation>>,
150
177
  TError,
151
178
  { data: OrganisationPostBodyBody },
152
179
  TContext
153
- >(mutationFn, mutationOptions);
180
+ >;
181
+ request?: SecondParameter<typeof customInstance>;
182
+ }) => {
183
+ const mutationOptions = getCreateOrganisationMutationOptions(options);
184
+
185
+ return useMutation(mutationOptions);
154
186
  };
155
187
  /**
156
188
  * Gets a specific Organisation
@@ -168,16 +200,10 @@ export const getOrganisation = (
168
200
  );
169
201
  };
170
202
 
171
- export const getGetOrganisationQueryKey = (orgId: string) => [
172
- `/organisation/${orgId}`,
173
- ];
174
-
175
- export type GetOrganisationQueryResult = NonNullable<
176
- Awaited<ReturnType<typeof getOrganisation>>
177
- >;
178
- export type GetOrganisationQueryError = ErrorType<void | AsError>;
203
+ export const getGetOrganisationQueryKey = (orgId: string) =>
204
+ ["account-server-api", `/organisation/${orgId}`] as const;
179
205
 
180
- export const useGetOrganisation = <
206
+ export const getGetOrganisationQueryOptions = <
181
207
  TData = Awaited<ReturnType<typeof getOrganisation>>,
182
208
  TError = ErrorType<void | AsError>
183
209
  >(
@@ -190,7 +216,11 @@ export const useGetOrganisation = <
190
216
  >;
191
217
  request?: SecondParameter<typeof customInstance>;
192
218
  }
193
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
219
+ ): UseQueryOptions<
220
+ Awaited<ReturnType<typeof getOrganisation>>,
221
+ TError,
222
+ TData
223
+ > & { queryKey: QueryKey } => {
194
224
  const { query: queryOptions, request: requestOptions } = options ?? {};
195
225
 
196
226
  const queryKey = queryOptions?.queryKey ?? getGetOrganisationQueryKey(orgId);
@@ -199,15 +229,35 @@ export const useGetOrganisation = <
199
229
  signal,
200
230
  }) => getOrganisation(orgId, requestOptions, signal);
201
231
 
202
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
232
+ return { queryKey, queryFn, enabled: !!orgId, ...queryOptions };
233
+ };
203
234
 
204
- const query = useQuery<
205
- Awaited<ReturnType<typeof getOrganisation>>,
206
- TError,
207
- TData
208
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
235
+ export type GetOrganisationQueryResult = NonNullable<
236
+ Awaited<ReturnType<typeof getOrganisation>>
237
+ >;
238
+ export type GetOrganisationQueryError = ErrorType<void | AsError>;
239
+
240
+ export const useGetOrganisation = <
241
+ TData = Awaited<ReturnType<typeof getOrganisation>>,
242
+ TError = ErrorType<void | AsError>
243
+ >(
244
+ orgId: string,
245
+ options?: {
246
+ query?: UseQueryOptions<
247
+ Awaited<ReturnType<typeof getOrganisation>>,
248
+ TError,
249
+ TData
250
+ >;
251
+ request?: SecondParameter<typeof customInstance>;
252
+ }
253
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
254
+ const queryOptions = getGetOrganisationQueryOptions(orgId, options);
255
+
256
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
257
+ queryKey: QueryKey;
258
+ };
209
259
 
210
- query.queryKey = customOptions.queryKey;
260
+ query.queryKey = queryOptions.queryKey;
211
261
 
212
262
  return query;
213
263
  };
@@ -235,13 +285,7 @@ export const patchOrganisation = (
235
285
  );
236
286
  };
237
287
 
238
- export type PatchOrganisationMutationResult = NonNullable<
239
- Awaited<ReturnType<typeof patchOrganisation>>
240
- >;
241
- export type PatchOrganisationMutationBody = OrganisationPatchBodyBody;
242
- export type PatchOrganisationMutationError = ErrorType<AsError>;
243
-
244
- export const usePatchOrganisation = <
288
+ export const getPatchOrganisationMutationOptions = <
245
289
  TError = ErrorType<AsError>,
246
290
  TContext = unknown
247
291
  >(options?: {
@@ -252,7 +296,12 @@ export const usePatchOrganisation = <
252
296
  TContext
253
297
  >;
254
298
  request?: SecondParameter<typeof customInstance>;
255
- }) => {
299
+ }): UseMutationOptions<
300
+ Awaited<ReturnType<typeof patchOrganisation>>,
301
+ TError,
302
+ { orgId: string; data: OrganisationPatchBodyBody },
303
+ TContext
304
+ > => {
256
305
  const { mutation: mutationOptions, request: requestOptions } = options ?? {};
257
306
 
258
307
  const mutationFn: MutationFunction<
@@ -264,12 +313,30 @@ export const usePatchOrganisation = <
264
313
  return patchOrganisation(orgId, data, requestOptions);
265
314
  };
266
315
 
267
- return useMutation<
316
+ return { mutationFn, ...mutationOptions };
317
+ };
318
+
319
+ export type PatchOrganisationMutationResult = NonNullable<
320
+ Awaited<ReturnType<typeof patchOrganisation>>
321
+ >;
322
+ export type PatchOrganisationMutationBody = OrganisationPatchBodyBody;
323
+ export type PatchOrganisationMutationError = ErrorType<AsError>;
324
+
325
+ export const usePatchOrganisation = <
326
+ TError = ErrorType<AsError>,
327
+ TContext = unknown
328
+ >(options?: {
329
+ mutation?: UseMutationOptions<
268
330
  Awaited<ReturnType<typeof patchOrganisation>>,
269
331
  TError,
270
332
  { orgId: string; data: OrganisationPatchBodyBody },
271
333
  TContext
272
- >(mutationFn, mutationOptions);
334
+ >;
335
+ request?: SecondParameter<typeof customInstance>;
336
+ }) => {
337
+ const mutationOptions = getPatchOrganisationMutationOptions(options);
338
+
339
+ return useMutation(mutationOptions);
273
340
  };
274
341
  /**
275
342
  * Units must first be deleted before an Organisation can be deleted
@@ -288,13 +355,7 @@ export const deleteOrganisation = (
288
355
  );
289
356
  };
290
357
 
291
- export type DeleteOrganisationMutationResult = NonNullable<
292
- Awaited<ReturnType<typeof deleteOrganisation>>
293
- >;
294
-
295
- export type DeleteOrganisationMutationError = ErrorType<AsError>;
296
-
297
- export const useDeleteOrganisation = <
358
+ export const getDeleteOrganisationMutationOptions = <
298
359
  TError = ErrorType<AsError>,
299
360
  TContext = unknown
300
361
  >(options?: {
@@ -305,7 +366,12 @@ export const useDeleteOrganisation = <
305
366
  TContext
306
367
  >;
307
368
  request?: SecondParameter<typeof customInstance>;
308
- }) => {
369
+ }): UseMutationOptions<
370
+ Awaited<ReturnType<typeof deleteOrganisation>>,
371
+ TError,
372
+ { orgId: string },
373
+ TContext
374
+ > => {
309
375
  const { mutation: mutationOptions, request: requestOptions } = options ?? {};
310
376
 
311
377
  const mutationFn: MutationFunction<
@@ -317,12 +383,30 @@ export const useDeleteOrganisation = <
317
383
  return deleteOrganisation(orgId, requestOptions);
318
384
  };
319
385
 
320
- return useMutation<
386
+ return { mutationFn, ...mutationOptions };
387
+ };
388
+
389
+ export type DeleteOrganisationMutationResult = NonNullable<
390
+ Awaited<ReturnType<typeof deleteOrganisation>>
391
+ >;
392
+
393
+ export type DeleteOrganisationMutationError = ErrorType<AsError>;
394
+
395
+ export const useDeleteOrganisation = <
396
+ TError = ErrorType<AsError>,
397
+ TContext = unknown
398
+ >(options?: {
399
+ mutation?: UseMutationOptions<
321
400
  Awaited<ReturnType<typeof deleteOrganisation>>,
322
401
  TError,
323
402
  { orgId: string },
324
403
  TContext
325
- >(mutationFn, mutationOptions);
404
+ >;
405
+ request?: SecondParameter<typeof customInstance>;
406
+ }) => {
407
+ const mutationOptions = getDeleteOrganisationMutationOptions(options);
408
+
409
+ return useMutation(mutationOptions);
326
410
  };
327
411
  /**
328
412
  * Gets a Organisation charges. The organisation cannot be the **Default** organisation and you need to be a member of the Organisation
@@ -344,14 +428,9 @@ export const getOrganisationCharges = (
344
428
  export const getGetOrganisationChargesQueryKey = (
345
429
  orgId: string,
346
430
  params?: GetOrganisationChargesParams
347
- ) => [`/organisation/${orgId}/charges`, ...(params ? [params] : [])];
431
+ ) => ["account-server-api", `/organisation/${orgId}/charges`, ...(params ? [params] : [])] as const;
348
432
 
349
- export type GetOrganisationChargesQueryResult = NonNullable<
350
- Awaited<ReturnType<typeof getOrganisationCharges>>
351
- >;
352
- export type GetOrganisationChargesQueryError = ErrorType<void | AsError>;
353
-
354
- export const useGetOrganisationCharges = <
433
+ export const getGetOrganisationChargesQueryOptions = <
355
434
  TData = Awaited<ReturnType<typeof getOrganisationCharges>>,
356
435
  TError = ErrorType<void | AsError>
357
436
  >(
@@ -365,7 +444,11 @@ export const useGetOrganisationCharges = <
365
444
  >;
366
445
  request?: SecondParameter<typeof customInstance>;
367
446
  }
368
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
447
+ ): UseQueryOptions<
448
+ Awaited<ReturnType<typeof getOrganisationCharges>>,
449
+ TError,
450
+ TData
451
+ > & { queryKey: QueryKey } => {
369
452
  const { query: queryOptions, request: requestOptions } = options ?? {};
370
453
 
371
454
  const queryKey =
@@ -376,15 +459,40 @@ export const useGetOrganisationCharges = <
376
459
  > = ({ signal }) =>
377
460
  getOrganisationCharges(orgId, params, requestOptions, signal);
378
461
 
379
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
462
+ return { queryKey, queryFn, enabled: !!orgId, ...queryOptions };
463
+ };
380
464
 
381
- const query = useQuery<
382
- Awaited<ReturnType<typeof getOrganisationCharges>>,
383
- TError,
384
- TData
385
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
465
+ export type GetOrganisationChargesQueryResult = NonNullable<
466
+ Awaited<ReturnType<typeof getOrganisationCharges>>
467
+ >;
468
+ export type GetOrganisationChargesQueryError = ErrorType<void | AsError>;
469
+
470
+ export const useGetOrganisationCharges = <
471
+ TData = Awaited<ReturnType<typeof getOrganisationCharges>>,
472
+ TError = ErrorType<void | AsError>
473
+ >(
474
+ orgId: string,
475
+ params?: GetOrganisationChargesParams,
476
+ options?: {
477
+ query?: UseQueryOptions<
478
+ Awaited<ReturnType<typeof getOrganisationCharges>>,
479
+ TError,
480
+ TData
481
+ >;
482
+ request?: SecondParameter<typeof customInstance>;
483
+ }
484
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
485
+ const queryOptions = getGetOrganisationChargesQueryOptions(
486
+ orgId,
487
+ params,
488
+ options
489
+ );
490
+
491
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
492
+ queryKey: QueryKey;
493
+ };
386
494
 
387
- query.queryKey = customOptions.queryKey;
495
+ query.queryKey = queryOptions.queryKey;
388
496
 
389
497
  return query;
390
498
  };
@@ -404,16 +512,10 @@ export const getDefaultOrganisation = (
404
512
  );
405
513
  };
406
514
 
407
- export const getGetDefaultOrganisationQueryKey = () => [
408
- `/organisation/default`,
409
- ];
515
+ export const getGetDefaultOrganisationQueryKey = () =>
516
+ ["account-server-api", `/organisation/default`] as const;
410
517
 
411
- export type GetDefaultOrganisationQueryResult = NonNullable<
412
- Awaited<ReturnType<typeof getDefaultOrganisation>>
413
- >;
414
- export type GetDefaultOrganisationQueryError = ErrorType<void | AsError>;
415
-
416
- export const useGetDefaultOrganisation = <
518
+ export const getGetDefaultOrganisationQueryOptions = <
417
519
  TData = Awaited<ReturnType<typeof getDefaultOrganisation>>,
418
520
  TError = ErrorType<void | AsError>
419
521
  >(options?: {
@@ -423,7 +525,11 @@ export const useGetDefaultOrganisation = <
423
525
  TData
424
526
  >;
425
527
  request?: SecondParameter<typeof customInstance>;
426
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
528
+ }): UseQueryOptions<
529
+ Awaited<ReturnType<typeof getDefaultOrganisation>>,
530
+ TError,
531
+ TData
532
+ > & { queryKey: QueryKey } => {
427
533
  const { query: queryOptions, request: requestOptions } = options ?? {};
428
534
 
429
535
  const queryKey =
@@ -433,15 +539,32 @@ export const useGetDefaultOrganisation = <
433
539
  Awaited<ReturnType<typeof getDefaultOrganisation>>
434
540
  > = ({ signal }) => getDefaultOrganisation(requestOptions, signal);
435
541
 
436
- const customOptions = queryMutator({ ...queryOptions, queryKey, queryFn });
542
+ return { queryKey, queryFn, ...queryOptions };
543
+ };
437
544
 
438
- const query = useQuery<
545
+ export type GetDefaultOrganisationQueryResult = NonNullable<
546
+ Awaited<ReturnType<typeof getDefaultOrganisation>>
547
+ >;
548
+ export type GetDefaultOrganisationQueryError = ErrorType<void | AsError>;
549
+
550
+ export const useGetDefaultOrganisation = <
551
+ TData = Awaited<ReturnType<typeof getDefaultOrganisation>>,
552
+ TError = ErrorType<void | AsError>
553
+ >(options?: {
554
+ query?: UseQueryOptions<
439
555
  Awaited<ReturnType<typeof getDefaultOrganisation>>,
440
556
  TError,
441
557
  TData
442
- >(customOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
558
+ >;
559
+ request?: SecondParameter<typeof customInstance>;
560
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
561
+ const queryOptions = getGetDefaultOrganisationQueryOptions(options);
562
+
563
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
564
+ queryKey: QueryKey;
565
+ };
443
566
 
444
- query.queryKey = customOptions.queryKey;
567
+ query.queryKey = queryOptions.queryKey;
445
568
 
446
569
  return query;
447
570
  };