@seekora-ai/search-sdk 0.2.13 → 0.2.14
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 +72 -3
- package/dist/client.js +125 -2
- package/dist/generated/api.d.ts +1492 -562
- package/dist/generated/api.js +1002 -465
- package/dist/generated/base.d.ts +1 -1
- package/dist/generated/base.js +1 -1
- package/dist/generated/common.d.ts +1 -1
- package/dist/generated/common.js +1 -1
- package/dist/generated/configuration.d.ts +1 -1
- package/dist/generated/configuration.js +1 -1
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
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 } from './generated';
|
|
5
|
+
import type { DataTypesIndexConfig, DataTypesEventPayload, DataTypesFiltersResponse, DataTypesFacetValuesSearchResponse, DataTypesFiltersSchemaResponse, DataTypesFilterField, DataTypesFilterValue, DataTypesFilterStats, DataTypesFilterSchemaField, DataTypesExperimentAssignmentResponse } 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';
|
|
@@ -46,8 +46,9 @@ export interface SeekoraClientConfig {
|
|
|
46
46
|
*/
|
|
47
47
|
contextCollector?: ContextCollectorConfig;
|
|
48
48
|
/**
|
|
49
|
-
* Enable event queue for offline buffering and retry
|
|
50
|
-
*
|
|
49
|
+
* Enable event queue for batching, offline buffering, and retry
|
|
50
|
+
* Batches events automatically (default: 10 events or 5s interval) for better performance
|
|
51
|
+
* @default true
|
|
51
52
|
*/
|
|
52
53
|
enableEventQueue?: boolean;
|
|
53
54
|
/**
|
|
@@ -326,6 +327,8 @@ export declare class SeekoraClient {
|
|
|
326
327
|
private storesApi;
|
|
327
328
|
private documentsApi;
|
|
328
329
|
private schemaApi;
|
|
330
|
+
private filtersApi;
|
|
331
|
+
private experimentsApi;
|
|
329
332
|
private storeId;
|
|
330
333
|
private readSecret;
|
|
331
334
|
private writeSecret?;
|
|
@@ -408,6 +411,15 @@ export declare class SeekoraClient {
|
|
|
408
411
|
* Returns store search configuration and onboarding status
|
|
409
412
|
*/
|
|
410
413
|
getConfig(): Promise<DataTypesIndexConfig>;
|
|
414
|
+
/**
|
|
415
|
+
* Get experiment assignments for the current user
|
|
416
|
+
*
|
|
417
|
+
* Returns variant assignments for all running experiments.
|
|
418
|
+
* Uses hash-based consistent assignment on the backend.
|
|
419
|
+
*
|
|
420
|
+
* @returns ExperimentAssignmentResponse with assignments array
|
|
421
|
+
*/
|
|
422
|
+
getExperimentAssignment(): Promise<DataTypesExperimentAssignmentResponse>;
|
|
411
423
|
/**
|
|
412
424
|
* Get store information
|
|
413
425
|
* Returns store metadata including name, status, and configuration details
|
|
@@ -813,5 +825,62 @@ export declare class SeekoraClient {
|
|
|
813
825
|
* Get the logger instance
|
|
814
826
|
*/
|
|
815
827
|
getLogger(): Logger;
|
|
828
|
+
/**
|
|
829
|
+
* Get filter values and counts for configured facets.
|
|
830
|
+
* Use this to build faceted navigation UIs without performing a full search.
|
|
831
|
+
* Supports disjunctive faceting for OR-based filter combinations.
|
|
832
|
+
*
|
|
833
|
+
* @param options - Filter options (query, filters, facet_by, max_facet_values, disjunctive_facets)
|
|
834
|
+
* @returns Filter values with counts grouped by field
|
|
835
|
+
*/
|
|
836
|
+
getFilters(options?: FilterOptions): Promise<DataTypesFiltersResponse>;
|
|
837
|
+
/**
|
|
838
|
+
* Search within a single facet's values.
|
|
839
|
+
* Useful for facets with many values (e.g., brands) where you need typeahead/autocomplete.
|
|
840
|
+
*
|
|
841
|
+
* @param facetName - The facet field name to search within (e.g., "brand", "category")
|
|
842
|
+
* @param options - Search options including facetQuery (required), optional q, filter, maxValues
|
|
843
|
+
* @returns Matching facet values with counts
|
|
844
|
+
*/
|
|
845
|
+
searchFacetValues(facetName: string, options: FacetSearchOptions): Promise<DataTypesFacetValuesSearchResponse>;
|
|
846
|
+
/**
|
|
847
|
+
* Get available filter field metadata (schema).
|
|
848
|
+
* Returns information about all facetable fields including types, sortability, and configured ranges.
|
|
849
|
+
* Useful for dynamically building filter UIs.
|
|
850
|
+
*
|
|
851
|
+
* @returns Filter field metadata with types, default facets, and max values
|
|
852
|
+
*/
|
|
853
|
+
getFiltersSchema(): Promise<DataTypesFiltersSchemaResponse>;
|
|
854
|
+
}
|
|
855
|
+
/** Options for getFilters() — high-level wrapper with camelCase fields */
|
|
856
|
+
export interface FilterOptions {
|
|
857
|
+
/** Search query to scope filters */
|
|
858
|
+
q?: string;
|
|
859
|
+
/** Active filter string (Typesense filter_by syntax) */
|
|
860
|
+
filter?: string;
|
|
861
|
+
/** Comma-separated facet fields to return (defaults to store config) */
|
|
862
|
+
facetBy?: string;
|
|
863
|
+
/** Maximum number of values per facet */
|
|
864
|
+
maxFacetValues?: number;
|
|
865
|
+
/** Fields that should use disjunctive (OR) faceting */
|
|
866
|
+
disjunctiveFacets?: string[];
|
|
867
|
+
}
|
|
868
|
+
/** Options for searchFacetValues() — high-level wrapper with camelCase fields */
|
|
869
|
+
export interface FacetSearchOptions {
|
|
870
|
+
/** Search query to scope the facet values */
|
|
871
|
+
q?: string;
|
|
872
|
+
/** Active filter string */
|
|
873
|
+
filter?: string;
|
|
874
|
+
/** Query to search within facet values (required) */
|
|
875
|
+
facetQuery: string;
|
|
876
|
+
/** Maximum values to return */
|
|
877
|
+
maxValues?: number;
|
|
816
878
|
}
|
|
879
|
+
export type FilterValue = DataTypesFilterValue;
|
|
880
|
+
export type FilterStats = DataTypesFilterStats;
|
|
881
|
+
export type FilterField = DataTypesFilterField;
|
|
882
|
+
export type FiltersResponse = DataTypesFiltersResponse;
|
|
883
|
+
export type FacetValuesSearchResponse = DataTypesFacetValuesSearchResponse;
|
|
884
|
+
export type FilterSchemaField = DataTypesFilterSchemaField;
|
|
885
|
+
export type FiltersSchemaResponse = DataTypesFiltersSchemaResponse;
|
|
817
886
|
export default SeekoraClient;
|
package/dist/client.js
CHANGED
|
@@ -51,8 +51,8 @@ class SeekoraClient {
|
|
|
51
51
|
if (this.enableContextCollection) {
|
|
52
52
|
this.collectContextAsync();
|
|
53
53
|
}
|
|
54
|
-
// Initialize event queue
|
|
55
|
-
this.enableEventQueue = config.enableEventQueue
|
|
54
|
+
// Initialize event queue (enabled by default for batching and offline support)
|
|
55
|
+
this.enableEventQueue = config.enableEventQueue ?? true;
|
|
56
56
|
if (this.enableEventQueue) {
|
|
57
57
|
this.eventQueue = new event_queue_1.EventQueue(config.eventQueue);
|
|
58
58
|
this.eventQueue.setLogger(this.logger);
|
|
@@ -99,6 +99,8 @@ class SeekoraClient {
|
|
|
99
99
|
this.storesApi = new generated_1.SDKStoreConfigApi(this.config);
|
|
100
100
|
this.documentsApi = new generated_1.SDKDocumentsApi(this.config);
|
|
101
101
|
this.schemaApi = new generated_1.SDKSchemaApi(this.config);
|
|
102
|
+
this.filtersApi = new generated_1.FiltersApi(this.config);
|
|
103
|
+
this.experimentsApi = new generated_1.SDKExperimentsApi(this.config);
|
|
102
104
|
this.logger.info('SeekoraClient initialized successfully');
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
@@ -542,6 +544,37 @@ class SeekoraClient {
|
|
|
542
544
|
throw this.handleError(error, 'getConfig');
|
|
543
545
|
}
|
|
544
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* Get experiment assignments for the current user
|
|
549
|
+
*
|
|
550
|
+
* Returns variant assignments for all running experiments.
|
|
551
|
+
* Uses hash-based consistent assignment on the backend.
|
|
552
|
+
*
|
|
553
|
+
* @returns ExperimentAssignmentResponse with assignments array
|
|
554
|
+
*/
|
|
555
|
+
async getExperimentAssignment() {
|
|
556
|
+
this.logger.verbose('Getting experiment assignments');
|
|
557
|
+
try {
|
|
558
|
+
const headers = {
|
|
559
|
+
'x-storeid': this.storeId,
|
|
560
|
+
'x-storesecret': this.readSecret,
|
|
561
|
+
};
|
|
562
|
+
if (this.userId)
|
|
563
|
+
headers['x-user-id'] = this.userId;
|
|
564
|
+
if (this.anonId)
|
|
565
|
+
headers['x-anon-id'] = this.anonId;
|
|
566
|
+
const response = await this.experimentsApi.v1ExperimentsAssignmentGet(this.storeId, this.readSecret, this.userId, this.anonId, { headers });
|
|
567
|
+
const data = response.data;
|
|
568
|
+
this.logger.info('Experiment assignments retrieved', {
|
|
569
|
+
count: data?.assignments?.length ?? 0,
|
|
570
|
+
});
|
|
571
|
+
return data;
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
this.logger.error('Failed to get experiment assignments', { error: error.message });
|
|
575
|
+
throw this.handleError(error, 'getExperimentAssignment');
|
|
576
|
+
}
|
|
577
|
+
}
|
|
545
578
|
/**
|
|
546
579
|
* Get store information
|
|
547
580
|
* Returns store metadata including name, status, and configuration details
|
|
@@ -1788,6 +1821,96 @@ class SeekoraClient {
|
|
|
1788
1821
|
getLogger() {
|
|
1789
1822
|
return this.logger;
|
|
1790
1823
|
}
|
|
1824
|
+
// =========================================================================
|
|
1825
|
+
// Filters API
|
|
1826
|
+
// =========================================================================
|
|
1827
|
+
/**
|
|
1828
|
+
* Get filter values and counts for configured facets.
|
|
1829
|
+
* Use this to build faceted navigation UIs without performing a full search.
|
|
1830
|
+
* Supports disjunctive faceting for OR-based filter combinations.
|
|
1831
|
+
*
|
|
1832
|
+
* @param options - Filter options (query, filters, facet_by, max_facet_values, disjunctive_facets)
|
|
1833
|
+
* @returns Filter values with counts grouped by field
|
|
1834
|
+
*/
|
|
1835
|
+
async getFilters(options) {
|
|
1836
|
+
this.logger.verbose('Getting filters', { options });
|
|
1837
|
+
try {
|
|
1838
|
+
const req = {
|
|
1839
|
+
q: options?.q,
|
|
1840
|
+
filter: options?.filter,
|
|
1841
|
+
facet_by: options?.facetBy,
|
|
1842
|
+
max_facet_values: options?.maxFacetValues,
|
|
1843
|
+
disjunctive_facets: options?.disjunctiveFacets,
|
|
1844
|
+
};
|
|
1845
|
+
const response = await this.filtersApi.v1FiltersPost(this.storeId, this.readSecret, req);
|
|
1846
|
+
const wrapper = response.data;
|
|
1847
|
+
const data = wrapper?.data || response.data;
|
|
1848
|
+
this.logger.info('Filters retrieved successfully', {
|
|
1849
|
+
filterCount: data?.filters?.length,
|
|
1850
|
+
totalResults: data?.total_results,
|
|
1851
|
+
});
|
|
1852
|
+
return data;
|
|
1853
|
+
}
|
|
1854
|
+
catch (error) {
|
|
1855
|
+
this.logger.error('Failed to get filters', { error: error.message });
|
|
1856
|
+
throw this.handleError(error, 'getFilters');
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Search within a single facet's values.
|
|
1861
|
+
* Useful for facets with many values (e.g., brands) where you need typeahead/autocomplete.
|
|
1862
|
+
*
|
|
1863
|
+
* @param facetName - The facet field name to search within (e.g., "brand", "category")
|
|
1864
|
+
* @param options - Search options including facetQuery (required), optional q, filter, maxValues
|
|
1865
|
+
* @returns Matching facet values with counts
|
|
1866
|
+
*/
|
|
1867
|
+
async searchFacetValues(facetName, options) {
|
|
1868
|
+
this.logger.verbose('Searching facet values', { facetName, options });
|
|
1869
|
+
try {
|
|
1870
|
+
const req = {
|
|
1871
|
+
facet_query: options.facetQuery,
|
|
1872
|
+
q: options?.q,
|
|
1873
|
+
filter: options?.filter,
|
|
1874
|
+
max_values: options?.maxValues,
|
|
1875
|
+
};
|
|
1876
|
+
const response = await this.filtersApi.v1FiltersFacetNameValuesPost(this.storeId, this.readSecret, facetName, req);
|
|
1877
|
+
const wrapper = response.data;
|
|
1878
|
+
const data = wrapper?.data || response.data;
|
|
1879
|
+
this.logger.info('Facet values retrieved', {
|
|
1880
|
+
facetName,
|
|
1881
|
+
valueCount: data?.values?.length,
|
|
1882
|
+
});
|
|
1883
|
+
return data;
|
|
1884
|
+
}
|
|
1885
|
+
catch (error) {
|
|
1886
|
+
this.logger.error('Failed to search facet values', { facetName, error: error.message });
|
|
1887
|
+
throw this.handleError(error, 'searchFacetValues');
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Get available filter field metadata (schema).
|
|
1892
|
+
* Returns information about all facetable fields including types, sortability, and configured ranges.
|
|
1893
|
+
* Useful for dynamically building filter UIs.
|
|
1894
|
+
*
|
|
1895
|
+
* @returns Filter field metadata with types, default facets, and max values
|
|
1896
|
+
*/
|
|
1897
|
+
async getFiltersSchema() {
|
|
1898
|
+
this.logger.verbose('Getting filters schema');
|
|
1899
|
+
try {
|
|
1900
|
+
const response = await this.filtersApi.v1FiltersSchemaGet(this.storeId, this.readSecret);
|
|
1901
|
+
const wrapper = response.data;
|
|
1902
|
+
const data = wrapper?.data || response.data;
|
|
1903
|
+
this.logger.info('Filters schema retrieved', {
|
|
1904
|
+
fieldCount: data?.fields?.length,
|
|
1905
|
+
defaultFacets: data?.default_facets?.length,
|
|
1906
|
+
});
|
|
1907
|
+
return data;
|
|
1908
|
+
}
|
|
1909
|
+
catch (error) {
|
|
1910
|
+
this.logger.error('Failed to get filters schema', { error: error.message });
|
|
1911
|
+
throw this.handleError(error, 'getFiltersSchema');
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1791
1914
|
}
|
|
1792
1915
|
exports.SeekoraClient = SeekoraClient;
|
|
1793
1916
|
// Export default
|