@commercetools/sync-actions 4.13.0 → 5.0.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.
@@ -10,14 +10,9 @@ function ownKeys(object, enumerableOnly) {
10
10
 
11
11
  if (Object.getOwnPropertySymbols) {
12
12
  var symbols = Object.getOwnPropertySymbols(object);
13
-
14
- if (enumerableOnly) {
15
- symbols = symbols.filter(function (sym) {
16
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17
- });
18
- }
19
-
20
- keys.push.apply(keys, symbols);
13
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
14
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
15
+ })), keys.push.apply(keys, symbols);
21
16
  }
22
17
 
23
18
  return keys;
@@ -25,19 +20,12 @@ function ownKeys(object, enumerableOnly) {
25
20
 
26
21
  function _objectSpread2(target) {
27
22
  for (var i = 1; i < arguments.length; i++) {
28
- var source = arguments[i] != null ? arguments[i] : {};
29
-
30
- if (i % 2) {
31
- ownKeys(Object(source), true).forEach(function (key) {
32
- _defineProperty(target, key, source[key]);
33
- });
34
- } else if (Object.getOwnPropertyDescriptors) {
35
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
36
- } else {
37
- ownKeys(Object(source)).forEach(function (key) {
38
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
39
- });
40
- }
23
+ var source = null != arguments[i] ? arguments[i] : {};
24
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
25
+ _defineProperty(target, key, source[key]);
26
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
27
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
28
+ });
41
29
  }
42
30
 
43
31
  return target;
@@ -46,17 +34,11 @@ function _objectSpread2(target) {
46
34
  function _typeof(obj) {
47
35
  "@babel/helpers - typeof";
48
36
 
49
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
50
- _typeof = function (obj) {
51
- return typeof obj;
52
- };
53
- } else {
54
- _typeof = function (obj) {
55
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
56
- };
57
- }
58
-
59
- return _typeof(obj);
37
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
38
+ return typeof obj;
39
+ } : function (obj) {
40
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
41
+ }, _typeof(obj);
60
42
  }
61
43
 
