@seekora-ai/search-sdk 0.2.16 → 0.2.17

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  * Seekora SDK Client
3
3
  * High-level wrapper around generated OpenAPI client
4
4
  */
5
- import type { DataTypesIndexConfig, DataTypesEventPayload, DataTypesFiltersResponse, DataTypesFacetValuesSearchResponse, DataTypesFiltersSchemaResponse, DataTypesFilterField, DataTypesFilterValue, DataTypesFilterStats, DataTypesFilterSchemaField, DataTypesExperimentAssignmentResponse } from './generated';
5
+ import type { DataTypesIndexConfig, DataTypesEventPayload, DataTypesFiltersResponse, DataTypesFacetValuesSearchResponse, DataTypesFiltersSchemaResponse, DataTypesFilterField, DataTypesFilterValue, DataTypesFilterStats, DataTypesFilterSchemaField } from './generated';
6
6
  import { type SeekoraEnvironment } from './config';
7
7
  import { Logger, type LogLevel, type LoggerConfig } from './logger';
8
8
  import { type ContextCollectorConfig, type BrowserContext } from './context-collector';
@@ -325,7 +325,6 @@ export declare class SeekoraClient {
325
325
  private analyticsApi;
326
326
  private storeManagementApi;
327
327
  private filtersApi;
328
- private experimentsApi;
329
328
  private storeId;
330
329
  private readSecret;
331
330
  private writeSecret?;
@@ -400,7 +399,7 @@ export declare class SeekoraClient {
400
399
  }): Promise<any[] | QuerySuggestionsFullResponse>;
401
400
  /**
402
401
  * Get query suggestions configuration (store-specific).
403
- * Uses GET /api/v1/stores/{storeId}/query-suggestions/config via SDKQuerySuggestionsConfigApi.
402
+ * Uses GET /api/v1/stores/{storeId}/query-suggestions/config via StoreManagementApi.
404
403
  */
405
404
  getSuggestionsConfig(): Promise<any>;
406
405
  /**
@@ -408,15 +407,6 @@ export declare class SeekoraClient {
408
407
  * Returns store search configuration and onboarding status
409
408
  */
410
409
  getConfig(): Promise<DataTypesIndexConfig>;
411
- /**
412
- * Get experiment assignments for the current user
413
- *
414
- * Returns variant assignments for all running experiments.
415
- * Uses hash-based consistent assignment on the backend.
416
- *
417
- * @returns ExperimentAssignmentResponse with assignments array
418
- */
419
- getExperimentAssignment(): Promise<DataTypesExperimentAssignmentResponse>;
420
410
  /**
421
411
  * Get store information
422
412
  * Returns store metadata including name, status, and configuration details
@@ -443,7 +433,7 @@ export declare class SeekoraClient {
443
433
  updateConfig(config: Partial<DataTypesIndexConfig>): Promise<DataTypesIndexConfig>;
444
434
  /**
445
435
  * Update query suggestions configuration (requires write secret).
446
- * Uses PUT /api/v1/stores/{xStoreID}/query-suggestions/config via SDKQuerySuggestionsConfigApi.
436
+ * Uses PUT /api/v1/stores/{xStoreID}/query-suggestions/config via StoreManagementApi.
447
437
  */
448
438
  updateQuerySuggestionsConfig(config: any): Promise<any>;
