@kasuvia/sdk 0.0.1 → 0.0.4
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 +1 -1
- package/dist/hooks/index.d.mts +429 -0
- package/dist/hooks/index.d.ts +429 -0
- package/dist/hooks/index.js +3073 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2962 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +279 -1152
- package/dist/index.d.ts +279 -1152
- package/dist/index.js +1471 -2208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1451 -2107
- package/dist/index.mjs.map +1 -1
- package/dist/sdk-context-Cy51kEKT.d.mts +565 -0
- package/dist/sdk-context-Cy51kEKT.d.ts +565 -0
- package/package.json +6 -2
- package/src/config/index.ts +10 -91
- package/src/constants.ts +13 -0
- package/src/context/sdk-context.tsx +70 -0
- package/src/graphql/collections.graphql.ts +2 -10
- package/src/graphql/products.graphql.ts +215 -65
- package/src/graphql/wishlist.graphql.ts +7 -6
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-auth.ts +82 -158
- package/src/hooks/use-bespoke-availability.ts +25 -8
- package/src/hooks/use-cart.ts +222 -119
- package/src/hooks/use-cms.ts +179 -86
- package/src/hooks/use-collections.ts +52 -15
- package/src/hooks/use-consultation-stream.ts +4 -3
- package/src/hooks/use-consultations.ts +120 -51
- package/src/hooks/use-countries.ts +35 -13
- package/src/hooks/use-currencies.ts +26 -13
- package/src/hooks/use-google-translate.ts +22 -8
- package/src/hooks/use-languages.ts +40 -20
- package/src/hooks/use-mobile.ts +23 -0
- package/src/hooks/use-order-stream.ts +9 -5
- package/src/hooks/use-orders.ts +99 -44
- package/src/hooks/use-payment.ts +108 -40
- package/src/hooks/use-products.ts +251 -53
- package/src/hooks/use-service-booking.ts +152 -90
- package/src/hooks/use-states.ts +35 -15
- package/src/hooks/use-wishlist.ts +92 -91
- package/src/index.ts +27 -28
- package/src/services/auth.service.ts +209 -167
- package/src/services/bespoke.service.ts +12 -4
- package/src/services/cart.service.ts +172 -70
- package/src/services/cms.service.ts +70 -35
- package/src/services/collection.service.ts +22 -5
- package/src/services/config.service.ts +34 -14
- package/src/services/consultation.service.ts +72 -18
- package/src/services/logistics.service.ts +35 -11
- package/src/services/notifications.service.ts +27 -12
- package/src/services/order.service.ts +74 -15
- package/src/services/payment.service.ts +86 -31
- package/src/services/product.service.ts +279 -39
- package/src/services/service-booking.service.ts +98 -26
- package/src/services/wishlist.service.ts +69 -25
- package/src/types/auth/index.ts +27 -4
- package/src/types/business/index.ts +7 -2
- package/src/types/payments/index.ts +3 -3
- package/src/types/services/index.ts +2 -5
- package/src/types/store/index.ts +44 -5
- package/src/utils/customer.ts +14 -0
- package/src/utils/error-handler.ts +10 -5
- package/src/utils/storage.ts +93 -0
- package/src/utils/validators.ts +85 -0
- package/src/client/authClient.ts +0 -135
- package/src/client/graphqlClient.ts +0 -53
- package/src/client/httpClient.ts +0 -298
package/dist/index.d.ts
CHANGED
|
@@ -1,119 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
1
|
+
import { l as ServiceLocationType, S as SdkConfig, C as CartResponse, a as CartItem, O as Order, m as CreateOrderParams, F as FindOrderParams, L as ListParams, n as PaginatedResponse, P as Product, o as Collection, W as WishlistItem, p as WishlistCheckResponse, q as WishlistListResponse, D as DVACreateRequest, s as DVADetails, T as TransactionVerifyResponse, t as PaymentInitiateRequest, v as PaymentInitiateResponse, w as ConversionQuote, x as ProductVariant, y as ShippingRatesResponse, z as SupportedLanguagesResponse, A as SupportedCurrenciesResponse, g as CreateCmsEntryParams, f as CmsEntry, h as ListCmsEntriesParams, B as CmsEntryListResponse, U as UpdateCmsEntryParams, E as CheckoutCustomer, G as ShippingLocation, H as DeliveryAddress } from './sdk-context-Cy51kEKT.js';
|
|
2
|
+
export { I as Address, J as AppContextValue, K as AppState, M as BackendLanguage, N as BespokeStageKey, Q as CmsField, R as CmsIcon, V as CmsIconListResponse, X as CmsModel, Y as CmsModelPermissions, Z as CmsModelPublicApiPermissions, b as Country, e as Currency, _ as CustomField, $ as Inventory, a0 as LangCode, a1 as OrderItem, a2 as OrderStatus, a3 as ProductType, i as SdkContextValue, j as SdkProvider, k as SdkProviderProps, a4 as ServiceLocationTypeEnum, a5 as ServiceRecurringInterval, a6 as ServiceRecurringIntervalEnum, a7 as ServiceType, a8 as ServiceTypeEnum, a9 as ShippingRate, c as State, d as SupportedLang, aa as Theme, u as useSdkContext } from './sdk-context-Cy51kEKT.js';
|
|
3
|
+
import 'react';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* SDK Constants
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
interface SdkConfig {
|
|
18
|
-
businessId: string;
|
|
19
|
-
storefrontApiKey: string;
|
|
20
|
-
}
|
|
21
|
-
interface SdkRuntimeConfig {
|
|
22
|
-
businessId: string;
|
|
23
|
-
storefrontApiKey: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Initialize the SDK with runtime credentials
|
|
27
|
-
* This must be called before any SDK operations
|
|
28
|
-
*
|
|
29
|
-
* IMPORTANT: In Next.js, this should be called in layout.tsx (server component)
|
|
30
|
-
* using private environment variables (kasuvia_BUSINESS_ID, kasuvia_STOREFRONT_API_KEY).
|
|
31
|
-
* The config is stored in module scope and will be available to client components
|
|
32
|
-
* through the SDK's bundled code.
|
|
33
|
-
*
|
|
34
|
-
* @param config - SDK configuration including credentials
|
|
35
|
-
*/
|
|
36
|
-
declare function initSdk(config: SdkConfig): void;
|
|
37
|
-
/**
|
|
38
|
-
* Get the current runtime configuration
|
|
39
|
-
* Throws if SDK is not initialized
|
|
40
|
-
*/
|
|
41
|
-
declare function getRuntimeConfig(): SdkRuntimeConfig;
|
|
42
|
-
/**
|
|
43
|
-
* Get backend URL for a specific service
|
|
44
|
-
* Internal use only - never exposed to storefront
|
|
45
|
-
*/
|
|
46
|
-
declare function getBackendUrl(service: 'auth' | 'store' | 'payment' | 'notifications' | 'cms'): string;
|
|
47
|
-
/**
|
|
48
|
-
* Check if SDK is initialized
|
|
49
|
-
*/
|
|
50
|
-
declare function isInitialized(): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Reset SDK configuration (mainly for testing)
|
|
53
|
-
*/
|
|
54
|
-
declare function resetConfig(): void;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* HTTP Client - Pre-configured Axios instances
|
|
58
|
-
*
|
|
59
|
-
* Each Axios instance is created with a default baseURL based on the static
|
|
60
|
-
* service URL. The baseURLs are complete URLs including the API version,
|
|
61
|
-
* selected based on the configured environment (development/production).
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
declare function getOrCreateGuestSessionId(): string;
|
|
65
|
-
declare function getGuestSessionId(): string | null;
|
|
66
|
-
declare function clearGuestSessionId(): void;
|
|
67
|
-
declare const storeManagementAxios: AxiosInstance;
|
|
68
|
-
declare const publicStoreAxios: AxiosInstance;
|
|
69
|
-
declare const authAxios: AxiosInstance;
|
|
70
|
-
declare const paymentAxios: AxiosInstance;
|
|
71
|
-
declare const cmsAxios: AxiosInstance;
|
|
72
|
-
/**
|
|
73
|
-
* configureHttpClients()
|
|
74
|
-
* Updates the baseURL of all Axios instances to match the configured environment.
|
|
75
|
-
* This must be called after initSdk() to ensure the correct environment URLs are used.
|
|
76
|
-
*/
|
|
77
|
-
declare function configureHttpClients(): void;
|
|
78
|
-
|
|
79
|
-
declare const tokenStore: {
|
|
80
|
-
readonly getAccessToken: () => string | null;
|
|
81
|
-
readonly setAccessToken: (token: string | null) => void;
|
|
82
|
-
readonly getRefreshToken: () => string | null;
|
|
83
|
-
readonly setRefreshToken: (token: string | null, remember?: boolean) => void;
|
|
84
|
-
readonly clearAll: () => void;
|
|
85
|
-
readonly hasSession: () => boolean;
|
|
86
|
-
readonly isPersistent: () => boolean;
|
|
8
|
+
* Centralized constants to avoid hardcoded strings across the codebase.
|
|
9
|
+
*/
|
|
10
|
+
declare const STORAGE_KEYS: {
|
|
11
|
+
readonly ACCESS_TOKEN: "kasuvia_access_token";
|
|
12
|
+
readonly REFRESH_TOKEN: "kasuvia_refresh_token";
|
|
13
|
+
readonly CHECKOUT_STATE: "kasuvia_checkout_state";
|
|
14
|
+
readonly ORDERS_LINKED: "kasuvia_orders_linked";
|
|
15
|
+
readonly STOREFRONT_STATE: "storefront_state_v3";
|
|
87
16
|
};
|
|
88
|
-
/**
|
|
89
|
-
* Perform token refresh with queue-coalescing to avoid parallel refresh races.
|
|
90
|
-
*/
|
|
91
|
-
declare function refreshToken(): Promise<string>;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* GraphQL Client
|
|
95
|
-
*
|
|
96
|
-
* Provides a GraphQL client with tenant and auth headers for product queries.
|
|
97
|
-
* The endpoint URL is derived from the static BACKEND_URLS constant (eager,
|
|
98
|
-
* module-load safe). Auth headers are injected fresh on each request via a
|
|
99
|
-
* factory so the token is always current.
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Returns a GraphQL client instance with up-to-date auth headers.
|
|
104
|
-
* A new client is created on each call so token/config changes take effect
|
|
105
|
-
* immediately without requiring an explicit reset.
|
|
106
|
-
*/
|
|
107
|
-
declare function getGraphQLClient(): GraphQLClient;
|
|
108
|
-
/**
|
|
109
|
-
* No-op — kept for backward compatibility.
|
|
110
|
-
* Clients are now stateless (created fresh on each call), so there is no
|
|
111
|
-
* cached instance to reset.
|
|
112
|
-
*/
|
|
113
|
-
declare function resetGraphQLClient(): void;
|
|
114
17
|
|
|
115
18
|
/**
|
|
116
|
-
* Simplified customer auth types for
|
|
19
|
+
* Simplified customer auth types for kasuvia-storefront.
|
|
117
20
|
* Customers only need enough to track their orders — no RBAC, MFA, or complex profiles.
|
|
118
21
|
*/
|
|
119
22
|
/**
|
|
@@ -141,7 +44,7 @@ interface CustomerUser {
|
|
|
141
44
|
avatar: string | null;
|
|
142
45
|
provider: 'google' | 'facebook' | 'email';
|
|
143
46
|
}
|
|
144
|
-
/** GET/PUT /auth/profile/ — matches
|
|
47
|
+
/** GET/PUT /auth/profile/ — matches kasuvia-auth UserSerializer */
|
|
145
48
|
interface AuthUserResponse {
|
|
146
49
|
id: string;
|
|
147
50
|
email: string;
|
|
@@ -159,6 +62,25 @@ interface UpdateProfilePayload {
|
|
|
159
62
|
lastname?: string;
|
|
160
63
|
phone?: string;
|
|
161
64
|
}
|
|
65
|
+
interface NotificationPreferences {
|
|
66
|
+
email_enabled: boolean;
|
|
67
|
+
sms_enabled: boolean;
|
|
68
|
+
whatsapp_enabled: boolean;
|
|
69
|
+
push_enabled: boolean;
|
|
70
|
+
email_order_confirmations: boolean;
|
|
71
|
+
email_delivery_updates: boolean;
|
|
72
|
+
email_low_stock_alerts: boolean;
|
|
73
|
+
email_payment_received: boolean;
|
|
74
|
+
push_order_confirmations: boolean;
|
|
75
|
+
push_delivery_updates: boolean;
|
|
76
|
+
push_low_stock_alerts: boolean;
|
|
77
|
+
push_payment_received: boolean;
|
|
78
|
+
whatsapp_order_confirmations: boolean;
|
|
79
|
+
whatsapp_delivery_updates: boolean;
|
|
80
|
+
whatsapp_payment_received: boolean;
|
|
81
|
+
sms_order_confirmations: boolean;
|
|
82
|
+
sms_delivery_updates: boolean;
|
|
83
|
+
}
|
|
162
84
|
interface BusinessContext {
|
|
163
85
|
id: string;
|
|
164
86
|
business_id: string;
|
|
@@ -186,8 +108,8 @@ interface CustomerLoginPayload {
|
|
|
186
108
|
/** POST /auth/register/customer/ */
|
|
187
109
|
interface CustomerRegisterPayload {
|
|
188
110
|
tenant_id: string;
|
|
189
|
-
|
|
190
|
-
|
|
111
|
+
first_name?: string;
|
|
112
|
+
last_name?: string;
|
|
191
113
|
email: string;
|
|
192
114
|
password: string;
|
|
193
115
|
}
|
|
@@ -213,391 +135,10 @@ interface AuthContextValue {
|
|
|
213
135
|
closeModal: () => void;
|
|
214
136
|
setCustomer: (user: CustomerUser | null) => void;
|
|
215
137
|
logout: () => Promise<void>;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
* Shipping and delivery types for the storefront
|
|
220
|
-
*/
|
|
221
|
-
interface ShippingRate {
|
|
222
|
-
id: string;
|
|
223
|
-
carrier_name: string;
|
|
224
|
-
carrier_logo: string;
|
|
225
|
-
carrier_rate_description: string;
|
|
226
|
-
carrier_slug: string;
|
|
227
|
-
amount: number;
|
|
228
|
-
currency: string;
|
|
229
|
-
delivery_time: string;
|
|
230
|
-
delivery_eta: number;
|
|
231
|
-
pickup_time: string;
|
|
232
|
-
pickup_eta: number;
|
|
233
|
-
pickup_available: boolean;
|
|
234
|
-
dropoff_available?: boolean;
|
|
235
|
-
dropoff_required?: boolean;
|
|
236
|
-
}
|
|
237
|
-
interface ShippingRatesResponse {
|
|
238
|
-
status: boolean;
|
|
239
|
-
message: string;
|
|
240
|
-
data: ShippingRate[];
|
|
241
|
-
}
|
|
242
|
-
interface DeliveryAddress {
|
|
243
|
-
first_name: string;
|
|
244
|
-
last_name: string;
|
|
245
|
-
phone: string;
|
|
246
|
-
street: string;
|
|
247
|
-
city: string;
|
|
248
|
-
state: string;
|
|
249
|
-
lga: string;
|
|
250
|
-
country: string;
|
|
251
|
-
postal: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
type ProductType = "physical" | "digital" | "service" | "bespoke";
|
|
255
|
-
|
|
256
|
-
interface Address {
|
|
257
|
-
street: string;
|
|
258
|
-
city: string;
|
|
259
|
-
state: string;
|
|
260
|
-
country: string;
|
|
261
|
-
zip?: string;
|
|
262
|
-
}
|
|
263
|
-
interface Collection {
|
|
264
|
-
id: string;
|
|
265
|
-
business_id?: string;
|
|
266
|
-
name: string;
|
|
267
|
-
slug: string;
|
|
268
|
-
description?: string;
|
|
269
|
-
image?: {
|
|
270
|
-
url: string;
|
|
271
|
-
alt?: string;
|
|
272
|
-
id?: string;
|
|
273
|
-
};
|
|
274
|
-
collection_type?: string;
|
|
275
|
-
rules?: Record<string, unknown>;
|
|
276
|
-
status?: string;
|
|
277
|
-
sort_order?: number;
|
|
278
|
-
created_at: string;
|
|
279
|
-
updated_at: string;
|
|
280
|
-
}
|
|
281
|
-
interface Inventory {
|
|
282
|
-
id: string;
|
|
283
|
-
product_id: string;
|
|
284
|
-
variant_id?: string;
|
|
285
|
-
quantity: number;
|
|
286
|
-
reserved: number;
|
|
287
|
-
reorder_point: number;
|
|
288
|
-
reorder_quantity: number;
|
|
289
|
-
track_quantity: boolean;
|
|
290
|
-
allow_backorder: boolean;
|
|
291
|
-
available: number;
|
|
292
|
-
is_in_stock: boolean;
|
|
293
|
-
is_low_stock: boolean;
|
|
294
|
-
updated_at: string;
|
|
295
|
-
}
|
|
296
|
-
interface ProductVariant {
|
|
297
|
-
id: string;
|
|
298
|
-
product_id: string;
|
|
299
|
-
sku?: string;
|
|
300
|
-
attributes: Record<string, string>;
|
|
301
|
-
price?: number;
|
|
302
|
-
images: Array<{
|
|
303
|
-
url: string;
|
|
304
|
-
alt?: string;
|
|
305
|
-
id?: string;
|
|
306
|
-
}>;
|
|
307
|
-
weight_kg?: number;
|
|
308
|
-
is_active: boolean;
|
|
309
|
-
inventory?: Inventory;
|
|
310
|
-
created_at: string;
|
|
311
|
-
updated_at: string;
|
|
312
|
-
}
|
|
313
|
-
interface CustomField {
|
|
314
|
-
label: string;
|
|
315
|
-
unit?: string;
|
|
316
|
-
required: boolean;
|
|
317
|
-
type?: string;
|
|
318
|
-
key?: string;
|
|
319
|
-
placeholder?: string;
|
|
320
|
-
}
|
|
321
|
-
interface Product {
|
|
322
|
-
id: string;
|
|
323
|
-
business_id: string;
|
|
324
|
-
name: string;
|
|
325
|
-
slug: string;
|
|
326
|
-
description?: string;
|
|
327
|
-
brand?: string;
|
|
328
|
-
product_type: ProductType;
|
|
329
|
-
requires_shipping: boolean;
|
|
330
|
-
is_consumable: boolean;
|
|
331
|
-
is_bespoke: boolean;
|
|
332
|
-
base_price: number;
|
|
333
|
-
currency: string;
|
|
334
|
-
images: Array<{
|
|
335
|
-
url: string;
|
|
336
|
-
alt?: string;
|
|
337
|
-
id?: string;
|
|
338
|
-
}>;
|
|
339
|
-
tags: string[];
|
|
340
|
-
custom_fields: CustomField[];
|
|
341
|
-
is_published: boolean;
|
|
342
|
-
is_featured: boolean;
|
|
343
|
-
is_popular: boolean;
|
|
344
|
-
is_new: boolean;
|
|
345
|
-
is_temporary: boolean;
|
|
346
|
-
digital_file_key?: string;
|
|
347
|
-
download_limit?: number;
|
|
348
|
-
download_expires_at?: string;
|
|
349
|
-
weight_kg: number;
|
|
350
|
-
length_cm?: number;
|
|
351
|
-
width_cm?: number;
|
|
352
|
-
height_cm?: number;
|
|
353
|
-
created_at: string;
|
|
354
|
-
updated_at: string;
|
|
355
|
-
variants: ProductVariant[];
|
|
356
|
-
collections: Collection[];
|
|
357
|
-
}
|
|
358
|
-
interface ListParams {
|
|
359
|
-
page?: number;
|
|
360
|
-
pageSize?: number;
|
|
361
|
-
search?: string;
|
|
362
|
-
ordering?: string;
|
|
363
|
-
collectionSlug?: string;
|
|
364
|
-
excludeProductId?: string;
|
|
365
|
-
}
|
|
366
|
-
interface PaginatedResponse<T> {
|
|
367
|
-
items: T[];
|
|
368
|
-
total: number;
|
|
369
|
-
page: number;
|
|
370
|
-
page_size: number;
|
|
371
|
-
total_pages: number;
|
|
372
|
-
}
|
|
373
|
-
interface CartItem {
|
|
374
|
-
id: string;
|
|
375
|
-
product_id: string;
|
|
376
|
-
product_slug: string;
|
|
377
|
-
product_name: string;
|
|
378
|
-
image?: string;
|
|
379
|
-
variant_id?: string;
|
|
380
|
-
variant_attributes?: string | Record<string, string>;
|
|
381
|
-
unit_price: number;
|
|
382
|
-
quantity: number;
|
|
383
|
-
custom_measurements?: string;
|
|
384
|
-
is_bespoke: boolean;
|
|
385
|
-
created_at: string;
|
|
386
|
-
updated_at: string;
|
|
387
|
-
}
|
|
388
|
-
interface CartResponse {
|
|
389
|
-
items: CartItem[];
|
|
390
|
-
subtotal: number;
|
|
391
|
-
total: number;
|
|
392
|
-
item_count: number;
|
|
393
|
-
product_type?: string;
|
|
394
|
-
}
|
|
395
|
-
interface WishlistItem {
|
|
396
|
-
id: string;
|
|
397
|
-
product_id: string;
|
|
398
|
-
notes?: string;
|
|
399
|
-
created_at: string;
|
|
400
|
-
product_name?: string;
|
|
401
|
-
product_slug?: string;
|
|
402
|
-
product_price?: number;
|
|
403
|
-
product_image?: string;
|
|
404
|
-
}
|
|
405
|
-
interface WishlistListResponse {
|
|
406
|
-
items: WishlistItem[];
|
|
407
|
-
total: number;
|
|
408
|
-
page: number;
|
|
409
|
-
page_size: number;
|
|
410
|
-
total_pages: number;
|
|
411
|
-
}
|
|
412
|
-
interface WishlistCheckResponse {
|
|
413
|
-
in_wishlist: boolean;
|
|
414
|
-
}
|
|
415
|
-
type OrderStatus = 'pending' | 'confirmed' | 'processing' | 'packed' | 'picked_up' | 'in_transit' | 'shipped' | 'delivered' | 'voided' | 'refunded' | 'failed';
|
|
416
|
-
type BespokeStageKey = "received" | "development" | "finished" | "dispatched";
|
|
417
|
-
interface OrderItem {
|
|
418
|
-
id: string;
|
|
419
|
-
productName: string;
|
|
420
|
-
image: string;
|
|
421
|
-
quantity: number;
|
|
422
|
-
price: number;
|
|
423
|
-
}
|
|
424
|
-
interface Order {
|
|
425
|
-
id: string;
|
|
426
|
-
display_id?: string;
|
|
427
|
-
items: OrderItem[];
|
|
428
|
-
total: number;
|
|
429
|
-
status: OrderStatus;
|
|
430
|
-
customerEmail: string;
|
|
431
|
-
customerName: string;
|
|
432
|
-
createdAt: number;
|
|
433
|
-
updatedAt: number;
|
|
434
|
-
deliveryMethod?: string;
|
|
435
|
-
trackingNumber?: string;
|
|
436
|
-
deliveryAddress?: string;
|
|
437
|
-
shippingAddress?: DeliveryAddress;
|
|
438
|
-
cancellationReason?: string;
|
|
439
|
-
hasBespoke?: boolean;
|
|
440
|
-
bespokeStage?: BespokeStageKey;
|
|
441
|
-
bespokeBrief?: string;
|
|
442
|
-
deliveryStatus?: string;
|
|
443
|
-
carrierName?: string;
|
|
444
|
-
terminalShipmentId?: string;
|
|
445
|
-
guestToken?: string;
|
|
446
|
-
guestEmail?: string;
|
|
447
|
-
guestPhone?: string;
|
|
448
|
-
guestName?: string;
|
|
449
|
-
}
|
|
450
|
-
interface CheckoutCustomer {
|
|
451
|
-
first_name: string;
|
|
452
|
-
last_name: string;
|
|
453
|
-
email: string;
|
|
454
|
-
phone: string;
|
|
455
|
-
}
|
|
456
|
-
interface ShippingLocation {
|
|
457
|
-
street: string;
|
|
458
|
-
city: string;
|
|
459
|
-
state: string;
|
|
460
|
-
lga: string;
|
|
461
|
-
country: string;
|
|
462
|
-
postal: string;
|
|
463
|
-
}
|
|
464
|
-
interface FindOrderParams {
|
|
465
|
-
email: string;
|
|
466
|
-
order_id: string;
|
|
467
|
-
}
|
|
468
|
-
interface CreateOrderParams {
|
|
469
|
-
customer_id?: string | null;
|
|
470
|
-
status?: string;
|
|
471
|
-
shipping_address?: DeliveryAddress;
|
|
472
|
-
checkout_session_id?: string;
|
|
473
|
-
items: Array<{
|
|
474
|
-
product_id: string;
|
|
475
|
-
product_name: string;
|
|
476
|
-
quantity: number;
|
|
477
|
-
unit_price: number;
|
|
478
|
-
variant_id?: string;
|
|
479
|
-
variant_details?: Record<string, unknown>;
|
|
480
|
-
custom_measurements?: Record<string, unknown>;
|
|
138
|
+
login: (payload: Omit<CustomerLoginPayload, 'tenant_id'>) => Promise<void>;
|
|
139
|
+
register: (payload: Omit<CustomerRegisterPayload, 'tenant_id'>) => Promise<{
|
|
140
|
+
requires_verification: boolean;
|
|
481
141
|
}>;
|
|
482
|
-
delivery_method?: string;
|
|
483
|
-
delivery_address?: string;
|
|
484
|
-
total?: number;
|
|
485
|
-
payment_method?: string;
|
|
486
|
-
shipping_rate_id?: string;
|
|
487
|
-
guest_token?: string;
|
|
488
|
-
guest_email?: string;
|
|
489
|
-
guest_phone?: string;
|
|
490
|
-
guest_name?: string;
|
|
491
|
-
product_type?: string;
|
|
492
|
-
bespoke_brief?: string;
|
|
493
|
-
bespoke_reference_images?: string[];
|
|
494
|
-
bespoke_measurements?: Record<string, string>;
|
|
495
|
-
bespoke_preferred_timeline?: string;
|
|
496
|
-
bespoke_special_instructions?: string;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* @file types/payments/index.ts
|
|
501
|
-
* @description All customer-facing payment types for the Luxe Payment System.
|
|
502
|
-
*
|
|
503
|
-
* Auth model:
|
|
504
|
-
* - X-Storefront-Key → identifies the business storefront
|
|
505
|
-
* - X-Business-ID → tenant context
|
|
506
|
-
* No business-owner JWT used here — these are CUSTOMER-facing types.
|
|
507
|
-
*
|
|
508
|
-
* Payment flow:
|
|
509
|
-
* Customer → Business Owner : Monnify (NGN) | Flutterwave (non-NGN)
|
|
510
|
-
* Business Owner → Luxe : Subscription (separate, JWT-auth)
|
|
511
|
-
* Luxe → Business Owner : Payout (separate, JWT-auth)
|
|
512
|
-
*/
|
|
513
|
-
interface Currency {
|
|
514
|
-
code: string;
|
|
515
|
-
name: string;
|
|
516
|
-
symbol: string;
|
|
517
|
-
decimals: number;
|
|
518
|
-
is_active: boolean;
|
|
519
|
-
}
|
|
520
|
-
interface SupportedCurrenciesResponse {
|
|
521
|
-
currencies: Currency[];
|
|
522
|
-
}
|
|
523
|
-
interface BackendLanguage {
|
|
524
|
-
code: string;
|
|
525
|
-
label: string;
|
|
526
|
-
flag: string;
|
|
527
|
-
}
|
|
528
|
-
interface SupportedLang {
|
|
529
|
-
code: string;
|
|
530
|
-
appCode: string;
|
|
531
|
-
label: string;
|
|
532
|
-
native: string;
|
|
533
|
-
flag: string;
|
|
534
|
-
}
|
|
535
|
-
interface SupportedLanguagesResponse {
|
|
536
|
-
languages: BackendLanguage[];
|
|
537
|
-
}
|
|
538
|
-
interface DVACreateRequest {
|
|
539
|
-
order_id?: string;
|
|
540
|
-
amount: number;
|
|
541
|
-
customer_email: string;
|
|
542
|
-
customer_name?: string;
|
|
543
|
-
/** Defaults to NGN — DVA is Monnify-only */
|
|
544
|
-
currency?: string;
|
|
545
|
-
/** Idempotency key to prevent duplicate DVA creation */
|
|
546
|
-
idempotency_key?: string;
|
|
547
|
-
}
|
|
548
|
-
interface PaymentInitiateRequest {
|
|
549
|
-
amount: number;
|
|
550
|
-
currency: string;
|
|
551
|
-
customer_email: string;
|
|
552
|
-
customer_name?: string;
|
|
553
|
-
order_id?: string;
|
|
554
|
-
quote_id?: string;
|
|
555
|
-
/** Window origin of the storefront — used as gateway redirect base URL */
|
|
556
|
-
storefront_origin?: string;
|
|
557
|
-
metadata?: Record<string, string | number | boolean>;
|
|
558
|
-
/** Idempotency key to prevent duplicate payment initiation */
|
|
559
|
-
idempotency_key?: string;
|
|
560
|
-
}
|
|
561
|
-
interface ConversionQuote {
|
|
562
|
-
id: string;
|
|
563
|
-
business_id: string;
|
|
564
|
-
from_currency: string;
|
|
565
|
-
to_currency: string;
|
|
566
|
-
rate: number;
|
|
567
|
-
original_amount: number;
|
|
568
|
-
converted_amount: number;
|
|
569
|
-
is_used: boolean;
|
|
570
|
-
expires_at: string;
|
|
571
|
-
created_at: string;
|
|
572
|
-
}
|
|
573
|
-
interface DVADetails {
|
|
574
|
-
account_number: string;
|
|
575
|
-
bank_name: string;
|
|
576
|
-
account_name: string;
|
|
577
|
-
reference: string;
|
|
578
|
-
amount: number;
|
|
579
|
-
transaction_id: string;
|
|
580
|
-
expires_at: string;
|
|
581
|
-
}
|
|
582
|
-
interface PaymentInitiateResponse {
|
|
583
|
-
id: string;
|
|
584
|
-
gateway_ref: string;
|
|
585
|
-
gateway: string;
|
|
586
|
-
status: string;
|
|
587
|
-
/** Normalised top-level checkout URL for gateway redirect */
|
|
588
|
-
checkout_url: string;
|
|
589
|
-
}
|
|
590
|
-
interface TransactionVerifyResponse {
|
|
591
|
-
id: string;
|
|
592
|
-
status: string;
|
|
593
|
-
amount: number;
|
|
594
|
-
currency: string;
|
|
595
|
-
gateway_ref: string;
|
|
596
|
-
gateway?: string;
|
|
597
|
-
order_id?: string;
|
|
598
|
-
escrow_status?: string;
|
|
599
|
-
escrow_release_date?: string;
|
|
600
|
-
metadata_json?: Record<string, unknown>;
|
|
601
142
|
}
|
|
602
143
|
|
|
603
144
|
/**
|
|
@@ -667,8 +208,6 @@ interface BespokeAvailability {
|
|
|
667
208
|
/**
|
|
668
209
|
* Service booking types for customer-facing storefront
|
|
669
210
|
*/
|
|
670
|
-
type ServiceLocationType = "remote" | "physical" | "both";
|
|
671
|
-
type ServiceType = "appointment" | "project" | "recurring";
|
|
672
211
|
type AppointmentStatus = "pending" | "confirmed" | "in_progress" | "completed" | "voided" | "no_show";
|
|
673
212
|
interface AvailableSlot {
|
|
674
213
|
date: string;
|
|
@@ -767,73 +306,6 @@ interface BespokeCapacityConfig {
|
|
|
767
306
|
updated_at: string;
|
|
768
307
|
}
|
|
769
308
|
|
|
770
|
-
/**
|
|
771
|
-
* CMS Types
|
|
772
|
-
*
|
|
773
|
-
* Types for kasuvia-cms integration - dynamic content models and entries
|
|
774
|
-
*/
|
|
775
|
-
interface CmsField {
|
|
776
|
-
name: string;
|
|
777
|
-
label: string;
|
|
778
|
-
type: string;
|
|
779
|
-
required: boolean;
|
|
780
|
-
config: Record<string, any>;
|
|
781
|
-
sub_fields?: CmsField[];
|
|
782
|
-
}
|
|
783
|
-
interface CmsModelPermissions {
|
|
784
|
-
read: boolean;
|
|
785
|
-
create: boolean;
|
|
786
|
-
update: boolean;
|
|
787
|
-
delete: boolean;
|
|
788
|
-
}
|
|
789
|
-
interface CmsModelPublicApiPermissions {
|
|
790
|
-
public_api: CmsModelPermissions;
|
|
791
|
-
}
|
|
792
|
-
interface CmsModel {
|
|
793
|
-
id: string;
|
|
794
|
-
business_id: string;
|
|
795
|
-
model_slug: string;
|
|
796
|
-
display_name: string;
|
|
797
|
-
description: string | null;
|
|
798
|
-
fields: CmsField[];
|
|
799
|
-
permissions: CmsModelPublicApiPermissions;
|
|
800
|
-
}
|
|
801
|
-
interface CmsEntry {
|
|
802
|
-
id: string;
|
|
803
|
-
business_id: string;
|
|
804
|
-
model_slug: string;
|
|
805
|
-
data: Record<string, any>;
|
|
806
|
-
created_at: string;
|
|
807
|
-
updated_at: string;
|
|
808
|
-
created_by: string | null;
|
|
809
|
-
}
|
|
810
|
-
interface CmsEntryListResponse {
|
|
811
|
-
entries: CmsEntry[];
|
|
812
|
-
total: number;
|
|
813
|
-
page: number;
|
|
814
|
-
page_size: number;
|
|
815
|
-
}
|
|
816
|
-
interface CmsIcon {
|
|
817
|
-
id: string;
|
|
818
|
-
name: string;
|
|
819
|
-
category: string;
|
|
820
|
-
tags: string[];
|
|
821
|
-
}
|
|
822
|
-
interface CmsIconListResponse {
|
|
823
|
-
icons: CmsIcon[];
|
|
824
|
-
total: number;
|
|
825
|
-
}
|
|
826
|
-
interface ListCmsEntriesParams {
|
|
827
|
-
page?: number;
|
|
828
|
-
page_size?: number;
|
|
829
|
-
}
|
|
830
|
-
interface CreateCmsEntryParams {
|
|
831
|
-
data: Record<string, any>;
|
|
832
|
-
}
|
|
833
|
-
interface UpdateCmsEntryParams {
|
|
834
|
-
data: Record<string, any>;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
309
|
/**
|
|
838
310
|
* Media types for the storefront
|
|
839
311
|
*/
|
|
@@ -874,68 +346,51 @@ interface StorageStats {
|
|
|
874
346
|
|
|
875
347
|
interface BusinessConfig {
|
|
876
348
|
business_id: string;
|
|
877
|
-
|
|
878
|
-
|
|
349
|
+
storefront_business_id: string;
|
|
350
|
+
name: string;
|
|
351
|
+
currency: string;
|
|
352
|
+
settlement_currency: string;
|
|
353
|
+
country: string;
|
|
354
|
+
region: string;
|
|
355
|
+
is_verified: boolean;
|
|
879
356
|
is_active: boolean;
|
|
880
357
|
}
|
|
881
358
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
interface AppContextValue extends AppState {
|
|
890
|
-
setTheme: (t: Theme) => void;
|
|
891
|
-
setLang: (l: LangCode) => void;
|
|
892
|
-
setCurrency: (c: string) => void;
|
|
893
|
-
formatPrice: (amount: number, fromCurrency?: string) => string;
|
|
894
|
-
resetAppState: () => void;
|
|
895
|
-
t: (text: string) => string;
|
|
896
|
-
translate: (text: string) => Promise<string>;
|
|
897
|
-
}
|
|
898
|
-
interface Country {
|
|
899
|
-
name: string;
|
|
900
|
-
code: string;
|
|
901
|
-
dial_code: string;
|
|
902
|
-
min_age: number;
|
|
903
|
-
}
|
|
904
|
-
interface State {
|
|
905
|
-
name: string;
|
|
906
|
-
code: string;
|
|
907
|
-
full_iso_code: string;
|
|
908
|
-
type: string;
|
|
909
|
-
}
|
|
359
|
+
/**
|
|
360
|
+
* Cart Service
|
|
361
|
+
*
|
|
362
|
+
* Handles cart operations for both guest and authenticated users.
|
|
363
|
+
* Stateless - all configuration passed as parameters.
|
|
364
|
+
*/
|
|
910
365
|
|
|
911
366
|
/**
|
|
912
367
|
* Fetch guest cart from backend (Redis-backed).
|
|
913
368
|
*/
|
|
914
|
-
declare function getGuestCart(): Promise<CartItem[]>;
|
|
369
|
+
declare function getGuestCart(config: SdkConfig, guestSessionId: string): Promise<CartItem[]>;
|
|
915
370
|
/**
|
|
916
371
|
* Add item to guest cart (Redis-backed).
|
|
917
372
|
*/
|
|
918
|
-
declare function addToGuestCart(item: CartItem): Promise<CartItem[]>;
|
|
373
|
+
declare function addToGuestCart(config: SdkConfig, guestSessionId: string, item: CartItem): Promise<CartItem[]>;
|
|
919
374
|
/**
|
|
920
375
|
* Update quantity of a guest cart item.
|
|
921
376
|
*/
|
|
922
|
-
declare function updateGuestCartItemQuantity(itemId: string, quantity: number): Promise<CartItem[]>;
|
|
377
|
+
declare function updateGuestCartItemQuantity(config: SdkConfig, guestSessionId: string, itemId: string, quantity: number): Promise<CartItem[]>;
|
|
923
378
|
/**
|
|
924
379
|
* Remove an item from the guest cart.
|
|
925
380
|
*/
|
|
926
|
-
declare function removeFromGuestCart(itemId: string): Promise<CartItem[]>;
|
|
381
|
+
declare function removeFromGuestCart(config: SdkConfig, guestSessionId: string, itemId: string): Promise<CartItem[]>;
|
|
927
382
|
/**
|
|
928
383
|
* Clear the entire guest cart.
|
|
929
384
|
*/
|
|
930
|
-
declare function clearGuestCart(): Promise<void>;
|
|
385
|
+
declare function clearGuestCart(config: SdkConfig, guestSessionId: string): Promise<void>;
|
|
931
386
|
/**
|
|
932
387
|
* Fetch authenticated user's cart from backend.
|
|
933
388
|
*/
|
|
934
|
-
declare function getCart(): Promise<CartResponse>;
|
|
389
|
+
declare function getCart(config: SdkConfig, accessToken?: string | null): Promise<CartResponse>;
|
|
935
390
|
/**
|
|
936
391
|
* Add item to authenticated user's cart.
|
|
937
392
|
*/
|
|
938
|
-
declare function addToCart(item: {
|
|
393
|
+
declare function addToCart(config: SdkConfig, accessToken: string, item: {
|
|
939
394
|
product_id: string;
|
|
940
395
|
product_slug: string;
|
|
941
396
|
product_name: string;
|
|
@@ -950,23 +405,23 @@ declare function addToCart(item: {
|
|
|
950
405
|
/**
|
|
951
406
|
* Update item quantity in authenticated user's cart.
|
|
952
407
|
*/
|
|
953
|
-
declare function updateCartItem(itemId: string, quantity: number): Promise<CartResponse>;
|
|
408
|
+
declare function updateCartItem(config: SdkConfig, accessToken: string, itemId: string, quantity: number): Promise<CartResponse>;
|
|
954
409
|
/**
|
|
955
410
|
* Remove item from authenticated user's cart.
|
|
956
411
|
*/
|
|
957
|
-
declare function removeFromCart(itemId: string): Promise<CartResponse>;
|
|
412
|
+
declare function removeFromCart(config: SdkConfig, accessToken: string, itemId: string): Promise<CartResponse>;
|
|
958
413
|
/**
|
|
959
414
|
* Clear authenticated user's cart.
|
|
960
415
|
*/
|
|
961
|
-
declare function clearCart(): Promise<void>;
|
|
416
|
+
declare function clearCart(config: SdkConfig, accessToken: string): Promise<void>;
|
|
962
417
|
/**
|
|
963
418
|
* Merge guest cart (from Redis) into authenticated user's DB cart.
|
|
964
419
|
*/
|
|
965
|
-
declare function mergeGuestCart(): Promise<CartResponse>;
|
|
420
|
+
declare function mergeGuestCart(config: SdkConfig, accessToken: string, guestSessionId: string): Promise<CartResponse>;
|
|
966
421
|
/**
|
|
967
422
|
* Convenience wrapper: merge guest cart if it has items (called post-login).
|
|
968
423
|
*/
|
|
969
|
-
declare function mergeGuestCartIfPresent(): Promise<void>;
|
|
424
|
+
declare function mergeGuestCartIfPresent(config: SdkConfig, accessToken: string, guestSessionId: string): Promise<void>;
|
|
970
425
|
/**
|
|
971
426
|
* Returns 0 — count is now server-driven. Use the hook instead.
|
|
972
427
|
* Kept for backward compatibility.
|
|
@@ -982,157 +437,191 @@ declare function getGuestCartSubtotal(): number;
|
|
|
982
437
|
*/
|
|
983
438
|
declare function getGuestCartProductType(): "physical" | "digital" | "bespoke";
|
|
984
439
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
440
|
+
/**
|
|
441
|
+
* Order Service
|
|
442
|
+
*
|
|
443
|
+
* Handles order operations including creation, lookup, and tracking.
|
|
444
|
+
* Stateless - all configuration passed as parameters.
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
declare function createOrder(config: SdkConfig, accessToken: string, payload: CreateOrderParams): Promise<Order>;
|
|
448
|
+
declare function findOrder(config: SdkConfig, params: FindOrderParams & {
|
|
449
|
+
guest_token?: string;
|
|
450
|
+
}): Promise<Order>;
|
|
451
|
+
declare function findOrderByToken(config: SdkConfig, token: string): Promise<Order>;
|
|
452
|
+
declare function getOrders(config: SdkConfig, accessToken: string, params?: {
|
|
989
453
|
email?: string;
|
|
990
454
|
page?: number;
|
|
991
455
|
page_size?: number;
|
|
992
456
|
}): Promise<Order[]>;
|
|
993
|
-
declare function cancelOrder(orderId: string, reason: string): Promise<Order>;
|
|
994
|
-
declare function trackOrder(orderId: string, token?: string): Promise<Order>;
|
|
457
|
+
declare function cancelOrder(config: SdkConfig, accessToken: string, orderId: string, reason: string): Promise<Order>;
|
|
458
|
+
declare function trackOrder(config: SdkConfig, orderId: string, token?: string): Promise<Order>;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Customer auth service — all API calls scoped to this storefront's business tenant.
|
|
462
|
+
* Stateless - all configuration passed as parameters.
|
|
463
|
+
*/
|
|
995
464
|
|
|
996
465
|
/**
|
|
997
466
|
* POST /auth/login/customer/
|
|
998
|
-
* The `tenant_id` is automatically filled from config.
|
|
467
|
+
* The `tenant_id` is automatically filled from config.businessId.
|
|
999
468
|
*/
|
|
1000
|
-
declare function loginCustomer(payload: Omit<CustomerLoginPayload, 'tenant_id'>): Promise<CustomerAuthResponse>;
|
|
469
|
+
declare function loginCustomer(config: SdkConfig, payload: Omit<CustomerLoginPayload, 'tenant_id'>): Promise<CustomerAuthResponse>;
|
|
1001
470
|
/**
|
|
1002
471
|
* POST /auth/register/customer/
|
|
1003
|
-
* The `tenant_id` is automatically filled from config.
|
|
472
|
+
* The `tenant_id` is automatically filled from config.businessId.
|
|
1004
473
|
*/
|
|
1005
|
-
declare function registerCustomer(payload: Omit<CustomerRegisterPayload, 'tenant_id'>): Promise<CustomerAuthResponse>;
|
|
1006
|
-
/** POST /auth/
|
|
1007
|
-
|
|
474
|
+
declare function registerCustomer(config: SdkConfig, payload: Omit<CustomerRegisterPayload, 'tenant_id'>): Promise<CustomerAuthResponse>;
|
|
475
|
+
/** POST /auth/token/refresh/
|
|
476
|
+
*/
|
|
477
|
+
declare function refreshToken(config: SdkConfig, refresh: string): Promise<RefreshTokenResponse>;
|
|
478
|
+
/** POST /auth/logout/ — revokes the server-side session. */
|
|
479
|
+
declare function logout(config: SdkConfig, refresh?: string): Promise<void>;
|
|
1008
480
|
/**
|
|
1009
481
|
* Verify a social provider id_token (or access_token for Facebook) with the backend.
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
* 1. Customer completes Google/Facebook sign-in on the storefront
|
|
1014
|
-
* 2. Storefront receives an id_token / access_token from the provider
|
|
1015
|
-
* 3. This function sends it to the backend for server-side verification
|
|
1016
|
-
* 4. Backend returns our JWT tokens
|
|
1017
|
-
*/
|
|
1018
|
-
declare function verifySocialToken(provider: 'google' | 'facebook', token: string): Promise<CustomerAuthResponse>;
|
|
1019
|
-
/** Map luxe-auth UserSerializer response to storefront CustomerUser. */
|
|
482
|
+
*/
|
|
483
|
+
declare function verifySocialToken(config: SdkConfig, provider: 'google' | 'facebook', token: string): Promise<CustomerAuthResponse>;
|
|
484
|
+
/** Map kasuvia-auth UserSerializer response to storefront CustomerUser. */
|
|
1020
485
|
declare function mapAuthUserToCustomer(data: AuthUserResponse, provider?: CustomerUser['provider']): CustomerUser;
|
|
1021
486
|
/** GET /auth/profile/ */
|
|
1022
|
-
declare function getMe(): Promise<CustomerUser>;
|
|
487
|
+
declare function getMe(config?: SdkConfig, accessToken?: string): Promise<CustomerUser>;
|
|
1023
488
|
/** GET /auth/profile/ - alias for getMe for backward compatibility */
|
|
1024
|
-
declare function getAuthUser(): Promise<AuthUserResponse>;
|
|
489
|
+
declare function getAuthUser(config?: SdkConfig, accessToken?: string): Promise<AuthUserResponse>;
|
|
1025
490
|
/** PUT /auth/profile/ — update firstname, lastname, phone */
|
|
1026
|
-
declare function updateProfile(
|
|
491
|
+
declare function updateProfile(configOrPayload: SdkConfig | UpdateProfilePayload, accessTokenOrPayload?: string | UpdateProfilePayload, payloadParam?: UpdateProfilePayload): Promise<CustomerUser>;
|
|
1027
492
|
/**
|
|
1028
493
|
* Silently refresh the access token on app boot.
|
|
1029
494
|
* Builds CustomerUser from JWT claims — no additional profile API call needed.
|
|
1030
495
|
* Returns null if no refresh token exists or if the refresh fails.
|
|
1031
|
-
* Includes a concurrent lock to prevent React Strict Mode from double-firing and blacklisting the token.
|
|
1032
|
-
*
|
|
1033
|
-
* Network error resilience:
|
|
1034
|
-
* - Classifies errors as network vs auth
|
|
1035
|
-
* - Retries transient network errors with exponential backoff
|
|
1036
|
-
* - Immediately fails on auth errors (401/403) to avoid infinite loops
|
|
1037
|
-
* - Clears auth state on any failure to ensure consistent logout behavior
|
|
1038
496
|
*/
|
|
1039
|
-
declare function silentRefresh(): Promise<{
|
|
497
|
+
declare function silentRefresh(config: SdkConfig, refresh: string): Promise<{
|
|
1040
498
|
user: CustomerUser;
|
|
1041
499
|
provider: CustomerUser['provider'];
|
|
500
|
+
newAccessToken: string;
|
|
501
|
+
newRefreshToken: string;
|
|
1042
502
|
} | null>;
|
|
1043
|
-
/**
|
|
1044
|
-
|
|
503
|
+
/**
|
|
504
|
+
* Store tokens in localStorage (client-side utility)
|
|
505
|
+
* This is a convenience function for storefronts to store auth tokens
|
|
506
|
+
*/
|
|
507
|
+
declare function storeTokens(accessToken: string, refreshToken: string): void;
|
|
508
|
+
/**
|
|
509
|
+
* Clear tokens from localStorage (client-side utility)
|
|
510
|
+
*/
|
|
511
|
+
declare function clearTokens(): void;
|
|
512
|
+
/**
|
|
513
|
+
* Get stored tokens from localStorage (client-side utility)
|
|
514
|
+
*/
|
|
515
|
+
declare function getStoredTokens(): {
|
|
516
|
+
accessToken: string | null;
|
|
517
|
+
refreshToken: string | null;
|
|
518
|
+
};
|
|
1045
519
|
|
|
1046
520
|
/**
|
|
1047
521
|
* Fetch all active products for the storefront.
|
|
1048
522
|
*/
|
|
1049
|
-
declare function getStorefrontProducts(params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
523
|
+
declare function getStorefrontProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
1050
524
|
/**
|
|
1051
525
|
* Fetch a single product by slug for the storefront.
|
|
1052
526
|
*/
|
|
1053
|
-
declare function getStorefrontProductBySlug(slug: string): Promise<Product>;
|
|
527
|
+
declare function getStorefrontProductBySlug(config: SdkConfig, slug: string): Promise<Product>;
|
|
1054
528
|
/**
|
|
1055
529
|
* Fetch latest products for the storefront.
|
|
1056
530
|
*/
|
|
1057
|
-
declare function getLatestProducts(params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
531
|
+
declare function getLatestProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
1058
532
|
/**
|
|
1059
533
|
* Fetch popular products for the storefront.
|
|
1060
534
|
*/
|
|
1061
|
-
declare function getPopularProducts(params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
535
|
+
declare function getPopularProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
1062
536
|
/**
|
|
1063
537
|
* Fetch featured products for the storefront.
|
|
1064
538
|
*/
|
|
1065
|
-
declare function getFeaturedProducts(params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
539
|
+
declare function getFeaturedProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
1066
540
|
/**
|
|
1067
541
|
* Fetch new products for the storefront.
|
|
1068
542
|
*/
|
|
1069
|
-
declare function getNewProducts(params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
543
|
+
declare function getNewProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
544
|
+
/**
|
|
545
|
+
* Fetch products currently on sale for the storefront.
|
|
546
|
+
*/
|
|
547
|
+
declare function getOnSaleProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
548
|
+
/**
|
|
549
|
+
* Fetch products with low stock for the storefront.
|
|
550
|
+
*/
|
|
551
|
+
declare function getLowStockProducts(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Product>>;
|
|
1070
552
|
/**
|
|
1071
553
|
* Fetch recommended products for the storefront.
|
|
1072
554
|
* Returns featured, popular, and new products.
|
|
1073
555
|
* Optionally excludes a specific product ID.
|
|
1074
556
|
*/
|
|
1075
|
-
declare function getRecommendedProducts(params?: ListParams & {
|
|
557
|
+
declare function getRecommendedProducts(config: SdkConfig, params?: ListParams & {
|
|
1076
558
|
excludeProductId?: string;
|
|
1077
559
|
}): Promise<PaginatedResponse<Product>>;
|
|
1078
560
|
|
|
1079
561
|
/**
|
|
1080
562
|
* Fetch paginated active collections for the storefront.
|
|
1081
563
|
*/
|
|
1082
|
-
declare function getStorefrontCollections(params?: ListParams): Promise<PaginatedResponse<Collection>>;
|
|
564
|
+
declare function getStorefrontCollections(config: SdkConfig, params?: ListParams): Promise<PaginatedResponse<Collection>>;
|
|
1083
565
|
/**
|
|
1084
566
|
* Fetch a single collection by its slug.
|
|
1085
567
|
*/
|
|
1086
|
-
declare function getStorefrontCollectionBySlug(slug: string): Promise<Collection>;
|
|
568
|
+
declare function getStorefrontCollectionBySlug(config: SdkConfig, slug: string): Promise<Collection>;
|
|
1087
569
|
|
|
1088
570
|
/**
|
|
1089
571
|
* Fetch the customer's wishlist for the current business.
|
|
1090
572
|
*/
|
|
1091
|
-
declare function getWishlist(params?: {
|
|
573
|
+
declare function getWishlist(config: SdkConfig, accessToken: string, params?: {
|
|
1092
574
|
page?: number;
|
|
1093
575
|
pageSize?: number;
|
|
1094
576
|
}): Promise<WishlistListResponse>;
|
|
1095
577
|
/**
|
|
1096
578
|
* Check if a product is in the customer's wishlist.
|
|
1097
579
|
*/
|
|
1098
|
-
declare function checkInWishlist(productId: string): Promise<WishlistCheckResponse>;
|
|
580
|
+
declare function checkInWishlist(config: SdkConfig, accessToken: string, productId: string): Promise<WishlistCheckResponse>;
|
|
1099
581
|
/**
|
|
1100
582
|
* Add a product to the customer's wishlist.
|
|
1101
583
|
*/
|
|
1102
|
-
declare function addToWishlist(productId: string, notes?: string): Promise<WishlistItem>;
|
|
584
|
+
declare function addToWishlist(config: SdkConfig, accessToken: string, productId: string, notes?: string): Promise<WishlistItem>;
|
|
1103
585
|
/**
|
|
1104
586
|
* Remove an item from the customer's wishlist by item ID.
|
|
1105
587
|
*/
|
|
1106
|
-
declare function removeFromWishlist(itemId: string): Promise<void>;
|
|
588
|
+
declare function removeFromWishlist(config: SdkConfig, accessToken: string, itemId: string): Promise<void>;
|
|
1107
589
|
/**
|
|
1108
590
|
* Remove a product from the customer's wishlist by product ID.
|
|
1109
591
|
*/
|
|
1110
|
-
declare function removeProductFromWishlist(productId: string): Promise<void>;
|
|
592
|
+
declare function removeProductFromWishlist(config: SdkConfig, accessToken: string, productId: string): Promise<void>;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Payment Service
|
|
596
|
+
*
|
|
597
|
+
* Customer-facing payment API for payment initiation and verification.
|
|
598
|
+
* Stateless - all configuration passed as parameters.
|
|
599
|
+
*/
|
|
1111
600
|
|
|
1112
601
|
/**
|
|
1113
602
|
* Create a Monnify Dedicated Virtual Account so the customer can pay via
|
|
1114
603
|
* bank transfer. Note: Monnify DVA only supports NGN currency - the backend
|
|
1115
604
|
* will reject non-NGN requests for this payment method.
|
|
1116
605
|
*/
|
|
1117
|
-
declare function createDedicatedAccount(request: DVACreateRequest): Promise<DVADetails>;
|
|
606
|
+
declare function createDedicatedAccount(config: SdkConfig, accessToken: string, request: DVACreateRequest): Promise<DVADetails>;
|
|
1118
607
|
/**
|
|
1119
608
|
* Initiate a card payment (customer → business owner).
|
|
1120
609
|
* Routes to Monnify (NGN) or Flutterwave (non-NGN) on the backend.
|
|
1121
610
|
* Returns a checkout_url to redirect the customer to the gateway.
|
|
1122
611
|
*/
|
|
1123
|
-
declare function initiatePayment(request: PaymentInitiateRequest): Promise<PaymentInitiateResponse>;
|
|
612
|
+
declare function initiatePayment(config: SdkConfig, accessToken: string, request: PaymentInitiateRequest): Promise<PaymentInitiateResponse>;
|
|
1124
613
|
/**
|
|
1125
614
|
* Request a 15-minute rate-locked conversion quote for non-NGN transactions.
|
|
1126
615
|
*/
|
|
1127
|
-
declare function requestQuote(amount: number): Promise<ConversionQuote>;
|
|
616
|
+
declare function requestQuote(config: SdkConfig, amount: number): Promise<ConversionQuote>;
|
|
1128
617
|
/**
|
|
1129
618
|
* Verify a payment after the gateway redirects back to /checkout/verify.
|
|
1130
619
|
*/
|
|
1131
|
-
declare function verifyTransaction(
|
|
620
|
+
declare function verifyTransaction(configOrReference: SdkConfig | string, reference?: string): Promise<TransactionVerifyResponse>;
|
|
1132
621
|
/**
|
|
1133
622
|
* Poll transaction status by internal transaction ID.
|
|
1134
623
|
*/
|
|
1135
|
-
declare function getTransactionStatus(transactionId: string): Promise<TransactionVerifyResponse>;
|
|
624
|
+
declare function getTransactionStatus(config: SdkConfig, transactionId: string): Promise<TransactionVerifyResponse>;
|
|
1136
625
|
declare const paymentService: {
|
|
1137
626
|
readonly createDedicatedAccount: typeof createDedicatedAccount;
|
|
1138
627
|
readonly initiatePayment: typeof initiatePayment;
|
|
@@ -1141,12 +630,19 @@ declare const paymentService: {
|
|
|
1141
630
|
readonly getTransactionStatus: typeof getTransactionStatus;
|
|
1142
631
|
};
|
|
1143
632
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
633
|
+
/**
|
|
634
|
+
* Consultation Service
|
|
635
|
+
*
|
|
636
|
+
* Handles consultation operations for bespoke and service products.
|
|
637
|
+
* Stateless - all configuration passed as parameters.
|
|
638
|
+
*/
|
|
639
|
+
|
|
640
|
+
declare function createConsultation(config: SdkConfig, accessToken: string, payload: ConsultationCreatePayload): Promise<Consultation>;
|
|
641
|
+
declare function getConsultations(config: SdkConfig, accessToken: string): Promise<Consultation[]>;
|
|
642
|
+
declare function getConsultation(config: SdkConfig, accessToken: string, id: string): Promise<Consultation>;
|
|
643
|
+
declare function sendMessage(config: SdkConfig, accessToken: string, id: string, payload: ConsultationMessagePayload): Promise<void>;
|
|
644
|
+
declare function acceptQuote(config: SdkConfig, accessToken: string, id: string, payload: ConsultationQuoteAcceptPayload): Promise<Consultation>;
|
|
645
|
+
declare function rejectQuote(config: SdkConfig, accessToken: string, id: string, reason?: string): Promise<Consultation>;
|
|
1150
646
|
declare const consultationService: {
|
|
1151
647
|
createConsultation: typeof createConsultation;
|
|
1152
648
|
getConsultations: typeof getConsultations;
|
|
@@ -1156,6 +652,13 @@ declare const consultationService: {
|
|
|
1156
652
|
rejectQuote: typeof rejectQuote;
|
|
1157
653
|
};
|
|
1158
654
|
|
|
655
|
+
/**
|
|
656
|
+
* Logistics Service
|
|
657
|
+
*
|
|
658
|
+
* Handles shipping rates and address validation.
|
|
659
|
+
* Stateless - all configuration passed as parameters.
|
|
660
|
+
*/
|
|
661
|
+
|
|
1159
662
|
interface CartItemPayload {
|
|
1160
663
|
product: {
|
|
1161
664
|
name: string;
|
|
@@ -1179,11 +682,11 @@ interface ShippingRatesRequest {
|
|
|
1179
682
|
/**
|
|
1180
683
|
* Fetch shipping rates for a cart.
|
|
1181
684
|
*/
|
|
1182
|
-
declare function getShippingRates(payload: ShippingRatesRequest): Promise<ShippingRatesResponse>;
|
|
685
|
+
declare function getShippingRates(config: SdkConfig, payload: ShippingRatesRequest): Promise<ShippingRatesResponse>;
|
|
1183
686
|
/**
|
|
1184
687
|
* Fetch the seller's registered shipping address.
|
|
1185
688
|
*/
|
|
1186
|
-
declare function getSellerShippingAddress(): Promise<{
|
|
689
|
+
declare function getSellerShippingAddress(config: SdkConfig): Promise<{
|
|
1187
690
|
terminal_address_id: string | null;
|
|
1188
691
|
address_details: {
|
|
1189
692
|
city: string;
|
|
@@ -1199,7 +702,7 @@ declare function getSellerShippingAddress(): Promise<{
|
|
|
1199
702
|
/**
|
|
1200
703
|
* Validate a shipping address.
|
|
1201
704
|
*/
|
|
1202
|
-
declare function validateShippingAddress(payload: {
|
|
705
|
+
declare function validateShippingAddress(config: SdkConfig, payload: {
|
|
1203
706
|
first_name: string;
|
|
1204
707
|
last_name: string;
|
|
1205
708
|
phone: string;
|
|
@@ -1225,19 +728,33 @@ declare const logisticsService: {
|
|
|
1225
728
|
validateShippingAddress: typeof validateShippingAddress;
|
|
1226
729
|
};
|
|
1227
730
|
|
|
1228
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Bespoke Service
|
|
733
|
+
*
|
|
734
|
+
* Handles bespoke product availability checks.
|
|
735
|
+
* Stateless - all configuration passed as parameters.
|
|
736
|
+
*/
|
|
737
|
+
|
|
738
|
+
declare function checkAvailability(config: SdkConfig, product_id: string): Promise<BespokeAvailability>;
|
|
1229
739
|
declare const bespokeService: {
|
|
1230
740
|
checkAvailability: typeof checkAvailability;
|
|
1231
741
|
};
|
|
1232
742
|
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
declare function
|
|
743
|
+
/**
|
|
744
|
+
* Service Booking Service
|
|
745
|
+
*
|
|
746
|
+
* Handles service appointments and deliverables.
|
|
747
|
+
* Stateless - all configuration passed as parameters.
|
|
748
|
+
*/
|
|
749
|
+
|
|
750
|
+
declare function getAvailableSlots(config: SdkConfig, product_id: string, date_from: string, date_to: string): Promise<AvailableSlot[]>;
|
|
751
|
+
declare function bookAppointment(config: SdkConfig, accessToken: string, payload: ServiceAppointmentCreatePayload): Promise<ServiceAppointment>;
|
|
752
|
+
declare function getAppointments(config: SdkConfig, accessToken: string): Promise<ServiceAppointment[]>;
|
|
753
|
+
declare function getAppointment(config: SdkConfig, accessToken: string, id: string): Promise<ServiceAppointment>;
|
|
754
|
+
declare function cancelAppointment(config: SdkConfig, accessToken: string, id: string): Promise<void>;
|
|
755
|
+
declare function getDeliverables(config: SdkConfig, accessToken: string, order_id: string): Promise<ServiceDeliverable[]>;
|
|
756
|
+
declare function approveDeliverable(config: SdkConfig, accessToken: string, order_id: string, deliverable_id: string): Promise<ServiceDeliverable>;
|
|
757
|
+
declare function requestRevision(config: SdkConfig, accessToken: string, order_id: string, deliverable_id: string, feedback: string): Promise<ServiceDeliverable>;
|
|
1241
758
|
declare const serviceBookingService: {
|
|
1242
759
|
getAvailableSlots: typeof getAvailableSlots;
|
|
1243
760
|
bookAppointment: typeof bookAppointment;
|
|
@@ -1249,6 +766,13 @@ declare const serviceBookingService: {
|
|
|
1249
766
|
requestRevision: typeof requestRevision;
|
|
1250
767
|
};
|
|
1251
768
|
|
|
769
|
+
/**
|
|
770
|
+
* Notification Service
|
|
771
|
+
*
|
|
772
|
+
* Handles contact form submissions and email notifications.
|
|
773
|
+
* Stateless - all configuration passed as parameters.
|
|
774
|
+
*/
|
|
775
|
+
|
|
1252
776
|
interface ContactFormData {
|
|
1253
777
|
name: string;
|
|
1254
778
|
email: string;
|
|
@@ -1260,17 +784,17 @@ interface ContactFormData {
|
|
|
1260
784
|
turnstile_token?: string;
|
|
1261
785
|
}
|
|
1262
786
|
/**
|
|
1263
|
-
* Send contact email to
|
|
787
|
+
* Send contact email to Kasuvia team.
|
|
1264
788
|
* POST /contact/send-contact-email
|
|
1265
789
|
*/
|
|
1266
|
-
declare function sendContactEmail(payload: ContactFormData): Promise<{
|
|
790
|
+
declare function sendContactEmail(config: SdkConfig, payload: ContactFormData): Promise<{
|
|
1267
791
|
detail: string;
|
|
1268
792
|
}>;
|
|
1269
793
|
/**
|
|
1270
794
|
* Send confirmation email to user.
|
|
1271
795
|
* POST /contact/send-contact-confirmation
|
|
1272
796
|
*/
|
|
1273
|
-
declare function sendContactConfirmation(payload: Omit<ContactFormData, 'turnstile_token'>): Promise<{
|
|
797
|
+
declare function sendContactConfirmation(config: SdkConfig, payload: Omit<ContactFormData, 'turnstile_token'>): Promise<{
|
|
1274
798
|
detail: string;
|
|
1275
799
|
}>;
|
|
1276
800
|
declare const notificationsService: {
|
|
@@ -1285,509 +809,69 @@ declare const notificationsService: {
|
|
|
1285
809
|
*/
|
|
1286
810
|
declare function googleTranslate(text: string, target: string, source?: string): Promise<string>;
|
|
1287
811
|
|
|
812
|
+
/**
|
|
813
|
+
* Config Service
|
|
814
|
+
*
|
|
815
|
+
* Handles configuration endpoints (languages, currencies, locales, business config).
|
|
816
|
+
* Stateless - all configuration passed as parameters.
|
|
817
|
+
*/
|
|
818
|
+
|
|
1288
819
|
/**
|
|
1289
820
|
* Fetch supported languages from the payment system.
|
|
1290
|
-
* Resolves to: {
|
|
821
|
+
* Resolves to: {kasuviaPaymentBackendUrl}/config/supported-languages
|
|
1291
822
|
*/
|
|
1292
|
-
declare function getSupportedLanguages(): Promise<SupportedLanguagesResponse>;
|
|
823
|
+
declare function getSupportedLanguages(config: SdkConfig): Promise<SupportedLanguagesResponse>;
|
|
1293
824
|
/**
|
|
1294
825
|
* Fetch supported currencies from the payment system.
|
|
1295
|
-
* Resolves to: {
|
|
826
|
+
* Resolves to: {kasuviaPaymentBackendUrl}/config/supported-currencies
|
|
1296
827
|
*/
|
|
1297
|
-
declare function getSupportedCurrencies(): Promise<SupportedCurrenciesResponse>;
|
|
828
|
+
declare function getSupportedCurrencies(config: SdkConfig): Promise<SupportedCurrenciesResponse>;
|
|
1298
829
|
/**
|
|
1299
830
|
* Fetch the business's public configuration, including store_currency.
|
|
1300
|
-
* Uses
|
|
1301
|
-
* Resolves to: {
|
|
831
|
+
* Uses storefront API key header (X-Storefront-Key).
|
|
832
|
+
* Resolves to: {kasuviaAuthBackendUrl}/internal/businesses/{business_id}/
|
|
833
|
+
* This endpoint is designed for storefronts to fetch business config using their storefront API key.
|
|
1302
834
|
*/
|
|
1303
|
-
declare function getBusinessConfig(): Promise<BusinessConfig>;
|
|
835
|
+
declare function getBusinessConfig(config: SdkConfig): Promise<BusinessConfig>;
|
|
1304
836
|
declare const configService: {
|
|
1305
837
|
readonly getSupportedLanguages: typeof getSupportedLanguages;
|
|
1306
838
|
readonly getSupportedCurrencies: typeof getSupportedCurrencies;
|
|
1307
839
|
readonly getBusinessConfig: typeof getBusinessConfig;
|
|
1308
840
|
};
|
|
1309
841
|
|
|
842
|
+
/**
|
|
843
|
+
* CMS Service
|
|
844
|
+
*
|
|
845
|
+
* Handles CMS model and entry operations using the kasuvia-cms SDK endpoints.
|
|
846
|
+
* Protected by X-Storefront-Key and X-Business-ID headers.
|
|
847
|
+
* Stateless - all configuration passed as parameters.
|
|
848
|
+
*/
|
|
849
|
+
|
|
1310
850
|
/**
|
|
1311
851
|
* List CMS entries for a specific model.
|
|
1312
852
|
* Requires public_api.read permission on the model.
|
|
1313
853
|
*/
|
|
1314
|
-
declare function listCmsEntries(modelSlug: string, params?: ListCmsEntriesParams): Promise<CmsEntryListResponse>;
|
|
854
|
+
declare function listCmsEntries(config: SdkConfig, modelSlug: string, params?: ListCmsEntriesParams): Promise<CmsEntryListResponse>;
|
|
1315
855
|
/**
|
|
1316
856
|
* Get a single CMS entry by ID.
|
|
1317
857
|
* Requires public_api.read permission on the model.
|
|
1318
858
|
*/
|
|
1319
|
-
declare function getCmsEntry(modelSlug: string, entryId: string): Promise<CmsEntry>;
|
|
859
|
+
declare function getCmsEntry(config: SdkConfig, modelSlug: string, entryId: string): Promise<CmsEntry>;
|
|
1320
860
|
/**
|
|
1321
861
|
* Create a new CMS entry.
|
|
1322
862
|
* Requires public_api.create permission on the model.
|
|
1323
863
|
*/
|
|
1324
|
-
declare function createCmsEntry(modelSlug: string, params: CreateCmsEntryParams): Promise<CmsEntry>;
|
|
864
|
+
declare function createCmsEntry(config: SdkConfig, accessToken: string, modelSlug: string, params: CreateCmsEntryParams): Promise<CmsEntry>;
|
|
1325
865
|
/**
|
|
1326
866
|
* Update an existing CMS entry.
|
|
1327
867
|
* Requires public_api.update permission on the model.
|
|
1328
868
|
*/
|
|
1329
|
-
declare function updateCmsEntry(modelSlug: string, entryId: string, params: UpdateCmsEntryParams): Promise<CmsEntry>;
|
|
869
|
+
declare function updateCmsEntry(config: SdkConfig, accessToken: string, modelSlug: string, entryId: string, params: UpdateCmsEntryParams): Promise<CmsEntry>;
|
|
1330
870
|
/**
|
|
1331
871
|
* Delete a CMS entry.
|
|
1332
872
|
* Requires public_api.delete permission on the model.
|
|
1333
873
|
*/
|
|
1334
|
-
declare function deleteCmsEntry(modelSlug: string, entryId: string): Promise<void>;
|
|
1335
|
-
|
|
1336
|
-
/**
|
|
1337
|
-
* Cart Hook & Context Provider
|
|
1338
|
-
*
|
|
1339
|
-
* React Query hooks for cart operations with unified drawer state sharing.
|
|
1340
|
-
*/
|
|
1341
|
-
|
|
1342
|
-
interface UseCartReturn {
|
|
1343
|
-
cart: CartResponse | undefined;
|
|
1344
|
-
items: CartItem[];
|
|
1345
|
-
count: number;
|
|
1346
|
-
isOpen: boolean;
|
|
1347
|
-
setOpen: (open: boolean) => void;
|
|
1348
|
-
isLoading: boolean;
|
|
1349
|
-
error: Error | null;
|
|
1350
|
-
addToCart: (item: {
|
|
1351
|
-
product_id: string;
|
|
1352
|
-
product_slug: string;
|
|
1353
|
-
product_name: string;
|
|
1354
|
-
image?: string;
|
|
1355
|
-
variant_id?: string;
|
|
1356
|
-
variant_attributes?: string;
|
|
1357
|
-
unit_price: number;
|
|
1358
|
-
quantity: number;
|
|
1359
|
-
custom_measurements?: string;
|
|
1360
|
-
is_bespoke: boolean;
|
|
1361
|
-
}) => void;
|
|
1362
|
-
updateCartItem: (variables: {
|
|
1363
|
-
itemId: string;
|
|
1364
|
-
quantity: number;
|
|
1365
|
-
}) => void;
|
|
1366
|
-
removeFromCart: (itemId: string) => void;
|
|
1367
|
-
clearCart: () => void;
|
|
1368
|
-
clear: () => void;
|
|
1369
|
-
mergeGuestCart: () => void;
|
|
1370
|
-
addItem: (product: Product, variantId?: string, quantity?: number, customMeasurements?: Record<string, string>) => void;
|
|
1371
|
-
updateQty: (itemId: string, quantity: number) => void;
|
|
1372
|
-
removeItem: (itemId: string) => void;
|
|
1373
|
-
subtotal: number;
|
|
1374
|
-
productTypeMismatch: {
|
|
1375
|
-
message: string;
|
|
1376
|
-
existing_type: string;
|
|
1377
|
-
new_type: string;
|
|
1378
|
-
} | null;
|
|
1379
|
-
handleClearCartAndAdd: () => void;
|
|
1380
|
-
handleKeepCurrentCart: () => void;
|
|
1381
|
-
}
|
|
1382
|
-
interface CartContextValue {
|
|
1383
|
-
isOpen: boolean;
|
|
1384
|
-
setOpen: (open: boolean) => void;
|
|
1385
|
-
}
|
|
1386
|
-
declare const CartCtx: React.Context<CartContextValue | null> | null;
|
|
1387
|
-
declare function CartProvider({ children }: {
|
|
1388
|
-
children: ReactNode;
|
|
1389
|
-
}): string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.FunctionComponentElement<React.ProviderProps<CartContextValue | null>> | null | undefined;
|
|
1390
|
-
declare function useCart(): UseCartReturn;
|
|
1391
|
-
|
|
1392
|
-
declare function useOrders(params?: {
|
|
1393
|
-
email?: string;
|
|
1394
|
-
page?: number;
|
|
1395
|
-
page_size?: number;
|
|
1396
|
-
}): _tanstack_react_query.UseQueryResult<NoInfer<Order[]>, Error>;
|
|
1397
|
-
declare function useOrdersList(params?: {
|
|
1398
|
-
email?: string;
|
|
1399
|
-
page?: number;
|
|
1400
|
-
page_size?: number;
|
|
1401
|
-
}): _tanstack_react_query.UseQueryResult<NoInfer<Order[]>, Error>;
|
|
1402
|
-
declare function useFindOrder(params: FindOrderParams): _tanstack_react_query.UseQueryResult<NoInfer<Order>, Error>;
|
|
1403
|
-
declare function useOrder(params: FindOrderParams): _tanstack_react_query.UseQueryResult<NoInfer<Order>, Error>;
|
|
1404
|
-
declare function useOrderTracking(orderId: string, token?: string): _tanstack_react_query.UseQueryResult<NoInfer<Order>, Error>;
|
|
1405
|
-
declare function useCreateOrder(): _tanstack_react_query.UseMutationResult<Order, Error, CreateOrderParams, unknown>;
|
|
1406
|
-
declare function useCancelOrder(): _tanstack_react_query.UseMutationResult<Order, Error, {
|
|
1407
|
-
orderId: string;
|
|
1408
|
-
reason: string;
|
|
1409
|
-
}, unknown>;
|
|
1410
|
-
|
|
1411
|
-
declare const AuthCtx: React.Context<AuthContextValue | null> | null;
|
|
1412
|
-
declare function AuthProvider({ children }: {
|
|
1413
|
-
children: ReactNode;
|
|
1414
|
-
}): string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.FunctionComponentElement<React.ProviderProps<AuthContextValue | null>> | null | undefined;
|
|
1415
|
-
declare function useAuthUser(): _tanstack_react_query.UseQueryResult<NoInfer<AuthUserResponse>, Error>;
|
|
1416
|
-
declare function useLogin(): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, Error, Omit<CustomerLoginPayload, "tenant_id">, unknown>;
|
|
1417
|
-
declare function useRegister(): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, Error, Omit<CustomerRegisterPayload, "tenant_id">, unknown>;
|
|
1418
|
-
declare function useUpdateProfile(): _tanstack_react_query.UseMutationResult<CustomerUser, Error, UpdateProfilePayload, unknown>;
|
|
1419
|
-
declare function useLogout(): _tanstack_react_query.UseMutationResult<void, Error, void, unknown>;
|
|
1420
|
-
/**
|
|
1421
|
-
* useAuth()
|
|
1422
|
-
* Consumes the AuthCtx provider value. Falls back to local hook query if no provider exists.
|
|
1423
|
-
*/
|
|
1424
|
-
declare function useAuth(): AuthContextValue;
|
|
1425
|
-
|
|
1426
|
-
declare function getCountries(): Promise<Country[]>;
|
|
1427
|
-
declare function useCountries(): _tanstack_react_query.UseQueryResult<NoInfer<Country[]>, Error>;
|
|
1428
|
-
|
|
1429
|
-
declare function getStates(countryIso: string): Promise<State[]>;
|
|
1430
|
-
declare function useStates(countryIso: string): _tanstack_react_query.UseQueryResult<NoInfer<State[]>, Error>;
|
|
1431
|
-
|
|
1432
|
-
declare function getSupportedLanguagesList(): Promise<SupportedLang[]>;
|
|
1433
|
-
declare function useSupportedLanguages(): _tanstack_react_query.UseQueryResult<NoInfer<SupportedLang[]>, Error>;
|
|
1434
|
-
|
|
1435
|
-
declare function getSupportedCurrenciesList(): Promise<Currency[]>;
|
|
1436
|
-
declare function useCurrencies(): _tanstack_react_query.UseQueryResult<NoInfer<Currency[]>, Error>;
|
|
1437
|
-
|
|
1438
|
-
/**
|
|
1439
|
-
* Get bespoke availability for a product
|
|
1440
|
-
*/
|
|
1441
|
-
declare function useBespokeAvailability(product_id: string): _tanstack_react_query.UseQueryResult<NoInfer<BespokeAvailability>, Error>;
|
|
1442
|
-
|
|
1443
|
-
declare const collectionKeys: {
|
|
1444
|
-
all: readonly ["core", "collections"];
|
|
1445
|
-
list: (params?: ListParams) => readonly ["core", "collections", "list", ListParams];
|
|
1446
|
-
slug: (slug: string) => readonly ["core", "collections", "slug", string];
|
|
1447
|
-
};
|
|
1448
|
-
/**
|
|
1449
|
-
* Hook to fetch paginated collections for the storefront.
|
|
1450
|
-
*/
|
|
1451
|
-
declare function useStorefrontCollections(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Collection>>, Error>;
|
|
1452
|
-
/**
|
|
1453
|
-
* Hook to fetch a single collection by slug for the storefront.
|
|
1454
|
-
*/
|
|
1455
|
-
declare function useStorefrontCollection(slug: string): _tanstack_react_query.UseQueryResult<NoInfer<Collection>, Error>;
|
|
1456
|
-
|
|
1457
|
-
declare const productKeys: {
|
|
1458
|
-
all: readonly ["products"];
|
|
1459
|
-
list: (params?: ListParams) => readonly ["products", "list", ListParams | undefined];
|
|
1460
|
-
detail: (slug: string) => readonly ["products", "detail", string];
|
|
1461
|
-
recommended: (params?: ListParams) => readonly ["products", "recommended", ListParams | undefined];
|
|
1462
|
-
latest: (params?: ListParams) => readonly ["products", "latest", ListParams | undefined];
|
|
1463
|
-
popular: (params?: ListParams) => readonly ["products", "popular", ListParams | undefined];
|
|
1464
|
-
featured: (params?: ListParams) => readonly ["products", "featured", ListParams | undefined];
|
|
1465
|
-
new: (params?: ListParams) => readonly ["products", "new", ListParams | undefined];
|
|
1466
|
-
};
|
|
1467
|
-
/**
|
|
1468
|
-
* Hook for fetching latest products.
|
|
1469
|
-
*/
|
|
1470
|
-
declare function useLatestProducts(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Product>>, Error>;
|
|
1471
|
-
/**
|
|
1472
|
-
* Hook for fetching popular products.
|
|
1473
|
-
*/
|
|
1474
|
-
declare function usePopularProducts(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Product>>, Error>;
|
|
1475
|
-
/**
|
|
1476
|
-
* Hook for fetching featured products.
|
|
1477
|
-
*/
|
|
1478
|
-
declare function useFeaturedProducts(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Product>>, Error>;
|
|
1479
|
-
/**
|
|
1480
|
-
* Hook for fetching new products.
|
|
1481
|
-
*/
|
|
1482
|
-
declare function useNewProducts(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Product>>, Error>;
|
|
1483
|
-
/**
|
|
1484
|
-
* Hook for fetching all active storefront products.
|
|
1485
|
-
*/
|
|
1486
|
-
declare function useStorefrontProducts(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Product>>, Error>;
|
|
1487
|
-
/**
|
|
1488
|
-
* Hook for fetching a single product by slug.
|
|
1489
|
-
*/
|
|
1490
|
-
declare function useProduct(slug: string): _tanstack_react_query.UseQueryResult<NoInfer<Product>, Error>;
|
|
1491
|
-
/**
|
|
1492
|
-
* Hook for fetching recommended products.
|
|
1493
|
-
*/
|
|
1494
|
-
declare function useRecommendedProducts(params?: ListParams): _tanstack_react_query.UseQueryResult<NoInfer<PaginatedResponse<Product>>, Error>;
|
|
1495
|
-
|
|
1496
|
-
declare const wishlistKeys: {
|
|
1497
|
-
all: readonly ["wishlist"];
|
|
1498
|
-
list: () => readonly ["wishlist", "list"];
|
|
1499
|
-
check: (productId: string) => readonly ["wishlist", "check", string];
|
|
1500
|
-
};
|
|
1501
|
-
/**
|
|
1502
|
-
* Hook for fetching the customer's wishlist.
|
|
1503
|
-
* Authentication-gated only - returns empty for unauthenticated users.
|
|
1504
|
-
*/
|
|
1505
|
-
declare function useWishlist(params?: {
|
|
1506
|
-
page?: number;
|
|
1507
|
-
pageSize?: number;
|
|
1508
|
-
}): _tanstack_react_query.UseQueryResult<NoInfer<WishlistListResponse>, Error>;
|
|
1509
|
-
/**
|
|
1510
|
-
* Hook for checking if a product is in the wishlist.
|
|
1511
|
-
* Authentication-gated only - returns false for unauthenticated users.
|
|
1512
|
-
*/
|
|
1513
|
-
declare function useCheckInWishlist(productId: string): _tanstack_react_query.UseQueryResult<NoInfer<WishlistCheckResponse>, Error>;
|
|
1514
|
-
/**
|
|
1515
|
-
* Hook for adding a product to the wishlist.
|
|
1516
|
-
* Authentication-gated only - triggers login modal for unauthenticated users.
|
|
1517
|
-
*/
|
|
1518
|
-
declare function useAddToWishlist(): _tanstack_react_query.UseMutationResult<WishlistItem, Error, {
|
|
1519
|
-
productId: string;
|
|
1520
|
-
notes?: string;
|
|
1521
|
-
}, unknown>;
|
|
1522
|
-
/**
|
|
1523
|
-
* Hook for removing an item from the wishlist by item ID.
|
|
1524
|
-
*/
|
|
1525
|
-
declare function useRemoveFromWishlist(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
1526
|
-
/**
|
|
1527
|
-
* Hook for removing a product from the wishlist by product ID.
|
|
1528
|
-
*/
|
|
1529
|
-
declare function useRemoveProductFromWishlist(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
1530
|
-
/**
|
|
1531
|
-
* Hook for getting wishlist count.
|
|
1532
|
-
* Authentication-gated only - returns 0 for unauthenticated users.
|
|
1533
|
-
*/
|
|
1534
|
-
declare function useWishlistCount(): _tanstack_react_query.UseQueryResult<number, Error>;
|
|
1535
|
-
|
|
1536
|
-
/**
|
|
1537
|
-
* Get available slots for a service product
|
|
1538
|
-
*/
|
|
1539
|
-
declare function useAvailableSlots(product_id: string, date_from: string, date_to: string): _tanstack_react_query.UseQueryResult<NoInfer<AvailableSlot[]>, Error>;
|
|
1540
|
-
/**
|
|
1541
|
-
* Book a service appointment
|
|
1542
|
-
*/
|
|
1543
|
-
declare function useBookAppointment(): _tanstack_react_query.UseMutationResult<ServiceAppointment, Error, ServiceAppointmentCreatePayload, unknown>;
|
|
1544
|
-
/**
|
|
1545
|
-
* Get all appointments for the current user
|
|
1546
|
-
*/
|
|
1547
|
-
declare function useAppointments(): _tanstack_react_query.UseQueryResult<NoInfer<ServiceAppointment[]>, Error>;
|
|
1548
|
-
/**
|
|
1549
|
-
* Get a single appointment by ID
|
|
1550
|
-
*/
|
|
1551
|
-
declare function useAppointment(id: string): _tanstack_react_query.UseQueryResult<NoInfer<ServiceAppointment>, Error>;
|
|
1552
|
-
/**
|
|
1553
|
-
* Cancel an appointment
|
|
1554
|
-
*/
|
|
1555
|
-
declare function useCancelAppointment(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
1556
|
-
/**
|
|
1557
|
-
* Get deliverables for a project-based service order
|
|
1558
|
-
*/
|
|
1559
|
-
declare function useDeliverables(order_id: string): _tanstack_react_query.UseQueryResult<NoInfer<ServiceDeliverable[]>, Error>;
|
|
1560
|
-
/**
|
|
1561
|
-
* Approve a deliverable
|
|
1562
|
-
*/
|
|
1563
|
-
declare function useApproveDeliverable(order_id: string, deliverable_id: string): _tanstack_react_query.UseMutationResult<ServiceDeliverable, Error, void, unknown>;
|
|
1564
|
-
/**
|
|
1565
|
-
* Request revision for a deliverable
|
|
1566
|
-
*/
|
|
1567
|
-
declare function useRequestRevision(order_id: string, deliverable_id: string): _tanstack_react_query.UseMutationResult<ServiceDeliverable, Error, string, unknown>;
|
|
1568
|
-
|
|
1569
|
-
declare function useConsultations(): _tanstack_react_query.UseQueryResult<NoInfer<Consultation[]>, Error>;
|
|
1570
|
-
declare function useConsultation(id: string): _tanstack_react_query.UseQueryResult<NoInfer<Consultation>, Error>;
|
|
1571
|
-
declare function useCreateConsultation(): _tanstack_react_query.UseMutationResult<Consultation, Error, ConsultationCreatePayload, unknown>;
|
|
1572
|
-
declare function useSendMessage(consultationId: string): _tanstack_react_query.UseMutationResult<void, Error, ConsultationMessagePayload, unknown>;
|
|
1573
|
-
declare function useAcceptQuote(consultationId: string): _tanstack_react_query.UseMutationResult<Consultation, Error, ConsultationQuoteAcceptPayload, unknown>;
|
|
1574
|
-
declare function useRejectQuote(consultationId: string): _tanstack_react_query.UseMutationResult<Consultation, Error, string | undefined, unknown>;
|
|
1575
|
-
|
|
1576
|
-
interface ConsultationMessageData {
|
|
1577
|
-
event: string;
|
|
1578
|
-
data: {
|
|
1579
|
-
consultation_id: string;
|
|
1580
|
-
message_id: string;
|
|
1581
|
-
sender_id: string;
|
|
1582
|
-
sender_role: string;
|
|
1583
|
-
message: string;
|
|
1584
|
-
attachments?: Array<{
|
|
1585
|
-
url: string;
|
|
1586
|
-
type: string;
|
|
1587
|
-
name: string;
|
|
1588
|
-
}>;
|
|
1589
|
-
created_at: string;
|
|
1590
|
-
};
|
|
1591
|
-
}
|
|
1592
|
-
interface ConsultationQuoteData {
|
|
1593
|
-
event: string;
|
|
1594
|
-
data: {
|
|
1595
|
-
consultation_id: string;
|
|
1596
|
-
quote_amount: number;
|
|
1597
|
-
deposit_amount?: number;
|
|
1598
|
-
merchant_notes?: string;
|
|
1599
|
-
updated_at: string;
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
interface ConsultationStatusData {
|
|
1603
|
-
event: string;
|
|
1604
|
-
data: {
|
|
1605
|
-
consultation_id: string;
|
|
1606
|
-
status: string;
|
|
1607
|
-
updated_at: string;
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
interface UseConsultationStreamOptions {
|
|
1611
|
-
consultationId: string;
|
|
1612
|
-
onMessage?: (data: ConsultationMessageData) => void;
|
|
1613
|
-
onQuote?: (data: ConsultationQuoteData) => void;
|
|
1614
|
-
onStatusChange?: (data: ConsultationStatusData) => void;
|
|
1615
|
-
onError?: (error: Error) => void;
|
|
1616
|
-
}
|
|
1617
|
-
declare function useConsultationStream({ consultationId, onMessage, onQuote, onStatusChange, onError, }: UseConsultationStreamOptions): {
|
|
1618
|
-
isConnected: boolean;
|
|
1619
|
-
lastEvent: any;
|
|
1620
|
-
};
|
|
1621
|
-
|
|
1622
|
-
interface PaymentSuccessData {
|
|
1623
|
-
event: string;
|
|
1624
|
-
data: {
|
|
1625
|
-
transaction_id: string;
|
|
1626
|
-
order_id: string;
|
|
1627
|
-
amount: number;
|
|
1628
|
-
currency: string;
|
|
1629
|
-
status: string;
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
interface DigitalReadyData {
|
|
1633
|
-
event: string;
|
|
1634
|
-
data: {
|
|
1635
|
-
order_id: string;
|
|
1636
|
-
business_id: string;
|
|
1637
|
-
customer_id: string;
|
|
1638
|
-
download_links: Array<{
|
|
1639
|
-
item_id: string;
|
|
1640
|
-
product_name: string;
|
|
1641
|
-
url: string;
|
|
1642
|
-
token: string;
|
|
1643
|
-
expires_at: string;
|
|
1644
|
-
max_downloads: number;
|
|
1645
|
-
}>;
|
|
1646
|
-
fulfilled_at: string;
|
|
1647
|
-
};
|
|
1648
|
-
}
|
|
1649
|
-
interface BespokeUpdateData {
|
|
1650
|
-
event: string;
|
|
1651
|
-
data: {
|
|
1652
|
-
order_id: string;
|
|
1653
|
-
business_id: string;
|
|
1654
|
-
update_type: string;
|
|
1655
|
-
message: string;
|
|
1656
|
-
stage?: string;
|
|
1657
|
-
updated_at: string;
|
|
1658
|
-
};
|
|
1659
|
-
}
|
|
1660
|
-
interface ConsultationUpdateData {
|
|
1661
|
-
event: string;
|
|
1662
|
-
data: {
|
|
1663
|
-
consultation_id: string;
|
|
1664
|
-
business_id: string;
|
|
1665
|
-
customer_id: string;
|
|
1666
|
-
status: string;
|
|
1667
|
-
message?: string;
|
|
1668
|
-
updated_at: string;
|
|
1669
|
-
};
|
|
1670
|
-
}
|
|
1671
|
-
interface ServiceBookingUpdateData {
|
|
1672
|
-
event: string;
|
|
1673
|
-
data: {
|
|
1674
|
-
booking_id: string;
|
|
1675
|
-
order_id: string;
|
|
1676
|
-
business_id: string;
|
|
1677
|
-
customer_id: string;
|
|
1678
|
-
status: string;
|
|
1679
|
-
appointment_date?: string;
|
|
1680
|
-
updated_at: string;
|
|
1681
|
-
};
|
|
1682
|
-
}
|
|
1683
|
-
interface UseOrderStreamOptions {
|
|
1684
|
-
orderId: string;
|
|
1685
|
-
onPaymentComplete?: (data: PaymentSuccessData) => void;
|
|
1686
|
-
onDigitalReady?: (data: DigitalReadyData) => void;
|
|
1687
|
-
onBespokeUpdate?: (data: BespokeUpdateData) => void;
|
|
1688
|
-
onConsultationUpdate?: (data: ConsultationUpdateData) => void;
|
|
1689
|
-
onServiceBookingUpdate?: (data: ServiceBookingUpdateData) => void;
|
|
1690
|
-
onError?: (error: Error) => void;
|
|
1691
|
-
}
|
|
1692
|
-
declare function useOrderStream({ orderId, onPaymentComplete, onDigitalReady, onBespokeUpdate, onConsultationUpdate, onServiceBookingUpdate, onError }: UseOrderStreamOptions): null;
|
|
1693
|
-
|
|
1694
|
-
declare function useIsMounted(): boolean;
|
|
1695
|
-
|
|
1696
|
-
interface GoogleTranslateOptions {
|
|
1697
|
-
pageLanguage: string;
|
|
1698
|
-
includedLanguages?: string;
|
|
1699
|
-
autoDisplay?: boolean;
|
|
1700
|
-
layout?: number;
|
|
1701
|
-
}
|
|
1702
|
-
interface GoogleTranslateElement {
|
|
1703
|
-
new (options: GoogleTranslateOptions, elementId: string): void;
|
|
1704
|
-
}
|
|
1705
|
-
interface GoogleNamespace {
|
|
1706
|
-
translate?: {
|
|
1707
|
-
TranslateElement: GoogleTranslateElement;
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
declare global {
|
|
1711
|
-
interface Window {
|
|
1712
|
-
googleTranslateElementInit?: () => void;
|
|
1713
|
-
google?: GoogleNamespace;
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
declare function useGoogleTranslate(appLang: string): {
|
|
1717
|
-
isLoaded: boolean;
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
|
-
/**
|
|
1721
|
-
* Hook for creating a Dedicated Virtual Account (DVA)
|
|
1722
|
-
*/
|
|
1723
|
-
declare function useCreateDVA(): _tanstack_react_query.UseMutationResult<DVADetails, Error, DVACreateRequest, unknown>;
|
|
1724
|
-
/**
|
|
1725
|
-
* Hook for initiating card payment
|
|
1726
|
-
*/
|
|
1727
|
-
declare function useInitiatePayment(): _tanstack_react_query.UseMutationResult<PaymentInitiateResponse, Error, PaymentInitiateRequest, unknown>;
|
|
1728
|
-
/**
|
|
1729
|
-
* Hook for verifying a transaction
|
|
1730
|
-
*/
|
|
1731
|
-
declare function useVerifyTransaction(): _tanstack_react_query.UseMutationResult<TransactionVerifyResponse, Error, string, unknown>;
|
|
1732
|
-
/**
|
|
1733
|
-
* Hook for getting transaction status
|
|
1734
|
-
*/
|
|
1735
|
-
declare function useTransactionStatus(transactionId: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<NoInfer<TransactionVerifyResponse>, Error>;
|
|
1736
|
-
/**
|
|
1737
|
-
* Hook for checking transaction status with automatic polling
|
|
1738
|
-
*/
|
|
1739
|
-
declare function usePollTransactionStatus(reference: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<NoInfer<TransactionVerifyResponse>, Error>;
|
|
1740
|
-
|
|
1741
|
-
interface UseCmsEntriesReturn {
|
|
1742
|
-
entries: CmsEntry[];
|
|
1743
|
-
total: number;
|
|
1744
|
-
page: number;
|
|
1745
|
-
page_size: number;
|
|
1746
|
-
isLoading: boolean;
|
|
1747
|
-
error: Error | null;
|
|
1748
|
-
refetch: () => void;
|
|
1749
|
-
}
|
|
1750
|
-
/**
|
|
1751
|
-
* Hook to list CMS entries for a specific model.
|
|
1752
|
-
*/
|
|
1753
|
-
declare function useCmsEntries(modelSlug: string, params?: ListCmsEntriesParams): UseCmsEntriesReturn;
|
|
1754
|
-
interface UseCmsEntryReturn {
|
|
1755
|
-
entry: CmsEntry | undefined;
|
|
1756
|
-
isLoading: boolean;
|
|
1757
|
-
error: Error | null;
|
|
1758
|
-
refetch: () => void;
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Hook to get a single CMS entry by ID.
|
|
1762
|
-
*/
|
|
1763
|
-
declare function useCmsEntry(modelSlug: string, entryId: string): UseCmsEntryReturn;
|
|
1764
|
-
interface UseCreateCmsEntryReturn {
|
|
1765
|
-
createEntry: (params: CreateCmsEntryParams) => void;
|
|
1766
|
-
isLoading: boolean;
|
|
1767
|
-
error: Error | null;
|
|
1768
|
-
}
|
|
1769
|
-
/**
|
|
1770
|
-
* Hook to create a new CMS entry.
|
|
1771
|
-
*/
|
|
1772
|
-
declare function useCreateCmsEntry(modelSlug: string): UseCreateCmsEntryReturn;
|
|
1773
|
-
interface UseUpdateCmsEntryReturn {
|
|
1774
|
-
updateEntry: (entryId: string, params: UpdateCmsEntryParams) => void;
|
|
1775
|
-
isLoading: boolean;
|
|
1776
|
-
error: Error | null;
|
|
1777
|
-
}
|
|
1778
|
-
/**
|
|
1779
|
-
* Hook to update an existing CMS entry.
|
|
1780
|
-
*/
|
|
1781
|
-
declare function useUpdateCmsEntry(modelSlug: string): UseUpdateCmsEntryReturn;
|
|
1782
|
-
interface UseDeleteCmsEntryReturn {
|
|
1783
|
-
deleteEntry: (entryId: string) => void;
|
|
1784
|
-
isLoading: boolean;
|
|
1785
|
-
error: Error | null;
|
|
1786
|
-
}
|
|
1787
|
-
/**
|
|
1788
|
-
* Hook to delete a CMS entry.
|
|
1789
|
-
*/
|
|
1790
|
-
declare function useDeleteCmsEntry(modelSlug: string): UseDeleteCmsEntryReturn;
|
|
874
|
+
declare function deleteCmsEntry(config: SdkConfig, accessToken: string, modelSlug: string, entryId: string): Promise<void>;
|
|
1791
875
|
|
|
1792
876
|
/**
|
|
1793
877
|
* Cache Tiers Utility
|
|
@@ -1873,6 +957,11 @@ declare function splitFullName(fullName?: string): {
|
|
|
1873
957
|
lastname: string;
|
|
1874
958
|
};
|
|
1875
959
|
declare function getCustomerDisplayName(user: CustomerUser): string;
|
|
960
|
+
/**
|
|
961
|
+
* Constructs live storefront URL for a business.
|
|
962
|
+
* If custom domain is not yet connected/verified, defaults to `https://<business_id>.kasuvia.com`.
|
|
963
|
+
*/
|
|
964
|
+
declare function getStorefrontUrl(businessId: string, customDomain?: string | null): string;
|
|
1876
965
|
|
|
1877
966
|
declare function buildDeliveryAddress(customer: CheckoutCustomer, location: ShippingLocation): DeliveryAddress;
|
|
1878
967
|
declare function getCheckoutCustomerName(customer: CheckoutCustomer): string;
|
|
@@ -1885,7 +974,45 @@ declare function enrichCompletedOrder(order: Order, options: {
|
|
|
1885
974
|
|
|
1886
975
|
/**
|
|
1887
976
|
* Type-safe way to extract an error message from an API error.
|
|
977
|
+
* Updated for fetch-based errors (no axios dependency).
|
|
1888
978
|
*/
|
|
1889
979
|
declare function getErrorMessage(error: unknown, fallback?: string): string;
|
|
1890
980
|
|
|
1891
|
-
|
|
981
|
+
/**
|
|
982
|
+
* @file storage.ts
|
|
983
|
+
* @description Centralized tenant-isolated storage utility for sessionStorage and localStorage.
|
|
984
|
+
* Automatically prefixes all keys with the storefront Business ID to guarantee multi-tenant segregation.
|
|
985
|
+
* Stateless - requires businessId parameter.
|
|
986
|
+
*/
|
|
987
|
+
declare const sessionStore: {
|
|
988
|
+
get: (businessIdOrKey: string, key?: string) => string | null;
|
|
989
|
+
set: (businessIdOrKey: string, keyOrVal: string, val?: string) => void;
|
|
990
|
+
remove: (businessIdOrKey: string, key?: string) => void;
|
|
991
|
+
getJSON: <T = unknown>(businessIdOrKey: string, key?: string) => T | null;
|
|
992
|
+
setJSON: (businessIdOrKey: string, keyOrVal: unknown, val?: unknown) => void;
|
|
993
|
+
};
|
|
994
|
+
declare const localStore: {
|
|
995
|
+
get: (businessIdOrKey: string, key?: string) => string | null;
|
|
996
|
+
set: (businessIdOrKey: string, keyOrVal: string, val?: string) => void;
|
|
997
|
+
remove: (businessIdOrKey: string, key?: string) => void;
|
|
998
|
+
getJSON: <T = unknown>(businessIdOrKey: string, key?: string) => T | null;
|
|
999
|
+
setJSON: (businessIdOrKey: string, keyOrVal: unknown, val?: unknown) => void;
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Form validation utilities for kasuvia-sdk
|
|
1004
|
+
* Provides realtime validation for email, password, name, confirm password, and message fields
|
|
1005
|
+
*/
|
|
1006
|
+
declare function validateEmail(email: string): string | null;
|
|
1007
|
+
declare function validatePassword(password: string): string | null;
|
|
1008
|
+
declare function validateName(name: string, fieldName?: string): string | null;
|
|
1009
|
+
declare function validateRequired(value: string, fieldName: string): string | null;
|
|
1010
|
+
/**
|
|
1011
|
+
* Validates the confirm-password field.
|
|
1012
|
+
* Returns null (no error) when the field is empty — avoids nagging the user
|
|
1013
|
+
* before they've had a chance to type anything.
|
|
1014
|
+
*/
|
|
1015
|
+
declare function validateConfirmPassword(password: string, confirmPassword: string): string | null;
|
|
1016
|
+
declare function validateMessage(message: string): string | null;
|
|
1017
|
+
|
|
1018
|
+
export { type AppointmentStatus, type AuthContextValue, type AuthUserResponse, type AvailableSlot, type AvatarObject, type BespokeAvailability, type BespokeCapacityConfig, type BespokeSlotBooking, type BusinessConfig, type BusinessContext, CartItem, type CartItemPayload, CartResponse, CheckoutCustomer, CmsEntry, CmsEntryListResponse, Collection, type Consultation, type ConsultationCreatePayload, type ConsultationMessage, type ConsultationMessagePayload, type ConsultationProductType, type ConsultationQuoteAcceptPayload, type ConsultationStatus, type ContactFormData, ConversionQuote, CreateCmsEntryParams, CreateOrderParams, type CustomerAuthResponse, type CustomerLoginPayload, type CustomerProfileFields, type CustomerRegisterPayload, type CustomerUser, DVACreateRequest, DVADetails, type DeliverableApprovalPayload, type DeliverableStatus, type DeliverableStatusType, DeliveryAddress, FindOrderParams, InvalidBaseURLError, ListCmsEntriesParams, ListParams, type LogoutPayload, type MediaAsset, type MediaAssetUpdatePayload, type MediaUploadParams, type NotificationPreferences, type OTPVerifyPayload, Order, PaginatedResponse, PaymentInitiateRequest, PaymentInitiateResponse, Product, ProductVariant, type RateAddress, type RefreshTokenResponse, type ResendOTPPayload, STORAGE_KEYS, SdkConfig, type ServiceAppointment, type ServiceAppointmentCreatePayload, type ServiceDeliverable, ServiceLocationType, ShippingLocation, type ShippingRatesRequest, ShippingRatesResponse, type SlotBookingStatus, type StorageStats, SupportedCurrenciesResponse, SupportedLanguagesResponse, TransactionVerifyResponse, UpdateCmsEntryParams, type UpdateProfilePayload, WishlistCheckResponse, WishlistItem, WishlistListResponse, acceptQuote, addToCart, addToGuestCart, addToWishlist, approveDeliverable, bespokeService, bookAppointment, buildDeliveryAddress, buildFullName, cancelAppointment, cancelOrder, checkAvailability, checkInWishlist, clearCart, clearGuestCart, clearTokens, configService, consultationService, createCmsEntry, createConsultation, createDedicatedAccount, createOrder, deleteCmsEntry, enrichCompletedOrder, findOrder, findOrderByToken, getAppointment, getAppointments, getAuthUser, getAvailableSlots, getBusinessConfig, getCacheTier, getCart, getCheckoutCustomerName, getCmsEntry, getConsultation, getConsultations, getCustomerDisplayName, getDeliverables, getErrorMessage, getFeaturedProducts, getGuestCart, getGuestCartCount, getGuestCartProductType, getGuestCartSubtotal, getLatestProducts, getLowStockProducts, getMe, getNewProducts, getOnSaleProducts, getOrders, getPopularProducts, getRecommendedProducts, getSellerShippingAddress, getShippingRates, getStoredTokens, getStorefrontCollectionBySlug, getStorefrontCollections, getStorefrontProductBySlug, getStorefrontProducts, getStorefrontUrl, getSupportedCurrencies, getSupportedLanguages, getTransactionStatus, getWishlist, googleTranslate, initiatePayment, listCmsEntries, localStore, logger, loginCustomer, logisticsService, logout, mapAuthUserToCustomer, mergeGuestCart, mergeGuestCartIfPresent, notificationsService, paymentService, refreshToken, registerCustomer, rejectQuote, removeFromCart, removeFromGuestCart, removeFromWishlist, removeProductFromWishlist, requestQuote, requestRevision, sanitizeBaseUrl, sendContactConfirmation, sendContactEmail, sendMessage, serviceBookingService, sessionStore, setEnvironmentMode, setLoggerEnvironmentMode, silentRefresh, splitFullName, storeTokens, trackOrder, updateCartItem, updateCmsEntry, updateGuestCartItemQuantity, updateProfile, validateConfirmPassword, validateEmail, validateMessage, validateName, validatePassword, validateRequired, validateShippingAddress, verifySocialToken, verifyTransaction };
|