@instockng/api-client 1.0.9 → 1.0.11

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 (117) hide show
  1. package/dist/apps/backend/src/lib/brand-response.d.ts +2 -0
  2. package/dist/apps/backend/src/lib/cart-helpers.d.ts +4 -0
  3. package/dist/apps/backend/src/lib/cart-response.d.ts +2 -0
  4. package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +2 -0
  5. package/dist/apps/backend/src/lib/discount-code-response.d.ts +2 -0
  6. package/dist/apps/backend/src/lib/order-recovery.d.ts +6 -0
  7. package/dist/apps/backend/src/lib/order-response.d.ts +2 -0
  8. package/dist/apps/backend/src/lib/product-response.d.ts +2 -0
  9. package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +4 -8
  10. package/dist/apps/backend/src/routes/admin/brands.d.ts +8 -0
  11. package/dist/apps/backend/src/routes/admin/customers.d.ts +2 -4
  12. package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +8 -0
  13. package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +10 -0
  14. package/dist/apps/backend/src/routes/admin/inventory.d.ts +0 -4
  15. package/dist/apps/backend/src/routes/admin/orders.d.ts +12 -24
  16. package/dist/apps/backend/src/routes/admin/products.d.ts +8 -16
  17. package/dist/apps/backend/src/routes/admin/stats.d.ts +2 -4
  18. package/dist/apps/backend/src/routes/admin/warehouses.d.ts +2 -4
  19. package/dist/apps/backend/src/routes/public/brands.d.ts +1 -0
  20. package/dist/apps/backend/src/routes/public/brands.js +1 -0
  21. package/dist/apps/backend/src/routes/public/carts.d.ts +18 -36
  22. package/dist/apps/backend/src/routes/public/orders.d.ts +4 -8
  23. package/dist/apps/backend/src/routes/public/products.d.ts +4 -8
  24. package/dist/apps/backend/src/validators/brand.d.ts +4 -0
  25. package/dist/apps/backend/src/validators/brand.js +4 -0
  26. package/dist/packages/api-client/src/fetchers/brands.d.ts +1 -0
  27. package/dist/packages/api-client/src/fetchers/carts.d.ts +18 -36
  28. package/dist/packages/api-client/src/fetchers/orders.d.ts +4 -8
  29. package/dist/packages/api-client/src/fetchers/products.d.ts +4 -8
  30. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +4 -8
  31. package/dist/packages/api-client/src/hooks/admin/brands.d.ts +8 -0
  32. package/dist/packages/api-client/src/hooks/admin/customers.d.ts +2 -4
  33. package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +8 -0
  34. package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +10 -0
  35. package/dist/packages/api-client/src/hooks/admin/inventory.d.ts +0 -4
  36. package/dist/packages/api-client/src/hooks/admin/orders.d.ts +12 -24
  37. package/dist/packages/api-client/src/hooks/admin/products.d.ts +4 -8
  38. package/dist/packages/api-client/src/hooks/admin/stats.d.ts +2 -4
  39. package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +2 -4
  40. package/dist/packages/api-client/src/hooks/public/brands.d.ts +1 -0
  41. package/dist/packages/api-client/src/hooks/public/carts.d.ts +18 -36
  42. package/dist/packages/api-client/src/hooks/public/orders.d.ts +4 -8
  43. package/dist/packages/api-client/src/hooks/public/products.d.ts +4 -8
  44. package/dist/packages/api-client/src/rpc-client.d.ts +83 -116
  45. package/package.json +1 -1
  46. package/dist/apps/backend/src/generated/zod/index.d.ts +0 -1114
  47. package/dist/apps/backend/src/generated/zod/index.js +0 -670
  48. package/dist/backend-types.d.ts +0 -10
  49. package/dist/backend-types.js +0 -10
  50. package/dist/client.d.ts +0 -20
  51. package/dist/client.js +0 -40
  52. package/dist/enum-types.d.ts +0 -8
  53. package/dist/enum-types.js +0 -5
  54. package/dist/fetchers/brands.d.ts +0 -25
  55. package/dist/fetchers/brands.js +0 -26
  56. package/dist/fetchers/carts.d.ts +0 -2335
  57. package/dist/fetchers/carts.js +0 -174
  58. package/dist/fetchers/delivery-zones.d.ts +0 -28
  59. package/dist/fetchers/delivery-zones.js +0 -26
  60. package/dist/fetchers/index.d.ts +0 -22
  61. package/dist/fetchers/index.js +0 -22
  62. package/dist/fetchers/orders.d.ts +0 -540
  63. package/dist/fetchers/orders.js +0 -44
  64. package/dist/fetchers/products.d.ts +0 -386
  65. package/dist/fetchers/products.js +0 -42
  66. package/dist/hooks/admin/abandoned-carts.d.ts +0 -535
  67. package/dist/hooks/admin/abandoned-carts.js +0 -83
  68. package/dist/hooks/admin/brands.d.ts +0 -79
  69. package/dist/hooks/admin/brands.js +0 -108
  70. package/dist/hooks/admin/customers.d.ts +0 -278
  71. package/dist/hooks/admin/customers.js +0 -26
  72. package/dist/hooks/admin/delivery-zones.d.ts +0 -270
  73. package/dist/hooks/admin/delivery-zones.js +0 -176
  74. package/dist/hooks/admin/discount-codes.d.ts +0 -299
  75. package/dist/hooks/admin/discount-codes.js +0 -165
  76. package/dist/hooks/admin/index.d.ts +0 -16
  77. package/dist/hooks/admin/index.js +0 -16
  78. package/dist/hooks/admin/inventory.d.ts +0 -224
  79. package/dist/hooks/admin/inventory.js +0 -107
  80. package/dist/hooks/admin/orders.d.ts +0 -1662
  81. package/dist/hooks/admin/orders.js +0 -178
  82. package/dist/hooks/admin/products.d.ts +0 -374
  83. package/dist/hooks/admin/products.js +0 -89
  84. package/dist/hooks/admin/stats.d.ts +0 -277
  85. package/dist/hooks/admin/stats.js +0 -25
  86. package/dist/hooks/admin/variants.d.ts +0 -115
  87. package/dist/hooks/admin/variants.js +0 -127
  88. package/dist/hooks/admin/warehouses.d.ts +0 -277
  89. package/dist/hooks/admin/warehouses.js +0 -108
  90. package/dist/hooks/public/brands.d.ts +0 -33
  91. package/dist/hooks/public/brands.js +0 -30
  92. package/dist/hooks/public/carts.d.ts +0 -2405
  93. package/dist/hooks/public/carts.js +0 -213
  94. package/dist/hooks/public/delivery-zones.d.ts +0 -34
  95. package/dist/hooks/public/delivery-zones.js +0 -28
  96. package/dist/hooks/public/index.d.ts +0 -10
  97. package/dist/hooks/public/index.js +0 -10
  98. package/dist/hooks/public/orders.d.ts +0 -559
  99. package/dist/hooks/public/orders.js +0 -50
  100. package/dist/hooks/public/products.d.ts +0 -398
  101. package/dist/hooks/public/products.js +0 -47
  102. package/dist/hooks/use-query-unwrapped.d.ts +0 -20
  103. package/dist/hooks/use-query-unwrapped.js +0 -22
  104. package/dist/hooks/useApiConfig.d.ts +0 -12
  105. package/dist/hooks/useApiConfig.js +0 -14
  106. package/dist/index.d.ts +0 -20
  107. package/dist/index.js +0 -25
  108. package/dist/provider.d.ts +0 -36
  109. package/dist/provider.js +0 -54
  110. package/dist/rpc-client.d.ts +0 -9607
  111. package/dist/rpc-client.js +0 -78
  112. package/dist/rpc-types.d.ts +0 -76
  113. package/dist/rpc-types.js +0 -7
  114. package/dist/types.d.ts +0 -34
  115. package/dist/types.js +0 -16
  116. package/dist/utils/query-keys.d.ts +0 -106
  117. package/dist/utils/query-keys.js +0 -108
