cozy-client 60.23.0 → 60.23.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.
@@ -3126,7 +3126,7 @@ var CozyClient = /*#__PURE__*/function () {
3126
3126
  CozyClient.hooks = CozyClient.hooks || {};
3127
3127
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
3128
3128
 
3129
- CozyClient.version = "60.23.0";
3129
+ CozyClient.version = "60.23.2";
3130
3130
 
3131
3131
  _microee.default.mixin(CozyClient);
3132
3132
 
package/dist/Provider.js CHANGED
@@ -52,7 +52,7 @@ var CozyProvider = /*#__PURE__*/function (_Component) {
52
52
  throw new Error('CozyProvider was not passed a client instance.');
53
53
  }
54
54
 
55
- if (props.store) {
55
+ if (props.store && props.client.store !== props.store) {
56
56
  props.client.setStore(props.store);
57
57
  }
58
58
 
@@ -15,6 +15,13 @@ var _helpers = require("../helpers");
15
15
 
16
16
  var _logger = _interopRequireDefault(require("../logger"));
17
17
 
18
+ /**
19
+ * @typedef {Object} FetchURLOptions
20
+ * @property {string} [pathname] - Pathname to use in the URL
21
+ * @property {string} [driveId] - Shared drive ID used to fetch the URL
22
+ * @property {string} [returnUrl] - Return URL to add in query string
23
+ */
24
+
18
25
  /**
19
26
  *
20
27
  * @param {string} notesAppUrl URL to the Notes App (https://notes.foo.mycozy.cloud)
@@ -45,9 +52,7 @@ var generateUrlForNote = function generateUrlForNote(notesAppUrl, file) {
45
52
  *
46
53
  * @param {object} client CozyClient instance
47
54
  * @param {object} file io.cozy.file object
48
- * @param {object} options Options
49
- * @param {string} [options.pathname] Pathname to use in the URL
50
- * @param {string} [options.driveId] Shared drive ID used to fetched the URL
55
+ * @param {FetchURLOptions} [options] Options
51
56
  * @returns {Promise<string>} url
52
57
  */
53
58
 
@@ -56,7 +61,10 @@ exports.generateUrlForNote = generateUrlForNote;
56
61
 
57
62
  var fetchURL = /*#__PURE__*/function () {
58
63
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(client, file) {
59
- var options,
64
+ var _ref2,
65
+ pathname,
66
+ driveId,
67
+ returnUrl,
60
68
  _yield$client$getStac,
61
69
  _yield$client$getStac2,
62
70
  note_id,
@@ -65,19 +73,17 @@ var fetchURL = /*#__PURE__*/function () {
65
73
  instance,
66
74
  sharecode,
67
75
  public_name,
68
- _options$pathname,
69
76
  searchParams,
70
- _options$pathname2,
71
77
  _args = arguments;
72
78
 
73
79
  return _regenerator.default.wrap(function _callee$(_context) {
74
80
  while (1) {
75
81
  switch (_context.prev = _context.next) {
76
82
  case 0:
77
- options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
83
+ _ref2 = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}, pathname = _ref2.pathname, driveId = _ref2.driveId, returnUrl = _ref2.returnUrl;
78
84
  _context.next = 3;
79
85
  return client.getStackClient().collection('io.cozy.notes', {
80
- driveId: options.driveId
86
+ driveId: driveId
81
87
  }).fetchURL({
82
88
  _id: file.id
83
89
  });
@@ -93,31 +99,39 @@ var fetchURL = /*#__PURE__*/function () {
93
99
  public_name = _yield$client$getStac2.public_name;
94
100
 
95
101
  if (!sharecode) {
96
- _context.next = 18;
102
+ _context.next = 19;
97
103
  break;
98
104
  }
99
105
 
100
106
  searchParams = [['id', note_id]];
101
107
  searchParams.push(['sharecode', sharecode]);
102
- if (public_name) searchParams.push(['username', public_name]);
108
+
109
+ if (public_name) {
110
+ searchParams.push(['username', public_name]);
111
+ }
112
+
113
+ if (returnUrl) {
114
+ searchParams.push(['returnUrl', returnUrl]);
115
+ }
116
+
103
117
  return _context.abrupt("return", (0, _helpers.generateWebLink)({
104
118
  cozyUrl: "".concat(protocol, "://").concat(instance),
105
119
  searchParams: searchParams,
106
- pathname: (_options$pathname = options.pathname) !== null && _options$pathname !== void 0 ? _options$pathname : '/public/',
120
+ pathname: pathname !== null && pathname !== void 0 ? pathname : '/public/',
107
121
  slug: 'notes',
108
122
  subDomainType: subdomain
109
123
  }));
110
124
 
111
- case 18:
125
+ case 19:
112
126
  return _context.abrupt("return", (0, _helpers.generateWebLink)({
113
127
  cozyUrl: "".concat(protocol, "://").concat(instance),
114
- pathname: (_options$pathname2 = options.pathname) !== null && _options$pathname2 !== void 0 ? _options$pathname2 : '',
128
+ pathname: pathname !== null && pathname !== void 0 ? pathname : '',
115
129
  slug: 'notes',
116
130
  subDomainType: subdomain,
117
131
  hash: "/n/".concat(note_id)
118
132
  }));
119
133
 
120
- case 19:
134
+ case 20:
121
135
  case "end":
122
136
  return _context.stop();
123
137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "60.23.0",
3
+ "version": "60.23.2",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -74,5 +74,5 @@
74
74
  "react-native-ios11-devicecheck": "^0.0.3"
75
75
  },
76
76
  "sideEffects": false,
77
- "gitHead": "cbb22ff63955ee894c60ebdfaf745d0c51ea13df"
77
+ "gitHead": "973a40f4d79a8456961df6838c8391904a2b9720"
78
78
  }
@@ -1,6 +1,17 @@
1
1
  export function generatePrivateUrl(notesAppUrl: string, file: object, options?: {}): string;
2
2
  export function generateUrlForNote(notesAppUrl: any, file: any): string;
3
- export function fetchURL(client: object, file: object, options?: {
4
- pathname: string;
5
- driveId: string;
6
- }): Promise<string>;
3
+ export function fetchURL(client: object, file: object, { pathname, driveId, returnUrl }?: FetchURLOptions): Promise<string>;
4
+ export type FetchURLOptions = {
5
+ /**
6
+ * - Pathname to use in the URL
7
+ */
8
+ pathname?: string;
9
+ /**
10
+ * - Shared drive ID used to fetch the URL
11
+ */
12
+ driveId?: string;
13
+ /**
14
+ * - Return URL to add in query string
15
+ */
16
+ returnUrl?: string;
17
+ };