@constructor-io/constructorio-node 4.10.0 → 4.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-node",
3
- "version": "4.10.0",
3
+ "version": "4.11.0",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "types": "src/types/constructorio.d.ts",
@@ -53,6 +53,7 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
53
53
  filtersPerSection,
54
54
  hiddenFields,
55
55
  variationsMap,
56
+ preFilterExpression,
56
57
  resultsPerPagePerSection,
57
58
  pagePerSection,
58
59
  } = parameters;
@@ -104,6 +105,11 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
104
105
  if (variationsMap) {
105
106
  queryParams.variations_map = JSON.stringify(variationsMap);
106
107
  }
108
+
109
+ // Pull filter expression from parameters
110
+ if (preFilterExpression) {
111
+ queryParams.pre_filter_expression = JSON.stringify(preFilterExpression);
112
+ }
107
113
  }
108
114
 
109
115
  queryParams._dt = Date.now();
@@ -112,7 +118,8 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
112
118
  const queryString = qs.stringify(queryParams, { indices: false });
113
119
  const cleanedQuery = query.replace(/^\//, '|'); // For compatibility with backend API
114
120
 
115
- return `${serviceUrl}/autocomplete/${helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(cleanedQuery))}?${queryString}`;
121
+ // Note: it is intentional that query is dispatched without being trimmed
122
+ return `${serviceUrl}/autocomplete/${helpers.encodeURIComponentRFC3986(cleanedQuery)}?${queryString}`;
116
123
  }
117
124
 
118
125
  /**
@@ -141,6 +148,7 @@ class Autocomplete {
141
148
  * @param {object} [parameters.resultsPerSection] - Number of results to return (value) per section (key)
142
149
  * @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
143
150
  * @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
151
+ * @param {object} [parameters.preFilterExpression] - Faceting expression to scope autocomplete results. Please refer to https://docs.constructor.io/rest_api/collections/#add-items-dynamically for details
144
152
  * @param {object} [userParameters] - Parameters relevant to the user request
145
153
  * @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
146
154
  * @param {string} [userParameters.clientId] - Client ID, utilized to personalize results
@@ -145,7 +145,8 @@ function createSearchUrl(query, parameters, userParameters, options, isVoiceSear
145
145
 
146
146
  const searchUrl = isVoiceSearch ? 'search/natural_language' : 'search';
147
147
 
148
- return `${serviceUrl}/${searchUrl}/${helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(query))}?${queryString}`;
148
+ // Note: it is intentional that query is dispatched without being trimmed
149
+ return `${serviceUrl}/${searchUrl}/${helpers.encodeURIComponentRFC3986(query)}?${queryString}`;
149
150
  }
150
151
 
151
152
  /**
@@ -18,6 +18,7 @@ export interface AutocompleteParameters {
18
18
  resultsPerPagePerSection?: Record<string, number>;
19
19
  hiddenFields?: string[];
20
20
  variationsMap?: VariationsMap;
21
+ preFilterExpression?: FilterExpression;
21
22
  }
22
23
 
23
24
  declare class Autocomplete {
@@ -47,6 +48,8 @@ export interface AutocompleteRequestType extends Record<string, any> {
47
48
  features: Partial<RequestFeature>;
48
49
  feature_variants: Partial<RequestFeatureVariant>;
49
50
  searchandized_items: Record<string, any>;
51
+ variations_map?: VariationsMap;
52
+ pre_filter_expression?: FilterExpression;
50
53
  }
51
54
 
52
55
  export type Section = Partial<SectionItem>[];
@@ -142,4 +142,6 @@ export interface BrowseRequestType extends Record<string, any> {
142
142
  features: Partial<RequestFeature>;
143
143
  feature_variants: Partial<RequestFeatureVariant>;
144
144
  searchandized_items: Record<string, any>;
145
+ variations_map?: VariationsMap;
146
+ pre_filter_expression?: FilterExpression;
145
147
  }
@@ -83,6 +83,8 @@ export interface SearchRequestType extends Record<string, any> {
83
83
  features: Partial<RequestFeature>;
84
84
  feature_variants: Partial<RequestFeatureVariant>;
85
85
  searchandized_items: Record<string, any>;
86
+ variations_map?: VariationsMap;
87
+ pre_filter_expression?: FilterExpression;
86
88
  }
87
89
 
88
90
  export interface SearchResultType extends Record<string, any> {