@commercetools/sync-actions 5.17.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);
120
+ return ("string" === r ? String : Number)(t);
154
121
  }
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;
162
- }
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
@@ -2718,7 +2556,6 @@ function actionsMapBase$9(diff, oldObj, newObj) {
2718
2556
  shouldOmitEmptyString: config.shouldOmitEmptyString
2719
2557
  });
2720
2558
  }
2721
-
2722
2559
  var addShippingRates = function addShippingRates(newZoneRate) {
2723
2560
  return newZoneRate.shippingRates ? newZoneRate.shippingRates.map(function (shippingRate) {
2724
2561
  return {
@@ -2728,23 +2565,20 @@ var addShippingRates = function addShippingRates(newZoneRate) {
2728
2565
  };
2729
2566
  }) : [];
2730
2567
  };
2731
-
2732
2568
  function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2733
- var _createBuildArrayActi;
2734
-
2735
- var handler = createBuildArrayActions('shippingRates', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newShippingRate) {
2569
+ var handler = createBuildArrayActions('shippingRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newShippingRate) {
2736
2570
  return {
2737
2571
  action: 'addShippingRate',
2738
2572
  zone: newObj.zone,
2739
2573
  shippingRate: newShippingRate
2740
2574
  };
2741
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldShippingRate) {
2575
+ }), REMOVE_ACTIONS, function (oldShippingRate) {
2742
2576
  return {
2743
2577
  action: 'removeShippingRate',
2744
2578
  zone: oldObj.zone,
2745
2579
  shippingRate: oldShippingRate
2746
2580
  };
2747
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2581
+ }), CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
2748
2582
  return [{
2749
2583
  action: 'removeShippingRate',
2750
2584
  zone: oldObj.zone,
@@ -2754,24 +2588,21 @@ function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
2754
2588
  zone: newObj.zone,
2755
2589
  shippingRate: newShippingRate
2756
2590
  }];
2757
- }), _createBuildArrayActi));
2591
+ }));
2758
2592
  return handler(diff, oldObj, newObj);
2759
2593
  }
2760
-
2761
2594
  function actionsMapZoneRates(diff, oldObj, newObj) {
2762
- var _createBuildArrayActi2;
2763
-
2764
- var handler = createBuildArrayActions('zoneRates', (_createBuildArrayActi2 = {}, _defineProperty(_createBuildArrayActi2, ADD_ACTIONS, function (newZoneRate) {
2595
+ var handler = createBuildArrayActions('zoneRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newZoneRate) {
2765
2596
  return [{
2766
2597
  action: 'addZone',
2767
2598
  zone: newZoneRate.zone
2768
2599
  }].concat(_toConsumableArray(addShippingRates(newZoneRate)));
2769
- }), _defineProperty(_createBuildArrayActi2, REMOVE_ACTIONS, function (oldZoneRate) {
2600
+ }), REMOVE_ACTIONS, function (oldZoneRate) {
2770
2601
  return {
2771
2602
  action: 'removeZone',
2772
2603
  zone: oldZoneRate.zone
2773
2604
  };
2774
- }), _defineProperty(_createBuildArrayActi2, CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2605
+ }), CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
2775
2606
  var hasZoneActions = false;
2776
2607
  var shippingRateActions = Object.keys(diff.zoneRates).reduce(function (actions, key) {
2777
2608
  if (diff.zoneRates[key].zone) hasZoneActions = true;
@@ -2785,7 +2616,7 @@ function actionsMapZoneRates(diff, oldObj, newObj) {
2785
2616
  action: 'addZone',
2786
2617
  zone: newZoneRate.zone
2787
2618
  }]) : shippingRateActions);
2788
- }), _createBuildArrayActi2));
2619
+ }));
2789
2620
  return handler(diff, oldObj, newObj);
2790
2621
  }
2791
2622
 
@@ -2804,14 +2635,15 @@ function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
2804
2635
  return flatten(allActions);
2805
2636
  };
2806
2637
  }
