@commercetools/sync-actions 5.16.0 → 5.18.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.
@@ -15,174 +15,143 @@
15
15
  var without__default = /*#__PURE__*/_interopDefaultLegacy(without);
16
16
  var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
17
17
 
18
- function ownKeys(object, enumerableOnly) {
19
- var keys = Object.keys(object);
20
-
21
- if (Object.getOwnPropertySymbols) {
22
- var symbols = Object.getOwnPropertySymbols(object);
23
- enumerableOnly && (symbols = symbols.filter(function (sym) {
24
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
25
- })), keys.push.apply(keys, symbols);
18
+ function _arrayLikeToArray(r, a) {
19
+ (null == a || a > r.length) && (a = r.length);
20
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
21
+ return n;
22
+ }
23
+ function _arrayWithHoles(r) {
24
+ if (Array.isArray(r)) return r;
25
+ }
26
+ function _arrayWithoutHoles(r) {
27
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
28
+ }
29
+ function _defineProperty(e, r, t) {
30
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
31
+ value: t,
32
+ enumerable: !0,
33
+ configurable: !0,
34
+ writable: !0
35
+ }) : e[r] = t, e;
36
+ }
37
+ function _iterableToArray(r) {
38
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
39
+ }
40
+ function _iterableToArrayLimit(r, l) {
41
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
42
+ if (null != t) {
43
+ var e,
44
+ n,
45
+ i,
46
+ u,
47
+ a = [],
48
+ f = !0,
49
+ o = !1;
50
+ try {
51
+ if (i = (t = t.call(r)).next, 0 === l) {
52
+ if (Object(t) !== t) return;
53
+ f = !1;
54
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
55
+ } catch (r) {
56
+ o = !0, n = r;
57
+ } finally {
58
+ try {
59
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
60
+ } finally {
61
+ if (o) throw n;
62
+ }
63
+ }
64
+ return a;
26
65
  }
27
-
28
- return keys;
29
66
  }
30
-
31
- function _objectSpread2(target) {
32
- for (var i = 1; i < arguments.length; i++) {
33
- var source = null != arguments[i] ? arguments[i] : {};
34
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
35
- _defineProperty(target, key, source[key]);
36
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
37
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
38
- });
39
- }
40
-
41
- return target;
67
+ function _nonIterableRest() {
68
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
42
69
  }
43
-
44
- function _typeof(obj) {
45
- "@babel/helpers - typeof";
46
-
47
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
48
- return typeof obj;
49
- } : function (obj) {
50
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
51
- }, _typeof(obj);
70
+ function _nonIterableSpread() {
71
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52
72
  }
53
-
54
- function _defineProperty(obj, key, value) {
55
- if (key in obj) {
56
- Object.defineProperty(obj, key, {
57
- value: value,
58
- enumerable: true,
59
- configurable: true,
60
- writable: true
61
- });
62
- } else {
63
- obj[key] = value;
73
+ function ownKeys(e, r) {
74
+ var t = Object.keys(e);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var o = Object.getOwnPropertySymbols(e);
77
+ r && (o = o.filter(function (r) {
78
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
79
+ })), t.push.apply(t, o);
64
80
  }
65
-
66
- return obj;
67
- }
68
-
69
- function _objectWithoutPropertiesLoose(source, excluded) {
70
- if (source == null) return {};
71
- var target = {};
72
- var sourceKeys = Object.keys(source);
73
- var key, i;
74
-
75
- for (i = 0; i < sourceKeys.length; i++) {
76
- key = sourceKeys[i];
77
- if (excluded.indexOf(key) >= 0) continue;
78
- target[key] = source[key];
81
+ return t;
82
+ }
83
+ function _objectSpread2(e) {
84
+ for (var r = 1; r < arguments.length; r++) {
85
+ var t = null != arguments[r] ? arguments[r] : {};
86
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
87
+ _defineProperty(e, r, t[r]);
88
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
89
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
90
+ });
79
91
  }
80
-
81
- return target;
92
+ return e;
82
93
  }
83
-
84
- function _objectWithoutProperties(source, excluded) {
85
- if (source == null) return {};
86
-
87
- var target = _objectWithoutPropertiesLoose(source, excluded);
88
-
89
- var key, i;
90
-
94
+ function _objectWithoutProperties(e, t) {
95
+ if (null == e) return {};
96
+ var o,
97
+ r,
98
+ i = _objectWithoutPropertiesLoose(e, t);
91
99
  if (Object.getOwnPropertySymbols) {
92
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
93
-
94
- for (i = 0; i < sourceSymbolKeys.length; i++) {
95
- key = sourceSymbolKeys[i];
96
- if (excluded.indexOf(key) >= 0) continue;
97
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
98
- target[key] = source[key];
99
- }
100
+ var s = Object.getOwnPropertySymbols(e);
101
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
100
102
  }
101
-
102
- return target;
103
- }
104
-
105
- function _slicedToArray(arr, i) {
106
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
107
- }
108
-
109
- function _toConsumableArray(arr) {
110
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
103
+ return i;
104
+ }
105
+ function _objectWithoutPropertiesLoose(r, e) {
106
+ if (null == r) return {};
107
+ var t = {};
108
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
109
+ if (e.includes(n)) continue;
110
+ t[n] = r[n];
111
+ }
112
+ return t;
111
113
  }
112
-
113
- function _arrayWithoutHoles(arr) {
114
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
114
+ function _slicedToArray(r, e) {
115
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
115
116
  }
116
-
117
- function _arrayWithHoles(arr) {
118
- if (Array.isArray(arr)) return arr;
117
+ function _toConsumableArray(r) {
118
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
119
119
  }
120
-
121
- function _iterableToArray(iter) {
122
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
123
- }
124
-
125
- function _iterableToArrayLimit(arr, i) {
126
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
127
-
128
- if (_i == null) return;
129
- var _arr = [];
130
- var _n = true;
131
- var _d = false;
132
-
133
- var _s, _e;
134
-
135
- try {
136
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
137
- _arr.push(_s.value);
138
-
139
- if (i && _arr.length === i) break;
140
- }
141
- } catch (err) {
142
- _d = true;
143
- _e = err;
144
- } finally {
145
- try {
146
- if (!_n && _i["return"] != null) _i["return"]();
147
- } finally {
148
- if (_d) throw _e;
149
- }
120
+ function _toPrimitive(t, r) {
121
+ if ("object" != typeof t || !t) return t;
122
+ var e = t[Symbol.toPrimitive];
123
+ if (void 0 !== e) {
124
+ var i = e.call(t, r || "default");
125
+ if ("object" != typeof i) return i;
126
+ throw new TypeError("@@toPrimitive must return a primitive value.");
150
127
  }
151
-
152
- return _arr;
153
- }
154
-
155
- function _unsupportedIterableToArray(o, minLen) {
156
- if (!o) return;
157
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
158
- var n = Object.prototype.toString.call(o).slice(8, -1);
159
- if (n === "Object" && o.constructor) n = o.constructor.name;
160
- if (n === "Map" || n === "Set") return Array.from(o);
161
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
162
- }
163
-
164
- function _arrayLikeToArray(arr, len) {
165
- if (len == null || len > arr.length) len = arr.length;
166
-
167
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
168
-
169
- return arr2;
128
+ return ("string" === r ? String : Number)(t);
170
129
  }
171
-
172
- function _nonIterableSpread() {
173
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
130
+ function _toPropertyKey(t) {
131
+ var i = _toPrimitive(t, "string");
132
+ return "symbol" == typeof i ? i : i + "";
174
133
  }
134
+ function _typeof(o) {
135
+ "@babel/helpers - typeof";
175
136
 
176
- function _nonIterableRest() {
177
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
137
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
138
+ return typeof o;
139
+ } : function (o) {
140
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
141
+ }, _typeof(o);
142
+ }
143
+ function _unsupportedIterableToArray(r, a) {
144
+ if (r) {
145
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
146
+ var t = {}.toString.call(r).slice(8, -1);
147
+ 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;
148
+ }
178
149
  }
179
150
 
180
151
  var _excluded$1 = ["prices"];
181
-
182
152
  function applyOnBeforeDiff(before, now, fn) {
183
153
  return fn && typeof fn === 'function' ? fn(before, now) : [before, now];
184
154
  }
185
-
186
155
  var createPriceComparator = function createPriceComparator(price) {
187
156
  return {
188
157
  value: {
@@ -195,13 +164,11 @@
195
164
  validUntil: price.validUntil
196
165
  };
197
166
  };
198
-
199
167
  function arePricesStructurallyEqual(oldPrice, newPrice) {
200
168
  var oldPriceComparison = createPriceComparator(oldPrice);
201
169
  var newPriceComparison = createPriceComparator(newPrice);
202
170
  return isEqual__default["default"](newPriceComparison, oldPriceComparison);
203
171
  }
204
-
205
172
  function extractPriceFromPreviousVariant(newPrice, previousVariant) {
206
173
  if (!previousVariant) return null;
207
174
  var price = previousVariant.prices.find(function (oldPrice) {
@@ -209,12 +176,10 @@
209
176
  });
210
177
  return price || null;
211
178
  }
212
-
213
179
  function injectMissingPriceIds(nextVariants, previousVariants) {
214
180
  return nextVariants.map(function (newVariant) {
215
181
  var prices = newVariant.prices,
216
- restOfVariant = _objectWithoutProperties(newVariant, _excluded$1);
217
-
182
+ restOfVariant = _objectWithoutProperties(newVariant, _excluded$1);
218
183
  if (!prices) return restOfVariant;
219
184
  var oldVariant = previousVariants.find(function (previousVariant) {
220
185
  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;
@@ -222,33 +187,27 @@
222
187
  return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
223
188
  prices: prices.map(function (price) {
224
189
  var newPrice = _objectSpread2({}, price);
225
-
226
190
  var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
227
-
228
191
  if (oldPrice) {
229
192
  // copy ID if not provided
230
193
  if (!newPrice.id) newPrice.id = oldPrice.id;
231
194
  if (isNil__default["default"](newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
232
195
  if (isNil__default["default"](newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
233
196
  }
234
-
235
197
  return newPrice;
236
198
  })
237
199
  });
238
200
  });
239
201
  }
240
-
241
202
  function createBuildActions(differ, doMapActions, onBeforeDiff) {
242
203
  var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
243
204
  return function buildActions(now, before) {
244
205
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
245
206
  if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
246
-
247
207
  var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
248
- _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
249
- processedBefore = _applyOnBeforeDiff2[0],
250
- processedNow = _applyOnBeforeDiff2[1];
251
-
208
+ _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
209
+ processedBefore = _applyOnBeforeDiff2[0],
210
+ processedNow = _applyOnBeforeDiff2[1];
252
211
  if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
253
212
  var diffed = differ(processedBefore, processedNow);
254
213
  if (!buildActionsConfig.withHints && !diffed) return [];
@@ -270,10 +229,11 @@
270
229
  var found = actionGroups.find(function (c) {
271
230
  return c.type === type;
272
231
  });
273
- if (!found) return []; // Keep `black` for backwards compatibility.
274
-
275
- if (found.group === 'ignore' || found.group === 'black') return []; // Keep `white` for backwards compatibility.
232
+ if (!found) return [];
276
233
 
234
+ // Keep `black` for backwards compatibility.
235
+ if (found.group === 'ignore' || found.group === 'black') return [];
236
+ // Keep `white` for backwards compatibility.
277
237
  if (found.group === 'allow' || found.group === 'white') return fn();
278
238
  throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
279
239
  };
@@ -283,7 +243,6 @@
283
243
  // with es6 modules so we use require instead below
284
244
  // TODO create an issue here https://github.com/benjamine/jsondiffpatch/issues/new
285
245
  var DiffPatcher = require('jsondiffpatch').DiffPatcher;
286
-
287
246
  function objectHash(obj, index) {
288
247
  var objIndex = "$$index:".concat(index);
289
248
  return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
@@ -323,12 +282,12 @@
323
282
 
324
283
  if (arr.length === 3 && arr[2] === 2) {
325
284
  // text diff
326
- 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
327
-
285
+ if (!originalObject) throw new Error('Cannot apply patch to long text diff. Missing original object.');
286
+ // try to apply patch to given object based on delta value
328
287
  return patch(originalObject, arr);
329
288
  }
330
-
331
- if (arr.length === 3 && arr[2] === 3) // array move
289
+ if (arr.length === 3 && arr[2] === 3)
290
+ // array move
332
291
  throw new Error('Detected an array move, it should not happen as ' + '`includeValueOnMove` should be set to false');
333
292
  throw new Error("Got unsupported number ".concat(arr[2], " in delta value"));
334
293
  }
@@ -338,52 +297,39 @@
338
297
  setCustomType: 'setCustomType',
339
298
  setCustomField: 'setCustomField'
340
299
  };
341
-
342
300
  var hasSingleCustomFieldChanged = function hasSingleCustomFieldChanged(diff) {
343
301
  return Array.isArray(diff.custom);
344
302
  };
345
-
346
303
  var haveMultipleCustomFieldsChanged = function haveMultipleCustomFieldsChanged(diff) {
347
304
  return Boolean(diff.custom.fields);
348
305
  };
349
-
350
306
  var hasCustomTypeChanged = function hasCustomTypeChanged(diff) {
351
307
  return Boolean(diff.custom.type);
352
308
  };
353
-
354
309
  var extractCustomType = function extractCustomType(diff, previousObject) {
355
310
  return Array.isArray(diff.custom.type) ? getDeltaValue(diff.custom.type, previousObject) : diff.custom.type;
356
311
  };
357
-
358
312
  var extractTypeId = function extractTypeId(type, nextObject) {
359
313
  return Array.isArray(type.id) ? getDeltaValue(type.id) : nextObject.custom.type.id;
360
314
  };
361
-
362
315
  var extractTypeKey = function extractTypeKey(type, nextObject) {
363
316
  return Array.isArray(type.key) ? getDeltaValue(type.key) : nextObject.custom.type.key;
364
317
  };
365
-
366
318
  var extractTypeFields = function extractTypeFields(diffedFields, nextFields) {
367
319
  return Array.isArray(diffedFields) ? getDeltaValue(diffedFields) : nextFields;
368
320
  };
369
-
370
321
  var extractFieldValue = function extractFieldValue(newFields, fieldName) {
371
322
  return newFields[fieldName];
372
323
  };
373
-
374
324
  function actionsMapCustom(diff, newObj, oldObj) {
375
325
  var customProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
376
326
  actions: {}
377
327
  };
378
328
  var actions = [];
379
-
380
329
  var customPropsActions = customProps.actions,
381
- options = _objectWithoutProperties(customProps, _excluded);
382
-
330
+ options = _objectWithoutProperties(customProps, _excluded);
383
331
  var actionGroup = _objectSpread2(_objectSpread2({}, Actions), customPropsActions);
384
-
385
332
  if (!diff.custom) return actions;
386
-
387
333
  if (hasSingleCustomFieldChanged(diff)) {
388
334
  // If custom is not defined on the new or old category
389
335
  var custom = getDeltaValue(diff.custom, oldObj);
@@ -423,7 +369,6 @@
423
369
  });
424
370
  actions.push.apply(actions, _toConsumableArray(customFieldsActions));
425
371
  }
426
-
427
372
  return actions;
428
373
  }
429
374
 
@@ -432,6 +377,7 @@
432
377
  var ADD_ACTIONS = 'create';
433
378
  var REMOVE_ACTIONS = 'remove';
434
379
  var CHANGE_ACTIONS = 'change';
380
+
435
381
  /**
436
382
  * Tests a delta to see if it represents a create action.
437
383
  * eg. delta:
@@ -444,10 +390,10 @@
444
390
  * @return {Boolean} Returns true if delta represents a create action,
445
391
  * false otherwise
446
392
  */
447
-
448
393
  function isCreateAction(obj, key) {
449
394
  return REGEX_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 1;
450
395
  }
396
+
451
397
  /**
452
398
  * Tests a delta to see if it represents a change action.
453
399
  * eg. delta:
@@ -462,11 +408,10 @@
462
408
  * @return {Boolean} Returns true if delta represents a change action,
463
409
  * false otherwise
464
410
  */
465
-
466
-
467
411
  function isChangeAction(obj, key) {
468
412
  return REGEX_NUMBER$4.test(key) && (_typeof(obj[key]) === 'object' || typeof obj[key] === 'string');
469
413
  }
414
+
470
415
  /**
471
416
  * Tests a delta to see if it represents a remove action.
472
417
  * eg. delta:
@@ -479,11 +424,10 @@
479
424
  * @return {Boolean} Returns true if delta represents a remove action,
480
425
  * false otherwise
481
426
  */
482
-
483
-
484
427
  function isRemoveAction$1(obj, key) {
485
428
  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;
486
429
  }
430
+
487
431
  /**
488
432
  * Generate + configure a function to build actions for nested objects
489
433
  * @param {string} key key of the attribute containing the array of
@@ -494,39 +438,33 @@
494
438
  * return an action object.
495
439
  * @return {Array} The generated array of actions
496
440
  */
497
-
498
-
499
441
  function createBuildArrayActions(key, config) {
500
442
  return function buildArrayActions(diff, oldObj, newObj) {
501
443
  var addActions = [];
502
444
  var removeActions = [];
503
445
  var changeActions = [];
504
-
505
446
  if (diff[key]) {
506
447
  var arrayDelta = diff[key];
507
448
  Object.keys(arrayDelta).forEach(function (index) {
508
449
  if (config[ADD_ACTIONS] && isCreateAction(arrayDelta, index)) {
509
- var actionGenerator = config[ADD_ACTIONS]; // When adding a new element you don't need the oldObj
510
-
450
+ var actionGenerator = config[ADD_ACTIONS];
451
+ // When adding a new element you don't need the oldObj
511
452
  var action = actionGenerator(newObj[key][index], parseInt(index, 10));
512
453
  if (action) addActions.push(action);
513
454
  } else if (config[CHANGE_ACTIONS] && isChangeAction(arrayDelta, index)) {
514
- var _actionGenerator = config[CHANGE_ACTIONS]; // When changing an existing element you need both old + new
515
-
455
+ var _actionGenerator = config[CHANGE_ACTIONS];
456
+ // When changing an existing element you need both old + new
516
457
  var _action = _actionGenerator(oldObj[key][index], newObj[key][index], parseInt(index, 10));
517
-
518
458
  if (_action) changeActions.push(_action);
519
459
  } else if (config[REMOVE_ACTIONS] && isRemoveAction$1(arrayDelta, index)) {
520
460
  var realIndex = index.replace('_', '');
521
- var _actionGenerator2 = config[REMOVE_ACTIONS]; // When removing an existing element you don't need the newObj
522
-
461
+ var _actionGenerator2 = config[REMOVE_ACTIONS];
462
+ // When removing an existing element you don't need the newObj
523
463
  var _action2 = _actionGenerator2(oldObj[key][realIndex], parseInt(realIndex, 10));
524
-
525
464
  if (_action2) removeActions.push(_action2);
526
465
  }
527
466
  });
528
467
  }
529
-
530
468
  return changeActions.concat(removeActions, addActions);
531
469
  };
532
470
  }
@@ -539,21 +477,19 @@
539
477
  };
540
478
  return assetIdentifier;
541
479
  }
542
-
543
480
  function actionsMapAssets$1(diff, oldObj, newObj) {
544
- var _createBuildArrayActi;
545
-
546
- var handler = createBuildArrayActions('assets', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAsset) {
481
+ var handler = createBuildArrayActions('assets', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAsset) {
547
482
  return {
548
483
  action: 'addAsset',
549
484
  asset: newAsset
550
485
  };
551
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAsset) {
486
+ }), REMOVE_ACTIONS, function (oldAsset) {
552
487
  return _objectSpread2({
553
488
  action: 'removeAsset'
554
489
  }, toAssetIdentifier$1(oldAsset));
555
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAsset, newAsset) {
556
- return (// here we could use more atomic update actions (e.g. changeAssetName)
490
+ }), CHANGE_ACTIONS, function (oldAsset, newAsset) {
491
+ return (
492
+ // here we could use more atomic update actions (e.g. changeAssetName)
557
493
  // but for now we use the simpler approach to first remove and then
558
494
  // re-add the asset - which reduces the code complexity
559
495
  [_objectSpread2({
@@ -563,7 +499,7 @@
563
499
  asset: newAsset
564
500
  }]
565
501
  );
566
- }), _createBuildArrayActi));
502
+ }));
567
503
  return handler(diff, oldObj, newObj);
