cozy-client 35.3.0 → 35.4.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.
@@ -2669,7 +2669,7 @@ var CozyClient = /*#__PURE__*/function () {
2669
2669
  CozyClient.hooks = CozyClient.hooks || {};
2670
2670
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2671
2671
 
2672
- CozyClient.version = "35.3.0";
2672
+ CozyClient.version = "35.4.0";
2673
2673
 
2674
2674
  _microee.default.mixin(CozyClient);
2675
2675
 
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.dehydrate = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _associations = require("../associations");
13
+
14
+ var dehydrate = function dehydrate(document) {
15
+ var dehydrated = Object.entries(document).reduce(function (documentArg, _ref) {
16
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
17
+ key = _ref2[0],
18
+ value = _ref2[1];
19
+
20
+ var document = documentArg;
21
+
22
+ if (!(value instanceof _associations.Association)) {
23
+ document[key] = value; // @ts-ignore
24
+ } else if (value.dehydrate) {
25
+ // @ts-ignore
26
+ document = value.dehydrate(document);
27
+ } else {
28
+ throw new Error("Association on key ".concat(key, " should have a dehydrate method"));
29
+ }
30
+
31
+ return document;
32
+ }, {});
33
+ return dehydrated;
34
+ };
35
+
36
+ exports.dehydrate = dehydrate;
@@ -0,0 +1,111 @@
1
+ import { dehydrate } from './dehydrateHelper'
2
+
3
+ import {
4
+ HasManyInPlace,
5
+ HasMany,
6
+ HasManyFiles,
7
+ HasOneInPlace,
8
+ create as createAssociation,
9
+ Association
10
+ } from '../associations'
11
+
12
+ describe('dehydrate', () => {
13
+ let document
14
+
15
+ const intialDocument = {
16
+ regularKey: 'foo',
17
+ manyInPlace: [1, 2],
18
+ oneInPlace: '1',
19
+ relationships: {
20
+ hasMany: {
21
+ data: [{ _id: 1, _type: 'has.many' }, { _id: 2, _type: 'has.many' }]
22
+ },
23
+ hasManyFiles: {
24
+ data: [
25
+ { _id: 1, _type: 'has.many.files' },
26
+ { _id: 2, _type: 'has.many.files' }
27
+ ]
28
+ }
29
+ }
30
+ }
31
+
32
+ class BadAssociation extends Association {}
33
+
34
+ const relationships = [
35
+ {
36
+ name: 'manyInPlace',
37
+ type: HasManyInPlace,
38
+ doctype: 'many.in.place'
39
+ },
40
+ {
41
+ name: 'oneInPlace',
42
+ type: HasOneInPlace,
43
+ doctype: 'one.in.place'
44
+ },
45
+ {
46
+ name: 'hasMany',
47
+ type: HasMany,
48
+ doctype: 'has.many'
49
+ },
50
+ {
51
+ name: 'hasManyFiles',
52
+ type: HasManyFiles,
53
+ doctype: 'has.many.files'
54
+ }
55
+ ]
56
+
57
+ beforeEach(() => {
58
+ document = relationships.reduce(
59
+ (acc, relationship) => ({
60
+ ...acc,
61
+ [relationship.name]: createAssociation(intialDocument, relationship, {})
62
+ }),
63
+ intialDocument
64
+ )
65
+ })
66
+
67
+ it('should not touch regular values', () => {
68
+ expect(dehydrate(document).regularKey).toEqual(intialDocument.regularKey)
69
+ })
70
+
71
+ it('should dehydrate HasManyInPlace relationships', () => {
72
+ expect(dehydrate(document).manyInPlace).toEqual(intialDocument.manyInPlace)
73
+ })
74
+
75
+ it('should dehydrate HasOneInPlace relationships', () => {
76
+ const dehydrated = dehydrate(document)
77
+ expect(dehydrated.oneInPlace).toEqual(intialDocument.oneInPlace)
78
+ expect(dehydrated.oneInPlace).not.toBeUndefined()
79
+ })
80
+
81
+ it('should dehydrate HasMany relationships', () => {
82
+ const dehydrated = dehydrate(document)
83
+ expect(dehydrated.relationships.hasMany).toEqual(
84
+ intialDocument.relationships.hasMany
85
+ )
86
+ expect(dehydrated.hasMany).toBeUndefined()
87
+ })
88
+
89
+ it('should dehydrate HasManyFiles relationships', () => {
90
+ const dehydrated = dehydrate(document)
91
+ expect(dehydrated.relationships.hasManyFiles).toBeUndefined()
92
+ expect(dehydrated.hasManyFiles).toBeUndefined()
93
+ })
94
+
95
+ it('should throw if a relationship is not dehydratable', () => {
96
+ document.badAssociation = createAssociation(
97
+ document,
98
+ {
99
+ name: 'BadAssociation',
100
+ type: BadAssociation,
101
+ doctype: 'bad.association'
102
+ },
103
+ {}
104
+ )
105
+ expect(() => {
106
+ dehydrate(document)
107
+ }).toThrowError(
108
+ `Association on key badAssociation should have a dehydrate method`
109
+ )
110
+ })
111
+ })
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "deconstructCozyWebLinkWithSlug", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _urlHelper.deconstructCozyWebLinkWithSlug;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "deconstructRedirectLink", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _urlHelper.deconstructRedirectLink;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "generateWebLink", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _urlHelper.generateWebLink;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "ensureFirstSlash", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _urlHelper.ensureFirstSlash;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "rootCozyUrl", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _urlHelper.rootCozyUrl;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "InvalidCozyUrlError", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _urlHelper.InvalidCozyUrlError;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "InvalidProtocolError", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _urlHelper.InvalidProtocolError;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "dehydrate", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _dehydrateHelper.dehydrate;
52
+ }
53
+ });
54
+
55
+ var _urlHelper = require("./urlHelper");
56
+
57
+ var _dehydrateHelper = require("./dehydrateHelper");
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.rootCozyUrl = exports.InvalidCozyUrlError = exports.InvalidProtocolError = exports.deconstructCozyWebLinkWithSlug = exports.generateWebLink = exports.ensureFirstSlash = exports.dehydrate = void 0;
8
+ exports.rootCozyUrl = exports.InvalidCozyUrlError = exports.InvalidProtocolError = exports.deconstructRedirectLink = exports.deconstructCozyWebLinkWithSlug = exports.generateWebLink = exports.ensureFirstSlash = void 0;
9
9
 
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
@@ -27,9 +27,7 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
27
27
 
