@commercetools/sync-actions 5.17.0 → 5.19.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.
@@ -22,174 +22,143 @@ var intersection__default = /*#__PURE__*/_interopDefaultLegacy(intersection);
22
22
  var without__default = /*#__PURE__*/_interopDefaultLegacy(without);
23
23
  var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
24
24
 
25
- function ownKeys(object, enumerableOnly) {
26
- var keys = Object.keys(object);
27
-
28
- if (Object.getOwnPropertySymbols) {
29
- var symbols = Object.getOwnPropertySymbols(object);
30
- enumerableOnly && (symbols = symbols.filter(function (sym) {
31
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
32
- })), keys.push.apply(keys, symbols);
25
+ function _arrayLikeToArray(r, a) {
26
+ (null == a || a > r.length) && (a = r.length);
27
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
28
+ return n;
29
+ }
30
+ function _arrayWithHoles(r) {
31
+ if (Array.isArray(r)) return r;
32
+ }
33
+ function _arrayWithoutHoles(r) {
34
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
35
+ }
36
+ function _defineProperty(e, r, t) {
37
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
38
+ value: t,
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0
42
+ }) : e[r] = t, e;
43
+ }
44
+ function _iterableToArray(r) {
45
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
46
+ }
47
+ function _iterableToArrayLimit(r, l) {
48
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
49
+ if (null != t) {
50
+ var e,
51
+ n,
52
+ i,
53
+ u,
54
+ a = [],
55
+ f = !0,
56
+ o = !1;
57
+ try {
58
+ if (i = (t = t.call(r)).next, 0 === l) {
59
+ if (Object(t) !== t) return;
60
+ f = !1;
61
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
62
+ } catch (r) {
63
+ o = !0, n = r;
64
+ } finally {
65
+ try {
66
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
67
+ } finally {
68
+ if (o) throw n;
69
+ }
70
+ }
71
+ return a;
33
72
  }
34
-
35
- return keys;
36
73
  }
37
-
38
- function _objectSpread2(target) {
39
- for (var i = 1; i < arguments.length; i++) {
40
- var source = null != arguments[i] ? arguments[i] : {};
41
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
42
- _defineProperty(target, key, source[key]);
43
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
44
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
45
- });
46
- }
47
-
48
- return target;
74
+ function _nonIterableRest() {
75
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
49
76
  }
50
-
51
- function _typeof(obj) {
52
- "@babel/helpers - typeof";
53
-
54
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
55
- return typeof obj;
56
- } : function (obj) {
57
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
58
- }, _typeof(obj);
77
+ function _nonIterableSpread() {
78
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
59
79
  }
