@instockng/api-client 1.0.25 → 1.0.26
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.
- package/dist/fetchers/brands.js +2 -2
- package/dist/fetchers/carts.d.ts +0 -1
- package/dist/fetchers/carts.js +11 -12
- package/dist/fetchers/delivery-zones.js +2 -2
- package/dist/fetchers/orders.js +4 -4
- package/dist/fetchers/products.js +4 -4
- package/dist/provider.d.ts +0 -1
- package/dist/provider.js +1 -2
- package/package.json +1 -1
package/dist/fetchers/brands.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
6
|
*/
|
|
7
7
|
import { createRpcClients } from '../rpc-client';
|
|
8
|
-
|
|
8
|
+
const API_URL = 'https://oms-api.instock.com.ng';
|
|
9
9
|
/**
|
|
10
10
|
* Fetch brand configuration by slug
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@ import { API_BASE_URL } from '../provider';
|
|
|
13
13
|
* @returns Brand with metaPixelId and other configuration
|
|
14
14
|
*/
|
|
15
15
|
export async function fetchBrandBySlug(slug) {
|
|
16
|
-
const clients = createRpcClients(
|
|
16
|
+
const clients = createRpcClients(API_URL);
|
|
17
17
|
const res = await clients.brands[':slug'].$get({
|
|
18
18
|
param: { slug },
|
|
19
19
|
});
|
package/dist/fetchers/carts.d.ts
CHANGED
package/dist/fetchers/carts.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cart fetcher functions
|
|
3
|
-
*
|
|
4
3
|
* These are the actual data-fetching functions used by hooks.
|
|
5
4
|
* They can also be imported directly in Server Components.
|
|
6
5
|
*/
|
|
7
6
|
import { createRpcClients } from '../rpc-client';
|
|
8
|
-
|
|
7
|
+
const API_URL = 'https://oms-api.instock.com.ng';
|
|
9
8
|
/**
|
|
10
9
|
* Fetch a cart by ID
|
|
11
10
|
*
|
|
@@ -13,7 +12,7 @@ import { API_BASE_URL } from '../provider';
|
|
|
13
12
|
* @returns Cart with items, brand, and delivery zone
|
|
14
13
|
*/
|
|
15
14
|
export async function fetchCart(cartId) {
|
|
16
|
-
const clients = createRpcClients(
|
|
15
|
+
const clients = createRpcClients(API_URL);
|
|
17
16
|
const res = await clients.carts[':id'].$get({
|
|
18
17
|
param: { id: cartId },
|
|
19
18
|
});
|
|
@@ -29,7 +28,7 @@ export async function fetchCart(cartId) {
|
|
|
29
28
|
* @returns Newly created cart
|
|
30
29
|
*/
|
|
31
30
|
export async function createCart(brandSlug) {
|
|
32
|
-
const clients = createRpcClients(
|
|
31
|
+
const clients = createRpcClients(API_URL);
|
|
33
32
|
const res = await clients.carts.index.$post({
|
|
34
33
|
json: { brandSlug },
|
|
35
34
|
});
|
|
@@ -46,7 +45,7 @@ export async function createCart(brandSlug) {
|
|
|
46
45
|
* @returns Updated cart
|
|
47
46
|
*/
|
|
48
47
|
export async function updateCart(cartId, data) {
|
|
49
|
-
const clients = createRpcClients(
|
|
48
|
+
const clients = createRpcClients(API_URL);
|
|
50
49
|
const res = await clients.carts[':id'].$patch({
|
|
51
50
|
param: { id: cartId },
|
|
52
51
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -70,7 +69,7 @@ export async function updateCart(cartId, data) {
|
|
|
70
69
|
* @returns Updated cart
|
|
71
70
|
*/
|
|
72
71
|
export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid) {
|
|
73
|
-
const clients = createRpcClients(
|
|
72
|
+
const clients = createRpcClients(API_URL);
|
|
74
73
|
const res = await clients.carts[':id'].items.$post({
|
|
75
74
|
param: { id: cartId },
|
|
76
75
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -90,7 +89,7 @@ export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid)
|
|
|
90
89
|
* @returns Updated cart
|
|
91
90
|
*/
|
|
92
91
|
export async function updateCartItem(cartId, itemId, quantity) {
|
|
93
|
-
const clients = createRpcClients(
|
|
92
|
+
const clients = createRpcClients(API_URL);
|
|
94
93
|
const res = await clients.carts[':id'].items[':itemId'].$patch({
|
|
95
94
|
param: { id: cartId, itemId },
|
|
96
95
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -109,7 +108,7 @@ export async function updateCartItem(cartId, itemId, quantity) {
|
|
|
109
108
|
* @returns Updated cart
|
|
110
109
|
*/
|
|
111
110
|
export async function removeCartItem(cartId, itemId) {
|
|
112
|
-
const clients = createRpcClients(
|
|
111
|
+
const clients = createRpcClients(API_URL);
|
|
113
112
|
const res = await clients.carts[':id'].items[':itemId'].$delete({
|
|
114
113
|
param: { id: cartId, itemId },
|
|
115
114
|
});
|
|
@@ -126,7 +125,7 @@ export async function removeCartItem(cartId, itemId) {
|
|
|
126
125
|
* @returns Updated cart
|
|
127
126
|
*/
|
|
128
127
|
export async function applyDiscount(cartId, code) {
|
|
129
|
-
const clients = createRpcClients(
|
|
128
|
+
const clients = createRpcClients(API_URL);
|
|
130
129
|
const res = await clients.carts[':id']['apply-discount'].$post({
|
|
131
130
|
param: { id: cartId },
|
|
132
131
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -144,7 +143,7 @@ export async function applyDiscount(cartId, code) {
|
|
|
144
143
|
* @returns Updated cart
|
|
145
144
|
*/
|
|
146
145
|
export async function removeDiscount(cartId) {
|
|
147
|
-
const clients = createRpcClients(
|
|
146
|
+
const clients = createRpcClients(API_URL);
|
|
148
147
|
const res = await clients.carts[':id']['remove-discount'].$post({
|
|
149
148
|
param: { id: cartId },
|
|
150
149
|
});
|
|
@@ -161,7 +160,7 @@ export async function removeDiscount(cartId) {
|
|
|
161
160
|
* @returns Created order
|
|
162
161
|
*/
|
|
163
162
|
export async function checkoutCart(cartId, checkoutData) {
|
|
164
|
-
const clients = createRpcClients(
|
|
163
|
+
const clients = createRpcClients(API_URL);
|
|
165
164
|
const res = await clients.carts[':id'].checkout.$post({
|
|
166
165
|
param: { id: cartId },
|
|
167
166
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -180,7 +179,7 @@ export async function checkoutCart(cartId, checkoutData) {
|
|
|
180
179
|
* @returns Array of recommended products from the same brand
|
|
181
180
|
*/
|
|
182
181
|
export async function fetchCartRecommendations(cartId, limit) {
|
|
183
|
-
const clients = createRpcClients(
|
|
182
|
+
const clients = createRpcClients(API_URL);
|
|
184
183
|
const res = await clients.carts[':id'].recommendations.$get({
|
|
185
184
|
param: { id: cartId },
|
|
186
185
|
// @ts-ignore - Hono RPC type inference issue with query parameters
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
6
|
*/
|
|
7
7
|
import { createRpcClients } from '../rpc-client';
|
|
8
|
-
|
|
8
|
+
const API_URL = 'https://oms-api.instock.com.ng';
|
|
9
9
|
/**
|
|
10
10
|
* Fetch delivery zones
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@ import { API_BASE_URL } from '../provider';
|
|
|
13
13
|
* @returns List of delivery zones with states
|
|
14
14
|
*/
|
|
15
15
|
export async function fetchDeliveryZones(brandId) {
|
|
16
|
-
const clients = createRpcClients(
|
|
16
|
+
const clients = createRpcClients(API_URL);
|
|
17
17
|
const res = await clients.deliveryZones.index.$get({
|
|
18
18
|
query: brandId ? { brandId } : {},
|
|
19
19
|
});
|
package/dist/fetchers/orders.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
6
|
*/
|
|
7
7
|
import { createRpcClients } from '../rpc-client';
|
|
8
|
-
|
|
8
|
+
const API_URL = 'https://oms-api.instock.com.ng';
|
|
9
9
|
/**
|
|
10
10
|
* Fetch an order by ID and token
|
|
11
11
|
*
|
|
@@ -14,7 +14,7 @@ import { API_BASE_URL } from '../provider';
|
|
|
14
14
|
* @returns Order with items, delivery zone, and brand
|
|
15
15
|
*/
|
|
16
16
|
export async function fetchOrder(orderId, token) {
|
|
17
|
-
const clients = createRpcClients(
|
|
17
|
+
const clients = createRpcClients(API_URL);
|
|
18
18
|
const res = await clients.orders[':id'][':token'].$get({
|
|
19
19
|
param: { id: orderId, token },
|
|
20
20
|
});
|
|
@@ -31,7 +31,7 @@ export async function fetchOrder(orderId, token) {
|
|
|
31
31
|
* @returns Confirmed order
|
|
32
32
|
*/
|
|
33
33
|
export async function confirmOrder(orderId, token) {
|
|
34
|
-
const clients = createRpcClients(
|
|
34
|
+
const clients = createRpcClients(API_URL);
|
|
35
35
|
const res = await clients.orders.confirm.$post({
|
|
36
36
|
json: { orderId, token },
|
|
37
37
|
});
|
|
@@ -49,7 +49,7 @@ export async function confirmOrder(orderId, token) {
|
|
|
49
49
|
* @returns Array of recommended products
|
|
50
50
|
*/
|
|
51
51
|
export async function fetchOrderRecommendations(orderId, token, limit = 4) {
|
|
52
|
-
const clients = createRpcClients(
|
|
52
|
+
const clients = createRpcClients(API_URL);
|
|
53
53
|
const res = await clients.orders[':id'][':token'].recommendations.$get({
|
|
54
54
|
param: { id: orderId, token },
|
|
55
55
|
// @ts-ignore - Hono RPC type inference issue with query parameters
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
6
|
*/
|
|
7
7
|
import { createRpcClients } from '../rpc-client';
|
|
8
|
-
|
|
8
|
+
const API_URL = 'https://oms-api.instock.com.ng';
|
|
9
9
|
/**
|
|
10
10
|
* Fetch products by brand ID
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@ import { API_BASE_URL } from '../provider';
|
|
|
13
13
|
* @returns Products for the brand with variants and availability
|
|
14
14
|
*/
|
|
15
15
|
export async function fetchProductsByBrand(brandId) {
|
|
16
|
-
const clients = createRpcClients(
|
|
16
|
+
const clients = createRpcClients(API_URL);
|
|
17
17
|
const res = await clients.products[':brandId'].$get({
|
|
18
18
|
param: { brandId },
|
|
19
19
|
});
|
|
@@ -29,7 +29,7 @@ export async function fetchProductsByBrand(brandId) {
|
|
|
29
29
|
* @returns Product with variants and availability
|
|
30
30
|
*/
|
|
31
31
|
export async function fetchProductBySlug(slug) {
|
|
32
|
-
const clients = createRpcClients(
|
|
32
|
+
const clients = createRpcClients(API_URL);
|
|
33
33
|
const res = await clients.products.product[':slug'].$get({
|
|
34
34
|
param: { slug },
|
|
35
35
|
});
|
|
@@ -46,7 +46,7 @@ export async function fetchProductBySlug(slug) {
|
|
|
46
46
|
* @returns List of add-on products
|
|
47
47
|
*/
|
|
48
48
|
export async function fetchProductAddons(slug, limit) {
|
|
49
|
-
const clients = createRpcClients(
|
|
49
|
+
const clients = createRpcClients(API_URL);
|
|
50
50
|
const res = await clients.productAddons[':slug'].$get({
|
|
51
51
|
param: { slug },
|
|
52
52
|
query: limit !== undefined ? { limit: String(limit) } : {},
|
package/dist/provider.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ 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";
|
|
20
19
|
/**
|
|
21
20
|
* Provider component that initializes the API client and React Query
|
|
22
21
|
*
|
package/dist/provider.js
CHANGED
|
@@ -6,7 +6,6 @@ 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';
|
|
10
9
|
/**
|
|
11
10
|
* Provider component that initializes the API client and React Query
|
|
12
11
|
*
|
|
@@ -19,7 +18,7 @@ export const API_BASE_URL = 'https://oms-api.instock.com.ng';
|
|
|
19
18
|
* </ApiClientProvider>
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
|
-
export function ApiClientProvider({ children, baseURL =
|
|
21
|
+
export function ApiClientProvider({ children, baseURL = 'https://oms-api.instock.com.ng', getAuthToken, onError, queryClient: externalQueryClient }) {
|
|
23
22
|
// Initialize client synchronously on first render
|
|
24
23
|
const config = {
|
|
25
24
|
baseURL,
|