@commercetools/sync-actions 5.19.0 → 5.19.2
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/CHANGELOG.md +12 -0
- package/dist/sync-actions.cjs.js +416 -399
- package/dist/sync-actions.es.js +416 -399
- package/dist/sync-actions.umd.js +416 -399
- package/dist/sync-actions.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/sync-actions.umd.js
CHANGED
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
var _excluded$
|
|
151
|
+
var _excluded$2 = ["prices"];
|
|
152
152
|
function applyOnBeforeDiff(before, now, fn) {
|
|
153
153
|
return fn && typeof fn === 'function' ? fn(before, now) : [before, now];
|
|
154
154
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
function injectMissingPriceIds(nextVariants, previousVariants) {
|
|
180
180
|
return nextVariants.map(function (newVariant) {
|
|
181
181
|
var prices = newVariant.prices,
|
|
182
|
-
restOfVariant = _objectWithoutProperties(newVariant, _excluded$
|
|
182
|
+
restOfVariant = _objectWithoutProperties(newVariant, _excluded$2);
|
|
183
183
|
if (!prices) return restOfVariant;
|
|
184
184
|
var oldVariant = previousVariants.find(function (previousVariant) {
|
|
185
185
|
return !isNil__default["default"](previousVariant.id) && previousVariant.id === newVariant.id || !isNil__default["default"](previousVariant.key) && previousVariant.key === newVariant.key || !isNil__default["default"](previousVariant.sku) && previousVariant.sku === newVariant.sku;
|
|
@@ -292,7 +292,7 @@
|
|
|
292
292
|
throw new Error("Got unsupported number ".concat(arr[2], " in delta value"));
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
var _excluded = ["actions"];
|
|
295
|
+
var _excluded$1 = ["actions"];
|
|
296
296
|
var Actions = {
|
|
297
297
|
setCustomType: 'setCustomType',
|
|
298
298
|
setCustomField: 'setCustomField'
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
};
|
|
328
328
|
var actions = [];
|
|
329
329
|
var customPropsActions = customProps.actions,
|
|
330
|
-
options = _objectWithoutProperties(customProps, _excluded);
|
|
330
|
+
options = _objectWithoutProperties(customProps, _excluded$1);
|
|
331
331
|
var actionGroup = _objectSpread2(_objectSpread2({}, Actions), customPropsActions);
|
|
332
332
|
if (!diff.custom) return actions;
|
|
333
333
|
if (hasSingleCustomFieldChanged(diff)) {
|
|
@@ -1838,7 +1838,7 @@
|
|
|
1838
1838
|
allActions.push(mapActionGroup('categories', function () {
|
|
1839
1839
|
return actionsMapCategories(diff);
|
|
1840
1840
|
}));
|
|
1841
|
-
allActions.push(mapActionGroup('
|
|
1841
|
+
allActions.push(mapActionGroup('categoryOrderHints', function () {
|
|
1842
1842
|
return actionsMapCategoryOrderHints(diff);
|
|
1843
1843
|
}));
|
|
1844
1844
|
allActions.push(mapActionGroup('assets', function () {
|
|
@@ -2361,406 +2361,104 @@
|
|
|
2361
2361
|
};
|
|
2362
2362
|
});
|
|
2363
2363
|
|
|
2364
|
-
var
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2376
|
-
return buildBaseAttributesActions({
|
|
2377
|
-
actions: baseActionsList$b,
|
|
2378
|
-
diff: diff,
|
|
2379
|
-
oldObj: oldObj,
|
|
2380
|
-
newObj: newObj,
|
|
2381
|
-
shouldOmitEmptyString: config.shouldOmitEmptyString
|
|
2382
|
-
});
|
|
2364
|
+
var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
|
2365
|
+
var keys = Object.keys;
|
|
2366
|
+
/**
|
|
2367
|
+
* are the values passed strictly equal or both NaN
|
|
2368
|
+
*
|
|
2369
|
+
* @param a the value to compare against
|
|
2370
|
+
* @param b the value to test
|
|
2371
|
+
* @returns are the values equal by the SameValueZero principle
|
|
2372
|
+
*/
|
|
2373
|
+
function sameValueZeroEqual(a, b) {
|
|
2374
|
+
return a === b || a !== a && b !== b;
|
|
2383
2375
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
action: 'removeTaxRate',
|
|
2393
|
-
taxRateId: objectToRemove.id
|
|
2394
|
-
};
|
|
2395
|
-
}), CHANGE_ACTIONS, function (oldObject, updatedObject) {
|
|
2396
|
-
return {
|
|
2397
|
-
action: 'replaceTaxRate',
|
|
2398
|
-
taxRateId: oldObject.id === updatedObject.id ? oldObject.id : updatedObject.id,
|
|
2399
|
-
taxRate: updatedObject
|
|
2400
|
-
};
|
|
2401
|
-
}));
|
|
2402
|
-
return handler(diff, oldObj, newObj);
|
|
2376
|
+
/**
|
|
2377
|
+
* is the value a plain object
|
|
2378
|
+
*
|
|
2379
|
+
* @param value the value to test
|
|
2380
|
+
* @returns is the value a plain object
|
|
2381
|
+
*/
|
|
2382
|
+
function isPlainObject(value) {
|
|
2383
|
+
return value.constructor === Object || value.constructor == null;
|
|
2403
2384
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
return actionsMapRates(diff, oldObj, newObj);
|
|
2413
|
-
}));
|
|
2414
|
-
return flatten__default["default"](allActions);
|
|
2415
|
-
};
|
|
2385
|
+
/**
|
|
2386
|
+
* is the value promise-like (meaning it is thenable)
|
|
2387
|
+
*
|
|
2388
|
+
* @param value the value to test
|
|
2389
|
+
* @returns is the value promise-like
|
|
2390
|
+
*/
|
|
2391
|
+
function isPromiseLike(value) {
|
|
2392
|
+
return !!value && typeof value.then === 'function';
|
|
2416
2393
|
}
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2394
|
+
/**
|
|
2395
|
+
* is the value passed a react element
|
|
2396
|
+
*
|
|
2397
|
+
* @param value the value to test
|
|
2398
|
+
* @returns is the value a react element
|
|
2399
|
+
*/
|
|
2400
|
+
function isReactElement(value) {
|
|
2401
|
+
return !!(value && value.$$typeof);
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* in cases where WeakSet is not supported, creates a new custom
|
|
2405
|
+
* object that mimics the necessary API aspects for cache purposes
|
|
2406
|
+
*
|
|
2407
|
+
* @returns the new cache object
|
|
2408
|
+
*/
|
|
2409
|
+
function getNewCacheFallback() {
|
|
2410
|
+
var values = [];
|
|
2432
2411
|
return {
|
|
2433
|
-
|
|
2412
|
+
add: function add(value) {
|
|
2413
|
+
values.push(value);
|
|
2414
|
+
},
|
|
2415
|
+
has: function has(value) {
|
|
2416
|
+
return values.indexOf(value) !== -1;
|
|
2417
|
+
}
|
|
2434
2418
|
};
|
|
2435
|
-
});
|
|
2436
|
-
|
|
2437
|
-
var baseActionsList$a = [{
|
|
2438
|
-
action: 'changeName',
|
|
2439
|
-
key: 'name'
|
|
2440
|
-
}, {
|
|
2441
|
-
action: 'setDescription',
|
|
2442
|
-
key: 'description'
|
|
2443
|
-
}, {
|
|
2444
|
-
action: 'setKey',
|
|
2445
|
-
key: 'key'
|
|
2446
|
-
}];
|
|
2447
|
-
var hasLocation = function hasLocation(locations, otherLocation) {
|
|
2448
|
-
return locations.some(function (location) {
|
|
2449
|
-
return location.country === otherLocation.country;
|
|
2450
|
-
});
|
|
2451
|
-
};
|
|
2452
|
-
function actionsMapBase$a(diff, oldObj, newObj) {
|
|
2453
|
-
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2454
|
-
return buildBaseAttributesActions({
|
|
2455
|
-
actions: baseActionsList$a,
|
|
2456
|
-
diff: diff,
|
|
2457
|
-
oldObj: oldObj,
|
|
2458
|
-
newObj: newObj,
|
|
2459
|
-
shouldOmitEmptyString: config.shouldOmitEmptyString
|
|
2460
|
-
});
|
|
2461
2419
|
}
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
return (
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
return actionsMapLocations(diff, oldObj, newObj);
|
|
2505
|
-
})));
|
|
2506
|
-
return flatten__default["default"](allActions);
|
|
2507
|
-
};
|
|
2508
|
-
}
|
|
2509
|
-
var zones = (function (actionGroupList, syncActionConfig) {
|
|
2510
|
-
// config contains information about which action groups
|
|
2511
|
-
// are allowed or ignored
|
|
2512
|
-
|
|
2513
|
-
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
2514
|
-
// - action group name
|
|
2515
|
-
// - callback function that should return a list of actions that correspond
|
|
2516
|
-
// to the for the action group
|
|
2517
|
-
|
|
2518
|
-
// this resulting function mapActionGroup will call the callback function
|
|
2519
|
-
// for allowed action groups and return the return value of the callback
|
|
2520
|
-
// It will return an empty array for ignored action groups
|
|
2521
|
-
var mapActionGroup = createMapActionGroup(actionGroupList);
|
|
2522
|
-
var doMapActions = createZonesMapActions(mapActionGroup, syncActionConfig);
|
|
2523
|
-
var buildActions = createBuildActions(diff, doMapActions);
|
|
2524
|
-
return {
|
|
2525
|
-
buildActions: buildActions
|
|
2526
|
-
};
|
|
2527
|
-
});
|
|
2528
|
-
|
|
2529
|
-
var baseActionsList$9 = [{
|
|
2530
|
-
action: 'setKey',
|
|
2531
|
-
key: 'key'
|
|
2532
|
-
}, {
|
|
2533
|
-
action: 'changeName',
|
|
2534
|
-
key: 'name'
|
|
2535
|
-
}, {
|
|
2536
|
-
action: 'setLocalizedName',
|
|
2537
|
-
key: 'localizedName'
|
|
2538
|
-
}, {
|
|
2539
|
-
action: 'setDescription',
|
|
2540
|
-
key: 'description'
|
|
2541
|
-
}, {
|
|
2542
|
-
action: 'setLocalizedDescription',
|
|
2543
|
-
key: 'localizedDescription'
|
|
2544
|
-
}, {
|
|
2545
|
-
action: 'changeIsDefault',
|
|
2546
|
-
key: 'isDefault'
|
|
2547
|
-
}, {
|
|
2548
|
-
action: 'setPredicate',
|
|
2549
|
-
key: 'predicate'
|
|
2550
|
-
}, {
|
|
2551
|
-
action: 'changeTaxCategory',
|
|
2552
|
-
key: 'taxCategory'
|
|
2553
|
-
}, {
|
|
2554
|
-
action: 'changeActive',
|
|
2555
|
-
key: 'active'
|
|
2556
|
-
}];
|
|
2557
|
-
function actionsMapBase$9(diff, oldObj, newObj) {
|
|
2558
|
-
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2559
|
-
return buildBaseAttributesActions({
|
|
2560
|
-
actions: baseActionsList$9,
|
|
2561
|
-
diff: diff,
|
|
2562
|
-
oldObj: oldObj,
|
|
2563
|
-
newObj: newObj,
|
|
2564
|
-
shouldOmitEmptyString: config.shouldOmitEmptyString
|
|
2565
|
-
});
|
|
2566
|
-
}
|
|
2567
|
-
var addShippingRates = function addShippingRates(newZoneRate) {
|
|
2568
|
-
return newZoneRate.shippingRates ? newZoneRate.shippingRates.map(function (shippingRate) {
|
|
2569
|
-
return {
|
|
2570
|
-
action: 'addShippingRate',
|
|
2571
|
-
zone: newZoneRate.zone,
|
|
2572
|
-
shippingRate: shippingRate
|
|
2573
|
-
};
|
|
2574
|
-
}) : [];
|
|
2575
|
-
};
|
|
2576
|
-
function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
|
|
2577
|
-
var handler = createBuildArrayActions('shippingRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newShippingRate) {
|
|
2578
|
-
return {
|
|
2579
|
-
action: 'addShippingRate',
|
|
2580
|
-
zone: newObj.zone,
|
|
2581
|
-
shippingRate: newShippingRate
|
|
2582
|
-
};
|
|
2583
|
-
}), REMOVE_ACTIONS, function (oldShippingRate) {
|
|
2584
|
-
return {
|
|
2585
|
-
action: 'removeShippingRate',
|
|
2586
|
-
zone: oldObj.zone,
|
|
2587
|
-
shippingRate: oldShippingRate
|
|
2588
|
-
};
|
|
2589
|
-
}), CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
|
|
2590
|
-
return [{
|
|
2591
|
-
action: 'removeShippingRate',
|
|
2592
|
-
zone: oldObj.zone,
|
|
2593
|
-
shippingRate: oldShippingRate
|
|
2594
|
-
}, {
|
|
2595
|
-
action: 'addShippingRate',
|
|
2596
|
-
zone: newObj.zone,
|
|
2597
|
-
shippingRate: newShippingRate
|
|
2598
|
-
}];
|
|
2599
|
-
}));
|
|
2600
|
-
return handler(diff, oldObj, newObj);
|
|
2601
|
-
}
|
|
2602
|
-
function actionsMapZoneRates(diff, oldObj, newObj) {
|
|
2603
|
-
var handler = createBuildArrayActions('zoneRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newZoneRate) {
|
|
2604
|
-
return [{
|
|
2605
|
-
action: 'addZone',
|
|
2606
|
-
zone: newZoneRate.zone
|
|
2607
|
-
}].concat(_toConsumableArray(addShippingRates(newZoneRate)));
|
|
2608
|
-
}), REMOVE_ACTIONS, function (oldZoneRate) {
|
|
2609
|
-
return {
|
|
2610
|
-
action: 'removeZone',
|
|
2611
|
-
zone: oldZoneRate.zone
|
|
2612
|
-
};
|
|
2613
|
-
}), CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
|
|
2614
|
-
var hasZoneActions = false;
|
|
2615
|
-
var shippingRateActions = Object.keys(diff.zoneRates).reduce(function (actions, key) {
|
|
2616
|
-
if (diff.zoneRates[key].zone) hasZoneActions = true;
|
|
2617
|
-
if (diff.zoneRates[key].shippingRates) return [].concat(_toConsumableArray(actions), _toConsumableArray(actionsMapZoneRatesShippingRates(diff.zoneRates[key], oldZoneRate, newZoneRate)));
|
|
2618
|
-
return actions;
|
|
2619
|
-
}, []);
|
|
2620
|
-
return flatten__default["default"](hasZoneActions ? [].concat(_toConsumableArray(shippingRateActions), [{
|
|
2621
|
-
action: 'removeZone',
|
|
2622
|
-
zone: oldZoneRate.zone
|
|
2623
|
-
}, {
|
|
2624
|
-
action: 'addZone',
|
|
2625
|
-
zone: newZoneRate.zone
|
|
2626
|
-
}]) : shippingRateActions);
|
|
2627
|
-
}));
|
|
2628
|
-
return handler(diff, oldObj, newObj);
|
|
2629
|
-
}
|
|
2630
|
-
|
|
2631
|
-
function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
|
|
2632
|
-
return function doMapActions(diff, newObj, oldObj) {
|
|
2633
|
-
var allActions = [];
|
|
2634
|
-
allActions.push(mapActionGroup('base', function () {
|
|
2635
|
-
return actionsMapBase$9(diff, oldObj, newObj, syncActionConfig);
|
|
2636
|
-
}));
|
|
2637
|
-
allActions.push(flatten__default["default"](mapActionGroup('zoneRates', function () {
|
|
2638
|
-
return actionsMapZoneRates(diff, oldObj, newObj);
|
|
2639
|
-
})));
|
|
2640
|
-
allActions.push(mapActionGroup('custom', function () {
|
|
2641
|
-
return actionsMapCustom(diff, newObj, oldObj);
|
|
2642
|
-
}));
|
|
2643
|
-
return flatten__default["default"](allActions);
|
|
2644
|
-
};
|
|
2645
|
-
}
|
|
2646
|
-
var shippingMethods = (function (actionGroupList, syncActionConfig) {
|
|
2647
|
-
// actionGroupList contains information about which action groups
|
|
2648
|
-
// are allowed or ignored
|
|
2649
|
-
|
|
2650
|
-
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
2651
|
-
// - action group name
|
|
2652
|
-
// - callback function that should return a list of actions that correspond
|
|
2653
|
-
// to the for the action group
|
|
2654
|
-
|
|
2655
|
-
// this resulting function mapActionGroup will call the callback function
|
|
2656
|
-
// for allowed action groups and return the return value of the callback
|
|
2657
|
-
// It will return an empty array for ignored action groups
|
|
2658
|
-
var mapActionGroup = createMapActionGroup(actionGroupList);
|
|
2659
|
-
var doMapActions = createShippingMethodsMapActions(mapActionGroup, syncActionConfig);
|
|
2660
|
-
var buildActions = createBuildActions(diff, doMapActions);
|
|
2661
|
-
return {
|
|
2662
|
-
buildActions: buildActions
|
|
2663
|
-
};
|
|
2664
|
-
});
|
|
2665
|
-
|
|
2666
|
-
var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
|
2667
|
-
var keys = Object.keys;
|
|
2668
|
-
/**
|
|
2669
|
-
* are the values passed strictly equal or both NaN
|
|
2670
|
-
*
|
|
2671
|
-
* @param a the value to compare against
|
|
2672
|
-
* @param b the value to test
|
|
2673
|
-
* @returns are the values equal by the SameValueZero principle
|
|
2674
|
-
*/
|
|
2675
|
-
function sameValueZeroEqual(a, b) {
|
|
2676
|
-
return a === b || a !== a && b !== b;
|
|
2677
|
-
}
|
|
2678
|
-
/**
|
|
2679
|
-
* is the value a plain object
|
|
2680
|
-
*
|
|
2681
|
-
* @param value the value to test
|
|
2682
|
-
* @returns is the value a plain object
|
|
2683
|
-
*/
|
|
2684
|
-
function isPlainObject(value) {
|
|
2685
|
-
return value.constructor === Object || value.constructor == null;
|
|
2686
|
-
}
|
|
2687
|
-
/**
|
|
2688
|
-
* is the value promise-like (meaning it is thenable)
|
|
2689
|
-
*
|
|
2690
|
-
* @param value the value to test
|
|
2691
|
-
* @returns is the value promise-like
|
|
2692
|
-
*/
|
|
2693
|
-
function isPromiseLike(value) {
|
|
2694
|
-
return !!value && typeof value.then === 'function';
|
|
2695
|
-
}
|
|
2696
|
-
/**
|
|
2697
|
-
* is the value passed a react element
|
|
2698
|
-
*
|
|
2699
|
-
* @param value the value to test
|
|
2700
|
-
* @returns is the value a react element
|
|
2701
|
-
*/
|
|
2702
|
-
function isReactElement(value) {
|
|
2703
|
-
return !!(value && value.$$typeof);
|
|
2704
|
-
}
|
|
2705
|
-
/**
|
|
2706
|
-
* in cases where WeakSet is not supported, creates a new custom
|
|
2707
|
-
* object that mimics the necessary API aspects for cache purposes
|
|
2708
|
-
*
|
|
2709
|
-
* @returns the new cache object
|
|
2710
|
-
*/
|
|
2711
|
-
function getNewCacheFallback() {
|
|
2712
|
-
var values = [];
|
|
2713
|
-
return {
|
|
2714
|
-
add: function add(value) {
|
|
2715
|
-
values.push(value);
|
|
2716
|
-
},
|
|
2717
|
-
has: function has(value) {
|
|
2718
|
-
return values.indexOf(value) !== -1;
|
|
2719
|
-
}
|
|
2720
|
-
};
|
|
2721
|
-
}
|
|
2722
|
-
/**
|
|
2723
|
-
* get a new cache object to prevent circular references
|
|
2724
|
-
*
|
|
2725
|
-
* @returns the new cache object
|
|
2726
|
-
*/
|
|
2727
|
-
var getNewCache = function (canUseWeakMap) {
|
|
2728
|
-
if (canUseWeakMap) {
|
|
2729
|
-
return function _getNewCache() {
|
|
2730
|
-
return new WeakSet();
|
|
2731
|
-
};
|
|
2732
|
-
}
|
|
2733
|
-
return getNewCacheFallback;
|
|
2734
|
-
}(HAS_WEAKSET_SUPPORT);
|
|
2735
|
-
/**
|
|
2736
|
-
* create a custom isEqual handler specific to circular objects
|
|
2737
|
-
*
|
|
2738
|
-
* @param [isEqual] the isEqual comparator to use instead of isDeepEqual
|
|
2739
|
-
* @returns the method to create the `isEqual` function
|
|
2740
|
-
*/
|
|
2741
|
-
function createCircularEqualCreator(isEqual) {
|
|
2742
|
-
return function createCircularEqual(comparator) {
|
|
2743
|
-
var _comparator = isEqual || comparator;
|
|
2744
|
-
return function circularEqual(a, b, cache) {
|
|
2745
|
-
if (cache === void 0) {
|
|
2746
|
-
cache = getNewCache();
|
|
2747
|
-
}
|
|
2748
|
-
var isCacheableA = !!a && _typeof(a) === 'object';
|
|
2749
|
-
var isCacheableB = !!b && _typeof(b) === 'object';
|
|
2750
|
-
if (isCacheableA || isCacheableB) {
|
|
2751
|
-
var hasA = isCacheableA && cache.has(a);
|
|
2752
|
-
var hasB = isCacheableB && cache.has(b);
|
|
2753
|
-
if (hasA || hasB) {
|
|
2754
|
-
return hasA && hasB;
|
|
2755
|
-
}
|
|
2756
|
-
if (isCacheableA) {
|
|
2757
|
-
cache.add(a);
|
|
2758
|
-
}
|
|
2759
|
-
if (isCacheableB) {
|
|
2760
|
-
cache.add(b);
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
return _comparator(a, b, cache);
|
|
2420
|
+
/**
|
|
2421
|
+
* get a new cache object to prevent circular references
|
|
2422
|
+
*
|
|
2423
|
+
* @returns the new cache object
|
|
2424
|
+
*/
|
|
2425
|
+
var getNewCache = function (canUseWeakMap) {
|
|
2426
|
+
if (canUseWeakMap) {
|
|
2427
|
+
return function _getNewCache() {
|
|
2428
|
+
return new WeakSet();
|
|
2429
|
+
};
|
|
2430
|
+
}
|
|
2431
|
+
return getNewCacheFallback;
|
|
2432
|
+
}(HAS_WEAKSET_SUPPORT);
|
|
2433
|
+
/**
|
|
2434
|
+
* create a custom isEqual handler specific to circular objects
|
|
2435
|
+
*
|
|
2436
|
+
* @param [isEqual] the isEqual comparator to use instead of isDeepEqual
|
|
2437
|
+
* @returns the method to create the `isEqual` function
|
|
2438
|
+
*/
|
|
2439
|
+
function createCircularEqualCreator(isEqual) {
|
|
2440
|
+
return function createCircularEqual(comparator) {
|
|
2441
|
+
var _comparator = isEqual || comparator;
|
|
2442
|
+
return function circularEqual(a, b, cache) {
|
|
2443
|
+
if (cache === void 0) {
|
|
2444
|
+
cache = getNewCache();
|
|
2445
|
+
}
|
|
2446
|
+
var isCacheableA = !!a && _typeof(a) === 'object';
|
|
2447
|
+
var isCacheableB = !!b && _typeof(b) === 'object';
|
|
2448
|
+
if (isCacheableA || isCacheableB) {
|
|
2449
|
+
var hasA = isCacheableA && cache.has(a);
|
|
2450
|
+
var hasB = isCacheableB && cache.has(b);
|
|
2451
|
+
if (hasA || hasB) {
|
|
2452
|
+
return hasA && hasB;
|
|
2453
|
+
}
|
|
2454
|
+
if (isCacheableA) {
|
|
2455
|
+
cache.add(a);
|
|
2456
|
+
}
|
|
2457
|
+
if (isCacheableB) {
|
|
2458
|
+
cache.add(b);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return _comparator(a, b, cache);
|
|
2764
2462
|
};
|
|
2765
2463
|
};
|
|
2766
2464
|
}
|
|
@@ -2961,6 +2659,325 @@
|
|
|
2961
2659
|
createComparator(createCircularEqualCreator());
|
|
2962
2660
|
createComparator(createCircularEqualCreator(sameValueZeroEqual));
|
|
2963
2661
|
|
|
2662
|
+
var _excluded = ["__typename"];
|
|
2663
|
+
function removeTypename(obj) {
|
|
2664
|
+
obj.__typename;
|
|
2665
|
+
var objWithoutTypename = _objectWithoutProperties(obj, _excluded);
|
|
2666
|
+
return objWithoutTypename;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
var baseActionsList$b = [{
|
|
2670
|
+
action: 'changeName',
|
|
2671
|
+
key: 'name'
|
|
2672
|
+
}, {
|
|
2673
|
+
action: 'setKey',
|
|
2674
|
+
key: 'key'
|
|
2675
|
+
}, {
|
|
2676
|
+
action: 'setDescription',
|
|
2677
|
+
key: 'description'
|
|
2678
|
+
}];
|
|
2679
|
+
function actionsMapBase$b(diff, oldObj, newObj) {
|
|
2680
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2681
|
+
return buildBaseAttributesActions({
|
|
2682
|
+
actions: baseActionsList$b,
|
|
2683
|
+
diff: diff,
|
|
2684
|
+
oldObj: oldObj,
|
|
2685
|
+
newObj: newObj,
|
|
2686
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
function actionsMapRates(diff, oldObj, newObj) {
|
|
2690
|
+
var handler = createBuildArrayActions('rates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newObject) {
|
|
2691
|
+
return {
|
|
2692
|
+
action: 'addTaxRate',
|
|
2693
|
+
taxRate: newObject
|
|
2694
|
+
};
|
|
2695
|
+
}), REMOVE_ACTIONS, function (objectToRemove) {
|
|
2696
|
+
return {
|
|
2697
|
+
action: 'removeTaxRate',
|
|
2698
|
+
taxRateId: objectToRemove.id
|
|
2699
|
+
};
|
|
2700
|
+
}), CHANGE_ACTIONS, function (oldObject, updatedObject) {
|
|
2701
|
+
var _oldObject$subRates;
|
|
2702
|
+
// filter out taxRates that were not changed
|
|
2703
|
+
// so the API doesn't return it with a different id
|
|
2704
|
+
// we need to remove __typename from the object to compare them
|
|
2705
|
+
var taxCategoryWithoutTypeName = removeTypename(oldObject);
|
|
2706
|
+
var oldObjectSubRatesWithoutTypename = (_oldObject$subRates = oldObject.subRates) === null || _oldObject$subRates === void 0 ? void 0 : _oldObject$subRates.map(removeTypename);
|
|
2707
|
+
var oldObjectWithoutTypename = _objectSpread2(_objectSpread2({}, taxCategoryWithoutTypeName), {}, {
|
|
2708
|
+
subRates: oldObjectSubRatesWithoutTypename
|
|
2709
|
+
});
|
|
2710
|
+
if (deepEqual(oldObjectWithoutTypename, updatedObject)) return null;
|
|
2711
|
+
return {
|
|
2712
|
+
action: 'replaceTaxRate',
|
|
2713
|
+
taxRateId: oldObject.id === updatedObject.id ? oldObject.id : updatedObject.id,
|
|
2714
|
+
taxRate: updatedObject
|
|
2715
|
+
};
|
|
2716
|
+
}));
|
|
2717
|
+
return handler(diff, oldObj, newObj);
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
function createTaxCategoriesMapActions(mapActionGroup, syncActionConfig) {
|
|
2721
|
+
return function doMapActions(diff, newObj, oldObj) {
|
|
2722
|
+
var allActions = [];
|
|
2723
|
+
allActions.push(mapActionGroup('base', function () {
|
|
2724
|
+
return actionsMapBase$b(diff, oldObj, newObj, syncActionConfig);
|
|
2725
|
+
}));
|
|
2726
|
+
allActions.push(mapActionGroup('rates', function () {
|
|
2727
|
+
return actionsMapRates(diff, oldObj, newObj);
|
|
2728
|
+
}));
|
|
2729
|
+
return flatten__default["default"](allActions);
|
|
2730
|
+
};
|
|
2731
|
+
}
|
|
2732
|
+
var taxCategories = (function (actionGroupList, syncActionConfig) {
|
|
2733
|
+
// config contains information about which action groups
|
|
2734
|
+
// are allowed or ignored
|
|
2735
|
+
|
|
2736
|
+
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
2737
|
+
// - action group name
|
|
2738
|
+
// - callback function that should return a list of actions that correspond
|
|
2739
|
+
// to the for the action group
|
|
2740
|
+
|
|
2741
|
+
// this resulting function mapActionGroup will call the callback function
|
|
2742
|
+
// for allowed action groups and return the return value of the callback
|
|
2743
|
+
// It will return an empty array for ignored action groups
|
|
2744
|
+
var mapActionGroup = createMapActionGroup(actionGroupList);
|
|
2745
|
+
var doMapActions = createTaxCategoriesMapActions(mapActionGroup, syncActionConfig);
|
|
2746
|
+
var buildActions = createBuildActions(diff, doMapActions);
|
|
2747
|
+
return {
|
|
2748
|
+
buildActions: buildActions
|
|
2749
|
+
};
|
|
2750
|
+
});
|
|
2751
|
+
|
|
2752
|
+
var baseActionsList$a = [{
|
|
2753
|
+
action: 'changeName',
|
|
2754
|
+
key: 'name'
|
|
2755
|
+
}, {
|
|
2756
|
+
action: 'setDescription',
|
|
2757
|
+
key: 'description'
|
|
2758
|
+
}, {
|
|
2759
|
+
action: 'setKey',
|
|
2760
|
+
key: 'key'
|
|
2761
|
+
}];
|
|
2762
|
+
var hasLocation = function hasLocation(locations, otherLocation) {
|
|
2763
|
+
return locations.some(function (location) {
|
|
2764
|
+
return location.country === otherLocation.country;
|
|
2765
|
+
});
|
|
2766
|
+
};
|
|
2767
|
+
function actionsMapBase$a(diff, oldObj, newObj) {
|
|
2768
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2769
|
+
return buildBaseAttributesActions({
|
|
2770
|
+
actions: baseActionsList$a,
|
|
2771
|
+
diff: diff,
|
|
2772
|
+
oldObj: oldObj,
|
|
2773
|
+
newObj: newObj,
|
|
2774
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
function actionsMapLocations(diff, oldObj, newObj) {
|
|
2778
|
+
var handler = createBuildArrayActions('locations', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newLocation) {
|
|
2779
|
+
return {
|
|
2780
|
+
action: 'addLocation',
|
|
2781
|
+
location: newLocation
|
|
2782
|
+
};
|
|
2783
|
+
}), REMOVE_ACTIONS, function (oldLocation) {
|
|
2784
|
+
return (
|
|
2785
|
+
// We only add the action if the location is not included in the new object.
|
|
2786
|
+
!hasLocation(newObj.locations, oldLocation) ? {
|
|
2787
|
+
action: 'removeLocation',
|
|
2788
|
+
location: oldLocation
|
|
2789
|
+
} : null
|
|
2790
|
+
);
|
|
2791
|
+
}), CHANGE_ACTIONS, function (oldLocation, newLocation) {
|
|
2792
|
+
var result = [];
|
|
2793
|
+
|
|
2794
|
+
// We only remove the location in case that the oldLocation is not
|
|
2795
|
+
// included in the new object
|
|
2796
|
+
if (!hasLocation(newObj.locations, oldLocation)) result.push({
|
|
2797
|
+
action: 'removeLocation',
|
|
2798
|
+
location: oldLocation
|
|
2799
|
+
});
|
|
2800
|
+
|
|
2801
|
+
// We only add the location in case that the newLocation was not
|
|
2802
|
+
// included in the old object
|
|
2803
|
+
if (!hasLocation(oldObj.locations, newLocation)) result.push({
|
|
2804
|
+
action: 'addLocation',
|
|
2805
|
+
location: newLocation
|
|
2806
|
+
});
|
|
2807
|
+
return result;
|
|
2808
|
+
}));
|
|
2809
|
+
return handler(diff, oldObj, newObj);
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
function createZonesMapActions(mapActionGroup, syncActionConfig) {
|
|
2813
|
+
return function doMapActions(diff, newObj, oldObj) {
|
|
2814
|
+
var allActions = [];
|
|
2815
|
+
allActions.push(mapActionGroup('base', function () {
|
|
2816
|
+
return actionsMapBase$a(diff, oldObj, newObj, syncActionConfig);
|
|
2817
|
+
}));
|
|
2818
|
+
allActions.push(flatten__default["default"](mapActionGroup('locations', function () {
|
|
2819
|
+
return actionsMapLocations(diff, oldObj, newObj);
|
|
2820
|
+
})));
|
|
2821
|
+
return flatten__default["default"](allActions);
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
var zones = (function (actionGroupList, syncActionConfig) {
|
|
2825
|
+
// config contains information about which action groups
|
|
2826
|
+
// are allowed or ignored
|
|
2827
|
+
|
|
2828
|
+
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
2829
|
+
// - action group name
|
|
2830
|
+
// - callback function that should return a list of actions that correspond
|
|
2831
|
+
// to the for the action group
|
|
2832
|
+
|
|
2833
|
+
// this resulting function mapActionGroup will call the callback function
|
|
2834
|
+
// for allowed action groups and return the return value of the callback
|
|
2835
|
+
// It will return an empty array for ignored action groups
|
|
2836
|
+
var mapActionGroup = createMapActionGroup(actionGroupList);
|
|
2837
|
+
var doMapActions = createZonesMapActions(mapActionGroup, syncActionConfig);
|
|
2838
|
+
var buildActions = createBuildActions(diff, doMapActions);
|
|
2839
|
+
return {
|
|
2840
|
+
buildActions: buildActions
|
|
2841
|
+
};
|
|
2842
|
+
});
|
|
2843
|
+
|
|
2844
|
+
var baseActionsList$9 = [{
|
|
2845
|
+
action: 'setKey',
|
|
2846
|
+
key: 'key'
|
|
2847
|
+
}, {
|
|
2848
|
+
action: 'changeName',
|
|
2849
|
+
key: 'name'
|
|
2850
|
+
}, {
|
|
2851
|
+
action: 'setLocalizedName',
|
|
2852
|
+
key: 'localizedName'
|
|
2853
|
+
}, {
|
|
2854
|
+
action: 'setDescription',
|
|
2855
|
+
key: 'description'
|
|
2856
|
+
}, {
|
|
2857
|
+
action: 'setLocalizedDescription',
|
|
2858
|
+
key: 'localizedDescription'
|
|
2859
|
+
}, {
|
|
2860
|
+
action: 'changeIsDefault',
|
|
2861
|
+
key: 'isDefault'
|
|
2862
|
+
}, {
|
|
2863
|
+
action: 'setPredicate',
|
|
2864
|
+
key: 'predicate'
|
|
2865
|
+
}, {
|
|
2866
|
+
action: 'changeTaxCategory',
|
|
2867
|
+
key: 'taxCategory'
|
|
2868
|
+
}, {
|
|
2869
|
+
action: 'changeActive',
|
|
2870
|
+
key: 'active'
|
|
2871
|
+
}];
|
|
2872
|
+
function actionsMapBase$9(diff, oldObj, newObj) {
|
|
2873
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2874
|
+
return buildBaseAttributesActions({
|
|
2875
|
+
actions: baseActionsList$9,
|
|
2876
|
+
diff: diff,
|
|
2877
|
+
oldObj: oldObj,
|
|
2878
|
+
newObj: newObj,
|
|
2879
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
var addShippingRates = function addShippingRates(newZoneRate) {
|
|
2883
|
+
return newZoneRate.shippingRates ? newZoneRate.shippingRates.map(function (shippingRate) {
|
|
2884
|
+
return {
|
|
2885
|
+
action: 'addShippingRate',
|
|
2886
|
+
zone: newZoneRate.zone,
|
|
2887
|
+
shippingRate: shippingRate
|
|
2888
|
+
};
|
|
2889
|
+
}) : [];
|
|
2890
|
+
};
|
|
2891
|
+
function actionsMapZoneRatesShippingRates(diff, oldObj, newObj) {
|
|
2892
|
+
var handler = createBuildArrayActions('shippingRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newShippingRate) {
|
|
2893
|
+
return {
|
|
2894
|
+
action: 'addShippingRate',
|
|
2895
|
+
zone: newObj.zone,
|
|
2896
|
+
shippingRate: newShippingRate
|
|
2897
|
+
};
|
|
2898
|
+
}), REMOVE_ACTIONS, function (oldShippingRate) {
|
|
2899
|
+
return {
|
|
2900
|
+
action: 'removeShippingRate',
|
|
2901
|
+
zone: oldObj.zone,
|
|
2902
|
+
shippingRate: oldShippingRate
|
|
2903
|
+
};
|
|
2904
|
+
}), CHANGE_ACTIONS, function (oldShippingRate, newShippingRate) {
|
|
2905
|
+
return [{
|
|
2906
|
+
action: 'removeShippingRate',
|
|
2907
|
+
zone: oldObj.zone,
|
|
2908
|
+
shippingRate: oldShippingRate
|
|
2909
|
+
}, {
|
|
2910
|
+
action: 'addShippingRate',
|
|
2911
|
+
zone: newObj.zone,
|
|
2912
|
+
shippingRate: newShippingRate
|
|
2913
|
+
}];
|
|
2914
|
+
}));
|
|
2915
|
+
return handler(diff, oldObj, newObj);
|
|
2916
|
+
}
|
|
2917
|
+
function actionsMapZoneRates(diff, oldObj, newObj) {
|
|
2918
|
+
var handler = createBuildArrayActions('zoneRates', _defineProperty(_defineProperty(_defineProperty({}, ADD_ACTIONS, function (newZoneRate) {
|
|
2919
|
+
return [{
|
|
2920
|
+
action: 'addZone',
|
|
2921
|
+
zone: newZoneRate.zone
|
|
2922
|
+
}].concat(_toConsumableArray(addShippingRates(newZoneRate)));
|
|
2923
|
+
}), REMOVE_ACTIONS, function (oldZoneRate) {
|
|
2924
|
+
return {
|
|
2925
|
+
action: 'removeZone',
|
|
2926
|
+
zone: oldZoneRate.zone
|
|
2927
|
+
};
|
|
2928
|
+
}), CHANGE_ACTIONS, function (oldZoneRate, newZoneRate) {
|
|
2929
|
+
var hasZoneActions = false;
|
|
2930
|
+
var shippingRateActions = Object.keys(diff.zoneRates).reduce(function (actions, key) {
|
|
2931
|
+
if (diff.zoneRates[key].zone) hasZoneActions = true;
|
|
2932
|
+
if (diff.zoneRates[key].shippingRates) return [].concat(_toConsumableArray(actions), _toConsumableArray(actionsMapZoneRatesShippingRates(diff.zoneRates[key], oldZoneRate, newZoneRate)));
|
|
2933
|
+
return actions;
|
|
2934
|
+
}, []);
|
|
2935
|
+
return flatten__default["default"](hasZoneActions ? [].concat(_toConsumableArray(shippingRateActions), [{
|
|
2936
|
+
action: 'removeZone',
|
|
2937
|
+
zone: oldZoneRate.zone
|
|
2938
|
+
}, {
|
|
2939
|
+
action: 'addZone',
|
|
2940
|
+
zone: newZoneRate.zone
|
|
2941
|
+
}]) : shippingRateActions);
|
|
2942
|
+
}));
|
|
2943
|
+
return handler(diff, oldObj, newObj);
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
|
|
2947
|
+
return function doMapActions(diff, newObj, oldObj) {
|
|
2948
|
+
var allActions = [];
|
|
2949
|
+
allActions.push(mapActionGroup('base', function () {
|
|
2950
|
+
return actionsMapBase$9(diff, oldObj, newObj, syncActionConfig);
|
|
2951
|
+
}));
|
|
2952
|
+
allActions.push(flatten__default["default"](mapActionGroup('zoneRates', function () {
|
|
2953
|
+
return actionsMapZoneRates(diff, oldObj, newObj);
|
|
2954
|
+
})));
|
|
2955
|
+
allActions.push(mapActionGroup('custom', function () {
|
|
2956
|
+
return actionsMapCustom(diff, newObj, oldObj);
|
|
2957
|
+
}));
|
|
2958
|
+
return flatten__default["default"](allActions);
|
|
2959
|
+
};
|
|
2960
|
+
}
|
|
2961
|
+
var shippingMethods = (function (actionGroupList, syncActionConfig) {
|
|
2962
|
+
// actionGroupList contains information about which action groups
|
|
2963
|
+
// are allowed or ignored
|
|
2964
|
+
|
|
2965
|
+
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
2966
|
+
// - action group name
|
|
2967
|
+
// - callback function that should return a list of actions that correspond
|
|
2968
|
+
// to the for the action group
|
|
2969
|
+
|
|
2970
|
+
// this resulting function mapActionGroup will call the callback function
|
|
2971
|
+
// for allowed action groups and return the return value of the callback
|
|
2972
|
+
// It will return an empty array for ignored action groups
|
|
2973
|
+
var mapActionGroup = createMapActionGroup(actionGroupList);
|
|
2974
|
+
var doMapActions = createShippingMethodsMapActions(mapActionGroup, syncActionConfig);
|
|
2975
|
+
var buildActions = createBuildActions(diff, doMapActions);
|
|
2976
|
+
return {
|
|
2977
|
+
buildActions: buildActions
|
|
2978
|
+
};
|
|
2979
|
+
});
|
|
2980
|
+
|
|
2964
2981
|
var baseActionsList$8 = [{
|
|
2965
2982
|
action: 'changeName',
|
|
2966
2983
|
key: 'name'
|