@arascreative/erp-client 1.1.0 → 3.0.0

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.
@@ -7,7 +7,7 @@
7
7
  import { useMutation, useQuery } from '@tanstack/react-query';
8
8
  ;
9
9
  export const getGetAntiforgeryTokenUrl = () => {
10
- return `/identity/antiforgery`;
10
+ return `/api/v1/identity/antiforgery`;
11
11
  };
12
12
  export const getAntiforgeryToken = async (options) => {
13
13
  const res = await fetch(getGetAntiforgeryTokenUrl(), {
@@ -20,7 +20,7 @@ export const getAntiforgeryToken = async (options) => {
20
20
  };
21
21
  export const getGetAntiforgeryTokenQueryKey = () => {
22
22
  return [
23
- `/identity/antiforgery`
23
+ `/api/v1/identity/antiforgery`
24
24
  ];
25
25
  };
26
26
  export const getGetAntiforgeryTokenQueryOptions = (options) => {
@@ -39,7 +39,7 @@ export function useGetAntiforgeryToken(options, queryClient) {
39
39
  return query;
40
40
  }
41
41
  export const getLoginUrl = () => {
42
- return `/identity/login`;
42
+ return `/api/v1/identity/login`;
43
43
  };
44
44
  export const login = async (loginBody, options) => {
45
45
  const res = await fetch(getLoginUrl(), {
@@ -73,7 +73,7 @@ export const useLogin = (options, queryClient) => {
73
73
  return useMutation(mutationOptions, queryClient);
74
74
  };
75
75
  export const getGetCurrentUserUrl = () => {
76
- return `/identity/me`;
76
+ return `/api/v1/identity/me`;
77
77
  };
78
78
  export const getCurrentUser = async (options) => {
79
79
  const res = await fetch(getGetCurrentUserUrl(), {
@@ -86,7 +86,7 @@ export const getCurrentUser = async (options) => {
86
86
  };
87
87
  export const getGetCurrentUserQueryKey = () => {
88
88
  return [
89
- `/identity/me`
89
+ `/api/v1/identity/me`
90
90
  ];
91
91
  };
92
92
  export const getGetCurrentUserQueryOptions = (options) => {
@@ -105,7 +105,7 @@ export function useGetCurrentUser(options, queryClient) {
105
105
  return query;
106
106
  }
107
107
  export const getLogoutUrl = () => {
108
- return `/identity/logout`;
108
+ return `/api/v1/identity/logout`;
109
109
  };
110
110
  export const logout = async (options) => {
111
111
  const res = await fetch(getLogoutUrl(), {
@@ -136,7 +136,7 @@ export const useLogout = (options, queryClient) => {
136
136
  return useMutation(mutationOptions, queryClient);
137
137
  };
138
138
  export const getCreateOwnerUrl = () => {
139
- return `/identity/owner`;
139
+ return `/api/v1/identity/owner`;
140
140
  };
141
141
  export const createOwner = async (createOwnerBody, options) => {
142
142
  const res = await fetch(getCreateOwnerUrl(), {
@@ -177,7 +177,7 @@ export const getSearchAddressesUrl = (params) => {
177
177
  }
178
178
  });
179
179
  const stringifiedParams = normalizedParams.toString();
180
- return stringifiedParams.length > 0 ? `/addresses/search?${stringifiedParams}` : `/addresses/search`;
180
+ return stringifiedParams.length > 0 ? `/api/v1/addresses/search?${stringifiedParams}` : `/api/v1/addresses/search`;
181
181
  };
182
182
  export const searchAddresses = async (params, options) => {
183
183
  const res = await fetch(getSearchAddressesUrl(params), {
@@ -190,7 +190,7 @@ export const searchAddresses = async (params, options) => {
190
190
  };
191
191
  export const getSearchAddressesQueryKey = (params) => {
192
192
  return [
193
- `/addresses/search`, ...(params ? [params] : [])
193
+ `/api/v1/addresses/search`, ...(params ? [params] : [])
194
194
  ];
195
195
  };
196
196
  export const getSearchAddressesQueryOptions = (params, options) => {
@@ -209,7 +209,7 @@ export function useSearchAddresses(params, options, queryClient) {
209
209
  return query;
210
210
  }
211
211
  export const getInitiateUploadUrl = () => {
212
- return `/files/initiate-upload`;
212
+ return `/api/v1/files/initiate-upload`;
213
213
  };
214
214
  export const initiateUpload = async (initiateUploadBody, options) => {
215
215
  const res = await fetch(getInitiateUploadUrl(), {
@@ -243,7 +243,7 @@ export const useInitiateUpload = (options, queryClient) => {
243
243
  return useMutation(mutationOptions, queryClient);
244
244
  };
245
245
  export const getUploadFileUrl = () => {
246
- return `/files/upload`;
246
+ return `/api/v1/files/upload`;
247
247
  };
248
248
  export const uploadFile = async (uploadFileBody, options) => {
249
249
  const res = await fetch(getUploadFileUrl(), {
@@ -277,7 +277,7 @@ export const useUploadFile = (options, queryClient) => {
277
277
  return useMutation(mutationOptions, queryClient);
278
278
  };
279
279
  export const getToggleWarehouseStatusUrl = (id) => {
280
- return `/warehouses/${id}/toggle-status`;
280
+ return `/api/v1/warehouses/${id}/toggle-status`;
281
281
  };
282
282
  export const toggleWarehouseStatus = async (id, options) => {
283
283
  const res = await fetch(getToggleWarehouseStatusUrl(id), {
@@ -309,7 +309,7 @@ export const useToggleWarehouseStatus = (options, queryClient) => {
309
309
  return useMutation(mutationOptions, queryClient);
310
310
  };
311
311
  export const getChangeStockItemStatusUrl = (id) => {
312
- return `/stock-items/${id}/status`;
312
+ return `/api/v1/stock-items/${id}/status`;
313
313
  };
314
314
  export const changeStockItemStatus = async (id, changeStockItemStatusBody, options) => {
315
315
  const res = await fetch(getChangeStockItemStatusUrl(id), {
@@ -343,7 +343,7 @@ export const useChangeStockItemStatus = (options, queryClient) => {
343
343
  return useMutation(mutationOptions, queryClient);
344
344
  };
345
345
  export const getCompleteUploadUrl = (id) => {
346
- return `/files/${id}/complete`;
346
+ return `/api/v1/files/${id}/complete`;
347
347
  };
348
348
  export const completeUpload = async (id, completeUploadBody, options) => {
349
349
  const res = await fetch(getCompleteUploadUrl(id), {
@@ -384,7 +384,7 @@ export const getGetFileAccessUrlUrl = (id, params) => {
384
384
  }
385
385
  });
386
386
  const stringifiedParams = normalizedParams.toString();
387
- return stringifiedParams.length > 0 ? `/files/${id}/access-url?${stringifiedParams}` : `/files/${id}/access-url`;
387
+ return stringifiedParams.length > 0 ? `/api/v1/files/${id}/access-url?${stringifiedParams}` : `/api/v1/files/${id}/access-url`;
388
388
  };
389
389
  export const getFileAccessUrl = async (id, params, options) => {
390
390
  const res = await fetch(getGetFileAccessUrlUrl(id, params), {
@@ -397,7 +397,7 @@ export const getFileAccessUrl = async (id, params, options) => {
397
397
  };
398
398
  export const getGetFileAccessUrlQueryKey = (id, params) => {
399
399
  return [
400
- `/files/${id}/access-url`, ...(params ? [params] : [])
400
+ `/api/v1/files/${id}/access-url`, ...(params ? [params] : [])
401
401
  ];
402
402
  };
403
403
  export const getGetFileAccessUrlQueryOptions = (id, params, options) => {
@@ -416,7 +416,7 @@ export function useGetFileAccessUrl(id, params, options, queryClient) {
416
416
  return query;
417
417
  }
418
418
  export const getGetWarehouseByIdUrl = (id) => {
419
- return `/warehouses/${id}`;
419
+ return `/api/v1/warehouses/${id}`;
420
420
  };
421
421
  export const getWarehouseById = async (id, options) => {
422
422
  const res = await fetch(getGetWarehouseByIdUrl(id), {
@@ -429,7 +429,7 @@ export const getWarehouseById = async (id, options) => {
429
429
  };
430
430
  export const getGetWarehouseByIdQueryKey = (id) => {
431
431
  return [
432
- `/warehouses/${id}`
432
+ `/api/v1/warehouses/${id}`
433
433
  ];
434
434
  };
435
435
  export const getGetWarehouseByIdQueryOptions = (id, options) => {
@@ -448,7 +448,7 @@ export function useGetWarehouseById(id, options, queryClient) {
448
448
  return query;
449
449
  }
450
450
  export const getUpdateWarehouseUrl = (id) => {
451
- return `/warehouses/${id}`;
451
+ return `/api/v1/warehouses/${id}`;
452
452
  };
453
453
  export const updateWarehouse = async (id, updateWarehouseBody, options) => {
454
454
  const res = await fetch(getUpdateWarehouseUrl(id), {
@@ -482,7 +482,7 @@ export const useUpdateWarehouse = (options, queryClient) => {
482
482
  return useMutation(mutationOptions, queryClient);
483
483
  };
484
484
  export const getDeleteWarehouseUrl = (id) => {
485
- return `/warehouses/${id}`;
485
+ return `/api/v1/warehouses/${id}`;
486
486
  };
487
487
  export const deleteWarehouse = async (id, options) => {
488
488
  const res = await fetch(getDeleteWarehouseUrl(id), {
@@ -514,7 +514,7 @@ export const useDeleteWarehouse = (options, queryClient) => {
514
514
  return useMutation(mutationOptions, queryClient);
515
515
  };
516
516
  export const getUpdateStockItemUrl = (id) => {
517
- return `/stock-items/${id}`;
517
+ return `/api/v1/stock-items/${id}`;
518
518
  };
519
519
  export const updateStockItem = async (id, updateStockItemBody, options) => {
520
520
  const res = await fetch(getUpdateStockItemUrl(id), {
@@ -548,7 +548,7 @@ export const useUpdateStockItem = (options, queryClient) => {
548
548
  return useMutation(mutationOptions, queryClient);
549
549
  };
550
550
  export const getDeleteStockItemUrl = (id) => {
551
- return `/stock-items/${id}`;
551
+ return `/api/v1/stock-items/${id}`;
552
552
  };
553
553
  export const deleteStockItem = async (id, options) => {
554
554
  const res = await fetch(getDeleteStockItemUrl(id), {
@@ -580,7 +580,7 @@ export const useDeleteStockItem = (options, queryClient) => {
580
580
  return useMutation(mutationOptions, queryClient);
581
581
  };
582
582
  export const getGetStoredFileByIdUrl = (id) => {
583
- return `/files/${id}`;
583
+ return `/api/v1/files/${id}`;
584
584
  };
585
585
  export const getStoredFileById = async (id, options) => {
586
586
  const res = await fetch(getGetStoredFileByIdUrl(id), {
@@ -593,7 +593,7 @@ export const getStoredFileById = async (id, options) => {
593
593
  };
594
594
  export const getGetStoredFileByIdQueryKey = (id) => {
595
595
  return [
596
- `/files/${id}`
596
+ `/api/v1/files/${id}`
597
597
  ];
598
598
  };
599
599
  export const getGetStoredFileByIdQueryOptions = (id, options) => {
@@ -612,7 +612,7 @@ export function useGetStoredFileById(id, options, queryClient) {
612
612
  return query;
613
613
  }
614
614
  export const getDeleteStoredFileUrl = (id) => {
615
- return `/files/${id}`;
615
+ return `/api/v1/files/${id}`;
616
616
  };
617
617
  export const deleteStoredFile = async (id, options) => {
618
618
  const res = await fetch(getDeleteStoredFileUrl(id), {
@@ -643,44 +643,12 @@ export const useDeleteStoredFile = (options, queryClient) => {
643
643
  const mutationOptions = getDeleteStoredFileMutationOptions(options);
644
644
  return useMutation(mutationOptions, queryClient);
645
645
  };
646
- export const getGetHealthUrl = () => {
647
- return `/health`;
648
- };
649
- export const getHealth = async (options) => {
650
- const res = await fetch(getGetHealthUrl(), {
651
- ...options,
652
- method: 'GET'
653
- });
654
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
655
- const data = body ? JSON.parse(body) : {};
656
- return { data, status: res.status, headers: res.headers };
657
- };
658
- export const getGetHealthQueryKey = () => {
659
- return [
660
- `/health`
661
- ];
662
- };
663
- export const getGetHealthQueryOptions = (options) => {
664
- const { query: queryOptions, fetch: fetchOptions } = options ?? {};
665
- const queryKey = queryOptions?.queryKey ?? getGetHealthQueryKey();
666
- const queryFn = ({ signal }) => getHealth({ signal, ...fetchOptions });
667
- return { queryKey, queryFn, ...queryOptions };
668
- };
669
- /**
670
- * @summary Health check
671
- */
672
- export function useGetHealth(options, queryClient) {
673
- const queryOptions = getGetHealthQueryOptions(options);
674
- const query = useQuery(queryOptions, queryClient);
675
- query.queryKey = queryOptions.queryKey;
676
- return query;
677
- }
678
646
  ;
679
- export const getGetCustomersUrl = () => {
680
- return `/customers`;
647
+ export const getGetApiV1CustomersUrl = () => {
648
+ return `/api/v1/customers`;
681
649
  };
682
- export const getCustomers = async (options) => {
683
- const res = await fetch(getGetCustomersUrl(), {
650
+ export const getApiV1Customers = async (options) => {
651
+ const res = await fetch(getGetApiV1CustomersUrl(), {
684
652
  ...options,
685
653
  method: 'GET'
686
654
  });
@@ -688,25 +656,25 @@ export const getCustomers = async (options) => {
688
656
  const data = body ? JSON.parse(body) : {};
689
657
  return { data, status: res.status, headers: res.headers };
690
658
  };
691
- export const getGetCustomersQueryKey = () => {
659
+ export const getGetApiV1CustomersQueryKey = () => {
692
660
  return [
693
- `/customers`
661
+ `/api/v1/customers`
694
662
  ];
695
663
  };
696
- export const getGetCustomersQueryOptions = (options) => {
664
+ export const getGetApiV1CustomersQueryOptions = (options) => {
697
665
  const { query: queryOptions, fetch: fetchOptions } = options ?? {};
698
- const queryKey = queryOptions?.queryKey ?? getGetCustomersQueryKey();
699
- const queryFn = ({ signal }) => getCustomers({ signal, ...fetchOptions });
666
+ const queryKey = queryOptions?.queryKey ?? getGetApiV1CustomersQueryKey();
667
+ const queryFn = ({ signal }) => getApiV1Customers({ signal, ...fetchOptions });
700
668
  return { queryKey, queryFn, ...queryOptions };
701
669
  };
702
- export function useGetCustomers(options, queryClient) {
703
- const queryOptions = getGetCustomersQueryOptions(options);
670
+ export function useGetApiV1Customers(options, queryClient) {
671
+ const queryOptions = getGetApiV1CustomersQueryOptions(options);
704
672
  const query = useQuery(queryOptions, queryClient);
705
673
  query.queryKey = queryOptions.queryKey;
706
674
  return query;
707
675
  }
708
676
  export const getCreateWarehouseUrl = () => {
709
- return `/warehouses`;
677
+ return `/api/v1/warehouses`;
710
678
  };
711
679
  export const createWarehouse = async (createWarehouseBody, options) => {
712
680
  const res = await fetch(getCreateWarehouseUrl(), {
@@ -748,7 +716,7 @@ export const getListWarehousesUrl = (params) => {
748
716
  }
749
717
  });
750
718
  const stringifiedParams = normalizedParams.toString();
751
- return stringifiedParams.length > 0 ? `/warehouses?${stringifiedParams}` : `/warehouses`;
719
+ return stringifiedParams.length > 0 ? `/api/v1/warehouses?${stringifiedParams}` : `/api/v1/warehouses`;
752
720
  };
753
721
  export const listWarehouses = async (params, options) => {
754
722
  const res = await fetch(getListWarehousesUrl(params), {
@@ -761,7 +729,7 @@ export const listWarehouses = async (params, options) => {
761
729
  };
762
730
  export const getListWarehousesQueryKey = (params) => {
763
731
  return [
764
- `/warehouses`, ...(params ? [params] : [])
732
+ `/api/v1/warehouses`, ...(params ? [params] : [])
765
733
  ];
766
734
  };
767
735
  export const getListWarehousesQueryOptions = (params, options) => {
@@ -788,7 +756,7 @@ export const getListStockMovementsUrl = (params) => {
788
756
  }
789
757
  });
790
758
  const stringifiedParams = normalizedParams.toString();
791
- return stringifiedParams.length > 0 ? `/stock-movements?${stringifiedParams}` : `/stock-movements`;
759
+ return stringifiedParams.length > 0 ? `/api/v1/stock-movements?${stringifiedParams}` : `/api/v1/stock-movements`;
792
760
  };
793
761
  export const listStockMovements = async (params, options) => {
794
762
  const res = await fetch(getListStockMovementsUrl(params), {
@@ -801,7 +769,7 @@ export const listStockMovements = async (params, options) => {
801
769
  };
802
770
  export const getListStockMovementsQueryKey = (params) => {
803
771
  return [
804
- `/stock-movements`, ...(params ? [params] : [])
772
+ `/api/v1/stock-movements`, ...(params ? [params] : [])
805
773
  ];
806
774
  };
807
775
  export const getListStockMovementsQueryOptions = (params, options) => {
@@ -820,7 +788,7 @@ export function useListStockMovements(params, options, queryClient) {
820
788
  return query;
821
789
  }
822
790
  export const getCreateStockItemUrl = () => {
823
- return `/stock-items`;
791
+ return `/api/v1/stock-items`;
824
792
  };
825
793
  export const createStockItem = async (createStockItemBody, options) => {
826
794
  const res = await fetch(getCreateStockItemUrl(), {
@@ -862,7 +830,7 @@ export const getListStockItemsUrl = (params) => {
862
830
  }
863
831
  });
864
832
  const stringifiedParams = normalizedParams.toString();
865
- return stringifiedParams.length > 0 ? `/stock-items?${stringifiedParams}` : `/stock-items`;
833
+ return stringifiedParams.length > 0 ? `/api/v1/stock-items?${stringifiedParams}` : `/api/v1/stock-items`;
866
834
  };
867
835
  export const listStockItems = async (params, options) => {
868
836
  const res = await fetch(getListStockItemsUrl(params), {
@@ -875,7 +843,7 @@ export const listStockItems = async (params, options) => {
875
843
  };
876
844
  export const getListStockItemsQueryKey = (params) => {
877
845
  return [
878
- `/stock-items`, ...(params ? [params] : [])
846
+ `/api/v1/stock-items`, ...(params ? [params] : [])
879
847
  ];
880
848
  };
881
849
  export const getListStockItemsQueryOptions = (params, options) => {
@@ -894,7 +862,7 @@ export function useListStockItems(params, options, queryClient) {
894
862
  return query;
895
863
  }
896
864
  export const getCreateBatchUrl = () => {
897
- return `/batches`;
865
+ return `/api/v1/batches`;
898
866
  };
899
867
  export const createBatch = async (createBatchBody, options) => {
900
868
  const res = await fetch(getCreateBatchUrl(), {
@@ -927,6 +895,38 @@ export const useCreateBatch = (options, queryClient) => {
927
895
  const mutationOptions = getCreateBatchMutationOptions(options);
928
896
  return useMutation(mutationOptions, queryClient);
929
897
  };
898
+ export const getGetHealthUrl = () => {
899
+ return `/health`;
900
+ };
901
+ export const getHealth = async (options) => {
902
+ const res = await fetch(getGetHealthUrl(), {
903
+ ...options,
904
+ method: 'GET'
905
+ });
906
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
907
+ const data = body ? JSON.parse(body) : {};
908
+ return { data, status: res.status, headers: res.headers };
909
+ };
910
+ export const getGetHealthQueryKey = () => {
911
+ return [
912
+ `/health`
913
+ ];
914
+ };
915
+ export const getGetHealthQueryOptions = (options) => {
916
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
917
+ const queryKey = queryOptions?.queryKey ?? getGetHealthQueryKey();
918
+ const queryFn = ({ signal }) => getHealth({ signal, ...fetchOptions });
919
+ return { queryKey, queryFn, ...queryOptions };
920
+ };
921
+ /**
922
+ * @summary Health check
923
+ */
924
+ export function useGetHealth(options, queryClient) {
925
+ const queryOptions = getGetHealthQueryOptions(options);
926
+ const query = useQuery(queryOptions, queryClient);
927
+ query.queryKey = queryOptions.queryKey;
928
+ return query;
929
+ }
930
930
  export const getGetUrl = () => {
931
931
  return `/`;
932
932
  };