cozy-client 34.10.0 → 34.10.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 +36 -23
- package/dist/CozyClient.spec.js +5 -1
- package/package.json +2 -2
package/dist/CozyClient.js
CHANGED
|
@@ -1268,36 +1268,49 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1268
1268
|
queryId = options.as || this.queryIdGenerator.generateId(queryDefinition);
|
|
1269
1269
|
existingQuery = this.getQueryFromState(queryId, options);
|
|
1270
1270
|
|
|
1271
|
+
if (!(options.enabled !== undefined)) {
|
|
1272
|
+
_context8.next = 8;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
if (!('boolean' !== typeof options.enabled)) {
|
|
1277
|
+
_context8.next = 8;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
throw new Error("option.enabled should be a boolean for this query: ".concat(JSON.stringify(queryDefinition)));
|
|
1282
|
+
|
|
1283
|
+
case 8:
|
|
1271
1284
|
if (!options.fetchPolicy) {
|
|
1272
|
-
_context8.next =
|
|
1285
|
+
_context8.next = 14;
|
|
1273
1286
|
break;
|
|
1274
1287
|
}
|
|
1275
1288
|
|
|
1276
1289
|
if (options.as) {
|
|
1277
|
-
_context8.next =
|
|
1290
|
+
_context8.next = 11;
|
|
1278
1291
|
break;
|
|
1279
1292
|
}
|
|
1280
1293
|
|
|
1281
1294
|
throw new Error('Cannot use `fetchPolicy` without naming the query, please use `as` to name the query');
|
|
1282
1295
|
|
|
1283
|
-
case
|
|
1296
|
+
case 11:
|
|
1284
1297
|
shouldFetch = options.fetchPolicy(existingQuery);
|
|
1285
1298
|
|
|
1286
1299
|
if (shouldFetch) {
|
|
1287
|
-
_context8.next =
|
|
1300
|
+
_context8.next = 14;
|
|
1288
1301
|
break;
|
|
1289
1302
|
}
|
|
1290
1303
|
|
|
1291
1304
|
return _context8.abrupt("return");
|
|
1292
1305
|
|
|
1293
|
-
case
|
|
1306
|
+
case 14:
|
|
1294
1307
|
if (!(existingQuery && Object.keys(existingQuery).length > 0)) {
|
|
1295
|
-
_context8.next =
|
|
1308
|
+
_context8.next = 17;
|
|
1296
1309
|
break;
|
|
1297
1310
|
}
|
|
1298
1311
|
|
|
1299
1312
|
if (!(existingQuery.fetchStatus === 'loading')) {
|
|
1300
|
-
_context8.next =
|
|
1313
|
+
_context8.next = 17;
|
|
1301
1314
|
break;
|
|
1302
1315
|
}
|
|
1303
1316
|
|
|
@@ -1305,21 +1318,21 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1305
1318
|
return (0, _jsonStableStringify.default)(queryDefinition);
|
|
1306
1319
|
}));
|
|
1307
1320
|
|
|
1308
|
-
case
|
|
1321
|
+
case 17:
|
|
1309
1322
|
this.ensureQueryExists(queryId, queryDefinition, options);
|
|
1310
|
-
_context8.prev =
|
|
1323
|
+
_context8.prev = 18;
|
|
1311
1324
|
backgroundFetching = options.backgroundFetching !== undefined ? options.backgroundFetching : this.options.backgroundFetching;
|
|
1312
1325
|
this.dispatch((0, _store.loadQuery)(queryId, {
|
|
1313
1326
|
backgroundFetching: backgroundFetching
|
|
1314
1327
|
}));
|
|
1315
|
-
_context8.next =
|
|
1328
|
+
_context8.next = 23;
|
|
1316
1329
|
return this._promiseCache.exec(function () {
|
|
1317
1330
|
return _this4.requestQuery(queryDefinition);
|
|
1318
1331
|
}, function () {
|
|
1319
1332
|
return (0, _jsonStableStringify.default)(queryDefinition);
|
|
1320
1333
|
});
|
|
1321
1334
|
|
|
1322
|
-
case
|
|
1335
|
+
case 23:
|
|
1323
1336
|
response = _context8.sent;
|
|
1324
1337
|
this.dispatch((0, _store.receiveQueryResult)(queryId, response, {
|
|
1325
1338
|
update: update,
|
|
@@ -1327,40 +1340,40 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1327
1340
|
}));
|
|
1328
1341
|
return _context8.abrupt("return", response);
|
|
1329
1342
|
|
|
1330
|
-
case
|
|
1331
|
-
_context8.prev =
|
|
1332
|
-
_context8.t0 = _context8["catch"](
|
|
1343
|
+
case 28:
|
|
1344
|
+
_context8.prev = 28;
|
|
1345
|
+
_context8.t0 = _context8["catch"](18);
|
|
1333
1346
|
this.dispatch((0, _store.receiveQueryError)(queryId, _context8.t0)); // specific onError
|
|
1334
1347
|
|
|
1335
1348
|
if (!options.onError) {
|
|
1336
|
-
_context8.next =
|
|
1349
|
+
_context8.next = 35;
|
|
1337
1350
|
break;
|
|
1338
1351
|
}
|
|
1339
1352
|
|
|
1340
1353
|
options.onError(_context8.t0); // defaulted onError
|
|
1341
1354
|
|
|
1342
|
-
_context8.next =
|
|
1355
|
+
_context8.next = 40;
|
|
1343
1356
|
break;
|
|
1344
1357
|
|
|
1345
|
-
case
|
|
1358
|
+
case 35:
|
|
1346
1359
|
if (!this.options.onError) {
|
|
1347
|
-
_context8.next =
|
|
1360
|
+
_context8.next = 39;
|
|
1348
1361
|
break;
|
|
1349
1362
|
}
|
|
1350
1363
|
|
|
1351
1364
|
this.options.onError(_context8.t0);
|
|
1352
|
-
_context8.next =
|
|
1365
|
+
_context8.next = 40;
|
|
1353
1366
|
break;
|
|
1354
1367
|
|
|
1355
|
-
case
|
|
1368
|
+
case 39:
|
|
1356
1369
|
throw _context8.t0;
|
|
1357
1370
|
|
|
1358
|
-
case
|
|
1371
|
+
case 40:
|
|
1359
1372
|
case "end":
|
|
1360
1373
|
return _context8.stop();
|
|
1361
1374
|
}
|
|
1362
1375
|
}
|
|
1363
|
-
}, _callee8, this, [[
|
|
1376
|
+
}, _callee8, this, [[18, 28]]);
|
|
1364
1377
|
}));
|
|
1365
1378
|
|
|
1366
1379
|
function query(_x9) {
|
|
@@ -2656,7 +2669,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2656
2669
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2657
2670
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2658
2671
|
|
|
2659
|
-
CozyClient.version = "34.10.
|
|
2672
|
+
CozyClient.version = "34.10.1";
|
|
2660
2673
|
|
|
2661
2674
|
_microee.default.mixin(CozyClient);
|
|
2662
2675
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -1195,7 +1195,11 @@ describe('CozyClient', () => {
|
|
|
1195
1195
|
query = Q('io.cozy.todos')
|
|
1196
1196
|
fakeResponse = { data: 'FAKE!!!' }
|
|
1197
1197
|
})
|
|
1198
|
-
|
|
1198
|
+
it('should throw an error if the option.enabled is not a boolean', async () => {
|
|
1199
|
+
await expect(
|
|
1200
|
+
client.query(query, { as: 'allTodos', enabled: '' })
|
|
1201
|
+
).rejects.toThrow()
|
|
1202
|
+
})
|
|
1199
1203
|
it('should first dispatch a INIT_QUERY action', async () => {
|
|
1200
1204
|
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1201
1205
|
await client.query(query, { as: 'allTodos' })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "34.10.
|
|
3
|
+
"version": "34.10.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -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": "
|
|
76
|
+
"gitHead": "89faf50ec74cf6acd4ea6ca3ff6af67fe6436af7"
|
|
77
77
|
}
|