60
-
61
- function _defineProperty(obj, key, value) {
62
- if (key in obj) {
63
- Object.defineProperty(obj, key, {
64
- value: value,
65
- enumerable: true,
66
- configurable: true,
67
- writable: true
68
- });
69
- } else {
70
- obj[key] = value;
80
+ function ownKeys(e, r) {
81
+ var t = Object.keys(e);
82
+ if (Object.getOwnPropertySymbols) {
83
+ var o = Object.getOwnPropertySymbols(e);
84
+ r && (o = o.filter(function (r) {
85
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
86
+ })), t.push.apply(t, o);
71
87
  }
72
-
73
- return obj;
74
- }
75
-
76
- function _objectWithoutPropertiesLoose(source, excluded) {
77
- if (source == null) return {};
78
- var target = {};
79
- var sourceKeys = Object.keys(source);
80
- var key, i;
81
-
82
- for (i = 0; i < sourceKeys.length; i++) {
83
- key = sourceKeys[i];
84
- if (excluded.indexOf(key) >= 0) continue;
85
- target[key] = source[key];
88
+ return t;
89
+ }
90
+ function _objectSpread2(e) {
91
+ for (var r = 1; r < arguments.length; r++) {
92
+ var t = null != arguments[r] ? arguments[r] : {};
93
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
94
+ _defineProperty(e, r, t[r]);
95
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
96
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
97
+ });
86
98
  }
87
-
88
- return target;
99
+ return e;
89
100
  }
90
-
91
- function _objectWithoutProperties(source, excluded) {
92
- if (source == null) return {};
93
-
94
- var target = _objectWithoutPropertiesLoose(source, excluded);
95
-
96
- var key, i;
97
-
101
+ function _objectWithoutProperties(e, t) {
102
+ if (null == e) return {};
103
+ var o,
104
+ r,
105
+ i = _objectWithoutPropertiesLoose(e, t);
98
106
  if (Object.getOwnPropertySymbols) {
99
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
100
-
101
- for (i = 0; i < sourceSymbolKeys.length; i++) {
102
- key = sourceSymbolKeys[i];
103
- if (excluded.indexOf(key) >= 0) continue;
104
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
105
- target[key] = source[key];
106
- }
107
+ var s = Object.getOwnPropertySymbols(e);
108
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
107
109
  }
108
-
109
- return target;
110
- }
111
-
112
- function _slicedToArray(arr, i) {
113
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
114
- }
115
-
116
- function _toConsumableArray(arr) {
117
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
110
+ return i;
111
+ }
112
+ function _objectWithoutPropertiesLoose(r, e) {
113
+ if (null == r) return {};
114
+ var t = {};
115
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
116
+ if (e.includes(n)) continue;
117
+ t[n] = r[n];
118
+ }
119
+ return t;
118
120
  }
119
-
120
- function _arrayWithoutHoles(arr) {
121
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
121
+ function _slicedToArray(r, e) {
122
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
122
123
  }
123
-
124
- function _arrayWithHoles(arr) {
125
- if (Array.isArray(arr)) return arr;
124
+ function _toConsumableArray(r) {
125
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
126
126
  }
127
-
128
- function _iterableToArray(iter) {
129
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
130
- }
131
-
132
- function _iterableToArrayLimit(arr, i) {
133
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
134
-
135
- if (_i == null) return;
136
- var _arr = [];
137
- var _n = true;
138
- var _d = false;
139
-
140
- var _s, _e;
141
-
142
- try {
143
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
144
- _arr.push(_s.value);
145
-
146
- if (i && _arr.length === i) break;
147
- }
148
- } catch (err) {
149
- _d = true;
150
- _e = err;
151
- } finally {
152
- try {
153
- if (!_n && _i["return"] != null) _i["return"]();
154
- } finally {
155
- if (_d) throw _e;
156
- }
127
+ function _toPrimitive(t, r) {
128
+ if ("object" != typeof t || !t) return t;
129
+ var e = t[Symbol.toPrimitive];
130
+ if (void 0 !== e) {
131
+ var i = e.call(t, r || "default");
132
+ if ("object" != typeof i) return i;
133
+ throw new TypeError("@@toPrimitive must return a primitive value.");
157
134
  }
158
-
159
- return _arr;
160
- }
161
-
162
- function _unsupportedIterableToArray(o, minLen) {
163
- if (!o) return;
164
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
165
- var n = Object.prototype.toString.call(o).slice(8, -1);
166
- if (n === "Object" && o.constructor) n = o.constructor.name;
167
- if (n === "Map" || n === "Set") return Array.from(o);
168
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
169
- }
170
-
171
- function _arrayLikeToArray(arr, len) {
172
- if (len == null || len > arr.length) len = arr.length;
173
-
174
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
175
-
176
- return arr2;
135
+ return ("string" === r ? String : Number)(t);
177
136
  }
178
-
179
- function _nonIterableSpread() {
180
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
137
+ function _toPropertyKey(t) {
138
+ var i = _toPrimitive(t, "string");
139
+ return "symbol" == typeof i ? i : i + "";
181
140
  }
141
+ function _typeof(o) {
142
+ "@babel/helpers - typeof";
182
143
 
183
- function _nonIterableRest() {
184
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
144
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
145
+ return typeof o;
146
+ } : function (o) {
147
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
148
+ }, _typeof(o);
149
+ }
150
+ function _unsupportedIterableToArray(r, a) {
151
+ if (r) {
152
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
153
+ var t = {}.toString.call(r).slice(8, -1);
154
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
155
+ }
185
156
  }
186
157
 
187
158
  var _excluded$1 = ["prices"];
188
-
189
159
  function applyOnBeforeDiff(before, now, fn) {
190
160
  return fn && typeof fn === 'function' ? fn(before, now) : [before, now];
191
161
  }
192
-
193
162
  var createPriceComparator = function createPriceComparator(price) {
194
163
  return {
195
164
  value: {
@@ -202,13 +171,11 @@ var createPriceComparator = function createPriceComparator(price) {
202
171
  validUntil: price.validUntil
203
172
  };
204
173
  };
205
-
206
174
  function arePricesStructurallyEqual(oldPrice, newPrice) {
207
175
  var oldPriceComparison = createPriceComparator(oldPrice);
208
176
  var newPriceComparison = createPriceComparator(newPrice);
209
177
  return isEqual__default["default"](newPriceComparison, oldPriceComparison);
210
178
  }
211
-
212
179
  function extractPriceFromPreviousVariant(newPrice, previousVariant) {
213
180
  if (!previousVariant) return null;
214
181
  var price = previousVariant.prices.find(function (oldPrice) {
@@ -216,12 +183,10 @@ function extractPriceFromPreviousVariant(newPrice, previousVariant) {
216
183
  });
217
184
  return price || null;
218
185
  }
219
-
220
186
  function injectMissingPriceIds(nextVariants, previousVariants) {
221
187
  return nextVariants.map(function (newVariant) {
222
188
  var prices = newVariant.prices,
223
- restOfVariant = _objectWithoutProperties(newVariant, _excluded$1);
224
-
189
+ restOfVariant = _objectWithoutProperties(newVariant, _excluded$1);
225
190
  if (!prices) return restOfVariant;
226
191
  var oldVariant = previousVariants.find(function (previousVariant) {
227
192
  return !isNil__default["default"](previousVariant.id) && previousVariant.id === newVariant.id || !isNil__default["default"](previousVariant.key) && previousVariant.key === newVariant.key || !isNil__default["default"](previousVariant.sku) && previousVariant.sku === newVariant.sku;
@@ -229,33 +194,27 @@ function injectMissingPriceIds(nextVariants, previousVariants) {
229
194
  return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
230
195
  prices: prices.map(function (price) {
231
196
  var newPrice = _objectSpread2({}, price);
232
-
233
197
  var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
234
-
235
198
  if (oldPrice) {
236
199
  // copy ID if not provided
237
200
  if (!newPrice.id) newPrice.id = oldPrice.id;
238
201
  if (isNil__default["default"](newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
239
202
  if (isNil__default["default"](newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
240
203
  }
241
-
242
204
  return newPrice;
243
205
  })
244
206
  });
245
207
  });
246
208
  }
247
-
248
209
  function createBuildActions(differ, doMapActions, onBeforeDiff) {
249
210
  var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
250
211
  return function buildActions(now, before) {
251
212
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
252
213
  if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
253
-
254
214
  var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
255
- _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
256
- processedBefore = _applyOnBeforeDiff2[0],
257
- processedNow = _applyOnBeforeDiff2[1];
258
-
215
+ _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
216
+ processedBefore = _applyOnBeforeDiff2[0],
217
+ processedNow = _applyOnBeforeDiff2[1];
259
218
  if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
260
219
  var diffed = differ(processedBefore, processedNow);
261
220
  if (!buildActionsConfig.withHints && !diffed) return [];
@@ -277,10 +236,11 @@ function createMapActionGroup() {
277
236
  var found = actionGroups.find(function (c) {
278
237
  return c.type === type;
279
238
  });
280
- if (!found) return []; // Keep `black` for backwards compatibility.
281
-
282
- if (found.group === 'ignore' || found.group === 'black') return []; // Keep `white` for backwards compatibility.
239
+ if (!found) return [];
283
240
 
241
+ // Keep `black` for backwards compatibility.
242
+ if (found.group === 'ignore' || found.group === 'black') return [];
243
+ // Keep `white` for backwards compatibility.
284
244
  if (found.group === 'allow' || found.group === 'white') return fn();
285
245
  throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
286
246
  };
@@ -290,7 +250,6 @@ function createMapActionGroup() {
290
250
  // with es6 modules so we use require instead below
291
251
  // TODO create an issue here https://github.com/benjamine/jsondiffpatch/issues/new
292
252
  var DiffPatcher = require('jsondiffpatch').DiffPatcher;
293
-
294
253
  function objectHash(obj, index) {
295
254
  var objIndex = "$$index:".concat(index);
296
255
  return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
@@ -330,12 +289,12 @@ function getDeltaValue(arr, originalObject) {
330
289
 
331
290
  if (arr.length === 3 && arr[2] === 2) {
332
291
  // text diff
333
- if (!originalObject) throw new Error('Cannot apply patch to long text diff. Missing original object.'); // try to apply patch to given object based on delta value
334
-
292
+ if (!originalObject) throw new Error('Cannot apply patch to long text diff. Missing original object.');
293
+ // try to apply patch to given object based on delta value
335
294
  return patch(originalObject, arr);
336
295
  }
337
-
338
- if (arr.length === 3 && arr[2] === 3) // array move
296
+ if (arr.length === 3 && arr[2] === 3)
297
+ // array move
339
298
  throw new Error('Detected an array move, it should not happen as ' + '`includeValueOnMove` should be set to false');
340
299
  throw new Error("Got unsupported number ".concat(arr[2], " in delta value"));
341
300
  }
@@ -345,52 +304,39 @@ var Actions = {
345
304
  setCustomType: 'setCustomType',
346
305
  setCustomField: 'setCustomField'
347
306
  };
348
-
349
307
  var hasSingleCustomFieldChanged = function hasSingleCustomFieldChanged(diff) {
350
308
  return Array.isArray(diff.custom);
351
309
  };
352
-
353
310
  var haveMultipleCustomFieldsChanged = function haveMultipleCustomFieldsChanged(diff) {
354
311
  return Boolean(diff.custom.fields);
355
312
  };
356
-
357
313
  var hasCustomTypeChanged = function hasCustomTypeChanged(diff) {
358
314
  return Boolean(diff.custom.type);
359
315
  };
360
-
361
316
  var extractCustomType = function extractCustomType(diff, previousObject) {
362
317
  return Array.isArray(diff.custom.type) ? getDeltaValue(diff.custom.type, previousObject) : diff.custom.type;
363
318
  };
364
-
365
319
  var extractTypeId = function extractTypeId(type, nextObject) {
366
320
  return Array.isArray(type.id) ? getDeltaValue(type.id) : nextObject.custom.type.id;
367
321
  };
368
-
369
322
  var extractTypeKey = function extractTypeKey(type, nextObject) {
370
323
  return Array.isArray(type.key) ? getDeltaValue(type.key) : nextObject.custom.type.key;
371
324
  };
372
-
373
325
  var extractTypeFields = function extractTypeFields(diffedFields, nextFields) {
374
326
  return Array.isArray(diffedFields) ? getDeltaValue(diffedFields) : nextFields;
375
327
  };
376
-
377
328
  var extractFieldValue = function extractFieldValue(newFields, fieldName) {
378
329
  return newFields[fieldName];
379
330
  };
380
-
381
331
  function actionsMapCustom(diff, newObj, oldObj) {
382
332
  var customProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
383
333
  actions: {}
384
334
  };
385
335
  var actions = [];
386
-
387
336
  var customPropsActions = customProps.actions,
388
- options = _objectWithoutProperties(customProps, _excluded);
389
-
337
+ options = _objectWithoutProperties(customProps, _excluded);
390
338
  var actionGroup = _objectSpread2(_objectSpread2({}, Actions), customPropsActions);
391
-
392
339
  if (!diff.custom) return actions;
393
-
394
340
  if (hasSingleCustomFieldChanged(diff)) {
395
341
  // If custom is not defined on the new or old category
396
342
  var custom = getDeltaValue(diff.custom, oldObj);
@@ -430,7 +376,6 @@ function actionsMapCustom(diff, newObj, oldObj) {
430
376
  });
431
377
  actions.push.apply(actions, _toConsumableArray(customFieldsActions));
432
378
  }
433
-
434
379
  return actions;
435
380
  }
436
381
 
@@ -439,6 +384,7 @@ var REGEX_UNDERSCORE_NUMBER$4 = new RegExp(/^_\d+$/);
439
384
  var ADD_ACTIONS = 'create';
440
385
  var REMOVE_ACTIONS = 'remove';
441
386
  var CHANGE_ACTIONS = 'change';
387
+
442
388
  /**
443
389
  * Tests a delta to see if it represents a create action.
444
390
  * eg. delta:
@@ -451,10 +397,10 @@ var CHANGE_ACTIONS = 'change';
451
397
  * @return {Boolean} Returns true if delta represents a create action,
452
398
  * false otherwise
453
399
  */
454
-
455
400
  function isCreateAction(obj, key) {
456
401
  return REGEX_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 1;
457
402
  }
403
+
458
404
  /**
459
405
  * Tests a delta to see if it represents a change action.
460
406
  * eg. delta:
@@ -469,11 +415,10 @@ function isCreateAction(obj, key) {
469
415
  * @return {Boolean} Returns true if delta represents a change action,
470
416
  * false otherwise
471
417
  */
472
-
473
-
474
418
  function isChangeAction(obj, key) {
475
419
  return REGEX_NUMBER$4.test(key) && (_typeof(obj[key]) === 'object' || typeof obj[key] === 'string');
476
420
  }
421
+
477
422
  /**
478
423
  * Tests a delta to see if it represents a remove action.
479
424
  * eg. delta:
@@ -486,11 +431,10 @@ function isChangeAction(obj, key) {
486
431
  * @return {Boolean} Returns true if delta represents a remove action,
487
432
  * false otherwise
488
433
  */
489
-
490
-
491
434
  function isRemoveAction$1(obj, key) {
492
435
  return REGEX_UNDERSCORE_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 3 && (_typeof(obj[key][0]) === 'object' || typeof obj[key][0] === 'string') && obj[key][1] === 0 && obj[key][2] === 0;
493
436
  }
437
+
494
438
  /**
495
439
  * Generate + configure a function to build actions for nested objects
496
440
  * @param {string} key key of the attribute containing the array of
@@ -501,39 +445,33 @@ function isRemoveAction$1(obj, key) {
501
445
  * return an action object.
502
446
  * @return {Array} The generated array of actions
503
447
  */
504
-
505
-
506
448
  function createBuildArrayActions(key, config) {
507
449
  return function buildArrayActions(diff, oldObj, newObj) {
508
450
  var addActions = [];
509
451
  var removeActions = [];
510
452
  var changeActions = [];
511
-
512
453
  if (diff[key]) {
513
454
  var arrayDelta = diff[key];
514
455
  Object.keys(arrayDelta).forEach(function (index) {
515
456
  if (config[ADD_ACTIONS] && isCreateAction(arrayDelta, index)) {
516
- var actionGenerator = config[ADD_ACTIONS]; // When adding a new element you don't need the oldObj
517
-
457
+ var actionGenerator = config[ADD_ACTIONS];
458
+ // When adding a new element you don't need the oldObj
518
459
  var action = actionGenerator(newObj[key][index], parseInt(index, 10));
519
460
  if (action) addActions.push(action);
520
461
  } else if (config[CHANGE_ACTIONS] && isChangeAction(arrayDelta, index)) {
521
- var _actionGenerator = config[CHANGE_ACTIONS]; // When changing an existing element you need both old + new
522
-
462
+ var _actionGenerator = config[CHANGE_ACTIONS];
463
+ // When changing an existing element you need both old + new
523
464
  var _action = _actionGenerator(oldObj[key][index], newObj[key][index], parseInt(index, 10));
524
-
525
465
  if (_action) changeActions.push(_action);
526
466
  } else if (config[REMOVE_ACTIONS] && isRemoveAction$1(arrayDelta, index)) {
527
467
  var realIndex = index.replace('_', '');
528
- var _actionGenerator2 = config[REMOVE_ACTIONS]; // When removing an existing element you don't need the newObj
529
-
468
+ var _actionGenerator2 = config[REMOVE_ACTIONS];
469
+ // When removing an existing element you don't need the newObj
530
470
  var _action2 = _actionGenerator2(oldObj[key][realIndex], parseInt(realIndex, 10));
531
-
532
471
  if (_action2) removeActions.push(_action2);
533
472
  }
534
473
  });
535
474
  }
536
-
537
475
  return changeActions.concat(removeActions, addActions);
538
476
  };
539
477
  }
@@ -546,21 +484,19 @@ function toAssetIdentifier$1(asset) {
546
484
  };
547
485
  return assetIdentifier;
548
486
  }
549
-
550
487
  function actionsMapAssets$1(diff, oldObj, newObj) {
551
- var _createBuildArrayActi;
552
-
553
- var handler = createBuildArrayActions('assets', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAsset) {
488
+ var handler = createBuildArrayActions('assets', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAsset) {
554
489
  return {
555
490
  action: 'addAsset',
556
491
  asset: newAsset
557
492
  };
558
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAsset) {
493
+ }), REMOVE_ACTIONS, function (oldAsset) {
559
494
  return _objectSpread2({
560
495
  action: 'removeAsset'
561
496
  }, toAssetIdentifier$1(oldAsset));
562
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAsset, newAsset) {
563
- return (// here we could use more atomic update actions (e.g. changeAssetName)
497
+ }), CHANGE_ACTIONS, function (oldAsset, newAsset) {
498
+ return (
499
+ // here we could use more atomic update actions (e.g. changeAssetName)
564
500
  // but for now we use the simpler approach to first remove and then
565
501
  // re-add the asset - which reduces the code complexity
566
502
  [_objectSpread2({
@@ -570,7 +506,7 @@ function actionsMapAssets$1(diff, oldObj, newObj) {
570
506
  asset: newAsset
571
507
  }]
572
508
  );
573
- }), _createBuildArrayActi));
509
+ }));
574
510
  return handler(diff, oldObj, newObj);
575
511
  }
576
512
 
@@ -581,7 +517,6 @@ function clone(obj) {
581
517
  var normalizeValue = function normalizeValue(value) {
582
518
  return typeof value === 'string' ? value.trim() : value;
583
519
  };
584
-
585
520
  var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
586
521
  return function (value) {
587
522
  return emptyValues.some(function (emptyValue) {
@@ -589,6 +524,7 @@ var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
589
524
  });
590
525
  };
591
526
  };
527
+
592
528
  /**
593
529
  * Builds actions for simple object properties, given a list of actions
594
530
  * E.g. [{ action: `changeName`, key: 'name' }]
@@ -600,17 +536,15 @@ var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
600
536
  * @param {Object} options.newObj - the new representation of the object
601
537
  * @param {Boolean} options.shouldOmitEmptyString - a flag to determine if we should treat an empty string a NON-value
602
538
  */
603
-
604
539
  function buildBaseAttributesActions(_ref) {
605
540
  var actions = _ref.actions,
606
- diff = _ref.diff,
607
- oldObj = _ref.oldObj,
608
- newObj = _ref.newObj,
609
- shouldOmitEmptyString = _ref.shouldOmitEmptyString;
541
+ diff = _ref.diff,
542
+ oldObj = _ref.oldObj,
543
+ newObj = _ref.newObj,
544
+ shouldOmitEmptyString = _ref.shouldOmitEmptyString;
610
545
  var isEmptyValue = createIsEmptyValue(shouldOmitEmptyString ? [undefined, null, ''] : [undefined, null]);
611
546
  return actions.map(function (item) {
612
547
  var key = item.key; // e.g.: name, description, ...
613
-
614
548
  var actionKey = item.actionKey || item.key;
615
549
  var delta = diff[key];
616
550
  var before = oldObj[key];
@@ -619,18 +553,21 @@ function buildBaseAttributesActions(_ref) {
619
553
  var isNotDefinedNow = isEmptyValue(newObj[key]);
620
554
  if (!delta) return undefined;
621
555
  if (isNotDefinedNow && isNotDefinedBefore) return undefined;
622
- if (!isNotDefinedNow && isNotDefinedBefore) // no value previously set
556
+ if (!isNotDefinedNow && isNotDefinedBefore)
557
+ // no value previously set
623
558
  return _defineProperty({
624
559
  action: item.action
625
560
  }, actionKey, now);
626
- /* no new value */
627
561
 
562
+ /* no new value */
628
563
  if (isNotDefinedNow && !{}.hasOwnProperty.call(newObj, key)) return undefined;
629
- if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key)) // value unset
564
+ if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key))
565
+ // value unset
630
566
  return {
631
567
  action: item.action
632
- }; // We need to clone `before` as `patch` will mutate it
568
+ };
633
569
 
570
+ // We need to clone `before` as `patch` will mutate it
634
571
  var patched = patch(clone(before), delta);
635
572
  return _defineProperty({
636
573
  action: item.action
@@ -639,6 +576,7 @@ function buildBaseAttributesActions(_ref) {
639
576
  return !isNil__default["default"](action);
640
577
  });
641
578
  }
579
+
642
580
  /**
643
581
  * Builds actions for simple reference objects, given a list of actions
644
582
  * E.g. [{ action: `setTaxCategory`, key: 'taxCategory' }]
@@ -649,23 +587,24 @@ function buildBaseAttributesActions(_ref) {
649
587
  * @param {Object} options.oldObj - the object that needs to be updated
650
588
  * @param {Object} options.newObj - the new representation of the object
651
589
  */
652
-
653
590
  function buildReferenceActions(_ref4) {
654
591
  var actions = _ref4.actions,
655
- diff = _ref4.diff,
656
- newObj = _ref4.newObj;
592
+ diff = _ref4.diff,
593
+ newObj = _ref4.newObj;
657
594
  return actions.map(function (item) {
658
595
  var action = item.action;
659
596
  var key = item.key;
660
-
661
- if (diff[key] && ( // The `key` value was added or removed
662
- Array.isArray(diff[key]) || // The `key` value id changed
597
+ if (diff[key] && (
598
+ // The `key` value was added or removed
599
+ Array.isArray(diff[key]) ||
600
+ // The `key` value id changed
663
601
  diff[key].id)) {
664
602
  var newValue = Array.isArray(diff[key]) ? getDeltaValue(diff[key]) : newObj[key];
665
603
  if (!newValue) return {
666
604
  action: action
667
- }; // When the `id` of the object is undefined
605
+ };
668
606
 
607
+ // When the `id` of the object is undefined
669
608
  if (!newValue.id) {
670
609
  return _defineProperty({
671
610
  action: action
@@ -674,7 +613,6 @@ function buildReferenceActions(_ref4) {
674
613
  key: newValue.key
675
614
  });
676
615
  }
677
-
678
616
  return _defineProperty({
679
617
  action: action
680
618
  }, key, {
@@ -682,7 +620,6 @@ function buildReferenceActions(_ref4) {
682
620
  id: newValue.id
683
621
  });
684
622
  }
685
-
686
623
  return undefined;
687
624
  }).filter(function (action) {
688
625
  return action;
@@ -722,6 +659,7 @@ var referenceActionsList$3 = [{
722
659
  action: 'changeParent',
723
660
  key: 'parent'
724
661
  }];
662
+
725
663
  /**
726
664
  * SYNC FUNCTIONS
727
665
  */
@@ -754,6 +692,7 @@ function actionsMapMeta$1(diff, oldObj, newObj) {
754
692
  }
755
693
 
756
694
  var CUSTOM = 'custom';
695
+
757
696
  /**
758
697
  * @function copyEmptyArrayProps
759
698
  * @description Create new key with empty array value on `newobj` for the arrays exist on `oldObj` and doesnt exist on `newobj`
@@ -762,74 +701,60 @@ var CUSTOM = 'custom';
762
701
  * @param {Object} newObj
763
702
  * @returns {Array} Ordered Array [oldObj, newObj]
764
703
  */
765
-
766
704
  function copyEmptyArrayProps() {
767
705
  var oldObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
768
706
  var newObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
769
-
770
707
  if (!isNil__default["default"](oldObj) && !isNil__default["default"](newObj)) {
771
708
  var nextObjectWithEmptyArray = Object.entries(oldObj).reduce(function (merged, _ref) {
772
709
  var _ref2 = _slicedToArray(_ref, 2),
773
- key = _ref2[0],
774
- value = _ref2[1];
775
-
710
+ key = _ref2[0],
711
+ value = _ref2[1];
776
712
  // Ignore CUSTOM key as this object is dynamic and its up to the user to dynamically change it
777
713
  // todo, it would be better if we pass it as ignored keys param
778
714
  if (key === CUSTOM) return merged;
779
-
780
715
  if (Array.isArray(value) && newObj[key] && newObj[key].length >= 1) {
781
716
  /* eslint-disable no-plusplus */
782
717
  var hashMapValue = value.reduce(function (acc, val) {
783
718
  acc[val.id] = val;
784
719
  return acc;
785
720
  }, {});
786
-
787
721
  for (var i = 0; i < newObj[key].length; i++) {
788
722
  if (!isNil__default["default"](newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil__default["default"](newObj[key][i].id)) {
789
723
  // Since its unordered array elements then check if the element on `oldObj` exists by id
790
724
  var foundObject = hashMapValue[newObj[key][i].id];
791
-
792
725
  if (!isNil__default["default"](foundObject)) {
793
726
  var _copyEmptyArrayProps = copyEmptyArrayProps(foundObject, newObj[key][i]),
794
- _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
795
- nestedObject = _copyEmptyArrayProps2[1];
796
-
727
+ _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
728
+ nestedObject = _copyEmptyArrayProps2[1];
797
729
  if (Object.isFrozen(merged[key])) {
798
730
  /* eslint-disable no-param-reassign */
799
731
  merged[key] = merged[key].slice();
800
732
  }
801
733
  /* eslint-disable no-param-reassign */
802
-
803
-
804
734
  merged[key][i] = nestedObject;
805
735
  }
806
736
  }
807
737
  }
808
-
809
738
  return merged;
810
739
  }
811
-
812
740
  if (Array.isArray(value)) {
813
741
  merged[key] = isNil__default["default"](newObj[key]) ? [] : newObj[key];
814
742
  return merged;
815
743
  }
816
-
817
- if (!isNil__default["default"](newObj[key]) && _typeof(value) === 'object' && // Ignore Date as this will create invalid object since typeof date === 'object' return true
744
+ if (!isNil__default["default"](newObj[key]) && _typeof(value) === 'object' &&
745
+ // Ignore Date as this will create invalid object since typeof date === 'object' return true
818
746
  // ex: {date: new Date()} will result {date: {}}
819
747
  !(value instanceof Date)) {
820
748
  var _copyEmptyArrayProps3 = copyEmptyArrayProps(value, newObj[key]),
821
- _copyEmptyArrayProps4 = _slicedToArray(_copyEmptyArrayProps3, 2),
822
- _nestedObject = _copyEmptyArrayProps4[1];
823
-
749
+ _copyEmptyArrayProps4 = _slicedToArray(_copyEmptyArrayProps3, 2),
750
+ _nestedObject = _copyEmptyArrayProps4[1];
824
751
  merged[key] = _nestedObject;
825
752
  return merged;
826
753
  }
827
-
828
754
  return merged;
829
755
  }, _objectSpread2({}, newObj));
830
756
  return [oldObj, nextObjectWithEmptyArray];
831
757
  }
832
-
833
758
  return [oldObj, newObj];
834
759
  }
835
760
 
@@ -854,14 +779,15 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
854
779
  return flatten__default["default"](allActions);
855
780
  };
856
781
  }
857
-
858
782
  var categories = (function (actionGroupList, syncActionConfig) {
859
783
  // actionGroupList contains information about which action groups
860
784
  // are allowed or ignored
785
+
861
786
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
862
787
  // - action group name
863
788
  // - callback function that should return a list of actions that correspond
864
789
  // to the for the action group
790
+
865
791
  // this resulting function mapActionGroup will call the callback function
866
792
  // for allowed action groups and return the return value of the callback
867
793
  // It will return an empty array for ignored action groups
@@ -935,6 +861,7 @@ var authenticationModeActionsList = [{
935
861
  key: 'authenticationMode',
936
862
  value: 'password'
937
863
  }];
864
+
938
865
  /**
939
866
  * SYNC FUNCTIONS
940
867
  */
@@ -968,57 +895,51 @@ function actionsMapReferences$2(diff, oldObj, newObj) {
968
895
  });
969
896
  }
970
897
  function actionsMapAddresses(diff, oldObj, newObj) {
971
- var _createBuildArrayActi;
972
-
973
- var handler = createBuildArrayActions('addresses', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newObject) {
898
+ var handler = createBuildArrayActions('addresses', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
974
899
  return {
975
900
  action: 'addAddress',
976
901
  address: newObject
977
902
  };
978
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (objectToRemove) {
903
+ }), REMOVE_ACTIONS, function (objectToRemove) {
979
904
  return {
980
905
  action: 'removeAddress',
981
906
  addressId: objectToRemove.id
982
907
  };
983
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldObject, updatedObject) {
908
+ }), CHANGE_ACTIONS, function (oldObject, updatedObject) {
984
909
  return {
985
910
  action: 'changeAddress',
986
911
  addressId: oldObject.id,
987
912
  address: updatedObject
988
913
  };
989
- }), _createBuildArrayActi));
914
+ }));
990
915
  return handler(diff, oldObj, newObj);
991
916
  }
992
917
  function actionsMapBillingAddresses(diff, oldObj, newObj) {
993
- var _createBuildArrayActi2;
994
-
995
- var handler = createBuildArrayActions('billingAddressIds', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (addressId) {
918
+ var handler = createBuildArrayActions('billingAddressIds', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (addressId) {
996
919
  return {
997
920
  action: 'addBillingAddressId',
998
921
  addressId: addressId
999
922
  };
1000
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (addressId) {
923
+ }), REMOVE_ACTIONS, function (addressId) {
1001
924
  return {
1002
925
  action: 'removeBillingAddressId',
1003
926
  addressId: addressId
1004
927
  };
1005
- }), _createBuildArrayActi2));
928
+ }));
1006
929
  return handler(diff, oldObj, newObj);
1007
930
  }
1008
931
  function actionsMapShippingAddresses(diff, oldObj, newObj) {
1009
- var _createBuildArrayActi3;
1010
-
1011
- var handler = createBuildArrayActions('shippingAddressIds', (_createBuildArrayActi3 = {}, _defineProperty(_createBuildArrayActi3, ADD_ACTIONS, function (addressId) {
932
+ var handler = createBuildArrayActions('shippingAddressIds', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (addressId) {
1012
933
  return {
1013
934
  action: 'addShippingAddressId',
1014
935
  addressId: addressId
1015
936
  };
1016
- }), _defineProperty(_createBuildArrayActi3, REMOVE_ACTIONS, function (addressId) {
937
+ }), REMOVE_ACTIONS, function (addressId) {
1017
938
  return {
1018
939
  action: 'removeShippingAddressId',
1019
940
  addressId: addressId
1020
941
  };
1021
- }), _createBuildArrayActi3));
942
+ }));
1022
943
  return handler(diff, oldObj, newObj);
1023
944
  }
1024
945
  function actionsMapAuthenticationModes(diff, oldObj, newObj) {
@@ -1030,12 +951,11 @@ function actionsMapAuthenticationModes(diff, oldObj, newObj) {
1030
951
  newObj: newObj
1031
952
  });
1032
953
  }
1033
-
1034
954
  function buildAuthenticationModeActions(_ref) {
1035
955
  var actions = _ref.actions,
1036
- diff = _ref.diff,
1037
- oldObj = _ref.oldObj,
1038
- newObj = _ref.newObj;
956
+ diff = _ref.diff,
957
+ oldObj = _ref.oldObj,
958
+ newObj = _ref.newObj;
1039
959
  return actions.map(function (item) {
1040
960
  var key = item.key;
1041
961
  var value = item.value || item.key;
@@ -1049,7 +969,6 @@ function buildAuthenticationModeActions(_ref) {
1049
969
  if (isNotDefinedNow && isNotDefinedBefore) return undefined;
1050
970
  if (newObj.authenticationMode === 'Password' && !newObj.password) throw new Error('Cannot set to Password authentication mode without password');
1051
971
  if ('authenticationMode' in newObj && !authenticationModes.includes(newObj.authenticationMode)) throw new Error('Invalid Authentication Mode');
1052
-
1053
972
  if (!isNotDefinedNow && isNotDefinedBefore) {
1054
973
  // no value previously set
1055
974
  if (newObj.authenticationMode === 'ExternalAuth') return {
@@ -1061,13 +980,14 @@ function buildAuthenticationModeActions(_ref) {
1061
980
  authMode: now
1062
981
  }, value, newObj.password);
1063
982
  }
1064
- /* no new value */
1065
-
1066
983
 
984
+ /* no new value */
1067
985
  if (isNotDefinedNow && !{}.hasOwnProperty.call(newObj, key)) return undefined;
1068
- if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key)) // value unset
1069
- return undefined; // We need to clone `before` as `patch` will mutate it
986
+ if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key))
987
+ // value unset
988
+ return undefined;
1070
989
 
990
+ // We need to clone `before` as `patch` will mutate it
1071
991
  var patched = patch(clone(before), delta);
1072
992
  if (newObj.authenticationMode === 'ExternalAuth') return {
1073
993
  action: item.action,
@@ -1112,14 +1032,15 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
1112
1032
  return flatten__default["default"](allActions);
1113
1033
  };
1114
1034
  }
1115
-
1116
1035
  var customers = (function (actionGroupList, syncActionConfig) {
1117
1036
  // actionGroupList contains information about which action groups
1118
1037
  // are allowed or ignored
1038
+
1119
1039
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
1120
1040
  // - action group name
1121
1041
  // - callback function that should return a list of actions that correspond
1122
1042
  // to the for the action group
1043
+
1123
1044
  // this resulting function mapActionGroup will call the callback function
1124
1045
  // for allowed action groups and return the return value of the callback
1125
1046
  // It will return an empty array for ignored action groups
@@ -1146,6 +1067,7 @@ var referenceActionsList$1 = [{
1146
1067
  action: 'setSupplyChannel',
1147
1068
  key: 'supplyChannel'
1148
1069
  }];
1070
+
1149
1071
  /**
1150
1072
  * SYNC FUNCTIONS
1151
1073
  */
@@ -1184,14 +1106,15 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
1184
1106
  return flatten__default["default"](allActions);
1185
1107
  };
1186
1108
  }
1187
-
1188
1109
  var inventories = (function (actionGroupList, syncActionConfig) {
1189
1110
  // actionGroupList contains information about which action groups
1190
1111
  // are allowed or ignored
1112
+
1191
1113
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
1192
1114
  // - action group name
1193
1115
  // - callback function that should return a list of actions that correspond
1194
1116
  // to the for the action group
1117
+
1195
1118
  // this resulting function mapActionGroup will call the callback function
1196
1119
  // for allowed action groups and return the return value of the callback
1197
1120
  // It will return an empty array for ignored action groups
@@ -1208,14 +1131,12 @@ function extractMatchingPairs(hashMap, key, before, now) {
1208
1131
  var newObjPos;
1209
1132
  var oldObj;
1210
1133
  var newObj;
1211
-
1212
1134
  if (hashMap[key]) {
1213
1135
  oldObjPos = hashMap[key][0];
1214
1136
  newObjPos = hashMap[key][1];
1215
1137
  if (before && before[oldObjPos]) oldObj = before[oldObjPos];
1216
1138
  if (now && now[newObjPos]) newObj = now[newObjPos];
1217
1139
  }
1218
-
1219
1140
  return {
1220
1141
  oldObj: oldObj,
1221
1142
  newObj: newObj
@@ -1224,7 +1145,6 @@ function extractMatchingPairs(hashMap, key, before, now) {
1224
1145
 
1225
1146
  var REGEX_NUMBER$3 = new RegExp(/^\d+$/);
1226
1147
  var REGEX_UNDERSCORE_NUMBER$3 = new RegExp(/^_\d+$/);
1227
-
1228
1148
  function preProcessCollection() {
1229
1149
  var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1230
1150
  var identifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
@@ -1236,23 +1156,20 @@ function preProcessCollection() {
1236
1156
  refByIndex: {},
1237
1157
  refByIdentifier: {}
1238
1158
  });
1239
- } // creates a hash of a location of an item in collection1 and collection2
1240
-
1159
+ }
1241
1160
 
1161
+ // creates a hash of a location of an item in collection1 and collection2
1242
1162
  function findMatchingPairs(diff) {
1243
1163
  var before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1244
1164
  var now = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
1245
1165
  var identifier = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'id';
1246
1166
  var result = {};
1247
-
1248
1167
  var _preProcessCollection = preProcessCollection(before, identifier),
1249
- beforeObjRefByIdentifier = _preProcessCollection.refByIdentifier,
1250
- beforeObjRefByIndex = _preProcessCollection.refByIndex;
1251
-
1168
+ beforeObjRefByIdentifier = _preProcessCollection.refByIdentifier,
1169
+ beforeObjRefByIndex = _preProcessCollection.refByIndex;
1252
1170
  var _preProcessCollection2 = preProcessCollection(now, identifier),
1253
- nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
1254
- nowObjRefByIndex = _preProcessCollection2.refByIndex;
1255
-
1171
+ nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
1172
+ nowObjRefByIndex = _preProcessCollection2.refByIndex;
1256
1173
  forEach__default["default"](diff, function (item, key) {
1257
1174
  if (REGEX_NUMBER$3.test(key)) {
1258
1175
  var matchingIdentifier = nowObjRefByIndex[key];
@@ -1321,6 +1238,7 @@ var referenceActionsList = [{
1321
1238
  action: 'transitionState',
1322
1239
  key: 'state'
1323
1240
  }];
1241
+
1324
1242
  /**
1325
1243
  * HELPER FUNCTIONS
1326
1244
  */
@@ -1328,19 +1246,15 @@ var referenceActionsList = [{
1328
1246
  var getIsAddAction = function getIsAddAction(key, resource) {
1329
1247
  return REGEX_NUMBER$2.test(key) && Array.isArray(resource) && resource.length;
1330
1248
  };
1331
-
1332
1249
  var getIsUpdateAction = function getIsUpdateAction(key, resource) {
1333
1250
  return REGEX_NUMBER$2.test(key) && Object.keys(resource).length;
1334
1251
  };
1335
-
1336
1252
  var getIsRemoveAction = function getIsRemoveAction(key, resource) {
1337
1253
  return REGEX_UNDERSCORE_NUMBER$2.test(key) && Number(resource[2]) === 0;
1338
1254
  };
1339
-
1340
1255
  var getIsItemMovedAction = function getIsItemMovedAction(key, resource) {
1341
1256
  return REGEX_UNDERSCORE_NUMBER$2.test(key) && Number(resource[2]) === 3;
1342
1257
  };
1343
-
1344
1258
  function _buildSkuActions(variantDiff, oldVariant) {
1345
1259
  if ({}.hasOwnProperty.call(variantDiff, 'sku')) {
1346
1260
  var newValue = getDeltaValue(variantDiff.sku);
@@ -1351,10 +1265,8 @@ function _buildSkuActions(variantDiff, oldVariant) {
1351
1265
  sku: newValue || null
1352
1266
  };
1353
1267
  }
1354
-
1355
1268
  return null;
1356
1269
  }
1357
-
1358
1270
  function _buildKeyActions(variantDiff, oldVariant) {
1359
1271
  if ({}.hasOwnProperty.call(variantDiff, 'key')) {
1360
1272
  var newValue = getDeltaValue(variantDiff.key);
@@ -1365,10 +1277,8 @@ function _buildKeyActions(variantDiff, oldVariant) {
1365
1277
  key: newValue || null
1366
1278
  };
1367
1279
  }
1368
-
1369
1280
  return null;
1370
1281
  }
1371
-
1372
1282
  function _buildNewSetAttributeAction(id, el, sameForAllAttributeNames) {
1373
1283
  var attributeName = el && el.name;
1374
1284
  if (!attributeName) return undefined;
@@ -1378,47 +1288,47 @@ function _buildNewSetAttributeAction(id, el, sameForAllAttributeNames) {
1378
1288
  name: attributeName,
1379
1289
  value: el.value
1380
1290
  };
1381
-
1382
1291
  if (sameForAllAttributeNames.indexOf(attributeName) !== -1) {
1383
1292
  action = _objectSpread2(_objectSpread2({}, action), {}, {
1384
1293
  action: 'setAttributeInAllVariants'
1385
1294
  });
1386
1295
  delete action.variantId;
1387
1296
  }
1388
-
1389
1297
  return action;
1390
1298
  }
1391
-
1392
1299
  function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAllAttributeNames) {
1393
1300
  if (!attribute) return undefined;
1394
1301
  var action = {
1395
1302
  action: 'setAttribute',
1396
1303
  variantId: oldVariant.id,
1397
1304
  name: attribute.name
1398
- }; // Used as original object for patching long diff text
1305
+ };
1399
1306
 
1307
+ // Used as original object for patching long diff text
1400
1308
  var oldAttribute = oldVariant.attributes.find(function (a) {
1401
1309
  return a.name === attribute.name;
1402
1310
  }) || {};
1403
-
1404
1311
  if (sameForAllAttributeNames.indexOf(attribute.name) !== -1) {
1405
1312
  action = _objectSpread2(_objectSpread2({}, action), {}, {
1406
1313
  action: 'setAttributeInAllVariants'
1407
1314
  });
1408
1315
  delete action.variantId;
1409
1316
  }
1410
-
1411
- if (Array.isArray(diffedValue)) action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (typeof diffedValue === 'string') // LText: value: {en: "", de: ""}
1317
+ if (Array.isArray(diffedValue)) action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (typeof diffedValue === 'string')
1318
+ // LText: value: {en: "", de: ""}
1412
1319
  // Enum: value: {key: "foo", label: "Foo"}
1413
1320
  // LEnum: value: {key: "foo", label: {en: "Foo", de: "Foo"}}
1414
1321
  // Money: value: {centAmount: 123, currencyCode: ""}
1415
1322
  // *: value: ""
1323
+
1416
1324
  // normal
1417
- action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (diffedValue.centAmount || diffedValue.currencyCode) // Money
1325
+ action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (diffedValue.centAmount || diffedValue.currencyCode)
1326
+ // Money
1418
1327
  action.value = {
1419
1328
  centAmount: diffedValue.centAmount ? getDeltaValue(diffedValue.centAmount) : attribute.value.centAmount,
1420
1329
  currencyCode: diffedValue.currencyCode ? getDeltaValue(diffedValue.currencyCode) : attribute.value.currencyCode
1421
- };else if (diffedValue.key) // Enum / LEnum (use only the key)
1330
+ };else if (diffedValue.key)
1331
+ // Enum / LEnum (use only the key)
1422
1332
  action.value = getDeltaValue(diffedValue.key);else if (_typeof(diffedValue) === 'object') if ({}.hasOwnProperty.call(diffedValue, '_t') && diffedValue._t === 'a') {
1423
1333
  // set-typed attribute
1424
1334
  action = _objectSpread2(_objectSpread2({}, action), {}, {
@@ -1426,6 +1336,7 @@ function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAll
1426
1336
  });
1427
1337
  } else {
1428
1338
  // LText
1339
+
1429
1340
  var updatedValue = Object.keys(diffedValue).reduce(function (acc, lang) {
1430
1341
  var patchedValue = getDeltaValue(diffedValue[lang], acc[lang]);
1431
1342
  return Object.assign(acc, _defineProperty({}, lang, patchedValue));
@@ -1434,18 +1345,16 @@ function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAll
1434
1345
  }
1435
1346
  return action;
1436
1347
  }
1437
-
1438
1348
  function _buildVariantImagesAction(diffedImages) {
1439
1349
  var oldVariant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1440
1350
  var newVariant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1441
- var actions = []; // generate a hashMap to be able to reference the right image from both ends
1442
-
1351
+ var actions = [];
1352
+ // generate a hashMap to be able to reference the right image from both ends
1443
1353
  var matchingImagePairs = findMatchingPairs(diffedImages, oldVariant.images, newVariant.images, 'url');
1444
1354
  forEach__default["default"](diffedImages, function (image, key) {
1445
1355
  var _extractMatchingPairs = extractMatchingPairs(matchingImagePairs, key, oldVariant.images, newVariant.images),
1446
- oldObj = _extractMatchingPairs.oldObj,
1447
- newObj = _extractMatchingPairs.newObj;
1448
-
1356
+ oldObj = _extractMatchingPairs.oldObj,
1357
+ newObj = _extractMatchingPairs.newObj;
1449
1358
  if (REGEX_NUMBER$2.test(key)) {
1450
1359
  // New image
1451
1360
  if (Array.isArray(image) && image.length) actions.push({
@@ -1471,13 +1380,15 @@ function _buildVariantImagesAction(diffedImages) {
1471
1380
  label: getDeltaValue(image.label)
1472
1381
  });
1473
1382
  } else if (REGEX_UNDERSCORE_NUMBER$2.test(key)) if (Array.isArray(image) && image.length === 3) {
1474
- if (Number(image[2]) === 3) // image position changed
1383
+ if (Number(image[2]) === 3)
1384
+ // image position changed
1475
1385
  actions.push({
1476
1386
  action: 'moveImageToPosition',
1477
1387
  variantId: oldVariant.id,
1478
1388
  imageUrl: oldObj.url,
1479
1389
  position: Number(image[1])
1480
- });else if (Number(image[2]) === 0) // image removed
1390
+ });else if (Number(image[2]) === 0)
1391
+ // image removed
1481
1392
  actions.push({
1482
1393
  action: 'removeImage',
1483
1394
  variantId: oldVariant.id,
@@ -1487,26 +1398,24 @@ function _buildVariantImagesAction(diffedImages) {
1487
1398
  });
1488
1399
  return actions;
1489
1400
  }
1490
-
1491
1401
  function _buildVariantPricesAction(diffedPrices) {
1492
1402
  var oldVariant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1493
1403
  var newVariant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1494
1404
  var enableDiscounted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1495
1405
  var addPriceActions = [];
1496
1406
  var changePriceActions = [];
1497
- var removePriceActions = []; // generate a hashMap to be able to reference the right image from both ends
1407
+ var removePriceActions = [];
1498
1408
 
1409
+ // generate a hashMap to be able to reference the right image from both ends
1499
1410
  var matchingPricePairs = findMatchingPairs(diffedPrices, oldVariant.prices, newVariant.prices);
1500
1411
  forEach__default["default"](diffedPrices, function (price, key) {
1501
1412
  var _extractMatchingPairs2 = extractMatchingPairs(matchingPricePairs, key, oldVariant.prices, newVariant.prices),
1502
- oldObj = _extractMatchingPairs2.oldObj,
1503
- newObj = _extractMatchingPairs2.newObj;
1504
-
1413
+ oldObj = _extractMatchingPairs2.oldObj,
1414
+ newObj = _extractMatchingPairs2.newObj;
1505
1415
  if (getIsAddAction(key, price)) {
1506
1416
  // Remove read-only fields
1507
1417
  var patchedPrice = price.map(function (p) {
1508
1418
  var shallowClone = _objectSpread2({}, p);
1509
-
1510
1419
  if (enableDiscounted !== true) delete shallowClone.discounted;
1511
1420
  return shallowClone;
1512
1421
  });
@@ -1517,18 +1426,14 @@ function _buildVariantPricesAction(diffedPrices) {
1517
1426
  });
1518
1427
  return;
1519
1428
  }
1520
-
1521
1429
  if (getIsUpdateAction(key, price)) {
1522
1430
  // Remove the discounted field and make sure that the price
1523
1431
  // still has other values, otherwise simply return
1524
1432
  var filteredPrice = _objectSpread2({}, price);
1525
-
1526
1433
  if (enableDiscounted !== true) delete filteredPrice.discounted;
1527
-
1528
1434
  if (Object.keys(filteredPrice).length) {
1529
1435
  // At this point price should have changed, simply pick the new one
1530
1436
  var newPrice = _objectSpread2({}, newObj);
1531
-
1532
1437
  if (enableDiscounted !== true) delete newPrice.discounted;
1533
1438
  changePriceActions.push({
1534
1439
  action: 'changePrice',
@@ -1536,10 +1441,8 @@ function _buildVariantPricesAction(diffedPrices) {
1536
1441
  price: newPrice
1537
1442
  });
1538
1443
  }
1539
-
1540
1444
  return;
1541
1445
  }
1542
-
1543
1446
  if (getIsRemoveAction(key, price)) {
1544
1447
  // price removed
1545
1448
  removePriceActions.push({
@@ -1550,7 +1453,6 @@ function _buildVariantPricesAction(diffedPrices) {
1550
1453
  });
1551
1454
  return [addPriceActions, changePriceActions, removePriceActions];
1552
1455
  }
1553
-
1554
1456
  function _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames) {
1555
1457
  var actions = [];
1556
1458
  if (!attributes) return actions;
@@ -1559,43 +1461,34 @@ function _buildVariantAttributesActions(attributes, oldVariant, newVariant, same
1559
1461
  if (Array.isArray(value)) {
1560
1462
  var id = oldVariant.id;
1561
1463
  var deltaValue = getDeltaValue(value);
1562
-
1563
1464
  var setAction = _buildNewSetAttributeAction(id, deltaValue, sameForAllAttributeNames);
1564
-
1565
1465
  if (setAction) actions.push(setAction);
1566
1466
  } else if (newVariant.attributes) {
1567
1467
  var _setAction = _buildSetAttributeAction(value.value, oldVariant, newVariant.attributes[key], sameForAllAttributeNames);
1568
-
1569
1468
  if (_setAction) actions.push(_setAction);
1570
1469
  }
1571
1470
  } else if (REGEX_UNDERSCORE_NUMBER$2.test(key)) if (Array.isArray(value)) {
1572
1471
  // Ignore pure array moves!
1573
1472
  if (value.length === 3 && value[2] === 3) return;
1574
1473
  var _id = oldVariant.id;
1575
-
1576
1474
  var _deltaValue = getDeltaValue(value);
1577
-
1578
- if (!_deltaValue) if (value[0] && value[0].name) // unset attribute if
1475
+ if (!_deltaValue) if (value[0] && value[0].name)
1476
+ // unset attribute if
1579
1477
  _deltaValue = {
1580
1478
  name: value[0].name
1581
1479
  };else _deltaValue = undefined;
1582
-
1583
1480
  var _setAction2 = _buildNewSetAttributeAction(_id, _deltaValue, sameForAllAttributeNames);
1584
-
1585
1481
  if (_setAction2) actions.push(_setAction2);
1586
1482
  } else {
1587
1483
  var index = key.substring(1);
1588
-
1589
1484
  if (newVariant.attributes) {
1590
1485
  var _setAction3 = _buildSetAttributeAction(value.value, oldVariant, newVariant.attributes[index], sameForAllAttributeNames);
1591
-
1592
1486
  if (_setAction3) actions.push(_setAction3);
1593
1487
  }
1594
1488
  }
1595
1489
  });
1596
1490
  return actions;
1597
1491
  }
1598
-
1599
1492
  function toAssetIdentifier(asset) {
1600
1493
  var assetIdentifier = asset.id ? {
1601
1494
  assetId: asset.id
@@ -1604,26 +1497,22 @@ function toAssetIdentifier(asset) {
1604
1497
  };
1605
1498
  return assetIdentifier;
1606
1499
  }
1607
-
1608
1500
  function toVariantIdentifier(variant) {
1609
1501
  var id = variant.id,
1610
- sku = variant.sku;
1502
+ sku = variant.sku;
1611
1503
  return id ? {
1612
1504
  variantId: id
1613
1505
  } : {
1614
1506
  sku: sku
1615
1507
  };
1616
1508
  }
1617
-
1618
1509
  function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant) {
1619
1510
  var isAssetOrderChanged = Object.entries(diffAssets).find(function (entry) {
1620
1511
  return getIsItemMovedAction(entry[0], entry[1]);
1621
1512
  });
1622
-
1623
1513
  if (!isAssetOrderChanged) {
1624
1514
  return [];
1625
1515
  }
1626
-
1627
1516
  var assetIdsBefore = oldVariant.assets.map(function (_) {
1628
1517
  return _.id;
1629
1518
  });
@@ -1634,24 +1523,21 @@ function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant)
1634
1523
  });
1635
1524
  var assetIdsToKeep = intersection__default["default"](assetIdsCurrent, assetIdsBefore);
1636
1525
  var assetIdsToRemove = without__default["default"].apply(void 0, [assetIdsBefore].concat(_toConsumableArray(assetIdsToKeep)));
1637
-
1638
1526
  var changeAssetOrderAction = _objectSpread2({
1639
1527
  action: 'changeAssetOrder',
1640
1528
  assetOrder: assetIdsToKeep.concat(assetIdsToRemove)
1641
1529
  }, toVariantIdentifier(oldVariant));
1642
-
1643
1530
  return [changeAssetOrderAction];
1644
1531
  }
1645
-
1646
1532
  function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1647
- var assetActions = []; // generate a hashMap to be able to reference the right asset from both ends
1533
+ var assetActions = [];
1648
1534
 
1535
+ // generate a hashMap to be able to reference the right asset from both ends
1649
1536
  var matchingAssetPairs = findMatchingPairs(diffAssets, oldVariant.assets, newVariant.assets);
1650
1537
  forEach__default["default"](diffAssets, function (asset, key) {
1651
1538
  var _extractMatchingPairs3 = extractMatchingPairs(matchingAssetPairs, key, oldVariant.assets, newVariant.assets),
1652
- oldAsset = _extractMatchingPairs3.oldObj,
1653
- newAsset = _extractMatchingPairs3.newObj;
1654
-
1539
+ oldAsset = _extractMatchingPairs3.oldObj,
1540
+ newAsset = _extractMatchingPairs3.newObj;
1655
1541
  if (getIsAddAction(key, asset)) {
1656
1542
  assetActions.push(_objectSpread2(_objectSpread2({
1657
1543
  action: 'addAsset',
@@ -1661,7 +1547,6 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1661
1547
  }));
1662
1548
  return;
1663
1549
  }
1664
-
1665
1550
  if (getIsUpdateAction(key, asset)) {
1666
1551
  // todo add changeAssetOrder
1667
1552
  var basicActions = buildBaseAttributesActions({
@@ -1676,11 +1561,9 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1676
1561
  assetId: oldAsset.id
1677
1562
  });
1678
1563
  }
1679
-
1680
1564
  return _objectSpread2(_objectSpread2(_objectSpread2({}, action), toVariantIdentifier(oldVariant)), toAssetIdentifier(oldAsset));
1681
1565
  });
1682
1566
  assetActions.push.apply(assetActions, _toConsumableArray(basicActions));
1683
-
1684
1567
  if (asset.custom) {
1685
1568
  var customActions = actionsMapCustom(asset, newAsset, oldAsset, _objectSpread2(_objectSpread2({
1686
1569
  actions: {
@@ -1690,26 +1573,22 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1690
1573
  }, toVariantIdentifier(oldVariant)), toAssetIdentifier(oldAsset)));
1691
1574
  assetActions.push.apply(assetActions, _toConsumableArray(customActions));
1692
1575
  }
1693
-
1694
1576
  return;
1695
1577
  }
1696
-
1697
1578
  if (getIsRemoveAction(key, asset)) {
1698
1579
  assetActions.push(_objectSpread2(_objectSpread2({
1699
1580
  action: 'removeAsset'
1700
1581
  }, toAssetIdentifier(oldAsset)), toVariantIdentifier(oldVariant)));
1701
1582
  }
1702
1583
  });
1703
-
1704
1584
  var changedAssetOrderAction = _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant);
1705
-
1706
1585
  return [].concat(_toConsumableArray(changedAssetOrderAction), assetActions);
1707
1586
  }
1587
+
1708
1588
  /**
1709
1589
  * SYNC FUNCTIONS
1710
1590
  */
1711
1591
 
1712
-
1713
1592
  function actionsMapBase$h(diff, oldObj, newObj) {
1714
1593
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1715
1594
  return buildBaseAttributesActions({
@@ -1764,7 +1643,6 @@ function actionsMapCategories(diff) {
1764
1643
  var action = {
1765
1644
  category: category[0]
1766
1645
  };
1767
-
1768
1646
  if (category.length === 3) {
1769
1647
  // Ignore pure array moves!
1770
1648
  if (category[2] !== 3) {
@@ -1776,13 +1654,14 @@ function actionsMapCategories(diff) {
1776
1654
  addToCategoryActions.push(action);
1777
1655
  }
1778
1656
  }
1779
- }); // Make sure `removeFromCategory` actions come first
1657
+ });
1780
1658
 
1659
+ // Make sure `removeFromCategory` actions come first
1781
1660
  return removeFromCategoryActions.concat(addToCategoryActions);
1782
1661
  }
1783
1662
  function actionsMapCategoryOrderHints(diff) {
1784
- if (!diff.categoryOrderHints) return []; // Ignore this pattern as its means no changes happened [{},0,0]
1785
-
1663
+ if (!diff.categoryOrderHints) return [];
1664
+ // Ignore this pattern as its means no changes happened [{},0,0]
1786
1665
  if (Array.isArray(diff.categoryOrderHints)) return [];
1787
1666
  return Object.keys(diff.categoryOrderHints).map(function (categoryId) {
1788
1667
  var hintChange = diff.categoryOrderHints[categoryId];
@@ -1790,9 +1669,13 @@ function actionsMapCategoryOrderHints(diff) {
1790
1669
  action: 'setCategoryOrderHint',
1791
1670
  categoryId: categoryId
1792
1671
  };
1793
- if (hintChange.length === 1) // item was added
1794
- action.orderHint = hintChange[0];else if (hintChange.length === 2 && hintChange[1] !== 0) // item was changed
1795
- action.orderHint = hintChange[1]; // else item was removed -> do not set 'orderHint' property
1672
+ if (hintChange.length === 1)
1673
+ // item was added
1674
+ action.orderHint = hintChange[0];else if (hintChange.length === 2 && hintChange[1] !== 0)
1675
+ // item was changed
1676
+ action.orderHint = hintChange[1];
1677
+
1678
+ // else item was removed -> do not set 'orderHint' property
1796
1679
 
1797
1680
  return action;
1798
1681
  });
@@ -1802,12 +1685,10 @@ function actionsMapAssets(diff, oldObj, newObj, variantHashMap) {
1802
1685
  var variants = diff.variants;
1803
1686
  if (variants) forEach__default["default"](variants, function (variant, key) {
1804
1687
  var _extractMatchingPairs4 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1805
- oldVariant = _extractMatchingPairs4.oldObj,
1806
- newVariant = _extractMatchingPairs4.newObj;
1807
-
1688
+ oldVariant = _extractMatchingPairs4.oldObj,
1689
+ newVariant = _extractMatchingPairs4.newObj;
1808
1690
  if (variant.assets && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
1809
1691
  var assetActions = _buildVariantAssetsActions(variant.assets, oldVariant, newVariant);
1810
-
1811
1692
  allAssetsActions = allAssetsActions.concat(assetActions);
1812
1693
  }
1813
1694
  });
@@ -1820,25 +1701,21 @@ function actionsMapAttributes$1(diff, oldObj, newObj) {
1820
1701
  var variants = diff.variants;
1821
1702
  if (variants) forEach__default["default"](variants, function (variant, key) {
1822
1703
  var _extractMatchingPairs5 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1823
- oldVariant = _extractMatchingPairs5.oldObj,
1824
- newVariant = _extractMatchingPairs5.newObj;
1825
-
1704
+ oldVariant = _extractMatchingPairs5.oldObj,
1705
+ newVariant = _extractMatchingPairs5.newObj;
1826
1706
  if (REGEX_NUMBER$2.test(key) && !Array.isArray(variant)) {
1827
1707
  var skuAction = _buildSkuActions(variant, oldVariant);
1828
-
1829
1708
  var keyAction = _buildKeyActions(variant, oldVariant);
1830
-
1831
1709
  if (skuAction) actions.push(skuAction);
1832
1710
  if (keyAction) actions.push(keyAction);
1833
1711
  var attributes = variant.attributes;
1834
-
1835
1712
  var attrActions = _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames);
1836
-
1837
1713
  actions = actions.concat(attrActions);
1838
1714
  }
1839
- }); // Ensure that an action is unique.
1840
- // This is especially necessary for SFA attributes.
1715
+ });
1841
1716
 
1717
+ // Ensure that an action is unique.
1718
+ // This is especially necessary for SFA attributes.
1842
1719
  return uniqWith__default["default"](actions, function (a, b) {
1843
1720
  return a.action === b.action && a.name === b.name && a.variantId === b.variantId;
1844
1721
  });
@@ -1848,12 +1725,10 @@ function actionsMapImages(diff, oldObj, newObj, variantHashMap) {
1848
1725
  var variants = diff.variants;
1849
1726
  if (variants) forEach__default["default"](variants, function (variant, key) {
1850
1727
  var _extractMatchingPairs6 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1851
- oldVariant = _extractMatchingPairs6.oldObj,
1852
- newVariant = _extractMatchingPairs6.newObj;
1853
-
1728
+ oldVariant = _extractMatchingPairs6.oldObj,
1729
+ newVariant = _extractMatchingPairs6.newObj;
1854
1730
  if (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key)) {
1855
1731
  var vActions = _buildVariantImagesAction(variant.images, oldVariant, newVariant);
1856
-
1857
1732
  actions = actions.concat(vActions);
1858
1733
  }
1859
1734
  });
@@ -1866,22 +1741,21 @@ function actionsMapPrices(diff, oldObj, newObj, variantHashMap, enableDiscounted
1866
1741
  var variants = diff.variants;
1867
1742
  if (variants) forEach__default["default"](variants, function (variant, key) {
1868
1743
  var _extractMatchingPairs7 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1869
- oldVariant = _extractMatchingPairs7.oldObj,
1870
- newVariant = _extractMatchingPairs7.newObj;
1871
-
1744
+ oldVariant = _extractMatchingPairs7.oldObj,
1745
+ newVariant = _extractMatchingPairs7.newObj;
1872
1746
  if (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key)) {
1873
1747
  var _buildVariantPricesAc = _buildVariantPricesAction(variant.prices, oldVariant, newVariant, enableDiscounted),
1874
- _buildVariantPricesAc2 = _slicedToArray(_buildVariantPricesAc, 3),
1875
- addPriceAction = _buildVariantPricesAc2[0],
1876
- changePriceAction = _buildVariantPricesAc2[1],
1877
- removePriceAction = _buildVariantPricesAc2[2];
1878
-
1748
+ _buildVariantPricesAc2 = _slicedToArray(_buildVariantPricesAc, 3),
1749
+ addPriceAction = _buildVariantPricesAc2[0],
1750
+ changePriceAction = _buildVariantPricesAc2[1],
1751
+ removePriceAction = _buildVariantPricesAc2[2];
1879
1752
  addPriceActions = addPriceActions.concat(addPriceAction);
1880
1753
  changePriceActions = changePriceActions.concat(changePriceAction);
1881
1754
  removePriceActions = removePriceActions.concat(removePriceAction);
1882
1755
  }
1883
- }); // price actions need to be in this below order
1756
+ });
1884
1757
 
1758
+ // price actions need to be in this below order
1885
1759
  return changePriceActions.concat(removePriceActions).concat(addPriceActions);
1886
1760
  }
1887
1761
  function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
@@ -1889,16 +1763,14 @@ function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
1889
1763
  var variants = diff.variants;
1890
1764
  if (variants) forEach__default["default"](variants, function (variant, key) {
1891
1765
  var _extractMatchingPairs8 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1892
- oldVariant = _extractMatchingPairs8.oldObj,
1893
- newVariant = _extractMatchingPairs8.newObj;
1894
-
1766
+ oldVariant = _extractMatchingPairs8.oldObj,
1767
+ newVariant = _extractMatchingPairs8.newObj;
1895
1768
  if (variant && variant.prices && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
1896
1769
  var priceHashMap = findMatchingPairs(variant.prices, oldVariant.prices, newVariant.prices);
1897
1770
  forEach__default["default"](variant.prices, function (price, index) {
1898
1771
  var _extractMatchingPairs9 = extractMatchingPairs(priceHashMap, index, oldVariant.prices, newVariant.prices),
1899
- oldPrice = _extractMatchingPairs9.oldObj,
1900
- newPrice = _extractMatchingPairs9.newObj;
1901
-
1772
+ oldPrice = _extractMatchingPairs9.oldObj,
1773
+ newPrice = _extractMatchingPairs9.newObj;
1902
1774
  if (price.custom && (REGEX_UNDERSCORE_NUMBER$2.test(index) || REGEX_NUMBER$2.test(index))) {
1903
1775
  var generatedActions = actionsMapCustom(price, newPrice, oldPrice, {
1904
1776
  actions: {
@@ -1921,15 +1793,14 @@ function actionsMapMasterVariant(oldObj, newObj) {
1921
1793
  variantId: variantId
1922
1794
  };
1923
1795
  };
1924
-
1925
1796
  var extractMasterVariantId = function extractMasterVariantId(fromObj) {
1926
1797
  var variants = Array.isArray(fromObj.variants) ? fromObj.variants : [];
1927
1798
  return variants[0] ? variants[0].id : undefined;
1928
1799
  };
1929
-
1930
1800
  var newMasterVariantId = extractMasterVariantId(newObj);
1931
- var oldMasterVariantId = extractMasterVariantId(oldObj); // Old and new master master variant differ and a new master variant id exists
1801
+ var oldMasterVariantId = extractMasterVariantId(oldObj);
1932
1802
 
1803
+ // Old and new master master variant differ and a new master variant id exists
1933
1804
  if (newMasterVariantId && oldMasterVariantId !== newMasterVariantId) return [createChangeMasterVariantAction(newMasterVariantId)];
1934
1805
  return [];
1935
1806
  }
@@ -1939,9 +1810,9 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
1939
1810
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1940
1811
  var allActions = [];
1941
1812
  var sameForAllAttributeNames = options.sameForAllAttributeNames,
1942
- enableDiscounted = options.enableDiscounted;
1813
+ enableDiscounted = options.enableDiscounted;
1943
1814
  var publish = newObj.publish,
1944
- staged = newObj.staged;
1815
+ staged = newObj.staged;
1945
1816
  var variantHashMap = findMatchingPairs(diff.variants, oldObj.variants, newObj.variants);
1946
1817
  allActions.push(mapActionGroup('attributes', function () {
1947
1818
  return actionsMapAttributes$1(diff, oldObj, newObj, sameForAllAttributeNames || [], variantHashMap);
@@ -1988,27 +1859,22 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
1988
1859
  return flatten__default["default"](allActions);
1989
1860
  };
1990
1861
  }
1991
-
1992
1862
  function moveMasterVariantsIntoVariants(before, now) {
1993
1863
  var _copyEmptyArrayProps = copyEmptyArrayProps(before, now),
1994
- _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
1995
- beforeCopy = _copyEmptyArrayProps2[0],
1996
- nowCopy = _copyEmptyArrayProps2[1];
1997
-
1864
+ _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
1865
+ beforeCopy = _copyEmptyArrayProps2[0],
1866
+ nowCopy = _copyEmptyArrayProps2[1];
1998
1867
  var move = function move(obj) {
1999
1868
  return _objectSpread2(_objectSpread2({}, obj), {}, {
2000
1869
  masterVariant: undefined,
2001
1870
  variants: [obj.masterVariant].concat(_toConsumableArray(obj.variants || []))
2002
1871
  });
2003
1872
  };
2004
-
2005
1873
  var hasMasterVariant = function hasMasterVariant(obj) {
2006
1874
  return obj && obj.masterVariant;
2007
1875
  };
2008
-
2009
1876
  return [hasMasterVariant(beforeCopy) ? move(beforeCopy) : beforeCopy, hasMasterVariant(nowCopy) ? move(nowCopy) : nowCopy];
2010
1877
  }
2011
-
2012
1878
  var products = (function (actionGroupList, syncActionConfig) {
2013
1879
  var mapActionGroup = createMapActionGroup(actionGroupList);
2014
1880
  var doMapActions = createProductMapActions(mapActionGroup, syncActionConfig);
@@ -2020,15 +1886,12 @@ var products = (function (actionGroupList, syncActionConfig) {
2020
1886
 
2021
1887
  var REGEX_NUMBER$1 = new RegExp(/^\d+$/);
2022
1888
  var REGEX_UNDERSCORE_NUMBER$1 = new RegExp(/^_\d+$/);
2023
-
2024
1889
  var isAddAction = function isAddAction(key, resource) {
2025
1890
  return REGEX_NUMBER$1.test(key) && Array.isArray(resource) && resource.length;
2026
1891
  };
2027
-
2028
1892
  var isRemoveAction = function isRemoveAction(key, resource) {
2029
1893
  return REGEX_UNDERSCORE_NUMBER$1.test(key) && Number(resource[2]) === 0;
2030
1894
  };
2031
-
2032
1895
  var baseActionsList$g = [{
2033
1896
  action: 'changeOrderState',
2034
1897
  key: 'orderState'
@@ -2039,6 +1902,7 @@ var baseActionsList$g = [{
2039
1902
  action: 'changeShipmentState',
2040
1903
  key: 'shipmentState'
2041
1904
  }];
1905
+
2042
1906
  /**
2043
1907
  * SYNC FUNCTIONS
2044
1908
  */
@@ -2065,18 +1929,17 @@ function actionsMapDeliveries(diff, oldObj, newObj) {
2065
1929
  }));
2066
1930
  return handler(deliveriesDiff, oldObj.shippingInfo, newObj.shippingInfo);
2067
1931
  }
2068
-
2069
1932
  function _buildDeliveryParcelsAction(diffedParcels) {
2070
1933
  var oldDelivery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2071
1934
  var newDelivery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2072
1935
  var addParcelActions = [];
2073
- var removeParcelActions = []; // generate a hashMap to be able to reference the right image from both ends
1936
+ var removeParcelActions = [];
2074
1937
 
1938
+ // generate a hashMap to be able to reference the right image from both ends
2075
1939
  var matchingParcelPairs = findMatchingPairs(diffedParcels, oldDelivery.parcels, newDelivery.parcels);
2076
1940
  forEach__default["default"](diffedParcels, function (parcel, key) {
2077
1941
  var _extractMatchingPairs = extractMatchingPairs(matchingParcelPairs, key, oldDelivery.parcels, newDelivery.parcels),
2078
- oldObj = _extractMatchingPairs.oldObj;
2079
-
1942
+ oldObj = _extractMatchingPairs.oldObj;
2080
1943
  if (isAddAction(key, parcel)) {
2081
1944
  addParcelActions.push(_objectSpread2({
2082
1945
  action: 'addParcelToDelivery',
@@ -2084,7 +1947,6 @@ function _buildDeliveryParcelsAction(diffedParcels) {
2084
1947
  }, getDeltaValue(parcel)));
2085
1948
  return;
2086
1949
  }
2087
-
2088
1950
  if (isRemoveAction(key, parcel)) {
2089
1951
  removeParcelActions.push({
2090
1952
  action: 'removeParcelFromDelivery',
@@ -2094,13 +1956,12 @@ function _buildDeliveryParcelsAction(diffedParcels) {
2094
1956
  });
2095
1957
  return [addParcelActions, removeParcelActions];
2096
1958
  }
2097
-
2098
1959
  function _buildDeliveryItemsAction(diffedItems) {
2099
1960
  var newDelivery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2100
- var setDeliveryItemsAction = []; // If there is a diff it means that there were changes (update, adds or removes)
1961
+ var setDeliveryItemsAction = [];
1962
+ // If there is a diff it means that there were changes (update, adds or removes)
2101
1963
  // over the items, which means that `setDeliveryItems` change has happened over
2102
1964
  // the delivery
2103
-
2104
1965
  if (diffedItems && Object.keys(diffedItems).length > 0) {
2105
1966
  setDeliveryItemsAction.push({
2106
1967
  action: 'setDeliveryItems',
@@ -2109,10 +1970,8 @@ function _buildDeliveryItemsAction(diffedItems) {
2109
1970
  items: newDelivery.items
2110
1971
  });
2111
1972
  }
2112
-
2113
1973
  return [setDeliveryItemsAction];
2114
1974
  }
2115
-
2116
1975
  function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
2117
1976
  var shippingInfo = diff.shippingInfo;
2118
1977
  if (!shippingInfo) return [];
@@ -2122,15 +1981,13 @@ function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
2122
1981
  var removeParcelActions = [];
2123
1982
  if (deliveries) forEach__default["default"](deliveries, function (delivery, key) {
2124
1983
  var _extractMatchingPairs2 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
2125
- oldDelivery = _extractMatchingPairs2.oldObj,
2126
- newDelivery = _extractMatchingPairs2.newObj;
2127
-
1984
+ oldDelivery = _extractMatchingPairs2.oldObj,
1985
+ newDelivery = _extractMatchingPairs2.newObj;
2128
1986
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
2129
1987
  var _buildDeliveryParcels = _buildDeliveryParcelsAction(delivery.parcels, oldDelivery, newDelivery),
2130
- _buildDeliveryParcels2 = _slicedToArray(_buildDeliveryParcels, 2),
2131
- addParcelAction = _buildDeliveryParcels2[0],
2132
- removeParcelAction = _buildDeliveryParcels2[1];
2133
-
1988
+ _buildDeliveryParcels2 = _slicedToArray(_buildDeliveryParcels, 2),
1989
+ addParcelAction = _buildDeliveryParcels2[0],
1990
+ removeParcelAction = _buildDeliveryParcels2[1];
2134
1991
  addParcelActions = addParcelActions.concat(addParcelAction);
2135
1992
  removeParcelActions = removeParcelActions.concat(removeParcelAction);
2136
1993
  }
@@ -2145,42 +2002,34 @@ function actionsMapDeliveryItems(diff, oldObj, newObj, deliveryHashMap) {
2145
2002
  var setDeliveryItemsActions = [];
2146
2003
  forEach__default["default"](deliveries, function (delivery, key) {
2147
2004
  var _extractMatchingPairs3 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
2148
- newDelivery = _extractMatchingPairs3.newObj;
2149
-
2005
+ newDelivery = _extractMatchingPairs3.newObj;
2150
2006
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
2151
2007
  var _buildDeliveryItemsAc = _buildDeliveryItemsAction(delivery.items, newDelivery),
2152
- _buildDeliveryItemsAc2 = _slicedToArray(_buildDeliveryItemsAc, 1),
2153
- setDeliveryItemsAction = _buildDeliveryItemsAc2[0];
2154
-
2008
+ _buildDeliveryItemsAc2 = _slicedToArray(_buildDeliveryItemsAc, 1),
2009
+ setDeliveryItemsAction = _buildDeliveryItemsAc2[0];
2155
2010
  setDeliveryItemsActions = setDeliveryItemsActions.concat(setDeliveryItemsAction);
2156
2011
  }
2157
2012
  });
2158
2013
  return setDeliveryItemsActions;
2159
2014
  }
2160
2015
  function actionsMapReturnsInfo(diff, oldObj, newObj) {
2161
- var _createBuildArrayActi2;
2162
-
2163
2016
  var returnInfoDiff = diff.returnInfo;
2164
2017
  if (!returnInfoDiff) return [];
2165
- var handler = createBuildArrayActions('returnInfo', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newReturnInfo) {
2018
+ var handler = createBuildArrayActions('returnInfo', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newReturnInfo) {
2166
2019
  if (newReturnInfo.items) {
2167
2020
  return [_objectSpread2({
2168
2021
  action: 'addReturnInfo'
2169
2022
  }, newReturnInfo)];
2170
2023
  }
2171
-
2172
2024
  return [];
2173
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldSReturnInfo, newReturnInfo, key) {
2025
+ }), CHANGE_ACTIONS, function (oldSReturnInfo, newReturnInfo, key) {
2174
2026
  var _returnInfoDiff$key$i = returnInfoDiff[key].items,
2175
- items = _returnInfoDiff$key$i === void 0 ? {} : _returnInfoDiff$key$i;
2176
-
2027
+ items = _returnInfoDiff$key$i === void 0 ? {} : _returnInfoDiff$key$i;
2177
2028
  if (Object.keys(items).length === 0) {
2178
2029
  return [];
2179
2030
  }
2180
-
2181
2031
  return Object.keys(items).reduce(function (actions, index) {
2182
2032
  var item = newReturnInfo.items[index];
2183
-
2184
2033
  if (items[index].shipmentState) {
2185
2034
  actions.push({
2186
2035
  action: 'setReturnShipmentState',
@@ -2188,7 +2037,6 @@ function actionsMapReturnsInfo(diff, oldObj, newObj) {
2188
2037
  shipmentState: item.shipmentState
2189
2038
  });
2190
2039
  }
2191
-
2192
2040
  if (items[index].paymentState) {
2193
2041
  actions.push({
2194
2042
  action: 'setReturnPaymentState',
@@ -2196,10 +2044,9 @@ function actionsMapReturnsInfo(diff, oldObj, newObj) {
2196
2044
  paymentState: item.paymentState
2197
2045
  });
2198
2046
  }
2199
-
2200
2047
  return actions;
2201
2048
  }, []);
2202
- }), _createBuildArrayActi2));
2049
+ }));
2203
2050
  return handler(diff, oldObj, newObj);
2204
2051
  }
2205
2052
 
@@ -2207,11 +2054,9 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
2207
2054
  return function doMapActions(diff, newObj, oldObj) {
2208
2055
  var allActions = [];
2209
2056
  var deliveryHashMap;
2210
-
2211
2057
  if (diff.shippingInfo && diff.shippingInfo.deliveries) {
2212
2058
  deliveryHashMap = findMatchingPairs(diff.shippingInfo.deliveries, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries);
2213
2059
  }
2214
-
2215
2060
  allActions.push(mapActionGroup('base', function () {
2216
2061
  return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
2217
2062
  }));
@@ -2233,14 +2078,15 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
2233
2078
  return flatten__default["default"](allActions);
2234
2079
  };
2235
2080
  }
2236
-
2237
2081
  var orders = (function (actionGroupList, syncActionConfig) {
2238
2082
  // actionGroupList contains information about which action groups
2239
2083
  // are allowed or ignored
2084
+
2240
2085
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2241
2086
  // - action group name
2242
2087
  // - callback function that should return a list of actions that correspond
2243
2088
  // to the for the action group
2089
+
2244
2090
  // this resulting function mapActionGroup will call the callback function
2245
2091
  // for allowed action groups and return the return value of the callback
2246
2092
  // It will return an empty array for ignored action groups
@@ -2292,21 +2138,17 @@ function actionsMapBase$f(diff, oldObj, newObj) {
2292
2138
  }
2293
2139
 
2294
2140
  var validityActions = ['setValidFrom', 'setValidUntil'];
2295
-
2296
2141
  var isValidityActions = function isValidityActions(actionName) {
2297
2142
  return validityActions.includes(actionName);
2298
2143
  };
2299
-
2300
2144
  function combineValidityActions() {
2301
2145
  var actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2302
-
2303
2146
  var _actions$filter = actions.filter(function (item) {
2304
- return isValidityActions(item.action);
2305
- }),
2306
- _actions$filter2 = _slicedToArray(_actions$filter, 2),
2307
- setValidFromAction = _actions$filter2[0],
2308
- setValidUntilAction = _actions$filter2[1];
2309
-
2147
+ return isValidityActions(item.action);
2148
+ }),
2149
+ _actions$filter2 = _slicedToArray(_actions$filter, 2),
2150
+ setValidFromAction = _actions$filter2[0],
2151
+ setValidUntilAction = _actions$filter2[1];
2310
2152
  if (setValidFromAction && setValidUntilAction) {
2311
2153
  return [].concat(_toConsumableArray(actions.filter(function (item) {
2312
2154
  return !isValidityActions(item.action);
@@ -2316,7 +2158,6 @@ function combineValidityActions() {
2316
2158
  validUntil: setValidUntilAction.validUntil
2317
2159
  }]);
2318
2160
  }
2319
-
2320
2161
  return actions;
2321
2162
  }
2322
2163
 
@@ -2329,7 +2170,6 @@ function createProductDiscountsMapActions(mapActionGroup, syncActionConfig) {
2329
2170
  return combineValidityActions(flatten__default["default"](allActions));
2330
2171
  };
2331
2172
  }
2332
-
2333
2173
  var productDiscounts = (function (actionGroupList) {
2334
2174
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2335
2175
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2397,15 +2237,16 @@ function createDiscountCodesMapActions(mapActionGroup, syncActionConfig) {
2397
2237
  return combineValidityActions(flatten__default["default"](allActions));
2398
2238
  };
2399
2239
  }
2400
-
2401
2240
  var discountCodes = (function (actionGroupList) {
2402
2241
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2403
2242
  // actionGroupList contains information about which action groups
2404
2243
  // are allowed or ignored
2244
+
2405
2245
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2406
2246
  // - action group name
2407
2247
  // - callback function that should return a list of actions that correspond
2408
2248
  // to the for the action group
2249
+
2409
2250
  // this resulting function mapActionGroup will call the callback function
2410
2251
  // for allowed action groups and return the return value of the callback
2411
2252
  // It will return an empty array for ignored action groups
@@ -2447,7 +2288,6 @@ function createCustomerGroupMapActions(mapActionGroup, syncActionConfig) {
2447
2288
  return flatten__default["default"](allActions);
2448
2289
  };
2449
2290
  }
2450
-
2451
2291
  var customerGroup = (function (actionGroupList) {
2452
2292
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2453
2293
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2518,7 +2358,6 @@ function createCartDiscountsMapActions(mapActionGroup, syncActionConfig) {
2518
2358
  return combineValidityActions(flatten__default["default"](allActions));
2519
2359
  };
2520
2360
  }
2521
-
2522
2361
  var cartDiscounts = (function (actionGroupList) {
2523
2362
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2524
2363
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2550,25 +2389,23 @@ function actionsMapBase$b(diff, oldObj, newObj) {
2550
2389
  });
2551
2390
  }
2552
2391
  function actionsMapRates(diff, oldObj, newObj) {
2553
- var _createBuildArrayActi;
2554
-
2555
- var handler = createBuildArrayActions('rates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newObject) {
2392
+ var handler = createBuildArrayActions('rates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
2556
2393
  return {
2557
2394
  action: 'addTaxRate',
2558
2395
  taxRate: newObject
2559
2396
  };
2560
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (objectToRemove) {
2397
+ }), REMOVE_ACTIONS, function (objectToRemove) {
2561
2398
  return {
2562
2399
  action: 'removeTaxRate',
2563
2400
  taxRateId: objectToRemove.id
2564
2401
  };
2565
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldObject, updatedObject) {
2402
+ }), CHANGE_ACTIONS, function (oldObject, updatedObject) {
2566
2403
  return {
2567
2404
  action: 'replaceTaxRate',
2568
2405
  taxRateId: oldObject.id === updatedObject.id ? oldObject.id : updatedObject.id,
2569
2406
  taxRate: updatedObject
2570
2407
  };
2571
- }), _createBuildArrayActi));
2408
+ }));
2572
2409
  return handler(diff, oldObj, newObj);
2573
2410
  }
2574
2411
 
@@ -2584,14 +2421,15 @@ function createTaxCategoriesMapActions(mapActionGroup, syncActionConfig) {
2584
2421
  return flatten__default["default"](allActions);
2585
2422
  };
2586
2423
  }
2587
-
2588
2424
  var taxCategories = (function (actionGroupList, syncActionConfig) {
2589
2425
  // config contains information about which action groups
2590
2426
  // are allowed or ignored
2427
+
2591
2428
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2592
2429
  // - action group name
2593
2430
  // - callback function that should return a list of actions that correspond
2594
2431
  // to the for the action group
2432
+
2595
2433
  // this resulting function mapActionGroup will call the callback function
2596
2434
  // for allowed action groups and return the return value of the callback
2597
2435
  // It will return an empty array for ignored action groups
@@ -2613,13 +2451,11 @@ var baseActionsList$a = [{
2613
2451
  action: 'setKey',
2614
2452
  key: 'key'
2615
2453
  }];
2616
-
2617
2454
  var hasLocation = function hasLocation(locations, otherLocation) {
2618
2455
  return locations.some(function (location) {
2619
2456
  return location.country === otherLocation.country;
2620
2457
  });
2621
2458
  };
2622
-
2623
2459
  function actionsMapBase$a(diff, oldObj, newObj) {
2624
2460
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2625
2461
  return buildBaseAttributesActions({
@@ -2631,36 +2467,37 @@ function actionsMapBase$a(diff, oldObj, newObj) {
2631
2467
  });
2632
2468
  }
2633
2469
  function actionsMapLocations(diff, oldObj, newObj) {
2634
- var _createBuildArrayActi;
2635
-
2636
- var handler = createBuildArrayActions('locations', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newLocation) {
2470
+ var handler = createBuildArrayActions('locations', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newLocation) {
2637
2471
  return {
2638
2472
  action: 'addLocation',
2639
2473
  location: newLocation
2640
2474
  };
2641
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldLocation) {
2642
- return (// We only add the action if the location is not included in the new object.
2475
+ }), REMOVE_ACTIONS, function (oldLocation) {
2476
+ return (
2477
+ // We only add the action if the location is not included in the new object.
2643
2478
  !hasLocation(newObj.locations, oldLocation) ? {
2644
2479
  action: 'removeLocation',
2645
2480
  location: oldLocation
2646
2481
  } : null
2647
2482
  );
2648
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldLocation, newLocation) {
2649
- var result = []; // We only remove the location in case that the oldLocation is not
2650
- // included in the new object
2483
+ }), CHANGE_ACTIONS, function (oldLocation, newLocation) {
2484
+ var result = [];
2651
2485
 
2486
+ // We only remove the location in case that the oldLocation is not
2487
+ // included in the new object
2652
2488
  if (!hasLocation(newObj.locations, oldLocation)) result.push({
2653
2489
  action: 'removeLocation',
2654
2490
  location: oldLocation
2655
- }); // We only add the location in case that the newLocation was not
2656
- // included in the old object
2491
+ });
2657
2492
 
2493
+ // We only add the location in case that the newLocation was not
2494
+ // included in the old object
2658
2495
  if (!hasLocation(oldObj.locations, newLocation)) result.push({
2659
2496
  action: 'addLocation',
2660
2497
  location: newLocation
2661
2498
  });
2662
2499
  return result;
2663
- }), _createBuildArrayActi));
2500
+ }));
2664
2501
  return handler(diff, oldObj, newObj);
2665
2502
  }
2666
2503
 
@@ -2676,14 +2513,15 @@ function createZonesMapActions(mapActionGroup, syncActionConfig) {
2676
2513
  return flatten__default["default"](allActions);
2677
2514
  };
2678
2515
  }
2679
-
2680
2516
  var zones = (function (actionGroupList, syncActionConfig) {
2681
2517
  // config contains information about which action groups
2682
2518
  // are allowed or ignored
2519
+
2683
2520
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2684
2521
  // - action group name
2685
2522
  // - callback function that should return a list of actions that correspond
2686
2523
  // to the for the action group
2524
+
2687
2525
  // this resulting function mapActionGroup will call the callback function
2688
2526
  // for allowed action groups and return the return value of the callback
2689
2527
  // It will return an empty array for ignored action groups
@@ -2733,7 +2571,6 @@ function actionsMapBase$9(diff, oldObj, newObj) {
2733
2571
  shouldOmitEmptyString: config.shouldOmitEmptyString
2734
2572
  });
2735
2573
  }
2736
-
2737
2574
  var addShippingRates = function addShippingRates(newZoneRate) {
2738
2575
  return newZoneRate.shippingRates ? newZoneRate.shippingRates.map(function (shippingRate) {
2739
2576
  return {
@@ -2743,23 +2580,20 @@ var addShippingRates = function addShippingRates(newZoneRate) {
2743
2580
  };
2744
2581
  }) : [];
2745
2582
  };
2746
-
2747
2583
  function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2748
- var _createBuildArrayActi;
2749
-
2750
- var handler = createBuildArrayActions('shippingRates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newShippingRate) {
2584
+ var handler = createBuildArrayActions('shippingRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newShippingRate) {
2751
2585
  return {
2752
2586
  action: 'addShippingRate',
2753
2587
  zone: newObj.zone,
2754
2588
  shippingRate: newShippingRate
2755
2589
  };
2756
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldShippingRate) {
2590
+ }), REMOVE_ACTIONS, function (oldShippingRate) {
2757
2591
  return {
2758
2592
  action: 'removeShippingRate',
2759
2593
  zone: oldObj.zone,
2760
2594
  shippingRate: oldShippingRate
2761
2595
  };
2762
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2596
+ }), CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2763
2597
  return [{
2764
2598
  action: 'removeShippingRate',
2765
2599
  zone: oldObj.zone,
@@ -2769,24 +2603,21 @@ function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2769
2603
  zone: newObj.zone,
2770
2604
  shippingRate: newShippingRate
2771
2605
  }];
2772
- }), _createBuildArrayActi));
2606
+ }));
2773
2607
  return handler(diff, oldObj, newObj);
2774
2608
  }
