cozy-client 48.11.0 → 48.11.2
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 +17 -8
- package/dist/CozyClient.spec.js +10 -1
- package/dist/models/file.js +12 -34
- package/dist/models/file.spec.js +4 -8
- package/dist/store/index.js +8 -2
- package/package.json +2 -2
- package/types/CozyClient.d.ts +2 -2
- package/types/store/index.d.ts +1 -0
package/dist/CozyClient.js
CHANGED
|
@@ -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 =
|
|
2653
|
+
_context21.next = 7;
|
|
2645
2654
|
return this.query(query.definition, {
|
|
2646
2655
|
as: queryId
|
|
2647
2656
|
});
|
|
2648
2657
|
|
|
2649
|
-
case
|
|
2658
|
+
case 7:
|
|
2650
2659
|
return _context21.abrupt("return", _context21.sent);
|
|
2651
2660
|
|
|
2652
|
-
case
|
|
2653
|
-
_context21.prev =
|
|
2661
|
+
case 10:
|
|
2662
|
+
_context21.prev = 10;
|
|
2654
2663
|
_context21.t0 = _context21["catch"](0);
|
|
2655
2664
|
throw _context21.t0;
|
|
2656
2665
|
|
|
2657
|
-
case
|
|
2666
|
+
case 13:
|
|
2658
2667
|
case "end":
|
|
2659
2668
|
return _context21.stop();
|
|
2660
2669
|
}
|
|
2661
2670
|
}
|
|
2662
|
-
}, _callee21, this, [[0,
|
|
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.11.
|
|
2842
|
+
CozyClient.version = "48.11.2";
|
|
2834
2843
|
|
|
2835
2844
|
_microee.default.mixin(CozyClient);
|
|
2836
2845
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -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
|
|
package/dist/models/file.js
CHANGED
|
@@ -482,9 +482,6 @@ var move = /*#__PURE__*/function () {
|
|
|
482
482
|
force,
|
|
483
483
|
resp,
|
|
484
484
|
destinationPath,
|
|
485
|
-
_yield$client$query2,
|
|
486
|
-
movedFile,
|
|
487
|
-
filename,
|
|
488
485
|
conflictResp,
|
|
489
486
|
_resp,
|
|
490
487
|
_args4 = arguments;
|
|
@@ -570,59 +567,40 @@ var move = /*#__PURE__*/function () {
|
|
|
570
567
|
_context4.t1 = _context4["catch"](19);
|
|
571
568
|
|
|
572
569
|
if (!(_context4.t1.status === 409 && force)) {
|
|
573
|
-
_context4.next =
|
|
570
|
+
_context4.next = 43;
|
|
574
571
|
break;
|
|
575
572
|
}
|
|
576
573
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
break;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
destinationPath = destination.path;
|
|
583
|
-
_context4.next = 41;
|
|
584
|
-
break;
|
|
585
|
-
|
|
586
|
-
case 33:
|
|
587
|
-
_context4.next = 35;
|
|
588
|
-
return client.query((0, _dsl.Q)(_const.DOCTYPE_FILES).getById(file._id));
|
|
574
|
+
_context4.next = 31;
|
|
575
|
+
return getFullpath(client, destination._id, file.name);
|
|
589
576
|
|
|
590
|
-
case
|
|
591
|
-
_yield$client$query2 = _context4.sent;
|
|
592
|
-
movedFile = _yield$client$query2.data;
|
|
593
|
-
filename = movedFile.name;
|
|
594
|
-
_context4.next = 40;
|
|
595
|
-
return getFullpath(client, destination._id, filename);
|
|
596
|
-
|
|
597
|
-
case 40:
|
|
577
|
+
case 31:
|
|
598
578
|
destinationPath = _context4.sent;
|
|
599
|
-
|
|
600
|
-
case 41:
|
|
601
|
-
_context4.next = 43;
|
|
579
|
+
_context4.next = 34;
|
|
602
580
|
return client.collection(_const.DOCTYPE_FILES).statByPath(destinationPath);
|
|
603
581
|
|
|
604
|
-
case
|
|
582
|
+
case 34:
|
|
605
583
|
conflictResp = _context4.sent;
|
|
606
|
-
_context4.next =
|
|
584
|
+
_context4.next = 37;
|
|
607
585
|
return client.collection(_const.DOCTYPE_FILES).destroy(conflictResp.data);
|
|
608
586
|
|
|
609
|
-
case
|
|
610
|
-
_context4.next =
|
|
587
|
+
case 37:
|
|
588
|
+
_context4.next = 39;
|
|
611
589
|
return client.collection(_const.DOCTYPE_FILES).updateFileMetadata(file._id, {
|
|
612
590
|
dir_id: destination._id
|
|
613
591
|
});
|
|
614
592
|
|
|
615
|
-
case
|
|
593
|
+
case 39:
|
|
616
594
|
_resp = _context4.sent;
|
|
617
595
|
return _context4.abrupt("return", {
|
|
618
596
|
moved: _resp.data,
|
|
619
597
|
deleted: conflictResp.data.id
|
|
620
598
|
});
|
|
621
599
|
|
|
622
|
-
case
|
|
600
|
+
case 43:
|
|
623
601
|
throw _context4.t1;
|
|
624
602
|
|
|
625
|
-
case
|
|
603
|
+
case 44:
|
|
626
604
|
case "end":
|
|
627
605
|
return _context4.stop();
|
|
628
606
|
}
|
package/dist/models/file.spec.js
CHANGED
|
@@ -455,8 +455,11 @@ describe('File Model', () => {
|
|
|
455
455
|
_id: 'dir-b1e1c256',
|
|
456
456
|
_type: 'io.cozy.files',
|
|
457
457
|
dir_id: 'io.cozy.files.root-dir',
|
|
458
|
-
|
|
458
|
+
type: 'directory',
|
|
459
|
+
name: 'Photos',
|
|
460
|
+
path: '/Photos'
|
|
459
461
|
}
|
|
462
|
+
|
|
460
463
|
const nextcloudFolder = {
|
|
461
464
|
_id: 'folder-12435',
|
|
462
465
|
_type: 'io.cozy.remote.nextcloud.files',
|
|
@@ -520,13 +523,6 @@ describe('File Model', () => {
|
|
|
520
523
|
_type: 'io.cozy.files'
|
|
521
524
|
}
|
|
522
525
|
})
|
|
523
|
-
getSpy.mockResolvedValue({
|
|
524
|
-
data: {
|
|
525
|
-
id: cozyFile._id,
|
|
526
|
-
name: 'mydoc.odt',
|
|
527
|
-
_type: 'io.cozy.files'
|
|
528
|
-
}
|
|
529
|
-
})
|
|
530
526
|
statByPathSpy.mockResolvedValue({
|
|
531
527
|
data: {
|
|
532
528
|
id: DELETED_FILE_ID,
|
package/dist/store/index.js
CHANGED
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "48.11.
|
|
3
|
+
"version": "48.11.2",
|
|
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": "
|
|
78
|
+
"gitHead": "e8129adc0b6d19e3165c79fe00294428e213f9c4"
|
|
79
79
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -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: {};
|
package/types/store/index.d.ts
CHANGED
|
@@ -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: {};
|