@constructor-io/constructorio-node 4.5.2 → 4.5.3

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.5.2",
3
+ "version": "4.5.3",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "types": "src/types/constructorio.d.ts",
@@ -266,6 +266,7 @@ class Catalog {
266
266
  * @param {object} parameters - Additional parameters for item details
267
267
  * @param {object[]} parameters.items - A list of items with the same attributes as defined in the Item schema resource (https://docs.constructor.io/rest_api/items/items/#item-schema)
268
268
  * @param {boolean} [parameters.force=false] - Process the request even if it will invalidate a large number of existing items
269
+ * @param {string} [parameters.onMissing="FAIL"] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence
269
270
  * @param {string} [parameters.notificationEmail] - An email address where you'd like to receive an email notification in case the task fails
270
271
  * @param {string} [parameters.section="Products"] - This indicates which section to operate on within the index
271
272
  * @param {object} [networkParameters] - Parameters relevant to the network request
@@ -295,7 +296,7 @@ class Catalog {
295
296
  const { fetch } = this.options;
296
297
  const controller = new AbortController();
297
298
  const { signal } = controller;
298
- const { items, section, force, notification_email, notificationEmail = notification_email } = parameters;
299
+ const { items, section, force, notification_email, notificationEmail = notification_email, onMissing } = parameters;
299
300
  const queryParams = {};
300
301
 
301
302
  // Validate items is provided
@@ -315,6 +316,15 @@ class Catalog {
315
316
  queryParams.force = force;
316
317
  }
317
318
 
319
+ if (onMissing) {
320
+ // Validate onMissing parameter
321
+ if (onMissing && !['FAIL', 'IGNORE', 'CREATE'].includes(onMissing)) {
322
+ return Promise.reject(new Error('onMissing must be one of FAIL, IGNORE, or CREATE'));
323
+ }
324
+
325
+ queryParams.on_missing = onMissing;
326
+ }
327
+
318
328
  try {
319
329
  requestUrl = createCatalogUrl('items', this.options, queryParams, 'v2');
320
330
  } catch (e) {
@@ -579,6 +589,7 @@ class Catalog {
579
589
  * @param {object} parameters - Additional parameters for variation details
580
590
  * @param {object[]} parameters.variations - A list of variations with the same attributes as defined in the Variation schema resource (https://docs.constructor.io/rest_api/items/variations/#variation-schema)
581
591
  * @param {boolean} [parameters.force=false] - Process the request even if it will invalidate a large number of existing variations
592
+ * @param {string} [parameters.onMissing="FAIL"] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence
582
593
  * @param {string} [parameters.notificationEmail] - An email address where you'd like to receive an email notification in case the task fails
583
594
  * @param {string} [parameters.section="Products"] - This indicates which section to operate on within the index
584
595
  * @param {object} [networkParameters] - Parameters relevant to the network request
@@ -609,7 +620,7 @@ class Catalog {
609
620
  const { fetch } = this.options;
610
621
  const controller = new AbortController();
611
622
  const { signal } = controller;
612
- const { section, force, notification_email, notificationEmail = notification_email, variations } = parameters;
623
+ const { section, force, notification_email, notificationEmail = notification_email, variations, onMissing } = parameters;
613
624
  const queryParams = {};
614
625
 
615
626
  // Validate variations are provided
@@ -629,6 +640,15 @@ class Catalog {
629
640
  queryParams.notification_email = notificationEmail;
630
641
  }
631
642
 
643
+ if (onMissing) {
644
+ // Validate onMissing parameter
645
+ if (onMissing && !['FAIL', 'IGNORE', 'CREATE'].includes(onMissing)) {
646
+ return Promise.reject(new Error('onMissing must be one of FAIL, IGNORE, or CREATE'));
647
+ }
648
+
649
+ queryParams.on_missing = onMissing;
650
+ }
651
+
632
652
  try {
633
653
  requestUrl = createCatalogUrl('variations', this.options, queryParams, 'v2');
634
654
  } catch (e) {
@@ -2232,7 +2252,7 @@ class Catalog {
2232
2252
  * @param {string} parameters.section - The section to update
2233
2253
  * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2234
2254
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2235
- * @param {string} [parameters.onMissing] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence. Defaults to FAIL
2255
+ * @param {string} [parameters.onMissing="FAIL"] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence
2236
2256
  * @param {file} [parameters.items] - The CSV file with all new items
2237
2257
  * @param {file} [parameters.variations] - The CSV file with all new variations
2238
2258
  * @param {file} [parameters.itemGroups] - The CSV file with all new itemGroups
@@ -2384,7 +2404,7 @@ class Catalog {
2384
2404
  * @param {string} parameters.section - The section to update
2385
2405
  * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2386
2406
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2387
- * @param {string} [parameters.onMissing] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence. Defaults to FAIL
2407
+ * @param {string} [parameters.onMissing="FAIL"] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence
2388
2408
  * @param {file} [parameters.tarArchive] - The tar file that includes csv files
2389
2409
  * @param {object} [networkParameters] - Parameters relevant to the network request
2390
2410
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -35,6 +35,7 @@ declare class Catalog {
35
35
  force?: boolean;
36
36
  notificationEmail?: string;
37
37
  section?: string;
38
+ onMissing?: 'IGNORE' | 'CREATE' | 'FAIL';
38
39
  },
39
40
  networkParameters?: NetworkParameters
40
41
  ): Promise<void>;
@@ -74,6 +75,7 @@ declare class Catalog {
74
75
  force?: boolean;
75
76
  notificationEmail?: string;
76
77
  section?: string;
78
+ onMissing?: 'IGNORE' | 'CREATE' | 'FAIL';
77
79
  },
78
80
  networkParameters?: NetworkParameters
79
81
  ): Promise<void>;