@ovh-ux/ng-ovh-contacts 4.0.8 → 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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [5.0.0](https://github.com/ovh/manager/compare/@ovh-ux/ng-ovh-contacts@4.0.8...@ovh-ux/ng-ovh-contacts@5.0.0) (2022-03-29)
2
+
3
+
4
+ ### Code Refactoring
5
+
6
+ * **ovh-contacts:** kill /me/contact v7 call ([c3f020a](https://github.com/ovh/manager/commit/c3f020a5be5f1dd3395183d10421952cfba0dc85))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **ovh-contacts:** The @ovh-ux/ng-ovh-api-wrappers package is added to the peer dependencies
12
+
13
+
14
+
1
15
  ## [4.0.8](https://github.com/ovh/manager/compare/@ovh-ux/ng-ovh-contacts@4.0.7...@ovh-ux/ng-ovh-contacts@4.0.8) (2022-03-24)
2
16
 
3
17
 
package/dist/cjs/index.js CHANGED
@@ -22,6 +22,7 @@ var angular = require('angular');
22
22
  require('angular-translate');
23
23
  require('ovh-api-services');
24
24
  require('@ovh-ux/ui-kit');
25
+ require('@ovh-ux/ng-ovh-api-wrappers');
25
26
  var moment = require('moment');
26
27
 
27
28
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -2477,7 +2478,7 @@ var _isKey = isKey;
2477
2478
 
2478
2479
  /** Error message constants. */
2479
2480
 
2480
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
2481
+ var FUNC_ERROR_TEXT = 'Expected a function';
2481
2482
  /**
2482
2483
  * Creates a function that memoizes the result of `func`. If `resolver` is
2483
2484
  * provided, it determines the cache key for storing the result based on the
@@ -2525,7 +2526,7 @@ var FUNC_ERROR_TEXT$1 = 'Expected a function';
2525
2526
 
2526
2527
  function memoize(func, resolver) {
2527
2528
  if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
2528
- throw new TypeError(FUNC_ERROR_TEXT$1);
2529
+ throw new TypeError(FUNC_ERROR_TEXT);
2529
2530
  }
2530
2531
 
2531
2532
  var memoized = function memoized() {
@@ -3651,120 +3652,6 @@ function map(collection, iteratee) {
3651
3652
 
3652
3653
  var map_1 = map;
3653
3654
 
3654
- /**
3655
- * The base implementation of `_.filter` without support for iteratee shorthands.
3656
- *
3657
- * @private
3658
- * @param {Array|Object} collection The collection to iterate over.
3659
- * @param {Function} predicate The function invoked per iteration.
3660
- * @returns {Array} Returns the new filtered array.
3661
- */
3662
-
3663
- function baseFilter(collection, predicate) {
3664
- var result = [];
3665
- _baseEach(collection, function (value, index, collection) {
3666
- if (predicate(value, index, collection)) {
3667
- result.push(value);
3668
- }
3669
- });
3670
- return result;
3671
- }
3672
-
3673
- var _baseFilter = baseFilter;
3674
-
3675
- /** Error message constants. */
3676
- var FUNC_ERROR_TEXT = 'Expected a function';
3677
- /**
3678
- * Creates a function that negates the result of the predicate `func`. The
3679
- * `func` predicate is invoked with the `this` binding and arguments of the
3680
- * created function.
3681
- *
3682
- * @static
3683
- * @memberOf _
3684
- * @since 3.0.0
3685
- * @category Function
3686
- * @param {Function} predicate The predicate to negate.
3687
- * @returns {Function} Returns the new negated function.
3688
- * @example
3689
- *
3690
- * function isEven(n) {
3691
- * return n % 2 == 0;
3692
- * }
3693
- *
3694
- * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
3695
- * // => [1, 3, 5]
3696
- */
3697
-
3698
- function negate(predicate) {
3699
- if (typeof predicate != 'function') {
3700
- throw new TypeError(FUNC_ERROR_TEXT);
3701
- }
3702
-
3703
- return function () {
3704
- var args = arguments;
3705
-
3706
- switch (args.length) {
3707
- case 0:
3708
- return !predicate.call(this);
3709
-
3710
- case 1:
3711
- return !predicate.call(this, args[0]);
3712
-
3713
- case 2:
3714
- return !predicate.call(this, args[0], args[1]);
3715
-
3716
- case 3:
3717
- return !predicate.call(this, args[0], args[1], args[2]);
3718
- }
3719
-
3720
- return !predicate.apply(this, args);
3721
- };
3722
- }
3723
-
3724
- var negate_1 = negate;
3725
-
3726
- /**
3727
- * The opposite of `_.filter`; this method returns the elements of `collection`
3728
- * that `predicate` does **not** return truthy for.
3729
- *
3730
- * @static
3731
- * @memberOf _
3732
- * @since 0.1.0
3733
- * @category Collection
3734
- * @param {Array|Object} collection The collection to iterate over.
3735
- * @param {Function} [predicate=_.identity] The function invoked per iteration.
3736
- * @returns {Array} Returns the new filtered array.
3737
- * @see _.filter
3738
- * @example
3739
- *
3740
- * var users = [
3741
- * { 'user': 'barney', 'age': 36, 'active': false },
3742
- * { 'user': 'fred', 'age': 40, 'active': true }
3743
- * ];
3744
- *
3745
- * _.reject(users, function(o) { return !o.active; });
3746
- * // => objects for ['fred']
3747
- *
3748
- * // The `_.matches` iteratee shorthand.
3749
- * _.reject(users, { 'age': 40, 'active': true });
3750
- * // => objects for ['barney']
3751
- *
3752
- * // The `_.matchesProperty` iteratee shorthand.
3753
- * _.reject(users, ['active', false]);
3754
- * // => objects for ['fred']
3755
- *
3756
- * // The `_.property` iteratee shorthand.
3757
- * _.reject(users, 'active');
3758
- * // => objects for ['barney']
3759
- */
3760
-
3761
- function reject(collection, predicate) {
3762
- var func = isArray_1(collection) ? _arrayFilter : _baseFilter;
3763
- return func(collection, negate_1(_baseIteratee(predicate)));
3764
- }
3765
-
3766
- var reject_1 = reject;
3767
-
3768
3655
  /** Used for built-in method references. */
3769
3656
 
3770
3657
  var objectProto$2 = Object.prototype;
@@ -5000,17 +4887,16 @@ var connectedNic;
5000
4887
  var meSchemas;
5001
4888
 
5002
4889
  var OvhContactsService = /*#__PURE__*/function () {
5003
- OvhContactsService.$inject = ["$q", "$translate", "OvhApiMe", "OvhApiNewAccount", "target"];
5004
-
5005
- function OvhContactsService($q, $translate, OvhApiMe, OvhApiNewAccount, target) {
4890
+ // @see /src/ovh-contacts.provider.js for dependency injections
4891
+ function OvhContactsService($q, $translate, OvhApiMe, OvhApiNewAccount, target, iceberg) {
5006
4892
  _classCallCheck(this, OvhContactsService);
5007
4893
 
5008
- // dependencies injections
5009
4894
  this.$q = $q;
5010
4895
  this.$translate = $translate;
5011
4896
  this.OvhApiMe = OvhApiMe;
5012
4897
  this.OvhApiNewAccount = OvhApiNewAccount;
5013
4898
  this.target = target;
4899
+ this.iceberg = iceberg;
5014
4900
  }
5015
4901
  /**
5016
4902
  * Convert a nic to a contact.
@@ -5088,9 +4974,9 @@ var OvhContactsService = /*#__PURE__*/function () {
5088
4974
  var promise;
5089
4975
 
5090
4976
  if (this.target === 'EU') {
5091
- promise = this.OvhApiMe.Contact().v7().query().expand().execute().$promise.then(function (contactsList) {
5092
- var contacts = reject_1(contactsList, ['value', null]);
5093
- return map_1(contacts, 'value');
4977
+ promise = this.iceberg('/me/contact').query().expand('CachedObjectList-Pages').execute().$promise.then(function (_ref3) {
4978
+ var contacts = _ref3.data;
4979
+ return contacts.filter(Boolean);
5094
4980
  });
5095
4981
  } else {
5096
4982
  promise = this.OvhApiMe.Contact().v6().query().$promise.then(function (contactIds) {
@@ -5146,9 +5032,9 @@ var OvhContactsService = /*#__PURE__*/function () {
5146
5032
  apiSchemas: _this2.getMeSchemas(),
5147
5033
  creationRules: _this2.OvhApiNewAccount.v6().rules({}, rulesOptions).$promise
5148
5034
  });
5149
- }).then(function (_ref3) {
5150
- var apiSchemas = _ref3.apiSchemas,
5151
- creationRules = _ref3.creationRules;
5035
+ }).then(function (_ref4) {
5036
+ var apiSchemas = _ref4.apiSchemas,
5037
+ creationRules = _ref4.creationRules;
5152
5038
  var rules = OvhContactsHelper.mergeContactPropertiesWithCreationRules(apiSchemas, keyBy_1(creationRules, 'fieldName'), predefinedProperties, options); // translate properties with enum
5153
5039
  // first get rules with enum
5154
5040
 
@@ -5225,9 +5111,9 @@ var OvhContactsService = /*#__PURE__*/function () {
5225
5111
  return this.$q.all({
5226
5112
  nic: fromNic ? this.$q.when(fromNic) : this.getConnectedNic(),
5227
5113
  contacts: contactList ? this.$q.when(contactList) : this.getContacts()
5228
- }).then(function (_ref4) {
5229
- var nic = _ref4.nic,
5230
- contacts = _ref4.contacts;
5114
+ }).then(function (_ref5) {
5115
+ var nic = _ref5.nic,
5116
+ contacts = _ref5.contacts;
5231
5117
 
5232
5118
  var converPromise = _this3.convertNicToContact(nic);
5233
5119
 
@@ -5259,14 +5145,35 @@ var ovhContactsProvider = /*#__PURE__*/function () {
5259
5145
  }
5260
5146
  }, {
5261
5147
  key: "$get",
5262
- value: ["$q", "$translate", "OvhApiMe", "OvhApiNewAccount", function $get($q, $translate, OvhApiMe, OvhApiNewAccount) {
5263
- return new OvhContactsService($q, $translate, OvhApiMe, OvhApiNewAccount, this.target);
5148
+ value: ["$q", "$translate", "OvhApiMe", "OvhApiNewAccount", "iceberg", function $get($q, $translate, OvhApiMe, OvhApiNewAccount, iceberg) {
5149
+ return new OvhContactsService($q, $translate, OvhApiMe, OvhApiNewAccount, this.target, iceberg);
5264
5150
  }]
5265
5151
  }]);
5266
5152
 
5267
5153
  return ovhContactsProvider;
5268
5154
  }();
5269
5155
 
5156
+ /**
5157
+ * The base implementation of `_.filter` without support for iteratee shorthands.
5158
+ *
5159
+ * @private
5160
+ * @param {Array|Object} collection The collection to iterate over.
5161
+ * @param {Function} predicate The function invoked per iteration.
5162
+ * @returns {Array} Returns the new filtered array.
5163
+ */
5164
+
5165
+ function baseFilter(collection, predicate) {
5166
+ var result = [];
5167
+ _baseEach(collection, function (value, index, collection) {
5168
+ if (predicate(value, index, collection)) {
5169
+ result.push(value);
5170
+ }
5171
+ });
5172
+ return result;
5173
+ }
5174
+
5175
+ var _baseFilter = baseFilter;
5176
+
5270
5177
  /**
5271
5178
  * Iterates over elements of `collection`, returning an array of all elements
5272
5179
  * `predicate` returns truthy for. The predicate is invoked with three
@@ -5665,7 +5572,7 @@ function __variableDynamicImportRuntime0__(path) {
5665
5572
  }
5666
5573
  }
5667
5574
  var moduleName = 'ngOvhContacts';
5668
- angular__default['default'].module(moduleName, ['pascalprecht.translate', 'oui', 'ovh-api-services']).run(["$translate", "$q", "asyncLoader", function ($translate, $q, asyncLoader) {
5575
+ angular__default['default'].module(moduleName, ['ngOvhApiWrappers', 'pascalprecht.translate', 'oui', 'ovh-api-services']).run(["$translate", "$q", "asyncLoader", function ($translate, $q, asyncLoader) {
5669
5576
  var promises = [];
5670
5577
  promises.push($q.all({
5671
5578
  use: __variableDynamicImportRuntime0__('./translations/Messages_' + $translate.use() + '.json').then(function (module) {