568
504
  }
569
505
 
@@ -574,7 +510,6 @@
574
510
  var normalizeValue = function normalizeValue(value) {
575
511
  return typeof value === 'string' ? value.trim() : value;
576
512
  };
577
-
578
513
  var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
579
514
  return function (value) {
580
515
  return emptyValues.some(function (emptyValue) {
@@ -582,6 +517,7 @@
582
517
  });
583
518
  };
584
519
  };
520
+
585
521
  /**
586
522
  * Builds actions for simple object properties, given a list of actions
587
523
  * E.g. [{ action: `changeName`, key: 'name' }]
@@ -593,17 +529,15 @@
593
529
  * @param {Object} options.newObj - the new representation of the object
594
530
  * @param {Boolean} options.shouldOmitEmptyString - a flag to determine if we should treat an empty string a NON-value
595
531
  */
596
-
597
532
  function buildBaseAttributesActions(_ref) {
598
533
  var actions = _ref.actions,
599
- diff = _ref.diff,
600
- oldObj = _ref.oldObj,
601
- newObj = _ref.newObj,
602
- shouldOmitEmptyString = _ref.shouldOmitEmptyString;
534
+ diff = _ref.diff,
535
+ oldObj = _ref.oldObj,
536
+ newObj = _ref.newObj,
537
+ shouldOmitEmptyString = _ref.shouldOmitEmptyString;
603
538
  var isEmptyValue = createIsEmptyValue(shouldOmitEmptyString ? [undefined, null, ''] : [undefined, null]);
604
539
  return actions.map(function (item) {
605
540
  var key = item.key; // e.g.: name, description, ...
606
-
607
541
  var actionKey = item.actionKey || item.key;
608
542
  var delta = diff[key];
609
543
  var before = oldObj[key];
@@ -612,18 +546,21 @@
612
546
  var isNotDefinedNow = isEmptyValue(newObj[key]);
613
547
  if (!delta) return undefined;
614
548
  if (isNotDefinedNow && isNotDefinedBefore) return undefined;
615
- if (!isNotDefinedNow && isNotDefinedBefore) // no value previously set
549
+ if (!isNotDefinedNow && isNotDefinedBefore)
550
+ // no value previously set
616
551
  return _defineProperty({
617
552
  action: item.action
618
553
  }, actionKey, now);
619
- /* no new value */
620
554
 
555
+ /* no new value */
621
556
  if (isNotDefinedNow && !{}.hasOwnProperty.call(newObj, key)) return undefined;
622
- if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key)) // value unset
557
+ if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key))
558
+ // value unset
623
559
  return {
624
560
  action: item.action
625
- }; // We need to clone `before` as `patch` will mutate it
561
+ };
626
562
 
563
+ // We need to clone `before` as `patch` will mutate it
627
564
  var patched = patch(clone(before), delta);
628
565
  return _defineProperty({
629
566
  action: item.action
@@ -632,6 +569,7 @@
632
569
  return !isNil__default["default"](action);
633
570
  });
634
571
  }
572
+
635
573
  /**
636
574
  * Builds actions for simple reference objects, given a list of actions
637
575
  * E.g. [{ action: `setTaxCategory`, key: 'taxCategory' }]
@@ -642,23 +580,24 @@
642
580
  * @param {Object} options.oldObj - the object that needs to be updated
643
581
  * @param {Object} options.newObj - the new representation of the object
644
582
  */
645
-
646
583
  function buildReferenceActions(_ref4) {
647
584
  var actions = _ref4.actions,
648
- diff = _ref4.diff,
649
- newObj = _ref4.newObj;
585
+ diff = _ref4.diff,
586
+ newObj = _ref4.newObj;
650
587
  return actions.map(function (item) {
651
588
  var action = item.action;
652
589
  var key = item.key;
653
-
654
- if (diff[key] && ( // The `key` value was added or removed
655
- Array.isArray(diff[key]) || // The `key` value id changed
590
+ if (diff[key] && (
591
+ // The `key` value was added or removed
592
+ Array.isArray(diff[key]) ||
593
+ // The `key` value id changed
656
594
  diff[key].id)) {
657
595
  var newValue = Array.isArray(diff[key]) ? getDeltaValue(diff[key]) : newObj[key];
658
596
  if (!newValue) return {
659
597
  action: action
660
- }; // When the `id` of the object is undefined
598
+ };
661
599
 
600
+ // When the `id` of the object is undefined
662
601
  if (!newValue.id) {
663
602
  return _defineProperty({
664
603
  action: action
@@ -667,7 +606,6 @@
667
606
  key: newValue.key
668
607
  });
669
608
  }
670
-
671
609
  return _defineProperty({
672
610
  action: action
673
611
  }, key, {
@@ -675,7 +613,6 @@
675
613
  id: newValue.id
676
614
  });
677
615
  }
678
-
679
616
  return undefined;
680
617
  }).filter(function (action) {
681
618
  return action;
@@ -715,6 +652,7 @@
715
652
  action: 'changeParent',
716
653
  key: 'parent'
717
654
  }];
655
+
718
656
  /**
719
657
  * SYNC FUNCTIONS
720
658
  */
@@ -747,6 +685,7 @@
747
685
  }
748
686
 
749
687
  var CUSTOM = 'custom';
688
+
750
689
  /**
751
690
  * @function copyEmptyArrayProps
752
691
  * @description Create new key with empty array value on `newobj` for the arrays exist on `oldObj` and doesnt exist on `newobj`
@@ -755,74 +694,60 @@
755
694
  * @param {Object} newObj
756
695
  * @returns {Array} Ordered Array [oldObj, newObj]
757
696
  */
758
-
759
697
  function copyEmptyArrayProps() {
760
698
  var oldObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
761
699
  var newObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
762
-
763
700
  if (!isNil__default["default"](oldObj) && !isNil__default["default"](newObj)) {
764
701
  var nextObjectWithEmptyArray = Object.entries(oldObj).reduce(function (merged, _ref) {
765
702
  var _ref2 = _slicedToArray(_ref, 2),
766
- key = _ref2[0],
767
- value = _ref2[1];
768
-
703
+ key = _ref2[0],
704
+ value = _ref2[1];
769
705
  // Ignore CUSTOM key as this object is dynamic and its up to the user to dynamically change it
770
706
  // todo, it would be better if we pass it as ignored keys param
771
707
  if (key === CUSTOM) return merged;
772
-
773
708
  if (Array.isArray(value) && newObj[key] && newObj[key].length >= 1) {
774
709
  /* eslint-disable no-plusplus */
775
710
  var hashMapValue = value.reduce(function (acc, val) {
776
711
  acc[val.id] = val;
777
712
  return acc;
778
713
  }, {});
779
-
780
714
  for (var i = 0; i < newObj[key].length; i++) {
781
715
  if (!isNil__default["default"](newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil__default["default"](newObj[key][i].id)) {
782
716
  // Since its unordered array elements then check if the element on `oldObj` exists by id
783
717
  var foundObject = hashMapValue[newObj[key][i].id];
784
-
785
718
  if (!isNil__default["default"](foundObject)) {
786
719
  var _copyEmptyArrayProps = copyEmptyArrayProps(foundObject, newObj[key][i]),
787
- _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
788
- nestedObject = _copyEmptyArrayProps2[1];
789
-
720
+ _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
721
+ nestedObject = _copyEmptyArrayProps2[1];
790
722
  if (Object.isFrozen(merged[key])) {
791
723
  /* eslint-disable no-param-reassign */
792
724
  merged[key] = merged[key].slice();
793
725
  }
794
726
  /* eslint-disable no-param-reassign */
795
-
796
-
797
727
  merged[key][i] = nestedObject;
798
728
  }
799
729
  }
800
730
  }
801
-
802
731
  return merged;
803
732
  }
804
-
805
733
  if (Array.isArray(value)) {
806
734
  merged[key] = isNil__default["default"](newObj[key]) ? [] : newObj[key];
807
735
  return merged;
808
736
  }
809
-
810
- if (!isNil__default["default"](newObj[key]) && _typeof(value) === 'object' && // Ignore Date as this will create invalid object since typeof date === 'object' return true
737
+ if (!isNil__default["default"](newObj[key]) && _typeof(value) === 'object' &&
738
+ // Ignore Date as this will create invalid object since typeof date === 'object' return true
811
739
  // ex: {date: new Date()} will result {date: {}}
812
740
  !(value instanceof Date)) {
813
741
  var _copyEmptyArrayProps3 = copyEmptyArrayProps(value, newObj[key]),
814
- _copyEmptyArrayProps4 = _slicedToArray(_copyEmptyArrayProps3, 2),
815
- _nestedObject = _copyEmptyArrayProps4[1];
816
-
742
+ _copyEmptyArrayProps4 = _slicedToArray(_copyEmptyArrayProps3, 2),
743
+ _nestedObject = _copyEmptyArrayProps4[1];
817
744
  merged[key] = _nestedObject;
818
745
  return merged;
819
746
  }
820
-
821
747
  return merged;
822
748
  }, _objectSpread2({}, newObj));
823
749
  return [oldObj, nextObjectWithEmptyArray];
824
750
  }
825
-
826
751
  return [oldObj, newObj];
827
752
  }
828
753
 
@@ -847,14 +772,15 @@
847
772
  return flatten__default["default"](allActions);
848
773
  };
849
774
  }
850
-
851
775
  var categories = (function (actionGroupList, syncActionConfig) {
852
776
  // actionGroupList contains information about which action groups
853
777
  // are allowed or ignored
778
+
854
779
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
855
780
  // - action group name
856
781
  // - callback function that should return a list of actions that correspond
857
782
  // to the for the action group
783
+
858
784
  // this resulting function mapActionGroup will call the callback function
859
785
  // for allowed action groups and return the return value of the callback
860
786
  // It will return an empty array for ignored action groups
@@ -928,6 +854,7 @@
928
854
  key: 'authenticationMode',
929
855
  value: 'password'
930
856
  }];
857
+
931
858
  /**
932
859
  * SYNC FUNCTIONS
933
860
  */
@@ -961,57 +888,51 @@
961
888
  });
962
889
  }