62
44
  function _defineProperty(obj, key, value) {
@@ -2682,78 +2664,6 @@ var shippingMethods = (function (actionGroupList, syncActionConfig) {
2682
2664
  var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
2683
2665
  var keys = Object.keys;
2684
2666
  /**
2685
- * @function addToCache
2686
- *
2687
- * add object to cache if an object
2688
- *
2689
- * @param value the value to potentially add to cache
2690
- * @param cache the cache to add to
2691
- */
2692
-
2693
- function addToCache(value, cache) {
2694
- if (value && _typeof(value) === 'object') {
2695
- cache.add(value);
2696
- }
2697
- }
2698
- /**
2699
- * @function hasPair
2700
- *
2701
- * @description
2702
- * does the `pairToMatch` exist in the list of `pairs` provided based on the
2703
- * `isEqual` check
2704
- *
2705
- * @param pairs the pairs to compare against
2706
- * @param pairToMatch the pair to match
2707
- * @param isEqual the equality comparator used
2708
- * @param meta the meta provided
2709
- * @returns does the pair exist in the pairs provided
2710
- */
2711
-
2712
-
2713
- function hasPair(pairs, pairToMatch, isEqual, meta) {
2714
- var length = pairs.length;
2715
- var pair;
2716
-
2717
- for (var index = 0; index < length; index++) {
2718
- pair = pairs[index];
2719
-
2720
- if (isEqual(pair[0], pairToMatch[0], meta) && isEqual(pair[1], pairToMatch[1], meta)) {
2721
- return true;
2722
- }
2723
- }
2724
-
2725
- return false;
2726
- }
2727
- /**
2728
- * @function hasValue
2729
- *
2730
- * @description
2731
- * does the `valueToMatch` exist in the list of `values` provided based on the
2732
- * `isEqual` check
2733
- *
2734
- * @param values the values to compare against
2735
- * @param valueToMatch the value to match
2736
- * @param isEqual the equality comparator used
2737
- * @param meta the meta provided
2738
- * @returns does the value exist in the values provided
2739
- */
2740
-
2741
-
2742
- function hasValue(values, valueToMatch, isEqual, meta) {
2743
- var length = values.length;
2744
-
2745
- for (var index = 0; index < length; index++) {
2746
- if (isEqual(values[index], valueToMatch, meta)) {
2747
- return true;
2748
- }
2749
- }
2750
-
2751
- return false;
2752
- }
2753
- /**
2754
- * @function sameValueZeroEqual
2755
- *
2756
- * @description
2757
2667
  * are the values passed strictly equal or both NaN
2758
2668
  *
2759
2669
  * @param a the value to compare against
@@ -2761,14 +2671,10 @@ function hasValue(values, valueToMatch, isEqual, meta) {
2761
2671
  * @returns are the values equal by the SameValueZero principle
2762
2672
  */
2763
2673
 
2764
-
2765
2674
  function sameValueZeroEqual(a, b) {
2766
2675
  return a === b || a !== a && b !== b;
2767
2676
  }
2768
2677
  /**
2769
- * @function isPlainObject
2770
- *
2771
- * @description
2772
2678
  * is the value a plain object
2773
2679
  *
2774
2680
  * @param value the value to test
@@ -2780,9 +2686,6 @@ function isPlainObject(value) {
2780
2686
  return value.constructor === Object || value.constructor == null;
2781
2687
  }
2782
2688
  /**
2783
- * @function isPromiseLike
2784
- *
2785
- * @description
2786
2689
  * is the value promise-like (meaning it is thenable)
2787
2690
  *
2788
2691
  * @param value the value to test
@@ -2794,9 +2697,6 @@ function isPromiseLike(value) {
2794
2697
  return !!value && typeof value.then === 'function';
2795
2698
  }
2796
2699
  /**
2797
- * @function isReactElement
2798
- *
2799
- * @description
2800
2700
  * is the value passed a react element
2801
2701
  *
2802
2702
  * @param value the value to test
@@ -2808,9 +2708,6 @@ function isReactElement(value) {
2808
2708
  return !!(value && value.$$typeof);
2809
2709
  }
2810
2710
  /**
2811
- * @function getNewCacheFallback
2812
- *
2813
- * @description
2814
2711
  * in cases where WeakSet is not supported, creates a new custom
2815
2712
  * object that mimics the necessary API aspects for cache purposes
2816
2713
  *
@@ -2819,20 +2716,17 @@ function isReactElement(value) {
2819
2716
 
2820
2717
 
2821
2718
  function getNewCacheFallback() {
2822
- return Object.create({
2823
- _values: [],
2719
+ var values = [];
2720
+ return {
2824
2721
  add: function add(value) {
2825
- this._values.push(value);
2722
+ values.push(value);
2826
2723
  },
2827
2724
  has: function has(value) {
2828
- return this._values.indexOf(value) !== -1;
2725
+ return values.indexOf(value) !== -1;
2829
2726
  }
2830
- });
2727
+ };
2831
2728
  }
2832
2729
  /**
2833
- * @function getNewCache
2834
- *
2835
- * @description
2836
2730
  * get a new cache object to prevent circular references
2837
2731
  *
2838
2732
  * @returns the new cache object
@@ -2849,9 +2743,6 @@ var getNewCache = function (canUseWeakMap) {
2849
2743
  return getNewCacheFallback;
2850
2744
  }(HAS_WEAKSET_SUPPORT);
2851
2745
  /**
2852
- * @function createCircularEqualCreator
2853
- *
2854
- * @description
2855
2746
  * create a custom isEqual handler specific to circular objects
2856
2747
  *
2857
2748
  * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
@@ -2868,61 +2759,31 @@ function createCircularEqualCreator(isEqual) {
2868
2759
  cache = getNewCache();
2869
2760
  }
2870
2761
 
2871
- var hasA = cache.has(a);
2872
- var hasB = cache.has(b);
2762
+ var isCacheableA = !!a && _typeof(a) === 'object';
2763
+ var isCacheableB = !!b && _typeof(b) === 'object';
2764
+
2765
+ if (isCacheableA || isCacheableB) {
2766
+ var hasA = isCacheableA && cache.has(a);
2767
+ var hasB = isCacheableB && cache.has(b);
2873
2768
 
2874
- if (hasA || hasB) {
2875
- return hasA && hasB;
2769
+ if (hasA || hasB) {
2770
+ return hasA && hasB;
2771
+ }
2772
+
2773
+ if (isCacheableA) {
2774
+ cache.add(a);
2775
+ }
2776
+
2777
+ if (isCacheableB) {
2778
+ cache.add(b);
2779
+ }
2876
2780
  }
2877
2781
 
2878
- addToCache(a, cache);
2879
- addToCache(b, cache);
2880
2782
  return _comparator(a, b, cache);
2881
2783
  };
2882
2784
  };
2883
2785
  }
2884
2786
  /**
2885
- * @function toPairs
2886
- *
2887
- * @description
2888
- * convert the map passed into pairs (meaning an array of [key, value] tuples)
2889
- *
2890
- * @param map the map to convert to [key, value] pairs (entries)
2891
- * @returns the [key, value] pairs
2892
- */
2893
-
2894
-
2895
- function toPairs(map) {
2896
- var pairs = new Array(map.size);
2897
- var index = 0;
2898
- map.forEach(function (value, key) {
2899
- pairs[index++] = [key, value];
2900
- });
2901
- return pairs;
2902
- }
2903
- /**
2904
- * @function toValues
2905
- *
2906
- * @description
2907
- * convert the set passed into values
2908
- *
2909
- * @param set the set to convert to values
2910
- * @returns the values
2911
- */
2912
-
2913
-
2914
- function toValues(set) {
2915
- var values = new Array(set.size);
2916
- var index = 0;
2917
- set.forEach(function (value) {
2918
- values[index++] = value;
2919
- });
2920
- return values;
2921
- }
2922
- /**
2923
- * @function areArraysEqual
2924
- *
2925
- * @description
2926
2787
  * are the arrays equal in value
2927
2788
  *
2928
2789
  * @param a the array to test
@@ -2934,13 +2795,13 @@ function toValues(set) {
2934
2795
 
2935
2796
 
2936
2797
  function areArraysEqual(a, b, isEqual, meta) {
2937
- var length = a.length;
2798
+ var index = a.length;
2938
2799
 
2939
- if (b.length !== length) {
2800
+ if (b.length !== index) {
2940
2801
  return false;
2941
2802
  }
2942
2803
 
2943
- for (var index = 0; index < length; index++) {
2804
+ while (index-- > 0) {
2944
2805
  if (!isEqual(a[index], b[index], meta)) {
2945
2806
  return false;
2946
2807
  }
@@ -2949,9 +2810,6 @@ function areArraysEqual(a, b, isEqual, meta) {
2949
2810
  return true;
2950
2811
  }
2951
2812
  /**
2952
- * @function areMapsEqual
2953
- *
2954
- * @description
2955
2813
  * are the maps equal in value
2956
2814
  *
2957
2815
  * @param a the map to test
@@ -2963,29 +2821,36 @@ function areArraysEqual(a, b, isEqual, meta) {
2963
2821
 
2964
2822
 
2965
2823
  function areMapsEqual(a, b, isEqual, meta) {
2966
- if (a.size !== b.size) {
2967
- return false;
2968
- }
2969
-
2970
- var pairsA = toPairs(a);
2971
- var pairsB = toPairs(b);
2972
- var length = pairsA.length;
2824
+ var isValueEqual = a.size === b.size;
2825
+
2826
+ if (isValueEqual && a.size) {
2827
+ var matchedIndices_1 = {};
2828
+ a.forEach(function (aValue, aKey) {
2829
+ if (isValueEqual) {
2830
+ var hasMatch_1 = false;
2831
+ var matchIndex_1 = 0;
2832
+ b.forEach(function (bValue, bKey) {
2833
+ if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
2834
+ hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
2835
+
2836
+ if (hasMatch_1) {
2837
+ matchedIndices_1[matchIndex_1] = true;
2838
+ }
2839
+ }
2973
2840
 
2974
- for (var index = 0; index < length; index++) {
2975
- if (!hasPair(pairsB, pairsA[index], isEqual, meta) || !hasPair(pairsA, pairsB[index], isEqual, meta)) {
2976
- return false;
2977
- }
2841
+ matchIndex_1++;
2842
+ });
2843
+ isValueEqual = hasMatch_1;
2844
+ }
2845
+ });
2978
2846
  }
2979
2847
 
2980
- return true;
2848
+ return isValueEqual;
2981
2849
  }
2982
2850
 
2983
2851
  var OWNER = '_owner';
2984
2852
  var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
2985
2853
  /**
2986
- * @function areObjectsEqual
2987
- *
2988
- * @description
2989
2854
  * are the objects equal in value
2990
2855
  *
2991
2856
  * @param a the object to test
@@ -2997,36 +2862,36 @@ var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Objec
2997
2862
 
2998
2863
  function areObjectsEqual(a, b, isEqual, meta) {
2999
2864
  var keysA = keys(a);
3000
- var length = keysA.length;
2865
+ var index = keysA.length;
3001
2866
 
3002
- if (keys(b).length !== length) {
2867
+ if (keys(b).length !== index) {
3003
2868
  return false;
3004
2869
  }
3005
2870
 
3006
- var key;
2871
+ if (index) {
2872
+ var key = void 0;
3007
2873
 
3008
- for (var index = 0; index < length; index++) {
3009
- key = keysA[index];
2874
+ while (index-- > 0) {
2875
+ key = keysA[index];
3010
2876
 
3011
- if (!hasOwnProperty(b, key)) {
3012
- return false;
3013
- }
2877
+ if (key === OWNER) {
2878
+ var reactElementA = isReactElement(a);
2879
+ var reactElementB = isReactElement(b);
3014
2880
 
3015
- if (key === OWNER && isReactElement(a)) {
3016
- if (!isReactElement(b)) {
2881
+ if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
2882
+ return false;
2883
+ }
2884
+ }
2885
+
2886
+ if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3017
2887
  return false;
3018
2888
  }
3019
- } else if (!isEqual(a[key], b[key], meta)) {
3020
- return false;
3021
2889
  }
3022
2890
  }
3023
2891
 
3024
2892
  return true;
3025
2893
  }
3026
2894
  /**
3027
- * @function areRegExpsEqual
3028
- *
3029
- * @description
3030
2895
  * are the regExps equal in value
3031
2896
  *
3032
2897
  * @param a the regExp to test
@@ -3039,9 +2904,6 @@ function areRegExpsEqual(a, b) {
3039
2904
  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;
3040
2905
  }
3041
2906
  /**
3042
- * @function areSetsEqual
3043
- *
3044
- * @description
3045
2907
  * are the sets equal in value
3046
2908
  *
3047
2909
  * @param a the set to test
@@ -3053,27 +2915,35 @@ function areRegExpsEqual(a, b) {
3053
2915
 
3054
2916
 
3055
2917
  function areSetsEqual(a, b, isEqual, meta) {
3056
- if (a.size !== b.size) {
3057
- return false;
3058
- }
3059
-
3060
- var valuesA = toValues(a);
3061
- var valuesB = toValues(b);
3062
- var length = valuesA.length;
2918
+ var isValueEqual = a.size === b.size;
2919
+
2920
+ if (isValueEqual && a.size) {
2921
+ var matchedIndices_2 = {};
2922
+ a.forEach(function (aValue) {
2923
+ if (isValueEqual) {
2924
+ var hasMatch_2 = false;
2925
+ var matchIndex_2 = 0;
2926
+ b.forEach(function (bValue) {
2927
+ if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
2928
+ hasMatch_2 = isEqual(aValue, bValue, meta);
2929
+
2930
+ if (hasMatch_2) {
2931
+ matchedIndices_2[matchIndex_2] = true;
2932
+ }
2933
+ }
3063
2934
 
3064
- for (var index = 0; index < length; index++) {
3065
- if (!hasValue(valuesB, valuesA[index], isEqual, meta) || !hasValue(valuesA, valuesB[index], isEqual, meta)) {
3066
- return false;
3067
- }
2935
+ matchIndex_2++;
2936
+ });
2937
+ isValueEqual = hasMatch_2;
2938
+ }
2939
+ });
3068
2940
  }
3069
2941
 
3070
- return true;
2942
+ return isValueEqual;
3071
2943
  }
3072
2944
 
3073
- var isArray = Array.isArray;
3074
2945
  var HAS_MAP_SUPPORT = typeof Map === 'function';
3075
2946
  var HAS_SET_SUPPORT = typeof Set === 'function';
3076
- var OBJECT_TYPEOF = 'object';
3077
2947
 
3078
2948
  function createComparator(createIsEqual) {
3079
2949
  var isEqual =
@@ -3082,9 +2952,6 @@ function createComparator(createIsEqual) {
3082
2952
  /* eslint-enable */
3083
2953
 
3084
2954
  /**
3085
- * @function comparator
3086
- *
3087
- * @description
3088
2955
  * compare the value of the two objects and return true if they are equivalent in values
3089
2956
  *
3090
2957
  * @param a the value to test against
@@ -3094,34 +2961,34 @@ function createComparator(createIsEqual) {
3094
2961
  */
3095
2962
 
3096
2963
  function comparator(a, b, meta) {
3097
- if (sameValueZeroEqual(a, b)) {
2964
+ if (a === b) {
3098
2965
  return true;
3099
2966
  }
3100
2967
 
3101
- if (a && b && _typeof(a) === OBJECT_TYPEOF && _typeof(b) === OBJECT_TYPEOF) {
2968
+ if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3102
2969
  if (isPlainObject(a) && isPlainObject(b)) {
3103
2970
  return areObjectsEqual(a, b, isEqual, meta);
3104
2971
  }
3105
2972
 
3106
- var arrayA = isArray(a);
3107
- var arrayB = isArray(b);
2973
+ var aShape = Array.isArray(a);
2974
+ var bShape = Array.isArray(b);
3108
2975
 
3109
- if (arrayA || arrayB) {
3110
- return arrayA === arrayB && areArraysEqual(a, b, isEqual, meta);
2976
+ if (aShape || bShape) {
2977
+ return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3111
2978
  }
3112
2979
 
3113
- var aDate = a instanceof Date;
3114
- var bDate = b instanceof Date;
2980
+ aShape = a instanceof Date;
2981
+ bShape = b instanceof Date;
3115
2982
 
3116
- if (aDate || bDate) {
3117
- return aDate === bDate && sameValueZeroEqual(a.getTime(), b.getTime());
2983
+ if (aShape || bShape) {
2984
+ return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3118
2985
  }
3119
2986
 
3120
- var aRegExp = a instanceof RegExp;
3121
- var bRegExp = b instanceof RegExp;
2987
+ aShape = a instanceof RegExp;
2988
+ bShape = b instanceof RegExp;
3122
2989
 
3123
- if (aRegExp || bRegExp) {
3124
- return aRegExp === bRegExp && areRegExpsEqual(a, b);
2990
+ if (aShape || bShape) {
2991
+ return aShape === bShape && areRegExpsEqual(a, b);
3125
2992
  }
3126
2993
 
3127
2994
  if (isPromiseLike(a) || isPromiseLike(b)) {
@@ -3129,32 +2996,31 @@ function createComparator(createIsEqual) {
3129
2996
  }
3130
2997
 
3131
2998
  if (HAS_MAP_SUPPORT) {
3132
- var aMap = a instanceof Map;
3133
- var bMap = b instanceof Map;
2999
+ aShape = a instanceof Map;
3000
+ bShape = b instanceof Map;
3134
3001
 
3135
- if (aMap || bMap) {
3136
- return aMap === bMap && areMapsEqual(a, b, isEqual, meta);
3002
+ if (aShape || bShape) {
3003
+ return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3137
3004
  }
3138
3005
  }
3139
3006
 
3140
3007
  if (HAS_SET_SUPPORT) {
3141
- var aSet = a instanceof Set;
3142
- var bSet = b instanceof Set;
3008
+ aShape = a instanceof Set;
3009
+ bShape = b instanceof Set;
3143
3010
 
3144
- if (aSet || bSet) {
3145
- return aSet === bSet && areSetsEqual(a, b, isEqual, meta);
3011
+ if (aShape || bShape) {
3012
+ return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3146
3013
  }
3147
3014
  }
3148
3015
 
3149
3016
  return areObjectsEqual(a, b, isEqual, meta);
3150
3017
  }
3151
3018
 
3152
- return false;
3019
+ return a !== a && b !== b;
3153
3020
  }
3154
3021
 
3155
3022
  return comparator;
3156
- } // comparator
3157
-
3023
+ }
3158
3024
 
3159
3025
  var deepEqual = createComparator();
3160
3026
  createComparator(function () {