@instockng/api-client 1.0.20 → 1.0.22
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/backend-types.d.ts +1 -1
- package/dist/fetchers/carts.d.ts +10 -0
- package/dist/fetchers/orders.d.ts +197 -0
- package/dist/fetchers/orders.js +20 -0
- package/dist/fetchers/products.d.ts +10 -0
- package/dist/fetchers/products.js +18 -0
- package/dist/hooks/admin/abandoned-carts.d.ts +2 -0
- package/dist/hooks/admin/customers.d.ts +1 -0
- package/dist/hooks/admin/orders.d.ts +6 -0
- package/dist/hooks/admin/products.d.ts +4 -0
- package/dist/hooks/admin/products.js +33 -0
- package/dist/hooks/admin/stats.d.ts +1 -0
- package/dist/hooks/admin/variants.d.ts +5 -0
- package/dist/hooks/admin/warehouses.d.ts +1 -0
- package/dist/hooks/public/carts.d.ts +10 -0
- package/dist/hooks/public/orders.d.ts +204 -1
- package/dist/hooks/public/orders.js +23 -1
- package/dist/hooks/public/products.d.ts +10 -1
- package/dist/hooks/public/products.js +14 -1
- package/dist/rpc-client.d.ts +559 -14
- package/dist/rpc-client.js +2 -0
- package/dist/utils/query-keys.d.ts +3 -0
- package/dist/utils/query-keys.js +5 -0
- package/package.json +8 -9
|
@@ -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 { fetchOrder, confirmOrder } from '../../fetchers/orders';
|
|
8
|
+
import { fetchOrder, confirmOrder, fetchOrderRecommendations } from '../../fetchers/orders';
|
|
9
9
|
/**
|
|
10
10
|
* Hook to get order by ID and token using RPC
|
|
11
11
|
*
|
|
@@ -242,6 +242,7 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
242
242
|
thumbnailUrl: string | null;
|
|
243
243
|
productId: string;
|
|
244
244
|
sku: string;
|
|
245
|
+
compareAtPrice: string;
|
|
245
246
|
trackInventory: boolean;
|
|
246
247
|
lowStockThreshold: number | null;
|
|
247
248
|
};
|
|
@@ -522,6 +523,7 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
522
523
|
thumbnailUrl: string | null;
|
|
523
524
|
productId: string;
|
|
524
525
|
sku: string;
|
|
526
|
+
compareAtPrice: string;
|
|
525
527
|
trackInventory: boolean;
|
|
526
528
|
lowStockThreshold: number | null;
|
|
527
529
|
};
|
|
@@ -567,3 +569,204 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
567
569
|
orderId: string;
|
|
568
570
|
token: string;
|
|
569
571
|
}, unknown>;
|
|
572
|
+
/**
|
|
573
|
+
* Hook to get order recommendations for post-purchase upsell
|
|
574
|
+
*
|
|
575
|
+
* @param orderId - Order UUID
|
|
576
|
+
* @param token - User action token
|
|
577
|
+
* @param limit - Maximum number of recommendations (default: 4)
|
|
578
|
+
* @param options - React Query options
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```tsx
|
|
582
|
+
* const { data: recommendations, isLoading } = useGetOrderRecommendations('order-123', 'token-456', 4);
|
|
583
|
+
* console.log(recommendations); // Array of products from same brand
|
|
584
|
+
* ```
|
|
585
|
+
*/
|
|
586
|
+
export declare function useGetOrderRecommendations(orderId: string | null | undefined, token: string | null | undefined, limit?: number, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchOrderRecommendations>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
587
|
+
brand: {
|
|
588
|
+
createdAt: string;
|
|
589
|
+
updatedAt: string;
|
|
590
|
+
deletedAt: string;
|
|
591
|
+
id: string;
|
|
592
|
+
name: string;
|
|
593
|
+
slug: string;
|
|
594
|
+
logoUrl: string | null;
|
|
595
|
+
siteUrl: string;
|
|
596
|
+
domain: string;
|
|
597
|
+
metaPixelId: string | null;
|
|
598
|
+
tiktokPixelId: string | null;
|
|
599
|
+
paystackPublicKey: string | null;
|
|
600
|
+
paystackSecretKey: string | null;
|
|
601
|
+
};
|
|
602
|
+
variants: {
|
|
603
|
+
createdAt: string;
|
|
604
|
+
updatedAt: string;
|
|
605
|
+
price: number;
|
|
606
|
+
compareAtPrice: number;
|
|
607
|
+
deletedAt: string;
|
|
608
|
+
id: string;
|
|
609
|
+
name: string | null;
|
|
610
|
+
isActive: boolean;
|
|
611
|
+
thumbnailUrl: string | null;
|
|
612
|
+
productId: string;
|
|
613
|
+
sku: string;
|
|
614
|
+
trackInventory: boolean;
|
|
615
|
+
lowStockThreshold: number | null;
|
|
616
|
+
}[];
|
|
617
|
+
id: string;
|
|
618
|
+
name: string;
|
|
619
|
+
slug: string;
|
|
620
|
+
createdAt: string;
|
|
621
|
+
updatedAt: string;
|
|
622
|
+
deletedAt: string;
|
|
623
|
+
brandId: string;
|
|
624
|
+
isActive: boolean;
|
|
625
|
+
description: string | null;
|
|
626
|
+
thumbnailUrl: string | null;
|
|
627
|
+
quantityDiscounts: string | number | boolean | {
|
|
628
|
+
[x: string]: string | number | boolean | /*elided*/ any | {
|
|
629
|
+
[x: number]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
630
|
+
length: number;
|
|
631
|
+
toString: never;
|
|
632
|
+
toLocaleString: never;
|
|
633
|
+
pop: never;
|
|
634
|
+
push: never;
|
|
635
|
+
concat: never;
|
|
636
|
+
join: never;
|
|
637
|
+
reverse: never;
|
|
638
|
+
shift: never;
|
|
639
|
+
slice: never;
|
|
640
|
+
sort: never;
|
|
641
|
+
splice: never;
|
|
642
|
+
unshift: never;
|
|
643
|
+
indexOf: never;
|
|
644
|
+
lastIndexOf: never;
|
|
645
|
+
every: never;
|
|
646
|
+
some: never;
|
|
647
|
+
forEach: never;
|
|
648
|
+
map: never;
|
|
649
|
+
filter: never;
|
|
650
|
+
reduce: never;
|
|
651
|
+
reduceRight: never;
|
|
652
|
+
find: never;
|
|
653
|
+
findIndex: never;
|
|
654
|
+
fill: never;
|
|
655
|
+
copyWithin: never;
|
|
656
|
+
entries: never;
|
|
657
|
+
keys: never;
|
|
658
|
+
values: never;
|
|
659
|
+
includes: never;
|
|
660
|
+
flatMap: never;
|
|
661
|
+
flat: never;
|
|
662
|
+
[Symbol.iterator]: never;
|
|
663
|
+
readonly [Symbol.unscopables]: {
|
|
664
|
+
[x: number]: boolean;
|
|
665
|
+
length?: boolean;
|
|
666
|
+
toString?: boolean;
|
|
667
|
+
toLocaleString?: boolean;
|
|
668
|
+
pop?: boolean;
|
|
669
|
+
push?: boolean;
|
|
670
|
+
concat?: boolean;
|
|
671
|
+
join?: boolean;
|
|
672
|
+
reverse?: boolean;
|
|
673
|
+
shift?: boolean;
|
|
674
|
+
slice?: boolean;
|
|
675
|
+
sort?: boolean;
|
|
676
|
+
splice?: boolean;
|
|
677
|
+
unshift?: boolean;
|
|
678
|
+
indexOf?: boolean;
|
|
679
|
+
lastIndexOf?: boolean;
|
|
680
|
+
every?: boolean;
|
|
681
|
+
some?: boolean;
|
|
682
|
+
forEach?: boolean;
|
|
683
|
+
map?: boolean;
|
|
684
|
+
filter?: boolean;
|
|
685
|
+
reduce?: boolean;
|
|
686
|
+
reduceRight?: boolean;
|
|
687
|
+
find?: boolean;
|
|
688
|
+
findIndex?: boolean;
|
|
689
|
+
fill?: boolean;
|
|
690
|
+
copyWithin?: boolean;
|
|
691
|
+
entries?: boolean;
|
|
692
|
+
keys?: boolean;
|
|
693
|
+
values?: boolean;
|
|
694
|
+
includes?: boolean;
|
|
695
|
+
flatMap?: boolean;
|
|
696
|
+
flat?: boolean;
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
} | {
|
|
700
|
+
[x: number]: string | number | boolean | {
|
|
701
|
+
[x: string]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
702
|
+
} | /*elided*/ any;
|
|
703
|
+
length: number;
|
|
704
|
+
toString: never;
|
|
705
|
+
toLocaleString: never;
|
|
706
|
+
pop: never;
|
|
707
|
+
push: never;
|
|
708
|
+
concat: never;
|
|
709
|
+
join: never;
|
|
710
|
+
reverse: never;
|
|
711
|
+
shift: never;
|
|
712
|
+
slice: never;
|
|
713
|
+
sort: never;
|
|
714
|
+
splice: never;
|
|
715
|
+
unshift: never;
|
|
716
|
+
indexOf: never;
|
|
717
|
+
lastIndexOf: never;
|
|
718
|
+
every: never;
|
|
719
|
+
some: never;
|
|
720
|
+
forEach: never;
|
|
721
|
+
map: never;
|
|
722
|
+
filter: never;
|
|
723
|
+
reduce: never;
|
|
724
|
+
reduceRight: never;
|
|
725
|
+
find: never;
|
|
726
|
+
findIndex: never;
|
|
727
|
+
fill: never;
|
|
728
|
+
copyWithin: never;
|
|
729
|
+
entries: never;
|
|
730
|
+
keys: never;
|
|
731
|
+
values: never;
|
|
732
|
+
includes: never;
|
|
733
|
+
flatMap: never;
|
|
734
|
+
flat: never;
|
|
735
|
+
[Symbol.iterator]: never;
|
|
736
|
+
readonly [Symbol.unscopables]: {
|
|
737
|
+
[x: number]: boolean;
|
|
738
|
+
length?: boolean;
|
|
739
|
+
toString?: boolean;
|
|
740
|
+
toLocaleString?: boolean;
|
|
741
|
+
pop?: boolean;
|
|
742
|
+
push?: boolean;
|
|
743
|
+
concat?: boolean;
|
|
744
|
+
join?: boolean;
|
|
745
|
+
reverse?: boolean;
|
|
746
|
+
shift?: boolean;
|
|
747
|
+
slice?: boolean;
|
|
748
|
+
sort?: boolean;
|
|
749
|
+
splice?: boolean;
|
|
750
|
+
unshift?: boolean;
|
|
751
|
+
indexOf?: boolean;
|
|
752
|
+
lastIndexOf?: boolean;
|
|
753
|
+
every?: boolean;
|
|
754
|
+
some?: boolean;
|
|
755
|
+
forEach?: boolean;
|
|
756
|
+
map?: boolean;
|
|
757
|
+
filter?: boolean;
|
|
758
|
+
reduce?: boolean;
|
|
759
|
+
reduceRight?: boolean;
|
|
760
|
+
find?: boolean;
|
|
761
|
+
findIndex?: boolean;
|
|
762
|
+
fill?: boolean;
|
|
763
|
+
copyWithin?: boolean;
|
|
764
|
+
entries?: boolean;
|
|
765
|
+
keys?: boolean;
|
|
766
|
+
values?: boolean;
|
|
767
|
+
includes?: boolean;
|
|
768
|
+
flatMap?: boolean;
|
|
769
|
+
flat?: boolean;
|
|
770
|
+
};
|
|
771
|
+
};
|
|
772
|
+
}[], Error>;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useMutation } from '@tanstack/react-query';
|
|
8
8
|
import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
9
9
|
import { queryKeys } from '../../utils/query-keys';
|
|
10
|
-
import { fetchOrder, confirmOrder } from '../../fetchers/orders';
|
|
10
|
+
import { fetchOrder, confirmOrder, fetchOrderRecommendations } from '../../fetchers/orders';
|
|
11
11
|
/**
|
|
12
12
|
* Hook to get order by ID and token using RPC
|
|
13
13
|
*
|
|
@@ -48,3 +48,25 @@ export function useConfirmOrder(options) {
|
|
|
48
48
|
...options,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Hook to get order recommendations for post-purchase upsell
|
|
53
|
+
*
|
|
54
|
+
* @param orderId - Order UUID
|
|
55
|
+
* @param token - User action token
|
|
56
|
+
* @param limit - Maximum number of recommendations (default: 4)
|
|
57
|
+
* @param options - React Query options
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* const { data: recommendations, isLoading } = useGetOrderRecommendations('order-123', 'token-456', 4);
|
|
62
|
+
* console.log(recommendations); // Array of products from same brand
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function useGetOrderRecommendations(orderId, token, limit = 4, options) {
|
|
66
|
+
return useQueryUnwrapped({
|
|
67
|
+
queryKey: queryKeys.public.orders.recommendations(orderId, token, limit),
|
|
68
|
+
queryFn: () => fetchOrderRecommendations(orderId, token, limit),
|
|
69
|
+
enabled: !!orderId && !!token,
|
|
70
|
+
...options,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* providing end-to-end type safety without code generation.
|
|
6
6
|
*/
|
|
7
7
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
8
|
-
import { fetchProductsByBrand, fetchProductBySlug } from '../../fetchers/products';
|
|
8
|
+
import { fetchProductsByBrand, fetchProductBySlug, fetchProductAddons } from '../../fetchers/products';
|
|
9
9
|
/**
|
|
10
10
|
* Hook to get products by brand using RPC
|
|
11
11
|
*
|
|
@@ -38,6 +38,7 @@ export declare function useGetProducts(brandId: string, options?: Omit<UseQueryO
|
|
|
38
38
|
createdAt: string;
|
|
39
39
|
updatedAt: string;
|
|
40
40
|
price: number;
|
|
41
|
+
compareAtPrice: number;
|
|
41
42
|
deletedAt: string;
|
|
42
43
|
id: string;
|
|
43
44
|
name: string | null;
|
|
@@ -236,6 +237,7 @@ export declare function useGetProduct(slug: string, options?: Omit<UseQueryOptio
|
|
|
236
237
|
createdAt: string;
|
|
237
238
|
updatedAt: string;
|
|
238
239
|
price: number;
|
|
240
|
+
compareAtPrice: number;
|
|
239
241
|
deletedAt: string;
|
|
240
242
|
id: string;
|
|
241
243
|
name: string | null;
|
|
@@ -402,3 +404,10 @@ export declare function useGetProduct(slug: string, options?: Omit<UseQueryOptio
|
|
|
402
404
|
};
|
|
403
405
|
};
|
|
404
406
|
}, Error>;
|
|
407
|
+
/**
|
|
408
|
+
* Hook to get product add-ons
|
|
409
|
+
*
|
|
410
|
+
* @param slug - Product slug
|
|
411
|
+
* @param limit - Max number of add-ons
|
|
412
|
+
*/
|
|
413
|
+
export declare function useGetProductAddOns(slug: string, limit?: number, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchProductAddons>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
8
8
|
import { queryKeys } from '../../utils/query-keys';
|
|
9
|
-
import { fetchProductsByBrand, fetchProductBySlug } from '../../fetchers/products';
|
|
9
|
+
import { fetchProductsByBrand, fetchProductBySlug, fetchProductAddons } from '../../fetchers/products';
|
|
10
10
|
/**
|
|
11
11
|
* Hook to get products by brand using RPC
|
|
12
12
|
*
|
|
@@ -45,3 +45,16 @@ export function useGetProduct(slug, options) {
|
|
|
45
45
|
...options,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Hook to get product add-ons
|
|
50
|
+
*
|
|
51
|
+
* @param slug - Product slug
|
|
52
|
+
* @param limit - Max number of add-ons
|
|
53
|
+
*/
|
|
54
|
+
export function useGetProductAddOns(slug, limit, options) {
|
|
55
|
+
return useQueryUnwrapped({
|
|
56
|
+
queryKey: queryKeys.public.products.addons(slug, limit),
|
|
57
|
+
queryFn: () => fetchProductAddons(slug, limit),
|
|
58
|
+
...options,
|
|
59
|
+
});
|
|
60
|
+
}
|