@instockng/api-client 1.0.35 → 1.0.37

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 (37) hide show
  1. package/dist/backend-types.d.ts +1 -1
  2. package/dist/fetchers/brands.d.ts +1 -0
  3. package/dist/fetchers/brands.js +1 -1
  4. package/dist/fetchers/carts.d.ts +132 -112
  5. package/dist/fetchers/carts.js +1 -1
  6. package/dist/fetchers/delivery-zones.d.ts +0 -1
  7. package/dist/fetchers/delivery-zones.js +1 -1
  8. package/dist/fetchers/orders.d.ts +94 -30
  9. package/dist/fetchers/orders.js +38 -1
  10. package/dist/fetchers/products.js +1 -1
  11. package/dist/hooks/admin/abandoned-carts.d.ts +24 -24
  12. package/dist/hooks/admin/brands.d.ts +4 -0
  13. package/dist/hooks/admin/customers.d.ts +33 -14
  14. package/dist/hooks/admin/delivery-zones.d.ts +12 -8
  15. package/dist/hooks/admin/discount-codes.d.ts +20 -15
  16. package/dist/hooks/admin/dispatch-riders.d.ts +59 -0
  17. package/dist/hooks/admin/dispatch-riders.js +92 -0
  18. package/dist/hooks/admin/index.d.ts +1 -0
  19. package/dist/hooks/admin/index.js +1 -0
  20. package/dist/hooks/admin/orders.d.ts +215 -78
  21. package/dist/hooks/admin/orders.js +70 -0
  22. package/dist/hooks/admin/products.d.ts +6 -4
  23. package/dist/hooks/admin/stats.d.ts +40 -14
  24. package/dist/hooks/admin/stats.js +20 -0
  25. package/dist/hooks/admin/warehouses.d.ts +7 -6
  26. package/dist/hooks/public/brands.d.ts +1 -0
  27. package/dist/hooks/public/carts.d.ts +132 -112
  28. package/dist/hooks/public/delivery-zones.d.ts +0 -1
  29. package/dist/hooks/public/orders.d.ts +98 -31
  30. package/dist/hooks/public/orders.js +23 -1
  31. package/dist/provider.js +1 -1
  32. package/dist/rpc-client.d.ts +6684 -3768
  33. package/dist/rpc-client.js +1 -0
  34. package/dist/rpc-types.d.ts +9 -6
  35. package/dist/utils/query-keys.d.ts +5 -0
  36. package/dist/utils/query-keys.js +5 -0
  37. package/package.json +1 -1
