cozy-client 50.1.0 → 50.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -263,9 +263,7 @@ var CozyClient = /*#__PURE__*/function () {
263
263
 
264
264
  return _this.emit.apply(_this, ['error'].concat(args));
265
265
  });
266
- this.links = ensureArray(link || links || new _StackLink.default());
267
- this.registerClientOnLinks();
268
- this.chain = (0, _CozyLink.chain)(this.links);
266
+ this.setLinks(ensureArray(link || links || new _StackLink.default()));
269
267
  this.schema = new _Schema.default(schema, stackClient);
270
268
  /**
271
269
  * @type {import("./types").ClientCapabilities}
@@ -2705,6 +2703,43 @@ var CozyClient = /*#__PURE__*/function () {
2705
2703
  value: function setAppMetadata(newAppMetadata) {
2706
2704
  this.appMetadata = _objectSpread(_objectSpread({}, this.appMetadata), newAppMetadata);
2707
2705
  }
2706
+ /**
2707
+ * Set links, e.g. PouchLink or StackLink.
2708
+ * When this method is called manually, i.e. after a client instanciation,
2709
+ * we manually call the links onLogin methods
2710
+ *
2711
+ * @param {Array<object>} links - The links to handle
2712
+ */
2713
+
2714
+ }, {
2715
+ key: "setLinks",
2716
+ value: function setLinks(links) {
2717
+ this.links = links ? links : [new _StackLink.default()];
2718
+ this.registerClientOnLinks();
2719
+ this.chain = (0, _CozyLink.chain)(this.links);
2720
+
2721
+ if (this.isLogged) {
2722
+ // If the client is already logged, it means this method is called manually, after
2723
+ // a client instanciation.
2724
+ // Thus, we call the link's onLogin methods
2725
+ var _iterator7 = _createForOfIteratorHelper(this.links),
2726
+ _step7;
2727
+
2728
+ try {
2729
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
2730
+ var link = _step7.value;
2731
+
2732
+ if (link.onLogin) {
2733
+ link.onLogin();
2734
+ }
2735
+ }
2736
+ } catch (err) {
2737
+ _iterator7.e(err);
2738
+ } finally {
2739
+ _iterator7.f();
2740
+ }
2741
+ }
2742
+ }
2708
2743
  /**
2709
2744
  * Query the cozy-app settings corresponding to the given slug and
2710
2745
  * extract the value corresponding to the given `key`
@@ -2997,7 +3032,7 @@ var CozyClient = /*#__PURE__*/function () {
2997
3032
  CozyClient.hooks = CozyClient.hooks || {};
2998
3033
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2999
3034
 
3000
- CozyClient.version = "50.1.0";
3035
+ CozyClient.version = "50.3.1";
3001
3036
 
3002
3037
  _microee.default.mixin(CozyClient);
3003
3038
 
@@ -353,7 +353,7 @@ var QueryDefinition = /*#__PURE__*/function () {
353
353
  /**
354
354
  * Maximum number of documents returned, useful for pagination. Default is 100.
355
355
  *
356
- * @param {number} limit The document's limit.
356
+ * @param {number|null} limit The document's limit.
357
357
  * @returns {QueryDefinition} The QueryDefinition object.
358
358
  */
359
359
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "50.1.0",
3
+ "version": "50.3.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -75,5 +75,5 @@
75
75
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
76
76
  },
77
77
  "sideEffects": false,
78
- "gitHead": "eabd164250195c878b7f40fb22c41e8b89503ea2"
78
+ "gitHead": "41510b18b99b7de549eca4a0e92a72668e105bf3"
79
79
  }
@@ -220,8 +220,6 @@ declare class CozyClient {
220
220
  handleRevocationChange(state: any): void;
221
221
  /** Emits event when token is refreshed */
222
222
  handleTokenRefresh(token: any): void;
223
- links: any[];
224
- chain: any;
225
223
  schema: Schema;
226
224
  /**
227
225
  * @type {import("./types").ClientCapabilities}
@@ -778,6 +776,16 @@ declare class CozyClient {
778
776
  * @param {import("./types").AppMetadata} newAppMetadata AppMetadata to update
779
777
  */
780
778
  setAppMetadata(newAppMetadata: import("./types").AppMetadata): void;
779
+ /**
780
+ * Set links, e.g. PouchLink or StackLink.
781
+ * When this method is called manually, i.e. after a client instanciation,
782
+ * we manually call the links onLogin methods
783
+ *
784
+ * @param {Array<object>} links - The links to handle
785
+ */
786
+ setLinks(links: Array<object>): void;
787
+ links: any[];
788
+ chain: any;
781
789
  /**
782
790
  * Query the cozy-app settings corresponding to the given slug and
783
791
  * extract the value corresponding to the given `key`
@@ -235,10 +235,10 @@ export class QueryDefinition {
235
235
  /**
236
236
  * Maximum number of documents returned, useful for pagination. Default is 100.
237
237
  *
238
- * @param {number} limit The document's limit.
238
+ * @param {number|null} limit The document's limit.
239
239
  * @returns {QueryDefinition} The QueryDefinition object.
240
240
  */
241
- limitBy(limit: number): QueryDefinition;
241
+ limitBy(limit: number | null): QueryDefinition;
242
242
  UNSAFE_noLimit(): QueryDefinition;
243
243
  /**
244
244
  * Skip the first ‘n’ documents, where ‘n’ is the value specified.