2775
-
2776
2609
  function actionsMapZoneRates(diff, oldObj, newObj) {
2777
- var _createBuildArrayActi2;
2778
-
2779
- var handler = createBuildArrayActions('zoneRates', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newZoneRate) {
2610
+ var handler = createBuildArrayActions('zoneRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newZoneRate) {
2780
2611
  return [{
2781
2612
  action: 'addZone',
2782
2613
  zone: newZoneRate.zone
2783
2614
  }].concat(_toConsumableArray(addShippingRates(newZoneRate)));
2784
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (oldZoneRate) {
2615
+ }), REMOVE_ACTIONS, function (oldZoneRate) {
2785
2616
  return {
2786
2617
  action: 'removeZone',
2787
2618
  zone: oldZoneRate.zone
2788
2619
  };
2789
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2620
+ }), CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2790
2621
  var hasZoneActions = false;
2791
2622
  var shippingRateActions = Object.keys(diff.zoneRates).reduce(function (actions, key) {
2792
2623
  if (diff.zoneRates[key].zone) hasZoneActions = true;
@@ -2800,7 +2631,7 @@ function actionsMapZoneRates(diff, oldObj, newObj) {
2800
2631
  action: 'addZone',
2801
2632
  zone: newZoneRate.zone
2802
2633
  }]) : shippingRateActions);
