cozy-client 32.0.0 → 32.2.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.
@@ -2550,7 +2550,7 @@ var CozyClient = /*#__PURE__*/function () {
2550
2550
  CozyClient.hooks = CozyClient.hooks || {};
2551
2551
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2552
2552
 
2553
- CozyClient.version = "32.0.0";
2553
+ CozyClient.version = "32.2.0";
2554
2554
 
2555
2555
  _microee.default.mixin(CozyClient);
2556
2556
 
@@ -17,6 +17,8 @@ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
17
17
 
18
18
  var _omit = _interopRequireDefault(require("lodash/omit"));
19
19
 
20
+ var _merge = _interopRequireDefault(require("lodash/merge"));
21
+
20
22
  var _logger = _interopRequireDefault(require("../logger"));
21
23
 
22
24
  var _queries = require("./queries");
@@ -190,7 +192,7 @@ var extractAndMergeDocument = function extractAndMergeDocument(data, updatedStat
190
192
  var id = (0, _helpers.properId)(data);
191
193
 
192
194
  if (mergedData[doctype][id]) {
193
- mergedData[doctype][id] = _objectSpread(_objectSpread({}, mergedData[doctype][id]), data);
195
+ mergedData[doctype][id] = (0, _merge.default)(mergedData[doctype][id], data);
194
196
  } else {
195
197
  mergedData[doctype][id] = data;
196
198
  }
@@ -10,7 +10,13 @@ describe('extractAndMerge', () => {
10
10
  _id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
11
11
  type: 'io.cozy.files',
12
12
  _type: 'io.cozy.files',
13
- blabla: 'new field'
13
+ blabla: 'new field',
14
+ cozyMetadata: {
15
+ created_at: '123456',
16
+ updatedByApps: {
17
+ slug: 'drive'
18
+ }
19
+ }
14
20
  },
15
21
  1: {
16
22
  id: 'b6ff135b34e041ffb2d4a4865f3e235f',
@@ -38,7 +44,13 @@ describe('extractAndMerge', () => {
38
44
  }
39
45
  },
40
46
  type: 'io.cozy.files',
41
- _type: 'io.cozy.files'
47
+ _type: 'io.cozy.files',
48
+ cozyMetadata: {
49
+ updated_at: '987654',
50
+ updatedByApps: {
51
+ date: '2019-06-11T01:02:03Z'
52
+ }
53
+ }
42
54
  },
43
55
  b6ff135b34e041ffb2d4a4865f3e235f: {
44
56
  attributes: {
@@ -78,6 +90,14 @@ describe('extractAndMerge', () => {
78
90
  type: 'file'
79
91
  },
80
92
  blabla: 'new field',
93
+ cozyMetadata: {
94
+ created_at: '123456',
95
+ updated_at: '987654',
96
+ updatedByApps: {
97
+ slug: 'drive',
98
+ date: '2019-06-11T01:02:03Z'
99
+ }
100
+ },
81
101
  id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
82
102
  links: { self: '/files/b6ff135b34e041ffb2d4a4865f3e0a53' },
83
103
  meta: { rev: '5-87840eceaab358e38aa8b6bb0d4577b1' },
@@ -188,48 +188,6 @@ describe('Store', () => {
188
188
  spy.mockRestore()
189
189
  })
190
190
 
191
- it('should store a new doc received in a mutation result', () => {
192
- store.dispatch(
193
- receiveMutationResult('foo', {
194
- data: [TODO_1]
195
- })
196
- )
197
- expect(
198
- getDocumentFromState(store.getState(), 'io.cozy.todos', TODO_1._id)
199
- ).toEqual(TODO_1)
200
- })
201
-
202
- it('should store an updated doc received in a mutation result', () => {
203
- store.dispatch(
204
- receiveMutationResult('foo', {
205
- data: [TODO_1]
206
- })
207
- )
208
- store.dispatch(
209
- receiveMutationResult('bar', {
210
- data: [{ ...TODO_1, label: 'Buy croissants' }]
211
- })
212
- )
213
- expect(
214
- getDocumentFromState(store.getState(), 'io.cozy.todos', TODO_1._id)
215
- .label
216
- ).toBe('Buy croissants')
217
- })
218
-
219
- it('it should store documents with included from a mutation result', () => {
220
- store.dispatch(
221
- receiveMutationResult('foo', {
222
- data: [...TODO_WITH_RELATION.relationships.attachments.files],
223
- included: [FILE_1, FILE_2]
224
- })
225
- )
226
-
227
- expect(
228
- getDocumentFromState(store.getState(), 'io.cozy.files', FILE_1._id)
229
- .label
230
- ).toBe(FILE_1.label)
231
- })
232
-
233
191
  it('should respect the query limit', () => {
234
192
  const query = new Q({
235
193
  doctype: 'io.cozy.todos',
@@ -307,6 +265,48 @@ describe('Store', () => {
307
265
  ])
308
266
  })
309
267
 
268
+ it('should store a new doc received in a mutation result', () => {
269
+ store.dispatch(
270
+ receiveMutationResult('foo', {
271
+ data: [TODO_1]
272
+ })
273
+ )
274
+ expect(
275
+ getDocumentFromState(store.getState(), 'io.cozy.todos', TODO_1._id)
276
+ ).toEqual(TODO_1)
277
+ })
278
+
279
+ it('should store an updated doc received in a mutation result', () => {
280
+ store.dispatch(
281
+ receiveMutationResult('foo', {
282
+ data: [TODO_1]
283
+ })
284
+ )
285
+ store.dispatch(
286
+ receiveMutationResult('bar', {
287
+ data: [{ ...TODO_1, label: 'Buy croissants' }]
288
+ })
289
+ )
290
+ expect(
291
+ getDocumentFromState(store.getState(), 'io.cozy.todos', TODO_1._id)
292
+ .label
293
+ ).toBe('Buy croissants')
294
+ })
295
+
296
+ it('it should store documents with included from a mutation result', () => {
297
+ store.dispatch(
298
+ receiveMutationResult('foo', {
299
+ data: [...TODO_WITH_RELATION.relationships.attachments.files],
300
+ included: [FILE_1, FILE_2]
301
+ })
302
+ )
303
+
304
+ expect(
305
+ getDocumentFromState(store.getState(), 'io.cozy.files', FILE_1._id)
306
+ .label
307
+ ).toBe(FILE_1.label)
308
+ })
309
+
310
310
  describe('deletion', () => {
311
311
  let originalWarn
312
312
  beforeEach(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "32.0.0",
3
+ "version": "32.2.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": "^32.0.0",
21
+ "cozy-stack-client": "^32.2.0",
22
22
  "json-stable-stringify": "^1.0.1",
23
23
  "lodash": "^4.17.13",
24
24
  "microee": "^0.0.6",
@@ -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": "d289d3676de1de89d0ff38d659c188319e73c16f"
76
+ "gitHead": "16685eb099ddfe814f616ff4d97eee844121c92b"
77
77
  }