@kasuvia/sdk 0.0.8 → 0.0.9
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/README.md +42 -15
- package/dist/AddressAutocomplete-CjcqPElD.d.mts +46 -0
- package/dist/AddressAutocomplete-CvJHuRkf.d.ts +46 -0
- package/dist/components/index.d.mts +497 -0
- package/dist/components/index.d.ts +497 -0
- package/dist/components/index.js +4217 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +4194 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/server.d.mts +26 -0
- package/dist/config/server.d.ts +26 -0
- package/dist/config/server.js +38 -0
- package/dist/config/server.js.map +1 -0
- package/dist/config/server.mjs +13 -0
- package/dist/config/server.mjs.map +1 -0
- package/dist/hooks/index.d.mts +393 -160
- package/dist/hooks/index.d.ts +393 -160
- package/dist/hooks/index.js +2792 -2137
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2734 -2121
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index-CNW_LINy.d.mts +578 -0
- package/dist/index-CNW_LINy.d.ts +578 -0
- package/dist/{index-C1chUA3P.d.mts → index-F7N6UItS.d.mts} +1 -1
- package/dist/{index-C1chUA3P.d.ts → index-F7N6UItS.d.ts} +1 -1
- package/dist/index-NkI10J_E.d.mts +40 -0
- package/dist/index-NkI10J_E.d.ts +40 -0
- package/dist/index.d.mts +20437 -103
- package/dist/index.d.ts +20437 -103
- package/dist/index.js +2111 -1802
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2006 -1786
- package/dist/index.mjs.map +1 -1
- package/dist/media.service-Cx7dQjzX.d.mts +1393 -0
- package/dist/media.service-mrBFJ2UQ.d.ts +1393 -0
- package/dist/services/index.d.mts +908 -2
- package/dist/services/index.d.ts +908 -2
- package/dist/services/index.js +1492 -1686
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +1431 -1670
- package/dist/services/index.mjs.map +1 -1
- package/package.json +46 -6
- package/src/components/bespoke/BespokeAvailabilityBadge.tsx +32 -0
- package/src/components/bespoke/BespokeProgressTracker.tsx +58 -0
- package/src/components/bespoke/index.ts +3 -0
- package/src/components/booking/SlotPicker.tsx +97 -0
- package/src/components/booking/index.ts +1 -0
- package/src/components/cart/CartItem.tsx +81 -0
- package/src/components/cart/CartSidebar.tsx +115 -0
- package/src/components/cart/CartTypeMismatchBanner.tsx +55 -0
- package/src/components/cart/index.ts +3 -0
- package/src/components/index.ts +8 -0
- package/src/components/orders/DeliverableReviewer.tsx +139 -0
- package/src/components/orders/index.ts +1 -0
- package/src/components/product/ProductCard.tsx +350 -0
- package/src/components/product/ProductGrid.tsx +84 -0
- package/src/components/product/index.ts +2 -0
- package/src/components/shared/AddressAutocomplete.tsx +212 -0
- package/src/components/shared/AnalyticsScripts.tsx +56 -0
- package/src/components/shared/CookieConsentBanner.tsx +98 -0
- package/src/components/shared/ImageEditorModal.tsx +1066 -0
- package/src/components/shared/ImageViewerModal.tsx +598 -0
- package/src/components/shared/LucideReactIcon.tsx +52 -0
- package/src/components/shared/MapPinDrop.tsx +101 -0
- package/src/components/shared/MultiSelectPicker.tsx +193 -0
- package/src/components/shared/OfflineBanner.tsx +46 -0
- package/src/components/shared/SearchableInput.tsx +153 -0
- package/src/components/shared/SearchablePopover.tsx +166 -0
- package/src/components/shared/SmartImage.tsx +311 -0
- package/src/components/shared/TruncatedValue.tsx +27 -0
- package/src/components/shared/UnsavedChangesGuard.tsx +138 -0
- package/src/components/shared/index.ts +15 -0
- package/src/components/skeletons/CardSkeleton.tsx +26 -0
- package/src/components/skeletons/CartItemSkeleton.tsx +26 -0
- package/src/components/skeletons/OrderItemSkeleton.tsx +26 -0
- package/src/components/skeletons/ProductCardSkeleton.tsx +26 -0
- package/src/components/skeletons/TableSkeleton.tsx +42 -0
- package/src/components/skeletons/index.ts +5 -0
- package/src/config/index.ts +22 -4
- package/src/config/server.ts +45 -0
- package/src/context/sdk-context.tsx +5 -2
- package/src/generated/auth-openapi.ts +2935 -0
- package/src/generated/cart-openapi.ts +652 -0
- package/src/generated/cms-openapi.ts +1668 -0
- package/src/generated/crm-openapi.ts +986 -0
- package/src/generated/graphql.ts +126 -0
- package/src/generated/index.ts +11 -0
- package/src/generated/media-openapi.ts +613 -0
- package/src/generated/notification-openapi.ts +862 -0
- package/src/generated/payment-openapi.ts +2713 -0
- package/src/generated/store-openapi.ts +9510 -0
- package/src/graphql/operations/collections.graphql +32 -0
- package/src/graphql/operations/products.graphql +197 -0
- package/src/graphql/operations/wishlist.graphql +25 -0
- package/src/hooks/index.ts +9 -2
- package/src/hooks/use-auth.ts +163 -69
- package/src/hooks/use-bespoke-availability.ts +39 -22
- package/src/hooks/use-business-config.ts +51 -0
- package/src/hooks/use-cart.ts +310 -238
- package/src/hooks/use-cms.ts +107 -127
- package/src/hooks/use-collections.ts +35 -55
- package/src/hooks/use-consultations.ts +9 -136
- package/src/hooks/use-countries.ts +19 -28
- package/src/hooks/use-currencies.ts +8 -20
- package/src/hooks/use-customer-address.ts +64 -0
- package/src/hooks/use-feedback.ts +34 -0
- package/src/hooks/use-languages.ts +26 -39
- package/src/hooks/use-media-upload.ts +23 -0
- package/src/hooks/use-notification-stream.ts +88 -0
- package/src/hooks/use-notifications.ts +163 -0
- package/src/hooks/use-order-stream.ts +29 -29
- package/src/hooks/use-orders.ts +91 -73
- package/src/hooks/use-payment.ts +116 -84
- package/src/hooks/use-products.ts +65 -269
- package/src/hooks/use-push-notifications.ts +122 -0
- package/src/hooks/use-reviews.ts +175 -0
- package/src/hooks/use-service-booking.ts +109 -132
- package/src/hooks/use-states.ts +16 -30
- package/src/hooks/use-wishlist.ts +44 -69
- package/src/index.ts +15 -11
- package/src/services/auth.service.ts +422 -132
- package/src/services/bespoke.service.ts +69 -10
- package/src/services/cart.service.ts +155 -186
- package/src/services/cms.service.ts +41 -50
- package/src/services/collection.service.ts +25 -63
- package/src/services/config.service.ts +10 -21
- package/src/services/consultation.service.ts +36 -93
- package/src/services/feedback.service.ts +76 -0
- package/src/services/index.ts +7 -1
- package/src/services/legal.service.ts +62 -0
- package/src/services/logistics.service.ts +235 -53
- package/src/services/media.service.ts +115 -0
- package/src/services/notifications.service.ts +204 -20
- package/src/services/order.service.ts +498 -127
- package/src/services/payment.service.ts +149 -100
- package/src/services/product.service.ts +157 -814
- package/src/services/review.service.ts +211 -0
- package/src/services/service-booking.service.ts +198 -99
- package/src/services/wishlist.service.ts +27 -74
- package/src/types/auth/index.ts +161 -18
- package/src/types/business/index.ts +9 -1
- package/src/types/cms/index.ts +91 -6
- package/src/types/cms/legal.ts +18 -0
- package/src/types/consultations/index.ts +60 -68
- package/src/types/index.ts +5 -3
- package/src/types/media/index.ts +35 -3
- package/src/types/payments/index.ts +80 -16
- package/src/types/reviews/index.ts +116 -0
- package/src/types/services/index.ts +113 -38
- package/src/types/store/checkout.ts +53 -0
- package/src/types/store/index.ts +273 -52
- package/src/types/store/invoice.ts +31 -0
- package/src/types/store/shipping.ts +84 -3
- package/src/types/ui/index.ts +1 -1
- package/src/utils/checkout.ts +19 -3
- package/src/utils/cookieConsent.ts +34 -0
- package/src/utils/format.ts +408 -0
- package/src/utils/geolocation.ts +134 -0
- package/src/utils/graphql-url.ts +47 -0
- package/src/utils/guest-session.ts +59 -0
- package/src/utils/http-client.ts +147 -0
- package/src/utils/index.ts +11 -4
- package/src/utils/status-colors.ts +79 -0
- package/src/utils/token-refresh.ts +115 -0
- package/src/utils/validators.ts +13 -0
- package/src/utils/youtube.ts +18 -0
- package/dist/index-C5YO9gTl.d.mts +0 -507
- package/dist/index-C5YO9gTl.d.ts +0 -507
- package/dist/index-CefG7_xq.d.mts +0 -793
- package/dist/index-DeHCf3zI.d.ts +0 -793
- package/src/graphql/collections.graphql.ts +0 -48
- package/src/graphql/index.ts +0 -7
- package/src/graphql/products.graphql.ts +0 -860
- package/src/graphql/wishlist.graphql.ts +0 -34
- package/src/hooks/use-consultation-stream.ts +0 -142
- package/src/types/bespoke/index.ts +0 -39
|
@@ -1,2 +1,908 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { S as SdkConfig } from '../index-NkI10J_E.mjs';
|
|
2
|
+
import { b as CartResponse, a as CartItem, h as ProductType, L as ListParams, d as PaginatedResponse, P as Product, c as Collection, W as WishlistItem, e as WishlistCheckResponse, f as WishlistListResponse, Q as ShippingRatesResponse } from '../index-CNW_LINy.mjs';
|
|
3
|
+
export { C as CreateOrderParams, F as FindOrderParams, i as OrderStatus } from '../index-CNW_LINy.mjs';
|
|
4
|
+
import { M as CommentCreate, L as Comment, O as ReviewCreate, N as Review, V as ProductCommentsResponse, W as ProductReviewsResponse, P as MerchantReplyCreate, Q as CommentModerationAction, T as ReviewModerationAction, X as CommentUpdate, Y as ReviewUpdate, h as ChangePasswordPayload, af as MediaAsset, g as CreateCustomerAddressPayload, f as CustomerAddress, i as CustomerDeactivatePayload, D as DeactivateAccountResult, j as CustomerForgotPasswordPayload, A as AuthUserResponse, r as CustomerUser, S as StorefrontBusinessInfo, o as CustomerLoginPayload, n as CustomerAuthResponse, aZ as RefreshTokenResponse, p as CustomerRegisterPayload, q as CustomerPasswordlessRequestPayload, k as CustomerReactivatePayload, m as CustomerResetPasswordPayload, U as UpdateCustomerAddressPayload, s as UpdateProfilePayload, t as CustomerPasswordlessVerifyPayload, l as CustomerReactivateVerifyPayload, _ as WalletBalanceResponse, a0 as DVACreateRequest, $ as DVADetails, Z as GatewayMethods, a3 as TransactionVerifyResponse, a4 as WalletLedgerResponse, a2 as PaymentInitiateRequest, a1 as PaymentInitiateResponse, B as BespokeDeliverableStatus, w as BespokeAvailability, b2 as SupportedLanguagesResponse, b1 as SupportedCurrenciesResponse, a9 as BusinessConfig, a6 as CreateCmsEntryParams, a5 as CmsEntry, a8 as ListCmsEntriesParams, aq as CmsEntryListResponse, a7 as UpdateCmsEntryParams } from '../media.service-Cx7dQjzX.mjs';
|
|
5
|
+
export { b as Consultation, ac as ContactFormData, C as CreateBespokeOrderParams, c as CreateConsultationParams, d as CreateFeedbackParams, a as CreateServiceBookingOrderParams, aB as DigitalDownloadFileEntry, aC as DigitalDownloadListing, aD as DigitalDownloadRedirect, aE as DigitalDownloadResult, F as Feedback, aF as FeedbackCategory, e as FeedbackListResponse, aG as FeedbackStatus, aN as NotificationInboxItem, aa as NotificationInboxResponse, aO as NotificationPriority, aX as PromoValidationResult, aY as PushSubscriptionKeys, y as ServiceBookingsPage, ad as SubscribeToPushParams, ag as UploadMediaFileParams, ah as UploadMediaFilesResult, ae as VapidPublicKeyResponse, b4 as approveMilestone, b5 as bookAppointment, b6 as cancelAppointment, b7 as cancelOrder, b8 as confirmAppointmentCompletion, b9 as createBespokeOrder, ba as createConsultation, bb as createFeedback, bc as createOrder, bd as createServiceBookingOrder, be as disputeAppointment, bf as findOrder, bg as getAppointment, bh as getAppointments, bi as getAvailableSlots, bj as getMilestones, bk as getMyFeedback, bl as getNotificationInbox, bm as getNotificationPreferences, bn as getOrders, bo as getVapidPublicKey, bp as markAllNotificationsRead, bq as markNotificationRead, br as notificationsService, bs as rescheduleAppointment, bt as resolveDigitalDownload, bu as resolveDigitalDownloadFile, bv as sendContactConfirmation, bw as sendContactEmail, bx as serviceBookingService, by as subscribeToPush, bz as trackNotificationClick, bA as trackOrder, bB as unsubscribeFromPush, bC as updateNotificationPreferences, bD as uploadMediaFile, bE as uploadMediaFiles, bF as validatePromoCode } from '../media.service-Cx7dQjzX.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Legal Document Types
|
|
9
|
+
*
|
|
10
|
+
* Types for merchant storefront legal pages generated by
|
|
11
|
+
* kasuvia-website-builder-system via kasuvia-cms.
|
|
12
|
+
*/
|
|
13
|
+
interface LegalSection {
|
|
14
|
+
heading: string;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
interface MerchantLegalDocument {
|
|
18
|
+
document_type: string;
|
|
19
|
+
template_version: string;
|
|
20
|
+
rendered_sections: LegalSection[];
|
|
21
|
+
published_at: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Review and Comment Service
|
|
26
|
+
*
|
|
27
|
+
* Handles review and comment operations using REST API.
|
|
28
|
+
* Stateless - all configuration passed as parameters.
|
|
29
|
+
*
|
|
30
|
+
* REAL BUG FIXED (2026-09-21): every URL here hardcoded a literal `/api/v1`
|
|
31
|
+
* prefix AND used a completely different path shape than the real
|
|
32
|
+
* kasuvia-crm-go backend (`kasuvia-crm-go/internal/api/v1/endpoints/
|
|
33
|
+
* reviews.go` + `admin_reviews.go`) — e.g. `POST /api/v1/reviews/comments`
|
|
34
|
+
* vs the real `POST /api/v1/comments`, `GET /api/v1/reviews/products/{id}`
|
|
35
|
+
* vs the real `GET /api/v1/products/{id}/reviews`. Every function 404'd.
|
|
36
|
+
* `config.backendUrls.crm` already includes `/api/v1` (same convention as
|
|
37
|
+
* every other backendUrls.* entry — see payment.service.ts/order.service.ts)
|
|
38
|
+
* so the hardcoded prefix also risked doubling to `/api/v1/api/v1/...` once
|
|
39
|
+
* KASUVIA_CRM_URL was actually set.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a new review
|
|
44
|
+
*/
|
|
45
|
+
declare function createReview(reviewData: ReviewCreate, config: SdkConfig): Promise<Review>;
|
|
46
|
+
/**
|
|
47
|
+
* Update an existing review
|
|
48
|
+
*/
|
|
49
|
+
declare function updateReview(reviewId: string, reviewData: ReviewUpdate, config: SdkConfig): Promise<Review>;
|
|
50
|
+
/**
|
|
51
|
+
* Get paginated reviews for a product
|
|
52
|
+
*/
|
|
53
|
+
declare function getProductReviews(productId: string, params: {
|
|
54
|
+
page?: number;
|
|
55
|
+
page_size?: number;
|
|
56
|
+
moderation_status?: string;
|
|
57
|
+
} | undefined, config: SdkConfig): Promise<ProductReviewsResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a new comment
|
|
60
|
+
*/
|
|
61
|
+
declare function createComment(commentData: CommentCreate, config: SdkConfig): Promise<Comment>;
|
|
62
|
+
/**
|
|
63
|
+
* Update an existing comment
|
|
64
|
+
*/
|
|
65
|
+
declare function updateComment(commentId: string, commentData: CommentUpdate, config: SdkConfig): Promise<Comment>;
|
|
66
|
+
/**
|
|
67
|
+
* Get paginated comments for a product
|
|
68
|
+
*/
|
|
69
|
+
declare function getProductComments(productId: string, params: {
|
|
70
|
+
page?: number;
|
|
71
|
+
page_size?: number;
|
|
72
|
+
moderation_status?: string;
|
|
73
|
+
} | undefined, config: SdkConfig): Promise<ProductCommentsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Get pending reviews for moderation (merchant/staff only)
|
|
76
|
+
*/
|
|
77
|
+
declare function getPendingReviews(config: SdkConfig): Promise<Review[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get pending comments for moderation (merchant/staff only)
|
|
80
|
+
*/
|
|
81
|
+
declare function getPendingComments(config: SdkConfig): Promise<Comment[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Moderate a review (approve/reject) - merchant/staff only
|
|
84
|
+
*/
|
|
85
|
+
declare function moderateReview(reviewId: string, action: ReviewModerationAction, config: SdkConfig): Promise<Review>;
|
|
86
|
+
/**
|
|
87
|
+
* Moderate a comment (approve/reject) - merchant/staff only
|
|
88
|
+
*/
|
|
89
|
+
declare function moderateComment(commentId: string, action: CommentModerationAction, config: SdkConfig): Promise<Comment>;
|
|
90
|
+
/**
|
|
91
|
+
* Post a merchant reply to a review - merchant/staff only
|
|
92
|
+
*/
|
|
93
|
+
declare function merchantReplyToReview(reviewId: string, replyData: MerchantReplyCreate, config: SdkConfig): Promise<Review>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Cart Service
|
|
97
|
+
*
|
|
98
|
+
* Handles cart operations for both guest and authenticated users via
|
|
99
|
+
* kasuvia-cart-management (Go/Huma). All cart operations target the
|
|
100
|
+
* cart-management service, which is the single source of truth for cart state.
|
|
101
|
+
*
|
|
102
|
+
* KEY CONSTRAINT — backend-resolved fields:
|
|
103
|
+
* kasuvia-cart-management resolves product_name, product_slug, image_url,
|
|
104
|
+
* variant_attributes, unit_price, is_bespoke, and product_type entirely
|
|
105
|
+
* server-side from kasuvia-store-management at add/merge time. These MUST NOT
|
|
106
|
+
* be sent in request payloads — only product_id, variant_id, quantity, and
|
|
107
|
+
* custom_measurements are accepted by the backend.
|
|
108
|
+
*
|
|
109
|
+
* Stateless — all configuration passed as parameters.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Fetch guest cart from backend (Redis-backed).
|
|
114
|
+
*/
|
|
115
|
+
declare function getGuestCart(config: SdkConfig, guestSessionId: string): Promise<CartResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Add item to guest cart (Redis-backed).
|
|
118
|
+
* Only product_id, variant_id, quantity, and custom_measurements are sent —
|
|
119
|
+
* all other fields are resolved server-side by kasuvia-cart-management.
|
|
120
|
+
*/
|
|
121
|
+
declare function addToGuestCart(config: SdkConfig, guestSessionId: string, item: {
|
|
122
|
+
product_id: string;
|
|
123
|
+
variant_id?: string | null;
|
|
124
|
+
quantity: number;
|
|
125
|
+
custom_measurements?: string | null;
|
|
126
|
+
}): Promise<CartResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Update quantity of a guest cart item.
|
|
129
|
+
*/
|
|
130
|
+
declare function updateGuestCartItemQuantity(config: SdkConfig, guestSessionId: string, itemId: string, quantity: number): Promise<CartResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Remove an item from the guest cart.
|
|
133
|
+
*
|
|
134
|
+
* REAL BUG FIXED (2026-09-22), live-reproduced: this used to type its
|
|
135
|
+
* result as `CartResponse` and read `data.items` off it, but the real
|
|
136
|
+
* backend's `DELETE /cart/{item_id}` returns `204 No Content` with a
|
|
137
|
+
* genuinely empty body (confirmed live: `HTTP_STATUS:204 BODY_LENGTH:0`) -
|
|
138
|
+
* `apiRequest` resolves an empty body to `undefined`, so `data.items`
|
|
139
|
+
* threw `TypeError: Cannot read properties of undefined (reading 'items')`
|
|
140
|
+
* on every real delete. The item really was removed server-side (the
|
|
141
|
+
* DELETE request itself succeeded), but the thrown error sent
|
|
142
|
+
* `removeFromCartMutation` down `onError` instead of `onSuccess`, so
|
|
143
|
+
* `queryClient.invalidateQueries` never ran - a customer's cart kept
|
|
144
|
+
* showing the "removed" item until something else (a full page reload)
|
|
145
|
+
* happened to trigger a fresh, uncached fetch. Matches `clearGuestCart`'s
|
|
146
|
+
* existing `Promise<void>` shape, which was already correct for this same
|
|
147
|
+
* "backend returns no body" pattern.
|
|
148
|
+
*/
|
|
149
|
+
declare function removeFromGuestCart(config: SdkConfig, guestSessionId: string, itemId: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Clear the entire guest cart.
|
|
152
|
+
*/
|
|
153
|
+
declare function clearGuestCart(config: SdkConfig, guestSessionId: string): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Fetch authenticated user's cart from backend.
|
|
156
|
+
*/
|
|
157
|
+
declare function getCart(config: SdkConfig, accessToken?: string | null): Promise<CartResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Add item to authenticated user's cart.
|
|
160
|
+
* Only product_id, variant_id, quantity, and custom_measurements are sent —
|
|
161
|
+
* all other fields are resolved server-side by kasuvia-cart-management.
|
|
162
|
+
*/
|
|
163
|
+
declare function addToCart(config: SdkConfig, accessToken: string, item: {
|
|
164
|
+
product_id: string;
|
|
165
|
+
variant_id?: string | null;
|
|
166
|
+
quantity: number;
|
|
167
|
+
custom_measurements?: string | null;
|
|
168
|
+
product_slug?: string;
|
|
169
|
+
product_name?: string;
|
|
170
|
+
image_url?: string;
|
|
171
|
+
variant_attributes?: string;
|
|
172
|
+
unit_price?: number;
|
|
173
|
+
is_bespoke?: boolean;
|
|
174
|
+
}): Promise<CartResponse>;
|
|
175
|
+
/**
|
|
176
|
+
* Update item quantity in authenticated user's cart.
|
|
177
|
+
*/
|
|
178
|
+
declare function updateCartItem(config: SdkConfig, accessToken: string, itemId: string, quantity: number): Promise<CartResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Remove item from authenticated user's cart.
|
|
181
|
+
* Same real bug/fix as removeFromGuestCart above - see its doc comment.
|
|
182
|
+
*/
|
|
183
|
+
declare function removeFromCart(config: SdkConfig, accessToken: string, itemId: string): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Clear authenticated user's cart.
|
|
186
|
+
*/
|
|
187
|
+
declare function clearCart(config: SdkConfig, accessToken: string): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Merge guest cart items into the authenticated customer's cart.
|
|
190
|
+
*
|
|
191
|
+
* The backend (POST /api/v1/cart/merge) accepts only:
|
|
192
|
+
* { items: [{ product_id, variant_id?, quantity, custom_measurements? }] }
|
|
193
|
+
* Product name, image, price, type are all re-resolved server-side.
|
|
194
|
+
*
|
|
195
|
+
* Sends X-Guest-Session so the backend can atomically delete the guest
|
|
196
|
+
* cart (best-effort) after merging.
|
|
197
|
+
*/
|
|
198
|
+
declare function mergeGuestCart(config: SdkConfig, accessToken: string, guestSessionId: string, guestItems: Pick<CartItem, 'product_id' | 'variant_id' | 'quantity' | 'custom_measurements'>[]): Promise<CartResponse>;
|
|
199
|
+
/**
|
|
200
|
+
* Convenience wrapper: fetch guest cart and merge if it has items (called post-login).
|
|
201
|
+
*/
|
|
202
|
+
declare function mergeGuestCartIfPresent(config: SdkConfig, accessToken: string, guestSessionId: string): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* Helper to get a guest cart's product type (for type-mismatch checks before adding an item).
|
|
205
|
+
*/
|
|
206
|
+
declare function getGuestCartProductType(items?: CartItem[]): ProductType | null;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Customer auth service — all API calls scoped to this storefront's business tenant.
|
|
210
|
+
* Stateless - all configuration passed as parameters.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* POST /auth/login/customer/
|
|
215
|
+
* Business is identified by the X-Storefront-Key + X-Business-ID headers
|
|
216
|
+
* (config.storefrontApiKey / config.businessId) — never a body field (see
|
|
217
|
+
* plan: Customer Storefront Identity Enforcement).
|
|
218
|
+
*/
|
|
219
|
+
declare function loginCustomer(config: SdkConfig, payload: CustomerLoginPayload, guestSessionId?: string | null): Promise<CustomerAuthResponse>;
|
|
220
|
+
/**
|
|
221
|
+
* POST /auth/register/customer/
|
|
222
|
+
* Business identified via headers, see loginCustomer.
|
|
223
|
+
*/
|
|
224
|
+
declare function registerCustomer(config: SdkConfig, payload: CustomerRegisterPayload, guestSessionId?: string | null): Promise<CustomerAuthResponse>;
|
|
225
|
+
/** POST /auth/token/refresh/
|
|
226
|
+
*/
|
|
227
|
+
declare function refreshToken(config: SdkConfig, refresh: string): Promise<RefreshTokenResponse>;
|
|
228
|
+
/**
|
|
229
|
+
* POST /auth/logout/ — revokes the server-side session.
|
|
230
|
+
*
|
|
231
|
+
* Never throws: a customer's own logout must always clear their local
|
|
232
|
+
* session client-side (caller does this regardless of this promise's
|
|
233
|
+
* outcome) even if the backend is unreachable — an unrevoked server-side
|
|
234
|
+
* session in that case is a availability tradeoff, not a security one (the
|
|
235
|
+
* refresh token still expires on its own TTL). What CLAUDE.md forbids is
|
|
236
|
+
* failing SILENTLY; the failure is now always logged with real context so
|
|
237
|
+
* it's visible to whoever is debugging a report of "sessions not clearing
|
|
238
|
+
* server-side", instead of vanishing into a bare `catch {}`.
|
|
239
|
+
*/
|
|
240
|
+
declare function logout(config: SdkConfig, refresh?: string): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Verify a social provider id_token (or access_token for Facebook) with the backend.
|
|
243
|
+
*/
|
|
244
|
+
declare function verifySocialToken(config: SdkConfig, provider: 'google' | 'facebook', token: string): Promise<CustomerAuthResponse>;
|
|
245
|
+
/**
|
|
246
|
+
* POST /auth/login/customer/passwordless/request/
|
|
247
|
+
* Sends a one-time login code to the customer's email. Always resolves
|
|
248
|
+
* successfully (the backend never reveals whether the email is registered).
|
|
249
|
+
* Business identified via headers, see loginCustomer.
|
|
250
|
+
*/
|
|
251
|
+
declare function requestCustomerOtp(config: SdkConfig, payload: CustomerPasswordlessRequestPayload): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* POST /auth/login/customer/passwordless/verify/
|
|
254
|
+
* Verifies a one-time login code and returns tokens, auto-creating the
|
|
255
|
+
* customer account on first use (same as social login).
|
|
256
|
+
* Business identified via headers, see loginCustomer.
|
|
257
|
+
*/
|
|
258
|
+
declare function verifyCustomerOtp(config: SdkConfig, payload: CustomerPasswordlessVerifyPayload, guestSessionId?: string | null): Promise<CustomerAuthResponse>;
|
|
259
|
+
/**
|
|
260
|
+
* POST /auth/forgot-password/customer/
|
|
261
|
+
* Request a customer password reset OTP (business-scoped via headers).
|
|
262
|
+
*/
|
|
263
|
+
declare function forgotPasswordCustomer(config: SdkConfig, payload: CustomerForgotPasswordPayload): Promise<{
|
|
264
|
+
detail: string;
|
|
265
|
+
}>;
|
|
266
|
+
/**
|
|
267
|
+
* POST /auth/reset-password/customer/
|
|
268
|
+
* Verify OTP and reset customer password (business-scoped via headers).
|
|
269
|
+
*/
|
|
270
|
+
declare function resetPasswordCustomer(config: SdkConfig, payload: CustomerResetPasswordPayload): Promise<{
|
|
271
|
+
detail: string;
|
|
272
|
+
}>;
|
|
273
|
+
/**
|
|
274
|
+
* POST /auth/customer/deactivate/
|
|
275
|
+
* Self-service account deactivation for customers.
|
|
276
|
+
*/
|
|
277
|
+
declare function deactivateCustomerAccount(config: SdkConfig, accessToken: string, payload?: CustomerDeactivatePayload): Promise<DeactivateAccountResult>;
|
|
278
|
+
/**
|
|
279
|
+
* POST /auth/customer/reactivate/
|
|
280
|
+
* Request reactivation code for a deactivated customer account.
|
|
281
|
+
*/
|
|
282
|
+
declare function requestCustomerReactivation(config: SdkConfig, payload: CustomerReactivatePayload): Promise<{
|
|
283
|
+
detail: string;
|
|
284
|
+
}>;
|
|
285
|
+
/**
|
|
286
|
+
* POST /auth/customer/reactivate/verify/
|
|
287
|
+
* Verify reactivation OTP and restore customer account.
|
|
288
|
+
*/
|
|
289
|
+
declare function verifyCustomerReactivation(config: SdkConfig, payload: CustomerReactivateVerifyPayload): Promise<{
|
|
290
|
+
detail: string;
|
|
291
|
+
}>;
|
|
292
|
+
/** Map kasuvia-auth UserSerializer response to storefront CustomerUser. */
|
|
293
|
+
declare function mapAuthUserToCustomer(data: AuthUserResponse, provider?: CustomerUser['provider']): CustomerUser;
|
|
294
|
+
/** GET /auth/profile/ */
|
|
295
|
+
declare function getMe(config?: SdkConfig, accessToken?: string): Promise<CustomerUser>;
|
|
296
|
+
/** GET /auth/profile/ - alias for getMe for backward compatibility */
|
|
297
|
+
declare function getAuthUser(config?: SdkConfig, accessToken?: string): Promise<AuthUserResponse>;
|
|
298
|
+
/** PUT /auth/profile/ — update firstname, lastname, phone */
|
|
299
|
+
declare function updateProfile(configOrPayload: SdkConfig | UpdateProfilePayload, accessTokenOrPayload?: string | UpdateProfilePayload, payloadParam?: UpdateProfilePayload): Promise<CustomerUser>;
|
|
300
|
+
/**
|
|
301
|
+
* POST /auth/change-password/ — identity-mode-agnostic; the backend
|
|
302
|
+
* branches on the JWT's identity_mode (kasuvia-auth/authentication/api/v1/
|
|
303
|
+
* views/core.py:353, ChangePasswordView) to mutate the right underlying
|
|
304
|
+
* profile (customer/staff/owner). Used here for a logged-in storefront
|
|
305
|
+
* customer. `old_password` may be omitted only if the account genuinely has
|
|
306
|
+
* no password yet (a social/passwordless-only customer setting one for the
|
|
307
|
+
* first time) — the backend itself enforces this, not the frontend.
|
|
308
|
+
*/
|
|
309
|
+
declare function changePassword(config: SdkConfig, accessToken: string, payload: ChangePasswordPayload): Promise<{
|
|
310
|
+
detail: string;
|
|
311
|
+
}>;
|
|
312
|
+
/**
|
|
313
|
+
* GET /auth/storefront/business-info/
|
|
314
|
+
* Public, unauthenticated — only needs the storefront key (no access token,
|
|
315
|
+
* no X-Business-ID; PublicBusinessInfoView resolves the business from the
|
|
316
|
+
* key itself). Real gap fixed 2026-09-17: this endpoint existed on the
|
|
317
|
+
* backend with zero SDK coverage.
|
|
318
|
+
*/
|
|
319
|
+
declare function getStorefrontBusinessInfo(config: SdkConfig): Promise<StorefrontBusinessInfo>;
|
|
320
|
+
interface PresignedUploadUrlParams {
|
|
321
|
+
filename: string;
|
|
322
|
+
content_type: string;
|
|
323
|
+
business_id: string;
|
|
324
|
+
context: string;
|
|
325
|
+
entity_id: string;
|
|
326
|
+
owner_id?: string;
|
|
327
|
+
affiliation?: string;
|
|
328
|
+
}
|
|
329
|
+
interface PresignedUploadUrlResponse {
|
|
330
|
+
presigned_url: string;
|
|
331
|
+
storage_path: string;
|
|
332
|
+
bucket: string;
|
|
333
|
+
expires_in: number;
|
|
334
|
+
asset_id?: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* POST /auth/media/presigned-url/ — kasuvia-auth's thin proxy in front of
|
|
338
|
+
* kasuvia-media-system. Params are sent as a query string (not a JSON
|
|
339
|
+
* body) to match every other caller of this endpoint.
|
|
340
|
+
*/
|
|
341
|
+
declare function getPresignedUploadUrl(config: SdkConfig, accessToken: string, params: PresignedUploadUrlParams): Promise<PresignedUploadUrlResponse>;
|
|
342
|
+
interface ConfirmMediaUploadParams {
|
|
343
|
+
storage_path: string;
|
|
344
|
+
business_id: string;
|
|
345
|
+
entity_id: string;
|
|
346
|
+
original_filename: string;
|
|
347
|
+
content_type: string;
|
|
348
|
+
size: number;
|
|
349
|
+
context: string;
|
|
350
|
+
owner_id?: string;
|
|
351
|
+
affiliation?: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* POST /auth/media/confirm-upload/ — confirms a completed direct-to-R2
|
|
355
|
+
* upload and returns the resulting MediaAsset. Params are sent as a query
|
|
356
|
+
* string (not a JSON body) to match every other caller of this endpoint.
|
|
357
|
+
*/
|
|
358
|
+
declare function confirmMediaUpload(config: SdkConfig, accessToken: string, params: ConfirmMediaUploadParams): Promise<MediaAsset>;
|
|
359
|
+
/**
|
|
360
|
+
* Silently refresh the access token on app boot.
|
|
361
|
+
* Builds CustomerUser from JWT claims — no additional profile API call needed.
|
|
362
|
+
* Returns null if no refresh token exists or if the refresh fails.
|
|
363
|
+
*/
|
|
364
|
+
declare function silentRefresh(config: SdkConfig, refresh: string): Promise<{
|
|
365
|
+
user: CustomerUser;
|
|
366
|
+
provider: CustomerUser['provider'];
|
|
367
|
+
newAccessToken: string;
|
|
368
|
+
newRefreshToken: string;
|
|
369
|
+
} | null>;
|
|
370
|
+
/**
|
|
371
|
+
* Store tokens in localStorage (client-side utility)
|
|
372
|
+
* This is a convenience function for storefronts to store auth tokens
|
|
373
|
+
*/
|
|
374
|
+
declare function storeTokens(accessToken: string, refreshToken: string): void;
|
|
375
|
+
/**
|
|
376
|
+
* Clear tokens from localStorage (client-side utility)
|
|
377
|
+
*/
|
|
378
|
+
declare function clearTokens(): void;
|
|
379
|
+
/**
|
|
380
|
+
* Get stored tokens from localStorage (client-side utility)
|
|
381
|
+
*/
|
|
382
|
+
declare function getStoredTokens(): {
|
|
383
|
+
accessToken: string | null;
|
|
384
|
+
refreshToken: string | null;
|
|
385
|
+
};
|
|
386
|
+
/** GET /auth/profile/addresses/ */
|
|
387
|
+
declare function getCustomerAddresses(config: SdkConfig, accessToken: string): Promise<CustomerAddress[]>;
|
|
388
|
+
/** POST /auth/profile/addresses/ */
|
|
389
|
+
declare function createCustomerAddress(config: SdkConfig, accessToken: string, payload: CreateCustomerAddressPayload): Promise<CustomerAddress>;
|
|
390
|
+
/** PATCH /auth/profile/addresses/{id}/ */
|
|
391
|
+
declare function updateCustomerAddress(config: SdkConfig, accessToken: string, addressId: string, payload: UpdateCustomerAddressPayload): Promise<CustomerAddress>;
|
|
392
|
+
/** DELETE /auth/profile/addresses/{id}/ */
|
|
393
|
+
declare function deleteCustomerAddress(config: SdkConfig, accessToken: string, addressId: string): Promise<void>;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Product Service
|
|
397
|
+
*
|
|
398
|
+
* Handles product operations using GraphQL.
|
|
399
|
+
* Stateless - all configuration passed as parameters.
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Create GraphQL client with provided config
|
|
404
|
+
*/
|
|
405
|
+
/**
|
|
406
|
+
* Fetch all active products for the storefront.
|
|
407
|
+
*/
|
|
408
|
+
declare function getStorefrontProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
409
|
+
/**
|
|
410
|
+
* Fetch a single product by slug for the storefront.
|
|
411
|
+
*/
|
|
412
|
+
declare function getStorefrontProductBySlug(config: SdkConfig, slug: string): Promise<Product>;
|
|
413
|
+
/**
|
|
414
|
+
* Fetch popular products for the storefront.
|
|
415
|
+
*/
|
|
416
|
+
declare function getPopularProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
417
|
+
/**
|
|
418
|
+
* Fetch featured products for the storefront.
|
|
419
|
+
*/
|
|
420
|
+
declare function getFeaturedProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
421
|
+
/**
|
|
422
|
+
* Fetch new products for the storefront.
|
|
423
|
+
*/
|
|
424
|
+
declare function getNewProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
425
|
+
/**
|
|
426
|
+
* Fetch products currently on sale for the storefront.
|
|
427
|
+
*/
|
|
428
|
+
declare function getOnSaleProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
429
|
+
/**
|
|
430
|
+
* Fetch recommended products for the storefront.
|
|
431
|
+
* Returns featured, popular, and new products.
|
|
432
|
+
* Optionally excludes a specific product ID.
|
|
433
|
+
*/
|
|
434
|
+
declare function getRecommendedProducts(config: SdkConfig, params?: ListParams & {
|
|
435
|
+
excludeProductId?: string;
|
|
436
|
+
}): Promise<PaginatedResponse<Product>>;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Collection Service
|
|
440
|
+
*
|
|
441
|
+
* Handles collection operations using GraphQL.
|
|
442
|
+
* Stateless - all configuration passed as parameters.
|
|
443
|
+
*/
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Fetch paginated active collections for the storefront.
|
|
447
|
+
*/
|
|
448
|
+
declare function getStorefrontCollections(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Collection>>;
|
|
449
|
+
/**
|
|
450
|
+
* Fetch a single collection by its slug.
|
|
451
|
+
*/
|
|
452
|
+
declare function getStorefrontCollectionBySlug(config: SdkConfig, slug: string): Promise<Collection>;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Wishlist Service
|
|
456
|
+
*
|
|
457
|
+
* Handles wishlist operations.
|
|
458
|
+
* Stateless - all configuration passed as parameters.
|
|
459
|
+
*/
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Fetch the customer's wishlist for the current business.
|
|
463
|
+
*/
|
|
464
|
+
declare function getWishlist(config: SdkConfig, accessToken: string, params?: {
|
|
465
|
+
page?: number;
|
|
466
|
+
pageSize?: number;
|
|
467
|
+
}): Promise<WishlistListResponse>;
|
|
468
|
+
/**
|
|
469
|
+
* Check if a product is in the customer's wishlist.
|
|
470
|
+
*/
|
|
471
|
+
declare function checkInWishlist(config: SdkConfig, accessToken: string, productId: string): Promise<WishlistCheckResponse>;
|
|
472
|
+
/**
|
|
473
|
+
* Add a product to the customer's wishlist.
|
|
474
|
+
*/
|
|
475
|
+
declare function addToWishlist(config: SdkConfig, accessToken: string, productId: string, notes?: string): Promise<WishlistItem>;
|
|
476
|
+
/**
|
|
477
|
+
* Remove an item from the customer's wishlist by item ID.
|
|
478
|
+
*/
|
|
479
|
+
declare function removeFromWishlist(config: SdkConfig, accessToken: string, itemId: string): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* Remove a product from the customer's wishlist by product ID.
|
|
482
|
+
*/
|
|
483
|
+
declare function removeProductFromWishlist(config: SdkConfig, accessToken: string, productId: string): Promise<void>;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Payment Service
|
|
487
|
+
*
|
|
488
|
+
* Customer-facing payment API for payment initiation and verification via
|
|
489
|
+
* kasuvia-payment-system-go.
|
|
490
|
+
* Stateless - all configuration passed as parameters.
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Fetch available payment methods and gateways for a storefront region.
|
|
495
|
+
*
|
|
496
|
+
* REAL BUG FIXED (2026-09-22): `currency`/`countryCode` used to default to
|
|
497
|
+
* 'NGN'/'NG' as SDK-level JS defaults — an independent copy of a value the
|
|
498
|
+
* real backend already declares itself (`query:"currency" default:"NGN"` /
|
|
499
|
+
* `query:"country_code" default:"NG"`, kasuvia-payment-system-go's own real,
|
|
500
|
+
* documented default for this route). Duplicating it client-side risks the
|
|
501
|
+
* two silently drifting apart if the backend's real default is ever
|
|
502
|
+
* changed. Now optional with no client-side default at all — when omitted,
|
|
503
|
+
* the query param is left out entirely and the backend's own declared
|
|
504
|
+
* default applies, the single source of truth for what "unspecified"
|
|
505
|
+
* means here.
|
|
506
|
+
*/
|
|
507
|
+
declare function getAvailablePaymentMethods(config: SdkConfig, currency?: string, countryCode?: string): Promise<GatewayMethods[]>;
|
|
508
|
+
/**
|
|
509
|
+
* Create a Monnify Dedicated Virtual Account so the customer can pay via
|
|
510
|
+
* bank transfer. Note: Monnify DVA only supports NGN currency - the backend
|
|
511
|
+
* will reject non-NGN requests for this payment method.
|
|
512
|
+
*/
|
|
513
|
+
declare function createDedicatedAccount(config: SdkConfig, accessToken: string | null | undefined, request: DVACreateRequest): Promise<DVADetails>;
|
|
514
|
+
/**
|
|
515
|
+
* Initiate a payment (customer → business owner).
|
|
516
|
+
* Routes to Monnify, Flutterwave, or Paystack on the backend based on region/selection.
|
|
517
|
+
* Returns a checkout_url to redirect the customer to the gateway.
|
|
518
|
+
*/
|
|
519
|
+
declare function initiatePayment(config: SdkConfig, accessToken: string | null | undefined, request: PaymentInitiateRequest): Promise<PaymentInitiateResponse>;
|
|
520
|
+
/**
|
|
521
|
+
* Verify a payment after the gateway redirects back to /checkout/verify.
|
|
522
|
+
*/
|
|
523
|
+
declare function verifyTransaction(config: SdkConfig, reference: string): Promise<TransactionVerifyResponse>;
|
|
524
|
+
/**
|
|
525
|
+
* Poll transaction status by internal transaction ID.
|
|
526
|
+
*/
|
|
527
|
+
declare function getTransactionStatus(config: SdkConfig, transactionId: string): Promise<TransactionVerifyResponse>;
|
|
528
|
+
/**
|
|
529
|
+
* Fetch authenticated customer's wallet balance.
|
|
530
|
+
*/
|
|
531
|
+
declare function getWalletBalance(config: SdkConfig, accessToken: string): Promise<WalletBalanceResponse>;
|
|
532
|
+
/**
|
|
533
|
+
* Fetch authenticated customer's wallet ledger (transaction history).
|
|
534
|
+
*/
|
|
535
|
+
declare function getWalletLedger(config: SdkConfig, accessToken: string, params?: {
|
|
536
|
+
page?: number;
|
|
537
|
+
page_size?: number;
|
|
538
|
+
}): Promise<WalletLedgerResponse>;
|
|
539
|
+
/**
|
|
540
|
+
* Claim a pending guest wallet credit into the authenticated customer's wallet.
|
|
541
|
+
*/
|
|
542
|
+
declare function claimWalletCredit(config: SdkConfig, accessToken: string, claimToken: string): Promise<WalletBalanceResponse>;
|
|
543
|
+
declare const paymentService: {
|
|
544
|
+
readonly getAvailablePaymentMethods: typeof getAvailablePaymentMethods;
|
|
545
|
+
readonly createDedicatedAccount: typeof createDedicatedAccount;
|
|
546
|
+
readonly initiatePayment: typeof initiatePayment;
|
|
547
|
+
readonly verifyTransaction: typeof verifyTransaction;
|
|
548
|
+
readonly getTransactionStatus: typeof getTransactionStatus;
|
|
549
|
+
readonly getWalletBalance: typeof getWalletBalance;
|
|
550
|
+
readonly getWalletLedger: typeof getWalletLedger;
|
|
551
|
+
readonly claimWalletCredit: typeof claimWalletCredit;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Logistics Service
|
|
556
|
+
*
|
|
557
|
+
* Handles shipping rates and address validation.
|
|
558
|
+
* Stateless - all configuration passed as parameters.
|
|
559
|
+
*/
|
|
560
|
+
|
|
561
|
+
interface RateAddress {
|
|
562
|
+
city: string;
|
|
563
|
+
state: string;
|
|
564
|
+
country: string;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* REAL BUG FIXED (2026-09-20): this request shape used to be `{cart_items,
|
|
568
|
+
* origin_address, destination_address, currency?, shipping_method?}` —
|
|
569
|
+
* completely stale against the real backend. Confirmed against the real
|
|
570
|
+
* Pydantic schema (kasuvia-store-management/app/schemas/logistics.py:121-144,
|
|
571
|
+
* `ShippingRatesRequest`), which explicitly documents why: "No origin_address
|
|
572
|
+
* field — the server resolves the fulfilling StoreLocation itself... A
|
|
573
|
+
* client-supplied origin would either have to be silently ignored or
|
|
574
|
+
* silently trusted over the resolved location; neither is acceptable, so it
|
|
575
|
+
* isn't accepted at all." The server also fetches cart items itself from
|
|
576
|
+
* `cart_id` (server-side cart as source of truth, preventing client-side
|
|
577
|
+
* cart manipulation) rather than trusting a client-submitted item list.
|
|
578
|
+
* Sending the old shape meant every physical checkout's shipping-rates call
|
|
579
|
+
* was missing the required `cart_id` field entirely and would always 422.
|
|
580
|
+
*/
|
|
581
|
+
interface ShippingRatesRequest {
|
|
582
|
+
cart_id: string;
|
|
583
|
+
destination_address: RateAddress;
|
|
584
|
+
currency: string;
|
|
585
|
+
shipping_method?: 'carrier' | 'self_pickup';
|
|
586
|
+
/** Required when shipping_method is 'self_pickup' — see GET /logistics/pickup-locations. */
|
|
587
|
+
pickup_location_id?: string;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Fetch shipping rates for a cart.
|
|
591
|
+
*/
|
|
592
|
+
declare function getShippingRates(config: SdkConfig, payload: ShippingRatesRequest): Promise<ShippingRatesResponse>;
|
|
593
|
+
/**
|
|
594
|
+
* Result of independently forward-geocoding the typed street address via
|
|
595
|
+
* LocationIQ and cross-checking it against Terminal Africa's own (city/
|
|
596
|
+
* state/country-only, street-line-blind) validation. See
|
|
597
|
+
* app/services/address_trust_service.py on the backend. Only present when
|
|
598
|
+
* Terminal Africa itself reported the address valid.
|
|
599
|
+
*/
|
|
600
|
+
interface AddressTrustResult {
|
|
601
|
+
trusted: boolean;
|
|
602
|
+
confidence: 'high' | 'medium' | 'low' | 'unavailable';
|
|
603
|
+
reason: string | null;
|
|
604
|
+
resolved: {
|
|
605
|
+
latitude: number;
|
|
606
|
+
longitude: number;
|
|
607
|
+
display_name: string;
|
|
608
|
+
city: string | null;
|
|
609
|
+
state: string | null;
|
|
610
|
+
country: string | null;
|
|
611
|
+
} | null;
|
|
612
|
+
plus_code: string | null;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Validate a shipping address.
|
|
616
|
+
*/
|
|
617
|
+
declare function validateShippingAddress(config: SdkConfig, payload: {
|
|
618
|
+
first_name: string;
|
|
619
|
+
last_name: string;
|
|
620
|
+
phone: string;
|
|
621
|
+
address_line1: string;
|
|
622
|
+
address_line2?: string;
|
|
623
|
+
city: string;
|
|
624
|
+
state: string;
|
|
625
|
+
country: string;
|
|
626
|
+
postal_code?: string;
|
|
627
|
+
}): Promise<{
|
|
628
|
+
valid: boolean;
|
|
629
|
+
message?: string;
|
|
630
|
+
errorType?: 'state' | 'city' | 'general';
|
|
631
|
+
data?: unknown;
|
|
632
|
+
cities?: Array<{
|
|
633
|
+
name: string;
|
|
634
|
+
city_id: string;
|
|
635
|
+
stateCode: string;
|
|
636
|
+
countryCode: string;
|
|
637
|
+
}>;
|
|
638
|
+
states?: Array<{
|
|
639
|
+
name: string;
|
|
640
|
+
code: string;
|
|
641
|
+
countryCode: string;
|
|
642
|
+
}>;
|
|
643
|
+
/** Street-level trust check — only present when valid is true. See AddressTrustResult. */
|
|
644
|
+
address_trust?: AddressTrustResult;
|
|
645
|
+
}>;
|
|
646
|
+
interface PickupLocation {
|
|
647
|
+
id: string;
|
|
648
|
+
name: string;
|
|
649
|
+
description: string | null;
|
|
650
|
+
address: {
|
|
651
|
+
line1: string;
|
|
652
|
+
line2: string | null;
|
|
653
|
+
city: string;
|
|
654
|
+
state: string;
|
|
655
|
+
country: string;
|
|
656
|
+
postal_code: string;
|
|
657
|
+
};
|
|
658
|
+
coordinates: {
|
|
659
|
+
latitude: number;
|
|
660
|
+
longitude: number;
|
|
661
|
+
};
|
|
662
|
+
/** km from the coordinates passed to listPickupLocations, or null if none were passed. */
|
|
663
|
+
distance_km: number | null;
|
|
664
|
+
operating_hours: Record<string, string> | null;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* List the business's active pickup locations, so the customer can choose
|
|
668
|
+
* one at checkout for shipping_method="self_pickup" instead of the merchant
|
|
669
|
+
* assigning one blindly after the fact. Pass the customer's shipping
|
|
670
|
+
* coordinates to sort nearest-first.
|
|
671
|
+
*/
|
|
672
|
+
interface PickupLocationsResult {
|
|
673
|
+
locations: PickupLocation[];
|
|
674
|
+
}
|
|
675
|
+
declare function listPickupLocations(config: SdkConfig, coords?: {
|
|
676
|
+
latitude: number;
|
|
677
|
+
longitude: number;
|
|
678
|
+
}): Promise<PickupLocationsResult>;
|
|
679
|
+
/**
|
|
680
|
+
* List ALL of the business's active locations (not just pickup-eligible
|
|
681
|
+
* ones) — the set a customer needs to choose from for an 'at_business'
|
|
682
|
+
* service appointment when the business runs more than one branch. Sibling
|
|
683
|
+
* of listPickupLocations, same response shape (PickupLocationsResult),
|
|
684
|
+
* different backend filter (GET /logistics/locations, no
|
|
685
|
+
* is_pickup_location gate).
|
|
686
|
+
*/
|
|
687
|
+
declare function listBusinessLocations(config: SdkConfig, coords?: {
|
|
688
|
+
latitude: number;
|
|
689
|
+
longitude: number;
|
|
690
|
+
}): Promise<PickupLocationsResult>;
|
|
691
|
+
/**
|
|
692
|
+
* Reverse geocode coordinates to address components using backend LocationIQ service.
|
|
693
|
+
*/
|
|
694
|
+
interface ReverseGeocodeResult {
|
|
695
|
+
city: string | null;
|
|
696
|
+
state: string | null;
|
|
697
|
+
country: string | null;
|
|
698
|
+
country_code: string | null;
|
|
699
|
+
display_name: string | null;
|
|
700
|
+
}
|
|
701
|
+
declare function reverseGeocode(config: SdkConfig, payload: {
|
|
702
|
+
latitude: number;
|
|
703
|
+
longitude: number;
|
|
704
|
+
}): Promise<ReverseGeocodeResult>;
|
|
705
|
+
/**
|
|
706
|
+
* Decode a Plus Code to coordinates.
|
|
707
|
+
*/
|
|
708
|
+
interface PlusCodeDecodeResult {
|
|
709
|
+
latitude: number;
|
|
710
|
+
longitude: number;
|
|
711
|
+
latitude_lo: number;
|
|
712
|
+
longitude_hi: number;
|
|
713
|
+
plus_code: string;
|
|
714
|
+
}
|
|
715
|
+
declare function decodePlusCode(config: SdkConfig, payload: {
|
|
716
|
+
plus_code: string;
|
|
717
|
+
}): Promise<PlusCodeDecodeResult>;
|
|
718
|
+
/**
|
|
719
|
+
* As-you-type address autocomplete suggestions.
|
|
720
|
+
*/
|
|
721
|
+
interface AddressSuggestionResult {
|
|
722
|
+
place_id: string;
|
|
723
|
+
display_name: string;
|
|
724
|
+
line1: string;
|
|
725
|
+
city: string | null;
|
|
726
|
+
state: string | null;
|
|
727
|
+
postal_code: string | null;
|
|
728
|
+
country: string | null;
|
|
729
|
+
country_code: string | null;
|
|
730
|
+
latitude: number | null;
|
|
731
|
+
longitude: number | null;
|
|
732
|
+
}
|
|
733
|
+
interface AddressAutocompleteResult {
|
|
734
|
+
results: AddressSuggestionResult[];
|
|
735
|
+
}
|
|
736
|
+
declare function autocompleteAddress(config: SdkConfig, q: string, country?: string): Promise<AddressAutocompleteResult>;
|
|
737
|
+
declare const logisticsService: {
|
|
738
|
+
getShippingRates: typeof getShippingRates;
|
|
739
|
+
validateShippingAddress: typeof validateShippingAddress;
|
|
740
|
+
listPickupLocations: typeof listPickupLocations;
|
|
741
|
+
listBusinessLocations: typeof listBusinessLocations;
|
|
742
|
+
reverseGeocode: typeof reverseGeocode;
|
|
743
|
+
decodePlusCode: typeof decodePlusCode;
|
|
744
|
+
autocompleteAddress: typeof autocompleteAddress;
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Bespoke Service
|
|
749
|
+
*
|
|
750
|
+
* Handles bespoke product availability checks and the buyer side of the
|
|
751
|
+
* bespoke order deliverable proofing flow.
|
|
752
|
+
* Stateless - all configuration passed as parameters.
|
|
753
|
+
*/
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* REAL BUG FIXED (2026-09-20): was calling `/bespoke/availability/{id}` —
|
|
757
|
+
* missing the `/capacity` segment. Confirmed against the real router
|
|
758
|
+
* (kasuvia-store-management/app/api/v1/endpoints/bespoke/capacity.py:184,
|
|
759
|
+
* registered under the `/bespoke/capacity` prefix): the real route is
|
|
760
|
+
* `/bespoke/capacity/availability/{id}`. Every bespoke availability check
|
|
761
|
+
* was 404ing.
|
|
762
|
+
*/
|
|
763
|
+
declare function checkAvailability(config: SdkConfig, product_id: string): Promise<BespokeAvailability>;
|
|
764
|
+
/**
|
|
765
|
+
* POST /orders/{order_id}/bespoke/approve — buyer approves the seller's
|
|
766
|
+
* submitted deliverable, starting the escrow release clock.
|
|
767
|
+
*/
|
|
768
|
+
declare function approveBespokeDeliverable(config: SdkConfig, accessToken: string, orderId: string): Promise<BespokeDeliverableStatus>;
|
|
769
|
+
/**
|
|
770
|
+
* POST /orders/{order_id}/bespoke/request-revision — buyer asks the seller
|
|
771
|
+
* to revise the submitted deliverable. Capped at 2 revisions server-side;
|
|
772
|
+
* beyond that, the backend escalates to manual review rather than refusing
|
|
773
|
+
* silently (see the real endpoint's own doc comment).
|
|
774
|
+
*/
|
|
775
|
+
declare function requestBespokeRevision(config: SdkConfig, accessToken: string, orderId: string, notes: string): Promise<BespokeDeliverableStatus>;
|
|
776
|
+
declare const bespokeService: {
|
|
777
|
+
checkAvailability: typeof checkAvailability;
|
|
778
|
+
approveBespokeDeliverable: typeof approveBespokeDeliverable;
|
|
779
|
+
requestBespokeRevision: typeof requestBespokeRevision;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* App Service
|
|
784
|
+
*
|
|
785
|
+
* Handles translation and other app-level utilities.
|
|
786
|
+
*/
|
|
787
|
+
declare function googleTranslate(text: string, target: string, source?: string): Promise<string>;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Config Service
|
|
791
|
+
*
|
|
792
|
+
* Handles configuration endpoints (languages, currencies, locales, business config).
|
|
793
|
+
* Stateless - all configuration passed as parameters.
|
|
794
|
+
*/
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Fetch supported languages from the payment system.
|
|
798
|
+
* Resolves to: {kasuviaPaymentBackendUrl}/config/supported-languages
|
|
799
|
+
*/
|
|
800
|
+
declare function getSupportedLanguages(config: SdkConfig): Promise<SupportedLanguagesResponse>;
|
|
801
|
+
/**
|
|
802
|
+
* Fetch supported currencies from the payment system.
|
|
803
|
+
* Resolves to: {kasuviaPaymentBackendUrl}/config/supported-currencies
|
|
804
|
+
*/
|
|
805
|
+
declare function getSupportedCurrencies(config: SdkConfig): Promise<SupportedCurrenciesResponse>;
|
|
806
|
+
/**
|
|
807
|
+
* Fetch the business's public configuration, including store_currency.
|
|
808
|
+
* Uses storefront API key header (X-Storefront-Key).
|
|
809
|
+
* Resolves to: {kasuviaAuthBackendUrl}/internal/businesses/{business_id}/
|
|
810
|
+
* This endpoint is designed for storefronts to fetch business config using their storefront API key.
|
|
811
|
+
*/
|
|
812
|
+
declare function getBusinessConfig(config: SdkConfig): Promise<BusinessConfig>;
|
|
813
|
+
declare const configService: {
|
|
814
|
+
readonly getSupportedLanguages: typeof getSupportedLanguages;
|
|
815
|
+
readonly getSupportedCurrencies: typeof getSupportedCurrencies;
|
|
816
|
+
readonly getBusinessConfig: typeof getBusinessConfig;
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* CMS Service
|
|
821
|
+
*
|
|
822
|
+
* Handles CMS model and entry operations using the kasuvia-cms SDK endpoints.
|
|
823
|
+
* Protected by X-Storefront-Key and X-Business-ID headers.
|
|
824
|
+
* Stateless - all configuration passed as parameters.
|
|
825
|
+
*
|
|
826
|
+
* REAL BUG FIXED (2026-09-21), live-reproduced: every URL here used
|
|
827
|
+
* `config.businessId` (the public BID, e.g. "B-2W9EC07") as the
|
|
828
|
+
* `{business_id}` path segment. kasuvia-cms's SDK routes
|
|
829
|
+
* (`app/core/security/base.py`'s `get_storefront_business_uuid`, used by
|
|
830
|
+
* every route in `cms_sdk.py`) explicitly require the INTERNAL UUID there —
|
|
831
|
+
* "CmsModel/CmsEntry documents are keyed by the UUID business_id... SDK
|
|
832
|
+
* routes need this, not the BID" (its own docstring) — and 403s with
|
|
833
|
+
* "Business ID mismatch" on anything else. Every CMS entry call from the
|
|
834
|
+
* storefront has been failing since the feature was built. Fixed by
|
|
835
|
+
* requiring an explicit `businessUuid` parameter (resolved via
|
|
836
|
+
* `getBusinessConfig`'s real `business_id` field, cached by
|
|
837
|
+
* `useBusinessConfig()` at the hook layer) instead of silently reusing the
|
|
838
|
+
* wrong config field.
|
|
839
|
+
*/
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* List CMS entries for a specific model.
|
|
843
|
+
* Requires public_api.read permission on the model.
|
|
844
|
+
*/
|
|
845
|
+
declare function listCmsEntries(config: SdkConfig, businessUuid: string, modelSlug: string, params?: ListCmsEntriesParams): Promise<CmsEntryListResponse>;
|
|
846
|
+
/**
|
|
847
|
+
* Get a single CMS entry by ID.
|
|
848
|
+
* Requires public_api.read permission on the model.
|
|
849
|
+
*/
|
|
850
|
+
declare function getCmsEntry(config: SdkConfig, businessUuid: string, modelSlug: string, entryId: string): Promise<CmsEntry>;
|
|
851
|
+
/**
|
|
852
|
+
* Create a new CMS entry.
|
|
853
|
+
* Requires public_api.create permission on the model.
|
|
854
|
+
*/
|
|
855
|
+
declare function createCmsEntry(config: SdkConfig, businessUuid: string, accessToken: string, modelSlug: string, params: CreateCmsEntryParams): Promise<CmsEntry>;
|
|
856
|
+
/**
|
|
857
|
+
* Update an existing CMS entry.
|
|
858
|
+
* Requires public_api.update permission on the model.
|
|
859
|
+
*/
|
|
860
|
+
declare function updateCmsEntry(config: SdkConfig, businessUuid: string, accessToken: string, modelSlug: string, entryId: string, params: UpdateCmsEntryParams): Promise<CmsEntry>;
|
|
861
|
+
/**
|
|
862
|
+
* Delete a CMS entry.
|
|
863
|
+
* Requires public_api.delete permission on the model.
|
|
864
|
+
*/
|
|
865
|
+
declare function deleteCmsEntry(config: SdkConfig, businessUuid: string, accessToken: string, modelSlug: string, entryId: string): Promise<void>;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Legal Service
|
|
869
|
+
*
|
|
870
|
+
* Fetches this business's own currently-active storefront legal document
|
|
871
|
+
* (Terms, Privacy, or Refund Policy) from kasuvia-cms — public, no auth,
|
|
872
|
+
* the same endpoint the registration flow's consent record is checked against
|
|
873
|
+
* (see kasuvia-auth's CustomerTermsAcceptance).
|
|
874
|
+
*
|
|
875
|
+
* website-builder-system auto-generates storefront_terms/storefront_privacy
|
|
876
|
+
* the first time a business publishes (_ensure_storefront_legal_documents).
|
|
877
|
+
* A business that hasn't published yet, or whose auto-generation failed,
|
|
878
|
+
* genuinely has none yet. Returns null in that case rather than throwing;
|
|
879
|
+
* the page decides how to render that honestly — never substituting placeholder
|
|
880
|
+
* text for real legal text.
|
|
881
|
+
*/
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Fetch a storefront legal document from kasuvia-cms.
|
|
885
|
+
*
|
|
886
|
+
* REAL BUG FIXED (2026-09-22): took a raw `cmsBaseUrl` string instead of
|
|
887
|
+
* `SdkConfig` — the only function across this SDK's ~90 service functions
|
|
888
|
+
* that broke that convention, which is exactly why kasuvia-storefront's
|
|
889
|
+
* `lib/legal.ts` wrapper existed at all (bridging this one odd signature
|
|
890
|
+
* back to the app's real config). `businessUuid` is kept as its own
|
|
891
|
+
* explicit parameter rather than silently reading `config.businessId`:
|
|
892
|
+
* this real backend route (`GET /cms/legal/storefront/{business_id}/...`,
|
|
893
|
+
* confirmed against kasuvia-cms's `get_business_id` dependency and
|
|
894
|
+
* `MerchantLegalDocument.business_id` field) is keyed by the internal
|
|
895
|
+
* business UUID, never the public BID `config.businessId` actually is —
|
|
896
|
+
* the same UUID-vs-BID class of bug already found and fixed in
|
|
897
|
+
* `cms.service.ts`. Resolve it the same way (`useBusinessConfig`'s real
|
|
898
|
+
* `business_id` field) before calling this.
|
|
899
|
+
*
|
|
900
|
+
* @param config - SdkConfig; only `backendUrls.cms` is read from it here.
|
|
901
|
+
* @param businessUuid - The tenant's real business UUID (not the public BID).
|
|
902
|
+
* @param documentType - e.g. "storefront_terms", "storefront_privacy",
|
|
903
|
+
* "storefront_refund_policy"
|
|
904
|
+
* @param fetchOptions - Optional native fetch options (e.g. Next.js `next: { revalidate }`)
|
|
905
|
+
*/
|
|
906
|
+
declare function getMerchantLegalDocument(config: SdkConfig, businessUuid: string, documentType: string, fetchOptions?: RequestInit): Promise<MerchantLegalDocument | null>;
|
|
907
|
+
|
|
908
|
+
export { type AddressAutocompleteResult, type AddressSuggestionResult, type AddressTrustResult, Comment, CommentCreate, CommentModerationAction, CommentUpdate, type ConfirmMediaUploadParams, type LegalSection, type MerchantLegalDocument, MerchantReplyCreate, type PickupLocation, type PickupLocationsResult, type PlusCodeDecodeResult, type PresignedUploadUrlParams, type PresignedUploadUrlResponse, ProductCommentsResponse, ProductReviewsResponse, type RateAddress, type ReverseGeocodeResult, Review, ReviewCreate, ReviewModerationAction, ReviewUpdate, type ShippingRatesRequest, addToCart, addToGuestCart, addToWishlist, approveBespokeDeliverable, autocompleteAddress, bespokeService, changePassword, checkAvailability, checkInWishlist, claimWalletCredit, clearCart, clearGuestCart, clearTokens, configService, confirmMediaUpload, createCmsEntry, createComment, createCustomerAddress, createDedicatedAccount, createReview, deactivateCustomerAccount, decodePlusCode, deleteCmsEntry, deleteCustomerAddress, forgotPasswordCustomer, getAuthUser, getAvailablePaymentMethods, getBusinessConfig, getCart, getCmsEntry, getCustomerAddresses, getFeaturedProducts, getGuestCart, getGuestCartProductType, getMe, getMerchantLegalDocument, getNewProducts, getOnSaleProducts, getPendingComments, getPendingReviews, getPopularProducts, getPresignedUploadUrl, getProductComments, getProductReviews, getRecommendedProducts, getShippingRates, getStoredTokens, getStorefrontBusinessInfo, getStorefrontCollectionBySlug, getStorefrontCollections, getStorefrontProductBySlug, getStorefrontProducts, getSupportedCurrencies, getSupportedLanguages, getTransactionStatus, getWalletBalance, getWalletLedger, getWishlist, googleTranslate, initiatePayment, listBusinessLocations, listCmsEntries, listPickupLocations, loginCustomer, logisticsService, logout, mapAuthUserToCustomer, merchantReplyToReview, mergeGuestCart, mergeGuestCartIfPresent, moderateComment, moderateReview, paymentService, refreshToken, registerCustomer, removeFromCart, removeFromGuestCart, removeFromWishlist, removeProductFromWishlist, requestBespokeRevision, requestCustomerOtp, requestCustomerReactivation, resetPasswordCustomer, reverseGeocode, silentRefresh, storeTokens, updateCartItem, updateCmsEntry, updateComment, updateCustomerAddress, updateGuestCartItemQuantity, updateProfile, updateReview, validateShippingAddress, verifyCustomerOtp, verifyCustomerReactivation, verifySocialToken, verifyTransaction };
|