28
28
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
29
29
 
30
- var _associations = require("./associations");
31
-
32
- var _types = require("./types");
30
+ var _types = require("../types");
33
31
 
34
32
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
35
33
 
@@ -41,30 +39,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
41
39
 
42
40
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
43
41
 
44
- var dehydrate = function dehydrate(document) {
45
- var dehydrated = Object.entries(document).reduce(function (documentArg, _ref) {
46
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
47
- key = _ref2[0],
48
- value = _ref2[1];
49
-
50
- var document = documentArg;
51
-
52
- if (!(value instanceof _associations.Association)) {
53
- document[key] = value; // @ts-ignore
54
- } else if (value.dehydrate) {
55
- // @ts-ignore
56
- document = value.dehydrate(document);
57
- } else {
58
- throw new Error("Association on key ".concat(key, " should have a dehydrate method"));
59
- }
60
-
61
- return document;
62
- }, {});
63
- return dehydrated;
64
- };
65
-
66
- exports.dehydrate = dehydrate;
67
-
68
42
  var ensureFirstSlash = function ensureFirstSlash(path) {
69
43
  if (!path) {
70
44
  return '/';
@@ -94,13 +68,13 @@ var ensureFirstSlash = function ensureFirstSlash(path) {
94
68
 
95
69
  exports.ensureFirstSlash = ensureFirstSlash;
96
70
 
97
- var generateWebLink = function generateWebLink(_ref3) {
98
- var cozyUrl = _ref3.cozyUrl,
99
- searchParamsOption = _ref3.searchParams,
100
- pathname = _ref3.pathname,
101
- hash = _ref3.hash,
102
- slug = _ref3.slug,
103
- subDomainType = _ref3.subDomainType;
71
+ var generateWebLink = function generateWebLink(_ref) {
72
+ var cozyUrl = _ref.cozyUrl,
73
+ searchParamsOption = _ref.searchParams,
74
+ pathname = _ref.pathname,
75
+ hash = _ref.hash,
76
+ slug = _ref.slug,
77
+ subDomainType = _ref.subDomainType;
104
78
  var searchParams = searchParamsOption || [];
105
79
  var url = new URL(cozyUrl);
106
80
  url.host = subDomainType === 'nested' ? "".concat(slug, ".").concat(url.host) : url.host.split('.').map(function (x, i) {
@@ -157,9 +131,36 @@ var deconstructCozyWebLinkWithSlug = function deconstructCozyWebLinkWithSlug(web
157
131
  slug: slug
158
132
  };
159
133
  };
134
+ /**
135
+ * Deconstruct the given redirect link in order to retrieve slug and hash
136
+ *
137
+ * @param {string} redirectLink - redirect link to deconstruct (i.e. 'slug/#/path')
138
+ * @returns {RedirectLinkData} Deconstructed link
139
+ */
140
+
160
141
 
161
142
  exports.deconstructCozyWebLinkWithSlug = deconstructCozyWebLinkWithSlug;
162
143
 
144
+ var deconstructRedirectLink = function deconstructRedirectLink(redirectLink) {
145
+ var _redirectLink$split = redirectLink.split('#'),
146
+ _redirectLink$split2 = (0, _slicedToArray2.default)(_redirectLink$split, 2),
147
+ splits = _redirectLink$split2[0],
148
+ hash = _redirectLink$split2[1];
149
+
150
+ var _splits$split = splits.split(/\/(.*)/),
151
+ _splits$split2 = (0, _slicedToArray2.default)(_splits$split, 2),
152
+ slug = _splits$split2[0],
153
+ path = _splits$split2[1];
154
+
155
+ return {
156
+ slug: slug,
157
+ path: path,
158
+ hash: hash
159
+ };
160
+ };
161
+
162
+ exports.deconstructRedirectLink = deconstructRedirectLink;
163
+
163
164
  var InvalidProtocolError = /*#__PURE__*/function (_Error) {
164
165
  (0, _inherits2.default)(InvalidProtocolError, _Error);
165
166
 
@@ -211,10 +212,10 @@ var InvalidCozyUrlError = /*#__PURE__*/function (_Error2) {
211
212
 
212
213
  exports.InvalidCozyUrlError = InvalidCozyUrlError;
213
214
 
214
- var uri = function uri(_ref4) {
215
- var protocol = _ref4.protocol,
216
- hostname = _ref4.hostname,
217
- port = _ref4.port;
215
+ var uri = function uri(_ref2) {
216
+ var protocol = _ref2.protocol,
217
+ hostname = _ref2.hostname,
218
+ port = _ref2.port;
218
219
  return (protocol !== '' ? "".concat(protocol, "//") : 'https://') + hostname + (port !== '' ? ":".concat(port) : '');
219
220
  };
220
221
  /* wellKnownUrl - Returns a valid URL string to a Well Known password change page
@@ -257,7 +258,7 @@ var wellKnownUrl = function wellKnownUrl(url) {
257
258
 
258
259
 
259
260
  var isValidOrigin = /*#__PURE__*/function () {
260
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
261
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
261
262
  var _yield$fetch, status;
262
263
 
263
264
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -290,7 +291,7 @@ var isValidOrigin = /*#__PURE__*/function () {
290
291
  }));
291
292
 
292
293
  return function isValidOrigin(_x) {
293
- return _ref5.apply(this, arguments);
294
+ return _ref3.apply(this, arguments);
294
295
  };
295
296
  }();
296
297
  /**
@@ -337,7 +338,7 @@ var isValidOrigin = /*#__PURE__*/function () {
337
338
 
338
339
 
339
340
  var rootCozyUrl = /*#__PURE__*/function () {
340
- var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url) {
341
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url) {
341
342
  var _url$hostname$split, _url$hostname$split2, subDomain, domain, _hostname, hostname;
342
343
 
343
344
  return _regenerator.default.wrap(function _callee2$(_context2) {
@@ -425,7 +426,7 @@ var rootCozyUrl = /*#__PURE__*/function () {
425
426
  }));
426
427
 
427
428
  return function rootCozyUrl(_x2) {
428
- return _ref6.apply(this, arguments);
429
+ return _ref4.apply(this, arguments);
429
430
  };
430
431
  }();
431
432
 
@@ -2,122 +2,12 @@ import { enableFetchMocks, disableFetchMocks } from 'jest-fetch-mock'
2
2
 
3
3
  import {
4
4
  deconstructCozyWebLinkWithSlug,
5
- dehydrate,
5
+ deconstructRedirectLink,
6
6
  generateWebLink,
7
7
  rootCozyUrl,
8
8
  InvalidCozyUrlError,
9
9
  InvalidProtocolError
10
- } from './helpers'
11
-
12
- import {
13
- HasManyInPlace,
14
- HasMany,
15
- HasManyFiles,
16
- HasOneInPlace,
17
- create as createAssociation,
18
- Association
19
- } from './associations'
20
-
21
- describe('dehydrate', () => {
22
- let document
23
-
24
- const intialDocument = {
25
- regularKey: 'foo',
26
- manyInPlace: [1, 2],
27
- oneInPlace: '1',
28
- relationships: {
29
- hasMany: {
30
- data: [{ _id: 1, _type: 'has.many' }, { _id: 2, _type: 'has.many' }]
31
- },
32
- hasManyFiles: {
33
- data: [
34
- { _id: 1, _type: 'has.many.files' },
35
- { _id: 2, _type: 'has.many.files' }
36
- ]
37
- }
38
- }
39
- }
40
-
41
- class BadAssociation extends Association {}
42
-
43
- const relationships = [
44
- {
45
- name: 'manyInPlace',
46
- type: HasManyInPlace,
47
- doctype: 'many.in.place'
48
- },
49
- {
50
- name: 'oneInPlace',
51
- type: HasOneInPlace,
52
- doctype: 'one.in.place'
53
- },
54
- {
55
- name: 'hasMany',
56
- type: HasMany,
57
- doctype: 'has.many'
58
- },
59
- {
60
- name: 'hasManyFiles',
61
- type: HasManyFiles,
62
- doctype: 'has.many.files'
63
- }
64
- ]
65
-
66
- beforeEach(() => {
67
- document = relationships.reduce(
68
- (acc, relationship) => ({
69
- ...acc,
70
- [relationship.name]: createAssociation(intialDocument, relationship, {})
71
- }),
72
- intialDocument
73
- )
74
- })
75
-
76
- it('should not touch regular values', () => {
77
- expect(dehydrate(document).regularKey).toEqual(intialDocument.regularKey)
78
- })
79
-
80
- it('should dehydrate HasManyInPlace relationships', () => {
81
- expect(dehydrate(document).manyInPlace).toEqual(intialDocument.manyInPlace)
82
- })
83
-
84
- it('should dehydrate HasOneInPlace relationships', () => {
85
- const dehydrated = dehydrate(document)
86
- expect(dehydrated.oneInPlace).toEqual(intialDocument.oneInPlace)
87
- expect(dehydrated.oneInPlace).not.toBeUndefined()
88
- })
89
-
90
- it('should dehydrate HasMany relationships', () => {
91
- const dehydrated = dehydrate(document)
92
- expect(dehydrated.relationships.hasMany).toEqual(
93
- intialDocument.relationships.hasMany
94
- )
95
- expect(dehydrated.hasMany).toBeUndefined()
96
- })
97
-
98
- it('should dehydrate HasManyFiles relationships', () => {
99
- const dehydrated = dehydrate(document)
100
- expect(dehydrated.relationships.hasManyFiles).toBeUndefined()
101
- expect(dehydrated.hasManyFiles).toBeUndefined()
102
- })
103
-
104
- it('should throw if a relationship is not dehydratable', () => {
105
- document.badAssociation = createAssociation(
106
- document,
107
- {
108
- name: 'BadAssociation',
109
- type: BadAssociation,
110
- doctype: 'bad.association'
111
- },
112
- {}
113
- )
114
- expect(() => {
115
- dehydrate(document)
116
- }).toThrowError(
117
- `Association on key badAssociation should have a dehydrate method`
118
- )
119
- })
120
- })
10
+ } from './urlHelper'
121
11
 
122
12
  describe('generateWebLink', () => {
123
13
  it('should generate the right link to a flat cozy', () => {
@@ -228,6 +118,53 @@ describe('deconstructWebLink', () => {
228
118
  )
229
119
  })
230
120
 
121
+ describe('deconstructRedirectLink', () => {
122
+ it.each([
123
+ [
124
+ 'contacts/#/',
125
+ {
126
+ slug: 'contacts',
127
+ path: '',
128
+ hash: '/'
129
+ }
130
+ ],
131
+ [
132
+ 'contacts/#/hash',
133
+ {
134
+ slug: 'contacts',
135
+ path: '',
136
+ hash: '/hash'
137
+ }
138
+ ],
139
+ [
140
+ 'contacts/#/long/hash',
141
+ {
142
+ slug: 'contacts',
143
+ path: '',
144
+ hash: '/long/hash'
145
+ }
146
+ ],
147
+ [
148
+ 'contacts/path/#/long/hash',
149
+ {
150
+ slug: 'contacts',
151
+ path: 'path/',
152
+ hash: '/long/hash'
153
+ }
154
+ ],
155
+ [
156
+ 'contacts/long/path/#/long/hash',
157
+ {
158
+ slug: 'contacts',
159
+ path: 'long/path/',
160
+ hash: '/long/hash'
161
+ }
162
+ ]
163
+ ])('should deconstruct %p redirect link', (link, result) => {
164
+ expect(deconstructRedirectLink(link)).toEqual(result)
165
+ })
166
+ })
167
+
231
168
  describe('rootCozyUrl', () => {
232
169
  beforeAll(() => {
233
170
  enableFetchMocks()
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ var _exportNames = {
27
27
  getReferencedBy: true,
28
28
  getReferencedById: true,
29
29
  deconstructCozyWebLinkWithSlug: true,
30
+ deconstructRedirectLink: true,
30
31
  dehydrate: true,
31
32
  generateWebLink: true,
32
33
  ensureFirstSlash: true,
@@ -171,6 +172,12 @@ Object.defineProperty(exports, "deconstructCozyWebLinkWithSlug", {
171
172
  return _helpers2.deconstructCozyWebLinkWithSlug;
172
173
  }
173
174
  });
175
+ Object.defineProperty(exports, "deconstructRedirectLink", {
176
+ enumerable: true,
177
+ get: function get() {
178
+ return _helpers2.deconstructRedirectLink;
179
+ }
180
+ });
174
181
  Object.defineProperty(exports, "dehydrate", {
175
182
  enumerable: true,
176
183
  get: function get() {
@@ -23,6 +23,7 @@ var _exportNames = {
23
23
  HasManyInPlace: true,
24
24
  HasManyTriggers: true,
25
25
  deconstructCozyWebLinkWithSlug: true,
26
+ deconstructRedirectLink: true,
26
27
  dehydrate: true,
27
28
  generateWebLink: true,
28
29
  ensureFirstSlash: true,
@@ -133,6 +134,12 @@ Object.defineProperty(exports, "deconstructCozyWebLinkWithSlug", {
133
134
  return _helpers.deconstructCozyWebLinkWithSlug;
134
135
  }
135
136
  });
137
+ Object.defineProperty(exports, "deconstructRedirectLink", {
138
+ enumerable: true,
139
+ get: function get() {
140
+ return _helpers.deconstructRedirectLink;
141
+ }
142
+ });
136
143
  Object.defineProperty(exports, "dehydrate", {
137
144
  enumerable: true,
138
145
  get: function get() {
package/dist/types.js CHANGED
@@ -495,5 +495,14 @@ var _dsl = require("./queries/dsl");
495
495
  * @property {string} [searchParams] - The link's searchParams (i.e. 'id=SOME_FOLDER_ID&sharecode=SOME_SHARECODE')
496
496
  * @property {string} slug - The link's slug (i.e. 'drive' or 'notes)
497
497
  */
498
+
499
+ /**
500
+ * Represents the different parts of a deconstructed redirect link
501
+ *
502
+ * @typedef {object} RedirectLinkData
503
+ * @property {string} slug - The redirect link's slug (i.e. 'drive')
504
+ * @property {string} path - The redirect link's path (i.e. 'public')
505
+ * @property {string} hash - The redirect link's path (i.e. '/folder/SOME_FOLDER_ID')
506
+ */
498
507
  var _default = {};
499
508
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "35.3.0",
3
+ "version": "35.4.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "@types/jest": "^26.0.20",
19
19
  "@types/lodash": "^4.14.170",
20
20
  "btoa": "^1.2.1",
21
- "cozy-stack-client": "^35.0.0",
21
+ "cozy-stack-client": "^35.3.1",
22
22
  "date-fns": "2.29.3",
23
23
  "json-stable-stringify": "^1.0.1",
24
24
  "lodash": "^4.17.13",
@@ -73,5 +73,5 @@
73
73
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
74
74
  },
75
75
  "sideEffects": false,
76
- "gitHead": "4d92b87e3fabf7b2a6ed34a9e55d6087a55a8aff"
76
+ "gitHead": "43e9bd9aabeb99f5ad54896db012c1c290f027ee"
77
77
  }
@@ -0,0 +1 @@
1
+ export function dehydrate(document: any): {};
@@ -0,0 +1,2 @@
1
+ export { dehydrate } from "./dehydrateHelper";
2
+ export { deconstructCozyWebLinkWithSlug, deconstructRedirectLink, generateWebLink, ensureFirstSlash, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./urlHelper";
@@ -1,4 +1,3 @@
1
- export function dehydrate(document: any): {};
2
1
  export function ensureFirstSlash(path: any): any;
3
2
  export function generateWebLink({ cozyUrl, searchParams: searchParamsOption, pathname, hash, slug, subDomainType }: {
4
3
  cozyUrl: string;
@@ -9,6 +8,7 @@ export function generateWebLink({ cozyUrl, searchParams: searchParamsOption, pat
9
8
  subDomainType: string;
10
9
  }): string;
11
10
  export function deconstructCozyWebLinkWithSlug(webLink: string, subDomainType?: SubdomainType): CozyLinkData;
11
+ export function deconstructRedirectLink(redirectLink: string): RedirectLinkData;
12
12
  export class InvalidProtocolError extends Error {
13
13
  constructor(url: any);
14
14
  url: any;
@@ -18,5 +18,6 @@ export class InvalidCozyUrlError extends Error {
18
18
  url: any;
19
19
  }
20
20
  export function rootCozyUrl(url: URL): Promise<URL>;
21
- import { SubdomainType } from "./types";
22
- import { CozyLinkData } from "./types";
21
+ import { SubdomainType } from "../types";
22
+ import { CozyLinkData } from "../types";
23
+ import { RedirectLinkData } from "../types";
package/types/index.d.ts CHANGED
@@ -19,6 +19,6 @@ export { manifest, models };
19
19
  export { QueryDefinition, Q, Mutations, MutationTypes, getDoctypeFromOperation } from "./queries/dsl";
20
20
  export { Association, HasMany, HasOne, HasOneInPlace, HasManyInPlace, HasManyTriggers } from "./associations";
21
21
  export { isReferencedBy, isReferencedById, getReferencedBy, getReferencedById } from "./associations/helpers";
22
- export { deconstructCozyWebLinkWithSlug, dehydrate, generateWebLink, ensureFirstSlash, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./helpers";
22
+ export { deconstructCozyWebLinkWithSlug, deconstructRedirectLink, dehydrate, generateWebLink, ensureFirstSlash, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./helpers";
23
23
  export { cancelable, isQueryLoading, hasQueryBeenLoaded } from "./utils";
24
24
  export { queryConnect, queryConnectFlat, withClient } from "./hoc";
@@ -14,4 +14,4 @@ import * as models from "./models";
14
14
  export { manifest, models };
15
15
  export { QueryDefinition, Mutations, MutationTypes, getDoctypeFromOperation, Q } from "./queries/dsl";
16
16
  export { Association, HasMany, HasOne, HasOneInPlace, HasManyInPlace, HasManyTriggers } from "./associations";
17
- export { deconstructCozyWebLinkWithSlug, dehydrate, generateWebLink, ensureFirstSlash, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./helpers";
17
+ export { deconstructCozyWebLinkWithSlug, deconstructRedirectLink, dehydrate, generateWebLink, ensureFirstSlash, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./helpers";
package/types/types.d.ts CHANGED
@@ -735,4 +735,21 @@ export type CozyLinkData = {
735
735
  */
736
736
  slug: string;
737
737
  };
738
+ /**
739
+ * Represents the different parts of a deconstructed redirect link
740
+ */
741
+ export type RedirectLinkData = {
742
+ /**
743
+ * - The redirect link's slug (i.e. 'drive')
744
+ */
745
+ slug: string;
746
+ /**
747
+ * - The redirect link's path (i.e. 'public')
748
+ */
749
+ path: string;
750
+ /**
751
+ * - The redirect link's path (i.e. '/folder/SOME_FOLDER_ID')
752
+ */
753
+ hash: string;
754
+ };
738
755
  import { QueryDefinition } from "./queries/dsl";