@constructor-io/constructorio-node 4.7.4 → 4.7.5

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.7.5",
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
@@ -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
  }