@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.
@@ -7,174 +7,143 @@ import intersection from 'lodash.intersection';
7
7
  import without from 'lodash.without';
8
8
  import sortBy from 'lodash.sortby';
9
9
 
10
- function ownKeys(object, enumerableOnly) {
11
- var keys = Object.keys(object);
12
-
13
- if (Object.getOwnPropertySymbols) {
14
- var symbols = Object.getOwnPropertySymbols(object);
15
- enumerableOnly && (symbols = symbols.filter(function (sym) {
16
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17
- })), keys.push.apply(keys, symbols);
10
+ function _arrayLikeToArray(r, a) {
11
+ (null == a || a > r.length) && (a = r.length);
12
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
13
+ return n;
14
+ }
15
+ function _arrayWithHoles(r) {
16
+ if (Array.isArray(r)) return r;
17
+ }
18
+ function _arrayWithoutHoles(r) {
19
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
20
+ }
21
+ function _defineProperty(e, r, t) {
22
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
23
+ value: t,
24
+ enumerable: !0,
25
+ configurable: !0,
26
+ writable: !0
27
+ }) : e[r] = t, e;
28
+ }
29
+ function _iterableToArray(r) {
30
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
31
+ }
32
+ function _iterableToArrayLimit(r, l) {
33
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
34
+ if (null != t) {
35
+ var e,
36
+ n,
37
+ i,
38
+ u,
39
+ a = [],
40
+ f = !0,
41
+ o = !1;
42
+ try {
43
+ if (i = (t = t.call(r)).next, 0 === l) {
44
+ if (Object(t) !== t) return;
45
+ f = !1;
46
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
47
+ } catch (r) {
48
+ o = !0, n = r;
49
+ } finally {
50
+ try {
51
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
52
+ } finally {
53
+ if (o) throw n;
54
+ }
55
+ }
56
+ return a;
18
57
  }
19
-
20
- return keys;
21
58
  }
22
-
23
- function _objectSpread2(target) {
24
- for (var i = 1; i < arguments.length; i++) {
25
- var source = null != arguments[i] ? arguments[i] : {};
26
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
27
- _defineProperty(target, key, source[key]);
28
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
29
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
30
- });
31
- }
32
-
33
- return target;
59
+ function _nonIterableRest() {
60
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
61
  }
35
-
36
- function _typeof(obj) {
37
- "@babel/helpers - typeof";
38
-
39
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
40
- return typeof obj;
41
- } : function (obj) {
42
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
43
- }, _typeof(obj);
62
+ function _nonIterableSpread() {
63
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
64
  }