963
890
  function actionsMapAddresses(diff, oldObj, newObj) {
964
- var _createBuildArrayActi;
965
-
966
- var handler = createBuildArrayActions('addresses', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newObject) {
891
+ var handler = createBuildArrayActions('addresses', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
967
892
  return {
968
893
  action: 'addAddress',
969
894
  address: newObject
970
895
  };
971
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (objectToRemove) {
896
+ }), REMOVE_ACTIONS, function (objectToRemove) {
972
897
  return {
973
898
  action: 'removeAddress',
974
899
  addressId: objectToRemove.id
975
900
  };
976
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldObject, updatedObject) {
901
+ }), CHANGE_ACTIONS, function (oldObject, updatedObject) {
977
902
  return {
978
903
  action: 'changeAddress',
979
904
  addressId: oldObject.id,
980
905
  address: updatedObject
981
906
  };
982
- }), _createBuildArrayActi));
907
+ }));
983
908
  return handler(diff, oldObj, newObj);
984
909
  }
985
910
  function actionsMapBillingAddresses(diff, oldObj, newObj) {
986
- var _createBuildArrayActi2;
987
-
988
- var handler = createBuildArrayActions('billingAddressIds', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (addressId) {
911
+ var handler = createBuildArrayActions('billingAddressIds', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (addressId) {
989
912
  return {
990
913
  action: 'addBillingAddressId',
991
914
  addressId: addressId
992
915
  };
993
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (addressId) {
916
+ }), REMOVE_ACTIONS, function (addressId) {
994
917
  return {
995
918
  action: 'removeBillingAddressId',
996
919
  addressId: addressId
997
920
  };
998
- }), _createBuildArrayActi2));
921
+ }));
999
922
  return handler(diff, oldObj, newObj);
1000
923
  }
1001
924
  function actionsMapShippingAddresses(diff, oldObj, newObj) {
1002
- var _createBuildArrayActi3;
1003
-
1004
- var handler = createBuildArrayActions('shippingAddressIds', (_createBuildArrayActi3 = {}, _defineProperty(_createBuildArrayActi3, ADD_ACTIONS, function (addressId) {
925
+ var handler = createBuildArrayActions('shippingAddressIds', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (addressId) {
1005
926
  return {
1006
927
  action: 'addShippingAddressId',
1007
928
  addressId: addressId
1008
929
  };
1009
- }), _defineProperty(_createBuildArrayActi3, REMOVE_ACTIONS, function (addressId) {
930
+ }), REMOVE_ACTIONS, function (addressId) {
1010
931
  return {
1011
932
  action: 'removeShippingAddressId',
1012
933
  addressId: addressId
1013
934
  };
1014
- }), _createBuildArrayActi3));
935
+ }));
1015
936
  return handler(diff, oldObj, newObj);
1016
937
  }
1017
938
  function actionsMapAuthenticationModes(diff, oldObj, newObj) {
@@ -1023,12 +944,11 @@
1023
944
  newObj: newObj
1024
945
  });
1025
946
  }
1026
-
1027
947
  function buildAuthenticationModeActions(_ref) {
1028
948
  var actions = _ref.actions,
1029
- diff = _ref.diff,
1030
- oldObj = _ref.oldObj,
1031
- newObj = _ref.newObj;
949
+ diff = _ref.diff,
950
+ oldObj = _ref.oldObj,
951
+ newObj = _ref.newObj;
1032
952
  return actions.map(function (item) {
1033
953
  var key = item.key;
1034
954
  var value = item.value || item.key;
@@ -1042,7 +962,6 @@
1042
962
  if (isNotDefinedNow && isNotDefinedBefore) return undefined;
1043
963
  if (newObj.authenticationMode === 'Password' && !newObj.password) throw new Error('Cannot set to Password authentication mode without password');
1044
964
  if ('authenticationMode' in newObj && !authenticationModes.includes(newObj.authenticationMode)) throw new Error('Invalid Authentication Mode');
1045
-
1046
965
  if (!isNotDefinedNow && isNotDefinedBefore) {
1047
966
  // no value previously set
1048
967
  if (newObj.authenticationMode === 'ExternalAuth') return {
@@ -1054,13 +973,14 @@
1054
973
  authMode: now
1055
974
  }, value, newObj.password);
1056
975
  }
1057
- /* no new value */
1058
-
1059
976
 
977
+ /* no new value */
1060
978
  if (isNotDefinedNow && !{}.hasOwnProperty.call(newObj, key)) return undefined;
1061
- if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key)) // value unset
1062
- return undefined; // We need to clone `before` as `patch` will mutate it
979
+ if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key))
980
+ // value unset
981
+ return undefined;
1063
982
 
983
+ // We need to clone `before` as `patch` will mutate it
1064
984
  var patched = patch(clone(before), delta);
1065
985
  if (newObj.authenticationMode === 'ExternalAuth') return {
1066
986
  action: item.action,
@@ -1105,14 +1025,15 @@
1105
1025
  return flatten__default["default"](allActions);
1106
1026
  };
1107
1027
  }
1108
-
1109
1028
  var customers = (function (actionGroupList, syncActionConfig) {
1110
1029
  // actionGroupList contains information about which action groups
1111
1030
  // are allowed or ignored
1031
+
1112
1032
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
1113
1033
  // - action group name
1114
1034
  // - callback function that should return a list of actions that correspond
1115
1035
  // to the for the action group
1036
+
1116
1037
  // this resulting function mapActionGroup will call the callback function
1117
1038
  // for allowed action groups and return the return value of the callback
1118
1039
  // It will return an empty array for ignored action groups
@@ -1139,6 +1060,7 @@
1139
1060
  action: 'setSupplyChannel',
1140
1061
  key: 'supplyChannel'
1141
1062
  }];
1063
+
1142
1064
  /**
1143
1065
  * SYNC FUNCTIONS
1144
1066
  */
@@ -1177,14 +1099,15 @@
1177
1099
  return flatten__default["default"](allActions);
1178
1100
  };
1179
1101
  }
1180
-
1181
1102
  var inventories = (function (actionGroupList, syncActionConfig) {
1182
1103
  // actionGroupList contains information about which action groups
1183
1104
  // are allowed or ignored
1105
+
1184
1106
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
1185
1107
  // - action group name
1186
1108
  // - callback function that should return a list of actions that correspond
1187
1109
  // to the for the action group
1110
+
1188
1111
  // this resulting function mapActionGroup will call the callback function
1189
1112
  // for allowed action groups and return the return value of the callback
1190
1113
  // It will return an empty array for ignored action groups
@@ -1201,14 +1124,12 @@
1201
1124
  var newObjPos;
1202
1125
  var oldObj;
1203
1126
  var newObj;
1204
-
1205
1127
  if (hashMap[key]) {
1206
1128
  oldObjPos = hashMap[key][0];
1207
1129
  newObjPos = hashMap[key][1];
1208
1130
  if (before && before[oldObjPos]) oldObj = before[oldObjPos];
1209
1131
  if (now && now[newObjPos]) newObj = now[newObjPos];
1210
1132
  }
1211
-
1212
1133
  return {
1213
1134
  oldObj: oldObj,
1214
1135
  newObj: newObj
@@ -1217,7 +1138,6 @@
1217
1138
 
1218
1139
  var REGEX_NUMBER$3 = new RegExp(/^\d+$/);
1219
1140
  var REGEX_UNDERSCORE_NUMBER$3 = new RegExp(/^_\d+$/);
1220
-
1221
1141
  function preProcessCollection() {
1222
1142
  var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1223
1143
  var identifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
@@ -1229,23 +1149,20 @@
1229
1149
  refByIndex: {},
1230
1150
  refByIdentifier: {}
1231
1151
  });
1232
- } // creates a hash of a location of an item in collection1 and collection2
1233
-
1152
+ }
1234
1153
 
1154
+ // creates a hash of a location of an item in collection1 and collection2
1235
1155
  function findMatchingPairs(diff) {
1236
1156
  var before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1237
1157
  var now = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
1238
1158
  var identifier = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'id';
1239
1159
  var result = {};
1240
-
1241
1160
  var _preProcessCollection = preProcessCollection(before, identifier),
1242
- beforeObjRefByIdentifier = _preProcessCollection.refByIdentifier,
1243
- beforeObjRefByIndex = _preProcessCollection.refByIndex;
1244
-
1161
+ beforeObjRefByIdentifier = _preProcessCollection.refByIdentifier,
1162
+ beforeObjRefByIndex = _preProcessCollection.refByIndex;
1245
1163
  var _preProcessCollection2 = preProcessCollection(now, identifier),
1246
- nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
1247
- nowObjRefByIndex = _preProcessCollection2.refByIndex;
1248
-
1164
+ nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
1165
+ nowObjRefByIndex = _preProcessCollection2.refByIndex;
1249
1166
  forEach__default["default"](diff, function (item, key) {
1250
1167
  if (REGEX_NUMBER$3.test(key)) {
1251
1168
  var matchingIdentifier = nowObjRefByIndex[key];
@@ -1314,6 +1231,7 @@
1314
1231
  action: 'transitionState',
1315
1232
  key: 'state'
1316
1233
  }];
1234
+
1317
1235
  /**
1318
1236
  * HELPER FUNCTIONS
1319
1237
  */
@@ -1321,19 +1239,15 @@
1321
1239
  var getIsAddAction = function getIsAddAction(key, resource) {
1322
1240
  return REGEX_NUMBER$2.test(key) && Array.isArray(resource) && resource.length;
1323
1241
  };
1324
-
1325
1242
  var getIsUpdateAction = function getIsUpdateAction(key, resource) {
1326
1243
  return REGEX_NUMBER$2.test(key) && Object.keys(resource).length;
1327
1244
  };
1328
-
1329
1245
  var getIsRemoveAction = function getIsRemoveAction(key, resource) {
1330
1246
  return REGEX_UNDERSCORE_NUMBER$2.test(key) && Number(resource[2]) === 0;
1331
1247
  };
1332
-
1333
1248
  var getIsItemMovedAction = function getIsItemMovedAction(key, resource) {
1334
1249
  return REGEX_UNDERSCORE_NUMBER$2.test(key) && Number(resource[2]) === 3;
1335
1250
  };
1336
-
1337
1251
  function _buildSkuActions(variantDiff, oldVariant) {
1338
1252
  if ({}.hasOwnProperty.call(variantDiff, 'sku')) {
1339
1253
  var newValue = getDeltaValue(variantDiff.sku);
@@ -1344,10 +1258,8 @@
1344
1258
  sku: newValue || null
1345
1259
  };
1346
1260
  }
1347
-
1348
1261
  return null;
1349
1262
  }
1350
-
1351
1263
  function _buildKeyActions(variantDiff, oldVariant) {
1352
1264
  if ({}.hasOwnProperty.call(variantDiff, 'key')) {
1353
1265
  var newValue = getDeltaValue(variantDiff.key);
@@ -1358,10 +1270,8 @@
1358
1270
  key: newValue || null
1359
1271
  };
1360
1272
  }
1361
-
1362
1273
  return null;
1363
1274
  }
1364
-
1365
1275
  function _buildNewSetAttributeAction(id, el, sameForAllAttributeNames) {
1366
1276
  var attributeName = el && el.name;
1367
1277
  if (!attributeName) return undefined;
@@ -1371,47 +1281,47 @@
1371
1281
  name: attributeName,
1372
1282
  value: el.value
1373
1283
  };
1374
-
1375
1284
  if (sameForAllAttributeNames.indexOf(attributeName) !== -1) {
1376
1285
  action = _objectSpread2(_objectSpread2({}, action), {}, {
1377
1286
  action: 'setAttributeInAllVariants'
1378
1287
  });
1379
1288
  delete action.variantId;
1380
1289
  }
1381
-
1382
1290
  return action;
1383
1291
  }
1384
-
1385
1292
  function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAllAttributeNames) {
1386
1293
  if (!attribute) return undefined;
1387
1294
  var action = {
1388
1295
  action: 'setAttribute',
1389
1296
  variantId: oldVariant.id,
1390
1297
  name: attribute.name
1391
- }; // Used as original object for patching long diff text
1298
+ };
1392
1299
 
1300
+ // Used as original object for patching long diff text
1393
1301
  var oldAttribute = oldVariant.attributes.find(function (a) {
1394
1302
  return a.name === attribute.name;
1395
1303
  }) || {};
1396
-
1397
1304
  if (sameForAllAttributeNames.indexOf(attribute.name) !== -1) {
1398
1305
  action = _objectSpread2(_objectSpread2({}, action), {}, {
1399
1306
  action: 'setAttributeInAllVariants'
1400
1307
  });
1401
1308
  delete action.variantId;
1402
1309
  }
1403
-
1404
- if (Array.isArray(diffedValue)) action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (typeof diffedValue === 'string') // LText: value: {en: "", de: ""}
1310
+ if (Array.isArray(diffedValue)) action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (typeof diffedValue === 'string')
1311
+ // LText: value: {en: "", de: ""}
1405
1312
  // Enum: value: {key: "foo", label: "Foo"}
1406
1313
  // LEnum: value: {key: "foo", label: {en: "Foo", de: "Foo"}}
1407
1314
  // Money: value: {centAmount: 123, currencyCode: ""}
1408
1315
  // *: value: ""
1316
+
1409
1317
  // normal
