@constructor-io/constructorio-node 4.4.6 → 4.5.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.
@@ -364,6 +364,7 @@ declare class Catalog {
364
364
  section: string;
365
365
  notification_email?: string;
366
366
  force?: boolean;
367
+ onMissing?: 'IGNORE' | 'CREATE' | 'FAIL';
367
368
  items?: File;
368
369
  variations?: File;
369
370
  item_groups?: File;
@@ -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;