2803
- }), _createBuildArrayActi2));
2634
+ }));
2804
2635
  return handler(diff, oldObj, newObj);
2805
2636
  }
2806
2637
 
@@ -2819,14 +2650,15 @@ function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
2819
2650
  return flatten__default["default"](allActions);
2820
2651
  };
2821
2652
  }
2822
-
2823
2653
  var shippingMethods = (function (actionGroupList, syncActionConfig) {
2824
2654
  // actionGroupList contains information about which action groups
2825
2655
  // are allowed or ignored
2656
+
2826
2657
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2827
2658
  // - action group name
2828
2659
  // - callback function that should return a list of actions that correspond
2829
2660
  // to the for the action group
2661
+
2830
2662
  // this resulting function mapActionGroup will call the callback function
2831
2663
  // for allowed action groups and return the return value of the callback
2832
2664
  // It will return an empty array for ignored action groups
@@ -2847,7 +2679,6 @@ var keys = Object.keys;
2847
2679
  * @param b the value to test
2848
2680
  * @returns are the values equal by the SameValueZero principle
2849
2681
  */
2850
-
2851
2682
  function sameValueZeroEqual(a, b) {
2852
2683
  return a === b || a !== a && b !== b;
2853
2684
  }
@@ -2857,8 +2688,6 @@ function sameValueZeroEqual(a, b) {
2857
2688
  * @param value the value to test
2858
2689
  * @returns is the value a plain object
2859
2690
  */
2860
-
2861
-
2862
2691
  function isPlainObject(value) {
2863
2692
  return value.constructor === Object || value.constructor == null;
2864
2693
  }
@@ -2868,8 +2697,6 @@ function isPlainObject(value) {
2868
2697
  * @param value the value to test
2869
2698
  * @returns is the value promise-like
2870
2699
  */
2871
-
2872
-
2873
2700
  function isPromiseLike(value) {
2874
2701
  return !!value && typeof value.then === 'function';
2875
2702
  }
@@ -2879,8 +2706,6 @@ function isPromiseLike(value) {
2879
2706
  * @param value the value to test
2880
2707
  * @returns is the value a react element
2881
2708
  */
2882
-
2883
-
2884
2709
  function isReactElement(value) {
2885
2710
  return !!(value && value.$$typeof);
2886
2711
  }
@@ -2890,8 +2715,6 @@ function isReactElement(value) {
2890
2715
  *
2891
2716
  * @returns the new cache object
2892
2717
  */
2893
-
2894
-
2895
2718
  function getNewCacheFallback() {
2896
2719
  var values = [];
2897
2720
  return {
@@ -2908,15 +2731,12 @@ function getNewCacheFallback() {
2908
2731
  *
2909
2732
  * @returns the new cache object
2910
2733
  */
2911
-
2912
-
2913
2734
  var getNewCache = function (canUseWeakMap) {
2914
2735
  if (canUseWeakMap) {
2915
2736
  return function _getNewCache() {
2916
2737
  return new WeakSet();
2917
2738
  };
2918
2739
  }
2919
-
2920
2740
  return getNewCacheFallback;
2921
2741
  }(HAS_WEAKSET_SUPPORT);
2922
2742
  /**
@@ -2925,37 +2745,28 @@ var getNewCache = function (canUseWeakMap) {
2925
2745
  * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
2926
2746
  * @returns the method to create the `isEqual` function
2927
2747
  */
2928
-
2929
-
2930
2748
  function createCircularEqualCreator(isEqual) {
2931
2749
  return function createCircularEqual(comparator) {
2932
2750
  var _comparator = isEqual || comparator;
2933
-
2934
2751
  return function circularEqual(a, b, cache) {
2935
2752
  if (cache === void 0) {
2936
2753
  cache = getNewCache();
2937
2754
  }
2938
-
2939
2755
  var isCacheableA = !!a && _typeof(a) === 'object';
2940
2756
  var isCacheableB = !!b && _typeof(b) === 'object';
2941
-
2942
2757
  if (isCacheableA || isCacheableB) {
2943
2758
  var hasA = isCacheableA && cache.has(a);
2944
2759
  var hasB = isCacheableB && cache.has(b);
2945
-
2946
2760
  if (hasA || hasB) {
2947
2761
  return hasA && hasB;
2948
2762
  }
2949
-
2950
2763
  if (isCacheableA) {
2951
2764
  cache.add(a);
2952
2765
  }
2953
-
2954
2766
  if (isCacheableB) {
2955
2767
  cache.add(b);
2956
2768
  }
2957
2769
  }
2958
-
2959
2770
  return _comparator(a, b, cache);
2960
2771
  };
2961
2772
  };
@@ -2969,21 +2780,16 @@ function createCircularEqualCreator(isEqual) {
2969
2780
  * @param meta the meta object to pass through
2970
2781
  * @returns are the arrays equal
2971
2782
  */
2972
-
2973
-
2974
2783
  function areArraysEqual(a, b, isEqual, meta) {
2975
2784
  var index = a.length;
2976
-
2977
2785
  if (b.length !== index) {
2978
2786
  return false;
2979
2787
  }
2980
-
2981
2788
  while (index-- > 0) {
2982
2789
  if (!isEqual(a[index], b[index], meta)) {
2983
2790
  return false;
2984
2791
  }
2985
2792
  }
2986
-
2987
2793
  return true;
2988
2794
  }
2989
2795
  /**
@@ -2995,11 +2801,8 @@ function areArraysEqual(a, b, isEqual, meta) {
2995
2801
  * @param meta the meta map to pass through
2996
2802
  * @returns are the maps equal
2997
2803
  */
2998
-
2999
-
3000
2804
  function areMapsEqual(a, b, isEqual, meta) {
3001
2805
  var isValueEqual = a.size === b.size;
3002
-
3003
2806
  if (isValueEqual && a.size) {
3004
2807
  var matchedIndices_1 = {};
3005
2808
  a.forEach(function (aValue, aKey) {
@@ -3009,22 +2812,18 @@ function areMapsEqual(a, b, isEqual, meta) {
3009
2812
  b.forEach(function (bValue, bKey) {
3010
2813
  if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
3011
2814
  hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
3012
-
3013
2815
  if (hasMatch_1) {
3014
2816
  matchedIndices_1[matchIndex_1] = true;
3015
2817
  }
3016
2818
  }
3017
-
3018
2819
  matchIndex_1++;
3019
2820
  });
3020
2821
  isValueEqual = hasMatch_1;
3021
2822
  }
3022
2823
  });
3023
2824
  }
3024
-
3025
2825
  return isValueEqual;
3026
2826
  }
3027
-
3028
2827
  var OWNER = '_owner';
3029
2828
  var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
3030
2829
  /**
@@ -3036,36 +2835,28 @@ var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Objec
3036
2835
  * @param meta the meta object to pass through
3037
2836
  * @returns are the objects equal
3038
2837
  */
3039
-
3040
2838
  function areObjectsEqual(a, b, isEqual, meta) {
3041
2839
  var keysA = keys(a);
3042
2840
  var index = keysA.length;
3043
-
3044
2841
  if (keys(b).length !== index) {
3045
2842
  return false;
3046
2843
  }
3047
-
3048
2844
  if (index) {
3049
2845
  var key = void 0;
3050
-
3051
2846
  while (index-- > 0) {
3052
2847
  key = keysA[index];
3053
-
3054
2848
  if (key === OWNER) {
3055
2849
  var reactElementA = isReactElement(a);
3056
2850
  var reactElementB = isReactElement(b);
3057
-
3058
2851
  if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
3059
2852
  return false;
3060
2853
  }
3061
2854
  }
3062
-
3063
2855
  if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3064
2856
  return false;
3065
2857
  }
3066
2858
  }
3067
2859
  }
3068
-
3069
2860
  return true;
3070
2861
  }
3071
2862
  /**
@@ -3075,8 +2866,6 @@ function areObjectsEqual(a, b, isEqual, meta) {
3075
2866
  * @param b the regExp to test agains
3076
2867
  * @returns are the regExps equal
3077
2868
  */
3078
-
3079
-
3080
2869
  function areRegExpsEqual(a, b) {
3081
2870
  return a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.unicode === b.unicode && a.sticky === b.sticky && a.lastIndex === b.lastIndex;
3082
2871
  }
@@ -3089,11 +2878,8 @@ function areRegExpsEqual(a, b) {
3089
2878
  * @param meta the meta set to pass through
3090
2879
  * @returns are the sets equal
3091
2880
  */
3092
-
3093
-
3094
2881
  function areSetsEqual(a, b, isEqual, meta) {
3095
2882
  var isValueEqual = a.size === b.size;
3096
-
3097
2883
  if (isValueEqual && a.size) {
3098
2884
  var matchedIndices_2 = {};
3099
2885
  a.forEach(function (aValue) {
@@ -3103,31 +2889,24 @@ function areSetsEqual(a, b, isEqual, meta) {
3103
2889
  b.forEach(function (bValue) {
3104
2890
  if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
3105
2891
  hasMatch_2 = isEqual(aValue, bValue, meta);
3106
-
3107
2892
  if (hasMatch_2) {
3108
2893
  matchedIndices_2[matchIndex_2] = true;
3109
2894
  }
3110
2895
  }
3111
-
3112
2896
  matchIndex_2++;
3113
2897
  });
3114
2898
  isValueEqual = hasMatch_2;
3115
2899
  }
3116
2900
  });
3117
2901
  }
3118
-
3119
2902
  return isValueEqual;
3120
2903
  }
3121
-
3122
2904
  var HAS_MAP_SUPPORT = typeof Map === 'function';
3123
2905
  var HAS_SET_SUPPORT = typeof Set === 'function';
3124
-
3125
2906
  function createComparator(createIsEqual) {
3126
- var isEqual =
3127
- /* eslint-disable no-use-before-define */
2907
+ var isEqual = /* eslint-disable no-use-before-define */
3128
2908
  typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
3129
2909
  /* eslint-enable */
3130
-
3131
2910
  /**
3132
2911
  * compare the value of the two objects and return true if they are equivalent in values
3133
2912
  *
@@ -3136,69 +2915,52 @@ function createComparator(createIsEqual) {
3136
2915
  * @param [meta] an optional meta object that is passed through to all equality test calls
3137
2916
  * @returns are a and b equivalent in value
3138
2917
  */
3139
-
3140
2918
  function comparator(a, b, meta) {
3141
2919
  if (a === b) {
3142
2920
  return true;
3143
2921
  }
3144
-
3145
2922
  if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3146
2923
  if (isPlainObject(a) && isPlainObject(b)) {
3147
2924
  return areObjectsEqual(a, b, isEqual, meta);
3148
2925
  }
3149
-
3150
2926
  var aShape = Array.isArray(a);
3151
2927
  var bShape = Array.isArray(b);
3152
-
3153
2928
  if (aShape || bShape) {
3154
2929
  return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3155
2930
  }
3156
-
3157
2931
  aShape = a instanceof Date;
3158
2932
  bShape = b instanceof Date;
3159
-
3160
2933
  if (aShape || bShape) {
3161
2934
  return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3162
2935
  }
3163
-
3164
2936
  aShape = a instanceof RegExp;
3165
2937
  bShape = b instanceof RegExp;
3166
-
3167
2938
  if (aShape || bShape) {
3168
2939
  return aShape === bShape && areRegExpsEqual(a, b);
3169
2940
  }
3170
-
3171
2941
  if (isPromiseLike(a) || isPromiseLike(b)) {
3172
2942
  return a === b;
3173
2943
  }
3174
-
3175
2944
  if (HAS_MAP_SUPPORT) {
3176
2945
  aShape = a instanceof Map;
3177
2946
  bShape = b instanceof Map;
3178
-
3179
2947
  if (aShape || bShape) {
3180
2948
  return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3181
2949
  }
3182
2950
  }
3183
-
3184
2951
  if (HAS_SET_SUPPORT) {
3185
2952
  aShape = a instanceof Set;
3186
2953
  bShape = b instanceof Set;
3187
-
3188
2954
  if (aShape || bShape) {
3189
2955
  return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3190
2956
  }
3191
2957
  }
3192
-
3193
2958
  return areObjectsEqual(a, b, isEqual, meta);
3194
2959
  }
3195
-
3196
2960
  return a !== a && b !== b;
3197
2961
  }
3198
-
3199
2962
  return comparator;
3200
2963
  }
3201
-
3202
2964
  var deepEqual = createComparator();
3203
2965
  createComparator(function () {
3204
2966
  return sameValueZeroEqual;
@@ -3229,21 +2991,20 @@ function actionsMapBase$8(diff, previous, next) {
3229
2991
  newObj: next,
3230
2992
  shouldOmitEmptyString: config.shouldOmitEmptyString
3231
2993
  });
3232
- } // this is nearly similar to `buildBaseAttributesActions`, however with a significant difference.
2994
+ }
2995
+
2996
+ // this is nearly similar to `buildBaseAttributesActions`, however with a significant difference.
3233
2997
  // `buildBasAttributesActions` generates update-actions with help of `diff`,
3234
2998
  // which is an object consisting of flags which indicates different operations.
3235
2999
  // `generateBaseFieldsUpdateActions` only generate based on `previous` and `next`.
3236
-
3237
3000
  var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(previous, next, actionDefinition) {
3238
3001
  var isEmpty = createIsEmptyValue([undefined, null, '']);
3239
3002
  return Object.entries(actionDefinition).reduce(function (nextUpdateActions, _ref) {
3240
3003
  var _ref2 = _slicedToArray(_ref, 2),
3241
- field = _ref2[0],
3242
- actionFieldDefinition = _ref2[1];
3243
-
3004
+ field = _ref2[0],
3005
+ actionFieldDefinition = _ref2[1];
3244
3006
  if (isEmpty(previous[field]) && isEmpty(next[field])) return nextUpdateActions;
3245
3007
  if (!isEmpty(previous[field]) && isEmpty(next[field])) return [].concat(_toConsumableArray(nextUpdateActions), [actionFieldDefinition]);
3246
-
3247
3008
  if (!deepEqual(previous[field], next[field])) {
3248
3009
  switch (field) {
3249
3010
  // BEWARE that this is generates update-action only for key of enum attribute value,
@@ -3251,7 +3012,8 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3251
3012
  // `generateBaseFieldsUpdateActions`, we need to extract the following logic so we could
3252
3013
  // cover both entity types.
3253
3014
  case 'key':
3254
- return [].concat(_toConsumableArray(nextUpdateActions), [// Another option is to have explicit name of `field` e.g `enumKey`, which we could use to
3015
+ return [].concat(_toConsumableArray(nextUpdateActions), [
3016
+ // Another option is to have explicit name of `field` e.g `enumKey`, which we could use to
3255
3017
  // generate appropriate update-action for respective entity type.
3256
3018
  // An outline of this on the top of my head:
3257
3019
  // ```js
@@ -3281,7 +3043,6 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3281
3043
  newKey: next[field]
3282
3044
  }]);
3283
3045
  // attribute
3284
-
3285
3046
  case 'attributeConstraint':
3286
3047
  case 'inputHint':
3287
3048
  return [].concat(_toConsumableArray(nextUpdateActions), [{
@@ -3289,7 +3050,6 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3289
3050
  attributeName: actionFieldDefinition.attributeName,
3290
3051
  newValue: next[field]
3291
3052
  }]);
3292
-
3293
3053
  default:
3294
3054
  return [].concat(_toConsumableArray(nextUpdateActions), [_defineProperty({
3295
3055
  action: actionFieldDefinition.action,
@@ -3297,11 +3057,9 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3297
3057
  }, field, next[field])]);
3298
3058
  }
3299
3059
  }
3300
-
3301
3060
  return nextUpdateActions;
3302
3061
  }, []);
3303
3062
  };
3304
-
3305
3063
  var generateUpdateActionsForAttributeDefinitions = function generateUpdateActionsForAttributeDefinitions() {
3306
3064
  var attributeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3307
3065
  var removedAttributeDefinitions = attributeDefinitions.filter(function (attributeDefinition) {
@@ -3348,7 +3106,6 @@ var generateUpdateActionsForAttributeDefinitions = function generateUpdateAction
3348
3106
  };
3349
3107
  })));
3350
3108
  };
3351
-
3352
3109
  var generateUpdateActionsForAttributeEnumValues = function generateUpdateActionsForAttributeEnumValues() {
3353
3110
  var attributeEnumValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3354
3111
  var removedAttributeEnumValues = attributeEnumValues.filter(function (attributeEnumValue) {
@@ -3376,7 +3133,6 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3376
3133
  attributeName: updatedAttributeEnumValue.hint.attributeName
3377
3134
  }
3378
3135
  });
3379
-
3380
3136
  if (!deepEqual(updatedAttributeEnumValue.previous.label, updatedAttributeEnumValue.next.label)) {
3381
3137
  if (updatedAttributeEnumValue.hint.isLocalized) {
3382
3138
  return [].concat(_toConsumableArray(updateActions), [{
@@ -3385,14 +3141,12 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3385
3141
  newValue: updatedAttributeEnumValue.next
3386
3142
  }]);
3387
3143
  }
3388
-
3389
3144
  return [].concat(_toConsumableArray(updateActions), [{
3390
3145
  action: 'changePlainEnumValueLabel',
3391
3146
  attributeName: updatedAttributeEnumValue.hint.attributeName,
3392
3147
  newValue: updatedAttributeEnumValue.next
3393
3148
  }]);
3394
3149
  }
3395
-
3396
3150
  return updateActions;
3397
3151
  }))), _toConsumableArray(addedAttributeEnumValues.map(function (addedAttributeEnumValue) {
3398
3152
  return {
@@ -3402,7 +3156,6 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3402
3156
  };
3403
3157
  })));
