cozy-pouch-link 57.3.0 → 57.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.
@@ -37,8 +37,6 @@ var _omit = _interopRequireDefault(require("lodash/omit"));
37
37
 
38
38
  var _defaults = _interopRequireDefault(require("lodash/defaults"));
39
39
 
40
- var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
41
-
42
40
  var _zipWith = _interopRequireDefault(require("lodash/zipWith"));
43
41
 
44
42
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
@@ -116,14 +114,6 @@ exports.getReplicationURL = _getReplicationURL;
116
114
  var doNothing = function doNothing(operation) {
117
115
  var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
118
116
  };
119
-
120
- var normalizeAll = function normalizeAll(client) {
121
- return function (docs, doctype) {
122
- return docs.map(function (doc) {
123
- return jsonapi.normalizeDoc(doc, doctype, client);
124
- });
125
- };
126
- };
127
117
  /**
128
118
  * @typedef {import('cozy-client/src/types').CozyClientDocument} CozyClientDocument
129
119
  *
@@ -516,14 +506,24 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
516
506
  }, {
517
507
  key: "handleOnSync",
518
508
  value: function handleOnSync(doctypeUpdates) {
519
- var normalizedData = (0, _mapValues.default)(doctypeUpdates, normalizeAll(this.client));
509
+ var _this3 = this;
510
+
511
+ var doctypes = doctypeUpdates && Object.keys(doctypeUpdates);
512
+
513
+ if (doctypes) {
514
+ doctypes.forEach(function (doctype) {
515
+ if (doctype) {
516
+ (0, jsonapi.normalizeDocs)(_this3.client, doctype, doctypeUpdates[doctype]);
517
+ }
518
+ });
519
+ }
520
520
 
521
521
  if (this.client) {
522
- this.client.setData(normalizedData);
522
+ this.client.setData(doctypeUpdates);
523
523
  }
524
524
 
525
525
  if (this.options.onSync) {
526
- this.options.onSync.call(this, normalizedData);
526
+ this.options.onSync.call(this, doctypeUpdates);
527
527
  }
528
528
 
529
529
  if (process.env.NODE_ENV !== 'production') {
package/dist/jsonapi.js CHANGED
@@ -1,50 +1,73 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.fromPouchResult = exports.normalizeDoc = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _cozyClient = require("cozy-client");
8
+ exports.fromPouchResult = exports.normalizeDoc = exports.normalizeDocs = void 0;
9
+
10
+ var _cozyClient = _interopRequireWildcard(require("cozy-client"));
11
+
12
+ /**
13
+ * Normalize several PouchDB document
14
+ *
15
+ * @param {CozyClient} client - The CozyClient instance
16
+ * @param {string} doctype - The document's doctype
17
+ * @param {Array<import('./CozyPouchLink').CozyClientDocument>} docs - The documents to normalize
18
+ */
19
+ var normalizeDocs = function normalizeDocs(client, doctype, docs) {
20
+ for (var i = docs.length; i >= 0; i--) {
21
+ var doc = docs[i];
22
+
23
+ if (!doc) {
24
+ docs.splice(i, 1);
25
+ continue;
26
+ }
27
+
28
+ normalizeDoc(client, doctype, doc);
29
+ }
30
+ };
31
+ /**
32
+ * Normalize a PouchDB document
33
+ * Note we directly modify the objet rather than creating a new one, as it is
34
+ * much more performant. See commit description for details.
35
+ *
36
+ * @param {CozyClient} client - The CozyClient instance
37
+ * @param {string} doctype - The document's doctype
38
+ * @param {import('./CozyPouchLink').CozyClientDocument} doc - The document to normalize
39
+ */
13
40
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
41
 
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
42
+ exports.normalizeDocs = normalizeDocs;
17
43
 