45
-
46
- function _defineProperty(obj, key, value) {
47
- if (key in obj) {
48
- Object.defineProperty(obj, key, {
49
- value: value,
50
- enumerable: true,
51
- configurable: true,
52
- writable: true
53
- });
54
- } else {
55
- obj[key] = value;
65
+ function ownKeys(e, r) {
66
+ var t = Object.keys(e);
67
+ if (Object.getOwnPropertySymbols) {
68
+ var o = Object.getOwnPropertySymbols(e);
69
+ r && (o = o.filter(function (r) {
70
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
71
+ })), t.push.apply(t, o);
56
72
  }
57
-
58
- return obj;
59
- }
60
-
61
- function _objectWithoutPropertiesLoose(source, excluded) {
62
- if (source == null) return {};
63
- var target = {};
64
- var sourceKeys = Object.keys(source);
65
- var key, i;
66
-
67
- for (i = 0; i < sourceKeys.length; i++) {
68
- key = sourceKeys[i];
69
- if (excluded.indexOf(key) >= 0) continue;
70
- target[key] = source[key];
73
+ return t;
74
+ }
75
+ function _objectSpread2(e) {
76
+ for (var r = 1; r < arguments.length; r++) {
77
+ var t = null != arguments[r] ? arguments[r] : {};
78
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
79
+ _defineProperty(e, r, t[r]);
80
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
81
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
82
+ });
71
83
  }
72
-
73
- return target;
84
+ return e;
74
85
  }
75
-
76
- function _objectWithoutProperties(source, excluded) {
77
- if (source == null) return {};
78
-
79
- var target = _objectWithoutPropertiesLoose(source, excluded);
80
-
81
- var key, i;
82
-
86
+ function _objectWithoutProperties(e, t) {
87
+ if (null == e) return {};
88
+ var o,
89
+ r,
90
+ i = _objectWithoutPropertiesLoose(e, t);
83
91
  if (Object.getOwnPropertySymbols) {
84
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
85
-
86
- for (i = 0; i < sourceSymbolKeys.length; i++) {
87
- key = sourceSymbolKeys[i];
88
- if (excluded.indexOf(key) >= 0) continue;
89
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
90
- target[key] = source[key];
91
- }
92
+ var s = Object.getOwnPropertySymbols(e);
93
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
92
94
  }
93
-
94
- return target;
95
- }
96
-
97
- function _slicedToArray(arr, i) {
98
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
99
- }
100
-
101
- function _toConsumableArray(arr) {
102
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
95
+ return i;
96
+ }
97
+ function _objectWithoutPropertiesLoose(r, e) {
98
+ if (null == r) return {};
99
+ var t = {};
100
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
101
+ if (e.includes(n)) continue;
102
+ t[n] = r[n];
103
+ }
104
+ return t;
103
105
  }
104
-
105
- function _arrayWithoutHoles(arr) {
106
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
106
+ function _slicedToArray(r, e) {
107
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
107
108
  }
108
-
109
- function _arrayWithHoles(arr) {
110
- if (Array.isArray(arr)) return arr;
109
+ function _toConsumableArray(r) {
110
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
111
111
  }
112
-
113
- function _iterableToArray(iter) {
114
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
115
- }
116
-
117
- function _iterableToArrayLimit(arr, i) {
118
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
119
-
120
- if (_i == null) return;
121
- var _arr = [];
122
- var _n = true;
123
- var _d = false;
124
-
125
- var _s, _e;
126
-
127
- try {
128
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
129
- _arr.push(_s.value);
130
-
131
- if (i && _arr.length === i) break;
132
- }
133
- } catch (err) {
134
- _d = true;
135
- _e = err;
136
- } finally {
137
- try {
138
- if (!_n && _i["return"] != null) _i["return"]();
139
- } finally {
140
- if (_d) throw _e;
141
- }
112
+ function _toPrimitive(t, r) {
113
+ if ("object" != typeof t || !t) return t;
114
+ var e = t[Symbol.toPrimitive];
115
+ if (void 0 !== e) {
116
+ var i = e.call(t, r || "default");
117
+ if ("object" != typeof i) return i;
118
+ throw new TypeError("@@toPrimitive must return a primitive value.");
142
119
  }
143
-
144
- return _arr;
145
- }
146
-
147
- function _unsupportedIterableToArray(o, minLen) {
148
- if (!o) return;
149
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
150
- var n = Object.prototype.toString.call(o).slice(8, -1);
151
- if (n === "Object" && o.constructor) n = o.constructor.name;
152
- if (n === "Map" || n === "Set") return Array.from(o);
153
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
154
- }
155
-
156
- function _arrayLikeToArray(arr, len) {
157
- if (len == null || len > arr.length) len = arr.length;
158
-
159
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
160
-
161
- return arr2;
120
+ return ("string" === r ? String : Number)(t);
162
121
  }
163
-
164
- function _nonIterableSpread() {
165
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
122
+ function _toPropertyKey(t) {
123
+ var i = _toPrimitive(t, "string");
124
+ return "symbol" == typeof i ? i : i + "";
166
125
  }
126
+ function _typeof(o) {
127
+ "@babel/helpers - typeof";
167
128
 
168
- function _nonIterableRest() {
169
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
129
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
130
+ return typeof o;
131
+ } : function (o) {
132
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
133
+ }, _typeof(o);
134
+ }
135
+ function _unsupportedIterableToArray(r, a) {
136
+ if (r) {
137
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
138
+ var t = {}.toString.call(r).slice(8, -1);
139
+ 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;
140
+ }
170
141
  }
171
142
 
172
143
  var _excluded$1 = ["prices"];
173
-
174
144
  function applyOnBeforeDiff(before, now, fn) {
175
145
  return fn && typeof fn === 'function' ? fn(before, now) : [before, now];
176
146
  }
177
-
178
147
  var createPriceComparator = function createPriceComparator(price) {
179
148
  return {
180
149
  value: {
@@ -187,13 +156,11 @@ var createPriceComparator = function createPriceComparator(price) {
187
156
  validUntil: price.validUntil
188
157
  };
189
158
  };
190
-
191
159
  function arePricesStructurallyEqual(oldPrice, newPrice) {
192
160
  var oldPriceComparison = createPriceComparator(oldPrice);
193
161
  var newPriceComparison = createPriceComparator(newPrice);
194
162
  return isEqual(newPriceComparison, oldPriceComparison);
195
163
  }
196
-
197
164
  function extractPriceFromPreviousVariant(newPrice, previousVariant) {
198
165
  if (!previousVariant) return null;
199
166
  var price = previousVariant.prices.find(function (oldPrice) {
@@ -201,12 +168,10 @@ function extractPriceFromPreviousVariant(newPrice, previousVariant) {
201
168
  });
202
169
  return price || null;
203
170
  }
204
-
205
171
  function injectMissingPriceIds(nextVariants, previousVariants) {
206
172
  return nextVariants.map(function (newVariant) {
207
173
  var prices = newVariant.prices,
208
- restOfVariant = _objectWithoutProperties(newVariant, _excluded$1);
209
-
174
+ restOfVariant = _objectWithoutProperties(newVariant, _excluded$1);
210
175
  if (!prices) return restOfVariant;
211
176
  var oldVariant = previousVariants.find(function (previousVariant) {
212
177
  return !isNil(previousVariant.id) && previousVariant.id === newVariant.id || !isNil(previousVariant.key) && previousVariant.key === newVariant.key || !isNil(previousVariant.sku) && previousVariant.sku === newVariant.sku;
@@ -214,33 +179,27 @@ function injectMissingPriceIds(nextVariants, previousVariants) {
214
179
  return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
215
180
  prices: prices.map(function (price) {
216
181
  var newPrice = _objectSpread2({}, price);
217
-
218
182
  var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
219
-
220
183
  if (oldPrice) {
221
184
  // copy ID if not provided
222
185
  if (!newPrice.id) newPrice.id = oldPrice.id;
223
186
  if (isNil(newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
224
187
  if (isNil(newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
225
188
  }
226
-
227
189
  return newPrice;
228
190
  })
229
191
  });
230
192
  });
231
193
  }
232
-
233
194
  function createBuildActions(differ, doMapActions, onBeforeDiff) {
234
195
  var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
235
196
  return function buildActions(now, before) {
236
197
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
237
198
  if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
238
-
239
199
  var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
240
- _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
241
- processedBefore = _applyOnBeforeDiff2[0],
242
- processedNow = _applyOnBeforeDiff2[1];
243
-
200
+ _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
201
+ processedBefore = _applyOnBeforeDiff2[0],
202
+ processedNow = _applyOnBeforeDiff2[1];
244
203
  if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
245
204
  var diffed = differ(processedBefore, processedNow);
246
205
  if (!buildActionsConfig.withHints && !diffed) return [];
@@ -262,10 +221,11 @@ function createMapActionGroup() {
262
221
  var found = actionGroups.find(function (c) {
263
222
  return c.type === type;
264
223
  });
265
- if (!found) return []; // Keep `black` for backwards compatibility.
266
-
267
- if (found.group === 'ignore' || found.group === 'black') return []; // Keep `white` for backwards compatibility.
224
+ if (!found) return [];
268
225
 
226
+ // Keep `black` for backwards compatibility.
227
+ if (found.group === 'ignore' || found.group === 'black') return [];
228
+ // Keep `white` for backwards compatibility.
269
229
  if (found.group === 'allow' || found.group === 'white') return fn();
270
230
  throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
271
231
  };
@@ -275,7 +235,6 @@ function createMapActionGroup() {
275
235
  // with es6 modules so we use require instead below
276
236
  // TODO create an issue here https://github.com/benjamine/jsondiffpatch/issues/new
277
237
  var DiffPatcher = require('jsondiffpatch').DiffPatcher;
278
-
279
238
  function objectHash(obj, index) {
280
239
  var objIndex = "$$index:".concat(index);
281
240
  return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
@@ -315,12 +274,12 @@ function getDeltaValue(arr, originalObject) {
315
274
 
316
275
  if (arr.length === 3 && arr[2] === 2) {
317
276
  // text diff
318
- 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
319
-
277
+ if (!originalObject) throw new Error('Cannot apply patch to long text diff. Missing original object.');
278
+ // try to apply patch to given object based on delta value
320
279
  return patch(originalObject, arr);
321
280
  }
322
-
323
- if (arr.length === 3 && arr[2] === 3) // array move
281
+ if (arr.length === 3 && arr[2] === 3)
282
+ // array move
324
283
  throw new Error('Detected an array move, it should not happen as ' + '`includeValueOnMove` should be set to false');
325
284
  throw new Error("Got unsupported number ".concat(arr[2], " in delta value"));
326
285
  }
@@ -330,52 +289,39 @@ var Actions = {
330
289
  setCustomType: 'setCustomType',
331
290
  setCustomField: 'setCustomField'
332
291
  };
333
-
334
292
  var hasSingleCustomFieldChanged = function hasSingleCustomFieldChanged(diff) {
335
293
  return Array.isArray(diff.custom);
336
294
  };
337
-
338
295
  var haveMultipleCustomFieldsChanged = function haveMultipleCustomFieldsChanged(diff) {
339
296
  return Boolean(diff.custom.fields);
340
297
  };
341
-
342
298
  var hasCustomTypeChanged = function hasCustomTypeChanged(diff) {
343
299
  return Boolean(diff.custom.type);
344
300
  };
345
-
346
301
  var extractCustomType = function extractCustomType(diff, previousObject) {
347
302
  return Array.isArray(diff.custom.type) ? getDeltaValue(diff.custom.type, previousObject) : diff.custom.type;
348
303
  };
349
-
350
304
  var extractTypeId = function extractTypeId(type, nextObject) {
351
305
  return Array.isArray(type.id) ? getDeltaValue(type.id) : nextObject.custom.type.id;
352
306
  };
353
-
354
307
  var extractTypeKey = function extractTypeKey(type, nextObject) {
355
308
  return Array.isArray(type.key) ? getDeltaValue(type.key) : nextObject.custom.type.key;
356
309
  };
357
-
358
310
  var extractTypeFields = function extractTypeFields(diffedFields, nextFields) {
359
311
  return Array.isArray(diffedFields) ? getDeltaValue(diffedFields) : nextFields;
360
312
  };
361
-
362
313
  var extractFieldValue = function extractFieldValue(newFields, fieldName) {
363
314
  return newFields[fieldName];
364
315
  };
365
-
366
316
  function actionsMapCustom(diff, newObj, oldObj) {
367
317
  var customProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
368
318
  actions: {}
369
319
  };
370
320
  var actions = [];
371
-
372
321
  var customPropsActions = customProps.actions,
373
- options = _objectWithoutProperties(customProps, _excluded);
374
-
322
+ options = _objectWithoutProperties(customProps, _excluded);
375
323
  var actionGroup = _objectSpread2(_objectSpread2({}, Actions), customPropsActions);
376
-
377
324
  if (!diff.custom) return actions;
378
-
379
325
  if (hasSingleCustomFieldChanged(diff)) {
380
326
  // If custom is not defined on the new or old category
381
327
  var custom = getDeltaValue(diff.custom, oldObj);
@@ -415,7 +361,6 @@ function actionsMapCustom(diff, newObj, oldObj) {
415
361
  });
416
362
  actions.push.apply(actions, _toConsumableArray(customFieldsActions));
417
363
  }
418
-
419
364
  return actions;
420
365
  }
421
366
 
@@ -424,6 +369,7 @@ var REGEX_UNDERSCORE_NUMBER$4 = new RegExp(/^_\d+$/);
424
369
  var ADD_ACTIONS = 'create';
425
370
  var REMOVE_ACTIONS = 'remove';
426
371
  var CHANGE_ACTIONS = 'change';
372
+
427
373
  /**
428
374
  * Tests a delta to see if it represents a create action.
429
375
  * eg. delta:
@@ -436,10 +382,10 @@ var CHANGE_ACTIONS = 'change';
436
382
  * @return {Boolean} Returns true if delta represents a create action,
437
383
  * false otherwise
438
384
  */
439
-
440
385
  function isCreateAction(obj, key) {
441
386
  return REGEX_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 1;
442
387
  }
388
+
443
389
  /**
444
390
  * Tests a delta to see if it represents a change action.
445
391
  * eg. delta:
@@ -454,11 +400,10 @@ function isCreateAction(obj, key) {
454
400
  * @return {Boolean} Returns true if delta represents a change action,
455
401
  * false otherwise
456
402
  */
457
-
458
-
459
403
  function isChangeAction(obj, key) {
460
404
  return REGEX_NUMBER$4.test(key) && (_typeof(obj[key]) === 'object' || typeof obj[key] === 'string');
461
405
  }
406
+
462
407
  /**
463
408
  * Tests a delta to see if it represents a remove action.
464
409
  * eg. delta:
@@ -471,11 +416,10 @@ function isChangeAction(obj, key) {
471
416
  * @return {Boolean} Returns true if delta represents a remove action,
472
417
  * false otherwise
473
418
  */
474
-
475
-
476
419
  function isRemoveAction$1(obj, key) {
477
420
  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;
478
421
  }
422
+
479
423
  /**
480
424
  * Generate + configure a function to build actions for nested objects
481
425
  * @param {string} key key of the attribute containing the array of
@@ -486,39 +430,33 @@ function isRemoveAction$1(obj, key) {
486
430
  * return an action object.
487
431
  * @return {Array} The generated array of actions
488
432
  */
489
-
490
-
491
433
  function createBuildArrayActions(key, config) {
492
434
  return function buildArrayActions(diff, oldObj, newObj) {
493
435
  var addActions = [];
494
436
  var removeActions = [];
495
437
  var changeActions = [];
496
-
497
438
  if (diff[key]) {
498
439
  var arrayDelta = diff[key];
499
440
  Object.keys(arrayDelta).forEach(function (index) {
500
441
  if (config[ADD_ACTIONS] && isCreateAction(arrayDelta, index)) {
501
- var actionGenerator = config[ADD_ACTIONS]; // When adding a new element you don't need the oldObj
502
-
442
+ var actionGenerator = config[ADD_ACTIONS];
443
+ // When adding a new element you don't need the oldObj
503
444
  var action = actionGenerator(newObj[key][index], parseInt(index, 10));
504
445
  if (action) addActions.push(action);
505
446
  } else if (config[CHANGE_ACTIONS] && isChangeAction(arrayDelta, index)) {
506
- var _actionGenerator = config[CHANGE_ACTIONS]; // When changing an existing element you need both old + new
507
-
447
+ var _actionGenerator = config[CHANGE_ACTIONS];
448
+ // When changing an existing element you need both old + new
508
449
  var _action = _actionGenerator(oldObj[key][index], newObj[key][index], parseInt(index, 10));
509
-
510
450
  if (_action) changeActions.push(_action);
511
451
  } else if (config[REMOVE_ACTIONS] && isRemoveAction$1(arrayDelta, index)) {
512
452
  var realIndex = index.replace('_', '');
513
- var _actionGenerator2 = config[REMOVE_ACTIONS]; // When removing an existing element you don't need the newObj
514
-
453
+ var _actionGenerator2 = config[REMOVE_ACTIONS];
454
+ // When removing an existing element you don't need the newObj
515
455
  var _action2 = _actionGenerator2(oldObj[key][realIndex], parseInt(realIndex, 10));
516
-
517
456
  if (_action2) removeActions.push(_action2);
518
457
  }
519
458
  });
520
459
  }
521
-
522
460
  return changeActions.concat(removeActions, addActions);
523
461
  };
524
462
  }
@@ -531,21 +469,19 @@ function toAssetIdentifier$1(asset) {
531
469
  };
532
470
  return assetIdentifier;
533
471
  }
534
-
535
472
  function actionsMapAssets$1(diff, oldObj, newObj) {
536
- var _createBuildArrayActi;
537
-
538
- var handler = createBuildArrayActions('assets', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAsset) {
473
+ var handler = createBuildArrayActions('assets', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAsset) {
539
474
  return {
540
475
  action: 'addAsset',
541
476
  asset: newAsset
542
477
  };
543
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAsset) {
478
+ }), REMOVE_ACTIONS, function (oldAsset) {
544
479
  return _objectSpread2({
545
480
  action: 'removeAsset'
546
481
  }, toAssetIdentifier$1(oldAsset));
547
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAsset, newAsset) {
548
- return (// here we could use more atomic update actions (e.g. changeAssetName)
482
+ }), CHANGE_ACTIONS, function (oldAsset, newAsset) {
483
+ return (
484
+ // here we could use more atomic update actions (e.g. changeAssetName)
549
485
  // but for now we use the simpler approach to first remove and then
550
486
  // re-add the asset - which reduces the code complexity
551
487
  [_objectSpread2({
@@ -555,7 +491,7 @@ function actionsMapAssets$1(diff, oldObj, newObj) {
555
491
  asset: newAsset
556
492
  }]
557
493
  );
558
- }), _createBuildArrayActi));
494
+ }));
559
495
  return handler(diff, oldObj, newObj);
560
496
  }
561
497
 
@@ -566,7 +502,6 @@ function clone(obj) {
566
502
  var normalizeValue = function normalizeValue(value) {
567
503
  return typeof value === 'string' ? value.trim() : value;
568
504
  };
569
-
570
505
  var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
571
506
  return function (value) {
572
507
  return emptyValues.some(function (emptyValue) {
@@ -574,6 +509,7 @@ var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
574
509
  });
575
510
  };
576
511
  };
512
+
577
513
  /**
578
514
  * Builds actions for simple object properties, given a list of actions
579
515
  * E.g. [{ action: `changeName`, key: 'name' }]
@@ -585,17 +521,15 @@ var createIsEmptyValue = function createIsEmptyValue(emptyValues) {
585
521
  * @param {Object} options.newObj - the new representation of the object
586
522
  * @param {Boolean} options.shouldOmitEmptyString - a flag to determine if we should treat an empty string a NON-value
587
523
  */
588
-
589
524
  function buildBaseAttributesActions(_ref) {
590
525
  var actions = _ref.actions,
591
- diff = _ref.diff,
592
- oldObj = _ref.oldObj,
593
- newObj = _ref.newObj,
594
- shouldOmitEmptyString = _ref.shouldOmitEmptyString;
526
+ diff = _ref.diff,
527
+ oldObj = _ref.oldObj,
528
+ newObj = _ref.newObj,
529
+ shouldOmitEmptyString = _ref.shouldOmitEmptyString;
595
530
  var isEmptyValue = createIsEmptyValue(shouldOmitEmptyString ? [undefined, null, ''] : [undefined, null]);
596
531
  return actions.map(function (item) {
597
532
  var key = item.key; // e.g.: name, description, ...
598
-
599
533
  var actionKey = item.actionKey || item.key;
600
534
  var delta = diff[key];
601
535
  var before = oldObj[key];
@@ -604,18 +538,21 @@ function buildBaseAttributesActions(_ref) {
604
538
  var isNotDefinedNow = isEmptyValue(newObj[key]);
605
539
  if (!delta) return undefined;
606
540
  if (isNotDefinedNow && isNotDefinedBefore) return undefined;
607
- if (!isNotDefinedNow && isNotDefinedBefore) // no value previously set
541
+ if (!isNotDefinedNow && isNotDefinedBefore)
542
+ // no value previously set
608
543
  return _defineProperty({
609
544
  action: item.action
610
545
  }, actionKey, now);
611
- /* no new value */
612
546
 
547
+ /* no new value */
613
548
  if (isNotDefinedNow && !{}.hasOwnProperty.call(newObj, key)) return undefined;
614
- if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key)) // value unset
549
+ if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key))
550
+ // value unset
615
551
  return {
616
552
  action: item.action
617
- }; // We need to clone `before` as `patch` will mutate it
553
+ };
618
554
 
555
+ // We need to clone `before` as `patch` will mutate it
619
556
  var patched = patch(clone(before), delta);
620
557
  return _defineProperty({
621
558
  action: item.action
@@ -624,6 +561,7 @@ function buildBaseAttributesActions(_ref) {
624
561
  return !isNil(action);
625
562
  });
626
563
  }
564
+
627
565
  /**
628
566
  * Builds actions for simple reference objects, given a list of actions
629
567
  * E.g. [{ action: `setTaxCategory`, key: 'taxCategory' }]
@@ -634,23 +572,24 @@ function buildBaseAttributesActions(_ref) {
634
572
  * @param {Object} options.oldObj - the object that needs to be updated
635
573
  * @param {Object} options.newObj - the new representation of the object
636
574
  */
637
-
638
575
  function buildReferenceActions(_ref4) {
639
576
  var actions = _ref4.actions,
640
- diff = _ref4.diff,
641
- newObj = _ref4.newObj;
577
+ diff = _ref4.diff,
578
+ newObj = _ref4.newObj;
642
579
  return actions.map(function (item) {
643
580
  var action = item.action;
644
581
  var key = item.key;
645
-
646
- if (diff[key] && ( // The `key` value was added or removed
647
- Array.isArray(diff[key]) || // The `key` value id changed
582
+ if (diff[key] && (
583
+ // The `key` value was added or removed
584
+ Array.isArray(diff[key]) ||
585
+ // The `key` value id changed
648
586
  diff[key].id)) {
649
587
  var newValue = Array.isArray(diff[key]) ? getDeltaValue(diff[key]) : newObj[key];
650
588
  if (!newValue) return {
651
589
  action: action
652
- }; // When the `id` of the object is undefined
590
+ };
653
591
 
592
+ // When the `id` of the object is undefined
654
593
  if (!newValue.id) {
655
594
  return _defineProperty({
656
595
  action: action
@@ -659,7 +598,6 @@ function buildReferenceActions(_ref4) {
659
598
  key: newValue.key
660
599
  });
661
600
  }
662
-
663
601
  return _defineProperty({
664
602
  action: action
665
603
  }, key, {
@@ -667,7 +605,6 @@ function buildReferenceActions(_ref4) {
667
605
  id: newValue.id
668
606
  });
669
607
  }
670
-
671
608
  return undefined;
672
609
  }).filter(function (action) {
673
610
  return action;
@@ -707,6 +644,7 @@ var referenceActionsList$3 = [{
707
644
  action: 'changeParent',
708
645
  key: 'parent'
709
646
  }];
647
+
710
648
  /**
711
649
  * SYNC FUNCTIONS
712
650
  */
@@ -739,6 +677,7 @@ function actionsMapMeta$1(diff, oldObj, newObj) {
739
677
  }
740
678
 
741
679
  var CUSTOM = 'custom';
680
+
742
681
  /**
743
682
  * @function copyEmptyArrayProps
744
683
  * @description Create new key with empty array value on `newobj` for the arrays exist on `oldObj` and doesnt exist on `newobj`
@@ -747,74 +686,60 @@ var CUSTOM = 'custom';
747
686
  * @param {Object} newObj
748
687
  * @returns {Array} Ordered Array [oldObj, newObj]
749
688
  */
750
-
751
689
  function copyEmptyArrayProps() {
752
690
  var oldObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
753
691
  var newObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
754
-
755
692
  if (!isNil(oldObj) && !isNil(newObj)) {
756
693
  var nextObjectWithEmptyArray = Object.entries(oldObj).reduce(function (merged, _ref) {
757
694
  var _ref2 = _slicedToArray(_ref, 2),
758
- key = _ref2[0],
759
- value = _ref2[1];
760
-
695
+ key = _ref2[0],
696
+ value = _ref2[1];
761
697
  // Ignore CUSTOM key as this object is dynamic and its up to the user to dynamically change it
762
698
  // todo, it would be better if we pass it as ignored keys param
763
699
  if (key === CUSTOM) return merged;
764
-
765
700
  if (Array.isArray(value) && newObj[key] && newObj[key].length >= 1) {
766
701
  /* eslint-disable no-plusplus */
767
702
  var hashMapValue = value.reduce(function (acc, val) {
768
703
  acc[val.id] = val;
769
704
  return acc;
770
705
  }, {});
771
-
772
706
  for (var i = 0; i < newObj[key].length; i++) {
773
707
  if (!isNil(newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil(newObj[key][i].id)) {
774
708
  // Since its unordered array elements then check if the element on `oldObj` exists by id
775
709
  var foundObject = hashMapValue[newObj[key][i].id];
776
-
777
710
  if (!isNil(foundObject)) {
778
711
  var _copyEmptyArrayProps = copyEmptyArrayProps(foundObject, newObj[key][i]),
779
- _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
780
- nestedObject = _copyEmptyArrayProps2[1];
781
-
712
+ _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
713
+ nestedObject = _copyEmptyArrayProps2[1];
782
714
  if (Object.isFrozen(merged[key])) {
783
715
  /* eslint-disable no-param-reassign */
784
716
  merged[key] = merged[key].slice();
785
717
  }
786
718
  /* eslint-disable no-param-reassign */
787
-
788
-
789
719
  merged[key][i] = nestedObject;
790
720
  }
791
721
  }
792
722
  }
793
-
794
723
  return merged;
795
724
  }
796
-
797
725
  if (Array.isArray(value)) {
798
726
  merged[key] = isNil(newObj[key]) ? [] : newObj[key];
799
727
  return merged;
800
728
  }
801
-
802
- if (!isNil(newObj[key]) && _typeof(value) === 'object' && // Ignore Date as this will create invalid object since typeof date === 'object' return true
729
+ if (!isNil(newObj[key]) && _typeof(value) === 'object' &&
730
+ // Ignore Date as this will create invalid object since typeof date === 'object' return true
803
731
  // ex: {date: new Date()} will result {date: {}}
804
732
  !(value instanceof Date)) {
805
733
  var _copyEmptyArrayProps3 = copyEmptyArrayProps(value, newObj[key]),
806
- _copyEmptyArrayProps4 = _slicedToArray(_copyEmptyArrayProps3, 2),
807
- _nestedObject = _copyEmptyArrayProps4[1];
808
-
734
+ _copyEmptyArrayProps4 = _slicedToArray(_copyEmptyArrayProps3, 2),
735
+ _nestedObject = _copyEmptyArrayProps4[1];
809
736
  merged[key] = _nestedObject;
810
737
  return merged;
811
738
  }
812
-
813
739
  return merged;
814
740
  }, _objectSpread2({}, newObj));
815
741
  return [oldObj, nextObjectWithEmptyArray];
816
742
  }
817
-
818
743
  return [oldObj, newObj];
819
744
  }
820
745
 
@@ -839,14 +764,15 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
839
764
  return flatten(allActions);
840
765
  };
841
766
  }
842
-
843
767
  var categories = (function (actionGroupList, syncActionConfig) {
844
768
  // actionGroupList contains information about which action groups
845
769
  // are allowed or ignored
770
+
846
771
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
847
772
  // - action group name
848
773
  // - callback function that should return a list of actions that correspond
849
774
  // to the for the action group
775
+
850
776
  // this resulting function mapActionGroup will call the callback function
851
777
  // for allowed action groups and return the return value of the callback
852
778
  // It will return an empty array for ignored action groups
@@ -920,6 +846,7 @@ var authenticationModeActionsList = [{
920
846
  key: 'authenticationMode',
921
847
  value: 'password'
922
848
  }];
849
+
923
850
  /**
924
851
  * SYNC FUNCTIONS
925
852
  */
@@ -953,57 +880,51 @@ function actionsMapReferences$2(diff, oldObj, newObj) {
953
880
  });
954
881
  }
955
882
  function actionsMapAddresses(diff, oldObj, newObj) {
956
- var _createBuildArrayActi;
957
-
958
- var handler = createBuildArrayActions('addresses', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newObject) {
883
+ var handler = createBuildArrayActions('addresses', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
959
884
  return {
960
885
  action: 'addAddress',
961
886
  address: newObject
962
887
  };
963
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (objectToRemove) {
888
+ }), REMOVE_ACTIONS, function (objectToRemove) {
964
889
  return {
965
890
  action: 'removeAddress',
966
891
  addressId: objectToRemove.id
967
892
  };
968
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldObject, updatedObject) {
893
+ }), CHANGE_ACTIONS, function (oldObject, updatedObject) {
969
894
  return {
970
895
  action: 'changeAddress',
971
896
  addressId: oldObject.id,
972
897
  address: updatedObject
973
898
  };
974
- }), _createBuildArrayActi));
899
+ }));
975
900
  return handler(diff, oldObj, newObj);
976
901
  }
977
902
  function actionsMapBillingAddresses(diff, oldObj, newObj) {
978
- var _createBuildArrayActi2;
979
-
980
- var handler = createBuildArrayActions('billingAddressIds', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (addressId) {
903
+ var handler = createBuildArrayActions('billingAddressIds', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (addressId) {
981
904
  return {
982
905
  action: 'addBillingAddressId',
983
906
  addressId: addressId
984
907
  };
985
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (addressId) {
908
+ }), REMOVE_ACTIONS, function (addressId) {
986
909
  return {
987
910
  action: 'removeBillingAddressId',
988
911
  addressId: addressId
989
912
  };
990
- }), _createBuildArrayActi2));
913
+ }));
991
914
  return handler(diff, oldObj, newObj);
992
915
  }
993
916
  function actionsMapShippingAddresses(diff, oldObj, newObj) {
994
- var _createBuildArrayActi3;
995
-
996
- var handler = createBuildArrayActions('shippingAddressIds', (_createBuildArrayActi3 = {}, _defineProperty(_createBuildArrayActi3, ADD_ACTIONS, function (addressId) {
917
+ var handler = createBuildArrayActions('shippingAddressIds', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (addressId) {
997
918
  return {
998
919
  action: 'addShippingAddressId',
999
920
  addressId: addressId
1000
921
  };
1001
- }), _defineProperty(_createBuildArrayActi3, REMOVE_ACTIONS, function (addressId) {
922
+ }), REMOVE_ACTIONS, function (addressId) {
1002
923
  return {
1003
924
  action: 'removeShippingAddressId',
1004
925
  addressId: addressId
1005
926
  };
1006
- }), _createBuildArrayActi3));
927
+ }));
1007
928
  return handler(diff, oldObj, newObj);
1008
929
  }
1009
930
  function actionsMapAuthenticationModes(diff, oldObj, newObj) {
@@ -1015,12 +936,11 @@ function actionsMapAuthenticationModes(diff, oldObj, newObj) {
1015
936
  newObj: newObj
1016
937
  });
1017
938
  }
1018
-
1019
939
  function buildAuthenticationModeActions(_ref) {
1020
940
  var actions = _ref.actions,
1021
- diff = _ref.diff,
1022
- oldObj = _ref.oldObj,
1023
- newObj = _ref.newObj;
941
+ diff = _ref.diff,
942
+ oldObj = _ref.oldObj,
943
+ newObj = _ref.newObj;
1024
944
  return actions.map(function (item) {
1025
945
  var key = item.key;
1026
946
  var value = item.value || item.key;
@@ -1034,7 +954,6 @@ function buildAuthenticationModeActions(_ref) {
1034
954
  if (isNotDefinedNow && isNotDefinedBefore) return undefined;
1035
955
  if (newObj.authenticationMode === 'Password' && !newObj.password) throw new Error('Cannot set to Password authentication mode without password');
1036
956
  if ('authenticationMode' in newObj && !authenticationModes.includes(newObj.authenticationMode)) throw new Error('Invalid Authentication Mode');
1037
-
1038
957
  if (!isNotDefinedNow && isNotDefinedBefore) {
1039
958
  // no value previously set
1040
959
  if (newObj.authenticationMode === 'ExternalAuth') return {
@@ -1046,13 +965,14 @@ function buildAuthenticationModeActions(_ref) {
1046
965
  authMode: now
1047
966
  }, value, newObj.password);
1048
967
  }
1049
- /* no new value */
1050
-
1051
968
 
969
+ /* no new value */
1052
970
  if (isNotDefinedNow && !{}.hasOwnProperty.call(newObj, key)) return undefined;
1053
- if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key)) // value unset
1054
- return undefined; // We need to clone `before` as `patch` will mutate it
971
+ if (isNotDefinedNow && {}.hasOwnProperty.call(newObj, key))
972
+ // value unset
973
+ return undefined;
1055
974
 
975
+ // We need to clone `before` as `patch` will mutate it
1056
976
  var patched = patch(clone(before), delta);
1057
977
  if (newObj.authenticationMode === 'ExternalAuth') return {
1058
978
  action: item.action,
@@ -1097,14 +1017,15 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
1097
1017
  return flatten(allActions);
1098
1018
  };
1099
1019
  }
1100
-
1101
1020
  var customers = (function (actionGroupList, syncActionConfig) {
1102
1021
  // actionGroupList contains information about which action groups
1103
1022
  // are allowed or ignored
1023
+
1104
1024
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
1105
1025
  // - action group name
1106
1026
  // - callback function that should return a list of actions that correspond
1107
1027
  // to the for the action group
1028
+
1108
1029
  // this resulting function mapActionGroup will call the callback function
1109
1030
  // for allowed action groups and return the return value of the callback
1110
1031
  // It will return an empty array for ignored action groups
@@ -1131,6 +1052,7 @@ var referenceActionsList$1 = [{
1131
1052
  action: 'setSupplyChannel',
1132
1053
  key: 'supplyChannel'
1133
1054
  }];
1055
+
1134
1056
  /**
1135
1057
  * SYNC FUNCTIONS
1136
1058
  */
@@ -1169,14 +1091,15 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
1169
1091
  return flatten(allActions);
1170
1092
  };
1171
1093
  }
1172
-
1173
1094
  var inventories = (function (actionGroupList, syncActionConfig) {
1174
1095
  // actionGroupList contains information about which action groups
1175
1096
  // are allowed or ignored
1097
+
1176
1098
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
1177
1099
  // - action group name
1178
1100
  // - callback function that should return a list of actions that correspond
1179
1101
  // to the for the action group
1102
+
1180
1103
  // this resulting function mapActionGroup will call the callback function
1181
1104
  // for allowed action groups and return the return value of the callback
1182
1105
  // It will return an empty array for ignored action groups
@@ -1193,14 +1116,12 @@ function extractMatchingPairs(hashMap, key, before, now) {
1193
1116
  var newObjPos;
1194
1117
  var oldObj;
1195
1118
  var newObj;
1196
-
1197
1119
  if (hashMap[key]) {
1198
1120
  oldObjPos = hashMap[key][0];
1199
1121
  newObjPos = hashMap[key][1];
1200
1122
  if (before && before[oldObjPos]) oldObj = before[oldObjPos];
1201
1123
  if (now && now[newObjPos]) newObj = now[newObjPos];
1202
1124
  }
1203
-
1204
1125
  return {
1205
1126
  oldObj: oldObj,
1206
1127
  newObj: newObj
@@ -1209,7 +1130,6 @@ function extractMatchingPairs(hashMap, key, before, now) {
1209
1130
 
1210
1131
  var REGEX_NUMBER$3 = new RegExp(/^\d+$/);
1211
1132
  var REGEX_UNDERSCORE_NUMBER$3 = new RegExp(/^_\d+$/);
1212
-
1213
1133
  function preProcessCollection() {
1214
1134
  var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1215
1135
  var identifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
@@ -1221,23 +1141,20 @@ function preProcessCollection() {
1221
1141
  refByIndex: {},
1222
1142
  refByIdentifier: {}
1223
1143
  });
1224
- } // creates a hash of a location of an item in collection1 and collection2
1225
-
1144
+ }
1226
1145
 
1146
+ // creates a hash of a location of an item in collection1 and collection2
1227
1147
  function findMatchingPairs(diff) {
1228
1148
  var before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1229
1149
  var now = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
1230
1150
  var identifier = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'id';
1231
1151
  var result = {};
1232
-
1233
1152
  var _preProcessCollection = preProcessCollection(before, identifier),
1234
- beforeObjRefByIdentifier = _preProcessCollection.refByIdentifier,
1235
- beforeObjRefByIndex = _preProcessCollection.refByIndex;
1236
-
1153
+ beforeObjRefByIdentifier = _preProcessCollection.refByIdentifier,
1154
+ beforeObjRefByIndex = _preProcessCollection.refByIndex;
1237
1155
  var _preProcessCollection2 = preProcessCollection(now, identifier),
1238
- nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
1239
- nowObjRefByIndex = _preProcessCollection2.refByIndex;
1240
-
1156
+ nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
1157
+ nowObjRefByIndex = _preProcessCollection2.refByIndex;
1241
1158
  forEach(diff, function (item, key) {
1242
1159
  if (REGEX_NUMBER$3.test(key)) {
1243
1160
  var matchingIdentifier = nowObjRefByIndex[key];
@@ -1306,6 +1223,7 @@ var referenceActionsList = [{
1306
1223
  action: 'transitionState',
1307
1224
  key: 'state'
1308
1225
  }];
1226
+
1309
1227
  /**
1310
1228
  * HELPER FUNCTIONS
1311
1229
  */
@@ -1313,19 +1231,15 @@ var referenceActionsList = [{
1313
1231
  var getIsAddAction = function getIsAddAction(key, resource) {
1314
1232
  return REGEX_NUMBER$2.test(key) && Array.isArray(resource) && resource.length;
1315
1233
  };
1316
-
1317
1234
  var getIsUpdateAction = function getIsUpdateAction(key, resource) {
1318
1235
  return REGEX_NUMBER$2.test(key) && Object.keys(resource).length;
1319
1236
  };
1320
-
1321
1237
  var getIsRemoveAction = function getIsRemoveAction(key, resource) {
1322
1238
  return REGEX_UNDERSCORE_NUMBER$2.test(key) && Number(resource[2]) === 0;
1323
1239
  };
1324
-
1325
1240
  var getIsItemMovedAction = function getIsItemMovedAction(key, resource) {
1326
1241
  return REGEX_UNDERSCORE_NUMBER$2.test(key) && Number(resource[2]) === 3;
1327
1242
  };
1328
-
1329
1243
  function _buildSkuActions(variantDiff, oldVariant) {
1330
1244
  if ({}.hasOwnProperty.call(variantDiff, 'sku')) {
1331
1245
  var newValue = getDeltaValue(variantDiff.sku);
@@ -1336,10 +1250,8 @@ function _buildSkuActions(variantDiff, oldVariant) {
1336
1250
  sku: newValue || null
1337
1251
  };
1338
1252
  }
1339
-
1340
1253
  return null;
1341
1254
  }
1342
-
1343
1255
  function _buildKeyActions(variantDiff, oldVariant) {
1344
1256
  if ({}.hasOwnProperty.call(variantDiff, 'key')) {
1345
1257
  var newValue = getDeltaValue(variantDiff.key);
@@ -1350,10 +1262,8 @@ function _buildKeyActions(variantDiff, oldVariant) {
1350
1262
  key: newValue || null
1351
1263
  };
1352
1264
  }
1353
-
1354
1265
  return null;
1355
1266
  }
1356
-
1357
1267
  function _buildNewSetAttributeAction(id, el, sameForAllAttributeNames) {
1358
1268
  var attributeName = el && el.name;
1359
1269
  if (!attributeName) return undefined;
@@ -1363,47 +1273,47 @@ function _buildNewSetAttributeAction(id, el, sameForAllAttributeNames) {
1363
1273
  name: attributeName,
1364
1274
  value: el.value
1365
1275
  };
1366
-
1367
1276
  if (sameForAllAttributeNames.indexOf(attributeName) !== -1) {
1368
1277
  action = _objectSpread2(_objectSpread2({}, action), {}, {
1369
1278
  action: 'setAttributeInAllVariants'
1370
1279
  });
1371
1280
  delete action.variantId;
1372
1281
  }
1373
-
1374
1282
  return action;
1375
1283
  }
1376
-
1377
1284
  function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAllAttributeNames) {
1378
1285
  if (!attribute) return undefined;
1379
1286
  var action = {
1380
1287
  action: 'setAttribute',
1381
1288
  variantId: oldVariant.id,
1382
1289
  name: attribute.name
1383
- }; // Used as original object for patching long diff text
1290
+ };
1384
1291
 
1292
+ // Used as original object for patching long diff text
1385
1293
  var oldAttribute = oldVariant.attributes.find(function (a) {
1386
1294
  return a.name === attribute.name;
1387
1295
  }) || {};
1388
-
1389
1296
  if (sameForAllAttributeNames.indexOf(attribute.name) !== -1) {
1390
1297
  action = _objectSpread2(_objectSpread2({}, action), {}, {
1391
1298
  action: 'setAttributeInAllVariants'
1392
1299
  });
1393
1300
  delete action.variantId;
1394
1301
  }
1395
-
1396
- if (Array.isArray(diffedValue)) action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (typeof diffedValue === 'string') // LText: value: {en: "", de: ""}
1302
+ if (Array.isArray(diffedValue)) action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (typeof diffedValue === 'string')
1303
+ // LText: value: {en: "", de: ""}
1397
1304
  // Enum: value: {key: "foo", label: "Foo"}
1398
1305
  // LEnum: value: {key: "foo", label: {en: "Foo", de: "Foo"}}
1399
1306
  // Money: value: {centAmount: 123, currencyCode: ""}
1400
1307
  // *: value: ""
1308
+
1401
1309
  // normal
1402
- action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (diffedValue.centAmount || diffedValue.currencyCode) // Money
1310
+ action.value = getDeltaValue(diffedValue, oldAttribute.value);else if (diffedValue.centAmount || diffedValue.currencyCode)
1311
+ // Money
1403
1312
  action.value = {
1404
1313
  centAmount: diffedValue.centAmount ? getDeltaValue(diffedValue.centAmount) : attribute.value.centAmount,
1405
1314
  currencyCode: diffedValue.currencyCode ? getDeltaValue(diffedValue.currencyCode) : attribute.value.currencyCode
1406
- };else if (diffedValue.key) // Enum / LEnum (use only the key)
1315
+ };else if (diffedValue.key)
1316
+ // Enum / LEnum (use only the key)
1407
1317
  action.value = getDeltaValue(diffedValue.key);else if (_typeof(diffedValue) === 'object') if ({}.hasOwnProperty.call(diffedValue, '_t') && diffedValue._t === 'a') {
1408
1318
  // set-typed attribute
1409
1319
  action = _objectSpread2(_objectSpread2({}, action), {}, {
@@ -1411,6 +1321,7 @@ function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAll
1411
1321
  });
1412
1322
  } else {
1413
1323
  // LText
1324
+
1414
1325
  var updatedValue = Object.keys(diffedValue).reduce(function (acc, lang) {
1415
1326
  var patchedValue = getDeltaValue(diffedValue[lang], acc[lang]);
1416
1327
  return Object.assign(acc, _defineProperty({}, lang, patchedValue));
@@ -1419,18 +1330,16 @@ function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAll
1419
1330
  }
1420
1331
  return action;
1421
1332
  }
1422
-
1423
1333
  function _buildVariantImagesAction(diffedImages) {
1424
1334
  var oldVariant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1425
1335
  var newVariant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1426
- var actions = []; // generate a hashMap to be able to reference the right image from both ends
1427
-
1336
+ var actions = [];
1337
+ // generate a hashMap to be able to reference the right image from both ends
1428
1338
  var matchingImagePairs = findMatchingPairs(diffedImages, oldVariant.images, newVariant.images, 'url');
1429
1339
  forEach(diffedImages, function (image, key) {
1430
1340
  var _extractMatchingPairs = extractMatchingPairs(matchingImagePairs, key, oldVariant.images, newVariant.images),
1431
- oldObj = _extractMatchingPairs.oldObj,
1432
- newObj = _extractMatchingPairs.newObj;
1433
-
1341
+ oldObj = _extractMatchingPairs.oldObj,
1342
+ newObj = _extractMatchingPairs.newObj;
1434
1343
  if (REGEX_NUMBER$2.test(key)) {
1435
1344
  // New image
1436
1345
  if (Array.isArray(image) && image.length) actions.push({
@@ -1456,13 +1365,15 @@ function _buildVariantImagesAction(diffedImages) {
1456
1365
  label: getDeltaValue(image.label)
1457
1366
  });
1458
1367
  } else if (REGEX_UNDERSCORE_NUMBER$2.test(key)) if (Array.isArray(image) && image.length === 3) {
1459
- if (Number(image[2]) === 3) // image position changed
1368
+ if (Number(image[2]) === 3)
1369
+ // image position changed
1460
1370
  actions.push({
1461
1371
  action: 'moveImageToPosition',
1462
1372
  variantId: oldVariant.id,
1463
1373
  imageUrl: oldObj.url,
1464
1374
  position: Number(image[1])
1465
- });else if (Number(image[2]) === 0) // image removed
1375
+ });else if (Number(image[2]) === 0)
1376
+ // image removed
1466
1377
  actions.push({
1467
1378
  action: 'removeImage',
1468
1379
  variantId: oldVariant.id,
@@ -1472,26 +1383,24 @@ function _buildVariantImagesAction(diffedImages) {
1472
1383
  });
1473
1384
  return actions;
1474
1385
  }
1475
-
1476
1386
  function _buildVariantPricesAction(diffedPrices) {
1477
1387
  var oldVariant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1478
1388
  var newVariant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1479
1389
  var enableDiscounted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1480
1390
  var addPriceActions = [];
1481
1391
  var changePriceActions = [];
1482
- var removePriceActions = []; // generate a hashMap to be able to reference the right image from both ends
1392
+ var removePriceActions = [];
1483
1393
 
1394
+ // generate a hashMap to be able to reference the right image from both ends
1484
1395
  var matchingPricePairs = findMatchingPairs(diffedPrices, oldVariant.prices, newVariant.prices);
1485
1396
  forEach(diffedPrices, function (price, key) {
1486
1397
  var _extractMatchingPairs2 = extractMatchingPairs(matchingPricePairs, key, oldVariant.prices, newVariant.prices),
1487
- oldObj = _extractMatchingPairs2.oldObj,
1488
- newObj = _extractMatchingPairs2.newObj;
1489
-
1398
+ oldObj = _extractMatchingPairs2.oldObj,
1399
+ newObj = _extractMatchingPairs2.newObj;
1490
1400
  if (getIsAddAction(key, price)) {
1491
1401
  // Remove read-only fields
1492
1402
  var patchedPrice = price.map(function (p) {
1493
1403
  var shallowClone = _objectSpread2({}, p);
1494
-
1495
1404
  if (enableDiscounted !== true) delete shallowClone.discounted;
1496
1405
  return shallowClone;
1497
1406
  });
@@ -1502,18 +1411,14 @@ function _buildVariantPricesAction(diffedPrices) {
1502
1411
  });
1503
1412
  return;
1504
1413
  }
1505
-
1506
1414
  if (getIsUpdateAction(key, price)) {
1507
1415
  // Remove the discounted field and make sure that the price
1508
1416
  // still has other values, otherwise simply return
1509
1417
  var filteredPrice = _objectSpread2({}, price);
1510
-
1511
1418
  if (enableDiscounted !== true) delete filteredPrice.discounted;
1512
-
1513
1419
  if (Object.keys(filteredPrice).length) {
1514
1420
  // At this point price should have changed, simply pick the new one
1515
1421
  var newPrice = _objectSpread2({}, newObj);
1516
-
1517
1422
  if (enableDiscounted !== true) delete newPrice.discounted;
1518
1423
  changePriceActions.push({
1519
1424
  action: 'changePrice',
@@ -1521,10 +1426,8 @@ function _buildVariantPricesAction(diffedPrices) {
1521
1426
  price: newPrice
1522
1427
  });
1523
1428
  }
1524
-
1525
1429
  return;
1526
1430
  }
1527
-
1528
1431
  if (getIsRemoveAction(key, price)) {
1529
1432
  // price removed
1530
1433
  removePriceActions.push({
@@ -1535,7 +1438,6 @@ function _buildVariantPricesAction(diffedPrices) {
1535
1438
  });
1536
1439
  return [addPriceActions, changePriceActions, removePriceActions];
1537
1440
  }
1538
-
1539
1441
  function _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames) {
1540
1442
  var actions = [];
1541
1443
  if (!attributes) return actions;
@@ -1544,43 +1446,34 @@ function _buildVariantAttributesActions(attributes, oldVariant, newVariant, same
1544
1446
  if (Array.isArray(value)) {
1545
1447
  var id = oldVariant.id;
1546
1448
  var deltaValue = getDeltaValue(value);
1547
-
1548
1449
  var setAction = _buildNewSetAttributeAction(id, deltaValue, sameForAllAttributeNames);
1549
-
1550
1450
  if (setAction) actions.push(setAction);
1551
1451
  } else if (newVariant.attributes) {
1552
1452
  var _setAction = _buildSetAttributeAction(value.value, oldVariant, newVariant.attributes[key], sameForAllAttributeNames);
1553
-
1554
1453
  if (_setAction) actions.push(_setAction);
1555
1454
  }
1556
1455
  } else if (REGEX_UNDERSCORE_NUMBER$2.test(key)) if (Array.isArray(value)) {
1557
1456
  // Ignore pure array moves!
1558
1457
  if (value.length === 3 && value[2] === 3) return;
1559
1458
  var _id = oldVariant.id;
1560
-
1561
1459
  var _deltaValue = getDeltaValue(value);
1562
-
1563
- if (!_deltaValue) if (value[0] && value[0].name) // unset attribute if
1460
+ if (!_deltaValue) if (value[0] && value[0].name)
1461
+ // unset attribute if
1564
1462
  _deltaValue = {
1565
1463
  name: value[0].name
1566
1464
  };else _deltaValue = undefined;
1567
-
1568
1465
  var _setAction2 = _buildNewSetAttributeAction(_id, _deltaValue, sameForAllAttributeNames);
1569
-
1570
1466
  if (_setAction2) actions.push(_setAction2);
1571
1467
  } else {
1572
1468
  var index = key.substring(1);
1573
-
1574
1469
  if (newVariant.attributes) {
1575
1470
  var _setAction3 = _buildSetAttributeAction(value.value, oldVariant, newVariant.attributes[index], sameForAllAttributeNames);
1576
-
1577
1471
  if (_setAction3) actions.push(_setAction3);
1578
1472
  }
1579
1473
  }
1580
1474
  });
1581
1475
  return actions;
1582
1476
  }
1583
-
1584
1477
  function toAssetIdentifier(asset) {
1585
1478
  var assetIdentifier = asset.id ? {
1586
1479
  assetId: asset.id
@@ -1589,26 +1482,22 @@ function toAssetIdentifier(asset) {
1589
1482
  };
1590
1483
  return assetIdentifier;
1591
1484
  }
1592
-
1593
1485
  function toVariantIdentifier(variant) {
1594
1486
  var id = variant.id,
1595
- sku = variant.sku;
1487
+ sku = variant.sku;
1596
1488
  return id ? {
1597
1489
  variantId: id
1598
1490
  } : {
1599
1491
  sku: sku
1600
1492
  };
1601
1493
  }
1602
-
1603
1494
  function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant) {
1604
1495
  var isAssetOrderChanged = Object.entries(diffAssets).find(function (entry) {
1605
1496
  return getIsItemMovedAction(entry[0], entry[1]);
1606
1497
  });
1607
-
1608
1498
  if (!isAssetOrderChanged) {
1609
1499
  return [];
1610
1500
  }
1611
-
1612
1501
  var assetIdsBefore = oldVariant.assets.map(function (_) {
1613
1502
  return _.id;
1614
1503
  });
@@ -1619,24 +1508,21 @@ function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant)
1619
1508
  });
1620
1509
  var assetIdsToKeep = intersection(assetIdsCurrent, assetIdsBefore);
1621
1510
  var assetIdsToRemove = without.apply(void 0, [assetIdsBefore].concat(_toConsumableArray(assetIdsToKeep)));
1622
-
1623
1511
  var changeAssetOrderAction = _objectSpread2({
1624
1512
  action: 'changeAssetOrder',
1625
1513
  assetOrder: assetIdsToKeep.concat(assetIdsToRemove)
1626
1514
  }, toVariantIdentifier(oldVariant));
1627
-
1628
1515
  return [changeAssetOrderAction];
1629
1516
  }
1630
-
1631
1517
  function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1632
- var assetActions = []; // generate a hashMap to be able to reference the right asset from both ends
1518
+ var assetActions = [];
1633
1519
 
1520
+ // generate a hashMap to be able to reference the right asset from both ends
1634
1521
  var matchingAssetPairs = findMatchingPairs(diffAssets, oldVariant.assets, newVariant.assets);
1635
1522
  forEach(diffAssets, function (asset, key) {
1636
1523
  var _extractMatchingPairs3 = extractMatchingPairs(matchingAssetPairs, key, oldVariant.assets, newVariant.assets),
1637
- oldAsset = _extractMatchingPairs3.oldObj,
1638
- newAsset = _extractMatchingPairs3.newObj;
1639
-
1524
+ oldAsset = _extractMatchingPairs3.oldObj,
1525
+ newAsset = _extractMatchingPairs3.newObj;
1640
1526
  if (getIsAddAction(key, asset)) {
1641
1527
  assetActions.push(_objectSpread2(_objectSpread2({
1642
1528
  action: 'addAsset',
@@ -1646,7 +1532,6 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1646
1532
  }));
1647
1533
  return;
1648
1534
  }
1649
-
1650
1535
  if (getIsUpdateAction(key, asset)) {
1651
1536
  // todo add changeAssetOrder
1652
1537
  var basicActions = buildBaseAttributesActions({
@@ -1661,11 +1546,9 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1661
1546
  assetId: oldAsset.id
1662
1547
  });
1663
1548
  }
1664
-
1665
1549
  return _objectSpread2(_objectSpread2(_objectSpread2({}, action), toVariantIdentifier(oldVariant)), toAssetIdentifier(oldAsset));
1666
1550
  });
1667
1551
  assetActions.push.apply(assetActions, _toConsumableArray(basicActions));
1668
-
1669
1552
  if (asset.custom) {
1670
1553
  var customActions = actionsMapCustom(asset, newAsset, oldAsset, _objectSpread2(_objectSpread2({
1671
1554
  actions: {
@@ -1675,26 +1558,22 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
1675
1558
  }, toVariantIdentifier(oldVariant)), toAssetIdentifier(oldAsset)));
1676
1559
  assetActions.push.apply(assetActions, _toConsumableArray(customActions));
1677
1560
  }
1678
-
1679
1561
  return;
1680
1562
  }
1681
-
1682
1563
  if (getIsRemoveAction(key, asset)) {
1683
1564
  assetActions.push(_objectSpread2(_objectSpread2({
1684
1565
  action: 'removeAsset'
1685
1566
  }, toAssetIdentifier(oldAsset)), toVariantIdentifier(oldVariant)));
1686
1567
  }
1687
1568
  });
1688
-
1689
1569
  var changedAssetOrderAction = _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant);
1690
-
1691
1570
  return [].concat(_toConsumableArray(changedAssetOrderAction), assetActions);
1692
1571
  }
1572
+
1693
1573
  /**
1694
1574
  * SYNC FUNCTIONS
1695
1575
  */
1696
1576
 
1697
-
1698
1577
  function actionsMapBase$h(diff, oldObj, newObj) {
1699
1578
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1700
1579
  return buildBaseAttributesActions({
@@ -1749,7 +1628,6 @@ function actionsMapCategories(diff) {
1749
1628
  var action = {
1750
1629
  category: category[0]
1751
1630
  };
1752
-
1753
1631
  if (category.length === 3) {
1754
1632
  // Ignore pure array moves!
1755
1633
  if (category[2] !== 3) {
@@ -1761,13 +1639,14 @@ function actionsMapCategories(diff) {
1761
1639
  addToCategoryActions.push(action);
1762
1640
  }
1763
1641
  }
1764
- }); // Make sure `removeFromCategory` actions come first
1642
+ });
1765
1643
 
1644
+ // Make sure `removeFromCategory` actions come first
1766
1645
  return removeFromCategoryActions.concat(addToCategoryActions);
1767
1646
  }
1768
1647
  function actionsMapCategoryOrderHints(diff) {
1769
- if (!diff.categoryOrderHints) return []; // Ignore this pattern as its means no changes happened [{},0,0]
1770
-
1648
+ if (!diff.categoryOrderHints) return [];
1649
+ // Ignore this pattern as its means no changes happened [{},0,0]
1771
1650
  if (Array.isArray(diff.categoryOrderHints)) return [];
1772
1651
  return Object.keys(diff.categoryOrderHints).map(function (categoryId) {
1773
1652
  var hintChange = diff.categoryOrderHints[categoryId];
@@ -1775,9 +1654,13 @@ function actionsMapCategoryOrderHints(diff) {
1775
1654
  action: 'setCategoryOrderHint',
1776
1655
  categoryId: categoryId
1777
1656
  };
1778
- if (hintChange.length === 1) // item was added
1779
- action.orderHint = hintChange[0];else if (hintChange.length === 2 && hintChange[1] !== 0) // item was changed
1780
- action.orderHint = hintChange[1]; // else item was removed -> do not set 'orderHint' property
1657
+ if (hintChange.length === 1)
1658
+ // item was added
1659
+ action.orderHint = hintChange[0];else if (hintChange.length === 2 && hintChange[1] !== 0)
1660
+ // item was changed
1661
+ action.orderHint = hintChange[1];
1662
+
1663
+ // else item was removed -> do not set 'orderHint' property
1781
1664
 
1782
1665
  return action;
1783
1666
  });
@@ -1787,12 +1670,10 @@ function actionsMapAssets(diff, oldObj, newObj, variantHashMap) {
1787
1670
  var variants = diff.variants;
1788
1671
  if (variants) forEach(variants, function (variant, key) {
1789
1672
  var _extractMatchingPairs4 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1790
- oldVariant = _extractMatchingPairs4.oldObj,
1791
- newVariant = _extractMatchingPairs4.newObj;
1792
-
1673
+ oldVariant = _extractMatchingPairs4.oldObj,
1674
+ newVariant = _extractMatchingPairs4.newObj;
1793
1675
  if (variant.assets && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
1794
1676
  var assetActions = _buildVariantAssetsActions(variant.assets, oldVariant, newVariant);
1795
-
1796
1677
  allAssetsActions = allAssetsActions.concat(assetActions);
1797
1678
  }
1798
1679
  });
@@ -1805,25 +1686,21 @@ function actionsMapAttributes$1(diff, oldObj, newObj) {
1805
1686
  var variants = diff.variants;
1806
1687
  if (variants) forEach(variants, function (variant, key) {
1807
1688
  var _extractMatchingPairs5 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1808
- oldVariant = _extractMatchingPairs5.oldObj,
1809
- newVariant = _extractMatchingPairs5.newObj;
1810
-
1689
+ oldVariant = _extractMatchingPairs5.oldObj,
1690
+ newVariant = _extractMatchingPairs5.newObj;
1811
1691
  if (REGEX_NUMBER$2.test(key) && !Array.isArray(variant)) {
1812
1692
  var skuAction = _buildSkuActions(variant, oldVariant);
1813
-
1814
1693
  var keyAction = _buildKeyActions(variant, oldVariant);
1815
-
1816
1694
  if (skuAction) actions.push(skuAction);
1817
1695
  if (keyAction) actions.push(keyAction);
1818
1696
  var attributes = variant.attributes;
1819
-
1820
1697
  var attrActions = _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames);
1821
-
1822
1698
  actions = actions.concat(attrActions);
1823
1699
  }
1824
- }); // Ensure that an action is unique.
1825
- // This is especially necessary for SFA attributes.
1700
+ });
1826
1701
 
1702
+ // Ensure that an action is unique.
1703
+ // This is especially necessary for SFA attributes.
1827
1704
  return uniqWith(actions, function (a, b) {
1828
1705
  return a.action === b.action && a.name === b.name && a.variantId === b.variantId;
1829
1706
  });
@@ -1833,12 +1710,10 @@ function actionsMapImages(diff, oldObj, newObj, variantHashMap) {
1833
1710
  var variants = diff.variants;
1834
1711
  if (variants) forEach(variants, function (variant, key) {
1835
1712
  var _extractMatchingPairs6 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1836
- oldVariant = _extractMatchingPairs6.oldObj,
1837
- newVariant = _extractMatchingPairs6.newObj;
1838
-
1713
+ oldVariant = _extractMatchingPairs6.oldObj,
1714
+ newVariant = _extractMatchingPairs6.newObj;
1839
1715
  if (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key)) {
1840
1716
  var vActions = _buildVariantImagesAction(variant.images, oldVariant, newVariant);
1841
-
1842
1717
  actions = actions.concat(vActions);
1843
1718
  }
1844
1719
  });
@@ -1851,22 +1726,21 @@ function actionsMapPrices(diff, oldObj, newObj, variantHashMap, enableDiscounted
1851
1726
  var variants = diff.variants;
1852
1727
  if (variants) forEach(variants, function (variant, key) {
1853
1728
  var _extractMatchingPairs7 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1854
- oldVariant = _extractMatchingPairs7.oldObj,
1855
- newVariant = _extractMatchingPairs7.newObj;
1856
-
1729
+ oldVariant = _extractMatchingPairs7.oldObj,
1730
+ newVariant = _extractMatchingPairs7.newObj;
1857
1731
  if (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key)) {
1858
1732
  var _buildVariantPricesAc = _buildVariantPricesAction(variant.prices, oldVariant, newVariant, enableDiscounted),
1859
- _buildVariantPricesAc2 = _slicedToArray(_buildVariantPricesAc, 3),
1860
- addPriceAction = _buildVariantPricesAc2[0],
1861
- changePriceAction = _buildVariantPricesAc2[1],
1862
- removePriceAction = _buildVariantPricesAc2[2];
1863
-
1733
+ _buildVariantPricesAc2 = _slicedToArray(_buildVariantPricesAc, 3),
1734
+ addPriceAction = _buildVariantPricesAc2[0],
1735
+ changePriceAction = _buildVariantPricesAc2[1],
1736
+ removePriceAction = _buildVariantPricesAc2[2];
1864
1737
  addPriceActions = addPriceActions.concat(addPriceAction);
1865
1738
  changePriceActions = changePriceActions.concat(changePriceAction);
1866
1739
  removePriceActions = removePriceActions.concat(removePriceAction);
1867
1740
  }
1868
- }); // price actions need to be in this below order
1741
+ });
1869
1742
 
1743
+ // price actions need to be in this below order
1870
1744
  return changePriceActions.concat(removePriceActions).concat(addPriceActions);
1871
1745
  }
1872
1746
  function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
@@ -1874,16 +1748,14 @@ function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
1874
1748
  var variants = diff.variants;
1875
1749
  if (variants) forEach(variants, function (variant, key) {
1876
1750
  var _extractMatchingPairs8 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
1877
- oldVariant = _extractMatchingPairs8.oldObj,
1878
- newVariant = _extractMatchingPairs8.newObj;
1879
-
1751
+ oldVariant = _extractMatchingPairs8.oldObj,
1752
+ newVariant = _extractMatchingPairs8.newObj;
1880
1753
  if (variant && variant.prices && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
1881
1754
  var priceHashMap = findMatchingPairs(variant.prices, oldVariant.prices, newVariant.prices);
1882
1755
  forEach(variant.prices, function (price, index) {
1883
1756
  var _extractMatchingPairs9 = extractMatchingPairs(priceHashMap, index, oldVariant.prices, newVariant.prices),
1884
- oldPrice = _extractMatchingPairs9.oldObj,
1885
- newPrice = _extractMatchingPairs9.newObj;
1886
-
1757
+ oldPrice = _extractMatchingPairs9.oldObj,
1758
+ newPrice = _extractMatchingPairs9.newObj;
1887
1759
  if (price.custom && (REGEX_UNDERSCORE_NUMBER$2.test(index) || REGEX_NUMBER$2.test(index))) {
1888
1760
  var generatedActions = actionsMapCustom(price, newPrice, oldPrice, {
1889
1761
  actions: {
@@ -1906,15 +1778,14 @@ function actionsMapMasterVariant(oldObj, newObj) {
1906
1778
  variantId: variantId
1907
1779
  };
1908
1780
  };
1909
-
1910
1781
  var extractMasterVariantId = function extractMasterVariantId(fromObj) {
1911
1782
  var variants = Array.isArray(fromObj.variants) ? fromObj.variants : [];
1912
1783
  return variants[0] ? variants[0].id : undefined;
1913
1784
  };
1914
-
1915
1785
  var newMasterVariantId = extractMasterVariantId(newObj);
1916
- var oldMasterVariantId = extractMasterVariantId(oldObj); // Old and new master master variant differ and a new master variant id exists
1786
+ var oldMasterVariantId = extractMasterVariantId(oldObj);
1917
1787
 
1788
+ // Old and new master master variant differ and a new master variant id exists
1918
1789
  if (newMasterVariantId && oldMasterVariantId !== newMasterVariantId) return [createChangeMasterVariantAction(newMasterVariantId)];
1919
1790
  return [];
1920
1791
  }
@@ -1924,9 +1795,9 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
1924
1795
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1925
1796
  var allActions = [];
1926
1797
  var sameForAllAttributeNames = options.sameForAllAttributeNames,
1927
- enableDiscounted = options.enableDiscounted;
1798
+ enableDiscounted = options.enableDiscounted;
1928
1799
  var publish = newObj.publish,
1929
- staged = newObj.staged;
1800
+ staged = newObj.staged;
1930
1801
  var variantHashMap = findMatchingPairs(diff.variants, oldObj.variants, newObj.variants);
1931
1802
  allActions.push(mapActionGroup('attributes', function () {
1932
1803
  return actionsMapAttributes$1(diff, oldObj, newObj, sameForAllAttributeNames || [], variantHashMap);
@@ -1973,27 +1844,22 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
1973
1844
  return flatten(allActions);
1974
1845
  };
1975
1846
  }
1976
-
1977
1847
  function moveMasterVariantsIntoVariants(before, now) {
1978
1848
  var _copyEmptyArrayProps = copyEmptyArrayProps(before, now),
1979
- _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
1980
- beforeCopy = _copyEmptyArrayProps2[0],
1981
- nowCopy = _copyEmptyArrayProps2[1];
1982
-
1849
+ _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
1850
+ beforeCopy = _copyEmptyArrayProps2[0],
1851
+ nowCopy = _copyEmptyArrayProps2[1];
1983
1852
  var move = function move(obj) {
1984
1853
  return _objectSpread2(_objectSpread2({}, obj), {}, {
1985
1854
  masterVariant: undefined,
1986
1855
  variants: [obj.masterVariant].concat(_toConsumableArray(obj.variants || []))
1987
1856
  });
1988
1857
  };
1989
-
1990
1858
  var hasMasterVariant = function hasMasterVariant(obj) {
1991
1859
  return obj && obj.masterVariant;
1992
1860
  };
1993
-
1994
1861
  return [hasMasterVariant(beforeCopy) ? move(beforeCopy) : beforeCopy, hasMasterVariant(nowCopy) ? move(nowCopy) : nowCopy];
1995
1862
  }
1996
-
1997
1863
  var products = (function (actionGroupList, syncActionConfig) {
1998
1864
  var mapActionGroup = createMapActionGroup(actionGroupList);
1999
1865
  var doMapActions = createProductMapActions(mapActionGroup, syncActionConfig);
@@ -2005,15 +1871,12 @@ var products = (function (actionGroupList, syncActionConfig) {
2005
1871
 
2006
1872
  var REGEX_NUMBER$1 = new RegExp(/^\d+$/);
2007
1873
  var REGEX_UNDERSCORE_NUMBER$1 = new RegExp(/^_\d+$/);
2008
-
2009
1874
  var isAddAction = function isAddAction(key, resource) {
2010
1875
  return REGEX_NUMBER$1.test(key) && Array.isArray(resource) && resource.length;
2011
1876
  };
2012
-
2013
1877
  var isRemoveAction = function isRemoveAction(key, resource) {
2014
1878
  return REGEX_UNDERSCORE_NUMBER$1.test(key) && Number(resource[2]) === 0;
2015
1879
  };
2016
-
2017
1880
  var baseActionsList$g = [{
2018
1881
  action: 'changeOrderState',
2019
1882
  key: 'orderState'
@@ -2024,6 +1887,7 @@ var baseActionsList$g = [{
2024
1887
  action: 'changeShipmentState',
2025
1888
  key: 'shipmentState'
2026
1889
  }];
1890
+
2027
1891
  /**
2028
1892
  * SYNC FUNCTIONS
2029
1893
  */
@@ -2050,18 +1914,17 @@ function actionsMapDeliveries(diff, oldObj, newObj) {
2050
1914
  }));
2051
1915
  return handler(deliveriesDiff, oldObj.shippingInfo, newObj.shippingInfo);
2052
1916
  }
2053
-
2054
1917
  function _buildDeliveryParcelsAction(diffedParcels) {
2055
1918
  var oldDelivery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2056
1919
  var newDelivery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2057
1920
  var addParcelActions = [];
2058
- var removeParcelActions = []; // generate a hashMap to be able to reference the right image from both ends
1921
+ var removeParcelActions = [];
2059
1922
 
1923
+ // generate a hashMap to be able to reference the right image from both ends
2060
1924
  var matchingParcelPairs = findMatchingPairs(diffedParcels, oldDelivery.parcels, newDelivery.parcels);
2061
1925
  forEach(diffedParcels, function (parcel, key) {
2062
1926
  var _extractMatchingPairs = extractMatchingPairs(matchingParcelPairs, key, oldDelivery.parcels, newDelivery.parcels),
2063
- oldObj = _extractMatchingPairs.oldObj;
2064
-
1927
+ oldObj = _extractMatchingPairs.oldObj;
2065
1928
  if (isAddAction(key, parcel)) {
2066
1929
  addParcelActions.push(_objectSpread2({
2067
1930
  action: 'addParcelToDelivery',
@@ -2069,7 +1932,6 @@ function _buildDeliveryParcelsAction(diffedParcels) {
2069
1932
  }, getDeltaValue(parcel)));
2070
1933
  return;
2071
1934
  }
2072
-
2073
1935
  if (isRemoveAction(key, parcel)) {
2074
1936
  removeParcelActions.push({
2075
1937
  action: 'removeParcelFromDelivery',
@@ -2079,13 +1941,12 @@ function _buildDeliveryParcelsAction(diffedParcels) {
2079
1941
  });
2080
1942
  return [addParcelActions, removeParcelActions];
2081
1943
  }
2082
-
2083
1944
  function _buildDeliveryItemsAction(diffedItems) {
2084
1945
  var newDelivery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2085
- var setDeliveryItemsAction = []; // If there is a diff it means that there were changes (update, adds or removes)
1946
+ var setDeliveryItemsAction = [];
1947
+ // If there is a diff it means that there were changes (update, adds or removes)
2086
1948
  // over the items, which means that `setDeliveryItems` change has happened over
2087
1949
  // the delivery
2088
-
2089
1950
  if (diffedItems && Object.keys(diffedItems).length > 0) {
2090
1951
  setDeliveryItemsAction.push({
2091
1952
  action: 'setDeliveryItems',
@@ -2094,10 +1955,8 @@ function _buildDeliveryItemsAction(diffedItems) {
2094
1955
  items: newDelivery.items
2095
1956
  });
2096
1957
  }
2097
-
2098
1958
  return [setDeliveryItemsAction];
2099
1959
  }
2100
-
2101
1960
  function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
2102
1961
  var shippingInfo = diff.shippingInfo;
2103
1962
  if (!shippingInfo) return [];
@@ -2107,15 +1966,13 @@ function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
2107
1966
  var removeParcelActions = [];
2108
1967
  if (deliveries) forEach(deliveries, function (delivery, key) {
2109
1968
  var _extractMatchingPairs2 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
2110
- oldDelivery = _extractMatchingPairs2.oldObj,
2111
- newDelivery = _extractMatchingPairs2.newObj;
2112
-
1969
+ oldDelivery = _extractMatchingPairs2.oldObj,
1970
+ newDelivery = _extractMatchingPairs2.newObj;
2113
1971
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
2114
1972
  var _buildDeliveryParcels = _buildDeliveryParcelsAction(delivery.parcels, oldDelivery, newDelivery),
2115
- _buildDeliveryParcels2 = _slicedToArray(_buildDeliveryParcels, 2),
2116
- addParcelAction = _buildDeliveryParcels2[0],
2117
- removeParcelAction = _buildDeliveryParcels2[1];
2118
-
1973
+ _buildDeliveryParcels2 = _slicedToArray(_buildDeliveryParcels, 2),
1974
+ addParcelAction = _buildDeliveryParcels2[0],
1975
+ removeParcelAction = _buildDeliveryParcels2[1];
2119
1976
  addParcelActions = addParcelActions.concat(addParcelAction);
2120
1977
  removeParcelActions = removeParcelActions.concat(removeParcelAction);
2121
1978
  }
@@ -2130,42 +1987,34 @@ function actionsMapDeliveryItems(diff, oldObj, newObj, deliveryHashMap) {
2130
1987
  var setDeliveryItemsActions = [];
2131
1988
  forEach(deliveries, function (delivery, key) {
2132
1989
  var _extractMatchingPairs3 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
2133
- newDelivery = _extractMatchingPairs3.newObj;
2134
-
1990
+ newDelivery = _extractMatchingPairs3.newObj;
2135
1991
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
2136
1992
  var _buildDeliveryItemsAc = _buildDeliveryItemsAction(delivery.items, newDelivery),
2137
- _buildDeliveryItemsAc2 = _slicedToArray(_buildDeliveryItemsAc, 1),
2138
- setDeliveryItemsAction = _buildDeliveryItemsAc2[0];
2139
-
1993
+ _buildDeliveryItemsAc2 = _slicedToArray(_buildDeliveryItemsAc, 1),
1994
+ setDeliveryItemsAction = _buildDeliveryItemsAc2[0];
2140
1995
  setDeliveryItemsActions = setDeliveryItemsActions.concat(setDeliveryItemsAction);
2141
1996
  }
2142
1997
  });
2143
1998
  return setDeliveryItemsActions;
2144
1999
  }
2145
2000
  function actionsMapReturnsInfo(diff, oldObj, newObj) {
2146
- var _createBuildArrayActi2;
2147
-
2148
2001
  var returnInfoDiff = diff.returnInfo;
2149
2002
  if (!returnInfoDiff) return [];
2150
- var handler = createBuildArrayActions('returnInfo', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newReturnInfo) {
2003
+ var handler = createBuildArrayActions('returnInfo', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newReturnInfo) {
2151
2004
  if (newReturnInfo.items) {
2152
2005
  return [_objectSpread2({
2153
2006
  action: 'addReturnInfo'
2154
2007
  }, newReturnInfo)];
2155
2008
  }
2156
-
2157
2009
  return [];
2158
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldSReturnInfo, newReturnInfo, key) {
2010
+ }), CHANGE_ACTIONS, function (oldSReturnInfo, newReturnInfo, key) {
2159
2011
  var _returnInfoDiff$key$i = returnInfoDiff[key].items,
2160
- items = _returnInfoDiff$key$i === void 0 ? {} : _returnInfoDiff$key$i;
2161
-
2012
+ items = _returnInfoDiff$key$i === void 0 ? {} : _returnInfoDiff$key$i;
2162
2013
  if (Object.keys(items).length === 0) {
2163
2014
  return [];
2164
2015
  }
2165
-
2166
2016
  return Object.keys(items).reduce(function (actions, index) {
2167
2017
  var item = newReturnInfo.items[index];
2168
-
2169
2018
  if (items[index].shipmentState) {
2170
2019
  actions.push({
2171
2020
  action: 'setReturnShipmentState',
@@ -2173,7 +2022,6 @@ function actionsMapReturnsInfo(diff, oldObj, newObj) {
2173
2022
  shipmentState: item.shipmentState
2174
2023
  });
2175
2024
  }
2176
-
2177
2025
  if (items[index].paymentState) {
2178
2026
  actions.push({
2179
2027
  action: 'setReturnPaymentState',
@@ -2181,10 +2029,9 @@ function actionsMapReturnsInfo(diff, oldObj, newObj) {
2181
2029
  paymentState: item.paymentState
2182
2030
  });
2183
2031
  }
2184
-
2185
2032
  return actions;
2186
2033
  }, []);
2187
- }), _createBuildArrayActi2));
2034
+ }));
2188
2035
  return handler(diff, oldObj, newObj);
2189
2036
  }
2190
2037
 
@@ -2192,11 +2039,9 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
2192
2039
  return function doMapActions(diff, newObj, oldObj) {
2193
2040
  var allActions = [];
2194
2041
  var deliveryHashMap;
2195
-
2196
2042
  if (diff.shippingInfo && diff.shippingInfo.deliveries) {
2197
2043
  deliveryHashMap = findMatchingPairs(diff.shippingInfo.deliveries, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries);
2198
2044
  }
2199
-
2200
2045
  allActions.push(mapActionGroup('base', function () {
2201
2046
  return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
2202
2047
  }));
@@ -2218,14 +2063,15 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
2218
2063
  return flatten(allActions);
2219
2064
  };
2220
2065
  }
2221
-
2222
2066
  var orders = (function (actionGroupList, syncActionConfig) {
2223
2067
  // actionGroupList contains information about which action groups
2224
2068
  // are allowed or ignored
2069
+
2225
2070
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2226
2071
  // - action group name
2227
2072
  // - callback function that should return a list of actions that correspond
2228
2073
  // to the for the action group
2074
+
2229
2075
  // this resulting function mapActionGroup will call the callback function
2230
2076
  // for allowed action groups and return the return value of the callback
2231
2077
  // It will return an empty array for ignored action groups
@@ -2277,21 +2123,17 @@ function actionsMapBase$f(diff, oldObj, newObj) {
2277
2123
  }
2278
2124
 
2279
2125
  var validityActions = ['setValidFrom', 'setValidUntil'];
2280
-
2281
2126
  var isValidityActions = function isValidityActions(actionName) {
2282
2127
  return validityActions.includes(actionName);
2283
2128
  };
2284
-
2285
2129
  function combineValidityActions() {
2286
2130
  var actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2287
-
2288
2131
  var _actions$filter = actions.filter(function (item) {
2289
- return isValidityActions(item.action);
2290
- }),
2291
- _actions$filter2 = _slicedToArray(_actions$filter, 2),
2292
- setValidFromAction = _actions$filter2[0],
2293
- setValidUntilAction = _actions$filter2[1];
2294
-
2132
+ return isValidityActions(item.action);
2133
+ }),
2134
+ _actions$filter2 = _slicedToArray(_actions$filter, 2),
2135
+ setValidFromAction = _actions$filter2[0],
2136
+ setValidUntilAction = _actions$filter2[1];
2295
2137
  if (setValidFromAction && setValidUntilAction) {
2296
2138
  return [].concat(_toConsumableArray(actions.filter(function (item) {
2297
2139
  return !isValidityActions(item.action);
@@ -2301,7 +2143,6 @@ function combineValidityActions() {
2301
2143
  validUntil: setValidUntilAction.validUntil
2302
2144
  }]);
2303
2145
  }
2304
-
2305
2146
  return actions;
2306
2147
  }
2307
2148
 
@@ -2314,7 +2155,6 @@ function createProductDiscountsMapActions(mapActionGroup, syncActionConfig) {
2314
2155
  return combineValidityActions(flatten(allActions));
2315
2156
  };
2316
2157
  }
2317
-
2318
2158
  var productDiscounts = (function (actionGroupList) {
2319
2159
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2320
2160
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2382,15 +2222,16 @@ function createDiscountCodesMapActions(mapActionGroup, syncActionConfig) {
2382
2222
  return combineValidityActions(flatten(allActions));
2383
2223
  };
2384
2224
  }
2385
-
2386
2225
  var discountCodes = (function (actionGroupList) {
2387
2226
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2388
2227
  // actionGroupList contains information about which action groups
2389
2228
  // are allowed or ignored
2229
+
2390
2230
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2391
2231
  // - action group name
2392
2232
  // - callback function that should return a list of actions that correspond
2393
2233
  // to the for the action group
2234
+
2394
2235
  // this resulting function mapActionGroup will call the callback function
2395
2236
  // for allowed action groups and return the return value of the callback
2396
2237
  // It will return an empty array for ignored action groups
@@ -2432,7 +2273,6 @@ function createCustomerGroupMapActions(mapActionGroup, syncActionConfig) {
2432
2273
  return flatten(allActions);
2433
2274
  };
2434
2275
  }
2435
-
2436
2276
  var customerGroup = (function (actionGroupList) {
2437
2277
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2438
2278
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2503,7 +2343,6 @@ function createCartDiscountsMapActions(mapActionGroup, syncActionConfig) {
2503
2343
  return combineValidityActions(flatten(allActions));
2504
2344
  };
2505
2345
  }
2506
-
2507
2346
  var cartDiscounts = (function (actionGroupList) {
2508
2347
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2509
2348
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -2535,25 +2374,23 @@ function actionsMapBase$b(diff, oldObj, newObj) {
2535
2374
  });
2536
2375
  }
2537
2376
  function actionsMapRates(diff, oldObj, newObj) {
2538
- var _createBuildArrayActi;
2539
-
2540
- var handler = createBuildArrayActions('rates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newObject) {
2377
+ var handler = createBuildArrayActions('rates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
2541
2378
  return {
2542
2379
  action: 'addTaxRate',
2543
2380
  taxRate: newObject
2544
2381
  };
2545
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (objectToRemove) {
2382
+ }), REMOVE_ACTIONS, function (objectToRemove) {
2546
2383
  return {
2547
2384
  action: 'removeTaxRate',
2548
2385
  taxRateId: objectToRemove.id
2549
2386
  };
2550
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldObject, updatedObject) {
2387
+ }), CHANGE_ACTIONS, function (oldObject, updatedObject) {
2551
2388
  return {
2552
2389
  action: 'replaceTaxRate',
2553
2390
  taxRateId: oldObject.id === updatedObject.id ? oldObject.id : updatedObject.id,
2554
2391
  taxRate: updatedObject
2555
2392
  };
2556
- }), _createBuildArrayActi));
2393
+ }));
2557
2394
  return handler(diff, oldObj, newObj);
2558
2395
  }
2559
2396
 
@@ -2569,14 +2406,15 @@ function createTaxCategoriesMapActions(mapActionGroup, syncActionConfig) {
2569
2406
  return flatten(allActions);
2570
2407
  };
2571
2408
  }
2572
-
2573
2409
  var taxCategories = (function (actionGroupList, syncActionConfig) {
2574
2410
  // config contains information about which action groups
2575
2411
  // are allowed or ignored
2412
+
2576
2413
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2577
2414
  // - action group name
2578
2415
  // - callback function that should return a list of actions that correspond
2579
2416
  // to the for the action group
2417
+
2580
2418
  // this resulting function mapActionGroup will call the callback function
2581
2419
  // for allowed action groups and return the return value of the callback
2582
2420
  // It will return an empty array for ignored action groups
@@ -2598,13 +2436,11 @@ var baseActionsList$a = [{
2598
2436
  action: 'setKey',
2599
2437
  key: 'key'
2600
2438
  }];
2601
-
2602
2439
  var hasLocation = function hasLocation(locations, otherLocation) {
2603
2440
  return locations.some(function (location) {
2604
2441
  return location.country === otherLocation.country;
2605
2442
  });
2606
2443
  };
2607
-
2608
2444
  function actionsMapBase$a(diff, oldObj, newObj) {
2609
2445
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2610
2446
  return buildBaseAttributesActions({
@@ -2616,36 +2452,37 @@ function actionsMapBase$a(diff, oldObj, newObj) {
2616
2452
  });
2617
2453
  }
2618
2454
  function actionsMapLocations(diff, oldObj, newObj) {
2619
- var _createBuildArrayActi;
2620
-
2621
- var handler = createBuildArrayActions('locations', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newLocation) {
2455
+ var handler = createBuildArrayActions('locations', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newLocation) {
2622
2456
  return {
2623
2457
  action: 'addLocation',
2624
2458
  location: newLocation
2625
2459
  };
2626
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldLocation) {
2627
- return (// We only add the action if the location is not included in the new object.
2460
+ }), REMOVE_ACTIONS, function (oldLocation) {
2461
+ return (
2462
+ // We only add the action if the location is not included in the new object.
2628
2463
  !hasLocation(newObj.locations, oldLocation) ? {
2629
2464
  action: 'removeLocation',
2630
2465
  location: oldLocation
2631
2466
  } : null
2632
2467
  );
2633
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldLocation, newLocation) {
2634
- var result = []; // We only remove the location in case that the oldLocation is not
2635
- // included in the new object
2468
+ }), CHANGE_ACTIONS, function (oldLocation, newLocation) {
2469
+ var result = [];
2636
2470
 
2471
+ // We only remove the location in case that the oldLocation is not
2472
+ // included in the new object
2637
2473
  if (!hasLocation(newObj.locations, oldLocation)) result.push({
2638
2474
  action: 'removeLocation',
2639
2475
  location: oldLocation
2640
- }); // We only add the location in case that the newLocation was not
2641
- // included in the old object
2476
+ });
2642
2477
 
2478
+ // We only add the location in case that the newLocation was not
2479
+ // included in the old object
2643
2480
  if (!hasLocation(oldObj.locations, newLocation)) result.push({
2644
2481
  action: 'addLocation',
2645
2482
  location: newLocation
2646
2483
  });
2647
2484
  return result;
2648
- }), _createBuildArrayActi));
2485
+ }));
2649
2486
  return handler(diff, oldObj, newObj);
2650
2487
  }
2651
2488
 
@@ -2661,14 +2498,15 @@ function createZonesMapActions(mapActionGroup, syncActionConfig) {
2661
2498
  return flatten(allActions);
2662
2499
  };
2663
2500
  }
2664
-
2665
2501
  var zones = (function (actionGroupList, syncActionConfig) {
2666
2502
  // config contains information about which action groups
2667
2503
  // are allowed or ignored
2504
+
2668
2505
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2669
2506
  // - action group name
2670
2507
  // - callback function that should return a list of actions that correspond
2671
2508
  // to the for the action group
2509
+
2672
2510
  // this resulting function mapActionGroup will call the callback function
2673
2511
  // for allowed action groups and return the return value of the callback
2674
2512
  // It will return an empty array for ignored action groups
@@ -2704,6 +2542,9 @@ var baseActionsList$9 = [{
2704
2542
  }, {
2705
2543
  action: 'changeTaxCategory',
2706
2544
  key: 'taxCategory'
2545
+ }, {
2546
+ action: 'changeActive',
2547
+ key: 'active'
2707
2548
  }];
2708
2549
  function actionsMapBase$9(diff, oldObj, newObj) {
2709
2550
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -2715,7 +2556,6 @@ function actionsMapBase$9(diff, oldObj, newObj) {
2715
2556
  shouldOmitEmptyString: config.shouldOmitEmptyString
2716
2557
  });
2717
2558
  }
2718
-
2719
2559
  var addShippingRates = function addShippingRates(newZoneRate) {
2720
2560
  return newZoneRate.shippingRates ? newZoneRate.shippingRates.map(function (shippingRate) {
2721
2561
  return {
@@ -2725,23 +2565,20 @@ var addShippingRates = function addShippingRates(newZoneRate) {
2725
2565
  };
2726
2566
  }) : [];
2727
2567
  };
2728
-
2729
2568
  function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2730
- var _createBuildArrayActi;
2731
-
2732
- var handler = createBuildArrayActions('shippingRates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newShippingRate) {
2569
+ var handler = createBuildArrayActions('shippingRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newShippingRate) {
2733
2570
  return {
2734
2571
  action: 'addShippingRate',
2735
2572
  zone: newObj.zone,
2736
2573
  shippingRate: newShippingRate
2737
2574
  };
2738
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldShippingRate) {
2575
+ }), REMOVE_ACTIONS, function (oldShippingRate) {
2739
2576
  return {
2740
2577
  action: 'removeShippingRate',
2741
2578
  zone: oldObj.zone,
2742
2579
  shippingRate: oldShippingRate
2743
2580
  };
2744
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2581
+ }), CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2745
2582
  return [{
2746
2583
  action: 'removeShippingRate',
2747
2584
  zone: oldObj.zone,
@@ -2751,24 +2588,21 @@ function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2751
2588
  zone: newObj.zone,
2752
2589
  shippingRate: newShippingRate
2753
2590
  }];
2754
- }), _createBuildArrayActi));
2591
+ }));
2755
2592
  return handler(diff, oldObj, newObj);
2756
2593
  }
2757
-
2758
2594
  function actionsMapZoneRates(diff, oldObj, newObj) {
2759
- var _createBuildArrayActi2;
2760
-
2761
- var handler = createBuildArrayActions('zoneRates', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newZoneRate) {
2595
+ var handler = createBuildArrayActions('zoneRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newZoneRate) {
2762
2596
  return [{
2763
2597
  action: 'addZone',
2764
2598
  zone: newZoneRate.zone
2765
2599
  }].concat(_toConsumableArray(addShippingRates(newZoneRate)));
2766
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (oldZoneRate) {
2600
+ }), REMOVE_ACTIONS, function (oldZoneRate) {
2767
2601
  return {
2768
2602
  action: 'removeZone',
2769
2603
  zone: oldZoneRate.zone
2770
2604
  };
2771
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2605
+ }), CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2772
2606
  var hasZoneActions = false;
2773
2607
  var shippingRateActions = Object.keys(diff.zoneRates).reduce(function (actions, key) {
2774
2608
  if (diff.zoneRates[key].zone) hasZoneActions = true;
@@ -2782,7 +2616,7 @@ function actionsMapZoneRates(diff, oldObj, newObj) {
2782
2616
  action: 'addZone',
2783
2617
  zone: newZoneRate.zone
2784
2618
  }]) : shippingRateActions);
2785
- }), _createBuildArrayActi2));
2619
+ }));
2786
2620
  return handler(diff, oldObj, newObj);
