@constructor-io/constructorio-node 4.7.4 → 4.8.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.7.4",
3
+ "version": "4.8.0",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "types": "src/types/constructorio.d.ts",
@@ -46,13 +46,32 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
46
46
  }
47
47
 
48
48
  if (parameters) {
49
- const { numResults, resultsPerSection, filters, hiddenFields, variationsMap } = parameters;
49
+ const {
50
+ numResults,
51
+ resultsPerSection,
52
+ filters,
53
+ filtersPerSection,
54
+ hiddenFields,
55
+ variationsMap,
56
+ resultsPerPagePerSection,
57
+ pagePerSection,
58
+ } = parameters;
50
59
 
51
60
  // Pull results number from parameters
52
61
  if (numResults) {
53
62
  queryParams.num_results = numResults;
54
63
  }
55
64
 
65
+ // Pull page per section from parameters
66
+ if (pagePerSection) {
67
+ queryParams.page_per_section = pagePerSection;
68
+ }
69
+
70
+ // Pull results number per page per section from parameters
71
+ if (resultsPerPagePerSection) {
72
+ queryParams.num_section_results_per_page = resultsPerPagePerSection;
73
+ }
74
+
56
75
  // Pull results number per section from parameters
57
76
  if (resultsPerSection) {
58
77
  Object.keys(resultsPerSection).forEach((section) => {
@@ -65,6 +84,13 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
65
84
  queryParams.filters = filters;
66
85
  }
67
86
 
87
+ // Pull filtersPerSection from parameters
88
+ if (filtersPerSection) {
89
+ Object.keys(filtersPerSection).forEach((section) => {
90
+ queryParams[`filters[${section}]`] = filtersPerSection[section];
91
+ });
92
+ }
93
+
68
94
  // Pull hidden fields from parameters
69
95
  if (hiddenFields) {
70
96
  if (queryParams.fmt_options) {
@@ -108,7 +134,10 @@ class Autocomplete {
108
134
  * @param {string} query - Term to use to perform an autocomplete search
109
135
  * @param {object} [parameters] - Additional parameters to refine result set
110
136
  * @param {number} [parameters.numResults] - The total number of results to return
137
+ * @param {object} [parameters.pagePerSection] - The page number of the results per section
138
+ * @param {object} [parameters.resultsPerPagePerSection] - The number of results per page to return per section
111
139
  * @param {object} [parameters.filters] - Filters used to refine search
140
+ * @param {object} [parameters.filtersPerSection] - Filters used to refine search per section
112
141
  * @param {object} [parameters.resultsPerSection] - Number of results to return (value) per section (key)
113
142
  * @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
114
143
  * @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
@@ -38,7 +38,7 @@ function createRecommendationsUrl(podId, parameters, userParameters, options) {
38
38
  }
39
39
 
40
40
  if (parameters) {
41
- const { numResults, itemIds, section, term, filters, variationsMap } = parameters;
41
+ const { numResults, itemIds, section, term, filters, variationsMap, hiddenFields } = parameters;
42
42
 
43
43
  // Pull num results number from parameters
44
44
  if (!helpers.isNil(numResults)) {
@@ -65,6 +65,15 @@ function createRecommendationsUrl(podId, parameters, userParameters, options) {
65
65
  queryParams.filters = filters;
66
66
  }
67
67
 
68
+ // Pull hidden fields from parameters
69
+ if (hiddenFields) {
70
+ if (queryParams.fmt_options) {
71
+ queryParams.fmt_options.hidden_fields = hiddenFields;
72
+ } else {
73
+ queryParams.fmt_options = { hidden_fields: hiddenFields };
74
+ }
75
+ }
76
+
68
77
  // Pull variations map from parameters
69
78
  if (variationsMap) {
70
79
  queryParams.variations_map = JSON.stringify(variationsMap);
@@ -102,6 +111,7 @@ class Recommendations {
102
111
  * @param {string} [parameters.term] - The term to use to refine results (strategy specific)
103
112
  * @param {object} [parameters.filters] - Key / value mapping of filters used to refine results
104
113
  * @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
114
+ * @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
105
115
  * @param {object} [userParameters] - Parameters relevant to the user request
106
116
  * @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
107
117
  * @param {string} [userParameters.clientId] - Client ID, utilized to personalize results
@@ -12,7 +12,10 @@ export default Autocomplete;
12
12
  export interface AutocompleteParameters {
13
13
  numResults?: number;
14
14
  filters?: Record<string, any>;
15
+ filtersPerSection?: Record<string, Record<string, any>>;
15
16
  resultsPerSection?: Record<string, number>;
17
+ pagePerSection?: Record<string, number>;
18
+ resultsPerPagePerSection?: Record<string, number>;
16
19
  hiddenFields?: string[];
17
20
  variationsMap?: VariationsMap;
18
21
  }
@@ -9,6 +9,7 @@ export interface RecommendationsParameters {
9
9
  term?: string;
10
10
  filters?: Record<string, any>;
11
11
  variationsMap?: VariationsMap;
12
+ hiddenFields?: string[];
12
13
  }
13
14
 
14
15
  declare class Recommendations {