@huskel/sdk 0.3.2 → 0.4.0
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.d.mts +66 -2
- package/dist/index.d.ts +66 -2
- package/dist/index.js +1601 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1596 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +38 -31
package/dist/index.d.mts
CHANGED
|
@@ -90,6 +90,15 @@ declare class HuskelAPI {
|
|
|
90
90
|
ingest(product: Product): Promise<IngestResponse>;
|
|
91
91
|
ingestBatch(products: Product[]): Promise<IngestResponse>;
|
|
92
92
|
search(query: string, limit?: number): Promise<SearchResponse>;
|
|
93
|
+
searchVector(query: string, limit?: number): Promise<SearchResponse>;
|
|
94
|
+
searchAutocomplete(query: string, limit?: number): Promise<SearchResponse>;
|
|
95
|
+
chat(query: string, history?: Array<{
|
|
96
|
+
role: 'user' | 'assistant';
|
|
97
|
+
content: string;
|
|
98
|
+
}>): Promise<{
|
|
99
|
+
answer: string;
|
|
100
|
+
sources: any[];
|
|
101
|
+
}>;
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
declare class HuskelClient {
|
|
@@ -100,6 +109,10 @@ declare class HuskelClient {
|
|
|
100
109
|
private onlineHandler;
|
|
101
110
|
private shopperId?;
|
|
102
111
|
private sessionId;
|
|
112
|
+
private static INGEST_CACHE_KEY;
|
|
113
|
+
private static INGEST_CACHE_TTL;
|
|
114
|
+
private loadIngestedCache;
|
|
115
|
+
private saveIngestedCache;
|
|
103
116
|
constructor(config: HuskelConfig);
|
|
104
117
|
setShopperId(id: string | undefined): void;
|
|
105
118
|
getShopperId(): string | undefined;
|
|
@@ -158,9 +171,33 @@ declare function useIngest(): UseIngestReturn;
|
|
|
158
171
|
*/
|
|
159
172
|
declare function usePageIngest(product: RawProductInput | null | undefined): void;
|
|
160
173
|
|
|
174
|
+
interface ChatMessage {
|
|
175
|
+
role: 'user' | 'assistant';
|
|
176
|
+
content: string;
|
|
177
|
+
}
|
|
178
|
+
interface ChatSource {
|
|
179
|
+
id?: string;
|
|
180
|
+
name: string;
|
|
181
|
+
price?: string;
|
|
182
|
+
currency?: string;
|
|
183
|
+
category?: string;
|
|
184
|
+
url?: string;
|
|
185
|
+
image?: string;
|
|
186
|
+
}
|
|
187
|
+
interface UseChatReturn {
|
|
188
|
+
messages: ChatMessage[];
|
|
189
|
+
sources: ChatSource[];
|
|
190
|
+
loading: boolean;
|
|
191
|
+
error: string | null;
|
|
192
|
+
send: (query: string) => Promise<void>;
|
|
193
|
+
reset: () => void;
|
|
194
|
+
}
|
|
195
|
+
declare function useChat(): UseChatReturn;
|
|
196
|
+
|
|
161
197
|
interface SearchBarProps {
|
|
162
198
|
placeholder?: string;
|
|
163
199
|
limit?: number;
|
|
200
|
+
/** Debounce in ms — default 80 for near-instant feel */
|
|
164
201
|
debounceMs?: number;
|
|
165
202
|
onSelect?: (result: SearchResult) => void;
|
|
166
203
|
className?: string;
|
|
@@ -174,13 +211,40 @@ interface SparkleProps {
|
|
|
174
211
|
productName: string;
|
|
175
212
|
limit?: number;
|
|
176
213
|
onResult?: (results: SearchResult[]) => void;
|
|
214
|
+
/** Override the backdrop colour (any CSS colour/gradient) */
|
|
215
|
+
backdropColor?: string;
|
|
216
|
+
/** Override backdrop blur — e.g. "8px" or 8 */
|
|
217
|
+
backdropBlur?: string | number;
|
|
218
|
+
/** Extra classes on the trigger button */
|
|
219
|
+
className?: string;
|
|
220
|
+
/** Called when user clicks a result — return false to prevent default navigation */
|
|
221
|
+
onNavigate?: (result: SearchResult) => boolean | void;
|
|
222
|
+
}
|
|
223
|
+
declare function Sparkle({ productName, limit, onResult, backdropColor, backdropBlur, className, onNavigate }: SparkleProps): react_jsx_runtime.JSX.Element;
|
|
224
|
+
|
|
225
|
+
interface ChatWidgetProps {
|
|
226
|
+
placeholder?: string;
|
|
227
|
+
title?: string;
|
|
228
|
+
className?: string;
|
|
229
|
+
/** Called when user clicks a product link */
|
|
230
|
+
onSelectSource?: (source: ChatSource) => void;
|
|
231
|
+
}
|
|
232
|
+
declare function ChatWidget({ placeholder, title, className, onSelectSource }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
233
|
+
|
|
234
|
+
interface AIChatButtonProps {
|
|
235
|
+
label?: string;
|
|
236
|
+
title?: string;
|
|
237
|
+
placeholder?: string;
|
|
238
|
+
backdropColor?: string;
|
|
239
|
+
backdropBlur?: string | number;
|
|
177
240
|
className?: string;
|
|
241
|
+
onSelectSource?: (source: ChatSource) => void;
|
|
178
242
|
}
|
|
179
|
-
declare function
|
|
243
|
+
declare function AIChatButton({ label, title, placeholder, backdropColor, backdropBlur, className, onSelectSource, }: AIChatButtonProps): react_jsx_runtime.JSX.Element;
|
|
180
244
|
|
|
181
245
|
interface HuskelProviderProps extends HuskelConfig {
|
|
182
246
|
children: React.ReactNode;
|
|
183
247
|
}
|
|
184
248
|
declare function HuskelProvider({ siteId, apiUrl, apiToken, shopperId, children }: HuskelProviderProps): react_jsx_runtime.JSX.Element;
|
|
185
249
|
|
|
186
|
-
export { HuskelAPI, HuskelClient, type HuskelConfig, type HuskelError, HuskelProvider, type IngestResponse, type Product, type RawProductInput, SearchBar, type SearchRequest, type SearchResponse, type SearchResult, Sparkle, getHuskelClient, initHuskel, useHuskel, useIngest, usePageIngest, useSearch };
|
|
250
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,15 @@ declare class HuskelAPI {
|
|
|
90
90
|
ingest(product: Product): Promise<IngestResponse>;
|
|
91
91
|
ingestBatch(products: Product[]): Promise<IngestResponse>;
|
|
92
92
|
search(query: string, limit?: number): Promise<SearchResponse>;
|
|
93
|
+
searchVector(query: string, limit?: number): Promise<SearchResponse>;
|
|
94
|
+
searchAutocomplete(query: string, limit?: number): Promise<SearchResponse>;
|
|
95
|
+
chat(query: string, history?: Array<{
|
|
96
|
+
role: 'user' | 'assistant';
|
|
97
|
+
content: string;
|
|
98
|
+
}>): Promise<{
|
|
99
|
+
answer: string;
|
|
100
|
+
sources: any[];
|
|
101
|
+
}>;
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
declare class HuskelClient {
|
|
@@ -100,6 +109,10 @@ declare class HuskelClient {
|
|
|
100
109
|
private onlineHandler;
|
|
101
110
|
private shopperId?;
|
|
102
111
|
private sessionId;
|
|
112
|
+
private static INGEST_CACHE_KEY;
|
|
113
|
+
private static INGEST_CACHE_TTL;
|
|
114
|
+
private loadIngestedCache;
|
|
115
|
+
private saveIngestedCache;
|
|
103
116
|
constructor(config: HuskelConfig);
|
|
104
117
|
setShopperId(id: string | undefined): void;
|
|
105
118
|
getShopperId(): string | undefined;
|
|
@@ -158,9 +171,33 @@ declare function useIngest(): UseIngestReturn;
|
|
|
158
171
|
*/
|
|
159
172
|
declare function usePageIngest(product: RawProductInput | null | undefined): void;
|
|
160
173
|
|
|
174
|
+
interface ChatMessage {
|
|
175
|
+
role: 'user' | 'assistant';
|
|
176
|
+
content: string;
|
|
177
|
+
}
|
|
178
|
+
interface ChatSource {
|
|
179
|
+
id?: string;
|
|
180
|
+
name: string;
|
|
181
|
+
price?: string;
|
|
182
|
+
currency?: string;
|
|
183
|
+
category?: string;
|
|
184
|
+
url?: string;
|
|
185
|
+
image?: string;
|
|
186
|
+
}
|
|
187
|
+
interface UseChatReturn {
|
|
188
|
+
messages: ChatMessage[];
|
|
189
|
+
sources: ChatSource[];
|
|
190
|
+
loading: boolean;
|
|
191
|
+
error: string | null;
|
|
192
|
+
send: (query: string) => Promise<void>;
|
|
193
|
+
reset: () => void;
|
|
194
|
+
}
|
|
195
|
+
declare function useChat(): UseChatReturn;
|
|
196
|
+
|
|
161
197
|
interface SearchBarProps {
|
|
162
198
|
placeholder?: string;
|
|
163
199
|
limit?: number;
|
|
200
|
+
/** Debounce in ms — default 80 for near-instant feel */
|
|
164
201
|
debounceMs?: number;
|
|
165
202
|
onSelect?: (result: SearchResult) => void;
|
|
166
203
|
className?: string;
|
|
@@ -174,13 +211,40 @@ interface SparkleProps {
|
|
|
174
211
|
productName: string;
|
|
175
212
|
limit?: number;
|
|
176
213
|
onResult?: (results: SearchResult[]) => void;
|
|
214
|
+
/** Override the backdrop colour (any CSS colour/gradient) */
|
|
215
|
+
backdropColor?: string;
|
|
216
|
+
/** Override backdrop blur — e.g. "8px" or 8 */
|
|
217
|
+
backdropBlur?: string | number;
|
|
218
|
+
/** Extra classes on the trigger button */
|
|
219
|
+
className?: string;
|
|
220
|
+
/** Called when user clicks a result — return false to prevent default navigation */
|
|
221
|
+
onNavigate?: (result: SearchResult) => boolean | void;
|
|
222
|
+
}
|
|
223
|
+
declare function Sparkle({ productName, limit, onResult, backdropColor, backdropBlur, className, onNavigate }: SparkleProps): react_jsx_runtime.JSX.Element;
|
|
224
|
+
|
|
225
|
+
interface ChatWidgetProps {
|
|
226
|
+
placeholder?: string;
|
|
227
|
+
title?: string;
|
|
228
|
+
className?: string;
|
|
229
|
+
/** Called when user clicks a product link */
|
|
230
|
+
onSelectSource?: (source: ChatSource) => void;
|
|
231
|
+
}
|
|
232
|
+
declare function ChatWidget({ placeholder, title, className, onSelectSource }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
233
|
+
|
|
234
|
+
interface AIChatButtonProps {
|
|
235
|
+
label?: string;
|
|
236
|
+
title?: string;
|
|
237
|
+
placeholder?: string;
|
|
238
|
+
backdropColor?: string;
|
|
239
|
+
backdropBlur?: string | number;
|
|
177
240
|
className?: string;
|
|
241
|
+
onSelectSource?: (source: ChatSource) => void;
|
|
178
242
|
}
|
|
179
|
-
declare function
|
|
243
|
+
declare function AIChatButton({ label, title, placeholder, backdropColor, backdropBlur, className, onSelectSource, }: AIChatButtonProps): react_jsx_runtime.JSX.Element;
|
|
180
244
|
|
|
181
245
|
interface HuskelProviderProps extends HuskelConfig {
|
|
182
246
|
children: React.ReactNode;
|
|
183
247
|
}
|
|
184
248
|
declare function HuskelProvider({ siteId, apiUrl, apiToken, shopperId, children }: HuskelProviderProps): react_jsx_runtime.JSX.Element;
|
|
185
249
|
|
|
186
|
-
export { HuskelAPI, HuskelClient, type HuskelConfig, type HuskelError, HuskelProvider, type IngestResponse, type Product, type RawProductInput, SearchBar, type SearchRequest, type SearchResponse, type SearchResult, Sparkle, getHuskelClient, initHuskel, useHuskel, useIngest, usePageIngest, useSearch };
|
|
250
|
+
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 };
|