cozy-client 48.10.0 → 48.11.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.
@@ -2626,7 +2626,7 @@ var CozyClient = /*#__PURE__*/function () {
2626
2626
  * This method will reset the query state to its initial state and refetch it.
2627
2627
  *
2628
2628
  * @param {string} queryId - Query id
2629
- * @returns {Promise<import("./types").QueryState>} - Query state
2629
+ * @returns {Promise<import("./types").QueryState|null>} - Query state or null if the query does not exist
2630
2630
  */
2631
2631
 
2632
2632
  }, {
@@ -2639,27 +2639,36 @@ var CozyClient = /*#__PURE__*/function () {
2639
2639
  switch (_context21.prev = _context21.next) {
2640
2640
  case 0:
2641
2641
  _context21.prev = 0;
2642
+
2643
+ if ((0, _store.isQueryExisting)(this.store.getState(), queryId)) {
2644
+ _context21.next = 3;
2645
+ break;
2646
+ }
2647
+
2648
+ return _context21.abrupt("return", Promise.resolve(null));
2649
+
2650
+ case 3:
2642
2651
  this.dispatch((0, _store.resetQuery)(queryId));
2643
2652
  query = this.getQueryFromState(queryId);
2644
- _context21.next = 5;
2653
+ _context21.next = 7;
2645
2654
  return this.query(query.definition, {
2646
2655
  as: queryId
2647
2656
  });
2648
2657
 
2649
- case 5:
2658
+ case 7:
2650
2659
  return _context21.abrupt("return", _context21.sent);
2651
2660
 
2652
- case 8:
2653
- _context21.prev = 8;
2661
+ case 10:
2662
+ _context21.prev = 10;
2654
2663
  _context21.t0 = _context21["catch"](0);
2655
2664
  throw _context21.t0;
2656
2665
 
2657
- case 11:
2666
+ case 13:
2658
2667
  case "end":
2659
2668
  return _context21.stop();
2660
2669
  }
2661
2670
  }
2662
- }, _callee21, this, [[0, 8]]);
2671
+ }, _callee21, this, [[0, 10]]);
2663
2672
  }));
2664
2673
 