449
439
  /**
package/dist/client.js CHANGED
@@ -97,7 +97,6 @@ class SeekoraClient {
97
97
  this.analyticsApi = new generated_1.AnalyticsEventsApi(this.config);
98
98
  this.storeManagementApi = new generated_1.StoreManagementApi(this.config);
99
99
  this.filtersApi = new generated_1.FiltersApi(this.config);
100
- this.experimentsApi = new generated_1.SDKExperimentsApi(this.config);
101
100
  this.logger.info('SeekoraClient initialized successfully');
102
101
  }
103
102
  /**
@@ -172,7 +171,7 @@ class SeekoraClient {
172
171
  // Log API request start
173
172
  this.logger.verbose('Sending search API request', {
174
173
  endpoint: '/api/v1/search',
175
- method: 'POST',
174
+ method: 'GET',
176
175
  storeId: this.storeId
177
176
  });
178
177
  // Build headers with personalization support
@@ -190,9 +189,7 @@ class SeekoraClient {
190
189
  if (this.sessionId) {
191
190
  headers['x-session-id'] = this.sessionId;
192
191
  }
193
- const response = await this.searchApi.v1SearchPost(this.storeId, this.readSecret, searchRequest, this.userId, this.anonId, this.sessionId, {
194
- headers
195
- });
192
+ const response = await this.searchApi.v1SearchGet(this.storeId, this.readSecret, searchRequest.q, this.userId, this.anonId, this.sessionId, searchRequest.page, searchRequest.per_page, searchRequest.sort, searchRequest.filter, searchRequest.facet_by, searchRequest.max_facet_values, searchRequest.widget_mode, searchRequest.include_suggestions, searchRequest.suggestions_limit, Array.isArray(searchRequest.analytics_tags) ? searchRequest.analytics_tags.join(',') : searchRequest.analytics_tags, Array.isArray(searchRequest.stopword_sets) ? searchRequest.stopword_sets.join(',') : searchRequest.stopword_sets, Array.isArray(searchRequest.synonym_sets) ? searchRequest.synonym_sets.join(',') : searchRequest.synonym_sets, searchRequest.search_fields, searchRequest.return_fields, searchRequest.omit_fields, searchRequest.snippet_fields, searchRequest.full_snippet_fields, searchRequest.field_weights, searchRequest.group_field, searchRequest.group_size, searchRequest.snippet_prefix, searchRequest.snippet_suffix, searchRequest.snippet_token_limit, searchRequest.snippet_min_len, searchRequest.include_snippets, searchRequest.prefix_mode, searchRequest.infix_mode, searchRequest.typo_max, searchRequest.typo_min_len_1, searchRequest.typo_min_len_2, searchRequest.search_timeout_ms, searchRequest.require_all_terms, searchRequest.exact_match_boost, searchRequest.cache_results, searchRequest.apply_rules, searchRequest.preset_name, searchRequest.facet_search_text, { headers });
196
193
  // Log API response received
197
194
  this.logger.verbose('Search API response received', {
198
195
  status: response.status,
@@ -352,72 +349,7 @@ class SeekoraClient {
352
349
  headers['x-anon-id'] = this.anonId;
353
350
  if (this.sessionId)
354
351
  headers['x-session-id'] = this.sessionId;
355
- // Use POST for:
356
- // - Complex filtered_tabs (5+ tabs or very long JSON would exceed URL limits)
357
- // - Explicit preference for POST (options.method === 'POST')
358
- // Use GET for everything else (including simple filtered_tabs)
359
- const hasComplexFilteredTabs = options?.filtered_tabs &&
360
- options.filtered_tabs.length > 5;
361
- const usePost = hasComplexFilteredTabs ||
362
- options?.method === 'POST'; // Allow explicit POST preference
363
352
  const defaults = this.clientConfig?.suggestionsDefaults;
364
- const buildRequestBody = () => {
365
- const body = {
366
- query,
367
- hitsPerPage: options?.hitsPerPage ?? defaults?.hitsPerPage ?? 5,
368
- page: options?.page,
369
- include_categories: options?.include_categories,
370
- include_facets: options?.include_facets,
371
- max_categories: options?.max_categories,
372
- max_facets: options?.max_facets,
373
- min_popularity: options?.min_popularity,
374
- time_range: options?.time_range ?? defaults?.time_range,
375
- disable_typo_tolerance: options?.disable_typo_tolerance,
376
- include_dropdown_recommendations: options?.include_dropdown_recommendations ?? defaults?.include_dropdown_recommendations,
377
- include_dropdown_product_list: options?.include_dropdown_product_list ?? defaults?.include_dropdown_product_list,
378
- include_filtered_tabs: options?.include_filtered_tabs ?? defaults?.include_filtered_tabs,
379
- filtered_tabs: options?.filtered_tabs,
380
- };
381
- if (options?.analytics_tags) {
382
- body.analytics_tags = Array.isArray(options.analytics_tags)
383
- ? options.analytics_tags
384
- : [options.analytics_tags];
385
- }
386
- if (options?.tags_match_mode)
387
- body.tags_match_mode = options.tags_match_mode;
388
- return body;
389
- };
390
- if (usePost) {
391
- this.logger.verbose('Using POST endpoint (filtered_tabs or include_dropdown_recommendations)', {
392
- endpoint: '/api/v1/suggestions/queries',
393
- query,
394
- });
395
- const requestBody = buildRequestBody();
396
- const response = await this.suggestionsApi.v1SuggestionsQueriesPost(this.storeId, this.readSecret, this.userId, this.anonId, this.sessionId, requestBody, { headers });
397
- const responseData = response.data?.data || response.data;
398
- const suggestions = responseData?.results?.[0]?.hits || responseData?.hits || [];
399
- const extensions = responseData?.results?.[1]?.extensions ?? responseData?.results?.[0]?.extensions;
400
- if (options?.returnFullResponse) {
401
- this.logger.info('Query suggestions retrieved (POST, full response)', {
402
- query,
403
- count: suggestions.length,
404
- status: response.status,
405
- });
406
- return {
407
- suggestions,
408
- results: responseData?.results,
409
- extensions: extensions ?? undefined,
410
- raw: responseData,
411
- };
412
- }
413
- this.logger.info('Query suggestions retrieved (POST)', {
414
- query,
415
- count: suggestions.length,
416
- status: response.status,
417
- });
418
- return suggestions;
419
- }
420
- // GET for simple requests and simple filtered_tabs (URL-encoded JSON)
421
353
  this.logger.verbose('Using GET endpoint', {
422
354
  endpoint: '/api/v1/suggestions/queries',
423
355
  query,
@@ -432,8 +364,8 @@ class SeekoraClient {
432
364
  : undefined;
433
365
  const response = await this.suggestionsApi.v1SuggestionsQueriesGet(this.storeId, this.readSecret, this.userId, this.anonId, this.sessionId, query, // query parameter
434
366
  undefined, // q parameter (alias for query)
435
- 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
436
- options?.max_categories, options?.max_facets, options?.min_popularity, options?.time_range, options?.disable_typo_tolerance, filteredTabsParam, // filtered_tabs as JSON string
367
+ options?.hitsPerPage ?? defaults?.hitsPerPage ?? 5, options?.page, analyticsTags, options?.tags_match_mode, options?.include_categories, options?.include_facets, options?.include_dropdown_recommendations ?? defaults?.include_dropdown_recommendations, options?.include_dropdown_product_list ?? defaults?.include_dropdown_product_list, options?.include_filtered_tabs ?? defaults?.include_filtered_tabs, undefined, // include_empty_query_recommendations
368
+ options?.max_categories, options?.max_facets, options?.min_popularity, (options?.time_range ?? defaults?.time_range), options?.disable_typo_tolerance, filteredTabsParam, // filtered_tabs as JSON string
437
369
  undefined, // userId (using header instead)
438
370
  undefined, // anonId (using header instead)
439
371
  undefined, // sessionId (using header instead)
@@ -468,7 +400,7 @@ class SeekoraClient {
468
400
  }
469
401
  /**
470
402
  * Get query suggestions configuration (store-specific).
471
- * Uses GET /api/v1/stores/{storeId}/query-suggestions/config via SDKQuerySuggestionsConfigApi.
403
+ * Uses GET /api/v1/stores/{storeId}/query-suggestions/config via StoreManagementApi.
472
404
  */