3404
3158
  };
3405
-
3406
3159
  var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAction() {
3407
3160
  var attrsOld = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3408
3161
  var attrsNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -3420,9 +3173,10 @@ var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAc
3420
3173
  return action.action === 'addAttributeDefinition';
3421
3174
  }).map(function (action) {
3422
3175
  return action.attribute.name;
3423
- }); // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3424
- // calculate how the productType will look like after adding/removing attributes
3176
+ });
3425
3177
 
3178
+ // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3179
+ // calculate how the productType will look like after adding/removing attributes
3426
3180
  var patchedOldAttributesOrder = attrsOld.map(function (attribute) {
3427
3181
  return attribute.name;
3428
3182
  }).filter(function (name) {
@@ -3434,7 +3188,6 @@ var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAc
3434
3188
  };
3435
3189
  return null;
3436
3190
  };
3437
-
3438
3191
  var actionsMapForHints = function actionsMapForHints() {
3439
3192
  var nestedValuesChanges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3440
3193
  var ptOld = arguments.length > 1 ? arguments[1] : undefined;
@@ -3447,14 +3200,14 @@ var actionsMapForHints = function actionsMapForHints() {
3447
3200
 
3448
3201
  function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
3449
3202
  return function doMapActions(diff, next, previous, options) {
3450
- return flatten__default["default"]([// we support only base fields for the product type,
3203
+ return flatten__default["default"]([
3204
+ // we support only base fields for the product type,
3451
3205
  // for attributes, applying hints would be recommended
3452
3206
  mapActionGroup('base', function () {
3453
3207
  return actionsMapBase$8(diff, previous, next, syncActionConfig);
3454
3208
  }), actionsMapForHints(options.nestedValuesChanges, previous, next)]);
3455
3209
  };
3456
3210
  }
3457
-
3458
3211
  var productTypes = (function (actionGroupList, syncActionConfig) {
3459
3212
  var mapActionGroup = createMapActionGroup(actionGroupList);
3460
3213
  var doMapActions = createProductTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3497,26 +3250,24 @@ function actionsMapBase$7(diff, oldObj, newObj) {
3497
3250
  });
3498
3251
  }
3499
3252
  function actionsMapRoles(diff, oldObj, newObj) {
3500
- var _createBuildArrayActi;
3501
-
3502
- var buildArrayActions = createBuildArrayActions('roles', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newRole) {
3253
+ var buildArrayActions = createBuildArrayActions('roles', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newRole) {
3503
3254
  return {
3504
3255
  action: 'addRoles',
3505
3256
  roles: newRole
3506
3257
  };
3507
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldRole) {
3258
+ }), REMOVE_ACTIONS, function (oldRole) {
3508
3259
  return {
3509
3260
  action: 'removeRoles',
3510
3261
  roles: oldRole
3511
3262
  };
3512
- }), _createBuildArrayActi));
3263
+ }));
3513
3264
  return buildArrayActions(diff, oldObj, newObj);