2807
-
2808
2638
  var shippingMethods = (function (actionGroupList, syncActionConfig) {
2809
2639
  // actionGroupList contains information about which action groups
2810
2640
  // are allowed or ignored
2641
+
2811
2642
  // createMapActionGroup returns function 'mapActionGroup' that takes params:
2812
2643
  // - action group name
2813
2644
  // - callback function that should return a list of actions that correspond
2814
2645
  // to the for the action group
2646
+
2815
2647
  // this resulting function mapActionGroup will call the callback function
2816
2648
  // for allowed action groups and return the return value of the callback
2817
2649
  // It will return an empty array for ignored action groups
@@ -2832,7 +2664,6 @@ var keys = Object.keys;
2832
2664
  * @param b the value to test
2833
2665
  * @returns are the values equal by the SameValueZero principle
2834
2666
  */
2835
-
2836
2667
  function sameValueZeroEqual(a, b) {
2837
2668
  return a === b || a !== a && b !== b;
2838
2669
  }
@@ -2842,8 +2673,6 @@ function sameValueZeroEqual(a, b) {
2842
2673
  * @param value the value to test
2843
2674
  * @returns is the value a plain object
2844
2675
  */
2845
-
2846
-
2847
2676
  function isPlainObject(value) {
2848
2677
  return value.constructor === Object || value.constructor == null;
2849
2678
  }
@@ -2853,8 +2682,6 @@ function isPlainObject(value) {
2853
2682
  * @param value the value to test
2854
2683
  * @returns is the value promise-like
2855
2684
  */
2856
-
2857
-
2858
2685
  function isPromiseLike(value) {
2859
2686
  return !!value && typeof value.then === 'function';
2860
2687
  }
@@ -2864,8 +2691,6 @@ function isPromiseLike(value) {
2864
2691
  * @param value the value to test
2865
2692
  * @returns is the value a react element
2866
2693
  */
2867
-
2868
-
2869
2694
  function isReactElement(value) {
2870
2695
  return !!(value && value.$$typeof);
2871
2696
  }
@@ -2875,8 +2700,6 @@ function isReactElement(value) {
2875
2700
  *
2876
2701
  * @returns the new cache object
2877
2702
  */
2878
-
2879
-
2880
2703
  function getNewCacheFallback() {
2881
2704
  var values = [];
2882
2705
  return {
@@ -2893,15 +2716,12 @@ function getNewCacheFallback() {
2893
2716
  *
2894
2717
  * @returns the new cache object
2895
2718
  */
2896
-
2897
-
2898
2719
  var getNewCache = function (canUseWeakMap) {
2899
2720
  if (canUseWeakMap) {
2900
2721
  return function _getNewCache() {
2901
2722
  return new WeakSet();
2902
2723
  };
2903
2724
  }
2904
-
2905
2725
  return getNewCacheFallback;
2906
2726
  }(HAS_WEAKSET_SUPPORT);
2907
2727
  /**
@@ -2910,37 +2730,28 @@ var getNewCache = function (canUseWeakMap) {
2910
2730
  * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
2911
2731
  * @returns the method to create the `isEqual` function
2912
2732
  */
2913
-
2914
-
2915
2733
  function createCircularEqualCreator(isEqual) {
2916
2734
  return function createCircularEqual(comparator) {
2917
2735
  var _comparator = isEqual || comparator;
2918
-
2919
2736
  return function circularEqual(a, b, cache) {
2920
2737
  if (cache === void 0) {
2921
2738
  cache = getNewCache();
2922
2739
  }
2923
-
2924
2740
  var isCacheableA = !!a && _typeof(a) === 'object';
2925
2741
  var isCacheableB = !!b && _typeof(b) === 'object';
2926
-
2927
2742
  if (isCacheableA || isCacheableB) {
2928
2743
  var hasA = isCacheableA && cache.has(a);
2929
2744
  var hasB = isCacheableB && cache.has(b);
2930
-
2931
2745
  if (hasA || hasB) {
2932
2746
  return hasA && hasB;
2933
2747
  }
2934
-
2935
2748
  if (isCacheableA) {
2936
2749
  cache.add(a);
2937
2750
  }
2938
-
2939
2751
  if (isCacheableB) {
2940
2752
  cache.add(b);
2941
2753
  }
2942
2754
  }
2943
-
2944
2755
  return _comparator(a, b, cache);
2945
2756
  };
2946
2757
  };
@@ -2954,21 +2765,16 @@ function createCircularEqualCreator(isEqual) {
2954
2765
  * @param meta the meta object to pass through
2955
2766
  * @returns are the arrays equal
2956
2767
  */
2957
-
2958
-
2959
2768
  function areArraysEqual(a, b, isEqual, meta) {
2960
2769
  var index = a.length;
2961
-
2962
2770
  if (b.length !== index) {
2963
2771
  return false;
2964
2772
  }
2965
-
2966
2773
  while (index-- > 0) {
2967
2774
  if (!isEqual(a[index], b[index], meta)) {
2968
2775
  return false;
2969
2776
  }
2970
2777
  }
2971
-
2972
2778
  return true;
2973
2779
  }
2974
2780
  /**
@@ -2980,11 +2786,8 @@ function areArraysEqual(a, b, isEqual, meta) {
2980
2786
  * @param meta the meta map to pass through
2981
2787
  * @returns are the maps equal
2982
2788
  */
2983
-
2984
-
2985
2789
  function areMapsEqual(a, b, isEqual, meta) {
2986
2790
  var isValueEqual = a.size === b.size;
2987
-
2988
2791
  if (isValueEqual && a.size) {
2989
2792
  var matchedIndices_1 = {};
2990
2793
  a.forEach(function (aValue, aKey) {
@@ -2994,22 +2797,18 @@ function areMapsEqual(a, b, isEqual, meta) {
2994
2797
  b.forEach(function (bValue, bKey) {
2995
2798
  if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
2996
2799
  hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
2997
-
2998
2800
  if (hasMatch_1) {
2999
2801
  matchedIndices_1[matchIndex_1] = true;
3000
2802
  }
3001
2803
  }
3002
-
3003
2804
  matchIndex_1++;
3004
2805
  });
3005
2806
  isValueEqual = hasMatch_1;
3006
2807
  }
3007
2808
  });
3008
2809
  }
3009
-
3010
2810
  return isValueEqual;
3011
2811
  }
3012
-
3013
2812
  var OWNER = '_owner';
3014
2813
  var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
3015
2814
  /**
@@ -3021,36 +2820,28 @@ var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Objec
3021
2820
  * @param meta the meta object to pass through
3022
2821
  * @returns are the objects equal
3023
2822
  */
3024
-
3025
2823
  function areObjectsEqual(a, b, isEqual, meta) {
3026
2824
  var keysA = keys(a);
3027
2825
  var index = keysA.length;
3028
-
3029
2826
  if (keys(b).length !== index) {
3030
2827
  return false;
3031
2828
  }
3032
-
3033
2829
  if (index) {
3034
2830
  var key = void 0;
3035
-
3036
2831
  while (index-- > 0) {
3037
2832
  key = keysA[index];
3038
-
3039
2833
  if (key === OWNER) {
3040
2834
  var reactElementA = isReactElement(a);
3041
2835
  var reactElementB = isReactElement(b);
3042
-
3043
2836
  if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
3044
2837
  return false;
3045
2838
  }
3046
2839
  }
3047
-
3048
2840
  if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3049
2841
  return false;
3050
2842
  }
3051
2843
  }
3052
2844
  }
3053
-
3054
2845
  return true;
3055
2846
  }
3056
2847
  /**
@@ -3060,8 +2851,6 @@ function areObjectsEqual(a, b, isEqual, meta) {
3060
2851
  * @param b the regExp to test agains
3061
2852
  * @returns are the regExps equal
3062
2853
  */
3063
-
3064
-
3065
2854
  function areRegExpsEqual(a, b) {
3066
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;
3067
2856
  }
@@ -3074,11 +2863,8 @@ function areRegExpsEqual(a, b) {
3074
2863
  * @param meta the meta set to pass through
3075
2864
  * @returns are the sets equal
3076
2865
  */
3077
-
3078
-
3079
2866
  function areSetsEqual(a, b, isEqual, meta) {
3080
2867
  var isValueEqual = a.size === b.size;
3081
-
3082
2868
  if (isValueEqual && a.size) {
3083
2869
  var matchedIndices_2 = {};
3084
2870
  a.forEach(function (aValue) {
@@ -3088,31 +2874,24 @@ function areSetsEqual(a, b, isEqual, meta) {
3088
2874
  b.forEach(function (bValue) {
3089
2875
  if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
3090
2876
  hasMatch_2 = isEqual(aValue, bValue, meta);
3091
-
3092
2877
  if (hasMatch_2) {
3093
2878
  matchedIndices_2[matchIndex_2] = true;
3094
2879
  }
3095
2880
  }
3096
-
3097
2881
  matchIndex_2++;
3098
2882
  });
3099
2883
  isValueEqual = hasMatch_2;
3100
2884
  }
3101
2885
  });
3102
2886
  }
3103
-
3104
2887
  return isValueEqual;
3105
2888
  }
3106
-
3107
2889
  var HAS_MAP_SUPPORT = typeof Map === 'function';
3108
2890
  var HAS_SET_SUPPORT = typeof Set === 'function';
3109
-
3110
2891
  function createComparator(createIsEqual) {
3111
- var isEqual =
3112
- /* eslint-disable no-use-before-define */
2892
+ var isEqual = /* eslint-disable no-use-before-define */
3113
2893
  typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
3114
2894
  /* eslint-enable */
3115
-
3116
2895
  /**
3117
2896
  * compare the value of the two objects and return true if they are equivalent in values
3118
2897
  *
@@ -3121,69 +2900,52 @@ function createComparator(createIsEqual) {
3121
2900
  * @param [meta] an optional meta object that is passed through to all equality test calls
3122
2901
  * @returns are a and b equivalent in value
3123
2902
  */
3124
-
3125
2903
  function comparator(a, b, meta) {
3126
2904
  if (a === b) {
3127
2905
  return true;
3128
2906
  }
3129
-
3130
2907
  if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3131
2908
  if (isPlainObject(a) && isPlainObject(b)) {
3132
2909
  return areObjectsEqual(a, b, isEqual, meta);
3133
2910
  }
3134
-
3135
2911
  var aShape = Array.isArray(a);
3136
2912
  var bShape = Array.isArray(b);
3137
-
3138
2913
  if (aShape || bShape) {
3139
2914
  return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3140
2915
  }
3141
-
3142
2916
  aShape = a instanceof Date;
3143
2917
  bShape = b instanceof Date;
3144
-
3145
2918
  if (aShape || bShape) {
3146
2919
  return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3147
2920
  }
3148
-
3149
2921
  aShape = a instanceof RegExp;
3150
2922
  bShape = b instanceof RegExp;
3151
-
3152
2923
  if (aShape || bShape) {
3153
2924
  return aShape === bShape && areRegExpsEqual(a, b);
3154
2925
  }
3155
-
3156
2926
  if (isPromiseLike(a) || isPromiseLike(b)) {
3157
2927
  return a === b;
3158
2928
  }
3159
-
3160
2929
  if (HAS_MAP_SUPPORT) {
3161
2930
  aShape = a instanceof Map;
3162
2931
  bShape = b instanceof Map;
3163
-
3164
2932
  if (aShape || bShape) {
3165
2933
  return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3166
2934
  }
3167
2935
  }
3168
-
3169
2936
  if (HAS_SET_SUPPORT) {
3170
2937
  aShape = a instanceof Set;
3171
2938
  bShape = b instanceof Set;
3172
-
3173
2939
  if (aShape || bShape) {
3174
2940
  return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3175
2941
  }
3176
2942
  }
3177
-
3178
2943
  return areObjectsEqual(a, b, isEqual, meta);
3179
2944
  }
3180
-
3181
2945
  return a !== a && b !== b;
3182
2946
  }
3183
-
3184
2947
  return comparator;
3185
2948
  }
3186
-
3187
2949
  var deepEqual = createComparator();
3188
2950
  createComparator(function () {
3189
2951
  return sameValueZeroEqual;
@@ -3214,21 +2976,20 @@ function actionsMapBase$8(diff, previous, next) {
3214
2976
  newObj: next,
3215
2977
  shouldOmitEmptyString: config.shouldOmitEmptyString
3216
2978
  });
3217
- } // 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.
3218
2982
  // `buildBasAttributesActions` generates update-actions with help of `diff`,
3219
2983
  // which is an object consisting of flags which indicates different operations.
3220
2984
  // `generateBaseFieldsUpdateActions` only generate based on `previous` and `next`.
3221
-
3222
2985
  var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(previous, next, actionDefinition) {
3223
2986
  var isEmpty = createIsEmptyValue([undefined, null, '']);
3224
2987
  return Object.entries(actionDefinition).reduce(function (nextUpdateActions, _ref) {
3225
2988
  var _ref2 = _slicedToArray(_ref, 2),
3226
- field = _ref2[0],
3227
- actionFieldDefinition = _ref2[1];
3228
-
2989
+ field = _ref2[0],
2990
+ actionFieldDefinition = _ref2[1];
3229
2991
  if (isEmpty(previous[field]) && isEmpty(next[field])) return nextUpdateActions;
3230
2992
  if (!isEmpty(previous[field]) && isEmpty(next[field])) return [].concat(_toConsumableArray(nextUpdateActions), [actionFieldDefinition]);
3231
-
3232
2993
  if (!deepEqual(previous[field], next[field])) {
3233
2994
  switch (field) {
3234
2995
  // BEWARE that this is generates update-action only for key of enum attribute value,
@@ -3236,7 +2997,8 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3236
2997
  // `generateBaseFieldsUpdateActions`, we need to extract the following logic so we could
3237
2998
  // cover both entity types.
3238
2999
  case 'key':
3239
- 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
3240
3002
  // generate appropriate update-action for respective entity type.
3241
3003
  // An outline of this on the top of my head:
3242
3004
  // ```js
@@ -3266,7 +3028,6 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3266
3028
  newKey: next[field]
3267
3029
  }]);
3268
3030
  // attribute
3269
-
3270
3031
  case 'attributeConstraint':
3271
3032
  case 'inputHint':
3272
3033
  return [].concat(_toConsumableArray(nextUpdateActions), [{
@@ -3274,7 +3035,6 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3274
3035
  attributeName: actionFieldDefinition.attributeName,
3275
3036
  newValue: next[field]
3276
3037
  }]);
3277
-
3278
3038
  default:
3279
3039
  return [].concat(_toConsumableArray(nextUpdateActions), [_defineProperty({
3280
3040
  action: actionFieldDefinition.action,
@@ -3282,11 +3042,9 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
3282
3042
  }, field, next[field])]);
3283
3043
  }
3284
3044
  }
3285
-
3286
3045
  return nextUpdateActions;
3287
3046
  }, []);
3288
3047
  };
3289
-
3290
3048
  var generateUpdateActionsForAttributeDefinitions = function generateUpdateActionsForAttributeDefinitions() {
3291
3049
  var attributeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3292
3050
  var removedAttributeDefinitions = attributeDefinitions.filter(function (attributeDefinition) {
@@ -3333,7 +3091,6 @@ var generateUpdateActionsForAttributeDefinitions = function generateUpdateAction
3333
3091
  };
3334
3092
  })));
3335
3093
  };
3336
-
3337
3094
  var generateUpdateActionsForAttributeEnumValues = function generateUpdateActionsForAttributeEnumValues() {
3338
3095
  var attributeEnumValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3339
3096
  var removedAttributeEnumValues = attributeEnumValues.filter(function (attributeEnumValue) {
@@ -3361,7 +3118,6 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3361
3118
  attributeName: updatedAttributeEnumValue.hint.attributeName
3362
3119
  }
3363
3120
  });
3364
-
3365
3121
  if (!deepEqual(updatedAttributeEnumValue.previous.label, updatedAttributeEnumValue.next.label)) {
3366
3122
  if (updatedAttributeEnumValue.hint.isLocalized) {
3367
3123
  return [].concat(_toConsumableArray(updateActions), [{
@@ -3370,14 +3126,12 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3370
3126
  newValue: updatedAttributeEnumValue.next
3371
3127
  }]);
3372
3128
  }
3373
-
3374
3129
  return [].concat(_toConsumableArray(updateActions), [{
3375
3130
  action: 'changePlainEnumValueLabel',
3376
3131
  attributeName: updatedAttributeEnumValue.hint.attributeName,
3377
3132
  newValue: updatedAttributeEnumValue.next
3378
3133
  }]);
3379
3134
  }
3380
-
3381
3135
  return updateActions;
3382
3136
  }))), _toConsumableArray(addedAttributeEnumValues.map(function (addedAttributeEnumValue) {
3383
3137
  return {
@@ -3387,7 +3141,6 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
3387
3141
  };
3388
3142
  })));