2787
2621
  }
2788
2622
 
@@ -2801,14 +2635,15 @@ function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
2801
2635
  return flatten(allActions);
2802
2636
  };
2803
2637
  }
2804
-
2805
2638
  var shippingMethods = (function (actionGroupList, syncActionConfig) {
2806
2639
  // actionGroupList contains information about which action groups
2807
2640
  // are allowed or ignored
2641
+
2808
2642
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2809
2643
  // - action group name
2810
2644
  // - callback function that should return a list of actions that correspond
2811
2645
  // to the for the action group
2646
+
2812
2647
  // this resulting function mapActionGroup will call the callback function
2813
2648
  // for allowed action groups and return the return value of the callback
2814
2649
  // It will return an empty array for ignored action groups
@@ -2829,7 +2664,6 @@ var keys = Object.keys;
2829
2664
  * @param b the value to test
2830
2665
  * @returns are the values equal by the SameValueZero principle
2831
2666
  */
2832
-
2833
2667
  function sameValueZeroEqual(a, b) {
2834
2668
  return a === b || a !== a && b !== b;
2835
2669
  }
@@ -2839,8 +2673,6 @@ function sameValueZeroEqual(a, b) {
2839
2673
  * @param value the value to test
2840
2674
  * @returns is the value a plain object
2841
2675
  */
2842
-
2843
-
2844
2676
  function isPlainObject(value) {
2845
2677
  return value.constructor === Object || value.constructor == null;
2846
2678
  }
@@ -2850,8 +2682,6 @@ function isPlainObject(value) {
2850
2682
  * @param value the value to test
2851
2683
  * @returns is the value promise-like
2852
2684
  */
2853
-
2854
-
2855
2685
  function isPromiseLike(value) {
2856
2686
  return !!value && typeof value.then === 'function';
2857
2687
  }
@@ -2861,8 +2691,6 @@ function isPromiseLike(value) {
2861
2691
  * @param value the value to test
2862
2692
  * @returns is the value a react element
2863
2693
  */
2864
-
2865
-
2866
2694
  function isReactElement(value) {
2867
2695
  return !!(value && value.$$typeof);
2868
2696
  }
@@ -2872,8 +2700,6 @@ function isReactElement(value) {
2872
2700
  *
2873
2701
  * @returns the new cache object
2874
2702
  */
2875
-
2876
-
2877
2703
  function getNewCacheFallback() {
2878
2704
  var values = [];
2879
2705
  return {
@@ -2890,15 +2716,12 @@ function getNewCacheFallback() {
2890
2716
  *
2891
2717
  * @returns the new cache object
2892
2718
  */
2893
-
2894
-
2895
2719
  var getNewCache = function (canUseWeakMap) {
2896
2720
  if (canUseWeakMap) {
2897
2721
  return function _getNewCache() {
2898
2722
  return new WeakSet();
2899
2723
  };
2900
2724
  }
2901
-
2902
2725
  return getNewCacheFallback;
2903
2726
  }(HAS_WEAKSET_SUPPORT);
2904
2727
  /**
@@ -2907,37 +2730,28 @@ var getNewCache = function (canUseWeakMap) {
2907
2730
  * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
2908
2731
  * @returns the method to create the `isEqual` function
2909
2732
  */
2910
-
2911
-
2912
2733
  function createCircularEqualCreator(isEqual) {
2913
2734
  return function createCircularEqual(comparator) {
2914
2735
  var _comparator = isEqual || comparator;
2915
-
2916
2736
  return function circularEqual(a, b, cache) {
2917
2737
  if (cache === void 0) {
2918
2738
  cache = getNewCache();
2919
2739
  }
2920
-
2921
2740
  var isCacheableA = !!a && _typeof(a) === 'object';
2922
2741
  var isCacheableB = !!b && _typeof(b) === 'object';
2923
-
2924
2742
  if (isCacheableA || isCacheableB) {
2925
2743
  var hasA = isCacheableA && cache.has(a);
2926
2744
  var hasB = isCacheableB && cache.has(b);
2927
-
2928
2745
  if (hasA || hasB) {
2929
2746
  return hasA && hasB;
2930
2747
  }
2931
-
2932
2748
  if (isCacheableA) {
2933
2749
  cache.add(a);
2934
2750
  }
2935
-
2936
2751
  if (isCacheableB) {
2937
2752
  cache.add(b);
2938
2753
  }
2939
2754
  }
2940
-
2941
2755
  return _comparator(a, b, cache);
2942
2756
  };
2943
2757
  };
@@ -2951,21 +2765,16 @@ function createCircularEqualCreator(isEqual) {
2951
2765
  * @param meta the meta object to pass through
2952
2766
  * @returns are the arrays equal
2953
2767
  */
2954
-
2955
-
2956
2768
  function areArraysEqual(a, b, isEqual, meta) {
2957
2769
  var index = a.length;
2958
-
2959
2770
  if (b.length !== index) {
2960
2771
  return false;
2961
2772
  }
2962
-
2963
2773
  while (index-- > 0) {
2964
2774
  if (!isEqual(a[index], b[index], meta)) {
2965
2775
  return false;
2966
2776
  }
2967
2777
  }
2968
-
2969
2778
  return true;
2970
2779
  }
2971
2780
  /**
@@ -2977,11 +2786,8 @@ function areArraysEqual(a, b, isEqual, meta) {
2977
2786
  * @param meta the meta map to pass through
2978
2787
  * @returns are the maps equal
2979
2788
  */
2980
-
2981
-
2982
2789
  function areMapsEqual(a, b, isEqual, meta) {
2983
2790
  var isValueEqual = a.size === b.size;
2984
-
2985
2791
  if (isValueEqual && a.size) {
2986
2792
  var matchedIndices_1 = {};
2987
2793
  a.forEach(function (aValue, aKey) {
@@ -2991,22 +2797,18 @@ function areMapsEqual(a, b, isEqual, meta) {
2991
2797
  b.forEach(function (bValue, bKey) {
2992
2798
  if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
2993
2799
  hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
2994
-
2995
2800
  if (hasMatch_1) {
2996
2801
  matchedIndices_1[matchIndex_1] = true;
2997
2802
  }
2998
2803
  }
2999
-
3000
2804
  matchIndex_1++;
3001
2805
  });
3002
2806
  isValueEqual = hasMatch_1;
3003
2807
  }
3004
2808
  });
3005
2809
  }
3006
-
3007
2810
  return isValueEqual;
3008
2811
  }
3009
-
3010
2812
  var OWNER = '_owner';
3011
2813
  var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
3012
2814
  /**
@@ -3018,36 +2820,28 @@ var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Objec
3018
2820
  * @param meta the meta object to pass through
3019
2821
  * @returns are the objects equal
3020
2822
  */
3021
-
3022
2823
  function areObjectsEqual(a, b, isEqual, meta) {
3023
2824
  var keysA = keys(a);
3024
2825
  var index = keysA.length;
3025
-
3026
2826
  if (keys(b).length !== index) {
3027
2827
  return false;
3028
2828
  }
3029
-
3030
2829
  if (index) {
3031
2830
  var key = void 0;
3032
-
3033
2831
  while (index-- > 0) {
3034
2832
  key = keysA[index];
3035
-
3036
2833
  if (key === OWNER) {
3037
2834
  var reactElementA = isReactElement(a);
3038
2835
  var reactElementB = isReactElement(b);
3039
-
3040
2836
  if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
3041
2837
  return false;
3042
2838
  }
3043
2839
  }
3044
-
3045
2840
  if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3046
2841
  return false;
3047
2842
  }
3048
2843
  }
3049
2844
  }
3050
-
3051
2845
  return true;
3052
2846
  }
3053
2847
  /**
@@ -3057,8 +2851,6 @@ function areObjectsEqual(a, b, isEqual, meta) {
3057
2851
  * @param b the regExp to test agains
3058
2852
  * @returns are the regExps equal
3059
2853
  */
3060
-
3061
-
3062
2854
  function areRegExpsEqual(a, b) {
3063
2855
  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;
3064
2856
  }
@@ -3071,11 +2863,8 @@ function areRegExpsEqual(a, b) {
3071
2863
  * @param meta the meta set to pass through
3072
2864
  * @returns are the sets equal
3073
2865
  */
3074
-
3075
-
3076
2866
  function areSetsEqual(a, b, isEqual, meta) {
3077
2867
  var isValueEqual = a.size === b.size;
3078
-
3079
2868
  if (isValueEqual && a.size) {
3080
2869
  var matchedIndices_2 = {};
3081
2870
  a.forEach(function (aValue) {
@@ -3085,31 +2874,24 @@ function areSetsEqual(a, b, isEqual, meta) {
3085
2874
  b.forEach(function (bValue) {
3086
2875
  if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
3087
2876
  hasMatch_2 = isEqual(aValue, bValue, meta);
3088
-
3089
2877
  if (hasMatch_2) {
3090
2878
  matchedIndices_2[matchIndex_2] = true;
3091
2879
  }
3092
2880
  }
3093
-
3094
2881
  matchIndex_2++;
3095
2882
  });
3096
2883
  isValueEqual = hasMatch_2;
3097
2884
  }
3098
2885
  });
3099
2886
  }
3100
-
3101
2887
  return isValueEqual;
3102
2888
  }
3103
-
3104
2889
  var HAS_MAP_SUPPORT = typeof Map === 'function';
3105
2890
  var HAS_SET_SUPPORT = typeof Set === 'function';
3106
-
3107
2891
  function createComparator(createIsEqual) {
3108
- var isEqual =
3109
- /* eslint-disable no-use-before-define */
2892
+ var isEqual = /* eslint-disable no-use-before-define */
3110
2893
  typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
3111
2894
  /* eslint-enable */
3112
-
3113
2895
  /**
3114
2896
  * compare the value of the two objects and return true if they are equivalent in values
3115
2897
  *
@@ -3118,69 +2900,52 @@ function createComparator(createIsEqual) {
3118
2900
  * @param [meta] an optional meta object that is passed through to all equality test calls
3119
2901
  * @returns are a and b equivalent in value
3120
2902
  */
3121
-
3122
2903
  function comparator(a, b, meta) {
3123
2904
  if (a === b) {
3124
2905
  return true;
3125
2906
  }
3126
-
3127
2907
  if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3128
2908
  if (isPlainObject(a) && isPlainObject(b)) {
3129
2909
  return areObjectsEqual(a, b, isEqual, meta);
3130
2910
  }
3131
-
3132
2911
  var aShape = Array.isArray(a);
3133
2912
  var bShape = Array.isArray(b);
3134
-
3135
2913
  if (aShape || bShape) {
3136
2914
  return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3137
2915
  }
3138
-
3139
2916
  aShape = a instanceof Date;
3140
2917
  bShape = b instanceof Date;
3141
-
3142
2918
  if (aShape || bShape) {
3143
2919
  return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3144
2920
  }
3145
-
3146
2921
  aShape = a instanceof RegExp;
3147
2922
  bShape = b instanceof RegExp;
3148
-
3149
2923
  if (aShape || bShape) {
3150
2924
  return aShape === bShape && areRegExpsEqual(a, b);
3151
2925
  }
3152
-
3153
2926
  if (isPromiseLike(a) || isPromiseLike(b)) {
3154
2927
  return a === b;
3155
2928
  }
3156
-
3157
2929
  if (HAS_MAP_SUPPORT) {
3158
2930
  aShape = a instanceof Map;
3159
2931
  bShape = b instanceof Map;
3160
-
3161
2932
  if (aShape || bShape) {
3162
2933
  return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3163
2934
  }
3164
2935
  }
3165
-
3166
2936
  if (HAS_SET_SUPPORT) {
3167
2937
  aShape = a instanceof Set;
3168
2938
  bShape = b instanceof Set;
3169
-
3170
2939
  if (aShape || bShape) {
3171
2940
  return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3172
2941
  }
3173
2942
  }
3174
-
3175
2943
  return areObjectsEqual(a, b, isEqual, meta);
3176
2944
  }
3177
-
3178
2945
  return a !== a && b !== b;
3179
2946
  }
3180
-
3181
2947
  return comparator;
3182
2948
  }
3183
-
3184
2949
  var deepEqual = createComparator();
3185
2950
  createComparator(function () {
3186
2951
  return sameValueZeroEqual;
@@ -3211,21 +2976,20 @@ function actionsMapBase$8(diff, previous, next) {
3211
2976
  newObj: next,
3212
2977
  shouldOmitEmptyString: config.shouldOmitEmptyString
3213
2978
  });
3214
- } // this is nearly similar to `buildBaseAttributesActions`, however with a significant difference.
2979
+ }
2980
+
2981
+ // this is nearly similar to `buildBaseAttributesActions`, however with a significant difference.
3215
2982
  // `buildBasAttributesActions` generates update-actions with help of `diff`,
3216
2983
  // which is an object consisting of flags which indicates different operations.
3217
2984
  // `generateBaseFieldsUpdateActions` only generate based on `previous` and `next`.
3218
-
3219
2985
  var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(previous, next, actionDefinition) {
3220
2986
  var isEmpty = createIsEmptyValue([undefined, null, '']);
3221
2987
  return Object.entries(actionDefinition).reduce(function (nextUpdateActions, _ref) {
3222
2988
  var _ref2 = _slicedToArray(_ref, 2),
3223
- field = _ref2[0],
3224
- actionFieldDefinition = _ref2[1];
3225
-
2989
+ field = _ref2[0],
2990
+ actionFieldDefinition = _ref2[1];
3226
2991
  if (isEmpty(previous[field]) && isEmpty(next[field])) return nextUpdateActions;
3227
2992
  if (!isEmpty(previous[field]) && isEmpty(next[field])) return [].concat(_toConsumableArray(nextUpdateActions), [actionFieldDefinition]);
3228
-
3229
2993
  if (!deepEqual(previous[field], next[field])) {
3230
2994
  switch (field) {
3231
2995
  // BEWARE that this is generates update-action only for key of enum attribute value,
@@ -3233,7 +2997,8 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3233
2997
  // `generateBaseFieldsUpdateActions`, we need to extract the following logic so we could
3234
2998
  // cover both entity types.
3235
2999
  case 'key':
3236
- return [].concat(_toConsumableArray(nextUpdateActions), [// Another option is to have explicit name of `field` e.g `enumKey`, which we could use to
3000
+ return [].concat(_toConsumableArray(nextUpdateActions), [
3001
+ // Another option is to have explicit name of `field` e.g `enumKey`, which we could use to
3237
3002
  // generate appropriate update-action for respective entity type.
3238
3003
  // An outline of this on the top of my head:
3239
3004
  // ```js
@@ -3263,7 +3028,6 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3263
3028
  newKey: next[field]
3264
3029
  }]);
3265
3030
  // attribute
3266
-
3267
3031
  case 'attributeConstraint':
3268
3032
  case 'inputHint':
3269
3033
  return [].concat(_toConsumableArray(nextUpdateActions), [{
@@ -3271,7 +3035,6 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3271
3035
  attributeName: actionFieldDefinition.attributeName,
3272
3036
  newValue: next[field]
3273
3037
  }]);
3274
-
3275
3038
  default:
3276
3039
  return [].concat(_toConsumableArray(nextUpdateActions), [_defineProperty({
3277
3040
  action: actionFieldDefinition.action,
@@ -3279,11 +3042,9 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3279
3042
  }, field, next[field])]);
3280
3043
  }
3281
3044
  }
3282
-
3283
3045
  return nextUpdateActions;
3284
3046
  }, []);
3285
3047
  };
3286
-
3287
3048
  var generateUpdateActionsForAttributeDefinitions = function generateUpdateActionsForAttributeDefinitions() {
3288
3049
  var attributeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3289
3050
  var removedAttributeDefinitions = attributeDefinitions.filter(function (attributeDefinition) {
@@ -3330,7 +3091,6 @@ var generateUpdateActionsForAttributeDefinitions = function generateUpdateAction
3330
3091
  };
3331
3092
  })));
3332
3093
  };
3333
-
3334
3094
  var generateUpdateActionsForAttributeEnumValues = function generateUpdateActionsForAttributeEnumValues() {
3335
3095
  var attributeEnumValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3336
3096
  var removedAttributeEnumValues = attributeEnumValues.filter(function (attributeEnumValue) {
@@ -3358,7 +3118,6 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3358
3118
  attributeName: updatedAttributeEnumValue.hint.attributeName
3359
3119
  }
3360
3120
  });
3361
-
3362
3121
  if (!deepEqual(updatedAttributeEnumValue.previous.label, updatedAttributeEnumValue.next.label)) {
3363
3122
  if (updatedAttributeEnumValue.hint.isLocalized) {
3364
3123
  return [].concat(_toConsumableArray(updateActions), [{
@@ -3367,14 +3126,12 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3367
3126
  newValue: updatedAttributeEnumValue.next
3368
3127
  }]);
3369
3128
  }
3370
-
3371
3129
  return [].concat(_toConsumableArray(updateActions), [{
3372
3130
  action: 'changePlainEnumValueLabel',
3373
3131
  attributeName: updatedAttributeEnumValue.hint.attributeName,
3374
3132
  newValue: updatedAttributeEnumValue.next
3375
3133
  }]);
3376
3134
  }
3377
-
3378
3135
  return updateActions;
3379
3136
  }))), _toConsumableArray(addedAttributeEnumValues.map(function (addedAttributeEnumValue) {
3380
3137
  return {
@@ -3384,7 +3141,6 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3384
3141
  };
3385
3142
  })));
