@commercetools/sync-actions 7.0.0 → 7.1.1

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.
@@ -1,91 +1,52 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var flatten = require('lodash.flatten');
4
6
  var isEqual = require('lodash.isequal');
5
7
  var isNil = require('lodash.isnil');
8
+ var jsondiffpatch = require('jsondiffpatch');
6
9
  var forEach = require('lodash.foreach');
7
10
  var uniqWith = require('lodash.uniqwith');
8
11
  var intersection = require('lodash.intersection');
9
12
  var without = require('lodash.without');
13
+ var fastEquals = require('fast-equals');
10
14
  var sortBy = require('lodash.sortby');
11
15
 
12
- function _arrayLikeToArray(r, a) {
13
- (null == a || a > r.length) && (a = r.length);
14
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
15
- return n;
16
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
16
34
  }
35
+
36
+ var flatten__default = /*#__PURE__*/_interopDefault(flatten);
37
+ var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
38
+ var isNil__default = /*#__PURE__*/_interopDefault(isNil);
39
+ var jsondiffpatch__namespace = /*#__PURE__*/_interopNamespace(jsondiffpatch);
40
+ var forEach__default = /*#__PURE__*/_interopDefault(forEach);
41
+ var uniqWith__default = /*#__PURE__*/_interopDefault(uniqWith);
42
+ var intersection__default = /*#__PURE__*/_interopDefault(intersection);
43
+ var without__default = /*#__PURE__*/_interopDefault(without);
44
+ var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
45
+
17
46
  function _arrayWithHoles(r) {
18
47
  if (Array.isArray(r)) return r;
19
48
  }
