@commercetools/sync-actions 5.12.2 → 5.14.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.
@@ -300,11 +300,14 @@ var diffpatcher = new DiffPatcher({
300
300
  includeValueOnMove: false
301
301
  },
302
302
  textDiff: {
303
- // If the value to diff has a bigger length,
304
- // a text diffing algorithm is used
305
- // See https://github.com/benjamine/jsondiffpatch/
306
- // blob/master/docs/deltas.md#text-diffs
307
- minLength: 300
303
+ /**
304
+ * jsondiffpatch uses a very fine-grained diffing algorithm for long strings to easily identify
305
+ * what changed between strings. However, we don't actually care about what changed, just
306
+ * if the string changed at all. So we set the minimum length to diff to a very large number to avoid
307
+ * using the very slow algorithm.
308
+ * See https://github.com/benjamine/jsondiffpatch/blob/master/docs/deltas.md#text-diffs.
309
+ */
310
+ minLength: Number.MAX_SAFE_INTEGER
308
311
  }
309
312
  });
310
313
  function diff(oldObj, newObj) {
@@ -682,7 +685,7 @@ function buildReferenceActions(_ref4) {
682
685
  });
683
686
  }
684
687
 
685
- var baseActionsList$j = [{
688
+ var baseActionsList$k = [{
686
689
  action: 'changeName',
687
690
  key: 'name'
688
691
  }, {
@@ -719,10 +722,10 @@ var referenceActionsList$3 = [{
719
722
  * SYNC FUNCTIONS
720
723
  */
721
724
 
722
- function actionsMapBase$j(diff, oldObj, newObj) {
725
+ function actionsMapBase$k(diff, oldObj, newObj) {
723
726
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
724
727
  return buildBaseAttributesActions({
725
- actions: baseActionsList$j,
728
+ actions: baseActionsList$k,
726
729
  diff: diff,
727
730
  oldObj: oldObj,
728
731
  newObj: newObj,
@@ -830,7 +833,7 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
830
833
  return function doMapActions(diff, newObj, oldObj) {
831
834
  var allActions = [];
832
835
  allActions.push(mapActionGroup('base', function () {
833
- return actionsMapBase$j(diff, oldObj, newObj, syncActionConfig);
836
+ return actionsMapBase$k(diff, oldObj, newObj, syncActionConfig);
834
837
  }));
835
838
  allActions.push(mapActionGroup('references', function () {
836
839
  return actionsMapReferences$3(diff, oldObj, newObj);
@@ -867,7 +870,7 @@ var categories = (function (actionGroupList, syncActionConfig) {
867
870
  });
868
871
 
869
872
  var isEmptyValue = createIsEmptyValue([undefined, null, '']);
870
- var baseActionsList$i = [{
873
+ var baseActionsList$j = [{
871
874
  action: 'setSalutation',
872
875
  key: 'salutation'
873
876
  }, {
@@ -932,10 +935,10 @@ var authenticationModeActionsList = [{
932
935
  * SYNC FUNCTIONS
933
936
  */
934
937
 
935
- function actionsMapBase$i(diff, oldObj, newObj) {
938
+ function actionsMapBase$j(diff, oldObj, newObj) {
936
939
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
937
940
  return buildBaseAttributesActions({
938
- actions: baseActionsList$i,
941
+ actions: baseActionsList$j,
939
942
  diff: diff,
940
943
  oldObj: oldObj,
941
944
  newObj: newObj,
@@ -1079,7 +1082,7 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
1079
1082
  return function doMapActions(diff, newObj, oldObj) {
1080
1083
  var allActions = [];
1081
1084
  allActions.push(mapActionGroup('base', function () {
1082
- return actionsMapBase$i(diff, oldObj, newObj, syncActionConfig);
1085
+ return actionsMapBase$j(diff, oldObj, newObj, syncActionConfig);
1083
1086
  }));
1084
1087
  allActions.push(mapActionGroup('references', function () {
1085
1088
  return actionsMapReferences$2(diff, oldObj, newObj);
@@ -1124,7 +1127,7 @@ var customers = (function (actionGroupList, syncActionConfig) {
1124
1127
  };
1125
1128
  });
1126
1129
 
1127
- var baseActionsList$h = [{
1130
+ var baseActionsList$i = [{
1128
1131
  action: 'changeQuantity',
1129
1132
  key: 'quantityOnStock',
1130
1133
  actionKey: 'quantity'
@@ -1143,10 +1146,10 @@ var referenceActionsList$1 = [{
1143
1146
  * SYNC FUNCTIONS
1144
1147
  */
1145
1148
 
1146
- function actionsMapBase$h(diff, oldObj, newObj) {
1149
+ function actionsMapBase$i(diff, oldObj, newObj) {
1147
1150
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1148
1151
  return buildBaseAttributesActions({
1149
- actions: baseActionsList$h,
1152
+ actions: baseActionsList$i,
1150
1153
  diff: diff,
1151
1154
  oldObj: oldObj,
1152
1155
  newObj: newObj,
@@ -1166,7 +1169,7 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
1166
1169
  return function doMapActions(diff, newObj, oldObj) {
1167
1170
  var allActions = [];
1168
1171
  allActions.push(mapActionGroup('base', function () {
1169
- return actionsMapBase$h(diff, oldObj, newObj, syncActionConfig);
1172
+ return actionsMapBase$i(diff, oldObj, newObj, syncActionConfig);
1170
1173
  }));
1171
1174
  allActions.push(mapActionGroup('references', function () {
1172
1175
  return actionsMapReferences$1(diff, oldObj, newObj);
@@ -1261,7 +1264,7 @@ function findMatchingPairs(diff) {
1261
1264
 
1262
1265
  var REGEX_NUMBER$2 = new RegExp(/^\d+$/);
1263
1266
  var REGEX_UNDERSCORE_NUMBER$2 = new RegExp(/^_\d+$/);
1264
- var baseActionsList$g = [{
1267
+ var baseActionsList$h = [{
1265
1268
  action: 'changeName',
1266
1269
  key: 'name'
1267
1270
  }, {
@@ -1668,10 +1671,10 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1668
1671
  */
1669
1672
 
1670
1673
 
1671
- function actionsMapBase$g(diff, oldObj, newObj) {
1674
+ function actionsMapBase$h(diff, oldObj, newObj) {
1672
1675
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1673
1676
  return buildBaseAttributesActions({
1674
- actions: baseActionsList$g,
1677
+ actions: baseActionsList$h,
1675
1678
  diff: diff,
1676
1679
  oldObj: oldObj,
1677
1680
  newObj: newObj,
@@ -1771,7 +1774,7 @@ function actionsMapAssets(diff, oldObj, newObj, variantHashMap) {
1771
1774
  });
1772
1775
  return allAssetsActions;
1773
1776
  }
1774
- function actionsMapAttributes(diff, oldObj, newObj) {
1777
+ function actionsMapAttributes$1(diff, oldObj, newObj) {
1775
1778
  var sameForAllAttributeNames = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1776
1779
  var variantHashMap = arguments.length > 4 ? arguments[4] : undefined;
1777
1780
  var actions = [];
@@ -1902,7 +1905,7 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
1902
1905
  staged = newObj.staged;
1903
1906
  var variantHashMap = findMatchingPairs(diff.variants, oldObj.variants, newObj.variants);
1904
1907
  allActions.push(mapActionGroup('attributes', function () {
1905
- return actionsMapAttributes(diff, oldObj, newObj, sameForAllAttributeNames || [], variantHashMap);
1908
+ return actionsMapAttributes$1(diff, oldObj, newObj, sameForAllAttributeNames || [], variantHashMap);
1906
1909
  }));
1907
1910
  allActions.push(mapActionGroup('variants', function () {
1908
1911
  return actionsMapAddVariants(diff, oldObj, newObj);
@@ -1912,7 +1915,7 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
1912
1915
  return actionsMapRemoveVariants(diff, oldObj, newObj);
1913
1916
  }));
1914
1917
  allActions.push(mapActionGroup('base', function () {
1915
- return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
1918
+ return actionsMapBase$h(diff, oldObj, newObj, syncActionConfig);
1916
1919
  }));
1917
1920
  allActions.push(mapActionGroup('meta', function () {
1918
1921
  return actionsMapMeta(diff, oldObj, newObj);
@@ -1987,7 +1990,7 @@ var isRemoveAction = function isRemoveAction(key, resource) {
1987
1990
  return REGEX_UNDERSCORE_NUMBER$1.test(key) && Number(resource[2]) === 0;
1988
1991
  };
1989
1992
 
1990
- var baseActionsList$f = [{
1993
+ var baseActionsList$g = [{
1991
1994
  action: 'changeOrderState',
1992
1995
  key: 'orderState'
1993
1996
  }, {
@@ -2001,10 +2004,10 @@ var baseActionsList$f = [{
2001
2004
  * SYNC FUNCTIONS
2002
2005
  */
2003
2006
 
2004
- function actionsMapBase$f(diff, oldObj, newObj) {
2007
+ function actionsMapBase$g(diff, oldObj, newObj) {
2005
2008
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2006
2009
  return buildBaseAttributesActions({
2007
- actions: baseActionsList$f,
2010
+ actions: baseActionsList$g,
2008
2011
  diff: diff,
2009
2012
  oldObj: oldObj,
2010
2013
  newObj: newObj,
@@ -2171,7 +2174,7 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
2171
2174
  }
2172
2175
 
2173
2176
  allActions.push(mapActionGroup('base', function () {
2174
- return actionsMapBase$f(diff, oldObj, newObj, syncActionConfig);
2177
+ return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
2175
2178
  }));
2176
2179
  allActions.push(mapActionGroup('deliveries', function () {
2177
2180
  return actionsMapDeliveries(diff, oldObj, newObj);
@@ -2210,7 +2213,7 @@ var orders = (function (actionGroupList, syncActionConfig) {
2210
2213
  };
2211
2214
  });
2212
2215
 
2213
- var baseActionsList$e = [{
2216
+ var baseActionsList$f = [{
2214
2217
  action: 'changeIsActive',
2215
2218
  key: 'isActive'
2216
2219
  }, {
@@ -2238,10 +2241,10 @@ var baseActionsList$e = [{
2238
2241
  action: 'setKey',
2239
2242
  key: 'key'
2240
2243
  }];
2241
- function actionsMapBase$e(diff, oldObj, newObj) {
2244
+ function actionsMapBase$f(diff, oldObj, newObj) {
2242
2245
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2243
2246
  return buildBaseAttributesActions({
2244
- actions: baseActionsList$e,
2247
+ actions: baseActionsList$f,
2245
2248
  diff: diff,
2246
2249
  oldObj: oldObj,
2247
2250
  newObj: newObj,
@@ -2282,7 +2285,7 @@ function createProductDiscountsMapActions(mapActionGroup, syncActionConfig) {
2282
2285
  return function doMapActions(diff, newObj, oldObj) {
2283
2286
  var allActions = [];
2284
2287
  allActions.push(mapActionGroup('base', function () {
2285
- return actionsMapBase$e(diff, oldObj, newObj, syncActionConfig);
2288
+ return actionsMapBase$f(diff, oldObj, newObj, syncActionConfig);
2286
2289
  }));
2287
2290
  return combineValidityActions(flatten__default["default"](allActions));
2288
2291
  };
@@ -2298,7 +2301,7 @@ var productDiscounts = (function (actionGroupList) {
2298
2301
  };
2299
2302
  });
2300
2303
 
2301
- var baseActionsList$d = [{
2304
+ var baseActionsList$e = [{
2302
2305
  action: 'changeIsActive',
2303
2306
  key: 'isActive'
2304
2307
  }, {
@@ -2329,10 +2332,10 @@ var baseActionsList$d = [{
2329
2332
  action: 'changeGroups',
2330
2333
  key: 'groups'
2331
2334
  }];
2332
- function actionsMapBase$d(diff, oldObj, newObj) {
2335
+ function actionsMapBase$e(diff, oldObj, newObj) {
2333
2336
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2334
2337
  return buildBaseAttributesActions({
2335
- actions: baseActionsList$d,
2338
+ actions: baseActionsList$e,
2336
2339
  diff: diff,
2337
2340
  oldObj: oldObj,
2338
2341
  newObj: newObj,
@@ -2344,7 +2347,7 @@ function createDiscountCodesMapActions(mapActionGroup, syncActionConfig) {
2344
2347
  return function doMapActions(diff, newObj, oldObj) {
2345
2348
  var allActions = [];
2346
2349
  allActions.push(mapActionGroup('base', function () {
2347
- return actionsMapBase$d(diff, oldObj, newObj, syncActionConfig);
2350
+ return actionsMapBase$e(diff, oldObj, newObj, syncActionConfig);
2348
2351
  }));
2349
2352
  allActions.push(mapActionGroup('custom', function () {
2350
2353
  return actionsMapCustom(diff, newObj, oldObj);
@@ -2372,17 +2375,17 @@ var discountCodes = (function (actionGroupList) {
2372
2375
  };
2373
2376
  });
2374
2377
 
2375
- var baseActionsList$c = [{
2378
+ var baseActionsList$d = [{
2376
2379
  action: 'changeName',
2377
2380
  key: 'name'
2378
2381
  }, {
2379
2382
  action: 'setKey',
2380
2383
  key: 'key'
2381
2384
  }];
2382
- function actionsMapBase$c(diff, oldObj, newObj) {
2385
+ function actionsMapBase$d(diff, oldObj, newObj) {
2383
2386
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2384
2387
  return buildBaseAttributesActions({
2385
- actions: baseActionsList$c,
2388
+ actions: baseActionsList$d,
2386
2389
  diff: diff,
2387
2390
  oldObj: oldObj,
2388
2391
  newObj: newObj,
@@ -2394,7 +2397,7 @@ function createCustomerGroupMapActions(mapActionGroup, syncActionConfig) {
2394
2397
  return function doMapActions(diff, newObj, oldObj) {
2395
2398
  var allActions = [];
2396
2399
  allActions.push(mapActionGroup('base', function () {
2397
- return actionsMapBase$c(diff, oldObj, newObj, syncActionConfig);
2400
+ return actionsMapBase$d(diff, oldObj, newObj, syncActionConfig);
2398
2401
  }));
2399
2402
  allActions.push(mapActionGroup('custom', function () {
2400
2403
  return actionsMapCustom(diff, newObj, oldObj);
@@ -2413,7 +2416,7 @@ var customerGroup = (function (actionGroupList) {
2413
2416
  };
2414
2417
  });
2415
2418
 
2416
- var baseActionsList$b = [{
2419
+ var baseActionsList$c = [{
2417
2420
  action: 'changeIsActive',
2418
2421
  key: 'isActive'
2419
2422
  }, {
@@ -2450,10 +2453,10 @@ var baseActionsList$b = [{
2450
2453
  action: 'setKey',
2451
2454
  key: 'key'
2452
2455
  }];
2453
- function actionsMapBase$b(diff, oldObj, newObj) {
2456
+ function actionsMapBase$c(diff, oldObj, newObj) {
2454
2457
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2455
2458
  return buildBaseAttributesActions({
2456
- actions: baseActionsList$b,
2459
+ actions: baseActionsList$c,
2457
2460
  diff: diff,
2458
2461
  oldObj: oldObj,
2459
2462
  newObj: newObj,
@@ -2465,7 +2468,7 @@ function createCartDiscountsMapActions(mapActionGroup, syncActionConfig) {
2465
2468
  return function doMapActions(diff, newObj, oldObj) {
2466
2469
  var allActions = [];
2467
2470
  allActions.push(mapActionGroup('base', function () {
2468
- return actionsMapBase$b(diff, oldObj, newObj, syncActionConfig);
2471
+ return actionsMapBase$c(diff, oldObj, newObj, syncActionConfig);
2469
2472
  }));
2470
2473
  allActions.push(mapActionGroup('custom', function () {
2471
2474
  return actionsMapCustom(diff, newObj, oldObj);
@@ -2484,7 +2487,7 @@ var cartDiscounts = (function (actionGroupList) {
2484
2487
  };
2485
2488
  });
2486
2489
 
2487
- var baseActionsList$a = [{
2490
+ var baseActionsList$b = [{
2488
2491
  action: 'changeName',
2489
2492
  key: 'name'
2490
2493
  }, {
@@ -2494,10 +2497,10 @@ var baseActionsList$a = [{
2494
2497
  action: 'setDescription',
2495
2498
  key: 'description'
2496
2499
  }];
2497
- function actionsMapBase$a(diff, oldObj, newObj) {
2500
+ function actionsMapBase$b(diff, oldObj, newObj) {
2498
2501
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2499
2502
  return buildBaseAttributesActions({
2500
- actions: baseActionsList$a,
2503
+ actions: baseActionsList$b,
2501
2504
  diff: diff,
2502
2505
  oldObj: oldObj,
2503
2506
  newObj: newObj,
@@ -2531,7 +2534,7 @@ function createTaxCategoriesMapActions(mapActionGroup, syncActionConfig) {
2531
2534
  return function doMapActions(diff, newObj, oldObj) {
2532
2535
  var allActions = [];
2533
2536
  allActions.push(mapActionGroup('base', function () {
2534
- return actionsMapBase$a(diff, oldObj, newObj, syncActionConfig);
2537
+ return actionsMapBase$b(diff, oldObj, newObj, syncActionConfig);
2535
2538
  }));
2536
2539
  allActions.push(mapActionGroup('rates', function () {
2537
2540
  return actionsMapRates(diff, oldObj, newObj);
@@ -2558,7 +2561,7 @@ var taxCategories = (function (actionGroupList, syncActionConfig) {
2558
2561
  };
2559
2562
  });
2560
2563
 
2561
- var baseActionsList$9 = [{
2564
+ var baseActionsList$a = [{
2562
2565
  action: 'changeName',
2563
2566
  key: 'name'
2564
2567
  }, {
@@ -2575,10 +2578,10 @@ var hasLocation = function hasLocation(locations, otherLocation) {
2575
2578
  });
2576
2579
  };
2577
2580
 
2578
- function actionsMapBase$9(diff, oldObj, newObj) {
2581
+ function actionsMapBase$a(diff, oldObj, newObj) {
2579
2582
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2580
2583
  return buildBaseAttributesActions({
2581
- actions: baseActionsList$9,
2584
+ actions: baseActionsList$a,
2582
2585
  diff: diff,
2583
2586
  oldObj: oldObj,
2584
2587
  newObj: newObj,
@@ -2623,7 +2626,7 @@ function createZonesMapActions(mapActionGroup, syncActionConfig) {
2623
2626
  return function doMapActions(diff, newObj, oldObj) {
2624
2627
  var allActions = [];
2625
2628
  allActions.push(mapActionGroup('base', function () {
2626
- return actionsMapBase$9(diff, oldObj, newObj, syncActionConfig);
2629
+ return actionsMapBase$a(diff, oldObj, newObj, syncActionConfig);
2627
2630
  }));
2628
2631
  allActions.push(flatten__default["default"](mapActionGroup('locations', function () {
2629
2632
  return actionsMapLocations(diff, oldObj, newObj);
@@ -2650,7 +2653,7 @@ var zones = (function (actionGroupList, syncActionConfig) {
2650
2653
  };
2651
2654
  });
2652
2655
 
2653
- var baseActionsList$8 = [{
2656
+ var baseActionsList$9 = [{
2654
2657
  action: 'setKey',
2655
2658
  key: 'key'
2656
2659
  }, {
@@ -2675,10 +2678,10 @@ var baseActionsList$8 = [{
2675
2678
  action: 'changeTaxCategory',
2676
2679
  key: 'taxCategory'
2677
2680
  }];
2678
- function actionsMapBase$8(diff, oldObj, newObj) {
2681
+ function actionsMapBase$9(diff, oldObj, newObj) {
2679
2682
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2680
2683
  return buildBaseAttributesActions({
2681
- actions: baseActionsList$8,
2684
+ actions: baseActionsList$9,
2682
2685
  diff: diff,
2683
2686
  oldObj: oldObj,
2684
2687
  newObj: newObj,
@@ -2760,7 +2763,7 @@ function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
2760
2763
  return function doMapActions(diff, newObj, oldObj) {
2761
2764
  var allActions = [];
2762
2765
  allActions.push(mapActionGroup('base', function () {
2763
- return actionsMapBase$8(diff, oldObj, newObj, syncActionConfig);
2766
+ return actionsMapBase$9(diff, oldObj, newObj, syncActionConfig);
2764
2767
  }));
2765
2768
  allActions.push(flatten__default["default"](mapActionGroup('zoneRates', function () {
2766
2769
  return actionsMapZoneRates(diff, oldObj, newObj);
@@ -3158,7 +3161,7 @@ createComparator(function () {
3158
3161
  createComparator(createCircularEqualCreator());
3159
3162
  createComparator(createCircularEqualCreator(sameValueZeroEqual));
3160
3163
 
3161
- var baseActionsList$7 = [{
3164
+ var baseActionsList$8 = [{
3162
3165
  action: 'changeName',
3163
3166
  key: 'name'
3164
3167
  }, {
@@ -3168,7 +3171,7 @@ var baseActionsList$7 = [{
3168
3171
  action: 'changeDescription',
3169
3172
  key: 'description'
3170
3173
  }];
3171
- function actionsMapBase$7(diff, previous, next) {
3174
+ function actionsMapBase$8(diff, previous, next) {
3172
3175
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3173
3176
  // when `diff` is undefined, then the underlying `buildActions` has returned any diff
3174
3177
  // which given in product-types would mean that `buildActions` has run with `nestedValuesChanges` applied
@@ -3176,7 +3179,7 @@ function actionsMapBase$7(diff, previous, next) {
3176
3179
  if (!diff) return [];
3177
3180
  return buildBaseAttributesActions({
3178
3181
  diff: diff,
3179
- actions: baseActionsList$7,
3182
+ actions: baseActionsList$8,
3180
3183
  oldObj: previous,
3181
3184
  newObj: next,
3182
3185
  shouldOmitEmptyString: config.shouldOmitEmptyString
@@ -3402,7 +3405,7 @@ function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
3402
3405
  return flatten__default["default"]([// we support only base fields for the product type,
3403
3406
  // for attributes, applying hints would be recommended
3404
3407
  mapActionGroup('base', function () {
3405
- return actionsMapBase$7(diff, previous, next, syncActionConfig);
3408
+ return actionsMapBase$8(diff, previous, next, syncActionConfig);
3406
3409
  }), actionsMapForHints(options.nestedValuesChanges, previous, next)]);
3407
3410
  };
3408
3411
  }
@@ -3419,7 +3422,7 @@ var productTypes = (function (actionGroupList, syncActionConfig) {
3419
3422
  };
3420
3423
  });
3421
3424
 
3422
- var baseActionsList$6 = [{
3425
+ var baseActionsList$7 = [{
3423
3426
  action: 'changeKey',
3424
3427
  key: 'key'
3425
3428
  }, {
@@ -3438,10 +3441,10 @@ var baseActionsList$6 = [{
3438
3441
  action: 'setTransitions',
3439
3442
  key: 'transitions'
3440
3443
  }];
3441
- function actionsMapBase$6(diff, oldObj, newObj) {
3444
+ function actionsMapBase$7(diff, oldObj, newObj) {
3442
3445
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3443
3446
  return buildBaseAttributesActions({
3444
- actions: baseActionsList$6,
3447
+ actions: baseActionsList$7,
3445
3448
  diff: diff,
3446
3449
  oldObj: oldObj,
3447
3450
  newObj: newObj,
@@ -3491,7 +3494,7 @@ function createStatesMapActions(mapActionGroup, syncActionConfig) {
3491
3494
  var baseActions = [];
3492
3495
  var roleActions = [];
3493
3496
  baseActions.push(mapActionGroup('base', function () {
3494
- return actionsMapBase$6(diff, oldObj, newObj, syncActionConfig);
3497
+ return actionsMapBase$7(diff, oldObj, newObj, syncActionConfig);
3495
3498
  }));
3496
3499
  roleActions.push(mapActionGroup('roles', function () {
3497
3500
  return actionsMapRoles(diff, oldObj, newObj);
@@ -3509,7 +3512,7 @@ var states = (function (actionGroupList, syncActionConfig) {
3509
3512
  };
3510
3513
  });
3511
3514
 
3512
- var baseActionsList$5 = [{
3515
+ var baseActionsList$6 = [{
3513
3516
  action: 'changeKey',
3514
3517
  key: 'key'
3515
3518
  }, {
@@ -3528,10 +3531,10 @@ var baseActionsList$5 = [{
3528
3531
  action: 'setRoles',
3529
3532
  key: 'roles'
3530
3533
  }];
3531
- function actionsMapBase$5(diff, oldObj, newObj) {
3534
+ function actionsMapBase$6(diff, oldObj, newObj) {
3532
3535
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3533
3536
  return buildBaseAttributesActions({
3534
- actions: baseActionsList$5,
3537
+ actions: baseActionsList$6,
3535
3538
  diff: diff,
3536
3539
  oldObj: oldObj,
3537
3540
  newObj: newObj,
@@ -3543,7 +3546,7 @@ function createChannelsMapActions$1(mapActionGroup, syncActionConfig) {
3543
3546
  return function doMapActions(diff, newObj, oldObj) {
3544
3547
  var allActions = [];
3545
3548
  allActions.push(mapActionGroup('base', function () {
3546
- return actionsMapBase$5(diff, oldObj, newObj, syncActionConfig);
3549
+ return actionsMapBase$6(diff, oldObj, newObj, syncActionConfig);
3547
3550
  }));
3548
3551
  allActions.push(mapActionGroup('custom', function () {
3549
3552
  return actionsMapCustom(diff, newObj, oldObj);
@@ -3573,7 +3576,7 @@ var getIsRemovedOperation = function getIsRemovedOperation(key) {
3573
3576
  return REGEX_UNDERSCORE_NUMBER.test(key);
3574
3577
  };
3575
3578
 
3576
- var baseActionsList$4 = [{
3579
+ var baseActionsList$5 = [{
3577
3580
  action: 'changeKey',
3578
3581
  key: 'key'
3579
3582
  }, {
@@ -3583,10 +3586,10 @@ var baseActionsList$4 = [{
3583
3586
  action: 'setDescription',
3584
3587
  key: 'description'
3585
3588
  }];
3586
- function actionsMapBase$4(diff, oldObj, newObj) {
3589
+ function actionsMapBase$5(diff, oldObj, newObj) {
3587
3590
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3588
3591
  return buildBaseAttributesActions({
3589
- actions: baseActionsList$4,
3592
+ actions: baseActionsList$5,
3590
3593
  diff: diff,
3591
3594
  oldObj: oldObj,
3592
3595
  newObj: newObj,
@@ -3735,7 +3738,7 @@ function createTypeMapActions(mapActionGroup, syncActionConfig) {
3735
3738
  return function doMapActions(diff, next, previous) {
3736
3739
  var allActions = [];
3737
3740
  allActions.push(mapActionGroup('base', function () {
3738
- return actionsMapBase$4(diff, previous, next, syncActionConfig);
3741
+ return actionsMapBase$5(diff, previous, next, syncActionConfig);
3739
3742
  }), mapActionGroup('fieldDefinitions', function () {
3740
3743
  return actionsMapFieldDefinitions(diff.fieldDefinitions, previous.fieldDefinitions, next.fieldDefinitions, findMatchingPairs(diff.fieldDefinitions, previous.fieldDefinitions, next.fieldDefinitions, 'name'));
3741
3744
  }));
@@ -3752,7 +3755,7 @@ var types = (function (actionGroupList, syncActionConfig) {
3752
3755
  };
3753
3756
  });
3754
3757
 
3755
- var baseActionsList$3 = [{
3758
+ var baseActionsList$4 = [{
3756
3759
  action: 'changeName',
3757
3760
  key: 'name'
3758
3761
  }, {
@@ -3771,10 +3774,10 @@ var baseActionsList$3 = [{
3771
3774
  action: 'setShippingRateInputType',
3772
3775
  key: 'shippingRateInputType'
3773
3776
  }];
3774
- function actionsMapBase$3(diff, oldObj, newObj) {
3777
+ function actionsMapBase$4(diff, oldObj, newObj) {
3775
3778
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3776
3779
  return buildBaseAttributesActions({
3777
- actions: baseActionsList$3,
3780
+ actions: baseActionsList$4,
3778
3781
  diff: diff,
3779
3782
  oldObj: oldObj,
3780
3783
  newObj: newObj,
@@ -3786,7 +3789,7 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
3786
3789
  return function doMapActions(diff, newObj, oldObj) {
3787
3790
  var allActions = [];
3788
3791
  allActions.push(mapActionGroup('base', function () {
3789
- return actionsMapBase$3(diff, oldObj, newObj, syncActionConfig);
3792
+ return actionsMapBase$4(diff, oldObj, newObj, syncActionConfig);
3790
3793
  }));
3791
3794
  return flatten__default["default"](allActions);
3792
3795
  };
@@ -3802,7 +3805,7 @@ var projects = (function (actionGroupList) {
3802
3805
  };
3803
3806
  });
3804
3807
 
3805
- var baseActionsList$2 = [{
3808
+ var baseActionsList$3 = [{
3806
3809
  action: 'setName',
3807
3810
  key: 'name'
3808
3811
  }, {
@@ -3815,9 +3818,9 @@ var baseActionsList$2 = [{
3815
3818
  action: 'setSupplyChannels',
3816
3819
  key: 'supplyChannels'
3817
3820
  }];
3818
- function actionsMapBase$2(diff, oldObj, newObj) {
3821
+ function actionsMapBase$3(diff, oldObj, newObj) {
3819
3822
  return buildBaseAttributesActions({
3820
- actions: baseActionsList$2,
3823
+ actions: baseActionsList$3,
3821
3824
  diff: diff,
3822
3825
  oldObj: oldObj,
3823
3826
  newObj: newObj
@@ -3828,7 +3831,7 @@ function createStoresMapActions(mapActionGroup) {
3828
3831
  return function doMapActions(diff, next, previous) {
3829
3832
  var allActions = [];
3830
3833
  allActions.push(mapActionGroup('base', function () {
3831
- return actionsMapBase$2(diff, previous, next);
3834
+ return actionsMapBase$3(diff, previous, next);
3832
3835
  }));
3833
3836
  allActions.push(mapActionGroup('custom', function () {
3834
3837
  return actionsMapCustom(diff, next, previous);
@@ -3847,16 +3850,16 @@ var stores = (function (actionGroupList) {
3847
3850
  };
3848
3851
  });
3849
3852
 
3850
- var baseActionsList$1 = [{
3853
+ var baseActionsList$2 = [{
3851
3854
  action: 'changeName',
3852
3855
  key: 'name'
3853
3856
  }, {
3854
3857
  action: 'setKey',
3855
3858
  key: 'key'
3856
3859
  }];
3857
- function actionsMapBase$1(diff, oldObj, newObj) {
3860
+ function actionsMapBase$2(diff, oldObj, newObj) {
3858
3861
  return buildBaseAttributesActions({
3859
- actions: baseActionsList$1,
3862
+ actions: baseActionsList$2,
3860
3863
  diff: diff,
3861
3864
  oldObj: oldObj,
3862
3865
  newObj: newObj
@@ -3867,7 +3870,7 @@ function createProductSelectionsMapActions(mapActionGroup) {
3867
3870
  return function doMapActions(diff, next, previous) {
3868
3871
  var allActions = [];
3869
3872
  allActions.push(mapActionGroup('base', function () {
3870
- return actionsMapBase$1(diff, previous, next);
3873
+ return actionsMapBase$2(diff, previous, next);
3871
3874
  }));
3872
3875
  allActions.push(mapActionGroup('custom', function () {
3873
3876
  return actionsMapCustom(diff, next, previous);
@@ -3886,7 +3889,7 @@ var productSelections = (function (actionGroupList) {
3886
3889
  };
3887
3890
  });
3888
3891
 
3889
- var baseActionsList = [{
3892
+ var baseActionsList$1 = [{
3890
3893
  action: 'changeValue',
3891
3894
  key: 'value'
3892
3895
  }, {
@@ -3909,10 +3912,10 @@ var baseActionsList = [{
3909
3912
  action: 'changeActive',
3910
3913
  key: 'active'
3911
3914
  }];
3912
- function actionsMapBase(diff, oldObj, newObj) {
3915
+ function actionsMapBase$1(diff, oldObj, newObj) {
3913
3916
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3914
3917
  return buildBaseAttributesActions({
3915
- actions: baseActionsList,
3918
+ actions: baseActionsList$1,
3916
3919
  diff: diff,
3917
3920
  oldObj: oldObj,
3918
3921
  newObj: newObj,
@@ -3923,7 +3926,7 @@ function actionsMapBase(diff, oldObj, newObj) {
3923
3926
  function createPriceMapActions(mapActionGroup, syncActionConfig) {
3924
3927
  return function doMapActions(diff, newObj, oldObj) {
3925
3928
  var baseActions = mapActionGroup('base', function () {
3926
- return actionsMapBase(diff, oldObj, newObj, syncActionConfig);
3929
+ return actionsMapBase$1(diff, oldObj, newObj, syncActionConfig);
3927
3930
  });
3928
3931
  var customActions = mapActionGroup('custom', function () {
3929
3932
  return actionsMapCustom(diff, newObj, oldObj);
@@ -3941,6 +3944,88 @@ var prices = (function (actionGroupList, syncActionConfig) {
3941
3944
  };
3942
3945
  });
3943
3946
 
3947
+ var hasAttribute = function hasAttribute(attributes, newValue) {
3948
+ return attributes.some(function (attribute) {
3949
+ return attribute.key === newValue.key;
3950
+ });
3951
+ };
3952
+
3953
+ var baseActionsList = [{
3954
+ action: 'changeName',
3955
+ key: 'name'
3956
+ }, {
3957
+ action: 'setKey',
3958
+ key: 'key'
3959
+ }, {
3960
+ action: 'setDescription',
3961
+ key: 'description'
3962
+ }];
3963
+ function actionsMapBase(diff, oldObj, newObj) {
3964
+ var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3965
+ return buildBaseAttributesActions({
3966
+ actions: baseActionsList,
3967
+ diff: diff,
3968
+ oldObj: oldObj,
3969
+ newObj: newObj,
3970
+ shouldOmitEmptyString: config.shouldOmitEmptyString
3971
+ });
3972
+ }
3973
+ function actionsMapAttributes(diff, oldObj, newObj) {
3974
+ var _createBuildArrayActi;
3975
+
3976
+ var handler = createBuildArrayActions('attributes', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAttribute) {
3977
+ return {
3978
+ action: 'addAttribute',
3979
+ attribute: newAttribute
3980
+ };
3981
+ }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAttribute) {
3982
+ // We only add the action if the attribute is not included in the new object.
3983
+ return !hasAttribute(newObj.attributes, oldAttribute) ? {
3984
+ action: 'removeAttribute',
3985
+ attribute: oldAttribute
3986
+ } : null;
3987
+ }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
3988
+ var result = []; // We only remove the attribute in case that the oldAttribute is not
3989
+ // included in the new object
3990
+
3991
+ if (!hasAttribute(newObj.attributes, oldAttribute)) result.push({
3992
+ action: 'removeAttribute',
3993
+ attribute: oldAttribute
3994
+ }); // We only add the attribute in case that the newAttribute was not
3995
+ // included in the old object
3996
+
3997
+ if (!hasAttribute(oldObj.attributes, newAttribute)) result.push({
3998
+ action: 'addAttribute',
3999
+ attribute: newAttribute
4000
+ });
4001
+ return result;
4002
+ }), _createBuildArrayActi));
4003
+ return handler(diff, oldObj, newObj);
4004
+ }
4005
+
4006
+ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
4007
+ return function doMapActions(diff, newObj, oldObj) {
4008
+ var allActions = [];
4009
+ allActions.push(mapActionGroup('base', function () {
4010
+ return actionsMapBase(diff, oldObj, newObj, syncActionConfig);
4011
+ }));
4012
+ allActions.push(flatten__default["default"](mapActionGroup('attributes', function () {
4013
+ return actionsMapAttributes(diff, oldObj, newObj);
4014
+ })));
4015
+ return flatten__default["default"](allActions);
4016
+ };
4017
+ }
4018
+
4019
+ var attributeGroups = (function (actionGroupList, syncActionConfig) {
4020
+ var mapActionGroup = createMapActionGroup(actionGroupList);
4021
+ var doMapActions = createAttributeGroupsMapActions(mapActionGroup, syncActionConfig);
4022
+ var buildActions = createBuildActions(diff, doMapActions);
4023
+ return {
4024
+ buildActions: buildActions
4025
+ };
4026
+ });
4027
+
4028
+ exports.createSyncAttributeGroups = attributeGroups;
3944
4029
  exports.createSyncCartDiscounts = cartDiscounts;
3945
4030
  exports.createSyncCategories = categories;
3946
4031
  exports.createSyncChannels = channels;