@instockng/api-client 1.0.26 → 1.0.27
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/carts.d.ts +17 -0
- package/dist/fetchers/carts.js +19 -0
- package/dist/hooks/public/carts.d.ts +23 -1
- package/dist/hooks/public/carts.js +19 -1
- package/dist/hooks/public/index.d.ts +2 -2
- package/dist/hooks/public/index.js +2 -2
- package/dist/rpc-client.d.ts +45 -0
- package/package.json +1 -1
package/dist/fetchers/carts.d.ts
CHANGED
|
@@ -4991,6 +4991,23 @@ export declare function checkoutCart(cartId: string, checkoutData: {
|
|
|
4991
4991
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
4992
4992
|
userActionToken: string;
|
|
4993
4993
|
}>;
|
|
4994
|
+
/**
|
|
4995
|
+
* Initiate checkout tracking
|
|
4996
|
+
*
|
|
4997
|
+
* @param cartId - Cart UUID
|
|
4998
|
+
* @param data - Checking out user data and attribution cookies
|
|
4999
|
+
* @returns Success status
|
|
5000
|
+
*/
|
|
5001
|
+
export declare function initiateCheckout(cartId: string, data: {
|
|
5002
|
+
email?: string | null;
|
|
5003
|
+
phone?: string | null;
|
|
5004
|
+
fbc?: string;
|
|
5005
|
+
fbp?: string;
|
|
5006
|
+
ttp?: string;
|
|
5007
|
+
ttclid?: string;
|
|
5008
|
+
}): Promise<{
|
|
5009
|
+
success: true;
|
|
5010
|
+
}>;
|
|
4994
5011
|
/**
|
|
4995
5012
|
* Fetch recommended products for a cart
|
|
4996
5013
|
*
|
package/dist/fetchers/carts.js
CHANGED
|
@@ -171,6 +171,25 @@ export async function checkoutCart(cartId, checkoutData) {
|
|
|
171
171
|
}
|
|
172
172
|
return res.json();
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Initiate checkout tracking
|
|
176
|
+
*
|
|
177
|
+
* @param cartId - Cart UUID
|
|
178
|
+
* @param data - Checking out user data and attribution cookies
|
|
179
|
+
* @returns Success status
|
|
180
|
+
*/
|
|
181
|
+
export async function initiateCheckout(cartId, data) {
|
|
182
|
+
const clients = createRpcClients(API_URL);
|
|
183
|
+
const res = await clients.carts[':id']['initiate-checkout'].$post({
|
|
184
|
+
param: { id: cartId },
|
|
185
|
+
// @ts-expect-error - Hono RPC type inference issue
|
|
186
|
+
json: data,
|
|
187
|
+
});
|
|
188
|
+
if (!res.ok) {
|
|
189
|
+
throw new Error(`Failed to initiate checkout intent: ${res.statusText}`);
|
|
190
|
+
}
|
|
191
|
+
return res.json();
|
|
192
|
+
}
|
|
174
193
|
/**
|
|
175
194
|
* Fetch recommended products for a cart
|
|
176
195
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* providing end-to-end type safety without code generation.
|
|
6
6
|
*/
|
|
7
7
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
8
|
-
import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, fetchCartRecommendations } from '../../fetchers/carts';
|
|
8
|
+
import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, initiateCheckout, fetchCartRecommendations } from '../../fetchers/carts';
|
|
9
9
|
/**
|
|
10
10
|
* Hook to get cart by ID using RPC
|
|
11
11
|
*
|
|
@@ -5068,6 +5068,28 @@ export declare function useCheckoutCart(cartId: string, options?: UseMutationOpt
|
|
|
5068
5068
|
ttp?: string;
|
|
5069
5069
|
ttclid?: string;
|
|
5070
5070
|
}, unknown>;
|
|
5071
|
+
/**
|
|
5072
|
+
* Hook to initiate checkout tracking using RPC
|
|
5073
|
+
*
|
|
5074
|
+
* @param cartId - Cart UUID
|
|
5075
|
+
* @param options - React Query mutation options
|
|
5076
|
+
*
|
|
5077
|
+
* @example
|
|
5078
|
+
* ```tsx
|
|
5079
|
+
* const initiateCheckout = useInitiateCheckout('cart-123');
|
|
5080
|
+
* initiateCheckout.mutate({ email: 'user@example.com' });
|
|
5081
|
+
* ```
|
|
5082
|
+
*/
|
|
5083
|
+
export declare function useInitiateCheckout(cartId: string, options?: UseMutationOptions<Awaited<ReturnType<typeof initiateCheckout>>, Error, Parameters<typeof initiateCheckout>[1]>): import("@tanstack/react-query").UseMutationResult<{
|
|
5084
|
+
success: true;
|
|
5085
|
+
}, Error, {
|
|
5086
|
+
email?: string | null;
|
|
5087
|
+
phone?: string | null;
|
|
5088
|
+
fbc?: string;
|
|
5089
|
+
fbp?: string;
|
|
5090
|
+
ttp?: string;
|
|
5091
|
+
ttclid?: string;
|
|
5092
|
+
}, unknown>;
|
|
5071
5093
|
/**
|
|
5072
5094
|
* Hook to get recommended products for a cart using RPC
|
|
5073
5095
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
8
8
|
import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
9
9
|
import { queryKeys } from '../../utils/query-keys';
|
|
10
|
-
import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, fetchCartRecommendations, } from '../../fetchers/carts';
|
|
10
|
+
import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, initiateCheckout, fetchCartRecommendations, } from '../../fetchers/carts';
|
|
11
11
|
/**
|
|
12
12
|
* Hook to get cart by ID using RPC
|
|
13
13
|
*
|
|
@@ -217,6 +217,24 @@ export function useCheckoutCart(cartId, options) {
|
|
|
217
217
|
...options,
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Hook to initiate checkout tracking using RPC
|
|
222
|
+
*
|
|
223
|
+
* @param cartId - Cart UUID
|
|
224
|
+
* @param options - React Query mutation options
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```tsx
|
|
228
|
+
* const initiateCheckout = useInitiateCheckout('cart-123');
|
|
229
|
+
* initiateCheckout.mutate({ email: 'user@example.com' });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export function useInitiateCheckout(cartId, options) {
|
|
233
|
+
return useMutation({
|
|
234
|
+
mutationFn: (data) => initiateCheckout(cartId, data),
|
|
235
|
+
...options,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
220
238
|
/**
|
|
221
239
|
* Hook to get recommended products for a cart using RPC
|
|
222
240
|
*
|
package/dist/rpc-client.d.ts
CHANGED
|
@@ -4696,6 +4696,51 @@ export declare function createRpcClients(baseURL: string): {
|
|
|
4696
4696
|
}>;
|
|
4697
4697
|
};
|
|
4698
4698
|
};
|
|
4699
|
+
} & {
|
|
4700
|
+
":id": {
|
|
4701
|
+
"initiate-checkout": import("hono/client").ClientRequest<{
|
|
4702
|
+
$post: {
|
|
4703
|
+
input: {
|
|
4704
|
+
param: {
|
|
4705
|
+
id: string;
|
|
4706
|
+
};
|
|
4707
|
+
};
|
|
4708
|
+
output: {
|
|
4709
|
+
error: {
|
|
4710
|
+
code: string;
|
|
4711
|
+
message: string;
|
|
4712
|
+
};
|
|
4713
|
+
};
|
|
4714
|
+
outputFormat: "json";
|
|
4715
|
+
status: 404;
|
|
4716
|
+
} | {
|
|
4717
|
+
input: {
|
|
4718
|
+
param: {
|
|
4719
|
+
id: string;
|
|
4720
|
+
};
|
|
4721
|
+
};
|
|
4722
|
+
output: {
|
|
4723
|
+
success: true;
|
|
4724
|
+
};
|
|
4725
|
+
outputFormat: "json";
|
|
4726
|
+
status: 200;
|
|
4727
|
+
} | {
|
|
4728
|
+
input: {
|
|
4729
|
+
param: {
|
|
4730
|
+
id: string;
|
|
4731
|
+
};
|
|
4732
|
+
};
|
|
4733
|
+
output: {
|
|
4734
|
+
error: {
|
|
4735
|
+
code: string;
|
|
4736
|
+
message: any;
|
|
4737
|
+
};
|
|
4738
|
+
};
|
|
4739
|
+
outputFormat: "json";
|
|
4740
|
+
status: 500;
|
|
4741
|
+
};
|
|
4742
|
+
}>;
|
|
4743
|
+
};
|
|
4699
4744
|
} & {
|
|
4700
4745
|
":id": {
|
|
4701
4746
|
checkout: import("hono/client").ClientRequest<{
|