cozy-client 27.15.3 → 27.17.0
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
CHANGED
|
@@ -2464,7 +2464,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2464
2464
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2465
2465
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2466
2466
|
|
|
2467
|
-
CozyClient.version = "27.
|
|
2467
|
+
CozyClient.version = "27.17.0";
|
|
2468
2468
|
|
|
2469
2469
|
_microee.default.mixin(CozyClient);
|
|
2470
2470
|
|
package/dist/models/folder.js
CHANGED
|
@@ -29,7 +29,8 @@ var MAGIC_FOLDERS = {
|
|
|
29
29
|
PHOTOS_UPLOAD: "".concat(APP_DOCTYPE, "/").concat(photos, "/upload"),
|
|
30
30
|
NOTES: "".concat(APP_DOCTYPE, "/notes"),
|
|
31
31
|
HOME: "".concat(APP_DOCTYPE, "/home"),
|
|
32
|
-
PAPERS: "".concat(APP_DOCTYPE, "/").concat(administrative, "/papers")
|
|
32
|
+
PAPERS: "".concat(APP_DOCTYPE, "/").concat(administrative, "/papers"),
|
|
33
|
+
COACH_CO2: "".concat(APP_DOCTYPE, "/").concat(administrative, "/coachco2")
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
36
|
* Returns a "Magic Folder", given its id. See https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.apps/#special-iocozyapps-doctypes
|
|
@@ -22,6 +22,7 @@ describe('Folder model', () => {
|
|
|
22
22
|
expect(MAGIC_FOLDERS.NOTES).toBeDefined()
|
|
23
23
|
expect(MAGIC_FOLDERS.HOME).toBeDefined()
|
|
24
24
|
expect(MAGIC_FOLDERS.PAPERS).toBeDefined()
|
|
25
|
+
expect(MAGIC_FOLDERS.COACH_CO2).toBeDefined()
|
|
25
26
|
})
|
|
26
27
|
|
|
27
28
|
describe('ensureMagicFolder', () => {
|
package/dist/store/documents.js
CHANGED
|
@@ -159,16 +159,16 @@ var getCollectionFromSlice = function getCollectionFromSlice() {
|
|
|
159
159
|
return Object.values(state[doctype]);
|
|
160
160
|
};
|
|
161
161
|
/*
|
|
162
|
-
This method has been created in order to get a returned object
|
|
163
|
-
in `data` with the full set on information coming potentially from
|
|
164
|
-
|
|
162
|
+
This method has been created in order to get a returned object
|
|
163
|
+
in `data` with the full set on information coming potentially from
|
|
164
|
+
`included`
|
|
165
165
|
|
|
166
|
-
This method should be somewhere else. The `document` shall not be
|
|
167
|
-
|
|
166
|
+
This method should be somewhere else. The `document` shall not be
|
|
167
|
+
dealt with included / data and so on.
|
|
168
168
|
|
|
169
|
-
This method takes data and included and merge both sources
|
|
170
|
-
together. It should be always up
|
|
171
|
-
will be as full of
|
|
169
|
+
This method takes `data` and `included` and merge both sources
|
|
170
|
+
together. It should be always up-to-date. The returned object
|
|
171
|
+
will be as full of information as it can be.
|
|
172
172
|
*/
|
|
173
173
|
|
|
174
174
|
|
|
@@ -185,8 +185,8 @@ var extractAndMergeDocument = function extractAndMergeDocument(data, updatedStat
|
|
|
185
185
|
|
|
186
186
|
var sortedData = (0, _keyBy.default)(data, _helpers.properId);
|
|
187
187
|
var mergedData = Object.assign({}, updatedStateWithIncluded);
|
|
188
|
+
mergedData[doctype] = Object.assign({}, updatedStateWithIncluded[doctype]);
|
|
188
189
|
Object.values(sortedData).map(function (data) {
|
|
189
|
-
if (!mergedData[doctype]) mergedData[doctype] = {};
|
|
190
190
|
var id = (0, _helpers.properId)(data);
|
|
191
191
|
|
|
192
192
|
if (mergedData[doctype][id]) {
|
|
@@ -4,23 +4,25 @@ import {
|
|
|
4
4
|
} from './documents'
|
|
5
5
|
|
|
6
6
|
describe('extractAndMerge', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const data = {
|
|
8
|
+
0: {
|
|
9
|
+
id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
10
|
+
_id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
11
|
+
type: 'io.cozy.files',
|
|
12
|
+
_type: 'io.cozy.files',
|
|
13
|
+
blabla: 'new field'
|
|
14
|
+
},
|
|
15
|
+
1: {
|
|
16
|
+
id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
17
|
+
type: 'io.cozy.files',
|
|
18
|
+
_type: 'io.cozy.files',
|
|
19
|
+
_id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
20
|
+
blibli: 'another new field'
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
}
|
|
23
|
+
const updatedStateWithIncluded = {
|
|
24
|
+
'io.cozy.files': {
|
|
25
|
+
b6ff135b34e041ffb2d4a4865f3e0a53: {
|
|
24
26
|
attributes: {
|
|
25
27
|
type: 'file',
|
|
26
28
|
name: 'IMG_0016.PNG',
|
|
@@ -38,7 +40,7 @@ describe('extractAndMerge', () => {
|
|
|
38
40
|
type: 'io.cozy.files',
|
|
39
41
|
_type: 'io.cozy.files'
|
|
40
42
|
},
|
|
41
|
-
|
|
43
|
+
b6ff135b34e041ffb2d4a4865f3e235f: {
|
|
42
44
|
attributes: {
|
|
43
45
|
type: 'file',
|
|
44
46
|
name: 'IMG_0054.PNG',
|
|
@@ -57,65 +59,112 @@ describe('extractAndMerge', () => {
|
|
|
57
59
|
_type: 'io.cozy.files'
|
|
58
60
|
}
|
|
59
61
|
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
it('should return the right data', () => {
|
|
60
65
|
const returnedDatas = extractAndMergeDocument(
|
|
61
66
|
data,
|
|
62
67
|
updatedStateWithIncluded
|
|
63
68
|
)
|
|
64
69
|
|
|
65
70
|
const manuallyMergedData = {
|
|
66
|
-
'0': {
|
|
67
|
-
_id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
68
|
-
_type: 'io.cozy.files',
|
|
69
|
-
attributes: {
|
|
70
|
-
dir_id: '7d2f9c24cd345ce3171bf71f401e80c6',
|
|
71
|
-
name: 'IMG_0016.PNG',
|
|
72
|
-
type: 'file'
|
|
73
|
-
},
|
|
74
|
-
id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
75
|
-
links: { self: '/files/b6ff135b34e041ffb2d4a4865f3e0a53' },
|
|
76
|
-
meta: { rev: '5-87840eceaab358e38aa8b6bb0d4577b1' },
|
|
77
|
-
relationships: {
|
|
78
|
-
parent: {
|
|
79
|
-
links: { related: '/files/7d2f9c24cd345ce3171bf71f401e80c6' }
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
type: 'io.cozy.files'
|
|
83
|
-
},
|
|
84
|
-
'1': {
|
|
85
|
-
_id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
86
|
-
_type: 'io.cozy.files',
|
|
87
|
-
attributes: {
|
|
88
|
-
dir_id: '7d2f9c24cd345ce3171bf71f401e80c6',
|
|
89
|
-
name: 'IMG_0054.PNG',
|
|
90
|
-
type: 'file'
|
|
91
|
-
},
|
|
92
|
-
id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
93
|
-
links: { self: '/files/b6ff135b34e041ffb2d4a4865f3e235f' },
|
|
94
|
-
meta: { rev: '5-ca91c0dc02dafb38eb56070c1d80d62c' },
|
|
95
|
-
relationships: {
|
|
96
|
-
parent: {
|
|
97
|
-
links: { related: '/files/7d2f9c24cd345ce3171bf71f401e80c6' }
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
type: 'io.cozy.files'
|
|
101
|
-
},
|
|
102
71
|
'io.cozy.files': {
|
|
103
72
|
b6ff135b34e041ffb2d4a4865f3e0a53: {
|
|
104
73
|
_id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
105
74
|
_type: 'io.cozy.files',
|
|
75
|
+
attributes: {
|
|
76
|
+
dir_id: '7d2f9c24cd345ce3171bf71f401e80c6',
|
|
77
|
+
name: 'IMG_0016.PNG',
|
|
78
|
+
type: 'file'
|
|
79
|
+
},
|
|
80
|
+
blabla: 'new field',
|
|
106
81
|
id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
82
|
+
links: { self: '/files/b6ff135b34e041ffb2d4a4865f3e0a53' },
|
|
83
|
+
meta: { rev: '5-87840eceaab358e38aa8b6bb0d4577b1' },
|
|
84
|
+
relationships: {
|
|
85
|
+
parent: {
|
|
86
|
+
links: { related: '/files/7d2f9c24cd345ce3171bf71f401e80c6' }
|
|
87
|
+
}
|
|
88
|
+
},
|
|
107
89
|
type: 'io.cozy.files'
|
|
108
90
|
},
|
|
109
91
|
b6ff135b34e041ffb2d4a4865f3e235f: {
|
|
110
92
|
_id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
111
93
|
_type: 'io.cozy.files',
|
|
94
|
+
attributes: {
|
|
95
|
+
dir_id: '7d2f9c24cd345ce3171bf71f401e80c6',
|
|
96
|
+
name: 'IMG_0054.PNG',
|
|
97
|
+
type: 'file'
|
|
98
|
+
},
|
|
99
|
+
blibli: 'another new field',
|
|
112
100
|
id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
101
|
+
links: { self: '/files/b6ff135b34e041ffb2d4a4865f3e235f' },
|
|
102
|
+
meta: { rev: '5-ca91c0dc02dafb38eb56070c1d80d62c' },
|
|
103
|
+
relationships: {
|
|
104
|
+
parent: {
|
|
105
|
+
links: { related: '/files/7d2f9c24cd345ce3171bf71f401e80c6' }
|
|
106
|
+
}
|
|
107
|
+
},
|
|
113
108
|
type: 'io.cozy.files'
|
|
114
109
|
}
|
|
115
110
|
}
|
|
116
111
|
}
|
|
117
112
|
expect(returnedDatas).toEqual(manuallyMergedData)
|
|
118
113
|
})
|
|
114
|
+
|
|
115
|
+
it(
|
|
116
|
+
'should assign a new object for doctype of document to update' +
|
|
117
|
+
'in order to allow selector to recompute their data when documents are updated',
|
|
118
|
+
() => {
|
|
119
|
+
const returnedDatas = extractAndMergeDocument(
|
|
120
|
+
data,
|
|
121
|
+
updatedStateWithIncluded
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
// Then
|
|
125
|
+
expect(
|
|
126
|
+
returnedDatas['io.cozy.files'] ===
|
|
127
|
+
updatedStateWithIncluded['io.cozy.files']
|
|
128
|
+
).toBeFalsy()
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
it(
|
|
133
|
+
'should assign a new object for doctype of document to update' +
|
|
134
|
+
'even if the mergedData is the same, because reselect createSelector update ' +
|
|
135
|
+
'according to object reference, not only value',
|
|
136
|
+
() => {
|
|
137
|
+
const dataAlreadyIncludedInUpdatedStateWithIncluded = {
|
|
138
|
+
0: {
|
|
139
|
+
id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
140
|
+
_id: 'b6ff135b34e041ffb2d4a4865f3e0a53',
|
|
141
|
+
type: 'io.cozy.files',
|
|
142
|
+
_type: 'io.cozy.files'
|
|
143
|
+
},
|
|
144
|
+
1: {
|
|
145
|
+
id: 'b6ff135b34e041ffb2d4a4865f3e235f',
|
|
146
|
+
type: 'io.cozy.files',
|
|
147
|
+
_type: 'io.cozy.files',
|
|
148
|
+
_id: 'b6ff135b34e041ffb2d4a4865f3e235f'
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const returnedDatas = extractAndMergeDocument(
|
|
153
|
+
dataAlreadyIncludedInUpdatedStateWithIncluded,
|
|
154
|
+
updatedStateWithIncluded
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
// Then
|
|
158
|
+
expect(
|
|
159
|
+
returnedDatas['io.cozy.files'] ===
|
|
160
|
+
updatedStateWithIncluded['io.cozy.files']
|
|
161
|
+
).toBeFalsy()
|
|
162
|
+
|
|
163
|
+
expect(returnedDatas['io.cozy.files']).toEqual(
|
|
164
|
+
updatedStateWithIncluded['io.cozy.files']
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
)
|
|
119
168
|
})
|
|
120
169
|
|
|
121
170
|
describe('mergeDocumentsWithRelationships', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.17.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"cozy-device-helper": "^1.12.0",
|
|
22
22
|
"cozy-flags": "2.7.1",
|
|
23
23
|
"cozy-logger": "^1.6.0",
|
|
24
|
-
"cozy-stack-client": "^27.
|
|
24
|
+
"cozy-stack-client": "^27.17.0",
|
|
25
25
|
"json-stable-stringify": "^1.0.1",
|
|
26
26
|
"lodash": "^4.17.13",
|
|
27
27
|
"microee": "^0.0.6",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
72
72
|
},
|
|
73
73
|
"sideEffects": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "f10fc26fb792b5b7ab5e57479cd94a64c4270837"
|
|
75
75
|
}
|
package/types/models/folder.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export namespace MAGIC_FOLDERS {
|
|
|
6
6
|
const NOTES: string;
|
|
7
7
|
const HOME: string;
|
|
8
8
|
const PAPERS: string;
|
|
9
|
+
const COACH_CO2: string;
|
|
9
10
|
}
|
|
10
11
|
export function ensureMagicFolder(client: CozyClient, id: string, path: string): Promise<IOCozyFolder>;
|
|
11
12
|
export function createFolderWithReference(client: CozyClient, path: string, document: CozyClientDocument): Promise<IOCozyFolder>;
|