@kasuvia/sdk 0.0.2 → 0.0.5

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 (77) hide show
  1. package/dist/hooks/index.d.mts +430 -0
  2. package/dist/hooks/index.d.ts +430 -0
  3. package/dist/hooks/index.js +3073 -0
  4. package/dist/hooks/index.js.map +1 -0
  5. package/dist/hooks/index.mjs +2962 -0
  6. package/dist/hooks/index.mjs.map +1 -0
  7. package/dist/index-CxNLI4nw.d.ts +786 -0
  8. package/dist/index-CzVMyUs4.d.mts +492 -0
  9. package/dist/index-CzVMyUs4.d.ts +492 -0
  10. package/dist/index-Dowl5224.d.mts +786 -0
  11. package/dist/index.d.mts +48 -1739
  12. package/dist/index.d.ts +48 -1739
  13. package/dist/index.js +1544 -2359
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +1527 -2258
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/sdk-context-BuarJbeb.d.ts +75 -0
  18. package/dist/sdk-context-Db8kf1Tv.d.mts +75 -0
  19. package/dist/services/index.d.mts +2 -0
  20. package/dist/services/index.d.ts +2 -0
  21. package/dist/services/index.js +2369 -0
  22. package/dist/services/index.js.map +1 -0
  23. package/dist/services/index.mjs +2252 -0
  24. package/dist/services/index.mjs.map +1 -0
  25. package/package.json +11 -2
  26. package/src/config/index.ts +10 -91
  27. package/src/constants.ts +13 -0
  28. package/src/context/sdk-context.tsx +70 -0
  29. package/src/graphql/collections.graphql.ts +2 -10
  30. package/src/graphql/products.graphql.ts +215 -65
  31. package/src/graphql/wishlist.graphql.ts +7 -6
  32. package/src/hooks/index.ts +2 -0
  33. package/src/hooks/use-auth.ts +82 -158
  34. package/src/hooks/use-bespoke-availability.ts +25 -8
  35. package/src/hooks/use-cart.ts +222 -119
  36. package/src/hooks/use-cms.ts +179 -86
  37. package/src/hooks/use-collections.ts +52 -15
  38. package/src/hooks/use-consultation-stream.ts +4 -3
  39. package/src/hooks/use-consultations.ts +120 -51
  40. package/src/hooks/use-countries.ts +35 -13
  41. package/src/hooks/use-currencies.ts +26 -13
  42. package/src/hooks/use-google-translate.ts +22 -8
  43. package/src/hooks/use-languages.ts +40 -20
  44. package/src/hooks/use-mobile.ts +23 -0
  45. package/src/hooks/use-order-stream.ts +9 -5
  46. package/src/hooks/use-orders.ts +99 -44
  47. package/src/hooks/use-payment.ts +108 -40
  48. package/src/hooks/use-products.ts +251 -53
  49. package/src/hooks/use-service-booking.ts +152 -90
  50. package/src/hooks/use-states.ts +35 -15
  51. package/src/hooks/use-wishlist.ts +92 -91
  52. package/src/index.ts +26 -30
  53. package/src/services/auth.service.ts +209 -167
  54. package/src/services/bespoke.service.ts +12 -4
  55. package/src/services/cart.service.ts +172 -70
  56. package/src/services/cms.service.ts +70 -35
  57. package/src/services/collection.service.ts +22 -5
  58. package/src/services/config.service.ts +34 -14
  59. package/src/services/consultation.service.ts +72 -18
  60. package/src/services/logistics.service.ts +35 -11
  61. package/src/services/notifications.service.ts +27 -12
  62. package/src/services/order.service.ts +74 -15
  63. package/src/services/payment.service.ts +86 -31
  64. package/src/services/product.service.ts +279 -39
  65. package/src/services/service-booking.service.ts +98 -26
  66. package/src/services/wishlist.service.ts +69 -25
  67. package/src/types/auth/index.ts +6 -4
  68. package/src/types/business/index.ts +7 -2
  69. package/src/types/payments/index.ts +3 -3
  70. package/src/types/services/index.ts +2 -5
  71. package/src/types/store/index.ts +38 -3
  72. package/src/utils/error-handler.ts +10 -5
  73. package/src/utils/storage.ts +48 -26
  74. package/src/utils/validators.ts +85 -0
  75. package/src/client/authClient.ts +0 -135
  76. package/src/client/graphqlClient.ts +0 -53
  77. package/src/client/httpClient.ts +0 -298