@@ -1,213 +0,0 @@
1
- /**
2
- * Type-safe RPC hooks for cart operations
3
- *
4
- * These hooks use Hono RPC client with types directly from the backend,
5
- * providing end-to-end type safety without code generation.
6
- */
7
- import { useMutation, useQueryClient } from '@tanstack/react-query';
8
- import { useQueryUnwrapped } from '../use-query-unwrapped';
9
- import { queryKeys } from '../../utils/query-keys';
10
- import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, } from '../../fetchers/carts';
11
- /**
12
- * Hook to get cart by ID using RPC
13
- *
14
- * @param cartId - Cart UUID
15
- * @param options - React Query options
16
- *
17
- * @example
18
- * ```tsx
19
- * const { data: cart, isLoading } = useGetCart('cart-123');
20
- * console.log(cart?.cart.brand.name); // Fully typed!
21
- * ```
22
- */
23
- export function useGetCart(cartId, options) {
24
- return useQueryUnwrapped({
25
- queryKey: queryKeys.public.carts.detail(cartId),
26
- queryFn: () => fetchCart(cartId),
27
- ...options,
28
- });
29
- }
30
- /**
31
- * Hook to update cart using RPC
32
- *
33
- * @param cartId - Cart UUID
34
- * @param options - React Query mutation options
35
- *
36
- * @example
37
- * ```tsx
38
- * const updateCart = useUpdateCart('cart-123');
39
- * updateCart.mutate({
40
- * customerEmail: 'user@example.com',
41
- * deliveryZoneId: 'zone-123'
42
- * });
43
- * ```
44
- */
45
- export function useUpdateCart(cartId, options) {
46
- const queryClient = useQueryClient();
47
- return useMutation({
48
- mutationFn: (data) => updateCart(cartId, data),
49
- onSuccess: () => {
50
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
51
- },
52
- ...options,
53
- });
54
- }
55
- /**
56
- * Hook to create a new cart using RPC
57
- *
58
- * @param options - React Query mutation options
59
- *
60
- * @example
61
- * ```tsx
62
- * const createCart = useCreateCart();
63
- * createCart.mutate('my-brand');
64
- * ```
65
- */
66
- export function useCreateCart(options) {
67
- return useMutation({
68
- mutationFn: (brandSlug) => createCart(brandSlug),
69
- ...options,
70
- });
71
- }
72
- /**
73
- * Hook to apply discount code to cart using RPC
74
- *
75
- * @param cartId - Cart UUID
76
- * @param options - React Query mutation options
77
- *
78
- * @example
79
- * ```tsx
80
- * const applyDiscount = useApplyDiscount('cart-123');
81
- * applyDiscount.mutate({ code: 'SAVE10' });
82
- * ```
83
- */
84
- export function useApplyDiscount(cartId, options) {
85
- const queryClient = useQueryClient();
86
- return useMutation({
87
- mutationFn: (data) => applyDiscount(cartId, data.code),
88
- onSuccess: () => {
89
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
90
- },
91
- ...options,
92
- });
93
- }
94
- /**
95
- * Hook to remove discount code from cart using RPC
96
- *
97
- * @param cartId - Cart UUID
98
- * @param options - React Query mutation options
99
- *
100
- * @example
101
- * ```tsx
102
- * const removeDiscount = useRemoveDiscount('cart-123');
103
- * removeDiscount.mutate();
104
- * ```
105
- */
106
- export function useRemoveDiscount(cartId, options) {
107
- const queryClient = useQueryClient();
108
- return useMutation({
109
- mutationFn: () => removeDiscount(cartId),
110
- onSuccess: () => {
111
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
112
- },
113
- ...options,
114
- });
115
- }
116
- /**
117
- * Hook to add item to cart using RPC
118
- *
119
- * @param cartId - Cart UUID
120
- * @param options - React Query mutation options
121
- *
122
- * @example
123
- * ```tsx
124
- * const addItem = useAddCartItem('cart-123');
125
- * addItem.mutate({ sku: 'PROD-001', quantity: 2, fbc: '_fbc_cookie', fbp: '_fbp_cookie' });
126
- * ```
127
- */
128
- export function useAddCartItem(cartId, options) {
129
- const queryClient = useQueryClient();
130
- return useMutation({
131
- mutationFn: (data) => addCartItem(cartId, data.sku, data.quantity, data.fbc, data.fbp),
132
- onSuccess: () => {
133
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
134
- },
135
- ...options,
136
- });
137
- }
138
- /**
139
- * Hook to update cart item quantity using RPC
140
- *
141
- * @param cartId - Cart UUID
142
- * @param options - React Query mutation options
143
- *
144
- * @example
145
- * ```tsx
146
- * const updateItem = useUpdateCartItem('cart-123');
147
- * updateItem.mutate({ itemId: 'item-456', quantity: 3 });
148
- * ```
149
- */
150
- export function useUpdateCartItem(cartId, options) {
151
- const queryClient = useQueryClient();
152
- return useMutation({
153
- mutationFn: ({ itemId, quantity }) => updateCartItem(cartId, itemId, quantity),
154
- onSuccess: () => {
155
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
156
- },
157
- ...options,
158
- });
159
- }
160
- /**
161
- * Hook to remove item from cart using RPC
162
- *
163
- * @param cartId - Cart UUID
164
- * @param options - React Query mutation options
165
- *
166
- * @example
167
- * ```tsx
168
- * const removeItem = useRemoveCartItem('cart-123');
169
- * removeItem.mutate('item-456'); // Pass itemId in mutate call
170
- * ```
171
- */
172
- export function useRemoveCartItem(cartId, options) {
173
- const queryClient = useQueryClient();
174
- return useMutation({
175
- mutationFn: (itemId) => removeCartItem(cartId, itemId),
176
- onSuccess: () => {
177
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
178
- },
179
- ...options,
180
- });
181
- }
182
- /**
183
- * Hook to checkout a cart and create an order using RPC
184
- *
185
- * @param cartId - Cart UUID
186
- * @param options - React Query mutation options
187
- *
188
- * @example
189
- * ```tsx
190
- * const checkout = useCheckoutCart('cart-123');
191
- * checkout.mutate({
192
- * firstName: 'John',
193
- * lastName: 'Doe',
194
- * email: 'john@example.com',
195
- * phone: '+1234567890',
196
- * address: '123 Main St',
197
- * city: 'New York',
198
- * deliveryZoneId: 'zone-123',
199
- * paymentMethod: 'cod'
200
- * });
201
- * ```
202
- */
203
- export function useCheckoutCart(cartId, options) {
204
- const queryClient = useQueryClient();
205
- return useMutation({
206
- mutationFn: (data) => checkoutCart(cartId, data),
207
- onSuccess: () => {
208
- // Invalidate cart query since it's now converted to an order
209
- queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
210
- },
211
- ...options,
212
- });
213
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Type-safe RPC hooks for delivery zone operations
3
- *
4
- * These hooks use Hono RPC client with types directly from the backend,
5
- * providing end-to-end type safety without code generation.
6
- */
7
- import { UseQueryOptions } from '@tanstack/react-query';
8
- import { fetchDeliveryZones } from '../../fetchers/delivery-zones';
9
- /**
10
- * Hook to get delivery zones using RPC
11
- *
12
- * @param brandId - Optional brand UUID to filter brand-specific zones
13
- * @param options - React Query options
14
- *
15
- * @example
16
- * ```tsx
17
- * const { data: zones, isLoading } = useGetDeliveryZones(undefined);
18
- * console.log(zones?.data[0].name); // Fully typed!
19
- * ```
20
- */
21
- export declare function useGetDeliveryZones(brandId: string | undefined, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchDeliveryZones>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
22
- id: string;
23
- name: string;
24
- zones: {
25
- id: string;
26
- name: string;
27
- deliveryCost: number;
28
- freeShippingThreshold: number;
29
- allowCOD: boolean;
30
- allowOnline: boolean;
31
- waybillOnly: boolean;
32
- estimatedDays: number;
33
- }[];
34
- }[], Error>;
@@ -1,28 +0,0 @@
1
- /**
2
- * Type-safe RPC hooks for delivery zone operations
3
- *
4
- * These hooks use Hono RPC client with types directly from the backend,
5
- * providing end-to-end type safety without code generation.
6
- */
7
- import { useQueryUnwrapped } from '../use-query-unwrapped';
8
- import { queryKeys } from '../../utils/query-keys';
9
- import { fetchDeliveryZones } from '../../fetchers/delivery-zones';
10
- /**
11
- * Hook to get delivery zones using RPC
12
- *
13
- * @param brandId - Optional brand UUID to filter brand-specific zones
14
- * @param options - React Query options
15
- *
16
- * @example
17
- * ```tsx
18
- * const { data: zones, isLoading } = useGetDeliveryZones(undefined);
19
- * console.log(zones?.data[0].name); // Fully typed!
20
- * ```
21
- */
22
- export function useGetDeliveryZones(brandId, options) {
23
- return useQueryUnwrapped({
24
- queryKey: queryKeys.public.deliveryZones.list(brandId),
25
- queryFn: () => fetchDeliveryZones(brandId),
26
- ...options,
27
- });
28
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Type-safe RPC hooks
3
- *
4
- * Export all RPC hooks for use in applications
5
- */
6
- export * from './carts';
7
- export * from './orders';
8
- export * from './products';
9
- export * from './delivery-zones';
10
- export * from './brands';
@@ -1,10 +0,0 @@
1
- /**
2
- * Type-safe RPC hooks
3
- *
4
- * Export all RPC hooks for use in applications
5
- */
6
- export * from './carts';
7
- export * from './orders';
8
- export * from './products';
9
- export * from './delivery-zones';
10
- export * from './brands';