@constructor-io/constructorio-node 4.4.7 → 4.5.1

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.
@@ -29,6 +29,7 @@ export interface BrowseParameters {
29
29
  hiddenFields?: string[];
30
30
  hiddenFacets?: string[];
31
31
  variationsMap?: Record<string, any>;
32
+ qsParam?: Record<string, any>;
32
33
  }
33
34
 
34
35
  declare class Browse {
@@ -46,7 +47,7 @@ declare class Browse {
46
47
 
47
48
  getBrowseResultsForItemIds(
48
49
  itemIds: string[],
49
- parameters?: BrowseParameters,
50
+ parameters?: Omit<BrowseParameters, 'preFilterExpression' | 'qsParam'>,
50
51
  userParameters?: UserParameters,
51
52
  networkParameters?: NetworkParameters
52
53
  ): Promise<GetBrowseResultsForItemIdsResponse>;
@@ -27,6 +27,7 @@ export interface SearchParameters {
27
27
  hiddenFields?: string[];
28
28
  hiddenFacets?: string[];
29
29
  variationsMap?: Record<string, any>;
30
+ qsParam?: Record<string, any>;
30
31
  }
31
32
 
32
33
  declare class Search {
@@ -23,6 +23,19 @@ const utils = {
23
23
  return cleanedParams;
24
24
  },
25
25
 
26
+ toSnakeCase: (camelCasedStr) => camelCasedStr.replace(/[A-Z]/g, (prefix) => `_${prefix.toLowerCase()}`),
27
+
28
+ toSnakeCaseKeys: (camelCasedObj, toRecurse = false) => {
29
+ const snakeCasedObj = {};
30
+ Object.keys(camelCasedObj).forEach((key) => {
31
+ const newKey = utils.toSnakeCase(key);
32
+ snakeCasedObj[newKey] = toRecurse && typeof camelCasedObj[key] === 'object' && !Array.isArray(camelCasedObj[key])
33
+ ? utils.toSnakeCaseKeys(camelCasedObj[key], toRecurse)
34
+ : camelCasedObj[key];
35
+ });
36
+ return snakeCasedObj;
37
+ },
38
+
26
39
  throwHttpErrorFromResponse: (error, response) => response.json().then((json) => {
27
40
  error.message = json.message;
28
41
  error.status = response.status;