20
- function _arrayWithoutHoles(r) {
21
- if (Array.isArray(r)) return _arrayLikeToArray(r);
22
- }
23
- function _assertThisInitialized(e) {
24
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
25
- return e;
26
- }
27
- function _callSuper(t, o, e) {
28
- return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
29
- }
30
- function _classCallCheck(a, n) {
31
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
32
- }
33
- function _defineProperties(e, r) {
34
- for (var t = 0; t < r.length; t++) {
35
- var o = r[t];
36
- o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
37
- }
38
- }
39
- function _createClass(e, r, t) {
40
- return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
41
- writable: false
42
- }), e;
43
- }
44
- function _defineProperty(e, r, t) {
45
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
46
- value: t,
47
- enumerable: true,
48
- configurable: true,
49
- writable: true
50
- }) : e[r] = t, e;
51
- }
52
- function _get() {
53
- return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
54
- var p = _superPropBase(e, t);
55
- if (p) {
56
- var n = Object.getOwnPropertyDescriptor(p, t);
57
- return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
58
- }
59
- }, _get.apply(null, arguments);
60
- }
61
- function _getPrototypeOf(t) {
62
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
63
- return t.__proto__ || Object.getPrototypeOf(t);
64
- }, _getPrototypeOf(t);
65
- }
66
- function _inherits(t, e) {
67
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
68
- t.prototype = Object.create(e && e.prototype, {
69
- constructor: {
70
- value: t,
71
- writable: true,
72
- configurable: true
73
- }
74
- }), Object.defineProperty(t, "prototype", {
75
- writable: false
76
- }), e && _setPrototypeOf(t, e);
77
- }
78
- function _isNativeReflectConstruct() {
79
- try {
80
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
81
- } catch (t) {}
82
- return (_isNativeReflectConstruct = function () {
83
- return !!t;
84
- })();
85
- }
86
- function _iterableToArray(r) {
87
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
88
- }
49
+
89
50
  function _iterableToArrayLimit(r, l) {
90
51
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
91
52
  if (null != t) {
@@ -94,15 +55,15 @@ function _iterableToArrayLimit(r, l) {
94
55
  i,
95
56
  u,
96
57
  a = [],
97
- f = true,
98
- o = false;
58
+ f = !0,
59
+ o = !1;
99
60
  try {
100
61
  if (i = (t = t.call(r)).next, 0 === l) {
101
62
  if (Object(t) !== t) return;
102
63
  f = !1;
103
64
  } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
104
65
  } catch (r) {
105
- o = true, n = r;
66
+ o = !0, n = r;
106
67
  } finally {
107
68
  try {
108
69
  if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
@@ -113,12 +74,54 @@ function _iterableToArrayLimit(r, l) {
113
74
  return a;
114
75
  }
115
76
  }
77
+
78
+ function _arrayLikeToArray(r, a) {
79
+ (null == a || a > r.length) && (a = r.length);
80
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
81
+ return n;
82
+ }
83
+
84
+ function _unsupportedIterableToArray(r, a) {
85
+ if (r) {
86
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
87
+ var t = {}.toString.call(r).slice(8, -1);
88
+ 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;
89
+ }
90
+ }
91
+
116
92
  function _nonIterableRest() {
117
93
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
118
94
  }
119
- function _nonIterableSpread() {
120
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95
+
96
+ function _slicedToArray(r, e) {
97
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
98
+ }
99
+
100
+ function _toPrimitive(t, r) {
101
+ if ("object" != typeof t || !t) return t;
102
+ var e = t[Symbol.toPrimitive];
103
+ if (void 0 !== e) {
104
+ var i = e.call(t, r || "default");
105
+ if ("object" != typeof i) return i;
106
+ throw new TypeError("@@toPrimitive must return a primitive value.");
107
+ }
108
+ return ("string" === r ? String : Number)(t);
109
+ }
110
+
111
+ function _toPropertyKey(t) {
112
+ var i = _toPrimitive(t, "string");
113
+ return "symbol" == typeof i ? i : i + "";
114
+ }
115
+
116
+ function _defineProperty(e, r, t) {
117
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
118
+ value: t,
119
+ enumerable: !0,
120
+ configurable: !0,
121
+ writable: !0
122
+ }) : e[r] = t, e;
121
123
  }
124
+
122
125
  function ownKeys(e, r) {
123
126
  var t = Object.keys(e);
124
127
  if (Object.getOwnPropertySymbols) {
@@ -132,7 +135,7 @@ function ownKeys(e, r) {
132
135
  function _objectSpread2(e) {
133
136
  for (var r = 1; r < arguments.length; r++) {
134
137
  var t = null != arguments[r] ? arguments[r] : {};
135
- r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
138
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
136
139
  _defineProperty(e, r, t[r]);
137
140
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
138
141
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -140,17 +143,7 @@ function _objectSpread2(e) {
140
143
  }
141
144
  return e;
142
145
  }
143
- function _objectWithoutProperties(e, t) {
144
- if (null == e) return {};
145
- var o,
146
- r,
147
- i = _objectWithoutPropertiesLoose(e, t);
148
- if (Object.getOwnPropertySymbols) {
149
- var n = Object.getOwnPropertySymbols(e);
150
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
151
- }
152
- return i;
153
- }
146
+
154
147
  function _objectWithoutPropertiesLoose(r, e) {
155
148
  if (null == r) return {};
156
149
  var t = {};
@@ -160,61 +153,17 @@ function _objectWithoutPropertiesLoose(r, e) {
160
153
  }
161
154
  return t;
162
155
  }
163
- function _possibleConstructorReturn(t, e) {
164
- if (e && ("object" == typeof e || "function" == typeof e)) return e;
165
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
166
- return _assertThisInitialized(t);
167
- }
168
- function _setPrototypeOf(t, e) {
169
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
170
- return t.__proto__ = e, t;
171
- }, _setPrototypeOf(t, e);
172
- }
173
- function _slicedToArray(r, e) {
174
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
175
- }
176
- function _superPropBase(t, o) {
177
- for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
178
- return t;
179
- }
180
- function _superPropGet(t, o, e, r) {
181
- var p = _get(_getPrototypeOf(t.prototype ), o, e);
182
- return 2 & r && "function" == typeof p ? function (t) {
183
- return p.apply(e, t);
184
- } : p;
185
- }
186
- function _toConsumableArray(r) {
187
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
188
- }
189
- function _toPrimitive(t, r) {
190
- if ("object" != typeof t || !t) return t;
191
- var e = t[Symbol.toPrimitive];
192
- if (void 0 !== e) {
193
- var i = e.call(t, r);
194
- if ("object" != typeof i) return i;
195
- throw new TypeError("@@toPrimitive must return a primitive value.");
196
- }
197
- return (String )(t);
198
- }
199
- function _toPropertyKey(t) {
200
- var i = _toPrimitive(t, "string");
201
- return "symbol" == typeof i ? i : i + "";
202
- }
203
- function _typeof(o) {
204
- "@babel/helpers - typeof";
205
156
 
206
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
207
- return typeof o;
208
- } : function (o) {
209
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
210
- }, _typeof(o);
211
- }
212
- function _unsupportedIterableToArray(r, a) {
213
- if (r) {
214
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
215
- var t = {}.toString.call(r).slice(8, -1);
216
- 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;
157
+ function _objectWithoutProperties(e, t) {
158
+ if (null == e) return {};
159
+ var o,
160
+ r,
161
+ i = _objectWithoutPropertiesLoose(e, t);
162
+ if (Object.getOwnPropertySymbols) {
163
+ var n = Object.getOwnPropertySymbols(e);
164
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
217
165
  }
166
+ return i;
218
167
  }
219
168
 
220
169
  var _excluded$2 = ["prices"];
@@ -236,7 +185,7 @@ var createPriceComparator = function createPriceComparator(price) {
236
185
  function arePricesStructurallyEqual(oldPrice, newPrice) {
237
186
  var oldPriceComparison = createPriceComparator(oldPrice);
238
187
  var newPriceComparison = createPriceComparator(newPrice);
239
- return isEqual(newPriceComparison, oldPriceComparison);
188
+ return isEqual__default["default"](newPriceComparison, oldPriceComparison);
240
189
  }
241
190
  function extractPriceFromPreviousVariant(newPrice, previousVariant) {
242
191
  if (!previousVariant) return null;
@@ -249,1274 +198,96 @@ function injectMissingPriceIds(nextVariants, previousVariants) {
249
198
  return nextVariants.map(function (newVariant) {
250
199
  var prices = newVariant.prices,
251
200
  restOfVariant = _objectWithoutProperties(newVariant, _excluded$2);
252
- if (!prices) return restOfVariant;
253
- var oldVariant = previousVariants.find(function (previousVariant) {
254
- return !isNil(previousVariant.id) && previousVariant.id === newVariant.id || !isNil(previousVariant.key) && previousVariant.key === newVariant.key || !isNil(previousVariant.sku) && previousVariant.sku === newVariant.sku;
255
- });
256
- return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
257
- prices: prices.map(function (price) {
258
- var newPrice = _objectSpread2({}, price);
259
- var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
260
- if (oldPrice) {
261
- // copy ID if not provided
262
- if (!newPrice.id) newPrice.id = oldPrice.id;
263
- if (isNil(newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
264
- if (isNil(newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
265
- }
266
- return newPrice;
267
- })
268
- });
269
- });
270
- }
271
- function createBuildActions(differ, doMapActions, onBeforeDiff) {
272
- var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
273
- return function buildActions(now, before) {
274
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
275
- if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
276
- var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
277
- _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
278
- processedBefore = _applyOnBeforeDiff2[0],
279
- processedNow = _applyOnBeforeDiff2[1];
280
- if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
281
- var diffed = differ(processedBefore, processedNow);
282
- if (!buildActionsConfig.withHints && !diffed) return [];
283
- return doMapActions(diffed, processedNow, processedBefore, options);
284
- };
285
- }
286
-
287
- // Array of action groups which need to be allowed or ignored.
288
- // Example:
289
- // [
290
- // { type: 'base', group: 'ignore' },
291
- // { type: 'prices', group: 'allow' },
292
- // { type: 'variants', group: 'ignore' },
293
- // ]
294
- function createMapActionGroup() {
295
- var actionGroups = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
296
- return function mapActionGroup(type, fn) {
297
- if (!Object.keys(actionGroups).length) return fn();
298
- var found = actionGroups.find(function (c) {
299
- return c.type === type;
300
- });
301
- if (!found) return [];
302
-
303
- // Keep `black` for backwards compatibility.
304
- if (found.group === 'ignore' || found.group === 'black') return [];
305
- // Keep `white` for backwards compatibility.
306
- if (found.group === 'allow' || found.group === 'white') return fn();
307
- throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
308
- };
309
- }
310
-
311
- var Processor = /*#__PURE__*/function () {
312
- function Processor(options) {
313
- _classCallCheck(this, Processor);
314
- this.selfOptions = options || {};
315
- this.pipes = {};
316
- }
317
- return _createClass(Processor, [{
318
- key: "options",
319
- value: function options(_options) {
320
- if (_options) {
321
- this.selfOptions = _options;
322
- }
323
- return this.selfOptions;
324
- }
325
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
326
- }, {
327
- key: "pipe",
328
- value: function pipe(name, pipeArg) {
329
- var pipe = pipeArg;
330
- if (typeof name === 'string') {
331
- if (typeof pipe === 'undefined') {
332
- return this.pipes[name];
333
- } else {
334
- this.pipes[name] = pipe;
335
- }
336
- }
337
- if (name && name.name) {
338
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
339
- pipe = name;
340
- if (pipe.processor === this) {
341
- return pipe;
342
- }
343
- this.pipes[pipe.name] = pipe;
344
- }
345
- pipe.processor = this;
346
- return pipe;
347
- }
348
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
349
- }, {
350
- key: "process",
351
- value: function process(input, pipe) {
352
- var context = input;
353
- context.options = this.options();
354
- var nextPipe = pipe || input.pipe || 'default';
355
- var lastPipe;
356
- while (nextPipe) {
357
- if (typeof context.nextAfterChildren !== 'undefined') {
358
- // children processed and coming back to parent
359
- context.next = context.nextAfterChildren;
360
- context.nextAfterChildren = null;
361
- }
362
- if (typeof nextPipe === 'string') {
363
- nextPipe = this.pipe(nextPipe);
364
- }
365
- nextPipe.process(context);
366
- lastPipe = nextPipe;
367
- nextPipe = null;
368
- if (context) {
369
- if (context.next) {
370
- context = context.next;
371
- nextPipe = context.pipe || lastPipe;
372
- }
373
- }
374
- }
375
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
376
- return context.hasResult ? context.result : undefined;
377
- }
378
- }]);
379
- }();
380
-
381
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
382
- var Pipe = /*#__PURE__*/function () {
383
- function Pipe(name) {
384
- _classCallCheck(this, Pipe);
385
- this.name = name;
386
- this.filters = [];
387
- }
388
- return _createClass(Pipe, [{
389
- key: "process",
390
- value: function process(input) {
391
- if (!this.processor) {
392
- throw new Error('add this pipe to a processor before using it');
393
- }
394
- var debug = this.debug;
395
- var length = this.filters.length;
396
- var context = input;
397
- for (var index = 0; index < length; index++) {
398
- var filter = this.filters[index];
399
- if (debug) {
400
- this.log("filter: ".concat(filter.filterName));
401
- }
402
- filter(context);
403
- if (_typeof(context) === 'object' && context.exiting) {
404
- context.exiting = false;
405
- break;
406
- }
407
- }
408
- if (!context.next && this.resultCheck) {
409
- this.resultCheck(context);
410
- }
411
- }
412
- }, {
413
- key: "log",
414
- value: function log(msg) {
415
- console.log("[jsondiffpatch] ".concat(this.name, " pipe, ").concat(msg));
416
- }
417
- }, {
418
- key: "append",
419
- value: function append() {
420
- var _this$filters;
421
- (_this$filters = this.filters).push.apply(_this$filters, arguments);
422
- return this;
423
- }
424
- }, {
425
- key: "prepend",
426
- value: function prepend() {
427
- var _this$filters2;
428
- (_this$filters2 = this.filters).unshift.apply(_this$filters2, arguments);
429
- return this;
430
- }
431
- }, {
432
- key: "indexOf",
433
- value: function indexOf(filterName) {
434
- if (!filterName) {
435
- throw new Error('a filter name is required');
436
- }
437
- for (var index = 0; index < this.filters.length; index++) {
438
- var filter = this.filters[index];
439
- if (filter.filterName === filterName) {
440
- return index;
441
- }
442
- }
443
- throw new Error("filter not found: ".concat(filterName));
444
- }
445
- }, {
446
- key: "list",
447
- value: function list() {
448
- return this.filters.map(function (f) {
449
- return f.filterName;
450
- });
451
- }
452
- }, {
453
- key: "after",
454
- value: function after(filterName) {
455
- var _this$filters3;
456
- var index = this.indexOf(filterName);
457
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
458
- params[_key - 1] = arguments[_key];
459
- }
460
- (_this$filters3 = this.filters).splice.apply(_this$filters3, [index + 1, 0].concat(params));
461
- return this;
462
- }
463
- }, {
464
- key: "before",
465
- value: function before(filterName) {
466
- var _this$filters4;
467
- var index = this.indexOf(filterName);
468
- for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
469
- params[_key2 - 1] = arguments[_key2];
470
- }
471
- (_this$filters4 = this.filters).splice.apply(_this$filters4, [index, 0].concat(params));
472
- return this;
473
- }
474
- }, {
475
- key: "replace",
476
- value: function replace(filterName) {
477
- var _this$filters5;
478
- var index = this.indexOf(filterName);
479
- for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
480
- params[_key3 - 1] = arguments[_key3];
481
- }
482
- (_this$filters5 = this.filters).splice.apply(_this$filters5, [index, 1].concat(params));
483
- return this;
484
- }
485
- }, {
486
- key: "remove",
487
- value: function remove(filterName) {
488
- var index = this.indexOf(filterName);
489
- this.filters.splice(index, 1);
490
- return this;
491
- }
492
- }, {
493
- key: "clear",
494
- value: function clear() {
495
- this.filters.length = 0;
496
- return this;
497
- }
498
- }, {
499
- key: "shouldHaveResult",
500
- value: function shouldHaveResult(should) {
501
- var _this = this;
502
- if (should === false) {
503
- this.resultCheck = null;
504
- return;
505
- }
506
- if (this.resultCheck) {
507
- return;
508
- }
509
- this.resultCheck = function (context) {
510
- if (!context.hasResult) {
511
- console.log(context);
512
- var error = new Error("".concat(_this.name, " failed"));
513
- error.noResult = true;
514
- throw error;
515
- }
516
- };
517
- return this;
518
- }
519
- }]);
520
- }();
521
-
522
- var Context = /*#__PURE__*/function () {
523
- function Context() {
524
- _classCallCheck(this, Context);
525
- }
526
- return _createClass(Context, [{
527
- key: "setResult",
528
- value: function setResult(result) {
529
- this.result = result;
530
- this.hasResult = true;
531
- return this;
532
- }
533
- }, {
534
- key: "exit",
535
- value: function exit() {
536
- this.exiting = true;
537
- return this;
538
- }
539
- }, {
540
- key: "push",
541
- value: function push(child, name) {
542
- child.parent = this;
543
- if (typeof name !== 'undefined') {
544
- child.childName = name;
545
- }
546
- child.root = this.root || this;
547
- child.options = child.options || this.options;
548
- if (!this.children) {
549
- this.children = [child];
550
- this.nextAfterChildren = this.next || null;
551
- this.next = child;
552
- } else {
553
- this.children[this.children.length - 1].next = child;
554
- this.children.push(child);
555
- }
556
- child.next = this;
557
- return this;
558
- }
559
- }]);
560
- }();
561
-
562
- function cloneRegExp(re) {
563
- var regexMatch = /^\/(.*)\/([gimyu]*)$/.exec(re.toString());
564
- return new RegExp(regexMatch[1], regexMatch[2]);
565
- }
566
- function clone$1(arg) {
567
- if (_typeof(arg) !== 'object') {
568
- return arg;
569
- }
570
- if (arg === null) {
571
- return null;
572
- }
573
- if (Array.isArray(arg)) {
574
- return arg.map(clone$1);
575
- }
576
- if (arg instanceof Date) {
577
- return new Date(arg.getTime());
578
- }
579
- if (arg instanceof RegExp) {
580
- return cloneRegExp(arg);
581
- }
582
- var cloned = {};
583
- for (var name in arg) {
584
- if (Object.prototype.hasOwnProperty.call(arg, name)) {
585
- cloned[name] = clone$1(arg[name]);
586
- }
587
- }
588
- return cloned;
589
- }
590
-
591
- var DiffContext = /*#__PURE__*/function (_Context) {
592
- function DiffContext(left, right) {
593
- var _this;
594
- _classCallCheck(this, DiffContext);
595
- _this = _callSuper(this, DiffContext);
596
- _this.left = left;
597
- _this.right = right;
598
- _this.pipe = 'diff';
599
- return _this;
600
- }
601
- _inherits(DiffContext, _Context);
602
- return _createClass(DiffContext, [{
603
- key: "setResult",
604
- value: function setResult(result) {
605
- if (this.options.cloneDiffValues && _typeof(result) === 'object') {
606
- var clone = typeof this.options.cloneDiffValues === 'function' ? this.options.cloneDiffValues : clone$1;
607
- if (_typeof(result[0]) === 'object') {
608
- result[0] = clone(result[0]);
609
- }
610
- if (_typeof(result[1]) === 'object') {
611
- result[1] = clone(result[1]);
612
- }
613
- }
614
- return _superPropGet(DiffContext, "setResult", this, 3)([result]);
615
- }
616
- }]);
617
- }(Context);
618
-
619
- var PatchContext = /*#__PURE__*/function (_Context) {
620
- function PatchContext(left, delta) {
621
- var _this;
622
- _classCallCheck(this, PatchContext);
623
- _this = _callSuper(this, PatchContext);
624
- _this.left = left;
625
- _this.delta = delta;
626
- _this.pipe = 'patch';
627
- return _this;
628
- }
629
- _inherits(PatchContext, _Context);
630
- return _createClass(PatchContext);
631
- }(Context);
632
-
633
- var ReverseContext = /*#__PURE__*/function (_Context) {
634
- function ReverseContext(delta) {
635
- var _this;
636
- _classCallCheck(this, ReverseContext);
637
- _this = _callSuper(this, ReverseContext);
638
- _this.delta = delta;
639
- _this.pipe = 'reverse';
640
- return _this;
641
- }
642
- _inherits(ReverseContext, _Context);
643
- return _createClass(ReverseContext);
644
- }(Context);
645
-
646
- var diffFilter$3 = function trivialMatchesDiffFilter(context) {
647
- if (context.left === context.right) {
648
- context.setResult(undefined).exit();
649
- return;
650
- }
651
- if (typeof context.left === 'undefined') {
652
- if (typeof context.right === 'function') {
653
- throw new Error('functions are not supported');
654
- }
655
- context.setResult([context.right]).exit();
656
- return;
657
- }
658
- if (typeof context.right === 'undefined') {
659
- context.setResult([context.left, 0, 0]).exit();
660
- return;
661
- }
662
- if (typeof context.left === 'function' || typeof context.right === 'function') {
663
- throw new Error('functions are not supported');
664
- }
665
- context.leftType = context.left === null ? 'null' : _typeof(context.left);
666
- context.rightType = context.right === null ? 'null' : _typeof(context.right);
667
- if (context.leftType !== context.rightType) {
668
- context.setResult([context.left, context.right]).exit();
669
- return;
670
- }
671
- if (context.leftType === 'boolean' || context.leftType === 'number') {
672
- context.setResult([context.left, context.right]).exit();
673
- return;
674
- }
675
- if (context.leftType === 'object') {
676
- context.leftIsArray = Array.isArray(context.left);
677
- }
678
- if (context.rightType === 'object') {
679
- context.rightIsArray = Array.isArray(context.right);
680
- }
681
- if (context.leftIsArray !== context.rightIsArray) {
682
- context.setResult([context.left, context.right]).exit();
683
- return;
684
- }
685
- if (context.left instanceof RegExp) {
686
- if (context.right instanceof RegExp) {
687
- context.setResult([context.left.toString(), context.right.toString()]).exit();
688
- } else {
689
- context.setResult([context.left, context.right]).exit();
690
- }
691
- }
692
- };
693
- diffFilter$3.filterName = 'trivial';
694
- var patchFilter$3 = function trivialMatchesPatchFilter(context) {
695
- if (typeof context.delta === 'undefined') {
696
- context.setResult(context.left).exit();
697
- return;
698
- }
699
- context.nested = !Array.isArray(context.delta);
700
- if (context.nested) {
701
- return;
702
- }
703
- var nonNestedDelta = context.delta;
704
- if (nonNestedDelta.length === 1) {
705
- context.setResult(nonNestedDelta[0]).exit();
706
- return;
707
- }
708
- if (nonNestedDelta.length === 2) {
709
- if (context.left instanceof RegExp) {
710
- var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
711
- if (regexArgs) {
712
- context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
713
- return;
714
- }
715
- }
716
- context.setResult(nonNestedDelta[1]).exit();
717
- return;
718
- }
719
- if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
720
- context.setResult(undefined).exit();
721
- }
722
- };
723
- patchFilter$3.filterName = 'trivial';
724
- var reverseFilter$3 = function trivialReferseFilter(context) {
725
- if (typeof context.delta === 'undefined') {
726
- context.setResult(context.delta).exit();
727
- return;
728
- }
729
- context.nested = !Array.isArray(context.delta);
730
- if (context.nested) {
731
- return;
732
- }
733
- var nonNestedDelta = context.delta;
734
- if (nonNestedDelta.length === 1) {
735
- context.setResult([nonNestedDelta[0], 0, 0]).exit();
736
- return;
737
- }
738
- if (nonNestedDelta.length === 2) {
739
- context.setResult([nonNestedDelta[1], nonNestedDelta[0]]).exit();
740
- return;
741
- }
742
- if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
743
- context.setResult([nonNestedDelta[0]]).exit();
744
- }
745
- };
746
- reverseFilter$3.filterName = 'trivial';
747
-
748
- var collectChildrenDiffFilter = function collectChildrenDiffFilter(context) {
749
- if (!context || !context.children) {
750
- return;
751
- }
752
- var length = context.children.length;
753
- var child;
754
- var result = context.result;
755
- for (var index = 0; index < length; index++) {
756
- child = context.children[index];
757
- if (typeof child.result === 'undefined') {
758
- continue;
759
- }
760
- result = result || {};
761
- result[child.childName] = child.result;
762
- }
763
- if (result && context.leftIsArray) {
764
- result._t = 'a';
765
- }
766
- context.setResult(result).exit();
767
- };
768
- collectChildrenDiffFilter.filterName = 'collectChildren';
769
- var objectsDiffFilter = function objectsDiffFilter(context) {
770
- if (context.leftIsArray || context.leftType !== 'object') {
771
- return;
772
- }
773
- var left = context.left;
774
- var right = context.right;
775
- var name;
776
- var child;
777
- var propertyFilter = context.options.propertyFilter;
778
- for (name in left) {
779
- if (!Object.prototype.hasOwnProperty.call(left, name)) {
780
- continue;
781
- }
782
- if (propertyFilter && !propertyFilter(name, context)) {
783
- continue;
784
- }
785
- child = new DiffContext(left[name], right[name]);
786
- context.push(child, name);
787
- }
788
- for (name in right) {
789
- if (!Object.prototype.hasOwnProperty.call(right, name)) {
790
- continue;
791
- }
792
- if (propertyFilter && !propertyFilter(name, context)) {
793
- continue;
794
- }
795
- if (typeof left[name] === 'undefined') {
796
- child = new DiffContext(undefined, right[name]);
797
- context.push(child, name);
798
- }
799
- }
800
- if (!context.children || context.children.length === 0) {
801
- context.setResult(undefined).exit();
802
- return;
803
- }
804
- context.exit();
805
- };
806
- objectsDiffFilter.filterName = 'objects';
807
- var patchFilter$2 = function nestedPatchFilter(context) {
808
- if (!context.nested) {
809
- return;
810
- }
811
- var nestedDelta = context.delta;
812
- if (nestedDelta._t) {
813
- return;
814
- }
815
- var objectDelta = nestedDelta;
816
- var name;
817
- var child;
818
- for (name in objectDelta) {
819
- child = new PatchContext(context.left[name], objectDelta[name]);
820
- context.push(child, name);
821
- }
822
- context.exit();
823
- };
824
- patchFilter$2.filterName = 'objects';
825
- var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter(context) {
826
- if (!context || !context.children) {
827
- return;
828
- }
829
- var deltaWithChildren = context.delta;
830
- if (deltaWithChildren._t) {
831
- return;
832
- }
833
- var object = context.left;
834
- var length = context.children.length;
835
- var child;
836
- for (var index = 0; index < length; index++) {
837
- child = context.children[index];
838
- var property = child.childName;
839
- if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === undefined) {
840
- delete object[property];
841
- } else if (object[property] !== child.result) {
842
- object[property] = child.result;
843
- }
844
- }
845
- context.setResult(object).exit();
846
- };
847
- collectChildrenPatchFilter$1.filterName = 'collectChildren';
848
- var reverseFilter$2 = function nestedReverseFilter(context) {
849
- if (!context.nested) {
850
- return;
851
- }
852
- var nestedDelta = context.delta;
853
- if (nestedDelta._t) {
854
- return;
855
- }
856
- var objectDelta = context.delta;
857
- var name;
858
- var child;
859
- for (name in objectDelta) {
860
- child = new ReverseContext(objectDelta[name]);
861
- context.push(child, name);
862
- }
863
- context.exit();
864
- };
865
- reverseFilter$2.filterName = 'objects';
866
- var collectChildrenReverseFilter$1 = function collectChildrenReverseFilter(context) {
867
- if (!context || !context.children) {
868
- return;
869
- }
870
- var deltaWithChildren = context.delta;
871
- if (deltaWithChildren._t) {
872
- return;
873
- }
874
- var length = context.children.length;
875
- var child;
876
- var delta = {};
877
- for (var index = 0; index < length; index++) {
878
- child = context.children[index];
879
- var property = child.childName;
880
- if (delta[property] !== child.result) {
881
- delta[property] = child.result;
882
- }
883
- }
884
- context.setResult(delta).exit();
885
- };
886
- collectChildrenReverseFilter$1.filterName = 'collectChildren';
887
-
888
- /*
889
-
890
- LCS implementation that supports arrays or strings
891
-
892
- reference: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
893
-
894
- */
895
- var defaultMatch = function defaultMatch(array1, array2, index1, index2) {
896
- return array1[index1] === array2[index2];
897
- };
898
- var lengthMatrix = function lengthMatrix(array1, array2, match, context) {
899
- var len1 = array1.length;
900
- var len2 = array2.length;
901
- var x, y;
902
- // initialize empty matrix of len1+1 x len2+1
903
- var matrix = new Array(len1 + 1);
904
- for (x = 0; x < len1 + 1; x++) {
905
- matrix[x] = new Array(len2 + 1);
906
- for (y = 0; y < len2 + 1; y++) {
907
- matrix[x][y] = 0;
908
- }
909
- }
910
- matrix.match = match;
911
- // save sequence lengths for each coordinate
912
- for (x = 1; x < len1 + 1; x++) {
913
- for (y = 1; y < len2 + 1; y++) {
914
- if (match(array1, array2, x - 1, y - 1, context)) {
915
- matrix[x][y] = matrix[x - 1][y - 1] + 1;
916
- } else {
917
- matrix[x][y] = Math.max(matrix[x - 1][y], matrix[x][y - 1]);
918
- }
919
- }
920
- }
921
- return matrix;
922
- };
923
- var backtrack = function backtrack(matrix, array1, array2, context) {
924
- var index1 = array1.length;
925
- var index2 = array2.length;
926
- var subsequence = {
927
- sequence: [],
928
- indices1: [],
929
- indices2: []
930
- };
931
- while (index1 !== 0 && index2 !== 0) {
932
- var sameLetter = matrix.match(array1, array2, index1 - 1, index2 - 1, context);
933
- if (sameLetter) {
934
- subsequence.sequence.unshift(array1[index1 - 1]);
935
- subsequence.indices1.unshift(index1 - 1);
936
- subsequence.indices2.unshift(index2 - 1);
937
- --index1;
938
- --index2;
939
- } else {
940
- var valueAtMatrixAbove = matrix[index1][index2 - 1];
941
- var valueAtMatrixLeft = matrix[index1 - 1][index2];
942
- if (valueAtMatrixAbove > valueAtMatrixLeft) {
943
- --index2;
944
- } else {
945
- --index1;
946
- }
947
- }
948
- }
949
- return subsequence;
950
- };
951
- var get = function get(array1, array2, match, context) {
952
- var innerContext = context || {};
953
- var matrix = lengthMatrix(array1, array2, match || defaultMatch, innerContext);
954
- return backtrack(matrix, array1, array2, innerContext);
955
- };
956
- var lcs = {
957
- get: get
958
- };
959
-
960
- var ARRAY_MOVE = 3;
961
- function arraysHaveMatchByRef(array1, array2, len1, len2) {
962
- for (var index1 = 0; index1 < len1; index1++) {
963
- var val1 = array1[index1];
964
- for (var index2 = 0; index2 < len2; index2++) {
965
- var val2 = array2[index2];
966
- if (index1 !== index2 && val1 === val2) {
967
- return true;
968
- }
969
- }
970
- }
971
- }
972
- function matchItems(array1, array2, index1, index2, context) {
973
- var value1 = array1[index1];
974
- var value2 = array2[index2];
975
- if (value1 === value2) {
976
- return true;
977
- }
978
- if (_typeof(value1) !== 'object' || _typeof(value2) !== 'object') {
979
- return false;
980
- }
981
- var objectHash = context.objectHash;
982
- if (!objectHash) {
983
- // no way to match objects was provided, try match by position
984
- return context.matchByPosition && index1 === index2;
985
- }
986
- context.hashCache1 = context.hashCache1 || [];
987
- var hash1 = context.hashCache1[index1];
988
- if (typeof hash1 === 'undefined') {
989
- context.hashCache1[index1] = hash1 = objectHash(value1, index1);
990
- }
991
- if (typeof hash1 === 'undefined') {
992
- return false;
993
- }
994
- context.hashCache2 = context.hashCache2 || [];
995
- var hash2 = context.hashCache2[index2];
996
- if (typeof hash2 === 'undefined') {
997
- context.hashCache2[index2] = hash2 = objectHash(value2, index2);
998
- }
999
- if (typeof hash2 === 'undefined') {
1000
- return false;
1001
- }
1002
- return hash1 === hash2;
1003
- }
1004
- var diffFilter$2 = function arraysDiffFilter(context) {
1005
- if (!context.leftIsArray) {
1006
- return;
1007
- }
1008
- var matchContext = {
1009
- objectHash: context.options && context.options.objectHash,
1010
- matchByPosition: context.options && context.options.matchByPosition
1011
- };
1012
- var commonHead = 0;
1013
- var commonTail = 0;
1014
- var index;
1015
- var index1;
1016
- var index2;
1017
- var array1 = context.left;
1018
- var array2 = context.right;
1019
- var len1 = array1.length;
1020
- var len2 = array2.length;
1021
- var child;
1022
- if (len1 > 0 && len2 > 0 && !matchContext.objectHash && typeof matchContext.matchByPosition !== 'boolean') {
1023
- matchContext.matchByPosition = !arraysHaveMatchByRef(array1, array2, len1, len2);
1024
- }
1025
- // separate common head
1026
- while (commonHead < len1 && commonHead < len2 && matchItems(array1, array2, commonHead, commonHead, matchContext)) {
1027
- index = commonHead;
1028
- child = new DiffContext(array1[index], array2[index]);
1029
- context.push(child, index);
1030
- commonHead++;
1031
- }
1032
- // separate common tail
1033
- while (commonTail + commonHead < len1 && commonTail + commonHead < len2 && matchItems(array1, array2, len1 - 1 - commonTail, len2 - 1 - commonTail, matchContext)) {
1034
- index1 = len1 - 1 - commonTail;
1035
- index2 = len2 - 1 - commonTail;
1036
- child = new DiffContext(array1[index1], array2[index2]);
1037
- context.push(child, index2);
1038
- commonTail++;
1039
- }
1040
- var result;
1041
- if (commonHead + commonTail === len1) {
1042
- if (len1 === len2) {
1043
- // arrays are identical
1044
- context.setResult(undefined).exit();
1045
- return;
1046
- }
1047
- // trivial case, a block (1 or more consecutive items) was added
1048
- result = result || {
1049
- _t: 'a'
1050
- };
1051
- for (index = commonHead; index < len2 - commonTail; index++) {
1052
- result[index] = [array2[index]];
1053
- }
1054
- context.setResult(result).exit();
1055
- return;
1056
- }
1057
- if (commonHead + commonTail === len2) {
1058
- // trivial case, a block (1 or more consecutive items) was removed
1059
- result = result || {
1060
- _t: 'a'
1061
- };
1062
- for (index = commonHead; index < len1 - commonTail; index++) {
1063
- result["_".concat(index)] = [array1[index], 0, 0];
1064
- }
1065
- context.setResult(result).exit();
1066
- return;
1067
- }
1068
- // reset hash cache
1069
- delete matchContext.hashCache1;
1070
- delete matchContext.hashCache2;
1071
- // diff is not trivial, find the LCS (Longest Common Subsequence)
1072
- var trimmed1 = array1.slice(commonHead, len1 - commonTail);
1073
- var trimmed2 = array2.slice(commonHead, len2 - commonTail);
1074
- var seq = lcs.get(trimmed1, trimmed2, matchItems, matchContext);
1075
- var removedItems = [];
1076
- result = result || {
1077
- _t: 'a'
1078
- };
1079
- for (index = commonHead; index < len1 - commonTail; index++) {
1080
- if (seq.indices1.indexOf(index - commonHead) < 0) {
1081
- // removed
1082
- result["_".concat(index)] = [array1[index], 0, 0];
1083
- removedItems.push(index);
1084
- }
1085
- }
1086
- var detectMove = true;
1087
- if (context.options && context.options.arrays && context.options.arrays.detectMove === false) {
1088
- detectMove = false;
1089
- }
1090
- var includeValueOnMove = false;
1091
- if (context.options && context.options.arrays && context.options.arrays.includeValueOnMove) {
1092
- includeValueOnMove = true;
1093
- }
1094
- var removedItemsLength = removedItems.length;
1095
- for (index = commonHead; index < len2 - commonTail; index++) {
1096
- var indexOnArray2 = seq.indices2.indexOf(index - commonHead);
1097
- if (indexOnArray2 < 0) {
1098
- // added, try to match with a removed item and register as position move
1099
- var isMove = false;
1100
- if (detectMove && removedItemsLength > 0) {
1101
- for (var removeItemIndex1 = 0; removeItemIndex1 < removedItemsLength; removeItemIndex1++) {
1102
- index1 = removedItems[removeItemIndex1];
1103
- if (matchItems(trimmed1, trimmed2, index1 - commonHead, index - commonHead, matchContext)) {
1104
- // store position move as: [originalValue, newPosition, ARRAY_MOVE]
1105
- result["_".concat(index1)].splice(1, 2, index, ARRAY_MOVE);
1106
- if (!includeValueOnMove) {
1107
- // don't include moved value on diff, to save bytes
1108
- result["_".concat(index1)][0] = '';
1109
- }
1110
- index2 = index;
1111
- child = new DiffContext(array1[index1], array2[index2]);
1112
- context.push(child, index2);
1113
- removedItems.splice(removeItemIndex1, 1);
1114
- isMove = true;
1115
- break;
1116
- }
1117
- }
1118
- }
1119
- if (!isMove) {
1120
- // added
1121
- result[index] = [array2[index]];
1122
- }
1123
- } else {
1124
- // match, do inner diff
1125
- index1 = seq.indices1[indexOnArray2] + commonHead;
1126
- index2 = seq.indices2[indexOnArray2] + commonHead;
1127
- child = new DiffContext(array1[index1], array2[index2]);
1128
- context.push(child, index2);
1129
- }
1130
- }
1131
- context.setResult(result).exit();
1132
- };
1133
- diffFilter$2.filterName = 'arrays';
1134
- var compare = {
1135
- numerically: function numerically(a, b) {
1136
- return a - b;
1137
- },
1138
- numericallyBy: function numericallyBy(name) {
1139
- return function (a, b) {
1140
- return a[name] - b[name];
1141
- };
1142
- }
1143
- };
1144
- var patchFilter$1 = function nestedPatchFilter(context) {
1145
- if (!context.nested) {
1146
- return;
1147
- }
1148
- var nestedDelta = context.delta;
1149
- if (nestedDelta._t !== 'a') {
1150
- return;
1151
- }
1152
- var index;
1153
- var index1;
1154
- var delta = nestedDelta;
1155
- var array = context.left;
1156
- // first, separate removals, insertions and modifications
1157
- var toRemove = [];
1158
- var toInsert = [];
1159
- var toModify = [];
1160
- for (index in delta) {
1161
- if (index !== '_t') {
1162
- if (index[0] === '_') {
1163
- var removedOrMovedIndex = index;
1164
- // removed item from original array
1165
- if (delta[removedOrMovedIndex][2] === 0 || delta[removedOrMovedIndex][2] === ARRAY_MOVE) {
1166
- toRemove.push(parseInt(index.slice(1), 10));
1167
- } else {
1168
- throw new Error('only removal or move can be applied at original array indices,' + " invalid diff type: ".concat(delta[removedOrMovedIndex][2]));
1169
- }
1170
- } else {
1171
- var numberIndex = index;
1172
- if (delta[numberIndex].length === 1) {
1173
- // added item at new array
1174
- toInsert.push({
1175
- index: parseInt(numberIndex, 10),
1176
- value: delta[numberIndex][0]
1177
- });
1178
- } else {
1179
- // modified item at new array
1180
- toModify.push({
1181
- index: parseInt(numberIndex, 10),
1182
- delta: delta[numberIndex]
1183
- });
1184
- }
1185
- }
1186
- }
1187
- }
1188
- // remove items, in reverse order to avoid sawing our own floor
1189
- toRemove = toRemove.sort(compare.numerically);
1190
- for (index = toRemove.length - 1; index >= 0; index--) {
1191
- index1 = toRemove[index];
1192
- var indexDiff = delta["_".concat(index1)];
1193
- var removedValue = array.splice(index1, 1)[0];
1194
- if (indexDiff[2] === ARRAY_MOVE) {
1195
- // reinsert later
1196
- toInsert.push({
1197
- index: indexDiff[1],
1198
- value: removedValue
1199
- });
1200
- }
1201
- }
1202
- // insert items, in reverse order to avoid moving our own floor
1203
- toInsert = toInsert.sort(compare.numericallyBy('index'));
1204
- var toInsertLength = toInsert.length;
1205
- for (index = 0; index < toInsertLength; index++) {
1206
- var insertion = toInsert[index];
1207
- array.splice(insertion.index, 0, insertion.value);
1208
- }
1209
- // apply modifications
1210
- var toModifyLength = toModify.length;
1211
- var child;
1212
- if (toModifyLength > 0) {
1213
- for (index = 0; index < toModifyLength; index++) {
1214
- var modification = toModify[index];
1215
- child = new PatchContext(array[modification.index], modification.delta);
1216
- context.push(child, modification.index);
1217
- }
1218
- }
1219
- if (!context.children) {
1220
- context.setResult(array).exit();
1221
- return;
1222
- }
1223
- context.exit();
1224
- };
1225
- patchFilter$1.filterName = 'arrays';
1226
- var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
1227
- if (!context || !context.children) {
1228
- return;
1229
- }
1230
- var deltaWithChildren = context.delta;
1231
- if (deltaWithChildren._t !== 'a') {
1232
- return;
1233
- }
1234
- var array = context.left;
1235
- var length = context.children.length;
1236
- var child;
1237
- for (var index = 0; index < length; index++) {
1238
- child = context.children[index];
1239
- var arrayIndex = child.childName;
1240
- array[arrayIndex] = child.result;
1241
- }
1242
- context.setResult(array).exit();
1243
- };
1244
- collectChildrenPatchFilter.filterName = 'arraysCollectChildren';
1245
- var reverseFilter$1 = function arraysReverseFilter(context) {
1246
- if (!context.nested) {
1247
- var nonNestedDelta = context.delta;
1248
- if (nonNestedDelta[2] === ARRAY_MOVE) {
1249
- var arrayMoveDelta = nonNestedDelta;
1250
- context.newName = "_".concat(arrayMoveDelta[1]);
1251
- context.setResult([arrayMoveDelta[0], parseInt(context.childName.substring(1), 10), ARRAY_MOVE]).exit();
1252
- }
1253
- return;
1254
- }
1255
- var nestedDelta = context.delta;
1256
- if (nestedDelta._t !== 'a') {
1257
- return;
1258
- }
1259
- var arrayDelta = nestedDelta;
1260
- var name;
1261
- var child;
1262
- for (name in arrayDelta) {
1263
- if (name === '_t') {
1264
- continue;
1265
- }
1266
- child = new ReverseContext(arrayDelta[name]);
1267
- context.push(child, name);
1268
- }
1269
- context.exit();
1270
- };
1271
- reverseFilter$1.filterName = 'arrays';
1272
- var reverseArrayDeltaIndex = function reverseArrayDeltaIndex(delta, index, itemDelta) {
1273
- if (typeof index === 'string' && index[0] === '_') {
1274
- return parseInt(index.substring(1), 10);
1275
- } else if (Array.isArray(itemDelta) && itemDelta[2] === 0) {
1276
- return "_".concat(index);
1277
- }
1278
- var reverseIndex = +index;
1279
- for (var deltaIndex in delta) {
1280
- var deltaItem = delta[deltaIndex];
1281
- if (Array.isArray(deltaItem)) {
1282
- if (deltaItem[2] === ARRAY_MOVE) {
1283
- var moveFromIndex = parseInt(deltaIndex.substring(1), 10);
1284
- var moveToIndex = deltaItem[1];
1285
- if (moveToIndex === +index) {
1286
- return moveFromIndex;
1287
- }
1288
- if (moveFromIndex <= reverseIndex && moveToIndex > reverseIndex) {
1289
- reverseIndex++;
1290
- } else if (moveFromIndex >= reverseIndex && moveToIndex < reverseIndex) {
1291
- reverseIndex--;
1292
- }
1293
- } else if (deltaItem[2] === 0) {
1294
- var deleteIndex = parseInt(deltaIndex.substring(1), 10);
1295
- if (deleteIndex <= reverseIndex) {
1296
- reverseIndex++;
1297
- }
1298
- } else if (deltaItem.length === 1 && parseInt(deltaIndex, 10) <= reverseIndex) {
1299
- reverseIndex--;
1300
- }
1301
- }
1302
- }
1303
- return reverseIndex;
1304
- };
1305
- var collectChildrenReverseFilter = function collectChildrenReverseFilter(context) {
1306
- if (!context || !context.children) {
1307
- return;
1308
- }
1309
- var deltaWithChildren = context.delta;
1310
- if (deltaWithChildren._t !== 'a') {
1311
- return;
1312
- }
1313
- var arrayDelta = deltaWithChildren;
1314
- var length = context.children.length;
1315
- var child;
1316
- var delta = {
1317
- _t: 'a'
1318
- };
1319
- for (var index = 0; index < length; index++) {
1320
- child = context.children[index];
1321
- var name = child.newName;
1322
- if (typeof name === 'undefined') {
1323
- name = reverseArrayDeltaIndex(arrayDelta, child.childName, child.result);
1324
- }
1325
- if (delta[name] !== child.result) {
1326
- // There's no way to type this well.
1327
- delta[name] = child.result;
1328
- }
1329
- }
1330
- context.setResult(delta).exit();
1331
- };
1332
- collectChildrenReverseFilter.filterName = 'arraysCollectChildren';
1333
-
1334
- var diffFilter$1 = function datesDiffFilter(context) {
1335
- if (context.left instanceof Date) {
1336
- if (context.right instanceof Date) {
1337
- if (context.left.getTime() !== context.right.getTime()) {
1338
- context.setResult([context.left, context.right]);
1339
- } else {
1340
- context.setResult(undefined);
1341
- }
1342
- } else {
1343
- context.setResult([context.left, context.right]);
1344
- }
1345
- context.exit();
1346
- } else if (context.right instanceof Date) {
1347
- context.setResult([context.left, context.right]).exit();
1348
- }
1349
- };
1350
- diffFilter$1.filterName = 'dates';
1351
-
1352
- var TEXT_DIFF = 2;
1353
- var DEFAULT_MIN_LENGTH = 60;
1354
- var cachedDiffPatch = null;
1355
- function getDiffMatchPatch(options, required) {
1356
- var _a;
1357
- if (!cachedDiffPatch) {
1358
- var instance;
1359
- if ((_a = options === null || options === void 0 ? void 0 : options.textDiff) === null || _a === void 0 ? void 0 : _a.diffMatchPatch) {
1360
- instance = new options.textDiff.diffMatchPatch();
1361
- } else {
1362
- if (!required) {
1363
- return null;
1364
- }
1365
- var error = new Error('The diff-match-patch library was not provided. Pass the library in through the options or use the `jsondiffpatch/with-text-diffs` entry-point.');
1366
- // eslint-disable-next-line camelcase
1367
- error.diff_match_patch_not_found = true;
1368
- throw error;
1369
- }
1370
- cachedDiffPatch = {
1371
- diff: function diff(txt1, txt2) {
1372
- return instance.patch_toText(instance.patch_make(txt1, txt2));
1373
- },
1374
- patch: function patch(txt1, _patch) {
1375
- var results = instance.patch_apply(instance.patch_fromText(_patch), txt1);
1376
- for (var i = 0; i < results[1].length; i++) {
1377
- if (!results[1][i]) {
1378
- var _error = new Error('text patch failed');
1379
- _error.textPatchFailed = true;
1380
- }
201
+ if (!prices) return restOfVariant;
202
+ var oldVariant = previousVariants.find(function (previousVariant) {
203
+ return !isNil__default["default"](previousVariant.id) && previousVariant.id === newVariant.id || !isNil__default["default"](previousVariant.key) && previousVariant.key === newVariant.key || !isNil__default["default"](previousVariant.sku) && previousVariant.sku === newVariant.sku;
204
+ });
205
+ return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
206
+ prices: prices.map(function (price) {
207
+ var newPrice = _objectSpread2({}, price);
208
+ var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
209
+ if (oldPrice) {
210
+ // copy ID if not provided
211
+ if (!newPrice.id) newPrice.id = oldPrice.id;
212
+ if (isNil__default["default"](newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
213
+ if (isNil__default["default"](newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
1381
214
  }
1382
- return results[0];
1383
- }
1384
- };
1385
- }
1386
- return cachedDiffPatch;
215
+ return newPrice;
216
+ })
217
+ });
218
+ });
1387
219
  }
1388
- var diffFilter = function textsDiffFilter(context) {
1389
- if (context.leftType !== 'string') {
1390
- return;
1391
- }
1392
- var left = context.left;
1393
- var right = context.right;
1394
- var minLength = context.options && context.options.textDiff && context.options.textDiff.minLength || DEFAULT_MIN_LENGTH;
1395
- if (left.length < minLength || right.length < minLength) {
1396
- context.setResult([left, right]).exit();
1397
- return;
1398
- }
1399
- // large text, try to use a text-diff algorithm
1400
- var diffMatchPatch = getDiffMatchPatch(context.options);
1401
- if (!diffMatchPatch) {
1402
- // diff-match-patch library not available,
1403
- // fallback to regular string replace
1404
- context.setResult([left, right]).exit();
1405
- return;
1406
- }
1407
- var diff = diffMatchPatch.diff;
1408
- context.setResult([diff(left, right), 0, TEXT_DIFF]).exit();
1409
- };
1410
- diffFilter.filterName = 'texts';
1411
- var patchFilter = function textsPatchFilter(context) {
1412
- if (context.nested) {
1413
- return;
1414
- }
1415
- var nonNestedDelta = context.delta;
1416
- if (nonNestedDelta[2] !== TEXT_DIFF) {
1417
- return;
1418
- }
1419
- var textDiffDelta = nonNestedDelta;
1420
- // text-diff, use a text-patch algorithm
1421
- var patch = getDiffMatchPatch(context.options, true).patch;
1422
- context.setResult(patch(context.left, textDiffDelta[0])).exit();
1423
- };
1424
- patchFilter.filterName = 'texts';
1425
- var textDeltaReverse = function textDeltaReverse(delta) {
1426
- var i;
1427
- var l;
1428
- var line;
1429
- var lineTmp;
1430
- var header = null;
1431
- var headerRegex = /^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/;
1432
- var lineHeader;
1433
- var lines = delta.split('\n');
1434
- for (i = 0, l = lines.length; i < l; i++) {
1435
- line = lines[i];
1436
- var lineStart = line.slice(0, 1);
1437
- if (lineStart === '@') {
1438
- header = headerRegex.exec(line);
1439
- lineHeader = i;
1440
- // fix header
1441
- lines[lineHeader] = '@@ -' + header[3] + ',' + header[4] + ' +' + header[1] + ',' + header[2] + ' @@';
1442
- } else if (lineStart === '+') {
1443
- lines[i] = '-' + lines[i].slice(1);
1444
- if (lines[i - 1].slice(0, 1) === '+') {
1445
- // swap lines to keep default order (-+)
1446
- lineTmp = lines[i];
1447
- lines[i] = lines[i - 1];
1448
- lines[i - 1] = lineTmp;
1449
- }
1450
- } else if (lineStart === '-') {
1451
- lines[i] = '+' + lines[i].slice(1);
1452
- }
1453
- }
1454
- return lines.join('\n');
1455
- };
1456
- var reverseFilter = function textsReverseFilter(context) {
1457
- if (context.nested) {
1458
- return;
1459
- }
1460
- var nonNestedDelta = context.delta;
1461
- if (nonNestedDelta[2] !== TEXT_DIFF) {
1462
- return;
1463
- }
1464
- var textDiffDelta = nonNestedDelta;
1465
- // text-diff, use a text-diff algorithm
1466
- context.setResult([textDeltaReverse(textDiffDelta[0]), 0, TEXT_DIFF]).exit();
1467
- };
1468
- reverseFilter.filterName = 'texts';
1469
-
1470
- var DiffPatcher = /*#__PURE__*/function () {
1471
- function DiffPatcher(options) {
1472
- _classCallCheck(this, DiffPatcher);
1473
- this.processor = new Processor(options);
1474
- this.processor.pipe(new Pipe('diff').append(collectChildrenDiffFilter, diffFilter$3, diffFilter$1, diffFilter, objectsDiffFilter, diffFilter$2).shouldHaveResult());
1475
- this.processor.pipe(new Pipe('patch').append(collectChildrenPatchFilter$1, collectChildrenPatchFilter, patchFilter$3, patchFilter, patchFilter$2, patchFilter$1).shouldHaveResult());
1476
- this.processor.pipe(new Pipe('reverse').append(collectChildrenReverseFilter$1, collectChildrenReverseFilter, reverseFilter$3, reverseFilter, reverseFilter$2, reverseFilter$1).shouldHaveResult());
1477
- }
1478
- return _createClass(DiffPatcher, [{
1479
- key: "options",
1480
- value: function options(_options) {
1481
- return this.processor.options(_options);
1482
- }
1483
- }, {
1484
- key: "diff",
1485
- value: function diff(left, right) {
1486
- return this.processor.process(new DiffContext(left, right));
1487
- }
1488
- }, {
1489
- key: "patch",
1490
- value: function patch(left, delta) {
1491
- return this.processor.process(new PatchContext(left, delta));
1492
- }
1493
- }, {
1494
- key: "reverse",
1495
- value: function reverse(delta) {
1496
- return this.processor.process(new ReverseContext(delta));
1497
- }
1498
- }, {
1499
- key: "unpatch",
1500
- value: function unpatch(right, delta) {
1501
- return this.patch(right, this.reverse(delta));
1502
- }
1503
- }, {
1504
- key: "clone",
1505
- value: function clone(value) {
1506
- return clone$1(value);
1507
- }
1508
- }]);
1509
- }();
220
+ function createBuildActions(differ, doMapActions, onBeforeDiff) {
221
+ var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
222
+ return function buildActions(now, before) {
223
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
224
+ if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
225
+ var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
226
+ _applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
227
+ processedBefore = _applyOnBeforeDiff2[0],
228
+ processedNow = _applyOnBeforeDiff2[1];
229
+ if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
230
+ var diffed = differ(processedBefore, processedNow);
231
+ if (!buildActionsConfig.withHints && !diffed) return [];
232
+ return doMapActions(diffed, processedNow, processedBefore, options);
233
+ };
234
+ }
235
+
236
+ // Array of action groups which need to be allowed or ignored.
237
+ // Example:
238
+ // [
239
+ // { type: 'base', group: 'ignore' },
240
+ // { type: 'prices', group: 'allow' },
241
+ // { type: 'variants', group: 'ignore' },
242
+ // ]
243
+ function createMapActionGroup() {
244
+ var actionGroups = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
245
+ return function mapActionGroup(type, fn) {
246
+ if (!Object.keys(actionGroups).length) return fn();
247
+ var found = actionGroups.find(function (c) {
248
+ return c.type === type;
249
+ });
250
+ if (!found) return [];
251
+
252
+ // Keep `black` for backwards compatibility.
253
+ if (found.group === 'ignore' || found.group === 'black') return [];
254
+ // Keep `white` for backwards compatibility.
255
+ if (found.group === 'allow' || found.group === 'white') return fn();
256
+ throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
257
+ };
258
+ }
259
+
260
+ function _arrayWithoutHoles(r) {
261
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
262
+ }
263
+
264
+ function _iterableToArray(r) {
265
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
266
+ }
267
+
268
+ function _nonIterableSpread() {
269
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
270
+ }
271
+
272
+ function _toConsumableArray(r) {
273
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
274
+ }
275
+
276
+ function _typeof(o) {
277
+ "@babel/helpers - typeof";
1510
278
 
1511
- function create(options) {
1512
- return new DiffPatcher(options);
279
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
280
+ return typeof o;
281
+ } : function (o) {
282
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
283
+ }, _typeof(o);
1513
284
  }
1514
285
 
1515
286
  function objectHash(obj, index) {
1516
287
  var objIndex = "$$index:".concat(index);
1517
288
  return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
1518
289
  }
1519
- var diffpatcher = create({
290
+ var diffpatcher = jsondiffpatch__namespace.create({
1520
291
  objectHash: objectHash,
1521
292
  arrays: {
1522
293
  // detect items moved inside the array
@@ -1846,7 +617,7 @@ function buildBaseAttributesActions(_ref) {
1846
617
  action: item.action
1847
618
  }, actionKey, patched);
1848
619
  }).filter(function (action) {
1849
- return !isNil(action);
620
+ return !isNil__default["default"](action);
1850
621
  });
1851
622
  }
1852
623
 
@@ -1899,7 +670,7 @@ function buildReferenceActions(_ref4) {
1899
670
  });
1900
671
  }
1901
672
 
1902
- var baseActionsList$k = [{
673
+ var baseActionsList$l = [{
1903
674
  action: 'changeName',
1904
675
  key: 'name'
1905
676
  }, {
@@ -1937,10 +708,10 @@ var referenceActionsList$3 = [{
1937
708
  * SYNC FUNCTIONS
1938
709
  */
1939
710
 
1940
- function actionsMapBase$k(diff, oldObj, newObj) {
711
+ function actionsMapBase$l(diff, oldObj, newObj) {
1941
712
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1942
713
  return buildBaseAttributesActions({
1943
- actions: baseActionsList$k,
714
+ actions: baseActionsList$l,
1944
715
  diff: diff,
1945
716
  oldObj: oldObj,
1946
717
  newObj: newObj,
@@ -1953,6 +724,7 @@ function actionsMapReferences$3(diff, oldObj, newObj) {
1953
724
  return buildReferenceActions({
1954
725
  actions: referenceActionsList$3,
1955
726
  diff: diff,
727
+ oldObj: oldObj,
1956
728
  newObj: newObj
1957
729
  });
1958
730
  }
@@ -1978,7 +750,7 @@ var CUSTOM = 'custom';
1978
750
  function copyEmptyArrayProps() {
1979
751
  var oldObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1980
752
  var newObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1981
- if (!isNil(oldObj) && !isNil(newObj)) {
753
+ if (!isNil__default["default"](oldObj) && !isNil__default["default"](newObj)) {
1982
754
  var nextObjectWithEmptyArray = Object.entries(oldObj).reduce(function (merged, _ref) {
1983
755
  var _ref2 = _slicedToArray(_ref, 2),
1984
756
  key = _ref2[0],
@@ -1993,10 +765,10 @@ function copyEmptyArrayProps() {
1993
765
  return acc;
1994
766
  }, {});
1995
767
  for (var i = 0; i < newObj[key].length; i++) {
1996
- if (!isNil(newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil(newObj[key][i].id)) {
768
+ if (!isNil__default["default"](newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil__default["default"](newObj[key][i].id)) {
1997
769
  // Since its unordered array elements then check if the element on `oldObj` exists by id
1998
770
  var foundObject = hashMapValue[newObj[key][i].id];
1999
- if (!isNil(foundObject)) {
771
+ if (!isNil__default["default"](foundObject)) {
2000
772
  var _copyEmptyArrayProps = copyEmptyArrayProps(foundObject, newObj[key][i]),
2001
773
  _copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
2002
774
  nestedObject = _copyEmptyArrayProps2[1];
@@ -2012,10 +784,10 @@ function copyEmptyArrayProps() {
2012
784
  return merged;
2013
785
  }
2014
786
  if (Array.isArray(value)) {
2015
- merged[key] = isNil(newObj[key]) ? [] : newObj[key];
787
+ merged[key] = isNil__default["default"](newObj[key]) ? [] : newObj[key];
2016
788
  return merged;
2017
789
  }
2018
- if (!isNil(newObj[key]) && _typeof(value) === 'object' &&
790
+ if (!isNil__default["default"](newObj[key]) && _typeof(value) === 'object' &&
2019
791
  // Ignore Date as this will create invalid object since typeof date === 'object' return true
2020
792
  // ex: {date: new Date()} will result {date: {}}
2021
793
  !(value instanceof Date)) {
@@ -2036,7 +808,7 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
2036
808
  return function doMapActions(diff, newObj, oldObj) {
2037
809
  var allActions = [];
2038
810
  allActions.push(mapActionGroup('base', function () {
2039
- return actionsMapBase$k(diff, oldObj, newObj, syncActionConfig);
811
+ return actionsMapBase$l(diff, oldObj, newObj, syncActionConfig);
2040
812
  }));
2041
813
  allActions.push(mapActionGroup('references', function () {
2042
814
  return actionsMapReferences$3(diff, oldObj, newObj);
@@ -2050,7 +822,7 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
2050
822
  allActions.push(mapActionGroup('assets', function () {
2051
823
  return actionsMapAssets$1(diff, oldObj, newObj);
2052
824
  }));
2053
- return flatten(allActions);
825
+ return flatten__default["default"](allActions);
2054
826
  };
2055
827
  }
2056
828
  var categories = (function (actionGroupList, syncActionConfig) {
@@ -2074,7 +846,7 @@ var categories = (function (actionGroupList, syncActionConfig) {
2074
846
  });
2075
847
 
2076
848
  var isEmptyValue = createIsEmptyValue([undefined, null, '']);
2077
- var baseActionsList$j = [{
849
+ var baseActionsList$k = [{
2078
850
  action: 'setSalutation',
2079
851
  key: 'salutation'
2080
852
  }, {
@@ -2140,10 +912,10 @@ var authenticationModeActionsList = [{
2140
912
  * SYNC FUNCTIONS
2141
913
  */
2142
914
 
2143
- function actionsMapBase$j(diff, oldObj, newObj) {
915
+ function actionsMapBase$k(diff, oldObj, newObj) {
2144
916
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2145
917
  return buildBaseAttributesActions({
2146
- actions: baseActionsList$j,
918
+ actions: baseActionsList$k,
2147
919
  diff: diff,
2148
920
  oldObj: oldObj,
2149
921
  newObj: newObj,
@@ -2168,6 +940,7 @@ function actionsMapReferences$2(diff, oldObj, newObj) {
2168
940
  return buildReferenceActions({
2169
941
  actions: referenceActionsList$2,
2170
942
  diff: diff,
943
+ oldObj: oldObj,
2171
944
  newObj: newObj
2172
945
  });
2173
946
  }
@@ -2275,7 +1048,7 @@ function buildAuthenticationModeActions(_ref) {
2275
1048
  authMode: patched
2276
1049
  }, value, newObj.password);
2277
1050
  }).filter(function (action) {
2278
- return !isNil(action);
1051
+ return !isNil__default["default"](action);
2279
1052
  });
2280
1053
  }
2281
1054
 
@@ -2283,7 +1056,7 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
2283
1056
  return function doMapActions(diff, newObj, oldObj) {
2284
1057
  var allActions = [];
2285
1058
  allActions.push(mapActionGroup('base', function () {
2286
- return actionsMapBase$j(diff, oldObj, newObj, syncActionConfig);
1059
+ return actionsMapBase$k(diff, oldObj, newObj, syncActionConfig);
2287
1060
  }));
2288
1061
  allActions.push(mapActionGroup('references', function () {
2289
1062
  return actionsMapReferences$2(diff, oldObj, newObj);
@@ -2306,7 +1079,7 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
2306
1079
  allActions.push(mapActionGroup('authenticationModes', function () {
2307
1080
  return actionsMapAuthenticationModes(diff, oldObj, newObj);
2308
1081
  }));
2309
- return flatten(allActions);
1082
+ return flatten__default["default"](allActions);
2310
1083
  };
2311
1084
  }
2312
1085
  var customers = (function (actionGroupList, syncActionConfig) {
@@ -2329,7 +1102,7 @@ var customers = (function (actionGroupList, syncActionConfig) {
2329
1102
  };
2330
1103
  });
2331
1104
 
2332
- var baseActionsList$i = [{
1105
+ var baseActionsList$j = [{
2333
1106
  action: 'changeQuantity',
2334
1107
  key: 'quantityOnStock',
2335
1108
  actionKey: 'quantity'
@@ -2349,10 +1122,10 @@ var referenceActionsList$1 = [{
2349
1122
  * SYNC FUNCTIONS
2350
1123
  */
2351
1124
 
2352
- function actionsMapBase$i(diff, oldObj, newObj) {
1125
+ function actionsMapBase$j(diff, oldObj, newObj) {
2353
1126
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2354
1127
  return buildBaseAttributesActions({
2355
- actions: baseActionsList$i,
1128
+ actions: baseActionsList$j,
2356
1129
  diff: diff,
2357
1130
  oldObj: oldObj,
2358
1131
  newObj: newObj,
@@ -2365,6 +1138,7 @@ function actionsMapReferences$1(diff, oldObj, newObj) {
2365
1138
  return buildReferenceActions({
2366
1139
  actions: referenceActionsList$1,
2367
1140
  diff: diff,
1141
+ oldObj: oldObj,
2368
1142
  newObj: newObj
2369
1143
  });
2370
1144
  }
@@ -2373,7 +1147,7 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
2373
1147
  return function doMapActions(diff, newObj, oldObj) {
2374
1148
  var allActions = [];
2375
1149
  allActions.push(mapActionGroup('base', function () {
2376
- return actionsMapBase$i(diff, oldObj, newObj, syncActionConfig);
1150
+ return actionsMapBase$j(diff, oldObj, newObj, syncActionConfig);
2377
1151
  }));
2378
1152
  allActions.push(mapActionGroup('references', function () {
2379
1153
  return actionsMapReferences$1(diff, oldObj, newObj);
@@ -2381,7 +1155,7 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
2381
1155
  allActions.push(mapActionGroup('custom', function () {
2382
1156
  return actionsMapCustom(diff, newObj, oldObj);
2383
1157
  }));
2384
- return flatten(allActions);
1158
+ return flatten__default["default"](allActions);
2385
1159
  };
2386
1160
  }
2387
1161
  var inventories = (function (actionGroupList, syncActionConfig) {
@@ -2448,7 +1222,7 @@ function findMatchingPairs(diff) {
2448
1222
  var _preProcessCollection2 = preProcessCollection(now, identifier),
2449
1223
  nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
2450
1224
  nowObjRefByIndex = _preProcessCollection2.refByIndex;
2451
- forEach(diff, function (item, key) {
1225
+ forEach__default["default"](diff, function (item, key) {
2452
1226
  if (REGEX_NUMBER$3.test(key)) {
2453
1227
  var matchingIdentifier = nowObjRefByIndex[key];
2454
1228
  result[key] = [beforeObjRefByIdentifier[matchingIdentifier], key];
@@ -2463,7 +1237,7 @@ function findMatchingPairs(diff) {
2463
1237
 
2464
1238
  var REGEX_NUMBER$2 = new RegExp(/^\d+$/);
2465
1239
  var REGEX_UNDERSCORE_NUMBER$2 = new RegExp(/^_\d+$/);
2466
- var baseActionsList$h = [{
1240
+ var baseActionsList$i = [{
2467
1241
  action: 'changeName',
2468
1242
  key: 'name'
2469
1243
  }, {
@@ -2629,7 +1403,7 @@ function _buildVariantImagesAction(diffedImages) {
2629
1403
  var actions = [];
2630
1404
  // generate a hashMap to be able to reference the right image from both ends
2631
1405
  var matchingImagePairs = findMatchingPairs(diffedImages, oldVariant.images, newVariant.images, 'url');
2632
- forEach(diffedImages, function (image, key) {
1406
+ forEach__default["default"](diffedImages, function (image, key) {
2633
1407
  var _extractMatchingPairs = extractMatchingPairs(matchingImagePairs, key, oldVariant.images, newVariant.images),
2634
1408
  oldObj = _extractMatchingPairs.oldObj,
2635
1409
  newObj = _extractMatchingPairs.newObj;
@@ -2686,7 +1460,7 @@ function _buildVariantPricesAction(diffedPrices) {
2686
1460
 
2687
1461
  // generate a hashMap to be able to reference the right image from both ends
2688
1462
  var matchingPricePairs = findMatchingPairs(diffedPrices, oldVariant.prices, newVariant.prices);
2689
- forEach(diffedPrices, function (price, key) {
1463
+ forEach__default["default"](diffedPrices, function (price, key) {
2690
1464
  var _extractMatchingPairs2 = extractMatchingPairs(matchingPricePairs, key, oldVariant.prices, newVariant.prices),
2691
1465
  oldObj = _extractMatchingPairs2.oldObj,
2692
1466
  newObj = _extractMatchingPairs2.newObj;
@@ -2734,7 +1508,7 @@ function _buildVariantPricesAction(diffedPrices) {
2734
1508
  function _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames) {
2735
1509
  var actions = [];
2736
1510
  if (!attributes) return actions;
2737
- forEach(attributes, function (value, key) {
1511
+ forEach__default["default"](attributes, function (value, key) {
2738
1512
  if (REGEX_NUMBER$2.test(key)) {
2739
1513
  if (Array.isArray(value)) {
2740
1514
  var id = oldVariant.id;
@@ -2799,8 +1573,8 @@ function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant)
2799
1573
  }).filter(function (_) {
2800
1574
  return _ !== undefined;
2801
1575
  });
2802
- var assetIdsToKeep = intersection(assetIdsCurrent, assetIdsBefore);
2803
- var assetIdsToRemove = without.apply(void 0, [assetIdsBefore].concat(_toConsumableArray(assetIdsToKeep)));
1576
+ var assetIdsToKeep = intersection__default["default"](assetIdsCurrent, assetIdsBefore);
1577
+ var assetIdsToRemove = without__default["default"].apply(void 0, [assetIdsBefore].concat(_toConsumableArray(assetIdsToKeep)));
2804
1578
  var changeAssetOrderAction = _objectSpread2({
2805
1579
  action: 'changeAssetOrder',
2806
1580
  assetOrder: assetIdsToKeep.concat(assetIdsToRemove)
@@ -2812,7 +1586,7 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
2812
1586
 
2813
1587
  // generate a hashMap to be able to reference the right asset from both ends
2814
1588
  var matchingAssetPairs = findMatchingPairs(diffAssets, oldVariant.assets, newVariant.assets);
2815
- forEach(diffAssets, function (asset, key) {
1589
+ forEach__default["default"](diffAssets, function (asset, key) {
2816
1590
  var _extractMatchingPairs3 = extractMatchingPairs(matchingAssetPairs, key, oldVariant.assets, newVariant.assets),
2817
1591
  oldAsset = _extractMatchingPairs3.oldObj,
2818
1592
  newAsset = _extractMatchingPairs3.newObj;
@@ -2867,10 +1641,10 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
2867
1641
  * SYNC FUNCTIONS
2868
1642
  */
2869
1643
 
2870
- function actionsMapBase$h(diff, oldObj, newObj) {
1644
+ function actionsMapBase$i(diff, oldObj, newObj) {
2871
1645
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2872
1646
  return buildBaseAttributesActions({
2873
- actions: baseActionsList$h,
1647
+ actions: baseActionsList$i,
2874
1648
  diff: diff,
2875
1649
  oldObj: oldObj,
2876
1650
  newObj: newObj,
@@ -2911,6 +1685,7 @@ function actionsMapReferences(diff, oldObj, newObj) {
2911
1685
  return buildReferenceActions({
2912
1686
  actions: referenceActionsList,
2913
1687
  diff: diff,
1688
+ oldObj: oldObj,
2914
1689
  newObj: newObj
2915
1690
  });
2916
1691
  }
@@ -2919,7 +1694,7 @@ function actionsMapCategories(diff) {
2919
1694
  if (!diff.categories) return actions;
2920
1695
  var addToCategoryActions = [];
2921
1696
  var removeFromCategoryActions = [];
2922
- forEach(diff.categories, function (category) {
1697
+ forEach__default["default"](diff.categories, function (category) {
2923
1698
  if (Array.isArray(category)) {
2924
1699
  var action = {
2925
1700
  category: category[0]
@@ -2964,7 +1739,7 @@ function actionsMapCategoryOrderHints(diff) {
2964
1739
  function actionsMapAssets(diff, oldObj, newObj, variantHashMap) {
2965
1740
  var allAssetsActions = [];
2966
1741
  var variants = diff.variants;
2967
- if (variants) forEach(variants, function (variant, key) {
1742
+ if (variants) forEach__default["default"](variants, function (variant, key) {
2968
1743
  var _extractMatchingPairs4 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
2969
1744
  oldVariant = _extractMatchingPairs4.oldObj,
2970
1745
  newVariant = _extractMatchingPairs4.newObj;
@@ -2980,7 +1755,7 @@ function actionsMapAttributes$1(diff, oldObj, newObj) {
2980
1755
  var variantHashMap = arguments.length > 4 ? arguments[4] : undefined;
2981
1756
  var actions = [];
2982
1757
  var variants = diff.variants;
2983
- if (variants) forEach(variants, function (variant, key) {
1758
+ if (variants) forEach__default["default"](variants, function (variant, key) {
2984
1759
  var _extractMatchingPairs5 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
2985
1760
  oldVariant = _extractMatchingPairs5.oldObj,
2986
1761
  newVariant = _extractMatchingPairs5.newObj;
@@ -2997,14 +1772,14 @@ function actionsMapAttributes$1(diff, oldObj, newObj) {
2997
1772
 
2998
1773
  // Ensure that an action is unique.
2999
1774
  // This is especially necessary for SFA attributes.
3000
- return uniqWith(actions, function (a, b) {
1775
+ return uniqWith__default["default"](actions, function (a, b) {
3001
1776
  return a.action === b.action && a.name === b.name && a.variantId === b.variantId;
3002
1777
  });
3003
1778
  }
3004
1779
  function actionsMapImages(diff, oldObj, newObj, variantHashMap) {
3005
1780
  var actions = [];
3006
1781
  var variants = diff.variants;
3007
- if (variants) forEach(variants, function (variant, key) {
1782
+ if (variants) forEach__default["default"](variants, function (variant, key) {
3008
1783
  var _extractMatchingPairs6 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
3009
1784
  oldVariant = _extractMatchingPairs6.oldObj,
3010
1785
  newVariant = _extractMatchingPairs6.newObj;
@@ -3020,7 +1795,7 @@ function actionsMapPrices(diff, oldObj, newObj, variantHashMap, enableDiscounted
3020
1795
  var changePriceActions = [];
3021
1796
  var removePriceActions = [];
3022
1797
  var variants = diff.variants;
3023
- if (variants) forEach(variants, function (variant, key) {
1798
+ if (variants) forEach__default["default"](variants, function (variant, key) {
3024
1799
  var _extractMatchingPairs7 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
3025
1800
  oldVariant = _extractMatchingPairs7.oldObj,
3026
1801
  newVariant = _extractMatchingPairs7.newObj;
@@ -3042,13 +1817,13 @@ function actionsMapPrices(diff, oldObj, newObj, variantHashMap, enableDiscounted
3042
1817
  function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
3043
1818
  var actions = [];
3044
1819
  var variants = diff.variants;
3045
- if (variants) forEach(variants, function (variant, key) {
1820
+ if (variants) forEach__default["default"](variants, function (variant, key) {
3046
1821
  var _extractMatchingPairs8 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
3047
1822
  oldVariant = _extractMatchingPairs8.oldObj,
3048
1823
  newVariant = _extractMatchingPairs8.newObj;
3049
1824
  if (variant && variant.prices && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
3050
1825
  var priceHashMap = findMatchingPairs(variant.prices, oldVariant.prices, newVariant.prices);
3051
- forEach(variant.prices, function (price, index) {
1826
+ forEach__default["default"](variant.prices, function (price, index) {
3052
1827
  var _extractMatchingPairs9 = extractMatchingPairs(priceHashMap, index, oldVariant.prices, newVariant.prices),
3053
1828
  oldPrice = _extractMatchingPairs9.oldObj,
3054
1829
  newPrice = _extractMatchingPairs9.newObj;
@@ -3106,7 +1881,7 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
3106
1881
  return actionsMapRemoveVariants(diff, oldObj, newObj);
3107
1882
  }));
3108
1883
  allActions.push(mapActionGroup('base', function () {
3109
- return actionsMapBase$h(diff, oldObj, newObj, syncActionConfig);
1884
+ return actionsMapBase$i(diff, oldObj, newObj, syncActionConfig);
3110
1885
  }));
3111
1886
  allActions.push(mapActionGroup('meta', function () {
3112
1887
  return actionsMapMeta(diff, oldObj, newObj);
@@ -3132,12 +1907,12 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
3132
1907
  allActions.push(mapActionGroup('assets', function () {
3133
1908
  return actionsMapAssets(diff, oldObj, newObj, variantHashMap);
3134
1909
  }));
3135
- if (publish === true || staged === false) return flatten(allActions).map(function (action) {
1910
+ if (publish === true || staged === false) return flatten__default["default"](allActions).map(function (action) {
3136
1911
  return _objectSpread2(_objectSpread2({}, action), {}, {
3137
1912
  staged: false
3138
1913
  });
3139
1914
  });
3140
- return flatten(allActions);
1915
+ return flatten__default["default"](allActions);
3141
1916
  };
3142
1917
  }
3143
1918
  function moveMasterVariantsIntoVariants(before, now) {
@@ -3173,7 +1948,7 @@ var isAddAction = function isAddAction(key, resource) {
3173
1948
  var isRemoveAction = function isRemoveAction(key, resource) {
3174
1949
  return REGEX_UNDERSCORE_NUMBER$1.test(key) && Number(resource[2]) === 0;
3175
1950
  };
3176
- var baseActionsList$g = [{
1951
+ var baseActionsList$h = [{
3177
1952
  action: 'changeOrderState',
3178
1953
  key: 'orderState'
3179
1954
  }, {
@@ -3188,10 +1963,10 @@ var baseActionsList$g = [{
3188
1963
  * SYNC FUNCTIONS
3189
1964
  */
3190
1965
 
3191
- function actionsMapBase$g(diff, oldObj, newObj) {
1966
+ function actionsMapBase$h(diff, oldObj, newObj) {
3192
1967
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3193
1968
  return buildBaseAttributesActions({
3194
- actions: baseActionsList$g,
1969
+ actions: baseActionsList$h,
3195
1970
  diff: diff,
3196
1971
  oldObj: oldObj,
3197
1972
  newObj: newObj,
@@ -3220,7 +1995,7 @@ function _buildDeliveryParcelsAction(diffedParcels) {
3220
1995
 
3221
1996
  // generate a hashMap to be able to reference the right image from both ends
3222
1997
  var matchingParcelPairs = findMatchingPairs(diffedParcels, oldDelivery.parcels, newDelivery.parcels);
3223
- forEach(diffedParcels, function (parcel, key) {
1998
+ forEach__default["default"](diffedParcels, function (parcel, key) {
3224
1999
  var _extractMatchingPairs = extractMatchingPairs(matchingParcelPairs, key, oldDelivery.parcels, newDelivery.parcels),
3225
2000
  oldObj = _extractMatchingPairs.oldObj;
3226
2001
  if (isAddAction(key, parcel)) {
@@ -3262,7 +2037,7 @@ function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
3262
2037
  if (!deliveries) return [];
3263
2038
  var addParcelActions = [];
3264
2039
  var removeParcelActions = [];
3265
- if (deliveries) forEach(deliveries, function (delivery, key) {
2040
+ if (deliveries) forEach__default["default"](deliveries, function (delivery, key) {
3266
2041
  var _extractMatchingPairs2 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
3267
2042
  oldDelivery = _extractMatchingPairs2.oldObj,
3268
2043
  newDelivery = _extractMatchingPairs2.newObj;
@@ -3283,7 +2058,7 @@ function actionsMapDeliveryItems(diff, oldObj, newObj, deliveryHashMap) {
3283
2058
  var deliveries = shippingInfo.deliveries;
3284
2059
  if (!deliveries) return [];
3285
2060
  var setDeliveryItemsActions = [];
3286
- forEach(deliveries, function (delivery, key) {
2061
+ forEach__default["default"](deliveries, function (delivery, key) {
3287
2062
  var _extractMatchingPairs3 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
3288
2063
  newDelivery = _extractMatchingPairs3.newObj;
3289
2064
  if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
@@ -3341,7 +2116,7 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
3341
2116
  deliveryHashMap = findMatchingPairs(diff.shippingInfo.deliveries, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries);
3342
2117
  }
3343
2118
  allActions.push(mapActionGroup('base', function () {
3344
- return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
2119
+ return actionsMapBase$h(diff, oldObj, newObj, syncActionConfig);
3345
2120
  }));
3346
2121
  allActions.push(mapActionGroup('deliveries', function () {
3347
2122
  return actionsMapDeliveries(diff, oldObj, newObj);
@@ -3352,13 +2127,13 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
3352
2127
  allActions.push(mapActionGroup('items', function () {
3353
2128
  return actionsMapDeliveryItems(diff, oldObj, newObj, deliveryHashMap);
3354
2129
  }));
3355
- allActions.push(flatten(mapActionGroup('returnInfo', function () {
2130
+ allActions.push(flatten__default["default"](mapActionGroup('returnInfo', function () {
3356
2131
  return actionsMapReturnsInfo(diff, oldObj, newObj);
3357
2132
  })));
3358
2133
  allActions.push(mapActionGroup('custom', function () {
3359
2134
  return actionsMapCustom(diff, newObj, oldObj);
3360
2135
  }));
3361
- return flatten(allActions);
2136
+ return flatten__default["default"](allActions);
3362
2137
  };
3363
2138
  }
3364
2139
  var orders = (function (actionGroupList, syncActionConfig) {
@@ -3381,6 +2156,50 @@ var orders = (function (actionGroupList, syncActionConfig) {
3381
2156
  };
3382
2157
  });
3383
2158
 
2159
+ var baseActionsList$g = [{
2160
+ action: 'setKey',
2161
+ key: 'key'
2162
+ }, {
2163
+ action: 'setRecurringOrderState',
2164
+ key: 'recurringOrderState'
2165
+ }, {
2166
+ action: 'transitionState',
2167
+ key: 'state'
2168
+ }];
2169
+ function actionsMapBase$g(diff, oldObj, newObj) {
2170
+ var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2171
+ return buildBaseAttributesActions({
2172
+ actions: baseActionsList$g,
2173
+ diff: diff,
2174
+ oldObj: oldObj,
2175
+ newObj: newObj,
2176
+ shouldOmitEmptyString: config.shouldOmitEmptyString,
2177
+ shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties,
2178
+ shouldPreventUnsettingRequiredFields: config.shouldPreventUnsettingRequiredFields
2179
+ });
2180
+ }
2181
+
2182
+ function createRecurringOrdersMapActions(mapActionGroup, syncActionConfig) {
2183
+ return function doMapActions(diff, newObj, oldObj) {
2184
+ var allActions = [];
2185
+ allActions.push(mapActionGroup('base', function () {
2186
+ return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
2187
+ }));
2188
+ allActions.push(mapActionGroup('custom', function () {
2189
+ return actionsMapCustom(diff, newObj, oldObj);
2190
+ }));
2191
+ return flatten__default["default"](allActions);
2192
+ };
2193
+ }
2194
+ var recurringOrders = (function (actionGroupList, syncActionConfig) {
2195
+ var mapActionGroup = createMapActionGroup(actionGroupList);
2196
+ var doMapActions = createRecurringOrdersMapActions(mapActionGroup, syncActionConfig);
2197
+ var buildActions = createBuildActions(diff, doMapActions);
2198
+ return {
2199
+ buildActions: buildActions
2200
+ };
2201
+ });
2202
+
3384
2203
  var baseActionsList$f = [{
3385
2204
  action: 'changeIsActive',
3386
2205
  key: 'isActive'
@@ -3452,7 +2271,7 @@ function createProductDiscountsMapActions(mapActionGroup, syncActionConfig) {
3452
2271
  allActions.push(mapActionGroup('base', function () {
3453
2272
  return actionsMapBase$f(diff, oldObj, newObj, syncActionConfig);
3454
2273
  }));
3455
- return combineValidityActions(flatten(allActions));
2274
+ return combineValidityActions(flatten__default["default"](allActions));
3456
2275
  };
3457
2276
  }
3458
2277
  var productDiscounts = (function (actionGroupList) {
@@ -3521,7 +2340,7 @@ function createDiscountCodesMapActions(mapActionGroup, syncActionConfig) {
3521
2340
  allActions.push(mapActionGroup('custom', function () {
3522
2341
  return actionsMapCustom(diff, newObj, oldObj);
3523
2342
  }));
3524
- return combineValidityActions(flatten(allActions));
2343
+ return combineValidityActions(flatten__default["default"](allActions));
3525
2344
  };
3526
2345
  }
3527
2346
  var discountCodes = (function (actionGroupList) {
@@ -3574,7 +2393,7 @@ function createCustomerGroupMapActions(mapActionGroup, syncActionConfig) {
3574
2393
  allActions.push(mapActionGroup('custom', function () {
3575
2394
  return actionsMapCustom(diff, newObj, oldObj);
3576
2395
  }));
3577
- return flatten(allActions);
2396
+ return flatten__default["default"](allActions);
3578
2397
  };
3579
2398
  }
3580
2399
  var customerGroup = (function (actionGroupList) {
@@ -3646,7 +2465,7 @@ function createCartDiscountsMapActions(mapActionGroup, syncActionConfig) {
3646
2465
  allActions.push(mapActionGroup('custom', function () {
3647
2466
  return actionsMapCustom(diff, newObj, oldObj);
3648
2467
  }));
3649
- return combineValidityActions(flatten(allActions));
2468
+ return combineValidityActions(flatten__default["default"](allActions));
3650
2469
  };
3651
2470
  }
3652
2471
  var cartDiscounts = (function (actionGroupList) {
@@ -3659,304 +2478,6 @@ var cartDiscounts = (function (actionGroupList) {
3659
2478
  };
3660
2479
  });
3661
2480
 
3662
- var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
3663
- var keys = Object.keys;
3664
- /**
3665
- * are the values passed strictly equal or both NaN
3666
- *
3667
- * @param a the value to compare against
3668
- * @param b the value to test
3669
- * @returns are the values equal by the SameValueZero principle
3670
- */
3671
- function sameValueZeroEqual(a, b) {
3672
- return a === b || a !== a && b !== b;
3673
- }
3674
- /**
3675
- * is the value a plain object
3676
- *
3677
- * @param value the value to test
3678
- * @returns is the value a plain object
3679
- */
3680
- function isPlainObject(value) {
3681
- return value.constructor === Object || value.constructor == null;
3682
- }
3683
- /**
3684
- * is the value promise-like (meaning it is thenable)
3685
- *
3686
- * @param value the value to test
3687
- * @returns is the value promise-like
3688
- */
3689
- function isPromiseLike(value) {
3690
- return !!value && typeof value.then === 'function';
3691
- }
3692
- /**
3693
- * is the value passed a react element
3694
- *
3695
- * @param value the value to test
3696
- * @returns is the value a react element
3697
- */
3698
- function isReactElement(value) {
3699
- return !!(value && value.$$typeof);
3700
- }
3701
- /**
3702
- * in cases where WeakSet is not supported, creates a new custom
3703
- * object that mimics the necessary API aspects for cache purposes
3704
- *
3705
- * @returns the new cache object
3706
- */
3707
- function getNewCacheFallback() {
3708
- var values = [];
3709
- return {
3710
- add: function add(value) {
3711
- values.push(value);
3712
- },
3713
- has: function has(value) {
3714
- return values.indexOf(value) !== -1;
3715
- }
3716
- };
3717
- }
3718
- /**
3719
- * get a new cache object to prevent circular references
3720
- *
3721
- * @returns the new cache object
3722
- */
3723
- var getNewCache = function (canUseWeakMap) {
3724
- if (canUseWeakMap) {
3725
- return function _getNewCache() {
3726
- return new WeakSet();
3727
- };
3728
- }
3729
- return getNewCacheFallback;
3730
- }(HAS_WEAKSET_SUPPORT);
3731
- /**
3732
- * create a custom isEqual handler specific to circular objects
3733
- *
3734
- * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
3735
- * @returns the method to create the `isEqual` function
3736
- */
3737
- function createCircularEqualCreator(isEqual) {
3738
- return function createCircularEqual(comparator) {
3739
- var _comparator = isEqual || comparator;
3740
- return function circularEqual(a, b, cache) {
3741
- if (cache === void 0) {
3742
- cache = getNewCache();
3743
- }
3744
- var isCacheableA = !!a && _typeof(a) === 'object';
3745
- var isCacheableB = !!b && _typeof(b) === 'object';
3746
- if (isCacheableA || isCacheableB) {
3747
- var hasA = isCacheableA && cache.has(a);
3748
- var hasB = isCacheableB && cache.has(b);
3749
- if (hasA || hasB) {
3750
- return hasA && hasB;
3751
- }
3752
- if (isCacheableA) {
3753
- cache.add(a);
3754
- }
3755
- if (isCacheableB) {
3756
- cache.add(b);
3757
- }
3758
- }
3759
- return _comparator(a, b, cache);
3760
- };
3761
- };
3762
- }
3763
- /**
3764
- * are the arrays equal in value
3765
- *
3766
- * @param a the array to test
3767
- * @param b the array to test against
3768
- * @param isEqual the comparator to determine equality
3769
- * @param meta the meta object to pass through
3770
- * @returns are the arrays equal
3771
- */
3772
- function areArraysEqual(a, b, isEqual, meta) {
3773
- var index = a.length;
3774
- if (b.length !== index) {
3775
- return false;
3776
- }
3777
- while (index-- > 0) {
3778
- if (!isEqual(a[index], b[index], meta)) {
3779
- return false;
3780
- }
3781
- }
3782
- return true;
3783
- }
3784
- /**
3785
- * are the maps equal in value
3786
- *
3787
- * @param a the map to test
3788
- * @param b the map to test against
3789
- * @param isEqual the comparator to determine equality
3790
- * @param meta the meta map to pass through
3791
- * @returns are the maps equal
3792
- */
3793
- function areMapsEqual(a, b, isEqual, meta) {
3794
- var isValueEqual = a.size === b.size;
3795
- if (isValueEqual && a.size) {
3796
- var matchedIndices_1 = {};
3797
- a.forEach(function (aValue, aKey) {
3798
- if (isValueEqual) {
3799
- var hasMatch_1 = false;
3800
- var matchIndex_1 = 0;
3801
- b.forEach(function (bValue, bKey) {
3802
- if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
3803
- hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
3804
- if (hasMatch_1) {
3805
- matchedIndices_1[matchIndex_1] = true;
3806
- }
3807
- }
3808
- matchIndex_1++;
3809
- });
3810
- isValueEqual = hasMatch_1;
3811
- }
3812
- });
3813
- }
3814
- return isValueEqual;
3815
- }
3816
- var OWNER = '_owner';
3817
- var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
3818
- /**
3819
- * are the objects equal in value
3820
- *
3821
- * @param a the object to test
3822
- * @param b the object to test against
3823
- * @param isEqual the comparator to determine equality
3824
- * @param meta the meta object to pass through
3825
- * @returns are the objects equal
3826
- */
3827
- function areObjectsEqual(a, b, isEqual, meta) {
3828
- var keysA = keys(a);
3829
- var index = keysA.length;
3830
- if (keys(b).length !== index) {
3831
- return false;
3832
- }
3833
- if (index) {
3834
- var key = void 0;
3835
- while (index-- > 0) {
3836
- key = keysA[index];
3837
- if (key === OWNER) {
3838
- var reactElementA = isReactElement(a);
3839
- var reactElementB = isReactElement(b);
3840
- if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
3841
- return false;
3842
- }
3843
- }
3844
- if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3845
- return false;
3846
- }
3847
- }
3848
- }
3849
- return true;
3850
- }
3851
- /**
3852
- * are the regExps equal in value
3853
- *
3854
- * @param a the regExp to test
3855
- * @param b the regExp to test agains
3856
- * @returns are the regExps equal
3857
- */
3858
- function areRegExpsEqual(a, b) {
3859
- 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;
3860
- }
3861
- /**
3862
- * are the sets equal in value
3863
- *
3864
- * @param a the set to test
3865
- * @param b the set to test against
3866
- * @param isEqual the comparator to determine equality
3867
- * @param meta the meta set to pass through
3868
- * @returns are the sets equal
3869
- */
3870
- function areSetsEqual(a, b, isEqual, meta) {
3871
- var isValueEqual = a.size === b.size;
3872
- if (isValueEqual && a.size) {
3873
- var matchedIndices_2 = {};
3874
- a.forEach(function (aValue) {
3875
- if (isValueEqual) {
3876
- var hasMatch_2 = false;
3877
- var matchIndex_2 = 0;
3878
- b.forEach(function (bValue) {
3879
- if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
3880
- hasMatch_2 = isEqual(aValue, bValue, meta);
3881
- if (hasMatch_2) {
3882
- matchedIndices_2[matchIndex_2] = true;
3883
- }
3884
- }
3885
- matchIndex_2++;
3886
- });
3887
- isValueEqual = hasMatch_2;
3888
- }
3889
- });
3890
- }
3891
- return isValueEqual;
3892
- }
3893
- var HAS_MAP_SUPPORT = typeof Map === 'function';
3894
- var HAS_SET_SUPPORT = typeof Set === 'function';
3895
- function createComparator(createIsEqual) {
3896
- var isEqual = /* eslint-disable no-use-before-define */
3897
- typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
3898
- /* eslint-enable */
3899
- /**
3900
- * compare the value of the two objects and return true if they are equivalent in values
3901
- *
3902
- * @param a the value to test against
3903
- * @param b the value to test
3904
- * @param [meta] an optional meta object that is passed through to all equality test calls
3905
- * @returns are a and b equivalent in value
3906
- */
3907
- function comparator(a, b, meta) {
3908
- if (a === b) {
3909
- return true;
3910
- }
3911
- if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3912
- if (isPlainObject(a) && isPlainObject(b)) {
3913
- return areObjectsEqual(a, b, isEqual, meta);
3914
- }
3915
- var aShape = Array.isArray(a);
3916
- var bShape = Array.isArray(b);
3917
- if (aShape || bShape) {
3918
- return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3919
- }
3920
- aShape = a instanceof Date;
3921
- bShape = b instanceof Date;
3922
- if (aShape || bShape) {
3923
- return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3924
- }
3925
- aShape = a instanceof RegExp;
3926
- bShape = b instanceof RegExp;
3927
- if (aShape || bShape) {
3928
- return aShape === bShape && areRegExpsEqual(a, b);
3929
- }
3930
- if (isPromiseLike(a) || isPromiseLike(b)) {
3931
- return a === b;
3932
- }
3933
- if (HAS_MAP_SUPPORT) {
3934
- aShape = a instanceof Map;
3935
- bShape = b instanceof Map;
3936
- if (aShape || bShape) {
3937
- return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3938
- }
3939
- }
3940
- if (HAS_SET_SUPPORT) {
3941
- aShape = a instanceof Set;
3942
- bShape = b instanceof Set;
3943
- if (aShape || bShape) {
3944
- return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3945
- }
3946
- }
3947
- return areObjectsEqual(a, b, isEqual, meta);
3948
- }
3949
- return a !== a && b !== b;
3950
- }
3951
- return comparator;
3952
- }
3953
- var deepEqual = createComparator();
3954
- createComparator(function () {
3955
- return sameValueZeroEqual;
3956
- });
3957
- createComparator(createCircularEqualCreator());
3958
- createComparator(createCircularEqualCreator(sameValueZeroEqual));
3959
-
3960
2481
  var _excluded = ["__typename"];
3961
2482
  function removeTypename(obj) {
3962
2483
  obj.__typename;
@@ -4007,7 +2528,7 @@ function actionsMapRates(diff, oldObj, newObj) {
4007
2528
  var oldObjectWithoutTypename = _objectSpread2(_objectSpread2({}, taxCategoryWithoutTypeName), {}, {
4008
2529
  subRates: oldObjectSubRatesWithoutTypename
4009
2530
  });
4010
- if (deepEqual(oldObjectWithoutTypename, updatedObject)) return null;
2531
+ if (fastEquals.deepEqual(oldObjectWithoutTypename, updatedObject)) return null;
4011
2532
  return {
4012
2533
  action: 'replaceTaxRate',
4013
2534
  taxRateId: oldObject.id === updatedObject.id ? oldObject.id : updatedObject.id,
@@ -4026,7 +2547,7 @@ function createTaxCategoriesMapActions(mapActionGroup, syncActionConfig) {
4026
2547
  allActions.push(mapActionGroup('rates', function () {
4027
2548
  return actionsMapRates(diff, oldObj, newObj);
4028
2549
  }));
4029
- return flatten(allActions);
2550
+ return flatten__default["default"](allActions);
4030
2551
  };
4031
2552
  }
4032
2553
  var taxCategories = (function (actionGroupList, syncActionConfig) {
@@ -4117,10 +2638,10 @@ function createZonesMapActions(mapActionGroup, syncActionConfig) {
4117
2638
  allActions.push(mapActionGroup('base', function () {
4118
2639
  return actionsMapBase$a(diff, oldObj, newObj, syncActionConfig);
4119
2640
  }));
4120
- allActions.push(flatten(mapActionGroup('locations', function () {
2641
+ allActions.push(flatten__default["default"](mapActionGroup('locations', function () {
4121
2642
  return actionsMapLocations(diff, oldObj, newObj);
4122
2643
  })));
4123
- return flatten(allActions);
2644
+ return flatten__default["default"](allActions);
4124
2645
  };
4125
2646
  }
4126
2647
  var zones = (function (actionGroupList, syncActionConfig) {
@@ -4236,7 +2757,7 @@ function actionsMapZoneRates(diff, oldObj, newObj) {
4236
2757
  if (diff.zoneRates[key].shippingRates) return [].concat(_toConsumableArray(actions), _toConsumableArray(actionsMapZoneRatesShippingRates(diff.zoneRates[key], oldZoneRate, newZoneRate)));
4237
2758
  return actions;
4238
2759
  }, []);
4239
- return flatten(hasZoneActions ? [].concat(_toConsumableArray(shippingRateActions), [{
2760
+ return flatten__default["default"](hasZoneActions ? [].concat(_toConsumableArray(shippingRateActions), [{
4240
2761
  action: 'removeZone',
4241
2762
  zone: oldZoneRate.zone
4242
2763
  }, {
@@ -4253,13 +2774,13 @@ function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
4253
2774
  allActions.push(mapActionGroup('base', function () {
4254
2775
  return actionsMapBase$9(diff, oldObj, newObj, syncActionConfig);
4255
2776
  }));
4256
- allActions.push(flatten(mapActionGroup('zoneRates', function () {
2777
+ allActions.push(flatten__default["default"](mapActionGroup('zoneRates', function () {
4257
2778
  return actionsMapZoneRates(diff, oldObj, newObj);
4258
2779
  })));
4259
2780
  allActions.push(mapActionGroup('custom', function () {
4260
2781
  return actionsMapCustom(diff, newObj, oldObj);
4261
2782
  }));
4262
- return flatten(allActions);
2783
+ return flatten__default["default"](allActions);
4263
2784
  };
4264
2785
  }
4265
2786
  var shippingMethods = (function (actionGroupList, syncActionConfig) {
@@ -4320,7 +2841,7 @@ var generateBaseFieldsUpdateActions = function generateBaseFieldsUpdateActions(p
4320
2841
  actionFieldDefinition = _ref2[1];
4321
2842
  if (isEmpty(previous[field]) && isEmpty(next[field])) return nextUpdateActions;
4322
2843
  if (!isEmpty(previous[field]) && isEmpty(next[field])) return [].concat(_toConsumableArray(nextUpdateActions), [actionFieldDefinition]);
4323
- if (!deepEqual(previous[field], next[field])) {
2844
+ if (!fastEquals.deepEqual(previous[field], next[field])) {
4324
2845
  switch (field) {
4325
2846
  // BEWARE that this is generates update-action only for key of enum attribute value,
4326
2847
  // not key of product type. If we need to re-factor `product-types` sync actions to use
@@ -4391,7 +2912,7 @@ var generateUpdateActionsForAttributeDefinitions = function generateUpdateAction
4391
2912
  action: 'removeAttributeDefinition',
4392
2913
  name: attributeDef.previous.name
4393
2914
  };
4394
- })), _toConsumableArray(flatten(updatedAttributeDefinitions.map(function (updatedAttributeDefinition) {
2915
+ })), _toConsumableArray(flatten__default["default"](updatedAttributeDefinitions.map(function (updatedAttributeDefinition) {
4395
2916
  return generateBaseFieldsUpdateActions(updatedAttributeDefinition.previous, updatedAttributeDefinition.next, {
4396
2917
  label: {
4397
2918
  action: 'changeLabel',
@@ -4441,14 +2962,14 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
4441
2962
  return _objectSpread2(_objectSpread2({}, nextEnumUpdateActions), {}, _defineProperty({}, removedAttributeEnumValue.hint.attributeName, _objectSpread2(_objectSpread2({}, removedAttributeEnumValueOfSameAttributeName), {}, {
4442
2963
  keys: [].concat(_toConsumableArray(removedAttributeEnumValueOfSameAttributeName.keys), [removedAttributeEnumValue.previous.key])
4443
2964
  })));
4444
- }, {}))), _toConsumableArray(flatten(updatedAttributeEnumValues.map(function (updatedAttributeEnumValue) {
2965
+ }, {}))), _toConsumableArray(flatten__default["default"](updatedAttributeEnumValues.map(function (updatedAttributeEnumValue) {
4445
2966
  var updateActions = generateBaseFieldsUpdateActions(updatedAttributeEnumValue.previous, updatedAttributeEnumValue.next, {
4446
2967
  key: {
4447
2968
  action: 'changeEnumKey',
4448
2969
  attributeName: updatedAttributeEnumValue.hint.attributeName
4449
2970
  }
4450
2971
  });
4451
- if (!deepEqual(updatedAttributeEnumValue.previous.label, updatedAttributeEnumValue.next.label)) {
2972
+ if (!fastEquals.deepEqual(updatedAttributeEnumValue.previous.label, updatedAttributeEnumValue.next.label)) {
4452
2973
  if (updatedAttributeEnumValue.hint.isLocalized) {
4453
2974
  return [].concat(_toConsumableArray(updateActions), [{
4454
2975
  action: 'changeLocalizedEnumValueLabel',
@@ -4515,7 +3036,7 @@ var actionsMapForHints = function actionsMapForHints() {
4515
3036
 
4516
3037
  function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
4517
3038
  return function doMapActions(diff, next, previous, options) {
4518
- return flatten([
3039
+ return flatten__default["default"]([
4519
3040
  // we support only base fields for the product type,
4520
3041
  // for attributes, applying hints would be recommended
4521
3042
  mapActionGroup('base', function () {
@@ -4611,7 +3132,7 @@ function createStatesMapActions(mapActionGroup, syncActionConfig) {
4611
3132
  roleActions.push(mapActionGroup('roles', function () {
4612
3133
  return actionsMapRoles(diff, oldObj, newObj);
4613
3134
  }));
4614
- return flatten([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
3135
+ return flatten__default["default"]([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
4615
3136
  };
4616
3137
  }
4617
3138
  var states = (function (actionGroupList, syncActionConfig) {
@@ -4664,7 +3185,7 @@ function createChannelsMapActions$1(mapActionGroup, syncActionConfig) {
4664
3185
  allActions.push(mapActionGroup('custom', function () {
4665
3186
  return actionsMapCustom(diff, newObj, oldObj);
4666
3187
  }));
4667
- return flatten(allActions);
3188
+ return flatten__default["default"](allActions);
4668
3189
  };
4669
3190
  }
4670
3191
  var channels = (function (actionGroupList) {
@@ -4735,7 +3256,7 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
4735
3256
  var foundPreviousEnum = previous.values.find(function (previousEnum) {
4736
3257
  return previousEnum.key === newEnum.key;
4737
3258
  });
4738
- var isLabelEqual = isEqual(foundPreviousEnum.label, newEnum.label);
3259
+ var isLabelEqual = isEqual__default["default"](foundPreviousEnum.label, newEnum.label);
4739
3260
  if (isKeyChanged) {
4740
3261
  // these actions is then flatten in the end
4741
3262
  changeActions.push({
@@ -4764,7 +3285,7 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
4764
3285
  // following lists are necessary to ensure that when we change the
4765
3286
  // order of enumValues, we generate one updateAction instead of one at a time.
4766
3287
  var newEnumValuesOrder = [];
4767
- flatten(buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
3288
+ flatten__default["default"](buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
4768
3289
  if (updateAction.action === changeEnumOrderActionName) {
4769
3290
  newEnumValuesOrder = next.values.map(function (enumValue) {
4770
3291
  return enumValue.key;
@@ -4779,7 +3300,7 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
4779
3300
  }
4780
3301
  function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPaths) {
4781
3302
  var actions = [];
4782
- forEach(fieldDefinitionsDiff, function (diffValue, diffKey) {
3303
+ forEach__default["default"](fieldDefinitionsDiff, function (diffValue, diffKey) {
4783
3304
  var extractedPairs = extractMatchingPairs(diffPaths, diffKey, previous, next);
4784
3305
  if (getIsChangedOperation(diffKey)) {
4785
3306
  var _diffValue$type;
@@ -4829,8 +3350,8 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
4829
3350
  // Make sure to execute removeActions before creating new ones
4830
3351
  // in order to prevent any eventual removal of `addAction`.
4831
3352
  // List of `removeActions` can be found here
4832
- // https://docs.commercetools.com/http-api-projects-types.html#change-key
4833
- var sortedActions = sortBy(actions, function (action) {
3353
+ // https://docs.commercetools.com/api/projects/types#change-key
3354
+ var sortedActions = sortBy__default["default"](actions, function (action) {
4834
3355
  return action.action !== 'removeFieldDefinition';
4835
3356
  });
4836
3357
  return sortedActions;
@@ -4844,7 +3365,7 @@ function createTypeMapActions(mapActionGroup, syncActionConfig) {
4844
3365
  }), mapActionGroup('fieldDefinitions', function () {
4845
3366
  return actionsMapFieldDefinitions(diff.fieldDefinitions, previous.fieldDefinitions, next.fieldDefinitions, findMatchingPairs(diff.fieldDefinitions, previous.fieldDefinitions, next.fieldDefinitions, 'name'));
4846
3367
  }));
4847
- return flatten(allActions);
3368
+ return flatten__default["default"](allActions);
4848
3369
  };
4849
3370
  }
4850
3371
  var types = (function (actionGroupList, syncActionConfig) {
@@ -4888,6 +3409,10 @@ var customerSearchActionsList = [{
4888
3409
  action: 'changeCustomerSearchStatus',
4889
3410
  key: 'status'
4890
3411
  }];
3412
+ var businessUnitSearchActionsList = [{
3413
+ action: 'changeBusinessUnitSearchStatus',
3414
+ key: 'status'
3415
+ }];
4891
3416
  function actionsMapBase$4(diff, oldObj, newObj) {
4892
3417
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4893
3418
  return buildBaseAttributesActions({
@@ -4919,11 +3444,21 @@ function actionsMapSearchIndexingConfiguration(diff, oldObj, newObj) {
4919
3444
  if (!searchIndexing) {
4920
3445
  return [];
4921
3446
  }
4922
- var customers = searchIndexing.customers;
4923
- if (!customers) {
3447
+ var businessUnits = searchIndexing.businessUnits,
3448
+ customers = searchIndexing.customers;
3449
+ if (!customers && !businessUnits) {
4924
3450
  return [];
4925
3451
  }
4926
- return buildBaseAttributesActions({
3452
+ var businessUnitsActions = businessUnits ? buildBaseAttributesActions({
3453
+ actions: businessUnitSearchActionsList,
3454
+ diff: diff.searchIndexing.businessUnits,
3455
+ oldObj: oldObj.searchIndexing.businessUnits,
3456
+ newObj: newObj.searchIndexing.businessUnits,
3457
+ shouldOmitEmptyString: config.shouldOmitEmptyString,
3458
+ shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties,
3459
+ shouldPreventUnsettingRequiredFields: config.shouldPreventUnsettingRequiredFields
3460
+ }) : [];
3461
+ var customersActions = customers ? buildBaseAttributesActions({
4927
3462
  actions: customerSearchActionsList,
4928
3463
  diff: diff.searchIndexing.customers,
4929
3464
  oldObj: oldObj.searchIndexing.customers,
@@ -4931,7 +3466,8 @@ function actionsMapSearchIndexingConfiguration(diff, oldObj, newObj) {
4931
3466
  shouldOmitEmptyString: config.shouldOmitEmptyString,
4932
3467
  shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties,
4933
3468
  shouldPreventUnsettingRequiredFields: config.shouldPreventUnsettingRequiredFields
4934
- });
3469
+ }) : [];
3470
+ return [].concat(_toConsumableArray(businessUnitsActions), _toConsumableArray(customersActions));
4935
3471
  }
4936
3472
 
4937
3473
  function createChannelsMapActions(mapActionGroup, syncActionConfig) {
@@ -4946,7 +3482,7 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
4946
3482
  allActions.push(mapActionGroup('searchIndexingConfiguration', function () {
4947
3483
  return actionsMapSearchIndexingConfiguration(diff, oldObj, newObj);
4948
3484
  }));
4949
- return flatten(allActions);
3485
+ return flatten__default["default"](allActions);
4950
3486
  };
4951
3487
  }
4952
3488
  var projects = (function (actionGroupList) {
@@ -4994,7 +3530,7 @@ function createStoresMapActions(mapActionGroup) {
4994
3530
  allActions.push(mapActionGroup('custom', function () {
4995
3531
  return actionsMapCustom(diff, next, previous);
4996
3532
  }));
4997
- return flatten(allActions);
3533
+ return flatten__default["default"](allActions);
4998
3534
  };
4999
3535
  }
5000
3536
  var stores = (function (actionGroupList) {
@@ -5037,7 +3573,7 @@ function createProductSelectionsMapActions(mapActionGroup) {
5037
3573
  allActions.push(mapActionGroup('custom', function () {
5038
3574
  return actionsMapCustom(diff, next, previous);
5039
3575
  }));
5040
- return flatten(allActions);
3576
+ return flatten__default["default"](allActions);
5041
3577
  };
5042
3578
  }
5043
3579
  var productSelections = (function (actionGroupList) {
@@ -5172,10 +3708,10 @@ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
5172
3708
  allActions.push(mapActionGroup('base', function () {
5173
3709
  return actionsMapBase(diff, oldObj, newObj, syncActionConfig);
5174
3710
  }));
5175
- allActions.push(flatten(mapActionGroup('attributes', function () {
3711
+ allActions.push(flatten__default["default"](mapActionGroup('attributes', function () {
5176
3712
  return actionsMapAttributes(diff, oldObj, newObj);
5177
3713
  })));
5178
- return flatten(allActions);
3714
+ return flatten__default["default"](allActions);
5179
3715
  };
5180
3716
  }
5181
3717
  var attributeGroups = (function (actionGroupList, syncActionConfig) {
@@ -5201,6 +3737,7 @@ exports.createSyncProductSelections = productSelections;
5201
3737
  exports.createSyncProductTypes = productTypes;
5202
3738
  exports.createSyncProducts = products;
5203
3739
  exports.createSyncProjects = projects;
3740
+ exports.createSyncRecurringOrders = recurringOrders;
5204
3741
  exports.createSyncShippingMethods = shippingMethods;
5205
3742
  exports.createSyncStandalonePrices = prices;
5206
3743
  exports.createSyncStates = states;