3514
3265
  }
3515
3266
 
3267
+ // This function groups `addRoles` and `removeRoles` actions to one array
3516
3268
  function groupRoleActions(_ref) {
3517
3269
  var _ref2 = _slicedToArray(_ref, 1),
3518
- actions = _ref2[0];
3519
-
3270
+ actions = _ref2[0];
3520
3271
  var addActionRoles = [];
3521
3272
  var removeActionRoles = [];
3522
3273
  actions.forEach(function (action) {
@@ -3533,7 +3284,6 @@ function groupRoleActions(_ref) {
3533
3284
  return action.roles.length;
3534
3285
  });
3535
3286
  }
3536
-
3537
3287
  function createStatesMapActions(mapActionGroup, syncActionConfig) {
3538
3288
  return function doMapActions(diff, newObj, oldObj) {
3539
3289
  var baseActions = [];
@@ -3547,7 +3297,6 @@ function createStatesMapActions(mapActionGroup, syncActionConfig) {
3547
3297
  return flatten__default["default"]([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
3548
3298
  };
3549
3299
  }
3550
-
3551
3300
  var states = (function (actionGroupList, syncActionConfig) {
3552
3301
  var mapActionGroup = createMapActionGroup(actionGroupList);
3553
3302
  var doMapActions = createStatesMapActions(mapActionGroup, syncActionConfig);
@@ -3599,7 +3348,6 @@ function createChannelsMapActions$1(mapActionGroup, syncActionConfig) {
3599
3348
  return flatten__default["default"](allActions);
3600
3349
  };
3601
3350
  }
3602
-
3603
3351
  var channels = (function (actionGroupList) {
3604
3352
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3605
3353
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3612,15 +3360,12 @@ var channels = (function (actionGroupList) {
3612
3360
 
3613
3361
  var REGEX_NUMBER = new RegExp(/^\d+$/);
3614
3362
  var REGEX_UNDERSCORE_NUMBER = new RegExp(/^_\d+$/);
3615
-
3616
3363
  var getIsChangedOperation = function getIsChangedOperation(key) {
3617
3364
  return REGEX_NUMBER.test(key);
3618
3365
  };
3619
-
3620
3366
  var getIsRemovedOperation = function getIsRemovedOperation(key) {
3621
3367
  return REGEX_UNDERSCORE_NUMBER.test(key);
3622
3368
  };
3623
-
3624
3369
  var baseActionsList$5 = [{
3625
3370
  action: 'changeKey',
3626
3371
  key: 'key'
@@ -3641,38 +3386,35 @@ function actionsMapBase$5(diff, oldObj, newObj) {
3641
3386
  shouldOmitEmptyString: config.shouldOmitEmptyString
3642
3387
  });
3643
3388
  }
3644
-
3645
3389
  function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next) {
3646
- var _createBuildArrayActi;
3647
-
3648
3390
  var addEnumActionName = attributeType === 'Enum' ? 'addEnumValue' : 'addLocalizedEnumValue';
3649
3391
  var changeEnumValueLabelActionName = attributeType === 'Enum' ? 'changeEnumValueLabel' : 'changeLocalizedEnumValueLabel';
3650
3392
  var changeEnumOrderActionName = attributeType === 'Enum' ? 'changeEnumValueOrder' : 'changeLocalizedEnumValueOrder';
3651
- var buildArrayActions = createBuildArrayActions('values', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newEnum) {
3393
+ var buildArrayActions = createBuildArrayActions('values', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newEnum) {
3652
3394
  return {
3653
3395
  fieldName: fieldName,
3654
3396
  action: addEnumActionName,
3655
3397
  value: newEnum
3656
3398
  };
3657
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldEnum, newEnum) {
3399
+ }), CHANGE_ACTIONS, function (oldEnum, newEnum) {
3658
3400
  var oldEnumInNext = next.values.find(function (nextEnum) {
3659
3401
  return nextEnum.key === oldEnum.key;
3660
- }); // These `changeActions` would impose a nested structure among
3402
+ });
3403
+
3404
+ // These `changeActions` would impose a nested structure among
3661
3405
  // the accumulated `updateActions` generated by `buildArrayActions`
3662
3406
  // In the end; we have to flatten the structure before we pass it back
3663
3407
  // to the client.
3664
-
3665
3408
  var changeActions = [];
3666
-
3667
3409
  if (oldEnumInNext) {
3668
3410
  // If the enum value is changed, we need to change the order first
3669
- var isKeyChanged = oldEnum.key !== newEnum.key; // check if the label is changed
3411
+ var isKeyChanged = oldEnum.key !== newEnum.key;
3670
3412
 
3413
+ // check if the label is changed
3671
3414
  var foundPreviousEnum = previous.values.find(function (previousEnum) {
3672
3415
  return previousEnum.key === newEnum.key;
3673
3416
  });
3674
3417
  var isLabelEqual = isEqual__default["default"](foundPreviousEnum.label, newEnum.label);
3675
-
3676
3418
  if (isKeyChanged) {
3677
3419
  // these actions is then flatten in the end
3678
3420
  changeActions.push({
@@ -3681,7 +3423,6 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3681
3423
  value: newEnum
3682
3424
  });
3683
3425
  }
3684
-
3685
3426
  if (!isLabelEqual) {
3686
3427
  changeActions.push({
3687
3428
  fieldName: fieldName,
@@ -3696,12 +3437,11 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3696
3437
  value: newEnum
3697
3438
  });
3698
3439
  }
3699
-
3700
3440
  return changeActions;
3701
- }), _createBuildArrayActi));
3702
- var actions = []; // following lists are necessary to ensure that when we change the
3441
+ }));
3442
+ var actions = [];
3443
+ // following lists are necessary to ensure that when we change the
3703
3444
  // order of enumValues, we generate one updateAction instead of one at a time.
3704
-
3705
3445
  var newEnumValuesOrder = [];
3706
3446
  flatten__default["default"](buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
3707
3447
  if (updateAction.action === changeEnumOrderActionName) {
@@ -3716,18 +3456,14 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3716
3456
  keys: newEnumValuesOrder
3717
3457
  }] : []));
