cozy-client 32.7.1 → 32.7.4

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.
@@ -102,7 +102,8 @@ var ensureArray = function ensureArray(arr) {
102
102
  var deprecatedHandler = function deprecatedHandler(msg) {
103
103
  return {
104
104
  get: function get(target, prop) {
105
- console.warn(msg);
105
+ _logger.default.warn(msg);
106
+
106
107
  return target[prop];
107
108
  }
108
109
  };
@@ -232,7 +233,7 @@ var CozyClient = /*#__PURE__*/function () {
232
233
  _options = (0, _objectWithoutProperties2.default)(rawOptions, ["link", "links", "schema", "appMetadata", "capabilities"]);
233
234
 
234
235
  if (link) {
235
- console.warn('`link` is deprecated, use `links`');
236
+ _logger.default.warn('`link` is deprecated, use `links`');
236
237
  }
237
238
 
238
239
  this.appMetadata = appMetadata;
@@ -402,7 +403,7 @@ var CozyClient = /*#__PURE__*/function () {
402
403
  try {
403
404
  link.registerClient(this);
404
405
  } catch (e) {
405
- console.warn(e);
406
+ _logger.default.warn(e);
406
407
  }
407
408
  }
408
409
  }
@@ -437,7 +438,8 @@ var CozyClient = /*#__PURE__*/function () {
437
438
  // This allows us to autoLogin in constructor without breaking any compatibility
438
439
  // with codes that uses an explicit login.
439
440
  if (this.isLogged && !this.isRevoked) {
440
- console.warn("CozyClient is already logged.");
441
+ _logger.default.warn("CozyClient is already logged.");
442
+
441
443
  return this.loginPromise;
442
444
  }
443
445
 
@@ -636,7 +638,8 @@ var CozyClient = /*#__PURE__*/function () {
636
638
  case 36:
637
639
  _context3.prev = 36;
638
640
  _context3.t2 = _context3["catch"](31);
639
- console.warn(_context3.t2);
641
+
642
+ _logger.default.warn(_context3.t2);
640
643
 
641
644
  case 39:
642
645
  _context3.next = 28;
@@ -710,7 +713,9 @@ var CozyClient = /*#__PURE__*/function () {
710
713
  key: "find",
711
714
  value: function find(doctype) {
712
715
  var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
713
- console.warn('client.find(doctype, selector) is deprecated, please use Q(doctype).where(selector) to build the same query.');
716
+
717
+ _logger.default.warn('client.find(doctype, selector) is deprecated, please use Q(doctype).where(selector) to build the same query.');
718
+
714
719
  return new _dsl.QueryDefinition({
715
720
  doctype: doctype,
716
721
  selector: selector
@@ -719,7 +724,8 @@ var CozyClient = /*#__PURE__*/function () {
719
724
  }, {
720
725
  key: "get",
721
726
  value: function get(doctype, id) {
722
- console.warn("client.get(".concat(doctype, ", id) is deprecated, please use Q(").concat(doctype, ").getById(id) to build the same query."));
727
+ _logger.default.warn("client.get(".concat(doctype, ", id) is deprecated, please use Q(").concat(doctype, ").getById(id) to build the same query."));
728
+
723
729
  return new _dsl.QueryDefinition({
724
730
  doctype: doctype,
725
731
  id: id
@@ -931,7 +937,8 @@ var CozyClient = /*#__PURE__*/function () {
931
937
  break;
932
938
  }
933
939
 
934
- console.warn('There has been some validation errors while bulk saving', errors);
940
+ _logger.default.warn('There has been some validation errors while bulk saving', errors);
941
+
935
942
  throw new Error('Validation failed for at least one doc');
936
943
 
937
944
  case 11:
@@ -1438,7 +1445,8 @@ var CozyClient = /*#__PURE__*/function () {
1438
1445
  }, {
1439
1446
  key: "watchQuery",
1440
1447
  value: function watchQuery() {
1441
- console.warn('client.watchQuery is deprecated, please use client.makeObservableQuery.');
1448
+ _logger.default.warn('client.watchQuery is deprecated, please use client.makeObservableQuery.');
1449
+
1442
1450
  return this.makeObservableQuery.apply(this, arguments);
1443
1451
  }
1444
1452
  }, {
@@ -1936,7 +1944,8 @@ var CozyClient = /*#__PURE__*/function () {
1936
1944
  data: isSingleDocQuery && singleDocData ? data[0] : data
1937
1945
  });
1938
1946
  } catch (e) {
1939
- console.warn("Could not get query from state. queryId: ".concat(id, ", error: ").concat(e.message));
1947
+ _logger.default.warn("Could not get query from state. queryId: ".concat(id, ", error: ").concat(e.message));
1948
+
1940
1949
  return null;
1941
1950
  }
1942
1951
  }
@@ -2275,7 +2284,7 @@ var CozyClient = /*#__PURE__*/function () {
2275
2284
  key: "createClient",
2276
2285
  value: function createClient() {
2277
2286
  if (this.options.client) {
2278
- console.warn('CozyClient: Using options.client is deprecated, please use options.stackClient.');
2287
+ _logger.default.warn('CozyClient: Using options.client is deprecated, please use options.stackClient.');
2279
2288
  }
2280
2289
 
2281
2290
  var warningForCustomHandlers = this.options.warningForCustomHandlers !== undefined ? this.options.warningForCustomHandlers : true;
@@ -2299,7 +2308,7 @@ var CozyClient = /*#__PURE__*/function () {
2299
2308
  stackClient.options[handlerName] = handlers[handlerName];
2300
2309
  } else {
2301
2310
  if (warningForCustomHandlers) {
2302
- console.warn("You passed a stackClient with its own ".concat(handlerName, ". It is not supported, unexpected things might happen."));
2311
+ _logger.default.warn("You passed a stackClient with its own ".concat(handlerName, ". It is not supported, unexpected things might happen."));
2303
2312
  }
2304
2313
  }
2305
2314
  }
@@ -2314,7 +2323,8 @@ var CozyClient = /*#__PURE__*/function () {
2314
2323
  }, {
2315
2324
  key: "getClient",
2316
2325
  value: function getClient() {
2317
- console.warn('CozyClient: getClient() is deprecated, please use getStackClient().');
2326
+ _logger.default.warn('CozyClient: getClient() is deprecated, please use getStackClient().');
2327
+
2318
2328
  return this.getStackClient();
2319
2329
  }
2320
2330
  }, {
@@ -2571,7 +2581,7 @@ var CozyClient = /*#__PURE__*/function () {
2571
2581
  CozyClient.hooks = CozyClient.hooks || {};
2572
2582
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2573
2583
 
2574
- CozyClient.version = "32.7.1";
2584
+ CozyClient.version = "32.7.4";
2575
2585
 
2576
2586
  _microee.default.mixin(CozyClient);
2577
2587
 
@@ -34,7 +34,7 @@ import {
34
34
  import { HasManyFiles, Association, HasMany } from './associations'
35
35
  import mapValues from 'lodash/mapValues'
36
36
  import FileCollection from 'cozy-stack-client/dist/FileCollection'
37
-
37
+ import logger from './logger'
38
38
  const normalizeData = data =>
39
39
  mapValues(data, (docs, doctype) => {
40
40
  return docs.map(doc => ({
@@ -86,10 +86,10 @@ describe('CozyClient initialization', () => {
86
86
 
87
87
  describe('explicit login', () => {
88
88
  beforeEach(() => {
89
- jest.spyOn(console, 'warn').mockImplementation(() => {})
89
+ jest.spyOn(logger, 'warn').mockImplementation(() => {})
90
90
  })
91
91
  afterEach(() => {
92
- console.warn.mockRestore()
92
+ logger.warn.mockRestore()
93
93
  })
94
94
 
95
95
  it('should not break explicit login when provided token and uri', () => {
@@ -380,22 +380,22 @@ describe('CozyClient initialization', () => {
380
380
  })
381
381
 
382
382
  it('should create a store when calling makeObservableQuery', () => {
383
- jest.spyOn(console, 'warn').mockImplementation(() => {})
383
+ jest.spyOn(logger, 'warn').mockImplementation(() => {})
384
384
  client.makeObservableQuery(
385
385
  new QueryDefinition({ doctype: 'io.cozy.todos' })
386
386
  )
387
- console.warn.mockRestore()
387
+ logger.warn.mockRestore()
388
388
  expect(client.store).not.toBe(undefined)
389
389
  })
390
390
  })
391
391
 
392
392
  describe('Stack client initialization', () => {
393
393
  beforeEach(() => {
394
- jest.spyOn(console, 'warn').mockImplementation(() => {})
394
+ jest.spyOn(logger, 'warn').mockImplementation(() => {})
395
395
  })
396
396
 
397
397
  afterEach(() => {
398
- console.warn.mockRestore()
398
+ logger.warn.mockRestore()
399
399
  })
400
400
 
401
401
  it('should add default callbacks', async () => {
@@ -444,13 +444,13 @@ describe('CozyClient handlers', () => {
444
444
  })
445
445
 
446
446
  it('should warn when overriding default handlers', () => {
447
- jest.spyOn(console, 'warn').mockImplementation(() => {})
447
+ jest.spyOn(logger, 'warn').mockImplementation(() => {})
448
448
  new CozyClient({
449
449
  stackClient: new CozyStackClient({
450
450
  onRevocationChange: () => {}
451
451
  })
452
452
  })
453
- expect(console.warn).toHaveBeenCalledWith(
453
+ expect(logger.warn).toHaveBeenCalledWith(
454
454
  'You passed a stackClient with its own onRevocationChange. It is not supported, unexpected things might happen.'
455
455
  )
456
456
  })
@@ -501,23 +501,21 @@ describe('CozyClient logout', () => {
501
501
  expect(links[2].reset).toHaveBeenCalledTimes(1)
502
502
 
503
503
  // test if we launch twice logout, it doesn't launch twice reset.
504
- jest.spyOn(console, 'warn').mockImplementation(() => {})
504
+ jest.spyOn(logger, 'warn').mockImplementation(() => {})
505
505
  await client.logout()
506
- console.warn.mockRestore()
506
+ logger.warn.mockRestore()
507
507
 
508
508
  expect(links[0].reset).toHaveBeenCalledTimes(1)
509
509
  expect(links[2].reset).toHaveBeenCalledTimes(1)
510
510
  })
511
511
 
512
512
  it('should call all reset even if a reset throws an error', async () => {
513
- const spy = jest.spyOn(global.console, 'warn').mockReturnValue(jest.fn())
514
513
  links[0].reset = jest.fn().mockRejectedValue(new Error('Async error'))
515
514
  links[2].reset = jest.fn()
516
515
  await client.login()
517
516
  await client.logout()
518
517
  expect(links[0].reset).toHaveBeenCalledTimes(1)
519
518
  expect(links[2].reset).toHaveBeenCalledTimes(1)
520
- spy.mockRestore()
521
519
  })
522
520
 
523
521
  it('should emit events', async () => {
package/dist/StackLink.js CHANGED
@@ -25,6 +25,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
25
25
 
26
26
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
27
 
28
+ var _zipWith = _interopRequireDefault(require("lodash/zipWith"));
29
+
28
30
  var _dsl = require("./queries/dsl");
29
31
 
30
32
  var _CozyLink2 = _interopRequireDefault(require("./CozyLink"));
@@ -35,7 +37,7 @@ var _const = require("./const");
35
37
 
36
38
  var _errors = require("./errors");
37
39
 
38
- var _zipWith = _interopRequireDefault(require("lodash/zipWith"));
40
+ var _logger = _interopRequireDefault(require("./logger"));
39
41
 
40
42
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
41
43
 
@@ -45,6 +47,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
45
47
 
46
48
  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; }
47
49
 
50
+ /**
51
+ *
52
+ * To know if cozy-client should use Document.find()
53
+ * or Document.all()
54
+ * Similar to what is done in CozyPouchLink executeQuery()
55
+ *
56
+ * @param {QueryDefinition} queryDefinition - QueryDefinition to check
57
+ * @returns {boolean} If has find options
58
+ *
59
+ */
60
+ var hasFindOptions = function hasFindOptions(queryDefinition) {
61
+ var selector = queryDefinition.selector,
62
+ partialFilter = queryDefinition.partialFilter,
63
+ sort = queryDefinition.sort,
64
+ fields = queryDefinition.fields;
65
+ if (selector || partialFilter || sort || fields) return true;
66
+ return false;
67
+ };
48
68
  /**
49
69
  * Returns full documents after a bulk update
50
70
  *
@@ -54,6 +74,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
54
74
  * @param {CozyClientDocument[]} originalDocuments - Documents that were updated
55
75
  * @returns {{ data: CozyClientDocument[] }} - Full documents with updated _id and _rev
56
76
  */
77
+
78
+
57
79
  var transformBulkDocsResponse = function transformBulkDocsResponse(bulkResponse, originalDocuments) {
58
80
  var updatedDocs = (0, _zipWith.default)(bulkResponse, originalDocuments, function (result, od) {
59
81
  return result.ok ? _objectSpread(_objectSpread({}, od), {}, {
@@ -100,7 +122,7 @@ var StackLink = /*#__PURE__*/function (_CozyLink) {
100
122
  _this = _super.call(this);
101
123
 
102
124
  if (client) {
103
- console.warn('Using options.client is deprecated, prefer options.stackClient');
125
+ _logger.default.warn('Using options.client is deprecated, prefer options.stackClient');
104
126
  }
105
127
 
106
128
  _this.stackClient = stackClient || client;
@@ -126,6 +148,12 @@ var StackLink = /*#__PURE__*/function (_CozyLink) {
126
148
 
127
149
  return this.executeQuery(operation);
128
150
  }
151
+ /**
152
+ *
153
+ * @param {QueryDefinition} query - Query to execute
154
+ * @returns {Promise<ClientResponse>}
155
+ */
156
+
129
157
  }, {
130
158
  key: "executeQuery",
131
159
  value: function executeQuery(query) {
@@ -137,7 +165,8 @@ var StackLink = /*#__PURE__*/function (_CozyLink) {
137
165
  options = (0, _objectWithoutProperties2.default)(query, ["doctype", "selector", "id", "ids", "referenced"]);
138
166
 
139
167
  if (!doctype) {
140
- console.warn('Bad query', query);
168
+ _logger.default.warn('Bad query', query);
169
+
141
170
  throw new Error('No doctype found in a query definition');
142
171
  }
143
172
 
@@ -155,7 +184,11 @@ var StackLink = /*#__PURE__*/function (_CozyLink) {
155
184
  return collection.findReferencedBy(referenced, options);
156
185
  }
157
186
 
158
- return !selector && !options.sort ? collection.all(options) : collection.find(selector, options);
187
+ if (hasFindOptions(query)) {
188
+ return collection.find(selector, options);
189
+ } else {
190
+ return collection.all(options);
191
+ }
159
192
  }
160
193
  }, {
161
194
  key: "executeMutation",
@@ -46,6 +46,22 @@ describe('StackLink', () => {
46
46
  expect(stackClient.collection().all).toHaveBeenCalled()
47
47
  expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos')
48
48
  })
49
+
50
+ it('should use find if a partialFilter is given', async () => {
51
+ const query = Q('io.cozy.todos').partialIndex({ trashed: false })
52
+ stackClient.collection().find.mockReset()
53
+ await link.request(query)
54
+ expect(stackClient.collection().find).toHaveBeenCalled()
55
+ expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos')
56
+ })
57
+
58
+ it('should use find if fields are given', async () => {
59
+ const query = Q('io.cozy.todos').select(['trashed'])
60
+ stackClient.collection().find.mockReset()
61
+ await link.request(query)
62
+ expect(stackClient.collection().find).toHaveBeenCalled()
63
+ expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos')
64
+ })
49
65
  })
50
66
 
51
67
  describe('reset', () => {
@@ -35,6 +35,8 @@ var _types = require("../types");
35
35
 
36
36
  var _Association2 = _interopRequireDefault(require("./Association"));
37
37
 
38
+ var _logger = _interopRequireDefault(require("../logger"));
39
+
38
40
  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; }
39
41
 
40
42
  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; }
@@ -280,7 +282,7 @@ var HasMany = /*#__PURE__*/function (_Association) {
280
282
 
281
283
  if (!relationship) {
282
284
  if (rawData && rawData.length) {
283
- console.warn("You're trying to access data on a relationship that appear to not be loaded yet. You may want to use 'include()' on your query");
285
+ _logger.default.warn("You're trying to access data on a relationship that appear to not be loaded yet. You may want to use 'include()' on your query");
284
286
  }
285
287
 
286
288
  return empty();
@@ -29,6 +29,8 @@ var _types = require("../types");
29
29
 
30
30
  var _Association2 = _interopRequireDefault(require("./Association"));
31
31
 
32
+ var _logger = _interopRequireDefault(require("../logger"));
33
+
32
34
  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; }
33
35
 
34
36
  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; }
@@ -93,13 +95,15 @@ var HasOne = /*#__PURE__*/function (_Association) {
93
95
  }, {
94
96
  key: "set",
95
97
  value: function set(doc) {
96
- console.warn('set is deprecated for has-one relationships. Use `add` instead.');
98
+ _logger.default.warn('set is deprecated for has-one relationships. Use `add` instead.');
99
+
97
100
  this.setRelationship(doc);
98
101
  }
99
102
  }, {
100
103
  key: "unset",
101
104
  value: function unset() {
102
- console.warn('unset is deprecated for has-one relationships. Use `remove` instead.');
105
+ _logger.default.warn('unset is deprecated for has-one relationships. Use `remove` instead.');
106
+
103
107
  this.setRelationship(undefined);
104
108
  }
105
109
  }, {
package/dist/cli/index.js CHANGED
@@ -190,7 +190,8 @@ var readJSON = function readJSON(fs, filename) {
190
190
  var res = JSON.parse(fs.readFileSync(filename).toString());
191
191
  return res;
192
192
  } catch (e) {
193
- console.warn("Could not load ".concat(filename, " (").concat(e.message, ")"));
193
+ _cozyLogger.default.warn("Could not load ".concat(filename, " (").concat(e.message, ")"));
194
+
194
195
  return null;
195
196
  }
196
197
  };
package/dist/hoc.js CHANGED
@@ -25,6 +25,8 @@ var _useClient = _interopRequireDefault(require("./hooks/useClient"));
25
25
 
26
26
  var _useQuery = require("./hooks/useQuery");
27
27
 
28
+ var _logger = _interopRequireDefault(require("./logger"));
29
+
28
30
  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; }
29
31
 
30
32
  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; }
@@ -67,7 +69,8 @@ var withQuery = function withQuery(dest, queryOpts, Original) {
67
69
  var queryOptsRes = typeof queryOpts === 'function' ? queryOpts(props) : queryOpts;
68
70
 
69
71
  if (queryOpts.doc) {
70
- console.warn('queryOpts.doc is deprecated');
72
+ _logger.default.warn('queryOpts.doc is deprecated');
73
+
71
74
  return /*#__PURE__*/_react.default.createElement(Component, _objectSpread((0, _defineProperty2.default)({}, dest, queryOptsRes.doc), props));
72
75
  }
73
76
 
package/dist/hoc.spec.jsx CHANGED
@@ -5,17 +5,17 @@ import { mount } from 'enzyme'
5
5
  import { withClient, queryConnect, queryConnectFlat } from './hoc'
6
6
  import { Q } from './queries/dsl'
7
7
  import Provider from './Provider'
8
-
8
+ import logger from './logger'
9
9
  // At some point __tests__/mocks and testing/utils shall be reconciled
10
10
  import * as mocks from './__tests__/mocks'
11
11
  import { setupClient } from './testing/utils'
12
12
 
13
13
  beforeEach(() => {
14
- jest.spyOn(console, 'warn').mockImplementation(() => {})
14
+ jest.spyOn(logger, 'warn').mockImplementation(() => {})
15
15
  })
16
16
 
17
17
  afterEach(() => {
18
- console.warn.mockRestore()
18
+ logger.warn.mockRestore()
19
19
  })
20
20
 
21
21
  class Component extends React.Component {
@@ -22,6 +22,7 @@ var _exportNames = {
22
22
  HasOneInPlace: true,
23
23
  HasManyInPlace: true,
24
24
  HasManyTriggers: true,
25
+ deconstructCozyWebLinkWithSlug: true,
25
26
  dehydrate: true,
26
27
  generateWebLink: true,
27
28
  rootCozyUrl: true,
@@ -124,6 +125,12 @@ Object.defineProperty(exports, "HasManyTriggers", {
124
125
  return _associations.HasManyTriggers;
125
126
  }
126
127
  });
128
+ Object.defineProperty(exports, "deconstructCozyWebLinkWithSlug", {
129
+ enumerable: true,
130
+ get: function get() {
131
+ return _helpers.deconstructCozyWebLinkWithSlug;
132
+ }
133
+ });
127
134
  Object.defineProperty(exports, "dehydrate", {
128
135
  enumerable: true,
129
136
  get: function get() {
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -18,4 +20,6 @@ Object.defineProperty(exports, "muteError", {
18
20
 
19
21
  var _account = require("./account");
20
22
 
21
- console.warn('models/accounts is deprecated in cozy-client, please use models/account instead');
23
+ var _logger = _interopRequireDefault(require("../logger"));
24
+
25
+ _logger.default.warn('models/accounts is deprecated in cozy-client, please use models/account instead');
@@ -11,6 +11,8 @@ var _get = _interopRequireDefault(require("lodash/get"));
11
11
 
12
12
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
13
13
 
14
+ var _logger = _interopRequireDefault(require("../logger"));
15
+
14
16
  var getPrimaryOrFirst = function getPrimaryOrFirst(property) {
15
17
  return function (obj) {
16
18
  return !obj[property] || obj[property].length === 0 ? '' : obj[property].find(function (property) {
@@ -253,7 +255,8 @@ var getDefaultSortIndexValue = function getDefaultSortIndexValue(contact) {
253
255
  exports.getDefaultSortIndexValue = getDefaultSortIndexValue;
254
256
 
255
257
  var getIndexByFamilyNameGivenNameEmailCozyUrl = function getIndexByFamilyNameGivenNameEmailCozyUrl(contact) {
256
- console.warn('Deprecation: `getIndexByFamilyNameGivenNameEmailCozyUrl` is deprecated, please use `getDefaultSortIndexValue` instead');
258
+ _logger.default.warn('Deprecation: `getIndexByFamilyNameGivenNameEmailCozyUrl` is deprecated, please use `getDefaultSortIndexValue` instead');
259
+
257
260
  return getDefaultSortIndexValue(contact);
258
261
  };
259
262
 
@@ -19,6 +19,8 @@ var _lodash = require("lodash");
19
19
 
20
20
  var qualificationModel = _interopRequireWildcard(require("../../assets/qualifications.json"));
21
21
 
22
+ var _logger = _interopRequireDefault(require("../../logger"));
23
+
22
24
  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; }
23
25
 
24
26
  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; }
@@ -93,7 +95,7 @@ var Qualification = /*#__PURE__*/function () {
93
95
  var isKnownValue = qualificationModel.purposeKnownValues.includes(attributes.purpose);
94
96
 
95
97
  if (!isKnownValue) {
96
- console.info("This purpose is not listed among the known values: ".concat(attributes.purpose, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
98
+ _logger.default.info("This purpose is not listed among the known values: ".concat(attributes.purpose, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
97
99
  }
98
100
  } else {
99
101
  throw new Error("The purpose for the label ".concat(this.label, " should be ").concat(this.purpose, ". ") + "Please use this or open an issue on https://github.com/cozy/cozy-client/issues");
@@ -105,7 +107,7 @@ var Qualification = /*#__PURE__*/function () {
105
107
  var _isKnownValue = qualificationModel.sourceCategoryKnownValues.includes(attributes.sourceCategory);
106
108
 
107
109
  if (!_isKnownValue) {
108
- console.info("This sourceCategory is not listed among the known values: ".concat(attributes.sourceCategory, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
110
+ _logger.default.info("This sourceCategory is not listed among the known values: ".concat(attributes.sourceCategory, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
109
111
  }
110
112
  } else {
111
113
  throw new Error("The sourceCategory for the label ".concat(this.label, " should be ").concat(this.sourceCategory, ". ") + "Please use this or open an issue on https://github.com/cozy/cozy-client/issues");
@@ -117,7 +119,7 @@ var Qualification = /*#__PURE__*/function () {
117
119
  var _isKnownValue2 = qualificationModel.sourceSubCategoryKnownValues.includes(attributes.sourceSubCategory);
118
120
 
119
121
  if (!_isKnownValue2) {
120
- console.info("This sourceSubCategory is not listed among the known values: ".concat(attributes.sourceSubCategory, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
122
+ _logger.default.info("This sourceSubCategory is not listed among the known values: ".concat(attributes.sourceSubCategory, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
121
123
  }
122
124
  } else {
123
125
  throw new Error("The sourceSubCategory for the label ".concat(this.label, " should be ").concat(this.sourceSubCategory, ". ") + "Please use this or open an issue on https://github.com/cozy/cozy-client/issues");
@@ -134,7 +136,7 @@ var Qualification = /*#__PURE__*/function () {
134
136
 
135
137
  if (extraSubjects.length > 0) {
136
138
  var unknownSubjects = (0, _lodash.difference)(extraSubjects, qualificationModel.subjectsKnownValues);
137
- if (unknownSubjects.length > 0) console.info("These subjects are not listed among the known values: ".concat(unknownSubjects, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
139
+ if (unknownSubjects.length > 0) _logger.default.info("These subjects are not listed among the known values: ".concat(unknownSubjects, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
138
140
  }
139
141
  }
140
142
  /**
@@ -4,16 +4,17 @@ import {
4
4
  getQualification
5
5
  } from './qualification'
6
6
  import * as qualificationModel from '../../assets/qualifications.json'
7
+ import logger from '../../logger'
7
8
 
8
9
  describe('document qualification', () => {
9
10
  beforeEach(() => {
10
- jest.spyOn(console, 'warn').mockImplementation(() => jest.fn())
11
- jest.spyOn(console, 'info').mockImplementation(() => jest.fn())
11
+ jest.spyOn(logger, 'warn').mockImplementation(() => jest.fn())
12
+ jest.spyOn(logger, 'info').mockImplementation(() => jest.fn())
12
13
  })
13
14
 
14
15
  afterEach(() => {
15
- console.warn.mockRestore()
16
- console.info.mockRestore()
16
+ logger.warn.mockRestore()
17
+ logger.info.mockRestore()
17
18
  })
18
19
 
19
20
  it('should get the correct qualification by the label', () => {
@@ -112,7 +113,7 @@ describe('document qualification', () => {
112
113
  subjects: ['very_hard_drugs']
113
114
  }
114
115
  setQualification({}, qualification)
115
- expect(console.info).toHaveBeenCalledTimes(1)
116
+ expect(logger.info).toHaveBeenCalledTimes(1)
116
117
  })
117
118
  })
118
119
  describe('qualifications items', () => {
@@ -34,6 +34,8 @@ var _const = require("../const");
34
34
 
35
35
  var _CozyClient = _interopRequireDefault(require("../CozyClient"));
36
36
 
37
+ var _logger = _interopRequireDefault(require("../logger"));
38
+
37
39
  function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
38
40
 
39
41
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -281,7 +283,8 @@ var isSharingShortcut = function isSharingShortcut(file) {
281
283
  exports.isSharingShortcut = isSharingShortcut;
282
284
 
283
285
  var isSharingShorcut = function isSharingShorcut(file) {
284
- console.warn('Deprecation: `isSharingShorcut` is deprecated, please use `isSharingShortcut` instead');
286
+ _logger.default.warn('Deprecation: `isSharingShorcut` is deprecated, please use `isSharingShortcut` instead');
287
+
285
288
  return isSharingShortcut(file);
286
289
  };
287
290
  /**
@@ -311,7 +314,8 @@ var isSharingShortcutNew = function isSharingShortcutNew(file) {
311
314
  exports.isSharingShortcutNew = isSharingShortcutNew;
312
315
 
313
316
  var isSharingShorcutNew = function isSharingShorcutNew(file) {
314
- console.warn('Deprecation: `isSharingShorcutNew` is deprecated, please use `isSharingShortcutNew` instead');
317
+ _logger.default.warn('Deprecation: `isSharingShorcutNew` is deprecated, please use `isSharingShortcutNew` instead');
318
+
315
319
  return isSharingShortcutNew(file);
316
320
  };
317
321
  /**
@@ -13,6 +13,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
13
13
 
14
14
  var _helpers = require("../helpers");
15
15
 
16
+ var _logger = _interopRequireDefault(require("../logger"));
17
+
16
18
  /**
17
19
  *
18
20
  * @param {string} notesAppUrl URL to the Notes App (https://notes.foo.mycozy.cloud)
@@ -34,7 +36,8 @@ var generatePrivateUrl = function generatePrivateUrl(notesAppUrl, file) {
34
36
  exports.generatePrivateUrl = generatePrivateUrl;
35
37
 
36
38
  var generateUrlForNote = function generateUrlForNote(notesAppUrl, file) {
37
- console.warn('generateUrlForNote is deprecated. Please use models.note.generatePrivateUrl instead');
39
+ _logger.default.warn('generateUrlForNote is deprecated. Please use models.note.generatePrivateUrl instead');
40
+
38
41
  return generatePrivateUrl(notesAppUrl, file);
39
42
  };
40
43
  /**
@@ -31,6 +31,8 @@ var _file = require("./file");
31
31
 
32
32
  var _const = require("../const");
33
33
 
34
+ var _logger = _interopRequireDefault(require("../logger"));
35
+
34
36
  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; }
35
37
 
36
38
  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; }
@@ -397,7 +399,8 @@ function _isDocumentReadOnly() {
397
399
  }));
398
400
 
399
401
  case 24:
400
- console.warn("can't find the document in current attached permissions");
402
+ _logger.default.warn("can't find the document in current attached permissions");
403
+
401
404
  return _context5.abrupt("return", undefined);
402
405
 
403
406
  case 26:
@@ -11,6 +11,8 @@ var _get = _interopRequireDefault(require("lodash/get"));
11
11
 
12
12
  var _account = require("./account");
13
13
 
14
+ var _logger = _interopRequireDefault(require("../logger"));
15
+
14
16
  var actionableErrors = ['CHALLENGE_ASKED', 'DISK_QUOTA_EXCEEDED', 'TERMS_VERSION_MISMATCH', 'USER_ACTION_NEEDED', 'USER_ACTION_NEEDED.CHANGE_PASSWORD', 'USER_ACTION_NEEDED.ACCOUNT_REMOVED', 'USER_ACTION_NEEDED.WEBAUTH_REQUIRED', 'USER_ACTION_NEEDED.SCA_REQUIRED', 'LOGIN_FAILED'];
15
17
  /** Trigger states come from /jobs/triggers */
16
18
 
@@ -20,7 +22,8 @@ var triggerStates = {
20
22
  return (0, _get.default)(triggerState, 'current_state.last_execution');
21
23
  },
22
24
  getLastsuccess: function getLastsuccess(triggerState) {
23
- console.warn('Deprecated, please use getLastSuccess instead of getLastsuccess');
25
+ _logger.default.warn('Deprecated, please use getLastSuccess instead of getLastsuccess');
26
+
24
27
  return (0, _get.default)(triggerState, 'current_state.last_success');
25
28
  },
26
29
 
@@ -19,6 +19,8 @@ var _findKey = _interopRequireDefault(require("lodash/findKey"));
19
19
 
20
20
  var _types = require("../types");
21
21
 
22
+ var _logger = _interopRequireDefault(require("../logger"));
23
+
22
24
  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; }
23
25
 
24
26
  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; }
@@ -122,13 +124,15 @@ var QueryDefinition = /*#__PURE__*/function () {
122
124
  }
123
125
 
124
126
  if (_sort.length > fieldsToIndex.length) {
125
- console.warn("You should not sort on non-indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex));
127
+ _logger.default.warn("You should not sort on non-indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex));
128
+
126
129
  return;
127
130
  }
128
131
 
129
132
  for (var i = 0; i < _sort.length; i++) {
130
133
  if (Object.keys(_sort[i])[0] !== fieldsToIndex[i]) {
131
- console.warn("The sort order should be the same than the indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex, "\n"));
134
+ _logger.default.warn("The sort order should be the same than the indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex, "\n"));
135
+
132
136
  return;
133
137
  }
134
138
  }
@@ -148,13 +152,13 @@ var QueryDefinition = /*#__PURE__*/function () {
148
152
  var hasExistsFalse = (0, _findKey.default)(selector, ['$exists', false]);
149
153
 
150
154
  if (hasExistsFalse) {
151
- console.warn("The \"$exists: false\" predicate should be defined as a partial index for better performance.\n\n Selector: ".concat(selector));
155
+ _logger.default.warn("The \"$exists: false\" predicate should be defined as a partial index for better performance.\n\n Selector: ".concat(selector));
152
156
  }
153
157
 
154
158
  var hasNe = (0, _findKey.default)(selector, '$ne');
155
159
 
156
160
  if (hasNe) {
157
- console.info("The use of the $ne operator is more efficient with a partial index.\n\n Selector: ".concat(selector));
161
+ _logger.default.info("The use of the $ne operator is more efficient with a partial index.\n\n Selector: ".concat(selector));
158
162
  }
159
163
  }
160
164
  /**
@@ -1,14 +1,15 @@
1
1
  import { QueryDefinition, Q } from '../queries/dsl'
2
+ import logger from '../logger'
2
3
 
3
4
  describe('QueryDefinition', () => {
4
5
  beforeEach(() => {
5
- jest.spyOn(console, 'warn').mockImplementation(() => jest.fn())
6
- jest.spyOn(console, 'info').mockImplementation(() => jest.fn())
6
+ jest.spyOn(logger, 'warn').mockImplementation(() => jest.fn())
7
+ jest.spyOn(logger, 'info').mockImplementation(() => jest.fn())
7
8
  })
8
9
 
9
10
  afterEach(() => {
10
- console.warn.mockRestore()
11
- console.info.mockRestore()
11
+ logger.warn.mockRestore()
12
+ logger.info.mockRestore()
12
13
  })
13
14
 
14
15
  it('should build query defs on selected fields', () => {
@@ -72,40 +73,40 @@ describe('QueryDefinition', () => {
72
73
  .sortBy([{ type: 'asc' }, { dirID: 'asc' }])
73
74
  .where({ type: 'file', dirID: '123' })
74
75
  .indexFields(['type', 'dirID'])
75
- expect(console.warn).toHaveBeenCalledTimes(0)
76
+ expect(logger.warn).toHaveBeenCalledTimes(0)
76
77
  })
77
78
  it('should warn on sorting non-indexed fields', () => {
78
79
  Q('io.cozy.files')
79
80
  .where({ type: 'file', dirID: '123' })
80
81
  .indexFields(['type', 'dirID'])
81
82
  .sortBy([{ type: 'asc' }, { dirID: 'asc' }, { date: 'asc' }])
82
- expect(console.warn).toHaveBeenCalledTimes(1)
83
+ expect(logger.warn).toHaveBeenCalledTimes(1)
83
84
  })
84
85
  it('should warn on sort order', () => {
85
86
  Q('io.cozy.files')
86
87
  .where({ type: 'file', dirID: '123' })
87
88
  .indexFields(['type', 'dirID'])
88
89
  .sortBy([{ dirID: 'asc' }, { type: 'asc' }])
89
- expect(console.warn).toHaveBeenCalledTimes(1)
90
+ expect(logger.warn).toHaveBeenCalledTimes(1)
90
91
  })
91
92
  it('should warn on sort order through the selector', () => {
92
93
  Q('io.cozy.files')
93
94
  .where({ type: 'file', dirID: '123' })
94
95
  .sortBy([{ dirID: 'asc' }, { type: 'asc' }])
95
- expect(console.warn).toHaveBeenCalledTimes(1)
96
+ expect(logger.warn).toHaveBeenCalledTimes(1)
96
97
  })
97
98
  it('should not warn for queries with no selector', () => {
98
99
  Q('io.cozy.files').sortBy([{ dirID: 'asc' }, { type: 'asc' }])
99
- expect(console.warn).toHaveBeenCalledTimes(0)
100
+ expect(logger.warn).toHaveBeenCalledTimes(0)
100
101
  })
101
102
 
102
103
  it('should warn when using a selector with $exists: false', () => {
103
104
  Q('io.cozy.files').where({ trashed: { $exists: false } })
104
- expect(console.warn).toHaveBeenCalledTimes(1)
105
+ expect(logger.warn).toHaveBeenCalledTimes(1)
105
106
  })
106
107
  it('should inform when using a selector with $neq', () => {
107
108
  Q('io.cozy.files').where({ _id: { $ne: 'io.cozy.root-id' } })
108
- expect(console.info).toHaveBeenCalledTimes(1)
109
+ expect(logger.info).toHaveBeenCalledTimes(1)
109
110
  })
110
111
 
111
112
  it('should throw an error when there is a select without all the fields in selector', () => {
@@ -53,6 +53,8 @@ var _dsl = require("../queries/dsl");
53
53
 
54
54
  var _types = require("../types");
55
55
 
56
+ var _logger = _interopRequireDefault(require("../logger"));
57
+
56
58
  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; }
57
59
 
58
60
  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; }
@@ -390,7 +392,8 @@ var makeSorterFromDefinition = function makeSorterFromDefinition(definition) {
390
392
  return docs;
391
393
  };
392
394
  } else if (!(0, _isArray.default)(definition.sort)) {
393
- console.warn('Correct update of queries with a sort that is not an array is not supported. Use an array as argument of QueryDefinition::sort');
395
+ _logger.default.warn('Correct update of queries with a sort that is not an array is not supported. Use an array as argument of QueryDefinition::sort');
396
+
394
397
  return function (docs) {
395
398
  return docs;
396
399
  };
package/dist/utils.js CHANGED
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.hasQueryBeenLoaded = exports.isQueryLoading = exports.cancelable = void 0;
7
9
 
10
+ var _logger = _interopRequireDefault(require("./logger"));
11
+
8
12
  /**
9
13
  * @typedef {Promise} CancelablePromise
10
14
  * @property {Function} cancel - Cancel the promise
@@ -44,7 +48,7 @@ exports.cancelable = cancelable;
44
48
  */
45
49
  var isQueryLoading = function isQueryLoading(col) {
46
50
  if (!col) {
47
- console.warn('isQueryLoading called on falsy value.'); // eslint-disable-line no-console
51
+ _logger.default.warn('isQueryLoading called on falsy value.');
48
52
 
49
53
  return false;
50
54
  }
@@ -31,6 +31,8 @@ var _react = _interopRequireWildcard(require("react"));
31
31
 
32
32
  var _propTypes = _interopRequireDefault(require("prop-types"));
33
33
 
34
+ var _logger = _interopRequireDefault(require("./logger"));
35
+
34
36
  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; }
35
37
 
36
38
  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; }
@@ -74,7 +76,8 @@ var withMutations = function withMutations() {
74
76
  (0, _classCallCheck2.default)(this, Wrapper);
75
77
  _this = _super.call(this, props, context);
76
78
  var client = props.client || context.client;
77
- console.warn("Deprecation: withMutations will be removed in the near future, prefer to use withClient to access the client. See https://github.com/cozy/cozy-client/pull/638 for more information.");
79
+
80
+ _logger.default.warn("Deprecation: withMutations will be removed in the near future, prefer to use withClient to access the client. See https://github.com/cozy/cozy-client/pull/638 for more information.");
78
81
 
79
82
  if (!client) {
80
83
  throw new Error("Could not find \"client\" in either the context or props of ".concat(wrappedDisplayName));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "32.7.1",
3
+ "version": "32.7.4",
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.7.1",
21
+ "cozy-stack-client": "^32.7.3",
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": "66a0c6eadd8f6d3298f075a706e77dcb634cb6d4"
76
+ "gitHead": "c98083b269380482d69615bb8c3fd59aeb3b1085"
77
77
  }
@@ -17,9 +17,16 @@ export default class StackLink extends CozyLink {
17
17
  stackClient: any;
18
18
  registerClient(client: any): void;
19
19
  reset(): void;
20
- executeQuery(query: any): any;
20
+ /**
21
+ *
22
+ * @param {QueryDefinition} query - Query to execute
23
+ * @returns {Promise<ClientResponse>}
24
+ */
25
+ executeQuery(query: QueryDefinition): Promise<ClientResponse>;
21
26
  executeMutation(mutation: any, result: any, forward: any): Promise<any>;
22
27
  }
23
28
  import { CouchDBBulkResult } from "./types";
24
29
  import { CozyClientDocument } from "./types";
25
30
  import CozyLink from "./CozyLink";
31
+ import { QueryDefinition } from "./queries/dsl";
32
+ import { ClientResponse } from "./types";
@@ -13,4 +13,4 @@ import * as models from "./models";
13
13
  export { manifest, models };
14
14
  export { QueryDefinition, Mutations, MutationTypes, getDoctypeFromOperation, Q } from "./queries/dsl";
15
15
  export { Association, HasMany, HasOne, HasOneInPlace, HasManyInPlace, HasManyTriggers } from "./associations";
16
- export { dehydrate, generateWebLink, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./helpers";
16
+ export { deconstructCozyWebLinkWithSlug, dehydrate, generateWebLink, rootCozyUrl, InvalidCozyUrlError, InvalidProtocolError } from "./helpers";