3386
3143
  };
3387
-
3388
3144
  var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAction() {
3389
3145
  var attrsOld = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3390
3146
  var attrsNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -3402,9 +3158,10 @@ var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAc
3402
3158
  return action.action === 'addAttributeDefinition';
3403
3159
  }).map(function (action) {
3404
3160
  return action.attribute.name;
3405
- }); // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3406
- // calculate how the productType will look like after adding/removing attributes
3161
+ });
3407
3162
 
3163
+ // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3164
+ // calculate how the productType will look like after adding/removing attributes
3408
3165
  var patchedOldAttributesOrder = attrsOld.map(function (attribute) {
3409
3166
  return attribute.name;
3410
3167
  }).filter(function (name) {
@@ -3416,7 +3173,6 @@ var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAc
3416
3173
  };
3417
3174
  return null;
3418
3175
  };
3419
-
3420
3176
  var actionsMapForHints = function actionsMapForHints() {
3421
3177
  var nestedValuesChanges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3422
3178
  var ptOld = arguments.length > 1 ? arguments[1] : undefined;
@@ -3429,14 +3185,14 @@ var actionsMapForHints = function actionsMapForHints() {
3429
3185
 
3430
3186
  function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
3431
3187
  return function doMapActions(diff, next, previous, options) {
3432
- return flatten([// we support only base fields for the product type,
3188
+ return flatten([
3189
+ // we support only base fields for the product type,
3433
3190
  // for attributes, applying hints would be recommended
3434
3191
  mapActionGroup('base', function () {
3435
3192
  return actionsMapBase$8(diff, previous, next, syncActionConfig);
3436
3193
  }), actionsMapForHints(options.nestedValuesChanges, previous, next)]);
3437
3194
  };
3438
3195
  }
3439
-
3440
3196
  var productTypes = (function (actionGroupList, syncActionConfig) {
3441
3197
  var mapActionGroup = createMapActionGroup(actionGroupList);
3442
3198
  var doMapActions = createProductTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3479,26 +3235,24 @@ function actionsMapBase$7(diff, oldObj, newObj) {
3479
3235
  });
3480
3236
  }
3481
3237
  function actionsMapRoles(diff, oldObj, newObj) {
3482
- var _createBuildArrayActi;
3483
-
3484
- var buildArrayActions = createBuildArrayActions('roles', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newRole) {
3238
+ var buildArrayActions = createBuildArrayActions('roles', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newRole) {
3485
3239
  return {
3486
3240
  action: 'addRoles',
3487
3241
  roles: newRole
3488
3242
  };
3489
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldRole) {
3243
+ }), REMOVE_ACTIONS, function (oldRole) {
3490
3244
  return {
3491
3245
  action: 'removeRoles',
3492
3246
  roles: oldRole
3493
3247
  };
3494
- }), _createBuildArrayActi));
3248
+ }));
3495
3249
  return buildArrayActions(diff, oldObj, newObj);
