@commercetools/sync-actions 7.0.0-rc.2 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/{sync-actions.cjs.js → commercetools-sync-actions.cjs.dev.js} +323 -1786
- package/dist/commercetools-sync-actions.cjs.js +7 -0
- package/dist/commercetools-sync-actions.cjs.prod.js +3747 -0
- package/dist/{sync-actions.es.js → commercetools-sync-actions.esm.js} +227 -1723
- package/package.json +16 -11
- package/dist/sync-actions.umd.js +0 -5207
- package/dist/sync-actions.umd.min.js +0 -1
- package/lib/cart-discounts-actions.js +0 -31
- package/lib/cart-discounts.js +0 -70
- package/lib/categories.js +0 -106
- package/lib/category-actions.js +0 -117
- package/lib/channels.js +0 -0
- package/lib/customer-actions.js +0 -125
- package/lib/customer-group-actions.js +0 -23
- package/lib/customer-group.js +0 -70
- package/lib/customers.js +0 -95
- package/lib/discount-codes-actions.js +0 -31
- package/lib/discount-codes.js +0 -80
- package/lib/index.js +0 -90
- package/lib/inventories.js +0 -89
- package/lib/inventory-actions.js +0 -42
- package/lib/order-actions.js +0 -71
- package/lib/orders.js +0 -89
- package/lib/product-actions.js +0 -779
- package/lib/product-discounts-actions.js +0 -27
- package/lib/product-discounts.js +0 -71
- package/lib/products.js +0 -208
- package/lib/utils/clone.js +0 -9
- package/lib/utils/common-actions.js +0 -157
- package/lib/utils/create-build-actions.js +0 -74
- package/lib/utils/create-build-array-actions.js +0 -146
- package/lib/utils/create-map-action-group.js +0 -35
- package/lib/utils/diffpatcher.js +0 -93
- package/lib/utils/find-matching-pairs.js +0 -67
|
@@ -1,89 +1,18 @@
|
|
|
1
1
|
import flatten from 'lodash.flatten';
|
|
2
2
|
import isEqual from 'lodash.isequal';
|
|
3
3
|
import isNil from 'lodash.isnil';
|
|
4
|
+
import * as jsondiffpatch from 'jsondiffpatch';
|
|
4
5
|
import forEach from 'lodash.foreach';
|
|
5
6
|
import uniqWith from 'lodash.uniqwith';
|
|
6
7
|
import intersection from 'lodash.intersection';
|
|
7
8
|
import without from 'lodash.without';
|
|
9
|
+
import { deepEqual } from 'fast-equals';
|
|
8
10
|
import sortBy from 'lodash.sortby';
|
|
9
11
|
|
|
10
|
-
function _arrayLikeToArray(r, a) {
|
|
11
|
-
(null == a || a > r.length) && (a = r.length);
|
|
12
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
13
|
-
return n;
|
|
14
|
-
}
|
|
15
12
|
function _arrayWithHoles(r) {
|
|
16
13
|
if (Array.isArray(r)) return r;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
20
|
-
}
|
|
21
|
-
function _assertThisInitialized(e) {
|
|
22
|
-
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
25
|
-
function _callSuper(t, o, e) {
|
|
26
|
-
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
27
|
-
}
|
|
28
|
-
function _classCallCheck(a, n) {
|
|
29
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
30
|
-
}
|
|
31
|
-
function _defineProperties(e, r) {
|
|
32
|
-
for (var t = 0; t < r.length; t++) {
|
|
33
|
-
var o = r[t];
|
|
34
|
-
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function _createClass(e, r, t) {
|
|
38
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
39
|
-
writable: false
|
|
40
|
-
}), e;
|
|
41
|
-
}
|
|
42
|
-
function _defineProperty(e, r, t) {
|
|
43
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
44
|
-
value: t,
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true
|
|
48
|
-
}) : e[r] = t, e;
|
|
49
|
-
}
|
|
50
|
-
function _get() {
|
|
51
|
-
return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
|
|
52
|
-
var p = _superPropBase(e, t);
|
|
53
|
-
if (p) {
|
|
54
|
-
var n = Object.getOwnPropertyDescriptor(p, t);
|
|
55
|
-
return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
|
|
56
|
-
}
|
|
57
|
-
}, _get.apply(null, arguments);
|
|
58
|
-
}
|
|
59
|
-
function _getPrototypeOf(t) {
|
|
60
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
61
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
|
62
|
-
}, _getPrototypeOf(t);
|
|
63
|
-
}
|
|
64
|
-
function _inherits(t, e) {
|
|
65
|
-
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
66
|
-
t.prototype = Object.create(e && e.prototype, {
|
|
67
|
-
constructor: {
|
|
68
|
-
value: t,
|
|
69
|
-
writable: true,
|
|
70
|
-
configurable: true
|
|
71
|
-
}
|
|
72
|
-
}), Object.defineProperty(t, "prototype", {
|
|
73
|
-
writable: false
|
|
74
|
-
}), e && _setPrototypeOf(t, e);
|
|
75
|
-
}
|
|
76
|
-
function _isNativeReflectConstruct() {
|
|
77
|
-
try {
|
|
78
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
79
|
-
} catch (t) {}
|
|
80
|
-
return (_isNativeReflectConstruct = function () {
|
|
81
|
-
return !!t;
|
|
82
|
-
})();
|
|
83
|
-
}
|
|
84
|
-
function _iterableToArray(r) {
|
|
85
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
86
|
-
}
|
|
15
|
+
|
|
87
16
|
function _iterableToArrayLimit(r, l) {
|
|
88
17
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
89
18
|
if (null != t) {
|
|
@@ -92,15 +21,15 @@ function _iterableToArrayLimit(r, l) {
|
|
|
92
21
|
i,
|
|
93
22
|
u,
|
|
94
23
|
a = [],
|
|
95
|
-
f =
|
|
96
|
-
o =
|
|
24
|
+
f = !0,
|
|
25
|
+
o = !1;
|
|
97
26
|
try {
|
|
98
27
|
if (i = (t = t.call(r)).next, 0 === l) {
|
|
99
28
|
if (Object(t) !== t) return;
|
|
100
29
|
f = !1;
|
|
101
30
|
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
102
31
|
} catch (r) {
|
|
103
|
-
o =
|
|
32
|
+
o = !0, n = r;
|
|
104
33
|
} finally {
|
|
105
34
|
try {
|
|
106
35
|
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
@@ -111,12 +40,54 @@ function _iterableToArrayLimit(r, l) {
|
|
|
111
40
|
return a;
|
|
112
41
|
}
|
|
113
42
|
}
|
|
43
|
+
|
|
44
|
+
function _arrayLikeToArray(r, a) {
|
|
45
|
+
(null == a || a > r.length) && (a = r.length);
|
|
46
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
47
|
+
return n;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _unsupportedIterableToArray(r, a) {
|
|
51
|
+
if (r) {
|
|
52
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
53
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
54
|
+
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;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
114
58
|
function _nonIterableRest() {
|
|
115
59
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
116
60
|
}
|
|
117
|
-
|
|
118
|
-
|
|
61
|
+
|
|
62
|
+
function _slicedToArray(r, e) {
|
|
63
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _toPrimitive(t, r) {
|
|
67
|
+
if ("object" != typeof t || !t) return t;
|
|
68
|
+
var e = t[Symbol.toPrimitive];
|
|
69
|
+
if (void 0 !== e) {
|
|
70
|
+
var i = e.call(t, r || "default");
|
|
71
|
+
if ("object" != typeof i) return i;
|
|
72
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
73
|
+
}
|
|
74
|
+
return ("string" === r ? String : Number)(t);
|
|
119
75
|
}
|
|
76
|
+
|
|
77
|
+
function _toPropertyKey(t) {
|
|
78
|
+
var i = _toPrimitive(t, "string");
|
|
79
|
+
return "symbol" == typeof i ? i : i + "";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function _defineProperty(e, r, t) {
|
|
83
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
84
|
+
value: t,
|
|
85
|
+
enumerable: !0,
|
|
86
|
+
configurable: !0,
|
|
87
|
+
writable: !0
|
|
88
|
+
}) : e[r] = t, e;
|
|
89
|
+
}
|
|
90
|
+
|
|
120
91
|
function ownKeys(e, r) {
|
|
121
92
|
var t = Object.keys(e);
|
|
122
93
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -130,7 +101,7 @@ function ownKeys(e, r) {
|
|
|
130
101
|
function _objectSpread2(e) {
|
|
131
102
|
for (var r = 1; r < arguments.length; r++) {
|
|
132
103
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
133
|
-
r % 2 ? ownKeys(Object(t),
|
|
104
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
134
105
|
_defineProperty(e, r, t[r]);
|
|
135
106
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
136
107
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
@@ -138,17 +109,7 @@ function _objectSpread2(e) {
|
|
|
138
109
|
}
|
|
139
110
|
return e;
|
|
140
111
|
}
|
|
141
|
-
|
|
142
|
-
if (null == e) return {};
|
|
143
|
-
var o,
|
|
144
|
-
r,
|
|
145
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
146
|
-
if (Object.getOwnPropertySymbols) {
|
|
147
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
148
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
149
|
-
}
|
|
150
|
-
return i;
|
|
151
|
-
}
|
|
112
|
+
|
|
152
113
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
153
114
|
if (null == r) return {};
|
|
154
115
|
var t = {};
|
|
@@ -158,61 +119,17 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
158
119
|
}
|
|
159
120
|
return t;
|
|
160
121
|
}
|
|
161
|
-
function _possibleConstructorReturn(t, e) {
|
|
162
|
-
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
163
|
-
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
164
|
-
return _assertThisInitialized(t);
|
|
165
|
-
}
|
|
166
|
-
function _setPrototypeOf(t, e) {
|
|
167
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
168
|
-
return t.__proto__ = e, t;
|
|
169
|
-
}, _setPrototypeOf(t, e);
|
|
170
|
-
}
|
|
171
|
-
function _slicedToArray(r, e) {
|
|
172
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
173
|
-
}
|
|
174
|
-
function _superPropBase(t, o) {
|
|
175
|
-
for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
|
|
176
|
-
return t;
|
|
177
|
-
}
|
|
178
|
-
function _superPropGet(t, o, e, r) {
|
|
179
|
-
var p = _get(_getPrototypeOf(t.prototype ), o, e);
|
|
180
|
-
return 2 & r && "function" == typeof p ? function (t) {
|
|
181
|
-
return p.apply(e, t);
|
|
182
|
-
} : p;
|
|
183
|
-
}
|
|
184
|
-
function _toConsumableArray(r) {
|
|
185
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
186
|
-
}
|
|
187
|
-
function _toPrimitive(t, r) {
|
|
188
|
-
if ("object" != typeof t || !t) return t;
|
|
189
|
-
var e = t[Symbol.toPrimitive];
|
|
190
|
-
if (void 0 !== e) {
|
|
191
|
-
var i = e.call(t, r);
|
|
192
|
-
if ("object" != typeof i) return i;
|
|
193
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
194
|
-
}
|
|
195
|
-
return (String )(t);
|
|
196
|
-
}
|
|
197
|
-
function _toPropertyKey(t) {
|
|
198
|
-
var i = _toPrimitive(t, "string");
|
|
199
|
-
return "symbol" == typeof i ? i : i + "";
|
|
200
|
-
}
|
|
201
|
-
function _typeof(o) {
|
|
202
|
-
"@babel/helpers - typeof";
|
|
203
122
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
213
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
214
|
-
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;
|
|
123
|
+
function _objectWithoutProperties(e, t) {
|
|
124
|
+
if (null == e) return {};
|
|
125
|
+
var o,
|
|
126
|
+
r,
|
|
127
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
128
|
+
if (Object.getOwnPropertySymbols) {
|
|
129
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
130
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
215
131
|
}
|
|
132
|
+
return i;
|
|
216
133
|
}
|
|
217
134
|
|
|
218
135
|
var _excluded$2 = ["prices"];
|
|
@@ -251,1270 +168,92 @@ function injectMissingPriceIds(nextVariants, previousVariants) {
|
|
|
251
168
|
var oldVariant = previousVariants.find(function (previousVariant) {
|
|
252
169
|
return !isNil(previousVariant.id) && previousVariant.id === newVariant.id || !isNil(previousVariant.key) && previousVariant.key === newVariant.key || !isNil(previousVariant.sku) && previousVariant.sku === newVariant.sku;
|
|
253
170
|
});
|
|
254
|
-
return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
|
|
255
|
-
prices: prices.map(function (price) {
|
|
256
|
-
var newPrice = _objectSpread2({}, price);
|
|
257
|
-
var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
|
|
258
|
-
if (oldPrice) {
|
|
259
|
-
// copy ID if not provided
|
|
260
|
-
if (!newPrice.id) newPrice.id = oldPrice.id;
|
|
261
|
-
if (isNil(newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
|
|
262
|
-
if (isNil(newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
|
|
263
|
-
}
|
|
264
|
-
return newPrice;
|
|
265
|
-
})
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
function createBuildActions(differ, doMapActions, onBeforeDiff) {
|
|
270
|
-
var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
271
|
-
return function buildActions(now, before) {
|
|
272
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
273
|
-
if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
|
|
274
|
-
var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
|
|
275
|
-
_applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
|
|
276
|
-
processedBefore = _applyOnBeforeDiff2[0],
|
|
277
|
-
processedNow = _applyOnBeforeDiff2[1];
|
|
278
|
-
if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
|
|
279
|
-
var diffed = differ(processedBefore, processedNow);
|
|
280
|
-
if (!buildActionsConfig.withHints && !diffed) return [];
|
|
281
|
-
return doMapActions(diffed, processedNow, processedBefore, options);
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Array of action groups which need to be allowed or ignored.
|
|
286
|
-
// Example:
|
|
287
|
-
// [
|
|
288
|
-
// { type: 'base', group: 'ignore' },
|
|
289
|
-
// { type: 'prices', group: 'allow' },
|
|
290
|
-
// { type: 'variants', group: 'ignore' },
|
|
291
|
-
// ]
|
|
292
|
-
function createMapActionGroup() {
|
|
293
|
-
var actionGroups = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
294
|
-
return function mapActionGroup(type, fn) {
|
|
295
|
-
if (!Object.keys(actionGroups).length) return fn();
|
|
296
|
-
var found = actionGroups.find(function (c) {
|
|
297
|
-
return c.type === type;
|
|
298
|
-
});
|
|
299
|
-
if (!found) return [];
|
|
300
|
-
|
|
301
|
-
// Keep `black` for backwards compatibility.
|
|
302
|
-
if (found.group === 'ignore' || found.group === 'black') return [];
|
|
303
|
-
// Keep `white` for backwards compatibility.
|
|
304
|
-
if (found.group === 'allow' || found.group === 'white') return fn();
|
|
305
|
-
throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
var Processor = /*#__PURE__*/function () {
|
|
310
|
-
function Processor(options) {
|
|
311
|
-
_classCallCheck(this, Processor);
|
|
312
|
-
this.selfOptions = options || {};
|
|
313
|
-
this.pipes = {};
|
|
314
|
-
}
|
|
315
|
-
return _createClass(Processor, [{
|
|
316
|
-
key: "options",
|
|
317
|
-
value: function options(_options) {
|
|
318
|
-
if (_options) {
|
|
319
|
-
this.selfOptions = _options;
|
|
320
|
-
}
|
|
321
|
-
return this.selfOptions;
|
|
322
|
-
}
|
|
323
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
-
}, {
|
|
325
|
-
key: "pipe",
|
|
326
|
-
value: function pipe(name, pipeArg) {
|
|
327
|
-
var pipe = pipeArg;
|
|
328
|
-
if (typeof name === 'string') {
|
|
329
|
-
if (typeof pipe === 'undefined') {
|
|
330
|
-
return this.pipes[name];
|
|
331
|
-
} else {
|
|
332
|
-
this.pipes[name] = pipe;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
if (name && name.name) {
|
|
336
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
|
-
pipe = name;
|
|
338
|
-
if (pipe.processor === this) {
|
|
339
|
-
return pipe;
|
|
340
|
-
}
|
|
341
|
-
this.pipes[pipe.name] = pipe;
|
|
342
|
-
}
|
|
343
|
-
pipe.processor = this;
|
|
344
|
-
return pipe;
|
|
345
|
-
}
|
|
346
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
347
|
-
}, {
|
|
348
|
-
key: "process",
|
|
349
|
-
value: function process(input, pipe) {
|
|
350
|
-
var context = input;
|
|
351
|
-
context.options = this.options();
|
|
352
|
-
var nextPipe = pipe || input.pipe || 'default';
|
|
353
|
-
var lastPipe;
|
|
354
|
-
while (nextPipe) {
|
|
355
|
-
if (typeof context.nextAfterChildren !== 'undefined') {
|
|
356
|
-
// children processed and coming back to parent
|
|
357
|
-
context.next = context.nextAfterChildren;
|
|
358
|
-
context.nextAfterChildren = null;
|
|
359
|
-
}
|
|
360
|
-
if (typeof nextPipe === 'string') {
|
|
361
|
-
nextPipe = this.pipe(nextPipe);
|
|
362
|
-
}
|
|
363
|
-
nextPipe.process(context);
|
|
364
|
-
lastPipe = nextPipe;
|
|
365
|
-
nextPipe = null;
|
|
366
|
-
if (context) {
|
|
367
|
-
if (context.next) {
|
|
368
|
-
context = context.next;
|
|
369
|
-
nextPipe = context.pipe || lastPipe;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
374
|
-
return context.hasResult ? context.result : undefined;
|
|
375
|
-
}
|
|
376
|
-
}]);
|
|
377
|
-
}();
|
|
378
|
-
|
|
379
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
380
|
-
var Pipe = /*#__PURE__*/function () {
|
|
381
|
-
function Pipe(name) {
|
|
382
|
-
_classCallCheck(this, Pipe);
|
|
383
|
-
this.name = name;
|
|
384
|
-
this.filters = [];
|
|
385
|
-
}
|
|
386
|
-
return _createClass(Pipe, [{
|
|
387
|
-
key: "process",
|
|
388
|
-
value: function process(input) {
|
|
389
|
-
if (!this.processor) {
|
|
390
|
-
throw new Error('add this pipe to a processor before using it');
|
|
391
|
-
}
|
|
392
|
-
var debug = this.debug;
|
|
393
|
-
var length = this.filters.length;
|
|
394
|
-
var context = input;
|
|
395
|
-
for (var index = 0; index < length; index++) {
|
|
396
|
-
var filter = this.filters[index];
|
|
397
|
-
if (debug) {
|
|
398
|
-
this.log("filter: ".concat(filter.filterName));
|
|
399
|
-
}
|
|
400
|
-
filter(context);
|
|
401
|
-
if (_typeof(context) === 'object' && context.exiting) {
|
|
402
|
-
context.exiting = false;
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (!context.next && this.resultCheck) {
|
|
407
|
-
this.resultCheck(context);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}, {
|
|
411
|
-
key: "log",
|
|
412
|
-
value: function log(msg) {
|
|
413
|
-
console.log("[jsondiffpatch] ".concat(this.name, " pipe, ").concat(msg));
|
|
414
|
-
}
|
|
415
|
-
}, {
|
|
416
|
-
key: "append",
|
|
417
|
-
value: function append() {
|
|
418
|
-
var _this$filters;
|
|
419
|
-
(_this$filters = this.filters).push.apply(_this$filters, arguments);
|
|
420
|
-
return this;
|
|
421
|
-
}
|
|
422
|
-
}, {
|
|
423
|
-
key: "prepend",
|
|
424
|
-
value: function prepend() {
|
|
425
|
-
var _this$filters2;
|
|
426
|
-
(_this$filters2 = this.filters).unshift.apply(_this$filters2, arguments);
|
|
427
|
-
return this;
|
|
428
|
-
}
|
|
429
|
-
}, {
|
|
430
|
-
key: "indexOf",
|
|
431
|
-
value: function indexOf(filterName) {
|
|
432
|
-
if (!filterName) {
|
|
433
|
-
throw new Error('a filter name is required');
|
|
434
|
-
}
|
|
435
|
-
for (var index = 0; index < this.filters.length; index++) {
|
|
436
|
-
var filter = this.filters[index];
|
|
437
|
-
if (filter.filterName === filterName) {
|
|
438
|
-
return index;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
throw new Error("filter not found: ".concat(filterName));
|
|
442
|
-
}
|
|
443
|
-
}, {
|
|
444
|
-
key: "list",
|
|
445
|
-
value: function list() {
|
|
446
|
-
return this.filters.map(function (f) {
|
|
447
|
-
return f.filterName;
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
}, {
|
|
451
|
-
key: "after",
|
|
452
|
-
value: function after(filterName) {
|
|
453
|
-
var _this$filters3;
|
|
454
|
-
var index = this.indexOf(filterName);
|
|
455
|
-
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
456
|
-
params[_key - 1] = arguments[_key];
|
|
457
|
-
}
|
|
458
|
-
(_this$filters3 = this.filters).splice.apply(_this$filters3, [index + 1, 0].concat(params));
|
|
459
|
-
return this;
|
|
460
|
-
}
|
|
461
|
-
}, {
|
|
462
|
-
key: "before",
|
|
463
|
-
value: function before(filterName) {
|
|
464
|
-
var _this$filters4;
|
|
465
|
-
var index = this.indexOf(filterName);
|
|
466
|
-
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
467
|
-
params[_key2 - 1] = arguments[_key2];
|
|
468
|
-
}
|
|
469
|
-
(_this$filters4 = this.filters).splice.apply(_this$filters4, [index, 0].concat(params));
|
|
470
|
-
return this;
|
|
471
|
-
}
|
|
472
|
-
}, {
|
|
473
|
-
key: "replace",
|
|
474
|
-
value: function replace(filterName) {
|
|
475
|
-
var _this$filters5;
|
|
476
|
-
var index = this.indexOf(filterName);
|
|
477
|
-
for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
478
|
-
params[_key3 - 1] = arguments[_key3];
|
|
479
|
-
}
|
|
480
|
-
(_this$filters5 = this.filters).splice.apply(_this$filters5, [index, 1].concat(params));
|
|
481
|
-
return this;
|
|
482
|
-
}
|
|
483
|
-
}, {
|
|
484
|
-
key: "remove",
|
|
485
|
-
value: function remove(filterName) {
|
|
486
|
-
var index = this.indexOf(filterName);
|
|
487
|
-
this.filters.splice(index, 1);
|
|
488
|
-
return this;
|
|
489
|
-
}
|
|
490
|
-
}, {
|
|
491
|
-
key: "clear",
|
|
492
|
-
value: function clear() {
|
|
493
|
-
this.filters.length = 0;
|
|
494
|
-
return this;
|
|
495
|
-
}
|
|
496
|
-
}, {
|
|
497
|
-
key: "shouldHaveResult",
|
|
498
|
-
value: function shouldHaveResult(should) {
|
|
499
|
-
var _this = this;
|
|
500
|
-
if (should === false) {
|
|
501
|
-
this.resultCheck = null;
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
if (this.resultCheck) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
this.resultCheck = function (context) {
|
|
508
|
-
if (!context.hasResult) {
|
|
509
|
-
console.log(context);
|
|
510
|
-
var error = new Error("".concat(_this.name, " failed"));
|
|
511
|
-
error.noResult = true;
|
|
512
|
-
throw error;
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
return this;
|
|
516
|
-
}
|
|
517
|
-
}]);
|
|
518
|
-
}();
|
|
519
|
-
|
|
520
|
-
var Context = /*#__PURE__*/function () {
|
|
521
|
-
function Context() {
|
|
522
|
-
_classCallCheck(this, Context);
|
|
523
|
-
}
|
|
524
|
-
return _createClass(Context, [{
|
|
525
|
-
key: "setResult",
|
|
526
|
-
value: function setResult(result) {
|
|
527
|
-
this.result = result;
|
|
528
|
-
this.hasResult = true;
|
|
529
|
-
return this;
|
|
530
|
-
}
|
|
531
|
-
}, {
|
|
532
|
-
key: "exit",
|
|
533
|
-
value: function exit() {
|
|
534
|
-
this.exiting = true;
|
|
535
|
-
return this;
|
|
536
|
-
}
|
|
537
|
-
}, {
|
|
538
|
-
key: "push",
|
|
539
|
-
value: function push(child, name) {
|
|
540
|
-
child.parent = this;
|
|
541
|
-
if (typeof name !== 'undefined') {
|
|
542
|
-
child.childName = name;
|
|
543
|
-
}
|
|
544
|
-
child.root = this.root || this;
|
|
545
|
-
child.options = child.options || this.options;
|
|
546
|
-
if (!this.children) {
|
|
547
|
-
this.children = [child];
|
|
548
|
-
this.nextAfterChildren = this.next || null;
|
|
549
|
-
this.next = child;
|
|
550
|
-
} else {
|
|
551
|
-
this.children[this.children.length - 1].next = child;
|
|
552
|
-
this.children.push(child);
|
|
553
|
-
}
|
|
554
|
-
child.next = this;
|
|
555
|
-
return this;
|
|
556
|
-
}
|
|
557
|
-
}]);
|
|
558
|
-
}();
|
|
559
|
-
|
|
560
|
-
function cloneRegExp(re) {
|
|
561
|
-
var regexMatch = /^\/(.*)\/([gimyu]*)$/.exec(re.toString());
|
|
562
|
-
return new RegExp(regexMatch[1], regexMatch[2]);
|
|
563
|
-
}
|
|
564
|
-
function clone$1(arg) {
|
|
565
|
-
if (_typeof(arg) !== 'object') {
|
|
566
|
-
return arg;
|
|
567
|
-
}
|
|
568
|
-
if (arg === null) {
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
if (Array.isArray(arg)) {
|
|
572
|
-
return arg.map(clone$1);
|
|
573
|
-
}
|
|
574
|
-
if (arg instanceof Date) {
|
|
575
|
-
return new Date(arg.getTime());
|
|
576
|
-
}
|
|
577
|
-
if (arg instanceof RegExp) {
|
|
578
|
-
return cloneRegExp(arg);
|
|
579
|
-
}
|
|
580
|
-
var cloned = {};
|
|
581
|
-
for (var name in arg) {
|
|
582
|
-
if (Object.prototype.hasOwnProperty.call(arg, name)) {
|
|
583
|
-
cloned[name] = clone$1(arg[name]);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return cloned;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
var DiffContext = /*#__PURE__*/function (_Context) {
|
|
590
|
-
function DiffContext(left, right) {
|
|
591
|
-
var _this;
|
|
592
|
-
_classCallCheck(this, DiffContext);
|
|
593
|
-
_this = _callSuper(this, DiffContext);
|
|
594
|
-
_this.left = left;
|
|
595
|
-
_this.right = right;
|
|
596
|
-
_this.pipe = 'diff';
|
|
597
|
-
return _this;
|
|
598
|
-
}
|
|
599
|
-
_inherits(DiffContext, _Context);
|
|
600
|
-
return _createClass(DiffContext, [{
|
|
601
|
-
key: "setResult",
|
|
602
|
-
value: function setResult(result) {
|
|
603
|
-
if (this.options.cloneDiffValues && _typeof(result) === 'object') {
|
|
604
|
-
var clone = typeof this.options.cloneDiffValues === 'function' ? this.options.cloneDiffValues : clone$1;
|
|
605
|
-
if (_typeof(result[0]) === 'object') {
|
|
606
|
-
result[0] = clone(result[0]);
|
|
607
|
-
}
|
|
608
|
-
if (_typeof(result[1]) === 'object') {
|
|
609
|
-
result[1] = clone(result[1]);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
return _superPropGet(DiffContext, "setResult", this, 3)([result]);
|
|
613
|
-
}
|
|
614
|
-
}]);
|
|
615
|
-
}(Context);
|
|
616
|
-
|
|
617
|
-
var PatchContext = /*#__PURE__*/function (_Context) {
|
|
618
|
-
function PatchContext(left, delta) {
|
|
619
|
-
var _this;
|
|
620
|
-
_classCallCheck(this, PatchContext);
|
|
621
|
-
_this = _callSuper(this, PatchContext);
|
|
622
|
-
_this.left = left;
|
|
623
|
-
_this.delta = delta;
|
|
624
|
-
_this.pipe = 'patch';
|
|
625
|
-
return _this;
|
|
626
|
-
}
|
|
627
|
-
_inherits(PatchContext, _Context);
|
|
628
|
-
return _createClass(PatchContext);
|
|
629
|
-
}(Context);
|
|
630
|
-
|
|
631
|
-
var ReverseContext = /*#__PURE__*/function (_Context) {
|
|
632
|
-
function ReverseContext(delta) {
|
|
633
|
-
var _this;
|
|
634
|
-
_classCallCheck(this, ReverseContext);
|
|
635
|
-
_this = _callSuper(this, ReverseContext);
|
|
636
|
-
_this.delta = delta;
|
|
637
|
-
_this.pipe = 'reverse';
|
|
638
|
-
return _this;
|
|
639
|
-
}
|
|
640
|
-
_inherits(ReverseContext, _Context);
|
|
641
|
-
return _createClass(ReverseContext);
|
|
642
|
-
}(Context);
|
|
643
|
-
|
|
644
|
-
var diffFilter$3 = function trivialMatchesDiffFilter(context) {
|
|
645
|
-
if (context.left === context.right) {
|
|
646
|
-
context.setResult(undefined).exit();
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
if (typeof context.left === 'undefined') {
|
|
650
|
-
if (typeof context.right === 'function') {
|
|
651
|
-
throw new Error('functions are not supported');
|
|
652
|
-
}
|
|
653
|
-
context.setResult([context.right]).exit();
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
if (typeof context.right === 'undefined') {
|
|
657
|
-
context.setResult([context.left, 0, 0]).exit();
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
if (typeof context.left === 'function' || typeof context.right === 'function') {
|
|
661
|
-
throw new Error('functions are not supported');
|
|
662
|
-
}
|
|
663
|
-
context.leftType = context.left === null ? 'null' : _typeof(context.left);
|
|
664
|
-
context.rightType = context.right === null ? 'null' : _typeof(context.right);
|
|
665
|
-
if (context.leftType !== context.rightType) {
|
|
666
|
-
context.setResult([context.left, context.right]).exit();
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
if (context.leftType === 'boolean' || context.leftType === 'number') {
|
|
670
|
-
context.setResult([context.left, context.right]).exit();
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
if (context.leftType === 'object') {
|
|
674
|
-
context.leftIsArray = Array.isArray(context.left);
|
|
675
|
-
}
|
|
676
|
-
if (context.rightType === 'object') {
|
|
677
|
-
context.rightIsArray = Array.isArray(context.right);
|
|
678
|
-
}
|
|
679
|
-
if (context.leftIsArray !== context.rightIsArray) {
|
|
680
|
-
context.setResult([context.left, context.right]).exit();
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
if (context.left instanceof RegExp) {
|
|
684
|
-
if (context.right instanceof RegExp) {
|
|
685
|
-
context.setResult([context.left.toString(), context.right.toString()]).exit();
|
|
686
|
-
} else {
|
|
687
|
-
context.setResult([context.left, context.right]).exit();
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
diffFilter$3.filterName = 'trivial';
|
|
692
|
-
var patchFilter$3 = function trivialMatchesPatchFilter(context) {
|
|
693
|
-
if (typeof context.delta === 'undefined') {
|
|
694
|
-
context.setResult(context.left).exit();
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
context.nested = !Array.isArray(context.delta);
|
|
698
|
-
if (context.nested) {
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
var nonNestedDelta = context.delta;
|
|
702
|
-
if (nonNestedDelta.length === 1) {
|
|
703
|
-
context.setResult(nonNestedDelta[0]).exit();
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
if (nonNestedDelta.length === 2) {
|
|
707
|
-
if (context.left instanceof RegExp) {
|
|
708
|
-
var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
|
|
709
|
-
if (regexArgs) {
|
|
710
|
-
context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
context.setResult(nonNestedDelta[1]).exit();
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
|
|
718
|
-
context.setResult(undefined).exit();
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
patchFilter$3.filterName = 'trivial';
|
|
722
|
-
var reverseFilter$3 = function trivialReferseFilter(context) {
|
|
723
|
-
if (typeof context.delta === 'undefined') {
|
|
724
|
-
context.setResult(context.delta).exit();
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
context.nested = !Array.isArray(context.delta);
|
|
728
|
-
if (context.nested) {
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
var nonNestedDelta = context.delta;
|
|
732
|
-
if (nonNestedDelta.length === 1) {
|
|
733
|
-
context.setResult([nonNestedDelta[0], 0, 0]).exit();
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
if (nonNestedDelta.length === 2) {
|
|
737
|
-
context.setResult([nonNestedDelta[1], nonNestedDelta[0]]).exit();
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
|
|
741
|
-
context.setResult([nonNestedDelta[0]]).exit();
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
reverseFilter$3.filterName = 'trivial';
|
|
745
|
-
|
|
746
|
-
var collectChildrenDiffFilter = function collectChildrenDiffFilter(context) {
|
|
747
|
-
if (!context || !context.children) {
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
var length = context.children.length;
|
|
751
|
-
var child;
|
|
752
|
-
var result = context.result;
|
|
753
|
-
for (var index = 0; index < length; index++) {
|
|
754
|
-
child = context.children[index];
|
|
755
|
-
if (typeof child.result === 'undefined') {
|
|
756
|
-
continue;
|
|
757
|
-
}
|
|
758
|
-
result = result || {};
|
|
759
|
-
result[child.childName] = child.result;
|
|
760
|
-
}
|
|
761
|
-
if (result && context.leftIsArray) {
|
|
762
|
-
result._t = 'a';
|
|
763
|
-
}
|
|
764
|
-
context.setResult(result).exit();
|
|
765
|
-
};
|
|
766
|
-
collectChildrenDiffFilter.filterName = 'collectChildren';
|
|
767
|
-
var objectsDiffFilter = function objectsDiffFilter(context) {
|
|
768
|
-
if (context.leftIsArray || context.leftType !== 'object') {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
var left = context.left;
|
|
772
|
-
var right = context.right;
|
|
773
|
-
var name;
|
|
774
|
-
var child;
|
|
775
|
-
var propertyFilter = context.options.propertyFilter;
|
|
776
|
-
for (name in left) {
|
|
777
|
-
if (!Object.prototype.hasOwnProperty.call(left, name)) {
|
|
778
|
-
continue;
|
|
779
|
-
}
|
|
780
|
-
if (propertyFilter && !propertyFilter(name, context)) {
|
|
781
|
-
continue;
|
|
782
|
-
}
|
|
783
|
-
child = new DiffContext(left[name], right[name]);
|
|
784
|
-
context.push(child, name);
|
|
785
|
-
}
|
|
786
|
-
for (name in right) {
|
|
787
|
-
if (!Object.prototype.hasOwnProperty.call(right, name)) {
|
|
788
|
-
continue;
|
|
789
|
-
}
|
|
790
|
-
if (propertyFilter && !propertyFilter(name, context)) {
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
if (typeof left[name] === 'undefined') {
|
|
794
|
-
child = new DiffContext(undefined, right[name]);
|
|
795
|
-
context.push(child, name);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
if (!context.children || context.children.length === 0) {
|
|
799
|
-
context.setResult(undefined).exit();
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
context.exit();
|
|
803
|
-
};
|
|
804
|
-
objectsDiffFilter.filterName = 'objects';
|
|
805
|
-
var patchFilter$2 = function nestedPatchFilter(context) {
|
|
806
|
-
if (!context.nested) {
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
var nestedDelta = context.delta;
|
|
810
|
-
if (nestedDelta._t) {
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
|
-
var objectDelta = nestedDelta;
|
|
814
|
-
var name;
|
|
815
|
-
var child;
|
|
816
|
-
for (name in objectDelta) {
|
|
817
|
-
child = new PatchContext(context.left[name], objectDelta[name]);
|
|
818
|
-
context.push(child, name);
|
|
819
|
-
}
|
|
820
|
-
context.exit();
|
|
821
|
-
};
|
|
822
|
-
patchFilter$2.filterName = 'objects';
|
|
823
|
-
var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter(context) {
|
|
824
|
-
if (!context || !context.children) {
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
var deltaWithChildren = context.delta;
|
|
828
|
-
if (deltaWithChildren._t) {
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
var object = context.left;
|
|
832
|
-
var length = context.children.length;
|
|
833
|
-
var child;
|
|
834
|
-
for (var index = 0; index < length; index++) {
|
|
835
|
-
child = context.children[index];
|
|
836
|
-
var property = child.childName;
|
|
837
|
-
if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === undefined) {
|
|
838
|
-
delete object[property];
|
|
839
|
-
} else if (object[property] !== child.result) {
|
|
840
|
-
object[property] = child.result;
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
context.setResult(object).exit();
|
|
844
|
-
};
|
|
845
|
-
collectChildrenPatchFilter$1.filterName = 'collectChildren';
|
|
846
|
-
var reverseFilter$2 = function nestedReverseFilter(context) {
|
|
847
|
-
if (!context.nested) {
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
var nestedDelta = context.delta;
|
|
851
|
-
if (nestedDelta._t) {
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
var objectDelta = context.delta;
|
|
855
|
-
var name;
|
|
856
|
-
var child;
|
|
857
|
-
for (name in objectDelta) {
|
|
858
|
-
child = new ReverseContext(objectDelta[name]);
|
|
859
|
-
context.push(child, name);
|
|
860
|
-
}
|
|
861
|
-
context.exit();
|
|
862
|
-
};
|
|
863
|
-
reverseFilter$2.filterName = 'objects';
|
|
864
|
-
var collectChildrenReverseFilter$1 = function collectChildrenReverseFilter(context) {
|
|
865
|
-
if (!context || !context.children) {
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
var deltaWithChildren = context.delta;
|
|
869
|
-
if (deltaWithChildren._t) {
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
var length = context.children.length;
|
|
873
|
-
var child;
|
|
874
|
-
var delta = {};
|
|
875
|
-
for (var index = 0; index < length; index++) {
|
|
876
|
-
child = context.children[index];
|
|
877
|
-
var property = child.childName;
|
|
878
|
-
if (delta[property] !== child.result) {
|
|
879
|
-
delta[property] = child.result;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
context.setResult(delta).exit();
|
|
883
|
-
};
|
|
884
|
-
collectChildrenReverseFilter$1.filterName = 'collectChildren';
|
|
885
|
-
|
|
886
|
-
/*
|
|
887
|
-
|
|
888
|
-
LCS implementation that supports arrays or strings
|
|
889
|
-
|
|
890
|
-
reference: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
|
|
891
|
-
|
|
892
|
-
*/
|
|
893
|
-
var defaultMatch = function defaultMatch(array1, array2, index1, index2) {
|
|
894
|
-
return array1[index1] === array2[index2];
|
|
895
|
-
};
|
|
896
|
-
var lengthMatrix = function lengthMatrix(array1, array2, match, context) {
|
|
897
|
-
var len1 = array1.length;
|
|
898
|
-
var len2 = array2.length;
|
|
899
|
-
var x, y;
|
|
900
|
-
// initialize empty matrix of len1+1 x len2+1
|
|
901
|
-
var matrix = new Array(len1 + 1);
|
|
902
|
-
for (x = 0; x < len1 + 1; x++) {
|
|
903
|
-
matrix[x] = new Array(len2 + 1);
|
|
904
|
-
for (y = 0; y < len2 + 1; y++) {
|
|
905
|
-
matrix[x][y] = 0;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
matrix.match = match;
|
|
909
|
-
// save sequence lengths for each coordinate
|
|
910
|
-
for (x = 1; x < len1 + 1; x++) {
|
|
911
|
-
for (y = 1; y < len2 + 1; y++) {
|
|
912
|
-
if (match(array1, array2, x - 1, y - 1, context)) {
|
|
913
|
-
matrix[x][y] = matrix[x - 1][y - 1] + 1;
|
|
914
|
-
} else {
|
|
915
|
-
matrix[x][y] = Math.max(matrix[x - 1][y], matrix[x][y - 1]);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
return matrix;
|
|
920
|
-
};
|
|
921
|
-
var backtrack = function backtrack(matrix, array1, array2, context) {
|
|
922
|
-
var index1 = array1.length;
|
|
923
|
-
var index2 = array2.length;
|
|
924
|
-
var subsequence = {
|
|
925
|
-
sequence: [],
|
|
926
|
-
indices1: [],
|
|
927
|
-
indices2: []
|
|
928
|
-
};
|
|
929
|
-
while (index1 !== 0 && index2 !== 0) {
|
|
930
|
-
var sameLetter = matrix.match(array1, array2, index1 - 1, index2 - 1, context);
|
|
931
|
-
if (sameLetter) {
|
|
932
|
-
subsequence.sequence.unshift(array1[index1 - 1]);
|
|
933
|
-
subsequence.indices1.unshift(index1 - 1);
|
|
934
|
-
subsequence.indices2.unshift(index2 - 1);
|
|
935
|
-
--index1;
|
|
936
|
-
--index2;
|
|
937
|
-
} else {
|
|
938
|
-
var valueAtMatrixAbove = matrix[index1][index2 - 1];
|
|
939
|
-
var valueAtMatrixLeft = matrix[index1 - 1][index2];
|
|
940
|
-
if (valueAtMatrixAbove > valueAtMatrixLeft) {
|
|
941
|
-
--index2;
|
|
942
|
-
} else {
|
|
943
|
-
--index1;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
return subsequence;
|
|
948
|
-
};
|
|
949
|
-
var get = function get(array1, array2, match, context) {
|
|
950
|
-
var innerContext = context || {};
|
|
951
|
-
var matrix = lengthMatrix(array1, array2, match || defaultMatch, innerContext);
|
|
952
|
-
return backtrack(matrix, array1, array2, innerContext);
|
|
953
|
-
};
|
|
954
|
-
var lcs = {
|
|
955
|
-
get: get
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
var ARRAY_MOVE = 3;
|
|
959
|
-
function arraysHaveMatchByRef(array1, array2, len1, len2) {
|
|
960
|
-
for (var index1 = 0; index1 < len1; index1++) {
|
|
961
|
-
var val1 = array1[index1];
|
|
962
|
-
for (var index2 = 0; index2 < len2; index2++) {
|
|
963
|
-
var val2 = array2[index2];
|
|
964
|
-
if (index1 !== index2 && val1 === val2) {
|
|
965
|
-
return true;
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
function matchItems(array1, array2, index1, index2, context) {
|
|
971
|
-
var value1 = array1[index1];
|
|
972
|
-
var value2 = array2[index2];
|
|
973
|
-
if (value1 === value2) {
|
|
974
|
-
return true;
|
|
975
|
-
}
|
|
976
|
-
if (_typeof(value1) !== 'object' || _typeof(value2) !== 'object') {
|
|
977
|
-
return false;
|
|
978
|
-
}
|
|
979
|
-
var objectHash = context.objectHash;
|
|
980
|
-
if (!objectHash) {
|
|
981
|
-
// no way to match objects was provided, try match by position
|
|
982
|
-
return context.matchByPosition && index1 === index2;
|
|
983
|
-
}
|
|
984
|
-
context.hashCache1 = context.hashCache1 || [];
|
|
985
|
-
var hash1 = context.hashCache1[index1];
|
|
986
|
-
if (typeof hash1 === 'undefined') {
|
|
987
|
-
context.hashCache1[index1] = hash1 = objectHash(value1, index1);
|
|
988
|
-
}
|
|
989
|
-
if (typeof hash1 === 'undefined') {
|
|
990
|
-
return false;
|
|
991
|
-
}
|
|
992
|
-
context.hashCache2 = context.hashCache2 || [];
|
|
993
|
-
var hash2 = context.hashCache2[index2];
|
|
994
|
-
if (typeof hash2 === 'undefined') {
|
|
995
|
-
context.hashCache2[index2] = hash2 = objectHash(value2, index2);
|
|
996
|
-
}
|
|
997
|
-
if (typeof hash2 === 'undefined') {
|
|
998
|
-
return false;
|
|
999
|
-
}
|
|
1000
|
-
return hash1 === hash2;
|
|
1001
|
-
}
|
|
1002
|
-
var diffFilter$2 = function arraysDiffFilter(context) {
|
|
1003
|
-
if (!context.leftIsArray) {
|
|
1004
|
-
return;
|
|
1005
|
-
}
|
|
1006
|
-
var matchContext = {
|
|
1007
|
-
objectHash: context.options && context.options.objectHash,
|
|
1008
|
-
matchByPosition: context.options && context.options.matchByPosition
|
|
1009
|
-
};
|
|
1010
|
-
var commonHead = 0;
|
|
1011
|
-
var commonTail = 0;
|
|
1012
|
-
var index;
|
|
1013
|
-
var index1;
|
|
1014
|
-
var index2;
|
|
1015
|
-
var array1 = context.left;
|
|
1016
|
-
var array2 = context.right;
|
|
1017
|
-
var len1 = array1.length;
|
|
1018
|
-
var len2 = array2.length;
|
|
1019
|
-
var child;
|
|
1020
|
-
if (len1 > 0 && len2 > 0 && !matchContext.objectHash && typeof matchContext.matchByPosition !== 'boolean') {
|
|
1021
|
-
matchContext.matchByPosition = !arraysHaveMatchByRef(array1, array2, len1, len2);
|
|
1022
|
-
}
|
|
1023
|
-
// separate common head
|
|
1024
|
-
while (commonHead < len1 && commonHead < len2 && matchItems(array1, array2, commonHead, commonHead, matchContext)) {
|
|
1025
|
-
index = commonHead;
|
|
1026
|
-
child = new DiffContext(array1[index], array2[index]);
|
|
1027
|
-
context.push(child, index);
|
|
1028
|
-
commonHead++;
|
|
1029
|
-
}
|
|
1030
|
-
// separate common tail
|
|
1031
|
-
while (commonTail + commonHead < len1 && commonTail + commonHead < len2 && matchItems(array1, array2, len1 - 1 - commonTail, len2 - 1 - commonTail, matchContext)) {
|
|
1032
|
-
index1 = len1 - 1 - commonTail;
|
|
1033
|
-
index2 = len2 - 1 - commonTail;
|
|
1034
|
-
child = new DiffContext(array1[index1], array2[index2]);
|
|
1035
|
-
context.push(child, index2);
|
|
1036
|
-
commonTail++;
|
|
1037
|
-
}
|
|
1038
|
-
var result;
|
|
1039
|
-
if (commonHead + commonTail === len1) {
|
|
1040
|
-
if (len1 === len2) {
|
|
1041
|
-
// arrays are identical
|
|
1042
|
-
context.setResult(undefined).exit();
|
|
1043
|
-
return;
|
|
1044
|
-
}
|
|
1045
|
-
// trivial case, a block (1 or more consecutive items) was added
|
|
1046
|
-
result = result || {
|
|
1047
|
-
_t: 'a'
|
|
1048
|
-
};
|
|
1049
|
-
for (index = commonHead; index < len2 - commonTail; index++) {
|
|
1050
|
-
result[index] = [array2[index]];
|
|
1051
|
-
}
|
|
1052
|
-
context.setResult(result).exit();
|
|
1053
|
-
return;
|
|
1054
|
-
}
|
|
1055
|
-
if (commonHead + commonTail === len2) {
|
|
1056
|
-
// trivial case, a block (1 or more consecutive items) was removed
|
|
1057
|
-
result = result || {
|
|
1058
|
-
_t: 'a'
|
|
1059
|
-
};
|
|
1060
|
-
for (index = commonHead; index < len1 - commonTail; index++) {
|
|
1061
|
-
result["_".concat(index)] = [array1[index], 0, 0];
|
|
1062
|
-
}
|
|
1063
|
-
context.setResult(result).exit();
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
// reset hash cache
|
|
1067
|
-
delete matchContext.hashCache1;
|
|
1068
|
-
delete matchContext.hashCache2;
|
|
1069
|
-
// diff is not trivial, find the LCS (Longest Common Subsequence)
|
|
1070
|
-
var trimmed1 = array1.slice(commonHead, len1 - commonTail);
|
|
1071
|
-
var trimmed2 = array2.slice(commonHead, len2 - commonTail);
|
|
1072
|
-
var seq = lcs.get(trimmed1, trimmed2, matchItems, matchContext);
|
|
1073
|
-
var removedItems = [];
|
|
1074
|
-
result = result || {
|
|
1075
|
-
_t: 'a'
|
|
1076
|
-
};
|
|
1077
|
-
for (index = commonHead; index < len1 - commonTail; index++) {
|
|
1078
|
-
if (seq.indices1.indexOf(index - commonHead) < 0) {
|
|
1079
|
-
// removed
|
|
1080
|
-
result["_".concat(index)] = [array1[index], 0, 0];
|
|
1081
|
-
removedItems.push(index);
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
var detectMove = true;
|
|
1085
|
-
if (context.options && context.options.arrays && context.options.arrays.detectMove === false) {
|
|
1086
|
-
detectMove = false;
|
|
1087
|
-
}
|
|
1088
|
-
var includeValueOnMove = false;
|
|
1089
|
-
if (context.options && context.options.arrays && context.options.arrays.includeValueOnMove) {
|
|
1090
|
-
includeValueOnMove = true;
|
|
1091
|
-
}
|
|
1092
|
-
var removedItemsLength = removedItems.length;
|
|
1093
|
-
for (index = commonHead; index < len2 - commonTail; index++) {
|
|
1094
|
-
var indexOnArray2 = seq.indices2.indexOf(index - commonHead);
|
|
1095
|
-
if (indexOnArray2 < 0) {
|
|
1096
|
-
// added, try to match with a removed item and register as position move
|
|
1097
|
-
var isMove = false;
|
|
1098
|
-
if (detectMove && removedItemsLength > 0) {
|
|
1099
|
-
for (var removeItemIndex1 = 0; removeItemIndex1 < removedItemsLength; removeItemIndex1++) {
|
|
1100
|
-
index1 = removedItems[removeItemIndex1];
|
|
1101
|
-
if (matchItems(trimmed1, trimmed2, index1 - commonHead, index - commonHead, matchContext)) {
|
|
1102
|
-
// store position move as: [originalValue, newPosition, ARRAY_MOVE]
|
|
1103
|
-
result["_".concat(index1)].splice(1, 2, index, ARRAY_MOVE);
|
|
1104
|
-
if (!includeValueOnMove) {
|
|
1105
|
-
// don't include moved value on diff, to save bytes
|
|
1106
|
-
result["_".concat(index1)][0] = '';
|
|
1107
|
-
}
|
|
1108
|
-
index2 = index;
|
|
1109
|
-
child = new DiffContext(array1[index1], array2[index2]);
|
|
1110
|
-
context.push(child, index2);
|
|
1111
|
-
removedItems.splice(removeItemIndex1, 1);
|
|
1112
|
-
isMove = true;
|
|
1113
|
-
break;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
if (!isMove) {
|
|
1118
|
-
// added
|
|
1119
|
-
result[index] = [array2[index]];
|
|
1120
|
-
}
|
|
1121
|
-
} else {
|
|
1122
|
-
// match, do inner diff
|
|
1123
|
-
index1 = seq.indices1[indexOnArray2] + commonHead;
|
|
1124
|
-
index2 = seq.indices2[indexOnArray2] + commonHead;
|
|
1125
|
-
child = new DiffContext(array1[index1], array2[index2]);
|
|
1126
|
-
context.push(child, index2);
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
context.setResult(result).exit();
|
|
1130
|
-
};
|
|
1131
|
-
diffFilter$2.filterName = 'arrays';
|
|
1132
|
-
var compare = {
|
|
1133
|
-
numerically: function numerically(a, b) {
|
|
1134
|
-
return a - b;
|
|
1135
|
-
},
|
|
1136
|
-
numericallyBy: function numericallyBy(name) {
|
|
1137
|
-
return function (a, b) {
|
|
1138
|
-
return a[name] - b[name];
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
};
|
|
1142
|
-
var patchFilter$1 = function nestedPatchFilter(context) {
|
|
1143
|
-
if (!context.nested) {
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
var nestedDelta = context.delta;
|
|
1147
|
-
if (nestedDelta._t !== 'a') {
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
var index;
|
|
1151
|
-
var index1;
|
|
1152
|
-
var delta = nestedDelta;
|
|
1153
|
-
var array = context.left;
|
|
1154
|
-
// first, separate removals, insertions and modifications
|
|
1155
|
-
var toRemove = [];
|
|
1156
|
-
var toInsert = [];
|
|
1157
|
-
var toModify = [];
|
|
1158
|
-
for (index in delta) {
|
|
1159
|
-
if (index !== '_t') {
|
|
1160
|
-
if (index[0] === '_') {
|
|
1161
|
-
var removedOrMovedIndex = index;
|
|
1162
|
-
// removed item from original array
|
|
1163
|
-
if (delta[removedOrMovedIndex][2] === 0 || delta[removedOrMovedIndex][2] === ARRAY_MOVE) {
|
|
1164
|
-
toRemove.push(parseInt(index.slice(1), 10));
|
|
1165
|
-
} else {
|
|
1166
|
-
throw new Error('only removal or move can be applied at original array indices,' + " invalid diff type: ".concat(delta[removedOrMovedIndex][2]));
|
|
1167
|
-
}
|
|
1168
|
-
} else {
|
|
1169
|
-
var numberIndex = index;
|
|
1170
|
-
if (delta[numberIndex].length === 1) {
|
|
1171
|
-
// added item at new array
|
|
1172
|
-
toInsert.push({
|
|
1173
|
-
index: parseInt(numberIndex, 10),
|
|
1174
|
-
value: delta[numberIndex][0]
|
|
1175
|
-
});
|
|
1176
|
-
} else {
|
|
1177
|
-
// modified item at new array
|
|
1178
|
-
toModify.push({
|
|
1179
|
-
index: parseInt(numberIndex, 10),
|
|
1180
|
-
delta: delta[numberIndex]
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
// remove items, in reverse order to avoid sawing our own floor
|
|
1187
|
-
toRemove = toRemove.sort(compare.numerically);
|
|
1188
|
-
for (index = toRemove.length - 1; index >= 0; index--) {
|
|
1189
|
-
index1 = toRemove[index];
|
|
1190
|
-
var indexDiff = delta["_".concat(index1)];
|
|
1191
|
-
var removedValue = array.splice(index1, 1)[0];
|
|
1192
|
-
if (indexDiff[2] === ARRAY_MOVE) {
|
|
1193
|
-
// reinsert later
|
|
1194
|
-
toInsert.push({
|
|
1195
|
-
index: indexDiff[1],
|
|
1196
|
-
value: removedValue
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
// insert items, in reverse order to avoid moving our own floor
|
|
1201
|
-
toInsert = toInsert.sort(compare.numericallyBy('index'));
|
|
1202
|
-
var toInsertLength = toInsert.length;
|
|
1203
|
-
for (index = 0; index < toInsertLength; index++) {
|
|
1204
|
-
var insertion = toInsert[index];
|
|
1205
|
-
array.splice(insertion.index, 0, insertion.value);
|
|
1206
|
-
}
|
|
1207
|
-
// apply modifications
|
|
1208
|
-
var toModifyLength = toModify.length;
|
|
1209
|
-
var child;
|
|
1210
|
-
if (toModifyLength > 0) {
|
|
1211
|
-
for (index = 0; index < toModifyLength; index++) {
|
|
1212
|
-
var modification = toModify[index];
|
|
1213
|
-
child = new PatchContext(array[modification.index], modification.delta);
|
|
1214
|
-
context.push(child, modification.index);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
if (!context.children) {
|
|
1218
|
-
context.setResult(array).exit();
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
context.exit();
|
|
1222
|
-
};
|
|
1223
|
-
patchFilter$1.filterName = 'arrays';
|
|
1224
|
-
var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
|
|
1225
|
-
if (!context || !context.children) {
|
|
1226
|
-
return;
|
|
1227
|
-
}
|
|
1228
|
-
var deltaWithChildren = context.delta;
|
|
1229
|
-
if (deltaWithChildren._t !== 'a') {
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
var array = context.left;
|
|
1233
|
-
var length = context.children.length;
|
|
1234
|
-
var child;
|
|
1235
|
-
for (var index = 0; index < length; index++) {
|
|
1236
|
-
child = context.children[index];
|
|
1237
|
-
var arrayIndex = child.childName;
|
|
1238
|
-
array[arrayIndex] = child.result;
|
|
1239
|
-
}
|
|
1240
|
-
context.setResult(array).exit();
|
|
1241
|
-
};
|
|
1242
|
-
collectChildrenPatchFilter.filterName = 'arraysCollectChildren';
|
|
1243
|
-
var reverseFilter$1 = function arraysReverseFilter(context) {
|
|
1244
|
-
if (!context.nested) {
|
|
1245
|
-
var nonNestedDelta = context.delta;
|
|
1246
|
-
if (nonNestedDelta[2] === ARRAY_MOVE) {
|
|
1247
|
-
var arrayMoveDelta = nonNestedDelta;
|
|
1248
|
-
context.newName = "_".concat(arrayMoveDelta[1]);
|
|
1249
|
-
context.setResult([arrayMoveDelta[0], parseInt(context.childName.substring(1), 10), ARRAY_MOVE]).exit();
|
|
1250
|
-
}
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
var nestedDelta = context.delta;
|
|
1254
|
-
if (nestedDelta._t !== 'a') {
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
var arrayDelta = nestedDelta;
|
|
1258
|
-
var name;
|
|
1259
|
-
var child;
|
|
1260
|
-
for (name in arrayDelta) {
|
|
1261
|
-
if (name === '_t') {
|
|
1262
|
-
continue;
|
|
1263
|
-
}
|
|
1264
|
-
child = new ReverseContext(arrayDelta[name]);
|
|
1265
|
-
context.push(child, name);
|
|
1266
|
-
}
|
|
1267
|
-
context.exit();
|
|
1268
|
-
};
|
|
1269
|
-
reverseFilter$1.filterName = 'arrays';
|
|
1270
|
-
var reverseArrayDeltaIndex = function reverseArrayDeltaIndex(delta, index, itemDelta) {
|
|
1271
|
-
if (typeof index === 'string' && index[0] === '_') {
|
|
1272
|
-
return parseInt(index.substring(1), 10);
|
|
1273
|
-
} else if (Array.isArray(itemDelta) && itemDelta[2] === 0) {
|
|
1274
|
-
return "_".concat(index);
|
|
1275
|
-
}
|
|
1276
|
-
var reverseIndex = +index;
|
|
1277
|
-
for (var deltaIndex in delta) {
|
|
1278
|
-
var deltaItem = delta[deltaIndex];
|
|
1279
|
-
if (Array.isArray(deltaItem)) {
|
|
1280
|
-
if (deltaItem[2] === ARRAY_MOVE) {
|
|
1281
|
-
var moveFromIndex = parseInt(deltaIndex.substring(1), 10);
|
|
1282
|
-
var moveToIndex = deltaItem[1];
|
|
1283
|
-
if (moveToIndex === +index) {
|
|
1284
|
-
return moveFromIndex;
|
|
1285
|
-
}
|
|
1286
|
-
if (moveFromIndex <= reverseIndex && moveToIndex > reverseIndex) {
|
|
1287
|
-
reverseIndex++;
|
|
1288
|
-
} else if (moveFromIndex >= reverseIndex && moveToIndex < reverseIndex) {
|
|
1289
|
-
reverseIndex--;
|
|
1290
|
-
}
|
|
1291
|
-
} else if (deltaItem[2] === 0) {
|
|
1292
|
-
var deleteIndex = parseInt(deltaIndex.substring(1), 10);
|
|
1293
|
-
if (deleteIndex <= reverseIndex) {
|
|
1294
|
-
reverseIndex++;
|
|
1295
|
-
}
|
|
1296
|
-
} else if (deltaItem.length === 1 && parseInt(deltaIndex, 10) <= reverseIndex) {
|
|
1297
|
-
reverseIndex--;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
return reverseIndex;
|
|
1302
|
-
};
|
|
1303
|
-
var collectChildrenReverseFilter = function collectChildrenReverseFilter(context) {
|
|
1304
|
-
if (!context || !context.children) {
|
|
1305
|
-
return;
|
|
1306
|
-
}
|
|
1307
|
-
var deltaWithChildren = context.delta;
|
|
1308
|
-
if (deltaWithChildren._t !== 'a') {
|
|
1309
|
-
return;
|
|
1310
|
-
}
|
|
1311
|
-
var arrayDelta = deltaWithChildren;
|
|
1312
|
-
var length = context.children.length;
|
|
1313
|
-
var child;
|
|
1314
|
-
var delta = {
|
|
1315
|
-
_t: 'a'
|
|
1316
|
-
};
|
|
1317
|
-
for (var index = 0; index < length; index++) {
|
|
1318
|
-
child = context.children[index];
|
|
1319
|
-
var name = child.newName;
|
|
1320
|
-
if (typeof name === 'undefined') {
|
|
1321
|
-
name = reverseArrayDeltaIndex(arrayDelta, child.childName, child.result);
|
|
1322
|
-
}
|
|
1323
|
-
if (delta[name] !== child.result) {
|
|
1324
|
-
// There's no way to type this well.
|
|
1325
|
-
delta[name] = child.result;
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
context.setResult(delta).exit();
|
|
1329
|
-
};
|
|
1330
|
-
collectChildrenReverseFilter.filterName = 'arraysCollectChildren';
|
|
1331
|
-
|
|
1332
|
-
var diffFilter$1 = function datesDiffFilter(context) {
|
|
1333
|
-
if (context.left instanceof Date) {
|
|
1334
|
-
if (context.right instanceof Date) {
|
|
1335
|
-
if (context.left.getTime() !== context.right.getTime()) {
|
|
1336
|
-
context.setResult([context.left, context.right]);
|
|
1337
|
-
} else {
|
|
1338
|
-
context.setResult(undefined);
|
|
1339
|
-
}
|
|
1340
|
-
} else {
|
|
1341
|
-
context.setResult([context.left, context.right]);
|
|
1342
|
-
}
|
|
1343
|
-
context.exit();
|
|
1344
|
-
} else if (context.right instanceof Date) {
|
|
1345
|
-
context.setResult([context.left, context.right]).exit();
|
|
1346
|
-
}
|
|
1347
|
-
};
|
|
1348
|
-
diffFilter$1.filterName = 'dates';
|
|
1349
|
-
|
|
1350
|
-
var TEXT_DIFF = 2;
|
|
1351
|
-
var DEFAULT_MIN_LENGTH = 60;
|
|
1352
|
-
var cachedDiffPatch = null;
|
|
1353
|
-
function getDiffMatchPatch(options, required) {
|
|
1354
|
-
var _a;
|
|
1355
|
-
if (!cachedDiffPatch) {
|
|
1356
|
-
var instance;
|
|
1357
|
-
if ((_a = options === null || options === void 0 ? void 0 : options.textDiff) === null || _a === void 0 ? void 0 : _a.diffMatchPatch) {
|
|
1358
|
-
instance = new options.textDiff.diffMatchPatch();
|
|
1359
|
-
} else {
|
|
1360
|
-
if (!required) {
|
|
1361
|
-
return null;
|
|
1362
|
-
}
|
|
1363
|
-
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.');
|
|
1364
|
-
// eslint-disable-next-line camelcase
|
|
1365
|
-
error.diff_match_patch_not_found = true;
|
|
1366
|
-
throw error;
|
|
1367
|
-
}
|
|
1368
|
-
cachedDiffPatch = {
|
|
1369
|
-
diff: function diff(txt1, txt2) {
|
|
1370
|
-
return instance.patch_toText(instance.patch_make(txt1, txt2));
|
|
1371
|
-
},
|
|
1372
|
-
patch: function patch(txt1, _patch) {
|
|
1373
|
-
var results = instance.patch_apply(instance.patch_fromText(_patch), txt1);
|
|
1374
|
-
for (var i = 0; i < results[1].length; i++) {
|
|
1375
|
-
if (!results[1][i]) {
|
|
1376
|
-
var _error = new Error('text patch failed');
|
|
1377
|
-
_error.textPatchFailed = true;
|
|
1378
|
-
}
|
|
171
|
+
return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
|
|
172
|
+
prices: prices.map(function (price) {
|
|
173
|
+
var newPrice = _objectSpread2({}, price);
|
|
174
|
+
var oldPrice = extractPriceFromPreviousVariant(price, oldVariant);
|
|
175
|
+
if (oldPrice) {
|
|
176
|
+
// copy ID if not provided
|
|
177
|
+
if (!newPrice.id) newPrice.id = oldPrice.id;
|
|
178
|
+
if (isNil(newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
|
|
179
|
+
if (isNil(newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
|
|
1379
180
|
}
|
|
1380
|
-
return
|
|
1381
|
-
}
|
|
1382
|
-
};
|
|
1383
|
-
}
|
|
1384
|
-
return cachedDiffPatch;
|
|
181
|
+
return newPrice;
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
});
|
|
1385
185
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
lineTmp = lines[i];
|
|
1445
|
-
lines[i] = lines[i - 1];
|
|
1446
|
-
lines[i - 1] = lineTmp;
|
|
1447
|
-
}
|
|
1448
|
-
} else if (lineStart === '-') {
|
|
1449
|
-
lines[i] = '+' + lines[i].slice(1);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
return lines.join('\n');
|
|
1453
|
-
};
|
|
1454
|
-
var reverseFilter = function textsReverseFilter(context) {
|
|
1455
|
-
if (context.nested) {
|
|
1456
|
-
return;
|
|
1457
|
-
}
|
|
1458
|
-
var nonNestedDelta = context.delta;
|
|
1459
|
-
if (nonNestedDelta[2] !== TEXT_DIFF) {
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
var textDiffDelta = nonNestedDelta;
|
|
1463
|
-
// text-diff, use a text-diff algorithm
|
|
1464
|
-
context.setResult([textDeltaReverse(textDiffDelta[0]), 0, TEXT_DIFF]).exit();
|
|
1465
|
-
};
|
|
1466
|
-
reverseFilter.filterName = 'texts';
|
|
1467
|
-
|
|
1468
|
-
var DiffPatcher = /*#__PURE__*/function () {
|
|
1469
|
-
function DiffPatcher(options) {
|
|
1470
|
-
_classCallCheck(this, DiffPatcher);
|
|
1471
|
-
this.processor = new Processor(options);
|
|
1472
|
-
this.processor.pipe(new Pipe('diff').append(collectChildrenDiffFilter, diffFilter$3, diffFilter$1, diffFilter, objectsDiffFilter, diffFilter$2).shouldHaveResult());
|
|
1473
|
-
this.processor.pipe(new Pipe('patch').append(collectChildrenPatchFilter$1, collectChildrenPatchFilter, patchFilter$3, patchFilter, patchFilter$2, patchFilter$1).shouldHaveResult());
|
|
1474
|
-
this.processor.pipe(new Pipe('reverse').append(collectChildrenReverseFilter$1, collectChildrenReverseFilter, reverseFilter$3, reverseFilter, reverseFilter$2, reverseFilter$1).shouldHaveResult());
|
|
1475
|
-
}
|
|
1476
|
-
return _createClass(DiffPatcher, [{
|
|
1477
|
-
key: "options",
|
|
1478
|
-
value: function options(_options) {
|
|
1479
|
-
return this.processor.options(_options);
|
|
1480
|
-
}
|
|
1481
|
-
}, {
|
|
1482
|
-
key: "diff",
|
|
1483
|
-
value: function diff(left, right) {
|
|
1484
|
-
return this.processor.process(new DiffContext(left, right));
|
|
1485
|
-
}
|
|
1486
|
-
}, {
|
|
1487
|
-
key: "patch",
|
|
1488
|
-
value: function patch(left, delta) {
|
|
1489
|
-
return this.processor.process(new PatchContext(left, delta));
|
|
1490
|
-
}
|
|
1491
|
-
}, {
|
|
1492
|
-
key: "reverse",
|
|
1493
|
-
value: function reverse(delta) {
|
|
1494
|
-
return this.processor.process(new ReverseContext(delta));
|
|
1495
|
-
}
|
|
1496
|
-
}, {
|
|
1497
|
-
key: "unpatch",
|
|
1498
|
-
value: function unpatch(right, delta) {
|
|
1499
|
-
return this.patch(right, this.reverse(delta));
|
|
1500
|
-
}
|
|
1501
|
-
}, {
|
|
1502
|
-
key: "clone",
|
|
1503
|
-
value: function clone(value) {
|
|
1504
|
-
return clone$1(value);
|
|
1505
|
-
}
|
|
1506
|
-
}]);
|
|
1507
|
-
}();
|
|
186
|
+
function createBuildActions(differ, doMapActions, onBeforeDiff) {
|
|
187
|
+
var buildActionsConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
188
|
+
return function buildActions(now, before) {
|
|
189
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
190
|
+
if (!now || !before) throw new Error('Missing either `newObj` or `oldObj` ' + 'in order to build update actions');
|
|
191
|
+
var _applyOnBeforeDiff = applyOnBeforeDiff(before, now, onBeforeDiff),
|
|
192
|
+
_applyOnBeforeDiff2 = _slicedToArray(_applyOnBeforeDiff, 2),
|
|
193
|
+
processedBefore = _applyOnBeforeDiff2[0],
|
|
194
|
+
processedNow = _applyOnBeforeDiff2[1];
|
|
195
|
+
if (processedNow.variants && processedBefore.variants) processedNow.variants = injectMissingPriceIds(processedNow.variants, processedBefore.variants);
|
|
196
|
+
var diffed = differ(processedBefore, processedNow);
|
|
197
|
+
if (!buildActionsConfig.withHints && !diffed) return [];
|
|
198
|
+
return doMapActions(diffed, processedNow, processedBefore, options);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Array of action groups which need to be allowed or ignored.
|
|
203
|
+
// Example:
|
|
204
|
+
// [
|
|
205
|
+
// { type: 'base', group: 'ignore' },
|
|
206
|
+
// { type: 'prices', group: 'allow' },
|
|
207
|
+
// { type: 'variants', group: 'ignore' },
|
|
208
|
+
// ]
|
|
209
|
+
function createMapActionGroup() {
|
|
210
|
+
var actionGroups = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
211
|
+
return function mapActionGroup(type, fn) {
|
|
212
|
+
if (!Object.keys(actionGroups).length) return fn();
|
|
213
|
+
var found = actionGroups.find(function (c) {
|
|
214
|
+
return c.type === type;
|
|
215
|
+
});
|
|
216
|
+
if (!found) return [];
|
|
217
|
+
|
|
218
|
+
// Keep `black` for backwards compatibility.
|
|
219
|
+
if (found.group === 'ignore' || found.group === 'black') return [];
|
|
220
|
+
// Keep `white` for backwards compatibility.
|
|
221
|
+
if (found.group === 'allow' || found.group === 'white') return fn();
|
|
222
|
+
throw new Error("Action group '".concat(found.group, "' not supported. Use either \"allow\" or \"ignore\"."));
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function _arrayWithoutHoles(r) {
|
|
227
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function _iterableToArray(r) {
|
|
231
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function _nonIterableSpread() {
|
|
235
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function _toConsumableArray(r) {
|
|
239
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function _typeof(o) {
|
|
243
|
+
"@babel/helpers - typeof";
|
|
1508
244
|
|
|
1509
|
-
function
|
|
1510
|
-
|
|
245
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
246
|
+
return typeof o;
|
|
247
|
+
} : function (o) {
|
|
248
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
249
|
+
}, _typeof(o);
|
|
1511
250
|
}
|
|
1512
251
|
|
|
1513
252
|
function objectHash(obj, index) {
|
|
1514
253
|
var objIndex = "$$index:".concat(index);
|
|
1515
254
|
return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
|
|
1516
255
|
}
|
|
1517
|
-
var diffpatcher = create({
|
|
256
|
+
var diffpatcher = jsondiffpatch.create({
|
|
1518
257
|
objectHash: objectHash,
|
|
1519
258
|
arrays: {
|
|
1520
259
|
// detect items moved inside the array
|
|
@@ -1897,7 +636,7 @@ function buildReferenceActions(_ref4) {
|
|
|
1897
636
|
});
|
|
1898
637
|
}
|
|
1899
638
|
|
|
1900
|
-
var baseActionsList$
|
|
639
|
+
var baseActionsList$l = [{
|
|
1901
640
|
action: 'changeName',
|
|
1902
641
|
key: 'name'
|
|
1903
642
|
}, {
|
|
@@ -1935,10 +674,10 @@ var referenceActionsList$3 = [{
|
|
|
1935
674
|
* SYNC FUNCTIONS
|
|
1936
675
|
*/
|
|
1937
676
|
|
|
1938
|
-
function actionsMapBase$
|
|
677
|
+
function actionsMapBase$l(diff, oldObj, newObj) {
|
|
1939
678
|
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1940
679
|
return buildBaseAttributesActions({
|
|
1941
|
-
actions: baseActionsList$
|
|
680
|
+
actions: baseActionsList$l,
|
|
1942
681
|
diff: diff,
|
|
1943
682
|
oldObj: oldObj,
|
|
1944
683
|
newObj: newObj,
|
|
@@ -1951,6 +690,7 @@ function actionsMapReferences$3(diff, oldObj, newObj) {
|
|
|
1951
690
|
return buildReferenceActions({
|
|
1952
691
|
actions: referenceActionsList$3,
|
|
1953
692
|
diff: diff,
|
|
693
|
+
oldObj: oldObj,
|
|
1954
694
|
newObj: newObj
|
|
1955
695
|
});
|
|
1956
696
|
}
|
|
@@ -2034,7 +774,7 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
|
|
|
2034
774
|
return function doMapActions(diff, newObj, oldObj) {
|
|
2035
775
|
var allActions = [];
|
|
2036
776
|
allActions.push(mapActionGroup('base', function () {
|
|
2037
|
-
return actionsMapBase$
|
|
777
|
+
return actionsMapBase$l(diff, oldObj, newObj, syncActionConfig);
|
|
2038
778
|
}));
|
|
2039
779
|
allActions.push(mapActionGroup('references', function () {
|
|
2040
780
|
return actionsMapReferences$3(diff, oldObj, newObj);
|
|
@@ -2072,7 +812,7 @@ var categories = (function (actionGroupList, syncActionConfig) {
|
|
|
2072
812
|
});
|
|
2073
813
|
|
|
2074
814
|
var isEmptyValue = createIsEmptyValue([undefined, null, '']);
|
|
2075
|
-
var baseActionsList$
|
|
815
|
+
var baseActionsList$k = [{
|
|
2076
816
|
action: 'setSalutation',
|
|
2077
817
|
key: 'salutation'
|
|
2078
818
|
}, {
|
|
@@ -2138,10 +878,10 @@ var authenticationModeActionsList = [{
|
|
|
2138
878
|
* SYNC FUNCTIONS
|
|
2139
879
|
*/
|
|
2140
880
|
|
|
2141
|
-
function actionsMapBase$
|
|
881
|
+
function actionsMapBase$k(diff, oldObj, newObj) {
|
|
2142
882
|
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2143
883
|
return buildBaseAttributesActions({
|
|
2144
|
-
actions: baseActionsList$
|
|
884
|
+
actions: baseActionsList$k,
|
|
2145
885
|
diff: diff,
|
|
2146
886
|
oldObj: oldObj,
|
|
2147
887
|
newObj: newObj,
|
|
@@ -2166,6 +906,7 @@ function actionsMapReferences$2(diff, oldObj, newObj) {
|
|
|
2166
906
|
return buildReferenceActions({
|
|
2167
907
|
actions: referenceActionsList$2,
|
|
2168
908
|
diff: diff,
|
|
909
|
+
oldObj: oldObj,
|
|
2169
910
|
newObj: newObj
|
|
2170
911
|
});
|
|
2171
912
|
}
|
|
@@ -2281,7 +1022,7 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
|
|
|
2281
1022
|
return function doMapActions(diff, newObj, oldObj) {
|
|
2282
1023
|
var allActions = [];
|
|
2283
1024
|
allActions.push(mapActionGroup('base', function () {
|
|
2284
|
-
return actionsMapBase$
|
|
1025
|
+
return actionsMapBase$k(diff, oldObj, newObj, syncActionConfig);
|
|
2285
1026
|
}));
|
|
2286
1027
|
allActions.push(mapActionGroup('references', function () {
|
|
2287
1028
|
return actionsMapReferences$2(diff, oldObj, newObj);
|
|
@@ -2327,7 +1068,7 @@ var customers = (function (actionGroupList, syncActionConfig) {
|
|
|
2327
1068
|
};
|
|
2328
1069
|
});
|
|
2329
1070
|
|
|
2330
|
-
var baseActionsList$
|
|
1071
|
+
var baseActionsList$j = [{
|
|
2331
1072
|
action: 'changeQuantity',
|
|
2332
1073
|
key: 'quantityOnStock',
|
|
2333
1074
|
actionKey: 'quantity'
|
|
@@ -2347,10 +1088,10 @@ var referenceActionsList$1 = [{
|
|
|
2347
1088
|
* SYNC FUNCTIONS
|
|
2348
1089
|
*/
|
|
2349
1090
|
|
|
2350
|
-
function actionsMapBase$
|
|
1091
|
+
function actionsMapBase$j(diff, oldObj, newObj) {
|
|
2351
1092
|
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2352
1093
|
return buildBaseAttributesActions({
|
|
2353
|
-
actions: baseActionsList$
|
|
1094
|
+
actions: baseActionsList$j,
|
|
2354
1095
|
diff: diff,
|
|
2355
1096
|
oldObj: oldObj,
|
|
2356
1097
|
newObj: newObj,
|
|
@@ -2363,6 +1104,7 @@ function actionsMapReferences$1(diff, oldObj, newObj) {
|
|
|
2363
1104
|
return buildReferenceActions({
|
|
2364
1105
|
actions: referenceActionsList$1,
|
|
2365
1106
|
diff: diff,
|
|
1107
|
+
oldObj: oldObj,
|
|
2366
1108
|
newObj: newObj
|
|
2367
1109
|
});
|
|
2368
1110
|
}
|
|
@@ -2371,7 +1113,7 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
|
|
|
2371
1113
|
return function doMapActions(diff, newObj, oldObj) {
|
|
2372
1114
|
var allActions = [];
|
|
2373
1115
|
allActions.push(mapActionGroup('base', function () {
|
|
2374
|
-
return actionsMapBase$
|
|
1116
|
+
return actionsMapBase$j(diff, oldObj, newObj, syncActionConfig);
|
|
2375
1117
|
}));
|
|
2376
1118
|
allActions.push(mapActionGroup('references', function () {
|
|
2377
1119
|
return actionsMapReferences$1(diff, oldObj, newObj);
|
|
@@ -2461,7 +1203,7 @@ function findMatchingPairs(diff) {
|
|
|
2461
1203
|
|
|
2462
1204
|
var REGEX_NUMBER$2 = new RegExp(/^\d+$/);
|
|
2463
1205
|
var REGEX_UNDERSCORE_NUMBER$2 = new RegExp(/^_\d+$/);
|
|
2464
|
-
var baseActionsList$
|
|
1206
|
+
var baseActionsList$i = [{
|
|
2465
1207
|
action: 'changeName',
|
|
2466
1208
|
key: 'name'
|
|
2467
1209
|
}, {
|
|
@@ -2865,10 +1607,10 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
|
|
|
2865
1607
|
* SYNC FUNCTIONS
|
|
2866
1608
|
*/
|
|
2867
1609
|
|
|
2868
|
-
function actionsMapBase$
|
|
1610
|
+
function actionsMapBase$i(diff, oldObj, newObj) {
|
|
2869
1611
|
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2870
1612
|
return buildBaseAttributesActions({
|
|
2871
|
-
actions: baseActionsList$
|
|
1613
|
+
actions: baseActionsList$i,
|
|
2872
1614
|
diff: diff,
|
|
2873
1615
|
oldObj: oldObj,
|
|
2874
1616
|
newObj: newObj,
|
|
@@ -2909,6 +1651,7 @@ function actionsMapReferences(diff, oldObj, newObj) {
|
|
|
2909
1651
|
return buildReferenceActions({
|
|
2910
1652
|
actions: referenceActionsList,
|
|
2911
1653
|
diff: diff,
|
|
1654
|
+
oldObj: oldObj,
|
|
2912
1655
|
newObj: newObj
|
|
2913
1656
|
});
|
|
2914
1657
|
}
|
|
@@ -3104,7 +1847,7 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
|
|
|
3104
1847
|
return actionsMapRemoveVariants(diff, oldObj, newObj);
|
|
3105
1848
|
}));
|
|
3106
1849
|
allActions.push(mapActionGroup('base', function () {
|
|
3107
|
-
return actionsMapBase$
|
|
1850
|
+
return actionsMapBase$i(diff, oldObj, newObj, syncActionConfig);
|
|
3108
1851
|
}));
|
|
3109
1852
|
allActions.push(mapActionGroup('meta', function () {
|
|
3110
1853
|
return actionsMapMeta(diff, oldObj, newObj);
|
|
@@ -3171,7 +1914,7 @@ var isAddAction = function isAddAction(key, resource) {
|
|
|
3171
1914
|
var isRemoveAction = function isRemoveAction(key, resource) {
|
|
3172
1915
|
return REGEX_UNDERSCORE_NUMBER$1.test(key) && Number(resource[2]) === 0;
|
|
3173
1916
|
};
|
|
3174
|
-
var baseActionsList$
|
|
1917
|
+
var baseActionsList$h = [{
|
|
3175
1918
|
action: 'changeOrderState',
|
|
3176
1919
|
key: 'orderState'
|
|
3177
1920
|
}, {
|
|
@@ -3186,10 +1929,10 @@ var baseActionsList$g = [{
|
|
|
3186
1929
|
* SYNC FUNCTIONS
|
|
3187
1930
|
*/
|
|
3188
1931
|
|
|
3189
|
-
function actionsMapBase$
|
|
1932
|
+
function actionsMapBase$h(diff, oldObj, newObj) {
|
|
3190
1933
|
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3191
1934
|
return buildBaseAttributesActions({
|
|
3192
|
-
actions: baseActionsList$
|
|
1935
|
+
actions: baseActionsList$h,
|
|
3193
1936
|
diff: diff,
|
|
3194
1937
|
oldObj: oldObj,
|
|
3195
1938
|
newObj: newObj,
|
|
@@ -3339,7 +2082,7 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
|
|
|
3339
2082
|
deliveryHashMap = findMatchingPairs(diff.shippingInfo.deliveries, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries);
|
|
3340
2083
|
}
|
|
3341
2084
|
allActions.push(mapActionGroup('base', function () {
|
|
3342
|
-
return actionsMapBase$
|
|
2085
|
+
return actionsMapBase$h(diff, oldObj, newObj, syncActionConfig);
|
|
3343
2086
|
}));
|
|
3344
2087
|
allActions.push(mapActionGroup('deliveries', function () {
|
|
3345
2088
|
return actionsMapDeliveries(diff, oldObj, newObj);
|
|
@@ -3379,6 +2122,50 @@ var orders = (function (actionGroupList, syncActionConfig) {
|
|
|
3379
2122
|
};
|
|
3380
2123
|
});
|
|
3381
2124
|
|
|
2125
|
+
var baseActionsList$g = [{
|
|
2126
|
+
action: 'setKey',
|
|
2127
|
+
key: 'key'
|
|
2128
|
+
}, {
|
|
2129
|
+
action: 'setRecurringOrderState',
|
|
2130
|
+
key: 'recurringOrderState'
|
|
2131
|
+
}, {
|
|
2132
|
+
action: 'transitionState',
|
|
2133
|
+
key: 'state'
|
|
2134
|
+
}];
|
|
2135
|
+
function actionsMapBase$g(diff, oldObj, newObj) {
|
|
2136
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2137
|
+
return buildBaseAttributesActions({
|
|
2138
|
+
actions: baseActionsList$g,
|
|
2139
|
+
diff: diff,
|
|
2140
|
+
oldObj: oldObj,
|
|
2141
|
+
newObj: newObj,
|
|
2142
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString,
|
|
2143
|
+
shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties,
|
|
2144
|
+
shouldPreventUnsettingRequiredFields: config.shouldPreventUnsettingRequiredFields
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
function createRecurringOrdersMapActions(mapActionGroup, syncActionConfig) {
|
|
2149
|
+
return function doMapActions(diff, newObj, oldObj) {
|
|
2150
|
+
var allActions = [];
|
|
2151
|
+
allActions.push(mapActionGroup('base', function () {
|
|
2152
|
+
return actionsMapBase$g(diff, oldObj, newObj, syncActionConfig);
|
|
2153
|
+
}));
|
|
2154
|
+
allActions.push(mapActionGroup('custom', function () {
|
|
2155
|
+
return actionsMapCustom(diff, newObj, oldObj);
|
|
2156
|
+
}));
|
|
2157
|
+
return flatten(allActions);
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
var recurringOrders = (function (actionGroupList, syncActionConfig) {
|
|
2161
|
+
var mapActionGroup = createMapActionGroup(actionGroupList);
|
|
2162
|
+
var doMapActions = createRecurringOrdersMapActions(mapActionGroup, syncActionConfig);
|
|
2163
|
+
var buildActions = createBuildActions(diff, doMapActions);
|
|
2164
|
+
return {
|
|
2165
|
+
buildActions: buildActions
|
|
2166
|
+
};
|
|
2167
|
+
});
|
|
2168
|
+
|
|
3382
2169
|
var baseActionsList$f = [{
|
|
3383
2170
|
action: 'changeIsActive',
|
|
3384
2171
|
key: 'isActive'
|
|
@@ -3657,304 +2444,6 @@ var cartDiscounts = (function (actionGroupList) {
|
|
|
3657
2444
|
};
|
|
3658
2445
|
});
|
|
3659
2446
|
|
|
3660
|
-
var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
|
3661
|
-
var keys = Object.keys;
|
|
3662
|
-
/**
|
|
3663
|
-
* are the values passed strictly equal or both NaN
|
|
3664
|
-
*
|
|
3665
|
-
* @param a the value to compare against
|
|
3666
|
-
* @param b the value to test
|
|
3667
|
-
* @returns are the values equal by the SameValueZero principle
|
|
3668
|
-
*/
|
|
3669
|
-
function sameValueZeroEqual(a, b) {
|
|
3670
|
-
return a === b || a !== a && b !== b;
|
|
3671
|
-
}
|
|
3672
|
-
/**
|
|
3673
|
-
* is the value a plain object
|
|
3674
|
-
*
|
|
3675
|
-
* @param value the value to test
|
|
3676
|
-
* @returns is the value a plain object
|
|
3677
|
-
*/
|
|
3678
|
-
function isPlainObject(value) {
|
|
3679
|
-
return value.constructor === Object || value.constructor == null;
|
|
3680
|
-
}
|
|
3681
|
-
/**
|
|
3682
|
-
* is the value promise-like (meaning it is thenable)
|
|
3683
|
-
*
|
|
3684
|
-
* @param value the value to test
|
|
3685
|
-
* @returns is the value promise-like
|
|
3686
|
-
*/
|
|
3687
|
-
function isPromiseLike(value) {
|
|
3688
|
-
return !!value && typeof value.then === 'function';
|
|
3689
|
-
}
|
|
3690
|
-
/**
|
|
3691
|
-
* is the value passed a react element
|
|
3692
|
-
*
|
|
3693
|
-
* @param value the value to test
|
|
3694
|
-
* @returns is the value a react element
|
|
3695
|
-
*/
|
|
3696
|
-
function isReactElement(value) {
|
|
3697
|
-
return !!(value && value.$$typeof);
|
|
3698
|
-
}
|
|
3699
|
-
/**
|
|
3700
|
-
* in cases where WeakSet is not supported, creates a new custom
|
|
3701
|
-
* object that mimics the necessary API aspects for cache purposes
|
|
3702
|
-
*
|
|
3703
|
-
* @returns the new cache object
|
|
3704
|
-
*/
|
|
3705
|
-
function getNewCacheFallback() {
|
|
3706
|
-
var values = [];
|
|
3707
|
-
return {
|
|
3708
|
-
add: function add(value) {
|
|
3709
|
-
values.push(value);
|
|
3710
|
-
},
|
|
3711
|
-
has: function has(value) {
|
|
3712
|
-
return values.indexOf(value) !== -1;
|
|
3713
|
-
}
|
|
3714
|
-
};
|
|
3715
|
-
}
|
|
3716
|
-
/**
|
|
3717
|
-
* get a new cache object to prevent circular references
|
|
3718
|
-
*
|
|
3719
|
-
* @returns the new cache object
|
|
3720
|
-
*/
|
|
3721
|
-
var getNewCache = function (canUseWeakMap) {
|
|
3722
|
-
if (canUseWeakMap) {
|
|
3723
|
-
return function _getNewCache() {
|
|
3724
|
-
return new WeakSet();
|
|
3725
|
-
};
|
|
3726
|
-
}
|
|
3727
|
-
return getNewCacheFallback;
|
|
3728
|
-
}(HAS_WEAKSET_SUPPORT);
|
|
3729
|
-
/**
|
|
3730
|
-
* create a custom isEqual handler specific to circular objects
|
|
3731
|
-
*
|
|
3732
|
-
* @param [isEqual] the isEqual comparator to use instead of isDeepEqual
|
|
3733
|
-
* @returns the method to create the `isEqual` function
|
|
3734
|
-
*/
|
|
3735
|
-
function createCircularEqualCreator(isEqual) {
|
|
3736
|
-
return function createCircularEqual(comparator) {
|
|
3737
|
-
var _comparator = isEqual || comparator;
|
|
3738
|
-
return function circularEqual(a, b, cache) {
|
|
3739
|
-
if (cache === void 0) {
|
|
3740
|
-
cache = getNewCache();
|
|
3741
|
-
}
|
|
3742
|
-
var isCacheableA = !!a && _typeof(a) === 'object';
|
|
3743
|
-
var isCacheableB = !!b && _typeof(b) === 'object';
|
|
3744
|
-
if (isCacheableA || isCacheableB) {
|
|
3745
|
-
var hasA = isCacheableA && cache.has(a);
|
|
3746
|
-
var hasB = isCacheableB && cache.has(b);
|
|
3747
|
-
if (hasA || hasB) {
|
|
3748
|
-
return hasA && hasB;
|
|
3749
|
-
}
|
|
3750
|
-
if (isCacheableA) {
|
|
3751
|
-
cache.add(a);
|
|
3752
|
-
}
|
|
3753
|
-
if (isCacheableB) {
|
|
3754
|
-
cache.add(b);
|
|
3755
|
-
}
|
|
3756
|
-
}
|
|
3757
|
-
return _comparator(a, b, cache);
|
|
3758
|
-
};
|
|
3759
|
-
};
|
|
3760
|
-
}
|
|
3761
|
-
/**
|
|
3762
|
-
* are the arrays equal in value
|
|
3763
|
-
*
|
|
3764
|
-
* @param a the array to test
|
|
3765
|
-
* @param b the array to test against
|
|
3766
|
-
* @param isEqual the comparator to determine equality
|
|
3767
|
-
* @param meta the meta object to pass through
|
|
3768
|
-
* @returns are the arrays equal
|
|
3769
|
-
*/
|
|
3770
|
-
function areArraysEqual(a, b, isEqual, meta) {
|
|
3771
|
-
var index = a.length;
|
|
3772
|
-
if (b.length !== index) {
|
|
3773
|
-
return false;
|
|
3774
|
-
}
|
|
3775
|
-
while (index-- > 0) {
|
|
3776
|
-
if (!isEqual(a[index], b[index], meta)) {
|
|
3777
|
-
return false;
|
|
3778
|
-
}
|
|
3779
|
-
}
|
|
3780
|
-
return true;
|
|
3781
|
-
}
|
|
3782
|
-
/**
|
|
3783
|
-
* are the maps equal in value
|
|
3784
|
-
*
|
|
3785
|
-
* @param a the map to test
|
|
3786
|
-
* @param b the map to test against
|
|
3787
|
-
* @param isEqual the comparator to determine equality
|
|
3788
|
-
* @param meta the meta map to pass through
|
|
3789
|
-
* @returns are the maps equal
|
|
3790
|
-
*/
|
|
3791
|
-
function areMapsEqual(a, b, isEqual, meta) {
|
|
3792
|
-
var isValueEqual = a.size === b.size;
|
|
3793
|
-
if (isValueEqual && a.size) {
|
|
3794
|
-
var matchedIndices_1 = {};
|
|
3795
|
-
a.forEach(function (aValue, aKey) {
|
|
3796
|
-
if (isValueEqual) {
|
|
3797
|
-
var hasMatch_1 = false;
|
|
3798
|
-
var matchIndex_1 = 0;
|
|
3799
|
-
b.forEach(function (bValue, bKey) {
|
|
3800
|
-
if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
|
|
3801
|
-
hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
|
|
3802
|
-
if (hasMatch_1) {
|
|
3803
|
-
matchedIndices_1[matchIndex_1] = true;
|
|
3804
|
-
}
|
|
3805
|
-
}
|
|
3806
|
-
matchIndex_1++;
|
|
3807
|
-
});
|
|
3808
|
-
isValueEqual = hasMatch_1;
|
|
3809
|
-
}
|
|
3810
|
-
});
|
|
3811
|
-
}
|
|
3812
|
-
return isValueEqual;
|
|
3813
|
-
}
|
|
3814
|
-
var OWNER = '_owner';
|
|
3815
|
-
var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
|
|
3816
|
-
/**
|
|
3817
|
-
* are the objects equal in value
|
|
3818
|
-
*
|
|
3819
|
-
* @param a the object to test
|
|
3820
|
-
* @param b the object to test against
|
|
3821
|
-
* @param isEqual the comparator to determine equality
|
|
3822
|
-
* @param meta the meta object to pass through
|
|
3823
|
-
* @returns are the objects equal
|
|
3824
|
-
*/
|
|
3825
|
-
function areObjectsEqual(a, b, isEqual, meta) {
|
|
3826
|
-
var keysA = keys(a);
|
|
3827
|
-
var index = keysA.length;
|
|
3828
|
-
if (keys(b).length !== index) {
|
|
3829
|
-
return false;
|
|
3830
|
-
}
|
|
3831
|
-
if (index) {
|
|
3832
|
-
var key = void 0;
|
|
3833
|
-
while (index-- > 0) {
|
|
3834
|
-
key = keysA[index];
|
|
3835
|
-
if (key === OWNER) {
|
|
3836
|
-
var reactElementA = isReactElement(a);
|
|
3837
|
-
var reactElementB = isReactElement(b);
|
|
3838
|
-
if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
|
|
3839
|
-
return false;
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
|
|
3843
|
-
return false;
|
|
3844
|
-
}
|
|
3845
|
-
}
|
|
3846
|
-
}
|
|
3847
|
-
return true;
|
|
3848
|
-
}
|
|
3849
|
-
/**
|
|
3850
|
-
* are the regExps equal in value
|
|
3851
|
-
*
|
|
3852
|
-
* @param a the regExp to test
|
|
3853
|
-
* @param b the regExp to test agains
|
|
3854
|
-
* @returns are the regExps equal
|
|
3855
|
-
*/
|
|
3856
|
-
function areRegExpsEqual(a, b) {
|
|
3857
|
-
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;
|
|
3858
|
-
}
|
|
3859
|
-
/**
|
|
3860
|
-
* are the sets equal in value
|
|
3861
|
-
*
|
|
3862
|
-
* @param a the set to test
|
|
3863
|
-
* @param b the set to test against
|
|
3864
|
-
* @param isEqual the comparator to determine equality
|
|
3865
|
-
* @param meta the meta set to pass through
|
|
3866
|
-
* @returns are the sets equal
|
|
3867
|
-
*/
|
|
3868
|
-
function areSetsEqual(a, b, isEqual, meta) {
|
|
3869
|
-
var isValueEqual = a.size === b.size;
|
|
3870
|
-
if (isValueEqual && a.size) {
|
|
3871
|
-
var matchedIndices_2 = {};
|
|
3872
|
-
a.forEach(function (aValue) {
|
|
3873
|
-
if (isValueEqual) {
|
|
3874
|
-
var hasMatch_2 = false;
|
|
3875
|
-
var matchIndex_2 = 0;
|
|
3876
|
-
b.forEach(function (bValue) {
|
|
3877
|
-
if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
|
|
3878
|
-
hasMatch_2 = isEqual(aValue, bValue, meta);
|
|
3879
|
-
if (hasMatch_2) {
|
|
3880
|
-
matchedIndices_2[matchIndex_2] = true;
|
|
3881
|
-
}
|
|
3882
|
-
}
|
|
3883
|
-
matchIndex_2++;
|
|
3884
|
-
});
|
|
3885
|
-
isValueEqual = hasMatch_2;
|
|
3886
|
-
}
|
|
3887
|
-
});
|
|
3888
|
-
}
|
|
3889
|
-
return isValueEqual;
|
|
3890
|
-
}
|
|
3891
|
-
var HAS_MAP_SUPPORT = typeof Map === 'function';
|
|
3892
|
-
var HAS_SET_SUPPORT = typeof Set === 'function';
|
|
3893
|
-
function createComparator(createIsEqual) {
|
|
3894
|
-
var isEqual = /* eslint-disable no-use-before-define */
|
|
3895
|
-
typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
|
|
3896
|
-
/* eslint-enable */
|
|
3897
|
-
/**
|
|
3898
|
-
* compare the value of the two objects and return true if they are equivalent in values
|
|
3899
|
-
*
|
|
3900
|
-
* @param a the value to test against
|
|
3901
|
-
* @param b the value to test
|
|
3902
|
-
* @param [meta] an optional meta object that is passed through to all equality test calls
|
|
3903
|
-
* @returns are a and b equivalent in value
|
|
3904
|
-
*/
|
|
3905
|
-
function comparator(a, b, meta) {
|
|
3906
|
-
if (a === b) {
|
|
3907
|
-
return true;
|
|
3908
|
-
}
|
|
3909
|
-
if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
|
|
3910
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
3911
|
-
return areObjectsEqual(a, b, isEqual, meta);
|
|
3912
|
-
}
|
|
3913
|
-
var aShape = Array.isArray(a);
|
|
3914
|
-
var bShape = Array.isArray(b);
|
|
3915
|
-
if (aShape || bShape) {
|
|
3916
|
-
return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
|
|
3917
|
-
}
|
|
3918
|
-
aShape = a instanceof Date;
|
|
3919
|
-
bShape = b instanceof Date;
|
|
3920
|
-
if (aShape || bShape) {
|
|
3921
|
-
return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
|
|
3922
|
-
}
|
|
3923
|
-
aShape = a instanceof RegExp;
|
|
3924
|
-
bShape = b instanceof RegExp;
|
|
3925
|
-
if (aShape || bShape) {
|
|
3926
|
-
return aShape === bShape && areRegExpsEqual(a, b);
|
|
3927
|
-
}
|
|
3928
|
-
if (isPromiseLike(a) || isPromiseLike(b)) {
|
|
3929
|
-
return a === b;
|
|
3930
|
-
}
|
|
3931
|
-
if (HAS_MAP_SUPPORT) {
|
|
3932
|
-
aShape = a instanceof Map;
|
|
3933
|
-
bShape = b instanceof Map;
|
|
3934
|
-
if (aShape || bShape) {
|
|
3935
|
-
return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
|
|
3936
|
-
}
|
|
3937
|
-
}
|
|
3938
|
-
if (HAS_SET_SUPPORT) {
|
|
3939
|
-
aShape = a instanceof Set;
|
|
3940
|
-
bShape = b instanceof Set;
|
|
3941
|
-
if (aShape || bShape) {
|
|
3942
|
-
return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
|
|
3943
|
-
}
|
|
3944
|
-
}
|
|
3945
|
-
return areObjectsEqual(a, b, isEqual, meta);
|
|
3946
|
-
}
|
|
3947
|
-
return a !== a && b !== b;
|
|
3948
|
-
}
|
|
3949
|
-
return comparator;
|
|
3950
|
-
}
|
|
3951
|
-
var deepEqual = createComparator();
|
|
3952
|
-
createComparator(function () {
|
|
3953
|
-
return sameValueZeroEqual;
|
|
3954
|
-
});
|
|
3955
|
-
createComparator(createCircularEqualCreator());
|
|
3956
|
-
createComparator(createCircularEqualCreator(sameValueZeroEqual));
|
|
3957
|
-
|
|
3958
2447
|
var _excluded = ["__typename"];
|
|
3959
2448
|
function removeTypename(obj) {
|
|
3960
2449
|
obj.__typename;
|
|
@@ -4827,7 +3316,7 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
|
|
|
4827
3316
|
// Make sure to execute removeActions before creating new ones
|
|
4828
3317
|
// in order to prevent any eventual removal of `addAction`.
|
|
4829
3318
|
// List of `removeActions` can be found here
|
|
4830
|
-
// https://docs.commercetools.com/
|
|
3319
|
+
// https://docs.commercetools.com/api/projects/types#change-key
|
|
4831
3320
|
var sortedActions = sortBy(actions, function (action) {
|
|
4832
3321
|
return action.action !== 'removeFieldDefinition';
|
|
4833
3322
|
});
|
|
@@ -4886,6 +3375,10 @@ var customerSearchActionsList = [{
|
|
|
4886
3375
|
action: 'changeCustomerSearchStatus',
|
|
4887
3376
|
key: 'status'
|
|
4888
3377
|
}];
|
|
3378
|
+
var businessUnitSearchActionsList = [{
|
|
3379
|
+
action: 'changeBusinessUnitSearchStatus',
|
|
3380
|
+
key: 'status'
|
|
3381
|
+
}];
|
|
4889
3382
|
function actionsMapBase$4(diff, oldObj, newObj) {
|
|
4890
3383
|
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
4891
3384
|
return buildBaseAttributesActions({
|
|
@@ -4917,11 +3410,21 @@ function actionsMapSearchIndexingConfiguration(diff, oldObj, newObj) {
|
|
|
4917
3410
|
if (!searchIndexing) {
|
|
4918
3411
|
return [];
|
|
4919
3412
|
}
|
|
4920
|
-
var
|
|
4921
|
-
|
|
3413
|
+
var businessUnits = searchIndexing.businessUnits,
|
|
3414
|
+
customers = searchIndexing.customers;
|
|
3415
|
+
if (!customers && !businessUnits) {
|
|
4922
3416
|
return [];
|
|
4923
3417
|
}
|
|
4924
|
-
|
|
3418
|
+
var businessUnitsActions = businessUnits ? buildBaseAttributesActions({
|
|
3419
|
+
actions: businessUnitSearchActionsList,
|
|
3420
|
+
diff: diff.searchIndexing.businessUnits,
|
|
3421
|
+
oldObj: oldObj.searchIndexing.businessUnits,
|
|
3422
|
+
newObj: newObj.searchIndexing.businessUnits,
|
|
3423
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString,
|
|
3424
|
+
shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties,
|
|
3425
|
+
shouldPreventUnsettingRequiredFields: config.shouldPreventUnsettingRequiredFields
|
|
3426
|
+
}) : [];
|
|
3427
|
+
var customersActions = customers ? buildBaseAttributesActions({
|
|
4925
3428
|
actions: customerSearchActionsList,
|
|
4926
3429
|
diff: diff.searchIndexing.customers,
|
|
4927
3430
|
oldObj: oldObj.searchIndexing.customers,
|
|
@@ -4929,7 +3432,8 @@ function actionsMapSearchIndexingConfiguration(diff, oldObj, newObj) {
|
|
|
4929
3432
|
shouldOmitEmptyString: config.shouldOmitEmptyString,
|
|
4930
3433
|
shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties,
|
|
4931
3434
|
shouldPreventUnsettingRequiredFields: config.shouldPreventUnsettingRequiredFields
|
|
4932
|
-
});
|
|
3435
|
+
}) : [];
|
|
3436
|
+
return [].concat(_toConsumableArray(businessUnitsActions), _toConsumableArray(customersActions));
|
|
4933
3437
|
}
|
|
4934
3438
|
|
|
4935
3439
|
function createChannelsMapActions(mapActionGroup, syncActionConfig) {
|
|
@@ -5185,4 +3689,4 @@ var attributeGroups = (function (actionGroupList, syncActionConfig) {
|
|
|
5185
3689
|
};
|
|
5186
3690
|
});
|
|
5187
3691
|
|
|
5188
|
-
export { attributeGroups as createSyncAttributeGroups, cartDiscounts as createSyncCartDiscounts, categories as createSyncCategories, channels as createSyncChannels, customerGroup as createSyncCustomerGroup, customers as createSyncCustomers, discountCodes as createSyncDiscountCodes, inventories as createSyncInventories, orders as createSyncOrders, productDiscounts as createSyncProductDiscounts, productSelections as createSyncProductSelections, productTypes as createSyncProductTypes, products as createSyncProducts, projects as createSyncProjects, shippingMethods as createSyncShippingMethods, prices as createSyncStandalonePrices, states as createSyncStates, stores as createSyncStores, taxCategories as createSyncTaxCategories, types as createSyncTypes, zones as createSyncZones };
|
|
3692
|
+
export { attributeGroups as createSyncAttributeGroups, cartDiscounts as createSyncCartDiscounts, categories as createSyncCategories, channels as createSyncChannels, customerGroup as createSyncCustomerGroup, customers as createSyncCustomers, discountCodes as createSyncDiscountCodes, inventories as createSyncInventories, orders as createSyncOrders, productDiscounts as createSyncProductDiscounts, productSelections as createSyncProductSelections, productTypes as createSyncProductTypes, products as createSyncProducts, projects as createSyncProjects, recurringOrders as createSyncRecurringOrders, shippingMethods as createSyncShippingMethods, prices as createSyncStandalonePrices, states as createSyncStates, stores as createSyncStores, taxCategories as createSyncTaxCategories, types as createSyncTypes, zones as createSyncZones };
|