@@ -9,7 +9,6 @@ import { createAdminRpcClients } from '../../rpc-client';
9
9
  export declare function useListStates(options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['deliveryZones']['states']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
10
10
  deliveryZones: {
11
11
  deliveryCost: number;
12
- freeShippingThreshold: number;
13
12
  createdAt: string;
14
13
  updatedAt: string;
15
14
  deletedAt: string;
@@ -23,6 +22,7 @@ export declare function useListStates(options?: Omit<UseQueryOptions<Awaited<Ret
23
22
  metaPixelId: string;
24
23
  tiktokPixelId: string;
25
24
  paystackPublicKey: string;
25
+ freeShippingThreshold: number;
26
26
  createdAt: string;
27
27
  updatedAt: string;
28
28
  deletedAt: string;
@@ -39,6 +39,8 @@ export declare function useListStates(options?: Omit<UseQueryOptions<Awaited<Ret
39
39
  };
40
40
  id: string;
41
41
  name: string;
42
+ freeShippingThreshold: string;
43
+ isActive: boolean;
42
44
  brandId: string | null;
43
45
  stateId: string;
44
46
  allowCOD: boolean;
@@ -47,7 +49,6 @@ export declare function useListStates(options?: Omit<UseQueryOptions<Awaited<Ret
47
49
  estimatedDays: number | null;
48
50
  noteTitle: string | null;
49
51
  noteContent: string | null;
50
- isActive: boolean;
51
52
  }[];
52
53
  zonesCount: number;
53
54
  createdAt: string;
@@ -120,7 +121,6 @@ export declare function useListDeliveryZones(params?: {
120
121
  brandId?: string;
121
122
  }, options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['deliveryZones']['zones']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
122
123
  deliveryCost: number;
123
- freeShippingThreshold: number;
124
124
  createdAt: string;
125
125
  updatedAt: string;
126
126
  deletedAt: string;
@@ -134,6 +134,7 @@ export declare function useListDeliveryZones(params?: {
134
134
  metaPixelId: string;
135
135
  tiktokPixelId: string;
136
136
  paystackPublicKey: string;
137
+ freeShippingThreshold: number;
137
138
  createdAt: string;
138
139
  updatedAt: string;
139
140
  deletedAt: string;
@@ -150,6 +151,8 @@ export declare function useListDeliveryZones(params?: {
150
151
  };
151
152
  id: string;
152
153
  name: string;
154
+ freeShippingThreshold: string;
155
+ isActive: boolean;
153
156
  brandId: string | null;
154
157
  stateId: string;
155
158
  allowCOD: boolean;
@@ -158,14 +161,12 @@ export declare function useListDeliveryZones(params?: {
158
161
  estimatedDays: number | null;
159
162
  noteTitle: string | null;
160
163
  noteContent: string | null;
161
- isActive: boolean;
162
164
  }[], Error>;
163
165
  /**
164
166
  * Hook to create a delivery zone using admin RPC
165
167
  */
166
168
  export declare function useCreateDeliveryZone(options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['deliveryZones']['zones']['$post']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
167
169
  deliveryCost: number;
168
- freeShippingThreshold: number;
169
170
  createdAt: string;
170
171
  updatedAt: string;
171
172
  deletedAt: string;
@@ -179,6 +180,7 @@ export declare function useCreateDeliveryZone(options?: UseMutationOptions<Await
179
180
  metaPixelId: string;
180
181
  tiktokPixelId: string;
181
182
  paystackPublicKey: string;
183
+ freeShippingThreshold: number;
182
184
  createdAt: string;
183
185
  updatedAt: string;
184
186
  deletedAt: string;
@@ -195,6 +197,8 @@ export declare function useCreateDeliveryZone(options?: UseMutationOptions<Await
195
197
  };
196
198
  id: string;
197
199
  name: string;
200
+ freeShippingThreshold: string;
201
+ isActive: boolean;
198
202
  brandId: string | null;
199
203
  stateId: string;
200
204
  allowCOD: boolean;
@@ -203,7 +207,6 @@ export declare function useCreateDeliveryZone(options?: UseMutationOptions<Await
203
207
  estimatedDays: number | null;
204
208
  noteTitle: string | null;
205
209
  noteContent: string | null;
206
- isActive: boolean;
207
210
  } | {
208
211
  error: {
209
212
  code: string;
@@ -225,7 +228,6 @@ export declare function useCreateDeliveryZone(options?: UseMutationOptions<Await
225
228
  */
226
229
  export declare function useUpdateDeliveryZone(zoneId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['deliveryZones']['zones'][':id']['$patch']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
227
230
  deliveryCost: number;
228
- freeShippingThreshold: number;
229
231
  createdAt: string;
230
232
  updatedAt: string;
231
233
  deletedAt: string;
@@ -239,6 +241,7 @@ export declare function useUpdateDeliveryZone(zoneId: string, options?: UseMutat
239
241
  metaPixelId: string;
240
242
  tiktokPixelId: string;
241
243
  paystackPublicKey: string;
244
+ freeShippingThreshold: number;
242
245
  createdAt: string;
243
246
  updatedAt: string;
244
247
  deletedAt: string;
@@ -255,6 +258,8 @@ export declare function useUpdateDeliveryZone(zoneId: string, options?: UseMutat
255
258
  };
256
259
  id: string;
257
260
  name: string;
261
+ freeShippingThreshold: string;
262
+ isActive: boolean;
258
263
  brandId: string | null;
259
264
  stateId: string;
260
265
  allowCOD: boolean;
@@ -263,7 +268,6 @@ export declare function useUpdateDeliveryZone(zoneId: string, options?: UseMutat
263
268
  estimatedDays: number | null;
264
269
  noteTitle: string | null;
265
270
  noteContent: string | null;
266
- isActive: boolean;
267
271
  } | {
268
272
  error: {
269
273
  code: string;
@@ -31,6 +31,7 @@ export declare function useListDiscountCodes(params?: {
31
31
  metaPixelId: string;
32
32
  tiktokPixelId: string;
33
33
  paystackPublicKey: string;
34
+ freeShippingThreshold: number;
34
35
  createdAt: string;
35
36
  updatedAt: string;
36
37
  deletedAt: string;
@@ -39,16 +40,16 @@ export declare function useListDiscountCodes(params?: {
39
40
  usagePercentage: number;
40
41
  id: string;
41
42
  type: string;
42
- brandId: string | null;
43
- isActive: boolean;
44
43
  code: string;
44
+ isActive: boolean;
45
+ brandId: string | null;
46
+ description: string | null;
45
47
  usageLimit: number | null;
46
48
  usageCount: number;
47
49
  perCustomerLimit: number | null;
48
50
  validFrom: string;
49
51
  validUntil: string;
50
52
  isAutoApply: boolean;
51
- description: string | null;
52
53
  category: string;
53
54
  createdBy: string | null;
54
55
  }[];
@@ -83,6 +84,7 @@ export declare function useGetDiscountCode(codeId: string, options?: Omit<UseQue
83
84
  metaPixelId: string;
84
85
  tiktokPixelId: string;
85
86
  paystackPublicKey: string;
87
+ freeShippingThreshold: number;
86
88
  createdAt: string;
87
89
  updatedAt: string;
88
90
  deletedAt: string;
@@ -91,16 +93,16 @@ export declare function useGetDiscountCode(codeId: string, options?: Omit<UseQue
91
93
  usagePercentage: number;
92
94
  id: string;
93
95
  type: string;
94
- brandId: string | null;
95
- isActive: boolean;
96
96
  code: string;
97
+ isActive: boolean;
98
+ brandId: string | null;
99
+ description: string | null;
97
100
  usageLimit: number | null;
98
101
  usageCount: number;
99
102
  perCustomerLimit: number | null;
100
103
  validFrom: string;
101
104
  validUntil: string;
102
105
  isAutoApply: boolean;
103
- description: string | null;
104
106
  category: string;
105
107
  createdBy: string | null;
106
108
  }, Error>;
@@ -134,6 +136,7 @@ export declare function useCreateDiscountCode(options?: UseMutationOptions<Await
134
136
  metaPixelId: string;
135
137
  tiktokPixelId: string;
136
138
  paystackPublicKey: string;
139
+ freeShippingThreshold: number;
137
140
  createdAt: string;
138
141
  updatedAt: string;
139
142
  deletedAt: string;
@@ -142,16 +145,16 @@ export declare function useCreateDiscountCode(options?: UseMutationOptions<Await
142
145
  usagePercentage: number;
143
146
  id: string;
144
147
  type: string;
145
- brandId: string | null;
146
- isActive: boolean;
147
148
  code: string;
149
+ isActive: boolean;
150
+ brandId: string | null;
151
+ description: string | null;
148
152
  usageLimit: number | null;
149
153
  usageCount: number;
150
154
  perCustomerLimit: number | null;
151
155
  validFrom: string;
152
156
  validUntil: string;
153
157
  isAutoApply: boolean;
154
- description: string | null;
155
158
  category: string;
156
159
  createdBy: string | null;
157
160
  } | {
@@ -180,6 +183,7 @@ export declare function useUpdateDiscountCode(codeId: string, options?: UseMutat
180
183
  metaPixelId: string;
181
184
  tiktokPixelId: string;
182
185
  paystackPublicKey: string;
186
+ freeShippingThreshold: number;
183
187
  createdAt: string;
184
188
  updatedAt: string;
185
189
  deletedAt: string;
@@ -188,16 +192,16 @@ export declare function useUpdateDiscountCode(codeId: string, options?: UseMutat
188
192
  usagePercentage: number;
189
193
  id: string;
190
194
  type: string;
191
- brandId: string | null;
192
- isActive: boolean;
193
195
  code: string;
196
+ isActive: boolean;
197
+ brandId: string | null;
198
+ description: string | null;
194
199
  usageLimit: number | null;
195
200
  usageCount: number;
196
201
  perCustomerLimit: number | null;
197
202
  validFrom: string;
198
203
  validUntil: string;
199
204
  isAutoApply: boolean;
200
- description: string | null;
201
205
  category: string;
202
206
  createdBy: string | null;
203
207
  } | {
@@ -261,6 +265,7 @@ export declare function useGetDiscountCodeAnalytics(codeId: string, options?: Om
261
265
  metaPixelId: string;
262
266
  tiktokPixelId: string;
263
267
  paystackPublicKey: string;
268
+ freeShippingThreshold: number;
264
269
  createdAt: string;
265
270
  updatedAt: string;
266
271
  deletedAt: string;
@@ -268,16 +273,16 @@ export declare function useGetDiscountCodeAnalytics(codeId: string, options?: Om
268
273
  isExpired: boolean;
269
274
  id: string;
270
275
  type: string;
271
- brandId: string | null;
272
- isActive: boolean;
273
276
  code: string;
277
+ isActive: boolean;
278
+ brandId: string | null;
279
+ description: string | null;
274
280
  usageLimit: number | null;
275
281
  usageCount: number;
276
282
  perCustomerLimit: number | null;
277
283
  validFrom: string;
278
284
  validUntil: string;
279
285
  isAutoApply: boolean;
280
- description: string | null;
281
286
  category: string;
282
287
  createdBy: string | null;
283
288
  }, Error>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Type-safe admin RPC hooks for dispatch rider management
3
+ */
4
+ import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
5
+ import { createAdminRpcClients } from '../../rpc-client';
6
+ /**
7
+ * Hook to list all dispatch riders using admin RPC
8
+ */
9
+ export declare function useListDispatchRiders(options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders']['index']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
10
+ id: string;
11
+ name: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ deletedAt: string;
15
+ phone: string;
16
+ }[], Error>;
17
+ /**
18
+ * Hook to create a dispatch rider using admin RPC
19
+ */
20
+ export declare function useCreateDispatchRider(options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders']['index']['$post']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
21
+ id: string;
22
+ name: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ deletedAt: string;
26
+ phone: string;
27
+ } | {
28
+ error: {
29
+ code: string;
30
+ message: string;
31
+ };
32
+ }, Error, any, unknown>;
33
+ /**
34
+ * Hook to update a dispatch rider using admin RPC
35
+ */
36
+ export declare function useUpdateDispatchRider(riderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders'][':id']['$patch']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
37
+ id: string;
38
+ name: string;
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ deletedAt: string;
42
+ phone: string;
43
+ } | {
44
+ error: {
45
+ code: string;
46
+ message: string;
47
+ };
48
+ }, Error, any, unknown>;
49
+ /**
50
+ * Hook to delete a dispatch rider using admin RPC
51
+ */
52
+ export declare function useDeleteDispatchRider(riderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders'][':id']['$delete']>>['json']>>, Error, void>): import("@tanstack/react-query").UseMutationResult<{
53
+ success: true;
54
+ } | {
55
+ error: {
56
+ code: string;
57
+ message: string;
58
+ };
59
+ }, Error, void, unknown>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Type-safe admin RPC hooks for dispatch rider management
3
+ */
4
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
5
+ import { useQueryUnwrapped } from '../use-query-unwrapped';
6
+ import { createAdminRpcClients, authHeaders } from '../../rpc-client';
7
+ import { queryKeys } from '../../utils/query-keys';
8
+ import { useApiConfig } from '../useApiConfig';
9
+ /**
10
+ * Hook to list all dispatch riders using admin RPC
11
+ */
12
+ export function useListDispatchRiders(options) {
13
+ const { baseURL, getAuthToken } = useApiConfig();
14
+ return useQueryUnwrapped({
15
+ queryKey: queryKeys.admin.dispatchRiders.list(),
16
+ queryFn: async () => {
17
+ const token = await getAuthToken();
18
+ const clients = createAdminRpcClients(baseURL);
19
+ const res = await clients.dispatchRiders.index.$get({}, authHeaders(token));
20
+ if (!res.ok)
21
+ throw new Error(`Failed to fetch dispatch riders: ${res.statusText}`);
22
+ return res.json();
23
+ },
24
+ ...options,
25
+ });
26
+ }
27
+ /**
28
+ * Hook to create a dispatch rider using admin RPC
29
+ */
30
+ export function useCreateDispatchRider(options) {
31
+ const { baseURL, getAuthToken } = useApiConfig();
32
+ const queryClient = useQueryClient();
33
+ return useMutation({
34
+ ...options,
35
+ mutationFn: async (data) => {
36
+ const token = await getAuthToken();
37
+ const clients = createAdminRpcClients(baseURL);
38
+ const res = await clients.dispatchRiders.index.$post({ json: data }, authHeaders(token));
39
+ if (!res.ok)
40
+ throw new Error(`Failed to create dispatch rider: ${res.statusText}`);
41
+ return res.json();
42
+ },
43
+ onSuccess: (...args) => {
44
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.dispatchRiders.all });
45
+ options?.onSuccess?.(...args);
46
+ },
47
+ });
48
+ }
49
+ /**
50
+ * Hook to update a dispatch rider using admin RPC
51
+ */
52
+ export function useUpdateDispatchRider(riderId, options) {
53
+ const { baseURL, getAuthToken } = useApiConfig();
54
+ const queryClient = useQueryClient();
55
+ return useMutation({
56
+ ...options,
57
+ mutationFn: async (data) => {
58
+ const token = await getAuthToken();
59
+ const clients = createAdminRpcClients(baseURL);
60
+ const res = await clients.dispatchRiders[':id'].$patch({ json: data, param: { id: riderId } }, authHeaders(token));
61
+ if (!res.ok)
62
+ throw new Error(`Failed to update dispatch rider: ${res.statusText}`);
63
+ return res.json();
64
+ },
65
+ onSuccess: (...args) => {
66
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.dispatchRiders.all });
67
+ options?.onSuccess?.(...args);
68
+ },
69
+ });
70
+ }
71
+ /**
72
+ * Hook to delete a dispatch rider using admin RPC
73
+ */
74
+ export function useDeleteDispatchRider(riderId, options) {
75
+ const { baseURL, getAuthToken } = useApiConfig();
76
+ const queryClient = useQueryClient();
77
+ return useMutation({
78
+ ...options,
79
+ mutationFn: async () => {
80
+ const token = await getAuthToken();
81
+ const clients = createAdminRpcClients(baseURL);
82
+ const res = await clients.dispatchRiders[':id'].$delete({ param: { id: riderId } }, authHeaders(token));
83
+ if (!res.ok)
84
+ throw new Error(`Failed to delete dispatch rider: ${res.statusText}`);
85
+ return res.json();
86
+ },
87
+ onSuccess: (...args) => {
88
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.dispatchRiders.all });
89
+ options?.onSuccess?.(...args);
90
+ },
91
+ });
92
+ }
@@ -16,3 +16,4 @@ export * from './warehouses';
16
16
  export * from './abandoned-carts';
17
17
  export * from './media';
18
18
  export * from './sales';
19
+ export * from './dispatch-riders';
@@ -16,3 +16,4 @@ export * from './warehouses';
16
16
  export * from './abandoned-carts';
17
17
  export * from './media';
18
18
  export * from './sales';
19
+ export * from './dispatch-riders';