3718
3458
  }
3719
-
3720
3459
  function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPaths) {
3721
3460
  var actions = [];
3722
3461
  forEach__default["default"](fieldDefinitionsDiff, function (diffValue, diffKey) {
3723
3462
  var extractedPairs = extractMatchingPairs(diffPaths, diffKey, previous, next);
3724
-
3725
3463
  if (getIsChangedOperation(diffKey)) {
3726
3464
  var _diffValue$type;
3727
-
3728
3465
  if (Array.isArray(diffValue)) {
3729
3466
  var deltaValue = getDeltaValue(diffValue);
3730
-
3731
3467
  if (deltaValue.name) {
3732
3468
  actions.push({
3733
3469
  action: 'addFieldDefinition',
@@ -3760,7 +3496,6 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
3760
3496
  });
3761
3497
  } else {
3762
3498
  var _deltaValue = getDeltaValue(diffValue);
3763
-
3764
3499
  if (_deltaValue === undefined && diffValue[0].name) actions.push({
3765
3500
  action: 'removeFieldDefinition',
3766
3501
  fieldName: diffValue[0].name
@@ -3768,11 +3503,12 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
3768
3503
  }
3769
3504
  }
3770
3505
  }
3771
- }); // Make sure to execute removeActions before creating new ones
3506
+ });
3507
+
3508
+ // Make sure to execute removeActions before creating new ones
3772
3509
  // in order to prevent any eventual removal of `addAction`.
3773
3510
  // List of `removeActions` can be found here
3774
3511
  // https://docs.commercetools.com/http-api-projects-types.html#change-key
3775
-
3776
3512
  var sortedActions = sortBy__default["default"](actions, function (action) {
3777
3513
  return action.action !== 'removeFieldDefinition';
3778
3514
  });
@@ -3790,7 +3526,6 @@ function createTypeMapActions(mapActionGroup, syncActionConfig) {
3790
3526
  return flatten__default["default"](allActions);
3791
3527
  };
3792
3528
  }
