@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
package/src/config/index.ts
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kasuvia SDK Configuration
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Stateless configuration - no module-scoped state.
|
|
5
5
|
* All configuration is passed as parameters to SDK functions.
|
|
6
|
-
*
|
|
7
|
-
* SECURITY NOTE:
|
|
8
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* SECURITY NOTE: `backendUrls` must resolve to real backend hosts (e.g. https://kasuvia-auth-...
|
|
8
|
+
* .onrender.com/api/v1) ONLY in a config instance built for server-side use - never pass that
|
|
9
|
+
* instance into SdkProvider or any other client-rendered code. A consuming app should build TWO
|
|
10
|
+
* SdkConfig instances of this exact same shape: a server one (real URLs, for Next.js API routes /
|
|
11
|
+
* Server Components) and a client one (same-origin proxy paths like /api/proxy/store, safe for
|
|
12
|
+
* SdkProvider and any "use client" component).
|
|
13
|
+
*
|
|
14
|
+
* REAL GAP CLOSED (2026-09-17): this plain interface alone couldn't enforce that distinction -
|
|
15
|
+
* getting it backwards used to compile fine and fail at runtime instead (confirmed: kasuvia-storefront's
|
|
16
|
+
* ProductsListing.tsx imported the server instance into a "use client" file, which silently
|
|
17
|
+
* resolved backendUrls.store to '' in the browser bundle rather than erroring loudly - fixed
|
|
18
|
+
* 2026-09-03, but nothing here caught the next occurrence of the same mistake). Build the SERVER
|
|
19
|
+
* instance via `createServerSdkConfig` from '@kasuvia/sdk/config/server' instead of a plain object
|
|
20
|
+
* literal - that module is tagged `import 'server-only'` on its own isolated build entry, so
|
|
21
|
+
* Next.js's bundler refuses at BUILD TIME to include it in any "use client" file's module graph,
|
|
22
|
+
* closing this exact incident class instead of just documenting it. The client instance needs no
|
|
23
|
+
* such guard (proxy paths carry no secret/real-host material) - a plain object literal is fine.
|
|
9
24
|
*/
|
|
10
25
|
|
|
11
26
|
export interface SdkConfig {
|
|
12
27
|
businessId: string
|
|
13
28
|
storefrontApiKey: string
|
|
29
|
+
authToken?: string
|
|
14
30
|
backendUrls: {
|
|
15
31
|
auth: string
|
|
16
32
|
store: string
|
|
33
|
+
cart: string
|
|
17
34
|
payment: string
|
|
18
35
|
notifications: string
|
|
19
36
|
cms: string
|
|
37
|
+
crm: string
|
|
20
38
|
}
|
|
21
39
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// REAL GAP CLOSED (2026-09-17): SdkConfig's own file documents a real
|
|
2
|
+
// incident (kasuvia-storefront's ProductsListing.tsx importing the SERVER
|
|
3
|
+
// config instance — real backend URLs — into a "use client" file, silently
|
|
4
|
+
// resolving to '' in the browser bundle rather than failing loudly) and
|
|
5
|
+
// admits "This type alone can't enforce that distinction". A plain
|
|
6
|
+
// TypeScript interface can't — but `server-only` (the same sentinel package
|
|
7
|
+
// Next.js's own docs recommend for exactly this problem) can, at BUILD
|
|
8
|
+
// TIME: this file's mere existence as a leaf module, isolated on its own
|
|
9
|
+
// tsup entry/exports subpath (never re-exported from the main '@kasuvia/sdk'
|
|
10
|
+
// or '@kasuvia/sdk/config' entry, which would taint that whole module graph
|
|
11
|
+
// as server-only for every consumer), means importing it from a "use client"
|
|
12
|
+
// file makes Next.js's build fail immediately with a clear, actionable
|
|
13
|
+
// error — not a silent empty string discovered in production.
|
|
14
|
+
import 'server-only'
|
|
15
|
+
import type { SdkConfig } from './index'
|
|
16
|
+
|
|
17
|
+
export interface ServerBackendUrls {
|
|
18
|
+
auth: string
|
|
19
|
+
store: string
|
|
20
|
+
cart: string
|
|
21
|
+
payment: string
|
|
22
|
+
notifications: string
|
|
23
|
+
cms: string
|
|
24
|
+
crm: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Build the SERVER-side SdkConfig instance — real backend URLs, for Next.js
|
|
29
|
+
* API route handlers / Server Components only. Importing this function (or
|
|
30
|
+
* this module at all) from a "use client" file is a build error by design.
|
|
31
|
+
* For the client-safe instance (same-origin proxy paths), just construct a
|
|
32
|
+
* plain SdkConfig object directly — no factory needed, nothing to guard
|
|
33
|
+
* against, since there's no secret/real-host material in it.
|
|
34
|
+
*/
|
|
35
|
+
export function createServerSdkConfig(params: {
|
|
36
|
+
businessId: string
|
|
37
|
+
storefrontApiKey: string
|
|
38
|
+
backendUrls: ServerBackendUrls
|
|
39
|
+
}): SdkConfig {
|
|
40
|
+
return {
|
|
41
|
+
businessId: params.businessId,
|
|
42
|
+
storefrontApiKey: params.storefrontApiKey,
|
|
43
|
+
backendUrls: params.backendUrls,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -23,6 +23,8 @@ import type { SdkConfig } from '../config';
|
|
|
23
23
|
export interface SdkContextValue {
|
|
24
24
|
config: SdkConfig;
|
|
25
25
|
accessToken: string | null;
|
|
26
|
+
/** Current browser's guest cart session id (see utils/guest-session.ts) — null when unauthenticated context hasn't resolved one yet, or when the caller is authenticated and doesn't need one. */
|
|
27
|
+
guestSessionId?: string | null;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const SdkContext = createContext<SdkContextValue | null>(null);
|
|
@@ -30,12 +32,13 @@ const SdkContext = createContext<SdkContextValue | null>(null);
|
|
|
30
32
|
export interface SdkProviderProps {
|
|
31
33
|
config: SdkConfig;
|
|
32
34
|
accessToken: string | null;
|
|
35
|
+
guestSessionId?: string | null;
|
|
33
36
|
children: ReactNode;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
export function SdkProvider({ config, accessToken, children }: SdkProviderProps) {
|
|
39
|
+
export function SdkProvider({ config, accessToken, guestSessionId, children }: SdkProviderProps) {
|
|
37
40
|
return (
|
|
38
|
-
<SdkContext.Provider value={{ config, accessToken }}>
|
|
41
|
+
<SdkContext.Provider value={{ config, accessToken, guestSessionId }}>
|
|
39
42
|
{children}
|
|
40
43
|
</SdkContext.Provider>
|
|
41
44
|
);
|