1410
- action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (diffedValue.centAmount || diffedValue.currencyCode) // Money
1318
+ action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (diffedValue.centAmount || diffedValue.currencyCode)
1319
+ // Money
1411
1320
  action.value = {
1412
1321
  centAmount: diffedValue.centAmount ? getDeltaValue(diffedValue.centAmount) : attribute.value.centAmount,
1413
1322
  currencyCode: diffedValue.currencyCode ? getDeltaValue(diffedValue.currencyCode) : attribute.value.currencyCode
1414
- };else if (diffedValue.key) // Enum / LEnum (use only the key)
1323
+ };else if (diffedValue.key)
1324
+ // Enum / LEnum (use only the key)
1415
1325
  action.value = getDeltaValue(diffedValue.key);else if (_typeof(diffedValue) === 'object') if ({}.hasOwnProperty.call(diffedValue, '_t') && diffedValue._t === 'a') {
1416
1326
  // set-typed attribute
1417
1327
  action = _objectSpread2(_objectSpread2({}, action), {}, {
@@ -1419,6 +1329,7 @@
1419
1329
  });
1420
1330
  } else {
1421
1331
  // LText
1332
+
1422
1333
  var updatedValue = Object.keys(diffedValue).reduce(function (acc, lang) {
1423
1334
  var patchedValue = getDeltaValue(diffedValue[lang], acc[lang]);
1424
1335
  return Object.assign(acc, _defineProperty({}, lang, patchedValue));
@@ -1427,18 +1338,16 @@
1427
1338
  }
1428
1339
  return action;
1429
1340
  }
1430
-
1431
1341
  function _buildVariantImagesAction(diffedImages) {
1432
1342
  var oldVariant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1433
1343
  var newVariant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1434
- var actions = []; // generate a hashMap to be able to reference the right image from both ends
1435
-
1344
+ var actions = [];
1345
+ // generate a hashMap to be able to reference the right image from both ends
1436
1346
  var matchingImagePairs = findMatchingPairs(diffedImages, oldVariant.images, newVariant.images, 'url');
1437
1347
  forEach__default["default"](diffedImages, function (image, key) {
1438
1348
  var _extractMatchingPairs = extractMatchingPairs(matchingImagePairs, key, oldVariant.images, newVariant.images),
1439
- oldObj = _extractMatchingPairs.oldObj,
1440
- newObj = _extractMatchingPairs.newObj;
1441
-
1349
+ oldObj = _extractMatchingPairs.oldObj,
1350
+ newObj = _extractMatchingPairs.newObj;
1442
1351
  if (REGEX_NUMBER$2.test(key)) {
1443
1352
  // New image
1444
1353
  if (Array.isArray(image) && image.length) actions.push({
@@ -1464,13 +1373,15 @@
1464
1373
  label: getDeltaValue(image.label)
1465
1374
  });
1466
1375
  } else if (REGEX_UNDERSCORE_NUMBER$2.test(key)) if (Array.isArray(image) && image.length === 3) {
1467
- if (Number(image[2]) === 3) // image position changed
1376
+ if (Number(image[2]) === 3)
1377
+ // image position changed
1468
1378
  actions.push({
1469
1379
  action: 'moveImageToPosition',
1470
1380
  variantId: oldVariant.id,
1471
1381
  imageUrl: oldObj.url,
1472
1382
  position: Number(image[1])
1473
- });else if (Number(image[2]) === 0) // image removed
1383
+ });else if (Number(image[2]) === 0)
1384
+ // image removed
1474
1385
  actions.push({
1475
1386
  action: 'removeImage',
1476
1387
  variantId: oldVariant.id,
@@ -1480,26 +1391,24 @@
1480
1391
  });
1481
1392
  return actions;
1482
1393
  }
1483
-
1484
1394
  function _buildVariantPricesAction(diffedPrices) {
1485
1395
  var oldVariant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1486
1396
  var newVariant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1487
1397
  var enableDiscounted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1488
1398
  var addPriceActions = [];
1489
1399
  var changePriceActions = [];
1490
- var removePriceActions = []; // generate a hashMap to be able to reference the right image from both ends
1400
+ var removePriceActions = [];
1491
1401
 
1402
+ // generate a hashMap to be able to reference the right image from both ends
1492
1403
  var matchingPricePairs = findMatchingPairs(diffedPrices, oldVariant.prices, newVariant.prices);
1493
1404
  forEach__default["default"](diffedPrices, function (price, key) {
1494
1405
  var _extractMatchingPairs2 = extractMatchingPairs(matchingPricePairs, key, oldVariant.prices, newVariant.prices),
1495
- oldObj = _extractMatchingPairs2.oldObj,
1496
- newObj = _extractMatchingPairs2.newObj;
1497
-
1406
+ oldObj = _extractMatchingPairs2.oldObj,
1407
+ newObj = _extractMatchingPairs2.newObj;
1498
1408
  if (getIsAddAction(key, price)) {
1499
1409
  // Remove read-only fields
1500
1410
  var patchedPrice = price.map(function (p) {
1501
1411
  var shallowClone = _objectSpread2({}, p);
1502
-
1503
1412
  if (enableDiscounted !== true) delete shallowClone.discounted;
1504
1413
  return shallowClone;
1505
1414
  });
@@ -1510,18 +1419,14 @@
1510
1419
  });
1511
1420
  return;
1512
1421
  }
1513
-
1514
1422
  if (getIsUpdateAction(key, price)) {
1515
1423
  // Remove the discounted field and make sure that the price
1516
1424
  // still has other values, otherwise simply return
1517
1425
  var filteredPrice = _objectSpread2({}, price);
1518
-
1519
1426
  if (enableDiscounted !== true) delete filteredPrice.discounted;
1520
-
1521
1427
  if (Object.keys(filteredPrice).length) {
1522
1428
  // At this point price should have changed, simply pick the new one
1523
1429
  var newPrice = _objectSpread2({}, newObj);
1524
-
1525
1430
  if (enableDiscounted !== true) delete newPrice.discounted;
1526
1431
  changePriceActions.push({
1527
1432
  action: 'changePrice',
@@ -1529,10 +1434,8 @@
1529
1434
  price: newPrice
1530
1435
  });
1531
1436
  }
1532
-
1533
1437
  return;
1534
1438
  }
1535
-
1536
1439
  if (getIsRemoveAction(key, price)) {
1537
1440
  // price removed
1538
1441
  removePriceActions.push({
@@ -1543,7 +1446,6 @@
1543
1446
  });
1544
1447
  return [addPriceActions, changePriceActions, removePriceActions];
1545
1448
  }
1546
-
1547
1449
  function _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames) {
1548
1450
  var actions = [];
1549
1451
  if (!attributes) return actions;
@@ -1552,43 +1454,34 @@
1552
1454
  if (Array.isArray(value)) {
1553
1455
  var id = oldVariant.id;
1554
1456
  var deltaValue = getDeltaValue(value);
1555
-
1556
1457
  var setAction = _buildNewSetAttributeAction(id, deltaValue, sameForAllAttributeNames);
1557
-
1558
1458
  if (setAction) actions.push(setAction);
1559
1459
  } else if (newVariant.attributes) {
1560
1460
  var _setAction = _buildSetAttributeAction(value.value, oldVariant, newVariant.attributes[key], sameForAllAttributeNames);
1561
-
1562
1461
  if (_setAction) actions.push(_setAction);
1563
1462
  }
1564
1463
  } else if (REGEX_UNDERSCORE_NUMBER$2.test(key)) if (Array.isArray(value)) {
1565
1464
  // Ignore pure array moves!
1566
1465
  if (value.length === 3 && value[2] === 3) return;
1567
1466
  var _id = oldVariant.id;
1568
-
1569
1467
  var _deltaValue = getDeltaValue(value);
1570
-
1571
- if (!_deltaValue) if (value[0] && value[0].name) // unset attribute if
1468
+ if (!_deltaValue) if (value[0] && value[0].name)
1469
+ // unset attribute if
1572
1470
  _deltaValue = {
1573
1471
  name: value[0].name
1574
1472
  };else _deltaValue = undefined;
1575
-
1576
1473
  var _setAction2 = _buildNewSetAttributeAction(_id, _deltaValue, sameForAllAttributeNames);
1577
-
1578
1474
  if (_setAction2) actions.push(_setAction2);
1579
1475
  } else {
1580
1476
  var index = key.substring(1);
1581
-
1582
1477
  if (newVariant.attributes) {
1583
1478
  var _setAction3 = _buildSetAttributeAction(value.value, oldVariant, newVariant.attributes[index], sameForAllAttributeNames);
1584
-
1585
1479
  if (_setAction3) actions.push(_setAction3);
1586
1480
  }
1587
1481
  }
1588
1482
  });
1589
1483
  return actions;
1590
1484
  }
1591
-
1592
1485
  function toAssetIdentifier(asset) {
1593
1486
  var assetIdentifier = asset.id ? {
1594
1487
  assetId: asset.id
@@ -1597,26 +1490,22 @@
1597
1490
  };
1598
1491
  return assetIdentifier;
1599
1492
  }
1600
-
1601
1493
  function toVariantIdentifier(variant) {
1602
1494
  var id = variant.id,
1603
- sku = variant.sku;
1495
+ sku = variant.sku;
1604
1496
  return id ? {
1605
1497
  variantId: id
1606
1498
  } : {
1607
1499
  sku: sku
1608
1500
  };
1609
1501
  }
1610
-
1611
1502
  function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant) {
1612
1503
  var isAssetOrderChanged = Object.entries(diffAssets).find(function (entry) {
1613
1504
  return getIsItemMovedAction(entry[0], entry[1]);
1614
1505
  });
1615
-
1616
1506
  if (!isAssetOrderChanged) {
1617
1507
  return [];
1618
1508
  }
1619
-
1620
1509
  var assetIdsBefore = oldVariant.assets.map(function (_) {
1621
1510
  return _.id;
1622
1511
  });
@@ -1627,24 +1516,21 @@
1627
1516
  });
1628
1517
  var assetIdsToKeep = intersection__default["default"](assetIdsCurrent, assetIdsBefore);
1629
1518
  var assetIdsToRemove = without__default["default"].apply(void 0, [assetIdsBefore].concat(_toConsumableArray(assetIdsToKeep)));
1630
-
1631
1519
  var changeAssetOrderAction = _objectSpread2({
1632
1520
  action: 'changeAssetOrder',
1633
1521
  assetOrder: assetIdsToKeep.concat(assetIdsToRemove)
1634
1522
  }, toVariantIdentifier(oldVariant));
1635
-
1636
1523
  return [changeAssetOrderAction];
1637
1524
  }
1638
-
1639
1525
  function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1640
- var assetActions = []; // generate a hashMap to be able to reference the right asset from both ends
1526
+ var assetActions = [];
1641
1527
 
1528
+ // generate a hashMap to be able to reference the right asset from both ends
1642
1529
  var matchingAssetPairs = findMatchingPairs(diffAssets, oldVariant.assets, newVariant.assets);
1643
1530
  forEach__default["default"](diffAssets, function (asset, key) {
1644
1531
  var _extractMatchingPairs3 = extractMatchingPairs(matchingAssetPairs, key, oldVariant.assets, newVariant.assets),
1645
- oldAsset = _extractMatchingPairs3.oldObj,
1646
- newAsset = _extractMatchingPairs3.newObj;
1647
-
1532
+ oldAsset = _extractMatchingPairs3.oldObj,
1533
+ newAsset = _extractMatchingPairs3.newObj;
1648
1534
  if (getIsAddAction(key, asset)) {
1649
1535
  assetActions.push(_objectSpread2(_objectSpread2({
1650
1536
  action: 'addAsset',
@@ -1654,7 +1540,6 @@
1654
1540
  }));
1655
1541
  return;
1656
1542
  }
1657
-
1658
1543
  if (getIsUpdateAction(key, asset)) {
1659
1544
  // todo add changeAssetOrder
1660
1545
  var basicActions = buildBaseAttributesActions({
@@ -1669,11 +1554,9 @@
1669
1554
  assetId: oldAsset.id
1670
1555
  });
1671
1556
  }
1672
-
1673
1557
  return _objectSpread2(_objectSpread2(_objectSpread2({}, action), toVariantIdentifier(oldVariant)), toAssetIdentifier(oldAsset));
1674
1558
  });
1675
1559
  assetActions.push.apply(assetActions, _toConsumableArray(basicActions));
1676
-
1677
1560
  if (asset.custom) {
1678
1561
  var customActions = actionsMapCustom(asset, newAsset, oldAsset, _objectSpread2(_objectSpread2({
1679
1562
  actions: {
@@ -1683,26 +1566,22 @@
1683
1566
  }, toVariantIdentifier(oldVariant)), toAssetIdentifier(oldAsset)));
1684
1567
  assetActions.push.apply(assetActions, _toConsumableArray(customActions));
1685
1568
  }
1686
-
1687
1569
  return;
1688
1570
  }
1689
-
1690
1571
  if (getIsRemoveAction(key, asset)) {
1691
1572
  assetActions.push(_objectSpread2(_objectSpread2({
1692
1573
  action: 'removeAsset'
1693
1574
  }, toAssetIdentifier(oldAsset)), toVariantIdentifier(oldVariant)));
1694
1575
  }
1695
1576
  });
1696
-
1697
1577
  var changedAssetOrderAction = _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant);
1698
-
1699
1578
  return [].concat(_toConsumableArray(changedAssetOrderAction), assetActions);
1700
1579
  }
1580
+
1701
1581
  /**
1702
1582
  * SYNC FUNCTIONS
1703
1583
  */
1704
1584
 
1705
-
1706
1585
  function actionsMapBase$h(diff, oldObj, newObj) {
1707
1586
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1708
1587
  return buildBaseAttributesActions({
@@ -1757,7 +1636,6 @@
1757
1636
  var action = {
1758
1637
  category: category[0]
1759
1638
  };
1760
-
1761
1639
  if (category.length === 3) {
1762
1640
  // Ignore pure array moves!
1763
1641
  if (category[2] !== 3) {
@@ -1769,13 +1647,14 @@
1769
1647
  addToCategoryActions.push(action);
1770
1648
  }
1771
1649
  }
1772
- }); // Make sure `removeFromCategory` actions come first
1650
+ });
1773
1651
 
1652
+ // Make sure `removeFromCategory` actions come first
1774
1653
  return removeFromCategoryActions.concat(addToCategoryActions);
1775
1654
  }
1776
1655
  function actionsMapCategoryOrderHints(diff) {
1777
- if (!diff.categoryOrderHints) return []; // Ignore this pattern as its means no changes happened [{},0,0]
1778
-
1656
+ if (!diff.categoryOrderHints) return [];
1657
+ // Ignore this pattern as its means no changes happened [{},0,0]
1779
1658
  if (Array.isArray(diff.categoryOrderHints)) return [];
1780
1659
  return Object.keys(diff.categoryOrderHints).map(function (categoryId) {
1781
1660
  var hintChange = diff.categoryOrderHints[categoryId];
@@ -1783,9 +1662,13 @@
1783
1662
  action: 'setCategoryOrderHint',
1784
1663
  categoryId: categoryId
1785
1664
  };
1786
- if (hintChange.length === 1) // item was added
1787
- action.orderHint = hintChange[0];else if (hintChange.length === 2 && hintChange[1] !== 0) // item was changed
1788
- action.orderHint = hintChange[1]; // else item was removed -> do not set 'orderHint' property
1665
+ if (hintChange.length === 1)
1666
+ // item was added
1667
+ action.orderHint = hintChange[0];else if (hintChange.length === 2 && hintChange[1] !== 0)
1668
+ // item was changed
1669
+ action.orderHint = hintChange[1];
1670
+
1671
+ // else item was removed -> do not set 'orderHint' property
1789
1672
 
1790
1673
  return action;
1791
1674
  });
@@ -1795,12 +1678,10 @@
1795
1678
  var variants = diff.variants;
1796
1679
  if (variants) forEach__default["default"](variants, function (variant, key) {
1797
1680
  var _extractMatchingPairs4 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1798
- oldVariant = _extractMatchingPairs4.oldObj,
1799
- newVariant = _extractMatchingPairs4.newObj;
1800
-
1681
+ oldVariant = _extractMatchingPairs4.oldObj,
1682
+ newVariant = _extractMatchingPairs4.newObj;
1801
1683
  if (variant.assets && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
1802
1684
  var assetActions = _buildVariantAssetsActions(variant.assets, oldVariant, newVariant);
1803
-
1804
1685
  allAssetsActions = allAssetsActions.concat(assetActions);
1805
1686
  }
1806
1687
  });
@@ -1813,25 +1694,21 @@
1813
1694
  var variants = diff.variants;
1814
1695
  if (variants) forEach__default["default"](variants, function (variant, key) {
1815
1696
  var _extractMatchingPairs5 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1816
- oldVariant = _extractMatchingPairs5.oldObj,
1817
- newVariant = _extractMatchingPairs5.newObj;
1818
-
1697
+ oldVariant = _extractMatchingPairs5.oldObj,
1698
+ newVariant = _extractMatchingPairs5.newObj;
1819
1699
  if (REGEX_NUMBER$2.test(key) && !Array.isArray(variant)) {
1820
1700
  var skuAction = _buildSkuActions(variant, oldVariant);
1821
-
1822
1701
  var keyAction = _buildKeyActions(variant, oldVariant);
1823
-
1824
1702
  if (skuAction) actions.push(skuAction);
1825
1703
  if (keyAction) actions.push(keyAction);
1826
1704
  var attributes = variant.attributes;
1827
-
1828
1705
  var attrActions = _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames);
1829
-
1830
1706
  actions = actions.concat(attrActions);
1831
1707
  }
1832
- }); // Ensure that an action is unique.
1833
- // This is especially necessary for SFA attributes.
1708
+ });
1834
1709
 