3496
3250
  }
3497
3251
 
3252
+ // This function groups `addRoles` and `removeRoles` actions to one array
3498
3253
  function groupRoleActions(_ref) {
3499
3254
  var _ref2 = _slicedToArray(_ref, 1),
3500
- actions = _ref2[0];
3501
-
3255
+ actions = _ref2[0];
3502
3256
  var addActionRoles = [];
3503
3257
  var removeActionRoles = [];
3504
3258
  actions.forEach(function (action) {
@@ -3515,7 +3269,6 @@ function groupRoleActions(_ref) {
3515
3269
  return action.roles.length;
3516
3270
  });
3517
3271
  }
3518
-
3519
3272
  function createStatesMapActions(mapActionGroup, syncActionConfig) {
3520
3273
  return function doMapActions(diff, newObj, oldObj) {
3521
3274
  var baseActions = [];
@@ -3529,7 +3282,6 @@ function createStatesMapActions(mapActionGroup, syncActionConfig) {
3529
3282
  return flatten([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
3530
3283
  };
3531
3284
  }
3532
-
3533
3285
  var states = (function (actionGroupList, syncActionConfig) {
3534
3286
  var mapActionGroup = createMapActionGroup(actionGroupList);
3535
3287
  var doMapActions = createStatesMapActions(mapActionGroup, syncActionConfig);
@@ -3581,7 +3333,6 @@ function createChannelsMapActions$1(mapActionGroup, syncActionConfig) {
3581
3333
  return flatten(allActions);
3582
3334
  };
3583
3335
  }
3584
-
3585
3336
  var channels = (function (actionGroupList) {
3586
3337
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3587
3338
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3594,15 +3345,12 @@ var channels = (function (actionGroupList) {
3594
3345
 
3595
3346
  var REGEX_NUMBER = new RegExp(/^\d+$/);
3596
3347
  var REGEX_UNDERSCORE_NUMBER = new RegExp(/^_\d+$/);
3597
-
3598
3348
  var getIsChangedOperation = function getIsChangedOperation(key) {
3599
3349
  return REGEX_NUMBER.test(key);
3600
3350
  };
3601
-
3602
3351
  var getIsRemovedOperation = function getIsRemovedOperation(key) {
3603
3352
  return REGEX_UNDERSCORE_NUMBER.test(key);
3604
3353
  };
3605
-
3606
3354
  var baseActionsList$5 = [{
3607
3355
  action: 'changeKey',
3608
3356
  key: 'key'
@@ -3623,38 +3371,35 @@ function actionsMapBase$5(diff, oldObj, newObj) {
3623
3371
  shouldOmitEmptyString: config.shouldOmitEmptyString
3624
3372
  });
3625
3373
  }
3626
-
3627
3374
  function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next) {
3628
- var _createBuildArrayActi;
3629
-
3630
3375
  var addEnumActionName = attributeType === 'Enum' ? 'addEnumValue' : 'addLocalizedEnumValue';
3631
3376
  var changeEnumValueLabelActionName = attributeType === 'Enum' ? 'changeEnumValueLabel' : 'changeLocalizedEnumValueLabel';
3632
3377
  var changeEnumOrderActionName = attributeType === 'Enum' ? 'changeEnumValueOrder' : 'changeLocalizedEnumValueOrder';
3633
- var buildArrayActions = createBuildArrayActions('values', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newEnum) {
3378
+ var buildArrayActions = createBuildArrayActions('values', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newEnum) {
3634
3379
  return {
3635
3380
  fieldName: fieldName,
3636
3381
  action: addEnumActionName,
3637
3382
  value: newEnum
3638
3383
  };
3639
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldEnum, newEnum) {
3384
+ }), CHANGE_ACTIONS, function (oldEnum, newEnum) {
3640
3385
  var oldEnumInNext = next.values.find(function (nextEnum) {
3641
3386
  return nextEnum.key === oldEnum.key;
3642
- }); // These `changeActions` would impose a nested structure among
3387
+ });
3388
+
3389
+ // These `changeActions` would impose a nested structure among
3643
3390
  // the accumulated `updateActions` generated by `buildArrayActions`
3644
3391
  // In the end; we have to flatten the structure before we pass it back
3645
3392
  // to the client.
3646
-
3647
3393
  var changeActions = [];
3648
-
3649
3394
  if (oldEnumInNext) {
3650
3395
  // If the enum value is changed, we need to change the order first
3651
- var isKeyChanged = oldEnum.key !== newEnum.key; // check if the label is changed
3396
+ var isKeyChanged = oldEnum.key !== newEnum.key;
3652
3397
 
3398
+ // check if the label is changed
3653
3399
  var foundPreviousEnum = previous.values.find(function (previousEnum) {
3654
3400
  return previousEnum.key === newEnum.key;
3655
3401
  });
3656
3402
  var isLabelEqual = isEqual(foundPreviousEnum.label, newEnum.label);
3657
-
3658
3403
  if (isKeyChanged) {
3659
3404
  // these actions is then flatten in the end
3660
3405
  changeActions.push({
@@ -3663,7 +3408,6 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3663
3408
  value: newEnum
3664
3409
  });
3665
3410
  }
3666
-
3667
3411
  if (!isLabelEqual) {
3668
3412
  changeActions.push({
3669
3413
  fieldName: fieldName,
@@ -3678,12 +3422,11 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3678
3422
  value: newEnum
3679
3423
  });
3680
3424
  }
3681
-
3682
3425
  return changeActions;
3683
- }), _createBuildArrayActi));
3684
- var actions = []; // following lists are necessary to ensure that when we change the
3426
+ }));
3427
+ var actions = [];
3428
+ // following lists are necessary to ensure that when we change the
3685
3429
  // order of enumValues, we generate one updateAction instead of one at a time.
3686
-
3687
3430
  var newEnumValuesOrder = [];
3688
3431
  flatten(buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
3689
3432
  if (updateAction.action === changeEnumOrderActionName) {
@@ -3698,18 +3441,14 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3698
3441
  keys: newEnumValuesOrder
3699
3442
  }] : []));