18
- var normalizeDoc = function normalizeDoc(doc, doctype, client) {
44
+ var normalizeDoc = function normalizeDoc(client, doctype, doc) {
19
45
  var id = doc._id || doc.id;
20
- var relationships = doc.relationships,
21
- referenced_by = doc.referenced_by; // PouchDB sends back .rev attribute but we do not want to
22
- // keep it on the server. It is potentially higher than the
23
- // _rev.
24
-
25
- var _rev = doc.rev || doc._rev;
26
-
27
- var normalizedDoc = _objectSpread(_objectSpread({}, doc), {}, {
28
- id: id,
29
- _id: id,
30
- _rev: _rev,
31
- _type: doctype,
32
- relationships: _objectSpread(_objectSpread({}, relationships), {}, {
33
- referenced_by: referenced_by
34
- })
35
- });
46
+ doc.id = id;
47
+ doc._id = id;
48
+ doc._rev = doc._rev || doc.rev;
49
+ doc._type = doctype;
36
50
 
37
- if (normalizedDoc.rev) {
38
- delete normalizedDoc.rev;
51
+ if (doc.relationships) {
52
+ doc.relationships.referenced_by = doc.referenced_by;
53
+ } else {
54
+ doc.relationships = {
55
+ referenced_by: doc.referenced_by
56
+ };
39
57
  }
40
58
 
41
- normalizeAppsLinks(normalizedDoc, doctype, client);
42
- return normalizedDoc;
59
+ if (doc.rev) {
60
+ doc.rev = undefined;
61
+ }
62
+
63
+ if (doctype === 'io.cozy.apps') {
64
+ normalizeAppsLinks(client, doctype, doc);
65
+ }
43
66
  };
44
67
 
45
68
  exports.normalizeDoc = normalizeDoc;
46
69
 
47
- var normalizeAppsLinks = function normalizeAppsLinks(docRef, doctype, client) {
70
+ var normalizeAppsLinks = function normalizeAppsLinks(client, doctype, docRef) {
48
71
  if (doctype !== 'io.cozy.apps') {
49
72
  return;
50
73
  }
@@ -64,10 +87,6 @@ var normalizeAppsLinks = function normalizeAppsLinks(docRef, doctype, client) {
64
87
  };
65
88
  };
66
89
 
67
- var filterDeletedDocumentsFromRows = function filterDeletedDocumentsFromRows(doc) {
68
- return !!doc;
69
- };
70
-
71
90
  var fromPouchResult = function fromPouchResult(_ref) {
72
91
  var res = _ref.res,
73
92
  withRows = _ref.withRows,
@@ -91,23 +110,22 @@ var fromPouchResult = function fromPouchResult(_ref) {
91
110
  if (withRows) {
92
111
  var docs = res.rows ? res.rows.map(function (row) {
93
112
  return row.doc;
94
- }).filter(filterDeletedDocumentsFromRows) : res.docs;
113
+ }) : res.docs;
95
114
  var offset = res.offset || 0;
96
- return {
97
- data: docs.map(function (doc) {
98
- return normalizeDoc(doc, doctype, client);
99
- }),
115
+ normalizeDocs(client, doctype, docs);
116
+ var result = {
117
+ data: docs,
100
118
  meta: {
101
119
  count: docs.length
102
120
  },
103
121
  skip: offset,
104
122
  next: offset + docs.length < res.total_rows || docs.length >= res.limit
105
123
  };
124
+ return result;
106
125
  } else {
126
+ Array.isArray(res) ? normalizeDocs(client, doctype, res) : normalizeDoc(client, doctype, res);
107
127
  return {
108
- data: Array.isArray(res) ? res.map(function (doc) {
109
- return normalizeDoc(doc, doctype, client);
110
- }) : normalizeDoc(res, doctype, client)
128
+ data: res
111
129
  };
112
130
  }
113
131
  };
@@ -31,35 +31,45 @@ const DELETED_DOC_FIXTURE = {
31
31
  const token = 'fake_token'
32
32
  const uri = 'https://claude.mycozy.cloud'
33
33
  const client = new CozyClient({ token, uri })
34
+ client.capabilities = { flat_subdomains: true }
34
35
 
35
36
  describe('doc normalization', () => {
36
- it('keeps the highest between rev and _rev and removes the rev attribute', () => {
37
- const normalized = normalizeDoc(
38
- {
39
- _id: 1234,
40
- _rev: '3-deadbeef',
41
- rev: '4-cffee',
42
- firstName: 'Bobba',
43
- lastName: 'Fett'
44
- },
45
- 'io.cozy.contacts'
46
- )
47
- expect(normalized).toEqual({
37
+ it('should normalize apps links', () => {
38
+ const doc = {
39
+ _id: 1234,
40
+ _rev: '3-deadbeef',
41
+ slug: 'contact',
42
+ version: '1.2.0'
43
+ }
44
+ normalizeDoc(client, 'io.cozy.apps', doc)
45
+ expect(doc).toEqual({
48
46
  _id: 1234,
49
47
  id: 1234,
50
- _rev: '4-cffee',
51
- _type: 'io.cozy.contacts',
52
- firstName: 'Bobba',
53
- lastName: 'Fett',
48
+ _rev: '3-deadbeef',
49
+ _type: 'io.cozy.apps',
50
+ slug: 'contact',
51
+ version: '1.2.0',
54
52
  relationships: {
55
53
  referenced_by: undefined
54
+ },
55
+ links: {
56
+ icon: '/apps/contact/icon/1.2.0',
57
+ related: 'https://claude-contact.mycozy.cloud/#/',
58
+ self: '/apps/contact'
56
59
  }
57
60
  })
58
61
  })
59
62
  })
60
63
 
61
64
  describe('jsonapi', () => {
62
- it('should return a response understandable by cozy-client', () => {
65
+ const expectedDocResp = (normalizedDoc, expectedName, expectedId) => {
66
+ expect(normalizedDoc.name).toBe(expectedName)
67
+ expect(normalizedDoc.id).toBe(expectedId)
68
+ expect(normalizedDoc._id).toBe(expectedId)
69
+ expect(normalizedDoc._type).toBe('io.cozy.simpsons')
70
+ }
71
+
72
+ it('should correctly normalize if there are rows in the response', () => {
63
73
  const res = {
64
74
  rows: [BART_FIXTURE, LISA_FIXTURE, MARGE_FIXTURE, DELETED_DOC_FIXTURE]
65
75
  }
@@ -69,18 +79,36 @@ describe('jsonapi', () => {
69
79
  doctype: 'io.cozy.simpsons',
70
80
  client
71
81
  })
72
- expect(normalized.data[0].name).toBe('Bart')
73
- expect(normalized.data[0].id).toBe(1)
74
- expect(normalized.data[0]._id).toBe(1)
75
- expect(normalized.data[0]._type).toBe('io.cozy.simpsons')
76
-
77
- expect(normalized.data[1].name).toBe('Lisa')
78
- expect(normalized.data[1].id).toBe(2)
79
- expect(normalized.data[1]._id).toBe(2)
80
-
81
- expect(normalized.data[2].name).toBe('Marge')
82
- expect(normalized.data[2].id).toBe(3)
83
- expect(normalized.data[2]._id).toBe(3)
82
+
83
+ expectedDocResp(normalized.data[0], 'Bart', 1)
84
+ expectedDocResp(normalized.data[1], 'Lisa', 2)
85
+ expectedDocResp(normalized.data[2], 'Marge', 3)
86
+ })
87
+
88
+ it('should correctly normalize if the response is a data array', () => {
89
+ const res = [BART_FIXTURE.doc, LISA_FIXTURE.doc, MARGE_FIXTURE.doc]
90
+ const normalized = fromPouchResult({
91
+ res,
92
+ withRows: false,
93
+ doctype: 'io.cozy.simpsons',
94
+ client
95
+ })
96
+
97
+ expectedDocResp(normalized.data[0], 'Bart', 1)
98
+ expectedDocResp(normalized.data[1], 'Lisa', 2)
99
+ expectedDocResp(normalized.data[2], 'Marge', 3)
100
+ })
101
+
102
+ it('should correctly normalize if the response is a data object', () => {
103
+ const res = BART_FIXTURE.doc
104
+ const normalized = fromPouchResult({
105
+ res,
106
+ withRows: false,
107
+ doctype: 'io.cozy.simpsons',
108
+ client
109
+ })
110
+
111
+ expectedDocResp(normalized.data, 'Bart', 1)
84
112
  })
85
113
 
86
114
  describe('pagination', () => {
@@ -140,4 +168,404 @@ describe('jsonapi', () => {
140
168
  expect(lastNormalized.next).toBe(false)
141
169
  })
142
170
  })
171
+
172
+ describe('normalization', () => {
173
+ it('Should normalize single doc', () => {
174
+ const res = singleDocRes
175
+ const normalized = fromPouchResult({
176
+ res,
177
+ withRows: false,
178
+ doctype: 'io.cozy.settings',
179
+ client
180
+ })
181
+ expect(normalized).toEqual({
182
+ data: {
183
+ _id: 'io.cozy.settings.flags',
184
+ _rev: '1-078d414431314ea48ad6556cad579996',
185
+ _type: 'io.cozy.settings',
186
+ cozyLocalOnly: true,
187
+ id: 'io.cozy.settings.flags',
188
+ links: {
189
+ self: '/settings/flags'
190
+ },
191
+ relationships: {
192
+ referenced_by: undefined
193
+ },
194
+ 'some.boolean.flag': true,
195
+ 'some.number.flag': 30,
196
+ 'some.object.flag': {
197
+ value1: 100,
198
+ value2: 100
199
+ },
200
+ 'some.other.boolean.flag': true,
201
+ type: 'io.cozy.settings'
202
+ }
203
+ })
204
+ })
205
+ })
206
+ it('Should normalize docs array', () => {
207
+ const res = multipleDocRes
208
+ const normalized = fromPouchResult({
209
+ res,
210
+ withRows: true,
211
+ doctype: 'io.cozy.files',
212
+ client
213
+ })
214
+ expect(normalized).toEqual({
215
+ data: [
216
+ {
217
+ relationships: {
218
+ referenced_by: undefined
219
+ },
220
+ id: '018bdcec-00c8-7155-b352-c8a8f472f882',
221
+ type: 'file',
222
+ _type: 'io.cozy.files',
223
+ name: 'New note 2023-11-17T10-55-36Z.cozy-note',
224
+ dir_id: '3ab984a52b49806a2a29a14d31cc063f',
225
+ created_at: '2023-11-17T10:55:36.061274688Z',
226
+ updated_at: '2023-11-17T10:58:40.254562842Z',
227
+ size: '51',
228
+ md5sum: 'AYU8xZStzHKpiabOg2EHyg==',
229
+ mime: 'text/vnd.cozy.note+markdown',
230
+ class: 'text',
231
+ executable: false,
232
+ trashed: false,
233
+ encrypted: false,
234
+ metadata: {
235
+ content: {
236
+ content: [],
237
+ type: 'doc'
238
+ },
239
+ schema: {
240
+ marks: [],
241
+ nodes: [],
242
+ version: 4
243
+ },
244
+ title: '',
245
+ version: 57
246
+ },
247
+ cozyMetadata: {
248
+ doctypeVersion: '1',
249
+ metadataVersion: 1,
250
+ createdAt: '2023-11-17T10:55:36.061274688Z',
251
+ createdByApp: 'notes',
252
+ updatedAt: '2023-11-17T10:58:40.254562842Z',
253
+ createdOn: 'https://yannickchironcozywtf1.cozy.wtf/'
254
+ },
255
+ internal_vfs_id: 'HyepeHXMIHkKhrmq',
256
+ _id: '018bdcec-00c8-7155-b352-c8a8f472f882',
257
+ _rev: '2-c78707eb06cceaa5e95c1c4a4c4073bd'
258
+ },
259
+ {
260
+ relationships: {
261
+ referenced_by: [
262
+ {
263
+ id: '536bde9aef87dde16630d3c99d26453f',
264
+ type: 'io.cozy.photos.albums'
265
+ }
266
+ ]
267
+ },
268
+ id: '018c7cf1-1d00-73ac-9a7f-ee3190638183',
269
+ type: 'file',
270
+ _type: 'io.cozy.files',
271
+ name: 'IMG_0046.jpg',
272
+ dir_id: 'io.cozy.files.root-dir',
273
+ created_at: '2023-11-19T13:31:47+01:00',
274
+ updated_at: '2023-12-18T12:40:25.379Z',
275
+ size: '1732841',
276
+ md5sum: 'i19eI81lfj3dTwc7i8ihfA==',
277
+ mime: 'image/jpeg',
278
+ class: 'image',
279
+ executable: false,
280
+ trashed: false,
281
+ encrypted: false,
282
+ tags: ['library'],
283
+ metadata: {
284
+ datetime: '2023-11-19T13:31:47+01:00',
285
+ extractor_version: 2,
286
+ flash: 'On, Fired',
287
+ height: 3024,
288
+ orientation: 6,
289
+ width: 4032
290
+ },
291
+ referenced_by: [
292
+ {
293
+ id: '536bde9aef87dde16630d3c99d26453f',
294
+ type: 'io.cozy.photos.albums'
295
+ }
296
+ ],
297
+ cozyMetadata: {
298
+ doctypeVersion: '1',
299
+ metadataVersion: 1,
300
+ createdAt: '2023-12-18T12:40:25.556898681Z',
301
+ updatedAt: '2023-12-18T12:45:29.375968305Z',
302
+ updatedByApps: [
303
+ {
304
+ slug: 'photos',
305
+ date: '2023-12-18T12:45:29.375968305Z',
306
+ instance: 'https://yannickchironcozywtf1.cozy.wtf/'
307
+ }
308
+ ],
309
+ createdOn: 'https://yannickchironcozywtf1.cozy.wtf/',
310
+ uploadedAt: '2023-12-18T12:40:25.556898681Z',
311
+ uploadedOn: 'https://yannickchironcozywtf1.cozy.wtf/'
312
+ },
313
+ internal_vfs_id: 'SidToiYjmikHrFBP',
314
+ _id: '018c7cf1-1d00-73ac-9a7f-ee3190638183',
315
+ _rev: '2-02e800df012ea1cc740e5ad1554cefe6'
316
+ },
317
+ {
318
+ relationships: {
319
+ referenced_by: [
320
+ {
321
+ id: '536bde9aef87dde16630d3c99d26453f',
322
+ type: 'io.cozy.photos.albums'
323
+ }
324
+ ]
325
+ },
326
+ id: '018ca6a8-8292-7acb-bcaf-a95ccfd83662',
327
+ _type: 'io.cozy.files',
328
+ type: 'file',
329
+ name: 'IMG_0047.jpg',
330
+ dir_id: 'io.cozy.files.root-dir',
331
+ created_at: '2023-11-19T13:31:47+01:00',
332
+ updated_at: '2023-12-26T15:05:10.256Z',
333
+ size: '1732841',
334
+ md5sum: 'i19eI81lfj3dTwc7i8ihfA==',
335
+ mime: 'image/jpeg',
336
+ class: 'image',
337
+ executable: false,
338
+ trashed: false,
339
+ encrypted: false,
340
+ tags: ['library'],
341
+ metadata: {
342
+ datetime: '2023-11-19T13:31:47+01:00',
343
+ extractor_version: 2,
344
+ flash: 'On, Fired',
345
+ height: 3024,
346
+ orientation: 6,
347
+ width: 4032
348
+ },
349
+ referenced_by: [
350
+ {
351
+ id: '536bde9aef87dde16630d3c99d26453f',
352
+ type: 'io.cozy.photos.albums'
353
+ }
354
+ ],
355
+ cozyMetadata: {
356
+ doctypeVersion: '1',
357
+ metadataVersion: 1,
358
+ createdAt: '2023-12-26T15:05:10.51011657Z',
359
+ updatedAt: '2025-01-12T12:33:00.313230696Z',
360
+ updatedByApps: [
361
+ {
362
+ slug: 'photos',
363
+ date: '2023-12-26T15:11:03.400641304Z',
364
+ instance: 'https://yannickchironcozywtf1.cozy.wtf/'
365
+ },
366
+ {
367
+ slug: 'drive',
368
+ date: '2025-01-12T12:33:00.313230696Z',
369
+ instance: 'https://yannickchironcozywtf1.cozy.wtf/'
370
+ }
371
+ ],
372
+ createdOn: 'https://yannickchironcozywtf1.cozy.wtf/',
373
+ uploadedAt: '2023-12-26T15:05:10.51011657Z',
374
+ uploadedOn: 'https://yannickchironcozywtf1.cozy.wtf/'
375
+ },
376
+ internal_vfs_id: 'VSHXbbIKcufNgifx',
377
+ _id: '018ca6a8-8292-7acb-bcaf-a95ccfd83662',
378
+ _rev: '3-e18fb4f579ba93d569cabcbacc7bcd60'
379
+ }
380
+ ],
381
+ meta: { count: 3 },
382
+ skip: 0,
383
+ next: false
384
+ })
385
+ })
143
386
  })
387
+
388
+ const singleDocRes = {
389
+ id: 'io.cozy.settings.flags',
390
+ type: 'io.cozy.settings',
391
+ links: {
392
+ self: '/settings/flags'
393
+ },
394
+ 'some.boolean.flag': true,
395
+ 'some.other.boolean.flag': true,
396
+ 'some.object.flag': {
397
+ value1: 100,
398
+ value2: 100
399
+ },
400
+ 'some.number.flag': 30,
401
+ cozyLocalOnly: true,
402
+ _id: 'io.cozy.settings.flags',
403
+ _rev: '1-078d414431314ea48ad6556cad579996'
404
+ }
405
+
406
+ const multipleDocRes = {
407
+ total_rows: 3,
408
+ offset: 0,
409
+ rows: [
410
+ {
411
+ id: '018bdcec-00c8-7155-b352-c8a8f472f882',
412
+ key: '018bdcec-00c8-7155-b352-c8a8f472f882',
413
+ value: {
414
+ rev: '2-c78707eb06cceaa5e95c1c4a4c4073bd'
415
+ },
416
+ doc: {
417
+ type: 'file',
418
+ name: 'New note 2023-11-17T10-55-36Z.cozy-note',
419
+ dir_id: '3ab984a52b49806a2a29a14d31cc063f',
420
+ created_at: '2023-11-17T10:55:36.061274688Z',
421
+ updated_at: '2023-11-17T10:58:40.254562842Z',
422
+ size: '51',
423
+ md5sum: 'AYU8xZStzHKpiabOg2EHyg==',
424
+ mime: 'text/vnd.cozy.note+markdown',
425
+ class: 'text',
426
+ executable: false,
427
+ trashed: false,
428
+ encrypted: false,
429
+ metadata: {
430
+ content: {
431
+ content: [],
432
+ type: 'doc'
433
+ },
434
+ schema: {
435
+ marks: [],
436
+ nodes: [],
437
+ version: 4
438
+ },
439
+ title: '',
440
+ version: 57
441
+ },
442
+ cozyMetadata: {
443
+ doctypeVersion: '1',
444
+ metadataVersion: 1,
445
+ createdAt: '2023-11-17T10:55:36.061274688Z',
446
+ createdByApp: 'notes',
447
+ updatedAt: '2023-11-17T10:58:40.254562842Z',
448
+ createdOn: 'https://yannickchironcozywtf1.cozy.wtf/'
449
+ },
450
+ internal_vfs_id: 'HyepeHXMIHkKhrmq',
451
+ _id: '018bdcec-00c8-7155-b352-c8a8f472f882',
452
+ _rev: '2-c78707eb06cceaa5e95c1c4a4c4073bd'
453
+ }
454
+ },
455
+ {
456
+ id: '018c7cf1-1d00-73ac-9a7f-ee3190638183',
457
+ key: '018c7cf1-1d00-73ac-9a7f-ee3190638183',
458
+ value: {
459
+ rev: '2-02e800df012ea1cc740e5ad1554cefe6'
460
+ },
461
+ doc: {
462
+ type: 'file',
463
+ name: 'IMG_0046.jpg',
464
+ dir_id: 'io.cozy.files.root-dir',
465
+ created_at: '2023-11-19T13:31:47+01:00',
466
+ updated_at: '2023-12-18T12:40:25.379Z',
467
+ size: '1732841',
468
+ md5sum: 'i19eI81lfj3dTwc7i8ihfA==',
469
+ mime: 'image/jpeg',
470
+ class: 'image',
471
+ executable: false,
472
+ trashed: false,
473
+ encrypted: false,
474
+ tags: ['library'],
475
+ metadata: {
476
+ datetime: '2023-11-19T13:31:47+01:00',
477
+ extractor_version: 2,
478
+ flash: 'On, Fired',
479
+ height: 3024,
480
+ orientation: 6,
481
+ width: 4032
482
+ },
483
+ referenced_by: [
484
+ {
485
+ id: '536bde9aef87dde16630d3c99d26453f',
486
+ type: 'io.cozy.photos.albums'
487
+ }
488
+ ],
489
+ cozyMetadata: {
490
+ doctypeVersion: '1',
491
+ metadataVersion: 1,
492
+ createdAt: '2023-12-18T12:40:25.556898681Z',
493
+ updatedAt: '2023-12-18T12:45:29.375968305Z',
494
+ updatedByApps: [
495
+ {
496
+ slug: 'photos',
497
+ date: '2023-12-18T12:45:29.375968305Z',
498
+ instance: 'https://yannickchironcozywtf1.cozy.wtf/'
499
+ }
500
+ ],
501
+ createdOn: 'https://yannickchironcozywtf1.cozy.wtf/',
502
+ uploadedAt: '2023-12-18T12:40:25.556898681Z',
503
+ uploadedOn: 'https://yannickchironcozywtf1.cozy.wtf/'
504
+ },
505
+ internal_vfs_id: 'SidToiYjmikHrFBP',
506
+ _id: '018c7cf1-1d00-73ac-9a7f-ee3190638183',
507
+ _rev: '2-02e800df012ea1cc740e5ad1554cefe6'
508
+ }
509
+ },
510
+ {
511
+ id: '018ca6a8-8292-7acb-bcaf-a95ccfd83662',
512
+ key: '018ca6a8-8292-7acb-bcaf-a95ccfd83662',
513
+ value: {
514
+ rev: '3-e18fb4f579ba93d569cabcbacc7bcd60'
515
+ },
516
+ doc: {
517
+ type: 'file',
518
+ name: 'IMG_0047.jpg',
519
+ dir_id: 'io.cozy.files.root-dir',
520
+ created_at: '2023-11-19T13:31:47+01:00',
521
+ updated_at: '2023-12-26T15:05:10.256Z',
522
+ size: '1732841',
523
+ md5sum: 'i19eI81lfj3dTwc7i8ihfA==',
524
+ mime: 'image/jpeg',
525
+ class: 'image',
526
+ executable: false,
527
+ trashed: false,
528
+ encrypted: false,
529
+ tags: ['library'],
530
+ metadata: {
531
+ datetime: '2023-11-19T13:31:47+01:00',
532
+ extractor_version: 2,
533
+ flash: 'On, Fired',
534
+ height: 3024,
535
+ orientation: 6,
536
+ width: 4032
537
+ },
538
+ referenced_by: [
539
+ {
540
+ id: '536bde9aef87dde16630d3c99d26453f',
541
+ type: 'io.cozy.photos.albums'
542
+ }
543
+ ],
544
+ cozyMetadata: {
545
+ doctypeVersion: '1',
546
+ metadataVersion: 1,
547
+ createdAt: '2023-12-26T15:05:10.51011657Z',
548
+ updatedAt: '2025-01-12T12:33:00.313230696Z',
549
+ updatedByApps: [
550
+ {
551
+ slug: 'photos',
552
+ date: '2023-12-26T15:11:03.400641304Z',
553
+ instance: 'https://yannickchironcozywtf1.cozy.wtf/'
554
+ },
555
+ {
556
+ slug: 'drive',
557
+ date: '2025-01-12T12:33:00.313230696Z',
558
+ instance: 'https://yannickchironcozywtf1.cozy.wtf/'
559
+ }
560
+ ],
561
+ createdOn: 'https://yannickchironcozywtf1.cozy.wtf/',
562
+ uploadedAt: '2023-12-26T15:05:10.51011657Z',
563
+ uploadedOn: 'https://yannickchironcozywtf1.cozy.wtf/'
564
+ },
565
+ internal_vfs_id: 'VSHXbbIKcufNgifx',
566
+ id: '018ca6a8-8292-7acb-bcaf-a95ccfd83662',
567
+ _rev: '3-e18fb4f579ba93d569cabcbacc7bcd60'
568
+ }
569
+ }
570
+ ]
571
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-pouch-link",
3
- "version": "57.3.0",
3
+ "version": "57.4.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://github.com/cozy/cozy-client.git"
14
14
  },
15
15
  "dependencies": {
16
- "cozy-client": "^57.3.0",
16
+ "cozy-client": "^57.4.0",
17
17
  "pouchdb-browser": "^7.2.2",
18
18
  "pouchdb-find": "^7.2.2"
19
19
  },
@@ -39,5 +39,5 @@
39
39
  "typecheck": "tsc -p tsconfig.json"
40
40
  },
41
41
  "sideEffects": false,
42
- "gitHead": "aa4094d6cb80bbd4173cc82fb1a2a06406718b5e"
42
+ "gitHead": "97e956957de48f36a29d0d55adf3cb0e248f0141"
43
43
  }
@@ -271,17 +271,14 @@ declare class PouchLink extends CozyLink {
271
271
  indexedFields: any;
272
272
  partialFilter: any;
273
273
  }): Promise<{
274
- data: any;
275
- meta?: undefined;
276
- skip?: undefined;
277
- next?: undefined;
278
- } | {
279
274
  data: any;
280
275
  meta: {
281
276
  count: any;
282
277
  };
283
278
  skip: any;
284
279
  next: boolean;
280
+ } | {
281
+ data: any;
285
282
  }>;
286
283
  executeMutation(mutation: any, options: any, result: any, forward: any): Promise<any>;
287
284
  createDocument(mutation: any): Promise<any>;
@@ -1,19 +1,18 @@
1
- export function normalizeDoc(doc: any, doctype: any, client: any): any;
1
+ export function normalizeDocs(client: CozyClient, doctype: string, docs: Array<import('./CozyPouchLink').CozyClientDocument>): void;
2
+ export function normalizeDoc(client: CozyClient, doctype: string, doc: any): void;
2
3
  export function fromPouchResult({ res, withRows, doctype, client }: {
3
4
  res: any;
4
5
  withRows: any;
5
6
  doctype: any;
6
7
  client: any;
7
8
  }): {
8
- data: any;
9
- meta?: undefined;
10
- skip?: undefined;
11
- next?: undefined;
12
- } | {
13
9
  data: any;
14
10
  meta: {
15
11
  count: any;
16
12
  };
17
13
  skip: any;
18
14
  next: boolean;
15
+ } | {
16
+ data: any;
19
17
  };
18
+ import CozyClient from "cozy-client";