3389
3143
  };
3390
-
3391
3144
  var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAction() {
3392
3145
  var attrsOld = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3393
3146
  var attrsNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -3405,9 +3158,10 @@ var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAc
3405
3158
  return action.action === 'addAttributeDefinition';
3406
3159
  }).map(function (action) {
3407
3160
  return action.attribute.name;
3408
- }); // changeAttributeOrder action will be sent to CTP API as the last action so we have to
3409
- // calculate how the productType will look like after adding/removing attributes
3161
+ });
3410
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
3411
3165
  var patchedOldAttributesOrder = attrsOld.map(function (attribute) {
3412
3166
  return attribute.name;
3413
3167
  }).filter(function (name) {
@@ -3419,7 +3173,6 @@ var generateChangeAttributeOrderAction = function generateChangeAttributeOrderAc
3419
3173
  };
3420
3174
  return null;
3421
3175
  };
3422
-
3423
3176
  var actionsMapForHints = function actionsMapForHints() {
3424
3177
  var nestedValuesChanges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3425
3178
  var ptOld = arguments.length > 1 ? arguments[1] : undefined;
@@ -3432,14 +3185,14 @@ var actionsMapForHints = function actionsMapForHints() {
3432
3185
 
3433
3186
  function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
3434
3187
  return function doMapActions(diff, next, previous, options) {
3435
- return flatten([// we support only base fields for the product type,
3188
+ return flatten([
3189
+ // we support only base fields for the product type,
3436
3190
  // for attributes, applying hints would be recommended
3437
3191
  mapActionGroup('base', function () {
3438
3192
  return actionsMapBase$8(diff, previous, next, syncActionConfig);
3439
3193
  }), actionsMapForHints(options.nestedValuesChanges, previous, next)]);
3440
3194
  };
3441
3195
  }
3442
-
3443
3196
  var productTypes = (function (actionGroupList, syncActionConfig) {
3444
3197
  var mapActionGroup = createMapActionGroup(actionGroupList);
3445
3198
  var doMapActions = createProductTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3482,26 +3235,24 @@ function actionsMapBase$7(diff, oldObj, newObj) {
3482
3235
  });
3483
3236
  }
3484
3237
  function actionsMapRoles(diff, oldObj, newObj) {
3485
- var _createBuildArrayActi;
3486
-
3487
- var buildArrayActions = createBuildArrayActions('roles', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newRole) {
3238
+ var buildArrayActions = createBuildArrayActions('roles', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newRole) {
3488
3239
  return {
3489
3240
  action: 'addRoles',
3490
3241
  roles: newRole
3491
3242
  };
3492
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldRole) {
3243
+ }), REMOVE_ACTIONS, function (oldRole) {
3493
3244
  return {
3494
3245
  action: 'removeRoles',
3495
3246
  roles: oldRole
3496
3247
  };
3497
- }), _createBuildArrayActi));
3248
+ }));
3498
3249
  return buildArrayActions(diff, oldObj, newObj);