3700
3443
  }
3701
-
3702
3444
  function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPaths) {
3703
3445
  var actions = [];
3704
3446
  forEach(fieldDefinitionsDiff, function (diffValue, diffKey) {
3705
3447
  var extractedPairs = extractMatchingPairs(diffPaths, diffKey, previous, next);
3706
-
3707
3448
  if (getIsChangedOperation(diffKey)) {
3708
3449
  var _diffValue$type;
3709
-
3710
3450
  if (Array.isArray(diffValue)) {
3711
3451
  var deltaValue = getDeltaValue(diffValue);
3712
-
3713
3452
  if (deltaValue.name) {
3714
3453
  actions.push({
3715
3454
  action: 'addFieldDefinition',
@@ -3742,7 +3481,6 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
3742
3481
  });
3743
3482
  } else {
3744
3483
  var _deltaValue = getDeltaValue(diffValue);
3745
-
3746
3484
  if (_deltaValue === undefined && diffValue[0].name) actions.push({
3747
3485
  action: 'removeFieldDefinition',
3748
3486
  fieldName: diffValue[0].name
@@ -3750,11 +3488,12 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
3750
3488
  }
3751
3489
  }
3752
3490
  }
3753
- }); // Make sure to execute removeActions before creating new ones
3491
+ });
3492
+
3493
+ // Make sure to execute removeActions before creating new ones
3754
3494
  // in order to prevent any eventual removal of `addAction`.
3755
3495
  // List of `removeActions` can be found here
3756
3496
  // https://docs.commercetools.com/http-api-projects-types.html#change-key
3757
-
3758
3497
  var sortedActions = sortBy(actions, function (action) {
3759
3498
  return action.action !== 'removeFieldDefinition';
3760
3499
  });
@@ -3772,7 +3511,6 @@ function createTypeMapActions(mapActionGroup, syncActionConfig) {
3772
3511
  return flatten(allActions);
3773
3512
  };
3774
3513
  }
