cozy-client 34.9.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.
@@ -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 = 11;
1285
+ _context8.next = 14;
1273
1286
  break;
1274
1287
  }
1275
1288
 
1276
1289
  if (options.as) {
1277
- _context8.next = 8;
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 8:
1296
+ case 11:
1284
1297
  shouldFetch = options.fetchPolicy(existingQuery);
1285
1298
 
1286
1299
  if (shouldFetch) {
1287
- _context8.next = 11;
1300
+ _context8.next = 14;
1288
1301
  break;
1289
1302
  }
1290
1303
 
1291
1304
  return _context8.abrupt("return");
1292
1305
 
1293
- case 11:
1306
+ case 14:
1294
1307
  if (!(existingQuery && Object.keys(existingQuery).length > 0)) {
1295
- _context8.next = 14;
1308
+ _context8.next = 17;
1296
1309
  break;
1297
1310
  }
1298
1311
 
1299
1312
  if (!(existingQuery.fetchStatus === 'loading')) {
1300
- _context8.next = 14;
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 14:
1321
+ case 17:
1309
1322
  this.ensureQueryExists(queryId, queryDefinition, options);
1310
- _context8.prev = 15;
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 = 20;
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 20:
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 25:
1331
- _context8.prev = 25;
1332
- _context8.t0 = _context8["catch"](15);
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 = 32;
1349
+ _context8.next = 35;
1337
1350
  break;
1338
1351
  }
1339
1352
 
1340
1353
  options.onError(_context8.t0); // defaulted onError
1341
1354
 
1342
- _context8.next = 37;
1355
+ _context8.next = 40;
1343
1356
  break;
1344
1357
 
1345
- case 32:
1358
+ case 35:
1346
1359
  if (!this.options.onError) {
1347
- _context8.next = 36;
1360
+ _context8.next = 39;
1348
1361
  break;
1349
1362
  }
1350
1363
 
1351
1364
  this.options.onError(_context8.t0);
1352
- _context8.next = 37;
1365
+ _context8.next = 40;
1353
1366
  break;
1354
1367
 
1355
- case 36:
1368
+ case 39:
1356
1369
  throw _context8.t0;
1357
1370
 
1358
- case 37:
1371
+ case 40:
1359
1372
  case "end":
1360
1373
  return _context8.stop();
1361
1374
  }
1362
1375
  }
1363
- }, _callee8, this, [[15, 25]]);
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.9.0";
2672
+ CozyClient.version = "34.10.1";
2660
2673
 
2661
2674
  _microee.default.mixin(CozyClient);
2662
2675
 
@@ -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/dist/types.js CHANGED
@@ -255,13 +255,11 @@ var _dsl = require("./queries/dsl");
255
255
 
256
256
  /**
257
257
  * @typedef {object} ClientCapabilities
258
- *
258
+ * @property {boolean} [can_auth_with_oidc] - Whether OIDC login is possible with this Cozy
259
+ * @property {boolean} [can_auth_with_password] - Whether password login is possible with this Cozy
260
+ * @property {boolean} [file_versioning] - Whether file versioning is active on this Cozy
261
+ * @property {boolean} [flat_subdomains] - Whether the stack has been configured to use flat subdomains
259
262
  * @description Read more about client capabilities here https://docs.cozy.io/en/cozy-stack/settings/#get-settingscapabilities.
260
- *
261
- * @property {boolean} can_auth_with_oidc - Whether OIDC login is possible with this Cozy
262
- * @property {boolean} can_auth_with_password - Whether password login is possible with this Cozy
263
- * @property {boolean} file_versioning - Whether file versioning is active on this Cozy
264
- * @property {boolean} flat_subdomains - Whether the stack has been configured to use flat subdomains
265
263
  */
266
264
 
267
265
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "34.9.0",
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": "5a1a67eb9d3b85690f92461e2d67308407d4fb7d"
76
+ "gitHead": "89faf50ec74cf6acd4ea6ca3ff6af67fe6436af7"
77
77
  }
package/types/types.d.ts CHANGED
@@ -335,7 +335,24 @@ export type InAppBrowser = {
335
335
  open: Function;
336
336
  };
337
337
  export type AppMetadata = any;
338
- export type ClientCapabilities = any;
338
+ export type ClientCapabilities = {
339
+ /**
340
+ * - Whether OIDC login is possible with this Cozy
341
+ */
342
+ can_auth_with_oidc?: boolean;
343
+ /**
344
+ * - Whether password login is possible with this Cozy
345
+ */
346
+ can_auth_with_password?: boolean;
347
+ /**
348
+ * - Whether file versioning is active on this Cozy
349
+ */
350
+ file_versioning?: boolean;
351
+ /**
352
+ * - Whether the stack has been configured to use flat subdomains
353
+ */
354
+ flat_subdomains?: boolean;
355
+ };
339
356
  export type Cordova = {
340
357
  file: FilePlugin;
341
358
  InAppBrowser: InAppBrowser;