@instockng/api-client 1.0.24 → 1.0.25

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.
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  /**
10
8
  * Fetch brand configuration by slug
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch brand configuration by slug
13
11
  *
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
15
13
  * @returns Brand with metaPixelId and other configuration
16
14
  */
17
15
  export async function fetchBrandBySlug(slug) {
18
- const clients = createRpcClients(API_URL);
16
+ const clients = createRpcClients(API_BASE_URL);
19
17
  const res = await clients.brands[':slug'].$get({
20
18
  param: { slug },
21
19
  });
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  /**
10
8
  * Fetch a cart by ID
@@ -5473,6 +5471,11 @@ export declare function fetchCartRecommendations(cartId: string, limit: number):
5473
5471
  flat?: boolean;
5474
5472
  };
5475
5473
  };
5474
+ createdAt: string;
5475
+ updatedAt: string;
5476
+ deletedAt: string;
5477
+ brandId: string;
5478
+ isActive: boolean;
5476
5479
  }[] | {
5477
5480
  error: {
5478
5481
  code: string;
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch a cart by ID
13
11
  *
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
15
13
  * @returns Cart with items, brand, and delivery zone
16
14
  */
17
15
  export async function fetchCart(cartId) {
18
- const clients = createRpcClients(API_URL);
16
+ const clients = createRpcClients(API_BASE_URL);
19
17
  const res = await clients.carts[':id'].$get({
20
18
  param: { id: cartId },
21
19
  });
@@ -31,7 +29,7 @@ export async function fetchCart(cartId) {
31
29
  * @returns Newly created cart
32
30
  */
33
31
  export async function createCart(brandSlug) {
34
- const clients = createRpcClients(API_URL);
32
+ const clients = createRpcClients(API_BASE_URL);
35
33
  const res = await clients.carts.index.$post({
36
34
  json: { brandSlug },
37
35
  });
@@ -48,7 +46,7 @@ export async function createCart(brandSlug) {
48
46
  * @returns Updated cart
49
47
  */
50
48
  export async function updateCart(cartId, data) {
51
- const clients = createRpcClients(API_URL);
49
+ const clients = createRpcClients(API_BASE_URL);
52
50
  const res = await clients.carts[':id'].$patch({
53
51
  param: { id: cartId },
54
52
  // @ts-expect-error - Hono RPC type inference issue
@@ -72,7 +70,7 @@ export async function updateCart(cartId, data) {
72
70
  * @returns Updated cart
73
71
  */
74
72
  export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid) {
75
- const clients = createRpcClients(API_URL);
73
+ const clients = createRpcClients(API_BASE_URL);
76
74
  const res = await clients.carts[':id'].items.$post({
77
75
  param: { id: cartId },
78
76
  // @ts-expect-error - Hono RPC type inference issue
@@ -92,7 +90,7 @@ export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid)
92
90
  * @returns Updated cart
93
91
  */
94
92
  export async function updateCartItem(cartId, itemId, quantity) {
95
- const clients = createRpcClients(API_URL);
93
+ const clients = createRpcClients(API_BASE_URL);
96
94
  const res = await clients.carts[':id'].items[':itemId'].$patch({
97
95
  param: { id: cartId, itemId },
98
96
  // @ts-expect-error - Hono RPC type inference issue
@@ -111,7 +109,7 @@ export async function updateCartItem(cartId, itemId, quantity) {
111
109
  * @returns Updated cart
112
110
  */
113
111
  export async function removeCartItem(cartId, itemId) {
114
- const clients = createRpcClients(API_URL);
112
+ const clients = createRpcClients(API_BASE_URL);
115
113
  const res = await clients.carts[':id'].items[':itemId'].$delete({
116
114
  param: { id: cartId, itemId },
117
115
  });
@@ -128,7 +126,7 @@ export async function removeCartItem(cartId, itemId) {
128
126
  * @returns Updated cart
129
127
  */
130
128
  export async function applyDiscount(cartId, code) {
131
- const clients = createRpcClients(API_URL);
129
+ const clients = createRpcClients(API_BASE_URL);
132
130
  const res = await clients.carts[':id']['apply-discount'].$post({
133
131
  param: { id: cartId },
134
132
  // @ts-expect-error - Hono RPC type inference issue
@@ -146,7 +144,7 @@ export async function applyDiscount(cartId, code) {
146
144
  * @returns Updated cart
147
145
  */
148
146
  export async function removeDiscount(cartId) {
149
- const clients = createRpcClients(API_URL);
147
+ const clients = createRpcClients(API_BASE_URL);
150
148
  const res = await clients.carts[':id']['remove-discount'].$post({
151
149
  param: { id: cartId },
152
150
  });
@@ -163,7 +161,7 @@ export async function removeDiscount(cartId) {
163
161
  * @returns Created order
164
162
  */
165
163
  export async function checkoutCart(cartId, checkoutData) {
166
- const clients = createRpcClients(API_URL);
164
+ const clients = createRpcClients(API_BASE_URL);
167
165
  const res = await clients.carts[':id'].checkout.$post({
168
166
  param: { id: cartId },
169
167
  // @ts-expect-error - Hono RPC type inference issue
@@ -182,7 +180,7 @@ export async function checkoutCart(cartId, checkoutData) {
182
180
  * @returns Array of recommended products from the same brand
183
181
  */
184
182
  export async function fetchCartRecommendations(cartId, limit) {
185
- const clients = createRpcClients(API_URL);
183
+ const clients = createRpcClients(API_BASE_URL);
186
184
  const res = await clients.carts[':id'].recommendations.$get({
187
185
  param: { id: cartId },
188
186
  // @ts-ignore - Hono RPC type inference issue with query parameters
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  /**
10
8
  * Fetch delivery zones
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch delivery zones
13
11
  *
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
15
13
  * @returns List of delivery zones with states
16
14
  */
17
15
  export async function fetchDeliveryZones(brandId) {
18
- const clients = createRpcClients(API_URL);
16
+ const clients = createRpcClients(API_BASE_URL);
19
17
  const res = await clients.deliveryZones.index.$get({
20
18
  query: brandId ? { brandId } : {},
21
19
  });
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  /**
10
8
  * Fetch an order by ID and token
@@ -1612,4 +1610,9 @@ export declare function fetchOrderRecommendations(orderId: string, token: string
1612
1610
  flat?: boolean;
1613
1611
  };
1614
1612
  };
1613
+ createdAt: string;
1614
+ updatedAt: string;
1615
+ deletedAt: string;
1616
+ brandId: string;
1617
+ isActive: boolean;
1615
1618
  }[]>;
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch an order by ID and token
13
11
  *
@@ -16,7 +14,7 @@ const API_URL = 'https://oms-api.instock.ng';
16
14
  * @returns Order with items, delivery zone, and brand
17
15
  */
18
16
  export async function fetchOrder(orderId, token) {
19
- const clients = createRpcClients(API_URL);
17
+ const clients = createRpcClients(API_BASE_URL);
20
18
  const res = await clients.orders[':id'][':token'].$get({
21
19
  param: { id: orderId, token },
22
20
  });
@@ -33,7 +31,7 @@ export async function fetchOrder(orderId, token) {
33
31
  * @returns Confirmed order
34
32
  */
35
33
  export async function confirmOrder(orderId, token) {
36
- const clients = createRpcClients(API_URL);
34
+ const clients = createRpcClients(API_BASE_URL);
37
35
  const res = await clients.orders.confirm.$post({
38
36
  json: { orderId, token },
39
37
  });
@@ -51,7 +49,7 @@ export async function confirmOrder(orderId, token) {
51
49
  * @returns Array of recommended products
52
50
  */
53
51
  export async function fetchOrderRecommendations(orderId, token, limit = 4) {
54
- const clients = createRpcClients(API_URL);
52
+ const clients = createRpcClients(API_BASE_URL);
55
53
  const res = await clients.orders[':id'][':token'].recommendations.$get({
56
54
  param: { id: orderId, token },
57
55
  // @ts-ignore - Hono RPC type inference issue with query parameters
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  /**
10
8
  * Fetch products by brand ID
@@ -484,6 +482,11 @@ export declare function fetchProductsByBrand(brandId: string): Promise<{
484
482
  flat?: boolean;
485
483
  };
486
484
  };
485
+ createdAt: string;
486
+ updatedAt: string;
487
+ deletedAt: string;
488
+ brandId: string;
489
+ isActive: boolean;
487
490
  }[]>;
488
491
  /**
489
492
  * Fetch a single product by slug
@@ -963,6 +966,11 @@ export declare function fetchProductBySlug(slug: string): Promise<{
963
966
  flat?: boolean;
964
967
  };
965
968
  };
969
+ createdAt: string;
970
+ updatedAt: string;
971
+ deletedAt: string;
972
+ brandId: string;
973
+ isActive: boolean;
966
974
  }>;
967
975
  /**
968
976
  * Fetch product add-ons
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch products by brand ID
13
11
  *
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
15
13
  * @returns Products for the brand with variants and availability
16
14
  */
17
15
  export async function fetchProductsByBrand(brandId) {
18
- const clients = createRpcClients(API_URL);
16
+ const clients = createRpcClients(API_BASE_URL);
19
17
  const res = await clients.products[':brandId'].$get({
20
18
  param: { brandId },
21
19
  });
@@ -31,7 +29,7 @@ export async function fetchProductsByBrand(brandId) {
31
29
  * @returns Product with variants and availability
32
30
  */
33
31
  export async function fetchProductBySlug(slug) {
34
- const clients = createRpcClients(API_URL);
32
+ const clients = createRpcClients(API_BASE_URL);
35
33
  const res = await clients.products.product[':slug'].$get({
36
34
  param: { slug },
37
35
  });
@@ -48,7 +46,7 @@ export async function fetchProductBySlug(slug) {
48
46
  * @returns List of add-on products
49
47
  */
50
48
  export async function fetchProductAddons(slug, limit) {
51
- const clients = createRpcClients(API_URL);
49
+ const clients = createRpcClients(API_BASE_URL);
52
50
  const res = await clients.productAddons[':slug'].$get({
53
51
  param: { slug },
54
52
  query: limit !== undefined ? { limit: String(limit) } : {},
@@ -475,6 +475,11 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
475
475
  flat?: boolean;
476
476
  };
477
477
  };
478
+ createdAt: string;
479
+ updatedAt: string;
480
+ deletedAt: string;
481
+ brandId: string;
482
+ isActive: boolean;
478
483
  }[], Error>;
479
484
  export declare function useGetProduct(productId: string, options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['products'][':id']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
480
485
  id: string;
@@ -948,6 +953,11 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
948
953
  flat?: boolean;
949
954
  };
950
955
  };
956
+ createdAt: string;
957
+ updatedAt: string;
958
+ deletedAt: string;
959
+ brandId: string;
960
+ isActive: boolean;
951
961
  }, Error>;
952
962
  export declare function useCreateProduct(options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
953
963
  export declare function useUpdateProduct(productId: string, options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
@@ -5553,4 +5553,9 @@ export declare function useGetCartRecommendations(cartId: string | null | undefi
5553
5553
  flat?: boolean;
5554
5554
  };
5555
5555
  };
5556
+ createdAt: string;
5557
+ updatedAt: string;
5558
+ deletedAt: string;
5559
+ brandId: string;
5560
+ isActive: boolean;
5556
5561
  }[], Error>;
@@ -1637,4 +1637,9 @@ export declare function useGetOrderRecommendations(orderId: string | null | unde
1637
1637
  flat?: boolean;
1638
1638
  };
1639
1639
  };
1640
+ createdAt: string;
1641
+ updatedAt: string;
1642
+ deletedAt: string;
1643
+ brandId: string;
1644
+ isActive: boolean;
1640
1645
  }[], Error>;
@@ -490,6 +490,11 @@ export declare function useGetProducts(brandId: string, options?: Omit<UseQueryO
490
490
  flat?: boolean;
491
491
  };
492
492
  };
493
+ createdAt: string;
494
+ updatedAt: string;
495
+ deletedAt: string;
496
+ brandId: string;
497
+ isActive: boolean;
493
498
  }[], Error>;
494
499
  /**
495
500
  * Hook to get a single product by slug using RPC
@@ -975,6 +980,11 @@ export declare function useGetProduct(slug: string, options?: Omit<UseQueryOptio
975
980
  flat?: boolean;
976
981
  };
977
982
  };
983
+ createdAt: string;
984
+ updatedAt: string;
985
+ deletedAt: string;
986
+ brandId: string;
987
+ isActive: boolean;
978
988
  }, Error>;
979
989
  /**
980
990
  * Hook to get product add-ons
@@ -16,6 +16,7 @@ export interface ApiClientProviderProps {
16
16
  onError?: (error: AxiosError) => void;
17
17
  queryClient?: QueryClient;
18
18
  }
19
+ export declare const API_BASE_URL = "https://oms-api.instock.com.ng";
19
20
  /**
20
21
  * Provider component that initializes the API client and React Query
21
22
  *
package/dist/provider.js CHANGED
@@ -6,6 +6,7 @@ import { createContext, useContext, useEffect, useMemo } from 'react';
6
6
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
7
7
  import { initializeApiClient } from './client';
8
8
  const ApiClientContext = createContext(null);
9
+ export const API_BASE_URL = 'https://oms-api.instock.com.ng';
9
10
  /**
10
11
  * Provider component that initializes the API client and React Query
11
12
  *
@@ -18,7 +19,7 @@ const ApiClientContext = createContext(null);
18
19
  * </ApiClientProvider>
19
20
  * ```
20
21
  */
21
- export function ApiClientProvider({ children, baseURL = 'https://oms-api.instock.ng', getAuthToken, onError, queryClient: externalQueryClient }) {
22
+ export function ApiClientProvider({ children, baseURL = API_BASE_URL, getAuthToken, onError, queryClient: externalQueryClient }) {
22
23
  // Initialize client synchronously on first render
23
24
  const config = {
24
25
  baseURL,
@@ -6379,6 +6379,11 @@ export declare function createRpcClients(baseURL: string): {
6379
6379
  flat?: boolean;
6380
6380
  };
6381
6381
  };
6382
+ createdAt: string;
6383
+ updatedAt: string;
6384
+ deletedAt: string;
6385
+ brandId: string;
6386
+ isActive: boolean;
6382
6387
  }[];
6383
6388
  outputFormat: "json";
6384
6389
  status: 200;
@@ -8112,6 +8117,11 @@ export declare function createRpcClients(baseURL: string): {
8112
8117
  flat?: boolean;
8113
8118
  };
8114
8119
  };
8120
+ createdAt: string;
8121
+ updatedAt: string;
8122
+ deletedAt: string;
8123
+ brandId: string;
8124
+ isActive: boolean;
8115
8125
  }[];
8116
8126
  outputFormat: "json";
8117
8127
  status: 200;
@@ -8631,6 +8641,11 @@ export declare function createRpcClients(baseURL: string): {
8631
8641
  flat?: boolean;
8632
8642
  };
8633
8643
  };
8644
+ createdAt: string;
8645
+ updatedAt: string;
8646
+ deletedAt: string;
8647
+ brandId: string;
8648
+ isActive: boolean;
8634
8649
  };
8635
8650
  outputFormat: "json";
8636
8651
  status: 200;
@@ -9131,6 +9146,11 @@ export declare function createRpcClients(baseURL: string): {
9131
9146
  flat?: boolean;
9132
9147
  };
9133
9148
  };
9149
+ createdAt: string;
9150
+ updatedAt: string;
9151
+ deletedAt: string;
9152
+ brandId: string;
9153
+ isActive: boolean;
9134
9154
  }[];
9135
9155
  outputFormat: "json";
9136
9156
  status: 200;
@@ -13823,6 +13843,11 @@ export declare function createAdminRpcClients(baseURL: string): {
13823
13843
  flat?: boolean;
13824
13844
  };
13825
13845
  };
13846
+ createdAt: string;
13847
+ updatedAt: string;
13848
+ deletedAt: string;
13849
+ brandId: string;
13850
+ isActive: boolean;
13826
13851
  }[];
13827
13852
  outputFormat: "json";
13828
13853
  status: import("hono/utils/http-status").ContentfulStatusCode;
@@ -14312,6 +14337,11 @@ export declare function createAdminRpcClients(baseURL: string): {
14312
14337
  flat?: boolean;
14313
14338
  };
14314
14339
  };
14340
+ createdAt: string;
14341
+ updatedAt: string;
14342
+ deletedAt: string;
14343
+ brandId: string;
14344
+ isActive: boolean;
14315
14345
  };
14316
14346
  outputFormat: "json";
14317
14347
  status: 201;
@@ -14822,6 +14852,11 @@ export declare function createAdminRpcClients(baseURL: string): {
14822
14852
  flat?: boolean;
14823
14853
  };
14824
14854
  };
14855
+ createdAt: string;
14856
+ updatedAt: string;
14857
+ deletedAt: string;
14858
+ brandId: string;
14859
+ isActive: boolean;
14825
14860
  };
14826
14861
  outputFormat: "json";
14827
14862
  status: import("hono/utils/http-status").ContentfulStatusCode;
@@ -15319,6 +15354,11 @@ export declare function createAdminRpcClients(baseURL: string): {
15319
15354
  flat?: boolean;
15320
15355
  };
15321
15356
  };
15357
+ createdAt: string;
15358
+ updatedAt: string;
15359
+ deletedAt: string;
15360
+ brandId: string;
15361
+ isActive: boolean;
15322
15362
  };
15323
15363
  outputFormat: "json";
15324
15364
  status: import("hono/utils/http-status").ContentfulStatusCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instockng/api-client",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "React Query hooks for OMS API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",