2665
2674
  function resetQuery(_x22) {
@@ -2830,7 +2839,7 @@ var CozyClient = /*#__PURE__*/function () {
2830
2839
  CozyClient.hooks = CozyClient.hooks || {};
2831
2840
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2832
2841
 
2833
- CozyClient.version = "48.10.0";
2842
+ CozyClient.version = "48.11.1";
2834
2843
 
2835
2844
  _microee.default.mixin(CozyClient);
2836
2845
 
@@ -30,6 +30,7 @@ import {
30
30
  receiveMutationError,
31
31
  getQueryFromState,
32
32
  getRawQueryFromState,
33
+ isQueryExisting,
33
34
  loadQuery,
34
35
  resetQuery
35
36
  } from './store'
@@ -51,6 +52,7 @@ const METADATA_VERSION = 1
51
52
 
52
53
  jest.mock('./store', () => ({
53
54
  ...jest.requireActual('./store'),
55
+ isQueryExisting: jest.fn().mockReturnValue(false),
54
56
  getQueryFromState: jest.fn().mockReturnValue({}),
55
57
  getRawQueryFromState: jest.fn().mockReturnValue({})
56
58
  }))
@@ -1878,15 +1880,16 @@ describe('CozyClient', () => {
1878
1880
  const fakeResponse = {
1879
1881
  data: [TODO_1, TODO_2, TODO_3]
1880
1882
  }
1883
+ const queryId = 'allTodos'
1881
1884
 
1882
1885
  afterEach(() => {
1883
1886
  jest.restoreAllMocks()
1884
1887
  })
1885
1888
 
1886
1889
  it('should reset the query state and refetch it', async () => {
1890
+ isQueryExisting.mockReturnValue(true)
1887
1891
  requestHandler.mockResolvedValue(fakeResponse)
1888
1892
  const queryDefinition = Q('io.cozy.todos')
1889
- const queryId = 'allTodos'
1890
1893
  getQueryFromState.mockReturnValue({
1891
1894
  definition: queryDefinition,
1892
1895
  id: queryId,
@@ -1903,6 +1906,12 @@ describe('CozyClient', () => {
1903
1906
  receiveQueryResult('allTodos', fakeResponse)
1904
1907
  )
1905
1908
  })
1909
+
1910
+ it('should return null when the query is not found', async () => {
1911
+ isQueryExisting.mockReturnValue(false)
1912
+ const res = await client.resetQuery(queryId)
1913
+ expect(res).toBe(null)
1914
+ })
1906
1915
  })
1907
1916
  })
1908
1917
 
@@ -55,7 +55,7 @@ Object.defineProperty(exports, "receiveMutationError", {
55
55
  return _mutations.receiveMutationError;
56
56
  }
57
57
  });
58
- exports.resetState = exports.getRawQueryFromState = exports.getQueryFromState = exports.getQueryFromStore = exports.getDocumentFromState = exports.getCollectionFromState = exports.getStateRoot = exports.createStore = exports.default = exports.StoreProxy = void 0;
58
+ exports.resetState = exports.isQueryExisting = exports.getRawQueryFromState = exports.getQueryFromState = exports.getQueryFromStore = exports.getDocumentFromState = exports.getCollectionFromState = exports.getStateRoot = exports.createStore = exports.default = exports.StoreProxy = void 0;
59
59
 
60
60
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
61
61
 
@@ -208,4 +208,10 @@ var getRawQueryFromState = function getRawQueryFromState(state, queryId) {
208
208
  return (0, _queries.getQueryFromSlice)(getStateRoot(state).queries, queryId);
209
209
  };
210
210
 
211
- exports.getRawQueryFromState = getRawQueryFromState;
211
+ exports.getRawQueryFromState = getRawQueryFromState;
212
+
213
+ var isQueryExisting = function isQueryExisting(state, queryId) {
214
+ return getStateRoot(state).queries[queryId] !== undefined;
215
+ };
216
+
217
+ exports.isQueryExisting = isQueryExisting;
package/dist/types.js CHANGED
@@ -486,6 +486,7 @@ var _dsl = require("./queries/dsl");
486
486
  * @property {string} name - Name of the file
487
487
  * @property {string} path - Path to the file
488
488
  * @property {string} parentPath - Path to the folder containing the file
489
+ * @property {string} [restore_path] - Old path when the file is in the trash
489
490
  * @property {'file'|'directory'} type - Type of the file
490
491
  * @property {object} cozyMetadata - Mime of the file
491
492
  * @property {string} cozyMetadata.sourceAccount - Id of the io.cozy.account associated to the Nextcloud
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "48.10.0",
3
+ "version": "48.11.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -75,5 +75,5 @@
75
75
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
76
76
  },
77
77
  "sideEffects": false,
78
- "gitHead": "90b2fff263719c7e04c153c92b4dbc1c70888735"
78
+ "gitHead": "73a573aa72e2b1d5d2589ae5c0afeec349092c1e"
79
79
  }
@@ -748,9 +748,9 @@ declare class CozyClient {
748
748
  * This method will reset the query state to its initial state and refetch it.
749
749
  *
750
750
  * @param {string} queryId - Query id
751
- * @returns {Promise<import("./types").QueryState>} - Query state
751
+ * @returns {Promise<import("./types").QueryState|null>} - Query state or null if the query does not exist
752
752
  */
753
- resetQuery(queryId: string): Promise<import("./types").QueryState>;
753
+ resetQuery(queryId: string): Promise<import("./types").QueryState | null>;
754
754
  }
755
755
  declare namespace CozyClient {
756
756
  export const hooks: {};
@@ -14,6 +14,7 @@ export function getDocumentFromState(state: any, doctype: any, id: any): any;
14
14
  export function getQueryFromStore(store: any, queryId: any): any;
15
15
  export function getQueryFromState(state: any, queryId: any): any;
16
16
  export function getRawQueryFromState(state: any, queryId: any): any;
17
+ export function isQueryExisting(state: any, queryId: any): boolean;
17
18
  declare function combinedReducer(state: {
18
19
  documents: {};
19
20
  queries: {};
package/types/types.d.ts CHANGED
@@ -902,6 +902,10 @@ export type NextcloudFile = {
902
902
  * - Path to the folder containing the file
903
903
  */
904
904
  parentPath: string;
905
+ /**
906
+ * - Old path when the file is in the trash
907
+ */
908
+ restore_path?: string;
905
909
  /**
906
910
  * - Type of the file
907
911
  */