3499
3250
  }
3500
3251
 
3252
+ // This function groups `addRoles` and `removeRoles` actions to one array
3501
3253
  function groupRoleActions(_ref) {
3502
3254
  var _ref2 = _slicedToArray(_ref, 1),
3503
- actions = _ref2[0];
3504
-
3255
+ actions = _ref2[0];
3505
3256
  var addActionRoles = [];
3506
3257
  var removeActionRoles = [];
3507
3258
  actions.forEach(function (action) {
@@ -3518,7 +3269,6 @@ function groupRoleActions(_ref) {
3518
3269
  return action.roles.length;
3519
3270
  });
3520
3271
  }
3521
-
3522
3272
  function createStatesMapActions(mapActionGroup, syncActionConfig) {
3523
3273
  return function doMapActions(diff, newObj, oldObj) {
3524
3274
  var baseActions = [];
@@ -3532,7 +3282,6 @@ function createStatesMapActions(mapActionGroup, syncActionConfig) {
3532
3282
  return flatten([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
3533
3283
  };
3534
3284
  }
3535
-
3536
3285
  var states = (function (actionGroupList, syncActionConfig) {
3537
3286
  var mapActionGroup = createMapActionGroup(actionGroupList);
3538
3287
  var doMapActions = createStatesMapActions(mapActionGroup, syncActionConfig);
@@ -3584,7 +3333,6 @@ function createChannelsMapActions$1(mapActionGroup, syncActionConfig) {
3584
3333
  return flatten(allActions);
3585
3334
  };
3586
3335
  }
3587
-
3588
3336
  var channels = (function (actionGroupList) {
3589
3337
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3590
3338
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3597,15 +3345,12 @@ var channels = (function (actionGroupList) {
3597
3345
 
3598
3346
  var REGEX_NUMBER = new RegExp(/^\d+$/);
3599
3347
  var REGEX_UNDERSCORE_NUMBER = new RegExp(/^_\d+$/);
3600
-
3601
3348
  var getIsChangedOperation = function getIsChangedOperation(key) {
3602
3349
  return REGEX_NUMBER.test(key);
3603
3350
  };
3604
-
3605
3351
  var getIsRemovedOperation = function getIsRemovedOperation(key) {
3606
3352
  return REGEX_UNDERSCORE_NUMBER.test(key);
3607
3353
  };
3608
-
3609
3354
  var baseActionsList$5 = [{
3610
3355
  action: 'changeKey',
3611
3356
  key: 'key'
@@ -3626,38 +3371,35 @@ function actionsMapBase$5(diff, oldObj, newObj) {
3626
3371
  shouldOmitEmptyString: config.shouldOmitEmptyString
3627
3372
  });
3628
3373
  }
3629
-
3630
3374
  function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next) {
3631
- var _createBuildArrayActi;
3632
-
3633
3375
  var addEnumActionName = attributeType === 'Enum' ? 'addEnumValue' : 'addLocalizedEnumValue';
3634
3376
  var changeEnumValueLabelActionName = attributeType === 'Enum' ? 'changeEnumValueLabel' : 'changeLocalizedEnumValueLabel';
3635
3377
  var changeEnumOrderActionName = attributeType === 'Enum' ? 'changeEnumValueOrder' : 'changeLocalizedEnumValueOrder';
3636
- var buildArrayActions = createBuildArrayActions('values', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newEnum) {
3378
+ var buildArrayActions = createBuildArrayActions('values', _defineProperty(_defineProperty({}, ADD_ACTIONS, function (newEnum) {
3637
3379
  return {
3638
3380
  fieldName: fieldName,
3639
3381
  action: addEnumActionName,
3640
3382
  value: newEnum
3641
3383
  };
3642
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldEnum, newEnum) {
3384
+ }), CHANGE_ACTIONS, function (oldEnum, newEnum) {
3643
3385
  var oldEnumInNext = next.values.find(function (nextEnum) {
3644
3386
  return nextEnum.key === oldEnum.key;
3645
- }); // These `changeActions` would impose a nested structure among
3387
+ });
3388
+
3389
+ // These `changeActions` would impose a nested structure among
3646
3390
  // the accumulated `updateActions` generated by `buildArrayActions`
3647
3391
  // In the end; we have to flatten the structure before we pass it back
3648
3392
  // to the client.
3649
-
3650
3393
  var changeActions = [];
3651
-
3652
3394
  if (oldEnumInNext) {
3653
3395
  // If the enum value is changed, we need to change the order first
3654
- var isKeyChanged = oldEnum.key !== newEnum.key; // check if the label is changed
3396
+ var isKeyChanged = oldEnum.key !== newEnum.key;
3655
3397
 
3398
+ // check if the label is changed
3656
3399
  var foundPreviousEnum = previous.values.find(function (previousEnum) {
3657
3400
  return previousEnum.key === newEnum.key;
3658
3401
  });
3659
3402
  var isLabelEqual = isEqual(foundPreviousEnum.label, newEnum.label);
3660
-
3661
3403
  if (isKeyChanged) {
3662
3404
  // these actions is then flatten in the end
3663
3405
  changeActions.push({
@@ -3666,7 +3408,6 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3666
3408
  value: newEnum
3667
3409
  });
3668
3410
  }
3669
-
3670
3411
  if (!isLabelEqual) {
3671
3412
  changeActions.push({
3672
3413
  fieldName: fieldName,
@@ -3681,12 +3422,11 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3681
3422
  value: newEnum
3682
3423
  });
3683
3424
  }
3684
-
3685
3425
  return changeActions;
3686
- }), _createBuildArrayActi));
3687
- 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
3688
3429
  // order of enumValues, we generate one updateAction instead of one at a time.
3689
-
3690
3430
  var newEnumValuesOrder = [];
3691
3431
  flatten(buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
3692
3432
  if (updateAction.action === changeEnumOrderActionName) {
@@ -3701,18 +3441,14 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
3701
3441
  keys: newEnumValuesOrder
3702
3442
  }] : []));
3703
3443
  }
3704
-
3705
3444
  function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPaths) {
3706
3445
  var actions = [];
3707
3446
  forEach(fieldDefinitionsDiff, function (diffValue, diffKey) {
3708
3447
  var extractedPairs = extractMatchingPairs(diffPaths, diffKey, previous, next);
3709
-
3710
3448
  if (getIsChangedOperation(diffKey)) {
3711
3449
  var _diffValue$type;
3712
-
3713
3450
  if (Array.isArray(diffValue)) {
3714
3451
  var deltaValue = getDeltaValue(diffValue);
3715
-
3716
3452
  if (deltaValue.name) {
3717
3453
  actions.push({
3718
3454
  action: 'addFieldDefinition',
@@ -3745,7 +3481,6 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
3745
3481
  });
3746
3482
  } else {
3747
3483
  var _deltaValue = getDeltaValue(diffValue);
3748
-
3749
3484
  if (_deltaValue === undefined && diffValue[0].name) actions.push({
3750
3485
  action: 'removeFieldDefinition',
3751
3486
  fieldName: diffValue[0].name
@@ -3753,11 +3488,12 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
3753
3488
  }
3754
3489
  }
3755
3490
  }
3756
- }); // Make sure to execute removeActions before creating new ones
3491
+ });
3492
+
3493
+ // Make sure to execute removeActions before creating new ones
3757
3494
  // in order to prevent any eventual removal of `addAction`.
3758
3495
  // List of `removeActions` can be found here
3759
3496
  // https://docs.commercetools.com/http-api-projects-types.html#change-key
3760
-
3761
3497
  var sortedActions = sortBy(actions, function (action) {
3762
3498
  return action.action !== 'removeFieldDefinition';
3763
3499
  });
@@ -3775,7 +3511,6 @@ function createTypeMapActions(mapActionGroup, syncActionConfig) {
3775
3511
  return flatten(allActions);
3776
3512
  };
3777
3513
  }
3778
-
3779
3514
  var types = (function (actionGroupList, syncActionConfig) {
3780
3515
  var mapActionGroup = createMapActionGroup(actionGroupList);
3781
3516
  var doMapActions = createTypeMapActions(mapActionGroup, syncActionConfig);
@@ -3803,6 +3538,15 @@ var baseActionsList$4 = [{
3803
3538
  }, {
3804
3539
  action: 'setShippingRateInputType',
3805
3540
  key: 'shippingRateInputType'
3541
+ }, {
3542
+ action: 'changeMyBusinessUnitStatusOnCreation',
3543
+ key: 'myBusinessUnitStatusOnCreation'
3544
+ }, {
3545
+ action: 'setMyBusinessUnitAssociateRoleOnCreation',
3546
+ key: 'myBusinessUnitAssociateRoleOnCreation'
3547
+ }, {
3548
+ action: 'changeCustomerSearchStatus',
3549
+ key: 'customerSearchStatus'
3806
3550
  }];
3807
3551
  function actionsMapBase$4(diff, oldObj, newObj) {
3808
3552
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -3824,7 +3568,6 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
3824
3568
  return flatten(allActions);
3825
3569
  };
3826
3570
  }
3827
-
3828
3571
  var projects = (function (actionGroupList) {
3829
3572
  var syncActionConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3830
3573
  var mapActionGroup = createMapActionGroup(actionGroupList);
@@ -3869,7 +3612,6 @@ function createStoresMapActions(mapActionGroup) {
3869
3612
  return flatten(allActions);
3870
3613
  };
3871
3614
  }
3872
-
3873
3615
  var stores = (function (actionGroupList) {
3874
3616
  var mapActionGroup = createMapActionGroup(actionGroupList);
3875
3617
  var doMapActions = createStoresMapActions(mapActionGroup);
@@ -3908,7 +3650,6 @@ function createProductSelectionsMapActions(mapActionGroup) {
3908
3650
  return flatten(allActions);
3909
3651
  };
3910
3652
  }
3911
-
3912
3653
  var productSelections = (function (actionGroupList) {
3913
3654
  var mapActionGroup = createMapActionGroup(actionGroupList);
3914
3655
  var doMapActions = createProductSelectionsMapActions(mapActionGroup);
@@ -3925,7 +3666,8 @@ var baseActionsList$1 = [{
3925
3666
  }, {
3926
3667
  action: 'setDiscountedPrice',
3927
3668
  key: 'discounted'
3928
- }, // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3669
+ },
3670
+ // TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
3929
3671
  {
3930
3672
  action: 'setPriceTiers',
3931
3673
  key: 'tiers'
@@ -3964,7 +3706,6 @@ function createPriceMapActions(mapActionGroup, syncActionConfig) {
3964
3706
  return combineValidityActions([].concat(_toConsumableArray(baseActions), _toConsumableArray(customActions)));
3965
3707
  };
3966
3708
  }
3967
-
3968
3709
  var prices = (function (actionGroupList, syncActionConfig) {
3969
3710
  var mapActionGroup = createMapActionGroup(actionGroupList);
3970
3711
  var doMapActions = createPriceMapActions(mapActionGroup, syncActionConfig);
@@ -3979,7 +3720,6 @@ var hasAttribute = function hasAttribute(attributes, newValue) {
3979
3720
  return attribute.key === newValue.key;
3980
3721
  });
3981
3722
  };
3982
-
3983
3723
  var baseActionsList = [{
3984
3724
  action: 'changeName',
3985
3725
  key: 'name'
@@ -4001,35 +3741,34 @@ function actionsMapBase(diff, oldObj, newObj) {
4001
3741
  });
4002
3742
  }
4003
3743
  function actionsMapAttributes(diff, oldObj, newObj) {
4004
- var _createBuildArrayActi;
4005
-
4006
- var handler = createBuildArrayActions('attributes', (_createBuildArrayActi = {}, _defineProperty(_createBuildArrayActi, ADD_ACTIONS, function (newAttribute) {
3744
+ var handler = createBuildArrayActions('attributes', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newAttribute) {
4007
3745
  return {
4008
3746
  action: 'addAttribute',
4009
3747
  attribute: newAttribute
4010
3748
  };
4011
- }), _defineProperty(_createBuildArrayActi, REMOVE_ACTIONS, function (oldAttribute) {
3749
+ }), REMOVE_ACTIONS, function (oldAttribute) {
4012
3750
  // We only add the action if the attribute is not included in the new object.
4013
3751
  return !hasAttribute(newObj.attributes, oldAttribute) ? {
4014
3752
  action: 'removeAttribute',
4015
3753
  attribute: oldAttribute
4016
3754
  } : null;
4017
- }), _defineProperty(_createBuildArrayActi, CHANGE_ACTIONS, function (oldAttribute, newAttribute) {
4018
- 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
4019
3758
  // included in the new object
4020
-
4021
3759
  if (!hasAttribute(newObj.attributes, oldAttribute)) result.push({
4022
3760
  action: 'removeAttribute',
4023
3761
  attribute: oldAttribute
4024
- }); // We only add the attribute in case that the newAttribute was not
4025
- // included in the old object
3762
+ });
4026
3763
 
3764
+ // We only add the attribute in case that the newAttribute was not
3765
+ // included in the old object
4027
3766
  if (!hasAttribute(oldObj.attributes, newAttribute)) result.push({
4028
3767
  action: 'addAttribute',
4029
3768
  attribute: newAttribute
4030
3769
  });
4031
3770
  return result;
4032
- }), _createBuildArrayActi));
3771
+ }));
4033
3772
  return handler(diff, oldObj, newObj);
4034
3773
  }
4035
3774
 
@@ -4045,7 +3784,6 @@ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
4045
3784
  return flatten(allActions);
4046
3785
  };
4047
3786
  }
4048
-
4049
3787
  var attributeGroups = (function (actionGroupList, syncActionConfig) {
4050
3788
  var mapActionGroup = createMapActionGroup(actionGroupList);
4051
3789
  var doMapActions = createAttributeGroupsMapActions(mapActionGroup, syncActionConfig);