1710
+ // Ensure that an action is unique.
1711
+ // This is especially necessary for SFA attributes.
1835
1712
  return uniqWith__default["default"](actions, function (a, b) {
1836
1713
  return a.action === b.action && a.name === b.name && a.variantId === b.variantId;
1837
1714
  });
@@ -1841,12 +1718,10 @@
1841
1718
  var variants = diff.variants;
1842
1719
  if (variants) forEach__default["default"](variants, function (variant, key) {
1843
1720
  var _extractMatchingPairs6 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1844
- oldVariant = _extractMatchingPairs6.oldObj,
1845
- newVariant = _extractMatchingPairs6.newObj;
1846
-
1721
+ oldVariant = _extractMatchingPairs6.oldObj,
1722
+ newVariant = _extractMatchingPairs6.newObj;
1847
1723
  if (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key)) {
1848
1724
  var vActions = _buildVariantImagesAction(variant.images, oldVariant, newVariant);
1849
-
1850
1725
  actions = actions.concat(vActions);
1851
1726
  }
1852
1727
  });
@@ -1859,22 +1734,21 @@
1859
1734
  var variants = diff.variants;
1860
1735
  if (variants) forEach__default["default"](variants, function (variant, key) {
1861
1736
  var _extractMatchingPairs7 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1862
- oldVariant = _extractMatchingPairs7.oldObj,
1863
- newVariant = _extractMatchingPairs7.newObj;
1864
-
1737
+ oldVariant = _extractMatchingPairs7.oldObj,
1738
+ newVariant = _extractMatchingPairs7.newObj;
1865
1739
  if (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key)) {
1866
1740
  var _buildVariantPricesAc = _buildVariantPricesAction(variant.prices, oldVariant, newVariant, enableDiscounted),
1867
- _buildVariantPricesAc2 = _slicedToArray(_buildVariantPricesAc, 3),
1868
- addPriceAction = _buildVariantPricesAc2[0],
1869
- changePriceAction = _buildVariantPricesAc2[1],
1870
- removePriceAction = _buildVariantPricesAc2[2];
1871
-
1741
+ _buildVariantPricesAc2 = _slicedToArray(_buildVariantPricesAc, 3),
1742
+ addPriceAction = _buildVariantPricesAc2[0],
1743
+ changePriceAction = _buildVariantPricesAc2[1],
1744
+ removePriceAction = _buildVariantPricesAc2[2];
1872
1745
  addPriceActions = addPriceActions.concat(addPriceAction);
1873
1746
  changePriceActions = changePriceActions.concat(changePriceAction);
1874
1747
  removePriceActions = removePriceActions.concat(removePriceAction);
1875
1748
  }
1876
- }); // price actions need to be in this below order
1749
+ });
1877
1750
 
1751
+ // price actions need to be in this below order
1878
1752
  return changePriceActions.concat(removePriceActions).concat(addPriceActions);
1879
1753
  }
1880
1754
  function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
@@ -1882,16 +1756,14 @@
1882
1756
  var variants = diff.variants;
1883
1757
  if (variants) forEach__default["default"](variants, function (variant, key) {
1884
1758
  var _extractMatchingPairs8 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1885
- oldVariant = _extractMatchingPairs8.oldObj,
1886
- newVariant = _extractMatchingPairs8.newObj;
1887
-
1759
+ oldVariant = _extractMatchingPairs8.oldObj,
1760
+ newVariant = _extractMatchingPairs8.newObj;
1888
1761
  if (variant && variant.prices && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
1889
1762
  var priceHashMap = findMatchingPairs(variant.prices, oldVariant.prices, newVariant.prices);
1890
1763
  forEach__default["default"](variant.prices, function (price, index) {
1891
1764
  var _extractMatchingPairs9 = extractMatchingPairs(priceHashMap, index, oldVariant.prices, newVariant.prices),
1892
- oldPrice = _extractMatchingPairs9.oldObj,
1893
- newPrice = _extractMatchingPairs9.newObj;
1894
-
1765
+ oldPrice = _extractMatchingPairs9.oldObj,
1766
+ newPrice = _extractMatchingPairs9.newObj;
1895
1767
  if (price.custom && (REGEX_UNDERSCORE_NUMBER$2.test(index) || REGEX_NUMBER$2.test(index))) {
1896
1768
  var generatedActions = actionsMapCustom(price, newPrice, oldPrice, {
1897
1769
  actions: {
@@ -1914,15 +1786,14 @@
1914
1786
  variantId: variantId
1915
1787
  };
1916
1788
  };
1917
-
1918
1789
  var extractMasterVariantId = function extractMasterVariantId(fromObj) {
1919
1790
  var variants = Array.isArray(fromObj.variants) ? fromObj.variants : [];
1920
1791
  return variants[0] ? variants[0].id : undefined;
1921
1792
  };
1922
-
1923
1793
  var newMasterVariantId = extractMasterVariantId(newObj);
1924
- var oldMasterVariantId = extractMasterVariantId(oldObj); // Old and new master master variant differ and a new master variant id exists
1794
+ var oldMasterVariantId = extractMasterVariantId(oldObj);
1925
1795
 
1796
+ // Old and new master master variant differ and a new master variant id exists
1926
1797
  if (newMasterVariantId && oldMasterVariantId !== newMasterVariantId) return [createChangeMasterVariantAction(newMasterVariantId)];
1927
1798
  return [];
1928
1799
  }
@@ -1932,9 +1803,9 @@
1932
1803
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1933
1804
  var allActions = [];
1934
1805
  var sameForAllAttributeNames = options.sameForAllAttributeNames,
1935
- enableDiscounted = options.enableDiscounted;
1806
+ enableDiscounted = options.enableDiscounted;
1936
1807
  var publish = newObj.publish,
1937
- staged = newObj.staged;
1808
+ staged = newObj.staged;
1938
1809
  var variantHashMap = findMatchingPairs(diff.variants, oldObj.variants, newObj.variants);
1939
1810
  allActions.push(mapActionGroup('attributes', function () {
1940
1811
  return actionsMapAttributes$1(diff, oldObj, newObj, sameForAllAttributeNames || [], variantHashMap);
@@ -1981,27 +1852,22 @@
1981
1852
  return flatten__default["default"](allActions);
1982
1853
  };
1983
1854
  }
1984
-
1985
1855
  function moveMasterVariantsIntoVariants(before, now) {
1986
1856
  var _copyEmptyArrayProps = copyEmptyArrayProps(before, now),
1987
- _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
1988
- beforeCopy = _copyEmptyArrayProps2[0],
1989
- nowCopy = _copyEmptyArrayProps2[1];
1990
-
1857
+ _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
1858
+ beforeCopy = _copyEmptyArrayProps2[0],
1859
+ nowCopy = _copyEmptyArrayProps2[1];
1991
1860
  var move = function move(obj) {
1992
1861
  return _objectSpread2(_objectSpread2({}, obj), {}, {
1993
1862
  masterVariant: undefined,
1994
1863
  variants: [obj.masterVariant].concat(_toConsumableArray(obj.variants || []))
1995
1864
  });
1996
1865
  };
1997
-
1998
1866
  var hasMasterVariant = function hasMasterVariant(obj) {
1999
1867
  return obj && obj.masterVariant;
2000
1868
  };
2001
-
2002
1869
  return [hasMasterVariant(beforeCopy) ? move(beforeCopy) : beforeCopy, hasMasterVariant(nowCopy) ? move(nowCopy) : nowCopy];
2003
1870
  }
2004
-
2005
1871
  var products = (function (actionGroupList, syncActionConfig) {
2006
1872
  var mapActionGroup = createMapActionGroup(actionGroupList);
2007
1873
  var doMapActions = createProductMapActions(mapActionGroup, syncActionConfig);
@@ -2013,15 +1879,12 @@
2013
1879
 
2014
1880
  var REGEX_NUMBER$1 = new RegExp(/^\d+$/);
2015
1881
  var REGEX_UNDERSCORE_NUMBER$1 = new RegExp(/^_\d+$/);
2016
-
2017
1882
  var isAddAction = function isAddAction(key, resource) {
2018
1883
  return REGEX_NUMBER$1.test(key) && Array.isArray(resource) && resource.length;
2019
1884
  };
2020
-
2021
1885
  var isRemoveAction = function isRemoveAction(key, resource) {
2022
1886
  return REGEX_UNDERSCORE_NUMBER$1.test(key) && Number(resource[2]) === 0;
2023
1887
  };
2024
-
2025
1888
  var baseActionsList$g = [{
2026
1889
  action: 'changeOrderState',
2027
1890
  key: 'orderState'
@@ -2032,6 +1895,7 @@
2032
1895
  action: 'changeShipmentState',
2033
1896
  key: 'shipmentState'
2034
1897
  }];
1898
+
2035
1899
  /**
2036
1900
  * SYNC FUNCTIONS
2037
1901
  */
@@ -2058,18 +1922,17 @@
2058
1922
  }));
2059
1923
  return handler(deliveriesDiff, oldObj.shippingInfo, newObj.shippingInfo);
2060
1924
  }
2061
-
2062
1925
  function _buildDeliveryParcelsAction(diffedParcels) {
2063
1926
  var oldDelivery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2064
1927
  var newDelivery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2065
1928
  var addParcelActions = [];
2066
- var removeParcelActions = []; // generate a hashMap to be able to reference the right image from both ends
1929
+ var removeParcelActions = [];
2067
1930
 
1931
+ // generate a hashMap to be able to reference the right image from both ends
2068
1932
  var matchingParcelPairs = findMatchingPairs(diffedParcels, oldDelivery.parcels, newDelivery.parcels);
2069
1933
  forEach__default["default"](diffedParcels, function (parcel, key) {
2070
1934
  var _extractMatchingPairs = extractMatchingPairs(matchingParcelPairs, key, oldDelivery.parcels, newDelivery.parcels),
2071
- oldObj = _extractMatchingPairs.oldObj;
2072
-
1935
+ oldObj = _extractMatchingPairs.oldObj;
2073
1936
  if (isAddAction(key, parcel)) {
2074
1937
  addParcelActions.push(_objectSpread2({
2075
1938
  action: 'addParcelToDelivery',
@@ -2077,7 +1940,6 @@
2077
1940
  }, getDeltaValue(parcel)));
2078
1941
  return;
2079
1942
  }
2080
-
2081
1943
  if (isRemoveAction(key, parcel)) {
2082
1944
  removeParcelActions.push({
2083
1945
  action: 'removeParcelFromDelivery',
@@ -2087,13 +1949,12 @@
2087
1949
  });
2088
1950
  return [addParcelActions, removeParcelActions];
2089
1951
  }
2090
-
2091
1952
  function _buildDeliveryItemsAction(diffedItems) {
2092
1953
  var newDelivery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2093
- var setDeliveryItemsAction = []; // If there is a diff it means that there were changes (update, adds or removes)
1954
+ var setDeliveryItemsAction = [];
1955
+ // If there is a diff it means that there were changes (update, adds or removes)
2094
1956
  // over the items, which means that `setDeliveryItems` change has happened over
2095
1957
  // the delivery
2096
-
2097
1958
  if (diffedItems && Object.keys(diffedItems).length > 0) {
2098
1959
  setDeliveryItemsAction.push({
2099
1960
  action: 'setDeliveryItems',
@@ -2102,10 +1963,8 @@
2102
1963
  items: newDelivery.items
2103
1964
  });
2104
1965
  }
2105
-
2106
1966
  return [setDeliveryItemsAction];
2107
1967
  }
2108
-
2109
1968
  function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
2110
1969
  var shippingInfo = diff.shippingInfo;
2111
1970
  if (!shippingInfo) return [];
@@ -2115,15 +1974,13 @@
2115
1974
  var removeParcelActions = [];
2116
1975
  if (deliveries) forEach__default["default"](deliveries, function (delivery, key) {
2117
1976
  var _extractMatchingPairs2 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
2118
- oldDelivery = _extractMatchingPairs2.oldObj,
2119
- newDelivery = _extractMatchingPairs2.newObj;
2120
-
1977
+ oldDelivery = _extractMatchingPairs2.oldObj,
1978
+ newDelivery = _extractMatchingPairs2.newObj;
2121
1979
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
2122
1980
  var _buildDeliveryParcels = _buildDeliveryParcelsAction(delivery.parcels, oldDelivery, newDelivery),
2123
- _buildDeliveryParcels2 = _slicedToArray(_buildDeliveryParcels, 2),
2124
- addParcelAction = _buildDeliveryParcels2[0],
2125
- removeParcelAction = _buildDeliveryParcels2[1];
2126
-
1981
+ _buildDeliveryParcels2 = _slicedToArray(_buildDeliveryParcels, 2),
1982
+ addParcelAction = _buildDeliveryParcels2[0],
1983
+ removeParcelAction = _buildDeliveryParcels2[1];
2127
1984
  addParcelActions = addParcelActions.concat(addParcelAction);
2128
1985
  removeParcelActions = removeParcelActions.concat(removeParcelAction);
2129
1986
  }
@@ -2138,42 +1995,34 @@
2138
1995
  var setDeliveryItemsActions = [];
2139
1996
  forEach__default["default"](deliveries, function (delivery, key) {
2140
1997
  var _extractMatchingPairs3 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
2141
- newDelivery = _extractMatchingPairs3.newObj;
2142
-
1998
+ newDelivery = _extractMatchingPairs3.newObj;
2143
1999
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
2144
2000
  var _buildDeliveryItemsAc = _buildDeliveryItemsAction(delivery.items, newDelivery),
2145
- _buildDeliveryItemsAc2 = _slicedToArray(_buildDeliveryItemsAc, 1),
2146
- setDeliveryItemsAction = _buildDeliveryItemsAc2[0];
2147
-
2001
+ _buildDeliveryItemsAc2 = _slicedToArray(_buildDeliveryItemsAc, 1),
2002
+ setDeliveryItemsAction = _buildDeliveryItemsAc2[0];
2148
2003
  setDeliveryItemsActions = setDeliveryItemsActions.concat(setDeliveryItemsAction);
2149
2004
  }
2150
2005
  });
2151
2006
  return setDeliveryItemsActions;
2152
2007
  }
2153
2008
  function actionsMapReturnsInfo(diff, oldObj, newObj) {
2154
- var _createBuildArrayActi2;
2155
-
2156
2009
  var returnInfoDiff = diff.returnInfo;
2157
2010
  if (!returnInfoDiff) return [];
2158
- var handler = createBuildArrayActions('returnInfo', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newReturnInfo) {
2011
+ var handler = createBuildArrayActions('returnInfo', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newReturnInfo) {
2159
2012
  if (newReturnInfo.items) {
2160
2013
  return [_objectSpread2({
2161
2014
  action: 'addReturnInfo'
2162
2015
  }, newReturnInfo)];
2163
2016
  }
2164
-
2165
2017
  return [];
2166
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldSReturnInfo, newReturnInfo, key) {
2018
+ }), CHANGE_ACTIONS, function (oldSReturnInfo, newReturnInfo, key) {
2167
2019
  var _returnInfoDiff$key$i = returnInfoDiff[key].items,
2168
- items = _returnInfoDiff$key$i === void 0 ? {} : _returnInfoDiff$key$i;
2169
-
2020
+ items = _returnInfoDiff$key$i === void 0 ? {} : _returnInfoDiff$key$i;
2170
2021
  if (Object.keys(items).length === 0) {
2171
2022
  return [];
2172
2023
  }
2173
-
2174
2024
  return Object.keys(items).reduce(function (actions, index) {
2175
2025
  var item = newReturnInfo.items[index];
2176
-
2177
2026
  if (items[index].shipmentState) {
2178
2027
  actions.push({
2179
2028
  action: 'setReturnShipmentState',
@@ -2181,7 +2030,6 @@
2181
2030
  shipmentState: item.shipmentState
2182
2031
  });
2183
2032
  }
2184
-
2185
2033
  if (items[index].paymentState) {
2186
2034
  actions.push({
2187
2035
  action: 'setReturnPaymentState',
@@ -2189,10 +2037,9 @@
2189
2037
  paymentState: item.paymentState
2190
2038
  });
2191
2039
  }
2192
-
2193
2040
  return actions;
2194
2041
  }, []);
2195
- }), _createBuildArrayActi2));
2042
+ }));
2196
2043
  return handler(diff, oldObj, newObj);
2197
2044
  }
2198
2045
 
@@ -2200,11 +2047,9 @@
2200
2047
  return function doMapActions(diff, newObj, oldObj) {
2201
2048
  var allActions = [];
2202
2049
  var deliveryHashMap;
2203
-
2204
2050
  if (diff.shippingInfo && diff.shippingInfo.deliveries) {
2205
2051
  deliveryHashMap = findMatchingPairs(diff.shippingInfo.deliveries, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries);
2206
2052
  }
2207
-
2208
2053
  allActions.push(mapActionGroup('base', function () {
2209
2054
  return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
2210
2055
  }));
@@ -2226,14 +2071,15 @@
2226
2071
  return flatten__default["default"](allActions);
2227
2072
  };
2228
2073
  }