3775
-
3776
3514
  var types = (function (actionGroupList, syncActionConfig) {
3777
3515
  var mapActionGroup = createMapActionGroup(actionGroupList);
3778
3516
  var doMapActions = createTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3800,6 +3538,15 @@ var baseActionsList$4 = [{
3800
3538
  }, {
3801
3539
  action: 'setShippingRateInputType',
3802
3540
  key: 'shippingRateInputType'
3541
+ }, {
3542
+ action: 'changeMyBusinessUnitStatusOnCreation',
3543
+ key: 'myBusinessUnitStatusOnCreation'
3544
+ }, {
3545
+ action: 'setMyBusinessUnitAssociateRoleOnCreation',
3546
+ key: 'myBusinessUnitAssociateRoleOnCreation'
3547
+ }, {
3548
+ action: 'changeCustomerSearchStatus',
3549
+ key: 'customerSearchStatus'
3803
3550
  }];
3804
3551
  function actionsMapBase$4(diff, oldObj, newObj) {
3805
3552
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -3821,7 +3568,6 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
3821
3568
  return flatten(allActions);
3822
3569
  };
3823
3570
  }
3824
-
3825
3571
  var projects = (function (actionGroupList) {
3826
3572
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3827
3573
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3866,7 +3612,6 @@ function createStoresMapActions(mapActionGroup) {
3866
3612
  return flatten(allActions);
3867
3613
  };
3868
3614
  }
3869
-
3870
3615
  var stores = (function (actionGroupList) {
3871
3616
  var mapActionGroup = createMapActionGroup(actionGroupList);
3872
3617
  var doMapActions = createStoresMapActions(mapActionGroup);
@@ -3905,7 +3650,6 @@ function createProductSelectionsMapActions(mapActionGroup) {
3905
3650
  return flatten(allActions);
3906
3651
  };
3907
3652
  }
3908
-
3909
3653
  var productSelections = (function (actionGroupList) {
3910
3654
  var mapActionGroup = createMapActionGroup(actionGroupList);
3911
3655
  var doMapActions = createProductSelectionsMapActions(mapActionGroup);
@@ -3922,7 +3666,8 @@ var baseActionsList$1 = [{
3922
3666
  }, {
3923
3667
  action: 'setDiscountedPrice',
3924
3668
  key: 'discounted'
3925
- }, // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3669
+ },
3670
+ // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3926
3671
  {
3927
3672
  action: 'setPriceTiers',
3928
3673
  key: 'tiers'
@@ -3961,7 +3706,6 @@ function createPriceMapActions(mapActionGroup, syncActionConfig) {
3961
3706
  return combineValidityActions([].concat(_toConsumableArray(baseActions), _toConsumableArray(customActions)));
3962
3707
  };
3963
3708
  }
3964
-
3965
3709
  var prices = (function (actionGroupList, syncActionConfig) {
3966
3710
  var mapActionGroup = createMapActionGroup(actionGroupList);
3967
3711
  var doMapActions = createPriceMapActions(mapActionGroup, syncActionConfig);
@@ -3976,7 +3720,6 @@ var hasAttribute = function hasAttribute(attributes, newValue) {
3976
3720
  return attribute.key === newValue.key;
3977
3721
  });
3978
3722
  };
3979
-
3980
3723
  var baseActionsList = [{
3981
3724
  action: 'changeName',
3982
3725
  key: 'name'
@@ -3998,35 +3741,34 @@ function actionsMapBase(diff, oldObj, newObj) {
3998
3741
  });
3999
3742
  }
4000
3743
  function actionsMapAttributes(diff, oldObj, newObj) {
4001
- var _createBuildArrayActi;
4002
-
4003
- var handler = createBuildArrayActions('attributes', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAttribute) {
3744
+ var handler = createBuildArrayActions('attributes', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAttribute) {
4004
3745
  return {
4005
3746
  action: 'addAttribute',
4006
3747
  attribute: newAttribute
4007
3748
  };
4008
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAttribute) {
3749
+ }), REMOVE_ACTIONS, function (oldAttribute) {
4009
3750
  // We only add the action if the attribute is not included in the new object.
4010
3751
  return !hasAttribute(newObj.attributes, oldAttribute) ? {
4011
3752
  action: 'removeAttribute',
4012
3753
  attribute: oldAttribute
4013
3754
  } : null;
4014
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
4015
- var result = []; // We only remove the attribute in case that the oldAttribute is not
3755
+ }), CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
3756
+ var result = [];
3757
+ // We only remove the attribute in case that the oldAttribute is not
4016
3758
  // included in the new object
4017
-
4018
3759
  if (!hasAttribute(newObj.attributes, oldAttribute)) result.push({
4019
3760
  action: 'removeAttribute',
4020
3761
  attribute: oldAttribute
4021
- }); // We only add the attribute in case that the newAttribute was not
4022
- // included in the old object
3762
+ });
4023
3763
 
3764
+ // We only add the attribute in case that the newAttribute was not
3765
+ // included in the old object
4024
3766
  if (!hasAttribute(oldObj.attributes, newAttribute)) result.push({
4025
3767
  action: 'addAttribute',
4026
3768
  attribute: newAttribute
4027
3769
  });
4028
3770
  return result;
4029
- }), _createBuildArrayActi));
3771
+ }));
4030
3772
  return handler(diff, oldObj, newObj);
4031
3773
  }
4032
3774
 
@@ -4042,7 +3784,6 @@ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
4042
3784
  return flatten(allActions);
4043
3785
  };
4044
3786
  }
4045
-
4046
3787
  var attributeGroups = (function (actionGroupList, syncActionConfig) {
4047
3788
  var mapActionGroup = createMapActionGroup(actionGroupList);
4048
3789
  var doMapActions = createAttributeGroupsMapActions(mapActionGroup, syncActionConfig);