@huskel/sdk 0.4.2 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1045 -159
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +66 -28
- package/dist/index.d.ts +66 -28
- package/dist/index.js +887 -277
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +879 -272
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -49,11 +49,36 @@ interface RawProductInput {
|
|
|
49
49
|
tags?: string[];
|
|
50
50
|
specs?: Record<string, string>;
|
|
51
51
|
}
|
|
52
|
+
interface CartItem {
|
|
53
|
+
id: string;
|
|
54
|
+
cart_id: string;
|
|
55
|
+
external_id?: string;
|
|
56
|
+
product_url: string;
|
|
57
|
+
name: string;
|
|
58
|
+
price: string;
|
|
59
|
+
price_numeric: number;
|
|
60
|
+
currency: string;
|
|
61
|
+
image: string;
|
|
62
|
+
brand: string;
|
|
63
|
+
category: string;
|
|
64
|
+
quantity: number;
|
|
65
|
+
}
|
|
66
|
+
interface CartPayload {
|
|
67
|
+
cart_id: string;
|
|
68
|
+
shopper_id: string;
|
|
69
|
+
site_id: string;
|
|
70
|
+
status: string;
|
|
71
|
+
items: CartItem[];
|
|
72
|
+
total: number;
|
|
73
|
+
currency: string;
|
|
74
|
+
item_count: number;
|
|
75
|
+
}
|
|
52
76
|
interface HuskelConfig {
|
|
53
77
|
siteId?: string;
|
|
54
78
|
apiUrl?: string;
|
|
55
79
|
apiToken?: string;
|
|
56
80
|
shopperId?: string;
|
|
81
|
+
onCheckout?: (cart: CartPayload) => void;
|
|
57
82
|
}
|
|
58
83
|
interface SearchRequest {
|
|
59
84
|
query: string;
|
|
@@ -78,6 +103,13 @@ interface HuskelError {
|
|
|
78
103
|
status: number;
|
|
79
104
|
message: string;
|
|
80
105
|
}
|
|
106
|
+
interface HuskelTheme {
|
|
107
|
+
primaryColor?: string;
|
|
108
|
+
backgroundColor?: string;
|
|
109
|
+
textColor?: string;
|
|
110
|
+
fontFamily?: string;
|
|
111
|
+
borderRadius?: string;
|
|
112
|
+
}
|
|
81
113
|
|
|
82
114
|
declare class HuskelAPI {
|
|
83
115
|
private apiUrl;
|
|
@@ -98,7 +130,14 @@ declare class HuskelAPI {
|
|
|
98
130
|
}>): Promise<{
|
|
99
131
|
answer: string;
|
|
100
132
|
sources: any[];
|
|
133
|
+
checkout?: CartPayload;
|
|
134
|
+
action?: any;
|
|
101
135
|
}>;
|
|
136
|
+
private buildHeaders;
|
|
137
|
+
getCart(): Promise<CartPayload>;
|
|
138
|
+
clearCart(): Promise<CartPayload>;
|
|
139
|
+
checkoutCart(): Promise<CartPayload>;
|
|
140
|
+
getCheckoutConfig(): Promise<any>;
|
|
102
141
|
}
|
|
103
142
|
|
|
104
143
|
declare class HuskelClient {
|
|
@@ -109,11 +148,13 @@ declare class HuskelClient {
|
|
|
109
148
|
private onlineHandler;
|
|
110
149
|
private shopperId?;
|
|
111
150
|
private sessionId;
|
|
151
|
+
onCheckout?: (cart: CartPayload) => void;
|
|
112
152
|
private static INGEST_CACHE_KEY;
|
|
113
153
|
private static INGEST_CACHE_TTL;
|
|
114
154
|
private loadIngestedCache;
|
|
115
155
|
private saveIngestedCache;
|
|
116
156
|
constructor(config: HuskelConfig);
|
|
157
|
+
reRegister(): void;
|
|
117
158
|
setShopperId(id: string | undefined): void;
|
|
118
159
|
getShopperId(): string | undefined;
|
|
119
160
|
getSessionId(): string;
|
|
@@ -189,27 +230,28 @@ interface UseChatReturn {
|
|
|
189
230
|
sources: ChatSource[];
|
|
190
231
|
loading: boolean;
|
|
191
232
|
error: string | null;
|
|
192
|
-
send: (query: string) => Promise<void>;
|
|
233
|
+
send: (query: string, displayQuery?: string) => Promise<void>;
|
|
193
234
|
reset: () => void;
|
|
194
235
|
}
|
|
195
236
|
declare function useChat(): UseChatReturn;
|
|
196
237
|
|
|
238
|
+
declare function useCart(): {
|
|
239
|
+
cart: CartPayload | null;
|
|
240
|
+
loading: boolean;
|
|
241
|
+
fetchCart: () => Promise<void>;
|
|
242
|
+
};
|
|
243
|
+
|
|
197
244
|
interface SearchBarProps {
|
|
198
245
|
placeholder?: string;
|
|
199
246
|
limit?: number;
|
|
200
|
-
/** Debounce in ms — default
|
|
247
|
+
/** Debounce in ms — default 300 for smooth type-ahead */
|
|
201
248
|
debounceMs?: number;
|
|
202
249
|
onSelect?: (result: SearchResult) => void;
|
|
203
250
|
className?: string;
|
|
204
251
|
inputClassName?: string;
|
|
205
252
|
dropdownClassName?: string;
|
|
206
253
|
renderResult?: (result: SearchResult) => React.ReactNode;
|
|
207
|
-
theme?:
|
|
208
|
-
primaryColor?: string;
|
|
209
|
-
backgroundColor?: string;
|
|
210
|
-
textColor?: string;
|
|
211
|
-
fontFamily?: string;
|
|
212
|
-
};
|
|
254
|
+
theme?: HuskelTheme;
|
|
213
255
|
classNames?: {
|
|
214
256
|
root?: string;
|
|
215
257
|
input?: string;
|
|
@@ -231,20 +273,16 @@ interface SparkleProps {
|
|
|
231
273
|
className?: string;
|
|
232
274
|
/** Called when user clicks a result — return false to prevent default navigation */
|
|
233
275
|
onNavigate?: (result: SearchResult) => boolean | void;
|
|
234
|
-
theme?:
|
|
235
|
-
primaryColor?: string;
|
|
236
|
-
backgroundColor?: string;
|
|
237
|
-
textColor?: string;
|
|
238
|
-
fontFamily?: string;
|
|
239
|
-
};
|
|
276
|
+
theme?: HuskelTheme;
|
|
240
277
|
classNames?: {
|
|
241
278
|
button?: string;
|
|
242
279
|
backdrop?: string;
|
|
243
280
|
card?: string;
|
|
244
281
|
item?: string;
|
|
245
282
|
};
|
|
283
|
+
product?: Product;
|
|
246
284
|
}
|
|
247
|
-
declare function Sparkle({ productName, limit, onResult, backdropColor, backdropBlur, className, onNavigate, theme, classNames, }: SparkleProps): react_jsx_runtime.JSX.Element;
|
|
285
|
+
declare function Sparkle({ productName, limit, onResult, backdropColor, backdropBlur, className, onNavigate, theme, classNames, product, }: SparkleProps): react_jsx_runtime.JSX.Element;
|
|
248
286
|
|
|
249
287
|
interface ChatWidgetProps {
|
|
250
288
|
title?: string;
|
|
@@ -253,12 +291,7 @@ interface ChatWidgetProps {
|
|
|
253
291
|
emptyStateSuggestions?: string;
|
|
254
292
|
defaultCurrency?: string;
|
|
255
293
|
className?: string;
|
|
256
|
-
theme?:
|
|
257
|
-
primaryColor?: string;
|
|
258
|
-
backgroundColor?: string;
|
|
259
|
-
textColor?: string;
|
|
260
|
-
fontFamily?: string;
|
|
261
|
-
};
|
|
294
|
+
theme?: HuskelTheme;
|
|
262
295
|
classNames?: {
|
|
263
296
|
root?: string;
|
|
264
297
|
header?: string;
|
|
@@ -279,12 +312,7 @@ interface AIChatButtonProps {
|
|
|
279
312
|
onSelectSource?: (source: ChatSource) => void;
|
|
280
313
|
defaultCurrency?: string;
|
|
281
314
|
chips?: string[];
|
|
282
|
-
theme?:
|
|
283
|
-
primaryColor?: string;
|
|
284
|
-
backgroundColor?: string;
|
|
285
|
-
textColor?: string;
|
|
286
|
-
fontFamily?: string;
|
|
287
|
-
};
|
|
315
|
+
theme?: HuskelTheme;
|
|
288
316
|
classNames?: {
|
|
289
317
|
button?: string;
|
|
290
318
|
overlay?: string;
|
|
@@ -295,9 +323,19 @@ interface AIChatButtonProps {
|
|
|
295
323
|
}
|
|
296
324
|
declare function AIChatButton({ label, title, placeholder, backdropColor, backdropBlur, className, onSelectSource, defaultCurrency, chips, theme, classNames, }: AIChatButtonProps): react_jsx_runtime.JSX.Element;
|
|
297
325
|
|
|
326
|
+
declare function CartBadge({ className }: {
|
|
327
|
+
className?: string;
|
|
328
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
329
|
+
|
|
330
|
+
declare function CartDrawer({ trigger, className, theme }: {
|
|
331
|
+
trigger?: React.ReactNode;
|
|
332
|
+
className?: string;
|
|
333
|
+
theme?: 'light' | 'dark' | HuskelTheme;
|
|
334
|
+
}): react_jsx_runtime.JSX.Element;
|
|
335
|
+
|
|
298
336
|
interface HuskelProviderProps extends HuskelConfig {
|
|
299
337
|
children: React.ReactNode;
|
|
300
338
|
}
|
|
301
339
|
declare function HuskelProvider({ siteId, apiUrl, apiToken, shopperId, children }: HuskelProviderProps): react_jsx_runtime.JSX.Element;
|
|
302
340
|
|
|
303
|
-
export { AIChatButton, type ChatMessage, type ChatSource, ChatWidget, HuskelAPI, HuskelClient, type HuskelConfig, type HuskelError, HuskelProvider, type IngestResponse, type Product, type RawProductInput, SearchBar, type SearchRequest, type SearchResponse, type SearchResult, Sparkle, getHuskelClient, initHuskel, useChat, useHuskel, useIngest, usePageIngest, useSearch };
|
|
341
|
+
export { AIChatButton, CartBadge, CartDrawer, type ChatMessage, type ChatSource, ChatWidget, HuskelAPI, HuskelClient, type HuskelConfig, type HuskelError, HuskelProvider, type IngestResponse, type Product, type RawProductInput, SearchBar, type SearchRequest, type SearchResponse, type SearchResult, Sparkle, getHuskelClient, initHuskel, useCart, useChat, useHuskel, useIngest, usePageIngest, useSearch };
|