2229
-
2230
2074
  var orders = (function (actionGroupList, syncActionConfig) {
2231
2075
  // actionGroupList contains information about which action groups
2232
2076
  // are allowed or ignored
2077
+
2233
2078
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2234
2079
  // - action group name
2235
2080
  // - callback function that should return a list of actions that correspond
2236
2081
  // to the for the action group
2082
+
2237
2083
  // this resulting function mapActionGroup will call the callback function
2238
2084
  // for allowed action groups and return the return value of the callback
2239
2085
  // It will return an empty array for ignored action groups
@@ -2285,21 +2131,17 @@
2285
2131
  }
2286
2132
 
2287
2133
  var validityActions = ['setValidFrom', 'setValidUntil'];
2288
-
2289
2134
  var isValidityActions = function isValidityActions(actionName) {
2290
2135
  return validityActions.includes(actionName);
2291
2136
  };
2292
-
2293
2137
  function combineValidityActions() {
2294
2138
  var actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2295
-
2296
2139
  var _actions$filter = actions.filter(function (item) {
2297
- return isValidityActions(item.action);
2298
- }),
2299
- _actions$filter2 = _slicedToArray(_actions$filter, 2),
2300
- setValidFromAction = _actions$filter2[0],
2301
- setValidUntilAction = _actions$filter2[1];
2302
-
2140
+ return isValidityActions(item.action);
2141
+ }),
2142
+ _actions$filter2 = _slicedToArray(_actions$filter, 2),
2143
+ setValidFromAction = _actions$filter2[0],
2144
+ setValidUntilAction = _actions$filter2[1];
2303
2145
  if (setValidFromAction && setValidUntilAction) {
2304
2146
  return [].concat(_toConsumableArray(actions.filter(function (item) {
2305
2147
  return !isValidityActions(item.action);
@@ -2309,7 +2151,6 @@
2309
2151
  validUntil: setValidUntilAction.validUntil
2310
2152
  }]);
2311
2153
  }
2312
-
2313
2154
  return actions;
2314
2155
  }
2315
2156
 
@@ -2322,7 +2163,6 @@
2322
2163
  return combineValidityActions(flatten__default["default"](allActions));
2323
2164
  };
2324
2165
  }
2325
-
2326
2166
  var productDiscounts = (function (actionGroupList) {
2327
2167
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2328
2168
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2390,15 +2230,16 @@
2390
2230
  return combineValidityActions(flatten__default["default"](allActions));
2391
2231
  };
2392
2232
  }
2393
-
2394
2233
  var discountCodes = (function (actionGroupList) {
2395
2234
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2396
2235
  // actionGroupList contains information about which action groups
2397
2236
  // are allowed or ignored
2237
+
2398
2238
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2399
2239
  // - action group name
2400
2240
  // - callback function that should return a list of actions that correspond
2401
2241
  // to the for the action group
2242
+
2402
2243
  // this resulting function mapActionGroup will call the callback function
2403
2244
  // for allowed action groups and return the return value of the callback
2404
2245
  // It will return an empty array for ignored action groups
@@ -2440,7 +2281,6 @@
2440
2281
  return flatten__default["default"](allActions);
2441
2282
  };
2442
2283
  }
2443
-
2444
2284
  var customerGroup = (function (actionGroupList) {
2445
2285
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2446
2286
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2511,7 +2351,6 @@
2511
2351
  return combineValidityActions(flatten__default["default"](allActions));
2512
2352
  };
2513
2353
  }
2514
-
2515
2354
  var cartDiscounts = (function (actionGroupList) {
2516
2355
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2517
2356
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2543,25 +2382,23 @@
2543
2382
  });
2544
2383
  }
2545
2384
  function actionsMapRates(diff, oldObj, newObj) {
2546
- var _createBuildArrayActi;
2547
-
2548
- var handler = createBuildArrayActions('rates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newObject) {
2385
+ var handler = createBuildArrayActions('rates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
2549
2386
  return {
2550
2387
  action: 'addTaxRate',
2551
2388
  taxRate: newObject
2552
2389
  };
2553
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (objectToRemove) {
2390
+ }), REMOVE_ACTIONS, function (objectToRemove) {
2554
2391
  return {
2555
2392
  action: 'removeTaxRate',
2556
2393
  taxRateId: objectToRemove.id
2557
2394
  };
2558
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldObject, updatedObject) {
2395
+ }), CHANGE_ACTIONS, function (oldObject, updatedObject) {
2559
2396
  return {
2560
2397
  action: 'replaceTaxRate',
2561
2398
  taxRateId: oldObject.id === updatedObject.id ? oldObject.id : updatedObject.id,
2562
2399
  taxRate: updatedObject
2563
2400
  };
2564
- }), _createBuildArrayActi));
2401
+ }));
2565
2402
  return handler(diff, oldObj, newObj);
2566
2403
  }
2567
2404
 
@@ -2577,14 +2414,15 @@
2577
2414
  return flatten__default["default"](allActions);
2578
2415
  };
2579
2416
  }
2580
-
2581
2417
  var taxCategories = (function (actionGroupList, syncActionConfig) {
2582
2418
  // config contains information about which action groups
2583
2419
  // are allowed or ignored
2420
+
2584
2421
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2585
2422
  // - action group name
2586
2423
  // - callback function that should return a list of actions that correspond
2587
2424
  // to the for the action group
2425
+
2588
2426
  // this resulting function mapActionGroup will call the callback function
2589
2427
  // for allowed action groups and return the return value of the callback
2590
2428
  // It will return an empty array for ignored action groups
@@ -2606,13 +2444,11 @@
2606
2444
  action: 'setKey',
2607
2445
  key: 'key'
2608
2446
  }];
2609
-
2610
2447
  var hasLocation = function hasLocation(locations, otherLocation) {
2611
2448
  return locations.some(function (location) {
2612
2449
  return location.country === otherLocation.country;
2613
2450
  });
2614
2451
  };
2615
-
2616
2452
  function actionsMapBase$a(diff, oldObj, newObj) {
2617
2453
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2618
2454
  return buildBaseAttributesActions({
@@ -2624,36 +2460,37 @@
2624
2460
  });
2625
2461
  }
2626
2462
  function actionsMapLocations(diff, oldObj, newObj) {
2627
- var _createBuildArrayActi;
2628
-
2629
- var handler = createBuildArrayActions('locations', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newLocation) {
2463
+ var handler = createBuildArrayActions('locations', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newLocation) {
2630
2464
  return {
2631
2465
  action: 'addLocation',
2632
2466
  location: newLocation
2633
2467
  };
2634
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldLocation) {
2635
- return (// We only add the action if the location is not included in the new object.
2468
+ }), REMOVE_ACTIONS, function (oldLocation) {
2469
+ return (
2470
+ // We only add the action if the location is not included in the new object.
2636
2471
  !hasLocation(newObj.locations, oldLocation) ? {
2637
2472
  action: 'removeLocation',
2638
2473
  location: oldLocation
2639
2474
  } : null
2640
2475
  );
2641
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldLocation, newLocation) {
2642
- var result = []; // We only remove the location in case that the oldLocation is not
2643
- // included in the new object
2476
+ }), CHANGE_ACTIONS, function (oldLocation, newLocation) {
2477
+ var result = [];
2644
2478
 
2479
+ // We only remove the location in case that the oldLocation is not
2480
+ // included in the new object
2645
2481
  if (!hasLocation(newObj.locations, oldLocation)) result.push({
2646
2482
  action: 'removeLocation',
2647
2483
  location: oldLocation
2648
- }); // We only add the location in case that the newLocation was not
2649
- // included in the old object
2484
+ });
2650
2485
 
2486
+ // We only add the location in case that the newLocation was not
2487
+ // included in the old object
2651
2488
  if (!hasLocation(oldObj.locations, newLocation)) result.push({
2652
2489
  action: 'addLocation',
2653
2490
  location: newLocation
2654
2491
  });
2655
2492
  return result;
2656
- }), _createBuildArrayActi));
2493
+ }));
2657
2494
  return handler(diff, oldObj, newObj);
2658
2495
  }
2659
2496
 
@@ -2669,14 +2506,15 @@
2669
2506
  return flatten__default["default"](allActions);
2670
2507
  };
2671
2508
  }
2672
-
2673
2509
  var zones = (function (actionGroupList, syncActionConfig) {
2674
2510
  // config contains information about which action groups
2675
2511
  // are allowed or ignored
2512
+
2676
2513
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2677
2514
  // - action group name
2678
2515
  // - callback function that should return a list of actions that correspond
2679
2516
  // to the for the action group
2517
+
2680
2518
  // this resulting function mapActionGroup will call the callback function
2681
2519
  // for allowed action groups and return the return value of the callback
2682
2520
  // It will return an empty array for ignored action groups
@@ -2712,6 +2550,9 @@
2712
2550
  }, {
2713
2551
  action: 'changeTaxCategory',
2714
2552
  key: 'taxCategory'
2553
+ }, {
2554
+ action: 'changeActive',
2555
+ key: 'active'
2715
2556
  }];
2716
2557
  function actionsMapBase$9(diff, oldObj, newObj) {
2717
2558
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -2723,7 +2564,6 @@
2723
2564
  shouldOmitEmptyString: config.shouldOmitEmptyString
2724
2565
  });
2725
2566
  }
2726
-
2727
2567
  var addShippingRates = function addShippingRates(newZoneRate) {
2728
2568
  return newZoneRate.shippingRates ? newZoneRate.shippingRates.map(function (shippingRate) {
2729
2569
  return {
@@ -2733,23 +2573,20 @@
2733
2573
  };
2734
2574
  }) : [];
2735
2575
  };
2736
-
2737
2576
  function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2738
- var _createBuildArrayActi;
2739
-
2740
- var handler = createBuildArrayActions('shippingRates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newShippingRate) {
2577
+ var handler = createBuildArrayActions('shippingRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newShippingRate) {
2741
2578
  return {
2742
2579
  action: 'addShippingRate',
2743
2580
  zone: newObj.zone,
2744
2581
  shippingRate: newShippingRate
2745
2582
  };
2746
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldShippingRate) {
2583
+ }), REMOVE_ACTIONS, function (oldShippingRate) {
2747
2584
  return {
2748
2585
  action: 'removeShippingRate',
2749
2586
  zone: oldObj.zone,
2750
2587
  shippingRate: oldShippingRate
2751
2588
  };
2752
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2589
+ }), CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2753
2590
  return [{
2754
2591
  action: 'removeShippingRate',
2755
2592
  zone: oldObj.zone,
@@ -2759,24 +2596,21 @@
2759
2596
  zone: newObj.zone,
2760
2597
  shippingRate: newShippingRate
2761
2598
  }];
2762
- }), _createBuildArrayActi));
2599
+ }));
2763
2600
  return handler(diff, oldObj, newObj);
2764
2601
  }
2765
-
2766
2602
  function actionsMapZoneRates(diff, oldObj, newObj) {
2767
- var _createBuildArrayActi2;
2768
-
2769
- var handler = createBuildArrayActions('zoneRates', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newZoneRate) {
2603
+ var handler = createBuildArrayActions('zoneRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newZoneRate) {
2770
2604
  return [{
2771
2605
  action: 'addZone',
2772
2606
  zone: newZoneRate.zone
2773
2607
  }].concat(_toConsumableArray(addShippingRates(newZoneRate)));
2774
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (oldZoneRate) {
2608
+ }), REMOVE_ACTIONS, function (oldZoneRate) {
2775
2609
  return {
2776
2610
  action: 'removeZone',
2777
2611
  zone: oldZoneRate.zone
2778
2612
  };
2779
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2613
+ }), CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2780
2614
  var hasZoneActions = false;
2781
2615
  var shippingRateActions = Object.keys(diff.zoneRates).reduce(function (actions, key) {
2782
2616
  if (diff.zoneRates[key].zone) hasZoneActions = true;
@@ -2790,7 +2624,7 @@
2790
2624
  action: 'addZone',
2791
2625
  zone: newZoneRate.zone
2792
2626
  }]) : shippingRateActions);
2793
- }), _createBuildArrayActi2));
2627
+ }));
2794
2628
  return handler(diff, oldObj, newObj);
2795
2629
  }
2796
2630
 
@@ -2809,14 +2643,15 @@
2809
2643
  return flatten__default["default"](allActions);
2810
2644
  };
2811
2645
  }