@@ -0,0 +1,75 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { S as SdkConfig } from './index-CzVMyUs4.js';
3
+
4
+ type Theme = "light" | "dark";
5
+ type LangCode = "en" | "ha" | "yo" | "ig" | "fr";
6
+ interface AppState {
7
+ theme: Theme;
8
+ lang: LangCode;
9
+ currency: string;
10
+ }
11
+ interface AppContextValue extends AppState {
12
+ setTheme: (t: Theme) => void;
13
+ setLang: (l: LangCode) => void;
14
+ setCurrency: (c: string) => void;
15
+ formatPrice: (amount: number, fromCurrency?: string) => string;
16
+ resetAppState: () => void;
17
+ t: (text: string) => string;
18
+ translate: (text: string) => Promise<string>;
19
+ }
20
+ interface Country {
21
+ name: string;
22
+ code: string;
23
+ dial_code: string;
24
+ min_age: number;
25
+ }
26
+ interface State {
27
+ name: string;
28
+ code: string;
29
+ full_iso_code: string;
30
+ type: string;
31
+ }
32
+
33
+ /**
34
+ * SdkContext
35
+ *
36
+ * Provides SdkConfig and the current access token to all SDK hooks
37
+ * in the component tree, so individual hooks do not require explicit
38
+ * config/accessToken parameters when called from client components.
39
+ *
40
+ * Usage in storefront:
41
+ * // In your AuthProvider or root layout:
42
+ * <SdkProvider config={sdkConfig} accessToken={accessToken}>
43
+ * {children}
44
+ * </SdkProvider>
45
+ *
46
+ * // In any client component:
47
+ * const { items, addItem } = useCart() // no args needed
48
+ */
49
+
50
+ interface SdkContextValue {
51
+ config: SdkConfig;
52
+ accessToken: string | null;
53
+ }
54
+ interface SdkProviderProps {
55
+ config: SdkConfig;
56
+ accessToken: string | null;
57
+ children: ReactNode;
58
+ }
59
+ declare function SdkProvider({ config, accessToken, children }: SdkProviderProps): React.JSX.Element;
60
+ /**
61
+ * Returns the SdkContext value, or null if no SdkProvider is present.
62
+ * SDK hooks use this internally to fall back to context when explicit
63
+ * parameters are not provided.
64
+ */
65
+ declare function useSdkContext(): SdkContextValue | null;
66
+ /**
67
+ * Resolves config and accessToken from explicit arguments or SdkContext.
68
+ * Throws if neither source is available.
69
+ */
70
+ declare function resolveHookArgs(explicitConfig: SdkConfig | undefined, explicitToken: string | null | undefined, ctx: SdkContextValue | null): {
71
+ config: SdkConfig;
72
+ accessToken: string | null;
73
+ };
74
+
75
+ export { type AppContextValue as A, type Country as C, type LangCode as L, type SdkContextValue as S, type Theme as T, type AppState as a, SdkProvider as b, type SdkProviderProps as c, type State as d, resolveHookArgs as r, useSdkContext as u };
@@ -0,0 +1,75 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { S as SdkConfig } from './index-CzVMyUs4.mjs';
3
+
4
+ type Theme = "light" | "dark";
5
+ type LangCode = "en" | "ha" | "yo" | "ig" | "fr";
6
+ interface AppState {
7
+ theme: Theme;
8
+ lang: LangCode;
9
+ currency: string;
10
+ }
11
+ interface AppContextValue extends AppState {
12
+ setTheme: (t: Theme) => void;
13
+ setLang: (l: LangCode) => void;
14
+ setCurrency: (c: string) => void;
15
+ formatPrice: (amount: number, fromCurrency?: string) => string;
16
+ resetAppState: () => void;
17
+ t: (text: string) => string;
18
+ translate: (text: string) => Promise<string>;
19
+ }
20
+ interface Country {
21
+ name: string;
22
+ code: string;
23
+ dial_code: string;
24
+ min_age: number;
25
+ }
26
+ interface State {
27
+ name: string;
28
+ code: string;
29
+ full_iso_code: string;
30
+ type: string;
31
+ }
32
+
33
+ /**
34
+ * SdkContext
35
+ *
36
+ * Provides SdkConfig and the current access token to all SDK hooks
37
+ * in the component tree, so individual hooks do not require explicit
38
+ * config/accessToken parameters when called from client components.
39
+ *
40
+ * Usage in storefront:
41
+ * // In your AuthProvider or root layout:
42
+ * <SdkProvider config={sdkConfig} accessToken={accessToken}>
43
+ * {children}
44
+ * </SdkProvider>
45
+ *
46
+ * // In any client component:
47
+ * const { items, addItem } = useCart() // no args needed
48
+ */
49
+
50
+ interface SdkContextValue {
51
+ config: SdkConfig;
52
+ accessToken: string | null;
53
+ }
54
+ interface SdkProviderProps {
55
+ config: SdkConfig;
56
+ accessToken: string | null;
57
+ children: ReactNode;
58
+ }
59
+ declare function SdkProvider({ config, accessToken, children }: SdkProviderProps): React.JSX.Element;
60
+ /**
61
+ * Returns the SdkContext value, or null if no SdkProvider is present.
62
+ * SDK hooks use this internally to fall back to context when explicit
63
+ * parameters are not provided.
64
+ */
65
+ declare function useSdkContext(): SdkContextValue | null;
66
+ /**
67
+ * Resolves config and accessToken from explicit arguments or SdkContext.
68
+ * Throws if neither source is available.
69
+ */
70
+ declare function resolveHookArgs(explicitConfig: SdkConfig | undefined, explicitToken: string | null | undefined, ctx: SdkContextValue | null): {
71
+ config: SdkConfig;
72
+ accessToken: string | null;
73
+ };
74
+
75
+ export { type AppContextValue as A, type Country as C, type LangCode as L, type SdkContextValue as S, type Theme as T, type AppState as a, SdkProvider as b, type SdkProviderProps as c, type State as d, resolveHookArgs as r, useSdkContext as u };
@@ -0,0 +1,2 @@
1
+ export { g as CartItemPayload, o as ContactFormData, R as RateAddress, z as ShippingRatesRequest, E as acceptQuote, F as addToCart, G as addToGuestCart, H as addToWishlist, I as approveDeliverable, J as bespokeService, K as bookAppointment, M as cancelAppointment, P as cancelOrder, Q as checkAvailability, T as checkInWishlist, V as clearCart, W as clearGuestCart, X as clearTokens, Y as configService, Z as consultationService, _ as createCmsEntry, $ as createConsultation, a0 as createDedicatedAccount, a1 as createOrder, a2 as deleteCmsEntry, a3 as findOrder, a4 as findOrderByToken, a5 as getAppointment, a6 as getAppointments, a7 as getAuthUser, a8 as getAvailableSlots, a9 as getBusinessConfig, aa as getCart, ab as getCmsEntry, ac as getConsultation, ad as getConsultations, ae as getDeliverables, af as getFeaturedProducts, ag as getGuestCart, ah as getGuestCartCount, ai as getGuestCartProductType, aj as getGuestCartSubtotal, ak as getLatestProducts, al as getLowStockProducts, am as getMe, an as getNewProducts, ao as getOnSaleProducts, ap as getOrders, aq as getPopularProducts, ar as getRecommendedProducts, as as getSellerShippingAddress, at as getShippingRates, au as getStoredTokens, av as getStorefrontCollectionBySlug, aw as getStorefrontCollections, ax as getStorefrontProductBySlug, ay as getStorefrontProducts, az as getSupportedCurrencies, aA as getSupportedLanguages, aB as getTransactionStatus, aC as getWishlist, aD as googleTranslate, aE as initiatePayment, aF as listCmsEntries, aG as loginCustomer, aH as logisticsService, aI as logout, aJ as mapAuthUserToCustomer, aK as mergeGuestCart, aL as mergeGuestCartIfPresent, aM as notificationsService, aN as paymentService, aO as refreshToken, aP as registerCustomer, aQ as rejectQuote, aR as removeFromCart, aS as removeFromGuestCart, aT as removeFromWishlist, aU as removeProductFromWishlist, aV as requestQuote, aW as requestRevision, aX as sendContactConfirmation, aY as sendContactEmail, aZ as sendMessage, a_ as serviceBookingService, a$ as silentRefresh, b0 as storeTokens, b1 as trackOrder, b2 as updateCartItem, b3 as updateCmsEntry, b4 as updateGuestCartItemQuantity, b5 as updateProfile, b6 as validateShippingAddress, b7 as verifySocialToken, b8 as verifyTransaction } from '../index-Dowl5224.mjs';
2
+ export { p as CreateOrderParams, F as FindOrderParams, w as OrderStatus } from '../index-CzVMyUs4.mjs';
@@ -0,0 +1,2 @@
1
+ export { g as CartItemPayload, o as ContactFormData, R as RateAddress, z as ShippingRatesRequest, E as acceptQuote, F as addToCart, G as addToGuestCart, H as addToWishlist, I as approveDeliverable, J as bespokeService, K as bookAppointment, M as cancelAppointment, P as cancelOrder, Q as checkAvailability, T as checkInWishlist, V as clearCart, W as clearGuestCart, X as clearTokens, Y as configService, Z as consultationService, _ as createCmsEntry, $ as createConsultation, a0 as createDedicatedAccount, a1 as createOrder, a2 as deleteCmsEntry, a3 as findOrder, a4 as findOrderByToken, a5 as getAppointment, a6 as getAppointments, a7 as getAuthUser, a8 as getAvailableSlots, a9 as getBusinessConfig, aa as getCart, ab as getCmsEntry, ac as getConsultation, ad as getConsultations, ae as getDeliverables, af as getFeaturedProducts, ag as getGuestCart, ah as getGuestCartCount, ai as getGuestCartProductType, aj as getGuestCartSubtotal, ak as getLatestProducts, al as getLowStockProducts, am as getMe, an as getNewProducts, ao as getOnSaleProducts, ap as getOrders, aq as getPopularProducts, ar as getRecommendedProducts, as as getSellerShippingAddress, at as getShippingRates, au as getStoredTokens, av as getStorefrontCollectionBySlug, aw as getStorefrontCollections, ax as getStorefrontProductBySlug, ay as getStorefrontProducts, az as getSupportedCurrencies, aA as getSupportedLanguages, aB as getTransactionStatus, aC as getWishlist, aD as googleTranslate, aE as initiatePayment, aF as listCmsEntries, aG as loginCustomer, aH as logisticsService, aI as logout, aJ as mapAuthUserToCustomer, aK as mergeGuestCart, aL as mergeGuestCartIfPresent, aM as notificationsService, aN as paymentService, aO as refreshToken, aP as registerCustomer, aQ as rejectQuote, aR as removeFromCart, aS as removeFromGuestCart, aT as removeFromWishlist, aU as removeProductFromWishlist, aV as requestQuote, aW as requestRevision, aX as sendContactConfirmation, aY as sendContactEmail, aZ as sendMessage, a_ as serviceBookingService, a$ as silentRefresh, b0 as storeTokens, b1 as trackOrder, b2 as updateCartItem, b3 as updateCmsEntry, b4 as updateGuestCartItemQuantity, b5 as updateProfile, b6 as validateShippingAddress, b7 as verifySocialToken, b8 as verifyTransaction } from '../index-CxNLI4nw.js';
2
+ export { p as CreateOrderParams, F as FindOrderParams, w as OrderStatus } from '../index-CzVMyUs4.js';