@instockng/api-client 1.0.0 → 1.0.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 (86) hide show
  1. package/dist/backend-types.d.ts +10 -0
  2. package/dist/backend-types.js +10 -0
  3. package/dist/client.d.ts +20 -0
  4. package/dist/client.js +40 -0
  5. package/dist/fetchers/carts.d.ts +2330 -0
  6. package/dist/fetchers/carts.js +167 -0
  7. package/dist/fetchers/delivery-zones.d.ts +28 -0
  8. package/{src/fetchers/delivery-zones.ts → dist/fetchers/delivery-zones.js} +9 -12
  9. package/{src/fetchers/index.ts → dist/fetchers/index.d.ts} +0 -1
  10. package/dist/fetchers/index.js +21 -0
  11. package/dist/fetchers/orders.d.ts +282 -0
  12. package/dist/fetchers/orders.js +44 -0
  13. package/dist/fetchers/products.d.ts +384 -0
  14. package/dist/fetchers/products.js +42 -0
  15. package/dist/hooks/admin/abandoned-carts.d.ts +533 -0
  16. package/dist/hooks/admin/abandoned-carts.js +79 -0
  17. package/dist/hooks/admin/brands.d.ts +75 -0
  18. package/dist/hooks/admin/brands.js +103 -0
  19. package/dist/hooks/admin/customers.d.ts +277 -0
  20. package/dist/hooks/admin/customers.js +25 -0
  21. package/dist/hooks/admin/delivery-zones.d.ts +266 -0
  22. package/dist/hooks/admin/delivery-zones.js +168 -0
  23. package/dist/hooks/admin/discount-codes.d.ts +294 -0
  24. package/dist/hooks/admin/discount-codes.js +157 -0
  25. package/{src/hooks/admin/index.ts → dist/hooks/admin/index.d.ts} +0 -1
  26. package/dist/hooks/admin/index.js +16 -0
  27. package/dist/hooks/admin/inventory.d.ts +224 -0
  28. package/dist/hooks/admin/inventory.js +102 -0
  29. package/dist/hooks/admin/orders.d.ts +1375 -0
  30. package/dist/hooks/admin/orders.js +169 -0
  31. package/dist/hooks/admin/products.d.ts +372 -0
  32. package/dist/hooks/admin/products.js +84 -0
  33. package/dist/hooks/admin/stats.d.ts +276 -0
  34. package/dist/hooks/admin/stats.js +24 -0
  35. package/dist/hooks/admin/variants.d.ts +115 -0
  36. package/dist/hooks/admin/variants.js +121 -0
  37. package/dist/hooks/admin/warehouses.d.ts +276 -0
  38. package/dist/hooks/admin/warehouses.js +103 -0
  39. package/dist/hooks/public/carts.d.ts +2398 -0
  40. package/dist/hooks/public/carts.js +213 -0
  41. package/dist/hooks/public/delivery-zones.d.ts +34 -0
  42. package/{src/hooks/public/delivery-zones.ts → dist/hooks/public/delivery-zones.js} +6 -12
  43. package/{src/hooks/public/index.ts → dist/hooks/public/index.d.ts} +0 -1
  44. package/dist/hooks/public/index.js +9 -0
  45. package/dist/hooks/public/orders.d.ts +301 -0
  46. package/{src/hooks/public/orders.ts → dist/hooks/public/orders.js} +12 -28
  47. package/dist/hooks/public/products.d.ts +396 -0
  48. package/{src/hooks/public/products.ts → dist/hooks/public/products.js} +12 -22
  49. package/dist/hooks/use-query-unwrapped.d.ts +20 -0
  50. package/dist/hooks/use-query-unwrapped.js +22 -0
  51. package/dist/hooks/useApiConfig.d.ts +11 -0
  52. package/dist/hooks/useApiConfig.js +14 -0
  53. package/dist/index.d.ts +20 -0
  54. package/{src/index.ts → dist/index.js} +0 -17
  55. package/dist/provider.d.ts +33 -0
  56. package/dist/provider.js +52 -0
  57. package/dist/rpc-client.d.ts +8966 -0
  58. package/dist/rpc-client.js +79 -0
  59. package/{src/rpc-types.ts → dist/rpc-types.d.ts} +35 -80
  60. package/dist/rpc-types.js +7 -0
  61. package/{src/types.ts → dist/types.d.ts} +0 -6
  62. package/dist/types.js +16 -0
  63. package/dist/utils/query-keys.d.ts +102 -0
  64. package/dist/utils/query-keys.js +104 -0
  65. package/package.json +20 -13
  66. package/src/client.ts +0 -57
  67. package/src/fetchers/carts.ts +0 -202
  68. package/src/fetchers/orders.ts +0 -48
  69. package/src/fetchers/products.ts +0 -46
  70. package/src/hooks/admin/abandoned-carts.ts +0 -102
  71. package/src/hooks/admin/brands.ts +0 -134
  72. package/src/hooks/admin/customers.ts +0 -31
  73. package/src/hooks/admin/delivery-zones.ts +0 -236
  74. package/src/hooks/admin/discount-codes.ts +0 -222
  75. package/src/hooks/admin/inventory.ts +0 -137
  76. package/src/hooks/admin/orders.ts +0 -229
  77. package/src/hooks/admin/products.ts +0 -116
  78. package/src/hooks/admin/stats.ts +0 -30
  79. package/src/hooks/admin/variants.ts +0 -173
  80. package/src/hooks/admin/warehouses.ts +0 -143
  81. package/src/hooks/public/carts.ts +0 -298
  82. package/src/hooks/use-query-unwrapped.ts +0 -30
  83. package/src/hooks/useApiConfig.ts +0 -22
  84. package/src/provider.tsx +0 -89
  85. package/src/rpc-client.ts +0 -106
  86. package/src/utils/query-keys.ts +0 -121
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Backend RPC types - AUTO-GENERATED, DO NOT EDIT MANUALLY
3
+ *
4
+ * Generated from apps/backend/src/index.ts
5
+ * Run 'pnpm run generate-types' to regenerate this file
6
+ *
7
+ * These types provide end-to-end type safety between the backend API
8
+ * and the frontend hooks/fetchers.
9
+ */
10
+ export type { CartsRPC, OrdersRPC, ProductsRPC, DeliveryZonesRPC, AdminOrdersRPC, AdminBrandsRPC, AdminProductsRPC, AdminVariantsRPC, AdminWarehousesRPC, AdminInventoryRPC, AdminCustomersRPC, AdminStatsRPC, AdminAbandonedCartsRPC, AdminDiscountCodesRPC, AdminDeliveryZonesRPC, } from '../../../apps/backend/src/http-app';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Backend RPC types - AUTO-GENERATED, DO NOT EDIT MANUALLY
3
+ *
4
+ * Generated from apps/backend/src/index.ts
5
+ * Run 'pnpm run generate-types' to regenerate this file
6
+ *
7
+ * These types provide end-to-end type safety between the backend API
8
+ * and the frontend hooks/fetchers.
9
+ */
10
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Axios client configuration for OMS API
3
+ */
4
+ import { AxiosInstance, AxiosError } from 'axios';
5
+ export interface ApiClientConfig {
6
+ baseURL: string;
7
+ onError?: (error: AxiosError) => void;
8
+ }
9
+ /**
10
+ * Initialize the API client with configuration
11
+ */
12
+ export declare function initializeApiClient(config: ApiClientConfig): AxiosInstance;
13
+ /**
14
+ * Get the current API client instance
15
+ */
16
+ export declare function getApiClient(): AxiosInstance;
17
+ /**
18
+ * Reset the API client (mainly for testing)
19
+ */
20
+ export declare function resetApiClient(): void;
package/dist/client.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Axios client configuration for OMS API
3
+ */
4
+ import axios from 'axios';
5
+ let apiClient = null;
6
+ /**
7
+ * Initialize the API client with configuration
8
+ */
9
+ export function initializeApiClient(config) {
10
+ apiClient = axios.create({
11
+ baseURL: config.baseURL,
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ });
16
+ // Response interceptor for error handling
17
+ apiClient.interceptors.response.use((response) => response, (error) => {
18
+ // Call custom error handler if provided
19
+ if (config.onError) {
20
+ config.onError(error);
21
+ }
22
+ return Promise.reject(error);
23
+ });
24
+ return apiClient;
25
+ }
26
+ /**
27
+ * Get the current API client instance
28
+ */
29
+ export function getApiClient() {
30
+ if (!apiClient) {
31
+ throw new Error('API client not initialized. Make sure to wrap your app with ApiClientProvider.');
32
+ }
33
+ return apiClient;
34
+ }
35
+ /**
36
+ * Reset the API client (mainly for testing)
37
+ */
38
+ export function resetApiClient() {
39
+ apiClient = null;
40
+ }