cozy-client 60.37.0 → 60.37.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.
package/dist/CozyClient.js
CHANGED
|
@@ -1833,9 +1833,10 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1833
1833
|
while (1) {
|
|
1834
1834
|
switch (_context15.prev = _context15.next) {
|
|
1835
1835
|
case 0:
|
|
1836
|
-
isSingleDoc = !Array.isArray(response.data);
|
|
1836
|
+
isSingleDoc = !Array.isArray(response.data); // A query matching no document resolves with a null `data` or an empty
|
|
1837
|
+
// `data` array, depending on whether it is a single or multiple docs query
|
|
1837
1838
|
|
|
1838
|
-
if (!(!isSingleDoc && response.data.length === 0)) {
|
|
1839
|
+
if (!(isSingleDoc && !response.data || !isSingleDoc && response.data.length === 0)) {
|
|
1839
1840
|
_context15.next = 3;
|
|
1840
1841
|
break;
|
|
1841
1842
|
}
|
|
@@ -3126,7 +3127,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3126
3127
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3127
3128
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3128
3129
|
|
|
3129
|
-
CozyClient.version = "60.37.
|
|
3130
|
+
CozyClient.version = "60.37.1";
|
|
3130
3131
|
|
|
3131
3132
|
_microee.default.mixin(CozyClient);
|
|
3132
3133
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -1296,6 +1296,19 @@ describe('CozyClient', () => {
|
|
|
1296
1296
|
expect(requestHandler.mock.calls[0][0]).toBe(query)
|
|
1297
1297
|
})
|
|
1298
1298
|
|
|
1299
|
+
it('should resolve to a null document when a getById with includes misses', async () => {
|
|
1300
|
+
requestHandler.mockResolvedValueOnce({ data: null })
|
|
1301
|
+
|
|
1302
|
+
const resp = await client.query(
|
|
1303
|
+
Q('io.cozy.todos')
|
|
1304
|
+
.getById('missing')
|
|
1305
|
+
.include(['attachments'])
|
|
1306
|
+
)
|
|
1307
|
+
|
|
1308
|
+
expect(requestHandler).toHaveBeenCalledTimes(1)
|
|
1309
|
+
expect(resp.data).toBeNull()
|
|
1310
|
+
})
|
|
1311
|
+
|
|
1299
1312
|
it('should handle queries with includes', async () => {
|
|
1300
1313
|
requestHandler.mockReturnValueOnce(
|
|
1301
1314
|
Promise.resolve({
|
|
@@ -66,6 +66,7 @@ var attachRelationships = function attachRelationships(response, relationshipsBy
|
|
|
66
66
|
});
|
|
67
67
|
} else {
|
|
68
68
|
var doc = response.data;
|
|
69
|
+
if (!doc) return response;
|
|
69
70
|
return _objectSpread(_objectSpread({}, response), {}, {
|
|
70
71
|
data: attachRelationship(doc, relationshipsByDocId[doc._id])
|
|
71
72
|
});
|
|
@@ -68,6 +68,11 @@ describe('Associations helpers', () => {
|
|
|
68
68
|
})
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
+
it('should leave a missing document untouched', () => {
|
|
72
|
+
const response = { data: null }
|
|
73
|
+
expect(attachRelationships(response, {})).toBe(response)
|
|
74
|
+
})
|
|
75
|
+
|
|
71
76
|
it('should add missing relationships', () => {
|
|
72
77
|
const doc = {
|
|
73
78
|
_id: 1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "60.37.
|
|
3
|
+
"version": "60.37.1",
|
|
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": "
|
|
77
|
+
"gitHead": "a8f098dca99c56f285eaf48199313f064bc68d1c"
|
|
78
78
|
}
|