2812
-
2813
2646
  var shippingMethods = (function (actionGroupList, syncActionConfig) {
2814
2647
  // actionGroupList contains information about which action groups
2815
2648
  // are allowed or ignored
2649
+
2816
2650
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2817
2651
  // - action group name
2818
2652
  // - callback function that should return a list of actions that correspond
2819
2653
  // to the for the action group
2654
+
2820
2655
  // this resulting function mapActionGroup will call the callback function
2821
2656
  // for allowed action groups and return the return value of the callback
2822
2657
  // It will return an empty array for ignored action groups
@@ -2837,7 +2672,6 @@
2837
2672
  * @param b the value to test
2838
2673
  * @returns are the values equal by the SameValueZero principle
2839
2674
  */
2840
-
2841
2675
  function sameValueZeroEqual(a, b) {
2842
2676
  return a === b || a !== a && b !== b;
2843
2677
  }
@@ -2847,8 +2681,6 @@
2847
2681
  * @param value the value to test
2848
2682
  * @returns is the value a plain object
2849
2683
  */
2850
-
2851
-
2852
2684
  function isPlainObject(value) {
2853
2685
  return value.constructor === Object || value.constructor == null;
2854
2686
  }
@@ -2858,8 +2690,6 @@
2858
2690
  * @param value the value to test
2859
2691
  * @returns is the value promise-like
2860
2692
  */
2861
-
2862
-
2863
2693
  function isPromiseLike(value) {
2864
2694
  return !!value && typeof value.then === 'function';
2865
2695
  }
@@ -2869,8 +2699,6 @@
2869
2699
  * @param value the value to test
2870
2700
  * @returns is the value a react element
2871
2701
  */
2872
-
2873
-
2874
2702
  function isReactElement(value) {
2875
2703
  return !!(value && value.$$typeof);
2876
2704
  }
@@ -2880,8 +2708,6 @@
2880
2708
  *
2881
2709
  * @returns the new cache object
2882
2710
  */
2883
-
2884
-
2885
2711
  function getNewCacheFallback() {
2886
2712
  var values = [];
2887
2713
  return {
@@ -2898,15 +2724,12 @@
2898
2724
  *
2899
2725
  * @returns the new cache object
2900
2726
  */
2901
-
2902
-
2903
2727
  var getNewCache = function (canUseWeakMap) {
2904
2728
  if (canUseWeakMap) {
2905
2729
  return function _getNewCache() {
2906
2730
  return new WeakSet();
2907
2731
  };
2908
2732
  }
2909
-
2910
2733
  return getNewCacheFallback;
2911
2734
  }(HAS_WEAKSET_SUPPORT);
2912
2735
  /**
@@ -2915,37 +2738,28 @@
2915
2738
  * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
2916
2739
  * @returns the method to create the `isEqual` function
2917
2740
  */
2918
-
2919
-
2920
2741
  function createCircularEqualCreator(isEqual) {
2921
2742
  return function createCircularEqual(comparator) {
2922
2743
  var _comparator = isEqual || comparator;
2923
-
2924
2744
  return function circularEqual(a, b, cache) {
2925
2745
  if (cache === void 0) {
2926
2746
  cache = getNewCache();
2927
2747
  }
2928
-
2929
2748
  var isCacheableA = !!a && _typeof(a) === 'object';
2930
2749
  var isCacheableB = !!b && _typeof(b) === 'object';
2931
-
2932
2750
  if (isCacheableA || isCacheableB) {
2933
2751
  var hasA = isCacheableA && cache.has(a);
2934
2752
  var hasB = isCacheableB && cache.has(b);
2935
-
2936
2753
  if (hasA || hasB) {
2937
2754
  return hasA && hasB;
2938
2755
  }
2939
-
2940
2756
  if (isCacheableA) {
2941
2757
  cache.add(a);
2942
2758
  }
2943
-
2944
2759
  if (isCacheableB) {
2945
2760
  cache.add(b);
2946
2761
  }
2947
2762
  }
2948
-
2949
2763
  return _comparator(a, b, cache);
2950
2764
  };
2951
2765
  };
@@ -2959,21 +2773,16 @@
2959
2773
  * @param meta the meta object to pass through
2960
2774
  * @returns are the arrays equal
2961
2775
  */
2962
-
2963
-
2964
2776
  function areArraysEqual(a, b, isEqual, meta) {
2965
2777
  var index = a.length;
2966
-
2967
2778
  if (b.length !== index) {
2968
2779
  return false;
2969
2780
  }
2970
-
2971
2781
  while (index-- > 0) {
2972
2782
  if (!isEqual(a[index], b[index], meta)) {
2973
2783
  return false;
2974
2784
  }
2975
2785
  }
2976
-
2977
2786
  return true;
2978
2787
  }
2979
2788
  /**
@@ -2985,11 +2794,8 @@
2985
2794
  * @param meta the meta map to pass through
2986
2795
  * @returns are the maps equal
2987
2796
  */
2988
-
2989
-
2990
2797
  function areMapsEqual(a, b, isEqual, meta) {
2991
2798
  var isValueEqual = a.size === b.size;
2992
-
2993
2799
  if (isValueEqual && a.size) {
2994
2800
  var matchedIndices_1 = {};
2995
2801
  a.forEach(function (aValue, aKey) {
@@ -2999,22 +2805,18 @@
2999
2805
  b.forEach(function (bValue, bKey) {
3000
2806
  if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
3001
2807
  hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
3002
-
3003
2808
  if (hasMatch_1) {
3004
2809
  matchedIndices_1[matchIndex_1] = true;
3005
2810
  }
3006
2811
  }
3007
-
3008
2812
  matchIndex_1++;
3009
2813
  });
3010
2814
  isValueEqual = hasMatch_1;
3011
2815
  }
3012
2816
  });
3013
2817
  }
3014
-
3015
2818
  return isValueEqual;
3016
2819
  }
3017
-
3018
2820
  var OWNER = '_owner';
3019
2821
  var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
3020
2822
  /**
@@ -3026,36 +2828,28 @@
3026
2828
  * @param meta the meta object to pass through
3027
2829
  * @returns are the objects equal
3028
2830
  */
3029
-
3030
2831
  function areObjectsEqual(a, b, isEqual, meta) {
3031
2832
  var keysA = keys(a);
3032
2833
  var index = keysA.length;
3033
-
3034
2834
  if (keys(b).length !== index) {
3035
2835
  return false;
3036
2836
  }
3037
-
3038
2837
  if (index) {
3039
2838
  var key = void 0;
3040
-
3041
2839
  while (index-- > 0) {
3042
2840
  key = keysA[index];
3043
-
3044
2841
  if (key === OWNER) {
3045
2842
  var reactElementA = isReactElement(a);
3046
2843
  var reactElementB = isReactElement(b);
3047
-
3048
2844
  if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
3049
2845
  return false;
3050
2846
  }
3051
2847
  }
3052
-
3053
2848
  if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3054
2849
  return false;
3055
2850
  }
3056
2851
  }
3057
2852
  }
3058
-
3059
2853
  return true;
3060
2854
  }
3061
2855
  /**
@@ -3065,8 +2859,6 @@
3065
2859
  * @param b the regExp to test agains
3066
2860
  * @returns are the regExps equal
3067
2861
  */
3068
-
3069
-
3070
2862
  function areRegExpsEqual(a, b) {
3071
2863
  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;
3072
2864
  }
@@ -3079,11 +2871,8 @@
3079
2871
  * @param meta the meta set to pass through
3080
2872
  * @returns are the sets equal
3081
2873
  */
3082
-
3083
-
3084
2874
  function areSetsEqual(a, b, isEqual, meta) {
3085
2875
  var isValueEqual = a.size === b.size;
3086
-
3087
2876
  if (isValueEqual && a.size) {
3088
2877
  var matchedIndices_2 = {};
3089
2878
  a.forEach(function (aValue) {
@@ -3093,31 +2882,24 @@
3093
2882
  b.forEach(function (bValue) {
3094
2883
  if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
3095
2884
  hasMatch_2 = isEqual(aValue, bValue, meta);
3096
-
3097
2885
  if (hasMatch_2) {
3098
2886
  matchedIndices_2[matchIndex_2] = true;
3099
2887
  }
3100
2888
  }
3101
-
3102
2889
  matchIndex_2++;
3103
2890
  });
3104
2891
  isValueEqual = hasMatch_2;
3105
2892
  }
3106
2893
  });
3107
2894
  }
3108
-
3109
2895
  return isValueEqual;
3110
2896
  }
3111
-
3112
2897
  var HAS_MAP_SUPPORT = typeof Map === 'function';
3113
2898
  var HAS_SET_SUPPORT = typeof Set === 'function';
3114
-
3115
2899
  function createComparator(createIsEqual) {
3116
- var isEqual =
3117
- /* eslint-disable no-use-before-define */
2900
+ var isEqual = /* eslint-disable no-use-before-define */
3118
2901
  typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
3119
2902
  /* eslint-enable */
3120
-
3121
2903
  /**
3122
2904
  * compare the value of the two objects and return true if they are equivalent in values
3123
2905
  *
@@ -3126,69 +2908,52 @@
3126
2908
  * @param [meta] an optional meta object that is passed through to all equality test calls
3127
2909
  * @returns are a and b equivalent in value
3128
2910
  */
3129
-
3130
2911
  function comparator(a, b, meta) {
3131
2912
  if (a === b) {
3132
2913
  return true;
3133
2914
  }
3134
-
3135
2915
  if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3136
2916
  if (isPlainObject(a) && isPlainObject(b)) {
3137
2917
  return areObjectsEqual(a, b, isEqual, meta);
3138
2918
  }
3139
-
3140
2919
  var aShape = Array.isArray(a);
3141
2920
  var bShape = Array.isArray(b);
3142
-
3143
2921
  if (aShape || bShape) {
3144
2922
  return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3145
2923
  }
3146
-
3147
2924
  aShape = a instanceof Date;
3148
2925
  bShape = b instanceof Date;
3149
-
3150
2926
  if (aShape || bShape) {
3151
2927
  return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3152
2928
  }
3153
-
3154
2929
  aShape = a instanceof RegExp;
3155
2930
  bShape = b instanceof RegExp;
3156
-
3157
2931
  if (aShape || bShape) {
3158
2932
  return aShape === bShape && areRegExpsEqual(a, b);
3159
2933
  }
3160
-
3161
2934
  if (isPromiseLike(a) || isPromiseLike(b)) {
3162
2935
  return a === b;
3163
2936
  }
3164
-
3165
2937
  if (HAS_MAP_SUPPORT) {
3166
2938
  aShape = a instanceof Map;
3167
2939
  bShape = b instanceof Map;
3168
-
3169
2940
  if (aShape || bShape) {
3170
2941
  return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3171
2942
  }
3172
2943
  }
3173
-
3174
2944
  if (HAS_SET_SUPPORT) {
3175
2945
  aShape = a instanceof Set;
3176
2946
  bShape = b instanceof Set;
3177
-
3178
2947
  if (aShape || bShape) {
3179
2948
  return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3180
2949
  }
3181
2950
  }
3182
-
3183
2951
  return areObjectsEqual(a, b, isEqual, meta);
3184
2952
  }
3185
-
3186
2953
  return a !== a && b !== b;
3187
2954
  }
3188
-
3189
2955
  return comparator;
3190
2956
  }
3191
-
3192
2957
  var deepEqual = createComparator();
3193
2958
  createComparator(function () {
3194
2959
  return sameValueZeroEqual;
@@ -3219,21 +2984,20 @@
3219
2984
  newObj: next,
3220
2985
  shouldOmitEmptyString: config.shouldOmitEmptyString
3221
2986
  });
3222
- } // this is nearly similar to `buildBaseAttributesActions`, however with a significant difference.
2987
+ }
2988
+
2989
+ // this is nearly similar to `buildBaseAttributesActions`, however with a significant difference.
3223
2990
  // `buildBasAttributesActions` generates update-actions with help of `diff`,
3224
2991
  // which is an object consisting of flags which indicates different operations.
3225
2992
  // `generateBaseFieldsUpdateActions` only generate based on `previous` and `next`.
3226
-
3227
2993
  var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(previous, next, actionDefinition) {
3228
2994
  var isEmpty = createIsEmptyValue([undefined, null, '']);
3229
2995
  return Object.entries(actionDefinition).reduce(function (nextUpdateActions, _ref) {
3230
2996
  var _ref2 = _slicedToArray(_ref, 2),
3231
- field = _ref2[0],
3232
- actionFieldDefinition = _ref2[1];
3233
-
2997
+ field = _ref2[0],
2998
+ actionFieldDefinition = _ref2[1];
3234
2999
  if (isEmpty(previous[field]) && isEmpty(next[field])) return nextUpdateActions;
3235
3000
  if (!isEmpty(previous[field]) && isEmpty(next[field])) return [].concat(_toConsumableArray(nextUpdateActions), [actionFieldDefinition]);
3236
-
3237
3001
  if (!deepEqual(previous[field], next[field])) {
3238
3002
  switch (field) {
3239
3003
  // BEWARE that this is generates update-action only for key of enum attribute value,
@@ -3241,7 +3005,8 @@
3241
3005
  // `generateBaseFieldsUpdateActions`, we need to extract the following logic so we could
3242
3006
  // cover both entity types.
3243
3007
  case 'key':
3244
- return [].concat(_toConsumableArray(nextUpdateActions), [// Another option is to have explicit name of `field` e.g `enumKey`, which we could use to
3008
+ return [].concat(_toConsumableArray(nextUpdateActions), [
3009
+ // Another option is to have explicit name of `field` e.g `enumKey`, which we could use to
3245
3010
  // generate appropriate update-action for respective entity type.
3246
3011
  // An outline of this on the top of my head:
3247
3012
  // ```js
@@ -3271,7 +3036,6 @@
3271
3036
  newKey: next[field]
3272
3037
  }]);
3273
3038
  // attribute
3274
-
3275
3039
  case 'attributeConstraint':
3276
3040
  case 'inputHint':
3277
3041
  return [].concat(_toConsumableArray(nextUpdateActions), [{
@@ -3279,7 +3043,6 @@
3279
3043
  attributeName: actionFieldDefinition.attributeName,
3280
3044
  newValue: next[field]
3281
3045
  }]);
3282
-
3283
3046
  default:
3284
3047
  return [].concat(_toConsumableArray(nextUpdateActions), [_defineProperty({
3285
3048
  action: actionFieldDefinition.action,
@@ -3287,11 +3050,9 @@
3287
3050
  }, field, next[field])]);
3288
3051
  }
3289
3052
  }
3290
-
3291
3053
  return nextUpdateActions;
3292
3054
  }, []);
3293
3055
  };
3294
-
3295
3056
  var generateUpdateActionsForAttributeDefinitions = function generateUpdateActionsForAttributeDefinitions() {
3296
3057
  var attributeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3297
3058
  var removedAttributeDefinitions = attributeDefinitions.filter(function (attributeDefinition) {
@@ -3338,7 +3099,6 @@
3338
3099
  };
3339
3100
  })));
3340
3101
  };
3341
-
3342
3102
  var generateUpdateActionsForAttributeEnumValues = function generateUpdateActionsForAttributeEnumValues() {
3343
3103
  var attributeEnumValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3344
3104
  var removedAttributeEnumValues = attributeEnumValues.filter(function (attributeEnumValue) {
@@ -3366,7 +3126,6 @@
3366
3126
  attributeName: updatedAttributeEnumValue.hint.attributeName
3367
3127
  }
3368
3128
  });
3369
-
3370
3129
  if (!deepEqual(updatedAttributeEnumValue.previous.label, updatedAttributeEnumValue.next.label)) {
3371
3130
  if (updatedAttributeEnumValue.hint.isLocalized) {
3372
3131
  return [].concat(_toConsumableArray(updateActions), [{
@@ -3375,14 +3134,12 @@
3375
3134
  newValue: updatedAttributeEnumValue.next
3376
3135
  }]);
3377
3136
  }
3378
-
3379
3137
  return [].concat(_toConsumableArray(updateActions), [{
3380
3138
  action: 'changePlainEnumValueLabel',
3381
3139
  attributeName: updatedAttributeEnumValue.hint.attributeName,
3382
3140
  newValue: updatedAttributeEnumValue.next
3383
3141
  }]);
3384
3142
  }
3385
-
3386
3143
  return updateActions;
3387
3144
  }))), _toConsumableArray(addedAttributeEnumValues.map(function (addedAttributeEnumValue) {
3388
3145
  return {
@@ -3392,7 +3149,6 @@
3392
3149
  };
3393
3150
  })));
3394
3151
  };
3395
-
3396
3152
  var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAction() {
3397
3153
  var attrsOld = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3398
3154
  var attrsNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -3410,9 +3166,10 @@
3410
3166
  return action.action === 'addAttributeDefinition';
3411
3167
  }).map(function (action) {
3412
3168
  return action.attribute.name;
3413
- }); // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3414
- // calculate how the productType will look like after adding/removing attributes
3169
+ });
3415
3170
 
