@seekora-ai/search-sdk 0.2.8 → 0.2.12
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/client.d.ts +8 -2
- package/dist/client.js +30 -8
- package/dist/generated/api.d.ts +8319 -32163
- package/dist/generated/api.js +2143 -46860
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -345,11 +345,17 @@ export declare class SeekoraClient {
|
|
|
345
345
|
/**
|
|
346
346
|
* Get query suggestions
|
|
347
347
|
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
348
|
+
* **NEW:** Full GET/POST parity! Automatically chooses the best method:
|
|
349
|
+
* - GET: Default for simple requests, including filtered_tabs with ≤5 tabs (faster, cacheable)
|
|
350
|
+
* - POST: Used for complex filtered_tabs (>5 tabs) or when explicitly requested via options.method = 'POST'
|
|
351
|
+
*
|
|
352
|
+
* With returnFullResponse: true returns full shape including extensions (dropdown_recommendations with trending products, filtered_tabs).
|
|
350
353
|
*
|
|
351
354
|
* @param query - Partial query to get suggestions for
|
|
352
355
|
* @param options - Optional parameters for suggestions
|
|
356
|
+
* @param options.filtered_tabs - Tab configurations (now supported in GET!)
|
|
357
|
+
* @param options.include_dropdown_recommendations - Include rich dropdown data
|
|
358
|
+
* @param options.method - Explicitly set 'POST' to force POST method
|
|
353
359
|
* @returns Suggestion hits array, or QuerySuggestionsFullResponse when returnFullResponse is true
|
|
354
360
|
*/
|
|
355
361
|
getSuggestions(query: string, options?: {
|
package/dist/client.js
CHANGED
|
@@ -325,11 +325,17 @@ class SeekoraClient {
|
|
|
325
325
|
/**
|
|
326
326
|
* Get query suggestions
|
|
327
327
|
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
328
|
+
* **NEW:** Full GET/POST parity! Automatically chooses the best method:
|
|
329
|
+
* - GET: Default for simple requests, including filtered_tabs with ≤5 tabs (faster, cacheable)
|
|
330
|
+
* - POST: Used for complex filtered_tabs (>5 tabs) or when explicitly requested via options.method = 'POST'
|
|
331
|
+
*
|
|
332
|
+
* With returnFullResponse: true returns full shape including extensions (dropdown_recommendations with trending products, filtered_tabs).
|
|
330
333
|
*
|
|
331
334
|
* @param query - Partial query to get suggestions for
|
|
332
335
|
* @param options - Optional parameters for suggestions
|
|
336
|
+
* @param options.filtered_tabs - Tab configurations (now supported in GET!)
|
|
337
|
+
* @param options.include_dropdown_recommendations - Include rich dropdown data
|
|
338
|
+
* @param options.method - Explicitly set 'POST' to force POST method
|
|
333
339
|
* @returns Suggestion hits array, or QuerySuggestionsFullResponse when returnFullResponse is true
|
|
334
340
|
*/
|
|
335
341
|
async getSuggestions(query, options) {
|
|
@@ -345,10 +351,14 @@ class SeekoraClient {
|
|
|
345
351
|
headers['x-anon-id'] = this.anonId;
|
|
346
352
|
if (this.sessionId)
|
|
347
353
|
headers['x-session-id'] = this.sessionId;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
354
|
+
// Use POST for:
|
|
355
|
+
// - Complex filtered_tabs (5+ tabs or very long JSON would exceed URL limits)
|
|
356
|
+
// - Explicit preference for POST (options.method === 'POST')
|
|
357
|
+
// Use GET for everything else (including simple filtered_tabs)
|
|
358
|
+
const hasComplexFilteredTabs = options?.filtered_tabs &&
|
|
359
|
+
options.filtered_tabs.length > 5;
|
|
360
|
+
const usePost = hasComplexFilteredTabs ||
|
|
361
|
+
options?.method === 'POST'; // Allow explicit POST preference
|
|
352
362
|
const defaults = this.clientConfig?.suggestionsDefaults;
|
|
353
363
|
const buildRequestBody = () => {
|
|
354
364
|
const body = {
|
|
@@ -406,15 +416,27 @@ class SeekoraClient {
|
|
|
406
416
|
});
|
|
407
417
|
return suggestions;
|
|
408
418
|
}
|
|
409
|
-
// GET for simple requests
|
|
419
|
+
// GET for simple requests and simple filtered_tabs (URL-encoded JSON)
|
|
410
420
|
this.logger.verbose('Using GET endpoint', {
|
|
411
421
|
endpoint: '/api/v1/suggestions/queries',
|
|
412
422
|
query,
|
|
423
|
+
hasFilteredTabs: !!(options?.filtered_tabs && options.filtered_tabs.length > 0),
|
|
413
424
|
});
|
|
414
425
|
const analyticsTags = Array.isArray(options?.analytics_tags)
|
|
415
426
|
? options.analytics_tags.join(',')
|
|
416
427
|
: options?.analytics_tags;
|
|
417
|
-
|
|
428
|
+
// Encode filtered_tabs as JSON string for URL parameter
|
|
429
|
+
const filteredTabsParam = options?.filtered_tabs
|
|
430
|
+
? JSON.stringify(options.filtered_tabs)
|
|
431
|
+
: undefined;
|
|
432
|
+
const response = await this.suggestionsApi.v1SuggestionsQueriesGet(this.storeId, this.readSecret, this.userId, this.anonId, this.sessionId, query, // query parameter
|
|
433
|
+
undefined, // q parameter (alias for query)
|
|
434
|
+
options?.hitsPerPage || 5, options?.page, analyticsTags, options?.tags_match_mode, options?.include_categories, options?.include_facets, options?.include_dropdown_recommendations, options?.include_dropdown_product_list, options?.include_filtered_tabs, undefined, // include_empty_query_recommendations
|
|
435
|
+
options?.max_categories, options?.max_facets, options?.min_popularity, options?.time_range, options?.disable_typo_tolerance, filteredTabsParam, // filtered_tabs as JSON string
|
|
436
|
+
undefined, // userId (using header instead)
|
|
437
|
+
undefined, // anonId (using header instead)
|
|
438
|
+
undefined, // sessionId (using header instead)
|
|
439
|
+
{ headers });
|
|
418
440
|
const responseData = response.data?.data || response.data;
|
|
419
441
|
const suggestions = responseData?.results?.[0]?.hits || responseData?.hits || [];
|
|
420
442
|
if (options?.returnFullResponse) {
|