3793
-
3794
3529
  var types = (function (actionGroupList, syncActionConfig) {
3795
3530
  var mapActionGroup = createMapActionGroup(actionGroupList);
3796
3531
  var doMapActions = createTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3819,6 +3554,19 @@ var baseActionsList$4 = [{
3819
3554
  action: 'setShippingRateInputType',
3820
3555
  key: 'shippingRateInputType'
3821
3556
  }];
3557
+ var myBusinessUnitActionsList = [{
3558
+ action: 'changeMyBusinessUnitStatusOnCreation',
3559
+ key: 'myBusinessUnitStatusOnCreation',
3560
+ actionKey: 'status'
3561
+ }, {
3562
+ action: 'setMyBusinessUnitAssociateRoleOnCreation',
3563
+ key: 'myBusinessUnitAssociateRoleOnCreation',
3564
+ actionKey: 'associateRole'
3565
+ }];
3566
+ var customerSearchActionsList = [{
3567
+ action: 'changeCustomerSearchStatus',
3568
+ key: 'status'
3569
+ }];
3822
3570
  function actionsMapBase$4(diff, oldObj, newObj) {
3823
3571
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3824
3572
  return buildBaseAttributesActions({
@@ -3829,6 +3577,34 @@ function actionsMapBase$4(diff, oldObj, newObj) {
3829
3577
  shouldOmitEmptyString: config.shouldOmitEmptyString
3830
3578
  });
3831
3579
  }
3580
+ var actionsMapBusinessUnit = function actionsMapBusinessUnit(diff, oldObj, newObj) {
3581
+ var businessUnits = diff.businessUnits;
3582
+ if (!businessUnits) {
3583
+ return [];
3584
+ }
3585
+ return buildBaseAttributesActions({
3586
+ actions: myBusinessUnitActionsList,
3587
+ diff: businessUnits,
3588
+ oldObj: oldObj.businessUnits,
3589
+ newObj: newObj.businessUnits
3590
+ });
3591
+ };
3592
+ function actionsMapSearchIndexingConfiguration(diff, oldObj, newObj) {
3593
+ var searchIndexing = diff.searchIndexing;
3594
+ if (!searchIndexing) {
3595
+ return [];
3596
+ }
3597
+ var customers = searchIndexing.customers;
3598
+ if (!customers) {
3599
+ return [];
3600
+ }
3601
+ return buildBaseAttributesActions({
3602
+ actions: customerSearchActionsList,
3603
+ diff: diff.searchIndexing.customers,
3604
+ oldObj: oldObj.searchIndexing.customers,
3605
+ newObj: newObj.searchIndexing.customers
3606
+ });
3607
+ }
3832
3608
 
3833
3609
  function createChannelsMapActions(mapActionGroup, syncActionConfig) {
3834
3610
  return function doMapActions(diff, newObj, oldObj) {
@@ -3836,10 +3612,15 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
3836
3612
  allActions.push(mapActionGroup('base', function () {
3837
3613
  return actionsMapBase$4(diff, oldObj, newObj, syncActionConfig);
3838
3614
  }));
3615
+ allActions.push(mapActionGroup('businessUnit', function () {
3616
+ return actionsMapBusinessUnit(diff, oldObj, newObj);
3617
+ }));
3618
+ allActions.push(mapActionGroup('searchIndexingConfiguration', function () {
3619
+ return actionsMapSearchIndexingConfiguration(diff, oldObj, newObj);
3620
+ }));
3839
3621
  return flatten__default["default"](allActions);
3840
3622
  };
3841
3623
  }
3842
-
3843
3624
  var projects = (function (actionGroupList) {
3844
3625
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3845
3626
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3884,7 +3665,6 @@ function createStoresMapActions(mapActionGroup) {
3884
3665
  return flatten__default["default"](allActions);
3885
3666
  };
3886
3667
  }
3887
-
3888
3668
  var stores = (function (actionGroupList) {
3889
3669
  var mapActionGroup = createMapActionGroup(actionGroupList);
3890
3670
  var doMapActions = createStoresMapActions(mapActionGroup);
@@ -3923,7 +3703,6 @@ function createProductSelectionsMapActions(mapActionGroup) {
3923
3703
  return flatten__default["default"](allActions);
3924
3704
  };
3925
3705
  }
3926
-
3927
3706
  var productSelections = (function (actionGroupList) {
3928
3707
  var mapActionGroup = createMapActionGroup(actionGroupList);
3929
3708
  var doMapActions = createProductSelectionsMapActions(mapActionGroup);
@@ -3940,7 +3719,8 @@ var baseActionsList$1 = [{
3940
3719
  }, {
3941
3720
  action: 'setDiscountedPrice',
3942
3721
  key: 'discounted'
3943
- }, // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3722
+ },
3723
+ // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3944
3724
  {
3945
3725
  action: 'setPriceTiers',
3946
3726
  key: 'tiers'
@@ -3979,7 +3759,6 @@ function createPriceMapActions(mapActionGroup, syncActionConfig) {
3979
3759
  return combineValidityActions([].concat(_toConsumableArray(baseActions), _toConsumableArray(customActions)));
3980
3760
  };
3981
3761
  }
3982
-
3983
3762
  var prices = (function (actionGroupList, syncActionConfig) {
3984
3763
  var mapActionGroup = createMapActionGroup(actionGroupList);
3985
3764
  var doMapActions = createPriceMapActions(mapActionGroup, syncActionConfig);
@@ -3994,7 +3773,6 @@ var hasAttribute = function hasAttribute(attributes, newValue) {
3994
3773
  return attribute.key === newValue.key;
3995
3774
  });
3996
3775
  };
3997
-
3998
3776
  var baseActionsList = [{
3999
3777
  action: 'changeName',
4000
3778
  key: 'name'
@@ -4016,35 +3794,34 @@ function actionsMapBase(diff, oldObj, newObj) {
4016
3794
  });
4017
3795
  }
4018
3796
  function actionsMapAttributes(diff, oldObj, newObj) {
4019
- var _createBuildArrayActi;
4020
-
4021
- var handler = createBuildArrayActions('attributes', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAttribute) {
3797
+ var handler = createBuildArrayActions('attributes', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAttribute) {
4022
3798
  return {
4023
3799
  action: 'addAttribute',
4024
3800
  attribute: newAttribute
4025
3801
  };
4026
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAttribute) {
3802
+ }), REMOVE_ACTIONS, function (oldAttribute) {
4027
3803
  // We only add the action if the attribute is not included in the new object.
4028
3804
  return !hasAttribute(newObj.attributes, oldAttribute) ? {
4029
3805
  action: 'removeAttribute',
4030
3806
  attribute: oldAttribute
4031
3807
  } : null;
4032
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
4033
- var result = []; // We only remove the attribute in case that the oldAttribute is not
3808
+ }), CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
3809
+ var result = [];
3810
+ // We only remove the attribute in case that the oldAttribute is not
4034
3811
  // included in the new object
4035
-
4036
3812
  if (!hasAttribute(newObj.attributes, oldAttribute)) result.push({
4037
3813
  action: 'removeAttribute',
4038
3814
  attribute: oldAttribute
4039
- }); // We only add the attribute in case that the newAttribute was not
4040
- // included in the old object
3815
+ });
4041
3816
 
3817
+ // We only add the attribute in case that the newAttribute was not
3818
+ // included in the old object
4042
3819
  if (!hasAttribute(oldObj.attributes, newAttribute)) result.push({
4043
3820
  action: 'addAttribute',
4044
3821
  attribute: newAttribute
4045
3822
  });
4046
3823
  return result;
4047
- }), _createBuildArrayActi));
3824
+ }));
4048
3825
  return handler(diff, oldObj, newObj);
4049
3826
  }
4050
3827
 
@@ -4060,7 +3837,6 @@ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
4060
3837
  return flatten__default["default"](allActions);
4061
3838
  };
4062
3839
  }
4063
-
4064
3840
  var attributeGroups = (function (actionGroupList, syncActionConfig) {
4065
3841
  var mapActionGroup = createMapActionGroup(actionGroupList);
4066
3842
  var doMapActions = createAttributeGroupsMapActions(mapActionGroup, syncActionConfig);