3171
+ // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3172
+ // calculate how the productType will look like after adding/removing attributes
3416
3173
  var patchedOldAttributesOrder = attrsOld.map(function (attribute) {
3417
3174
  return attribute.name;
3418
3175
  }).filter(function (name) {
@@ -3424,7 +3181,6 @@
3424
3181
  };
3425
3182
  return null;
3426
3183
  };
3427
-
3428
3184
  var actionsMapForHints = function actionsMapForHints() {
3429
3185
  var nestedValuesChanges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3430
3186
  var ptOld = arguments.length > 1 ? arguments[1] : undefined;
@@ -3437,14 +3193,14 @@
3437
3193
 
3438
3194
  function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
3439
3195
  return function doMapActions(diff, next, previous, options) {
3440
- return flatten__default["default"]([// we support only base fields for the product type,
3196
+ return flatten__default["default"]([
3197
+ // we support only base fields for the product type,
3441
3198
  // for attributes, applying hints would be recommended
3442
3199
  mapActionGroup('base', function () {
3443
3200
  return actionsMapBase$8(diff, previous, next, syncActionConfig);
3444
3201
  }), actionsMapForHints(options.nestedValuesChanges, previous, next)]);
3445
3202
  };
3446
3203
  }
3447
-
3448
3204
  var productTypes = (function (actionGroupList, syncActionConfig) {
3449
3205
  var mapActionGroup = createMapActionGroup(actionGroupList);
3450
3206
  var doMapActions = createProductTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3487,26 +3243,24 @@
3487
3243
  });
3488
3244
  }
3489
3245
  function actionsMapRoles(diff, oldObj, newObj) {
3490
- var _createBuildArrayActi;
3491
-
3492
- var buildArrayActions = createBuildArrayActions('roles', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newRole) {
3246
+ var buildArrayActions = createBuildArrayActions('roles', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newRole) {
3493
3247
  return {
3494
3248
  action: 'addRoles',
3495
3249
  roles: newRole
3496
3250
  };
3497
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldRole) {
3251
+ }), REMOVE_ACTIONS, function (oldRole) {
3498
3252
  return {
3499
3253
  action: 'removeRoles',
3500
3254
  roles: oldRole
3501
3255
  };
3502
- }), _createBuildArrayActi));
3256
+ }));
3503
3257
  return buildArrayActions(diff, oldObj, newObj);
3504
3258
  }
3505
3259
 
3260
+ // This function groups `addRoles` and `removeRoles` actions to one array
3506
3261
  function groupRoleActions(_ref) {
3507
3262
  var _ref2 = _slicedToArray(_ref, 1),
3508
- actions = _ref2[0];
3509
-
3263
+ actions = _ref2[0];
3510
3264
  var addActionRoles = [];
3511
3265
  var removeActionRoles = [];
3512
3266
  actions.forEach(function (action) {
@@ -3523,7 +3277,6 @@
3523
3277
  return action.roles.length;
3524
3278
  });
3525
3279
  }
3526
-
3527
3280
  function createStatesMapActions(mapActionGroup, syncActionConfig) {
3528
3281
  return function doMapActions(diff, newObj, oldObj) {
3529
3282
  var baseActions = [];
@@ -3537,7 +3290,6 @@
3537
3290
  return flatten__default["default"]([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
3538
3291
  };
3539
3292
  }
3540
-
3541
3293
  var states = (function (actionGroupList, syncActionConfig) {
3542
3294
  var mapActionGroup = createMapActionGroup(actionGroupList);
3543
3295
  var doMapActions = createStatesMapActions(mapActionGroup, syncActionConfig);
@@ -3589,7 +3341,6 @@
3589
3341
  return flatten__default["default"](allActions);
3590
3342
  };
3591
3343
  }
3592
-
3593
3344
  var channels = (function (actionGroupList) {
3594
3345
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3595
3346
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3602,15 +3353,12 @@
3602
3353
 
3603
3354
  var REGEX_NUMBER = new RegExp(/^\d+$/);
3604
3355
  var REGEX_UNDERSCORE_NUMBER = new RegExp(/^_\d+$/);
3605
-
3606
3356
  var getIsChangedOperation = function getIsChangedOperation(key) {
3607
3357
  return REGEX_NUMBER.test(key);
3608
3358
  };
3609
-
3610
3359
  var getIsRemovedOperation = function getIsRemovedOperation(key) {
3611
3360
  return REGEX_UNDERSCORE_NUMBER.test(key);
3612
3361
  };
3613
-
3614
3362
  var baseActionsList$5 = [{
3615
3363
  action: 'changeKey',
3616
3364
  key: 'key'
@@ -3631,38 +3379,35 @@
3631
3379
  shouldOmitEmptyString: config.shouldOmitEmptyString
3632
3380
  });
3633
3381
  }
3634
-
3635
3382
  function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next) {
3636
- var _createBuildArrayActi;
3637
-
3638
3383
  var addEnumActionName = attributeType === 'Enum' ? 'addEnumValue' : 'addLocalizedEnumValue';
3639
3384
  var changeEnumValueLabelActionName = attributeType === 'Enum' ? 'changeEnumValueLabel' : 'changeLocalizedEnumValueLabel';
3640
3385
  var changeEnumOrderActionName = attributeType === 'Enum' ? 'changeEnumValueOrder' : 'changeLocalizedEnumValueOrder';
3641
- var buildArrayActions = createBuildArrayActions('values', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newEnum) {
3386
+ var buildArrayActions = createBuildArrayActions('values', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newEnum) {
3642
3387
  return {
3643
3388
  fieldName: fieldName,
3644
3389
  action: addEnumActionName,
3645
3390
  value: newEnum
3646
3391
  };
3647
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldEnum, newEnum) {
3392
+ }), CHANGE_ACTIONS, function (oldEnum, newEnum) {
3648
3393
  var oldEnumInNext = next.values.find(function (nextEnum) {
3649
3394
  return nextEnum.key === oldEnum.key;
3650
- }); // These `changeActions` would impose a nested structure among
3395
+ });
3396
+
3397
+ // These `changeActions` would impose a nested structure among
3651
3398
  // the accumulated `updateActions` generated by `buildArrayActions`
3652
3399
  // In the end; we have to flatten the structure before we pass it back
3653
3400
  // to the client.
3654
-
3655
3401
  var changeActions = [];
3656
-
3657
3402
  if (oldEnumInNext) {
3658
3403
  // If the enum value is changed, we need to change the order first
3659
- var isKeyChanged = oldEnum.key !== newEnum.key; // check if the label is changed
3404
+ var isKeyChanged = oldEnum.key !== newEnum.key;
3660
3405
 
3406
+ // check if the label is changed
3661
3407
  var foundPreviousEnum = previous.values.find(function (previousEnum) {
3662
3408
  return previousEnum.key === newEnum.key;
3663
3409
  });
3664
3410
  var isLabelEqual = isEqual__default["default"](foundPreviousEnum.label, newEnum.label);
3665
-
3666
3411
  if (isKeyChanged) {
3667
3412
  // these actions is then flatten in the end
3668
3413
  changeActions.push({
@@ -3671,7 +3416,6 @@
3671
3416
  value: newEnum
3672
3417
  });
3673
3418
  }
3674
-
3675
3419
  if (!isLabelEqual) {
3676
3420
  changeActions.push({
3677
3421
  fieldName: fieldName,
@@ -3686,12 +3430,11 @@
3686
3430
  value: newEnum
3687
3431
  });
3688
3432
  }
3689
-
3690
3433
  return changeActions;
3691
- }), _createBuildArrayActi));
3692
- var actions = []; // following lists are necessary to ensure that when we change the
3434
+ }));
3435
+ var actions = [];
3436
+ // following lists are necessary to ensure that when we change the
3693
3437
  // order of enumValues, we generate one updateAction instead of one at a time.
3694
-
3695
3438
  var newEnumValuesOrder = [];
3696
3439
  flatten__default["default"](buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
3697
3440
  if (updateAction.action === changeEnumOrderActionName) {
@@ -3706,18 +3449,14 @@
3706
3449
  keys: newEnumValuesOrder
3707
3450
  }] : []));
3708
3451
  }
3709
-
3710
3452
  function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPaths) {
3711
3453
  var actions = [];
3712
3454
  forEach__default["default"](fieldDefinitionsDiff, function (diffValue, diffKey) {
3713
3455
  var extractedPairs = extractMatchingPairs(diffPaths, diffKey, previous, next);
3714
-
3715
3456
  if (getIsChangedOperation(diffKey)) {
3716
3457
  var _diffValue$type;
3717
-
3718
3458
  if (Array.isArray(diffValue)) {
3719
3459
  var deltaValue = getDeltaValue(diffValue);
3720
-
3721
3460
  if (deltaValue.name) {
3722
3461
  actions.push({
3723
3462
  action: 'addFieldDefinition',
@@ -3750,7 +3489,6 @@
3750
3489
  });
3751
3490
  } else {
3752
3491
  var _deltaValue = getDeltaValue(diffValue);
3753
-
3754
3492
  if (_deltaValue === undefined && diffValue[0].name) actions.push({
3755
3493
  action: 'removeFieldDefinition',
3756
3494
  fieldName: diffValue[0].name
@@ -3758,11 +3496,12 @@
3758
3496
  }
3759
3497
  }
3760
3498
  }
3761
- }); // Make sure to execute removeActions before creating new ones
3499
+ });
3500
+
3501
+ // Make sure to execute removeActions before creating new ones
3762
3502
  // in order to prevent any eventual removal of `addAction`.
3763
3503
  // List of `removeActions` can be found here
3764
3504
  // https://docs.commercetools.com/http-api-projects-types.html#change-key
3765
-
3766
3505
  var sortedActions = sortBy__default["default"](actions, function (action) {
3767
3506
  return action.action !== 'removeFieldDefinition';
3768
3507
  });
@@ -3780,7 +3519,6 @@
3780
3519
  return flatten__default["default"](allActions);
3781
3520
  };
3782
3521
  }
3783
-
3784
3522
  var types = (function (actionGroupList, syncActionConfig) {
3785
3523
  var mapActionGroup = createMapActionGroup(actionGroupList);
3786
3524
  var doMapActions = createTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3808,6 +3546,15 @@
3808
3546
  }, {
3809
3547
  action: 'setShippingRateInputType',
3810
3548
  key: 'shippingRateInputType'
3549
+ }, {
3550
+ action: 'changeMyBusinessUnitStatusOnCreation',
3551
+ key: 'myBusinessUnitStatusOnCreation'
3552
+ }, {
3553
+ action: 'setMyBusinessUnitAssociateRoleOnCreation',
3554
+ key: 'myBusinessUnitAssociateRoleOnCreation'
3555
+ }, {
3556
+ action: 'changeCustomerSearchStatus',
3557
+ key: 'customerSearchStatus'
3811
3558
  }];
3812
3559
  function actionsMapBase$4(diff, oldObj, newObj) {
3813
3560
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -3829,7 +3576,6 @@
3829
3576
  return flatten__default["default"](allActions);
3830
3577
  };
3831
3578
  }
3832
-
3833
3579
  var projects = (function (actionGroupList) {
3834
3580
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3835
3581
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3874,7 +3620,6 @@
3874
3620
  return flatten__default["default"](allActions);
3875
3621
  };
3876
3622
  }
3877
-
3878
3623
  var stores = (function (actionGroupList) {
3879
3624
  var mapActionGroup = createMapActionGroup(actionGroupList);
3880
3625
  var doMapActions = createStoresMapActions(mapActionGroup);
@@ -3913,7 +3658,6 @@
3913
3658
  return flatten__default["default"](allActions);
3914
3659
  };
3915
3660
  }
3916
-
3917
3661
  var productSelections = (function (actionGroupList) {
3918
3662
  var mapActionGroup = createMapActionGroup(actionGroupList);
3919
3663
  var doMapActions = createProductSelectionsMapActions(mapActionGroup);
@@ -3930,7 +3674,8 @@
3930
3674
  }, {
3931
3675
  action: 'setDiscountedPrice',
3932
3676
  key: 'discounted'
3933
- }, // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3677
+ },
3678
+ // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3934
3679
  {
3935
3680
  action: 'setPriceTiers',
3936
3681
  key: 'tiers'
@@ -3969,7 +3714,6 @@
3969
3714
  return combineValidityActions([].concat(_toConsumableArray(baseActions), _toConsumableArray(customActions)));
3970
3715
  };
3971
3716
  }
3972
-
3973
3717
  var prices = (function (actionGroupList, syncActionConfig) {
3974
3718
  var mapActionGroup = createMapActionGroup(actionGroupList);
3975
3719
  var doMapActions = createPriceMapActions(mapActionGroup, syncActionConfig);
@@ -3984,7 +3728,6 @@
3984
3728
  return attribute.key === newValue.key;
3985
3729
  });
3986
3730
  };
3987
-
3988
3731
  var baseActionsList = [{
3989
3732
  action: 'changeName',
3990
3733
  key: 'name'
@@ -4006,35 +3749,34 @@
4006
3749
  });
4007
3750
  }
4008
3751
  function actionsMapAttributes(diff, oldObj, newObj) {
4009
- var _createBuildArrayActi;
4010
-
4011
- var handler = createBuildArrayActions('attributes', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAttribute) {
3752
+ var handler = createBuildArrayActions('attributes', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAttribute) {
4012
3753
  return {
4013
3754
  action: 'addAttribute',
4014
3755
  attribute: newAttribute
4015
3756
  };
4016
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAttribute) {
3757
+ }), REMOVE_ACTIONS, function (oldAttribute) {
4017
3758
  // We only add the action if the attribute is not included in the new object.
4018
3759
  return !hasAttribute(newObj.attributes, oldAttribute) ? {
4019
3760
  action: 'removeAttribute',
4020
3761
  attribute: oldAttribute
4021
3762
  } : null;
4022
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
4023
- var result = []; // We only remove the attribute in case that the oldAttribute is not
3763
+ }), CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
3764
+ var result = [];
3765
+ // We only remove the attribute in case that the oldAttribute is not
4024
3766
  // included in the new object
4025
-
4026
3767
  if (!hasAttribute(newObj.attributes, oldAttribute)) result.push({
4027
3768
  action: 'removeAttribute',
4028
3769
  attribute: oldAttribute
4029
- }); // We only add the attribute in case that the newAttribute was not
4030
- // included in the old object
3770
+ });
4031
3771
 
3772
+ // We only add the attribute in case that the newAttribute was not
3773
+ // included in the old object
4032
3774
  if (!hasAttribute(oldObj.attributes, newAttribute)) result.push({
4033
3775
  action: 'addAttribute',
4034
3776
  attribute: newAttribute
4035
3777
  });
4036
3778
  return result;
4037
- }), _createBuildArrayActi));
3779
+ }));
4038
3780
  return handler(diff, oldObj, newObj);
4039
3781
  }
4040
3782
 
@@ -4050,7 +3792,6 @@
4050
3792
  return flatten__default["default"](allActions);
4051
3793
  };
4052
3794
  }
4053
-
4054
3795
  var attributeGroups = (function (actionGroupList, syncActionConfig) {
4055
3796
  var mapActionGroup = createMapActionGroup(actionGroupList);
4056
3797
  var doMapActions = createAttributeGroupsMapActions(mapActionGroup, syncActionConfig);