473
405
  async getSuggestionsConfig() {
474
406
  this.logger.verbose('Getting suggestions configuration');
@@ -478,7 +410,7 @@ class SeekoraClient {
478
410
  'x-storesecret': this.readSecret,
479
411
  };
480
412
  try {
481
- const response = await this.storeManagementApi.apiV1StoresXStoreIDQuerySuggestionsConfigGet(this.storeId, this.readSecret, this.storeId, { headers });
413
+ const response = await this.storeManagementApi.apiV1StoresQuerySuggestionsConfigGet(this.storeId, this.readSecret, { headers });
482
414
  const data = response.data?.data;
483
415
  const config = data?.metadata?.config ?? data?.config ?? data;
484
416
  this.logger.info('Suggestions configuration retrieved', {
@@ -528,7 +460,7 @@ class SeekoraClient {
528
460
  if (this.sessionId) {
529
461
  headers['x-session-id'] = this.sessionId;
530
462
  }
531
- const response = await this.storeManagementApi.apiV1StoresXStoreIDConfigGet(this.storeId, this.readSecret, this.storeId, { headers });
463
+ const response = await this.storeManagementApi.apiV1StoresConfigGet(this.storeId, this.readSecret, { headers });
532
464
  const config = response.data?.data;
533
465
  this.logger.info('Store configuration retrieved', {
534
466
  status: response.status,
@@ -541,37 +473,6 @@ class SeekoraClient {
541
473
  throw this.handleError(error, 'getConfig');
542
474
  }
543
475
  }
544
- /**
545
- * Get experiment assignments for the current user
546
- *
547
- * Returns variant assignments for all running experiments.
548
- * Uses hash-based consistent assignment on the backend.
549
- *
550
- * @returns ExperimentAssignmentResponse with assignments array
551
- */
552
- async getExperimentAssignment() {
553
- this.logger.verbose('Getting experiment assignments');
554
- try {
555
- const headers = {
556
- 'x-storeid': this.storeId,
557
- 'x-storesecret': this.readSecret,
558
- };
559
- if (this.userId)
560
- headers['x-user-id'] = this.userId;
561
- if (this.anonId)
562
- headers['x-anon-id'] = this.anonId;
563
- const response = await this.experimentsApi.v1ExperimentsAssignmentGet(this.storeId, this.readSecret, this.userId, this.anonId, { headers });
564
- const data = response.data;
565
- this.logger.info('Experiment assignments retrieved', {
566
- count: data?.assignments?.length ?? 0,
567
- });
568
- return data;
569
- }
570
- catch (error) {
571
- this.logger.error('Failed to get experiment assignments', { error: error.message });
572
- throw this.handleError(error, 'getExperimentAssignment');
573
- }
574
- }
575
476
  /**
576
477
  * Get store information
577
478
  * Returns store metadata including name, status, and configuration details
@@ -658,7 +559,7 @@ class SeekoraClient {
658
559
  'x-storesecret': this.readSecret,
659
560
  'x-store-write-secret': this.writeSecret,
660
561
  };
661
- const response = await this.storeManagementApi.apiV1StoresXStoreIDConfigPut(this.storeId, this.writeSecret, this.storeId, config, { headers });
562
+ const response = await this.storeManagementApi.apiV1StoresConfigPut(this.storeId, this.writeSecret, config, { headers });
662
563
  const updatedConfig = response.data?.data;
663
564
  this.logger.info('Store configuration updated successfully', {
664
565
  status: response.status,
@@ -673,7 +574,7 @@ class SeekoraClient {
673
574
  }
674
575
  /**
675
576
  * Update query suggestions configuration (requires write secret).
676
- * Uses PUT /api/v1/stores/{xStoreID}/query-suggestions/config via SDKQuerySuggestionsConfigApi.
577
+ * Uses PUT /api/v1/stores/{xStoreID}/query-suggestions/config via StoreManagementApi.
677
578
  */
678
579
  async updateQuerySuggestionsConfig(config) {
679
580
  this.logger.verbose('Updating query suggestions configuration', { configKeys: Object.keys(config) });
@@ -691,7 +592,7 @@ class SeekoraClient {
691
592
  'Content-Type': 'application/json',
692
593
  };
693
594
  try {
694
- const response = await this.storeManagementApi.apiV1StoresXStoreIDQuerySuggestionsConfigPut(this.storeId, this.writeSecret, this.storeId, config, { headers });
595
+ const response = await this.storeManagementApi.apiV1StoresQuerySuggestionsConfigPut(this.storeId, this.writeSecret, config, { headers });
695
596
  const data = response.data?.data;
696
597
  const updatedConfig = data?.metadata?.config ?? data?.config ?? data;
697
598
  this.logger.info('Query suggestions configuration updated successfully', {
@@ -725,7 +626,7 @@ class SeekoraClient {
725
626
  async getConfigSchema() {
726
627
  this.logger.verbose('Getting configuration schema');
727
628
  try {
728
- const response = await this.storeManagementApi.apiV1StoresXStoreIDConfigSchemaGet(this.storeId, this.readSecret, this.storeId, {
629
+ const response = await this.storeManagementApi.apiV1StoresConfigSchemaGet(this.storeId, this.readSecret, {
729
630
  headers: {
730
631
  'x-storeid': this.storeId,
731
632
  'x-storesecret': this.readSecret,
@@ -766,7 +667,7 @@ class SeekoraClient {
766
667
  id: document.id,
767
668
  data: document.data,
768
669
  };
769
- const response = await this.storeManagementApi.apiV1StoresXStoreIDDocumentsPost(this.storeId, this.writeSecret, this.storeId, request);
670
+ const response = await this.storeManagementApi.apiV1StoresDocumentsPost(this.storeId, this.writeSecret, request);
770
671
  const responseData = response.data?.data;
771
672
  this.logger.info('Document indexed successfully', {
772
673
  id: responseData?.id || document.id,
@@ -810,7 +711,7 @@ class SeekoraClient {
810
711
  data: doc.data,
811
712
  })),
812
713
  };
813
- const response = await this.storeManagementApi.apiV1StoresXStoreIDDocumentsBulkPost(this.storeId, this.writeSecret, this.storeId, request);
714
+ const response = await this.storeManagementApi.apiV1StoresDocumentsBulkPost(this.storeId, this.writeSecret, request);
814
715
  const responseData = response.data?.data;
815
716
  this.logger.info('Bulk document indexing completed', {
816
717
  successCount: responseData?.successCount || 0,
@@ -854,7 +755,7 @@ class SeekoraClient {
854
755
  throw new Error('Write secret is required for deleteDocument');
855
756
  }
856
757
  try {
857
- const response = await this.storeManagementApi.apiV1StoresXStoreIDDocumentsDocumentIDDelete(this.storeId, this.writeSecret, this.storeId, documentId);
758
+ const response = await this.storeManagementApi.apiV1StoresDocumentsDocumentIDDelete(this.storeId, this.writeSecret, documentId);
858
759
  this.logger.info('Document deleted successfully', {
859
760
  documentId,
860
761
  status: response.status
@@ -932,7 +833,7 @@ class SeekoraClient {
932
833
  default_sorting_field: request.defaultSortingField,
933
834
  enable_nested_fields: request.enableNestedFields,
934
835
  };
935
- const response = await this.storeManagementApi.apiV1StoresXStoreIDSchemaPost(this.storeId, this.writeSecret, this.storeId, apiRequest);
836
+ const response = await this.storeManagementApi.apiV1StoresSchemaPost(this.storeId, this.writeSecret, apiRequest);
936
837
  const responseData = response.data;
937
838
  this.logger.info('Schema created/updated successfully', {
938
839
  name: responseData.data?.name,
@@ -973,7 +874,7 @@ class SeekoraClient {
973
874
  async getSchema() {
974
875
  this.logger.verbose('Getting schema', { storeId: this.storeId });
975
876
  try {
976
- const response = await this.storeManagementApi.apiV1StoresXStoreIDSchemaGet(this.storeId, this.readSecret, this.storeId);
877
+ const response = await this.storeManagementApi.apiV1StoresSchemaGet(this.storeId, this.readSecret);
977
878
  const responseData = response.data;
978
879
  this.logger.info('Schema retrieved successfully', {
979
880
  name: responseData.data?.name,
@@ -1024,7 +925,7 @@ class SeekoraClient {
1024
925
  throw new Error('Write secret is required for clearDocuments');
1025
926
  }
1026
927
  try {
1027
- const response = await this.storeManagementApi.apiV1StoresXStoreIDDocumentsDelete(this.storeId, this.writeSecret, this.storeId);
928
+ const response = await this.storeManagementApi.apiV1StoresDocumentsDelete(this.storeId, this.writeSecret);
1028
929
  const responseData = response.data;
1029
930
  this.logger.info('Documents cleared successfully', {
1030
931
  deletedCount: responseData.data?.deleted_count
@@ -1833,14 +1734,7 @@ class SeekoraClient {
1833
1734
  async getFilters(options) {
1834
1735
  this.logger.verbose('Getting filters', { options });
1835
1736
  try {
1836
- const req = {
1837
- q: options?.q,
1838
- filter: options?.filter,
1839
- facet_by: options?.facetBy,
1840
- max_facet_values: options?.maxFacetValues,
1841
- disjunctive_facets: options?.disjunctiveFacets,
1842
- };
1843
- const response = await this.filtersApi.v1FiltersPost(this.storeId, this.readSecret, req);
1737
+ const response = await this.filtersApi.v1FiltersGet(this.storeId, this.readSecret, options?.q, options?.filter, options?.facetBy, options?.maxFacetValues, options?.disjunctiveFacets?.join(','));
1844
1738
  const wrapper = response.data;
1845
1739
  const data = wrapper?.data || response.data;
1846
1740
  this.logger.info('Filters retrieved successfully', {
@@ -1865,13 +1759,7 @@ class SeekoraClient {
1865
1759
  async searchFacetValues(facetName, options) {
1866
1760
  this.logger.verbose('Searching facet values', { facetName, options });
1867
1761
  try {
1868
- const req = {
1869
- facet_query: options.facetQuery,
1870
- q: options?.q,
1871
- filter: options?.filter,
1872
- max_values: options?.maxValues,
1873
- };
1874
- const response = await this.filtersApi.v1FiltersFacetNameValuesPost(this.storeId, this.readSecret, facetName, req);
1762
+ const response = await this.filtersApi.v1FiltersFacetNameValuesGet(this.storeId, this.readSecret, facetName, options.facetQuery, options?.q, options?.filter, options?.maxValues);
1875
1763
  const wrapper = response.data;
1876
1764
  const data = wrapper?.data || response.data;
1877
1765
  this.logger.info('Facet values retrieved', {