@@ -12,6 +12,10 @@ export * from './browse';
1212export * from './tracker' ;
1313export * from './event-dispatcher' ;
1414
15+ type RequireAtLeastOne < T , Keys extends keyof T = keyof T > =
16+ Pick < T , Exclude < keyof T , Keys > > &
17+ { [ K in Keys ] -?: Required < Pick < T , K > > & Partial < Pick < T , Exclude < Keys , K > > > } [ Keys ] ;
18+
1519export interface NetworkParameters extends Record < string , any > {
1620 timeout ?: number ;
1721}
@@ -215,6 +219,24 @@ export type FilterExpressionRange = {
215219
216220export type FilterExpressionRangeValue = [ '-inf' | number , 'inf' | number ] ;
217221
222+ export interface VariationsMapSingleFilter {
223+ field : string ;
224+ value : string | number | boolean ;
225+ }
226+
227+ export interface VariationsMapRange {
228+ field : string ;
229+ range : FilterExpressionRangeValue ;
230+ }
231+
232+ export type FilterNode = VariationsMapSingleFilter | VariationsMapRange ;
233+
234+ export type FilterBy = RequireAtLeastOne < {
235+ and ?: Array < FilterNode | FilterBy > ;
236+ or ?: Array < FilterNode | FilterBy > ;
237+ not ?: FilterNode | FilterBy ;
238+ } > ;
239+
218240export interface Item extends Record < string , any > {
219241 value : string ;
220242 is_slotted : boolean ;
@@ -223,6 +245,7 @@ export interface Item extends Record<string, any> {
223245 data ?: ItemData ;
224246 strategy ?: { id : string } ;
225247 variations ?: { data ?: ItemData , value : string } [ ]
248+ variations_map ?: VariationsMapResponse ;
226249}
227250
228251export interface ItemData extends Record < string , any > {
@@ -244,16 +267,32 @@ export interface SearchSuggestion extends Item {
244267 } & ItemData ;
245268}
246269
270+ export type VariationsMapResponse = Array < Record < string , unknown > > | Record < string , unknown > ;
271+
272+ export type Aggregation = 'first' | 'min' | 'max' | 'all' | 'count' | 'field_count' | 'value_count' ;
273+
274+ export interface VariationsMapBaseValue {
275+ aggregation : Aggregation ;
276+ field : string ;
277+ }
278+
279+ export interface VariationsMapValueCount extends VariationsMapBaseValue {
280+ aggregation : 'value_count' ;
281+ value : boolean | number | string ;
282+ }
283+
284+ export interface VariationsMapStandardValue extends VariationsMapBaseValue {
285+ aggregation : Exclude < Aggregation , 'value_count' > ;
286+ }
287+
247288export interface VariationsMap {
248- group_by : Array < {
289+ group_by ? : Array < {
249290 name : string ,
250291 field : string
251292 } > ;
293+ filter_by ?: FilterBy ;
252294 values : {
253- [ key : string ] : {
254- aggregation : 'first' | 'min' | 'max' | 'all' ,
255- field : string
256- } ,
295+ [ key : string ] : VariationsMapValueCount | VariationsMapStandardValue ,
257296 } ,
258297 dtype : 'array' | 'object'
259298}
0 commit comments